swig-2.0.12/0000775000175000017500000000000012275777517012451 5ustar williamwilliamswig-2.0.12/LICENSE0000664000175000017500000000206212275776201013443 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-2.0.12/ANNOUNCE0000664000175000017500000000220012275776201013561 0ustar williamwilliam*** ANNOUNCE: SWIG 2.0.12 (9 Feb 2014) *** http://www.swig.org We're pleased to announce SWIG-2.0.12, 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, 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-2.0.12.tar.gz A Windows version is also available at http://prdownloads.sourceforge.net/swig/swigwin-2.0.12.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-2.0.12/configure.ac0000664000175000017500000022153512275776201014734 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],[2.0.12],[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 Microsofts attempt at deprecating 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 - ], , not_really_there="yes") else if test ! -r $x_includes/X11/Intrinsic.h; then not_really_there="yes" fi fi fi if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then AC_MSG_CHECKING(for X11 header files) XINCLUDES="# no special path needed" AC_TRY_CPP([#include ], , XINCLUDES="") if test -z "$XINCLUDES"; then dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" for i in $dirs ; do if test -r $i/X11/Intrinsic.h; then XINCLUDES=" -I$i" break fi done fi AC_MSG_RESULT($XINCLUDES) else if test "$x_includes" != ""; then XINCLUDES=-I$x_includes else XINCLUDES="# no special path needed" fi fi if test -z "$XINCLUDES"; then AC_MSG_RESULT(couldn't find any!) XINCLUDES="# no include files found" fi if test "$no_x" = yes; then AC_MSG_CHECKING(for X11 libraries) XLIBSW= dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/X11R6/lib /usr/lib/X11R6 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" for i in $dirs ; do if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then AC_MSG_RESULT($i) XLIBSW="-L$i -lX11" break fi done else if test "$x_libraries" = ""; then XLIBSW=-lX11 else XLIBSW="-L$x_libraries -lX11" fi fi if test -z "$XLIBSW" ; then AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow) fi if test -z "$XLIBSW" ; then AC_MSG_RESULT(couldn't find any! Using -lX11.) XLIBSW=-lX11 fi AC_SUBST(XINCLUDES) AC_SUBST(XLIBSW) 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 doesn't contain tclConfig.sh]) fi fi # check in a few common install locations if test x"${TCLCONFIG}" = x ; then for i in `ls -d /usr/lib/ 2>/dev/null` \ `ls -d -r /usr/lib/tcl*/ 2>/dev/null` \ `ls -d /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 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 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 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} "`${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} "`${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/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 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=none for i in $dirs; do if test -r $i/ruby.h; then AC_MSG_RESULT($i) RUBYINCLUDE="-I$i" break fi done if test x"$RUBYARCH" != x""; then RUBYINCLUDE="-I$RUBYDIR -I$RUBYDIR/$RUBYARCH" fi if test "$RUBYINCLUDE" = none; then RUBYINCLUDE="-I$RUBYDIR" AC_MSG_RESULT(could not locate ruby.h...using $RUBYINCLUDE) 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) RUBYINCLUDE="-I$RUBYDIR" RUBYLIB="$RUBYDIR" 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) RUBYINCLUDE="-I/usr/local/lib/ruby/1.4/arch" RUBYLIB="/usr/local/lib/ruby/1.4/arch" RUBYLINK="-lruby -lm" 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"; 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 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 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 -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'` if test "$go_version" -lt 470; then AC_MSG_RESULT([yes - minimum version is 4.7.0]) 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 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" fi fi fi AC_SUBST(GOGCC) AC_SUBST(GO) AC_SUBST(GOC) AC_SUBST(GO1) 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" ; 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_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 \ Source/Makefile \ Examples/Makefile \ Examples/xml/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/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 \ Lib/ocaml/swigp4.ml ]) AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) AC_CONFIG_FILES([CCache/ccache_swig_config.h]) AC_OUTPUT dnl configure.ac ends here swig-2.0.12/RELEASENOTES0000664000175000017500000003405312275776201014257 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-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-2.0.12/README0000664000175000017500000001202612275776201013317 0ustar williamwilliamSWIG (Simplified Wrapper and Interface Generator) Version: 2.0.12 (9 Feb 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-2.0.12/.travis.yml0000664000175000017500000000400112275776201014542 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=lua - compiler: gcc env: SWIGLANG=octave SWIGJOBS=-j4 - compiler: gcc env: SWIGLANG=perl5 - compiler: gcc env: SWIGLANG=php - compiler: gcc env: SWIGLANG=python - compiler: gcc env: SWIGLANG=python PY3=1 - compiler: gcc env: SWIGLANG=ruby - compiler: gcc env: SWIGLANG=tcl allow_failures: # None before_install: - lsb_release -a - uname -a - sudo apt-get -qq update - time sudo apt-get -qq install libboost-dev - 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" = "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"; then sudo apt-get install python3-dev; fi - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi script: - export PS4="+ " #Temporary workaround bug in Travis build environment - ./autogen.sh && ./configure - make -s $SWIGJOBS - if test -z "$SWIGLANG"; then make -s check-ccache; fi - ./swig -version - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi branches: only: - master - maintenance-2.0 swig-2.0.12/Lib/0000775000175000017500000000000012275777517013157 5ustar williamwilliamswig-2.0.12/Lib/allkw.swg0000664000175000017500000000130112275776201014773 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 check 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 separete languagekw.swg file, and add it here. */ %include %include %include %include %include %include %include %include %include %include %include #endif //__Lib_allkw_swg__ swig-2.0.12/Lib/xml/0000775000175000017500000000000012275776201013744 5ustar williamwilliamswig-2.0.12/Lib/xml/xml.swg0000664000175000017500000000002512275776201015263 0ustar williamwilliam/* nothing special */swig-2.0.12/Lib/xml/typemaps.i0000664000175000017500000000026312275776201015761 0ustar williamwilliam// -------------------------------------------------------------------- // Empty file for %include to work // -------------------------------------------------------------------- swig-2.0.12/Lib/r/0000775000175000017500000000000012275776201013405 5ustar williamwilliamswig-2.0.12/Lib/r/rcontainer.swg0000664000175000017500000001260012275776201016272 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-2.0.12/Lib/r/std_map.i0000664000175000017500000000010312275776201015200 0ustar williamwilliam%fragment("StdMapTraits","header") %{ %} %include swig-2.0.12/Lib/r/std_pair.i0000664000175000017500000000010412275776201015357 0ustar williamwilliam%fragment("StdPairTraits","header") %{ %} %include swig-2.0.12/Lib/r/typemaps.i0000664000175000017500000000004112275776201015414 0ustar williamwilliam%include swig-2.0.12/Lib/r/std_container.i0000664000175000017500000000007112275776201016411 0ustar williamwilliam%include %include swig-2.0.12/Lib/r/r.swg0000664000175000017500000001405512275776201014375 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-2.0.12/Lib/r/cdata.i0000664000175000017500000000003612275776201014632 0ustar williamwilliam%include swig-2.0.12/Lib/r/boost_shared_ptr.i0000664000175000017500000003651412275776201017131 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-2.0.12/Lib/r/rrun.swg0000664000175000017500000002164712275776201015127 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-2.0.12/Lib/r/std_common.i0000664000175000017500000000434312275776201015725 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-2.0.12/Lib/r/std_list.i0000664000175000017500000000024712275776201015407 0ustar williamwilliam#define %swig_list_methods(Type...) %swig_sequence_methods(Type) #define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); %include swig-2.0.12/Lib/r/std_alloc.i0000664000175000017500000000003212275776201015516 0ustar williamwilliam%include swig-2.0.12/Lib/r/exception.i0000664000175000017500000000034112275776201015553 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-2.0.12/Lib/r/rfragments.swg0000664000175000017500000001110512275776201016275 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-2.0.12/Lib/r/rtype.swg0000664000175000017500000001757512275776201015311 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") SWIGTYPE * "$R_class"; %typemap("rtype") SWIGTYPE *const "$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 *const %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, 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[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 = 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 *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-2.0.12/Lib/r/srun.swg0000664000175000017500000000747512275776201015133 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-2.0.12/Lib/r/ropers.swg0000664000175000017500000000422412275776201015443 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-2.0.12/Lib/r/rstdcommon.swg0000664000175000017500000001220712275776201016316 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-2.0.12/Lib/r/std_vector.i0000664000175000017500000005333412275776201015743 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-2.0.12/Lib/r/std_string.i0000664000175000017500000000004312275776201015734 0ustar williamwilliam%include swig-2.0.12/Lib/r/std_except.i0000664000175000017500000000004312275776201015716 0ustar williamwilliam%include swig-2.0.12/Lib/r/stl.i0000664000175000017500000000023512275776201014361 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-2.0.12/Lib/r/std_deque.i0000664000175000017500000000003112275776201015526 0ustar williamwilliam%includeswig-2.0.12/Lib/r/rkw.swg0000664000175000017500000000102012275776201014723 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-2.0.12/Lib/pike/0000775000175000017500000000000012275776201014074 5ustar williamwilliamswig-2.0.12/Lib/pike/pikekw.swg0000664000175000017500000000152112275776201016107 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-2.0.12/Lib/pike/pike.swg0000664000175000017500000002221512275776201015550 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 [] "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) { 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 [] "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) "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 &, 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 [] { 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]) } /* 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-2.0.12/Lib/pike/pikerun.swg0000664000175000017500000000403712275776201016277 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-2.0.12/Lib/pike/std_string.i0000664000175000017500000000310712275776201016427 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-2.0.12/Lib/d/0000775000175000017500000000000012275776201013367 5ustar williamwilliamswig-2.0.12/Lib/d/dexception.swg0000664000175000017500000000222612275776201016255 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-2.0.12/Lib/d/director.swg0000664000175000017500000000231312275776201015723 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that D proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus #if defined(DEBUG_DIRECTOR_OWNED) #include #endif #include namespace Swig { // Director base class – not used in D directors. class Director { }; // Base class for director exceptions. class DirectorException { protected: std::string swig_msg; public: DirectorException(const char* msg) : swig_msg(msg) { } DirectorException(const std::string &msg) : swig_msg(msg) { } const std::string& what() const { return swig_msg; } virtual ~DirectorException() { } }; // Exception which is thrown when attempting to call a pure virtual method // from D code thorugh the director layer. class DirectorPureVirtualException : public Swig::DirectorException { public: DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) { } }; } #endif /* __cplusplus */ swig-2.0.12/Lib/d/ddirectives.swg0000664000175000017500000000072212275776201016417 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-2.0.12/Lib/d/std_map.i0000664000175000017500000000332112275776201015167 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-2.0.12/Lib/d/wrapperloader.swg0000664000175000017500000001732712275776201016772 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-2.0.12/Lib/d/dvoid.swg0000664000175000017500000000105712275776201015221 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-2.0.12/Lib/d/std_pair.i0000664000175000017500000000127712275776201015355 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-2.0.12/Lib/d/typemaps.i0000664000175000017500000002547712275776201015422 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-2.0.12/Lib/d/boost_shared_ptr.i0000664000175000017500000002003612275776201017103 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-2.0.12/Lib/d/d.swg0000664000175000017500000000250512275776201014336 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-2.0.12/Lib/d/carrays.i0000664000175000017500000000501712275776201015210 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-2.0.12/Lib/d/std_common.i0000664000175000017500000000014612275776201015704 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-2.0.12/Lib/d/dmemberfunctionpointers.swg0000664000175000017500000000526212275776201021063 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"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register 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) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register 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-2.0.12/Lib/d/dkw.swg0000664000175000017500000000456512275776201014710 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-2.0.12/Lib/d/dhead.swg0000664000175000017500000002314012275776201015156 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-2.0.12/Lib/d/std_shared_ptr.i0000664000175000017500000000010412275776201016541 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-2.0.12/Lib/d/std_vector.i0000664000175000017500000004010312275776201015713 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-2.0.12/Lib/d/std_string.i0000664000175000017500000000604512275776201015726 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-2.0.12/Lib/d/dswigtype.swg0000664000175000017500000001213412275776201016131 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-2.0.12/Lib/d/std_except.i0000664000175000017500000000355512275776201015713 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-2.0.12/Lib/d/dprimitives.swg0000664000175000017500000001077612275776201016463 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-2.0.12/Lib/d/dstrings.swg0000664000175000017500000000501112275776201015743 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-2.0.12/Lib/d/stl.i0000664000175000017500000000054512275776201014347 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/d/std_deque.i0000664000175000017500000000003412275776201015513 0ustar williamwilliam%include swig-2.0.12/Lib/d/cpointer.i0000664000175000017500000000663212275776201015373 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-2.0.12/Lib/d/doperators.swg0000664000175000017500000001767012275776201016306 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-2.0.12/Lib/d/dclassgen.swg0000664000175000017500000000703712275776201016063 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-2.0.12/Lib/d/denums.swg0000664000175000017500000000357512275776201015416 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-2.0.12/Lib/modula3/0000775000175000017500000000000012275776201014510 5ustar williamwilliamswig-2.0.12/Lib/modula3/modula3.swg0000664000175000017500000010267512275776201016611 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) 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(out) 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 (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 (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 *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ cPtr := $imcall; RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner); %} /* Properties */ %typemap(m3varin) 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 *, 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 (CLASS::*) "" %typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public" %typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;" %typemap(m3interfaces) SWIGTYPE "IDisposable" %typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(m3ptrconstructormodifiers) 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 (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]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-2.0.12/Lib/modula3/typemaps.i0000664000175000017500000001032112275776201016521 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-2.0.12/Lib/modula3/modula3head.swg0000664000175000017500000000374612275776201017432 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-2.0.12/Lib/pointer.i0000664000175000017500000000044612275776201015002 0ustar williamwilliam/* ----------------------------------------------------------------------------- * pointer.i * ----------------------------------------------------------------------------- */ %echo "pointer.i is deprecated. Use cpointer.i instead." %echo "See http://www.swig.org/Doc1.3/Library.html" swig-2.0.12/Lib/python/0000775000175000017500000000000012275776201014465 5ustar williamwilliamswig-2.0.12/Lib/python/std_vectora.i0000664000175000017500000000147512275776201017163 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-2.0.12/Lib/python/director.swg0000664000175000017500000002555112275776201017032 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes that proxy * method calls from C++ to Python extensions. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PYTHON_HEADER_ #define SWIG_DIRECTOR_PYTHON_HEADER_ #ifdef __cplusplus #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 #include 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 { protected: std::string swig_msg; public: DirectorException(PyObject *error, const char* hdr ="", const char* msg ="") : swig_msg(hdr) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (strlen(msg)) { swig_msg += " "; swig_msg += msg; } if (!PyErr_Occurred()) { PyErr_SetString(error, getMessage()); } SWIG_PYTHON_THREAD_END_BLOCK; } const char *getMessage() const { 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.getMessage() << 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 Swig::DirectorException { public: DirectorTypeMismatchException(PyObject *error, const char* msg="") : Swig::DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char* msg="") : Swig::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 Swig::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 Swig::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 /* __cplusplus */ #endif swig-2.0.12/Lib/python/std_multiset.i0000664000175000017500000000207512275776201017363 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-2.0.12/Lib/python/README0000664000175000017500000000765612275776201015363 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-2.0.12/Lib/python/pyclasses.swg0000664000175000017500000000614612275776201017224 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-2.0.12/Lib/python/pythonkw.swg0000664000175000017500000000442612275776201017100 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-2.0.12/Lib/python/std_map.i0000664000175000017500000002313212275776201016267 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-2.0.12/Lib/python/pyrun.swg0000664000175000017500000014407312275776201016375 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) { register 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 { register 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 { register 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 = PyBaseObject_Type.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-2.0.12/Lib/python/pyhead.swg0000664000175000017500000001325512275776201016467 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-2.0.12/Lib/python/python.swg0000664000175000017500000000376312275776201016541 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-2.0.12/Lib/python/pytypemaps.swg0000664000175000017500000000576012275776201017432 0ustar williamwilliam/* ------------------------------------------------------------ * Typemap specializations for Python * ------------------------------------------------------------ */ /* ------------------------------------------------------------ * Fragment section * ------------------------------------------------------------ */ /* bool is dangerous in Python, change precedence */ #undef SWIG_TYPECHECK_BOOL %define SWIG_TYPECHECK_BOOL 10000 %enddef /* Include fundamental fragemt 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-2.0.12/Lib/python/std_iostream.i0000664000175000017500000000015312275776201017333 0ustar williamwilliamnamespace std { %callback(1) endl; %callback(1) ends; %callback(1) flush; } %include swig-2.0.12/Lib/python/pycomplex.swg0000664000175000017500000000430212275776201017226 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-2.0.12/Lib/python/argcargv.i0000664000175000017500000000512212275776201016433 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-2.0.12/Lib/python/wchar.i0000664000175000017500000000027212275776201015744 0ustar williamwilliam#ifdef __cplusplus %{ #include %} #else %{ #include %} #endif %types(wchar_t *); %include /* Enable swig wchar support. */ #define SWIG_WCHAR swig-2.0.12/Lib/python/std_pair.i0000664000175000017500000001345112275776201016450 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-2.0.12/Lib/python/std_complex.i0000664000175000017500000000072512275776201017164 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-2.0.12/Lib/python/pydocs.swg0000664000175000017500000000174212275776201016514 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) 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) 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-2.0.12/Lib/python/typemaps.i0000664000175000017500000001054512275776201016506 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-2.0.12/Lib/python/pytuplehlp.swg0000664000175000017500000000046412275776201017421 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-2.0.12/Lib/python/pyfragments.swg0000664000175000017500000000104712275776201017550 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-2.0.12/Lib/python/std_wstreambuf.i0000664000175000017500000000004012275776201017662 0ustar williamwilliam%include swig-2.0.12/Lib/python/std_container.i0000664000175000017500000000007212275776201017472 0ustar williamwilliam%include %include swig-2.0.12/Lib/python/cmalloc.i0000664000175000017500000000004012275776201016243 0ustar williamwilliam%include swig-2.0.12/Lib/python/cni.i0000664000175000017500000000005212275776201015405 0ustar williamwilliam%include %include swig-2.0.12/Lib/python/cstring.i0000664000175000017500000000004012275776201016302 0ustar williamwilliam%include swig-2.0.12/Lib/python/std_streambuf.i0000664000175000017500000000003712275776201017501 0ustar williamwilliam%include swig-2.0.12/Lib/python/attribute.i0000664000175000017500000000004212275776201016636 0ustar williamwilliam%include swig-2.0.12/Lib/python/implicit.i0000664000175000017500000000043712275776201016455 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-2.0.12/Lib/python/jstring.i0000664000175000017500000000333712275776201016325 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-2.0.12/Lib/python/pyerrors.swg0000664000175000017500000000312212275776201017072 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-2.0.12/Lib/python/cdata.i0000664000175000017500000000003612275776201015712 0ustar williamwilliam%include swig-2.0.12/Lib/python/ccomplex.i0000664000175000017500000000137312275776201016455 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-2.0.12/Lib/python/boost_shared_ptr.i0000664000175000017500000003766512275776201020221 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-2.0.12/Lib/python/pyapi.swg0000664000175000017500000000247312275776201016337 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-2.0.12/Lib/python/pystrings.swg0000664000175000017500000000561712275776201017262 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 return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int)); %#else return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); %#endif } } else { return SWIG_Py_Void(); } } } swig-2.0.12/Lib/python/builtin.swg0000664000175000017500000004027612275776201016666 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-2.0.12/Lib/python/defarg.swg0000664000175000017500000000220212275776201016433 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-2.0.12/Lib/python/carrays.i0000664000175000017500000000164412275776201016310 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-2.0.12/Lib/python/std_common.i0000664000175000017500000000442412275776201017005 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-2.0.12/Lib/python/std_list.i0000664000175000017500000000123412275776201016464 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-2.0.12/Lib/python/factory.i0000664000175000017500000000004012275776201016300 0ustar williamwilliam%include swig-2.0.12/Lib/python/std_alloc.i0000664000175000017500000000003312275776201016577 0ustar williamwilliam%include swig-2.0.12/Lib/python/exception.i0000664000175000017500000000021312275776201016631 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-2.0.12/Lib/python/pymacros.swg0000664000175000017500000000004612275776201017044 0ustar williamwilliam%include swig-2.0.12/Lib/python/std_carray.i0000664000175000017500000000305712275776201016777 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-2.0.12/Lib/python/cwstring.i0000664000175000017500000000007412275776201016500 0ustar williamwilliam%include %include swig-2.0.12/Lib/python/complex.i0000664000175000017500000000012012275776201016277 0ustar williamwilliam#ifdef __cplusplus %include #else %include #endif swig-2.0.12/Lib/python/std_set.i0000664000175000017500000000272212275776201016307 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-2.0.12/Lib/python/pythreads.swg0000664000175000017500000000546012275776201017217 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-2.0.12/Lib/python/std_wiostream.i0000664000175000017500000000024612275776201017525 0ustar williamwilliamnamespace std { %callback(1) wendl; %callback(1) wends; %callback(1) wflush; } %include %include %include swig-2.0.12/Lib/python/file.i0000664000175000017500000000201312275776201015552 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-2.0.12/Lib/python/embed.i0000664000175000017500000000521712275776201015720 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-2.0.12/Lib/python/std_multimap.i0000664000175000017500000000470112275776201017343 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-2.0.12/Lib/python/pyopers.swg0000664000175000017500000002162712275776201016720 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-2.0.12/Lib/python/std_shared_ptr.i0000664000175000017500000000010412275776201017637 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-2.0.12/Lib/python/pywstrings.swg0000664000175000017500000000377312275776201017452 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-2.0.12/Lib/python/std_ios.i0000664000175000017500000000010212275776201016274 0ustar williamwilliam%rename(ios_base_in) std::ios_base::in; %include swig-2.0.12/Lib/python/pyname_compat.i0000664000175000017500000001003412275776201017471 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-2.0.12/Lib/python/std_vector.i0000664000175000017500000000126312275776201017015 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-2.0.12/Lib/python/pybackward.swg0000664000175000017500000000221212275776201017333 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-2.0.12/Lib/python/std_string.i0000664000175000017500000000004312275776201017014 0ustar williamwilliam%include swig-2.0.12/Lib/python/pyiterators.swg0000664000175000017500000002462412275776201017604 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-2.0.12/Lib/python/pyabc.i0000664000175000017500000000064112275776201015736 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-2.0.12/Lib/python/std_basic_string.i0000664000175000017500000000540112275776201020160 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-2.0.12/Lib/python/std_except.i0000664000175000017500000000004312275776201016776 0ustar williamwilliam%include swig-2.0.12/Lib/python/pyinit.swg0000664000175000017500000003207512275776201016532 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_SetString(PyExc_NameError,"Unknown C global variable"); } 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_SetString(PyExc_NameError,"Unknown C global variable"); } 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-2.0.12/Lib/python/stl.i0000664000175000017500000000026612275776201015445 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-2.0.12/Lib/python/std_deque.i0000664000175000017500000000124612275776201016617 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-2.0.12/Lib/python/pyruntime.swg0000664000175000017500000000143312275776201017244 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-2.0.12/Lib/python/std_wios.i0000664000175000017500000000003212275776201016465 0ustar williamwilliam%include swig-2.0.12/Lib/python/pybuffer.i0000664000175000017500000000533612275776201016470 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-2.0.12/Lib/python/Makefile.in0000664000175000017500000000737312275776201016544 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 #SWIGLIB = -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 # X11 installation (needed if rebuilding Python + tkinter) XLIB = @XLIBSW@ XINCLUDE = @XINCLUDES@ # Python installation PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@ PY_LIB = @PYLIB@ # Tcl installation. Needed if rebuilding Python with tkinter. 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 these) #TKINTER = $(TCL_LIB) -ltk -ltcl $(XLIB) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(PY_LIB) @PYLINK@ $(TKINTER) $(LIBS) $(SYSLIBS) # 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) $(SWIGLIB) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-2.0.12/Lib/python/embed15.i0000664000175000017500000000546212275776201016070 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-2.0.12/Lib/python/std_sstream.i0000664000175000017500000000003512275776201017165 0ustar williamwilliam%include swig-2.0.12/Lib/python/std_wstring.i0000664000175000017500000000007712275776201017212 0ustar williamwilliam%include %include swig-2.0.12/Lib/python/pystdcommon.swg0000664000175000017500000001533712275776201017574 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 %{ #include 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) swig-2.0.12/Lib/python/pyuserdir.swg0000664000175000017500000001426712275776201017247 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-2.0.12/Lib/python/std_wsstream.i0000664000175000017500000000003612275776201017355 0ustar williamwilliam%include swig-2.0.12/Lib/python/pyprimtypes.swg0000664000175000017500000001630212275776201017616 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); } } %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; } } /* 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-2.0.12/Lib/python/pycontainer.swg0000664000175000017500000006667412275776201017565 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 ***/ %insert(header) %{ #include %} %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-2.0.12/Lib/python/std_char_traits.i0000664000175000017500000000004112275776201020007 0ustar williamwilliam%include swig-2.0.12/Lib/octave/0000775000175000017500000000000012275776201014425 5ustar williamwilliamswig-2.0.12/Lib/octave/octcontainer.swg0000664000175000017500000003767312275776201017657 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 %insert(header) %{ #include %} %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-2.0.12/Lib/octave/director.swg0000664000175000017500000000524312275776201016766 0ustar williamwilliam # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) 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-2.0.12/Lib/octave/octuserdir.swg0000664000175000017500000000342612275776201017337 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-2.0.12/Lib/octave/std_map.i0000664000175000017500000001104612275776201016230 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-2.0.12/Lib/octave/std_pair.i0000664000175000017500000000607412275776201016413 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-2.0.12/Lib/octave/std_complex.i0000664000175000017500000000072612275776201017125 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-2.0.12/Lib/octave/typemaps.i0000664000175000017500000000004112275776201016434 0ustar williamwilliam%include swig-2.0.12/Lib/octave/octrun.swg0000664000175000017500000012642512275776201016473 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"); static 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-2.0.12/Lib/octave/std_container.i0000664000175000017500000000007312275776201017433 0ustar williamwilliam%include %include swig-2.0.12/Lib/octave/cmalloc.i0000664000175000017500000000004012275776201016203 0ustar williamwilliam%include swig-2.0.12/Lib/octave/octfragments.swg0000664000175000017500000000000112275776201017632 0ustar williamwilliam swig-2.0.12/Lib/octave/attribute.i0000664000175000017500000000004212275776201016576 0ustar williamwilliam%include swig-2.0.12/Lib/octave/implicit.i0000664000175000017500000000043712275776201016415 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-2.0.12/Lib/octave/cdata.i0000664000175000017500000000003612275776201015652 0ustar williamwilliam%include swig-2.0.12/Lib/octave/boost_shared_ptr.i0000664000175000017500000003655012275776201020151 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-2.0.12/Lib/octave/carrays.i0000664000175000017500000000020112275776201016234 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__) %enddef %include swig-2.0.12/Lib/octave/std_common.i0000664000175000017500000000443512275776201016747 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-2.0.12/Lib/octave/std_list.i0000664000175000017500000000124512275776201016426 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-2.0.12/Lib/octave/octruntime.swg0000664000175000017500000002466112275776201017351 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-2.0.12/Lib/octave/factory.i0000664000175000017500000000004012275776201016240 0ustar williamwilliam%include swig-2.0.12/Lib/octave/octtypemaps.swg0000664000175000017500000000463112275776201017523 0ustar williamwilliam // Include fundamental fragemt 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-2.0.12/Lib/octave/std_alloc.i0000664000175000017500000000003312275776201016537 0ustar williamwilliam%include swig-2.0.12/Lib/octave/exception.i0000664000175000017500000000021312275776201016571 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-2.0.12/Lib/octave/std_carray.i0000664000175000017500000000306512275776201016736 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-2.0.12/Lib/octave/octprimtypes.swg0000664000175000017500000001253712275776201017721 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-2.0.12/Lib/octave/octopers.swg0000664000175000017500000000515712275776201017015 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-2.0.12/Lib/octave/octave.swg0000664000175000017500000000033612275776201016432 0ustar williamwilliam%include %include %include %include %include %include %define %docstring %feature("docstring") %enddef swig-2.0.12/Lib/octave/std_vector.i0000664000175000017500000000127412275776201016757 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-2.0.12/Lib/octave/std_string.i0000664000175000017500000000004312275776201016754 0ustar williamwilliam%include swig-2.0.12/Lib/octave/std_basic_string.i0000664000175000017500000000441512275776201020124 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-2.0.12/Lib/octave/std_except.i0000664000175000017500000000004312275776201016736 0ustar williamwilliam%include swig-2.0.12/Lib/octave/octstdcommon.swg0000664000175000017500000001405212275776201017662 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-2.0.12/Lib/octave/stl.i0000664000175000017500000000026512275776201015404 0ustar williamwilliam/* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-2.0.12/Lib/octave/std_deque.i0000664000175000017500000000124712275776201016560 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-2.0.12/Lib/octave/octcomplex.swg0000664000175000017500000000450012275776201017323 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-2.0.12/Lib/octave/octiterators.swg0000664000175000017500000002164012275776201017674 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-2.0.12/Lib/octave/std_char_traits.i0000664000175000017500000000004112275776201017747 0ustar williamwilliam%include swig-2.0.12/Lib/swigrun.swg0000664000175000017500000004050612275776201015371 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) { register size_t l = 0; register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register 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 { register 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"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register 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) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register 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-2.0.12/Lib/constraints.i0000664000175000017500000001560712275776201015676 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-2.0.12/Lib/guile/0000775000175000017500000000000012275776201014251 5ustar williamwilliamswig-2.0.12/Lib/guile/guilemain.i0000664000175000017500000000203412275776201016374 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-2.0.12/Lib/guile/ports.i0000664000175000017500000000247012275776201015575 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-2.0.12/Lib/guile/guile_scm_run.swg0000664000175000017500000003404512275776201017634 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; SCM variable; module = SWIG_Guile_Init(); 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; SCM variable; 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-2.0.12/Lib/guile/std_pair.i0000664000175000017500000011751112275776201016236 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-2.0.12/Lib/guile/typemaps.i0000664000175000017500000003572212275776201016276 0ustar williamwilliam/* ----------------------------------------------------------------------------- * typemaps.i * * Guile-specific typemaps * ----------------------------------------------------------------------------- */ /* Pointers */ %typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); } %typemap(freearg) 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 [] { 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 [] { $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(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(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 [] { 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]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* typemaps.i ends here */ swig-2.0.12/Lib/guile/extra-install.list0000664000175000017500000000004712275776201017736 0ustar williamwilliam# see top-level Makefile.in common.scm swig-2.0.12/Lib/guile/list-vector.i0000664000175000017500000004350212275776201016702 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-2.0.12/Lib/guile/guile_scm.swg0000664000175000017500000000230612275776201016743 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-2.0.12/Lib/guile/pointer-in-out.i0000664000175000017500000000637512275776201017327 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-2.0.12/Lib/guile/common.scm0000664000175000017500000000452012275776201016246 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-2.0.12/Lib/guile/std_common.i0000664000175000017500000000110212275776201016557 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-2.0.12/Lib/guile/interpreter.i0000664000175000017500000000261512275776201016772 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-2.0.12/Lib/guile/std_vector.i0000664000175000017500000004100512275776201016577 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 */ T* x; 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 */ T* x; 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 */ T* x; 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 */ T* x; 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-2.0.12/Lib/guile/swigrun.i0000664000175000017500000000170512275776201016124 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-2.0.12/Lib/guile/std_except.i0000664000175000017500000000026612275776201016571 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-2.0.12/Lib/guile/stl.i0000664000175000017500000000054512275776201015231 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/guile/std_deque.i0000664000175000017500000000003412275776201016375 0ustar williamwilliam%include swig-2.0.12/Lib/guile/Makefile0000664000175000017500000000003612275776201015710 0ustar williamwilliam co: co RCS/*.i* RCS/*.swg* swig-2.0.12/Lib/guile/guile.i0000664000175000017500000000206412275776201015532 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-2.0.12/Lib/guile/cplusplus.i0000664000175000017500000000136312275776201016460 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-2.0.12/Lib/gcj/0000775000175000017500000000000012275776201013707 5ustar williamwilliamswig-2.0.12/Lib/gcj/cni.i0000664000175000017500000000202112275776201014625 0ustar williamwilliam%{ #include %} %include extern jobject JvAllocObject (jclass cls); extern jobject JvAllocObject (jclass cls, jsize sz); 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 (void* 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-2.0.12/Lib/gcj/cni.swg0000664000175000017500000000043712275776201015206 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cni.swg * ----------------------------------------------------------------------------- */ #ifdef SWIG #define __attribute__(...) %ignore class$; #pragma SWIG nowarn=313,402 %nodefaultdtor; #endif swig-2.0.12/Lib/gcj/javaprims.i0000664000175000017500000002670412275776201016066 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-2.0.12/Lib/go/0000775000175000017500000000000012275776201013551 5ustar williamwilliamswig-2.0.12/Lib/go/std_map.i0000664000175000017500000000333212275776201015353 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-2.0.12/Lib/go/std_pair.i0000664000175000017500000000131012275776201015523 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-2.0.12/Lib/go/typemaps.i0000664000175000017500000002312612275776201015571 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-2.0.12/Lib/go/cdata.i0000664000175000017500000000306112275776201014777 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. * ----------------------------------------------------------------------------- */ %{ typedef struct SWIGCDATA { char *data; int len; } SWIGCDATA; %} %typemap(gotype) SWIGCDATA %{ []byte %} %typemap(out) SWIGCDATA %{ $result.data = (char*)_swig_goallocate($1.len); memcpy($result.data, $1.data, $1.len); $result.len = (int)$1.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-2.0.12/Lib/go/std_common.i0000664000175000017500000000014512275776201016065 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-2.0.12/Lib/go/std_list.i0000664000175000017500000000170312275776201015551 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-2.0.12/Lib/go/exception.i0000664000175000017500000000025512275776201015723 0ustar williamwilliam%typemap(throws,noblock=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } %insert("runtime") %{ #define SWIG_exception(code, msg) _swig_gopanic(msg) %} swig-2.0.12/Lib/go/go.swg0000664000175000017500000003060712275776201014706 0ustar williamwilliam/* ------------------------------------------------------------ * go.swg * * Go configuration module. * ------------------------------------------------------------ */ /* 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" #if SWIGGO_LONG_TYPE_SIZE == 32 %typemap(gotype) long, const long & "int32" %typemap(gotype) unsigned long, const unsigned long & "uint32" #elif SWIGGO_LONG_TYPE_SIZE == 64 %typemap(gotype) long, const long & "int64" %typemap(gotype) unsigned long, const unsigned long & "uint64" #else #error "SWIGGO_LONG_TYPE_SIZE not 32 or 64" #endif %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 &, const unsigned long &, const long long &, const unsigned long long &, const float &, const double & %{ $1 = ($1_ltype)&$input; %} %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. */ #if SWIGGO_LONG_TYPE_SIZE == 32 %typemap(gotype) size_t, const size_t & %{int%} #else %typemap(gotype) size_t, const size_t & %{int64%} #endif %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; %} /* 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 [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 & "" #if SWIGGO_LONG_TYPE_SIZE == 32 %typecheck(SWIG_TYPECHECK_INT32) /* Go int32 */ long, const long & "" %typecheck(SWIG_TYPECHECK_INT32) /* Go uint32 */ unsigned long, const unsigned long & "" #endif %typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */ #if SWIGGO_LONG_TYPE_SIZE == 64 long, const long &, #endif long long, const long long & "" %typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */ #if SWIGGO_LONG_TYPE_SIZE == 64 unsigned long, const unsigned long &, #endif 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 *const&, SWIGTYPE [], SWIGTYPE (CLASS::*) "" /* Go keywords. */ %include %include swig-2.0.12/Lib/go/std_vector.i0000664000175000017500000000470212275776201016102 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 { const_reference 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-2.0.12/Lib/go/std_except.i0000664000175000017500000000226712275776201016074 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-2.0.12/Lib/go/stl.i0000664000175000017500000000044212275776201014525 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/go/std_deque.i0000664000175000017500000000003412275776201015675 0ustar williamwilliam%include swig-2.0.12/Lib/go/gokw.swg0000664000175000017500000000105312275776201015241 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-2.0.12/Lib/go/goruntime.swg0000664000175000017500000001144012275776201016304 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 SWIGCONCAT2(s1, s2) s1 ## s2 #define SWIGCONCAT1(s1, s2) SWIGCONCAT2(s1, s2) #define SwigCgocall SWIGCONCAT1(SWIGMODULE, SwigCgocall) #define SwigCgocallDone SWIGCONCAT1(SWIGMODULE, SwigCgocallDone) #define SwigCgocallBack SWIGCONCAT1(SWIGMODULE, SwigCgocallBack) #define SwigCgocallBackDone SWIGCONCAT1(SWIGMODULE, SwigCgocallBackDone) #define SWIG_GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC__PATH_LEVEL__) #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 void SwigCgocall() { SwigDoCgocall(); } void SwigCgocallDone() { SwigDoCgocallDone(); } void SwigCgocallBack() { SwigDoCgocallBack(); } void SwigCgocallBackDone() { SwigDoCgocallBackDone(); } #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 %insert(go_header) %{ import _ "runtime/cgo" import "unsafe" type _ unsafe.Pointer %} #else %insert(go_header) %{ import "syscall" import "unsafe" type _ syscall.Sockaddr type _ unsafe.Pointer %} #endif /* 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-2.0.12/Lib/wchar.i0000664000175000017500000000046512275776201014427 0ustar williamwilliam/* ----------------------------------------------------------------------------- * wchar.i * ----------------------------------------------------------------------------- */ /* wchar_t not supported, unless otherwise specified in the target language. */ #if defined(SWIG_WCHAR) #undef SWIG_WCHAR #endif swig-2.0.12/Lib/inttypes.i0000664000175000017500000000511212275776201015174 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); /* 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 #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 /* SWIGWORDSIZE32 */ #ifdef __cplusplus } #endif swig-2.0.12/Lib/linkruntime.c0000664000175000017500000000100012275776201015640 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-2.0.12/Lib/runtime.swg0000664000175000017500000000232412275776201015352 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-2.0.12/Lib/cmalloc.i0000664000175000017500000000446212275776201014736 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-2.0.12/Lib/cstring.i0000664000175000017500000000050412275776201014766 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-2.0.12/Lib/attribute.i0000664000175000017500000000076012275776201015324 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-2.0.12/Lib/swigerrors.swg0000664000175000017500000000076312275776201016102 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-2.0.12/Lib/lua/0000775000175000017500000000000012275776201013725 5ustar williamwilliamswig-2.0.12/Lib/lua/luatypemaps.swg0000664000175000017500000003223212275776201017015 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(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); } %} // out is simple %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&, 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_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]) } /* 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-2.0.12/Lib/lua/std_map.i0000664000175000017500000000333212275776201015527 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-2.0.12/Lib/lua/wchar.i0000664000175000017500000000207412275776201015206 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 *)malloc((len+1)*sizeof(wchar_t)); if (p==0) return 0; if (mbstowcs(p, str, len)==-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-2.0.12/Lib/lua/std_pair.i0000664000175000017500000000140112275776201015700 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-2.0.12/Lib/lua/typemaps.i0000664000175000017500000004575412275776201015760 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-2.0.12/Lib/lua/luaruntime.swg0000664000175000017500000000574412275776201016646 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; /* start with global table */ lua_pushglobaltable (L); /* SWIG's internal initalisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); #endif #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* add a global fn */ SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal); /* begin the module (its a table with the same name as the module) */ SWIG_Lua_module_begin(L,SWIG_name); /* add commands/functions */ for (i = 0; swig_commands[i].name; i++){ SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func); } /* add variables */ for (i = 0; swig_variables[i].name; i++){ SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set); } #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)); } } /* additional registration structs & classes in lua */ for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } #endif #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* constants */ SWIG_Lua_InstallConstants(L,swig_constants); #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-2.0.12/Lib/lua/carrays.i0000664000175000017500000000040012275776201015535 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-2.0.12/Lib/lua/std_common.i0000664000175000017500000000014612275776201016242 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-2.0.12/Lib/lua/_std_common.i0000664000175000017500000000477212275776201016412 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-2.0.12/Lib/lua/factory.i0000664000175000017500000000100712275776201015544 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-2.0.12/Lib/lua/std_vector.i0000664000175000017500000000601212275776201016252 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-2.0.12/Lib/lua/std_string.i0000664000175000017500000000632712275776201016267 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-2.0.12/Lib/lua/lua_fnptr.i0000664000175000017500000001026312275776201016073 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){ // swiglua_ref_clear(pref); /* just in case */ 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-2.0.12/Lib/lua/std_except.i0000664000175000017500000000352712275776201016250 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-2.0.12/Lib/lua/stl.i0000664000175000017500000000044312275776201014702 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/lua/std_deque.i0000664000175000017500000000003412275776201016051 0ustar williamwilliam%include swig-2.0.12/Lib/lua/luarun.swg0000664000175000017500000011533112275776201015761 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 (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) #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 #endif #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 /* ----------------------------------------------------------------------------- * 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 /* -------------------------------------------------------------------------- * 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; /* Constant information structure */ typedef struct { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_lua_const_info; typedef struct { const char *name; lua_CFunction method; } swig_lua_method; typedef struct { const char *name; lua_CFunction getmethod; lua_CFunction setmethod; } swig_lua_attribute; // Can be used to create namespaces. Currently used to // wrap class static methods/variables/constants typedef struct { const char *name; swig_lua_method *ns_methods; swig_lua_attribute *ns_attributes; swig_lua_const_info *ns_constants; } swig_lua_namespace; typedef struct swig_lua_class { const char *name; swig_type_info **type; lua_CFunction constructor; void (*destructor)(void *); swig_lua_method *methods; swig_lua_attribute *attributes; swig_lua_namespace cls_static; 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)) /* 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 */ } /* the module.get method used for getting linked data */ SWIGINTERN int SWIG_Lua_module_get(lua_State* L) { /* there should be 2 params passed in (1) table (not the meta table) (2) string name of the attribute printf("SWIG_Lua_module_get %p(%s) '%s'\n", lua_topointer(L,1),lua_typename(L,lua_type(L,1)), lua_tostring(L,2)); */ /* get the metatable */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) assert(lua_isrotable(L,1)); /* just in case */ #else assert(lua_istable(L,1)); /* default Lua action */ #endif lua_getmetatable(L,1); /* get the metatable */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) assert(lua_isrotable(L,-1)); /* just in case */ #else assert(lua_istable(L,-1)); #endif SWIG_Lua_get_table(L,".get"); /* get the .get table */ lua_remove(L,3); /* remove metatable */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) if (lua_isrotable(L,-1)) #else if (lua_istable(L,-1)) #endif { /* look for the key in the .get table */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); lua_remove(L,3); /* remove .get */ if (lua_iscfunction(L,-1)) { /* found it so call the fn & return its value */ lua_call(L,0,1); return 1; } lua_pop(L,1); /* remove the top */ } lua_pop(L,1); /* remove the .get */ lua_pushnil(L); /* return a nil */ return 1; } /* the module.set method used for setting linked data */ SWIGINTERN int SWIG_Lua_module_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 */ /* get the metatable */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) assert(lua_isrotable(L,1)); /* just in case */ #else assert(lua_istable(L,1)); /* default Lua action */ #endif lua_getmetatable(L,1); /* get the metatable */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) assert(lua_isrotable(L,-1)); /* just in case */ #else assert(lua_istable(L,-1)); #endif SWIG_Lua_get_table(L,".set"); /* get the .set table */ lua_remove(L,4); /* remove metatable */ #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) if (lua_isrotable(L,-1)) #else if (lua_istable(L,-1)) #endif { /* look for the key in the .set table */ lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); lua_remove(L,4); /* remove .set */ 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; } #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) else { return 0; // Exits stoically if an invalid key is initialized. } #endif } lua_settop(L,3); /* reset back to start */ /* we now have the table, key & new value, so just set directly */ lua_rawset(L,1); /* add direct */ return 0; } #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* registering a module in lua. Pushes the module table on the stack. */ SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name) { assert(lua_istable(L,-1)); /* just in case */ lua_pushstring(L,name); lua_newtable(L); /* the table */ /* add meta table */ lua_newtable(L); /* the meta table */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_module_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_module_set); lua_pushstring(L,".get"); lua_newtable(L); /* the .get table */ lua_rawset(L,-3); /* add .get into metatable */ lua_pushstring(L,".set"); lua_newtable(L); /* the .set table */ lua_rawset(L,-3); /* add .set into metatable */ lua_setmetatable(L,-2); /* sets meta table in module */ #ifdef SWIG_LUA_MODULE_GLOBAL /* If requested, install the module directly into the global namespace. */ lua_rawset(L,-3); /* add module into parent */ SWIG_Lua_get_table(L,name); /* get the table back out */ #else /* Do not install the module table as global name. The stack top has the module table with the name below. We pop the top and replace the name with it. */ lua_replace(L,-2); #endif } /* ending the register */ SWIGINTERN void SWIG_Lua_module_end(lua_State* L) { lua_pop(L,1); /* tidy stack (remove module) */ } /* adding a linked variable to the module */ SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn) { assert(lua_istable(L,-1)); /* just in case */ lua_getmetatable(L,-1); /* get the metatable */ assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_get_table(L,".get"); /* find the .get table */ assert(lua_istable(L,-1)); /* should be a table: */ SWIG_Lua_add_function(L,name,getFn); lua_pop(L,1); /* tidy stack (remove table) */ if (setFn) /* if there is a set fn */ { SWIG_Lua_get_table(L,".set"); /* find the .set table */ assert(lua_istable(L,-1)); /* should be a table: */ SWIG_Lua_add_function(L,name,setFn); lua_pop(L,1); /* tidy stack (remove table) */ } lua_pop(L,1); /* tidy stack (remove meta) */ } #endif /* adding a function module */ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn) { SWIG_Lua_add_function(L,name,fn); } /* ----------------------------------------------------------------------------- * global variable support code: namespaces * ----------------------------------------------------------------------------- */ 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 */ return 0; } SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration /* 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 = 0; assert(lua_istable(L,-1)); /* There must be table at the top of the stack */ SWIG_Lua_InstallConstants(L, ns->ns_constants); lua_getmetatable(L,-1); /* add fns */ for(i=0;ns->ns_attributes[i].name;i++){ SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_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;ns->ns_methods[i].name;i++){ SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method); } lua_pop(L,1); /* clear stack - remove metatble */ lua_pop(L,1); return 0; } /* helper function. creates namespace table and add it to module table */ SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns) { assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */ lua_checkstack(L,5); lua_pushstring(L, ns->name); 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 */ lua_rawset(L,-3); /* add namespace to module table */ return 0; } /* ----------------------------------------------------------------------------- * global variable support code: classes * ----------------------------------------------------------------------------- */ /* the class.get method, performs the lookup of class attributes */ SWIGINTERN int SWIG_Lua_class_get(lua_State* L) { /* there should be 2 params passed in (1) userdata (not the meta table) (2) string name of the attribute */ assert(lua_isuserdata(L,-2)); /* just in case */ lua_getmetatable(L,-2); /* get the meta table */ 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 */ /* 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_pushvalue(L,1); /* the userdata */ lua_call(L,1,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: if its 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 */ /* NEW: looks for the __getitem() fn this is a user provided get fn */ SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */ if (lua_iscfunction(L,-1)) /* if its there */ { /* found it so call the fn & return its value */ lua_pushvalue(L,1); /* the userdata */ lua_pushvalue(L,2); /* the parameter */ lua_call(L,2,1); /* 2 value in (userdata),1 out (result) */ lua_remove(L,-2); /* stack tidy, remove metatable */ return 1; } return 0; /* sorry not known */ } /* the class.set method, performs the lookup of class attributes */ 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 printf("SWIG_Lua_class_set %p(%s) '%s' %p(%s)\n", lua_topointer(L,1),lua_typename(L,lua_type(L,1)), lua_tostring(L,2), lua_topointer(L,3),lua_typename(L,lua_type(L,3)));*/ assert(lua_isuserdata(L,1)); /* just in case */ lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ 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,1); /* userdata */ lua_pushvalue(L,3); /* value */ lua_call(L,2,0); return 0; } lua_pop(L,1); /* remove the value */ } lua_pop(L,1); /* remove the value .set table */ /* 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,1); /* the userdata */ lua_pushvalue(L,2); /* the parameter */ lua_pushvalue(L,3); /* the value */ lua_call(L,3,0); /* 3 values in ,0 out */ lua_remove(L,-2); /* stack tidy, remove metatable */ return 1; } 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) */ assert(lua_isuserdata(L,1)); /* just in case */ unsigned long userData = (unsigned long)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"); const char* className = lua_tostring(L, -1); char output[256]; sprintf(output, "<%s userdata: %lX>", className, userData); lua_pushstring(L, (const char*)output); 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; } /* Constructor proxy. Used when class name entry in module is not class constructor, but special table instead. */ SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L) { /* unlimited number of parameters First one is our proxy table and we should remove it Other we should pass to real constructor */ assert(lua_istable(L,1)); lua_pushstring(L,".constructor"); lua_rawget(L,1); assert(!lua_isnil(L,-1)); lua_replace(L,1); /* replace our table with real constructor */ lua_call(L,lua_gettop(L)-1,1); return 1; } /* gets the swig class 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 */ lua_pushstring(L,"SWIG"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX); /* then get it */ lua_pushstring(L,"SWIG"); lua_rawget(L,LUA_REGISTRYINDEX); } } /* helper fn 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) */ } /* helper add a variable to a registered class */ SWIGINTERN void SWIG_Lua_add_class_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); } /* helper to recursively add class details (attributes & operations) */ SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss) { int i; /* call all the base classes first: we can then override these later: */ for(i=0;clss->bases[i];i++) { SWIG_Lua_add_class_details(L,clss->bases[i]); } /* add fns */ for(i=0;clss->attributes[i].name;i++){ SWIG_Lua_add_class_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].method); } lua_pop(L,1); /* tidy stack (remove table) */ /* add operator overloads these look ANY method which start with "__" and assume they are operator overloads & add them to the metatable (this might mess up is someone defines a method __gc (the destructor)*/ for(i=0;clss->methods[i].name;i++){ if (clss->methods[i].name[0]=='_' && clss->methods[i].name[1]=='_'){ SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method); } } } /* 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; } } } /* 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) { 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); SWIG_Lua_get_table(L,clss->name); // Get namespace table back 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) { SWIG_Lua_add_function(L,".constructor", clss->constructor); lua_getmetatable(L,-1); assert(lua_istable(L,-1)); /* just in case */ SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy); 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); } /* performs the entire class registration process */ SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) { SWIG_Lua_class_register_static(L,clss); SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->name); /* get the name */ lua_newtable(L); /* create the metatable */ /* add string of class name called ".type" */ lua_pushstring(L,".type"); lua_pushstring(L,clss->name); 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 tostring method for better output */ SWIG_Lua_add_function(L,"__tostring",SWIG_Lua_class_tostring); /* add it */ lua_rawset(L,-3); /* metatable into registry */ lua_pop(L,1); /* tidy stack (remove registry) */ SWIG_Lua_get_class_metatable(L,clss->name); SWIG_Lua_add_class_details(L,clss); /* recursive adding of details (atts & ops) */ lua_pop(L,1); /* tidy stack (remove class metatable) */ } /* ----------------------------------------------------------------------------- * 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))->name); 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; } /* 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_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; } /* ----------------------------------------------------------------------------- * 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 its lua_dostring() In lua 5.1.X its 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-2.0.12/Lib/lua/lua.swg0000664000175000017500000002110112275776201015223 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 /* ----------------------------------------------------------------------------- * 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 [] { SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor} // member function pointers %typemap(consttab) SWIGTYPE (CLASS::*) { SWIG_LUA_BINARY, (char *)"$symname", sizeof($type), 0, (void *)&$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-2.0.12/Lib/mzscheme/0000775000175000017500000000000012275776201014757 5ustar williamwilliamswig-2.0.12/Lib/mzscheme/mzrun.swg0000664000175000017500000003447712275776201016673 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-2.0.12/Lib/mzscheme/std_map.i0000664000175000017500000017617412275776201016600 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-2.0.12/Lib/mzscheme/std_pair.i0000664000175000017500000012541312275776201016744 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-2.0.12/Lib/mzscheme/typemaps.i0000664000175000017500000002374312275776201017004 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 [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); } /* C++ References */ #ifdef __cplusplus %typemap(in) SWIGTYPE &, const SWIGTYPE & { $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)"); } %typemap(out) SWIGTYPE &, const 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 [] { 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]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-2.0.12/Lib/mzscheme/std_common.i0000664000175000017500000000077712275776201017306 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-2.0.12/Lib/mzscheme/mzscheme.swg0000664000175000017500000000346412275776201017323 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-2.0.12/Lib/mzscheme/std_vector.i0000664000175000017500000004262312275776201017314 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-2.0.12/Lib/mzscheme/stl.i0000664000175000017500000000054412275776201015736 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/mzscheme/std_deque.i0000664000175000017500000000003412275776201017103 0ustar williamwilliam%include swig-2.0.12/Lib/mzscheme/Makefile0000664000175000017500000000003612275776201016416 0ustar williamwilliam co: co RCS/*.i* RCS/*.swg* swig-2.0.12/Lib/ocaml/0000775000175000017500000000000012275776201014237 5ustar williamwilliamswig-2.0.12/Lib/ocaml/director.swg0000664000175000017500000000570112275776201016577 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes that proxy * method calls from C++ to Ocaml extensions. * * ----------------------------------------------------------------------------- */ #ifdef __cplusplus #include # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) namespace Swig { /* base class for director exceptions */ class DirectorException { protected: std::string swig_msg; public: DirectorException(const char* msg="") { } const char *getMessage() const { return swig_msg.c_str(); } virtual ~DirectorException() {} }; /* type mismatch in the return value from a python method call */ class DirectorTypeMismatchException : public Swig::DirectorException { public: DirectorTypeMismatchException(const char* msg="") { } }; /* any python exception that occurs during a director method call */ class DirectorMethodException : public Swig::DirectorException {}; /* attempt to call a pure virtual method via a director method */ class DirectorPureVirtualException : public Swig::DirectorException { public: DirectorPureVirtualException(const char* 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); } } }; } #endif /* __cplusplus */ swig-2.0.12/Lib/ocaml/std_map.i0000664000175000017500000000444012275776201016042 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-2.0.12/Lib/ocaml/swig.mli0000664000175000017500000000324012275776201015712 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-2.0.12/Lib/ocaml/carray.i0000664000175000017500000000626412275776201015702 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-2.0.12/Lib/ocaml/swigp4.ml.in0000664000175000017500000001477412275776201016430 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-2.0.12/Lib/ocaml/std_pair.i0000664000175000017500000000131012275776201016211 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-2.0.12/Lib/ocaml/std_complex.i0000664000175000017500000000301412275776201016730 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-2.0.12/Lib/ocaml/typemaps.i0000664000175000017500000002152112275776201016254 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(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); } } #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)); } } #endif %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 & }; #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]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } swig-2.0.12/Lib/ocaml/extra-install.list0000664000175000017500000000013512275776201017722 0ustar williamwilliam# see top-level Makefile.in # libswigocaml is not needed anymore. swigp4.ml swig.mli swig.ml swig-2.0.12/Lib/ocaml/ocaml.i0000664000175000017500000000265212275776201015511 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-2.0.12/Lib/ocaml/class.swg0000664000175000017500000000326612275776201016075 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-2.0.12/Lib/ocaml/cstring.i0000664000175000017500000001366712275776201016077 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-2.0.12/Lib/ocaml/swig.ml0000664000175000017500000001111412275776201015540 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-2.0.12/Lib/ocaml/std_common.i0000664000175000017500000000102312275776201016547 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-2.0.12/Lib/ocaml/std_list.i0000664000175000017500000001034412275776201016240 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-2.0.12/Lib/ocaml/preamble.swg0000664000175000017500000000073112275776201016551 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-2.0.12/Lib/ocaml/libswigocaml.h0000664000175000017500000000070612275776201017067 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-2.0.12/Lib/ocaml/ocaml.swg0000664000175000017500000003406612275776201016065 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-2.0.12/Lib/ocaml/typecheck.i0000664000175000017500000001113712275776201016373 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 [] { 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-2.0.12/Lib/ocaml/std_vector.i0000664000175000017500000000530212275776201016565 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-2.0.12/Lib/ocaml/std_string.i0000664000175000017500000000620212275776201016571 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-2.0.12/Lib/ocaml/stl.i0000664000175000017500000000054512275776201015217 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/ocaml/std_deque.i0000664000175000017500000000132212275776201016364 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-2.0.12/Lib/ocaml/ocamlkw.swg0000664000175000017500000000205212275776201016415 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-2.0.12/Lib/ocaml/ocamldec.swg0000664000175000017500000001233212275776201016531 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-2.0.12/Lib/ocaml/typeregister.swg0000664000175000017500000000006712275776201017512 0ustar williamwilliamSWIGEXT void SWIG_init() { SWIG_InitializeModule(0); swig-2.0.12/Lib/cdata.i0000664000175000017500000000425212275776201014375 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); #else %echo "cdata.i module not supported." #endif /* ----------------------------------------------------------------------------- * %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, const void *indata, int inlen); swig-2.0.12/Lib/swiglabels.swg0000664000175000017500000000615012275776201016024 0ustar williamwilliam/* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) # define SWIGTEMPLATEDISAMBIGUATOR template # elif defined(__HP_aCC) /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ # define SWIGTEMPLATEDISAMBIGUATOR template # else # define SWIGTEMPLATEDISAMBIGUATOR # endif #endif /* inline attribute */ #ifndef SWIGINLINE # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline # else # define SWIGINLINE # endif #endif /* attribute recognised by some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 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-2.0.12/Lib/swigarch.i0000664000175000017500000000305412275776201015127 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-2.0.12/Lib/uffi/0000775000175000017500000000000012275776201014075 5ustar williamwilliamswig-2.0.12/Lib/uffi/uffi.swg0000664000175000017500000000621612275776201015555 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-2.0.12/Lib/csharp/0000775000175000017500000000000012275776201014424 5ustar williamwilliamswig-2.0.12/Lib/csharp/enumsimple.swg0000664000175000017500000000546112275776201017332 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 = *$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 = $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-2.0.12/Lib/csharp/csharphead.swg0000664000175000017500000003700412275776201017254 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); [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); [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 System.ApplicationException(message, SWIGPendingException.Retrieve())); } static void SetPendingArithmeticException(string message) { SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve())); } static void SetPendingDivideByZeroException(string message) { SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve())); } static void SetPendingIndexOutOfRangeException(string message) { SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); } static void SetPendingInvalidCastException(string message) { SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve())); } static void SetPendingInvalidOperationException(string message) { SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve())); } static void SetPendingIOException(string message) { SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve())); } static void SetPendingNullReferenceException(string message) { SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve())); } static void SetPendingOutOfMemoryException(string message) { SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); } static void SetPendingOverflowException(string message) { SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve())); } static void SetPendingSystemException(string message) { SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve())); } static void SetPendingArgumentException(string message, string paramName) { SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); } static void SetPendingArgumentNullException(string message, string paramName) { Exception e = SWIGPendingException.Retrieve(); if (e != null) message = message + " Inner Exception: " + e.Message; SWIGPendingException.Set(new System.ArgumentNullException(paramName, message)); } static void SetPendingArgumentOutOfRangeException(string message, string paramName) { Exception e = SWIGPendingException.Retrieve(); if (e != null) message = message + " Inner Exception: " + e.Message; SWIGPendingException.Set(new 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 { [ThreadStatic] private static 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(Exception e) { if (pendingException != null) throw new 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 Exception Retrieve() { 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); [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-2.0.12/Lib/csharp/director.swg0000664000175000017500000000220612275776201016761 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes so that C# proxy * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus #if defined(DEBUG_DIRECTOR_OWNED) #include #endif #include namespace Swig { /* Director base class - not currently used in C# directors */ class Director { }; /* Base class for director exceptions */ class DirectorException { protected: std::string swig_msg; public: DirectorException(const char* msg) : swig_msg(msg) { } DirectorException(const std::string &msg) : swig_msg(msg) { } const std::string& what() const { return swig_msg; } virtual ~DirectorException() { } }; /* Pure virtual method exception */ class DirectorPureVirtualException : public Swig::DirectorException { public: DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) { } }; } #endif /* __cplusplus */ swig-2.0.12/Lib/csharp/std_map.i0000664000175000017500000002476212275776201016240 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) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case * the C# wrapper has only basic functionality. * 2) 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 > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\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; } } #if !SWIG_DOTNET_1 public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys { get { System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>(); int size = this.Count; if (size > 0) { IntPtr iter = create_iterator_begin(); for (int i = 0; i < size; i++) { keys.Add(get_next_key(iter)); } destroy_iterator(iter); } return keys; } } public System.Collections.Generic.ICollection<$typemap(cstype, T)> Values { get { System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new System.Collections.Generic.List<$typemap(cstype, T)>(); foreach (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) { vals.Add(pair.Value); } return vals; } } public void Add(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { Add(item.Key, item.Value); } public bool Remove(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (Contains(item)) { return Remove(item.Key); } else { return false; } } public bool Contains(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(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) { CopyTo(array, 0); } public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) { if (array == null) throw new ArgumentNullException("array"); if (arrayIndex < 0) throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); if (array.Rank > 1) throw new ArgumentException("Multi dimensional array.", "array"); if (arrayIndex+this.Count > array.Length) throw new ArgumentException("Number of elements to copy is too large."); System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new 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 System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i); } } System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { return new $csclassnameEnumerator(this); } System.Collections.IEnumerator 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 : System.Collections.IEnumerator, System.Collections.Generic.IEnumerator> { private $csclassname collectionRef; private 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 System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys); currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current public System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current { get { if (currentIndex == -1) throw new InvalidOperationException("Enumeration not started."); if (currentIndex > currentSize - 1) throw new InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new InvalidOperationException("Collection modified."); return (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject; } } // Type-unsafe IEnumerator.Current object 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 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 InvalidOperationException("Collection modified."); } } public void Dispose() { currentIndex = -1; currentObject = null; } } #endif %} 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-2.0.12/Lib/csharp/wchar.i0000664000175000017500000000611112275776201015701 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(IntPtr message); static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { return 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="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" %typemap(cstype) wchar_t * "string" %typemap(csin) wchar_t * "$csinput" %typemap(csout, excode=SWIGEXCODE) wchar_t * { string ret = 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-2.0.12/Lib/csharp/csharp.swg0000664000175000017500000010743312275776201016436 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. */ /* 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"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register 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) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register 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="IntPtr") SWIGTYPE "HandleRef" %typemap(cstype) SWIGTYPE "$&csclassname" %typemap(ctype) SWIGTYPE [] "void *" %typemap(imtype, out="IntPtr") SWIGTYPE [] "HandleRef" %typemap(cstype) SWIGTYPE [] "$csclassname" %typemap(ctype) SWIGTYPE * "void *" %typemap(imtype, out="IntPtr") SWIGTYPE * "HandleRef" %typemap(cstype) SWIGTYPE * "$csclassname" %typemap(ctype) SWIGTYPE & "void *" %typemap(imtype, out="IntPtr") SWIGTYPE & "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(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(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(directorin) SWIGTYPE & %{ $input = ($1_ltype) &$1; %} %typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)" %typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), 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 *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 [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 [] "$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 *, SWIGTYPE [] { IntPtr cPtr = $imcall; $csclassname ret = (cPtr == 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 (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 *, SWIGTYPE [] %{ get { IntPtr cPtr = $imcall; $csclassname ret = (cPtr == 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="IntPtr") SWIGTYPE *const& "HandleRef" %typemap(cstype) SWIGTYPE *const& "$*csclassname" %typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)" %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& { IntPtr cPtr = $imcall; $*csclassname ret = (cPtr == 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 IntPtr */ %typemap(ctype) void *VOID_INT_PTR "void *" %typemap(imtype) void *VOID_INT_PTR "IntPtr" %typemap(cstype) void *VOID_INT_PTR "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 { 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 (CLASS::*) "" %typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n" %typemap(csinterfaces) SWIGTYPE "IDisposable" %typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csinterfaces_derived) 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 HandleRef swigCPtr; protected bool swigCMemOwn; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private HandleRef swigCPtr; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} %enddef %define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes %typemap(csbody) TYPE *, TYPE &, TYPE [] %{ private HandleRef swigCPtr; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) { swigCPtr = new HandleRef(this, cPtr); } DEFAULTCTOR_VISIBILITY $csclassname() { swigCPtr = new HandleRef(null, IntPtr.Zero); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, 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 != IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } 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" %pragma(csharp) moduleimports=%{ using System; using System.Runtime.InteropServices; %} %pragma(csharp) imclassimports=%{ using System; using System.Runtime.InteropServices; %} /* Some ANSI C typemaps */ %apply unsigned long { size_t }; %apply const unsigned long & { const size_t & }; /* Array reference typemaps */ %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 : IDisposable { public readonly HandleRef swigCPtr; public SWIGStringMarshal(string str) { swigCPtr = new HandleRef(this, System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str)); } public virtual void Dispose() { System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle); GC.SuppressFinalize(this); } } %} %typemap(imtype, out="IntPtr") char *, char[ANY], char[] "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 = 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 = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode return ret; } %} */ swig-2.0.12/Lib/csharp/std_pair.i0000664000175000017500000000127712275776201016412 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-2.0.12/Lib/csharp/typemaps.i0000664000175000017500000002464612275776201016454 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="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="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="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-2.0.12/Lib/csharp/boost_shared_ptr.i0000664000175000017500000002430312275776201020141 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="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 > *& "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 > { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == 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 * { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == 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 { IntPtr cPtr = $imcall; $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode return ret; } %} %typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ get { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == 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 { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %} // Proxy classes (base classes, ie, not derived classes) %typemap(csbody) TYPE %{ private HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); base.Dispose(); } } %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-2.0.12/Lib/csharp/std_common.i0000664000175000017500000000014612275776201016741 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-2.0.12/Lib/csharp/enums.swg0000664000175000017500000000555212275776201016304 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 = *$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 = $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-2.0.12/Lib/csharp/arrays_csharp.i0000664000175000017500000001156212275776201017444 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="[In, MarshalAs(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="[Out, MarshalAs(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="[In, Out, MarshalAs(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[] "IntPtr" %typemap(cstype) CTYPE FIXED[] "CSTYPE[]" %typemap(csin, pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {", terminator=" }") CTYPE FIXED[] "(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-2.0.12/Lib/csharp/std_shared_ptr.i0000664000175000017500000000010412275776201017576 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-2.0.12/Lib/csharp/enumtypesafe.swg0000664000175000017500000001124212275776201017653 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 = *$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 = $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 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-2.0.12/Lib/csharp/std_vector.i0000664000175000017500000003452712275776201016765 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. * For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is * made to look and feel like a typesafe C# System.Collections.ArrayList. * * 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 > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n"; %typemap(cscode) std::vector< CTYPE > %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) throw new 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 ArgumentOutOfRangeException("Capacity"); reserve((uint)value); } } public int Count { get { return (int)size(); } } public bool IsSynchronized { get { return false; } } #if SWIG_DOTNET_1 public void CopyTo(System.Array array) #else public void CopyTo($typemap(cstype, CTYPE)[] array) #endif { CopyTo(0, array, 0, this.Count); } #if SWIG_DOTNET_1 public void CopyTo(System.Array array, int arrayIndex) #else public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex) #endif { CopyTo(0, array, arrayIndex, this.Count); } #if SWIG_DOTNET_1 public void CopyTo(int index, System.Array array, int arrayIndex, int count) #else public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count) #endif { if (array == null) throw new ArgumentNullException("array"); if (index < 0) throw new ArgumentOutOfRangeException("index", "Value is less than zero"); if (arrayIndex < 0) throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); if (count < 0) throw new ArgumentOutOfRangeException("count", "Value is less than zero"); if (array.Rank > 1) throw new ArgumentException("Multi dimensional array.", "array"); if (index+count > this.Count || arrayIndex+count > array.Length) throw new ArgumentException("Number of elements to copy is too large."); for (int i=0; i System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() { return new $csclassnameEnumerator(this); } #endif System.Collections.IEnumerator 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 : System.Collections.IEnumerator #if !SWIG_DOTNET_1 , System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> #endif { 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 InvalidOperationException("Enumeration not started."); if (currentIndex > currentSize - 1) throw new InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new InvalidOperationException("Collection modified."); return ($typemap(cstype, CTYPE))currentObject; } } // Type-unsafe IEnumerator.Current object 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 InvalidOperationException("Collection modified."); } } #if !SWIG_DOTNET_1 public void Dispose() { currentIndex = -1; currentObject = null; } #endif } %} 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-2.0.12/Lib/csharp/std_string.i0000664000175000017500000000614712275776201016766 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-2.0.12/Lib/csharp/csharpkw.swg0000664000175000017500000000320712275776201016772 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` /* 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); #undef CSHARPKW #endif //CSHARP_CSHARPKW_SWG_ swig-2.0.12/Lib/csharp/std_except.i0000664000175000017500000000411312275776201016737 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-2.0.12/Lib/csharp/stl.i0000664000175000017500000000054512275776201015404 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/csharp/std_deque.i0000664000175000017500000000003412275776201016550 0ustar williamwilliam%include swig-2.0.12/Lib/csharp/std_wstring.i0000664000175000017500000000664212275776201017155 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="[MarshalAs(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="[MarshalAs(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-2.0.12/Lib/csharp/boost_intrusive_ptr.i0000664000175000017500000005457212275776201020736 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="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 > *& "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 > { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == 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 * { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { IntPtr cPtr = $imcall; $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } // Base proxy classes %typemap(csbody) TYPE %{ private HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); base.Dispose(); } } // CONST version needed ???? also for C# %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef" %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "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 > { IntPtr cPtr = $imcall; return (cPtr == 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 * { IntPtr cPtr = $imcall; return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { IntPtr cPtr = $imcall; return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); } // Base proxy classes %typemap(csbody) TYPE %{ private HandleRef swigCPtr; private bool swigCMemOwnBase; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes %typemap(csbody_derived) TYPE %{ private HandleRef swigCPtr; private bool swigCMemOwnDerived; PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwnBase) { swigCMemOwnBase = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { if (swigCPtr.Handle != IntPtr.Zero) { if (swigCMemOwnDerived) { swigCMemOwnDerived = false; $imcall; } swigCPtr = new HandleRef(null, IntPtr.Zero); } GC.SuppressFinalize(this); base.Dispose(); } } // CONST version needed ???? also for C# %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef" %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef" %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef swig-2.0.12/Lib/carrays.i0000664000175000017500000000512212275776201014762 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-2.0.12/Lib/allegrocl/0000775000175000017500000000000012275776201015110 5ustar williamwilliamswig-2.0.12/Lib/allegrocl/allegrocl.swg0000664000175000017500000005727112275776201017612 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 & %{ (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 %{ (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)"; /* 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 &, 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 & "$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[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 & "$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]) } /* 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-2.0.12/Lib/allegrocl/inout_typemaps.i0000664000175000017500000001053312275776201020344 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-2.0.12/Lib/allegrocl/typemaps.i0000664000175000017500000000012712275776201017124 0ustar williamwilliam/* Unused for Allegro CL module */ %include "inout_typemaps.i" %include "longlongs.i" swig-2.0.12/Lib/allegrocl/std_list.i0000664000175000017500000001136112275776201017111 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-2.0.12/Lib/allegrocl/std_string.i0000664000175000017500000001502212275776201017442 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-2.0.12/Lib/allegrocl/longlongs.i0000664000175000017500000000312512275776201017265 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-2.0.12/Lib/chicken/0000775000175000017500000000000012275776201014550 5ustar williamwilliamswig-2.0.12/Lib/chicken/typemaps.i0000664000175000017500000002700312275776201016566 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-2.0.12/Lib/chicken/extra-install.list0000664000175000017500000000010212275776201020225 0ustar williamwilliamswigclosprefix.scm multi-generic.scm tinyclos-multi-generic.patch swig-2.0.12/Lib/chicken/chicken.swg0000664000175000017500000005330512275776201016704 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& }; %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 & { $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) 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 [] { 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); } /* 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 [] "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 [] { 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); } } /* ------------------------------------------------------------ * 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); } /* ------------------------------------------------------------ * ANSI C typemaps * ------------------------------------------------------------ */ %apply unsigned long { size_t }; /* ------------------------------------------------------------ * Various * ------------------------------------------------------------ */ /* Array reference typemaps */ %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-2.0.12/Lib/chicken/chickenrun.swg0000664000175000017500000002547212275776201017435 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 it's 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 it's 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-2.0.12/Lib/chicken/chickenkw.swg0000664000175000017500000000124612275776201017243 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-2.0.12/Lib/chicken/swigclosprefix.scm0000664000175000017500000000221612275776201020325 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-2.0.12/Lib/chicken/multi-generic.scm0000664000175000017500000001361412275776201020025 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-2.0.12/Lib/chicken/std_string.i0000664000175000017500000000452712275776201017112 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-2.0.12/Lib/chicken/tinyclos-multi-generic.patch0000664000175000017500000001311312275776201022176 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-2.0.12/Lib/exception.i0000664000175000017500000001743012275776201015321 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-2.0.12/Lib/cffi/0000775000175000017500000000000012275776201014053 5ustar williamwilliamswig-2.0.12/Lib/cffi/cffi.swg0000664000175000017500000002273412275776201015514 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 & "$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 & "$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 & "$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[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]) } /* 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-2.0.12/Lib/std/0000775000175000017500000000000012275776201013736 5ustar williamwilliamswig-2.0.12/Lib/std/std_vectora.i0000664000175000017500000000022312275776201016422 0ustar williamwilliam// // We keep this file only for backward compatibility, since std_vector.i // now uses the std::allocator parameter. // %include swig-2.0.12/Lib/std/std_multiset.i0000664000175000017500000000473712275776201016643 0ustar williamwilliam// // std::set // %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-2.0.12/Lib/std/README0000664000175000017500000000117212275776201014617 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-2.0.12/Lib/std/std_map.i0000664000175000017500000000711612275776201015544 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 #include #include %} // 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-2.0.12/Lib/std/std_iostream.i0000664000175000017500000002122512275776201016607 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-2.0.12/Lib/std/std_stack.i0000664000175000017500000000663412275776201016100 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-2.0.12/Lib/std/std_pair.i0000664000175000017500000000714012275776201015717 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-2.0.12/Lib/std/std_wstreambuf.i0000664000175000017500000000014612275776201017142 0ustar williamwilliam/* Provide 'std_streambuf.i' with wchar support. */ %include %include swig-2.0.12/Lib/std/std_container.i0000664000175000017500000000563012275776201016750 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-2.0.12/Lib/std/std_streambuf.i0000664000175000017500000000331512275776201016754 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-2.0.12/Lib/std/_std_deque.i0000664000175000017500000001050312275776201016223 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-2.0.12/Lib/std/std_common.i0000664000175000017500000001160112275776201016251 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 // %{ #include #include #include %} %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") %{ 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-2.0.12/Lib/std/std_list.i0000664000175000017500000000743012275776201015741 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-2.0.12/Lib/std/std_alloc.i0000664000175000017500000000373712275776201016066 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-2.0.12/Lib/std/std_set.i0000664000175000017500000000643212275776201015562 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-2.0.12/Lib/std/std_wiostream.i0000664000175000017500000000014412275776201016773 0ustar williamwilliam/* Provide 'std_iostream.i' with wchar support. */ %include %include swig-2.0.12/Lib/std/std_multimap.i0000664000175000017500000000625412275776201016621 0ustar williamwilliam// // std::map // %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-2.0.12/Lib/std/std_ios.i0000664000175000017500000001203212275776201015552 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-2.0.12/Lib/std/std_queue.i0000664000175000017500000000666612275776201016124 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-2.0.12/Lib/std/std_vector.i0000664000175000017500000001401112275776201016261 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-2.0.12/Lib/std/std_string.i0000664000175000017500000000033312275776201016267 0ustar williamwilliam%include /* plain strings */ namespace std { %std_comp_methods(basic_string); %naturalvar string; typedef basic_string string; } %template(string) std::basic_string; swig-2.0.12/Lib/std/std_basic_string.i0000664000175000017500000001453612275776201017442 0ustar williamwilliam%include %include %include %include %{ #include %} 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-2.0.12/Lib/std/std_except.i0000664000175000017500000000215212275776201016252 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-2.0.12/Lib/std/std_deque.i0000664000175000017500000000666012275776201016075 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-2.0.12/Lib/std/std_wios.i0000664000175000017500000000013212275776201015737 0ustar williamwilliam/* Provide 'std_ios.i' with wchar support. */ %include %include swig-2.0.12/Lib/std/std_sstream.i0000664000175000017500000001231312275776201016440 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-2.0.12/Lib/std/std_wstring.i0000664000175000017500000000037112275776201016460 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-2.0.12/Lib/std/std_carray.swg0000664000175000017500000000261012275776201016612 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-2.0.12/Lib/std/std_wsstream.i0000664000175000017500000000014212275776201016624 0ustar williamwilliam/* Provide 'std_sstream.i' with wchar support. */ %include %include swig-2.0.12/Lib/std/std_char_traits.i0000664000175000017500000000616612275776201017276 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-2.0.12/Lib/cwstring.i0000664000175000017500000000041112275776201015152 0ustar williamwilliam/* ----------------------------------------------------------------------------- * cwstring.i * ----------------------------------------------------------------------------- */ %echo "cwstring.i not implemented for this target" #define SWIG_CWSTRING_UNIMPL swig-2.0.12/Lib/swigwarnings.swg0000664000175000017500000001551612275776201016420 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 /* ----------------------------------------------------------------------------- * 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-2.0.12/Lib/intrusive_ptr.i0000664000175000017500000000537612275776201016246 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-2.0.12/Lib/swiginit.swg0000664000175000017500000001756712275776201015543 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 staticly 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-2.0.12/Lib/php/0000775000175000017500000000000012275776201013733 5ustar williamwilliamswig-2.0.12/Lib/php/director.swg0000664000175000017500000001051712275776201016274 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes that proxy * method calls from C++ to PHP extensions. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PHP_HEADER_ #define SWIG_DIRECTOR_PHP_HEADER_ #ifdef __cplusplus #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; int name_len = strlen(lc_fname); if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) { return false; } if (zend_hash_find(&(*ce)->function_table, lc_fname, name_len + 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 { protected: std::string swig_msg; public: DirectorException(int code, const char *hdr, const char* msg TSRMLS_DC) : swig_msg(hdr) { if (strlen(msg)) { swig_msg += " "; swig_msg += msg; } SWIG_ErrorCode() = code; SWIG_ErrorMsg() = 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 Swig::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 Swig::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 /* __cplusplus */ #endif swig-2.0.12/Lib/php/std_map.i0000664000175000017500000000453512275776201015543 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-2.0.12/Lib/php/globalvar.i0000664000175000017500000002155612275776201016067 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 & { 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) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($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) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($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 & { 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) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($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) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($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 & { 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-2.0.12/Lib/php/phprun.swg0000664000175000017500000002162712275776201016001 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(clientdata) #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(void *SWIGUNUSEDPARM(clientdata)) { 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-2.0.12/Lib/php/utils.i0000664000175000017500000000503512275776201015250 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) { 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; } zval *tmp; 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-2.0.12/Lib/php/std_pair.i0000664000175000017500000000131012275776201015705 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-2.0.12/Lib/php/typemaps.i0000664000175000017500000002414212275776201015752 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 ); } %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 ); } %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 ); } %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 ); } %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 ); } %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) char OUTPUT[ANY] { zval *o; MAKE_STD_ZVAL(o); ZVAL_STRINGL(o,temp$argnum,$1_dim0); t_output_helper( &$result, o ); } %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-2.0.12/Lib/php/const.i0000664000175000017500000000265312275776201015241 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 [] { zval *z_var; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); zend_constant c; c.value = *z_var; zval_copy_ctor(&c.value); size_t len = sizeof("$symname") - 1; 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-2.0.12/Lib/php/phpinit.swg0000664000175000017500000000130212275776201016124 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-2.0.12/Lib/php/std_common.i0000664000175000017500000000044212275776201016247 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; swig-2.0.12/Lib/php/factory.i0000664000175000017500000000604512275776201015561 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-2.0.12/Lib/php/phpkw.swg0000664000175000017500000003457512275776201015624 0ustar williamwilliam/* ----------------------------------------------------------------------------- * phpkw.swg * ----------------------------------------------------------------------------- */ #define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x` #define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x` #define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x` #define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x` #define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x` /* From http://aspn.activestate.com/ASPN/docs/PHP/reserved.html http://php.net/manual/en/reserved.keywords.php and reviewed by Olly Betts. Further updates from the PHP manual on php.net. */ /* We classify these as kw since PHP will not run if used globally. */ /* "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." */ /* case insensitive */ PHPKW(__halt_compiler); PHPKW(abstract); PHPKW(and); PHPKW(array); PHPKW(as); PHPKW(break); 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(for); PHPKW(foreach); PHPKW(function); PHPKW(global); PHPKW(goto); // As of PHP5.3 PHPKW(if); PHPKW(implements); PHPKW(include); // "Language construct" PHPKW(include_once); // "Language construct" PHPKW(instanceof); PHPKW(interface); PHPKW(isset); // "Language construct" PHPKW(list); // "Language construct" PHPKW(namespace); // As of PHP5.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(try); PHPKW(unset); // "Language construct" PHPKW(use); PHPKW(var); PHPKW(while); PHPKW(xor); // Compile-time constants PHPKW(__CLASS__); PHPKW(__DIR__); // As of PHP5.3 PHPKW(__FILE__); PHPKW(__FUNCTION__); PHPKW(__METHOD__); PHPKW(__NAMESPACE__); // As of PHP5.3 PHPKW(__LINE__); /* We classify these as built-in names since they conflict, but PHP still runs */ /* Type 1: case insensitive */ PHPBN1(__sleep); PHPBN1(__wakeup); PHPBN1(not); PHPBN1(parent); PHPBN1(virtual); PHPBN1(NULL); PHPBN1(TRUE); PHPBN1(FALSE); /* Type 2: case sensitive */ /* "Core Predefined Constants" from http://uk2.php.net/manual/en/reserved.constants.php */ PHPBN2(E_ALL); PHPBN2(E_ERROR); PHPBN2(E_PARSE); PHPBN2(E_WARNING); 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 PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3 PHPBN2(PHP_OS); PHPBN2(PHP_VERSION); PHPBN2(PHP_SAPI); PHPBN2(PHP_EOL); PHPBN2(PHP_INT_MAX); PHPBN2(PHP_INT_SIZE); PHPBN2(DEFAULT_INCLUDE_PATH); PHPBN2(PEAR_INSTALL_DIR); PHPBN2(PEAR_EXTENSION_DIR); PHPBN2(PHP_EXTENSION_DIR); PHPBN2(PHP_PREFIX); PHPBN2(PHP_BINDIR); 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(PHP_OUTPUT_HANDLER_START); PHPBN2(PHP_OUTPUT_HANDLER_CONT); PHPBN2(PHP_OUTPUT_HANDLER_END); PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3 /* 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://uk2.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 PHP5 */ PHPBN2(E_STRICT); PHPBN2(__COMPILER_HALT_OFFSET__); /* 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); /* Class names reserved by PHP */ /* case insensitive */ PHPCN(stdclass); PHPCN(__php_incomplete_class); PHPCN(directory); /* Added in PHP5 (this list apparently depends which extensions you load by default). */ PHPCN(parent); PHPCN(self); PHPCN(exception); PHPCN(php_user_filter); PHPCN(errorexception); 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). */ PHPFN(cos); PHPFN(sin); PHPFN(tan); PHPFN(acos); PHPFN(asin); PHPFN(atan); PHPFN(atan2); PHPFN(cosh); PHPFN(sinh); PHPFN(tanh); PHPFN(exp); PHPFN(log); PHPFN(log10); PHPFN(pow); PHPFN(sqrt); PHPFN(ceil); PHPFN(floor); PHPFN(fmod); PHPFN(min); PHPFN(max); #undef PHPKW #undef PHPBN1 #undef PHPBN2 #undef PHPCN #undef PHPFN swig-2.0.12/Lib/php/std_vector.i0000664000175000017500000000527312275776201016270 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; } const_reference 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_PP($input), Z_STRLEN_PP($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_PP($input), Z_STRLEN_PP($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-2.0.12/Lib/php/phppointers.i0000664000175000017500000000272312275776201016464 0ustar williamwilliam%define %pass_by_ref( TYPE, CONVERT_IN, CONVERT_OUT ) %typemap(in) 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-2.0.12/Lib/php/stl.i0000664000175000017500000000054512275776201014713 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/php/std_deque.i0000664000175000017500000000003412275776201016057 0ustar williamwilliam%include swig-2.0.12/Lib/php/php.swg0000664000175000017500000003161012275776201015245 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 *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&; %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, enum SWIGTYPE { ZVAL_LONG(return_value,$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 &, const enum SWIGTYPE & { ZVAL_LONG(return_value,*$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) 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 & %{ 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 & %{ 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 *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 [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]) } /* const pointers */ %apply SWIGTYPE * { SWIGTYPE *const } /* php keywords */ %include swig-2.0.12/Lib/windows.i0000664000175000017500000001005712275776201015013 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-2.0.12/Lib/clisp/0000775000175000017500000000000012275776201014256 5ustar williamwilliamswig-2.0.12/Lib/clisp/clisp.swg0000664000175000017500000000163712275776201016121 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-2.0.12/Lib/typemaps/0000775000175000017500000000000012275776201015006 5ustar williamwilliamswig-2.0.12/Lib/typemaps/README0000664000175000017500000000372512275776201015675 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-2.0.12/Lib/typemaps/factory.swg0000664000175000017500000000461112275776201017201 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-2.0.12/Lib/typemaps/carrays.swg0000664000175000017500000000517612275776201017205 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-2.0.12/Lib/typemaps/std_strings.swg0000664000175000017500000000366512275776201020105 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-2.0.12/Lib/typemaps/std_string.swg0000664000175000017500000000053612275776201017714 0ustar williamwilliam// // String // #ifndef SWIG_STD_BASIC_STRING #define SWIG_STD_STRING %include %{ #include %} namespace std { %naturalvar string; class string; } %typemaps_std_string(std::string, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STDSTRING)); #else %include #endif swig-2.0.12/Lib/typemaps/strings.swg0000664000175000017500000004416112275776201017227 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_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) Char [ANY], const Char[ANY] { size_t size = $1_dim0; %#ifndef SWIG_PRESERVE_CARRAY_SIZE while (size && ($1[size - 1] == '\0')) --size; %#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_FromCharPtrAndSize) Char [ANY], const Char [ANY] { size_t size = $1_dim0; %#ifndef SWIG_PRESERVE_CARRAY_SIZE while (size && ($1[size - 1] == '\0')) --size; %#endif %set_varoutput(SWIG_FromCharPtrAndSize($1, size)); } /* constant */ %typemap(constcode,fragment=#SWIG_FromCharPtrAndSize) Char [ANY], const Char [ANY] { size_t size = $value_dim0; %#ifndef SWIG_PRESERVE_CARRAY_SIZE while (size && ($value[size - 1] == '\0')) --size; %#endif %set_constant("$symname", SWIG_FromCharPtrAndSize($value,size)); } #if defined(SWIG_DIRECTOR_TYPEMAPS) /* directorin */ %typemap(directorin,fragment=#SWIG_FromCharPtrAndSize) Char [ANY], const Char [ANY] { size_t size = $1_dim0; %#ifndef SWIG_PRESERVE_CARRAY_SIZE while (size && ($1[size - 1] == '\0')) --size; %#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_FromCharPtrAndSize) Char [ANY], const Char[ANY] { size_t size = $1_dim0; %#ifndef SWIG_PRESERVE_CARRAY_SIZE while (size && ($1[size - 1] == '\0')) --size; %#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 --- * ------------------------------------------------------------ */ %define %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, 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)) { if ((csize == size + 1) && cptr && !(cptr[csize-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_As##CharName##Ptr, SWIG_From##CharName##Ptr, SWIG_As##CharName##Array, SWIG_NewCopyCharArray, SWIG_DeleteCharArray) %enddef /* ------------------------------------------------------------ * String typemaps and fragments, with default allocators * ------------------------------------------------------------ */ %define %typemaps_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, FragLimits, CHAR_MIN, CHAR_MAX) %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, %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_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %_typemap2_string(StringCode, CharCode, Char, CharName, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, SWIG_CharPtrLen, SWIG_NewCopyCharArray, SWIG_DeleteCharArray, FragLimits, CHAR_MIN, CHAR_MAX) %enddef swig-2.0.12/Lib/typemaps/cstrings.swg0000664000175000017500000002003612275776201017365 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-2.0.12/Lib/typemaps/string.swg0000664000175000017500000000104312275776201017034 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; } } %include %typemaps_string(%checkcode(STRING), %checkcode(CHAR), char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen, "", CHAR_MIN, CHAR_MAX) swig-2.0.12/Lib/typemaps/std_wstring.swg0000664000175000017500000000061312275776201020077 0ustar williamwilliam%include #ifndef SWIG_STD_BASIC_STRING #define SWIG_STD_WSTRING %include %{ #include #include %} namespace std { %naturalvar wstring; class wstring; } %typemaps_std_string(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, %checkcode(STDUNISTRING)); #else %include #endif swig-2.0.12/Lib/typemaps/cwstring.swg0000664000175000017500000000031712275776201017371 0ustar williamwilliam%include %include %typemaps_cstring(%cwstring, wchar_t, SWIG_AsWCharPtr, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtr, SWIG_FromWCharPtrAndSize); swig-2.0.12/Lib/typemaps/misctypes.swg0000664000175000017500000000072312275776201017552 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-2.0.12/Lib/typemaps/cdata.swg0000664000175000017500000000352012275776201016604 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-2.0.12/Lib/typemaps/valtypes.swg0000664000175000017500000001574312275776201017411 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-2.0.12/Lib/typemaps/primtypes.swg0000664000175000017500000002064012275776201017566 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-2.0.12/Lib/typemaps/cstring.swg0000664000175000017500000000024712275776201017204 0ustar williamwilliam%include %typemaps_cstring(%cstring, char, SWIG_AsCharPtr, SWIG_AsCharPtrAndSize, SWIG_FromCharPtr, SWIG_FromCharPtrAndSize); swig-2.0.12/Lib/typemaps/swigmacros.swg0000664000175000017500000001755112275776201017717 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 languges. Basic preprocessor macros: -------------------------- %arg(Arg) Safe argument wrap %str(Arg) Stringtify the argument %begin_block Begin a execution block %end_block End a execution block %block(Block) Execute Block as a excecution 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-2.0.12/Lib/typemaps/enumint.swg0000664000175000017500000000161212275776201017207 0ustar williamwilliam/* ------------------------------------------------------------ * Enums mapped as integer values * ------------------------------------------------------------ */ %apply int { 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(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-2.0.12/Lib/typemaps/swigtypemaps.swg0000664000175000017500000001157312275776201020273 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 languge, 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-2.0.12/Lib/typemaps/std_except.swg0000664000175000017500000000224212275776201017672 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-2.0.12/Lib/typemaps/implicit.swg0000664000175000017500000001133212275776201017342 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-2.0.12/Lib/typemaps/fragments.swg0000664000175000017500000001730412275776201017523 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("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-2.0.12/Lib/typemaps/inoutlist.swg0000664000175000017500000002241112275776201017562 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-2.0.12/Lib/typemaps/cpointer.swg0000664000175000017500000000627512275776201017365 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-2.0.12/Lib/typemaps/cmalloc.swg0000664000175000017500000000460612275776201017150 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-2.0.12/Lib/typemaps/swigobject.swg0000664000175000017500000000157612275776201017701 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-2.0.12/Lib/typemaps/exception.swg0000664000175000017500000000522612275776201017533 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"); } } */ %{ #include %} %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-2.0.12/Lib/typemaps/wstring.swg0000664000175000017500000000106712275776201017231 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; } } %include %typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR), wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen, "", WCHAR_MIN, WCHAR_MAX) swig-2.0.12/Lib/typemaps/ptrtypes.swg0000664000175000017500000001470012275776201017424 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-2.0.12/Lib/typemaps/typemaps.swg0000664000175000017500000001072412275776201017376 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-2.0.12/Lib/typemaps/traits.swg0000664000175000017500000001657512275776201017054 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 // %{ #include #include %} %fragment("Traits","header") { 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-2.0.12/Lib/typemaps/void.swg0000664000175000017500000000403012275776201016466 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-2.0.12/Lib/typemaps/attribute.swg0000664000175000017500000002257312275776201017544 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; } }; %} */ // // 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;// my newfree override" %extend Class { AttributeType AttributeName; } %enddef swig-2.0.12/Lib/typemaps/swigtype.swg0000664000175000017500000004543212275776201017413 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 /* 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[] { %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[ii] = $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[ii] = $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[ii] = 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)); } #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)); } /* 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); } #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) 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) 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); } /* 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))); } } #endif /* SWIG_DIRECTOR_TYPEMAPS */ /* ------------------------------------------------------------ * --- Constants --- * ------------------------------------------------------------ */ %typemap(constcode,noblock=1) 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) (...) { 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-2.0.12/Lib/swig.swg0000664000175000017500000005711412275776201014647 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 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 */ #define %nestedworkaround %feature("nestedworkaround") #define %nonestedworkaround %feature("nestedworkaround","0") #define %clearnestedworkaround %feature("nestedworkaround","") /* 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 clashings 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 %$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 /* ----------------------------------------------------------------------------- * Include all the warnings labels and macros * ----------------------------------------------------------------------------- */ %include /* ----------------------------------------------------------------------------- * 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 { } #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]; } } /* ----------------------------------------------------------------------------- * Overloading support * ----------------------------------------------------------------------------- */ /* * Function/method overloading support. This is done through typemaps, * but also involve 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 /* ----------------------------------------------------------------------------- * 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-2.0.12/Lib/stdint.i0000664000175000017500000000450012275776201014622 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-2.0.12/Lib/math.i0000664000175000017500000000404612275776201014253 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-2.0.12/Lib/perl5/0000775000175000017500000000000012275776201014173 5ustar williamwilliamswig-2.0.12/Lib/perl5/std_map.i0000664000175000017500000000444112275776201015777 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-2.0.12/Lib/perl5/perlprimtypes.swg0000664000175000017500000001674112275776201017645 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-2.0.12/Lib/perl5/perlrun.swg0000664000175000017500000003435712275776201016420 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) /* 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); if (!tc) { 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-2.0.12/Lib/perl5/std_pair.i0000664000175000017500000000127712275776201016161 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-2.0.12/Lib/perl5/typemaps.i0000664000175000017500000003075712275776201016223 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-2.0.12/Lib/perl5/extra-install.list0000664000175000017500000000006212275776201017655 0ustar williamwilliam# see top-level Makefile.in Makefile.pl noembed.h swig-2.0.12/Lib/perl5/perlinit.swg0000664000175000017500000000370412275776201016547 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-2.0.12/Lib/perl5/cmalloc.i0000664000175000017500000000004012275776201015751 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/cni.i0000664000175000017500000000022612275776201015116 0ustar williamwilliam%warnfilter(SWIGWARN_PARSE_KEYWORD) java::lang::ref; %{ #undef STATIC %} %include %{ #undef TRUE #define TRUE 1 %} %include swig-2.0.12/Lib/perl5/perlopers.swg0000664000175000017500000000352012275776201016730 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-2.0.12/Lib/perl5/cstring.i0000664000175000017500000000004012275776201016010 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/attribute.i0000664000175000017500000000004212275776201016344 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/jstring.i0000664000175000017500000000202612275776201016025 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-2.0.12/Lib/perl5/cdata.i0000664000175000017500000000003612275776201015420 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/perlfragments.swg0000664000175000017500000000105412275776201017566 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-2.0.12/Lib/perl5/perluserdir.swg0000664000175000017500000000004412275776201017253 0ustar williamwilliam#define %perlcode %insert("perl") swig-2.0.12/Lib/perl5/noembed.h0000664000175000017500000000305312275776201015756 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-2.0.12/Lib/perl5/carrays.i0000664000175000017500000000004112275776201016004 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/std_common.i0000664000175000017500000000115112275776201016505 0ustar williamwilliam/* ----------------------------------------------------------------------------- * std_common.i * * SWIG typemaps for STL - common utilities * ----------------------------------------------------------------------------- */ %include %apply size_t { std::size_t }; %{ #include 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-2.0.12/Lib/perl5/std_list.i0000664000175000017500000003405512275776201016201 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 #include #include %} // 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-2.0.12/Lib/perl5/factory.i0000664000175000017500000000004012275776201016006 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/reference.i0000664000175000017500000001611712275776201016311 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-2.0.12/Lib/perl5/exception.i0000664000175000017500000000021212275776201016336 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) } swig-2.0.12/Lib/perl5/perlerrors.swg0000664000175000017500000000154712275776201017123 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-2.0.12/Lib/perl5/perltypemaps.swg0000664000175000017500000000536112275776201017447 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 fragemt definitions */ %include /* Look for user fragments file. */ %include /* Perl fragments for primitive types */ %include /* Perl fragments for char* strings */ %include /* ------------------------------------------------------------ * Unified typemap section * ------------------------------------------------------------ */ /* No director supported in Perl */ #ifdef SWIG_DIRECTOR_TYPEMAPS #undef 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 (CLASS::*) { SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); } %typemap(varout) SWIGTYPE *const = SWIGTYPE *; swig-2.0.12/Lib/perl5/Makefile.pl0000664000175000017500000000126312275776201016247 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-2.0.12/Lib/perl5/perlruntime.swg0000664000175000017500000000050612275776201017264 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-2.0.12/Lib/perl5/perlmain.i0000664000175000017500000000370212275776201016156 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-2.0.12/Lib/perl5/std_vector.i0000664000175000017500000005446212275776201016534 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 #include #include %} // 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-2.0.12/Lib/perl5/perlstrings.swg0000664000175000017500000000262112275776201017272 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-2.0.12/Lib/perl5/std_except.i0000664000175000017500000000004312275776201016504 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/stl.i0000664000175000017500000000054412275776201015152 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/perl5/std_deque.i0000664000175000017500000000003412275776201016317 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/perl5.swg0000664000175000017500000000270412275776201015747 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-2.0.12/Lib/perl5/cpointer.i0000664000175000017500000000004112275776201016163 0ustar williamwilliam%include swig-2.0.12/Lib/perl5/Makefile.in0000664000175000017500000000745212275776201016250 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 staticly rebuild Perl #SWIGLIB = -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 # X11 installation (possibly needed if using Perl-Tk) XLIB = @XLIBSW@ XINCLUDE = @XINCLUDES@ # Perl installation PERL_INCLUDE = -I@PERL5EXT@ PERL_LIB = -L@PERL5EXT@ -lperl PERL_FLAGS = -Dbool=char -Dexplicit= # Tcl installation. If using Tk you might need this 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 these) #TK_LIB = $(TCL_LIB) -ltcl -ltk $(XLIB) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(PERL_LIB) $(TK_LIB) $(LIBS) $(SYSLIBS) # Static linking # 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) $(SWIGLIB) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-2.0.12/Lib/perl5/perlkw.swg0000664000175000017500000000743612275776201016233 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-2.0.12/Lib/perl5/perlhead.swg0000664000175000017500000000506612275776201016510 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-2.0.12/Lib/perl5/perlmacros.swg0000664000175000017500000000004412275776201017062 0ustar williamwilliam%include swig-2.0.12/Lib/swigrun.i0000664000175000017500000000040012275776201015006 0ustar williamwilliam/* ----------------------------------------------------------------------------- * swigrun.i * * Empty module (for now). Placeholder for runtime libs * ----------------------------------------------------------------------------- */ %module swigrun swig-2.0.12/Lib/swigwarn.swg0000664000175000017500000003231512275777517015546 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 /* -- 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_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 /* -- 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-2.0.12/Lib/std_except.i0000664000175000017500000000371712275776201015470 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-2.0.12/Lib/java/0000775000175000017500000000000012275776201014065 5ustar williamwilliamswig-2.0.12/Lib/java/enumsimple.swg0000664000175000017500000000501712275776201016770 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-2.0.12/Lib/java/java.swg0000664000175000017500000013316512275776201015541 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"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register 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) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register 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" /* 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(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(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(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(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), 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 *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 [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 [] "$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 *, 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 (CLASS::*) "" %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javainterfaces) 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 [] %{ 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]) } /* 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-2.0.12/Lib/java/director.swg0000664000175000017500000001445312275776201016431 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes that proxy * method calls from C++ to Java extensions. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus #if defined(DEBUG_DIRECTOR_OWNED) #include #endif 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); } }; } #endif /* __cplusplus */ swig-2.0.12/Lib/java/std_map.i0000664000175000017500000000444112275776201015671 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-2.0.12/Lib/java/javakw.swg0000664000175000017500000000236612275776201016101 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-2.0.12/Lib/java/std_pair.i0000664000175000017500000000131012275776201016037 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-2.0.12/Lib/java/typemaps.i0000664000175000017500000004122012275776201016100 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-2.0.12/Lib/java/enumtypeunsafe.swg0000664000175000017500000000524312275776201017663 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-2.0.12/Lib/java/std_common.i0000664000175000017500000000014612275776201016402 0ustar williamwilliam%include %apply size_t { std::size_t }; %apply const size_t& { const std::size_t& }; swig-2.0.12/Lib/java/various.i0000664000175000017500000001047312275776201015734 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-2.0.12/Lib/java/javahead.swg0000664000175000017500000001012512275776201016351 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-2.0.12/Lib/java/std_shared_ptr.i0000664000175000017500000000010412275776201017237 0ustar williamwilliam#define SWIG_SHARED_PTR_NAMESPACE std %include swig-2.0.12/Lib/java/enumtypesafe.swg0000664000175000017500000001110712275776201017314 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 "" %typemap(javabody) 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-2.0.12/Lib/java/std_vector.i0000664000175000017500000000512412275776201016415 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 { const_reference 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) { 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-2.0.12/Lib/java/std_except.i0000664000175000017500000000360412275776201016404 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-2.0.12/Lib/java/stl.i0000664000175000017500000000044312275776201015042 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/java/std_deque.i0000664000175000017500000000003412275776201016211 0ustar williamwilliam%include swig-2.0.12/Lib/java/std_wstring.i0000664000175000017500000001150512275776201016610 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-2.0.12/Lib/java/boost_intrusive_ptr.i0000664000175000017500000004727412275776201020400 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-2.0.12/Lib/stl.i0000664000175000017500000000037112275776201014121 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ #warning "stl.i not implemented for this target" #define SWIG_STL_UNIMPL swig-2.0.12/Lib/cpointer.i0000664000175000017500000000673712275776201015156 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-2.0.12/Lib/ruby/0000775000175000017500000000000012275776201014125 5ustar williamwilliamswig-2.0.12/Lib/ruby/rubystdautodoc.swg0000664000175000017500000000343312275776201017725 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-2.0.12/Lib/ruby/std_vectora.i0000664000175000017500000000166612275776201016625 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-2.0.12/Lib/ruby/rubyfragments.swg0000664000175000017500000000105012275776201017533 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-2.0.12/Lib/ruby/director.swg0000664000175000017500000002016412275776201016465 0ustar williamwilliam/* ----------------------------------------------------------------------------- * director.swg * * This file contains support for director classes that proxy * method calls from C++ to Ruby extensions. * ----------------------------------------------------------------------------- */ /* 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 #ifdef __cplusplus #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 { 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 (strlen(msg)) { 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: VALUE getType() const { return CLASS_OF(swig_error); } VALUE getError() const { return swig_error; } const std::string& getMessage() const { return swig_msg; } virtual ~DirectorException() {} }; /* 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.getMessage() << 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 Swig::DirectorException { public: DirectorTypeMismatchException(VALUE error, const char *msg="") : Swig::DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char *msg="") : Swig::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 Swig::DirectorException { public: DirectorMethodException(VALUE error) : Swig::DirectorException(error) { } DirectorMethodException(const char* msg = "") : Swig::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 Swig::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; } }; } #endif /* __cplusplus */ swig-2.0.12/Lib/ruby/std_multiset.i0000664000175000017500000000257312275776201017026 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-2.0.12/Lib/ruby/rubycomplex.swg0000664000175000017500000000742412275776201017227 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-2.0.12/Lib/ruby/std_map.i0000664000175000017500000002576012275776201015740 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-2.0.12/Lib/ruby/std_iostream.i0000664000175000017500000000034312275776201016774 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-2.0.12/Lib/ruby/rubystrings.swg0000664000175000017500000000304112275776201017240 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-2.0.12/Lib/ruby/rubyclasses.swg0000664000175000017500000002615112275776201017213 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-2.0.12/Lib/ruby/rubycontainer_extended.swg0000664000175000017500000000672412275776201021424 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-2.0.12/Lib/ruby/argcargv.i0000664000175000017500000000231312275776201016072 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-2.0.12/Lib/ruby/std_stack.i0000664000175000017500000000152512275776201016261 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-2.0.12/Lib/ruby/std_pair.i0000664000175000017500000001233312275776201016106 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-2.0.12/Lib/ruby/std_complex.i0000664000175000017500000000072712275776201016626 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-2.0.12/Lib/ruby/typemaps.i0000664000175000017500000002606212275776201016147 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-2.0.12/Lib/ruby/extra-install.list0000664000175000017500000000006512275776201017612 0ustar williamwilliam# see top-level Makefile.in Makefile.swig extconf.rb swig-2.0.12/Lib/ruby/std_container.i0000664000175000017500000000007412275776201017134 0ustar williamwilliam%include %include swig-2.0.12/Lib/ruby/rubyinit.swg0000664000175000017500000000004712275776201016515 0ustar williamwilliam%insert(initbeforefunc) "swiginit.swg" swig-2.0.12/Lib/ruby/cmalloc.i0000664000175000017500000000004012275776201015703 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/cni.i0000664000175000017500000000005212275776201015045 0ustar williamwilliam%include %include swig-2.0.12/Lib/ruby/ruby.swg0000664000175000017500000000513512275776201015634 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-2.0.12/Lib/ruby/cstring.i0000664000175000017500000000004012275776201015742 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/rubyiterators.swg0000664000175000017500000005444712275776201017603 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-2.0.12/Lib/ruby/rubystdcommon.swg0000664000175000017500000001201512275776201017553 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-2.0.12/Lib/ruby/std_streambuf.i0000664000175000017500000000003712275776201017141 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/attribute.i0000664000175000017500000000004212275776201016276 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/jstring.i0000664000175000017500000000167012275776201015763 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-2.0.12/Lib/ruby/rubykw.swg0000664000175000017500000000223112275776201016170 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-2.0.12/Lib/ruby/cdata.i0000664000175000017500000000003612275776201015352 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/rubycontainer.swg0000664000175000017500000006474112275776201017547 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 ***/ %insert(header) %{ #include %} %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" ); } VALUE r = Qnil; 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-2.0.12/Lib/ruby/std_functors.i0000664000175000017500000000140012275776201017007 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-2.0.12/Lib/ruby/carrays.i0000664000175000017500000000020112275776201015734 0ustar williamwilliam%define %array_class(TYPE,NAME) %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) %enddef %include swig-2.0.12/Lib/ruby/std_common.i0000664000175000017500000000444312275776201016446 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-2.0.12/Lib/ruby/std_list.i0000664000175000017500000000201512275776201016122 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-2.0.12/Lib/ruby/factory.i0000664000175000017500000000004012275776201015740 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/std_alloc.i0000664000175000017500000000003312275776201016237 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/exception.i0000664000175000017500000000017612275776201016301 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg);)) } swig-2.0.12/Lib/ruby/rubyopers.swg0000664000175000017500000000347412275776201016711 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-2.0.12/Lib/ruby/rubywstrings.swg0000664000175000017500000000463312275776201017437 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") { 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") { 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-2.0.12/Lib/ruby/rubystdfunctors.swg0000664000175000017500000001014312275776201020126 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-2.0.12/Lib/ruby/rubyautodoc.swg0000664000175000017500000001041712275776201017212 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-2.0.12/Lib/ruby/std_set.i0000664000175000017500000001460312275776201015750 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-2.0.12/Lib/ruby/Makefile.swig0000664000175000017500000000165712275776201016546 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-2.0.12/Lib/ruby/rubytracking.swg0000664000175000017500000001204412275776201017354 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-2.0.12/Lib/ruby/file.i0000664000175000017500000000117712275776201015224 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-2.0.12/Lib/ruby/progargcargv.i0000664000175000017500000000140212275776201016760 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-2.0.12/Lib/ruby/embed.i0000664000175000017500000000025112275776201015351 0ustar williamwilliam%wrapper %{ #include int main(argc, argv) int argc; char **argv; { ruby_init(); ruby_options(argc, argv); ruby_run(); return 0; } %} swig-2.0.12/Lib/ruby/std_multimap.i0000664000175000017500000001370512275776201017007 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-2.0.12/Lib/ruby/rubyrun.swg0000664000175000017500000003236212275776201016363 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) { VALUE klass; 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"); } klass = 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-2.0.12/Lib/ruby/std_ios.i0000664000175000017500000000057412275776201015751 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-2.0.12/Lib/ruby/rubyruntime.swg0000664000175000017500000000064712275776201017243 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-2.0.12/Lib/ruby/std_queue.i0000664000175000017500000000152312275776201016276 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-2.0.12/Lib/ruby/std_vector.i0000664000175000017500000000230212275776201016450 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-2.0.12/Lib/ruby/std_string.i0000664000175000017500000000027612275776201016464 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-2.0.12/Lib/ruby/extconf.rb0000664000175000017500000000035212275776201016120 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-2.0.12/Lib/ruby/rubytypemaps.swg0000664000175000017500000000341712275776201017420 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 fragemt 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-2.0.12/Lib/ruby/std_basic_string.i0000664000175000017500000000512012275776201017616 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-2.0.12/Lib/ruby/std_except.i0000664000175000017500000000004312275776201016436 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/stl.i0000664000175000017500000000054512275776201015105 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include %include %include %include %include swig-2.0.12/Lib/ruby/timeval.i0000664000175000017500000000223412275776201015741 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-2.0.12/Lib/ruby/std_deque.i0000664000175000017500000000133412275776201016255 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-2.0.12/Lib/ruby/rubyprimtypes.swg0000664000175000017500000001215412275776201017610 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-2.0.12/Lib/ruby/rubyuserdir.swg0000664000175000017500000000122112275776201017222 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-2.0.12/Lib/ruby/cpointer.i0000664000175000017500000000004112275776201016115 0ustar williamwilliam%include swig-2.0.12/Lib/ruby/std_sstream.i0000664000175000017500000000003612275776201016626 0ustar williamwilliam %include swig-2.0.12/Lib/ruby/std_wstring.i0000664000175000017500000000010112275776201016636 0ustar williamwilliam%include %include swig-2.0.12/Lib/ruby/rubydef.swg0000664000175000017500000000005212275776201016304 0ustar williamwilliam/* empty file added for backward comp. */ swig-2.0.12/Lib/ruby/rubyhead.swg0000664000175000017500000001027112275776201016453 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-2.0.12/Lib/ruby/rubyapi.swg0000664000175000017500000000144112275776201016322 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-2.0.12/Lib/ruby/rubymacros.swg0000664000175000017500000000071012275776201017033 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-2.0.12/Lib/ruby/rubyerrors.swg0000664000175000017500000000720212275776201017066 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-2.0.12/Lib/ruby/std_char_traits.i0000664000175000017500000000004112275776201017447 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/0000775000175000017500000000000012275776201013726 5ustar williamwilliamswig-2.0.12/Lib/tcl/tclopers.swg0000664000175000017500000000275012275776201016307 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-2.0.12/Lib/tcl/tclerrors.swg0000664000175000017500000000323712275776201016474 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-2.0.12/Lib/tcl/tclwstrings.swg0000664000175000017500000000345412275776201017041 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-2.0.12/Lib/tcl/tclstrings.swg0000664000175000017500000000143112275776201016643 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-2.0.12/Lib/tcl/std_map.i0000664000175000017500000000425212275776201015532 0ustar williamwilliam// // SWIG typemaps for std::map // Luigi Ballabio // Jan. 2003 // // Common implementation %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-2.0.12/Lib/tcl/tclruntime.swg0000664000175000017500000000074412275776201016643 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-2.0.12/Lib/tcl/tclkw.swg0000664000175000017500000000036712275776201015602 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-2.0.12/Lib/tcl/tclresult.i0000664000175000017500000000125412275776201016123 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-2.0.12/Lib/tcl/std_pair.i0000664000175000017500000000130312275776201015702 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-2.0.12/Lib/tcl/typemaps.i0000664000175000017500000003727212275776201015755 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-2.0.12/Lib/tcl/tclapi.swg0000664000175000017500000000603412275776201015727 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-2.0.12/Lib/tcl/tcluserdir.swg0000664000175000017500000000030312275776201016624 0ustar williamwilliam/* ----------------------------------------------------------------------------- * Special user directives * ----------------------------------------------------------------------------- */ swig-2.0.12/Lib/tcl/tcl8.swg0000664000175000017500000000273412275776201015330 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-2.0.12/Lib/tcl/cmalloc.i0000664000175000017500000000004012275776201015504 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/cni.i0000664000175000017500000000005212275776201014646 0ustar williamwilliam%include %include swig-2.0.12/Lib/tcl/cstring.i0000664000175000017500000000004012275776201015543 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/attribute.i0000664000175000017500000000004212275776201016077 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/jstring.i0000664000175000017500000000175012275776201015563 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-2.0.12/Lib/tcl/cdata.i0000664000175000017500000000003612275776201015153 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/carrays.i0000664000175000017500000000004312275776201015541 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/std_common.i0000664000175000017500000000072312275776201016244 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-2.0.12/Lib/tcl/factory.i0000664000175000017500000000004012275776201015541 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/exception.i0000664000175000017500000000022112275776201016071 0ustar williamwilliam%include %insert("runtime") { %define_as(SWIG_exception(code, msg), %block(%error(code, msg); return TCL_ERROR;)) } swig-2.0.12/Lib/tcl/tcltypemaps.swg0000664000175000017500000000532512275776201017022 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[] { 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(varout) SWIGTYPE = SWIGTYPE INSTANCE; swig-2.0.12/Lib/tcl/wish.i0000664000175000017500000000655412275776201015064 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-2.0.12/Lib/tcl/cwstring.i0000664000175000017500000000007412275776201015741 0ustar williamwilliam%include %include swig-2.0.12/Lib/tcl/tclinterp.i0000664000175000017500000000115112275776201016102 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-2.0.12/Lib/tcl/tclfragments.swg0000664000175000017500000000105312275776201017140 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-2.0.12/Lib/tcl/std_vector.i0000664000175000017500000003637512275776201016272 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 // ------------------------------------------------------------------------ %{ #include #include #include #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-2.0.12/Lib/tcl/std_string.i0000664000175000017500000000004412275776201016256 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/tclsh.i0000664000175000017500000000351712275776201015223 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-2.0.12/Lib/tcl/std_except.i0000664000175000017500000000004312275776201016237 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/stl.i0000664000175000017500000000054512275776201014706 0ustar williamwilliam/* ----------------------------------------------------------------------------- * stl.i * ----------------------------------------------------------------------------- */ /* initial STL definition. extended as needed in each language */ %include %include %include %include %include swig-2.0.12/Lib/tcl/mactkinit.c0000664000175000017500000001236612275776201016065 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-2.0.12/Lib/tcl/std_deque.i0000664000175000017500000000003412275776201016052 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/cpointer.i0000664000175000017500000000004112275776201015716 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/tclmacros.swg0000664000175000017500000000004612275776201016437 0ustar williamwilliam%include swig-2.0.12/Lib/tcl/Makefile.in0000664000175000017500000000745012275776201016001 0ustar williamwilliam# --------------------------------------------------------------- # SWIG Tcl/Tk 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 one of these for rebuilding tclsh or wish #SWIGLIB = -ltclsh.i #SWIGLIB = -lwish.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 # X11 installation (needed to rebuild Tk extensions) XLIB = @XLIBSW@ XINCLUDE = @XINCLUDES@ # Tcl installation (where is Tcl/Tk 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 these) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh #BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish # 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) $(SWIGLIB) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) clean: rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) swig-2.0.12/Lib/tcl/std_wstring.i0000664000175000017500000000007712275776201016453 0ustar williamwilliam%include %include swig-2.0.12/Lib/tcl/tclrun.swg0000664000175000017500000005303612275776201015766 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-2.0.12/Lib/tcl/tclinit.swg0000664000175000017500000000774312275776201016131 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-2.0.12/Lib/tcl/tclprimtypes.swg0000664000175000017500000001274612275776201017221 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-2.0.12/Lib/shared_ptr.i0000664000175000017500000000414412275776201015454 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-2.0.12/CHANGES.current0000664000175000017500000000634612275776201015123 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 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(). swig-2.0.12/Doc/0000775000175000017500000000000012275776201013143 5ustar williamwilliamswig-2.0.12/Doc/README0000664000175000017500000000040012275776201014015 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-2.0.12/Doc/Devel/0000775000175000017500000000000012275776201014202 5ustar williamwilliamswig-2.0.12/Doc/Devel/cmdopt.html0000664000175000017500000000433112275776201016357 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-2.0.12/Doc/Devel/internals.html0000664000175000017500000011566212275776201017102 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, it's 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 it's 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-2.0.12/Doc/Devel/wrapobj.html0000664000175000017500000001663112275776201016543 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-2.0.12/Doc/Devel/migrate.txt0000664000175000017500000001122712275776201016376 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-2.0.12/Doc/Devel/engineering.html0000664000175000017500000003146712275776201017375 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-2.0.12/Doc/Devel/tree.html0000664000175000017500000002176212275776201016037 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 it's 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-2.0.12/Doc/Devel/parm.html0000664000175000017500000000507612275776201016037 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-2.0.12/Doc/Devel/index.html0000664000175000017500000000155412275776201016204 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-2.0.12/Doc/Devel/scanner.html0000664000175000017500000002420112275776201016520 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-2.0.12/Doc/Devel/file.html0000664000175000017500000001330212275776201016006 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-2.0.12/Doc/Devel/runtime.txt0000664000175000017500000001753312275776201016437 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-2.0.12/Doc/Manual/0000775000175000017500000000000012275777523014370 5ustar williamwilliamswig-2.0.12/Doc/Manual/Python.html0000664000175000017500000044742612275777521016556 0ustar williamwilliam SWIG and Python

34 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.

34.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.

34.2 Preliminaries

34.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.

34.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)

34.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.

34.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).

34.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).

34.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.

34.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.

34.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.

34.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.

34.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.

34.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
>>>

34.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.

34.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.

34.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.

34.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

34.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

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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 *

34.3.15 C++ reference counted objects

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

34.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.

34.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).

34.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

34.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))
    

34.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.

34.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.

34.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).

34.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.

34.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"

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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
>>>

34.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.

34.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.

34.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

34.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.

34.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.

34.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"])

34.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)
>>>

34.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.

34.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];
}

34.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).

34.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.

34.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

34.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.

34.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"""
    ...

34.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"""
    ...

34.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 *

    """

34.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 *

    """
    ...

34.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);

34.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.
"""

34.11 Python Packages

Using the package option of the %module directive allows you to specify what Python package that the module will be living 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 that 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 also in base class declarations, etc. if the package name is different than its own.

34.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.

34.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.

34.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.

34.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.

swig-2.0.12/Doc/Manual/Lisp.html0000664000175000017500000005607112275777520016173 0ustar williamwilliam SWIG and Common Lisp

25 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.

25.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

25.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.

25.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.

25.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, lets 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))

25.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.

25.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") %{ ... %}.

25.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.

25.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.

25.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)

25.4 UFFI

swig-2.0.12/Doc/Manual/Varargs.html0000664000175000017500000007504312275777520016671 0ustar williamwilliam Variable Length Arguments

13 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.

13.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;
}

13.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.

13.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.

13.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).

13.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.

13.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.

13.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;
}
%}

13.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.

13.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-2.0.12/Doc/Manual/Perl5.html0000664000175000017500000022674712275777520016264 0ustar williamwilliam SWIG and Perl5

31 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.

31.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.

31.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.

31.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

31.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.

31.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.

31.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.

31.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).

31.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 -c example.cxx
$ CC -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.

31.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).

31.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.

31.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";

31.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.

31.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.

31.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);

31.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

31.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";

31.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.

31.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;
}

31.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.

31.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).

31.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.

31.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

31.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.

31.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).

31.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.

31.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.

31.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
>>>

31.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.

31.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.

31.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;

31.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.

31.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

31.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++;
}

31.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);

31.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.

31.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";

31.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;
}

31.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.

31.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.

31.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();

31.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.

31.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);         

31.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.

31.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).

31.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);
  ...
};

31.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);
swig-2.0.12/Doc/Manual/Extending.html0000664000175000017500000034626312275777521017217 0ustar williamwilliam Extending SWIG to support new languages

38 Extending SWIG to support new languages

38.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.

38.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.

38.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.

38.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.

38.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.

38.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).

38.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

38.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.

38.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 )

38.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.

38.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.

38.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.

38.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;

38.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).

38.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.

38.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.

38.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.

38.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);
}

38.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.

int Close(String_or_FILE *f)

Closes a file. Has no effect on strings.

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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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'

38.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).

38.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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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;
}

38.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 wrappering code.
  • init: This section holds the module initalisation 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);
   Close(f_begin);
   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;
...

38.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 constriants */
  ....

  /* 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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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 testcase argcargvtest (with run test) under python
checking testcase python_autodoc under python
checking testcase python_append (with run test) under python
checking testcase callback (with run test) under python

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"

38.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.

38.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.

38.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.

38.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.

38.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.

38.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-2.0.12/Doc/Manual/Mzscheme.html0000664000175000017500000001165412275777520017035 0ustar williamwilliam SWIG and MzScheme/Racket

28 SWIG and MzScheme/Racket

This section contains information on SWIG's support of Racket, formally known as MzScheme.

28.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...

28.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.

28.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-2.0.12/Doc/Manual/Scripting.html0000664000175000017500000003450512275777517017232 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 at really 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 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 machines is shown below:

# Build a shared library for Solaris
gcc -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

# Build a shared library for Irix
gcc -c example.c example_wrap.c -I/usr/local/include
ld -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-2.0.12/Doc/Manual/Php.html0000664000175000017500000010246612275777520016013 0ustar williamwilliam SWIG and PHP

32 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.

32.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.

32.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

32.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");

32.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.

32.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!

32.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.

32.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

32.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.

32.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 REFERENCE.

However, this relies on call-time pass-by-reference, which has been deprecated in PHP for some time, and was finally removed in PHP 5.4. So you should avoid creating new wrappers which rely on this approach.

%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.

32.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.

32.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);

32.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)

32.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";

32.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();

32.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.

32.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.

32.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";
  }
}

32.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.

32.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.

32.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.

32.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.

32.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.

32.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-2.0.12/Doc/Manual/README0000664000175000017500000000152212275776201015240 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-2.0.12/Doc/Manual/R.html0000664000175000017500000001070512275777521015460 0ustar williamwilliam SWIG and R

35 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++.

35.1 Bugs

Currently the following features are not implemented or broken:

  • Garbage collection of created objects
  • C Array wrappings

35.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

35.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.

35.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.

35.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)

35.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.

35.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-2.0.12/Doc/Manual/linkchecker.config0000664000175000017500000000010412275776201020024 0ustar williamwilliam[checking] anchors=1 [filtering] ignorewarnings=http-robots-denied swig-2.0.12/Doc/Manual/maketoc.py0000664000175000017500000000110312275776201016350 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-2.0.12/Doc/Manual/Contract.html0000664000175000017500000001447312275777520017041 0ustar williamwilliam Contract Checking

12 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.

12.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)
>>>

12.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.

12.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.

12.4 Notes

Contract support was implemented by Songyan (Tiger) Feng and first appeared in SWIG-1.3.20.

swig-2.0.12/Doc/Manual/Pike.html0000664000175000017500000001407212275777520016147 0ustar williamwilliam SWIG and Pike

33 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.

33.1 Preliminaries

33.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

33.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.

33.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

33.2 Basic C/C++ Mapping

33.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.

33.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

33.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

33.2.4 Constants and enumerated types

Enumerated types in C/C++ declarations are wrapped as Pike constants, not as Pike enums.

33.2.5 Constructors and Destructors

Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

33.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-2.0.12/Doc/Manual/fixstyle.py0000664000175000017500000000072612275776201016606 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-2.0 Documentation

SWIG-2.0 Documentation



Table of Contents



SWIG-2.0 Documentation 1 Preface 2 Introduction 3 Getting started on Windows 4 Scripting Languages 5 SWIG Basics 6 SWIG and C++ 7 Preprocessing 8 SWIG library 9 Argument Handling 10 Typemaps 11 Customization Features 12 Contracts 13 Variable Length Arguments 14 Warning Messages 15 Working with Modules 16 Using SWIG with ccache - ccache-swig(1) manpage 17 SWIG and Allegro Common Lisp 18 SWIG and Android 19 SWIG and C# 20 SWIG and Chicken 21 SWIG and D 22 SWIG and Go 23 SWIG and Guile 24 SWIG and Java 25 SWIG and Common Lisp 26 SWIG and Lua 27 SWIG and Modula-3 28 SWIG and MzScheme/Racket 29 SWIG and Ocaml 30 SWIG and Octave 31 SWIG and Perl5 32 SWIG and PHP 33 SWIG and Pike 34 SWIG and Python 35 SWIG and R 36 SWIG and Ruby 37 SWIG and Tcl 38 Extending SWIG to support new languages

SWIG-2.0 Documentation

Last update : SWIG-2.0.12 (9 Feb 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 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 a 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 overflow 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 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 also can generate the custom commands necessary for driving SWIG from IDE's 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 it's 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. Later versions of Visual Studio should also be able to open and convert these project files. The C# examples come with .NET 2003 solution (.sln) and 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 at really 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 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 machines is shown below:

# Build a shared library for Solaris
gcc -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

# Build a shared library for Irix
gcc -c example.c example_wrap.c -I/usr/local/include
ld -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 a 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.

Many target languages 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 overidden 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 describes 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 pointer 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 not 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 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 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 introduced by '\' or, as backslashes need to be escaped in C strings, rather by "\\". For example, to remove any alphabetic prefix before an underscore you could use the following directive: %rename("regex:/(\\w+)_(.*)/\\2/")Prefix_Print Print
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 is 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 make 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 previously 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 is 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 times produce 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 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 interface 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 in a C program--thus, a little forethought can dramatically simplify the resulting scripting language interface. C header files are 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 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 rest of 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: If 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.)
  • Nested classes, see Nested classes for workarounds.

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++ -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.

There are some subtle issues when wrapping data members that are themselves 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 directive and is 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 variables will use const reference typemaps
%naturalvar;

The observant reader will notice that %naturalvar works like any other feature flag directive, except it can also be attached to class types. The first of the example usages above show %naturalvar attaching to the List class. Effectively this feature changes 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;
}

In fact 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.

Other alternatives for turning this feature on globally are to use the swig -naturalvar commandline option or the module mode option, %module(naturalvar=1)

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 constructor 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

There is some support for nested structs and unions when wrapping C code, see Nested structures for further details. The added complexity of C++ compared to C means this approach does not work well for C++ code (when using the -c++ command line option). For C++, a nested class is treated much like an opaque pointer, so anything useful within the nested class, such as its methods and variables, are not accessible from the target language. True nested class support may be added to SWIG in the future, however, until then some of the following workarounds can be applied to improve the situation.

It might be possible to use partial class information as often you can accept that the nested class is not needed, especially if it is not actually used in any methods you need from the target language. Imagine you are wrapping the following Outer class which contains a nested class Inner. The easiest thing to do is turn a blind eye to the warning that SWIG generates, or simply suppress it:

%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;

class Outer {
public:
  class Inner {
    public:
      ...
  };
  Inner getInner();
  void useInner(const Inner& inner);
  ...
};

Note that if Inner can be used as an opaque type, the default wrapping approach suffices. For example, if the nested class does not need to be created from the target language, but can be obtained via a method call, such as the getInner() method above, the returned value can then be passed around, such as passed into the useInner() method.

With some more effort the above situation can be improved somewhat and a nested class can be constructed and used from the target language much like any other non-nested class. Assuming we have the Outer class in a header file:

// File outer.h
class Outer {
public:
  class Inner {
    public:
      int var;
      Inner(int v = 0) : var(v) {}
  };
  Inner getInner();
  void useInner(const Inner& inner);
};

The following interface file works around the nested class limitations by redefining the nested class as a global class. A typedef for the compiler and the nestedworkaround feature flag is also required in order for the generated wrappers to compile. This flag simply removes all the type information from SWIG, so SWIG treats the nested class as if it had not been parsed at all.

// File : example.i
%module example

// Redefine nested class in global scope in order for SWIG to generate
// a proxy class. Only SWIG parses this definition.
class Inner {
  public:
    int var;
    Inner(int v = 0) : var(v) {}
};

%nestedworkaround Outer::Inner;

%{
#include "outer.h"
%}
%include "outer.h"

// We've fooled SWIG into thinking that Inner is a global class, so now we need
// to trick the C++ compiler into understanding this apparent global type.
%{
typedef Outer::Inner Inner;
%}

The downside to this approach is a more complex interface file and having to maintain two definitions of Inner, the real one and the one in the interface file that SWIG parses. However, the upside is that all the methods/variables in the nested class are available from the target language as a proxy class is generated instead of treating the nested class as an opaque type. The proxy class can be constructed from the target language and passed into any methods accepting the nested class. Also note that the original header file is parsed unmodified.

Finally, conditional compilation can be used as a workaround to comment out nested class definitions in the actual headers, assuming you are able to modify them.

// File outer.h
class Outer {
public:
#ifndef SWIG
  class Inner {
    public:
      ...
  };
#endif
  ...
};

This workaround used to be common when SWIG could not deal with nested classes particulary well. This should just be a last resort for unusual corner cases now as SWIG can parse nested classes and even handle nested template classes fairly well.

Compatibility Note: 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 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.

7.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.

7.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.

7.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
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).

7.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.

7.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).

7.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.

7.7 Preprocessing and delimiters

The preprocessor handles { }, " " and %{ %} delimiters differently.

7.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).

7.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.

7.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);

7.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.

7.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

8 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.

8.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.

8.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.

8.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.

8.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 *.

8.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
>>>

8.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.

8.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.

8.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.

8.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).

8.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.

8.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.

8.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::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.

8.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

8.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.

8.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.

8.4.4 shared_ptr smart pointer

Some target languages have support for handling the widely used boost::shared_ptr smart pointer. This smart pointer is also available as std::tr1::shared_ptr before it becomes fully standardized as std::shared_ptr. The boost_shared_ptr.i library provides support for boost::shared_ptr and std_shared_ptr.i provides support for std::shared_ptr, but if the following macro is defined as shown, it can be used for std::tr1::shared_ptr:

#define SWIG_SHARED_PTR_SUBNAMESPACE tr1
%include <std_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.

8.5 Utility Libraries

8.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()));
    }
}

9 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.

9.1 The typemaps.i library

This section describes the typemaps.i library file--commonly used to change certain properties of argument conversion.

9.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

9.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)

9.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)

9.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.

9.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.

9.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.

9.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.

9.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).

9.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 *;

10 Typemaps

10.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.

10.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).

10.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.

10.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.

10.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.

10.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.

10.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);
}
%}

10.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.

10.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.

10.2 Typemap specifications

This section describes the behavior of the %typemap directive itself.

10.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.

10.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.
};

10.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

10.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.

10.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.

10.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.

10.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.

10.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);

10.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.

10.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.

10.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.

10.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*.

10.4 Code generation rules

This section describes rules by which typemap code is inserted into the generated wrapper code.

10.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.

10.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
....

10.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 */
   ...
}

10.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.

10.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.

10.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
  }
%}

10.5 Common typemap methods

The set of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

10.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.

10.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.

10.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.

10.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;
}

10.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.

10.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.");
   }
}

10.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.

10.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.

10.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.

10.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.

10.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.

10.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.

10.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.

10.6 Some typemap examples

This section contains a few examples. Consult language module documentation for more examples.

10.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.

10.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.

10.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);".

10.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.

10.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.

10.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.

10.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.

10.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>} ...
  }
};

10.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.

10.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, irregardless 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.

10.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.

10.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.

10.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.

10.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;

10.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.

10.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.

10.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.


11 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.

11.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.

11.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.

11.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.

11.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 {};

11.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

11.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.

11.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 *)");
  }

11.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.

11.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.

11.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.

11.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.

11.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.

11.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","")

11.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.

11.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.


12 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.

12.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)
>>>

12.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.

12.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.

12.4 Notes

Contract support was implemented by Songyan (Tiger) Feng and first appeared in SWIG-1.3.20.


13 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.

13.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;
}

13.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.

13.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.

13.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).

13.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.

13.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.

13.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;
}
%}

13.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.

13.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.


14 Warning Messages

14.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.

14.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.

14.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.

14.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

14.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;

14.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.

14.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.

14.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.

14.9 Warning number reference

14.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.

14.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.

14.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.

14.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.

14.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'.

14.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).

14.9.7 User defined (900-999)

These numbers can be used by your own application.

14.10 History

The ability to control warning messages was first added to SWIG-1.3.12.


15 Working with Modules

15.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.

15.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. Oftentimes 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.

15.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.

15.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.

15.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.

15.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.

15.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.


16 Using SWIG with ccache - ccache-swig(1) manpage

16.1 NAME

ccache-swig - a fast compiler cache

16.2 SYNOPSIS

ccache-swig [OPTION]

ccache-swig <compiler> [COMPILER OPTIONS]

<compiler> [COMPILER OPTIONS]

16.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.

16.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

16.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.

16.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.

16.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.

16.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'.

16.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.

16.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.

16.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.

16.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'.

16.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.

16.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.

16.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

16.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

16.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.


17 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.

17.1 Basics

17.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.

17.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.

17.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") %{ ... %}.

17.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++.

17.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
  

17.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.

17.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.

17.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.

17.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.

17.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.

17.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.

17.3 Wrapping Details

In this section is described how particular C/C++ constructs are translated into lisp.

17.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).

17.3.2 Constants

Constants, as declared by the preprocessor #define macro or SWIG %constant directive, are included in SWIGs 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.

17.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
    

17.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 it's 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 it's 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)

      

17.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)))
    

17.3.6 Classes and Structs and Unions (oh my!)

17.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.

17.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. It's 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.

17.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,

17.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.

17.3.7 Templates

17.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.

17.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.

17.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> 
    

17.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.

17.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> 
    

17.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> 
    

17.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(). It's 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.

17.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.

17.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.

17.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.

17.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;
   }
    

17.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;";
    

17.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. It's 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);";
    

17.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. It's 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.

17.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.

17.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)";
    

17.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)";
    

17.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)";
    

17.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";
    

17.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";
    

17.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";
    

17.5 Identifier Converter functions

17.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.

17.5.2 Existing identifier-converter functions

Two basic identifier routines have been defined.

17.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.

17.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.

17.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.

17.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. It's 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. It's value is an integer indicating the number of arguments passed to the routine indicated by this identifier.

17.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

18 SWIG and Android

This chapter describes SWIG's support of Android.

18.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.

18.2 Android examples

18.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.

18.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

18.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(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);
};

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(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;
}

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

18.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.

18.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

19 SWIG and C#

19.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.

19.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="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);
    
  • 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="[MarshalAs(UnmanagedType.LPStr)]",
             outattributes="[return: 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 {
      ...
      [DllImport("example", EntryPoint="CSharp_GetMsg")]
      [return: MarshalAs(UnmanagedType.LPStr)]
      public static extern String GetMsg();
    
      [DllImport("example", EntryPoint="CSharp_SetMsg")]
      public static extern void SetMsg([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 : 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 "[System.ComponentModel.Description(\"Colours\")]"
    %csattributes Rouge "[System.ComponentModel.Description(\"Red\")]"
    %csattributes Vert "[System.ComponentModel.Description(\"Green\")]"
    %inline %{
      enum Couleur { Rouge, Orange, Vert };
    %}
    

    which will result in the following C# enum:

    [System.ComponentModel.Description("Colours")]
    public enum Couleur {
      [System.ComponentModel.Description("Red")]
      Rouge,
      Orange,
      [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.

19.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);

19.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.

19.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

19.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:

[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy([In, MarshalAs(UnmanagedType.LPArray)]int[] jarg1, 
                                      [Out, 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

  [DllImport("example", EntryPoint="CSharp_myArraySwap")]
  public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1, 
                                        [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
                                         int jarg3);

19.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((IntPtr)swig_ptrTo_sourceArray, (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.

[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3);

19.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.

19.5.1 C# exception example using "check" typemap

Lets 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.

19.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();
  }

19.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.

19.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);

    [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 : 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) {
  ...
}

19.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.

19.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)

19.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.

using System;
using System.Runtime.InteropServices;

public class Base : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal Base(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(Base obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~Base() {
    Dispose();
  }

  public virtual void Dispose() {
    lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
        swigCMemOwn = false;
        examplePINVOKE.delete_Base(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      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, 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(IntPtr b, bool flag) {
    BaseBoolMethod(new Base(b, false), flag);
  }

  internal delegate uint SwigDelegateBase_0(uint x);
  internal delegate void SwigDelegateBase_1(IntPtr b, bool flag);

  private SwigDelegateBase_0 swigDelegate0;
  private SwigDelegateBase_1 swigDelegate1;

  private static Type[] swigMethodTypes0 = new Type[] { typeof(uint) };
  private static Type[] swigMethodTypes1 = new 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);
  }
}

19.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.

19.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.

19.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.

19.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
      System.GC.Collect();
      System.GC.WaitForPendingFinalizers();
      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 {
    IntPtr cPtr = $imcall;$excode
    $csclassname ret = null;
    if (cPtr != 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 : 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 : IDisposable {
  ...
  public Wheel getWheel() {
    IntPtr cPtr = examplePINVOKE.Bike_getWheel(swigCPtr);
    Wheel ret = null;
    if (cPtr != IntPtr.Zero) {
      ret = new Wheel(cPtr, false);
      ret.addReference(this);
    }
    return ret;
  }
}

Note the addReference call.

19.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
      System.GC.Collect();
      System.GC.WaitForPendingFinalizers();
      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 : 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 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 HandleRef getCPtrAndAddReference(Element element) {
    elementReference = element;
    return Element.getCPtr(element);
  }
%}

19.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 : 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 : 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 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
  }
  ...
}

19.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 {
      IntPtr cPtr = $imcall;
      CDate tempDate = (cPtr == 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 {
      IntPtr cPtr = examplePINVOKE.ImportantDate_get();
      CDate tempDate = (cPtr == 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.

19.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(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.

19.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 : 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 : IDisposable {
  ...
  public int Part1() {
    ...
  }
}

You can then of course declare another part of the partial class elsewhere, for example:

public partial class ExtendMe : 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.

19.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 : IDisposable {
  ...
  public int Part3() {
    return 3;
  }
  public int Part1() {
    ...
  }
}

19.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
}

20 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.

20.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.

20.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.

20.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.

20.2 Code Generation

20.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.

20.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.

20.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.

20.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) .

20.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))

20.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.

20.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 )).

20.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.

20.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.

20.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.

20.5 Typemaps

The Chicken module handles all types via typemaps. This information is read from Lib/chicken/typemaps.i and Lib/chicken/chicken.swg.

20.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).

20.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.

20.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).

20.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.


21 SWIG and D

21.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).

21.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.

21.3 Typemaps

21.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

21.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.

21.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).

21.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)

21.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).

21.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.

21.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.

21.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();
};
%}

21.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.

21.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.

21.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#.

21.8 Other features

21.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.

21.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 *).

21.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.

21.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.

21.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.

21.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.

22 SWIG and Go

This chapter describes SWIG's support of Go. For more information on the Go programming language see golang.org .

22.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 under the names 6g, 8g, or 5g. 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.

22.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.

22.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
-intgo-type-size %lt;s%gt;Set the size for the Go type int. This controls the size that the C/C++ code expects to see. The %lt;s%gt; 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 6g/8g/5g.
-package <name>Set the name of the Go package to <name>. The default package name is the SWIG module name.
-soname %lt;name%gt;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 6g/8g/5g; when using gccgo, the equivalent name will be taken from the -soname option passed to the linker.
-go-prefix <prefix>When generating code for gccgo, set the prefix to use. This corresponds to the -fgo-prefix option to gccgo.
-long-type-size <s>Set the size for the C/C++ type long. This controls whether long is converted to the Go type int32 or int64. The <s> argument should be 32 or 64.

22.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: 6c, 8c, or 5c. It should then be combined with the compiled MODULE.go using gopack. This file will not be generated when using gccgo.

A typical command sequence would look like this:

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

22.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.

22.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.

22.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.

22.3.3 Go Constants

C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration.

22.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.

22.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.

22.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.

22.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.

22.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++.

22.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
longint32 or int64, depending on -long-type-size
unsigned longuint32 or uint64, depending on -long-type-size
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.

22.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);

22.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.

This only works if your wrappers do not need to import other go modules. There is at present no way to insert import statements in the correct place in swig-generated go. If you need to do that, you must put your go code in a separate file.


23 SWIG and Guile

This section details guile-specific support in SWIG.

23.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.

23.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".

23.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.

23.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.

23.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.

23.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.

23.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")
    

23.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.

23.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.

23.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).

23.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.

23.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.

23.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.

23.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.

23.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.

23.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.

23.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.

23.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.

23.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:)))

23.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?)


24 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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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 -c example_wrap.c  -I/usr/java/include -I/usr/java/include/solaris
$ gcc -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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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));

24.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)

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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

24.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();

24.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.

24.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).

24.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.

24.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

24.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.

24.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.

24.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.

24.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 *

24.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.

24.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.

24.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.

24.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.

24.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.

24.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());

24.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

24.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.

24.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.

24.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.

24.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();
}

24.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) { ... }

24.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.

24.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.

24.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.

24.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;
}

24.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.

24.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();
};

24.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).

24.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.

24.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.

24.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
%}

24.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.

24.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();
  }
}

24.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.

24.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.

24.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.

24.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.

24.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();
}

24.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.

24.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.

24.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.

24.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.

24.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.

24.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

24.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.

24.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.

24.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.

24.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.

24.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.

24.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");

24.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

24.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.

24.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.

$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.

24.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.

24.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)

24.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.

%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(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.

24.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.

24.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.

24.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().

24.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.

24.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.

24.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"});

24.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

24.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.

24.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));

24.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.

24.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.

24.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.

24.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);
  }
%}

24.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).

24.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.

24.12 Odds and ends

24.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() {
    ...
  }
...
}

24.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.

24.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.

24.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.

24.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 overidden 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.

24.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.


25 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.

25.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

25.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.

25.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.

25.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, lets 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))

25.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.

25.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") %{ ... %}.

25.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.

25.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.

25.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)

25.4 UFFI


26 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

26.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 supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.

26.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.

26.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.

26.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

26.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 -I/usr/include/lua -c example_wrap.c -o example_wrap.o
$ gcc -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).

26.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
>

26.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.

26.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.

26.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 it keeps all the functions and global variables in. It is possible to copy the functions 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.

> 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

26.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.

26.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

26.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

26.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 are created using a function new_Point(), but for C++ classes are 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)

26.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, the 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

26.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.

26.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.

26.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.

26.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/
  • __neg__ unary minus
  • __call__ operator() (often used in functor classes)
  • __pow__ the exponential fn (no C++ equivalent, Lua uses ^)
  • __concat__ the concatenation operator (SWIG maps C++'s ~ to 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
};

26.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).

26.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.

26.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.

26.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 *

26.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).

26.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

26.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

26.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).

26.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.

26.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

26.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).

26.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).

26.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.

26.6 Customization of your Bindings

This section covers adding of some small extra bits to your module to add the last finishing touches.

26.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.

26.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.

26.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.

26.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)'.

26.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.

26.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).


27 SWIG and Modula-3

This chapter describes SWIG's support of Modula-3. You should be familiar with the basics of SWIG, especially typemaps.

27.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

27.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 be still 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 Module-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 Module-3 module into a C/C++ project.

27.2 Conception

27.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).

27.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.

27.3 Preliminaries

27.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.

27.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.

27.4 Modula-3 typemaps

27.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.

27.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.

27.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.

27.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;
%}

27.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%}.

27.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;

27.5 More hints to the generator

27.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.

27.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.

27.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.

28 SWIG and MzScheme/Racket

This section contains information on SWIG's support of Racket, formally known as MzScheme.

28.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...

28.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.

28.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.


29 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.

29.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.

29.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).

29.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
% ...

29.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. It's 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")

29.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.

29.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.

29.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 it's 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.

29.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.

29.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

29.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.

29.2.3 Arrays

29.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.

29.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.

29.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.

29.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

29.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.

29.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 = ()
# 

29.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();
};

29.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

29.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.

29.2.5 Director Classes

29.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 {
  ...
};

29.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.

29.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++.

29.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.

29.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.

29.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.

29.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.

29.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.

29.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.


30 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).

30.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.

30.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.

30.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.

30.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

30.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 

30.3 A tour of basic C/C++ wrapping

30.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

30.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 

30.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 

30.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
.... 

30.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 it's 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 

30.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.

30.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.

30.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.

30.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.

30.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

30.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)

30.3.12 C++ Smart Pointers

C++ smart pointers are fully supported as in other modules.

30.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

30.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.

30.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).

30.3.16 STL support

Various STL library files are provided for wrapping STL containers.

30.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


31 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.

31.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.

31.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.

31.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

31.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.

31.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.

31.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.

31.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).

31.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 -c example.cxx
$ CC -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.

31.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).

31.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.

31.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";

31.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.

31.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.

31.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);

31.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

31.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";

31.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.

31.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;
}

31.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.

31.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).

31.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.

31.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

31.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.

31.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).

31.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.

31.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.

31.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
>>>

31.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.

31.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.

31.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;

31.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.

31.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

31.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++;
}

31.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);

31.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.

31.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";

31.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;
}

31.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.

31.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.

31.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();

31.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.

31.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);         

31.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.

31.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).

31.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);
  ...
};

31.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);

32 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.

32.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.

32.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

32.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");

32.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.

32.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!

32.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.

32.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

32.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.

32.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 REFERENCE.

However, this relies on call-time pass-by-reference, which has been deprecated in PHP for some time, and was finally removed in PHP 5.4 . So you should avoid creating new wrappers which rely on this approach.

%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.

32.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.

32.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);

32.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)

32.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";

32.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();

32.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.

32.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.

32.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";
  }
}

32.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.

32.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.

32.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.

32.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.

32.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.

32.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.


33 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.

33.1 Preliminaries

33.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

33.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.

33.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

33.2 Basic C/C++ Mapping

33.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.

33.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

33.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

33.2.4 Constants and enumerated types

Enumerated types in C/C++ declarations are wrapped as Pike constants, not as Pike enums.

33.2.5 Constructors and Destructors

Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

33.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.


34 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.

34.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.

34.2 Preliminaries

34.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.

34.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)

34.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.

34.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).

34.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).

34.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.

34.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.

34.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.

34.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.

34.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.

34.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
>>>

34.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.

34.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.

34.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.

34.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

34.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

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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 *

34.3.15 C++ reference counted objects

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

34.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.

34.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).

34.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

34.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))
    

34.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.

34.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.

34.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).

34.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.

34.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"

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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.

34.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
>>>

34.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.

34.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.

34.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

34.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.

34.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.

34.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"])

34.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)
>>>

34.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.

34.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];
}

34.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).

34.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.

34.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

34.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.

34.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"""
    ...

34.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"""
    ...

34.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 *

    """

34.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 *

    """
    ...

34.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);

34.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.
"""

34.11 Python Packages

Using the package option of the %module directive allows you to specify what Python package that the module will be living 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 that 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 also in base class declarations, etc. if the package name is different than its own.

34.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.

34.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.

34.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.

34.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.


35 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++.

35.1 Bugs

Currently the following features are not implemented or broken:

  • Garbage collection of created objects
  • C Array wrappings

35.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

35.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.

35.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.

35.5 Language conventions

getitem and setitem use C++ conventions (i.e. zero based indices). [

35.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.

35.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.


36 SWIG and Ruby

This chapter describes SWIG's support of Ruby.

36.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.

36.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.

36.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 .

36.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 -c example.c
$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
$ gcc -shared example.o example_wrap.o -o example.so

For other platforms it may be necessary to compile with the -fPIC option to generate position-independent code. 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.

36.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".

36.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.

36.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++ -c example.cxx
$ g++ -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')

36.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.

36.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

36.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.

36.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.

36.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

36.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.

36.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

36.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.

36.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;
}

36.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

36.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").

36.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.

36.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.

36.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.

36.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

36.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.

36.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]

36.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.

36.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 *

36.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.

36.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.

36.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.

36.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).

36.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).

36.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).

36.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);

36.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)

36.6 Exception handling

36.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.

36.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 .

36.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.

36.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.

36.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.

36.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

36.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.
};

36.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

36.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.

36.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 .

36.7.6 Ruby typemaps

The following list details all of the typemap methods that can be used by the Ruby module:

36.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.

36.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."

36.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.

36.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;
}

36.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.

36.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.");
  }
}

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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

36.7.6.17 ret typemap

Cleanup of function return values

36.7.6.18 globalin typemap

Setting of C global variables

36.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.

36.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.

36.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

36.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

36.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

36.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().

36.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.

36.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.

36.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.

36.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.

36.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);
}

36.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.

36.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.

36.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

36.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

36.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.

36.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
  ...

36.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
  ...

36.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:

36.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

36.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);

36.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.

36.9 Advanced Topics

36.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).

36.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

36.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).

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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

37 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.

37.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.

37.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.

37.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 -c example.c
$ gcc -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.

37.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).

37.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).

37.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++ -c example.cxx
% g++ -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 -c example.cxx
% CC -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.

37.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).

37.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".

37.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.

37.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.

37.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
%

37.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.

37.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.

37.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

37.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]
%

37.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)

37.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.

37.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.

37.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.

37.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

37.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.

37.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).

37.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.

37.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.

37.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.

37.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.

37.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 *

37.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.

37.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.

37.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.

37.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]

37.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.

37.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.

37.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

37.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.

37.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.

37.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

37.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
%

37.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);

37.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);
}

37.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;
}

37.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.

37.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).

37.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.

37.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.


38 Extending SWIG to support new languages

38.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.

38.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.

38.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.

38.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.

38.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.

38.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).

38.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

38.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.

38.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 )

38.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.

38.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.

38.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.

38.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;

38.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).

38.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.

38.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.

38.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.

38.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);
}

38.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.

int Close(String_or_FILE *f)

Closes a file. Has no effect on strings.

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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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'

38.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).

38.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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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;
}

38.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 wrappering code.
  • init: This section holds the module initalisation 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);
   Close(f_begin);
   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;
...

38.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 constriants */
  ....

  /* 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.

38.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.

38.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.

38.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.

38.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.

38.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.

38.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 testcase argcargvtest (with run test) under python
checking testcase python_autodoc under python
checking testcase python_append (with run test) under python
checking testcase callback (with run test) under python

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"

38.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.

38.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.

38.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.

38.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.

38.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.

38.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-2.0.12/Doc/Manual/Ruby.html0000664000175000017500000045602612275777521016212 0ustar williamwilliam SWIG and Ruby

36 SWIG and Ruby

This chapter describes SWIG's support of Ruby.

36.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.

36.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.

36.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 .

36.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 -c example.c
$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
$ gcc -shared example.o example_wrap.o -o example.so

For other platforms it may be necessary to compile with the -fPIC option to generate position-independent code. 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.

36.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".

36.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.

36.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++ -c example.cxx
$ g++ -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')

36.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.

36.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

36.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.

36.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.

36.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

36.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.

36.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

36.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.

36.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;
}

36.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

36.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").

36.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.

36.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.

36.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.

36.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

36.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.

36.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]

36.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.

36.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 *

36.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.

36.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.

36.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.

36.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).

36.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).

36.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).

36.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);

36.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)

36.6 Exception handling

36.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.

36.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.

36.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.

36.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.

36.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.

36.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

36.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.
};

36.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

36.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.

36.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 .

36.7.6 Ruby typemaps

The following list details all of the typemap methods that can be used by the Ruby module:

36.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.

36.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."

36.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.

36.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;
}

36.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.

36.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.");
  }
}

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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

36.7.6.17 ret typemap

Cleanup of function return values

36.7.6.18 globalin typemap

Setting of C global variables

36.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.

36.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.

36.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

36.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

36.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

36.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().

36.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.

36.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.

36.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.

36.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.

36.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);
}

36.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.

36.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.

36.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

36.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

36.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.

36.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
  ...

36.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
  ...

36.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:

36.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

36.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);

36.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.

36.9 Advanced Topics

36.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).

36.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

36.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).

36.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.

36.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.

36.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.

36.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.

36.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.

36.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.

36.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-2.0.12/Doc/Manual/Java.html0000664000175000017500000077505612275777520016160 0ustar williamwilliam SWIG and Java

24 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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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 -c example_wrap.c  -I/usr/java/include -I/usr/java/include/solaris
$ gcc -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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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));

24.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)

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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.

24.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

24.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();

24.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.

24.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).

24.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.

24.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

24.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.

24.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.

24.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.

24.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 *

24.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.

24.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.

24.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.

24.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.

24.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.

24.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());

24.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

24.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.

24.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.

24.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.

24.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();
}

24.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) { ... }

24.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.

24.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.

24.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.

24.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;
}

24.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.

24.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();
};

24.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).

24.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.

24.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.

24.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
%}

24.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.

24.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();
  }
}

24.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.

24.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.

24.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.

24.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.

24.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();
}

24.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.

24.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.

24.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.

24.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.

24.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.

24.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

24.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.

24.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.

24.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.

24.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.

24.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.

24.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");

24.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

24.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.

24.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.

$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.

24.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.

24.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)

24.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.

%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(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.

24.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.

24.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.

24.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().

24.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.

24.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.

24.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"});

24.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

24.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.

24.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));

24.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.

24.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.

24.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.

24.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);
  }
%}

24.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).

24.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.

24.12 Odds and ends

24.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() {
    ...
  }
...
}

24.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.

24.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.

24.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.

24.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 overidden 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.

24.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-2.0.12/Doc/Manual/SWIGDocumentation.pdf0000664000175000017500000765505612275777523020416 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[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]endobj 228 0 obj<>endobj 229 0 obj<>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<>endobj 280 0 obj<>endobj 281 0 obj[228 0 R 229 0 R 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 279 0 R 280 0 R]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[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]endobj 332 0 obj<>endobj 333 0 obj<>endobj 334 0 obj<>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[332 0 R 333 0 R 334 0 R 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]endobj 384 0 obj<>endobj 385 0 obj<>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[384 0 R 385 0 R 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[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]endobj 490 0 obj<>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[490 0 R 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]endobj 543 0 obj<>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[543 0 R 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<>endobj 651 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 650 0 R]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[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]endobj 705 0 obj<>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[705 0 R 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]endobj 757 0 obj<>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[757 0 R 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]endobj 810 0 obj<>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[810 0 R 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[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]endobj 917 0 obj<>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[917 0 R 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]endobj 969 0 obj<>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[969 0 R 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]endobj 1024 0 obj<>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[1024 0 R 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[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]endobj 1132 0 obj<>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[1132 0 R 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]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<>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[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 1186 0 R 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]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[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 1227 0 R 1229 0 R]endobj 1231 0 obj<>endobj 1232 0 obj<>endobj 1233 0 obj<>endobj 1234 0 obj<>endobj 1235 0 obj<>endobj 1236 0 obj[1232 0 R 1234 0 R 1235 0 R]endobj 1237 0 obj<>endobj 1238 0 obj<>endobj 1239 0 obj<>endobj 1240 0 obj<>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[1238 0 R 1240 0 R 1242 0 R 1243 0 R 1245 0 R 1247 0 R]endobj 1249 0 obj<>endobj 1250 0 obj<>endobj 1251 0 obj<>endobj 1252 0 obj<>endobj 1253 0 obj<>endobj 1254 0 obj[1249 0 R 1251 0 R 1253 0 R]endobj 1255 0 obj<>endobj 1256 0 obj<>endobj 1257 0 obj<>endobj 1258 0 obj<>endobj 1259 0 obj<>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[1255 0 R 1256 0 R 1257 0 R 1258 0 R 1259 0 R 1260 0 R 1261 0 R 1262 0 R 1263 0 R 1264 0 R 1265 0 R 1266 0 R 1267 0 R]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[1270 0 R 1272 0 R 1274 0 R 1276 0 R 1278 0 R 1280 0 R]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<>endobj 1301 0 obj<>endobj 1302 0 obj<>endobj 1303 0 obj<>endobj 1304 0 obj<>endobj 1305 0 obj<>endobj 1306 0 obj[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 1300 0 R 1302 0 R 1303 0 R 1304 0 R 1305 0 R]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[1308 0 R 1310 0 R 1312 0 R 1314 0 R 1316 0 R 1318 0 R]endobj 1320 0 obj<>endobj 1321 0 obj<>endobj 1322 0 obj<>endobj 1323 0 obj<>endobj 1324 0 obj<>endobj 1325 0 obj<>endobj 1326 0 obj[1321 0 R 1323 0 R 1325 0 R]endobj 1327 0 obj<>endobj 1328 0 obj<>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[1327 0 R 1328 0 R 1329 0 R 1330 0 R 1331 0 R 1332 0 R 1333 0 R 1334 0 R 1335 0 R 1336 0 R 1337 0 R]endobj 1339 0 obj<>endobj 1340 0 obj<>endobj 1341 0 obj<>endobj 1342 0 obj<>endobj 1343 0 obj<>endobj 1344 0 obj<>endobj 1345 0 obj<>endobj 1346 0 obj<>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<>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<>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[1339 0 R 1340 0 R 1341 0 R 1342 0 R 1343 0 R 1344 0 R 1345 0 R 1346 0 R 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 1360 0 R 1361 0 R 1362 0 R 1363 0 R 1364 0 R 1365 0 R 1366 0 R 1367 0 R 1368 0 R 1369 0 R 1370 0 R 1371 0 R 1372 0 R 1373 0 R 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 1393 0 R 1394 0 R]endobj 1396 0 obj<>endobj 1397 0 obj[1396 0 R]endobj 1398 0 obj<>endobj 1399 0 obj[1398 0 R]endobj 1400 0 obj<>endobj 1401 0 obj[1400 0 R]endobj 1402 0 obj<>endobj 1403 0 obj[1402 0 R]endobj 1404 0 obj<>endobj 1405 0 obj<>endobj 1406 0 obj[1404 0 R 1405 0 R]endobj 1407 0 obj<>endobj 1408 0 obj[1407 0 R]endobj 1409 0 obj<>endobj 1410 0 obj<>endobj 1411 0 obj<>endobj 1412 0 obj<>endobj 1413 0 obj[1410 0 R 1412 0 R]endobj 1414 0 obj<>endobj 1415 0 obj[1414 0 R]endobj 1416 0 obj<>endobj 1417 0 obj[1416 0 R]endobj 1418 0 obj<>endobj 1419 0 obj<>endobj 1420 0 obj[1418 0 R 1419 0 R]endobj 1421 0 obj<>endobj 1422 0 obj[1421 0 R]endobj 1423 0 obj<>endobj 1424 0 obj[1423 0 R]endobj 1425 0 obj<>endobj 1426 0 obj<>endobj 1427 0 obj<>endobj 1428 0 obj<>endobj 1429 0 obj[1426 0 R 1428 0 R]endobj 1430 0 obj<>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[1430 0 R 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]endobj 1476 0 obj<>endobj 1477 0 obj[1476 0 R]endobj 1478 0 obj<>endobj 1479 0 obj[1478 0 R]endobj 1480 0 obj<>endobj 1481 0 obj[1480 0 R]endobj 1482 0 obj<>endobj 1483 0 obj[1482 0 R]endobj 1484 0 obj<>endobj 1485 0 obj[1484 0 R]endobj 1486 0 obj<>endobj 1487 0 obj<>endobj 1488 0 obj[1486 0 R 1487 0 R]endobj 1489 0 obj<>endobj 1490 0 obj<>endobj 1491 0 obj<>endobj 1492 0 obj<>endobj 1493 0 obj<>endobj 1494 0 obj[1489 0 R 1490 0 R 1491 0 R 1492 0 R 1493 0 R]endobj 1495 0 obj<>endobj 1496 0 obj[1495 0 R]endobj 1497 0 obj<>endobj 1498 0 obj[1497 0 R]endobj 1499 0 obj<>endobj 1500 0 obj<>endobj 1501 0 obj[1500 0 R]endobj 1502 0 obj<>endobj 1503 0 obj<>endobj 1504 0 obj[1503 0 R]endobj 1505 0 obj<>endobj 1506 0 obj[1505 0 R]endobj 1507 0 obj<>endobj 1508 0 obj<>endobj 1509 0 obj<>endobj 1510 0 obj[1507 0 R 1508 0 R 1509 0 R]endobj 1511 0 obj<>endobj 1512 0 obj[1511 0 R]endobj 1513 0 obj<>endobj 1514 0 obj[1513 0 R]endobj 1515 0 obj<>endobj 1516 0 obj<>endobj 1517 0 obj<>endobj 1518 0 obj[1515 0 R 1516 0 R 1517 0 R]endobj 1519 0 obj<>endobj 1520 0 obj<>endobj 1521 0 obj[1519 0 R 1520 0 R]endobj 1522 0 obj<>endobj 1523 0 obj[1522 0 R]endobj 1524 0 obj<>endobj 1525 0 obj[1524 0 R]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[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]endobj 1541 0 obj<>endobj 1542 0 obj[1541 0 R]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[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]endobj 1562 0 obj<>endobj 1563 0 obj[1562 0 R]endobj 1564 0 obj<>endobj 1565 0 obj[1564 0 R]endobj 1566 0 obj<>endobj 1567 0 obj<>endobj 1568 0 obj<>endobj 1569 0 obj<>endobj 1570 0 obj<>endobj 1571 0 obj<>endobj 1572 0 obj<>endobj 1573 0 obj<>endobj 1574 0 obj<>endobj 1575 0 obj<>endobj 1576 0 obj[1566 0 R 1567 0 R 1568 0 R 1569 0 R 1570 0 R 1571 0 R 1572 0 R 1573 0 R 1574 0 R 1575 0 R]endobj 1577 0 obj<>endobj 1578 0 obj<>endobj 1579 0 obj<>endobj 1580 0 obj<>endobj 1581 0 obj<>endobj 1582 0 obj<>endobj 1583 0 obj<>endobj 1584 0 obj<>endobj 1585 0 obj<>endobj 1586 0 obj<>endobj 1587 0 obj<>endobj 1588 0 obj<>endobj 1589 0 obj<>endobj 1590 0 obj<>endobj 1591 0 obj<>endobj 1592 0 obj<>endobj 1593 0 obj<>endobj 1594 0 obj<>endobj 1595 0 obj<>endobj 1596 0 obj<>endobj 1597 0 obj<>endobj 1598 0 obj<>endobj 1599 0 obj<>endobj 1600 0 obj<>endobj 1601 0 obj<>endobj 1602 0 obj<>endobj 1603 0 obj<>endobj 1604 0 obj<>endobj 1605 0 obj<>endobj 1606 0 obj<>endobj 1607 0 obj<>endobj 1608 0 obj<>endobj 1609 0 obj<>endobj 1610 0 obj<>endobj 1611 0 obj<>endobj 1612 0 obj<>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[1577 0 R 1578 0 R 1579 0 R 1580 0 R 1581 0 R 1582 0 R 1583 0 R 1584 0 R 1585 0 R 1586 0 R 1587 0 R 1588 0 R 1589 0 R 1590 0 R 1591 0 R 1592 0 R 1593 0 R 1594 0 R 1595 0 R 1596 0 R 1597 0 R 1598 0 R 1599 0 R 1600 0 R 1601 0 R 1602 0 R 1603 0 R 1604 0 R 1605 0 R 1606 0 R 1607 0 R 1608 0 R 1609 0 R 1610 0 R 1611 0 R 1612 0 R 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]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[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]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[1642 0 R 1644 0 R 1646 0 R 1647 0 R]endobj 1649 0 obj<>endobj 1650 0 obj<>endobj 1651 0 obj[1649 0 R 1650 0 R]endobj 1652 0 obj<>endobj 1653 0 obj[1652 0 R]endobj 1654 0 obj<>endobj 1655 0 obj[1654 0 R]endobj 1656 0 obj<>endobj 1657 0 obj[1656 0 R]endobj 1658 0 obj<>endobj 1659 0 obj[1658 0 R]endobj 1660 0 obj<>endobj 1661 0 obj[1660 0 R]endobj 1662 0 obj<>endobj 1663 0 obj<>endobj 1664 0 obj[1662 0 R 1663 0 R]endobj 1665 0 obj<>endobj 1666 0 obj<>endobj 1667 0 obj<>endobj 1668 0 obj<>endobj 1669 0 obj[1665 0 R 1666 0 R 1667 0 R 1668 0 R]endobj 1670 0 obj<>endobj 1671 0 obj[1670 0 R]endobj 1672 0 obj<>endobj 1673 0 obj[1672 0 R]endobj 1674 0 obj<>endobj 1675 0 obj[1674 0 R]endobj 1676 0 obj<>endobj 1677 0 obj[1676 0 R]endobj 1678 0 obj<>endobj 1679 0 obj[1678 0 R]endobj 1680 0 obj<>endobj 1681 0 obj[1680 0 R]endobj 1682 0 obj<>endobj 1683 0 obj<>endobj 1684 0 obj[1682 0 R 1683 0 R]endobj 1685 0 obj<>endobj 1686 0 obj[1685 0 R]endobj 1687 0 obj<>endobj 1688 0 obj<>endobj 1689 0 obj[1687 0 R 1688 0 R]endobj 1690 0 obj<>endobj 1691 0 obj[1690 0 R]endobj 1692 0 obj<>endobj 1693 0 obj<>endobj 1694 0 obj<>endobj 1695 0 obj<>endobj 1696 0 obj<>endobj 1697 0 obj<>endobj 1698 0 obj<>endobj 1699 0 obj<>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[1692 0 R 1693 0 R 1694 0 R 1695 0 R 1696 0 R 1697 0 R 1698 0 R 1699 0 R 1700 0 R 1701 0 R 1702 0 R 1703 0 R 1704 0 R 1705 0 R 1706 0 R 1707 0 R]endobj 1709 0 obj<>endobj 1710 0 obj<>endobj 1711 0 obj[1709 0 R 1710 0 R]endobj 1712 0 obj<>endobj 1713 0 obj[1712 0 R]endobj 1714 0 obj<>endobj 1715 0 obj<>endobj 1716 0 obj[1714 0 R 1715 0 R]endobj 1717 0 obj<>endobj 1718 0 obj<>endobj 1719 0 obj[1717 0 R 1718 0 R]endobj 1720 0 obj<>endobj 1721 0 obj<>endobj 1722 0 obj[1720 0 R 1721 0 R]endobj 1723 0 obj<>endobj 1724 0 obj<>endobj 1725 0 obj<>endobj 1726 0 obj<>endobj 1727 0 obj[1723 0 R 1724 0 R 1725 0 R 1726 0 R]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[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]endobj 1738 0 obj<>endobj 1739 0 obj<>endobj 1740 0 obj[1738 0 R 1739 0 R]endobj 1741 0 obj<>endobj 1742 0 obj<>endobj 1743 0 obj[1742 0 R]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[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]endobj 1763 0 obj<>endobj 1764 0 obj[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[1765 0 R 1766 0 R 1767 0 R 1768 0 R 1769 0 R 1770 0 R 1771 0 R]endobj 1773 0 obj<>endobj 1774 0 obj[1773 0 R]endobj 1775 0 obj<>endobj 1776 0 obj<>endobj 1777 0 obj[1775 0 R 1776 0 R]endobj 1778 0 obj<>endobj 1779 0 obj<>endobj 1780 0 obj<>endobj 1781 0 obj<>endobj 1782 0 obj<>endobj 1783 0 obj<>endobj 1784 0 obj<>endobj 1785 0 obj<>endobj 1786 0 obj<>endobj 1787 0 obj<>endobj 1788 0 obj<>endobj 1789 0 obj<>endobj 1790 0 obj<>endobj 1791 0 obj<>endobj 1792 0 obj<>endobj 1793 0 obj<>endobj 1794 0 obj<>endobj 1795 0 obj[1778 0 R 1779 0 R 1780 0 R 1781 0 R 1782 0 R 1783 0 R 1784 0 R 1785 0 R 1786 0 R 1787 0 R 1788 0 R 1789 0 R 1790 0 R 1791 0 R 1792 0 R 1793 0 R 1794 0 R]endobj 1796 0 obj<>endobj 1797 0 obj<>endobj 1798 0 obj[1797 0 R]endobj 1799 0 obj<>endobj 1800 0 obj<>endobj 1801 0 obj<>endobj 1802 0 obj<>endobj 1803 0 obj[1800 0 R 1802 0 R]endobj 1804 0 obj<>endobj 1805 0 obj<>endobj 1806 0 obj<>endobj 1807 0 obj<>endobj 1808 0 obj<>endobj 1809 0 obj<>endobj 1810 0 obj<>endobj 1811 0 obj<>endobj 1812 0 obj<>endobj 1813 0 obj<>endobj 1814 0 obj<>endobj 1815 0 obj<>endobj 1816 0 obj<>endobj 1817 0 obj<>endobj 1818 0 obj<>endobj 1819 0 obj<>endobj 1820 0 obj<>endobj 1821 0 obj<>endobj 1822 0 obj<>endobj 1823 0 obj<>endobj 1824 0 obj<>endobj 1825 0 obj<>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<>endobj 1843 0 obj<>endobj 1844 0 obj<>endobj 1845 0 obj<>endobj 1846 0 obj<>endobj 1847 0 obj<>endobj 1848 0 obj<>endobj 1849 0 obj<>endobj 1850 0 obj<>endobj 1851 0 obj<>endobj 1852 0 obj<>endobj 1853 0 obj<>endobj 1854 0 obj<>endobj 1855 0 obj<>endobj 1856 0 obj<>endobj 1857 0 obj[1804 0 R 1805 0 R 1806 0 R 1807 0 R 1808 0 R 1809 0 R 1810 0 R 1811 0 R 1812 0 R 1813 0 R 1814 0 R 1815 0 R 1816 0 R 1817 0 R 1818 0 R 1819 0 R 1820 0 R 1821 0 R 1822 0 R 1823 0 R 1824 0 R 1825 0 R 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 1842 0 R 1843 0 R 1844 0 R 1845 0 R 1846 0 R 1847 0 R 1848 0 R 1849 0 R 1850 0 R 1851 0 R 1852 0 R 1853 0 R 1854 0 R 1855 0 R 1856 0 R]endobj 1858 0 obj<>endobj 1859 0 obj<>endobj 1860 0 obj<>endobj 1861 0 obj[1858 0 R 1859 0 R 1860 0 R]endobj 1862 0 obj<>endobj 1863 0 obj[1862 0 R]endobj 1864 0 obj<>endobj 1865 0 obj<>endobj 1866 0 obj[1864 0 R 1865 0 R]endobj 1867 0 obj<>endobj 1868 0 obj<>endobj 1869 0 obj[1867 0 R 1868 0 R]endobj 1870 0 obj<>endobj 1871 0 obj<>endobj 1872 0 obj<>endobj 1873 0 obj<>endobj 1874 0 obj<>endobj 1875 0 obj<>endobj 1876 0 obj<>endobj 1877 0 obj<>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[1870 0 R 1871 0 R 1872 0 R 1873 0 R 1874 0 R 1875 0 R 1876 0 R 1877 0 R 1879 0 R 1881 0 R 1882 0 R 1884 0 R]endobj 1886 0 obj<>endobj 1887 0 obj<>endobj 1888 0 obj[1887 0 R]endobj 1889 0 obj<>endobj 1890 0 obj<>endobj 1891 0 obj[1890 0 R]endobj 1892 0 obj<>endobj 1893 0 obj[1892 0 R]endobj 1894 0 obj<>endobj 1895 0 obj<>endobj 1896 0 obj<>endobj 1897 0 obj<>endobj 1898 0 obj<>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<>endobj 1907 0 obj<>endobj 1908 0 obj<>endobj 1909 0 obj<>endobj 1910 0 obj<>endobj 1911 0 obj<>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<>endobj 1930 0 obj<>endobj 1931 0 obj[1894 0 R 1895 0 R 1896 0 R 1897 0 R 1898 0 R 1899 0 R 1900 0 R 1901 0 R 1902 0 R 1903 0 R 1904 0 R 1905 0 R 1906 0 R 1907 0 R 1908 0 R 1909 0 R 1910 0 R 1911 0 R 1912 0 R 1913 0 R 1914 0 R 1915 0 R 1916 0 R 1917 0 R 1918 0 R 1919 0 R 1921 0 R 1923 0 R 1925 0 R 1927 0 R 1929 0 R 1930 0 R]endobj 1932 0 obj<>endobj 1933 0 obj<>endobj 1934 0 obj[1932 0 R 1933 0 R]endobj 1935 0 obj<>endobj 1936 0 obj<>endobj 1937 0 obj<>endobj 1938 0 obj<>endobj 1939 0 obj<>endobj 1940 0 obj<>endobj 1941 0 obj<>endobj 1942 0 obj[1935 0 R 1936 0 R 1937 0 R 1938 0 R 1939 0 R 1940 0 R 1941 0 R]endobj 1943 0 obj<>endobj 1944 0 obj[1943 0 R]endobj 1945 0 obj<>endobj 1946 0 obj<>endobj 1947 0 obj<>endobj 1948 0 obj<>endobj 1949 0 obj<>endobj 1950 0 obj[1945 0 R 1947 0 R 1949 0 R]endobj 1951 0 obj<>endobj 1952 0 obj<>endobj 1953 0 obj<>endobj 1954 0 obj[1951 0 R 1953 0 R]endobj 1955 0 obj<>endobj 1956 0 obj<>endobj 1957 0 obj[1956 0 R]endobj 1958 0 obj<>endobj 1959 0 obj<>endobj 1960 0 obj[1958 0 R 1959 0 R]endobj 1961 0 obj<>endobj 1962 0 obj[1961 0 R]endobj 1963 0 obj<>endobj 1964 0 obj[1963 0 R]endobj 1965 0 obj<>endobj 1966 0 obj[1965 0 R]endobj 1967 0 obj<>endobj 1968 0 obj[1967 0 R]endobj 1969 0 obj<>endobj 1970 0 obj[1969 0 R]endobj 1971 0 obj<>endobj 1972 0 obj<>endobj 1973 0 obj<>endobj 1974 0 obj[1971 0 R 1972 0 R 1973 0 R]endobj 1975 0 obj<>endobj 1976 0 obj[1975 0 R]endobj 1977 0 obj<>endobj 1978 0 obj[1977 0 R]endobj 1979 0 obj<>endobj 1980 0 obj[1979 0 R]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<>endobj 1992 0 obj<>endobj 1993 0 obj<>endobj 1994 0 obj<>endobj 1995 0 obj<>endobj 1996 0 obj<>endobj 1997 0 obj<>endobj 1998 0 obj<>endobj 1999 0 obj<>endobj 2000 0 obj<>endobj 2001 0 obj[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 1991 0 R 1992 0 R 1993 0 R 1994 0 R 1995 0 R 1996 0 R 1997 0 R 1998 0 R 1999 0 R 2000 0 R]endobj 2002 0 obj<>endobj 2003 0 obj<>endobj 2004 0 obj<>endobj 2005 0 obj<>endobj 2006 0 obj<>endobj 2007 0 obj[2002 0 R 2003 0 R 2004 0 R 2006 0 R]endobj 2008 0 obj<>endobj 2009 0 obj<>endobj 2010 0 obj<>endobj 2011 0 obj[2008 0 R 2009 0 R 2010 0 R]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<>endobj 2020 0 obj<>endobj 2021 0 obj<>endobj 2022 0 obj<>endobj 2023 0 obj<>endobj 2024 0 obj<>endobj 2025 0 obj<>endobj 2026 0 obj<>endobj 2027 0 obj<>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[2012 0 R 2013 0 R 2014 0 R 2015 0 R 2016 0 R 2017 0 R 2018 0 R 2019 0 R 2020 0 R 2021 0 R 2022 0 R 2023 0 R 2024 0 R 2025 0 R 2026 0 R 2027 0 R 2028 0 R 2029 0 R 2030 0 R 2031 0 R 2032 0 R 2034 0 R 2036 0 R 2037 0 R 2038 0 R]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[2040 0 R 2041 0 R 2042 0 R 2043 0 R 2044 0 R 2045 0 R 2046 0 R 2047 0 R]endobj 2049 0 obj<>endobj 2050 0 obj<>endobj 2051 0 obj<>endobj 2052 0 obj<>endobj 2053 0 obj<>endobj 2054 0 obj[2049 0 R 2050 0 R 2051 0 R 2052 0 R 2053 0 R]endobj 2055 0 obj<>endobj 2056 0 obj<>endobj 2057 0 obj<>endobj 2058 0 obj<>endobj 2059 0 obj[2055 0 R 2056 0 R 2057 0 R 2058 0 R]endobj 2060 0 obj<>endobj 2061 0 obj<>endobj 2062 0 obj<>endobj 2063 0 obj[2060 0 R 2061 0 R 2062 0 R]endobj 2064 0 obj<>endobj 2065 0 obj<>endobj 2066 0 obj<>endobj 2067 0 obj<>endobj 2068 0 obj[2064 0 R 2065 0 R 2066 0 R 2067 0 R]endobj 2069 0 obj<>endobj 2070 0 obj<>endobj 2071 0 obj<>endobj 2072 0 obj<>endobj 2073 0 obj<>endobj 2074 0 obj<>endobj 2075 0 obj[2070 0 R 2072 0 R 2073 0 R 2074 0 R]endobj 2076 0 obj<>endobj 2077 0 obj<>endobj 2078 0 obj<>endobj 2079 0 obj<>endobj 2080 0 obj<>endobj 2081 0 obj<>endobj 2082 0 obj<>endobj 2083 0 obj<>endobj 2084 0 obj<>endobj 2085 0 obj<>endobj 2086 0 obj<>endobj 2087 0 obj<>endobj 2088 0 obj<>endobj 2089 0 obj<>endobj 2090 0 obj<>endobj 2091 0 obj<>endobj 2092 0 obj<>endobj 2093 0 obj<>endobj 2094 0 obj[2076 0 R 2077 0 R 2078 0 R 2079 0 R 2080 0 R 2081 0 R 2082 0 R 2083 0 R 2084 0 R 2085 0 R 2086 0 R 2087 0 R 2088 0 R 2089 0 R 2090 0 R 2091 0 R 2093 0 R]endobj 2095 0 obj<>endobj 2096 0 obj[2095 0 R]endobj 2097 0 obj<>endobj 2098 0 obj<>endobj 2099 0 obj[2098 0 R]endobj 2100 0 obj<>endobj 2101 0 obj<>endobj 2102 0 obj<>endobj 2103 0 obj<>endobj 2104 0 obj<>endobj 2105 0 obj<>endobj 2106 0 obj<>endobj 2107 0 obj<>endobj 2108 0 obj<>endobj 2109 0 obj<>endobj 2110 0 obj<>endobj 2111 0 obj<>endobj 2112 0 obj<>endobj 2113 0 obj<>endobj 2114 0 obj<>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[2100 0 R 2101 0 R 2102 0 R 2103 0 R 2104 0 R 2105 0 R 2106 0 R 2107 0 R 2108 0 R 2109 0 R 2110 0 R 2111 0 R 2112 0 R 2113 0 R 2114 0 R 2115 0 R 2116 0 R 2117 0 R 2118 0 R 2119 0 R 2121 0 R]endobj 2123 0 obj<>endobj 2124 0 obj[2123 0 R]endobj 2125 0 obj<>endobj 2126 0 obj<>endobj 2127 0 obj[2125 0 R 2126 0 R]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<>endobj 2136 0 obj<>endobj 2137 0 obj<>endobj 2138 0 obj<>endobj 2139 0 obj<>endobj 2140 0 obj<>endobj 2141 0 obj<>endobj 2142 0 obj<>endobj 2143 0 obj<>endobj 2144 0 obj<>endobj 2145 0 obj<>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<>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[2128 0 R 2129 0 R 2130 0 R 2131 0 R 2132 0 R 2133 0 R 2134 0 R 2135 0 R 2136 0 R 2137 0 R 2138 0 R 2139 0 R 2140 0 R 2141 0 R 2142 0 R 2143 0 R 2144 0 R 2145 0 R 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 2167 0 R 2168 0 R 2169 0 R 2170 0 R 2171 0 R 2172 0 R 2173 0 R 2174 0 R 2175 0 R 2176 0 R 2177 0 R 2178 0 R 2179 0 R 2180 0 R]endobj 2182 0 obj<>endobj 2183 0 obj<>endobj 2184 0 obj<>endobj 2185 0 obj<>endobj 2186 0 obj<>endobj 2187 0 obj<>endobj 2188 0 obj<>endobj 2189 0 obj<>endobj 2190 0 obj<>endobj 2191 0 obj<>endobj 2192 0 obj<>endobj 2193 0 obj<>endobj 2194 0 obj<>endobj 2195 0 obj<>endobj 2196 0 obj<>endobj 2197 0 obj<>endobj 2198 0 obj<>endobj 2199 0 obj<>endobj 2200 0 obj<>endobj 2201 0 obj<>endobj 2202 0 obj<>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<>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<>endobj 2229 0 obj<>endobj 2230 0 obj<>endobj 2231 0 obj<>endobj 2232 0 obj[2182 0 R 2183 0 R 2184 0 R 2185 0 R 2186 0 R 2187 0 R 2188 0 R 2189 0 R 2190 0 R 2191 0 R 2192 0 R 2193 0 R 2194 0 R 2195 0 R 2196 0 R 2197 0 R 2198 0 R 2199 0 R 2200 0 R 2201 0 R 2202 0 R 2203 0 R 2204 0 R 2205 0 R 2206 0 R 2207 0 R 2208 0 R 2209 0 R 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 2226 0 R 2227 0 R 2228 0 R 2229 0 R 2230 0 R 2231 0 R]endobj 2233 0 obj<>endobj 2234 0 obj<>endobj 2235 0 obj<>endobj 2236 0 obj[2233 0 R 2234 0 R 2235 0 R]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[2237 0 R 2238 0 R 2239 0 R 2241 0 R 2243 0 R]endobj 2245 0 obj<>endobj 2246 0 obj<>endobj 2247 0 obj<>endobj 2248 0 obj[2245 0 R 2246 0 R 2247 0 R]endobj 2249 0 obj<>endobj 2250 0 obj<>endobj 2251 0 obj[2250 0 R]endobj 2252 0 obj<>endobj 2253 0 obj<>endobj 2254 0 obj[2252 0 R 2253 0 R]endobj 2255 0 obj<>endobj 2256 0 obj<>endobj 2257 0 obj<>endobj 2258 0 obj[2255 0 R 2256 0 R 2257 0 R]endobj 2259 0 obj<>endobj 2260 0 obj<>endobj 2261 0 obj<>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[2259 0 R 2261 0 R 2263 0 R 2265 0 R 2267 0 R 2269 0 R 2271 0 R]endobj 2273 0 obj<>endobj 2274 0 obj<>endobj 2275 0 obj<>endobj 2276 0 obj<>endobj 2277 0 obj<>endobj 2278 0 obj[2273 0 R 2274 0 R 2275 0 R 2276 0 R 2277 0 R]endobj 2279 0 obj<>endobj 2280 0 obj<>endobj 2281 0 obj[2279 0 R 2280 0 R]endobj 2282 0 obj<>endobj 2283 0 obj<>endobj 2284 0 obj[2282 0 R 2283 0 R]endobj 2285 0 obj<>endobj 2286 0 obj<>endobj 2287 0 obj[2285 0 R 2286 0 R]endobj 2288 0 obj<>endobj 2289 0 obj[2288 0 R]endobj 2290 0 obj<>endobj 2291 0 obj<>endobj 2292 0 obj<>endobj 2293 0 obj<>endobj 2294 0 obj<>endobj 2295 0 obj[2290 0 R 2291 0 R 2292 0 R 2293 0 R 2294 0 R]endobj 2296 0 obj<>endobj 2297 0 obj[2296 0 R]endobj 2298 0 obj<>endobj 2299 0 obj<>endobj 2300 0 obj<>endobj 2301 0 obj<>endobj 2302 0 obj<>endobj 2303 0 obj[2298 0 R 2300 0 R 2302 0 R]endobj 2304 0 obj<>endobj 2305 0 obj[2304 0 R]endobj 2306 0 obj<>endobj 2307 0 obj<>endobj 2308 0 obj<>endobj 2309 0 obj[2306 0 R 2307 0 R 2308 0 R]endobj 2310 0 obj<>endobj 2311 0 obj<>endobj 2312 0 obj<>endobj 2313 0 obj[2310 0 R 2312 0 R]endobj 2314 0 obj<>endobj 2315 0 obj<>endobj 2316 0 obj<>endobj 2317 0 obj<>endobj 2318 0 obj<>endobj 2319 0 obj<>endobj 2320 0 obj[2315 0 R 2316 0 R 2317 0 R 2319 0 R]endobj 2321 0 obj<>endobj 2322 0 obj[2321 0 R]endobj 2323 0 obj<>endobj 2324 0 obj[2323 0 R]endobj 2325 0 obj<>endobj 2326 0 obj[2325 0 R]endobj 2327 0 obj<>endobj 2328 0 obj[2327 0 R]endobj 2329 0 obj<>endobj 2330 0 obj[2329 0 R]endobj 2331 0 obj<>endobj 2332 0 obj[2331 0 R]endobj 2333 0 obj<>endobj 2334 0 obj[2333 0 R]endobj 2335 0 obj<>endobj 2336 0 obj<>endobj 2337 0 obj<>endobj 2338 0 obj<>endobj 2339 0 obj<>endobj 2340 0 obj[2335 0 R 2336 0 R 2337 0 R 2338 0 R 2339 0 R]endobj 2341 0 obj<>endobj 2342 0 obj[2341 0 R]endobj 2343 0 obj<>endobj 2344 0 obj<>endobj 2345 0 obj[2343 0 R 2344 0 R]endobj 2346 0 obj<>endobj 2347 0 obj[2346 0 R]endobj 2348 0 obj<>endobj 2349 0 obj<>endobj 2350 0 obj<>endobj 2351 0 obj<>endobj 2352 0 obj[2349 0 R 2351 0 R]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[2353 0 R 2354 0 R 2355 0 R 2356 0 R 2357 0 R 2358 0 R]endobj 2360 0 obj<>endobj 2361 0 obj<>endobj 2362 0 obj<>endobj 2363 0 obj<>endobj 2364 0 obj<>endobj 2365 0 obj[2361 0 R 2362 0 R 2363 0 R 2364 0 R]endobj 2366 0 obj<>endobj 2367 0 obj<>endobj 2368 0 obj<>endobj 2369 0 obj<>endobj 2370 0 obj<>endobj 2371 0 obj<>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[2366 0 R 2367 0 R 2368 0 R 2369 0 R 2370 0 R 2371 0 R 2372 0 R 2373 0 R 2374 0 R 2375 0 R 2376 0 R 2377 0 R 2378 0 R]endobj 2380 0 obj<>endobj 2381 0 obj[2380 0 R]endobj 2382 0 obj<>endobj 2383 0 obj<>endobj 2384 0 obj[2382 0 R 2383 0 R]endobj 2385 0 obj<>endobj 2386 0 obj<>endobj 2387 0 obj<>endobj 2388 0 obj[2385 0 R 2386 0 R 2387 0 R]endobj 2389 0 obj<>endobj 2390 0 obj[2389 0 R]endobj 2391 0 obj<>endobj 2392 0 obj<>endobj 2393 0 obj[2391 0 R 2392 0 R]endobj 2394 0 obj<>endobj 2395 0 obj<>endobj 2396 0 obj[2394 0 R 2395 0 R]endobj 2397 0 obj<>endobj 2398 0 obj[2397 0 R]endobj 2399 0 obj<>endobj 2400 0 obj[2399 0 R]endobj 2401 0 obj<>endobj 2402 0 obj<>endobj 2403 0 obj[2401 0 R 2402 0 R]endobj 2404 0 obj<>endobj 2405 0 obj[2404 0 R]endobj 2406 0 obj<>endobj 2407 0 obj[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<>endobj 2414 0 obj<>endobj 2415 0 obj<>endobj 2416 0 obj<>endobj 2417 0 obj<>endobj 2418 0 obj<>endobj 2419 0 obj[2408 0 R 2409 0 R 2410 0 R 2411 0 R 2412 0 R 2413 0 R 2414 0 R 2415 0 R 2416 0 R 2417 0 R 2418 0 R]endobj 2420 0 obj<>endobj 2421 0 obj[2420 0 R]endobj 2422 0 obj<>endobj 2423 0 obj<>endobj 2424 0 obj<>endobj 2425 0 obj[2422 0 R 2424 0 R]endobj 2426 0 obj<>endobj 2427 0 obj<>endobj 2428 0 obj<>endobj 2429 0 obj<>endobj 2430 0 obj<>endobj 2431 0 obj<>endobj 2432 0 obj<>endobj 2433 0 obj<>endobj 2434 0 obj<>endobj 2435 0 obj<>endobj 2436 0 obj<>endobj 2437 0 obj<>endobj 2438 0 obj<>endobj 2439 0 obj<>endobj 2440 0 obj<>endobj 2441 0 obj<>endobj 2442 0 obj<>endobj 2443 0 obj<>endobj 2444 0 obj<>endobj 2445 0 obj<>endobj 2446 0 obj<>endobj 2447 0 obj<>endobj 2448 0 obj<>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<>endobj 2456 0 obj<>endobj 2457 0 obj<>endobj 2458 0 obj<>endobj 2459 0 obj<>endobj 2460 0 obj<>endobj 2461 0 obj<>endobj 2462 0 obj<>endobj 2463 0 obj<>endobj 2464 0 obj<>endobj 2465 0 obj<>endobj 2466 0 obj<>endobj 2467 0 obj<>endobj 2468 0 obj[2426 0 R 2427 0 R 2428 0 R 2429 0 R 2430 0 R 2431 0 R 2432 0 R 2433 0 R 2434 0 R 2435 0 R 2436 0 R 2437 0 R 2438 0 R 2439 0 R 2440 0 R 2441 0 R 2442 0 R 2443 0 R 2444 0 R 2445 0 R 2446 0 R 2447 0 R 2448 0 R 2449 0 R 2450 0 R 2451 0 R 2452 0 R 2453 0 R 2454 0 R 2455 0 R 2456 0 R 2457 0 R 2458 0 R 2459 0 R 2460 0 R 2461 0 R 2462 0 R 2463 0 R 2465 0 R 2467 0 R]endobj 2469 0 obj<>endobj 2470 0 obj<>endobj 2471 0 obj[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<>endobj 2477 0 obj[2474 0 R 2475 0 R 2476 0 R]endobj 2478 0 obj<>endobj 2479 0 obj[2478 0 R]endobj 2480 0 obj<>endobj 2481 0 obj<>endobj 2482 0 obj[2480 0 R 2481 0 R]endobj 2483 0 obj<>endobj 2484 0 obj<>endobj 2485 0 obj<>endobj 2486 0 obj<>endobj 2487 0 obj<>endobj 2488 0 obj<>endobj 2489 0 obj<>endobj 2490 0 obj<>endobj 2491 0 obj<>endobj 2492 0 obj<>endobj 2493 0 obj<>endobj 2494 0 obj<>endobj 2495 0 obj<>endobj 2496 0 obj<>endobj 2497 0 obj<>endobj 2498 0 obj<>endobj 2499 0 obj<>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<>endobj 2507 0 obj<>endobj 2508 0 obj<>endobj 2509 0 obj<>endobj 2510 0 obj[2483 0 R 2484 0 R 2485 0 R 2486 0 R 2487 0 R 2488 0 R 2489 0 R 2490 0 R 2491 0 R 2492 0 R 2493 0 R 2494 0 R 2495 0 R 2496 0 R 2497 0 R 2498 0 R 2499 0 R 2500 0 R 2501 0 R 2503 0 R 2504 0 R 2505 0 R 2507 0 R 2509 0 R]endobj 2511 0 obj<>endobj 2512 0 obj<>endobj 2513 0 obj<>endobj 2514 0 obj<>endobj 2515 0 obj<>endobj 2516 0 obj[2511 0 R 2512 0 R 2513 0 R 2514 0 R 2515 0 R]endobj 2517 0 obj<>endobj 2518 0 obj[2517 0 R]endobj 2519 0 obj<>endobj 2520 0 obj<>endobj 2521 0 obj<>endobj 2522 0 obj[2519 0 R 2520 0 R 2521 0 R]endobj 2523 0 obj<>endobj 2524 0 obj<>endobj 2525 0 obj<>endobj 2526 0 obj<>endobj 2527 0 obj[2524 0 R 2526 0 R]endobj 2528 0 obj<>endobj 2529 0 obj<>endobj 2530 0 obj<>endobj 2531 0 obj<>endobj 2532 0 obj<>endobj 2533 0 obj<>endobj 2534 0 obj<>endobj 2535 0 obj<>endobj 2536 0 obj<>endobj 2537 0 obj<>endobj 2538 0 obj<>endobj 2539 0 obj<>endobj 2540 0 obj<>endobj 2541 0 obj<>endobj 2542 0 obj<>endobj 2543 0 obj<>endobj 2544 0 obj<>endobj 2545 0 obj<>endobj 2546 0 obj<>endobj 2547 0 obj<>endobj 2548 0 obj<>endobj 2549 0 obj<>endobj 2550 0 obj<>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[2528 0 R 2529 0 R 2530 0 R 2531 0 R 2532 0 R 2533 0 R 2534 0 R 2535 0 R 2536 0 R 2537 0 R 2538 0 R 2539 0 R 2540 0 R 2541 0 R 2542 0 R 2543 0 R 2544 0 R 2545 0 R 2546 0 R 2547 0 R 2548 0 R 2549 0 R 2550 0 R 2551 0 R 2552 0 R 2553 0 R 2554 0 R 2555 0 R 2556 0 R 2557 0 R 2558 0 R 2560 0 R 2562 0 R]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<>endobj 2581 0 obj<>endobj 2582 0 obj<>endobj 2583 0 obj<>endobj 2584 0 obj<>endobj 2585 0 obj<>endobj 2586 0 obj<>endobj 2587 0 obj<>endobj 2588 0 obj<>endobj 2589 0 obj[2564 0 R 2565 0 R 2566 0 R 2567 0 R 2568 0 R 2569 0 R 2570 0 R 2571 0 R 2572 0 R 2573 0 R 2574 0 R 2575 0 R 2576 0 R 2577 0 R 2578 0 R 2579 0 R 2580 0 R 2581 0 R 2582 0 R 2583 0 R 2584 0 R 2585 0 R 2586 0 R 2588 0 R]endobj 2590 0 obj<>endobj 2591 0 obj[2590 0 R]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<>endobj 2604 0 obj<>endobj 2605 0 obj<>endobj 2606 0 obj<>endobj 2607 0 obj<>endobj 2608 0 obj<>endobj 2609 0 obj<>endobj 2610 0 obj<>endobj 2611 0 obj<>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<>endobj 2624 0 obj<>endobj 2625 0 obj<>endobj 2626 0 obj<>endobj 2627 0 obj<>endobj 2628 0 obj<>endobj 2629 0 obj<>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[2592 0 R 2593 0 R 2594 0 R 2595 0 R 2596 0 R 2597 0 R 2598 0 R 2599 0 R 2600 0 R 2601 0 R 2602 0 R 2603 0 R 2604 0 R 2605 0 R 2606 0 R 2607 0 R 2608 0 R 2609 0 R 2610 0 R 2611 0 R 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 2623 0 R 2624 0 R 2625 0 R 2626 0 R 2627 0 R 2628 0 R 2629 0 R 2630 0 R 2631 0 R 2632 0 R 2633 0 R 2634 0 R 2635 0 R 2636 0 R 2637 0 R]endobj 2639 0 obj<>endobj 2640 0 obj<>endobj 2641 0 obj[2640 0 R]endobj 2642 0 obj<>endobj 2643 0 obj<>endobj 2644 0 obj[2643 0 R]endobj 2645 0 obj<>endobj 2646 0 obj[2645 0 R]endobj 2647 0 obj<>endobj 2648 0 obj<>endobj 2649 0 obj[2647 0 R 2648 0 R]endobj 2650 0 obj<>endobj 2651 0 obj<>endobj 2652 0 obj[2650 0 R 2651 0 R]endobj 2653 0 obj<>endobj 2654 0 obj[2653 0 R]endobj 2655 0 obj<>endobj 2656 0 obj[2655 0 R]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<>endobj 2676 0 obj<>endobj 2677 0 obj<>endobj 2678 0 obj<>endobj 2679 0 obj<>endobj 2680 0 obj<>endobj 2681 0 obj[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 2673 0 R 2674 0 R 2675 0 R 2676 0 R 2677 0 R 2678 0 R 2679 0 R 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[2684 0 R 2685 0 R]endobj 2687 0 obj<>endobj 2688 0 obj<>endobj 2689 0 obj<>endobj 2690 0 obj<>endobj 2691 0 obj<>endobj 2692 0 obj<>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[2687 0 R 2688 0 R 2689 0 R 2690 0 R 2691 0 R 2692 0 R 2693 0 R 2694 0 R 2695 0 R 2696 0 R 2697 0 R 2698 0 R]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<>endobj 2721 0 obj<>endobj 2722 0 obj<>endobj 2723 0 obj<>endobj 2724 0 obj<>endobj 2725 0 obj<>endobj 2726 0 obj<>endobj 2727 0 obj<>endobj 2728 0 obj<>endobj 2729 0 obj<>endobj 2730 0 obj<>endobj 2731 0 obj<>endobj 2732 0 obj<>endobj 2733 0 obj<>endobj 2734 0 obj<>endobj 2735 0 obj<>endobj 2736 0 obj<>endobj 2737 0 obj<>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[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 2712 0 R 2713 0 R 2714 0 R 2715 0 R 2716 0 R 2717 0 R 2718 0 R 2719 0 R 2720 0 R 2721 0 R 2722 0 R 2723 0 R 2724 0 R 2725 0 R 2726 0 R 2727 0 R 2728 0 R 2729 0 R 2730 0 R 2731 0 R 2732 0 R 2733 0 R 2734 0 R 2735 0 R 2736 0 R 2737 0 R 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]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<>endobj 2774 0 obj<>endobj 2775 0 obj<>endobj 2776 0 obj<>endobj 2777 0 obj<>endobj 2778 0 obj<>endobj 2779 0 obj[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 2769 0 R 2770 0 R 2771 0 R 2772 0 R 2773 0 R 2774 0 R 2775 0 R 2776 0 R 2777 0 R 2778 0 R]endobj 2780 0 obj<>endobj 2781 0 obj<>endobj 2782 0 obj[2781 0 R]endobj 2783 0 obj<>endobj 2784 0 obj<>endobj 2785 0 obj[2784 0 R]endobj 2786 0 obj<>endobj 2787 0 obj<>endobj 2788 0 obj<>endobj 2789 0 obj<>endobj 2790 0 obj[2787 0 R 2789 0 R]endobj 2791 0 obj<>endobj 2792 0 obj<>endobj 2793 0 obj[2792 0 R]endobj 2794 0 obj<>endobj 2795 0 obj<>endobj 2796 0 obj<>endobj 2797 0 obj[2794 0 R 2795 0 R 2796 0 R]endobj 2798 0 obj<>endobj 2799 0 obj[2798 0 R]endobj 2800 0 obj<>endobj 2801 0 obj<>endobj 2802 0 obj<>endobj 2803 0 obj<>endobj 2804 0 obj[2800 0 R 2801 0 R 2802 0 R 2803 0 R]endobj 2805 0 obj<>endobj 2806 0 obj<>endobj 2807 0 obj[2806 0 R]endobj 2808 0 obj<>endobj 2809 0 obj[2808 0 R]endobj 2810 0 obj<>endobj 2811 0 obj<>endobj 2812 0 obj[2811 0 R]endobj 2813 0 obj<>endobj 2814 0 obj[2813 0 R]endobj 2815 0 obj<>endobj 2816 0 obj<>endobj 2817 0 obj[2816 0 R]endobj 2818 0 obj<>endobj 2819 0 obj[2818 0 R]endobj 2820 0 obj<>endobj 2821 0 obj[2820 0 R]endobj 2822 0 obj<>endobj 2823 0 obj<>endobj 2824 0 obj[2822 0 R 2823 0 R]endobj 2825 0 obj<>endobj 2826 0 obj[2825 0 R]endobj 2827 0 obj<>endobj 2828 0 obj[2827 0 R]endobj 2829 0 obj<>endobj 2830 0 obj<>endobj 2831 0 obj[2830 0 R]endobj 2832 0 obj<>endobj 2833 0 obj<>endobj 2834 0 obj[2833 0 R]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[2835 0 R 2836 0 R 2837 0 R 2838 0 R 2839 0 R 2840 0 R 2841 0 R 2843 0 R]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<>endobj 2856 0 obj<>endobj 2857 0 obj<>endobj 2858 0 obj<>endobj 2859 0 obj<>endobj 2860 0 obj<>endobj 2861 0 obj<>endobj 2862 0 obj<>endobj 2863 0 obj<>endobj 2864 0 obj<>endobj 2865 0 obj<>endobj 2866 0 obj<>endobj 2867 0 obj<>endobj 2868 0 obj<>endobj 2869 0 obj<>endobj 2870 0 obj<>endobj 2871 0 obj<>endobj 2872 0 obj<>endobj 2873 0 obj<>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[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 2855 0 R 2856 0 R 2857 0 R 2858 0 R 2859 0 R 2860 0 R 2861 0 R 2862 0 R 2863 0 R 2864 0 R 2865 0 R 2866 0 R 2867 0 R 2868 0 R 2869 0 R 2870 0 R 2871 0 R 2872 0 R 2873 0 R 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<>endobj 2901 0 obj<>endobj 2902 0 obj<>endobj 2903 0 obj<>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<>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[2899 0 R 2900 0 R 2901 0 R 2902 0 R 2903 0 R 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 2916 0 R 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]endobj 2945 0 obj<>endobj 2946 0 obj<>endobj 2947 0 obj<>endobj 2948 0 obj<>endobj 2949 0 obj[2946 0 R 2948 0 R]endobj 2950 0 obj<>endobj 2951 0 obj[2950 0 R]endobj 2952 0 obj<>endobj 2953 0 obj<>endobj 2954 0 obj[2953 0 R]endobj 2955 0 obj<>endobj 2956 0 obj<>endobj 2957 0 obj[2955 0 R 2956 0 R]endobj 2958 0 obj<>endobj 2959 0 obj<>endobj 2960 0 obj[2958 0 R 2959 0 R]endobj 2961 0 obj<>endobj 2962 0 obj[2961 0 R]endobj 2963 0 obj<>endobj 2964 0 obj[2963 0 R]endobj 2965 0 obj<>endobj 2966 0 obj<>endobj 2967 0 obj[2965 0 R 2966 0 R]endobj 2968 0 obj<>endobj 2969 0 obj[2968 0 R]endobj 2970 0 obj<>endobj 2971 0 obj[2970 0 R]endobj 2972 0 obj<>endobj 2973 0 obj[2972 0 R]endobj 2974 0 obj<>endobj 2975 0 obj[2974 0 R]endobj 2976 0 obj<>endobj 2977 0 obj<>endobj 2978 0 obj[2977 0 R]endobj 2979 0 obj<>endobj 2980 0 obj[2979 0 R]endobj 2981 0 obj<>endobj 2982 0 obj<>endobj 2983 0 obj[2982 0 R]endobj 2984 0 obj<>endobj 2985 0 obj[2984 0 R]endobj 2986 0 obj<>endobj 2987 0 obj[2986 0 R]endobj 2988 0 obj<>endobj 2989 0 obj[2988 0 R]endobj 2990 0 obj<>endobj 2991 0 obj<>endobj 2992 0 obj<>endobj 2993 0 obj[2990 0 R 2992 0 R]endobj 2994 0 obj<>endobj 2995 0 obj[2994 0 R]endobj 2996 0 obj<>endobj 2997 0 obj[2996 0 R]endobj 2998 0 obj<>endobj 2999 0 obj<>endobj 3000 0 obj[2998 0 R 2999 0 R]endobj 3001 0 obj<>endobj 3002 0 obj[3001 0 R]endobj 3003 0 obj<>endobj 3004 0 obj[3003 0 R]endobj 3005 0 obj<>endobj 3006 0 obj<>endobj 3007 0 obj<>endobj 3008 0 obj<>endobj 3009 0 obj<>endobj 3010 0 obj<>endobj 3011 0 obj<>endobj 3012 0 obj<>endobj 3013 0 obj<>endobj 3014 0 obj<>endobj 3015 0 obj<>endobj 3016 0 obj<>endobj 3017 0 obj<>endobj 3018 0 obj<>endobj 3019 0 obj<>endobj 3020 0 obj<>endobj 3021 0 obj<>endobj 3022 0 obj<>endobj 3023 0 obj<>endobj 3024 0 obj<>endobj 3025 0 obj<>endobj 3026 0 obj<>endobj 3027 0 obj<>endobj 3028 0 obj<>endobj 3029 0 obj<>endobj 3030 0 obj<>endobj 3031 0 obj<>endobj 3032 0 obj<>endobj 3033 0 obj<>endobj 3034 0 obj<>endobj 3035 0 obj<>endobj 3036 0 obj<>endobj 3037 0 obj<>endobj 3038 0 obj<>endobj 3039 0 obj<>endobj 3040 0 obj<>endobj 3041 0 obj<>endobj 3042 0 obj<>endobj 3043 0 obj<>endobj 3044 0 obj<>endobj 3045 0 obj<>endobj 3046 0 obj<>endobj 3047 0 obj<>endobj 3048 0 obj<>endobj 3049 0 obj<>endobj 3050 0 obj[3005 0 R 3006 0 R 3007 0 R 3008 0 R 3009 0 R 3010 0 R 3011 0 R 3012 0 R 3013 0 R 3014 0 R 3015 0 R 3016 0 R 3017 0 R 3018 0 R 3019 0 R 3020 0 R 3021 0 R 3022 0 R 3023 0 R 3024 0 R 3025 0 R 3026 0 R 3027 0 R 3028 0 R 3029 0 R 3030 0 R 3031 0 R 3032 0 R 3033 0 R 3034 0 R 3035 0 R 3036 0 R 3037 0 R 3038 0 R 3039 0 R 3040 0 R 3041 0 R 3042 0 R 3043 0 R 3044 0 R 3045 0 R 3046 0 R 3047 0 R 3048 0 R 3049 0 R]endobj 3051 0 obj<>endobj 3052 0 obj<>endobj 3053 0 obj[3052 0 R]endobj 3054 0 obj<>endobj 3055 0 obj<>endobj 3056 0 obj[3054 0 R 3055 0 R]endobj 3057 0 obj<>endobj 3058 0 obj[3057 0 R]endobj 3059 0 obj<>endobj 3060 0 obj[3059 0 R]endobj 3061 0 obj<>endobj 3062 0 obj<>endobj 3063 0 obj[3061 0 R 3062 0 R]endobj 3064 0 obj<>endobj 3065 0 obj<>endobj 3066 0 obj[3064 0 R 3065 0 R]endobj 3067 0 obj<>endobj 3068 0 obj[3067 0 R]endobj 3069 0 obj<>endobj 3070 0 obj<>endobj 3071 0 obj[3070 0 R]endobj 3072 0 obj<>endobj 3073 0 obj<>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[3072 0 R 3073 0 R 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]endobj 3122 0 obj<>endobj 3123 0 obj<>endobj 3124 0 obj[3123 0 R]endobj 3125 0 obj<>endobj 3126 0 obj[3125 0 R]endobj 3127 0 obj<>endobj 3128 0 obj[3127 0 R]endobj 3129 0 obj<>endobj 3130 0 obj<>endobj 3131 0 obj<>endobj 3132 0 obj<>endobj 3133 0 obj[3130 0 R 3131 0 R 3132 0 R]endobj 3134 0 obj<>endobj 3135 0 obj[3134 0 R]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<>endobj 3174 0 obj<>endobj 3175 0 obj<>endobj 3176 0 obj<>endobj 3177 0 obj<>endobj 3178 0 obj<>endobj 3179 0 obj<>endobj 3180 0 obj<>endobj 3181 0 obj<>endobj 3182 0 obj<>endobj 3183 0 obj<>endobj 3184 0 obj<>endobj 3185 0 obj<>endobj 3186 0 obj<>endobj 3187 0 obj<>endobj 3188 0 obj<>endobj 3189 0 obj<>endobj 3190 0 obj<>endobj 3191 0 obj<>endobj 3192 0 obj<>endobj 3193 0 obj<>endobj 3194 0 obj<>endobj 3195 0 obj<>endobj 3196 0 obj<>endobj 3197 0 obj<>endobj 3198 0 obj<>endobj 3199 0 obj<>endobj 3200 0 obj<>endobj 3201 0 obj<>endobj 3202 0 obj<>endobj 3203 0 obj<>endobj 3204 0 obj<>endobj 3205 0 obj<>endobj 3206 0 obj<>endobj 3207 0 obj<>endobj 3208 0 obj<>endobj 3209 0 obj<>endobj 3210 0 obj<>endobj 3211 0 obj<>endobj 3212 0 obj<>endobj 3213 0 obj<>endobj 3214 0 obj<>endobj 3215 0 obj<>endobj 3216 0 obj<>endobj 3217 0 obj<>endobj 3218 0 obj<>endobj 3219 0 obj<>endobj 3220 0 obj<>endobj 3221 0 obj<>endobj 3222 0 obj<>endobj 3223 0 obj<>endobj 3224 0 obj<>endobj 3225 0 obj<>endobj 3226 0 obj<>endobj 3227 0 obj<>endobj 3228 0 obj<>endobj 3229 0 obj<>endobj 3230 0 obj<>endobj 3231 0 obj<>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<>endobj 3278 0 obj<>endobj 3279 0 obj<>endobj 3280 0 obj<>endobj 3281 0 obj<>endobj 3282 0 obj<>endobj 3283 0 obj<>endobj 3284 0 obj<>endobj 3285 0 obj<>endobj 3286 0 obj<>endobj 3287 0 obj<>endobj 3288 0 obj<>endobj 3289 0 obj<>endobj 3290 0 obj<>endobj 3291 0 obj<>endobj 3292 0 obj<>endobj 3293 0 obj<>endobj 3294 0 obj<>endobj 3295 0 obj<>endobj 3296 0 obj<>endobj 3297 0 obj<>endobj 3298 0 obj<>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<>endobj 3349 0 obj<>endobj 3350 0 obj<>endobj 3351 0 obj<>endobj 3352 0 obj<>endobj 3353 0 obj<>endobj 3354 0 obj<>endobj 3355 0 obj<>endobj 3356 0 obj<>endobj 3357 0 obj<>endobj 3358 0 obj<>endobj 3359 0 obj<>endobj 3360 0 obj<>endobj 3361 0 obj<>endobj 3362 0 obj<>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<>/XObject<<>>>>>>endobj 4306 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–&¦ !)`µ !ÉÁážîºFz .ùÉ¥¹©y%‰%™ùyš!Y\®!\\ ”z'endstream endobj 4307 0 obj<>/XObject<<>>>>/Annots 68 0 R>>endobj 4308 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_=½þðúÕ ¥±è/f ú“ø8ùqX7˜tqè‡-‘¸ÜU%d:úÿä´ãg/á¨EpØy ñ –¸[’L¬­²¸‰¨œEœä•‰…ƒ$©)…ªõ¯†]ÇŸåéLÏŕ¡¾4NýÁ"ßñ•‹~=¹7‹ííqqË"Á#T¥ŠùvX×òi™6*Ë#‚¢hSóþŽréÒ*<”æÝçn=|êvtdH!špŒïb‘Â'ŒîÈ š^¼èqêi2)Èo=e*ˆôn×Ý,–zf£”ä÷šHqærŠp1ñ˜†(ÔAø×ÛÃ&ËnˆÏš2‡1žæ·tÀ²N'"âD¤°B¢Ó4 bÿÚíöæx›´º™EÚ¶ZžècÒ¾é—Ýv/ž_ްiªâºÃ­þqwÝ~8î–„Õi:»ÓUiéj”Anv&/œÕ®ûíØïûƒÈW_TÚÀÖ:i\ „Ør&â/»ÛŶÿe{(ÚH‡þr–NCÀ=Üõ|Îx$Î9Ù,¶ÇÅš¾I%ߊ4Eäʼn&Ú3Mü4ܳ.e: ª€bªÇâóЯøkГC²ë«~{K—EZÍô»‡;vhUØ7£®¨ŽÓMQUÎÙMYø½ž/–ÿ¾_ìVl, XÅrØ|‚}ì×ýá+ Bë=kÇØTR‹»ù³3Yßwën¡N©¥žèvP?€ªïbJ¢4e7>áþƒ¹ºœ ?îÊp’\íºU/¥$·n.)-‘tEÄôœKF=òù‘o)úE¹Ú'.ï§a§r£ª6ý­h\ŸëÁžXr.Y”ùõvX¬×æá¡  :[=TW-!­FÛ“îkŽõC¿] ÷â—\´êÏ%¯Óf„‹ˆò€-ÞOtñOdüǶÿÂD‡ü@>ÒÒXÏV¤D7‹Ⱦ؎ñíbÙoÃþŽäÄC0 ›¿\Ó'yZþ'}€§!?¢ŠVcö÷¾²œT¢_C­?/;+ÄdŸwûCÈ!è›c=Æ3mŠpxhv*l²½ø²Ø|ZKÍj¸á8O~ö2ö3Ð9…ŒÒÑà›œÏyQäçbŽïì4r^ìZ¨>kVÇëêýw‹»¥*ÍCš$5‚‹±T&ÿ…¾…—ñBà}léQ}Æz˜Äê_ò‰ìœí¢©oMÖ£äŒpU!“H¼ðíe¤"úÔ:è:²Ž¡ç¯gþ÷±FH'מϽJ‹‹kž ÞÉ3Ù5Û 7¸é Éc²"nu;klâ‰I(oziPãÙæh/z6 á‰D–ä#ˆ<×RÖ5õö÷=çÒ°þ2T¼(Qár}Œ6}=šžû™_ábor*¯d"AÞçÇ~m%=RéÐY1£ò ÏTÞu»µÄ:÷üaŸJàýñՉ"<™ûÓ–\äwKÿõp'ÏÑ͘8ññzÿ¨úA*{qv½åƒô×w¨—G) ƒiŸYÐØ Tó'ÁŠÔ«ëã'*t;¾xàkË®ž]ýðÙ5Êþp‘×þÛÔú7ÝâpD×]:¼„~ý;kC…Ïkë]!NÑô?Û |ôî¸ï?sW¯¬Ùó‰o:ïÞ ”élLÅ£ô6PW¸(}ÞÜ}½];œ:jiO"Q·®Ý7˜´<¡ÍûKñ x§ËJ¹_:$ôöù¼s7Æv¢Šwò´Kóyw¬]úoJíÚ7x~ŒÏ@ƒÐ™;ÔÐ%‰YòN^¾`¿—í¶ß ;Îï#U ‰HhZ$<Ó;ën™¿¼ïÜÈDãÈÚ–¿öûð¬YU¨*®ÇUÏq¯`ÿ¡9•ª©Àó+ °T_UÁòÁ+^ý‰õAß»€n]šsº;A¶;MRI¥úÛâ3§3ü‹šñˤjN¥bîΊªP>-z×þb¥’4žÕ;«.‘ ].=)´>/XObject<<>>>>/Annots 121 0 R>>endobj 4310 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è7A¯º«Å…}ÎÂð}õ¸@|œRÛ‹çmKOÿvöìïÏþ²ßæ endstream endobj 4311 0 obj<>/XObject<<>>>>/Annots 175 0 R>>endobj 4312 0 obj<>stream xÕ\Û’Ç }×Wð-r9¤9Ù!ù”’eË¥ª8V¬­Ò‹_f¹Ü݉y /vœ¯ÏÐ œáîÊ®²£¥ã”Ä3‡}@ÝCýûE1ã¿b0iäÿ‹õ‹ñhŒ'òG!|ÿ<4õtTÖƒÚ?¯ï_Z&Õhš¾&Áõ ™ŒæÄÕ•ôRÕÚã4€´#¸ãùh’¾)$c°Å|Ô0Kl}Ö–0Øi3*¹-áõ ,j™°ÎP…id“‰N¸šá/Â\æ…ÌH¿(A¦ß1ØÉTôçMMGeA:R ÝšŽ':™ '£Û²é³„Á6³QAmmPt(Km£(ˆAW@AÕ q’1º­*QQ°„ePŠXÂPý¸Õ{[R=7ëÓ)ð)en.jŽ †œÌ±€AZ§32ÀZAtš¸¢˜ÀL‚d,Ý–0Ob ƒŠœÁÚ S3"“DA š¸™ŽéA²‚…ÕN2[ëÁ -Ω­MHµŸV»VJ\1nD'£ÛªÍKìL§,a™ÒY[Âb c™°·e ¶Rí;kâTd¼µ‚'qŸ’es’±ˆSõnáè6q°8ôêAt ·ƒ9ÉìDõ,a°õY[Â`gª£hKXÙ ~ã2[ÏDTo‹aá%¥¹…Æ5"*AK‰°AL¨‹¨Ú‹44ýÁB B‰›k§ÎD§åXFt’1؉ê XÂ`ø!–³6¡±˜e6{1¡ÄÁ]àjΔ!k™“ŒÁbÃbÕ!«™¦2sbгAŒÑ­Z±„EÎ~[tJ†[)ˆAW”"hŒ¥[1¿`ÕHª†ŒÄ€t«F’9èíô‹ÂD§P “ŒÁNf¢oÊ,b'¦ë¬ÉY“U BÎÄÙ&$ct[J8!–°LIì…XÂ`‰¬Ä;+a€ÄÓÖÄA uó¬„8‰S Ž £zCÆ`‘ÌAƒÁ‹í£"Ö&T²ñ*ˆ %n.ISåAtZH ’1Øj*ò¦ŒÁÎ$ –0ô‡´jJ¬M·`³WÓMœíb•“Œ1(*Xh°„eÂ¥h0XÂ`±óCØ` ƒÅqœµ )©Ä„7ŸÉŒœ#ˆN¡,š“ŒÁ°4Á CàŽƒŽ{=K50ÑMܪû,“•j 3šþE­&p´àj<®‰Ó`3iÌö4ºá"ñ–-=8‚¢Ƀd,º™öš2‹±¹­M(C61¡ÄÍEkç¬]*y¬W!ˆì‚çb2…X]ŒÁV !X’‹–‰W6dâ0Ú9GP†”ݘ8‡Ý C ÇtTßšh1‘özî[™+Jq® £[­ˆ% ¶‘—XÂ`¡…~ASrAcÀ§”9©5¦ƒ Ë b¶Ä‹­½a–°©¾&VµTr9d ¦ä儸 e̓jFM,a™’ÔšÁêz—Zª¬‘ñ $pOÊÜTì$8‚ðñÎàÊtd Ò¤Ôr!ÙB鵃–cÑPó¡ K·’~K,üñŽmÐTxØ(^wDC­±J'ƒm$œK, ¨(ÚÆjÃaGÎ2[Eœ` ƒÅVË=3Æ‘òlnkÂj9‘5ìµ… ›¸…Äq’1ÄA6KX„•\X˜0ò LØÛ2‹xU8kNÍÐë‚°3‰¥seºr ¤uªåFÖ‚×Öiâ$–B N2F·X˜¯³Ö­–¹[¯/¬ÛÄiáY:G"³ÆNj§&Üó3gs ’1ºÕÌ-Xõm‰A’êopßÎòœ3ê…#(J,Ò:å£ðÀÆHœî™ÁY»TØÄd‡5ƒÚ¥PùÂäP 8‚¢T9 ÒLYºv'•uJp=˜I½œµKÉ´}Ñ3b‚PÝÇ”.3e ™%¦ãMƒ­eËÖÕdT3³ZÛód‡H íxÖJÚ‹vœ#hÓÁ€NʧŒÁb𠳄e²ýAm²šÆæÉzNkJœÔ“P­“Úpn%¢~Q?‹îé1u9pF ÖÔa° & fâ‚Cš@Í‚›ŠÑD»€S¥ä4Î×ÈúöÆ1qÁ!fÑ< J‹ñ>UY9ÃégWVbæb¼Î‚hÈ^‹ ‚C´f. ¦ˆÃê’ 8õ NãV* TJý¬^+*HŒ™šS1øΙ¥²P NzœÓÁRZ¯ƒyV°h8•˜§g§EÎȉn¢ƒT'h÷^ ʃ9ec§V–§‰aæt?. TŒ£¦•:T×Z&¢¹;¶QªçñòDœ²‰¤Vr¥!~ÖHÀ,µsjr)÷WŒ ^š'FÌ™@è;R†e ÊPR59÷å]qé=×þnðÅ›9<³½ºÅ÷‘ŒNpC9˦\ÝèuØxpµxyÕ^¯–ƒííàõvs\nŽ‡Ï®þEÝé™v‡0Š·ƒaîmˆ’{ж«›—µ4ªqë†Ïƒ÷Þ~#qo:IϾlÝB»þâ "¹v„»­rŠîJía„¡­äòNºy·í0¡½6‚u•³ôü¸•¯I—ŸÜž6‹c·ÝØW1j™¾Únnô»Íh^¥G‹vµºn?æïæNFÏò¿j"óX—:4¡ÚDaì =îO‹ãi¿ÔIW“Ñ83xÚdM çË](”ù,Âýê • :Ôèf€@Û3ƒ«_vË›å­<ƒÌ>²´‡¾šp”ýW'ò©¾P5¶ÜEE‹=*{ò¾¾o÷í†/O±EL¦Ér!^·¹S€gùñ#&ÐW„öIkŸJÎÇÆÉ²ãH‡M}¤Pf§µß·¿¨>h­×Ëõu¨¸“Û?6ȳ?«¦ºÂ³ÞW½~ŸÍTžbqŠ&-ðM{låâ¢?»lÑ“´Eq¶¦ê×¾¦¯E(²Ø"µê`kÁ7º“ʱæ›eïÛ8›¸Œ¨VÍD®¡;¾ÔÇ]øW77ðZ]ê趪ú[öä'·±‡;Þ¹Jx|ŒêS:D¥û7Òƒ3kP—p…ü˹ÔmG-.{_„½2eŸR€ß6V­ñz¨W´ìj .åwÇ{‹àRñç>Þ{GF’÷ð‡«»Ù—b‘Ê\oOGyˆ”ÖºÖÔ”PñÌS(ùyßîvÙî[¤ü6ç·jËiʲŒMN}‚2š×Û•°œŒš”¢ Þn˽¤qÉ/fI˜ß9ÿó$pM1¿9ObîmAg‘ºa9wiEñ4ï[MtÜÎræìÙ4²¹gpê_U_’×ú´Üç9Í#ËÝõ–[jEKû¯WÛ”#½@¨u7â4–·ŸÅ¼Ý¬º9_ÊEVmx$.îº.ÓäkËÓç=‰ûIÍÛMwìÚU÷ß6{0j^wmò"×Fžd”0)=Õ­‹âÖ+ N…à·R£Þ¶ õoE³ß~yêV¾õüs˜{Ü·Çå&¹¸C¾°%ÔÖã-ÝxrŽþn¿ÜµR‹ÈS©PÇ>yiG¦/ÞÄi3 Ûqö¦”WÓ£æšw6jòéÖëÏ?×%ÇeKjI.ùgøXk9g½Cc%CI¹1íª¯·ëu>yÆa=O,´R€¿hjÁ¹s•ú*¼1½´OSÄïÕ‡üZ@’X¯vØÛ…Z=„þl+^[Ý_“„º?„ïO»ÝvŸê~`{f˜ WôvÙúY7~}Oî/Ïê“ÜòëO›‘î$ºwòp]ù±­êâQùlwq‰­4[x”X-¶ë]·òTo<»–š±Hƒ› ²ÝHïöÛÿX¦€ì/ïz‹U{8؇{çâÒü÷i³K#1ñÀv~w+5;¢I§¸vuxXé#$õ æ2âL=Ï ›:òbcIv k~öýò°=íS]„Ý.×?p†ön)ñ^ FªÄí;«­è^OÒ™iରznÓh´ âG ,u?þ{»¹;A>‘ ¥Ñ?Ÿ~"R·û»STØøéÞ%ï¿&ncE匎 ôH¡_N—úâ—†ÚKõ¿¼|gO­`BI@[Œ M"~½9­5„Ê]yöËG2 ¸mzy/%æïžy)0ÉŽ£}º…ªC_©¶ÃŸ7ûn¹¹1áÿdK;%õ'(!¢Ö$â÷ËÛ%6ÿEz¯~NqYâ¿9á2ÕÓ¥,ižÇ4I8í&».ìÈ+Î:Þ¡è·MÖmuðˆÐû%Ž‚$YךY’›üÔ®NZrá}‚ËÔËT0ÄûÚdòÑÙÃÛ ^éŽ-,B#Ú%•ƒy}Ÿø{ª² ñ3A^uMIÀW"½Ôr ×ð*³'V7Ýaq:Ò‘ Ÿ™=<2Y£,ér J'Ç]hR+8b•KñìHJH¬üˆÓñò©.Mzq¿\ü˜oyeü¡µÇTU6,ñ'V¤¤…ûôN½©$ûî§å~µÅ5’¾`©ýé ¿#-'9^üvy¼ß¦Ð‹|ÿÌpj9ëYíŸfÚMtžûWÝa×ÓÁ9ݳæÜ\–N^ÎK·Ü,q™M /Ñ_ÄÎ’¥Å²ô=•áYÚWëëîîÔ5úñ=ÉÓ³lÉLñ»»ì^Oøï'|<Í—‡çÒjÉ¥üàIiñüvu¢EÌúytÿØ´ë쫸?}¾åž¦·E:2•qJLÔeþÍaÛäçI4\äW'>áB>1Ô,mugÉþzË¢¥†¤({ïv'ΛŽÜ¸ë º6¡õ·7ñ‡þl¿0D¢v‹Ÿ{áÝ ü¿ª`‡¸–»à¡ü;*_mZžydšÈ?-‚y §Òöæe×ub'__½øç‹ÿŠ6a)endstream endobj 4313 0 obj<>/XObject<<>>>>/Annots 227 0 R>>endobj 4314 0 obj<>stream xÕ\mÇ þî_±hàÂA yßµ›ÒKœH 7>7_{Òžo½u¥³cýï}HΔîâ:1|§k ãž}v^ÈáΪÿ~”%)þ›%EMÿ›¯¥ÓO蟌þùé[z’ÔÕlZ%«¤Ò¿—ÉËG†VIQNgá5¢D«bZ8ÎÁU2+ѱtÏíj¡¬d´‚8<œA´›ÑxÊ9¸J²¬9hXp§5çÉ SÖiàZîT9i—g®k¸,åŒ,Iд决V5tp•`À,¼Hœƒ"¯§#=‹‰cPSÁβiîÛ:¼JrL´t,ËYapÕ•3r?ð9Ë ‡ ö‘“C€‘Ò½BlÈ€†”†Ë2ŠÊ¹’Ò³æØPShi8Êò!¥’Ò0æÐrMu¥aàhë·Ž•‡\WÌIÓY±ïXåÊ9¢k®GWP*<2¬GI™)g¡QDMIe¦#…é(é1­¥Žu,Õ¶Qµ@•呼.“óW´Óä|þä¼»XöÉæ29Û¬÷ýz¿ûüüW×½¹;l4¸L&±· ­Šäç‹'55ªP8ÇßÉËŸ¿ÿ–0öɬϺõ‚aÕyxtöÅôèé32SéÓ­ÐÎ]N³7¡E•ŽÏ–ÝŽ§‡‘ÍÂÃþ7Ìz7lÖôr™N‹0äô”ÿÓ”4ÛI“;i›#iÏûÕvÙí{–¸ Z;e¡lnMÅâUt~³ål|Þ­úݶ›‹„Õƒ‘°-D:Ú~NºiFóh¬çW=ËÛLÓøhÍÒò[ØtÓDÛå²ïö×#¿Œze^ÇÇ›‘ÛÃÔã£õÂ÷¨³–íÎ€Š¾ª†<åIÛžý©Ç¬‡õkzŒTG©÷ÁºÙ-À¥¶e{ÿn+K}{àÝä7oÂk‡º@±* Z2+¼³¿T3§¶ù²Ìßü6ï·ûè§PØV±Ûöóár˜wDòfG  ìÉðaµ¼‡'ÈVœ¤ùÑ’ÿ®¤WˆË` |ͼöWÔ‰.ïc¨c~%†€C_¼ý‡Íò½…4›¦9ÁÍ¢“ž[ç›qtä…Dº¯í7¬&'ãýê"¾ØèøD“ÿ˜nUðÔÅ«œC˜üåª÷¼Žõ´hÃ6ÝzmàF<ÿ˜Ô*w²Ùöc·ßŒ“¿ýòä—Ï©#J÷Ned)oè .ÈÜâsœs:9 ,9N<ûË~ì×sqð(DÕÌ7×0ötKüæâ×~.YÂA¨ +Ä0º}z½Æ¿ô›©ŒŽÑ…ת;õŠY*¡1Ç=— œ:5½Ú/€}5•E?_v°õ‚þ=æ2¬¯úqØwA³HÈ‘;²CùSÿè¶8SÑŠ9‰ãLöy¿‹K‡SYȿۅà‡Dý!$²(²°¸3¿+Ž3Ù¯èdTN&ó?‡þm¬…¹*ÈV3ß  ÜÅŠCÛpB…ðÄòd´M!ïÁRKöëÎþ·ÔÅ?ëÇQ¤E= v~ËÂö¶×±˜ì΋΂ÛP/l§Í ˜DPÈÁy‡n Ãy‡÷@Lú5yp©àr¸»ñ)•¾c>±åþÐm›a’ÀÝòyûhnn1Ç|üYð©|1!NtÕYEH>ã>¹Årœ2éÔó‘]ßs)>#m‹WÛN ÒÈoª»?uávU30|õD2ºSâa—~}5ŽÝ;vˆO¯–nQÄAy7,!¦~èrÞá{QM(Ô.Ùbò0õåéÀ6 à'ùLJÂ×'4× ¼zˆ $Öa‚0ïx9ƒTôµÊ½EðÙ²Fóu¢qZ©¹Ï|Õ-—›ùƒZ0ÝG ÆÁΤZtûNdB{ËE ‹/pxÉjwˆon–+èçk^îG+ß·1„}g£—{èät‹˜4~‹ ²»}X¹—¯ûËîzÉh|'¯ñeg p|·›õ©l£¸ÈJlsâWE¤5㸈9)*Ê1J^ 눠Œ£Åy2yjÜ®9EÇ‹ïyÛƒ>ôF·^D=^÷oåŽÚãRSÒ›Eú±_öÝNîöšD­zTæ%uà÷SáŠòã[?¿âGŽKl9¸ãû™è‡‡˜¸sea­BÕÜ(<¾<ÿái¸ŒE­%_üpSÃ2N<®â'ÎlÃø8ÑÅTœŽé©nÛÝ~ñå—æ” ðˆ@ø±¡ˆæÊMXÇ#Ä¢½ÁáN·à"@år»Û,¬S°Õ¸úøy'ñøR*Þ–þÑÝqïãˆÏKç3óR¶ ÙäU7ö‹m÷#½ŠJ¯Jvúˆ»Ô y]uÄ›nñ7ƒ~ÇtòY¬¿]cyù§+šÇ#ŒñâÄ“—Ú«„Žòd½A0_Á‡:Za›ŽÙìWãë뾆&™![\·Äg¹ð³q¡ï`Ó}üYÁ^È•bìC6¤÷G}K!†>ͤº«.yãª/¯ <Ù<"¨`Ò¸x Ñlûûõ~Ü,®QQ”¯Ê‘žx@rጚ'\¼“Õ'¿Žåc÷iíß\­z½˜ÂgT§šáÿ<„l”à`ÿðošðòYô;ú(.¬¨²:¡ }½™óŽÖ»õ—49>Ó›Ìèç‹'Ãêý›óGÿxô?´ÍÉ1endstream endobj 4315 0 obj<>/XObject<<>>>>/Annots 281 0 R>>endobj 4316 0 obj<>stream xÕ\Ër[ÇÝë+n©RºB¸O\¬R²;Z¸¬˜Ly£ÍpI"ÁƒA)þûœÓ=ÓÓCÒr.LR’¦gú1==ä?/ÊbŠÿ–EÝñ‹Í‹édŠOøGÉ?~þŸ];›´Å¦híßëââEB`ÊI¾&T‚›b^Oæžk(¥iEâ,¶spS”ÓfR‡o’ôl;tŽmER];±’ØÀ•U?©ŠÎH!Ch«b«Ò‰Ä®œNi#=†ØzF]ë0Ø®ÍÚÖM4K§MÏ `§nоŸôŽs]645ôlÓÐ+‰u˜šå¬Ã`çi|’بkŒˆ ˜"GöE"=溜ul_Ãm©­vÚ»0j¤NW–ôw"=†XÈé«bg.ŒZIlàÊ’Ñ™H!¶›NJÏ: vÆXqm¦¦sɺõxSTÕœV2–ó³m4TÊ8^1CgöErb-¢Pæ5ÕU@®M£™26ÉyÖVÁîsb Ù°¢ ä›:š„Á"Ž!ÖXµ{ì.r$±++‰#µá4LPi( 5 \‰X‡áŒô˜ã£+bx‚ö™Q¬9õ{"=†Ø¶…«bgaªˆXIlàÊ)ÕlŒôbḴƒ­i Ç:Ì!Õ°¼c‹ÀšyÖaú%lTª²W²’€¤NàÂðôV ­”X‡©N—³SžCJm¦:=f©cæ\ª1Ó«êHøG§ Hꮬflh¤Ç0³§cÛ19Öa Ó ö7Ƀí$*ŒÕ7.øiÀCr†sB&ƒô,|Ñ{Öa°h•±ƒÕà1É’t$0K: 8\Ñ)r( U¾HÎAE­—©6(ý”l¸ÃFz¬z ‰…žƒEþ†KÕNá«øR§ãLÅhôb±êb¦+bk¨kb˜ØÈ•e‹ñ$ÒcêRå¬Ã`[&ÂÔV;í]ÕR§ é±ušXí4¶ÕNÕN;—_k©ÓÀi¾O¤ÇèEε+å°©Ç`QŒ@Sc%þêXÌÒÊ ØRâ/r=×öÄ9H=™¬é1X-ô!be|±Úeö¬$=ÇŒ8s¤Çˤšz ÙϳjÜX K§VîÊZVÇZS2’S?bˆ…Ï0ÞÄ: vÞsÀÆj§¡Ö^¬Üu K†Zm¤Ç`¥0p¬Ã`QâV¾­Ã\žXu¥¶:$©qC>¯­àÕ!ŽB#=f§¬ +b«XïÒF ̧‘ãdïé15eîLM=f§ŒÇ: vθr¬Ã´CƒxH¬Ç`Q“ÔŽUub%-ê¤J:AtŠjm^TFz ¶cÒq¬Ã0W.Ç:Œ!Õy[™¨•Ô¸¨\9QØD*‘Òqr¸b_‘†ƒÅŒ‚õU+t. V’SÇ‚z© C.QU H cu^q Idé0ÇÃØu¬Ã`aLøÛ{ óaïÙ9V‡Š{’€4¤À•˜0’‘sHL«‰U±¾ô¯¬~×^Äé1ŲÄIM= BSk;Åcñ $FdÅ?7³©xÆXmjå¿|Õ üÐ4²}Å9‘X‡ž5}c¬„'³‚Õ1 h_‰ÖÈI'ÎAŒ¶žbF$Òc°]—&VlOÛXe À\9¤¥FŒ¨ ¢ƒì’y!5T¡R:‡üÈ•DŠCÚX c -yZPÊ"¤MU¬"ŠÆ8n1#=f§óŒU±RLF±VYêhǺ¤G˜q.³O!¶­~‰U±¡(U9V[:ˆ†¨þ0Z#=¦X±­±*V Æ8Z«UlàJÄ+ŽÛŒôb1çŽU±¡¸T9V=:ÈѶ /#=æh¹O¬ˆExZtÉ¿ÍaáÑÉ”çyÑ®UÿyâD`¨ýd\Vù%„FHÑóÂ()‡[ƉÀP¢ÃùX¬ùB£šZå 8äljÀP Š«ÙB#1£Qr„r¢Á9IK‰ÀP͉+ôB#d}nÿ¢ ¤@Ù¡DNJ}…“>©#£å¢@ÚÐÊ0)64N—U]âdÒY –‚•mŒIâ` dn?¯dW,|ûîÒ%Ëòþºxõ=B™¡—WHm8׬q²‰x¨º¦¸\ʹó´¸\œ]×c±»*Þ춇q{¸ûæò_NœM‹¸!LaçQÚ9Ì9ÃQöåòlÎF-Ž·ñïâõþú~Iü z݇Ïÿ>l—ëÕöšŸ¿ú³[ÄU“®‚ÌJÄL°Ý$]ñ¨œ²~º?ÜÞ‹$fð(évØ›ñ0îe°è£ªôû““úf•9ÇnëUl2ßm¡á«¤("±œõ(Š C}BŠâ°HôC©íե̓ÿ¼ .¯ ó ×ruu5îCŒ`¦ÌƒZÅ~§¢&é‚»OƧ¦o5KúV4AYÁÃ!úoo׿•QVZÌ.vÛ»Ã~X…†¤}Yv"Ã}yŘ(ÁzÕÉŸ†õ}0Ò`èï˜ÆÁÙ›ú_V›ÃHÔ2ô8‡/V›ÛõÈ0‡û&h“ìAæ‘ÿ;XƒšÚ¦m墫\¦+’hð²hå¦2òÕÍn)±Ê0úþ˜î{ÔwÔpž)˜'ä×DxoÇÏ4vìe îåp¿Þj|׸¯8N|¼úÞV» 3ø¼âšyVNeÔ1®/1ÜÍp«këI¬ú >@õOÍÒ¢|ר’ŃQœÅ—&¹wÛÃ~·¼_V»-)Ù¼>õ±÷çˆÏ rêRVÔ®å·pg1Ÿ!a}BÅ5Æö÷4=D> )YÔ<•Éb7$Þ“ TìÅe]î2MLQ£÷áD#—™XPl†Ãâ&,ÇH+±²:1]ËFÜsþÀgZ(F ïc-ÅW,†™5c‚†³S,…q(L+‹Ä¤VŠQ¿_n­y°jÆea1ˆGK·ø(3çÚV0,w[­î³Ï«ÃÌ`WUEKý•nƒŽWKG{”ØŒùI*õtõ;ù³Z §‰ÑJœIŽ=¸“)Lr©0Í"(%Wëa¿:¬´PÀUvº&=®¢_ßÝŽ 17qOõÓ~…Ǹdw8ŒÅ: íßïwרVnB²Àñ@ýµ#NeEùjšg¸žŸšò—7ù8вïD?Ì› »+¶Âü²x¸YI‘ÂoÅ–‹›áùRŒPNªãM…Ç™8Zµ˜›’ åàNÝV0*ÀmVô.]¾ºZ-–&¢5ÎJf§¤ž)õôÇp[Ü>EO½¯VÛ´‚™ïªîü²›x|nˆšÕz;ú?¢ºåÔ‡ˆ¾O–&»ØYMvšþ„…ËFwĽŸÇ¸í 26ßìnã>¢Ÿ¿äONÊËQ* ì=úXsíÇp +-Jj+ÜØbzüùŒGì:Ÿ®êÉ«íp¿Ö¢¦±8ÌW«µh«çé|”rÜHÇÅ™ªÝæjçYúGè¼:ÂÍx{¦OÜ9QnŠãÞóxQ+=ã2[UC¡î§jž‘t'¨­*öÙȺØmp碛žIÇc„Ç›‹7ß~ËÎqSYqqn=ì ³ EéW1“#ÛcãÍ­Œ2oÇ÷××a9ÆÅ™)þ~›ªX•Å=6JG q¼÷V÷ã=–ÏÕÙn•z³[ÆÃ¼.¬±Åõ¸÷²G $®Yd|X”§v# —×¢zVg"ûf¾¾°Š™÷‰í¢&ùßQ/<;Î<nYR/x  WÉ~š>q±°Þ-†µØÅ}BkÞ{K¢ãmÃל©¹Êáõ€x”oZsÕ%ÇY9}Áý­*„_ØôÍ«®S+3TM¼r-1î”°ñ–'Û/«ÈïâÍ&ìfXìwâH¼:òb›¹¶ìôØš¯‹s—†™Š‡˜1¢ÿ´ïûÕía·ÿpÆ\üáê•Ìä |I)1¼:a9ùp¦×žef“Y<¦!ÖÕ¿0<Ê®;96\xùÃ&YX²%d³Ñ›.T?qœÅo¬™þ¦¯OììÉ–—ái∆°Dórµ}É𠳞¹y…qáyš9&dšà×™ßÕàÖ$ב -nÆÅ¿EU¬:qc“kzr. uï#ækÅËÝýAÃ5æóóaÙ©–x1â£4_+^bË‚ÓQU§iY‚Á­ÝÍÅâÄ<cT5|pŒ™•G)6ÞÜ“Š+Y¬Ø¦DDG4:z óÄ„ .ï<Û”àiW®`š‚x>9p±Ô;„'ôÃGP0ÒüÚŠQç"‚´Š{<Ëà]Ñ é¦`^—â(÷áÕ~¡f R,§O­ÓSœˆ¦b¾VH©šÖCì-¨£(ØT“>^¾z'âdz_ëÎð©`|ú3ü°@æ`~põ^ÎÃêøœéåfÜ|±« ¹>‡05åp¹é‹lÞ˜Hæ0õ¸ERݰqzºEwF­¥ÖÝ^Åç™f¢†¥üìÇ/÷¥,‘)H7ûÝç;Í2³IÿÔZIxüȿ7~c¤“OÕ“~ò™Ûg\ì6zTõø}³;° ¯dïäslJNð¨*è,¿HHÈ ð“!,WNùÄ1pÚŒ ë‹_ÞýpÎß¡½Ý-ägvJWãÇ;øÿ(Îgl»<ûDÕÿvùâ/þ"O±endstream endobj 4317 0 obj<>/XObject<<>>>>/Annots 331 0 R>>endobj 4318 0 obj<>stream xÕ\iÇý®_10 @†Ašsðú$²åˆc'^Ç_ #îì.Z+¿>ïUõñ†¢d@ˆÅUûæMutwUM3ÿyR#ü·,ê ÿ·X? GxÂJþóÏoø¤˜Œ§Ãq±.Ê VÅO® ¼_$7n›±µ›Î '}Võ° oZ§‚ÁÖÓa­¬`°“¦×Ö­kÔ@4pìvRL©ÝÎêa£¬àuQêáTXÅ`›¦×s=¡èUiSsfLG®‹ù”½Ú‹äbBe9œ ©lÓoªì´ε­`L·SÔ4¬Ow4—éÈÓ ÜlÆ%N §;¢Y©,¬„ eV0§k¾’YÁœî¬×³b°õˆ:Lmƒ•q(މ:†žéÙfIÔÈ•å>˜IŘð„ÂfÖ»¹ãgè}lÀºÍ§3'Â?çBz§SwlïÔ@î4pÞKâ¢Ó¦¤‰´Õ2ž¸kθ^°ShX5œª½IR1»¥Ç +ZU½Ž}ÐÆÌG1 \YÍ`Ìq"sÐqŸ vÆå-mcJVI=+;³ 'ÖU{˜›˜ dÕn:ᘉˆ •4]&ƒÅ>JMƒL¨ýĺ+w0× ¬ÁÀ• é m&ëÂÈ Çí³M¤«`ö0S¬‚À•06l–HÅTœʬ`Š9§Ë'Ömfa'â Ò ‘ƒ½¦Â D§£)¶·ÜP1Y©lÆ`›Q¿­`°8ïz= &›{℃5wÌ㺨Sq±Æ@5pó Ìœ@tŠMzH ƒm&Ô`fû„ Lb}BÙÃyB›Î¨ÀÄ D§£fX ©lÍS 7õ!mÆnlæ6‡ t1'ÐÎPô™8ìíb@è2&R1Xì PmfƒÅ Ûcs‹ãéœÛ2Hj*w\ ‘˜(7m(‰½HN gÛp¶‰tõ”rX5L=Ü[BÜ…2'Bç°Hj¨,ö‡ZYÁ’Dnk›I3’øÎIÂ#(6[žg>¨¥cø” ä)®„ëÂ4‰TÌ)Ñ—„ vÎHWXÁ˜R]ÂK3ëM5}© ä)ŽÛȼȤb ja„°‚ÁN˜I+˜Zb’YŸRH`\K)ˆnáóh˜HÅ`‘_õXÁ`ÇôFi+윹„°‚ݽ¡ÿ4®íYµ¦>¨CÛh#gGværºŒ~2©lS÷YÁœ.ƒÄÜÖ'déAˆøë”+ø„‡¨b&N :Ù„©˜Ó5ýeV0Xä ðßÌ ætyÊdÖ ^…Å,ì ù`ä<^ˤbt VEf½Û x·)Aˆ†V‰T vn-ó0‹rñU! ñ~R¦!ÝŽ¡]“ s¶TQf}¶!Iñ~R"лÅ|Én#æl¹õ +ì„Û•°‚á×fñÌú”l%‡´2í¸ °D*Æ " ‡Ä24¨bèž©(C8.Ñœ95÷Š”Æ: gN¹)ƒÇÌ ¤òþdR1Ø1OÄÌú©‡uÄ(¸'âЂ‘8#rÈü¦É(˜ÊáÂÎÝÚeÌØÒA’2rgN ;eœIÅ”’µaó€˜ôXŸPˆËMÏe Ÿšƒ`ÌÄÑ’¥½€30 d¸.àÓð"9ÈÝ*èÆ;!'}bY–Búœ K6©Ægš œWNÂó›íκ–Gín×¾±¾qvMfþâð±üÅ3Nx€ROOܪ'îËõýª[CÝËÍ- ìü~¡öÛÍþ°k—Áp€Y¨‡åáÎúA8^DÙÌÃ>¶BPF3«ÑTžò™m‰o»ÄïØw}\–P{¨!|„?´»Ûî`â‡Õ4<]µ›Ûc{Û™C `†Y؈ñ‡¨ œ¾¢‹Ù‰.¾»?,×í*È »_›ÌàëhÜÛnÓíÚÃr»áÛPÜ4zÉÃ]gÏP6J‹e׎»Mp)øB"^½±)TØêܯÛÕÑC”ºü(ÃFÍ© ªR5d$Þò-]`{¹FØ¿´ z…sI‹ŸWÎc“ ñß%Q’‰Vû$_…ç&—~h͈æÑ8¦aõŸê²OQ/3Aq URßÜWÒ›]{K ûâEAäÑŠE\ØÔϱ:}/‚DÁ¦=Ÿå3|˜Vaîï»Å²]-ÿ›ø‰jpŽËÙ›—ÙÔ+øùÈf Ä[²ºõ°7EÁÚ͵É:ÎãæÝÛ5ä\@>ˆ°˜­cyÿ¼nBTðÇé&ÊÎê=;ûñ-}gÛ'JË£¸šwÇÍ»Ÿ[" %4uˆéwÝâßÝΤ®†Õü‚gÖe–S;²^>@ÖaSŽÞžÂ˜äÁˆ./wüž%<ŠÁízâôúÇ= ˆàÅ—á»…ÉL9óÓ_)zÞZ›â­#jôuf¡n_w»Õ¶½Q’¬ÇeÑrf.8@}MMiÇ­ßnwnI ÚWÛ£ÇÓ!fóÓ§íýýÊ¢#\åÇ¥õ2"iñ÷«®µõʤã‘SøÒBC¼è/Ž=>±ÿ÷í~ÃÂz8ŠÉÕu{hù&¥*v‡‡ÎCKßqK?‰¹æøNœü}•3õm X&þðü‹/L'(ÕD#v¸[î?³§ãaãêû-/ß™q$Sï›ÃŸ(ü\CéÒo‘ü§».,X9Ê~ØšÝ%¼õ'yÏ8“y¯ã¢‚Åž–¼È“}»ùûDåvvqç(gfÿ/_¤¢E…2 ¶ÈŠÅg¥m!©\ñü¸Gp"a> §XæE×"©òô²Fêc§×â]¸îASäÒË@òÑÒÏpɶ¾þmÑ!% 9¦Øöûà*zòx® ñ´ëuò²² n é €ì'u§¿ªˆ %q<¸•‚ÃÒÒnTÒ£+Ï©l,®X’ˆ‰<¶Õñ¥—ŠuœÝ[Zðx6Zôÿá«íæö×õýÏÏ~þœ#"¡½\bž¤ÆM¶ÑúE¹ßeý3§Å‰CàcÑ# †ø€ä&FcŠê!Qõý&îvæç¨6¤ÒÓ™ýÿu»[²\ìï¢Rÿ1+Gom„å܃ßr|jd¢ä_u7ËT“|ízysƒ£ÑëK| Z$S›K5Îöè*Ä ‰Œ“ظïÙ÷my¢Ø?xu2àªI dо ±O‡MýŒ¹OötÞI¾\nWÎCÜ?î{¹‡;Qèc˜‹ ®Yuqõv®þÃO/¿¡fâ¥Hæf_-_íÚ% ø({_}Xœþ÷m-ìço—K>ÌCð;BÊ#Út–v3·qÜÍþòb¾k©vø·nsëvpG2ÙýÏáZƒO¸;?E|Ø4ÿàVø­±k!ÞâHµ9Ä™²È_b'Û^(‡j"CõOÃòAÒªVñˆÆ$O\úÌöýýn‹’ÈÚl[~Ÿˆ¸øug<°;ŽYÞÓ½ µ“aIæ€"‚,s`Öbád¼¿ßîb<6zœ¥òj>á.büt”Jâ™S©]w¿jvu"º˜ÇT{@rkÁOUUø–zÑè-‰Þû^Œ±EV1ö³d^Èe?s*|¼¬xïÙ ñ‹ sw\£Û³ß—ûa‡Äñ{¸ä羃 Vts³äXø÷¨âÚj²ü&3çÑø=؉ñRieÍooìÅQ*|£”øËj¹·åŽ:Ú£»‰+î€ßÿ™ù{ Jø'¢Ÿ)û¿Üï!EùáÙ܇CüÀÆ—Lµõé=˯–ûÅWÒõÒOFÀ(¡]wÏÿØMuüT!®½ã¿]{ǯeøò˺ï€ÿw _mv·4…ß5¯·ánÀ`ÊÆ×Ï^Û"þúêÉ?žüÀ¯¬Ûendstream endobj 4319 0 obj<>/XObject<<>>>>/Annots 383 0 R>>endobj 4320 0 obj<>stream xÕ[ÛrÛF}÷WàQ©i`Ä£LS1kuqH:Þlù…¦(…»"©I;Þ¯ßÓÝ3= Z[[y± ÍV¢ƒƒ¹ôeº{ÿʒÿdI^Òÿ—›Wi?ÅúWFÿšþBO’rPõÉ&É"xHf¯ Ü$ƒ´?ô/gà&©ó~n¸¼¤>‹÷9ÈñÜ.BoÐ/ ) szò› bCÏÕ˜}R*g :uuª¤Å`«ªŸV†t™’AÒsµ£vʈN³¢_Òb°ªÓ¦2dZ›!Ä!=7,úuR*g TžQŸÊ(À\•$  ¶dÅ*ËÓÔâ¬t:ÀÕ¬9Ñižö!¥Ó¡qƒØ©ç²tH •”†•qƒØÐs¾N"g f¿ª i1Í•¬›Ê¥qƒ8¤çØÍ"g :Íjè8’ƒ-XJíV†,Œ Ä!='c(g :uVAlh1X˜:Ц~93W5µd@CHÝV-Òbê6#{iS‹7‰KyPeeP'n £0ˆƒz.ÃrE·JZŒA«ÖWd¥ÛLœDºe»õy¼DI‹Ñ-ÌPXÖ`´ÝVMÅMdPqPÏ‘·aP%-F·ÎµYƒÁŠÕb[ƒI½%iIYžR17â) Ð).KI‹1hQaeÖ`°èhXa”‚´ Ê ê¹Ì¥´PÒbt‹PSXÖ`”œÐ´5zp$rdeJ¥q³‚Aœ’ç²4¥A•´ƒædà NhÛò.8`"Y iB hP9TCå(Ç,úŒ€šè®¼È]Rþ í*?ˆœè3Ëhž<5”yf&¾ ¸SZBÃ<•ãX¸¬`Õ()ÂÑ5S b§žRÚŒ·ËQ/h;Ú.pU‡œ˜hÝâ $R ‰ - O±ÝÊt†&ôç ât<‡5P'‘3^µH‹Á: ý±©Å`Y¯†5lUBQ‘•é–&mä ât=‡¨1•3p“ K,öÈÍR¡9IJ‘´,ü{hYƒIªÉL[ƒ±œ3ŠN‘1}MÊë&gÅÔz•–s$¥¡-ÅnSB ”}”0diÔÌ2ƒAi¨ü•‹ÆÁ&O¹ÁaóR.B*¿x¯ÚHÉœê í“MÆ'k!•ër£?<ƒÈ…z%0Ñô¹Tëƒ ¿“Ô¢õáQ€R’Ì´PîÍÜœpÂûÓ¤¹O^_`Òw~‡ŠÅžã@¸²Hæ·|š&óåÙ|ñùa•ìî’Ñn{XmûŸæÿ4Ýñ)w‡èŽwI/ôÖÃN·Âëüö,+¨x¼q{–|\4Ûõöžž(‹ ÿøjµß/îW<*þ¬”çý—ð?'"¾¾@5 *¨Â‰ôýŒå§%˜lÍîö¸<¬w[V­J¦:/¬—´WZù܉|ÆÂpî¢öboÄÂô2M>ô÷ÇÇÇTP*ô¼;ÚgÈcÓüDæñKÅ»u>ì—ô™¼}õç¡Yл8ÓRM|•%À¾Ž—ýè”ñ]6 Y÷ZŒÔ²’'ï÷Ç 4ŠŸ`i¸ì×am{yÙò(fª'‚²S·–€ËJÑæ×2k…« ±ïìÛæóîa½¤Wm8Ûós±pÞ/»Í‚¨µ3’²ôFÒÑn³A X4ßHVä©—³‚l••­"Œl>bIò#‡Ø´à'( ‡>$%«¦Ù5ü”κ泭$Ç6ÍF®á‰ì>ñÒS­wÇÃãñ@O±™N½ÿ&w»f³Oënzª5š6B—5y}"öÿHRÛãæóªaeäý4dìfu·jVÛåŠ um=«Ìim–0NíhÂ.ˆñv…L»\V·ôàÒàÖw«Åáˆ,Ìòáœ#´øt†ï½¬®?ýÄMð‰Õ=sœVQ‘Nc\FíÚõ}YwKÔ;¶&â•ÊA(§B¹>ÊßÎ$•Kx+aÞ’pôzôóÏü„‚$½_4{ñ^úâž~:Ë!o®òâÄÀ—'­xñ< Š[´ÌÉ¥†zîüÛ£8§3eÅbË~œ™G¼·Y<²S:þý鬀 £‚çŽÝ.ãˆÔ£žQf¶Í¼»å¨ƒýu°Zr¿Ú®š…nˆB¹ùél9*gÚ/}.{ëê¨*nÞ63WjæËÅöþˆ] i‡Du0ßÛ¥ ¾tÌ"ξ\-×wRzakRÔ§³ *Ô¾àÔÉü˜?œKIŽ^VµEæì¤" Ö”·«»õV‚4¾·šu\C²ÚHÖ¥R_åÍmÁœ±°û f{·ÞvRDæÏKþ’#8ÇÙôõ…vÔ)-]Gg&g²_Ч»æ_Oœr|]þàåmvKWìÜ’zq0ÿ<Îú—4ч­9ÝšÊV™ƒïÎ<¬fÿø‚NB¼È=:8ÛY²§ÙK¼Yì×K¶æË0¥µ|¶VD.<Œˆó?8ã{©Vȳ“_رͳæ¸=¬7¶MöZúŒ†ëaÏ„­ìú·s,oëèhNÌ<þó°j¶‹zl³K*:ƒ* ÈaÇÍq#0l-^‡HÞ> &V_ˆ—ÝHܬçXü^û Çã'J9' ³‰¾î.ÑP¼¨§ìî¼*´8[.Ž¡–Á=D=5Z|Ɣޥvèq@Ýç-¶ zXnÍÚï_òg>AÄÇ\š6%þÖ2:=Q™†]%» ¯¹ÎìBt5<ýG±Œ[l|MaÃÆè>]áÛ$ÁPÍ=áú_›Åã£ßw#¤†Zîn-U>^©·ì×ÿ‘èSõ‡ÝÙ†{…˜âW[´6ˇ/ ö^)´™ e‘P,Ÿ ¨§ª…år±”ÐA—J²è‘ê’ä­Þþëú[xÙ¼—XF¾tÞ,¶±ÌNŸ%Ò8ÇZ1%DÖ:©*¿«!®Ï¯Æ^Î÷’°z¼°½"–Æøjy²^f¿_ß¼ŸMfô˜o²¼Œhd3ß„ðyçD¶·ãÙh:y?ŸÜ\ƒw;.\ ÷Qb)„ËÑ'rݰHb2“¦f®®Î§¿Ó˸ü’~ð†nü7HH?Ͱ"ž&õ¶ˆ:)û?jtNÎMŽ*û§9xr=›Ÿ_^žÇä”Ýe× R™o5¸pâ•ã¿Ï§\‹áŽ”&NkG”ã]^*¤ —§.Æ×¿M¦7×Wãë9‰ûš;ŸNÎß\Žy]Iž%Ã}ïŸÎ±½ŒÃ{8ÛEpb¿Ñùè§:ÚY„cÜÙä’þÌ^êêüúü—±ª€rœ¿F ‰p¸ëCXáô(èI1G7Wï§ãÙÌgŠ G˜Ý9­f“ªt|-Z1“¯-æ¨ëæ#©ež~Qœ°¯â÷ºÍùx3ýû)lÝ?ýÞsñ·˜Ù¨8N52scŽ÷>Ì&×|€#YÝóÔÒž†êþãdþŽõƒû¾0};™ÍG#zˆo‘îÙ?¯‘3ÔÎ6Ef\Þ©gïqDîÂ|Ž8Ý«—qÞ…¥zbj•ø¤(NFâw°ÔT8/hçÄkÕªrtkd{;¹¸OÇ×#I %ü3l´.¦7WìžæêE¬ÉåxªÖÅÝúôG[×å}p﮵<¹Þ1¢¦ã·“¹Ô«^¦è ²®B.{Œpçæïn¦džâ¥Éfð‹<ÿYAJ»ptðÔ)Aø j¼ôüáaußð™#ýj!DWºÂ㯚t¹Þ?rÆuÎn”-t9§{N€“ãq3˜foާ_ô |Ω¥‡š¡%âÉMŽéq.Ñ¢løþ ×—;hJ¶«óãõ ˜ðäúyª÷kdÜAäT™\â³(»ªù´óH‡Ç{zÜ¡”êrŒeª%S o›d²Å×ßC¸Ai>ýWaú }X½á» î…h9¹Þú/ hÞó·ü%¼´G§©¬'|¸)žaG„›ód%ºNÔrîÓs°tÎÍ÷ï›/«æËzõ•M.:¶-°Q+ˆÊ¿Òˆöǽvvß`ÿ‹ãVoã"°š°¥üdüGV”§ÿöò â¿ø·øÅVë~5.¿+ÀÜ |¿Á7rÊ^=‡_B¼Ý-|™T¿ûà7Ž)îDô*j{{öe½&Eç¯~}õ_‰Á˜endstream endobj 4321 0 obj<>/XObject<<>>>>/Annots 437 0 R>>endobj 4322 0 obj<>stream xÕ\ÛrÇ}×WlÞärao¸<¥Zt±J±”Ž*U~YKi]¸0H›ŸÓÝÓ3gAª"»,ŽS²ÎžÞéËôô\àÿ¾È³þɳr,ÿŸ¯^Œ†#<‘?rùã_ßË“l\O†u¶Êò–Ùå ‚«¬œ 'áE᮲z:,‰#¸ÊfDÛ¤A|¯¬†‘ŒÁÖõpFl]IW«Z»:™E b ¢a^ ÇáMÕƒ°ˆMr„5X–$VA¸™v'rE“‰˜ ’&´ÈI¨‚$4py5ûD’1ÄN&b‚ÈšØÑŒÄ*Hb—Óa‘#ÉXL «b뙚Ò@ë\>*!6‘Œ!¶ÞKì¸DKìtÔg ¯²"¯(©-c°Õd8%ÖÔ™R Ô ’:ËGb¥D2+i—bÓrŒ«'(µüË€ˆ%ˆO/ GPl4–¾ªm(ÁX)P ¤¾./åDš’…B­ 5 \^ŒÄ+‘´†ˆWñæl©aàò|&]¤5,ج RÃÀÉ`ȳ:’Ö0§V+H 'öGˆDÒŽØ8 RÃÀå¹'’ŒÅæS‰žÄ7ëGK줖.%–0"o¤šF–1Ø¢Ë'–°Dm%æì¤@$TSsh>ªàC¢-ctª”G,aérÁÄ;•a˜Xû,òŒMúYEôYgí3‰%,‚eö¨"k‚Ç.¡ÿŠH°³•„h•XÂŒçÐ6±„å³2ÁKØ\PkÒÑŠ¦fdEÔ)g1R«¬J,a´­r1cb ƒˆo‰%,Q£ŠmK—KL%©-c°ÚŠXÂ`a}îcLá˜r’̬ŽÚ$Y_µbž0 –Ò´á\Ž‘ÈE/‘­s±qb ‹kÇ¢Mb ‹§¢Md‹ éTb ƒÅÜÃm-,òÞ PD]v¶”tQ%–°8~*‘œXÂøl©qY3ñˆ2j¥ ™8p9š &"ÉË$B,a±¢~4µ%,vÊ%R#Ël¥ÊFVíTÎ,“Ûð1”ìYj%ªFyWYÂèT]ôYÂÒezÔ–0:5õ‰U+–S TъΉÕP ë›Ú%‹rwB,c°gÌÚGÇäS±©@ä„.<&ƒ«bSÆ`1Πib K‡%(Ëìx‚¬™Xëp(ô­‡ R‡}KQTFÒ†²Û*H 'ñ¯E’1tÑ¡XJk«g‚h±P3’ŒÁæROKlUJ—R[Â`‘ ib ƒÕ™žXÂb|©H«ÅaŠzÍÉÄJQJ†&NC'TíšV%+Û!ˆî`Ò€?#ÉX•FÄ‹zFJm ‹¢2éK,Ö9ˆßÔ–0Ì€€Ûj‚(ÂJB±àWöÄêYçÌ“‰d ±Xܔ͒ÞÔˆ„ÁÂLÐ5±„¥K² #–°å±f _5˜ïâª!XÂYLùÌ©R8Æg1ŽðÙÈš`_U˜à¸ª‚Å`„ Ä}TpdM°¯:Lp\uÁÎb]a¶“¹Ö̘0ke‘XW%mqU;‹™ H,aÆ~¢-²&Xk~Öã¸` V×!Eb ‹`ÙI¬F[V^b´9—’NÉX>*ó±„ÁBþ”YÂO’ËR[Æ`ÑCn« STÊKͤÑ0%I'Ž :TÊê,‘ŒÁ"cWÄštV¾²´ \k ‘Ügc'ƒÅLMK,fôœYÂÒ%™®¨-a°Pê$É„aA„0·5uÔV®Ž‚äòÀåp F’±|´–'–0>Š-:n«,‹Ÿ´\4¤ƒJ:²+ê»Ú')„r­ÈñU{5ÖçŒñUTœhYû*&úª"úª³ÈøLb ›ýM‰…ýƒÕ:“XÂè #„SlËìxŠow»¿éãÑ0¯+ ¢=f’—Ùã:”cVzwýs;7õámOz:p»õGé|…©äÈÿ2#åLú7j—UÔ´¤EeؤL2lö]»oº¥×:øí˾}ü·\ÛIßŸØæ#DþЬÚÝmƒÐ“ÇX¸œÞP%ÛE¥äŒ<)„=¥P èhTt¹¡ž%A'ö×¢ihŽõÒØŒÎúwHª×IÎü}»Fµ8Çb¶ç¬7ë»U»möœ¦1(68Y•ŽŸÁÁ¼Ê¹§Ôëí¶yPuŠS,ÐúnTT:„ußUýéðlÙìv–)t›×ò¥×Æ4Ç]î·ws+ÆqÂUx½óÄ›?®Ýï¸Îà!ýôróIì‰m—8•®þòÓ7jdÌŽÇ®•p6/Ÿ䘮9ïŒ-’5ÎÞ¾»Ô^N‡#Ÿ‘šÝgØcê¿Í* }“Ç~9ò“¢Ò8Æy¨§†ÇÿÑóbý©Ýv¨ƒæZÝ`ZN%Uƒ[ú.,Å ¤Ú?ÚÕu»Õ‡ãaéÁ{ӵ˅ iTm^ø=Ò¨éç1›ÉŽKƒ#»Ruð&Nmûó%öº”þðéAž à•êz£…aÁ‹n‹òo©¯bU:òrߊW€¸÷R÷ìÛoõ‘®t-YÌ)…ÐH¸Û…áÍ% Ù ­€‘Üû‡ÛÖêd¹€ñfâQrï×ÀWíêvÙì-žP„?`® V{ì1DÀ÷íZçáPÆ#û*FóWOkóÍBÇ9b&:>±(±ãâ`ß3v]Ž•ì\ó|v¨úa2»€C»y§á.›9ž ÝÓ¢6[bâì´jR çgæQGì[÷‡¸®àcéx…A³hoþª>Çf¦ç/×p§ ÆîÝ'2ÛåÃz³~XkL}˜‹lKŒØ;?nÂ'õ{Ñ›@ª©F[â9û´Ùx’+cçyJ—Ûm·j¶–à8ˆ¡£¼)™Ïâè4¸qì#=ȱSß庾.?ó‚ªßBÆ}õ¾Ùb¸·±-[ç¾ØE¬4w˽-XÓ³(*öv±vÕeRé;µï°Úì-ãàè=Î;Ÿ«·žéω #‰ý0GZðã˜\Ý[èVNٹŴkÕ`³ý¨ï47\RÈJ-R‡%n‘[*vž¨Þü:ooc=… åEGOü³ƒ¢¶…!.w÷enå¥køK(ñ/ŽbUu­é?Jðduß,ïZÍÈ(qbF¾ M‘ƒbýù¨é¶½i·m¨ÀQ}>kh¸Qp OéYKOÚp“ùcÕܪYþÈzîkÇ„k§;Li bÖP»3ϼL¢S¯µÂIÕZžøàÄ2FÇþ“Í<´êxb˜èl¬ÑžgwÒ "7UxÀ"æã‹ÄH¸ãÃ9 a eÕtÌùæ #ÅõÃùCõ+Êw?^iüiô+jUa çç½`ZKÙéìê?ïߨ›¸T¶A¬qp–_hدùš+†k œƒm‡µ ÒaA)Õ<¤~ÀËi=,›4¯!¢ýäøk*û9ÙѸïÚ]\NRŸ%÷¾ C“Îwxh¹ǭñ?§SzîÚõÖy•Ÿ¨ÓÎÎ[–ÝpÇ\|3ÈG¼€Å‡äùù…J¹vàSOßoži“ážçoQ-½ɹ¦x´-õöâò}ÔŒ1¬&‹“ˆHÜh4wá^Øá Ó8ŽDèuööõ奴À}›Üw·X1 µ?p{ëw:;j….ö•†`\lþc³èn|¹H;†ñ6 œçayÝ~jî»°nÃ}_t>¹ ¸§ê—B0tAÿ;µùmÍ\wü’‚tW_Rýz±ÀÍ£ûÃ[ͤ¨ÎýL‘¸!–×8šîŸÎt)+5?àë;¸*ÚE‡Ÿm[ì~Ù^!î³ùÌv«ë’ËEß#zQÖ.Ã-)¾Ô®ï»íf½‚‰u¨àWvÇÚ? ±íqp5A޳ț_»]´«Ãc€k")p,Zó00“/Ê}LDEqÙ,t¨ù¨Dè©4Xß-—bŽgé¹kpè1ü ±¨rX¨?¡Š„!’™h#3ïñAêDŸèÅ;W‹Ü¹’=;é7fš˜k’†ÊPé³×Û‹¼Ö´Ñ«ïQaa»ó“ZÜó:R-ëÚã—½ˆìÏ=л[{*¢iæas§5y2™¤ïü4ê»ÍWãÖûxÊ\â‡îS¬¢i»xyßu¨ÿæêÅ?_üñMLendstream endobj 4323 0 obj<>/XObject<<>>>>/Annots 489 0 R>>endobj 4324 0 obj<>stream xÕ\ï“ÛÆ ýî¿‚“N'îdNIQ”fÚŽgÒIš4¾¤ŸiI+Ö¯êtŽýß÷ØuŠkÇ>GN3®w¹Àb±v•ÿÞ+‹!þWõXþ­ï C<‘?JùãǯåI1nÚAS¬‹2Àªxzຨ§ƒ6½(ÁuÑL5q×Å´õH»f$pÔè÷Ú©á¢Ýt0J/ Gã¬ÊÉ,¤™PSûd]Ó'Ä'WG"‡“ŒÑíh„‚­Ç2xŒD4×HïTʀ뢭SâBÊÑ "Nôß@c>¤KŒÌ©öƒ#˜ŒÜß.Ó¤O¡™Ød¨\„̕à Ң7—½Q W«Á¸’1TZVP ±„e–Û~[Â2m¿-a°“¡ ØeÓd5 bÀ‰keVƒ#(Ãb iަ¤ÑiâÆ­´sŽ ® Ô95Ö¦6Ða@ú$¨í0•ú¢p0š Es#!ƒ­ÅÌ£)c°PDÅ,a°SÕ«Ö†‹Ï‰!ØøÄpW–Ñ“ŒÑ-Ì$XÂ2¤)4±„×E5œÈT{[Æ`ëþwƒ…p<*Æpy¥ØKôl–äH!lâ’pN2vaƒ5as[.XÂ"¬®g͇l× dH¶ g6çA ¨‰öT9G³kT.gæ¦5L%8‚èV6&’1ØvˆÕMƒŠýK:¨¦=–±L©¬àhk´´ F B˜ÄÙè#èÂ8™„I-Óàƒ5á2kƒ–0†‹]eRÄl¸cZP#1ÜÄÙøœ#èÃu2 7µLà ֆ›Y^°„1\\SăÅvÝ{[Fí0y‡‘‚&q²ÀXœd qª±è(XÂøh)®/XÆ`ÑjD¬.˜ÑˆŒ’~ sºB‚#ˆ [éT{ц*6ÌÒ½àHAÈ™8sA2F·š½75õA¼èVAt›¸Ô“ŒÑíD‡ç¬u‹=ºUÝ&Nüôî$ct;ÒYqV5[Ã¥[U¥U<ÍŒ¤N@8‚è´–-6Z§š®ZAtš8Ÿà¢SL×´’±È1 VÕSÃëºz ¸z2W–t«o ÉÝêsb ƒ…ž g´%,«L¼|°ŒÁ"(1KìdÜë™1¶´ªÂ žƒ± ƒ5U¤ä@7‚ZA¨"'¦ '“*2k¢Kª˜¨*‚% q`ƒ0gƒõÛ2Kã—!3;–È€z& Ûò¦ø.a‹  (gíCœÕÔ BQ‰+‡?ɪh†òQoÊl« 'X¢FI¦¨-aˆƒ%€{[Æ`5µ!–°(J–±„¡ 83c°º½E[Sçbµ§[f`‰›èä8G¢Úzv’1X|þ%X¢q†Á2 ¿›ð¶ŒEj‹ÁÛö‡ÌŠ@¢/ãmM){4É„Å$.Yˆ“Œ!,äD;o iÊìTvkùtb cÀo1$gƒ…'ƼK,²-¨1XÂ`±ÀyTŒÅbÔCy[Æb1êÝ‚% ÖI@;•i/Sêf2ynF"j=ÚÞ”†ŒE¯ ±„Á"2®˜% ¶-eHþYÆpÅR¡!gƒ­dû –0XÔÛJf ‹“—ĆÚ‹$ˆÛÚ”¦dÔ4ãÙ&Aˆc–ë$c°UK ;m„Á¢¢‰!KX„‹Õ!¥W‡ wKŒ,ȪpŠ ¾‡>$. 8,¡’¸€‰ú ï“ 8„•m´#áqj´œO÷ÓéÄ rh g´ælù CöE_‰Q+׿»‘k~”V£çJª¶Äˆÿ–2}ž™€2mý8§ƒHY”.6Ïe¡RƒåžÜa@Ѽ}påc²Fƒ ’¡æå}ûÌ95ñ“Ôï«Ô‰1äA| M2,@@ˆœ (á¼ApÐõI*%HrŸÁMzÜ——t|ˆxgXì)<Á⑉º¼2EÕ8ƒ°È•ŠË¹5‹ËÙýËîÙjQl¯ŠGÛÍa±9\ÿíòWêNO#µ;¸M4¸*.Tíèí޾Åéååü~9‘VàñÆü~ñô?ß|-àfÛ:=ë6s}g2WéÑÃÍ|¿]êãO๬{D/軬¬ß|©vÕ¤F¾øB1Òõüh¶ê®uØPõt”Þ[¼êÖ»ÕBÞEÁ»”W mpFÿ  ”Ñ]”°Ä£žÄßž/öödPµ}ñTl9IIj>#ñl(¨ú'![šTRÝÆÌ`NLêÓËo¥a §œæùìd;5 $ïƒ'¾\¦5VЬ¹ûåT%zÇUòè/Ú ‡6Ÿ’²nà·dø´¾ë0TòT6ñffßlûíüfvXn7Bi’uv+7 ×ûÿ$éŘ嫎ä{¼¼ºZì›ÙBW.Ä+³Ã:lõÝá š$e`Ýë#$@Ùeþ³{ÙÉ3¸^wk(,9:8ÿéÙ8º¬rTùÒG>|¤‘ŸÓ€JH6‚Ýv‰­ho¾M*{Ÿ€T­9sd§±{á¦Ì‘´¾˜ËìÈî÷Ýkå’ɹºñž¥Èk‚–w/HlkºÊ“y™Œxâ~<ÂzöH…ÕÕÒ…ZƸPs«å³}·­+@’és0 ¤N2ž œå’™ãúŽ2«á»nÓý²ÐXGÊN))N‹ys½Üü¢Í¡Í¬‘|³y¹}a ¢¨ÜÅ|qÕݬò:*Áî´gí£ ³YwûëçÝj•ºG}±MÝŸ˜à÷x”uR5R¹`ãÐåïÆñþZÙ-7›$ ¤ÿéÞ¯jU‹R BòF¦‚#ž¼«ûü~õj¶ØÉ¾§Î™Ký)8ƒªUwÑLišq𤖗ÿ¶×[daå=x:ïy¶ãñÉñÙìùböâ3éyÒ4wqx½[¬»>Fá6mïaÍoÕ´juŠ/ä°†M¾9rw¤‹¿ö5*•½ëqL GvØ·„þ‚¿#éû“9]ï³åÕrÖùÂt—&ÓEÕCU÷õÐÏéÝ\¶ëd¹žßÖÎÃÝn•FïþAZ¡æžž— êÉ׿•ѾïK.,¼Xø:ÍøÞèë/÷‹Ùa›B¼O'îAÍN'·é¯ññ‘¿ë‹GÛ=O"„½Fßfº³ˆS6_ÔZEnß·WÀ¥Ô\Ö(#é‚“6ØÏFÎj’*.™ëQ…) '£¯›Á$ç^³î墳ú˜„ç}ÞšÒjb²œ=ò>¤Þ™åwˆ—˜,‹6†ƒ‰ÇˆšNêc”vËñGÞGn ô¦YX\UcY­U…Û~õ2b„ÑmWšu2¬§;½%úÝb½µL ³˜7…b­iˆ,Pyåç$añÛó…\pô™§¼Ø/7{®‘œå—÷‹^5j½n1Ö‹õ3+_b-ùžõ²Û/¥ðlf†2þ{×g³RäÒJÏŽ\×;êåj»Má²›K¿}ö+6/9ÖMÎMw(B[‚‡²·¿üVUåÏU÷:}Í܉âþ¡ZÑqކŸ õ éqwМÅuÒóHlqÙKžŒÔOT²fÈqU³”Êö#w7Ú|t@v ]ogKŒL3j¡fÓì‡ýòÙÍ!YâàìU“Øõ\¹ö´õP©cž´‡:¶ÛG”ã̱b7ׇ=¶NËþêç ß^©Éoû»Ý~»[ìËäîåHê§ÕÔöV¹æß_ê¬"t8aND!'LêóÝ~ñy²©I.›œ0žÏwÛ냾ˆ¢c.€¿g|}ƒ¢)9áæGqí»ÇâÕÔªI¸ŸÙsîºV]‰—ä—©:üÛ¾ÛíR‘‰ªfz>–mv(²š·F./Ÿ]#éVjÒT£äRÁÔŒNïó¸z ƒÁYc?äFåJ™K _½Âáå<×µàry –ÿÊ †岯&y¸föÛòð\{…–òŽÖÍçKIM)£¨Rß^d³íÜ ö¸dùî3Zþ7<Å:L5zé’#uTn,?mæ‹ýêuÖ M«˜¼tçäþû„U/67kÝîäRäGœûÿ/;³áT:Ÿ³Uš¤½ëiô£çËÙ ‚pªL†õ†1œ UMÕÅÒv÷Á8*RÏL±ÿûÅj¹^n„™[ÀõˆOCÞ$êEãÞQÄ; }¼‰š0Ü`v~+V@ŠAh½DàtͨètéÚBÜ[ˆ[æ¤e‹3ºÔ”¥ÅÕéž‘ö“£'7½Ù¡Á„žà$ä3òHü&BC,ÎiÔ8û9—æM0I€ÎZ°,–þŒ"lS-“„Ëåæõ£o¿**Àý3Ц7Ë×ÛÔIºo—›8’áà2?áDÎjjµˆ¸r«<¾yñTŠð3‘ë=Ÿy&aŸ%D¥*ÕpO`ŸÊY¨Ð˜=|ÿ‚ ¸Oð"½›owOSf1Û®wK¿‘é{Ôa¹¶ í.³¦¬3:˜S¥õæ/o–«œFÊOhr9£ì ªM É:¯s,AÚ3E¥èZÌëNJxdò¿ó×,´üŽ€3\²5ÃH+‹!â¿“°N‡ºH*å3‚S¡´]CSˆŠ3N?Õ§rêžcÁoï<ž¬¦zõ÷0e¥‡ÇS7N>! ¨ëâÀïÌÜ;=Îòå}DZ?|‚ë\YÆžÏ;>yýºÛ?ËNF˜ «˜mW+Ôìc¡–gx·¦Úár‰r éñÉÝO›ë›Ýn»OÅoäî^Y¾ÂåÍ>•úð<íjʼn`òÅfû›ø‹F± ‡2VìÁ5µæÏÑ’+¢å`5™žË:r"8ÉàûÌ)GÄ5*¾ÄåÓd+5ý¤àïÿÈoürq¤åœwœU%èo;âýY~-G‹Ÿeȯ›qE|Üâ—;÷ÍÅK_ÈVâñvvÓ;”—ÿ€R…ßO\´Òx~ùJ$ûêòÞ¿ïýt³d”endstream endobj 4325 0 obj<>/XObject<<>>>>/Annots 542 0 R>>endobj 4326 0 obj<>stream xÕ\ÛŽÇ}×W áš9$PV °½Š´‰_ü2"¹+ÚKCr%ùïsêÒU5\m,¿hgã@Ö™3]ÝU]]]]=ôYŽЬšÒÿ›Gù8Çú£ ?Þ¼¤'ÙtÒŒ'Ù&+\go¸Éªù¸Ñ‰ p“Mfã*pn²él\®šRõ„û›Tø—’ e2®) +j¹!o¨Ü¼¡ „“qȈÁNæãy`¥Ë²]2ð.•“>œ«IÇ|Îíš¹jà&›W4~‘¸i¨9ÕȈÁ–6ÜÄÑ”4ú&‘Cl5ÄyÓˆÁNIWg¥Ó™øtÊÀ;Un^Œgp0z‘mäB¡ÿ4ƒ…—`@Ö4b°óyO° ¨ÿ’1ð)7ŸR;ã„ЂddÄ`±0 gÞd%ÚFÁ2 ©xŸ ˆH¹¢,iŒ˜:-áÔΊØ:8ç„‹U®ÈK2®‘Clc]6`°³œ:µ¶Òi]Œwªy91uÊèlÀ`›†ì`,/ßIBꔈq“çK´$5Yµ œ¿HœôW„5aàý)7ÏÉ Œ“vy3ÞN9YBÆåa8¬/#Yh=“ifm˜Ðıç„P¸ÀLß¼¯/û‚é»Þ²²”&­º›£<ÃÖ˜ž-×ûÕâØíõuª(žRhF¦@4€)LùºîMvͳ•<~™´š&õqÏäêŸêŸ6ý— €éþ|¡ÊYÅQ}?.õIOqòÛÅûÕâ7ž±jœë͈H!Žn8ïO‘;|ÜôË)ûN{žuKY™¨à¦ØµÞþ 'Ö ™ëÓ¢Ò¸ØC|ÈFmÊrY!*Ûô”}‹Ù\·×ô G¶yšÌ”îñózÜ$;lÚžã] Ûl@éX•³›Žè:(N®¬ZM7ÿz¹j7{Ñ ‰¸Îëƒ2‰*y‡û êq•ó4ŽPhˆÚ² Bªõzß^mZÑ*„qÎ/2¥©ó*^©AÁÓœâù§ÅjGë”uƆ’âðuy/UùŒ–ÚÉ‘¯Užâÿ£ì3ÝYe~›q©ûÊý©ñ¥='u§ä”®0Û (|~|¿ÚK¸—霠kX”.ìØø¥]ßÏ{Ia.z ŸäÑÏ?á`½\ñùÛ‰éL©òa×.8r¡òT%cnv»nÏٲ˔œüò˜Œ6±ãÒÖÚ–ð s¿|K/¡xtÇ‘d¢‰&îùe¶5Iþ g¿²ÏýŒ°ëÖ¨?°_àv8 ³h ÔWÌM].ª‡W=…Ïw«}‹\™"‡²Üªû°Ú_w-’Î+¢êá¥W¸¤‘¤H5ìçÍon¶[Õ³yòX,tjŽ"¢«Ãqt¸Ye»FjX‡Ó¸WÌa+„vºA]H–̳øêS»Ù]¯$¨aO”÷†iJç±ÂSä¤N=i:îö|>Àõ›Å°5³èë«tüÙí»«ýê J#¨¥ç©ÿHùèîºÝn%.â3"+ôö‚j<×°üÕþª–yòªŸôÅ ‚}IUÔÇ%G¶?[÷|Ùéªx•ÏJü"Ö=ÝkPŒgݼÚwŽ ÷a½úH9‹8Ùªj:šDýdÆ]¿;BŸ•ÀïÓúù¸>¾ç%V‹ù óL²ÀÜ÷ór¬sl£§Ëåš’s9oâºÅBÖ„S Ç« Ÿ{>'™è«­ëÐQÒQ.cÒGjòT›š6S¶—ßwRãBÆbJ¿XkÄçû™áÍ)T¯ ^¥#ºNõĵ”´%lsOÉ[q‡“j»Ç|xf5”î’|HÙÞµ‡õ‚ýu¤äûgOξûŽÒ Ø*ÙÇ}»Û¥´…‡”YÌ:(ô¬s’Ößvˆ×íâ·öJ2äéÉl?¥’8¾§\ý,zé¾´H1ÞçQ6JþVÖ°þš¦uc~ ÂN™ÜôöœâZôplõ^&C.=TÏØˆ¿)ðH†"Ø(ù|{³¡3J*±à@;L=“†üqCÔ°_ÎþÌ4^·‡ƒfâÞDZ5IMþ0¡§¦Ä P¸CUžðps÷j‹¢ËެÕ|ö4ˆÓHUðD…7ÖP°ûåûÛj^¬p¶jqž$U¿0EË[ ³_¶¿­d*’ŽøšÅ¶”³àÎø´sp»ŠMkïV†¦•«–T=[]¶7שÒU§Ìà¶!vûõY¦ÔpްD’îjÈ:ø:Öò\XQ^!žAŸÊÜKf6àï$ã*ær‚Ùàóid»¿BLNû>âæù€w–Qï|€Ï¸rP¥Ïè€ %®·Úþ©Á« Wr:ö ½¹+‘V«*ôqµWx¡ÿéŠÀ  ²\Q *8T‡‚@ífý¦$*ÞJq[Ëáá6öe0Bòöì?«ý!e%Ø"Ò²Pj©êc}û-~<Â1ÉË?®Z«†’ÀíÓÓ7?â+±ëÕ7Ô—éc¹),C1µCÍP³é0Ùç×|ëž¼üž-ª€Ÿ÷§¯_©ñ­ÐæOfÀïÝü¬¨ wÐú‡õÖN†îÊVÖ÷¨òH àÉaøíš*Ý4et{“ ¼QmD‚Á¥):­U!÷î¨@¤mš4ì_ã‘òßœ¢†÷”gÜé›'Úáw==9ú~þZSBOvˆß=SŒó{?^T…ܾÓGý}ÅûÇáÛ1êéͱýà7sT¸TßÍŠAL{ܶD§î”¿ïÞ½[k¾ÏªŒW›nHúãÌž~(óoܺï‹N¾ Âýê$0^t×–“b©ß»¯Þ½†“®øïuDUO?™ÑH9ò ñ¨p‡†U!7̽OžpÚÑÍ?ÕåÞ¬v¸SÄqȾÇ/í¸x;‹Ò¯ ظZ´tR¾šÂu¥`°éÞñk¸ÕœÞÿ]´ÚƒÅáð0è‡Pô D3ú-~·UC/ÜBÒ]Óˆ~ù¬[ð™ÑŒ„#(>Ù„ß4Ôtùø™õùÅ£=úY$æéendstream endobj 4327 0 obj<>/XObject<<>>>>/Annots 596 0 R>>endobj 4328 0 obj<>stream xÕ\[›Ç}çWÌ#ù Íô\¤GŒaCcâÝÄÏÃjvQ¬Ëf$ù÷9UÕ]U£UÀÄö2Øþø8:êK]»ºfäÿ<ʳþͳPÓ×›G³é ŸÐ9ýñã}’ÕU3­²M–Xg—Üda1mâ‰sp“Uóipœƒ›l^N Ï•´^YñzÍBÍé íeN ò7‰¬x`n ¹<¯¦eV+é1¦­˜ÁØPÓŠœ§­hv¼¤ÁM¶¨§µãĤ˜ àYh L:£• ž…M9Ì‚•sv:.o,g—?½¼ Ž›?k·KþÎ|Zñ£‹ãjÝчO^ Ëä(þ*,QȬS¤,ž¨J3ovox‡ÅB>™ŽûŸPÌhÿ“ªU „ºhû7í-kçVh¢¬Ïvëuw}Xí¶ômÄtu9"‘“|ÈNNÀ9m˜/ñ‡ç¿\ww*H˜Î’9ÿ¯X¯¶·ôý€"'~>"u+IR$5ï ‹Q_÷»ënyìÙš(Œge´ærw}Ü ¾Ú¤$‚²'1‡ÍÙ‹qä$阌¸Ï,Rœ¿_Þ’NŠy”}ß]/qÛLGºhQЮ'8Õ#ç’}Lî‹~x}ÉÞZ™xPÆ/XfDoÌKÙ³u»ßw,3Žƒ0¾Ð…g'¡ùY€%]ÜYîòù«v“‚W†”¾_î÷G•om­ñ2’¿9š&¸·ù°…ˆœƒUÄ¿¯¶?«Œ£‹ÊSeF©ž¼°C9Ÿg“‚ŽöÇEI¾ø¹‡ñ_Ûw-û0º(#N皊šöîë*“KãÇ*¡ SN¤Þuý»U÷ž>ÆÒ¯IàPðñ:©,Q¡<‘ïuß­WÚ¶_Iˆ¢bü:„Tñ¬b‚x'eàÇí6E+ΞdU­;Ñv«´I¾ù¹'J}2`‘yº\®¨Nh×ô1®1z”>Ûm6R4q…—Hp`EŸæKN\c¾ BÁeÑ„î>> ÑYˆyº ™ÑÎØÃ[ Í=júÕíÛEW%°o»vÙõü)´Twƒ;ë€^ʈÅ×ù¤ñ0Ÿª.¸=f©˜ršV“ðw«T “Å“˜œ•áäZH~Øâ8¾&¹q[Ð7»åQnSjþâ冉Mx½ØÕÀþ¹€B-ûaw»¢å—êJ'ZÕã«6B›qù`R+猧õ»kõ™“©ïú.ç éq\xUÌ0³XUœY¯:èªTô õ†2Yˆ§þ€séëAHà.•ÔuîŽñì›oh ˆúŃh*¹0Èó`ïà|<«Å¿E“c™’ ¤¹Õ£É“×O«ír÷^lýPBüêP“E=pn´¯8™Ÿ:™çz0e7ýnÃ^“[û×j”C¯@£(éêòp\®vü]<âz؃-IŽŽô‰è¬$ÛdÀ³©ìÕ÷Oÿöœu„VV”çWkýý¢J¬wƒömÖõnžF/Ýú17#ÐÔ>»ä²õ›v/GTáº=ÏžÄ E_0nïûöî.…šæ»ŸÖ+Þƒ ‘&ò‚•E7ž<ÐçÝßó©»ÿ3}X¦ëò]{ý3úy1m[ir&ÅÝvÛ®o÷FéQ*æô:†6JúìÚZ ˆŽ&~üia~Û7’*è‘°?Éñj ŠÇ-7+Yl.v8áÿ¶ÅÿÈÑ!p6Á£Ã¡\lz5ñÅz÷&¦$ïp³¢Î¹yÄý(ä ÿ(¿W}n÷‡6vÿ¿ãqyßxÃòòùMWîRl)¼üò°ÇÇg9p\FMðîÌÐ#ñìŒbÍ6O·»í‡Íî(R¹[Q‰ùC¼4š' †·›Ý! )cÎÑ«wݾ½á 3z­3±ðVó¨L˜d[ÐOüIç®'FC£øÎn¬©š=—꽸hôŒ$“† ­'z«ðTVÎ¥ÎAÉ|>¸à¸M¦¥ê.^¼¨£±l±ƒqÏa9¿89/W›»xïv77 oNDI?+ü‘_Váf¾…—"çùëÝ „å© .{#qÁè%”ñYëPªáÍôòЯx>Ç9ò«8é¢X÷Ê”á=3•Ö³i™.$Ãz±UÖ¼gÇPÊ =;ŸD9 µ;#äjû¶ëW¨]®9ÝàQä—ì|ÞË}J>†¢¨“§«ú(*_*ð®kjve}wÓõ÷ ˆšž°¶}ß~c ”Ô3;sá¸ÃSI s¼/¯Wº7üðÒµ"Þµë£$oüvêaÜ&)¿KØ¿l“ÒǞݼ:®¹-îŸ0ßùd…›I¼­:íÙ¿†Rîxáu(ž—nŽgü{‡'Uë:ÝrEtÖ½ñ.ª•F!´JŠæô°FÈ¥aòY—ÝM{\¸jr÷Þ¶¿åW'$eúãéþâ·´[d¬aÚÊ9Ô5¤ÏØMünNA<ˆPP=L }^$ùÐSõY9—jï#¦"áå¦íÙUý“‹”»Ù…ËÑ•~¡” ¦¼(mesº¦ß‹c§p=KẳËîЮÖlRßž½×Ê>óïÿmtáݤ̇/>US÷üø"Ö#WñQ¥ëjsѼ閫¶çco›§›Î__½$âeúÔŽK4ú‡Y9Žöp(ã%O§œ‡LÓKAî®þûIïœì®oo7­ä ¼ü —ßPÆkßà(ü\ä¤×yÆîçnñiÍ›¼ÏIF©°’ ÔI'C_¿p·ÞßGÿÓê_äÁ}?? y>Ê5äÏÙÏ4ã €•=°ö·/úaÖÃç°OõIà¹oÊñ…„¿¹ì÷Ýf'ÙlðÆA»ÅSz§•¾N¿C£#T\R#sJ%å§Iõòôæ8B!&Ùý&øi€¯¦ÉJL¸˜Dwñþk¨Î q”꣤37Ã[÷:Î9m" ßBÇ+ÿY§†ŠKþQƒýÁ¿GÀÁRø=~UÿiDVÏœüÃzlB¿äøîô¥ë@/~¢A2ihðòñ/+òÝçWþñè¿ý(ájendstream endobj 4329 0 obj<>/XObject<<>>>>/Annots 651 0 R>>endobj 4330 0 obj<>stream xÍ\k“Ç­ý®_Á/©r’Zš3ÃáãÓ-GV^'÷^mâϳ\®v\|™KÊR~}€nà 9´åhwµIJÑáa?€FhtS?¾*#ü·Tùßbýj4áù£?þÿOòÉ`RO‡õ`=(¬o_\ªùpš¾(Áõ ž +⮳ÑpFÜ´”ñÆuoŒÿ7dÆlÊr8a–0ØIÝe ƒëtuí™ðzPŽ ÆYÆ`gSŸ£´e =”óá˜Ú2;®:³b vrÒ–°h¸èöLx=cÎkЬ*V¤"Rdf+Ud°„E‘sY„` CåHÖÖYÆ`«i—% v2–µ¶„ÁB<äl=­—… 4;yb£Rê7MØÀ`m Áa§²>ÎÚ #ÑÀz`£(ˆAWŒjY'Ë µ”³º8õ<ï*±jC±8ΪÅKXæ;ðÄ;ŸAš`mØo®Z ›Yè}Š+ßU–0:®«áœYÂ`§³n[ÂX×ѬÓÖ&5eC­Ѥ2[ÊêKX&5–Ì Gƒ)GÏ„1©BŒ-Øjûª'flë£@æD61ƒ GCSYoÈØ´„é‹¶‹–ÊN[Æ`á^!Œ·U3­Çd¦dºjµ™“)@ƒúMÕ/aÑ`-ZpÖºÅqë¯D·‰+ ÙÉA2F·p¤èÖ›Z·¥™¡MOAt›¸Î t’1ºE‡³„E5ÂhKì¬e;kS*ÌmJ bJ‰+°‡!©“ŒERR°„ePÝSÎÚ #òhµ‚4qIN2IU½Á6Ia½Îê ã™Š4s6HŒÑ-å|@,a°óºÃêvOÍtÿA ®p‰Å 8‚è½Ìˆd v*[6šÚúb»6†‚2qó –0vŽ :­ ÒIÆ`g:¤³¦Z+‹±‚Pmâ uA269Çb!JÆ&'TäÛ þ¾G%0§­†l G*¨“ŒÁŽ%¼FSÆ`™+f ‹¯R-yÏ6%äA1%¡‡ÄIYœdŒAë9|±„ÁB8,M´%Œ)éçÁ2;ž`nÄFžU”b¼Þ³‰Gâ(qW !&ì$cÑð¨Ë Kx¢¶„1a„2ë=›q#åãVÆ8„;´sŽ öÚQ:8‚˜ ŠuTØ®®ƒÌIò…Ä~SHÆè¶%%–°hH‚±„ÁÎcÚ3ah¨èm‹þÄ/Kì\Ć9Àã3ËlÝ•W¥Bt E)E%·}Ó%öœ[Êöƒ*¼©u«™wr-rV ]nZÒÔ5HÆ`+Ysb ƒ…V0¨wÌ,Ü÷œYÂ`‘jÊ92OŠ14Œ@ˬ‰“N•ê¥*¡¥Ä¥.«“ŒE]Ö` ƒEHÂÂ9kƒ¦£¥ ê'<‚h÷ -9É,’Nè!XÂ2¥¹XZ°„ÁNG¢gmJzÄÉËêç›Râ (p<¨œdŒna-5³„ÁjšHm ƒÅiâDÏ„ÁÚ²KËZÉ99Ú2–M'鱄ÁNu;{ÏŒÁ"€UwT©m§hn@ FCaæÔÃG K…}ww²c¯Æ M7}â œ _'£ÛZ7U°„ÁbɱrÁ†œè»ÞY5ˆ2 Õ øÆÈœM!HÆ2¥ê#–0؉„?b cJ¥,L°ŒÁªOÖ&œ6a?3Ä J'ƒÅ¢ÌPYñã&a°•/ˆ%,âH.¬M +ïËZ*&Î2  £[DsèЛ2Vö9³eJbÁÚ”tߥ}^*ˆ)%®(%I ’1ºUÿF,a°ØQÐ’wÌ 7Ë”œe,‹.%:b ƒ­¤Ž@,a°8YÍ™% vVбù¸¦ >ª–~Þ4ƒI*r˜‘sErÔ’±(BNÁÚÐU„‚Ð~âl ç¢SÍ¥ • "„Á¢îRh¹ËXR—yÁý¬iR&.-°“ŒEN p=Ó „Á"´aY‚%,S’œ‘XÂ`õ,J,a,ŒúõžË‚áÒ‚5aÓÙ¤ó3.Adœº¤ÎÄ„pÖ‡}:ÉX„¬ ©‡Z”Õaù — bŸB N2‹ØI‚% &´ï¬¡"aä5´˜ó‚SŠBÁD§Hû§Dª$’[‰qêÔ ˆqI$ ’1XlÉ1³„Á"*˜% if§gÂb ¢Á—1ر–ˆ% ÉÄ„X6¼M:?=Ä”à¡%'ƒE~ƒ KXÄ‘Ê?±„eÂÂ[°ŒÁ Ž÷Ì,<,Ô,a97Jõ>XV³“¼² begµb±Å´Ëq^CG™ëÊKÂb”*}W:f iTm C¤WÇYÆ¢(ñ=ÄEéD[Â`1N§g¢( Tѳ)*•0Ì ¼–@â ßĦs’±¨Brb ƒÕ"4±„1a¨Šòžƒ-$ K,Šû¶„Áb¹  ïÙ„Õà‘­Â+ &lâ$à@'‹*Ä»KXT!Gb ƒ¥qÔfƒU¯Gm ‹°r‚ –1XlØŒÏÙ„MåÅk1(îaòN2qÔAK¬ÆjK¬žgˆ%,âÈÑ?X›p*žØ ½xBP&,9´ìÜ´g ƒµÕ–°LIj=Ô–0XÜ{Á¹E[ÂbNºwœe,úï¶e + ›ñ¶*lªé¨p^µ ”%uÊO­ä8>íP³ª‰ (ãU´ (òK–\@HÏAí‚á€Ú‡z%ÍEOuÕë,0‘‘àApØÏ%qÁ!`. 8ÄŽ‚ÚÄ$õ„äã‡Jé<Ú‡ˆF}Á;ã©à©Š¤:÷zM Lî w™9µ!(‚Kæ\@\\@pØv¸'Î}êDà”4é[пkdt„FH@åÎ_S?2KÜk8P4©-™#(ÚMz;‚àPÐÇ}“· n>AF\@4õ"·ó¾ÜY&Tp­ÿÀû‹¨^ ”wÊôZ™àÁ©à™Ã¶AM×R@€s=ŠÞ™#qœÚ‡½CÓ$Nƒhô6®\T$Á B)8Þ£Rž9UŠÖz’R¼î£JIŒÅ§Ba8p£°æT@pØÔRKJ!“Dй€@ÍÍ9‚¢±¢àŠR´’›û$(‚ËÃÛ7‘}œ\.i­JÐÈé'Û=ƒm%§¦Ä‚h#)ì9E5Îw¹Apz“çÜ®éQ¾ Ú¿|ýGÉù¡Õë;¨Ó©°ï!6Œcp}«ˆFƒëÅW×ÍÍj9ØÞ ^o7‡åæððÛë¨;}c¤ÝI(•ήroWrÄ›¤ëۯʱ´oÜ~5xûý_þ$ ɘVé³fs«ßA™¢LýµyßÈg_ÿy…ö£å¤Æ¥u:„U µkìÞ:µº¾_¦ŽFù£Ý~¹nǽrx§ï¾kö7Í;ý¡§Èß_lW«åâÐn7ÒÃ<7@Oï¡„ÌÔÃršºÚ5ûf½<,÷Ú7ÿ³DÜmõ#„½b’¿»ß~ø(߃yβ«æA•‹uóñÖÍþá¾Y­ÚÍ;íû1Mexñ?U]Ëw¯*4N•¥ )ë-:^©ü0§Qžßá~¿ln—º H{æyŠÍn·jˆ¯3E•Ô§Ÿ×_ÏʲnTN¼¢˜'áš»å!K?M*¿(Ìg¸8PM”¢« 5š2¯÷õÇ馑?ûiim5q(³jt•–¶N8$¡>k–ظªg*°•’yŸè»Ào6ǵ®ËdXåu!Éä€ ï ±WqrÖUUÏUJ8Ûîª"Q‚ì[VV N?ÆæÉ«»Ì @E5»RÓ$ý£Íú×w”å,`}µ–'bþï~›l3w7“ý'ü°»©_qàK®|5éââüu"tu"tß®=nòjßå=ûË2ÙÅ®&j¶WRígƒÖ=«'f ›¯÷Û!àrxY5›wÇÃBæÝvõq½ÝïîÛÝéȦfÙ/R8A:YäøuÛîò¶{umRþx~àzÀLÃÞÓ¦&ß…Œ$ —ižƒS²cûõûî [dç󎄺Ÿ]ÂoÓR¨½#CèsPˆ=Éžp¶ÿ]×ÕDŹšueÔíë2þãýr$CdD‚Ue3ìI#Û[‹ÎøZ¶ú›Õ¶9H[$K³ç·Ô ŠÉ’Ãaw7²%©.üÛv½³¬ ‘Ö·e×€)cZ~hüûؘIUæð|ã°#+€Ú]ènªqɘ-9Ìy-E¨öáá˜,Ô0^ÐÚfiO×v¢v˜3‹Kò">ã$°n6 5fœÖG9­>7Ù!ã®åˆ_5Ÿj¢ùñ•<ß〤’R@úf±X>ä`¢Ú-PíöÛ‚I:@à—}ôz¹¾Y¦×ý‚²g}Xd=@ȯ·ëµ ñE?¼.އíºý·ÄP0ôÀt·Ô³§V`SZò|µ¤j¢õÊn`"Þâš±cЯ¿~ýûßë'ò`Ýø~¹Êù&ù©»ãFÍ&)ѳy‡C—V«",m7ö¾öS8åF˨|<äC?zj÷ªø¯š~£ßÎgç2ïþ5xŽO«‰nÛ+)ûv,{¨̓қ‹åÎ+t¾GLö„KŠ fdçNhç÷Äõßü€úÎ’G•2å“è+ë@ávuÐ-|·<Üomé°Q³×jÔÍé:£H’³è^ùE$TÐÉz{ÛÞµÉÙáÖ¦~ưÊÌöªÄu6‹«Ÿ’3»nwºW倘ͷg¡àËï7í)*ãöjúRSOì§,»^ÂÄ>G¾¬ ˜­÷/›ÝÑH^èTƒ¤ÖöxÈ_¤™ûT}ØXž¿öž­vûvÝÚ÷^†ÈÙînÛ¢¨š"•"za¿¼[î—ÈlHÔ}e§duÉÝHÇT¬ÆàÞ¡?eíÌ¥ïÚÎÜ*nptCtŽ$x.×1‰ï¥â—Rps°{-ßB4Ë‹Öì÷ÍGÛ7Tís}j«Ü/¥°jšJÈÁx“tÝá?77Ûã&‚ñŒ/¯ïàT%ß„J°ÑžÑÓ­tÏ.«>fi»'•?´›fo…i®|è¾mz Wêâ¿×ÕGw¹Æ0x{ØÃrÌ(ðòüË×YÕT ý §;‹Ý=¸È‰|ßÞæ Ÿ–CÂfù“lÖ@ƒº]®pý¡;ŠÚ¶Ú”ÌjµÅ‚ùB8ß”NÜí·V’¦Û¾ýƒ¢Á.Í&×êYÖGû{V~wBJÓÂ3EоPs^7YqH(_–1ô+¨šÚ‰¯fw‹×åÌ1óÛå]s\iÔD‰ÝýãÅè&ŠHKåÛ Š«;Ï(q“§Ùdÿ¬žúÓjšŽ@'i!íSç…†,~Ösã·Ùn®:zÒ×–HK7æ9+¨ºÞªi:à…‡¼ßéhàmû!ÝÙaÇf×x·=îÓúºk¼iÕ>pQë·‰ý×w&jW_*Þ]Ôˆ+@_ EpÀ;ÐŽ¾¿OõFºÆmU,Î ¤ %É@þG>–çE/Î\–¾¯É¥!ÿ÷Õî±ô´ÁEd}ho6ÞWD»§ü<^\r±yËds¼¸ÄŸMTÓt|RÖÅ%aÇF.Í*Que4$ 7ǃm|‰/©6KWp'µdE¿(ïÃn¹h›•ÊKEÝ÷;•‡$ºhò®ýe9‚*KÜÉð¨#ï¯Ø7ÛóÂÐiÒÜ“CåJ^Òæ »Ø®wíÊ ‹xŠœ/ >Û®?¥ƒjf—9xeÅiÐP!?öY~ßµMrˆfPoòS&ò<ßqqÏÂA¡{¢ÊO˜.•ùÕþïÚ…n€ÈnO¯_B¥šåì‡3\“oU³&«äøC‚7v)¥K‰ØöÂŽõËÓ³ÃâÞ´€z…_<þîwªüøñ-æçtˆðM¾Â/rºÖ¤®×7Ø›;l±¬2•ÓuîÓÖöæ\¶fmåë‰óDz³{›ß`ŒüÍfÿî¸Î/{õiýÓÉñ/u¨^pCÑÕ‹fÔ®—æËedÞ^kãXÊÇîs‰÷K<úÕ7¼Ò>{¢SyŸÚÍöÛG5× ‚G_gqIã•ëà›Ûlô®±Ïn·?m̓½ÐæSÚ¹bâu˜&*xŒà—]ý:«Ó•÷6OX²©æVÀ¿ŽÖµ T?¯“FWUÙìçËÍʦ˛ìGì~NÌz®£CzGN×2}ZçW£¨ü¦MÕ¿æøi5O±{t¢(MÌ]QÿÚ¶zIù\çΆ„ë9ŽœzœEò㇟wà7̓U‚)aTE‰Öá—Ÿ n÷ë¶š«>ðS„5¥t>Û"ÎÑ}¨{š¤*5JMÎm…¾øRòYòÓç’÷Zâ›eÿn‰‡¢UHÊ(ðR ¯J%.#"ßûß/Í¥RÈœFŠ_¨fxèäÖ¶³>W¢=ÒyÐï*N+õg=*,Wú[ÏN~WXÎû_j¥'G³¸¬îGžùå„e‡ŸyØË(~«}®ŽÿÓ“o¯šö#ÉD=·R˜Ö^¦«.eòcñÁ·éF‡âó¯ø5@ï5yÄ?à=E›#¸ûõ”œšlŸ{xØ¢•ž¢Ñµ³Ò×ÏK{Æ# èŽÈ¤)µ7r¿kß§}"ËŸO™Ÿz{œËfUS¶ÑïýžÿÓñHã·þÈ,þÐ߇ÉÏ–å÷ap#ù­~è6†=à7&òs°+ù÷·Û…f¢^í’Ui„*ÓÕTÚÞ~õ¡meÑß\¿ú¿Wÿ?½AÙendstream endobj 4331 0 obj<>/XObject<<>>>>/Annots 704 0 R>>endobj 4332 0 obj<>stream xÝ[ÛrÇ}×WàŹ@ØÝÁí)%Ó–J)%V,ºüâˆ\Rp€]òõ9§{º§‚TV*" Ø.YgÏÎ¥/ÓÓÓ³ø×ƒª7Ä¿U¯ó¿‹åƒá`ˆ'ü£â??å“Þx4ŒzË^UÀMï僗½f6˜äɸ즃&p.{Óá`¸fÌñÒHÆÃ‹£ Øg€hWªÀ¸ìÍf.@ÈPͳÐp”8`ÓÈ€Ó8`€hXÙPÞé;Nœ«³Úm]…n”n3WÕ3*ÇɈÙí˜ê)lÀ`!Y‡ xÙ«ëÑ`ÚF v4¢8Þ³Nx8 P&œ¹ fO½±“cJM5¨#0ؑ谴 ˜ÂN8¥ÂŒ 'ÇY™ðh¦ž)–Rà6®jذcÐ µØ€ÁÎê.0¦TÑ襭NiªÎ«SP¦”¹ª¡FNŠ×&ê„âæ Ø0Àeo2…Á  æ ‡œ’‹u”Ô ²T°ÏóÊ-œ¬\k‡Á›ÜIž‹AŒ7vȈ9›Š³‘ñÙTE„)HF”t$@º- {L; ;sH'#›ºMuH¬‚2¤€2dæf |vä\€:$Tî$‡4 ˆ,lÀð˜:pVý£R3Of´N(@š(§“ƒ6X ˜N)îîmuСF"E@4sæ YœŒƒÂ’°Kaæ”Æ´¨³2hšªóÉ  |PãtBFlƒVõ¶2h`f¼ ò 1X¸gÙ€Á¦â”¶*ÎDWÅPÄÉ\å£['#†8ðÈ:²ƒÅ.;ŽlÀ`— Né9`5ú0°tÃ`1Nl+ #ÃÂP@qdiÇÂ|åEá¸=&y¡ˆþ« ¨!sꯅŒ¢ˆ¿6`jžÊ )øoPÍ\…­aÚ+dÄ´®±¤0uÏt"°sÂ"««úÃÆí% éru+„Ž&Ô»sŒÈi¨j—¬€Í̹p‘­DäÂ(»„اL³A4ói*ðiGM5Èàøfi8U•‹!¥aæfL  ”V1{+¤¬¡fB‚v*¾dœ:K!#F·È€jd«ì‡M#¦¥h<°Óµ¸† «SÊÉ­ÎA@™RæòœŒƒÂ10¥Â  J*lÀ`‘P@õ… ˜ —˸°:áœë„” g.OÐɈ1¨$eMa;žRœÂŒ)IX-¬N)çÏ:%O‚D·ðKèÁɈÁb[Å … ,܆sV=[rלL4¨õ×ÌÀ   á¢pâQs<ï3@LF½ÈɈÁBo8M6`°HùfUíIN›#jã ®j/sUÅ ¶Ò°ÎÙ¯¼©À=Á8=¶Ræƒçu¢[±ZådÄ”ûU`;áq9°sJô¥ÂFL`¼)¬N8'”:CÏ Ä â•“ƒEüÅ„Õnsʨýx^ wëdî6·ä ê-lÀh‹@UVÍ £ŽâIa€>¨“yÐÜR}›á#äiÎX êÎÐB=N½óK)Þ{çÏç¯nÚÞúªw¶^mÛÕöîÛóßCwRß—îFXVì¬o½õYHÄ}ÀùåÃ:±x¼qù°÷ò×gOùhÒägóÕ¥¼3Œëüè¯ó7s>{ô$Yߨø´1­R]?¬/äD5Å^¬—K³Vùp¢*8iM8TºÒ‰i]º'»ÕÅv±^Ío( Vt=Ͷ\À/7Wó‹V$Ÿ ’oÛ×ëÝV7ƒá8¿»Y¿{χXNS×ÒÍüî®U×Aýç}" gœ V ×yǾLÝìûËÝbu-óFõz–…y¿Þmäâɲ~»â#lœ_J&Â¸Ê ™qˆ°ew,Ç0=0;ÙÓƒD÷„°öz³œ¯Ôâ ¦¦‹5nV*Òt0´å~ ¼†Û¨¹qºÈš;Šè©Ò4}ì]ëøØ¥þ¡}µ»¾Î€`úùj1™f¼Ø .-nÑÚ"Š_¶EV@Ÿuñ(·llAîÃ>YoÚŵ¸RJOfl-!ÄÙ®öÌvÁßž=yòì·oùNß™ÿ²’î÷î’O¨,`ÏV›×fÚÇ——‹Ã›:u‚¨}³XɶŽÌº²ñÓ-›hŒG>sÄ@èbJE0Š©i©‰ù´]µ›ù¶oOÎh*Yа°íÕ¯«K¼ª¢Î{D£]S%ѻϪצÕÿÂ";±^°ÃS/8 Uæágß}'ªÂ~mo]¬/Å=X#È9@œò—ý{ªÆœÎ;ûN.ùŠ;ù³Õ]»1ã£:eÛÛá¹ ç6!M"ìËc‘©HPÄaÅ—ûµºT+‡&l­Ž«EÞ;ñ¶eÂ_VÝÞS¥é,?*Šn"NƒÞóg/_ˆ=ùžlÝŽN™ŒuÉØPü‹mÙŽ{± ….±š-ÁÚí|q£Á*žAôRR½³`oßÄ÷C]Î×lúT[F^‡½KK¬ƒi¶ò‹…îÍ>>¥ÄTKé ¤¬¸MÆjͫĵÏÍXŸï¤XƒP<þÚÖó`jñꫦb{á%LÛ¿Ø´7‹åb5ß,ô ‚Ââ×!tªuGeÀòÔ»÷Äûy·ZådELß“½lEœ¾´&i(šAÒ?¤/4¥fâ ÌÒ°“­C>ŠójÞµ?µü¾g"W˜M©»1Éõí’H5‰¥4«Ÿ¨“<_¬þi¾€dÌÒŒoÊ ävÓ¢'ZÆx„ÃGÒZ3²²˜¦RÝ4õã:àäCìòýj¾\xYÕJJËõåîFKŽèú˜$ñ¦¤e†>¯JÚE±»Éè."ùŽëÔY,©ÎÙ7Nÿ%’íg™iÌPÝær)’c?Q¯¯ø®«½€új~§Ç-‚gëgìÂ/ÿ5x»™ßÞÚê@ÙøÞÏ ‡•ãºéÕP5Þ‹~ÖÜíÄ+Š*¨ ¶ßösR«‘ˆdˆÞ'¿Y¹\ÝÅÛìŬ§7ëWzÿÁ›3«¼AÂK:³ã1w ÃþØ5¾‰ Ÿþpýùq÷ŒwÛy.ÎsëÍÖ;|·[ŠØ¸o¶õü©)Ü'—j½´«ª}y¥ ìò¾Xã|ßnÔz§qú´šL°p_ÁÐ"áØ¥z¹Ýì.¶»×ñ¿‚5¨^ù80ì(ƒI×=T¡ÂÝ!.ÒO[ÒÔèávRî’i=ñU·žít¡Ô¶X½n7 ,L½uãç'*hjä¸Öÿ Έ}]F[w¦yqÿia³·i¯ÚM 9ï„¢¤V‰{3¿ÙåÇøPË,}(2Í7›ù{ M¸è8‚¦R#9ÿy0rq¿X<`ëõ›vs³ž_æê"’a»ué^£nyÅ—§ÕîÖRu?‘8$ë-KóëOxù¦¦¡§ö‘dÆè¤—lÅšŒE°Âa­}‡/wîpiB‚_,™9ù…„¼ŒûDóñoäm©+CǾ[Kì–¸ßßEõ:Â?x°ùfÕ¾]¿ú½½ØRJt᎜+êAn”tÚùžèðØ òËv¹Þ¼gó ùþ÷çÔØ-C7`W’5¹ø<{Ûâ}¾ÍyáI{¶Š¸ïÙÝ Hør9߈eù{N;“Y\“á;¸#Ô >•?¥Fò‰þ‡i¡^'}Ê¢?¾»hK±éd·àÔXæïûñ»š$ÎÎßß¶Ëù­„+”[¿š; Ôh¦('Ë‹p) '¿¾ž«s†;Ì….³¥fªM[ÕÉ_Øú¯^XÚ÷å”òå~÷Zür¡#ýÁxœ¥S‹ãËÜý†ÅdÜË ñ㟎ˆÿ F>Pí¤ƒ÷¿‰ì±ƒñsUŠõADÂÏcþ[qoõLÛÏÿg7øG²ÝÍ"ñ©ø½ûAJš×øÑGôbýV«\ôüŠ#Õ÷ÂG8Ñq£o{OG­'RÇíOº9TþËÖÇüߘ҂!r_ÌõzÛ®¥o¡)IžðmÚìtö\¿\ i3®<:®Í›­?IT§V8ku7šý3y/|´ñø…~I;9Å/ðŠ´±(.ÙU°ÞÙîn»^.þ/’ôH€ÑLMè«á‡>1þ>~£”îð)IÀ’_8”?äÇ ølz%¿‰àðc•„*>ϤéûøŒ¬‡OçwüPÞµÒð§o(r`Ùˆ?¼[,ô†ÏüãÁ)Ñõàendstream endobj 4333 0 obj<>/XObject<<>>>>/Annots 756 0 R>>endobj 4334 0 obj<>stream xÕ\Û’ÛÆ}×WàQ‰CŠ ùhË’KUVÉÑ®ËÏÉ]ÑæeÃ%W’¿>çtÏL7(*–ª‘JRª=8˜K_¦»gÌ•Åÿ-‹ºåÿfëG£áOøOÉ^ÿÄ'EÛŒ‡M±.J«âꑃ뢞ÇñEr®‹f2¬çàºO†¥çÇ Œ7žfÀ>Ä\ÊjØÆ7e2ƒ­ëað¬Ã`›zXyÖa°“ÐïÙáuQU5•rÜF&Œî© ¡›päʲÄ;m&=攬Ça°ãŠZ²¶ƒŠ°™­[ª­âpÐ=g¦@¦kp]@0ØE^$çຘ¶Ã‰ãÄ€ºÏ =[Mû¬Ã`ÛŠúËmUÎÑÔéO€é/re)ŠÏ¤Çè6”4©±sÐÝÁX‡Á¡#c íözv˜î0é±"N3Õõ"î  ‹“¸²ÃJFzŒAkºƒc;¡8Æê ·h6häʲN±ù&IÑmK+ËÕÞ´êF²ÖHCÏÉZ7ÎÁ¸ô“¥o}VOF`§â·MPW¿U@ÎAøfCñåEáDWµ×¹rj‚È•WF“I°R½élÀÈ•#®¿ÆH™}#ÀFŒ\Y¨ðLzL+Óië0Ø V¶¶ƒ7XeÖV}`¤ÖR©Ø”"§Ió”ŒÕ)¥¶ ~c¬Ãh;i)lfE½aâì© «7q%–^]8’ê cgPY–Ä•ÆU|Sz•†­[A€5Œ\Y1ôé1a@u¬ÃXòX¹­cULqŸnƒ3râ¶Æ9H½·œ5IIJ‡&IäÊQ‹wŒôÝBA$7õlÃ…d¬øP@¸¶AØ ‘+±Æ…¾IÒcª¯¥UrS¡¾‘ šY:µAØ ‘cÆ/‹ImˆÞ¬¡k9-B&¥a0ž*È G±¦¨lø&Im8qF©XÃÈ1˜£ªÊ¤¸H-á5ºˆ锽'>?Ž@:5ˆ¨Ç´jí„ʱ‚0S =¦°¢q¬Ã`ÛÐk«RÆ’O"I-À¤Lå ²I(ŒÔ†¾v«s™¤ýDNÓŽ‘ªžX'ɨs1ã TÀðc“P-i›È@a¬MõEr’ R;ÉHÆ9ˆ>që8‚4dú¨br—‰) ç æÉÈmœƒè¾áIÁb×TTSÅô­cäìí`¬åôENGj¹ÔŽ!~\©Žuh/LŽÈ!vO‹*sr¦%gšI꿊É[Œ¡€}:aœ#µíç œ"¨§2ÄÄ®2ä¼î æ)É¥2’‘µŠ‰]ÜR'ê ÅÕo¤Ç`ƒõ#zÓ¾ö“3·ƒh(©§Ê¤Ç`¡LÏX‡ÁJÝj¬¬¸*&g%g_áŒGú"'ë '$Cæ†sH†;k*C–1©Ë ²úW"Þäf’sPæÇ: –;VõA)À+ªµ³‰ ê0º³Þr¬Ã`',åë0Ò–BÆz ‹Áë1Xl×°£Î³ß-c)"Ϊ€3vûIÆ;ãÄt± ›8Òcj!ÈšzLQÇpmcU¿2tÜÄr‹¬*TGNÇ8Ñi=ṡÇ`Ǭ„Õ!}Ã-œ28,)ºL…È(P﹘(æŒdLc 'ÃŒŒu,r)¼ÁX‡ÁNEÖ̪4±PQå:ÅA4‰g)Ò¤BEgŸ •(Mb놊0Öá,±*Mj‹ÙÃYŒu˜%YËå–Yéù5½0³â̱zÒæÉAÌ(pÃnœApd­ã r6¬¯s;9Ú;s2•Ts‰òrÉ¥SIœÞ8ƒœfÕgÓ¤Ú2'ÃáëFí_€F7N,qèç#9òD;¸C|QÚÁp6’Û¤V¨±Ì9H­´XyÆ×Öðrã ‚C•€Cž4žƒà¦üß8ƒHáH©Žs\Õk' Ã×’ýR22¨e±¡OAÛT‚°‹=e¢Ä©Šƒç S ’8$Ù ¶SPµhÙ ºl*Ùj%Î 8Œ­KngÖ¡‰3H ð(#s2ÍXÏê¼r=ë ºÄ¼P¶§Pë 8ÔRØCdÎ 8ÄïÊ8.ž÷iÿùxÍAí%[ ³!BpØ ÏgÎ ¤ƒï¡JÜ×îœeߨØÝOž#–Ž¡ØëɤM /‡sWm(®çr¦<*®g¯»7«E±½)žn7ûÅfÿëß]wrì,Ý!¬£ÁM1`^foV±8¦¾ž?®Z¶7æ‹«ß^üÄÇã:>ë6syg2l«øèçCÇGOž#Ki×8@¿e¥}Ûa)Ý4±Áo»å~¹¹å3Ø¡åi9‡û°=ìä½Ñp’†Û¾ÛðQ‰¤áf‡ûýv-Ëa=ßíº»»ÅNÄfÂŒc ¿öBœÚßÓ@%’% |?Ÿ'ÐÁUþ÷Ëí¦[ñ]·DD—“á(=šmç éŸ}mI{ãe±›±{Ì)JNV \ì»åJmä¬66÷oE¸2˜ÕOèàÍr“µÈ…$côfuVBCñzrd«[±\2åN œ<ÿvµ}£žP1J«çÝ^ÖÖCÙÆgËÍ~+z†{¤g'¸ÞΫÅo"Ù§ö•5”u2ÞM†ýÕñëýb—$ÅZ…´@bìÁqhzôµgè§âÞ1†‰¯,Ø©áBp Ë÷…­{æ¹XowÄ,N®u·énkr2H¥É´§:ódm?yné¤ •0)=®tÝayIí¢¿òÂÚgi6„ äòŸ$ù´âãzwaðÕÃb÷°\¼£³J¼°Èõ?¤Ž²w|Gíåv¿|è˜Ê(aàAúEK˜„’3K‚’3*«Ùâ.‹5¾l¡Ìˆ!Li‡‰wdµ¨w7Ý,†RìRÅóËhXMb$~Ê‘ƒ¢ŠÕòÍ®Û-µ)öÏeÌb6‰óý•Ä/¥Ðöò÷³ÎÉÿÝwÔ*çTh© N.ÄéC3ësWbE9v|ê¼û—Ýbµ\/7ÙŒØb^ˆá;IÂÆÒ,Ä;òî§ÛõÝr7!–Ññùè$’ÛDP¤¾Ãráö [žÛ5 ˆùj¹‘:ºq+õ•0©–°·Nû‰sHšdÔ“[—²rŽÙ« •Ré·ÿp·Xww" .”.¬@êi44RòäÄËIzä£/6wݸ»’?m¸]q¸=ìó‹XÔ±èïxn$žú:!9ðÕYcs»¸ÿcÒS›ö/Ï6‡õb'%„’8Èlb4*®ª¤§«çÞõ…FÖäÑÕD8ÿôfüêÍï‹™NZ.N.ºR×I‚5¬Þ¼ËÊò¬’d/ÖwÛÝ·&™gð‘d²]Ï’={‹= 0—_Ä6*.³ú“M¨«[ß­$-à8ûHðøvGê9Ð7Gcõ²ÄNÄ‚Œ¼ÅшX•_:%+>.fO–Ü.6 ?Û‡ÆD:f5ƒ$+nz-Û"OùÙ{œ©Ä Ī:ŸÌ·3¸œ]ÇC2^Ô_Îɵ“:4¦ÜÚæ'/¶¸åhéK÷«Y·–K.Ü,^ð’vjȆ&|çËÎÆ¼ûì#ø–OUDÐ;UxGÆëÃfãbXÚä‹cüãR#vh$/ &VjP¾~©¡§FQB|†P¥ëæ5cº’Å5-v½—¶ÅKââÃ…œ”(¯D¬¼;¸Ž¯þ¦KõNê~2’âµÞ&ÒÙ¹¡7øy‘œý“Öo_)¯H’åýõ>ÚŸI¦ÿäw=yÇ1ŒŸ]L›@hôŒÿؼý=­ºsN:¸VL¦+îv[Ü¢®µút_[œ8~šÉQjZu>y+Þ-÷oé8·›=)ÿj‹")B¿hKûE|/s˜Oxújûn°Z<,ôó Èn7$]=‘;ìó÷*Ø]ê…‰,ƒf8º¢=©@?Úu*8 Þ'T÷½ ùÆŠÖIÎÿqj|QþÚxÁó@«Å`ñ£XÎ3EqïÄmõ\ä_I.|šåmˆ›qñ7ûZ†‚ɲs1 ‡ã)²¹ÏB–ú¡[žV‰áûÙóûohE8§ú,…ï E¾T^|¿Ûu¾-SªXG¦ŒwTò£Ô ÅéÍo:T\÷µÜö†:ÁO@Ò§<Å›ía3×¥‹½FNÕi ¿ 8ÇÒÍVEèô®/´œüLP«Å{qpdë}N$¡ÃƉ‹«ƒSââ‡ç¨>?-®¸±÷dùÑé"uÅÖV®t d¥\HÌ ­dÖÁ´¥ðóH1¢‹Rn‡ïÊËx‹'/;+ÞèÑ+¾Lg…|øæ_9lfiûŒOò2Øw¤Ðggk7«m'‡H¨Mò›ÿä¨öÎ /CŠç;øIHý·×¸IsU{œ·ú5êÓ¿5xºêîïã±.¾ì=‡“¶û%1ñ»‰~v†i\äêúg>ñåãîÍÔp%Š;6 “',…²duwþÌ9~dø·Ûðs´ZYöþ.æX²v\@ø”­E-PX ˆ}¹Ò±ÒçÌæÿùNhÅsü¿8–ô8ô}ÉÎÚâ·ƒgß\G9å}ûG¾®çøu=>Då‡úø=AÀ‡ëø&’G"þ(éÇ㣿¿ª¨c6?~¿| ¹Ÿ]?ú÷£ÿ]G_˜endstream endobj 4335 0 obj<>/XObject<<>>>>/Annots 809 0 R>>endobj 4336 0 obj<>stream xÝ\ÛrÇ}×WìKªäraï‹ÇX·rUTV,ºüâXŠp,‚ºü½OwÏôœ… ÄtÉ$œ8–yöì\zz¦çLÏRÿy”g3ü“ge#ÿ_nͦ3<‘?rùãÇ—ò$kêvZgÛ,O`“½yDp›•ói^Žà6«»iIÁmÖͧqm!íUuh¯Â Yƒ £7eëï*Kl;›æT¶®äå²ÔŠÛ¹)IójÚ…7µZÂ`«VlÑz´¨ö·È¹¿Š´èLûÙj&EKÏ‹k1›sÅŠ¨âÈÖ³é0aRYÂâI˜$ÖÌaQ™»n´j£¨„*DA'M’F£PŽèpb ƒ­ ™áÎZ£AtZ+®9 ¢ æßIÆ`[9šK,RA#–0ÆÁf´×Ìl=n—1X=^§vÕVÉú³/¹ÀØ sŠ Ø)^I\‚à0;âoÊñÂËiœ ÚY×¹Ëê„ ¦ý”M­„Ð6Ö&QÁaƒ¦bÁ¡¶’Ê%ˆ.ª öæt¬‚ÒVW»ÎNâØ„¤ŸOÿÁUšìt.ApÕ\.At;r¦±App$ #§ ª^»åÊ;!4†ÁG6NÎcº WˆC— 8$o‰S§½®nJŠ\3áØ–Ã3Î`¢„ê°õàl*¯i7 "GûÀ©]A‹«%®Ä’¾Ë)Ð)-ÄÝ•¶ Œøœ"(½óŸsß]P& b–íßeO^ @Ëk—ºrë¹q4€ð›]¬4k?Ë.–/o7}6\fO‡Ý¡ßn¾¹ø•ªÓľV'aC*›HÚ&0«ÅEÀÅêq1—RàñÆêqöæçï_Ê„̶ Ï»•¾ÓM›"<úa¹Ønäá“„Z9vŽ5ç…Õ:-¦ÐïòJY`ÈCí‹íõ¦?~Øßܬ‡>•{ tczÿ«5`‚cðȰZúZD£ž­÷ýò0ìÕ€zÚÅ1zºYÜÜôêÈî¦;+Ó|€‘$“ŽOôlÂÞ«§¹Z”¼÷%C¿ßöÃêvy^D:6? k£m–eW÷Ãû~¿_¯Ö»wB P²WýájX™%ÀÙT^ë„E-â{¾& h»êa¼íkô[\Yü%wþt³x§kwBÕ<˜ûücZºèá±Ï¢{þÁÍÔÈ<6ó8æ<Ý÷‹Cp+ö—yðL¶âe+g+óëðöW¬æ¸j«ðøžíóæª¦¯Mò†êº¥àzñéºß.®µëy´èÒBRyþ(Ú~ówìÕÁ¡‘X‰Ó;RÃíÁ¸nÚs‹ý;ÐR'¶û*ìnÌù!@Ñåã<ÕÁ^¦n‹³U ã];بèÜÇ=ç?Ò•¯[&&ê`¼mBÆjoL [•çn›[EplYwÊ2š5h[ˆì8Ôðøë:á.µUºe"iܱY:]<ÿ¸ì¯e+´…(/«Awië>ß v=y‘T¢æ´&…¨ÍÇåL\vw}xX¼B/?óvÕè$MÂvÕSY¤çw›¨¯÷ýf½]ïûµ©=}ÿ¬},¦NÚ"ÆV˜§ÂˆÌûñv·£í3.O?(@¿£¥8Aµ –š+}å>¶[œu&›õN§.>ÞˆÖiEkæ|¼[5z€Ãe>2MÝȦ]¯a—‰ÛzZD]·ÕͪèÓn±]/5LÓã-ô½Üʯ±±Ý‘ͱX=ª"×Íþé&˜ I^F“? ·zVø‹G\²/Ÿ¶AÖܱSæënpÁKU¥¥úqîñz–⺦ 'k¤ ,ž'Ûß.nÌáH»Îâ„úäé·ßÊ›HÄû°_\_ÇP€ÄjxþgÚý{êö±Ñ•™–wy´¼_éÖ]ç€óYÓªÕ½w¢÷ll×xm¿¸ÝéÑÛô†ä2Ï':ôŸÛEB ‹·œŽïËÍðv¡I&IFÅ9ý۬佢Ïp±ªÑÑHä”Y<à»$]U¾Î ‹»Ã…Î<1éFA¸ßÝnÕlÌãz>9Àð°jUa:¶wœ,{=¬‘«Ü›÷(Ir§á‰†Õ¼½"]0òâ›Ãé¯Û½ÍJÑ<Žžpc ¬È|Gg/SªÙñú“a|ªVã r,šp%>2ý„5ëÝU¿_cV/UFaŽÃq§‘¿‡—«Ö¼Ÿ-R=¸Œ8aã€táfX¬zMÃÄy”—Žq»„øYÄãh«Ýòv¢ò¿{ÝïÈpÛªÅ=ß-&Z‰,›˜ëNZÆ[MÍë4FR¬ ‡þ#.QâM>bwqøa}¸Ò—)Ùû7}[1Uö >®ZKâçzW;2Ü’ønxu{=îd‡°¡ž±s«Ör¡Ð# 5J%×~ná›íb¯II>Œ7¢is1×c>‰–)wb?ÍK!ÜÞg!mkB) ý_/›xäCú8Æà쇥çf0É£®ºÜ[äÐ 1E~"î-‡UÿË7ú"ª¼Ïƒ ÈüÈÿÂ}<.®ï·5ç¯/ªVwšÉ(/ƒ‹åöãª}Õo‡ý'u;ÉAä*pQ³Åů0ø¬dvNs8Z6ÎKÀ4ËÛGÓÞ\üS'…Ö›ÛëëÁ¬|˜òÀ¡ÕW䉪Ör/úEÇ(&Y?ùjqد?ªt’ î¸pã=â‰vîQ°“Ãu‰Ï,5l™Ðh¥gacCQþÒ§¯!œìL€ë˜ó§Ç¼êTHPr¸j}7Ê?K Ë¥òûuÿA—®|Qó *á´I_xZuv «Ù>Ýj)áôN}Gó’ND¬9ʽì~sœrÁ‡+=Öà>Õ“ûõ»+S¸0é²+ìCý>¬úx’]®CîB¾¡>ƒ *úÙ¾êŒALÆBŽÃöÿ*ƒü?ºÍ“íæ( õÝíz? ‘/È£ºú#yóxÚ?užxµøw/ÿê|Á—jñðñ…ÕùõWú_„%Y%àªÊ½ÿ{‡¹¬ƒ'“cŽ*CŒç* ±ËËÏSѲ7È‚ÁڈDz¯géjŠÃ‚¯ü)¾#èzŽžÐõòœg’7GÕé¹b¢ÑsgºpG†0'Û{P¾$®÷ò²–¡”ßjˆ'‹¨Hº.GÁ‰ø­Ê©¥N!˜Pþ÷°VÎýI¡ßàóPe¾FFÐÚ‰nšjòvm;ÝDɹ/Û!ãðЇЪ iýú7Y®3ƒ¶ý/EZ¾¾öŸÇ¬Šê\$ÊâôÏnwq{ÄØÅ$ÌÏëÝjøàšøÁÄÕY²Á~u’†âH"ü¯Ûñ.»O°ŸõïûÍ€ôš„ùh+F–7‡ÛÕzÐ`ƒßì¼ÿÏbÝ~J¤AÛ‰‚“ño@T{ø>ÑV|LüC ŸÓYu:usËt¿Š¿_B÷¢ôÍçEP~äÔÍða²'ªqŠY¯9.–GŠð<¾ˆÇ| h86å4É1uæÅÉø×»aì,{¦¿÷Ìv©ÖqUó¿a4#õ·ÒúÁ?~ç å%þfäèðËø•QÜæÈç\rHŸÈ_eólXÞJîÈ·òR~J¾ào¥ìêñÇ÷2ž_<úףߖ*Ûendstream endobj 4337 0 obj<>/XObject<<>>>>/Annots 863 0 R>>endobj 4338 0 obj<>stream xÕ[Ù²Û¸}÷WðÑ™‰d‚;½Çߨw’gZâõÕŒ¶P’—¿Ïén Ñ”e—§*eÑã)—±4Ðh4Èÿ>pIŠ?.É+ú±yÎSüB9úëÍKú%©Êz^&›ÄE°NÞ>0p“äí¼ögà&)›yn87I“Ï+ËÔ^Qr{u«€ê4}ÉÒyëŸ$²ä‚yn 2ˆ=ç\A½QR fÎd zÎeÙÜ%•’R0mMA± çÚv^$•r’‡Mè·Ýò´–ÉgRž•$lCÆU÷ÝâÏî½>™VÓ˜@޲ÞVŽÖc9̲«^m÷§# TzEר´ _0uw:†›y04ÙwC·éÃöÁÔ´ÓÚkZ3¤ŠÍªåˆlÆàù§E¿§•Hã€k£4Dæ{ ÄÚG!(â±'š‹–§vÖÖÆRËÆÒ7ý¦Ûï½EU˜ñewì(ðÊvkôÇÕñžÝ¿5Þ=èAÔž½ºê(ZžÑ2Öö9Çl WÉ ÈÊ !«Í~ݳmˆ½aCò¶ÑϘqÝ”úO]xìÊ?}]G(Zˆ’XŠqºžs˜SÃU,Û%~>‡ÓZ·q`‹VÔ"‹µ—µZx+I“VßýÐ +:£°£b63¿óÆÚ¯ÿ¯`Ÿãôž5q,ó?ôw§uðV¿Ñ$c 3Û•uÒׯ³hEÓ‰ÝxnM|úÊD>—Õ'ÇéÉðk­]ó÷2}Ì™”8È ñÜ…§QèÂcˆÄ”Öð[/=fÏÅÅÛ C÷™ëÃf¥ºyG¿Ð}_ˆÓÝY]‹ûnàgCàÿå_ªõ¥~ðà…ñr£DÔ-]àozœy{¦Ä@ˆàºõI72ûõuúÿ]Ã…·PÈœÙN1cbeð‰L}ÂØ í<ånØmx\ܦºáýiR1®lý4W/ÿÏ£)å4Zóóqd{¼Xô‡C°šÞbô+á’“B^€,‡8ÇŽ/OoúÍ»A¼Ú]¦rÆ äôØêq‚ãþìmÆM»º4-w2 —æªÍ†þ®ú-F‰èÓ2,pd~dÑIþ”2‚foóCÈB^áŒR¦ìçHÿ{Â87âSY<µ¸Â S;RáHÌ^ѧ¿µDÔʳ=Žw>³ÇÝ »O¼«hã84UÏÌ/S^É³Òæ‚àz4ºo†~½Ú¬¶ÐbâÀxš—ìYeÓ€Á¤ÚÊM¤¾G&ir’=kÈò™j³óÄri¦?8……h…wd¯°&χ;.7šQ¸ànbdûëwô IÃ_ÜœûÕžžÅ¾sí|ݹuŒËTމíxnÇ»Ñ?ûÃQRu6M)Vsü¥Ëå ž#Äâ2•#!^·›D÷h/† 6‰cÔTƒP°oýŒmo&¯¶÷ý°ÂÏ‚ÏøH¼zátÑ7&ðc™ÊI—ßæ´ pœ[Grru÷9È¥2ªýã=Š{LU{Ýj™ igäëîwKñå)¤2‚Ýô®˜PIÊâ%Œ x/—A1Å;üH©»ŽeîUÃÓ—”Ôb·”„Þ»šR£LY$SVON«µ®d‘þüØO·O”£AC,§‡> ø×Ïj–NÎÉôYS dùX€ýŽ‹8÷ë1ỦújçÂ/½|ŽóæâhÍ•sBOºÃjÁ«ÙÄö æò‹wlxt_1a¥l ³¹_ÛzzøéÞÚvŽÿdרƒ_®wïd˲ ­Ö8vL3§U:6f†Û‘ SÈÂñAa,')’M÷ÔNjߧѿoCv¯ý}¾—"üBÀ„- VÕ㈠ÄEÕ’ÍQyá&øÍ85©Ìk°ß(Œ\s|4Ðó;‹`{á{ÁÜo¿ËB/ìLàô.$cðZþØtQ ø6*ÌuÜ=ñb—Á³íN ØBîñÒ®u…ßJçï¶ÏMã8dLãí‚Þóo¥àÕÕ`Ê¥—žá°ož¦°®¦‚‰xÃèlú8*ßâ¦Þ˳Pãü7­i+ñÎ7”kß–NR0òQŽÝ< V¸óÑMÿŠç›MûWðUjRÍ4™QÚIÆ'ù îfèÞoºÃßy(ð A8³`,†ã‰³kÈ?©ä½®ÞÞŸŽËÝG}•%¤&ÃÑ7‡LÀœ0Vä²[›3ÜÓawàxŒ÷¦ƒîIÖÝöý oXñxàJÄ_öìwëϛݰ¿_ø ¬Âáe"/Ïñìû÷2F›¾(%+TÙ>ßâLòæ¶g¹`õñ ïš„Éþ1³õ­”NrU&• ýw¦qŸyKxò€ ×¶gwÓÔ¸´ˆ¿xó„ld¿ÕY'¾ÍáúÂÒÜÅÔ¹¹ Xú=(¼~†×T®xl+g¢fãK[²{¬‚¿úÊÜi;ìÖÆ¯§÷Î\™ñüµCü‹?T oèCº9§ð-Md*’pô]ÂŒ>Óz¶[ð ;ö`y_0OiÆÙj*»|øéÊþùíƒ=ø~ÐDendstream endobj 4339 0 obj<>/XObject<<>>>>/Annots 916 0 R>>endobj 4340 0 obj<>stream xÝ\ÛrÇ}×WlÞ”ra/³X Ù&ËMXgŸ^8q“•‹é\¿H˜7Yh¦¥Ãœ¸ÉšÙ´ñXEãUÇ›/’@}:s)fÓJ¿É“q2ÐrNCr?Œ:(f€Éêd M>-xJeé¦Ä‚MI±¼(©a¥a‘»†,XCÅrX ³M ™9,œÍE`E<ÆF6̉jsÃØæ±Or®PŸeMã5bó@zŠ@˜a™ÍÓd™0w–!)±<Ó…~“µp2º­¬“ÅÚÙ-°`Ý*–çô½Œn‹ËáP'Ó óiíQ'×pK×ÖÉ@õh\^èP-l¡E° +–ÏœÖ@/§ ówÙJ2áØ–ÔÚʪÁ¯)2e™X` ò"*6oÈ s"†œ5ÓÜ^ZÕä(©©èY¸à ,˜žŠå9(Ò0÷ŽÂ‚5TŒ¢Ž’@i8ó®À‚5TŒ&Ž©&Ðˤ¥C¹Ûªq &Bê6b2½Œna™EæP'mæ‡:y“Èžs‡Ê”沜œé*lJŠåeÇ5ÐˤébŒ:è‚|ÁÚÊ µ[ЊT±|VÁ€z™­hÐÔ”rTUÉ¢ñ&!õêDÝ3 ãüÛqÂ2̉›l‘#Š ãH¨ YMŽh<'¢EŸaÒ.wT±`퓼ç@JPb™BOÖŠ3›b’÷䛬=ç½ØRòž¡¼åÂE‰©ÛˆIÚ0ÐËX Øû9÷êÐlKlji¶"X·Šå3Ú¿ ô2-2¥S‡:( =B t1CšqmŒP(È£ ;Ô.:KlЉèe²C ASSéV© ¯ZÉ‚u›hù‰jÞˆrVv¨“É”‡ •A=Ÿ)í9(–—´@zÝVâÏ¡NZØ­êd˜wFn¨LÉó™2Q™Râ3ôæ…ÉdÞ†¬”šz™¦TÑ” u2M)•*SòL©LdH¦™o,ÊF#2YiNSJM½ A u2åc"›†zhX:©-§Žt(m¾"p¼QG¬æ°à/æDPßœúL˜‘ª škœEE<èe2B hJM½ 4oáP¶|¡\“M-B Šˆ‰¥ ”†J¥! ÖP1Ù2‹JCO ¬¡b²…èeR“¶tC¥[O‹1i ™bèe ¼…;ÔÉ@kâ5†Ê JÐÄ,˜.Šå9…N‘@iˆ¾SN.X°†ŠåÈyf 4ô¬H,K& ØbP0̉d:(zzV$&*&½$̉èûFL tê©[‘Ø™t©bºAJ üGú“§E™L^Àaêd ˆa jmL1MgDC½ &Æš¤¶<á\IaC›¦4''bP¡Ê^ˆXS/Ó„s¬§¡2¨R;%Ñ>'¦A¨ƒFRVàÔBEó•n•¼I?‰91u›@íV[æègŽ% ¦cÝ2§Búb±`&RL»I —1(RTÉ”Áw«„QºeÁºMd’-Ÿ@í6¢%ÕrCŒA»°|BÅDÊePlPÅtz™t©¨[C §-hj¨“áHÒ¾-ï*¹'¤"°éiW‰’)\,‘U'bH¤tš@/[©=êdR&§éZ['“2”‹êd ‹“qLÁFámmÅúžBËwàì "ºÅÇÐ5^ ŽM(w‹Ò*ÿMöãNÉs"œ r"õHì9aPqF5uH D  ®žÆÍK Y¢¡Ò,bàq3]6%2Ÿµ3&˜;ÌDòªÆ·s"-tê“Íåñ˜GÆ«ÕÌ”õ6á¾R3îP-[œÿNöW„ÎSM– '¢CL™ îè1Í©r`}šH¡Š^„¼‰“p†2ÊÔMݧÁX Aܪ„¡Ä|“=’HÓ vÂØÊ]eÓ‹»œIÒaÝÊu¨"°@§˜„½¾r5Zœ³gÙîsöêÝ#r¯nà5Í4”ð) PÔUvµâzî,»Z¾¼j¯×]6Üdo†í¡Ûö½úÍuÇ%_7Ù$ö6iš£D|µzYÔ 8¾±z™}úõï餸y©ŸµÛ§™Ö…~ôñ§ôÑ«wËÜ5QÀ…ô9…5¹›  ~þÒín»–;¢,4?點.*ýh9¬:n‹¯5úÙõzhúaCenÌuzöÿ…bFs‚ÖÄ#½òõHù«û»nÓÞñúTªæÙ'ÿ¿&Šœ•ª#æ#>ôûe·^·Ûn8²Zaq)‹ò@/UèÕ; øÕ¤ `zY–¤×7»ÿ;»(™µzøƒa/÷ƒPpÌûà-ÒZc#b‹õ””ðq×­ûM¿mw}'kMûæ…„à“VVE'¡òꉂETï—ãvÛo?“ÒØIñã”Qõ½Tm£~…*–oÊ«›ô{ßQ?b'²¨‡[q`ð‡˜ÓwýçÛ˜cK çŒrv·ãع­oúµ¸BŽòØ$´h9ÄDL¶àðN¶ø÷^-„T¼Ž¢ ŽqËÛ «ãš-¢;×]èI_û¾`(X1hê#—žÙ¾,òëvß/yíÜ2¿yõæ‡tAã*hïx\ž¾lݨ4Îܶۢ wÐxí8S! /5v¿D½¸ÀeÎ[œò»ãvyè‡-kuñš%½<;¢õåûõpÝ®Õ#S6ú‚í†øm\Ç Â§²bbÆEßZåèX¼´ÏDríp·=nº]{è„-»¼{‘dƒàiBUŸsë7ÉÃéâŽy?ë½;.ÃŽ'ŽZ­ü={Dõ»ýÁ}»ÂÄùÝ<é îîÃsLò?ÚƒfÛ0-âÁåC·¹îDu\°DïvÁªŠž#WeâȼÔßÌ‘ï·Ã–‚7Ü‘9\†¶6 <ƒ y;‚Œƒ¿m9(Œì6Z:Ý~黯¬-Ý"=v,V»ñ$Ì“o£ö|¢ßs>¨zºPï„1<ë#€è玤/àÓ´wÕïÇC¿– Ô‹)«<ÏPpõaÒŒ±$/MJþ¤Û *Œ¹nÙrØÜõke¶U9E ¥¦nË]ÝoÛdo:ÆR”;ÐÕÓ™¢: Mw"וq¢esŒÇw ¨ÿ{<õ\ðD‹Š+:·ó,i9fÿ?g¸R«‡³±[iÅvaP ÙKÌùÓpCÖÂ¥h:¶Æ“œ5Ï÷騀wgŽóPJ}‘.RýžŠ™‘:)žEñ» Tñ°z3ðqîÅb8×Õäº?psw°¿[·|yîšMë³2f¸·ÔÚÁ™O5çøNš¿>öë•ÇÓz4F…59êíxþÇm,ÝÀz±àþk¿] _%éãbéû•m£öxæ˜çpǤþN‹ˆ»‡X”:hq…¦¸AáÆãÔï¯S¡9>zþc…ޝ;WéÀ­Õ÷SÿÁ¦æ?R†žÈ+1ËðZŒMžñüJ¥G¥ \”çWÚˆzùÓ/é5æ$ϼ´¡JŽêm¤ä˜v|kiƒsOçúgÞˆ|Ò߸f¥¼2‘Ÿø CëV=ÓŸžÎþ 9”zò´ uÞ/c¶üÄu—ãNêKÏ¢¼XÊ©€ñùå:áZívœh¹n÷{-¤ázý²ë¡TRìYb9S†Gˆ_¿½ív=jŽK¾ÇÀs¾¸3>á*g¢†ò +ž6¿w#¿Åc¿XÎvÝM·ë çž!Ò4–ß¾´ë£~Œ×cq¥«<¶»]{/© /4Îà¡Òã?Oòþœ3PÆ'¬õ€ú^H¬´bŒl¼Èºñ—x …g:Åz× •žø‚f¤+OêzGµq-'£¦Õ÷‡Š«0“QiŒŽ?}JC”"ºý] &OG ü"U s Ž£äOŸRïÐmèd&Ú]öІ§ Èôç) ?mÚ݃ÓhL_œ½ð«3FOC$TÂÔ²ŸœéÏSú¦̺áML<ª/‡#¨_cá¥b:®׿uKy®FïÌΚ‘B¥¬GNóc¶…;–¾;îðb‚ëxꃫîÐjµðT¾öÀ«ÔH®ymñøaž™ Y/Ó(L7oؼx–†Ý ô8j|æÑÛÛ¦wÃ÷¬‚+E8Æ…}8¿0æïc!ªy² £É:Å¥ÍaÒËý¸t¬WÐS?NÛøÝÆ¥¾£€º¡’#²súx1‚ »¨ç?ñò‹.6ã³lFg W¿TöwTOCÇêÈ^kêü¬ä#©™¢òÊl(‹Š—ŽÞ§F9™ÐWÁ›b©ñ¸ç0Ä£éTuEtoþÂÞŸPœ£¢*½ ÎqR¹,®¢‡GæèŠ£Ý¶Ÿ» žÓ—Q^Žw$fݳþ…_ÈÓÄp*÷çünd¤ÛãÙTïÁ"›ŒösbÒk{·Ê._Ñ=ξW‡ „¿»ôEsÞ»Ü>õf7ìcúIoðL÷ó‹Lߊž|7¬ïáw·ý~CP ùEœØß’Æx§k1£ÙhÝßnñF(–Êݼêw`ñ€T|ްü³¸ Ó?û·ñ‹}üî ‰éÿéyýÿÖ@‚‚Ëô.uB¿bùqXâ™ÐV’3/-~Ï2Ã6<™SÛÕË?¾ô=}þöêÅ¿^ü×POäendstream endobj 4341 0 obj<>/XObject<<>>>>/Annots 968 0 R>>endobj 4342 0 obj<>stream xÕ[ÛŽG}÷W4 p’¹oÕÝzZØc;#ÞxŒ¼ä¥Gê™QV·èâØûõ{HVY%±±ë‘²Y$sút±‹Eɺè·GE–ãŸ"«úÿdñ(åxBÿ*è_?}GO²Æµ#—-²BÁ<{ûÈÀEVG­‘8™ëF•á \dãbT[®¦ïÕŽ¿×Ž# ™¢/E=êü›ÜƒÁBBaXÇb«Êˆe b=W”ŽúI‹IlIš(k0Øfœ²/²²hF¥i+]* Ó%Ú%ÏeIºDÒbúhAb#+bó±Ë@Åz®(sÒ4’ClÕ’.Ê &„µ•5lÇ]Š,wÉŇ؈b—W”tQRvÆmè¹îVÁÍèM"«ŽãZ1·£ÿ Î@x_$Î@R²€‡iC‹IIý‹%s0MQ’q¢aÞÆþM"-‹®×–5lÛÀä+úÑÚÛ1Ðz®(¨cJZ ±2б©Å`;ši¦­ÁpëœÜZYoÑq` ]ò\‘óØGÒb|´æñTÖ`°MMöVÖ`ê.²Ò%Llíí’çdf¹HZL£45™a  #c”´­ÁèRI6RV´°Ê€Êþê9¸&¤FÎ@8oŽI¨œèŽù åáÄÀè0Ð1ð\‘—¤e$-†Ø‚Ç@YƒÁÖmÚÖ`°cíCìRÝ绸‘¤Ë”´˜>Zã£Ê²µëÖ8 ë¹¢ìà¹JZ ±pŸÊ²ƒmZLwm+mŒ‹Õ ô£ž+r‡Ù¯¤Å¤K…Ù¯,±æˆ…,J~!€‡O!\¡…+ŽFº®µhw<'“NI‹Ñ‚Òa &–‚®eÓ‘w*+#ÄÓÀÇÇšvÉsÞº‘´b‹¬ˆ-¬µ¨XÏùÞFÒbÛ’Y"+ba«8]j*Ös½áD‘´b‘—`e ÛåôÑȲµ+ä ú([[}Ô@ÎZ .z‘8ü }ÒaÜ•dM*d䨉€¨IàŠ²Á;JZ,TY0Ø–JÓÖ`Ò“ÜȰKncYÅËi•µ˜Â*饬(‹²K•e Êz®()§U‘´]ª(Ö`° EHÃ,ê$,Ô ˜Ô¡©m-‹éub¯,Û¥mEY_šs‰Q1Pe=G1¦Î”´®)Ö`°Ž½" ¶˜”-áÁ¦­Ád ’ÊJ‡mm_1Ð{®À<Ä(EÒbêpGê(k0Ø–-«¬Á`ÇÜae F‡ñ]¸qd-&ëPTUVÔñëÿ¸00u"i1X”•²“:# k0XDtXÛŒÃÙÐáÈJ‡ýªBz— R‡iiPEÒb°ÈêèRd%lqµÏK=x°–þ9´çŠœÅFÒbˆ…LºÈroK¿j@É™gÈ[ ¤Þ’·(i1X¸neXë× "'. DCLÓ.¬)Òп¦ ¤ä<¢YŒ¦ˆÈ­e &/+Vû•ƒ—GÁÊŠ`ßÖ Ž¬+é±ÖøGÁÊŠ`ßÖ Ž¬æúMEP¬¶-Ž‚•Á¾­Yªq¬µÁQ°²"Ø·-1‡a­ÈŠÕ}M-fŽ5µ‹pgŠ$;7-(8'“7 £cÑà"ã,¦œŠr®«fJy/ …Ž¥(g Šš.ʈ"aa ‡¿ÀBiú¾îe}g õ”¹’ƒmø›,GÅúÊVäĪ×@4„Ë7hæ’Å`QÓᣑec¾ê9 ´·ž“- y“H‹!¶¦RѰƒå@ª,mm‘È$¼±%€ÅZŽ7¶”3Ðïs)Çû\Afӑޱn@äb ´OaKê9ÖN Jå†F.rÒŽKF_#R6·í<‡€>†"3}}‰Ü$@Òö5”´lUÇwih¸;˜yQ þ›VÂ3Æ´×"ý4$–È5Ê)‡UJc8…àæ*å¸#¾ÊåOóß±#žAÕf‘Qq…C)çkEk2E˜‚¼WH>CRD=oл؈ÅùjŒÄzJL]a”"£âò½‹‹ã*Åû@¬XXœgh ãàϯÌî.<:Ï6·ÙÓWpJW7ˆg•ËøJÙÔÙÕ”w‚óìjò䪿žÙê&»\-wÃr·ýúêW#Ž7‹Yü n²‹ íÛŒ-6—¯¦OªšZÇÓ'ÙÛŸ¿ÿŽ`N´•Ö/§üN7jJÿèÍÇÝÝjIOŸ¾ªƒtlÿ8|£±#ØŽ%9ßæÅl3Lv« =Äz¨ ²&ó~»¸óXü¼>:·ÿ9WQÏ/ºq¢#?,ƒŽ?þ¾6Û»Ùš^%wóÚda ›Ñ¸ö㱺þãÁCdžN‡ín³Ÿìf2¼T÷û§ 4MìÔ¶ì6Qï—&Ã:ö¹åa@öËÍj>Ÿ-oÙêX#xâÊÿ¦s¬ÊÅÔTEǶ šüø~ØÜ =Oļªõf›NC-1,¢n‡dÙ~N〓Ï@h†®òQrNŒLùÉÕÆ‰^jä4¥^RyÀFF•‚îðÏ6äH(Üý÷ÙîŽ_ÎGe½_ñÛ¸Q¤•¾î¸7ËìscêâÕ£©æŸ˜TïsbN¥ŠøÂèn33ê+?„¦­|È5¹è<¶!ŒC² aW3I1(O£õŽä×Ý0¹[Î~ÛKàÂ`{®E#”ÇÁ0kÎË­Ž±©É~Œ÷ýr½—úq8Äç#º¯ö»ðb7Ê}ÀÎÖý¦_ ;Ôž$Ë‹ê²YP'.&oµë‚·³ÅzÎõ’TëÕ ‹Ñ©©8“ÔtoÚ¸†ÃUº,Àâ-1î»åõj¿œR<"ý»]ÒkÀ!®=ÛlúíN6U喝ÆWÊ|oÁºr·Þî6>Q¡ª?Za…„ŸÍ£–ykœ¶#CÙHe â“g”O<×HÁÏGÍjB8[â°?ßùÅ rnðÕû¥qÖžš˜¥ëNÆäŸôòKŸ“?½s_úÍ üáR§Å‰öÇk'¯v-Ï¥XNÍ5RLbçÙ–¸ë—hè×sl)äÚ~Þ÷›m*±ŽT+ )ŸrÕ€õzZ7bo!QñÝv¸ÙsULýÁ‰›ö•]ðÔàŠ*ÚS ¨,ŠkO. C{¾üÐSn—-â¢ðšüÕ7]Ã!öâ L‚é«b«û0;Ÿ_pèÒËqÃÎg[.ªp5®ˆw+’ˆã-1é d“»žW¸KÓ†Rì›o¸ù܉|Ã5~Ù€ŸÄ¢×ËkÔa„°ÑÖF‡ñúøß–D1&ÃfŠÎÅ~¾›…Ò ß ‹Ì~s»_„ýh,I¿tªw­¬-ʃí\YI|çÝVË’PgQ=Ö}/Ù Ø+á=o”5q_ïPÙ°EþWþþÿæÃ mÇañu¿^ûa¨ÌNÐq_ØíCô •ÃfÊ1_Ø.ú¹[³JﵚÅ»‡Î%®•…N\M!‡ƒ¡Ä)þ`<¶–—ˉØÐÎ}ß/køDë–+› º&ÆŒt÷¬¶hd0‰¢¥“š—÷Ïh×ÌÎ\§ž£$ c?­j Ž 8=IâÅj‚Ó• =‹ye7BqKá\W›ÐÚµ² ;H”ÈgìîU8É{½šîý²Úì(LíàŠæÆ‰Ò™5`úwÐð°Â£”ÍTüÊï_ÿòäq¿ß­ Ûã_¾¦7B*Jåž …ÆMâœ#\ë`}´Š9¢Ñ?D¡x ˜=ν–øíJ{RGu­?=B&IçTS}¦jÅßB5Ž6|?J6^?ÉjåßB5Ž-Ÿ«Zu>ªù£”cɾú¹ªÅxéUÄu»ò¡çœk½VI!ƒh(~x$öú¬¢|TGè&WË:OsõñŠôM?ùwë7(P¿>´->/‡U“C‚#£©JŽkÊÆÕðùv¿^¯6¼˜=£“ÚãÃáZÙ¢Á5¹$-„|<6l»p4 Ë~¹\íâ5ýüæÄeô¡šAAùÅžqâö‚†Ï÷77þ4ÎêÏéø`㦟ș]W;» q_)Q0 :Ï®QP÷r †qY|Ýoå ŒÙ]´½ð㱓m¤Z“°kyûéé+½+‡»¨ð^ܾ¢[rœ<>÷–ÜO䨸¥ÉYizLû£Ï\ÇË'sÁ¯Ò³[,I9³ù|»¥G§?_?ªÍŸ>ôª^àfˆ,ѨxtÉ9á9³—*Osöþ§ªG2ŒÁX³2Ž‘ŒüW8W‹õ,Ü>À‘âfÁ[a2çqy8ìŽÎÍÌoGøÁõÙÍ ×±W#ÞÙívDèƒaønÀ5O¹rCw¯ÃöÂz5ŸM>ò$ÀÐvÑÔúGP¸µF—X§¥Çýòv¢‹ÃáHØÈË&´¿¤ÛG<ññƒ™žc*5Ó "7âºÚLðp ?‰ 6M“Ö—ÞÊVËükØÃë6/—اßp¡%ùð~6›‘«¿¼zô¯Gÿü;L3endstream endobj 4343 0 obj<>/XObject<<>>>>/Annots 1023 0 R>>endobj 4344 0 obj<>stream xÕ[Û’Û6}÷W°RµUN¥DóR|ÚZß²®r¯GY¿ä…–8­u[äxþ~Ow¦fÉ“ ÿæIYÓóõ“,Íð„þÈé÷?Ó“¤vMê’u’Ga•\<1â:)Û´ñ/fÄuâ¦ii0#®“i•+kê¯rÜŸ+ñ—¤Óˆ4––”ò› VÔ°¤ë¤iU ̈h˜»´õohe UÔÕ¹QËBTë±<§wj­ µEMfFÔÈÔi“Ö52ЦN§52жôëxüpNô qÀË‹Š¨ •¡¶ÌiÀ52Ðz:D¼NŠ,£\ж<$×Jq,DÐ!,Ï\Z%´2:eŸÔÈ@‘Ui+N%‘¤Sb§Ë3òƒSÐÊä—æµI3ÇBTë1r K"he¨­ êT›Zh] â52¹—<Qž2®–å9" Ɉë¤ÅœN"fDt‰YQÐÊ4  ›Zè”Ô FÆp‹†Ãã£!Y¨«ÉŠŠ+“¾Ž…è_É´ •1$žÆ52™C%À FÆP×ríÖÊ@KÎ3EÅû¥$·¸›…è}5ìBÅŒˆá1ü« •bÂ#6ŠŠ ›Ú,Dy,Ï©68¥an“—…ØÐcy‘‘ƒ”†™©‚Ž…ØÐc> Z†8ö¬¢¬¶šš`‹ j&㉠4lLE©Xˆ =–ç4¹#( n­Ž ±¡Çò¢@DPr|ýòR±z¬mQÂ"fDØ_Ð"AQZ·V,D¥-ŠJ«±Š E)zŠ&²•zL´(fDR:EBV Zh› Pé2—p`AÏ’ŠêÒˆhˆZ ï(he±Ä¢¢kY"zXˆj=æÕ(he¨…x]QV[¶2 X­ª6`¢&‚V¦Ñ:¤VDEíT‚)jYˆj=æÕ(heR[ÀÞ2¢F:¥•Á F¦ÊÅCÒ¶V M…i+®%QdÀ,Ä{ÌPA+cHà è#顦VŠ¥ **z>)²;U®I©R*è; ¨tQ#S§ùPQéÔ“JéTy£Ñó³TÐÊ@ËŒœQ#S§5*FD¥SOH¥¢¥Ë]S*heŠiI~P´á—édŽUFZidŒŠAì#jd ˜­Ay!+Y;Íh¼FÄL$îg0šï…ew"P;æ]Ë1ísÿ&VÆp°¢=Ü%«µü­PŠ&jËiAŽ`ndò­å¨–¿‰Gø[F΋`nd-­dµžƒÉð”Ò A.ª¤PÐÊ@Á•J‹™liÈEÚ–#Vx>Ä!ÝG C V)‹A «fD-‚±¡•‚ô‡>¨K³Ÿ@E¤,<aÇÏ*fD(-y< Šc-×)”Έc×A}‡c”½ƒÈd Ç+¢F&KZLlÓÖȘàÛж•!y¦$cP¢dD¨•LTÐÊ@QŽ[žÞ¾n(Òy«m¥Sϲ¤¥QF¤N9f Z(R¶(ÊjsËÀDÐé0 }­Lji;QN…Üs0ÎL43†²ÑÀVbŒÑ¤'v®ÜE„8œ@Ï2rOs#‹0eväƒ J'2P¬’¶± žøå,Ä!yÌ«UÐÊP‹ ˆƒŸhDK-õË•ÞqkÝJž½Æ4¦Ú<»DÅðJ&º¢®’Ù‚d³d6:ë>®úd{™¼Ønýæpýãì?FŸÚ²:4¸L&AÛK^ƒSÞÙâiYS+àxcñ4¹øðægz€)Û”þY·Yð;ØþÑûãÇ~­Jk'ÏÒïå7-hèÏ^WÁ-U×â4g[)kÅ#ïöýj¹^nºý²g£ž|&»iI¶L\eÍ‹`Þûãf³Ü|¢±R·á±æhæX­uÓŠí›¶û8ºjßÏýáì£Ý´õpÕs˜±] )½_~º:ÐCLβõï]õÝ¢ßóÓ6ÍCëËåJRH]uþôŽÕݤrÊ  ¾x±]ï–+ï TÊ"˜Ù‘…ˆ¾·%YÜlºõrNO))Âãõvq\±ãJ(_Î7í£Ùt´iÍæ¼P³¿ö&ã’@#{³=J\±…ÎØ—§Íôü=ñ-.&($,`sù©š{qè;lS oE‚°n@Öú¬?é`b0³Îk^¨ÔJÉeXºÝO°éptƒIkØö’ž`s­}ñÓOô«^æpÿKæ5ZsM‘h|ósù XMP›Í\Θ̊uÏËÕ"T4,SÁj³$ç÷Ä«¡‘&ý›P×#áõËÍbû§8Äx¯uÏ~±ÿuécxÉM9ä +D¥âüƦ–GBùÐ6Õ%,¹Üo×Ü6Uíeÿ¥_mwRæAòµÌ_Ž‹åÖÞ>~zDû c=—t“3¿”+)&‡íäÅ3Ÿø8ŽÌBžüÒív1}BmŒx>Ô‡›6älzïò$Þ¿ð2ÄiŠÕÉgÁCÊωÃø´.æ1¶¸ƒ<~}ÜÌ©žÉ$ðŒ?çÈïï[í®¿å íø7¨3mUÈX¢a¹}—$ð‰ÌW¡û»|tÔM§œ”˜(6rC† Øõ¡ó;0>»}äÄ*[Y± dä»í;˽LµÝ£ï¦-GËYêP¦CêpqØç‡ã^8ü÷.1ëV¸¸`FNt›æÌWÝõµZà$aÜ%ŵG{*;×8Uï3òÍæªß/1ç\cp >Ö=«k™ºLð½ÍpÞq|ï³ñ·/ý~µÅn”Ïbp£4åtÙð›ºçÊ_ú‚k™§Lr^¡m4sŽqœî æ¿‹u‡­”LÏñ“WÛÁÌ9È÷™ˆíu½ëæ¾tfºÖ8¬¦9Ó–ûÌ;ôëݪ;ˆut¢:ÖºãZÙQŽÀ79yï³›ìÍ¢Ûód„!E“™·œêÎ}ukõvùqßíùÌ\§ /<½˜½ýãGYtÓâÑ—Ø`?}¶7,H9‡þ^ÌÞò¸ae8dàRä'.>–lFGé\+[Ê<»e/'Âÿiï#­T#5Øï©nÌž¸×àu·?pˆÍÁÁ¦u=®MŠk…ØÊ'׃u‡íÝo¯¯'o»Í§c÷‰i>aÀ¹÷äÝvu³ÞîwWËk>/ÀEp{NK]+'¼j„sYkâ}Å«¯ó~ŽÅª2–¦ß7ûíJOãQØ_ÊR®†9{õǜqüŠÓhGñ½\¾Ã¥å´8d’’ïÓíe¹Ô[³šücµì<{Ç÷eár&¨Éßu&¬}°CÆ/9âm±œƒÐSúAˆGõ‡«íBv˜uŠ#ßÑ휃}ùÉ1$¾&˜øµ„`¿y—uøs„Öù$ª3Ù˜L‡iÊQ·%t—NpIVýp?lnŠ.â›Øvæã»JIƒÁôiŽe>LLéy³Ùe4a½Ãâíñ^ÄökE²ëö`úÁi¸rÑS‚×OSlÓì33ãƒo.)WpDXQ°Ñ —+#)LÃaÔ™ìH·JøLw0‡ï¼*¼ã²øoý`•5õl±Ü÷8Åý"…Î¥õ™s?˜»á‘>…XþOJØ®ÅïºVz¾ÚÎ?KÉÆ§”12 ¬•êLös˜Õ†'¾l}ß-Õ0>îÑɪ1eÓ@ªGßY[îþÿ: ;˜Óxkõ7çìðDpœSVÄOvlqf o Óìfׯ»ÄkÌWÚ'±¬3Ù•ñÙsܤx2¯ë퇫N–ðŰ¢,ÙXÿ…KÛÓo7â“¿SÆCqöÏ4NlÇÊ{÷–´9©H>¸l‡9I¹žã®–§s©Ÿ¨vqv?x¥!NçJø¤ÇíÃðÙÞî&lkÀÂão”šÒPÇTnÅÏÁØág)M:,H/ûU¯_bªø€¹ã›Õµœ`Ÿ|…ƒ ø ¸ïV8Ý]ã«LzJ_„ |ûë?cybcknêÏžÄ45v° âÖ±w‘„«Â·8£°Ê¢–Óú v¤¶{fˆÃÚ0/Xn~ «ñÑ_ ‰7’cn&aÕŸùÿƒuÓúÄ:9Ã7Ö‘)ó«~þ™[ ÐÚH_Ö`ÿ¬¢_Ñ øA꩞ vfl~Rð½Ä­–+Ü,DKª5®ÛÂÉ‘ˆX8q$&‡Ópb›À›Œ\ô—Ýqåmä ߨ„ĤÏ%÷m“³vc[œiØ´á$ÅZæ;¦µ/Úvš“r®nlCN†9‡”,ÂYØÐ¸1ôÕrßÇ¿¿ˆðO'ðC"Ô»KüT5ÍègSÐìñ™)}!?¡à¾ÜδÐë·¨%îZ l¬°¤p­üºüJ īٓ=ùæ·„.endstream endobj 4345 0 obj<>/XObject<<>>>>/Annots 1077 0 R>>endobj 4346 0 obj<>stream xÕ\]“[Å}÷¯¸åªTˆ„¼c»¨ÂÁ^x¹+Ýõ VÒF«Åö¿Ïéîé{÷B UArHMÏôtOOOψ?ɳþɳ²¡ÿ¯wOfÓ>¡?rúã»WôIÖÔóií²ÜÁmöæI€»¬\Nçé‹Ä¸ËêÅ´ \€»lQM‹ÀÍ ê¯ªSþ-H:tŒÑTeŸ ìb6­B[\RR„1 ‚•­æÔÔÙ€IpEÚ+‚‹< ^Ò˜‰`ÇhÚÌh’œ ìrÞcEðŒЈYÿ+[±`gFÛ9 6–×èÍ rÁÆÂó,°Cð¢˜6Á 5¸f+ËsØ€I0ͱ³"x®ÆcÁŒ‚`eëÙt™ÕÎL‚çÓE`EpW3 ‚•­kìlÀ¼,H°±"¸ŠÆ«ÁÊ6 šEgÞeŬî±"¸ìQ¬lÁæq6`Œ¸æi4V=ã1 ‚•­*RÖÙ€iŽsòcë KºÎÅxó¥’ æK²:“; ˜Æ;§ù7VÄÎÄt"‡‹M\>[ ÄÔFFLbgÓ<°< ÕB GqBLƒco E0 nÐm`Û4ˆ1 ìr£6`¸DÑïW†ŒEî¡­b†¬l± !;0 Š,Ø€Á†~XrÀ`au¨ë’¶!+Mu6žUFaÈÊÂCgYålÀè¶æn ˜E“âm¥ÛZãwË(t«,Á@ÆJÓJ#7eš*‹è[f•±ì©U!.Åž*€Zˆá²Ã;1XX3Ìr¨©ˆÍÅ옘$Ĉ†%ÚɈ‰]¢Ö4bê”bH`‹hÞc»¤ˆÚL­è±“ÃôûlYcѺd™ DJZ¢;ŸŠÄåðwÌ¡‘cÀ02 çlÀ¤,ÉÙ€‰]ÒTÖ1Œ\ “l,¸\Š#ò€Ø€•Ëó ŒÖ4‡Î²“–Xy¾³ "¹’B‹fž6`‰ÀòLhÛ"§øï¬hÓˆƒ‹6 \›Äå742btŠä‚rQ’؆4h0Xx^¯mÀäk´³¸äˆÕ›œ-¬¥2å¼ИÜeðg؆¿H\€æÈH™#hD¦áU_2 †¢aNnædÄ`aqhbME,'£*Ö3SÚkËÄåMEä$%Ú¥¥­ÏñÌs~lì‚6ÀLsKÙ¥³âƒš˜Š K=%ñ.•AÎl‚eÁ…¥­4bA>bcYP`VÁΊ`8ŒïŸ£ XYälÀ&ØX¬‰)OEá‰iÀä¿4Ç ‚±£ÌËV/8ÙLV`Τ\ŽÅÔdN²k)ñd_@ „k74½–“ˆ± |ÐI '’:Ï*É‹ÄåØdñÜ ±ÍœÄZS›RN^"…唢!bä;PÄ:;§ÈØ€1³Êœ•N9ÉT],ã”N'¡«02btŠìaáàyHƒÅ^M«¤t§c̼e«¦€ãÔå [›“¬ õd{¢Çhå$v2bˆÅ´æ<â¤IÀÔ)ÔBÛ€ÁrÚØ€1õ%í‰ÎÊ€S¢*#´|1@ˆÅİ+e>boÇ4$RÙY›’I‘cÙb€&ÖÈÔMj)ͱ¼fRÊ‘3ðéM\šN##¦ÑÒñÃ›ŠØ”HÊð,  >0óFF ¶¢Ã‡³"6¥ "ÇòÈÑC¬‘ÓhK2™³ƒ³A ,Â"4u6` ”I:±¸JEÜ“)ÈuÀÎà0¥ä‹ÄqQJÛqʹ±ð+cçx}¦díÈ'‰Žh 4uNQFžR1ŽüwjärJÖŒ âl8‡àP/içܼAðq™Áq$7Žý"%g<,K¾Ñ@¸äey™CpÈsPÀ3Î!8T2"ç Î%+mÇI)wm‰“#d§7*@ù—q,0¦[–2±ÀÄé”§‘Ä!ò|;çÜ'emÇõ“°$‘;ÓŒÏa–É1L¹Šó:Û/¢3œ¹J禑¢ q<”Ôq×VktDš‘= sH¡Ü9‡²€‘À7“ÿsjÉX’³ìø6ûüåΉ®WרçJÔJ1°¢©²Õ†ëγlµ~¶j¯n»ìp=?ìOÝþtÿÉêç ŽKÓ,q ®³‰J›ð*”²W›geC­Àã›gÙ›¿zE þÌËôY»ßðwP+ÒGß=\} Ï>‰8Dz±Ù45z(Dèënº ¯”táO¯]×ß>åÏÓå<§wÝ®½ã‘°¦Ž§çÿ_“—4¨I>kº-‡ºí»w¤ë·\4#º!xWòñÙU3Íò| Y>cÕhÁ$³íºÝUwÜîY7ªÑ…yKßnóåùukòJ †âßÐó|¨Ø¯­jEñørµRo1íf#Ú#ÚN²Ø°E^ºz®¥öýH"ËÏ<É'O7Çû{Q—‹ÄjKñJçïlÿ6ݯ6ö× Ùf{ìÖ§“ì‰ÄµÓ­ºÝš¼–Çç´Ù˜Q~ÉÚá„|ÉÚ¹n#.ÉçˆnØà’z8båDc¨ÄΘ>>—C69~’sJ40Ú|HŽ öiƒÔðÌڌ̢*ˆmx $%¾»½½=\µ·²ÚcþˆÛÝK‰$SÕŒòî~˜d»j¢•çT(‹šjÑ–Gy#'‹8±—“l™ME.ïDû±ñLÅïï»ë‡[òV¤«¹&\/öëÓö° —ÓÅ¥¤\¦ÿ¥ÉÙ^“yßCSÉR§®çÖ`¤ÿ&çÓì‘2[þЂíoì'/Þ·»»´ Y½¼íD•Ã~àé «¥TQ~펧íþ-•BÝI[ÂÍt™ö‘l, µÇcËœ;gúÅÇy(j}ÓÊ2F¹EÏgŸ~JýÑMø9r›.œæ£3¤Ã³OÖí-¶¬°¿ ý}Øi5 /ž,HÌ=ì½ìÚÓÃ1ê)*¢—ºŸaU5…T%p©ÓŽ”]Û¦öú°y¸íØ…Q¿Ö¼‰S€þâ\Iòï†U‘¯ª‚=%6ÿv-vûéÙÓöát€nOú„4¾¸s‘)O8<:¨ôwÑhZèÞût–ÔÌ›)ŽXguUUlXm!ÝdCñÓÎÒ-¿$ÝÆ+I¤›„Ù?©[ñqè6<¼ü!»•‡nÓÌÒÍ‚fÒ¢Š¿~Ý5ErÇÞY?¬á=[3ú ÐpØëMŸ²{6ŸÌžýÅæ×v¿îøš?ï±Èêp·]ß³ê¸mýë­ñ»û×TUçt9îû*_=Û}s'Çjúy§ézÀáíöÐn4sÁâÂVåõJÔ7Û±Ÿ±cëñ!œ;_?Üž¶OYèzA‹‚ß¶ë_Ú·)9;sÆÒ©æÓK»ñê§gÇ7wÝz{ýAÍU{Þýzû^Ί¨p/uÉŠÚìËTµ>ÇÑxè°”eJáσÇJ]/ómìÝîpäê†ne„×í££2Í ,׿¯Iߦ”³0î>‹c¼õõº=þÂö '~}8”~ó®ëøG¬Ø¿jW˜ ^ѸTŸ~~àƒ:‘†+ñØÿ×OT¼¬ïO@¿ uuž‚pñÍ»}w¼¿Ù²Îôû¯Ë»Œ0ýJ{æõZªÇõ[x4VÁD—§|£)ÙT“ÁI‰Jlìsªâ˜,·I¥œw‡‹TR9Uð%(±‡† Áž‚YÁ•ÕÝ”r_¶ì§0¢\Ä«Ž/ðVi³I¹îs5šŒ•dFÔé†gïÝõÊ7{þÙgiÒ´*™½9ÁíùCÜ¿§TÙ”¼÷|þÒ^÷(SMp¦W}nßÞp ‚W©^ÂîÚ¶i£ÖDæz›nzr¼ë½€P¯!/øƒ©5°ç‡ÝÝV+òxŽ\è•ùðbóaßî¶kÞBÖ²ó2!ªç,ióÂpµcu“\`bã¡€(ƒ_£X ó ;6ý¬ù22éñ¯Š†»(Ò’wm;.}ŸòÌ?Ž)h[=?X?àNï|Æ;>˧M%i Þëǰ%˦®ø2 {à‚tnкõášTÆŽh*l]Ý{¼¿×÷1x?¢gÑ6{-îÚâÎNvæ} ¸Ÿm<…hªÉÕV‚ZpŠ»Ûö„/ïø‰›žæÌ®¦bOæwÿþ?Ù_è“}üg:°7ø…~…¥Š­^èOèW©_Ö|Ñj®Pâ¿à€ñg“9=Éß<{ÿžÜáÅêÉ¿žüÙó…endstream endobj 4347 0 obj<>/XObject<<>>>>/Annots 1131 0 R>>endobj 4348 0 obj<>stream xÕ\M“Ç ½ëWÌ%U²¥8_=ä)e˒ʕȵñÒå|-g%Æüò,)¯þ}€nC1늫¼œ$)IoÞ4¦Ñ@£Ñèf~}–gSü7ÏÊ@ÿ»Ý<›N¦xBäôÇoèIêfRg›,7°Înž9¸ÉÊù¤‰/çà&«g“Òqn²¦´«+ú^Uó÷š¹’é õe>™Å7¥3†ÁæaÈ: ¶.‚=ÛÌ&•“,]*K×%Ö¥ÈåÓš*é1}´&M•-õ¡ÈYlMÒX7Ù¦pœƒZLI(KáQplh&¹g;/¨»ÖÖáMV £…c=r_m+c“›ˆØE.ÏëÉ< JzŒ.Ul~c&uNÚ:Œ.Á¡¬¶õ˜Ô™Ñ@)Ë®çâ×ÜaÚáĉôX:2cÙ¨õLÜ—­(@š¸@£kœƒ›lFckœƒp†jç :ƒ±õ¤ÇÔÕz‚®rߨU‹çsÇÊø4Îék6>‘£™VgFJC¸‡zBÍÀFŽ\_TRVÎ…jÖ0rù”Li¤Ç¤fƒ`c¬ˆ-½¡˜ØÈÅþ(é1Äâ9zk¬Ã`‚²òÑÂE±š}4ry^Qo•”†¹vÖ0ryQÀÛk%¥áÔ;k¹ù“¾VÎA¨QP7’…V3g*4q,Å8É _4R„6Î 9‰áFzLC^À Žu켤ª`%Tx–BEÂ*ȃ¬­t±†Ê$}”}4rñ#Jz ± EV)+b+qé<¹(FIIZµ+eE,¼Ç†ˆ‰\£¤ÇÔÛšF^Y›‹«Ho˜ØÈE1Jz ±åµ2Öa°˜»ye9„WXÊI8ôQaZísB1¯!”¥PCÁ¡Ø±ƒÅ°b¬­Ã`‘‹ $; –—2×Öaò{ SÆòø–˜*«P¹aâdÑ3Òc|´¤uÇX‹eËÄ20±‘“Å¿TÒcˆ äOƲaJ~ #@ “8ÌzJi©5Ò ÖO²‹qâƒSô˜º3£î¨XéNÌŒÙ1JÖÈÍÉØÆ9HCÇýц"4¦¿"” 2 ¹q–ʘ‡Šé4ÑtœRâ!o’PÁæ\ϱ;?a ƒ ”ŠZ[ñ‚˜ßJ4]tM2ËJå`’!T\KIÊY\Ì3KMéDhäb_•ôb1àóÌš²ØÂgƒØ}h’8š¹uD<|SoiÕ±¦ƒEþRzÖa°LèÚ: Û¤A[‡Áb¾­Ã˜õSJ´L²Ç†}–¡à,1ŽpÁÀ†"r9ÅHEÙ9Ê& ¶¦Íšc¦óPèg¥K>-†¹¨@ˆEfˆqPÒcêÝXë3UÚÕĘÁFO™*Ö†œ·ZÜ®éÑ‹×Ç"Kb"s’OXnQ'¹Ýá°Ú¾§F´¹®’hz&ó„÷íí/íûŽ_Cˆñµ}ßÝ­è)Ç<>\þ?¡ª¨SP»è>“®ÆÞÿx5Ç^ œÇ‡ÛvÓÝCÝŽ­V£4Mg-0Áåµ²¨~X¼u Òƒ°xÍ7ÇÕz™Ì‹U“®_,~áÁ€?%çyõo½_í¶¬:ª:(Çí²ëeì&EGê§Õv¹ûMÞ…ë$¯œ×/¾_ð»XƒgO5viDŠ)%¥æï(¶J¿c§8n·i@àß: ÒôšM¦éÙ]¿ÛpÛÜæÁ·ÝÇn½ÛË` D—§—oÇåjÕž?½Ëàä>ŽHâ=¾˜°Gèl?ëñß¿ýúﯨ1­áOßsóêÇþ¥úMgÝ’ºíüýkÂΣ»#»mŽ™|wǜǾkïW·ô)µþË/¿úŠαúËtú­o÷ûä=ØÇçõû)¸PêèU^Òòe¾¥ŸH>úv·<®%®a)OŸ¢ƒôI1Þ¢{½†^ýú¸½=hØ¢1]ÀŽ€ê5ŒUå„ýYgë›õî]Ëë9­ú)Jlû%xaÇæÉbìP‰ßC¡âLã ø¡SòÒ¬J"Gº?´1IBb¬!9e7. é¶Ç «?ÍçßëÆSñI]ÙÐxgåÀ¬ú^ïVH {±^L¯žªè;¡â¬éªžB ‡ÕêæÐoÇ^¼’w¬£Ÿƒsš|ìÍ5ÌÓ"€sÆFo×íý½(Z`0îhjŽ•WO Pó, g”\m?tý ó–“~$ƒieüCNô'6J~gؾê¡iÞý•4G¦“Âf†-L×wÐóž)Ò4FÔìc»>ÆÇØ%Kgg"SÛ÷í' M¨ö]À%B]²;Ó‰Â0ÜæSÖ8m$ÏØz÷±ë×»vÙñv0O¹ü_Yq3 ÛÈLkÕ•³?wsNxÊÇtEîÞv1þŽxú†Z¶°H2òt~LÃá”ä·âüßE‡Zö+óõØ‹SïÐmöëöÓŸ‘jGãjÉÊO Èf}LÛMÛ8>»x _<—QÆO­…mŸ”•Ò±9,+ë6h¯ý ká¶ÕËîЮÖ?ýVmK/¢’š–^´å'¸Ä’ÒáXñ :­@ðM§,κîP×áoã€â‚#ˆk¹Ô‹+:tòÁõîvR÷ºß=|â'Î\úEiŒÕ© ’š'K.6 ´|Ûmv=«‰x®öÚ´[7(ŸÒËtï÷‚K¹¿C-i1Ž¥\€æ æüý»íþ(s¹Ô˹üaw<¤QŠšfû¶G52íPtKÅ!ŽCœ[ ðàǀÞƒW·ÝžöçdÈÊ•X> ‘Z§r fäÒ&gÐÇÿOÍ«¹/?ñ,vš.>í»M»ç8V"Uz\©Ä† É#ïÛ,xã”f0QúЊ/#N%]±²È SU¸¥&ndLþÆÆÇm—˜Z¦O_þï¤|~R9Fõz ý™…&ê&öžNBƒËëôyBà¥øê$ã4k¨¤X‹…«ɨ§5§ñYùVˆp¾½à½˜5× NØï¤C/\-J«í©çž1øzuÏ3‰z wàª?]LIÛÆSA·ZÎxpXÓ¤*ô—_Ò#µA=ûr[ªbåxPÜÁ œâ‡•tjRY6&Ûc~Õ›¬$ióãÑ¿?ÒB.óUéKªLSCÕ®üî5ÅÚ?ÞwwÇT~Õ€7ÜcþŒ´†ÂÙò+ %oPâY¶=ïüñK›TäÉ|hÃó1®Í!Ä ì³ ?¬nÅ­©=Ód(ÚŒôäË´õ²Ž>÷°)Škoº=:EzÀÙzÃçB<>6¹±_’ÀæòÑSag"äµ\˜°´ í²BÒ.n¹ÔœŸ¹ûogãÛî7ê<‚µÎù_pÒÍÁ —SRðÂý~Í#žÝuJìƒû¥%õçç1PºüüKÅE¸K䡉 }ã#F‚:¥+èÿû¶´‰©üpBI¿$Hù¬qæ’ú߉/àp}¤GoÃô/4œÈ¾xm×­ î€Ë1tÑH"Iª™ò%tgµàtH’˜TÖÔGK/÷Çý~'Õ+ÜJÓëD6§40­Ûíû#vø21pítcš’ÝÝž¢ûîV¡™ÉDpAä»í¡GôäãgjÊ·ã.—Ï ÿ8 ì°kIÉ2nÇè“æÀu³‘_«ûU¬¸Ö—K+r–Uí†öcû:û-bAÑ­†ß¬ø6îpëQôõŠÏ69’¼±8)?³² R¸Ó¾zènçÊ2¸&ÒIÚ;òš >©lÁ‚ªŸ-Xݾßá„/]øÃ}õ[14²“ìÕI«aAâºí“>|ñgì^ÉÖ’ý&¿EÜQå¹¥Qšqžò­TiZô]úÕ»ãAÎ$ÜÁÇÉ^3¶Âï$Ìb¢È×÷½%‡¥ƒ›O›w;&¸Åm·”õþ.òÌF°ð'» ÿNJâ'+C+ëgÖ¿Üu-݆!kc÷Œê OÎl¹ê;ä …@ñ`Lga&y1~Yâ2ì%>û«?pû–7Ý–NÕS‰¿ÉÍÈ¡=áµA¯pÈä]vX.ÐD×ågn|üëí?xðë…qVÂŒƒê~zâ´åéé ë~µY©GºÜþÛöÀÛ}œ¡–©°yrË [ßÚ9êÍ?Ú°?ø÷ø9æá]†,}J¿Ý˜5“ l‚ÈèWôÿ-ôíî–k•êÍ%Ž ”¿®j»|þð°"»¿Z<ûç³ÿâ»endstream endobj 4349 0 obj<>/XObject<<>>>>/Annots 1169 0 R>>endobj 4350 0 obj<>stream xÕZÛ’ÛÈ }Ÿ¯à£ó ™÷Ëk|‹«œx³VÊÏôˆ#++‘ZŠÛŸ  jfœlRSRv·¼>:ltãÒh Éßo’(Æ¿I”•ôßíþ&^Æø…þHè_ßÑ/QYTË"ÚGI»èÓû¨(—¹{8÷Q].øšJ' qb¾,]Öf Å`‹«’µñr  I©a‹œæÉ V¤jÐHIɆ&å'Y˜ef ƒ0Ðq ì()3¦‰È t\ÇË&*•”XÙ\ÖÆ t\’ÔË**•´Š”)‰U–Å0‹Š b=—$ ¤Å›˜Ô°ƒE¨”–5l•cv3Öà}”ÆXYpm\V0 v\“ÃcËJx·¨ÄcýO3Ëá¡(?I¤Å`“jÎLª¤d†0Ö`°M¹Ì,k0…$IÇÊ‚K‰Y!ƒ°`Ç5 SÎ@ZnBVPÒb°Å|¨L™KŒÉ” Â”Ž«JšR9!4.iJ%Åa™0$”ã¸p\"žVÒbˆÅÞK"y–Ýb0iÂQÆ ó`½ÊÊ’RC Â’—Ä)Mª¤Å4)eÀ LLR(±Žsb”´bÓ”ÂDY›”Q0b—$òJZ ±‡B` &QÖ‚yÒ¼6éF€Nê¹ëL£@ÊÀʸ;g:ŽRjÒb¬ñ–C3/ÅešH¬ÈÛ72ÁyTcßç x`€8sÈÕ3\3礕âT4-&»æ½ Ṽ!”okŠŸœ-Ç@ L+šSI‹ÁBÄ*+bSq—ÈaÄ:ŽN¸KI‹!çTnX‹ÄVË ˆu\’²X%-†XìÕ*Êk0XtQV&E2“2“:.ÉS¨¤Åd"Úô†5ØgÛÀò¤Y#{— (@'õ\ÓF ¤Åd@Úd†5˜ì@1fXƒÁ–d|ÃLç Y8°²àÚRÆ ,Øqtb¡’SÒbZ0OXƒÁtš±ƒÅI;“l0Ì¥K+ .Mˆf ‚G‘N¥'=I¤Å˜”ƒa  RåêÇʤ®R·2“:Nb'SÒbˆEÕ”E±ˆb ÑŒAë¸Fˆ£@Z ±œ‰+b¹VDr ˜1`±b '‡@ZLbK j1ØŠŽÊÀʤ®ê”Iµè4¹”Í”´˜&i_(+b]M*r´è4eC)i1Xäol¨À ¶¡"Ù°Ó–©f¬ÅŸ”=ÂX‹Á¢d‚ u^rq”º:™ÖÂ!ŽPƒÉ 6<ˬÁ`KrŽa ¦%ÓX¶bê*Z6›ÏQ(A,?I¤ tå® ÔÊÒ@¬'çJZLºTü4°ƒ­©O3¬Á`QÏXƒ¡)ê†ÄŒµ,lVYÖ`°ØÉPVWe1XÌïÖà=»ÔŽ%{ 5¢Õ×b°0oc$‹‘].VÕJÛ@˜"¥8¥˜ò)-`°80i` &#ó¤ÊrA“ryí ìu*hpb„ê½@ZLË¡}nXƒÁ"ÿb±:©,Öé\Ô¥Z£ˆÑù8!4ç)u Å`±×ŸÊþyeîAø2dÜD/ß6ȧPku?ÁJîÐl¤e­Ö|gG«Û«öË®‹†»èÕÐO]?ÿ´ú§Ç×*,®@:$a /mÈ©p ³Z¿ÈjO¬_Do¾CÒzÛoèW¨’»ß?}~ÿŽ~B‰Weî·i¡ËÚÿr<Ã8ÑÏhÕk?¸ï¾ñ“›º±»¶ßœÚMÇk~ù6÷+l nŠ…¦²¶%Ú3ž¶ðë˜F,ŽG¥ü¶¼îÊ:' E>S+©õ—öøUlñ£Uñ˜VÙL«Û£%Ÿß`×í+Z]Y‹fþbæ1vcêñÕ°ß=©‹”§[b8tc;m‡ž#TU][–uÉž£•¹‚¬·*ø~bU$ 5fµÛ‚Ã}7²›ãeê´‹¬§o¢¶_ÓsI¹l|&qžá¬*/kµÊ€¹%ØBÁ/?²N‰ëaŽâн\T&†Y-îˆ%Ùÿ­½ßn®šíÕO¸nßöÛÃi§ã.,õ!qhÇcÇ1‘áDáÓØIFà ^ÐteÍ'Ü‚®ë¬—Ù>ÆŸ‡ñ7g‰¬^Æ>ˆ¿m§¯¬¢Ý«ÛN8…¾œ&ÑO—W·Ë%“5ÒX„3UN|º~O­~¼óTíããÔíYñzéwôµG~ÙĬðÙ~®­!X7¤&o…®¿|ეžø8îèIt©ZåL°—T hß.œÃŒK¼ö v›qör^i<æì[œWÓxº¥ƒ‹”EÓíÍbä_þ¯eÃÅà¢if ΋ŽÇÄN•B÷”¹søåÕyjeÃ.[ ‡· Kç˜õKŠ®;ŽN*¶}eýHêÞö_»q;µý-ïsT6—LÈgj{mÏÃv^|¸ow'—o/x˜œ­ýiX6•‹bªóÂâãi:œ¤[2§ËÝ©çÈ)‡‹ï™žžì"LÙH_“ W é†OsªþÒŽí¾C)ÉÚät‡Â‡ÎE–üÇ&õ –V¿„O\òù]øË— (~è3ê£[Úª¦ðýàú]úmAã;æ¿ëÓŽw%>@ˆÝþcë|¦§ËFú ܨÿâ䜅 ƒîöäÜúi±ÖÝNÖµž&¢àì4~œ|U¿OS;ªƒóeâ;žA6.½u¾|&?üob½«3'rvR%©™u綨ê¸Ûöšf?ínqtMª—ëkù²!d$z¿@ah”íï¶›ÓÈ}:1¸Û ûöaÏz»Ã8ÜvÇ£ÛçôÀÓXÙHk—ðåíLQhUôM??xæzˆD‡aÛó‘“b¯úWoò´ÅA-,=AÿM×»Û J¹ü²Å¯bvµs ¨LŠ5 ú½kêQ9ù\üHåôml¸ÒáøA¿ëíuü­Ûu“»þA¸˜ÊÆ5·gµ"ŒÀA¢Fø0|[ìº{ÉÈHÓ^“ŸøyÐ3û*Î¥*–æ¯æç[@Å]øÓ»ûn»swÕ²¾ºëã*–ºÿüfÎä²JuüõÔOÛ½T ¦ƒµ·ï(&.˜¢ž<³ªXÊâó3WÊ*¼çê ‡n¿nG¾>´—1»í—±u9Í´èÁ­¸jº"·zméý¼íäàÐDª(¯ð?ŽîNÕ¤Ûî{»?¸xÍ1⚊Cu°Wžk(u”×p…œÒ(n}C­Çí}Ç7øÐÇÇk´¦45öx£Eð:TïbÉÐÓW)QÌGÝþâxÚN²CðºÞUåºêgûKs­!/Úæi*ÁW:|n†Þû¸÷½ƒÙÇÿ^%¼b¼tÑ©šægé8‘ÒÒûýõp{"Wjµ…—˜××V±ò»SóÒ/c7v¿Ÿ¶GÄ7´68ï®Ð„x]ûEzoª74¦7 ¯Gu =JOÒý²Ë‹è©B·è-ü°x{$€ôý­Ýhx=Ç÷ØîÚ/Ç·`ÿåNñöËðeÚy¢Ô¯öU¸dEì=N?¤ F¦Äù.§Àæ´E ‰„M¢Å›çÙ¶ï(¸Š]Î_A˜ œ7¸¹xÝ}9m6n‹ãÚM߯| múþ ×Ñ?ÓZUE håÜn}G®¢`M’ó©÷D4M&R‰x¾G÷ÁNG“R^Ñ.–ªbWt§te¬Â™ÏXåíiÄV䬀}¡Î}vÀ™w«ï{d‘½æJìÈÒ½tú™“ž›«¤ZáïSÂüiIí>ÜÀw„È’yï>‘çpF gAŸ·=82|ãåꢢ¯RÖ/¾ßn)Þ¬nþ~ó/2áÇ_endstream endobj 4351 0 obj<>/XObject<<>>>>/Annots 1208 0 R>>endobj 4352 0 obj<>stream x½XMsÛ6½ëW Ó‹2É" ~¨·ÄŽÝtœ©k«õÅš„%6"©R”Sç×÷í.EÀíøâšœd?=>¼Ýåb诉§øã© ¢¿Y9YÌø„~xôãúbDó… ãh©RElÕMÇEš¹$œk2°\è;:ÄÉ2· ç¾ {Î¥òñ(ОäEõRêÍ«è=r¼ŠåHõN扲¤,št¥"h´(·„@==÷R„‘”;¦—¨P¸PJºÔó@iÄ9‹â-„)B-u‹YÈÀ.Húñ­¨p¤â]Äx–s µOYôB1ô»ô±#”fÀ‹ZHé{”FOŠŤMÓÖ :á"êÝs¤ô—´hOò¢ÁRê.‘†ZÔ¥J(EË9‹b9ß!] 6x.KA›c‚Yb!-!VKº˜2±Ï’ÔÅ`v7 5íGlh!Z D0–]"eŃŽë,ä@¡ë9Ñ¡óÉ/äÎ<Ä ë9ÑER˜0@Ñ|¬³~ô-'ºP sB Hç@øب~Ï9P^þÂ!eÑ@ŠÆƒÊgÀÁÐVˆ`h¤XNtè$JÓÆBj š–! i§"TF¤t1XÌÄÚ³"]HáP2•)ˆÐ!f9Öy|” £hR `…ÐEx–Î~Á1rô.´µ¡“Ár¢ÃŽd0`…ü‚á×s¢ »†¢Nð°Î®1,':LKò“üØü:Nòë9ÑÒPø4ÆÄ!@:ò†ñNt^_èpœ´ÑrãC×s¢Ãl¢85ílLŸ…È&‰åX†ø ¡PÝùwr³ˆM®.xŒ¨+çúÄw¨f­NΗxO0^=à¦%ÈÙW«œïX µÊ¦7·Ÿ/f>ºî¬Î¥©Ú´-êêÝêÏÉɹ†…g>nWaåô2Ý·ê°ËÓÖ¨ŸÔQ>÷|u7]ªss>ôôÝ;Yî‡!»Ïpžâ×|zc22Ù÷ $ o† •$ü¢R§ucþÖ¿®ˆœã1P\"g>ûåÓ«Æ<¤™!+±eñ¨Þd;£úâ·|zçG±zþ<ßBŸYÐÓ3$‹ç?WmSçÎå¹ìMm.LÛÕZíÛ´iM®êJÝU^ãú ”ÛMÖ;²01êõ1ÝÙ ™LÑR×&ÍU»)ö?[ê Þ;§U®Nß¿0ÁÕÆðQ»Æìš:3û}ÝŒá·-î›´yÐêC³æi¡6(ãvØ>Y=íL™î^h’“ó7hˆÓþ­Ëâ;?õ`ÒöИA k 4k‡ôø#mŠô~kÔÖTëv£Òî éy›6 «½ž®-ámÝ|%«orû‚A¼Ôî÷=™ñä`Ç,K³Í«Ž>“ùÈ£qIÇ'—iµ> f].¯?ù>l·fÝÔ8?ˇÅe±ß©ýa·«›vȉPåM]ä#8þ8†É¦È¾šj§³<.ê1L†ÍðöKú˜Ž`3îö¹<Œ‘É4¡z_¾ß`<–æä:Å>jGpü5KËí(>mú8FŸ_™fŽÐÕÏWc¸_G)ÚS»Á¡7üºÃãpÿ4‚Í*û_ûæ…ûÌ™y4Ûzgš×ßd>ýÝš*?Þ»^sy99ïÿŸ/w-|Õ'ò-Ä‹ß|„øÆDkùRÀ#×O«Éo“gþñendstream endobj 4353 0 obj<>/XObject<<>>>>/Annots 1230 0 R>>endobj 4354 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 4355 0 obj<>/XObject<<>>>>/Annots 1236 0 R>>endobj 4356 0 obj<>stream x}XïÛ6ý¾Å Å¡Ûv-[öþJ+pÉeÓ|h“6{WPà@K”ÌZUвâþõ}”¼«f7H²±Lj83ïÍ›áþq–Ê RÙ\óoVŸ­’¾á”?~ys¶Æ“\oVÉÔ’^_ž*ù¯.oãbÊ­ñ),Þ¬“[I/7É ¼ºY­’«ñ‰«Ÿ±º¾LÒG«/ï¹üq¥,ï.%]É}Ÿ¯_àC\Ňìü~g:éŒ×’ÙÆ+ÓtâwZ*åuçå ]gl#¶ßv¶ðƒrúBú+Rö&ǃjr1Ma]­›ºÅ‚†a£w&Ûwɸe}É-ÿ³½dªUuVº~ÛeÎlµxÝL¹ gR+SñüÊ ˆíQ!ò ÆÖªR«sÌB¢Vr›l˜©5ÜZ¯“ÍOùùÎûö»år†¤Ã!‰uå’g$;_Ws[Ÿ&}lm’ëëÚº‡ 3ÿTÝHnº¬ï: 4l­§Œ×Ö!<í“©JT×êÌw\ýðëÛ7ȃEPƒñ»jk{Ä­½•V´ú÷l½ïa{°n?Ïñã¢úí¿Ê2Ý1ÍŸr#øXÔ‰QÀ8‘éýcfDÇ<9GÝ’t:å¿›'2Òç@ §¾¬´T{ÿÕ$^ B¨¦Äõ6YE,R”Ö{§þ£'CtG—Ëõu{aƒÓµjúC××È©ß)/GprߨAvø‡ ŽÕôjùêÛoIöÒ©:dÿa÷N4â"ãe§Q,D”dnK+Õ”=X .ôÙ¨‡ÌLurŸUòþèw¶‰µ÷^»*‘IÀM…\Òü_N4êô“ÆPc=(‚è!¨`³/w‘…ªQD ÑÁ’æ+xÚ;ŸÈOvæMëŒu¢?¶ÚÝd`Ù¸íM`y…%Л*2Þ<¦ó‹…B)8øI°:0Çêܒƽ·”TCuœˆõã;h0ö" Ò!’*'òlò(SHÑGjÔ‚©ÏlÝ"sªÝ؇TµZíuJ$cÃ3UäS¤f)y1`9‡ B-ó¤ Þ{äôi]hS h%¯&ÖLÑEé{‡ÐÄHCHÆ©®™¶v²)SÀzãm/ i8íéèõâÄ€ŠwäçTf`ÕÌ‹ØC0bdìÄÆ 'º ›–‚y‡¦™£fŠ §ø¾&Ž»Špõ¥5YœTŸ-Ã[y©²=†çìG@5†òt Žø‘§ tÓcûŽ™pÌ&ù("ì¾ÙØ%‘É©ðB¯ÑpuûôÑÈôÔñ™[Ô—®¨ßs‰eÂ0¯À.7õ>èžöZ·ÏY>µoаªuìN²q&XÂàP+临Tä ùìnè˜0ÎÆBœAˆ‰*Ä91Æ™”U7„^?RRÎŒ=†Å>-ÚÇ.¹µe‰bÌí€^F—§“5sÄt]ÏxAj<[ ƃG¨²]· #žc+VnCb» žƒÍOn!çcoçp6vÞÓži¦=Ÿ#U&YáPƒy )‡°‘;A¢ž!A€Ä…(cK¢â±@™K2ïÿÿ}ýˇ·ï~šeaA/íŽõÖV£”ìlÞóåщÁhÌÔDýQg=´=™n`>þˆÉ"Y˜e¯Kðÿ©±xõq•®6i*¿gÖafimµÒ«‹4Ù$iúÛ×ìp¼€ ª ㆠt>ŒL aŽé¯™•ú±E£j! ž s’ǤŽxf©xÈû4A‰öY¸á,ïž¹d~ ®>έ|ÿO™‚šŒóò~¾üFþ,Â=±€ŒÑO†iT“o–³Í_jd!8·¼Ão` ôö2¹Ú\ n¤ÉåU¸áòàÅ¿‡ø·Íp·/á´„+Sܽ¸áÛùyŠ«·Cl;Û;”!·]¥°u‰ß0`dž_¼¾?ûùì/Z—vendstream endobj 4357 0 obj<>/XObject<<>>>>/Annots 1248 0 R>>endobj 4358 0 obj<>stream x•WaoÛ6ýž_qÌl9–íİI–dŠ´KÜ ´DÙ\$R#¥¸þ÷{GŠŽÕ-íŠ)OwïÞ½£þ>™Ð)þMhzÆÿ³êä49Åþ3á?·'i:I–4ŸÎ’U”Ηɤ[•ôxr¼ÆîÙVÁÖï­±» ¡sz¸~s}ñx}ÿvuýèÓpä¶ Iå´SÍ6¤Ù%ߘšJù,KÊ••Ycìž2£¡ô°—𕮯¾‚é~ˆäaQ¡=Ž™ `ÃvaEü¿j`Ÿ•i]tå|®­*Xzþ{ÖT/è¦)½6w_Gœ¹²2WÍWöõW„¦V­Î‘'jÿÒGv¢¡iËÜSi-©6Ωu)=¶¦e­Z· ØçÈT ½§Zšš }RzÓñOYrµ°’UpwE/˽iÁ¶gIk°´P ÓÔgÞ‚^Ÿÿà”yƒ—:•ƒºÞC_ÝÐ2ƒ_ ŸjŒ?Ø7‹5àí')kÅ6u‚ÑÆà oDÚ$5 *…ÝÈ^ÈÏÂ*D©ÛjX{L{kÂÉJä_"PEY&/ômÇUÒXïæh*^ ÁeØ"÷"¸zûîãÃÝío+Ï~)»~yµ`?®]Wâu»ù‘&tÙnÀÏÚØ¯‘é¢l¶¦Ýl `‚ϬêÆ+ÈZA¯ÄS »G…•rH;éS¥3ÔØ}W:oYHÑ´€CU`æ³dT\ g%ö=0˜hòRä“¢•é‚FñðdqtÒQ¡«¹þÌa߀s©ŠèÝgŽŸL0·S›‘?áq¼|ªoýÂ3€à ‘tÎûÖÑwOb9n"²'iûæçh$MhžøŠ!ˆ Ú,bªPÿŽ;Dí³²Í9ÞOU@©2¦þôð±‘VP~±‘nè_,×x¹ë¬Ñx¨DÞVµ&“yÌÙ,X@ö/aÊDa8 :I[Ô‰'µNæC/…¬(3Î4b­$†·ÕáäË‹³+3¹ô:x€í:zft¹‡ÿÏž „TA±'mv$ÖtUßÐÏÀºÍ )1šö ãGñ(=ë¦FyŠiþAéÜìþòP´ù!ø.蘓Cº‹*°âõ‹91ˆÎ³­¨^ßê@?•øý¶Åüòz¬c<\rÏs\¢7¡¶ÕÚ·ŸE…u^ýzŽ'r<ª=_22Àƒ¨¹vv†Â Œ¹nUÙ„ËÏ2kæÚÐHð >‚º¡%ÿ5¦ûõ} ÀìNa ¨†C@ÐYƒZ3ŽNTžûü ®»Î> : »¿ ‘–x1D…Ó¥9Ø7[†C–.ðꋚ‡ žÒ{ vý¯jÄh«Zˆ ¨þZ…oïß{e|­´ˆ’±ä+Ï1Ÿ^@ç_3¨võpýšSÎb ×@3ø `ˆ×·wp¿íßÌôႆx£²‘êÌÊÆq¡6!EŸgh+×™g<» Ãð¡­ÄH´þJrèXΨTkËÓÔ!ËÆ_8Ž=ã#Ëã :Q‚ÿ<ÝÃõ DØr„i2b•~ d|5âÄ_"Øáý"‚ߨ€#ïwšœóéË=[ˆ6*DGAhh¨7¨6n—:s SlÚã&`V \ì‹BòWñ V@f¶<·âp¸û}3¢1óøÕ}àŒFP/Ì~2µ÷ Êõ¾€èå³mÐ ÂèÄõ;¦Ã/cŽ}ÌYh(ܸ»¢ºè{J±è>&'‹Y2ŸÎél¾HÒ¹/3÷÷(Åé¯&kùžu|¨[°3Lü· K\ üwh\Õ°]«R5þJ6Ÿœ'³¦$LgŒÓõêä÷“7@endstream endobj 4359 0 obj<>/XObject<<>>>>/Annots 1254 0 R>>endobj 4360 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 4361 0 obj<>/XObject<<>>>>>>endobj 4362 0 obj<>stream xuT[oÚ0~çW|ª&•ª%„pi»·]ÚiÒ4i*Z_úbÜ:6³hþý>›ÐއBÈŸóÝNþ &Èùž`ºˆŸ²|^ò,çáÛ—[c|Ÿã&›bY£È±¸d‹Å5–UªÊ±,‡àëñ"1z.0zA¹‘åËÅòy0¾Ÿa¢#^Óþòð“öö ß¿{øv»µ. ¶_./¡âQ]«RItQí„)e…°¥tA(ƒ }ðÛ¡JÃX]ÉC‡Ò6[¥¥óxÆ®Êø[@Õèlë"6â™$2<£²ÒÃØð¨‘ÍŠƒl¶ZpÞÓE†åFz éœewá$6Â5Zzß÷fs81HCÄ-ËCºTKZÇDQÀîÍ ’­³k'Ÿõ§Å,âûiƒüç&Ê#ߪ Q¶ÎÔ)­‰zxرÎé_R&Ã÷Ä•øv’2™•ªko!·–Z˜u+Ö Òš ¢ðÚîy©Ü(#¯ Â ÌF­7± o, -†÷°‰œÈصtçn"4¾¿ET¼fêFÅ"R›d“"›ãîUPaéã”÷ÈĪY–$ˆäE¤ád¬ëðF]`'œ’¡ƒ­!ûnñwë•Y§œ%b*P¦Ë6+g÷^¬´¤ceÛP”5ÁtØZzxÂ;y–®ÅPØÄ±fÌpÖc+SÉ×l}vêá®ÓPê¶¢ ¿•o…N+À$<“$ pVùíÓâ$ŸvdÕ*]E^‰YF±ßY<ÉeøÁÔž†ñdÉ´ÔÇy¡­”Å^ieÍMåBÁ‡Ž x (ŒeHú †n£t boõM¿÷E>ËæÓ9ŸùÁʸó£"Ëñõ_Õ£Î|DjG×ñ™Ñ§ƒþsÑÉ6–Ì'×ÙlÆüðßE<¸[~ þaµ‰‚endstream endobj 4363 0 obj<>/XObject<<>>>>/Annots 1268 0 R>>endobj 4364 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¬í]îZ_þ)Ÿ8eSVPàœZÅöå@<üÜ<‰|mNšÇﯵ¸Q¡OÑCw"×[+-!ul;ìͲ»ÞX׊½?Œ8BÀ„³ë®9Gõ2·ÿmF»ÆÆ(ía (©ÊOæÌc÷8@&½P1™©J• ¸ZΦ¶¢2(:åQ«Óõáߘ> 0<`µ;¤«ëÚÒýkë¥.IÛQ:à{]ÐDû:%mz»:Dñ89€³FÊÍö¨Mí,¥ñíTž ¥i)ÈÚ¯Œ°Ý]Œ6 D' O¬ÆT1jfÊé}¯ÀÚ£q½U…‚'JºsSu¤Ã7CûµSÉ€Bª èR~ÜMæŸ4…ìÅA)Cˆo¯1àbêÄÐÝø'âJ%½’ ‘þ ÝÓÒ|Á±Á\Ðw¦P'~W*¹“sš› 7dv{0)&H%û¤Y™áâÛmÂ#Î*1qG¦QÖ´p•J£eƒô¢ÄÉÔ9.YE<[F;‰¾ÿÇ/n´‹•¯Ûf ø„óg”ÑÆGƒvåwÜÖTVCcÀš£²gB…O*õC*"ä+i½Nk,s”ò„ý>Ôä2Ô$®\Ø)9½Ž–ëß…â(¹c¨»>&,Š¥NÆ>A.¼¢Ò;oÊA»s]ûΠɨº~4q`©¾7'Lvˆ™8ÉLžÃ{/÷„oà"ךW6Ò ¼:㺰¸ë pAÖF¦ÈeS Ôî´“ÍøÐ£Ó­;ò&8òž½÷K5>ò^S¡¸²ð€’ áIµÀ©úÅ*$Õ¨ÆAš¸=©á<³‚øüòáEN3šÁGÔó|ÑéÇøÙn¼8y'D Â'Éç§ÈZ¤ÿQl°6KwjÏÁÏ5­r=t¼«q«¬!ÀY¸|P¢ÜûCxwêN<,+~ÅBš[§ž]=?}IÑŒtʺðZÆ-|²š#äú¥w-¿¾Ìe]lgjë2=†"“^RWÐË_4£|š|%äF׿^aûTp3†×.ǧØ”×ø w;ꃈÐâu©=.S4|;àb+ú*í;ãWàúw–ÿÎŵGDXMXjÜ‘/ &«ý Ó2[$ËQx}zñÛ׿•Ífá›%Iþ´¹ù÷ÍT*´Ãendstream endobj 4365 0 obj<>/XObject<<>>>>>>endobj 4366 0 obj<>stream x¥WmoÛ6þž_q_ 8­­ØNš¸íŠ¡Í–¢²ÔX7 @AK”Í…"=’Šãûï{î$ÙQ–[×lÉ{yžçŽLhŒÿ:>åO^¼Œ³1~Üý K:º8¡É˜æ%¾ÀS!xȃIÆ-IQu ã’¥Ê5™HA¥~[+ãÊÚÒÕÀd:Rî]4¿~TUñúI+º¼8Ò¯“ÉÞÍ¿’¤Ü–\]-`íKò¼ßáü÷ƒ1&Sø1°fT0:^füâèb2kej¬®¦§gÔ¼îBá—£é ï1×QB€ÇÉTZü«Å©«Ä÷jm¬>*ô¢^R¾Í­~ä4NÍà±ÃW~ð‰´Š[Jž‚F*J³¬ƒæXó:&_™ÏZ’áë$|¶JÆ»ãû'^ú¢¶ÈÑgÙ…råh¡)“_o¿tÏ:¯Qø-ç*×ÁEwQ—%—é°~C%B2.&‹ÿ˜¯Ñt–½Ø•Ç“*Š #ʳÒQ“5•ILRÅ逤C¤•ºÑ¤B07º •xxiëˆ$â+~3øDªê|ŵ0ðÕ~©0ƒvi·%°ÙœrËZ-u”øööIÅë˜ÑÅ ‡´Ù‘8_¯L®ì}šTjËåˆféL —ì¶sÊ8Ð*æÁ¬Ÿ¶=ºï¹ÖôÓ6­Ξç̳Ã8ø€Á8Ú¬¶Tk‘…ÈdúGÒ€‚ºC"ÒŒ1±†Óo‘¥œLI[_“Ó°«|Ð=G°/QgzãPyB šçuÐп\%R6z‚Xpb#,B¯¥h‰+(µ¤LÞÛŒ~D á¾oß©Õn¹DH\Ï¡hªµ5%˜†$py8è®"…‰`À¢N…ù]K†£/ÓFÑk®5å¡h Á;Ü]òØÝ}ʼ0`gÕw'WË´BÄo£Õµ¤50s‰T2k†-.õ-L+ ÔŽ‹€9ý.Òù\x¥±Œ–ðqÉŽÖ ŸÎ“4(¨‡´èçá.Œë;žüRsЇR`–$IJqò¨•È0„J £˜Ó…-ñ´ŽÛ¤Ct^ÃYÕe·—–!X¿®À9#({£ÊÁWr:+HÑÔ¬=†®Šà‘E]ŠVÐ7Ö)Æôžíbâ4f«ÿËbì0è@_X;K«oͤL[Àù,í°¨°ÂcQ³ð¬Ï'a4±åÑ6!îÌ,@Q*Îö.n%ø„<óðÆŽ±T¯}Œ\BVˆHà7Q;–ó I‡æ;»•õBj]•ÐY·àçmt/k»I@Õè.ÌÕ…ñ8ˆ3À¬Pla‚*9ªnË´ñ» be¯vÏ1™(ѳšÍ£ÂøÇ3à$]< ¡/îøˆˆI­ÑUòfüÀœqgfè‰.F Äzƒ9¾b +41¹5f&_öüèÆ¾&å;™þYE^¡÷£]ÚÊCŠ…Ž­²rØœ—CÛ $}EŠ$­ Xc-n&$¼•êã-ò@eUg ÷0]qû5ÚQêMN2ŒÍ%.<¦É=ÍŽéM“2}«¸(á^UDÔ³ÙL¦m8+ eƒÉ¸ÁD‚¹€ÓÍpXî˜|¸—hjwÌè¼»7p¼%TÔo`ÀA¡Ef.Æ4ƒ/ðnÊg¯c|+GOé#<½Üí–ÓÓ£¶ 0…IákV'ºÜ~êT˜è5gãW=;lu.|Àˆã!Ø–‹àö²ÂÄ÷<º«Cú³+¼PûcÕÕÀÑW¯iLJup4éNm6ëlµEokMÜSvKGX×7ÿë1—«UùZm?á]ë,Ë\¢êQŸØí'lõÀéûê¤ÇÙ).aÈˇz !aõAƒáy’Å*Æ šçû1¿ß¹æKëHö®<$—¼íhw*×¼éîz*y˜ÀlœÑo8PºÆ¢N/TW¹R 5vêC%ãâWÜV6|Ù‘«Ï ¦ôñ!3±iÄ+„-h”Џ™[$±E'ȃ#êœr.PÜC8± ­æ³ÇÐlîô‰4—yšíº›ñdv’=?~N§3Üó'Bva4ÍÆô dœ‡1Q#^†ê5Ö£³ŠÓlJq—à)‹—}ÍVÏ'gÙÉ 4AÍø‡oç?ü Ø.5Õendstream endobj 4367 0 obj<>/XObject<<>>>>>>endobj 4368 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‹©0EúÙÄU&1åóhË€:<ñ¿·ˆ¡›©w~ðééð$šL0™b‚{Î ¯g¿ü R<jendstream endobj 4369 0 obj<>/XObject<<>>>>>>endobj 4370 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<]üݨ<k )ì^k+ͧ–¹D?ÌØ\‹˜‡—(eµëJ³µ(1Co5ªëEñ—á˜NNqöÍ›ÆÝm@?èÄsÖ'žcÃU y98mî­|Ñ[œ9 ÌÎͱ™KyË8ŠB̾ÙEþþûãìà—ƒ¿Ì#™Éendstream endobj 4371 0 obj<>/XObject<<>>>>/Annots 1281 0 R>>endobj 4372 0 obj<>stream x•XïoÛFýî¿bÐPµ(ë‡e¹ßYv„8¶+ÉÍ0 ¬È•Äšä²\2²PÜÿ~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ùùgò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¤ßB[ :y„FN@*Œs>Û}˜ª¨Í’wÏ4.rÃY³(*1ß7Ô}‹_ñM²i.W²ÐêPsAD±ÚÇ×\þç}÷ášýÍ6ÔÜzÈc»®ÊQ·|˜5k˜¢ãÍ»ÚÉä}EŸ OòD‰KB¹]Ü E5ÈäXÞÍ$/ðhn¨?º¦¬ @KÛ›Lºˆ“:ÑC¸¦íÆý ÷¶„p!Äp† ßg"c^ ƒ7 ™)rh¦»çÀüåûÉOÍ«È^áÒbCvΩý¶ìÎÀíÐØ8U2 ¾Ë4RY åZ³P| =WL8\ã0N’ᆃ¿Œ`ln¤E$÷‡¼Tû¯;ˆ>£SÄ¡À¸XÐ2ã! uF¸Š‚£m\N4Òå¿â2Ôä¸IW²XrÌ­…‚®Âø°Þ–bRȳ ÷G76aVPaäÚYçvTް½‹wÙ¿¤aÿÒÉŒcl÷ð_ 7Æ/êílÅê^n_9ù_où—Ý.³G´»ÛeSÓåÙ¯gÿOAiwendstream endobj 4373 0 obj<>/XObject<<>>>>>>endobj 4374 0 obj<>stream x}TMoÛF½ëW |‰‹˜´¨È®zLܺõ%E9¯È!¹ñr‡Ù]Šá¿ïRr¥C †­7ï½™ï«‚Öø)èã~Ênõi¿Zçk|ùö+4tÿüÛ|KûÑ»‡ü‘öÕ³¦}y»ÉwôåëËŸd|Eu`®¤ûeÿ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½xªMyª]¯¬-,%¹ÓŒÖžÍo0‹$ð ECdWk7ªÆ÷7dkªŒo8È/iƒÌs5b\N/9‚Ä@-è:™áU3öySè$/ÿnпLÉÃh ºSÂë<•ÒõΖðL5k1ø!ðÖÓýÓû÷dúå.‹gæ7°uuûÄ#͹Iñ`¦ÅÅ‹–3åÐûh+VÛ¢Ëàô8Lhs¡E‰ÊŽ&©hÄ”­B,¥bjØsÀ›øœ>ªJï´Và»+âçv)XôBbecRÀì uÀL¦:_€Ž5×®dÄ»è>u˜cÖ.«ÆAT„@®UÔPŸé0XW©˜‰ËÖÛïšLD¨ø+0?y¡§KAsº²©?±é¹ÆMXQ6ÑBB•ɺ…¿£ á[Ýçi‘ê Ã):\lWË(²”„5'êIµ„ô6Øè·C£"Ù®ì¹ÇR릂ÝHåà¿¥|›“¤ÁÒ`é3øá Ž3 ™Ú³l'XBÄ{ìœj&êüÓ6ï­n{²#ø04ÍL<\†Æýr ¢§K—7°Sí1’ŸÍ Á¯oÿ]:Ÿ"-[³ICàÅÞ÷Ï»ÓÞ¬·ùÇ*vE¾™Ï°º,Ûäkú]Ê¡c; _jÝìœýª×»úßûþPzÓç˜b£©ìWÿ¬þÝêendstream endobj 4375 0 obj<>/XObject<<>>>>/Annots 1306 0 R>>endobj 4376 0 obj<>stream x½X[oÛV~÷¯ « 1û¤}ÛzÓ ‹¦ØM”üBIGkŠTy±¬þúýfÉ3tÇ[À‹2†ç~•þ¸ÈÇ¿€¢”ÿo¾çã üñáÝE”z>¥IêEt žöDA/y eä% Sä‚(¿•ÂŒóåÄü`à3(ƒššÌ'¨µ' …5 ¼”R!˜S‘`ôC/V ¦Š:Çj- Ù¶hé…” e-r4Ð(bÁU4PØ ›ªh Ð_ªè…A<Ñ«i ""<òjhyF txs…þ‚3€ÏÁ_ B‰¿‚&K›ô L¼YJ¡‹>{a ½‰P ¿8V,#J¡iç0õ–”¥Ðx°*†Í‰P ‰.ŠQ¨ð)1ƒCaO «$tD%a–TÑC* yÅ…*zH Cm^›0…JBGzes¨hNàr‚J$jK°?Ò6—ôÈ‹&GÂUäaAMs„“)ªh Ð‚€¼6þ~ŸXΠPaEƒ½‡‚r¨¢Âo”ŒC t¹àrs¨”j¼èK&Ž ×R¢WÑà]øÐ«PE#Â~2áÕ4ÐxÊ«i °q®$kè‚3«ôZ›ç}{Y…R6¨µÑ¡ŠmÑÞæž7Œ–ˆU<¢¶éã´ï«W(¥w@­‡*zÑ|1YIÌ+É[Ÿ2(”V4’¨*…*(ªj«h óóBñ*Faz"½£^M^M…$„jä•öŠ‘sž&ó„mBœu$»ã³;#¨i ÑœÅ:TÑìì^EÃ$ŸÌñjh¸àš%‡ÁîE×0Pä6é)6YÓìl:E1SY–7ͼ0|²¼Žï‚ï…*ú@QÈV84 xA‡AŠO 1ÿµKÖ4P¬X£ŠŠeÉ"Ix} q+4ðy‘ˆ†lƒ8¯¥˜7P4g!…¿ U4ü•IãÐVêF’C©¾¡7?B­6³ˆÞ™¶ÍËjÚ¬nÍ–ª’>çå¶:5¯V¿+‘ˆºO"2Æxf8Ì.1yã$…ÈÙO%$EÖæ0Â/¬wÖK¦·÷fÓµÙº0S%Îî`Ñk¹ÄæG°ì×aâs\b1úsÔ¸}šÎå©pËÇ—Ær¹_†1¿ÿñóOïaIv8Fœuv²3u·a_ÚU5u Ǩݛ‘Ny»§_ó¦Ëº¶Ûæ[æd\}÷mßæ^÷®E±uíi'ðzÊewÙ‹*ø·©‹—Upn÷Uù¢*VW?¿¨ü/+½[Ÿÿ’‚K¬”dI )÷±ižª,Ûd—˱•ŸUý¢¦Mu8æ…© Q'ãy½ì/þ·fÆB»óæê|sÊKÊÊ-½ÏËwŸ9p®èòb+cî”ßxæÞ|uD}ù¦í}jÅüíã_JËS Iзö×L°.þŸUgEkêcýÎIçÄc ~d õň\è îÄ|9«ûbŒ¥ >te9Ì^Ók•¼~2?74O,“´_1Ï]&²IgïóM]5Õ®%sßš²‘ÁEh{cXxty}ûŒá55µãÍþ½Äeµ–ØjŸ7´ÙgGd‡¶¦ÙÔùÚ4$»­k²)pg\o‡GýšæˆÊ»ljýXˆY|ugjœYC'Sø+µ7l õÐS¼Eúª_ë}#xI¢+ùOe~OE~kÈ”wy]•S¶mV髾ƒ¡8+š NµÆÊÖc¥rÈð&‡ GBf߯O.v>ÇÍ[HE‰©Û Ñ*«–§—±»œìdYkÏGC¹>lŽuuSg‡×´¯NÑ¡¼%Œô¶ð+kÎÔVtcÚáœòh©‡ 1hZsœ0«ÍßÙ9Sö4ùgu*‹*ÛJÀŒ*iæG:f›[Nê®®N§ÀÐCö¶9™u{¦¯ Ý:“Xw%KÍKX›Ñ6¯Í¦­ê3[ o$Ôd-•Æl§Vã4¹„ø4â° ;âþóCŸ37ø¹®\k.9ú6CèTyÐ]Vç|&¢&š±Ì·0ü›ALÒž:. \ç“"«z‹Œ"$h´³= ûc= éPÿWßÿɵï¦gå#áÜæCÕÈè8À´ìˆ©!¤ðÜÞBܲµb“d²œjºã±Èaw¿ ä­ºÂ>—™›èCǸ ý§ª¾õè=·q‘•7–kCµá;mZö ߯$ˆYc&›Öú‘ô¿XÌð*EŒ›/³ñÌrµëÑ/îY´î)Pˆ,¹6—ï2PuÌ7·\»YyæÃ¯„ÁVïðK Çoé-}{}ã‡?€aØÉ­D,èíêâ?ÿIgÂendstream endobj 4377 0 obj<>/XObject<<>>>>>>endobj 4378 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 4379 0 obj<>/XObject<<>>>>/Annots 1319 0 R>>endobj 4380 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¸¿±rrèR'5·}+WNðØÅ½1÷ŠÃÿ3™òì0‚“G’hÈO®îŽþ8úÈe^endstream endobj 4381 0 obj<>/XObject<<>>>>/Annots 1326 0 R>>endobj 4382 0 obj<>stream x­XmsÛ¸þî_¹~¨2'A/”d)_:9¿¤nϽÔv›¹Žfn(²“­(¿¾Ï.RL}noÒ‰Ç1Ab±ûì³Ï.ùëÙTLðo*¢%ý$ÅÙDN°B¿¦ôëîýÙl=“K±˜,äD"š®äÌ_åâþìôw£‰`™,fRÐ5.GÓ-´–ヌɉœNG³Éd.ñùC¤¸Ÿ”¨£ÄQ7"óÞdVèRØ=nÅ…‡¬Lõ>˜ìY‰\Y«Œˆkç4{Ñžê¼.êc½ÙFç›7RÜ8£•®m{V˜¬²C2|¼óïÊú€3ŽÂjvã»T³ƒ‡¬ÞÓZ¢K›• ¹f±GOmþé;²6¾ž®<ð@IN"Ôf¶˜0T]^ÜÝÿrô>Fì>&•~ÓAÇJö~§óñâê°Ï’ýi2TêO%hÇ_óÁ±àu-äú\ÌWD‘¨ãÌ’I8Cù»|ø«£ ³ÑçéàµûØ~í(¸æ‰û`¶Îλóg/t…”#›8"× Ýc À-Yôô¼Æµ·}>‘7£¸±ºßÄDÚØÈí—Ù7P¥µ :îF3¹XÿŒn³Z—06QÌlðñËïsÒ'å„$/:]Öï¸e”ÔDE\¦¢2º¨¬ ?!?Icc8¾žˆò5£*ŸÈ(ÂU:HR1&·x‘`VŒ>}Þ‰–ÿ› ï•/Ùþ Nx#!¾*ëQ4óÖße‡Ã‚ò<{Væ(òØ*RªžU®«B•–Ökˆ¬Ð;qÿñæ=ÉXügy¼ÍAN åé7-hý€ŸÆÆ÷Ð¥fËø´…†0`“¸[% ¬e®ãeEÅ—¬» §hC»G<»›í¸ØX†`=ƒJ‡â9‹é@)®p*d$Øä$ûèú®@š'‚üý—?®»ó´.ãªÞkÇ‹¦$ïˆ!F•Ô¨T­®Ð-DŒ-§!ã¦6ãÚ$ãú=Jñy‡ôíDSS‰Ãõ¡°}5tÕÿ:‹§43­ýp. ‘ÓŸÛ[pI®K%öÖVõÛñ+H”D°ƒÎK,Ò¶ñõ"4âþ,’Ëå9QýCfwÔµKÝVIèñqãuˆÁ#Ä_åq¢<‹J$8Ív;ü¬Ç+(ê= 4޳+C$“ŽTè>$‚ªh(¥iˆ‹ÉñR‡®‡àWÓFÊ©ŸÕ:¯Ñ3áúlò`Àé£k÷8^’Y*xNœwE3´Uóáâî 63Õ€– ‚²­‰QI¥RiMØÛ&øRªÏàå¥'ù)!ÙH­t [à9Ä$‚æ×|Ì‚HæNt5P%FV"Ôïû᫵I'2j¿Q‘.S¾#÷]ô’âîµ§"¥F%V›£? êTpl\Θîl–€øôPŽü”šJ˘ƒ#ÔR‰!ÇE¤ ®֯נá™7á$®†ì÷C`¥ÄXè”}Õ%}Á-ägŒ†1FÄRPùqÊc{ʼ†î¸†ÁéíZ·ï,ŽŒ KºË7Ä"ÇDäGU¤^rLÍ#{Ä,Û[§&ôB´m_X»hÇ×ë@·ÆÐåœê<’4‘Ï\VIªB^¹.ލ¼¾u Þü7ˆÁÄMô>Îë“Úpp6¤ø³>@EÍÐ=Í5 n”ü×üblݳâòÇ1'âžkÔpLŠkž˜è©=—ë?Êì3· Ó$ôÚPÓŒIœ»»zwy{åZ_b7†Øœº‹‚vyTùœ]r«dO90T0BâjuÏ £/ ãÑ)‘«)»aâÙ—˜V7U•gÃv¾7*W1¤,Íjk²mÃï@âa¯°Fý½û:‹mu¹ì-iÛiŸEÝ»À ­<´9ŽM—ÐGR6¤ÂÛ'*´$3IS ÄËç{íÉ>.é ÌU ¦O« ÖÖŽg-QË¢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ç’±rFøï6KŒ®õÎb‡U%MÑO‡MÈ iÚÓKœ–+~5}‡Wü¢¬`fîÂéËd˜±ƒ-*|r±;z×”¬v"w)h Ϲؙ{ž«¼ö¤=¨¨ÓؤÒÉ1Æœi»¹ÿI\Œ‰ÐÐqŸ³Tã,S4Á™La49ö ÂดhðË/©JòºRÉfÂÍ¢ÒÆ†÷ùÀÐ_‡/3|½YD ±\-ä’‘"4èuCÄAòç!: Ÿ{Üãs¤B;›¾ 4X÷qÈO“&™XLñ®¼rN¦KZ¹z8ûûÙ¿ƒúîendstream endobj 4383 0 obj<>/XObject<<>>>>>>endobj 4384 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‘F1l ïÚ/óöY‹4À‹[ïKfѾKÞk*GÃ9Ô¶w-uTáâ¿×N¶/ÖWY%I”çäi*ÜúÈ·"øüM&çØendstream endobj 4385 0 obj<>/XObject<>>>/Annots 1338 0 R>>endobj 4386 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 4387 0 obj<>/XObject<<>>>>>>endobj 4388 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< ¼ÿðúUé…Iü~Ù˜@ìAºû$<ÜóÔrÇžq¼Gñ}9>øõàéNîendstream endobj 4389 0 obj<>/XObject<<>>>>>>endobj 4390 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ï_kò'ñendstream endobj 4391 0 obj<>/XObject<<>>>>>>endobj 4392 0 obj<>stream x¥VÛn7}÷W Ð<Ȉwuµã¶¨Ä©SšÂBób  ¸\‰1—Üpw-­ƒôÛ{†\­¬Z‰b¶ÅËðÌ™™3óùhL#|izÆ?²8z3?¥#,ö¿ü’†W?ÓxBógÏÎÏiž…ýÍå`–NÒSúàݦ%iDU©êxþéhx5£1ð•d2Kg¸4¸¶$•¯…Æ_ƒ'¤kÒ•®ªôÂ(ª5þ¬·NŒºW†„”ªªœ§¼±²ÖÎV|Nz%jE‚ÊÝÓ'$Låèκµ%Qa³Z‰Ì­#°”^32àa_²Á£‹ ‡K%µ0t§mF.'·ø¤d 4¢¦¥ª«îÍŒ€§¥×e­í’Œ°ËF,üÛ—ÃË—/ãÃt;úªö¬oãíµhƒá=Dƹ»ŠŒ¾‹8¯—ÚP¼ÚxKŽÔ±Zð: õOÞ§t…GÕF¥Q :§Ö5´÷Ñvî fô—”©\[ÍÌÒ/1v#:O§¼ Go’N§ø” B|éoÓ_¶ÐeÙ,Œ–á:Ö¨ûŠn·Ç¿îÝÙîÿûÜÌÁº¢ÍI{ò°oâkø¸K¶$ž¦gg¯ÕëÇÙÁÎJ®„ÕUAkט ù3H©.vÌæŽñëÂ{+êÆƒäBX«ÞymkåK¯ð{Ÿô­³!Û`çC[¯œ= Ïz¹ªi-,òËQæ`IWßgÿââ‚îé·Ž¦sû@`;l§˜Xo±>;°þ€õdüôFš¦ONg(Æ{^ý&ß7ºÐFxÓ"áà¯òæ4z‹l¾‚ÛÀW.d¨—µówÛŒŽ€ì½UëŽýLxqŸ\|Ù|e÷l´¼1;°ñÀ àPMû<ºâ2켚KóL™t¨ê‹áž¤³¹^r'šRÒÒŒ’ŠäÿÒÝÓWÊ>Îb”»€ ÈdvBõÚu*W!T¬lƒ×$q–éYúT® –Ð9a©±"Õ1ª…¯O€¿–Ê‹¨¾"ÏY®^õ¯«ÏMx—MæP|j½–(™²ñÐøNðEY*á¸Úª;TiUËÅ¥ËÆà%TëVEá ­(´“ØYÎcg™A®Þ4Úd|í©«ÐÁZÙŠ{Ç~þ²¼ÍÒÐÒsä&„0è­*™·¦Š(\k8EõÐÃ)è_ (4“, vos©uyÚ:t])“ïS@ †Éá8—^·„—¼r…D`¢3ÇY=Rb D¹ò^eTCë¬þÜ BÇ\0?à4k­(8, Û8‘ ÖÖä6_`»Ø*@H€ÐLÙ®Ñ  h§’UÔèÒ¨xî/éä•tE©¹³’ðu'˜´ã±G€ÌÈ2Æï0FÏÉ䌕OÇt³;[DÜ 9ý:ÿ‚oàæPÀÃ424D`NØj ¼¾}ÿ>ºär¤d'"âM(3v ¹Š¤§­?Æ"„»s%,FÛ;n ¸5fŠ]©=VK©2…P5”CÞ`¡@/.dmaá«V<Ò,ºÕ÷›ÄO± x>Ùw‰Íß8ˆ³%ÐëÒRJJävPHûÿþY{Qâcr=l*?4 3ÔVš&ë=}9•¼ëï»íñ¾£¤_I+×¹Ž&~ê{m›Í–©p<ÍKýƒpƒ™Ž›n:J{ˆ?úÚë€yxuÞ ¿ãóYz:=ÅÔ?úëè?>¨«%endstream endobj 4393 0 obj<>/XObject<<>>>>>>endobj 4394 0 obj<>stream xWýoÛ6ý=Å¡@1ä¯$Mƒ¡C÷‘-@±u‡m@€‚¦h›«Dª$Çýë÷Ž”dËI÷ÃÀ°%êx|÷Þ»Óç“)Mð7¥ùÿËêäûÅÉ$ŸàbÿáÖ4¾žÐe>§ÅŠfºx=Í/.^Ñ¢ˆ«&´£µ””IR¢ªK•÷ß>n¨ñ3»7ÞK+E9ÖF–M¡^,þ9™P6E€bT”ùpªèƒØî[ b)ë¯äÞòÓãë3âÇW”!¯l>oó-,5^ÑÎ6ŽÚ¨¥^:áv§|‘¼Fš»¸&lIëœòµ5…6küª*a Ò†ø¦—N×o”¬±Vt7*­(N Q¬ §ç”Tyžß½Èi±Ñ¾;ÜŒ·ÕeÙ.N9U¶hJE¼‹(K»IK>ŽwÓ!§kë:®Ò ‘Ífù|޲£çÄQ>î*êá}N+!uiEÌgßϟ€tÖCúçFÚZ÷‰sÛê°¡^¾V…ò§§ÚY©¼'»¢e£Ëå{­ÀŽ|¸{Ãö:'ºÖ8Ù³o}€ß<;M„›Cß ‚vKÇ[©±—z\ˆ ¦ã¥_JµÇ4Òg^ïºH³'#Ñ w9Øç&šäOŒÌÑt:™^}mË¥6ãz6Ö\‘+‹+ºFF%µÏBL¥Ap@ͦ³jJ¨5yX@¥è”1â°€õžÊŒ²—Š×yJmI/Ç\{àÎð._ð.çÇRoÅ&÷ÕÛƒ°¨8ÿ>êa‡† ´J¬ª”€Îð“ 1rkOó¶ŸH§ØMáTtûçÍÏT¨Zp>*«·4¤ÏnW–Xü,e) vÒÑÃüFÏâÖÝ!¢3ÅýÎUÑŒoL',îôºY°ÆÒ9àŽ]ÛüÍ>»R[5nÁ‰QΆƒø¤rÞ c ܇½‡ëØ;¸ƒªn#¾NA¡ÑrNìµ(ù¢…ÎqÁ©Ïæé"ž=…÷OiÐ÷ VF¬õØÎslŠ kúI¥mæè}³VRƒœíN«R¬{á!š}8ò4’˜§ªóÌÕ"DÍïé0J#Eœ&:å±EUÊp‘!hd€€pw3øè“bà#ãÕW†³HoÀmâ Z´«Ø–ÑÉðuƒ¡·<<.ÖX Sã,£…7ŒXªñõô²›Ç^åSJe»›aVÀ73E}½Žƒõ“+¹@Õd°àkë¨êAÉ&0ÏÒ¤…¢ËÑŸ16 jf«¸¯8Ÿ¸mýí(€Ž…ŽÂ9±qƪk²? ˜Z—"à‰Ê?y¤´økGJ¾m1ûã×›¿H™{í¬ášÑ=œ¨#~¼ûñã»›ï?¼ýð÷Ç÷o¿ ±q¸{ «¡vÀg´8œ!ò6ëˆff¸ã¿›ÓÛNÛ¬7ˆàð¾(áwÀ°lx–:là(8ÜDA,? ãk¶TÐ#NÆœ_äF][jYŒÍX9ÀY˜…(ž÷_öÌeþš²óØ y|™ÓmA˨>œiÙá¼Âƒ*Dr°65p§â“ÈýxÂט«Âgv{¯õ̺vÒÃ´Ûø6ºeïmyWá©V€uœ!ñz08~% [˜zS…½aä\£ë£¶Ò_ mÆÂŽÓ cÛ¿y°ßÅ—„4]¤™ÓߘK°ØDP’Qv;Åy] 2éºØ…UE#ÙŒ Ìø‰÷ɵ1R©z Ž:lj~7ÂY 5 ´×ÛâwóȧVèqX»—2‹¶Ÿ3ŸL©=#•z’cä·†Ãs¯`ÜfjŒQ L‰AÁG++,‹sÊ2Ù;ñø‘ĆìíÌn69ËÏççt1»È/ÙÔ¸ùf³|B?ZÙ°ôÁ¿ä7xOMk³Wé½—Ù<¥Ûôæ{ЛPçb‡…9Ž7»–ãçÓi~y‰7vl2›q-~Zœü~ò/knyendstream endobj 4395 0 obj<>/XObject<<>>>>/Annots 1395 0 R>>endobj 4396 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 4397 0 obj<>/XObject<<>>>>>>endobj 4398 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þ+ ù2endstream endobj 4399 0 obj<>/XObject<<>>>>/Annots 1397 0 R>>endobj 4400 0 obj<>stream x¥XQoãÆ~÷¯¤=”‡“hI¶uNûÔ¸q⇤hO@^ +r)mŽä2»äIjÐÿÞof—¢Hû®i‹;µ;;óÍ7ßÌò—«%-ðoI7kþŸUW‹t'ügÉþþÝÕíj™¾§õâ}º ŠnïÖço%}¸ºü^ÑÝâ>]ǵüë7› ƒbÕíèúqA÷é m Z-hýõ2]¯ßÓ&—c´É’7¿¾Ýü|µ ù_óäw¦ÎÊ.×ôUuÚk•k—î¿­xó¯Ñ×ëkúѨ4¾¥?ÿøá‰®Þ½£\g¥rª5¶ö£õ¦n©°öO/n•{Nø×ãóÛñ¯išòêëÇ[b' š#–ùê&Æ’löš*›w¥¦ZUšŒ'ß5MitN7õŽZ¬ðÎŒ*)˜æb*yvŽH(7Ng­ù¤SúAL{RN#,Ÿ9³…á¢s°êÈÔb]Âçð'ýÞ§ºu0‹¶/í3ÅXq<Ÿkk ™Ã¼å‡ß~ÒîÔî9–‹9»}¿`¢œ©„¶¥Í> $¦jÊe¶a\`o‹ìTÔZñßiß•-Û?8Õ4¬0À3sZµX¾=чŸž¾Ki³gtƒ‹°*±ôž«²²`*êä<öÁzO¨À&1 ,뜬àwIx¢°8;ýK‡ ˆJ}ÔâãN×”ÂÓÞÇÌ‚©™­øšÒS;rŽ"dëZRÁ]5{åÍ?ÙŽù¹ƒ¯[)8J'ÛU—äe¸•ÄŽOMîâ¨Y°pá:åV ×ë>%T[qè2ªkmÜ3U–§‘· º:ÓéõPçó9c¦ ˆØåZ_@仸´GœYß8ËÉÿ_1è/3ù½íJ°g9(×êcKb9û8ˆcü-4E²`Šåx£e Zí§'ìÓ/-‚÷/iïOu«ŽÌ³Ê^W`ƒÉ@:f•ɨJ»³ÅnØBw‘àôÂkìè ûÄsG1q(`³%+Q¶'å餲 q¼Ù ýúñkâò/Ð!æ«5—ü]ºLWÁÇ¿v-¨ ì5P¤!qØx+KØq®S®w•XêX”Y`bjüT–}ˆ£Jb:Bm;ƒüªšO]{'èdìWjÌÞž¯ä-Xå¹a ƒÚòéÕè:gua\˜'ÊítK¥ªwÚ¡v¿9aQ¡ A3>v—¦ÝËÑö ŸØ|jÆÈ$}ëTíQ'•´²€F@yÅÖ?4›?¿øxœ.NFö1;f5sœãŸX›gïÞM؆!$HêL×¢§ÏoYc› $åmç,è2ÀˆÍöÀIáôlûúÉÐÓš2 ùÙ3嵟Ø|W戬²PK5 ;pPQˆ—QŽÂu•©ƒr{Û¹L\íSOÏÉÃŒ02ÌH·Y# 7‘Û«O°bù¨W±ûŒÿ¼%/»‚×=í¹Hæ=i‡~"À™‚9{àÂÔ-87Eæ¶tÅ|$oJȲ>*ôZýÇéa›¯VéÍ æ±<ù=ùƒÙ§žæ š;’=G— {#›¦0eù+3P˜¼F·oDjFž¢èaª`>KVùÖadA¹LU²|®ãV< º¨õ>ÅQ3¢Ä+òm·ÈRÃ~2-Üq[„™ö^9° x@Jä¨Ë¸ž B¢¨´ö#A´ÙŸ°h6rˆ%ÚàVmaû`ë?´$ùl­ÍR;Þ^Ö¬i´ÜîuнK'àtd<+eޏþˆB;ëF*î$S_\Ôe¸´sJ°0eg¿GM±¥­CøãðU±nzœ-W¥·}ç‘–ÄœW*ï£ü¢€‡d]¤eƒ°"qûæ^ ìcŠQt}G‘È8]˜¬?’ kžçïÁ´‹Ÿ…(*ªFɨRh.¦Ïë|ÚÅä0ô0žöM0¡ ’ÿwÙ‰mjNì™ç2ÌšF>_ÿõø'¹FXg`uPÂ4"¦ÒdiôkºRqé ä,lYÚƒŒïLèþó/«PïÅ‹8ù0î+¸%åIt _”6Òý‡Áv"F1øIœÁ¬s¬›ŸM$+´”ç„ë;¦X̧rÿü–9§¹­ænáQA¸3(jO Ú±âÎý‰!f^޹ßG,·°ÃðHìó†èþÀð”~Šn¢3øÈÆWl;d8©FñX._ôƒ¦[üLjYmÆØž€/c|nØ­Åô…‘döò¬/åjt>¹CKÍÚ ¹ŠUµq@®o½~œ¥b„4ãúÛeƒEŸ‡(‹Öeòy½Ѽ.ñ-«“ö =ت5ã-®W˜‹1ûATž_nøöÄwã¸0 S¼¾A£1ía.’ F BeÜV *2OáBóÉðMîóT Ê„‰}6˜;ð~)‚V¸~Nn_Ò¸lfû*¯WzëßÛ÷sÖä©À½ïƒøI‹„u5ÞçànÝ(ã$é˜ÎwO±‡×¡Ù9]jÌ}¶ûx¯]-nÓ»›;Zßܧ÷,2K­ðÆê/—nqF aíü}оÓ,1WÊEù’KÍÝr™Þßãæc«;ÞøíæêoWÿÿ-endstream endobj 4401 0 obj<>/XObject<<>>>>/Annots 1399 0 R>>endobj 4402 0 obj<>stream xWasÓFýž_±Ã`ƒ-ÇNâøÐ¡ÐÌC‰gúÅ_ÎÒɾFÒ©wRÓÿÞ·{’,h Œ‰biïíÛ·oWLé§t6çq~râ7ü1å¯N®Î£9]ÌçøÌiz6Κ«ŒîN~]ôžÇÜš&7¯h:£EŠÐó«+Z$ñ”ñà"šFçtM_œ.µ÷Ö žLnÎiŠ;ø™ñì÷,’ÁGs¯ézDwÜ~ ²{B{RYF¦(ëŠR“áºÚ8[¯7¤ ÒÅF±NèA;olA6Å׈Ӌ`]DoÂWªH”K¾¢T«ªvÚ3. áT’rš|]–ÖUˆmŠ8«S¬åüpɇ(¶Eb*ü¨2üœ—&S|d å*vÖGô›Ýj QÈ\K惧!¬>$dÀ0+ë¢Bâ€aÖ…uQHý%'ztÜeÇq/g\™)4ÙRpn”§•Ö…$›D´@P§•G©u”¯Vxdݰú W@U¡P¸ð6וÉñMí´²|rGeSxrj‹ªl´J´ uŒè¶@$Dˆ•×#ÚÙj@ß‘-ð±UE%ÕÔ•.¤¼¹MêL㌥us.ÀÅÑBÝ8•æ¬0¬ ÁmŽs€~P™0 ?É)7ëMJÚð ­vá›rZL¤£ùG©šƒüùefå”ÛíQHWq´F Ž™hý¶"¿±u–@ÛÞòy…e¥ N⨠PoÊÐ è€ðãÌ2ÝÄ$šÔ±ž}‹¢èÙßÇ*Xe6¾æU¤;©ú '(k…£©¨óˆC‹‰¶ &"¦ ƒh Íl*Ê¡]*Ñ.­3N/Ô’ÎÑ2Ç]ºØh¯©«ö¡Ú¹ícgV’¶À~"Xm ¦48vœ½Óµ¾5xBñF••vRš¾gs6v¯‹P‰wÆi¨ì!ØÄíë“õSÕ{îÑ`:c/`}Û¢r6Ë€rò¥Ž ²Oº ¡îœ Ê¶jç¹0µp»"IrrÓ9dz£¢>á~@£Vqmü†™É)u6‡¬Ñ%Mtœ©€þHïaM'Ó9 Ð#p$g© ´µ™– ΋þYéz0¸}È–‘Eî؆"ûíŽ(‡.*8»Ÿ9}ÆS‹Mìu(Ê)]afb²Í8çYtv†«d0yÑ€‹6Dãñ˜î˜¡^z1i âÁð€x@%<%¶èÙ°MPóãê¢`ˆ/&âì¼â©Ink³—ß?kL4µS‡û5†YÚ¦¦ÔXÒ8‹æóK)_Ã侌@ušÞÏmFäwùÊBè:ÅÌíKNÛ ' µmŃ*ì'ü¿5䜾@oPßG“LJvþù+ÅÛ¬‚ËbSc¹Ô|”ɽz=¹~ùØö½ ‚K,™ÍÙ‡à¬<Ù3]a«G$dοd˵1zêÝÌöP ¶P)ˆ ]Ä£G¶†ÌÄùpÿ]É·${DÜ<¡’‡°ê0ìvk‰èŽÝ$EŒÍ`å)œÆn™ÿö®¶üÝnÃùŵs@9Ûm:¢a¬†ØÉ¸ÚŸm1†îphFg~0¢4¼~TÌE³ºu6a3òuŒÅ7ý¢º` sܱ֔Nh¬ñ†åð?í;Øe¦b©û³¯¬Sk¬ 7( ‡c¿pÅr¸oÂÐAHBñÉLr}– ø¦á³ëÔ÷•S]ž`dµ =Ùr/-öIUÎ<âDôÞrø†ðg2¡·´Îì ü>(g°mµêùñ¡$ÈQaÃþ{ ÿÁ4rËÁ]©rœúÁÙûåp9xg7øo(yì[Yzý¬ëõ[„v S/FeS½å­'…"wà‰·]ãÜœÅMakÛ:ƒ.‰-ö‘Î ö Ë—2újãF1 Þ»ZyòÓÅi-c¢Ö•µ÷}/ì‰Ï1¢R­eù@þÀXc¢ñÞ¸Jk/ÝöIîù¦ðí ‹í}0ƒåC,˜ÃvƒUS–1Þ@yé<¢ý¥Ùß&7Ó«f}_FSšÎãrwägö\ò·ã饴ÑׯŸÅ„°pÿz[;°Þg–î¡ L(Š®GÅeÉÓ6Šå6°ÎÄ¡q±`•‡Y·ëº,ͤJÔD¡»pÛѪ’fŠ÷öoÙïÙÌX¨Á áÓò:ƒšâM¡oEáÅ gëjÞpL;„Äe ÄØ{’ƒŠùKPN§z‚HN²£ðÛÆ15Ëa»4¯A£æ=,õCñ³Ìa3p¶,˜¡hHÄ`#é›V(Ûϧ6ÚGHß:ð Ãk¨³X›—§v¾1gmîÒîhoFÕG â[Ã/]•ÔåÑ73»N}ýZWÄ·€~/ÊëîHØ:zÂlu;½¼ˆæg4?}‰xY•ãYtJïl\wãŒÃΣ Ü;¾ vø³×ù‹é4›¿¤<›ó£ï'¿ŸüÉÐ<Þendstream endobj 4403 0 obj<>/XObject<<>>>>/Annots 1401 0 R>>endobj 4404 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öþCã™endstream endobj 4405 0 obj<>/XObject<<>>>>>>endobj 4406 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›<¸Ùšà|‡ä› ^lÄ/‘%N¨Ìfƒ3.»zz'L NgÌå>›e7ò½i\.¯û•Ÿg‰ñýC¦³»ìŽ+žkñÐ1ÎEçÊb„w_еÈÖÀ²í.LkZœ¡_Ù?:·5%°‘øÌÕZ–Ö„•m<3ùŦ,÷—£Ì™÷¦eõèeüÖVŒT>X)]åZKÔ[± üì¶(k b ¢Ìå`—Xp‹A7Àš¢È è´õåÉ‘qõ(SùyrB˜{r,W̉´âö‹oZù|Ô Ò)­’wE€¹™òutÕ¦´¤êø¢¢«9©T& ý¸nÔJN^*ýiu'’Jƒ³{HdéËÒïz& Ü/³Xû°(ËÈ2+óaj ‚S=îÞH¨€eðUJ¸j'5ÿ[ ø1»%YgÄp–ÝÞâS‘rdD´… ‚ šõð$%8<èêÆ­j[pßáá™Gé=&x²çðÕ››K¾6áÌ Ÿ>_x_Æ“¼¦šâmöððS¢Á%U­À}ˆ»„=šà€9‡­HnP|×5x|$:8 >Ñê‚ÝÛ€;†òêBGŸ’›Y¸Rµ<DÉCÙÃõ(Ê“Œ,¬Üθ$6Í€& ƒ)ã!ò¾è‘)\ˆ¾FñÙ£D™ÔÂä¹§f‘ Õx|p+W™¹ª$“gÚÝÑúÖ{¬„ñ-]› ·q´´‚6£]½3& Q¯CÅS]-i¢TŽ%Lë&‘OCµGo#Ú²CÀ¨ "!,𠢊ð˦¢¢§G@6™üêŸï#>'gž í åq«`#ˆñµr­ÉÑ&åýËüùYš6@ìcÏz¤'G~JÞc÷CY8r"‰½ïÆ4´HcØäµ~}ƒ\Ò^Y¹H^NËMÐñh‹íè‹ã8_<ÚmN<¡ƒÀÖêŽ2Úùð‘n¹síºgDÏË ~Ó™¡(0{TôåÔRÙÿ1“þt ZAÈ*’žp  Áü‚†’2WL1›õ¬p8VÃíU50qÔï“ÝÚåëø>ÊŠ=@ åû(˜Ú® yt¼º«Pâïßdòž†}FG|q–Z8+V>yÔQ™Y[r•3‡ZŠŽ'D9ÇM.à|ÍKõ‘bŽ¿¿üÄDÛÀ0é?Ú°ú Ô© Î: Å—€9¿W:jÒ =qè³è*‡‹Š_x€g}lw.Ò-ÎUO½èAÚêô×®+‹pf'¨ýYg´Ž³y ÃBh8œ4Ö¶“Xõeà]œoÃóË?dþîÝ(⦅ÂL(R›e®] ç ² 'BXÀá€ãÚ©6hÆôÁ_ÌG4Èu êX8áb¶é_Š‘´ÿÒÈ:×"mƒ^ù€#I­W$³ß ªtõ«Úý¥DH“±,KÙÃð7tÒÆÔÈçÇW]’"Ò¶ðSJf{2>ÏéÝ\‘êÛúqÇ%YkÓvœJö¤¼5zdoÊŠ–þrjRÄê´óSŸKa½  ”6 ŒM¶ÎÎóM&>Q×:» éG:(ô©Wò¬“=Ïu !ìÚC‡Êq„ýõ·Ÿ˜u…¹’Z9žŠb;Æ$‚Zë†Ñ©t9ž¹ßÁKGØ¡ßÁOº Ìȳï'/NȼY’N¬àpHœSú£ú1:½'ªÃœŒ 2¶…¢¸ÿa“8ÞBÑ+úôVª¾Ê%¶ö8[/]!;"g ‘7qÇ£øWKï¿b ¼‰w0 ÿw¥†>’ ¦Î‚¿ ÄCcÞÿ^~­ óê鱿Ï®ï²ûÛ{yxœÅ¿Vé,»–|Þñú¬: X|wú]¼HâO!ò ™àb4Ã}6õƒÍ1Wé*§ïon²ÇGL°¸§Í¹Ñß_/þuñ_—endstream endobj 4407 0 obj<>/XObject<<>>>>/Annots 1403 0 R>>endobj 4408 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 4410 0 obj<>stream x•XoÛFýߟb€"8¹hý²ã^×N¤v+íP¬È•Ć䪻¤e!×ï~of—)Ç­š2LîÎμyófV ¨ÿñOœ½žõ£>n?ì‚N®ûth2§aŸÎ¾Dgg/i’Ȫ>MâŽ.ªœfÆdZôåöîU¿K¿^Ý¿üùýñä÷£>õX—øu¹)Ê¥£/ï.n»t}õºK?^|ìÒÅ|üxñk—Þ}‹wŸÞãÙ§7Ý–jþ»¿úÐ¥»ËI—nï~îÒW—{ǽˆMáJU””˜j–izýþâ-½¢ñ0½l{öM¢çi¡éÃÍoc|œŒ[ÇÖo¯ß_¼¹§þcLÿã_çòkÜçÅ'×câ(çÔJ½Ñ( Ô¹)È¿Òò¾̵wu(Ñq¦¬*SxÝ¥r©©Ü¬4™9)ÚF’:J‹¹¶V'4ÛÛ¥zŒèÚXÒ*_eº‹åÈÇL[Z§åÁpš«ŒV&° œ«r(MæÓ3Ó4Ï (~mDp^%IÊ>uéþ—›7”W®$¬T hih^eÙ†¬v&{ÀÓ,c‡Ùy·Ég&sT9œ”ÂÎ0`©± ¼Ÿ#¦Fä{Ϊ¸¬pÚ†}‰­V¥N"š,|)m³Ïl¡c휲¼2VðæP?€SæŒ÷†¬¬^YÃ&á^®bkÂU%)«ýš´ÔÙ¦laJÊQ%WÊ–[˜b›®òL‹J-4À*µ«X·òúïšE»Zì Áä*3©9EWÿ\}¼`¢N€XÞ<˜4´fÚ™K ìwØ$nÉxÆÊTSŸ!ïÔSñ¯’Ö!"3W12ƒ¬×Þ{üúX:4í¬¾µ©20ÄyPY¥Ó¦ÇBÀ….´UYàß:Åhˆm Ì ÔUâ„;!9U‘!Y Ë1DŠIc¸Z8WHÐÊQÿRSìC3Ë> ©HI $@P^¢fæA·¼Ø ¿nTs Ã_&N”g+=Ï&ųÔÜIÂ3´þp³ôZ1¥Q+ ‡Ìz—@ š¦TÑLrÿ¹0ë"¢·f­´í ®S9#X8m {@à‡w„=\÷uZj=r)#ϼBÚ9ÈFº( 4­K®Š¡Yî Ì®»¼»½Ÿ€B^à§ÇtÚì''t±'iЕ¶;ìE(Ñï]L.«dm»S?‚ αR‹žf‚ó³ªô*™ åAÙkf3ĉ)“GôQá7pLKˆ€sXÄÏñaMµX²<ào2U¹‚¥y ”v{¨P”õd¾„;ù K,­ Ʋ(xZ@êñ,ÓŽè¶xT/T”¥9tŠ•ûX±ÑjzñRÇŸYý—>ß(ÀpöpÌ"]½åºâ`…°è¨y8€J–lºðŽðh d“&"©.â¬Jp¶3¹^V<Ùµ>ú´£ÑÀŸt%xË]· ‡í>Û6ûâK÷ÅŸþÙNmf™‰?³°(¦@õ—V.CŽ<®<Ì„a‰M¢ÑE4»Œ?ÑÅÙš Ø…‡äžè8Ä«­RlßašðÔ‡5ƒ#òM¶Úctý”bHE$Q»üãP<ð ãC¿ãE;y¼ÛG¨Ža¥$å“PÖœ]iàð#G²0Æ©cÑ|¢¹âŸ[™"a aC’Î1©h´½KJT©˜c.¢‹¬\ Û=yöµ¼r¾¯sõÔy¢áã–‚kâüÃB`R.b…À2ùȼ£- ‚¬a’lðÊÿØôi²Y1³Ì›<ñúžµ-»í,¹¼ Jâwʺ52Yj…(œ¡§Ta¢ù–†Y‚ã¯U:¼¦ û°õ¬Q’ð“ëbŽÑ¾7<ãº=†ÑR8³©ž3FÐýD&ðaÖwÄÓv€lcŒÍ°rÁ‚ƒéšW,~^Ð/y.XX•£ƒ.˜0£Î1¤±Ì=üShjíeÙË ÆÇÔ¸ˆe.`ÂrØŽØÓޝs࣠P3 ‰“a@K&`jþ÷GmÅAü„Î!/þr&2Ø.Œaêò×>TÀôXn ¾-ÿCL#ºãCÖhµNâ6‘ßr×grñ Pß\…¡\û¦4¯ùEãZ$UJñR!úL†ò’ï0ü* m}¹0É.o`vÀ^ (Â'i{jèÛàJÃRۉЭü4ñŒG˜7½·Ì%bî¯ ñ–'1>{½¼ tpE ·QP»;-ãòâu@¶Â½õ>/XObject<<>>>>/Annots 1406 0 R>>endobj 4412 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‡OT~«#õ“‚‹œœŠáUPX[ÖßDnttI`–^«¦[Ã-w1‚T,ªö=¶ŸG*‡þÎÄ—äîù¦‹èM &©,rgÐȤä‰2úÕí5–µôE˜ÑñµJ”É‘#‡n·cÞƒkÜ$p‚o¦]Ï1š6ôôûÄýŽï™_ºÖw ]€í“x“ _ ¼Kw|L„OkÕŸÈåÿ@(œõ/m’›^%¿1Þ1Xü3…Õ¦i…Z”÷àH!¨š ú:™/H _%È­‰u.:õ×X¾Ò´Ø IsÉQŠÎšœoÃÜ1Ñ¥uÓun~½ÌV‹­×·ÙZ"äÂMçøågW´²¡˜Ïtxú*}YÁ v ɽÁÎgA¹æ •1çGV³Y†ÄE–,füÎ/^ü N‹@endstream endobj 4413 0 obj<>/XObject<<>>>>>>endobj 4414 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œÍWÅB~te?ö&žhÓÚù‡ôs›?j\-—~‰]h½âÞO÷gÿ;û .¦¶endstream endobj 4415 0 obj<>/XObject<<>>>>>>endobj 4416 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[®Æ³q:¤7&CãÄÁÅÊNpˆh{ö<¾'q+ŸÐi‘ñXwP«X¸à&´ÖØÚ/F£ôòs$}2aogGý n4cÊendstream endobj 4417 0 obj<>/XObject<<>>>>>>endobj 4418 0 obj<>stream x•VmOÜFþίEE2'Î÷ ¡­ú¥´¤H•š*×ö R´·ž;o±½ÎîšÃ­úßûÌÚ¾p„ˆ3xw^žyæ™ùp4£)¾g´8—]ý¸:š¦SüsÿËmirõ-Íæ´ÚàìùÅ­²ø~J+œ¥‹ôŒVmÍoNVM®–4Ã+9<ž/Ó%Ž'¿š[¦ËSêÀc<„§®%¤UEk¦ÆsFÁ ›Š©âɪTÉžLEïþº~“Ò•uÄ÷ª¬ þn°‘.$‚¹„0O ü• Þ¨©¼ÙV°mª@ÞüÃïÃ÷ÃÅ.°q¼¸HÏÏ_?¸x˜]ÒÅe‚±•'U׬œ©¶—Š‘‰yv¥™”CÔ6Píl­¶*ty…œiË»øŽ´Í8¥UÎŽ7Öñ)áXKlðá$¤$µÈ’Š;3@ªCH"@g*]4^æ¬2Xܘ‚ Õb‰‡ÄsƺPpÃ÷¬å ©SÈÉã‡HPÇ,™Œèºó)ˆñOÓŠAŒ&÷úò¶ ’jtpüßÁ=ø[qQt(«µm™@/4þ‘§ªm#Ì“«)=É¢cSBÇG¼0—Ïz¿®H³ @jåÙŸRk*Í6ÒjZ¢'ú“Z<,´—·Ú*Úµ‹©À£2úÍr\Ú¬¯¾³ð?6em] W¾õIܧù+9ñ\Vª˜ÒÃŒ\Óu1)Omw_`Þ7äwfKãëIãÝd@aÜ?(¢85Ï„ÎÏmSd*ZSZ)WAÀv@»`µeÚØ»S®¥­cŠ@;4ç»Ö.{ÔÑû]w[glãqH[h‘ѱ«U•Q©ZrŒMS”±‰aÝphÉnE5ö”ËèRt@ä„ïC¯DcnN·é)ùF瘯YUPfœ´ïDµsyys’ÒUÁÞGò-ÁÇó›66¨‹„êa;ˆ¨³†d`N¢¯C¶4ŒAB|[®mRÆjJb"k;ën¯“0àç&ÊFðruéÊ÷6Sr[ïn'ƒh8§ô­ÿÊép \!æ2z= :èäô¸íAç¬oiצ°5Öl"L0¡ ÜqGžaPí5·ïòîí0ç’ˆS®„BÜÓXJ·iªNUDü¼®ÞY“Á€½IfÔ¨îæ¤ŸQƒ×Gªµ‚ëX’Eæ eF¬ˆÒšëÎn)‡æIVÁ? àqÂÀö¡¤›£4zt2;îqè–‚‹n)8ÃÇoQ¿Þ¢þS`š²?4!#|™Æ­#ygi£\Ï>«–r´Hê‘ ºX¥õøŽ] N  BÆaVÞVK„ÊtÓCXâ!gPºý¸ö)ýbwb½fÁžK‰hÏtÃÖ©ÒG#&3Q;DäüN„¤ÄìFgn6F7”ØBjùPäµ3uÐ UmQš½o™ü ò03–Ãkð;bㆵØ!ã}îPû¸¨çç2›r:£·Ê{qèƒkth€­[H[ÑôLXÕ¡Ýu&R‘æ @Žö, êV Q%Ù=@¡†;Ôbpq0vNASš,&O·Ëó-’ÙFF`fÃ{"C67ÉŸÐÔQRÿ´þb·ÈV éÜa­BŠ6Qåe\J2è塃{ÊÔ6*‚§e$¦Š†N㦠¢ú »¯JJì¼*³ÑÇÔFÈ×/ÂWŸø=ý@#Õ+ÅE¿fÏ.–éÙâ «û4]Îâ*,ÉŽçé”~²:ê@\„B•îôøu·{}²àŸÍfÒŽq1[,åÎÏ«£ßþòªÔ‰endstream endobj 4419 0 obj<>/XObject<<>>>>>>endobj 4420 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öÓÙßå%:3endstream endobj 4421 0 obj<>/XObject<<>>>>>>endobj 4422 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À‚;gCúÅäu«ær­OâtÁßg“ÛßgðŸ~5BkÄ ÏF£ìü_‹˜™'S~òjvðçÁl´^endstream endobj 4423 0 obj<>/XObject<<>>>>>>endobj 4424 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—„ôØS Òwê‹P™Ç# ¨ˆýQe~Å£ ²“ ±r'WiFï(=UOñ nzú'ŒyüÀäqÌÖk'ÉcaE8 š`EîœÜÌ8`€ÎŽ¢ÄXHÆÀC÷ùþAÍÙ¶·Û‹ï¨¡<‡ì[ÇyäàVÍ%L;g1ÏÍ8bü­t¢@Î0<õ…û¾´;Q™ ‰­‚ªe΢±ÃáЧøØõìP7yQÇ@K;ëÀ(Çå?d:7J8êŒö¶AÁGl ËÎTÆÃJ÷XïyHÈšRH迵;>1enP¨ŸüÓ¹ú©á«˜'ÃT`0Ê"ïwá „.w L«¹YÎï–ô+ôp€ø÷À:›R0ÆÈf`TgúÿŒ>‘3­Ï3Èx_ªs's 8Ì9”)ùÄ‚³ ôoþæÁ0øª4F+SKòWÒ|1 2à™Â7:Gÿ,óàC1áo™J0£¡íu þûM-­èùâ#…cúš"(=Ñù€nÛKŒ®hIâœc[¶öçGbŠß|þ çdxÃC¨P«th˜±DkEŠxÒXD¼eÀ/6“‡‹ÓãAЍEê¦m]ã ä“+šÞ\Ä×a*åï)ËxD¿Ú¤aÉ‹Øc¦°zxÍßÐÂ8I¯MÉ“ˆQ&T^{5Ç77˜ü±lrÍw~›üyòQ¸dòendstream endobj 4425 0 obj<>/XObject<<>>>>/Annots 1408 0 R>>endobj 4426 0 obj<>stream xWßoâF~ç¯QEr1¶ùîN}¸^›SúÐ;¤>ÄQ´ØkØÖÞåÖëWõïÌúÑ5‰pXffg¿ùæÛá[/Ïè/Î{¾çã ½ôòås/ϽÂ`îÍ ‡ðnâëw|í¿ÏaL½»£OY´Qõ F÷>Ì1È"…ЇٻÀ›Íî`‘Øm}XÄÀhŸ4g†³UÃDä\BI`Z³=<â;z ü'Œnõ|è› ¯"g€gküø‘C‹äÝF·ÖíŸ/ÐÜ”Z¢o¡²Œn!gY¦âÈ¡ƒÀÐS¥ÖŽâ}8 õoçý};ºŸ%˜Â= Çõ¡tžT äEØTfN¼fºZj<<<‡5“IÆ`bSlx,X1+8,÷ðõχϤÚeHuéÆnråq_0"œ#z]cÐ œ¨qعû amànª¯6äâÿÏ%¦8*qŽM¥4"aU‹ï6™ˆ…A²$¢ óäJ±ß*µQ(e]´JÆX†Å”¨WÈTý.ImN*M­˜tD ‰ˆ‘”ØG²GZ‹wSV(ÒRÃV«J¡[*Z-Å£Yý¼Nº)`w‰UXüßöâîbs:K*ϳMÙ2¡®ùÅXD‚šLU{FNªUœéLp G¹´ÍÝv¶«Ãï/¥zþœýu¢?D±WÊM¢OYÝŸ‡Ô«·h{$^¨,6XMd›=VwþÁqŹIq)Ñðà×µlž ‰•o/Áë•þ©²?F Ù.rú-{ú'˜·Ž5¶—/:ºýÚ÷U”ª«|ËPáj‡œÈ…€ÀV³Í×­?êZ–8"PÓ(ɯ`Òp*0‹ÕÚPpV¨½(žG0œV,^_GåP¸Ë”jøO)^HÍÖ¦غv0ݾ ÔÍ…Ñø.æãV¯ºê‚V¿ÚV Ûn¸´ú½+ÆoñŸ$þäÒ¬K2ÓÜ„Û5—]%"NWÒTierÔ1NM¦Zk[âÔɺÓuˆ“—:-Žíç÷Òé„Nƒ- pØÂ<à…këîã×>†»at?¯‡ã`>ñ¦ã)ÌðyW ”4 Cχ_U\â—cÇQ:'ÞÔ•õð®ºui6™B5x“Á4¼ùg>ÆsZùmÑû£÷†¸¹üendstream endobj 4427 0 obj<>/XObject<<>>>>>>endobj 4428 0 obj<>stream xµWÛrÛ6}÷WlÓÉDnlZ[vš§ÔmÚ<¤iÏt:ã! 5I0(Eýúž]Ô¥N“v¦qlË$°×³gw?hˆ¯M¦ü_—GßÝ ³!ö?ü‚Î^^ÐhH7sœ>Ç\Þãƒ\»²VÑÎlaã†*Í·Ç7½LIŠÑàöø0)kf–ä¦!T›2ÚGùïu€J0n³”ˆ¬GV—;©ÆØYÈi‰Šãú/‚ÓÊÏ,øÃƒ°qŠø·EøQ^ʸªip‡%ZÊOÊAÁ`ÿ²tÕžåÑèee?4†ëu*ìƒ9BŒê’.¢%ÊÌxšƒð¨°÷¬Ï†ÿ×=üÿP[ÛJ y”LÏ–Ù@Ž{@¶º"¶ÕŒ(}QíÐiÍM‰9€ÆØ NëøE?‰1¹z2bôT܉ÃÍÃá„VÊ[nMøšÂÌ=rÑ7Z”°L+M9ãt´l‡'|¬}š«¨2z‰š ]Òœ ³-Fµ;ÍÝŸ íë§O“>–ÈŽ´üšÄì¥S$t™Ó{)´'t;X/­^2z¶´ æýeƒ~_Ý·|êš"O1œ–¢ !xïšX7ñ O#©C1ë|†.{P¤Ë=#xô­Ð¥ˆïLì,|w ÷³|€¡¦Ü!‹°ðÚ!!ë¨ Ø^ñÔaô½H µ“j{« Õɥõ‹Ó¶¨ÜÌm% Q˜ m‡ô§½À÷M²Í KÔø1o R3„@2jð Ôh`ž»C°ty#¨Úvµy“H«!á\í W†¬Õ;öº.\08éMLȴϵ?&’z¥L2Ÿî•Ù!“?~ø‚EWãR$Y†Ò¹Ýéƒ À§î@÷Ї4Îs±o—jÛ»”¦¦Þšüú÷×/®ß¾édíH‚íÚ÷“¦\ʲ.?©àD­Ì’“=%ŸŸ’œVîAŸÞÒâ  ½ö–¨ÈDM©ô%ÌÀÞ!:Οôa.+l#݄Ȩd€iãî µR¶`b¤¹wåNÙt®ÊÑ·ß¾Çÿ˜0¹¾ÌªÔü€÷´ ìK‡ñPølwüN¶¨½ŽÈÄɵ¸T+&0î y¾g$æ±ÜrÓP7â~u-„Ë¥íQ´-÷ȳ#ó&"Ìcíá*d`˸,¯JA:uàm+ÐÎÑ«Dú•‘úÝ3Çñ{ÕÒá^`ÇÑб–`–A ­Rmµ7xËK%ZËÖ:Y0¹01"Hw7X,'<î}Áâú¦à A€%ÒA[¥n…‚ÍQÉÒ"¿Ã¤r¡¥g۾ݯ´ž¾ÿîh§E¶ÅÕ.¾ãáyv1¹ éå4íVlËé8b»Ó Ot’>ÖŠî‘Ξ^¦’â=nJט6eïà%-ä}›çk£Qvu…íÑ™<ã'?Üýzô·ê]endstream endobj 4429 0 obj<>/XObject<<>>>>>>endobj 4430 0 obj<>stream x­ZkoãÆýî_10°ˆØ´¨—í, Ûd“ AšU‘UaŒÉ‘Ä–">,«¿¾çÞR3ÔŒãE‹Ãû:÷ÜÇÈûûE,Æø/ÓýIvãhŒ'ý_Õ†>ˆét¿ãé]4Áç{Q)±¦WÅ4žá#=šLð‘ŸÇxyæ=9I T¶2™-¢‡“•°¶éý$š{íØ2uFHÇ3‹íxÂúæ“i V[&vÕƒ¥ƒÉþûpóœ$ü¸qj |ڴϾ[f ÎôžÐèiV7[9|†lW›–Ñ´š?ØvÂÚtz|vlW[R>¸›DSv<'' ov´_8 Òmω-3PÆ3¬Î`ã1dËø²£#rñ k3Ùñرe\mAHù`ú¡oZÓbõœ‰çä$áÏû5€Ó íÑf ñœØ2ua<Ãê 6C¶Œ7;‘‹gX›ÉŽÇŽ-ãj BÊã¹ißgÙñœœ$üÙa¿p¤=Ú 4ž[f .ŒgXÁÆcÈ–ñf‡#rñ k3Ùñرe\mAHé 9ÞÚñœ$üÙa¿pj¤}Ú44¾[f .ŒgXÆÆgÈ–ñf‡#rñ kÓÙñÙ±e\mAHù`r‡Í‰:v §³Åž““„7;Ú¯œi6çÄ–¨ ãVg°ñ²e|Ùѹx†µ™ìxìØ2®¶ ¤t€uSo¿Ãäxú÷ý©a§Xj˜=º4,žKb +ŒdP™ÅcÅ’ð&…cqa êÒ9ñ±$\U! éùdf&ÍüÞ­ÏAÿ¾7!ìÑC®G•Äs`I t1 êÒ€xŒX¾tp$.„AUfºœ£hI¸ª>,/n?¢°/×b2‹‡8Z,îÄ2EÛãê¸LFï ¹S«QÙ6û¶Y] õÒ¨ªÏe–Š}•Íj””E݈d++ñõêêýÕò_Ð;1ä×âzopãÒzGËmV‹4«TÒdÏJàCÝdy.êv¿/«F¥×â©mD†?xOíñ¢ÄS!‹TÔÛ²ÍÉjù$Ÿò£xRB’*Är«„6Œ±È†Gï*E¾»îŒ\ã» ç¾<¨jÝæô&œ'`DŸTƒ`;ßjq¨ä~ŸQ®E%b«dŠóu–#’b]V;Ùdei“ÆŠF*çÑ,¢;÷_ÒgY$Š$}&z×Õ^î·-8TYCïê—þ(J8#ê½J²u–Ç$—ûV3äÙnª(ÛÍöZÔåN5ÙNÕ¢Š50;yVµx±P*ÅaɈï÷yß›Òk'‹ãµØÉ#%%ϯÒR4°®*˜,Xó—ß>ý€ŸÁ£H|„êE’x·!IÒ^¨DÕµ¬Žd `#Ëäh*YÔ=À|Ò»”b²àxC¬6ª¹,6­Üà3¹Ïù\—y^`µ&i ~&wAäk‘gÿF iJò"¨¸Î^:ÓLÀ°n 0r‘ø®$‰¬q<ÉŠ4{ÎÒ˜%EÉdÛKQ2‹JBG"Q¥` j v¤' §„ànf×="ÄP€àºÒgDc¡“ŒàDQ6]¤*ý†ÄÜÎpƒ/„¦Sô‰´+«ÕèrwÔ˜<¾«/Ñ./ß‹Û[ÝÄÍ·¢?æ6¡u¾ÖdŽðQãâ¡l8ä°Ý!3OçÕ”w©êâ«Fl%Ú‹¡,RŠ:&|t¬ w˜DLç¡Zvv½­®\G7Ì ÍA£(ŸÎyWsq¡!Ò«×Cõ—Àj ˜ð¯Ô>—ÔY³fQ”U¶É øo¥ûZHôN UùT>«Hüˆ6öŒvÔP‹59•ùAk2Ø76]õÜP™kh§ (jˆ:{Q— 7*¡¶o9¤Ã`W‹Fve€*â"Õ ]HáMŠ:)T FtÅaô9nt™´X¦ÒbrÿµWPaLËGîZ[X~ÌËbãIÄýý'ù,uö4ò}ïLË/ÔúHÉ瀎cÙ PÅq½­Á,À3Ðv‰¦¢ªý(Od­ÎÒÌøbXõ€êöŒŒ1³(mo­¼w«‘klue—àº,Ÿ0Q„øñƒ¬Þ£ßÒÿOO´ïr$T,ìM©ì1B€V•ý‡¦4÷2ÝÀ½`]ög” èYc¸G3›ëº*wÜ—OìXhsš¹D6ã €"ÑpŽ›åÅ©Qò”Ú½¦hR‚,B®i¬ó«¦}óùès ßüãðòOùÃË ÖgþÁ^§àUà?(LœKÐjw; ÌÙtü¤­0 LSgV¢¸y ¯™ÁJM³/Ož;€??— ñ—Jšò¬'ÅÎa¸nž‡ROW´ê4ØÎ*A ¤ÕHêÒBßHMÞåp¤—7¶pWþcزJ<®jGýÞfÏ2Gñ¹Ù”føŠx>Ǻt-â9 ›&?ä]ŒoÙ'ú~UM[LˆønÍq—£ÇßF®FYq‹µëâ]ÉßÌâIßǰßLH›'•m}¶)bZëluÒúU7ƒ|M˜áW¤êï¤ ýA¢S/5ðvÃÕG÷ŠñƒqýZ¦éœ–~xÆ ùõÓÏKzxC[üÝã¸ioqœ_}ÅñÏÔºþŸŽ÷3ßr»¯F¼Éš|€vã‚`ü¢Ç4ÓyU˜¥¹ÞܹϙSbÓ*…sl˜}ˆý¤£<˜]¼Ë`‡8›é}tïÒpr|J¼cª°3¾#à>ó–((?½ó þ«+î6:má>³†bЃQÈóö(:È5k¨'tÙøóq0÷ÏãàÅñÐe£µ.±GØ—†…‹ý:H9}ß³9gÓÌáw¾âØÑ±Ÿ,NÄhÀm{aÐår5:l3¬üÔ+µÃ¦†…[߇0ý趃E‰ô=Àhß§Çì<èñ30ûÊ9ˆúIG¼ž™ù«`Þ ˜vÒsIJ¥Áˆfg¨÷È"É[¾·Š–vé=Ý-˜ºÿ²^fÎO#…òÿÆ‘ò3L«7ÓÚû 7ÆÇèú[+úò7,?˜°„9pÓg»–®UÓL ûË…QÞq¼hwO˜ ¸:Hš‹™c±9h™H|.7tÍñ@wýÐÝ€Æ í.—Nn…j8”FäµvaÊàöã}ÿýâz.‹q4㥂o)ô¾+¾]ò7# ×dŒ]bŠäŽn™ÝW6±ø¢¿1éïàz÷íŠõMé˜ÇqtEAâ³1=ù~yñ·‹ÿ=!Ö2endstream endobj 4431 0 obj<>/XObject<<>>>>/Annots 1413 0 R>>endobj 4432 0 obj<>stream x•XmsÛÆþ®_qUâ1•ˆ ÁWÉñ´£ªŽëL&u%N2SÓÕ#y €ƒqIuòãóìÝáÕ ;‘=þ=»û삟.|6Æ?ŸMô?ˆ/ÆÞwª_ÙŽ.ØrL¿ýéÒ›àú†e‚méQ¶X,pI·¦3\šûþtáÍzOj‰Ž*+b­Lf ï¶¶r^ÛôfâÍ{í4e:ꬵt3…ËU8çÕÍ3ØjS¦­ÍÊX;óÛ¦óÚær¨ÏNS¦­í,¤æ`| „(ÂùM';='µDov¬_8Ò=Ú4='M™ŽºóxžWç°é1Ô”éËŽ¨çym.;=vš2mm€Ôu“OŸÞ^L'ÔCóù5£i¦ÞÔ]EìñŸùžÏæ³¹9õo–ÞÒ]™ÓÆuÌ&OÙgé´yÓå¤%Û¼†Ý1õX-{6õt0[ÜÀIª"6i—QïQ-Ó_GÁNâmMôª³Yì=jJužÏýôÙDöšjJõÖ’‰ªý/¨³ÅÔk©)ÕÖwX:˜.¦(“%$·EŽGµLo–¬kP-Þ½ê,>½GM©ŽÂó¨~AŸ¨×TSª/K6ª6ª_Pg³Ôk©)ÕÖ÷÷ÕÅè{ Ë1[mÙÌ[ø˜QË[oz3g« ƒVÁ@{ËíóÕêWö‡êßtbUEÎò½`;y ³²LeæžÊäN&‘H^£†øµe†z§h™~Nr~Bì\#Ø4UYŽ\nžM%ßÚãˮɕÍs¯b8$7‘`.È7 ìýÛdêmÓàö©Ø‘D…"ž„d؆UF[ûo²aK2”Uð„ Á ² ªuˆ~(¶D€:ÊTXl™”-\aór½~ÙU­²k\HŽ }°D@ ’‹ª:à)®`ðÞy¡¯[¸ ZöH#дšK£ƒË5~.;æ<ö=:Xœx ι&#™ˆÕA ¥{¾¹ Z\çoÄ–È ÔüÇžUD¨EÑŸ&Ÿ[EÅÙ¥¾Pfµ{¯Ú^Ö¸×Më:l= Žß®¯žÖï›õÕˆ®'£N'Û&{o˜í©êÜ&9V7ëvö±á;j T£$^qØÆª3ÃÝÿ*ò|¨¶€8QïƒýœpúÏt J.‰m€¹&rC2dNµ ˜2 )Ç‘†:«þG÷ÁdND¦Ôj5°'¯Ð¤V#Í+êxeªD%¨T²€N*:ˆ6Ãè”âsδ€ŽN3…ú†ú¦0S Ò(Ø:ÖC€| }Á†f‰ÊQ_’ÀÈ {Y¦+'‰¾Š€ia…FèÌ ¶A^âBçÔ/ÈKŒ¹DübÇ5£É¹n/{£ÆëåëÏRË]bÇK7­u‰–E“gl2.¤*Z^¾~ýÚ•i½R @€ øX$Z¨ׄ¶ æHÕAE¤-ÕÛK9µl)VõÜ.r;Çj{¨v»í ñÒIÛö€*!V€j'¤¬*)*lØÇª¾!N0ÕBNçÔã( Û#%„½[óåq/ƒ=U€ ÕÁ,=)"˶EDT–bꔓ;óp >7õ“pÈ,?(L-ZN\O1*Q‡(Ct hYãÜèÆ)’Ž¿†[ºÞ"NýDŽAŠU1„O.CšlÉ\ÅUôE¯bØ+'àöÉÄ›NqF#FÓ>5–§rgÚf*6èÖc—8)-X(q»$¼¦h§7?¯J@Ƥ¸®¼ëãÇãi=øÛ_ðäúªÁþh}¥Q{ìòò;ާGÄó‹ w"gÿ²úªe€ý™£†ŸÞß½ûiEZÇöÒ©0;»¡°¬@º‰6ÌrF±RzDRÄLD`²ÓBCi6GTZXˆìô©yªÔkKŒ¦ÃDâ q»ÿjô?ðVp}èýw=øp7üÏÇ|ø¿˜1ß¶‡ xÍ^|-Ñ®EŒ­3®!½W‘*²§#BÇŸnÈn¤¢Ÿ.E>z+òË*³´ÒFp6±p R¿Cª•ÙI'³xæg‚œ0Z1ÿ™|2*˜û\]ƒML¥O½ÅbI‰½ÃÆbö0åAdϘO&£Xç˜/š#‰–DðüL¾Õ|VÖ³½[Ó´]i%ÆŠ¡+fF_v¤<ö.a[äXgPQ‘YÌ©ý¥™€A–Š@Ò¬æ–5ði¨–2¢,P4ÞŒ~ 3¾îÕ’J46ežUcÂI2ZÚè8|ùµõ¸»…±%ÎC3éjeb:‘iêÞ®^–ya•Í¿k£1l§ A•.õ«ªÞ”JOQæÄÎÿO¯eÇ 7‹O…D=\Úî{xÓÆ×ˆwá†PX—†{Í!©¹ï{7ønžÚfæÓ7«‹_üuxŽendstream endobj 4433 0 obj<>/XObject<<>>>>/Annots 1415 0 R>>endobj 4434 0 obj<>stream x¥XkoÛ6ýž_A ꮎâG^ÍÐ]·v¶[R ز´DÙl)Q%;ޯ߹—”#)NêahëFyyxî¹/9˜ˆ1þLÄìœþÆÙÁ8ã7ô1¡ßÞLÏ&Ñ©˜œÏ¢±ÈÄôåitžŒ¸>h?gb6»ˆ¦­·íg¼=;&í·­g¼…åæ²üÝM #*âäíK1‹›¨Ï_⇄Áâ‡xxZ4?éLW:_ˆ…±siD©r™ÑsYåžß|:8y‹ƒ‚•ãé)¬ _;¡î #u®¡sQ-•(JµÒ¶v©¸Ò6w#¡+¡(¬szn”¨¬PKKˆÂÎD¯tRãØDÅF–’7 [ Yf#d³’ÀÐ~iŒ°)—´±8žL ¬„Íc‰÷9€HˆÕˆaYU88–v­Vt¸,Ù.ŠÒ¥–•ÒÑÚ?Ð?³–\Ãf ·ŒUáAátºæBåª$žˆžHÜX@Çãë "ˆ‹m¡µÌEƒ]pæy…l˜×á³®ºlEŒs% ¹›jG~qõÜ©/µÊ«¾•LV1ƒ¸÷ØP`5S €À.Õ¦1Jk%RóM µsWêy])~œ‰©DÌ7âú÷÷ïøÂLHÇs°ªdI0¡ ]9üWÔU$ÞÂ¥êNf…QWÍÝ/¡>Hs 'N§Ñl†§¤aâv8H­ŒßéH{5˜Ërpû\ ßv‰:f³èüü‚LÖjn/5üÎX앦Phð¹pš@•ÿ ÉÓdž@@¤ºÜVªÛ€ 8A9Ž5ëɱë<?Y6‚$v:“®& C-’.[nÕ¦€úÓ{λ¶·QÃg¼ òœt9"òüÇdž—’Xxqû4‡ÈC8Ýáñ7/^€º|÷Äa8Iå5I9{â0äŒi´˜Ìlá*£2ÈBf2ˆadH4¶ùJåZ! l\ZǸ:^ðÈX¸“ó©i9_ÑãÑí°Ò•Q·Ïtyt¨]s›=4¹ÖH\±,t%þÇ‹‘D òðŽ8&{¢¹¤@ä±xâ¥Ì~G,'ZlñQvüZ(EÍfÔçŸà²çz^uý´¥šÖ§uΉ¼¿e§mäûª¬ãʆHjJÆp'”:‡ö± ­ ÌTýÌ8Ú¥1¼Bò‘¨5=ÛMÒ£œ‰Ÿ9á´l{çx©âÏÈu(Û’ER®–ãÄÆ5‰+T×ên)kDô Ñæ”÷Ñ ärª‡‰ŽÝ š’HIÑ#Ûf~·Ö‹È­}À¤OrsZCF»ª¢quQØ’2²Í–º£°Ö×jTD™$¨ñH:ˆ,ƒøCýBÄò>®(Té(Ø‘¶©Žõ1òÂ>À­™UŽBðÚßTª…ºÛ¹7óƶ$ G>¾˜ý eÀØaB.Є8dsä«E ñSc¼SvP‹‘¹å o@¬W7ú¹¢›~1É€ªΩÓTß ¾¢­ UÞ ¨±øJ–8ôG CÜß(”/Ø?ܧ~Q­ôU ;¤£?“¶4:*W¨X§ÂKêxxgNzôª](ÓˆD—({ð{¨`)…¨1#•·JK‡àÄæ*t=¯ñ+Y.‹³Õtì[â{dy[¯&”O™¬§kìK]x@óG7æø¥ÐdÈ\”uÐk&Á÷ŽrÐ¥(“¢YMÙá¹òmƒ×mälvKªq]‚î;W6!#`ú"'3dų¸ÍbÛfýOÖPðà žÁ8뺱ººzCžž¯®¢oö`í=埞¿ŸŠRîõwu ì†PÐ}Šñ-ÓÛÈØ«šºÑ‡‚FUCãmñ†]€ÌõûhTÞÐM•7¡w‡4,œöÀ!‹Ò‰Ð@¨ÄÂ(|³7ý·C>Ä÷RB ÿýçëã?þz±_°ëœ’ñHpåBsCðzÄ?2ìh³Ž|öéK̇>ÊÚ$?RP!$º–Êb]Ê‚d-,Uce‚w÷鑎Á±´ °•äß¼Z/5:-Ò}¢RY¤ärÁ%“„%E¦r1f ØG%¤Øb_v‡hÌ­Ã×Ù\/j]màvgMÍÅ‹€4Óiw_3ïÛ…–ÌÓ¥Ð?p2Åö@FY?ŸŠ÷TH4#nm}ŠÍ™‚ž¤HÕ'¤QÜÀm²¹5MÈyV# •Š—¹ÆÀÖ¾¾œƒëóq(P- JÂMp †bîFT@À¡Hçì=-&©s_µmj÷ÀsÜÿÑÌJ& c#l<œò aË6þøèÁlé}¾DĮ́¥ oÑÅØO” ‰*"ü4F%]…oÑ^£ôÅ Ù¬%f§„{Ö ~å!ù;µÉ.¢™^B‡1—mLI•ü¬ò¯„v s¥89ñB@3¾•k 3*Fõdˆó°ÁÓîõŒ°? ki†kϲGŽ ?­%í2Lþ“ËÓèlv&Î/ÆÍL³Íñ_}ßn9É0 øÕÇþ€ý¿Ã9›L¢ËK| X§S2öÃÍÁ¯ÿf+Ã]endstream endobj 4435 0 obj<>/XObject<<>>>>/Annots 1417 0 R>>endobj 4436 0 obj<>stream xWÛrÛ6}÷Wì(ñDn$Z7Ë—´î¤Žø%Ikeò¢D‚"j’`ж^úí= ^$æâÄŽR»gÏž]~ÙÓ¿cšÎù_˜í‚¾á1üóvo<G49sÊh|rLë»”növï3šL'í^^ýk±cÐ[5k:¼YÄ4ÑütÌçÇ´ˆü±#Z„ýÃCzmÉ%’Ô:×F’¼—f㕯éA¥)©3µN#1ê¶TN¬RIÂ’rii Ï‘‘_J…uøÃHçªÁ»7ÑVæ2ƤN†vÅÕ¦gÂÎ{|Ùο¥uÛ´HÐ"Ásí±"ŠHämrnÀ®È78=[IcIÇ[²‘Á ö/üÊ¡6µƒŽ?Œ(gÛˆ<ç€Êƒ^2 *hwY<œL‚éœF2Z<¯˜3 ýçÊz@’^ϧòCnÕäæý²´#UVC;üòª9I/˜C/ºý˜ §4à Ž*³à„ÞÈX”©;Ô…S:) ³.3™;ïÓ–GÌ¢Y0ã@o>_¿GŠB`U¶Ïq‘­À2º@~"ºxù’BÉ€®´AEV¤ÒTWvT¹£"ÕnÙtÉ<|DWW›Ì;Lµùãó»ëÅåòÀWÝÖÓ¯Í$Ba值ïk™K#X]%Öx™0 73æÛ˜VZˆj¢#ké(ùºën€,.ªM«ç{\æ!cŒÃÊ4âb+-ÊÆ!`·ë4Õ–žgßCCÃ)’q ÑýÙÏ3ú‘k"ºi)»ÄùÊdãÉŸgd´O—6¶+è0ħ*ŽŽîL·º“B“Ëuâá}ýþæì°ü&Ú©t õµe"Ë»géÉl!C« @QåÌ&! V›;t ™ØÄëÓв²®æ£Z(=Á™ÞïµkøÙÓ‡"17@#æ¯8ie&r§B|iKˆŒÎCirÖ3fRËbò­ß\¼¡CĨCÄ€>Cº:NÇÜiøsáùëûY{¢O4ÜÅ6™)çjÏMß °+øCt•ï~,·BH—׿ê'P8©ZaÐúzI=m­ºD8n–@€Ñ02” Nñ=†ÃB[«VhJØj¥ÁF(QëTàyÚI<æ†{…q«fFÕjDjkª÷2ãá£ØXÆÓտТH†/†U}ò¸ñ„Ìv<ª{Ê€kÐÂ5L7­y`uÇš®ìÓªÊMe¥r z«‹eŸoEÕjVÕËþoX8ðK,ãò'‡‹˜6º¤X 8\ K˜é\­_ÐûùÆIøÆf:*S4+~˜s l*Ñh@ãd¡¨¬ÎžŸ_¡¾Çv°amP&‚>b”ÖùÓ@œŸŸsÁ†®eÿq°Yøý\v~8 ‚À·#]irz|ÙuÍrs¾¿gs;¸N³[>èlZh6-û™VÌYîòßÿp¸X€Òꃤ±\ùAßà_&½×yeóŽîr´·È_: ™„FaòbBÔcÄ–º1PïMÑôN?ð+Qwp•Êzí³\˜ÂêŠnÔÒR[“Ì.O€ŒÒÌ|áó;Úfðô䃫k*·¯_ÜÚ°¿Â¯‹ÈsŒwÉZ–÷ýkLtqë£; «Ž•¨¥~ÍÄ“ÚÆd4 ަG4?™c0­Íá$Ñú™TðüĆ1ãU{‡Ç-Yf1]ó{#ùóægóªçñ´A>@êRxƒüÛM¶Ò©Wߣñ889A(8z6åc.{ïýŒû¶Éendstream endobj 4437 0 obj<>/XObject<<>>>>>>endobj 4438 0 obj<>stream xÍWÛnã6}÷W +¶â[.›)ºÍ¦Ð-â`_ ´D9L$R¥8þûž¡,Ù’ãl€¾,r³å!9ì80ÚæGò" wv­ö,ÓjFÚbñÁȤˆÛ‘§·âM#ê#ßþh¼Ë»Ó”?*‹¼­ì_‰‘-C=$W>©{{!Èj/Dè°½Rj…ÑB X…¥xÈŒ*x,ðAn’r‘-eN6ÈTš+½¤Xèe!–Ò§)§Ž¢š•¥µ)(7TX¬x” Çqu„¥È¸°«2]òôG#<•Bïúúz—ãÞ¤ÇêV›¹R_4Þ½±„ño.ŽÚkÊ4*\[EyБÉòB‹\Æë-ÖÊ _ž©y\P ¯lƒÖ$2IÚPlô°Š ÖªE,9¶^èÓ­ÉH¾Š$å÷Áqt,­ûM3H§¬™—›S& vs¢(—…`ÜÞµâˆn29úÙæ¡Ò×G=Š•–4d¹Ñ/ °¦ëT~Í2“]‘Y<ɺ±¸W¹¹À}®èÓ<Š£Œ‚y:æà‘ûá_Ÿ{¡Xï9­XàR"žV ‰¡b>’!\˜¦§TÓ»¨çv „®˜Ù–ÆqUÍffïS>ªôXÓùX›C‹Bèsõ"-Eö,î÷Ëúãú䯭gÞѱ‹£­çnmû=ÿd}Ï5ùó7¼²&éÌΘšèš„I s¼i–Í;Xa6/J!ë<êÛ| ^A÷‰@ÖùFëü:•Š ÊÒ×"a€Ö_p÷6,išBí4óÚ™Ø&ÉjFÁ`-D›ÆÐqȆÃgՌơrÖe»ÝñžÄ„K¡´³jE,ÎYŤœJåk«@å1 LYNpþí¼ÚçÈ:ÍoR;=…Æ1Û9÷Q™Eȶ°¢•ÉžþÇÛZ÷Óß_µïûeÃßwÐýý3÷Ë-Rñ/“+‘?‚9+F«QHýöÄÄ«,¤WRLÄL.Ð̆%Û®”† 6ùã±»A‚\Š1¥ë7ÎÕL뽬QͧbÓ¯Édj‰,n²îdf^Y¢-^E–Ñ„›ùý·»ß¡.ó¢BÜJ.’¡‰Ðîr©-ÄMˆ N+²~Ûhq£B7k8 ±Æ¸Â©F¸]L¼{ÍËÊ÷:À …‹7nYÒIÿ‚.œf]t—’®êàHË ³HSžƒ0‘m{ú! ~½¹i•doD»ø²òƈöçí°ïöO¼;N>óÜõøv³®ý<ýr3í/'þÙøŒÎñw32ƒú#@7&pæîªÇ(a`+£ûe/:ó'þgú»œa­*÷DY1ÔEæÕgáy‰ÿrÀÒÉ„Ÿ|vþéünß×endstream endobj 4439 0 obj<>/XObject<<>>>>/Annots 1420 0 R>>endobj 4440 0 obj<>stream x­WÛnÛF}×W ¡‰Ö=r‹pÓ8ðKÖjû"ÀX‘+irW%—”ä¢ÿÞ3Ë‹DUR4¾ŠÖîÌ™3gήÿlõ©‡Ï> 'üÄ­žßÃ_øGŸüú¡5š ýMFx¦˜Æ½‘?)Ÿ"zâõ4ܹ÷ðkT>ð[?ÎŽ¢¹ÉŠnFÔïÑl‰´“;¼]6¼¼{Zš$–R›(½"³¤öìcëö`ÜïÕ7s/2[™"•óvúªx¿ éQ`t.›’ˆ" Ö"•IJÖÛG¼Ñ§ûë)¬²Ñùðb£¬ˆÔ‹Dȵ¤¥JRËzÔíPŒWç$¡Ã^œÈÔž)·F¼õ´ÙvH ®¬$±0™¥e¦«Œ¦QQšm6&±(%²k“­ÖôôÇã a¾Ád홳EÙQ´Á§:£d!i›(k¥&¥e0^+’•´ ½ÊÄJvP±JIö‰ 0ñ&RéZ†´UvíøÈRÉ]³ûŒÅ]@I±a.t€µæR ›Ÿž$!™ËÞÔÔâÍÊH pàxš[*y,"ŠMRQ×£t¨rf`÷¤ƒ‘?ò–³œ"·;”i¨E)·…\‹\¡WºÏÈKTR&c•CJÈY¹r€[Ð*qltHY ˆ…bTÇ+. k*ñö%µK6Ð× •½|¦¢}@5¸t ¡ æïxq,>IƵ1àvA¦¦„tTA,ãêôiiT€Hjð´’Z‚ÌÀb_´/U¡=”ˆL¢mΣÉ,>‚c§˜b„‹è£¯u\@ðéLÉ@D7ªÍn5Ÿ¾-´×£©?d¹¸8ÄSèÌÑïNãôWU ü7ô¨üMÆ„ì:ûÎËw±+]w9öpèO&oy?ìMH„NÙèAš`œ¨–†mŠ[p±ùŸÁ]b*p?ïž‘k~RÌ 8·/Ô”HŒ¨£½ûÃîLQ(„¡Ðk&Ú_KT¸Zµ±bï8Óþ¿gzù™Î5ª®)7*,[êЂsÔupº¸¾ç"Êp<^ $ƒAúžÜ²kõgݬû/Íúò5²¾\Éz¸î¸QÔ£ð¨q$†Î;…TþY?„7;Ç\ó9 #®ž¢–8é5ÜÃ95œÎ •©ÚàÖð%ãåö¹¨¹w¶ß¥”ç^i7XÅG¦ æ^¿“âžd–'Rš·çíÏŠ"”‘´²ÎÝô¤‹c¼L¤œ{nÈÏd¸ØŠßÜщ³—˜P7’¹Œj3?œ>¸˜Õ¶\Þ‚blÅ5+Zm²ÈÙû21±kÁé#s™"‘‚çó…êzCrh«Ù…†ÝÖnçF6ï æísï—Õwú½ó Ê9È;ÝñÉß¯ÎøÒýšÉ‹å·ÓòŠÞŸŽüñpL“ÉØŸô݉Â7•îÿ!üd‚,–Úº;ãÄL«»o‹èW¯Kã~Ÿ¯H΄GcÞÿ~Öú¥õÕµò]endstream endobj 4441 0 obj<>/XObject<<>>>>>>endobj 4442 0 obj<>stream xµWÛnÛF}÷W ¡c‘ÑÅ– Цuk4PXm^¸9”6&¹Ì.)Y-òï=³KÊ-;y©m4µ;—3gÎŒ?hˆïM¦ò“G?ÍŽ†Ñ/w¿Ì’^^žÒhH³ g§¯ðºÏñ¿é ¯Ù ¨Ð¶&Ñõ‡«_Ÿ[ÊãrÙÄKÆû´ÉÙRœ[M•Ñk•2Å´RËU˜ãjNª¬ÙdqÂT¯âš”ÅÔèrͥⲎèwæŠ Ç©*—ÑñìãÑËËW4ûÂñ!gÑY4¢Ù¶â”3ŠË”lmš¤n [å>‹p|Ê%‰–lSUÚÔþ™2çz?€·@›•JVاFÕYQèqÓ[ÉhiâÂÒkïcHÑDâ)£É¥A݆ÕüW〠šÔ~¥ºYäLwƒíàŸï÷N|¦¿8©µqoïËŠ“É$šNÏÅ·—Äe¢A”Ó+ÅÖ6*àЕ˸`)•<ëÅGX–Üþö.ž;è€]KÕ’„­Õ†²¦LjD(W·L ÎP£ˆfb¢Ì·]´(I¤*Ëà¿DEawç¶±Îk‡“gT‡ŒÛU(]Pë¨5¥FW.ÞÞmgÿò-o7Ú¤ˆŒÊºä’ ÒIQ¹A_"¾‹‹*ç§«ÖÄssw³äzø¿è›ÓáJíJ7|s×+å~°®„ã] ¯P• Òm¬]­PôàK=øõ °>yokÇž›ÿ•};fõJäñÚÏ:b¸„z }-tìÝÛ‹¹Ý*a—–œ^ e•Äù}OÒÄ¶Þæ(9pM9ÉcÐÀ‘¡JNŬ´¡£mŠéjÉä^”„¶òF íÇØúT¨mÞ–Bç¶2~Ĩ•VŒmßîaÌDÓT½£³³°—A\AŽ*£ˆ 7LVœÜz-ñ=ˆ…sLoW'®€tß(¡;•hk¯¿Ö C¬âµˆô/ÝBÞ„=QAIœ4 ϲxá>Ÿóã¾i¡Ó°­ëÄ÷¾{)ÌüñúíÕU[DN†mƒ‰·ÉHµ1U¦D”¥î•áµÒ퉑ScàYÚ( ±`̼œc4þÀUCn–¼‘Éäí’Úµ¯hÃw~$S±õ…Ü,Š"G“Ýlj~©õ#Rçë!#e_纡Ö7øyßÞ›‰´a`79@h[ñ~"˜FOË ÁßH€^¿%•ooœ ß<ÌËÅx0z1êz¬ ˆÎÁ€ü§É£cBe4Ü?8–æ½7‡1Ý]¡`À{ÁíŽÃ¨YÎ%>˜ŸŒæÇ‡màPRm¿p6ÀñÃG¿œfÒÛIöšÔtÁhQ…ÁëG›EªºÀb……o«°à õƳ!ÈXŽvJíÛÅ­iϼ2¨ò™·"® #¥t‰›$Ø€D‰•Sac¼f§Ú·À‹‚ã–•s•(v,6m…¸¸ŽUn;öÝzø^×üZ†‡tž'.ÖeT>£ LNNö¹®$èn¸ úWлý¢.=Ã)z¾æ»yVØ—µ)D]´&yiƒçVâ/ÚÇÃÓèlrFÓóit!tÃq4¤Ÿu‚°¬Èâ |ögÃs¿”~m>¢‹ üG³§S1ñËìè£ÿ°p®¶endstream endobj 4443 0 obj<>/XObject<<>>>>/Annots 1422 0 R>>endobj 4444 0 obj<>stream xWÛnÛF}×WLÚÊŽD‰’,9 Z ¹8ÈC4ÆŠ\ZL–\•»4-þ÷žÙ%i’VÜ&’»s;gÎŒÿ…4Çß–kþe£y0ÇþòÏFáb,h5_àgFájÕ>)ú2ê>ãëåè4·² «] IZKRÉLæ–#áÀçåq1äÚRí¯ãES´ù­tW" «¹5=”Z#UÐ×½ä°RC&µ¥à({AáC,­Œ¬Œ'>G®Ö­Ìe!8KªD‘§ù-JfŒ€KSFû¦Œ‰VJWüõ•Ç`N— ,…E°\â)»¼É }†kDå=ŸV½ìÔ]ëõ†n5Š—fiÎqrí‘NÈ2CÀš¥á$=ÈÈ›SOMT¼¦p’‚©‚k{Àÿ}ÌAüˆë†ÙÑñÑ+aSØÛ‹"S(Tà#dñt±æ˜™¼+úÒPŽbaECÆ~²ŠpJ⑱¾`Œ¿@ø][ˆD…+L&ÜI qkºkå½ÈJ>×0–M›àž¦šìÑnñ˜µ³tÿº÷öO6¯€,½A7ž´tl®q;;ûì4y GÍŸÙyL];:Ÿ ¼Ãº3ó( ö¸¾èÖÒk “¢*X,À”Ôò#:-V`¤CPÝÃ*sÆÙq±D¼ !ËB¨;Qø/0A·–ÞI¶Ël¤j/RÏQ“‰ÓŒLã³J¿s'¾}ñÚ’àBIº)ÉîË5ôsÌGÿtâèhÑ?Õ¨ìøú, -‹N­cHÇKS] dŠÂNêºLŸ‡‚TújáL/p/ æyr1°ç€ê&¹¹•özÌœ8ß]Ÿ=%†×Túe7ý=éóã¡qëØr§Ó˜¼Eóhqâx{~'T)OYg«ôù'ÌÿE\=Ì£!÷ ZÊ -·Ñ™¬¸M¹³¨ ‹Î^xT8Öh\»wÜ9ÎX»3§É‘Å„«1á'××inÒØË?79{Ž8 {==ßÃAIG]B1!bví}8Ï®ì—mÍ®Zú&Á½óH[Ãc¨ñ“c»o`…g+âyì=Öýb3Á=XnžïÞm!rµæúøš“Þæn’"ÍvGÐLƒV+]ª¸™¬¶ž&*Òƒ³¤0SKžqí¼Y°” Ó Ë y="ÿ‡ŽžJô¿¹¿ixÚ4ø?Yn®Ïž¯f“Kœ=C©üö0€Ò÷ë¬ë³!Zm*V ­n±'H#Êá]TÏb3böœ:Nçƒ nvúúùr2nŽ‹iäV’¾Ø.La•zâ:ÆÏ®ÖÈR¤Ç—SdáÖ⊡ì Ì!»“á½fz«°EBõx¾þjœ)׿M›ýT'°pûçGôÿ¾áÜr., 9ˆhd¾@ .Øä°q’Ž¢²ï¿–}ÏuÅó†çz/tèqwŽA…"%°‚ðŒ¯£ñû'£&0:]8à= ì^us†c›øô°Íù=âô*ðõÓçw˜ÒU¿¯žçr ÊžYQ¡U9U¬c; Ñl"©‡+Û÷¯ZyªÉõ¸Ÿ·Ë«ž9WXµ3®Õó…ʥĭZù!å†VÒŒ‘ÙÕeÍÉðr\,/ð Ë&ýÞË1MÁœÞé¨dqj÷ol#þôtãלüZs†~r³mµáÌßoGþí¼}endstream endobj 4445 0 obj<>/XObject<<>>>>>>endobj 4446 0 obj<>stream xW]oÛ6}ϯ¸(PÌ]lʼn›®ØÚ.[_Ú­5З-R6‰ô(*®Qô¿ï\R’-E-º%GÔý<÷ÜÃÎf4ÅïŒKþK‹³«³i2Å?Û·¡‹›)]' Ze4ŸÒòÙ,Y.ŸÒJ†SSZ¥#ÂS¾r†²ÉoûçOVŸÎ¦4™á¡}í|»·ZÒµ÷KåoG7oßÒÏÙ˜>¼}÷ŠîE^©Û'ô¥ó [g³ôk<0`þâæŠØ[F„8™/êG/m±^¯u®ýÞX¯~aÛ7—õù½ÿðúÉ,Y$³ #I —kåP®D©JòN˜2³®P’Dž“±f²sºÐ^ß+*T±Æi)¼ð‡·´³ÚxåÊ„Þ{á¼6Ò¦ÉiÎE9:Éoõ‰„kÃá‹›e¤5ù¡¸MÓÊ•¤3­{‚¥;c÷†ÃX+<)½«R´F)ÍEYŽÉ:ª |$´bÇø«L®ïT~/9%î:±ªÏº 9¤Vª„þ´{u¯Ü˜lEF¡.ðæjÃy!áQJ˜• >ž7åaopÃWÚ˜J]ìðªäxQè½p²Ž»H´êCe•nI”‹‡îÅtaÏõ –ÄïÏh†dþd¾ä^\%ø¥—”Zß¶¨*#Aªö{׿z™\ò˶ÊÐމݎ»ÜeÖž“Ý(£\ÈéeUÎ•Ú àF9éV]œ3¥(K¨rëÙؤ]R©”^ÇrKk~ò$-GÄ3à$Ì 2›qlÀ^£¢ò¶€É4xqxEYeRFXù#^ÑŽ!fß¹€E›ÞŽnŸtË2 UëΜRG“ã0¶Yø­ °Ù{äÁ T#[Òž› È .;kBc¥¢Û‘NT2ŽgØS/ÎIz~ÞOÇî¸Rhc|pGc}ÿlY… ‚K6ŸÚ¢@+ùX›`® è-¡—ççŒ t_æ<:Ë”SÆç‡€Ñ/W§å{a|=_¶†Ú)U&ªÜwÁËxÂh:°h(©yVSžJŒÙ@þ ¦;ØJ½uýì¤v@!óLãíø¼AD›àä»Fê’—bmLª#õY€j>Ý6“ù>/XObject<<>>>>>>endobj 4448 0 obj<>stream x•WïoÛ6ýž¿â,¨“*²ã_M;,@×.[¬èPcÃP÷-Ñ[‰tEɶ2tûÞQ¢9ÉÜ9i#ÉäñññîÝÓ—£Kêáç’cþ²£'G½°‡‡ÛÿòuožÓeŸ&sŒ_]Ñ$vß÷huFá(ÓË8VzA™Ìf2§y©£Bm©0ôŠl‘—QQæÒžM>uo†t‰©ì¢? ‡×ùÍØ‚R¡¥XHKËܬT,I b”­lFs“S”KQðBQ*¬Å@¡c²årir÷ØÌ>ɨ “+© sœE.² SBºÉM†ˆŒÓ–Fé"`@€Á›‹;ÿ1›°pšVô©ΙQ©¥Ø¬5ï¯H$¯IkÉÌI…ˆÆØbaÇAH“DZyçkmòŒ£·Á,e. IFc“¤4ƒŽp;w nÃÑ´^jäÓ³^¦EbÊE£rI ‘ _¤”‰å’!Æ«§O»-£l”ÈL»9ÚP¬rPÙ‚Ô>‹²P©ºåxª µ*0™X†ô‹YË•Ìzÿ盟ýY2»”‘: w. :§rSH×O}rtj%K@ÿ޵–ÆZ5KñØ4lï¡ñ½Ôsù³,sÌFP0+Uê’ôîŸa{‚Nåt­v)hËiL3^ÎdHÍM’DäœCa| ;+Â8› ß¶~,•Ë/%úrÌ}ÞÒõ–йŸG0\N`ØÅr{k+]ˆ ú—©k,"*+Svbv Í.R@­]/õÝ~â†ÑÀ\Î Èn¬æsØ6,Ž“ÚáÜC©²e ãl®=6Î…±»Ž¯œ_ÜÚ3qÇÚ´àÞm±lxà™XÐþjUgsHË5ìÜ–2œHã2çð$¨fY+y¯ÂÑÕ|?Cp\-¶qqwÑ%".¯8"-aºé¥t¾¿ˆ‚ÝDZ¡ [é}@ß¹ç·f¸Œjr‹Í,él|2澫À¯œ‘áF³u…[±»–{À \__ ½¿A0 zP¥ýÏ ½bŸÎYš7ãùq:Ê‘œ Ð*l+Ü^¬zÇú‚vÒÈ`+Ì(ìµîÀp§H{Áˆ|8¸HSnÍ­ƒô ¼”|¼3–)6þàç„^s™™ ΔçíÉOëŸP&û¦é ïåc\è^5 üZÄêß§ÐØV6ï°ÖE·-¼ñ ýäFp•5nêªÉã~oŽ#?×/`lÕ/úa^›¨Ü–$ï>°{ñ¬n‚ÿûotyâ­ÑÑ<|Î1šý~ô/ËGC4endstream endobj 4449 0 obj<>/XObject<<>>>>>>endobj 4450 0 obj<>stream xÝVßoÚ0~ç¯8uªX  e«6i¿˜ú2iZÔ½DªÒØL‰Ý:N TÝß¾slSŒ ÝÞÆàäΟÏçï¾ã¾3„ßCOÕ'):ÃNàøp{ ̘ùcS0}3ô§Ó Ië@˜xƒ¤YNá-Ô4‘\øY7üÕ  ?D3ñN N*4¸ÆçöUÆ’¼"N ÔòıŸ>š[ ¡esG M¡”¢J$\·Ëƒ æExu‹Q¬Ïš³Í¥j=NéZRFŽÌ·^z‘ÈÛâ5gv´‰ºð¾ïƒ WgÂBØßßë/ýñ`àî*&í&ósP‹§ÐÇ”õGcszÞ7.)Èe,AAªCÖnžÉ‚~j'{Ä n)T%% 9ÄIBËTÆ‹ó¼•È$¦ÒŠ%2㬄;ÁëŒ(ÿ%m åyÎWj ,.2¶€„³š2å«a3†Ö¬´[©¦ë¸¸SܲQ>Q±?ùã1“xƒÌ&ÐXœ–)èaØQP¹ä¤Üwx‰yfvÑÕ=¶—(àD`ÝÕ‡IXÃ;ˆ<ë„Ä(0»<‰¼2ÛPžZSÔºGúï׈±>jmÐÚµnÐz¤>••`°¸K¾šgÍ©¤Û4ÙÍÔŠæs’ J#ínXZ»É¶F»)âË$J…ÍôŽã›ÈË{!qLPO]^ã¥Q£F6j„•û\¨t.Ï\¥CóÂHã„¶’èlö?ÕÁŒÉ3óÅäæ Ä"F½Èóv«%ê:é°õ`~w´ðr×äâí1ëyH+Ç;TQnC\eyÞÆi¤a—S/ ÿK%µ"mM¹ÛˆÊ%¯r¢dר&ž¶cÓðbìVŒKdzl_D¡V3µ·sÄ6‚ú¼žÚùfEêGŠê8¯è^å¨ZpÙ}mñÚ €êü‰ í[õº¯Í;óL_Õs®Xrp–Ö ü<çØär/mm‡‚wߡ†l¯×Ûæ3ÓB‡³s2žÀt¶mP?~^}íü>ó¤*°éÅªí©˜°-kïþ…þ“0ñ'þ>¢ZdA‹[LüSOÅýdγ´í•“áПÍðŸ6ÂI 0¿„ï?r µœendstream endobj 4451 0 obj<>/XObject<<>>>>>>endobj 4452 0 obj<>stream x­VÛn7}×W PXÉÒêf)jÝpÓ¸ÈKÓÂBúPÅ¥¼ŒwÉ5—+Yüï™!w%QV—ưàe.gΙácküÂxJÿyÞúuÞÄ\Üý˜{èß `a¾‚Ѧ?ãéôÌwjs‰'+T7™f¾BÇ/ÐïÀ{mŒàËtúíù—ÖzC¼•„·>³¬ÁÕŠ¿¾Ü¿¹º½‚ÆÒëX¢y*ŒY‚VÄ…•ZÕ`S\5U&€aˆ6Åqa“ ÜM”ÖT .1¥Õ6×U™m]¼ ”O•?QØ! ½Ñ(“$²ÛB$bÕúäõ¿DWKŒ`MY^'^à7·®6ˆú½—Ol[CùŸh\C&­E‡Jo¬³£W.å&dS¿ÚÀA"©rríPõ°YàLËJ KU)O ,A¤¶ Á,å3.1k\VV`1 Èu"W[çz)R¶–Ú4ŒA K<ÉÒJu ³ìÀB 7hC<±¼ÈD Rº°Õl˜²>€œ=8J*g÷JÚ*Çi10‚%=­°Ê»H ™#Ÿ1yçå¤*-^§ó,È!6ÕI s ‰ç\×E™ËûÔÂÆH‹TÓ(®ÕÁˆ‰˜oS«ß‡k—›ƒ`Ò}t¯ää·à5¹Æà1:ÇÄ>!ï^š¤œBÑÿzãPG´H-’ê e™“WM(ïòngóî^XXU é£U`ñ, +锕ET§ÓY/Ú¯r2i­`ÚÁs壱‹hÝ»zêÐÏ9þlékK_Ïôõ¼h¿•ø™Ãa_x×lÆ»fƒ ta…ÄdY…a˜'gøUbgÙ=æÒϱ½Æ6 °¢ÌxN¼ù4rÕË/ÈŸÆqtA’¹†Ræ2ÃkVðTÉGlž§´¹Ñæ6Ò¦^X¹È—”XJ삈H¢…Ñ\”å‘ÜV™tB=T¢ÞÌŠqñ6iúáŸèqXwžbì4þ™ þ K4?Ö¼€·âÎUe?n±/69ùÆ TImÏ£ŽƒÎ Žˆ¼¾*ÃþŸmضl1˜1g%ö2G°áì$ÐÀ€“Iezƒ€j¨9¨4çÂLCF¬ÑZØ+Ü0¤¡ä:‰qÝç'ù?mFÇ1âßÁ>/XObject<<>>>>>>endobj 4454 0 obj<>stream x¥VÛnÛF}×WÌK Ù°],ÙiÑiZyiÚF@^ +r$­Cî*»KËjáï™%)™‚,»©lØârv®gÎ̷΀úøÐh"¿iÑùeÚé'}nÿ¸½¾êÓe2¢éœ†}š¼$“ÉM³(Õ§iÚ%*ÔW¾)W+v×ÝUï­Q_Ÿüt2½íô©7€PÖ}h=½Š¯¯ÎIÞΩÕ½á¨VݽÒFåùæŒt ¿´ežÑŒÉÇÞsFa©ñ|³åbI¢[ü¬”u_ñ}`“U§‰.¥Êˆš2ª°¤²Œ ¯)SAQÁÅŒ?ƒFöÏë£xÍØÐø?”h+µc‘&xjS´5dç¢UËw•Ã_ëÔ‚I‹ŸLvvËi ë.'‹$ÒŽîT^²§¢ôA|c 6ßßñDÿpçÎÄ÷Úm¤BpzVܲó–Sb9*ÓPÂ5ë`1(m sÏë%;T%©²2®s%i?—ˆÞÛb… f:×aCˆ—ÜÏßú«³ç2!ˆ4è;ÄîIÅl &h§ÄË}-HZÁ¨eæ÷mn5%ôY›ô¿\Mk܈Ja,\Sü !ðm—°µK*l¬*r+%©½:ƒ`|ãKÔ,gÚúE1°¥ò(™.­gS'ù ‰Ñ9š¬7œH’ÇÉ8¹ ßÙeky/èX’$åSš*Á$Í è=­œ]8UÐZç9€ugs$y§‰rýUP‰´×å{ܼ½á0ÐÊY7lVœñ¼¾JŸ*lþÓä*¶,Õm‚€W®´{º(€ÿðåFF”ÈGGÄÖÓÈf¶”SöÙt©œÜ;E^ ~guÅWGÅÛð¯Ú~>ÔyЧ{ä5Ú’×—%pðùËÇèf`ÐðJ,I¤3p$º ¶Ø–ü ]»Ûâ}Å%‘ä‚SÆWòÒ7§¹ªßÃA›I¨‘ƒ:„ Ö1~nAOkÇËðp¬”M ›2+eSÂFöX)›6²Ï”²)áVüp)›bÝ´+‰Aó}ðŸ> ÿªyj;ÿ83±±QDP‰c0^Ì>]¶ìíæTB¶ ;8äuV*¤ðS Ñ¹Î9¡wiЉ ¹yiÀ×ÖøŠX0‰*ë>x;³aÙÕÖˆOè£L7𠘊Ï)Ú1ѺàÎãPl…G§­Ç›‡ënuD§öúä ÖqŒh0k[·é~°½·mHZPë­»7Ú;ÐTüy?ÄärjïDOšô»˜w&A&p1*}> [ûôsseÙšòÆî¨›·ÕÁßÿ!hÇŸ$ qH ÿÛ ŽËáŽ_ßåõÖa‡(® aQ Ž¥Ò®Z×Ö}õÕPÜØ’*$òýJ±z- ÊTäS§W‘‚se%ö¶^=µl¢„íÉÈð½ß4™Šì :ÆF 2ÇÖ «EBWèt\PXV¤Fô»¼üe½t ûçÉx4¦ÉŤšóÒù½aÒ§_mZ`ò8Äb¯d{L¬ãÁ ¹¼Ä¶!›ÆPnÿ6íüÙùô…;endstream endobj 4455 0 obj<>/XObject<<>>>>/Annots 1424 0 R>>endobj 4456 0 obj<>stream xWïoÛ6ýž¿â°n«“ÚjlÇNÚ"Ú´)‚ M—+†yh‰²ÕH¤FRv¼¢ÿûÞ‘’bµé>,-[¤Ž÷ãݻǿ÷†tˆCOù\ìF‡x¿†üëêÝÞh:ŽF4â;4zÆ÷œ®÷v¿4 Û½¼úz¶cÐ[5Kzz~H'јf)` §Ócš%þØCšÅ½GôAš|B66Yé(Õ†DKk3µ$%­“ ²XH³?û´wHƒ!^Kz?j:¥3#…“—‹O2vóÞ|ÿ=ðó¨ÞFB‘ö[ÉêB®ôæ+ƒƒ—Ÿ3å®dù…?­E^É/8ä¸kæVB-%ù ¤SÒQx- ï°Õ§çGÄ~¦4@؃Ѹ»w‘ÒVW´kI‚ríØ@¥u¦Š]e$%2Î….ÓÊö)s”YÉ:³b‘Krš]áÓ ^Éø–ÜJ$R' ™J)ÎÛõÇ‹w½ÊÝJWËUŸ·À,[ibq—Z'#œVWÂñ¾-m²<§6·}ïk!¶Á_œ[è$K·¼³4©À›i§2E±4Nð_a¥êƒFG|Ðy¦Džoû¤´«â ÙU8’e†í~*—oÙÞÙ“'| ì“•’¼½.`¯Þû€äËâÔ=ïÌÓóg4DØ)š`0š²[“hÐ%g1ÁËÉõ>Š…®Ý—dcDYbŸp_]¶tù9娋´ê±C 8Ý©OÔN1¹ØbÇ(‚>0n“€—^”uè…üÊ;s^ áPuøÉåª,²#\J%è£-§ôŒb¤æ=yKôTØásƒöñ•ç==;ßè=ˆtXB{Y­øpLJSi4°WXÒEæ| ë'Àk\·* Ù¬(áq»½lÚñ&‘i¦2†;‰Üé¥äŠDT7 Ÿ»Bö·T¢È`©=úg£7;oc4øÍ£•†úŽä¥]fk~ËWh7ý÷ÇvÑzí„ñ±ÿÚ0÷Q*U1qÞšÑkY¬Œ_tóBJ…ê ï€õq–RIô²F@×¥Œ³4‹C/À7.wèwòˆöm0ŸHfÉE]ti¸)­²åjÃZ^3'rŸV*öôA¶ŠWœ¢~€Ö.%F£h<A'½@*ô;ÈT››»”aÞ ßè`=ß§ÏMÑ<ƒ])Z^Þ½è¬} }‡ m=ï1 êì $Ÿ,¦(p '°Í3åiÁÀ%ÿ©õˆ"´F4cvÃàSŸÍÂ×Õk¾ßu‘‹ïŒöxy—Y·n¯{?[@{¡WЛ@:N߬Pј‡ãM`¼åÌ`¯q°©Îs½áµÖIÜšnRèýÈFŸHž7¿S2ë|Ó¡šw}inØÇ›nÀgy°¾NPÜ~쳋7Lå%ø¦*ûj›AÛ~þöñ$ÃÛ¿tpvùþzÆ×þõRj€×à¢a–Cêb†M×4ÒV¹k×1BO^¥Î{Ü\7ï¤{e–vÞkœ±ýÊç»±c|ä)ýÐÿ‡úàb·6Ùnç‡íÏþøðö¦I!:=¥ÙÙ¯7o¯®.¯t¾µQwC»ïÛðê¸ND)LÏ{œ ´ôK§Šì—çZ:äøÊ礗ÞËÍ/° ùSÛ„ÉpÎ|ÿ!‹;^^þÒ=ð¿»]FZ¡ ÃTa²F;†9„ƒ‹%Ø|–X:Z×hƒàzÀý$ïœTIxÚ0DlÏdèiÜÖí"’d‡b­X^à Z4.K–H²I™oš¦­º|Þª ¤ÀÝJ n†½¦ž•rH»J@Ý…¶µ`ô-’Ö—ؽ¨²<ÁáȆ+'ö§–B÷’«QNFÚž À5k·ï#o Á3¥õqN`Êzž|ãÛâ ”—´´³¬Ÿ¡`x€†Cõx‰tÏIP+“hJg<.”…lC1»õÂæä„ïjÙeDGÈŸ’,Ï…Ô8šß'Ë“Mä5‰+ Yãùn—4ï ÛZª²ähi”2ç}jÔÉa¦â¼‚ßÀ† 8³–;8³„"Õ¦€SXyö—МŸÒØàÙzhxЦº2p¼(€hdÐkÀ:,žI}T)v˜çHwZåpê­ÒÂuÂW¢£ÄvŒe®«ÛVò$Prƺû²²1:†<˨kã¡ÂxÅù‘§?Å_‚à‹òæê°0ú[«’‘Š™A®XŒT¾^ pº(µJ¸NXÆ‚«íKÙ§f4¸…´l”Eˤal*\Óü¨û:û~®3o!?ЬÚÀTfkRË^\H¡¤m¯å’áÜëÆÞèøáIs¹:FÆ<‘ÏG¸V†ÝÍâð Ohz<Q‘ÁWÚ7:®Xºy,ð[¸¥El‡Áð?oÜœÑ4ޥɘ-¿íý¶÷/O;×Oendstream endobj 4457 0 obj<>/XObject<<>>>>>>endobj 4458 0 obj<>stream xWMo7½ëW \Pj­[–{s¸Í!‡¶*r1`P»”—É.¹%¹RÔ ÿ½oÈåÊRÛ(bŠLß¼yófò×`Bcü™ÐlÎ?y=øy9gc|Ùÿeèìöœ&cZ®ùÐü ŸŠpòá55•ÈeiªBZZK­“Ö‘7Ô´žrSHž|)i%”ÖJ?Y‡/nÎnÞ¾¥­MÃwU%3Z–Ê~jã<Îy©9`Áñ ¹VZ¾Y~ŒÆ4šLcØXÙX“Kçðr-rkðt‰…•ñ¢ÒT øNæ^í2Žpv{ÑåÔ‡ú½Õ^Õ2@ŽGRÚÃpeÿhÀ2c¬Áµ¨áŸ>üBBœ@B­t^µ Áï9ÊK™aø)€Õ6±žÖ­ŽøŽð¯v++gT=ÜŽÃÚ-x‹€'‹.©Ñe6¡é93t7_ÒaÊüËj‰ßþ*×­ãæiÇÌì(£èá:ó¥p(5êÖe^P—BŒ½- O¿Q–etúÏÑ«T(Ë¥Ú@ ºVT3€wsO9ïX>eÀÍ7{BX?î±¥¬‚¬¯ÿ›£O@9Å#¬ÿ†t;¤Çzï„íèAji¡Á‚DëM-¼ÊCVà…ó$°(ïï/–öc¨=xV^‰JýÀF?…°çh XIh`u@XÂ}°˜C”µAQ@»¯ƒ{EœÁšFÓEvµ-XmÙ<›Ò {‚Ò° ÆK«Êä_Ü!lžžgA¿ñ4÷_‡h8ø…mXÓXf£Ït*f½µ.øŒ–Ék‚>÷ösTAS»’•Ù²ÿàŠåžˆ v ±d!Àð¸ÂÁº¸ç¡|Wš­þ)f3¦E6c¦œÏ4›Íð¯bxŒN¿¥Øì¨C¢ÐÎh–©/ù7‡cÓpÔp÷ÔvÞõ|Ìt*ñôRÔØd/í½6frû瑦S¯Êª}g8ò|¼ý c^GÓY6‡w¢6,Š·uªë«-,¨‚Ea}Žq Ba{pÊ9ŽÙ³þ´=&!D `dÇ‚¼â—ýë•„ÇåzýÆ*ëÆïøûÜbäÂd½@Ÿˆaž­„†}qSÁóE[ùnH'.}¸Qûz€¶bÇ‹#‹ÑÈú¥ ¶`ì×n/ð¦I]šêÎ^Ž@P¤wݨŒ½ñÈO3z¿‘v‡é€‘Šž1î¾Íƒ·p rÓ(Y@Âͳފi=ï,áñnŠkã©–7äÖô‘W“@Òé¼£Rl¦SIÁ› œÇµyÝ-kÜž\i¸ ‰dt]ðvÃëEH>z%؉›H×»-6 öT0€Åi)Q–α¿gGÇ×»ø!‘åФ~HÛÌI½»™dåÉá0Ϲð!øw2¯¸{ÒäY€{x+½ mcV SË{ùÕ[qŸnÞ ïÞP:¶yëÀñ~qÔÚ× ¶®1† Ð°¾>æ™;Õ`Ž+L˜“¸Oœì³â›÷ àñö陫u7ïy;æÎoZÛ\4ë„;첫VU<`QPÖ¤´k,Ö?Ò ’Ü– Zbã.Á;Ks£œZ¡Uº‰¨­!•nÈ+êŒnñ¤ü*ê‡^˜JÖ³Û´BNçÙÅì‚æ‹qvKk4ÍÆôÎäm-aiá©ñôè2V…'ý$ÓØT˜¦|¾˜L²Åÿñààœ¿y¿ü6øÿ Å•endstream endobj 4459 0 obj<>/XObject<<>>>>>>endobj 4460 0 obj<>stream xµWM“ÓF½ï¯è(¼°’?ö“ä›,ÙTRë W‘±4²'È3b4Zc¨ü÷¼î‘lËì—evíqO÷{¯_·>i„¿c:½àÙêèÕôh”ŽðæöÅ/hx3¢«ô”¦MFtñbœ^\\Ò4—S#šfƒá3ºöZMЬ^ӽ΂óôlx<ýçhDɧòAT0ýÕ~ˆƒïãϳÁ옾ôÎRûÇëÐxK³A÷-œ\©²tÙlP›ÏÚÝG³ãÙñ/½ÿ¶¿!iÜþ¤û5&3Ò[·¦µW™@½/vwõ3”àÛ4ž0 Â&“ó‹~D·¶4V甹\ÓY~¨9òðæŒøÚh'“³ôŒº36Ó–š*ï2]×ä äc‚± Zê²ÒžŠÆfÁ8[“©©PÆ—Ä^­œ=áozÍï+ª+U’i¯/œ_q´]8­nj¤§ÌĵdÇ¡¤|ðsÌuŸíd2IOOÁ=ŒÑéIŸ©ãþaHÿGÒ#Ë‘ôüBÚéiGÚàw5G~º*û¬ (7²5÷ÜÖÚ ^– 1ó'0 À-ªh?‡ØW8œœYj•ƒÐÊyæ“¿©,ª}¡ ƒÂ”:%ÎG‚(¶œÅ–Jyæn¾¡¹ K z÷îö5Ô£[¡å”ÍIzŽÖÔ"Rs‡Ìõ'µªJÜ ­Êºá^e9ñ·pØiÿЦf:[nzé9«)×Y©< w6¥¾cI¶6h T}pÓNW”¦)R6ˆ}ÄÚ]Kt À5§_»X9ãqÂíŒÃ¦,õ=\/M4]ÙHø¶Ìâ+mŠ_eøå[™¥±žÎ¸Ã/¸_ØÎàhhUšÏ‚Ê÷<áHß* M5G^Âö׸™ßëÜe@5«”Ý!‚¹Ê@3±FxÇVŽ+—7‚ég×ÙMJ7ÐR«Ä*h㚌VëÁlJì¦v+–Xðê0*äÞ^W:•C<'e6e.†Ç.hêïºJ:ðžnJpïï•7j^êšÇItšGb¾{_¥#™dàê’^ZÕõã«Æ”œ*Ý¡  ¢õD¿ºbž§È½ÃPgÞ̵ô/-´ÕT:TeK¸®§yz×ýkƒ†f5F ;/LV“×%nœ÷5ægƒ#¾¤âAÑ#¥TvѨš ƒ¡p ºÒáž²¥ªðý¸Z/Ó1ý/Œ¨[Ñ5Ï¥…W+Éš³ë‹-bGûPîtmŸäü±[2çEˆî‡cÒ=¢²œt©èŠ h‰õªðšVÌéÕÇ[ãdƒÄ„DéˆÃŒQØ}½®›2ô'ÙÊ,–¬ 4×´æÑÇŠÓŸ0'C’$@®Ä7ã ZM™ÒOe¬joøÒ‚ê «:ª]žKZ©bi;*™a`×ã¥ÃQŽE + ç6×6˜b#Íݵ §Mw­làKxGIé6 'DšCã)ÍjÞ”GG*“BcòlˆÝÝÅd<’S’™ŠJÇaåZº†ñËPk€Â ãŽãb€tGÜY+[5Bk­·€¤‡B›}p¶ªÆ çòŽaF²0Vºþ`""# q|Õ.U K7b:› ¡û:å Ä{Kê6E¾Œa×¼BÈ·Šââæ–Ù¶©ú ÉÖùX>qáºvUd_ ¢‚a…Þ¢<’p«ü [`ƒMN<²ˆc“—“wr}ö—Eê¢pÌ2DÃöEûl¸×~V y¬ÌHÊî’ºÁ"O!“5ù@](ª¦—oïnézxýü9ÕÔ§oþ|wó¶¶ë—¿ › ã¬8ÀëiŸ ^’ø ÜÒä¦À`ƒõ«{eJ<—„ε{Ö}—$Û¥N[ÁEzžáà §wA;Ø$#f™ó¼Â y¥Ä2ßZ®,‡htA®[ŒRzãjxíŠWO8J¹9H…ã™!wÏ5;@»>ðÃÂOôRL»]³ÖØ«(h¼°£ÂÁ9kØ&Þ| uvà=|Š6nÜ$-k~œA-²”É-M݈ëpµÂS D¯½Ç«ÃðÀѸã kÍ‚º êµóˆ§)Ÿx0+Ø»[³ e­áœ#ëýÞv±§êÎjÆ—XëNÏéâ ‹„ŒÎ7™¤#úÕeÍ ­$–'£³ô‡“Ëø4Âá„®ùÙ0>E°‚vO‰çãqŠ•Bt}~Î~›ýyô—“ßaendstream endobj 4461 0 obj<>/XObject<<>>>>/Annots 1429 0 R>>endobj 4462 0 obj<>stream xÍW]oÛ6}ϯ¸èÌicÅßqºaÖ5]€ Ûš}ñ -Q‰ôH*®7ì¿ï\R²¥®)¶=ù€e~Ý{îá¹G¿ŸŒi„Ÿ1Mü›V'£d„oøß˜ÿ½y}2YÌ“9ͯ¦Éˆ*šŽ®’YóTÒÝI÷£³I´óŒÑùe2鮽êî<›àÄÎh÷¹¢Ùtyˆ‚Ïí>ct±L–µßßw ÙØ ]ÜÌh<¢ûœS]\áS2Ňt tnl%¼2š”#m<¹­LU®dF©±V¦¾ÜŸ“/$í¬Øn¥u” MkI®^ÍÖ«J”$tFòQj²ÒÕ¥'¥©Ö©©¶ª”b]Jº¾¸~ñ;f29»w2¢áx‚H·9íMmikÍÆŠŠ áHP%”^ Vg”cîœgáë=i‰È¼ÁAZT’”§ÕÀJ‘‘Ñ«³°÷ÅÍxÙd<¼L¸Ô8g5Y\Ÿ|„ƒÇš(ÞÔšîÞÞ¾y4aÿ§½†“erEÃÉŒÏú®ô…©7P¦´35âK• /³ˆ(’N¥säk«™Úsb@6Ê–{’Âí‘V*Cò‰a”¡zC&Gæ-’ñÔ[†Û=1c]«2S˜z)í¥ÍE*Ïc¢•D…jþžÜ^{ñž¤µõ5– N EAí*—Ð=^Kçi‡u2“(úNù&G¤éM¯®N!×=RÞb>›<—:Ãàp êìäVXàq r0&Ò)Cm‘$ýhv –…*ex.Màb!ÁLcÀ LÚËüèƒX¬Á<$l€S´Ã!“Ê¡Ve>mõÄ# Y¢äEa·¾Dàf ÜNm†!flÉëJå|v{Œë§÷ ±­ë y+ÒiŸØ¨aæñÊÁïádÁ¼›',4\ª°Ñ¡äSÞëÈ}^3ƒfaÏßZ™#c`XIp—)§:àwâòÒFjŠõDÕº«·[ã"]Ca»Ü”¥Ù16×TࢂW¡Æ/cD#Z&SNcÂ1M’éOÙàâ9Ý0^6k’‚ž_<0+Üè/”NË\úÚùL™¤ø¦f±ËÇaÈ[q‹å{Ð>Ü ÄgVƒÌÔ`úêì«Þͬ8HkaWLÎl}bê£Qeuµ] nnzEÏófâz8& âüŽü~ Q€º³õ‹†àÀV‘.r»@ØÒ˜Ðí!Òúˆò¿ÅõpR¢ŽÐFìN+“Õ¿ÚÇ=PNÿì=p~CLŠg½ñÓ¿zŸð¿äP§:ÀõŒ §‚Ÿ¸uáú¸ÞCÆYÔÐø í$/†lÔ ;t, XBƒ´F¤E°0ÔQÞHû¦bÊ}Þu:moW¿¬Ðxr 1«wmÙ£@3Ù°äGT p3T:øžêÑÁ¹¹a^·AE˜˜ø»†‚%¤[”ûŸt±fP—ÍS&t«[š[QËâr½goñ>ÆäœÔ XyÒu%­©]c`!$9 Z(ø€cþƒPãøÝaj{>œê<š\%µwíø5º à™¦q´žÑWpe-zH|¸´¥L:µÑˆ€!È,ĵ-Z"ƒ÷©Ž1¥·Å>ðø ]wßöÓéôŽƒÓ Úž0tVĠщbè¹™£þM]83D¼³ Í÷‡='$ð8Õ?yÐfÇŠ17Žˆ`?óÓ¯µFÑd‚œ ƒÀŸc'ƒàçÚ!õà,Õ¦`s£ƒ˸ë77¦¹±u·!‹m`l´dç&`8øØ4Ø8Þ›EBo ­se¢ *…Åhƒ£ŸŸëþ|~虥òëÁmBYxÆaàc>.µj  ÷¨¬Ñ̬àÑÐÆðyH‹í:ßžª)_ßÇžrÅÑQÞ}ܱšG…΋zt|ëk­ @¢ u†j¦ úhÑKàê×lp ³ëßBë`zq·uмºö#]ý©€c:·­É <‰/*½ˆâŒpyÝ­þo?ÿ÷È–ø_Fëˆ4¤eACf’ò» ,„ç‹,…e:t/ì­xdõé˜áhÙ5¹@Nà#Kéd§Ìº»Û'„€náÕÜÈ8ºöxyú(þ£îí«Òørž,¦sZ\NðN c™ 'x7ýÁ¤PFÈ$'ÎŒfÉs‡—Ñ/°ñÓ¯°ÐÂÆ\®9ŠðBÇBÎ[ñÂùxœ,—ñ…l¾ào^ÝŸüvò73M¼aendstream endobj 4463 0 obj<>/XObject<<>>>>>>endobj 4464 0 obj<>stream x•Wioã6ýž_1E±¨°q’]ô@¯Ýh‹m×Å¢ÀMQ6ŠtI*®[ô¿÷ )ÉëØ)\ä´DÍñæÍ›ÑãkB³kþ–õÅW‹‹q1ÆÅþ—_Ñå«+šŒiQñ¡ëø¯LðÜÙ¨|%¤¢Jhã݃. ªWø¨¤ŠJUi«£v–\EÛµˆ׊tÿ´ý”´6j»¢èHý•-Óɰ QÕ$…¥•ã{xüùâ÷‹1&SD4Ø›â@Hà9]תÔ"*³£ Tv«‰¡XâÔVǵk"­ÅCë²Ô+Ò‘ø"]+Q*ŸS+ØÝå«Ém Æè¦˜Pöý~z}Cùö‹t©¢Ñô¶xA£Ù-Ç6/nŠ+z­bN ‰{½ZÃíæóãÒHkz…gðð[W«¨k†·Jª„ß1 À•ÊG¡í9@KΧàOJ‡²¬”Uˆ”´ÜÑÛww¯Ù†tõ†1Cí6Ê›]A?ˆ{E¡Aw®y³4 ô ›M` E‹È•ˆ3xö÷ðÙ?‡)hiœ¼'£á+®ux™ï鶘1Û¦ ´˜Íð©<«]Ù È•›µ–¡‹Šéó?Ö6Gùéëï/W¦Xþ_·›Ç÷s¤ì=¿¼¤7 ƒW!q¢TÒ`.@î{¦ÃEÑòdO64/®A‘– sz—ÀQé©FùÞÞ?Ïœ Á]Å•ð\"Pç~B»}ÚÒ€ªÆJyÈvào¨þJ!7]2Ý™ø‰ZQ£7A¶ŽC-Ñéõ&±Ø»jÄJ,.ÄßԊLJB0Q{r[û˜ OÅ„¥*™‰‘1ý¥0‘k Aeq®!a‚CÞ÷Í:ÈEãl×ÊÒÖù{æ,kÁAå8hIƉ ZpµIðUjKbƒè„\Ã$ ÎdA{ç:öì*9éle´Œ”¨uEÓ3I ]Iδ¤ ™:wR¤1?ШŽ_,`­zþœk~¦·”-Ti͸)@‚_Á*g0š{™å%Ë IÔýº'/# &&a °:¡e²²Ž¾aì>s¦ä¿ùTþàd²GŠÜOÙf|1h-Ó@¦4µ4WÒY ŒNB#l AQ !GvG}_  L<.„ÖSÄë“q7Â'f×0\¢¯¬j{ ®ybÝ‹| ú޵-tæžùÎmÕƒòCîÝnŒ“YÀ"È´À…5Äï¸ð0/½Âr±§R[×Á´¢ Œ¡ÆÍéKxµAÆlBÇŸ‹@Ë£$?Knìzcójc°š¦eGÐì6Cz³Ãʇ1ˆ:.¤i+ß¶æ¼]Wúšýˆ2µkI'#Â,ØÉà/EžæiZçàœU°'¬{0ŽA¤-¶pŠ*„q^¡XÚ:…M}¨\ðmµ1ûñˆK HÔÒ´N1£âP`Ц<–õÈëßôK\ŒÞ5¼'ƒÒiü&æsÂÜG¹Ï‹¾Kxx%[J‘âå€û•|$0¤y–àÇóúttŒOŸ@<‘¯#à=œeª²j,oÿ¨’Ä‚Ã//ªª€‹âcZ†]½t†–ˆ—)_+ ¡Ô¡æ®å$yïmï•Ïp.]Œ&ÇK”Ð~»B¶Üë^+¦ã«b>›ÓÕÍu‘^XdFÓbLß8ÙÔÐñ$DŒ#öÓ|vtÃkv~Ϙa¹Ì"w:ÚñðÕ(|ÁÏÎ'“âöoüØ _ùvqñÓÅ¿$Zqendstream endobj 4465 0 obj<>/XObject<<>>>>/Annots 1475 0 R>>endobj 4466 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 4467 0 obj<>/XObject<<>>>>>>endobj 4468 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Íê";W?Kù±º8¿Ì®póê†ïxF[«;·\|Á— ˜ý<¾ôäWë5ÏirïÕ'^ùãÓÉßNþ œ ¹endstream endobj 4469 0 obj<>/XObject<<>>>>/Annots 1477 0 R>>endobj 4470 0 obj<>stream x•W]oÛ6}ϯ¸ê,±êØI6ì¡Í–.ÖfK†¼èh‰²ÙP¢FR±¡ûí;—”ÉX24 ‰—÷ž{î¹ô_cáwLÓ9ÿ¥ÅÁ(a„?Æüñûûƒñø$™Ò|6MFTÐød’Œ›7M7ÝwÌžN’“Îì»ÛŽÁ`Õ®èÍå Gt›ãäù9²p ÒÁíZRn´6U®èâèˆr)|m¥#a%•ÆSZ[+K¯wäêª2ÖËìûÃÛ/ð89µÁ§iµ™ÌON™Ò‘É)•Ö U’©¤ÞXG‹A)7Ç”I-½<&éÓdqȶÞ\ŽÏ‡§ˆ—,&óSгm<7Oxö£tð„R-œ“”añ ˆo)[|ZÔ‚4 –6ÆÞ kê2sÉ·ø5œœ%ç-oÙZKÁ¯ëbyL7wWïÉ­M­³êRRíà¾)ÉŠMޙڦȆÒfi-©#X©wÁ§Q{Û|íâÞ˜R8€—+Ã鬬ù"SOÎà¯hÜ‘0¬U¡¼ð!Q…ؼÑ*g8‘®¼æü“E’M賑Èë1m$âžY0l3c V¾ÕÎ õæ={ hY¯`Šiœc‚ìheLFì ­¤gG—Z¡náÄb6Þ/›œ£ÀòÀ_:pnަ(D™Á÷ÁU1HMQ)ìó'`—œ1îÖ²¤UÕR?5X©‚§©U^¥B#ÂÇô% h8¸Q~ IFó(^06§Á0=:êŸ8xÝx–ÐíéI×¢\¡ºx7# ¨Ae.˜æÌºõèêtMÂQ!  ¹XÉ•*f3¸–ÐÞ‘’¥¦ñ +S³*è†s¸ÌïådÍéÁ˜Úþ?ʵX÷< ÜÞ(­IÂBQÎÕ‘m„-[– -ì Ôy ÖíJ/¶$­eeP9ã.˵ç¡!ÁGÎ3”V<š‹¦>úuS8qÏÏŒ2´¬Ö!ÙMAµy.-8Ë&T¯gt¢5iº„ór+ŠJË zo.Gt}F¶'̦I2â-¼"·Q+bÐЧ#îJT VµW¤íôgv*I·Û(^¨©Î²ÆD\cèÕbðé݇›Å! ‘߯¼ Åø¤ñÃàÖ4™C<áÖ%tÍ×¥ðRïŽ ¨¶T:GÂ*ÄiµZ³¼ƒR€c*›Š„~åjw¬;SÈà)F)3iÍä Eö¸Õs’=r]®j°“5µ>ˆv^ÛÀL¢3hï¦îÔ½ŠÄ]ƒãûë"/gm¬i<€ ,•V~GosÔö‹ý,,Bë¶¥pÜJ–Ü”PË_j‡ŠaZ{A¨‰Ù 5OÓ9¿ƒŒ¿½¾â°1b»¡å], Vˆ!ú×Êx{Ô°4{»‹ÓON^,\Ýbqlª”ÛÌcô±'«;«J­ úïYZžj¢l$BW²Ÿ€ˆ—¥uF×ìvÛ\ûîw5ô zb¹GDú P°P4¾A ¨ŠF[s4ˆz ‡ö¢k‹ÝmoÒg•K†í±_X7¨Í®’©‚ýÖnȺ_o0ˆ§ßU¬õ0­¸Ð™×H d¦ïyrRç=e€˜ä=gP.¯Q5ËZé,h]ï ²%"Èp1ÀÕ‡ í‘Pœý(N!õ¢]Ýñ4¡OÖœ qÏòñ zv{ž<FØ×=!¦Ý¥ÊwÅádÎ 2Of¸u]àRçm¶=¤³Qº¸³åw$HèÒ×]¨…F×ClÍg° /·Þr—ØMèQŽ(á迸 ¹NaŠ” Êœ×eðˆ•ÄêÅÌeÍ—ÜUìaÁ"¶8°ƒ¼V8.Ÿ—Õ=° ÍÀÐß­É ÓU½Ô* {™‰aŒÂÖ.‹ÃzËÃÌ?ÏOq -…] øiûŸûã¢mßò×ðú|pŒ%“hWNÖÐïpÛÝrÄæ—E@‚ ߊNÌ÷DV= %Ï`Ĉ|ÇÕçE\Ã) î^2ºÍ›¤ ß7>¿÷×ÈÜö»Çøì$™Mg4?›&“óÐÖ¹[ 'ø*öS·áñ64Ú¸zxó>ǵà¦ýаnïn¼|6óÅ30d>⑟o~;øÛlPxendstream endobj 4471 0 obj<>/XObject<<>>>>>>endobj 4472 0 obj<>stream x­VßoâF~ç¯)8ü áZåáš+§>õÚ Ý Zì±Ùdíuw×ZÝýí7³6Ô&P©€, Ïof¿oƶЧïFþ…iëçy«ôéÏÃÅ$p3ëÃ4Á<†a&ïÁdróÈ[õa¶?ßfZ6z»[´ø»3jõ¡7 ƒ¨4ðV*t¸$ëEÛ¢ŠŸNØ~=ñŸÌ¬„Y´ùfû¯I ºÂd@I–ÞƒuÉå-©¶ËÝ…bjy*ó·•ô¢eÛ¥åD—«âr*ãÿ^ÐW_óÍl |1ôè{ÃQuˆíßbua,vA¨ØYxFÌAfÊ,·Ž.…‚œÏB%¬iac¤s˜±1›8a¨c D–"Á€Úo·"ÍE'£Ï;·ÖY×—¡R™¬Ýþ¨‡L¥õ3]$kµ%Ÿ)ìZÚÙ¦IÄÞpŒFD˨]¢îx³ë"Œa¹”™tËåžo¯­<5¹¥'ƒ{ÈpS2tÑÙ£;¹ I4¾ñ˜ê>ú™ˆ šžAXcÛÁÜÇdjŸÁI'"œ3{¬ÝL¤¸èœI càçp×Ûë3F¾Y5(5âŸ+лAp#ÑÿÆî‹PÅÿôH4e¿ªà¯ðÔž•̇DHb±tפ‚4ׯ HN¦ùZXùs¶’Ò›žÂT ­%EÄE:©3 Âà^t…ÅV»š4<©ÑðeE0kk労´‡íÃB’hÁòÖ$B’Œˆ^it|Ð#Ä(h*²)£ãäV¦R Ã~ïÞ0gö{M’\CUD G#ÁÖAiÉ,é’ªC̹ˆ”µÈ"åŸÓ hš Tm•ÔŸýÍì= uLk§7œ°v'Ám0„?ÐÒ R‘ì©¡40ªÚ8É?§Á®ã`ÌÎÈþ‰°Ik „të½ µ,DCMæÉ”bª©=µàÔ—yN]׫' 5úÎDF„™]b­èì¨î E‹ÐËáò :Z}y±R2<%%"&o—+‰Wé™GÔ•æ<áîm¶ÍåàÖù9VNÌÇ\¤o ?xÝ4#{ÉÀ±¸/lC«­¦qcC#sç›\r“ÔàÎb¹lðˆidW=+á®Wð@›ËQ8ÁC­ö”õàaÏmð{þàÅ7ÇžlÕt |7(@|äøHzñ ÆhˆÈ ‹é\˜_`a `«Põ8W$ ~‰±`9\D¸ öÊ}\÷«îÙÖ´L2H8»ot)I»„ÕQe”+øˆÖ½£§ìp3›Voƒé8¸ÝÂänÜ•[øñ˯ŸzàuX°‚Å~@éJëÞ]ù>È¢x½9Søaȃªöv¾G·ƒA0Ò¬à91`¿Ì[¿·¾a-ü1endstream endobj 4473 0 obj<>/XObject<<>>>>>>endobj 4474 0 obj<>stream xW]sÓ8}ﯸ7IÛ´ Ã2ìBÙÎ0À.á¥3Œb+ލ"ÉNšÙaûž+ÙŽãšÂ.ÐàÆÒý8÷Üs¥¯Gãï„Nfü/]ýv}4NÆø²ùp9_žÒdL× ¬ý‚‡,¼ÇC:xg·CZ[“IGÅR’“¾Ô…29­äʺ­„¹\ISò¾”>¡OKiÈοȴð$œ¤ÔIQÈŒ” 6|êÔº†çö²­ë5–ÍwdäVï]9Óh2EDƒÚÆÚÙ»¥ZxϾ®—‚cð¤<Ím±$Á¨µ¾}!L*I˜¬zÝ|e!–’³Ô;Nî÷'O¢„®8hå‚‘wbµÖrñ«ãKà0,âï5¦ƒà±³&˜ÛãŽ5]˜ÉVìúÃnåFºˆR("Ö]{ÉFèRv=È(›£´tÊ–~4m¹:òN¦%J2k«LÁåµÔ±Úɤ©ÌúºPQ¯2Æ ÃD¬&WKVRìP fN¬:ƒÛ*Kt8«¡£—ï^us¨m7%!¿d´¸¸NrMzp!V‚&Ð& žÞJ|ÈÔ5ú‚0œºôÌè!¥Öp:‘éßÅ:§çä{ñ®¨¿—‰S±°ç$çØ¸Ü…>ïÂprȶb³8Ç‚·!}F(f¼/O×î÷Ësi¤ºÕJÆ2Ý[c·æ±Sts˜À§…³+pLÀ²Ô-ÅFÒ\íºÑÜ{6 J´o½Zho[[b@Q8P%#´FCTýHká •–Z8°9¶ãA<ì"¡rÄ =!múôÄQÛ<Ë” /Á†¬ÍUZX×µÑéA/öÂÖº ºÔ¡i'†î~0†:P<(a±µí d¥û–žE£µà4Ä-« ™ž²–^ª€e‹ð[îÒ%Ë/Z6(D¬pÔo0®pv'³ }4s-DÃ."ùóÓÃpQº6Â)1×òÞúÎjFã"®rˆs8 ´0y‰©dŸ•½ÍJ#É‚sA é'ê-6BéW6n› ®Ö˜\ÊÖ10/¡ô±•E‰©CÖÀSœ--ã,È^AÇV º·ÐnH¤ù”gRÓ=ZTfª$‘©k“"¡÷ n8çC Ü¥@¢¦u—$§rf@%ñöëú^YXâZTAªxAWU`aæWŽQ•½¨ŒGÞ][Ê$ünFôýó°AV¨ê!ª•êaÊÐËW¡ Ñ›`¤ÖÐ¥µÂäïÚŸër®U p7†ï(üÁþÿ±—zñì`O|y8„[/o˜KjŸ7ƒ›Gtè7.ˆŸì“ ç ÏØÁ‹kcíxâÚÊ–OžU6ŽéÂá>”üV<ßî§ñÏOƨt3¨œ#P_2†Ëá÷‡Üã’$¹!‡÷59š’ƒB=K7Ve”ÌÆuÕ¸Ͼà‚m‘~-•“?k|òcãßê%‘{B.pò)Eþ/’~¨ŒÜ ˜±ýT«ˆæëpºôúOˆõ&õq-V}m¨Ú[úšô8LƒÏ¹,DÞÉ¢t& Õ$Î^?·¶GFör²§ê¡èq·gç­ˆÀ²å3ìbŸÃÍè×ïwc€{êö”¡'¼.j÷ýdÔî$™ÍÎYyÞB!YkÃY³%h+O\>ˆó-pßJq Ä Ïpʨ ¸xŽ¢ü¿é²-ít+å' ¾Ž`-´Èy„*“©ò­ìû $Ö@ššáJ’0Ùšn¶xÊ"(Ãñå䢺eŒÎ¾#«›)²c18¾¬_NÎÏ’ÙÉÍ.­óã§«7£i2¦W6-ù)ø`À[Ðir†•£óHøYr–Lé/é1‡q%iß‹MÈZųÛÙd’\\ÄfS6õúúèÏ£¹£lendstream endobj 4475 0 obj<>/XObject<<>>>>>>endobj 4476 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·Ñ4Ó['‘'¶3 hŒGwM£`…ÞN&VFâÅ|Æ^~[\ýyõZÒ«Uendstream endobj 4477 0 obj<>/XObject<<>>>>/Annots 1479 0 R>>endobj 4478 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]]…Ñb2Çk²kû¹ß»ÅŽ£øÖON.ëz°ŠVxQv}_üžû ;9„cÞúb6‹p¼¯2«%_y·>ûéì/ ª5Ùendstream endobj 4479 0 obj<>/XObject<<>>>>/Annots 1481 0 R>>endobj 4480 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£?ß~ü8S°endstream endobj 4481 0 obj<>/XObject<<>>>>/Annots 1483 0 R>>endobj 4482 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 1485 0 R>>endobj 4484 0 obj<>stream xVÛnÛF}×WÌKZÅhÝ,+. ½85Ð>´6ÐÆŠ\J›,wUîRŠPäß{f—¤DYvj‚HwfΜ93ÿôÆ4ÂgLÓ9ÿ§Eo”Œp‡¿Æüõ×ÇÞt¥¥^’ Ÿa’JçlIyeR¯¬!ep²¤Ôf’”§•4²„µKèÎ8/E6 BKYÖï’«Ò5{Ñp¿æÄ>”+ZHkJ…aIŒ’–Q常€  µ½QEQy±Ô2>8¨!‹Å©ñ‘é‰ðwt:Œ€)Z±åÐT0ƒr-V×v`4úÞ¯[”8iÄdùY"º ÕÃúÜZOw¬ûæ{O;pn•+!)È»’QÈ3Is:K86 3#‹*š[ ½ YV‹øf¨‰­PšáÐZÒâ\÷ÛˆÎ3Õ¹@ÍJlª¥Vi`5s= ”$á°öúP’.–0áÎÑöM]î[§§ O¨49PI{YÈ"÷ç€ö¶‚®š(œù"J-aªA!D¶&•@8€§Üë}{È0`tss.ÓÀ_ĸœÚâÖJ ptyIw Ýi‰lx.ØèÙTå̩߀î^ Jɰa‹- ï1+ì ‡È äiøLÿ1‹]½¥õš&NõðJ˼fF6¤™„Áø°–°ç1è,ÚUK¯±¨8WÁõn-M<‹I‹2áÐ#Ø–ø5ôOá¤ÞÂ< ÍZÎSQ!4®-„.tX ă­ £e¨zƒ]ØtüZ¹A£¯4È­µÿ£?¸|a´*»ìæguñ_¤4"»Ûa©iGS½G5±Ö¢Å{‡zÔÂÚ,,6Ž6<“ewƒxüqK@êOÁMZŒÄàÏÏ­z`}ÇÃ÷g`èN¬­Uj×8«u0ˆX^tFÖåí¢ÞIÇ‹Yr5½¢ùbšŒã”å]z8IFô‹M«;cXšŒ¡h=¼ŽRÆ»ÜU³m´«(›^ÇÉbGÂüšïüúÐû³÷š¦endstream endobj 4485 0 obj<>/XObject<<>>>>/Annots 1488 0 R>>endobj 4486 0 obj<>stream xXÛnÛF}÷WLQ$U ‰ÖÅ–)›ƒNÓÆ*úb X‘Ki’«r—VÔ ÿÞ3»\ФãI&¹œë™™3üçhBcüLh6çÿq~4ŽÆ¸Ã¿&üëÝ«£éâ,ZÐüì<SN³é4:«¯2º>j_ãéé$š·Ÿ¶®ñt1n$¹wÇÓhF§³Ç^òlMê+÷´uÍ’§Ï–-S½åšN.Ç´€ÈeJÓ1ÍØù9-çИ–ñ€ðÏÈ,ý¢¬Ì =¡ã[‘UòçGË¿Æ4šàT2øÌW'—§Ä—) l4ÕÂot)I©.sa•.H¬teÉn”¡X´’”êªHp7%]ÿõú=FÅx¾[+Ë!9}ÝXÃÁµ-«ØVP+(—ùJ–¦{8x;€'1ÕÆOOÙø%TîJ±ÝÊ’bH²šÖ²¥°øEKcti`&Žd ËtŽßi©swh«UCÉî·2[ѲåŸÁáÝFXªŠBÀ\‘±¬ÚŒÉ”Íà#îm¼z =ò£È·™’ Ê@ðNWY‚»[øàô¼"c“‹ cKU¬½auèV”J¬2Xo`ï`BÂ@^ýBn+ʵ´[2Q¬+±†raÃ^m'A“w8{ öT"…±TÊT–²ˆ½'Ò)nùã\S.J³Y«‡dX^"È”Jç c• θ€;¿r¿Ê¶Ñ|°1»ÉÍkËêø«á2ðÈ<¨Óƒøù'ÓJTÉð¹ «†íà€v Mu–é¹bÕ5B#˜ÍPkÉà䄞Ÿ+…ˆµS¸Ç¾ùPòÓ‡ œ‚ÔWÒ6Ò Åˆ²óÒßÙ ÒùÞiù>Ù- A…¯wUÇèSÇ2òNy­Ýw>‡ËÆJŽÁ½îßERGQ+ONî½Íg‰ë èVŒO‘p-q¨ m•Ë2¤ëÿQ°ÓåC™úÀ0Ø“†ÊûšSsš‰µ³¾é_‡–Ô jˆÚŽåÀ´®+Š •ÊÖŠx¤õJÂÕ^hìeªJà åŰ®»ð„2Fa­4pk6z÷ ®zÍÜZPt,´%F–¿u(’º#¼DÑ»Z]§¨Cᢀ©á:z{ÁÆ±èØ·ú¬@-˜wG|iÁœ¯סzè!úÞÍ­÷èp7Æë1O³›GwpKÀ:OÑžv±ônÈ5#ïV«„  –o:ò‡­¦‡n`~Qew²~ó`}]P*P‡@ Ú‘X†ˆ Zk•Hqè—8ð¸Îô í}ðïÖmð"?ÚRÐo^]aËøƒ›2:ß"=wàÈI¼ÛgŸ6÷êAφ´ã†ïFÑA5 "Ã<¨u7jea0Ø\T+ëòS‹Â¤êËÍËDã8$Ò3Š©…@³s©E”¢0&¤O"yL=>?Ò*ö0XíZÅë`Z Âì_.íF'(5ázˆèO’–5ÞèCàëštè<¹üžÔ½ÃÌifDžÈ{Þ«0\ d'ËÔ:®P%Ðf*›¾©˜B°´¾¡Ü4úç³»¨w8ÿCDªõ†ðLq@ýké6–‰ SŽ!WÁ¾Š0u'|)b áѵ¾°ç SÕMKÜí§ò¼²¼#ôÔÀñÛþéûÎöX‰Q™§ÿgmaD/tñ“å…SØæ‹‘¹Šu¦‹¼²ïIîï¡„šÂšL±2!jõ*ÈÙ¬Š…Þa¹äýc‡VݬC(N`¶Þï(­ ·2µç.Wc¯×Ñ;Ë™Ji¯+ŒKl¼WÕ˨ã‡L|B¿¸|…F“QÿÊ÷–áìÑ^ºzË6ÃlÃös7ñžû;S³\¯Âßl Î ã¥ÙyýÞéVHe1ü\¿"A¢í¦ªÚêãžP€óÚ ÑväT… 5E°’àÜ7°~%¡½\¥J&‚åÆÜÑ>ýÊm÷ça£/•(œp;’ævIŽMM)„û~àëLc« nXÌ iõ+ûÉå¢V3ŸFg3|ÞY¸9â08ÅÇ™:®rð÷¹ƒ-C’üÉѹ'“óhÓ÷¹Â©æSg“I´Xàû¶¸ù‚ï¼\ýqôÔÚ´endstream endobj 4487 0 obj<>/XObject<<>>>>/Annots 1494 0 R>>endobj 4488 0 obj<>stream xÅXÛŽÛ6}߯¤âEÖŠmùš¢iÒ R è%‹æe‚–([$:¢´ŽSôß{fHÉ’Í}h“`WEÎpæÌ™Ã|¸ÓÇÎù_”_Œ‚Þð1ÿøíõÅx,h:žágN³ã £·aNãQ¬ü—<Ùcv: –ÝÙγóI¶3Îi2agílŒ(\¬Ä¥ÕVÝ€­v†ìÒ²7Ùc6\8ºì#wƘ]†0zœóÑÃùBŒòF5¹³ÇX:Ðv¶3Æ,ÞϺ³1ŸuHt×.x¯ièì®VÁÄÄngŒµãyo¶;Æì|Îve'^"³!McÙ9œNp"7’ÙÎ8‡?#ì|œýþ¦ƒK¹¡g×SDœn@j¾ÂC,HÂC4ˆ2em@7[]êÄ”úŠª­&µ6wš"kÚ›:‹i‡Rív:¦´¨ ©(ÒÖšÒbxg²»´ØÐåÍŸÏ®P15°é'ýGå^6öl)µmU±Ñ„'[¯« V×uEiE67¦ÚZ‚ù’/Ñp<˃DïiWšu¦sK¥ÎTgàŠ­Ê:ªêÒ{Èž¨"&krM&¡·ïÞ¼~‹µ­Lž~RUj J´â6pî­PÁÔh8Yòc<˜#ü¯t¢ê¬"Unê\•í¾M¦ÁrÉŸ³Ú§Y&"…‡ê°Ó8JBI]Dl×"¸ª¢­BpãÓ­º6%é*ßešr¯‚våsgyDK`™œ°íI†Å.‹Xoè¯&fœæÁ®^gi$k9ŽòŽðçΤȩ*oÈ&}¼â¤Ò¾£Ð=~ÂãôöòÛÞfËð¦¡øóù¢ òg8ôÙéh} .t‰H†pÒªT’ę̀¹Ìuµ51…¤U´möÀLþ@²É°ÑI¢Ò;$bŸ ¸Í,2Rµ;µûXRn€ÛãIÍ‹úúCÞ© É>÷M ¥¶â¢|ë“%å‚È Ú[ÀÂMgf¯‘r.[iüÞÀíBl%&ËÌ^,9Ú‘eŸáÓìÞ‹¯øòô“ ¶ñtAMÇu$YFô?ª¨Ê«PÁ.‚§œÄo}4¬Jâ P±•J3©ºŠ™F"f|Æ”QâãbxkyÑo° ÍÁ;f<ÎÎÏXïAzÝ–2“ÌOYa…cƒnhw@–1j Ozج4 lpƒÙ[‡eÃOøbg¬MÁo òx~칩‚IŽ­Õ}î²USM[„ªÜÎ Rˆ¾ iF£#÷²-›/W K ×qÿ’ie5Φ%K÷ÄîÚ3¬pñ™ñþ¢³€IåèFHè w¤ Þ®-§ƒWwÍcÏæîuÛj\é·Úc±ß4–†]\¼ /òuº©Óê€ÞcMVKa ”ºP9ÜzèL*³iÀ/çÊçÏ"»éÓ£°÷®m¯ÓM~‰ u©Oœjz–†€Þ$t0µTɾL…š1.ÉìÁPh_¹Úyº“^V[©¶ž‰ÏA‹÷Ìըƙ E•é¹ÂÆPܧ‡b“ÑVGïOå}Aø2ìnŸ9b\ö\¶_‘n:qC8>X¡Ü§€9NÌ0wþ4Áo)>2ù„å „A£4(Ét‰Eä F"²Ö`/@f­>ƒ à"{ÉWé:Íq…©´o Gxÿ®K+šÂ‹iŠS€P˜ ‡ã &¡/ìø¸î¹¿Ü{}á E¡eŸ=£wrI¤°Äƒ6kïI,Š¿ôVÀº\ßMÐIh¯·Ñƒb‰ô"Øä%¨?…Æb!Ø®ÜÄ×:RÜŽNØa:åŒj6.dã%Ú‚}EH3Úݽ²ñÏ]¬½¤RÁÕ€²\e›½8ó:G~ø7¹½@£ªõ­QXt;ȵ*\Ñy:÷=@.¼ RV—ÑÛKOHKßø&£i0 g4ŸÏ‚I{ŸNðÿI¯L$woì8îîãáÂÝhï½©ÏÆc¾K:ç+^ûÃÍůÿ5†Òendstream endobj 4489 0 obj<>/XObject<<>>>>/Annots 1496 0 R>>endobj 4490 0 obj<>stream xWÛn7}÷WÌ[åFÚH+Y–Sô!Û š"©­¢/Zj—’¶Y‘’kEúï=CîUr8†BŠäðÌ™33ô—³ ñoBÓ9ÿ&»³q4Æ7ü1á»Û³8žDsš/®¢1í(ŽÑ´šåtÕvŽÕÙUtÙ]í̱z ÃÝÕÎ|GÓñ8Š;«Ý9Vg³hÖY}³ì@õx͆^ÞÌh2¦å>ͯ0H½+$ƒå6³´–•F†¢tz'\–ˆËÃ^›´=EƒÏ{ذçÞ&1Àµ…L²u€kmHâVXxK¿}ñÂC‰è׃|RP.Ô¦Ùø®×dõF“ެ·Øa°ÿUìŠ\Ò]¹:ô¡ÀO·Õ*¢û?ßß2¥+ìušlYÚ8 ^ñ¨ás®E vRÜe5Á‘–¿¢0Z$[J„RÚÑJRie1„—7W4aøÐŽ 9 ÓÁm 4äT%Î*¶¥ÅU}ØJ3Ãþ<ʈÞ+ÚH%ȇP˜gd­2…ø&{ =àØF ЉX‘PóÃùóÙtEתÜŽ=é¢*gÝÂÚ¦o†8}rø¸4g|NmªD ki x\eFóUS{8be™q|™FÄj…óy*}{‹: 1™ŒS ®c”lEiGô‹ÞsµEØ>Í:ò_$O]å žˆ*òD3£Ö1¡êãðuE1õ> ìÅ׈n iYÕÓ* c⎉B³Àâh:Å,„Ât¿Ï6ô­V?ªEÚUÇØGÕû@ß^¸҇׷×wCúôñnÉÿß/?þ±ü÷§ž¥0mc9bÓi4Ÿ_òE·¾Ô8ÄÎuJ¡•ŽÓ¼% „º–Nû=ï)ûø0ÓÏÄÃW¯0îáô¼?Í?;ݼmv…éé6OF³ËÏxÓÿ2ñ[ÕBÂA‚ˆi8P—ðg£oºõO‡pµ$iÙ7%†‹—F9Bô•¦eõùÌDØoL&Uê_-p–PÝå†n•€íDoT†^Êéǽ°§K´µµ/L[j„Ã…4•ÏÇ0¨õFëïkyû ^{—èQg€–‹íÀ-þ¸~8ï ׫ýØÂ“jŽ5CþZ.Üy¹niM5RÀHË:_BH§…ä— 7G9ã ¯•lšXxõs§c·Ð3Ùÿý|>M«Áׇ§eûnûüo{MU<: ñb°LštÂϽï&§uÝߪZà›ŽMÐÖùáÇ%$ˆ§ê<‚’È¡—?XrÓ¢zÅãYt1½ ù|-|÷eÁŽbüáðN'þíŸþ°ytÊâé{ðb2á7 'åṙ®—g¿Ÿýºwõsendstream endobj 4491 0 obj<>/XObject<<>>>>>>endobj 4492 0 obj<>stream xÍVßoÛ6~÷_qÀ°DMmE’ÛͰë:w{°ÍÀ^ 4EÉl)Q#©¤ÆÐÿ}wåXqœ.osC¶÷ëû¾;þ=J!Á¿¦súçÕèíz”Ä ~yx3%\¯XÆSX%0“ÆóùÖ¹·J`Í£oeYk#`ËÌííV±Ý&Zi WÅæÕw¯ÖG Lðä:jV Û0îMáŸÁo\1kNö¿¤þ@Ón•ä·Á¾ÿâ8>ý²0RÔ9Üi™ÃÓÙ<ëáKŸsgõ…\¯f@ _É$›†D 1¸7¬i„Bp;•p;Ã%E¿„{©ÔÚÁV@)ja˜¹ÏûzõÒY<#ÇÔ¤%=æÑ …yõöã¸Ïè ³8!%&Œ/4›üàO‘ÑK¨ó#ejÁ%SÀ™ÅVWÚ:P¬.[V"‹tÞ*„¿!Yôt,Œ¸®­r!:FŸà4²’NÞ È™cnß «MôÈÿÈËøq(»C }ͨPš ÇcìÜvwLµ‚œ cÓŒ"±ÁrÐÅ9âÉöº…Ãm͇ ÷µO {…i~èBSÂW¨Å§tê34¶ÊÁ÷`ŸÎ ¼èÌ_"ç_ô=N3>u[ÏÕÿ‹~ƒ4qoWHö}_8m¯Ð*?IOu‹{`‡«)I\ DŒVÆKÕêçY§Q?L¿¦S¿SX´K\¸îøŽd:].°Y†þhÇc¦.èXÖåÈ}²RÜöŒÌ¯æwº¾>/XObject<<>>>>>>endobj 4494 0 obj<>stream x½WÛnÛF}÷W Q‰ÖÅ·4m¸­ Ez‰¼VäRbLrÙÝ¥d5È¿÷Ì,)‰Š•ø©I HÜåì\Î93ûÏш†ø;¢Éÿ‹‹£ëéÑ0âáæÃÎéôæœFCš¦Ø{ñ_YÇ—¸÷ÆxýýóéÇ£Ó›³fS¦ M®Òq¦ròV+_èÒSj,Yj«ËX;ò†*›™Ï–šå•_Wxœ9*5Ö²ë°Ç,³DSa,ŒjUäX£¬ôzn•ÏLI«Ì/d™ÝÒ`4†‡=•,ÎIèç/heUUeåœð_žÅòž ºñ2_ó\yl‡[^ÿp¤J<@0o§¿Gˆ ¾­”£4³Î“JlÏJzûþö·Á(šD£q2ñ’FgÑYHØ`|Å_“ÞÖéOçÙªÕ¾¶%ÍÖ´Ty­»Dã³èêŠ_û#Ž•C˜*Ï×}RNe ‚/yžSµg2Îù™}Ô±w›"ºAúõƒBhší¤uKúòì^#HÄVdóâª*­lSÓ!]EdÌ>£É¿’Þ;؆¹Øç>À›¤Žý]ûTõ©YŸÝ=Õl v&ÑÅÅ%Û¹M©4È! Q„b Ws‘[53µ§`(6‡t­öúRø¬qÙBÁµÝF逴\Y)/ šš<7+ âIqž0~><íÉ6ÜÄKŸØ5F!ó¤GÔæâ~¤%éxduÍ«³C««{§?ô×Mrw­5¨*õª9ö®g÷·}îæn¿"%›pæP_†¾P¿c‚±)ªŒ!ô”ºPQƒ)‰N³R£*±©Öø(· `&(^WuîwW„H 9¡`ò¤Óžp¬2 @Q„%æ*†ë3À*ƒ_X)Ä è?æJ‹­…*çØÿENfë¶â¢;7U¹úÁzû•×,€¬ZŽ¥LmÄ‘µ©U›m¦™À}¼jM=_`7Æ‚H14€ 6o0hßÔªÒ1{Žƒ>u\ ÄìðÁ/”§Ü˜{GÞ?‰{ðkþMð¿]eów,pïYµý!¼ø ÃÁýrpÿÿHé ¾-ÄFÆ2ì}ަUjuínP‡ªpC :Ǩc¦±ˆfë4ÒK¶¶ÀG‹á T›··PíT|Ÿ[y¡îq¾TÐêl¤ñ]µ6 ¿¬‹hnR‘Òg@¨kŠìß©¸Y8Fº54i—™¬FƒýÊ„mÛ!Vè~,Ä54mÒ´ŒáŽº¥„'€»å³ãÍh‡ÌÝ¿#³ Íùâ'í»Ü(ÐIä¦2"]‰yû…ÐMή]-$ÚKeʉ˜°”&‹ÂÃ}’ƒ•å¡‹õyDp¦2_K2¹Hðî˜ÓñÔ,µµ,™çÀoN T&n¾{ߥèyµÕw½cO£×ÇwÏ÷3Çué°•Ñ©¬÷X¤ä°ÅÒ|ÓfÇóŽ}VV>ãëú²ãÿ§ÑëWh âߦËMݶJÌh³;Fö¦ëvghÈ¡õÐ5}êšås®ïzûÍ’ŸžR„?m ràgv¬›àýF*9^iLh+0l!Ý EµrÌ~ì¨CS@›X 68c©N -æãG;SD·>Ì€V vYäªô­·ÂÅ]Yà&B°Ì&0åùÇRÙL±>$.ØFÇBïl@ÕÃs]jlÑLA¼´à=Ú+AU¸ñä-ÁÀÐ\†Û.´ƒ)"ÝV ­* ˆï¡1œÚ–ðh©q¯q"›šóÈ7 Œ/ø¹ËñÝëK3P¼yìÖ"3ðžŽ/0G`BÕi à ñ%¥@ƒ—cÊ5A8lo¤× ðk«bø ¤b]qîQ€µ©!Î`ÝM¸!Ó–t€/t3q…ù%ÅÖ\7¶·³¯…7å3lìʼn%;·™‘ˆ»5C~1ÃÉ}'­YoÂÄ[“VN£/Ü–˜S®<`1eÞÔÌ™¼ö\Ä]ñc”KÔ»€Aõží̇ÅÓ›«æz0žEç“sÂý"ËýIngãhH¿˜XÆ06Ó„ ›—ApCÑß-Â=­’ãÎG#¾”‰\Žùɯӣ¿ŽþÙ3ݪendstream endobj 4495 0 obj<>/XObject<<>>>>>>endobj 4496 0 obj<>stream xµWÛnÛF}÷W Ò‰¦n–œ"yhÚ¤yh‘"òb X’+scr—Ù]ZQ‹äÛ{f—TDÙFÓ¢• ™—Ù™3sææ'SJñ3¥ù9ÿæõÉ—'i’âáþË^ÓÙË%MSºÜ@öüEx‹|ô›ñòéé凓³—‹NhD—¥¤ÖI2ò¥räeÝTÂã®vdò¼µŽ¶¥Ôd²2÷Ž„•ÔçdAÆ’•¾µ×ÙŽnEÕÊ„^{‚"m<+.h©OžPc”öÚŒe)M¦3àY¹‘Vê\º$‚» é"YD&³5_£ód:§×º”Vyá¡P6[$ë5K¾}÷ú¹¶iŒZ¶¬¾c?óŠÑÃ]¨*³u”_’Súº’áqÝV^5¸98:&á¨RµòÑóp4:îD/ìµôÏ*¡¯[qp”.¿kä$/e~#-Ýh¶-2Óz_"–ˆ¼2Ú•ª¡Lú­DØ3vj×oaïøûÐzÑÝD¤ýCá,_ÀMÚ´:Æ£h0LEôà5´È\8ĸ3ùqE8±AT 'ÁÐV!Ö÷8ИÜÓè­lž‡œ´¸DçLÁ5ÌL^ ö8’̺kr¬!v‘ê îFdªR^IxmŒs*«8{5ÕÆyv ïÈCÔRh”I)|dt«ª õ`Ù8,k£'M›U*,$bi#»cÊáЗâ–Ï‘ÜlàsÁŠ®¥–8À„›BâŒtªî2õªråÁÿE^÷‰Â…—#›¼msë˜Dým¬¶}¸/arc¸P$? ¨•äJÎP|E_K¨¨`á ô ½d3pNùÝ8 ß´ˆ3ÀÀ©7'²AåÀ®ÈSZ's®ñC˜%ó9îŠÑÙlн@õžr=®MÑ@ürøêÏÁíwJçU Ã:Eå£ÁûÇŸ»[†ââô–mÒPQd14L@ä¦ZŒ¨ûKú4Þý0PÞ¿¿UÖ·¢¢N-S\®Né¥ßtÕ¥j‰nù7§Œ*ؤ“þ}eò^W£=¸Þüîêthõóð6Æà…²9|zJ]úþÓ˜Äó{óVªuÇ–û}é¥8ŠÜp¯¥Dk(y¯§o?¶<Äþµ§ñüÞS§þ¹ñ¥—}Hà¿ò“Óðë\Ÿ„ªš'çç+NÛw<¿·V4Mè›h’ov¾4zL[‰F§ D·¨cùî»7ùزèjÄ­@£™s{àþ„NA•¼•U§‹DŽîŒçÝ–ñ@OM°>¨œçÏŸs+ÃÌîÀ·yÌÏg}ƒÐrû¾Ï¢ÕÕéyYÈ÷lLÓ{`ÊèÞz5¿•M™.çÉÅ|.Òt±¼àÏj¹ºƒb 4”Ôÿ¨3º|Œ3å ñèsg×,#Âa?‰Zdzñd~¤šI»ÇÁƒz¼Ñâ1Àó3:ÌânL)²&\¤x¿­†áæOλæý*ë Û××…‡+›Ò·æb4I‘— ^lkqÃiŸcåÃè7–qÌ^´»Eö e†èGcE!îˆò˜v(úÅlQa6ŽU'j^VSl;2jÎðüw%p¨ãm`wP¥ÇvyΘ]w>ÌÒE²œ/é|½Jfû-z2KRúÉäm-µ€Õ¡·DáÉ*E¬æ3zƒ:Ä?þC°ÿw€O,§SÞÍÃ]ÍùÉÏ—'¿Ÿüq_å¸endstream endobj 4497 0 obj<>/XObject<<>>>>/Annots 1498 0 R>>endobj 4498 0 obj<>stream xXMsÛ6½ûW쥥±hQ’eÅ=%iÉ¥™ÖžÉ%3ˆ„$Ä$Á¤d%ÓÿÞ·H‰”Ü8͇lIàbñv÷í[|=‹i„¿1Mfü/ÉÏFÑŸðKÌ/¿?_½ŽbšN^G#ÊiÇÑ<¼Ëèöìð=¾ÅÑåÁ·oï :«fE7SŠGt·ÄÎ³×ø%uâ—d°¬‹¤Rº ü“ªZKCzñE&UôòîËÙˆ†ã)Ö>’T^jS‰¢¢R+¼&ºH¤)T±"UàA…ï,³T­E…I™Þ3¹‘‰$‘ÖjC͆–„‘Ø5ÛÑJÒˆJ¦´Ä‚$ÖJ ›´]«d͆vÁ™xÌÎðƒ"©j‘ááTâ#Óˆnð°*¬óâœgÄBo$ÉG‘—™½ é„8µá“(¢[•+/ÛŸÊN„½k}UeÔ¢®]¯þý>` ooK£}5 \ î³ï8>÷+Yȉó¾ýf9"ÿüå»'­Ÿ8ßaÇ>±CS³> oBi[²5Êèøt!Íž:žCÇ%èF LÈøáëKŠ”vº&»Öu–RmåS8œ†­ñÒ3ËŸº’³' 6êL Òð™v?mŒÌ\YÒBV[)}aÿ7µ ö\ý¥Ñ;ò»þS#‘Y¼§tÛuó+³úyû¿{õÊSUßüùí¡5«Üá/n.[BË0\÷S˜±¶"#mUöœn?}xw_k…$H 4¼ Üå¶TÊ 4( ¼VÒ,E"Qú|î­âÒç æ‚ùK[ḼGÎ+ð¸z`À” .ŽhM¸¡Œ¹CŒ£ÉïÒA ÙH]Çókúä Òt_ηæNñPè-\Zèº:p›^Ühý"¢«¡IHM-Ý.“h6»â]>,¿ìÍ9SáÄ[15µmAwH£]iWJ€çÊ®UiûC´-Ê‘RY±Û¢Ÿâð—~íÇ‹)°ƒ7‹@‡¾«viÐ?ß¶ Øì[4r%Lš! L¥Û5Zwhã‡K„¶n(KDœæÇ†]¶ð¥Ë#}/ÕÅ‹ ‰PTS £ Éïb¬kÕ.7ÛÜ;'³3Ǹ~­Ê$K^Ò+dZ­€° }Ÿpü¯9ú¨¤È|¨4öÊ!Ö¶U$Yú —Ø6A,>3Ž:Æ1ÜQ¸'ö·p‹u‹€Ë€Âå”*À*¹ã)Dª¥e8 ‹èM†r,°Ê½uØÁ­¼ú¥FÑ{×ûn{ÎìŽ:—yYí-ä’¤­N†°{ÊBq‚„†Q–  -ä>/XObject<<>>>>>>endobj 4500 0 obj<>stream xW]oÛ6}ϯ¸osR[±óádÝÖ!Éš­/†苦h[‰$ª$EX÷ßw.))’â¦Å’ -ò~Þ{îáçƒÍñ» Ó%ÿÉìàúî`Íñe÷ÏléøöŒsºÛ`íòG<Äþ=ä䊬ÎTµޤÎ2ÓçRY—à!±Tí”Û)CÚP®á™\]¨™[,/Ó˜ÖŠ¬Ø¨´&£2ý¨bÚù•…Nr§LD·ØžäÖ‰\ª)9M[å°ÑáåáÝýÁœf‹5)”Ùh“…eÁ|­K²Î$‰4õ¾ ¾-‰<¦ûÒ:*-H²"UpáÔVë})ÿÚ?9cãr¸Í•)B@"·2C4n‡LûYç:",çU•²Sï¿ÉîBþù£2ñ&Ñâ 'Fa”U¹Jom¬†aHE¾-ÅVEtW‰D–u1qês™<Š–HoH M¾…³&ŽŸÍߢ üOuÓQø²=÷ Ìs–™BÚ°‹ÓyM7oÞL“Üϱ‚Öj™N²JÜÎGÔz†¹Tã’€T€ÃÂBÔ˜¸ß!‰Âèuª²`›8®#ìíür¹ùÀ˜´”+Ã+ÒÃfœ`±eQhãR“ˆ¹NbŸÃF WïÙLÙB!` 8È#+S—„A9'¾C]ª'ÁÅ3 ÖQL\q;ã4cEiò€ŠrožsºŒN¹‘NP´''Ñé)>Å™(º¢Z§Üc“¢\§‰ô;¹ÄýwD\-ôôÓ`å¿íG˜íÌ]¿¹ºÝœì5wCo)DDWÓöiìc´“C½ú{Sæ’+c²8«ÃQ\HÉ(ÀŸ“˜½'Ö¤òbs×=s×t´~ÅÜzönœX8…¶ªgþN£åò‚aûSWSîJ›ÄÜØ¨»NS]qµùÓôå°ß×2ÁÙWŽü†Ž$ý‚2­èf5YO ô`«¦‘§®‰¢¶Q©ùºÀŽ>àrl-ÆxqÅ}8WÚ[üLû# <·¡Ç”)­5»ÍµáA ‡CÔ'ž|Gq¼Ø‰šRµõä&¤TÓéõ½’žÖ<Œ,à±_`™ôO׫ÈþЕOyq7It®˜.} 4Õ‹a–`„ˆ´µm+–TF£@Ààx9Ï”˜„%»ÓUÎÌ©ðZXŒD°•§ƒŽ¬àšéO—Ûãð=q‚ä0+†,û FvÂøj'sc˜1±V6ÿ)h󈋩¬òSZ=O5Ìܜϭ vHÅú™ß÷Í/½ A´C¦úf\DŸxNìãÛ··î%‚rGkÊ ô‰h äƒg}ŒFœò€¢_§`°ÐóϬ÷ÃßþŒÏèD”ÔêpJx‘­|•ö‰¹ÛÿÅ?]…Ï_8ÃýËz^f¼§qã»ð뻼Ùëo§¾q,â.#þ:Í´ÿ'{Žo/›¦]\žEç§ç´¼„–ú™+|vÍé7-Kî{?Ñ]X=»*i-Π´×&QŠ+KËw.¤^yu J7ÜBùT|¶r§ä ’œ/Ñå%.ÆçüÍû»ƒ¿þ¥–8endstream endobj 4501 0 obj<>/XObject<<>>>>>>endobj 4502 0 obj<>stream x•VïOãFýž¿bDu%p‰É\«"wT÷¡ªª¦º/‘ª½N¶Ø^wwM°ªûßûf×Nâ¤* (س;3oÞ¼™¿{cáwLÓÿÅyï~ÞE#<Ü~˜]<Žè&šÒ<¥ÉˆfÆÑlvMóÄ[h÷ŸµJè¼¼£ŸhÑü³8£øÇ³ù_½ Ç0JZ£û£FQu©ÂÑ NÜý™VEì”.ýEÿŽÎqy·8ëº`ëÖ÷ëû`}ßX_<^G”Òé 'Ó&þç‚J#à$–rkI¥Æ…Ò²´–YBÂ’(ˆŸ­ŒÈ¨¨ò%¿-¼±f%e¢XUb…ÃF¿ÔgÂZŸÒÅã_F—ì˜ÝÞðפ?‹ÆWôň²TÅŠ~}–&Ó"‘ =6ù²Ï„~‘n­ËØìâçk.£›¾Á碨wþsT™´úýËçŸ9šg•HK¥0N!x[•¥6ŽRmHï¼¶(ã\\¼ÿXÖ™*vÚØˆqH¾ˆ¼Ì€”JÛŠM8ZWþò¬ž7Ê­_õ@™z’€NÙBZû,N&Ñt Î5¼Iµ^ô=PøZ‡žWDȯÒEÿä…kõ.Y,Š“½Òãkçœ'­¿7^ Cç0ÿ¯›OßÙÓcwïJs@­9ØÔBË!VqÅšQtpÂUÌ«¨;‡çööE:ÓÅY'?Å´óhk{>gúäµ§þÕéá9þÿÍôZÚ2…7Ú<Ù›U¹Ê-ˆY Q˜j ©Žs ”"¦ÑZ<‚¥DBo°Ä7ˆ©jXVËLÅ­1Ħ’Ù½ñ„÷÷}#<¿¸ ]¢£wÐÁÈõœZ ³åjWŸlïÐjLìú0–¯þ웘+G¹Z­-e Ó¶Žâä)‰lÒ÷ùïèÁHá$8‰wÔü™È§uH2~µj¯KÑAí®c´Ž\Õpp0 ,ôúieùª•eVÈhL•-…‹×»>ZI°JðL·²dÑ«+÷âËeá¼)éôu5b•mÙ‰µ:—›µp¡AU dJ*ðQ{¹OêBä*M+ùVU:´@‹—Ãv@5ÿ(|‰Þ¿Ðf­ÊR‰Ý§  ñ«2øS9DÖ‹x^YG ÄÂäªàÎðS¦äÖj†…Qdª‚Ouâˆ×2~ò-¸s7+ÂìBˆs¨1S|I+¦Á²Ó®.%¦‹ÝË?–Æ hÚ·÷‡‰Ñ Gaœˆ‚-NÌã S&ËÈáVÌ;# ÒQB1s¨L ñófO6z¾»›-ÇUã•ÐíØA3|Ž7%—D›$l¡Æü«AÅ ¹y|Á¦25ž8ìQ6 «ôßèL¶[ÐÄÓ˜ç-ðò¯ Ôl«×ŽxÌëkÓRîÔ6„ÞBÄúœKÈN¡lŽjë]stlX©S§b¯”µ¡eÓ‡\9J¾éR盈Ù¢k¶&4L‰Õy샄[çL`ìE© ¯ [Æ71¤Ê 7x'Ag  û½åfÛ]ðcDÊIÄ1jÆØ4½j Ç ?0¼B5ó÷¦Ù'£ËèjzE³ëëhæw/nÎá$ÑGû:oE k@0^‡%øÿ¯{Wã1¯x~Õ¹ž1Ÿæ½ßzÿVÅ—šendstream endobj 4503 0 obj<>/XObject<<>>>>>>endobj 4504 0 obj<>stream x­V[“Ú6~çWœ·° xm†´Ó‡Í…vgzI:ôAØÂ¨1’#ÉKœ_ßsdc0koó°ìÈÖ‘ô}ß¹|àã_“ˆþãÃàÍjà{>¾l¾t ·Ë>¬vd½ÆQâ p-[®Aí@óÏ…Ð<¦ÓâÀ¥5ÞÍêßÁírZ¯Â/ÜîUbЂƒQÚ¢ñ¶!cÍ™2ù»T»Ÿ°áÄ8iê®>l™sÈ5yÂeÌÁ¹Ë2xûê$Ì2²­€1cD*É‚õˆ¯7‚–6Ãã^Ä{n¹>Zµ- WÆî9dL¦K9TRd|sS#ñaáMè^C4Co2Á§d¸"حχƇÓÞîÆW€ó‹–áêïïáåå–¾{Ø é~sÓ2~P"i‡~Ëà^ZžrmÎûMÛËL1KtæJHKfQÛ Þ3}^M£EÛà£Õ¸þâ”AÞ VÇ ïYWcw}/Šæt}:%á½›Kò+ÎÌÔ׈/AªµÂîˆ2ìÀŸÔà¥r…<)—'t?ã†s¥“*$ÎÚ«wÄ“†ƒ©c0¬T<#o4uìïQOVb€2D[B¬ä® ·F°-,0 ü ;䇣@ ïy–{ðVI#è`òd§²L‰ƒG<¶BI ÒÇÞGØo—=ZtbØ)µ&ªØ’v¿oiáÍ$Ù¢ÎåŠÖ›µÿƘcû*'¬ƒf¦[ë°1èÂzÒÌv*a=mæ;ï"o=kVt±×v+ê°=±×¶œ7–8ÚÂ{’qÃ1dGù¨áœï°@T¬œÈy¦”2ŒëžÂu™ø…eaendstream endobj 4505 0 obj<>/XObject<<>>>>/Annots 1501 0 R>>endobj 4506 0 obj<>stream xµX]sÛD}ϯ¸/ÐláÄIÃ0 PåZê™CxXK+{i×ì®âúßsî•dKŽ3M˜ºÎØÚ½{?Î=÷¬ÿ>ÓÿÆ4ñ+-OFÉßðÛ˜ß~ÿ‰¿¡Éøï%M.’Yó¡ w'%O“qçYçcI—WÉ´ó¬ó±¤1lw~?ï8!žø%}u3"¶1Ïi2¢ÙËq2›]Ò<WG4OOïÉ(wîöÔØHoϾ>›8ÑpŒÇYçqáìr÷ü«›sâ9 aw8™6vO_[úáË/W&^kísÆbK…^ª"¡ŸÝFßk? cIQH½YGË…²ËJ-5oÕ^óÞ¥¶Ú«{•7MwÆfärlŽz©=¹ÅXOhÎ{rçõ õ~ÂÞoV&]a·æ=°4å•M£q6Pæhë*Z›ôî[ú¡ÐÊÛÎéÖÑFm):оÂñ¥ºÓð83þŠ úP…H „æ[’Š|Ý«¢jOì¹ÓzmbÐEN·§ü”KT§’+PÓ&÷”â=XÅ…8\VÂS¤ÕÒB‹ A•šÖ^§& ÖÛ³n†h³ÂÂwï_ÿDÚ¦®B*}À.d<˜X)ÎÊñ¶©AÔ| ƒBÒªo9âR‡€¢Qa1"©j¸nƒØ£q8™$Ó)°™êª\:1×ç×ô¾±}1zyM¿+…S™ÎpV\¹«œƒÛ3Ò9ƒËÜkÔÇ,-êŸí ðÝžV€gd”…•ʀɌ ÙöÖÏðʣđ¬T·k˜hAê„ü¢îÕ¿ |<ûTàÏ–U‹µý¢V™D¹ëuÀ·“/lÒõ‚G›}Θ)µB3ÅUþ SÇ=º¯[Ûq´1EÁ5V¥)€cúÑ»²GÜ$>W):È –›ºoœ}nÓ´ñjÍÉVÒ,{P`ñNeÜó(± Gåâ]_ƒ{0ÏÍG[«ƒ®°T@>¾¶ú#ž¯fÎ6<ýR`ÎHœÌXLÏùc¯©Ñ®¨x‹øÁ¤Ê†ö)LD‹=Q·AqGµ¶\šVÐaÜSØÐ²ß ø>™Žû@»O¨ íYØ+Êõ†BõÒ@‘3CdC­º1qÕËI'yƇ8fa±5´ƒôº´¾¼u~–èæh;WoËŒ"iåã:?|Vª¿ÝÿdÜûùR,b³çb#<roåùdtž\L/hv5ª3ËŽ'øåê•KeÌK7²%܃ëµÃËºí¤ŠÚWUø­¹û5Å»“«+E¿¼b+?ÎOÞžüÕ—ÕNendstream endobj 4507 0 obj<>/XObject<<>>>>>>endobj 4508 0 obj<>stream xÍWÛnÛF}×W ¦‹ºÅ²¢>Åiø¥Aky!¬È•¸ ÉU–¤¡è¿÷ì,/"%nüR_d‹;3{fæÌÙÕ—Á„ÆøžÐlnÂtp³Œý16/fK£Û1-ü­64ÓüÍğϯi±Õ˜V¡÷Rm3m$m´¼DgÛàü—óÕ_ƒ1 ᱊¼­"·ª²¢]œô+Wr_£ÝqÜÈ'úÓ^&‰oÃŽn_“uÝpøátVòV±$]ÄÒH i2Q¨I*§B“‘™H±œáwC0¢T±ŽrŸV1LB‘ÑZRd Ê\e[r[¡>¼•÷ÒEèð|ºÕ†äW‘]Úr §S6Cñ¢:@à½@>å±6Å‹àÜ•…ßõ SíxÖÞÕæÙ%®7jJü6 ežËˆDnƒ;\œÛ\ÐÀö¨€Vþ';õ».$š îÄ—osF—YÄO2¹'î—­ô®P:É%Åz/¤¹$¤Q&=StOлѻW¯è³<ìµáõíÙt-넦¶6ç¬P"!•LÁD0Qí„a Hc´±‘Øà(ßc à¯Ið]ÞP¤Œ -?mÞ’Öà-ÁäÝ!K³)(Ðy­U±“D*Š0¦H†‰€+j2Œe£¡HÌyçÊ’Ý5é¥}t ±Û%6šÛv›è5 ±)3B΢™Ž'ó{taga/Pw;CÇØèbT£ÇD̓¥ª'Á ±a_g¢Ú2Òå:‘ý¡ñ}ֈƷ/=•¸Ø?˜ê-8c g|­g C!¶ª¼áy_ˆƒó;£ÀËtQ) àUQœô¡7yN÷;‘Òßð; W!KFáÛ]«Jð–?€Úñkê‚§}¿¨›",úõú‡•ûäàÞmè KÈ(ø³™›ß¦Ýv„jj ¥)X˜‡z'™yd‡“ߢZ¹NJË7Ì·}!£·\¢»•[ÿŒ¼ÖtZ.ñ_àõÊøÁ"¯ƒv½ªF!vyÄmøÎ *x{•$Ôr\óS™®¥É{ÄèÚÒßr¤‡AOãm™eyu²c,¢ɦÚ8ôl³¤Âö­‹c-s›³¯­»¡wIª°ÇìQ8Öv‡Ðj¢@] ±»Èí#«s· 壯3$¦€A“T^@¯Û,Dh4æ ‡¶•q¨Û+V ’ cSAP™¦‚68MŽ•è9¬ê—¢¾è¸s²ÓT«TGæÍ\V9ÿ¤>(S”Pë“:ñ'_t¸§< u…YsAà‡G`Xãz¢~€o+4ì8¡(æ’œÆýõ{®7¾=pªîyÙ=)µ÷Fns³‰>MØÿ©nÕýv²xí_Í®h¾ÀåÕ]Xï?Þ½Ný1ýªÃ2ÅœñÃV­vÖÃkÇû¹?¹ÂG„·éZmK{S9’w;ÿ,¸¸Xç«ÉÄ_,ðÁw€ë7öÉo«Áƒ6C¸±endstream endobj 4509 0 obj<>/XObject<<>>>>/Annots 1504 0 R>>endobj 4510 0 obj<>stream xÍX]SÛF}çWÜÉLA°ð7à<‘¶¤¼¤ÓÀL^<ÓYKkk“•ÖÑJ·ÓÿÞsw%Ùà·cli÷îý8÷Ü#?P¿Mù/JúaWøeÀ/Ÿ? §ýpHãþUا”Fýq8¨>iº;ÚÿŒ»£‹f­»»÷w'ƒðjoï‡û½ãÜ™ùŠÎoÆ4èÓý~M¯ð&vîàMܤ, m ­µj¡%†Té2–trÿõèüž»íÁÛ\f"•þjm4 »–‘ZªHÊd›©H$EZXK±\ªLñ R…•zÒÉI>Št­å¬>à2±ƒÃ>õ†Ãp4§8ðîÖ"¥x!n²#q@D•+ó`iÌ_j~Bø?TVÌOÞ\×kcS"Úîò5.ªÈùµÜFåE)4mŒŠ÷‚'ø9?§Ï.31'ÏyÔõá©æüg Ä]a¶.ý[‡‰œ5¹ú rš‘žIÜÿ3ºçCÛÁ¶ç`1 §Ó õ–ñÔFÂÊ35NÌa«\F…ÚHK¶PZÓJ$Ök­dL"ÊgMfVƉÌU!²HR¢d.ò(ٞѢDËÇ–2CÚd+™S&#i­È·¨~]£!{*aiÌÓÙl¯7=ØÿÈp´'“½n"µDjÙ1)p2xDøS]ü/âá“)äì9àdŒ&‘d·Y!™ó2“õ,ª‹<¦_Þ½ó•åòŸó‚TŠÌå9ô tñÒ"¥¢ˆàHdÛ*]Ì‹ÈÕxÏ”:ÎŽ±5QÙ7”§ @#4^3PæFØ¡oMI‰ÀÇfŠ¥8#+³˜d*”æê°‡Îb{¬€çû V½Xn¤†ƒJsMµ²E{u=‚¨t‘˜r•°×`me£ã¬Kë\¥"W¨ÙÒà:ðƒ>µ?š Œˆ½¶œ¢¼Ôœ78€©kI­2“w§ÌOÌ·Þ€GÖ>Í2Wãt}ëŽp¸và¬W¹\Õc¦¶ã{ëÞûýþugw¬»quØÊ<¨OsöZvv÷^a±î¬–¹V|­Ø\CíÙg½nÇ~I$º¯âF& Z€m}ˆg¯+³xÑåx§\[Ç Ö PTQ Èó}ߪó¡£x<;–mʳK^;¶€»W“Ô*Uè¸'²¦•¥îVÖ_jÎçuWG\ uDu„Ëܤ¯Ø_ܤÑi=OõLm–›­bUNL,;ܱYmºƒzû¹Á(ávîÔ_= bw™é¨LÉñ†Gâ3u5QÖZDäT;ö qÀÔmÉy ÃUvƒáéCHÓ—>µÎ¨p”¿‡-æÔövÚ16?©&ç® ™âÆ—Lp{ XSäàbNGšzN½ûrû±7Ä·0¿BÖ¦˜3nº ñ­Ì+{žÔ§á`‚ï(®Ó…Z•ªà§—fñP®G$ož áå%¾m—}¾òÛýÑŸGÿŽgYÊendstream endobj 4511 0 obj<>/XObject<<>>>>>>endobj 4512 0 obj<>stream xÅWMÛ6½ï¯˜K/bk-{íÝ&§4í9A\ôb  %ÊbC‰ I­kýï}CJ¶åõnôÐý´)93ïÍ›ñç«”¦øNi¾äŸ¬ºúiu5M¦X<ü±[ºy¸¥tJ«‚7-Ä«™sÜ3œ6›%ó9Þå}@ëÑFØõ5ƼéoäÜŸãÉŸ ;>6¢zýïÖ#Uûõõ3Û°ádsØuÌý$81O–Ë;¾DÔ9bQîÛ<½t4ghèïŠçYO×£'(1àŒ±ó1gæÒªþ„×Z9O\$U Ü”ªc½Rëë„~+(3­ur ;+AË>ßH»²@’Òš²RÔÛÈ)'½€-H•Ê´î{¯ Uü[d^ïSÊ€¸Æä2Ó°û´y+ ®ÇBpmÓh%ó$Æ“Þwu4¹KRJK= âó¾ øé$]Þóãx]µÚ«Fƒê5¯BîPŸLþPmõYõq¼Ëp’P[ÎÉX8T( töHQËhÂAFsÙør ¼Oh2EHD8”J%­°Y¹çrlÝs!€ž‹xv˯ œW¬<†æ¼U!û…ÑÚ쨒Õšò¹Z* š³' `UÈÙ˜Û›–Jø ü£»Z}br(÷²:ÄÍ\òô¥ÏH(³¦Ýh•ãCéQ’¤O—ʉ‹q=È k~¨¬þyY-Î*0RgJ/Ëgô H;/_ʈ * ÎGÍ>Èm[w‰G±vHôŽt5Û]W{fXº%xÆ2¶á–Óz@m HËíEï_«ëMëÑ¥XORÿ¬¸½­ÁiÆaÀpm KØ»W¯¨€&µ1r_ ß—e¢îZùݱùÎ^ä‡Üp¿ƒaìQ¨/ä: •íi*£Ï©Eþ?}>Ư›úý Ƚ·¡°ï»± Ó±,87<¯”¯p¾Ã6¤i«ÑãƒÊðŒà…ÝJOR`\é4)ØàK“;ä;W*‡[z?ÚAäã CR‘“,ã>Œ®å€ ³Šá=ýM¦[ùÄL/VáA1$žïýT• ¥÷å«Ð(À¸¨¹µ"cj[óÀejüF?»ÆœÙ'í1ÚœU3Ê×—!!E‹¦;ÐâA’Ç=þ!•œÁ£†GÚ™VÃA‰£>þñþ×WÙ"Þ}Eƒ–žûí ³#‡u¶ý²‘Ø€+_¯KWœü†RÉþ>æsðhL›Ö“–Üu ÜǘÛ5¸› ÁŒ{þí"çÒçzä-&G4Éw-$±æY••Îè–gfn¾´èüWãàȃ–RÑÖÓ±ï8§° ê’÷Óçä÷ h_µÎ ŒçuÑêн]#0‰õ,LG|>¸¨úÜ[vÆ~:o ­CEbvÛç²â&Êõɪz¹ƒ§Ó>ݕȅ§÷àÿVÚ¾ÿÆL ®ðÏFû›‡3·ýÙ'õƒ]z·H–ó-çèÌâÉ,™ÒÏ&k+¦ŽŸn“vNîâà¾LÒ> ¼­6jÛ*¿?E•'Ë~PcãEš&÷÷ø´&ܧ¼òËêêÃÕ¿z;Üendstream endobj 4513 0 obj<>/XObject<<>>>>/Annots 1506 0 R>>endobj 4514 0 obj<>stream x¥WMoÛ8½çWÌeQuÇIÑÃn»i³ØC·1Ћ‚–h›[ITIÊŽQìß7¤¤DrÒ´(¶DÎ gÞ¼yüz2¤þ†4žñœ ¢žðÇ?>¾;™]D—4½˜FÊèòþGJ·'~f4œŒ¢aµ’_þ±x`Í›4:¿Ð<ÓbMÓÍæÃh6» Eâ}h÷âTXK·…ÈèÛéâß“ ñ"éå*UñUëí´Jh­õ²w“;¹‘fyúŠèüœn8XzW/hÙ˵##s‘ÉdyÚ²ñß«ÖÏàÿýÏ»W¹ó®»ÿœ‘ÓÝgÕr|ž_OˆÏ¶¦³³NFo±•Ä¡R&\¼Uù†L™JK"µšJ+)‘kQ¦Ž„Ù”™Ì…Ck•KC±ÎÑ)í·2§½EÁ2é¶:±ä¶ÂÑVìu\#Îqc/Bü±HÓ°¾Þ¼Wnûˆoadp$–Ô»$ɯ¥Ú‰Ñ‘ÞI“j‘à}mj+ZI™·ÜÂX¬YöüÓ6žÞÛî±ÛëjõÈÊØ)/O#ú[º–“bU‚ìpdk¦zÏY‘w"+RI¾èZÊ5¢ñpM~—QÕgó𭡺fÙVH½>ö)Ñ€5ŠñÁ>Ý-]+g4®ºÈçþtlŒÏ0Öû-à?<­‘×£½B™=Ð8±K$r²(ð è (äé(ù¦ùXQWÀ ÃIf/g j«D"ÃFpMà â2ƒ¸öï£Þy•Gpœïר:!º]î9ϧžG®®žÏy§Û}óòe…[ŠEÎQåÀ.¾§)[ùH» jŠhB;çšííÞãkŽT7Œ.ª«ïsf «µ’Iß7wÕ+êTµ:joÔ§C¨SÞþ“ë–(ä ãGk#z¯÷mݯ۽³ó °%ee.f–ªÝþ‚\À¨Îš5,y±E£y0M·GÌÑ­æUníÛIgfüUŒÝ7uÕÐ? ®¬´îÐÕ©À3Àóa¥Ý–÷5ÚÂ#Ùé œµQ•‹4`„ßqì»mtкÎex4ç1ÞüÖÇv¢sšÈ˜ÕorZƒ«ʲÿ{®)´µŠ9ÜÅdÔ‰î `‚˜Q tÛg“DVüî†DNýy„ãY䄎(ëN\+?RºcCðû tÇJk[EÂmª|··*Sàóô€ŒpÒîœÍfK¥•)ÏãDÿªM® UrïÕ&¼ k&”Ÿ£ç×ÓjŽñTžðD~£³#e¥RåL*uç6;iè~¬þ‰2!F0äSRÆ’×R]M¦rºýtóîl£Ñ˜ ®°«HËRÎ)| YØf¼Ååù¦ÚkϪ‰¬JÉp^ëÇ Hïñ|ÆiYŽ ¨Ã¡/‰Ç/ËËytIg“0ŒgÑpMé ÒЯ±Žš´“ï“Ű{ .ÐÆùaT¯GŽjAÇ®•ƒ‰„…Þü '‘/…b±ÅNƒP–¬Îäž%i™—¶§xÕse%Ns8 9Ù€;<Ö©èÂ<.òX$jî÷[³TmdÄsQH—J†±h ¹,ÆBa³4¨ÉÒ¾/,Z5²°øÐ §,˜5ŒBØòNÆ¥—7ˆIÞŲð?Pç$e £Òkµ)!”u‰qæ£ ™ãW*ßé/²Ö‹Ý7¸Í°lÝduÊÙZ&AÊf|NV*CÕ{L+¨7`­;3`;•¾FâÖPe.‘#ݺu‡Nypý3q 0‡ |9ˆcÔß#úé¦Äu¹á»KŸP&§X2!¬CÚÖ«QõEÒ_b'Àñè‘ÀÝ­8 £wïÄeñC‰ÁU&§ä€‹Ò÷ì~ÀÕ£O¸þä}úX®@Z¬oqZuºdÂ_ã*ÌâÑŽ&™Ñ§úöTçaë‡rÚø©s?ÙC£Ì瞘 ÙцcÅ•¼ `®4^ÿþº"ÂÕ$¤Èm•­FJÝø£Á$šŽ§4»ÀåÑ;÷d%Houì×8›¸d†Åga~>/XObject<<>>>>>>endobj 4516 0 obj<>stream x¥WÛrÛ6}÷Wì¤Ó”¶EZ[Q‰zq›·v¢™¼hF“„˜$T´¢fòï= ²ÈÈŠ›ø:$w±gÏPÿœ ¨ïÆü“'¿LOúI7wÌ’.nû4IF4]аOãŸÉxüЦ™‹êÓ4Ò\Týª‹u.?Ò§Ó釓>Å<Ë¢µQÂÊëÖM¢L×w¹$³ÆöHñ¿×­5ž«´›ækÌ¢Oo¨ß «)¾šÒu³î,2³S¿ø,Rxð‰>·ŠP=‹R]V6\ÒËt™4q8÷KùØ’ôR¯¥V›7WoÓDørE°_®Í¸š.àanikSÒ™]©ª›þÄÎ) ”Jc„U4‹ h©ª õñ)Bq›¬0KÙÆ0ÌN;2ªËLš|Ë+*>c ÐïDÝH =Ãà2*Hܳ¨Á,„¸¥¥„VEî8¨+‹]ìäõ£‘,Öæî£â3edjÕƒ ” œx¹¯˜Æ¯]@Á½£JŠG»çóˆ1Ö•ÌÜ‘Þ~§ˆ‡Ãd4ÂFy³h>Y6ŸÃ¯üs}8ÈR¡ ›×w†ÀܹÝq]ÜóF¡ÍØò[‘#0@âV¿-­4%7Ïy“ï—E7†=Ë f&iÎ…¿•=îiƒ¥\ë{ª cÍÈâ8_W²Î4ç§}Î¥æžéyà>‚F+~Ça>vot8¡’$L ó‚]á¢û\ß}ˆoÂñbѬÓ} ø"Ó½¢·vV+îq„v£ %ZÈK<±˜ûµ®*Å/™h Ò\ŠÆDäZdX$ÀC¸)˜ýÆ®¼¬Óussƒ^¼ ÒœE£Þåì´Å‡Üí‡\õ†BR„hônïÜÿ’xÐ÷0!߯ٶ*;ß[Ëê„ô4ì¨tç ;‚ú—7Þ: !¥nDRˆ%l +Y6l¡ÍñÐTz¶9ïÑ%fb­Ò{Ø'= x¶‡|§}ž¨~á΃Ñ8X«Çßù\Š Íûªà#†¬êÜLG,Yš…Hq’«åÊâÜ0÷SsÉWú~¸ç·&—ÉÕèŠÆ“qð¼wïßþ“>ý¦ÓzçíÜô¸‰Ž_5Ÿ¦ÆÉ`LïÙ¸aÔ\qÚÕ`L&øhCŒøÎïÓ“¿Oþ':Üendstream endobj 4517 0 obj<>/XObject<<>>>>>>endobj 4518 0 obj<>stream x•W]S7}çWÜ!%˜Ä^l†$“δ´4yé´S·}ˆ3Œ¼+ÛJv%GÒbœNúÛ{®´2¬ƒ“°×»–®îÇ9ç^>ì ¨ßŒø/¯ö~ïõ³>nÞ윎¯út‘ÐxFÃ>ž ²ÑèœÆEXÕ§qÞÉé%‰LŤ3QøyD—¢,ñØ,¥ÞاáË£ñ»½ã«S`ãŒz0Øž4;?`ƒ™‘_Hò2_hõ¡–Ž ér«¦² op#JZ)¿ s#miDç³Zç^íH”ÎX.Ë5/NG»Œ®Œ%y+ªe)ŸGîÕ³“„XtÔ\+éÒðÚÛçÏ“‘—/b`Íûñ1½Ž+_’Ò”—¹´‰@`ãÁ';ME‹[9yÁ¨tšÛáÖÆÇûæ$Rµ^-¤•Yc yg׬Ԣ’“Îõµ«§×רÝga÷^Pûü»=ZÎwì™t&GH|øS »¦^°±³îcùó´ÖG(—ÊEª,kç!`aaVTÕ¥W¨ °0SZÅÂ7°aW¯^”¤^|ž`סJú…)¨Ró…§©¤…ÐE)‹MzN9=¯ø¡Òó;q¥ý¾UBki‰?ç6vÍŒ] [dôʬ8í]F3à$øE3¹"dÚÃyåƒ(}/å’ WJ›àboIúÿQî¤LhD× Ë÷uÂÄ·@æøjp±iLçÙ€g£Ô&Cô¼vByEo0º`Ž\Jë8œb@øˆ‚¦k¦ª€nÅp”v^èo—°£åª}F‡ AÛ« YJ/·>|´p´’È7®¹Ñ>ðÖÏàâB•ïç ¤ @jWô,ßNB½ÊC'o²íº—‘J¬È*áó ay¬§‚°s =¯Å>/XObject<<>>>>/Annots 1510 0 R>>endobj 4520 0 obj<>stream x¥WÛrÛF }÷Wà!Ó‰D“ÔŲ“¸Ó&ušéLoÖ´U(r)mBr.)[íäß{°KŠ¢ä8™6Ži-‹€èã‰O~|Mù”x®‡7üðùñÛÛ¸—®Gù—¾{Ù¬Rº=Ù_gŒ¼,žÑÈ›˜³ãi·2»{ëŒÆ—S†YÞ…\ŽÌÉÑ…4 ÞÚ[âÜ®´‚Fi·Ìh2u/ööö–]Îp]wî»ùžï€rEç7ÍÜÍ <šÂ÷éô‚æ±AÈ£yä\__ŸÍߟx4ô±ŽyMzE¿‹¨RåÂYœ½8Þwï!1zàýïǼÿï½£÷E)ójálg½­?   hÌñ¯Þncðù͘Øâ„†ðl85ž9óµ ×ÏŸÓiµ–ú” …;DIR“J*‘S.D,bª…Q$´¦LdKlÂR†ËTèÞTkkUäëcJ{¡óD‹4±ïZ#Ò…ˆd˜îô^«:i)¨Ö"n}仵(Å—nUM‘ƒLc²½R܇Y‘ —j#(™ÊuU†•ÐÄŽQ¢ÊÆ™¯Ž|pé'U H†¢Ù×=#bØà7ÇrûUNfµ®Ø£¢^¦2jÕRÈF x ºN+™ÁÔtK+‘ ¶:&„Ó*UK ”ÔyTI•S˜Ç¤ÝÉ4¥\U´7¢gf˜oÛHAA®òaÿr —X2’ÕaØ 0©(…y+Lr´Æ_º·kú õSq¤1Ñë2Îi3ÄíYú.'Uս܂ñˆ„{!« hDiˆÔC e¥i"øæÍx@¨ï Œ,ÅÇZ–"¶Î&*MÕ«m³¹v§ žA*ç˜p6©Þ]Ô†îªõ·c‰a¸£8#vquTÑwlß?­jCDYV5ç»’qƒÇÂA å|$Läº;°Ÿš³aZ‹>á|ê/“ÞˆRn€ãÕCÆibHí™ÿ鉩þá5ƒrueÉpØ :?§ðGZ!ØR?$sà3Q£mÃŽƒ$7/Èþ;ÒÕIéø¶é.} a=Âì2êÆ4…%çmBå*N ›¡^9¯QÏ-¸ËTE®èIfb¯¶Yó ôU6c¥ØKê45[G '>)pQ^±¨!…fÝ(êxØ´6ó0 Mι= ^Ës»A m†àh45&¢TƒJ3çd2_ñŽ£5+rþŒ6‡ƒ1—Çü¸5|†/b/®“[¤*øÎÞCš]ŽT¾û°{Úзƙ^“Íú$æÒ/©àz4ämSÍ6¨€ù6Ž»îÐC»å_·êé7R@Ç}'©KàS¢+U¡LµåüfÒ´Gtc Ïk•@u)SYm™gEÃ6]Óü/‚Ctñ;2©ÂöÀ˜Ãîõ4Œã†äÙ£.ùêb¾ýãÝ[ßõ]º•èƒV´%ž‰Lj>¢ÌÒkÓãKËð°p2C“ièF9½çÚØ¾·9¨kYñô±gqo\X Œ-ÑZ¡5P_’?v‘‚ fßa0㱃ésFsFÈSBßkw†}dm#BÕ¶DÔAˆ&["ÄP‘oÍxËŒàFõ#{Mçþdª$ŒÌ2.Ý M#z¼˜V‘(º4ÓåKhº¦gá€UR~8jñeˆ!4•ºbáïy8pßHvQ=¦4Ô5—V¨-”MUJSúè¹¶sq¡þxž0n†åªÎP€(°[&!k1º¤–u]ªÜ¡ÍIJӎÊÕUnÒ\Â-OØüùAÝñ´7`êäKO_ž-§×§‘>¤†¢ºdRÄ ÕL*;;xbã䥅súòU«?ÀkŒ¯õj½83±1ݦò×ÇésÀ7ýi÷êçÛ;Lk nÁ³I¸ÝÁ]Ÿûòñ…\ûô ÆCÇŸx‹3›¬÷cÖ¥0ýÄ?N ›Õz«+‘1ª: KÄ.gĸ€¹Ï’ª+ŒdfH_ŸµÕ3¹Zc .·,ˆ:ÛÚÚ¶W¶´áp>Åâð ‚­ir%B‹äx£1{Éþ`Îcôã…ÔÜ`Êæ¾Þ¬Di¦¤ó›YCÂþlìNFšÎ&îÔ7ÃgË0À÷©7*2©n:Û¬ôðÂ~ <¦’‰ï3}˜øÎ&|èûùɯ'ÿ@Wtendstream endobj 4521 0 obj<>/XObject<<>>>>>>endobj 4522 0 obj<>stream xÅWMoã6½çWÌ¥¨¼±$ŽÛM÷¶Y(P´+ ‡8F¢eîʤJRvŒÅö·÷ %Å‘?ôTç˦†Ã™73ï1Ÿhˆ¯M¦ü®În“³a<ÄâË/›ÓÅÝfñ„’‡4ýaO§×”dÁjHI­ÊhaÌ9µ* I?ŸŸ“—x+¼¤L¦…°Â+£M¢p†žÚ`³xçgæV FB>—BgŽªÒ0´’¤°…Ú‹.œ¶’Úï1ÝJ$Ž•K+ç8ÂP¡·´¨,'×g_0üC ¹a ;ÚšŠ´”yC_´Ùx2•ße…eLwÊ:ßÇî'8é€ÕMÛHGÚxä¿P§!g¬'³ [i-ž”yúŒÖ¤&“¡f›¥JkDRÚØ•(€FʨpÄMCµmȶOJw¢06C ¶Å–¶ýN޹ZË<¶´U@°IZPÉN+Ôíe;ìœG+¨ÚrÉ8Oµú‘ís<”õP¼t˜°Vlo2Sý¦î“ôi<ï¡EdjtÔõ^š§ÅU@í¿L Ï\.µ´]®’ µ(À*C;©:‚k¥ieœï ŒöÏ¥§Bè¼¹t\ÊÕø†yj)€ÌÍÛÖ`/xßhDW)Úá­diMK5Ž-E´YJ]7Ú³ç®]šåz|CúÊy %È À:dJ#Ð…) ³ “³›_ô¯âñý±>ú5¯Æãx2ËfQ›ã ÆÝ9J>Pýæ7å<}m#fQiÕgÜa‘ðJè]&¼\Ûy€ì AÈ•;þl%ž<-ÑT*=<†CšGìûæ½½è8"Žƒ~'lÕìO¦&&Ø =m£Âs¼=´øÖA…Oý§íTL² ‡Ç݇KAäXt6&œ¾Õ‚æQ 1Ýp¸ÏÆ5<µùùù#„çÃÓ‰S<\áBRç~9Nh¥¯¬>Ù‡>ÌwScý¶O.ôƒ>RÝ®Óo!»“€Û-)ïd±`…»´ÓðZþ˜u*ØHç–ÍZ/±3ÓC.”‡.¦6ü6ƒ‚èï}-GKH8½&-–ÈI tU´}4»Ò|-(O˜\vx›KIRÞñ‚+­Yƒ ²®ÜÿõÚ\NL«C ¹ Y‚\)SPfºKº« ‡ismÎ`&¯5š»–Ö_8J&¡š72e¡¿B}éê,ü6}g%si˜ñ0Q=â?á†÷žç ¯‹ ú3XqpH¢%á´¨zÚ‘Y}OüÚyz’Ѹ·ÿN;œÅj9|Ô! Ž8ÐÄ¡]wP?=v]‹v‚fÍ`4»Œ¯&W4[ wÉq<¤_LZ½\ìiÜ·këÁu-Óx4£¤)Ç&W£Q<›á_(ÌlÊ+¿&gœý yØ›’endstream endobj 4523 0 obj<>/XObject<<>>>>>>endobj 4524 0 obj<>stream xWÛrÛ6}÷WìKfäÄ¢$;VÜ$ugÒÆ©§ít:ÑL_ô‘ „†´¬fòï=‹ )©‰ëÔWа»g÷œ]~<™Ðߺ˜òO¹>y3;cÜìþØ%nžÓdL³k§ßᢠÏqQf+I§³¿NF78'¬<±R‹µŒwóÎUÊÊÒ«;IÊ‘–²’yCK¾ãqŠ—ëM#¼¤²ΑÐ$6k6VñMUIíU­¤%>œ”Ž›„]JOÐËV,%ÍkãúÏŽÓpr§[Ó6iã ž˜¥VKúñÙ³Þ²Ûi/îIÀ:݉FUɶ8?-ˆƒµç›:X/M¢a÷{…Û•ð-Á),»*üÐÆ®E“ήd­´òÊè"-:ÎξWº”´ºÅRy¿ÚaM°œ€r„ÐÄÄ&hÕZ»; ŽEìûŒdlãý/å¤Þ I­‹Y)­ ¨kçpìLÕG‘äsc,½—pØ«R4 »¦²p?ÌHœáz |‚–úÖ²t]Ó‚~Àÿ—´xEŸÓI¨k&áˆ~o¿F>T@ŽôÀ½ôÀ:à…Y\ 5Å4Â3JJxØáJ³Ì@… fû¦é% ;¥µÆ~CF÷¼û]1 £Ë ±èö 7¥ämô€úZ ¦žj—´ ¤yu°=DÁól)ÂäšòE@°¯Þ0;¢Ö]@lkÒL‹a)–¡ÄðÈމÀäŠXvÐñdêvë…irÄ^/0*Pn³½‘³C±{ ½Àã]L›¬¡*ÍFãvH9Ný¢’ ÃX’ÓllÍ@Cµ²j‘yötcj«B@|ÜÞ‹Å^ÛîÓ2A"±bð ¾–¥tNXŒˆºGù•ù 3AR¤ƒÂD‘´ƒg# ,Iòc«ð~€¸cÇóK?RÀÈóÂU÷ƒÿ1?ìËHv'vÕ8· »Ål´”6‹RÔ•cͺ3x‡©™Ò™i×5=½ŸŸ†½£›«ôâ6¹z^\^\Òôrš'`1†çŘ~2e˜(Ã|Æ>a‰«‡/¢éi1¹ê¨È9™WWxgD¿zÁ›ÞÎNþ8ùŸ endstream endobj 4525 0 obj<>/XObject<<>>>>>>endobj 4526 0 obj<>stream x•WïoÛ6ýž¿â€¢¨;8Ší¤©—Z¬´]·zË—-Ñ–V‰ÔHª®0ìß;’’-åG7$p›:¾{wïÝ寣9Íð5§ÓsþN«£7«£Y2Ûý‹ÙÒÉÕÍg´Úàìù÷ø%óŸã—tr­Èå…¥TX9¥ç«?N®ÑŸž|‘©ÓæòZ9¹•æUø´‹5!<&¿ŠÔ•-bH²¢’äÚZ’°D*”GIèµj©±’ôfüÔïß¼¿u-36£ãù©MÖ"ýLN{H…²N(WWhuÏ1Á{`Qj¤p2#)LYH“Ð*—Fn´M…ãÜ•v¤d*­ hÚß ðÑŽÒRXKxÈ£an† ÷ #Åc†o'™.Ô–,‚[22kT†|H¨ŒvEY’-ªôi› ¥:“´.µp·Ï“ÈËâŒy¹É¥,'ñ2 3”€oâ›<펅´ª@¬XëÆ!EábƈmŰ·néÓÍõO0j :K+wÌ$ƒE×Dˆ¡tµÑ[#ª„®ÀZ H™í µº¡Ñ@íó+‹Ïè4´í´ƒ»LN¹¿ t±HNOñW6I’ŽîçlŸÌíWXpDüã’à‡Š?;~6Tò·ÒÁOÐÕͺ,Òýóô÷ cüã¯Ø«ñØÃ=MÎÏ_2<°¡[Ÿ•ÞÙÀg—`Td6¼¿×âš%z6kÁ”WËPÄ‚¤¢,Áþ(Zda‹»K#ÔV…¦o”L8 µ+ ©tX¹T±–mB×›)Al|ZãÅøÇ§¬–œ ­Áé¡}ÓŒ=”ß4´·üV¢ÿi'ŒâpËo ó)ª¢Ð ¿°]Ü{#¶V’_œ-.è&†:›Íúab µÖa£WÏåVÁ ²ÄSÊ2ö]óHà÷¢]KŸt³…uŒ ã0|Ôb/¾p˃s½9Ôu@ ó1º‚üB):5‡®¤*‰Æ˜J@T¶2½×áš@x½v^ʺöNHš2g²{+ó÷K;ñãåèP]è«W±i¯´‰ê~E±è=ýzƒÆè‹¨—¸b¨Öo>9¡ë~”À_¹Ù~ÐQpÑàBø _{×fú³ÓÃPäþpø»·¥!€|лCãîjÐÕê  @ðú_€ìy°W,wƒ~ðs¥ªµáÁ YÂ)‚©ÁþÙÓØCºF⡬°5x—ù×Ò`˜Y¼©ãÑÞn(Ç&ÍÛ89âЃ t)ûñÌÏ„Aq;a/”«kwˆ±óÉa3wDb~ÒZ=s´ƒ¹µÇÇq±ÿxsóÙb*©íÔg8€asÝ”ÌJ5æÖÇêFSÎ?§XÀ@lº ²¬D‹"HÓIø^˜£Þ4 yµ²@3¹)kËHòvJkLæ]^¤9‹˜³±M]kÅÐüzèâ‘„>íË¿æEG 7ù Ñ8ÍSŸ W¢+%>ìîŒû¬ÃWÅ„È$Ã"ã`5ªáç±Ti~«彉Ľ†×Bæ¡Ý>«ƒkAÙ'°x`·^\\™}çN°:¹YùÞû>5r¬…³—AÓ¨’@xúsév•¾³„@Œ÷Æx|M€Ûó:”c¿ÏA%J…=:+6ìX`tc_ÐÞ|Äë(Hã`U±ÍqV+[°„wñ<\EhºJ¤F{ž-‡ÝãÞþ4t%­Þ¾ÿøîõêí7¿¾þx;©±J_§´‚ñ‚†.îØ=Ã1zò„í3šèŠzO¼ÃèþüÞ¾îœ{ýS©2 Œ‚ÏŽà¸yãž8@::;ÍNþøÙO΀á)¥9fÓwáìÉÕ2þç5_ž%/N_Ð9~Æe–å¼Hf𤴩PZ¿z3 ¿púøe ä<™/iÕÉ‘¼˜Ï“åÿþaÍ\.ù·«£_Žþ1½hendstream endobj 4527 0 obj<>/XObject<<>>>>>>endobj 4528 0 obj<>stream xåWÛnÛF}÷WÌKPÚ±h]lÙI i·’ÂmäE@±"—ÖÚ$—å.¥¨Aúí=³Ųå$h«Ä]Μ™9sfôçÞˆ†ø7¢É”ÿçõÞÙÞ0âáæOwMG—C:K'”•4ÒôÙ(NO)+Ü­!ey’½~wõöeöú¿¿¼š%WBuïm§šë7=$c‹çÏ[<;7îá!©Æ^Ìö÷³›½! F0Q$išò÷£Ëcâ% àk0ž_ɯÚJ² I½‘¤K´ºZä¦RwîÔ®[IYJoJ|U†VÂ4?X~©8tr]×ümY·•°² ÷^xZ cI~8“´Ò}UP£mD;f´sI­6FÍ+é`3Ôc>È€ðý‡7?“ ¦©–ùB4ÊÔ>¼i/¡BK³rB¦o[ÝY2­Ì•¨Ô_Â*ݤt‰ðTc¬hr‰ô•´Ö=²TD&r 6T©[Î2‡ÞêÝ¢ Æãt2A ‹$;¿ï½UÆžsEèSŒÑU¤íÔ¹y¾õðÁ]:(„/v5 .Ìî³Z|ÜqÚöóJå1²YÂîðÞlÿ¡É¿ý]GK­ m+›Â›Ðó›]÷Øz%›k»˜%_Ë£¹ã³Ãô(iÁׯÓa¥ªÊQ×±2ט…C¹”ž· hε¢) ÅúùFH6òÏcƒ$`yCm'r«˜Îr-Ö´KI0¼%¬‡eYÊÜ’v¤5s<î›BvÕJ«Ž³Õ‘Ãfˆv…„vÒ¥EDÜMd5|ë¥B$¦R× [­©Ö…*kiº 9¾KC³dµPù‚D'I]7ºÃùz ÷Ìl?¥_ôŠsÑðà³W¨¨%l™ž =ÈÑnàZ´÷Rtx?—OäGDP<¸†¼“q2b”‹†ÐáÂZ‘/|¨" -‰ð·ðÇTä½±ºŽ—X•\ ¥ÊĘmµ¸E›‹í¾çŒ·þ ’´ÁåÎ¥ÅËBªPW=/ Ê›ä–͡ƈÉÇ¸Äæ6tµ¯%:ƒß€Ò¡Idôù[²âÅ(ÛR—ìà»Å%ûÿHKFÿZX܈ „0h3vS<¨ÔTÝ"ÄlºGæ”^鯠“;§ÁÛó~×è5†’c¹/µ¦OôùωŸ£#HÁh¶áPµ€>EÌ‘…nîćP?Þ3¼œSCÒÛ&ˆ Ü:/cxy$»}5¤ó ¡fã»^4çlÂ!…VÞî`öõètpEäã8¼œB€YF……ÈmàûÁ¡à]À|½D»2à ‡h7V·zŸ<f r÷¸y;b0›*B߃l²è¡×8ÐT'=¼¹•ºªôŠ}ìN°¹ [›înéR—¹ö‹X¬^+Ú zõô)†Vݪê[üåä¸å%ræKf$ç\®>7(uÄàÈzÇdŽâ@1y9º†ÿ«Iglc-–ð»Q>ʼw²žcÔ—}ã«[\ÄˆÞ š”x½³# o›\ñZ ÚrI¨1'[¿1×ë;³Ì Žà¦XÀóNb—$“ç V޾©$XÞiã­±$ — H>IÌuoà uëðfîÅý7Сö±Å¨æÝ„*­o#™T졳°‹‡ÇéÉ䄦§n‡g؃q:¤ŸtîÆ CÀÈñ›Äßœú_-ÓttFYXõÝ62¥ggøU…Uûì¿ô:Ûûmï*Hendstream endobj 4529 0 obj<>/XObject<<>>>>>>endobj 4530 0 obj<>stream xÍVÁn1½ós©B$XHI£H­ZÚ\ZU¬”K.f=°Ž–õÖ6õß;³ÆÀBh«ž±Æž¿yóf~6ºÓ» ýÒyãcÒˆ£˜·_fQ èÉz1 ®»Ñ`p‰¬vŤÍ4ÖÂHkx9Ož1´»´.›åb’«ô¦¶ür8/sáðÖŸLî`©•„‰0Íž[Àúñ^ Š"øõþØ­×ýžÎèØóÚi»×ßDÚL4às) .í÷XEq¬aaØßÔŸo¾ !úõ`· ª°J’ ²S_ÅQ‡¨ÝëEý>&ß2ÞÛÛ<6 cU8—^ôû–î^¸~BjÊ$Ò!>áý%ßM ÔÖz+Q8prK£6j¦ ‘{@AâTÊ)]€Èu-xZXRèÊVlzÃx°õ¨ïðÙ!ñð¸XÞF¢´ÙE¨‡]å¿)ZŸ„™ Ÿê®N_EÌ%Àon^'|}³Üß¼Ïõ“êr_TÌ„TX"++C/ˆ‰Oú¡”He0uŠª@Y(´ƒQ¢l Õ¡‰Sz$5Z7‘:2ömÅáIO¨à"ŒèÛÒ‚[ir°‚9ºLó³f¬Õ=FŒ2)w¢Æ zÁ}Óo`‚©`¡ÔÓÊÍJ°;A¥¼Ñr  d{Îwx †°õ4s®t‘“q2W–(Œß;º bêp³¸ev¶'>Äúõ6Q²òLpÓ P†..º 2eÀ 3C¹(f 1#\e©³ —hr-¤*f­JÑRQ.‘X`Ö>Üý†¹W6u¢íóìX…Oïý'N2…¬*R¯°!÷+àÊ-² Ái fÎÕÈY•¾5¬Tž3ZáÆ›«Œ.›Š|›èT¦òÆn ø`C*[ —fä]bIHðI<§Ž^̑ۺÄzJØÑNR0.#ó ûßô"ÒÒ}höHÉ¢¢Ce—!%;ÐÃÓ¾"q™ªR€ÍÕ,ãÚ*ÑPâ-ÖnG…Gþ¹)u:ðaë!¯d*¸ÝÍA~ :î'G©Ê¸‡åuU_9p4¾£ ‹ýØó´5>š¶:£á¦âºÃ‹è² ƒ!u?Ԍ{Q ŸtZåMp³æ‹ÑØåw·¯ü8ˆºCH‚Bð–Ën7iì$a¹ŽyåsÒøÑø w‡Þendstream endobj 4531 0 obj<>/XObject<<>>>>>>endobj 4532 0 obj<>stream xÅWÁnÛ8½û+æÒ@lÅ–7mƒÝ¶isØÃbUôâ -Žm.$R©ÄFÑßJTeÙͦØ6 ›’oÞ¼¡¿Žf0¥ßÌü—£ßÒÑ4žÒ`÷Rmàân ×ñÒ5$SX¼šÅ‹ÅKH¥šBšEÀ?qŸ§¦0™Ñ Œ¾¿i?Ò$úxqv¥Ð¬ñ ,VXâ̅C{0÷îRè1ðíà À‹0e­D¥–ç@ÿn”v·aÃfÿa¤l#¥©W9‚¿±¾«P5Âc%Ê+ kC€·Ø>@ÖÃE°ý;ë0ŽQq\ÕÅÝ%ðÖ0!î&ɼ%<ú]U"«sSÛ|?†½©áQå9¬Qå¶ÂŠl È4[e4˜50DN`³^D[5#a‡¶Â†d¬k9šh‡Ó<ÑÑò|8—Ó9ØBåòT¨”(ƒB’K–Ä[ÈLQÎÚ"cJ”g@")V[WÕ™3m&2S*´ÀèÙ%ˆ¡ÇDgEÒ¾à~èw’$ñ|Nj–QÒM– k!¡}—ÜB³”BUG¤P"½²n¨8H°HhäÑ^ˆy×ÍÔe”Îøóò|ÜN¡‘¤o´ì,#Oo¶#°Ìoy¶ï¯»ë/ÉON¬68úçîèŸéè Ôfu~CyüŒVöéîjÜþ3^º3ïbÏ!lhZF»¸}wŒ³qŸVCº%}H¤”U‚UËr¡2]cæò=ˆ,ÃÒ *uÖП_î?ŽaU;_¿þh”ºZnJi… 6ÚT(¡Ö9’*¸Ê¨¢r•)^Ö—åbH})1 «I_ƒM]f¦Îen /”•Î&Ò¡´ Yie¨œÅ|ý ‚¶yZ´=ãñ>÷‰¾!Ù§Éí›Eò騑(E®^®ªNÿ¥/[äWz3tŠíÐS<”ÊBh‚1mœÊ¶æÑç"šj“m]£ïÆtœJèØ©[BM¥6J‹üG–½™(–ËÀ‹rš§IG¼õ ‡ÃŒu©¢(K¤9’Œ¢zÚ)/Ç_q""ý¾›‹m‡ ‚9`{DÅ}Æ×(5Àñq„Kn7>¼é7ã~ÛáVZuÛþDOû‚ÑT‡¨Ú~}€äØ6‡h˜{!!ï;ñu;ìy|¿hAÕ6†¾~›þÖ)¸_6m#Ä<ÿ ¡«šot’gœ¢œdOrò®ësý㜠姦ù–º¥Zs%ÑUFTt ½©Å†.;uYšÊY0$½ÜIE;æÓ]å¹jïUŽB>Ý[éðÿG:{ÿQ6Âr'úï“q϶OV— ‹žè®ÜžÒîV<4ÆgÉí@ÓK ŸPg´·¹¦‘…rú GòÎGÞBn¬Õ׃j|ózPVq«ì5%DWJÔʖÂÑÝ’m°¬ µYM,±¤{:›;õ_~H’ª ÔÔg÷%z‹½¸»noŸÉô2¾š_ÁbqÍ “ÁN’x ïMæçxÛdXäCMääesÿYÄ3šÒÿªp5›Å××ôí…z5ãIÒÑ£¿ƒ³í¢endstream endobj 4533 0 obj<>/XObject<<>>>>>>endobj 4534 0 obj<>stream xVmoÛ6þî_q+Dù-qÝ4°au`û0L@¿0éls“HU¤’E÷ÛwG™Ve+­7Ø$òx¼ã=ÏsüÜÈ~c˜ÎøŸä½_¢Þ(ÑàþQ®a¸¸‚ñ¢ÙÎÞÒKêæé% îW ² ô ìFF[ø\I‹€JWë •ÂVWP"náI( VC.þF0:G­ðÜÀE ø\d:Åüùéþ¤²ÄÄÊG4`ª„èGõ† ŠØEœ•¨DŽõ¨1´­Fp9žPÌÁ>[T页 °½$8³ÛsQØB"< H•dUŠé.DÊJ*°˜™ ¼S\I%­ÔÊ„°Ð%¥%h oü&ópʇ9¡È&“p:¥¯4a!3„Ȥ±á†9t>îÀû¾M2a DwP¿üF¦ð¥e a¶†Šê!“‰Û~ï‘Ì`w|q°\®ÑRÉòå2î½ÇT6î¿k¹á%¼¡›¤ú=wüS[tM†Åþ¢ýnt„)vºÜÕí8OvÉF”p±\[RôÅtÎŽà øa'€¬¥Z&‹ *+¸\p1b¹­÷\hP)•±D=é2õø˜\¹ ,ñ–hl4Úù@0$†,DÉ€¦˜ Ú0GߌkX•:w±zdÖ€üx| Ÿ›‚`{Ý€?ÿ]Åo—™¡Ð8Ot±íSÄ@åÉï!µD[• >9¶ÝFwqpñÚ`¶ê"U;Œm¬+N6ãöÅ:MFŽt„“|IK<íá 샨µ‹WBóÃ`ÀœOTGý SáÜ^]‘§ rkmÄzÒñ õÈÿžéh¨Å4¬ _Q7ÊÝÔáë÷TŠ¢sV)O¾tø½Apç¼Ò:" n|Lç,×·íu»"û…qÀîû@OWì]ƒœïúØx~^O¯a6ß_øÄ/'á~ÕI•ûnÍ“ÎÕÖ—oj±™…ã9D»›˜a“ëñ8œÏéæJÝöí„GÞG½?zÿëœtendstream endobj 4535 0 obj<>/XObject<<>>>>/Annots 1512 0 R>>endobj 4536 0 obj<>stream x½WÛnÛF}÷WLQ•‰ÑÅ–/½MZ§yh€Öú¢—9·&¹ìîR²äß{f—”D+E­c8¼ÌÎõÌ™ágãß„fsùM˳q2Æù3‘?¿¾9›Œ¯“Mo&É•4™]&—í]A÷gÇ÷x;¿L®Þ¾z8R´Ú5½¼» É˜V°<¿ÁE â"<äÚÑV­¹b«<“ß2¶…Qg´µª®ÙRÉ>7™’Ï™VÚ:ÏyõȤÈéj]0éÊóÒÊ‘ªHÙuSråq…sŽSƒË`Pž?ü~6¦Ñd §bx¾=é’Vdz!"‚#oÈ©Ýî{ûæKÜrYâ¼kêÚXOµ5±£º€ý™™ð¦©´×xKËê1¸…‡ØqB¹òЬ³¡ø¯KQ¦ÀJWªèy[øJÈžÇyóòî²Mó ¸E™ÊÀ¶+cKâ'Ï•ƒ)bk¥4çôyïºÜgQWW2èª9Õ+ª¢h>Õìwu?—{ÕìG´öBê•‚MTR¥¾Q¡,ðÍ»à wîPÆi¡€ m**C©«9„dÝë*…(Ä_¿xe­ Ô^ªÛKUnj^5p¿ó €.g$NÅc’G&Ë®)¼¤¤ƒÝ *æ,\–t¢´ðYÒiåàrŽšfM]àÀFz^¬š ç ꨈÅ`ÉN2„Ί»¸OˆyÃ|¶1Ì–°’BŒW¦Yç’íÀÿ#‹E²z{¨Ü.Ît¨Î#ˆ_#b$t©ƒ#;téà0ìzl¯>–à){¬[.45gµÑÈq(Tj àV+À ÷º Ù­-£/Rô±]_ÅÖ{hûÇQ®Ï%£6¥Aì^ÂÒЗB™\š¨N¡eÐêÒÛÀ¹lĘdq4If ´w­l¼­da*pE¯Hã,¡×&“¢ÛØÃá¼ÀcÅÊ7@K­kþCÀ`€•h¶Æ>&ô“Ù¢°6’¡œ`=4•ÙFì}ÞsDʯ<…`—Lâ—\îYŒçmðÄšü·o˜ŽóþEõßVÄÊ¢¨–„–PÁЗ’ÕH¿âéË;ŒŒ±°úà‹Îx|~ ŽL[æQQÍš¬I…¢Š·„®Vª ¤'…K4cS¦®zÉè°Õ>'ƒF§tª]BwH?)i„ÛÎ5™aðm*¨Ÿ&³£‹ÁŽ«çQ®¾‡ß}ÝYE\|™µšÞ÷Þ~6FgäL‰þ“á´@Ý{úГû”ºk\š%óù• pÉ€½F‘aZÔ´³Dù¶´†ÂÎ4äò%@"´¢XËt8@ ¤Pí8ÏÿKžB"ÿ›\ÝëRc€ÅäX× a´©j™ùY‹´qÞ”úÏH[]»¶MqC“‹]6’ÑôZ.³Á<™ÜÐ; ÐÕ Ôa9gr}-‚÷íŒÞ—Á#éŽg¤~2O,c¸È Ò²ñ´ÜÒW “kŠ tHyÇ‚òhZöT ¬FId)†?ø¥ d*<¨²Â°Ë:h……eoxOÅ &@ÕƒX³Ã"6¨‚›yõ…ºmm0„³.µz‰^•ƶ|(Ínm*1›=‹Z¯1襹êö³R:È>ß\T*#@êævåÒ®ò8ÞÚNì$ôŠ‘r†´W˜]`a‘ë2ûlPIqž;:ļï%å5ƒS°%E} |Qê§ ó6ðÞi–EÏ|˜Ý#ð0ò^ŒF@V%Ù“B kem‹NQs<§€Õž3±SK…QMx—Ð÷Ø[1±è.•Ãì/d-Àºp€›l ¯ÀýŒà*E/4aKYQŽwO ̽-,!HÓ f¦YbëÆò½ÄëÅyŸDÁ’­Pjܩȡ½¬&?:¨ÑåÐò‰~è4°?ZUæRЊcI²_5º§‘’åž ýiÿÌåR¶3Ù†PÙC–¤ Þ3šEjŽî—Ý«¬ƒìA/VúIZ!<û„Ê´I}¢oCinoC ð ÷¼­`©Öøòh2^ ¤”··]ª¿JŸŸè¿Oû¹n3õ·ó   {èÇÁŠu „ ï°a¸ÀÝh4PÞÑv$,³vXo¾£ÂÊãe ÙQ³–Æ’µ]¦ Ï­Ù†õ ˆ;ÁVí0zMuHµPj»GôÒ>/XObject<<>>>>>>endobj 4538 0 obj<>stream x•VMsÛ6½ëWl*ŠDëÃVlez°äÚõ!éX^tÈ¥ˆ$XÔÇdòßûÀÉ”O*[¶D,o÷í¾Å¿ ñ3¢ÉÔÿ†ig¾ì ƒ!ÿ˜ ]=é6˜Ð2¦ñ¦w£`:ý@˨´Ò2ìVfJ…Kf³…NsÅûï–ÿt†4Á êFºX+†Å&“®ˆxխͨ®Þ}¤êuuEˆ”m.B¦Üp,÷d‘yΑwwõxMÞ_LŒ'5î‹L¥Fúä¦PgŽ3gIÇ$2ÂGi˜²£ë×MÄ$¶[=8%?3¶K;«Îzô`<&¤ ªc=9óQ3Ø=ýJÈ˪; †ˆñÿäãÍ`ï•c“ '·ì— %…åèí8N|Ð7£ø4›ýx 0nqûf,•…êt-}D:+9‡–)fá öOÒ‘´”kk¥'ÊiÚé˜Ñ€÷¹Ò‘¯¿PƒÏdñý=}iQC*a-=j}±òµÍâ×z#Š…qr9¿ØøŠ£Åå"ª¿ê “‹ûöI°h« ÜmÁ1-f3ï…ÞÞØìº€øü4íóÆú|ýáeqŽåß8  ªÜÍ…¡åèy]zlÀU!“[a©<½ä"=¹z˜Í¼ë/-ÂÎömµŒˆ·R­º÷Ufz¢O¯0So]~¯óÖ ñ­õ¢~ëÄU¿*Ãf'÷ ˆšÄS/®ÛüL§&GzBÏf¥DUÅ,•tе![„ ål¶l,ÚÀ×ü/–a"_îÂ)3¼Þ!46Z¼…Ô#Ò” ¥r“8Ú‰ÌUžÊVØá•“dè©&¦±¯V'̆)‘m ±á€н‚– XµŠ ‡Z<1ÌÉ8f-­8fÐïzçÑôI´Ö%}[‡mhY†\7m‘EÀ)p" ”rß‚sò^öÀOõâøÚc}ùûù‰âB-ò\H»OÀ±]pX†Œù¥6ª²9Ȭã# ªë2ÁGÕHE@Ï1t¡A’Ê3üðk½õ#$»Òµ@î¤R~päÂ@^ac ‡Î‹0ª\ÜpÆF@š iy=W*LíÒƒi¬A`T`Ô ÚióÙã²!¦óŸb(…â ä˜x4‰B€§Ûo]s"¶EÀ|¬„Ã8<Ë–ßyQKL?JY@†]®¼Qk˜*ÕÂñŠ ‹JÜ /N£²° R¼h8ð½TÂï…¿; 1£bâ¤êec¶/$¯fóÏU²ÐQºÁy&ÍX9“tv)kaV]ÔÏù¨nÖq+IWÝóÕFÂÎõÞ¾wŽÉwü\=ÞÖ÷›Ñíup3¹¡étÚÜ;|ÆÁtX¤èÃr^ú0qª¬*%£»ÓMÊz››Ñ(¸½ÅeítwíŸü¶ìüÙù¥Œ…endstream endobj 4539 0 obj<>/XObject<<>>>>>>endobj 4540 0 obj<>stream x½WMoÛF½ûWÌ%Ø´%ÙŠ-.ì6N}iZD@.й”¶"¹ÌîÒô¿÷Í.)™òÚKÖÈÝùxóæÍäûÁ€Nño@£1ÿ$ÅÁÝôà4>ÅÃí/³ “û3œÒ4ÃÙñ%>¤þ=>$‘[Ê’¾~{øLVUÞPb¤pÒ’[)imDUICY]&NéÒÒáô¯ƒ“{8õ£¹0³hvžvn¢£ýc¶Å‹çD™îŸçbùÂYR%‚’ä„YHG¹(µXÈ8DŸjÄ\jÇœÒñ`ˆ,£ÊÈJÂ_+Ekå–$—J$’p$SÜ4$ Œãä.WœXÁEÊ®EÙÐJÁ˜Î¨”Öá©Mt%ãÖãðŒ=N—V”%« IF0f"‡MØw÷p×@Õh‘,½*ÆÏ>ì‚ÂkÑ™Cij GNSŠ0KI…Nëy \9âxƒ?ÑK¼®6"§D#sÍ¥[KXäsµ’\k]‡³œ“8È6 Ö?á1dØbºGBª´N ú#RŽÖºÎS®õb©K0ʆ9p@&ÂÚظ¥pp F8V¨ÅÒQ!VÏ­¬à“$7ÑÆ6w¥t}ÌbzàÔm"¬¨DˆnŽ’È´.SQ:¥ã‡|”¦ÁeT'åNSŠ·«KG–5÷ ÃØ‚¥œ•9Ì‘hÚ tóˆ üôbØ¢÷*“¿ªj QWZ‹ÐfÔ蟲ïSĽ’²Ú…²µ`uMÌmK Ò+ø,6éuÛý L0—¶½ø|' >uÆÜÌÀ)”E¦¾ô½ÒÖ*.0Ý6Å\ç¶å¬ïžTe˜Š¶(@b4-`Ä—9ô$32ËUâZˆzá?k|æ ÜÈ–œðI–¥‹xÄB7„ ‡ñh„oi´õI·ô£³ ýJ#"zÔ*EØzƒÙáUïýß½o;;woÙIu (^4µ“âcâ(?r ß§˜¿:IjcBùUž,æIc8ÔÌB›BieŸ,Ûʾ F‹X¬&ÃqLŸØXLïÀ{Ö­¢Îâ9Ç©Þ ²Ð×ß¶ :ÚðXH£'>F1ýnä£Ò5"ɹ«¹›!9Þi(\79öP™j4¬Õù#ç‰è|ê[–31Ãõí8zŽAèûF#/ ÊŠb®03 *œÑ“`lгÅ¥ÖÃ,ºû“IsHw“ >ôiÇ}àjÙù ð<…ÚvÓ+êCÞ7Äýê'hm!Ãûõ{Z+Jµ3KVðT–(8Õ'j·»$:ÅÀš.eãçjˆ%¥yô´[$¶³µ}M‡_%Z§`#„Õ‰=Ë¿ê5?ŒÁȧ±†<ÆÝ²Äþ÷Só!ŽÝ‹0örM%!£Ø2 æ®3XDüÃcÏ$Ÿ ß ˆ^°Îzß:ok›üä` †¬“ iúl/àNæé¶x'·­-Ú´Jù:ûx=]•zÍò†­!@¸íùÖÎ>° Æ]š<Û[o'“Wî­— ËÅÛ·UéÍ]ÄQ×ïÄ¿ñ²É‹U4Ü ‰†ø``†u­0B%„ç×I´Â »8â½ôÞu‡÷L•ïº`¯Ûä¦b ên‚“¼=¦la»3‡é…¹ü´pG(àó‰¸õÍâÃ4½¡) ÙÌ¢)‰#|žCA@š°¯r<74§ŸðwBó+êóªû†¹‰ X·“ Ìu ﶈÍ"¼C­àƒØë5>ß\yQ ¿ _V¢éІWÿz–kÁ:W×þA°Ò^§Yô½¹ÊêËiνœû‹¶ógñùèœÆÛ„w¹ãa|J¿èûpéüXä a†ÓÇC@ãxpI;Jñ™óÁ ¾¸ÀÿçÅå9?ù4=øãàg[T`endstream endobj 4541 0 obj<>/XObject<<>>>>>>endobj 4542 0 obj<>stream xµWÁrÓH½ç+ú’B[¶bìî–¨-\µ—\ÆRË‘fÌŒGEñïûzF’#ÛÚ­Ú"±=š~ÝýÞëη“MñoFsùNÊ“7‹“i<Å›ývE“ë)]Å´Èè|Jó«Y<Ÿ¿ EêOMi‘DZ•ì6*aZ*Kߟ.¾žLi<ÃgiDøª]®W´;•óúàÐiÅå¦PßD¥ºOM½,øæ)^ü^ýñZ.›Lèó­jâÁ?äÕäú9IÐŒÆ:>¿hF‹5SbÊe®U•M&Ûq¤tJ¦Z³¥/|Oin9©ò;vÝP®+kÒ¹¹zYø‘˜ - Ô”6Ögéb’ ·ÜPµ–d+ƒ¼ÁãÎs©F™#XîpHU¤Š"„\±fë¯ÛZµÙ°(Ër·ÆpHqÞ¦Ѫ0KU v‰Åô¥)—¦p”YS¶ö=T±U TIÂÎ!hhZVECßjUäYŽwýãñØÿô(5ß¡ty¹1V ‚zAÛ£À‹Z¸Õ¿l3!ËZrÕx×PjÈÚæÕšTȼô­"ùÒy<ûÙ¦œ ¥CWcú¨QÒÒ¸PÙD9v£P`•~­]…H  Y}Ó][Ä_2íeÓ³•ÔF@Žá[› @5ï751)·jU²FW'Èe¯5xº-Mš ‰^ª ~ãû„7þ³5ØW á£€ÈP†2®cº6§Á#pW»ìeëçÛCYý{"^Ÿ‘ŸLÅmîÝÚh؈ÉõnöÀ ÷˜$Ój£V˜bûÝû•qû Ý뢒éÙŽA#eÈ3“¶¢{ÜÔÁðÀ¶Ù¨´¸X*£#ðXCnmê" pw¨Âyöì” ®lhÍJ<7;EØe¾ZW[wXt˜%jRÔ¢J±ŸöéwñA:Ý[M"r²^´ó*ì[cSLÌÈ+׎­¯n?úàŽöàþ_—E1Àå·š¾@´Å Æ%¦î®Ò„Z#频.¼=; µëˆ#®ý\\û(eÞÊ0ô…q2ûlSÝ\ ·uó=z´Npƒý£¹.`Îôè#¡ÕÞÇ1ѱM†íI†' Ñ/?rm_ܤ Kœw¨ÎÌ–²ÐyîíÖÂmŽÅM–Ä`PÀˆz ô¼;ŠéÈ ¹âаH€‰h£^uDÇÎfãÐŽf\†¾‰[õ×¹°í#ùo›æÞ{ƒHÒ¢.zÄ}…o÷@dB›³w&OeO¸‰@4ÅžûÃIè§æþj0<ÄÒ¯@úFõ@c¢wíˆñ-’ô-ÞÕjè‘?C~z_Îå©w‹“¿Nþ%+)˜endstream endobj 4543 0 obj<>/XObject<<>>>>>>endobj 4544 0 obj<>stream x½WßoÛ6~÷_q/”!Vü#qÐuËЗÃŒõÅ@AK”Í•’²b ýß÷)ɱÝ 6 -[âï»ûî»Ëã`L#üÓtÆÿ³rðób0JGxØÿ°kºz¸¡ñˆÎÎîñ!ïñ!K>/ç‹¿W×í¡„>ndE~#)¾À Á:y#Ÿ¼¬òÓã¹²2ój'I9ªÌIUNå’U¢”n+2yüõ_à >®ªL×y0 'Ö²’Vx<(ê NMåRz0–ïÑpñd’N§ø–'‡8 cèïÎ9§&!¢L çh%ìù«m½Ò* ãp: µé97 oñCUžVZl– zZ^üxzs8ùåìñÉ“/\W°a7Mg³[À…9ç´”~còÓ*Æ–ÇN®F)¶[ØyƒÒuù?5çБµOHϧè ßæsÎÖNêU‰àNü§´@]z·òPP+™/̆HmVBÈ“FW'׌ô«ä}«º^o掄•TháÁÞÕ¼°kéI‹j]‹uËÐ?>¾ÿ$l,gÄFr™•“v‡09ÃÌ>\q„&3ÕNV»$úŽVªÚÖHŸÒ’ÓQ»@a¸C|ceÈí˕Ѹ°*@4ßç$X†.¹FiM«pþì`üIL¹|UßÇR˜Ø#zá9>”ÊèšÁ1a›ÂØIÅ÷­°HŠ—°#Øá#48&¼±±ëËÚy0ÍgB#g^ù¡iHyø< ;—…BÉRúÅàrOÙÕâ—ôX ­ •‰‹)ÂÃì>ê„«·[ãd+9 _!ÐÊtÐŒVGô¯4ã¬y£š@ËsexINÒ4ìLf:Œ,PË"ååêŠÞ=KyAáÆáO|¬Ëé‘\}Åÿ«tf"FkÓ¨jÍdàre )| –â‘|Úb4DI_«¸afÁWg™t®¨u¤ÃËùc%Ëö2ñ‚³¼`šÏä|~–|˜h'yxnÐÑÌ­ÆØÏܯ ùa>|‹î­R3|ðï[„wÿ®ˆgÜ13 ØãÞ®ILJÁ³f^r©$º“õm1Êu볈µ‡qÎèD×mB W%NQ£¨]ÍCscà^öÆ´»zè£<į*jÏó \²~†Û7Éw9ìVì4Npxîì@Xœ7o¿&ü-ùð˜¢ïîênšž4Ç;Sn!©+¥•ß³¥¥o·m$ôg”uǤórk">N§étB Ï3lvXÞ”C¿ƒaÌÐ ÓÔ‘mRz‹M@Cú[‡Dp¶© Ò®÷¼vCx¬±fæ—´ÂmL­aÐ5-¼;c§|Æ{Õ¨ z·ƒ¶•ûÂcüf…8y^T¼TfXX*ÄÕ©ì™^(8% ‡8R$°BcÅþ:Y8Žð•&¯5„ˆ·€¬¶Ð:ž‹HÖ3•çk£üskÿì.ÑàtMé}Û…5 ïe¿ÓPç¶ÄG‰øg ~w¼ —ÆÊ£0D¾UÖ#,îPiÌNëی޵ LF×éÍô†f³;ÞĘÃI:œÎê>»½âÉámÜ–géøž> ÖÁ}÷7ãqzw‡¿Nàéþ–­~] ~ücãÑendstream endobj 4545 0 obj<>/XObject<<>>>>/Annots 1514 0 R>>endobj 4546 0 obj<>stream x­W]oÛ6}ϯ¸èPTb%v'ñ°‡®kŠèÐ5ò’Z¢c¶©R”]cØß¹$eWª[¬EÓ ò~žsîõÇ£1áߘΧü]TGgùÞð1ÿx÷êh2™æg4Nò)U4¹<ϯғ¦»£ßçŸ] ÷Ü#ÞÞÐxBó%lO¯¯i^“g4/²i>¾ÉÇ4_I2M- IK)|ëð¿udD%ÃÛæxþþèôö‚ƸÅvF“‹ü–²;[IòÂ=JOZ˜ÇV<ʆjgת”Ô´umÆ<|D3È&˜É¢K~9H4DÝy›L.ó›+8…»]ÿJ—h–‡Dº ah!IÔµV²$oI˜-Z4Í 5Þµ…?¡Ö(k¹JÓVlv”ܸdeVJ\p¸¾Q~¥ ‰P”r_š¾ÏuCœªßÖ²»žû5¢¦–…Zª‚ k Y{²Ëd~òtmP2G][TC¥¬àÞ;ÁvRÛM@ÒheC4K«ñžŸRâ3¶xz{F×ù9ƒpÂ(œäççx*³§ÉüCö$òäá˜Þlï­Óålöžœz6{aµu¿v9L=M‘ïNߣ‰5Ìæ-¡µ€<ƒ  ¯)Ñ“&T£0ó¹i ï&p’9Ýòäî#*ÍÛQpÏãf[-¬n+»-ìH~R`1Ì1†øçYÏ2åâÏDXVXr$_3lJké?Ðå«óé'ÍÌ_¦ñÊoûgÍ_[UR©P_¬väz¤±ðC3à§úLú™d}€©¶Bìj¡4ò#FXbÎN¯­ªÑÐR¹ÐOï ]E¹»ûׯF“ëaê öà°¶Æ ö:n°Ó3èÏÖd/¸°—ìh¼kÝÁ-8,ÔÙó†Vˆb!¥¡ ¢<Èò„6à>¥Á̺-ñRYIl$ØC~»ç$°ªlxÈLh8o|»˜z€Ç˜²º * ¸ÖÒa‡¬dùpœׂ¼ÃrEäØhõ¸b/¥Z.±ÞþyÈ)a‰e©Ø¨Ð1*®“À ÆbÖêCŸvÆšÑÀ–VsIy!¼À½Û<ƒcÉÎéu\E‡ Ü7ǪšÖg.²òس¡Ä+¹/h…ddu®±ÈRbÏ&ì.=L?¬ßéP{!iJ\Nc—^àP0¸Ã§‹¸_°šÅÁ·[]‹Ef¡ºÜúh¯‡û±>AüûEQ ì'¼_'–MÎ.òËóKš^]åSþ˜uÔ ?lÑ2`Ãìf+`d<<ºŠªñ=/Çã„jssÍæ^Îþ>úðW–Sendstream endobj 4547 0 obj<>/XObject<<>>>>>>endobj 4548 0 obj<>stream xå–MoÛ8†ïþs   kY²×q‹M7^ôR`[í.|¡(:ÒBU‘Š“ýïû’Ô‡­ÔȶÛ[GˆIj¾8ÏÌ|…à7¤ÙÂ|ønt?Àb÷¨nh²héÏ(ÚÒ4 Åeè/Ï)Jì©€"îU¢`;±ñâ8ޜӇ’q±Z½¾z³Z1Æ6^Dzsþ‚ýL&´ÏòœvLó”âZã«N)—{QQY .QpA:eqÎÏ£FC(Mz¥Ø8Rú²Ñÿ鯿_5ô+Ö’zÓì&=R|¤ï‘õß³Ö ¨ŠP 6eÂå‚F•†l<ú³{:Cì= ÒöDþÿ7î¨urã9ò òç!gr¡ë0q¬èL’y÷m†“ƒJÓºYHíJL‹^›Ü¿.ˆï¤¶µUS›ŽW1v+-Á%R(ðÚ²¡¬¸BR—Ë€Sɼ֙,Š8«FU5EJ+d®Ï5˳mBÌ.íj¥AM{K–QU îŽqmrçÅ]É@–, ü·x>É¥é6YAgâN‹"ùŸ:!'*ï€Ò¾÷]±ÍÖj†Dm:wÀôöÒù®ÐÙæp¶¶ý`Ã>/XObject<<>>>>/Annots 1518 0 R>>endobj 4550 0 obj<>stream xX]oÛ6}ϯ¸ÈÐMiÅ’?â¸ØKÛ¤ëÃÖn Ð-ѶZIôD*®Ql¿}ç’’,)N—®)lË$ïç¹ç^ú¯“€†ø h4åÿQv2ô‡ø†_~ùãíI0™øCšL/ñšQp5ôÇÕSJ·'íçŒÂðÒµVG“ŸG…³£«Ð¿ªžølû9£ñÈJ¶{yµýŒÕÉпlm?g4vφSÖ88«®¦°Â=±äö3¬]úakõÕ]+6Åš.nÆ én…hM¯ð!¶A‡È{·"‘“üÉ­ITNz+£d•DÂ>%šJ-ãÝ~|÷–DiT†…H¤éžÖ2—…0RÓ®Û­,(R±¤•Âa¢M’¯Él$%yÌâdÜÒ"rÈÜmd~v÷édHçA£¼­Ò:Y¦r@…4›BíXDb Á(+ʈb- ¥"_—b}¬Kå÷²0í­ìPQ`-É#³Š]¢¥O7Ø%¿ˆlËZ“®9öf£òíU r¸™éœL“Ï¢=g.n†4C’à΄€ÍO±·¢Ÿ¡A-¼ÅYí(Gß3ÅÞdÏí„+™ŠÍƒ½.5tÍ äÃcô!ÆšD•†nh#òH’ZÑ©=wꬬQpn­ùÓé%[óF‘¤š·oÔŽ8Öx¶¡­ò¹A¾Ò:Ÿ‘(×C¯_¼è&ôX&8ÿ½¤ý¤Ç.lšêÐX 4ª2ás¢3vN•ú¡*£öH·ØsïÔ¢FŸ’Ùoe&¶Ýmu9x¤eÄðö+Íá˜Ãp›p̩ķ¤U&M’ò*Gpi `DФû‰Tå’2±§\ZBb®0ë¶P(´NJaÇ÷F·öéNQÌ f€ÔÆÉj% ™˜n8Q¶Lø€ë2N vèv±•l–O¯U®ËÔØ°ùï‘#Çëº)û&ì»ÄlèYcÉ#t뺭ÂiK?v`‚H}.¿°Å6ØT­0Pö!ÉÊt‚"ÿ‡…ܦ"jö%ÚžA˜m/n®(ƒ×-¿‡3þ{S? éQ-CIÍîµÙñ<û³oNº˜v©Ïå/¶ƒ9pûáÓm’%©(\òÙæàC€*å=ÄÌYIëÀ‚%£‡&£ÞB !w¡‚WVä=;ê¨G+)LY€ß^ábªÏŠ~ª.ä0.ß#qìîðw§KtŒ-5»ÆuÿÝ–ä´àþă€¹¶Š´Èœ¶#ï3‚Íøa߸Ò\5Y¹œ‹¦ºMщ¨±Bjj§9ÀõûÝ ¬Ô†I웣JRàœËä{ C+èXºË«.YÞs;Ô^;㜰̪™ï’4mz8ÔY TÌTp/<Ä–ëÕªE/Þ©2uPeŽÕpTštƒæÓoÊÈR¬ÄÚ(ë‘E!X8-ÑwxÅÙ„i£+ŒN}ß?í6ï4Gû°6Eº~%´¤¯tŸ¦yþc¿àŽû’þ~Ygr}‚»n@óæè7¶…OÛ6zÚ¶ñ±mèÛ ¦º¦žmîÁÀ¾…eqÆóÆ|¾…u«ãSë¢Ù[Muœ”¼Ö,Œ¾v„lËešDÇ(ïìã‰æ^%15å°Z)Gº1ïõ=²Žœcd醾V—ž£÷&žöW,‡‡¶Š$Û!sKõ¤äU„ÌÃj‚ú⺳–21bþË×G«©SKÚ{O¥Ë\OÙês‰íí"f#Qx¼ÖÌχrq ª …gAáÓ5³CÇ,4,Ȩ¦çªÚì`w¨`L}͆z ýyÎÚÍ©vœ»ëTqmÖ«¶#?‚]æŸsµ«æù‡JÜäö±jGR[c¾êÿ¡ÿÚ±ÂÄÏíìa£5˜Àå=5÷L` r6Ï‘¦ãÊNîšøu©Ž‡Jð}¢c#¸‹AX½ª÷qÏ_Ÿ~Q;  v;§üH‰¥ºÇé7©.ì¸ã§5Y×)æÊZ–L¹–LzÀ,Ô3Ô¡SQ}»´9i£´{ïp8éc²YæðtŸGôAA¨,Ðiý*³%>vä+^=&Þâvc§QVžÆÏä_rÞ0°ól•bîãÛ/î v6Òåv« cYaÛÒÅŽ9ÖÍœÖNƒûöE3V e‰ßj»ðÞ/?aæ¦çj€oìBýÝ|þœ/ïK}^œ-<·:poø¢Ç°˜Þe‘‘±RjkŠ#º ý y㫨9"âæýû#çq_þÑY?ŸC‰wq3«ˆ:˜ýÉhBÓË™?»²7lñ?—¼QQ™á‚d·à|úÝîóKwÇÆ… h]:#¬Íðdˆ_ZBüF‚ ‡,äúîä÷“Ä™ Zendstream endobj 4551 0 obj<>/XObject<<>>>>>>endobj 4552 0 obj<>stream x…V]oÛ6}ϯ¸PTYcʼnëv]€.]¶>téV}1`0e±‘D¤âEÿûÎ¥D¹r².ýˆ-‘¼çž{îáýçhBcü™ÐlΓòè×åÑ8ãaÿŸÙÐÙõ9Mƴ̰vþ Rÿ’èmárÝlrr¹´’îT•ZÒÕZUNK‰¨èVR-Œ•)‰*%#kƒµxÒíŽ7Ò§Ïï'·«%Ùu²<¥Ln©Õ¦I¥N›BZº«ô–rüsúdùåhL£Éh¢Ç’O*)mðA“*ëB–"œÒ¥*ˤ‘U‚S2£K²{„I骇ÓßR¤ŒYÉçŸ]Ï»¼#¬7ºÚ»öyà#"‘Þ+N !]Ù¦pÈ‘Ÿ ÄÂcùàPm“ä$¬Ïúx‰ÔßV•H¬½zñ‚>ˆªÅ1eÚ­e¢2•P*P…»ƒ¦çœóç\V=t_Êò¶O¶©kmpè©ÔƒîEvJµÉ²®¥0 E´‘DÁIªjC…ºc2•}Ýf;¦E<ãòOÁøtÏfø–F———Tcƒ#ù ˜îøúæ&$Ë*‰ÖY6N/ÎÅbÜý¬ËõÍ홸õ:[§º¹-døÕýìG„Aà{äÌâùü%Ÿÿ¾ò0¡1+ÛLs@IA[‰lRµQÎîåæ©€"”‘Ð)«/гÍŠ£,5E(Zi¢ª›¼¨Á.|¥ÀU“¸¦UJ¯DH­ÔÖQ)’\Uò f,óç¨=„>Jr™ [6¨[ý*[rdQXTRa¡JŪØr·Úøµ[åò®ÐµéOmÖ®k#£ râNÊšœÉ] Õ7 ’VU.B$²=¿ÃÐpâz+ï¥9¥JCK ¥CLƒFrW}¯R`dµ¶òÛ£j ÷Š&ç1ôÊÖ1š.øcÍcHøS)Œë—{cе4Âi3º\E«“aåyûy¼Xte·º”¾ À°1¢´§¤½°|ó€P3B»‹-é» Nƒâ7ê  ±ûaGI!¬å´—Ð<§È§;U‚ÆTWC;P)§KLÂÙk³CÙ+øÛ­"#;Ë34]µYE—*¸ØGÈ]­_Æ‘Ê "ò.)`%è1¤ÒÂà€F –rK,ý—Q4:蟈Ç”£óo%XÒ(t¡Ñ5iG€§ƒÃã@HϰSÀ¹ ’H=5¤ñÆ´8bºFJüØ/ÎÎÚ¢‡ ñ†r|ÓbX^¶kÚ}¡¯!o¿œð³¤ŸÚŠÊŸïj˜‹J<"îÎ~½×ŽZE¼y݉P®"þú•â8¦oƒ³º8»VŸO`áuF‚3`â÷OF¼A´o!˜º´Ý˜TUúò´ ·D]k½~y`ú/سB”=5÷Ê8ÝkÍ P´:y¼êÿázŠû*·2Ôl3w_×7!KÈI‡˜}þWF²ð}ÿËà…ƒ3ñýw'×øÀȸø®6Aû¨«¨Â¼žEÞ}˜y([霑m6¿!ïË?†çIMõºß´Šqö$P­f«èø~¡géjUc$]>Ââ¬ðüÉb=‚|Åw»Dèé!âïÌ7„_è„ÙH·ÄžòóëÏBËútÌcr}9÷3äÁþ÷Ôãžà»”'G†“ćv´äÅãy<›â6‡3MÆ~ôÛò诣$Ôendstream endobj 4553 0 obj<>/XObject<<>>>>>>endobj 4554 0 obj<>stream x¥W]oÛ6}ϯ¸/œ5Vl'uÒËC·fíÀ P 0PÐe³•H—¤’Cÿûνȉ séËûqι×_¦4Áß”Îæü.Û£77G“b‚›»¿¢ÓësšNè¦ÆÞù+|©d_Ê‘òš¢W6lðÍÆfK­ÚltEÑQ\kª]Ó¸;cWÇ7ŸN¯'tYœ±¥Ù„ƳYqv†«j´Õ…Ûh¯¢óã«Åhq¼8_ÝÿÂa#~hÓRyÞ/[‹ý³b>¿àG?®µ¥•¶||¡;ÏNúpB>¾ÿØcÝvŠˆhmÕ-£qV5&ns<ú>"LlP‘ Þ6.³ltA7Ž*ŽÚÀîNÔ·Úç°sþÆÓ;4 6mÊI±UmK×Ù¨=Ri,)*²¿s_‰¼Ž·œñíF“²uÑÀ9ÔǬw£ žTYj8ŠÂùŸTD–]Äî–âu¶Ò¾ÙrÆÜò³.cA×x\ß«vÓhÉiäU®´Zº[M¥«4m¼«:ñpjc¾¤¬¾Î y©½vîÓý§•Ž‹¾ÒÏõâ˜þ¨š#^~‚”oƒí·ÎT½Õð`õit«šN?wÀÎ2ýš6 ±xàãa¯³ÑǘÝÁ[LDðÍZ‡GUŒ ùTZåãxãŠö(DeK,ÀŒ_u-ÀzB(*¡’ºÆ?¯3pSwJp½R|%˜È0Oå~ÀÖr›ëö#@.è×QX»®©¨„@Ô]…(]ËjÁ¨ÄÄÜq¸oD:Œ‘°3&<‚åZm8ÒŶˆPShÌj ÝÉ%(W¦–Xãâ¸èfçÌ;¤ÔªX衯0¹>ñ ¬ÝR0­i”ç|üöâÅî·ˆ ôDP=ßÙå¿¶ðÞ~ßWWWTQ-Ê÷ 8aåÊŽ‹Æñ†gdÖÅý`e2¸CE£ý¾>¤CRˆ”{×­Öû¨Ú—ÈŠÒ4Ôj$ bèUЦ–H‚[.-uv5 N’!hçîðä:Z²QÓ÷e‚Ë2mlÙtÄFY4ŸÞ‡Á¡YïdìZ{#t)è»c­>aØR€ÕÐO²]»ì ‹"“¾¤Öè›ã„­?µlºUÞ(•‘b¨¦®¡fDø[Ð[œ#-ÊYH}‰Ïè»=WœUD™oö­‹ìèx'áý ‚ùÓëéeŸÇñE1¥$ò‹:bÊrî7¼Ø‡ð>éþPV¤óÈùÌÊ'=–.®áZm,KR ˜Ð&r"r7 ªÕdñ!yŽÒ<<õh¾´†˜m¼.uÅÒµGDSsq­Ðy¤gsûIј4R0,ÑÞ²é–)¥¢;EFŸº"íÍ!ßr+ÀŒIIß@+~Ä"ÛÆ+'@,ñ iÃé —¦ túAz£DI=ûGú}ÎHÏ*øúúµ¨Ëƒ™QOÀ–«¼÷ēͩÜ2šìm…ñt'Ãk”° ¬þOËHÍžåçq~~ÉeyèãÙeñ ÓÎ…¨°ìp×”‰J­wýIßc¦“ö´×`S©ûö$œ­U 8§A#´j Ƹ‰œÒ!¼w¤âvüå}i…Ç4¾zB·GjÅÐo;ôÈ ô7j|È<‹Q _x)ÖPÔž)w xf»Q—kk¾všE¥ÄÜ'sæž3ÈIÀÔÇ4äpœÿ"C®$éù>p Сi‰¡³©œÿ“YYM¬ ¸ÍíÙßï¢ùYbÈ”:!7s ¯ÓSz/U94aZ&QÈéåyñòì%Í/&ù' 'r<+&ô»+eŒÂ/gÙ ~[¤Ýã‹DÉyðG±,åIû‡4æG_NæÅÙ ?£ÐédÆ·ÞÞý}ô+X$éendstream endobj 4555 0 obj<>/XObject<<>>>>>>endobj 4556 0 obj<>stream x¥U]oÛF|ׯ À$&EŠ–¢(°Ù­Š¾´h" /„y´Î ïXi7pœßÞ½;Ri9è‡eÂ}ìÎÎÎÎý9ŠÒ'B<3ÿI1ºZ ¤ÅÃWuƒñ*Ä<ˆ±Î0 1û³Ù{¬S{*Ä:ñ’œi+VááÍúvÂh=õÊf—‹dÑ[°R oUÉ+V«Ê¿Üx›7‡g‚ è-=ÚãÕ9Lè >Añ'q Å[æ5¯$«ÅÏ¿žá«j0 Q”ªªQï9Rž )j¡$TÛÔå‚y„È­tá=d•*À yÉ'G&rŽF y3¼üÚe°ðÇ«i›Â =7œü¦jnyªÅ×=—”Ìñh‘r=LÓ'líÌÖØ¨5Ï3ûŠ•%OÁ4Å/x½Wé0ðv›òŠgÛ­iÄ n@ͪÀÿbE™w°ÕàO&A“6R/Ã…é¬ B=>þ{…Ï«j¿TBR›LŠ'‰Ð­,èAh¯¾Â'vöŽkGWŸé`väÄp’âµB*4ÛQô1"ìøžÝ UQ‡ùŸ×âFªŠ˜A­à6†çŸPþ?BÛ¼f®‹§ í ü›Ú-ý*uSÚ©¸'Md¢Ò5Xš’D„Äç/¿þâGADç­~?€~’p32 27?SoL¦¸~÷$’ŽL8ÕPoS¨Ý-Oj ßìIßÈ8«›!v ‚ùÜÄ[JE=© E!rr‘ >ÂcrˆMÃLchp_ÌàZI-HÊÈþ©dݼ}ºþ}w‹uã±±œ\:1¥Ø2<Ù3)tÑS3´¥sK‡OùšÙNyþ£mº¹µiŽï“ÛO§ýôNTuÃr|·…Øù»@Ø9ª»é€µ ¨ I]@‘K}"#JÓ—>¶wŽ£Ú&Û´.îs*){†×« ß¾ÓáÖÈ?žC3¦@Äqrâz/tW{g:³iñj?Þ}´czðs¥=Þƒ5 ÜìB¹Wˆ‚ĶN?K,à4Ô‡}º[Ëã¶v,2ç}'^=ãg‰·[ÖÝü‘V®6eDñ[¶ñ̯‡çÌ0ÿ²ÕÊÇáfGH§€ïòÅ iœ3^ÍÛç1šŸÓxŠÙœžôȾ'Ö‹&AˆŸTÒ˜!¤×]I£?²{wÚïüï~4 gA>/XObject<<>>>>/Annots 1521 0 R>>endobj 4558 0 obj<>stream xWÛnÛF}÷W 䔉ÖÅ–)à¸u—MäÅ@±"WÖ¦ÔRáŲPäß{fv—­8©m&gwöìÌ™3£¯GcáwLÓÿ%ë£Q<Âþóǧ÷GçÓ‹ø¿Â3­é|vÏüSF¯â1]^ˆ ¦ ÷?[Ú§5½ºŒ/[Ë»ùÞ1rVqOg·#ºŠ§4_ÒdD37›]Ò<0#š'ýooNç_ŽF4„}žö­h­Œ½ëßÒ¿Þ4Ñ5½PDoÉê-]óŠ7ä~ÎÎ讟䵭^ÓèîôÉ65üµÐËýõ¼ {",´Ò…nŒÑ;z±ûsßÝõ•;øY“ÆAn–p?¦—ÈÉÛ·ûÁÕÜ!“'‡<{Äôà¢TgºÒ´˜„¨„+Ö—Т®Èæ•_—¶>Äû­““Öõ¸qÝÄïgÎÛh†` ²©›U±²é!̧‰g·çÄŽ—B ádê Öÿ`©ZiÒj½É4©Eþ ò*ºŽ(ÉTY’±e¥l¢…¦$Ålø•°I§”/¾è¤Ðve’%ÊF-tƒN Sª0ÙŽJÃMEpU®T¡Ó@Ä S{¡«­Ö–óZR´GrÛh1‰bbhØœêÂ<àìe‘¯I±“³Û™¿fŸ>5o˜ñX÷Q0ºu!}Š>ÝÀè†ã°Ö¶*% ¸é™ ¶IM¾ŽCÆÏê<§Jg¨÷ÏÞcµª‚3Áª`1p`J05‡*z.€å€êRËÉ=¬é‰£žè‘œÝ•(hG©UUºìšƒ´ôcš¯4|âX~,qVY™“zP&S Î|)þY‰Qú'àÀûZõ”{×.Œß]>ÀmË Øde»˜nó"ðíuðÒŠßp2‰§SHaÚ?Yçi hžœ½¨\7©ç…»¾Ä ÒA$‰¥Þ/ÕÊ”­¶õ:~öö¹(cgwŸ¼–" ;Þ€ÆYjê Ùpk¾~jòØÛˆ²¨ïÕäV„–Ë2Éáƒ{+ ¯iòO[Æ¡èô£Nj&[†äDÕ¹îÀ΂Ò\—ÜÙôã&3‰©Ð͸À˜ˆ|.À5:ª…¼h„3À±³Úc#?Ѝèî4¦(­Â…*õJ-h—(ŠNEºò6öþ=`$è2¡öáy)+;7`A6Ë]ãÂ5¹y1¡%À+ªv§´7ÔzZ'Ý>"¥¿ÖæAeh› —± Š:Ô+rO‰¹ó‰‚÷žhj+òT^ÔóA•#ëŸÍ(†§Û¼HÑjÛ‹ÉÀ'j‚fÈJxT&ºù?4“³ ªJŒT¶U;Œ,WÄ¶²Ÿâex_b=¯Ýðá¤5Œ_MÃs³8)~‚H¼wíÖ]ØŒnˆ*ͽu665 $‘sÈœ¯Tq¯+Ê”½¯Õ½/ܳ\åuÖƒ£”o­.ʕٰvó&'%pè Äô¤ng(Ð$·_j‹¹ ·]µò„ƒLR+˜Ý¹~h‰V˜'ÑÒx‡ÁÈ @*M »ów¤×>/XObject<<>>>>>>endobj 4560 0 obj<>stream x•VßoÛ6~÷_qh1T bY–Äu±)6yÖbö⚤"&’è‘Rlcèÿ¾;R’#'nã$l‘üŽwßwßéßÞ"üÂhJ<ï}^ö¢0‡í?sƒE³pË⦇átz KávE°äÁ-\Þ./µÙ¯‚Õüw±|èEÐ⪌,+S@!·pK>uÖ¿Ó·Áb ´=>éÇ£:H°L%ø xS·!hbuÏT/•Æ@z x yÅSÈÔ£œe”ÊW‘¸.li*ʶªL1»‘¼¤ó¹Ì1OHY!2UÜÏ›ËJÔãp4‚‰€Á¯Ð\וÞÃ_ÿÜ}AÈ>° *I°¿`uôú‚¬®«¢œÃpuAèm%åN•ðì罃PÑ2ɬW¼*xJ[ P…K\ÈC^†m6Ò¢E>Ú`ñ†ãp|àbFŽð`ÆSøÛbÖ $ϘaTn X J£JVpÙTÄÓElŽÃÙŒÊQÑÙãbw¡Œ«sYª\Z¨0#*•-‘S.­­IXKcA'°Æ´/c­´!,1¹cù&“?fÆÀíúH­›j)îζu÷W±tÐÇÝ 7²Fc®>ÀgfÞ@hŒ-ëõ—·EÁ4(Ðüí)­«æó97püÐéùœý®õŽêà7!l½©#Q_*žâm.}­\/r"›“ÍGªEu׌^½Ö¼?×TÎЄJi$÷„Âq²Eñh|i&Pj]å>¦-ƒ ÐÊT‹ZŽŠ8KŒÎë3êIЦ&q«„3¤Y³y™4‚ò>šôoü…F¨¼Öøó1„»âI?bÇ´Ü9‘ùÇ!œ0ŽZbW×à)w©Ì2ýÎø¼@ÈÎÐNk Ô]s’rç2¯2Vb:Äe9¸öv–©rÛTÀDÿA/Úz'ëvÿ¨öºr«ˆƒ*âZH2¯{¤¯ðbʵ¨¿­6¶Cš37:ˆ®22¤!ðc_¹¹¹•o´)Õ6°Îh9Á¡P+:ô…¢Ñðr[ØÒ}zˆ<¹Ú2D;hŒ¿:aÞ@œÀ2«a-[KƆ.îq®zKv„à>/XObject<<>>>>/Annots 1523 0 R>>endobj 4562 0 obj<>stream x­WQoÛ6~÷¯8 (欶bËŽãdoé–¢/Öè‹–(‹«$ª$eÇöß÷)¹–l)°´,ùx¼ûî»»/_Sšàß”f þŸ”ƒI4Áþ5å_ß fñ$ZÒÍUtM%ÍæËh ú48zÄwË›èæÛwwGμG³¡Ëû9M'ôáÖÅ >¤þ2|H†ŸsYÑÅÃË{Üî†UÕ&¼ë)•I!ŒpJW–„‘ÔX™’°ds½«HUäri%ÉGQÖ…´£þ‰Ìè’-h-`WÖÊà'ѵ‚'U9í RiÔV¦|ÿ„ÆÓá½=‰*¥u óJ›RÅ>"ŸAp2jEj¤ˆMT{ª®¥q ÷º\8*Õ&w”‹-‚’@A8'’¾}þ§ ¼6²¥J«‹-f‰r­6r®ò£µÐ"å/xtÖFn%šª·Ëýf^K¶éf-ak¼€>žÝÂÿw>´Ûs5äÞù½ÐÕfuÁC) †Õ0¼éwa¨Œ^Z¬ƒN1öuàkÚjµ7úb~ô«=åI{ˆ¯ã¼'ÑÿÊ©§õ ¥ÑꢉOã‰.ðƒ²gù,©MzDªšÎ#¬û m³„ O~N‡‹(¾¦Òbw²-P£ã!wÚØuªwèïÍÓ®èÀ[!’HÓS©Y´>rß@¼}óa”5d®'Å[Ì\Ùër¤a4„â7yà žv¼8Ópjg5ô©…r#'Á/TJJ¦yW/?WuÍÚzuº ^Fâ-l¡p¹3P‹ªd…S(è6¯Å×FR­Ai€f½‹`'„MÖІüè…űKز#¨xåŒâ’3j+ŒØš£,üYщ$‘Ö*^¥eï„aUT@Â4Pa€Ú ªãëŒhuœ¯wßâm|YÃrØ kVü‰É…Ԛʩ‚Ó¨ÅP,Fö ¼ØF7U 5l ½ð …Ä€ƒ Ë*×x‰çåîå}7{ãÉ<ºš]Ñb1bÏjŽnGúY'M‰êqñ°c‚ñø:¨¦gºåj²ˆf1þüBL' >úËÃà·Á?ƒ91Pendstream endobj 4563 0 obj<>/XObject<<>>>>/Annots 1525 0 R>>endobj 4564 0 obj<>stream x½WÛnÛF}×W R¸•›ÖÅ–/EÜÄ ´Nk ð‹`E.¥­I.½\Z‚ü{ÏÌ’¶(_о$d‘»;;sæÌ™ñ}oHü i<áÿqÞD¼á!\}ê £!£å4íGGÍSF×½õg¬î¢ãµÕß§kŪ›ÓÞù> 4Mqóä_¹_âþ…§ÜÌžfšJ[Uf–iò–ê ÏÊy£2Š3UUdŠÔº\yc RÙÔë‚V¶¦XáEëÒ“_(þÐTèÊë¤=YQa=ÞéD';¤«Rǰ›­È¤d<™j{úOo@»Ã|ëó^ûZvÀW“*V”k¿°I%—²1JÍå:¯Ü\{ÊT1¯Õ\Gt‘«¹)´lUNÓÒ©²4Å\v§6Ëì’ŸøÞ½s@/èô?×^»ð®E¬ßİ\˜xÑq3¶…W¦¨Hu£Ý°yQÏlF4FZU0Á%qÌRbùÚ!\še¦HH¯$ éR¹"DŒ¯o.>Ñ\ôòºÚ!ë¨2y H«º,®ºÒºu™ #À=Eã1ž’þOM†ðoûlûæôêòË_§W×g_.Oÿ<ûøåòìzŠ_þ8½¾¾Ý&AêäD‚ûµ&a*EÖé[ ˜¬”5bŠÅε¼£^1´±Ÿðïå3¼EQÇ:Ñ÷Ö‘Öt0 bÈ—ÛþíöæŽk¦z³)E>äágè>?²yo¸õ©ÄvÙq4™2—Ö#ƒ\àz›ƒ†nrQx·F7TjQx2Ó-Õ} #«Rïª:óO¤·UñÉOSë*¢s0BU áêgE™XÝåH[¢\ýp vÔz½ÆvhV{©}l¶3.ì~0 Ü …ŠÅ,ÛOp ‘°¬§f‡Æ†šÙ½Ã‹úÀ†œæ2á UlX‚ðZ+!VXPÎÖÔ¦½¾ym „÷‚+O$¸Ý~Ù•–n£}Îëñ€Ûæšr }Ñ)Ä1HŸxŒj„€‰V²o€ÕéJ"‡–L…úÞÐŽf¯ðÐÕ1ãÏ»„ ­Øu±è å vfî´¦E Ú[ì®ëqD§UUç¬%KM õÀ}–›7´å˜Z%0ÑÐokËÞcY×èQC¨X ë`ŠÛ,Ö‘¦ôeýFˆÛ ï½í?àë·ï-Ü\ý‘ùI™"YO- Žk—ªïå¥uwP !¿¤u=ó`Fn¼Ð²¢Ù U)1MWÙhÚ¬=4Ïì¬@Ñ i1‘v âËE±ÍKxà„±/*8ÂþïÄHwøéÌ*< Ž1² ÚRhQ2K35ïžkgœ>·N•UAÝבñÔ`p´ñ°í—IPNí J–¿¹'‡Ad·¹¹GøÎ¶¹:£†ù¢LbfMî FR¤Ü@!<6tiÏB䯓 ÆŸ…Jd>šif.Q/ÈC–‰äð|òbÓn ë¤úÈ´‰жr›Ô DÓšµÐ¥qö*$#í­Iz[ n D™:Y dç:˜Tûº ==¢Ïæ9#Q1HR Kc«¨¡_‡ÁAÊñÙ ðÚðj]ÿ¯ª~¬é€ÍÖ&Sߘv¶º#ÎO¦ˆ³:Ñô®Q»wˆ¶ºj²õÚîÇÝè_ Î©µø,H"bî_¦¸{œdLÿ6u¥0°°Kyž–;ž YlÇ™øNˆüáýû¶54OˆGû ±ýyÔÒ†!Ìþn7àà Hw¿ ¸]%¸ì5ƒøðh?:п› •ƒßá/¢6®s8!*Æ1aà »w‘&Ñè.×þ ƒÎÁ`GAO†ƒC>z6íýÝû¾endstream endobj 4565 0 obj<>/XObject<<>>>>>>endobj 4566 0 obj<>stream x•W]oÛF|÷¯X (¢4-ËqR €›Æm^â5пœÈ£t1É“G+BÑÿÞ™=R6•¤ù0d‘ܛݙ]ÞË åäœÿòúàÇ›ƒY6×»a)GW§r<“›÷ž¿Æ‡B¯ãC>¹YY)ü¦i]a%z‰+׊Y¯ƒ7ùJøYj¬ä¾^Wö³¸&ÚPšÜJé*+¦)de\³äõÁeü—¸ñRØÒ5.:ß´âKyqóéàè `ÈäCÓØ¾ÀMqº•`M%¾Ñؼa&Óã90Ox‘ß3>>î!‰+å÷?>ü,kZÛfò‹ßØRÔn­"!½ÑT•©m\ù¢=z0Á™EeÛ!zcÛh É+Ó¢ÁŽ˜ã*Þ.eðµŠ&,m”Ê4ËÎ,ž•C?oû8yi‘³aX× º)X—ˆ|£Ö9OEˆFüÚÜwhÍvm3a·4èN™ãæ…Ø¡ËyÌ·Ñ¡mkd¦PÐ8Ól¥/…˜<·ë¯"Êä²j½4>Ë6Œ€øà–®AûVHΆD$®)¤kj_¸ÒÙ"뛟²±W|¦Ú{¡ŒAE&¤O­#^-ìÆ‡;|‡4€·Ö¶‰â»8®àS ö¬1yìvÛÃ|¤«ÙŠ­ïØsÑ“ׄ½eºµ"'/²*jzÎçÙÉ ~+&GGrEY‰ ÙjˆNÉMR—®yEþ]Yw‹ÊåoFß=seøÊèÑéù¤Ú $øóµ`ü^$ˆ²SƒÅDä¯F¡ŸY”¿}õåSé™GK™jN²óóW zCÿxÒíJ¨Ì¬k4s³²Mj àèÉÆÅÕ¨P#˜]ÞU&lec«ŠÀíJýÔµ‘‘ tׯ¸šE°­QJ@»®eÏs ? î€S7¤’é¥Ý?î i`qM¶öòŒ^§N Xi\¨z€Dqtu¶3Üiâø;Ðd^¸ÊÅ­|„„´ßuœ(–éqv’ÎÔW­ •`xX«.Z¸T-.h÷=5Á{,~‚²³W)á4iMÙàñG?Ê}1V2Ê×Ujê!¬…ñÔŸ÷ÈT³m{ɦ>>5Ï žåe¶Ûô¾µUêÔÁïø † •”2y-ǧƒsl:¿àÇbržÍ/äRÁA-ÁÀÌ‚F >8EσÍ#p·ãj0ÂivqÁ—DNj:€Me™±’òÝË—´Ýe05ò]w9JÖ¾mçÖV³Y9ŒÏ¯ôHa¡Läô¤/¹€°•ÉïF¥@œ`}yûppÚ#ãŽ&T‡(+P îŽV¹Ä,†BöîD÷ÿén ÄV§Œ¦;XFbñe…«Ýr•tsµ²‚’Ô„µÒÁ£˜Sž»™ÿÕÜQ,9vÑgŽ:i·˜µÕE3V6k ¤*›±öiÝe°°á²§A°Ôkö$.¦ ¯N±¸ÜQ[1‘âÆdó¨¦mm€Ò¾`Ò°#ìÍ|zS×"Qó8ÿz0,ŠÿR˜ØŸÀa$ÊÙÛ€Ólên\£e×äºherþØÏ†ËšÎSn=A‰XúªòÒ–jG#” xoHßméÔk…"ßÃXýíäöÅx€Þì©ÍM(è<¨Ø®Æÿ—)öÑoöª·°\sQ\_‰{ÜãÐ#¿n!‹†kBW ¾þ2¾}û6Uh‡~þ™\ß™í&ïN\\|oÜî©{;¨–W ²-HÏõ‰[&ìž…¦º¦I]‡XÏ>“¼ë€}Õx°móÀÕ¡Ë / œpºnÔñ#ØûÎ<Œ4}Žf»ßÉt‡®™FW§M·7* Χ»Xé`»Vä˜ÇرSÎ èϱ6BÁ[ó·3xÖÆ>‡I6|'€FQð p^ ! ¬¶·/Æ–²ð1bχ­B7ý„þ¸žô³cç(ô&P0•Pß´¾ÜGjù¦7•àUÙ™\Ó©:¼·êòY»å*­0Í¢%F*«¤u`"Îð_‰+wo`Iæ`='_ÂlÓÁhªÏÈOn ãPúI{ѯ/óÙivvr&Xî8f!`âžÎ³™üäónÄ03Ý<}•öËÿ5™ÏfçÙɃgÏ.˜óû›ƒßþM_Ç>endstream endobj 4567 0 obj<>/XObject<<>>>>>>endobj 4568 0 obj<>stream xP;oÂ0Üó+N,PÑ'$iû€Š¡CK$f7q-±SÇâß÷3PæÊ–e[w÷ÝÝOÓŠ°Ìü.ûà©8ãôy;LƒÅf…(a ŠšÐYž² EuÆpå,cñ ûV «ÑhÔÚ ×ôì]{a;­îН`±IÅË„qÂòœtfÛ'í¦?1 j0JÓi7ây>G©+yï軦µ8 eýœ¡+¿áB 'è“¢•xTJ[aeu&Èšl©RâM('|ž°>ºBUÞ9‰bocg ´Æ EKÚ–ÍM¢Ò¥ë%M?J¸ñÖu•$ m½ƒÝ~û:½ØÝ0hcÙ%w~Íó„¥ËYÄâsxÏcÆñr¿•þaÃßYõÿšSž±eL)â+ï`]ïÁ/n¹‘zendstream endobj 4569 0 obj<>/XObject<<>>>>/Annots 1540 0 R>>endobj 4570 0 obj<>stream xµXÛrÛF}×WtÉå]º"ÂàÜ·c9~p’µ™äEU[#`(ÎÀ ¸ˆf¥òï{º—Iśݕ¬¢Õìé{Ÿî~½šPˆš-ù7J¯Â Ä7ü1áï®fË ¤åbÌ(¥Å$X6DBŸ®<2¥M¬<ž“›Ï=9!z¹†·ž³ÎŽçäfS‘[Ï‚)-…`9Li2[°ÁŽé§¡.§Á„–B° GB0\kéõ”…ÁžD„sNEǹŦÉÌÎ8B"ìÉ”–DØó<:gð¥çy$‡¿g:ƒÈ—bÃ.„`ƒÉnàiÏôipQ¶…Ç]Mù0>Yídºf½B±^ŸfÝYáz4¸KnOÖ£Á]p=Ü5çÑ“õhp‘e¤°÷Ê£Sš†Ü&=×§Áœp=š¹›Ï> .Ç×ìR…°¼T 奪åºÔô\F@ N÷¢çz4¸0;àz4s¥ŸzY怤1:®kš¹ëîõŠƒ‚=öH¨ ˆ=Ó§Á…µujñÉ™@%ç´‚Õz$§ŒšžéÓà"n´['êÔB„ÕÊxYÁj=&×ÜÃÏ#»Óñ<ejôLŸwµbw:Ñù|lЛ¤-¥ùz ÅŽb‡|Þ†Œùž‹)*¥bIm üzë Z™¶Å½¾…¥ßî0“—°µšÒ6–iÒ6­è‡Bç…tYšìáÕö_ž×¢âøŽúxŠL,–Ð2º5‰&“EI]› e{&ëFxÌy€šxt7]®hxþÜŸOØÝÆPšÛ¢*‡bÿW3ol› ¡¨„ÞØ47‰bê-~PQaéíç\eÏœÂO?¿GbîY3¸ÙÊbz÷݈ªÒÕst¯˜ŽubRSéBÌrú:?ùò7 ‚€^þN¡kùóš†ÒÒ]ý‡@¡oç 8³¶¡áÚÒçÍïÿ³ ãÙ,W4ÿ9¤!S@ZŸ%[H:·Ç\§*Îþdô³‡ònÁ¶­«¼®žzÛ½¦º(š8_T‘±±)tT™Gý_…üú¶•c\z6˜–RAŸLÊX—dª’ì!#íUé˜Ñ­4dwTÁ­7ƒTÄ®’SÖ¹ÌB9]V@œ*âá‘“0Z08S:º:TÔ‰.úÖ4¹!EYÞkÔ`G©ÍÎD2KiˆÆéTgˆb¯5ÝkAi¬ÙSSR´W9ð‡F.£ÂÜ#àÒ¦ZJÙºá-õPÀgdeͱeeq%ƒ¼ Î÷MŸîS¬×ÜÄ[ë¶R¬á±EF Ú¹UUYD×.îT¤o¨†œvg;UVÝèeS/÷u[ÖQß ”˜_XÒ”kEùF¿§ì ®[3Pq§ˆ®sk2˜ ÌõPéXfÁk?f¬ùæÔ¡—:;÷”ã]ÿií]F,ÚîFÜ“$„lQ¡«bɈd }YÖ÷¥þµFÉO}zÊV¬£D®mî^Ia‘7‰ÑÎ…ÞÙšŠÐ0l5Ó|QÅ‘P#®Hãíø¡Fo3ÙIÝÊV©CØ×GôÛNÕIus©˜O䎭›‡ ¾ÄTg€AIG[µƒ©ö—ÔïT’ +9"›óÁ¶ÐªDú«³Âó¥*T{É`Ñ.+]uàRµW•8bwØ¡Ûì¯Ò/½‹ UH”T­P91lèCho´Äœ¯n0ì5ÀYPy,+’£˜UýÙ$Y¸Âewé}ŒÓŒýì2Å_Ü/ ¾46GQOåû¥C§¹î†\@·È±þ¬Ò<Ñ_B£¨¢ëµ_¢ ÞºÈ-ú#Ë™÷ÄE§¸~–"›$Ø#é¢R(†ÉЩ‚v…M»\ §QKìÞ¦Nî Î 6"©¨ªÑsÃr=èL3ÔP~•逖ÈQîÈòDþTë¾qw:Ú^»Øñ@OXŒ<g“…e'e¸{Eª¤ƒÆüÀÿo¾úŠ ©,QoîãAg¥æa_aa0Âc>}¯J=n3Näï¡3Èg<±¶xFü™š¨¤ÄZŠ1{Ëå¾tÞTvàj“U®jï±ì°j+ÛìkLKU!,J·Fe¢TF*~tû½²¹‰ð `YvkQ0ÊÂ.B±?|Y†+çèg[üÂÅå&¸øÁÙеOD£vç$·4 ¼¾íúxÜdå|–uø¢ Õ-»é³CsÛ¡Ou=5g1‹0{ä΀$:ƒ¸sH²ü¦ØÕ ™Ì>™w'EA- ` íØÉäy­t 8Ú²AÎe|aÊÍðøä#á .é½E7©B®µpÛd@ÐýÑõ— Ó]  šßJ áÿÇã] MOÿü=9¨#ƒÐŒþ=`ÎK° @^Z°æ÷~øþãöí7—ôsI¥ëtÍý$ÐàZØ­¾t6þùÓÛŸÞÿÝ%ßbÅaP›o(îF÷&Ãêó ydòׯÍí=²o¶-Ii2nú»—2rõ\áfÂWÏ ïƒxµ=›ºçÜÉ$dñ·Û«\ýr«cÞendstream endobj 4571 0 obj<>/XObject<<>>>>>>endobj 4572 0 obj<>stream xW]SâH}÷WÜ6ÖH$ àìFPf@\‰³ÎUl›45Ig:‰†ùõ{o‡ !ͺ*’JnŸ>÷ëÜÎÏ# ZøkA§KnxtéµÌÞÜý“+8¶àÂ쀳„v º_,³Ûíã)«8®ü$™»–@+oY­ŽeÁÜp…”<‰EäùÑ R³?G×MË옖5?6ŽZÐÄýÏ Gýñxp}?µÇš­®øÒ¸¯kA–`?øJ °Ç[$k‡d‡# ˆº¥A"ó:ÆÍÈþ6¸ÕÂè0 ó:Ìx4»Ó‚è`ȼ2»éß@Ñ4j×£ñàÿÓ¸Îü€×@¾ö¿÷`è|ùÊ^X cüpB‡1Îê“éÕøßÑ2ÑDc"¼,`ÍNÊ䯙}3˜hâÃù•¸kòrßÞÔîOtµK 4xS—…Äé×R:’²—z¦î÷‡˜è¨ÜqYgrws âôî yÍ™»Ñ·®h¹óŸ5®üpn¦ú6Ôº²I×"ª1¹/³¦ùÖäæ¾ðpùC³VÝÒdO›Ælðx0¤ŒY“ç1*hâ‹(©9Z,(jÀ·žáǃåªMš‹ÓáÔ.•v7Ûí¬0F0ÏóS¤{¢´<¥Ú ¤kKâ•„;á)ˆ%$)‹<&=°OíÏŸ!d®ÉïÅï§Q³Ý6;œMž±XŒG·ƒÅâP"ì 'N”B€³¢,|â²·Åbˆ2øñú%ªD,¬Vãb1s®ìë˨ã¤óqæ¹,åпÀÞ#áÆA–ÐGëG £F]ÓÅЈ˜bŠc{$ årÉ\ 6:€Ë"„x–R É&|ABƒ:â.–“šÌîšE+®òôÊ6H­O=ÂëÔO`Å#.Ñ/„¤u¡Ÿ«L—¶)Kž/¹›ú/ÈàÕO×`ƒ+>/XObject<<>>>>>>endobj 4574 0 obj<>stream x­WkoÛFüî_±ˆaTN$F[–[´€“ØŽ¦GiPT…r"OÖ%äsw´¬ýï=’’¨8N¶‘\Þ¾ff×÷zÔÅOCþ³½gã½nÔÅÍõ‡½¡§°éÒxÎFÃS|K‚¾Ä­wwïÇï÷ž^U6]êôú0i]Í©|R¿ÝºkZ¶H9ä¼Uú†\a­)t"š­(1Å,•ô±0^º6.I¿€]D?û…´Kåd›|a5)íÍæ˜T}»~÷wG4^Àwp¯î8/t"lÂñ­ãýöê’ä—Ú)££2öÞ¨J³sõ¨ĉNúÓÊå)õŽ"ÜœS§?ŠN©sÜçˤuS8𕈭qÍBÀeÿ(Ø0åÖܪD¢:š¤^£*¿I±ÈÅL¥Ê¯h©ü‚PŒÝt9WZ6}´pVò‰¥Ô Œw-eeìÕ­t]‹"ˆ,Oå·¥]—FÑ€SìsÜýh0ÀUÒª¼ÒÙõõÙï/ÏüåüzÒò«\¶µÈää_æÚ2|ZJ§‘þnÜfsz¬årJûûÄïѤ…þ’V^fnrHM{"²2€ tEa’‰45ñ¤åÔ_ÒÌË“ÃÇõß5<þÓ¸º5*¡D¦ÒËuõÉþ>ïs+% &‡² É ©éôë#Û ^ü%òî¾Ó«ÜüÁâχ|„È×>Üý>@.ð­HïóV»¡ïÙâ!gͪlPĈ n I¶éJû3kÅj Ã’õmzØ¿e¾‘>¿ÓDCp@þ¹U™°+Ê ›'É|"<Ÿaøé(ÙB©°7²$™ã#b“Ȉާm,`EÏáK‚œ±t¼Œ„:)ôб@‘–üˆƒñ¦FVC/m¦´ð’¤ˆÀø+àH{¥ á¡2/„1¬üÉdrØé0ÁKê‡@U0 ²”„ðùù\YçÉÄ14TB,î+Á¦I›b¶‚ª1+C…Åi63Úº\H QF°eš$,‚¿Ë!#2’rn¡ Â:è“_@¿oJEjŠå¶@‚¶U§Å6Î\(M l£XPz Qê$!†Xæžæh€–ÎÃ3¿¼Rµ•wë±ÔœAù3©½«³.å{Œn"ÛØ0n%ºù±Pñ‡  R8(¯àÓÔÒrOKìˆ óËoçJÓÍl£‚zÅ=a7ß@Õ“Û é¤çR@É‚æ'ÀÇÌ «ø UŸ*õT8“‚Ž2 œhå2 $´H8zþä !¿<å€\‘çÆB—ª±µ™KÌžQ=“†ôüô4¤uùÓ:¯gÝÆS§ " † ´­²Lámåb•HTÜlbÙú¯˜)û7_œ?{sy1iÍ3ߎ¢êE4íµ‡¾;ŸHkÛül:ýílzv}ùz:-efõÝxËè.Û6ÒXñ˜·µ¾)@¸¹; ‚Û]@qkPnžÍˆÄ„Qìr+(E(o0;ÇlE¸s\µ“ˆÔZûÁ•ó½>¡Ão¬ÉZñ¨¬PR¡cÇÛýº×„€>Ì%/cë¸u‘ÍÐY€¶Q•4 Ëý*¢—f)Á V Ò̱'®HÁæ46—PÔØd™NÛè#Æ­@ú;BË@`¥9÷Õ õ 6a÷úï[H”G ‰”a0*ΟÀ¥2@TaÒ}(c¦¹'‹Åµà·Òj3„v[¼¿¿ÓY°#„ËôðõµhÇŽ´§/¾j3ÀUqÔ8Íw®éú¿0”ã*šn³Ô>°”×ÑÖëtotŽix<ŒF§a¡äˆ;ý¨‹m ´ ’k .—Ö“r< ½ ëñ9(Æ Ûw‡Ñ ÿp°(ôz}¾u>Þûuï_#!Þ=endstream endobj 4575 0 obj<>/XObject<<>>>>/Annots 1542 0 R>>endobj 4576 0 obj<>stream xµVÛnã6}ÏW ’uWlŲÇiчÍu‹¶ñ¢/´DÙìJ¢–¢âAþ½gHßäxÓEmÃÐ…ž™9sf¾DÔÅ7¢þ€q~Ð »xÂÿý~ÇO(ê‡Êé4 Ï—7=\޶ֻMfJ'·gui”Âðà‰³‡‹8¸Òy. ûãñèσ“ÛÓ庀îíûŠ m /•‘Ù‚âL C3=§Ga”HTL¹ˆ®(WÓ™¥‰¤º’i‘Õ¤ +M*bI“Ze‰*¦!}Ôsù(M›ìL.H·>ñK ‘á«F—:Q •—™dt$¨¨ó‰4¤SzøãþŽ`Š­z”‰"qÆJ£U">>_¥_˜kœë¼VM2Isegtuqg‰ ½×†§>>Þ/“àqýÕHXeUÁwP"3•+øV5̽Óp8䣙¤r½S#f€˜é3½´é_†Üz¦Ö mìÁ¥4•Þf‹ .ijÖé –˜Âh*Ø Ãíýë|y¸eyRç"uÑl M4 ræ—®-2#Ÿ˜ q¦+DXÈ&™Ž¿²/þü`ÓÈAo“Ji¡kšÄ˯ÎÒbgªj{L]†}ö°Ç.öÂ~wIÐzæ×Læjp¤ÒD¦ôéææúËå/>6^‚h!fã`|LÍ}DŒª±ú¥qw$ ½ñ¨åVl ¡ãõÃÁàœ¡€¹ðÜ.lÅ\ä{Þr‹ŠtðËXøç›Šò¡bÚǺTˆ"SQ×–r *AuÁäe£x^âÕ8PˆyÍõC¨&­650>~‹1½=Œñ ·ùׄëùìXâ"²¹XTdê¢røŒaØÌQ–ÆªŠ ¥¸šå¡Í“‚-a¨t.­ÊÁ?eIUàp¥Œà²]Õ´àÍÌ ' ëpP)*Fit=í4U™ éE)ŸËËRø¾ÇD¸’`ƒ~M®G­š³Ÿz`ß’¸×7—ŸïV¸£ñŽ?%beÓqpxÿ>çšb[ãâp|üÓžÕ{È MB¿MÞËšŠ:³m_ösJ9¥F í>2ïz°)Œ€*+¬Sç­.KÞH'çsJÏ„õõ,ŠØÖîåÔ5 Çö•·.§sÃ42Ä™j3áSõôšrëdW^ÑÙÄvúûMñ­•çÿÌwk7\k séþ— oý÷Œ»ÒuY®¬Q¥ #mÄne¶vãÅ ýþ‘åz§›­CÏ”õ‚øwt¸¥@(=6>Z”2¥k£;Ž›XV©óB´l¬{÷¬¦0².KmxZ¨J+‘‘°ð{RsÿéÀÅžÚ©ò®÷snbη×: K¨T?»´1ÝøºÙêã¬ðÜ>WLgãkÅšÊBÔ{¼Ô»A„û&I ±>„µ  “F†‘ US»äð½WƒÃ òž¬Æ½"ºë$ž-µq'·ëfé*ñ«ädE~–øâfÂqpõáa„޼ºx§ ô³U(œ¶¬O'÷8¬¼G#~ýì¤ieâ5|[Öüô¹ ¬w÷;rN^ÄOn‡Ën Oóþ †hñnøàšéô0a_ë¸æáÓõe6‹YÀ¯îœûÁ„'p%™ÏwŸ>Ó 7‹ ]Üý¬;û= o˜¢¨ÏnF¿üÃu>endstream endobj 4577 0 obj<>/XObject<<>>>>>>endobj 4578 0 obj<>stream x­VmoÛ6þî_qhÀ)bE²Gi‘Ý–ÖbC…õK€–(‰Dj$ÇößwGJ¶¢8†Í1ŒH ùÜór'ý1‰ Ä¿+ú¦õä‡d!ÞÜýè.>„ Hr˜‡°ºŽ‚Õê ’Ì­ !I§€¦‹èæn*¤½;ûNïÎ’ï“f.ÉpÉ_t}ña t#‡ž5›/º³¦›’kÎŒ_3Ä›ÍçÁbèÙô$ã¹¾~ûôñ÷š¥ZÝM|ÿ5¹;ƒþŸ×B6­}‚|j· ¯YCµKµ®TzážOÒŸ¯£›'ç¹ú߯µEi¡à’kfùÑ’_ÒåE˜ÌŽøß5蘟õ¡’žùéqêÕVÙ¿¢þÂó»†h,÷IˆƒÐ¥jz\Ão‚o„, Ñ¼Ñ*åÆ( ªµ·{õ(CË Ž)?‹{5“[HU݈Šksî¼Ó6ÒÖƒ^\ÂéìÖßèS9¥½xF%M5V( VA&LS±-ØïºB תv×Ã*øVrÜËþÊl„MKZFm2'Â@kxÖÕ½URí³Än£YÓ ¹l,g™CÓÜ´QÌ-×ÏÊ‚’ЭÄ6å=ž”ˆèó¼vIÞU‚eäm¸á. (_·EAÆBIĵGW9:€ ü±aÒ x&ð:ìý&Ïb²>C¯ÉܵF‹éØ“ Ó’02¡yjÅï¦BïÑÐsJ×Þ^ª„üS²Ú:ÇôgM'Ü‘]¾¢ñ¡ՃIÈg†¿¶ãÎß”¡Ô„³“Þ‘B¹…1-ÇÌö‚ =‰ü¤ïwJFwŠŽë?„í{ñø£°X“-3g–UàÎàö‘ÕMõ´ÈÖ°‚¿íEÛ?†óÚ›úÊ… söäT¨±«ñˆW=u÷˜è5ƒÁ¦žþpÃ~Œž#‡|8¨Äš—ìA¨VCŠ_ÓäÈ8…|£ô=v?Î’ž\7+úÚÆšŠü`»§Ô¤š*¼¥2ÃÓu¾ë–]ÞWØÌ’QTÛóC0'fEÍÆ{Ÿ;v4Uˆµˆa5žçØ]çcÛqïïq7.ÞÀg•‰\àQ;ùÞö½›)nܰr>*Ÿ†7T+1t†t ü†¡h7Ñh%âQºÆ\¾€þ¿!‡^ϸ{W‰âep¹¸„ËpÄ×î]„zt6BøI¥mÍ¥E“”óéWÏ®<Å« †_†2š6‰)q£Ž]ÌñM 'b- û6™ü:ùRÓåendstream endobj 4579 0 obj<>/XObject<<>>>>/Annots 1561 0 R>>endobj 4580 0 obj<>stream xÅXÛŽÛF}Ÿ¯¨—ÊfDQ)iü–LÖYâÍ(00`´Èæ¨c’­åE²þ~OUóÒÒŒ$Î`aCv±ºëzêBþ÷fN!þÌi¹â¿Iq!žðÏœ~ýéf¹ BZÅ«`IÅó`Õ9=ÜxdAwó`ãñ<² ùâ÷¾èÓàF,Ýãz4¸ë8ˆ|®G´—Aìq}ÜÅ2Xx\çL‰3Ñ"XÓJ¶É# Z/XçÀóÈ‚6âËÀóHv4â L\Dô– Q8Ÿ‡Á¼£X£c.BÇ WlªP#3ÜtÌMpG+¡f|ç’r·­Ž`žøo<Á<ñ±ç­î`êÈóHø²“#SLñË(˜‡ì•£XªOsÖ|UÎ ×£Á]E€ÉÈu‚W} l’P½àžÆÕexÉõhp£;<Üu‚#¿»á‹…`¹É×|q`ú4¸ñ9ó¸ îFb?ÞõhF_„”ŽwIÈ bàÆB±M.m¸Á̵ð„`žGBg¸æèLIƼ‡ØHÉM!Ã.¼s±G¨ÁdV oÈÌóH¨\ÆÂÈG¢uçˆHußœ{4_eäz\ ƒV‘Äw% ­¬Tæy$!DñŽLgQÜK)Šoþ°õúš4·ê‘f¯ïÐZ h›¡®6h Ú¦ÒüBÚ&“ =¼óåfW©êüíöwOˆ4GÁö9] QÅ+™l÷š¾1e’·©¦ÔT:iÌQ“*Ó^ÕZUÉžªÙ_Ê œo:áÓ5"5éäÃbµ¦ËóOmáÓÓ9{3¹§ï«JkQýΚ²ÑUÍ÷Ù^w$9¸Ç¹”ûœh`á²·$ÿÐw¾W¤Ä”—×S¨<·ÉËëIU£þª–ér„@ðæÏeu%(¸§‡¦2å#ý ˆÊñŸËŒþ¨3Õæ ÕîÐÞ;$IÂ#̾*½ïT]³M;S¢^ˆƒó€úMô}Sê“ÝýŽ£ÆR¥s­jM….ìuÕþýˆvþ¿`àaûvvÿÝwôvìOcM×Múê•3î…s šŽ¾­^X&ý9Ñ‡ÆØRz؈ã¿=³õ^U:ýxh*ª U5Ô5É¿æãWûoÉMsîmôUûBò•(tÃ`˜/³×ýd›.x‚O.l–ö:?Ю5yŠt4º¬‘*lÚæº¾u3ÓÔ˜kÉ'õ¨S:™fOj{6£º=,BšÜ f¯:Û–UR?2MÉ*²'~†™•©D×D¿Ÿ[˜±¨s'Äf0„R™Rú3c¼5ÙŠ•=Œã¶‹gÖ–˜Ê€’3ÕïÀ­a3úˆJ Ý¨ÜÎpF£Ÿ¢“ª*¥{§Æp%ºM h»G’½:Àô^1f0ºS¦+]&šU°È¤­@£U놵t¡ ÝÚáüÇg¯ãn±jD2ÝmýÁì@JÛèWlÕ˜» ý’§0ሩ/®B‡l5] SØT¶ÅGÀ¹ÐIbV¨ÒÚ:ÐØ»@’Ý Ç¿Øg,Üp¥ß'}§Mš¶â@ülk´e/S(+*í ¹:`+R \e){…õh§‘Ä ûˆ§Ye Qj¸‘í6[ô}Ž–0燀÷!¦Ú&W—æôyV\E½só¡Ò yöÓ”À´¬Íó3™Lé €$Y@}ÐÕåËc„×.Y¹B$üª°ýӫߘ.Il°‘à­ëëÀ9lCÎZ™{ —m¼¬Ë:éWÎk …Ðû=bìvOÎ)'YJè¶[Sm#Á@»,¨ÈŠ‘ue[Õ©[6`©k¶¾u²K8=°ênOa§,0ó@LÙ‰ùQvd§¼>èÄdš¥w<ãçô͵‡‰-€UN€•ÁG…‹k…]‡ÐÍê“yüˆ,_J,¯ø/zCžÖN@ýPÕ2w9x±;_ç‰uÑ”Ÿ(œÜJNôgUò' žµu5c%ùL&”X=›Ë`~ÁðèÚð_JzoÊÔž¸‡¬?±ø»”8áÝÊ^×¼oÑ;ÜÙ!œì[ ?ëkh‹*¯í.IÃäØÙ:]ðË”@é=¦ð×£ˆ±Y _"ĘғjZNãnôd¦BÇÉ­ýTK zꮿ~¦Ä¢ßÖ[¦Œ~îóÔ¨êÝ7Wåc‹‰E&:x n¯=:œ›½-¯ü¹½t{€s“ä×'I7IðáÛ€Þd0¬-ÓÎà“nº—A†ú`GWÉàü• çºéÂï8'çce:\1 ” ‘›3˜Ôñ;­7\ÀrÿO?‰K‹&ÀuàFÀ/0XcjÉdx¦DùèÇ·o~¸ éòh*[²mtT•Q»\ô€°ç¸œ¥=Zð…ÖêÉ$ÀKG×F΂«Á©-D÷,†ì=Ž šC®ÎÜw¸Iº.ëìp=Å$ÝÙú ®»þ㵟®Á|aN,°C|áÍüùq EÍßÐ]R]'‰ð¤Ïd· ä/†6@2ÍõQç¼´ŒŸúYÎ`ÒŸKî™—Ÿn×á7(·ÒJÖîøt[ WÐ=lI0q;œI`ý˜è×^*<ЯbŠþq…“'å—ÚHyæØ•¼£5铃ÎÑÞ§ËeïÎÉ·ì%Ýä-ï@-ÖO^hW0-±Çõ»œ{×tëЩR‡á;‹èÔõ47ŸZyKÅVô€Q.µÅ l¿†^XÑ/«µý6ŠJèu¡ZL% ãe›š"LGËZeîSoÕõÞ¶²©ë*1P—(·H¹˜õ˜¸Rð,t[ÌEóÁߦ—‹ntÏc~ôÏíÍ¿oþãJŽkendstream endobj 4581 0 obj<>/XObject<<>>>>>>endobj 4582 0 obj<>stream x½VÛnã6}÷W ²( xmùÇmÑiÒl÷e±m äÅ@@K”Í­Lª$¯ÑŸï I)–"oóÒææHΜ9sý«71~O`¶ ŸdßûyÕÇc|YÿÑ[=|“)¬2”],—°JÝùVI´Œ§ñ’B i¹ŽÅåêKoô0‡ ž’üp:çx#Zí8øC4è£s·"Ø«´Ì9¤<’سD+vÇ,$L†Cix VÕŸ[.¹f–ÃA³¢àÚÓª”)±/PÕˆ&‚Rh±gúHˆ$y—F¨T†fšôð?!!(r[k!Û¤CXñŒ@™eöX TS&;`¦í*²Ód&†àZ„¤ªÜä¼%ûçÉ)¥„ö»àÐSVÊÄ %Í:" Éö|}ÙÔ2u‘ kQH$*Ϲ»K~gªÔP+ÃGÄKQ”9³ä:«œoÃ&«ÐoŒ~ðÏU°kû^XòÓÃGz§9”p¢4¨Í„êâCæšÚã-Ž`Ím©%élQ܄ᣄ»†#îc¤g0Åœ"w[–ç*Y¿Ây]ïßÚ7uÒ°Î44F B[q4|‰’g)QÅ1Ðä^<³¼üFhÿSÂn%Vf;ËÁÁôÁp ›#¦Qq$Æ„…L«}›'Þd"æ@'51ÿ_0"rà-AHyÎ-? CQžOÛ{')'«Ôr±k¥½ksÒ9Ɇg%R rybƈ­ô…„)¤rø—̸u×^u%R?ùËoãì90Þ¨«=‡å<'¿‡2¤zóÙƒý¦énD`º@œðð¸ã2T§oÒ4^Õ]µØÈŽ45˜á( Ó2˜"É+œòx&d’—)‡‹—q$P JŒúà;µGŸªqæ&ÐAé?©·„ÝÁzý èš&:&!J/[¬/l[»­mø•»€+×3ê]õ±4]Gdþ«S GÿÑLj•¹ F^Ÿ´³x±¸&?©ÉÃç£Ý)YÆN2onnw¥-tñIÇ m8‹i’:?q2}½«ØÄD]8Ušxôxô‘ÆJ›ss6˜’ -hÄáW“vö2Áx M¡¾ÿî1#3ü•‰«¯:3®Ï* -×»Ui"EÔ‰éÖè¡Z‡†sÊüšè:™“[团G\O„×Éu¼ö~ƒá4ذΜ©á†ÑFй¦Ò¤-«°~v%i0¸EÌ·3ÀX]âªC­þöî.Ãö7YÌã«Ù­áñµ/¾??~Nã1Ü«¤ÜcÂmMIº†I襇׾»–õ«ñ"žMqSÇ4Ltï—Uï·Þ?ç¾®endstream endobj 4583 0 obj<>/XObject<<>>>>>>endobj 4584 0 obj<>stream xWÛnÛF}÷W \P‰ºÙŠÓ Ò¤Ný’¦¨¼ÖäRÞ„âªË¥e>´ßÞ3³KÚ¤í¤IIæî\Μ93úûhAsü]ÐjÍÿÒÝѯWGódŽ_vÿ¹-Í.ætž¬è*§Ó9­_-’õú%]erjNW鈈JµÓ›ÑæÅk¼öÏlFïœV^ÓÞšÒkGöú«Ný‹«¯Gsš.`,ƒ±ÿ¯±÷ºÐ?2F·Öd¤ªÊlËÍÈ7{M·ª¨u?TDöVŽ„‡ƒ€èÁµçs„ÚÇÀ8U•ÿH N¿¹È[²ÎlM© ‰bYå•7©ÀOãÜÙ]D6¦:–4ïqO A§ö{ ÏçIߙʛr;´ülïÀnt×»üÏkþ8»8%®hNÓ%Š»\EÚŒ>ßè’ê .‘©©h§Rg'rG*Õ73"vºòΤ^ghUf·/t(Ó† óMmkSÜå…UY74uaíÀTBŸ™+ReFÕs”¢…IAõŒ3¹—Ln&Î9M¥õ¤ŠÂt– p"/´«ÁŒk”A_0Údºô&7pL¡±²† C«U[F.[6„aÚ±¼?î…¹S ûòN•ÕÑ–¾hhêDØË†òºL½±%l(íÑÇÕCê&Ñâò”¿Ìå™Wn‹)T¹­ÕVSfÇ_Õû½užöÎÞ5!<]…‘Y¾Þr…¦(ødV§Ý¢ï”Рb´‘!Ï* Ø’ª+ÃI¤í—î,·å#È™˜’Æ” ò@¨7¶.2Æ3 GšK„-WˆL’ÃǨ¢R¢â¡©¥ (E •«PS¦4 4hw½N}íPÍ˲ò(¯àÑ+”S‡{—>£Ì8Ô¢húø]ƒt@˜ZÌB'FJpìéç¸(üÒÁËdµÂÈF';@®‹&ÚˆD¾OL™59Ncf‰iÉ+¸=ÓgPËB¸Ä$À”³5ZH•tŒ_Òø˜Æ³¾ñ¶nõf„S¾¿‡ÌŃ·B…€ wès¦Ã˜È21Jwb–šð2†êÔ…Nž¶öÀçéSãoЛQ€¶Gé–eÝHí#ûæÍ‚¢q'<.?Né—öY"©ƒ¹$ÿÔؘè1å`Zå1C ·!¢l1zJg¿šœNÒ¾EÈT‡å£ËiÆéÃ(„ó´ËñS¦¢hÜB‚—lèY$ÿˆjq°a:@ Âù¶“G] úÆdPõku ÙbÂï,Ä3µå­. ÄŒ<‚Ö}cTÆß´s$ò«JèŠåƈ€p÷ù¾Ö©b9b›íQQs•¦ƒU†OØi˜k¬ j†b@-´ª âÙ*wÍÒ—Ú¢@Ÿ¢a7£Œ§šõT¤®3?ØdˆÈiÛ„^FÃhW4œHp¼y!?»XôƯ¨×=j²‰ð4Z@T𲜄n ‚ÂN¹7™¸ËîZí í%è:Œ€A¡Äǰ>ÝO[Žq ²¬é”Î%j30ðÄÌLèäìþ¢uÂ"ÀˆúL¨†$oKT(~ÆËo¿Ôxý‘\ò`D”Ñ{˜d]øƒØÚ}bÚy#òìx”ª¡ì„ìÏÕÈ€³Ç øˆ‘¡h׳}´e 1È-ûXÕ²¶õY©\ƒ½Ü4±c°‡•Û ìd“Þ(GãA-yà=ynx°£o|7zŸ ]öœïur ÷NíCF6÷h}tc›tâ–çîÎb>VZí nd‹õ‹µ-#’¯ˆ Ç·¥érÍCì>/XObject<<>>>>>>endobj 4586 0 obj<>stream xV]Sã6}ϯ¸ÃŒÄ8 ZÚ‡-[Ú}é´%3<†¶œhëXYI^Èt¶¿½G’íÄ"°; 8F÷ܯsÏÕ§Þ|i<±?é²÷Ë´—Ä ^¶¿ÔœN®Oi˜Ð4§QB“ð”¹xH£+Å™ášrY)Ê«25B–:>œ~ì\ÛÙ%4Â,2ë§£’?=”lÉg‘( •¼àK^=;ôV[Þj³Æ Ãá'bJ±5ÉœäãGžmpשsÖEŒbúPÒUŸÌ‚×0B+ ™"‰Œ*-Ê90©ûÿ, ëÁŽû¡… òî>pMðTiž¥ ¦âd(‡áu}|½˜Z‡Î7VïÝydQúŒšƒ,rÅQï&j£r…Ù‘‹ç»Ó±m~˜s# _Îêö#>Ù΋2ãÏaH›Ìþæ¦R¥vÍúÌŠŠ‡uÐÃkýz?K‘‘ J¿b™ê¼¾à;­Å¥Þ„E?{ˆ€ .¼­Æß.xYsÏ,@“%K•|Á*Q„“kz•˵˜•YMö…Y¥³£‚ÏYA"Ãü‰\p…ž¸z¦Ð5*X9¯ØœÇß‚ª²*P]i¬?Ðz8²3ŸJ¥¸^I„f¤ Ubü”ë‚›ˆÆ'(ÁUÎRN¹(¸+R;¿sÅ-WÁrþÌ–«‚Û©÷y5*8exhUhßcº©V+©9­eE –kU‹ ñGöBÿØ_ÄãZ÷£Q<ãS9­Â}pgQ&«GDô|7Lîg‡ôo“¿•ʈȓý2|›KE@$¹$A?A,ñ÷øx@œÇ|íÝd÷0:˜Ïfå&©Ç~_8øÒñè>m´ÜóoO&ç6Ê©¤'ÅV$Lß•f)æ ƒWÜo(ÉÁRf*P÷¦ö‹Qò(Ó¢Ê8í¥®\:{À^¶Í׳Oþï;«÷›ô<êךàŠñj¶È'+Ah¾N•X+û ׿'†~Ø­¶p4LÐÉÍ×>ù5Ö*u§– †¤0rPê¤oÍí$5LÚ.ÉC+a¬/ú£#aÝíÓ æ–mt§µî0–uBkƒÜ§?™†âJºêDW/¥Nz!Ä>½çÚ(¹ö{ÈÚŸ\ëÀàÔŽr˶ºåio~-ôÝ…àÕÀ-¸‰é§•t*±cøýªô^›Ö[©!n0t® ØŽ£š˜¦VoÛÏNaì]7‚§¯¨R­RÜ^ ¯/Þ%Þn.Û2·''o’‚è?ö·6»€äo›ê·‡…«N»‡‘0’vË7ÀŒ_»¾ìp(nèZÖµ(Ým D Xî‚ðmJ™6Vï[©ÙÊॢTb.J¬©fn'¦ 3"õm8Ê•\Ö i.‹ç®ªž NìVØBÖ$Ls+Œ7ÈŸ…vÚQ;í}©%è¢áä4>ŸÑä|Òl’›Û¿ FqBïeZÙ;0r‘¥E:ûÓƒs?ûñ(Q« öÌY .ðÙáð¾úuÚû«÷? )OGendstream endobj 4587 0 obj<>/XObject<<>>>>>>endobj 4588 0 obj<>stream xÝWQoÛ6~ϯ8´ ¶*Û‰›nÈC—-C_† Їºh‰²ÙÊ¢JRIÜ_¿ïHÊŽe7í€öeNXöywü¾ïŽŸF”ágD“)ÿæ«£ßn޲4Ç›?fA/®Ïh”ÑMI㌦¯ð®ðx“'ï–²¦ÖªzAn©,­Dnô€Nn>½¸ÆÚÞ/qëF†º¥‚±‘Ö•;YÓ$ȪUSIbkªÅJR¥>ÉþZªvý¥´é••}³”Þj8KcIÔi·”†r-U.| Ø×òÚ Gc¤™ƒ@´#QUú^i²̪µŽæé܉J¤ Y;U*l–2RkR\6™’/  &„ÆU¹7¢iP8)¯„µRŽrQcYÞm¸‰ÏQÛQÖ®ZSÓXÊzMe[çNéç"ɇFæÎâAv{¥1Õñ§êã@5æªÆ÷Ê-©1úa"ˆ]C²›s=ƈõ­r–ÌNöjÁhˆ‘“´A¡”kμl«”®qròAð©ÿÒ-}‘N"Ö†ãq:™à©HŽWºhh#gtá;UçU[Hz–ûplªžíìDYèv^É…ÿ¯9ÙɯÑÇŠwçÖ€åֻΒ`LïGÙ‡h½¥Å^Ãñ$N_²÷k‹¥µnÕ…öÄx:=à^>$_Šàsºì>O‡œŒ²Ù ÑsºžœŒép|;î%*¬l@ÊBÎ’lÀ~>F‘O—ðÊß«Øi|ªøéÑë9½¶V-jFs»¥‡wŒñ¦;¥Ê9,ÿzNoH.ÂÇôâú<êÁðl§`i×ÿVn–ÒÊ '–‹ÈÜ‘u.ÛVœï…ÃFncõð¢B8<8Óæ®Qä”°$žÁ°ZÓ\·ua)_Êü‹¬¬(¥[“.» •`î¿)ý™Þ‹Úù#øG»ÔmU@G|&já6%éùGЇxƒË‚æ,/‘øžŒÛ q}<-Õ¦cÝø<½C·ú~õÛŽêöYëBù»:·¯Ò6æÄ%‡¬QX˜- Ô_/_ ¶Øž ÚÛ•­è´gó~E,¸%²öÉ ÇSNï"… /±üæ©Úuõ%J}‘n|ç QÈ ‘%Æ¿ÔСÐRôý°’w²‚Vr¥ÍÚ«;:k妒ýàC ê»×ërí÷X‚¸œØ!SN•ù!¸w‚¥‘ óžàÆjŽ"Ï6(:îÂ÷­õý€ûÖ%¿‡˜íVÕK™/jÐîA¡!ŽIóÝ• M„»F©YùÀD§y㨇c:(÷lâÊ:ƒ„NC·á‹g²mÂ[ãYñ¦z¾v€Â%‹/R—³¤ïzhŸÙÉ·BÐ÷ô|Ó³â¶>ÚÐÄwUnÑÒLjnp4˜Qú;„TzÞa†úÜ*ó ämÏëÀ|²ÝB×hŵ”ÐAh4˜î“ 莱Ž7Û`pÃ!Æ3?Tx)Åt´?éÌ™.ÒùFühäSéKÀ³}³ØnO˜J—§³“ÐCö°=îøÇgK?êÝÒ}Ò$?êa§ÿutºaRD…í—ÿæí—§ð¾ë¤î16ºú °Yûçc nõ åØªâ!i£ÓÆ™‘Z9¹²ßR:?}P[û{‹ÔU_a¾^paèzÇBÖÓ¤e¾öÓSíˆo|*W|}‰c|¸£°bó¤Á›æÚà¦ØèºðM¼öôßhÓ£[Ä^7îŠZÌ’f€Æˆñ·«h„ðl?¿¦okyžÇ… 7²¥® X‘I'¸X>!K¡c‘±e³³ô|rNÓéE˜mþy÷æÏá8Íèw·+\ôü ÂQòÁvø2ÌñÆ¥ólšNâ°8½b·?nŽþ>úã¼”×endstream endobj 4589 0 obj<>/XObject<<>>>>>>endobj 4590 0 obj<>stream x•VÛnÛ8}÷W U‚H–åKœ]4½¤Ý—E ô¡^EÙÜJ¤JQq½_ßRR"ÛÛd‘ ¡Ä™93gnú1š@Œ?˜.è——£7«QÅø²ÿc¶0¾›Á$†UI ‹ù “ét4Q¤\«Ú2eÞËN ¤²à!Ÿ)¼n¥Ÿò“Ñ2Ì gV›úEüA(a\i´…Qcб:Šry/@ç.í,Õô€…ìDb"¢>| î£0$ÕW-˪ ~2÷ßî˜YMm= QÛÔa<”Œ]ÿžåñ¾|ýëq,Lθ«ÌU-fºÔYó€I®=ÜIÅ‹&ð‚—Ž¢H¾hÐ{§ì^¯´Ý’ü ìÛapsª—WäXõßÚ§­•ÇIËt“¢Ïs×{žä¾ª?é=¡ÑÜÈê‰ê¼½½ÅÞÓeŸLŽ6.‘Ãzôm(ÜvôL8‘Ò«MÇ"g×ñ¦"•Wƒ[ŒMïŒ1ßqké°:‹˜l¶ˆiBˆO`¢½ô (GPîHß´tóøœÜ)pÎÒ›%Âz½ÓhÉ4YêÂÞö)ŠÏÙwó°ó€Ÿq 2H\7N¼àÀ¥åà Ù¦çñÝ LÁ¾hæÝ(\FI4ž1Ë"é%»òœ$3¼ÄNXagúË~œU  í·LäRáRÉÅÝTp£â½0–V„a{x  VÃuãŠGÞÖTÆ4 ,3[a¡`jÛ°­ˆ€AJf]˜Uàâ*$Î8@~0áÄi}Ùë¦È EEÆ¿£õq£ÚI¦R¡1ï ¢7Ü6FÔaÒ¬“nÎs}•ÃA7 „ÈDF.‹Ÿ8µ¸uŠW\ Ò&Ï…ñ…%Ž<¨›Ê5\²Û£¢LEFÝB2´Ép1“Kv‡‘!þ^›ïnÔŽïº-çFl¸Å|Ç \º<­ý®¥ÝxåJgcA¥\û¾ÀÝÂóɪïõ†¥“.™8Ò 1…±€1çà#ž¡À™¢2u€J£6ëmv¡?Ú7î«¢e‰ki÷cVú¸—ý‡Ñ,šOç°˜/}ÉÓR “(†wš7¥PÖ¡"–— ¯ý’9é¡y¼ˆ¦ ~˜a.&ILJïW£Ï£_µHÉÕendstream endobj 4591 0 obj<>/XObject<<>>>>>>endobj 4592 0 obj<>stream xWmoÛ6þž_q(PT lÅoqÓ -йK[ ë6$Ã>ÔEAS”ÍU"5ŠŠëýú=GJv­ºm’ éã½>÷Üéß³1ð;¦éœÿdyöËíÙ(ápÿÏ­éâzFãÝæ4Ñü)ž² €™,l¥UM¢(Èæä7Šjï´YS&¼ mèñí?g×°4$uüÜiL âm¸WªÒºU'*#œ®výÛ•w½û)Ýl–bGÒ/`W•+•ePôo¡Ê«šeuM:ø0¢áx‚P!}÷w$hëDU)Ƕc$ÂdÂe´ B¯œ€w½hàsiïTÏ'Ê#½¶f@Û–X¤LÉB8¸#Ú ŒÛŒLg“tÂ…€+wVgÔê\ÆOçyÀú‡­`ë5¬=… 絓ªõê£'³|Üó&f¨ç8®ôıR¡ÌÚoúQš¾h%œ(•W…wŠÔgïE—;[†Ô¬±*%u®e‹¾Ǫ÷EA¹É”+vŒ§®6Òf*å[C q8™qÞ~7­U‹@,mÖœ¡ Š5¾ÓFM¦èΉ]êß`g_#pX~n}¬êz™Àþ€xÁª–ŽNwms5Mçó'|õßX´È}|þü92òì ;"Æö‘°Hni‘CåÕ2 X,än/—¦)áG¼×XáQ°¬c…SÉ¡.1˜²²:ºóh¹ü<ýøßø„ÈäÄÙôÄÙìÈâ ËgógONœ]}uæÙã¬È'Or°:Q› „ìI¾Ÿ}8R~Lñ·²ïaæpU‘Á4Üj‘ák2Öƒÿ·@0}2v ÖãÖÍmQØ-÷])¤³¡±ŠÚ‚smTÖvUÇ‚ÀHlå‡-ü®Rô~`À3ÏøùCŸ×ÝÿJåø½g·#€Í–£ØŸEôœ+h­ï¸©ð¤:Ùçr#ç>Æ)¼Lƒ@¬\‡-rÍô ë°ü_\_í_Áféåô’æWØæ 2B‡“tD/­lJ0Hè*v ¬…‡Oâ:úM‚½ÍÓé$¾„Œ'c¾üëíÙŸgÿ²ÇDîendstream endobj 4593 0 obj<>/XObject<<>>>>/Annots 1563 0 R>>endobj 4594 0 obj<>stream xµWÛnÛF}×W   ‰ÖÅV’ Ð"±ã"pÚDA^+r%mLr™]ÒŠZäß{fx1ÉÀn^ Û´HîîÌœ93sôe4£)~f´Xòo”ަáOø2ãËû«Ñù"œÑlvÎ)¥åóði}“ЇQç6ÅãEø¼ó²{·‹iø¬û¶s·Ï潃[u<wÜŽÎ.§ô,\ÐjKó)\™…ËåSZÅâï”VQð„¶ÖÒ$ötõytvyN3¼ØÒ&óE½!(ö:£j•ïïè`Ë$¦Üš¬ ÂöÓ¹Ó^g…*ŒÍÈnéDŒÉ¼‰µ,ZE n í°×>±5|.]f²©¡åh¯ý40?¦Ÿ®¯Hy_¦Úã`UÁ¯¸‰`fsD(ºùøöífR“©BÇä 'F²˜Ru‹Š"›ÙWS„´ÚO;s'GÂ_åvº De»Rí4–x²‡¬ÝRíˤÙ?ñœí®öÚiRø³›;cKO¹³›D§ž¦Ø ±Þ*l¤Þ+¬—ÆùbLÞd6ÿ °±H$@XŠU¡º€‚#ŠÚÙ ¤ ³³Ë‹&Õtón5€›¼Új°ÇÁ¯m™E’_ØJml¶GÄØÄî:ˆÁˆy¼SGå\™ƒ `G'餀¢UÌþ"Nùýú”+]jwAêùÛF±Eš2[€Šî– u…î¹vGñ'¤ëÌ0X%óH8gFh#Ö7zÈIåÙ%jÚ¢þ'ó%'µ…"ÿ{9ÀŽ‘>VB‚Php½¥£- ùå|ÞãÆdÕ_sNsÆÕAÝ*žÌçábšŽoþÖ!Ïʙ⸪ª@PLy“è¬ýl2S•¬Oé;7(tö.RœÊoœ®R.K?¤ß×§}°E¬ QÂP³³ÌÇ\§*é÷ÒH 0ççGã~¢ò<9RcÿÃêýõÍUèÛ×7W«7ëSú§]1Àï¾ ÜÐËâ ›j­îÿdoì…– ¨ß`{éu“ÿº/I %æ–[¥ñóòåKòô=v½þ:â2»Ð;þü—ùô„amƒæÕ wüx:ÌÛ€וçÌ‹\»–ºUQæ(ûVz0¨;TªÆs)iiGØYz¶CÓk¹ÅmV?į&¿èÿÒÊ›Dé–¢‡šIK´š`¤4!u§L¢Ðz9*ŽQ˜Lp±á\=Þþƒ^«µˆ}²?ÉôÁn>£ÈÙœÓhwHwªÑÜŽýã~°c(ŒíCÌׇPË“ÇGÕ)0ù×× ÛnYADÕkÌmF/Ú*ÂÒT,®¹^êFÒÝ7¬"U qüã³ú5÷­ò€nhúád¨ït¦Lëš<5A²ºVòø¸Lx°TfÁ<©ž†ëÏÀ#1u}Õ aVòN›Ä B²ÈB˜dèÊf—aÅMŸ¨§º¥­ù*;>Œ‰Ë˜O«BlÓ=ú±Z@eÔž‡½‰ aeiË"/‹fTo±w¶Ü‰B6˜µ~@~Í0aTšÃchu_┎¤JÍnÏRô`B(qéK©=Ãí¿—TÃǰj–ï)õ”Å·/ù¦3Ÿž‡‹ ZâÛ›P€{ÒdNé•DkË.>]¬Z;yZ) –ˆ3zU+ûºçìÑm=Þq1]†‹94%dÈl>çG¯W£?Gÿ¹Zùendstream endobj 4595 0 obj<>/XObject<<>>>>>>endobj 4596 0 obj<>stream xÅWmoÛ6þž_q+PTlÙ–'iëKÚ`ÅÖ¡Þ†mZ¢,-’¨’”]wØßs¤äDNƒ¢Ø†ÅmÑ佘ü£\37ÑrÁòþ6ã0Ì‚IäÏE­'¥5ˆ€¨Èk¢(éÜìv¼EÈ„1MéC†(~÷ã›7C()(첋¦žÐk3Qõus­ºØµ>šÁy.bˆƯ¹XX_…Ј².äcü6] £(œNAIp/jž/¸€ šÖîaí|’nøz{ñòƒ¹ôEm…FéQ!ªu#ÖŸ±úéÓ§· ÕÇtÏh£ ¬1ZIñ±»Q-âkÈ3£ ¥FÏ„f4öG!§æÛ89¹<}Ên5R1êê”K@Å!÷ìès(ï—±0¬Ë•€ŠÒò}# Çœ³Ñ¾Fn@@n‘$îL­XÐâó©3ØeÀ a¡ÔÚU£ì"æ_AE"sN±M{Cýv—¢  6fÿ­(@BÉ®½Ìnç´wÃßïÙâŽ8XV[mÆ dáÞ«YÔ>-ƒ²)lޤl¿ôjДŠ:`’,á%ÌD&ûM»Rì•AÇ­v.¸´Õ9X¥rÔ¹¸Ã¯m`JpW¬…É?ã–üîçËWÃ(Ó cf@‰ò,Å΃üÉá©Þñ œQ;ø„9Ÿ9ÏÃi„_4‰¦¼õrqôÃÑß áÉÁendstream endobj 4597 0 obj<>/XObject<<>>>>>>endobj 4598 0 obj<>stream xÍWoÛ6ý?Ÿâ`ˆ3زc;nÖZ$iëÖz(°e0h‰¶¸J¤JRqÜO¿GR?"gmŠ…+‘¼§»wï?íÑŽh2sã|ïõ|oð°ùG¯ix1¥£ÍW4ÑìgüJüüˆ{óRKCÓ,ç–k:œÿ³7¼Wzx‘‡Gõ=Ò*b”—–-3NÆj!×ÄôºÌ¹´ÍSŽ5EiëWÂ3oÂÎ%§_ÿ¸¾ Z.$³xÊdB&gY6e² bDƒ£1@÷rvgÄg¾‹'N>Æq&ÄV¥Ý ž~AÆñáw“ðxÜiD'ѤÊó`<Ž&ü/éý‡-–ª” OUænz9ýTâu Ooq'¹vUêEQÔùÿ­ åì#_”EÁõýª­m­(ö`<‰f³î¨+‰OãdQ&n)cr]²5ùUà§§§hû)Ï2E¥³dÿæ°íàòüúú-}xûîúì ó§„(5ƒ Cé$Š¿í"¸’³X+r¤Ére,ñ;T7Ûzü4E)« ûž×S8ÐÛ«è!qV"V+®¹ŒAU_t뎯q{¶µ=Áâ˜xdÅë[–•ÈeʬÛ]š@l!…,C=T´‰ÿ.Z–.VDW~µÈ ¥-“¨ˆçEʧÃaþóW¥Œ­P¾ ê'Š’Êú®³!@ÕxL~ód0i,g ¬S€šbUlI­*T®7üž~u˜ÁÚ¾ïAÍ­—ìEŽinÊÌz/ŽëdÓÕª“¨\i_VU™Ô ;}Ón_n­ƒ…M-¬å²O[Uj*´ZC†h#²ŒbÍLŠŸ6ŽAR·\¯2µùÁ…,šv¬i,'[ôWÔ)˜4Hæß®m{øî𻿌è•$U¸²³¬“Ü–…îñ=en>-<¯›«G¦à±X ¤Ø5¼,ó%TÕçwVƒ XÒrK›TÄ©_W‘)ëÔÒZ« ÞqðÝs6WèÁß@xµö2ëðyòw¸Y!)²Òuܶ­á=ì%܆­Ð~»Ä:YõêÜèúN˜Ôëùåù«³ów‹÷Wž?)&³–Åé"Eï¶ÊîŽú®•v`ï_~Å"·½¤{kžgóÖ‚€Zi•?êMvUÀ 3Az‘ '[Ér;K‚e*öCÊMOÅg} =¡õjjÄÚM2*J¾ÙéÍ›C×AˆP ~±lö† _&.U¹F?*LNNT¿(ÝôÝdÕ›’ïb{Ð`JÙ-Çè…–ÖüSÉáèæg:5.”ͽ'»Ì>ÅŽ:¢ñ¿Z“W³ÚCƒx$A ƒ›9Ùk+Ô§6¬&Y;ÚÚZWÐPŸi7¬ ›Nþݸ‚Œ.*üñc7ì™Á¾t¾KÚ{ÖÕöý9t‚¹¼š6[Õ¤J¬ëä'ñ`ÙRy“ ¹¨É\ͦáak.nRÇèÏîD^æ”q¹ÆÞÖ£`êJ#3·#/ü S†»`Ðp“†ðçúË`’Íj³êžƵ0“„‰Å…ƒa»w‰Nø`%O4‹ÝÏ(˜Mû€î¦)TæOsÌØ ¿¸Jã—Niç‘C±gÖ³Çõ6p¸OÔéð†u0LU·KÎ>g|;üÅq0à ¥†¯™öZ<¼8©Æ·£Ù4:žÓ줹ɼÿpõf0ŽFt¦bÙcõ  øaõàE¸ºà&M©ºùDÂá8Í¢ÉV\GŽÆS÷è|¾÷ûÞ¿š—Ÿ‘endstream endobj 4599 0 obj<>/XObject<<>>>>>>endobj 4600 0 obj<>stream xÅWmoãDþž_1:ÎZ7oM{ NA¹JÈé¾XªÖö:ÞÃÞ5»ë¦ â¿3³»vâ´¥E:‰¾)qvçå™gž™þ9šÂ¿§0_ÒOV¾[&ñöôί'pÏaUÀbË7Óx¹¼„UîNM`•Eoß¾=Y}_/`Š 8›MðwF«R¨Y¦4Z݉œ``XÁ5°Êr-™w ¥¡hef…’lÉ,HÎs° 6ZXÆj!×3Ë@H|Ì m 4ÃÆLÛ4•Àþ)±ã ‡MguÔo1ßJV‹ŒUÕƒ¨TÆÐAÍk¥· $”œ51üÆM[YŒVsh*–áUç×Åœ0™ƒæ¶Õ?e.3¦J?ñÌÆš‹4 ŠäËÌçs«ZÛ´öv#lI'QÃt}ŠˆÝÓ‹äd®ÃÖ8Àî+1 ŠCªZ™cDYÉ4ËdðnÞ”óJ•-Hïéà*Ñ5=G@¹2h‚€®àÃGnrÌ èˆ³¾7RXAèŸb¥ù‹l!¬æäÙE€!ܱªå)i™D2‡Ø‰º­bøE† ‘/„Ê_ÁX[{>”S#YBìZVlë”0, ÝZnbøÖ °l§Bäuƒ\ $þîè¸\Û2†> eØÇÐÑÚ‘ªfÛA!,H…dÈL¢~`Tߕ޳x>Çý7Vù’’…Sb1Œ$z—œ|ݹÄÚçQ;„‚{§DknoÝáÀŒ'Í<©7ÒAb™F[P1¹nÙšÕ‘(HÌ0T–ÏÓÉlỡíõýrv9¿ºz3½$ñ‚›ÛÝnûà’çy!#ò€Q5ßL¡j ÍՆ뢭àŽkƒFdé² ]uÜòYÙÊ?’è¸Å£~òJ„nª¼ËÕIueÆ$¤ÈV «‰)áÃu«‘ˆš$¦vòêη´ª T¨Û¬ Š™9Î#™{]K·$$rÝõ—g¯*(Ž}Oå2"æŸv°¢è56žüêØit§ŽšWœ~ Ýsêè3 -† ©{g>’aṊÓj’ãd¯‡?C 쥋l·Íƒ¼}³ (ÖCéAíø=CÙx¦ \J%¡ùÆ&9¿:;®I¿Æ¾î ž¨]RI´Ä®¶86 S[$ÑØœÂ«wg l”®ò$‘¯Ž/ü=,àƒÏ÷T Cz¨®HÍŸ?¼†â]£’Y)³nâ„‚E&ÏD!pe šÃö¥ ã]á$@ÁDŽ GÍ^É-K+$L ïhîQ€^„ÿqÛvtX‚…æ8¹Ç_L““cðÔ£rºú|vítNŽ%sXê'°ßWpç;XåžBâöpq1;¿ÀüŸ-j7¸lvMjHŠ_Ü¥{Ò ®z:ökÑc;Žkê—éa#‡QlvŸ¡£Çf‡°\<ìõósøè7hœX‡»„Oï*ôàt¹ˆ/æ°¼ê׉ß?Þüx6‹'ð½Êœb㪮$]C ð§Ï.ýž€<^@XjcAg.&Ëx>Ã2p­˜Î.èѫѯ£>¿wendstream endobj 4601 0 obj<>/XObject<<>>>>>>endobj 4602 0 obj<>stream xXmoã¸þž_1Zœ“Ûh-Û±]tvÛí8Ð[£Å¡.Z¢b¶zñJT|nqÿýž!©×P›âöE‰IÎ3óÌ<RþrÒCZ®ù_”]̓9FÚGùÄ(Ülƒ ­WÁ·TJJx%…ëe°6Cá]3Ž¡;ïDg0²ÆÃf7­‡I¤p5V^=“!–31^ÂÅ Á¶n¦ÑÔï§o3‚›¢iÆWÛ‰|y&:_¾ÀtMCŽ–¼ÉEë™é™ ±¾BpÍåËã§oãË—1Ò4ô—,&®ÔX_ž‰Î`4ÉÑNx\´ž™ž‰7_†Çˆà4šË—ÇOßf7EÓŒ‡[Ö—/ÏDgàË— jÈÑ’÷ ¹h=3=“!ÖWN£¹|yüôm|ù2&Cš†þ|éZÚX_ž‰Î`4ÉÑNx\´ž™ž‰7_†Çˆà4šË—ÇOßf7E“Ç·[º<ãír_²LDC‚†¹ÇFê™è †@_¡6‰eåqÒ³ð¤É ù1íÍ2Xø6¡g¼]>D™âfÆ=06LÏDgàK’‰ÄkÊæÈã£g1š`ÇÃwÛw—Ý3Þ.÷äÈ„3¤f({`l˜ž‰Î`4ÍkÊæÈã£gáÉ‘1²cÒ«%žyÆÛåC”)jfÜcÃôLt¾™øG¼&¡lŽ<>z#¬?í®Þ~B÷AóÙ%´šÓú> Öë íbägŽë.šþAp½û÷ÕœnCŒÅ³_øÓÛO¸ÃácB· Ì,pq2¦³ÝQâ*«ë2—1UºTùeâBQ‘k¡r:¨\”Š…Y¤…Cš•2•¢’CüU'©DÉŠŽÅ™4ˆ4-"¡á!“Y8U‘.èÀ® DLû™JHœN©ŠÄ!•ûë–Ä‚I|'q߆•ÈIþ,²S*ßY·mF ­E°\"?ñì÷‘åòXÔúTëÇ&‚ÇJýWîgÑQ”tsS½!•kº©R™¿¡¤”˜ºù]¸¿Þ_¿gø6‡ãœ>*¦¤(¼HÎx2å¹IŠå“Ô”Šü©O¯ðùðáƒõ·¿öÍ~ÿ³¸ÿé~$k<â 2Äc˿ŇïÞ_ðóž?lYòÇ{<ÂÕßñ”s6•±Àc»ýfàÎm²'5„ÊpIQêJ$²Ò¨j]àXqAé Q¡æVk¬œàX]¨}þÇÃ_zHèRÔtÏxŪóH«"gp¡Y•IQf $òþÊ&P£’SYèB_NòAÈÔÓÑØT*–%Kè‹õ »ŒÎJIÐQ¦'Ì5~úT”Ä Ž&”FªúºæŒ¨èE}dBP4k ÒzM?mTÔilB$¥›àš¨(Uÿ‘ÿGF–Ùå± Á ½”Uj§vý¯Éœiè7vý:ó.øv+¸v‚×[ÛNЉzíäc‘e2×M¦Áà½úv±âù¹>ŠRCÌ%×Áµ¼E´™Û¶ n1Å5TË“Ì㊠ï è‡ÚKS£$gSQT—%‚J/T9ï\̆¿QNª%úœi:o?…xײì68¡C³b¿@ÃFÅ“ŽÖÌP~Ê"+*Å™>º¦j6ˆ@üÜà4ŠYœTÐFÄÿLäÞ$¦3Š(*ÐäTu4UïöÆC &ØHÿ*¯ZŠœ`A‰>/XObject<<>>>>>>endobj 4604 0 obj<>stream x½VÛnÜ6}߯ذ¡4YíÍ^;)ò¶qk n½E^ \‰Z3‘H•¢Ö^ý÷ž!EÙ²ÀÚ¬k]È™3Ã3gæ¯ÑŒ¦ø›ÑbÉ߬ý°MÓ)ö?vC“³#šMiU`íò5.rÿYrQJÑH*ùD…±ä®q£ÖVت” )튺¶¦¶J8,zÓŠÍÝÊ\Y™9cwé‹ÕÇÑäì5ÍæÁßx¾„¿ä4=JgÔ¸üÍ›ÆY¥7aÝ®ñü(=â•+/˜`ÛŸaWª†û’+ÀmU¸nWËJÔ&3z+­ƒ?úñåË'ì> '!³þˆ€`ÍÐ9ÖT@ÏÀû„8a7Ò1ž)9ÜO ÜåÉAeò¶”qq4ÌÇ•(•m.iï~.öº5°ÃÎï’‹ØÍUrõâû‘­Q9uŸµ°W ²Ó¸û‡B‡·Ý¦;ÊŒ=ÊEº\ž°—óÀ†|O„¯GvKo{D@ü¿O¿K×ZÝèÜå~ÝÃÝûE–¥¡Æ–ùpv&öéB4MÜ,øê ,{Ê;ÊLUMàκ”h.ÕÒà¨HêÌ´ÚIK ,ঠ¬„'ÙLÀ„6jÐ 9tBif˜x>¿RZ]Ãn&4­%pP$­w1jO§\ÑrÇêoH§|¹ãø†9¤Ï÷üìß‘g‘ˆœªv\´¸Š1y–~ÜÑýÃbSÑW~žÃÿ9{dkä6ˆ·¦u<Û'œ½ÚhºQîºcÛ h£vä Djö ï<7‹ßZzftZ`4Ž iëÚX#H[ó|’yåbˆ“³^J'†Q‰“”. ‘ åÓFÃ&+ iQ€ ,¤_ýÉz¶¶ U¡dî7Z_Ö|ÓÐå‡óŸ©îÌúÁÊ×É=êà~Ãáz+Úq‹öƒ²céÖ¢’M-à=¥ó‚v¦…PrZþE> Ä†H¹pŒÂçuöŠ*ñI"ÕðÛñ`}`Q{ݵA§Ì%TÀ §PܱÁ +€îhÛ°èôyáJVÓ¡ JìÒ÷°áº4GªÎ÷ ßABÇ£æU'a7º¨¾“ [ïšó]ëmœ*Kb¿âDÈ~Û Ïó€pë'ˆ!=M¾:„]Ϙ º*‚È„!çKóÀS0’ üqº\ýšÒ>ýŽe<ÒWé­)·<ƒ`†i9`xÌC|}=8‰É3Õ0î„ÂD¥¶`Ô;ä’ù®%ª In|OÂ/¤YhçG2Tž/OGh&''<>ðötl1#A^|¯cw70ÍîHÏ_ÿÃDOq8Ñ ¸M¾sLÎN»©pvz”/ŽiyzœÎÂÅ23ž§SúÉdm%ј¹J9`]X=> r=ž.ÓÅC2ZÏl~Â߯F¿þë‚fñendstream endobj 4605 0 obj<>/XObject<<>>>>>>endobj 4606 0 obj<>stream x¥WoGýߟb”ÈÄpÀá8Äq,¥I]YªÚTAM¤RYËÝÛÞí^wïŽÐ*ß½oöî0‡±ÛºØ²€ýqóæ½y3þãhDCüŒh|Æ¿QzôÍôh ñåö]ÒàjH“`LÓ…C:{5 ÎÎ^Ò4ö»†4:DtœË4KD.gRF¹±jÖ¥êÝ…Òùåëîô·£!õG8<߈M1OäÞ™¯þŠÁÕ)ñ ê#˜~8®ƒé|ZIM‚š0ˆŸÇ‘W›ë .>_Vß7—tH9RÚåBç ÑǸBé\Z2 ÊWJ/­D–I}Î'‘¦~xÊÞR”ç°Gä$¿dÆIþ éÝÉ ½ýpÍGVú;•ö+¹°K™S"ô²KIMW¼KhšK*žž›ú™ùoÈ£ë!ºÒü.)•ùÊÄ®×ä1ä d5—ø`ø¶ÂZ©ód$®˜;<Ð#‘„`ú8ý¾¦¥Š?¨ò1š4Y}Œhä/Ÿ… ¹.^¬ñ_ë¬È)ßd2™#a%År¡4@,Œý·éïíoŒ Èh„óù’žµèôHèøŸ=ß;ÐB’"ZÕ¹pÒç±Ï‚ôXe2íÕÑ»º¡ýK)æ-ƒ €tD®JI‰†Š@ÐwˆûG§ý­&Sä;©g="ñ]s`^~Ȇ±I×WÅ뉅¼‘u€DŠ `ÞÅÇY»ÍæžÐ –YIBue©%ª FѬ¾*ôµåµŽ+eÃude$™ ñ(msV¸“ ­¥=ˆÁ{Ù}eR |É/‘Ì8n‰Ž 9P .ÏÏÁìYÜX„Ü“ðÍ åGò¹é‘C–ƒ«\ÅG¤@ñ,.ŠüåVIh»ù®=™ÈC½Zjÿ¶®„Z†µ#Ŧ»¶2öÈÿ%~8 ^QV œRIR¸ÜÂiýÝðÑÚ»„:·Â/ÛŠŠ‘z~úÂ$‰Y- yEyso7º~ã1Ú^Ü<§+•H:—mN+z>`dÜ‚¼ ž*%E,颪ßg¶ýîvU$KôÆ|•Þ·¡ I$÷í@’VEÍrõüªe’(¥Ek™u¼žvú/•h¯Õ!o›0“\XM~·ˆ¢"-êÌåRéYgÖí•xôï0̺ƒ2pêOü›ª,Õ>2 %nÁí éªÁl¾9—©t8æº[_;SñµÎöƒñí˜ qî͸`lçÈ{?9{HƒJeGìw+)Øúlaž*17hŒ™5¹áê=zëU·¹jçö^ü`ÖhÂw|x.W¢Tèàõ<á"«ÐàºÀ-m†b’¶åÌF>l0årËô6û°^.//iaMÚì&•fÆæÕ ¶…ûTIo@nC@ç4¯§ôÎOé˜+›±“ya5 ®š©x49 ^Œ_ÐÙdÛXî}Ô ½7°M4D?šð1t„jwÿee´“à4+­¤Ç»^ Ï‚qˆ¿Ð_Fá„¿úvzôÓÑߪVªendstream endobj 4607 0 obj<>/XObject<<>>>>>>endobj 4608 0 obj<>stream xµVÛnÛF}÷W ¤ ‰ÖÅV7u‘›½"BûÄš\Y[S»ìîR²Rôß{f—”L5n‘‡Æa’³s9sæÌþq0¤~†4žðÿ|yðjz0Hx¹ýeoèør@g阦s hò|˜N&ÏhZ«Móäââ‚æÆ’"¥É }#gÉ w2;:?šþ~0 þfE’¦)…jõA}¤oHu>³±’VðqµšEãíïGôZ”%-¥_˜¢sr˜žvž;ž> zÃÞ¨7þ¸sØxZ+¿ R9ß9ü9g QÎgɇ}?!µGô_IüÓ@HO{à ¤§³£NN^W2S:«J‘£æûþÑO¦r#S «k‘ßÒ,YçÉÊ\jO9£R ç÷ñ&ºT¥¤ÃÎJ_ö¢–4ìq›¾íúÞTò­µÆžÓ’ä¿Sz{WÉÜË‚²*ƒ“,[áÑØiaêëRf]ฤb…¶¾ _ ¦³4è„b³/! |>Ä–}‹i€ßíÃa‹Õ̤Ê*@Ú%&xÛq…éØ{îÒï|ÿ£PÔhÀ3p²ÇÝÿ³Ë-!äXV¥L«Mˉ³HŠ,sÒ+/—YÖ©€‰^È9Ýû>Kž{ãÀ9ðÐ×V“¨ªr3KçyzŸÙ½“½x®àJò®!`ä8ŠWdjOfE¥s4âçãËbu™SâÔqJ¦ åÀ÷k+솖¦¨1 x3¯ËrCb-¬d¿¯Ÿ>%-–ÒU˜-—ÒÕœ6¦¦ÚIŠi8 *aüBÚhÙ£¥¸•äjx`[¥ó².$Á¢MpÄj8¬„—3…Ô†L“Ú)}ÓÍ>!è§Çè1Ì…Âh{µâŒ.ñ¾4p¶«ÆýÑ(¡ÍEò¸Mä'5fŸªÃ&'€›m©ú³Í7|ã?Fë!Fbt¥}3ÁG /0_wÎüÕñÊÚÁÉ1ºæm}øp~Þ´9iíbš+£ h„™%Ñ(D¦'w=ʆðÅ3ôÕÝì(<¾<ý< ~4^6¨µ4I(0£a·Ò…vƒ Nòö)I+¡s¨Þûß®¾£¹ 7¬"¾è5(©O°áš–¢r$4ø¨Ö+Q¶`B8h)Þ©OÂ+£·\c&z» ~ ­­¨(²¹™0+0°uízuKu³ðTsKÂ3÷¢)ðñ"_ [Îl‰¤ã-Ӹǎh²…&¥—¥—V#Á•,71R.4¹…Yså.’Š“²KoâLÀBYZHQ€²U‰ÜƒpîÚÃzÂDüÏÆ`T1 ¡^¼âB7<ÄC¢p\2j\0 ïÌšûFøP/Ã>4ÏÃÐ(›Þ£ kKåôòç+NÐ8îŸé4‰‘Ï¥­ jðº‚|4E<'pŽS4á"ÎÒ\‹ÞO¿‡³\VÜÕ°±wšêMCÅ?½aÅá|„]!À¼Öuœí æ Ôˆç ™ß2)˜Wk…úý¢ ¸g4µ£ºJB$Ñ€°®·Yp¿êµíIÒJ”5ˆ¬§k¸X¤p×`¡a¡ÖŠ ]›Zn›L´nUµ)mAR«¼—š¹Ð&ÊÞå ¹¥!ã è,0inœÉþ «-G¡¯|Aƒ p᳕Ø}˜5c0)½‚üëíý1ŒDɤ‚5Ê^ànI7-„Œ•–ˆ™×Λ¥båîÆ9=jÞ†‘F=š¤p øŠ|¡`UÐõÛ‚—chç.çñjîp+(_"ýš5íkýYÿ÷µ/æ›%1 Ü”ƒDcùffž…}ÜÇ—gž ÏpsŸÒäl>‹ˆ´?J¸æa*œ vs´î?‹ÓÁ$0b¯áè9Ÿ};=øåào¬5×Ãendstream endobj 4609 0 obj<>/XObject<<>>>>>>endobj 4610 0 obj<>stream x…WkoÛ6ýž_qÑ.…ØŠ©›fA€tM¶[Ñ5^‹Z¢bv’¨’”]oèß!%J–œ¸HDuŸçžsõõhL#üŒi:³¿Qvôf~4 G¸ÙüQtz;¢ópJó„&#𽇳Ù+šÇîÔˆæQ@tzJQ©Ìˆ‹xa„ÌiÅò8åêdþåhDÃ1NÆÁ÷ÎÕ±áY‘2ÃÁ'™w¹Yœ6ñÅÅ—R]ŠÜ\ýl_9½=#k!¡!bN¦u Á|ÅŸôL™xX™%R!,W|@©| ƒ—Ú8q•S$ó5W†~s#‰‘.x$WJªÓö¼5g-¦¸ñ Mlz)ËJöÀÃúîäÌÞýl”Zä•ç»ùïÎ&¯…f˶à1ŽášX¾Z]Bû8b&ZKS²ï7Ñèl ª¡—®FÁqó¼[¼€b¡PZ±FÕXÞ‰}É#i¹%ô$òÑ&2MåÆ^E2æ´äHŸ#Ê-IAQÆÍJÆšP”T,S‚k/Ìm+ _øàZ '“p:¤âàXäQZÂò³&æP<«#C¯í‘æ ýçCvˆŒÚîÝ#ú‰!EÙ¤WŸý^×p ÙÚT@kL¿ ðõíÝ}~÷ë}sj¸ëenDÆo,2ÄÃÍŠ™E°8Yœ8´6p'êÞ]=‰åkÕ¬”Üä½ÓF ï§(ëƒbOÊ4ÝÖ#fq£ g1É9VHc)¦W‰§·¯i €&˜öádfkzž…g¤WLñø¾0ŠtÆÿBýÕ̶aÚ—ìi¼v'3|ò`×xÒeQH˜°ãápë´1G¬\ 5N—RjsqцQ=÷³t£²Pº{„öpÈRQZ3‘º¹bº?Ž^ŒòZƒ\°ä2ÖT•[PS±øsò„é'sqƒÚÍßâÄEíêpß¾Š~!ªÙÂh*¹F=Q…rw­?¬*²x¤,ý÷ývŠn[Þ‹Á•¹M¨—΀–%ˆ6q<Ú2LÆ"%ÑQŠy"òªÆz…yXÂaYVq8zÊãáÆf¢ç•×jâï~»þxóöþÃüãýÝ_oÞ_ÿqs÷áú—ÎØ§^q“§¯KdÜ©àU7çžný-K—Ì«Ñ ™s;¾rÍi e¹«&»3 yØÊRY…â* P" Ì@®,…àeÓq…â;f2hsS;Ñ£ÃÈðK™;ÂϘ•ëI¯›Çm'Á|qÒM- ׸m {Z4ïF‘%•yÌUºµ,Q³™maþZ2ã¸C¢×Ó=h5¤u9ï9pt׌Õܪ´µÙKg/$_Ÿ\æÃB‰LX… éš´°[ƒß€ËÌJ‡ÂÊ¢«àCê8“qÙ¾oðÁõ³?ý.­öänõßåæKKˆUm­ÖH‘§:î*ØóžÎÉik)\…wS™@^edÈ;ØÓB À„ë¾Æù7;½¨.‚µÕÔžú×½Wt;²F•QÙ¨N¯io›^ØÝ°›‘â¦T9™ð‘¸¼×ƒnî¬ê-öóÒû½¢C~‡W×m>¬ùï¥F±>üpì|DûÓó(eÀ¤]ºe• ›e†p&´{TÑmoöÁWh5ØKÏf%¢•‡°£ŽFì¾A¹@;ÐúîÓß8*íʰ¸€¹åe¶D©-u#øŒÕF÷×$QÑvý€È°2í~64'±»4XØåG%¿m MÖÚª#¾³°µ9®/pËþ«$ŽÛ•„µdj?bª"4ßOWggƒ„‰”AjvvÁ†Q±Ø÷¸ÛÆ^/fØö•døJÉ8Ë-É[aÂNkm¢FhÛj/éu0î¿& ûǯÖý(q“6¨:¯?t&£³ðåô%ÍÎgõ~Šm}8 GôVFeÆsã|Ú— ¿ÕÙá«j0¼¿ÍÂé;3ßñtd­ÜÌþ<úìû¶oendstream endobj 4611 0 obj<>/XObject<<>>>>/Annots 1565 0 R>>endobj 4612 0 obj<>stream x¥WkoÛ6ýî_qÑ!ˆ‚8Šßq²ÐÇRtŸ¶%X¿(h‰¶ØJ¢JQv‚¢ûí;—²^Nì¢R¸EÞç9çÒŸ{CàoHãÿ ’ÞÀ`…?†üñ÷ÛÞxzåi:¿ö”ÐøêÚŸîžbºëµŸš þ¤õ¶ýŒ·“+ÿºõöÕ}ËóiÖty;¡á€îWˆkv/¡ _ÏÈ•42 dŸ2­R+ iC"'Ay"Œ­V}º$¹ 2·2$#EˆÍ‰ZG–¶"µd5ÅZ"¯Ø»–©4‚·:„ùHoåFš>¹XÃTN¹J²XžÝì èb8B\žHCJ5…jå²a%Véš÷ù¹PWF'·f--Å"]0êÓ-‚—‚íö9ç%z厉¥Þ`a•¦þA[]Äa'˜¥¼áçËÛÍÑ/Ôo„@G#<ÆSè½Kí?".ˆ~¥Tn©ZYxÃÑx²8û¹²ÇE÷P=ÚˆxˆÍ»}ù`J3 Om8rÇ-zîÜÝ#š”øº°~fà7Nžs}N/ðwÎqŒvÎx\¸üÆþlvÅñÞGܤH ä2k(VK#Ì#*e>å„^XÙt*~dܽ÷ö4G M"â>- K¹Nä6(b•àDØ'W”.)€R¯ƒ·ºñÝͤ½MpU¡Šª@C-9[cuG½ikD–I“÷éc‘[Z4Ï;ïñ$ÂPY¥SÎýðHA,ò¼Œ¢Ì¶½Þ‰F¥A\„Ãi$²t˜cÁVóHe9£»á ØWä…ˆKë:EiÁ¶˜™“Z£Ã"–(:"bwŒÒ’äÞI·,M=JD`4{³ÜœíDÚÊŒr« ª'*¨²ol#¼Ì…¿@˜^‚ŒØîŸ©6úô²]%‚€¨MÅgAKP´Ï6RAÄÑ.%—¯l[H[e£6.&¥Ž»—·Óª ” ·ee*ùó`¨¶Rj\ƒn«µ“FU cëvBÄÎÑ£së„gî´©£f®Ï+ÇzË¥pÚÅy?qÂE,cîÄ—C~S’ÂÄô¸¬µà³ðÞ”-ª…í¬²êíD¥gI'_:˹5E`iï,ÝÔúHÝý´¿’Vje!g­sNÄÜÚ—¯D¾ïwV¾vµ÷Äío¨°'u/ÛxÚM‰ ˜)¤dËÏ!BP"m¤Ñc Bº¹ú²ò!“O?à†›¿7ªvÒ*ël«´ ßIØëóóã]Ú/nX¡½7 o:»š,ãƒeáÁÞ3“gvè9x°ÚïÊ1Ì §liŒ.*K¶Hw*\•¸ÅMªùØw3 š*o…‰—˜Šh zÄ· îM-½8Ž%â‘/DüHb[§„‡I¦J!'iŒ6Òöõ†µ*Í {¼­`O I/–ZçöC#·¾zQ…Wr¯yµðþÄNmÓ0 r ðô$ú©òò‹órÙ˜ò£,û­ã‡0 ßÔ«tô„¿De,fýÛÚ¶ðÀÞ'L­™YYÛß™¾¡–…cŽv9—בŠCÊ·Óp;¿‘Ï[Tù¸´0èµê$nÌyÎÞ½q¨NÜà8@ª›£ºŽnè=Œ³±éhpC¯jé§ÓV Oy.Ÿ–Ÿò4e ãf Ü\-p…üF=såïÀ åw¶çw'8åÔ¡SW¹ÿåô p¼ÄU Ù2g«2rß!"y©+õà$àx­Œ­Ú×WìùîZ2œOüéxJ³yý3‚ïÌ#ü|£ƒ" 8/ ©r÷ÅU µ¹?ÁÁ†­]ñ‘é`æGø¡`ÇC^úý¾÷Wï? ƒðendstream endobj 4613 0 obj<>/XObject<<>>>>>>endobj 4614 0 obj<>stream x…UmoÛ6þî_q(–A)jFò[\·Ø‡®M [·ÆÛ€Á€AKg›ƒDª$åDúßwGÉj•TX´xïÏóœ>ˆé“ÀtÁÿi1z³Å"¦‡Ý—=ÀÕM K1…õ&1,^&b±¸†u¬bX§Ñ…;J‹Ù¶ôvýFGí7—¯.×ÿŒb'd’õM~>ª<ûjAQÉBÒÁ÷Æ"Ð/ö¿º™ØÃ˜¬Æ“i›;úÕx\5³Ö"‚õÉU9H+ËEä5h®*Kc=P\h<¨çó۪ǒ:DÈ”Åԓ륯,¶e½„d&f\—µäc-Åþð*W¾†jg¥UèšÀd?9[/ÄrÙš‹ð!ÅÒ+£…ê×ÀCŽ,¢Æ—>èAR×PZsR:K}¨äÇJgX"}iH¥SN&c¥rJÈÖVzìU_+¥Ã,¼´ô]°0 F˜:ãiðçÔ|dcB r˜Á®îþº}ßÙÜ[åÑ:·{(sj—ã 6¦h- ýH0ä\–KH%É“T¹$CðjSYhjâÉu•œ›e:„ %–ðC‚1ǵk0¢¶îÒCÈ宺‘¤&&’·5÷º…•JÏG+m*M;© ¤A¹3•‘l‰àE`]³õMx”VÒM5Ø…É*ҘΤ)–@OïUYíÝÈðAe~^§t¸P:Í« áYF¨g=.ºj8[­Naq®V´3HéüÛ³úóÔËÓ§|óƒ «é‰Ç’¦O°‰B šÙÖì·–Öþ$²p¥Úð·#â‹ Øm*ͪ}þÓ&BÁ»am.ùÓ›q…_zµ…_W7Ë–Ér&æÓ9Ì®"N:='"†·&­ Ú¿wB 7Öãëæe9ø™Ç 1Ð+‡ô™L'ìün=ú}ô`Zþendstream endobj 4615 0 obj<>/XObject<<>>>>/Annots 1576 0 R>>endobj 4616 0 obj<>stream x½XmÓFþ~¿b„tj _lÇyiU$ŠzpŸ ½ ¾Ü—½‰·Ø^³¶ïˆÿ½Ïìú-i(jS¸ñxfçå™g6¼?ói†¿>… þ‰ó³™7Ãþðùãgá›Ñ"Zx!åùÞ¢2º9‰9­—Þr¤‰9ùÁÂ[”Ë€ÎçÖ©øÞ¼•Ø«S†U®Cϧ…X7á5\{ÑHé ƒ™3\ó‰V°†ƒÃù‚½öJg8[µá„œˆ•ØÒ¦KTg¤µ¦ÑÚ•gykr‚=s9Ø ʱ íbvdj«­\–![ZÝŽDúk´dPŽehƒ5»íMÇ2´Qp¬ÉЮ‘­ËŸ ÆUެd‹4’¡ó[#íH†v¹B­sŒXÇ>W;²’u<’aÍиAëLçmãfÜãÈJ.¦AfÓˆ 5hG2´ Û«A;’¡]E|ì É9AÄÙöÚ_7£1²³dötyµFâxo³ÃÄ-V· h“ØY›Ñ&ž¬é™Ù7¹,jz)Š$SÅþñæÏ‘';ÖÓåg?Ù)ΞG xšlRIõ¡”¹(+OQ¦¶F˜ûà÷|>mr]ÔF'M\+]{âôW­û©‡!¢…ámÍèØâïñ¸÷û£Ê¦¦R‘ËZšêØø??îUS×ó® wù½O}S”¨ÝNFJâ~ce§aè͘ç\{Ë/¶w‰˜ZÔNž•evàPb]Tµª¨+ª5)® ݉¬qa È»Qy™ÉÑû$?~ô?ãây ‡©N¾±\°öã ¸¨4…¼§DÔ‚Gôch[†¢Ú‰l[vyÕñÁ4Xϧ®¥×=OE‰Ñ£ð‚nÞ^¿ø-2RÔ–cô޶¢Rñu¨Ôh%¦•îEE‰¬b£¶2ñÞ0ÊµŠ›L˜ *ÊU­îãTT5qJ°àf^^áò`ùi_îIá„9~iÖqS¢›­ƒÃÞ7’Àh¥L_±6FV¥.Ÿ-%0G5SŸ0{YS&Š}#öÒ£+mHÞIs¨S~Yf•Dà]~ì·©œW#1NìP768â² -ÎDUá!¢1âÀÿ¢T§öa¦‰Ü©¾úþzôRßóá^,M!¤‘©X0ùV¤jR¶ÄÊäm³K¼ìzÁnB«ÄQ8U)cµõ®MÖ ÔtC¹Ú§5º’@bF"«‚ò&«¡›PÔÍèfŸÚú¡|vûTö<Ú5…ÝmRÄ;(…ÑÁí×¹d3Û§…z : àè|x®ïXƒs\÷ìdÀâ×d²µ<¼¿<,ÁÜ[­ØÆÆUIeU@Xp'õ0¶¢S hl—$íT&§ÓXç¹.²C dÍ éúW]¢• ©qOºu D§+tuHÛ–÷ü4°³Šôàéò=MËVâ¦)K]IÛÃT$$èyß ìôw jùS—!ß|pRÀGáÎBJ&wZÁ0In'n¦H\ <]´í{”·é#;ã1´«€Ú?­ž~A?Òö磗>rjϽ( ç_r )úQéÆÄLþ FÐ?ΤÀÌ¥øÄÜx&ªZp0í¼K¹å–6¡6Ìãx&ýc4‰Ø±[7Ý\3+¢2èg¡k»0ÆC,[ ×6âäVhÌÓÇé]¡ï»Ø0~8‡¦H¤qkq+Sq§´±€° åº¼‚óÖC"EF÷ªæÙk=h†ut’é×Á×rÒ½QµDÁ@á;ÑVükQsyIí’n73âéX–ï”U’ó×Hài¼Ä;£ÎY“Hz4Dþ¨µPPˆsfÂC‡É'¯Þl^¿ÙÐÇþƒ&}:üâV,éü°ò²-èßþÄóçñÌÌtÒ—{8ÐI¢ ó¯E™e•er‡¦d^9{G‡Úî‚ n¹XàRQOù†k   ûœ9Õ< ¡W½“Pºz»k·0ìêéàÊwGÇõî4E·È*JßýÚiw½¶{ƒv<ßxØ3 S?Çÿ@„'±µ+ÅžŠ•ÝË~C±;Ò­e‘eÝRé+À\ÕPóVm0l„/9±¬¦SÇ¥X`Šª•ÖI<ާôm*ݽÌ#Ђ½óJ&nÇÆ¨3A7·=‰õ}жƒu™¿Ã‹ùíc·§endstream endobj 4617 0 obj<>/XObject<<>>>>>>endobj 4618 0 obj<>stream x¥VMoã6½ûW 0à,Å_q’.šC?RäÒm»^ô’ -Ž-îR¤JRɺ‹ýïIv”4 Ú$A ‰ÃáðÍ›7ó×` úÂ|Éy9øa5˜dú¸ÿ¶prµ€éV²]^Ѓ–uzÈG×Ra"ä*âv¾¦' GK¾NUàVÙÁùP*kw0ÕÁ¡Ã *lë]‚BE(ÕÖäb¼F$« \ÜÐ~Ù”<¨£Õ§Áާ3Šh´©]žŒw­çæ¼ ~´¨'A–ê3F9no]Öy¨¢Á䳎ѸÁ$ k9Ö»--:Ì1FÈ•§Ð\½Q9]AA¬07Êr8'Wg U˜öõÚ"¼m–;$Gàן0O œ†JÅÈ’gÆb\ô%ŒY{ÑÙ‚/úž£Sv–ª¤UUÖ6ŒŒ¬ŽÙeLjG¾àfÃÇ€@˜Ò¼Ïó:$—üFNgÇ•S%fpEð‹*+Ûä·zîk«á.˜Ä¤È½µþθíwçÙœ‰3£<ÍfÙ|Noz4,½® “Öoç’™5ú¶ÖoÚÆÌ¼éh,ø¦;èp}ÿqõÛÇ|Ýk›àÛ»þ.ã¬qï½ãðKÂààÖbŸÖ7£Ö­wþÖû§·ç›£Î3gZõúµ.ÊÚ¾Ö…6·ÿÇÅð[š,âªÿX²8Ï–Ë3¾w¿ô9ý¼ýP”o› 5‹þf•Ø}Þ1[v5À媘¶L¬~!¬Ú Ø ƒâúg)"¶ß’b¬™a nª‚€M†hÜSˆø€á9y0šÅ@TÍk|ÊÏе¡Ç°¡«!Uk‘ ®ÊÛÑ© *å•ͶxDÚ“øC„’`"•0nFÍ®Æþ樗1añU`4ã͈]Ó‹Ñí)OlÉü’Üe¦…‘tºÃU$>ŽY_DZI£4¬j°æ³è||ÑËËK¸ð=lÑíoB‘?¸,ÛUAnØa1™ôÞvEïûü±¯?‰i!z§lôL.ç3‹ù©l¢µm!*ظéÁ¨!@ß÷´ ¤ÇæVj@ðaáŽÑS+a5mÉÍUB5àA«¤ø#áÛuY‰ƒ;Õ^w5é…RZ,ß±=†ä’Z@×]r^üõ”ܼ#âåÃ-¡“pÊ0©~uì¢iôúujÿ ½n„ç¡^?¹ûòýbèy|’*­2Eé¾÷šoí’±œ­傱£Ž›ÄÍ -2™¨ÙÔ¸¡N%œ'R"‚m¤n¼òóDsÆÿJ91z’r]z„,-©Û*íÉáó…:l"éúpÓßüˆp•žØÍÃFKæ(ÓGß¾‰ñxˆÛÐŒÀsÂi×a.²i6ƒkÇóc¥ššµë=oXd2­îO ‡CI S¨iöùðçõ/„—+Tž”ƒd> L˜ÞQ o5 -S™{“œ+¢ö<"à׿òÒûé`–* ˜鼘5—>o'Åéù";ŸÂò|™5Gz<Ë&ð“Ïe –ÖÆÛ¡Æúø¬i/ŒÑ”0Jf*™€Ùìt²Ìæ3š×©OOç þôójðûàCQ¯Mendstream endobj 4619 0 obj<>/XObject<<>>>>>>endobj 4620 0 obj<>stream x­VÛŽÓ0}ïWŒVjKkÒ¤-» ¸-Ú."ˆ—¾8‰Û;ø²¥Bü;cç²ÍÒh«*±ñœ™sŽóm0ƒ¿3H–þ——ƒé "vz®#¸$ ¤kˆ#X^ÍÈrùÒ"¬Š ͇BÉ ŒoÞ¾ÿ”ŽÒ/ƒ¦3/†N¾‘¬.íÙy³UúüŠS[Êe‚ ¾ŠÆ|t=ŸÖ¦c' Œáç-“à +&À-P!ÔÎÀ-ް 258(Œe´µ†J!$¦ k¥}§e%Ør…ˆ ¦Án¹µ“¹åJ>ñEéWqÇ$I°¦Å°A@‹bÕ^éZ`Ùj?zU…棙uZ˜>gO{+~ÖžÀûVíîgúñóÍß$¦×4gçó½(Uá°ä èÞÆ\æÂ Ø}ÅJZÂôVBz÷}lì;æ [ð½šÜ•d5êýx;Ö‰(z(Ü6ÑîÑ#éÓÃnY×NÀÖzº`Á°Ï L®ye9J@P¹qtÃêRVØ ¦©v\Ø)ýÿÊ;ÎY3ã„…gJLæ«QÝÓ+˜Åw^´¾"3Tè;g+g‘®š–~oS?ÓòÀ³~Næžt©Ç£<Õ}ÞM³@c_‘ó “ Œ°[TPCuÚ£UõA^ ´« %í•Ã.‚T$ÃZ¡Œ«*±÷AZ ’bHõÆ• bçu˜£þBJ'pS+oJbJ¥û™ 8R+‚b'Ìèݧô¾[5&td¦6Ÿ#}ƒ;·àtð.ÆÉ]Z+8¿1¹»™“4ÆŽH‹­* –Yzc 4¦0»ô|ÆaFµàha¾ï9_ƒoí–ÞÖ4†—]ÿá<¥o/j:·Ž× 1ë®ÆùI»ç^ÿÉêž×<îœ Ö«ä›­¡Ôÿü6=.‘ä Ž›ßߪnùq+3|/¨×N×ï/ÞUc4ŸßMu-IãËØ,Yø§_§ƒƒ_ÓÃôendstream endobj 4621 0 obj<>/XObject<<>>>>>>endobj 4622 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?®“ArI·ºªýÅ]íñ*aE)°Û€¹Äfxÿu)‘ ª ‘–œ´+‰„8š .)>IèœL<4¤* žáuí80$Ö…Y+¤Ëo*YŠÊÑë‰à œÞ~ÆìÒç-÷ýFÎJP©KO3IÎ YKÆð|Y•“– áeÇäÓ§é }ÛÁ”šŸÓ'ê|Úã-Óêßwù±çüÄP)@à§m[‚0ð‡ˬ¶¡G[÷]d0‹ôíæ"ƒêðuΗ&¯±«)ý •Ί:—ô®%`¢ÞíìH’dçûñ.J2Ät¯ãXßk¦â‡5dK/fdŽ1!—YUAXԸĜ‚ÎmðiÙÑPml‰ÅÍÿ &õ–$)j³F-¹}ãOw“ß#lÛ;³¶P±9L'`Øœþþzû’.²Çµ°¹Ÿ»K„ ЬBÃæÖ™ŸÑ í2—XÈ Ëy|Û³a0sðÜ­GtïFÐfŽÄ¢!j´ë½Úc‹¦Wt ½\)S;$ýl­áXTŒý0c¹bXT€Q WØ}˜PöŽ9ÛG4IÿÙÅC\|]Z±æRëp`ÃÚvê‹àìÌ~¯w‹‹ úƒÛVÛ¾›™ Á?ŸdÚ»Âô‘ë,blô­[hŽøÞvOL‚Èe{Ñ­öéNÛÆÆ]1TGÄáªáÿàê2¥#_q(eª“>ýb²0á¢,LÐ tâ¸ûüCœ˜7)œïFýq‚ûƒKƒtÌ·þ:9úëè_Ã^‚¹endstream endobj 4623 0 obj<>/XObject<<>>>>>>endobj 4624 0 obj<>stream x…VïoÛ6ýî¿âP €cØŠ$޳u².) ´NÖ80ø -Ñ67IT)ɉWìß;R”¥ ÍÚ¢¶%òñîÝ»wüÖÑG4™ò¿0éüºì ƒ!Öÿ™-Þ iLh¹¡ñ¦—£`:½ edW ivߊ,‹¤Ò‚zóÅÝÃ’¾Ó<-&cê©”þýùdùWgHì^FÝÓSú,þ–ëtK½'ìÒeQ­Ùœ[0_Ü2^µÚaÞœ/ÝXÌÁdREÔ]j c) 2e,ûTì$16çàvtßÚéR¤Œ µ—¤r*sýä·SŒÇÁd"¢ „"]®cI=#ó2.|žU.’š‡¾ÏØ.{–Âø˜Â!“‰È(’a,Œ(”Ns|É'Š<ç¡ÎdD¹FšEµ¼¥9ÉÍYÐÆèĦži®‰Þm£RÅ`ThûJ¦¿`‚6 9hæ«0æQ„;…y"^çïnà6\Òè,8ã"qégü5ê^cºb±0pˆÔ #bÎQ©4+ Ú‹¸”¹ƒðåa€³`6c„yJ"ŠêTÂH· Ɖà{ó$¶Fé2o¡öI\_ƒ»Lç¹âêáhÜ3iCqznÄÐ ’O"É «g<Ö’º¤G²m"y‰‚;Q B6!>"ì=T ¨ê¥-4ü:Õé`ñðéS@Ë~†"%àŠ0Ô8Så;T\¥a\FU¶í²€¢‘-[3hÕ¦±K±Za¶âÇ2aŸ+Ò´*Q0¢{Å™6Jä“oCºÊØÒ.Q€ÆáõYÈe-sðÇ%—»@"냞ŽcýÈù@ÒlDX‰ñõ惃 «šëU±kî äì$ÑÌ ™³åÞ9J%½i„¨7€s¬ªËåS¶êVߟV'ín¯žÇz[¯¹»½Ÿ/ç_¯±”ü„~Å9“NÑÈ^ ÑבU€ù7SÔˆ‹ÛÅâúãU€ '•[XÜ˵…o‘PÁ©tßDûóúËm3<ªàþ‘F¿Ô^«©lŒ”«®ýÑ㘠ڗPø9r´µÍëž9_ü! µÜ‰½BXk‚t¬7á­ Lä®ÕtGx˜ÁîšoH¤ogÂlËD²©)†Þ¬ÖŽõe¡8é£=óШ¬€=]¶‹b¸J)¶,šPâ5|ó掄aa<t!güÞWš–²}ÒZD}ÊŒÜ#,J9ÄkÍ)3zkDB¡hp”aM:}­9Çô¡6NJd±ÓÑ‹~Ywå¦n³# n¦„¥1‰yÝ  Ø!ÓОø±ç%íåÜú¼B Ò2YÃÎÞÃóWÝTÄJZxnmÏy ·6û w¯‚[Áo=~6@ÞÿBÃöé·‹gÑØøî…Ü.ÇSšßЃ¶g\þÏ´Ð\^çÞm¶ Xk5Ìê䙸5˜œû æ)nf?š¨©|¤H‚/ ¯K¤) ?$¬Eåe–iÃÝ™•ØFޏ}Zcl»Á*EgǽÄÝí4lIËvïEæ¯v½{èg~׎\ϤmÊjüÒÿNËºó˜• оH£òB¯Ý¶ºr.œ|k|w[^¼Äþè?Ò™t¾›5Ž•;gˆT'®Ê_ab°¼^uS>½™UwÕÑì,8ŸœÓt6f#{ñ¼ÿcþq0†ô›­ËÙ"Ÿe¸Õƒ 7Û.ƒQpN–ðHáfÈ­N©Hœ·Ó7tÚhrÁ×ËÎïÿeÏendstream endobj 4625 0 obj<>/XObject<<>>>>>>endobj 4626 0 obj<>stream xMQ[Oƒ0~çW|Yb‚FX QŸ4:ã‹ñBô¹”nÖ@‹¥›áß{ÊÆ44$=ç|·Óï £/A–û#Úà¶ X̨xü٠櫆rM³y^ ¬Ç>UDX~JôŠ7pC'{˜5fOÛ¶’v®kÌžÒÎßר$x×5JÖp†úô¶•V‰q¶ÛbÇ­âU#GJXéœÚÉfˆQ4œøN˯€!JRòZÙšQCÝ;ËIñ޼ù©ùŠ2ŽþÃÑH>BÿB…¨•ÝóO·=ù»š°Eœùð)©¥iœet«Lx•\éëÉ É{ïDj,ÎÆæ|UL$Å"^fKùÄõöñø¥1ô í¸SF{Ê(eûáèÂ'¨Ã˘à†V8(½ù·÷ûÔò5'¸ _2IéÝšd…/Ý—ÁKð ÷W‘ëendstream endobj 4627 0 obj<>/XObject<<>>>>/Annots 1630 0 R>>endobj 4628 0 obj<>stream xÅZMo#ǽëW4"Ã=ßœ9ñn6ðÁðÆ‹.£a‹œ„Ãa†C+›_Ÿ÷ª{¦‹ò’µ ´ž룫««ª[þÏEl"ü›´à¿Mw-"ü†1?~ùûEZ,"SäÅ"5)óEæÁÖ\_,rY&\•, È)Ø™8-•"`šˆ`§‹¥)­IäȈÿ-‘Œ†Þ,ZÄŠuz£Ò‹f‹Ò‚œhÀÍéïÌŠh^¹uVôÈYK€ŒEj 6aL‚¨Æ4š"ŠUl‘-Í*Ü™$ª¹bÃ¥¾x( 8ì¹8ΰÒ|&5¦ÃÅ)«0.i4È*L‡KDX± ÃaØëÆ'3)ŽK’‚ds¦S%M± ƒÍKnOU,öQ ¬Âp*—HÍ,~Àv.ÙÊ%C!€>)µQÆH̤Æ`ãËR¬Â`%·«0X·Í³f9q9Í8-SFX]Rjc ¤¬âàH#H¬0ý•ÕVa°yÌðϬ RâR-FÂ%ANqÀô)g@gÖ‰Æ~Ó£‚z9Ñ€éSzÊ*LŸ¸GAÖ)–jÒ)¤O¬SX…gÅ3+гÒ×|uiÅ CËÌ5«0Ø‚9dÎÈdK·=Øsp¨WA®†'ÓhÐCQç¯(èLÅ ’ § SŸ@j 6ÏOX§6Ÿ6N–"H ь•) ¬Â`ËŠ>ͬSŒÂí²”9› rЦÇlŠUì’e@± ³\F8ÌufQGÄl*> ³ Ócv•lfhìÏÊ?vNˆ*L0Å*Le{‚¬Â4+ÙX…¹žŒ±˜YÁ¢›•Šu.CDV ¡Ìd‚œËÃ,*â «0’d†ÙäTVR›¹Á¡o`8Q95DÜqЛ¦È+‡TO€N*.³Nç(@|´Ü‰cð=çÚóÄýp£^Wä‰eX›ï?"ù–Ð|s‡˜¢LËÄܬä &27ÍeŒÏÏ{ÛÕû÷7ÿRä}F40A)œ«ùšÐpùãnúÕ±Û~GI²1u_RŸiúݯv8xRÜ ¢6扢Þ+.*…{½MòÈ<åˆû¾²ö[ïÃú_Ȩ́zí°3]=6›v·>õñÕÍýbX1ã÷æÕÍýsS¦©wæÎšU¿³æ¡7³ñ¿¼ñb'ëÿû×m×në¡[{0coþzØÛf4?­Ýve> ýz¨»îí·ýfcÍ`£éï͸i¦ÙÔ{äÝË6à ò¥[Îë-ÊÅ“'‹7*Çr:Æ8X†ÁhïÛ¦æI—"Žú{ßõ”,/óTZ>~[v¾tÚÍ¡é÷öm½ï÷ŸÏ¹¶vkÇsü´­Û!Ç%ݾªÒøT+|nªI3º|\[ÍpÜÚG™öC}h›¹ú†o„Ìyõ¢È>¶²÷8¾Ífûoœy8Võq;Ngj6{–eÿËíU=¬L įJŒ°?OœìŸ|cukÄüÐíkDžõøýwß™Ñvûm=º´J_}Ó?Ø»ãzÍSè×mö¯Òùýq ÿüZ\f,Åïû•5k»³ƒá¡_Ÿ¡ ~° Û$b³³fÛ7õÖüŠ_Ôwþ¸¾á¾\³ ýöp›¡T”¾YÙC3´û±n/™/·ß>]pkÏü°›fO»òu?ë~ãsòö²³ã¦_ýY’Ô'è m_áÍ;ç{ÑÉøíÓ5“Ià÷§k×õ»ù9_…î]»{7}ãé˜}Õ á£Öllóï³YìãÙl¡Rc;Ÿ=´D6§³­ï¼;‡hžsóîkaòlÁDá¦É³ÙëlwgÑ2Îfýè¬ÖΙ-ãfè_K_Úc÷ŒóüÚŽÿƒ-âºïìT¸ýo±ìñ¬~ã'Fsߦ†ú³ÿ7œ~¤W9œàéé0uËáõäãe}ÆÇkjϽÚ`4óoa|’Ptœ¬á¨qäíh¶õn}¬×Ï™iy1ÿw+÷÷ó~l;ÌMÍ£òacw¸ÙŒÇAîïwŸ1ÉmϸR¿Ø“Ó{Å”BÏÈŒ[ôyhjYä9LÝõZ®M̵0ô¿–U»•zÛþO¦ù—ee8LOÜ«&ÓSïV¦>Ž=ž0q•ö£ä«8óå#òýÇù…Ñ©Ìþ¦–2g>zuÎù×ÎÄ%xœVŒÈßn.þqñ¨&üôendstream endobj 4629 0 obj<>/XObject<<>>>>/Annots 1641 0 R>>endobj 4630 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Œ?Ú<- ü*„Å„tŸ¹Ë¨´v|‡xr¼Wo÷*‹4¨šë>mÉo(×ÂWb|0Çêx$q›i²[*N–Ÿq6sßÉ&m ”H'•\fTºÂ¦æŸš¹ÿñÝ«£Aåøá <{pK¸‡t<‰M5GHËt“0)øàÙôë½ÎœÙ$šâÜuâÙŽVÃv-Ó&¸'s˜ÜédÛ>ѧÓ^R`±·NM+| Ø7)(÷)Ñ’v…Ê :¡4Räö‹Ø¸(Q¸ØÀW7:`F*>2 qƒ4˜¶Z%s€wr{41 1¹ŽP„8ÆÍ£u‘PbOƒDs½‘Å–Ît® ›ô“-ÈfÉY|öñªÏR’`>ïr•Ð+à†AÙ91íEÝÙ:¥uOQf!ÛÀÔ`Ca&â¦pdOÙúUp‘N+m(Æ'“Ô¢2«4§• ut„ùµDÁq“T)ƒÏih&óP‘05»= ¯è”ë3Rªiø+V:2[aøå¥¾îäÖ–P_fü$‹í6K[>EGµ+Á³X+®\H"`©„Þ)¶ ~ë­*“B‘éѶ…ì F"û²¿¶›(ˆäßÍë*? þŒN¿¾©IƒûUÜÙäÝ¡ ïN"üÖõs+.ªÚ¼ŸVžZmMŽÑj°nÏËgò™ìPò¡¶+ùZM‚¨ªs®ñAE\»•‹l{Aìqž—½ë‰“Ó@9~)~€ÜèëV°Œbœ}·~Ž9™KºbpøDä‚jÅ« ÷×"8-πȵµå ¹Ûö˜£|èиµð¥¡œk6Z·~Eÿª«–¾37Pç£ÊðUæ;äçÆ?ÑAƒ^ðÐÚ½>/XObject<<>>>>>>endobj 4632 0 obj<>stream xWmOGþί˜"Úb~!&iÕJ”–4R”PÅU¾XBËÝž½°¾u÷ö°­¨ÿ½ÏÌÞù5ð¡„{wnæ™™g^üÏQºø×£ÁÓÙÑo££nÒÅáúÅOèüæ‚z]å¾Å›Lîñ&m½/ðj:=ßtéM2`¹~—:ý~2àSÖ2E`¡»w:|pÅäÆ»Ù§û‡q‹ÏÞAû9AÛ"‡K:s÷m²§³'e+=>ý™@1CÉäad-õŠD©<²ýÄ}G` ’áðR4L5ͽNM©)ÓA[’òš ¨tdfsçƒ*BB_¦*)7Gü!𡲖\Ž÷šª"ÓÞ® ‡Õ\SêŠ'íKã –žª"³:£û.¬ÕiÀEÙxÔg<ÐScMXQ^Q€ð•S¡{J¶u ™&k5ìš²Óé¬\E%ðÚì<áØ‘×*Xzt!(2—V3]Ŧ)wžðœ§\=9o‚ÞÁbU1©ÔDT=nASü7Î?–4n©‚ôR{‰Õy`“6«ýø4‰„xK=¸Æ¼éô‡ìc¯›ô!@35ÿ7ùa©‹ä‚å>›"…qŽ£DŽ£Š("-)<ðʲÁ…Wó¹ö1]h/®µéó—÷ï85nœ ¶{ΤƒF2›É·¯ëãSÎŽ¤²Ô^<`¶InFŽ2öДmRTÎÁ`ˆN¢€ÀÈœZß3^¸›šiQfÀ²`¸P•:Kè†õR1¢—kçüŒ®…HrÔ Ý®ÂÙët~ÎΛ¤II4öǨ88Ãe÷uG€ðsÒ£_ årwUr9Ž['¦˜Wa¿Àþ­EÑ !û8®BæYŽÕ>Äë²²a†ÛB§÷M,¢ìòbc|hÚ¦º-yЬX¨uîYCe+u™W%•Пn¡Q£ü€Fá#;à¯A¸̪tÊ,3h#P;š¨S ê0QŽMq,,EÖǧM¬…1uªYCìh$})&’ÊOt íb»ŽÆJ‡PÀ‘P5„sË\æm¦;vhNÍAWDýÐŽ¶¸ŸhÅ~Ö†€ôžq[˽šp»`é8Òð ` ”G@ùD˜Ë_ ¯®DÔºdÝÚ èe«J"M¨ŒëW¯êôM ÀIQÁÅkƒ×ç,Û4‚-Ý]@|¹EsÑÂBñcØÁ¡ìB­¸‹ƒ @qw™ædæ²Êj„…ÛÉAÆ$0 1ðuKZrd·<€-IßÁ²&€4–ܤ lbð4šá›âæST³{4=d¥iCOÊuÏ 1Îr³äÈãAÈžÈ@ÓË9Æ·ÑT³«àzMô‡ªÜ ËܪTOE/eFÄoLı ÛÙˆaÄ4v¦ ´„ˆî~rÂÎ Iḷ÷›hlFžM½·7g@ÁíÄ SHZaY@‡…Vä»Ð:cI’žÏ3˜¹ŠÏѨQûºoŸÄNô¬M á HÆÄ‰{bÄëPy'˜ªqwgÃËäÀrï£5à&ôÑ»)xÊœ-s•ç#—çQna—†t©Uq*Æ¡½ç9êh€h€‡õtªG¹ŒfžWõ6R_ÓÌL¦è•ª^F€ºÍÎ8’Z­<žóªA n²BžZo9›]æåY´4I3o–mn;´ªGņ,ûáÉÈÆÜÂU6«§Â|îÝÒÌ”ìëêe·+lšÌ·3væN mÎJmó6&l#ƒr/1&1£Ç]ow­Å„®/úß¼ˆT=¸Ú˜C)ªÜ¹>T¼¹Žê¡£±§?£ÊÁ ïnWW~rw«Pè£ Ë˸uüéÓOˆÀq›~`ÓñO| —caÐÇ¿?|8P‡}b{x¢±ù‰l§ø6׉ó›^óu‚×0ÙB€ãkSYÍÎ8Œë=¢ÙjÍþYYk¶¾ª0³Uσêÿ/PýoBlšh¬z ÔzMž±«m¼4ZÎoÞÔëgïÍEòz𚆗Ãä2~ñâqÜé']ú}{õçÂç(ݹŒ d1ïÉb^ï+üE_w‡É ž×÷ iXŒŽþ:ú: dýendstream endobj 4633 0 obj<>/XObject<<>>>>>>endobj 4634 0 obj<>stream xµWko7üî_±RT¤³Žâ¤ /R×­•ÔObrGª$Ïö5Èï,y'ëá&·†!ß‘ËáìÎìêïƒ! ð3¤ñ„Óòàåô` ðpýÇ.èèt@'ɘ¦94y6L&“§4ͪMÓ.=¦Ž©|‡|½’¥XõÈJ_YM×¢¨$=>:œ~88:¶‘ÔboÆ{?ñ»Íxf¥« oæè'º¨Ï´¿:µ¦|kôbÖïf‡?ìîûYÃEL އ4pÖq·77;‰Aåa[4n.Ú=Óä—ÊQj2Ù£ÚT” MNJZš¼’í­Ã Z Gs)5)í¤õ2Ãoº¼Ò©WF'ôWEÎl…r+™*QÐ#Pg•˜Òµ÷ñ]–âZÆðòv%t†ð^ Ÿ.)ÅqB1éq'iQJÇ8TzcÅj%-Ý™òÍðk¥(Š:.ZšB¶´T:ÛÐdØõûX“Så û é3ñÎ$ì\y+l) d*Ï¥•ÚÓJXïÈäá´…ÔÒ ¦iœKè¥LEåäN¼-<œ‹9à6d÷HáãœuLMjPz éRèEC„¨±…n– ¼…"u8Dbµ¾IKb1=£!hÏ¡“þhÂüÉj¸ÞKÔw ^éE\ݯ>NŽyý nÉ™ ¦JI× OV•LÉ4ˆu!€Ü‚:ôŠ2áÓÆÀ NØ/pŸJ,dB¿é,mÆÉd®´ÜÎ]n,ÝdáL€…JB : ] KÓÊ"a)„d `â„Ò«ÊS® œŠÈòV0ÕÏ#kBƒýÑ(á!YNñ*rL9$MÒÔïÿ TÑ%°:ZÃwM¥ÍºJÏ)F];úƒºûVòh¹¼>{?ë> pwm#(Ÿ£H’ö5œA¹H½žŠY÷!uÛ[8Æ"Ͷû¶÷ {Ö÷’šJûYEné1Š,~ð‹XŠÛ&æÑi[ÅLʆ N‘ò¶ÜC=D«ÅyWRÁLJƒòñPª-þ“·¾‚¯… é@,¤ÐFaõå{мR…Gu5¦YÁälQ7"ãÜ#ääjçe™°Y‰ê†?o¬´€é¤ì.óº¡-/¸|—WB%1«í¥»½èš+²ï– ŠÝR&ÓBÀ¨`ß,ih¡T‹¥§eë­_À¹¥¦…˜ªÈÐ+àæÜW¨P™2å¾M>TóúÿUÏù»_GgçÓ¯ (jvW@ ÅœL¤ÜË…´Ûêй¦Ü˜}ý†l"Gíf:¯ÊùnŒÏmÈ(b> Á(¸û”4vwÏsîÕ¢[‰r?P=o°FìëôKËç_S+‡áXC üÞy›ßp}~¿²†Gt–ªD—v$¯1Äø¥©ˇ8MdFïI7¢vÍÜ¢CßÔ÷V£ÚZÄ\ÊcºÀdEú1„ N!(µÊ«ÎÀSûÊåŸg¿ôûè1ì¼P 6£‚ßîzTš¬Â|D7Æ~¤óˆm}ý‘÷5þ„¯½ƒû ƒž §Ò#™ÄiÀÆÕ-þÂ1À}˜0𵎢àŸvÊòxÒo°š¶ÙŒÂ¤€Œ‰,¬7DÁôÂyሠo+1¾„Ñ“O31ªb£ X`tÈS|ãšmbƒ¿m;Ò9aÀ îï|7U<У¾Ò¸3Sñh¦Ör?½–{bøÔ ]ßB¿¨O #üÕ ÷:„ø/KÂz•ÞéG`tØ ‡„ïo¬½º”þÒ[ð<ëâÁmzõž¿±à±½Îš²²—àztÒÙµŽšïçïÞ¾m)º#ÞµóF|ÐþwÿôÑå0þt›ÏwMú¤ébÓãäÉø MNN’§qÄ %zmÒ åд˜Rtô¸ºÿ4Ó,Úé†Hž &Éx„—‡Ýão{3=øýà_žCÿendstream endobj 4635 0 obj<>/XObject<<>>>>>>endobj 4636 0 obj<>stream xVÛnÛF}÷WÌC‚ÊŽDÝlåR…ëÆ­_ÚԬɕ´1¹Ë,—²Õ ÿÞ3»\Ê¢œôb 6E.çvΙ™OGcáwLÓÒâè§ùÑ(áfûÇ®hx9¢WÉ”æKšŒhözœÌf/ižùS#š§½ÌÔ·¹¤ÔT‹xý°8þþxþñhDƒ1Îdñ~õɺEŸ /ÇÑl|¨Ör%œÚÈp¢uÜÛ™C 0ç¶¥Ìä’××RäOúËÍêП¦å,Äž$Iˆç”øÆ’b0™6…è]K©´N(MNTwUuº&Q‘ÒeíHØU]HíP!½‘¶RF÷‰3(DYQ*4ÝJB6JËŒ–0VÉOµÔ©¬È,ù¥J¦5W¥µT%§±À®ˆ|E™Ë7ÊùH'Ét ³ÞóÆë¢§ôâ˜K“®…¥“ÊÙ>bw”Kݱ$èstì¡ ü<Óôn{ã¬Ò«çU¸Xôžù<œžPkN†‡6&mܨ¿äþûì6š°ð¥cã˞ų–üZjjýûÚ¨¾šs?Dž6,^~…WÀ­ÒJöIP…j@æö£Lá±|(…΀5‚28V eé‹ÇøÎÙP*‰¼2TZ³QH!hÍéà]·–T뺪Aè°J@‡± žZˆªt- dcò ßàC,ìÀçÞ³q¸óêõNLN BX ¬[7yMc¸]¢« &3&Üx”Œ“Sº–5×¢%ý¾->}ŠS8?ªVB¢¶y¾Ý×F)SµT©·EC+/$+QLç¤ÕPȯæ^Bn©ùRBo©) `ÑȨ́À|ñ…û]Kº[.rÆuøàŽBÙ•Zi/é\ÝIÿø? ïJ;¹’„,.HËÕ•†ÞÖË%§ÃØW,c¼¿èÒ÷ŸhzN…AyWRK âÀ"4šrË !Ï%”Âôô `µ\y.Ê2ßî#Ø£LY°›{Ôÿ«'uÐW ÷ ß2ÑC5çí‹ÖâÝi(cWõû=aWWS;Tïk>¯¥«­~ìr#òZvÎ7ü…!…ðϹVoÎfµÆ$ÚöJ1˜\×|¨s2ùÂ\éH³3Œž†§V"'îd ›Eíst]4›`wA®±ý)e >DˆDzr,X&Ö?†3N¾¡­©ý°S:Íë ¯±×Vp©) tLY +„YIçk—Ûm³¸¿têî§zlúúÒ×l- *î@ý˜ÑnLÚÙξy%bVFùhW™Q¦›÷W¿€VŠlKwÚÜ7Ñ3U£·fFÀn'Ü]î¾%$ô'ÎŒþÎQˆÙ÷N¡·^¯¾9"Îè=-îBL­{åÖ­‡÷]?žˆ´´ª`L¸73u#$¾“Ù0>¸³Ý[ Z†Îç°‡h„ª¼sÒ9F†«Ò™Â¸åÉz1¼xñ‚2á„Ç7¡9¸ÍËØþ¬Mkk±åAf•zh»k ¬Œem 4ÌpŒè"V9*²Ì‚WÍ 9k¤é³ä©xÈ5ÆUŽL"4O °4æp¹ãý¸3o›­æ¤iËöðòUÈøÕir6=#,þÉ8l’LœÁ$ÑÏ&õË-Öv£9.Ð,œ¼ ë³ß¦ô. f*„K™|öl4K¦¬ ¼*œNùÖÛùÑG»"·endstream endobj 4637 0 obj<>/XObject<<>>>>>>endobj 4638 0 obj<>stream xµWmoâFþί¥ªJîÀCœDUUåIS]5GuJU-ö{Yv}»ëzêïÌ®íBRQQ%JŒ×ÌË3Ï<3þÜèBºÐKè7]4Þ¨ƒ7ë?f'×}èv`4¥‡’ ¼Êüx‘6oU^8`fV,¸rjõÈZÁ¸y$Ô¸UÎ,GÇ£O“ëîyi¬}‘ÿQÖÇÉ„Óʵ»1ny {Îyú ÔŒœÐ ÿù¾î ·‘Μ©L–~0G]¸8ÙJè‘Éb3£Ce³åH(á“â/æÊú`Jtó9]ñ)+äW"XªLnÀüV&†[]˜”Â)6ãžyèoj8Ç”öõwZ2>. ÷‰u÷ÜFA(NEƒ’Ápõ¨â>G½~ÊšB¹pީΛ0ÕzLðÔ‚LÉaÕBö2oìøøûMÒw´×‹ì´w]¨Ôʬ‡²Ù`‡!äF®/`‹Aì‹ëŽ^¾ßQ¸©6 øR®€I©Sæxzò‰§Î“¨®û:ßYÔáSÊséÿUQps£—ãæSš¿ð…6«¡1Ú´àVeüÉ_oæ_(ñS%Gz ƒ·o×ùXÔ@1ˆ¶¶¼.R$íFê “Ø F0¤°ÝJîYí_¥ö¥µb¦|Ûb& f›|øäíããž³ŒüE/ÿ¡‡v’ K<áf¥Z 6Q²Î©ƒk­áË8iÜzE§ßãÎÛ4ñà¶Ébxðï=ÐΘcà4â‘JfíIˆ¤0(¦>~¸ÜÿÀ ‘ŽÑr`¸ççV:›È|ƒSC(×wwУ'ë,¿Eí †HQß]ÞÃÐ}êõ3\ ø—ï‡-xy3¼oÁ‡ÑÝo#x¢A k/^ûC/ù{ŽMŽÅêÈJu¶·(UŠØ^Ÿ4WÜ1!-¹æ,Ó7ç–W›“…¥&¸#hÜ­Pí\'W\J«qœpƒH¦fŽCXè¬À6Å鸂M–e8üµÂ6.2‹^˜ŸXžß´øSŽEŽÛ›› RX!I * [ä’·(4ø™=²ÒIiß"¨a¹[ùøÃÎgQ á錖~Z ƒ‘d¡Ä‡t½ÍªÚ>˜‰PÔ·ˆÿËN»E_%v8RS¿v†…†œM ƒ ˃Zîœ@ NqÛlÇ uV·u£>"2õ#x3´[ 7¯!ú10µ*}½ùõ`TeX»°Xì«ðÜèë"° „3°<Ç ‡çƒRîŒc÷™ ÖÀ¾å\K¾¶-ò\#Vº€9Ë€m ´f+õ€„ÁšµBÈ/ÈéÍ›{àâUØLÔ³™ã…åëB” –ØÂ!EÇ‘>ÞÞ„Ô*á¡ùÌü&ˆMû šb/Ì}œ^TK¢Z^BÀÓ!}^Ë'Ü9n6À@Å»¶â  $îƒ7.Ïæ²$ž¡ûÆ,Ê¡—”»b”.×½ŠM̧vák¾Ô…̈Y¨³:~³ üšó@õ.wúÑiï’ó$ð‹ÐmÇQ®Ö)N_Âê„gÛgAü=—Ok.¿ÂäÓNõâðÎÕí÷ÉÚpÔøµñGnSendstream endobj 4639 0 obj<>/XObject<<>>>>/Annots 1648 0 R>>endobj 4640 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¼{¼'¦Ó)Ãi3k3`<ŠÆPÓ'“›L£=øÖ—:©èg€¢ðÞÙ­Sy$ûqàÍX½à—¨ÁNy*•è:“ĘùD—<ÙMuPàà;>³%óòö‡÷«›þ'þŠB‰¨½¢XHÈ`l3»=~b :˜jÎoá·øpâ¨! [)Ï÷F8+=àgø&!fª¢¾†ãÁYïo“ºªšôK´+D‹Îb=ø‚U–’W§"õ÷r›ÖœFb¡ ÌÈ6MUfª#ž¨ Œ­ñ=à CŠdß™dÇŠ[:“cS:~ù]CÞ2÷œÍï€U„º¢ jP+‚*Rz¸{øüs‘Æ»Çñ²ñþv%ÏÒÁj‰a#î[løeÎÛto’ËJÀh µMÌÚJ‡ø’ê³íúEXÄá°Ó+…˜Ùõ:ý±6N§¯)Lü”¡ð¼· Ž NœJd°²l^¢4QB‘}X^L!æ0—YOÄôËø„§°r œb_pšý³¶:ýÆÒðøl#ªøÚ¡À5iÔ:"A¥—Ð ¡†E¢I+dK˜« ä>kò´ív²DwÔÄ>t ¼WЧX=vjÏ„Qä5¢ŸâW%‚-§zZ«Plw’ä¿—n§qÖ†Žp´ùîáЀܩ5ºÖ/‰.9šJ´Ùn9¹Õ…Oñ¸ÓGh@aT™s2@\ºƒJS‚RmÙwi €G‘JUq<ñ¾ @«ë,ÄsÖQô¥è „M°ãžªívúuäûDm„ÂîM IH5¸˜I¦žû$|£R[è Èh©­À¡¦úÐ&šg6£Ûcah7=$Q:*“°Ú4˺JqÏ-j&Á­I‘Jqi+7Ÿ¤ûB©D:Ñ;¾·0MŽmêIÏsÙnvíÃ¹Í e™™$ð†óÐlL"Ž!žh+œçÖ×Õ™öAUJ¢óÛ¾Š¥ÂWÎ[¨.JmÊž1çËÚeGŽ=T5ììè>ò!Rtí¡d\Áˆ 0Ê{tX ÑçŽ7Fçém¡ÖØz£PÍr=h¥Ôña`¬Á”^h¯²Z£Ó)€3Cì%~ÂO¹Ÿ=â7‹}¬Qn6†a\ t´†—Ô þR2W7p£ruÂí?¶âÉ—J¶‡%3ƒO*ҞŹFWÎå©@Ñ‘†Êê¡á+,Ê{°u–2—h%oô‹%в-|càëKydyÃYþÐmgèoMU{ƒ»OïøïQ¯Íôiü`ªdg¤­› N®¨· =!È¸Š¸º„Y`ˆ¦-êDMøëw¦¯´O|qc•”ÖF¯²†Ú|“ì»è}—`;.&Ì®&C]Ÿ8³æfŽ#®YTAÔFóÙÍÎEðºÑ÷ð¸Õì.zŽn‹Q¸† ¯)Î¥ýÞ˜"H÷«v´æï]äMy-‚V{Þ€mþ£6êb!Ø„~0ÔÓŒ/uyð°¤çYÜúœ»7d1KŽgÎpËä*Ì'ÃÖÐüDQÑÏb¤•Š ²ÕÍÿ¸4î·7à 57¶A®«•$gøÛ§ôSË¢ÎL‹k6ó¬Å¡ü3®áÙy2Ÿ—™@» ÿe…ó+Íåbj®ƒ§~m<‹¦óÍç“h9–{$Ëèí»xg¹¥ ¶¼nÓhÏèvn,Riæô#«P¸E‚ƒ©È4·Õ þ+^<Í£x,Ogüè›ç«\ýüstÜendstream endobj 4641 0 obj<>/XObject<<>>>>/Annots 1651 0 R>>endobj 4642 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ˆÃ>/XObject<<>>>>>>endobj 4644 0 obj<>stream x­V[oÛ6~÷¯8/AÀ¦uqœtEz™·¼¬f /Z¢,¶’¨‰T¡èß9$å[ìÎÚÄœ;¿ï;ügAˆ?$súŸV£÷ËQÈB<Üþj×0]„pÇXæ‡0±ùü–™µ a™߯—_FÓÅ "üÌa‚f“8ñfÁ»¬’ƈ¬ìÇ Í+ µ2` •ÒZÁ3¾*è¾6ü ¸\¶ø‡uÉëT0ø]mÄ£hÇÖ¥éÚFi*·Ÿ²Îä£Ì:^B#E*4ldYÂJ¤ª–‚·ÌÕö¢˜j£ÊæX|…,fxÔ7¢â èT5â° 2±ÂJ ¹¬E6Æ{µè+k ²‘ç"ÅÚU Kðf"-yËThe jN•¥Ú0x· Rñ+ÆAø6F&1^+jC5a%T}hLaCax^cÚ¦£q•8¦&O¼jJñ‹ëcÿÖ&qÌ’ï0 ¦Ó!s4ÄÆ[Ë‚+ßÔC ë‡kŒmàÛcv–TŒu°·NC²_dŸóÔ»y¸~'þKM¾ë4³®ð„(Áïþ(Æs_—wwTûÚ‘ºie%Îvt”ú,>Õ¯& Ýe¡;@ˆ€'ë5´]‰ðmDk,¢¼Õp“ŽXÁ•x2¢ÎÜé@·‘¹EƒË\¤†N‹ŒªáÆð´€Zlö!\Õ0P‹=Ž|âZâL›¶KM×zNHê‹Á{‘rŒé /5òä -ÞËê\•*ý Sénõ…v4?77¢Öaµè±c%òާQ„¬MIJ߮!i´(sÀ‰x¾€L.ÂB©#® øŸÑå/Ðáö?ñù<À¡¿ƒòþDnjsUòÂ3ÊSi‡W(8ɰ-ðq‡ „ƒ„ƒ%Ø2 Øòý½ésð¦AÝÕ¨i(†nÐC³û;;ébÐi·Cn†bÕ:ªé‰,[¦’v¼ÛSì¼b;D1lfÕ#æ­»Ör]W¨®/¸ê¡š)êã}mÄZ´ð–ÔÊ?0òh"cL!õeùtø1üÑU+Ú~˜%‰ÿ6—䣆wˆ³W9ÊT¼æk×?’÷Û"DÔíšv‚þÿ¡ë'à}#ä°Ü®Øu§:Ü—™>òÖŽú‚¨hê°ÃÆÑ,¡¢ßÓ(T.¯É$}1D:“R>“+DyÙÂ/xÉ쬿ïìÞcéûÁÖD*Þm‰ÔÖ~uÞ】W'BøúG!WÊ[Tó:óÈs-Þù§]t7c7É ÌïnYäÞ}¾ÿm³>ª´#NÙ×¹áÈõäÖ¡àÜ›ë&œ³$Æ·>C¢Ù-ùþºý9ú'‘ìendstream endobj 4645 0 obj<>/XObject<<>>>>>>endobj 4646 0 obj<>stream x½VÛnÛF}×WÌKZÆ‘©»¢8OS·yhÑ6‚й’6]í²Ü¥]5È¿÷Ì.I™’šÚ­lÔ^æræœþÑÑ#šÌù?ÛõÞ,{ÃtˆÅö«ÜÐàfJ£!-×8;…‡<ìã!K–[I…ð^–ÆÑÚ–ô|ù±7¸Ñp!y&ŠBïãbc%ÁA­í=y\vb'©¬´t$Î[ðûBîDqd#¥x“Š]¡åUãu‘N8Îñ.Çãt2Á¯¼Ž”ñta+_Tž>Ñ;ãåF–íÊç×tæ3Ð2º§{å·d-û‚}N°µ}›d[c«jÝŽ´4·ÏáæÁÆZ–qÏ©¿$6Ù#ìÿPi¯‰rSí¤ñ.&óŠFcÎå2$3Kçó—ìp4LÇé”ÞJ-½2t`Šs¸ñMs‚2ah%)ç»2§Õžœ|{¬¬•akÆRfsùpk÷·‰âŒò1ÈñZKQº6æ v<±Ó'mͦOnkK6úv:ÿÅhSï&ȈuÃ̈õ¤ÁšÉøœq*Ý[ 媔™Ww’Â6¨¬u“m$µ  ¶MX| ºÁÞ9T#YÉ/rgïX=µËèïÞÖPƒ@D­ùõ:¦4«u{ÄÖ7k Jè½2™¤÷Þ}÷µc ôÚŠ;Åõ kÊDžÕÅuýP$îº29ôd¼ˆ`‘V¿Ÿ^'rèA ”ˆTwgýVø)U¦rb¥[qB:yR´G{[g#Í!42òžœôdׇ*©ÝNæJx =ˆ5ZhO6[ÈRxeMaj´É*›·ªœÑOZd’3zh¹K–Â\Ö%—™Ѿ;h”מg@ö+Àä2„Ò½‚®_¼=ÉpÜ'aòîŒ8÷¾¨>qüm¿íÒ4 Ð.}® Osî!r>?½Œú#"ì•à@ ]k‡ý¬ë?;c…ÏÇÁkM,±97¿bdÑó´énJEµÒ* #¤ ‡Z£!çY‚ôU|þ­”èåìÿR˜4è‡áòá‘k9|‘KðuÁ‘B?lÑ\ÚY@˜º¡ã*ãTß–Ú H`yÔAìsL®×è`‘W#'A%–Yâ8Ãsó6ùXŒ Ô•DÇ kÙ4÷½½—w<éøf]Mò+Ú?V´Í3¤–D–YxMi¹¦l‘¯¢{ðŠÒÒÙ±þ¿1íÅéjü¨6H¦”hÏæì¡R< ¨Ž‡ tu5Ðu¤ô+šÓ9¡ábî­XïËïCÿ p “1§/XúMàt1¨ûCÔäã S^Ôi´˜¦³ÉŒæ‹I:ŠïuÌËËq:¤·6 oN¡Eó5 ž¾|½†·¦ ]ÛbòÒ4ÎÓÉï¶üv5]ðýo—½Ÿ{‡2¡endstream endobj 4647 0 obj<>/XObject<<>>>>>>endobj 4648 0 obj<>stream x­WßoÛ6~Ï_q/œÔVd;?ÜnÐvI—‡Yk (æ=Ðes‘E•¤âÅþ÷}GJr$»][,MG"ßÝ}÷ÝñãјbüÓô‚¿“ÍÑ‹ùQÅxØþ0+:½ŽiMižÑ$¦‹Ù8º¸¸¤yêWÅ4O…ØH[ŠDÒµÖôùxþ÷QL£1Þ¥ÂW’ kÉ:£ŠÕÏ{or¥Üˆr1PÅâ¸^FŸycø:=a»Ïžtrºgë¢(Ú{üOç‰ÿëôúŒXF#83šLkg7¹µ²”+‡ø($ÿn«)Ñ›2—Næ”*ëT‘8ªA[,ŽDYâ¥Óû˳ –аÞÒbÀ8¢ÄÀº´q,¼ià Hiw1ÇtÂ1}Þ¦Åq…ɯ¼qd׺ÊSZJ*´“iÀ›iC6Ñ%¨·ÚÜ éÝû›W´pIÓ]¡·ais{Ç'|H˜ ”ÊL8j«ÒoJaœJª\j¹Ò .5á—ŸÇš3›øNu!©²èZ€o…IkJ¥Ô2Â)]PçcÎõÐú“O¯ŸÒø,B”2ÔÀh2ãé`ƒé·Â9i Ú—À™*—¶k…÷œE³oš˜•‰‡‘J›µ”L ÇY¢åm×*YÓËÓ—OžP*œ`>!ˆÌ:ku¢çŠØ2-">§‹ t-WK ¤Y/­4÷ØÐ—F 'ÊeµZ±cºdÐ87·i ÐÓ]€@·ž‹&8ј^«’CÁñ‡â®yð@ ,5¼ ´a²ã£gÏb€X¨Dä\QðØ?Ô^ ³ª6(&°Š`ðd¥îå^êçn¯èÍó×W]PdC_Ûe:Ïõ¶MsÈêYÉtÈ1Ô&•¼MXÍ(½!™2¶Õ³Â¶²2² šxŽ4qðzš'þyS}ê2þ>tŽOxÖJÇëÄgÆ]"]^†hv×(¿«¥MÒÓEþð£Gßd}¿¹ïõ…KÅIÈjƒ@.™½Í¿ÐüöùÛ×ïè×®·ƒ!JŽE½Űº·6(?¸×ƒ²A¬'P8¨XË”ÖÛhë‰{`³ç9¿Û‘.YËä.”^°è¤òÛbîqüžôìyòcÄÆÓ†:çq:áíÿ€î s=šN£ø’Çèí2³€?¥Ñ…'û7rªHò šG+‘«L!·èÏ äÐ é^ƒeŠ‘tI´8Æo½n—r•ïrÅC9…îÇB¡Ír»[äÙÊeŒ,w¨ÒSt±Ô÷aô0²”¾  »1gÚóØTП\fn´ÑРÃȼ> ÉH[å˜[V¬glʨպ޸hÓÁãt9Êå½Ì1Œí¬.%oo!`¢sA„ëŽÝ¯+…™ÇÇòÄÿìÓá ÚÙZDØÂ¢VàØÄáݾP­îãEÉwj¦Í7Òµˆ™ÅñPk|Ûœ…å܆‰>tŠ5ý[ BÇEÿ´ˆve}‡ÝwïÏço>üÕìõ!×úŽ)ÄýMÒ Ùz8Í$ð]R[FÝ„4©<¯sðjH¶*KmÁXat…áû[VaÀå‘*WwüRY¯GÝ{Àh2‰¦SÜ RŒípu];”¬1æØÅ±õ¿8pÏÛ~ÊtÆüï]fr6m¾ÏO¤Æ|/põôº…{Å„A­rÙÜNjëƒþÃÎ1Í¿¯¸gáç2öc‰¯]†ÂÂïµçñîG›ï>°)„ìñzÿyή{$jW”Mñ,Ž»¼¹=käÍùÓ¿bå‹ {ﻓæ;ÑÂsy“9žiÚÂ÷ŒzübI=Â…R'·C¢ áÅ ?-ÑïÜœQR0ÝHŠç%î/[?{·½Èj(-ÏHðÒÏ£~F÷›/cÞ¾NÚÞ­Ókͧý»+®•­—ãN›Ë%®‘¨Cæ¾nmÜŒjãÙYt>=ÇýzÅc_W|M¢˜~Ó‰Ÿ{½ìð6Ü]ÃêÑe`Zæ$:§[Vž›ñeåcw_DÓIèçã³§lãj~ôÇÑ¿áå²§endstream endobj 4649 0 obj<>/XObject<<>>>>>>endobj 4650 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Ûìo@ø,³®Â4ÍD©£lôøÎ&m™U5¡¹O(~ÍÃ4Á+Œ®¯YDCËÑO£µ“endstream endobj 4651 0 obj<>/XObject<<>>>>>>endobj 4652 0 obj<>stream xVÛnÛ8}÷W °U¶*_âf/½¤ÈË.¶1P,’>Ðes#‰ªHÅu¿~Ï¢l¹N¶XÄpd 9ž9gf>¦”àoJó%ÒrôËj”Ä ^ö_͆ÞÜ,hšÐ*ÇÚåxÈœiôa++jdÖ¦ªÚÝJ²ûZŽIWÅ_þg&s¿Æ*]‘2$êºP2#aIU¥Œi…­FŠ&ÝRÝèTC©®¬ªZiÈj·eðb¨…± ñzõÏ(¡Ét†°¢RXìǹn«ŒtÓ­ª4•º‘ÇÛSQÑZR)2w>f öqƒ]©.`*,bäû˜±»š»§»C"¼ld%,ÅU  e,éœja­l*Ó¯º2*“s’ë¢Ð; õ#ûæ&¡ËxÎàÎpÙ,žÏñ+‹øXÆMU–n++7²ù)Ü•SÐ/èŒô^ï÷‹ÃEOZeC?Dl¦FïÌý4ùøðÚ-;$vâŸÇËå[ö½Ò”+(€#šÎmˆØ³aèÓÛS"ͦ-eeÇt÷áöít[d”neú8„¡ÇiLÆêºf9öì˜ZÊv¹<“è—\x€œ³0 _¿u]ÿñ÷ÓýÑk ”¾£÷L|é §Éä*$ i¸) ð?g瘞³õ‘ÇÁyÈ¢àÞYŽÍ'a†u©ªì DüîÙqÛÎ…ÖïadŽÏõa¹mÓ³|cÍÕ¢¥„bÔ— :HéDBŒÐW'B£l+B!‘Oàˆ“ö‘dcºkëZI{ÝÒVddt))“i3x«érwëw5„.Óºu“ÅÁÑê÷LdøO”veH$Îz<ôV(C¦†ûzaߎ¬æmºyˆ²®A\v©%‹øb~AËK× 8o“YœÐo:u cˆšæWNÞú¶1MâyŒ¢ÒÑhPP ¸ç‹dÏgP?féÅ”=ý¾ý5úÖô†endstream endobj 4653 0 obj<>/XObject<<>>>>/Annots 1653 0 R>>endobj 4654 0 obj<>stream x¥X[oÛ6~ϯ8°TimÅ—ØMº§^–¢ÀZl‹±¡¨‡–h›­$zºØu‹þ÷}‡%KŽ·s‹ØÉsýÎÿžô©‡}ŽùŸôüÞðŸ>ÿùãõÉUÏÒ`à)¦«+|™ßÝžÔO1õ×þe½´óˆµáµÿtg­~ÄÚhÜX«±vuÙX«côGþ¨¦ùb²#¹?]ÐÅM® üdNƒ¯ûþxü”&¡Ñ¯G“ÀËò´rºµ__}ßÿöóùäãIº}l½|»’¡œ»vãľt;A;â­±XM=•LÏËåNúJ ªDàÔxó­|²´ÖZ…´ÐS¯LØïé¹ayqs s³V]lïF¥Z^ž‚º¯ä\QN¥@‹UÅR$n)rx߀™ð6Xê œæ©Ž7cåµÀðj&sÒó=°Ó2k¡"F‘ñ_C˜Ò—ÚìiRr­ñ+ÈÀëãùž_wÝ`@ÁÉŒi«J‹’ßr¤æµìˆ=¸‰É*ØÑm¯SR©½{à¤}í‡çò×À$·l}–"‘, ±ëó‰‚2þàEMÈ*Aôz.ÌäR¬âþâ÷/c«\­m”g%àv™ä*¼YÎÒ&_dy*Ôb™Ã‘†˜ìpʰP¨¤`XV0‘fKE à¼Q! ;¬C«˜4ùh“*$F\}bTöÌY«.4]Èáeg¯(0LêÏ)Š3YËÉZ#«æ\N]]±¨UW²¥Æn÷i“°«™GÁä>m"vuŸÞ8«ßUñ¬¹X‰3PnݧÕÒÊžµÒŸýÐY+ôƒgKêhKèЕÐ[…ì[•‹*˜æ:ŠôiYÝ9¼¬ *àØ¾­¢ÐFNMMÞDåÉ–2v8€sR#`ï‹‘vËñm‰t¥¤R],–GÊerÐ )^ŸÀ¸X1ä5âц*VÎ ˆ>Þ{‘-¢¬gheL{QÅ%ÇY°6W¹Ê™7"MÅÖäƒ%Þ¡t"†Q1`+ÐD€ ‰Nº.C°ÑÊ¢h¸BS~Љ؄ÊU“— ×”ÑÞ°ZåP[Q•Ö*Ä9ä@îwÊ” çØa—;”«S¤9î¢ÁfÀa— $$Ã2•A  ”î’ÊÐìV‘²ù¦mVX`©7\=7 VèT%§Î´ÑEÚ†ˆ³Ðw% ªºpˆVŸ¯œv* ë„g<ÂðòÝŸV»Ü ëŠÝãÝÓMv%4èfDDz³ùÄ2½›ÝñÓïbWšô>v˜ö8vž¿{ÿweOË®ÿŠæê3ð”©/€³-£\tØDZ£53 ÃX(’O‰Þ$†[hÙ=ì¿ûÙɤˆMÁwK;;•·8¯˜¦Vgwâó~vÖýM¦g¥vw²Û9P{q‡ýýìª@˜z/}~{ûìÙcÌˆÎœŽ¡ …XÆ3$£JÝ;ÃïH†•)ù‡õ^¦Ì¬â¸ÞÏÆ·ìÖM []ÐF`ü1å I>AÈŠ?ʪÜRñb–r¸ÚбLv3K[ëf‘s®(Z¸²m»³uùÙöˆïtŽ •³iKÿ²N˜É‘ó·9m{.Bq__²uÈTïP'ò²bp}× ÚùóÇr²3µùþ?®*[׌´Z3S9¥¡/ЀÎŽC Ϭʴ&l*cs£íBæ(®©Z,0¡†v6B]‹¸QNe^à® jXJ#Ú6œ­'Pœ;<º0FÐê#E5ÊòN³tlgê‚ïBÿƒ*Îw SïOäGt¨ü5«nLÚboB·G-ÆÜ)ÏvdåP_@í-},€ XÅ"&qH9ÏEs_QÅ…‰È³´Ñ;G…ñŠÞÉÉËæ0hG´äºîÀ¦“n]óá²ÌCóÊ,HÕ Ê ¯â醤Hѧ VaZ\4º{6oznbíâæª¼Cô.ýÑpD㫱½\â íü½ÒAQ)Êä€N»·ûÔ>/XObject<<>>>>/Annots 1655 0 R>>endobj 4656 0 obj<>stream x•WÛnÛF}÷WÌK¹‘h],Çn‚m' m¤ô²$—â&$—Ù%¥¨Fþ½g–\Š”/p|DrwvæÌÌ9ï'3šâwF‹ þ‹ò“i0Åþ˜ñÇßoOæ³Y0£óùU0¥œæËE°h¯2úxÒ¿ÆÓ«i0ï?í]ç´˜OƒeïiÿO/†{[õœq™ ]ŸÓlJ«^_\áKìœÅ—hôÛžŒŒe¢ Ulètõùäìa¸Õ£ŸÞ¿]ýûç›æ¶72"UQ.öJ*µµ*Ì$UšT^f2—EEºJ¥ÁãTl•6]kCò›àçcR íuMQ&N&‘eTíK™‹ÒR¢ÍÐ…)Mfs8|Ÿ+cbÉòÙ{ÚéâiE;#JÅžêâK¡wÅ¢|­G»TE)åj“Vì~meRg|,Å2¬7€°> è׬’¦•ÚÊl?vþº=ì\çR®c•ì C cS‘‘?˨²¤ Ü´•Y¾°•1é„"]l¥©r@•óÖRc±46hϘŸsØÈê©ååVÅ€TGÚbÀžJxŸezçly,BRà"n@R–2­¿ðB˜·†Òr*+`âoÉ¢ÎɦÀml(qÆ/>9—(g”ÓXÌçÁb«xôS›ÆõHëSçtEï$œ£'ÔýÜPôÝçj¼{§sÄW [xÄÎ[{šc±³Pçë£Îìvö¶áëðL …8{ "7ß_ àwh¥Ê=<ôíÄ!½..ž³RׂM¢r™¬tÉ…ÅIÍ,íú ¥ÚÊbL…æ‚*žÛµàë#QÆVc ëãl+ʰýVðÙÞ{סäªâÆ+eÐûÄõ_ëOë)7€óO„zë½äf×ZgƼ YUÈo ’Bâ¿•®³˜@+`##WÉaÇ06®¬w`(ô•üVfºíœ"ê €ù> XÂ]áqĉœdШ{ï•ë A¥@ÇFu& e¢ØÔb# Pg2 UcqŠ‹IU ™%nÈÚÖ »=¬ÕhÉ G_™ 0{¾'(Q S[£%…=&äÏb+»Ûð9‡ê×E`!SÞ±’dôNï$øgìË™*›T ܯ„ÙȪ Hª® (U1´S…€" V‘¨À9¹ˆŒ¶c²Úíêçc«äÎÝâ̆Âܵ:ÌDÊÆ?0ÛÇŠ-R$ºÃzñ¸5L(20]Î2c –F¡Í!Q-Å;!JÞ»BquÊBùº)qž1¹âcES’@‡;G¼>F§¶Ã2GkÚȨ°é;6"ÄÜ][²BѸó mëÐʯ5w•?Å¢¤;Ç¡Eìœ%}à±k3Gün”‡”r¯ú.µC8{tíÆOLœd…p0eS"rp w§ªthh ú`yFY´ùp®8êz4XܹಀâÚïHÇòHb„¹j§9A^?rUÖn—8ÉðQ!*€OL¥¥)Ä/+¾ç¡žGð”‡ä˜°°sঋ˜Ë¡ÐÅäÂ[̽§ ç#ÆÞ^w¯U ‡Ž”8ÆF±8r¼µ”Š…Rúh&ט6è†Âƒ1 xHà¬òMÕtï +—ŠêIsû JSbøK«ЙÕ+~C!Ð?À·rœ!Ö#憣±üa;/É{G¯¼°oç^2ábs9[jܪ˜Œ9^ä0%´DÑ´D®Ñ§VÍ|Ø‚pÙŠú|z,Kº¸œ—,Y^…éw9™s:ÉP‚Üšµ“çü²ÿ(U\N/‚ÅBÊË— 6ófuò×Éÿæg^%endstream endobj 4657 0 obj<>/XObject<<>>>>>>endobj 4658 0 obj<>stream xÅWM“ÚF½ó+ú’-6àõGù`Çkç'©¨*Ùª½ Òãˆ,—ÿ{^ÏHâÃÀºÊ/ÔR;;Ýê~ýúuó©3¢!^#ЦüNV×qg qØþÊ4¸ÒMQ<§pHÓg£`:}Jqên )Nºÿ¼$¥-]Ñ+ÚûÙŽ^mG¸ïÞ_¿¸Ž?v·cÁbN}xê‡Qí©+tJv)in²Ìl”^È2Z ›,ݹ7F¨Î¸Sbta¯}vi-r«DFÅZ&øTÿ «Œ~ÞXï’è‡aEH)mbÿÙ{l2؆{ÌÚØ/?½5p÷wVÛˆ ¢Ç vmÇl0Þ38‹Î³éÑB=HMËÂ2"…$»1”ʹ(3œTk¹ë¢G›¥Ì%Ť ZdfaÊ‚¬¡¿þþõ]|÷ÇÛË`üT;ºïApÝZ5UýL8§/ h‹ÇY›Ñ=›³ƨýBj™«ä8'jªW×¾Iä¸öH¸,dJe—´2 @"E ‰¢qs’޽‡¿¡M”gˆZÃÜóõÌÔ¿(' høkåj +} .W£¯™È9´•áó}šžþçQåýÁ »ŽuÔæÖ“® ’ò2“ ø§%•JmU‚vœ›Üõó1[á×”‹eÏ][¤%Ìy.ª"¨#ÇÜx·p£î»é‘Ñ€J-––ä­oo™õ^O¶ó2˪2€)m2.î€â%8„·–"ÇU.H" D4+-gÔÀr0ŸJee@o CHùуÌá_­T&rÄá²áØ{T¸Uø\ ü ËQXµrŒ”øKÐWÁÄÒ$r™%Í-zÉìÓOˆ_Qaó€ÝÕþ™ŒJÉK6}qªÝòiçagç•ß±ÌëíÁ gíálßÿ®k ¹‚–'XĨµ2¾_, ›Ø¬ºœëÝÉDO¤j"µ¹Õ;A÷€T<ªpo†[øÔwv‚*zÌb7¨âIP5“€ƒ¯Ëíaᢟ…ò›µ°¾‹ˆ\h>®õ‘›‘ÏÛb¦2c±˜™ ²Jÿ¨9Ҫו/ŷΑĬÐfª0šfÒn$¦æ)Õ@Zé   ¨m攸Y´lƒ(Yæº Ã=jàÚS·z˜.NÈ›·¬Þ¨ƒuæD<—ùÜΧ–}ß©ùÍ@ÙÜ–vœÊmuŽà—‡Ä{³‘¿©9ÄŠù®p sƒYac“"½œèÙe¢Õ§ÇV“ >¿…8èÍm7É Ù”ªùG:A±!äÇS™ë>3˜VÜO>c&Õaþ…Ø÷œŸ˜—!8ŸX+’«Ï9r noêÍyt3&Ñ„¦7XƒüþË›J? †ô‹IÊF¶Û™™ÊØüíþS¿ùކALè7^ËyG÷óÞ÷K´¡7Ož´0¹k2œQˆ/™£É˜Ý¾;vþiÍ©Oendstream endobj 4659 0 obj<>/XObject<<>>>>/Annots 1657 0 R>>endobj 4660 0 obj<>stream x¥WÛnÛF}×W 4‘ ‹&©‹}p‘8m¬¢ì<¬È•´-ÉeÉ¥Uµè¿÷Ìð"ÉMl uÁâΞ9sfvvøÇ ÿÏø7J¾çã üñéÝ ô/=Ÿ&—3oF)…“À7ߺìÇêåÔ›î­þ8ßÔbEç7>]d¾¤Ð§ÙëÀ›Í.h‹[ŸæÑÐdŽ"›•îT>_žÌø4 °ï_Rós~N©rÑZ—”Ùl륪Gn›ëTåÄhq~3!ÆXÒŽGá¸q<œ¯u¡Iá¿uø“ÊjáM±Y.±E.«hMªP8 µÊâÄd«3ZTŽ”£D«Ò‘qT®m•Ä´ÐáYAnUÀv|„+¶RQ%@†Û6¾ã+MjÞg±Ë–š–Œr•˜¿tLN§y¢œî8x¼ÿüæ5X"Ÿ£pÆHï!Dz£ÕjÅ[Eråœ.²Z5,Ôû[qxÿÄ›0ÂN·±T•zY%3ò“¦Ð€ dËA¾H=(p_@;&-†ûŽË3ª]¡º$C$ `#—–*Znà*•º ÕØ´ü‡¢‡DÑÄp¤×:2ˆ‡t±à$4ϾÕäuéÑ|]‘Ê8ýغm5ã}®QIÃú0ãÓAyaQs%*—TÄʲ$ݬ *²É¨TûŠ™BÇ66%*e‹Õ$Ù/A<ï-YÞNT)U>‰µ¿£Ò˜u•9“@æÄpÀ—eJU¬=ºÆé€ïÆ)È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£0ôÆc´äxÈaxîšïÏJß·i‘þÛ4‹ôÉn&w“/‡FÖpùØû!/Sa7å]à¹?³o6âk*E¢V“]±•ËÑhQlè¯>_‰ÝHEqV^˜ìE{ž¯Ü˜r]$Ôµ¦ šôxæ \ÏkY_?­Õúj|E·RÚ|¦¹>ø'íï•É^µ„xíJdêt8ð@ôÇ­9ÖUí‡výñóó–wÏYµYo3ŠÌ?å¾5gš=M™iôæ"†ÏZtOÖlÚƒq‡Ø‹­€ö²¼ýõý»ùçŸÞÖtÛÒO‹¯xx2} ßÏö´ËäSÒAŸ>›ÁÎô8à#qûw÷Øì—'øŠ¾ãöˆ©ósêý u”Ù7]å››w„nx\àZÁ@UO¶2A¢Ùäybp×,¶â‡›#7CV›gìfÄzDaçrØ6¨îênz›´XÌj ¶»öÛ$ÊøU3èæ ¶äé£EÄÅV_ˆ<H µ,”j µ1°ñ]æ€z°R e w!®>Ëó¤\‰»0 #Æ%G‰. ¯e×ÞëððÖ2 eVýOjWH‚øbøZ™à²} ¸ðøý—Þ}ˆ7CÝx­™5{ Óâ%”(Âÿéc&fÝàÑß»èŸ>èmˆÁÅÔ›§4›6=WÃ(Ä ÝU©ÎœÌQ ‰w¢‰7…í袾éŽz}˜ú3oÖjÓ)¾~ü êMcÊendstream endobj 4661 0 obj<>/XObject<<>>>>/Annots 1659 0 R>>endobj 4662 0 obj<>stream xWaSÛFýίØzœ"[±l „N>$2LBÁL§eÅnV*ï,6¹Õ7’®þ8{K eg;ÃÏ[=ê}øãa:ñ‹ç§@ɹêuOʵïéÌyˆ&Êd‰X/Ër™å:’ÆÈ éÂf…íÀ“ )òhF8Z9OäVEE"ð¸Ìä\dT`‰;Çv’P¬°† Æžê)‘N­L­Ùð6ôä˜g‰$4RËD/ÜFK;Ói¸sTæÐ0ð}œ´ß÷qD=ªFßѯ:Eˆì…ÍC¯­RÉÏl§ÓžHå*³lGöÿBf„;¿4 ª>üä ž™¿…öwxg+^µ59ÇGò.’.F£X¨$ôÜÒ×ùô$Ï56øÐ"ÂQÖI«ÇŸÁwG٠ã\FÙHŒöF#”6þ¬Eiyp2æ“Û÷¿Y‹åh xˆ±Aƒ«\Ó>½O÷>}/c¨’³¼6ôvÃ,®™ _7#Òýi*_¹¦1çEbUÛ•%©âžA‘’¨ÚÜ%SîH N‘‚y tÑhÆ$z|-M4l‹È`ÒTUÆútªó:ÉO«îÒq/[Úª ¸êR·hS] Ý{8B¢ÀìM H±»›«j‘àj‚às'hfæiÚ51­ögGƒ—GTbÈ 0ˆ‚L¡,—&ÚVéöª‚a숋PN»ã"Žå ‚Šgï´¾©l<9ïý£AÂÖ([M?‰® lÑz3BoÝ‘çU"ÑÆë¨8—*c÷jê‘.ˆ5Êd¥Tøø÷ú ø²½u‰ã»vÎB¤«;Œç$ ×ÙZì— «ä%\á1¡Úã·‘†èýcm$ÿ7uÀk¥åª÷C±U{RЦ¦/ÕH…’"s+†n# ±L±cå´,‘_…’ ÑЉÑG"$*•®=U‚­ÆÙeÿÊ4w>o)çX#$ ôžïJrÔí°ÒàÅ8Ñ 7LnW°P¶Ñ’q+§<¨)‡¨a»FAΩX•aXÉR„®œ¤q)8¿ħ óéÓˆˆŸªÁéZM:nc?ž‚~›ß7늺À~ªZœ»&Å™õ¨Þl“Y¨)u!3êÖ¡v ÔÌUµ]—êõ[ðùˆ†•Zæl¾Ô‹=ÊQ¸dƒ6 $¡tªTì™å°F3Ý4¬¯¿_m²ûc{ĹD¡œ6v¸»²ÿ½‡pÂm° ¾ »åžÂÞ~³†œëE‡õŸQ\.ÊzÌ…UI汈 .U"Ÿ.ÐÏæzR€hU +„ Zùö±yqpniG·")$*!v·®0ïBT&8Ç×2WrÿYýX™«8È5´ŒXYKÏ?œÎ¯ß½k*bãZÑæëŽóäùéauç ÷üýÁ>àuUâ(tû¸'ëÈuawKåó ú–³»/ÊkHÐó¡Èé¸æÄŠí™°@—Žª7óêýÞ?èCE\ÇùÕÉpë÷­üWº\endstream endobj 4663 0 obj<>/XObject<<>>>>>>endobj 4664 0 obj<>stream xµWaoÛ6ýî_q0Z@1,Ù’cÇÉÐíÖ ‚¬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Û×å…=<º½:‚ÈüɤР‡atTYäe¬¯Êõ ÁhÇÜ¢`2Á H<³kðs®³)ø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ÂòêG—$ ¥yÆwLPE‹0˜ÚË!¬©£~«ü€è‡V¦ˆB«\ Vpè ¨õÒ¹ÐTw§MÅî¾S†„€6øT´#B]e¾ƒÑ·ùÖª}!û5X8«á¼®6WAÎÀ2žѾ”^žR{¼U‰H×$m#QSÃ×–g¤¡¿©¨mãÔv@H{®_’îY´¶ ýXç Eùˆ‹Ƭ)0\[ŽÑÞŠõ¦€L©'̸4åš Õ¤a-—Xc•ðn1€-ò;îŸ|zsŒX«±u¹ÁhcŠ;bV´Ô¤&6E¼þ}f”e¢c`Ë$£^LF>aÇm¿ý.1T¸ B“Nõ  ‹Š@¸õ&ÄÝÌ;B§³“^Cx ø¨ý̓kð§=&^8Æßß#ϰæ’k[@—·CÅñÄ]ó¹Ó/‰•ÇTG°ašX‹2cOÁê€Áñ¦V„ "©Ç®©¦à8ã­nÄ¥½FEâŒcî\GÄ(»‡3?šÕHQ.Ÿ±ð6k›uçˆK`ÍÝ$iž ‰Wdâ‰c…y½¹×EdéÙ‰XáüPòép'‹Ç÷æ^ÉõÒ{#$NÕ¬A1¶"²­óÈ¡<޵™*k­xrü>/XObject<<>>>>>>endobj 4666 0 obj<>stream xVÛRG}ç+:N–]@ÆvüàØàPqbTñ‹ª¨aw¤XÍlffª”ÿ=§g/Ò B\‘( Íöôõôéþkg@}¼4ó_¼Øùe²Óú8l>ìœÏúth2£aŸÆ¯ÑxüŠ&IêÓ$î¼ð«\.D>í(=Ý'—ëéïýÉíNŸzˆ$"ÊŒž“—‹ü-~T¯ÃšàÄXaWt/²BÒÁáöE5£iggן¤ÿ %gÖ,.nnÙš—6ïÒžÒyá»ô#k‡?¼£É‡Ï׿áÿGnÀ²•¾°:Èœ~ùrñåí¶ÅoÛ{z'BdP¢hÉ„‡gGÄáΨ‡Lõ†£*S‹Ŧ°NvIhÔ*q“IG>žV¦ DÆ™°’”v*‘$¨J)ña"·f%Žœ1š¿}*¡ØàNŠCù ãÂCpÚÁóU¸­¯]r)î•S0NÞ¥\XïÈ̂ʥyŽÃY¡c¯`ÊØJ¬ò¨rz¡æ©§ÂAqb!›°Hã—›îG•Ù᛽ˆcá PdÙªÛö|©²Œn %—±š)¸_8°šÉ%‰ UÖ«{I3c.¢38%Ä"Ïä6Ò†ho8ŒF#6ÙF&C»¡–—«sí¯ß;ÆÓ´Shºÿv· …-`óõm@=§¬Îzh€mLmjî’67™‰ïÞ €-6ò?m<ÂI*Cµ¬¬òбJg+.dÂÙNÝBz»^/¶)IÀ˜rðÕ“ÔqføF×à?¹Øä’–©Ô¤(‡ä-b×Áç²U;KíäqöÞÓܘ¤î¢V2ÂU¯lqô¥@eò²"̰³LUœâZ 0’fh!¬K/¸ @—^y”±T€¼èÃË—kbÉÔ]¨X•—Í!³ÑÁÜ3cÀ½>yó¦ÔM`—Щëtn1®ÐÉ–{\]¸PI¥¨J™v.=eBÏ 1GÀDÌv^,À’ou/t Ç¥Ki³nËÐ×P¦7­|.½£&Úç kïƒ&Ä»û«Ì2C_Í’Ýÿ w¨T_¹Ò«XèŸ<Ý΃ÝCÜV,ƒ×Uyê ÂŽ2{–c«äòY=Ò:ù8G.¤HJ[ecŠ­DÇ"Å<ÃDo+ç] lýu%·M˜›[c’ƒGÊŽæD×.' $PSá £u`nðƒ ¹ËKM žÌ8^YUc&ègû_õÈå^âúËoOGŒ3Öü%ܤvðy ·T<¨ªN×åþR§­Zº:[ã€W§kÂ\l¥n-–ˆSaù›_îñsœ]Ý_þY¿.´eå|b3;åøcßJÿãí,”;Èà¢ÙÖ4½OCi€'V< s4ìok_Ø™+ôgݬ(”ûß4>?Ï™'ÁoØGÐÍu¶«à”GkàßHL$L*Œ§£30Ö¾q¿{ia²¾ðÔþº‰§°‡rš~îõzÕðÁ¢Ä[¶9NõÜÀo,y’cb¤×Ûx5ëY}ÄËx9ÑX(׺½—”õY+jtãŠm ÷Äío¡$OøzxvRñÔàä(:Óød½*7=žÔ½aÔ§&¬òÀ1JéÞ«ÒÃ0«tÅË ÷ÇÑhˆYÎsüø„N';ìüæñïJendstream endobj 4667 0 obj<>/XObject<<>>>>>>endobj 4668 0 obj<>stream xÅVQoÛ6~÷¯¸Ø`‰l˱›¤ØC·ÎE¡Ãy100es•HM¤ì¸Ãþû¾£D×–½.O¡È;Þ}÷ñ¾û£7¡1~&4óoRô~XöÆÑª5cº¦´Ì(ÓünÍç¯i™úScZ&ý¿Ëß{£Å M°ÌèÇ®ãi{¬ÿ¸‘šö¦&+5'q©?Ùw²(Oûä ÚŠ¼–W¤•²²Ê:K™©Èm$¥u%œ2šLæ×»J”8DY­ÿ]è”ÖI.…–)Õ%‰Ú™f‰Èó=ÁX>+ñÕë Òép¤,_—ÉÄá™ä`j+©0þß\ªñϾ”…(Ié­É·J¯)7pŒ +%žri±ãC³¢@¼2ÉErD $!ŸEQæÈŽAIL§íÙÆ3‰9q”‘¥û€Ü—R\Çq4¢0ikT €Ìªo]zo]ÅQ Ÿ¯èd½ï¬?¯oNáïÔn¹$øe, Hsú$Á°<<~xO"qµGµ’ùZ¢U2“ØN°û´'®—N9B*ªu]HíH×ÅÊhë,SÏ¡4 Ë ¬Q`Æ XK-(IL*iç!<„‘ó‰rõ‰ ¦ì×qcîüæq[ èÏ?¸™ö‰PEGCÄ7yƒ†ôÖ§zÙÒpôO6±äb¦Ÿx›ží׈_Äᾟ™V6°# ´ ü;¿½ëé<Šî‰óh¢è~ý Æ#ÙˆŠ†ö,Þ«µUk~z a.õÅC.b[@$,{Ÿ¯`ÞÒôM>É¥¡ïiØ`Ö­„ïJÇ&ÿyñK³ˆ‘ÅwœÅy½þÿ,¦/Íb²8çÔYÝÚ]B úhËz<CÚ8ô”Ĭµú,;ÍÆÒªßHÅž >®Ðm÷Þ'߯½u¾9SzŠÑØ?¸G›wÜ¢ø› ¤j:rhU‰Ñ[–%舭ËÒT­»U_鲯¢ôÍ:Ù°¾k½RúUØA ìy´˜µJxP¡ÆÉ¶g==ìy%mäÄ7ÏàÍKcQçNAVüG{ERàj„ŠÚ:´î­„œZ2;ÝìD¡š°ŽÿHf¾mã<Ñ0<w”aG`PŠãm¦8ìF#úøË7ZßdðÉWáøôACM:ÑvÍ.†@h˜#`‚)íjpbî…‡IÍùßÓº˜ÇKsýÑT઻ÃhqG¬qajš…©i2Žn0t=”2QÇ£{ù2jyjD~|yT;È)Ä7ЯQËÌä¹Ù1al×:¨Ä8RBÖeQP{H´6T`xbøÃÓŠÃ3ÃÆd¶þ5¢ùbžË…^×b-mÈÎ?O6‘¦Šç1D~ñn£øeàúÔ$^ÿ½Xø‡|6f™JXjJ‡×>šÛöÑÄã›h6ÑüvÞ`ÀóÈué]ëÔŠæšæìõëF=¾1½óãå®Ã4ŸÓl<¦1Ædðd2»c_?-{¿öþ¢‘Pendstream endobj 4669 0 obj<>/XObject<<>>>>>>endobj 4670 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ÃêÓãÔo³€Ÿpb!¤¡G÷Ǻz¶‹ÇÛ:8Û{‚{ßUd†þ€D¯f{?ïýãÊÁRendstream endobj 4671 0 obj<>/XObject<<>>>>/Annots 1661 0 R>>endobj 4672 0 obj<>stream xµWïoÛ6ýî¿â>d’&²å$nÚnº®é C׆:0h‰¶¹H¤&RvŒaÿûÞ‘’m%ñ~`[–EïÞ½{wüµ—Ðÿ:ñ_Zôñ¿ðGÂÞö†—ñ€./â4ÆWá{N{»§‚®†ñåîÍî© $ÅÉîÕÞ#Þ]$ñÅîÝ×ã½ó½Õ‚ú×” h<‡££çø’yÿð%~•³\Z²uº$aéxüK¯ ïýŽèèI2u›R†Ÿ[C =Xzr`i%©¶2#gÈŠ¹Ì7T˜LÍ7ä–’Ø8Í6Tɬ”^©Hd+ÒNV6¦W¹[šz±$m{2 ³dˆ@"-eËJäuÞX!J{ʦ­DP3딫2Ú’€#ÖÒ©7[áTY™RVpkmª[Z+·Ü‚á(5z%+G+‘ר9“n-¥î8Òúê ëâfÁð‚=}7lj©´VT¸ÇQW2Þw½L…&‘[ƒclë¥Ô”É4G®€JnR¼Žé@É;Q”¹|²3 «øœó<>Ãa|~ާ,úŒ*“HéÉ1°rtB“è¨I9Y”øý·6fHDøÇ/èKz¿y§Ýô•ýÎè¶)]ÖnrüòÁò£‹Ÿð¦î»ßƒw-wμwçñhôŒ/%Ò¢,-9™9¥Â§ŒÄÌÔî~ìHCKZäÝ-±·ZË*&€¼1u³A’`m7OFPxø[ÿ=öSp°’iîóÆ!vcŠNI9x¯?çO(W·Ò»"ïJ™:š3««JlÀBTN 6 8«t†Èç{TßK+Œúx:ž®+ãP5ˆú4øð÷³þ)Ü|n¦úh?´’=”§@6 .4ާu­Q‘GCå9s”°í®Gi̼D'“c–f;u{@,ƒÿò\.DN¯Én´w>!U©)J•˘¶$L몒ÚA 4ÄÊUB-–É[ s- Y&$XT¦F"=û ЂUèãOïÞRV#A¦“5†Èog9iê²’yæï€Ec•YLßšµ„îœúÒ(µ Çøã›Ókª‚l¨Té-bƒv@352± âÚñã€Ê¯ŒÊè$ÀßÖiÐx7ªÑ:ÒBÂyD’ VûjðòÄô߉Òaz÷¶)gõoE*Ž[™Ýþ4‰ R ¡¡k¼ ¤Q7Ÿ~¹@ݽdiëŸE0"H:ô[”Ùýs{…¾#Q"}"]žÒz©ÐOnºŠÝW€6F–Á ¨ïn2 øöHÏÝ©ÿ j×ï‘k“Ò øðŒô„ósâþ>GãVvÙ6‹d_`ÞùMU(é¶@ÿÓÊ4òÑò—7òbô˜ëý@à•Úï§y­Ó0)ø¾Â•º”(y-çî / 7+î€Ø¼¨ h…mrÍÓ…sXë9±ÞhË+ße|¡[H¤Wœ º“iZ…_Ûo@Åå9æ œÒ²ÄÞù>mÂs|‘suÇú°õ…´( v߇‚ðjí£×¦*DÞñ4êǨ Ðì5«)ˆNƒ‘ ã˜F± „ Mküû¬öÓ ¯ñ¢XŠŠ›o?hnhÖ‰…Ä(3Æ¢¹És³ÆŠŽÂŽù̉•P9¯ä³ÎІ’ ½¨a•GÌs­W‡þ5øäçYO ¦D`æê£LÚ´R¥3Õ$⪛w¡Ün‡ILkzz‹nðõJ¸³Ä­£N] JøÎ¯7ôºÿúéÓ ˜>¨¹ sk8l[þÔ=ƇF¹+Ìž>aµ» >†yå»ó¢GDÀ KgÜ{gíBÞ¥²dÖêoahPœZ®MóÊ{´j+*Ϙü¢;+=—èÙn#‡‰‘ԟБ²Óz¸‹gY—½x±Bë1ÕÀþ+Â8p?J?W´#?bRŽ~ÿfZNau: VÇS˜ú;Æn°ˆ˜¡ÞsQໄÝW»— Ü+<‡xºt€­¥%bø¸*pÁÑãkKHIº”é-€®-˜ÞÝÑ^úmÀÄRâ¿j `8¸ˆ/Ï/i„ iÐFàp6Ä õ“z=ó¥É› ½aíÙ³Ð[ÿZ}/£ø|ˆ{&WØ(a+oƽzŒüœ%endstream endobj 4673 0 obj<>/XObject<<>>>>/Annots 1664 0 R>>endobj 4674 0 obj<>stream xÕW]OãF}ϯ¸¢ -q'hÕ‡.[¶HUÕv#õ%R5¶'Élí×3&¤Uÿ{ϱ!°ˆ‡>4A!ã™9÷ëÜü9˜Òï)ÍþËÊÁ$šà Lùã׃Ë8Š)IΣ •4b¯]ôi°¿Æîü*ºØßÝ[c÷b%{»³xS2‡ ÏÎ/Ù¯yÝd]íïî­KšO&½Ý÷‹=;¼1õšÆ7W4Ðbƒ“+|ɽø’ aÕݮ’¥¨–ÃRºÉψTÂ9Yëåééâó`|3ÀÅsà e©Ym¨±Ò’ÛHâ£΄Ã §]¶QzMuSHÛ?Üi<¤\Ú¬V©ÌIŠºP²&g¨0æ¦"¡s¤É6©uÊ5NzÁ¶’™݉Z‰´­b[å6~?3¹ôòh4Y{¥ýs¯$µˆh+Ú‹µP!ÛÐÊÔk½”•Âùt篋zÝ”R;{FÛ¬ƒÆ7à‘÷yëϾ‡ŒÄÎêħ“e_E¶5\}ÀÛ‹Ë3 ÂCRçma©bçµqÙSë¤}ˆÑÚ— §Œ¦ÖE|虘~+¥9–A*èÓ?øO+3Æ‹ü>=°GwîÍÇëùÈ€wå}§ÀýJ#6 ª•>4lâA$½+ÎH×óuÐj˜°Ý(D8@0™L…Ì#ºÕTÕÚg9áŒÝB9†ô­p< yЪÎô­ûÆ ÒQ!ôºkiéX@i¬+v Á¶0tO¥Ãk8 œ÷€uˆ «þ!GsBm–†LêD«ÂB ÆZÝ!sØÒëñõ»wá!³¬4pnfÊÒèb×Ó„0µÛkÝ%˜€°Ë²*°5¸‹bñ4Äò^à¤TfË–s&]E—EûÒaMùl:XÊMæìÁO|9Ûˆ ÒÎ(màMGvc¶HN1«'άŒµŠK‚Ýi'îC‰`BZ¯.§Åe4ãOÀÎ8šÍ°Ê‡]’,‡™e_/O©ÑV­5t) ‚‹×Q&uãòúúµ4¥£Ô˜âåk\¬ í½¨¯ a-üÝ“@tgTOšåð±t%Ït@(ŠÓ³ÖÞ¿^CHÓ€¿a9ì{Š1Êì (=Œp}ºâÄ6º†h<k<¸–¬ìþ§·>ñËÇæ6ò˜EIrÁð ¤J-mSø¤åÄY™DæÔöµÈ‚F øÿ&“øË$a¾ò‰—IÐx9À”ÿ*†t0Îp‡(^F“EÌ9çtí«›/yhUz®A£Ïé?./»Ð[”n.(a:² BfÖZý…€þ/Ê:êgŽM`ÇNÚEôƒÙÊ;®P}δHt_Ñ59hʶ¢ø:ð Ö`Ná±m'¬[MéHé£N£p²7˜±o÷ráõ½M"3‚­íÛ2”hgZÕ¦ô?醮#ºAénëy«ä«•Sa|äfý4M§ô-ý¼»Õî÷ïì(§¨eJW[ž~ÓKÑ×3ô1'§@t)46q'TÁCá—µ⻲ÈÿG úêgŒ0´1EΙ'ŠíÊ ©uÞİÐSúØîJžçÑFô¯A§ÎñãvîK%ƒnkQ¡Ÿ÷Cú¤!Žø«j“ž0‚ò(ñлAÑœç20´ãZ*3Á£ úd&4ëÜ1Aqgæé•²Æ:Szbzp]ëÚãe;ÌÆ“yt>ÃoüfI|Ž|úíöã(Ƙm—ös#›ÅÃáÑE(Ôoù­q>I¢Y æ3듘ñ¾_ ~ü Ãhêendstream endobj 4675 0 obj<>/XObject<<>>>>/Annots 1669 0 R>>endobj 4676 0 obj<>stream x¥WoÛ6ý?ŸâdƒÛÆŠdÙ®Ó!¶,邵]׸((h‰¶ÙJ¤*QÉÜaß}ïHI–Ý´h77pM‘¼ŸïÞ>Dâ_Dñ”ÿ’ü B<ᯈ¿^==ˆâY0¢É$BÊiFÁ¤Yet}Ð_cw< ƽÝè4Â:‡Á”ïÆ,ïÜÝÞ»¨íïöÖ9Åa+¶wdzY0£hʶå4EÐàW,™%E“©Û‹fÁi³à­Þ2§iÌ×ÜAÞë-sš=fÝ^o™S4šî í­±ŸÂëíÕþ»=-¬ôçy/è.òåŠN.! ¤ùÙ™žâGê’‚ÉàJ“HSe•ÑÇd×’•>$»)d. Yfî*÷\×ùB–d–”}+K+SåªÎ¥¶8ah!©*d¢–J¦Í!êÁüÝÁÉ%‚çt A颶•ÞÚ4 am©µ•-E¢2e~ó©†ÑöìZU]š’ä_"/2ù¤> böl„££QÇX¥ƒ“ºZiSöl Zyìÿà»ÆÃ›‚ßegáÍRÚÒCS[âMKVæžþ½sŸð9ŠèŒ¾çívöþñ¦µþ iÀÆô1kþ á Y•Ëc2:ÛÐGY‚kFË^Hs±á˜vÑèÍZê¯*TTº …>±m²;r¹”‰U·Ú•Të‚ ·Ð)%Bkc]Zë¢ÈUZ–&w`°á™Ð«Z¬¤Ow_AeU–Q)?ÔŠ“pÇ–çâ½Ò+wÿüäüÑ#hÀVŸ s+wŒhAX­[ ÞŠ¬–TW'”®¬)™…J·æ Ê ÞP*“L°ö[Q*±ÈK<ÇÚç§Ã%gp7eƒ€^Wµ²w¶CÊÞ¶Ñâ§f»j8fÿKYF;WS¹ufa»ƒ›gHXüt©*ÝCáð€ü1,PŒåÇÁÚcôÊÇØÅ¦MÓŽ5{)c`°¤m&ÇîËQ6Øcð¶ªa«¨å_ŸÁ·\3 ¢4·*EB©R¹B‰,¬ÂgígeºcsëÝc|k¸vE²¨¢œÍC€×Þ‰ìÔøØ:P9&8¹œtœ8¹2ÏM^«L@ÎfK2m%èÚ܆3áШÆYèw¶—`Žt%rØä›,ѺÂëȶ1 í%ÈT=MÙ¬( &è=‡\ÉZ&ï»»ŠøÂ­WæPwÏy†šr_¡¦Mi EWfF¤¼ZƒŒ®\MæÒ®M Ò½²”½((§w;–bURrfá"¬ÜÉó‡ÂuaqÛ‘8}Ÿo麋ÂqQÊD¦Ð:»~sõôíüÏ—ç¿^œÿööêÅüâéÅ«†Ê?!nÇÛ/7WÚ¾=çxÞ Ž\_Âù1½<¡ð[øœ{Rg€áÉ::ÖAÔEv'6.Š›·¹B¼šªo™:â.‚¸ ©SWîºZ†¤C’³v›µß*¹i”ˆN3mãó ¿ZÒÆÔP±e’–w; ¿iÍc|Ëf$ì¢lÀ×K.òU)r†SÕÇPƒšc§Ä]è"«L«PÀ4p°Ã“Y¥;ÈaÃA€ßstqÜÅgà‚û²ëŸKÈ1wˆ¤ ‰»Ü‘QG]óFŒCt uv÷ø–»*oÙK1¦Cñ•EØ?Ù/¿¦«w5w⇎iëRû΀iˆûí9£Å“õ þ§‚EŸ-ŒRVÜ—ÎÈWÇ%Ô?3z…‰n|KQ0ù1Š]#YWÈ#r*n‘RnËM´Cºw”;jŒâ‰Ë†ôÊÛiïä>f 0ŽX¾?˜´ rCßQµÉ5³p÷Ò ^ˆ-ùµ‰XH¶ü®ìšÒvˆÞèÙîä¹áV¸©ÉL©p¾ri™‰U;Šò~.²C¡@øã–4P·¥*´$Ì <&aÓ|ý2î÷R[ïÝLçd®¤–¥—èf2;vu±ñ¨û?¥1¦CÄ_iõµå±º_"nzŽXœrèái ©]²:q¨4Ú”{?©8jkô[“$5ØÐ½“øïjxQ@ Ðà4:JU‰rsLx¡\­ÖnË-ëŒc¾Æ#l­>"@H¦Óo|E¹RÛ©„Áûâõ³g˜fîsÄ9ÑñüÞ+LŦ¬¦ÂŠO_W\×c ÷Ö1^NãG³q0‰'„—üïÞ¥¸¹GxþÅ$îmϹÊ0A!øÓÃÇ|»U¢ŽÂç&á4ˆGhl|dó£‹ùÁÿSôÚÆendstream endobj 4677 0 obj<>/XObject<<>>>>/Annots 1671 0 R>>endobj 4678 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šûÓ &(ž[æ|þvyöëÙ?ÝAˆendstream endobj 4679 0 obj<>/XObject<<>>>>/Annots 1673 0 R>>endobj 4680 0 obj<>stream xV]oë6 }ϯ Š^ÀímÜ8n»¡{X·°ØÃ2\(6“¨³%O’›eÃþûH)vâ6k»¡EbYEæ÷^úK`”òVöñ€ÞðGÂ?Ý÷’4¾Ñh§PÂxD_aQÀCï`YÂõU|}°w°,!Œã«ƒÍÃ5íNÒŽÛ¯gqø`Ì .§cr³%œÞÐCî㤇,rk„©NÀm+,EÃTÀ?DYøÅÙì±w9Àu<âãÃô‡Ãx4¢U]^Â=:PHë@/A*‡+4–O‘%_™GvŽç‘Tó3¶sé°´ðWÇÀï©°w ß¡Z¹õ<:•ªªÝüìK2€ç'N¸öLNÉy)ŠBgóÈÊ?Q/ýûùÙypI:§ÿî¬(—©A†Ã§ÓÙÝç°$#aVo$ÂVyrôÎ}5úOâEzÅH͸» Úz(ÄóÑ¡ÊktcDU¡e­2'µº€Çš*±À¥6™VÎ褃®6Š|,Dö8íO;ʃÊWµªÅ c˜­e[º!”éù¸(¬†ªy ¨5•ÜV˜IQÀ“0R, ô•a¦žE§YBÕøO8¢‹)Rl)H¨­÷šr1 ÿ,lÖ¨ð‰Þˆ ‚BÌ-%ÐTLJ)Ú8¨ Ñ—ÒÄb‡[o ¡}&}˜r>É žPGž(Ü0Ì-ÆÝ Ù|ÛŠ<·fDšÐ ãÇø°‘ní îZ(>½xÄÌuï‰ —†ÞÊ'AEmܾ9z" ‡Pb©Í6\¸Ø²öÂÝås•¥Ûºð=(Z6ü‡NÞó{—,ñÛ:#Õ Î_¶iŽRd§Ék µw©¹{_qwº þ~Ø>øK?O.Ã#wQÿ«ì3E3ægGª•š8ö•çéi‘‡¥ÖÝh÷¶A¦štÉ/òÆ{â>ëÔR _†®ä“ÔFßûJƒÞ(µ¬|i»ØŠF #ŠÛØøNÈÑ YØWYLAŸ5HEz'_˜2.ÓÕráˆ>„} jÚ43å@`Pä[VêMÖ#¯Ë$Eí)¹+jE™:ã–dS¨1|r|)M™Ã­;|&ò¯©HP„1$á I«žG§QžLX´ÿ‹ã ;ÿeüëKŽ“M©Ÿ¼ˆ_@A0>ï –£dÜÃðŒ3!u#X HÇ2´VPcSÂC3ïH9m¿ßøùÓ}‹}eô“̑Р…X îxÉcºDåO#œ½Øu=vŒŽA’Þ`Y'¬ðï¥X×¶Ë/OØÝJ 96ƒ;Ÿ•ªÚTšŠÌãNX+WЉLÜ]Þ}ü«B/DÑÉ­™GašqÏòôYÊìõîú¼I¹ÞÙ[tí¡ñ±Ì› > µƒãßÐàIHÒ.rλ9’no£xað;éë]cé§åd4Ôÿ¥Élëã|£³ºeLd¶ý« —~–^¿ü½ÂÆ“A†4wyæ¦~õí¬÷cïçÃQàendstream endobj 4681 0 obj<>/XObject<<>>>>/Annots 1675 0 R>>endobj 4682 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 4683 0 obj<>/XObject<<>>>>>>endobj 4684 0 obj<>stream xíWoÛ6ýߟâZd€œÚŠd'N¶¬º6.dY{+†(0™²ØH¤JRq¼¢ß½w”äØÎÝ0lÀÈ(òx÷îî½Ë‡Vþ†ÐÐ'Î[?[àâòKÏ`gÀ߇q½߇þ`°ã©ÛÀ8öÀýœ/޵žŒ¸Y-ä,òpá6žüβ’ã¥;ÏGüCÉeÌg<çÒÈKcኃ,ó+®Íó¨}XYkß·è†xÁ´¾@s[j g¿žÞ{ýiceóy+„—`y^¬uÛv†»@%ÐÅ»½~¡w"Á¦Â¿ey‘ñ>q¸aZ°«ŒÝHàTG=2^-5Ö<`Y¦bf¹&Ç'`Z³(2Ìá5ËâkÆø`ÏYA/$ª(3wÐ9Pbr 3Í V5!÷#²WÊ)×ÙÑGÓI)c+”ôëm½]Úöެ—†O!Ñ*‡ó…M•¬k §çÆ9˜(ú›ìÑKPÉÒ*ĸ퇂»úèöz~¿Õ2õŽŽŽÀp;¹á±U:òÈD. ì@Ïßë~î˨½ŽÚfX¨æLZtÚ*˜qÉ5ËÄŸÙ*l XQd Úâà2ä.A>Xk‘0ÎR.f©…¹– ótßÕ¨DžQ’L1‹%€5}ñêìKˆ¼j‰²±Nð²C‚MrêÒ‚X¯=‘àùg狦/&¯S_GÞ–Ei£övSöÅ>;¾-s„ «®n9ê¬ —žè¨Íþq®®xzÊå̦w®Â³—P‡ÿ­^(¥¹À>±qêÃ2ˆÚì’4þj(‰Ò»@>AÀßøðâÅ#Îÿrõ…m…§VPxËí f¾¡#B¹†îÌQ\“bõHvÁ‘Ô…¸Ä‹êÚB—ÎC*¼É+óF•È=‘‡çïçóbdø½Ú#FýŠªiªp ô‘ V¾`Ù£,]Ó:åxàH¾@‚Ŧ™ ›:ja±-ÑTE¾w,âÃÏefÅr¡Ùb%ŠYÓfŽ–]1£Q!©E.2¦!g9̇!Vb­-ßÀBhZ‹[GCOpQMJáC¤¾ïC¬ä ×Ýë!a8yÂå&G_O«$EQÍxÍ»R§Uu]ä…Fª…#æZQ÷”fx¢B'ƒ(K¤4Ìu¾Ö‹»,2&Us‰R©`®ôu•¥”3§¹4)8¸I»Hp§0e–Uº¶"bo#‹Ò¦b$ëJ¦· :¢’%ËÞgÔ¹Rl…ƒNì ê 6<Øõ÷ú{08XŽp£w'o»=?€7*.ibg4Q7à”VíîîW3zø?„q5Å ìª9Œ¶ï¿ßÃÿ6p. û´t>/XObject<<>>>>>>endobj 4686 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º»"°¢ GAH¯Lìïw~ 8 @´Þ=|Z ~“ ¢Ùýäí§á$ðÏîÑdÊK¯gü;‹ºendstream endobj 4687 0 obj<>/XObject<<>>>>>>endobj 4688 0 obj<>stream x•VýoÓHý½Å(€äÒÄÍGÊq ÐÜUªJЉ jc¯“Ûkv×I£Óýï÷fmœ$ÒªMœÙÙùxóÞ|=P?ù7Ê^Núa·Ì‚Ž'}: G4MhاñÓA8?¡iì­ú4"•;RϧŸúÔàaŒ‡´eêè9]o.•u·Wr= nc•õg‡»æ‰64 ÌûÏHÑïT[âÃÑÑìþÝqOpûfþYFŽkÉ$ÕÂÝNŒÎ^ëržÊY0 âêÝ!¼}TŸöoe/>¸é.œÌ`vWuõ¾ù­ ü§ãÉ qÊ õPŸÞpT×'¸Òë.mtIk•¦”¨<&·Ž2™Í¥!EÒZR–¾–ÊIÊU$c÷í‚÷†Ãp4BùãàÅ‹d‘éÎd•92¤¾ÄHä4—k\X…¶lW¬-eôå»ÚX¢„ܯ.nƒ‘¦zm=¿k`¤ÑEYœ‹À¡­DZJËA'eùšØlH˜Ë;Ááÿè2—)%ܲn/F e{T#døkÁ Õ|S¡mýnŸ&/•€[À*`ž{¨„mšWd´ø2 :çw€hÕö¯œZaJKÞÎ>3T§ïáîº> ëþs°ýj\ÃSßò¨/Ø!—Ñ–\|sëiBÈŠœ‡Ð—… ¼chm%PMÓŒ.Øærèl“a\ÂÖê{ÞèÂúZšm‹dáûéÉlÞÆ Ï§y,ý½ˆkaDF€t=ˆö€Ei PaŠÅB6õú™ð)}aš~¶°ªÜ 3)SZ3R×ÚàÌ¢º Ð~Ž~ k{z®#ÆÇ÷À¤ÑsˆÔqt½97æzrãÀ±‹Y€wÑíä†/´év®Þ]^Òu+åÚU3&㪦0>·+›tä~ˆ߼€[A"ßl‘þYétÅ…T±6¯jAS6™”@h½ŠþœO«nAH0,k-õ:à¹H'MۆР„'ï B…(X¹`>«.Ø"@*†48Æ)óžSÔh¨|fi¾!† ÛbÕ€?pª L,-# kªÂ¨À¦F™Ç€ü†^¿::â{έ^<‰WšpVñ9T;Q%_Öób† ˜ŽP:JE¾(ù{5áìŒÙm õ¼ÊD­òñ—¶o¶n(–…D ¹ëÒ²QËŒ[º{Ù²(´qž ­@ÝjÄcJ. 0Ù‚1Z%ˆ±®!ÿRÙoZ†V ñU’@ª mJ¬Ü‰JñRƒVÙ¥.Ó˜¥‡¥¤Åý•uGå[Ññó< iò¶Do£ÆÕÚ(ÇðöçúñsKl\2ž¼‚\Ÿ¿½ÜÙ”ˆ¾‰‰Ê1̼u ϽRܦ\%<¾Y]¼‡t¨¼(H¹Ó„ç)üV«Þ¾{ùOuÕñ䬡ÁÙIx::¥1þ÷~—ã¨zðO¯uäµÛcC-*ëÞ“j“þåã´?GC¬,¼®ŒŸ²ÓóéÁßÿü‹§endstream endobj 4689 0 obj<>/XObject<<>>>>/Annots 1677 0 R>>endobj 4690 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 1679 0 R>>endobj 4692 0 obj<>stream xÅW]oÛ6}ϯ¸(ÚÂÕŸIæµ[×t:dkŒÕ Z¢m¦©QT\£è~ûÎ%%9RÝÃ0 œ˜"y¿Î9÷êÏ£õñ3 ÑÿÆÙQ?êc…?üñîõѸ?Š&4N¢>e4žô£‹ê[J×G?Íîñç슞]öé"ÑlIÃ>}?ˆÎÎÎi–ø‹û4‹{O¾Ïnž]Ži€ïK:žÓá¨Ú×sk©iÃøb“HRÙR“X ¥Oü²)]^:~P¨,O·Ópå}Ó§Ãa4Á‘¤7Ÿßôú7Ǽ¦ØjÒû‹ÃÚ7]ùÅl¼µG&w*é#ÎYµ(¤± v`! GòSžÂ9™PY(½ò§VRK+Ö8ˆˆÞ+·†ßÔÜBioÃÇrýþÍëWóß®ÞÍèΨ„¾#^¹žýüòÇ·oéåõZØüÃ|þ!¶¶9DúÜ œês·Veêè‡ÎãùœÂ“îƒjÿ šÏ§ÓÝýÝmõ½/HË ö‡^l4²„›ŸÞ‡knŽ»ç¬t¥ÕTo?Ý™QÎì· ’\ÁèÿNí¡Ô´ûïS´cÕ \ÊÄ­±”¨åRZ©cÏ+æXÍ@Ç^¨OX¬9Ú#'³ÜXa·t'¬‹TÒÚ¤I ö;‘–¸áñKk²î½íàº÷ƒIÚPjôJZj8QCsÈ”:!I‘øjÇ&ß‚[X±eìZ,Ò”)™ ˆF¢¬Œ]º ¾pœÛäa 0eà2P›,W©´EËCÖ"™Ií8-ïþ¸ªÁ?}|ŽDìJx¹¥Ähy‚ph‰%ŽYÜÂa¿QÞ! a ™ „…ñG>2‘öê q»OÆnZL¦) ñÅ-_ƒp6VštUæÖRä½ ¶—Ê‚¾œ{Ü„¨:n<tM¹Œ•Hwxï\·Íe&r²‰¢/J;Ó l/k—Ú¡H  `#øwзC¶$ÆÜwð5EÁõö5ݬ‘n±‘ø{ {LSF+6!àÄDUÃ1|ö£¾ý¨B8…âàm`& Àq"—‚¥\À%Gkü¤Ël™%«9ºV̧‹ˆ.¹–éö„ “Uý5š¯\ÈVV9§RuuDhµ8Â,[‚n¹(|³óÅã°»„ŒèJój–ÁMÇ¥mtÇ7xo®=t`‚è=‘Ÿb‰Žkt{C=bô8%‹è%BR dËq‘4²´4ij6œsÞÁ³IÅš¶Ý¡3¾„ò“`2?Ü1v·tz"=ù\»ä§ Ýl¯=ñëë©ä ²ëâuÝ0 —L§M6è©ÜÓÍcž)ž?'1ü|Ãço:I÷´Ðfü90„y„@–cQjæ±}Ènàã‹B,ÓÅJ¼ÒƢ˗ž3±(0=ùçEžÁÀÙ•i#¬F¹N{U›HM‡SzŽÐø|<¥_%†¬¤[²+ÉT`cÕ0wŸšÞѤU±®mÙ¨tŒó^k׎£“€ªîi-+µ/<ŸL=F› íƒLDzxû¯1´#Kgrã¨À„›&PŠS),’R)¢X˜;–4æNjªÔ »*¹sÖüëj‰—î<¸P'^€8å^ïiCå¢pʕ̵¶Ü^û¶ÁR¨2ªjzq)ßœ1ºá´­îŠš2è°‚pxŠ &+òœç¢R{Ò M<ª@&wʔƂ*>–ø(~öÁ@°­‘ë{ >/XObject<<>>>>>>endobj 4694 0 obj<>stream x­W]oÛ6}ϯ¸ 2ÌIlŲS7]·]×vº­CÒõ¡.Z¢,¶©‰T¯Øß¹”dGr’nÃ’ –%òòÜs¿ŽþØ iŒß¦3þ‹ò½.öÆÁ77ÿÊ%¼8¥pL ÖÎá"öÏq ~2+y%Ë!)G±‘VãHd+±¶´”Žï–j™º!%¦$y-ò"“´J¥¦Ã‹{'/pº·<8ëíQR–VÊ¥J“5¹¤Èä¹ÔNÆd*‡o± ê(< Nkx£É_ƃp<¢Ÿ«Ì©‘(—ï$·.d. Û=hL£ÉipvƻΠ%θTnVSQJ[œŠ+ G¢Ê2 í—¥Yd2'“P,E¦ôÒ£&‹+¸z%²JÚ€^lݼgŽ×Šv¡ÒEåð„ceÔf»hã H”T:r 8"‘emBÁ¶ÀŠúË+”–D))VI¢"pöS¡càÄrPm)ZË2 §Xª;pšàyôVŲôî·!0ÒàÖšr©´fï@Š·¥¢p²ü¶f~LgÁ”ã5aî'ÁtŠoñ@!D‰1sO#•Š’Žp}õþÃüðq7p#¿}Ìf}쪢0qKem*Z Ÿ-ðqUŠ¢²¡Ìšz!TD‘ºxKs¦¬cìÖ•ðÂR¦>±]eïwàÉ“'µï÷E&÷‡û™XÊŸÖ!e÷áÁ½\T?fèñk:[“–7»À؇-­M)Ýd­{â`H '&;ÙÛÌQ`ò{¹ŠWEÊR,Î\i[¬yé&kÙv&õÒ¥uôñ lô– ¢öDz¡mq¹Á:W'o¹‘µ¸‹Z…«ËkWÊ\@O*d}·Æ»Pšz§TfÅ&ír•à²ñíÃW?§ÏSÊoí츸 ª¬;'™-d¤%-¥fÅjêšDMÞ¬ímM÷)m Ü—L‚utÌLèe…¼iêwLÒñ ‡XUNq/j;öú‡ izvòìø¸×r8,‰É2³â0ô\å¦H…,Ñ£sŸ7bK•j@ãi› M¸¿:¾nÚ/×÷üî.súÜãf@p ƒÄ?gY{3‰¯Þ¬_#».Ÿ¥2ú4ø&:?„ù¾ ¢7ëçeyy.ݹ¯êù7®£Ëß¹ðÄ íï?¿FH›¾Ìi»ß4ç•ÒU¥¦_Þ¾~ÝõWùAHßã`ñ\ý)·û;&X9Ô¥{rôtÍØ‡óÃ#‹ý&i—°“}Á2¸…Kft‡†þYáevë:颠Ö=›IÛØmÀ6IèE6F2–:‚$€¦ÄíH…ów¯^¶™Û /H5£—ÒºQ."bQcÞ –í¬¯•õE*Á„)‘ ^(*ĉg/gËvH.$ (óÕº-i?ÖZùÄýçîŸÏ>§ÛT ·¾4=³÷LËÎ)]Óÿn¸ÕÞR{éM]Ãӎặ}Y¾wÖ_NN Q™-MÊž5Ê)<; LÐì 2?ôo õÑ$Óxã×:¯å8ÑëêÕ£‡µHøÒ;àƒñ,˜NðR‹Î>ôG?¿ØûmïoÇ”‰endstream endobj 4695 0 obj<>/XObject<<>>>>>>endobj 4696 0 obj<>stream xµWkSã6ýž_q»3 Cœ×Ø>>° i™¡….lÛ™¦Ã[ITlÉ+É·³ÿ½GRHâ@wº q,éêèž{ε?6zÔÅOC÷g·×nÔÅÍå?=¥Î¨KGÑ€®'ÔïÒðM/é:ñ³ºt7…´tËôØ_0=÷ÉÝz·¾¡­ŸN‡>nÈ–9ÏXN½ÖõŸ.µ{™øH&gÙÓ˜ñŒiÚCüûßÿاðK|©öY9p!;£×äbN¨ øíþ`¿yfÉÌT‘&tËÉXÍá Ù³”©mìTdY@43I,Ï9p0YÎg\sœ”M [¡$%jÇ¡Œ=ø½Áì³^Xp@‰Ðé¿G5™"ž3T¥+0ßÜki¹ª “‰qŠ3lLL"œêŽæÂÎÖËÕk"zBá dy, ’‚ZžV¶#Èí¿”‚SÐsÉ·ö·Ì¯Mð¸µ2û“Oðr3TÆÊð®ÏÇKû/Æ·ìW»ÃVY§ªœndy)ÂŒ•(4žQ*î88„p”ðœTX›r*œŒ'œÙBCL®@0 †ßsÍR2Â^ †‚‚1¥¤ŒÝñêä^’†KÃA«Ð"2Ež+ý6çLZç( 㪴♀úÝbRªæí›¦ëE¦9KÆÍ@ÄcjëÑ;@Ý\S‹Ä,M?§ø\>¡B1•8…3j#þâ7¶¢)èÙÝ8ÝÕ$Ù'¯ð=}[L&\##~¥ŽS-}ôîîÕµó­k³°fÒdž„ñ,Â5Ó’æ éÇ>ŹŸWNŽQäDŠΙq˜néuž3‚TÆéN@öjB¹:¸ܱex¬0P™~»Ýf+õk£E`®kb:sùùXÀzür‡AÍxš#j…,¢ÔÜUÞ>@ 9­3p¾jEh3èIV3i&JgˆåÝÂ{ÔY炸~M7y¢¹ÓZo=…n Ÿ¥ŸŒ´Ê` RU–rváýd˺uç茎o½£×ÑÁà€†GÝêqýê׳ïÛý¨K'*öoþqÄÝ/Ìn†^ÚëFoèÇú×·à ;Œ}¼Åá¼wè_xN¯?7þ—--lendstream endobj 4697 0 obj<>/XObject<<>>>>/Annots 1681 0 R>>endobj 4698 0 obj<>stream xWûOÛHþ¿bTqª¡‰ó$ÐV­Äq…VºB"U'Yª6ö&q±wÝ]›4÷øßï›];äÑTè…d=;Ïï›™|;èQ¿=Œø/κa'üÒã—Û«ƒÓaxJ½î ^sü„½úSFwëŸñtØûkO¯ésJÍŒ:—]: 4žR¿K£—½p4:¥qâ¬viDôïÑøëA—Ú=$|ph¤­²’ÞЧå]iR5ûritîßž«ä.ýKFÁa¯å墣×Û¦F:‰íGÎTçr¿Ù§6œj÷µSA(]ÊWôAQ9—$&úA’ü.ò"“-b¿ÔNúÓFa@B%Û’ÞËA#©\hJÒéT©Jz&“LÚðiRëÜ4RdtA‰(E¹, t.JZKF–•Q2i’ÓçôN–îÒ´Rq™jµcjOXµ-›´(QÊ„šUb&IO¾Ê¸¤‰äÓÆ$•Ú™IU)MSiÂè(¬=éÙ“k½hQªH×Ú¢¥®(Š&-%Å:©ƒ±)*°¤BX+-M*N˜%Dh8,eé=‹¦ö•Ïò:èÚý~8‚Iðöí[šUuIC]HÏ>Š{9M3ù,:jRåÈâ(’œDÁ´5ìn =ß|dÝÏ ÃNF‘ºûüájuxŠŽ:áóÿ¡?ìØE:c·w+_1ŒÏo¯ÞùÑ~ýq¦-1Ýò¾»ãÐl7?S­ŸµV™¸ùòùöæú÷?韵£‹ÛwçãuGÃá–…õ$ººFÁ¬õì½Ì2M m²l'¾×ßq«‰÷QÅå&ü *¥-¤åd¯–:³-_w²Á öv‹sRU>‘†ô”r´«´-̬ʙÉÌÃ\T >çp2³š@o+ñY:1ø,;®ÒLµÉ)€ó÷v,²¸Ê³Ó¶ÛÒ2NEü§SæÔzd™£4,2!­@ºL/Ú™|]jSI4æRÈGMÍ<Ùòt6/i.Ðæ5-á©l·‘ÿ/v™çŽÇQè áÒ1af—dôÂúw±Îª\ÙºïÍ©ë¼(j,,:.÷ïâBpVµkdu.é>E£EæçAš:溡3 pŸÎÆè±ÜR¸â:Œ®²¤î1b«rymªøÄîòK-©ŠŽèié ¿“Íð£7¾­‹Ù†R½¡+Yz9Œ^1UEU"Ç®MtŽYªNƒKÚ\/è¸SÄèóÓ–6Y²dt®dW“™{Þø'íZ{ˆí˶û^êõß'2ð"50vý|V;ú7 (e¨Õ¸Â’¬J1K‹;9{Ü*ëVŽW<¡ÜwØT‰T17A>o¬†ô?5®³ç®Ó`©Î5ïós¸jU¾×Ħögèvö˜?uýÖUk…¡ß †ç{Œ~Á[±ÏçmY¤Ø çÓ—såk½‘)×±iWE½À—÷¬þ*ÓïÓÁ κáɈQÍXm÷Ã.ý¦c·Ñ8Œñ-|còÂíS?öæ¤; }‹iu:äÛïÆü¸s—endstream endobj 4699 0 obj<>/XObject<<>>>>/Annots 1684 0 R>>endobj 4700 0 obj<>stream x½VMoÛF½ëW „  ™!)KrZä&uÚCÑ´Q‘‹cE®¤µI.Ã%í Aÿ{ßìòKŠì¦=6.9;3ûæÍÛù< )À_HÓ9ÿÇÙ(ð¼áŸ~Ïo(š¿ÂoFQè‡Í"¥£Á2£Ùµ?|,3º^øÑà[4›³m0µN§aä/š{®3šÎf¼×Úò×–ƒm¢å–^Þ\QÐrƒÃÌ_á!±gÀCìmê<®”ÎIä U;™S‘ŠXå[^©‹B—uV*¯4 Ú”b›É¼òÏ—w£€.£+8õntIòO‘©œÚÐ^×´d¹§T³Û}!3QðÆ—7]ûSN,b'‘?b•xgÑÊSùêœ~Ù¿M…1tA_šx|šÄ£þ˃HkI¯)ø¾Í¨±ð}Ÿ2‘#¸Ê¥!½Áª4;‘b½¥X'’6G»^”ÒÔi‡ÖqëÔ…ýËåÞbzisŸúóù‚“²°‰L~Gqø —²¢’ ©œŒ4"ma1`ïH«|<¡ñƒ(ÝC¢JWºÔu…÷²Š}úøéç÷8C¡p2ŽËÇiŠ8™ WD°¿r[sÁ`&*$ð¹†7·©ÁÚn†_aT ´¤H, ´ÃhjìC¾f+säÌà€>-5ÉTe*Ç;("‘àMâ0›†5. •Çit™gHx\›ïÔOѤ¥áÊ¿1 K³²—åÔy’0ýÊû°ÿu}héB¯ïNìùšYý¢jQÕe~ŠgD–ièŒï¸O,µ‡=2éòõˆg;§gø‰*/êju~‚ï'âZfþ¡{ù:jµO,WLHnÕ›f隉˜ÿ­zˆR¶ÄO&v[¬s´ceUÝ´t¢òv°$4¯H¼„þÁö€×-ßÐÌNKºàT¯Lz™å€ÃÖã2SÚʧŸdCCÙ&“ÕN'Ô6‚Óq¯+š{ßj‘G*Mi}˜_߯V¾Ùëc)ŠB–MsKà„f…Jddµ‚±0¤Ž¤-ß¶xë}.QAP)Ä©;hxmËÒ$ÕÞ4=ö,Éœg‡•KRUF¦hžt‡;¼‰qËqŸXÑ{ë<YÚ‹ Òß[°nO{3z6¤[µT™Š/ˆ¶ŠœªñéS@؆Ÿ¨68*ªÖ–ß§wj³‘%Ëlb±’¥™rÄZ»œeû[(fg_øª¢³CY8k¡ƒ žÜævýËMcj|H¯£þkFÃMSýh!ª.*pÇ•:–ÆpË:…ÎóýƒIƒAs½qX;Q¡ŽÞ‡ƒ½=’‡æ} ›¢àB…\&”ûÝh°ÍF·›[†pâÛZ±k X%j›h ¥±•ÂÌ×L6oz’ ë$Žgg ƒ)Íë“U'ç–©ãÄàõÞת҅{ß7pÓ›µæÑ ©Úfm…Í/;ª;qxžVZ%8¢^õ1ŤSÅ‹u#÷Oª,'ß+ˆ=¥™Të{ 0kÝÝs/ŸO¤;r'^ÿ|÷ö£Ù©;Ðí–á¹µ„õ‰ûoÛùÎ9!‡B wƒDpõ‡_#1E½®‚v, ý¦Š×MÃŵ?›Îhve…‡Ç±ËSû;ÛiK0ßmÅ¢àÊZ^.\ aà‡!-Ý,ܑ˪Ô,˜ûÓr†ù-\ÌxûËÑo£¿.컹endstream endobj 4701 0 obj<>/XObject<<>>>>>>endobj 4702 0 obj<>stream xWÛnÛF}÷W T ‰)[vÛ¤€›Æ­’ÞäE@±"—ÒK.Ã¥ì¨Aþ½gfIêâ8 b‚DÍÎÌÎ9gfüþ$¦ ~cšÎø/-N~žŸL¢ ö/õŠÎo'tMižÓåŒfßÇÑlvEóL¬&4O‡Dª^%ô‚nüëíK«¼_ Ýò]²8ýñtþîdBãvì¢(:z’;·âx<'ÇG>±ùùí±‡œÆ œ%Ó6ƒ¡¾×%)OÍZךŒ§lSY“ªFgÔl+]¨ŠR—ijUµKµ÷´tÍš‚WÜ]¼Õa”!©2;¶YÙŒ8ê±Q_€#c*t³v=ki©)Ó¹)‘¤+í/©îË’p¡n(¯ÕªÐeC~í6¶5<8ˆ3t—ï®^8” Y«þÚ¦1® yæ¦öM+O¹Xœ?Ûn¼Î"ºAf(®9õ1c&©H¦rÄ MÞX¤…¬ÍªDD¼u5骨¬‘Éië6´V÷:” çŽ —DÓ)˜” Ÿu\ }Ñ#¬µÊt=XœÒGfË.<ÅøH‡žPxÒNö n“Þí“4”¸ZŸ«b¨Þ]‰r¢¦j+H‡{]׆ه£¸ˆÚئÖ“uéï·w¿’5ËZÕ[Zn[„Ê;$z º‚>y€Z÷»R·t~fÊÔn²N;È޸F8Ò„d—8Àב¡ªœ7lâ:ùø=ˆ¸øP6N]qÈ>·–Î窂ü@ëªÖ÷ÊXr´<ö”;k݃ÔBÊ86å8¼q›*-¡eæ+=°ÝVgÊF— Ú±rVÖ-•å¬@ă$ÚÄMNY—* ÒúJ§FYó/ˆË‡¹1Åñ32‰DÌxæÏøI—;•ªÐžié$ÓF»Ô…ò½¡ßtßÇ‘™àŠ(%¹ª,i)»ãÅ•êõC‡lÛ€ŸÑsk ÓøhýÓ‘ŠºI‚DϾkÉA»&¦_%(dÛ"üb°s(ò=ðJÔN:ëå¾þ±ý}ùN§ a\°äÎìºWv£1b&ÝHA)€á‡ì]¡©Pµ_gýHÛß›7;s´(Z ÒszùÛÍ_ÿ¼¾{Cçg-‰Y—»›œ6­õQ¶ŸH[@üøOÙ?òpÜÐø~µn6uIRîö¬t¾}‡Vøüåi‰‹IJ•G§†¬ù³¦½þÛƒÉAƒO¤èé )ëÑj³Zé: a‘g½:B´ï§—G‚ _ì’\\F!<8Ð+–|™È•›b©k%#ª÷öôMjYšUÇÛ=¹ì“™¿Žñ]göbÀï’GO¦ÌõÁ@pyr€¼ík½˜‹ÌÓ#Lèf]ëÝÕ÷…Dæ\Úd;‘÷Ó´HA§ÚX‹.iʽ6ÏôÚr,JƒŸ7‹AÀ¸j¶Pó@üÞeÈgŒ;-NûÌî|èV½ ÒB¯Ñ6ÑÍ»Àö…æúE~tL—¥âÄž%WÂêËI®Ûu¨_æÐDå¶ÜI7ž¨R?DÈoËF}àËf&Ï‘iÙŒdD—: ™ 9Ò—)˜×¤Û¹ng¶t~òºRµlšÖø&¢—®ôöõÿ´ìö&h@ØÌ:Ç\ñH(&¯B«è_–4¦`º ßo¸£ár˜“ß–Â>5¹é}Ept&0ÖZìÔÒKö„e_«%V¡äx"óv¶C9ŽÃ¼5%é€KH;l`5š®Û¨¾n¤ÀJ0²r˜÷ܸ9‡•.uFfXV/eá‰/,» ñÏo¯Ûÿâ«ëèrzI³™4&ÞÌÆI4¡_\ºaÁ(ÞNDQÉäB,ÇW¡íÆ“(ŽiÞþÃÑêÙör2‹¦Iˆ_ÍøÑ«ùÉŸ'ÿ¨ôendstream endobj 4703 0 obj<>/XObject<<>>>>>>endobj 4704 0 obj<>stream x­VïoÛ6ýî¿âà"ˆºÆò¯ØI·¶@×ÍÀ ÛPûb  %Jb#KªHÅñ‚üï{$EÙR¼d†$¢ðŽwïÞ=½¯ƒ)Mð5¥ùR‡ÛÁ÷Á`âOð°ý¨¯&tíÏ)ˆi±¤åÛ©¿\^Q™S Bï,®X²å¹Z{ÃHÜ_Ãõëï^_ãÕ%Mq0¦Ñl‚Ÿy“ÀÛ¥"LIHºãÕžjÉã:#‘Kqb¤ø¶Ì˜âfLÊ Š‹Šø=ÃCîë´#Ô<š]¢ï×B*ª8‹x%i'²ŒÊªØ°M¶§Ë©‚ä­(I¥œr~;<©7#ÉC%Š\R‘‹îXòˆ\ý¨ˆ%œê<ãR¢ ˆKQq WeÈpZׂ¶¦3]IR‰R— R’Å–SYìx¥ÛÚÔ8[‰ðvO[V±üÉM*eJÃ$"à@%«J‹MÝŸÿüù'Rû’oYI™ØT¬ÚÆ«·¤/1ËÑl©«˜NüéÔŸÒª™‹‰#YòP°LüÅtÏÝÉèÐK߀é‚$…,§ ·—ͽ^.uy>@YîsÅîu3LbrYVìä·ödË&C†™?Ÿƒ[Q‡D9Ûòá S3RðˆÈ÷}pý™ˆ—˜¬›þK:¿ž¸v"߃~üǬ§sÚ¤Ï0˜ƒ®/KrOßÓÅAŸÆŸÞ¼1=øô‹¸•ì85¹›IYÐY& ïˆ`­CwžÇÔÅÐ;³C|è@$UU‡Š>ÒCç1ÑñB‹<,">|øø.øÐC¯EzFtnÎt;^)œèE¹© ˜în@Y{"?àò~Ø©C3¢—‡ìõ©ÈÎ@gÖæ\§;®å¼Åšº9uõ½œ®6˨ÇFÍܺY5[85³K7k—ÔÇŠ³Z[,\è†}¨åù5üŒ†y[«[F»í&óèBw¹oV•xÆ´ÉhˆÖ=·ô¶ù´:H鉘öEM)»NÐ,•ŠhšyÎ;k/Ã’™U¿¶HÇ<"Hÿ~²Jw,«9½?Ì«WæÏÌìA[SwGΠË(² ÿQkÏÎØ:ƒ6É1kÏ ý‚wës³àxÓ—¼êkp»Ú–…ºžƒˆ{þÛG°?Æ™xm€!Fÿ¼“gk.e¾0 ®=E/WÐýd…n€†Á,Ú!PWѳKÒÔ„@[w@‚ÃA4º‰-Øý>/XObject<<>>>>>>endobj 4706 0 obj<>stream x¥WïoÛ6ýž¿â€}˜»ZŠ$ŽÛ ÚnÙ: À¶è—-Ñ6ITI*®²îß;’²-'.Ú. ìØ%ïÞݽ{wúp6¦þi:ã߬<{¾8¥#|¹{1k:¿~Bã‹ô‚+œžÍ/Ó-rfD‹l0¥ã -6’LS%N•’\[KÊ62»‘æÑâýÙùõq˜ $“‹t>‡…Á+mŲ̀کjM…¨ÖXKK•”y°¡ª•6¥pJW$ÜÎA wÊÞ?’‰ŠT•M.i£·ä4eº²Î4™ó§í0~Ϩ€…烵0K8ÆÙ¢û“¢ „¥ª4ʉ*Cˆ²ðhìFÕ––Òm¥¬‚é”^®üù.\tÒ¬®åšÃÒŽj£oÐ)gIoÃÍ–È­Ó¸†ÞêZV̼҇~óò7`…NÒ ̦ÑÚõÊË2²”ü!•Þ’¯Žm­“åS>Ú£(|ü5öãõ9àj²¡[QHNÂ!F>°”$–ÊÎé6),Zd*ÉŒà½ÏZûŒxˆç×ãyäDr•2áÿídvE iOþ¿X¦×tý!‚®¥Î›BÚoµþ*\'æ*´È‘kÞU-i“K3$…à@–nP¾‰Ì5¢rYË*G~ÚoEðìV«À¸ÆJ6Ÿ·•(U& ¤/:óå/e©M;®œ µ4´硚À^–1²ߊäÏÈR* «+T·¥•@»ª².<| ©T•*Õ÷/·J¡õMS“¦ðìúšþg^4è‡r¸·gk™©•Êz|ŒåÎ Ò©cwZ}5éŽhÑT‘+£Ë=³Cþ¿(ÝSˆÎ -7OŸà•Å4h(˜þ²—Þ~'éô}zRl ªò %[*AÜ!-ç…•2§X<¾·d›ºÖ†ÕÄ ³–n—UËÚzBÊi…~nŒ´ l§žÜ”,m&hMî‰é;uÓÑóˆ˜Ö6ÏÜÆàïNóm“mHXúCÜ oáÅwÉ~@0á-ŠŠ³²‡bo †Å pÞÞx†X„QãÝS-Œ;H†®YYyÆD‰Dûíìù¢úÜs¡Þl ÷QÇ0L„1¢åw@ÓË÷P>øA>¶FÔÊÀ ÷ Žö™Â<ã†Æ`º•¾Å@Ò¼³ÜÙJéY“Ó‚½ôBV˜l~(¡¬*æ~Ê®µ¦ÂwÝä W×çÅ…0ܲP+Œ–‘–ieý<8¿Ñ<2I'ø$Nñ)¼ær6Ÿ¿«ßÁAß|âNÓGŸ!ù\%tg!o%¸Çòp¸e-á9ÁcãÑê¸9$V¬¤k¹uåG'+Ë•éă~×[„ß3î‹Âz\;rÂp @ñxââ–↷`1 `¥è*õâñcÊ a-p6(iÔìZ’$°ÅñÕÛ2ƒØxq3Qý9¸ˆ Ñw¢‚g6as#cˆ8ʦp Õ?tÖ£ÅçKæC‹4ýÓqÇOZ"tôñÇÞ·ÿvQL1\~.Ì×Ûî4“.>/XObject<<>>>>>>endobj 4708 0 obj<>stream xXïo¹ýî¿bp Y'Ë’8¹÷!¹Æm€4MMµKIŒWK—kE-ú¿÷ÍÜ_RÜ ¹ 'iÉáðÍ›™7ûûÙœføoN×7ü7Ûž½¹;›Mgø±ùÇ­éòöÍgt·ÂÚ›_ð!—çøÞ•ä7šöNívÚQfsMk]j§¼Îiei•m¨PåºVk=¡5¥×®"å4mT™Xç7ÎÖ똪+MvEÕNgFä;M¹®2gvÞò¾2Ç1å#l[žß}=›ÑÅü ^Vu™yüXMé–Oþ¦¶»gšlM…µ¤ü±ÃìæÇƒßØr" ÷¦(¨Ò:\§0{LõG>ìòvF/§×ŒÆ¾ºš^_ã[>Â!‹ÑbôéŸïþ|ÿ›øç?z·Ùå×Ùd1z´&§ñxqNPn=Ÿ/¼ûòñíýîþÖÚÉ|qŽg¿þŠ»àÿNûÚ•ôáïß¿ §¦\È©×Ó››|ªào*ñtBÉÁ-ñ¥=¢ogDØÅ¡ŒßQ|©«¡I¸Jã¥)ݰó*óµ*Š©vò–oobVyWcÈ #²^™²"S"*[Åá$µ´u›8[ª-V[b¦˜À?LµïÐLQa*ÏDÒ¿×æQº„p‰7WˆÔ£Qò=×+²®ç’)7Ú¯ÊL/Î'B¸ÈZ‚¡:Ò֔랓 f² 0™ZØ` X!É$Žé±8 I‰Å Ê€ÁŒ_íMaü¡çg³Póêk‘ïtæ¿\*pÑ&…=!Ç€.NtCØSzã¬ß~þ¹çQ„iJ±{ ÇpD¢&É J0x’Ä¥ä+lj¹Øæu‹B®´¼"ð@èÚ4"‰Dí9‘jM(!+“Q¶Q;©9œè¹ÁŠ ñ‰»®žq"1…_CFH%“ËSµ7kW—Ój¿lÕ•J;.r¥V.¸fwé" £\67åqe h±Û8úþb@Ÿ{7™ JÊ8Œz‰¤ ^}ù‰¶Z!=dÉÚàÞ©ˆ²{‘tÌ09N˜õ„ó¡ãe…AéÍ•WÉí1ŸEA›¨‚¯züŸA$¥)rû• ÃÖ ÆÄ¼èë…$Ô· Pø2\e_˜é§¡2I"Å[ÑÆü±sax˜Z’Y®) 6uûqÁ•çw( *$ŠYàCóõ3¬!ÎqÁ”04ªëت¤Z4$¢ÿ¥þ&<ë;ο¦àƒ-E~ÔìÎéG†¥o–Ýä'ÆÖP2Lå½~~$þ=­‰Þ²âäLg­ûn?>áa’T£P¶¸vïÄéÞÒµu¬)ÉI ·; Î†Øå¶^¢cw IQì´æT„D³.Uö ª¨ u¹ïhdä:OaÁÒ½ñ8Úa“:Õ6¹6ÃßS ? ÷A’ÊýæÉ¡€Üzä€X”©mêh~oP&¥AL`×9¨ \4(UΟžSlGh¼Çp JÜl—ªBáJ§`Y©‘É)¬bšY›"—/n]ozE;4«°'1Êÿ fŒ5%dáJŸ ö<ÒêOˆ±8LÐÊÙm@hBpš§ý ³Š”5¤Ý)¹,Ú+]6ÛhÄʱï¢L C–°lÅbêÔA=Zkô[v|©ÑqÀ¥ÁiýYäĹ_k$åQ€VúÔZ u”…~.8F §à’ˆihˆRLEÞÖD‘©ÖM7äíÀ¬8Öï:†õµ#Pj`ãIˆ «VÌžƒOô?v†çÁ¡ !²íEøys?îÁÂ5¦;Ìc<Ò¾;5ã‘ż̊ïTÎsÄN–2Xr(+ã¡ù’ëÐ%¨šlj;%}ÖžK\„x$SH>ÛˆÌ/‡¨Ÿº(‹º¾DEΟâóÑœ†–’´sMÀ¬QÙýêò:–RSUÖ8Ó˜j8ÂXå¹ÓR5°¿‚ð“G(óH­và\j¿×@k[Þàmm^Õ寬o‘ð˜ò ÊŸÄ%åòF Šéß>¼‚òtް q€G¿·épZ¢CÈÐËQââÆ«J#ây\…4Q9H°å„eÙ]ï6ž•±­ž/m« 5Ž ×FçaÕŠ¦&¶§ôFgŠ –¶ [½µÜco‰|£Ì¸¬.Ð7§ËÌ@GÚUÏ>‰³“CщÂDΓøÄûvŸòQ•Ýê=¿®ðÎdËôâá-pÀ¨ _#)øUOÅg'ï`"¼?`wZ±ÐdÞ{³¼dLi>/XObject<<>>>>/Annots 1686 0 R>>endobj 4710 0 obj<>stream xÍXïoÛÈýî¿bpp ÙhQŽe»‡|è]“C€ ½^t8`¬È¥´1¹«î’–Õâþ÷¾™%%RQ€Ü·&±j—³óãÍ›·þ÷EJSüMévÎÿ²êbšLñ KùÛ/?]¤³ûäŽîî’9U”ÎÓä¶}*éÓEÿ«É›þjï«É}µ÷\Ñ,}3x·ÿŒÕ»á¹ýg¬>¤ð.úÈ^ý°è"Ñø5ݼŸÒœ_4›Òü¯Ìïi‘K¸SZd#¢grºÎJ£m«Z}OÃ?7×ôQÙu£ÖšÂVg¦0U.oJM¼Ÿ®o®Ÿ/¦4Ia1ýNagÖOqÇ“±…ûž×oÞ¿!ÞPЮLf·­+£w*ÛtöBí¼¤,)ïÕž\A[gl­} ÚQ´ƒ:‰‘œSï·ZN2¢Pû&«›h/§z£É6ÕJ{¶Êo2›ÐžžÐ'G»Æá]@3(èÌÙ¼sÛK§rÉÔT›Ã5Ø>ç[/_õŽ çÅ@a|¨»S Zùl7Ùü!âyB di?ða™:Û!* OyCÔðóÄøF½ÀhéµÊ÷´ÒºUäT·õ-)÷ ^s`ÊœÌpbm욬ޑ³:$´@Œçú–ü-3Û(c5ªìÖZFieÆgM©|¹§ÒØg¬—&ÔI¬Å#¥(o.˜Ìæ\çtš¤³dF¿@}X/ÞíŠ]  Qg)s/ ÍÛ1<‘6®¾• ï*)G¥¶«£eµÝ+™*ËóïèW Þª¥+QåȺšw²¹ÖV#ÓìiçÕ6Éd÷òj Åå ÁFï:ë*Ëtæ‚mòÔ¦B£ïC­+9ëÀŽ© µbø’HI 'æ7îœC·JQœEzØ;©ÃYs]JÁ\£!k {FjMeP2Î'÷æ_b!ú46™Í’Û[Z>úSks92vyEï£kúo—"°D‚3²·}úíÃOO?F—~®ýrtiì¶©ÇXŒx ¾LÇt™>å:dÞlAGË+|üö-Ø ?½¡Xúû¯? ©!ø–ô¢›_¡¸®º6kƒšÓVùš¤~*ÚGF3Þéboùnà×ð@Ô„©–_”7jUê„bAJ•)Î2¡Ë“°œ~Ý‚td«¤þ‹Ó9‹ýüîéúôh.3Fnõ!µBw$ôWt(E –X©Ç´w …kÊ´Sû ­óíÑrÚÅicS•K¾üži¾o”Ï'‚«.»}笼sãáa¹"ebÆäùãðªG¹U@—ï6û¯¸üG‹tR>§…cºbŒ%â P¥<º„ΜÇpÛb6Ià\è;ô ”|ëϵ™Ô  ÉÛx(û <Œàø´ÊÔm—²]f’-¢gâ÷R7ðåÄ„³àØ#Å™ÆóƒŸÉ.«švœa…± ÞÛ³ŸÂ |ªLù`å§Ö<(°Çë¼EIÄÁüçÐltàQ/HSm=°‡È ˆ›ì¤ÒÿÈ2={áX™õ¦ÆP‚C€Ð} ?,%¾ó"üpH¼ðÚ‘ìЮ0©°<æ^ÄŽ„wZæï•ÊüòæòØRË[^^ñKG!5Šó.c¤@¿yÊ œV:æŽv‘ä zØL¯¤$ÝÀÕ‚˜ ÕJ@¥~à¡~UÕ¶Ôÿ_t|Êô®?`t\ctm‡ü,’ö ¶1n8íDôhP9«+ÊaBzó⌃ìÉWLj¸ù{—øv~áÃË”ÞbNÉ|ƒùsñ ß’§#RN$÷ý¶õT"=Èô‘uÖƒ8Ïc=*b™{¥# 9"hÑ"5+2ˆm‘|b“dŽ‘ô/G•Þqqdv¸ÈL¯à@Ø ºÚ›VSµ˜1”_7.-“É„a ®€ ¯ŒY´€‚cŠÉ5$::¤íÄhT¼ÈoçmÛ£]þeÄpðë0WCççLäàˆ@hÄ ›ÍcjYz/ö3“cCãažµLp=f‘tx_º W‹BÖz*ŠS|PW8Ó2pÔ:; 5hã0T ]½sþ™_Ü™zƒ@©±Mõ‚7ª•±q ö÷¶b“EÔÞˆ‡‡us|ÕAÞAâ¡ÃÐ*ˆþHJ9^OhG²0¯-=v'tìÛêèSLŠØ“#Àµ£Ü°Òguüž ,kº†VÞ8¨1ü§tÈ~¸ ɹk09 ÊPèäxîIC‰Ô:i¡óî¢kxêµ0éà±2ÄÇ`Dë¨c ¢Þ 'ªÅ˜Ã¤§Ë Ñ,`¤=Øxˆà÷G7yt P\¢QW®‘›Æñ6 åÃU40µC¦p £ÜeÒ‹R\} Å¼˜œÑVv¿>h1•Ð/mÂ'÷™àŸ±²Á¥€1§Ê=§Ë-‹¾Å¢'iþhV7ü‹\]’°[ÇÕN‡:ÿ²¥Yy¦¼–œ*._]ëǓۧ®.ytñ Ò)ÅêòÑêñÕ—ÍÊ&Šiâ"õµQ”Wy á1ú!WVÐh{úÌôU:÷L “jK {ç7uHëæCû›ÙôMrw{Góûy¼¤òÞÉ,™Òßúuá—ܸwro._Üzï¦óäv†k1.OéÔ_z·¸øçÅÿ^óý™endstream endobj 4711 0 obj<>/XObject<<>>>>>>endobj 4712 0 obj<>stream xÅV]oÛ6}÷¯¸h^œÕ¦õa»N‡¼¬‡ôaØPCQ#Ò’6ZÔH*ŽPì¿ï’”èıãbÐ$0ë~ž{Î%ÿÄáo éÜþeÛÁO«AD"ü2|¨&Ë)Ĭ6h;¿ÂæÞãC6¼ãÆpšWšÃF*(äL[s TqØÒŠæœ‘ËÕŸƒÉò â)™ú@ãdaÙ0ŽHœÂ ]¶´F¯Š¼çJHÊÊ*÷ŽûüãdJ ë·*Jy3SÊ ˜Ä„•4@ëZ´`$˜‚ƒ6Ô”öŒÏ@Ð*o° ¢ü‹ÃzO]Âw#Ø ~”äÆEñÝ`²keÛd…­+‚qœØR\°w¯_Ã] 9¯¸Â´UbYn É4”•IUÎM(‡ÀMe¡jû”«W`žZé|üãæìª6 ¶õ¤ ÝÔµTFƒ­¤ïãQn‹ì¦©`šÀ‡Åè¶|åZÙ`‡÷(dRˆXÄ øxÐ âþÖ%‚ÁÑm A(’„¤)þdžee ríÖ—?öeZêìß2ÙÜ § ²‚*øÛ¶Û.ΞŒc—5%óù÷ÖŸÑ h–q­ÌûÊwŠüP[*`G[Ø(¹õÉTY»ia®jÅñóåö.à·§Y=éÊõ›®/aÿs@X_±%³GÖ­‡ä˜ù«‚ !_¼SgîrøÁ¸@mŠÃ¤î‹x©>/XObject<<>>>>/Annots 1689 0 R>>endobj 4714 0 obj<>stream x­W]s›F}÷¯¸õC*O$H–åvòàø+šº–kËI3Udz‚E¢–î‚UM'ÿ½çr@ND*{d³Ü³÷ë\öð÷žC6~êù׋÷lËÆ 9üu{¹7[}Y6Åø;°FÕUDw{õ똧qÑ`tX ÑóßMk¾ ‡zAo.lÁÛ4 צá±c ‡G4õ‹ˆlšz*?Ÿé`úמM=«þf5 hÖ›3•Ï#9ë½0ØÎfôï×ìy/-³\'ô°Ò"}”zp  ×eôìàç¯á>o/¾X("Á½}Kî·üWñÞe:LµxéÕ+›q’É…ÔÕº³;i¸ÿGRk…ö¯Å"ó–“‚<ñ²P%?ÌfÉþvŠB¼¹÷% ºØsûU;Ó¥¤4ש2’T@.ýu"âÐ#?4){xÞžBC™"##ée…©HS­RŠLÒéë×_,çÂHŸTB(xËæëTš^¯'(æh‘Qœ›lÓ7—I3G0RJÇ@Ã@çIƒ„be2ŽðîãøòGÄeF‘H¹XHcUû¸Þ‡³ZÈDjÁeù®ÄhÁüIFkB÷½Ç5‰ ¡¶èZÁu‚uÁ¤y™O,RCˆ92Á:Š#žÀ~çnÏU„ž] LÅËÏ–žôeâIú ¢\nÊZ<‘‘áŽÑË› 8·êaúéæüôýùé/7“ñõôü¶ƒMÍ` ða2>»™Öx íòðn2¹ªmÀ{D4j ð¬Ûåá…=¹íœaÝE¿ÕCÓžúíúnÝàÕCӞ톃º‡ÃVM{:l÷à¸õN [=4íi¸ÛSï²A¾£Ý.®&'ÓzÎ4Ú 8›Ü¿»:¯#ŽwN'¿Þ\ÿ^C8k»Øw=>}Òˆ–‰ânz;¾¾|öâ´0|ËpN c·0¢…<§'··'Ÿ6a9vˤòàmCZFgØÀ8vË,Òw· -ÃÈp°ia;æ6²qìúlÜòò]|¬c»‘ W€N~_óë gÓýo*È«-¨›ôËÙSˆ{b²8‹“™gO¶R‡vÌ*\Xfµ(—7ò´ÓÅi…sŒkœ¢ë"‘Að…‰å¬zp„C6m @èC? gÕÌ•JpÌúƒu«ÀûG·Ð"_­ÔŒ/¡(ââ¤f­Rê!H‰R)”šŒsY(–8JY•¶²èJ­è‰ÏÚ2_­ÄÚlnoÆ¿·¶|ê/–Ð[%Æ¢ ¥Iþ#XˆtYBòûE¹UåÞ \Õ—™.²Ô|n ­êùMp¶lê—{Þ£¨…˜CO–Åa¡’‡>‘iKc×äLS$ís‰Š öŸ5®E`E%jŸ'ušQ UÌne¹YCŲ¾çþQEÐØÐí¨'7®ÒC£Š5®=°1öÃѰÐCÐ$=/±gÊ+^3 ½ÏÛã5§´ì1ßüŽc[4ÔF‚sq6RÅ`È¡=´p”–Ö#——Χ{¿íý¥¥Qendstream endobj 4715 0 obj<>/XObject<<>>>>>>endobj 4716 0 obj<>stream xÝVmoÚ@ þίð¤.‚(„Ö”uBÓFÓ­*YÉÞ´L(MHîØå¨ÄÖþ÷ùM€®R«}( Àw¶ï±ýøâ_ |›Ð²ä'˜VÞ»C7p1ÿâchÐÖ[àŽ i€õÚÔ-ëÜ0Õ2À ª œ…˜0 b1#LHð3¢càó˜$ 6jîUÅ€º‰Ê¡T>g‚¼”Ú©²WýêÕ JÀ‡©p#Ƴí©?󪹞6ã$ !¡éH‹Ü5C×w¾ôN†î7ÇîžÚÝÃÞ¹kŸØ^­€V¯ˆ ’ ãø3:Ö¶«Íi) !ÕÏ¥¥a.ßãaiL|®AnŠÛ”¾2HkõõÚv›€ÑDHŒ h )ĵ˜zPvD™Yäà ~òÕ’Ã|ýžsøkìÆÄdz¼ZÓ-8!»ü™ê–?¸ñ¶$´Ì¹§ËšòlÒö¹ß;r\ÉÃ,;ez²¤Ï„^΢yEj¨e²-Ÿ?Ù#^tdo©žR»qÜ9DÀl¿Ò÷[û`Y8™µp6 ÓF®7uŽX0Ÿ*|1*­7L»~`¦¡›hƒÓŽW8tÑö?> B¼^¥É¾aé­&‡èØl·ä’íV>Vþ¦ Éendstream endobj 4717 0 obj<>/XObject<<>>>>/Annots 1691 0 R>>endobj 4718 0 obj<>stream xXÛrÛ6}÷WìxšFN,FËVÒÉC›6mÒ[”é‹f2 I¨IB@Ëj&ÿÞ³ ’%§Ó&ñhLØ]ìž={à¿Î†4Àÿ!¯ù'-ÎÉßðÇ?~ÿñl4™$MÆø,h4$×õSNïΟñöùM29|{ð\Ðx8m-ñÞïfîħ[ѳ×W4Ðl‰¸®Ÿã—LÂÁ/iïM Â¬Ö‚ºÕ¤haÙ%¥¶ ºØä*[^Ң‚µñø>Ó´Vž ít¾#ëVª4ëŒTžóưִPÞ¤ôêéS »ö—´qöÎdXäm¡ÉÖ³?ÏÔŽN×õÓµNoM¹'—¤JõÞ¬JlÔ*]‹5„¸q:Õ™.SMw*¯tR›]±©×¦D(»K –VºÔN-Qe»Rˆ+3~£Ì-«2Ç{÷Ç›©òÚËÂ¥Ís»å@T¾²Î„uñ‚] šýèã—;ír«øD…k›yRNÓÒ8pFðb±ceU,´ãÌ8ýWeÞ(·ª ]/?{=œÖÕéß$ b>º¾!ö¹/¿«³õ¶ö¹EhâÄ+¤uï©u Q¡"åAPÇÙó[³#ìKãš¡ŠRD1S¨ML‹  8-¨ ÐU(ž:-N£‰ Þ[ç‰L)ÇL­CéO—i÷¿‚ì¦Éó¦zo–´³P|§ËǶ¨p@ŠT‰Šá7r‚5¨ÛèGKúUYwÞ+‡u–¶fGja¥5±æð WåÚ'ô“Ýj@ö.;¸o|—z‹CnØTÁ¥Ä[“#e—¾ÚlÐsêÔ…¶:Ïú¶D¯øm•D™YdÁ㇠pçíÐ_tnÙmÁºwõ½ñðàyÐôlJÁɽâ.¾Œ Ð43ÁŒÐÒ£Q2ã)ë={F³xZZ‡À™|p°ß¤Aàþ¨>õ¼gÊùVd/^Äeô±³ð¹œ÷~ݽ3^1iÌ{_IöæØ}ºƒwÑWCzyhùÀÆ·>;4ó͉_úD:÷úsö™C>èûTo˜Sæ=yæÓÿàœÎëé{4 :á|~ñŽÛO'dóWŽ)¶­NddÎîyºVŽžœ'$ÌÁÜz”ÜvÓQŽ_¢ãx«Ä³gœ¾sœ\ƒ‹PÌ3» Á”›R¿ º˜ùÇ Æq]KFI& æ•ç×ö„7#̷ô°P À³;íb´=@<5-Pn1ËÓ)¡w†GC{âå1vÇãŠã²_j*§1%ÖŒiao¼«Q-Í‚¿%¦Øf¾ÄQÕö4sHìÏÜÚ[oÉt;î£Ü,SÆÒ€¹[|>nr”˜Çug¬* ÈšÓ&í´®çÍÏ6h/3h_ý4š5Ìszœ©´gZ&J[öO³ŸÐw:UX'·Á¨Ž\ @ETñHÚííùÝ7à” Šf=7åyƃ³ø¹ç+Cíd\ó-QËB«|iiÁ£d­+ÇÌ•&„ÝuI  S*€RÅó}+ï * ÎQ T±0«J”’+pPHæl¦WNÃ¥g6o1žšqö6g¾fÚvLØÕÌ©fCœ†Á!! A„Þ9†~«ˆê`éFU–<¨—Ëh ѹ) ~¤›ÅèºùŃuˆ™þ\€.nùYܼ& R½Q.…Ióí×L&eî^'ªD9èH{sUì™&ûLß’n µS NUUb'Ô,œ„Yb*Ñu@@+éð;ïi„B£ðÀ ÕÂCñæDu•C•°FÚh-:PÒ÷Ð^ª„ [úÅi}ËRÛƒ~„Vy®¤-¦–(9Ÿµø9—¸ºW h{™3’ ±»¤‘ÿ½sæ÷Møšé9 ¯Hé%&yTMS~ÌzÃA2¼¢·œ‘({Øäk»¾÷H±@‰_ïÍô$¼ÓÅi®•‹_ïï'`¼d:ewoz\`¹1HéSí‚BJ5¨n-haåThbnž´5…áªLæíð— ¤:Èæ–‡»h–Ãj{‘uD=Aê±Dkué%‹(ÄÀêQì¢áÙ´t,"J’ø2 F*J KHyÑ3þå£Ú´O~y?ûõý ÏO|5{HéˆÆùšßv¥EWGì]á$8Ó‘‹ÍÙE=@9Aw8iYÆë–Œ¹µÝv–‰‡ýp:–ì4 2§&ÖT°Ò¶>r;„îÛgYè#Š ¦ÌšS"lp£FKê¯ÁRï€]ëÖæúDñ‹+Ož7'h¯ R°¥ƒÂá #| “cã”ñXx¨9³dQ†éÙDõ ŽÍÑ©æÇø„ìÊEÐ-ÃxDOj }úwA&¤upín¼×99€M|³OL{Ñ=Hˆ‰³‡ 4±›`qwº~üÑúš+››îhp•Lƺ¾™$#évÉýþ–ñ½Måv,y`+ÀR\Ü¿‰‚ö„‡êÌrHZR™ ®„# N¯ØÒ³³ßÎþ©±v÷endstream endobj 4719 0 obj<>/XObject<<>>>>>>endobj 4720 0 obj<>stream x•WaoÛ6ýž_q ÚÁmcÕv7ÝÖY–lŠ6CÒ ´DÅl$R%©8ZÑÿ¾w¤äXN ¸iÒÄy÷îx÷ÞéËΘFø7¦ý)§åÎïW;£d„ÅÕöš^žÐxDW9öN_ã,<Çéà/³”·Òî‘_H+I9äê¹/$ WÉÔ“ÉéÙÕç—gpŒ žŠª*š¸ØYÀ€ð¤¥Ì•¦2éR«*¯ŒNè(eÑìmg)3Ò‘6p dK«<°o*YŠŠl h*gï#Ž'ˆf |^X)²Žs¥eF¹±ya¯¥§LxÁFºZ ̹\ˆ[…-¢(ÌÒQcjò†2C~‰Ÿ…Ò×îö‚Ä'ìæ_lI…&΋…úOR%¬wœ"A©)«BÞõÎÊ•uðΠ`s¹ì6!Û:cšjÇO·Ë´éG¯Sc+còÄñZä)úª”L¥K¢ÑñQ{ÃWɘbâf“é«Ögw‘ü°÷RÆØ2•ç(íïas渂Bª‘8öìpË«<·YYI ˶ -S5§n¿ƒškwðèáä(yÝÁ>Ã¥Ê;Á·.+÷(ÙçúŸ d&“dŸ²ÁÓ¶¦f¥gÏH!Àççï.>\¯ ZYVXÿÚe;x' ëô†’$!.¬[QÔ’rkJz¢tU{~òëæ¡'cù™Mö}k7ZRºéM‡êâýåùÕùÇÓ‡XT°Ïaü·74z ,ð^þsþç'y—ÊÐŒ³Aøü‘QŸZkìÞîéw:îHPeœâü“®Ë¹´?Ífzwö¬&ñe¥¯­¦wÞ¾}𸠊 #tŸbˆHN/7‘MÖ³ÏÖ¿Æ¥cv¿õ]¬ŸYåæñ3÷ä7 ·¿ŸLQó@u©t*·¬Ê‡„„Ce&„nPoÊyn`¦'Ø”Œ.ZІ»ÃJ‡JYqø‹µ‹ ËéX§×´ÂÆÅ®+´êŒ¶;6^‘àÓG À¢à™¢èº7bìÑ$8Ÿ9-Wéª}Ú¾‚çÞ……ëzyö兔3GÛqë%£˜üñ(Ò…põ˜š‘¿” ¶)]?|ú 9:â›;oéÞR%ˆÏ nVÃ’Á … 1UV•Â6!Ë è¤¢@¯Z%æ¸" I!8ä¼Ho†¬ià*3ÿŒ†pQBв ×Ö’ÒNe¸ó®„ƒþ,-ˆPZÊk ò2-  >rá<ž0ÍëVÖh€4$¹õ­ ¿\>!0À,¤ý$t®A3ZZQĺºA@fY'AVRg2ë‚ ùÅCa ó0Ûå¸ÏèAÀº´'´6 †–é3† ²a™D΂ø…TǼj0¿#(j¨è¨o]²xDFaÍ`9 ³ìÚ^pšºÈ‚#‹?Îá[±wؼhεÿtìÞ}=D„ð~”¾µ©}Çßyû¢yjŒžèBq ‰0X&žÀRö–M üú]žCù„bL…“±€bgu2hÅÕ{ÂéÊŒ;EÞU¨`*-JýÆ­òP…•ÖúH ºd©À:XåáDÉEÛ·­É]J§W+®N˜;7Y™Ó1ÞÄÇ-µ ï›lìCÿxr‹PQ˜X˜#xâŠ$þᤠ}Ãcœ©˜Oj D=#Ö9Šý& Ç"ÆQPv”ãÜ+"ňÅ,Ö $„ƽs_ î` sP&¨[>É:ެ ˜¬[¡E^аT ¬ôOÂ*H ܱÖè=,¡+1¥.ù˜ÆýÇÏл­ªÜv¤ë0÷2YOéäÅ ÚåJÚÅÀŒ³!Që }ÌjOA !].­CÞQ÷¸yx âÈ–qéK‰Sø}²¢ ΟÈ2\¸‹w1¡Ô¨Ho1­ âa‚ …Éo2á½X‫‚Ü=„--˜ ±{a2¾ÍúAtåÓÅšÐû P‰†ðÆÑ#D<¯­ Ãp³ö¦:ÍÓf ¢Àá·“)#^視ªî¯z t0Ï!ê©›‡öc]ý†’`õ8N}Í÷èBÉ\ žù¥V˜¯˜œQû¼²…Ë.œåB¡Yè+Ï’ßgV}±®¹X çmú¶âº·’Éè 9Ü?¤é¿§a@ÃØ:œ$#úäAA‚†1B qóðUœ0·'GÓd‚·` ã£C6uzµó÷Îÿïê°Bendstream endobj 4721 0 obj<>/XObject<<>>>>>>endobj 4722 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ŒæîMyénÞû£÷/Ê:C„endstream endobj 4723 0 obj<>/XObject<<>>>>/Annots 1708 0 R>>endobj 4724 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,ϬòÝðÔÈ7”•tC±Jä±jëJ°êuO|9ƒC´ >Ÿ87Ö<ßëþ˜­¹*wï‹j3Ù\ËûäŒÞß|þ9Ù<³Ö¿eÝPªjzu&¶ùér§¿‘iVrb$YšÊZ–­utÖÀ¢gÁ]%ãLäÖgã$ÕŽÛôŸ(ó~jØÿû½¤»·¯¿uÜϳm-êÿó~:›yþ’VsSÑò/Ëa‰^7]ëÂý~û^Æ-©ÇÑßg¡0ée)•&þÚ"–ÕâßÕlZÀÐh´Æ1y™šÖƒ©aSö íým[gÛ®}öŒ¦¹Ø=wfÞäuˆìèƒðÜúzßýD¦¢Ë[õ®+P˜ÿ‘r€(ªü_öû>í£ã仾Ô4äý|jÊâuI…(‹F6W”µ”5”È&«¹õQ«(F Úá'$âŽÇZT߉J©u›Å].jÐ1þÓÓR-Qbtµ²NE,=ºEKíýº¢ƒê¨ÈvûV×Ñ0üzTVµzÈI{¥~6½8m¼gǃáŠD’h #T  d< å ‹cÓ»2‘u~`¹ÒQ×MI–qŽ*OxãÇÞ£óàž²’Û¾5ã??pW5] ‰=ÍåƒÌI·dYSÚ•:!ÑŒ¸,uQ8{;eË`V'‹mMX¹BM¢ƒ ŒßǬOnéœêûÈÀœPÓU•Ò^ñ^…„k¨–UŸÓx8Q[ŒW·jî¥p{+ ûy'71\“~{¼Ç8Ëó+*$’•£ù P}€;ìHŽøbbÈ6ö6—}Užöi„³–…@üùB$–s,„]Ùfy?'åS•gqÖâJ™Ë¾•󕿇ð&Åí:½æJ¼ÿAôñU8A4Ä0­'<ÒNŸ-ÕXɧOë®]blcÊuÊ¿[³_"ͯ¯éí¯AžT™êí'·édx/1ÚÃëçq×¹QE…°o³>/XObject<<>>>>>>endobj 4726 0 obj<>stream xVmÚFþί˜¦­jN`°9M_¤&9šTQÕªTýPªÓ²ð&ö.ÙµyI”ÿÞÙ]Ûœy¹ä8Á3³óò<óø}'‚!½"Mì?Ï;Ïça8¤›½†Áì{ˆb˜¯Èv2¶Cõg -ùæ°Z™ôÈ¥GÙ,ºõ)v€IP{yã&—¨mõ©U®ËŒgÈôÃÌ®&tº)Ó'P‡öß|yþî‹b‹Ô…úÜ) E©e{írš¢3ƒµùï¿yÓ¶r™¡Þ·¨ÂÉä©mÜ\YXZÓ窔Üñ¤w¼¬ÈY–íß`Fìt¬ ÎÆºèz‹šW…°‰à¬ ’TÕ€â¼ÔÚ’ázáqø&ª\z…Ü.‚êzuV®Ÿ{øŠÐxìdûvoZüx‡µÉY­O^Š­0´U`y€¨Õ“k ¬CT=AN}· ÏN:ÊS;·ã†êÁA•À©Í;-l¿ýìXø†LIδç¬ÿJe™ÚÙE¹LªvÒ®>øu6¦æ=>•oN_ ±gñæ¼éhwnô sh<‹›®ã ­› $[t¯ƒÓb~ç4ò»¶œ27Ç"U xD°¥ÚbèMŽÂÛ'v‡8½á®–Ù£RîD‘B¦äúm¾Y§ÛÁÊS¥º|-ŽYF KÊÉ’„ÚGðâM+ËvÁ‚÷¤’I(é¬0ýù´œL,5Ó‡^Y½¦É1f)Hâ…±ªgus”V‰ÓN¹5fÔôØÝBÊc£‘dž“@Y'ɹòÖ!kíú­4…+'Až1íSP+Êq…;XgjIª¿eZ0ÚvøÕ°V® ~ŸHù×Bò¬LÚ ±e¸3©G÷ËruÜöÛ O˜êÔ½žê½W¦š¦^ÝÏJKþ¤+™ fÓJE¢ém8é)nFþQå¯^ÿÚÃ!¼T¼lfb›Fêå­ûO}ø/}Ö'á(¦=‹×éÔÆº›wþìüHþendstream endobj 4727 0 obj<>/XObject<<>>>>>>endobj 4728 0 obj<>stream xíV[oÓH~ϯ8*[‘@3ñ¥MSP_€váaA@V+­,¡©}œ ÏtÇã&ñß÷Œ'“ÆlRXñÂN”‹çÜÏ÷ãz1DôŠ!»w^õžM{‹èææÃÌ`tÁ„¥0-!‰`|³ñø¦E+Á4ïãÒ¢Qð±ºùpÕ”€Ëo¬ÐÊý+Ñ<L?ö"Æ$\a¡ì–`m¹mê HnHðA¥PÖ¬@”õ3Ò –½œC–üny§Ù Àù9DÙ ã>X͹ÍçYÿ–K’CY£÷ñ_çÐÊì4bçF/‚©Õlg(Gû P‚\ÊUÀÚƒO~ô.B²ëkx4êH„DÞq5à c´wÅ;}!nEMy¶ú†d§Ð›Æ¾)ÿÀJSÁéJÐèò\ßJR`Ã4]7¿ÿZ/Ž`!ì\(àðnŒž^ÁJ7s…;G(µ”z!Ô žx{Û`& KS‚VÑ/ts%© ê6 ¿—Ô™ÏH]XîjáàŽ Ú†³h´ èñ0ó‚à[»îS· Ù «ñåÞ|/}§ŽÀjÈ r‹”öû¿^ý~‡b˜sUH4T#èüÿ¤ØMôP¹l „H6?èâ° –âÑr¸íž‚9u=„ú„ïßxî(ÛñξPC[¶Üamok‚Nn4¿Îú­ ´ø<øºâAvcÿë}#æà#¨ÁÕ >¾¿íh êß é€.¡j r‹ÀéûëbÿS]+½Pw(Úo¹Ó›]hM¶Øiñ Lç¢QÝH¬PÑ„¥þÝÑŠ&Í_TÏBʦ¶ÆaÚav† — ä ¦*~MÌ´°Ðæ®ÐÒ´oyþPJPèmTº%™µÎ 'Bˆ7qüVX[’t÷ÜBñ3¥O¸ôw”éC¹ä [3x1Ù(iW “±3Ç,¦ôÒñÍ–çß°îZtJÇìØ©í‘w5á²Öàj fs[j³à¦`pIC—ÜUðþéõ‹€ízù9¸VŒ±ïæö²p²Æs<9f'é ŒÇvê÷š[ÄEðBç͆†¢4»½ôðÔ¯¬ÕÉÖÞoiäðíö,lž/üÍI4fiBœp|˜œ9‹ÓÞÛÞ¿ßœ½“endstream endobj 4729 0 obj<>/XObject<<>>>>/Annots 1711 0 R>>endobj 4730 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áÆÎ×Ö³[yuuôÇÑ¿ ¥endstream endobj 4731 0 obj<>/XObject<<>>>>>>endobj 4732 0 obj<>stream xÝVMoÛF½ëW Ô‹"%Kþè©uâÖ‡"h" ]VäRÜdÉe—KÑB‘ÿÞ7KQk9hOj¶EîÎÇ›7oæAD!¾#š-ø'Î?/aâáá—ÝÐä1¤Û`FË”¦!-î¢`±¸¡eâO…´ŒG„¯X¸8£Õè7™»{o­±«KúórùeÒ8¹ğóg­_W£á‡Ú‘I)÷W†«Ë_œþÖ{â?M¯‰Í¥4F8ãélÎès& kQUTZ™ªgRUuYj%“+r™$ùËÒ)SP&ŠDKËGD{‚œñgbc­¬JS$ªØP"aÑ Gþ@UÊX¥°¹w&*j¤Ö$ª.Ü)§›XOdáT,´ÞQ!r\Ië"fcÞ­–}Àn"­Úve°%F¾M•½f›‡Ú#  ¹kIuKȦTEiTá ‰U%{é4Œ˜ÙJ«ð¹ ¾Ð#B—Ï"/µ¼ï"9r`<³q}X‘±»¿G®l«<Ÿå€³»W˜ñFxl:¬ùF/ý÷„ûÉ9g\¿CQ*F}OøëÊóŒ6Æ$Ôˆ³2©cI±I$­QГóeº2\FÁÕHkÝÝÞቷO·SÏ¥°®âÞ”InQª´ü7uÍMRkîO‚Α/ÈE¿«PE¬k$1¬L.[wA6ì_é- ÖL&ôýYpŠ©lŽu]Y7ÏY ûvÈÿoéÇ­ßÂþ2×tÊÉüL3½Úb¯vX×SEÿ(Šü® Ç{=*ùL¦UuË×þ©¨FDxå;|S>‚Àà‰Í)—{á^¼NÁÉãüü¸x0y U_+­´Ù¸N鎒ºÄÀ`?GþŽþ& ë áhìR‹XB p¿“{áÝ”Öl1ZCð6‘¬ËË„†my‡äv¥ÌEÜwY¶ Þ¾ ÆÔˆ@fO:Ç+4ÃeÖ4O¶ï„GH£µØ@gOL?~i¥«-þ…ÙV*ºX £šÍ*œDMý,Y÷ƒÛ1f¨ªr߫ݨa9<Û·ýj ({EÊQÁÿ!?c¿²“L¸ý …ް€6'!VýI›×Ø=ÖÒ9i÷ƒóŽ"`–b½O,9Q`q¡O<º…¦-¯Xk‰…æè£-wG¾}øÁ‹bœ; …÷ ÃjÛJ™Ï½ç É¢V’§Ef4ô¸õ뵿ª×Ú¸æ¥À!qmIÇ1öHPe¦i™%¶Bi~ßâÝóÉL¤Ã¬& +£ù24jÏV\¹Ì£óÙ-2Ÿû¿ÀîD3n0ùï€ÌëžM)m»"a …ø\yÝY€Ë~åÁpÓú ÄqÆ *¶¼' ë«C9`S]‘tq°ºäÌÇ{—ãh„7¾–ox“âwæaòðö-U»|m´_·|u9÷.Ÿà9“¸ôšÕS{~³â¶°…§.úøÓç§_ZÚÜî•&š… Úâv„w#ÅGÆÓ ¤w&®sl„>mŸÝ4¼Ìsß´;²çé¼Ì€D¥©´¸rfH²y¸fÓ¶ Ñ]ÄÞ/¿þQ{šendstream endobj 4733 0 obj<>/XObject<<>>>>>>endobj 4734 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¥ó¿ÚÐ××þ7GÙ„=z¯ã’—;¿arM0 *éΘù' ü0µÄº^UùÇÚz­â³—½Q8Tk9 ñ­»ÉÉO'd÷endstream endobj 4735 0 obj<>/XObject<<>>>>>>endobj 4736 0 obj<>stream xWÛnÛF}÷W Œ‰ÖÅV}ÈÍ­Z£‰Ò…€bEŽ$ÆË]v¹”¬ù÷žY’ºYJƒ8†c‘»s;gÎŒÿ>ëQÿz4Êwœ½Ÿu£.n~¸9]Þvi h<£~—†/zÑpøœÆI8Õ¥qÜ¢úë统ÿâǘsŸZ3i…Ï¿rfÝúsÖµéü¾ôdg”…‡ç“‹—ãÏg]êô`( †¾P¬|¼˜´¢(š\пOˆ³£žÞ—ƧW®Î?šcW†6ñ÷¶gþ‹|º¼½" gFäÛ ê|[¯ Rn^fl|Ѧê(ÊŽV¹n|MZ“‹}[-òêaI-ȯs¦Ø&L“¦Æóœ2V&ٞʸ(Ôœ©ð.5óˆÆ \*C zME™çÖyNš,úRÅ­} ˜é¦ u‹b§ß`šT×Å ¥klDB¡ïîO¼Ø­ø‘k&áÇ7ÇÈþÄ«·é2-ÀŸ×ë?ÙÙ§fï—ìfÚ®N\ÿ°6^rû‡Òå)¿Ö…çì„ÕWLKêòËŸFü[©õ{ž1P‹·xÖßðL0#ÒxßÌ®Yibé:t!¥ KS¦²àÌ \ËT^D•ÙÔ»Š®„áàw$¿&­^/êÓýô3ÇèЕaW,Ò<ñGÃ+^T×›öËWÑh$·_ÊY÷¹³SÍ™x-lƤò\§èh„VPZP¦ŒšƒÊr0g·ã ²Py)"ºEƒð£ÊrÍmX6Ešà¬¢M–:}`ò‹´ø:¹o­¥gS­ 'Ç´$¼žÑO„ áÓÊ©'ŠäØ—ÎÐlÿÅ1©ØBx7£µ-iåTŽ(y÷®Mhû…mµƒÀÑBd,!w+ÊSu8Ka²TIðÐ¥µExUňD¯ÈqQjß®¯Êï(¾¸Ñ­äâÑ3 ì2›”šÑZÐIÊðÕRMšÕ”Jô@¼ &ì–Àu‰CP¬Uª5"AoRš=7`Ri4DŒRO"ÈÍ€mÌΫÔìÅqá&ZIBޱcÉprˆø'ä[š¥H1….KÝ¥Á• Rúè¢$–¼ •º;g°\y„SÂHêŸSÔoQ’:t ²ß#ë×Ù¸µFü>¡ö¨^mû? ¢-»¶vxC+ë éœXÆCh’ÃŒ B*ãËááÉÍ4;8Ñ!‹j9ñ—ìÔ\y¯â…@:ÇZvLú)´D8"f6¬Ë•Cž]úN§EP À=e°ä;K{sÓtÕËf1Ùùÿò’î´‹èæ1k;U:@Ò„f߶̵.6–A¤vbKèä¶›•ßÝ·"ƒ•¦ž²üìæ&¶ùúX¨b÷ Þ¡†~aƒ£É«ºr±g»’|>9R>-Ø<Á÷„¬·¤¿e³@}’¶6˜¤Ì¼”=¤’ˆ¢jwåžC‡ÑTXnöµ\ºiW«dw¹‚LAð¶I ˆP%g0„©¥Jo3p!ÆÙ5Í•›Âs'¶Z£ã@–•$ŽÁÔQ[„à¤Ð˜výbW"B"xxŸpÎ&AG`3t kP9 Ìc‘c¿M +Ø^8ùI C5^X[„ŒÓ¹E¿S4ì†U„‡ƒ„£ž› `KÆ} ZŠŠœã$–­“¾ZÏðÌ1Ÿ7ƒ06{|`°ÔSãÈ©ÀÛ+K@ íjoC-Uª:A*[ñ´RøÕ"…|s2ê¦ \«¾” „—9#[*V„c™N™×q=ߪÍf#.;ëÃÿ(r]¯I«.¶„x¡=£s©Ü¤õC=~^ëñ¨ÞÇz£«èzpMÃÑu4ìmÖèN?êÒ[‡?‚˜IþïêtçyõW6­^ôœ>†¡3ÃPݨ-d{ê”[ËÝëî0ô±¦É‚öb ÞÏ~?û®+ÿendstream endobj 4737 0 obj<>/XObject<<>>>>/Annots 1713 0 R>>endobj 4738 0 obj<>stream x¥WÛnÛF}÷W Œa‰ÑÅ–eç)—:ÉKÓÖòb  È¥´ ¹Ëî.-«Aúí=³KJ$Â(*’¸—Ù™3gάþ<™ÒSš/ø?-O&ñ#ü6å·ßߟÌ“xFóÙe<¡’æËÃSA7'Ýç’Φñe³–g»Ï˜=ŸÁF°äg;Ϙ]ÎâegöͪãŒ÷Èlèåõ„–ñœV9Í&´¸œÆ‹Å­2ïò„ViÇñ³Õ—“ §x΢'Jìôú‹HYg²ºzÕ›.O·‰¡çaåm”je5c·ÏüÖ—×gĦsÃ…ñlÞ¸}Tä¶ÒRšX1ÂWAFغp¤sÿ”×*uR+š„‘jC’7 r‰ÙGE¢6u²1ÝH•b˜íµ+yWª«}kO¹‘*)šc‘Yâ’6ÀÇo„«­÷ÄŒ`p?j£¼}&Ú¸"öPi*´ÚCJˆLd1­àç)Ð̧äö•(“ª @Ü'eU²{¸TÀ`C¥(µÙ·y™±_¯C8¼©Ê‘Óˆ‹Çì \QntI7Ÿ?¾Sçñl9¢½®¾¢Ú2rbî“L [”I~È;à~­ 5±ŒHæÞæ6¹¼…9å1u;M¥p[Ùi…Ó4¥F$NP8±©¬É€Ö{v©ì9yÕ{dôx6‹çsð»GÜ`û\ë>yQsÈÃ5C‚_kMÏo£†Ö‡‚¹Ó2ëš»üþX:Ð94å¼ Qb‰ó€¯¯®šHÚHQc#-kyž¾µ™ðãU½.dê8@Ô ¤o¨HÔ«ï‰`º2ò™Úø‡=ç{#m $à˜ÚNEAHL:(ë¶ (ŽæÒ@aPýµ¯‚ a¢V›bhÜÉ¢ µh“"²‘§¶‘kÓˆÍ@BZ˜}þeXù!‚6ÙM ÁC°!OR‡Br=w’ÂjDS •YT‰bà>³”xq`¡d°žfÒêz jA“•´%UFWÂqYa1{ å ‰hóÕi2„¢e¿¤rbcJF;é¶²8³§ºVŽ}áâD©¾Ã ¾†|ˆýö‰Ž½}ñbh{èïi»\D–õH+/™/¯ÏÅævãÅó­.«Äɵ,¤ÛsZ}­)¢_¸“º¶-Lè?§Å¿¦þÚÆ7Ò1ÿÎy§SßÓ}¦8ZÜÂêñE°>Î? ÙƒNoeåYÓ¿öžOñ|&3‡/ÏØÖÏ«“ßNþèËýendstream endobj 4739 0 obj<>/XObject<<>>>>/Annots 1716 0 R>>endobj 4740 0 obj<>stream xWÛnÛF}×W ÔU‹%K‰]ä!mã E ÐöÁ/+rimJr•åR¶`äß{f—WIqí:†rgçrfæÌðË ¤ þ…4[ðo” &ÁoøOÈþx?çÁ”æ ËÈî ÇÊà­ÚÊ‚„‘d¤HÓåÚ®U~KÀH¸È)‘Ñ©|«Ó-í»SE¹§ÿ²k33žNƒÙ yŠGßÅ2Q¹¤6ê åX¬£INs§ ©{§E¸ïȰKà™‹L",”‡cÊèÒ¦p(Fœ æ{­„J½ÍVê¶Tv¼ –œ»‘Ð uÎã¦ë QÁX³ìf“*سš€÷±¤6WU¥QC3e8U‰óHöÁµšHô¹,, *62R"¥D›ŒËÝßiëíx‚b,÷`Ì$*ec©ºä‹k+ÍŽ’TÞ«U*^äVÎ;ί ÂCÓ²kÚ¨|£U÷¢¨4"Ú1bÎÑDEË(F0¢¨Ì„r)cô6Ž¿äR>uº+ë3ÀoQöù)B¿MõŠ#÷ Lz°BÅlw%¡…ë&–kÜoå¹XUkE´FõXíÁ[ÔÍJ’c?ÈBë…–NS}WTêaa­ïjçšv'´cœJã0í9Úxw¥ É{‘mRùxž½¤_| 6 Ø¡—gµ•}>k:ô@-R}„U¿!3=… Úš1þ ‚ 'S xJÅ)­ÊDŽ:íUAuÊÅÊŠ»Dz¼°;=⫔ʩue«$‘è,KÅ.·âÞ7Aâ²ÇdÂLÊ}-¿”j+R>ž†c¤G__^fÒ®uLTaG_ûóç)—OÚÛ'ÿãú°±=ü/Û§ÃÊMrýŸuœfM¾‰2 ¦­0ʵ8 ¤·2—hyžJ™|ðuÔ&D'S•)ËÝâÓ·FÞˆ·1ã¤iõÞFŸ+½³« bFJ°X§ æ×0 fXC®*š@»µ*­ttÑZeùóàœopPÏ.7‘ O÷‚þ¾þ »c¾lÌÕ<ÁîH‘©Öî62›‚b Ì1ÄËl…Ñ"«G·âSOküÏ$Äe bœä Û*;˜5óO.k¶X}Ð %þo ß ßÖqýɇn9*vÙJ§ß,5¯ìiJèÁÙüvÑ?KÙ‰×öH=K]…ÇãqÝì`«R“Jl²<;ëij* Ç=é,Ã8—žxŸªÂz†úUlvº»' ª)á+‚—u:xÙë×n3£QŽm¶Po° ŠÁxÛ“l-6±øºc(]õ’ó³¾ðSìÆ± Ñ÷;¬åÌ?ðÖNC ¼!±¡Æg®ä¶´«¸O÷»óz÷®^«f{û¾V-Q»ÆJ;Îqk,èì |Ø÷©†ãè2|*ïýÒ›á¾[‡äŠùP‡ë¦4†ê3Gpói„zü“ˆÇn¤cDÅÁÁ3¬Nûžy8Ú%¢Èœ†Ú¯z–û¾3[öÜÛÔ¯J ˆÜ •"»¾êõ ¼¨'Fgi}³r»¯^^Õ]vZwÜî„üô¥ôj¼®ö·éä<˜Ïæ´À—®ãõO}x?žâù•æ»›P¬î{Ùñ+zdpË¡vQu²Û-ƒ/Ï'‹`6ÅÀáas1çWï–ƒßÿþ¬°àendstream endobj 4741 0 obj<>/XObject<<>>>>/Annots 1719 0 R>>endobj 4742 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 Ã`LèIв2’¶©HŠwëσ»§…`ÛÉ,˜AkØ“"ùª1•šd.6©$m(V…ý(h/L©¢*†¶µù ïÇZé,Ó9mª’ •ía¦*Dc[ª#AÍm$Ãïœ~€Cy̯)§Ë2qDZI*vºJcÚH’ «æÔrxj²—ÓIã3Â>íŽëÀ«­°½(ä„+9 ¦S<ÅM.Ÿ†7.Ô\dòæÓ;jþÝݹº>¶ÈY¢-Œè&ôfþµ…¯ÿÙ¸cÁçÚ4¼BQ*…éhzk+; ‹%×å!*+‘¦GÀâHõök»çåNäô—4šžUšzÌvwŒ~Õ¥$È•¤¶ø+¾*Hgª,v -ezYXnE•–Np#±.]yÜ6¸a*ôÿð‘‹ÇÒβ¯•ó<1 h”=l}Ó©,«JîéSØÇÊȨT»Ð$Ë"2jƒHUnÓ± íÓ§ Ê C9(üouŽ ; Jvt)>ä:q=>WEI‚2aC·`žÓ¸]²h°& ê$‰“E¸Á±™ ØsI,ANEiD)øÕ4ù½wx¶¿›.¾ð˜ö»ayÐõˆÝ_‡)‡ív•—¨Tüþ‚9î‘Î61Õœ’D· 3PLR½¾!^xÕFä‰ìhtB€rcÖ)¾âwtìà,µ~]ê/ešê狎ߜîÈbëVä54Ÿ2¯§Ÿ)óóApѯJ¿Í¾ÃiL3.‡ˆ•Øà »ÂÉÆ_dÅ–Ùþ v¶#2î.>.¿îS©ÝYŸñ±?Aëñ­×ç$A¥0 82¦XF8ÿÑç:·ÇaÃL4b£,QJF3ìãŸ?Àáx¥Q—;zéÆ2 ß¶øPAŽŽº²=[ûi©|¨-ûÔN ‡ã_¤x¹éÓ•‘φ™='Q¼ÞÑ~úèJ-ÔÀöHoã^“¯AÕ¿ºÁë)€Õ®ìÐVñªkÕ®l‰VñฎØïÑÛ š9ˆÜK]Ô<Ç…Ä8 iktfåN±ÆúÏ;áŒ̺~³ì„ c<ùZ[w8Ã0UnU œrˆ©NTäΧ hÆaÁ¨ü ÇÂgÏ7à{ÝeÒ¯Éמ!ovøx³¼Ýßžôÿ¨îËÙù¡ ! aIñÜ<Ó;iZKÃedíh½žM,;:ºs㢂ñƒèðmJ÷Ǽ_kľ|ßNY~K-ö뉫3ÜÝ=ùIwX<«$(žVè„H¿¨æØi­æ®åùw3t/7Ý™|S«L$*gµéÆ£K›/O§NÝÒÛX ¸Á§ºüR)\$ÈüÑaòŽ»ÓR8&íý·}½ênÌuGËú¸Âƒ½GÁÃëw({9èy¹Â…½gÁŹ;ÖÊݽÃÕ,˜Oç´X®‚e}ƒeþ¼à[uTe(•=æ9uÌžµôí²æþKß2ÌÇ‹`:ÁW ¸¶…÷ Öýi=ø}ð7g[endstream endobj 4743 0 obj<>/XObject<<>>>>>>endobj 4744 0 obj<>stream xÍWÛnã6}ÏW Ò.êtmŗĹìS»Û´yhb]ôÅ/´DÉlhÒ%;F±ÿÞ3¤.–/AѧÝ,ŒD&gÎÌœ93úûbDCüŒh2åÿñêâÇÙÅ0âaó‘gtýtC£!ÍRœ>à—Ä_âÞl))¶&–ë‚lJ±–"W&£TŠ¢Ì¥#å(Q..“ ùZDW³¿.®Ÿh4&ã)LöF£hMèã¡…p¼E0ßD7|á‡Ú ¹BìàÉLSTšBiR;—¯k­bUè]'“ˆÚ›8à!ÛbG®\¯õŽá n‘xï]PM±åð¨6’¶ªX’±´º”=ÙœÏiÀq&=ù*Vk-ÏÙ÷.XÉËþååüêÀ ®QV0h%…qT,EAÂìšLÀKÌ¡®D/} ør˲¥ÃóD¦Ê ØÚŒr€¯­ÉdN%— -P_ÖZÌK-]DŸ-©yj-Õûœù•Ê–øÊ¤…©ü„-$Nkœùˆf¶ƒ'Ö`Sºë“–Åw(•5N%°Â¨B’šÉWæàAæt"fÞ;¸ô.ÜRÖ\œ_=ÖGïAJPŒJŽÇÑd‚¿’Þõ5}ò©¤LۅР»‡!Z “hÙŸÛ¥aª¢Èô{`~ø#„E¾;ñ”¿ùe­Pvn|¡˜+È¢(:i“oǹ/ðý‡y1vkèãû÷-`@ùp„äKçIýrЉý(hJmNåŒA#pFK›€¦L«ÌW-<j­êOÑ÷ÞÒ¼w2¶óù‚;°8R&µˆ»ÊÞÉH¿¶ì¢Žè;U(ÊÉJT…ƒŠJîÁ4pAlºIÆÅªhM™¼hø´Ÿ—€N¡k•kyêõˆöëP“%xa¸”ÿ ¶,ß_“h:½cŽ=å eu±4ÐÛ÷¡%gŸi^K˜kLŠkÊl,ºÄç-ÍíÊ[)Dž!»Z˜¬ôz¶Ä,pk«TÅuR¼r+œ§9kÐAä{H"úÅnåFæ´Ãìt„Çé0¥4ô!B&›iÞã™bK¯jÍ ajCÙÑ‚äC•ÒÚyõ¯A®x ò¹sJÕÐÆOÕßl!qsų' ý‹‰£·>/XObject<<>>>>/Annots 1722 0 R>>endobj 4746 0 obj<>stream xµWkoâFýί¸J…äTÁ< „¤Ê‡íƒÕ~kw‘ªJH«ÁãYÙjºêï¹3<¶U“b{îÌ=÷qÎõŸ­>õðÛ§hÌqÑê…=Üá>||ߊ&ƒð–ÆÃ^8¦‚†ý^8j®rúÔ:¾ÆÓÑ«ÜZ~z(ð½‚&·0tüèÇÙÑYöÀjIÝi&aD³”=ßõÃñø–f‰õ¨G³8ø.‘©*%µã\ŠJnc¹2J—ÔN¥0ëJ΃+wóêæêj~}=ûÒêNï¨?à=;Ø´35›ý~…Cš:ËšD™¶ëܨ–ëB–¦v; ©ãSĪ8C¸|úýÃ{2Œk*¤ÉtRÓF™ì| 5Õr%*a$éGYåZ$2Ù[áq"P9î©’L&‰O}’ „'¸èÝac€ãbKHïÊC€„zŒ$ð;tiT¹$Ñxø¬Ês«U¾#£Ià‚]—[S‰K0M& Ù¨-e)95©”m,Zê8¿Î0"’ꕌUªjòһť¨Ã¬ÔæYÓ>Ú…»Ù @¢&ÎN\²žË­ˆ m*–•Œ.žë†úVô!Mu…x‰b•Ë{Ÿ¦Cýwƒ0ŠÐ ‡dÊ{~MZ%”É<×ó@•†ÔC^ä’’Ö|¥0 éo%o°ûÁyãËÞ5Näç8ñȸ޾*)Ÿªæ`#ýª~ç™k@ókë: ùŠ—4ϺÓgýë"zŽï±—ÓvŒñÿIØåBwÅëû×d vRÞ/ƒ{=Wφû¨cê³RùÆSÿcÚmgœŠ3m¬‹ú½!#P¢‚KTËì´Ì—ëZ&G¤’¨4••,c~n6\ãXlÇ‹Ñùr²wΉb öÝ¥œž&Ù˜¹WÅ‚ûòe]ÒÐFŸDäÓ3mº†T``Uì'ÆiÔBåÊìØ#OD¾Qš¡Å=(™xTz]‘N½o·==[ 8þÖks—7ðtUéd[>÷äde‰¢ÃÂ<ˆhãù@+-âŒuÆ¢ã¾"º|Lœ‰r)=x?°ˆ™Bì0ò€gâSê;Rüw5eØta3™éMIAr%+›tÆ$KÖuÔ¥ëÛ̋ﳢ›¨ŠûQ‚!9—‚2µÌ -i.·Š#»ºP!Yw ÉÐT]8ZEyÄ…´Åhe¹DRyðHdœóófPI¢øRäðCøxov!,v>­q3PŽp®ÅRRä岿ùBæ^ÅØ}uê Gá׊^[«þÐk*€ÏØsÞ"¤¾’›J Ša»ëÖ™Hô†€ªF¦ub› ÕÃÍ+*ÓvŽ'|/+mt¬(0G.DõY%PücõõÆIëo0M¢ˆº]úØøeW !|«uDü؇Âm2å¬ÂáÁЊ±@ßßûcqÝþê³kOQ8§¾g^š_[ÂÜ ü`¬Êe9Üszx è|/DH15ƒfXæA3‹Ä!<øìpãö8qàuÃKVm?…8ä.o8ˆNÑ­0¿¨øÜ]žp|Lh{È‚›Ø¥Ó{UÝ=]kýèN' ö'Ãpá¥fröݸeIhöègÛ×ÛLBnuçÖüæ—ˆQoF¼A0ñÜMx³_f­ßZÿ¬4 Ëendstream endobj 4747 0 obj<>/XObject<<>>>>>>endobj 4748 0 obj<>stream xMOOÄ Åï|й˜à¡,´Û®½n´Æ£±‰g„¡²iËÊŸÄ/´®1LÈdx¿7/"€ç# éJ©…œGÂÏÿËOpŽ 8Œ&k»>7z{Ï¢Còñ=hŒÒΜûñBC¶ÝzgPÆäqßœ(¤ '2”·¨Á®Í@;•\£ŒÖ­`œ‡pEeU0ËuJ…[œN3¶»>ü.«ù‘µM u IßÞ_ž«šqxüoXˆê&¬N%¥¦B°†µ0ìQ¿år·È-ïXSçŸUßúi$¯ä"ŠW§endstream endobj 4749 0 obj<>/XObject<<>>>>/Annots 1727 0 R>>endobj 4750 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ˆÞéÒ‘Øútý÷À„K‰31§{·œ´óè2˜_.`b²Î$½NÚ³”*#«äØÈG¸j­œ/‘ØK'›h±¤ñþçNy÷9PbÿÑ›(SJrQ×ò èïêÄÔV”–ÄngäNX¥Kbׯ»ò¯$“ÉÝ8†ïŠáwmÿ_Œ·]ÚΣUp…Ì͙ß)ÑE8*£ã\d3•´ÏdI{#ªJ•;zG¹Š ^áªýF½¥B¨Ò⇷™+«\ÙGGŒcƒ_lµ!iŒ6u@\([Ôá°Í|t)-„µÒôæ Q>Â/°íŒ(jà’Tj«ÒMíŒbůTÊnœ r^á\‘.óGõÌGó¨’‡J×’} KSмf0¢t‰ë° ì\%m–á» ÿñŒc·à&–`tÀ^­@YM‰uÆ[jUTp?Æ"…Ϫ±ph¨©4¶*Ôí…GŠÿÔå;ÂÂ8ËT¦AûÔ'o!I&*æ,•ubT 4Ÿ>xÿ¦¦º©*m¬£©Þ=³×5(èùP: ø‰<¸lðÁ3 é6Q"8FzPr/SL‚iJ«ŠqÖ°¿†d¤£šÓ‡< ä!eF°¡;£2 [®…ƒ9òŒ8ìEŠZ, yÞ5…„¹¾€L“Ëú̯lÝXÐH"o²ÞŽè´mJÈOÛŸ…62 Ï\ͺ”mÝ!˜d¬JçÂ+R%ˆY¬,ÓІ °‰¬œ1lÞÉR"ìÆï ¼£aJÊħ’Kª-Ö&T•«yIc¥Ë¤“ãy€Nd9æÆtMò¼ZYO½Ì‡æÁ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 4752 0 obj<>stream x¥VÛnÛF}×W • ‰¦(YQT @[Ç®"nj~1¬È¥¸1Ée¸+ÉB‘ï™åE–,× ¹—¹3gø¥7"#Où?Ê{¿†=ßó±ØýTK:½ðiæ)L(ðiúnäM§o)ŒÝ)ŸÂ¨OD QÑÏäÿt~îù4a=îmÞp oo"]ØJD–.´žÏñs×W…%qwBÿìݫ䗕ªä|oNÄK.¢LÃæ –«E¦¢'öø¤‹áîd?pø" Y¹ý¿úêîœ^Lˆ³Mhˆ4‡Á¸©N?L%mÄ7i“ª(%ΆkYŸÞ•£^o­ôIe™)ó£|@Ų-Y˜3"—$Œ{>´–HaW•<4£Ž‘UkéQ˜®Ì€D±¥› K[½"SÊH%pÉ÷¿€Kt…š/„‘TWv£²ŒDf4-ˆµ"J¥ÕH2••²xÉ¥Mul<Ô¶âàó2«Ü§Ñ0¼ñ¤Šûµé›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¼ &ÔŒãþ:G¿éÂXÁ³n¹¬äÒÕ JÓ›vA~‚”F÷ûžØÌÄ›ÍØ›P¨®ñ0’U""I‰Ê¬£‘P.?,ë,Ó-Òñ òûº–F¢¿ÿdå¤ÇÀ#ÀuD·{~}û»ÁñÝ¿®.‰ÆÇwÿxMš4»u¯­µÂ´JwýËëÅgp~¬¥[ºh_¹|‘lFð³}qFÔÈ›‡Z®–©Å FÝnŒ)eHå ôàz|°z°Žƒ2Ob)ÇC±q/÷˜¼­¤ìÆõšN` ‘Q$Kžzk‘­¤é´ÅuHè|2Ýts{uIe¥×€ã½ ) fºFkIxˆ*ý„ w}ˆª#+ZéÞP¦óØ}Æ<;MÕ|¿8v}êRí1¦btäìê;k¾RF³‰w6>£é ß5#7®9•aàùt®#×:ŽÍ -D´>=|[“Üh79˜ðNa¥áãgþÔè°;ðíÞ‡½½)F$nendstream endobj 4753 0 obj<>/XObject<<>>>>>>endobj 4754 0 obj<>stream xåUßoÓ0~ï_q RÔfùµ®ƒ'ÆÖ1 6Ø{‰4yÉ5õhìÌvºVˆÿ³“u›€7h«Ô±}çïî¾û|× ! oñÈþòªw˜ö? ÉÍC•°;I ÒÞÑ ·NƒÜKg\C… ç+(pÊj`Ð>çfÓFä†Kr f†0•ªê§·½ÝIc?¶.£†QäÇ1½òæß® ®ÐÙfnr™õß´–k,Cgû£Ñ¾µLg¬3Õî(¦Ê¦Br·#A#Ÿ7@p¥À5 ›7„xεÁÂÍ#ð9pƒÐh,€ È¥0ŠåFû0‘ pɪzޝ×KV– KfðÚ…ç‚< u_> àèüêl§'ïÓ|8ž¤]è6Q6ùÞË5¨ä3ïRVx~sKé‚WBh`“<ûšõá»Gö¶Š…§ð®¡ì:Ä›I°ŸG©ß8ú…¡õñ£óØ"zÞ–¿ón·Yµ‘Ñzôôª‹ ~zÕ&‚l“­s’—›m˜ÈñODz;7¨3|Aœ¦ü«¶ëoV5V¬&ž‹$ÑZ­ó½ÀljUæµüêoóàl‘¨2ïÙ£Š¿³>1æòêôä—9Ö¶‰cöý«í–c¥¤ÀÎ!+ÖqK±óÿðã©“a7–¶ú¤,„ÖYor¸g++:5*+x yÅçLµÝ¥áž› h* ­üøð‘­H`H[I¦iÈ% *2¾¥ûîäÂÄOZFc;,¼0¢ÿ3iP·›ÖÂhu"ñÇc»ç]§U ›º–Ê4 Üê•ÕFÒ³›\JQ®ˆâ™—ò‚¢tìžr¥ °ºF¦Zñ³<†~ìGA‡mÜÝ Qø{ñ$IèGîp·7ò8’¹ÓbJŽ, Y»y¸ßÊ Åµ-JvbioÛdÕ F~ÑDQF“”ã´÷¹÷Õý˜endstream endobj 4755 0 obj<>/XObject<<>>>>/Annots 1737 0 R>>endobj 4756 0 obj<>stream xµXkoÛ6ýž_q`€Û:ŠdÇv²aÒGºÙº¥ÞŠ F¢l®’¨’T\ûñ;—”d9í–mXÐ"-MÞ÷9‡t>$ãOBÓ9ÿM˃8Šñ ÿHøÇõëƒé<Ši>›GS*ét´‹‚Þ¶{''~o–Dsšûï –°[Dgƒ½às:ñvsÀ/Øn°,éÌÛõ{ƒeIÉ4ædúÍàt{§‹9'ãìt°„áÄ{í7‡kìÎ&Q20®±{6á ½mŸ†JÑ‚æ~á+Ù-ÑN¨ß,9!ßÖ~Ó;…–ÏÙKXôN»½$æJv›Ã5»=&ÃÝÁšëŒ÷‡ È‹çŒ~Å4ó‹¶}ݕ̣ÓÁÞ` §É¾apºƒž°S¿`§ƒ%œÆ\H¿ìæí,ÏxÏ/Øîùr€RU³¢ã‹3JÈ}™ÐóÓI´˜Ð2óPŽi™Ž’)ý*Œ·…¤+Y­ÜšÎͪ)eåì“åï—øÞå %°Í™G<¢Ù.G—•3:kR§tµo¹K&9mMœd£›É|Aûç?ħÎ|´\KúÉhä[î[ý¯Q^Ê\4…£;a„YY²M]kã1b×u2².D*yÔXU­è«6‹GŒ ø:E•‘ÛÖ²õ½ñÿ¯ííÂmŒ¨k.q£¼BÝæ¹zÄ*ßuátŽÉ¾/”}̉¾xöŒ.­mäcvò¥²icíäÜñŬ#$Dð t>ñœ‰èC$ÆtÈl[kc´‰hðÿÛ'<¦ã‹N âÎt¹V–Òµ¨4”I›u+-9ø©k Íïçž7• >!9ñA’`ÖEªšò~`tQŠèBR•u¢Jå˜V²’F8€È§“ AK9Nsô^dŽ/pƒ{ñÕFU.¿Ý/eD¹(U±å¨}zQë<ôÇét­RBµ¶jS¾ÂHdwœX¤©”F9RÎ’ÞT]S"º¬!uãNT|Š-ÅÙŸ¨ÚÉ Jðàqp–Ká#C“6U)Ób·+XdªŠÞ¾»|}”DÓ(™Dôƒ¶Ž4ê7¡çø·k˜®£.,­Å­DúéZ[DFòâN+TÁãT bßœà¦÷×É0ãñ’ ÊÚ×ÿ{àˆNOZouɳ`a~+#JK¥Ø"ù´h2¹ëz¨W¤©¬Ý?‚…ü$ʺ*J®»uŽ1ö­B'ýŒ•@[Xyú9SntÙârQÜbLéšÐsFQ®‹Bo¶¯þcâ'º1aà>Ÿb•€,DøJ5°ÊÓ7ô4/1ö(Šæ`ÂX ÇóîüÅåÕ+z:¦/Û}Ó¡¼7´aaÿÖr7”#Ÿñ4šãúE ç…[ëfµæ*ÑLéŠgÁ²ì^µhU* ªS& ¶žÈ0Ã'¶–©0á®{»Ö⸠„šÙJ…¨VXIºmÀý®.ÉotSdtË€G`F~wód óÎë.Á¬Ôó²Ü¾ÔÞ^Ú˜ÄùO—AHZÄ<ô’„¦—¸·¬ÙW^Õ£¬¹yÀ-_A€¯¦ÍZAFŒ„ŽWhje÷=ð½,¢ïõFÞI3ÞëháiÞß‚ÞTVCÆ©Þ01_ô·Î_‹è¿\]aF¥ª|—îgÑ9­´ÎöòhYÂUíµŒêhæ1áwæ’ü$Ó¢¾ %®n½/](6iÕr_õ  mvÐ0h×ñSz„Ÿžwyû.ÐaaÇáÇQq8æÜ>/XObject<<>>>>>>endobj 4758 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@ÿ&^¿`(/ÇJünÍ b§»¬;]e77lùNji…WzAkËÉZpÌØÈ8%p˜J©~IH± dL¤ÚJv:릚IKfN®–¹%—ºä“ÒeôªôKÓ,–àdmÍJÒ%£\Sׯúà¸#=‡”\¹HsP^*°Íp44 Ì·±JÒfÿx.4-ÐV:ô‡aÓ^…‚n®Œ>psņ^äöÂág)ë»›c\ÅF‹*Sn¥ð’1aâ3" 8<Ósù1¬Ì}°j»HJ›Œfß–fhÎÇG(y1è@Už”£Ú8§¸\€eº¥O乬}H=ÕÈoj¹/mö3``ᜩ$>£8(=+7T¨ù¨kŸÑ_ ©^>:@âä÷DÎÛ&éqpÕÂÁ-2ÔT—"— («Û7)Àù ŠËF+šÝzúÜ ,…‘.ÔÓØû>¬Ü5(¡ô!å]Kh,À48Mk…–à@Öbƒ¿¡Á n0¥,-$äÎT5¦J­nB‹˜îA¥£t[ßßn‡hAìK 9¬ÿßÚ*íçÓÁ“÷², =E ¢06u)ªø´˜Nõ“3o%~6U«=[‘ˆŠ2ή£¢|\ÊØ6mN–JcîAif”Bã¡F÷Ú¬[²qÇprÔÌ•½Ò§§§ñE7m"®@*÷ –_ZÉÍ…YLË][‹¨“Çb¡\—­"uç Õ[‘l”%î€Ø—NýO*à1¹Ns‘´\E™ØB3€ŠpR`TGEÄ]åƒÌ›($w¬GTÄË8õbEäwU"G_3Sp‘¬cƒ¦Fë$ÎS&è‘ßÓ”‘MÔx+fšà²ÇÞ'ÿ­†wí­p~KÓPKïeUû(XÈ:@÷ -ŠŽlG€5 ž<Ö9v†-$üHjƒØÁÛ§D¡Ý;¯ö7V‹VmŽmxµÝpÇ‘9|dÁH°Ó£³ûÈxúƬÿ¶‹-ÇöÚ¯û I°J-–Ä„nX–4§´ÊÌ1Èò]+Þ3ìŒi?ü¿LañO‚Æ$˜î¹õeÕá^žo劋k47ò¢¼mã÷à+ºêŒòR ‹÷ øÚléšÎÕ¢á½2Ü*~¸7¿¤”žÇÏÚøQó0*{¡€,¼=Ã& 6ag Ç^|L"`Èê P>šÆý&eQJL*w´)Vc}0`þÔßhl aχ7§|sÃIºÜªï鎧F«…’çmŽæ„¡ßSß-Ú-އ–1%”–a'ÚæÚˆ1ÁM]i ¿GLOlAÎ55˜ò%ÙFŸ{UIP‰… ý_ H–ER#Wë p¬1mÈ}5ó^[Ï}?Iª@‹ò`°,xf¶R¦ªónãò½ILµ- XÚBÓÄÕ6ê^({¼SÍiè-v;@”éuHñ@G†± ìew¢¤³z‡»›è$5 ^B"/CÓCô"£®‚(Ä–ƒÍÇ@@%ŒÿùêõmX°ñ¸—7¾#ñ®‚íÊ*l]%¦Z#0غ‰ Œ±úò=iy¬¶˜í¸ª„nxaÔø²Ç[Ï D±Óº³0 ™B|—èEÒéI8Ñ^§Ì°ÔµbÀË“pX?¬üÒ` ¹â)Ê¢46ŽÜÉj‚)@Û7Qi¸„ÁLÓË™2Lkæo/ µiÊ‚ª ;´¼#±2ªµ¾˜Ü´;Âhx•=?§ë/³QøRõáãí»óQ6¤_L¾3…ææ«!ëÑøüñßÔ.ѬޚxAîØêùð:ð¿0À~ôöîä“ë‰8óendstream endobj 4759 0 obj<>/XObject<<>>>>>>endobj 4760 0 obj<>stream xWïoÛ6ýž¿â€3ت$nºa¶viƒuE·eø -QWŠTIʉÿû½£,Ûj›ÄŠE÷Þ½wþ|2¥ ~¦4_ðoZü|s2I&øp÷ÇôüꜦºÉ±vñY|‡tx«BI¡TžŒðAé=)C•2Ùˆþ¼½~Kµ³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»-‡|"ù ÒOã܉JR%Œª-¸Ë3R9mlC¸’Óz›U!9G“yÊ” ›„~•²F®"„x~õ’¦çÉy ÑxvÉÙp:OæôFæ¢Ña—Î6ÇvÛ×ñì<¹¼ä]·¥4¼Z ÔŸ´4’6M%MŠu-…cŒQe‚t¹Hå(‚˜mÏZI®©ÅªˆoælÝÜF퀋¸ÊI½õŠéd­EkPÊ*¢ y|€´>üõþ=Õ6žŸÐŽ’÷¢ª5Ù±ÎDycR®oŒþüjB—¨ ¸<sf³d>ÇÙpmÖ;\¥vˆš/Á'ƒÜÒ—ý.¯Âˆ’$YžýÐ/Ü8F™'‹Å Ž¢À*ÛèŒV@™ Ú 4DNxí$Š›ÉTãø*·ZÛ;ÿ}öÿ&÷T^Sn³®ŒL*´FÊx´għMÙy1¬À ŽJ³W>@<EœžJî'p \Û0‡ªæ¬HÑ(RV-d.ÑÏœÿ]i~ž5áAš´k4 ®»éDÁƒt¶)ÊãºöÍA'tædcJÑ'ˆ™ß‡kí)³ƒêiÍ€7^æQÙ ×0³#÷3wj¾ÆUZÆ¢ðAînú”yÓK§Ÿc´<úŸÅ-‡hÁH”ãqú¼zõªOíÓw¬£[ëtvº<ëNee>´xàúÛ6®q 5È–KsJZ Ôlį–gOÆ‹Q µ¬Jˆòr2$Û,öNóEc}°A¥’K ýDƒ`¤«D€ãd%ù!³F²2µeaf¨$#÷:¡Ч-?o`2µ‘<Õ¬öU ú8z‘£Æ–ñä`¯»òD—aË(Êžäp{óýé‚}Ž XétpÊ,ðØÓjBfUéSÁÒ€EÖepDvœ¨@©! * Q|·:Ú¸ÿŠï×%N*X =£Îè®ù ¾9èb>£ÂÚÈÝñû#â`5hCõÝÞÊŸð°sb…`÷é±'ÈøÜ°Ð`;8pöûÓYÚ;?»Þ³€(ŒþƒÚ1bgÎf`Ìk¹W$æ O 1 jÄø„Šå4\£Aôvïaâ<÷4ª…:Òj¼ünˆùrbòµL†‰/Îúö­‡< H˜rŽ)­0ÁÛ,Ú#JG¼»bw‹M ÊÂ'~¤ hdki¢ræ‘1¸<'¹ûŸ7𪾑Ö"”p~—kQÀiŽqU¨õçF­†‘8±>ÞÇžÞ¿Öãæ~mZåM…‡Ö‰(]¤sæle1àEds•¢­”aD!±â”Ù)ïá¦cWijRE%j«X,]Ñ£:uöžÐu˜`ínìÖÅQ´lŒâ$(lêã¯ÖÀ$RLMá¡ÿÒ)8Õî\¶5`&|?Íc†ž=÷æ£íÁÿxöå=ƨúi¶ë¾EÃà ýx1‡³}È>/XObject<<>>>>/Annots 1740 0 R>>endobj 4762 0 obj<>stream xÅX]oÛ6}ϯ¸0T)Ŷ/ÙЇî#]®èVo{100ms•D•”ìÃþûÎ%EEVÒ-{Ö‹ä¹çž{î¥?Li‚Ÿ)% þŸ'“x‚¿ð¯)ÿúéõÉbÏi1Á[*èzÏÚ79}8é½-hš\ÅIïÃéü*¾¤ùâÒ­œ^^Ç×í;^ڵ׋øªÿiï}A³d/zŸ~½ìát`͆.n&Ä–kšMhq=‹/h™¹h&´L#UÖ$ïdšW«(Õ¥­)Ý C/*QoÇÔÿ‹0›1-?™Ðùk³ˆîÿùE¶6SzIï~~ûö ΞþhÒ>º:ûŠ\Ü̉!¬éaÏ’6¬h¹U–öºÉ3ÚQ9¸Ì8 ®ÎŽw‰HX´nÊ´Vº¤z+ji*«ZfÔTTkJHWü¡È L4…,kÓ·²’e¦Ê ¹e’DUå*üäûN!t+q3&®ÐFò!%ÉR7›-­µ¡Êœžbÿª1•¶ÒÆí¢Ùœ-·’°$ËÝikŸŠce"ãQ&×¢É?€t›tÏeD”âø[Éé.7ˆr§ É!e©.*àjwŦvHÝZŠº12¦7kpûBì•ÙØE'ïDQ历cQžÏfq’@¢YtÚ®\E£‡ÇŽVg­P:žî„aX«(^v!ÃN/®‰ã@­ò¿,,ÿ'! Лç´6ºp¬Ö€(kÊÁu#6’ö[•n)ÓÒR©kä^ïTÆšÐË*š‚ʦ¸•†ôú>•c² – ë«ëeÄhL£ÛÑøHo£ì ó¶W¸‘¥4¢–ô j<.U¦y“›Ã£¬eÉaíDÞH pE¢ž…pü¸5¶†PX:]¨Tή«”‡:†•1ƒ^iÀËÕ+»¸²6,Žb?>¥óƒŽ5†ú¼%vD‰H‡õºAnµáí:¨[™WÌ“Ï%¿d᪔9H-M¡J暆ò¤\Ù:¦ïõ^î¤i-£ R1¢¬å †$D)8d¸†°p GPJ]ž3ÓäråêÕÈçVزÀóú•÷i\rÄ<öš©€MYu›#$MZwŽ;¾ _9×è¨r 3_ .¢¨t™hF"ËT;k<CÏ{+}×ésÙV“‹ŽÉJLæÎù^¸·'[ÉT­š}ðòA6¸h¤…FégWíPAFV¹H%OAœ¯B£Z0ú]ÅRÁƯr³h@U‚ŸPyWÑ KࡦTl²à­aØBî7Eì"é#Ø+cú>î ŽÉÎíüs¯ÍG&ÆÑ&?V^7úQ¡îÀUàFÛ‡be½^Et’÷®Ñó¹¾óvÞ›W+Ø2[©Û÷Smñ¸éÈ¢Ñ0ÝÂÏìh@i·ÚÔùauævqsMÓ9î(‘áºlHìŽÓ—_ü¼äiöN9˜éxÅ<¾ºâ%xZ vø\–”O`#̵¾‘î`º­ÈüŒ&ÓsÊ/ƒÜî¯$}“ìyìj¹1‹þŒwWŽ‹ zY sßg­"« ¹Õ{Ÿn;Ýâ¡×ýÙn{O C ý к¨Çô7 ~@ý«ó@P ä¾;í³·—ÁP2ãb‚%¡¸˜¸*>aør—ÔÀžÅ:bÌ#®BÌé úüÁç:B•zé Ú’ëó1hk¨ënê„CÕHäøÁEíä±#2>œŸö[u¾þø Ò"u€6x~§UF/àù€Ig8ÁÚR,—gnÝ>/XObject<<>>>>>>endobj 4764 0 obj<>stream xÕWkoÓHýÞ_q·l¥Rã$´taAšB%]« Цö$j{ÌxÜÔ þûž;c'V|]ŠÚf÷yιӯ;= ñÕ£ÁÿÒç£0±¸üfftÿ4¤ã`@£)õC:ú£=¤QìN…4Š:?ï¾ì„tÐÃǸÁÚg•YÊ ¾OÇHg…¥h. ݦ¶K8<Þw÷ïŸ> 60¥ø9èj?³Œì\$oDš'²‹O’¦Ú¤ÂRaaxFØUØS‘²IE…´d5q¼7ÚÙÝ+výRã§Ј çF^ËÌ$𫞑ÒÔè”rQl]Ð¥ž•EË'< &Ó>g.o¬Ì ¥36,3)[‘1©,/-éË/2²o,#c]d1剈Ü—Z+îk­bºÛŠœ„™•)‚†©ÊpÙv{Ìíïÿìz@èZ\]ÙR$4-³È"ŠD’pЩˆëú—Y,MRqyFä¹4ÄùÐBád¢õ]ÎæèF¢®$"SÅ£&±šúý`0¶â[™40ïÓ÷&(‡)¢4È»·7lùa«¿±Åà#2²(Ûl^pˆe6FOˆ‘Ñìyû½>öÆoWm“g…ÿeÜa—hià%p½M‚e°ÙdÉî»lâîÿXï`‹"o´U‘¤¹^ªv¾D m¤Ã1â»j*#O@Z´˜ƒL•.i¡Ë$ÕrÀ´¡qÿ× ˆ¦ oxHèt þ ‹û‚R O"¾CùJÁ¸žÒµ0H° [å2y@'ªˆ¡Ri9P 5_K…þP—  +Ê<×aÚ9¸/mG³Dd³RÌ$|Æe¯œHA™¶„u#2+}º m®€H.Pyññìe}C"˜û¡tfq¢Ða ¨Ô*9*t*9ކ³\‹‰‘C<.™¢šì²ÎƒÒT)¹2Íd&H”­ÖK|6E!ëRyXq[d• ŽÄca©lÛ9Þ[qg-kÇNïÝ‚«ž¸È—»/¢HæøÁÑ*D(+ÓKðZO×2F?œò †P]§jÜg:Žë²@SVÇ®…JœAäïŠÉâí$’¥7R8K‹C…/³SÇ\f1>{4_ ¤îþ¥ä—¬±~¾€é®WP%£Á5”Å#·È…UÒµ v8Þè•^@ÿM×w Á¸r820”q"#ÙŒ€ع^ÌFÿ~¢ÀòFFI>îlŠðR^ 7#)L¢¤Aa4H‰(P‡²@KP`|Já¨å·ZPØ«¡æ——ƒ®ë¸ªÙÜÒTŒà…QvÉ+äý¢bïÕA;*ƒ<Ö(DÜtG ³âŸ^øy‹–³(«¶âò"îDíu.+\@7ÃǤèOÌsü¼wv½õÙí5بÅMaý¼•x4L.Ô7 -÷r´©·j îÊSØß2ÁÒИɅ´øcá&š|I)±£ Ý‘Öžu0åI²»é‹Ç‘-MFoÞ¿~ÝÎÖéü­A²‘½+Qÿ÷VÎä[ÿ¸›WL· ðRÚ3+Óe º¤¶…æ›Y߬éÞTéüïɇị³·o&¯†Ÿž> oÂAèþýg,0ØÎ”Èý·óê}¦øí0y1—ÑÕ¸ã"ïomÆè¯ôaèæ¨+êâÖ6¸™üÓNµ{A”W¾2«˜ŸïG§Ç $êÐ7Sõ×ð=.!çÕó SóÖCÂæœ7¯žW“O'Ã\˜hÚ»#¨–› ·³ª¯îP^_¥-שּׂuEÞY¬–éyÔÝVl´ÝÔßù¸zå9IY¿S?½Žë?$zÇ‚ÃÁ!ágývå{ÐB:Ñ‘£½àW3ï4úà¡YöÁ!}¨_E<7k-øôax úø› Ï­~ø—†£¿vþ3Åendstream endobj 4765 0 obj<>/XObject<<>>>>/Annots 1743 0 R>>endobj 4766 0 obj<>stream xXýsÛÆý]ÅÖ‰G”LBüÐ7IÙÑL&V#Öm'ôhއyp‡Rh§ÿ{ßÞ ÉÒ îövß¾}»ð?&4Æ¿ Í.ùGfGãhŒ;ü5á¯ß>M¯&Ñ9Mç³èŠ2š½½ˆ¦Í_)Ýý¸x²Åïsk:{?¦y4£EBÓ1]Î'Ñåå-boxL 9x]Ö¹ÊD¾$N)áÖËZ¢(ÂïŸ,¾i4ÁÊxðúÐí?î?]ÿvwóñ×ûŸ¯ÿþ§ïÇãÙØÖiS’~×»™Xãš¾§ñ;ÒôGšðï7ožEø°?ËÁ.ßâËTÙïúóò¤oó?g¼þF™X'÷üг÷ç8‰ÑtÖ 1¸1TnksL C§È•Ô"%x Å*UÄFÐ`†=cßÂÝÖø€tA‚Ê*džMcmÖ$Ò”lâªÇÒ Â¾*S¦,(E¡b€Rn°?þÔDK*-oh™rnërc e6®Rµ<‰hÇŸy±¡¼JÓ—ìD.\IÂÄT”Z>ð]…XÒJá¬Ã'jö­(<-ú1¾ ?ÕˆÂv>¬(ôÚ¨øÀ]œÑƒìÛI­åÀ)Éø”QÇaŽ]ímÝZÓi{—iSEn‘|þüä†Ò½ýŒáÏv§¶Êq@] œN†5iM‘&Múx;׃ÏF®eY95ÂG¦¨, &Rkï6¶$elµÞ°C™x@²XRYjäqgÝCÈáqS{‰-š‚ªœ2•YW3‡¬%¸¢÷„=ð§!Â»à…´±wb­Œr~|X)b°aD$¥rÞIÇjõ¨dš÷pÚûŒ°‚8nÁÞRnˆá3ø*Rm+`¶E°–œÚ9]ú¸|­L¬˜/ކ÷·*|öžgÿu¢ƒÝ÷+Ö O©qXª=¼ºø® h¯{£é4šÍ ‚±ÆÐrðJøƒ_A{BÌ=¹#’áèôÔ+$k9hn`êbÖ"ð¯JK, æ–,š yétÈ"².~n¯&ÝÕ´»šuW矇-\^zY?ÁÞE·ã²»ºê®æÝÕ[\ýú×_~é«g«PD`Ã’Ýú.­)Êdy3¤§wÌ|ð |U[\Rž$šxa’Yű痗^ZEªŠÂWIñ¤LckŽ¡( õ˜§B›@¾{žre)祹+×ÊxsÌÎcwĽH*WÂêÀ‹ªÁ¤€d²³Ð~YåP&“D©ˆnOoø¢ÜwˆáT•ª- §¯+WANAWõÕ†Ã,•ÜûùÅ®p¬P!µÇ·Ô¦òeÃ2aÐ*ø1KE8ý–&ç˜ÐøƒÍù2LÐÉèSèE´s"Ï.7¨‰U’èÚáçÑ|Î[Ø÷¥Ü©­¶pY=Š ½«%ìTª¡«¦n<w»ù0HTn"÷GŽv·ÑP„#l®¡Ø,LM©Ý€“J[f{Í„„p¨ð„b…t¤È6šrÆ›v¢.|«aFn;ŒÇkøÄq ´PC’P¡Q§Ê¬>XÚtÙU¥R r7æ…\ŽŽtªì{ca3E;ÉvÁlldÕ8óÈ OqîþüÁÜ¡0T= G+XÊÜDQ(— ·(Aø>¿S»Ž„y‹éêiæk"ˆy ¾0üÌ[ ³¼Æ(† Ïmœlêp+½^ÃÉueŠöŒ©gÍG´(€Ë[b4àX¨ ªÊa ¶yår‹;` «©¨]Q4Ì‚$z 'UŒƒMYæß(G œŠQa‘´ÙÙž“û·VÜÃöFtÇúúDîíî0i9GP‘iîKu)WIˆþ¡yö …¸µè¹³RÅè%<á °TpÁ^ÈI YÈð V9IÀCtЈ~ Ü$±btÁ¾ú´Id]6±èpm§n"Š5Y«ÊS‰ââáÁá,ß¡7ÊuTiZXÒiZa#ë Sžóš›C$$÷ òvêìýe;£ú Iëpw?£2£_‚¯  ËbXÞ –ÈNßNÈ‹”*‡¹þѨßþú®føAÇ÷®~üLÑÐ1Ð:Óë §yCÝ©‰ø г32ψô¥+¢÷ˆ¡Ñ±ÿ= œÒÂÛÜJep¼s6‡uN8"1XñTû¸ ¦mÕHO;NŸž5C‡Ý¿liƒ)âå÷,4úfÐ0Ûþ”ÁGó(€gòkϺ÷®pj³“Ém½à“û;ý¯ðj+E(Ë·½‰'ãò“ËA­6ig¡åÉ©Ÿsä›ÉòäC̦ƒ>ïöW_ù~\}0Ò©}âïUÞ”*óoƒìòP¿pü†`.¸­ïüÛÌýŸ7J>,–]{6Ýa¹ÿÜÖ×ÎÝß©2lZâ-ëúQÞâ7%<±nøêú¯‚\0FoCã3ìsá­Nn¿¾Æ)̲ÆOd/™i§²ðÚì²A¼þzLšè~(Zà3;ÍKï¼Q‚Éü<º˜]à¿®¢Ë‰…¹‹¦Ñ˜~²Ò÷IÈ 5ÌW¼!‡Õ£«àÃÿ5c\Œ/£Ù£ &‹éxΆ®G9ú/Ò,endstream endobj 4767 0 obj<>/XObject<<>>>>>>endobj 4768 0 obj<>stream x•VmOÛHþž_1 k›„ÄäRªª¨ :tí•ôø€OÑb¯ñöl¯»¶¹Šÿ~ÏìÆ¡yëéäÏì¼<3óÌ~kô©‡oŸ†#þ ÒÆûI£çõðrù0÷t8îщ7¤IDƒÞô½Ñè5MB«Õ£IÐ$"aîg·ê/:¥ß¿\]½mM¾6zÔíC²ø—>$~s¦UHm¿eÕW•žGàGÛôY>UJ*cIQ•¥Ò"I:T*»§DÝE‘¢ö!ìÓÊé‘ee¤ßÜöÜ>\ÊG$9}_ Me%ŸÇGuh¬EÓ@Eã¹MXÎsIÔnóo±®`óµÆÛí™HªM Æ*À0\Zp0"pŸæ“*OäôZýƒœf°¦ßZ÷fC 4‡m#k3Ú)PÓßÄÙà`è·Ú éÈo>«ù­M{.â ÷S[um7íp´È‘À¦kcÂËa@,ª~-KªrÊEãaD*KiP㵪ÙTo{Üo/ë$¦¹F1¥©­ÖÍçÒX(Ãm¿VØt)S”ÜœU*Ñ;Üöÿ[§ “ƒÝn„W='\lºŽ´~ ÷Þ’¢_O¹YI ¾ß×Ð!rø ìDþ'Bh3Ûœ·õ„[`šëˆk$ë­ÿÇ\¸ÊÌyLüæK<;4_NÏ/Æg_®&Ó³÷—ŽÊ`€7 Â˶’ïzÕ~‡îŠÂI·ÅP;YÒ÷9ØV˜Uúöè&–{ëÍÍìØ¡3Ì‚£ &ýøžûòƒ²³½y(ÔÕ]")Ü©°¸Í´óOÌ«ÖòáødQ•þÉ‘w<<¦ÑÉpž³îÀëѹ,$‚{‰±Å;íîk·búhúÓÝw\ÑLÄ¢YøÔqoä ¸È¢˜ƒÞ~u1iüÑø¾"4endstream endobj 4769 0 obj<>/XObject<<>>>>>>endobj 4770 0 obj<>stream xVmOÛ0þÞ_qB0µ¡„¤¥ãŒ!!`Ø‚*“:­YgŽSÖ!þûÎN\h`@QZÝïž{{œß ü¸Ðí©ÿ nìz ÇvP8{ˆ¬8з»à…Ðq ÷ŵ{½Mð†ÚÊ/h<ÂDNSºÕò(¢˜&y på ŽN¼¶úÞ;½Ü=Þ×?ÏNQ¸ó§VK' ¬(¿1Iý&KüøÍ€'™„`LXa,Û`Û6*Bk<`1šÌû`‰üCUð‚Šy`Ý‚.b"!“‚%#°Öâ-»° gÓ ­ìdÅ¿¹Ì’4—~«ÆãŒÜF"šŒäXÊcšÈ¬ê]aÕþ½<èà‚ý¥~sBʳ'ߦì( 5Z¨â…å‰IñÀo*GV†ÇyXªýVÕAÈžfèÃÙߊZ[]­©4`Ú§·w4`ñg ©<’4žál³j lFˆ‘ΦG‰|Óà—ßä Q¥ŸeÇ&×ìÆÖYm—ce k’n8!‘Íð‘SKÙÉŽy2ÒQª'F5˜"N>„ªòª{=s:lø¬ˆ´“íñçá¿À•ƒöš•{÷¼ÔÀÃr6ÔST3ߨ­ª§²Ž ;¢Zs6ÝbpA¥Yü WªI¨á¢½t™dyšr!ép¶ z¾T k¦†¾^/¨ÌE'—ÇÇ5P0ö1ã´Ü)6É”@…™÷bN\LqNï“ä˜B˜'d<òLqGÄnÃá’«zÌ…_ )A¬˜ÍÑÇ0cH‘pdXYˆ’ÅÐkäÂdaàràs0V •z‰À²Ôw¶h ;®à¡žƒªEq^Y`IfjC˜“wЕFºÌ3`ÖsÒ V]¿5#®'³:ö*?kÛ«¾ÌpWgGå…ùÍ) ;¦Z&Yì94ä)à…)ÒrL%Åûiñ’Й^;7èó“Éarl%Æ©¼"‹Ò£ºÆ UP¼yø¹æ©P:ŽÌ‹„žÝ3ŒõNe†pk99 H—Åõþun’Õè€^ÚìÚ]eóç˜°ÉÆ¤«ÌË”½ª¿ŠŽâ’ÅëÝ J~UYÁÅï7Ô\uø*¼‚Ë뽯$ãwà{a\Þ¨_Áæï8¤!É#©­ôAõ)·ÿÙÞèn@¯o„]|'6/~®ulöx __ˆâ;5 k§°^Û,ºìvíà[^¬{AÒTÑ!ÎÚ¸äDujÃéÙݾ—¢ïŽë(Ñ¾×øÑøáÙúÐendstream endobj 4771 0 obj<>/XObject<<>>>>>>endobj 4772 0 obj<>stream x•WÛnÛ8}ÏWL¸U²ŽâKnmÑé%E°½d7.ò"À %Êæ†UŠrê.úï{†’ÜÈIÚnÚØŠ9Μ9s†þ²5¤þ i|ÄÿãlëÕdkðáúÅÎiÿl@'á˜&)tôtÓ$ñVšÄù13ÖEA´óœÿÜߥ«…èJ>±’Ji•©J½¢…)eB»û;“¶´7„‡¤ñ0³R\óî;kß7>Ùü[¥iª¦…•Å4Vi<ÆkŸÎÎΧoÞž~~?™ž¾:ïÓ2þcØßðæÃ¿ýò˜]¹U!§•Ê]Ÿø±ŒvèÅ ïðÓŸxþ÷ŽÞ ­Û³£`iT‚Àv£Æ› 뱕e¥áy)tÅ®ŸoxûNR—òžC.Vo­^Jwéàkøàk<ý»ÊÊ$ÖŒíÓ¶‡þ~¶ïº&J­”QÐ$µyr»üPdíº°ó{â&²ÒU6§Ÿß¿ßt½YµŸÆQ/>E½z_ í!à*ˆN’Ò*2ù&ïP¦&Q›¼t/„¥Ý4CmÂ0lÐÛ?; &jJ{p»77-|¨â9C+SY™ø&3É„QŽäRæ ½ÌJ6¸1öšÀR’³+<ãŠw{ko4 ÇctZ¼|ù’TV £H~Y¡e‡ ¼Ü|ÖœŠ‚íwV$òõJP¹—ì èõá(íõ¢(ß-Þˆ¥ÄûÁ1ÿ†ƒÝá`³h§ã»qöptp\;:†Œ{CQçð8ŸRŠK)Ñ@ ,NiM¥É$i•)'¸,"Æ_%Òþ˜;™kA‰¤¤}한äh#¯K9çâø)h?´flSRe…LjóK}š'}ƒÜB•”‡¬nƒd˜ÒÊr†(I¡­O0)œA¸üXEc <`II"‡¥´±*eH§Ú-L5_ÐÅ 9-`0“àNÅ:é­[ÔGÌŒ&ù>etÅ)ìÛÉx‘«/RMˆ¥¬ã´™ÄΊÂháà°ù¼s gI¥±ûF¹ šÀpͬ }™ÒH'”.;á0¡sYû¼ÎÍ Þ8*&ª>¯xä͈cYrfˆS î¬KGm$!ÒsÄÙÈ›:J<£Ó „ÍÊBÆJh??¸µêž –²RtÉ@{­3 ô qðÉ]‡Ò‡”’»•˜ÄúÅKèBZ}H%¨Ö,Á[®j»—ò*›¡Ö©±wbL•EݺÐ0ÆÀ­)•/gö5|¡›Æqß«f†ìeAÉ9“VБýB8ϪoÇŠLú\ÑÛw¹pO„O’o#¾Ån1ðçbÄãcÙêïùÑ€A¢øÕ9-!H^ )ÜE­bz©!3[òå‰nÈÀ¸4dýƒoÜË«ów —°s&c.±)ÊY»JLì› X{ë‚™•ùŽiÀëH·Y”ÎV1F»„jÖ¹sC¯YçÐ`«ÛE1”€À¨ºÅ3Рl¬?HâåÀªí„ôÑ@r 2€¸¸ ¦óÚø½¢bÖ´!s¨qC=§jµâ°*´˜Õ+f/ßÜöJ'b(Þ¹{â5{$êâ)mÇ4fËß;~ͦS鲎9!òË:¡Å¼OT¯úëóXë–Š#ßa§^ƒ…í“VXvü=yÌV ƒjÂò‚$Y×ÐC% ã;5lªÀ3…àÌoMŒD•qå5Éj{¯ºª+ô­†°>4'„ôJêZòE­†r}$›Õ2ðC†ëNéŠC)ÈѲ îkPXë‹&ËÐßßó—Z“Õ²z´tÕª]=Õ6öš¼6#ô‚ÜL¢f2!j°KÅ`4£Ùö¡ŸõâÚ«aΗ¾£¯­‘ÒÛ_§n]ùzÝoÿS[˜nþÆÛóàý³“fú OÂÃñ!ã‹ÛÐ_.Y&öFá€Þ4jào,œ5®·µõÞqííg 88 Ç#Ìèúh8äýo'[mýgSbóendstream endobj 4773 0 obj<>/XObject<<>>>>>>endobj 4774 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£Ù"YÑ/_Òst¼ùòöŠØVŽ’OæWÉjÅéýlE]«jK&ëKYn¤¥¼©R¯PLò…@ºÒTÖø@þ¬-©jÂ:ìBá›RVÞQü… qôXÐZV[ézw \Ø1lÊ.œ9;!…SUÙ‹yC…¨2á åxÒ8¾•ãdC=î†á(SVÂýLhÝ©õÁqØ&å ÖrMÍ/¥Z8'•MZVÏQ;<1‚8:ôÖX’‹²Öò¦sùƒ&óy²X€OwKºͦã–7€Ñ¯~üôÞss³¶ƒ[Ddð•ß »n6Z¥áÀžhÄ?;e}#4íŒÊæÀ–@PT®åɬº¼¤­D*:—ÄÆìú2*~}ÎOµ(o(žýÿ9ÅA‰°h5ªÏð°h#ÚÚûàh¯|AA¸l“zcݘL-­ˆ—ŒQÈ6P¤¶fkEY2kúmÇ< 9Œ4éÉ‘°x\÷÷†7Ã,0Ž‹ÒXI"Û‰*•[ªzð3Tp@U;£wXGNZe8n¬Î˜¸µPUBw›ÁÉ–0@Þ@—иÉs5¦ƒi²Ö­C¼•äƒ =Tf˜ÖT°¤!F¸uzUà¬dÒ ¥;ÀÜdµyûî.,œ…d"šÀõã•ìw”hYÌ„©6H#Ç‘ÐÏfŽ`Ǽƒ¯±ÀþPËRÔFZLd›'ozä :¶Âùnn@'ÈB7EîRpy»j'£ùô*¹^\ÓòÕ*¹^r%Y™&ódJïMfø øì ˜O^Eò<ó…âzºLs|›€¥ù,ÈOë³ßÏþËÅz7endstream endobj 4775 0 obj<>/XObject<<>>>>>>endobj 4776 0 obj<>stream xVkoÛ6ýž_q‘¢˜ÄŠc'i»oéÃmÐÅÀM]Yl)Q%)»Æ°ÿ¾s)É©ºv/Ä1lšºÏsνŸŽÎi†¿sZ\ÉKWGÏVG³l†ÃÛßÐÙò‚Îg´*p÷ê)>äéw|Гw5SãLÉ”› ÛŒ«I»Z³¯Å’)DßêØz–Kr`ͺ( ñgU5–™:7ž·Æµë+½u7¤".àM»œOÉD2jå\YûhõáhFÓó9B›hËÊw·c‰kx‰KVÁpˆ´S{ŠŽ‚³[å*£×nÇ[ö§rŠP•üSÝVköwh×Ñâ(4. ™ÀN+¡Âæ8 W“³ŸN+¢Ý‘d$ YïJ£Ë/àRZ3×”³vUãç-16ÔLÒ:”5SªK U=Ò–Œ+….áÅm”W)è5ÇøÚyÕ4Vr3…ѰW8_u—T§ìûX´uj:Ø­ÒV”J˜JÿU<{×Re6e¼Ÿpæá2²/”t|”Ö˜ð£dr¶œÑ“l!ð›£Éóy¶Xà[>y÷ Wª¹›lè¬.Ñ÷“¢B¡²,»{D¿…ÈNˆäxtôÇèÛ•€ônr¬RVǰ="j<‚+þ½=Ä ‡g'tSkÛæ €«%Q(Ú™ˆ¶a}ªOÎÆ™þùc1Ð=Ÿ•Çrçž“ÓT•EvuõX¼Þ6u~Jø-ZKA{´ÞÃ¥µ‚±²(n"ªÜ•P¸#u¨’(hr7IÅûœ¦ 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_þööæÙry3ÄšÀþMòüWÞäòÉF´ÅÈú¾ß­^¿|ÿÿ½ÿ½Ü»þ.¿–U´ûSÜej¹vSŽû#¤55‹}heäxe–”PÒ©|‰÷’›@´…¬ú ÕËiè¤>².kó©ÔÐë$òÀÙP˜D ¯'fÇKA£Ê· z¿I3wÍBi=/ðI C=¼{åKSíö—›W@'Æ&†ú%¬HðB¥AAçÒ«kpŠ&ÀÚ9ÙIJ÷œï6^U{æ\I-’d¤ÐBh«ÎêAˆÒ’ 1YP“@n¹Þ@'Q›¶b¬‡úÈôSc²u!i®çâÿ/C]&f·W ”@¥kD ñ Ö–†E7ºè»Ù6UûX†Œ®Q¦Ä1Ì"‚Øt¤”%C¢0j‹+ R[gr¹þ½t ºEBŽVØtnŸ!éY‘=p ’B0AJîço0²?IÒi ‚dQc£pD>à†-„«o>}õ0>/XObject<<>>>>/Annots 1762 0 R>>endobj 4778 0 obj<>stream x½XYÛF~Ÿ_QÀÂHR<$9ÈCâd²v‘ÃZäE/-²5ↇÂcýûýªšGSÖ2ã1ÕTwÝõUõüq瓇Ÿ‚˜ÿ'Åçzø øüñëwAìzG±PA›È {"§÷=/ …·Æ Š…`žEä{k¾82mÜhíúר VFìŠyBˆØ‰,hº±Å³H wc1Е'BãÐÝR, µÈ‚`8î<‹4~Àš‘É~ 4¸aàFרô6ÆŽR,„ø1‘¸è{îÊbÊÅhÛÇ|ž!ø¢ámú˜³‘½Ð”\­-R7¬Ð‡¥ÓE#tÝGœ !B'ßÂ߉g‘ºKÇ‹Fhl".å 1 íy¾²Æ‘iÓ&ª°|äB>‡&ª¾¿fG„b¹6«‘ÏNO\‹õ‚ÈŽ\#Vs¥û«€¯ %‚-Ü8æ8Œ\sue’‚ „ Á7-’ÅÆœ±‘iÓ,v~ÕˆõMZP+„ˆH\ôƒÓ¦ÁÄÑñªMƒ Áðt䥞IÛ6`?…¥‰‹Á21mÜ K˜¸"6Ü ióa¯¡$º¨ÇÆUôÑÖæZ4¸kN¹u×¢ Z¡7=‹kÔ®MR·ËB¼™HˆE‚aÂÈ´ipãhvUj;np­  RˆÜnÂò)äïÌ‘ª ½à5²¾ÛYØ+\?ÒýÃîBÇ7+w½¢]*íÑ.qü~Su™•ôoÝ4êQ7¯wÿµ$ Š‹¤Yp~¹ŒG1$9ïʶ®Ò.i³ªœßœlð7ýÕ%ƒ„¤Î~¯i~þCM|zé³ÁÎ`daŒ¤¦;Ÿk|^­?”êslôŸm­èb"u¡¿ÕÏwMÓ±ÂQõÏcõ·ê|-Už%ÔÈ—çtïmUºlU}}FúZiH5¤ëºªŸÓ£¾k¨êÚs×Ò±ª Õ>¿sTvÅA×T룮u™hVÉiÚå{îHT«S:jÕvhÚ;¾ç-ýívÿúãöaŸð‚¡U#jÎ÷Ú®¡¾JОU µ+¨]½€Ú·÷o¿úŠ~VuƒÀìjƒP»»ž]U¦Ôâ[¡ÎêÊÃPþ¶J5=êR׊š10—Ñ hþ—*;Ì *ÿ¹¦æ¬“ìÙ;k˜°yþÉNõ1+Qç{g µÛ/W»Ä¾ï­i~Þ|ÚÊügÖ´Õ—¡šÌè«fëðV>Å ?ļ°÷Ã$öp2t76øû®æ¹‘TÅ9Ë¥ôþ·w?R¡®ChŒ•'Ugº½RuÆÙ0a—ЯúOUœsý†1âþÁ#Þ·`ÙŠ•a @¥NÈÍÞøñ›qƒˆ<ÿ ýô¤ë¼R)R’ê$W}afeUëÔ%:¨zï¤UwÈuD@-Y ,©ÑT@ÊSVuÍ\fc„eek$M¡YнX°fÀ^ôh–¨<¿.>ðš²2¯ÕTVåò¨Z•Ð Ö ]²öDíIã£ûå°ºo98y©ÕùŒ:L¸/Ynnco¸öÉÐ Ûš“µ’–²‚ȪþòìwMתCðÑE­kbÕ­/ Žý†+$ņ'ÇG¶¡) v…| Óú fL9ÔW¦‰®Ñ»âD{R0±¡æT]Jx.ßÜ„ Î.íªq“sg”aË•ˆ—˜Yú…faÔòÃÑV'§2û£’&ª¤ƒ¦®ájyÈê¦]Hlø÷uWšª3”©ÙMåÅübh‡“P08cÓT%?£Ð_QsÉiy¾¶'Àëò‚ZÄÍ¿¤zÿêè"ò¢Ex{eÊÏM™~›·º.ѽOÚ*Õ1$ÃÒ‹ª;\‘ÀŸ„Zð•µ&ï¹V…¹¶²jø˜}¬¹_õˆÞ·ãÌÉôBZÊŠ«â„äSÎ ±˜'è&YiÚ”+qi ¶¾þÆX¤YƒC$5C„ÆžƒjPË]Ã5ÉlÔãÏSHÚ‘œW,1Aàç†9”fØ¡8R/ƒ‹òù$üq´ÔòÈö÷¯±:V_J¤ \W€=là‰äC{Gðn~vä Àú5ÍþÝßÓ{$¾lKÏý½IÄîËB@i$Ì*°`$²ŠWˆ>ëi& Î°1èº1hì™2ƒ½BæV:‹hܹ9&ûØ­À~¾9:‡çF€çCòÊ’ámê¼êeLÅ1?8<Ìø.oâÖ,(; –]Ô.sèé ,ù ªÐ@œ”áWBÖ4tB¨Tœ0ÄxV$U—§¢}-)÷yÖô£{xt£~‚Ð]{ýø‡Gÿr‘ÇQäáï+³ï¯ü¥þ°»ûåîL¸‹uendstream endobj 4779 0 obj<>/XObject<<>>>>>>endobj 4780 0 obj<>stream xÍVMoã6½ûW ¶(àElÙ–?ÖIÑC‹Ý¹´(bÀ( -Q6weÑ%©xEÿ{ß’Éν5 ƒgÞ{3ÿ{ã3¡é‚ÿ“}ï×Uo±Ø|™-îÇ´Œ¦´Ê(Óâv-h•z«1­’þGaŠLåNš§þ|ËÄÝÝeZÿô~õ¹7¦á¶i?É…µÕ6}kmÊM®’»Ö©ÂÜ<õñãé}ÛÛëíT㼄ñ7Ñ£Êeáò©m¡L»ž£(j-ýS;GžM¨¥QÏ2¥; ñý¯cÝψqÎhˆ†ñ´âª¿CªØZJDAI¶<Œ´‰eÚ”2’?›“·ÈO8C¢Z,Ä^FtsùUì¹ôTµå1Œãh:…XÒ·Uq å —ëÚÅÝoPþKžH¬HŸoE=T²¸@ø› ­vˆ(K…&}pJät Üõ¸~ø­¾ŒöTl¥'ÏVIÀ™ó.=äd¤°º‡pê$œt áêc†Ñê½t;æa/N Ž7G÷‹Šæ>mŒþ"‹°Z“ßçtáÍpñH“‰Ä=ø"à.„悹>t€às_£û[šÌ¢ë‰Õ´äŸiKSúTT+¢’_µGÛŽƒÍ¢å’O="Ú¬AÊc’* _P"T—ÊL”¹ƒ S¿·•…4ÂaS(d u0úY¥’Dš*¦Dä”*ܬSI€Þ6Õzo!êJSx‡TZ΀ q£úâé×>­v6ýJÿ¥ÈÕ–*w4<œÜ*ªê'Rí :5»‚ÖdŽ6Šþù#l Ð¼AràÕÃÕ]"}N)E9û³Ö£lY¼‹êVº´¸F,C«PÓ'ÆÿîæÀnÁÆr¯ÊŠŠr¿‘h_ß *$Ž7Óñíàf6¯DíæLÌ„a#}¢R!S³÷2¦^õ¡Fl÷"”j¡9…Ÿ› ¾K€þ¾ãÖØkJÔ߀” n0Ð1ÍT–á Q¸ˆÖ—ØY_ÈødàÊZGÀhÒÐ@ÕtaeD¼BPÜÁ4œb’â½—¦˜€hÁ·ûË kz¡­žQe<ñ;†ç&Pì–Õ ŽÇ³h>Ób9âð‚À[kGcú¨Gá.>…ÁŒ‡¸Gù'JLëð¬Gd#ëêÐ|¼ˆ¦16°'söóiÕû³÷/>.à‚endstream endobj 4781 0 obj<>/XObject<<>>>>/Annots 1764 0 R>>endobj 4782 0 obj<>stream x­WÛnÛF}×WLÝe ›ÑÝŠ‹<¤±(‚6Va0`¬È¥´-¹Ëì’–…¢ÿÞ3»¤$*v…e[—s9sæÌèso@}ü h4åWRôúqŸðŸÿùø¾7šMã>'£ø” Fñ¬¹Ê麷»“a<Þ»ûË|Ï ·j—ôêò5 Æ87Ïà{:›ÄSš§ÞiŸæIäï]9W+½$Aka5¿+¤sb)_Îÿ콺Ógùù“á8žÍ` ºét”M I ¦dJ™5á¥+i3‘HÊT.©vÁ®‹…´d2J••I¥î¥‹i¾’<ï1zÁu£ˆvÏÀUx¨0®"§Š2—g­Y<☇ô0p•stôºß?›¯ð0^S[Ê 4¹wÔõwâMŒâéô”M¼Íóöd‹’#a%™²RF‹<ßPie¦ÃbããkQmÒ® €1]eìÝ?¼”ZZQ1:> ³Ö­wL…øK’«­¯ 9~65úÇŠ­Q°í(…k ×J{וXwQù ©SƼâÔÃntÌÉú²ÉÇ* –ÚXùMup¢€/÷Eƒ‰.¬ɇD–¢Sx1se›w‹.­Wçt¢JV R*“\0`Ƴc‹ ËL­Ó˜.…ñ œØ%x¦Ã3Sr-Œ}CáVztûåm>ü¹›Ç=nžè áœI”¨P™µªVTmJYˆÒ5-Á,v·ÔoHÓõ¡”•U‹ºá2 ÒØÙä9¹7ßFJ·À¿A Î>5Ì´ÒSziv0×Ê¥•\5@]³Fp? îØÿ×àãµÈÅŠ~¢¿9~.ú9ˆ(Ž[Ê…þé&x糞áä1ÞÊ6È;ÂSZÖ Û²…·èÀ‚HªÚg‚fI!M©·æ£ëª0D3r¥D±rºVq¹î¹V\#ÔÒ{o“ô})J˜g'ðZ–Ö 4þÌüFJ6¼ÕÙptF-¥¸*ô¬²45p2ÏÚ}öìÿûUyûÃ&r÷ƒlbÎLèzS,L®rþGõññòˆ¹µZrOÄn½älvFa¸!¨kW¡Òm§]ß\½§ÄèJàF㙯qHW m8ƒ‡;íØîgå6d&rfòܬ¹s¨ûW†\ÞåÍÛîæŸ~»¸ûãÃùÅåÕ‡‹ó»w¿¾½¾¦q@/0p¸ÐA’nj§ò¤Ý®­¨Avª«¤ðCþŸÑÀøæqädšöéé-!úö¿³…Î]ÓL„Ý¢õ%÷§ôÎ… í¦ ‘Ÿ½ÍRŬ •« {ƒÁćz`;Ô<¿·4ºl´ß7̽bÅa…é½Ð .@c ‚ÒAþ´© ݉‚O‚Þë4Çb–kK[^h`H±V"’¤*Û„Õd·ÒáÖ¯£P9Èdáh¥–«¿,ÅÝíi¬¤õƒ¼4Î)ÞK¸U>´É‚ãHš1èÚ©1Ä*›Fï¤å~öïxùþÚFÁáKk [%Ö£Úõ‡ ã*­1 •Âú…4¥Ûhnº ªôÀßbI* ¬­eFx½Rɪ$Z=Ìd÷ÊÔΣ­eã÷ÚíÝB&+¡•+|­ö’ñ¶c-¤»¯§Ì“ïñ)ïì§íT@]“êÓ¼j&ÈvIG)ëãöQ.UØÍYl‚¡­îÜx|ºæ¹³ €“zAj–_N ø¡˜+”HËlx~ñà]wgsu’€åY‡c‰I%/7MíX©¡ÑüeB¦ž ¯.gÍw„a£e4¡éä4‹1sádˆïQç&©}Óµ{"3>9 ÛÇ׿þLúÓx4Äw?L…‹yï÷Þ¿Ò@8ƒendstream endobj 4783 0 obj<>/XObject<<>>>>>>endobj 4784 0 obj<>stream xµXËRã8Ýç+nuÏ¡š?BXòšbÑULu(6Ù(¶4Ø’G’ ùû>’“@ãéÉÄEˆ­«sߺGw" ñQ2p¿iѹw ÄÃÍ=§ÓÛsŠúAŸÆ3¬ŒÎ‚3¿&¤qÚÅ»}çÆ°9'UÙ²²4Sº`öxüWçô¶OÖ9Ù^Œ¥#wÇO;KM•}¢ÓRȹ!&3âZ+m(e’¦œ Ïyjyæ iù\3+”¤…€àRUšfìÂrº»¾9å™°Jtã?ë-ñÜ8Å N;]Üæ•©Xž/©dÚð•ŠÚ¤ZJÌHH²P›•¥V¥ µ™€ÏsâÌì`Ù3wªP&4”uO”—3Ð+…Õ3ÿÍü°¥‹±°šio!HÂ@5<]RÆg¬Ê-ñ×”—–`õ£™ZZ‘÷˜°qåRõMD–q¹¥GeJUQ¸(äBBñÒ¹ÚœxçóWV”9¿¨#Ò(H\ˆcã8H|˺¿‘Yˆ9õÊ¥}‚º½Ûu+ñ@¬A‘ Ywóô¢A?–Ò²×U(àz!‘WÁÖúûó7[m lžNºýÉ15¼Oúž7k„ƒ¡Sù~Nu–’¬Š)פù 1©¦—EjÕ)?X¥¼ "ºæ%òɃsf+Í MºQö¢óóÉqíÐuÉ *]Í ôFÁ{éz%Ê×W÷wþj¹öQ|+¹î* Å ÷®;½F+ÞÊx·ObصëÞ­ª# ãFØ–oË3iÄD“i³ßˆ™ æ9ÏTÚôY#4—í!‘a­’ù²‹‡¸Æ.óU)­Ká i5jDÍUÊò¶ Ï¡­°m…¨zúáÃ5·*SMÛƒnnWºMôæÆÅ²¬à8 3?¶Oã|i:4gY;µ5w/¼pY iÖܽêI©Øææ%ù¢ÌæÖe—%/X9Á å¦ÃÝ9¢»÷éýKßZ㊹Tš7Þî\ŸL¢˜šzº’Vü„z@¯ÿŸïmkÜܵ$+þgƒGù±°0BöbÇ£ü8Ät¯1ªœDhÒ1ÆÍaìÂ?8Ž1¨ón°ž ñ,ÇððAí}=»YðJUyFR‰`ö« ⯘iÙ%o ¸7;Ű?8zë¥cˆB¦y•q6ÏEQ*mý7Ð Ð$°•ì¼ÉQ˜·µû㢱^ÝßÓ×3=¡/;~^½Ø1ôËþˆè¨ѳÄxþñáÐÐE$"Usk«ž¹éNÐ×KkR :±ƒþyÆ?BBW§W߾ѽ#â®BÒ\‰+„Z¡ Jsf>²Ï|¹P ׎RŸÐ÷.A.b¡²½IRâ ã$ÚŠ™€ÚG;nû¤ÀW¹ +ëö™íß¼’Õ±ãO ×MáÝ]WˆçñîêCfÞ‚6äöKÊï›ÚIˆbz¦*]Í:H\)àÎÃ’ë%ü0ž@õ\²v¶F©ìÆVl¾SGîöE/®EúË#|‡½Lý—ü·¦êÑWnÉ †Ã`èÏŒwôâ ¤k•VÒÎ_ƒ9|ÜUôƒ3,î ÝÅ€?^nçÎÂAÄõ=@ Ý7ãΟŸ&%\Iendstream endobj 4785 0 obj<>/XObject<<>>>>>>endobj 4786 0 obj<>stream xµ˜aoÛ6†¿ûW\ ¤qšI–䨖4À–¶C¿mêaæ EÚæ"“*IÅMì·÷hYëz˜#jH‘ôuwÏ{4?wbˆð'†þÐþf«Î/“NFøÏݵ€ÞÛ ˆ#˜ÌíMÃ1~¢›ðCÖíG£®‰85 ™Êæ¤Ì µ(WL¸'yÉ`Úå !£Ó³³É_ÞÛ8ÝJ£Ð®bB»Ód8‚êjÏ^ âÄ^íGi7dÅtA2$çDÃiuûp«Õxý{…î)‰ËÉs¹f–L±~Öº\q±8êùÆë‡ðG¡ø=1 ¡PÒ°Ì0ú'pËà†|mZ¦Qâ(„ [¹rT:Ö˜7’+Fè¬) L˱©l¡ŒqÂoŠ‚`YN´Þ”)+•¦É@—E!•½êÄlž¥¾ ªX&‚EQöÅ0%À< žÿw=ogá%âß—Ï9S?ô-Ç:í- r"{7Â{XKE›'g€`I³´@Ü ¹@f²4OXjóÐÃnYÁ°y)œ¬$-s”c¡ ¿gÍeÑ’>,ãè_‰áR€œcƒ‰À<•æñÑªÞ „¾ ÿ¤Ð`‹¿šñE)Ký:†#¶ßáý¦(5£Mžóö#t½ $Ë2­mlsÃë)`.̈fòû/rÀ½[á.A|ó¥ÈyÆ ìÊð]N½}8‰·Ý²›Eð¯hC&ÅWc4¬¹YYÉsp6Û.Ak½e´pØ2tVµkÀc¦CóØè°· ý[c¡AgÕsÈßÿ½õÆ*‡ë\™Ýp á½’¶S­÷áäÖ%6E;&«¦5NjµiwzÖ@ÃÀFtЯ[{»Ã v)ËnÖ|v€´×‹<÷WC~kµÀ_ i¬Õ^ú«!7µZÏ_ »V;ñWíF­öÉ_ 7µÚ 5œÅµÚ£·ÚÐâo5‡ˆgþj ¯üÕ.ýÕ®üÕÎ[xU† 9‡†—-È98ôZsx8ñ—9@|jAÎ!âE r-ȹLøC1r¡¸ò…#ŠËË^Ö¡âêª=‹W-È9X\÷®1Ïï‰Òx¨0ÅSá(èÇÕ©ò †ý¤:LNâÔʼ™t>t¾_àîendstream endobj 4787 0 obj<>/XObject<<>>>>>>endobj 4788 0 obj<>stream xÍYM“ÚF½ï¯èƒ+°Ž’X\©Tù#¤|°ãÄ8>„i“3d4Z¿Ï } vVlR)»v)­¦§§ûõë×ßWCrðoHcßþ6W¯çWNßÁÃò‡^Ñ`æÒСyd_ò§øf/àCÐßLú¤¶\3£tï;+©4û×ó?®³áÍaeoÒ·›ÍÃîbäO(ÿkaÖþ­7Ù¿Žon*s‹îâúrƒÓÊào¿_lnêTæ¾-¬Ñ¢›J¦÷‹ëÖçž+»½§´;ªì>J»ãÊî7Oi×­ì’ä»§H™W3ò˜þH«S²èŒ¨7ºéOñÓ·Pºýiߥù~Ëb2$ƒO¶M€×qzîtº¸>:ê§7rí¢¯ ã”Y ¹¢[©v’ØR¥†‚˜% u$ÛðNŸÞ]VO®ƒü¿f ?2K"!!µÙÚ`´Å¬ëojÞÒF¬Ö†–'IŒfimÚC™½å[ÍfxZŠ83©æˆð³D¥:àƒg†é7í+Ïõ‡OÜ›‡@ÉX3MÏéŽiÁ–1§ ÛSÌÙ-møFé}ûC!¿ð„ë;¶äG׳1g²cˆm·ñ‘Ø2c¸–ˆàT!L!„lOÆ®,|–Y Œ¢(²Ï]÷ÌÞ­=+½K %AQ*#€­Wé†Ëöpð‘£cG4dmï¯û#déMÓ}[hÇeÚma®üL¸©@¤¢sm¿;°Qí®9 ÿÛíAÝŸe’n·Jۢ͊‰Iƒ8mÏ2>è»:ÕL‹’<‡íC韥ä‚}cÈ©Ÿî¸Ž –¨ rtH-U²$•¡*ö‹®Ì¹dƃ[Ëm:EÜ"¥©Ó¨€êHeývŠÎõhçúpࡎYkµëd‰BS,¨(s€ÿðmF ÕÖÕ«g-6‡ØÃæ8¤Ølµ•¥ 4hS0€µÜ𥊮¿ùl9_Û²h¶Óû©LXÄi§A×È‹¬*DÇr³™YîóAON –·Fíä h²ˆšY«Ö}j2x_³På·n·š [q²$¹Æ/ cÃbBgÓb™^ L›EûtR‘M´û(Rq¬vYgÒd:´ƒ²IvŠ cÅ¥VªMò—M؇ù³cäSÊC3Ì(Wv0Öû46òŠÇð0sb0û§0” ªp3¤0ÝÓ'1ÉCv‘³àó°¤õè Olû^t=èYïëzÖ³z¶b.|IUEöŽU1°ïäQ.Чšß •&Ç’f†î[{_ÆÎ:=+’k®gK§–5þÿ®—zÐRÌ ·ƒi¤‘àºç˜)æ44·È– :µ©Zt”ŠÜÕÆxÏAùÏò¯™¹{mRèî5»Ãèp Ƭ¾/ž<µøk!äc.Wf]ÊQ@L$Óh´í ¡ëñ,þÐ » íö¹åûÒam?ÄÅ»A¼ CËr*á*4ö9AnJ„Ã]MûÙÉsÐìßÖ üÝT÷d»CÉš…jw\â,€Ga®;Áª;¥ïí5Ð Â,xJ *jnW£&âÛ窢FõvÌeH3E ÈæµCÌ_Ø I;ˆç±@.÷Í$>|˜ÖgB¤Ì´à¸¯( s^Ê.¼Øó†hy¡Ø9ò´4²ŠQ¥ò-½KÚõ˜Õ¶2Ui’œ’½ü~àñ–.ÓuÞ°$ùBä‚’ë$Ô©Ì9—.èZƒì©}ØÜöK½öKÁ£—ÔØq²Î/¤K5·7œ´?3Øó#fe¶±0{Ú1-´—4ñÉ-K„gÃ¥¡Íıº¶nvZà"HÞC#v騹º.°÷‚˜9¸LDÞLðb²Ç ²-¥:eB_„´Tݡ٫ù8³RJi{éùa>ûTH +Ã3ì 6*´Ó¦E¥¥¸ƒÆ¸7P'ŠºøÊ`í=ò'£þ½1ýôåݽQß¡·*È®“Ê9¸7‚Þððnob¿¨xÄݬçøýñ(ÿfb4œÚ ý0¿úùêo°hÇLendstream endobj 4789 0 obj<>/XObject<<>>>>>>endobj 4790 0 obj<>stream xÍ™[oÛ6Çßó)Òq€Y‘eùÖǦíÖ¢-²ÕE^ 4EÛl-R£¤¤Þ§ßÿX—4ŠÓ%Ö  E"©Ãsýñèï£ùøéQÈ¿2>z9=ò=7ë?nIgoBêù4]ð áWÑv.dgЛxôè¡ò"cŽxé¬Yný “¤u°ÌG™}zf§¦ý™Ï7¸*Þôˆx 1z¾G-}1š²M¢b‘À‘Ú@Œ…uÍà!·÷ÔïÄ•ØG„"{ЋÀ‹NÄ% ‘V ÄÎ¥pFÃ-v¨¿N´ ¼ NÚMcÍqo;£1ºª'}È×™Nà»Ú¬ð3a$®Ë$œ'‰u쎈B¶0;[[K‡÷ÓÊI…} ¼S¬õ?ô•a-ËÜF›Ãùì¨–ÃæÙáÄ×bÀU–EVÀpHs"µî€Ò€«šÒÒDAoïÀ Ïí•pZ˜ŒœÊrWùÞ4qáì7 [Á®×@œrÖ®üôS J€,ZºB AóK|ú Ó”Sú»o:¥Ó C'üó)¸*2ëq%ôe;Ç$²ÌéyžoJáµip—ñŽ9k­WjÿŠG€¬;ך4(S %àŠÛr•§¨RÖܦòеƙ Ù²‹U¾ߊE—Ê(œ¤°Ž´ö,6Û“ˆ´q¢QqáÒG‘U·Üž5âW‡)~c8j.Nkl]±e»ˆÊW‘Rž°c¬¡Ü0æ×ÃÿCgEa¼ï|ÖdÊìyHòû*[<ðΟµÀ»~w²%Yµ“¡ ;™^ROîΟ±§µÓïþ`×/ÀN¦í±®Ý ¨“i;¤k'Ct2mÅ íD(`N¢^*_Löf•°êf=â\ž/Âý )|!q¬µç£V :’i]¥dèdtþŒÔ7©îaÖUªlå쵡.7EÁ.Ê ¦òêNvC ºÍ3/ç}ÜnéB¤«Ï&èPÂôX4pIÚEûFЧ˷¿ýuþi%\òIeèÑ_ßlµ cÖT°Ý^Í+Ü]oOó5Z$Åü]¥t¥EÑæ–³²nˆí‡{|5Œ@ O± qñûÅÞ¹a ùlp0´Kƒæ(ˉe,šLûýÝïÚ¾³ÎÅ*y Ýß4që×Õü5ëLÐ(œÜmÂîUŸÄ‹n±Éã¹r)üËpÿv ¼ó mlîˆãD$ÉZ£÷‹(*T} üÐô4 ÇÞ˜‘³x>½²2\·ú~ЭÆvGüý¢ltpúCð•€Ìa:ë ö {à½~P|mŸúzzôÇÑ¿ÚwÆTendstream endobj 4791 0 obj<>/XObject<<>>>>>>endobj 4792 0 obj<>stream xeOoà Åï| »C\ $K¯ÕÚnÇiH;³@SªT šúíg²?—É–Ï?ë=_™N% ík3ÛjÆ‘“ø7Òëý„BúHt?t؃¶ ÃA+Ú Ï>—˜îúÌÖ{¤,x#ñ+}r`>üÅ—;”c %Å |š|˜`v9›Ée2}ÊŒµÎVöíýåÐlQHü6~ $Wص¨ ÊÅeA%rxŠãmv¡˜âc¨GÍ/Û<ÖpöîŽ÷ØJú‘–RŠz´Óì•}ÒM2endstream endobj 4793 0 obj<>/XObject<<>>>>/Annots 1772 0 R>>endobj 4794 0 obj<>stream xµX]ÛÆ}ß_qa €ŒH”D}§èƒcx?hŒ #r$MLr˜!¹ZµèÏ93¤D®í¤(ØØõåpîç9÷^ú×»¹Ìðg.‹5ÿ&ùÝ,šá ÌùãÃw‹u4“õj-$— ž¶B&?ÝõÄ\æqíz‡áâré/®ãh.k/ðb8[Äþl5Ö²öÏz" îg=ç‹(î]ìË8],WƒÉxÜÙÑU/Ðäú&æ²Û Îz"”ζ4y½Ø—¯¸†Œ´6çÈáªw78…LìÒ‡â:ÔsY3÷ëëYOD~6Ìëõ¬'ÒÙ«u=ìËÌÏ"ÚöO{2NW›hÙ?íÉ8ÝÅÌíU³eµ ÙÎp3×R¯¶þ Ïzb.ÛB¹õDŒ‡û2N—³ÁÕ¾ÌPX³›âz(÷PwG™Þïd¾sb½£M,©§ÂL’Ñ|%­ûdŠ£œM}’¿Û´Étõúá—ž6ϯm‰ìSX5‰WÑrµ†¶Q{IÞµÃý¤6¶j¸ù3ß¶*&,1”¥£Çx½‘áûŸ[äÛ“9ý *“¼pñ›x8iùéãûÅ5Emr-‰MõÐÁojïÝs­]¡2QI¢«Jj+5\h­ÿ‰†ßÈÙºTìAÕ°j¢ö¶©¥ªUmÉÌÞ)g^Âá›ÆþA´Óâþãü Jbœi=;U–ÚÉÁdZ*óïÿ«²žXKtaoÑZùb Jª_£Äô¾£Ð 7–ÑvË+ïTrS<ÙyGP€?ýkcœ®DIî‰)…=\/ubF§‘°ýL%M¥S¾.Mºj²Ú'A¹£®%SűQÇ~Ç- (}ú"y÷¬’:»Èù¤jäªs­ ¸T¤Ý3¬tVÖIªK]¤•@s^MŽ…ïèg•—¨_ ›#‰* ä` à_\÷oW¥J´@MüÀ?dD1êC“whj1K _œœtÆÒ'™ª*]!8üÅU–]Æ×$ý°yé ^þ̉G•EIr²Ð…V‘eÚw@Vñ˜Ù=xý©=|˜šÂVcÌ¡UVÓÖŸP‹\8y;}ûÝwR_J¸Ø:{h½¬3“D$4e™€ޤ¤>[9« BäƒqU-¨`sS‡ŽÏìûgð“Æ¦÷X’|“ý%` <íp;’DOšÊ¡ô*—70I¦)'9®MQ° ôvMÆw`Y¡àëQÚÁ”/ïõM ˆï;/¹b€~1™„•k)í|~Ù’TšÿíÕ“Ê=5âöAüjEÑãëçþnüœx½‹há½g&@5$Åó žåભ»øú1¨`IÑYY @ÔânxÎ.Ÿ¦†¾1H­êÌDè—Ò$Ä¡ö¦Â Iq¥ü€@ÿSB$¿|©š/¢$X*Xr[]úpadAA`B÷ Ÿwia3ù’¡˜‘3Y˜*LŠ¯Î Œ¯¨ùŠã£HÞ€û‚‡Wb´m¨ï˜ °OÚ9“’݈Ã×ôšcÙ#ŸG÷‡¤h ŒýxBOôè½íYlïc¶+WùÄØ•ÇØu5Í&¸ OTqD )%CÀ%ƒîq±äæxªo]²}•ª‰¹±¬æmö­J*‹ARa €Š¡ßpɉägèEÔldyÉ Lvt Ô¬ÑhºÊ;@ Æ û«‹ØHîûŒ]à úA˜ýˆádÏà à„3gý ¬ÿB»Ì¹…L&Vƒúüh»¡SÞo< všUöå6aÉèf ­ -_Dc£„ÿèŽ@(F¢¯ûË¡sK#zAAôÀé½³Ÿ 4%{škŽtASi46š—Íï''U¢ç¡hUâ̾^.ãkXÅ0ýÑÍqpt*×|ûaÑϪÀ¶#œyÉ€ÂÑÆT¶Œ5aïâf>{·è‡º> N— 9dwîÌΰ‘øˆú»{ïmï‰å¶›ß:iÓy€é=÷wÊD' xñ$çvÂu €Ùõ‰îäËŒ­å¤žpÍÙªš¸ëî(#ðú÷=6™ÄN㦫 ƾ¼•7ÿx_=¾F+ášnÐLæ³9"ú›pت“m²T~áH#…Kr;ÃööY&žŽ•Á:Ó’atñt\‰’çç o<ðýð—¡Æ`Ò'ØK@+S UÔÓ̪hõÛ¢)Q„VŠh»u®ûlUy¯ÎÞu$û+?è(>â!NßÈØö#‹= ÓÏ,…Ç ‹TžO抭J 6Íê¤0åLÁÁíš@»åCq8[PúU+¢×Ì… $F¡Ül+hˆ©væ‰QœEžêßyÓ©Ü£u}O¤éèÔ)õ›~ÛòòŸÁAÙìÑš¼b–£, K‚ÄÙÇÑãë¿^ÿo'.ý'ðÀä¿B„‘áéýõ‹×oøß„ÍœÊçÓ{5Ã[qø:Žã˜jÞ=Üýóî7ƒøendstream endobj 4795 0 obj<>/XObject<<>>>>>>endobj 4796 0 obj<>stream xÅW]o7|÷¯X¸0¬ ÒéËV}HÚ¸H~¡òb  îx:Ƈm'"ÏÔíÍ-}H—_M¦·ôöé%¾$µ6ò¤øgñ›Žœ‰çs½S Âu°ƒ½Eeö¾b²ÐèE§¸CS"‡†ÒÂ¥~#sU²@%…HI,û“NüÊ™7𽬯5¶Ý#gxöó(Øb/¤WN¬ ftvê#XAh½€Å ΋K©?Ê}Í œãÒ Þð׉¤öô5t\„îàH9óR‹@õ!ÄJrÙ¡VP¥…[CÃPS-v´’0Ú#ôok&¬ ÌÅÃ? úØzdý\¯¹EŽs³eP!7ÒpjvÉâ¬ØŸ8G³0üÕ®+ ãâì¦QÖ}j±Nýj ØœZµÈǯÇ{~Æ0åe쿳o’¾ÇÁwä"±š¾bÇå¶Õ§æäFÃŒ ´_SX¥ÕÚn‘ã?·Ó=tï‘¶ïÂ>†ïùý‹ÓýàÿœÂJOšë&.F\=wW:5nèeÖfúÚ³… >‚cÓ«ÐO¤ñuEAG}= ØŽö{ËzÚJtAˆøœ’žQáÓPÿ"¹`Fl@Wì½oÒ@‡W·ÁpV.º?püëV7 “ ­ÝubZ_àZU+.aÉbxÅX[F±CwKM¥³õᢦÂ&„ÍExfbß+a€ ?*˜KÚæÜÒ£0Jk8>aPÆ……ñÑ$<±M2Ø×4½ÊV‰µy4»á‹Áôš—cÔ:\ïÚ°R`¿)Nv¢@IvsÃïü,ÌŽ _Á\lØäšý÷†F‚¡òx€“ek`õÖðæT×Ö`tƹkJçÇѳs=¼Î{\`ÕÂ)\ã¤F$Þg‚b»Ø Éï°³ÔiÉ+™?`ý±Á©£[Ãņ‰‰X{Š»[#<ŽùË ÀÅ ”-¿aª‘Jº çQè5AI¿ù2£7¨]"A“ÃïÀÍ7¢I{Ãæâ†û°?‰G1¤pv¸^µJc<Š—…4(¤x=Lܯ•ÀXƒRxŽûV¯Ì@жâÅ=ÞÃ6F̤“Ìn‡À3ߨ}½¢qðñÝMZÍg“«ìz~M‹Å4›ÑðáÑ,›Ð6ok ,aÃp…'ÅãWñW,hrÆ[ÊC\OÙ|ÑBz³Ùœ½[žý~ö7­<`ˆendstream endobj 4797 0 obj<>/XObject<<>>>>/Annots 1774 0 R>>endobj 4798 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ü³:>{‚ß×_¡pZÈ]–Æ£zb «÷Ê|±¼(®®¸ø¹g—E¦¬8DœÌç ¨ú$Ý¢ÝÜrkÊ;:Ùô~šŽCÚ‹ü` kqGýu×rë°ö{o¿5»÷Aǽ[}ùfy,¹Âìj ÍÌù’¤1» ꌩ õ¿CÅ`÷ØÛ””dl£;?vëAmPDgE Íç"0$Ú€0rnÄ>ŸÛ>M%ìþ'PóBh—Ô÷aœ úYé{më CÐ Xh“WtIŒ’ŒBÐC }ŠMè¥H JLÇðA«&[¶h`¹­y²(H,J#©JŒc×¢S1Oö;ôf*º´oŠ¿èXn%›„µ• õs&TŒ!ä æIë‡4¢ÞNðÈü„R$ü<'ÔÞÕ€üåÉ2Yôû¥ _JÍK×¢‹ ï©Wû;Šc$b )ÿUs¶:…3°Ï^c`’•ŠÆn¶S¤Ue¦¹&2Õÿ¿¨®6{HùÌb_a“ì¦å‚`6æåRà¦õTdx›òp^Ê8ðM7"á.D<æ÷)Añ‡Ì¸¡g*I\Ô¡!öz0Uð+ïL•¹®7Ú¶¸' #¥ÕvÕËL/Ê™ôøt,*QÀóƒ(ìxsÁýTÚ'Oîw¾ãc( ŒO0ws\¥æ¥`N’DLîž’D²ßônÜl1ø}ÿ à;Šº\ª†®¡i:ÜjÈMï:ŠŒ);2ˆ‚ µC)ŒÓ·™Š*F²t÷Ä”Et°àê•ÛAòè’wW{ E ©…*¨4ñRá-œ‘gÔ$<2Cx:ïk$NŒš´FÄG,çÈÍ=NñÀk^ˆˆµ©× ó"ÎzIX§©!±DB*n‚Ø·Ý \ÑŠx»³‡)TA3LæÛ9x&XpÛtÀ8½I¾P‰¤¡F® ™3¦ú—¹+dÕ$J(VÙ5ØÏ'áf.¤IyhâlÝTI^z(³ óšÔKš ðøõUTDËÓ‹âÉùuyûYf<Ü>U¯\)3½ˆþ^^_rzYœ/!ñæryÁ¯®o~=ú×oÆendstream endobj 4799 0 obj<>/XObject<<>>>>/Annots 1777 0 R>>endobj 4800 0 obj<>stream xµWMoÛF½ûW U›Ñ·U÷Ô4MÂHÑDE.¾¬È¥¸6Éew—’•¢ÿ½o†2e'EE ù3oÞ¾y3ùëlBcü›ÐlÉ?qq6ŽÆø†Mø×ÇwgóÕ"º¢Éê*šRA‹É,Z´ŸrúÄïÓäj!Ïæ~Q>ð£×ëGÑ$¤ÛÒ«·?ÒdÍi"ñ±—´N$ã˜Öñh²@øŸio]B6¥XÕÁØ’ÔÆÖ|PÁÄ”›SÎhÿr}wöêíœ&8Êá.§óhµB¼ÑçL—äÞ”[Ú›QQçÁT¹¦OŸß¿£Â&u®ýlM>³užPP÷ ¦Ò –j¯Ÿ¤Œè­u¤TXdR‰©&վ̨€e2e Ö5PÁ•@å¯Sk#5¬`DªL$`nÊ{ŒmžëX‘7E…L…–ŽÃi£N© óœ¶: žì¾¤Ê™ (ÐVf6dúY ±M4™Òkt‚?Àƒ ­3ã ?;íøxÐeZh*¢¿¯O«Ù39ŠK²åz9]±rVé’>êT;]ÆßÒá›ZsF âY2&ýmž¦ªzÁö•€¼Âl³b ­µ¸ŸD+NÛÒCà8Hh¯œ¹jD¿Ù¬¤½3¥þÁÓù „¦—Œ7àŸó=gHfœìB—‰Nþƒ+ð‘Ô1÷W»wªª´£Ôà.¼ù"xžïÕ?=:-·¸>m¦¨¬ §ZK °Ü'£g…õг}TÐw¨:a’5Wn+‚»ÃaÑûg`¯$ÍÙ7rYÔƒÎIL*Ez6nf«KíÐiÉÃpzƒH;k’Ž™ö9»‚Á4ð5HÓÆM‡óÄŽ4ÄÛšŒçA»®ˆº½ÍÅ,=¥h&hùx|M¶Ç €ÏÙz V@›2alB0 |®Øzq¤Z…ÚißÊ ë{1]n‰Ë”®â“‹éùy&zãTíYAÒeT¸Ü¦<âL•ÛŽNñ«žóưNOâ^VÆCC¢îÂî´§M®`·\rSë…¶Ÿ…Xb°pSÜÇÑ ÁXZçB6ÇÐÑGâÈí8(Ôƒ)êâØÍS6ÀͰ?QP’÷-ö ·;ãB­ò¡èûr¾Í­Ó\¥P;Ôž¯Ñ¡i^Û¾Þ$ EÂWZÞÑ¿@°'çSÌ#»gêM .LP°¿Ódâwqv¸n°ŽiÍx:OY)Óh6çd䃫ã@¯T÷wƒ$Q…›¦Ås;º}ùÓÉkQÔÏ9øO÷23¼ÊlýúÈu´³K©n-—Wœûƒu…L£ŽFéá£H¹?7–—akÈž;]±|`>_í\X…lümx—ª»²Ž%Ù>8Qwíœn ¹¾nr7O»jQƒ*› ëª ûV;‡k6•Bqkéw…mšÜ^J`‘<ªq'íÞÅ BÓ1ؽ¼[È'PyIýÉìâ"ÑÞ1ž–ÎjûZÝMð'÷¢µ½ÛÑykQ‰N&-æ†?¿}9ÄÔ#–†lÊ\7nzð8H:¨­ XXZypr‡õßòöÚf…޶5Æ1ª5ìÑwËa)÷q²¼cݵg®"ßö ·¢0á|\{7d'íêà±ÀÛdn 4¾L†v¬Ú%p:žG‹Ù‚³Y´’E‰WÖË)þðÆÆ\Îq^´Lóòå+SvªïÛüãe4›bíÇáétÁA]Ÿýqö/—–Zendstream endobj 4801 0 obj<>/XObject<<>>>>/Annots 1795 0 R>>endobj 4802 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<ÐL¸«’lÁƒw ÏI½…8Žâ-ƒaófX='›Çöxi”ц‡JRü¡À¥ \QÂÇÆPÇ§ÂØD©Áž»Ç]ršÕ„ '诺9ãñohôP£JÁ×Åò6ð‚ãÿUâÊ ß» ½å¢G•% ¸›ÏmÿkÿJ=*x‹ ´onìž-s }ãz,Ç]Ü{þr1w!ÜÛ¾g¾qûÜpŽíÌ\¼ß]˜Û ûÚ%åëzÎr~ë»AÐï6Ÿ-À áaééÓ»À[\ƒ#*{ðÂ\yAè8=ºÌpk ¨ \µG¥–²ìõqåM§®ï.7€©¿œmïÆõû.ÍñÝ+/ìsgØwáléÿÌêðËÔÀ^︡ná­M¯WxâÔÞtÓö&Tq„¡X ×*¿Mñn`U5ÄyZ$;V¿s))Y„Â;ä»î}‘oâÁø/•ù1‹­ú'øÖ®oû4=Žzwä¿g=‚®Ï÷O*´§ÍM8£€WCU0¶ª`_@Ɇ‚ê$Ï _ƒsá|øpÁ›˜8_1xzáÔÙ%ûžäûªgÏV°b5‹kä{D7ñ¼eÔØýTQÊÚÀ„žMµÊ3Ñ&J2EîŽh@Ó5;ªöE‘—5¬ó’÷Uí`.,d°¯Øê(‡$«Yo£lâ§Ý $”*¬òxŸ²¬Vþ{›íÊÄiÓg õ¹ÛÕ>M£ò…œ¤êó‚|­ Îå2a¨éå å¾½¬à NþTÛüªªª“˜¼áJmżç¾ž …WVæRìqL|:¦Üg´{x ïX”í‹ã8çt-yñM,žÌî‘ÝËqø>fŸÞNQ±Ûã¿“tŸÂOtEËv8Ôx©5F—æï‡WÉ+®Àº©áq€®9ànúòx~œÎöm*ô ß0[¶+àаR¸?R”¸ñà;++:RÙ>}b%i]LÛ&«Àï–¦Q%?ûÅa¬â7]ôúºn’‚žýzö#ˆÚÚendstream endobj 4803 0 obj<>/XObject<<>>>>>>endobj 4804 0 obj<>stream x¥WaoÛ6ýž_qó—¦h,;vâxÃ0 k›"X›v‹·nC¿Ðe³‘HM¤â¸¿~ïHÉ–Œ%ÃVÄH‘<Þ½{ïîô×Ñ)ñsJÓdqôãâhœŒñp÷«ZÑèê[:=KÎh‘a÷l~žÌh‘†=cZÈãÓYrNï?,®ßßÜ>_|>]Ñ)Vx÷pr–ÌçØ~¼X+§È–^[ãÈš|K¢,ñ{³V†¶¶&mîí")…\+ŽñëÐmôjÐGÞ7¥¼,HÚ¢Ô¹ªÈXÛùÞ%Á~B׆½‚/§vį…')à .å£U!ò½©ÖÃèœ0iðÍ­m§T© ·y¶×;J­¬ e¼àè’Ây¾x¸î£È—>TÚxÄÓÞíê¢Õ–J±R}cÃý¡¡{Ú° YWÜ"Çž9¯¥£Övfoa´Bzº»DÅÿÚJ¥äÊJ .+ë\8âêeª+%±®rpo ±O;¨uÚ¬zi¤¡HSGumí=kny'{7pJÆ(Þï­¹;€¹‹Ì—ÇùSUvu'à'Œýö˜±˜µ€a¤ì½ªòO¦.–ªŠÇZtÝ“Y|™+a:þqÜ•J‘Ë:^u–2𤭙7Øåô¬F\è&PÒb߆²¡56ÖÓR‘QR9Ç,H»¤5ú»SªŒpÇà–*·›`Ñ•JêLƒ¹.4r=UpDP-|‰';”ãT[J9 £@¸VnÌ; …ªÀ¨ wnàqaGµSY“΂ ajPd‹ÕTg1Æè¡´Æƒì0W!À\«{ ÎíhaêxVˆ-c¡ |‚/ŸÊZÔn‡.¢N¹ÂÞ³˜ÑÁÅ”8mO1÷о/ÄCØõÃc÷ÈœjÄ€íº¨‹†t,Æpš/µäHwe~/ò1£DkãtÚåV+nPéäBÈ2÷–Ú凃Êj_s¼± »„^Á0RÍ€o-ÿ=¼Ÿ é‘Ãf é…—`QŽ#Ž*p:Å“Ônày´eê‘ó½û‹:÷º„1:PëŸÔö.@ÊùˆFVñÁ„þ@’Ðfä>€iã2´Ò+±ÜzåN¨PÍW¦àÎmxNËÐê”IèÍ ½ÃöxO÷ŸÚX^1Q©Ê¢dpv—Ä•€mŸÄŽúxí½kÛ·øP©&sî÷)÷ö]ßÜ..ß¾½äq~¤Áƒ Ü8üÆrú™2,Þ¦£ïAT$¨PÑU¦z­”©£=l°§×9Œ) œ‰–„j"zŒpÛbis-Q–Ìdí7 Cg†tfþQľ&€]Øfºr©ôkxÉU~™{e4÷Ò¦}®ñx#ð€IZm{®ØG"àõF»u‹…öÄ×Y˦J a?£B@ xçnK=hª ÞML]ÃÍu¼iö¼éF‹T< ù]XD3NÖó•Qê•¶ÜöEè BÚQiÂM¥ðëÀªÇnaãý ÓhǯY!¹Æˆ¯î»H¶1Í“i3NN'ÉtŠÒc"Yö|Õ®åÍr´ÔfÔ"€A”7ç£ìérã`i%C—ær÷-¼xñ•>|µ <8G ;‚N“Ùì‚Q d£‘û­îx¤Î-·«CœX•ÐËR"±OpŠ™Ñ@‰>oÖ-Uªv±5ƒ NäáÓó„.3¹7<ã ³Œ¹õ2[Œâlny’ A´ë¾¥ „ãN³o热ôQê¸y©Ø.·’>ón¬WßÐ+‹1߇Z$h-*ž\ÌÝIó W7àmØjHÀF ®aLŸ 9fh³°`—¹*ÚN¾/žLù}鼠׿/~¹ü÷—£ðjÑ÷_k² # ¡q´Å¤8¨Ñ–8¡9Ô³¶trhû÷,Øcµµ%. Ï%ºæÉ<”›þáµL=H²PÙx>Ç­Ä1ž ‡­pîtùŒ­`Èj¹:c¢âL„ãŠgŸX wÉ3êa·¦Ñæ´Ñ^a¦ã,…¢>ºš7¯O“ñYr>=Ç{çi25ëöãõ›á$#­·.ŽcØn^DÕ¾šžgÉt‚÷R°2¹à3¯G?ý Z Ø5endstream endobj 4805 0 obj<>/XObject<<>>>>>>endobj 4806 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îÞà˜¾ÆÛûGýc1¾º›ÜL¯.ÇW3q7¼™ O.Æ·táz=€¸ýãcz§¦$'D SfsdIWæQÖd ô}”…–ó)CÔ‘5¾°)pP…$bõÅĈÌ:Ð[RZ ±ÊšßÕÀ²&hŽäPFc•HÐɉJ§i à™€ðu”‡mÃaòv4ŽÎÇNnºAznd~uêÅ0„ËU¤ _+ð eIΈ¥r” 1J5^«¢ÒC3ú‚ø\ûÚuœÿðÛùôr¼Ûö>< ¢·r²vp6¾¼~[(õÉ÷‡C2ç ‘,–Ìu÷<ΈC­S,=Ð)‰T­pì‹+ëI¥ Ck7nåÒ/DV‚È« d1\¸û³&õ+›P>¿Øé^êHlqGÁºìˆ8$Òv}¥TÐ_A©t²%‘ä¶²Åëx_L¿žM.Æ›¨3I˜»Nub¬_zz`a:ô© œœE쩽‡ÄA72.Â%ðlAôªu{…w¦ÑtjQ6e ²ˆÊ3)Sc=NŶ2"/, 3 i÷¬)˜_¹v7¾9™Þ¾3öú¥7Æk—§Õn à±ó ²L—¶yjóh#†ƒ+g=gÝ)“ŠŠ )¯kÇj^ÞßSä¥QO(aRû7Ç=œoJü÷ZãƒÂrg ÔT¥7IøHŽ1§Ð°¸Õ0í•ÔÚ‡*HšCÚŠ" $ë²>fµŒ‰ûÜŸqªc/ÑÊL=©¨ô¤É@ÌGÔx»@sïæ‹>NLEˆ# ¤Î²ë„[fs›¢Ecüx`¡lYUš¼Z[£ÑCw4¢»Bw%eY:ZÚàˆÐ€æ“ÿ/â )‡|i•Œ˜˜6kj[ê«A]ߌÏ&ß6ÆÅ8#dÓ0’*ÑOÅÒißÌðºÓ¥áÞCÓÜ£åj®ÏóŒÙÃJèT˜ ¨Ž> LmÕM~ CKÛ ĨCE¯w:¹¥Ù`StÏÔð¥y ©ÚÅÜUßÔ¢F:¥°#æKš³kævˆGÙO1§ËWC¹O§Wß7ÅBàÖÕÜÝ i*M!<ÁªyOÍý€ ˆ²£)µÆâõYØ! ðŒfBo»Iòè¼d+Æpj–<%c ¯Z–РÑr[b )e1˜«H‚úÔ˜Š&Œ Ôgܳ&]îàiîÊ ¿˜Ÿº+3žJbU³w¬)\ÓÆÑòy’¯4nl O¤†cöãQ—¹ý|¨Ðoî?£ëëÁ¦ô¼ƒjdæWžê„å™ ½´î¹‰VÇ>°^>rŽZ‰ Q»=´“H9‡6;_֪ݼºö}šÂ£ÉiÜp{ÌšOè7¯,¤[„-pb6¦q]„w@j÷ÌëÖ–ä5/t†›×“UÏ :ƒ%.õØSïa—ÂÜ¢„¨ p’yî( ¯7«¦ÃS¶XÈGŠ1Œ ø B¨)%­Úо©bîÆ‹±zòÊ8Pe³¶­½CaV -B ÌÝZ#^«!¶jH*aP$Ì^-í«éhz ¾}¶Ã¬†éw°ge,p Ü€¹¡½&CŠ&k*¥ØÔ³'C{ob¨ì/b g³/Îm¥UA¥s¨-– €L«$¡•À ´Tç…ž‹×Àœ¶=9vZgð(lÞaUÂ\E;ʼ›¶ÒÑ ð$ogÃÙÿ#[ ®ë×a}çQ…´ö»:h  `Wë.ÿºÿã»ñEíÿq½öú‡ŸÅÑñaÀ íퟓ¯½AOœÚ¨¤õ••€¯l÷>Óÿ ñ¾üYŒ¿Ín†bz=›L¯ØøáÞQÿÓ{5N Çôæx¶õÇÖ?Ë|í=endstream endobj 4807 0 obj<>/XObject<<>>>>>>endobj 4808 0 obj<>stream x•XaSÛFþίØñ;’)vÀJò8Nñ48¼˜„ö̼s–NöéÎÕI÷×÷Ù½“l…PÚ “Aâno÷ÙgŸÝÓ{GtˆGôú”’bïÝÍÞáà/ÛÿʽúpLG‡t“ñ¢Ó7ø-•ø%yq³Ô¤í½)-´­è^•FÍsM£ÑùèbüÿéÇñ—ñÇ©=Õ™ªóŠŒ§axSkŠºà7G¤l*v õм<°½WNbX}ÄmG¯/ίßœL ëvÂË&™Dâu%¶ÿ€Æ/´”H8´6yNªªt±‚G5ÀXª2¥ÜØ;OYéŠç‚§µØ+µªŒ]„Õ®X™œÁ¬«U]Q©pf‰?)‹x•¢ (q+€÷Y^í ¼2å+]ÐÛlKœÍàãÐo°*Ý¢T…‡·wšö u§÷ùœ¨ó 9K…KMf¸†‡ÊÚèbŸ*‘wd»¤B¥š2Wâ bUjïuŠs‘qqÔ?›¨ë±Ðì©<Ý,9&W&Ú7Ðmë*A\ÙM8,…ãò¯,™ŒLlêØb@S½nÖ{ï+Πxš´ôƒÁK`ü˜°¨‹ÒÀÞhÖ•:}6°Ï—ç³'é'a|âÕ…òwÄSõ†*3yJÈÂ÷8ÿë _'KRa#Îlùú’«8á§p¾B‘ñ¬Îøb×õX9F¹%q4Wr' [›jIN‡ý%2>u×8xQ±}•{G*ËP¼ÁáâJ—…ñDñÄõÄ„AúÝüw¬ , „YfH]ð‘]>†H„lÏ3æâ|vñ~rý·Œ©t!е ˆ±WI]–¬rkWÞq®[)ŠÕ¨ò¤Î·÷„P D{„'µ`º††<Ï[x%#¨Ðh)Î"Tµ@*€2»â¡€j 2y|Ú³¨£©ž× ˆjæx‹ÚøÞßIq®ª1dŽ/̽ÆFyNw÷Ĉ`Å“ÇØ<ö€mlâ€fÂEº•è°rYÖMñ|Óê|<¦Ýά‘Â$°y'ÒŸð}ƒ!˜Ùè7ê ±õÜE: uµƒIôy'óH†E ”¦'<a<_áÓɇߞ¢aãà?h0ŸÙ#ßí.ˆXÒ1z5úñGª-ôz+Mƒiù½Ø@·~T (rl"ÐÂ>xãÕLÛÆxZncë<}Óuv•…Ê¥‚õß$KÚé›Ýt·SDŽ1韛ªBãšC–‘f¿Ò:Ê.^ZA;„ƒ‘¬Ü¹*t%Ré½²U,–}ðMÜæð ©j4ÈŽÇñØI·‡Ø$Ü0ѦР=j—(5šJÎvœeoÅ.´Ú8I„ì$Í (\F_ ˆ…ÔÔ¿°¯ CÇ× ã(æ:¨‰DÐYóÄk¹ Ü8>ëUHtÔGÝɪæ›NÜ;C• ˜T‘€måaZi8V†„;> >FÆ©Ò2J˜<ñ¼@½Og“OSv¨3{Æák*”ⲎÒ$ÍÉSuåØƒÍõ“ FÁPú¡ÒHÆ-:Œå%:5è.4‚ìòŸ»“§¹bÙ˜uª6+_ibsÍ!ƘSŒV FU[Ø…'Âuï -“¥N{»šÈômý Šè-ù ôa^ªÑ¨±‰rìjóÅUÿó¯údÉo0²5ØÅ-›³ÕJ@Å[`) -p Gi@n>/&]¬Š}iÈl²ùNÕnÇ}Øê™ON|zsònÏ âìæzr5z*ëÿBƒ!©+‰r¿’HûIƒ@n콓~þmùƒ­ >jR«Ò¸í ÁÌ%pV[ºÅhà—nE,»m iq熦b!Š4f€“dQ!%TJ§”›ºÁbL «\mtú·ª·t*ê-õúã¤iË¥½¥5ÏL|{è…ªÇtïEÃüW¥páëË^ Z,*4p rÖõ r ¨Êçw;ùù©´Ýr¥gXöíð)çC\¸&¤Ã,†Œ}¿6‹ý¦ÑèÔ•ôW« }ËxGécÃì¾ËP‹ž!õd}„H¹2E§âì5Râd´CÞâdF> ö9tUè=ÿy|9žÞt‰†yyx<8;ã=ï¶3bL'¤˜tÑf¡æ¨|n ž!Â%#ôoþ„Öëp _ ¶_%¤ è·¨©ÒYQ‘¸ÆÈM ؤ:©`zö¢ýËžØoŸ?ô¢ çaôf³¼eëKûY$ô!9§½# $©-ì¼áÏrÃDÚÁ]>5@$jL|B왎†‡?€JÖäu8| Áx•ð¸(£^¨ÐVÝ;“¢P¹ÓÁP'Ú`4Á…$Å.Œ•ã»(û(ל¶m¦ñq)¤zôéòêz<{ÜüŸH3ÒÈ7V‚:V¨24Áˆ¸ÍâËŸä.PDêñaW]‹€¶h¢ó󟹙‹jóFL ºÅ%š‘ƒBr›È™úª¼Õ‹Ü, ôBè쇲›çà5uÀß<îýòEÄòýOb°Äg~Ã5¼Ãm*æxop· ¬ê’• Ûu3ÅYüž5<<œ¼>¡ÓŸÎ'§\,?ýáàÞ»¤æït’ ÞÕo÷âo|Ryg4ž~™\šr½Ñ—óëÉù»ã/?9<¼â£!V‡oøÕøfï¿{_ý¨‹endstream endobj 4809 0 obj<>/XObject<<>>>>/Annots 1798 0 R>>endobj 4810 0 obj<>stream x­XkoÛFýî_qQ,µhI~$é7¯ãÄB6q×Rà-`;"GÒÔ‡;CšQ}Ï™JVê Û´ˆáÐâð>Î=÷ÜKýï`$CüÉÉ9òõÁ0âþñ×íÛƒçÙ+Îð{-ã“Qv’þ*ezðÏÙ£'Âcn)ÇoNe4”Ù¦Ï_á¢q‘zÝ4¦ZJ³Òryyqy}õß7—7ï¼½šNEWÆÙj­«F”3j^êìùì—ƒã7ˆá4;Fã—¼,GçÙh$×7w2™ÉÝÍí»i<¼ó?Ÿf/_òì çÊ›\L¡•/•B7:o¤[éJ6¶å´äv]›’AêÏ*oÊMÖ«5oZ”Œ«Bƒ¿.Z¯ÃÚéc[óÑ‚.ĶMÝ6™üd[6”ÁhÌX’Ûf¥1øA,ˆnçb¾‘…ukÆ d¥üJìâZ@‘Mð¸ÔÎæÚ{ë’3Y8»×VUsŠÆIgš• ®"D£—©FƒY“ŸÆç/d@ÞK1Ó!L­™3ÐÑbëÆØÊÿsN«²Ëyñæ×éÚfarEûèoô¡ªø¦Ðn ÎRWÚ©¥Ä)#[»?ãô{Õ×a¶Ò yÃ:Ápë üº8•O‡ îÁçe¸÷éyà‹’\åÀr·¬< Íx”'a/Ijî´oK°çŽìd°‰ ¤gÄÆôw´²( |êÜö Í£3øa/‘ò¾­ëÄéÜ:GúoùŠÀM•—møW–Ò)G6yÑMŽ,ÃxL$ô'Bˆ´Lþ¿Ì5ÂÎÌ¢-á°s¦i˜ˆUvjãA_[´¹~ªÍ˜¢ÞV-@Âöìl[²ÔèXpÑÆ†0d²`·`ð¼~€‘ÂøÜò‚È£Vhvvy&_©j©cÿ¥ìí‚Ràv¨ ÕJêRóá¾Ñø÷•íþH˜Æòq:ùð6ÉœÜMf×òz2]^F²=%RˆµÉ¡P(— ä Õðª¥Sk’…ù4ÎÌÛ £±t‘ *wÖóIÇœ »¼v0ç3™µ± V"ÙFA`eΖŽî÷` ¢Á:o#=aÈJòz¸ð5{ fEkG‚PÓcsõ`M!O†B €V“'¡<521½úoÙ5³AnJB“‰€ÉP'¹—¾4a0\ÞLþ“+¨±üÒúF*XÙ(*ùüÔøÙcßž|Cy:;Qª3hHóÂ|VÖV4y…84P5 fH%}÷†ÿˆd'2½¾¸%Í.$ŒÓ¯sëB–΢2àEÆ(m F %*A·CŠÓ‹5Za,Q(YG¿Â(£(Þ+ UúM&3 †»a"Ü{YÙ.´\®8ÛªSµÖcâîᨠXðG™P@ óOÏ$ŽETG:ŽÃ•bùÌËïƒoÔºfè˜(—ÙÈB•ð_ètÐUnØà‚$hœåíOýß‹ˆã<D!ž·Jã7¾Ñköƒ˜ª,ªäÈB÷(ê †®$HŒmjÌ/ÈÞQ8 $…×̆ÏÏEp Ç^4hÆtù;Mxm¨y¬•­àÌ õ#¥Eâ-[ŒI«…-KÛ1>Ž÷–þÀe­›/ö‹‰œ9‘Sgia8ì·×“Ûx§W²Ã';ˆíEhâÙ?½w|¬R{~% Ðÿõ¿&Þý?¡|cïÕ=„­E-H‚ ¥1EK’ðñýÅôÝÓéƒyÃáøEIuE;|4í¹¸ýQ9÷:j ¹»u v³ ¡•“8ìC7̯írqJïŠn’Ñh`õ€‰IåRcEXI’Olåèü5Ä=‰×nLˆ3·q”Vvu4 ¹aÀ©åƒíˆùzþw¥ÜèfiÐÝq«&s?ƒéãe»¥|‚û$=e,(8ö=q7ÚÆ’tvXýÊÔÄ$Ó6•Jw]Ðên]þ._A¹dù½—Ÿ`ý#±$ƒfSC«~þNÖf¹j¨RŽCŸÃž¤ùf|¦ºùJÓìÞ¹¾l:ÝïHL¨ªN%Ž ³ŠÛ·ÿ°eıPXD†%Óº¸Y‚î<úd_¾wìÞòú%ûћީ\c}º¹ýi?æ°¤—¼~c®˜Ê×àèï6ý,Vu rîLhãý†Š‘wåÌ=§ŠF÷‘Ý“´z–JZ ×ê^V&nd¡úsƒè=VÔFc¿EtÖÝg2…þ‡ûû/Ùxe>\5MýÃñq×uøv¿Ùl²B§õÈ…˜÷íß¶OtC2fƒ]/‚1ðYƲfIR?ZLBL¼E@XÕ½ØùžÀóª("iòÇEez7yʹ]Ì€³dl®ã€ãȸµ«Ð˜k .aO„YŽ3„ÖoB1š„ùöa§×Xá±b÷N ”fmš°ø’„{¡G½A=©²‰­‰‚ý›ïxxšœÉùé(‹ªÉÄãl(¯mÞò[ˆ`Ÿ¶ýáÁ ~µ¿zÆ•Kúï/&7xölxžŒã;õødÈ®fÿ>ø èS~Pendstream endobj 4811 0 obj<>/XObject<<>>>>/Annots 1803 0 R>>endobj 4812 0 obj<>stream x¥V]oâF}çWÜ·²Òb0Bö-%EÊ&)aµª”—Áìiìwf7/ýí=wŒCSe+¤(àù¸çÜ{®ÿìÅ4Â_L“ÿ'eo°Â1l®{ñlÑäâ<SIc<áxx*èÏÓdzöâñßíïýºý—¹`Óf4\]P<¦´ÝÃól~Íh›—#Ú&ýxÅgtµ^­–›åíbù@«ÍÝ7ZÜ}»_ß,7‹ËÅ×å§í½ájJ1n°•Ïç0Óßæ’v*ˤó”ªý^Z©éh'}#¥¦¥UO¿8JLY©BÚD$¸à«*OB§”´+ÂÊ/ì˜À6>l(GUÞÔҴøLM®’œJñ' 6àÝÓ^8/-=öQJgdjOÞü ËZTY“YQ⊣Ò8_¼Àðä ÓÈ”RÓhò¹ä]<æÚ(Ý㧨M?žòœƒ‘öÌãxvNoÑáÍ·9$B“¨½)…Wà íR‡?²Áuà¼ç€§ýŸyic8 õ$eåÈy8qðãÈhÊ•wÃR9'ÝÇŒs ©9fA-m¥Ð"“¥Ôþãæ[‹Ì`Å$2KJ'E‚ðFX z]DkÐ/ˆ¹áxÍÔ3~vEe:ÉU–£0ZÛ@ƒ¬ðò]>Oš±ÈQ»…Dõ/JáÄ áËì_ %Syeô±ÏF¥¾RSïà”Kˆ‹;©*æXt\€æSX8ªÁ`<.P«s‡4ÁŒ›åÕzûÐZz¿ã…~ä&ðÞh!n¹Jš Ñíå ÐöVíêA8ÐÀ–mÎú@Û\ÉãU2VeŠ»¶+†–¾¶OI± ;´bÛ$7u¢„6´1I.º ¼‰#aœ7eeå‚sH¦+DT?¼Ç¬[¿§!þN8÷¢.hS£1Á%CŠÙÕAH¹d‚8r0©Ü!pøJžPÉNÉÿ)>§ËïÛ¯w›Ÿ3|h¡Fµw÷B—:µ²¡­UiÆQóýÿ /L›~î}õe8t¢Ü‰ÈØlø7Š7†oÏwÓ©uËîD**=æê†4z{à~à•œj'©Q>§‡ëë`²“k„øCAýEI«ºðF‡6³Š«{½§Sã®ËÙ¼••±<>@4šªDÑ…¡‚•# \ €¾’¥Pè;P®Á˳,L%mZ^æa–TC¤ø39Ù–·“`½ŽšhMÓDl%àÆ6¢Ü—ÅûÀ½&v` hÑDˆ4¥Z³qL×·ßéZjiÑM÷P•ÐJ¤F>Ï•FcN½Ö6¢û6Unï1²ñ"pÿûúö: ûán*=¢s!íæâx4Î&xu™O¢yFj0ÆË•IjNFsBƒîðàœ_*Zõ9å5äl4‹&c@‡;ãI̶–ÛÞo½³A½Ýendstream endobj 4813 0 obj<>/XObject<<>>>>/Annots 1857 0 R>>endobj 4814 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Æ“ó 3wŸ®ß›¼ššw³YñØÔfTÏçuenÊåâ§ñ_J«<‰Vî#êÄ#ÙŠ/NRh=ÿ%_–“%eøû€–Î[WUY=Š•mmÞÇMGÔ]à¢Ðà)?‡IßlK|mß~ïLÑo®ã¦¬ s»X•u%Έ!ÿCðƒL^WË¢Yq}küÁLêiaÊjU›Ç¢*š|ULÍC9+¾Ó Ü^û¼ÁØx¤ÙÞxd8b/â¿ÿÔä‹=»}.šç²ø²—«u5a„LûÝv¨xr®ê¦(¹¢ùΈø,î©…««k»²Ó›úPW5b<«ó)òýŸâa}òºcN_ÓÞ§§|eòûz½BWËU^b«=çM™ßÏ “O&ÅrùïÑíý_Ådudɺ]5ˆ¿mW e¶»i^ååìE³ûÏ‹å"G(Nˆ‘K©íüáò{j;—ÕzÎ~ù -û]Óä›S¯g4Ë—Ëb){änÕ¬'+ûçß+®Ð|>¯ŸÌ|ó¯Ï?m7åÑÍíùÒ6îúaaØŠÝyÅûÏKù¼=.iìºz*šûyRœÔدÅüäCY̦6è’rŠ#ùéicªze¦eƒÎ1Û¸FeF?ÿl&.Ië%Éw@­6‹âF¶Ã© ¼d&x2–ó÷[æ—T&žq1_Ì03HDüõÞŽôQJ£3à°Yi8î:½wøë¾>Mu¥\ïrR®Lë!f9JÙ±ßU8.V¡ë‡Ïzv#KÓâáMçÒòÝl›ª®6sCþEGOu-™ÎÍ¢)çy³1Ìõ1ÞÛ÷[2m×Û _íÜ€ä¾ý˜78>VH/–¯g+÷;wÔÄ|»`ÓEu=‡‡z÷[å݉Á9“7´‚£–ËMù÷¤x•«ÁGœæ~ƒi¶.Þ˜…ƒMñP4ÅAív×ZÝð¢×ËéÐ;A˜ÈmŒÛbž/^î ^[Ú6ƒ+AY™ÕS!=Ræ¢aú}Gºþ û Šö—Åmçö÷ñ«Øÿüxy”%×ÌÚ‹ÚáÍÌ#ÆßÝy%CüyùnÛý‹lݼRøo^+þ¸«C²›ë»¯jltóîîîG—¾å¬‘§žó_ëiù°áô =÷ÅSþ\¢åÛ©‡'`Û| wÍÿЂHšËçðÐn„AÃöu=-ªU‰™°Á›S…+-¿­¹Ð÷œQS`ØÀ*–›ù}=[¶MjÆRTÏeSWs¨Ûß‘v-Ä/ýëIÈ~ï†æË¿Ë¥¸Qv¾_àFüϾýíEµžÍö»zDóÜa“¡B)œÔ,^?8ºoÞà5ÌæŒOÔò°KÞŽµÙfá[)o‘›zݘú íŽ$îÏQ„C¹váÁÛ¡ÁPšã%q²žåÍôk÷cÇÛ«îÅïàC¼Õâ‘ÿ¨›ò€áo€-/#H…ŒØåøì¿gÿ„a9endstream endobj 4815 0 obj<>/XObject<<>>>>>>endobj 4816 0 obj<>stream x…W]o7}÷¯ ,ª´ÒØ–ÇmŸšìza hÑ‹¾ø…š¡$Ö3ä”äXÖ¿ßs.gF¦³À"A"iÈûqî¹çÞùûâZ]áϵÚÜðoÝ]|z¸¸ª®ðãüOث˻÷êúJ=ìpöæ|hä9>Ô‹‡ƒª>è>™ ë`·&ª/ÞÿûÛ¨âÐ÷>$åwêç¶5ûàÕgßuÞ©_lì«ó¿(˜Ñj7´íjgt‚i”íúÖtÆ%,®ÀH:˜ÑÀ»‡¿.®Ôêzh4¦ZíöƒÞ“v N뤬«Û©N»“z6®ña{SÛ­•qíjqÿ®QºiVðÕùfhqiç-£#¢ÞÚÖ¦S5º_¿§ûßœõa¼5¹DîM†ŒÿÎc÷NÝ ®f^QÝ;€·ÓµQ‹»»ûÇw•XsK•´mq©Q}°¶=©äȰÁŽV¬Û«£Mõùòó÷ß3©¥B‘’¶Öm{Z2‚´[ž¶ÄF«ÎhD²=©ãÁ"“Úw½máH´µoŒªµS[£Z¯–Ç%›ap>‹XZĸg¼cZóbê!™†ÙÞ“I¥º ‘ Ø“ëÝ  Ô™tðM\*ôÇ\¡l™×踈$ø!YÇJßÍ&%›ÇmuýßÁŒ³>½ŽqŒ ÑI#át4ÆÍwyNò£‘’Ìkïu›© Fç ’Û€ªÓOH;©ÞÃÁ¶5üíïÁÖO¨çÞ8tÂo0áLmbÔá4ûœ @‡í¬³™6Ñ+æ±(bzˆ¦Hf L@¶v@€ÑØ`ê¿‚ŠdCÊ+ E²CÇ,ú™X R Ñu$ šeüóXæ`—ÌíhÛ•‰¾ˆdÎn7˜c\£I4©\s¤‚'2̺'|’Å‘s9†ìíak"ãœÓ©Ô}B”`4JWĺ£û&ãÀΜX ¶“ÚµæÅŽ®¾øÎ|]R†ZrRÁ´Tì`t¿dë ª^2Œ³m”ó©*,±Le…PæãzH¾ƒÚI£r÷l žRŸ˜2Œ¹ëΓ ½‚pÊA´² "Ì6„eì­"©¬35aåqñ¤]aœ|ÆÿKÞSæEsÂQï¿p|0igïК[HÂ-ÅüËȳVÍ pöÌ€QÖ÷§"Ä xB*#Z0ADÜv¾}Â8#º¨Œ8&ì4 MRæË»Ôõû #Žƒµ¾åÇfqý±ºVŸt´u¤/9…)œÏÜT··Ó!ûOž ²äÃçMbµÛÍâ~§N~ø…À˜mXµäªo)BcSûóÑ$³¸ —'-Æ…`i 4‚hs%a1NzY uðGð'ˆÑ:)»E ƒÖÁ;Ñ[ê$SðÆÆÝ<ù™«Ξѿ¢ÑX22ޱ“uS¬’°/Kb5/ØRرã^ÕO[Ð1ï5ÂŒ‘³5#ö6˜+ú̶A4ñ[Ä: „Ÿ&Dcj°^Ò…(`‘e CM‚Ê“âAZ":îPv§³®*H¢ I\ª-+ÊÃ[$îTÀ¬÷Äv*s¶!4›w=t9†öÄ4-¤’yA/Â×jEíDl› bÐAÂÈ» ŸNý¨±Nwç˜3E±cµÝ©EeKÎ.б˜C$€½³˜Q`±ëPW JQ1 ””'²`ªú0ïDÛ±zqAF/¯¡ ×K¯êCæ”Gä¹(<ÚëÇR LGH±zszh»?`!‘ ð îy,‡–{´¬¿pɱKú†ç}²£œí\béÂM4KŒf>Auâ>¯·R°3ònÀV56H¯GŠgL'ŽØƒôe×ü:Mž‘ªºKq k:Nê4.“¯7©ŸÄ÷ÛjaŒ“–ç †å&¿TÀð´¤Uê—°`ðòR$yäz”0kDÑ^³{ ¤…E\–óÐEñ&åì,/Gȃ{7A—ó2ùŸ±Éäyò†ö2¢Q®îؘ³`Â)@™Žþmo/e³Ä³Ü1ÐDH‘$ÏÎ*ÀBu‘ù«Þ—ÉÄw§×¹p¢ªEf‰Q˜ßÙ¨M#û.è•Sšƒtà!Þ'è{Í %óiDajÞ+u[m¦ñ´®6|iÿ7óñð=ŒðÙè^}“ó¨ßÏ¡* okéqÁOîñÝO||~I^I,›êææ#Í=pX ÷Aa¬Ô"ŒÕA†Æ ôL4ìÇ2éX¶ý¿³8G‚7ð ¾Ã›o’wYĤ”º¼”—r ¯Öˆ8CŒ¯B)yߘgý4˜ÿOôºu›´Þ?A7¸¶ah¿Éá|8gq;*ëõíûêÃæƒº¹ýXÝȾ@%Y­«+õO_ó+?o!ž|xõ‘²üÕþñáê¦Ú¬± àÑz³á•=\ü~ñ_ «Äendstream endobj 4817 0 obj<>/XObject<<>>>>>>endobj 4818 0 obj<>stream x½WÛn7}÷W ]ÇÖZ_R}pݨ¶i* } P»”ĆKnHndµ?ß3äîÊ’óм¹ ‘†3gΜ¹øÓÙˆ†ø5¢É-ÿ.ª³çgÃ|ˆû¿Ü†®fCz•Oh¾¦ñn¿å··w4/£ÕæE¶ÈJ¹®EñQl$M壨j-Ïç i0‚E™-²iãñma«ÊšV¾¦©ß© M×k~TèÅùâ¼}…@ñUžç´•º–Žœm‚2ÒÓÚ:BFÿ$êÚÙÚ)€n{s÷Ôø®éîµ–gi6{“Ó¯vB{{™œ%°ì[yŽ}5»iÙÉH:g´MûEG[–Ó¬¥ø­E'h+JŽ Œ 䛺¶ŽéT†.‰³9DŒ‰°&MÍtËÏ’é³Íf¥O¥*£6Ð(D?3®™pm] €ž®p$èáɘÁ7]úo{N¸>œ²Ã‰u<•8À¨ ɨ;“WĤ“‘­™g¤äi%µÝM»—‡<óÉã¸Ì¾Iq¹Jï:rO4ùa FVÒ‘UaŽS{¸¸ˆ‰\âãB7Q ’: ] ÅÅÅqŒü×BÀÓÄ}ïQ'}£Ù5*äÄÿåU VÐ W¾‚(v"Д 懥и˜Aì©ÓϺcÂltÇ)×Èó¿¯VsQÎ>z…8ѶÆao]æÇ0ÝÒlX;[E kÕ×j婈ƒ§¯Ö“IwÙ·²D»3 Ä!ÁažbxxóuË9OOTª›e¥½ ˜½mg/ÕÆô@Â'Íf{Ä4ŒÁÝfæOS SƒµÂXƒÛRyÿ åN¦2¶ÀzJâßq··è˜ìãY¶Ú?Éz`lÁÁ™lî œiè-\P‰ œ$óΰ>I¨Œi(­ù–oÔh¬˜–Qd˜©üyj„.ö¼QzEN;鸚"\5†%YÊB‹$OXòÝg¥çFÊò˜8‹4b½öÝ,à3‡ŠÆ[©¿7kpÔH_q_Ä>oç V‰  %bRTœ9ú­TN ¾?1[uó¦ÞÊ––5ã¸B ÏŽpXô:åe¡ÄÁŽÞå ;nO^ñÙÜ™ÃnÏ«W`ص[5ì©ÜÔ<ìںġÇ˾kŽ0^&a;ûÒäi—EåóýÒï"¾ªIÛ›3’ÙÀ¹âŸܯÿ|÷Ûû9ÓE÷o—Ë%ÓËe¼8‡¸˜øD¦—¨é·ýÓ•k‘F øP·ùöp´8Ò÷Ï “#öCl—þ —_²e4Égç§ûñ‚˜CöußòŠKpÊò$=ÅÈy.²”Wôs5{Õ®ûÑ«ëüfrC·w=©ÌÇ`œé'[ÄÖŠòä$±©“õà.ÁÝå£|DïÛ]Ç/Ùîfx›OÆHHÇ“kþèõüì÷³C–Pendstream endobj 4819 0 obj<>/XObject<<>>>>>>endobj 4820 0 obj<>stream xÍVÛnÛF}×W üD;&MJ–ì¨ÈƒíFE·qS-š\ÊÛP\eweY(òï=³¼H²äôòPÔ6D™;;sæÌ™ÙýÒI(ÆoB½ÿ¥óÎõ¸G1^¶fFg£˜.£sêÆ4xDƒÁ3oÓ8 ¨þ)Œ´ËÂѪ¾|w<þ½S˜À*k­ŒtKSRm¼oó•RáÒšQMŽéoy™ªt“ãø€›m_ëÿzÊÛßîÞ¶ÒÕÍít:ÍEê¦Ó_~}÷Ã4A`^(„™%ÃûÕ6ÕíC`CöòÂÒ.Ià¶&ÉoySØwêÌúEJjökHœÔ$¨Òhül¢pÍþï;‹'§ÀÃn¯–^pUf$fB•§ä$Íd)p2£BÙ¥:“ý¤Äªp¤e*Ï¥±”=§•i·¶­dI a¬*gtã Y1»Ú»Ý¨×C'x1Cµ¨*R']©Y¨Êp!ÒÏb&!¤ÉñäøQ&ó¹t:ƒÍ×鈎ö”ÑЭ’†ù²LÒ% …QnMÐeíµi-„ î®>üO­s é¥ÅÐ:ÃM‚¦Â@Ï[6›‡USV¶CÖí^ªÙ0Õå£4ŽÐw{( ‰­Àâ[ ҋ骃á=qy¦¢(¨ÝʦmˆŽÿ}É¿¢¯dÚ@€œIC5-ˆÿ°r+÷MØLÚ‡)ri…vPSJZX@WMØ[ï]‰¦RCÚʪû˜-oúÐ’[iò`7¥Êµ™[ܹõÒ¯E4f¿ £U8°‚ IúEÑÈ­Ë-¸ ‹ÝÄÊÑe¡E†9`ôÒ©RÚˆ®h®¤L:¡ ¬ÀujÔ·“Ϋ\r)p&!&â;M÷ˆ©—ª8WIVVÝ甃q6ê׃) QÝœ;à(ÈàìNnG @†À‰—•“fºí$9çÌ@±6ì…ó7¯^ñqUñ|Jk½¤•BÊ¥DJ y© O,šÜÁ{#pPøq'ŸÄ|QÈéʈE”>=Etœ¯÷¯ÊÏMž˜CËg$ªrÄSš8(i±€)sJÂÒJž¢\“† g»eÆ“Èn£‚Ô"¡d5®SR¹Oˆ}‚ôªâ•ÇW ;ÌÞc¸rxPýlQ! «[>Š­´®ŠBÎ ô¸bÍr“ðñ<¿Š3Α9gÎÈÅ“ ]ðѱ‡‰1î3\(«‰wsëËz6zM ›ã®v\àä"J¢.ÝèùœûáJ¥÷^’vW¼ã<ò¢ZT ÕE8#%m¢]ÈTå*Źå†È^’ö¿}Œq‹RŠ™ ´ õ.KŸ(G»”nn{sÑ¥C>/XObject<<>>>>/Annots 1861 0 R>>endobj 4822 0 obj<>stream xW]oÛ6}ϯ¸èÌAcÅ_±m°¦M——k äa Z¢m6銔¬Ýß¹¤(Ën’KGÉûyî¹×ŸúÔÃoŸ†cþK‹£^ÒÃþèóÇû·GýqrAçÃIÒ£‚F»ENŽZË‚Æû{­eAýÞ8™ÔRøb{Ý–¿ÛZcw:NÆí»“qÒ§Á`˜ aÑ ×ÇnXñÝö»Ã^2hïžš5v'XÕºÛZc÷b´/¹µ.hØ?o¬`½¯f­Øù–K:»êÑfΰ“Æ0u<¡Yæ#Ü£YÚ¡ïþ,LIn%)WvMVe’Ì¿PÚÉr!R™ÐÉìÓQºÐ1ËXd7Ý–bM]ú+“ Qåîoz+µ,…“$(Iïïi¡rI©ÑN(­ô’.‰¯¬eI‹J§NMÛ•Ôµä~”ܘëO‡‹©É`à 66&ѲV—‘²°ºP¹€2…ë'ÅfFKb—/_¾„y|x´«MôîÍý:W©rù¹ªÔÌ"*fû'ïjí˜ rƒTz/…5ZÌsy¨ q‘ü…ÂdU.-m•[±'kÄ­ñÓ&t)4iãh%t†-‘ç”Ë¥ÈIêªxF6Žsü­Ú…‡²J=%η¸ƒ¤lƒ-±ô ÿpsý–ÒÊ:S¨„OÏB x-mŒÐ.ûÊšœSÝ¥6Ú­ƒÔTvs…‹rYR»Ó`.#k%óvò-ÎHzp<{Æ ¥¨J«Ï•¤µHïØ\- ™yLvìV-“_B»üþW–Õ! q¨9_ Þ1¾à0 `öº”Êöë’'†¥/€ ¶FSw'£•@€ƒ'Ó ³‰W·óˆ¥Œ’˹æ’GLÒ2•ÖŠ%k %Í+Hc¹Ýl-ùL{¢äø…õÐÒØ$Ê3êð u#ï×çiÀȼRyÆf‹`¸—u˜YšÛ§ñÎGf‰@ŠKXÝIèãÂF嬙,+ -=˜ ¥™ö,•>d°óCôæÅJŠL–ÉêE8sÜ&JÎÞÆÓ%%¸cÞ·Î`eÙlvß×ý¢c ¹íØ…Û:þBI’x¾L:þ÷IÅ?EY»¶Ô ’áM*ë×%UÇ‘Ïr=ù©—¡ žðÇÃ~°awûñà4ûH¡—Á)~Ò·'?ï»pP¿e™bÍÖA° àD41¤¥Ì]$DŠƒ ±ÆGt×™|Gmàq£RŠ‘æÀðQÎê¾Q0lÐ`¡ú$¹‡5ÓfŠvçYº.Šþ4Ö9J ‘·Œûúx¯Ë5>­L ”Àž‡ºH¤©)=äá,x)GÜÖEiaª@¢Z®>oXDnw0ÅXÇâAkñäÈç&½;ð£àøy Zô5€òdW¦ti…ä#[ûÑè48¯ êEôo%û&xv óœHlè46 žn€€7Jn÷£Ë@%Ó)ÇþÜzF²LQ¾¹JšªD󤼽³ghîÕ¯„UéS Œ¾‹îÏÖÆ'.öt—­’yöZª’4 ðNJ\T[bìõâíÅ»’6&—eXU­¡0¤H†ÑíF8'‹5`°$++„Õ¼*1Q€ÍøË5¾ãHÜj|â1 ¨ÒL|f —wh¾`¾8ÜÑå^>/XObject<<>>>>>>endobj 4824 0 obj<>stream x•VQoÛ6~÷¯8( 4–bɉ“zÈC—ÖE€¬ë:Å-Q6WYTIÙŽ‡þøÝ‘”-ÇJ—ʆI™wÇ»ïŽßñ[/‚~"Žè›®z¿N{ƒp€îÔ.&¸ ‡0Í!ÀèMŽF×0͌Ԧ©îIì³±ÃÙôŸÞ‚E²Fä{#jG|ù¹T\,JÐ"ã³³n­/ŠUWÊŒjñÇš«¼;¶vICÊŠB” ¸;?‡N+Î=7 •|]¦µ¥Vf°âõRf:ìÒmÜþ~²„ø ðsn~é º¸ŸBèê‡àÀdrl‡øó ·Pð /À¨Š±ÊYÊCÈóqÆóÀ!bý“ˆÈÈ)TÇš¦›¼Kùy¬šσÊÆlªT UUˆ”ZáSSº êT}˜¯kã³-Q¼†˜ró_å92Γ"ô!Šc¯ÞpÌö lÃDaìSþ©°‚B¹(¸îÓ¦ºâ©Èw˜b§ö+ßm¥jÑè¥\X½ÜI ¬B²Å`û•ûÂ5ˆÒ ŠÍi°~†bÜàîHIÄápˆ7¦Ìµ’Ùƒ?DEËæJä"Åì× V'®xo½R^Ÿšsbþõjov†NÉ_šØ_bAñ‚#›$KΪ[o\â•@y}YÕb%þå Æ˜ •¥Ü™Ÿ3Õ˜·âÅöĶ+œF}p³xvÖˆÚë]‡hºdx[’ÖèF Äš©™of¯©Ó&yy0hÅŒöëÇÇǙdilØÐØG@ÚdÕ”O3t” „+(„â+[p<޳³ý=Ôzã„ØlOG‘ñÀ{{÷€tŽó$!îKŒ‰ò`Ü48&Dâ(ytõùŸÞ~þmä ›Dx,Æc;œ(¡éDI?¯s¢5óÇÊ 1#¾P¾N„`L5ØšƒÚÖõ;˜ÑÍex5¼‚ÑÍ0ŒlmSÀAàLÍÁ©a†¬tpmëðNwáC=è _ Fá0ÆFƒÇ%^Ó_ï§½?zÿQ‡…2endstream endobj 4825 0 obj<>/XObject<<>>>>>>endobj 4826 0 obj<>stream x½Wko7üî_±0PT.tж’¨( ·‰ }¤­€| PObsG^Iždõ×w–÷°tRŠh ÎéD.wgfg™?¯F4Äψ&Sþ•ùÕwó«á`ˆ—í·¡Cz5˜Ð<¥ñ¦¯Gƒéô%Í×qÕæ²GD3œ6ŸHkvÊ2:[ÜÜÌÿ¸R2ª5V-z™ ø»èýþþñ‡¥p›!½»ÿí§á2-n>aù(.-ÓñÅå~¯7Iš&Rd=Ñ<Å3Ž6¢¤µèÅmk•æ*líù]§Ö^Óõý÷?.—Kœ0ß28p{ ñ}ò¥Ü’ðT”YµzOŒ&Viãƒ0Þg6xBxð„CçT^X'Üh ù¡ù pýRÂÄØiÁ´UØ4tó,LàÌSÔ@6pÈEÁ‰¨Õ0ÄÒÉP!¼Ç)¹è–7x¸D'`æâ@VÊÝ£RÕJµ*SgsÒ‘¾6±v2JahÕ £‘8¸.©+á  }¬˜êýe5ÝÑ/Ÿ¬¤Gk–0NæçH‚M€Léý7ÊÊÇaÛì;ø5öFBJåý·§ ¹ì}fý^‡mp‘N¯ ˆD€;PõÁT.ª¼LÐ@>=5Òë#àÍíº¦‘§¦ÀLà›,2K¸Ûëg44çe`7NWöÛã«kÊi(®©=ñ¥J‰±’;€øîƒ†B%z«ßU,´Ôl>E¤Ç«WgvÛuM.Ý<)|U7¬¯)@òˆ,°È›ã«J6™]£(,¯ØgŽiùHbÕ@ìæ»D±«ÌˆýžumxèÞ¿{Œ±p>ìM‘ùz"ÔüÕ“üU}Óow“;šÞa’ópæÿ%ãÁÞXnœ‘œ .6ÕÚäeuoŠÃBô>›‹~q7œ&cÜm>/XObject<<>>>>>>endobj 4828 0 obj<>stream x}VÛnÛF}÷W T¥‘ÖÅ‘õÉuj#@Ú´€¼VäRÚ”Üew—¶…¢ÿÞ3»¤.ŽRX°Mî\Μ93«¿/F4Äψ&SþäõÅÏ‹‹a6ÄËý/»¡«ûw4Ó¢„ít6£E·´È“ÑM6ÎnèÓú«Ì=}±¢i”Þ\.¾^\Ý_Ó6앎¯³kø%·UEÚè´±ªV^=Jò»F:Z&w•pNº7ä¼msZ­ŒÆ_¡‹`UÈÒ‘Ò¦zD r¢–ËKÚ ”k¥kŒ.ø¬4VªN98ÁOiYÑä·’¡×S$•r 9UHzT‚ÊrÛôØ9ëÌÇÿ‹^XIekÝ’• €Hí‘q½²»Ÿ>SÎÕ½¡ÜJÁœ ©ÂÛŒn5 ïeÝxRŽj8Þt¶ 9”Cœ ß*i…Í·»7ô¤ü–È !A¨Ò†AF¡,zSíÈX¼Þ?•ÖÔ\r_nc@ÛŒîc%Šò5© ­E¡Ú£#HÔ™»DVúÖ2×1xìzƒŠ˜£'–N ޼(í¼Ð¹$S†Jqn Ä–b)€Ø/:“€ƒ½ð±ýk)õ ޾å Q>7¬LAûBEQ Cðgqd›¶uk'O9Ê…¦JnrGkI Ë´ˆ¢Dk:¸aÜ©»×¯O€˜8¢õ¦^1ð y+rè £ÅÇG NTTB!-¸!·òZó£ëõ ‘éÜc*À ZUŠ\† ‡m‡ ³9Ù$½—^¨*ôëåh†™N>ð|‹_!‡ƒF]nÕõnÍJ·(¡­„¥»+TŠÆ¢}aZC{Q•vU8ðâé:àëH:žòä1¶lD¿aˆ]ƒ:Îâ CljôÞìl¢<ƈò—Ø@ú˜ºÏ_><0¹’*³«ûq‚ Pô^Á ,ºÈ¼ºÇ^ì·W\¯jS´UwÚﶤ/^e*kàÔ=Iϻ妮±ÙÒ »i/Áýð³>%m¤Æ¬w;åL÷¤6)Tß‘!ô÷ë®õªR~w¯Ö  ë˜Ö‚µ }uÒÃ,8ÒÒqâ…h;\X#q:峨›JÎ9ë8,{îpiL¦Â;ær)vWÁ8›LðP$¡P·aWöãxÿO÷È (’”Ϋ+dÀ!·ƒ“ÃWÿžºž·q*€„O“Q–õÛ>æÅ«ƒ‡ÇußúÀR§Â¬œ©%ÆGo– ¿ÑËËŸN€Â²‡ǧÃ$ríéd’M§7\ôC×p^s¸\LU™'^æ¼KÌS¢óŠ“2›{¦—ÉA¼{¾ûB—ɼſ›³(q;‡kqΚ‚qIsùœWËËåå Õº"»Ëä…q©raGž1ßw-ih>öˆ±¿“Ká‹Dœú>×™/s¶š;6 ÁíÝǰ®BþÕêøtµâm²hnŒy¿„÷|X\&¿ßþùëp¥‰æ¬‚oJ'äžÇ[’»‰‡höR*sìU¸4ÌšõäÏd«$2$Ë$àÃ-6¤.ûÙ´¡;e™òäŠ]Ø4†¾ºŸuo4»ÎÞNÞÒôwÊ(Œ*§HÇÙÞ›<\–¸ÌŒfÔÐm´No"ßÿFøv8Í&c|„¾Ç“wìýËââ‹ÿçò=Üendstream endobj 4829 0 obj<>/XObject<<>>>>>>endobj 4830 0 obj<>stream xXkoÛ6ýž_q‘b¨“ØŠ-;®Ø€4MÒm²­Ùº Z¢m¶’è‰Rœûñ;—¤äH©Š¡i‘úAÞç¹çõŸ­ ñgDãCþ¥[¯n¶†ÁÖ¿òíŸOh4¤›9ξÀ‹Ø~Qïf)IÌô$•2Ÿ‹HÒ\%’ÖºLbŠDi$­DôU,¤¡¹Ö}þD"ï“ÈâêMP¨ßšf’¢\ŠBÆ]g•¹ÂÙ¾æeJg´ÎÅj%ó›/[CŒBDÕ›ëœbýÙèTK•-(–¸(cÄæ.;ÏÞ™jÚÛîÞN8a;Ó¿Ý??ði÷vÝûª ½éÝGrU þÜšöÆ()üÍ쇩ŽËD"Ñ$±_œ’ëb N#kNMÅ2+Ô\É|éìNæ¨ç ÎW2EޤL#åµ*–$ÈŇVÚ6õ~.V²3éù“c­ ªu6 Ë‚ú°¾è_EAÑ¿ªúy!3™£OöP, “yHg:AÆQ¤Kdƒp…"Á(Èå\æ2‹¤é7rq¬¸§ÂV‰ïD%Î,¢f_®´u'Š ¢Ð°4<8jÎ#˜“¼),÷­“¨ÌÑ™º®Ü{g¿†”ŸZ7;-ßv’tI¢(dŠ©<¸°‚"¦:$ʬ6à1eÌZïŸWêH§==ŸöFÒxºÓòe±þ‚x䙑á!Ïìè(!êÌ"+¼õjbùØ$°Ã]ŸJ :%ÅzdÒU®Ñgƒ=süA©ˆrͰ°kæ'ôÞºlJ1&\uÇ€aWY””1<ŒØ72gô岉%‹ U`h2fÃX‚RKcÅÐZØ`Ÿ”eqÊ¡“Ûo”(ÜÁ8݉¤”}à‚Ûׯ†Rä"3 s,£P3\«$i“bÙ¦ö‰7Δ÷kmê=ž?µÕaêÕ6=›N#73OlÒ«§–ˆ:l~×ÖkC¶íuØzƒavvF!~Ú¶º;Û¶Ç;l£ÆefÀ¹ÜÓo¡eØŒe½¹â \’_p¬¡ çÍ€:R»°©…ó®ÜÞ` tÓ¿ëŠf#µŒ­ñ88<ñš´"(k.<;ÛPS‘°¤` ¤¥çêŠO:ëÁýòl ²¹ºç² <~…+N‹Ñ¬4“Xï–6RìK®Ÿåä\9õ UÁÕÌÕbY4*æô(ï] qø±Æe#üuªÑ]¬MÓýãA’±“uMl³ w«õÀj ëa#~Ñâu®³zÙe-rÛ€µ‚,Å꨻h{þØÅ¦E(±;üx‹ñÑÍe-—/}W]ÿ2/é„öè¬=(Cw¹)ßËòlOw:¨à-þ}Ê*]´ò–m&z¡Ðî´z‹o÷ LviŒ'Uđ޲ÕÝ*ZÐ<Ç=¦ ›ïûv„CÖŽóUë‡7DWè·£ð"]äÁáìÖyt¥:'Yær zù’>þq}uQA¬Á¥·c› üàžÍ¾¾›ËøÇ<}òmø¶ìÒ·¦#ŸO 6í 6)Ñ7¦‘U''ÿidîÙH”Ì2ŽNÒ à¯™^óÀ*Vi^”bÜ0ã’¥•oŸ@¸€9Ü«$‡û¸Ò±=¦†´¥®¾+‰Çô—WKÝ’˜ ûÔi203 H(ÂGŠ=:¨ÕVÄϱ`•ÍÌ3ay Â\$zfE§Sg¦¹>òƒ‘Õ}Ìþ§{{HÅ2†Æ¬¿ÊK'•éLæµÆG¢ Xm•ftÿV l×Üj]·Ã° Qå v{©4- ^›}hÆ–ip¦L­û¯¦äýãŸw<ƒ±‚- –Â]2ŸQ·>ÒJw¬‹[+íÃΘ`éz|ìŸÞGÇ“à`|@‡G“à˜w?ïæA 鵎JfV»ÒøD‚;;8rºÑ>èªz®·=?ãJ°N†|ñìfë÷­ÿ‘­r'endstream endobj 4831 0 obj<>/XObject<<>>>>>>endobj 4832 0 obj<>stream xµVÛnã6}ÏW òR)²•8Y/Z M7‹v‹^Ü–(›ŠrEÚ‰[ôß{†””Øq 4@aC°©¹™93üãhH >CJÇüÍ«£ï§GIœà°4 :»Mè*NiZÒ(¡ñÛa<_Ò´ðR Mó•´+‘K2ÆÐ_'Ó¯G EC¼+DÊ8Êkc-t=z¶ }K£w{r¥®E™…Ÿ‰“]©¿YçìöœØxIŠÒ´ hðAÙ' ø+ä„eY`tÎÀ«s ôˆ"~?ŠÓøŠA6°÷j)ÍXHÊÇÀtœd';á¶’…,׆…¡Óñõͧ´f³ÇÓÙBºÙì×/?Ì’cš¸íJÒgN6{– æ&›Z‡ÎéÖQfÁBœØgB4±®€ól¹g2mðeåBë'ØR_²CØBIö±…Ó™=€ g‡±eƒŸ®ùœøÜ´…¦I(ø“HºæÌÌœ˜×‚ÖùB}D³Hh?’ƒø–hsE½.‹ö‰}eÞþ‡žè¹Ó¬D¯ïŠÉöcí$ mëSrK÷~)¬VZåb®å)… û‡²±$ð^U+-+i˜¤Â²HI•t˺°TX’XA VîTmNiÕÔUpÓ ÒÊ®¶¸s,MÉÃÇÕ^¿¬©ÆÏ€xî~ôt_[Ù|‡–Àà)¨¥0ÆD\h Æw^<'ÞÑmk–…9–ÀíVÜûégžÛQ}ÉK~ÀɧÖx>ɲJÝIe¶ÉñÀXÊ2'­Ë²GÇašý«ÛHzMÝÿ‰1ª&“ð—góòÑ2½o"N^6â[à`8-JãdÏ"N^¶xYgjG©5rvû–†h¥n\tëdx§ñ9½7ëŠ× zѲþ##ünºð£¡›S†ä£4m„^£åÑù†· \È&œ‚-Jã´Þ¼yQÉ¢råô–(sbqŸ?3Ø󔘯±q!Â줹¤BY‡–]+»íæ[Rîë#%^D1÷6I‘/ÃY!s-`0+.j)ùµ<‹nѲµ ‚¹ËèIì}±ÖXC¼òê’xmÅô¨g©[Å×5î¬Ý1·ek–6Jø±K!ù¸°€‘% Xª«½š :*†­ÏÅ 9óGÐ\ÁY£ò;…j`Á1Ò‹l!QÊ(§„V"Mkë'ŽÙ²:–ÎÍ—J>¬ ȵ‰‰kN÷Ê-}ð‘©su(UU SDZ¹“‰zæÙ½¤%¸’ ˜!XiÁKëGdß/}H¾³”¾èóÊã/W—ä¯âÇ“ZúŒiºDÕ–ÂçŠç…oö.Š 4ù¦ƒÒ 3¦vH#72PÑl¹ß0‚}zð³+R¸ðáû¹QrÓß;´1}YJÓÅéIqþðÐ-*ÑþhžüT˜°­Š&[ë5§‹é#Áƒz+‹˜®{TŠ× ¿Ïéo} cªêb­åŒ‹á}¶¾7Ae9yÚн¾ÁTh±«¶ÅFÉy|‘^Ðø* ,çíáRJ?Ô9†Ç!²n¢A6º W?d½÷Ó£Ÿþw”Úendstream endobj 4833 0 obj<>/XObject<<>>>>>>endobj 4834 0 obj<>stream xµV[ÚF~çWч²*öØ„ª› D‘¶¡Ý¥HhaR{†ŒÇË¢ªÿ½çŒmn»PVQB3ç;·ï\¾5:à§QŸ¾7!¸à¢‹K¦­Ÿà¿B’*Æz2®p¦­é œƒZ¾éL¯.P@?¿UÿŸ0âé¯GÁÁd]ÊqS|õÄÓÖ—@ß„ˆÎ*pêÏGgW–G¼¼U1¬—BÕt¤¢bàó§' ®®„yNÏýCWÎ’tøço㇠86PeÃíÝýløéó¯³Ù ¹7›ýñåã‡Y€•„'WØAæ_ W¶˜}´}"œûî–âœ)›À¾ö}&Ö^Vî¡Õ`XðG`[f½ {ËØ–i'À®Go¡Ò>/XObject<<>>>>>>endobj 4836 0 obj<>stream xVkO£@ýÞ_qƒ ¶ºÝ쇶¶ÆÄ×úÈ>¬!#\(+…î@uñ¿ï¡E@ÔiÓÐË™3wΜ{gþ´L0èc‚Ý_wÖ\´ Ý `ñÃØ·Á4àÂ'l÷3=xò==¸ê£ä¸ÉlÎqŠqÞ!à_6›G¸é4¹ã€ñbvƒ" XÃíáæ&0ÎÙxèFŒ³,LbâŠ= QMñÞ#dœÅiÄ2ô Œ³dýâwËÍ´(ÕO8†A¬es„tŽnè‡î’(Œ#qÓè(L用‡ºà°ˆÄj ™„>Áí±»º/W³,ݶ駮yè‡1ÂQÿ‡3¸;ç¿F$‹Õ^fCd„ŠÙ Ó9sÆ''ð¸ÊT¾‘<QrÃ"çŽqóÊ´¯¿Ô ~”°2Ⱥ*OXÀóÙž*s# ÓÓ3x„³Ñ|¥ü¶`ÿl4:¦g‹ž‡—£-8½<;=Q¨C¡áÏþ1<­Ò¨¯bÐ'²ZŠî”ñÒ2ìJ†° f‘¥p§ÔÕ® ¹nÒ!¥=¥ #÷ð²ÊHšì ur½…*BíΕâEnbOV˜î•P£€äbÀRÓh'U)†ä+–ûò\6i¶­w»;Bý¥ÓžV¼+›ÐDô5NÔ0ÖÈ_·,@XÓ7Òû0Ðf‰·ˆPÞÛ˜¬W<1Q%‚¼»4Q²¦2Y/yÎHÚþ22d‰,%2Qß Ó*ªHƒ*Ð#Ý_Í€¶ r°Jx茎/Ç¡€ãœ?Øw /ë½çR¿ÈØ{Trç«d2ôA:QEU6ù Y^ŒUº<öABaá*ˆ¼Oö_›[‘«VúƒR.DE6Ææí­Ø¦nÅ:ý"òk©e.FvœRØ 0{±BŠeÈkYöî’ÐkŠsÌ<§9ZÝXš^@¡—fœ`©Fë¿CêPu/‹ifìµPú“΃O¾ß[U«jI­òó¹—·pqÞMÖI"­U‹'UËêI‰?*\„™ÜYëŒFé´±ç.«Ű×õ«˜ðcSƒSÊ­p{¼»¼™»m½cw »Kw†ü¢ ¦×,Ý€½Ä]Ì0ÎäeDte:r´¶“Ëfîè¶Þ¾¸¥Ñ1ººmÑ=‹Ž «m‹Ðè¢õ­õÓNendstream endobj 4837 0 obj<>/XObject<<>>>>>>endobj 4838 0 obj<>stream xÍ–oš@Æßó)¦ø¢ØùwÇ;Ïêå’K/õlš&$d Òâr]V?|gñD®G“ž©µÑ3™Ù>ì3ß L|Y`{ò/•«¹b&›žÁ`jÂ…aÃ<…¡ Þ¥exžó¤Î2ak¡VýÈ3=¡éŠA¨©YQ~!E´&ÜVAo£«Ñ,ŠZᨢ"Šî?Ý\G¦ Ø>/XObject<<>>>>/Annots 1863 0 R>>endobj 4840 0 obj<>stream x…WMsÛ6½ûW쥥±hKþˆ“:©Ó¤žI§ÓZ3î!ˆ„$8$Á µÓÿÞ· ‚%w:ñÄ2,ï½}»üódFçø7£‹kþÉ«“óìOø¿ÿ÷û'~BóËyvM]]ö”tòãbo½lrk:ûø†fç´X!ðõ|($>ä“Ùëì"»Îftûù×{zrªiL½&»z¹x<9ûxÙoœÎ/±qr[*ïµ?¥¶6¶ÆoUäƒkóàI9Mª,)8­‚.(l4yUizR;ZîäoSíV*×´Öµv*X—ÑGëh‡cy×d—ž ½š®¬Óf]OîќØ9MgsN‡O—%9çEXWI]l]ÄØz«ÝŽVmd3T §Cëj$]w§Ñ— Òh¬dxæôJ;]çúËKNëöìöÕ+âó)":ÒÉc¤&§rÍ„ä([\¥­ã1øXé°±‡çŒ4}6¾!o Àe¢jƒ­T09Ý 3²ªË¯K ›š¯`j²í $ðèlã x Á&£ÅÆøQ:•úª=™@U›oH+o´£`q–Á.†¶ÐËvM¹ENÀ §¬>žž5¬PàlËLMzl«e)y0k„ܪ²Õ>‹8 RìÕ)pxWo4Žç«ŒqåQ @%b”û|£+•Ä„\ŽtVç¬ó‚žÂ'¤$ ãP³|XfráS°6¼i„Ùjõ6‰11ó€¢ JÀY2zf•al§ˆ4 â hŠ$±¦RÀZm•)£Ø]&%–Ž-ÆQ§ü­B÷€¡D„HXkÄ F¤°|” ï°-º0<Ò—6LÅø§ßE˜ÑÏö‰›qä¿¿STZG» W‡àƒöfôÁ¬¤‡^È«xl=ð¾Q"]Ü¥âÞ„îºïúb{H“ «¼q˜8ºÖ¹5.´ªL$¿õÜ=³ùKÛ7$;ôètn7ÊDåÎb.IE„œ¹q–%¬ŸÁ¸oËpÊ=·†˜m;.µ¸6ê} Ó{ó ®AQ¬h¾OÕD ÇšNóÀfŸ¯¼¯qò;¨|È‹·iu D8»dœŠ|pxÌb<\Nç×<”IGM ¤U‚½ÎÍGµ™É0bøüGA.¿tŠ âÔã0G©m‹ÉÉÃmšÆº ÍµÐª”ÒÈS˜xQ4VÔ¯JèKa4ÊùA%|))"å9Æw?ß" ƒÝaÄt<®˜ËlÌ,âsQÜTk&Þr§E‹3Ü(´BrC<œ™é°¿Š#+§°µ¦Ž\ÑßøAÞ’û÷Þñë† ïÞÔ“ÁhÊeøíý°crNwɹ÷ìïeÑ›Y¿ýaƒN€ `0áb‰Ì?SzÀ Ä×<®ì}™¨Â—bÏÇ1ƒ«©ó²•Q—¹Ièô<â&ûÅ#/#2¶M£JÏÆ -ÐY ¾Ó#~Ïsßïj[ï*ù¾+šD ‹bŠ/#Ñ4ø‹MŸFþShÈE擊­£ÆDÆöe}±ÈkYd# cÂ( šˆv# %{6(ÁØ|Óâ\^cÚõ†M ]l„hÉ^‚s[¯Ð3l;ç1rJKͳ»Õëd,õ[0ï•á#&>Û¤do²‹ä6óìâ“8‚¿§¿enÀf~7+&Dà,зw)©ý§»ñÓÒŸ8[ pDïñnj嫳7Ý+ßìæ2»º¸¢ë›«làÎñ*þÁæ2QãÅ-ª}:?«§¯cRÝûÎóoÜWç×ÙÅVŠæ—Wœ÷O‹“ßNþû,endstream endobj 4841 0 obj<>/XObject<<>>>>>>endobj 4842 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ç/àÃÀÐ;>?žïŽ®ÏŸ_.&§Ñ,:‹&ô!ÓÚrÑ!{Äå#Ú9h’iå°ûo ë˜T¹Ó}³²ùÄ(ˆ¯©0ÅAãå>«ùav͆]°a”O+>×p²Ó£ ý-u»O[XaàœîÇàÌ®'g!§ˆ×uT<ÅÙ ‘¿zzêƃ[V,ˆ"†"Çx–¬‰˜ø\%ªÎwàÈiY+œIé{?íêöS°Ðõ?ý¯QôT‚áGѤ‹õìØe-$â†õÑ‚-¯Ê@|–2ÑsïÉ/úÔÎËíYtŽÏ9Ó“ë¾sºÛmØZÑ(£/€®yQC…¤7»©rÝ9Iç ¥æJƒ-—Pæ°ž0/UÙ®Ž­ 6Ðò6‡›éÊ~ç £ÌÁ¼ÑgÇ3²rú˜ŸA1‰:å K2o \•œ¾gЩÚOFY¦£&N<à¶ BìÐXwp~Å‘=YºÃìóÔ²ÅZ‡@ ürÕȘ[3›ª2ÂíÛ—¯ˆ™të=¿ux0{2j:[„0‰ B¸@v[¿CÕRnŠ%¬ ëBQ×ã' 3R7G6iß`…Å$Aë¹Ï nßI5òsD—o~{(×h¼7˜]{`«¹oÁpøJcÝ‚ö"Ü |~»¹ºüNâT÷qç †¢¬‘ã@5“³“èÍì ÞWO|£Þ~ýôq8Æô»NÜë“kL†‡õÇŸžz‘õÔL Œ'*xL‹†q0«Ì9· !ò÷– ¼Ï£ÙÔÛôĉÇÕâàƒ„Äêendstream endobj 4843 0 obj<>/XObject<<>>>>>>endobj 4844 0 obj<>stream xÝU[“@~ï¯8´–áÖ›n4©ëÖ˜˜¸*‰> CC¡t—Æô¿{Î p[V}1mJ9—ï\¾3g¾,0ñc3£o¸¼v&3Qxú0V&,˜n ¶ ³…Åf³9¸‘´2Á µ0 Š–ðcè~˜ [(4Øí×i¾è !ÉJ¨®Î}á±yÅ ˆ§y€ŽUåi„Œ¼Ó^€1ÁË½È T02z1:þK%YQÖÊ»ë_Á3Xê¯êÇ¡F2V ÂbÐ1#Ýqê6hׂ%/ ¼ãçiš?$Ùßçð ‚ÝŽ‹bŒ<ï ¥å./ŠdrÄf¿åXR˜o×I”Iž”:E±'T{~Ï–ùǪ"u‡2´™ã G‘vóõöÃ'îó$‚åõ{ß÷#žò’ûKßÿüåÝ[ßOäØò†¿’†D%é°µÒmLè“F”7™H˜F[ÚRÎ “ŸÊFº7nŠaR! Jl’§1Æ:Éu,z¬ë7GÎH]º¢ZÕŽÓ)›&G&¬¸§¿v'J›¾‚H/öi)!%Þ°íDkL¨²M=Tö©­J…PǶÌßw—ò®{o7¾-òåÞ?®G( 6&L< uCÛLˆ–¶ý|Û˜dU¿Ú¸Ajm.‘ÛZtP>/XObject<<>>>>>>endobj 4846 0 obj<>stream xÕVmoÚ0þί8Ñ/aZ‚íÐ@ÙV½0MÚ¤nCÚ—H‘•8ÔSêt±YASÿûÎ †Ò@é4MÓ(¢NüÜÝ“»ósùÞ¡@ðBÙozÕy5ë€àÍÍO5‡þ”À(a–#Ñ Š†0ËjYê~¤2À«9ƒg½Ù·ŸâVVoåEÉ TB/ ãvÑÓz(¼€Âþw»[ÛÚe³ËÚ»¦ZÁÏVȵ~@ì3kÖqïhZ£‘÷^t×8þ€ƒæW×…€FB…Ö¨«µŠîNÐ;béDõãjarô{JÜ$G`3HOžO@ÉN–!;cÑ^â’‘(Í#ÊÎwÎgËkìMP 9v %÷'%ÇMWµ)»oÊ›¢ÈÃ}ÕÀwŠƒ¡,>l“ ÙðV” Ã[Ó%dM,áþt´ž·t4NÃSˆ†7í¬øúhoÊtq%”áv˜Z3Î Ú6=O‡AœÁt=‹ÁU gJÿ‚WÇ%6(ÎMޝIxÓ:9%Q2|GÃÁÊ#{ëí¬ó©ó åŸZendstream endobj 4847 0 obj<>/XObject<<>>>>>>endobj 4848 0 obj<>stream x¥—mo›0ÇßçS\5µ¢I!Ò6íÒ¼ØC§½š¦Eꛨˆ‚¡L`§ÚMªöÙg7À –/U—')Àïþwgßq<ŒfàŠ÷ ü3ù‰ŠÑ‡õÈu\q°ûá)L¯/`æÁ:מ-°Ž_λ°Ž¬Ù¹ã;3¾m +Æá‰‡ÛmFSiüï({$bE6¥bàU ¼çöQâŽð 7à(ú¶y6dRÓ¨Ã{d7PiAKFÌõ½°´‹yz½hfüÙbîœú§ò¹Ä9ßé?n¾~±=Ç…O,ª B+ñ´À¨œšmÏÝ]mŸï:ÀÛž^NÝ3Ç÷ÄØ½ù…´üy=ú>ú $^Ïðendstream endobj 4849 0 obj<>/XObject<<>>>>>>endobj 4850 0 obj<>stream xVÛnÛF}×W R¸ kE‰–츑„ÆE^ZQÛ‡ªVäPÚ‚â*»K]äß;³äJ¦,hmÃÀ’³3sÎ\¿túÓo’ÿ¥ëÎdÚ‰ELÿÌzO1Ü‹¦9 b½ë‹Ñ覙·ŠašFWK¹ÆY4ŸKƒù|>»†g?oôtÚüõ÷O×Ó:½§[èÓպ䲛$ËèWrkY. U.A§ie,èdQ€­ÒÔ‘2P–Nå ½«Á­¤ƒ‘ œ ,±ä˜˜ÁâuPÂêƒF“SFãv>ìÅZà‹+óù¿Ìçgæ7|&ý1)âüâû´ÖvµérZv#S|<÷+i)&Ð,ÃLÀï–€XëLå‡!Ã\V…óéÂÍ™¨3xM=ÎR…LLÚ¢U¶ò&ïÊ€Þ• äª@+š÷ƒ[Æõ[S>Ð[4…–>h*KæI¦+…Ûšæ&¼*)Ž.)Eié "Ôu¥£çtî[k«\…Þ1*ÜËõ¦À6Å<Ÿ0e™U’Çr+Òan¥³` `JñíN½¤ ÷ËìUª8JÅœf²0B Ýæò”„çû»&QoÂM±ªãçªËF‘$4eY~ 5¢¦Í"ØT‹B¥í‡TI{?TÜ…µ¥x8¸Ðº€0ˆãñ,š@J5r?‚¦êšYl_ûæ¯Î«¬©»R}ä5vU %Xi€‘/B{õµ…óU¦E•!¼Ï­3(×—_¿9¹«7-›«oß àÉ™43~¤Þ*"èÆóéÉýìºåµ&@¯GÆ4¼®ÕÜu*ž öÅë Û*Õ„k¹6Ørí=7$ P.Lf¨5EB@¦Áº*ÏùÐr`×öç,^/×”¢š¸3°—Ò3YïÊYÄÝy$îô×lZè¡k¡Ù9)éÍäVIšzK»‚‰Ÿñ”2c™¢=ëH.ÂvñSÓ²gwjšG Ú7]û>ìgõ.UÑb÷õ«É¸É.{Oï€U$hâ0hbÿN$¢ß‡?¤‘fikÛ Ÿ~»¿¤é½’ b¢ÀrÉûÐ,«5©$Ê:KG„R;’ÑÍFÒÅFQhûæµÀÊ#g¼ú°LuU:4l.a'MÉ›ÙkäI`‰uë24æØy^ ›„}äcT_4®Ñç??þòB¸¶—0F'åâEÎ{?(è…ƒ®¸övƒ)«¥¤2’2(‡´ÕZ<Àn¥¨/@Mä}óM0ˆoÅ0Âè“óëD ?ëÔó(y|ù}³Ô¶Ý»z¨.ThD2 ¯+ÚeƒaÌ×>L;Ÿ:ÿÊÅendstream endobj 4851 0 obj<>/XObject<<>>>>/Annots 1866 0 R>>endobj 4852 0 obj<>stream x…W]³Ó6}¿¿bèÔߨù¸¡ÐÎPàRf†–;å%/Š­$.²e$;!ÓéïYÉrâ\€ þV»gÏž]¹Jh‚¿ Mü/+¯&ñOø'៿Þ\%É"žÑb>'TR2ŸÄËîNÑÇ«ó{¼]&ñâüíÙ}Ii:ì½]ÆOi–Ìð‹­é$žwwlø÷û3_œCfK7w3J&t¿Ó‹§¸È¯¸È¢µ¤¢²Ò42ÇE£©ÙI:Q×ÒàÕJd’ôÆ=ß Sˆµ’¤dµmv$̶-eÕ`a^d¢Ñ&¦–DEò«(k%G”éÊ9l±ÝM[eM¡+º¾ÿçêæh9¯¢ÚàèÍ*Z]ûÁÝ(æû “NGo›Ÿ-å2SÂgæ [•û* K­”>Ø_º]éŒw}”Òî^Õ–¬ô^tŽ\$€E‡@ß µÎrŸìpDµÑ{„iCà–`|§—‘þš³sJKD0C*Z+ó ¥áå¡Â°™q´dÛl×£iÃnŸ¶Üvs÷äð9§ "¹§1ž½|ò„^ÍdÍ^x¬Óˆ‹å¯Îàµ'6dªåíD•+NªÆÙ Ö‰êˆÐƒMà-*Å‘cjvF*:ì ŒÚh#‹mfä2¦û]ai'Um¡Ü3™lÁÔÍnHc´AŽ.és¡g’I…-…% [s2i-›•xÓYk V¨#UšJ™Áó–ìøNì1,Lœ<‡warTCW lwà Ž~öhYŽ`ÙÀóžA¨U‘ˆ¢­kmšP:ýd¤\m?½}Cͱ–¥@ðk)+rsAÉ$qJ„Ŧ#í…jQfuwkäW™ƒïD°³´¾PJn¦—ï(×Hf¥O¾2œl‰¡EÉWº£4KD ¨BÞlcÚ¬i ö†ó}Õ#2Ûªfä#+[Ûh]¢V3¡Ôq€b.T! ËY"ö žÏpÁˆï‘m~o$N«|¤–ÓRkÈ¿=ìdΪ$§]˜cG($>ו¤}!GPW{p&;|ÿ¸ÑÀQöÀîœÐ0TF~i™nœëM#š¶b¸£‡ƒÌˆ˜ÇŒü:€y¹ä•`’mOÕéêŒ5yœ.}É¡BQz%†^ù .—Nј9aYTe­ÒlZŒ´rçð§-Ðbå„»\|¾¸­)tkQ U!°_ØÏ6„š3r`Ÿ¨à¸ùvú­„z¥…©í2΀W^(Äg[ôMŽ“Á®¹^Çœ^ÆSVû”‰’ÆÓ)îòÈ—Î"T|\¡´VJ¬œ°l˜2QÇþú½ïÀ°Á9þ ÙvwD]-:ƒÊ—û3<½y<(R¯Ñ¡m<¾¹4ò\iÂø¬“ÿv¹Á$ˉåº?ß<§*Xd¨? @ l|¾æép¹S½€ôîW7Èă¨aÅ;C¿ö*ÕéŒI÷€ÒÝËg]X½uv'È »L£":H8åÎw"@¿ÄËwáUÜV×ß ÀXE¨ÙÕõ$¸æóŒþc“njp$˜NãÅâ–qdeŠÐüíû <~}PM§O¼’)ê_õã]áDãÔ¢Ðö¸AóÈÃj(ßKSÀé¬poò«Ïç’@‹šƒ!v ¦<.ZÈuîÔonnžt„YKæF08`r)ìˆÐÂ7˜2ب®oÖ…oøcŠTP¬õJöÉu ˜-üt¦]ŒŒËP¿ „¢oþ¼Ý %ò­\¿í9J!®†(a&Q…²°‹‘¯kØk´‰ÁÕYdñx„lv‰ÂLÄb˽ÚÍmnH[Eð=Q ºW×@ºÏZù Æ#Ç÷À%ªm+¶®Ÿ».6L`·Öþ÷;‰îÃ1Ý‘dk™þ^áù7ÂÌîšOL`ˆ]ÒøQQÕmÜgÓîT…ÏèÉêi ~{÷»=šÞP_$’¡eÖ`ÇRn–°ì4Å5j÷†4x¸ÁÓþݶ˜4Üü{ŠW6Ü»ñIÂ_qlÎO˜‹¯¦›»e÷Q–Nfñ|:§ÅÃI?vŒS|Ͼҙûìs²× ¿x|ëõäûŸóÉ"ž¦z éÜÅüúþêÏ«ÿ|]Æendstream endobj 4853 0 obj<>/XObject<<>>>>/Annots 1869 0 R>>endobj 4854 0 obj<>stream x­˜ooÛ6ÆßçS‚¬sZ[±ìÄIÚm@—5E¢ûSC± -Q17ZTI*iöé÷)ÉV7'EÒ$M‰GïîwwÊÇ”ÆøMi:ã¿lµ3NƸ×”/¿½Ü™ž'§4Ÿ&cZÑádÒ4½ÝÙãélš7sùiz|”ÑéI2ƒèdÛŸÿµ3¦QŠóÏ̖©.º,eNq¸9è ÷vvKcýšÉͨ[)Ž·K«r-¾w’<Ú.§MyÙmdn-´Ø47õBË!ñìnÀ§ÇCº2*o?oÑB–õŠÞþþêåüý//†Ý7Hnß¾þÇó7ïÿÜy¬}÷E>kêy£Ä…÷V:8?%vA#ÄÙh:mâl'‡IšLèçwsšÇPãœ6˜>9äÀ™/%ÅG)¬50µïOP®¤Õå ]ÊRZá%e&—|£0vEËYék[ҕе$S„{×VT•´TXsפœŠºÌ¼2eÒZ}5Åîa3|VZdÐC•aõï2S^IëI”9-.VºZ{VKǯ?“aÑV#±0Wò¹—V¬zå¿u”ËB°,ð¬b » ×Ó¤0Z›k÷´µÛšõ’Ît ò7‰„=¿€ñFc¨€ót;ãqÅ@N£v¿æÎ{rN_tºé]>ø_Ôw÷:Þíº[YßX©”×´—~`ü.{éÅ~w‘?¥3Naw²ØÞ@»4>â ”#i ä`qH‹ÚSU[©oõÀ·¢t̽`\YÐÔµXVTIìµr¾¯I}¢Zâ#‚•U+aoXÆ/A¶–´¸Å´‚[øne!­,3昀c-šœÐlƒTÑÓ‚!_3î¤÷`„[ù¥8gÁ·í]ð±µ@·òÁ— 0ÝazÄôU1¦ûL·¡ŒJûA³ïôà-ïî=ŠØÆEÖ…÷³Jò‹÷K+q…:#¹JfªP™ÐàM®*mnPï7»çZËKkèì5»QÚŰ-ÈÆ&át$´3¤ )W²DÌ Bw³Œ(ÉuÚöì6÷Ká)%-ä:´yå0VàXwÏΞ<¡–´„Þ›:ˆZ)rBEÆÀF8`ت߰£Odfµ±íÞýYm7= è*C/Òš¯£ÉŒËlhu&tÆMH«eL¯•«:ÝxéµB÷“„þçù†U²ÚynOZ?,:„`Æ…”%‰<­Ì­´òÜüp¿³±-L»i¤½ 4TkÚ Î[ EÏ#ïôÜK—Yµ`WKôa-„SÙç ™œ·u†N+¤Hô*ZAJ°Ÿ´ Y{–ÒyÜ•Ÿ*'ÎŽnH¦”!K‘-×ÉqÈGA /ûúp¦_‰RUµFއûùÀ› Þ0ô\Z84ü /]‡xК”wRm?;Ï7&ØÑÆrÑùCæ/jŽýµÐ§p7«…ÑŽ®9p´ GB•HèŒÛVµ*ùõ:®8YÖ:Ç[ ÑßòZ¹Nƒ4´–o™>(;iQÆbÖ”>Y°:ÄjÉ6íGixùäXNgÉ4Ié *ž«Àcl»˜_G3›4—^(íÖA:ï®)AÕ^¿zsg —aVc?„+·¦]…þïBHšÅ_h†¹4:îæ9hìeÓ*+›"@ÍG;\s2`Ç& À‰é…îVï'tŽ#ËO‚sÑÝWv EB¼ E[·áà 6\þMá!Ñù›ÛÌT1Ö\=uÚ•Ö˜0ƒ@ öÓø^ˆ®÷€Ž5è8g§þÁ¶üÁ¦!°}Ü+Z¥]”ƒšã®±Å¦"`ësp~Ò¼WMƇÉÑôˆf'“˜z¸|Œ&øoÂO& ÆÇB(qîè˜ßÉš,—" úñp4FÐM 1er4aÑó_wþ» ¦endstream endobj 4855 0 obj<>/XObject<<>>>>>>endobj 4856 0 obj<>stream x­XaSÛFýίء´5 l!ôSJC‡&I'ît2u's–N–‚|§œNvœ_ß·w'ÙCBÚÀÄ–}w»ûv÷½=>íôé?}žño2Ûùu´sãÃî?3¥£«êÓ(ÃÚ³x“ºïñ&é c„šJÊ´!›Kª­Hn#Q–:¶ÐŠtF‚¿•ÅTQ’ C¼eyH‰®–´ÔÁS¨)Êj*ì! •’Ò–r1—„ÏÚ˜%‰‰n,eFJ^Ì¶Ü "³Òì>îSÔÀ·•5*qæ´QuV NxÅ+n®_“]Vr&*I"+[»C3 ßl‚·]zoo.L!&¥ôŸ·ôÈÈL©é­¬¶ÒÈÜ+ÔÝ]ÉÏ"…Uí +1“Œ»_ ƒ'F­¨ª²©_Z`‹wÜŸÙ?.FÏcN(ΞßñŸ¿ íÈ'¹ÃÉ,©ŸD]#™ÿŸ;…úeÒ}§\.Cñt9å¥-R— —Þ£«§#qðßmÓ¢°9i…¬i”0rfäLÏeӵ˦‘„”)Ý~È)võЕìÞÊ^ËQ×\¢&”N@gk¾äÊw¨¾‰N—÷±KtU1«´±BYx«ÐˆM‚>x÷×õï´ÈQÕT7“Z~j¤²h·TÒT*i|g×VV5Õ¹nÊuŠþ­¥±( ×ÈCÒ4†«µ.ÔPº1ÝH1ç6ã®wе··Íå®ÑyYæº)-¬QYÔ- ºDFOXJ5¹øÊÂÚRÒdI ±ä¢A%—Û^bl¢ÎCŽ3¦× #=›I•"™¿Í óðn€™(£óøE'gñpˆç´÷c{܃ññ>‘Ãxôþí+¼uÿvǽ¤¼(¥¥qoÜãåÔ÷ñ3VDñþî/ÞmËàöpŸ¡ßa¦ÿ<>‰ñ€nÞü9¢Ñ:K´|…õk$ÈË‚kmáͤPµ,/’œ’d–Éĺªt »¬e©‡²¯9—7oÞq! ¢˜éù©©¥/ÇÕ„pÞkL\{ò/zZ+Ë% ‹“䌋Ä6à¡´ˆ3éÒòpHM-}7­Xý·ô¾ÆÕeR‚á<Î-j=ŠèÕ&_»PÝR_qFV¨H”{Ýy¨'\Ýr•×"‡7Í„MrÒæ+>ßZdßBèÛº%¢wB˜Ã†ÜÅô¶ C Ë©ûv‡£QÐìkÄuÄˈ³éýÝΖ©ôD£n¯¦‹- ×ËÙD—môXIZmf˜}> èŸ:ô݃ÓKÖóš' vÝ“ÔFýe…eñ%Œ+˜O«‘ž"¡©0á&ÁL€Dò8Óq[ ÏŠã^-ÙµL0#ã $L÷·"µ…¸7¸cx²…;À n¢u‰ù ³Ô!5*h±\hƒtÔÒLxkLZayxêÎòÏí Ýn÷¾ÛËOí,µšv[ýC·×=>¶9+µ€áT7˜Ã‰×wn¶<8¤¹.R ¯z"U3Û á]G²žb™pkÌíÑgqdâþûåë÷ÿ®8xÔX»‹~ ð|?·2jù’~L-lj4©` àoéÿë¾±NPœ¢Ü9 ¢òÐÁIÿ2î½¼¼ùäÖÉÔ·ºŒ:c{‚Iˆa£JŽÝY¼ø"Ƥîñp¢ø„ÃägW'¹L›RF ¿ÚÀE/Az¿Ù ­Njutõ¸NéêêÚ _—êve«Ö¸ÝBYñK¹,1ø8: ‡ÔÏ9<­¹Q(Ñ £dèòèòÙ3/?u%“"+ü•Ô¢”S£¡á€±±w·ÚÜÓ(‡äm,§Í%¬ý—>ÌYv†Œ\i«iÄgƒ2ÁÝ~žlµ_9ífÚ`ò²<Ûa>ÄЫç†7sQ6xýúÙSåFLïYÍÜx:Ói‘-½Z´™/wšù”/²¹^8€7®aµ Œn¦9.®Þ'gQlx2-æŽ#¤˜® Kò³˜ULQÁÈ­rÇb0|¹ƒ¸4ˆâ1«ŠÒ]ºáÙÝ`.·5„Äͯ‡±†ÍŠiŽSÒ  D/ؾy á±p0¸¯ YV°“ADh=æ5 búl§Ëvê‰6§KŒÄ¡¤Ö‡ðª†G4N¨ÅŸj8ĪUçøöc Ãß à÷òî]×\&î<¦óðÁà §'Ù ¨CúPø`£ïë.ìo¦K¿!ôƃ’°‚Ó©ÏîÅ Å-$½ZÝ¢îÿ ò@Úk}ÿü$>žÒÙyw`5‰ñ1ý¦×&m† )ó«£ç^¿Â• ï!E˜Nxáé1Nø? N‡üÑ«ÑÎ;ÿŠúzpendstream endobj 4857 0 obj<>/XObject<<>>>>>>endobj 4858 0 obj<>stream xWÛnÛF}×W ·S“ÖÝŽ‚<¤®ÕM‹´fQ`¬É¥´-Åey±lý÷žÙåÒ’ã eI¹Ôœ¹ìœ™YýÓPï¦ü ×ïƒNßïãaó•/éxÞ§SDALÃ>Mß üéô„‚ÈHõ){ß”w™\‹lÑ‹cÅ÷‹C*Ô2•…+‘SwÆ—îûÃà¯NŸ¼@Ñã •ÎË#‡-x°¹¶@WimÔݯ­•Þ[Ç=lã{ËÔØm‡Ntºl‚æìòeÃ5¬±Ü'Zp˜æÚÂ^¤«ëD`oZ ÞRwÑ{K†‹Ã¨­"r(^´Gug,߆L«5]þqñcðç—óÖ©nßÖ1m{w<GÌî˜<”Š7Õ¥ÒœøcèéóÅåc/°%Ã%q<×(`†c.Ž`¥ ÂG¤º\Éœ¸¨H§É•¹H‹XçkQ*ªîR W ®Ô”åúFE’€¤D™Çè#Ú¬T¸b9~®3†‹ •G$òeµ–`¼J]‘Ùæy‘ÉPÅ ®¨”Åñ,’±?$êÜ E’;åÓ¥¼S`±¸·NÐkº‘±»2g¨1\Éðo#6øù¨3e¢àXUêS€`àŠ¨’’@®$6ޱ¨ÝcD'gv£·;™7ú£úÚv/âýb:ØµÖ uÃdÆ7R¤ORj cÛ0|#ÂR>Ýõ¶P®jën 8‡\¶ï4ڇЗ91„<ûüñò’»[O2RnɺÝbÝR¦2¥¥ÝZ–+™F.Ê*GNbC<#¦B/®Ò)XÔ¼Üä"#}#st¤¹m~ߥ˜ÞüBU®\òqd-gÅž,¬¡ÁÓS€óèd÷L¿ƒíä¿™¬ìÈEoF&=ò2£­ÁÔ«F¡]¿¨tkT˜ûF¯^„ó°iðvÑ(0Ë5ìöb&—^›:p»XÏ2  4DzÏµí¼¹±¬½ÝkrŽQÅvÑ~ÜØ6•‡êFÁdgŒèg©Ø´Iž(t-WâF¡F*vÞu®‚7îÁxÀ1B¢¤¸©²¸¼ë séF“Åm$FfféØTž¸Fy5šyPˆ%Ze³\}n8ž«ÒÈùÖüsMÓôëEc¸â¹vöéüì§«ß¹8ûôñ7TS÷/ è ÞÓîˆ ¹ÓzU ùúå`]ƒ:PiV•ïŸiÀ÷йè!#‰,iÑ[ôtÅ7xÂáy¡ÆÖ@ëâм)ÑÁµŽîž9e$[îÕ6ÌùDÞB)7"/ÅD¾‘ž%Á‹Œw‘î\kGáÙëð4“·˜9˜ë<šqD 7ß%ª,Q 2”Hi‹ÒS^©Ç[^¼ñ¾Ö=]ì€ÛýÚ­‡Ô@ön4 >ÀXá©ÿÔz†[Øj™x¦zuÇ̇P’¯uÜç¾N{©ëÌ[&½rÛæï•ê[¦ÏÚñü´>–NÇþd4¡ééÔ?±'&.xoè÷éš“£9޲[8ùZiïÄîc}öÑ|~ñðè;éOýÑBÑ †“1ãσίÿaH endstream endobj 4859 0 obj<>/XObject<<>>>>>>endobj 4860 0 obj<>stream x­W]oÛF|÷¯XhË"-Q–ìºHÄI iƒ6Bû" 8‘GéŠÇÜ­èßwöÈ#ÅT.Ò ˆË÷kvvvõñbFSü›Ñ|É?ÙþâÅêbšLñfÿŸÙÒåë)Ý$sZ”Niy3K–ËkZåþ©)­²èw¬å^Ôë¨(¿^?%¢C¶æ/GOn›Êªm%óØî´qO~|ºz1¥xãüĸT¶Ö½ñ£OgáÑÓPÙ£F"+…µÈ°‘•·œªÈœ4ÿÅò{zS댪¶­Ýåëhv•\1V1ÀŠç7Éԃͮ“Ýç²rªPÒЮ¤AD*š*sJW–añR¶‡uºLnn#6Nftg¤pFö¸ßèÒ’ªÈí$qU$«etµG„ÖÑ1À­#ŸSý!ŒÒíí÷u´‘´••4ÂÉü1ä4v*Û‘GrY¨Jù¬'CÊP†•³z@,±)%^J—%ÔÅ ½Gy´ÑM•'ô»@¥ˆŠ m2I‚jaœÊšRvúÀ¸iÿ)UbÏÀÄÊPÉ„`ªt×nQB§½c½ƒlR–+ód”Ïs~Ïľ:£w·.¸]"!6ÂíëR2܈}ì‚uÉae¼×¹*ŽHvB6ÛáYàf•¢¦`JÝW' x÷çýÏH8—޶€$d5LU…è…8zó^f.JFÒÈ*C›#)g[>´ÕÚ‹Ìh.XU¨Ž» ¤R,A!”2‚àlÍ¢LƒÀ¶$Q×F×h´ ­ÒIèÞqT<‡µ‘$?ÕH<ÄgûsÑFéô‘,™NGøwiyopYGò#zÜ–K[ªøÔü‡V:Ò ³m¸SÖ·û³ë,¥WŸ”õv.¯çœáåë3óµ:hÚ«²“ÂÈè>¥¥x˜6ä×lÈfÔ! ü?Óˆ«¦,ÏÄg³_5yÆ© *aAácŒ©Õ*nJ .i³é¨š?ϰš|n½G ŒÈÊëÅA¹]k8j[£_½ï”C„TYzG,gÝ0øžœE!=‡+Fë žÃ?„E›v½Lh H&S¡iw¬1t6¡·ŒÅAYŒá`T îÂ=Ç©%œWæΈÊ2ؾ+'<[îœ^ÊB4%F§Wάã÷ eݺ±Yp·“Ùߺ‘\ :Ð~%TØx ´Øâ<ðiFoÔæ‚!·Fgåð*±‡í¸ Kxï¾ë¾/ç'X +¯¶ ´þ¨Cúp*ñC¶ãð¼6»m÷%jÞë N“¦Ì™ Ü*Fœg§Ðe©~åBº°¹ÛѺ à wQœ¦É|Ž+)ÖÀmÎ%ôJåôíy$>`º}Š]éŽP±$I6:?â×úi øçhÌœxöì§À€¼Ž oE÷Fk0È’¿?Òyw¬E+T²îZzÿr ]ÔÏ>+ÆÕ_6ÜÑy£ã5ÛÝ@LâÀ;=AÂ^m7¿õå¢îƒ6ù ûãL·. £òèwòÕê¸7ƒ” ãÀ‹å;‹£l`á3õS—ÐjÇr˾p±¡ÍXaØ*XÔ~‹:ÚÉÆðȬ_ÀØžuÍ•OpF–'jH áˆB<ü÷*×/K¿lCGýíOëÁÉ@iœ!rÌ@ÖãŠc$gZܶçXÌwrt÷æí»–SÝr™Ýt_c¡x.­Sœ¤ãÖógñÌçu‹ð7 ^Áçðnk÷•^M“9ðvpÜkFÎ[ÁâÕž:_´rÿ²0RzZÿOûz†}G&°H{év ׋dS}QŸBg׋d9_à[Ø2¹ò_ ˜kqšLé¥Îü㇇ƒ\% <_óÀûoWø÷K¸J[žn$î…l:ε_åüvYL—É>/XObject<<>>>>>>endobj 4862 0 obj<>stream xUËŽ;Ýóµ‰B2¸šfî&7ÉÕ,¢( R6³ñ¸Ýà¤Û&~ ·ÿ>§úÁ0 Š2¶«¨Ç©S埣Mñ™Ñ|É_UÞmFÓlŠËãâ·týñ†fSÚ”¬´¼Ã®h°QãuY ·×^FçI•µ$©t^›­%%«Š ]« z2”kE/,³ù>ºþ8»íˆUÆqmŠñC¾\Q'"`™˜å,]ouŒšö›2Y³—ÚkcßK¥Oòø÷êªË‰ï/5†@tú‹!àŒ>Ɇ¼ŽÉ[`÷0†¼¤ÐÔ®zxA©½¶—û?SÎk¸žPHjG2Ðç¾ÿLŽÛ·ÙÅYW.ž øh8¿}RñZU2„ëdQ10'pû‹ýÅfZ¹aíõÈò‹}>Ioäcuê÷xõŸƒÎ_ùùmvG"¿aòovšÖ-‚ôC7ç ’~›jm27 @6vËÜ埓†dÔ3ú¶Ó–¬³ÂšjB†+S%#š7îdÄ¢I%ÚAT`5¥A¯í@’ @è3/¦C3²~ØkÅjµµÉAá$` ›ßv¶jHî÷ZúÀ ³]ó"€a­ãÎ{ßyž·ÙíM¶˜/(_åÙªóÊdy6¥÷Nµ-ÜBþ›È§¶Xqz*Íé=¿¨Ì#€ÚìÙ‚³…Åt™Íóî=ÍK¾ú°}ýßÀt¬endstream endobj 4863 0 obj<>/XObject<<>>>>/Annots 1885 0 R>>endobj 4864 0 obj<>stream x½XKsÛF¾ëWÌÁU¡+H€H:•ƒÖ+%ÎÆ]±*Um 9^Á¢õï÷ë ÈR”²e©FO¿¿îð÷‹@,ð/˘þ'ÅÅÂ_à }ôñŸŸ.–±¿qûKQˆuä¯z"7=oµb^¼ÅWÌñFd!‚ÅÖGÌuHJ—! A@Z™"É1 Ñ8ô7#® VtAß1S,:¢­ÕhÂÝúŽwùÛ×*^lXñfK<&H ü3Ç4©% ƒ(«¶6Ûb±©‘\FHÊÀäÄG›ÜhE<&HpD¢(+?ñB8»«-i+Ärä¥HrLƒ»Üøë7X,Ú ŸTí`¹†fK‘ì˜7Ú’,ŸeîzëgÙ0‘ë;¦ "¸xÄ–p6v¶0»%IKÞIÙ%&eÛÑà"ôÕ˜;¢a4\ÁÁAvLƒ»Š§Ü n¼@G²#š’LɸcÜ0šÈþc7j3îµæ æ×c´ï2td¼ ýu(v)÷âBì’Y°7¿½ÿIÈ2—eÚT:}½û2ÒÄ ËšˆdÔÒl¯¢šfŸîUs¯Õi*5؇+æ­‘(Hg·a¼ÓóßZ¡Ó^@ÎÎz¿„ú*‹:W†DÉ Ë½êŸ ]¶M•vI««rªý)o<\:¢Å‹þØó½ÍMŽˆwÎ¥¿ÙÜ»ï¿I.ù?ÙûÔUãlqº9ƒÃãa¨ìS¹ô–h>4òæ¯U Ô—…>[$˜fÝQ–šE©ªU™Ò_À.—Ȩ¶«†ŒVGߘ[`C%ßÕ0yC\d|yÁ˜Þö¸-œ]À"²mF÷&ØÞ?ˆ¦+K²Iê\ìU^|ñ9W’B°¨ P0n­ƒ½âTÝëDõƒíYôGQÃqV^NfVåð…tã›Òu]#€“þùÙ•)’DNºqè5j ¸€<&y‡©/Åy§2ìŠißé3‡ù<&©Tªw`˜ßÃ<¦Òó0ÅS´gæ0p€™0¹ÎÑrÆ Á9ÅKSb?f]É—KêÊ“Â&Å7Þ:\T©ÎÏ!¯ö˜&÷²ÑTv_\ë©>©ï á"ìcDXwu¼ä¦°0{èd“Úi‡oW& 9×ý*µP:_çÉO» š¬/ßzQ{â E …ôŒнÃÏnNú`sk®g°ƒØM·&ßÓl®Kwæú âbø_¸ä‹çYø>Ö…ö@a ëU©ìëŒ[JJ6¸PsNHt¸Õž×¥Ã.%ï…WŠ™ÿÜÎý KÉå³í|ñ¢R¼ëwv˜çŸG†mŽñBGÐÜÈV1ÝV5v `+i+fÝtÏ5*ñÄ]v T`v˜VÕæÏ†ýB.Ëø9ÇóJºÀ^}þ¼ï Ï“è{Ý><>•ÜɃ óà@ÈP€Á=šðO>—e‹±¼ïÓJ{¼ÝÎCÿƒmÀG 1M2‡Õ9Yí½œø_0ž§Zgö~L¹OU&;´P[ýñ^­å“ÑýÀèÂ^â†Ã~»o}êÆË>W|p~}~Qæ¸"?Zv¢=ù†á˜eh_`ÃhM¶®vÿ¾øKsMendstream endobj 4865 0 obj<>/XObject<<>>>>>>endobj 4866 0 obj<>stream x­VÛrÛ6}×WlùÚ®@]bEu£&µe<“Di¤4/œñ@$¡¡¥x:ù÷.x1EQ±õPÛÃ1ÀÝÃݳ‹³øÖêB»Ð¸¿hÓºž·:¤ƒ›½‚`Ò!éÃ| ½ ~ë’ÁàÌYfÕyä‹M¢´*™V‚eÈu*YÌ?›ÿÓê@»‹VìÐj+øŽüG­v‚­¸E}¨N…V¦ŽF ÏêúÞGͱ;ž}Jå3° m !a(½Ópêú’ïŠ6h´gè‡gh=Õ½v ýªŽ¦š¿æºÂªýQT²B¯÷&šŸâ1ž¯¡ïX„->Nìª$„& ž#ä{H»}Œ6Iñ°q×²ÜUÜûÅ®'B ³æì—z=ªäððFšTóâĹ*bX –à£ÑØØÄÅÉ$‰26/²"é"æ.68Þúû4êT>b¹÷…%ªD^­ý¢’Étüyvw3ýòá8e÷ úq̸4¬()uÅ€ÈÅ8_\@¤?&!ûYÕKÔ î8-Hÿ|z3mX—qå d«`òÜr mŒ¶ÝëÌŸ;å[ ’ƒq }”¡ÉçÂöÓØy¯/ 4Ѓ¬|w£ýLë¡ï4Mî¢|€àUFª›Sª‘‡q¡†>“×ÉöÈSò!‰l§Égp@N5Sž&¨0MÔ²êìü… &Ãâ u‡ÏÉeÿÃAyf_nß¶{¤7*JÝ}/ë@—JInÝ~‘KMwHz¤Å]oŒ·=ên}Îö²ƒ€=¼kãáê]ÝÖ›yë¯ÖDÐjxendstream endobj 4867 0 obj<>/XObject<<>>>>/Annots 1888 0 R>>endobj 4868 0 obj<>stream x•Vk“Ó6ýž_q‡)C Û±“l Óe! ”¡-Ê—a[±Å:VåM2Lÿ{Ï•â% ,}dbùê>Î=÷H;}ŠðÛ§dÄé²Vø£Ïožw’á(èÓ0™-)y8 &»§’.:ûÏKô'Áhïíþ3ÞãO¼÷Él/œ‹ir §ƒ„f Š#MúÁhôf™K*¢YÚ%ü<¾?ûЉ¨×ÇJÖý}&7ö_%׫l'ªÌh•ªìÑ?~UYøWcWeû;·—b«û~­2[<º³6bõ>Õ••Õ÷÷Rå…ýÞ¦ð(ýð"5º,¹‚ã7¯T%…yå2rïÂ逸êõ€O/NvøtßÈy£ÊŒl!ieô™ZZ+[Š1”¢Êe}ÊEBÜ‹ã IxÖýxYÊà(÷v·„:+m¡›¼àXF’À¥©V]KZ4Uj•®(eY“ª\F©Îä m¥Å‡nh)¶´æ`V#5™^ÁHà©P5Õj¹*QC·/ŵ ±Z‘iªšær¡lûsÊ"ËT•·Qv)¸ÈM•©¯––š•‡áÌó5^«¹jC…0ÙšKpuçðÆ[$¹0‡ÓzvßÖoo;ª[.w 0p?va2G ²Ô+iîqÉVô®@MsõVú|wyÖ€­K*UmeæëÕ5°·VÀ 9ë¥~H®TWò»Îæ;|îí(½‚Ò‹öÝGku–ĽÑÓ'Ï¢(ê÷&Óé_¢^Ô>ÅçI/Š£þ8ŠÇ;/\ö­´qË—R ½L Ï¥5)²-³CUµ‘Œ B©RÐLWAx·ûjqHeTØnž«*¼X«üÂQ«ç:ˆÕÕaU“!ýù$¬é²;'šo­tüE;“úò~Û>§9¬.ü³ºÊO)Ì„a©A¼Ð.W_u°û¢IÁý7ÁXÉu¹mË@ßï}®âž›‹µ6à…Xê*Gë*7ðšg“MZÄê–ŒˆBuj¤¬zÓx†òŒA,I±h”e›¬›1°oMÂÃ=Ú‰O—wú¥V$º4o¬eÆC]i®7È«ÄNeúÛ ZîáOxÑn y|vŠàüB™!à®ù,lö*…òTŒISíúàx&Pà–¾ÀÅ—]ÑB@0— 0<ÚêU§mÜ7+´~¯¥©™Ž€½m³1èý±Á|“53ZÓÂè¥oR¡Ž'¾±ÒüÈÈÞ”DÚäA Jœ6¾ãæ°ë5:ã4—§®n±'¹­N2-ÖÚ\¡‚,A« ¸NkèåëÈ=“”ËJ‡†«ìâÝ‹ç-¾?Nˆ ŒƒÂxà†áޱî‡Jù•ÏDª›y¦ N0m¶®?`¤Ñ;`¡£säÐH¸Ë‡Ì—NC¹¬¥AzäþÛ@‡ppàü9¥›ýô dÌ7‡/LÎ(/õ\”t-ŒsØßØø;I¦^¢ß( ¢ßŽ=œû¶;aË]ež dÊÔµªq6AˆW‡Ÿ« 7l;„uÊÓì²Ë_6'lGÛËûôiЧCn=o³hs$·=^\\ÿewC)úŠ'"Þ¶9ÞF´aot÷k¯¶xõEôÿŽR4Ò6¦:¶sV·ªäyË*¦É`’q´s |¾»;ŹãÉÉ·XrLŸe‰:nÌÝ¥Î$±£×NÇ;Ö÷ǃ`˜ i4ŽÚÛЋqË~ªÓf‰Û¦;èxhç­{}ãúã bòÇfa/Ä0IŒK=t1Nxû³YçŸÎÿÂÔy¢endstream endobj 4869 0 obj<>/XObject<<>>>>/Annots 1891 0 R>>endobj 4870 0 obj<>stream x¥V{oÛ6ÿߟâ5€ÒV’%ÇŽ“-'iݹéf»h‰¶™H¤+QqŒaß}w¤äWݰ<œ¼÷ýîñ­@¿h´è'Jku¯Ž7ôÐÇàC­x'Ðh7¼:¤Ðjâ{H`XÛ:¦Ð>õ­·­c A3ðP‹‘BŒ£-MF]6ÿºm¯£)„uhµ¯Õ:Qlì©Ã(r…L„äpø×Ñè®V7ÀëØášg„Ô€_³(;ôÿã{sµýøy¬ŠIÂáZ©Ýçÿ‰Ú¿>’>qÃFiŒÓ“êžÃðÞ`9LU’¨e~fy¶pÃÐk4ÐØyùRÌÀ½c Ü‹îÙŒƒÊfÝ{¹Hh‰« ‹ ò,òñͧ7ýwRøü‘éí2c /Ú¾òÄ«Vsg\òŒižƒžóÒr!g0 ßx`½F8¸á1ÿŒ9•ŸnzùdUí*b'˜l“™qˆ¬BcÓ›„ß‘üÄ> Ô¿±o“î¶wZù~ƒÐ‚%Éy ZA”qŒ0È5“1ËbèÈ8S"†›Ë_`Rˆ$†|•kžš î¹îe%ƒ—Þï&ÌyB?À5fé¬ÒW²¯K ÿ¥ÛéßþÚ}„³sx3v"–$®\Ôøˆ4ˆMN„Œ’"æDÔí_u·¿wÃ=+îó—˯ý+ª)”YB¯e Ï’ ÝÛë^ÿj¸EV!´äò¢—L¸øÚë_Þ?vW—·ýÞÅ 3øÓób976"wûvg;#±ŠŠ”KÍ´Pr—¾ê:B©Ê° ¥‘û$•˜j˜q­©V0ñ™F0,…žWÔt ¬SÝ!Úh«®¦ ã{×d)05‘J˜P#+Ù” XE¶H ds–¡*5¹ã‘öK\%b’±låÁ—B/ D'I›p2@$,C”¾¤7KvrÙ]T¤Ìx•pøiû2©ÿ•m| š¡ñªoÝ EèQ“\íïI 7ºW~í‘ÂùÏÄ›û,K9›ÿ‰ !t£–y¦Mø»€} ¶â̱¥O8—¦–õ{ªýˆIXfËþµïHaíP+ ÃpÌ(#CÏEnExðYÅbº2×ä 5Ûú‰Èxà]ä´UÏq åz®b”·ËAõýb«â|šÑ±Õ-7"+©×“ƒÆðÍÄ2`c1¶5|Ç0k! <+"ì‰bæ¹Ê‰µÄ¶7Œ5ÁX4’Jƒ•°ŽÆ®Ñù:)µþÛ·@AÉm<»~÷Ý;à oýJ·i]D¼À©¦>PÓÝÄsì¬;˜E‘în tƒº|£ T‘ÙMa|ÓBFëQµIKnö8‡ãpwIؼ®ð5¨7_zžás…n³™<¾²Xa8ý±žG8q<¶Xp‰[ÌÁC:33'×Û[T,DŽ ÂžrïàL2é´2'Ä"ftåÁf²#À*ÄP|fR,Š„few!˜%jÂx`™`¸•ñßã+{Ð9DE–a‡E†¤¨¨7)(׬)ŠÞŠר‹’ö\Üž‹™vn¼"Ißó«;g7,²ï%»ª¤ä¥) /8š§akcÓžÓ4wÄÔÂÜÊ×JÝŸN±=?Á) Äž&tãF¥KŠ=¯üëjŸ ÚÇ^³Ñ„ÖI½Ú(iŸsC\Æ/÷'NyKížØ4m/ÄÍÜv èVh$ƒ›õ–×íª¶êtu5ªýVûÜútAendstream endobj 4871 0 obj<>/XObject<>>>/Annots 1893 0 R>>endobj 4872 0 obj<>stream x}UMoÛ8½ûW ŠÔ´¢¾lÅi]¤Xhl —^h‘¶˜J¢Â»Æbÿû)ɶœ¦Ž!ÄÒÌðÍ{oFO“büK ËÝ·¨'O,r²ð·³ø–ääI Mb2uÑ}2ƒ¾Mbc²»$îòðy’Î\h’d$†ÒEêÒý¯ V“Ëß5dÓ)FŸþ½¾(諪DËæ$ƒõÒòEBòüÖÌúÀ¢¸6RqØÓÊò7ëÇI a‚!¬á¿hÝVœhn–Rþ¶xyó׳Àÿú;x\ŸÝÜ€6Ôˆ Ùh£lÁMô,·ú÷Ù‡quԆפ’”ý#6ŠªãàUêÕ‹H¢å\[Q˜f=Á¬[Qq0%‡/tOã@5Xmiõl#+­*!+{®´ È­¿EÛÄ;ÓÇr´a xx™Üð`ô{×ÖX0MI–¡<,x™ßØÝ¨}¼Ï6h¤Ú}xNŽßÄGoD­0råC_šÐö't8^àåÁ6§ö莊ÆwdJ¡ÁˆšÃQZ8¸–5ïȓִÖ@+ c°á•<¼]ʃhv¾–âÚVÆW ¡Ù2Ò?¸ó¬÷Ä, IP(S6‘|êŒ$s‚ÁÝÛ·PTTkè%7á¤â|aÂE§´¶è2w ƒáó½ÂhqZÕRŒ7èJŠ;8RsDæqµŠï…´:€Ã™>ô~èPüÉ ×3潟PÿA솫RèÄ‚Rp4nQ=®ÞÁÔ%mñ_ŠàqM9¦®¯™ú—B!üBqj°x¦¤`Ð*ùÈ |‚M#ªŽ"ÜÞÿóÂ;sL]àÎB„vð7šÇ xþ¯’ œùöÊŸa¡¬À¹¡žÒ/_ïûœÊ,p‚àP ¥ìÑb7n¯‡¡¡jÇÍÕ‘¨››ÓÚ‰'ì“SU!±ƒxþ˜ñjÅM|êö—wŸ’ —fc‡­Éyw^jGx/ÁÀûßaØPœ–çx£¥¦u.CŠö¯bŠŸtÇá4å>úÂò§¥ü ÖMĘž«5÷UNŠ\óû؈qn0v[e(Ks.àD+9eHöÖ-ϦÞaX0 [^—>”¢(qÁmEƒN—V§ÁO€Ëqz‡t­ë?¯Íè–ÉûÓ¤”ý›%ZÎ{ç'ó)™e3Èç9ÉæÎ|«ï÷ŸÃ_Ÿea‘ðíÔ™éë‚ÃÛîå÷§ý3‹±`Š K¦yâÐZO¾Mþ"ÒX(endstream endobj 4873 0 obj<>/XObject<<>>>>>>endobj 4874 0 obj<>stream x½VËnÚ@ÝóGÉÆÚøÆq”MÓRe©Uº±T¹öP&26ñƒ€¢ôÛ{gƶbh¤JÌÌ™sŸçÂãÀ‚IO Ž+^Ñzðq10 “6Û·üÆsžá`±„mÂõ,ÃugXÄebiQîWá†áùbñ00¡[tk›êgÂ#¿³… ´à¢‡=ÒBУÑUïÒKo½åyY… ~K»§Ùtý€­¿gä*v°¿"?úÖ2 ÷ÖÙ–Z Ž Ü|Ý}ÊÆÃæ, ´-Qà×0ÿß°œ¯YÉòSwŠ2,yð´l2×¥}i–T:ª‡ªÔ Ï#ŠÕ‡*ÏÛ•Ëù6,Y¿tu,yóªh¸OÕZÙjS–Sì>Ôõ@«g´>*àDâº& Iëâ[K¯³qÿXQiþ%O<.W]KG_šj“ñ$“!ošXüÿ\Œçˆ´/¡SNtÛ©Å­…iŒˆ:¶d(W |½IØš¥¢ß²”úMî ‘ˆñ ´‡”Ù.P#ÚlÔiïaÉÕO݉¢Û¶á84_bm<Äœ@T‹W4Žk1ªªó4Jª˜á¬­Î:j=Ù’§ w?¾ÞÂ1¬‰5½´Ý©3õ.g—Žíx·CHVïHÖ2"9}Pf‘²'$Y¤n}P=*T¬dãû§FÂÁ€Ûatx×m`/·÷Ýífâ©°…Äå¨óýzF¾" S«SiÎ÷;繓# ge•§2IC¥Çúã”=r;ˆ·¶bE1Þo@iò}Hý ßÐ`7µë ó»]Ÿ¥>ª¥›÷ßo¿ˆÙÌòe1),³œ:¸eÔÇ$&Q›#Bâꬕ‘œÈã¹W‹Î6'µ6Ü™'$,ê¶aâSU­^é[!õ™êaË3HxÊ ù^ËI€§¦k86ý9 JÛµÅÖçÅàÛà?-S¤endstream endobj 4875 0 obj<>/XObject<<>>>>>>endobj 4876 0 obj<>stream xµVkoÛ6ýž_qѦ¨ÛF”‰“fËlj[wN²Ùn‡ Z¢m&’¨T\£Øß½”äGš×0Ä6lX<¼/ž{.o¶jPÅw MúñÖñp«Êªøpù¥§àwªpÀ0œ@½ Í5ÖlîÃ0t¨* ƒŠÿ:2pâ;ÓH0 ïýwë­*x5„„•7± 3„€b íÑÚ èk™Q xUZ›½Ú¼ùgc;zï ûÖÀUf,L5ƒ PZNeÂ#˜  Šp&´ø)´üù] à'àaœ^½Qä]é&·êZÀà¯î'à&*ŠÔÜì@¢¬@×Ü:ÿ^ðá¨ÔJ•€4 ÅM&µ®¡K Å!%²Y_¯^gV;¬lƒ™Ë)8CÞ¿åà¥<¸æSJnÊh‘7¦¨x*³¡Ô`tà#Â'„W‰ô‹ £¹æ) Òtý!“yP$ﲞŠDhn…q™æÉÔÕØ,“Ê‹‡Ìò껔σaùƒ›ŒkÁ(ÇÜyí ,ý>#–âîË:²®¬WnšÖ¼ZýqÛE®_λ/jÿeŒ·¥°^¤0ƒOÿ—éû˜ôœã[1ë€},Éq.¾[˜ HöˆUhž@+ µ’!œŸüãLF!˜…±"Î;šÚ)Pq*#" 5~Ù\wÈR¡p [,¾Þ$y…Á·nÒ«âM´µwÚÍ1.wJÂñ)vxòÖ‚±Z6Z¸,Š^·3ìþ‚„;˜€%5 ,‹už,œäÊ‘l*Ê ?v—´’ß5yxíD÷°¬O‘ÓRq{íVoôGkø`û²ð(‚xá¡B\¾£LIÔ\k•ˆ vï´Õ}kõw0¹¹³‹“¯½SÀÚ,’*Lå:ŸÃýö¨ÓíÖ`+±)ö‘ðܳ·Ýéµ> «¸/Øã¯ÝÞÉhð¹Õ?=õºÇýVÿï<ìµ»FÒ„‰"p§ÎjIxíåÜšK¬Rq¶ŽNNix$c¥ô3CÑ A¯D`ý‚”‘k® .2›âa;{cAneÄ5RûñSÝ^ŲQœ¶ã¸@fØYñÊúïˣXÖø¿oýé4«ôòtÈfflˆS9‘^ u˰ ,بHº‰±ÄÂâål® pô›sâs >–>z\­’¡õ\Íóþq(öñ6ç ôXˆÄ)‡Ý!… PSæZ¢¸|¡™JsØ &”×±n;ƒ3ÊÉ"÷W%w ÌŸ:œ¼mÍkÒ]Ê^&ZÅŽ[¡˜ð,Âû¤xtìÿR”¸èå8UÚUI4OSÖ ¬¼•vQóNÅ6X*ÃŽ³$ŒÄ£¨[)æì~=ŠšËp*,Ú³V%ÏAQüŸkuh¼p=‰¶h’ÅÂÎTÈò-8ÎÔ­ˆEbÏÜó2²¼pi6ŽdîºËóÃ&³" ”EÜàóÄê2À«¶?ý…#H²(*½åÕ'ì*0.)äëÖï”— ÚÁ.ÛkìA‹»!]ü:«Â‰ 2JÉI…ƒšž£½ýÜUí€á•2‹DÉR7¼Wm²F=¿`Õ› zt:Üúsë_NÌ Îendstream endobj 4877 0 obj<>/XObject<<>>>>>>endobj 4878 0 obj<>stream x¥VQs7~çWlyñÙ®Å1ñ4õLc·~°imÚÉe:âN¥‡D$Ä“Éï®áq§ÄŽI÷íî·ßîês£ )þkC·G?ù¬q5j¤,ÅÅÍæZ×)\°.Œ&ÐI¡wÑf½ÞKþT £<ü´NN ÏËR°œ n*€çN.¤{ia"uÁ(œ´ŽGŸ)œµ¡ð? ÂYˆ½y5.e - Ъï1²äªRE)Àò…(n”u\åbè>;ÞCøº·B>Ûj. «cP¯âo ××Ê åþb™%ïXÉtåØŒK•¯_B¾VÁ‘9ÜŸWn$¾8¸„,¡ÿöñDª‚ž®n Â’lÎÖh5U»hÌ š%Í_°ŽÞUêœ$Å8ÆX–©æópnõBÌ0¬[á¦Qb ÃÜè²”êþñfv\ƒî†jý+Âø@ÃûC ÛÂÔXu ßVì×è»ZÀ@¯*ç0…(²„ŒÀ‚Rò< Ô)a|> #n¢† iô)ÚGe Ò{–ÄüÞNv|-•´SQ|·›:8,£¼U¶2¨kO!eÝ=‡z‰ˆqM5›këBÂÅÇ¥ ß .ýmM¥ž8‰e²J&›Te²•%á/ñÍ®ý߇¿¼¿‹S°NcX\‹^¬)Y÷ R!ýVÿôr]ˆX ÙŽj7E{ÄÅhAòÏèƒñ'‘¯º•Ô*¬îI1šdhúþ„ÕVÏhe ”C,d€¾496²‹…Ê-|Í’v?Ñ,4©#„ÆX@ðš€DáosWmÛ9~®8Ime9|ý–mÀ#ËvßrT¯ó@õë<§–Å©W9lò31cßð›Ïe|…âxIuBÖ‡S>ì^¸;KOÖë©€ð–Ã^ £G™‰zy¼*¸ã8ռLJ®«î¾æßÛo1qL´A’±Åƒ¼L_ü1€³R¨{7Å…ÓÓÈH‡ÓíÕ¾1ù†ðA~dNÁzÜdïpî´zÒ}$ž.½*‚ódƒvbø­ë  â˜@ûâ;ïžãÅ/Ù]¼fÉðýÍÏg–ÂWtÃΨUÝY' §Ï^†Òj_°ÞÍýP¤îâ ŸÍK‡>O{¬ÛÁ>Bvz/èý·£Æo+¥Xendstream endobj 4879 0 obj<>/XObject<<>>>>>>endobj 4880 0 obj<>stream xµVmo"7þί­*…$Å»@ÂQzôªãzQN¹T-´UUªÈ¬ ëËbom/U÷ß;öîr¼,—|)‰¢0Ÿç™ûŸF"üiC·ç~ãeãí¤‘Û?záûú¤ “9t"è}×&½Þ+˜0ïÁ$nBùQ¹Ír;áO–Ð,ã’M›T‹×bÉ-×0Dã%˜„fÜü%þ&Û•iszŽ+Át*˜ž>ùÔˆ ÕÆCXyÈçÒ†H¶¶0„{eEÌ!Qk° ª9õÁ¨d°~žËØ %  OšnjÎÀxB®Ô#/be™V™ÔrX msšòH%Ó85ûÄcK꡵ÜÞñ¹_q½±‰ ðöš-µ"¢"797nÏÒâ”S yR­´:Ö…†0%%ã9U<7Vç±Uº^†?U±ÊSxâÊé¬ò1TÏè‚ãzš"ûÚ1až·ËE]6MÍú.ƒ:-Æ®nÈ‚Ûû¢‚ª¢) Óº¤BȲ[BuAƒ¥ØlÃOn;®»ð⌥Xw(¬t„‹ðHÊÒëߣ×ã±|IREÙ˜iª7ÓfÀŸè2KyP§Z…¤ ä¿…ï¯À}C Õkuºe‡6±-Š"®êZÃõŠØ“X®&?Üß"†FW/~Ùv ˆß”HxÅGØ9ÅBup³ì ŒYäÀEôÑvšµ°‰yóÛm%EÇu15:$› {ã…ÅN+‹-Ó|%Tn`F8i ”ˆÀGÅÄ|8‘Q˜Ò æ:tå@ž–G€14&ÎâªG…0WÚÿök.Ïö0Îrk±Ýh&ÖXòt† ,Ž: |=¨Žÿ2([évql²æë7.8¶¾ÁÁ3 Ú$ €K”¹·úÁ›ªóüd{}'$§úÎSÜ.Í×J°aX› ÂÐÄ Öº!¥ÄjÒì1tÜK[°ÔÕ[¹0PZ Æ˜M‡¡y¹O»Z>¬³É0˜‹4}È0SÒ>»%áb‘ØgöëÕ>‰Ýiðã¥`!¦©pÅ[æ¤÷>ôµ¦ÙƒË»Ãþü® ýK·¹Šˆ‹òµðJŽR?%·$¼åXÏð@œ±¯¿ß±êNRÞ Tør}µªƒ}uþïĺ·ÁËÿ¼}K¼û^ŠNJSò­ÍëѦCéÃ/Ú$%ÜíW¿vr(Ô2nxà ü@W´˜‘Ô@nðmñ-äRàu‚Ö{(¼|ËÉjîMø¶1Çí½8óSIóÖî6É×€~_ŸKßàN ŒÏòÅu´³Ù¥ĬłÄ)5¦œ¼5;*3!Ã1úœ{ËÇÇác9£«+ãà®Â6زÃÑlx¡³<µŽ:^©»Rœn£ËËB¶¹VK¯bÉ´_^TèŠ\w¯¡wÕwxüÇíM«C"x§â|Y >GQž­WÅÚîÜÅ uÓ8çë¨Gº|3cÈNïÚ™~š4~iüdÒ[»endstream endobj 4881 0 obj<>/XObject<>>>>>endobj 4882 0 obj<>stream x…TÑNÛ@|ÏW¬ÔJAœØNL‚Ô(P¡"ˆQ_Оà+¶ÏœÏ„ü}gÏIi U•ÄŠ¬ÝÙÙ™¹{îø4Àǧ0âoRtžÉŸDÞĽG^D~z(˜Þ ú—þÎ4ÝtNãÎÀ ÿ÷ÃÏt“§n fn¡‡0)űžt¥F ÷]àÜï;³åsƒ€¤‡ZhÜ«{RU¹J„#W<íÎíÒRAÀRÊ‹k†J üyÛ³…ÜÙskäšea%Þkåõ>ŽzëÜD˜MVå’càœ í,i-¦FLæ’³&éúì;¥:i ‰ü»úÖìvŸQu;Æ}T"j:OùÄÕ•LTµÙÕÝœ½ùÝl6½½Ì¹G§2×+NôÛÆáùÛ~ÿ—Ì ñ´+#Á®JK8V%”o|| 2¤à·’r^p7|9^ò­ÒýDðì˜>úʧž§Ý“ÙìOÍñz,›ÚæíÈw¼I†?z£pD£!n¼ÈEïÇå·^à pÕý¡3wõ‚A[Ü;jGüóJ "/ pŸGEÜ|wn:¿‚Bª^endstream endobj 4883 0 obj<>/XObject<<>>>>/Annots 1931 0 R>>endobj 4884 0 obj<>stream xÅZkoÜÆýî_1°QXA¬÷½[\Ù\X©[«Í¡H®D›ä0|HÞßsî3—~Ô®!ˆaèèðrÎ}Î _ÌM„ÿæf¹áŸ¤|Í"ü†Íù׿~z°ÜÌ"³YofKSšÝz¶@aÞ Üjå¸Ålc6Èí,Í~1Û+NÁÒÌ£íÄPc°‹íÄTc°›ˆ‚ü¢Nìr!‚ ÊP‚ͶŠsv‹HìV[rh§`i¶[®ç¹í‚KD;ñC€ @¯é¤'5¦“«ÙN³ ƒ]Ï)(Ø* v1@žIë½Ë×<ÚÏÆ!jÒ¦p{®Y…Á"¶KÍ* v¿Ã²êÍ —f±˜®«1Øõb¢JãÒ,#5¼Ù9´sE68 H94²ÎÀ*ì ¬sh´Ý/‘Úµga Xœu/5à€/‰‘Û¯ÙÀ9¹òjôË™[ ’rkFß“Sìœr«0X4" ¬Âˆï|?a5fô7³µ²u‚WC ‹BAðÀ =©±X'x´u«0$-×,5Ï:IȀ̑$ H¸A‚'5ö’ë$¶NB`†$Ìäß³ƒE™ †žu‚ѵ<–L¬ *Öì|K_«0^,Ã0°ƒ]-ÙtÞëCã\ר®êJvàv[îArNnäÆÝÐR‚œ\éÝ‘]I¥yVLW;W-ÎÔ¡`êÙ-ƒXgº'S¾äLF–[LˆÀŠ£«‹/^ KâL€Œ.{ !æïâ•J„D§r› œ‚xébG5ÞÐ9²÷AlW‚œ#Ã-iVa°(#¼8Ø*ÌäD ¬Æ`7*ö¶ƒÅF¥ß¬1F,Ê™ñ¶ƒÅþ2W¬s1pÅ-î Rs/° Ã]d¢«0$Gk†Ê³ƒ]Nm5‹ ¶ ƒ]³¢«0Ø-§¥bv»‚áßì‚1wEŒSR €±PÎ"ºx­'5f]pÇW¬Â Ôžî[…Áb«…¤À*Ì@I=«1CÁÍ5Øj vÏfW¬Â…LéÀºPDCSJˆ0Œˆô¡Ž=§ œA^OjLW%¯Ur‘åq.ª1]•@x[Án‚B±U˜ Â#WP%®.qle HšðY9O—&ÃŒ•H³ CRÄEƒ­Æ`qèÄ)]4ˆ`…Áb`®5«0å¬R¶ ƒÝsV(Vafs&°ƒ•Y¡X…ÁbŸÐš]q`u“„Ù[ ¢CsdjÄÕŠCH± ƒÝòt¤X…f¶b†»Øp5«1Xì ;eë$o†á7çξ$’ƲK‰«0X)0Å*ì%‡7;Éú \bP7žÕ˜’7 \`»w=ëîs<Œ A‚œCÓ!)æÀ* ©F«0âÆ§X”ÑrèI°›l]Gʺ Ó–3E± Ã!þ\±ƒ…žµf‘"¼ §­Ë6Y ˆëòé­gÙõ{Å.çL;OÏ´]®y/tˆ¶ã†€æ…­Ž¯§6¼×¾WAÜFy œ‚˜RœoSÆÐ])’©šãʶÅz¨ˆÝ¸ž‚X¸ÉýíR}/͵9{¹¬›Ë>-lð`»0—©|TˆÌer2ß›7¿¼üÉÄUjÎýpùN½D>:ÈK OPÖæ¥Õzƒ—œ¼¬ºÆ¦}Òå¶šZ†åç/¦§[„?¥'oÑfúü§+ñéÓ9µž<ˇ¬Éª$kMgMw“™¿Ç·±)±v‘M_ô».ü›§¦¶yÕeM{ëœ?2O›&>Ê ±óûŽJnÎM,´)ò«&nŽ_—‚sw´£½Ž¾m÷ü°îE\Å×Y:.Ú·yum^Ÿ½¬níṳ̂Ù!î‹Î±¦Œ›ö&. <òG¨ªóªúî¥O—CØâ¥–¿½(W;%röüC’Õ¬ýò*)ü—u‘ŇÉM–¼hºc•q}Ï!ûBþäþq¼ÓÖY’ò$öÑ”>É £ä7•÷yßv¶Ä°3Oëºõ¹ö}aJʕȷ—ÔFæ"=Ë›,鬛6aø_ÿ6u!žŸÎÛÉëå,Þ2«:IÍ÷åÿ^Ö$ñmwß0r?W¿©­/0Úr¸Ü»Ë7høî} ù¾ts`LëGƒä"+msÄŒåÿñGSÄǬ¹gMÏâ.Ó{Ò0vydH°sWN;h“Øéº®É¯úîÞcöÔ¤T8n )\µ]ƒæB6Õ^jìªnl5]~ïº$nŸWÅØ=®›ì±íqmÛîqˆ£œaòS=¾BÛËO¿ç¿êÿ®‰ëùK V[kpR³¨ä­´Ïù§ ƒl 6øÙÏÏ/1tªëÓ³®ç ÆM¡ñ˜-Ó}cÕ5¼QØë"îPà%\“CðÛ“×î§·?°è²æ'‡Óe*tômV lYçJ4¨sJ{©ÎQIxÓMÜš« ³>¹Ax*co‡‹¯<1èâ¾êrxnK®lƒ³¦Z‘á ƒ öþv Á’©u×ähûê‰ÁS1Æ;BÇ û||à™Ë§¬:yãÔ „«I:œ»ZË— ñù#W‰ÁMsÛÆô ~‡1$pËèŒúW~]>Åà¹Ðc™µ7¶/RŒ9tAœ²[½ë+W„"‡ ê—Ĭ.°y9me ã4dÕùÀžœ”ZeÝ`WO2k²@ŒÔpµƒ- {‡Rÿ3Må›Î/¼=äÜÁØÄ!32CÏ^à»#n¢sršà«N#ß'B0︌¤P]aÏ–oxF\ÇLàjú%ïÐ^îwãþ?Öu¸Êz{ ªo€—Üׯ¯l}Ôß$2µH2B‡“7>4×ï"¢Ž“÷8_|äæg#u"*Ôu %™ù üëÔè´ÝåØÕ®³Š»Xf°ÑA²ÌPk(¼rØÜ1L¯Ž§ø³ËÍp$ ߨm_ó@‚  …ðÿnV~ÌO‰XÉ)îëÇáA™=ŸÚˆt”[bûƒEÎÜGfæ{¸ÅHé‡jñZNýâÌÑ쪰××íì.O± ~¶'8Äë …a²ø×´ÃJÓjr›«ÿtöÂwfü£Ð6¦¹ëÄð~ágîë->•SÕóËÿ|ð_èÛå˜endstream endobj 4885 0 obj<>/XObject<<>>>>/Annots 1934 0 R>>endobj 4886 0 obj<>stream x¥XûoÛÈþÝÅÀmÎbô²ìíI9wn¢ö @°"WrWÇ]JQýßûÍ,¢—CK†ÉÝ™ùæ=»¿^ i€Ÿ!§üçƒh€/ügÈÞ¿¹¸žDCšŽÆÑ€rºFãê%£{¯9 ‡Ãèzoq4™‚f2#PŽ®o¢iõƤûï9“ÎêËÙS,éÙý€n!¶ ë)MŸ£éô†f‰àÐ,î•k·V±¦ØæÑ<³Ë¥‹¶i²Ôž~ûnöx1 þ;“QE/ÿá·g÷â ê°Z½Ÿ¬×äWÊÓ|G‰^¨2óWø i©.”× ½úÅ™rN;Z©&c©¤L"Ûs›”Ö€”RG¥)t&Ô~o·‹h¶Ò5¼> {,§,ý&†~TE, s †;*U,ÉY³‹¸ÖÆ "bIävãÖï™`Ù…V¾,¸fSí¢CP™³äÊõÚlå`0é/@ëWج–‘Ó±O­¡mêW¤Ø„ú«Ê×™ŽèFôå¶«4^Q¡-ÓB»ŽaØж֯÷QK¼¯ã•6XOÍRÔNFt‹“+ÂÇÚó=ªT þí·>¬X¾±žrX\y[ìha C>»ÞÖtƒÄŠU?¨])¼ØMصµÍ9¾+\ý$ËÒœ Heù?t‰{ß,?KM£©[ë8]¤ˆ>6‰Xåó»wï#?0À]–½9‡”÷ðX‰¨‡v¼È©#Êè†ÎoÍÆ"üríW6‰è-‡,sXe¯eºÑ&Øô‚`àu¦0xÇYƒxâÿCB0§~÷rê@bë+Ç¢ÌÄ[ “m•ñ`c¢Å‡_Þ¾¡9"ôȧ(#ØGIºX Ÿ œ-ië®h‡R×)ö©,c(ë <™ Â-¶ g'„(âøô9%¨½ˆƒsQ2¹åÕWÏ^}ÿ=mT‘ªyxª€…Z¯‘U’=Èua׺ð\8J9}^jeÈù z]„eþ?‰HŠä9@!Þdv®2¨iœs2¢¶Šæ­£Bi”º†m{¤Ø¬‹ ÷ÿ f¶‚Ÿ*¶HœLçðš’ ÀÙéwkT ãÔB“6eî¨/ÖI46ÂP:ÖΩb÷ˆ¯»‚ðžá(€ƒ «P¼ rp9Æp%Z‹K4ñÜv'±Cê >}#òæÐwilÁþ縖``‘!R‚šr«  ¹Ž×N.»@ÔM¦ÔkØ)çFâLêS•¥ÜW…ÍÔupº4¾”J€pc~Ä,Ð 9Üöœ-Ó‚«yê;ÉTKn®H(©ÜC4Õ&Ù¨¬ÔHÕ‚[ ÚnXZ (ë}{¦«Û³FzÇ^ §Eýú]w×[[fIÛ¢M–é%¢¿(¨ßhbn“¢!752F¡8Y!³Ï¥ÙT’ŠW¦©{ªhÜæ¾)¾°[ÞŒ]&‡B#èy^i“â©_ñ¶§’ ¹ZS[à«V-R% B¨ãý5Ö¡—ÖÓ”´À¯Ñ;Ì"[DGG¨Ñ-È?ôn¸Š‹)èYÂ^¿{òˆ2Õ ‹M?† ¡8ø«®W'º@­KŽÌRðÄ# yñˆB’ã Ž šG(º‹Ç´<âœx-(ÂP»'¦¢ Ë$ÚŒ÷àœs›ìNH¡ Ä,Rƒ^õï#pBQ/Qá˜â‹2> ¡ªÏRÕ>©‘v¨êE¦Þ?#ŒäpÓäÞ¹2¼ G…*¡söiÌ3íç_üóÅËŸï>~~xÿó¿>ÖÐØr²üêC»ØQ¬K<ûøðú—÷/^¿‹â½Å“Ú¿©ÜDt{ÖÃ= ]•‹×Å߯S±ãiø U+«q¡žˆw(þè;mGQar˜·ç˜ð=Âi&M7= m Ù[”fè=Bn\h„˜Í¾îê{ƒg2´´âä›V¼>cÅ=ñbO¾×hΗ¦Ì²Ëv F2/.a’ËZWŠÑ¿1Ö'L¹YðMŠôW8“ðÆšäÍ)öÏÌ<|kš9묿®å¶‚ÏFLVcxg{–[”F®ø´‡k—BãÖÁ`b6ýMqàüÉ9æªÀ­nd*(Š Q`øåQ/¢{ȯ®À ŸñËc —tA;[R¼R÷ ¦˜I3›W€¤Aõûáú¤ŠœO=é ã?à„R:ºdÚËš¹T½v/ü€YvüÛåeKò__QueÕÞ8H5¹Ôü\1y.çøûp‘sn8h¹r‰:6êKŽáÍu4ãÚïFް\6ú#\øÝÙ¸lŽ`¬îÓ&Ñ5vöo Üðy4¢»ê€ãõ|`Ý;Ü_¦Ñx䦷Ìêõìâïÿ°Ð³endstream endobj 4887 0 obj<>/XObject<<>>>>/Annots 1942 0 R>>endobj 4888 0 obj<>stream x¥X[s·~ׯ8aìˆr$šwIé¸3©o£6IÕˆiÂLÜÉUö,V2“éÏw,KSRœÚKØs¿à—£ ñwD“9ÿ‹²£á`ˆ/ü߈ÿûþýÑøòr0¡él6RF“éÔŸRº9 Ï€ž×@ƒsFÓáù`BG³Á9MG—–ód:˜¹“¡ Îà|aä\ Îà<2gN‡ƒ‘ç<±„œ3š /¼Ì9< ž­æÌ †°3ÎÛSÇŒF£ñ`ê08·g(<±  ΀^ÂùtÂr&—6ós˜fL!t8¶-|&4ZÆsbÊð RàÎ.Cÿ¶rÁ$„ÚÐËwCº“Åšfsšƒd>?§El2fH‹¨ÿüV܉¨È+Mý9û+=*ûâaB¦ûâA¾xÐÑýúë#šZ`WS¦Kò²>\¥°Ð÷h«"M»þ°'¶¹ ¨ÉŸŒÛyšü,Io%õ¬†=Ò»Rf¢<µ_Y1ÿâi”šªºä„48Çå&*ËcZ«dUkI¢2€×ŸJ¥F:xº­¸˜u>ãV0æä)äéZIÚµIQ‘¦2ÒI‘€wè æW¡Èæ-Xá®jN£ŠD'Œt,J÷‹W­"ö™ŒGŽÑ)’ä1ƒ–äBêØË‰u ºâÓäàë¤v}á¥j[Ôi Wä‰cüY6012êš,¼ßÊ^R$L…îm˜"}3TÍ6ÐV¦%p×unF‚’ŒÎcÕŽ¤~Íí·¦±õ ’÷ÐÖÉ›5í4ëÓ*-¢ŸÙS• ~ÐwÒ_o…†Kà§Sçü òÊ&šMº®ò>üðê+­®àvE&Zš²q\°¥‚©J晴z@שä‰VI[ÍÌö@¼A4;Œä‘•©9’€+â²*Ö³­j£^‚†ñ„6n]+ؤ¨Îc¬rÙÌbÍ–Â,Wë¢,S´D0­§þ¬ím› ÿueM^Ü-5Y^8`y|^ι>4[Gà 3\]¯e?‰j—¡ª$²= H Wr÷oN¼$3¿5Éf®¹#cS‘·]Òjè+£¨µýÒÖ…7§ã¼ûm‚"Cø\):–†VpÅaØ obJ‡W,’±8¶Ø‘ª@®ýyᡨŽ"¡Xc7×Éaf.‰®dº9šâ²£š‘žP%Ê*´ÓÌ«½owΪÐð–Ù¸¾œÒ쟧´Ð×y“¡< ƆÉ.ÂÞÛUê…Åh™á²j›š ÜŒ•~-oâ÷bW6|Ý dow.\öm¦²%¯zW¹¾Öª‡ÍœÕ Ô«®ù¦ÇÌü ÄÁš!´ìÛË“¿t557†ñÄÝzú x(2‡Mo늬Pò6z&ÃŒ|[JVuª¹·$¼ùf2N„ÚñXàÕØ_>Êz…Äí^ã‡üy#¼µÅL·BmFÞ¢½ ÍÜíæÁòŸ|Tþ&—}4SöñJPâvíz¸ÔyáqË[Õ @ŸÚä™~qC$&k Ìc¸þÔ(ÛÀY=‘VÅ“:¶mÕ³ü]êOÓk·6ï@ #Še*7˜§Õ)\„‹#Æh†ÊAf`m%¶6, Ý™ØÐ‚„µ©?uÍó/kkiÝojáÒ‚µWdtë&[hfØëƒÏ§ØËóc=ÏlakîP,¤mf+©ï¥ÛÀô}ñÙgfóîòö ÏõiŒë&¶¡¼Þû}ÛïõªmyÍô°½¾«äÝ+Ì~l&‰ ³ÝËôTÅê°ƒ¦–½\Ì˪ÀÍ”wØûmàË×_~i4<%\VŒ³²ÚAisÝÚù1fÞì3Üœ¡ ¶ÇoíRöõÇ™ØÔÓ€Þan»èñîòÜùÍwÔFóhã¯a±¾êýèUXöÈ3‘ã/xp}s}£Õòä§žéã¾õz>R#%q Ë¿¢§rs7/NM‹‡  ÅcN`«é`¼—úÛj³ìƒò·ÿu̺+’˜n8¤É€ß`·K÷Ðéäæ¡±ÆµsclJ|h³vµ#NÅV3LNúíÉ…äñÀY¡.Æ×WßýûŸÿxK¿uÌ$ {_~|“¦WæagÙï9êÞ)½ÍµÚ]0ëUïõ ¿aý׺Cõ§}8hL®ŸcÞ?ÇxÆuïjÁjÞ€Fç³Á|‚ÇØ¹}äùÏÕû³1FßQí[óEPð” ̳sûÀˆ7Ü1½qË?=¹Ëãßñ âÞ˜n6ÄéïáH—ñü’?½]ýëèwj†èRendstream endobj 4889 0 obj<>/XObject<<>>>>/Annots 1944 0 R>>endobj 4890 0 obj<>stream x•W]oÛ6}÷¯¸ðDAÅv§Í°‡Ôi‚ ËÖÕÞöP#Q– IÔH*ŽQô¿ïÔ§“¦Y8•EÞ{îå9促 ñ3¡ã™ù ²ÁØãó11®“Ù‰J§“7þ˜2šŽÇþ¬zJi1è>ãíÉ£ÜXóöí²hQ嚎®ÆôÚ?¦eD§3š½™ø³Ù-C»ì˜–GT”wiÒLãÐ\æ´Ð2É×tÍõ­Z¯¼ÕÁÏË/ƒ1N1+Ĭ—iz“Bê•7ä,+R>Ñ»\Ëí{‘äú—á|3Y|^XŒáêàS1© ž\ø^$!¹)+ïã-“*fé…ZyåËÙš‡ËmÁýßÞ#B@Vq~ar=iƒt+|3ë]yŒlè‡ÓãŠïw¡9é˜i|prCQ ;Ôk’ëCxÄ4ˆ¹+15QÄÒ Û*ZóœK¦y8¢DJ® èäž“ˆˆå[ba˜èDä,mg+2£’(á¡_±2=1Ä.c®xw“xTJ‰Y6‰ŽmÀó£ù«WT0É2ŽŠ‘+$$I®KÔÏ<Žh'Al"UåN·&QÄ%Ï‘³°(M:&ˆC”w25QDœ…#Ã<´P+â“CÊÑ#>µü±45`ˆ»ÅŸÿÔM"`9ÝqdwIeVóŒ|,BŠ™ªhpdicHN"ïÐa¹2a6dí.L$ØhÞ&5‹Ü¶jˆ¤\]›z×ÓD‰]PUøÑ<Ã)ˆh#[­Y#©ŠÒ§|Z)Jò^N¦Íêu(HQÔE¨XµyF¶ ‹M²¾¬Þ2Å?{‹²0[ÎÎC XØìÒ>Ùˆc#YQ $Ç.Ö¹g2awiUQž—¾JK®|ZÆèü††éR4p™êº[ÛĆ2%ýü½ 4ua]p*‰´Ó$W7å/©ý%ªÁ®&¯›ëÌ™?¡Óñ¬¶ßÕW;§(õ˜ÉÙ©?;>¥ÉÙkc®æ¨phn—"(3tšõv3×:Ü<1òðÌ ® Sº¬® ŽU•¬ýÊîqh!z×̳ËOq­úôÌžUß-þªþž¶endstream endobj 4891 0 obj<>/XObject<<>>>>/Annots 1950 0 R>>endobj 4892 0 obj<>stream x½X]sÛÆ}ׯ¸ã:#8‘(~HÕLYv•ŽlÕfåéDÏ X’Xf Åéô¿÷Ü»H€´3}é$“ˆöîý8÷ܳûûÑ€úøg@£1ÿgGý^Oø?þχ·G£þy\Œz}Êht>ìW¿Rúx´ûo/¯zW;o½ '°…µƒÉoÃ/^;ì÷wÞG£ÞxçíÏÓgÄ#7§³7}š`ÑtFc_ zãñ%Mq¹OÓ8"ú`˹>y5ýí¨O§¥&îúP;ª ŸnßÒ\çÚ©û®:ÿßÃ2žr[_ê˜ãNNĹ:صá@8Z§—©Š5¿m§®qye\Qª´ãóYûë(×ë?øÂ®´s&©¶©1ÖBev¢/&ÿâ A Î.QƒB÷hºÀ“:üYz=+SÁœ·À¼}òq¨¥×Rè&$5–Ìff¾(ßB2Ò ãÿ¬Éc뜎‹VÏÐÚ Ê ƒBoÃoS¨<Ö»ü Ü­+ÆÂSÜÒÈh`è>_öûxÁ|–ÐÌÙŒLák,3v€KãˆBÿ›ânÕÆ ‘pN·íXÅ\¾†Yá›z­(œy*‹½Ö5YCfd1.PzéO/Œ† Æÿ¹.fÅæÌ•Ãao4·'Ñw•ßю忼àÔ€ˆ+Êã_íÝ„q‡#2¢Û=Ü_±ƒœjÏD¼ÏÃÁ‘Cë°D²M“d d€õí ÕÑVìþ «¶ýiÓÛ%wBøíÈ£ƒ›‡ rW5£Û„Ü6ü¨R:^:¶+÷¤æ€œMSø/W˜–ò§rȆÑ1gOò¡œ_¨45ùœ?jÇýUåIª?èY'ÂoØŸ6qê ˆ5VpÆtîKdžØpž@·Õlòy®¦*dzÐiB%œLÅ…2ÏTŽ0ءƘø)ÜN&no‚a¨U3} szùe‚ !‚ ØþÆwá@¸¢èúOdót8é­G\C·ò >b—rúdòÄ®Y ÎhcKD‹fÔP‰kF©hG|¯è¹yn•Oç6Ïø3öWÌìn³ & –ýw¯É/l *b­Êž3ÀÐàÝìfà¹nJQb¡YçšÒÈpßSš&ueÞò¿Yý¼gù1ºm±?R‡0^ðàISúÌb:|ÃØ¿oA˜X ÝB *3cRo{+"·{õ"Z[÷…¿ô÷%ÀÈrJeÀ_oækì5/”×!h”;“¿ýÔ¶¹]¶[m>-©²°˜Š&¬ò™™—ý<«1WùL\K°°TƒÞŸò P(sŒ±Z,p°ÜÍš§vYNHòŠ}X£:Õ°¨1 7ЂA#iàxØ\t~³ÿn4`ì ÷2&Ž—ªXˆËgo®hpŽƒ>ޱLþ3‰W8z?Xƒ6µBzÞ›LøÛŸ7µ$ ]V8Þö޹+6ö}@Ûö˜Rœ+dÉÕ[I·AraÞg•À£ y¼JC­ŸŽ]8WË”Gh ó©búÏû›ÏËϼugãv¹IÐZ…¹Uïd?PZ§»A¸P¸Í‹ûÂuÌ7«3º´pP^ªæJƒ Äƒ‚¹R_‰¤v¿©î÷ïo_¾}7ý|?ý°·sGfˆ†€X £>C§æ HªÉ|Û?PìlcC¡ž»žÐ¿«‡$×#ì®u—4{ŒÂ_«ÇW?¯·Ð z~Òë=øs¿üäœÚ|zS9@²bdµ`KœËñ=ï7.¤dyèXÃãë³ë~²ªº N…ÛjÐVC_‰ß¾CWÃŽkÆA4Eia’/&àT}]€ñ çß(:¬[F¹_غ ^&XJ¿Ê}ÕV•F5 n¯:"þ®Û}œ9|ÜZ`8¤³”Óç@pLä5ù•¸—réF¨z«µqŸ&‰â~ɬ/XÒâ  ÎEá䳉*»Øt޳-Ú—„ËJR&| Ï–/lw†ƒ‰ù£XB©r¹©ýÒK•<“…ëz¯Ô<9ÜÂÐýÙm¾²~]zq¦!6 O–&Ïop´âÈúÒkˆÒ‹Ñ/ú=ÜJ‚üx«Ó!.=_Û¸d­ c‚¤Ãǧ—¡sêEÜ Á½06¼ðÊ›éÑßþ ‰Üendstream endobj 4893 0 obj<>/XObject<<>>>>/Annots 1954 0 R>>endobj 4894 0 obj<>stream x­X]sÛ¶}÷¯ØñLåT¡EÉŸ·7®w47IÝXiæNÔñ@$$!&$¥j:ýï= €é8ž>Ü8c›°{vÏâìÊ¿Ä4ÀWL£3þŸäƒh€7ü-æo~:8?‹NèìtQNq<ˆNÃSFwíg¬Ž.£óöê9?/O¢!Îû'>Û~Æêéùn¯[m=cõ<Ž.ƒ%·ÚzÎi4ˆÎûáÕ§­8\0vIÇ7—iº@Àg4M]œš&½ø2:‰bš®$Ý}šüDcÖŠmI™š[a·GÓ/Ç7'c7Ÿ5¦±•¢Âní+£É§=Îͬ§E½ü@ê?1ÿþûÙQgíüx×ÎÇ})+UÉ|Ö}Õ¾TÎ!íÿÁ÷¬ÑÖ²c0$$*,|ß»ìÁÌc{Sþ7¼eÉ1~Ò\*3YÉn"¾mæ®eYY³ÝgfÏÚ+—þQtvvΙâúo*‰}Í~’›_j.îÿ‡ùVÎ)çàšZïv\·ÙöëŸãÁoDýc¾“hÇ®êÓänë²TKíIÞ „«®'YN¢D”Õ¬7;êÐý˜Û½zz"N"œté]Ð3W;%n’ÒKº=žèµy‡…¨3Ô_Ê…-WGléòÓÖ‰ʯ,´ÎR™¬dy1Z‚™ºJL%‡Ï7l³’¬ Nl”Ã’ ’@ÅòÌW¢c¯!Èij!¬ÈQÖD U-ê îêÊÿ´47Õ*¢O+éÑî¬C³‚Ç ~o?°Œ›¸ ÝN6 ŒÉªÖdM€—¹Z²3@ï Y*èii!ªdåF]™\T*—-tÚéuJˆŽ¥Vâ²ÀÿºƒÈ;#šø·ž—}°ÀD?@ƒ Dí:MHÛƒÎW,Á|'“ ,1…r ©éózÁMäøœ1Þ˜‹TF46Öʲ0:…ÏlÛ'õ-€ä<»£¨…}Å›‚}i×Àô˜€r.’ç ¢Õ¶KšÄ‚«ÀdÄVVµÕeDWT‘¶èQ´ˆ¯€qOãæ‰rWë=Ý®6ÅTfi´“8¸ãÂá Õªœ€–atãÒVºÁeà*Î-t£1ó/èí”Öü%-…skNL–…–߉&T‰YK»’"¥DÔË|ëóaŠ-[a¶±pâªêµQH ¡€Dâw-² Ä¢pJ•"¥…ÒšÏ0ú.Hh|§Ð[O•eønáƒË?±jîŠÍÓòªRº ¾A›Å8†ÙB;`<ä@EÜ©²v©éã¤Ï¨ƒðõu$í3ÆÅj~忯î™ý@%,®(Føzwwý¾‹ŠiVïà². cyÄ ÉgO­Þç.ryŸ@_m)¿ºo͈¹VÂ;yûqÚ§Ÿ?NñÓÍ”“÷xpð›±²Ú2Jý­¬¾ÃHlÌ Kir(‹ÚüäÄ×7Êd.PMfÉïdçù™jmTJùÖåpŒªò£ÐËÒÔ6‘î-õ²v)«ÖÍ“O‰ÖøÑÐð %޹K› Ì`Ò¨QCnÞÇBE»”4­ªÝhš éM¾Ÿœ _(du*éð‡!£˜a0»¼E•æHŸ#úÓÅÕŠô¯†„ÇGÁð»_ûRù'8œE£!þ,€»=<²7Óƒ_þ£ iZendstream endobj 4895 0 obj<>/XObject<<>>>>/Annots 1957 0 R>>endobj 4896 0 obj<>stream xWaSÛFýî_±ãN¦¦1–ÁvúÈxšœ¦ÈtÎÒÙ¾ é”»“O¦ÿ½oO’‘(!$ÀØHºÛÛ}ûöíêcgHüi4æ¿(í ‚îðÇ?Þ¼è ÃapHáQŒ)¥á~„ÕUB—æ5ž‚AãéoÓ†AoÕ,hïl@GÁˆ¦s 4~6 ÆãCšÆþØM£=êçêuáúôJ»ɱ½î½ÍR‘‰…Œ§›\//Ž›ë÷*sWïéƒ0‹°¿3ýÐÐîçÄ<‡°ßï]ïüÂû÷Îö‰ Ìi솣*€Þ±%‘‘ü$Ò<‘¤ç” kU¶à»*Ó…#Á.ÑuO2 ·”äà•t4/²È)ÑZ% Í´[’‘"¦¹Ñ)vÇ´6Êaµö›¼•ë>E:³*–w•¥“:¸ƒÛštKáÈ®Eïh¡V2£¬HgØe"S™9 ÿ¼éò¹?Àþ\ÛÌÖn£r÷VZÅ”n<È—°Ž €ÓO~ë°ïA+/Âò"C©ý„çzݧµ¤ÈCf)"G—ï&/8öµyêló oOT%E,©[FòOŽ˜bqè‘SΑ¶Hn¡Nu\€&Q’P*ÝRÇE”³DEdpøº7¡‘úêN ès+2®¶Š´“ó?_ÿ~´òZôß0ÕÊd£˜†€Y p¥Ie¬„Ù|KàWÏ“d’æÚ¸ë^·rµÛ§Ó̙ͅ†Õ_»'—œáŽwQúwâl(?Á›ì¯&YŸ¾]]Àú;ç=JÇè;û>1#OwÃ[9{FCHF-gµœ ŸûÐéW¥¨–¼²TxEËU–AÙJÂÖrÈb¸ìsiMñ"±šr œé¨`lÛŠ§¼÷S >Tª8WŸH¡JæÄí V<=sÂÛˆ•‘†œ³Ï¨±©ï¥²šyåõRQgÄkbc5‹/ëI.c:Ù;yút«ÁùjÅ#£E´Äù+¬¤¥LCpó ÂîÓ b®¥â¼-mnXPùÿ…03ô!¬N8© ›é–/¢ÜWµ¬ª3èÙŽŠÕ/ÓŽf¢á€—39×(âÆÈð¿Ь.‰VÆý­ ²K]$1 /Xî»7¯ô%â-wj„í–ÖKY‚îâŒNäÖwÑ&|§‘¸áÛ,qï¡•Hi$’d&¢ÎÀp†à¢ïclpÆE$I¢.–[œnùáŒZ,°ñ† BP­ =ÁÎph#‘À’zªôÉÊ ¿´=Ê`òèÉúé»^{U=Ÿô˜q íÉ”ˆlQp*œ–,’m/Ю(‘îG¦«Fðèð·@«Rú0Y "8!œ ÀË7Ì ¾±À¯ä“j=‰á/˜’ #Ð"¤±ÌNÉŽóUN!,ÁžÞå¶m³+WÕÅÙ£DÍ ï\¡Å‚ë9Y!‰%üX ªP‘³ÖúÔ²Ÿíãzg“¿NŸß5î0s¥˜1zéñ(l™ ¿·¥åçÞ¹u™ÍçF®”8ÜG¢?wœ «¹ÃêÂDò˜)^ åhÕ¸Óê[_lÕï$JoM™P•X¢AWqOǦ"³b.¡<¨®FY d)L_¢žD¶ìü0­æ ù­G*ºUÃ*éÞ7}Žn§O?Ì0 ^ºr£@sªó±øg~½åÓÃ`û åɱ¤Yùâ4ÕÞÑÈÚÃóĹÆÄCÑ!0V/Ñ>q°‰£ Ýœ‡oÜ+§ð-&H61,¬},}Y•¾‹½ dÿF"ÿs© uêß3k[Žy¬.G;?¹ò8Ïç½æÚ.3\«J“DøGU!‡ƒýà`t@ãÃqÙEyðÝ ñJõ\GÏé^渀ðæQ®Ý=,ße|³ïoÖÿ Æ E3$6y0£¯ƒhßááˆoN;tþˆøT®endstream endobj 4897 0 obj<>/XObject<<>>>>/Annots 1960 0 R>>endobj 4898 0 obj<>stream x­Xkoã¸ýž_q‘¶€³›(~å…b?L½É6(¶›6n÷Ãz0esF5$eÇ(úß{.)É’ãd§ÓΉ-‰—÷qι—ú|4¢!þhrÉ?q~4Œ†¸Â¿Füëï?Ç7Ñ%MG7Ñå4¾F£ú[FGÝï9MÆWí³|wr1Īfíäf;k»ßsšŽ¯Ûgym÷;îNo¢agm÷;îÞô×þiÞ ÄGc–t~7¤ëhBó”ÆCº„3——W4O|¸CšÇ¢²zÎTLUaE*É:áðm­UBùöƒ1b;Óåv1P…ûåW²º2±ô—O)\rÂ,¥Û]¢B9™ÛÅ ýëdþñhHg#ì”`'¢T½È„^JߨZ>•ÎÌõSÇ.}×Ý…þ;;g`§ûí ×É‘—™|¸ÿë?úËmÔKÂbp_¸g'‡}?Elžèøqú*'œ—7ÿ5¹üã«eÿþŠ+~ÍùÝ”¸")gãI‰ÁO¹•¤\º•NȪe!\e$er-3KÙ–•¦ÒÈ"–ä´¿¼–Æ*]PeU±¤‡óûb­?IJd*ªÌQ.Œ]‰,ã›ÊúÇmÇô¹…S©’¦M̘Á²Y©xÅOù¹R y–±¨¬¤$§V¢H¼ÅRKp ªó1žòú™ ¾ù›¹L”0[Š3am`¦õ'K‚2å\oë°¥FçÞËCÔè 3ÿD+ø)_J;QMe|$$Bà¥0‹¤!·-¥÷¹Ïѳñ8šLÀØdðË÷YvŸ—Ú¸Åà¸Þ÷ø”n g¶õwdzǕ0åS£Ç‹“_›ý=íjz×¼–/Ø»8@ïÚÍ óè”:߯žçÄ7&‹Ãó»M#$ºÁÐu4ôº2€d^ÐìwtûËÒ–ÙAŽ7®¯9¾{Ç.µµêð`2zƒ’t „rÌÎgß~K±NdD?ßÿ@"3R$[*^«D†ì¦œÜ6Ÿ(ÕÈð Ö¸"0'[H¥¤xç&K¾J¢ö Amb‡¥Â±س]‰Ý«Œq }¨œÎY.nðÂ/åý¾d5‡ÎtêyÑæb³’Å«ý-ªÄØdÃzÐ!9%+%y+ý6õ´U ÞÚzûxÓ,ÍÁÿß´ÕRo£ÜŠþÐ&¨¿°±ÊúïSl™py* ã%Œÿ Gƒ¾­j”J¯EÍ*‹¤+DîÑà Ý:ÔºbÉûð_]½.f/!ÞóÆÏ.&!2¨&KYð9ÕY¦7ýYo Š\ßꚤìÊ^S²»´¤"Wä'¸ÄÖb Å*zëufXì ¬»ž?à…xÖë ž?Lž€¸« ÑØó”i£§X…vp4²í±JU‘‹B,» ´FI·eÀ+ ÞFô£¶Ž`Ü`# ²ûÎ5ÛóÀH é·èó;ÙÖx xÇÔ÷ ˜ÑCÝ3 jÒ¤½…S?C:AmŽ¥*ˆ¼ã«mœ­æ€1x¡è[ˆa­³5– £±r??!”Á:SÅ©`»7(µ R ÜîuÊúÔrßS—>/XObject<<>>>>>>endobj 4900 0 obj<>stream xWmOãFþž_1J‰tà¼A€Òûpp¡BmÉ¢¶ª"{oÏÞõy7ÉEÕý÷ά_‚M|„b{<;óÌó<»ùÜ@Ÿ~0óŸ·®f­¾×§›å¿t ½›ôa¶ Øñ}Üsúàwg!ÂB¦ÆB"R£Å\H…6¡ôCðî&3À/>&VjeÀ l˜êúñpöO«wÓ‡soÄ ûp<z£]]»M’ªU ÿr(=æJ‚.Àß·?¼~Eš¼K’Hú‚óOŠ…Ž^O¥ ©Té7‰~/×2À«íߘê&ñ·*À/Ó•.î…Zb³WÖ"’Áµ0ö;§ ¦{¾6É|·Š¢{\`ŠÊoT¹ëó7Œuºm’ºÆtéM“؇­±—‘•q~}:ý2äZh.ó@bÒ÷0(]®bTà—Ç2XåÚ/Ò-Ëý*'öwU,·ën§Çc§—‘7Ÿq·›&w ’àDœDtÁp°À2w_QM]Ƚ ¾NS4‰V«I´XÓ³ë{—Ÿõ9äRöI²–Ü6Z}±YÖÂ@¨ 弿£"¿©—.DF£•R¹¢¯ØYÄhŒX¢K\ÆC‘­lA£}),°!Ãpy°°f³:án÷4Ò)Cë%.PØUŠ@¥QY¡ dŸã@.é²þ²°6•+‹`ÐîE°ã¥Ý»¯W` ’ŸžÍà›¥—$w#¦*@Z4Y=­H¬ÙÖŸ¥kÔ  &Ô«(­¢-ï+Ãȇ¨@0Pe7 ³õü”€ÄÀM¢wsL<Þ¢Ž‡cžÉàÂ;õÕ7sUPj©–ÐöCô?µ·™X$U¨Ýl=7Ý_Ñ0b Ü5¹Ð§1’•×oÞ³l¨ƒ—7µµ–$ÚH+×h¸ÙyW* ´Ç=b:?töM‰³¨Œ уé: Ð]òR%4”¬‘RòYâjw]QD±5e-Nráféø“á^ËVØÑ7«-QH$3–H p®[. šMËuÃf}”Ú4\!¡ [½"-F‘ÿR–$á½|AübиêRó>m!…q@tX¡ÅçO\ôíTU=)¼¡€hÞÖ1qž· £phjœ‰d^&M'ÖÁŠH–8¯9Ûã:9ç]‡ßŸ°ÜüÞæ‡eA-èTP4êy÷`?AŸâªÏ*Ç«[|EÑ÷j”ΑÞ ÙOÛyA!–\"4ŸO“´ ±»ë†™/‘"¹¬‚E`‡‚ìÙ×bä.²×s‡‰É_×Ó÷' ˆ…ŸêÌ·t¥¶@ŽJ'[ßhÒWŽ·©¤éd§Þ'¹*¡=Ÿ+n:C=ç‡Û»?¦¿L<ưN"/¿1?lïOD^:BÃAƒ\÷H»®‘yYÍ×!òRé•5ž0Š>bï%a¼å:3œˆ0ÎÇê¬81‹æò {§’  }§¸Ì‰,UD_v<Ín¿f˜5êÖrºËÞÍy~œŸx§£SŸ{gÙ· îêxèõá½öÝ!Ъ¹p:^eÑÇgsxOᥔºãÀi솴óЮ3<;å7'³Öï­ÿƒ{ 0endstream endobj 4901 0 obj<>/XObject<<>>>>>>endobj 4902 0 obj<>stream xÕWmoÛF þž_Axæ Ž*Û‰“¦],M×`]“%ÞºгDÛ×IwªîÇößGžt²¥¨YöqΫÏ$/R_÷†ÒׯþŽÒ½§{aÒaý+_‹w‡0 aº ÙÉKú'vŸÓ?QÿÓ ØÂB'‰^Kµ„óï Ò1‚4€÷ãÓýé—½ïB8 ÆlgÂÁhŒÇô.îgÅ<‘D‰0òB¥± ñµqèe¬°$t§e ¿©fýÙ~‡Ð"Í 2m¤•wh´J6³þÁp¶ÿêÕ¿'îÝ6Úçæ8˜LŽÙ‹)E‰÷fVjÅÑÙU®×êñØ~S+¡âc¸ðª§p»1Óà,_)*{UØ«ÅPKÜ‘a¯ÁǪHç˜ßqÃík‘‹-æ èïi%Ü‘ ^‡÷aŽßø zë.C0ëKegûÝjaô¦¬Ì)çždKÁoæê£^C‚ö{òX‰dcÐad‰ sAî—±–lMÀ¢Hr¿P1i)aŒ#½pJv“a*2`k‚pB¶—dìüùs¸Ç‹qûéò§‹?®¯n¦%ŽøýíôíùÙ‡p~»yö¹‘—ø"ò%§l”0àÁ‹SÁÕÿà“êL¼‚*·[)¹ 'úÂÎ+úìæçÒ¿[´×èÒSCå¬BѬ¿#ç; 5hT˜íÿ‡WïqXöÐ+¡Úëê6¾(G[äªÎضÁ}+n³Óªçikµû·Ž¥.MH©—"¢E®S«^´ÂèÏTð*ÑåUòWIl©Ž‹+v’æq„5¨¬b¢À©„v­*«Ìc'(*Ã×—¿úù¢Ít^уr›b·–2ƒ¦ © :h±A‰ÇzžC¼ VnÐæïÙ¢íL³ÚO(cY>_Ì2]Øm}‹zÆîE ’· 1%æp„¢HlÉ my£YEiK(—‘%$)ŒÐ‘ohèå΂Ÿ9ð^¯)à|Ò’šï´;cV4,€8/ÆT+2FDë•°àQGd…­¸±b= µ"aÂT–¸r@ב†4bM6ÏCµœÍýg4œhî–§~b÷ÁdI‘ÀÈ¥˜’‰^é§­Ý¥ÌØù.,Å>§IÀYB¡t0£“'OóÁ­]LlMØÖ.i®ÉVHÁÑ à:´luyÔ‡Wx´tžÉ4IÒÎZ$k±á„Ý0΋¦nl«AZ­é»«uEÉärµ˜"Ët^³Š"Ç<ÅX2tܶã¸x[Âo¸ÐºŠÀU’5ª ŸT¡ ¯¥]ÕWÒÄ-ïBÂL3b70ڽߺŒÑÒԪ䞿ð¿Ç$üC™]«r_Ïn—,Ú \ˆ”#‚ãœzi—ä}@müð¯U`‹Œn 5 î±ªÐµCUkЈùZÈœA„€ÂPØ ³Ûy5è¨ß¥ªùÄ\ßʧ¾ËH‘àêfÅ#ih'ÑhW>úiqtߦœ‹äô|ó”2»äÚº&à÷”•‘#ÁËrjÍ;ˆifVÃ{i,Óʃ=¾1øÖŽ…$ñ òqgûÿÄÎtRÑéðä08Á䘞YÊçüÁ(á­ŽÜâNO$Zq²éI¡”>8.§íðep ùQh[áŠW¼Ý¶êÁVŽÂI0ÑCM‹Ññ„.¦{¿îýßÏ&òendstream endobj 4903 0 obj<>/XObject<<>>>>/Annots 1962 0 R>>endobj 4904 0 obj<>stream x¥WmOãFþž_1âE5ºÄÄNHBîE¢\QÑA!-ý mìM²W{7µ×pQuÿ½3»Ù86¹\QEÙ·ÙÙgžyfø»@èôè/Jm¿3ôÐÇݧFütñ³)½º%pߨ§¶{~wcusŒ«aÏïo®nŒqµ_=ûóhÃãQ6ƒãË.mMÑëÞ)~‰³ø%ò~á‡g9ç ç\ÆB΀øB %!šóè/šŠTÌAä R¡5}¸’0e‘nšƒf•MÔšSEÄÌKž1Ü bj6¾4Ž/&ã1©ç™z¶Ó¥“­ D'=¦u&&…F‹,©4iÌìŸö@/z[»"ãºÈ$È"Iªkß*;ͰäOË Úñ{½>¡ôYalôœa`¦ˆ¹æ‘Îa© ˜3t«È1úds#ì°loììGTV5Aq2ÙmʾÍä³ÐsUh$¾ÖÄn"õ’ïÐÓƒ’—ôÌg‘$Èt išI´EfÖ¦<ÏÙ L¤"ahånÙJRþ•¥‹„ûbCx°aÐ=Âï2eMÅ6#%5#C´Âo»ñpŽЧˆÉÎ÷­ÉXq›gsœM¶ˆAO‚¨\ê–`øö].h5ªœEº@/— ´ELäyAäAAYÁS•¡;K˜22Ò3á3! Q<¢çõðüø­%q½•w§@¼!!l…=¢ppêŸø!!P*Þ*È]ºúp½P} ™è¢p£‘k®ÊB™‹µ„¹`7Õ R…©4E1u¦MÒí£ø¿y³qý4S©y0ªr*c‹ÆÜâÃZc’2Ë1ɉû*)¾ç127R&”uÒdi­/¬ÞZš0‡‘ëT —]¡q(·a+·Ëã ùŒ‘lå$bc„ø‰%G±­)±Î–/ô÷«¾¡BçoŠÆ*0ör‡˜Újú˜‘Ò™}†Wµ{±HZÇ+×È4ûϨ|$-u}ݦ¡Ä“v‡B" ¼þÌ}!£¤ÀûÝ·ŒûPyß“ñ.Øêï3Ì` ÞS«X£"cè/Ð{«º9 ¤-ä.\/Jɶ§–YWÓ€JlÙU93J EJäÆ8¢‘"W3ƒ´ ³ì‰gXbPH6$z˜¼ÕLðζDÌnqòôª’¶\üy{s7<ïGÏÏ®¯ÁþG‡É…¿°llá˜NƒÁU[K ƒ™~¼Å׌Œ‰·61eL°¶¤ÍCÖ…—×¼6?¬ñÝû¿²Ä^°êEœÇ¶ÿ¢EÇ- ÕîN„¨U©Ž%ÏLQ3Ÿ)0Ī—MnE9ËA:¾âà> ãrê…մδRÓjüBéÌ]Ê™V….®ÑÔÑúѲÁÀî&Kl«¦¬Hôîþ`QLP¨0¥Q«"KÜ-,uB[W pÕéöêó7¿^øµ³«s&PÇ—ƒU ºþIçzü?Å6ÚDšVè·á£ŠL'l¤“‰‚`w·ú6ί-¿'ø¿R'ÄòU7ì÷ɿōñ[ã_sÄãendstream endobj 4905 0 obj<>/XObject<<>>>>>>endobj 4906 0 obj<>stream x¥WÛnÛF}÷WL¸ ‰ºÙ²“4ÅnƒºN«M+r%1!w^¤Eÿ½gv¹”DIi؆m‘Ü™33çÌ ¿u¨ïõúü$G¯‡Gm¿‹Õ¯tJ­›6]ú=N¨Û¦þ³Žßï_Ð04Oµix„¯hB#O~É<–ïßÞýùî×kÿþãÛŸßKFjzý5ó<ÒÊ//ŒNO‡ŸŽÚÔìÀDhLå³T/éÿXù ó4’ 9òF§/j–þáÏ­›gÔé2è&P7»ç%j¯óÌ?G4ƒGðSbr©Èuãz6—A4‰ÁÈ3köŒñ‰kvÏü3ÿq& ž>=x’D*a\† âœP”‘Ç’rM¡Ìe#rÁ¿$%2Ÿé’h:ã œ¡Ö†}z½Â™‰(âÜØr±#ÔÐ[FqL¢ÈuĈãM¥’©È%:4L03®Öñ â¾ZÈ4§? À%B‰© ÉÆ ¢˜¸½«ù<.SRUu;5^ƒDÆ(#…ããÕFÒplÌŽ)_Íe"æ™OCÜžè8ÖK[ C(šÁžà ¦”ìvë‡i9‹rË™Æ'DŽˆ¾-ÿ먷ªËñç"Rì§p–‡ÏŸë"Г‡T¨©Ü‰6+à9¶Úa@P™V±IBëÆ±Çs…K„ê»Ck5»]¿×ƒêBï¤ÌÎȳéjP ”ù÷egtJ;ðèo6·!-æÜÃà~&Òù½Ì늼J§E"U>ò6žs« 7èqÇ_‚¥¬¸Ýýq{»«¼TæEªè±*âx[•F“,£ö“HÅàl#}© .@ÓŸ“­Ó«­P: ©ÊèÈQAÖy‘# V+#o'¸·í¦lVæàI—~xIí=ÝÈÚÛµæ«"ƒW šÒ¹s\O… ×6·“²#¹âÛŽÔséNCžUàbC©!“-¸“»dŠ™G"eþ?@gß6§~fuž®@ÿ8ÖÁgZF¹é.æƒÔš¦Qz²ggè±L¿ÍX&Òõ_ïß}’)¾¾\ÝÞ’åáC­ŠŸD:e2×+…Z¡Æ|“¡,…xæ˜Ë/1wðÌèÔ˜xaô·Á} Ľk–Ïo`°î‹õLÚ.$2iØC3úñAî €x'S¢ï×åÈ3ž›¯þKŒž¿J•îK´®»b³þm"ÿ†¡aþ—4+©îaú9&†”Ít‡L^\câiüýi´„|æqÄ0–ÌsÓ{JŸ»¤™ëg4(2Œ?ïûæÌ›bû­Ó#Û(Gùp•z /d5zÜD«0Úqe&§âAÄäß]7‚09àI&æóT ;Ÿ0]ƒTòP¼±L_£Æ}!lC÷0Þ8—¼'˜ÉM+]`æ­g´Å8ÕÀf„¼Ú  ”ƒŸ;Ëýðö”FXÇQ%…«M-õ„«œ¶(Û¹ÉL%Mî¹~C¸w{ÁÚV•?ÀþRDH™ÙŠacȹclϸãùUÇŽûÛ¶®ªÑ¹kÓ.r–ü(ý" Í.dDïÓ/z‰î“6L§w,kFUþ* Î#u„ÎKóx½ÎñÖÈ ‘Ns3“I¡³®’’2Ì ör]SSŸÞb•Ì2©VRŠÚgQ†³(U¦Iƒﱦí—I©Ð@R|Ýòiã9,#,ãµÀMýð2xܨË€/o§ÚÃ2€½{EZ@D šh½>/XObject<<>>>>>>endobj 4908 0 obj<>stream x•XïoÛ6ýž¿â­€²&Šãüj;äCæ¤k€ Í0-Ñ6W‰rE:N0ìß;R’#ZvÑ$ ‹:>¾»÷îä¯;GÔÃïŸñ_’ïü2ÜéÅ=|Øü+§tø¾GoâcN¨ß£³·GñÙÙ9 S·ªGÃ$"<ÌD9¿~JäܪBD–Eòå³¥dal‘¯Ý¡ úøûííÏ{Ãvzt€ÀÃqä“•¥¦ÝÁ.=üqóëõŸwŸî‡Õš£jÍc¡Rw÷ax5¸¼½¥A{‹{9Uaj£è[èš•{ôo°m9€?Zýp}”æÁÑéca%Ù™°>¥ÒÊÄú™rigEJ ˆ3¤E.S2V”Vé)-•°ŒùùìOö íÔ)Ö6<Ó¤(i)JÍÞœœÏ#¶U 5TnäÉEI¡ ²‰4ÓO¹™Ž¾ƒªQäØD'ìU›¯WóRLs} W¶Sy’ c’"•¯Â4¹[a!|Ù\–){ƒ@&§aªìLÒàpðúõ¦|Íã 6Q—A)^U[Œ"cKÎD.S9Ú É N7§dC„ V.ÖðÐö-—›b¢UÛ¯€Ö %úë*ËnòyQÚQ´ûcšeÊ]ìîÓµ¶åó]¡´½Ø …¢Üíý½v„ŠÒŠ ïk‹ªcvÑnå·­¡¡/qŸ×Òí:eK!¾‚xëyí¨6rR ƒóQ´ÊÊå|ŽrB º1„S×Ë bí/DmÅ0/Ý5äu0Š:5 ïns´N¢'«æn’[¬¾Þ† ž_uJ¯´b¥¡bu†¶r¼m¾?!Þkâ:ÉAÿ¸jQѲ®¬m¨„«*íµþBÿ Î&t"÷‰‹ÛµîoÖE¤ -Ù˧ÎÆèãç—NRuÁ˜>Kù(Ë}¾YtŸ;žüºP"“Ú’-B`¼ñ±Ï wªbîƒ$™âNAcIðE5Õ¼¿„™áe¡s¡á5h*°LŽ"Ÿd²°2i8Ã¥2-("™)€tg˜/¬ë<¼¯ÒÊ*‘)ãj³ æI„Ðe‰V¥DùL΂cº—L…Gî× „¶¤“_(éîF?_ÚÌø¬™}2ž—Z¢TbœIÀß„ýÀJƒ¼ML1q|V›VåQÅ-¾•ˆ² Çç—™“a•õ–Iœ¤6‹ø×sÊ9z‰™û¾[† Yðq·Õ'†ª#Wb(IÏ݇·ôðšÿ†øÃÃTZª¸ßËK6ŒPÑáÆ‰r‘@”1/ià~‚TÌ„A¥¦´ÐÐfPωД‹/ÒŽgMæ®ÒP]øË¢ÌRˆ#<´ç­ñ–A¥©*×Q [PS.?‚ ¤Ì1Ã8L«žÓ%TÈ;•úà ïÛ§7Ÿvì.LþÜHf \ €-!)%6œï¹ W.ËuÄ7 †LLˆlX0™ï‚×Lè´£Éèö£^–ÓEÿ늙ÒÄt£i"$@Wõ×”†Q¹ÊD™=×33›E=_£DZ )c #SÆb\,,å¸Áòhãð¸•ÅÒ¼ò}a1Ëa¤00C©2('‹‘À¡d ÀγQŸJ³rÙ®V;¢LÝm) ¨/xøDaTííú¾ ]"Y–°iÖøó\æbn'(6šZ^ýn8Cœ¾½QÄù §“ðÌ3?J{o„6uaÉÌŠ¥Þ'0ÁÆ5•Z–(:§7wv\WfÚ³«a€-ךÛ݈³ÔYºÃj;¥ÛõN°´8ß#v~ª±cˆNïåï-Z™œ"§Àˆ‰\§f\¨ °çËÇõM”È#ê3·”'i º (© á6JJ1áÓäz%w wÅïêW¯Úý~||Œï4â77¦ñ‹Kc\ü׉{1~ù Ôµ½£‡g¼çqçÝðªšÅ7ãï˜}[xx}Gcaä‹1vm>/XObject<<>>>>/Annots 1964 0 R>>endobj 4910 0 obj<>stream xVïoÛ6ýž¿â–5ƒ²ÚŠ,'Ž“¶ÖôÇ:`À¶xØ-Q–V‰TI*¶Q´ûI˲ìlh[8uHïÞ{÷ŽŸNFáïˆÆû/©N¢0ÂoìÇÈ~üùþd_…c_ß„×TÑèrFÛo%ÝŸìÇê4 ¯öV_Ïöº¨jIï"š"ä,£8¢ÉÍ(œL®i–ºk#š%Á™ÙÔ¼bõ<0¹’+= „ ÷ßW£ù9i“ÞÞÊÆ<ÈìA1±äôù|öÏIDÃާÑýßÞ?ÜÝçLÕ÷ÜüÎEZˆåÛuÂkSHq×h#«yðl®rfæÁü|~þâ „â¦Q‚ž‰¦,ûk_¶;‘<.;+DYNgýe‘’LS-E¹™…0Tˆº1HßBóਠ¬õƒ6ºƒg1}÷ŠPþAž´w-8MµàŠ MB›Íéam-¸3÷õâÝ%Ùï Qâ0où f9§SÏÈ)m)Bäé¢ªË H*KM²Q$øŠlž–j*ø6J|y]eH,i¤%*e¼… ¶ð–V+Zpüh–¹Ó¤›$¿mé47Œãp<†ÓÀ¨Íè|ÍP;úâ#Üp‹IrãÅôs]—~…Dw2#þ¡a¶Ù;ùl¿Ac…—æÓ0r=Œn Ý}Oo Å#•öÕ´ Y~.ÃéÔ–bé±(SÚ3¨˜ƒ‰¯b”È”“±XrZrÁ3<µ7ÔJ®ÁaÉ´æÚCÍ[”Øs XÛiAn4N¢­Å1‘(©õ°DG6 MYËrSIUç…®Bz‹°ÂÈf@…![S#*&°9<¾ËÎJ‰,ùˆ;l»Å%ŸIE…2 +©â&—¨MË^&N(ÌVå²vÊH¹*9eJVÄh¥X]·—ÚÊZZb°à±ÌdYÊŒƒ4 ³ÚbôX¿B ‰ÊÑM¦Åwµ¸“m^¡\¿ƒ‰…á[!¨’˜¹#ûQÿÔ€¶ÔRlªé…×!ý"Wü‘« ãööm.üÊÙ.%'›ÎÛ[+ÚÒHç²)Sb%Ú ô*Î,½$`³9-}òÐR!tþòÄ´%{ø.ÞAÇB†™2Œ'H«ßpÔÉ*tÍe“îÚÜËØ!ÿ¡bKë§+¨·9ž,`úX°V‰ƒCƒy¥~Ô`àÙ^åZW®Æ²øè: 9$a y!ÝÃ+p‹ ,ˆ¬¬Ÿ@°’!+uÂ^l1ü™£„î a®ŽRòÙx¯´ÂéKù°ª¿>ó›ùA _Zm»û¸…œ˜ûsvÏó..(+J~ÛræmuÎ’<Îg¬›LÎù)kgm›ÿW{ÂÎRúÜN?!iWbc¥#œqê*›½…õ¶I~è'˜úôò%ºì†½§vaíVçç˜ýó›ðg;Ý×ýÉNÔf~XœçöÒ×R–žy€žF3»T~X h%ÊJ¶Ü‡ÀúÒÞãñ{}|Æ~«÷–ª‡…::¾†èk·“>SÊK›=÷â¸4ûBÑÏWÁ ¯Ä_E¯hñǃ{?áänst¼¹ÇoG¼Mö)ò[z|ÈáO݉yutñ=œ5ŒSìP˜¾,£ÅÇ«-~_97|[Æ‹ÿ)Ǔٙׯ¤Öw~bŸ“¾Ì2ZlpwÆšÒÀB`ùp½a㦇µW®2–` ½êÜH,©³tç~Œ¦8›F'-oíÓËöª›ÏÙÅtûJ‹£Ëðj|E¼ö'îQaÃOþ72iv#ÍFAÙ~óðÚ£úäSå*š„ãó³ žFöàÛÙÉ'ÿ6k»óendstream endobj 4911 0 obj<>/XObject<<>>>>>>endobj 4912 0 obj<>stream xµV]oÚJ}çWŒ¨*9-Û$$éU_BJéöáªT}áec/°·ö.ݵ!UÕÿÞ™ýÀ’¨yh¡ì2>3sÎ|ø{/…SOè/¯z7ó^'x¹ÿÐ+͸ŠÇ0_B–Àä:'“K˜Ö*yÞÀL”Þ`զ䱀7£³ùÿ½†)šÑëJMÉQ!4Ïk¥Íû~Ú_œ…'ºÆ?;ÇWBæeSpèøu¿cðú—?b|äkÉYÝhtÖÞÈÓ 3üŸ®áÀ£Ù9PØK"â0ûŒ£ùšÃR•¥Ú ¹a€Áôä%3„\s-júb©U䉨s@ywW;zLZv‡YÇÈumšûRä|úyÍôæly<´=¿]ÆüÓj˵H]#d _îdý‰×kU,"{ñ°8ó„8•Žq¦J…’~Åäø¿B­Ýp†àŸÉ¯ÅYˆØàš£0Ž¿ :K{zV„Àœ'wÊÊ’ë#z=u9“P𠳨5«9Ô¨áÑã-/Ç•e î9Éš“—©ÛÈŠI¶Âc®ˆ^CÝ–U~÷•5¢Ú"yRVS³‹b«DŸ˜‹ ›‚Þ?ñ¨„–¨~8žà=H¾w „ †kÀŸÑæÜÔXFšÃôí[Çå‘#ði/lq#µ ù9ÏwùÝÒ¶»ÇF“{c`oTSošš®°ÝäóÝe‰éŽ'|§:bÃÖ£Ù5¤Y».ÂJH¯ãIœÁmXk hV\R§*IžÚIFËä<>§ñN«d£ùV¨Æ€Á•ˆÆ‡sªÀÝb,VX‘°Ããæ×Vèºaå‹çØŽ™Î³3j|Ëm¬4G0Í"BgÒñíVHG? ‘ú}’8…ÄV‹Â%ƒ‰S&ŠäCÃÉ¥`…# p iÄj"J¼\«u´o]¿¾ƒH.¥¿™îj0hoµ‡—œFºŸÁK¥-N½Sr›ÁŸ3ÅdqlLUt£TéVgWÑh@²8¦BÀ}2T¯\²{»@| é¹77vc˜Ù¹áøúáËÿ€œv€B<Í®ü;J–œÇã ˜\N\~þz÷q˜Å ܪ¼é”4¾9Ûá¥kfÛéAøW5Šé"™Äã ß4±¬²«”®>Ì{ÿõ~Üé’endstream endobj 4913 0 obj<>/XObject<<>>>>>>endobj 4914 0 obj<>stream x•VaoÛ6ýî_që‡BV²'Í` Hœ¤ÆÐ&½ h5²tvÔÉ’&RN²¢ýí»#¥Ø¦ä¤‹["ywï÷OÇ—> †ü®:§³Ž+\|ú*–ðæÂ…c1€Ùú. ßzb8<‚Y¤W¹0 RÆé¦Ráê—îìKÇ…f¢qS¦*^¡˜¤ ‹,Ÿb±ŽC”µ9'‹¼œ'qaH §D8É8–y&ƒy‚ðuÇ?@^Äë@!¼ Ò(Á\€¼—gת¨ý$¼2S*Œ`že‰YöWW÷i½Ò ˆ`$:¾ï^r!}õŒmHvYñH¦~·¶]Ã6‹ë85¢j%;AŠ÷›MøŽº‹eOÇô»¶Ý·Šƒ^©Eäm¸X¢b*|G3™Í¿´â-P•E ¾C `DPÊ$¡…¿Ú˜x¼†ñ‰rH‹N€ŒÄ>Îm¤ß‡ï´¢0IÖ³/m¸É:.TIiZgq[æ-)I²ðoCjklÊùÂwê]C ü4ÚÞ,¼~½Ù=~ìì/‚D¢½Ðø¬ò¯'þ¸úí\D˜ Â[ÃP ¥™|6­iÝé9)µ¤­ Ð噘–y^ ”1©?þ—rÁ2lÃ`#¨ßkIZ*éHÁ卵÷¨î²ÈwôÀC+‡zŠ$IgÂbˆ©¹ÝöR³ÔrÕÜS¥kú±ç^€«ÅÑN©RÔùæUX$Á²}dÛÓ6ψ§C:÷»=0žmÀ,P: –÷韓ËkL#*¿ç!æ*ÎRQ ø]«R²pÔ]‘ÝÛ´¶z¹AUĸþ?Ç‘7£Ïö Å!ÙØh©ÂUêæ}ª¢ÄV§T¿ÇqA¥:+β4¥öj3ÒHauèÜíñÑR4­z9’ŒÎøâyÈ:ë¯6z{ÕÓçßÌÌs”®ßm¥™<¦ã¼¤›É­j»‰aƘ©[×w¶anâ4÷Zeÿ9˜»kBõ~ª·ª· u7V\K§z¿Q•ÓÛ°N*ÓÄדáõ‰°ÝWþ£©×÷ú3$I’45*+]ƒ>+ì§ñó_ÕÎi»&uo#¨½HHŽ|ÊŒ &é"«ŒõãH+_\¢b_,[~®µ´Ø>/XObject<<>>>>>>endobj 4916 0 obj<>stream x½XkoÛ6ýž_q›\Ø®›z[Õi×-Ö-6` Z¢mu6éJtÜ è~ûÎ%õ0%ÅèöamDyyî¹ç>ØCàïÆþí.^Ì/ý^–?Ò5=~5 «þ˜æ+ hòlØŸLžÒ<¶«4¢D™*±¥XnåZI¼¢Ûc²¾Îß¼™\ ÂÀ~øv¾íÌß_ ¨7„‰¸ÕÄN⦉aÜ(óΤ´ìÒRë-­¶b]ÙFkoŸ&w ¤‰²Xƒ:Ž÷ ½}Ãb_ý¼Ì“D4¿ßË?þ´[ÞJ³Ñ1¿Èô=)y,¾~"ƒ·zåX ;ô¹°Z°R 9kuøUæ<ìtËS˜®æ)Ÿ9_=!>tE=xÔó(/ïdzo6‰ZÓ*Õ;2In¤c7–â$•‘ÑéL+…_ ìøfÚYH¨˜–r«”déX¤0ü ÕöžÖRɋ鸑ŠâÜnF"•$•XneÜ/´3âXÏ(–Y²V0·c™Äjš}U©q)¢“ˆ-¾Ç´Ò)Imè.IÍÊÍÑi6¢2“"“àA¯¬ÇÑVdYŸÞHóMFò£Ø%ŠqKŸ –³…ÄÄ¿Ù.ô5" ô£'ŒþFµQÊjÛ*\€.(Û-“¶Ì þ19npHTf‘”,AÇ– Øg¶ø<~N˜Gº1tpôg‡ý^§&çµÛŠO"Ge>/XObject<<>>>>/Annots 1966 0 R>>endobj 4918 0 obj<>stream xWßoÛ6~÷_qÀBiÙ±çGч5]º>tØš}1PPm3•DM¤ìzE÷·ï;R²-ÙsÚ!AbYäñ»»ï¾;þÕ;£!~Îh<áß8ë Ã!¾á?güçÃÛÞÅ0œÐÅ8SFWãðÚNé¾·}Êèl4Ä ·Œ_½~رäÌ•sÜÓÙf8rr‰; âàwm%Ù…°4Ó%I/(Q¥Œ-žâTC÷ß½¥¸”ÂJC"§*ÏD.æ2é.d™ø¬ò9 JŠEšF"þlBºcÓ_DV¤’N{ƒ;¸é¯…‘þ«c@ aÚ«†tz6ìà~¥æojxŸmyÒ=áÉ=ÊP"Kµ„G³RgÝýŽ é~¡«4!A·?×aŠäZés˜ØÑ{U éš#xûâEÈ÷8âó”P)`»äÄæ]3ýy@ÂÚ1:Öž8''Å©ÍdnÁ4mù„÷´T¥­DJ™´ ˜>•Ò“Œ=ežª ²ôñÌŠu"IÍZ<$2•s°°\ç§ËR‡ÄÈ7Ç «tNzÖveß½ÞÜp4^k¾wÐü¾-ÍB¯ PàÄÓÆ €ŒÖ¤ò¥nXÿðöSSÇœUyì¼(´Ê­,o“W¨s”ðÞŒFáxŒ§$Xj•ГnM]™Q¬scéYÔ§Ó,óé }å8D, ‘3ùœ#z½xÙy[åFÍs” ÀÑ#› Í@s¸iðÓŸœJÄaéæcD}³‹ƒÀ![•y÷ûo$S#÷œ"ïOˆçð,zé¿ã99‡^¹Ðt-ó(xDXÝöéIwç·V ÝÓàîÒÍù#’ µù²èJ=¤[pZÁ:ïh!ñÐy7K©×ªU)Šž 8Þé^ÇËÌoããg:ì*ª(U±3°C¦FóþivMƒ}f4‹\ÍÕ ½M.0ñ e9ìîûæ¶íêžBã†B$+ ‚¦Î¾ûd˜šû˜Ë\¢_HÒKt UK6{¶C߇WöôÉhßëì¶âïC£ÿ 36mɑҮt·×´\g3[ç«DŽPÇSå³Q'üö~!Ê¢ÉÝPó±êëk뉨6ÁápçÊÎô¤³©k„š³š|Ö™¤ÁÝ ÑæÔ$u6–"­|!v¬¶¥ãû 1q¾<‰¯m¹¥F`:ŒzgÑìÖ Û%3•¢$žUi,šIe ÒÏC“’{$„Ä1‘}ÚùÚI [¹ç"ñË(Ê­>Èæì)'‡\kNsDÌÃEºö ‡þÐyÀºw$OCüF¨%¸äôHåÊ*L15$ŽYkV)Q0mb%ëêx|A£ N¹€à .€’_ èxtåÄÇókÌ) ü„ÕªuÌ[¾î€¤&ÚÄ/’¬’FZ6À,õCÛäù};we…׺ÈÅABSˆuUÖaÚS‘ÿá~Øø›^IÔâ&ÿnJGSùÑTïåqPná»Ì:çp[‰AzM—\äY—Ügà8ô&±TpŸáp¦¸!ðßú¨ûÔxÈÌaæCg^­‹§àÛ¿v00ÇZÝ&Î&cÇ+èŸ*nÌÎøžì ¬†ëw…f!y.ön>q#_OGW~ÚÀtrIï1C(Ìû˜€uRá¿GÙ,/?¯®x:ùÈ—¶ Zû’‹«iÕÆvmmïÂÍ 6¨Ç­Ðƨ3ÂQ Pøè®­îžÚô2Ô†ëõN‹¸K%j6äÄ=Õ™Eé:¤ ¯¢u+¥*s.¶ݤ‘ÁædŒº;+ø¾Œ°0Wr¹9ˆ¬Ã«•¯i[H)f©à¬J•]3MP›Á\ÚÛ?lyH7Y“êK„ýËÊ]ë·€+M¤“Ý>l×…ÌDË—” @Ü-ç`•W‹aÜ]Õ·ûÑð<¼_ÐäS­#'étéŽ+¾0º1Ž}BËñ‹O/ýMäÈ$|1ÄŒ<1A±ÑÕ9oÿõ¡÷gï_¦îI'endstream endobj 4919 0 obj<>/XObject<<>>>>/Annots 1968 0 R>>endobj 4920 0 obj<>stream xWïSÛ8ýÎ_±ÃM3“nîCK¡Óεå sÓÜt[ITl+•dÒ´ÓÿýÞJvÀ:½+€ciµïíîÛÕç.uðÓ¥þ€ÿ'ùF'îàþèòÇù«Þá Ð~ç0îSNýî~¼_=et±q÷o†ñÁ·/Fw z«fF{§ûÔíÐhŠ“‡ø#õâ$ºQVMT¦ÜŠ”¥íѧ½S¸âWGªpÒ" _×F"š”Ž”£BÊÔ’Ó4‘í‹r’©¤½oª ‰$‘ÖÒÔ蜥j:•FŽ„µ2Ÿd«˜Þ”ÖQ2ÅL3ÚªØâ“¶‚á-R¹¹ä:´ÛíSäV ™‹N˜+y#áÙ\Ù˜FKM¹HŒ¶$Œ$q#T&&™d-¼‰ ³ˆírÖöGçâZz“$…UHŠ”JË>“œéÃoZ DF¦$ £áLÃI}ƒVå‹lE‰^¬ªíT9a5×àÅ¿yKaRìÊÂ)F°TnŽ °Älq`å>¬‰NW÷ Ut©¢áà´t%h‚›VéÂ’žÒÅåëWààîðȱ xõ—•÷š!, Pa’q<šDd¤]ÈÄ© ÜH—Ò‚ zËk3–¹ts AF/œ)‡Cô” Q!ÈêR ×‹û}<¥y?_¼xÿòêãÙùû¿¯ÆQظSØñKFWg'ãí<—Ek//¸<~vvr~ßBm‘ɹµt[j»Þ«~<̾§ç¸96n½d²=.Téµ>4ºœK™Ñ·m%å ö«ü­õ½_=æá†ì×ñ6ùUãÈ?|ûÞXý½Þ 5Gqø¶F/&öiÁ¤ŒÌê=¬BiÕz<NäÊ9¶|µÞ ¿u…Ç– þJ3é*÷±ç[sN œJ¹þhCâÖÚ¤¼´œz^`¡bІE¦,|îóÊáÀ£ËÙÜ7Ðdžü?ïmp~Çĸôì£ng¼ßEÓ$-læÜЙŒ/ròU€±MÕGìˆ6éi0sœÇÛÙØÛ£ •—D)}¿ÀáÇVmàÕ1†¯Ãqô°íÛ…—B9èà™,Rdï©ÂÐ Œ}lçÿBöh,_úæ‚ÞkK³0è‹Zˆ.zÃW™9®*]ºÚê sDÞž«×x.}WãJ(™¯î ÛiÐ×xÕ?ètƒ}^ñ¨ç—ìæ3ÏœçÆŽc\ÀhféV´Ðgxi%Ž佋×UóÄÈ[ºÍ³®-©––›1”¬¸æ/p_e`gine^ kh~FÁ(1—Ç6¶´ÓÄ<òÖ¹;<º:=H¼†øBz¹Õø-á†ép<¬ø  mý‡ ØÀš’˜^Ð}n͆â>¯¾êë®n4ÿɉ@>$°±¾K>„!ç›ÒV¤L¾o.÷ö=Äì:u+ À+ ¨<„¦U—ÂdËœ÷¡ üMiðÍwå¨KtK!AªTƒÙíL~Û´ÖóHýÁ Ê“jÙ£k*”üÒ7°'¾§ì«ûww¸ôh0DïìúË Ï3»½¸C/uRò‚› .ø8Ü7ÂêÝg¡Ç`ô{Fo¹ðyàã;eY)AÜïaBwê x÷ÉhãÏé"endstream endobj 4921 0 obj<>/XObject<<>>>>/Annots 1970 0 R>>endobj 4922 0 obj<>stream xåVmoÚHþί˜Ó¥W§)›Hª|¸åN}¹]O'¤ÓbÁí¥Þuªúßof—lP¥ûÐO— ƒíyßyæ™/­ºô@¯ÏŸ(ouý.=áKÀ—w­ ?ðCC¿9à ŸÞ™» >¶öïsÃK?Ø{ûz²gÐX-çйíÂÐïÁ$° ýËÀï÷0‰Û.L" Óq¡ªA/„¦ ÂÝb‰ªx®!’Y†‘Q¬áuú€J‹"BP¨!)e£ŸO'Ÿ[]hd1&‹Ë2}­üŒ”>`‚%’Ò«†dZh, ‘Á£Lcq¼•œzÆkOOákC f®Í}Óú·šÖ3wK• 0)í_còIáCéâ-)z|ÄBów.4×e.Ê™˜£«E* *GLZªÊtZÌ¡RXsE¶e±(æ¿ÁRš\}¸§”‹cHd 9ê…Œ•­|‰ä­p’ dÙ4º“4$…žc>ÃE™ŠY†~Mþ™^/)ƒåÔ‹”¬ôKÀ§HÆxýñÓýÝø¯Ñ»›1öÓ1ûæ¨Í¯#…¦xßë"¾\ÃIšG"Ë^Xc5‡@'‘Š2¡T!r¤iR)*’?L ÀØèO×\úåÿ¥öÙû?;j•ÎG„Ùc8²Î~øi‡úDdŠÈ¡ MCäüG~Ësßo%àlï¢&šx²šÆïÜ^B@Mhah‡}ÆPpéi7xƒ¹,׋‚)gšb‘³ÏÄÑ –4ywS…i'k44²›UlòÜ?g£>/XObject<<>>>>>>endobj 4924 0 obj<>stream xíWÛR#7}÷Wt±Ù`ga06v³IÕÆ „ÊeI ÂËT¥äÙÖ–Fš•f0“Tþ=§çæ 6û’<¤*@ÙƒÔjµNŸÓ­ùÔ9¦>~i8â¿(é|w×é} ¶nFG—'tܧ»)lG¯ñ—óxˆºÂÄ”{1“4u6¡ñ«W½»£Ë>C^2èÓá` ‡ø/î~ÆÖdBé(jž¾æE0ä]*£ -i2’ÕwØôÃÞS³ÖCàeV¯ »_6«¶®È3zû–öj›àAè\¾¡=\º›­¸ {‡ß–Vl"M¬Ë8–¨–g£Ñ‡Ï$ÖI²Ž´ôžä§\a=gªŸEj+Vô ¹X¢v·CT£Ñ X/k1ÚŽ'­@°Šè: ;~7—L8‰%-”Ö$ôBžR§pz èýšà;ƒij9'ãr6›ÑDÂ@yR¦4¿X‘½tmp e–rƒŸù†HÎÄb^ð¼b;A3á&LÕÈj-£LY¸ˆ¢±Í‚ øÏ¦cM8%g¼Õ2¸w*“?Bha÷)Ù9Gµ ƒu®W‚ØÎ©£#ºUI®E&·ÂÙ ßʘè¶ð™L‚«q0®PßÅ×¥á½PÙ¥u72s©ŒÐêäw×Ê12üOøYjã ©u­¨"'E ®gsjTÕÊ.«tMnÕ|SK»È@®cú›Äd‡sÍ)×™J°.(‘ÂøR Û´y\wϤ(Eð œ- rš[Í"w±03Í©…2¥;`×NNŠJª<Ãj¦ ¬!i¡¼W‚U)ì´ŒG>¦b®f1:èôÁHBVrVGÖÆƒ0 XǸEš:‹"À¤rrŠ(L$W¥¯E!Ýçšæ­"Š´@Å#êó†®ß+ŸZ_Bðg vÙgj§ˆ­Ã/ŒÏQ½³¹¨ªÔÕ˜b+½ÙÏšÂQÂÒÔW”ɺ÷•}EŒð%ª”•õIŒjYË }†&á‘ ?ZÛ¼§EU `y`\šÍê:ükÓfGlì¿G¾´„Ók|“¹w&~Çíº°»á1ìQβ oî†RmîKÈ\–;ÓÊ5…· »õ‚§õä¯\Ô |°*¦ÕÖÓº=ÄG‘¤ZÞ\ÿüÛ‡.PcêÄÿ¾êÂ/ÔŒ£9؉† {»#¬)ã}¶>/XObject<<>>>>/Annots 1974 0 R>>endobj 4926 0 obj<>stream xÍX[oÚH~çW¥» Q‰&!´«}èæR±—4Û ]UBª&önmëBѪÿ}¿3cƒm ÉÃ>l[QÆ3s®ßùÎ1_[=êâoúþ$­®×ÅþèñLJw­ÞÐëÑ`à{JpÈ{],bºkU– q­²WY&Ôë ¼ÓÊæY÷Œ¥ö‡Vê™ï³X»b±V?°{P-»à­Ê2¡_ßìU–Ð 0g}ñ—qÅ7ë`>£“ë×Ôóin\ŸÂ §çØ?E(Æa{ ¼i±6ä0«}#nèê[ 3©”ä7‘d±¬Ÿ-]hS¤IŽøHy”ÔÔZxðY<ˆ(=¨YM‡Y.7Fz4žCL¡ˆB™¨T›žhš«% «›Ž9VaûâÕ+ 9,A ;¤ÅÊ:rr ÔX/Û¶ºçí"¥{Žf–!D*5ÊZ© ‚'ò¼›«qM²“°–z·ÒF&ËGIS>ݯ*ɱvà¨Òž¦aÍ…ÃldY*’jô:lœÙMÐ&mÎöÅ ’_уˆej¨0½àɇr“Î ¸uÏS/5Îû¯HWÍÎ-ô=ާ< ¥`T˜¹€¡Ê*Éy"Œ¸¹ÐÈÏr.sù s+‚sþövÄ; ·Fbv¥Û£ß¥9Äa­.WÝ@lS B 0p--s–¦©ŠcµÔoJ\„(P·Aý>VaÛ"¬Zú§Œ ¶³Å}ö6ë³ÏÈœ´'G?Õ¯7"¤t%EÞ!þô›¹ûŠÕö%>3“æ#.ì’YlÿÁRÙ¿„èyžW³ñ{Ýd”å"0ô6°ÔP÷¥d¢À:ª;•H3G„'í€ë¹ˆ×K®ÝQÚ©.ß/̶›NÇŽËO]u&oHïØ&¯ï 眢î°à,s\°†3Ì=, Óò›3Ÿ)ÐÉåTå’r)˜Câ•¥Þ’àÓQ‚R•;ja²J^ÆÜ·Ô|åWlñ+õLi«À‚ÖZ¬Îd*™"C&žPNÅ"6W5®d^P–«o+G“Ï).Z[zÜWP#î:à$ó©äã%á€_(+àñ†F—‘Š{4‡&XšH#*d”‰wõU‡ ¯,Z\ïÚ”áϘéI»`©ÛÑÍ_ï»òR¹üT“é¡z.n ªÇ ŸªoX=¼ÌËÉÑ–DÑ”¶´Ýý=zw+ÓÀ_÷P¯x!Œ‰ 3°Ùfž£É5ŒÞ)æƒD[)î*Üï…d€ _“Ù V‹Gµ™$ø¹4ôsÓBÒO5ázÍ8²]~²¯Ïûcm¬'c”r&vDïyùÔ©EŠëÇgÿO™%Žÿ"Où¿¦¥eÖ]§±«½Ä7ÞîÅ /›DÅTçž­‡Ÿ…7Ïc8±ÜT£¥i®Ë#®¥Ú±u©Jª*gÂ':íÅ€‹6 ù+*ˆ+cüñöŠ^ÒÁ¶½˜G©ƒ8ª#`gïµ Ì ,JÁÈ“#+joídB‡U݇vàÉEªcKÉ(7\V)˜t®LC6ÍxrüY¾5g¯l–WÎŒ™È±SwHÎê©[Ï=;û›Gל§‹ 9àƒÙ>µ½¹Ät…Á9ŽyGaôJTMÑtx[FfNºlóG_žhÑÏÛ£ÔŠ¦Ææ¤íw{½v¨×oN³VjyŸ¤ÍuÇŽ''d§4:öMcÄÐ×)íÉñJ¥h†i0é ÞrBŠÖSç HB 4øÑF‡ýÀˆ¾Àl¹²ñäÁ•UÔ°Y´Gá†(ç}Ù \’:¤àM¡qc½«rwdŸ¯ˆšß¡sDí´¸¸Èc$4˜sC­pƒßŒP¦˜"$2·Ù§ ²®3†«ôbúà÷CG³¹Á ¤òUŠi¤‹#rk`o¤¯ ÿȾµ®q êÁ{O:ëøÞù¶W¼Šðì’È0ùÊÌËÚð§_$l˃>ºŠ]¤¡ÌãÓÕ3ô¸Çi+¨ u³Ž«“0,ÞKýî©wÖ?£Á9ÿ.ÍTvì㇂Kà-%åñY¥| 3«;{|î’þ_þpÖx}?:À8d}WãÖŸ­@> endstream endobj 4927 0 obj<>/XObject<<>>>>>>endobj 4928 0 obj<>stream xåWmoÛ6þî_qð¶VbÅ–ÇÉ]œÆÐ5[Œ ´DÙ*,R%é:FÑÿ¾;Q²%Z4Ø—&Al¾yÏÝÃ{ø©3„þa4¦¿(ëü2ï üvîÿ©%œ¿½€áæ Î_ã—¸Ç/‘gV©¦8è•Ü XðµÜú½ùÇÎùÛLü­ Ð4ÂVìýdv9ÏXz‘¦¯a")´»)3^A÷q§ Ï|jÎÓŒwÉš #4—§â ƒPýäŠßv©a¢¹üÇH§"߸Á·v ôª^ÿÎÔì›ï¤0«Z{ÊvaïçæQªÍ\ÚÔEÛÑši-XÆý%7wF…^ýha¯Ú!s|-¡Úƒ$Ñ“ÿ(òþ$ÚR 7ì,avŽØô—P ÜC/ìU®Û0WØÚÏ.Ôa¢eE|ŠuGC*2û÷ÜÉ#½JÅm—À¬Bß~Œq ý·F÷À¦>c4òÇã+Šö|ÅAq½Y›T,aÉWÈ€r%ŸvÈ‘˜C*Àà,:ñË’Ò{™T ÛY1Õƒ"× ‘kd¤¾©–´R2ß,ÖiT®°ÖàfÓTçR³ÅšÃÇkß/H¾g%@i#bù(3Ž7ƒX†ž“£O3ämKþcï7±v÷«ÙZhÒØö•$.%…Ë–%°ã†k7oÚÅÜ9ZbÔ®å|€Á1?2ÀŸX–¯ùÃì÷¿Þÿvï[D?4`ÑÛtIÀ)J5óÿ™V‘•ÍëÄzL 8:û3†Z†NØ.BÔ† b@è9î?þ=ûõ‹Óáþ)â9%«_v`¨[ÏhVJn][ ýÉJùgN”?ŽPD6JÐÇñèWHRÁÖëöxŒ‡„pòØ^d唯=ÖîP ºû.ºÛj–œ«­6Òr³¡÷Õé©Ú¶¢hà r=WégôfÂ`Â#¥#Uaµ‰ŒÍ×e’8‰‹2áC…Å *ÌÑìÄàIž|yWÖ‡ O‡Nÿ±,8¹M ºÁŠ˜ê°,‚~k"…ªšS҉†ÉNêó¸Ö¼Ì-ö2wXÅ_+‹Š–£ ‚½‚x *Û¢ðj0„4¼¨ü(îûÁE%2ºVx£¨²JVLC´bb‰jƒôEÎjTÃU1ƒ,ð5ÅáDÏŽ¤GŠ g1Ȥ0󄡪©IÇ\ÁŸ¦R¸P?å‹b8)%OÿÊ‚TO͵4XsWHÑ·/Œ¶máUs±g}ÆWMÆ”^au@P†%$ኋ¨Ž ²»h˜`£Ô‚ˆ „BX½rTU©Áò¢QHZ‰Óh»þÞ=¹øÈ#SD`Á¹€Hq´Ÿ–¸%=TÊx r …Fï7R—“¯ñµô˜ÁBºØ  ,ÏQ”kô!‘ø²#×PÛp•ñ8e(~"˼ƒæÉËÓÅ÷¼¹ð€…cáX69–ÂÞ B€O˜6 XRР ‚ÖÍ‹w[-'«Œ^]úãÑ%Œ'Êj’2ýÀÀTF›Œ *ÊVÂã£à¿ęý+KùáµO¢}JÉU¥$=6øœ]Á¡‡ížËLPºj¥”G‡¨jïr0öG>ãñÁ䚺îç?:ÿX£xendstream endobj 4929 0 obj<>/XObject<<>>>>>>endobj 4930 0 obj<>stream xµXmoÛ6þž_qð^â´¶b+iš¬È€-iŠbXÛ!Á†þBËtÌVU‘Š—ýï{ޤdIv²Ø’ HùÜÝs/Ôǽ)Mð;¥£þK²½Ÿoö&уͿò–¯Ži:¡›%/:9ÃÓÂ-ÀC2ü‰lyOQDK•‹4½§yª“¤ ÝÊ\–ÂÊ­•]‘]IR¹•e&J@&ÁrŒ¸ Þà Š|Aû…6vŸ½`· ³{D7+ypó~oBãi 8C‘bã\Xu'I/é}e,UFå·$ÈʬÐ%Ÿx'J%橤¥.Ý®¥´U™c<­0Xêì” Šñ·Í%¶ï€P¹‘%ë;—8@¶O0†ÈdnÙ0¹¶ b(·€Ì* ûÈÙ™´+½ 7Ñ™4®`ãÆ ¬1ö4º*I³!c$xµ²÷…ÌD1;ˆXæðjzœ:~9ÀŒ³øä9ùéÚå<9>>e#Ãè;Œijá •7ç0ûñ[‚iŽECöÈ·¼º{ÔpDë•„ÔÀMØV¥,R‘´9TˆRÀ²dáFócQ[°2²š2áL–hÜÏ‹a$oõÌ»Jä¤sÙGzq ¿Ñ÷=œÎ–Ð-‡§A3$ .5ÈØ"Î3 <ïÀià(×ÊÀkM`¡;#ÒžÙÄ‹a íZW)kU;ݳ£r#Â7¸ 9N?ZnƒV˜cm‰Ê•L YҲʫtfõ‹jžª$6ßJ•a·âXÛ˸;Èìóåãé·M[—^»œuC°þ9°Õ¿xªny‰/Cý<ÏÜ Š½{ýæ÷·¿¼lå!!Lµ'ÝœßCáèætÞísscÛu–“,0¼í¨pÄo†{¬oÆkÊoi͘þÙÈ– +P­xé¿G‘ëUš4nò66p“›<.é®G¯ÏÏH\wJW†Ð¢ñÊ\÷‹Zch…t/ÂõÓ_jÛW…ºGäxë^K˜îJË@\LV¸Â ðñ}¥ulš„1æûóÐÚïóm×r´ð펕w ¾ž²I¹2„Âí.Î~¬®úC;o.Þ›ÕlV‡×Ts[ŠÄõ¡Öl¤ÃfÌ‘½ÑÏ¡ŸÊ†¸ö½Ä\£,÷Ô¥¶ÆoZÐ/¨hÛÕ§);þ+AÝrµ“`7”ëœûEå)øÓVâÿOéùïkNÍ]zÄŸ¹§©AšV‰k}Kç/ZÝjuxU•˜žGÏŽžÑÉéIÝ$_ÿñúÕ8Ž&t©“Š?¦¸;såɯ?÷Uszq›Ã½¾”f…ºÃ=»÷6Ç~¨¿‰øÛ…1:Q@#^_îŸM€ Æw2´-ñÙ„Ï{y³÷ÛÞ?¨ÝÜaendstream endobj 4931 0 obj<>/XObject<<>>>>/Annots 1976 0 R>>endobj 4932 0 obj<>stream x­WmoÛ6þž_qðZDIeÙ²cÇná [’Á^Ú-ƺ þBK´­UU’J ùï»#EG’Õ(šNE‘wÇçžçîüñ(„!þ a<¥ß(;C\¡>þxC+0:? ¦ážà¼zHáæ¨ö˜ÁdÌjïjÌ'{#tî§eÍq&·0x=„Y0†åFC˜ÎÃ`:=‡el¢Â2òzÏ"¥L©œe<Ør}ñNË•§yVà›$/J½:é,ÿ=B­,cïV$1¨r­%‹ôßœIµò..™æpZÐ’\ýyqÿUgCsª=°sdå™#ýïÑ3™Zy«èÛÃ><¾ûUäzG/ë‹—ìž–V'¯>èiðú ÈåÆDÝ«»{ËÉU™ê$ß–ç\bÌ1D"æ vâNÆ-šË,É™NDbc–¬YL£1땈ζéʃu*¢/ÝÎGðû£Q0c*b¯(×iø'–)?@©Ú¤4FAâ’oàæ^a¢}™dÜâõ4ü&np)£D˜1#9¿kd% ŒT€&îGÜÂÐò¾cÜEß]ÿöçÛŸ¯‚.ú4Ùg‚¢|WDjæðç6˜¡4ívX¿T 'Ko³|:Þù˜ô Z®Q®±^±Î§$£&¯)¢§~†>Ðo›¬tĶaêƒ=‰Œ.I6y†e-ÿm#A4vTª˜C8zTÅÄ©"œ³à ~„˜tìXóLä un´’¡Òwˆ7é%qñR\ê„+Ëx'9*ghÙNr+$¿MD©@ñÈ*âJŽiT]~KÐ$ƒ‹/¬« -ÀšÝK®•ǦS6BBÁ$2T¯ `¹K}òOšç1‰“˜3‡Â{Jà Œ‡¤ )1P¨ßψµfIŽaßíxw’…MAß2™°uÊÑç†Ö¥±¤0”öLÙkGn/¼‘"3ç`Í+ðXŽÈÁ6k–î=?]rlu¾Î !5˵©ÕûÎçsYáÃ8¬ØùdñdIf§T·ûR†è†H!‹"®¨ˆâÑ aÄa α…$6"MÅí)Ûr:(Q˜¥LÄeÊQ £ÐŽ+þ?Jµ+hãBe°u•7Q¾aèÃhÔÖpk3$- ;5ëÑF¤.ÍKèÁ‹¦é/eë=õæýõÃV…¬qDE‘ì³}h€"/#=(sìwØ@Ì;Cqä»­9 }˜MZÁ$ÜÜHŽ$g ¯Ûä}&¹ÉKsðÁ„jœ‘ÛqWb*1ë 2ž­Q±ÍCnŠñHÈÖ]Æ ëVòe"16"â+ ¥q§êÍÕ8bW]UBCoLx{¥;í Kñ"ñ=Ä\%[Òz—]¦»Éiˇ‰ãT>Üñã45"Ñ;R1Õ€P£×P¤6Aw)JK~ ¤lû$J}¼·dêxs–«Ï+‹+/Rô_ðð¢×âd›u ô:F‡æ„W·™äŸétÞ¢GíËÚ¥å&Ææ,áV«qbÿXMûg3T¼ê}ÎPx-òàŽT~ZwmN¯ï®ÙÕ´{¦Í:Ó@ý•LO·m½ç¶4ú¸‰6R»$_Ô‰î8sä(†“fŒCzõó³z=“†e>6wuT®þºx{y…õlÏçíq`p C#í¬|:8ˆRqÝ9ü}[†¸EB$Y„“É«gör;๛ìw˜.(™¯œ';‘¹Î5~ß‚ˆ>ûkÄ_YÕ½QïæÐ¬à.fòÈK,;/ëÓ<íôáöU.±i|%À2®K™›£¢"ß A͸ÕÖÄì–VèVƒ×³ªF‡³³`2žÀt6 Îí7#¢d„ßk/ETf<§/?´üæiw÷Ï­t¿Å¼:Nƒñ›jl4)¼«åÑïGÿÀð¨ïendstream endobj 4933 0 obj<>/XObject<<>>>>/Annots 1978 0 R>>endobj 4934 0 obj<>stream xµXÛnÛF}÷W „$¦‹–(_äFÑ&q`mÓFhÑB@±&W’Ë.I+Bá~{Ïì…¢(ÙÉK}ÌåîÜöÌ™ÿ}0¦¾Ç49çŸ8?…#¬ðǘ?~y0…Š¢QxN9£Ópìž2úxÐ}ÆÛ‹IxÙ}ÛyÎ)¨óö»YGÑ©ïèäzDS(œ-(Ñùå8¹’ƒèæ:ƒcZ-S˜³RM–Z.†¯À##§L3¹€) ú@N§ =óŸÉÏ\Uìª/\½.‘€u*nQ¯äç÷é3cÉQ±¨Ð’~ …-±,ëTL‘d&°þÖ'¢X³?Œ¤¦ÈE!îdÂz‡œ²9l‰Ï ”†C ƒkq$ºZ¢h²æT'ª` ó#¿NäBpÍl%Û¢äðS…ó#ëâvRYµm“õý ¥9×ï~Ð-LžÅ•q½¹)C›rŽ7ÆÛ@?nÕã]AÏÔ½‘þZõbÅ”zêÛ–ª÷3[b2 {Š­ŽÍ:Pà4ê(½+”Á»[hùt̉ޒÓȾµ1ÜdØF2åMÅôæO$`T4%ZG€4¡UŠ+°ÍçNM³*†Ð£%:H—€½»æ†ÀßF/ŽRáºêå÷ _x^»R‘&²@MQ!VKa Š·ƒ¸ ØÞ;²yÜÉòK̶AŸb¦ž™t_†ÓðŒL?åò¬’+DHoÜ4—f/ËÞ›OúNdÒIªe\+]m;ÏÁiØv;Ò:Rœƒƒ¸ò²ÒbàÙ‘˜³ô“­SŽ`+¤q~x”@LçxHFز6§¼Çé‚V®4® ±š]Û“F©À„©ËÉNÀöv?yÞÖ´zz~±ƒ‹úcK¿#âúÌ]ˆíCÁ­»í¬ßâšÒ'÷˜uÏŽ‡íaxhýocSëúVÞ§ºn˜,mhß goEüÉÍô"AŽí1Ôû×ÊÝ×ø÷`íÚô½y“%‘ˆ(xâÐ3ið|Ìm°>]ƒ]Òô-dï´µÐ.nÖ\ºéZ—¥¸7-*3“…H’”†Ðta£1 £…¶häݶU-.-^ô•¡K¸QK-ù$ÌÅš2¥>}-Üž»ƒ˜ž:YöȈ¦¹ô:ÃsinªŽ›c{[ÌM“ î¿X'YTôl[–y3üêfj›Ï‹ ŠŸÆÓÓðlrFçÓixaÿðñ·›÷Ã(Ñ[79H<¦ >¨ØÝà ûŒÿ‘ýÎFçá$²Lt±úw³ƒŸþ±¶]>endstream endobj 4935 0 obj<>/XObject<<>>>>>>endobj 4936 0 obj<>stream xÍVßOã8~ï_1bïN©–†6….,º—+pâaOœ¨´Bê‹›L[ï%vÎv(â¿'i›´iŸŽEhíØóã›o¾ñ¿ôé߆#þ³Î“N?ìÓææYÀÙ].Ã!Læõat5G£/0Iü©>Lâ?'³<úEfRå… -º'fðv"†~Ù½žNÕIwò£Ó‡Þ€Ì$šù¦•[îØ)×?aèF¬wÌðª{ýN(Ó.Œo(høC‡]8àDêôüµ³»sàæÐ#„zѰB(˜,¨ÐÐÝr£_Ö§ÂZˆu‚°’i n‰Š–Ê ©xs¦z%ÕVFä9Ú1‹4å½Â¢éég4© e¹B¥ÿÀê Çtt&â¦Á´[~®Ã ¾ÖÇ·íEQ8Ry“ ÃVAr#Ÿ9ïg-x\ÉÅ4;mš~î•{p"ìµeàqm ´œÈ =‚ÏßAáªý™ã¾Þ³áÌú€e€f$u}ÊPö­¼Á\*Âç°­³3X!Ä9g™PbA×uF*ñEÂi×c çhPÅx ? ëÊjiõŒJòî^"P1Ê·É žgÓ€wNa.RKXî'¼ˆO½ßZ|n¼ñ­÷:é£{‡gïÎ[k§¹®8önË<ˆ5Øc)RΡrRS_hz†™&”uÉèHk ´§Ô\ jK…sÎÈYáÐz:ŸÝ]Á âîäÞ1ÑWáeHÿ+ŒÚöYR¶&ZŠüåÂ8Â÷+ZNj4[:ÏÙÖøØ"ϵqÖǨ´XÏÛ`µ$žÌÖD¬R$.J: fH‰§’rb÷”(õÉ’öµ"M)†pÏùB®­•³”¾(”{­!§4“ ¤kãÏŸ+OÞ¢ØD!—lPkËHlýL'r.Ñ´²À­sÌDÂX++Ò(±ã޵j_šn_¨šÉ7ëÉ$©Œ³¾Ú€¼˜¥2öš¶3D(Yx â XGà•úÓ£4¸†&ß|sm#9 ÝT!Q¤°]ñÞJº´ÇµŒ°B{“ÅW¸¿‘–ê(¸Œ¯uñª!x@…}žÌ‹ÝÄZ×ö/¶nrøH¾íò×õ»”4‘H¥[Âã÷û?‰¥ÕÝ7ÂÎHùµbÊ4hÛ¤Ú°ÉÓÃ-œìât|¤þ¥Iš©/h Ó¬dë<n Þ¨¥#.^ñ°>/XObject<<>>>>/Annots 1980 0 R>>endobj 4938 0 obj<>stream x¥VÛnÛF}×W \`‹æE–dyhœ81Ðm£"/~Y‘#i rWå.- †ÿ½3»¤DJŠS´¶!ƒÔÎ圙9³bˆè7†tÌY9ˆÂˆÞðGÌ|$£$¼†ÑtŽ¡„d2Ù=ðeÐ}.!¯ÂQs–¿}?ë8t^«%\ÞE0 S˜- ‰`|‡ãñf¹ Á, Öõ¼¬Ee¥( +„1ðñÉ¢ÊA¸ûÒ¬µóáùÍì¯AØ,󠱕ÊÂodŸ<oŽThëJAòãùKïÙ=]Þ€½/`Hù“´É7*‡L—kIiØÂB…ÞHµ¤·9Þ°§>Öa’„iJÈó`‡Kx 7;|œp?«[­Œ.0üZI‹?K…ÁsßÀsôrvX†Œ5fÓkœ;¢ão"α¤\l%,£´+ap_ L++¤2P¢]éÜ@&Š‚Ï͵]A­J¡Ä™²a-=žÚ`À¿o)€Yþ¾©KÿÀ4„Ù ù·G¬ï+„O¢\Sݤ¡ ‹•"Tb½®´ÈV`5ˆú"’ „Ÿ¨²Ê÷E£z60.‘™l»‘¡Ÿ÷7«èëÁ_û ºñ2ýÛ/Kv»ÆR¬‰«lr$àÕ¡"4‡`Ž M_~ùzÿ‰ëc¸,ÇZuè‡Úµ±g–JœƒTÎþ°ÚÄ÷:ÛÑžó&™‡ dο£§éëzšö•  ¯§ç§5Ý *÷õ~®ú­HE) ‚k,Šœh|]^›-à‰Ú{}s„¡_f™Ê}b—ü?ìG«ÉÉõ‰ÕtœGŸÄ†ÃVdüRºj—’“š)ü©r¬Š­4êOÚM ªKsÔR­¨Ý^ŸÂ·f}Êë#ŸÚH¥ëü­®©DÆÉf¶jé'àК†““¦–T ƒÜ¿Šƒrf»?1™™ j¿Ÿ:ÓwÇUß°Kʨ‚îP’zxE@ºDÞ]¤ý•s á ?…#ªm‹žXiV|å;PiÛK´½8Ç$å+IÔ¸ù×ÚÇaAZHÒQ ^6ô?„ÏH*à—O“ôë ÝY¦fö½\þZ—s¬ œÕäô¬ÍËuï¹T´|ñx ]Ù:¶Ï0—ËwÑÓ4ò?ü¼Ä ^ú³|rv÷—¡þìº nbÛê:™Z’–S­:ª{ÊtÅš_l_§£™ïC,7ÀDÍ¢KVb)h÷^6C6m¤?žŽÂ«ô Æ£IûKø0 #ø ³ºDºûðRe'4‘þôpâ•俯ÿ«h¦ ]$H’ë{ÿ8ü>øWÏuÿendstream endobj 4939 0 obj<>/XObject<<>>>>/Annots 2001 0 R>>endobj 4940 0 obj<>stream x½XkÛÖý¾¿b¾Uà%—¤HŠÒ/¼ŽÑ<½jƒF Šº’˜åCáceå×çÌ\^òJŽëmc Ö ïÜ™3gÔ¯7>yøÏ§yÌÿgåçzø†ÿøüçÍ«›yìzG±;§’’%þÑBA7‹€ua(:ß‹ÝpXiË%ùóÐl­%C ‰­µdh£¹»´µ– í"q–V;5l§D²œ2ZíĤµäÑ©I«2gãÈ (ž´–Œ³@ .Zbà‰SÑÂõ)}²DôBÆtTêh¼dˆ&ä;EÒÑL2ŽÂ²3jåh´Ô™ó½ìj‰je2¤Î÷‘ºH$±kɰ$—ZK†6^§é¬6Œ¿Ì_iº5Ö0ø>&‰•‚QêPtѤÃl5N@–H„Éh CY2‘"Xg‰Hp¡´ehçsðh:jË&Gdi-Ú¥8^kË%~2LgmZÀÛZK†6ž3H£e[†6™_œÕàû†û’r‘‹Fz|tÒZ2J$ IkÉPÌPZ}­7¤ÕEÒ×N2£¼äÄNZKf”ìÔ¤µd\+µ1imZ`"ŽgmÚ…¡²…‰&Ûbp´ÀkÝÂ"[(ë$Ô06-/Bbµ¤Cd.@·I«ÍF:9‰\)Ÿ´D |>8*m™dú[ZKfàki-™L€Â¤ÕÑ óºXc>*’Dƒ,†1ptÒZ2´È<+g-× S¦³¶ -úªmÙ–¡4.ë¬%C‹æokÑŒB\·Ä—p Lœ’NÏ$Cr×ϲö«µ5ýd6{º»_"6XYï0(ã$p­·2"=Zg³À£‡Ÿ^¿¢´ÚÒêgªúbý‹eIæ¨X áÛÁ¤u‚È £–f?4ªÈ˼J›\µ|”Õ>_2{ÓWU^íõyE+*ë­º4?9ê'ƒ}ÇÇ—s¸ oƒÈ£Ëï;¤ŸÿÐ¥/^ü‰k4UokgâÅGáÙè8¿B´ôJUªI»¼\'p¾KÚžVuõ¤*V xÇôGpÿDÀ|[oûB§hº@>}Ê[OÛ¥U× £þ V¤›Ïë}_eÿ _¾ËÔñO\4Ð)¸ý\:IÍÎÖyu^}óýÃe9üQ™ƒÿåºb¿É«Çt/%:1õ¡}3ÚpŸ©n¨=¤ÚR‘oþ¦À!ˆiGY]óBQ——Ÿ»Ì¿êóbË”é¦Eê]§ªu4ø5t£ÏHu‹=(û¢Ë[)Z—òî@ÏOÙõ¼-º™¼ žË–0áæ³>U™ŸÑUþg¶üPçU§š«®ÿ*m6àÈPJªòã„ýÑkb>?zݪÿQµýñX7ˆ¹Si×7H ϸǪ>Utljt¥òÊs“­Q­“8ŒEzB¨Ì¯/ÿ†—Ëeð)£º»7ÃÕÁö¼4d}È[<=eÚª6kò â`žýµ¥!Bªw´úúõêï/¿s͹”²ƒ*•ÓÕÎÊ”&ŠWã"Ä­ÛŽOwEEZíû¡ô=3À'äZ\¿Ë+ ‰9Žç9ø»ûx˜Ø3z£žòVmÿáÃNÀI_¯Ÿ4áÍ\zÙP¦0“vâé;ÎLƒ¦q@É;~ž{Îã^OO<ÂVy”`‹È†-‹‚ns¾+câ°äUVô d}ÛÕeþ›œ¾<ùžÑ@pm€{ZK]Ût›C;ÑlH©ÍK®öûºQù¾"3{è5Ã.ÍœÑôüÚô€–v}QP—æ…Ó¨¬×ÜbŠîò¦íœ¬H[$¿ÆnPõ²?[G»¡¶ë#V?TÅv !SÒRd¶A5š8η#Gú„¦,­ŸtóBÀññ±S“üä­Ÿ©2šrÃó¯ë“B‰ÜÊ3J J·OØ@ª–YÖ·Ì9é‘âÙÀYÉ}ÞIpw÷ÑÈ(Ãn¾uõâÅÈq¨Þü‚þâÔX<%^¦›ïvy†¦Ìùcï/ÜÜœéÀ(ó>ª«†mÉ7ï;Ñ¡‰nA=á 5 ÔiqÙ¸ÎMu;»%Õ².Gàâ³^©±}NÊ«§ºxbÚ®é3Ý•ŸäZµ‚§lì!Þdcçv »'~Pñé½]{ºiÀûc"­ßÄe <¥-ÂíL¦ áÉ0-Íwç.^òõ÷¼ÐsÊ*jëR!ê a!™Û\6© Ü-0}œÂ Œëª8£‰ V 4,ª´Õ40Î ÌýU_ntIÚ؃EÜùÐ*Þ;Ô¯=À…ûx½\^Â¥u->/XObject<<>>>>>>endobj 4942 0 obj<>stream x•WmoÛ6þž_qÈLA-Õ–ÇY±«×dÁÐì%Þ† †¢b¶éŠR\cØßIɢܤ)ŽLÞëólÿ”÷ðòr£!,r<;½À™ý?ðèVC®K¨VæPèL€ÎáöŸë+˜ÿr=ÿõÍÍNŽ^^¢k"ŸY±Y‹÷Û’mî¾lìGÀTÖ¿ ý/.…õœËµ0ø‰UPÔ¦‚;\|šA¥Aß}¼"OCˆG)ƹäl-ÕG<&Ü麄M©éxâ"»º@™Çé”n¦Ãd”¤ðg­”T÷.U©`þâ…M?̇nM’ Ý[h(k”¶÷P—LÌW’ bŽ6õ¦’Zù`†0KÆMJ†Ód<Æÿ²èÌVÞãùîŦh2Œ(¶WÇÉtzn£ZI[¹^ýP¢d•èW?l×çÏ¡¹/6¬qmxÑ;ÀrÇŒäpËW¢ F!f¾Ôµ9V„*LM!3mïÌÎT¢øÞ4kz]ñNW+pÝåLHÈd‰}]ï¼]‚lQóIx,û‰sÓç׺ÐÔ¿“?ĺ®6uSHð’{MérÊÃêYõ¬6= öôY¼ šâ8æ+ÿ<^Yb8fÍG[)Ì W}‡ €†Él晘&#¸aÁd®ÕƒPD‚®ÃÁ+‰G€¡R=°R²»µ@^+N·</WLU ¾fÈz®Xúàl¶"v©õû×Ìâr¯ŽÑÀªQ÷²¥Ê{`rM-ç23(wAeF)äÑ(TFim%âùÐy|蜸…(Í­B­2Q®±“ÈpLìA”•“C3+ f[ªå;]CÁvt°*õ¶dÊŠºµY“Ó]—I½OJAusO÷ênƒã!¶‚jA>ìS`QæŒ ‹!Oµ ímÏSx«³%?4ßi4© ù'ÚXžÛó­Ì¸a5´rG¶¶lg~ ƒ8Q´ÉÙïkÆ©ýÜpÌ¡wð4ƒˆ¾žÔhæGa|ŽðÅ¡˜EËå84Dßùaõ—ÕÁ^ñÓQ pÛÒâ,,<%…/ìóbˆÓYrÑTƒjÚ ‰¬I>A· #o ŸntY™~Å–‘¯8,£ZIœÒ¶‚Ô¡åéò4L>/XObject<<>>>>/Annots 2007 0 R>>endobj 4944 0 obj<>stream x…XmoÛ6þž_q PÌÙlÕ–_âlë€ÌMº`mÚÍî†2Z¢m®é‰RwØßs¤¤HNסEŠä½¾ðÿøåÕI8CšL/‚>¥N.‚°\%4?i®±;ƒæncÒ°ß.»Í5v‡Á¨¹ÛXc÷|Òº;MaÇè"ÄÏ”FÓip^®Ø*8€o}·ó«o5–)Ù5÷Ë”ýöÅÑäŒB/uÜa­_ñÕ è~Ù†ž_ †k`<¹À/±ƒ¿DÈĒΞ<¿ÖîPgÙ±2ÿ‚Þü>{{;_\Þ.´ì4V˳噿RÉí4—^ÎQä ¾s-E^dÒ’Ð1å[IÏÖþ Å*“Q®î%‹{¼YÞ¡µÉHéµ!£ikö”»]r`1îõ!êT"oØñgv¸NxŸñR×…†>£mÛ~>6Â6Îh]¡XF‰Èd œÝóßn^á÷\fkIZ«DÒ^% mޤÈdprgt¬ô†f?ÞÌ~ºº¥y´•©¤]f"3 ]Ã)ù Ò]"»Nî¬åJ¥ŸN¡Šì_Y¾ìĦXAÙÃòìÛS¯r%IÜ •þ^XVÉЖê€[ú‰°B…Ã2ê¼<¾poTÜÆ©C™D(5Ý‹¤(}ßTá«B1»›Ï~¼zsu÷þöåÕõÍíÕKˆ=®Ú"É]€ÞŒöe6¥âPIOM&áл,u­ /½Uu¾}¿x÷~qlªÝÉH­•̽ÙùZ­žG[}úy~ØÉTìl –g-¶òP£ê=DÐ…K˜ê3,…ñ !óöØÒš#K–‡Œ}/©5Ç~)Kmÿ<.0çØî+mtá¯ñxsýàH"…Í4"Û˜"gj3w"©DŠv i&è¤ä{T”“BõMXï0i)·!pA§^IkÒ^åÛ6µ%ËN$’¤Ç'zÿÊg«uLW‘Ü}¾\:reYFØÆ‚´EÊÙb·3Èx&Y‹‚™ÙkZg&¥ƒ4ûúk/xìß"Ql¶„&ëj÷³ÜV›Ø R7N¸$ÙyzV+w‡êÖÖ¦9—ÌuY*Øg+Ä¶ä –UK±µ©¨]Y3Ÿé–V¦ ~ÇUÎèÝÕ²—&F£‹ŸymEF_¥v󉜮©hï%ˆ ý?ÒÁéY0ö5fËÎìno²˜Kê©ôš9~.hG(¸*m‡ŽÛJí­}°ezU!.±âZéEÂÊ'è0ÕLR¨ëHäÀ ÁzÔÖÖíúxdÒöXÁÁTwdÒ´ýT/[Syº©b?×&IÌž“È*îý%UU2§˜1±„ÈÒ0 †C¬0Ö”tV[}—K[>Žò¥A5Èþ¿îhWî3yæçãw.å|e£ßyl-,G©cù·–‹£¼H 6véÅ Tçi0þöøà?-ÏÜòqØì9W†ÁdrÎvF¦Hš’²B·ÚÆ'_vž$,Bw*jé$¶“}QîÆ>-w–]Æ´v:ã-Ê¿8…WGrXRyj±Íäž,r!ß:ÊIP»§^A5û6ä£q䞯kàUåfP7S®Pê4è{$0‹"¸Jf¯ßÎÙŒGÌøÜ(˜N0ÎQä[°¤:ߥW™ÜàÛO*ú(‰q!–6ÊÔ vu<ü òŠX‚¨FC—{©Ô¹ï2-è2Ó2Qeüe…‹«ù6H†»˜ à!ÌêOÈãln"“ø9áH$´É{Ì >Í™»ýäPå½3im L3h²°Ÿ—hÓž&[êß>/XObject<<>>>>>>endobj 4946 0 obj<>stream x­XaoÛ6ýž_qT"Åq7í·¶k¶bÝÖ!ŠZZ¢m6é‰Rÿû½;R²­¸MW-ZÙ"ywïÞ½;ú߃áÏ Nøo^¼º>e#|ÙÿSÏéøòŒNFt=ÃÚÉs<òyò¾6•iÌ&¿®¦®ô¤lA³ÖæqÖÓMÒ,4Ûèz¦rMÍB5´rmYÐTÓ²Ö^ã]AfFé²v÷kZ)OÖ5´TÞëâæ)©ZÓÂ…¶r¶uT:;×õÓëÏ#JOÆp(Qy®½7ÓRgôv3šÒÖb›^ö殪ػÒXSçmÛd|4E£«o9âÝVŽØìí¢[™²dÏÕ2¥‚¹#š¶ÍŽ+Zå êÖ!™¹G€Óµœè›ÚØ9ö'¿8Œ›ÇgÇ5×÷KW3(Á(YUiO¹²l8w¶©]YâõÊ4‹i^:, Diëu^¿î»«l†o·Ø $€¡ït½¦JWS]÷‰íã›k«kÅÎöÞˆeqšJÅI›´l9[­+W¼ØŸ‹=®ôyéÚí1Àƒ©Ã¯#pDé–wÆÌ­«u‘±3Ç—Ïéä,Cš¸Òñ?Éx„ÿß{«æ:,ÛTK:>Ë..xÕûR+¯ PÅÆ……“XV ½þõíëßÞüA)½^ Å“«RrÉT`žÑU¾Ð—™ot……{]?ñF·ªÜ5œÐÌÕTèEfº\’³´p+æ8èKnúYç ͰÀóæ¾° ¯52ŠÌu^EÓ¨Ïy­ªŒ^ÕFÏÊ5 eÏi(xÙ¢hñVß 3"!ɧ|aò[mS0yfæ”êû¦Vii¦»ŽÈ7Ÿ†!®ÇÎó (F±}.í= î­][ HŠ[Šbe ¬TÕÀNÎ}àlcýÂaü²Gr¥ .ÛpkT2'¶\CÂT!iE´,Zÿ¸–*3_4¤Jï ‚a3*Yœ©ZˆŠ7Õ²„«ÏrŸ?ðjߢlªD©6zž±™ÌBå7¬\>ðŒ™ËPk”Á¦Ê!c, "CÊ@à¾Ü$K²“ÀwIéñå¸K>!\–³á®§7O!dt½€åJ+?˜l@-À!¨ñ–îYíªÎùÜfnüDUë†Íˆ¦˜Ãá`hRPˆI§Ù ]5 EMScä4Ž4ïkþ†«¬ÞhSKßt8í Š¤êBCC€¨°‰Y0Û¦­AoUä·íEýÑEvÊÎ9åãìôŸŠä'ò+.ÄX˜è?Šy–™_nùXÅÒ»þµÏ«îù#3Ëû«Z-ñ±Ñ¾ùèóÚ,›ŒW§®[189;Ž6†]¼©øyšM&ÏØƒ+Œ GÉ©USw‡,+»&ÛJwr³avcuÁøîÉPHV>`'‘:‹ã_‘˜¶"Äã±)Ú}Û#ƒHÌãŠGˆp(÷{ö·B½Z.KHKÍLŠßŸ•˜†ˆm—¤M2Ñ¿†×·^½;n w@…“ˆÕvt–¡`pÄ€ÃÄrFd§KʲB+´ €êÿçÀ^D “ê`ûP²:ŽÞì¥ßÛ²1(Ž ‚^äð©ÞD/\Xû2€L1™}ì=³m7b©GýϲŒö9ßyòˆå=Hzç·ÔæKP»ÄoAm@ åš  dݨ¸(DŸ;Çâ„p“°ÎsÏe|íÓá»ÃýbÀ>² ±h¬ET8”>ß1¬ª,šz‡°;Ü…F ½‘êcsÝ‚Ÿ<"ɽhè°áÊ$¹§KŒé«7 ÆF‹m=Ô2¦k©]ɲ’ËPZ$ýæ¡|aï-_ÂD†D6 Ö Œ…h+WßbÖ ×¦v¤pO ‘ÂF“/$P68½|þƒú?÷Г{"ÛDê‘LøÐIÓ°w{€ý.Š`öYáÌ#s;ÁÀ\AØ…´ÝØ €’—aCê0Òô|Ž[“Ó1Æô*Pÿë"cMœÃ¾c.B=nµ]Ç—4÷xÇ‹;nÈHG• Ñâ-æ3žÑš•£¥ ÷fò®lÃ¥]¬ñ»Ãᥩ}sti dhQj]ÛG·±Û]¶E*|ÜeM²Ã–þ¨ï*Ôx?»JàVÆÂ]›ß‚‹óî®$âü1tÙ}PÇé÷|3ýb.”;½L|qø5 ®#+;3›D¿1 lå¿{Ž>ö㸆I _üØ$ ry[ùb¹âZï "èýoÈn’ZÿÛ0ïI4ü@ÇûŸ2ºÒBszI€¼ðE1Ô`l Q ûôEÓw¸:3 ·J¥¿Ê†ë²”t…›=–„ÊßÌc1[ãÑYv~zN“ÉY6’;<_|Òq6¢Ÿ].¿ÉÇ!bP ‹ÓgÜÃäGŒÖÆ®_¿ûóŠWœ&Ùé¿ðËçü՛냿þH¬endstream endobj 4947 0 obj<>/XObject<<>>>>>>endobj 4948 0 obj<>stream x¥XÑŽÛº}߯\4¨SØZ¯w³w÷1Ù&mpƒÞ1—Z¢m&’èˆÔz¢ÿÞ3CR¶$o›¢H8Ež™9sf†?.®hŽ?Wt}ËóêâÝòbžÍñ°û§ÙÐ出šÓrµ·÷øQÈ{üÈ'okë·º!UzÝÔÊ›'MÆ‘·Ô´5}þòñ/TÛ¦Rey U”7ZyMŠ\¾Õ•¦µ)5ù­ò”ÛÚ+S;z½üvqù°äÈÉã¤Ðy©M“Öi^/ÒkªlQ«J¿zýø:ÀÖü|N³«,™ä¶Úu©ëÈmqjA¥Y5ª|G{]–}° égUíJ=% 6› ‡ÀìkiU‘¹¼Bღ ò]vÍÎ]Ób‘]_ãÅÈl¶óê1ZÅè9gW-ÒªcÜf²÷uv{û+õekò-ím[ ¼¦•†ûÅíßþGd ·7šåØå;>f`™INXg–,FKr—ÓÌ=ñ÷ŸÂfpÿX°çäÉ×}£vY.O~_}5BzÏ,/Ëœíû|à‚%›ÍAÓÏ^#„¶îâœ+q‡Ñgw #û8iôÖ€’ÄQ#¢eô–©B¼‘Óš Jòi¤õ©Õ}¤“c*0ÀÜ ½”OÚn´wÀ®óÖ3Èd vm‘PÈÀPÊvâìSXíÒ[Z!uŽ’øt1@> _zokó£•}+ÛH®u „œ\·e€p°-íUí9ÿA¨•©9Õ×z”  Î0‹w‰B£ LI»Îè†Y3JØåˆe Ñ%$¤ Õ¡ïÒÑ+0Á6â¯c prÝ0ù?Ö¤ShV¥ýÖldÐ!È ŸÑeÃKbKò¨ÒYNžÊ¿« 0Ér„]o6-ÏjÂU$ð0èPÇìáȼðëÈ)lQWvMp8›â<ë®*Ùßü«°PdOµ\ÑgÄ&@Ç<¼‡áÿÉlFËGô£á$|[ç³*ò „`Põ§"–OH6DQŽùüî¼,ò:Dç3ò…ãÑwÅä}[ws‰ó‡,¹·PjR[Žs¶mrÄšÍq û„@¯ZS0mo9^n*”l©7am×Oº@ñ"{ó¸ÔiT¯"J ºüpO\`¸fηL¼Å<»Ò2õw>¢jKoPBú©!r³4õááÓïŸû ƒ3ápÚÃ[è€P9m–E˜,ŒüaÇá…*ÔgÝ÷ÀËgg‚ð²c¹²ï·\*…õa“Á³]cŸcZë.">R ¦WirNäaA]ƒÏüÕã˜Î I>j°8V£“Å’ãIJ÷ -I£×Ðð:ç\³äÕÊ–Žb_ÂYßßµS"3Þ}*òœWjhìO´;WýÓ&ãz?!Ð}¸êX´Â›®…b”ÃÅ£æ©jç\×Ϭ­A&8Q½Ý‘=²±á½vt*ôZºÓP>$aáfÛÖè&áœzhDd(ýÌÜõeæ—€üÈ¶Ž­èÍ|„;bÉOxù'›ÊT Fg÷-,Í,ž`ÿÞ6ß°fÔl·⠕’«òIÛuNùf5¼aÅ ½l³i+J‹@÷öé*Ш¯I]‡2tî€"¥µ­ îã‘ík!;J;8ÚÔùwX`w""0‹‹ø“nšÔÿªÖ[–˜œ6ºÖM›17†¾gœã0ªØN¹N…còÒºãHp¤@„è¥ìÌvI§œÎ"<ؾ+MË$÷Xз'˜+õpøñ+”4ÝøÇ ÃÚA2ÌóãkzõOzõ¯pÌ`ÇQ4\õ!ÍBÜ¡Ew‡Ù¤›-ЕtŸpûNB&ö%ã‘4Í2_ˆÊ ìŽŒé~ԣй–÷< Cït„æ¶Üôlˆ:Ño¡1Ø \3'F‰Ý#ƒ@öÊ<ÃHîn9~q&ýà^Çb¤L„ææ' |pÎ¦Žˆ=Àÿï”ù8A•ÄxUi…ayÀ,pÚR2ÛzŠ.G¸gè?9N=È<…p²Ž½—…ì]B®CÎ÷r$›Ð[WòH­à˜aPýmÑCœ•y<&|„!Ú†Î/4ñ]žÍ’°¶£ãhXz‰}ã*÷²*H?ÌJ¸÷†ŠVˆYðNnnxpcñ¿²†²,;£d8óP¼ùà&t8rÂŽ04Lé×Ù´v˜5x7-Üvr™Òwþ蚀_w9]^/ÈÇ®ö†{ÐÐ×Þ…víZ¢Í¬Ô.ÞϤXâ”ÅMvwÇ 0óïáxiÀƒêÔ—¹ŽÃŽžŒ’_¼UÓÞâ?´nl5ôÎ'³êæÞL¶‹‰“V“­ïΧßÇ9#sûáœñ_qK·Pe´/ýèœ:‚/vaU°zJ ×2zøëLJßÞÿ¼ÚðD×Áo¸€5¶òýTú0í,ä•™Ç7¸o+1tA@{¡WôdMAÊè 7€ˆÛ°´ã€ð^ŽJP¸î‡Í820›6÷mƒnç3&)ΣAAh´©w4ã#md}©qÞu»“»ÐˆR…¦¬‡"‰7_ à0¸y˜UŽï¥òà$Þ×®¾A*¢­AÓÓäÛƒt<Ÿ¢BеâY”‡öH£»x¹˜ßdo®ßÐíÝ"»—qQÜ±Èæôg›K«'ýcÅUVX<û5ÜÊd¹ w<ÏrU|éZÅ„ÛÓ7óÛìzÁ”‡Òû{Þòýòâÿ´(»|endstream endobj 4949 0 obj<>/XObject<<>>>>/Annots 2011 0 R>>endobj 4950 0 obj<>stream x­XïoÛFýî¿b¾ S™Ñ[–sé95Îw°ÓZE€ƒ&—ŠËî.­ú÷¿÷Í,—e§ ‡H.wfÞ̼yË_OF4Ä¿M¦ü—nO†ñwø¿ÿ÷ó‡“ÉpOèb8§´¥Éä<¾j¯Jº?9¼ÆÓË«xtøôàO¯¦ñððéÁõ–ÎÏgý§ã+\Ÿ_̼ÝËa|Ù^‰Ýƒk¼;c•_+Og¬_NàùÏãY{ÅOÿ¶8Sb5kz}}N£!-rà1½ÂL`À4ZhJueiRG ݧµU¤>+\çFoqsNµ.*§Ì€ÜFÑÎ$u­ ÞË¥IYZ¹7Uê ]ÑéâóÉëk ,&£ûO7V·j÷Ñïq÷ðy=ê"£Wµ3^<¤³Ñ^EvW¬Wî©V«¢Ê5½âŸ‚iÒ»J™å©ß:D h:Ãn“¸Ö¡?õáh'Ú6ÖÑ&yTˆ÷11EòP*ÊTZ&FeýÝ:wç«6ˆãK÷V¶NRE?Ð|HtºŒæ«û›½¿»^ ïnnï^žþåØô£Â’þB¹À»àñ[mßë<é*zŸ9°mòE‘mŒ¢C_7‰%Uéf½!ï|® ±œåԨĩ,¤ÞÆ­ñ9g e³VN¶µAFÕFY…:Éèá‰Ëæï7ó¼¿%—¬×û¾©†|€¡„º°ȹ®•qaˆ%v@¾¢^Áƒ¦túz%åe²¶/TRX[Tkørº‡iBm—tòr†JýV£[ö!×mLb‰S« ¬2ôoe4áÃrXýxs÷é––‘UŠT©wËSúõõqWpÓž§ úxOÁAó¬‘!]–°‹–óp…¶àõ籤é&¥{Äâ0á)J­ñ mÚß5âHFƒã×z}üÆ®@1%YPó¢Jʰi1¢Ý¦H7$ˤòñ€÷èž)9PÃ_¦Jåm•ÛèŒ4dž†÷`/°åÁê¤ÊÂò@–ÐÊTi*uµ†Èš6œ5®úÆ*ð YOÌl}f*@‘*É$wÄ›§ðü‹ªÐY碭Ó v)\“p^,T0Ê—Îc¦„Ë€#%@5Ê5¦òµ'¨È»ÑM‰Nê²îç^e¿¹Gºqz à åÙ¶?’èG1]3šR‘Á ô§ä¨"¾«Ô΂ã¼f…áÂY mùhÑ E^´Èv6€…Ê>ZplÙ(K]”ô,²˜îÑRýÁ‰aŠð€’Øì¦¨%'}‡÷ã>ÌÁHRýŒ,yÖÆMW}’{)•< ßüûï÷9ôà[ÛðääA%¡>;.ˆnÓØ®pÚÈ÷õx®_‚RDµÑêü¥|y*9ÎUQÕo’mRÇô.Ç' ðòÉÓ ‹[ •°ÇO䣾ð 9ˆ¤Æ>ýä<‡-ÕA‹qD½“W¼G=Š'Áð2#õÚÉw  ¼…´÷°=¨—JçÆŸ/Ä—–Ó"c)Ð<¢ôH½Õkuü ´ô¯(,.a¤;tèÕÁ€&j$j[8éH)$¦H*iÕ"m$æ‚:€“8Î2œÌ ^Mw¤åÅ&wÈŠ<‡žCûUÍöí޵㥭}³w2Úê=…ˆŸ‚ní(,ƒ;àPÈ´O´œBу½6³ ÆÀËV!”X_"Bµâò™×¥ªÖnƒ³fßm_Góׇ¢ )÷•é%¤ú-ÙÖ%Ø–©¹ÏçqHüMÇ–1grO&¸Ê"¤­…ôÔôŸÿÊ ˜–žäã}®õ2âÉ@Ö¼zhÏÉ_Yõì}&Ö&ñý kBcÈkÖ`’L´?tq¡9ŠJµŒe· ŠÐ+Czëtý×å©¿Ñ[D‚K¹á7‡¸#9ÉÔ†+%rÈÆ‘íˆßæ{]ˆßbÿÿapO¤G¨ý"LÒTuâpʺbö)¶ ‚#;>$9ýì`íKGæ’¿Žp©ä…Á ]ù9Í`þ:øh䱟Pþ• Cn“*@(”1Ú´ôØŒOd“ š^àŒ n—³1¾Àý¨S™¦B¼ñ‹Ï.}qò‘›>ú/W2…øcádì§Éd8ä—Þ/N~:ù>Mkendstream endobj 4951 0 obj<>/XObject<<>>>>>>endobj 4952 0 obj<>stream xuSÉnÛ0½ë+æè±,Éq =´iSÐK.45²ØR¤BR1ò÷}Ô8Eá93zŸ“œ2|rÚ^Ưl“Ïe’¥6—?w ÍÝå•5j/o°¨†s,äªlØ1 üBã˜É[Ýe§`±¥|J(!^ù@jØî»ƒ:b“qvÛ(ù‡ ½°óÒÝQy>Êj¥ù¬ülî€xB³Î  YÝ«ýFŽí› Ì«ÔÖ¯Û^µ>°a§dÚ‰ ›±}&³"e†É¿¾ðÞI&iM ð -$ñ1Ð<7õ²E£W‘@3 Êh‘§7M@æ )ªŠ|ßuÖAƒoï©¶ŽFœÂú–M  0t{‚¸l„q€$%w«qȤ×ÓV>R[p8~î•c¿`Á;÷LŽ÷½Ò„©Hö>ØHZ“­çÚ”>:°3"¨<ƒK§ÒŸH~ª4ôy¯ólÝð_ácL@6V’&ÂÕ!©HÔÀò&ŠÆƒó‡ tT‘bã¢'Þ¶Luoä˜ÂÉ©Eñ`O”’Ö9–A¿.ý׎!Æ|„<¦VÚ6úW <ÛE÷64 p‰æZÜ e°l¡&R=Js=%¸È.ÒÝvG×ñR­b×EšÑ+‡0 -±c=®¯bô«U‘¥Wiþ¦Jçì^së!Þÿî*ч£'í²Ët[à"cÈ6ËãÖ×2ù™ü°‰Mbendstream endobj 4953 0 obj<>/XObject<<>>>>/Annots 2039 0 R>>endobj 4954 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î‹=¯7WÿºúŽÕiüendstream endobj 4955 0 obj<>/XObject<<>>>>>>endobj 4956 0 obj<>stream xuWÛnÛF}÷W Р‰–%[q‚ ±ë"EQÄA^ kr)mMrÙåÒ²úõ=³Ã‹HÉL(Ü™™3g.ü÷ì’øsI«5ÿMг/g‹x—ý?nC÷Wt¹ ‡Œ…Öð+ ø‘D_ö”êL5¹ŸÑ·_ÿ .µS^×äw–i“ëú#ù­>øçìâ~ÝÞQåìë^^v&¢VaF¥*tJ¹yÖ¬Jµm\¢ÛSzŒ´Á[Gu¥“H¾5Ø@TÁãÍ/—p8úMü˜KÓ‰7/š¬ën ꮈNk&¶(TÉ–png|²}<ŸÑnk’-%¶ôÊ”5©<Þ‡H)ÉU]ëzFYSª-ñS—MQÏØdï«öI<#¾üf¦ôÚ£ÜМ vb]â˜ÑSã©n²Ì¼58¾üӜގlŒÕÂ+¼,£ÛÇóÉU}ìà ðU‡­ ­œy¨RÎ×dË|OM OCà%ÝÓÓþT +f3sØ_^qº¿fA¢®rã…fÌM¦àê)Ç}¸¤B:L¹(ÞKIù y˜^äi¥0øRGÊiÒ…ñwzËnô( ãÈîʾEíµJcz§ pdðe"áöìÉœÖ=^‚Îj¯J Õàw¢j¢¿¸ï(;G¡¶¼ŸW*yVMŸªçÍçq.©Ã*†Ó­O}ñv\”´äbbvŽ€K6Àç¬îb:¦ïʶâ|Ïho›T‰*ÛZÞÚ0Á+·Ñý5=tÄ©XwNU•v¹yr¨ú´Ëߌ˜áO˜Ó¦e)Ý£|L˜–[ªn/nß½C”ÁåjÞ“[û\S†Î¡ÐÄ&«c£_…¤?Yœƒ<ÑvÓ˜~pe03`FŒ“}ÑÎøÎ©âR'+tÏ (Ä/;?C„ÈãÉ5¥7~ŒXfâ"˜zV9&Ñ%ä¥ô{½Eþ¹2}ŸéÀ0•)^«ÆÛ5àœ¡æù=לeújúëÛãy`o_º\Œ…Ùl=éÐÝ¥ä5w¬ÉÉdLÚ¡˜m¦|±!µ2 Qrë Z£‹p3üÑn¹ù¡¶«)§kÌ.8Äáqÿq€CDZH-“¸ŽâÜ·÷.¯btœŒBÍ-oø?i´¼ŒWô°¯t¡ªZ`…$Q†y;_®ã››N,¾¤Û_èÓü3ê)ä’½µ-ÇùÉõèn ÊZÉžžK» `p›D+„$3#ÓËs»ãLŒ‘ç¶Ø‚üQL/è†ãÈhÉÆ—ñj…ÿ¥%¡ÑÑÃAÈ«3–˜Á7ÅIù .gcù¤~[>壩8Záñ®Õ¦Â 8zDGSiY¬™éáè-¥‘©±Ò SaÀe*u‡§‹ã4MM J?Sɉ’£À&BèRw4U~ÂèLµ¿Ä"MÅÃúnñ¾å:'E||t¤Èvú´Š8šŠ›¢²<ûGO „M5ž,Ê`ú´àh*ŽjP¹ùo쓈§ºö®I¼uS¥îdd¦U2ueñê4:øƒæH£;a[÷]‹˜‡r»Ž×ë÷}—XJaÍÚbB'í aXÏ:ÄŸhÀ¡Ëb0 `jzÒ~§y>£çÊ,k'ÖìøU?>ô+Ââk‚Ö°‰ˆÎ]/'ý¦,ìÛ’ÃV,ë7Þnœ Ýµ0GÓ)tAiøRàÈÐ`y© "ºuªy;敜]–ÐñDz/!øÞëÞ%YÆD8s¶ºb¬Û2¢¡O xGÁ{€‘7о]XÃEzX…Ç+¯ í6a§cW9 Ùñû5K¼œ¸u‚ƒWýÉXÜ oºÙ¥Cry zrÃè깂›3BÃW7ÉáwÛà´Øù÷yÞ›à!&6ßAÛT@@¨ÊŸB`Ûüm?/;R†9Í7qˆÝÖÓ'›N»fðòVce:^6Ú5ðͼO¦ð€îëÚ0@ƒMSh^ÎÁ9©™©OÝ ‡(¬ms.‚iXJGIzŒ&9?U óÏ@Ãm8T¾¿Ù؇‰öQ^ÆyÑ¿dºäЋÊt¡COYî(D§}ãú¹Údé˜z9o7ô¾ÐNE×fíâþ¦ý¬_.®âëÕ5­o–ñUX¥xõ™/ãÝÙ$ä |Wrìè¦"</û–³%Ý~¾ó™ô ׋u¼ZbQÃî²Z¬øŽßÎþ>ûÉ–9Mendstream endobj 4957 0 obj<>/XObject<<>>>>/Annots 2048 0 R>>endobj 4958 0 obj<>stream x­XmoÛ6þž_A`ýàb‰ê79IQX“uØ·nÍ0 0Ðs‘D’âøßï¹#E½9k‹Í-S$÷òÜsGý}¶sü[ˆÕ†þ'ùÙ<šã }-èëןÎñut)âëy´¹XÎa”‰ÏgëuÍE|yųëxƒ¿nij½q.Ö—qtÕ›Å1"ÞК‹–~À»a.®V$”òÜb]‹xÑyFîÈnŽäµNîU´ {ãÅ:ŒÜì'­c'9^ÉnD³¤îzíÔÅÆµÐkÔÎaûuoîÃ]Ï©ìYû Þ|\‹Å\ÜíàýÍ5~¤ìtüHfw{%^ßýuöæ#‚Àkf©¶*©Õ…›h7ÏD},U.K¡+ÑT*µ‰)ž”­E)­ÌU­lEOkH¥Ån™.øÁ­h%‹DfÙV&b×I­Mq.t] «êÆâIfÂ!tü\\,–ÐxVZ“¨ŠNÝ_ÒØ4õXåûY¥”تÌî_GnöZHòÆÅrC²—‹h§z¤‚ïVU~Ô&òI2îœo*±3^I•xP…²’¬ðÀ­€ÏG! ø\s°²,ÖffU¬Ëci§ÂòÅx¸£9 ºxÎí‚Ã'CEkòÓ1r:æ&m2%ÈR®ÑAL>ºº@ðs•ji0Ö‹¸ŸxÓ0×–r¯àúÒAÛ} à;¹L¬!üYUf2Q)‚*îð¤ø ˜…ÅçÙžÁ6äÊVÁIlšÜAá9¤*!³µw`R&Êž³×Š‚ò¥UîIH”ó1@KSMI@I"êB"÷F…¬k«·M­*hXÏ.³îge¦d¥àŽÌö™G›;2µÂ³›ïD*kÖ5dU.mµ‡Éäõ,sˆîn9dƸÎÉwº€ sl`^«”Ï­Åï${¦„ò€ûÄЃ¯×  µ!²1÷zÇâ@Ñ{“2†ê½5ÐÑOTI<å]Û¹,ä×Ȧ¢0’„Î'/Y8i˜iuÀÛ‰SûYKØ>­:ipóý÷N õŒ‚¥OZž‚ÐË.ÿj`¦S\c&ð¤žkíÑyø–Zu‘Nz‡¶Öï”d/A™Jý󡥇½*„<Ñ?Á«ºx2€CfÌc%2ýHìuõ¶%õ hv–ÄÍËhµÂ( þð9î§ÿ¾ùôé†JþÛ·9ÈrÒEÞ¿nƒÍÚî¹_¢m?ýÁÔb¼ç]‹y„ï}·-<ÖÅûñ^õÇ`O21ÍÙsüSãy?s+`X§ÁpxþÛÿòŠâct>Ök¬–_1Ôëö„(!¾Í+ïú¹3p~”ÿÏûéØJq˨ŠZP¹Uo>¶ ùƒ4Ž6›K)·å1gC²W¸-X*”䎮°}þA%t{.š‚uì(ªÄj”7]&‹‡…­US–ÆÖ®èþýçŸÎѳ¦3¨o¢P˜ ­é±¹NxU)ëd/ö*£ž­„Lè:‚Umlø–bpÊŒL±¿m \ÏX6M O®ÃøÌÍ•UÊ<5´nnSz§UM´á2ï§íD}°9Tâh†lêP4U `Ø…˜˜†®¥Ô ð…ïQƦÃ;éoÜ0ŒÝAÍÃÈÁ'›%SÂ5>/XObject<<>>>>/Annots 2054 0 R>>endobj 4960 0 obj<>stream x•XkoÚHýž_qÕ%+' BHöÛ¦MU­´ênª•¢Á`ÛãÚšVýï{îŒؘ´UÓ(ffîœû8ç^óùÄ£þy4šð Ü>á_ÿú÷ÝÉh:p‡4™ Ý E4zîMñÒÃÉþ3V§#wº·êM§x¾º˜³ÃÑ z²gÇî˜Æ7cky2¨žÌêÞ3,ÃÆu±—W½‘玀٢òÆ7Õ“YOp“w=1–½k¾×>ñꟳ=7¯éŠ.ïoÈÒl‰xL¦Sš& šù|áö‡DúJ„´©‹PR$üTgg³O'—÷cò°—O÷‡ìÖ,pfkIY.â@¤=||ÿ޲–…ŒD*Il… Á¥Ni“IÚ©|­bÊŸ‰»2 dæ§j!âXæk[Ù‚ά<hÉ8¹Òqssé³sA¸Ñ¬QŸùED \³N¡ ŒSNϳ”^âd{‡Š“MþÃ]©Ì6a{ÉÜwù¨ Ãø¸–1­d,SÀWô†v©H™f$h)w$‚@±gȇMC3”·Mx•á^à‡"ËbÉVš;w¿Ý¸ågÇÌÏØhS„n¶VÙA†i§Ó'|¬"¤8¥\ÉÛå}ëø‘oâQ±±LY]hŽ-‘“Ê)•ù&3Sìé%âÄf¨ÏëòK‚:ĺ6[ÞP’ê/Ïd\ã‹ú-€ò4—˜9¿œþÀ¥÷KcÁ,ZfëœÖb‹2ŽQ§™ErTéÞÌù"§5Œ Sœ@n ò Þ˜O³ÿ>¼}LðïAGò.Iî8µí´")E!ÕŽëÊ\ËNÙ­Uà÷­ÐùyËP³@Ámf.þç;MÑJ­.Ä9èZúuï÷ãõ‡µõÎnw ˜¾np+…r+CN½Š•JŸùqÁnTqÝ­È͹ Ežãd*#½Eu,]º‡ü¨˜%Ë—/Çê^ëú{?ˆ± ZH@HBá#9‹gƒÌTNµ)S2•éë’h8ˆtÚ#ÁÕ•¹zO¿¦¬Qƒ¯_Q :üœT<äÜmÂð™>oD¨– îß½~m™€Ú­U3”f³Ã¢_w x¤Vëœë±GʌǾC®?_¦¹@?.Ï€ÈÔp©l¡xÉæŽtW.m_dyÕÉæg ˜ò׬"ˆ—± ÕsUegwÇ(¢¦Wuu¿É×dJg.Îg-ˆw—\v%ÜÊ so=é 0û4•˜OàW+òƒ&‡ 'è˜dV„6…˜5Å(‰´<Öåµ46^ }…ËÊ67€ 7hlÆ&úPN>:ŽÍKÀJ°ÀEzƒf'RË„é@ÌM;”iªSÓ*5œ;-Š›zÕ?ZÞÌÏ^HÔèpú9:QtmîÔjÒDü õáÃ:œûêêp€¥¹§kvàþkGKtVv9 t6C)Š{8ÆÐôXÔL혠TâRQžKÅWf@SL阑‡¼èŽFx œÓËœ‘ƒ¦ ³ Ð9½ªÜ•Ìï>h0^¦s§g>?{e\…9Ì©0¥bðRÒé·âc_‡ ]­ŒÑ·ï&½\ ÅŽ­V¬fzîÔ»ÎEºšŸ5wž~gÓõÆ7÷‡#w2¹æ«B)ê1k©ÃPï¸ü«‹ùh'ªŠƒÕ¨Ú.\µ},âþ¨"·éG3tæp۫©RDûW<Õz¥S=±â5w¸S´% §w˜ÙÛ»'ëN£‡4 oɨ&®ŸgÔÀBÕ%_¢‚{àL'Bh*^ª ©Fè9.Ì挩ÍHJ¤Ïé`ƒQË*<úçVá Ž·1 º•YQ³Ìb¿Lÿ=ÒÕL­ðö†Ù‰œ‘@“ —y@Ê¿¢rF?+3.¤^|Â`H˜9d®ð¢0wò5¿CàÅjßPsˆ ÍÚè„`÷³<Ýø9,ã‡%z!1UG"}‚.l•hÃ?åÎ^Û*ŒBR+õ¸cÔœ0M "OQØ/ódOEõ–Œ´©Rè:7,­o±v‰êp¡¥A늗÷øW/ÉOݫѾ¦º×VCùm¨?tô¦ýÖ¸c³»m¥îÇ_f\ &îhˆo2 g£Á'ííì䟓ÿ CMendstream endobj 4961 0 obj<>/XObject<<>>>>/Annots 2059 0 R>>endobj 4962 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Ü,ìÝ{çp‚_,»Ó) ®Û9¼vr2‡Süåž.•8JV÷OY¢xæ£E8à>(>ÓÑ‚>º[]üvñ*â;oendstream endobj 4963 0 obj<>/XObject<<>>>>/Annots 2063 0 R>>endobj 4964 0 obj<>stream x•XÛnÛF}÷W Ü ›ÖÅV”E‘ÆI¾ôEQõaE®¤MÈ]fIÚVŠü{Ïì…’hÅqa[æew®gÎÌêóÑøÒx¿Yy4HxÂCþøãÝÑèj’>§Éø*}F%¦£ô*Üôáh÷¾¤ñp’NvÞŽ§¼k4¤—Ø{9¾Ä[Ç{/‡S<.ÃÛ+~ëîÜ[hŒ÷Ø;vkÝÛ{¼NÒáÎÞŸg;Ž8oìŠ.Þ^Òp@³%»:yŽ«ÜyŠ‹,ymt#”®©YKZ¶E±¡Ï­(ÔRÉœ´(%™¥{§t#m)s%솮©4y[Èôtöñèâís²/Ðpç#vo–'#6ݯv+’“¥MkekRû'ÑØ]¦Ó)KšÁ¸¨“r¹TZÖ$H·åBZ¶0WVfºÁãÛµÊÖlŸZnœå,¶—^D%ùðçûwlqª·kbäªeC«Â,ÆXZâOP]É Ê`JV+eô o=ðãBí¬gÓOòRhµ”u“]7û>&$tBwb‡[y#ŠVÎÿïtGy8bñ¿¶MÌÐÂÜ‘ój%µ„U£,“u £KÙ¬M^;^÷5þBº¯Ä÷úéSröÝÔ)q&ö=}ØCÄÁÚeˆ¤‹‚eEU)½â$Õr«„DÍÉQÛy>OzšFTiºžõ”ÀJß=^9šŸ:wùz‹`5k…‚0tkì§3‡¡×>9ŠÄ-ØÚK.CT¶u`¨d¦¬T!½+™É%‹1íjÒ{®'Èǯ6“ž‰Zž±uç]¸6¦¥LhÊ‘Áw#­UÐÏ…*ï*‹¼vˆ¢j©Ù\~sM•5w›PŸÔÖ!Àýx사—.UgT hÑ+^Ñ™Æj´¼ ~#YJø’ö~$½èÚ²PŸ‘Xþ˜…„sà(ø½Ÿ PÖ°:RÄG$1Õ(°Û°F|à8ãjrù˜:FGà·h¿c7g”µ«(Ç3JÚym tƹî"êrú-Ó;Yf|&—­³CTÝO!Î…R|Òú¬ÚE¡²~nã½d–ÒQhTrOˆU7 ’¾Ž  jÊõMÓ17Ó(qçp?RôêÅ‹¥1t\yáÇ/ƒEØÇë•.Àïtòo4Ô=®Ûf ½¢ýÇD7F嘙'óÓ(‰98O¾îßž|õnìt«+ß­“g¼ýêŠ~³bUŠ^:;l{‘E¸ùíãÖ3nåwm;CW޾Qž…¶ËÐeä*½É#¡v™)zÞ·ßW¼Êy’ÏOI•¹×Ãö“µ‹DéꙋFÞ54O®ÁS¹äý5®*nù`™úYùäpÛwP”w¢¬ Q5Öó„û™BM»}š™kîzWDZhe‰m"ÏQë@[i´–E…êt‘ˆTËÑZl³5›J–¢ª¨Íƒ¡QeelÓKì6:¯¶¦8ÝÈê”­l<Ë0í \IÆÎ{0Hˆ/oq Þ.yúxâE±3û+¶³G)2kbd9lnaì§ki‘¹”þB£Q,ÐS7t‹&Í™sðrMF#’úc ºUÍÚAÍc$òZò~HçŠxd¸g=Œ¿p»t Ò3åa‰oÇ®ÚRÂ×-pCÁyÎìfÅyæw3V†&³óܨÏÙ¨«hô{QHßL Ð}aì^bŽ/ÞvÑÔu%²^&qÔd“9™®lpÝCXÉ­°ç„Ñ\EL€ŸV„ï ~æÆÏ”µÖ" ÀPn0›ñdR·WLà´ ¹¬¤ÎAX k0|€F¤åêõRj`^¦«”–Ö€A Ÿ›U.lŽT/,Nž ¶Í6Vø5ueM3üà¶{X š8ÌsSËíR…CkÅ4T¥@¾Ó$ á˜`‹Â?Ч †óv>&– ‹üï%—±0? ½…¯«{ð÷bžl—EöäŽHÜÒvD¸‹†ø€ï•cgkaÿþ‡ŽçÉ<¨p ø‰ë•Ië&Ïða‘¯/ic>ø«nö¾ÀÁ©(æ§ÇÑWßwwYó¾Gô#spê Y¹¯î¥oåÛR8ç;¦ß`OvU¸ñ_Úˆ\Úïõ-ß©Ü\ÄâPdDt(ã{œpž™;Q±t».õdϺ…Ò8“õ;k‚ Ø*>˰J+«UŸs£b„ ‡1ã$føpòbAÑö8ráL«%(iq¼P8±×›ra Çe¬å kcÄÞ‡ÑÑý¬ø3›³ÅáËTäKJÞ(ÓÖa®Çž«Ãñâ‘äs jÎ{åi(ËÑà2½ãÛ”)þOxòb†>¥º6™#vw¤æ]çqñù3?Ô¹/âw®›_ &éx„¯s h>/XObject<<>>>>/Annots 2068 0 R>>endobj 4966 0 obj<>stream xXMsã6½ûWt%9ȉ֗5ò¤rH,;•’Ý«rñ"! ’`Ò²þý¾n”H{v§fjFôÇ{ýº¡®f4ÅŸ-Vü7-®¦Éßð?3þç?¿\-æëdM·ÓEò‘ Z,§Émû”ÓŸW—Ï-§óÞÛåêc2§ÅÝ4Ybïr½LîÚ'Þ{;]âûøöv¶Jàˆ¬å·ËÕ‚ŸgSXÇÞ»»î‰ßþütáªøëötó¸¤Ù”žvÌêŸ2‰ÒÑÓAÓ†R[ªÌ¨¶ÔxM;ëhkÊÌ”{ª±àèTUiG»¦LkcKO;g yusÿý÷”›­SîÄûy½?[›{2¥<š²Ö®Ð™á%›ë§¿¯¦4™ÍáǨ°Y“ë„Ø ~q󈋯£ï¢µð}ŒaD/ʵÍ5¼.keà Û,U¡Éîäó¦ó4ºÀP06–%CcÁå/š2ž_M:¿®r•ꌶz`=-·©Ix?¶Ï—öƒJTx\Œ§Ê©}¡Ÿ|¥S³3: ^VN¿ÛxÄœ7šØíŽÎÔµ.åÈ›Ç;š1aïøNÀK11Ÿ%+ ûðšêJ0ëÇ&®$ë5{óGSÇÌmíë˜QÝí#åÀˆ¦Ì`ä;ÏO „©Tm…€¹q¤ÿi üÄ¢û†ŽÖå1µRU–¶&oŠ 'lu›@ƒÊÙJíU„â8…ÅyÎäÛP¡ëƒÍ„ pÃø1ìQ# cœJZù•ÏÛü¥Ë§…gÅ'ú­ñ5«9Û@© *:(ìíy©ž«Û¨”ôb®!2¡ß!ÄýPô:7hJláH4qÒByט?0¬â´…‰NˆsçI‹+~wÓ»&Í< Q?PÚ8‡¢ÏO’ÌSèZ@ hÙ£Ç)c ÓŸs]`tkëþÝ™°Ï¡+»9ýE»¯¬ —‘saO/¨tö'TLº‘0)úÔŒGèˆ]fâYˆ Ãón Ø5ÜR[=ÝO|}ÏZûãIä²mÄõ3¦¤ÍÉë‘B™0<:=¨ZÉùñô¾;‚’à ˆ äCÈ (8‘£Å£qsžYN1Aç8©õ©â&&_¶û„>Ð_Œ¬N³(úo“Æ8îè J_`ä˜ä·òçë1eÍv‹¬H87gêTÂ&p°ù>#L@¿¯°÷ð©<0®µ)‰`"/™Œ>=`(ÕG°§£""à & í?‰“ÁbwqH;†®t¹áqxƒÙ{þ·Vy)ê:öÇÁ~îê/º ãg‹x!$†Ö`H5ås~ å—m÷m©*Í0jjì{.ßÄeÊ7o—ئ~³F&³„dÀè“xÓørk?ƒM%uõázçš:°|A®·ú€Û¤ÄäSÌþ›’òä’~4ÎCâ9dL¯)ÖâÚÙbãyu…)CAòªÆ£íwKØ|S‘ÃE2Ôa‰ráôIÙ³¶8@ô™EqJˆ6&²ƒö+1ôº¾ð¶²Äî圃ûB¸¹ùƒŒÎíµñú° 8s.)x̳%4ÀìÀÈvÌuÃÙ‡sÖ;úi ø‚g­ËrÅ ×ãð5¤€Çôf€C¨D‚計«(ÿLÀ#*ÿ,À"ÖÓ§Jl•£Á¤)‘õ=aÅp¸›=PÀ8ßW'{¦Cª„Ô¦7ÜÑx\u@¼;9Ъõè+‚}ì|¯ÜÎzÄ*\~p]}Dpóà[tÚŽ^L߯93òŸ[ù`ý.·jX«BêÁºs”?~3û&¼Œ­q4&Ú°ÈJ÷sÎàˆ¯,„Í—M 'CXŠ{b)vaËÝðK±Ð‡ï˜Eœ©7Üø'©E?<_?Â>kGÞu;êÌñûÚíâ–V«e²’9“{üdžLi3¼ßMââÉGþUJ¦[ú—ü\#³ñít•,æŒñn1]³å‡§«_ýÄBLendstream endobj 4967 0 obj<>/XObject<<>>>>/Annots 2075 0 R>>endobj 4968 0 obj<>stream xXïoÛÈýî¿bŠ¥'ÑmËvŠ~ÈYI ¹\c£÷¡.+r%mMryÜ¥÷Ç÷Íì’i»=$HL/ww~¼y󆿞Ìé æt¾à¿Yyr–œá7üÏœÿùúñäâê&9§ËË‹dA%]ÜÌ“ËøTÐÝÉÍMrA—©,Îçóä*>ñbzÛÒë4¹ÁÖóù…'^=~Æêâ­=cõú ÷Vç‹9?_ÉÉéüšï‘'¹÷蹤ô<…UG«GÏX]œöþp D³¡Ó74Oé~`-®¯é>—Ñ}6IçÉ5üúRëFyÛ}ÒMaUnªÍ›ûŸœ~¸ 9^ä­³ôVßç“û­¦%•6o M™-µ£ñ[Z)g2²/E®­kÛxZ㊕ŻË9©*§ešŽk4©FOikwLIÑZï¨0¥ñÊ[9¬‚)ìN>Y7¶„U¦kߪ‚r³^ã,<;Zi¿Óº¢Ûï¿7½eċ·µiœ§G½?ÚHÆ‘ß*/û¢ÕŽÖÖ´n«,Úâz/=LTa«Mj6m©+?Ëu­«?Qaíc[?¼™Ònk°e´#¸Ðè_[ÓÀÞ.l¸ÞÂx*u¹ÒÍÑ¥v ÃïB96V#dqC¶JèîçO)S ¬·Þ–_¦ U€GÈ@׿Íùʶ%â±BÔ .À7lJ«ÖÌägøÊqŒ·ï?ýB’*š|÷]øEWVçè¥ß~½.P…³ãóþðìM.«ºA6¾Áš¬Ñ ÇÓ\ÇŸÁ`[yóˆ3Á“å|¸ÐÉ„€ÔºËN0‚hª­ó|#ƒðàð¿zxúÊáݹiG219â¶ÍÙŽ¹FÒ†{|aÌ£h|£*Wä3d‚óÂoƒ¦ñ¯ ƒ€ƒ#üze æM+#ä×óŒ®l»ÙbxAŠˆáhª'[<á&—Ç(+Û9K:ô5Ø—_^ d[T‚ܬ˜ªz‹pè^{fFã$Xá)ð[æÝa‚c˜Ý¨=hv岯Ô(”ÈÂÓ1`þù/>ñÀë“)ç ,¾2Uˆ„p9HÆl*£Yd®°±‡rw=;’OdÞuìÑ~àA£}Ëå‰0êÈÕ¡Îñ" »Æxÿ½¢ËpèBŠ P+¡°g–|×~{'6Ü¡ù­Íi6%T%d2ãJžYóa"URFÚT¾AƒË 8³Léɨq(Ua>“tÒ‡7 -Q)L* µBeL]0ÄÎ2¥Žò'²EØb PwÛTH'§~M”3à!)ã6?KÜ夻_Ð×¶ªâÑäµó3Ç|7 ÔQû¹ªö¨·PÕ¦U›À™¡ËΑ†ܯZS„¿Doèî¥êO³|vØ:4aBýS#Û±×y[Ï ‚‚ßë«ñ³z»Áiú[¯U[x@e.’tŽ¢@…AHŸ­y™N¥eqBlÍ­adÝò—¼ÿz÷éËcÞ ?˜ð§¤“M2ÞV¢‰`„ìqà)õGÿEøï-CÞûÑzý–>=oµ—·hëô7SµßÊ*¶Å|‡†SÆ2ê·j¡0ÕãØÞ¬r‰é‘ÂVù¾ReÔ Q €Ý´˜\Äjö¡±—f³õ€ððnIåùøÆYñüÂúØÂIå"ÿ¤T#Ïã\pYŽv¼ÝvíD;ЙbÙ±Ì-z bÈ/õØÊÚúe)Z!È/ØU7jSª‡ 0M’äáÍèrè(ÒXU)Â9hèë ¡Q™7 ·û}­KUwjA8è”P“¢ØYtÇ~XYZÎ\­3³†Üö£Bçøk'¤…ÌÙ µ‚´—ˆ½Ðð‘uQò Wã2ÏX—ÀôU¯BÆÌ$:)Dᓃhš\+À]3öçÜVà‰½hb&¬t~ÁªÌ"®¶Prx÷öàà¯ö ö³m7uc78]ˆµÈ…ëZ+´&ý»R Ð0[È&ªn_¬?Ö¢;yšy"½F€†Ü3­ÛBŒEí„–Ãq©´â €Í’éåôÃ"êHŒ»ǘâïX¿dRæˆR|í .o;@™pdä‹~ ;±È¸ÍqéR¤ëÛBBÁÍÐ&Ù*·/Wfç9ÇE—9%³¾ŠxämÍ nÚÊÀ içÝKÈ mÀp\(Ù€¥ºŽÑi5ŒN±í°œ„q¨„íº›)™ìÕvÞÚb–m2©Z𠸃‚&ù–O?}aË„Å6d“;E…ß„ŽÝÍH&¾è.ƒN´‡",èlåqy«•h½ "}¸Д°ý?º± óë˜ÄÙU"ß.Ňtqé¬K1/Î.xZŸÜFy'sÓKYþÌ­:WÉ7m&8f ‹j¾=e-òi. ̺U<3>±C’‚’G¬ØÌé 3²Jyà!׿×p,Ðà8_e‹»gzÖv|“„·!nbàó8…U†é]\ð´ øK€ÅS œ!ΰ­S@]ßa‘(x•Q¸TYc%þN—fÖë¯á@Œ Š@ÒýbšB±¥©+±Yz &‰ºã)¥´s9BiËÃnb¸@MÈ<¡ð_Ä|£!ë¹4LÖªÐ"É€- »ã¨¡Î”{•>ëÒ¢2k5îϸà]% ³#†#{iÙ,1ËsEHiôF52W±UoE0ð97kàžٌs­ OJÜÿàP1ÃE(¾*ÎÌü¿bl¼x1aì<ÊÄ `Bž ×£Âf‹ uò–¾4fÁW†Àˆñ3b2„å¬71Ú„ñýcÁ XÎ!3ÓÓŸ¶vPuŸ´ú=uóÚˆí=#Þãœðy¬o±ƒr˜ ’;]WþFÖO¯^ä?áZ+D޹ÆEÔÇŸÀ‘üÀ6ô¾tÒÌW\YÚg¿/®Mͯ.“Åù%-.ñ)UÆ ®­YšœÑÒfò¹KG©Íôì"¹Ä˳+þà'׿/^žá«jŠ‹xõüì†xò÷“ÿ`šÅ;endstream endobj 4969 0 obj<>/XObject<<>>>>/Annots 2094 0 R>>endobj 4970 0 obj<>stream x½XMsÛF½ëWô%µt…€É$•ªX‰µ¹¬vcVíE‚ˆñÁ 1Ú_¿¯{ÀвËÞlÙeK¥fczº_¿y=à7­ð/ uÂÿ³úfå¯ð ÿ ø×o÷7ëÄ_Q'þšjÚÄ~dŠÞZ_ߊ}b°o3›5í¶~ìø³¦ Øú[ÇéÚð®×WK7!§³eË ˆx©X¼§kcéfíï\¯c×®¶~àxMàp%·‘R"ÇuLÎ7âŒ&§ks¾ Ã0y |Ø‹á‹ÖV ë˜5%—2ù°‡þÆñ9& ¯|މdÂØOœ…® o3>Ó–‚@¼3–’1!0úT·¢ÙéÚ1³×„EbñR×f|"Ægö:6¼»M™½&¥ÐEOŒ9%ë Â-‡œfaà¢'ƼÐúl÷&§k#Ÿ8ÛãÉk® ¶ÁJK ul,5 Í^ÇæÀ̾xö:6¼PšÄõ:6În°a¸§µ’T´5}ÛípŒÁ99&ÂâÈí§Y¸±m“ì#±æjŒÍKùØ;^Çæj8#ÇëØ\ ÷föFèU@ UØ ‹±xß×{G†E‹uA·ovƒç÷G(v²…"„´ÏE«W´ÏaHoÿýë=¥MN÷í«ýïNÑr Q€§¬öÄ!ŠY<<)ýTªËõªyë`k—yäùâ1L6týüË]øi/à<¿ MS6…ÉñRö'›$'bžø)Ï˾l›´¢»¶®QGU6ŠÎüaw½Õ‡R ðázL.^}29ó¼Ýü¾¥‡¡?=½)+õwó0«V £ÿ @€~¢¾4µG:¤]™ÑÝíÝ·ßÒE§ç3pãòg¨í?Óì]Z(úGZ«/ ïòA‘Vɯ—üx¿whtŸ6ýWØê—f¨•N¿·îª´ë ‚W]”Ïé׿¤t‰Â³ÏhåÆ"ËòudXî­q½‚<ÈA{ ?Ÿû†©`Ó^Õç*í¿F.µÊúV“ƒÉÌùK”jÖœÿë`ÿ¬ŽéPõP:벆Â<)êŸÏŠjs²¾4׬¬¤ºá¾<µYE!³é,¦EKY›³>„³•´`m¹eEÿöÍ8H<Œ²$Ü ’ý©ì(;¥ç^iÊU—éò :ý¿uÔ çs«{Ö¸ûÖ§7 AÝjEeslu-g‘Ú†ú“2íj Ö5—S¥M1°ÜuJ}DØEËOù­±|I©…Ï:)s”/`2G9{Që0ĨrÇà\á “¯[i°¦´>cNäSbKjÚ®ËIÙ§¿·…»¤²§¼üèˆE.Dz´Â´+šãÐd"Kÿ²ïU|Ì4Ž9è{À”¡¹g-8ÏÏtP4tH«o©P ë›2#DéŽ?ämèNø@GÝÖÀyIL=`ÎàÜàmžTS‚¬tAÌiÆé: ¹s˪B|n~‘žÇŒº MDNñó¸H{ªTÚõ¯¨¿´”—Ç#œØ¸ZHuçÓÆ>B1Šlr0Ä`IU=§öÊš<ãçP”KÚâÄŠ Ÿ°5µðj#nSdoÜuI—S™LwLÜF“ÄœWöÊÄ.ñ”>¦¥µóšâ ·R½B²s•`9'{• ãp]½ jéÑÑ,Aû ¢‰Šφ}|="¹µr?ºÆüµÊRð€#—TôÎëÒ#󒸼§𾬭6f'•½Á6£§*:ÕH½d ÓìUŽ)”Ž8w§v¨±B š;ÚÎr Ai­RÑ)†W«N4ÿ–âó6­EÊ>~jCúØÍòÃ'xïœ Á=WK®DXdß}Èyárž-È MR5çêÓktØÎIþ‚³0>áƒí»Kf°ÜÍdè<^Rd`è’žÛ,–iÕµO–7Œâ<æ;cç÷/”;'TuïÓ7¢™û“nÌî˜õ>);â2,¿î öùP™³ó )jHêA ê S{èÀ¹ïÆ.ðë² yK¼)­aå‹îR„ÆwRÕÙ<o'x¡Ùâ/6á*¶zÝUVËŒÝø»é…ÄtR(;WçáÍ}‹qâmn#y8äEëñÁëÊÿÈáõ& þ¦ê¿ï¾)úï%:^h7ãõÿ­Q%^#00F œ\=Æ -ϰ…ùdê›9NÀ´éu+Ò 8R‚†r(óz ôR¢Ä^ô@iºJlJw¼„Œ|ôìèQÙ-¿YÁÍÒ ÓêS*§|Ь ¼}¯Ó¦“×µqŽð†¬ƒ¨1ðƒ%¥í ¯’0â>Y?_’È;`bþ¹M¨{îzUËÍ¢) óÕ_˜2ý©5Ä1ÅíFfJÂBÁ#‰äÏÇW>.Ù’øqèýž#3[·™¡ òøIZ¡ˆÖ|´q‘‡8!–mÄç×dϸ Å >·2Cä|zøŠƒùƒ»ÔD>‘‡[òê}?NöI\ä1ÓøQ‹x3Gê¦G“âv[Üb:rÔmy¶/–?ðHýñý½GZ³“/+–Õã"liÖ]'3ºe•…A5Š ÓÛjÔüMÃÆƒ˜¼uìãÛ0>Ì/¿áˆWøæ&4oCë`ÅÉþ²¿ù×Í=,õ/endstream endobj 4971 0 obj<>/XObject<<>>>>/Annots 2096 0 R>>endobj 4972 0 obj<>stream x­XoÛÈýߟbpEP‘hý–œ $¾³/@¯i·‡krIoMqu»¤ݧï›Ù%%Rvq +޼Üy3óf†¿\Li‚Ÿ)ÍWüI·“d‚þ5å_»»˜ÏÉ„VÓdN[š_w”ôåâäÏ--æÓd6ò³÷'ÂD¢+èêvAÓ Ý翜ohµ™%‹ÕŒî3¹OÒ˱·•Úê?ÜÿûbBã)?¼|SÖïyñMQ¿çëer½^ÓtÿèšêGM®©j³ÕÄÉæ²æ•Ó•æÁ)wÀ’ {³v™ª'íÈ?Ú¦ÌÈTiÙdš°) Kè’3«¦¬ÉxÚÓl§Ò'UÄK÷¦~¤oo¿!µÛé*Ó À1|lU¨ñÐfÿ¨+*t¥ªMUPjqgn­Š«Mqµ,Þ‡-ç§EšvÄ—Ž;<Ø\ýKcžU©«:X¼7eIšjõñ¹³[A€^ÝŸû)ºGg\’ÝÕÆV´Sž¬­ à$ruD|<]&“õŠav¼s:7_{€|ÖþÈ‹­›Ä‡?½fu0|tc8Ï:¬_jÓ~g« Ê íÊ{ê¼`[mÅC¹öUãJ[ãú°Óco~í»ü[n\ƒ¼Y\ɺ¹ºyû–X ´eéa©Í‡ËÎÒªv¶ôá~ÃI®ÔVÏÚÕGßÝ¥.6U=Ÿ n&ëúêã ÛW‹Áö”+š-Ç_Lß|i´Z®W·×Äù›Óx½N–Ó%Òy)yð™ÍüôüÜÔ»¦¦[Sjß¿ ¾š-’GÛ0zpŽÓfD_~útGû1£À>·ei÷œ?9Ë}Ç‚AqÇÒ~üüÝßÿô}RØpèÕÊTr‚ó¦J98ÛAÛ8ÖSÒTnJUY u›ÛÜ;N~çqðö-_ßEÞñˆÅTpÚÃ!ܲµYS¶AÏŠGhGÌg)ôð°0§v»ÃSP 3Û+úÉ¢‹ØƒCÎ×ÉTü]þk¶ZLjjöPù™õORöc€).|ýÚ+D÷Ñ–Ö|S=Û§`ST,"†0ïÃq´óeÛߨ’nX#N¨h¼#U1³ƒÀ™¹A hÒýÿˆÇ`5@oã ·åì.æ'Á>3N§µekU7üTÓÎÙg“iµÄÍF6Ö¥£,XÔC£FiÉdìE2<œ(QC* Æ×©ö^Jšð$ôÀŽÄ’ Áì-Ê ßéÔ¼TA™š¶êÀ ?êr—7%“i[ôðÐT=U$ðC–Ü+Nyót¯Ò)ù)žœ¯4EÚyyÔFa‘"(CúÅt½‘ˆSšôñ„ƒÎuå!7(3¾véŒm=Rò¨~®n‡ ÞÑ*Ñÿ€ËTºV1f$‘»|ì”8RM,ç–[†×Ò@ìc÷âM†“này<Û$×4^H³ôË‚1$[Î FBW©¦½ô@¥µOȪ'mx“Û‡ ú?ùŒ)y–Ìçø mù½)é¯j»u™6‚ÐnðTYã“ãÒnSú6EÖyigÌòöÊîòpÄÒ¸[A+6°*:-гg†?s° Nâ8*\·+Q¬UûO®'qçå…Ë ý.}È*vô‘ P¸˜ —á°•Š*5U|±I& t@Í^!x—‹HæAy8Zø©Å’Q(®‰Š‡¶ÇUÕµÞîj鶃ÞX¡Ë·!pPj@·Úå Aš7±Y ý`÷ÝÈHR¹TUÑ C:ðHiÏE53y®šél»Òèmà-B“#LC~TÏr“MÓÆ…ÔAØJ¦gtVL-®”þœÀŒÌ´§˜ÿ`…°.²E"&PÛž0BB "ê!,üKìëÿG‘!nÒF|@ǽ˜ éJóÌD[¯8H£p2”@ø$°Y;\ľötz í@èå94~ï‡íà›°å̳al µ%ôOÔ+æ~FÉ¡,…‚ ´ò²ôqT´/þ²£_LZ2:üWD¥Íc$_ïï>U@rÔÚ†¢™ž7è„lSû 8 n0 ñlDA沑çk*5‚W’€×O`ÞpOÆe0Æ–0@ÕîÚHœÛì“‘E‚:¡:U\ëcbZ±äÕ!Z¹Ì8¬Àiº¼;Wz`ôKqÖïôä.ÃÔ=}°—)C•N«ì QH$ŽñÖX‰öE?¢-æ›á˳rFI|EÃëkUÕøª«f‹ÿ¸´G¼3TíØÝYÉâÐÐÅîsÃ͊𵻜óàÎ&híÙ/¯y¨•Ýc;Pztè!²¦ÄÐŽ ‹éölŒÂ¼ÆrO7µý+æÏvt¿ÅÁXeFì¶ ‡Ì^˜ྠ¯´aÕàáÃêd` Ý?KíÙx„o –ýãLª?ØëÎ7¢oÉ‘_Ú¦LÃåü~ÍÏ@„DHXk'…Ki€C$ 92xa$ïx: Þ˜í¶©9æ’tÜ2ƒ™øÁQFûžè’q•w%üZdPkBT^¬°kbøµŽŒÃUd¦všMAñ¢jy¬'×\:Ùžñ o¹¾³© ´RvX3ÔØ°{¼æY*N­SúeÒΣÄÜ„6J¨ð³P¡Ür²J0 Ë¡ùtʾ¿¿øëÅ ¦ïàendstream endobj 4973 0 obj<>/XObject<<>>>>>>endobj 4974 0 obj<>stream xWmoÛ6þž_qÀ0Ì]ű÷íÓ–6Y?´ØÐ`À-Ñ6Yô(Ê®0ô¿ï¹£DK~I‡‰-‘Ç»çž{îøÏÙ%ðsI“)ÿ¦«³_ïÏFÉã· ‹Û+ºÑýk§¯ð!“÷ønž?§4We©KÚš<§™¦Ì”i…'Í+ç—Úáan· ý¦¦­þ Ë ë5ù¥òø£in\é)×Þc±Ë3±J…ZaKcxn] «ÞRµ^k—ª6ì³û/g#:¿ñÁÂlØ®aJ‘¯×šLAw6¡_(µEé]•zë¢]>$#¶sq 8$ÔÁG½ OÚà4·9âÀÒY|çCR|‘™>n¹o8ºúV#`ý¿ÎHªWÄArÎÇSŽvf:µH#Ül×–C … ;8°5~‰4확•&eòÆOBrÅg½+ª•v²ø{¨èÝR¡KÃåTU`ا¿Þß1ç(È6ÈäõLf‰û]Æñç®Á‡,éq<2™#ŒŒØ±Z•T••Êž%t{•W¨°¦4ºÖ›Ú€7Ê5˱PèþpgšÊ¥­òŒÔÆšŒV63óÚ ¤Ò"¸¸åI<¯…b¡Ìû9é /á7ƒãæ*ÕÈñJ㔬” 1”À€£)JfVy2ž2 _!Øš´:çÃ’K¿Ô¼„Y—¡0%U 1×[êÌ &–Vj5))szí4ö{Ù­ÇÇ ^P…&c)“[°\ñiaÃ>-o„ð¬Ã`h"Ùhˆâ·¶!“óš™S™vyÀ²4¤íÒ¤Ë D_*hàÒrªhmF¦CwzDaâÝiØ(€Ëi/1 -Gƒ2ºS!%‡!)(z!èïãµB|*뫯 ý^Ír“"–ÕL»(U»8¡êñ€»uA‹Ð÷9Ê2|lYÆ5ÎáwPêÌmÀ§±GWôâVP"À]‚pÀ¬u™)”«Yââ¹]²pàÂ))7MÝ·l‹XGrœªkR¦”èYì)¤|ׇ;í£ŸÿTîH¶úxÝ üOV×0tm´‘RƒztF7Ö¡F±Áp”ªNFôÖ¦2ÄÈ݃ú°úüEˆV.nci¹ž\¦ÉdŒ»üŸ\ŽyÛ»û³?ÎþŒß¢endstream endobj 4975 0 obj<>/XObject<<>>>>>>endobj 4976 0 obj<>stream xXÛrÛF }÷W७ÒH´DZ·Om\»~hf:Ñ´Ó¿¬É•Ćâ*¼XQ=ù÷`—¤D¯œNÛŒí.€àà"º˜ÐÿO(šñŸx{1Æ8ikþ@“ëE° ELñqA…¦¿¤ Žær4™6ç‹G¾‹NàT‘ a8‡ÖÖÄYUÑx\{‰ô”3/ç³E0óúá¹è|~HDz¦-(*ç‡çæH¤§ìœy9ŸFgüð\t>?SÏ´åQåüð܉ô”3/çÑÂQ­Ï+ÏE'àóC0õL[PUÎÏÍ‘HOÙ9órFÁ•—Wž‹NÀç‡`ê™¶ <ªœž›#‘ž²sæåõyýð\t>?SÏ´åQåüð܉ô”3Ïç×‘ß ÏyûÜç„êÙDEÖÏE'ÐÓtÆ4ÏAè˃ç¼}îq@Ðô¬ ‹ßsÑ ô4±Ìdz(ÀÈÁ¨èÕµç¼}îÁ/hzVŽGÅï¹èzšÎXæã«~xð{ÎÛçü‚¦gUàxôXüž‹N §éŒe>Ž"?~Ïyû܃_Ðô¬ ‹ßsÑ ô4ý¼¼¸¼½¢É˜–+l'³kü#AÔÇXM–ñཀྵ4UUáW¦8ЪÎã*59%F—”› [JU9)ZÚ™4¯tñ#¥A VYvpJûBî¡Lt¿ÍV^'0Å*§GMyeC:˜úÍòï‹1&!à ø2Þèø#­Lù´¤ÇD²,Í×¢ïÃ>]Ç»ªx<¼¡­®6& XÅå-Vçë(¼bea`×B©Üz—©²¤û|£‹´Ry¬­L'óîí[ŠåmÚ½%ÀPue¶ªJ ;½+t©„Òœ $5Âi™’êR“Yá±âX”-ãö³ø¦àgš%ÎØ>Í2ŽŠ:‰FYïtQꊵq–: ¬–vª«ƒÔœ†'•‹96Rv¬ƒÑnÕÍíxܪKý~“ÆÒŸw:®Ê<ŒáÔä aóRè'ÆJâI¡?Õ)ö[dz²4aÄ:Û+˜`C²fÇ%递rµµAîÒ j0…Gá¬M댽Xêí.S•”ÇdG2±1€÷9™"Ñ ’‘´pz«FÊÆBHHÛºD,|øóþŽŸÇ…†jÚjÇYpIƒûà@)¨tz ¦¥*Ãäȸ`„ºC6ù"€–xØú…¬ƒo5ö¼!䀵ø¤_Üãp#OQ0ÂòWÂÁ¾}W:Õx¿‚‹5ò·Ì'ÅÚ$QL‰U^ ñÊúÑX¥¨«‘}Zmè)-¸¸b²£^ð'6HrÉE‚*{N‚Á=‡è@¬På Oô*Í™¥m¡íj¥™çÙ]…é;¤²*j°Sš‰{ÛØm&?l êa•jT™Þ>ê$WúÕ왪Ã,ûægû‰`G™6w!&±ˆã³µ;¤” È7D/?—EeÈ>E*-Ìéã*ê+<Ãm×¶?”q‘®ÓÑå¬H)4îôÐòThËý¡k»rfº%Ñ=Š§Ð‰‹É[ Î2ïˆÒ3ŽêÄ%IYªàm¼`±Iò/S»z’¨&IÖ+ëÌäúÄõ.Ò¦8 Z¡1Cžµ3J2Ó´Gõ±Ïy-Ò—\)µFœë½x0òq/ìõ_7ïX570®jŒÊfD2ðËÛ¶ßë}S‡R†ïÕ¶7dÜôÀdêIž{Ε¿‘þî%?ä¥û ¿êbb8 V¾ß#÷b„oh㹬-Æd}ÙæÌó<Þ¨âÅóC%-Åó¼L×9æ‹O saÁš>/XObject<<>>>>/Annots 2099 0 R>>endobj 4978 0 obj<>stream x­XkÓFýž_qU ) ‰7±óZú`éR>´Ð„*¡Y{âÖñ¸~lˆÿ½çÞq6‹Ô ´Šg|_çžûHþéi„c fü?\÷FÞ'û?yÌ4ñßEàMñ¸ \ӊߤÙbâ]ÈÑxº;_øÞ¼óâ ÐT$΂ïÏ¡uo⤪`´€Ý{¬·”2/ç³ ¸ÏvÛqt\:âp>µL»8:TÕqt܉´”2/çÓɉ8:.]qˆO-ÓΩUu7G"-e§ÌËypuå£ãâ ЇøÔ2íœêPUÇÑqs$ÒRvʼœ}o&q€ØuÝ8M®8ħ–铪ê8:Œ‰´”Á|]ùcþôÇó^0šyòGsϧ5“ÃSB¯{Çϸ]̼qý®Ü=¯i2ž¡^&¾=~Æ-Àñožqë"/Xöé²w~5¡ñˆ–+{Ó`F°ð&3Ÿ–°ÁùeØOlÿ9[þÕã¨'HÞè›´œMøpXŸQó£ùŒïª´0qª#ì”®¾&¾J¬*Ûöä0ðOXŒlu“èN™“^†·*§‡,3¢á˜ÃîËÑ»÷Gz$ž¢ÌC`ˆNí/¦xÿB ƒÌo¶ÔTÞª’^¿}ñœ6¹Ê kBÚ¢Ðk¤ßyC˜†Uœlë¶¶VûjãŽ5Œuª1‚ÐYŸ¼záWصKgk[Ã÷´>8 Ö¾F ÐÕ”¥N¹rb7ökž¨`A@„yk@Mf »¶‹^–‹H—Ê$®£Kg®çúO±Ô¶ &ÛÈC—ø&&noÀ¼ÀÌÿÅnô*{ÇVae_ë¡ì´žÒ‡¥ÿOìmØÜQØyàús‹ÂwÖD„yüʾRwCÐ1bºk*2 QO8tÛ£üÅ<{#Y »®@ï†âË甓ft ¦?S§ÎKIÀwK©ÂÐ+„ÒE¦CƒeË»”ÔylÏQ·2p´Ý·á`ƒ!²Òq ì5 ¼*Ë„¸'­Òåm¿R¢²Îë~l?¸…ð‹úé¾µ€ïï¬ççtéö.\žæ¼`µCW6zë–Ó<*<Â^ŠZÝÏm^vqKã‚ZÙ8n0̆\ÆrlkFâ·Èà+ 6ñi0•_/¦ã)ב¡_>žÙPÖ!YrØãÞÎ]«Î,è™^)ì'Üõš‹å~)dé)¾À¾ûÚŒåKÏÏËÞï½2GÆendstream endobj 4979 0 obj<>/XObject<<>>>>>>endobj 4980 0 obj<>stream x•V]oÛ6}÷¯¸/Á”À–e;v³ yÈ>\ô!h‡ºëC]ŒDÙJ$R#©8FÐÿÞCR´,wè6$1dê~ñž{ÎÍ߃ %ø™ÐlaÓjðëjÄ jCãeBWñŒV9MZü<‰‹W´ÊœUB«4‰(oDJ«kž}©d–¯£¼”Ì,.‡ôésû¸>§öé|õ0Hh4A€,:S\°Š¯£Ý±ÿ9ù0™lîKNÏCjŸ.Šz}þK5ÙÈ[îo?¬Þ}XÑËá ¨ékðð9ÛXÿ#E!4Wfmä_§ÂuÎ^zu «-§¢ª•|âm$Âp•³”“‘d¶…v­2…CÚm‹tK[¦Éì$)n%艕 ×Ã^‡·ðæè‰â$,YéÂg…¬®{ÆŠ;Ásè7J Š¥ï˜2áph‹;>€U¸ï:w}Ó!ø‚ÙøÚËèCØ›“dªóó/?%ŸOÞú&ôC¾j÷u¼¼$[bN#¦³v*£¥T”–Lk´t!Ðw½+6´á‚+f¸&&:L†´— ¥8bYfÿ :[q³•™¦{ Ï Qˆ %P7a_Ó²É/CÝS;”6ï(äÍ:·˜l‘ü™UuÉÎ}ަÓx6㎘˜u·ÿÍ^@µOý©>0)Ø¿ææö/;PÇõuw ºxîèÔÒÓɽáOŸ Žêëq=Ik£òݤü ôwEº#ýËwD—V ,IŽBÿÓ[As4’|ì]¹‘³³úmN©l”æP”ÜqvËžœ¢*¾S…±ºˆ9‘¹×HO^+oÚp–Ùó‡ïå|7´6©ŠÍ§˜$^–žèܾP$w‚´QMj`ÍL¨Üñú˜ðN\Fn!÷òþ§Àí(¯ÕLhз¼$Iƒ÷ ;½´Ô_ÙU!¶ÚNªGÝÞ[ù¡çJc·‰Gb„ÅΑv/QØ;ØlMÉulV‚A«jÅ5Ç„¤Û;7·Õ‚·6È ú䯮¯©T ÷£º´ë éDá62¦7žPŠ´ýó:[Y êÆø£ÆTf.#Íkfå<.=uÇË«Vá§Ée<ŸÍi>¿²yÿñÍëÑ4Nèw™6¶Vf5ÛÖ‹Uà-G¯¼ŽY!ñxëA8Ò÷6¹õš'‹x6ÅBˆ=›ÌíÑ«ÁŸƒoÛÒuendstream endobj 4981 0 obj<>/XObject<<>>>>/Annots 2122 0 R>>endobj 4982 0 obj<>stream xÅXÛnÛF}÷W òR°hR")é1ucÇ@»±Ò¾VäÊÚ†ä²$e[ß3³”¸J“8iãqgçvæ²³þó(¢ÿ"š¤ü“•Gaâ7üñÇÛ‹£I„”&i0¡’¦Ó ꉂnŽ<²¤(Œ‚™Çôip'ó`îqÚ8vj£ ¥TQ;%ÍÆAìñ<JÇq0ö˜Néd,JD@©¬Ô#KJ§ìÌžç‘%ÍÇÁÔãy$ Ft‚Îà8ƒéŒãB¢³ýp&¼(ä3Žb¦O38  g÷¢ÉÜa…¬ÈQNt Yt Åw*Ì™Ãu>C(‰,鑌ÝÀLŸ7™²Ñ½¨Oƒ P`tÏuFñÉ52I!بGB0N‘°dÏôip§!Òâq=º¤q‰ÇõipQ_3ë\J]f¢HPJ ôhvJ Üs%©Iì‡z‹ÈÍ@B0J_9ÉL'ˆÏ¾UÀbà¡^™‡Ì\!˜ç‘P¦ÈžéÓìkÄ \7áfñ¸ î,<à:ˆ…¸4çÄÁ.9ž-»”p^„b¦O³QÌ +(Ä3ß4Ea;BÔ$#Fj`:AH|)⌅èw$'³¦L¶d, z$"aÓ§Ás\§²?Òܱ¬Ö#‘ÎØ N§txþïVùô(b×_kU™ê–슞½¶ù¦ÐÏ¥¿«µ«¡½tÐÐóëË'4õÊTÔ­$€AvÑÞ˜².4y< oøä °FàLvÀ&á£Àºó½±kÕ¶æî¿²öFulLªŽ\&ÿ£89©Ï7½²*çZú|xi—KÓÅ?ÿ»G“IbÑùÆN’!pü®ÊÑ®™m4Û‚xÂê^lk]ªú)'Ã[]7ºÕU‡Â²ˆÚšªCŒ¤ZjK»ë^sí~5´“|ûž=u¡š%ºšÎlQèŒ{äO5qŸéqüm3Ábf¾xÈt- ¼Ä /ž6Ó×Ít¾AUå6Û”»|<ö?¾ö[º7ÝšZÝqÖŸÐâÅÕÕõ ÁîÖΠŒMýQi½Q%–˶Ý8Ö–__•Ò¯¯«ÓóÝ}?Âr2§Q<ã:Z¬ É•1åºS¦hé–׆Q[ë̬LF­[ ÈT²YœYCb,5²†°J)c<^"úÒ 1¸b눃™x! ˽m>ôévÓû®_=ðæ²Ðà½<; ´² õ§p(Å¡5æÂRëŠòÆÖµÎZ¬5!ŸÝþ ¦ˆØëÖª£¶3E!eµ»Ÿ?çFop‰4{2($Æòí4õZUÓqµHñ œpµC—Z»i2ÝR¦*8L™-k€žKHØ{¢Ö B,U•i¶ñ“mš-Xl©²uºåe „ÑÞ›[¡-ìP Õ<²Jµ¥;Õl¡Ì²ÕV­ð¡;ÒÕilÅ­ÍŒZbE¹xwùêÅûçïWïÏ®^_ƒ Îb¹_ßMËñ‰•[]éFÁ‹\Ô™Íõ#3¦Ï,€Ÿ®äƒHá·n4F’Y­ð8žYàTw­,’¥[$Q´w¶–'¨î•©U«kÅî@®Îæ‰ÛN¤Æ^™egm!©;krZÛ¦1@ä >X[[н&ýP&3œ\Y+ó ©Æ™N?t'¤ƒÛà„ž¹Æê]{– }jSý4&®_øï<¼õãæ× ÐØ`)B’åÂ\)Lð>iݽõPSµù¡u•ysöš€)6dìÆ®{ð}¯ƒ+Àe•˜óõœqæwàVÜ·ZåTò¢–vÓ¡`¶<>/XObject<<>>>>>>endobj 4984 0 obj<>stream x¥XmoÛ6þž_q3PÌ"űóÖåS‡¶CbØPÃ%Ñ6‰ÔD*Ž7ì¿ï9’R"ÅMZ, ‚Dâïå¹çîü×ÑÍð}F‹KþÉ«£Ÿ—G³t†‡ý¯fC§ï_ÓÙœ–kœ½¼¾¦eáßÏh™Oç‹ô<=£OªªKI•¾y¼ürtúþœÎp„…’ùyz±ér+©kÑ–ŽÊp–”%‡ÇÖk°î†´q[¥7dk™+QòÂh™Ò“ø/Vz™u«s§Œ¦p!<ñN?ýñá—ÏJ+·š®Ž‡ÆLY¼¯Mãd‘vvG[ø(¬e_‹i.4e’Z+ R𬼓 ¬Ù‰½ý)輈÷!tðeÞU™, üÒªRžÀªLÑ–Ò¦c3þ4-tiGÎd1A —9ÙÔÄoþÛÐÞ´ ÕÙ4¢º!Q–”)] D–*QHÊöĬ·[>g·fGmÍösŒc\4(%äB#”8LûÆèM#¥µl>WBéCïÒ„p˸IÈö„„.fO*áu?AŠ#ÊR« Äatß»øötÃq/;¸Mc¨Ï®cz’+4äg5¿¼ŠººäñËDöÞT#D•ºO”~6qy#…“}æB®†ïÈdÀ^i™„##‹O(7Ú!z,—þô)ßÊJâqá½ëA‰xNþ £¤TiDá3θè H¢ÔJ•5¢Q¯˜GkttF×é‚ËvÎu;O üWLWÓ´šVû¨xuŠŒDý=œ¥jŸXƒ£ElÂeF“ô×Çü¦ÖLÉGÏI_Γ quL7@þ­ô°ïãÁAím¸¹ébèíVLÌš6†¶²&ñÞ.ÒKàü*w ¡ì­FÞ)”›à²jÜ–s±6O°ùØÙQžîOpñÈÕÑñH3_Íg9‘÷Nj6ði`éQäÆ<8rø rÙHbZˆ\ÔðVä[Ú™¶äP¶†ŠÆÔUíQ«Ñ„ÿcðä;¬eîÔ8fK•+W²l?,4è)ï„T ºËø2@á!ë‘°_ò%^¶6†2ѼÞ®sEÔŸø("¹,ÚUß30”Ž p9¸v|ªÏÖC‡{S¢háÔ,÷'Þw®‚hþ ™ì˜1`­=ã¬MYšSLb÷ÖÉŠ¶"¿})FQ¢5H UVüa÷Ýu!ë –_ ß7oÎÏËÛ¦‘ÚE@¥²Ž ŽdÄAµ=•}!]ž59J¢m$šÓ¼>"3[×f°`ݘjœ½QŽ3„f І§}¾ƒ“££ðÐÊJ%¢u¦Å\¸'µö)¬…w»A¦¸Ã禪@2Ì´(âfÓVÙøºÄæÛ?ºÐ¾åÐNñ!#JPh ­ÑkýÄ€AvÞM\![áaïVŠ{Fwt“H¡™;Óìù}5?ñ­Ôc¤)KLë 5Öþõ~pP¯—õm0bâ Ó&ßÍC¡Îco)Œ´úGG·ƒSHžo®<“±þ¤7¾gÁX(@‡/¨‘ϵ‡§ÍdHñ#çWÇ¡ž;*´m]"¦J£5a˜âÆ€`£²å‘‘+éñ7`$@?¢>¤~ ] D‚óþ|©¿²a^yõWåwµ%zõïЭQgZù¥aÄxßPp³ÏÞ VÌ‹…çV‚àE“)‡™£òÃh…—8ÁøéjA‹!ºÀù5È E]"NÃI6“n'1a³ö‘õϧͳýÁƒ<Á3H•vŒ6œzÏã@ö0övSr2¿N_Sr¾ð{ˇÀ*Ý>Ђ,î<§È¹Ðh:à—¦Õ‘›ýØ6NÓ`l8¾Z ؇p¾ÄQ“zfJ졚—Ân±HÑ{_óq<áªd3Oˆ91 Ù/¡œq'TÉMnöØdîG~¿¾Îé·(úñ…ýµ;÷E¾âK‹ä‹'ì4Ý^{BY l¸Z°Fp˜DE©þ•ÙmF´ó3‹"tbã#À"wÆA W†Å $5z0Ömòrh¬Ø®2 ௎½¿]X{x^ÂÌÊ“ÖÙ'BsãÁ‡'Ú¸†wNÀ.@˜7 ¬ q¯©°¼+^öƒQÝfÛm[óÙyz±¸ Ë‹YÊøe<™§3zkrߎ¼ëì*=œM®N¿úaÂÅì2]ÌñIô-ήXøÝòè÷£ÿm9endstream endobj 4985 0 obj<>/XObject<<>>>>>>endobj 4986 0 obj<>stream x¥XÛnÛF}÷W ¥–dÙq⧉ÓIŠ" ÒŒ¹’6&¹ /Vدï™Ù]Ê¢’8h‘À¶Ä½œ¹9ÃÏ'ãß„Î/ùZœü:?'c|Ùÿ¨ÖtvóŒ&Sš¯°öòêŠæ™<Ó<¦çÉ,9§·ª1÷š^µ&×ôÆf-~½6åZëÓù§“³›M°žOˆ§³d†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ââÓ¨}Ê'“ós|Ê¢Eä¹§èbÐ;>:™Fïh”œ!b3Zœ:ÊfÞx}í¯ã»o17r²õàªJK¥ô÷WHÎúÄ*º[ù7ú¿G [œú¨7ÇlºÚ%â4oõ%âŠ%ZK§ÊSpµ­À, ­²©ÎÚJƒ‚*)n_ÄΙN÷ÎáøÅúK£K>r虜#z zÈÀ}¢M9™®ïü}¶…ÖO¯’gÐD¨DÚöŒþÿ‚°Ç¯uî }óc Üyt†L´Tsû±rCÇ‘l Ÿ¸R©ÉMÓ‰gìòø3–Ö²ˆæÌ…a÷)¼Ôh0…ªîpp¦ÁR©$ ÔG€&“ÃäEpÌÚòÜøLÍ2BUT[‹Ú%Ä%Ç1ú$뎺1à%+®„p¸ =Ø=Äÿ*'ò&Ëq݌Ց€agʹs]ãyß皺k^é¾ÛÈÙ]•þÜ¢¥¡/À}¥mˆoÅÇN7‰Ï…û ÕV¸»†gÓð‰ë‰ÖsH0ÿt« €¸ ½K7ÊhÅòp²èμŸÏP ªvè09á€×¼d½‚)À ¸Ç´„¿i¹È}NŒŽÛ*slÚ`ãQÛÊ™ÿ!W×PœÐÅoß3é7ÖæÌi[ ‹0^œ&ôû 18ô ‡e[ÄÅÛ{1µØj ¨ùܺ+–8ÒÝÛgVÏ­Y?lÇ_·~¸êØûžµæ?ˆ®×ul‘Ëß'’ÏŒ>tfÂ!"Лƒ¥Ü$´go¸(ªÒ¢3®ÅÜš.‘{2céSÞ…ºzâµL¨>v®õô¹ É4rçŒx—Kž(y …˜iké20vû©fÆDÞf i‹˜9ýÐÁ„ÄGOf¥†¥.»dPqɚРì×_ô´~BKøöà²00|CkÔ;³¦ØÙÐBû0çÁ±61ã,úÞj?uñ®ýÎý¼1PN;™]ŒCŽºòíYäûýia|o vµÓæhÆ·T!9ÔÏÿ¹ìaïIT*&“@[&1Xu#Õ. A(_ç ¯HÁóÉ_ÉÇäo!‘úZ™aºv*ŵ1dŒÓÐ#¢®Ï ÍÜNGɈx•÷X ê·K¯Ýé<¾—î2†Âƒgûz”w%îµÉ•{m‚š¼ ÷²4ål¹±¢\œkä;^³È»šh¿V,wX„9X'©z#C™Œ® „ÞDY¡:ZWvÇ´ã¦{LJZ€ïá•CÑGªm †‘¬Ðì¥ô;¡ÆðÎük‘Ïh3`”ÔJUÞè0>/XObject<<>>>>/Annots 2124 0 R>>endobj 4988 0 obj<>stream xXkoÛFüî_qH€$FO[NŠŽc»’Ôµd'òd]BòÞQŠòë;{J¢•"i¢xÝÙÙÙ]9ê²~º¬Bÿ“ü¨wð ýêÒ¯»ë£á î±î Ÿ²œF1ÞØ‡ŒvsÖí ÷^î>ãm÷ 'l·î>ãíp÷wßî<ãíÙ0í¼};Ù±Ó[>²WW˜À&s8tr†©õ’èU±„¬Ò‚™…`ã¿o®Y*K‘¹šO>½º‚gvô¢à¹pß…3#Æ‹ôɺRZiÓK‘ÈùÆ^v]ÉL0ZÈÔÜ~³.ùr)R6¯   m_ñRòYs¦‘öþkw{ð$ºøãüãõåxz;³Î€F»Ìq`Ú;9õhVÒKïøX:ã\[ÍÈ<¹õ·iø6ÛeJ—+lÆ)WPTÆ"n1UˆúZÐB`jO[tEíßz!À˜'‰öœÜ^÷³V=5‡(ìQŸ‰1µA?‡,%ÕkƒX Õy©à½©ÊBMtWJ¦Mû§Q®`Ã:#µÈ6-/Dš­ `º-Ç‘ªLóŸFþæ'Ž/><Üß^^Ü\Ý\¾kìžS²`¤a@m?-¬ÃS(¶âY%ì7EÓ&^>~ß,í(°+®9OJÕ<äúþæýåÃùííåÇww—ãû÷“†©P¦ÊT”6AA"è-wfÑ7ÄÂLj Ý3½ÆÓyüðkœ(|¨2#—P:ç¤-3Ä…k°UK:œ,šŒ¥­P—B°5ßh/6'>%·bÓ<ø’‰ÚS-diÄÞn 5s3ZLΙe…ìÚ»¬Q6LŠÁ*ç‡H‰,Þaë¼·áLB8PXý>ìᢡdÉ›|vðaãL,øJª²ERçàï0*¼(š=¡×‹û}<¥Ñ wÛ×d÷x«J=Ržþ ,ß‘¦€’•¦MŸ0­PyUy(©u…üúQóÜIÞÀ€xÛzƒrÅ„7þ6Wª[ˆ®[Kè0éA}p|Ͻ¡­§M÷¨”äžqmÜDF•­žÁéaè6|}Eš‚â¹ÅE&yaˆ|‡¨ôC \$ÿ °8$)§ÏŸzaŇ@Ô-'g›fæ'Ðä6•U·µÑ˜DÈyë8 Z‰BŠ"Ùï|ª U qs AG_A­MÆ 4å_q™QGE9·A HÀ=‘Üi„è·]+d[¯r.™Æ¯öhzü¤ÄÇì‡äTÀ†Žõ5=hx-ª©\É´iãŽþ#¶ñÂeÖA„)ó¿TÊ c;CŽ4Ϲ, Ž-ëÉíº”FÔ}ÐÁ,žF(”ëúÀú(ç™KÍrÄðo9£Yì< Îó XèÏTºidhÇqØBÒÔyX׸¿='l‰Z–sY"J¡‘H”¯á2ß¡Æ6¤óLUFÏÜÐV7€4Hði/ˆ¤8I kmÀi j '’®ë$v”$8ì;î‰Â5‡gÚÕ»g6ël?CûÊsÔ0{:¡jÛ]4–Ô6ƒH”²èâlwL ¹ÓiX¢:–9‘±'ºly1GkP•b=ƒ·8K¯ghˆbPF *™D‘„û¼Ø0·¦ 2–ç•¡ä"ï‰vN `£+(™(ªœŠZt}.wD}Ö!kó ÑÇõ$T )án§Ú4AñÒíÕ¶v4³µ¯ö'[LŒÑ•ó`ù4¶³áþÎ0kF¶1¦‘œ-ÔÚâ¨ÜÄŽñLøÞ°vÊîzC4wsx¾m^ÑLçjÖKx?Çèøí\ 9Ó~À³'wígô¢˜_Pý>Ó ,õë&©ùÃ#µÍUbØ×Í·oö’u¾v{ýŸÏÅoÈvԎزÕhɬÜòÑ­ ‰/Ï~om&øUðð›7˜HWnP×45ÛƒÖ8ÞÚ„˜(Ç k.]œš}BƒáæSÎ.ªŽGnú.±/usIQ7’ «hòkÙrIÌæÞ<—õDF3§µ A‰P/Â`å²ÒzLzÿ•ˆ¥Ñ*ÙΔ²0ªÛ‚gsפ vq~GÕn;‘S`ýe8n¿-|Æ&S¸³69ŽÚ #AºÿôȺÆãBDlÞx[îaðíuñeèätmIh÷ð'¦w*©ò4´ íž[Ü>uµ %gÈî©^ê„°»RY ´ií°s÷{øJ^¿{F_]NŽþ:ú¢Ù¬õendstream endobj 4989 0 obj<>/XObject<<>>>>/Annots 2127 0 R>>endobj 4990 0 obj<>stream xXmoÛ¶þž_ql€sa©¶œ8v X», °ÞôÖÁî  %Úf+‰)Åõ~ýžCR²äm]vÛ¢°Dò¼=Ïy¡~=›Ò§4›ó¿´8›Ä¼áÿ¦ü߇۳érÏh¾XÆ*(™,âExÊiuÖÆêåÕpµ÷ŒÕùU|Õ?Û{ÆêrO{«óE<§Ëd'P»¼†\ÿÀZ{M/§ñ²·ØÆêÕb¸Ú{†Òéd øÍC/. fK¯~¸¤é„6Õ|‰™‹~¤##+#­,kUn©ÞI’Ÿ+™Ö2£J«²–†êC%cZII"·š.>öT¸ CÅèGMSFµ*¤;BéN¦Ÿ¤îoMÅt·qúV؇#zýj©ÖB÷^X*uM‚V?ßÝ’-ôÚÉ¡hšÀü¡Õ‚R]T¢Vë\¶Vq”O¼úDp®öF—Ûˆ½‰„ÙúÅ6.#¸ÊªVº$eÉ+b¿gI¬“c%sVžÌâk ½‚Qv(†·\Æ—¼é®$)L®Àgi,[ÒçΘ޶fZÚKƒÀµ ÀuxBbkP,¼+k¡JHÐN~™LU!r+3É{X2c c£`ŠÕ³È@WB2¢ÜæÐÁA RÀõ;K·BàDžë=\—[e;Kml€ßŽÉê(Å>g4ì9=Ž,ŒÈröñ‚c^4éŽÒ\Š2 ߚѹœäÜ\K‰hUüÁ´ ˆïcb"e玂ü5ž•MG U:G7š­…#v:ŸÝï4¼qÚ<)ÆxÅŠjFv£ŒÅRÕJäê7™)5RÔÒR½×Žh`"Ã~îÕöÜEî<…>—O’º,±Êqßh‡Êh+ÌZl%P "¼¶ŠÃΰuKNú@$Ó!“65j “Ö^Çt#dFÁ…‘%XXLÐXˆz<°J°ö Êtà ’JÄÔû Z½}÷ôWïîß$£Ç €Ó^›Œ©•‰Z° ÖÔUíCÚ2½œdEúúƒKúB8rO Ñ“*7šþE z“Ö R!8Ëô«w¬ÓUÔ A[ RªŒnïï߯¨ÐY‡:*å™@?;î쨪là¶»Aí«`1«óBÓè‹™ŸÐm€ô­‡|fOûU¶+íÖq¨/‚6໋èúô³ªLe[*лæ.5]õCZ -mŒ »¿ÅŽÅ8pZ4µðŠóón§yƒ8´™á«ÀŸØ>YÊÕ'&¡²  ÕN°9"ckÍ U¢„ÒVÖÔ’9W—jI‡*ò€su á‘}§z;ËŽP{ø £›@²Læ²Ý›2åZ‚Þ„Äu¹Xs½@Ó jÏzõ}=.t[,Ê4üã¶Ã‘$›OéS&7ª”O[Û¬KVXàŒÿ£5L.]Œ½Ót»G”m›ƒ›£ ÇÂP –ºh6;b°ÄMœ‘®G>£V NmhâJQÕóGƵTš>:Î"_wºf(­Aû±±Xô˜´Î“QŽ¥4pËÃq‹'º÷­\ï‘®v§*WB¿.åÞ‹á±n `b±—ŽòhTÈ‘À .DåJ,DÑWN0= §­;[×Â|AX¶“‹¾‡S{UïÐÉÁÇ)âY¡rê£!…„| 3Ùïz¹ïü ßÖÑûtÓÍ ?€Xçiþ/Ü’œ;©ÎPxA*{:”0ɤ1ÚIG #6©IÆè.¾ r‘ͼªðöµ×=¡¦\Œ) wÃ$žÍð”Èýy÷ÝûGgÉÓ;Yhs¸ac·äº\T¸×‘³äüñâ›6†<+þAÆÝ}ï< ñ2”~áù ¦ÍB…øó˜ùõ …Üaôù|ÑÁ¯_(âÄêK~0ß^(á{õ¬x´{søE€zO²ð:Z¢ß°ð·½GåÝ µwÖx9:¼~¡5«æÄ~L¼ë^¿PÆyZìÌè°uCä E¬ÜÔÕ“ÑšÁÃØPÆ‘ð‘£í,žÏ¯ÛA•W4yí§7.t…f“aFëäV¡yî Q—LêsSùI­_ué+×€ÂPù7Ù½¤÷F§2s³ˆNMÝÈú×)ŽáD•Ïú så…«n$¨aY„â€Và/m¢†ûHTAQ¦SÿZ´×Œ¨¹*}Ul'U:ÚųÊŠk²¨èݘú ë®m×ÄH?µ0Ùu~[µ-ýxÂõÕHL*%ê-˜á+îÞ(70ãâ^`;‹$îjäK"*yk)FÓ?sÈ5ƒ{'<Ã|‹ý4+¾E×u·Ôg…–öÏîÅ Í>ÆÇé:‰Wc=tøÒ€yêúN4/Oàrèûxñšn"<“xådU»žÍ¨ù R7§‹@†ˆï™®?&H ¯¤½ÐòZ¸ã¡Ç©òÄ„¢vêiŽÙÚü¿&Ôò3Ïò_0"ìÀM²1)˜äÁ,0„ñ‚ê1ämwÔîp‘à;¨WøkÀ—£7eí’ÌÝ¿vÉŽ°¶Ÿ¢„¿·DÀøþO7TJ$6,hoÆ~hë’lÈ]N^_<¨Ýx(Ô"›L.ã«>&]_Å^gE”àÕ÷ýd`Pýæèšùç?@Їö›¿Pã"æo°Ìú;¾šÌãYâI4K&üêæáì?g¿;Øîïendstream endobj 4991 0 obj<>/XObject<<>>>>>>endobj 4992 0 obj<>stream xÅX[oÓH~ï¯8ÀîR»¹”ÒÄ,EH¬Êª‘ö%Òʱ'É€í1žqK„øïû{;i—¢•¶T4žÌœËw¾s=ÓÿÆ4=åß$?x3;E#,úÿª_Žè,šÒlI“ž£ÓÓ4Kí®Í’`ÔZ„¹JëLhš2á9¥*©sQ˜ØHUÌ燇³Ï# Ç8“âŒæQS¸”, ·ìϬs\AQ„Dh“^Áö×°ã×°×nvÜr}ÄôäÌS¨Ç¨üxàá¬LKßnì°Ó£K ÈcƒÂq%aò¬u瞊wN`qǤ'p3n¬·Æøç×éO. q¶]kK:/æÞö"“KA@ä ‰Ï¬÷o«…Gè{â»útçY@ R'é)Ës’²öÚûÃï3çøò¬i,㳓èùô9âïÙ¹Ípîüá$Qï… {κÝá —òx'qÞ½’迵áÏG§Ñt‚·(Óɘ—ÞÍþ<øK‡.endstream endobj 4993 0 obj<>/XObject<<>>>>>>endobj 4994 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¸;öû‘%Ÿ·ð­nÜÖÝ0Ei‚k<êL“„ü0éýÚû ©,†@endstream endobj 4995 0 obj<>/XObject<<>>>>>>endobj 4996 0 obj<>stream xXmoã6þž_Aìa±kc;ÉnÓ¢@w)¸¶{Xýb %Úf#‰®Hååßß33$eÉö¢(òæHäpæ™™gfø×ÅL]ãk¦wô]ÔŸ–×Ù5¦_íV½¸Q³kµÜ`íÝwøPò{|(&¥Þ˜Æxce7êrùçÅûHäÕgkýÐ5Åj²º”WQÐD­õƶZùVC?éûhm¬¬Ÿ¶z£z ïHIH2Do¨TT¹sr4dþ@²~L»£‡ûåYZ2: wÙ>/²»»dƯ֛‚ Ï}8Í8Õ9Àœb¼Âv‹.ÅóBϼUvΫ}çÙuýàð·¦ÞÛÖ«7k³Ý›oøühcS™&8ó H*[<²ß?|§fs‰ÁéüŽÌ€A³Y6S¿æµi¶ê³svÃ#Éì›ì†VÿäÔ«íT‘7Êi­LÃúë—¼Þ#¨òµ}ÒWô1™ãgo½n¼É+ÕˆøÂ6›ÊÞ 'ï*¯ô  èò¢ÐÎÙV!¬OAƒ¨¾¿Ï‡êMÔSÞš|]±áf°°œg ™#Æ»EZJ¹G™ôÜæû½nÕ¶²k¨¾AîqjBâHÖV{hô¥êFˆM2õYd6L  {Ĺyb÷ñ =‚º#R(€SZœ¬‹úæU•@s*oJUëz å£ÖN=¬YíÞ름Ôgãwl©ä ÉÊÔWË’â¶G£³§c$ùx8Pô¬:çåÕ_Ÿ^Gðdê§ÊÙ+eNC»µvïWÅŸïGû’Û®F@RŽÖOºåĦ¤ØÝ€±é@cýz túèDNŠÅå³UÛ¼;­mÙUžBv­fZ†°¯¿þ9RD fe éâsÓ€1–‰3¨ÞQÌR ôq[¸ñ0pFLwž  ÖA#$`hHè?(²âåEŠÅjÂ#p¦º4ý¯ió­ÊŽÀ^]*¤pçŠÚùn¥Ágd ´%¡D¨iØ~tÂ8uaÏ!ÊLµŽ2(Ï”€²°…\ÔZ¡¯ÂÖ5eqgŸaÇ@£@0-%ÑÛà¬Ò´Dñ¤a:G¸6ŒmZé|Kûfš\ù&S”C{„L”¾ÔÎ ûœF4³EÉd<÷ºÝä(RTò™CÄþÀsC¬‹è)(5RäÛîN)2ÚEj÷æŽ ˆ =挨„t*¾N’ùP|†GG,)ð=î\Â@ŠÅ.o¶’ДB#íYs×mNP5!L«]ÄØHLꨤ$\õsþµÎÝQùfòÙ· x2OÔp’–B$SP{ìˆúæp ‰x"·Hë(õ¢ï4¥âÐB1—,gw‰¥w±“=ÍäµH’CvÄÄn¯ "âP¹¦¶óXHüB>+º¶%RO{ÿ&-ÄJ2)bȘâF. I+OûFì€!Ð H¡¤<Û¹žHûèX‚F+ò8!˜tîÓ>é"G«;˜JįJ÷u»¸wÌu¯jmCo02élǪt> #„‡4¸œ Þ ÍÀ¹´ª¤®Ã Q[Ùh¸-ÜI¹C@¤ÎнÖk[9µim â†i­è:8pH§Ñ„“SÍjsS=Æp5’ Xü_÷¢IKà Ÿ¨oÃ[¨w‰Nî#J(NÊÿR¥wé%öM»L ·q‘Ö}®¨ýÃhãÞCšö%p t0rËÎD¤ˆBøÈž@'†® ®uÝžç’VÿÕ¡Ö!d¥iˆu ¥ 3àDx<¹SüP«TAÈíçr“Ê´ÛñìJz†æ¥Ï i*‰žv~á¦kˆÏ„“²áÞ=Ñx/}—’ }BÞy[Ù¼D …õ¿RŽ‚¡.'¤iaòzÙðK^pût¨]¿7L¼ýø9€XnV‘7âô¤;¹PFÍE8z»pñ@õ ‡’ÖTXØÀIÙÈTÏt€Û¡“¥ÖiÝæí뙘Ôá÷¡ó“À¸RÚÙêRz×[|yx‚3Q"œn=µÎkãé4QÉäÒ—²cS¥ßM¾¨ `ÖaÃIçRæ$”1ËhykÎìJA£ÖèÞ1ñï©Æ“-âõ;Ì‚·ÁϸÂøLSÀ—ÐÏR¾RßL}!JÙ¹þö^áŠ!\0GrZÒ>ç_1lïò0¤›"ò˜éiøšb8–%êê6NŒLèqRàL”q¥±>ŒÆ%•ë|À)¼©6ÛOUFÊdaíè„󱛈g"“E !Æq<=îb§ÅÓ±­0!0<àdÜÔqôFW Ê©PP²o§FpšÎX¡L” ¦p?&÷G‡é* E¼ —m ¬D)hC«;À†Û^ø;­U¥ÙSñ“ñ÷[áþò+dÇ)>»gCHO?àÂèæ#ÅôjŽÛ0yßÎ> B-nÕÝbžñ‚o:ϮտmÁówN·´ í&»ÅÚé)šgo£n¯ï²ÅW§8s1_Ðæÿ,/þwñÏA¶ endstream endobj 4997 0 obj<>/XObject<<>>>>>>endobj 4998 0 obj<>stream xÝXÛnÛF}×W ¥“’([¾ä)E›4@ »°¾0VÔ’Ú–ä²»dd¢è¿wf/¤HÛêAÛÄpj/3sfΜá“9ÌðïKúIŠÉ÷÷“Y4ÇÝ/•ÁôÝÌgpŸÒ¢å~Ú˜ø! ê-½eŠo kÅTÜÿ6™¾›Áe´ Mñ Âù,Z,ð›à8“²Òpü'¬‚\²MÈk^j!K8ЦxD*e¤åé¤x¥¨Šö¡›&çú¿tŸV'pü—½Ê›ÒUñ"Z./èª[…»®lLežË(3H䆫ÍÓZV Só1ã%W¬F?ÞßÜÜÞAÖˆœ‡öb´u'ê­Yç½³ Š%¿³ŒCÑN•´‚|ŽÉZ>46@CŠ‚•· RYSð²Ö«Ã^üâØÇolxŠü¹« hÁ]ŒNÊÕ‰=€"AHoÞ€‹ùF(žÔâ‡LbT¶\qoªYù倸ãìÅ« ÑÞLDÜñb‘[w;AP…,½ÉÓwç.Ï óy$ÓšÌþ(JjƒEˆù¡ëf=Šê5ü„~¨JVp¯[ )¢Š +›|k>ÖÍŸMž…•… HE¸mtËûté îðî¶Ž·)^å,Áô2ÖﶘjŸ¸¡!ËJû˜2ud’1F7i*ÇGúœ‰à÷™¼®%PU÷‡e霦3:c1¹LLÒ‹ò¹ì>ÖÉ–&Mz Ë¤SØmE²Eãóœö—S¶Ù ›h y³÷î~ýðÞ.fM- V‹„åy ¾øh Yv&šâ…dœYöëØaܺŠƒ9>ÅUʾc¢tf?å4^‚Hí!÷ÎÌñ]Ï%B,GA!ç LCVI¥²lc³vd¦-^ûÐÝ0t^TuÁ ¯vB» 8à¬Î…T_‰,k†yÑåªÉ0ô¢äÜ!ìsm• ‡©DpCµÏµžö\"~;AŽÞ›NLBQ&yƒ½êÛ…¡[$„N¤Xücº%JYSöO4¥Å(LƒL,ë{áà1à-„&ÄGSÊ”i-§HñCz¢Fxøv¢Ý©¥]JQÜ<ØûÍ:*Ý:Ò=Ø_·Ça48V¶#_ÿaqúÌÞ#üÊ®Ø%Õ˜õƩاfĵâÔý:¯Ûb-süuÃ#þ#“+ðº?ßuzMýÛ«–ù¥ïˆñE4‡x‰"Æ ¿UŒªÌÂîÛ<­c#(˾ÅÛuÝ]cƒCÞÁl™-hìÎ9SÔb*' °MôÒ€½Üur-‡ù¤õt|ø/ê>/XObject<<>>>>>>endobj 5000 0 obj<>stream xTËŽÚ@¼û+úÉHàµÍšl’C¤zrF9¹ŸÂó/À5©PÚóN·Ì‰ŠIr_BòȲE …ï@8è™lp ÃÃxÃè.9ů­»«ÈŸˆrCI Q¼:H¯Ø¾oÙwª½ó4âžyÅÍÜý-RHñ5ýÖñVïH-hbl@2ÕxÖà°n¡í‰ã– (|½øc<ÞV>W.Oï“b^ÀCXü8šåI Ÿtå[ò—ŒÔ*€Î†ÂÙë°«<ÎçI–%9|ê—PM¨)ÒE2Ïé5Bçyn}.£ïÑ_{ßUendstream endobj 5001 0 obj<>/XObject<<>>>>/Annots 2181 0 R>>endobj 5002 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ʨš_ß\üóâ¯UÝendstream endobj 5003 0 obj<>/XObject<<>>>>/Annots 2232 0 R>>endobj 5004 0 obj<>stream x½[]sE}ϯèjYX;šÑ÷Ó8 ›Ôv7†¼ð2–ÆÑ¤¤191¿~Ϲw¦û¨Â”‚rùøèv߯¾}o ~z’…þÉÂxÆW»'£ËþÂüï›'óürf‹%~îB–.—=Ú†7OƒÍç— eƒ,/seƒg—sa}ÛùÜ·.Çafȶ ѱm›XÁ\xÂm#ë ϦýÂS.lÈN˜O/gÊ æÂæ™(ëp:Ö… ÉÂ;]\NÂ,±‚±ðbvÂŽgXr6A@Ø‘õ€ë „`6£ÿí“¶©`°Ó´Y_6÷ÀÎÇt’[6AŽ3.IÅ`g¶ldÝ ™n¹¤%¸¬@æ3æR$û²ð}d}Ù‘‡m9f®°e¤¶“Ë©ŠÁN'´%Š*»Ì™‘µM§ØÍs?G68â®Y–0!0 ;g +xò'NXÅ`‘Î'¬à]ÆpqZÙU^x²d ¡”!SY0”B\OXÁ4(ãÂIV0”šÌ‘0‰µdšÎ<™×‹à€» DþŽºÄ Ä–ÈWXj«PÐm™ö©d¦ ‡ @÷žcÙ)˜v.NYÁ`Ì_ÉdÃÎÑ‚úÆm»`ibᕃ]ä'++‹Ã û*FX'ɾä ÔËD+SC¦²`š;¥¹‘u/ŽSÃņÜS,bŽ!šgŒjbƒ˜+ìŒ5Mdƒ],xx’¬`ø"c¡M¬«ŒÍýÜY ¹Ê SesybƒEhàäÈúÂ#OSÆàº!˜™5‘TÌM—ŒsbƒhMdmÓɲ¿Ê`ê28rk†(b7RV0Ø)ƒ%²‚ÁΩ²°‚ÁšÃ…Œä9|‘XÅ`'¼B… vÆ$¬`°‹)\•X+ü‘¡µÊà€¾¸ Ë œ˜8w"®)?æCæÄQÂ0 ÔM¬`°ˆXÁP+…õmgC9µm ɶ;Éiibc[+ ƶ™ù0Ê*k+ɺRhŸè +„ÔI 6Åk"©lÎfGXÁT˜ Yb}S»{lSpúMA¸~ˆ¤b²<:Ê&ì›"tQÖ7…^^xÏO ™û³„!j_XÁ`ѦÁÖ$+ìrÊŒI¬`gA•#«,Î~¦¬`°ð=e’ Ö²0±n.Ì¢¹h¹±«Z+ÆÎèŠH*¦±l ëËŽ<‰}iٞˬ™DR1–E—Š#Y[v'ÃQ Nd- ÆÂv‘+˜ÛÎ:aƒµö^XÁ`QEN´ÌàLP ’¬d“BïþqÌm±lÆ “HÅT˜e"±¾¬Í Ñ\š85(‹“+ìœ)‘X«¥cTM¦ R œú_ qéÀ ‰4û‰‚M"È45†h>¦F‰ ¦btL¬`°ÈÓ•ƒÅ!ƒ'’¬`+Þf‰UìSk”uãäY@‰At Y* ¦AK*•XÁ`1†báÄ v¥¦ÂR©ƒó¬'YÅ`§Kº*®¬˜m¼¥bdÝ aŠâ5Ž£Ð2A(Œ–JIÅd-c¢¨b°hîalbCa”=(YÅ4–U^XÁî 89ÉBƒ]°AV0]ÁY)±î ›É ²-9Žšbšk¥"±‚Á¢1A^$V0Ø¥9#±‚¡2ªbYÅ`Ñ`‘‰LgŒindÍ É k­°‚!Kš(«˜ÎàH’usûy¯2àâ@+›Z'”HÅ`1F#ᢨb°Øt¦¬`°˜2eCa< ãÊŠÁâbЕ»±Êº±6ç'Ê~~z®7.’Š¡°µÍ¬6£`Y!쌃rb}S›ŒAŽØ1²Œõ¢‚)jÁI¬`°H‚\eÓvl£¬b°8MHÕÄ ‹îKWVŒ{à R5Ê*‹ñÑ‹¬›k3y4ן3`Ý¼Ä †¬5˜ybCe«ò‰U o“0(Ê*‹v%V0XÝYÁ`Q¾‘RIV0¯ÔœÎˆ¬9#ë_$¬p@_„±žD*‹ t¡¬`:Š÷È †Â–a‰ULW0k„ ++˜Æ²ü%YÅ`±’Zd=tÖ¿GÌrT t…@Ì9Wµ’S±e.¤b:ñTÔ·ÄõÅfõ0ƒ«†3+-ý䄈2Á~1ÉyD‡—÷m|MðÓ ¬•ZG´ÄEíºâ!!•ƒ„Á¢½‡ã+,œs FÐ03ÁÒ(«˜g•XWÊ X_½ºY†²ÃpH…y‹&R1XøËÚ:ULs,Ë+¬=¥$YWÉ&y(k°&ÎõŠÁÂÕ'¬`°x˜;aÃhñí[\Ù·µI¢°öĹßS©ŸÞ¡=BÇsæBx)r__ÿò›¾ö]xúKÂõm˜ã» %~[ÛWøeõùwwe»)‹u(êuX5ë2Ül›¢ûûõ{Y š‚­”Q.u§øÑ_2^¯?ÿ·|8•À…ÓK {ûç/²œoªÝ~[†uÕ–«®i¡üXð/§‹üåÛ>ë÷ ݦ…ÍUý.T‡Ã±<|ª}÷e{Û´»¢^•¡;ÖPà¯ßù)¶œ#@æé¯V«òp ¥û¶éàírvåî¦l`4kXáÙüw#ÌO÷»^5»]S‡ÕñÐ5»ê碫€nË¢;¶îl|+=|ôéÕ—_†M¹…oÂí±^ñ³ÐíOåßÕ¶80麲>PµU· Ÿ^ÿõ9IýçWåÞü±Á‘Û22ÃîÁ£øÙûâ®(‡ÏžY§×e·iP,Wzu¸ÿÎþ¾kÖÕmõ „ù­ \°qÅ£æÂKÅCif‰w]íVšº›ºú©?«)}^ÖûcgŸhŽÝ-õ†ºáØç}µ«ºê® û¦ª ƒÛò¶lKÄsçZ_ë†ÍÏÊ·m±ß3©®BѶÅýÁÃù Ñìÿpf¾¯ošc½F™¹ _™gÞðëª.Úû°.º"Ü›®…ùç*¯Í¶²¤.?Xþ­Ë-Ò.tM(¶ÛfUà÷Û¶Ùs=®ØýãüÐ\ÝvÓ>ôø,&ü¼íÝÝïË]±7—¤ƒó¬¼-Ž[œ—v8ü\À™>çöß°û [Àµꦾ8UçÜj¼©>v÷Øû؆›ª ¯~x}îßnŠMG(Boú?—ÖÙßiµ®û蛇ûè†+»t©Á ÓäÜÖÇ H(:Õ›cwö l»öåª*¶á®h«âf{öMOü~Ó ¿@EƽÃngÕìöÕÖº¢3GßL·¶¾O·sG8¶ØæïÛj5äù#7î˾±ücõ/[Á죞û|aJ¤èWsëù_ÖÇÝÁN‰ÿÆ® =E¨jtŶúùÑЃÏ꿆ŽI›¿0¸Ò¥ãÐ+éš§Ïš•·OP„_ôXh6í½á¶ÀkßÐMàî㽟ó³—¿ î9Ý ‡Wß¾üdlÿ‘‡ÎUƒW–¶öèlà’¤Áo=$=¸_yVÞß½C >î|öÙïP?æ¸}B·|×n3im¿ýâý×éž^ë/ðeó2\ä6É_o04¢¡Ùã+¬Ëà £†·7o_~ó·C8÷û¦íBsk—ÉexÙ!ÛÑáÂk},¾¿þ#`è IDzm>\lË»r‹Uñ\‘E‹‹ˆÂ¨$üÞ͑Ëíï—B\ª Ë¢ÝâqpÐípÉÏ>}1|Oã?€šŽñ?nLÌ ê{Á¯ýq­#ŠCÐÅðÉ‹9¿aX»ùi«mô*×â04öÆó9ÿôüúÉŸüš¹ßßendstream endobj 5005 0 obj<>/XObject<<>>>>/Annots 2236 0 R>>endobj 5006 0 obj<>stream x}X]sÜÆ|篘RJÅ“M‚÷ARGçÉ–B™Rì("c½èeXÜ­`!|Üñ’ÊO÷,pÐŽK*AìÎÎôôôÌâÛÉL¦ø7“Å5ÿÇùÉ4šâ/ü1ãOïN.£™\ÞÌ¢×’Ëü&ºî2¹?<ærµŒæƒw‹é2º‘Ë«+ݸ˜_EÓî‰;‡Ï¹,WÑrøvðŒ·°Ü[Ò½ƒg¼].Ç{Ϲ\ÂÅá¹óë%"˜Ï¦Ñ%ÂYLg°žÔòà™^-`ùøö§‡: Qµ–‹Û™]ÂÚC ¯—W0ÿ(‚Syˆ'sÂ÷­­¶Îî^=|=¹¸½”^qù9Þ.—X?yØXüuúR>¶••÷fkĦ©¯qµ‰}žÛ"1«Ìâ÷"¶es&¿³0,®Û+k2Ùù*K¤¬üº2ØRÕâÓÆb–TRX›Hã±ö¼­-·¹ŠNÁ•Ùœ~Ø'W7®Xã”ÄŠWãµÏ­Ô®iMã|QËÎ 4æÑŠI¶x4k,Nƒß«¶ƒ à}ŒÓ\¥mM›j¨€•­•/“7o¾ÿþË+=)À°ŸyßkÊãî?ß½“gÖâAà{±¦ÞóU™µùŠ8ÜWã!ø!&Žm]KZù\O9Sƒ»Ê5°Hõ_Õ½‘wEc«ÔÄtúý¯wËŒOö¾äN“”¸4µ• Єxiôô+‚ÚœÂKŸuRU™ò>“R…ÐD·*ÌõȡӀáið8m‹˜‰‘ÄÆ™©º$™"‘V\ã°ìh|³/mõ˜²_¥yî+Xü´®kX‚Õ‘' §&dJÛL\JDÙ$ºƒY‚s ‰É}[4äeç—žxÈ àLÅÙ?”€ÍÎ P—Þ}8r‘Èvì Ð.:¢uTÙË &àà#ðîbµ‹ˆ5Õ‡ÇJ!‰€¸Ã±±An”´Cõĉägˆ¯—íÏ¿";ä­ð¨–*¬®ma‘Ä]À6‹ <ž¡N@Eà„P×Á8Œí¤nËZ·p.®<¸œ™bÝ¢îF§—>Ûç¾*7®Î™¬p"²Ô»¡Õ¯Ç·e(I—Ô¯P^–,W¾Ùº uŸIn›Omg´VWÙ8H ŠA²¢Î9„0™¨1œª)LuCjw¥8¯ãÊ•ª0}’û¤eJP¿L\$?vµÙ6.sÿÆ +µImƒ’ß(P_²CžXŸAF P§˜pÊÏŽ;¥jJðÛÄ" FAäD+û÷~¢Zî )MÕ¸¸—¥¤Q=‹76~$jD®uoGždnUè–2$ÑÓV{ŸÈêo¡à îÊW¨€’;˜ÔÔ žž¡ömݰˆø»ò=ñq‹&ѨtÖâ)!^HÄÈ>?•ÍTî@ûÚf)Ø‚í®ŒbG•>[Öj]£‰ òL…õì<ûfCoøJ 1H‡:DG4Õ‰îÿ å;¬èÛîä…ô±©›ÀËNªQ"nˆæk¯;ºw•“c²*ì½±ºA~Ñâ¸Ü€Ü;` ¯(×8Ð:‹ÌŒû$ºs ¦v‰9–ëZõŒ1ç™÷Êõ dÙå-ªVõ‘„dèò*¢ºU:Ö×(=íĨa¬#ήˆ³öÀÿƒjã[P!•íÔ—]ˆÕ>Þr€¼Íe·q(ûTf ȸa¡ª*dãÖT磆‚TÔMÕÆ”°£”Þú,󻀩ßE¤ "fÚ%hr Å=«úž4â“Ö°æ¥Ïªöm«¢K;ÌT†!!¤HÁS dÏÕ$ÕagöªJ!öq_£Š^(—‘Ä‚BrŒUBFJÈ{Ež†‘É£gÕ œ{2ö (ÀX“ØÔ´YD½Op/(ÄËW6éÉæ¹ßº\Ä-ºVîjiú=ll¼)Ü·ÄnwLiXPb¶PÖ ‚AA9PP_j: râ;aâuc”<çÄÁ2A¤öT˜‘:I;„âì¦a‡íóù’swÂ{.!fE„€­òómÍà 39&åÇ®Ðß¿ýÐóòíÜ{f¤3þ8ƒyŒ|Æçr¯Ïþˆ[§Ò&«½ê-øƱä{u>ao¼‹í™Jgg q®04ì©bŠ'-Aâ;SÄå¾-Nk:R¡¡¨w¡ƒòªðˆqA§e†×ç4lûí—çmàÞ£94Ì¿»¢} „ÍúúM3³…bhþâ8uà.!ŸÑüŽuÑ+ΛýE|ú`Ѓå=Î:³æÄ¯r:B!g6Tì´M;*bå\Ne8ÌS:ûì%E]­A2¡*­#ÄnH ~ô圀4W#xF¾@×·OŸ•¥Œóü®ùGEyÍ‚ñóq MP£¶í,;4 YïJ븨s9¢ñ%‡@ÆSïëÆ†Ù ‰¹ Lóì`ZÓOm°O†²Õ—lÝœ×-n-` @CáBABDò©-„v/nq‡×‹æ„·&9DËÄÞõ—ÐI)£|ª<æ’~ºÛü3¸IòBˆ™i·Ó î_…{ê uª7ÛþZ;dhe¿µ˜k"°@¨]îPWœDœÄvËbKö…ÉѰ2¯Ós€ˆœFø¹^t– c*Áãâ‘÷¤ˆÚ(ÙáéŠ: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ªÒ¾Ýÿ¬Ne-èÀœ|™GøÞB/.¾“[—ÙzÚGN¾»èŸ“ÉËÎ8 düâ?£Ç¿²ò¢nÚ46aÜÄ·Ž`æ¿£Õ¸ó nùÍ— +¾¼ú+_ƒ?W7Ñõõk¥¶—Uë0ªw7ÉàӧÀ@×ìx°s¨Æó¯`ÍØö ¡Zñçм¬wn-ºÿˆN°´ìj}¶¼Œ®Wrýú&šß( ,Óó9>ƒ½Þ¸ !…Õç¯$¿ûZu5½Žs|ªì‹ù’›þöpòÏ“ÿøjn3endstream endobj 5007 0 obj<>/XObject<<>>>>/Annots 2244 0 R>>endobj 5008 0 obj<>stream x}XmÛÆþ~¿b>¤¨©wÝ© ¤vì^š¤h|¨QÀ€±"WâúH.³KžNÿ>ÏÌ’”DÉ:‘»;¯Ï33«?n¦4Á¿)ÍWü?)n&ñoøcÊ¿¸Y¬ñ=-ïçñ„ Z¬'ñ¢}Êé#ï§åöbm¾Š§í/-æ Þº¸ —³xÖ>ÉêÝ$^Òü,u…Mò kÇÇ‚–Óûn#¯M'÷ñšfK97ÍãyxµãcAÓ»y¼:®ýóñÄ7qÐíhü~AÓ =n„Õ_Rñ_’ÑÖ6ÉSSîèí›7·¤Ò”êLÓ÷_oÆï 98Š’7o«NÖˆlU[þ­Ûy#¡c6¡h6‹çs<¥£ïÈïÍŽø8E_Õ³"ý¢Š*×±9É98³ºãs™ñ”8­jí©Þ[JÍv«.kÚš\û¿“¢·cXLÞ6.Ñòvht«êËÞ©*NÎõÁ|÷úþ——á U¦T6…v¶ñô3;#¶Äô˜iÞ Ï§3¶~§Kí`zzÅÆÄ–µ2%¼B”þíØºJ;JlªñRÕTjbÝÒFãmQÁá”XynÊ'|Ý›:“ãNûšì–ˆAPufäæ&Qœ¥¸]˜-Bt5•ªÐ|–ÍèL`wOµ3ÏP´u¶ §›MY5! 1½GÛ(ß’ ÂŽë,*İÇÑ7²?º=UsæÄ5û® ½žgdÇR’©rÇÑ5þ–£E‰*©ñüæê6ˆ=¦‡š=R¹·TYïÍÑB–záAÔ ¸€€#ÛÔˆÙ™[©q:©­;ÈÛ¾uœÁ2 A0Ò”ÓtÄ–)¡¼ñLÝA@"(„‚—(lÚÀÎî-ùJ'fk:| Dþ%숼Tjí S2MË(ÏÊfÉÑÚ$WÞc—¼ŒO<¤b÷•xåàŽX\ëÓo¶n‰lPÏ»(µPVÚnaê…0¶RÉ“˜N›/ª&¯üŽÆÊÖÎâÔŠœL=¥ôÌ?VÊÞ–¨Õ4ˆX[5¡Ø'ÎlƒÎí^2pš*1•TëËnmŽãŒ<éžÄÐmãG•Sx¨¼ã)2ב6erO¶¤ Ú™…Ùe5í,© àÓÌûÌ8Ã}Î" aðuM\¹ÛD³—›Ù"æ¶øcš¶¶¼µE±¨gšþ#mğljÏrc•V€êÞ{Y+f]nPøØ´«N&*e/3´&¸ú /åÄ•ŠHfN${‰¼pÕÖk]2,ÄÝ×;[èk_™œQ¦óªåà²í˜Ñt¯W3¸±Œg“%;"ª[–%-nGStühºŒ'w¹¨´Õ.©*Îzß/Wˆ*Dù¦ªPüçð­PuõA¹ ƒ;A¸ýŒ®‰°S¥ˆÞ2+jÅ ”9û"éTY—q‰Àå™Ó¶)pH'*‘v[…6ŒÆVk•rc©Xµ$b®©ìèøƒünj4Ó>%쎀ÇSÑzÏ×»y¼œß·¸1NŠüÞä9h€ 4¹Fuœd†CmðŽÑHcJã3pƒ‡ŒDÜ0:b1W>~zø |`K„Œã÷×á>§º®™>¬Æ ·2H…jáÊ7áþPb2ámÜYBóaÚi;5º‹m×]71àUÛ÷Û¯¥‰³s]#qàrß—"½Üzj2í3“dÒ„%<„QïþÝ•¥0ý¨Lu³ÞpòƤx‚q¹~À© ,7ŒjÚŽ !3araÎŒEÀèMÞ¨ûÂ!öòØ>><ú]‰7Ž>Zl1Îë8ì®0 Å®‰†Û ‡HÀøí’—œn¹D‰¢‡ œ^{7öÁ”Ε«Bà æDgžRôá\¥ícKgjÓ%Á¦Úo²aæ6ê%D©  UPˆ!‚ ã⇛æàö{Lÿ²{´wjdí˜éذkº6j`×™÷:­áºsZnNÜ?LÒœ†žLνÂýB±õG®AD{‹i]’pÖpü)\<½Ô”°vñ»útÀ”Ï×ÌÞ<@–…랉g†JOé ÉíB 2"‡¹o×`‚Ô¾Fó%8%¸('BT<žàEœ˜þßÏc2™$™N@¹Ö§ãP,¿^ðCúÒ'ó$—êãz74÷\f«NF&SrÃQÂu<Ú‹ˆ‹—ì“ \¹®ðň›í¶ÉÑ=åªÎ·rè `¡ ¯ñr|[8ïÛÁi6Y ƒ/i…ßb–™‚Ø»h†ßNÞÙ×oÜŸyžaK€â°;º L”QsJ¿7eÉù$x> ³Ó|¶æW?=Þü÷æO•ñ1endstream endobj 5009 0 obj<>/XObject<<>>>>/Annots 2248 0 R>>endobj 5010 0 obj<>stream x¥XmoÔFþž_1Ѝp çÜù^’ЪR„RE¥%AõªjcïÝ-Ø»Æk'DUÿ{ŸÙ]_l'JÅöîÌ33ϼñygBcüÐtÁÿÒbgñ†LøÇÛW;“é$žÐb>ÇTÐd~ÏÃSNç;Ýg|]Ƈݯg|=<ÚJrw;Ï%ÉQ|Ô¹;s“§w†³äŸøn÷¹ y2fTî,…´ÏÝÍéAœ„þôü¢c£3´ZÓþéœ&cºXÁ‹#ü’9à—4z]”¦ª…®÷.>îìŸÎ¶G“£×+º1 ‰JÒÚ(½¦ÚPc%™²V…²¢VF[ª›JËŒŒ¦kUoh¦´ŒV¦"ùEe.iô&Yî=%©mINbn ¥¦(>»[£•6#[W*­G"WÂB]LÉÐÆ½:9(߈+I—²$âÅz]Ik^¯*S0œÑ Þ2úZT™%¡3hÌs©&¯IiÉ$ÕQÓJ¨Üz@ µXz0°?¦sÉ‚$¹Ó}º!ÑÉþÉ“'ìÄ_Ä• ú¦”…(mÿp·ˆ¬LÙÁÄ®t¦e²f|qÀ’Ì8FpiëÍÊ©¶„+£\]V¢º!ÓÔeÃØÑÊ’j#‚ËPÛ»KEçï_¿‚®¬ñ§wYÓþ)Æ( õo[¶D»O{‚ 4ô$JMW—FgÌ <‡ËnL“gˆ" Š 3¶f¨,c’}nÔ•È¥®)“¥ôZà5gO!ÒÒò)|ù`P^ÜÀ*…Çô' ìa/+s™ËâÁmC£4~-\B,÷o·Že'ߺԖ2U+…5Lñ-[:^þΟ˜K™ª˜à5¬ö·ÝYQ0ßaZ?&L`£‘öOˆÅõa”,˜RÉ,NPsÞ9€ÞŽ}D||{ÊȼÏC„5œ¬-[hÇ}LÌo\5ádxl‡&ߨZ1Ë=ó\õÆdœÀÂ'Tš kŸµ®9Œ§lUÂ8“x:ÅSíïSÕèBÆ¡”OòW.ŠQÙ\æ`“áÏÐßá³?‹ˆl ›Ò;¯‰îb]F»¸»Ë½rþé)& ªƒø+£2*„ÒËèõÕúê?—{kF–Ç%ÎÖ9nµ³i½Œf˽‡xËžÛòÏ%Óx±8`»OB™¨™ÌeW»8o}-…;¿îòGľNéû®Ï½bÿÉ{»ç£dÖ{|ÄOD!SH~#­~\Óµ©>‘ë ¤4Ÿea¯Lž›kW‚B]½Þ¨tƒ´²ic-¬i“Ýq¹ÍÍ~½újÆ,hPJ¶ûð;‰slQ͵f3Ȳ’WÊ4x0òKßžBŠ Ô•^b-£>DÐuÞkÜÖ‡{ Ê•ì샋¸x)_ðÚ®› 4!tßñðNsï·\ÆÎP5_V•ëö©teŵX¾ƒ‚ž5hˆ ª›âRVܤ*),Ɔ~û€1£7´–5®crhe¡N¨\T,¤®ÿBµ{øôr+Ï92ÚåÛuäŒsiã>«ž‘6Û9w™Êq¨iq)ê {mK¹? œ?ÈbO¸*¡ŒÉª[Í–Q÷†qƒÒ·%¾m4æ/Ù•6^Fí['ê`vô_$ÝÇ‹ðΉ9LÆ‹ñ…ôÇÝEÕ?-#ÿìî͇´Ô” к0¶æ°@³N•ÜM9ÈL`@i7:¤5·RÎÇ0á Àß ƒL _£·:¶øŽßi¬_é%«F»a«e¥]&ÏÐýSÑÀ\mxàLóÆ œ°˜Ç2ù¥ÆhÌ“ž›ÅB)ðzy´›|BîŸ.ÚIŒâ,Ï™‹¹À¿éœº35Ý©ƒߥºzÒP°d¨ iqßiŽ÷Ž25I6¦7šÞ+™k,pñ   Þ»’âªÌ†ªXÏ}`dð#S‹¯pbºEæV_Ⱥ‰ìª}0Pžî— ¹;r¶ìð“÷1|°AM öu-øŽQyæs ôÆÆâ(,xò´ð㕞‡ ñ ,äÍ Ú†ŽhKÐmsÜÚ,õ•ª fLÆW¢R“,°jì¼´Áï|¹M•~ ç´®v‘§Á!†³½~þöøí‡¿~;¾øÙÞnwUö"2u¨þ8sžb„ÀFÿ[^K%ª‡E·ÇP€Þ꣄Da™n¦õt ,¢xtÍç›pP¶õ"fJ7(\Ë*À%¤aµàò©k}~ÑeA©Ûe0ª‡±Ééê›çû(Ò¾>í!¬Þ‰Ûþ=ª¾hå¶ôÇ ˆ_)^ýúÎ/<c<¸Íd&m˜ hÝðÁ2èÈC–ÝF»ð­%o4¶¦q¥Žôœm¶Á %î yÇ­”Û¦n¹A+†æKÛC=KƳx>Åsð²`èäEt”`mÑ͈ÑIüÙÑoºn[™‘S9½ea¥»ÝŠæãE>/XObject<<>>>>/Annots 2251 0 R>>endobj 5012 0 obj<>stream x½XmoÛFþî_1(TA-êÍQlãP u“ÀEšâjùbà°"—ÒÚä.»KZÖ¿¿gfIZ”Œ¾Üα‘\ÎÌÎ<ó<³þýdFSü›ÑbÉßiy2M¦¸Ã¿füë·'gÓäœæÉ”JZ.“³ö¢ ›“½Ë’ÎÏ“‹½g?Þî‹~M“g4›Òm¯Ë |ÈÄ>¤#çéÍíýÉä|Ë’Qê ouoèntã åM¸{Cµ#•eücjã¬*(håÓ UªÞ~\o4e:WMQSØ…Z—”:››uã¿sõÆòú÷ÆxÎÕ¤ÒT‡@Êf´s mMQÕ:ƒEgJãÙ¡¼V¸¥²ð¹Ö*iWÌÏxÅ-ZxzÔT˜•W~­©"8²pU8˜09[ñšÿØ5±¸â.î\¹"±â)uee Ü¿š\}÷6“鄨KîŠÂm]“~Ju%›3a®±™Ic0Ž=šp³;¥ódÁE™ckóy²Xà*½¢{õ¨È7¶”2ð¾¹d£÷Ï8*IÃ7¥2öy#)”]'_l€¯}2öá½÷Î_rô“*«B'Á]b£¨Ž±:ëûqÏ—”«´< öKÕ{Ž® Â'äQûWŸe{ŸbªNîÝ(Þ£_t½qÙÝ›¿ePL´æ¦w£=W çæ”®úz ÿ…ñÿ‰íß[›RÝÝý¾‘¶Ù·‰Œ÷þ–EQò´0ÖÔßßâ5›¸|{¸W–]Ó–‹d¹|{ «NÔ„FÅÍ!ÈFÿÖ`ƒ›6w~þ›M¦)¸R“[Ýë´¦=bW\´ †ð¸‹¤CŽš—ßKèõÐ7„AhиìµmOZ¹z#ýzóõú#m½ª*íÅ«° s·®¼ÃM/+Ø­±-k°Ft|÷{Ó²·Ö_‡i †i‹wÑíè8q‚pý!7±—Sq!œ·†E%¸ÜFÁ”ÌÛÑjO8ÿiäçÏ×É:E‡__ß½¹îr ²G‡‹ÿ"t,%º Aël~×=gÔL…€ÏÎã+Ïòw€é­Ð„}/p=l„ùŒÒ„ÀhA(ol*l/Зb¯µÕÐ7¨D§}&ôËO SÜ $Jh¦ø­"öÄ,Ðzî–¥Œ3í£DϹ¢ñ£ö+ôå½5‡{v¡›L Œ­©¡ÛØž(£¢5D¥¦­Ú1܇¥C›‹¶.ÁñPngÙ`¯ÅÇ’™Ð¯° q¨©2:Eïç >q­ô–{¯ítf1+Êy˜0+2PÙ åÈæEÅEùš ñÊŽŠÝ ŽV’dz%A±±¡ ã+•>0 1hÔ>T®âÿ"5×*zl]Ѫ©)sxG-F‘©É›õ¦Æ„9}ÝV~Žè§ Tr{8 c€Ih_̓ÀùyZîÜQð½ÁÞ9®X•1èUЛ¸âQ.ÖÔA°Sì Sûꆃ opHÜÒ˜mkpOë›ÄPéÔä&E`ó•w«B—qºÅŒÙðÛAP:ùpA<Øòp>ž/YkçgÉá°Å!ÁÜ4–ZÄô4Þ7H­=èÅ`\^ƒpºpäØg±íÚ«>½^>ÇÅäxˆÇCõþüìó×AsuŘér}Œ–Áó—aÒ%wí½ Z”O»¨¼&6ú±wz\ÿO¨ÁäæËç¯  ­Ž0A/åç}Ùì·5«Æô%º¥VìÊRÅzÄÀTŽz¶àš-œ{`z†vê'„à¸ÔÚ«’%°Á‰÷‹5O{Ô³Ãjö)²£¡ˆi•PfÖ^zDdºÒ8aÚ>“(t¿å—5É’ÂÒÀ6«ŠìhÛ JÙAÔ±çS&5Q÷® í\„q;ªØ€Ó]вÔyû×ùô,y»xKËwÓH¬,ã9þÌò“K›É¾e?¨J\;~àBËKúigUù·ó;o§Ëd1“ƒz‹ßz{òÏ“ó>´¯endstream endobj 5013 0 obj<>/XObject<<>>>>/Annots 2254 0 R>>endobj 5014 0 obj<>stream x¥XmoÛ8þž_10 œsµ[‰¤À.ÐMÚ^ºm¶·Ém±€€…,Ñ6kYÔ‘Rìܯ¿g†’e%nÑëõ%­ir8/Ï<3Ãi„ßc:òŸd}4 FXácþñû»£ñÙ(élrLiMãsþ×ÊèîhÿóšÂpLö¾½¸NébêO†“`ä?ÈÁö#¤N&ÁÅÞwíG|w9LÂç~¹ßÓQµ :y ɸê~Nሦ—ã`:=§ûT,Ñ}ÒAYš’ÛèÅñý—£ ÇXNûTÿÊôÌ•iòòåÿK¦Áx8œÝ?ýL'•³'X濇7EýÑöl4_ŽF£èøk¬YâT$ÖÒê•úødöÍãɳãõJ}üüüëǽú)ŒË«mk˜¨ÑY­eAÒ3K^°]'oψ=7§!= OkG÷ßê<βGZÇ+E®²ŠÊ¥¢e69™9½¿þ•–*N•¥¹Î”ÃÎ2Yâß§ûâ‡kqI¦¢‚l•ç:_PìHç‰Yq©g:Ó¥ÆéÄTYJ7n9®¥Á7ëBgØ‹û kf™Z;2–ª¼°*ÕIc‰fj?hSÙÀ›wIc˜#)†á”%…gAlþRé,e- í³ÎS³q]ð³àŒØKÚ‘5Õb 9½†^– #ÛÝåUN¥´Ñå’þ•ëm@ÂüÎ2ÚÄyÉ›±1­E1]øà]”Ä9, ÌÀ¯)ÍY`ÇïÙ›h[VqFãd©sÐýê8•ˆoÃQꨂpU޽û|óÎëôQ'Ö83/!ͱ°«—/iJqV.Ù¬öxʱ_Ç5 ccµXh §­#„˺F¬`RP豄ª 6{cìj `oä –bacW0¬tîJ€ëPcq¿XŠo¼ØŽ28lQùýíM•- äÔÁ˜~¯Á(ž™[³nüqWV©60ÁÇoæ;4§°.3'ªÆE‘éÄÔ}•ŸùÚ‰ìGs?˜LFVÄ”T®„*3)™‚ãÊQîbáÍ6^ȼ(ú¨HµŒ}„+YÆ\mHüÔ­`×~ xj$t·5$ÜG@ó2Ö’¬5J¼Wº_pEý uEtì)@TÜá_Â2LšRÈ£³F€§Ž9@ÓÕN¬°„Ï®W| ¥ ÉÈŽÿ­P9Uvç0¡äŠ˜s(O9ᯋâ³þOlVNe¬¨Ï±úÖ㋆úÎ)Qˆ2Ã7¶¼Èß ™CÒþkTœ .·`t^*;gظƒ Ðò):@-ÐCUÆ– +ï'^÷pÍãµb2åc èÔlЦäRÍûPq{e@¢BÔ×`¯3мÀ¼¯<4þb™AÒ5¨tmò¿ác}àþÔ(Ç;ÔV;0·*‡Ã.D·•R «æÊª<x¶º<èk˯9ц³ï|àØ3‡\Í\€p=ç:U²ƒQ„T^ \¦žfq€ÿ XVïʧ–pz¯É-ï¡ÿo8üÔcýzÌM|Aª\bµ¤,¢­²ô ¾mµð'‘厇†’ðCC/¢þ'¤âµ¶ÑqáÓM^Tå-P×Áç=²ú).—¾™iÁÝߩ݇0…¯áÚ¨ïüÖ6šbKï£<¿MëÃÆ|‡úO°Ûêû[UÂTŸP¢®÷vïGÝ}«¶e) |ˆÙ‰#«òÛ’ÔW'\<ÑH^ïí“U î 5A-˜žb"a‰h²*}’6 s7TÃûiUCÏÃïAº&ƒN­µ«8ÝZð¯P ÒÕ88¢úÂÁµ(Úèü4<ì¿ï ñÿáÀ:_òß;•+ ã×t§Ð:Ás{ÄÉiajZX°÷¤)íœ"-mÔí—6h͘AšeàÇ…ù34bF—–=v勖ɾ…%ߣGø‡ôÝ€ §ó®Ø;Mum ¾×í1× 4Ë;9¾w ÂQ?}=rç6;¹¶>8EÊZƒ>s³DåcÚÊT·Ö½ø=Ô_Ï(“užÝy­}c% NaPš|‹d95ÂòÐ/»õÉ;é™O89ÔKö²c¦sßKIÅÜÙó÷€ïÿaêóÄ*°û‘þc^—MûskJõŠÐ}úv´3 di "‡þ $äªù\o›€vzЬÖüvðÝúhfÃ>J*®ð‹»&£.0Ï6#p<r3ïžØyôp_ÒÛJ†ô±3àPr„Á0L`ãf‰PÚeÆ3DA¤{pÝš  ã\µæï1HÐÔYV·ÜMcW貨DFݦùˆW­Näè3_ž‘ì7ø./YÆùBÉ ¹3s)®¡ð'¢h`•«²’Í–g¦DêA@eO=.rë»7‰sÆï7]oÜã[¡»$ƒOd>Gk)Ö\é0ñä3gxøÜ±T6È1Ï èï1jU¾ÏÉá7D&1°±Î<c£¦÷ôL:è0Ãþc”ÐøÃo~p*П0SçrEKÓ°{aã5M²ä&GP©A¾ÕškÀm<ûïfaÌ¡¾·ÅÈQzç±Îº1‚‰CdK¹ýøú×7>UšŒÛùu†Óû:{„ÕúWJ† nKxäÁ P%åñ`cuY*Ì‹¼³}ºQùƒ¶&Gƒ\ÒCl5¿–xæÿx÷S]à9>/XObject<<>>>>>>endobj 5016 0 obj<>stream xuWsÚHýߟ¢«r[‹oA`p°×UT-Á8GÛ{6Yï]©*;HL,F:„Í·¿×3úaa’¸,yÔ£î~ýúõè'gÔÃÿ3 ù'Øž|Zœô¼«_隺7=ºô´XQ¿GÃ_ϼáð‚¡µêÑ"h} [ñ,W*’´ŠSÊÒkz|š}&¡Cú"v®O(ˆCyºø~Ò£^µ[“GªþH¾ŠmI/(¬Î¬Õìf6Ÿ¾·jÚÜ-¦7㉳Ñ?ü–ÝæŸzªaøô0þ£~ß[Ão/©H*×.À4‘©XS¼¢l#éOerÑä—_(‹ãÈßôi©2Æä[ú§÷÷ó:ÇW¾¿5¡Ü5¢ZŒ>OeŽ5a5ì&“Ò†¯6zëÀ?õý¥Ò¾Dž|-AvðÍgw¿×»Žì‰”~~·kv7™½ž"7ç©3¤•/¥ƒ(¯ŠéüÜŽ'ÿšÝ•…Ñì¯ËaŠ4¡¹Z¦"Ý“–2”! ¤e®¢]Ïç kü=ûT¥;¢­ÙiæEjIqj±•ÆþA]èIé0~1CxRÒ lÕI%‰$ÁEgQé¿íÓìK¤Fô,S-£AßzáN$ªø#72-n×a¹ÄÛ0ZË/J›ôà½ñ98.ìØ‚XÀ@Dçoñ ˜š8®Öÿ”éíÂÅý»÷kDNq¬=xãýÇFÔ å2__­r¸v÷Ù>‘WÁŽºw÷×Ó›ñ×ù‚áè>LçÓñã”—ç÷ŸïÉ÷Q–xÙk·àÀâ+n`§û«o×Qt+”ž<,3‘fyòÛY¾+Š—-ÇB±M ')­"±.sp'7óñç —uÿ{AÝûºuuÅë¸Þ—ñŸão—K"_£¿‡ÏgÞÀ÷ "SgvdÕ÷QÇA¿ðwÈÙÕUÃG yQkê°ub[¢Bk\Áf¥DU áú¦ÜÌ&gê’t÷o3p+¬šî®³¼ÑÈŒPÃÑÛέ ùÎ; …{ïDÁ]'γ«R“Q'ΉY‰Gåj¼ü^Þ;ýÄÂ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˜~¥³sïœ+Âóù’oÃVÿ£ŒXrHÊŠ–¨€&]<.“"œMÞ{î]^òæO{ åJäQÖ.ÎY&· @Bn¥îk‘å)&êî¥3™®D ÙØ¥…/.·G7¹¬ªY5·þ1C+´)ˆ0‡"„¾Óë¤M`ƒËÈY»|ð>‹ GóI € UäJ".¼¢©êû˜ñÍ6sŒ´áÑcg:ñŽw¡>P$Ô™BÎÂ$ØbÜÙ¼+!­+‚»z Ëjxgt‡9¢nS"‚gÁ”áÀÖRËT€hÊ"KWÛ²×\ule`=¤9‹ªI~ÚÚ·7÷µ(T)g·±³Z¹Á*‰qy6²%tÛ=zÚHíèoí÷ô÷qG¥|8ü¹]âÖ½– LulÈÓ$ãö‚u(Ñ]`Á¯b4qk\Ñõ®ÊèÚ„é‡jj)°Õ*$ì00ǾÃhØA3÷*øRFYÓ¶µQT·T{±í3¦â#Ô—»Ùýµµ¯ð„MG$¸ÅMô"¡ð¸jœbÓ8Gž njÉtG’Ư 7·ÚAÔÐR éÑT~Teúf +,W ­»B¬~™,ÍÑ mÊ5[œè­ÌÊÇ·ª;è?…Ö‹È8™}W.VqåÂÂKʱHI­,Gªë¤Ð{„䢕û5pRKë£mU¶@øÀOÊ€ŽÁ_tK°‰cûñ$ ¢[˜Ú í¤09à`XÂXÿœá‹ z ÂîEÛ(cŒP|³ÔD~[Ç{D„SŒg¹ÇÀÁœzDŸd l>ÒðâÂÚéÉâÜé{=ºŽ´¤Î,.+¾žqçÂâ0qûÞ¥×§¯–>öHĆ{C_pö+z0ðÒtqòï“ÿ1â¸öendstream endobj 5017 0 obj<>/XObject<<>>>>>>endobj 5018 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É'Ïb.ftÓÕ^vƒ·-DÒm©ÊrBš!0IeeÖ²¢ÀW<‰!Åõk*Òñ$q—}ƒâ[ë¤Óm•Û˜ ¯}B£Ž¼ Ý9ô);PŸÉÉi<#nNĆ2BÝR!3·ò¿êÕÙÏè=ùóžüÀ8ÇѦh€U:¤¥½³¬ôÌU{ª4²À–ÃôÜq*¶ºÜ¸Ÿ^Ûtë ,øx{Ïøg€™(nо‹Ž÷M&¾(`l—A–lsPkÿ–£›þ<û§ƒ-U&,'ä=€Oa.¬¤ˆ*€°ºL¦˜ÜÓtô…·¶¾Š·¡Î†"‚ÓWfg©hÍÖƒy™í/{ëÔV@¢iÁcU¯’±ŠP‹ÕY_I1!îˤH¯›9½•/[-×0Š!îGòñ% ¢ßîåPt ÇvMcZîc°PÖ»¼æ-­6Ž[žÙùÄ™{Õ¶:gù¡r*s¼7 ÷AX?„Çù\¸zÉ,Sè”Ü[Ó•t9çT‹ ¯s4Hÿ[Я%ú$“à™oyVþ^÷QëéÖs ·p±=Ž}$möNŸØB«<{„«¯§½"ÐÿŒ%@ÞG‘rÕ"Ñ*6sn#Gè}™/ï/y‰©yƽºö}ìt(Gõ€;kî˜ôiÿ5Åí}§¿&îÉ Ü)UµÕn?Ür:”f¼üYq~FÁ ‡>?/kÜüÎZ ¨•SuèƲàG̤üybžRÒâ£_èz•M ›^®F½Êz 8EÊù’þß REá¾ œ­FSqµXÌz 'çy»Â5­r]Ë3´ÇzŠuç'IYíäž[)u WsÎíWÝ+d3ˆ/OËÐhKʯ}6¾M£CNH,Qé'»¦ÅìÈCU03ÿ çí­‚×á%Äíö( «K¾¥mä}˜"·Úb®pÏkEhç~fÚ™G®ã›c®‹‚áÔp¸ØÜ{èü¦ŽHu;ÀoÏÑ®|ƒèMë´Uù)ã’úôÄÌç\N—b>ÃÈ…Ñc>_ðÒo·'œüÓþÚendstream endobj 5019 0 obj<>/XObject<<>>>>/Annots 2258 0 R>>endobj 5020 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ÅtîÍÀlGLˆÍFG+L*s#_G“£—/ɒ˳KoÄ'„»D#JPÛiò,¡)b4HÛiØ·å]ÛÖrÑ7±Äåu <ÆNU­¤%¯{4`ñbµ¨û"Jh¬ ³ͼ`„‡N‡%gwüëñùÅêý;ÚCŸÚëI e(Ã’NÞ¿§W4Ÿö)¢“±Â;Œá½IU˜Iª#‘î=O¯QÉ2U ؃/®e& ?‘ ›6•©R‰Tý±«;fd.SAoÞ­À»iÊ“³BeÇ´BI¬¡Ý¹Ug¿}Ëùn# µ5¥Æ–4‰ˆþ,¦Të”*tr£ŠçÉ9¯®ÀWÅFA“¿#Wúì·©!jnÔlðk¨‘œÎW®'ÀUïlõ¼¼]¾ègæq%¥á(¹¤÷45›_£®Fã[¤|ŽÆ$掾g¼ó¸"Û¾ºú¾76¼Ó(Ñ’[úÅo«SÚ`XPY" Œ®#*ïò:‹èÍ&2Â|`tŽA7-X «ãFJ  ¾jDv¾¹›¹. Å)±Ø*,Å[ý.™I¬É£€[£ê¦ ÝC†f«w¬¬sud! ºoeºxºÛ‘Þæ*E‹yêzŒ%ûÖÜ&kût%™Èbn¸ ÀUF›žŒA¹•YÉïc0âÁw0` ¶þê®Ëþ×·l8üRµö\b"׎ÊeºšŸ6‹º´lC£†Zcõ>Ò¡‡ 8¹B<Ú¹é©flc×sË‘>/XObject<<>>>>>>endobj 5022 0 obj<>stream xÍXÛnÛF}÷W R¥Q™–%[¹}¨];u&mìÞÅŠ\I›P\eIZVƒü{ÏÌò"2ô¥oEÛ"wvgÎÌœ9ë{G4Ä¿#Oø+Zí^ï Ã!ÖßÜ‚/ŽéhH×s¬<Ç/±¼Ç/Q°Ð©v*×Ù‹ýë÷{‡CzŽyéhH£Q8ãS¬‹Yb"2i®Ý\Ešô­Z­}fÓ,WižÑ'¶‡ D¥Åܤ*!¬É½9ÿùË»ó««Ë·oè{šÃÛ£áðÛ“éþw°Olº ÓË—°,Ïõæ2ă¿:ŸÛ佺QáJåËðÔ,.ÐB;zýû—çímåQÿÆŸ=Vª‚Õ8œLžrìol®)_ªœ®þ€¯K•·¹vNÇx¬éŒ*¨}R ‹¿µ· (ß®5Í]u-rw­Jc*2¡RRëµ³kgWz…pýFÓ çÜÎ6Ó}‚»Ê[=¼œLÆ!ñBNýˆÃÏV*It–Sfþ;ÍùÉÆ$ åêƒ&¬¢µÍ23K4ݨ¤ÐÍ­Ãá(¤+³2‰rÉVL;K;†¥¯£cöõTS¤œž °3(.ÎOg—¯¹`"®óip4ÝïìG±q:ÊÍ Ê(µ¹ÄuF‘5I°‘]­ BÄkÁ‚ß„tH˦TœëúGs _¿nŸY#- õÞS)Îë6ÂÞ¿u7úöë’ÔÌ"è-’˜*á<š2ç>ÎkZÅëÃ(tCK»¡­-€Šzph`v¯Žm­£@neÅ1_TpO Ü@ûÜG¡o€zwi“ì6æJ›9¶:K¿É¹Óî6í­¤Ÿ‹+ÖsU$¨BN¹3¨úܶB¯Á”jºF%µÍ‡ÔSH?Ù¾ÑnP–®ú¯áx8”Û5Ù9§ÂíÐûœ+Íl—’mËA¼]­t3Ûø°Öh"ÏpU¹çf…æªS'­0Óu¥0OÅ´²à n–*ÃwvŒ,7iË•nQ>ÈÇaã¸ÞÀ¾U®¸ÂpòÜÜÂ_ßæ>¹˜œVs š¬c }ÑâmÊ@A;†y6Á8L1ÚÐ l–&ZJ]ãT¡d¦5øOئq³d=ŸbËuU¡×&‹ë%RÑP-Oéjž—¤ÛD {Nÿãn¶ÐFé !fþY5Ý>¹œR‘N¯H@.dÁè79”D•—¼¦¸ŒÀ®­ä Ó§Åj¦]HU€@‹¹ØH="B¨è ”©ôÜS‚!xÜùÙ•<: €|’ (+Àˆ0A0âbi!1 7·bîîƒ_Rõ«V]34N,0bŽBS¦Pö½„—#‰÷‹¬&‰Â mEÔ¼,3ü$ÕâÙÔ3BÓ'Lîø1ÝÇ—W7lÇ“KÁ¨ÕB¨ŒÈ¯ÀX&Õ»ºmGµU¶–bÔg5¸jMXí$t }Ù3}ú•P•ú¡¤•W ¾F«>$Þ'þaS¸Ül:‹ÔºÊÎÜ&‰Ýð ÷Ý”6|tjþwú—ñ­uŸäî+ZíÞ]AÏ® ~X÷¾À€‹0´Á‰àôòƒŒ ç÷%lã _½‰Ó*>°)ÔÝ‚š…PalTÃDE‘Θ<«+d3#sÛÇÈ»33¼3Òþ|R#.œ¾1¶ÀxcéfSiÝ-q¹0 ìxPO&ßÝú6Òk¶`>â†&W°´ƒayŤ ‡‹ô*{Ã=ÄŽÃs£å ðʲC”xå-ƒ°¼?}¾ H/^ÈTºó¾æw£ŸqÍùòjÖu•..çËÏI» >ËÇË“rØtšó :iž™Ää[âKOÙBMÿ]¦¢šŽÂqxô\R§!Ö Rät¢1º³ps 3mxºV ˆ“'@k(…˜‘¬d#¦ôÚ¬…gsIMÌCUßš,éTE6ÊÅ^B5®#‹+#ü÷eÇ[·Î3|ÕåyçÅN}ìŽ`šÐb\i¶X,[îd¶B&ÏÌÃ÷:ˆ®ÆÓúi®.h‡™ŠiíJ4ÒÓýG”ǧš?õ®Y5’Îj¥õ©rR¨ûþÎþ :=_¢_– JG_Z8Å1ø,ïNP8 8rqÝØ-H½"ÚY]c1QQ†0`/{ôNù:lþšà6µ‡Ú¶AiSCp·qHo!†K¢#$A#oU20=¸®2d )bFùl7m}ꓱ“„ê„0¨ïG€9‚>ºï æžËÇ8”4ñ¬ìáÑð8<ŸÐäøw¾ÓŒÂ!ýh£‚ \Êý@³û•Oýx£‰©F 'áx„¿*a«ñxÂί÷~ÝûWE®Éendstream endobj 5023 0 obj<>/XObject<<>>>>>>endobj 5024 0 obj<>stream xµXmoÔFþž_1BB8ââÜKÞÚŠ! 44¢-ª„Nª6öÞÝ{÷ð®ï!þ{Ÿ™µ’4TTDäÎÞyæí™™|ÜÑÿF49àŸ¬Üz>ݦC<ìþ«´ûâi:ÇÙƒ£#šæò~HÓ,肋tŸNm]êJã¬ßž~ØÚ}±G#à+;8³‡KÉÛ?Ï^ÒRټО.\X’U¥Î O¨¶ñó,QÖÙ«ÒÕ~¶Mú†Ø”¦K]i2žeKg2MnNjµªœÊ–m*|7vÑH>Ù=yú”ñ[',ѳ(ˆÁO^k¾†oÁU&SUZyAÊã}‚cÖƒ7¾^­\hî*æiƒC…)MhŒx¥ÖŠr““u oa¬*Š+ؼÖíõšNTJ§°¡37€ _+Ô–±‡rã¿xb›`JF…“,,5Õ^WlU®3“kÚ, Dã$¿+=â¿UeTDWÔÂÖÕ îž»ºêp \²´¹©¼€à/¹ž«ºÝaºPŽqV{Gpoâ¥pµÒ^Íu ‡V*]E äuæ`ûB[Î.¨G°W°Ndt±d ð4…ë´ã,ü@î)46è…®| »Zt!reJÏ5âÐGR8wÉi¤‚€_«Ê #o çÐÝ–m15Y“ÆM®°/a‹GD*§l·ÔÕu‘pzÆrJGtÜ¿÷jŠOÛŠ°N2^ÌûJ3ï#DWÄ(bæÈÜˉ“5ñ‚óúoÅþú1êÒQ:á"sÓÉßb Ñ':>?ÐùñËÓ7ÏFýþön: ßÏÎß¾>}#Þ?k¾ÑçŸúìˆÄIzppÈ‘œâKd"%XÅY‚L‚WÍU¦øˆâGLM¡**•EZp¥²cãÙYâµF–èµ ùà =۾ߢU}Q˜ìZQ뇓Nî'ÆÏ,‚xå Qs#æt‡xBÏÚë¯^Ÿ¥xð×B‡Y2Û<@†ø´/E}«‰H_Ž<úV9m{v5ÿƒ¬÷}Hôþv)ŸïÍä>µi[MòøXra–Ì µ˜m÷%$B¤w^Z«¢Ö³$þúêjn*N&09R´ryI¶ ?|™oLz×9™)Ë:»¤ ”ã…ðtNƒ>Ø0Ù±ô$æÒ Ô)ÅÜIˆ¢–cQ0wš1K†·î¥)é„ÄB”œÁ·Ì•+†D1©ö€f.×)ýâ6z­+ŸP½‡ñv®w¸²Ô6‡P³*çâEyÞlô5°k·6\ÜŠ›Ì÷¦m©||Ä18 ý®ïU@&&8—Á}<‰Àe"”é…mEóà°Áf´Ey·qöIè|PÖØ[Rzç™ÿ¿ÍQ¢­¯…ë£_ƒ)û­¥‹¨qÛÙr‰o¥/ÀÑEá6¬œAÚT/8¹Í8ZZ Gú ™1i„‚iü4R8ºF‡ûiïf½ 4}~ºù Õ{ÿÀû®­ uˆ¿ú÷fìaß®» ¾%çуo´4o>¥ÑCUý¼Ûˆì#¸Ÿg™”â'¤„Òì2xÀU ®BÕg™ö2a–HÛÊÕ ˜Qdq‰ºCýf…Â!ŒBq]oíª|dz˜Àƒ~íuìÙŒ(ÜXã‰v*JXrÿRÒ>iuÝrë_F1l ͨYº¯¨Æ²Û´ [Ö’t»šÜ²˜4„?ÅévŽ¥ÞL¿qË©tÁb­Av þº´nÓ4–ªÎ0šbáqÕ%CêÜ£à| |Œ£PÙ%S©(ã ‚"#/â¡Ðæ~ކ£W?ÿJ£t?¥³Àc;oBP CŒåõ£‰ϼ,˜6ÛžtTLäX‚p®‡¤ÝŒpøy_LK<²!mø K•ìh!#ó¨Z¬eîçc£‹xh—¶Ù¤å 4²¸ô@ÈøÏÌ(»©ìK1™ñµÖ÷©ß,IIé\,}¼ðôÏJ2?66+j´•[äîî’[ñŠm¶UÚÄ…;›ßdM‹^æLƈõq—ß‘[zUK¶ ×5;ûx¸—îOöéàðèzsß§CúÙe}ãM†ŠA>žÝ9Œ£ñؤ“1þ€éy29ä«§Ó­?¶þ˜‹4¼endstream endobj 5025 0 obj<>/XObject<<>>>>/Annots 2272 0 R>>endobj 5026 0 obj<>stream xÕXmoÛÈþî_1pq8'S"õbÙE>$¾8Mšær±Š©‹bM®$&$WÇ]Zq÷ßûÌðEK)n‘~(z¸ ¹ÑîÎÎëóÌò—“Æø/¤ÉœÿÄùÉ8ãþ+ä¿Þ¿< çÁÍ.΃1å4›óFÈèæÄs:_oÍs Ç‹ÞÁéôZ£ÅD´NQ6«õeÜFÁÔ[…uÃ<Øž‹FàƒžˆscØSoäµh²šæ`´8fþª'ç4™Ìaîþ¬/cõ|ÞÓìËX]œõ䜦cç^ót1 ¢ÎªÙ˜²_õeÄEç{$˜]xaˆfmò•Ýš'Bç”Uvkž˜Ó…°[óD>\ô”†Î~­«³9'´;êËœ´ˆc¿_õd¬^DœÓýª'çE³Þª/cµÎ[wÖ—± «ü@ø2VqϹw¯/#«(XߣçK¯U¤_Ê5®ÇÄaX®(Óü" æósZ&ÒPcZƃmu—¥1­ÒBegÊZz®ïu©Öš~}²üt2¦³;“Qo¯uÊá`·ùÙ›ô” ½ë~ºœâÇÓÛ'ü=ož½|ñþX“ü|:$ýEåÛL¿~û*Ÿþ±Öîvpûäo¹Yþô×åñ-òó·ZüîÕ››·_³¹Yø/ô}<6 Ê>öýç_wÿoAJ’Ô¥†sk«íÖ”Žrí6&±dòÔ9ÐÊ”tWêûÔ=Žü½—«ßX]O—\Cg(¢³ˆ+E4¸Ñšd{¢QwƒåÃV[µÒ¤‹*¯ëJÛþÞ¶Fä Y¨rÝYu`m@oãÊÉ6Ñš:Ó.uR¥UYúO]Òí@Jãö ¥Ö[HZ×".g9ÈWŠ®{•U¸ýΩ´@PîSEŠPd«, èOfÇM1$eÛMñ›ÊÊq ŠM¦(œRe¡l%¦Ö{Iß}R÷JvÖ mh¹ÍÄ®$-uìÒ{ÍÆ[Wšb=~3y®‹Æ!\ñFhP·Áž;½Q÷©©ÊËöª}ÇŸEQ0™ ÿ“ÁwigU¢é”vM~»[ŸÒhDfÛÔ >m$úM@ãÑÒÛ¥YFk]¨œþ÷Ž÷Pëw€páø0Žÿy·XÖäúØÝÿv-Ñùmýpë¢1ÐKZÙ‚+µJ¤«sƒò׫U§ºp Š\ °hÛÏ¡ß u| ïcÇ3`z ÷Å °Àx۵ö™¤õyOÓd|¤mç#丠DêÕ>lXa`úâŠÎª 8¶i¦yÃk`øê!Zêø®|oÀR}:Œ:èúCSöÖÀµ3[ŽÊ@ j.W*F$«j L˜3fw A71òâà‰"Ø)mK“TP Yã56 3ngŠï]çuÈ,Åñ€8ç}<8–Ýꎢ»w)Ù¨ÌànvNh1}¶ZgæNe=QEðp_€ˆŠáª‘ÉÆü„ìàSmUü™‡2QÎV6-Ö]ýðCÓ¨á®æ ’¥ïpWÏ‚£{›a®žÓ°úS¸<Å@ÄÿËCMêA£7š2ÇôXßxI˜#-1ˆÜƒa?öF¬§mº•ŠXë’©ºÍ´†zĹ 1—â>ƹb½†aæ¡“YŠ 3* ( k$©‡Ü‹¢ŸûÅ»Â"rñœ‹ˆƒj]ÍêV—2Wˆ&n6¬­t@ï2à…¦Ì˜ÏÔTúÊd™Ù!3½x—z ‹Þsµ¬ª’M†¿rQ|Iç¶—£­Šm;JùÌlu9zŽ;ìÈnÒ•ãRá]£-—g(5B뺲äêã‘ì}½‡^pùõÌ“Q芫îñ--øÈèzÞ2ôbµj)Šw¥Y—*Ïß÷Ì=à®æÚ¹©PÎúÎbn>67^w1è±#BíÞTÅåÁ7õÝÛO‘¼öÁ”`»ÄË${ü±w™n{A'“Kú ƒ=›ë¯Î­<ôõ­‘O<ÿ¶WPE—xíÐVuÿô´³›\£}E_sË¥[Ûï·þPlÐa_å¿T˜!ëɾî³Þ…Y• +ºr]¢¯QkµRJ ™¨xüÁ­ªŒ’ªD~%›Ø™šþH-Š«ù„Ê@û¹1Ú7L¯UüÀø^ƒ:£Ї.¨Ú¢zQnèõÆ×žÁ¦ 倹ûÈ4|…T7íÛËdÃÃC™ÔMåØx  OÉl»7=k “HM ]ïâ5‚ eh¼2{t{ ÜØ# ]_4mÁï#ÂhL‚žÞè‹~PÙÖ}wtŽö¡W¤A‹hùšò„•Û考ä ¶ˆŽr!OÂ¢Ìø(ª;¾´¶Œ0`xž_ŽÃÏIèůFï;@ ¢`Ó5¿Š:o¨GÝ`²à¦öP–)þÎà9Ö•7 TÝc°AÕM›>VoL÷)Êš¬âHêïS~÷˜Œ©üÐJŒ >5Ù-7§“€^1ô0h71ÂŽTÒOèjÔ²'‡nWb~½{¨çžn ^æ ^k y_3¬ [ÚR¯#(±÷Þ¥ ¡N,Brh 3~ÝÙ-Jï=pV¦d•­Bß (·Djæ¡=KÆ•uxÐó*·zïþæ½Ð͇W/É©Ï ¡ŽëG*œ_v+X„c6K3fNT‡„›f©>sˆ!ù¾Ÿ»)9[ÐÇJ¤\¶ÆZ)JO[;6‰týTµõU¦Å~¶=ßBaýl~£Ý÷€¸‡Q¡edPuCúM›ú_Ã}×¶-ñ÷Ì]4P§Ál2£ùB‡Ó{áÓë&y‚ ¸}Ø |µ©wž×_òlÂ›ãˆæfø<‰ðÓÜd²àã/–'?Ÿü ùÍendstream endobj 5027 0 obj<>/XObject<<>>>>/Annots 2278 0 R>>endobj 5028 0 obj<>stream x­XÛnÛF}÷W U›EI¶[ø!'uj¤i¬¢@ê>¬Ä•Ä„ä*\RŽZäß{fvI‘²§@AÎr¹Ã™3—s¨Ï!õñ/¤hÌŸYvÐú¸Â_!½}Žƒ3}Êhc¿Héú µÌh57ò^k™Ñéiç\k™QžvO†¼Ã¡ô)5æñÌIQ\l¾DÚ4z4QR{“|–V±¦}O«aÁäÅÝùÒ%:Áa˾·$£ú<ì’#Tª)”ÿóáܯ諘ÚÖä½Ý&iÚ4ëìRW´‚ñRÀUŸ+¸­O`ˆ:÷ú²EÁ²çtNýnx÷ß.1â@øÝ' œp'ŸRø½ªñ:wpÒ;úôºü¶¸x&LÅ­*,µb‰‚O7R¯[R¼ÃÓírÄryk1¶ëI£oY!fm\A»¯¸Î1R¤Ág&Æ8høS-вhì:£ÂhÆ692ÝÅÂHê~~ÛK” ­A·É°ÿß Rü¾Ã G<À“ÍìßO<0:¿-‹©™b0s·bZC×´H0gÈ<Þ¬EÜç[è)Ö-´Wjö‰'äÆTb§²I¾Ã܇ZÄ* F”l¹–ÜûÜ‼Üã —!DוÂ|Ù8zéj­¬ò4ÁtìLqÐC—ð ý¹‚¢±<š ÌSC™±¥ãŠ“ùóÁnÀ _¤Dˆ—€÷ªÇi“%$1;_­…°ƒ-ù þœËë„…ðzóò¼ÁŽ˜b2ƒ<­Pñó*}€îGäô…Ë£´ª Ó «64€;“T +±íªo èbG |Xš=Hþ­¶…qÛe8/\)²,»SŽßP $“ª-µŠé¡ÚæØD7´œìF1W3̘gʽXžmRÂ;å+šÆ’B<yd[ž»ùºY#Y—†ìÖeJOKQ¬p»â#ɹô]ؾwØñ]"&àr¹[ŬIPª¢Ëáƒä­)~ø¶ÇD¡‹]”40ù&ã—6ÙïôV=Ñxõa;<й*1šùÍRî¾3Êzûl6w5¯›î]R1+¤FQpŽY Š“5L£}|Œvï P L“”ß ¹õ½TØRÎõ—¯BèâA(“]«"Mf›…–m)YPÃJƜွ0vNïkÀÒ\‰™¡¦ 2)á·Œæ Â…ÖfTEãzEæÀ ½U~)`RÜFX¿ÝBFÞ‰ï1«‡êÔC5èƒQ4¢ñø”圠1À¯8/Í zÞÃÏ@¹;NÜÏ'þe"¢w»/_|û¨?¢~†ƒÑ(:ãK“ƒßþ£0÷Ÿendstream endobj 5029 0 obj<>/XObject<<>>>>>>endobj 5030 0 obj<>stream x•WkoÛ6ýž_q ˜“ØJb§nöÚ¬YSô5Ôk1À@AK”ÍV"5’Šë ûï;—¤œÈM -ÚD"ïóœs¯þÚ;¥ü9¥É”ÿæõÞ³ÙÞIv‚‡Ûì’Ž/¿§Ó1ÍJœžŸÓ¬ïOh–ÆgÙ$›Ò;£´—ÖÌ>ï_žÑ)^òñÞŸáÂàâøâ舚tŒ„•T¶Uµ!×6±^´ØÐûW¿etÙZ¿’¶6VÃ#Z GÚPcÍ¢’5­ý¢ô’ÖʯHéÜÔM%½$¿i$~/­…WFg‚àà‹Á §Ê‘ +Ø>9Å÷p‘—"—?ÄèOè<›pøcŽœM&ø­<ªMÑâ¸ü*øZ23xwyõê9–¦‘z>Èvžò•°x¤*©E[ó¹ÞRyïTîÀ½…¹¸%òåp‚”ÚÍHuP,b5»(æƒÊèe|Ô!@B”[ã\´øæŠ¦Õ…°ZɪØ î€Èé-”'ÝÖ i3z-ô† C´CHÀ/ב*¡—­XÊž Mš$XP0'L&¦Å˜·x•Ñl%Ñb—[Õx>Û‹V8óàöګ:Ñ)_ÉüËN$ àZå‘sá[OafC…_}Gn|Ü= ¾ ТnÀd}¥ÉØ´1k JÜyÓ”½ÂlU…õ5å cܽ„yÖÑq>t1¯„sÁ1§ž6˜ëȃ.G"îöy[h·udIăÓ$…ƒP¨^Ø1.K!Œ]³¹¨*@.>†D=ìPiçR'wã ¸ou.É,¼Pš /b§:§fñYæP)@ PZ)¡Å ê§Â2R¹…*K¨&úpqKüJx”«a8de.JSÉjÀ ð½lY›Éh¸âF-ƒ !„ï<D@ûepˆÐ¹']qoÉÎÛ˜i­ƒ¤†8”ãëu›¯ú (äm5>\×Ö~mžºxpe!¬Õr幘%—‹ÓÿUÉ邸U+Qäë‘Á6¦!‚G 1¹x~þ•qNXó0 Ezµ©ÌR¡áTKÌ<¸, ‹{•Ñ i« ×+Ö÷¶§ á׬*…Äô‰U ºÍmYl¼f I*áyLÒ| 2™ {á,ÔrĦÐÐkð£RÞW2=™@Ÿ æÛ˯1JA¯É8ˆæJ…$âÜphØÐK¨d bÕ↨ðEN”Î\ºÒÒK®­< Ð hKp&wg“}“1ÌöÕš!´Bo“°@eQ Ô˜¿I±9°ˆÇ|? FReÖý;½pp¿WêLdôŒûàÔøã,b€ …“@¥9[ ݂ް˲@‡i+ב©«ÖqË¢Vá(Ìa$[a!®m%*0$ø à;T?kýìŒÍñqÄÚWh1¿dk «£í¸È(ÖéµUl°Wg€pÌ·ïo¯ÎKQüá‘ÒLDzôOg>,ILJt1r~ƒ}%„zxÜ{ýŒW®Kcf?a/2Øü€úFˆ3¬4à7p¢ì/cÿ&³q»c¯GGø Ž`jfðS2ºxÀošŸ8‡Ÿpåð—ùçŠ!¸¸Ò¹ ÂoåpîrÔeX©»­ò@ÁN½w3z ÆÂIÙ_¸Q‹¸?º•i±Éˆ ›!æ>4î–HÆ1Cí¦[€Û­‘ƒç-ËD˜Ù½wÝ ûOý35N`™ZãI.€o+Á üeÊï4+Häöâ›?^½Ú2©ñÌŒk|¼`ååˆq•‚Y e&ÇíO Ñxʵ _>Oè½·m4Éû¿}Éxô‚à(Iº‚•èm(7«Iü¾YJÏ_VAž\ú™0‘ópá’s ØÁQ«xß©5×ñøòž›}ÀXƒÙo¸º&\Ëâõu¸þ½¨ðëñåyÚQNÏÏ²Ç“ÇøP<ÍNã—o-£qvB¿š¼å­.L Ž Ÿ(ñôèI䟓O¦$>àurvÂמÏö~ßûCK¤Âendstream endobj 5031 0 obj<>/XObject<<>>>>/Annots 2281 0 R>>endobj 5032 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ö`Œïé—&ÀhR±ŽcF»ƒ÷ñ7žúÿ†îëÏ™¿¯‡32Æ(>&Ó|µ8ûýì?BkÁóendstream endobj 5033 0 obj<>/XObject<<>>>>>>endobj 5034 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ºÕ“ùè:…1FaS”÷Aî.A×U%µ³á²ÇBk¼@¥PKnµ—ºë6š…("¡@¦C$8ÄæÙJ’é_Û¨Dƒ€…!Ò–xÔZ¿A)v€¿WÞêe¿'js€ˆ­…™wÏ¿Ûä»Òf…˜kq9¬s?¬2ÓÀ¡’¸Ø—¥Ä^ ò#XÌ0‚]„a²RgÉ …ÑÎ`‰”~ˆoÍ [ž×¸†µ(…âF$\÷ËD<ƒÀSÊ.ˆ³_¢ñïéTýM.à#5Ú•ÁŤ_Þ@/w"浕Šè8jèiºµMX…× Ù&9ż„B&YJ=l©¥¤¼L@l…: &Ê5ì¤ú¢ás­ X¥ÐÒ¬sí+†–±š"ä±çE•?‡§äô(#¦…y»òB±3÷®êˆ¥Œ/UÏHÐ2Úÿê-Ù÷£7ÈÇ${Æaì6ùX ¨‚.ýdþ¨ó֯׭ƒ) Ù-Ü¿zq‹äù)›gGàJÀNñªrû›oy»žÔ·ynIÇ °D_B–ÚÝð­s²ƒ_ºlǃïÈ϶"xÈp_¿ö©ê(Ïb«åŽX°ÀÎÓG÷ÿ§çÐÌ-¸Š7+/Þàô¸ÈŒ(†S`+³„L)Æù!P‰BnÅÓ@§ÐÊ£*ÊÓœ¶¸\”k³é;òƒ¹õ ™-3X5ØÝyæµdçèÏó–³–‰osñbXùÑã…‘µy ðÀ×BF‘«i+°œfõÊ †yˆGO z°duýÝ©~OB‡„ÞB8PPÏîìBA#eÝ@-x‰ƒ”4}îÅá¤Y£ÆÀca¸Éb'è^ĺԵªT¦±üЃi·ÄšAÊøh£§Ç´óÅ¢âų|Ñf³*N¥ì:òH‹!V#®~JqK:}ú ÑDv³˜—ØœrÝõpM—·Í;BàOÙux ³ßMœÅ§wæÃ2® œüȳ,‰{<\v|ãÞVÎϱkÆÂß½p|…Ó€Vþ¹ý3úT²­;endstream endobj 5035 0 obj<>/XObject<<>>>>>>endobj 5036 0 obj<>stream xVMsÛ6½ëWì)C'õ-Ûéô§U'9¤i­iU JHH‚@ËšNÿ{ß‚$,É–Ûã‘Hìûö½·ø§7¢!~G4™ó_Rôn—½a<ÄÃðÏlh°Òu<¡eFã!ÍoFñ|~EËÔ¯Ò2‰î*Qę֫huñÃÅòKoHýÞ¤‘*­…¡ɯÙHw+LX6XÜÐh̉ûÈÜÏÚÌÑxOâzÿæ ©r+r¢L$g,¦Ä©3¼eSÞåîÏ¿²”Õy¾'±F’ÎðÄÖÒ’‘¹p2%§OÆ´Dr™i#/Ie´×5mޤ$Ö"4W_%¹­²ÍÖ‡8ôÇãx2*iäWÓBkú÷¨ø8޾ÿ×aƒbCð ·TÕë\%ßã…¸IœÛjûx|ÆagDU¡ztB“ ­’F˜d»g€>Š{ju[á€U–ËÄ¡fIVò~²ÎÔ‰«|û"\Ñ/去HñžÑ¥KÖ1á¿N„Uw{ëdëÚÅ•Áéór%¼þ®®¤ñ˜s?ù„“òç–}gÑÙ©<çº]À”*[åbÿr5hkSmǻĵX¦x¡¬.§tù½,º×*% %­"¦Òëì[Õ`ÛÒ7Ê·±ÛŽºÞ4*‰šŒ«‹ã""I"+gÑ`ëÅe˜“Ø'µG¤Íq„(Á$€*£öM)D{ÚeFßNÛédìåüI;Vèè+K5”XjG¶®*muîT•ŸìÆYž}§œØN"®É·ÑªÜ°-ì´ùÓ;‚q”xÄ(0 áLp0KTRÒŽá~>½¥T:ÈõŠ2%]Â…XA™2–ý¯“$o\[™úrÍlÎ{yÛCß>ã`N{Éz„AÁûðY#öÖïP±€Ö{ºy}Þ?”lx—|›AÁ¥*óIêå|°Í†©T¨Í–= ‘¨Øo„UÕ쟤×_P¢aR†äƒ(З¥=j)ýJ“ÿ ès[CÕÛî­1DŽ›ÈWÏFpž4±¡t°k@.øMØsÚÆýõww\ĽcðY"- RÎx€gævÈ{º1E„ÊAØŽS-âaÀôû¶’‰ÊT"0úH?ȘMG*õÞ'щehl©©Å‘©m:@<ƒLˆ¸•‰¹k—äGg]bcˆ [7o$–¸}…GNÃ_YÞ­†šqb¼Ž*tG T`Fp¥º[ÏÏ '±Ö VÇ8@9V=»”ËÈY”©öGl„á|™lì™Y;uðÙÏ⎿7’é+x¸v¸x’µŽÙ!ÁPö[p¿Â Z ž 1~ï”z6|<ùƒÕÛY_s_:<xx¼¾áà*‘Ìe!Kwêê'£éN*ça,q©QP­N >Â}"Ç /9Ötè#·/4êñ*tÉß îB܆׌èìéDçw¯øÝüùw~ú]…wƒÅu{Õ]OãÙdFóÙU>/XObject<<>>>>>>endobj 5038 0 obj<>stream x•VÛrÛ6}×Wìd¦©ÜX´DÊrÒN7®Óɤ»ÍtF/ ŠˆI‚HÉj§ÿÞ³I™ªåI}M‹³»gÏîçÑŒ¦øžQ´àŸ¸½¹Mƒ)^ö̚ήæ4›Òmн‹WxHÜ:âqÉ’DžS))mʸVº´´UxidݬS¥UYKCµ&« I'·ŸFgW¸Ú™_iíßtI¯>ɸèF•±„uþU&éo åØV¢¸Xž´·X\³y#O©”Û|Ǩt,j™°é)Mf! Yh³#e©±2a@™Îñ‰ Œ´M^“(“ˆ±Ñ{ÍËñOb#:×r)¬Ce©5ºå`xKì7Nx/¾¶”ªRäê/„@ÙÓ”´Ú¹SkaVb-)ÖyßµYž>,¯úøOÂ9{΃(˜Mƒ}hç6¼ÎòÃlµ»?js§Ê5€×•pàÆ. ×ä|ó÷õ‰áÍþÕ>3±béÃÇË ¼ˆAé„ä}윌Êèûʰ–4R¿«äÖˆªÂn÷ÒùÖçåZoÙÐ)©šA•º†WÖªUŽkªØŠƒŽ.Ï._¼è™`–ÓºMÇ”^×CøaDþKÆò^U.æål9f´Ë“ïˆèìŒZK4!}×]Õ48ú­ÃŒcÁ9j(:0ô×Åÿ52?0òÚ±ëØÓl⢋Å;t…x{Êô,rñïö4â2{dßü?ûVzãàK Š\‚F”6çò'H?üþþ}W)”%sŠË«\´CVt›IÆÒ34Ö%Š’¹Õ¤ã¸1öÔsOáá¡yÐßó„o™‡Î:½h@BYNzñI.àÅJoúqc}ž„‹½>̈ëá3¹ "ÑËóð^>6œ°;pÚÖ7åÄ!¶6 ‹”÷µÐ¶†æÚ¦ª´á £än>¾û1 æC[(n_z™à”nõåênnȽý¶ Ù£õöU¡“òÐZç½ì‰+«VpWëåÙG¶‹Üo’ñ~1΄¡oâvÃQNÿ ™`ÙCË`ª ”—K| B$„Zg58µhQ…(KižÆÞi…ƒy™€R¸/ÈÅùøàÔ³k‰÷¬;Ûê]ò±ë î JoT¡raòÝ0'¢ÕkÎ<¯½•#ŠçÅÝ›þଚU®b.tv ;—ãÃlô ŽT¼‡ž?¶'úŽá þã’z4g,휳­QµôÙŠu"ÑœkO'ˆa¤ô=Ï=l—üA¨/„¶ ùØ7pÏ­žK»ùsºÚQúdj~në•¥©­§®#~nØq"—÷®5âDÕbRÂ`U«Br?D«sä›rÛ!¹9$Ü[eE±RëÆyÑÁbçŒ–Ðæ1-1H]B#¡'ÜÈÁñªb€Úk+ë(*ÑɯÊþé@»bäq¼TýjSZµæ¡Êf˜–!GÓÍ!Xi <§YÃóìA‡ÞÁƶ€Ü)Œ1B;iùR¦öV“Õ!y÷rÃëÏ»õ£Ð1Ÿ$¥e„¥mgœt âîƒ J`NŽ.å)9!È¿å!²¯àûËv„ §óà<:§ÅE«øÌŠILé7…,kw+Ó’á÷N.| ·Sg7Ì ôS÷ž8t‰ŸÖºŒMOA¢?A}£¹ëñooG¿ŽþÉfÄ¥endstream endobj 5039 0 obj<>/XObject<<>>>>/Annots 2284 0 R>>endobj 5040 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 2287 0 R>>endobj 5042 0 obj<>stream x•WýÓFýýþŠ‘*H9“ØI8RŠÄwAâ£õŠtÒiÏÞ$ËÙ^wm'DýÛûf×ëĹ@uÀ‰½;;óæÍ›Ù¿OF4ÄßESþg'Ã`ˆ'ükÄ¿>½> 'Ó`J“á$RFáYœ5ßRú|²ÿ=£h4F{o£QŒ)|Ù½Q4 ÂæïÝÿ޽“0˜ì¿ÝûŽ·°á-ñÞgó=W­¿fI^ é,ˆh¾ pHÓG£`:}HóÄ4¤yÜOt}•JÚÒo´–²úrÑ¿¸÷ë½ùד¯Æ4šbïi5{ûo´Õµ¡Â襭DI™6’ª•ÈIç’r‘ɲ±Øë|‘ª¸*颯$òíÅ=бøJ’‘¥N×2¡ºTù’ÜÉ۞ܿc$ëúÓ§WÚü&²"•3¿cçiQ„¨¿ÿ¢ÿL˜K¸”á`|œÍø³ “CÃYI¿uÖ5ýÃfñŽýHú„?*¯ÈZðµo¿7kíà ÛÛùØöZþn ›pnh#àl¥éZÊi‘ÊP¹Í®tZR) aD…Ô +¥J¤¡EÁàceFȦ_CŸÏß¼ö@„ D¦“:•e@/E¼²¯á ?òé,R¤=a°4‰!áZ,eà‘³±ùJR"¢N+0)¦U"ËØ¨+W±6¸r:€ŽCôÄg¥d€8_\ñ˜¹Ç?«: ¥ìEŸ™ía @CÙË?©eŽñ$AëçáTi”Ò)ƒüVh.FW]¶ÞXvÛFfKÓv¯½<ˆ gw¼a?z_se«¬¡jµ.–™ð‚Ï8¶ÜöÈÙþû!¯¬÷’ÚíŸ(“nÀÛM u#.׉¡(§§p„»NÁxˆkBÛŒZ3œèŒ£fy'b)-ŒÆÕ^Ao–h.3ÂÖ$£¶“ Úy©®Tªªm{¡mäÜù\ÆÉœ]G‰VŸQðÏ?V‡¢D™·ç üèxé§â­dŒZì±?½C°Š]á#%³âòíÓ?Ÿ>ûðâËåÇOþúâœÙñ3±ÑPmùÃÉÄ´-}&^& 7P´÷‹Ýtâl?"Vã®#§á”ç¥pDÁhl‹Jbø…:[»úåµcÜ °šG‰vU£¥’ÎMFЪ^"ÅF£ 3 <‡ÐïzƒB6KÃÃ!à‰ †)Ù´ƒqˆGL+xYI”­šver×pŒ›¬l—«T\c`jÃYe…U î¥ÐJ o‘՜Ĭfž;TÚôßñÁf"Q©UkÜâžÐL±M7ðXm¾Ó½ ü¢ò8­!àëÊòöIwu÷6à|ì d>BÓäñ’æawŸc:гz÷@Ü=˜0à.ÍG´P¦¬.ù¿¾´W”vUˆÁÅ“_æÜØ?÷ûn¼a¯Ú‹a{ïcî…-T8w×]**w·¹Eî-þ÷¸•ïþ4w}jÓzÑçõJA¶ùÃchÂ?Oìòã;VngÓóÏšY.ŽƒI4¡éYSLØÓ—ð:Æx›W–{œHØskO:`]ÕEÝqÞ–Ýd8 ¢õ‰j‹ÆSÞýr~òÇÉRþŒendstream endobj 5043 0 obj<>/XObject<<>>>>/Annots 2289 0 R>>endobj 5044 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ÄŸûÃdœóAt+è“‚ÚùèPCÀÃdÈ.W¥Ú!æB¼Jg—Nåþ„L`$R›ç‰Zª¼¦4SÞkÏ(Z©µFŠºˆèè9Ͷäm7UY†‡c/”»’cz¯ íðQ6R“˜)Ö6[ËÑZ®² Rßñ—‹ãµ†ÁÎu¼àÉd‹uíØÇëº\õvÆÊÌWÔ{¿ìs´Ûï'ƒ;ïÔ%¯œ^Ĥ#œŸ‚£ÿØã~Q’H9ö_MéY;˜6©ïqúÖ÷€£Ó•.P‘mmqW»°š¬NÍ*&siíAøe5ËL*ˆìÇO`l »¢ŽïgÊ5mÕx}ã»ì µè@ ŒÔZúƒ)«<ú%Ëìæ'5j£¯‘Ð…L‘·N£Mñ(ßÓSŠïæ d®Ñ°tÓ)lˆ½ÙÑÄ~XÁ²{q‡12x…ƒîýƒÓq×Ë—w-.0f[?Ý‹¢CïÚß/¸•¦Š­ùA­Õ yæþ]‘aöÊИÙ*À(Ž–½V¨j_ÒÙ‘†g ;én¦×:;ì$$wèig_t0äÚÈW˜tÌESø Š`~t¨›‘±•‰õP$•çqÚvê<©»ïðvP¿Ð©ö^¹mì]=uoæ'¹W™®ùÔ‹ÞÜ}Ó©cf>=m:_ØÖn‰qdýG»AÛÖåÒn‹ „¼±A˜ÿ_*,¶ãu_Od/"á{½sxß°³ÓóøíîÆoÝ-ÊÄëðÖ.–é!Q÷žkÎ>@öä!®ËµóÏgC„Jc}`㨔+.LÅÕ.Û2tuFN‡ÊqëШ={àRð:[4ÝÄ{ힺ½Åzq{{ß.ÉuXÙ¹±FTȾ+Ë㵫h!*¥uÇa €ÜgIÑÓ^öìü,f„í/;¼V4“¤'2‹UÀ.+‡¬\£Gx‰£å—²ƒ`ã‘R/ô6Dh1™ì仕N‹J"h¬`,–‘¢•Y®vãcm â°±åÌF+m0Ïá豫5ÀzC_õ–Ei ¼b{ÑO=ä† \•¢¸º-xjÕDaþˆ_¬¿Ü ér‡ówEfܶ¬ÍÜ÷pEÍeéx*ÅùxÚˆö+,"¶wB„¯hÐj6¼”yʲvk3gC⾦B!d•AEò­^-t„Cô×B¥QPË·§¼ëR;×"úJ3bcÂJJT'Ã:,Æ+§æf™·ƒøÝn¸[¸E•ÏPjú}¢×:tÃ’Öæ&H $ò] ÷3˜9£dq^]JÞ˜±òû¨ò¨â¨[¬‡D$;ÇfbuØÑ+¦`íGѶŠ!žL‘ö¢Â)ŒÊX†h—ë¹Áܧ¯¢c¦…üŽ‘½“ ì÷†ÉùàœFcH|á0¯Ên¿ûüfÓŠ•£”œ½ ³¢qwå\ÐC‘Âõ.ž÷FÉ ¥ ‰8ŽÙùÝô诣ÿU ìœendstream endobj 5045 0 obj<>/XObject<<>>>>/Annots 2295 0 R>>endobj 5046 0 obj<>stream xÅXmÚFþίåK}ðaת•Òkˆ.Šú’ µÐb¯a‰í%öšƒVùïÙÅÆæ wm•Cpã}vö™—åSÇ>þ9à é$¾ÝÇ'ôáÐÇû7×·}]{ ø¾í„>tjbãacÌéû8¥œèx¾íÕfÖåßmέÉ8:Ú£úܱkß‚ß×¹ý!k,ª‰ ¸Þm?Ž œRÄ1Œ Ç±£ˆc·»_;Š xî ¾ž7ðJUÙRqìÖ/iìÇijÍw¶„›É-8.L#ôÉp<†i¨]чi`á²Û銃HÏ –íáíÏ÷Ä,ϯ¦ëÎÍdª@f „uŸ‚ÂY4~â]\Òzñá÷û7°`¹òMÒ, X^žO w/_žVlƒFç]¹b"ÎAFˇ^Ì·<†\eE ŠŒë•ôvà!c›H—ÀðqÈó  Ú0•ÚJèS¡•IÂ2ñ'ÇMÊœÃq%Á^°b[„…e,,†¨H%dZ[(i²80؇1:)t‰C×ö<”BË5‘þ*×G¢CkS,b|ÛxôB/Áî»öçù†%3‹4Ò"é¢^C$å쪩ÿ¹)n¥/—3KOVb“¦ßÓf{öp8"óÐó)h«Œ¥y$³$×á`öƒ&H$'çªéM&2¦ý€®CæW nžç Ѥl; 9øuEû·9Uc*!;š†ÇitÑRí!@{ Vzu¼évélØO©·4±†Ç5^7ÒCË+éDU‡ðîÁÝ 5 :#p:бߨâ”rXJØ †1_‚ÚðŠðJ‘N{<öñª½Wœ§åi LCÆâpÀĬ3‹S÷ Q&u»lÒNOmÞÂ鞆m÷novÅõMåx—«îiÝs—4µßð²‘ãÒ]/‘a㫼n¶š  5Sù€—,M|ƒŒöºa“ÎÍd|¸½ºýí{ø³Ã¨oî°Ô$ô\¼”ÿ$ƒ"Á ë”Ô,ã}ÇèöF¦õyÖEÙ§_ \¼%c¯ä Æ´úëiç·Îßþ¦Æ¤endstream endobj 5047 0 obj<>/XObject<<>>>>/Annots 2297 0 R>>endobj 5048 0 obj<>stream xXmo7þî_10`œŠØk½ËºC>\Ó&HÑmãâp¨‹µKI´w—ê.×¶Pô¿÷’ûjÊM/ -É™yfæ™á¬~;›Ð'4[ò¿8;Gc¬ðÇ„?~úp6¹YDZN×ј2šNÑÊ?¥ôé¬ûŒÝÅ:ºéîvž3š'½Ýî3v¡yÝ‘í>cwµˆ–ÝÝÎsFsh^tv»ÏØMz˜[í·bÇãÔ >×S˜f!iËÑ ùt \¼4YÔëkv$´Ñ ô9ka>G³ÖÄIU ˜›tDÊN™·ëã@‡ül´!?lD¦¨€*ïG`§#2PvÊ<¯Ï€(èGh£ùa1 L[P!UÎÐNGd ì”y»¾Z•|Ì­@À‡i`Ú ¨ò~v:"e§ÌÛõe]2ƒú˜6ZÓÀ´PåýìtDÊN™·ëózH(V ä‡Å40í@Ty?;‘²SæíúlzÂÀF+òÃb˜v ª¼ŽÈ@Ù—·g×ïç4Óí÷Ðr/ r0ÆÕsþ«+ÊÄ‘rmT,Éì…¡OÿùøªR–$èñ((ÕùŽžö²²ÀâA«Üà›.(NEY’ÞÜËØP.eR’Ñ´‘PZ”{‘¦2!‡Ì^ZuWï®ß½yóÅíýÙ˜®&SÀmt•'¢8Ft»W0{8ZÄ{J¥p 3•«L¤ôÍ÷)Ö‰…ýL<å86Ò0¢ƒ,𔉾ˆ²=®òG>ZRmHo©4…Êw=S‡*Fé}ª2µÛøc`Ù‰ ôn$‚ÆB²‡#‡õGdRB[Bl}J%D"²Ä±ºazõ>åH#× v‡}‰÷"ßÙ¶Ð '¹Uj.! ¢¨’¿€b Õk©ÁU…. ÁTË–K[›ëc‰*@dæª0(ëMø\K¢Ñ}®¬ûlÂmÕ=qÄD·Cø4b¿W  @©òŸµŠ “ âLÄX6›á)]xÌw=ÕoÏÙÀùÝÞ¥—殬šY´\®XÍÇíéK‹ÃTrÜQ†50W #‡$$!Gºø$wÔs7=Ÿ¯UŸFðÍä –A×ï×mE»úÀ˜>&xõ¹=M¤C!v™°õÖ–=g¢©°×h„JÑ_zÅÁéfþzÝ—Æ0 ¸Ñâ2§GôÒµÆÈü1{Ï01|!¡åxŠ,¼cxCšÝÚÂþìþ`Ás4ø‚žcåœ%˸Pî ý@]ùSWóÆ+[n5o7¢´¼íêùk¢f†„cÁV^ÑíKog ó×o¸o¹Û–j*ì”ð×––hÛ/¼°%.ª­Bß|gûS³Û#ñî™ãës| [ÆÐ0´7¸® ,Á•¾Áµ‡fÅ·öÿmNe]˜ÖCŸùÆâ%(Xa::XÆsTÆw “Âh‚œáÞBw´ïÞÐ'RÌ3RÍ©W²m)²E_ {ê *%ßÓ<4']ü¤õW1™E³›’?«‹à¶)!fîë™W¬ËVµ½—7£<éˆAõIWiBòù€nÿzwþ…êÂñ™ðEL¿2 x¤°oõ™ÙœnÔØž)Ÿ n¤’Z1.ËæpO5}ö L]º;Š›ØãÞ·M„~¥ß{Z6ªõ©Þ™(òsläÞPWNô$þà§¶Ñn+N¥;POgÍíÇ ú²£9:æo•ÂŒ¶»­R[È<b¦À8ð]Å´Iuü`7S-ì.Ó/ܽSµ)x`º¦äˆ\àxªò‡f­¢vþP$Ms4x\Ò^?y(K”wÄN~뼺ËgÁ4Àäð¯ÚËPøƒbað¶s7ú9/ªÝ¢ùÃ×EÖ!2dÉÛ‘Ea¨ËMšÃÎ÷n¦·”©cºÅ‰£ß1¦ˆîîòszÃz_biàËgeîF“ÐË¡¦Æ€¿çÑÅësW&¿!¤)¼ß‘Ä»æ?G®†wççn¡ãŠÁ™‹ßihmÄóS"S•EÑ{Ž  þ%Þ7Í?ê©è•æïGtŽØ}UÚ÷z°­]µ,ôëÂÿÈCµ›ìý44¦ð\yŠ~|96wãÛsÛ°| ð»)Ȳ¥ÉÍM¿Ò.ñ3êrÍ—8¿Ë_Mñ›ÞW:®øNAþÝØÒv§¯V®þÍil1^F³©fó5;þõíÙg¬åwƒendstream endobj 5049 0 obj<>/XObject<<>>>>/Annots 2303 0 R>>endobj 5050 0 obj<>stream x¥XMoÛF½ëWÌQFlšú¶[ôÐ8umÓÆ@u+j%1&¹,—´"ýï}3»)ŠrR4 l‘³óõæÍì( Fâïˆ&sþ¥ƒ0ñæð£ØðMnfÁœnÇø7ThZóIš,Â`&¯F³úýíŸú±!§ ØÏ¤qqÖÔt1¦½NZ*cçÜËûÙ ö8µn=‚F¡/A¤ãÚÕcÊçÑ#i©tŒs/ï§á™B gœm8«)1;J Nh]eQ›ÌÈõ=ŠŽH¨«ñœCOƒ)úñ½WÏŠS¨®ÀáTl¯ø0+1¨›Ä,UË©lEϪˆ®.°½¶î7©<ת¨Ño; èÞ€· ýE¥y¢/9 \§ÈüseK2®VŸÆw.¤n@¤1æ<@œ žVC¨+¥·F×`^ ©†Ý–ªúÏ&^‘Þl‡÷ÆP´sûxq¢Cul`JPŸã݇²xDYEí²Öÿ¾ãòŸ£gyj({%9L‚ù|Ár!Úð0 ™fŠ0SÝ8™![E[ Å…‡DÕ5Ç¥–Öh!½ó2œ‚v^•(H]p‡©ÏtÓpPè:XaìFgºP%8 ³º°…’ÃIÊeB³8*û³ÚrzzZÖYe*Em]v ‹_.±¯ª+B¦w y>^<^è/šqÊ ZY“Ñ´C›vÂós ak ÷Ö×`œ1ó7å®ô™•ûüÏh«£'èCÀè+4¬É`O ýõ=F¸º&¦¤{S·à§3F:GÅ€³TPwÕ@ЮZ]²KÚqo1Y²}W/1Ù‰âÿôç }D©þÑÛÌ'ÉûZF›O¸ƒz'¦ Ú¤Êç{P>i&ŸN©âÄ à¶0Õ†{Hó åéî-^8Ê|MU†>¨§ý™ $D¯~ÒH6NãD(37Ú ­Ã­¯«#W;µ—^¤È0›JLóíµ6 ¦ºõÝ»Q`³É  šÉoŒ‚ÃÁÛÀßMx¨¼Ñ6*âœ/‚c¤®ü©+ì”áB.7|–`e×ÊkfªëîƬ=©øøY{¢†ÓîzìZ¾“Ë÷ pœ#n éÔÿæÍ¬N¢—‰AÀ52y ÜŸu±Ä5¢¾•¾9!´º)J!ž`¸pH¼\¢²Ç^î/À•‚p<  %ÓA愽¤1[ÐÒÌøÕ°>ÔÅÇóÉkËý¢¿”:öWŸf:÷Û£oúsìÉŽö`¸³7ÔΩ:Ê£d‚  ¼{K p;¾y0jê‰m ‡Ž”^Þ>jwtV~ü§…¬õéÞë¢î4Šò‰ÁY"…)ëª@/ &OQ zû;ÞÛhyÏ¢9q‹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­«1¾:¾1QÅkf½»±t»ÓW çïk_ƒfá<˜à¿-„É,düô0ømð/Î¥¥Bendstream endobj 5051 0 obj<>/XObject<<>>>>>>endobj 5052 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~=•¯—gœý_±Ê.endstream endobj 5053 0 obj<>/XObject<<>>>>/Annots 2305 0 R>>endobj 5054 0 obj<>stream x­WßoÛ6~Ï_q{ꮉbK‰“¶ØÃ–-]´Å{ 0Ðe³‘H¤¬zEÿ÷}Gʶäüè,‰Iäï¾»ûîô×Ñ„ÆøP6忼>'c<ᯠýþæ(KÇÉ%¥—ɘjʲËdÚÝUtsÔ¿ÇêÅË䬷ú㬧0hµ :½>£É˜f%Nž¾ÄEÄE>z«éW±¯žÏ>^é2Éxc:¦“4M² wÅèÚ*é{Ò²%\ߎnŸ¿&¢ÓS¢2q­Z\½“õ‡Vc‹·d]ç#;Ù VÊd.ì¤'[Nþ•lº•Mû²él)*÷ÀÁÙV8ë g ï‘: dÉtzÁ^Ì–ÊÑ\.ÅZK%>+£´—Ö‘ÐYYJ+u.aŸt+™+QURõÊX/´2y%œÃ¿žDŽ£Üh/”†¦ØZ’ŸD½ªä1©’ÕÒ/M±4eS¬ôÕ8wky#ÈÌ?J¨ ºaÄVoAJ;UHl1~)m·ï˜6¦¡B–J+/aiaô3O-›Ê ”:×Ô’LËÖ-ÕŠ]˜RHç­—þ›îyzcna‡¤Ú8O+aý1©ÝP-´XÈZâíÀÂÊîÓR…Ô ýbZ¹–ö˜å-ŒÆÇ)߯ |nÃC¶¼V‹¥'ÄC²¥PÛ0Þëò¥Ð ,ý ¨n±Š€(‌‘²¸^•ºcaåž®Sú0ÿHŸ¿¼Þž2?®¼g]Ÿ (ÞÿÝZTʬšy¥òp⮂°}mTANú?ƒÈí(Šß>§Ïž ËׯéËà”hÍ£ýÞ´=¤ÒT•i•^Ä`žv=¸ÆEϼÀ7Ûcf¸²Rx4†‚ÁΘN ®R²Ø@‘Nz˜˜HJ@‹¿‘>B3ù«ü@ÀРMã 9âr³ V?Šˆ““ƒrá:Œ_€ƒc|;Òñ~Ë¿#¦‡¥© FYìiƒsø@ÒÜ“dºÑœå½*¹ùãíTÊ¨Ý ë¹Ó¦…=`˜`/šdÕšk?{®…Ub^!°å½ RÍ'¸$КÐÍœS,Ö*ô<ä„3h>y㼩ÕߢN#Ü%,[ª0LäK…öäÙPãb‘ùÍ -f/wŠ]l=á|Z5ˆ\¨ŽÐ P…DŸ® »‚¯–3‘‹Þ!/ÑšAýpšÃð5ŠÝ4á†{¶Úhé8îU 6T6:R'¤Ú5Ó8yð4ÀAˆóœ+[ä¸Âä0¶èz~B‡t1]„$`Ý# ˆ S1øÚ©`²ä°ÅŽÖãdÒ;n×̹cç軘4˜\d?‚lqOIç›*Ñbaª*ÁqçÅÍ~ ‡M˜âžo e9Bk™ÐU×ÞŸnj½~ž$Ƀ-ý£3ÃFöHë&P‡Wyìø1~]“C󎈅þ¹ë|ÿ©‹ƒeZ "`);˶Y” *;˜”ØJ¢fÌùÓ°À<Î"´éÎûdàK÷:€Ö»q¨nCÆ$–‰Æ„Î? àÁŽ¡…DÚ¾;íâü´=‰ÎW¯†Žt¶aüǬý$Ãéõe7 L.Ï’ó윦øß½YqAž¤xÑûÉ䘵{­žÇÝ'ñE*=K –LèÝá(Í&Ÿ§I–âVgç)?úyvôÛÑ?Ô?T”endstream endobj 5055 0 obj<>/XObject<<>>>>/Annots 2309 0 R>>endobj 5056 0 obj<>stream xµVQoÛF ~÷¯à^ eM[²'A0¬í\¤À–m1°ÅY>;×J:÷N²ãýïûx’å“ítØÃšÆM?ò㑼/uñÓ£xÈÿ“¬Ó »ø†?züñçûN¯?4Â.eÔAYK)=v|9£(ŽÃ¡§õehûWᕯõdh¯Fí³žœQÜmŸõeh{£VT¾ mµp}ÚAF^T¾ íÕ }özöjëŒúÑuà ³áËÐŽâÆÖi=9£2Š=\Ç+ba–ã!ƒ:zbF(Âmtž˜Ñu—ÃitžˆÊEƒpä)}Úa?ì{Ú7ï*¸û`–t9îÒAOuixÝ ‡Ã+šÌÝ…éÒ$ ÿl! •ÐÃìý˜) ‰?§ÁôŒ¾’‘EirÊå†õüå-};›|êté¢óàÛ-‹—ã>±¼  ]D¸V)ø™‘¦ThªÌpOY0—©,${lŸHYÊ5¥:_JäDZ+Ì–„¥âIÒR˜™XJJtšÊ¤Ð†6 ™ø,þíë×4—¶0¥S:ô™LDiåav£–o•ÙÃ&?Ž¿á$#N2ׂGî’Ø³zEaƒãyÀ jüÞÑX0ø6lÑy ®//Ù"ôaÍž‹ ©aX#½Àê£Î$e22ÏÁG&óÌÙRZFÒ—R Ĩäó–Ù_¨gùÖ[Òyº¥™˨»³T’X »´*_Òœ Ç?*“!=ä’l™0 »;ÊË4…áOxÔÝì7à b­FªÊEªþvûôûe{˜ýQr®9ÈnóäÉè.çäö.NøW‹i°+;ýp‡l^½ò«{’ ¼>/XObject<<>>>>/Annots 2313 0 R>>endobj 5058 0 obj<>stream xXasÛ6ýî_±÷¥‘¯cK²ãÜMææ’6­;Ó\îâN¾h¦‘ˆ˜x (Yíô¿ßÛI‰”Ü´—xlSvöí¾]ú¿gWt‰ÿW4»á¯´<»L.ñ »âoÿùîìåMòЦÓWÉ%•tuuÕ?ôñìêåu2£«Ù,®¾ºNnÛ'Y=x.i:›âlÜË«‡ÏX½ÃÆÁêÁsI³ém2?X=|Æêüz¸zð\Òüj6X}spK¹ª_Ó‹w0I÷+„ãæ~É$ ø%ÜçšÎï?Ÿ½x€²gòöf£³øiwrBi¡êšôcÐ6«ÇgÞ¨Z”Æ{ç]S€“·_Ýš06‡‡ lª)7Ú+Ÿæ»¤q‹˜éô’žO§Él†§lR5ˤíù_…}Ó¯|gøÙ„¨ÂTÐT8ø¯·fýöCðo7Áx»ÉQks1‘ý)ö^ÐÒ¹B+Kéºt~÷¯­]œù!ª›JûÅD?ª²*ôïï’Ÿî¾k þT¥ª‹ [\œ_ luh:È0Õâ¤×ÄÆ~{~T@|üZ¾ë¢ã‘ÜòóIà^‡Æ[ZL°^¿&Û6þYò7>”tpþ8Ž3­ŒU…ùE/&'ÝfºÐA¿h7²^ïlš{ga2#ñ°7q‚³ZL:äô—׸ÍW_ÅȂǧHlcw ü+UÔzŒðï€æˆâç>u:§‹óãƒu'¹¾<Þ/I•ìï9ÞÑÙë39†*sø©iåÜÁo9?¸E ÿg9Ó]á%kêã‹<á¶ÁIÂÅÔa}X½ÝG«"øFÉ™¸Þ+ÙsˆYrsó’kù= Yd¦”Z%·µÚ×¹©ÈÔ”:¼+ ¤Ïr'»–,"h }ï¶z£=i•æ½BÉ®“BE¹ªÉ„š]PåŒ ÚwÚ3e(U4š¶¹98wË Œ…ë¬-˜÷Mƒq6¡ò{B=çìayˆ±* ¾€ ëk …VÞ•¤ÆúÜ2D ŽTü¬ÓQ¹ˆèêøCÆ­ð¥ÈêT×µ ;BHDß]Y™'å‘…^ƒG†u±Ô6tqÜþN€·&ä”™ÕJ{>$ñ¬¥?pO˜sŒï‚„v…4TV88óá.v¨qN5¨¦ææ´ƒ !óµQ1tÐÝjl¢á8‚EåÝÆdûôбÈôgŒTÑ Ó¤-ARYÆáPT5ˆÙÃØû·ÒxÛr»uä}ÈääÄ¥%åàHLÕF«@Êf ¿ð‡v×R™!‰ ²Ìº@ÖmI-]ØCŸ!ºÿwíàîÒäV$÷@s–ax"1Üšû2A©×T(»nÔš™/vèÎL•¨ KK™Czˆ(jƒòÎ(’Í•"WŽ‚’&™ñ˜œ¯‡ëÝ5¡bŽÚIÓžŒK}NNçÉ<™azùàÝã®K$ îZù%ƒMY„¤ò#QÝpÕÛx³CVª)B”#$VgJt種÷bhq"~¶¶æñR‡Ü!Ü'$éËÇDŽ¦Â§Ñ‰>/XObject<<>>>>/Annots 2320 0 R>>endobj 5060 0 obj<>stream xµXßoã6~Ï_1O­eË¿’Ü¡¹\ÝÍ{ÅmŒ[È -Ѷ6’è’R´î¡ÿ{¿R¶ädô¡ˆ!ˆ"9œß73Ìo1ñÓtÁ¿¤¸Gc|áGÌO?_̦³hLó›)žÍæqtF9=\tǘ½G7ÝÙγ×WÑ´7Ë’'³+/ù†%ûKž.xr:—É«vúÌÅÑMb¨• Q<×´ˆ£Yg®3,èfÂç‰Þ×Çlîi²;Æìâ¦?Û0á:štövǘ½š÷Ôýתãsq¼ÝÒh9£xL« ‚³¸ÁK*1ÁK2x0…¦ÒTä e©V9^òºÊLéHYýw«/ð '3lÜ©<§j§‰?–«ˆ<\¥‹ÈÖå2+Užý®­û¥üékV=*[ëÇw~C«Ç€Œí‹Ó0žðŸê²Ê mu^ïþŠèÊ.]mµhº9*ÄöP tJk½1~«q<|oÍÖª‚44w­`i¢ªdG™ƒ0Uá7ü¥zo5&!lS— {L„“⥚R“Ô….+%3Nœør´\§Mpª÷ꊅºÚ™”egåN[ìÌT—NmtD÷ê@V»:¯°€:V­uVn[» Dž=k2ë/:©5»,Ç YheµJ%¬=£S&µ 'ªÌöu­!¹£¬Ëp @DïlV”óDˆ’˜×O= ÁàƒzVÔè5¹¬Òý5-U¬O *;­,¼œ£þ¸÷ ˆ#† ɵÐ'ŽDÆÃ›ƒ}iMA_Ò§ùÈ”²*usÄÔåù¡*Mvu•š¦|s™g‡^R feeMZ'À'@à!¼­•Ue¥ñÍ»0°¡ÙéRüц ±tF†_¬D!ðe‚YµõôÚ*»æ÷Ä€WI'A2‹œ`z)Ô_U±Ïõ%bÇ!F8(bØ`kO ¦Q’+¸· ÌòæsO¡²ò/=h‡ÀÉÈ»I4b”¨ÕàÿíÑœñ™è™èE<ÜàºãN’®„o¬½ÎìëuÛŸM–°äWRÈ¥Û„Çÿl‡'¬IBñs¼Ð™èå7H9['kNUAø9™F‹ÅÛ~›ƒ÷õvçT»Ñ<´D|™ÚR£]ù}EGpyîžEéýýŠSIL ’ÊŸ×b¨U]ŠÃ OÝú<ëhÇ䢎z¤’_Ö<%•£¾ꉳćÿÜ„©¹¤ë=h/éÈN˜$ûp¹äÚS¡²*yâ rÀ*Mw£»~úS}äz<²ONdÂö»–g¾Iu®+Í!=wɱ² i†0—ÅUYQè4CBt²òÙÀ8Ñú¤Ú¡ì2ÅOŠ\½Ýâ)¤Q®%œ@{†m —¤pf°Ó\ëÚÜÏ_Êœ†Å5W;+ …6}Ö¶ ¥ËÁIj r²Ë9󊄽AbB1Ò_½÷ú¸ž¨RHm—"[åXZðÈX嘚>üï#Ç v\‚ð; â#Z"…lC[ìg->ßÿL[]jT.(çSËíÛùá–ŠÃ-ý(„¾ÖµÚ ÛG#h eM ¸nÈöE§Èö)ˆm 8Þj6²›Kþ«6öŽƒÌÙEšâSÞ/Þó|Þ7Sà Ž?÷" ú­ÀŽN¡ cK_¯½€—&Kü ^£²­žJȉø0rÒ4c°R§Š uå áÄy}<¹¼oÉ@ÄžH:•„2ít&´ýlÑpæ@GÓ”¡‘â¦UβNŒåˆ¤ $SmŸÌmqÀ 9dõÌ>Ñ‚­ÑðÄùrìó’d“6Ä¢‘Ÿmû7ôVšvJ¨–ÙnÛ‡„*$ ]';íaÅxÂ{vâXÀA¢ädGúžÖ¡Rs*ÀOÎ~½Uê©UöºP{ÏÕãúSÛ”êJe¹Cn$ìu’mÐÏ¡ÈØÂÿ“ ŽQðýïÌa8Á=cvÍ%èAû\ö íÞûCÞ£WƒkEøÒ·ùbä÷Ž> þ†ŸWq€÷ÎÕú›Ú+‹&¢¸Éë&µG¤’—®§›€îõ¡ç"Å…œ§;p†0HƒÝbóhys¼‰…æ2‹pŽr…âJQ¨Š=vÖW± ˜dÆÈ+ú8\HÖ:~EK-R¡¬Û‹Ðƒ•;1yÉ{u31ÈÓ`:Û<ÓÖ'[_É|Ýyam²–> ÷%á$#­{"º²]réÍ;÷“Ș:åŽöhád¯'nÏi!»‡Û6ÂvßèãŠÀW@v‰ÄÞr¹#Æ"¢Û±FÏ(^Ž`Ù6¼·ã ¹?xÆ¡P¹ÚIñY#âg-ç[ˆè·bÂW)ÆJž›†ãÝvoWïÒÏÙší7„ôó¹4„á…ƒ°á»&´q§ˆžµmŒŸ?¤û£p¯'qgm…$…¿høã67kÜø=PŽ µ?¹žA¸Ÿ¾mbhhýñmõí›Jêähy¨_Ï¢ùtN‹ëqÛ•s"Nð_‘woѬŒö«‡W¾Ìþ½ü™*…ôé|Îü´ºøïÅŸ§¡Äøendstream endobj 5061 0 obj<>/XObject<<>>>>/Annots 2322 0 R>>endobj 5062 0 obj<>stream xÍXmÓFþž_1â A\|y¹hÕ…:$ª¶•/'¡½¶÷°wÍzªþ÷>³~IlrGU©åÎÎìîÌ3Ï<3{G3šâߌ+þæ£i0Åþ˜ñǯGÏ–Á3š/ƒ)å´œ-‚UýÑÕèùúh_e:5¥§Á‚Ö1ͧ´z6 V«'´Žü¶SZ‡c¢¢Úd*¤Ò ‡[£"Ú™Í&“×ãwŠÒîúýõh}3šÒd†UVÉO"/2ùæ×Ë o$Ò½øÍÙë1žñê‹ÿî=û§óWÄ{Ç4§“9bóžŽw©´’xS›Œ›³ë·íÂ1©’\*I‹\’‰ý﹉ªLôs–á½S[I¹t©‰JJ ,¬©’Ô[*í¤Íe¤„ÝS˜‰²¤]ªÂ”RÑn{´¼`ÎpDöVF˲ ÓZwØOæó`±@&¢qx}ÄÅ/ ‚ =¥½Y+-²6aMP½¼eF't#l2;£&‡þéý0wC¿–¥ ލ  ³a*ê™8kSQX™ W!ƒ‰°‘H M–ÉÐ)£ _n¥®m÷'ÓGEÀÓqŠ8¡·!ßùE™*&5ö´$èÅù‹Ç’­BGÆ6Åι°e*à„O— 7b+ˆ èRÃ2Ârœ[iü‚¢€;»t¿u©üwpHd€¢öªM‘'BMVvù›jÞqp_v T¬œ+Æ©í¢úÿé~ÌaÔ…É6;6–ŠÅ‚BÏè¶ÒÔs- ÝüPZ­¢ŸHË]CûëñÐïN·:ÑúBŸ¾^©qea8‘*_d3§·2Û£b$TÀp¶9ðL}ÿQ$¾Ìwï gtO{‡²{~N;¦Ÿ6žïðÛJ¦ß²¸šƒ*`âs†h~ªA¢k/‰&³¹|·¸F"F±y:eEejvš¥Vi¼E<… ‘Hžy»{ê€DŒ>£CV…D(Ýâ˺õgyZ󹹚[ƒ€ëÞ{~ëHEÂ1õí Í è ŸEßT´ÒøT‘­´f6Õyõç}¬”ëRç=e¶ƒÞ'_€Ü*ÔgàÇþð›oÂFiV¾­_¡^á×­Œš¸÷ÊêúK_ÑÊ•µ`f{ö’•7’µöâØºª²‡©Ùl•©J8©RÀl ‘`7±x{R'˜7->UÉç{VÔ¤ è%z ©xø­[iö]¨÷¢(LY*ž‘¾^(!ÀõýI¾Ï÷l郸o²P'ú¥'‹Ï#Gv|\/’fÈyóç[J*tcLCÐ1^‚M[Ñ÷Mµr‚˜#Y½þŒRbv”@þ Šu]r…ò 7 Ò3¢?£ÍIß­ð÷ÕÅÛÔîäìú­"z·46 ªc0|‚ÆPæšQ*SHÇ<#Ý:@ù¥°'ôÊÇút‡=íd£Qr<#õ²o6¥´[ˆjûªÒÑÁøÙó!¶&§›èÃd†«„Ñ;a1=sq˜) rCãUkÜαó ž×`Ìnžœ ¹À k>5³9¸‰hŒ{jÑ:"cQeGC`ßz/d®³záVdðëZ‹<™A¼ÜKˇñ“#PŒ£_ë’‡ò“³0íFØÆ+¶±má,RLnܾˆ?sQô¼A‘aÂtèz˵TJ½À=¯=’óÀ•ÑJuwÔÃfï‡$œ³jS¡mso;J•÷±ǵzÌw†þW‡÷Óæ’:Ÿ^ËÅ’VO=ë¯Þ]¾žÌqsÿÅ„UG"ÞÞÚrò¤¾]Ï/‚‹``<ùוÒ]xÐTø¸åt,æøSJq±\ñ«—ëÑï£>#8endstream endobj 5063 0 obj<>/XObject<<>>>>/Annots 2324 0 R>>endobj 5064 0 obj<>stream x¥WmoÛ6þž_q˰BAmù-qÓÁ°¥M‘íºÕX¾h‰¶™Ð¢*RvÜ¢ÿ}Ï‘Rl)N¾, l½Ï=÷ðîòõh@}üh4æ¿duÔûxÂþøû=?¡ñùk|®htŸV7š¾ý1iÛ ê]Ò O“9_ã"õþp‘Dn›Ë•ÈO&·{ ýnXÅ4YJÎjV:IÊ’ ¹ YJÖ]šR§4“d¥#gèxpÌ_23-Éaµ-ó¼Ö*“uȤ%"ã%f¥œ“)?¬W÷ýêTY^{TÔ 9º‚™¼«\Ë7ü¢wÕ§óxÄa ûÔãÑwiôKÓ4ºå«e&_$y~lÓºQ3†ö‚޵ÉÇÁÕYEP×»Åãñ+vuiV¹pj¦´r[øqõÖ5¡‘'h!3YÀÎddæšiJSÅ„¦\b%,(U);!“$%ˆÈh- æÅR^(„â¾Ü\¿ïâQ<êûð{W¯rמ2¨!Rƒ3ú¢²…'¹""ϵJ<@‚Ü’ßsé¶!Ð83æ½µ|kÑôTZìC>]S&± @&€¬RÔØ ˆÅ"Ö°^ZšsPÐÀåÏ´2i °›¥,‚.âOï&o B¨´’>_gks'cºÜí?/_R¢…µÏ+À›ÐDZGßë-Xö‘…” ¾~m¼É˸ónA Ÿ¶fÓ¢yÃ+¦Ñ±ÊU¡YGß4üðþvG­¥¤IžÞ¼0÷ÛUÚ±³­Ïþó¡œÕÚƒBJk³Êê&»Q‹ËÏí` zƒ–>|3c´Äyô–åêÏMV3ƒ³àYØ>¼ç^;«¬4Å‹™™1„Ÿ=çtA;ãz§šïÊ®ÙìîšóÇЬƒð“õB:zy‚Ììö ¨Bº²ÈhÁ€..(+µ†áo¨’oÏâ§È{ÄÚà„ÏN½ú&½ps‘JbÀ/ÛÑ·ýözt)´öªO¡Ä¢Lœ)ZäV‚°Û,Y&þ)y»}$DͧQýt_¼ØÏÒAÂÚyœ me;NwU¦Q2â€âß œzÇÇ¡ÕÁ”B¿½Km]ë`Ÿ*®NÏrÀ ‘k÷4ÚßÉM~zÒ!¸•Á7Áø»'ëÀµ£¥°ä6†Ð–&ÅõRpKD¢¹ÆVOѵPHõ¶Cœoîu¡ƒ?…-XÕÕ=ÚU^®˜;B¸-4rµóýu/èFÒ¦'ÏùÞé2¦kî}’¢˜‰…ĶZ£Æ TWÜ”ÐõpR³ݿꔾXwHÉ'pítÜÆ6ËÝTÞsÛSN£¤‚E™"OK™…ƃðwi£À2&¢d ˜eR5Ÿ£!e˜]B¯DwãV¯Ã#nkØ 3™ô&†ñÀúü ïÏn+[­Dq‡3È­¯Å„Ÿ€D¶­Œ-à¸åC¹@ãh°00h…B‹¯¥,ñÖwuç·*fÑUK±ö=Wm5íת6½µ>Ȳ’G´–Æ;–@$¢ÆÀ¥‚.!fî „¬Ì%`DÙVNßÞ ±—¸¥yHŠ9TeÎíʃY‹GF $è@!¬qÌT>“<$Ñxºp‚=±ò^&˜aSèÔçÉ-Ë&̨º{‡äY·<ùìOX¥…°ÒVÙûé†V¥vª[E¾œÂ¤Õ¬…’¶ãÅP¯ŽoxYïã[2¹ŸY,ÿ([ Ý ‡#ÁLy£²ÔllL¿k„œAk_@êsK"IžáðŠy™%쵪,>ùžÎ* xÕKå3Ï« 3ìŸÆg£3Ã|Èéÿk¼5I¹A^Ž N°ì¾ Eû ¦gýq<¢ aà½b÷ï&GýÈ"ûäendstream endobj 5065 0 obj<>/XObject<<>>>>/Annots 2326 0 R>>endobj 5066 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Î#üÑl[JÚÐ$÷ü“–]ì·þ¿ÛPd) Λ[ôÁÑ>dÐá[¦G°uˆ)y°Ÿu-÷ú”i½æ¯™Fʾl­ZY-ÀݺK¦ß¼›ýóñí§ò×ñ°d¨Ó-¢„ÙnÔòÍGgš  _WPÒɘséZ›÷ü±Gú´Ð]XÐâºr•‘Zy„!Ôú@ýø\㊳g 5u{ÜõcÖßoÚ²Ôă¥t Á¼×M•ôâóQF"[¨ÔâstßaNᾦ[31ÝÆ ÝX]r ÅO,%Ú¯—uMEÌÚàçÂbKrá'奺©­U –͇E±YP× FGˆzaf ÕôÐP ÃÒTPÉ¢ŠÛœÉÕNa4D5¢ýÀjÝ®eØH5®j(",n´YÃu˜ `D7)mu…¦å–ÐH’%Üñ•üÄôðoy™äÄ;±°À[ˆRîª\”–l)c•¢|xŠèƒç:©¬¡‡sYXÀàK轃ýã¼çç\ãÀGÐîÍÈï|'Tfi¥7>¨tËtBÞÉ«tw’ìV(ÄÏÏ‹ñM&“è2ìälöl èWüðh&1¨mxûì2¬ì®ƒI4á7+6¯ñÅ›x;;ùýäZ˜ÀÆendstream endobj 5067 0 obj<>/XObject<<>>>>/Annots 2328 0 R>>endobj 5068 0 obj<>stream x¥VaoâFýί!]ä”°Áé•J‰J¢TQîh«æ¨N‹½À^M½kHrºÿÞ™]Û`ã&—;@°^fgç½™7»ÿÖ\háÛ…N>Þ²Öb-œ¡/—¾î®jm·Ã:Ð=é³,¡Ýë³~úÀ¨v1ÞYbÖÅs8¾<·ãúîáÀ7.qà9·‘ \ƒ~\ _Ìðgbîý#|˜>ÂèÏë+à¡V8o äKRA¢ÐHGàE¡Òqâ¡›Ô 61_­D ^À•2 \F1ˆ¾\âèpü©Ö‚¦ÛÆxZ/}´¦åW6 qÑñ%¢7á;£?==ÚÉ “Cqð<2 †‡åu2ÔåE›…ôœ ++ñc¶_9F¾Ú`»Í:|ò Ë5eo"~,—Ì…1ÊPñ™(RA+-"–¶Q¦ê×F²X,šPqï¹Dæ*ÉròBa½‘¡$¾€:%+óÊÔf^ψ3byó +×´‰ã¦‚È•dò|!֘¹À2;¿ÁÍùÕðnà¶°"Çï~Áûë›ÑíðÎ îé|y^[E:°ux/€M*L ~%ÔTC3ò msÛ˜ ` ¶©êrc„Ų©‰SÇÉz™—ü†ö=™éú6ÑWú3<ïû3Ó¯-KÏÎôoðw¿:»G¤©Ï-\ìI(…}ÔÆÔFÎÿàA"&5´RÖb¡“8Üš;>ØæG-n0Ò1õÙÁËÎoñ@ýJßåê!ãˆ:ÞÄ)Bª$g0qrÔðÓšbçzÛIøy€·†ƒƒ=b_¹õ!þRO)…Á`k29¬pQfw×O™ À.cìQbæ[oñ§"|œn4*w+BWä«bݯò°%YÑÆˆù:Äœçñ£P<±¢ Å}ÙÖ]‡F®yfoJ ¨ÃFbÖT–øÐ¨ ŽØÿÎWž¦­Jì5¦¢¨c¹Æƒ"ï7¶¾ÉUn¥tôB*S d ËŒ«(K-3Sñ ²±¹lìêí¥Ðìmel…È¿3Ru9P«Ž[‘â1V ·l÷ €²CÂ0jt_%ôgA_öÓ;µÛÇëY§ ½~ŸÚ{.Í6kÁ/‘g*×Ü£¨ ±ÍYëæ©­•ÿ¹Ýu[=ÖicãÀ¦ÛéžÑÒá¸ö[í?¯ βendstream endobj 5069 0 obj<>/XObject<<>>>>>>endobj 5070 0 obj<>stream x•WmoÛ6þî_qÐ@mE¶7í–iæ)‚´]´ hÝŒDÉ*dÒ%i;]Ñÿ¾;R¢-ÙI6çM¦wϽ>—oDø5€Ñ˜¾“yçM܉Âý/•ÃñUgáâ †Œ_ Âñø%Ä©•Š NÀ—™:Ôë"ÿ‹•Kç@ϱœo9Š¿v"èðRj/‘Ì-0(޼ߴ…V—‚½¼PÅŠÚ0S$ð†¯¸b9ÿüŶ 4ªý7“Ü\¼üу»øýŸq>\ßÜÝÒ{|ø?Û¦Zª a¬Î hô˜xVVB-m<-zgT!r§›ÍySØú{|u­ úèw8ªB\hH˜€{ôŸsÑÃèqÅÑd¬P€¿ç dz¹XHe`ÎÍL¦2©HÌ÷×,ãÀQÌ®Dñc¡g+Y®¸®³8¤D$ŠcüÑ ´[<ðtÛ°ËL!0E"ášÀak/)™ÖÎZ"QB-#•¶.Ôñ7en‚`©º›âÚò ™’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”ÒàE!’r™r8°Íˆ|“ÔNY²xñ}²Sc ¦GÍ9kãP³Gƒ.ÎÑ~Æ8¯ø£bŽ«­!}÷÷õ[%ت9ÈNvvlÇÀ»ú´ƒ‹å}‰×BÚp,͵ŽìœA—£é‘oèŠ=¶äkZÜ=þ4 ª7áóDìÐía¿i0=‚-mPOßÍ|ì0½3Ð"zK›nMƒéî5Zg¸½Ôç¡#¤œ› µK*I&Œ&ÚøŠ ¦Ç¿n­aÉEŽsx¸9„ßÎqÍ:<܉íM^þì¿lv&8w›”]'¦G{TTÕ_ÞÖ³ FÍ4¨½¶ÖÉax½d¯ï3‰ÿ|„Óå]Pf¦ä_Ã5ÒDÎÊ •/çÈf“‡„/höMƒƒ[G¶p]¿í¹¬AwOX(¶O¾Ü.àƒ”úî¦|§$«å³Žã#•ÞÜiq½«öÝPàÒÛí¶#ñ¼™ç }Ǧw«m špª•ÝÚ_¿7¨Ÿ|Mííýðš%õ<Φ’ ìñÕYÅTƒ3ä§Ñ)ŒÏ>/XObject<<>>>>/Annots 2330 0 R>>endobj 5072 0 obj<>stream x•X]oܶ}÷¯ºAÖò~Ø»v ?¤©¤ÈMsã½½@á®ÄÝ¥#‘*)yã[ô¿÷ÌPÒJN|‹"cŠähæÌ™3£ü~4¥ þLi¾à¿iq4I&xÂ?¦üãÓÛ£å"9£óù2™PAÓÉE2mV9Ýõר]$óþnoÝóErÙßí­±»œ-÷ÖØ½¼L–ý»½uA³ù,¹èíöר].“óÞî«^”ªßÒéÍ„ØùÕ†fZ\N“ÅbI«L°˜Ð*ýùru4¡XeX—Þ<¨JÓÆX•“±…½ÙþªòZÿðÌÑP©Ê¤”æ*ºÅéúKE4§§áƒéæ<Û¶|òŠ&­éöpëU\Ëêôæ ™âXØ×“Ù¼ f´ÚiÒ¶.ÈTº¤ÊR+ÿ}¨zo>kªp¢z,uP›æh©ªJ{;–­ÔÙPù:­œÇu¯[ bÓ_ízý{m¼Î¨r´S6ËuéŒ!|súæÕ+q(ÐÞT;`h*£ró?íC4Éç971œƒµŽèAy£Ö¹&`@Ü|r«úéMc­öM2¼Bè·•m­R1U*PL›¤Sñ(àðƒî|”*k]EkM…ËÌÆ øw…Äï¢ÍŠ ýKù°Synìת½Ö–~Vª°IL°>€z ǘv AÄ9££¾…Stå®A‚§hð‹â³îŽÏOϺڹ 9zçò–aêa©9ÑbÙĬÐqä¾Õ(tˆ÷9r¢Ð™ýNàÞj$嘑وKõZ3¬{ÏTÏ(s:§g§4ežôهͻœŠ"äbtkŠ2ì]\6Î÷¸ìêj@ç¡VvFtZg)Ó!õf ÿvn/%X¨RèÄ\ªC,"•ëÕ΄„MžÞ\6µÁ…~ÆU5;KÎ’sÖ2Ô1ÕöPÊÂeâ½¶€º{\Á—çnÏé/Š#„_…°Èq«o1|mõµód6Kæs¼=½06ÍëLÓ1ç‚e%z“„ýöXA%‰æ½¸á…Cw£éÝË¡ÆI"DØ^m5ýA¯ß_éýë·×Ÿ®¦“1Ý®~ùÏjLß½¿ýpýI~ùíªYÑŸbêYA¼ýï»·(M¸¥PçCa(zgaÍc†ªsÔ!õê|Íýc‚¶0‚Áðn´~DÚ0±±“b÷€©¤ö8¬'“]«hûƒ †çλÔe:¡_¯j ‚ƒ@»3œ·jWÇö#ã bRiª {ÙÕè"7Œ<æDt…ø™b$(Iè2(І!„T–!-l9wàqY¦š9Ïë\Þv¦ì&Õåtd] f„Ññ#Ç -iࣼs븬¬Þ·€ ±‘“®Ze‚Äã]V§ØŸе«*pßÅ6éݱ¤‰YæÍ{·nOl"ÚÊ ¼ñèÅÇddiŠK8›¢DP¸[Ì({`Á z¨Çc„ÐñXgßKRSW¬ñ$¬v›'Š;z´´‰ÚØÉuÒõDì*ðš&8ê@Cã{¹yœtÍ£aSBp¡ Î| ŸÌÍuޝÑk‹BýÛþ"C× ym9HÍME¦ñÌ.öŒD~6ªÎñ¥…ªÁ@×ôèj*xü-¤6÷Uˆè–'®¨ý<åûBOÙ˜Zsßl&“!u€æqëF8&W Þ‘ø"©y¤“n‰ä…€ÉüÝ oÞ:ÛWÇÓã»—ü‹V­ӛ‹f^ qÏÏi±YÆi°™`gôÑ»²?d·”à[ç“E2Ÿ!ghîóÅ”]¯Žþ}ôøKºendstream endobj 5073 0 obj<>/XObject<<>>>>>>endobj 5074 0 obj<>stream xWÑnÛF|÷W, ‘™–%[Iœ§¦‰ hÓ"‚z9’Gñ’á‘’…¢ÿÞÙ=ždÊvj4 bY<ÝÎÎÎή¾ÓÏi6çÙêèÝíÑ$™àÍÝ͒ή/è|B·ÎÎßàE.Ïñ"}1m麖ÚÒxruk\E•£Ü4:k]C™Ë5mŒµ”jZêJ7ªÕyBŸuæª|L[×Ѫó-u^ãM?Zµ]££ãxÉñ⤿ЬqÈQ«qßç/7¿žÜ~=šÐéù˜F›Òd%eVy¯=©*§•¸Ü“D›#|»æº½íÞý™ª«ªkk4>d]ª¬ÝŽ9°¯uf “Å(c sïÁP~LÖ|ã䌿âçg×z̘Ï)ÀO§Él†ßòÑÙÙŽ¡=N*À"ĸGµT*0±6MÛ)ÓŒ±¹@£Çi|KñOþ3ðA2UÀB×Î=#&ëã†ì£˜N%ûY2Ÿ¿bA Ìý#B¨ÜÓR蚊\QvX(‰}9 ='¤ê;µª­TOÔäq%§§r¢EöWW©jÞþ0y騹pñkàŠ} Hßeºn A£ÅIÒãš^0«ïûFô­²Þ ‘ (0™iíÂj\·,QßR7¦UU¦º©¤+ g­Û˜j9îã¾SMhkn*µCÜ?í5Z刮ŽTIŸÆ®tš­ÍÚnœ¼^ŒR˜IåØP-Ï'?îšçVHŒ GG8"þºKÁ€Ä`+‘÷¸K"åkgrê±JŸ>Õg1<õOü5ôZ€ú®(Dþ¿vÅûôîìú ±+ðö˜ËØeÓ‹ä2™R”E¨—öCqò'.ÑÏ5G«è«¨Š˜ßÜ“®Tj5¬œ yg`0`ªôæ¾r¨j =[QêÚR”ø€§|ï´—ñÁzPÁj• À0£Pž?½×Þ˜åÕUÌbˆ~‚ŠÁc¨ìPh?¦Fºi`ëðlµÏ"Òu÷·Îy-=Á-ÑÂaø8ϧ_^¾$ý½3keuÅ¢˜DÛ|â£Z+ªw·×†Y=,¾Kƒ†jgªV72ÙJmê*pe·h·Ç.ë†þæúøØÄ[²º}áÉ,+¾™Á ù=ƒ7éGá©ï4KSaÐpî¡^=1%ÄL¸–‡ ½ÛR® ÕÙVÌuWµ>¡ïZ]a@?fq'pÏ(+ÞE-L{? -F^‡tk¬:gâ<ö^Fx|–nù¬0FŠíA½°¶¤ãÔ¸Þ‰¥ { ta-ô³)±Rp©J½¼´ R¸A(¼’ú¯ÍƤ× æ5d…¤©«ù°jðà2žJ+œU’1‘êÈñ-ÞûêRfcð8º+òBÊptÀÃ'< ™ÄÒbËi\Ý,eT[•q*íB(TøøÁgiÃQÐAŒ¨'ޱ‘ýK––Tkì`Mhv–Õ^>¢?.0ó8À $ßõÏFCä^«¦Œ«ÜEË&ì—·lTñÙî Ä`òg<ñ6|hÀžVÖ&×XúUùZ5(‡JÇ3uÍJsk‚²ö~K¿ÁâØ¡!xý RÃBç#˜dUµìÔ’§£Ã…¤†cû¦‚U)kZÞ;ñ™ÇÈæ…»Ò,W±UáÚÚyoRƒÏí¯¢&™È„>ažã.|*Çë{*VJ²DˆöËäÊÀ{`ú~1…ýú&T+s0Ð Gd Û‘.ÀAXäÒáÉ^±½>zy³¶:à© t ïâ΂ýä 8ÿ@£´æÏÜpžØ3e pá¸ÔÃ;ô`—~å¬#UÀ«xÂ.Sçy›C!ˆu¶‹½,T׺Ú›co©ØIF‹a3d¶ßèö§óœw;™å3úý•ZahÂUDp©uÁWîsÛô<°Y¸ÑRPs8—ê­}¸Š†)OƦæó°³f{˜k_Mi£ ÊþjdÙØÏË"æ±»[Y,€¨Ã>AhU³ÔT|‡l2üÀw¸ßäáAÇŽÉ †–nx@Ã2ÇÊ»ÃÏ `YòbŠÌ“,!\‹A%Ûm–d0(ÆK:D=`¡yòJ;¡Q=ûŠtZí%gq1–øALq+ËsiÍ»E¿8…îeFã—–¤èHr_Á_&¹Ýe‘”­´Ÿ;œ›(o §¤ƒÏ®_÷ûÓt‚õovIóù$yÍâítšLè½Ë„A™9 {c8{ú*,–¢¶sz¨>}9™'³)ö3Ü9›Où­·Gý •cendstream endobj 5075 0 obj<>/XObject<<>>>>>>endobj 5076 0 obj<>stream xWmOÛHþίUBJ¯É ¤´§ž”h‹Tªƒ\û%R´‰7‰Áöº»ë®êýö{f½ëór' öÎ̳ÏÌ<3ù±×¥~ºÔðï<Ûû0ÞëD<¬ÿè%œR·CãÎÞâCìÞãü5LíJ•Ëʼn–s«´¡LÜHJ,å–Z¤deÉ-ÿ›¬%¼zEjv³†6‰]ѹX‹úɤ%Lí*<¼|M*—d)i&Il„–¤dWòåøz¯Cín¸Zj¶NTih!æ/…¥L`Ls‘¦†¡ì„[h•9D›$MÙqVÎWdRµ‘šÍó­Ý=Ü ã8±‰Êáôî5ÍUVO ÷;`æ©0F"*ãˆåÊRid}?óšñ»¤Ui“|IIîž6=|C"Žñ‡L†¤ÖR¯¤ˆ#¯C&±%ÈUŒ6ç[¨Â&Yò7Íîv™‚x¤!½#™‹YÊ!Äš´JÃ/ÜþBrh˜N^ÒBi$>@-îSQìïɉI“޶FÞZ™ÇÀ‚«1ù#:8{Kœ1.©voÀ©ëFGÑ!]%Y‘†p\NòVð“Êj[ˆmœ?d»•›$vù’@–"y þêûçi¥F-àE’Êw•G}ÝãØ½¨ßÇqk?Sq™ÊI+ðaÞ¿è¾Àm=€ß=“°âÓž—IëE8ÏgG¾ >#w \1ì¼§ŸÞ#÷VÜ*J¤cî0r9»gDëD#¹)ýsßó¤…P?í˜o®USYpÅO«Ôs˜+ú±¦¤?dü ’M9sìEtQ‰:Ëûr]ö"¦Žßo_¹D¸~Ì€VhŸ€™Ðf…bgë¹Ê¡r–„^–™Ì1-fÒn¤ç’O8f7—ã…å‰ö®ÚËAãº^£ÌsíIä=4l«Þ ×ð]Z³ÒŠÚô©ÎlX]Ý+³3!*4HKsèL#ð»wŠÆWWAŠvû(@ú?ýxYæyÛ¾t|s½…ÚyTF(·Óå=Ò´©ö…Æìí"õj-н¢úsOjˆ›àZš2µ?ðŸ#¹¢!̱JÒŽ‚¤¹ivT_x46£HŒ)ƒœãAäÇÙH—nNwªÄ¤-¸ßù‰qeáÚ½axâcryá†X© [ e$ö 6¨¢bÏàÇY²\Y Bßšçß¾6œ¥Á(G$ÖõO-ã•„v%Ћ%ÏdÄ2*Åž‚‰ËÃÝ¢‰¹D±…H*´\HÍ[P8CZþ(‘=C×ñM»‹iÍ SH—vŸ° =¥ªCkÅ|uRÂ_nÇŽº¡ ™©¼b=×B®Ñ*B½hjê#NšÆ¬Tòy±B«y9'þ~Ñbëš¿j¹- —žÝaö€ÛŠõJ§çÃoÃép<ž|šžüuyyz1žŽ?]žGÓáÕt4<ýòõëò\+r:Æ‹dâv2._ÈûNÄJÁI~Dg¼ƒ¥˜w„DòàCðûa/¾NG§D„A¿ §HVfn}É‘|‡&…Ž·YÉÛ6kt¡Àn˜)”I*ÅMˆ\a_”q5€[‘`5G 즮q Ê;›˜üh‡ˆkl‘A"³Ybáœi)¼å…2î¹íð ³kÂb\±„b©|g¨I0.› p,¾~ DRnõ%»-öqdÝW Ÿ Ùa$\a×4â‹Ë†s¬¦Ï«Ï>XÀЃØë2Ç/y§Üw[×Áٱ߈ºÇØ”ûG48îGÝjwu‹A/êÐHÍÝ´t_˜4ÈRuºý¦R~'L}úê¿BøY‹Íd–*aÙä¨3ˆú=,æØÌúƒ>?:ïý¹÷/-Ýwendstream endobj 5077 0 obj<>/XObject<<>>>>>>endobj 5078 0 obj<>stream x­WÛnI}ÏW”XE;¾$&ñHÂE"Ë‚^,Eí™¶ÝËÌ´éî±É"öÛ÷T_Æ‹°/«DQfº«ºêÔ©Ó5_ÔÇÏ€FcþÍʃ“ƒ~¯—ͳ ãë>õF4™Ó°O㧃Þxü„&¹ßÕ§IÖù-—sUIúøùͫ۷Ÿ.no~¿½¼š\¼|}ûòÏ®n&·“×®..Mþ:èSw³¼søƒ¯ŸÒ`ÈÞ»pßžF÷áIÿÓ¥22sÚÐJš¹6¥¨2I®®Tµæ'ÄîæÈ¤ “öüy)+TÉ ©Ê:o¢çx“'gÓ<Úz–ÂÚé#R–2#…“9,è­X‹#rKI/?&«rI0ççÆAŒÆÂ©©+§JIÙRf_8Ì”%²Ê;E)ÝRçä4åÒIS2bн G+aœÊêBŠÛ^KcTž#—!h˜(Gv©ë‚c]ë/€#F:>ËU!KY9á”®~Kq×£‹ÁÔ‹%LqR)¾H gÊ)Q¨¿½!ÙB-–®¸£RIòÛJVV­å›…¬¤Ö-4ãpñLΈ\êù¼ú’¼Ö‰ °F°kàɸ©¶µ÷>ö[ fw¾8Mé¤õub„ZÁg¢"X–…æÂïp#ÖZå ƒÔ|ñ,­•ðhòn&~ V$©Kãa1ñ®CÂ9£fµ“=ºF…ä7Á%8O>¶ÍÓ{£Z 䟃mµ‘Ó΃Ń#jŸó|f^ký¬}`è“Q꓉§¥ùZ æ À"ŠÉ‘…Z‚½é”H0Ks£KÏï w Sžr-mõБÈ\?eì1‰ÌÜ(”Ïȯ5z‰D›`"ÏQ]‰‚2®r½B(¦÷.ªœf-‚è+ТŽÙ’+Èt_±%G¯+°ª¶r^äƒKa$–8‚cO¦Ë&p̱°ø– =.'‡sA²Š¤gxœmi Î ¢Gàžº^˜¼ m9 ÚÓE–Ik™=+£ô œ-e9“ƶkDéì¬Q¥Ú[¥böî8Y+ÃÐ7Eâ®…Õ´1bµ’yPnÐ5Ô"à—h£Ü͸ȣŽÇow-x‚íÁ+ ‡G{#îi¼M¦Ñ6ÜBÂçÉÛXX"gø’Uõ I3І<н¦ ɯ·µà]@ µU"FŠÛ˜™$•®º €nÑàOŠ€$ŸõTk<<„^åèÄ vßû×-"‡m+àÄéHYáP Ba¥sQ'(w+ ;ç¶ëÞiè  bS0ï9Ü=' ©=æìz`«C¤U^{¢S/Ê…ò÷€²ÿ!;ÁË´¹–ìóžLø „'ì¬D¹§w{òó~¯h-Œ³ £™ˆ:íÌ4è‰ËæW¸Êá‡yQAš^µ[„n ›Èê1÷{K·ãëÓÝÉ€;ð½ñÙª÷Ÿ¥ñN›Z¤òUÐs>mÏ$(×j¥#w·Bªa3¹·!ÛL¯<A*UeE{Xî Dué ÞÔ’‚+8boHÀ1ׇÐVÉ8Žðx²ÍØ‹ ç9AÄs]zÃĵ~"H×ó[£-"‘F×ýJBœB̉ý™Æ0ej?qm‘L|üßHïÎØ§ï¹*A™÷)ܘzüÉù{‹ãcz³@é$ß"ŒU]ÅrÓP°iSáîCzú(ÆgVü¶??O•k‡q¨ª‚§¼Ãï­||ÁÚáSÚNi*áqeŠø´¨m4í…ï~ˆÞÙ’„óŸVˆ¿ÞË£Fõ¼ócªßïëý“x7º÷£ïå´?×5šžrÄt]ì}Xø?ÙbF õ³düBœàíñ)ªKB:!³AòÍ×ñþöÀ"0d‡ç¿îâx 2åY ¢¤o….\dÌ5¬—-ÂPêj„èMåäBš }?¥db§Ý·Ê1D½øzÂøòŒÚµÿá]_ŸEÙœá jtJã³a¯?ðS'¡uñD—:CÛï|# sÂîî“©ÿü:Ý~~¹%¾üÀ¬0 K/^§ýqo4Ä—ºt4>áį&ü \®Qendstream endobj 5079 0 obj<>/XObject<<>>>>>>endobj 5080 0 obj<>stream x…VMsÛ6½ûWì%SƱi}Y±Ýé!qëÖ™q§hÚC”É@$(!!E)™ü÷¾HÉt7öX!µØ]ì¾÷v? i€Ÿ!§ü›UG¯gGƒt€—û?vIg7ºHÇ4+h4 éå0N_Ò,Vše‰Òžþ²ÆËÌËüµpòêÊyáUv'«…´ÿ«Ä¢”ô ??Ÿ}<Ð)\ÍòäÙ7~<»™àÀ¯OÇã6Bò'|’_ ?’¢)¦É­ör)íl·–}' ­„£u—¹Ì¬% /UÈÉQ³RÙŠjÇ”#7TÕÎÓB’ZjceNpƒÀ;ʄֆ¿i“Ž8ùÆŠõZæiûr4á—3$ŠÐÛUÒ¯LîHØð&V焜 i]ðpȵË9‘eÒ9d‚ …D5 ÊJá81”%—Vm¤£ÂšŠ=õòË•EGŒ¹Æ…㕨0ei¥—W±v÷[|:¥ã1ž'1ÔÝ®×]’[/5nÖ{Û…}ýÚ{"Z׋ReôÀÑ<™?§‡¦{€ìnŒB?B9öa=O´QÖ×¢¼ õg›s œÞçÉùÁþ›Ù¢À…åÏŽõÂt)ß'RÌïE‰?òý®êÑAËÊKNR ºååè"æ'£Iú’®MUM8c*õ|ÇS!…¯­tU­¹“ôâ‚ËÿJ“¶TÒ¢rY8´Æ 6G‚Š…3e â/„S™#SÐõÙõ‹øȦt[ÐÎÔ”4’I±¤EíÞþ{û;8²’Ü B•ò$Ø6ª,¹ä0ƒA2tCÚBd­ÎTªâ˜,7 ¹úäÒeV-ÀtúÃ4r#-³ôV¨ÔC9ý“'©M½\‘7¬y Ÿ‚´ÂG…§R¦t-­à0‹ _¬—LQëPQ*õPËUТJ9Ç7D"œÕ½| e­¿î¨;ͧFX¤NÅ8çÚ1‚/{xYJ--ºc¤D„úÆPjhA%àc-¬e˜õaÆ0S2ÒPDžÖ•Ðj]—±Å®V>,]+X© JbÕz)ÅF»NÚˆ²g¢°Åý”‹ÂÀ“¶± 8 ”Àl³‚®Qˆ>.SzÃËAܾÛEž)]*ýÝ'0&tmOÜÖ=ëƳcâm誅I¼#wJ~®îýd~ Z› áÛB(~ ­yr<Ž“t|Ö,LÄÃ×Z6*á'›Ñ¶Ÿæ•PxMó¶ôøOôŠY^R&ÃHš;õEš¢3bg}2ôN Fa¥ì¢RÚ†4Y€u)ç ¾ÿ_ÏáJ@½.ÚÆ‚ø<ãÇÇ=7…Û¾Sïß}|¹ºy*`›y ‰ótÈǵnã=«[Ÿ/Úxx1IÏÇç4Åç`68ÖóÓQ: _MVƒ”¼õÍíÇ®­O_Æ©]žÒ«°b±CèãΊM–7ŽÀûóÁ4 åÐññôœýü6;úûè?üüÍendstream endobj 5081 0 obj<>/XObject<<>>>>/Annots 2332 0 R>>endobj 5082 0 obj<>stream xV[OãF~ϯ8¢E5»ŽIì U+µ,léCo VUSEƒ=&^lwfœ`ªýïýÎØ˜Ë–$Š<žs¿|ç|Mi‚9ÿâb4 &xÃSþûýýhzÇ…AHMgÁ¬=ät1zp,(Œ¦=!ß=8âî€ùww,(š ø~¸|`„³D_ÓþÙŒ¦ºLaíü‰3±w¦UA?‰µð©Q5Ūβ+YÒFgVâE")Ïn$^fæë½Ë£ý³ Ë '4à ŠpJ¼óB\KÊ ú–J¹!w\x‹½o˜ ”lCâ]üyþþò¯_O—ÕR,gËe¢ê«\’—¼E•ËÜËBØÙì)wOâ®—FÚ…'ü ¾ˆøcMÏÒN}|_Iúás´A <êõÀš¥Õ¢4©ÒÅÂË _¼dRª¥ì]ì‰îÓ4vq‚ùü#ö}RdÖÊ$o|—Ê •Êrš¨PÆ’Ìåµ(-åJÝdå5‰ªÒJÄ«€~T¹–Ú§ÌÒFéC¢LÜA˜ò+ˆPŠVB#å ‰Cì YÚ€Î-먔1çÆªÞßí¡VkIªlÍ© +å"rå#›J¢2¾Ó¦`§¦¸6VÙ°øR)l­%Ì1à…V•” R#c&ûUmɨBÚ¬íJæ•ÔSÒºliIh®¡uß8­R˜¼yíôÁ½$KÓ,®sK±0Ò¸îŸÓ>qgŒÃ9;΂CtÛI.ŒAAZY6x“ÙíºsÂÜ'‹9¹¯ÁûK‰ ¤]^`OVÂi,‡gë1¸8Àv%h6¨lU%d¬®ã.4ÈTÌfÀu§ž› ±X©ÄBD"G­´A¦¡iÈd\RûÆú|ûî*©‘í®œ{a®iwÿ¿ÈÊ8¯ ;œ•‰ÔÁjg@³û©;¢˜›ÖTú¹…íCqDÔ¡À­ßøwC¼øÔ[9]^£œéUV#ì O•AJŒÉ‘Û¢ú{: gÿôªZ¤b2|LI6]x ówZÞîµï~‹½Ÿ¾42OÇßÝúÝCÓ?Ü=€V$i‰£}Šê‰Ê>l[zÛõÁtï æy/»p¿Y]^u!ò\Å ÏdwRÁ·NÉÞ ö®áDÜ>±–ýÁeƒËæ¥Ë;\>Jê0 ë'œÃ ´%pßrðñgµÀ•¸æ^Pÿ î¥Îg/ô#öØñ‹ÆXYª¶Ë^.¼uGô¢%›,Ï4¦ÊEó K½êž¶ÒÜ{u¼Î0\béÄÁÞÉÛ·„†' ÐÁ“¥¦ºD¯æ C’ºú€näȉ²¡hÆã1Ï”-êfÊ(ºRª«®/1ûe úæRËÏbjD§·±¬¯0…r6¡‡Õþ‚§ÓîLÙÓ¶¡¹_`¶`{žßNÙç~À*­6<æHj­0ùx­)û‡ ‰9ØÄ¼áé ðu4ŒÓ ÂÜÛ*èCC.Ã$r˄ֆ7!‡´\fmÂx·qQAª:O†f{( ÍSm-!q&Ü{_ å åÒg–í†V 8ÓMkYJš`{ÃÀc—÷7x×¶(ilýW2¾é§~"­Èòv§5ê¹Kµã.¸Ø-½ÿOê±_J½~ÌwEsÔÅ2œÌ‚ƒè€æ‡óàˆ+‡å8 &ôNÅ5¯'nƒ`¡è“–v|Ø‚¥›ÝS:ÙçŠh·…maæ8˜Ìƒ(݇Üh>çW§—£ßFÿj+qÈendstream endobj 5083 0 obj<>/XObject<<>>>>/Annots 2334 0 R>>endobj 5084 0 obj<>stream xíWÛnÛF}×WL¤ ™’([r]´uíÔAâ´‰Š €cE%ÚË]f¹”¢ù÷Î,/’(;IÑ×Ú²ÌÛÜgÎ~è a@¿Cù¦? +ü5䯷/:Ã`âŸB0žøHaxrêÕ™„wÝsº;9mžuwwÎS†'þpGö—éŽ9gÓ, uÃLcòküDÎ:½k=*´‰V c‹ %¡°˜ƒP€Æhó ´…Q‰Z@n…-ru„0ó(\›¬T‘ÎÑI¸ùóÕ+Èt¢,]ÉÐ,E–Ϻ>ü†!!åÝé]gÇÀœòò$Í$~a©×°Ñ¤Ébia)TD÷íRØsì_ àÌq`) 4¢³È{ŠCÌ\8©R‡ðwmˆ£÷žmëjS(ßÌ igÝ!€»PŠœ‚–âÓ'ø‰~v‡j5ëÿ|E»à›3/õàèN¬D_ µè¿)ì›ø5¦Úl.9•G³î-˰«kº4z}ƒëZ•3Go´TºX,!uÚTT ž¨Bʶ™Ï{f÷ÏV:‰àY™¯ÕâÞZPó 5Aåï¶Ž]¾Gþx<á|R½¤h{¬ýÑ¢¼{ýbú×ï—·Ù­3%(U©ýÚj0¨¾frH ™ÑQ"·¯H™Rë{nPö‡ÔWmðåv¹¬£¶§î2("8JE¢Ž€‹èsývÏá {É…êGPÍʆ~ysÝzSÎÊk´Kͺ_‘lÄê|±[çÃñウP)’X¢f^y\Š ƒRæñRÆ”M™Ì0Îï*‰r"P^#‚X B#d n(9ã±)®µ¹ï¹‘ 8„Ì5y9²>\&T|¹ ÿi~ ­nuÆ`4ófÝÿù_ r JC„„8†:”Ö¢¢2R/Úi84Ô3^.”¨-oÔ›ÆëAbÄg™L0bQ‚bX‘Ñ"höMîÃt‰m­;ð¼íTÏ©ÆÈ3 êÁ•0‰˜K¬ÈíZü¨ÁLŠLÓæ²dã¢ñüycBvgŽÜº¥Sу®Àé®CåF¢=FªT9Ò©éjU‚Ýd˜÷\åfÏIüj0h¯ÑÚàP±2Ç!ì<iª‹eÿ(.úÐLÅ…„˜Š-¤´VÝZ‹sä(\>·“÷œrû[Ê=o*³Î]Þ!,BŽ'P®@-"CÌÂs0Û.FîT7¬§¦!žó7. ©f  ê°{Zù•+Á /.RÜ”Zb GPäTG]±Þ#•PÑŸ —e}w‰·D\^¥Ü‰‚4µ–ÁÜ=Ç™äߌF ´‰Åô€XË6Å üßic&9÷ø\ùLKÖFç纰·:¾5´d¾Ço+f{”c‡l4ËìArPJn FM-Þ:ëŽè=(w0;ñÀ>¨Ïˆ"P5ɦ+­/ÜÁ~’²b.“ÐeWlŸVe|æ‡dVЉ”«µß‡×Ž–E>LfÓEu«W q߯›®¬ÊgÇ”¶£}Hpxªåb®WØkƒÖ–+45`Ã[¥€…K ïi<÷˜OR’¸ci_2¿³Üè4Æ%—£Ì¸Hÿ¤¯£r˜G{¹4Fof ^•¹– >¸BÐNçá!nxcFhFE dýÀa ßjYyÊQ7‘ÌÊz3clÙ¥Úå–‰•Ž÷5pá]Û¥ßíÁšã`G¸¤¡ÃšƒçÖ°¯¡V–(j…üJBœ`C§)½À`ÆKŽw V©s;à1C‰ÂìÜrb¤·¢òÝÆ5̇"Y ‰Ô»”Ò}µÞS§®É][·ƒ{"'†«D¹Ül;¢‘«Ñ䮣ûWgUƒÿtt ã³3D^›Ç½pþªÃ"%ô²QêõòÉãI9 Á‰?¡×ªË†7oØ%l åZv¿Xáé`ìzÙ$³£ñ„/]N;tþâù†Üendstream endobj 5085 0 obj<>/XObject<<>>>>/Annots 2340 0 R>>endobj 5086 0 obj<>stream x•WmoÓHþÞ_1ªàd u絜î$®P®è@:ˆÄ—Jhko’­l¯ÙµÓÄ¿gvmÇNCO¨mšõìÎë3Ϭ¿ i€Ÿ!¦ügGƒp€'ü1äoÆ“ópDÓùy8 ŒÆç£p^¯RúÄûi:›9ÙhÎêE#Í¡†±È/XÔYf4™@ãNÖYf4›†pÎ)áseFó üÚÉ:ËŒ†ƒ(Œ:ÂîÒ(ê¹Ó]C:‹ÂóÎÙñ`Ⱥ&>Èq4ewÝÊ…ÒY#N$«Ùë±ã‰KÂp8'õŠ…Ý5Ì"}ƒ®´³öN»R8Ù¬3Š¢svÙÙaÍÝ5¤ã‡»“vÖNûv»ëŒFƒ)ÔžýkшÉYÑÙå§ÅXšžãKâ „/q°XKz¶¸=:»¤Üžài®oÅFÈûX¥Ò¹7*ZJQVF’²Tâ´üZ©He^R©èú©‘'”(+nRYkj,Ò²Tš>IïÞîTp‘JaT¾b÷t:ŒWPûfÝöWšDÀwmœÓ‰Z.¥‘y,IçµÐEìS\+nµa“ 9Ђ,F0ˆŽFX%ÁÓ^²®ƒc^‡©ÈWá›& ãëg´’¥*eF߇¹Qi¶žÑ7ÉçèêÍ?(e¼¦ëÀ–ÉË—º*¿èåc’~“°²¯è6N…µˆJ|ûFЭÌ7§^ª<¹à絿gìïY×ßß÷Ü„"wr±6ú»œÆ:þè¬Kc´AœÏ ¸äô$¯ÒôôGÏL³B†‘ïø¥ÖÎӽЊê&UñËÞq¤¨Ýÿ¼Îøu €M,ïážÛCggô^­Ö€,‡C“ÙCm§8†íÃ.¨]“:|ŒÂétÆQp‡­d.(eB…Ñ÷[Êd¹Ö å0݈, ïŒ+Ue%Å:/…Ê–e§C Ìïh›Ôå…O„¬ÏCÀhóõ}/—ûqÕçÚ‡ÜqÀGúι£¦È ¦÷í8ù£é”÷"+˜5ÄÞHZ*cKâ”1]лWh“4åÌÙ-’xÏ‚ÜK_¼8 ‰«tÙÞ¹;•¦(S‰bd…Je“"G6ÂÂ3†H­¦™l¤±"¤+àÍÒZßI< B[«ÀrÌw$Ðz`én­ÐÎÎLm‚* ÕÐ.×µzö‹Í@eŒx `¤\4Λ–åÜÌÈÀtþ-¶…ÌDaëíéóÆDK1­–WZé¨{4nÐÌ\Q‰•<åž*$>Ð_€íiû'T^ÒB“RucHo‰|"ß¹Oßä &œ##jÙj°~ pm|ú|õ–þñjû[vÑÄkQ” ¦Â¬dº%Q•:cÿO8G¸’ üÅÒðØ$îkKz ÊD¸à5X8ã˦(ÉðÅ•Ï$ Lç"e2 Ö¢*CzSϘÖT§U")‘ÂqK=.a8A…0pC“à>Á7S¡0FlÁa‹5ó·g!¾qÆ•µ [tÈ8Ã5t— ÇØV§v;lŸ²š@ê"â„9^Ì®8—å."TŸ•!xÌÐBã’ßÝv#ëËñÁ¢Ô|Q;]ûÂÉêŒÇ/ž¬ ëF`Ú»ì QCÓ’U<Æw¶Ñ‹;ӿЛ½¨£¿éÝŸÀ™’¶þßs#-¸åÐÕ¸áR|O/h[wä¼~ÎÇád4ÁË4pùkͯÓò¯r£ÓˆMç¬õÍâèߣÿøª™endstream endobj 5087 0 obj<>/XObject<<>>>>>>endobj 5088 0 obj<>stream x½VMoÛF½ëW ¡UiC‘²ä$è¡Eë@=¸  ‡(‡5¹’¶%—ìîÒkä¿wöK–XYN. Y$çóÍ›·üg0?Hgæ/¯¿fƒ˜Äxs÷%×ðò:†+’B¶‚$†Ù« ™ÍæÖ*†,¾^d ^^Oa‚—+£Ù8I½YTKh˜ÜÐF9³ýhã$!iб‹ˆ ª½]ÚÃíÌa·¼€ã‡!Mô"Ét+ ·ãa÷æàáéJ² ƒPƒ+5Ò]Ã*,p÷ ôAÉo%•¬xÉàž—%lXÙ`U 7L1P\·TóZ(ר#ÛÒª)Ùëಽ&Ï«ºh1ž7>¨ýœ‹¼l gEy D[¿«y´(,F ÒŸ³w³åÅ!À=H7hãìooÿäàþ wt„ s´,ë{]Ý‚®¡¡J!¦c¸£e˾S˜dª-5ü  vöóÑ´ßŇNiV‘ºÕ¤‘èYŠet6‡1LÑù ~ò‘únhùù v_¡ÕCüõ?±X¦£éíúŽæM1_È‹>Ÿã/ÏøiÃóãOÁUSÒî4CBgé7BÞ¹cW`ioÓnjÍs›úÞp´Ou;óCÿç(iÅ4“~ÀfëØšI?T3ê[f§Í |†£ Ô+hjch¼DñTBÇÊ'3ZPB—‰á·ßkS»§‡Û6ÜA©4°’U ©ƒéI¨”JI;â%Sh±²<-jñBÃ=Eì£Å¥5~Vßnµ«EÒ*[t´¥Ñ.tÏúœ6MÙ¹›ad\²\ó;öÃtÃÕaƒ¡ëÜ•‡¹·ûö–5ìw²¼ó8¢Là­:/6.I¿L5{ê´‹üÜBál)¬ZÖªVSã¬3¼àZíSºä›™s5 “9ªÊVW[c¤pü;v†[Ô’ñ2nû½œ>vŒdæTX–„:<Ÿ78>AvUŸVŠSç…;* ká®ÿß§Íÿ,âç€Ùº¦Õž f©7×–â{EXX»¡V)ÐZ2ÁÕä¶³ž(ì&¢_ê0ØïØ $*=ŽÏ(}º#¦k9(}˜.þïï¨Ðß6àŽšºRРï7þ/(ˆHÉÿE^®PCÖx:*.Ö{íúÉ^y]Iâ)¹L/av53òõáÓâí8!1üVç­‘<ûžah‚‚ï,Çs×_2%Wd ;£ÅÎ=]omn¬§â¶£é–lÅ$9³/g—ñŒ¤ ¾béì•Éø{6x?ø“;ç•endstream endobj 5089 0 obj<>/XObject<<>>>>/Annots 2342 0 R>>endobj 5090 0 obj<>stream x­VmOãFþž_1B¢ò…Ä$vpU¿Ð'ªŠÒ&Õ©R$´Øëd{¶×·¶ QÕÿÞgvÂ]¥ ”7ÏÎËóÌ<³_zcáoLá”ÿ£¬7òGø…_ÆüòûÇ^8öÏi2ò§”ÑÙ¹¸Ï)Ízûo]\n­øÉÕü™#ëÍ,éôzD~Hó„‚M/ÇþtzNó؆Ñ<ònåRTêQ’N(¤h¾›ÿÕ;½žÐÏâÜ0›sÞ|%KIÕ¦™(JŠDN"-5=HE‘*S¥éÇ“22‘Fæ‘,}Â)Qä“ÈŠT–´ÖuãÕ|¦ OK‘IR ÞÐJÄp(sŠe¢r¸¬K•/9/ä2¿·÷N*/+‰( Ð*¯¤AÄkm¶±6ÀÏâQP¤c$¯áoˆêJî¶T/g,d»~’:*¥ó&eTú}2À&_"µ]+¥ê3'¢Jçóùv›!Ñzá] C}ôÁÝ×[a­Ò”Ó•À¼qA<y äe’Ȩ" PÝFnzÿp™±£ìÐM#è$— ™€«®/dÛÁÊRqz}I<½ äoL™”`â_@ÞfŠEa7¾íÃl<ñ-‡7 mtMYƳұƴ¡žÖi­­Ð©ÐNSÛµG/“uÍØïZ @€Éf™3Z ‚Õæµç0’®WñiŸÚ [ÔhØËvkPª ·-·_KèÞøãLÇÌW£ÀžƒBùbï‘ÖÐÆ£}ø£Æúï,RH1ÿÝ:(Ÿ0g9YÕqì$ë “ åÚ¸·¾‘eV‚íCþÓößTw¿‘Òú².Н©ßü¥”¿â‰äІÅ;޽ßqe"2š–2— ¶˜•L¡E»¡Å ³rðÊËvÕEFâÄÃQVF£æH›Á$»« {j™¬ÆØÍ^d©rûʧ›Üªœ—ðÅC»ÃÁJ'º9Ñiª×åÛ$3îÔÏåúŸŠ…×EÝ=çþ¡ÿÔ5³|¢¤2ú †ëÞUÙ,­¦¬ÎwÛ¸CŠ{÷Üí¹m{Z:;ñ²X pׇí߃µÖ·qš}ºù8ÿóîÃ}Áåq2w•Áí§ÿ0‚[ Ûíá`2pg_+Ò5þ3¯š²{l¶Á]&óu]ùX%y•æ ï(¤šÀÍÞ[Ãt*§“Fºêº}wÍym6‹+Á¨uGëúÐù(énN_=ë:°Ñy‘Cÿ2 lÏ ™ªf/ØìtÏ 8±]ó²«pâcš*¶î¢ ¿ @_@„ß´b×ô"d&Ý*¶ºÐ¾îã–îq;Ò/N×Û&Û‹¼GÑJÒîÛ¤6vŲ*-/š{l0šøgáM§nm²ûaàè'Õ™Ìq3i®R1g;Mý0ÀêÆ6ÏGœæ‡yï·Þ¿‰kËCendstream endobj 5091 0 obj<>/XObject<<>>>>>>endobj 5092 0 obj<>stream xµV[oÛ6~÷¯8PÌiÅ·8YÚ ÇüçŸ&^ÔÃáæ£LéøêGêh2ÇÛñÙMwߣIÜŒ¢³hH×¥( ¥Sº$Q–b]ÑJÙ½KÑìO>wޝFÔ‡+:‚䪺¯ßþJ±Ð´‚Ž ­4 ÊM)I [—"óªr¡µ,É.ðÜ.$%r.êÌÒlMuÅæùÐ[BXÎR×ûóé3\‰Ô®]ÊÔ¬åšæ*“ý.íÅFW*‘%¿…ŸyÒ…Ay'ò"“çA?ÇPË ñ_Ò}¡tœÕ‰¤½»{¯‚68•t•¶>Ò›ÑíîÍÒ¨„ SÔ™°rêÞÝÜN÷éëŽÂ+Q»Ò|<7%Að¢÷ŠÔë>¦û„ùåݺ¥ àÔ£ƒûš¾ù(C¾Ž\”Ãh<>eÿ' YI2P¹\F#EMæ9—ȃ¦™DVdB¢"5ç£5­$RÚbÅó`"›[¯~j¹â˜@Öä%Ú¢æ™îlà;|þ¸®¬Ì#SÛ¨(¡gÚõ):§½íSæLÒm d|=ŒNa”IÚÅSˆ>Ôï¤ãÚkñþ·+ißpÉL=S·¾øgƒ433‘}rEM7²÷Åz³7ê¶šÿ/î¶•ûáo[À=JµHŒKÙŠÛH!*¦ ¼”sGÇò*CB¯)FHe…N1¯ulABÊÅXãGk¥²Œ©XI¦äÚÝÄ"˸]¹ˆ~ƒîP$®àÔ ™€.Eb[ô²ÖÚwÜÆ&ù^à쟻úê÷úø;Àï0XqLkCõèË'ñzo¬„‡Âº‚J*u¾ù —¢Tb–1—Œ+B´èpKƒ+Ô!ªÀvàm  ‚Œ!®€í61ÞÍTš6m8Dã0c[—´ ›BºAÑyèuÏ _d&Ñ;,šƒoæÍèð¢Mï@bÌJ.eyØ´¶;ðDK™(SIR›:]ÜwGÓÚÔŽO™ú"ÙC(„UÉ”­ G?EÐ8E˪¢¥2è¿ Ô!}®+˜€°Ó´2u–°Ã—]sspƒ‚`¬ëu¸ ¤ªœ{t|¦Ñfž„få¯C›íº|Uê0/dËg´)„†ÚÁ§,‘àf®´/ÎA[~›¾¨gàÆî™È/p+öÞQ‰…íº¹(š´@˜‘üŠñ–ó¹Š°ãÆŽBr.o’ɯwoæ¥ÉÝåÖÆ_„%a'Y+ É‰v>dØÞF-t£ðÝû·ŽbM`;ijÈM@é6Ì&玉EÑt¥6Cÿ]EÄHT B@ù{Ëç—œ§6Æ@Jà p®úeà+çíå7ÆñÕ† ï¡ý³Qt2<Á†Þú~eÖ ¢ýlâzÓíX1†¯}têqþ®=þ¤7ކ,ñàþð´Ï ™tþìü ˆNÁ£endstream endobj 5093 0 obj<>/XObject<<>>>>>>endobj 5094 0 obj<>stream xÍXïOGýÎ_1BŠjÀÆMó¦¡M?¤­ ª¢8B뻵½ÉÝîe÷ãVýßûföÎæL‘¢V%?dßíÎî̼yó†[‡4ÀŸCðß´Øúþjk ðpõŸŸÑÁÅèjе'gøÉ{|H{WsM;Wï·.`GÖôÎ_¿‰OÚ]= æOM “ç¤m¨½¦ Ûªe© U’ ¤Ê27:£Ê‘ò^-¹)),ç!¡7®¦ÔÕyFïÝ¢³¿PU:7vF¾Îu É’OÐþá7í…R§fºä÷ŠJå+“Ö¹òñ±ŸÐkX\òÊR4/äKþ¬nT³NÙ ›C Sñ%ùú/p£LÛ:šŒ8BC<&£¾e=c«·ïÏÉêñ“ÃAüy÷ŒV?tΞ³ã‡ƒý±2Îòr=Ó>´.qð{Sçi̶É<<#óÄ,ɵUs|ßÛïÐ_Ñ4ì^ꊂ+4ݨ¼Ö]S/÷Ö¼£çdžuŽù»ó ueúVe®|3•.¸'ç÷Å­ñN×Èå2`Mâê*)=lävÜÛ¾;Û´Ç›kíK GÉÉÉSö–CÏñæÃ‚‰¦Ì„2WK}>þñ £³³³c„<¦ªEåÆ1WóˆCïT:gL–ÞMÔ$_Êá… °WÕ^å´@šAŠ 5¡ŸÜBßhßg|„z:EÊhê]A¥öHW¡lªÅbŽ€Ñb®hŒI@q¦Û@ `%˜( ü¥ÜU ˆÔ•`|äHhѶB‘¤iƒŒ¥Ê+p*B<“5b%^·”Σ‚Zøîí!œxйE­UÚÃ?s³q™aà€ˆ¿l|]ð@|„[„UP:öèòW?Rn&^ù%MM~0Òèrbº ê%ÔM —'r_8ß½¤žNMj¹D´½¢ÈîÇhp‚ÓT‡¦qvGRB]™B't|YOŒMó:Ó´½ºýv›F)Ò'ræõ´¶i…JF•ýÀ‡­Î3¡þ ·ŽáXñê}‹Ì }« =ÞÙ*õŽfÚj¯*°âÔÕžæ:iu'ľ7aœ©×ØA\v™•wË&˜­{¥xí`Œ—‚§ZH&ô `äRJUÐ} þú8REF¦.ÏÝ"|>ÀÌ7»`ÌëUÄ„ñl{Ò&ÑÜ8ÃÎu¥7¶ìÞn®eÛ­Ùë™®˜Æ"¡îÞJŠð6Ó÷¶É«}áÁ}Ñ„°íciF´¸ úÒ~"»1­0f×aËÍ~d‰×ÙÕ›__^—€ókºîƲíA¸ ÑW5±´ÑuVmíî‡G[µ¥—ܲTSßôÍf.ÿ']êÕTRè5Ú¨þÑÒ…‡}ü+ïWîdùÀî4‡‰4òɱÚð -‡ï€"dª$Ù·/ â¢V:†ªB/ ïуÔë29ú nDUWÜ&ºZh4±5¹¶mš9‰ŠL#G'm0>)‘¾”Hïx¿ªÝǪëam¬ ¢¯?Ì ‘ Ѳ£G±ç±L´Wƒ$Ï(Û&ïu mx‡PY/Ê{^(ý¼ù`XEQé$ch(ò6R’ÆÚÏZÕÒ#dacYæjÎÏæÊØÍŒ «†bXƒ£‡JBÑÓ3Ö² $óУ”,½kE-  ­÷ŸPʈ$$YÓóWsF¨÷Æ;ÿ–ÄeœFm;ÁÑ6EÜe˜f6³ÝÈ€Á÷ù#sh÷ÂQÛT•ÃZtƒ2Nt0P-Šd.‚˜çÆc¥{ƒ; SPØ  újõèîs~`"ƒšêJe—„§¦“÷5³`Ðz1ÞIè{*îm"bMˆl%§ÃœhñVàØªE& }[yè]qˆ†ý2;ï܈[µ†Š•QÙoÐÚÁ€¢K ÈÙ‘N0uY¡h°ô±Ö£xg<ŹéŽïìº7ôD¡Á Ð?Yæ![¥´‘FH¿s›…BÍŽ{VÏDL³0œ, äŠoé!ACEI/qè“®Ò„cõa–EÔ’c…T€SWÓ 'xê€Úw˜80v`\îÜDfê·€øLè—ÈÕŽóJsucsÓŽõuÌ×Úš ~¡y&Çià5nwÏ`YÌ f¥-<è\×l”å$ÎG} Ôé5Ó41˜ê—”© BˆCÀ.N›_( GÉñè˜NNOxd™³?LôƒKkžƒÄEÞ‚‰.®ÜÊšõ†GÉirD¿¯¸úE²e>œ$£!~¥…£§C6ðòjë·­¹NMiendstream endobj 5095 0 obj<>/XObject<<>>>>/Annots 2345 0 R>>endobj 5096 0 obj<>stream x…VSÛ8ýŸO±Ã7!€ÉoRZ:4Pzön¦é0Š­ÄJm+•í„´Óï~o¥8ÄéõZ:0²V«Ý·oßêËVjø©S³Ãÿýx«æÕð…Õù×ýåVë¨åÕ¨ÓixŠ©]ká¯[EôÀöÔi×ì^£Í[vÁ[k˘Z-ïhm﬿v“½ÎŒéðâÕÔ!¤N·KýÀFR£¾_i´¼®×¦3•³ @d‚f)=dF%ãt·?Ù:¼hQ¦|øÖ-¯œÁTŽDeôð÷Õ%…" "™’;€íŠ CÕ²— ‰”¥öæe¡4’e? ŠáW3Îc™`1•±˜’˜ ‰a$Ùï(È€Tb¯ÝiWÞ‰4E|?bg‚Êð9Qû}U–¬ŠGýPÒHG‘žã4¥*žâNù$ìß@Æ:Aô"C¾9ûGÜÃE†¨Œ „“fR¤G4u÷s‚+¸–ysN„d)’É8 )Ó¥(ùÄ܈éùòÄçT=‡cº^“ËÑàz4¼f« ²ãhAƒ%æýû«ÛË}ÿU>ftÓ»½ì¿ìÒ7¶àøÉÖ†ëýñÓÊ ÁÀæ{ ŠÇ*‰T"iç[éóL«€˜ç¨rý×nË牦 X6T¶që1í–|Ç´½Ï˜ v_–®#Ä öe>ê¤ö’Ô+¾¤½=5ØÝ0^ó¾óÄ.m¢êÓnWQ ÉöæövùܶM¯Ó9b ÎE Æ42:¦k•Œü’+šLrÎ5]ãI¦i(-E‡Ái¶ø ÷‡Ò 5V072È}øåI¥Ý ,Í‹æI¹=Ø,ÙQ$’q.ÆXkB÷ì»hÙ@5FoD”Íõ1û:¼ø Õ8‰ŸœVœÐv¨ƒÚäó¶ÿgØJ•M—½ã•øÂ%!ñ?w_!4ÀA@»ÌEçÙ4Ïþ7Æßib+'±,€±t¶dk/¹ÖéRç‹¢ ÎÐù+”ÒÅáuŵ2Ù¡»™4FK"ç¶I4?ðDýµYXc@(Å´œÛšˆ¾Gc}–”êX®ê’RšO§Úd¨òpaÅuß‘)´²™™\ÒX˜!×ЇFI« 85LžØ£;TÓ¬9œ«(BHRZo–%…Äèá~Rš‡Ò²EPlUN|¾%‡)ü”û*ö\D:à¤øä¬ý¸6–®¸]GÌ'õU°zíùòCŠ!‘‰ÎHû~nJÁð ‹E¦béÑ™ôE‡v¾^E3$ÖQûœæ%L8b0p n,õ¯?ü‰qkÌ7vˆžô?#rùäKظKq°hy°D*VYºï¦=>”@IA°ód™ §F?-ŠÌ=ºÐÆg†üG™0äüH ƒëEL•±#-ÕQ¾RyKÖ”Ó„@¯±@FêÉjàùÞ§$ጻØQBP&¤MÜÙÏ£ÌׄˆÚy›†zž £ü(ZK8¬¡ÊÒŒ„¿êK¤.ÌþT«t«cÛz\OQõ°×M“X3[2a˜ç²Û(‡ß–Ñ«4 ¸RÓìuÉÑÊ`{’(/Ü^nB’ÛaÕ>:VΩJtŠ'‡HCLi)HB3ƒeÚLì‚T *cê(p²|Ø”®ÞÌ #=÷3ô÷?•ó š°\žÚ§Ád(6§ÚÄ1›Û­¼õ½XºŒ{¦|Ûw`sÕçf '³˜N¨V6½¾½êýóîî¾O”’°ÙI^…ÈJ3“¿ÊÙRé2)®s…#Äžå&±|èÝ?\ÝÝ>Öe«b’–³A¤É ʾ}ÿx)3,xvügÄv2™•½]NÑø@á9ʃ×+_—\u°ûC"ÂZŒ›sŠHÐìïÄÚöÞôú§ço{o êw—OÛz·åµ›m<§ë^ݽÀX¨x¶¿Ñ¾}¸ZÝc,1KœõÁ‘Ãì—îv­ã5˜L só¨ÉNzý­¿¶þH¶¶Jendstream endobj 5097 0 obj<>/XObject<<>>>>/Annots 2347 0 R>>endobj 5098 0 obj<>stream x½WýoÓHý½ÅP ‘–ÆM“6-ÜÄG) Õ•pè¤HÕÆž$[l¯ÙµºÿýÞ¬í4n ôNº£(ò×μyófvöóÖõðw@ƒ¡ü“­^ÐÃù9Ÿ‹³­þpô©SBƒÞa𨼉éýÖóÑÆ¿ÊÎhÿUN‚¦ÔïÑðÑA0Ó(òf{4 ;„ùÜš%¹ñÊ%•F¸´ŸH9r‡‰há´NüOeQšýY~—ý{•ƒ_u7²ß»-½eã–˜D«­)Ú|¸®æ5zôŸ»tŸfæê»–»n¸¥âÇU#^´ôR¯ÞÅ÷;m òÇݨ=TñÖ½S/½³LJß•Áf[B•¤ü³ƒÊâ¥ï éè¶VªuX§·4éµß­7Eá÷*_Íu°¾›ßöQ§½._øôܢũewj{?7Õ4ݼ»ß¼ ‚@î¿:$2¥.dØíªq§3škG¡‰˜ü¶î0Ï0½U %ÌjkRÙµ(*¬Ng¤S£“è¯ØñLºç»ÌrΘFxIb§jDª´°æUÞù¾¤0¬Pn(³f¡áÎj:ú2¼ÿøæŒÌäŠÃÜÑRçs4/…C§×¸æ¬²€<î9º›à M2Ñ)L3öä0'3Å®ÓUαÍ÷:&D”h… F,xà(։Ƃ´#áÄØU yjV•Š"`RXÉ,;WXÆrïb¦ìDÍúq(‘[¹œ ó#Á*’ý¹©ñªŠÂ³†5Ùp±žÍñ]¹Af±=…•t{!u©°·bumt"xEÓh¤/¦âÛq½yÀ)á°@Vj,*¥¹Ê2nR忬 cP{K pk ÙKNdv(IýâU^¤@¯ö¥ÄžöJÓ²FtæeUÊqÈlç%&å±ì€ëL\xbýô C÷Ò`—ß/hiy„ng‹ã/»ÈW×k³dÌÏ{´2†Ÿ pbàënŠÔçL$¥0Ì‹{@^# JSkкJDØxK•IQJ±_#ùÁg®™Ók/Ðt‹¸¡ÖÁŠÞÑ’Y¦¾8}û¯ÑÁaN§8uû'ruúrØñ<櫌•¹fÁû<''ò­¯Wi3bZ=væ8ä'!²ôtER‰(ˆ§ªˆÁ²P+ANx®t å eµ)½Øñð!E ·æƒ©„‚sšï=ûÄ[ËEÚ ¶ôg•"-´+›Ä=U‰Ž5¦)ß$ Rdeº©ZĶ/äæùǽÎhƒ›ëãc}ìl†´ ¦ú8×1—繉—TK(tèSü|JÍÓÖŒ÷Ê NªØú8t Žhx‚“¨'[(ìöƒ½4a±–·¬B.?î—»rx éê´:ž¥|eˆ+éZ^€>á">±wÔƒ>DŽåÑéhë÷­¿㊩Nendstream endobj 5099 0 obj<>/XObject<<>>>>/Annots 2352 0 R>>endobj 5100 0 obj<>stream x­Z]oã¶}ϯ˜§»Þv¥µäïܧýè¦)Š mô¡éƒlѶRYt%9ÿ}g†”EÊC À½ØE6æpΙsHQ#yÿ¾I`Œ˜Ìéïæp3ŽÇ8B?úñÛÀ|±ÀŸH“8µJx¼q>`šÄ3'æ|<À|/œ˜óñ8±tÎéÊ.çÄÈŸˆ±/«wT+Ì0>‡$YÅSü¼„ZÁ–ëž%S,І’Y7ž$Kœ,EŠ3P6…Y–«xÒ“„ÁÒ1é’hÜÍæ0Ï4Å‚/bÂhét…ICöŒëòUý˜©XЏ9>ZXeÍx&ñ¸9מ™ŒPv`–†<"}Æ*¬ÒF0[±qs$ÏŒ_eÍz&ð¸9>ZP(Òî6qŸ ‘>CöŒëòUZý˜­Xˆ¸9>ZXeÍz&ð¸9‚gœ1J¤«E¼=“"}Æ*¬ÒD$0S±qsDÏX¯2Œf<“xÜ-(” ÚcÒ>K…HŸ!zfêòUZý˜­Xˆ¸9>ZXeÍz&ð¸9‚gœ1ÊL'!Ï„HŸ1€ «´ÌV,DÜÑ3Vã« £YÏ7ÇG å@2LJ6qŸ ‘>CöŒëòUZý˜­Xˆ¸9>ZXeÍz&ð¸9‚gœ1J$XÓ\ôLŠô¨°J‘ÀLÅRÄÍ=c5¾Ê0šñLâqs|´ PÌSûŒ>ìi!Ògˆž™º|•V¿f+"nŽVF³ž ür½AªÅI¹É*X+Øèª9•­ÊA!”ªAWeQ)ÈÚ÷O/Î[?~)Ioý JR,tôxªÞ5†öM­¡)ZågÀŒè¶µ>@;­s®e­õ_1`¹¹Êo ß’F锘ŸŠ¶T·ðA5EVâ­ì@ü>Ú½®oá7½†;]纊á—Óº,”{ ¿Ô‚^ý˜•e ÷Ÿna%“h¾X-W³hýÇo ¾Ë䵊èý"-Öè9/ÀD»…¤˜u¨«“TŠËCäzWg(³F/ïNEŽÆW9<Õ¦Ø^)GÂã^¡O?Yµs5PÑea>åyÑè*ú]5¥:÷ŠÒqMÒÙb¥1|* ¸eŠ2[—Š5ðzñn­Gf/|ì—5kyçáF€¯êU•úˆÛçAá2Ö‰ž™#˜¥K|‰p‰ÑÔÏj«qýµÞ(•ãÆøE Í^ŸÊœvlÓÖ W>Grªà|T‡ìhöL¥[ÜdµúûTÔ8á˜Õ-è-œÚ^¿ßßEQDK®¶nzx«³ã‘bkµÏ^ ܧEÃj»%T•>íöPTpÐM‹×L£ܶ.'ztF¤+¶pÖ'xË*,KÃfË„åÒ%›5¸¢\ ÑïT¥êŒ®¹Î•µjdQÊ>¤Ó˜ÞŸ|µµëâPðåM’5Så\®{Œà5‚‡-]%þµÅËŒ{¾mxÑ:\,s‘òNÅò¿|üòý÷¶¶™ÝùøEÃd‰õá=ÿEžÄk@¶ñ™Š‹È׆ÁÁR)²\ƳqÀ£ˆhi¼¯<âƒr:Açñi~ÁàaPzËA‡UKgD ÿq /³UV é^hºïIð K‚ËT $4,t³]A/Ý ß»ŠÚ²ô—©Ñâ„¶õÙª[7(±*T ù¼ #^f5ŸüåeTâ¼/'•FPÿŠKÕ!.‚@ZTת오ɆŠpô‡¾”*s¸a¬ÔÕîj‡wƒ’’.6Bü­É[|;&_Š °xq®KóøºA‰Ëî&H’xÂõÙÐ¥ük"¿ò.}Àx=IÐø‚wÙøµûøs±»ÇÎl§ø¼ñJÑë¼?ð{9û#j[jÛŽu÷%s…ñ¸@y™ïq\F%cs‘ià|Hú ¥–høTýÎ?né ýãOëî|œ?¶5Þß®ö:Þýí0âã÷ÉKj·VÝýèA·Êôt·çû»¹ß}±m¾)ànÔÈýhÄw%¼Uc AÑlƒ]4¶Y/Uã(6fY]gç†z nÏùîIÍ*7xÌc²)º¼Sù¿]HÍá|%ßÌê:H[‡íϥΠì|Ø’ ÖbïÕé°Æþ ûêò±w§ W'w„Ø@Yÿ°ægƒÛ©­Âyƒ­öj÷[Ó‚qmÆ ì‡ëÌÝüŸ`pt}†×¬<™ž¯&ÓÐßáCKEs‡/°=UüðÃÝ?™¸Äo-±AJ)/'ü”^u‘óÔçÑårä»dX|·Æ_¸q0‡Ãæ\fòÿÈŸßÿ×8ÚµùÉÿ ÃÿgÅ2‰W³‘q ™â릯áf4³£m°|DÝ›éúi“P‡JÓ° Š'ø="͘,f4ôÃÓͯ7ÿË— ;endstream endobj 5101 0 obj<>/XObject<<>>>>>>endobj 5102 0 obj<>stream xWÛnÛF}÷W •™Ö-r’¢('iØi»q+r%­Cî²\R²ôß{f–d,ù§AC‘˹œ9sføïNŸzø¯OÃ1ÿ³×;½¨‡›íÿŠ9¾Q¿G3œ¿ÀE"Ïqw.š2—T©¦8UÞS¦Ë…Khåª4¡©~¹qµsø®GÏ£![ôè`0ˆ†CüJ:y5MML¾T%þY:“Ь²ñ¤clIªKçea윦]âq—®ÔRE™*Ñk3?±¥žë‚’É>}‹¢è¿à« ö@| £ñøˆ}q¤°¢‹L'Fkzÿᤎ9[yM%y•ábkÿ¨àgƪ´IÁ"‘¥ÞÎäJó~› ÿ„ŒørØå° Cœtè1î„&û¿<ˆ‚²‰$ÉÉ3Ô¥q¶.VêÜWJÍWFÁü ÷óË“ßßþóñÏO!W˜;~uzJïQŸ/úZeyªqïK¨&®ÞÚ%ý|¥í5 DÁ?þáÔ¯¸è5vW>P¡¯}4„=7½Òq8‰üI…Lå9¸åiæ :¦†¦çÌ¿M;ÄÈÝ:—:;¿u°Ðã…Ë £J-†šP:ÏÁwpÄYO«…‰¤pÌKÀM)L}òýç38‹ÇÆ“uì…I2¾ÑÅŒS®“@Ÿ•+­­À_ª|ø•8ííO%ù*Ï]ÒTüTÖ›¹…ßcJT©á#úíôR]9Ób„—ÜJnͪ4Ý¥Pv®ÉÍh©ÒJ8µBbÇb’f…Ë$’(àô‚8–’ƒÁ˜sŒ¢Ñ€Þ虪ÒR^‚ß`È:{3#]%=¹‰6[E£¦¿óB/«°ÖÔ6µYȶs¯î°'}Êß¼®M[É} ¨<ØXC:7×å"T¡D –[3'oôÐɌ֮ª5‰'¯j¡ù|&2µ¦…ˆ´Ü[›“?&Î ´¨Jt𛂡k€_âËxR·w#)"À+Išê zøµ/u†·rmmË®¨h=XÄÉkVƒ—…®­rÏýmÍ5~DEƒ Oé¢nÃÜ:#&p[?Ù‘sÀÎn„rfâÂy7+(.MܪÑï:ú À‹=ŸœÂì¤Ó°0°+h°è†ø[ϼ?é´nEÆw ©¨J‡5É™Íh¦vYpÀÞ³ÂAyy³Šq-$”¹ÈT^÷7hQYèÏŽwó…I‘R¾@-]šx‚°…9ÅÓ!góò~ŒÀX,B\n hVÓ8ŸÏ" N(+¬@¥ÕVŽŒA>,Wìë»+îvð }GtɱFIk¡Ð¿ÝËÞWÍ‘01±Å€ÁYèN…ôÅ͵ՅŒ`€ÈØAYblqIÌç:63,¥a>yÜ Ýcæ écQã6ÜG.]{õ¢]‡P³[.¤p#:¼:câ–ûÖиÞ+wûô+í›W¥ìˆiý£Ñ–³IçÉ'k,°ÐzË6d½~I{ÉdbŸt‰vûõ~Ù¾+;wûkÏØ”SÛÛô­¯±v‹A𩏠ë=„Ùê¹ìËÛF÷~°É‡TQ2U¥+µÆ¥÷.æu ŸÐNòK|[DÅW5AéïÀ°â1‚#䉱OšÏ™pèÇMÕà)+X¨}Ó‚‚*â™WÔJ^I¤,Qö@Ývºáp§‘â3—Û·}žÃ˜ç»uƒô±JÈ€M‚^ð0n±Ðmʼn„aUvÌœ ëÚü¹×Ù*›b@Ó xø²iÖ Y‡ˆÇð€QkNîngÒ,¶!º­ÌwûÛÇ7Òëä)œ²v .^Öô3¾û8tïEjwo8¨s© ÖõVU¹6),a[‰ñ‡É¶-ÙìkŠ‰Ú¡_²³^²¶ ýšÑÆÇ°Þ·`ªÝ Cëcfá3½‰âKA±’Í/çÍ÷ÚózsôFѳá3õ±\ó®„!q0ˆzôÆÅBR‘@ßÉáìÁQÐÙÈûíF~ÏÞ̯>ë#Ì1Q‘áјo½½Øùkç‡Ýendstream endobj 5103 0 obj<>/XObject<<>>>>>>endobj 5104 0 obj<>stream xÍV]o7|÷¯X"7ÖY_–“EÑ&u“¾µ`Ð ÍãIlyäåŽ'E(òß;KÏ–üQ´OÛÉåîÌìÎ~>™Ð_š-ø¿,O~\žŒ³1>ì¿Õkº¸ÓëlFË‚¦cZ¼™d‹Å-ópjLK9ü´o¼*3×ú¬ªµõÆ®†ê‹(+£²BH¿.Vg«³oÏ–œ\\Ïi‚[m4uÑ†Âæä7Š¥j=í´1t«ÞÆ;÷3M§Ùl†|òáoJ*½U9 KxW­UMoiÁw›ŸÉ‡WÓñ³ï~´xV7Ô%|’ðûJ•¢"|.ªÊh<á ¤ä¤lëZY©rE8œRŒe ‘ÈáƒCÊ…2£ß]KÙÖªÐVÅ—o÷Ô´xe¯íš+q•×Î “ʘr•¨E©< ´ø™Ñµ«SÊÏc4(]Þ•wA=‚º:WHzuÆ’uÖªµð€•þJ„ÃD/&ô½Ðü.{Œ‰ïÅjxú8%ƒ|µ²§ç¢ÓA÷ëaFÚfpø¶ú‚ÊÇu”êqÐAˆú¤ÖçR4êpérŬ;kö$¼rÓq_¯ÛRY߀3áMéq¤^nˆKà6¹SÀ}ã_“ì‡Y*xÎ,!ù 1 ÌÈ/HP’4×TJêBË^CP$:Eté54`nëÌ’,]ͪ‚ŠÍýGÐB–P×hÔEFZuyL‚¾ŠÖ œÐDµð¨¿º ïO7¦w¯^…¬FMìuºÙ(K{¨9J¾Kº€2r£S¡±É€­ûç«¡þÏ­0€EåElE­Œ : ¼ˆæ8œt¶ñ\ÛQ>A"Ï5“p(‰X1η{+Gည4èXŽÖü›fíù?4dŸƒÇ²+›‘raòŽ„ÛºßèZ¿‹ úáÖaÞ$5ÜMÝÄnœVÏ7õ·S[UGò’⹟"7}w>ÁXèø0ݹ0åºV’)„:Š{bGûõ¹>¢ö®Ò#Iœ“†ðÔïïyJ*0ô`jêè,Öqê@û(êÑ0‰¶Õ‹¦qpЮAs¸¦uíÚ*„çFP² s¾÷¿+u5”QÓ7H“ŒbG9œâY–ÒÚúš$݈¯I×Zì !˜<§Ç‚†KOŽö0—•­ñz” ëÙþq^åQ&é@˜‡ð÷Ø7„é™^*ð)ƨ]cŒþ"¶‚zÎhÉ+öžØZh,ZTÃÓ ø· býgçö«! ¥¢Û…ù ¤Ö~s<ØO©=†ðêìyoˆÁ“Ó²Õ¡÷R½tGËdSð»%œ*S­`«ìeåj/ Ò¸ø5ØØcy-x ‚Ž>‰`Gîëno˜ŽçÙåì’óq’3M³1½w2,ÁO¸PìÎñìè*¶R`pW†©²2S±ßóéËñ"›M±êcߘ]]ñG?-O~=ù†¹§Áendstream endobj 5105 0 obj<>/XObject<<>>>>/Annots 2359 0 R>>endobj 5106 0 obj<>stream xÅY[sÛ6~÷¯8㇎âÚ²$êbogv“uÇ}èÌn4Ó¿ÀdÑ •«þ÷ýÎH4˜¦M:›ÄŠ ðÜ¿sôëÙ”&ø;¥dÉÿÒül2ž`¥û(ŸøVþ\.Æs<ÞP©iËoÒòf>¾•¥é¢]_ÎÇËèÆ‰ d$VÂ|q;žD ²ZÌ’?–Þc6$^Ö—·PŸMëÛÙ8Dì°鉶vDX9;";IÙxYOØþIØ ‰“åÙ8Äìz¢Y9;"B<’³!ñ²>IÆ+±c¶ íˆlœbvˆN=ÑV©+gGdÇ#é1Ïë‹Å ÉÀñXL;b'‚˜¢SO´(ceíˆíx$=fCâe}2/¢vD6N;¬N=ÑV©+gGdÇ#é1ƒxWÁ¦üÛÿ~<[.QTæsìéã™÷˜Ót>'Þæ%¼>OnœK–IÚØÆ‰ æ1¯g…Øce]ÛñHzÌæ«[”éä†?s@1?ì»@Ü“¬V²9Ìa–}âÍ!Íy=Yµ ¡ç‚ØÆ‰ âkNOk±'ÆÊº ¶ã‘ô˜%É%AÐØ t€þòÄVúÏ9Í'ÜÌN»CªËz²d"7‰lœ">°öôÔ¶EX9Dv<’³5$¡ Ã>íÒ=‰¼gì owHu^ŸÝ®\×îuØÆ‰ æ±§§¶ce}ÛñHzÌ’Õ †˜©`‘N’î‰}à?cw±‚uö]Þý÷úìúnAÓ ­·„‚˜Ü`λåŒÖ``‚r³NGë׃ÎÕáÝúùŒõ˜¢`ôAWi™ê̼u}5„Ó•{ë ³ÇdµäwŸ‹¬OþÓÏ÷ôžjð®Æ´ÞéJÓ¡4/ÙFS½Ó´Ñ[Õìk‚àCV<‘ÙÚwi[šœÞ_¿ÿþ{ª 1—­)©yV%/=Œä‡w”š³ìN+tàV+–îé5e»G?©^µ.s½ÉTùúõJ2Çž–…ª³>¡++xÛ){³j- ”`³Ò½ª¬·D'Ê›ª¦Gë0ýk“½¨½.j Ø6ÊÞ<9›ªƒN³m¦7"~éäó‹çˆÔ¹0‡ã{~C¿qѬzŽ“wR¿*žW ãÜl𽶏d½;µšß^톮Hë›c äè²ÝmAš´¶@ u„ vEÓÁ{S¼è²B4,àžÅdFÜ3ÛÞ"Va"õf­Û*:î²tGu©Š aÏ–À”ýnqʦZ³Â8H”/9¾À.@]UAP…ù¹U¸ %2ºs„£z„ Äq7(‰9z‚Æt_¨’ަÜTT ªMq»˜vNêµB¹®wfC©Úïé J…gpf™Õçbjšš™ºR4TñÇT¢û­‚óu¾lƒÖ庂\bXÐ š>“ƒaŸü•¸†â»ÛDbF"[êº)‘œ[LßUkt`/S7Y©ÓÚ”^Æ¢åÏ£WJaKî@Õª?™Æ¢`WÞDäïyàß .~ëšÁ‘!W7tV»^ÝOä®ãt©Úu³¾óQ%u!yÍý½9¸Îîú:Šã˜>jÛ!Ãîp®:=>8D´JV⎀‡ÁèKPÖŒX…à[ê³ë ªþÖ@£Î„ ìádÔ %ƒU„±QA;`}j ¢¼ѶÐ8¤ì‹ *™Ù”vZä–Û¸—¸(‹œ¯,-¨•\|ÀNCf«cP²ìÀ×2DKøKÆŒ"Hÿ!ÀZ"$h;xXçÕÜxèzIéã‹Y´j¶ýÖ5aÌP¥9”™ªíÔ6öˆ4MLÙݸ„z±1Oã÷)<$æu°ç(p8>ÒßÚù÷¶–è‹‚õç*ÀÛ…Ù¦cèß:þ+#ijy%è!L¬—Çâ3jEwEG¦XµåëÿåxºXà@”Èiƒøý–^MCÜ¡eV3`ð\’9ÚiA`hì0øã| xF¬³´Ù+;$^ ù1ÃôX`æ^ñî‹ä3d’Ôì÷+xØçcæNçÖiî อ¢&ùsÞ½¾Ã±Zξ£gn\ÕñÉ.·GâѹL*Cyö´“3›¢'ƒ¹ö°W©=§m³b#ù`»-:«¡G…s­*^©ÐGBVUøN†Ùþ´FöÈ¡íÿÙbËG þüƒ<ØT8†eæÈÚf>¾ÂÅçìNܱÏ>éc&Ò9Ò¯ãêÑøË8YlA(@™-Èí!šcZëâ’enK­Uùd}Žß|f0 Ší’B‹+XoGM|¤2¹=,U/ª»’ø^£˜µ¬g8 ¸³ 9ÇÊ2ã@[Œ˜µ,¸ÎrĺÔ{ T¨É¹Á=bgRTbñ)Ê„° 4hÕj £˜d9Wº®· ˜Ä]åõ„=Ã2j¸t°2K½Õ¥.Xqͱø³A:Õ;%'PÎ.«¼m«=®2ØZÚiÀ¬ÄÿæÉ‹¥V{† m¾Há=s8˜Šض.dox/ L{÷”è³v¹å|^·1ÝAñt7fv“CaŠ+t¸•Šk Œš¬Ñœ0*Œ›¯´MÜRW\ e(qlª*)…º>jLÑl«ÍÖƒ‘-ùÅ«Ë9=fµ¨ëW©½)ú%J´!æèâ…¡ƒ)kÅ2€/ÄbUQn>/XObject<<>>>>/Annots 2365 0 R>>endobj 5108 0 obj<>stream xµšmsÛÆÇßëSìh쎤ˆðÑž¾P+£Ô»݇©:%( À M&ß½ûpÇ…ë4­$Ý-î¿{{¿Û;’ú×CüëC8¡ñú`è ±‡¾øôåÓ÷ÓЛÃd6÷†°ßz¡iep}`·Ñ:ò=ß¶Zm´N®Õj£u†^í±V­ó‰7²­V{ ïw­AàÍpB¡Ä<{4=jqÌV•§7¶­V•‡sTnÇÚm´âüæ–]`3˜²ÛyÛ ¯V†” y’C²Úhsø¬ÃV«M©y56ðCšžñŒÚµÛðlDÓi”í6Zç³F‰ÇZí5„ãI'f»ÖéÜ›ZÊ-GüSyOPA0™àWbʇ¸De+B‚ñSG]þx×ï”Ô,íGÊ /áÄH²—~µ œ¡KÍ=ÆïÊ™Aì ´Óé— påBÕ‘=ÆQ“1ì' ì õ«…mmBö˜®šÃ~&®H³<ýjálмh~ì1ŽšŒiVÈJ\¿Ü8 ½«:²B ²äz!aVŒÏ1œ;¼)–v„ÎÃëbØQÔÌb+{Œ#÷B_Eά¶f±Æ¨¼ñŒº„ô«™ÕÖü½léª}¡WQ3€hkŒÊ[³B ýr†7Í‘ðÆ71ì×7:etÞ4 ñ&ý:o{)™V}ÓÔÍ"¼Oj}cO!ÌŽ&'„¨kŒ£ÖKH¿š°£úa5±¨¼ñ|B˜MMQ-ÖG­~9áMuÄrbQx3…·Àdz“jø˜ MˆbaÞ¸_å­u¿Ï›¢fxS,†7ñ¤ñ&žB„E΢Y¬1ŽZ/!ýj†7ͨ±EãMæã"ì(jÍbqÔúé—3¼iŽDŽ-obØç ó0aÜðjÙÁM1mÜ­ÃÖøÞƒMÑÖƒ &nTÒØÃS£ˆ š¡áHáÃ!øì¤ F¯–P¦9a-6t¥l.*˜EK˜Ð íGªŸˆ^1áKóÂblPè’þ}¸ÆcórÁ½«)‚‹»U¸Ï{l)R–b¶Ä‹Æ{qx`P-ÁA3´#)”euqè•N4,ņ®”Å¢Cc¢H š¡áHõ²Ð«%\iNX‹ WÒ¿ÏU03\¹EK1WÜ­rÕxÞãJ‘®ƒp%^4®Ø‹S¢h š¡áHõÁÐ+%”h>XŠ W<¦D‘4C;‘êe¡WK¸Òœ°®¾]œ]Žð­ X¬ð´ÉXâ 8Ä7ÍñÑyÉ:J3ØUæ÷§p¼xtß\Ã7EŽÎ³4ªøM‘æuRBUuQ¾„û8†Ð »#ÉÐHH²è®(£:©`µ-ë[ä€ß¡ÚÞ=&qíÁU×½úþ”{Óüu‹m}õËCÜàà¢d0ðœÄ‘ cÀk#>•ÆQ–½Ð#g—C˜añÁ)Cà»laˆ­åàŸ×Fðæ(ÍoŽ¡ªËm\ÃeQÀ ¼þeçÒļòáprsd?yrsü‡Wi¾ÙÖoáì„sY‘ß&§€ ØÔ%œœí©½þu¿«‰§Ûôm„z@m,üÇR&Õ6«1ÐW~‘„ÁIpjD²ä˜ÕfÎf¦¤þ‹çy¿¾Ý ÚÊÅ—Ÿi`vñ‡n W7ǬÛâ9àÅÂ÷'SʾL ™Ãœ2«"ËŠgꈋeÏiüweýT±=2ŒB¹Í’ê ÝKáöîo?|Z˜uûáÇ«‹ó÷ïá‡è)ºM~ŽÖ›,Á¾Û]èøó»ü N“üéã,ª*úVî%‡(ûÚ?².Qyï£jÁû¸y‹,¸8š§›Å‚»4Öœ(ÑM;ªöŽâÅRÄq]x7Ü=éòæ˜rà:nl˜’^EtëZM˜-Õ¼‰jÎÃ[—Ï&Àfb÷Íñn©HÐÀ…»‡u«Ï³~#%?(®êm™Ã£1wVšwr/¼W+x)¶\š¶T7¹HFu–Xâb½I³¤<å§ÖéýC ÷I .“2Yáÿ<¦aT›mž'K¬ÑRyŸÓ,î©z¥q=è’¸‹“ËäsT椄Ex[ã>I+>fITaýM’¾zÁò8X¾äÑ:a],qc±8w®ðm™Ç²¸ûò:]'°)‹»,YWðœÖ´AÉ#Ç Ýx=o0"Ìx0,“UDåŒ÷ù}’'t|,áî… : xÃÓ^5QQFé€)‹5›LQ­vµƒsBÕ@N£GêUÏ÷äº]Ä£CÈÒ»2*_`…Ë#%¦“Í”êÂ:Éñ裬› þ(ŠÎ¼ïLü›2]§uúÄçSxŒm0¥UwT›B:L»¶=Åf^”ƒ¼È]½Òqñ„L-!‰Ê,MJ0ÍxlÒÑYàDº'+9ÙÛž¿¦ sÒM–X—•d²´â5J°F›Ú;6Ùö½q8ƒÁD¾ã_À]ÐTé.9™ÑÇ{´ôrÔs?^,ýߥþK\ êÄ Ùh„¯ß©ïOi¾¤>¼¸á•Gú8´2zàŒÀ6ë´Èi@»ÚºhÑù_ÿ§’mÓÙ^/ÄÑ€j ï¨ÝþL8Û»ðð«?~^ìÅOù¤+Œ—º³à+„5 áiÜáu+&Kã–TØ£™™?£€ÏéL¬à)ʶÈ?n»¶®4rÑX™,àcÑO´µ›)ºW«eTG¸sðzÃ{óÿ¨Ÿ¿-SX¼0œß*„²Œ^þSÂ’lÉ 鎘&ß<~/£x‡–d«í˜P2 œE‰ÛM#~ôú?â II¡k³_TÞ­†·f–{yÆ¿Àà~b¥pwIü‰mw[of÷çBõSÍ7~XkòMPÎU¿ÉÀsÛ×ÙËÿÀS7Z'˶ù ¥œTõòVuvô×f˜Ÿ»n1Û™{?c1¥‹Þ¼m!.:»™WHTzé’-Å cû$ê..§ý“ÛG:0íúõµ³•2ÕDÒ™CͦcÒ«Ý.?æ$Å›”®99-5œ±¹Ùij½ßì“ê ³/ «³mŽG'af‡œÿåüöüÓ§ó¿_¸¼x~}ýîšfÐÆ°Žâ’Ò͉¿B[¼þŽ|ò¤ÇŽW®Ÿ_ÀÌ€‚Ù<æ¿NÞÙ%þ¾b²Âj‡¿™1žá¯¸L§Þ|ίÓè¥Ô€>Šÿ®ˆ·t5ŠvG-¾ Ã§Ã1 ¦r FÞßËZ˜óQo–òìâ›oø¶ÁÇ/`Áx8ñBsÀ_á ©½[üùàßA Ì›endstream endobj 5109 0 obj<>/XObject<<>>>>/Annots 2379 0 R>>endobj 5110 0 obj<>stream x•YkoÛÈýî_10²k%+3âC¯ý°›ƒ,¶.+(MÐäÈ¢#’Z’²cýï=÷Þ’#QNŠ$fîÌ}žûúÏ3_MðÇWáŒþ&ùÙÄ›`§ýQÝÑBÍ'ôÓŸ„Þë…ª´ZÓQ5‹Þ’·¦¾Ý÷'7¤t7XÉ#%œ–,å4· \@ä·4ð]vrI$Mg^Йsš]°Œ¼pPPÿÎ7¾#r oÐina0ó¢a9= \nrGäÌD¤ ÏinábîÍåôïpã;]„zŽ;Ín„'0Ò¿Cê±; &3²1˜àm€ÒÝÄ›@ç oÜL°(ý;ìžAˆÀw€AÈ¥wgob‘‹ÓÜL´‡äÞ˜âr{!‚Þn&ØC”Þ!¼uêä4;ƒ·!Ay¦ áMÇõmº ÞÂ¥‹·! áMö‡ñÖŠ—’Ù«oCÜ:CÁ›‘4Tßf,é!Œ!v‚AJïη“9ÍM°3(‡¹ eolÏB;CÜ ƒ”Þn§ršàmP³Ê1ÞL‡õ©Í~xÇ4ZÎQûs5 Ñ+d±U7g*h¤"€ˆÁlêùfEÔhõ¨Ñ|†².g™Ú[çjêSóÕE”ù.ÐßdAÃÉÄp.B)jK³bjocj »r–©½u®¢I•:j°bؘNY,)<7+«°]“ÂTæå,QIá0"w@*©& Ú-sµˆˆ)$Zo™+=b¸\`,>ŒvY±>½5l™SïQ{kÒ6r¨¤m°m#ª!²`¶ÝÚNá¾m1£³¾ÏfN'SØ"+ºILý¥„%"KdA¤p1¡u´ÄèŠ|Yš•ˆìÖ B¯EêÏæ€Æ|ÎW}8#Ýì-¿.òA¢ý²:{}a,T«µò½iˆil>ñ¢Y V)šôð^%£¸ªâ§Z•k¥‹}^¿\ÝŸQ›-hø\¥£Ÿ?|øù›¿_½½þø·¦J‚P¨rûó}ü{Q <ƺš»}C›ué“ÔQ¹oÌê2Ïžkþõo:7ó= •töc1¶¬TïvYq§Þ(£jSÒÙË–éoniŸFÍÓNï‹:^k©#½ÎòÝV³ê±¶.+ìUeœl4RlŸ>½ô˜N5f ‡\úSo2gÛ’M\©WDu¼õË«·¼ÙwÒC\eå¾vľmd¼Á›·OvÜÁ»l$‘ÄR•Õ*)‹]5:Uâ‘Ö!¬;ËÕéåh¬þÍêÃûëwŸ9æßeÆÿ盦B Û‡¡¾þøûï$¾µ¨ÑUž1ÙÚáõª™a}h?ûJ„™ãÄìõr(\«Ëp±ô|Éñ¤¼ÚC¾JêTÜ€ÿí¾Ñœ]2A-èÚj£1'ÄôO­õ£ŠÓ4k²²ˆ·ê˜‹j6qƒZÄäeºëýnWVMÍPcÖ†±ZgUÝPfâ ’!§»ͦ*ë‹N=OA Ðh»Û¥óåÎ(ƒTPõN'Ù:#®áPff•,âœó…@ÕÄYAø×N(KØ™”y«ZïâŠã‘lãºF¾Pª’õÈÔ¦Þ¢ìM*ÇÅ“Êu³)S2¾ ‚8E\î©÷ éÃårÆðbMÚg/wfzûÚ²òÃ=J€þšh6×=L…Náðñ‰›}¥/H¶ë*vý뫉¢n €†À C¬ÒÑÆIR[ rÖØ0ùëù[+÷ yÂ+w#8ÿô’± þ£<ÏSÿ,ÚÂ|ɲBo6›Û°·°#O:ÑuWOì`ƒr2#•*ù‚€¶¶“ëR•Ä…ºE<Ó”‹ƒºßGñ-ª/ÈO™›mÆsbm ®UV$Û} N[à{óúÍO?©O£ß®ß«à:ÆÔs×ó6L£•—³ˆÃÑý Àœ+¬!’t'1l›kbÕ­© ƒ í„ º»«ôU[Ç Z'”îµcu‹ªÂȃóû";ã?òÂ9ët~_Ë¢uL̹ø„lØoS …ئþ‡Ç8€2Üï¢sœâ‰&Gï;]hI,J(1¨üjÓFAî£F0D¾BLBÙÐNVP½ÔiF°áüD^­Q¡$÷(ë\÷pb# Êzëo¶\£J*)UM Õ&~@%0™ßÕƒÇ(J­öÜoJYçˉ¥¿.]u¸¡y×{*Sy‹R¥ûÝ6KP,GOÝhºªOAå:¾îé¡¿Æ4œÀ§Þz_]çÅwú8.ÆEð#¤«ÀE¹»Kv»^ÝV› î5ÙŠ¨P'ç~P!çY{‡žó\Ûìs.oê.®n¡¢ãÓ¤Ün%8?tAÙ ¨„ºry¶y1d% mVœ[$ ˜ E.ÆêbWÖ LEB_°ÙT3{¦×\|)jl9ÁÝZ‹òÆIt«±+}‰[–c—ОPq2ÈÃô†\a`*nXÜaM ¬pá‚ÔëõȶÝIÒROr’ÐhàȲUJlttêJ·Ë¸Ëê®õZÝ¥ z‰t±°@,îž…ôàDvGK|øN( vÔâœÖë}Á•”‡’ø[—€R–c(´¦¾ó¸ÑÒÄç61’ m§bÕèƒj”£ Ëñ-æ"Ip†LÂêIÌõ€²ëE€GŠù€ƒe;Ö1úºòe Qe’ñtCZ·QÈbªò;÷ISVcw©6z»3Éd'ë'UÓºîn :½e Š;AòZAñÉã/ì:ÆRÌ8U¾£z’kcI@‰²}ÚÐàÊo2~ÏÌ{“^$6µŽQÐ{ÎàQ÷ÆUªnþùþ<úw屃.°å,¥²¥3À ùn'à9Õu‚÷>/XObject<<>>>>/Annots 2381 0 R>>endobj 5112 0 obj<>stream xÕWkOãFýž_qØ`ò€ðè§] [(º›U[)R4q&É€3öŽmBíï¹3~$NʪýP©€Bï=÷ÜǹùZkS ¿mêöøÏŸ×Z^ ŸðK›_>}¬µ¼êá’æ„gÙE@Ÿk+—s:éx•{ú+ƬE3¥Ã«#j·¨?×ÞÞŒ­3¼ñ #¢HòǤÅ\6i’/b¸Øë?Ö¯€Ìh|þýúcÿχËa4Lu¬¦Zއñ,4‰;—;jŠi*µ4"‘cZ̤&ëJéiÕdn‡¬Ú¯XòÜu»á s„;âYö·oŒzý¡´;|¨?Ž8’¾= £Ä(´ÍSLz’U,¹Ñ8Þ4ÚhÒ(MÀL$ô8¦d&i’Á’¾¦"P…8/޽˘T: í‘HøOb*3jÕ„ÒGK\Àd[öƒõB@î:†x’"I ³¬–<Á@HÎ _–kÙœ = à’³ ß$b®ýD…ÚÂòèj%ãŽÉ<áÄ;l¡´ÏÏ‹÷óó_¹pÖÙ·Éw4Á¯ebÝh£0Ðo;CkjX±åÑö*ë´€—ÆHraÙåPçâ‰kÍǧÈU¸³Ò–*“f.ÇJ˜%ÝÜ];Ö@¥Íí’„‘°âÈ[¨d†‡PL‘‘õò·E©Që¿pâá[ée”,#9‘Åf$r«I ƒ&&œ[8yŽŽHh&ž%Ià@·>‡jLRõ½Êl°Y.]÷žç´Ÿz]nÿ°t:^·‹«qc7ƒ0hø3é? ö8U´O»¯®ÑC<+D¨ÚACze£Tv“ˆgÂðÝØŸ™pqùâˈkkÐx”ú¹YÞ¾ÖcùrŸ&÷“aŠ*N6©þÞ±$ȹë«>ØûiÃWæó\½û}íô®½,gß¾ëõz'ÕõÄAÆfU‚Ü"/¶\WÄfÞ2ŒºpÞ›dÝÓBA6¸ÂtˆÑÓ·Ig®.ÿx¸ÿÔwIDÝ]¼¿½%¦oø¨Õ´yž·•ç¤á¿MedP5 Dëy B¥‚&*Ëd½äâ­GQc…ûý- —©ä02(×%è[›Z•OAÈ‹­ÒÒâºáÇ­Þ.öWÌÊï›ÝínîÓH€wáq“*ѦñŒ…#ŸÌ+p*v ÜÜå¹µ2Û£ŠôÛ2¥£@ù'è'?Ëk;Ž[0ÛÁ—.ä¿{Úf#—ýÚoµ¿m0tendstream endobj 5113 0 obj<>/XObject<<>>>>/Annots 2384 0 R>>endobj 5114 0 obj<>stream xXÛnÛF}÷W ¡‰ÖÍŠÜ¢Z%N¤A[«è‹^–äJZ—Üex±¬ý÷žÙ]Ò¢,'pƒÉÝÙ™3gÎ óédHüÒxÊqv2x—!_þ|{2º‡SšL/Ãe4šMÃK—ÒõÉþ}FãÑ ¼Ø{»·Óa8Þ{;Ì`y<»°–‡¶ìîØòþ}FÃÙ$œì½ýe±çªõ·XÓùÕ„†Z¬Óô? ~ÄÁ¯²tz#n…Òy]ÑF”I©©y*b™P´£³ÅÍÉùb·F‚8-Ý“Æl@B'‡«êrs°*ÄAZÅ"MSm$iQ©[I™¬6&!^Ûëž> þp„y'²<•ï?¾ #Q,ƒ0 —g'Z¿NÍVËâø‘]ÛÁJ¤¥<°Ò»=×rk¢W¤JªK‡‹H¥×Ä~¯Lšš-߉а‘ÖÕH®•ÖüÒ¬ÈÔyß¿oŽŸHÏ;F£p<Æ]ìiœ§¢, à÷¨Ö¥Zk8QnLQÁŸÍò쇮ß}k ¾bc ø¸–ÀATØ›Dâ¢Ëª¨ãª´²ª MÕ.—0ÈÎ6Þù´cí!6¤t‚„V yaîvp‘=Øm½ïº0–…,s8¢¢”A,(‘pÊì‹ó—/yS e&3Sì¼08¡ð…¬èÃÙÁq_†;¯£TÅTV'&ö!îJ{°é߯+.§€†E4q[—øi-†kYͯ@WäqyÖóéäüõˆöyäx­åÿ\ C_{Y=uÞvãl±Zl€o™ËX‰”nE¡ƒ,ïrT+rnH*0Õ£4mªÛ#е`Ö¦Úp^™Käé¬i»A©¢¼pñ‰Ç¡B#!\tï!,þ±3€jº/!¥mE³‰g,E–@™IÔJÉ¢|f9™‰œJƒcP_ëÔDÉ.“( IÚ"ÏÁ(˜=vŒXÄ ¥Á-,§š½çR×™µÐñdÏÚÙà¬Mù©V·"•ºBºØ…jô”qwN ŠMö¸¼'ÌÖA«·=§½VÙÃÓ\ÄÿˆµÌEu ž{Y•¥|V!·Â„R`$U@®LL£¤_Òµ”¶LÚzDðÚ/w–W(f›E¦íMS |µVB¥å£q"‰uz {‘|…Ÿ†³€¾É§Öò¼8Ö˜ž;ÎR—-¹\´]¬|ql² ™H•–dòJýhp*³ dלí¦>-BˆŠ,2™(a³m´!ýUÖй² œðÇA”8ŒaxqêÜGû{Áý •\^À–õ·ñªõETU¡¢º’lêEÏ–n’íìðˆz2¡3w×µdð]÷fž3ú£)}4 /Ã-<-g"ÈÍmAÚJ4Y®Rˆ®ÑPÄv[/ˆÒÎ%euY¹bWU…1±Â£+àô¸.q»CÔ‘dÑB†q Š9ë¼é ?|[†snMëT bÁ€–e¡ÎM+© U­cŽš§®·b’É"a¹Ó•¸£Týã¹2 £Mß6eºq4Àõógú‘–Áw7Rß.Ïú?]¡ãÎ9¿Ë€õœ`ž§B¯Ï¯‘`½~öµQŠ]HPÈo6< ´4kC²òüDM÷›oâÿ¶P9¨N”¶!<)¾›¶­®Q0Î$ݪ#Ï ®ï!Í.ùûÙ†ÆP)+Æáýüçî(qaJŒKídœÈÄ!A‡³ÅÐÌ£TtÎÍË^6R$a¹]÷¸?B˜ïšúE»a:À¼(Öu⢴`s>nÑï˜D> ïCZ ´EdàC󬤭©SÈ «ÉÆmá FE#á–vÈ«òsûS¸gQ.ƒ–x=úVâ}4Û5™b׿{K9>3 C¼lùùÉdõÅíaçX’czÁî6e ® õ-€d©¶8¡|¡›Ý7À¿“-™1L¶‰ Ÿ¢N++H|ž­‹c¨Ù„œj?#ó†~ŒÌÙpŽ4þzØ™šÃóSÇVô|¼-@A¢£ifH;R(%ÎÒnuKl}@ë8‡ÇAûЕÆF‡ó_õK?ÛY¿½¼?ªß¿¨68Í ½¸Hîg®J†Ò¢ø˜Ÿ7åÛ†m+†Û&^ÛÎ>¥I%:7×A»kÚNs zHoRéêv¦7Çþr£%²ÄÊ˧A^&³Nßûµ.ŽÆ3 ƒ¾‡²>¸?ÚÆöÜC:"QâÀ¡8óóøh0 /Æ4}5àFšŒa„ÿxmb+ m—ÂÇ[Ûå>žÞ}/Óp>/XObject<<>>>>>>endobj 5116 0 obj<>stream xíX]oÛ6}ϯ¸0P@EűÓ,íЇ5m‡XÛ¡ŠZ¢m’¨‘´wØß¹¤(YJœ¦Ã†aHb8yyî÷¹üýè”&ø9¥Ù9ÿfåÑË«£I:ÁÃöÃ,éäÍNèjAÓ ?÷Ü/À—,™ +é:‘7NV¹½~L mè'±”ÂÚç$ËÚí(— ±.Üã«ÏG:>BFòN;In%>”%·«e)jY&kgI¯>y€þðÄȺ™ O#¤„„sFÍ×%°©"];¥+QТË”>­dEVâM£Óј”£­* jÄè4FåØ^íèòÉ–Ü‚ôúyU$ 2ØR-WŽVb#i.!»ÆÊ<¥·‹ KЧҎl-3µP2‡ð¯¥Á1øÃ1´/yÌï*¨\ÂHª.¼’-Ua£r¢Ê$m…©TåPÖ®;É”iè *–ÔÚ0Ô²Ò†ñ]í=…Õ‡ ä9ÜÈü>[ó»â7Øí"êºØ±Gz–eË4ÓÂèöˆ†jü¸†¥á=·b-{>~zûãÕ¯^{Õ½“¡;–/Ö„äRmØlK]–º Öç¡P}³‹XØp³²c~¾QyØ×¹+¼· 1ªªˆ¹t[‰[2£ûCfì‰ nCüýü³Ì|–tI—xüòF”ˆ‹çäxÔ¤ÍuòIÇ’Çy_ â¯÷0¶†]zK¼Ä–Q€ÑæTÚ‡uŒ¼orvpœÎwA|—×NÏ8¿9¥µ²r Ùh×u­£9öxzFG ÿw¶A¾éª€|8¥ak4ÒD/y‹Êj]Æ)½º£ÆdºrBU–P  ;¿²Î¬3§ Ü[ÊR›ém%]©š_;£ ~1ÇQa”˜rô-’Ø­Z^þ,Ë÷[úÉxè!¿ôƒ3{½`¡à¥t—··æ/¥[霤˾ÅE¿5Ñð¹*&iÌÞà§”>ŠÒWá‘E8z+јP¡½?9)ó.Xý®Ú?TI£Ô9—Zƒ&Ô7u‘~µ = ŽÒý~Õt*®à£z=/T"¬É‘˜ªs‚Ëðaá$_©-­æÖ€þ3N•\‡hnuÏ®DËãà.¼òb”ËB:‰þ¶Fxµ´»*[]©/2oŠFÖ £t”Θ’Çö Ãy×ÉÐI Íø~»ø¸]Eå Sœ¦A:¶+•­B¾œ÷C)øúyd”AœõýdOƒëj,ŒDŠ_rÖ£€Âp¯6œÁ³ó@.ûýWOL,/oKå»=*t«$|Õ’ì`ŽW”¯…Z® ×, Ï:2Gý]oº øÛÐñª@ÂÂu pm yNã9EÂF‰ÃG¶›ŸÞ|5ã¢?c™‹!þ°¸ïiôoÉ»_H£~£;jh,˜¾y²*]-yõ ´$ü?›ªdnuOç È:ád Ff}ïÛï{§Ó¨ÊI³ÀLvßÉíT|À(Âù™Ðë “:Ö°Ëtýꎚ×núÖæ4L¥;d­X7å&0ä~Ù̃ÉS„ùCë@¢dxnp( 7 F²Ápo ‡Z0¹zft!-e¾HgÍ•ÍñtšÎfø/Oúã[Œäb;>ú#jÉ÷< Á.£˜{Ì8$ÝZL´Éß÷D''`S­&µ‘ OV@®ù2ã¼¼Q81(Õ¸åÏ ìEs#tz~–>=¥ó‹³¨ ëqÜyèrX}üß'åÉô,}–>k¸?3òèv^ýtržÎ¦¸ÃÂÙÅŒ½¾:úåè/ùcøendstream endobj 5117 0 obj<>/XObject<<>>>>>>endobj 5118 0 obj<>stream xíWÛnã6}ÏW ‚ÐbÅ·x“-‚M“m ´»m E½(h‰¶™H¤JQvÜ¢ÿÞ3$e[¹,Ú‡¾m=ž¹œ™ã?úÔÃoŸ†cþËʃ¯'½´‡Ãí?» Ó›§CšÌiÔ£ñE?ßÐ$÷V=šdÉÇ£W“»ƒÓ›3êãyN'°; £]reÊJ85S…rúÁ8ù6Ø¢}B·š~þåöÝI?¦ƒ> “¶PÒ’•…µ¬Ém*YŠª¦L…ÌéðN¬ÄBº¬röпãOð”];ÛdÎØÒäj?õ!­¥•|1Àõ Á몳B¦4YÊZ’°’rYY™ ‡ †[ÊpÑÌä›Ã hšIjj˜)\&EžF߃ûFDuS–Ân¼ rR»šÌÜ?oc)Å=ÜT$¨²æaCY!êš …S·TuÌÔ¶Îì Q<ù8ª¬Œ…ëè“>¶A¢­w»ÍÅÎÔ;ðjQJ’@™×Ï÷iÇ+ý—,déÈ‘ ;™ÜMu.ˆt2Ö£äüžK«VÈù§b+- õçKЫfV¨ŒêΖÖhæ´2*'¾ÿôfÐ6{’£óœï˜= $Ódú*æ'—¡ËèýOaûü¯Pf& aš¦±æÎœB7Î:ùù; m)tâcK9&™ï³6¦@ÌG!ÅCލë-¡Rº¥É}O0 Â#툙‚žž«Ec™AÇTËH”6 {”lÚĶ¡xn¹ ff%Û0ÀK_kZ[QUª¦Z• ¯ûH(2õ™08aP>?^n»O·WBê¦ÜU@µù\†Gs‹¹{ÍiZ‰¢Á|{ÌÛ½¹ö¿•ɯÁ¸v+ œQ m,o¬°„ºå Ëi¶Áâ­4ØöÖK(8ÖïR8‚“õRê@G¥lÊn:„Î%XÊ÷¬v˜Æn»zý:¸yÊî\ÎES`}Å•Š`­Ês\â 9lhÌla¬"Ï}Y§ô-69CáËo RÙeK¡ûãÇë’báꃳÏ;^÷0¶cæÖ”~ F¸·ˆÈ°Ä°Å l'3/üYJ·!Ë5*£%U"»‡jñZC Áid™±g(ðÉRz [µ_äBpn|FÂ\®IKd›½A“´È0¶­,ÍÊWi 3¼W˜5r% Úîf(4£¡~8ã[œ]Zà 8šNr6¦ñ!(½2÷|ë7,¡fˆç1ȶËvÁ"whs”T»6;hU”V ¢ìj ØbุmÃçèè%514ß>QK±‚¨{roĽ½ÞVG‘›Ó„+,}Žpòë‡k:êJBíÕ Š‘ ƒ(ëµZp—}ÙÂô2ŒÚ™M È–ßËòýZ·Æ€Ͷoü#ðÙâmy¼ FéEzçßÞʬÙú¬7N‡àCÚ†ç#>ºžüxð†r+endstream endobj 5119 0 obj<>/XObject<<>>>>/Annots 2388 0 R>>endobj 5120 0 obj<>stream x­XkoÛ6ýž_qa´«Û%ŠßIZdCÖ6[‹¢Ëo]1-Ñ6SIÔ(ÙžQì¿ï\RÔkÝV`C‚ØÉû<÷ÜËüv4¤~†4žño˜ ‚ÞðŸ!ÿyóíÑtÌh28 ”Ðù8¸(bº=j<&4 ‚qcq89¯ž±z6 ¦ÍÕÆsB£Á48o¬Žì>›@5‡S(·¬´ñˆµ³,ª×êDŽƣ!ÎWkG¬M.‚³zí›yÃsë¾YÓéõ„†š¯¢Ù¾D62øöçIÅ!“‰È(Ô‘$•Sw¹H°°¿P)õÎïŽN¯N+¨'v"È÷k÷ÚËï÷Ži)ŒQéÚJ‰E^P±×”Èb£#Jt¤VJš< ×º(t$ß¾}ñíüÝÍóŽdÚ«8¦B˜µ,HÄ1/èd8‚;ýÌèßB].s˜°-(ÕÐ\:G{#²L¿# «8×vY,õ®Ž|Õi| m.#ZiC-Á.ÂHÊ`|Z(ÃÛ\¶L)hÎÚ¿I£v¬Çè„Dicäl$‘Ó^Æñ±5²ÇÑ^êèð¾<Ó«r–oô6Žø³l[lj(’iPZ8šp°®á— §½à“Îe$¡µÂ»1;v+ˆ(R¸’þÛ}  „1Ô=@±m^8dz4·c©‹“Œ»œˆ p!Á£Q0ã)êß/qº°àãp,’G =:®¿Ñøþ˯‡Eÿé««ÛÛÇáèý>q\}B²ÕN•±|ó½Z?½)Ì»jrÈÛ=ΊMwŠbYôí±G@­c)RZ^o‹­‘?æúºê¨ÒA—Äç¼*.1¶çÏVýoÒŸ/:/D¡B”‡`Ño»Jzy÷IFÂÛ”}l ËKJ·qŒ_ƒwó!F;¨]OÝó}ëxÍZ'ã`6;ãÀ\­pZl˜˜þO²êp”­È’õÊ€¸·éµËëíF¦¨&¦@›¿v#÷“m\¨,–L‡ÛXæímžµûTÖi{Ù¶3–’æ™%­¤`ˆµ7Õ2”%ðP'‰FÌ4¨|§?H[*`Ôbâ©ë™…48þ >ˆµ•]g£²N‘F«´Ã8Y¡ † ]ŠpSúÐwz/AF¨‹Er%à¿e µL¥AÅô¸õ$â`iò3…ð¨5v8rç^¤S0°3i˺î;Á'4ƒ è¿<níT®–*VÅôÊšÓq¿Bÿâ¡[©Nì}¦UZpOÑi^˜mXÀëZ»%ufÙŽPÏäm‰U#+).§TÊ(§p#Ò5ä,ö¡kXŽè(@³qüÔÖзMhp‚çwn—± »ç8›" ežûNUÆ”ÏT>¼Ü¢é{ËéAeÐÆßƒÌ*yÀyl6!ÀE#\Ï ÓÁœg÷[­ŠÅ’1‘vþ›I„•%P·D!EޱƒóÖ2Õ•)ìH<•dF¢¹@ƒÑŒb«$Ã`êìà‡›*WŒ;ÙØ%tnÏMÝ^Fw’UÙ~Wsé¡e† |/câ2е¸Û¹×5Ký|jeÛ ÁЈ!fe+ÜÁ¦GÎ%GÝM$l7 éLGÝ¡H[&™gh{XßÑâ:ʨ_7䱨fQ¸Œÿso'kïû—W?]}óý³wïoÞ|ÿó»Eß=&ÿ黽«HF\Ù*y¡>ÍããÛ7W77ÏßüUƧe^_`ðç¡Ãu›©ï6£Ip@Í3eà?âÇqÀÚÐa~²ô]Ó#,“ÀZsDú%  †ugQAŽ­ÉÈß¶xéÚ—ïü•b†n½ÑÛ‚_56Ø q«—¼§2ˆ¡ FEd§•Ľ68÷…デÕT–q%‹Ó‹¶tŽ!×#ÍŽÅȸÂLY¨ÕÁbÉzèé0ßXþWi¤v*Úâ4ç¦eFÍ’‡åÈ\ ÞÓP¹í¯u_²n„þ„J»\mG‡*U¼åÊ+8[ÍûÀ-ЍàÇì¾MàgU–O¿ü²Êd9¥s –*0=òðøòõ +E‚jcú± ꤢÇmÚ[[lpxŠ)¯`vŽ/V¢ƒâ΄A:’yhTÆ ô…Ìç™FwÁvÕ¤|¾™1J*µëV+(—agìd,ºÄ&Œ1Ü aT¥m¨àV{Ä5Xl¤2„n¦M!ÒPƒ‹Ðñ8F e{ö¯#+ËŽth  C—>a&FsmŸ¬&Pܵ+t3jŸòh`nP R`4]óÿ‘öЇ€ÓÃÒé­•ù„¡ÇŠè‘FÙ)î¤ w2Ý|õZîÝ¡ç׸ê Ÿ¿‚œ—ÿïÎ&Át<¥Ùlœ¹ë(cðd„è>/XObject<<>>>>>>endobj 5122 0 obj<>stream xÅXmo7 þž_Á.ì¬ñÅ/‰›.Ø€-mŠÅ€¡)öÅ_”³lË»“n’ÎiP쿤¤óÙ‰·¾R$gŸD>"ù<¤úçцø3‚É”þååÑ/·GÃlˆ_6¿ìN¯Ï`4„ÛŒ‡0}‰Os^€yÿƒ“v0— ¥åüC%¬ÄF‚_IÀ¯E]xè̥˭ª¼±Þ[uW{ ãÛõÑé5`ãýwÝJ䈥¬„_v×b#òB8§E)/ÃÚ¤ßû•´r×£1¢ë· ímå[td*ô‚ðÖ”üòýï7o 7e)ô <Ðî³þ.ÀnÞâ! ²æã-hò¹zì<ƒ›;Ý3?ˆ÷ GXŒÊT^MGÒÆCMgð\%sµxhó„>hèµsÚƒ{Up'ÁÊÒlä|b +&Qé%˜ÚWµ‡·¿ÞÀBÉbŽ NyÍÌó”KxeÓÂØ¥ô ÅK[*-ØRï²øêISœ–—Ý+¿‚Þ»^´ž²?hâCGæ0…\xyv>ÝRjiV›€N)ýÊÌ#®ZÏ;`kí€´ÖØè%Õã«}0>£zzF…]ŠjÖŸ++s¬cô2;ÞMÍvù-Ö~§µ²ÃÄÀý’³DgÏÞÈpN" EÕJ_[Í«Aá_üúêùsH¦€Ë†RLoD…uUYE‡£U„‘m£#s^[W¹ÀTãNŠL×è_~eUÈôäåRZÂÊ„ +I8LQQ˜{÷C8è.²I”ÁxœM&øé`pÈ,<ûÝP?ð#ÌúøÕ츫4VÑ%<û+™ üñždÓé æ0/Û q?±— ÊÔ5<=/ËÊXa`#0,w64Q›«b?(Ù#^À<7l ÷Mfdðs“iÊðä+aENYp¨zzéð_M²ßçä–T¸Ða`‡¬Ž&~«ìçÙñ£=¸«•“`xv¼–z3øéôïé‡Ûë+té’ÎŽ÷ý°§ïº#t‹·«ë¢Ø_È©nî'þŒˆÖ$~K¶5Öjª}¥ó튙äH YµÖD*öµã'ÊE²A\ÈR‡,šçºÈÍ÷ž;ì.*_·B;ܺÛbún¦TpËaÄ$[ʹ¢"¤’ „õ‘KA•Öbdv‡a6Ú€ŒÄfSûÎÈÒÌk,k6{r¨¯` ¦vÅî-Ê–ïÀ‡ p ZX(<Ô)C<ÈÓF¡Ú³˜á áÆÈ¢íD¢Â’Ç “ Ä“îÇžz·R$ê*u²Æ* êKb…:W*¯h°@HŽúY ËjöZaŸÍ´ý:céêt×Z±Å9¥é>,ôM¹b=R´“ޱžúœ(¶ú„À……YšckB<©ƒ\M-K8ExG+«BäXdw¡ÿófœobJvEúù9=¯žì{xèGDäbüÏxøM|35MùH-9`†R€· øÛôàË8˜ô—a=!PO“0ˆ6Ѱ™÷ZWâeåp&™ì’Ä•M¯!Õ ÷Q\‚ò€Ê uˆÇs¼Éˆpªž ]0šØã‡[™ï$x‰¤¤ˆÒÌÁý›ÖºÖ9ß—øZ‘:¢_ ÏS@ºÄbÅ9ô q²ÌkkðÈÉ„^ Àâ¨1=±GÒ94v à=Œ¥ŒnI’ ±?“PSC, »òW@Ê×6W­-!;íA>Εñ 6º8ËÎ'ç0½à+ ÁŒ³!^ÌòºÄáEÌh.ºñ0¬¼óãø,{™áã«x×I=5OãŸç|8Í&cüïœC'S²ôúöè·£¿ i0?endstream endobj 5123 0 obj<>/XObject<<>>>>>>endobj 5124 0 obj<>stream xíW]oÛ6}ϯ¸0ÐB lƱÇÝžÒ.i·]¶(h‰²ÙH¢FRqƒ¢ûí;üb9ÉÖ—¾- üAñ^ž{﹇7œÐ¿'4¹¿´\ÂÏÔ¶áý —Éò°õ‚ÚÝu§dFµ¬ÖËÄeéˆëõÉ ÷qòØ´C|}u_’ûšÓ©M¦±É…1M)Èn¸Å‹ð…%A9jŽÄªÜ?ø…ßq,¤·|-‚ÇYô˜PªJ¶UåŠ[–+Õ?/¡U\ó•º{µtEÿ¶S\Á'®à;‡‰PȽ}”v£â©ƒOqÈÞ×¢äõ>|üù-meQè÷LV¢PÕÚ!µ;”ÀF d6UÚQг{—ÎT(uk¨·Ù;]ãK5aÓ)z(û~Í)æͲ›2ô h7ôÄ8 o/i°ST|Ðgï‹ÿÛ.Kþ½í<ýBá›Ú÷W¤(­¸ETå±Ïº>ã©Ó=º{NÓ2© ÙìjU+¯šEõµÓ‹i*–‡C2P[Ȫ¡ žHÞQ]¡RÉ­ ޱ- hƒ¦±8¢ m ¢ÀèZ LapO¦ü¢5¤{ÕA;¥z dšÞ}ôyèËûÐÅ7ê€l72Ý8¨QèG¡ Žõ§ìi»•?vÃ!8eSX ¹§]3ŒÞ+œï$o#ŠZh*yª•!×ô[Á5bÔÌÍo‹w—Ü\_¼ùõâíå͇ëË7ûÕpùk­urñþ?͆íâD>\s/Uƒº@~Åg«¹Ë>òÉÈ_qؒşחŒ±=¤Ì-uÈ#ò¦¹©Q]ø"+p¢ Y,­UþdŸ DV€âÓ‡‹éX-¢¯Qf îx;_ŒZ‹Z«T€?ÚÚÃЕŸ@­WÁwÓB_÷^<+Lî@~s÷‰ Qí*½l÷À»S¿õgÐr:Wš•ÊXæïDa:¥‹F&r74<®ï²­Ëò°‡âù`B mþB» Dú’¨Þ¢Ê&žÕG÷ÿ¾>^„FØ.OÏ£{*g×AJn&7>ß7ª‚\õò÷t,­Ý4ÚÙ­Ú³;>"aS::vÞž†è;°LÉ å¬XßC4†7x}'3§_È4‡¬´Òç»c.±ƒ>)-í};Œts÷%K&§Ìå<Ì9í¨ëÛð!jˆ¶Íçnÿbƒà ¸Æp– t!æb áñƒ²ñaÎ+Y*d¥}4¾”ëõà ÅYÒ ëæ‘^¹á‚™íº_ˆdànª^ ö…®M “Lqñ9ÉôTÈ•æú>jÊ>/XObject<<>>>>/Annots 2390 0 R>>endobj 5126 0 obj<>stream xWïoÛ6ýî¿âà5˜ƒ&Jl'®Û û°,é C·†eh‰¶YH¤GRq¼¢ÿûÞ‘’,)Y0, K:ß½{¼;ý5Ó9~Ç4ñ_Z ΓsÜá1üòvp1O¦4›M’ôê29¯.rº´. z}Ùò³ÖeAãÉ4yÝZøý¢µSØÎ®éìæ5 i±¤Ù|N‹, 9§E:š\$ãódL·ªØæÒÒq/Hê²p´2¶ú¶S~cJOJ+¯D®þ–Ö/> În.h 7ìøž.àz´ØHÊäJ”¹'6êE<£Öl;{uíjÜ#Û­5"Ý7´³¸Rz]aRŽœ)än#<ÝK»4N&´Øà6þ`¾:Ë%‰<§­qN-qquvõòe\‚`®tÊÔd£­°^¥e.ÚAw"f÷’ÖRK+¼Ì(5™¤ThZJrLŸZ)ÜV+ò°cñ„äx’éHl÷@¦÷]÷œIÃâÊä¹Ù±·1;GøàȬ, Öó&®ÜnõTH$(CÜ̆°m”Ë}“ 0‚—"£ÒEõJ¥ƒCN‡–†€uš çBFÏn âöÑ'Ø'¹Ðëäñòʃ&>lï=±àŠýõW°æ aÝy;äz)ýNJ]å½2Θ¿ßJŽ&ëÀf?L?-ÄÖ! ’¥ÑÃâ»ýõýÛÅo¯ûhví±žàªÖt³a8 ¬/öá"šaüîvë!­$‡Ì•y†í;ðäƒ(”f±h26ÃY@^Œ)1V­•9!ËÖª,Cäøæ”ÑŽLTWWR‡ÃÅçpÂq’L§¸ÊFGJ§y •¶`U8`È•Ÿ»H¥ïŽ£nkBhø‚3¬ô¶ô €2¬»ÑÝñ°Žæ /(Ü|îØ~¬ô¥ÕÜeiQÈ$|KÖÒ³š®¯Ú;Þñ÷Ÿ´JÁößô|}é\w#Zšlÿ̰F_q 4¤&é¨2HãPvÁûLËÜèLž’³–ö„–¶ÔÒ{I_úîÊNÏ‹ïF‹ÍÝqß²y†˜£ußæ(Äw8U§!ÅÓd6{ÅäLÑNA…ua b=”>)!©'Ôȹ)œ¡l±úP-Û"Üò1RVÛr™«4*¥  Ï^ÅV'9Ts×»[3ÙeçùÀ¹ „¾3±i¡S<ì›J(YÊÿT†ÒOÿž5êÇçíòÃOï“&Í›öég±i”\E`µoCaKv¬ÎKmûÜIikyì›çɽé•áFD¡µvÚ(ç VKÕªBïÖ¨J —S.×\ñR£QØ|Èc³j"Aø/qÐè^ä¥äb[«¦ê×hêh°eHåbÏç²®£ÃXº†uH¨V+öÓ@p'Áçáq…ÐSá€×t ´°Vm4®¬‹4ݸësG…­§”Nt±Ç膅Jó™à脵bϵ?Ô$Ð #P¢ßà'„Á=¹kI8÷*“èO·U‰yi:r¿ÚÆÇÓ D %þÀjµw3¶ð`Qw]žŽÌÊ£aF YÝfÊ}º7ØÁ,<lLLˆÍÎè¯=»á†ö4šÐ{M+‘ú‚ÖÆ {ØÖ·‚|E¾û Bv݆j ñV¦˜å¸Ûìë9’wt(´ó@k FP,Â#Œ¦ù¾ÊìŸ´ÌbÑžsÚ´ù^oo­ÖM%TaA€aJj–‰;gœEÃ逊ù<¼œNfÜ8âà?¡w:ŒZa4~HåÖcÐ8pÀWŽ”x:jƒÞäÖ™ÿAsUƒ04,VæßáYeJ°Èô#´Ø:ûò bñB寢LpNª:æ¥æœ6HúQú¯ ÀˆÓ<¨dÅÑñ4öä _}nð¼/}Þpd½ÕÓëyåumÒwQõ\Œè8À~c1„‚]ÌuÆ>ß›³›óÙŸ ‰MÔÎÎB®qóÍ›x·BÃ@ʾªg¿o£ÕwÕɈ(ÑAþ¨å´·(¤s¨&¡AŸÝÌ«ñ<¿H.§—x©¼LÆqääyät‚—ÙLZRsk5áM ƒK´>}Å}¢Vàÿ|õ¼<Ÿ%Ó Þ;áh:Ÿsp׋ÁσÂhÙÆendstream endobj 5127 0 obj<>/XObject<<>>>>/Annots 2393 0 R>>endobj 5128 0 obj<>stream x•WmoÛ6þî_qšFYmŲc×ÉÐi—t)¶lk Å<´DÛL$Ré8FÐÿ¾;R’%Ùq×$ôBïåyž;ýÛ  ‹¿ô‡ô&­®ßÅ'ô/ Ÿ?¶‚‘À ø]H`Ð÷Oó›n[•ÛκµwÁ0À½‘Ûœ üA~G;«÷ ôúîukéíûqÅëM6‡“«.Œü>ŒgÐëÂð,ð‡Ã·0ެ»]‡^ºœÆ"…<5Bɉ*© hŸk“ 9 ‰žOŽá®5›ó‰ç<mXªl‚Õ‚™‰‡Ûž‹2n–™,¬ýØx_7úµx!¡·aÌ´†[‘¤1'¿·¬W]˜áÉ^˜pïNÂÆäÎ ¦lʯ¼Â0ë~<*J9¦w™E¦V殺ëíäø¾ÿ?Òqru Ì :˜–N¯ŸWÚ»Ðx2AhpkPç˜xÖê‰P'•ÀvÀ[Ì`âY#“ã¢.y»„ܨ%â GQ·ëÚÈ¿hz~x‡½“„ÿ{˜³Ÿ87 ’Ë-ÉŸHJ»ü‘ËÛ‘…èi-60ƒ]}Š<±qíÐV„ —z‰`cy-“JåÅc ªFŽTå-¤™zZç¤)2æXF(É{JÁÍ&|aŠŒWÒ0! 8iu’íÅ"ê:”‚Nîî~ܹ1€–î(¶;r¾sG×°³ð hêãÁþRÿÊ´‰×m@®Õ"%Œ%4Ñ»"=Í][H|§$/R–Eð %j#ÚÒÖîu¡SÞ¢\d,MQ/pS½z8©áckug©J&]IH æ ¦ E›¼A'ù£YÍ:Ž–8@`qi‚Ö08+ãä·‘+u”ªTŸÜšRam›Èki"Ð8¶öGÝ,C¯ë6=[*+Ý/)œQ$h ¢~eU5óŦØP²LDV÷êÖKwœâϹù­˜¤¼lºe1™9zåœE‚«B_%0b&ÆduVïGùf!G¦Ló-u:[OÄA£¥ç~LlÒBm[ÙXr–ÜÚO”jÈ[ª]Î…€Öχ{¾1bØN[(Ó7T“¼º†Ë(çt=?[¼¨{â?¹åz0:õý GÃbˆ¤Y¤ÓÃoÊŸU¸L8J#á@†#¿[Ýyë>hz§~Ðõ{ð r7&jíçqÜÐ új2:èâÉ=üÔÅùµ?:£G—ãÖŸ­ÿ<µöendstream endobj 5129 0 obj<>/XObject<<>>>>>>endobj 5130 0 obj<>stream xíW]oÛ6}÷¯¸0DImE¶§Ù°‡-«‡Xö}10Ðm3“D•¤¢Åþûî%)É’“ ú¸4h+™¼ßçÜãσ Døg³9ýÆÙà§å #|Ùü¥¶p±ˆà]8ƒå¦Ìo&á|~ ËÄžŠ`€?Š›RåPí˜Y«³ïÏ–ƒÆ<àü3Z°ÏE¹NE ‘ò÷_b^!óUpo”È·éíê ¾B†Ï]ô'kwðµç¯ ˆaY‘òwÂŽ³¿ÜU]‰ííïFÀì„~>n—‡Íâbq ô¸1f3žÎ|=‚ObY¦ °Ôp•3#yº‡{äPjžÅHÕt·ƒÅs–q÷¶¶€‘XLú ¾N¶Aäx¥g{Ëͯ\k¶åÔÞÐ=ßÀdJiPsjËô2œDØé;vMW` ¼îæ’')µh#0(˜2".S¦Àì‹^&dö2¼$Ã?ÂGöÈìÄ,‡5Çš+Yå°Q2–ïÝ)´ŒÝÂR&<„åŽ+ŽÎø˜†Ljc=e¬Ðx"7LäÀ…ÁSG—GðPjC©Òb¦IÀÖ²4Ö…‹F|Ãlø¾ÐzÆ,ÓTV”¯#Hx&sm3\·§ÛºÈËBÆa½÷ÿ2-4>u‰w<þ»®ãéÄ  /³5W§° °þ8ÿÕŽçü³uÆyÀ¡¹qV]›QÚ¤’ÙTÛá ÝVŠOlÃm?¨ ·˜HЖí ÅÛ·omÑ¿«m· O§ál†k)SˆYJ]78\Ö3l„ÒfîAsìLâ±ÔÔCËRÂ#KE‚V€ÒÜ÷GøÉœÖœªV0Mx±ǠGPÕÀ+yBsEoð?‚mI'åz ªˆwnu§O T™Xl1Ðô…¼Ôµò~2fìƒoñkñË>ÉdR¦äÑ2W%Îñ*x@@‰ÇÄÕ|øÆÝ oi²RÑ oÜ©¢4«³a×P¡Ø6cÎZq·©f?œô¹ôâüî²èÞ³¼¶9Ú¥–HoyŠlÂÐÐåã<êx¥E4ØŠ—AåqtÓñAç½kÚ ›ÆP(ixl°õ.ëN²î¢ˆvGï>€Ø °“Ph[{Òq#„_L £ƒœWð§ë~C†«`xÖáñÂhšn :_'/oôCƒÌðŽçì qÊ´Yº, © _ìd‚Ì„äÃ9Ö:IdÈœ±8E án"L=á¥о7=–$ëJ[‚m Sïdåæd‹4F|™8H"ƒáÂÂ Ðæex‰àb¬ù·ßX”>€ZYü?­ßxZëÂú~x(Òàˆß×­‚'éã>;0åßvÙÌ.™ÕÙ¨fÆî§õÖ9†d­=ìþ ꆎ?‡µæ ޲JŽä[Z2ŽK…z-æ´›Ù«‚ÛJÖ¢‹h©4„ß6¤G”F±Ó¬4« S(èxÒÁ¶^`È5†ÂÌ ”!ßÂ]Åàö¶û¤ #Ðl?˜´á,¡¬HG½&±ŠVô-1¾vk6ŠçY‰lYªHnpbiéWú)0ƒ_ Öå!!µÆóž>&¥££(Q’»@P…*î½V($­×†Æ>/XObject<<>>>>/Annots 2396 0 R>>endobj 5132 0 obj<>stream xíWMoÛF½ëW „¡ ™Ö·í9´I$ 4VÑ‹.+r)2!wYriE(úßûf—”IJq‘è©¶ ›»Ü™·óñfæ÷Á„ÆøÐlÉŸ Œý1VøkÂ_ŸÞ fÿšøSF‹±¿¨Rz´3šŒÇþ¬µÙ~Æîlé/[»7sNó›™;™Üø·õËm?ãèbî]ÞýyÕ‚i±[ººÓ ô¯"šŽiy;ñ—ËkZ…ö2cZÞ™Ùç2ùÚû,E¢F”òÕðó"Óa•Jÿu,ƒ/wº¸÷kï…{-¯ÌúüÇáúœ¢T CçõáùêóàênŽ«³ÞK(¾œÎjÅÞ.N‚˜vºJC‚ü$Ú“‰%¹3°¯=ã" ªTÙ•åQT©À$Z‘Ñ”¨ÒHÒFÒV*YàõDùC#ëéâ—Ó©?›Á ¡—W›4 (HEY’ü*²<•ôLÖzD¾ï÷Vêc¥§7Z§R(:À\{Î QR”fTÛ¤”V!LÔOâ®iíaXµ§úo7Ò_?VGTHSªÑûáþ½ßÆîP[âŸ=HÝgûôM‡?Hyðp/ Þx2Q”±HÓDmˆVã!íšxFè‚`ùÆsUÉg¢ª@4tÁ9¤:¨IS$›ÊȲqètÎ.~ÑNR(ƒ$dtàý’$SÉžvBJJpü#´ä×@æ6øšÈÓ¶‹J™$“OÛ#–pxÄBmY>ÄHQ&*•®¶qf2e0+Ä^è¯{ʤ‰uèU¥,ûiaƒŒ-ódmÏIRrDYU6·"² ¬:æ‘8¼lâBïJ^ƒ"Ÿ~{ÿÎbäa1Crb×[¨e•çº0¥ñÒÉxiQžp푞ói™ÃÑž½is—gWŸ€ºŠ«²±p‹AòBl3SØkwP7@N |ž.ŽéÑ]ú• 5?…ƒý·M\´éðï¸Ó²ärÎzGÂ` w:С|uÖOç«‹ zHÀ[û:«7lУH+I•J%è-±¬´A”ª*ÛÈbÔØ¥&:¦ù2GV98ÕæÕ!ÆY,bDùtqÕ;VÓ ‚ÖÈ€Y×±_§P¸%¨Åuê`ãìì™ì7&­½;®*~RÚšc…¬Ï{ »LJîè“˃/ÖÞð¾uq¸æ˜(kR„øþ^—àΞg¸ÕwÔ¯:ÕÞQ̉ۘÆå¡^ùˆì€'ð©è 4sRѽKi“c£M|’"È–¶W‡(Tè–š2ËágÓÚùÊñïÔÈah³¡¬´ ŸétÁ„(`»:l[ÑszOÅóø݆-áÿg‰³Ã‘%ÍÿU“ô]ñl;S÷'›«QÓ9tw›Öç˜%ºLð<¸®b:Ef §1{0WnÑq¡¼"]s`ÛßBæ©@Îp’—U$hm‘[èHv ê/“€¢4ù‚;¤)K¶¤ôÔÝ0Q9ÂV©ùD3ÐÁqh¿lÃsuwKÌ7†«Ëé’ãs:÷'cŒ<¯µz”…áêo5= mÃÿ¢(ÄuHs+UÐÅE—9X Lô —e¨a¨I›Tf|¹L¨=½æ•m!2”CW(ñ :²|˜ŽqÏ€Þ7.¶U&•Á Ýœ"àʪt aމô Á¨“Îw®{ÿëÇdd‘%ÊÎ"¥½EéWˆH§©Þ±VÛk% /Fìþ(ÂÖÜŽ‰ãëóí1áXê·ÃÙ ápï¤e<Ò›Ï(͵ÝÛC`k:smF“NðM=ƒM0‹.f ZÞŒýk7;1ðË)fÓ7:°vÂ0¤ÃçÞ¾¼v3Ô?qìb¼ôgSü9»°Ü·«Á/ƒ¿Ö;µýendstream endobj 5133 0 obj<>/XObject<<>>>>>>endobj 5134 0 obj<>stream x•VÛnÛF}×W Õ]¤d+.Üh8H`¸h¬ ¡l¨‘µ ¹dÉ•U9È¿g†Ë«(E)lÈ2wçvxæÌüÛ²Á¢fsþuƒÖŸ‹–5¶èañ?Â䯂Ëñ +˜Z0¿´Çóù X,Ó[,ÜµL@£ï'pÿÏÛ7 CÐ1 îZÄÐïƒH@@¡+…®H¶kT°IpiÎ"‹5ƽ…ײ`d“ëe¤"ËÕF¹Z†ŠL}ú“Ú¥3½‹0‘Ó•Êé!®'•†D>#=ýZ3!¿äXƒ„—`]5ŽØ†NœnßCõäôF¿¿AýG‹Ý-ªG½&×ô|©¢vzM;µÏʧø%ºN×é²óíôúü%\9]sÉéòCØâ ní \ w ‰Ž¥zÜ‚«Z…1åmêùǸ9„€ ¼Ì—÷)ûÂug)§}öÐ5@¼ö1@¥ëH A*‚ø¡Jr:€[UÅø>­ëÃâæšx“äÎóÔ†`sß±?Ê‚¼³Ž}T„nËé5@? 9gKP¸ÑÎé¦n‡E¾Ç¢WPz>½ORfÕä'PñøŠŒý-Å*då(¬–-"6áÑ(ŸŸëJw#Õòšs¦µ=ªiâ õ81…µKÜ q˜°Ûµô‘hKL£ì¨2ú3\ñY3Ñ“¯ëïp[Ñ—<:y¡þã4‡p÷áö¶Œ]L ââ.FfB¬ÑýÂâRk/Å´(“­qŠ"üH!+`6ò-º<϶o c¹m"_ëê{Ô•j÷ÔÔ3nHN‡4U‹—yÒéa©8á!g½Á3ÿ¯" HÓzÙ5cÞLùíš&ü»»· ÔRæó%ºò`/7žKæ{ŠÆDÁü¶–c¥]ãJÅ„=W ôŽ$§,ö*œ–®©"3«uËÆ ¯4{ù‰Ç~¹Dê¶ô}Ðò‘Z×’'â3.OÒE`â€P‡Õv—v‡›.Ý.ŽHNIH¦Qœ§}J6Þõ]¸åe ·Ä:šÖ¹¸'Ì¥ò¥B8ûšUl°diŠh1ÑŸH¢I?2e¤h‡úX.'lK“ý 9K‹‰GS±Þ<[òp–8Žj§ÝSØïמÓHµÿÖ Ç¥T˜ HY¿›Þ›Ü\_\}y>¾˜]ÐŽLûòŒ6æe——áÑtlÁ«ÐÝð¾$X£8àhj™Û£&Ìô|l[ãs¸N§YÁÃ$m­ UvraÍdz)-ñjö딽^´þn}Û©fÂendstream endobj 5135 0 obj<>/XObject<<>>>>>>endobj 5136 0 obj<>stream xVQOã8~ï¯Ew·Ú¦¥°ÝÛ—caÚE:µ§} èä&Në’ÄYÛi¨ÿýfì¤ÊqÒ-«BíñÌø›ù¾ñÏÎüÀpLÿ£¬óǬø.î>ÔŽ/8ó‡0K `|6ðÇãS˜ÅÖ*€YÔVLÁáá’›¿™Zêyw~³u'€þ-â.€6̈œé†¥%×·wðÁûÂ6Üë÷]ÜÛßÓR³œ®åÊþþ.¢OSÚ ž>½r¬¸)U¿Õ>ƒ»¶ÁSmŽ©c¿Ú¯Ç—# ¼èãr?Ö7êÞHÃÁ¬˜ÁÎ?ÀõÍD,ME¾„Hæž!sJÍcÎW<º§ÍD*`ù*YåÀ"^©–®¬£¤Ì#{œmr° l8f–¦²¢¯Ù†A¡äR±lBÁڥ퇡?b¡ãîñ1\b PežqçZ0å"¥b¦Lkg³«·ÃyWï×m`ÔvgÜ4à¿éVžù©dñ7±PLmç]?°¬ÀÂÏÚU¥OxY­`Þý+ר\:æ÷Ja1øMø"WÊ/”ÈMšcœ<¿áˆoÌ!uÑ!a5 ”“‘ÓýDv¹óaæÝÁ[6M67n¾7pÕˆÖ,ÙHCƦ65˜äW›Û»7¯ÔXä"ciM*ç}‘Kü<—~~•¸´ÇÀNµ;0jþ2çë­‹4Ñç–¿Íñ—ä߇ˆØ1ï"Ú >Ÿ@üN:á§<_š~=:š4Í_ë•j¬,Ís±ÖÁ›P5ÈÉ­@T^lÐuh¿Ïy˳†XHá˜*x£÷Iò 1\ÿ·²·Å Hݰ û;ÚÁÒìï„öŒ¬öw†´C%lmÒÎÖÒ`B2ÚZ 'VQ[kà ‰kki„'ÎÒò¿jä©oÚ¦ ^A,’„+TG0Û‚g¬@ÝSN‡|˜¡½'r¯Ùk䓸¥xĉz¨["/JCE-3rD¥°’«°kЯÄPçMÆV"™RlëÃTä‡x›³ E)ã™D‰A…•¨/ÄÚzp«¼±¢¾¤ÛXO=û§—(Î1‰7³Mi¹â)gz²ÍÅ)uÛ*¾C‰G¥MB&Öû³V×°`kïG¢´MÇhvÀ¹ùæÃ7¦Mê”Ý[ç‚æäš0÷ÚÐ xÞZÛvWÔBýg)”S7]ðH$[¨hîÙA§4Á…3Î¥ãË0Àk&ø\è‡cšáÈþ \<X(+Qî°\¬ydË••©¨Þ»’êvc‘¯‘?"oÓ²(¤®gïV–8c,w„£ Q¿gì4T¬žý‚.qà8%Ìwóî}ö’%R:UÂzG½úqrHô­5å¿XP(¾²Ô/éP*̧R4Ù‘1 š•Ìa´Qìß&m‡ >ÇìäySQ.mÔºÔ8ø ¯ê7ï ³h·%½R Q2s1%~œFÕ-@£äHq—ôíÝ£‡Cm·D¢Ø÷Ù_s´P­„áÞÓ»³ú2ƒ³‘2<ñ8ôOÝcúãêk?ôÔÁÈÒÝR•nŠO2gÝ?uòý¿;í$ûÃ[løqHÎ/f?;ÿÅKóendstream endobj 5137 0 obj<>/XObject<<>>>>>>endobj 5138 0 obj<>stream xWïsÓFýž¿b'¦Ž±ÿHL(mg(!4 -8ÃÌtÎòÉ>#éÄéã2üï}{'É‘í„Ò$ËÒio÷íÛ·{ŸúÔÃoŸ†#þ “ƒ_ǽ ‡›õ?3§“ËSê÷haíè1.fî9.ÂÖÓØ.t1_]¨œVÚ|Ì;¤ì9 Š•µ±$±ú¸fFVSžÉPEk,Æm3/™Z u‘ڀƚ"õÙÙéà夈­êÖ‹ì:“‰È()M%Íd¤R9 ŽÇ˃uû8Õ³ øKµ¥iÖ4SQ¤Bêv׺ ÆkZˆÉ®$⣤Ü<°,--ÿ./8æò&‹E(;Ä-m…-±o:CÏEߣX§si(•¡ÌsÈM—w»£ç–SV'h¨j¬Ì¥–+È«ðºleg¼¿–‹‚HëI+•+ªúåÐÈÙa‡ç(´”/¦€‰?W eåáײ²N.7øM–íYÅœÁiÐï#ºÎ™:%@®i “Ö#FÞL'9 ÈOÑ ’DS£Aš„³—ëDÒ3¾3GbÉìB`¤ðYLÄš'¿rˆ7¢" yvؤ2'#€™A1°””(½rv¸uŠÄ•Ï5ïqÍÚ*¸@5Ci1éªq(§«W^;ôúzŒO ÅÕ+|Ù`dQåUäpŸ ¢cÌ…­ÐŠ)‡ ïÜxW‚ÄbÌŠÕÔ0Åœ°…‘!ÇLÂe‡J–ÓâLô 'h&¬àíØ-W Žý+_þ"Ë|ý?Û éP·˜Ó\þêjK´oà™†˜JƒM@ùún­p"¿•’fy½Ò+Zñ*i3à&]Øc¥‹#†á%dà›Ñ<æ`Iá¸æ¢DAc_¥ôÂ'®8–3,Ûú2ÓÈöþÃv.Ù켃A1+‡ #çIä†6x 5M¼áö¶ÝZaò€®Xž½:¨§™.@ì…)ŒE¾£ŸÉúÂy¿½3GŠYÉ›àÖi»7hP-P9ÄT#ú£C0F~*Ô¤™âߨ"žê¢–ªš\÷kÆÜ7NB8y¨‹c€/[N]éJ PÙ Mßqƒí˜›}ž‰dÒòá“èPy5­¯Úl¢ñmPK_Õ¦¶šæUÄäõ§ ç¢)BHÞ!þ¸#[¨‹îKn/‰¶ó›Èd =«Û+v{Ù¨ä‰bqñŠÒÐ ¶WsáVóp¯è"ž&—ÿHã`²ò 7îlùöÝÕ‹ûöG¸BX6›r3?¶ ™î¸ ¸ÿ`œ.Á*龡n•›v™Ç“Ëórn蟟gÃ3‚GþœÇ^uA.tèN²îüÈ[#Y~u÷O³Ö÷uª³Þ(pØÆ›Ãǧlñùøà¯ƒNËÉÎendstream endobj 5139 0 obj<>/XObject<<>>>>>>endobj 5140 0 obj<>stream xWms›Fþî_±£‰;X‘°„lÅIÇi“8ãŒë¾DN>”~8ÁIBŽÂ!EÉø¿÷ÙƒCF"_b{¸½}ß}výßɘFøÓdÊAròÛìdäŽpØ<ò%ߌèÊÐlAÞˆ¦/Çîtú‚f¡¹5¢YàœFi¥’N¿ÍÖ'#Žq:z—ÉP.¨Ðyhj ?¡*籤ˆKùs‹õ‘~ß½1Ôöùéc}mb4(<ïÓßR—yZ€V¡Ë¢N" IoUõUP”’*õØãÅ£þyK}”j*2‘øNm¢XcçÍ[ŸE´¾<ÿìÈK#ª2åšÆmoˆŒ º&Ñ#æ]TÔ9¨äÜøZ;Úæ}l6aC‘Ä©åîlÄÙJDFÛ(Ž)Ÿ%¢³³^÷iQ¦ŽTJ™ÈE"µÌ \Õ+JñeÄ9<Ì>þz÷ð–e;¤+-E"_–‰DpÕ¢I0’Qh)B>«£ÝwɘdLi ˆcµ%½’ˆ5·ÜÛ¥å,†‰VŽÍþæ‚Ê¥axr•˜{Ö)·¥ä NëÈøN”"ÁV¶õö(ãDë EAx~ýŠô­eºþr¥ák>÷ž-îžÖNwÅzÉ8¼}C‹(l¸ßI}SûŽ‘; ^±–¯ÿÔyïï»EÅ ! pç© ;a¾ó,J³RXU—)ÖNêgÍë5Ý?ÜÝ›Ý÷æN¿ïŸýô”åˆÈ6Ëx6†{Æá/]ÐPçª*å}rÖœ¦®üì£ÝÊòÎâÇYÓ¨SåZÍ×2нïÙ*6¢»˜zÏÖ††¬´™Ñ³÷(ý-Ú2Ëâ)_Û²(}®zîÄ%ŸG°Z‚ÚiÅx\¿MIÉ£IöùÍñlXÐéz“z”8÷JKø ´qäõóçôþþ¶éñ@¥ £ÏJ4—2¥²€¯ÚWb€/%e¡A§@%Y㮳4ƒÿÑ0Àˆ xdÙŠð-s†&eáŠ>|º}çSdž«œ‚• >3‚4f¨$Ò—Lz½³`â]°ÐOÖ©:Y¢M"—ÄîÓÆ–ð¤­ÂSÏ~ujƒæìÑî #˜f9¥rkpø‰Û‡b¶9jXMæ2— ¸’zQj‹nl"Ò°‚£Ý° h)5JáL¡6 Q‹(Œþ±Ó± ˜ÍJd2‡[Á&k&˜Ø¨ŒªÊ‘ζHÞ7Œµ<±E6O·)½Gk h»Bù°Ù–VO†$Éueˆœz 0Q8»m…ÿÈ;‹ïøgßSÈæâž‘…¾B?W>›H3ScöBñPãªbû(ËÕ–B™(LÆT¡e­Ø/cCÏs'¬f˜éçtƒŠEy™&Òe©µT@™aÕŠ®QL&s§\Õ2‹®|³Ö™]'’Îw§Dv˜Ü‰+ÞEó\ä;Ì6ùE$Y,;çÑ#ZZ+ò‡´:*0êÀš~~kÚ‹áûX{£=èf9Ê,N¡çüîôPR\i§…0MгM.õè9Aèñ ÙËüißwݱ«fµÌÙo®:¢¼g"j…i0ª;4Œ\¢É—›þítÉöeµ…^›Öµg\TÇ[*sðJÈÍnϺ9ª±òàn·ÚhÇ®7 ‰{10ÊÍ{«Ñx~sUãÏøê½œ\Òôjj Œbè¹#z£³ÄÁm•r­Ë«ÛÃU¬¼ ëì” ŽC|HK½²Ú=°`öËtxøGU>/XObject<<>>>>>>endobj 5142 0 obj<>stream x¥VÛnÛF}×WLÕ¥kkM],ÛªS uí6E_Š¨Î cEŽ$Ú$—Ý]J‚ü{gvI:T#Ç@)÷2÷9gþé !¤ßÆSþÇyï—y/!-¶/½‚ÓÛ.ÄæK…0½Šéôæ‰;Â<€ž÷;c1ª²¢Ôia³" 4Z8†>Ðÿhg(VhïdVaDG­Qg+:úéhþÐ a0$ )øÔùv_§·àí% È®Áh\Û|Xc±ÊË4Ãd‘€® Ø"öËéz4ÄxLþ%Áwð 7’çØQ8„áH„ã …Æ‹¸¤¥gågòÑD Cqo“$-VðËKÔ¶ˆ¥±¬‚Re»\érÆ@ªtvW¢ñR—Ø¡‰˜°Qï?¼û LU–J[X*ý™“ÃVéG) YKK/Y–ZQ¤EؤÚV2ƒeUÄ6U¤b™Q\ü®¶¸A}â.%¸”Uf)Djº™P“6äh$ ÊÝW[gIãy*àO´?À'™§’PRµMíÚ‰_*¾Ãa±/'áû´ˆ³*Aè›ÜKÕ´i¿Î¥šlù¶9s•*:2ÿ¹“¯Ê°®BæhJ#¤nEÅ™4î²!|ì\.«E–ÆÎÈÏ*Ú`nTšD©­+ã7ve !:ò>5ÛÞv¯úm¾¨2Ym3ð XÃÍ僕5¢|_²´ÏW«©éf,% èå¿?v;‹µ5E³çg7H|Ÿ˜ú®® ßêô¡Á¤ÏËX${6ó¥/èt1UUAO5x­/k$œbpÀðeL¾yµÚ¯¤©©7¾Hî—2¶JïXV·r[h#ý;Ô;ÈT•ô÷1íe {·dÀÂ'Œ+jcnëçr˜òõ>j¨í‡7®7Ë Å<êÖU}@´EÞlû nÙVñˆ‚v=:ª%4÷|¹¶§…KÖs¦Ý±Ãxþ änU7Õ×é@FuAݶ×Ü÷ׄÅ7O1– ‰ƒ\œü”:¹L™È˜K™ §Ñ_9hí͆ØÇ®UµZs  ÆJ­ò¥ƒaµt9½>>v€H¤Ñ‹%Bv¤ìe©«4¨¹Ã¿Z<`l…“ìËiC³'á„Ìã%Æ8ðR£Ç÷A"1Uejgˆ2VnµDM$”;ûügþáª0gØWq\i Œ¥—M›æ$€ L –à#AljS:v0ugh1ÛAIÙ".rñã`‘U®ú·Lñ¾åè¹?œdwÐûy(ŽÜ¿{‘ð·!–$}޵¼I x”B‘ƒtäÜÆ©ÁdžT ¼ãaXì &ÒbìxM7=5#±.E“2´g\Ûaÿ1i¾FÊçDÂ’PÅbsí¸!‚&ËŽ7 p‹< 4Ì3r£É€eªeÞgꮳ*}y&á·tCïÖAÎå#çÞ™m3>4tb§*ýǦÁžñp6KvÄÉi|Ïš£à®¦ßbÈ?½½¨›`x1gã3˜^LŹŸÑxð0ö«Š‰Â ëêˆÃGc ?=8÷xó¿f±³p*Æ#šiÜ_NYÁͼ÷Wï_kà[yendstream endobj 5143 0 obj<>/XObject<<>>>>>>endobj 5144 0 obj<>stream x•WÛnÛ8}÷WÌéB6bE¶§í&ºÙd›>XÔè¾0h‰²™Ò¤KIvŒ ÿ¾3¤.–/ÙÄ r¡8÷3gF?[}ð«Ã}G‹ÖŸãVàxXý038» à½?„qƒFúþht ãØÞ `y€ŸeB«Îø±@¯ç±= „Þo†§¹ÌÂ<ï] áÇH²4þñ%\Ã#W«Þ§;¡â:½ö#[±3ÉÔì̞ܰ4»¥Ëd²vþ8¨Õš¶:¶Æ­µñÜèõ_‡ž•8…v¼Ql!¢I„Æœk/ZûµçCó¤ùß;þ”qÃçÅ4Ǹ"~ 3iÆ2m]én»zßù\D’Cwåþ8¥áYnlK_Õ†»ŸB¯Ò°ŸÉ¦ß¿ì…³»s 'ÐCHôÃÞ}k˲9W0å§<†Äè|Å‚?8>)%« ¬Þ`à‡³Ø«}cUz®ë<øÛõ½õS«x’ ÃUè`9Á·¹õ¿ôÏEYæÇ–±{ tFAê²Í’ÃŽPåÁ®˜Msّه÷®°H1ˆUåÃxÎA! Õ2'p>d°Ì 7$F8 „ÖÏ ³Ì™ŽQ ;…ˆÙb-¹I´Y`ÅP:i£J}øÛ‚B¢¥Ôk¡f4^¤Jrˆy"”°Ö1;Ḛ$ÈÚlvbùXÞ®ée ï(§ ¶ =uTp?Ð*5bºeTÈ#Û8ÙüIÿktÃ-ìu»aç÷Ç\¤¬ÈV³CÊîÀ6À<×.aý¿ÛEc*¾®Ñz'JDLÊS8A›Üì{j­…ðŽ¥Ys`ø+O©\:7ðCéµäñŒª†(Sßø‘B“k¶IÁù‹<€öª;EFp:‹KK£Ÿ6ÕÈp–!Ú˜¥ƒ ­ìMú}¸#ì,ÜLå„Jì`jãLî¸ÝnL ©3¼f*ƒL°)21þYÂÄežäª¸lð®á°{¬UbŽ9O‹N;¥vp,’‹ˆÊٳŢ9¥Kqó؇­RsƒCi‰Ž”æOl±D'Ö"›£UÙ2T¯†+ä?ƒõp"ù“ ç‹…$Wv”¿Ünbß!©Þª™P>"ïL%ΫÒèsiѶ†{huRBªý Ö@Ü ÏeCÕ7VÂd9“°Ò"œ‰&s7êiÓ'¦ƒ«+h×z ÛtŽ3W6;˜¤%cùn‚ 'sò×ý‚÷¬Qhž½Þ¢ïûpܘ­U¦´œôe›†ž@Œ¬ÜøŸ¨|1%¶8ÀvjÞƒëkÂNÃ,å‚>‡y©ý› HÇW..Ó dUyw´ÕU©&qäˤ6>Üeì´P ͘Œ&±ë2ó—ñ[{ ‚˜;_ã²Z? ;EOùeêŠ ½½ñQ+ñ÷`Ó\E”P-8^¶&Ï f±`Me•Š·m9ÄÅõ4/-ò:33ni ¯8hK{Ý(‰HJ@Ò|EÓFà ñ ³bðZ-ˆüYÊ-á³on1¬3B¦ËL‘Kn’}}¸Ç±Ë:hP®.K|I ÄÕGcCà1‹ŒÆ Š$¦´2//ö.©Q€h¸²a÷'UãÇväÙÝû"úApî_ /`t9¢Qÿíßû¿{?€¿t”/ªqWw¯?¸»›½KGbƒs¿ø—´F‘— å˜@5z-7ÈÅK\çËÖ£’Ø©xŒüá_ÓÐæðÃ%UävÜú§õ?uxendstream endobj 5145 0 obj<>/XObject<<>>>>>>endobj 5146 0 obj<>stream xÝWioÛFýî_1œ‚2,Z‡£( MìÀ’¸¨š `E.-Ê$—!—R”"ÿ½ovIê6zEQ_ ©åÌ›7o~>êQß= ùÇOŽ~uÝ.n6ò;:»îÒÈÐ8¤~—†O{îpø„Æ9Õ¥±ï<ÒËL&"óœYymú §‘K:™Û‹O¡ðµÊ—Ôš©ÉLúºÕÏŽºÔéáñ`ýq6ô ÊôAÅ?¶ æB•ú!¿o '|åR—yJÇßqülëÀ·êзî_öó"™”±H}P+šËK –©H"ÿ“/ }±væ¹ç÷¼ö6¢ë(—Wé]”ÂPˆki¯·,­Ÿ:h* És0 m—fè쌘ÒSI BωUzGþ­ÎOi¢T,EJþ[™@+ï)Œù*-t^²z¶8e£D3?EAøûõ+]ÒL¦óÎóë( ^ò}Ïi5¾Zûx`&cà xã)‘zª‚›W”DAãêµÔo«ûžcŒœRë"J#ý¼…+Ïyó›×þpÐwã6ônX²2Ã}w7©|¦þ:ñœ&r:9ñÚßûö¹&SÏh/¡µã\e¬›@ßÉÅ{SºM˜€|Jlõ”B(ÛÃê°õ^ûؽû$,Ù”¬ty™uQ­Äú/¨jåì`jÿ¯²Z…¾¡«U¶þ›ÂÚ»Úþ^å£/Óŵ~Iå— ãJÄc…Z|W¦ÁNƒ'ªµl[<+Üà»ªŽ¼ö>ÓxºQÌ^ù¹ZR*4Ã(¢j`î÷l¼ž]ŸVHxïôÕ|v~”ZËœdž«œ¦¸#tÛ…*ãö­»‰$¸ŽR8×ÓÍTÒ¥ñTæø ¿ =;§BÅ¥ŽÐޤ9—åjËt™;蹚ä‘d±¬ãíóÈ ÐÒ¹‘#²–Ihñ¨ót®â9œ¿ywS¹ýùãÍk*‹³bIw2•öÆD lÓÕH  ø²äP°]â&Î<"Š ‘&(E!"ÄaH‘C˜5AdCW|0D<2wéBFôTp˜²Kb¢æ.áWPZ&U!!N+u_f†.3ùÄ’µÁvŠÀÀµàxà´ÊÒ¤|¿Ì«&K@ðU’4ºlôìú)õÀsˆe®Ó2áýs·×uGô" ƪü N ²SÌæ¡¢,wÖR-%¶tîž³­S™"ÀLA"ˆíºƒ¼…¹Jð§/,SŸÉ;%Kò"Y†#6#à‚6îÖFÐ¥),{8·itéj %e¾7h«@€pȇ“QˆD—‹ÛE Ö èLEmr˜÷©Zàd•;½PA³š´À¼Iï˜=°¶Z%Ö®6ÀØÒt鯍 ÉÈ¡i뮡 ƒÑ2‹EÛ©c3á9¶'¬ª×YKŽ?•þ=SÇਭ38,DsËT›:5“œ·ô?é`#¤³.7á³ÀD!m“%òº|*ŠéKâнÊ[\a‡œæ.gȹLy• ¶gË +BöªŠ×œßL¹-‘öFü_Åѽa|û:À%ŽbZÛu«—˜N¿ïx¥Ùxù@1pÓÀºÁ]hüëí=ÚžY9‰#¿YV Vì™ïÍnÄIÚ»¬Ô»­ íÒ.L»ë’°š×|t“ãÃâÅŽluò ¥ÀáBa—ØÃù{ûƒÉ-ÑÝKìÙty‰DEscßÚV½Î´Û(ëAW¯r!è è¦+}ì{ ¨Ìz{í;©omKa==ìæQ5èF•Ä{£s÷ñà1 G#÷‰Í#§¬Ów»ôJù%ëLp7b¶0íéÎ úo6ÇÇÝ¡;è£Ç‚øÁÓ›¾ýtô´=Šeendstream endobj 5147 0 obj<>/XObject<<>>>>>>endobj 5148 0 obj<>stream xÍWÛnÛF}÷W ¤¡‹ÖÅvìA‘8q“¢@RXmPTE°"—ÖÚ$—á.¥Aþ½gvIJ¤£ÈSmà¨åÜÎÌœÃÏ{#âwD“3þ‹²½WÓ½a8ÄÍö_yCÇWC:'4Mh<¤³óQxvö”¦±;5¤iD©0†®´¦¯ôíùÁôvoHƒ¾ŠÜ<¤RÚªÌq9ãÏt˜àêgý}ÂÇçô;¾:!~.¡\ Æ“ÚU0]HKS½Rù ­t•Æ+S¤bMþAäá ‘Ù5ÐJÙ…®,YØé¿Kéxç».d& s½”!}„÷xs?–‰Ê9š{lÊÏ¢è‘Ióyþ†K4æ•ÒT©%eú‘Ù²êG6ÁoŒÇádx\±¹˜#zA¹\1 ³`v°ŸãŒü"²"•á<ütÿ‰ëµ±2 Q¾°(UnÓ|ìóÁŸiŸž8‡¡Ox°åÙAmáøê‚8ÅÍÓÍñI8†ô§V16eiHä1 Št–éœ~*4F’k®n)¹5NÂNù}.)S7 ‹¦ÈcYÒj±vˆÔvY|–®?¾û…d¦¬AÈ¥;S”úËÚùePiUŠ¢€ çQF$×–ŠÊ,dLˆR#¾ML‹EîÐR ƒØñœó(Rnº›EW³R7—lÙM*@êÜÖs hï®NcãÕ/Ò´ÒEÍ}xIaÔ¤9"Åa{H¡Ón+]Þ9#—Ož´FT¾ÔéÒe‰zÀùB–ÊŠßÞ¯ ¢Âê†Ì[çÿò£¯ ~uA€“•‘Eg¥s#í?NLÔ?M W7sÜ%òôÝÖûÑÃlþš©S:ŽÚjø‰p¸¶·GQÍS˜±ïDdë­ÄÏíĽɲ=}OºM2JÂx:s­SÉÓàØ|¼Ÿß¢b¤ç·÷V¨sôê„HczÓ‡*A3Á–¬qÓɱÏzqÏ:×°Pðë9ÿa°/°?”éÝîS9›¬E—³ÜÎÁÆìZ7 ;ä™ûT|Z2WÃ)söêV ½çgA7ê#_£Ý(›8|Õn¦)ÒnV¤s ºò¬Á‹+©RJª<ò_Y¬G·Ó:ËR弇¶u $ˆ…YJpŸb%˜U™Ä™E=»sðn×â¶ûñîFg¾äz¤feñ`K%üå2’ƈrí$H÷O×[´APgâÖð>0QAˆ:+v=_ukå¥öV±6ÒôJt09çbza „¯’j²«ÓêVšG¥¢õL@úµgU'$î8ÍêŽEàg} /1‘Õ(Š«l“¢ ª’EÌ@yBÒe—¶TÑÎ2¬y ß,÷:q©s£X 3v›w&£l%x X(9{½†~UYè­n~Фè|(Ò…*Ñ“Ìæ _=¼Ÿ9 ¼Õrtg'Cztqi^.…Jt“[CÇWMsÎOÂÓÉ)^5'áÈ¿Ùð"ŒÃ!½ÖQÅmêRá`±«üéÁS¿-~ìåâtxNÆ~¤&lùÍtï÷½-ô¹endstream endobj 5149 0 obj<>/XObject<<>>>>>>endobj 5150 0 obj<>stream xW]oÛ6}÷¯¸5–MñbYþˆ›eè€4]Ú Ã€-öâZ¢lf’¨Q’¯èß!EI¦/mÃ!ï÷=÷\æŸÞ˜üÓt®´÷~Ñ ü‡í‡ZÓè! J‹˜&Íûóù[ZDF* Eè…¦h°Vœ—"[ÿx¹xê4ã6ò¾ÐûªL¸jNa§£ý.K~KŸ„âµíD’K²’S¹á”òTª=9ö ¹ÀUA®(­Š’b8>”_íÍ5B¡‡ÖüÒ[^¾yã˜âÏ%W‰¬<céÙpƒ<¯¿./›à딬ÞVŠÈqÐ(ºj£‡i½˜†È}8™Úz÷ʈ“Hó„§<+Y)dv«#tk>œLü鈼¯•>;9’-? lTôŽº——©)øÒ+Ä¿\ÆÍÍòò8g"«?üi#+UÜm™HØ*á°7™¹õ9m0a¼Ö0é|N'§^ŠR…ù~éµÞ WÔ¿+ißTpµ!§G¡ú§Ú¶Á§µržâe…ÆÝó/Ná^ïîI¥5_ˆü4DGðøÚ„q4¿ñò»‚Jö7¿“Äò\In8Î$í~×°/7¢0èòͰÄBaLpÈo`Ç(®²PCŽ%z¸ŠYȯ0Qᆡíc̤k¡%î;¿©ÓDCRc,1µ;íøW¶e5¬‹Ü„Úã°ŸEÆ¢Á<âXqª ý?Þ ÿìT=q¾E–ï(ã;{¦GÚm¡–çÏLO”ß1ËÒ«•_’~Ü%O}Y•~®f’-½þGËd·Úõé{ª øk^6wÚùW´Ó"Qîo ~rÆI›…¿>*‡)£±ý 0ï=ä8'ѳ ú“U¢©1MéˆBäUI» ÏHU¯ÐQS‹ºN/ŒgƒÃùn&37E-z6`½+L UÁÖ€SA[ŽÅÐaU dY%Q+±ÆÝŽ+|(ar­ùö v˜†+ %ODU»gR–Áº¦bí!ã<â‘=Õdað~ßHC¤YVQSÇPf °ÊŒÉØ„\'†Ekv€Ý.n¶žžÊgl­„°j'åðÌìÆL–q8ûºYÄU²×}¼wb´ù˜&"=DbByXê|î(«Òp¥ãÛç;¢D£ÁtoºmaˆxC…¶ÚÚÖ¾vЦÞS$q­KU‹â+ʱˀÃ=ú`±49Ë«†ç€‰OÖ!À,½àŠb–ˆü˜¬Ý{ÑüÚVlxv\(P6ˆZc¾yn œÈ.ºŠe¢+JÓ’«' Aÿœ¼Öt5jgŠ×4œLÌ é$ÚÀ‰až4øYʱ€É’¯¶z&F‘96ï5¼îºç]‘l|3Æêü¶‘2=ÜXRßÌüëé5Ío‚楩Çr8ñú ê}ê¨ðŠ­¥‡okôOfþ8À=šñ¡\.0ú«V»æþt‚?8ðf˜>úyÑû£÷µíÞûendstream endobj 5151 0 obj<>/XObject<<>>>>/Annots 2398 0 R>>endobj 5152 0 obj<>stream x­WkoÛ6ýž_qa$­’ÆŠ‰ÛfØ€Ö]Òk÷H†~ñZ¢l¦’¨‰T§Ø~ûÎ%%[rÓ ÖI%R—÷qι—í i€¿COø_”í ÂÞð!ÿøãroü2Ñpò2PFøÕ<¤tµ×zÌh88 Oë¼Ø~Æêéi8l¯¶ž±z¶ómë«“q8iÛzÎh48ƒoÞC>÷õu+ J¹ “‹½Çt`?†“ÉsºŽ]¬ºŽ‚ƒ¿¯oöÔâ1캙(f(º²³Cz]ÙT–ttD_:[‰NNèRÝJz/n¥¾[“]JšR¡UnñÍ,Ð år•®)*¥°2&=¿‘Ì‰Ra áçý=ýˆnd~;;ìÿt¡òxÊ‹³€_SÏ;Ô›þ°k$Q2ß½¡DÅ]#—Ò^øµÆŠ; ÆÌJ-¦¿Ù²‡ÿ¿ÈfªóEØ‹ƒÝfÁ&=³Ã'õ¶£ýáîÆV@WÒþ›ÎŸÆ›}••=fÇÝa»Á}«J7H½Ê;Uêíû—0Øã\ž(nB}` ?¨‚ÚJLXWµ÷ßQ¤cIFZãÞ¸Š>5äkÎHÐd¬k; LfsÔüV”JÌSXÖü†ÅC8é+ðAf¿®òîŒÒ£´DUn¨Ê£¥È€ðj)©‘³Ãc2|b—Çe¬¥¡\[Ò«Üyou¹ùNÊ)›å„œ;tÓAŽl$¢J-Ūhê±2\ìl4Ë‘Î-«Èê’DS,·>¹FdHˆÊ$¬ á_•‘HR9eÚÀ¯„MÖîø(#a¤9v׺¢HäT®˜$yW¤*R¶åäæô­ß1;´ñEÕ$¢¥’ˆƒ8§Ji8BÅ<•±Œ»áê‰øb2‰Ïái"KC~—²æ3éRIP>F< ~""W>ʼnü.Cú„üqeý|M™ø¬@­Í_(§OM7­üF"MÝ7T¾E‰<gW—-î›v©Q4]ë³På±,Ó5;1­ãéU+«tŽcÖ´’´¾‚Þ;†²øŒ¨W9r°TEÇO_C& Õa¢`P݃+ÿ¿ÄÅ£A$€;»æIÓJ—7j—JÜñî!TÕÞ1N£TS@QUÐj)s„Xîàf .™óÌK@'÷ùàŠRRêŒæ’3ØP¾A&K~]ªn¥6$~¼bì_÷Ãàû²cBúÓˆ…ôÎ9ô¹ŒÊ 85—çÙmcìFáxŒ67r~#ªäCµêȸêÊúÕÚX™…h“aQøi> z—¥”9'þÓ£gäm…@R³Æ¦¾ËØ+¨{*æ*Uv}¾cì­®JSoH%›ÄY=Zòk*PX¬›†¶å£= îeŽƒN£ }SAžRÔ‹|M|-=©ý6.p#ïl)¸0Àn¦µÃ#ÉIÏP*•µÀóØ+xØØ!Q‡• X}CÚa 2Äàb}ÞB”s®|¤ñÖéáj© XÐX[•ùçÞ³- jb@ÉÌBA¨¡>‹¹†Ènµ0Qhˆ®»Î+Kh_¼Ì)j°X÷VîܼͿnúv@õTæzˆ}÷I¥^1Ò#CÚ?µÜ3tÝ>š´Â@$XRNbÙG*ë'jÂÜȰŸ Õ"gÉoó°™~ŠZ{wrPÒæzóÉQñÕG˜O@Ax æªP4¦»VèöÙAÞO`Q•õA_:‹ÔbóWm³HGµkÍ|Díhž|„¤™ü¥t°«wtµƒ¨;ÒýS§‰¼ë3Œµ³¾odšì ötMº§ïd¾Ã&2Þ@©ÆãO¥»…#/Æ©>MŸ=s躿5Óºn¢ ‰¶é®î<¯ËÖuDÌahÚÔËz¼ôTÙ¹§á†pÆäÒ<}nË3%?‡UrœÑÍ-¯¹¾—N7߉´ÅÚ%¼™KèUïRi%úZ{±ôs¦)7 nÔÁßmúÌBŒV¦{ I¯œ+]a̜˥€d„j£²\ÞÙDÊÔÏ\¹®à)BÜLWÆ n'/‰‡Ç×ÛþhÂlá:‡CúàÇ’LäÐH'[®ç{r K‰ÁNæú,× mÆy—À-˜Ø<ß]q€håà‘Yê•AZ±‰f^ÀïŒ]Æ4ÕUh((>oÆÏ ®q´&3à˧Ë;ʃgs½Ôe*ÿùlŒ§ÝûHw°­ 㟫ÊFIšqKªG}ZrEv© Ñ'ƒQo—în÷,pË÷ ø¹Û5 ?|©¹ú¢¾d _œ†gã3š¼„Ïý`rõéÝe„+ÿU\>'Üœ´t¿»ÿÜkÏÿYò³Á$'Tút0äó~¾Þû}ï_»UŠendstream endobj 5153 0 obj<>/XObject<<>>>>>>endobj 5154 0 obj<>stream xÍWmOãFþž_1=­`ìrÕ}è½pºJ•Ú UÊ—½I önº^‡æÐý÷>³k;± ´ôSy qvçí™™g†?1EøŽi4柤¼Ÿ ¢0‡í‹YÐéUDáˆ&sF4~‡ãñš¤îVD“$øöãáävÑ Î'iä¢,é}v'é¡>ˆÝÑÍRÊœîùµ‘ñG«j–gÉeï:똙²´ùô.½è4ðßz÷úïi!­{7 ó@FÚʨÚ*ue¼ë§WgÄ~Ì]'ÃQb TJv)i®ó\ßgjAU)x6º ŸÅZ˜[iÈTJñ)ßMt*ñÆèj±¤ë›/Ÿ]T]O†Ãp4¦i@øÚ…Þ‘’÷½iGÓÃp7š.h,z½)­,B]Ùpe€T®¦Á+0•ÙWyI¯èȇΊ®ñ£2=|¬éô”®³¢Ê…•$h!ÌŒ#M¹Ll¦UëÖô"aõÕžš«L‰<û*X˳wÿ[Ofï£V?XšI*+pJÉÉ–²¹K”‘e•[Nì®*K‹l-K*­ ‘ûcïLG€¿°õÍÖ‰J[?!¡á<:}†^\ “‰Y.ÛzuNt ÜÜÔÁv²ïA6×p8ùÕ úúVe\}d '\[¼ (Q0Ç[¸Õ¾«˜ÓÀ)üîaï±ILì®f/yL¯õ½’fßxt²a·v¸=÷ÝmJ Y£œ,ï4ð¿£»ûäHœ4 JæužpMÝy¼8”Ÿa׎œÜ­uÇ3Àê„߀j¥ÛƒÄ<0õ—6³•Å å®Uù—Þ75ãæŠ[¢j @ƒÎLûÜù1Í+å¶–ç—/¿vzßk®é÷l=÷™M_L>ÜÝÔáÂŽ®ÿ)é4ç9§ƒÒ{ŽéŸAªe<ï&ÊËž^]Ôw|qžÎi|5+1/Í'Ã0¢:© Lg·9r}à? ûäÏÆð,Œ£0Žé¿;Bake¿5xjb.ëRP€JV~ÃÑÿa¯9‹†üѧÉà·Áß)Oë;endstream endobj 5155 0 obj<>/XObject<<>>>>>>endobj 5156 0 obj<>stream x½VÛrÛ6}×WlóÐÒµSËŽ“ô!Žqf’^¬i^4ÓHHb  Zf;ù÷î #É–Ûi§µ5¾{=»{v?÷â÷Fúdeïõ´—²v?ÌޝR8c#˜.`˜Âäù€M&§0ͽT Ó,ü’Z-!ûÉxâž—•ï>\³×Å­øm)ÜÇ•r–Øu±¼@¡#p«ÂÎ^L?õRèÐNîíxA0¡UKùP¢XÀ,ñž¾yéìþx`Zb Ñ3)Á‚K+së5Ïó_ÄB¡21Kö…øå? ·6Šœî†»-ëÿ;¾廀>âÙŽ"žÉíâ"€ìêA*ÙŒ*¼j $q)YxøC²J6'çpÌ)ÇïE©M%W|)J¡,´=ÿ$2g¡âÖŠœö¾/AòF˜mOdtÌÆdö=™)°Úe0›qs ÜÙmë•PP[zO¦¸Êá¿ãP}ß@&É™e0Å4+#î ]Û¶_À®ôÚ‚Vl­07+¼*…C‚)æIl0l:}k»6” yð·‘!÷A•­tŽ¡èEÜW>@BPQòB~l¦+ cá„!€¶âXÔ*s…V°â–ªM rZÙ"òµ”zMx¸µöî#çáÍáê‡l4ÂQËëL9¸”¡`»=^`︬ÅnÃE…Y%p>΃ä,A—žÜ¶àƒ£ æ)ì:Žö¿"ÛÖ®ê¹,2Ÿ+Nugm–øp¢ê,ñÓ»À.r°Âu™|uIÑ·Ž‰g^À®r'‹œÓðjqFE {Gó‹ÏcïhR×§F—TÅ'‹G„Ø% Y æ6V$Clsš%C„ä¡XgmâòmÌåqÚÁË—ð,Ê0ß,çðŒ~5·Rÿ/E"BåzŸ„i‡Æ€§øs] >ÑËT4üÿ+¢dïEj¿ )Fd¢©Þ4Ö‰’éÚ±Êà°H5KZ´ÂÀZ‡{ÁbˆÝ¯4Yt°,¢;¢ÃLçÖ…”Àåš7H¾ä0Ü­G0ÇßÄC¡ þ23½-yJ;O´È†DL$è©ux²ÏàZaQ<ÿè-ºª>´Žšy½jŽ(µÀS–ÜÌ©½3d+¤Câ4e5F·d,.˜=Lµ§ÙÿóÃMQÖ’ãÖ|,6õî´ˆ_f÷R|mjuU(.‹ß9Áð¤ìÿ×<ت•6·xhÈŒÀ̱’…[í^  LàÆÙ k™vðnáÉ _‹µtE‰$Þ ‚+ëÛ­äx˜t<²m¾[ÓwÜ|.`î´Ìi rȹZJú³ÒØûÂß‚xrÍ›0 ô†:ž«P ¶+Rn‰BáÐr‰…'ìnŒ9¼Å§Ã”Át@hYSùÚ&ðg†«Ï©v|x…g ޵i¿íáò·Ð_@X{ñÚè(«ÛxæáFˆfè–ŠO°‡/•­‘EÝ Ïé·kaÕw®FEä3ZŒaµÄº±gÑÞ!dÄOºlKO;tvuH×x.á…W£^£ýª ¥;‹·æàlÌNF'09;c§á¹ùxý¶?d)¼ÑYMÇ£ RÃ,‚tÿ4lúpž¤6â ‹xÓy¹œö~îý †ÔIendstream endobj 5157 0 obj<>/XObject<<>>>>/Annots 2400 0 R>>endobj 5158 0 obj<>stream xÝWÛnã6}÷W ‚¦–»¶â[œ¤ERç‚,Út»1P00"ms+‰Z’Šcûï!%[ÒÚÙ<ô©IàèBΞ9sñçÖúø;€Ñ„þ¢¤Õûø„>ôññ¶58ñýÅ0œ@‚‹Â‹â&†‡Vå6sÜVyW¹M`0˜„ãÊË_fOÎ^ÂÉMÎÃÌ0ìÃäbN&g0ãOfQiù̬€ëX$"µ üÿb!´H#ñSgö©Õ‡Þ×óÊúX¥KX ;ý`õeÊ/9ßn™ cóüÓ0_9‚ŸËGM—ZØ\§%ưp; °óNsË—ÂۣΟbÁ³’Œ°¾ Ðý_X’Åâýý]8U©e2ú±ºÝ¬å’è‚]IÓ=ȇ˜wº€‡`zrè“›1Ðíz¾71 f+ Çj-‘y»ÉDÂ2kÇè‘Q-.âÂH-8DŠ‹h[û{Fðír$ÌF+aÜr™f¹…Œi–+´[ƒŽðb%ˆE‘D*Ÿ; ü‚qhb¥xÅ+Øù5ùÜãÜ€L{“‰H.dŸZåž¿GÈ(Nõ²(fÆ„%– {Ãa8¡¼yp\ð1üQ1œ¥ptH§ßùÕHÀ¼sT“LÝ MnEÇM=ŸœÀujrM!`Öàv \ “¶-†"ŽEd¥›Rä$CXh•´ð]&Zc>:yÊ…Ž7òé»wž 0ViŒ³b$´Ÿm&þßyí‰:.2æH—eÆœ–3‡ƒ~8Á¥F´£‹¨ÌË!L /€mb°”#óFE·à¥µZ>åV¯¾R蔘c¬¿¨<Ê/G}½Îcõ îÙ=\¿D"³R¥ |1©¯-+uÒÅ“òC”KA-œŽ<È£Ji ´3ɵIi‡f GX•KuÁÀ U²U™Kb’'b\zuÁ°;È.߃)W?yÐ…ˆ¥ðD|fR„uÑ'¬±HÓÜé¹fÙ[(«ˆËÐ0·2oµX*-Y:e± Í _ð´ñ¡r¤•Õ‡jœ;yÿ)c‘ŒZ;[FY–b«0bQè+”ä‚ñÛ”m ý&>Ü›$a½Âfù,þm•$œDòå‡;ZEñmØßÇo¿ ÛÆÅÆä‰/èT}q’ìZ{ÖI-¦hæÇÒìÞÒè ÎU£ g®)ºÝºh•nå<ÀB Á°µÑ*É®ü%g›¯­Á"ûn˜_ÿFV^y…¦÷ìCWü·¿ÔÛ(J<ÇÚz¹4kf”¥ÅÎO¹zPÔ ÈyQn´|Oyp—v«·¿SO¨;‚ÂÇžÍßÚê!ìí÷Êõnle(}Ç <0ÿ°,>®Vxø$|”™دNIŒò‘,>ßc ϴǃT¥=oPå–¦ê¦%çCWæn¤Fºb'ÍX©¿±ê¸Úä´éò%YŽ!œ—‹ËcÛõÉáS§«öô&Æ}ù@ùér¬˜üH€ázÁ"ñºö½Â‹®y@ MuáHì‡ÅCÊñ©T— Ý9Å4R ð§^‹²LäGòXÓ£³º›l½yKG¹m Ý7ýì1ëpz»î²)ò³³=÷MÁ¡*EÿÚái.Æ9}7H§býX3U?syâ®ÓÆ[Ïû†S∮ó·ŽàçÅÄ;8‡§£S˜LÆá™Ÿ4þ¼»í ñ‹Ù•а@ã·*;œ×ýêÞ™¯¥ÿõüqÚŸ„£!~½Ä±cÜ“ÏëYëÖ¿ƒ:L©endstream endobj 5159 0 obj<>/XObject<<>>>>>>endobj 5160 0 obj<>stream xåX[oÛ6~÷¯80¶ÖFÅ—ÄÍ6ä!Ë¥s±¦Yc````$Úf+“EÅ5†þ÷CênËé¼¾51 Y"Ïõ;ß9Ôß­ôñ£1}üUë×i«ïõñfþ¥p|sƒ>Lç¸vü^ö9^øé’Cwú±u|ƒrìšÎå3^¸»ÙÎ0ÔWúJÆÖ¿eO |p1,¸äÅ0×jµÎUªµ 0kŸ³$4`6_±(þ93êÌ‘åÃ> ‡Þh„¿‚Îé²YçcL—³.Üÿ9y3}¸»†Ðþá#êöCÇ’­x›Dávr¯² ¹w«·àæòÎèYÇŠ2J̬kA=²¶¼ñø5)X/¹æð²jÃK ‚ÑLÆ¡‚FÙ(DZ}Þ€µÈØ^=Æ6º»rá4X“¥“DPsÒ”aH6FLãÃuø¢®1@ '²¦ÒƒJ%µg G¸4BIëÙ’K@|†`}c°R˜cÂ/î&°f ±B•KJx(>ñý ¦z‰¡÷Fó…Ò‚ÉKr0MJìÅD¹µ=Ï-àŸäkس{Ööƒ^iI&×»¸û0ù½ƒQúî3ëþ’…ÍbgÜܪ÷‰A³žµ¢èÁŒí²Ò1†GŽÕÑËÅ¢³ CÈé/™\`h©$³hÞŠ±(1s¬)ÌZôÄ„ÃãÆ&ðòÕ+«ª²é§”zºÏ’5ëd&²0µ¸Âr[Y iܽçD4–Ò ÷—‚?q´Abˆ?=Xsô@ž…cëPF!–sRÂ!|Æ¡X,M¸Aâ:f?D@„eÙ†ª€Õ‹` vÕz ÈÙJB«Ÿ¸&nK‘ï–Vù´º½ãïÛÛ íázÅÁôÆYƒÕ‚U#øC0ìGã"e—‘¿dy"®Ã •ÒWèrìâ4fôŠ’hgîF%Ì ù+^ªµt ô2_KÅ¥¶€d¼§hö3³£ÂJqSC¤ùy›.\ã1|ìœÏ>*³619v‹œVòª¸¾ø0ëö j ‰Ïÿ\?±LÛ(æÝûÛéo$§0¥qíÕÅôzÖÅúi7º¸ð£ˆÈû¼]u¯íª^×¥·CTë€d‰kcUii+ÃýŽ„v´UÈJ³ÈUVÚŠ1H¾,½å±ü’§bã e4 Ï:ÕøS^8Ãñ‚³ýì’féV£‡Ó^Ô0BR¯ØÆí+:Ùa`s5f‡Áÿ ³fšGJÓ<Æñ­ÓÙÈŽ8^ઌ‰ÒIÕµw³TÝ0åÆËgæÈ(y …ŸŽ_iû§\ϳXò>Ýfp323TúeA2[MÜlÕTÕ´æ¿ YíY9¶CÝÜ2-:mUJt÷¹)£ÃZr[v_<#4'Ço*5§Ñ-©Ec ʉ,í éÍoƒ,'bŒÂ³r›ã`p¤ØÆ`±™DKàŸÙ* 9N!žÃþ_Ûh‘7EëpyÎÈÊýú`.¨Aŵ£Ã4SõQ“d|¹xÜØía–âœt³[Œ[zP¢[ââÒ“tºº/µ;Ùo×Z:K‘OJrÝýZ,.é­ßdÃrQî»ùãà€‚à‘miú!BÁnxPåì•Ø\3ß1wßœ¥ï€g'ÞéèÆgãì• ½_9z}¸R~²Â£?¢YÙ·8<ºÕG¯ÝIpxâ úÞ`WôÓñ •z{Ó7urÂ"žuÓóˆ=Éâëå Ü‚[c´xL ©¨NûhÅ_^á9ù¤J·®§­?ZÿÁŠ‹€endstream endobj 5161 0 obj<>/XObject<<>>>>/Annots 2403 0 R>>endobj 5162 0 obj<>stream x­XýoÜ6ýÝÅœÑÞ®Ñ]e¿mç¾:Mê¢mÚÆwÁ ´Dí*–D…¢¼1Šþï}3”´Òz}(ÐsÃEòÍÌ›7C}:™Òÿ¦4_ñÿ0;™<á_SþõËÛ“ù|\`vL(£ùù2XÔ£”ÞŸtÇ-&—Á²3Ûcv9íÏvƘ½\çµóœ/çrìù~À§~}Ó*hí†^¼™ÐE0§›˜fZ]NƒÕêœn"1gB7áðãì#ýzvóñdBã)žFò”ÈjWÙœôg•©þîÇë ×»ÛW¡KL¾^½VNí®~rv=t:+"x¿K6W&/­B×é·­]#öÛ !<4¥îÙ!£oÄØÆ0g<›×Ô¾¢XïGç›’œ¡Ü8ý’ G6g ¶üf«é”mq…>%þ©‚¶ª¤p«òް^S¡¬Ê´ÓVÞà½xæ´?x¸wLJù7ˆC2¶¿vÌ\Ÿ1˜ý&O×&pšV™X`E:VUêh£sm–è–øp“šÏ:½h\wLÉÃXÏ™ýE<ÙñXh"MI.…ÕRÎÙä®ršTQ€Â%ÝéØX-¯ _)D6Ðzè·mÝv4¡ûGéEQë®ÎbO¢Ûȼ7ü`“õÙÿÑ`Sºc«Xº4=S2î9û¼! ‚VEîRÞSRv"½KܶïÝ: ¬¡þ}•G4(m7b4ÉKq ¨Ðså’ n±ï:¬¬JGU Ÿ’=5VáˆU¸K5!Ì‚£Öè•VxhMÖGÇ`8•º€î4ïºgo‡3~7FÒÆ»t x¦sÇŽ@.L+†°nf£rý3ñœbrMi‚_ !AÊ=<É}S¹6õ†ÌkÅs1ƒšÔJÂÕ¦ïÀfËAIÞžS’BvpV<ÍZÞæ ƒ$? ñˆv[u§õô)»Âê"U!¶i(ÑóÚ^ºrHXÐ_Z•,p†2HüÈ@Û¸òëTïÖÌç²òÞô¨Ú,•¡¿`õRbÉpDU=ƒ aRÄ©k¢à°»¤ ^’œŽPi ¯l­¥’ Ú©Òˆk)õ§Â ÐÒ†‘Ã,ì¡êBœ[¨q•KgòTïŽT¾¯­Ï8=¡Iɯís´1»’¾Gbì×Ôtê¤Q£DÂ}áʧ*±>íz‡¬HRß™|à8Exè7FÅÑ–+‹ß´>Þ`À•} DþS¾›°(8Š]iâ–¢&JâG¡¨¹û¨CD¬…*kn1Á×ï’Ñ|Q£2…ÌPöNmØ8dž&!ÜJö¬k§¿gÓÐ]>qQaaY@ŽÛ%mÚ7þ/ÿhº¤é=¼43Á%FÃÙ"˜Néûä–L—ؽF4Cg¬dß q„›Á…W&¸±¬ÅŸIîÐÉùÄWQduÉ‚¨?Up:VUÞc£’]ŠÃ¸Î´ÎCSa&: Èo†\ÜB}TQƒªæÄªî2ö×^‘=òôVq·Ñ.F”x ¦?´muÀÞ´a­·±1~¦Ù}æ\>1@F¬þÊsÜkK-¸‡–hHo3U©¾Mò¤>°ÝVŒhËзfG‘¡kçÏ€—”ÿêoÇYê Æ»‚½Rg¯¾úŠv–›# Q­lXçWÌ™Æ.N¹—ZêwkÅõÔ#gkOû1“áåTîþ¡ùžìÔÌ8ÑÏH—¡M pJpeêe€SGê«Vá–ÂIçÇ& +t{uïÑYË-4£ e†öP*¼ç$ÑÆRt ¨êhjеïmûïð õN#**‡°Š$×oµe•<½ôþÃõ[ ÀÓµ±Jµ„‘¯•+iÁ¦AÝä6qÆÌø\ñëAV« 'X*ËQâÏs.Ò)’ˆ™Å §”’‹Qƒ½¾NŒ±G]²Æ6J\d“Í¶ï –ÃhÔ©Ô\$Z–ý›ë$ÝpGÀž¼ë8(»©¤yB©à׺OnGý«úx6 æs\ܣᗵ=k¹©ÔF‚GHÞèåËÑ¡¿Ãçÿ$:å õ+÷,B^æ¡8ÿËízøY÷.¾Îq³~²•ÜÿöÉ?ž#|øŽàÍŽ…ðB}A`˜¨ž®…:”ÜPXR¢‚»­5Õf‹ÈqŠV…\T$ÔÒ„³·p)„p  †ß²Ñ¾fz…-î÷5WœWXñÍçP,£}àîBw< ç7ÏJÇÆfüý`\¹ÉÇ ¶Ä‰< ¹ËÕ†V3;=ºh±¯–Ðq¨<Šú†ÿåúSwÛø"ð`’ˆ~x‹nk)òNZëǨ-i<‚€!W>‚fÓõY“íŠ_{#¢7Æà#Þ£>ãð˜…#ŠUZvnýÍç >!88]¶¨?ô rÙdÞ¤¹æNÏ/‚å|IË‹e0“êÈB1žá;ÖkJ‚Àlß àkÂB^Ÿ{Òþ‘¼œ¬‚ù Ÿí/‹ÉŠMÿææäç“ß"endstream endobj 5163 0 obj<>/XObject<<>>>>>>endobj 5164 0 obj<>stream x­WïoÛ6ýž¿â–/UZG¶ãÄÍ2Ö4C‡ÃPÙ-Q¶ItIÉŽ1ìß»£hÅN“vÀòÓ¢Éã»»wïΟ†4À÷FcþIʃŸ'ƒx€Åí;§þõ€ÎãM2:Óøûa<¿¥I*»4I¢Ž&wýëSâ1£ã“~Gí¶èÏ*3¶n*UëbÓ£z‘;*ŒÓ/5ýªVŠêÍRSÎûJUç¦Â;ª&ì[*[“ÉdgS¥Ú›¼šÓµ1”æV'µ±´´æaCI¡œ{å¼=3»Ã{Œ H†'-M^ÕÚR¢Ç&øn¹6Q®¦ÚP¦ò"¦ –?Ý|øÅÛ)MÚV·—%&Õ¤êZ—ËJŒebHf….{>gm8"š5p¢*6ù½ã-ª`÷XW GSï†v»zÌ ]8â·’ÕµÊ+GŠæ…™© ™¶ZvÊR"ì#Âþ5®Ç8¶vÂÕ;Ñ’h#ªJ·Ž<1ð,vF=ו¶`@Ú¦K@I0 cî9Sj0‰)ò{}áýßòNuF`!RÙÌŠ×nG¦TáôôhzôCk¡ÈìR¼çnÊ—u[½w/çÍBW´1 ååU  û¥V2Êey¡AòŠYÆéfPª3=ꆾ2wze0ÌN’±`XÀ£dU’hç½zaM3_ˆyÞÿ»4U§Nø¤€}ˆ}óì„ޯ æ°T2Êéee'ÚÕvƾw5/x«rì ×Ö”œ4|tìvêTp`ÃÊÜÃGP=3EaÖ_ÖÂ’ð…fs…Ò[Áƾì·{¥/ù·ýˆÁgÆ|¹}ÐKÒBÂ5hR˜äFn'™®™0eŸïjÓ×·ÖÀF<Ä£xýØ"ÞE'BÚï%Ü(û¯ÁY ¦²m| 2¤éu€´ž- —ÑOÍAF–`°‚ ± —ªR"(Ë……Jø¥ C@ÈlEšÏ†@ù|‰ /µ…ÅÒÁ\À+,Θ2\K®Áf9Ú#Ïãvž{yñWu&ýPë*u2ìS1ŒãøiÀž°?$?îìK6ÿ™¸)î#AB1A6¶z†RX~tçWXf”n¬ S Aej$h]ò¼v }|ÿè¥ ýú!ó¾€ú}ºQm+îà´†á˜;†Aê,r7ó™=±3$øÑœ×ºËô~oð àÿ–QjÂCú]5÷ @¦[´Àv ©ü?$'p+Ì·³þõy;9 OÏã³ÑÏñ¹ÍÏÌ<՟ĺ2ISbÖØöJç©ì>~ë½<9‡Cú-_q…­ózá›ËUÛœä³ÉÙ`NðáÌéà-‡ùýäàƒ?[uendstream endobj 5165 0 obj<>/XObject<<>>>>>>endobj 5166 0 obj<>stream xWko7üî_±5ä¬X§—­(n@ì¸u€¶(ªÔ_ÔeѾ;ª$O²ô¿w–¼“¥“\M'¢¸äììì,ó×QºøÝ£Áÿ$ùÑÇñQ7îbqóÃÜQçºK£x@ãiø¦‡¯iœú]]'Q§EqS«s2¾?êR»‡õë‹rš©„–Z¥”K7×é×r‘ˆ,›D×ZÓLë¯zz/79iD~k|&BÀ•4j)S¯´úç»­õ8Õ«"Ö=mDÛwü¸w(€ié­ui(Ñ©¤¹4r?—v‚ý§Îõ8ÕµûœuMMt;_“²ÅKGn.iaôãš’LX ÜøÛ 1µÎˆÄ} ÞŒ¥zwª цSo–Tñ‡1ÆÎõY… ˜úg\‰+«*îöŽEJÊÙÍ-5,Zé2Kij¤xðAŸ½Ê»2—…£\;GùD>áÛ›Ÿ^"9Ï–1Š6ÒçËge‘8¥ ‘)·¦It§9lftNŸÅRÓtùêU<9¡KÜæ$NܰvØrØssá@ ĘýLpMY[bš\¿»®—¡ ë¤HcúbŸhK¥KË ªª#E¾ÈäE q£{.n¿è‚4ªD½a*@ûb¥ùSY…ûù<ùèd‘†³›Zî´Zô‹xdK­D é¥4F¥Ò‚kUWã•«+¯GÎ3(¢Î«ê1jÑ\,²°ñÞ7Ïôãú÷4fÝ4 Á÷t§Ó¡«ªÑB 8_q—–Š4넃!ìn­tcÝîòÿðgÖÔdfa¤+Mé=™ýðŽŠ2Ëè–‘@e-!>lÉv¾½ðQ““š•Úéˆj¨y"J„Kæ8þ’;ÿ¾ôé1‘ nÈ#Áa ؽÞ:Ä–µQ°ÉS²:—¤!õT]óèál’UÞœçóxë jüásåoµ“xë*ëÆ,ÒTKsaä’MÁ+”Åìû2á^æV«aBÛµiû €|Js½B°9m*–¹¬Úm"fÒ­ëü|;’+î³ÍåbÝL~‘Ãx„ŸŽS(Ì'ÇŒ*#ô­Äc¬?²ìÏb ½¡ÞY OeËR{>¥Qÿ,†Ûý– "÷þ&ˆg´ˆG#>ÍoŽ{ÞÜ®t‚©“³­V5çÞ½ù®|Kï±à<ñ j¡"»†©å˜4””ÄekpŒz@y^w;—<„7`Êñ–ë{×ÒJ¡¦’fÊ[,´ñÜÌvXLj„¨yP­ŽaH1ïv™@j% •çëJ›atÉÕ¸#X¿ÊØ®câôuzqïC±rª™’¦AOD3( ºð8˜jêñ‰4enàpê†t_/ÜQf°òƆ€ï˜©œ™±ÇäÖ ™‹³ëvÌÕ½Hv¯ÇìÞFÀco»î¸/”‡SÝø©µ¸oPVø¨gI[q— ÏåfBs"³úsªpÒä2UÞÊ€ÀQ-YÏ^¦äJYy°á<³Ï&±›ÃQ¨Çwe²‘áv cú™q>R«¦:UZ@1ÄN9¸awkþ߀CÚ¤Âäë‹‹L[ùÏ#èÚN"xüq-Žz|¶Z¿¬S[Ó?teÎïî»—™Øèæôvú¾t¹¶îmgúº,Ù!‚k1«õcaÿ]&óq= ÂøzQ |mÉÙø,9ñs†;81âïê™ËÏ,t8Ø'Ì>vi‹¾áÿ Ôt„k‚–¡»Ã0 òuØ‚ïß+{kŒ.ŸJçzTy~otŸÎi8ÅÝžÂñ{µÝ»xÈlù)Ó‹Av·_Ξ1öóî0ôáê<º#ý4>úýè_¦_Þendstream endobj 5167 0 obj<>/XObject<<>>>>>>endobj 5168 0 obj<>stream x•WmoÛ6þž_q(PÌ ű·ÝºmÖ¬é‡bÃ\´DÙj$R%);ÞÐÿ¾çHÉ6•&ÝÚ `Dò^Ÿ{îøõàŒ†øFã)ÿ¤ÕÁ›ÙÁ0âãö—YÐéå„Ά4Ëqvú‹Ìïc‘>h'É-%=©›yY¤OHd™ÌH8ÿUªŒtî—‡³/§—Ðæ% ž~+QI·ÔY¥³"/¤±áH§l@Ââfa ?¬"“¹hJG¹6á{.…kŒLh†Ý…TÒݵÑw–5¤“³Ì¤¥°–Ö…[Ò{¨ýM§”ꪒÊuÂ+ËuYêµý¹3õy2f¯G3%ã1þʧGG^_jÄßò’úh% EŽŒ´Ú¸„ŽN;+8hƒ¡p…ÞSmèŸè@’$ÑßDPÖûBtD¢, µA1„seI•¸•´Ñ Y__d3}^Î_5®ÒÖ½<¿¢T4®Ð*¡ûºbˆZVºÈ¨ÔVÞTÂÌKi¯ׇ=oÿî{ô-ÒÑß÷»§—/ˆó–#ìúód:}ÆM’³Q2¢ËF¥l°(©PNš\¤Á/ݸýdÙC ›$uåUµ¶¶€ùä4™FÑ_Ÿ®~‡Hä˜d\Æ™––”ö‚³Š<¼:4ßPcC2$(Ýî]BeÈ’$]‡à¤ï”;Óa »”²‹ªpÅ î,¥¢µuÍ­3MÊX·ð{Ða ì…HSi-€ï–F7‹%åm|زDíhìHv©«-b_.øYÔÝCQ¨{WHXÅA¼Þöˆ*2TS…¤PÖ0ŠkéDyo+™Âlèý‡«ÖŽVÿÈ'åB+ 9\Ý’ä¨jØ»–š¾ œâ£Â;…â°D©x¼l\jÝCi´¿Ëtá •‘ËÈ¢»_ºøÄßm-ªëŸPMuLzòÐׇñùoþÏ}8;8âð°š=rìp>o ñ˜Ü¦î’°$fÇ~…²N O»QxzíqÂp,|Œw9d(­„)3@Õùí‘ÚáJЕ(ÆJÇ´¾»Ž¼ÀN[^0`- “;#̋ܵ^kƒ’>)ðŠëŒ¬uë„B•A¼ˆÜ,jAü޵ââšô1îac½ÁC#âåv13o‰Öåäùi¿¹»YHw=`â˜}þãíM}ó²Ì‚˜Ár1íõÅ1’—ö¿Äx>h“Çlo×£÷?XÚ»¦äšìÿC7}Ô2YáVO‡í»Ž¶m¡+„^ÍxF/-Ò%ÃÙZIaÊ Óâ!¼„e(¶¨,Q·-gâ¼d*Õ4—8¥G<Ï!£¨ç J¿v$–ìÅ)¦ˆnIÈ>êêz€›Ç˜’údÂA…î w<þp§~_r„<ªºÓûÙÙ }Â>*(¢\Ïm]*Ps²ªHo™¶+Yi³!†2z›6––/Dž;b&Ú`…nƒ¶×•&ÄÇ|ÉÄí‰êžõ=õ ‘Ä\¯¤v“ÓÝŒ1ƨĖb–2¤×Êw¬-Db©{SÅg?zm‚#VW+ëÚˆBOH`=ÖÖ©…Û@wK Ð4:pèÛ ¬=~çÞ¹µ1ÄiµˆÈñ$ÜöÖ÷®×ÈXxÖÜN?»&Žëà)jÃHìÂH `"]å~ÞÌ´úÉG¼>(çQ!X‹#û:ë'Љ>E”a1Ç"E°?U¡£ôm*J›Çlz§×r% 8çãÛ™Õ5JúÒ OÁÿ"€ YoàD”ö`îCVý0R3¨ºðaÆÙ¶Iî}Þ `*ä›|Åæ‚l-S~¡…*ªKžtu…ÓûPðµ ‡¿lƒÌãØVïKQ„üöòÓZ‚æ³-¯–åž·µÑp’œÏiúl’<çá@žŒ’!áÕð ÑŠ--‡³'ÏÂæõ³{o.>|>œ&ã^”9¾àOogü ­¡Ž4endstream endobj 5169 0 obj<>/XObject<<>>>>/Annots 2405 0 R>>endobj 5170 0 obj<>stream x¥XÛnÛF}÷W UZ‰ÖÍŽÓ>µnÜ$hÓ4Vo€`E®¤µÉ]v—´­ý÷ž™%)QvƒMA¤¸s9sæÌ0MhŒ¿šñ¿´8'cÜá |øîh2O^Ðd>N¦TÐ|šœ69]í]t>I&{¿í]ôòÇ£>·wYàöiwâüf±…„â×tr9¦ódF‹MÇtör’œ½ E&±Ži‘žYU™;M׃×Êf\žëìú9Ý9“ÑÞ±ÕÒòôùõó¯ž/nŽÆ4šÀD6xöWïòí»7¯~{ÿã‡E4‚Ë‹¯¿ÿžÞª;õ±Té­ZëwªÐ —ÕyüºïˆÛ;ú|H7i®BöŒÓÿús“;»†áPyc×òø›]\ΉóZѦ³²Á;G„èhUÛ´2ÎÒ½ÉsZjZk«½ªtF€ª¦håCƒÿ–{ßûౕ¦:³Ìu‹É”ñ¯’·W¿¾ùn/vKM} ]m\F©BÈÆÊÓ(©ö…ÎŒò[ILð¦ûI71·Ü¹[ÊÍ­Æó&|ÙfµcÔh:Mf3ð+•õ27)­ŒU9… ¼J[ïOщn”_O†t%Å«iS’­ã«Õ¡† Ži¾ß{U–¨Âr‹B8ÔÁ7ɬœ'EëÜ-qìbwæÞÕ9 âxÝ iI‚Å̸ÉõÉ$‘ã¸Ë‘Fsõû…­TQæìJö{!ާú=Gôi².“p¯÷™Æ°¶Åm(»ëÎÇ‹:TäV”ºÚÍüO÷:­Hç¸Þº:’g­+pÇÞ¢ Ú{çQŸŽÌ{ûË”m­* óqËXM„͹SY~î÷ZB¿Ãn¡¶´QP«Ê‘Ê2.Yp…¦ã›j[êã!¾„îÈoì±´äñ .\]ÿZ¨²‰EÃÍ#V௠?z­=ó_S¦WªÎ«=Îßsë;4Ö!hO ÅôàÁ¤‰`:çžzƒüê¢àþ|BUé>°@™áb°¦£%*£kej­TE€YR—E õܓ˗ÄÁ¯0ÁGÓ3†y:O&ÓdNïµG5 eSæ4>½ Ÿ ì†>Î|xŽ3\%Iç3°$&ŽDaÔu ö›z­Iy¯¶!ö ·ú¹å êó®x‡TîÀ\õj…öY¾ V¥vj/&{´åÜ1ÞnÅ>r'$¦ŸËuÅäÂXS´1£­Jm3I ‚P˜‚'_|щh°7ÜSÐÝ&:]”ÎËX»^ˆwÊ… Æ!†J«Œ!i[3ÅŒ•*Ȉí”8¨è=‚×ïw¢Û°~o0ïÀ]e·q"™?5$(òŸ¹J †Õe$˜~Ði-1^àÅ‘&ê±ãµòKì.x;RZñ]G™Kè’›ï%Útï ©²,“¡ríxŠ0á6€ª¶‡¥âÉ…уJµâóéÉô¬‘¹ëÁ¾)LîŸÅïï_ÑñqßðÁ®óÚÝë;í‡;5oe—å^yicµd€ ]8Œ8…FK –†P‹rªJÌ4 ŠA,KÀcTcK3ëJ_®Ÿ÷ãëÆÜ-Ñ-ÓÅi¶ËÝËÅeqˆ0U3…¯–’=ë•×OøÃö…G£~Z6Né[½¬×ktú£[…X0}º%Q€h8‘ÉY&¢,qKl-H˜Üü„Í}©(&žþNâ*Ÿe±©tº±æ“‹Ãépûr[:²ŽÐÐ NIñÉ9°Nsƒ# é0Ú` LBeµ«C¾M臠 ÀñÌèù¯m†þìgœ¤¸ã+øJ·Šnã˜fy€ö¤º”†„>\Õkb‡Gcs"ô@¥‹ë0w"ĤÜiiLAÆà<ì [X"? mïŒw–éÛÂ'ð×9vä¸BçÛa“"ã̈{çr¨c™«”ï TâÝ¢âÎàµP:Bä˜ÉÎ2š«m¯€‘4]<ëï³i°›ª ]éþ@ÛH¯¡x@æRƒ­w§»L쾗ݱö½q@wgQZVPÔ€}<Ú€•3K49†É2¬x".3+b³;ìjŒ“í¡òý;é“^fÐÜâQœ+0?BãXÅcÍý–ntzûå=œkÉÀíÓ–åËfc}‰ÇÑ ±@Ëšý…SÚë8l0{j× KÞªŒïZp©!¢À5KÓp-]жÄÙÝX§âLpm<¶A°çÂYƒé#$d/Ñ,ö§NÉbœó¸£ðŠ3‹¹½Šï‰Ç}æüœ/^Vööùž%ØÏÙZT´XÕÌÀŠßXEr †"yw„ôãW¬+_И¼¹7ÄÚ©VSì¸^B¸So–`¨£Brt]L²òlª"Ç”‡là98ÄÂçyí’À:Wáu ÎÙ"[ô­Kkn|!›TÊ"=¹KfS¬¥(Á|2f[¯G?ýZx½ endstream endobj 5171 0 obj<>/XObject<<>>>>/Annots 2407 0 R>>endobj 5172 0 obj<>stream x]RMs›@ ½ó+Þ‘Nj ƦεmœIgzhC›ó/fÝe×Ý$þ÷•À¤vÐ,ZéééI“9=ʊߦOò,'›‚ÍÏ{ö ªVd{”ë¬<ÿh<&¿=ÖùÕÝçúkt{Ì7K9ê–ŠV·tØ µèФÑË6jø \Pf£U&dxhq²ÑáñéáÊеÖ"(kð"M £5~õ Êw¾³Qï°•[-,Âé(ñ¡>$ó 55O{ñGŽ®‰OJØ¢é _E¤Ôr² Ö>"tÒ\#ä˜ ¢Ÿij@/Ôùþ?Uö’t²‡‹ÆPK6Ö±‡èÙªÛâI™}ñ#ý¡”#îüioñ[ù(4¾ÜÜàèì¡UZzf+ÐØÈL …@™à»é‘âoD§:wc{þ:|Pš¡îä%ƒ^˜œÜ;é=«¤Cyîc›³wæ£ ºeøÎ¹#;/щgÉRÕ“.g˜Æ$&C‚ú¸}“?•_Ÿg·È—Ùª\aU±ü¼³íæWÛÄžbX ΘM³O<ô]ºXfE‰o<¯‰6Ç­ò*+¤…,‹‚]wuò#ùëåèÊendstream endobj 5173 0 obj<>/XObject<<>>>>/Annots 2419 0 R>>endobj 5174 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û\$ }vÅôþ»Çw”Ö9Ý›ª25}¥»æ‹ýGÇšPXÛ€EØÈÈ‹b'°vû¦,Õ±5Ÿ7°¸îF ÞØ­üöC”lé¥yµ²ï·£›¦UúXÓÃPg½†ßu¯Ú"ÍÔ‡Ûû‡‡Ç_°MvÔn{“çš×¥¥ø‰€K]+úwûëóŸóT¬'ãàEíúñðwªVmÚëúHìtCø»Ž¥Â´tÿêe&Wqèu§Z‰|À9‘tÝ:Úœ¨œ ]ª?˜ É m°û}HJy÷_=¾ÿúÿ%ÿT}ªËŽfqíOÂdÌM´ù}¹Aˠ˾L_FƧMüúaâ/Úm={¼Ã-¤;Jé¤'¯TOª\QZ–^3´éÔŠÌá£ÊzÏ´Z¡¡óå—:­t¶¢bìttpÓšc›V7T™ÖÇ!=*:ëþD¥Á£“îzÓ^| `"€_¸4æ"Ui}U™w+ja‹m­©è¬”³‡¦©à ³…®Ó:ƒ—Ì—iÙàYH†ð­@AÔep=S¤ò!CÏ›úÚýIµŠRü«@aÔŸÒšî(×Eç8FWM©ø@Ù 4Ó!%˜™Î'd{ú´¤‡’Ý)K:¥OÊ1ƒ~œ²v• 4 åÊηüŸ -^^¨šÆ´=£RRô ½¯&®™…±”'ŠdlÕT“_:ÉÌ09ÆËüÚà¶&ó‹%`Æè ŸsËn™0øüPÃ31L‘2džÒŽJÕ44y èqÁu•C®æµLœœÝÛ‘ùê•Oß›2±U)@q0 r²´:Å9‡õ™±q˘ Í÷ûea„?›‚è·áó‰áq´’2ýñùŠ®lç2:u}[—úGE,DøD†t«Fl¦ÔU üNõÜ$¥9[BqˆB÷èmîeƱ8qÝ]ðeàn²Ógò%ƒUfôÓÙŽ3ÜÝLc*…†¾XnÈQOéçŒW4FÐMD`9qo¨jq-+ :Ȥ¡ç`ŸT{¡R÷=”ªÀiýŠ.ÀÜÇ¡ë©V¨°ô[å€øîˆ†‰¸p/^CÊo»³>’'yãIv}4­¿µ=UaÛûÏçù©Cðá.&2 .p8á-€Ÿ¢ƒz&Á3š ‘ $Uâ 4æ Õ æ:쌚+ñÒ%r#ðé-¸÷ µÃ‚ú¹)S4ë Ïæóž+4É~éP>ö)mµpÚ Ît#ƒr¹ks¸Àƒ +©pnš|cö"†à›ˆçÅ+ä’K>ÂV{¸P˜¡p.lï€Ê…%(]lò(™®¥Æ^Kiæxi)ÆÞ l©|‚í‹„!Ãè¢bJ%ñ¿'U6ÂM¯âé†m1À7w~Ä\`éÁ®Q™.tF£‹Dçz|íÝ­‘8¼4l%yÞtÑóúK£rU¶@ië?G°ÝÇ‚K¼HÐÌ2Gý„0.꣊Œ7Z BܨÿdöªðÝ í‘ _i–™–/ÙŒNÜxzÇ|ϲ®1®¥âÿÔÀÞ¸^ÿP›ÿfç6•w¡i¸»Úšïh½|-ŠÉ~¼+Áe¥rI‚aÁ€ðT}åm†‘!’bÉŒdàþÂa§CÉA:87qŸß äF–Màž”µf¹„ÆUŸùc3 a¡0Ò\åõìëÄ•àt .Àm‡ Û„¥éŽÒá n =wûTi`yªt>·ˆ±YçÊ0ŒýÝ^×x¡¶—Ø_y»ù×°ÈòÛ&Œ¸,_îoþsó?9ÈdFendstream endobj 5175 0 obj<>/XObject<<>>>>>>endobj 5176 0 obj<>stream x•VmoÛ6þî_qHÑVölÕ–'K°bk†ë<ìC¤´HÙÜ(R)»î°ÿ¾;Rrb;Û<ÛLò^ž{yŽzèŒ`ˆßŒ'ôˊλYgqsû¨ðfú-Œ˜å(;¹¸€÷çC˜eQr'q·B‹Š9©p=~€¹Ô¶;û½ófz #&õArŸ¢è k…ÐN-8V))*pK’ ¦`Í6à ÔVÀ/¿}¸iÛ¥ÔNT9ËäR ÃÌ€Tª¶!o‚´LÒõA gY[tÄù]²•Fà…Æ#2š‚Ì“sNX/w#‰`-ÝÒ»ÊRfí#‡Ìpq$‡p)è„¢NâñWì<+•sø˜Y+ÿˆ¾±L:=˜Ô-Òàz …Tß>÷y­³4ZÉ1ã½kel]‰i­Ónm÷€dúíÎæ©9+i·ïq•i·Eœ’²>JÆiÄåêóˆé÷ùì=x”~Q}º ÙÅçݾLI[Z,Þ=7õÛ3ÈbjÖ=`UÅ6ûºB×¶¢2Ø ðñæ}ÞýøëMn?ÞÜüRòÈÉ‚$ãx29§¦¸6U%li<}‰pn‰ÄCʬ‘a°®$Œ•E‰x|&·Dü÷ÆY^£±i§s_J©š 8 D;¡Ó=|ã-¾·E685ü`¸FÒxóÿ ßÕÕ•×XW¬,qØ]Á:Vá„XŠJìàJ£L]"á –UðÓ8©(µiôjnøha·,ݶåɵÑ+A6IcS˜ÚQJ'ÚÉŒFŸÚÙØ‡J¨áãgﳬÌBCÿ{¿PÆ”c%WLÕ”ñ`jâDåéá_à;½8Y5BÇ Fß„íCè‡6pg½UÄ~te@’v± ƒ9+M%òãÍ[òVì(¤ÏúÝÙ á{û¹¬¬kͲA œŸ½…'E€~°ŒŒÄüþ{ØÅM&.3S”x] œA¬„‚Keß.0y§µÆ»Ê†åsSk^Âk»–‹Ñ\æHãƒ\µhk O%ÑÝT+¶,è+SÒ5Š—f•,ûƒ-m÷šÿ= êÀ6(ŠÍ…"Xi´ŠX‘F ó«>p8ï€Õ¾¸A%Ã;EvRÕ¶ðNÑüÂÇ@ñ ‚}iBÀu³Æ{8Bǃ|6¾°^÷³bPBv”&ƽMâËx“x탲ÒÎ}†ÿ& kcÖX#. êA´ìA/ÒtÐd㸨ZLM+àFÙ§ù„Ö¨ö-Ž2×ÏÜKï›éEó:5º8ÏÆgø™ÄçᕈFò ‰‡ðÞdø’¦¾GM™Á»)HÎCñ¶y6œÄãç^f§£1™¹™u~îü úLendstream endobj 5177 0 obj<>/XObject<<>>>>>>endobj 5178 0 obj<>stream x¥Wßsâ6~ç¯ØqÎw­0¤äé.2™¹é;:NÝa„,cµFrdŽ>ôoï®l¸!Ó8°v¿ÝïÛÕÊyì  ×†cúå«Þ‡Y¯öñfûÇ,ábÚ‡ëp³¢>Œ¿„ãñÌgÕ‡÷áôOìg"/„Øçù„'òÒÆoáM®7í]­Êf=c&¨ ÎJ­Œ cºÞÎþìõ!`¬¤#V컉\JpB*ä O Þ‘¥ƒs vôkžD g¥}'`±_¤–Sph¹,í;àðM­$¯EFõm#2ÉÍ[ ×êë”Ëë”æÿSâù^VÏž…ë:Kfg)ŒÑ¼µf¹L€¸0n…™À?ï=ê–ÝuRÞº‚tŒýT~m2§b§9[žôÙõÅîÝu)VÀ2eA¨j…™TKí}ëŘÚdÍŒd‹\€÷î|'×ÚÿgÅG©PÕÅÇ™p­8³Bá«ËÞ`ÈÒ©º¥A;Ý]eÄZTø`>…wah€b+R£*‰ÝéÞˆlgŒÞ½Z0þ["àÓÕáÄ)tssóåׇ{Øæö,׉ÀŠ&%dÂìD:SÇ$)ŠV~ £6pvdÒt+3áàÛãÑ:¤©œ*j\q fN2ý&e¦ Î҃Ǘ Lh³t,^Xÿ&…vmÕ ¡öLZ£#®ØúØ Þj;¯Y{Ð~lšSâ(âX#\ªu‡.H“>nörì#ë–Ukt%­¥ÜXÎñ+÷`ÿö,…9È!öos]VFLÑÿ)Α×åøbx =h>t…EÀ–ÕQ4ì”îE³·øb:¸e‹›ržè g™7(½µ–ÉQ ¨Æ©¢Ä>3†mÏJ/pëÓ;fòùîãAغ擟~¹;½rÿùîôÅô¨S°‚hØ<-ù³ÌÍ…‹é¸Y÷a„𓯠âD1"ÅùVƒÍ”…à’Ž^ZÚd’g5 ‰+!²«pZân4áø…[çÂoºÎØÊ(ÐêB§)ÁîE4×–B ìÔhA«Ÿ(Úb‹ÈÖ8ì³~Wúr#—ñ‡.­Ž¾ªpPgl-@i+9eœ1[“XjQbV8E¿Zà´¢ >BÑ.pvϽN !„ÂÀ*«W˜9w­$S‰'TKC ÔøîeXÔ—•HÕÕÁ9ÆHz!8#)+iJ‡$xåŸÐÊg™lè0ÇL•Ì` Ü~úñ Îä)’([xÿÓÃwÀ1Fxâ‰.ôƵÁ'ÝB«D(t\»ì0_çKPÏyÔj_7õ/ÃÑpã«k*&Ñ ¢°5¯VBY§¹`kÖ–ÁU=/£Q…Ü7å§®!R%XuGxÔ‡Ãÿ_@äËÁ%ÁÜÍz?÷þzP2endstream endobj 5179 0 obj<>/XObject<<>>>>/Annots 2421 0 R>>endobj 5180 0 obj<>stream x¥WÛnÛF}÷W T– ™ÖÅR\÷­jHÚè‹cE.¥M–» —´¬~}Ïì’)ËIŒ$c‰s9sæìÌòËÙ„Æø;¡Ù‚ÿÅÙÙ8ãþ1áÿ¼çohqO”Ñô]tSÐôñ¬ó1£Å<švžýþЉåºº»¦É˜R$]üŠ_Ÿ ¿ÄíԹ‹.>érzgÿÄ~-io+Ú SRii+žüÙ¡Øš'iJe ¥¶ 4²¥2ÒÊå”V&öȤó&±- érk¶Z™ŒQ8ݧʕ5’É”‘4ù9®J÷Tn%ù¨#ÚÙ­%HÚIN³‘eµ|Îmüpª1Ê$@ô1"z°”XèLr3`”cÇvîØœÇ«ÐÁ‹–M[[­>¿ÐAçàÕÚ=ge i£í¥î!3ã ®“Kd¥fHD÷ioè–Pæ°è!fn02šrýÀOd `o` XÓNÞ”bP9~z¨nÄzai¥1p ‚ÎeÓ¦y. \80Yw؃ mÈBÚŠ¤ƒ×­.Nm!…yÛÇ;<¬n Ï ŠeQ ejF¼@_´â`e8>B“ƒê´î@Ê­s ÇóKVž­|YŽÓYWNlü/|Û mígªo¼ç×•Ò âò–Þ=/?0ø¶ž¼°Ÿpë}ohž+?¦ÏmgÏ9…¡ºo¯lw,o}›ÈwB­ÏóoyŸòýzöç~vŸM¸-Íq+[]œŠ÷:–~¬—¾iª<®,ªøkQ0-œó‚ö;‹[äï+TÿY _ÒÃÏi[7ºu[ÜPZßöÿòƒþâÈG³xCúõ¹ÿwä^_‚ÞÀ¼¡ñ]j|ÑÀ·¹÷»ø6ß~ßæÛïÞÛ|û­ ¾Ww7õ}ersÍgsZàÿúÂϳérŠÑ?lìï†~$òÁ‰Ö—ï‚b§xÅëèûÃáòîîžÖÊ¿øù[Ì|¼ˆfS¼DáÊz=™s˜?Îþ>ûúF«¿endstream endobj 5181 0 obj<>/XObject<<>>>>>>endobj 5182 0 obj<>stream x¥VÛnã6}÷W ´¢ ¶|KœÔoÝl(ŠîÖE_ ´DÙìJ¤BRöº‹ý÷!-ÅŠÜ\Ð80dqfxæÌ™!;Càgã ýÇyçã¼3ˆø²þÒ+èÏpažÂh“ëa4™\Á÷fïómfÐö­¨OKIRÑœøMb¥²|“Ì£S²µBI’²cùY…aÓ|׫l­?¶EVhêƒÅv/qÿØvß%…&r¤XÈLHî$‰èëý¨erH@á3š[î$ܷLJéF‰¤Å <.ïEÈ´f»w0øv$ÏÙ«òä²Ìôq¬2¥‘,Z~¡‘ÛmüåöÓÞmò’Ãô+ßm•Nj¦+©øIÐðñ·¿nÿ_„»/··¿ÿGˆÆ›ÆA›ïߟýÃ)t ôÆ—û3%]F#Ò1¯JƒÈ¸‰À #f’¨I»årö•dV*…àä{àR N~àƒ³¦½–>/XObject<<>>>>>>endobj 5184 0 obj<>stream xVQo9~çWŒšƒäXHHD{÷Ðô¨òÔ»†¶¹ ™µ\-öÖöjÔÿ~36»$,¤—D{Æ3ßÌ|žñ÷FbüíÁ`HɪñvÒˆ£7«³€îøz1LRÔo`½w’Ögf¤.,¤‚¹Â ›¥L–°F[3™±y& Õna)ÆB°Ìj˜ (¬à(0"‚ÉR€cf!ÜN³² ­-´T pšŽø í¨=ùÖèŽc¸‰„¯C§ß\ñ–b+as–ø õN¬4<ÒT¢px ɘµ0Ö ¦ óL&ÞçàÒL3Û×53$ív!ÑÊ:S$N{T‡0À´µÖ’OÛð¸…? ~ýó%Õàò¡Ô~¨´1 >¸€ ¯ùƹtR«ÓFu. CÕ DâûÔœÁ„õ£Xgå÷Qi{±Ž¶ÓöQ×è8já–`¿XA~Ôoˆ"(Þ½}žûtKi;rMy:§Å ÇÖ1'¶¹Ä¥B<‰ý¾ ‰2ói{Û´Å:¸Š¦i뤩2©DHEÎ Ë2‘ÝêU®•P„ñi %Ý[f s™É£éØ%¸:çý Kˆ¥;ί’&Ï ïe…û×é¯ÂèSYÝ/$÷T-«”îc‚h´Žçg¹5(Yø4M%ÁÎM¨Ž}^bZɱõ¹­ˆUYƒ9ëøh¤ñN ¶:ƒÒî›7hø@TsPKücm‡®Î®ÐhsÚjÒd{X¶›eœe+(ËPÃêSü‘)®WŸŸýuü ¾þ1$Pyëk(^Äì[wŠì~d\ö>§vJ´öÅ÷K¥ÍŠeò‡ž†òÁì;Ç·ÖA4^Ss¡^-•&¥öê›ø¯ºñ«•æÎwØl_I•dÐ$Q”äy“2qÒ÷ý—»÷°ŠZœ¤2H#‡˜Ri°âÄá gÎÆ°|?G¸V¿9°K½ êV Ÿ9éÒá>/XObject<<>>>>>>endobj 5186 0 obj<>stream x¥—msâ6Çßó)vxE&à8pi^&mn˜¹™´ }ºÒñ{e+'$"Éúé»’¸$2 ’¥Ýÿ®V¿užZçÓçCÿ“ÎZ7ãVÅ4Ùü29œÝÅp `Ì¡Ãð‡óh8üã,¬Šaœv&”sq!Oy©`Òi'KÃæÉ­K’„eY’´a{49ë¹Ê¡9?¶bè“¥¬´Ù¢äÍÓÉÉÞóÅÖÃæ1)£íG…HT¹+žJf0«åìÌyQ\jæö\¾ô¯™°Ž©k‡ëáa_l+¼=!Ó­‡ïQ1g†I‰òVÏæZ¡rµœ½ùÿs0¥î†Ya?(Ò¢ûËé¯ht­n3ñY‡Ó²`Æ×f¨Ã7^ü×fS]†ëâlæ×W††zoÃÖÀË^h‘íãÇ *If¥ôW©þr4+u-7l.Ø.P’H[N·Ù;_?æ_oÁ^øPð+S™žýF%ö;¦N›{õçן%St±>ÚÒW¥áìî|8ôè@{ýA²Î¸@Ð¥›—¨|ç[A®uS?å€3!-tÙl*ò’9¡rÐ 4„Œ 3 ô¥NheÁ–iÌ‚#«)M8SzÉ]¿ßä e#¸WK¶Í× ê{ˆ´Z.¼ñ°vnôTâÌërf컜¥¥­f *6Ch(AbÑ Ò =G^J¹ò› ±¦ /eÐÁHAZø<ü1ú¼£‡I«!G…†9´]`pûåþ¸è×í¶‡^¿ Ô,Œ¥¶¡+HfI=uƒIç•zœt8ß eÑ罺1LNü§–ÒÜ¿Úä ]A§CÀ—ׄ ÏtØ“3yLôô±r·1°)ÿpÿŸÚE+7î€6‘ oáû~ŸiëÛÜ䯺yÕõ-X¦—Ð>m7qW²}˜U*ë¸O_ø§a@JȱOÄâ;ñ×]™Vîe`gÊ[ ™ÝZ¶xËÉTµg«v{Tî‹`ý;@8£æüF¥¯&v'uë–×K×½ð¨8z¸ékUzé][nšì5ï.k¼½%ËTĽ•Ó=ßÃŽ†qHó¦Å.Ã+¥°NðA”Ž€å=’˜ ¤º½»Áíé)ÌtVJ…˜YÚÑÑh©Í·n³#ð´ò´%æ-D†–XCoO&6P¡ D¨e!ˆ¯+]GL‰¥~`‚¥ri‚Þwªý^SÃŒ ÄÒ/ÂΣ5^.<±F>/XObject<<>>>>/Annots 2425 0 R>>endobj 5188 0 obj<>stream x•WÛnÛF}×W RU‘)ëÖ>%npê´VÑ<(VäJÜ„Üe¸¤.úï=³Kêâ8‚¶yÙ¹œ9sfø¹Ñÿ"MøRô†áwøGÄ?þzÛ›Çá˜&“8œPAQ…óö*§‡Þé5žN¯Â«Ó§'×x:‡³“§ðB£ù<Án< ãö‚;Yœ⢩Öty3‡Z¬ñd6£EêÒ"éÇã0†ë[meU+½¦PbRIJ׆ÖRËJÔ2¥•Ê¥}¹øØ»¼¹¢‡Ù\sà‹´[“²dVµÔ¤e"­Õž`€O<Á!õ•NòNØ]Ê•ÒpÁnÏßïRèûhêL’hjSˆZ%"Ï÷'ñ!\Y­D"}¤!ݘŠäNe.´ÍزQyÊI ç…F%í_¿zÅæýéAwæßm%Ê0Ùíh«òœrõIŸ65Â,J€A"–ö¦!‘¦$\®—7`€C§ÿS—ä‹LŠTVaöâ¿>¥ª’I­62¤E(=]t©Ñ ‡Íé?üsûö©£ åÊ÷Ø·lÌèÇ—tñ…Â0d@ñ‹.þû¦ã_ü“!ÍÀ'Ô4æ¢Æáh„«´Q˜´Aª-Ž-lx‡Ÿ}i/9Ýô[Ùœîc`ëþôóàž£ „jÖ JMHé×óØLÂÉdÊÞ_§©âÔEN-–2±‘@…Gy˜Á „GŠÁ„Yã=R­ Ïp(©Þ—’R™ä¢kn{(šµ4 ¦!‹ L>ÆÈÅÛë8ÄÏZ–Ú­Z³Óo;è¾êk$’ÄTŽ÷È€ TM¢,¥¨,Âu(„Êåë­?¸®ýƒxMkñøÃÔÈ5µ³¶ÌMòéI. sò2‚ørµò€d3SÕI dçˆôdo»êÅí_[ýYÈŸ“)¯X3¯XP¾]ßÝ>¼ç—¾–¨§2焳ÿ̲ˆ}%EÝT2È z>%ÅúSH]»âC!Y> £!( Û6SIÆÊY"a±D§‰¤2•ÂØš_æ–7%K0sÖîm- ’z£*£Ùªc÷˜S2¡S°¾J·¢‚¢¸XQ_§´M{n—•Oµ2÷w*—ÍzÍ÷¯ïîôîþ=¿ÂVkD+ôºk7:¡TÑL¨’ëÜv vqÈœXËlg#dGå@ ˜鵦Qt|Æ`ˆP¹C£Î*Ó¬3Äôa@oE¥a†Ï^ßýýû%ò»G–€“oå!çA°"p£ÝÊlWc¹G¼"åw;|ªF[z'vªz}};0¹'ô+çõºãz•"ù¬# Ó‚…!XqµJ\Y[ÕDýœ\Wòs¡·´‘йªk–Ô°­n||lPm- :Tî$¨/Êó¬0³P཭;Oö¸Sò¾¿hQ8`¢)¯,О䇻GšÑ’úF&ã¹ca¦P‡\ndNÚ1¼{àivss;ð­¯4k=Í@ÝáP?@— ùÒšY¢Ý!N<AT‘‡)^;+d òQ+,™,x\JZIJ¶ÈN|ø<&æÏG8™ä¹Ü0ŒówÊÂÍå£÷Py«§wÎâ¨+…¢B SÚ`ÑpkÒ¡…—  e ˜ã8æøË)IaÒôÑóÝ£*µKYO¸.¬HÐû“QÖr›éJ÷åÉôè$ØQÐë²2yn¶Œ‡Ñë1`7÷‹³i¼Í“†cÁ}Ô ‰‰Ü 6ÌX^§ö~/ù¦f2/[Awó/š„óILÁÕ<Œ‡cÂWÀ–2Q+•@ÿžÉ<ˆ°]X‡S^ wP5`+ä¢EÃQ8NÝÞ‹í”…:à-±"¬±s¹ŽÕä›Èí #ë¸;ˆU£ÝNå„68SÚun–Ø76¢R\VëE “@cxevú±UÜC xââŒ[>zœ9øsíp´ Eïì:þ`«òø²è0èV™€—¸;"1!‡ÒwÀ qG™ ÿ&u†Ïbî¦4ûtÃ`ú´þÛ…ÒeS·¼ï|ÁLðI4š†ÓiÄegb|Üüf’æ02Ù%–½«p>/XObject<<>>>>>>endobj 5190 0 obj<>stream xµWÛrâF}ç+ºxAö"Y;äÉk/)W¹²I-©}X\®AÁÄbD4€Sù÷œ]¸ˆÍe+—,õôôåôéñ[«G>¾=êø/\´Þ[¾çCX_²]Œ¾£^@㺃›GvݧqèW^ß è^æB%†RMwŸ~¢©Ò‘Ò3s6þµu1º¤´y¿\z—°àÜZH«Tˈ¤È%3Êçòh?ͤ–™È¡4ÝÒ§Ï?ÐBlIKLº´H#«P°%ãÑÂD™%/¬·~€5Ía¬ 4À"¶«ÌÎ…©FšÍv"/Eø"f²C‘ pL—jÓåraÝú)\ÒtWm[ÄÏÐtÂt±HµË™tHèˆ:q¬:T*"ýÛĤÝê™äf™f9‚L»?^éÐâÔ%“g«0_eŒŒŽy™Ó+qšÑz®Â9tžªªÒñ×…ñv߯9 Y.‚Öñ"8F9¸ò]»rP+èÉHDÌÙb“X%9%BÏV@×ú¹ùtãõ™L³)ðú}6ÜÀóé> í©jÏ Ž‡z¡í^Èþ“ŸWþÀëøpølçøõsëOÿ°À}endstream endobj 5191 0 obj<>/XObject<<>>>>>>endobj 5192 0 obj<>stream x¥T]o›0}ϯ¸ê^臉$M³§U-U¤¨ÕTª=,ÓdŒi²Îl£†Nûï»&Ð|i•QøÜã{¯Ï¹¿zP¼=FöÇóÞuÔ£.Åoêú!…±@”‚Oatå¹£Ñ%DI¢qgî¤ér’ˆ”p–eD–²¥^i©Ì÷D–q&N£= ÄCxâ^sgR°\ÀÉðd~z€E$SÏe. £1¬»×²0 ¥m¯¹Ã”bâ-š“•Qpóðt=»%áìáS4?µww'%L© bª•€ûéì$[ÆŠ© Λbë8ß¡Ã&a‘Gzb„6žìºÓ øgÖð8½¿ÛÒ¡k{`‰«NÕpìî×Ü`O6‚µ“ hâD ¹LÊLË´„+’LhÐF•†— ñ |@å, \Ú0{Ì 1 ùR@,2ùâÂã—é°ÒÈœ™¥ÕX,I4Ü ŽR%7RÕtm¾=ƹШC \ fD©Tu˜Í0²~C)è*e¦A¬W(^„ÇU½¾bü'{®%ß÷ñ}7ЉÓPÆLÁï6‹7Ác=ÊÀúª5¾Àvqw …g¯_=Jé·îêÎŽgPì¯ÿi_7zl›œ³5¥M~ݦ±’-g'Ϲ³†Ií 몺¢#©Þa ÆVθêOüÌkƒi}ÞuýÛ´¨«Þ±i;‹ìHÙÕ’¬$v](ÀƒÜ›­±Q®­T¡mç&ÿ~xÞÀl½0vi=,ˆŸŸÂpj»ÚÇc|:p‡ÁÞȆ%Ž•:ñ] 7’×C/ „æÚ`Éå&÷=Ê!¹ã9¾gn£ÞçÞ_¡Y¨ endstream endobj 5193 0 obj<>/XObject<<>>>>/Annots 2468 0 R>>endobj 5194 0 obj<>stream x½YÛnI}ÏWÔË`Œ%÷M-i°À"ãM›EfìA^üRV—äžôEÛk´_¿‡dw5l&^ df‘E²HVû߯Bà_hâ”þoÊWÁ<À7ôÒÇOï_Åé<0é"Ǧ4«5~(ÌíÀ% sË`ž˜”q –f½š/4ÑšqÄra˜ÌW"AKBóR³ ƒ]&óH³ —& ÒvÉj£@«e¤ÔŽl’ZÏ* µéb¾Ö¬Â`WmÈË* £¢%ùbbŨ`¥b¤ŒÙˆò¬Âä©™ìY…Á®CòÅIJÚÅZº¦í ­ B0¤xRc°ÉËz–³e±’ŒHbâв –& á#Ï)XØ“œ‚ȤЧ Œ‰óT j –ƒt²l`Xœ; –HIAd«¸'S%Dj/y2‘­Ù ØwbÕxI»œHY>b•!¯Êˆ$C…i/+ÒéY…Á.ØÜ‰•…#q{ÐZ0òæ†ãi‹ÈGŒ<ÈFq¼‘ ˆS (šÉ*“•8Ÿ0 Ž\+ׯ“"¸œ¿Ç&aD’‡Ó6c8A± ƒ]Å´°—U˜pÂj,§p¥dŨT(»aàw3pÃn&Rc˜cR“L¬,»×˲ ü²Fkäu2‘"˜HXÖ1q HPAhŒ”OjL¤TP¬Â`×d˜gE)Ò“‹@€•R‰Á„òÚ““ÒÕ<Ô¬Â`‘2ˆé´°Æ*èž“P‚†îx\dÒDŠ N‚dàŽêœ0‘Ó^B èÄò²1û»áÚ˜–9É Oâ&^I@—KT Ê¢éàw vÌ€8¶@XPgñ¤ÆÄ®Ãz,;‰”¬(ú:;fÀJ)Ø!ÓaÑDŠàÐôÃͺ¾Æ$À{±g&‹¨zVž¦^˜™4,<²²gÆÂpfÏ*ŒÃ÷pâÄJd¸£--IrjÎ bYÔ&¸e"ÅÞ±7‹#¦þ:Ø;²à|Ï*Œ…qœàÏ* “œ8±¬6:wPÄnR¢PkVaRKåÞ˲#¢¡w¯éäàŒð‚Á‚”N Zc°¥ºb‹Ú˜*VvƒOn‰°>4£q7#¦…©Þ+Va°/–šUìrqº²ÂH Œ ØÐ¤WŒ»?ö3u:t#&µT«0Ø”º­bË Ë³€a®àM£ƒ‚Rd°çDݦ‚å9¡B“ÓVhîò¢â%¡a1’Ðx Q$D=«0صbÅ* µî„U,|t²²Â8šyýÊbò4ѱ¢Ž1Ùc,ŒïOX…ÁâÐÁ¨IVg(Ü+覤•…=¦ýàþ¤X:¹!œ+¥?Æ©‰IJ˜|3ô…[O÷úñ¥¬Ù™«wkXÍw[\ÝRÜ-–‘¹ËøÒ˜»ÍE”šÛO7ï­2óÏÞ¾¾ûE­Â·:^%A6и÷Í07'‹«\|l\‘—ye›Üµ§¢Þ€p5ÈΨZb•ìâ>J—æôùß«¢§g!Y{ñS_UyµcKIŒ¬æM–å]^W¶0›º,iE^9SïéÛ/°)„¡ñhÕ"øŸVÉóƒöëºÜçз÷åÕçñ÷›ªs;qø<ÝçùåÿeƒÉŽ•-ó)ë¬/Ü™ÿÜÒfuß &³1ì™EåÁãçî+t+ù¶¥;ÉìÚ¼ùxóu™7x%â$ÿòköŽCqÝ·]]æÿ±4ÐÑÉÃîy•ÁW¿=*ƒù‘úP™ Ë,zþ1†îAt ñ×!8W¢ì+Ãô,¿ýÃu6/Z§uŽBhÄiDŸWƒ'ÍNfÙÌvÖ`è«YJî0ó¯ ;ß²øã÷÷Ê“ÜÏ­kX/ *`w÷Óôn™×U»s¥«º¯Ûå$IÖ)¹¯Þ—õ^›¯ÍL®J*啚 öM½kl‰üζÚõ0Çd®Íwf(¢í÷ûpç*Ì8…ÀÆeýðë$Ë“»›&çFf¶vƒËq‡Wss#[¯í¶hk(Ì‹­ÙÕu6)ÚÖ¸Íñˆ1«ñR7€Œ”Žš.§*)Æøï)~dÁ,kò'Wi¡9g`.íd´€.MŠØåƒ3}‹_-uº}}pͶ/.ñ"a÷ØÍŽ~à(UÛ|‡s-˜œEöÚê8ªCæ¢cVÎe”ýnÔlrL.èA Ç{4¥ÈÛ/¹¬Â*œÜ"umî/xÅ£4¾¥ÓD¯9p°Úþ¡u¥7ÿº½Á“äLI÷¯ÉÙ(œìb~Ÿsõ.ÞÀ\`h³EÁÚO“ ƒÚœw˜3¡·Â_€ñg}z¡rê>/XObject<<>>>>>>endobj 5196 0 obj<>stream x•W]oÛ6}ϯ¸ÈVÀYlÅ–?âvOY¶ ¬k ô%@!K´ÅU&5RŠ ûï;—¤dËõŠ j["yÏ=÷ðòϳ ñoDãÿ¥›³ŸgÃhˆ‡ífMWwoi4‰&´Xaôl>f´Èܘ!-Ò^<‹FôÞˆBn¤JŒöbñÇÙÕÝ„FxÏsñ$šÏ1©·È¥µ1BUôôñþW’›²üL*©IK™°r­DF•¦­6Ÿi+«œꄦÑ0Úõñ1Šv”¨ ßâhÑ}E6×u‘Œ/’JzÆbYKzÅ+ôàŒbƲ¬+J…©©ŠWRºÚGšDCÊjÁl½´U¢*™tóþžÒrºn[ 6uwàõg¼ë8Ö¢º²Uã2R‘Ñ¿ó”ë<ûbÝhÓÍuJdd­ þÙÓŒöñ“4Ö¥ J¨‰k½]°B\Ÿæ¢èÕŠ}mÚK¹‚W¡<’®ñó š¶ò/ï}°8>g"úÍKS#„KA …œy³8Åß±*Baw <ä…©5NŒ@PD¹ñe£sûèçh“T\†¹ÞR^¯¹mHna‹¢Cø²5üS!wÉ~N ©ÑÊË=}¸yD»™š|²õ‡ís‹¸ÀÆÑ—2uðw¸C…f{¿£Ç&Wx…Ül6©ôgE——–¸ÓUÃæš¨Wä²@îlŸóØwŽç|)“F¤zbv'·ÿÖ”ƒ!¢q³:•®) &…ÃÍ­Š]$îþn2k:H\cnö…M8ûp:9õŸ¼Ø´ÇXÛ&’pÃtðx‹â>/XObject<<>>>>>>endobj 5198 0 obj<>stream xWioÛFýî_1P’‚6¤Õa[±sj§äÚµ4@Y+r%mBr•]ÒŽô¿÷Íò%d 9;Ç›™7£o;}êáݧý!ÿEéί“žèáfóaÔ=9 ~&sê‹Ãý#‰ƒá€&±—Ó(訤»“/;Ç}Ñ;Bë$>ªLY™+GãÉ%E&]É\ÏE7V®VÊ:šK.•I¢,ÅêZGµE–élA¬Q°ÊN¥³Ó?½—CÖìÍEÛö³¢3jEV:ç}°Ê¹¥&VÞü“f2¹"Q‹ÄÌd²m。ÌädÕB»äKÅz!O™LIG’Ê£t-­–û¬àya³»ò¹6·&¥p8Ê ¤¾Ú*A÷ä˜ú€|Nã‰ÑàlÁP Ä€~À:aèdÓXg_ëëÓ î­`UYŽaÐu―üa,'â–Æ…$íH¥3Ç*&Á‰@—qeÍÂÊÔ[¸ÑIB3E.GZÙë[‚õ¯*4ÊH}Ï­Jn:®8IJ¸#“)Öy×!¸ÁÁÅA”þ¡(}Á©Î„ÏóÚç ÜeÿúZe0Ÿ˜›Wõ¡#±Ï 8¬ØßÇ·8x¦³()í7.µËw,Î&}‘6[\oËÖã={â¹,¾oÀ  ™F¼õf¥²©ú.0Àé°S{4w_S·‹ˆi•¯Œ²I⪢*·J­¬.•: ¾’vµ£¥´{|yý÷?áîF?6¾±¥YÚ¿Þ|¤ç¬îÍ`Km)A!Àô< Z/Ü+z3׉â’Pþ. ³VÛ{Òƒ+[&êÚïmÝÿwÓ“ñ[v“ñ ‘ï-Y<òHΤŒ;ò/ ˜èÅ8sˆG-DéívHµš&!µ¦Z ÷óƒY(+‡<\Ð2ž²UÆÞ”‘÷ùÛ·=”j­Œ{ÔæSË¢›ñú¬¬¸‰XEß÷ÂV‰Û>Õd¡È< S=/Ü: ìÊ}§Qbjô6]©Èi+A>?ë&ìøÛÃáK.ó¥E´$4º5×à §r2sÐ-Ú.’ܦàÚ€ŠÕ18&iZ :Ô&#v¡{Ò´½³QÀòÿ½ötZ5ô­)lÕmúR8´B{ýeÛ•ŒÝKÙ\à*ØûÅ‹Êm»Ïb5×à§ñ§ÑôÃçÉåh|úëýhU%Òjá»M¼…JÐ&™{¬JÔµDs®•Τä™v 0Êy¥¨‹rò|\Ó73)Ó7æÆ-ù¹M9æeÊ£¡¾ô»]€%­Œs~º6àWÊ‘ˆØ°®|©ÝÓ\ùœÜ^Pa²‹ÌSBSÇÔ_¦ÜeF}N‹(¢Îi·p¶[q-'Ž:yúæó|a6êì©c•éÊÚ=û*Šjœiþi£cï>(ûîÝ­–nÜQéº"Ʋlëõh«)N°Ü¨q!Û¾"Š5Â~ÀeŠv˜:A½b.èFçK/ÓìE‹js•ÝÒÕ_§ɯ˜¡E5X/U*™MÜf55_Ê42Ù\,7ý üß<`Ža‡qÈÂt±Š1¯âµÇ*CciCùnÌÔMÕ‘‚.‚æI½Ún´løQ»¦”€Ë˜É¡\¡Ø­& ?[jGœòÝ=ºòõÚôF2íukU弿ÓâãÑääüòlÊm>½>/XObject<<>>>>/Annots 2471 0 R>>endobj 5200 0 obj<>stream xWÛn7}÷W ‚¢’i%Ë—8òЦM` iÑÄE^Ô’’ï’[’kYß3$w%ű$1ìÕŠÎåœ3ÃÿŽNhŠÿ'tzÁ?e}4-¦xÿNø×ÇwG³Ë—Å9]\¾*¦TÓùô´¸ÈŸ*útôûÍÞ–¸Ï­hòöŒN¦t³„í‹WxÑ$Êáëi³´®A[CøY´º’Ú¬HI¥5K½jVï[A¥À EKÛâÛµrꊎo¾î=űÃuÍÕd²Ùl Uµ¢qö«*CaT˜H[Nî¦ÅåD™/ÝqÅ:ÔÕ¡©]¯èd–"Ï.ÁpvQÌŠSzcëFWÑY’[#j]Rme[)¶´ùxvVœñÎÖ‡‚ dl QUÔT"p<ù¶i¬ Öª7WY³a—Ù²§ùð³6Òn<ýJïµiïIÚùqAÕR9 6îçdÕ´¢â7Råjm¢_Ss8r¨—´µ­ë=èð¤CAo­Cþ—·Ä^)™=ŠçyQ+Ú8Ñ4ð!W©õJô›÷-Ž^ñY´w Vå¡#üQ0W‘Î[þ« Zê Ëq$¾K)#˜†ê^ÔM¥Šò0ÕÃQtŽ#zéi£‘b ÆÛZ…5»Qé[…5Ú_u/QJàs†ÄÌPÖS|’Ã_ÈoôŠÆÀugiÛîÃ6Î e`cϪ,i|=i½›hSV­T60.¿ÙöÀeg¾5Ôï*`µ?¹øîZ¿YúÞáï£?•^D_r0Éÿ=£û'øxÄÀ㘰ýâ%Çy€æZ{³d[âèÅ–>}¾~×U?aï™È\U°'¼W.̇Ùêü˜Ï¯DÈ·ÜþÂÀÇ^`tê?˜të‡Ø‘þakaL*‡LK€%ãCeìß½(Kk¸çKŒ|È+ª±Àè”yòö‘dwÁüp²çÇsð¤o×)>›¤–fhcÝímŸat™b¡ù¤âÜÔ€0ÍÂëf“’ÙÁ‚Û>kñlwAKÈE¬Ûv7]Í"Õ½*Ûáx@_¶° ¦Rsͽpÿôù0pqKÈ1Ë7ctüWå^Èß)0>¥æ±t£òu#Ê[±RÅ'ýY„‹gìþ ÎLi€y4ýLÅÿ²ƒs0 olÅý\r³ÓVÏN}? —iUÙFÖ1ô ÓˆïP?#+ÜDIÝŸW #/ux²˜DâY.Xìi‚o–á,›©)IôS bⲤ RGꔡ I i`}´àtCZåw4«¬½%‘ÆN媂¤zÎ8£èA—m%ú÷4X ºH»Ñ>”±ûF•z©Ñ%2!ËØ¸BÝìža¿»äý”0Ü=áN$‹áMH>/XObject<<>>>>>>endobj 5202 0 obj<>stream x¥VMoÛF½ëWÌ¡…eD¦eJVܸ• =U‘CU¤+r%mDî2»KÉú÷}³K2¦ì8‡Â‚!‘³óñæÍ›ý<¸¢1þ®h2ãOVÞ-ãdŒ‡Ý?»¡Ëùt•Òb ÛÙÍ -òð~L‹l˜Î’4™Ò_Né Mm©4y]ÈóŧÁå|JW°âséf‹|øÖ¹ºdcQ´1ÒÑAňÏÒAáÙJ’X’¼!¿UîÇèiL7É„]¥ì+M&üʇßQrY?µ`3¼âxùð UVi¿ÊQV…L6Y¾NG³åùò¼g™ö~=977æäÀää@–·Ó“w'I°ø¬uh´J·Ôç Öµð9:§½°ŠÏ¸„>p´lkL«6ÍýˆJ±CYµ•!åÜè3OµC“¶aêxÄŽk  möJ‡ä2S–ÓXr_„Í,‰»‘Ò¼Íû9º…)¿/Ì T Ò $• š#-!æ^Hª³LhޤÔF1ÀW†ÿû~—ÚF@#Ô…ð7½<ÿ©Ÿk­I2‹£•Y)<ÆáLmFÔæ¥¬“”èžûއèƒðt0v縌Ìc, …–±Â1yv¤<åP¾—¥­Ñ¢Š$Æ›žÈQú¬„´pRåÜÜ•GVd¦(”ÃôºF"=ú¶*Ûr¾;)+À}~JÜMlvÇ_&ÊóŒTÆ9Õ¨yfªcÛ£@о'Sû8™8ÆÔ £Ä&{©÷Ê]BT°(ü6&‚Ìgê‘(e£ qð,G«<äèA9φm_Qµ3'ù tY;Ï;•Ç8™°²ˆ¯ñ ­ÁÙÝh¤©ʺnó,ÏÑjúxÿ÷îŸÛ=IÝÉEOuÍý?í‹Â™îV`(› ð$æl¢ßªOÞ6ÙÖO_~aç7 8]Ì/þåæ™|ÝÎ+¯B,ÃFf:æõG‘—gsë85¤å0R½Åtêš å¾ 4BÏø±««ÊX/óQà#¬6,LIŸ˜%B€j;áæîCùúÕxU†BjQ´°Þ—2Û ­\ÉR„‚ã–òÐ=VúÒr¾-¬QŠ›æ:•ާÉõä—±i·;ヒ4ÓÏ&«yD¯eŽ à¢ñÅëx7zéÆv=®)®kØÐÓtÆçY þüA£¿endstream endobj 5203 0 obj<>/XObject<<>>>>>>endobj 5204 0 obj<>stream xWkO#7ýί¸_AJ†¼Èn©Øj€Øî¶›UU523NâeÆNmOÿ¾çÚ3“I–…ª€"°}ßçž{ùç`@}|h4៴8x7=è'}6vA'—}zŒh:§aŸ&? ’ÉäM³ðªOÓ´sX˜¬Ì%ÉQ¬ry<ývЧÞwYG>xi5e¦¼Ã‹Kc~æë“Ë1ñýœzÐÙŽ*/\_ÑFå9Éù\¦^­eþH ©¥^’ßš—çF;ŠšAÐSÁ|#·NúYgv¼k«CBgÏI-ž”JèÚ“_JM"Ë *¤^p<ÞÔÁ9X<¢xqT9s„'” ă;'[΋ “Rc-â$¯ I³Î†Í<š’„÷²XáÜb!c‘_gØqŒ³ã„¦KiåÜXIjÄ6ø{×%ÓV%œS ;Ð"7wná^XZ «8ªnÔÄE`›‚rƒàéê¥ñK(Ê®¬Äg—6K•.I9ÒÏõêr¥ïeÆ }ǧ÷ЕÉ$§ ®Þp˜ŒF€ZÖyC+ ³vUc=hj¥ho(=o!€ˆz=JÙ%Aï?}þ“̼Ng¯ Ocœ@æ9ªÅž¾–¶óñÞ]å\ú¢K§ì´»ˆj6‘Š`¬Z(ä¶l=m©õ »ouŒ`é”å~ØW@0\à2G¸°+4DÓQaÖ`Ý£F¡ ¡„5b4òåV"•$© —Q±…vèX[š\38Z†êàB»Xɺ‚ÑŠA‚"F 8-¤ö]P!îpO#=5z-µÂÝK’5 j«PP8*¨’Jj9ôîï%œ!ÉÀi Æ¿w„ÿŽ‚æ=,Èý¸ sàz[#‡Yn·AŽåPEÉ(SL1 RÉÕ5'‘_Bu€SQ‚°Ý”‚¤µÆ&t¯Pç(Ô²–=ãÓÝ‘Ñêêç&ÅÖá0"š6z‚4ׇU”ÿu®€‹Í&TÛJ‘¡ë™j§«I‚2Ç“zJuè®ô ¹=óqMÏ€y!2P&@’Ô´Aì÷;àeöVk¶‹ÌΤQ»·1öÞ‘¹¯Ó@¼ÏG-z8#7½è°Už#ÌŒdfö;*¦LJuÙ˜Àìßbè† Ã©üÍÓ9%4¿ô!Y€C“ ‡‘ –Ô[+S"]Òº°zàËpoÜ)Í0ruô¡2•ÍŽŠ, Lì¬÷ݸùúööúê×O¿_Ü~¹˜Þ^üøuúöÝÍkÚ†Ùã+8LfÅ{O–•ÌØpB¹-”d8æÁùUç l)…Íõ=+o»skôB‹žÙaÒrÓ ÀÛ.-8ìÈÖ]úV:´ƒ”¡=0\Hì¤É-xÉ`Jåm(9˜44a˜G’Ae àÎÃऊK>(ª±Ýö˜°ÁýÀ£ö\îHcÕžQ#Ùu©æ=cwœiªº»9±p ¾ƒ%M¡“ŵ%ô.æe™ÇÎÏ ÷’3/µ2—jý|ÝôÎRíP5‰ê®ožïÍ­ò=‰­æóQ2¹Õ¹`k‘—È~ß÷$^²Ô°ÌÉåëj•¼'§£SšL°øÇ}ŒñÚ&}ú`Ò’³`,²6øøº÷*®üÃI2Âÿ WqÁlêÂoOû¸âŸu<|ÅGÓƒßþ,7Ñuendstream endobj 5205 0 obj<>/XObject<<>>>>>>endobj 5206 0 obj<>stream xWkoÛFüî_±pXn$F–,Çi›Ž‰4icFÅ™<ŠLI{kL£ƒ |,3s«2ºS6U·™®Z æIZÞ…;Yò#qfeaXÛŠ–ºÐV9Ä´J]ò`P½˜ûmäÇÁ”ó5“I0â[4xC£”e{š)²µ·í3ÄŽuÎ~E:N yƒ gJ›n1Ы¼Ìt€Õ,5n,ö{K'ã6ÍÎí-o™ûìP¡WÈMVkRQ¤£Þ¶ï>p&ÞCe$±Oƒ££—ìúeÑä3R\!×¾" ^€¼Ÿßݶ^m€»½d“*¢Ç7Iˆ‹ýo7YÄY;“'¡ÊP€û2ß®éêæò£ Í‚¸~}\ÞÍWÄàãŽMŽ8“£`Ò)Âvªp•¸¯QÀªo8ÄBly«CÅgscDFWÅž#«Åié7nµÐ¡.g—ÞôN_œ>~ƒ¢f¨7»Û•”l< y¢×²H…®–¾Ö:£“†Ð”ë¶b0À¢‘²‡ø¢mi5>Å ÕÈ£æÇk UA·p6QÅýäs ` ¬`@ ƒ¨´LïtA•ÉuÏ‹&ÊŸ|ÞÆô`¯=óLÒZkMH3<ÛŠßÑåé§Wóׇ“Ÿ;‹~ð-Hx]É ¾"Ú}¯ADtcl ¸6Íɵ¤3µ®þ¹ºþxvòeøë'ù7¿>¿â¯7çgýÕüýõg¹uñù’Ÿ\̯?ãâ_ñàÑj9kOƒÑ@w:[ïq‘ï´e–ÚTÃs%hPšH?«–6™è$¢}ê³ðú‰4¤äÃÝ% /_°VzqÚ¢wÖe­,:E³¨@7W€ëVé6Ð¥BåºEæfAhê,bÔ©0L#†àPUéÜêBKpÑ,íÎk`in¿"Ó]À²« ¨A¶2¦l‘‚=¸Z‹v}ÀÙ–SànÄ- ˜[Ïè{é è DSNzÁ·³·OBôm\g’8áaRQÜ=8PW\cÑMæÂ{ ö‰îêo7ù_Û'χez;ÑéF‡ÜКMA¶ªd+÷ºÂXÐ Ë%ÖÔËbnÝe&FEz~ïJ-û´„ƒ~Ê&¼'ñS’6ôÄ«áAÇIœí8xÅêäm¼ èh\bÔ°tº‰Ÿá¤I´[“û´T—Æ”:Z1n`¨ÙÝ›L†ž.€XÇŒ:JœpC¾y^#{i–⮌ 9·ŸXp(W9§sˆà:Lã5ãEõœÎU¤›Ö|„K¿;m†g6Ì­K°S O!¦hûÛ«ïD÷IŸñöfHú%Æ”$o¼ÐÆ*üVX1•a²¸¸üpN?Æ€T±HaX›-ná fÓ¡ÇusàÑ‹ý®>"‘—µ«º†äm?¸<ÌL¥ÍéÍŠGåî&ü{²‰¶~0¡ó¨^âÙØš'¥MÁÒµÅÀ/¤Ì(#ÎÖhѨáqóûd2> fӽǜfñÑ$Ó™ 뜕ƒ«ÄøªüÚÑK?‘?=ÕÍÆú&˜aôprÌÎç;¿ïüÓk!endstream endobj 5207 0 obj<>/XObject<<>>>>>>endobj 5208 0 obj<>stream x…WkoIüž_ÑŠt‡{ãØIœ8 | E÷F|‰„Æ»³ö„ݽ™Yëtÿýªç±~po¯{gª»«ª›¿OÎiŒŸç4½â_y}òz~2ÎÆxØÿa–t6Óu6¥yI“1]=?Ï®®žÑ¼ðQcšçƒ_©|)¿ˆº­dVêV6÷ƒÓ‡®ù|:<ÝœÞ?~<8Óè±bûȶs‘oeUiú¨MUœËo‡ç•¶ò~#ÎfÄ'–4ªÑdQ >4•ú,©Í–lnTëT³¤J4ËN,¥Ò]'h%,~d»¶ÕÆQ© µZ5NKNÓÍÙÍÓ§¤2w´èTåH5>JP¥qžSµÌh¾’[FR.ªJ)Ñ 'ú¨³Ò‰GícÒn% ½ÿøî7Zã6¥K›•ÊW„ÈêZÒgÕ¤K’M® YP¾FäÀFÖd3$\Ñáe… IF¶FZ‰ BzâMã1ûÛG\‡n–Z£×ªxl+s%**»&w€G|“ ”{`7jùÉm[ô"4k׊Á0¦¢JZªµlp\º9UÓÃ5Òu¦!”â%ŸÊ‰Ç‡ŽÜN(fO÷amWs[•£ÿÊ×scDÛ"ûðúýã,!ßÑw4™dÓ)ÈÌLlQL×3ª§hBü‚ÆãéìöÕõ8Œ Žïí¤<"îìÝÝzB£0>bðüàIô ærCd*æèJÊ9¹4Êm¹&ÊÙ¾–Cð„sW–ÖʸtØ’ª[m­ZT’ –kcºÖùs˜…½î—‘æ ùLþw¤ý¶ºc.§\=‰A¨õ‡²FJ#e¨ûð‘%ÉYkÕ‡Žîh0ˆy¸QnÅ@ïõ×ó-ÝU JÐ 3oiDnANH¨ÐȾÑn[deõ @îðœS¬p‚fbt9ês?°RB •Þðy4’JÕ€Ë8O¾ °Rìh8È­ùýÃÝÝ®ŽQàcH ôK¼ÂÜ*ÿ5·¯QÕH÷µUòEè„‘ðK¿dÒxûR‰(Q´›tõ!P8ðlöœÎÑËä“—É''W<“ÞûÒuè^ˆNÜdO½È.X(ïJÏ V—ïX¨6^FŠ t¬ƒöX«ÞbSµ@J轪U% ‰îãù[Qø±×5~P &îw ½¬À«zè;ºH{!yм©@ýµð·â´ZM“βò³°üȲäë×fž{Ro?ڜռ‚‡N\Düf¶”˜ `¡Åßœ[˜mó6Ÿ½À´õ¨šä=$•£¹·¤8€z âã£ÿ$Y ?~˜ÅñPØD`ádWzƒjx>„q$Ã2Çï:ïjlhPü\í@–Þ¨*»··-x+f#Î1Šý»»–öUè7$ B´Æ«U-Fº©¶Ýî 6@Èž­Ñ¯¾q~…Œ/Àܘ°ŒYÕÜvìB™Ð±Œ^ùiÑ«Üù°ØöáØ´Ñ#¿| çdÝb>§¶äõGI£Í_ÑÆgZÓ±‹S–%érÙŠ<ð§Mtóë¸Äž__d—ÓKººždÏÂ:Èäh’é66I0Ù¹SUˆ= 'ûÑy† c.ǧüo _Lžó£7ó“¿Nþ²¯'¿endstream endobj 5209 0 obj<>/XObject<<>>>>>>endobj 5210 0 obj<>stream x•V]oÛF|ׯXh#;"MS¶ì$¨ìÆ…´Hy`œÈ¥Ä„ä±¼£%µèïì‘”LÉQQÛ°ì»ÝÛ™»?çàûœÆù‰òÁítø·¿ªÝtíišPÐäí¹?™\Ñ4vVM£!¥…¥õ{üá¾ÎÎèV±§‹lC9çs®ÌÉôë ï±xDKUÑi¡r~¿¿õC^[5Ï7|ßïÙþã\Ïî/HŽMÈC‚^8nN—ŒèT¤&§DW”«B-Òbᢟv©‘2´â,“OUUj›3¥†Lš§Rµš´]rE™*µZ°ñéÁ: ój©,Eµ«ÿvY†R¬*b2K]g1••ž£² Í?Öâ8dgÓ|C1'i!Ùé„ì¦ä\•†fØMT¥sØd ³“® á…ÿeÉ©¶qUdlUG¶®XÒK­á¬·:šìt¡¥l*50äʧ{ô‰×*/3‘©ËR¦®aþÄdWzw¼¡,ýÖ/Ö.SóNÊïÓÆ C<‰âa“Âhú»ëSG ¡‘êó¡ÁXpuF­÷-9ð–#“—¼¿ËßôjW£ ¥PEl mB߬EókËÒZ +%cï¿Ê¼¡9ý$³áì¤Wç ­±3÷“¦Mß!ïCá‚P¤ pX ^[°ƒTbHS»L¥x·,&Á0Ÿ¦ÈS\¥ƒY£'•Õ,D_pÁøä˜'åÐE:æãàIæýKàS©èǹw“t ø$ŒÚ%s´Ú[ŽT žIž-»úÚb\¯G§H”ë8M6Î/Ò °D”ã'®6( Ó´ÒÕ7C_kcìâ•G^—YGù!7±-ý·âÀ×WhɸÄîÃóè×&á­vóÚˆe—Œc|.[Åꋈº)?ƒ}á( nô?ÖŠV©]ºž6æ¸$JBC³ZEý3†¤K›êƒÔÁ#:›–5ä ëÐ GRH^ÉT8ç\ƒî§I=sLê"§>?»~8p>yøÅ§l_Cœ¡Õ;i’yÕY¦W‚ú.™FVåÔã€6+«µÅ]p ]ŸûÀ5Ö5®*ú«¿±§Z7@å¾Ò91ºÛUÓ¢+>/XObject<<>>>>>>endobj 5212 0 obj<>stream x•VïoÛ6ýî¿âÐ/UV[•ÄI=d@›-]€ Ãûb` ¥“Í•5’²g Ûß¾;Ò²-Åi²$0bñøx÷îÞ£þì !¡ß!Œ§ü—½Oó^'ôððaVðþ.ëx óF L? ãéô æ™J`žF©Öƒ´þ¾˜ÿÑK`0¤…,ªê¥’é¬õ |à"Z\|ßyþ/#œ[¥°(Lº^DéZøN:,ž"l´Ì@– á¼h°Ðüv`Y!áqåÓ3}r Ë•[· úÇ}7&#‡±7÷ìE;]C*J¨-‚t”5<Ô”üŠàÖÒzÒÚÔF£x<¦FdÑ àð/QT ㆷŸ2k¨xóQá›ÅÅóëN×î›b…æiDe¨þE¤fž¢áâ¢sŠîœ{ØXëì·£ùÛ³.¢/Úá rmˆK¥d¹‚ÝZgtüdö¹fž¼oH˜ÛYذˆ„YÙËñ¼¨¥vg÷Å/ì“î­ê/ »ƒ‚&[pguS݈ÛXг~Ö[Ü ñUd Î¹¬Z?öüù‡¨6E$¬ý£ ŸqëÅéq ,–h(+ƒ Ò­E– Í‚B!Ê’nÁ:S§®6hcxtÂÉ4°I”Š–4!ÀV˜J¡ 2z©°ð…Ð0÷ ¨U.x¦Ñ–o¬Å†­«Jç7Ø:]CŽbä|©¯Ø‡Çßî?à )3Á”l¨*.í…gvÄ*lµùJuéºÌÀj*…ÚOe±¶¬­¹†y›z©TM%b?¤A¡<&>¯ýà¼VÁÿ+Q¼ÊÿˆZO§w«\ës–×İ»,…ù_Îrï­¤ÚŽjzƆ³u:×Jéí‹~Óx Wùû>i8ù  äÙlÓ )ŽmKÜ´€¨´ ƒ"c^ï t÷ß,;[##ÐT@ã¨êŽß“ûZ¯sº jch¨Õnq•¶VÒ@3RKÓ•†Nö˜’/'Ê_²lÛª»~š9põ$x’§Ïû󩧮gØ?"”V`#ÉQŽY¶àNöý—ÀX°ðå—¹—Xàñ ɾší²¹ÑFÓx_Ãí»w”;ÉWzVÚÔó8‰½1yYS¹y­ÔÄ–]‰ z¥9P¤ÍŒ¹ï’”Þ ó£j½ )ÙÃŽ>}{9¹Bƒhï´îh6ŽãEáç¼ý‡mŸh.g^oàµÏàG2­ÓBòºLÔå“R®÷7×(™Ä—ãK˜N¯\Fq?ê´.h€É`tÉuPÚ!vpÞÉ|—®<©{Â8ì2¡æèmT:ùÑOóÞ¯½ÿç²ãendstream endobj 5213 0 obj<>/XObject<<>>>>>>endobj 5214 0 obj<>stream xVÛn7}÷WLýʉ´ÖÅ– KÝ(дZU(.WËd—Ür¹V„þ|ÏK] ŨcHñ.g8—sÎÌ?gãß„fsþ•õÙ›ÅÙ8ãáîíéònL·ÙŒMÇ49ÉæóZäáÔ˜rð`uNm#êåàÎZz^,/¾¿X|:»¼»¢ N4‚åh:ë-¾T†ðAEg¤×ÖP<Ž`ÂñAt¶¼8ö2 !¥j|K‚ø¢Æjã•#ëð ýá- ³%Y‰¶¥\9ý r*œ­Ù$c‡ÊÜ{Ò-µ¢P«®UTw•×M¥H›¦^©h£}Iÿ¸ÿ)X_Þ½¤É”“b?sö3g³ì%}ˆá´CrªPNÁÿUÇßÂä$œÛö8©Mã1ôöÅ‹!WÆ)F<œJ®‹àÎÓÖHuWµZ¯KÛ¤B–á覫„WdWŸ”ôm†¼©/¢F^ߥ:ï:šN³Ù íÍ÷}œôü‚FRø¹¼¤\ÐÕ6º¯$7ìÀr-Ÿ´Ü•å´í,ÚîMéàÖPÆÓvW½Ý_§pa÷šKM¶Heˆ‰÷&ô7U 0ØñBWO®[¯{œVú3ÀRêv4j%u¡¥¨ªm²äžYSm鼯þyF‹]7á´Gé#ŒD\ Sz@W>`¼´– ë|™Ñ% ñíÃ/u(@¢ªâ…#~Ûà‘·kÅ8’Ó6N4 þ”6WÚ´ßCÒmmrùŽ“¡RälsÎÊb y@òÀe”Á¨RkQ1rB|j¯¨ ˜‘ËÁò"B,|ŽFôÖ)†o x !€ìUÐ`úr`B°ùås–èw OZ†¡qhD?,”A4†dÔŽVYyjv Y­jë¶<@/ÀÞRi«øi1¢p'âòÁ臗ƒŸ;‘b¯”`òœÔûܤ)wØ2v°n%ÖÇü’¶ª@$•//‚d ìõŒ3ˆJÒ Ú”Z–á丫cÈ«0)à2gæâ¼ D±CDByõ@Tºïû Ÿœjè?Fû®²"Ç;`q÷>c_3¢0¾´y? ¥…¹Nz d‡ag[’¶kˆ^Ì%ŒÝà vrè—gP@úQs¹OëPX] –!¬a¿)KÐñ¹ìì³~DÜ?¡¢R˜°J  5‹/C_‚¬ày o‹Qm”{:<È$Ç6;<èÝ>â”o¯áÅù{¬Ÿ÷Féø.‡ãÆ=Já½Ý(4›òÕµý·-°¢œä5­Vðbt‹Ìð™2?½®1p ûœ¡Y˜uÛãêpy<›>³óY 3*:‚Å£àX ÷è ouü=䡈ÙÃc—1uî›'³zÈÌ>/XObject<<>>>>>>endobj 5216 0 obj<>stream x­VÛnã6}ÏW ØÔi,ŗĹ»À&©‹Òvî‹‚¦(›,jI*ޱØïJr,çҨǎȞ9sf8_÷úÔÃOŸ†#þ•˽ËÉ^/îááæÓѸGgñ&) z4:ïÇ£Ñ)M’°«GÙ!¼ÆÆL;ÓƒŸ&ïõ(êc!y\&wž÷Ðþs{â8nÙ}nŽÆÇÄ~RŠpp4ÖwÖ¦$)rZYíýZ ’&Q”é;E~¡Ý;kÃŽƒx8DIç#¥ô¡ÁËЫWÑ•U/¶ð|¤yc’N bS¬)­Î{íí½²™‰ÎçäÊ¢0Ö“v”O_K@8J3õ gYø®sº:<Œé³Y*¯—Ê!&e±„7ž,LÂO„§Ï_n~a~ð”h'–3=/?|KêA,‹L½NÅ½Ñ ¹B,§ûÝÌl­ºP×ë/¦ÅØÞ9iÚÿ¼½¹¦ñíí´3ûôýxùìi)«èRXÚŸ=9­%›”%3a…×Ј• &T9PUJØ.±PV:Ëh®<Òº6ç,€S'æoLMe¬/úƒ úR;9é_P“[•Ô©©Ù¬ù"•¦Jz}¯²5éyn¬Jº-emùîïøF4:(Å-DbV8b¶ÞNV(™“11”ê‡PJ³Œ(WpäM† «r±Tdr¼S&°QÙÒûÊÉ´Ãbú«‰¾RÖ¶v6a·â·´ö6%¢Žè“”È%"YG¿ZŽOTzËF¦ï«4µóØîjÿö›J¯‚ %n•3Ù=ú€©; âM˺b勼ў£Ò±¼Åv;Àrr¡áÐ4¬Èï*#‡’ví*R"¡¸k:TËc]¨¨°JªDåR‘-3åbš@5°„¾Ð½V bl•gU¼ÈúÒyQ¢g„Ä]p)¼‡¥zª€àW{4²ÝŠ[_ HÕç´_£!j§\¯è¨R8Õ ¤ÚâºÙB@^Üá´GàÍ}38æà~ËlQ )p tù.pÏ좿#¹£LQ1KÔ1pâ+ 3ÁbfP“ä íþZ‰Œ³B ßÕ•¥¬d㥂ï\»e…½°Úà^C¿pdM9_ u„ö¬æÊº.® #<>·ð‰/¥S6^LbºŒªiÌT ÁÔõ˜Z<>*=”;ä‘c3Ž+ ÀbBJ›pŽÆçÔ‡RÌ Ñ`ļ Fñ0î÷™!2…‚#c][м÷8,_)ë’v?Jycîô™"àH2®éÒ&XŠ  Ðü8#­¦ÔÅÅŸ;ͺà çÞ:T›¯ ß‘ô­aÓFÒAîq†«sÓ°z-ù†¶…°¾Kš?Ú}¡Àº–»fõÓNcI¢×m¼iþ#ÅEåwÚ±ÓƒÚ9’Ž…oô½Ž0rÐÓN5T51ìËm728·œÉ8@~Í%í7¹øðœ÷v´ ›Ì>g2´CÔSÓè_LÆgõ(Ø?;ŽO†'4Âçi5б,¢AÜ£k#Ë¥Ê}(Jf scµ;:­ÒJ°½] njNzPõ"‡އC~ôódï÷½Ñébèendstream endobj 5217 0 obj<>/XObject<<>>>>>>endobj 5218 0 obj<>stream x¥WïoÛ6ýž¿âö¡«Úت¤Nš.ºnŠ †(3h‰¶¹H¤"RqŒ¢ûÛ÷Ž´”H‰×ÂC‚¢ŽäñÝ{福£! ð3¤ñ„“üèûéÑ `°ùS®èÕÕ€Îâ1M—4ÐäÍ0žLNišú¨M“ˆè½É‹LÞ‘)d)œ)_΢Ähëšß&³ä‡Þ¾˜þ}4 þSÓ'¦ögQ7ÛúÐÔT‹LR)ïCè]Uj* Qº·ô¹³ünŽÊŸš£žšóÙgøêê„8Å%õ±}4Þ:ú¸–š6¥( ™öH9Ú˜òÚR¦®%mMEò®‰;ç4ÚÈõG£x<ŽitI ]ÔØÌ¢qïdö¢•÷%¥N{g$:¦´3Qž|ZÃCT´5pIò<`ÒŽBÜÞÓÿ¦ëJ•8e„rë¦êdne™‘*½"[…))Kn-ýññÃOü #Áet†–U–mi-tŠçš;»xQJýÜQ*—JË”„%.™eðˆ‘tkII&¬éÊ”_0Q—¥/ÆZ¤`]*CyÜZYž½·.~¥º.ô©ÞÉÓ/ŽãÖó²TR§Mpýñ, ”ëº7¬€6÷»+~x8ª(¦FZÆæZ› m\`™šP Fd—Û²Ò¾Jý¾Ò´‰ó|µ mI­´A%™ÁÀ•±žmD©Q¿˜þ™¡É:•ežñõùäëC÷hQ9x.¸ž·¾ºR'¢°U&œä]ƒ q(‘¡ò!µVÙþ[4Ï@‘Cû;³™‹4§ì+uû±ÿô]ÿÚ¿R]Ž ™®e) ì’[pÙP.` ̽&Qb÷åRãýŽÈTY–?×\ >=“w” £µ;E”ª†£neL?KY@ž^€5[G'¬“w™5¨C}9&‘¥¨J Ÿ‡˜V¹( ))4X‚ô©DÏSÄš\òÓ—&¼?>¾ñnG¡/@¤µ]xy[2— ßõ‡é„4ÈÊ\h§ð”Ý0/q¤Àd˜1òæµ>j BÎϽð¹íxò¢% ¥ÞÄêiu š¿¯5ZS×€¯LeÉ@]3ú¹¸Sy•CüyÕ*Snë• ¤¹¨©Z.Á4zU‰k0»çá…Òl¢dÀkžfA}œŸ °A¨+k¸À&·nmtLï2ü¯Vk¬îd©[-dT­UèiÊåKÁ=™Y ,`ïÍÙ¸ÉAz]¦Ìݪ ‡Rèúr´0(•¬½“ VJ>‹¸^|6‘ù™Ã1?Ä º6¾„€»J?°zî=`ÞUD]ÏãðbxVwòÓ˜¯<Ãl„+L»ÖünÇŽùÜV‹ùÞeû/›WÙþeéåÁë¦êvÿº¯^VËÕãe+-Ê-åJW»^z¼ ÈøxåºlíºD|q C÷žr.!_–Zš·ôßÀ¥­'Za63c’â^g4dë»—†<´ñf#o*u+2¼éysôŠíá¯Nþÿ#¿à\O§¸×ÕüÝ ¶n9ãç¶ÃüèŸNz;×ø„†©-ob..Þ%s_½Ëw‡o"¿~“¯:JMôþè,~S›Ý¯ÆÉs&;½ÓwgæåM%2Û£LZ6u¡ClwMÓ@À`w­Ž‰½Û€ß僀YôÍEï²wyì—D²VòJ[l£¦‹†›Š Ì¬$®öE‘)„¢²jpì2‡›ºV{—vå4–&Ë̆PÍËmƒ?º#ǽíl!½ñN[,ŽÝuý` ¾[…ÂÖ]`48‰__Óäl­€µÑÇgý`’Š/ þNÀSðá"û§ácu4‰Çñpèeߤȑ¯x3 ­åd|ÂC?N~?ú(˜…endstream endobj 5219 0 obj<>/XObject<<>>>>>>endobj 5220 0 obj<>stream xWmoÛ6þî_q(BI$Ù–ß’°uÍ`À0ÌÀ>TE@K”ÍN5‘²ýï»#E9v„®sÞZwGÞs÷*]?>ÆžÃÁ•ƒ‚k^CÖ”‰ÆƒÀ~+’-$²Üñƒ±äú O4!ÊÈrÂj+ÔÁGme“§PsÝÔ%Z¡·Ò”ÑÈÕ9Ù²úʇªæÖj?S8¥™ @ÖÏm̽ ˜8/… kÚ“M…gÐ}¹P+Z »Ìµ´Gî3w9+%üÖ°~Rª)0AÚõøü²¨rþIŽ †Àté»o aÒQN&¸J=˜ôᤠŽ¡ÈW·•YAûÕ¢C®°n2ÄíS4›}~ßol0ÉbÏZúo>ØÇÞÅÆ¿ØÄ—o|% îjNH´ QÐ"¾ìÙ–ÓF<6ùfsv]˜œ'ᩎ9¯¶¼D±CL5USU²Æ¾ÌdžË=!œÈ”·¸À;H` ]:j{¸CïÒ— ÿæ•Gƒ®!=ÂîÛÑ4?qè6üqtòðÔòÐTèŠâØA–wecØ„ýdÛŽZ¸èßUîÛõ ½'?hÚÑо’(QëÜHžDÒæ’¥k'‹ÞV >}¶o¸ây>¶—†¤©kT9b&U.ae)51‘5Z¢Œ’^áC”ZJ‰§ÈW çì×iiuÉ‘æ(U-wBïeÇ+埒ùñqõм藲ú#å^{Œ Ÿª†ÛmŽjÖOÐá0į#CÇÝT6T‘£ób«ˆ/ ¼‡á„kQ¦üÉoåÓöQÊ4뼓"%!9deâúíŽ8èzc§n¯W¿fïo&r†ÚEú5s\Žæá$Ä' 8üIóR™1!ô.ÌÚ°êЩä> Ílú½ä 3ÓŒ(ñDwÍk®4ñ?ã §Wd`f˜aCŒ°qêØÐD£&±†T^£¿è´§íK¾Çá¡·2U!<äpš0;!3O»NS8¿ðо±h ÜJùÞL.seXó’gØ])lj<6{VË‚&à án7œ{Ž£ _•,8¯b¢ÆâI³ÉKîuÇpl1Li »y‡Î,MéWÐyñ‚pQm`;€„õ‚JB:¶Ýb/+ö7r áµØ t”5Ùï„pÜú(˜;¦ù»“Öl›¯®X­}ôr>/XObject<<>>>>/Annots 2473 0 R>>endobj 5222 0 obj<>stream x•VaOãFýž_1G ˜â˜ØÉè5|(=®'U•ÚKÕu…{ø°½ézMˆN÷ßûf×1\N- d¯ggÞ̼y»ÿ Bá7¤ñ”ÿ’r0 FXá!ÿûýÝ ã•¢É(˜RIáùe0iß ú0Ø}/) §ÁåÎ×ç;­W½ ³› …#šgˆ<½ÄCjâ!ñ~UkZK’FV)å†Ö¹YR­JI•\S¢Ry2ÿ88»ÑE0fш†QŒÇxK½Ãvçµ*W…|¤Ol Ž—zDðPÕ†’¥ÐôÝímmôímìÅ'/ aKµ&Oœµ)W…£hò÷›ç.­åJç•ÉbfþA=öþá">9ðéÛZÙðJKŽæ·oyÉoñÉ]ji]¾øüù9„;¥ R+©…Qz6‹=—f‹ãˆ’øäù–O »{=x³Y8 ttÔ!wXù“{zÓñÙ‚|jíÐöeL§ç\yôÕ§¼¢_Á@ööѶ~cò ù¥»çþÅ  ƒ„N)í¥|E¶E±'Ñmû3º%jjYSK2ŠÒYJ´M]P¦tÉËvÏçg8òÃè.àlöÜp‚‘µá(p6Û6±ÇèÆÒ~Kä§d^íøŽ,öÔØß«™Ëí¿øÞÛº·n×Jß×nïfòš&ôúôÔ¥Oª¢¤5—’? vMbê€ÞJ+e¨Tižm,´¦J¥.6œ¹ºû(ÃìÕ†Öb3¸«@Äü±c]ç^*6T/!ÍŠ7qr Ô™Hd@s,Y³ÜHÛ:#î! Ê`9£¼¶{XKh)ð¢¸JvíØÎÁ1|ÕFŠ”­Í2¯}Nª‡È,…¡j(ç&’DÖ5H‚(‰‘éºÿ ±”åÔÀ=…=ÄåÍB[\ø˜åI. ¤¶Úl¹¢ñIÀ‘Ïn.)D1X6‡Ñ”«MƒqŽéšëx…lk‰”´,¤@Z¯ôÆ9xÒÝa4ŒÃÅûÌâXŠI‚²¦J ª ¤ÈpT‚êÖ 9ÊÈõð¿="ìÔ5SêËÊê>kY7…Á¨B¬¬ƒ·¥{A|A±Úu SóV¿œ¯¾LZyÚKjÆ1çßïßaà+–N™ÒZ‹d”‰^`‡­Š+!¡ž÷–™­lÂ<F8Ó;‰9XåXJÙŠGÛ &ª*ú,‚Nã¤35å‹Ji™vF¶9sEYþh7î`ð·tµåèØ8_½"¤¹ó7M[Óî(öZfíiäŽ#t³_ßçÝè5ýë‡Á rUëHÊ¥éØ–¶lû:é'Vz0Þ«‚º—ß,P[+(Qul0£²FÑѤe³<²wt:OL‡€~Vkù µ=±”†P±F$Zò8w ñŸæ],—¶–W­~u»lag>/XObject<<>>>>>>endobj 5224 0 obj<>stream x…VmoÛ6þî_qÐÂY-Å–§M³[·Ö­C ì‹€–éX­$ª$Ǻ߾çHщ”—:oy¯Ï=w—oƒ ñ5¡tÆßY9øu>Çcîé:ºÓÛ8¥ùš’1ÍÞMâÙì„æ+'5¦y6$"»«åJ®iž‘™ªV×|òþpþe0¦h±‹Í'´Îµ±/‚Þ£›Zäz1\>s_ÆÂîëµÉëÇÂÿ=må{0ŠÄà++˺V.†,Ÿç‹C⇳¼²#üœ;ñ£‹)qBkŠ %i‹Çð²¢?qÊ9w1‹’$NS ¸žSM?“¼p$ãÖË0M‡¬ §áİQ{\{r)@¥©wùLX-osÕ˜b7"»‘ZRn¨Tøk…„i«E]çÕ DDEf£¶åÞ ¢¥O¬µ’Vä…¡ rKIkÕT+/*éêŸË$ðþáÍ›NÂigQ[©cºR¥ôÞ3ò h¯‚CÛ¼(‘H¡‰ ¡cŸÚ;šÀÎl’LfqOŽÙ]•B[ú¬€—Ô¦‹+Lã)« <™Ô¾rZµV7Z”fD¹eHO©±¢ÆHÊ aŒ4 ‡¥¸•ÈUV&¼Ü‘QQ&Š/ÆP·ÄôQVRãÒAž»¸ yu«Š[gZ:WjMâ¾αw›3GJYYCª†=«ttέ@EþåCm^&[¨î™7:?÷iyÀ>[Mÿ†"…þŒc8ŽæôS×{虽D_é{·½.™odÌ×´SGV´aí³yÇ΃òÉ\(Õ ¿n–à“CäaürZº{µ?_Š'†‹ Ïöù/Ô)8mUS€®š®˜” 5ŠBmP#G^Ôâ ùáðAK0¯n꡽ŽÈŸ­@ºR¢7i1¬”õmÚýbÔÑù&NúžÅSX‡¯ÓÓ»³ô  ê+EÜ¿\påÚÆñuD†Y½ßÑè~\,Ucq‰éÁmÄ´ôæ9ÂÇÀ0*ä­,8NRË/2³1}hÓ` 1r,QÙÀÝ›i ZÈÊõ^h¦_%3iŒÐ»vuA/7Ô«R­šBá`ÛµJøË$$Æ5=ÜÇç*Þ¥ekãYæý©¶h·fFHôCCóš)ø¥Á*<Ø*ýõàå<º[¨C¸û*GQK;Œ'Gø¨p…ôa2vD»7ЂÁ'˜v¿éN[¦£ÇŸ ü#¶]úÁÂà Ä˜Îè"ãR;2aYI]ì´–¶Ñ•êžÈøŸ%]Ó°;øüeزCì #‹õžÒ¼6˜¯=××ð(×××ÜÎ}¥´µr ä«ý’hWn[Å·m<Éx§Ç4;™ù•Æ %ñ˜~SYÛBØ\Ul C×ËF'~Nû…9u«/´[LÇc¬Ò›+ršž°òïóÁ߃ÿƒ¹Ûendstream endobj 5225 0 obj<>/XObject<<>>>>>>endobj 5226 0 obj<>stream xµWMoÛF½ûW r1H´>lÙQi·zh9T…±"Wc’Ëî.­Eÿ{ßÌ’²(ØI ¶!™äîì›™7ó† i€ß!'ü—GßÏŽñ7wvE§×ºŒÇ4[Òh@“—Ãx2¹ Y*«4K¢+ZÒ+ª¦··©¶zy{;æ'Ä?ý>ý¦}mKGu‰‡ù6+Wtm =?™}8:½~IÃ[îÃttÞ˜ŽF“x'ôæÅ zû1Ñ•ÏLé–3âÔ%÷GgñD?׊R£•ÆS©|v¯ó-¹ºªŒõ¤wz´¨=ežÖÊ‘¶ÖXG›u–¬IYM.+²\Ù˜Þ¯uIŠØê².>›¼¶EÓ8d“yl(ƒXcXÃŽ¤‘mÜ5¥¦{•ך*¹#oȯ5%*Ï5Nx÷þæGRµ7ÀòÍ-ªr°ºÅz—%ä·•n°e{­Ù””•°€ ú˜fkޏz|ê@i±OCÜö³Øâñ9M#ؤB;§VZÒ&GÍ£ñö”¬•¥çHæß­e„>(šGÏn(Ít?›Ÿ|s°"‚†Ýûÿ,mCÚÇmÚ%,›,Ïb0÷™ôkŽE7ŸtîjßµÀxçžó’*«ÍI“¸qbŸ…ÑôÇ›?§HÄ3Ž›èwl…ÅDΧY9Ê–Ba_²®Ë»G—Šåï:®øêôú‰pÝ,ikjÚ(¤QI”g&ƒ˜-á{ò¼¨‘ÉÚiÒ ®¶T1á$× ÌÇÝUo¯R“Ô….½NÙUf.C¡ÊZå1ýÃή?¤.ÏÍF&³ðì´JÓŒËHå”êE½‚Uð•ÉÒšG®fà ?Â…À{ÎÀü$Î?Á[4¶6•8³O]¦Üuž±Çîá¦,m‘Kv÷¬;û%qh3¬6¹CíÛÛÔFSÊÉÑÁaæ®gµ{ÕÄ^q·h¶(Án ìª,Šu…Íó“Îӥʑa¢Çx}EÍym²UO²K ™ê_À×(,[—…ŽóZM/¹x¼vL.º;¾Ý{4‘šûe‚ù¹£^žÿ¿Ò²Ø¥7¢ý©E®ƒœ@¨D™ÚF.\4®ñÅm»ùz~̪’ršNƒV¸Ãf …•50WÄt4$2´±™÷P@– Q%”jË5)s±µk2b>ó•m!¼)%¹rNãü ­Í¨íL”µ"€IÁ‹¬³Èüd6] À,쀉®öÝ7ÒШ#³D·ù ïXE/›kQw¶AÎR‚ã.KD´µcišÇ´ÈMr·/§x¸í8¨’M,4eƒ£èolE©m…»¬ì3Ü0‹ûÌÔˆ²ÚŠ\¸‘˜‚OD7¦ÎS¶ƒíMGn´RQbª-;Âfø¡I{Ó…²“ÃvÛâæÉé•|4ýZyÆdêÕšç§uH5ø°©Ò–±ÈÿhÛãŽïm¢Å€°ÙùÊ8—0½œÂ@_ðÌÜ"ç`Žp•g¬Òt:½Z0éÛùJÍ1¦ùibµb³ºË ĸz[°n©ê܇3®òÒI÷H"*"„ˆäxghöòÜ×vßOÏM÷T’î~ûzpzýä¸D¥Þ¬ý²™èëx[MHæ<ªŒÁHæ}˜~V{Î=‹*—f3-Σ3° ³,ÀÊeïc• i7ÆÞ¹Ï+ðžû-#DMuª}ú:Ìû»®ú…‚€É©Ä,=÷ôú²y^žÅçãsš\Nâ‹0Ô2û£x@?4ƒŒLŒgXÝ¿s]xÕ8—Ww…”ù‹‘Š–×óÞDFx×@C:_²…·³£_þ^¯ƒendstream endobj 5227 0 obj<>/XObject<<>>>>/Annots 2477 0 R>>endobj 5228 0 obj<>stream xWýoÓHý½Ũºê\HÝÄùh'(- !Ž;¢»CU[{›Ú^ã]7Pÿ÷{³k§vÝ ÝìììÛ7o>úuoDCüÑxÆÿÂ|oèñ ŒøãÏW{““SJ£“©?¤œ¦6›UFØžF³±Ý³‰[ðVg‰sSÜÙë,s:òÖ ŸÍæþÉÎi0<õƒÎnwS0™ílùlwÝÙIQwÓxÔ?ûbÙy½¥ ZÓñÅæ€¾Œ)ÒìtäÏf'´Œ,GCZ†5´‰Òb1ZPZP.ð&uq}¸ü²7¤£L£é§³Ï ú­·õŒWÇb˘ŽpÙQ0n.ó–ŠÖÒ \U’j-ã:£+™ˆ›TÕ©ÚŠéÃßo^ÑVÕ”×ÚLM"«••ºI#‰Ã±%£(TŬ [V$oCYšT¸±©M•k= U‘I*µiQüuõE†FÓ&IÄBQü•©ŒüÆ0˜°á›Ø@éîQ’ Ýže˜QwmJÀÝåöä&Í2*¤Œ±ˆ"ìšm)sQ’V¹4 PR–^K LõÂ±× ÕQøã1yÍÉ•g_¤W‡”o/ÝËÛçÙø|£Þš(«ÅeYëÄ![yo¿ŒüM"ÌÊ[®ŸÐñ1 ë:g8;§‹EkB•4urÓŽ¨„‰¨Q.µkùà2Žße,Ò̺E ÖkÉQ$« ñHDe²ê:¸ãåO…ÓÄa“êäA¼™WÏás4óM¬J|+«¥ÆI)N+m²m쭸ʤOËD6TVm6ÒÐB•²œDæp¡ XAsX ˆ²Ì¶}Ð"/ŒÌeaŒËHߪ ‡ÐXnYæprJ´Æ}Ô>]€*y+ò2“ÿ¡ Å^´üøþœÎÿ9;¿|óû»Ë/ÿzþ–¾ß†w.?@„MºÚÒÈj¨Pu©kB„$†üœìÙú[ó½«e}•¥¡…Ø©°[yˆ…ƒŽdèQÕöÏsÝ 2û)…OzžyŠ-Âr»òr½äƒ`:ƒ\XYítî¶×ÂãC;-ÁÏ'xùÜß¼k—î­7*EÆrÝàüâ$q«•ÇïúþÖÔmz“`°ÿZiíÛÔêa½³‰ùS™[-²|c•ejÃÉh™i* fD+¯PF.hc (•¡€È¶PÔ2>ì²L+6ᓨœ!Õíµuruh+]¿/tŠÍ3R׃Jê§ö‚¦äX2{/z÷à{å©ëU'™î—†-ü>0ÆÓªH± áp8~9Ÿ| NúL CóÊn&k†Èòß÷À«ŸÿÎRŠ:”lE¥Ò:E}Ý&QõÌÊMŠ‹.Ève‚⺹J8q–hH"£(cY¡ ÐuZDHò¸ÓŸPqà~\È=¢ÅjkK%¿Ö)¤pÑ4r@ð‘§h/h¡p™Æ÷åF£ Ë·­m”¹Q¸Ó¨¡ßÕžC1m²ú²¥_²BDÓOÏ?vÒC`ô=zÒ¥ Ó8…ØøÙ+ÏuPA™2)©‹_ ”E¨× ³ùÂæ mß¾´?a>á¼r ¼Ç„müª ¦:°—ºï¢q¼}0ãÂóÿ.s½èþ${Åå÷WpLPKxŒ‰¤A¯C” JÔ†ÕÁ}¾ï©í}ú`Ú*Ç+Zgê Ù¼¯7˜6é̶»T=¥ÑÄÇ\cÖ= æücä3þßÍ–™{‘³ÕÄŸÏÙlÉݦåGÞ–F;bðf¬€òYs ®yBÏ,æ¶Gâ™±à n*´f¬3·53n…Mž òiÅççkµá4qãOŠ ÂuÈC“ ¥ÔdÞ} æÑ$Ek-BÛ ® Ðì„×@·¤s?æÚA‘KᕈqG;¦aŒhˆáçuIhØeïÖ£D~‡†ex|1o&ƒ`8ñ§ã)ÍðûB`)çÎ`r©Âš‡›4| c±3>:q=Aû£qÚí2ÁFs:ÄV€€#†“ñ)Ÿ>_îý±÷/ôjá8endstream endobj 5229 0 obj<>/XObject<<>>>>>>endobj 5230 0 obj<>stream x…WkSÛFýί¸ÃÀ`Œ¶C“&–––™LÒ‡3ùâ™ÎZZ[[VZE»ÂÖdòß{îî l—P0X–îÞמsîúóÞˆ†øÑù„_i±÷Óto˜ qóñ_½¤³Ûïh4¦é¶“ëkšfþù¦ioÒå&£Z.€:žt]öà È´ r¸õÛŠ|–M!Kçܜݜœpyòß5\øæ=ø^å*ÍýÝ2Ô 5ÍQ]Ui%³àÆ6áÝìdÎÁ+öÁS«ã̃д270rÒžBÓƒ¨•˜÷Ê)¼Ì[øþ²×À~´äýÒ0ÍÎd½•o¯ mÒMψƥq¢³Ð±Ø UfrMh%w†m¡÷)aQ o:âó‰Ç^”>å2îaÄ 7#5E¥4JADVvØ= $T¬P’qƒ(Z›ÕÿHÃ[@ás£¸ýe¿«Ú³ÿ-š‡P³^‡ÝÀ±Éìxv¼eø<µ'[6Wã!~ÒîÀÂËŽ…^¸ÇôѲüFÈxiÜ!Km y‚¿B”-ê`J®jå÷­ãÒ¼QÚë¬ ÜõÛ¢‘o ìlµ-´n@€oڔ˥¹¨û’€T+óSav<èêòœ 8÷Ò€mDóg @E·ƒ@ÜÒ\ ¸ëž1. í5U¢v^üDb%øÍ¬$惊C¼íPZ4eÊÈFn!\àè™i˜} pœÉÍx­kˆH!žz¥ \*/€¿ïz•¨·ÏÕÞ9¡²³ëð‹åV¹ÆODðñvsÆa‘U #vy¿<¨ŒÂlȲ âk@ãä·~-m£yølë?ÆS|„ù´¦j·•¿"aܱ'ÛÌC€þz}·˜=ÿõ[K×`´Àì´ßŽ^rë·+QEÇ6æÞ·ísŽ9 ÷¦o×Û>¹»ÆýüýöÛ¶Ž­;ÎìL´;4IµØ/ó`²Y…¬y àptZzÄ‚‰¼ ¡­GGõG-_€jAÞ6PÆœ8²ëhfÛ ³ˆÉ-ª<­L¨C9¢ãÌÅ3¸3ª bälÑXW• P‹9r¸‡È2Ê í5&Ö@S”³ªáqGÄEšš:ƒ¼èv›qp°(¤`bñügEFHlòêÝÍ@ w åRW^R K º†s+TsA½üáãô÷Ó ŸOÊÖÛæ^%Å ?RXÅd2ñT"wòDmC"zl“©‚–ø,öÜf t«¥bLÄ3É·ªLuƒ1»©ݾú9â3Qûê£/¬ýúšÎÎ6iÌE¼}ÓÍÝ{t)z٠ꆫõȃÓÇiqÝá3´á:nÆèú"¹<¿Äׄ«dÄ,Õ§ãdH?›ÔŸl¼†ñ2°(XŸ^ñVf/™¸N’ó1¾IÀðâ·_¦{ìý èoô±endstream endobj 5231 0 obj<>/XObject<<>>>>/Annots 2479 0 R>>endobj 5232 0 obj<>stream x…WïoÛ6ýž¿âP ‹“ÚŠ-»N]ºv¶v[]ô‹‚–h›‹$º$Ç(ú¿ïI)–›¬ëšØÒÝñîÝ»Çë×£ ñgDã)ÿŸ•GÃdˆ'ücÄ?þyw4š$ç”NÓdJ%Mž$Oã—‚>ý:Ûsð^fEgo‡ô$ÓlIé¦OGÉtzN³Ü‡Ò,ë=›M±#U¹Sº|ÿáÓŒ¾á3Ú›>?ćÝ÷çtv¿Ü¨òæ #ñyS;ÿT×Ofÿ i€ãfyïZ«œDžÏ{+†ÜÅÈFÚºpó“çÑeä]ØÐÖ‹àqz3ŠÆ»Ñ¡¡m·bM÷2ަgo'ÄA—>A:ŽÕ÷>¯eE[ƒÒeŽøŽVêZZrkIK]z«ª…ôì3ή‹ã M“ñ¨æ½W0ûZ+àð@ÞˆrSÈj^ÑÆ ¢y/¾M<£~:?™Ÿt,Ço­_.Kx<îrŒ¼Dñ†O³~þ2òpÁèàðö8¼êÃúàõˆÂéÁoú½(¿×Ne²X…£ãç1)K•v lÌ%»0«º”•C4e¢(B7ê*sJW}–û$* ,£0¢”NÒU±Kè­6tloŽ=íî˜ýwTÖ¶aä(å†-$\­•þàya½]ËäùIŸ 4sAµR•(èZ5˜2/u®– æ½?jA¹s¸¢µ¸–$|tZìPàRYe ”®6r~’Ðl-›ÖølÚX‘l~¢ptwøT8…3Üêø=dbz €.ßÿõiv†‘å_avoQÜ*X,¤O  ²ªT…0TŠª’&‰i¤’ÏèâÑ£Û¬­‡PW•H Τ‚‘±Àž¶¸ÿ®·ò]øøùòùCEít)Ðz4qç§ §óq%îøš:H§\e:M&¬…»,ņϺƈí&Á“ÄóÚ¿Æ K n¢Žlªdµb¡Eƒ.2µ•T¨+K£*il¤%ÇU¥·´]K€gA˜·”ÏV{¢Ù>ød:ø8âÀ²Š;Ä<¤—´FxtyaD|Qd׺.rdwÛ¤­rkß¿Ñ$²ªU.K:ƒ«VÅ®Á “C€Ê×ö]ËJ1$µ+ÙeÓ;ˆiêeߟˆ¨¼bAׯ}ñЉ§\J¸úáðƒ[®ëE!ç½ðûNç{Åj†Æ„ž,Aà.ÏHÎk1Ê%$!B©0‹p¥¥2 4Œû@$^%U-ç_dÁD½êò­æ,Œ0-HŸZìuQu‡á⌧b€!HÜ3ÌèÓŽå¤0ì,KLîVè.Ô´#¡KäªÍ˜ÆZ§Ü1¦&'s¦„þÔ€#—N¨âö]ûË¿C ìt·,½¶àîûf9éA;3/úžÆ]1¨V‚h˜Qü-90¢Vì @o#¿6.%påN€”ãNör§nõ¸KÐÏ‘oiW¯<µÍáᶈ#ú DçßÏ„>Ô ödî…‹ZsGÏÑ2Ö°†u%Xä,›Ê9n2J“ZS†~;a¯À8Í,;lCÉ7”X /÷P`9.aÉÛL»çy&dÚ0>/XObject<<>>>>>>endobj 5234 0 obj<>stream xÍVmo9þÞ_1:‰c[ºÛ$mÃÛõ$.„t´ âàö„Ü]'1ÝØ‹ímˆÿýž±w›nxù|€¨º¶Ç3ÏËŒ?í i€¿C:ó¿b¹óÇtg ðñæ?;§ƒgzÒtF£³ñø>M˰k@Ó"±òS£¬¤_äg±¬+ùËîôã΀Ò!VËäÉë×OÞ}¸xñþôd8hW+iJµpNé9 š°V¬Éò IÎXÿAiŸ'ùn/v´÷dZ®âžÍù.!la¥ð2 Q{fÆ’:ìo¥C* ŸSº”ŸQXöòäcãÂÆª¶Ò5•gÔžQ ÌÓÑaëªäüòZ™ÆUpÌ”o×Ò:° Øšª¤KIKQJª¤sy;]®ie•^âZ;‰0wµ´@i"FwáfÖ,™df’·‰ŽÎ»s’ëd4E1e4‹rr§jDaÊ@Ô¦’„J´ó*p47¦$fÇ/”ËèBJºxûâyžŸÆ6áòaò<\ãÂNB\d…sñæãöf†êˆ³{+¬F±úX&p0:I°±tà[XOÂÓûÓ×çû¼ÆÈ|³z~vŠô.¯‘¿£¶vÀk*8…kAo8C»€¹C¬€ëá@vgû“.dff®[!*>j&$¢*…ž7bmfôB‡õÎ4«…Ôð¸gÞÞP¦Û¶‰hÂÒW“‡ÄÞš‰^¢(Œ-‘Pµ» ޽Ú!Ž‚‚5ˆ.9£µi¿r3˜l4µZ¨b5ûÆjךµ0D‚΂ýª¢rÜ?4¹¦®Ñ×cÊŽ/¬ ú'ÔÍÜÀŸj©*a!o­¥ ñž=$.e†I•ŽÆLýhœeAìMh'࢓¶?o2 ÔläÃgËäBNQÑäÞ=4ùK+¬N±íý0Zh„q¶(Pa.?²\‚EÐ/;Ë9 '¢è öºù%§¶tÃD·J }–9ëꨂh䪽4£—ª°Æ™™¿ ½ž¿ 0< þû›„£•D¿ÆO`¹&ƒÃöV™Q¶]Aœ ¢§à®ŽŒžlüȆ†±5ä ·¾»ý2HG£ìðï„2qÞ6…'õ þ17؃ ô%¦zXhl¿ÃC4 ¨~àyîíQ]{Œ¯Ç|œáóÄœu®A8ˆ~‰±d ›ú†è­¦ú6èuÕµO°\nšrt%ûs—•òçµÅÜ™=î@ .Â\õ¿™«“^]¿ÆzzçPÞàBÏAÏWlÚÚ‘e·âšY‰1³§T®6 Òãã?Ä"XreÈT”qnxÛuh­”pFHÆ50ºèdr#qöëoí—©ßѶ<ÕÖ\«²í6h1< 0•D]3¸­&»ÒB{Â7¼ÂÔbyÏ*1g§(Æ7k<|~ôßû©‘Ž?ä¡sa/Ñ>Au™,i%ÂÄW óÊ3 ¦®Ö?gøŽÒEÕ`ÿí»´×wP4#9}÷êJ=3}õfú% O{{,\ú„ëÙ‡sÅNE4¯›ðàvþï 3cHXj'×Ï3Wû¨»/ùøb88&;|ºØÎÛvd#剹Úz§qd­*~ ²Tº8˜Ì<¡ŸOî"å±*ªh€í£aøà(;><¦ññ(»;’޲=5:‰ö¢{Nƒ‘¸;½ÍÆ ÚÚíqŸ,|Ëñ`œŽ0œÐöŽŽFüétºó×ζ-‰endstream endobj 5235 0 obj<>/XObject<<>>>>/Annots 2482 0 R>>endobj 5236 0 obj<>stream x¥Xïo7ýî¿b.@aÙ•6ÖØÊݧÖmrÆ¥I®`л\‰É.¹Gr% ÷Ï÷ÍpW–Ô6¹öGŽDr8óæÍ›YýçlLWø;¦é5ÿäõÙUv…OøeÌ/?¿>›Í¦Ù ºžÝd7TÓlþ"wï*úp6³9>}™Myu2ÍfÝ;^ý~q`P¬ú=õ’Æ3ì[”¸û¯iQÈ¥W´È“kÜ÷Ñ›hìŠâ®ÑµjÂÅâÓÙóW3c MfÙ|ŽsƒÅÚ :ÆY*tȽyÐÖnK;×R®,Õ®0åŽ>|¼{}°§TmiëUÓðz­6Æy*ño£¼qm Ûç·ß~K…ŠŠ]Ôqg­)¹€Ä•Á7‹¿ñp´]›|͈X\7ÊTê¡ÒOhöx0– _ ”™ÔEêµâ Ö€*=ùÀ¿Ž%ÖC¸TPåÜg"|F?špÄkp®Åc"¬Za? Û•˜é+!3Ì$/²ñà@áCárÐÇF Ë·–Êx`­UØ1FìuF¿<…!ÈĨëFçtiÎ…?rÄmÁª.$,šJò…zÑbR®âCÚ‡È7‹K)mp²4È2-ˆ~²‚ÒBÞ*8Z¡*ÄΛB+öóAá »A[ç?ûb—’(WÒÑ èROr±ÊnIXlåT;„Ñ€2Œµ²;‚H”ø€©(%Ï1¤Ø¥Ù xÎ6£¶CIhÙ¢+$U„«}>eõ¯#‚ ýÓmAmÐü¤JWUnË’Äîc"ÇN¸ºvyo¹Õ‰ÚÏ_õr•ïÊ9Qî —¬ FñÃ2hlÓ¢tüJ8©qT¶VD¶Óâñ¼SÀÑ ‡ƒåäúæDy­ׯãLßèul}b\ð®þ¿/„÷_¹SíïØ‡Úkd:­ª€eòŒ±faJv•ùÓ0òµÎ…Ø¿½¤ Xò[ ¶‰”9p rŠe³OC¯Gà\7±"EFag£z”$2-öW"³ìõ½³ïL=Ýí~3DgIK'YÄ‚І}‡ž ¤^ t4™g/i4•NÍ=›ômm$혩µwå 2ö⪛J›šwrâþ`JtϽ¥Œî"zÃê–3h©4p°Û¥Uf+‰ë¿'8Ì>í‚AdÅRßIP_Pâ/“ß@7دû[gqq|ýr!¿ÿ€B_Ò›!ï@ÃÑÃ3Åå%5ÑÃÖ¬î9I÷Æ–Ž.ù¿²³¬Ô xÿãžÉþ¾~šà¼‰ð*@!rž¼¥)+žÇéœ$žnQ}plm£ª²˜:‹4ä™ÝÆ«¬ï#|p;zKwTDšŠb’Ë䆭VâË3ÄŠ/Ö¬Î1(6…С|(0dS¥áÀ Èó;Ö8@ˆœ"uºFEƒ®~äÊ~^[½ïtÎoÏ¥oZt$+et”V|~‰<œ3wÀá’$|¶òº¤÷ý»»·‹¾ÿáîûo¹ “NÜ@¤y¥•,;BEs\›F,Š5Ì |›{ø„y¥?R-ðy’hP—Œ¤]ˆPïû`k•ûλ»ðî_ËÁò"±¦'éˆi“¬sÂS oõö}ôÝçª -¾ÌOõ?²Ó5 <^ ¡žTˆÔ"ÈÒ´# µz»'M§}2î¿Ãôйä¬ëЇùåÀŸ4®Q^A²Á™sø{Þk®22Wv às’d޽…ÌØϰ2æ›E@9ûúö wpkœËžë8rD†ÂÄÛ®<ÑŽ“´\&t~jC|­¿¨_ –#Ðm[QR<"¬•¿”.roÍ×r¸o7lDø9ë·™dÒ 1ßæšJ®X€'pi<à <ÏÉÄÞ½Y­° ˆUR{ï ˜Ë‹DkÈ“~<ŽBvž‚ZõOS‡ÞuO¬|iðæiݱИÔsHÙ’©²Å¨¡ÿ8BR ÐUª¢þ©óD{¥ê†)ÿ]æŠìîØ#¥$¯éyNô>ã(³éS[7½ø¤ñTT&wE§ìäKŽó ma•±m#›1”^kÑz,ñp/ϳüðƒV"¬*wÐsF÷Ø‹Ðw¬°%™ÕÝ,°G ÷ß.W4ÇS7†O²éoÐK¸ñ70‰ÑIÉ/”ñŸåÅòâ¿}82>Š/¬x’D ËÁ›á³ýÄ…'ƒ‚07eú¬c-«Z:ºOY×/ûát<Ÿe/¦øþ¿gcq·Ž&ÙýÐ=1¡8Ëž ÓîÑM2û‡_E¼¸ºÎ¦“4õâ >üãâìßg¿dÀ~endstream endobj 5237 0 obj<>/XObject<<>>>>>>endobj 5238 0 obj<>stream xWÛnÛF}÷W \¦›ÖÍŠÓ>%nÒHƒÆŠ\I›»,wE-úï=³êV$@mðÈݹžsfüçÙøÒxÊ?E}özv6ÈxØÿjWtûv@÷ù˜fK húr˜O§/hVúSšÙ?W³Og|lˆKºÁ±›Ñ8Ë?¾ûåi)Tõ$ÚÕ<+Ö¢}FËNOZÔòZiGx¡»ú:¼rÛFί‚ÉI4é-Nà4›­•¥Z­¹¦ÍZj*DUÉ’6Ê­•&·–TíäWGfI‚Ø;mZÑ48Ä^2WUUQ©lS‰­¿$ÛÖ´TKkÅJ’Ð%}êꆜá· rŽ8‚pr#•lᬔ9ÍàöТ„giÚ:(Ö‘ë3ÊÇcµÌÎßx×>œ¥jg}‘Ž®g4ÏP²“ó¡ŒÇ‡çW×$¿6²p¨Àå±®öñKZwzt³N~AΜߣ°'wÏӓq-À`´u!¡Oa7jõÄžž”^šgÞéüê§àáªV•@|Æ·½ç_ÈÆ!páH¹Óî:"öÖÖ‚¡‚¿­“¢ÌƒÓ—4œäbDùpÊÊl4ͧôÐYgjõW¸‡îoM×Òk¥K¥W±P)hFÀ$¿¿ï!mÑvWTØ’(ùCÈšZ’­rdáZA å,§è­×¦ì*tÃð ߘJ ¢K¥•VxÓkiwáÃK°þf4MçCúØ*ǧ½M³A>—Hœö?ƒ÷‰?":§@›k®k 2-$iY0Z0+ÄÕ›µ€¡UOD\Û¬U±¦Å¶iYšK_í—yéÖ¦¼Ž¼D‚=$¥¿ˆÂ‘ô¾ôê÷w^¬§¦•t©ýËËgBEÍТò{õîcef£ûH‡B³90?l#Qy½@ðñCdÁý!p³èœƒ:ÁÙÓÕæî‰E44ÏêíËÃüŠC¤`Þ?aͳªO|}ö„!º½¥V®  pœ†ÖO_ó” ¤¼Ìò܇SóŸ/þ>xý}×ì¸ÞF^, š£cw~°ìœÇ9“8t4gfÿ£ìqbˆXz‰º©ä59YU6Ð+Ú `eŸã£)1?$NJ|Ø>{û6%’EÀÐËÖö¨Óe_œIŸÓÔMˆ82}™G&ñÀÓuØ>ˆTèm¢9*€aìåBn †aÔ#p¼*!'fà¯`ÈcÊÉ $B–¤v Yµ¥ÎOTœú¦èU?öÊx†0«ÙÜaz¬c^Ëì•¥ úÆLŠÁîÝ~¸}xþÜßgºÄ‘ÊjŒµ ±ŸÈTrÆ/vägÓì"Š@ŸÜWYt˜­U5º@Žað hÈCTÊúÙ€tQu^áÙü¿öÑÑ>²_kûFq÷‘{’*Ñ·ÿ;-PÆÅ°Ávß¹84‚ò¢Û2f€ö`UFpd9}ðBŒ®ù®š®*Yv@ö„ý0oÌŽ æ]ù¸l¦[­½¹Â›“Â*ØZkå„ýœæÕþ湯‚1ƒÈX¿0‚FÅBБ¸ôq%¢ç«VJ7Ï ~)o€ðÕ´¨¯ÑnCÓVåùñ!©S˃ßþÒoa&sÁbóÙoD½ŠjÚ±â]|[ã>§¬¤J±¯Pt»­ßywOÌœ±~Û¼×n1–ø|õ‡jÌ|J¸gÂK 0$Ãä ǓὠpfY²t\€£¤& AMYPx߀ƕ>ã Ã£bjÓþ¼›¼@¿\Š®rpˆ8¯WØüŠ´3´MèÔϽ…=­ö@®uÒÖ/ˆŸw.è“î aï o˜í{º€ÝTãŸÄÎëRfyaǃà„¨t”©ûþß—I~7¾£éý$øc¾åúÙ] }ôÂÀaÅáðÍ‹0s±[Þå#Ÿ%„ u½yàý†ÏÞ ¦ùx„m ™L&üèÍìì³¢XGZendstream endobj 5239 0 obj<>/XObject<<>>>>>>endobj 5240 0 obj<>stream x­WmoÚHþž_1ªt‡#yK(é)9¥—ЋTµº+Ò}(Zðoc¼ÔkCù÷÷̮׎óRUºk*xvæ™gž™Y¾ i€¿!'ü½=y;?„|Y¿äêÏ`3 y ÛÉÞDö9Þ¬ƒOÿܽ[Þ|ü4ÿûîûåìúîý"À‡ÅééüëIvV ¨ÐÉXe’E*Že.³‚V2{¥ËœL¢Ë4¢"‘´Ö‘¤X¨4d'êÎ3x§uD¥‘†bÃPáE™KÂ[E*ÛŽ)“ë¢K0;äªàï™îdNq™­ ¥3ÃxŒÚîRÉè­ä“>xHŸ¤¬bGûö»€­4ý´}‘çâèPˆŒ¤{äΣ·Àû³ ž…ÀÎÄõFS~£Iøšndü éÌ}_ Z©Œ3hóf“§S>xçlw¹dÆ iSé‚ÐDm’^*÷2¥½BúÈ…]r±Ûqöaç (—QHWÖCzÄÑTlnŠ2Ž)½9( ÐXhf-3P^è[q/] Ü‘æ\ Tš‚˜]*TÖb7Õ‡ gÔ0èƒóÅe\' yDƒ“Zx•îb:ê’¾–¦@VPêMë0G:ë´PûU0Óù½ér2ÀRèåRX­$Ð`‘7š™R²6eò4š°Îá±Eƒ÷Ò]Ñ1´Eº •幓z¡C¢¡G *5ÝgÀsH[º`¨þAAÈ®°má@vN6/špHoFh“ê•H)…houT¦^z¾ñœ€¬ð®)·œc –ÅDD®:ýÕO™^‡Ü$LçJ ÿ°T@_!ý‰Œ" yXú# ºwÐ4s #F0 Çc|Š‚_Hß4¿y6y¨ò{!ó ˨›im7C¤g}ÃÉä5›Û˜Ni'èÈÿHÈ5«SÒN¨œ‹X·ýÁíµŠ8ìÒÈb8‹Ó6ÆÜrÃVÕóA^(FH•°?½>èB¾!F€°—¹±ã$º[%üarD‹qkƧVü¹â¦!¾Kë2ç‘ßBÁXnñ­£ÆJ)Ã@²„$˜W¸>"Et,¼-A+ÌR£Ùcƒ¶˜'Ž.Ë$Ú~ò\%˜€ÅA7þZ8†ÛsÁr‰N“ßÝ·¾—›ÞKì›çŒ™ C ò«Ø¡'ÁB°õ‘BÈò‘bÌQX§¬ÜÚ<õíú´}Ê“•yLê•ù…iªñúB—^aY@ˆ t¤]{n›£‘™(°y¼¡Á`<›Î.Œ©~vEÛK¤SWã%W®>/XObject<<>>>>>>endobj 5242 0 obj<>stream x…WÛnÛF}÷W ”‰‘dYq8hÔi€H} ¬È¥´1µËòbYÒoï™Y.%ªš†ÉݹÏ93üûbBcüŸÐõœ’ÝÅýâbñ²ûUnèåØnãkZd4Óüõ$žÏ_Ñ"•[cZ$jÿ™ŒêC¡—ƒlyuw÷"klRg_P½Õ–²åàIå^^]-¾^Œi4pÚ ë¼ÒTª}¥ëå`çÒ¡U;=l%HÛ´'Õ>¿|˜«ÉhßFÓëÖ·Áb«jÚ«íÙôÁ5”¨<§ˆ•p@^h îô³Ú¹ŽœógAá ²ßdl­Ë¢ÔøM¹sA3ÔjkŠZUZW8ð§%+²Ž2£ó”"¨HÙTܨB(SNÀjelªŸcZl!²7pÓXª›ÒR²ÕÉ#?EñF×Qk’Õd/ô³©jmM.;1#‡Ó¬…•<ò~xO¡4âNÏötcËÁò*Šé‹Ù™\•ù2WŠpâRD}–Ç“,ÞMÆÿŸH‰ÒG×¥RÒ˜¹Nürµ²z/©AM²•Ôô|Å­#ˆbôÎi’:U'K|Òc“1Gè}}MÔ"FÓ9e:_ÅSú³Òeªj%¥û]×øE—ú[…fñŒÅ~®h§-7½NI#oF—CJrUUh.\U—M‚²èjH ]ÂÑn¹ETE…“fRS»‘$üÖ(ŠšÖ ôXn»¥{ænSÐ uR½,µZ©v¤Pú£HTíÍf•7jÕ¶©Nœ­•±ÜÏ:¸Å ø‘óßÏ_‹2†?Ú9s´(ë±cUÞóçË_Ÿ>¶^,¯$'в\mZÓ;UcL%°åÖ_uRsp0¾†mS®BnÑÉ‚l¾tŠP .wv¬Z­Sè©9SH³ä¦ç‡J]I¢[X¥¨=%>ìBÙüZ¡i<Μ y“.’6à&`{G!. qoâ1eZqí‘ßÒ|˜W±Hò’(k˜«T…ÍbtiLŸêˆÕxÊñ¢[—#>E9ðÏ鮆½(]¡KU»WÑ}ˆ 4ë¦ÖUÛ@p`Ï”µ1OÂ^º‹IbÏ´Î}+⎑B(*µÊCeX);üµж}dgvzçÊC?-aÂ⎠}ì–Ñt__c̤ƒKÐnÕÏIQ¼mÿãH„é3%„)ï¿õžŠf›äMï· =A_;}D“Ý·ç»ÃÝøí÷¾Ð?Çó³“'S2ÜèÉ™”>—Ð.Z þ £î…ÒO—Š}™/ÓåÕri_ ¹q†ðcyufë»xv¤•³‰&íáy¨ÑÒtš& ×Ô[¡ÆÄ“*kªcW üʤ:¦_Ý^?LyîöRgøÜ˜âò‡1º{(­ò"3Kš6?€‚¾€R}áGÆ2ÄLdjí ¿žA„ŸMîÖœ@¸*¬Ê¼×ïÄ›ˆq†f:èùj€lÊ5öqä4¸£JÁ¤Î Zûi.Ó+8Î(ïìôúÞlyÚ£¥ç%qŒF`°Ôà ­Í¬b=)p;çΑIõZa  `©÷àhØË\µ ºÅ>1³¡r‰èðUæÃNOLÄÔÉCJu‰*v»’+ŒŸzä®I/Ô¿¸]WH”D—¸[a²[æpé‰õA–)æ–vêâa—Z–ÿ&ÞQõ w UNÀ¹‡eq¶r†¼¾¡ñøúáÃýôöLnw‡ ¨sh98WðÎ3qŒ¾Ò˜ØW‡ÞTµyb7÷z&V«MÂKs mïÉýü}ß““HVìóë÷²jaðx2k7Éÿh}Ý×Ê»$«“iÒZž}8»Ãx>»s33ËWzzn|.Èb@ ö4Î Öá0Œd¾ã€7þÐÒ‹~v·Ë/šÓ“Ë•²ƒ}üšJ;ŒOÏm#X´äûL¨À"5Y¦¬Î@"_‰Qh?d…çÚIÛ®¥mk˜¥À ]Êĸ¦Q÷>èl1•j¿wÂd×”SY93¼&迃mxîRÁ7³Ÿ¶àI†LPQ…/lu‰™@œ' GúCàq¬Ø²_/ ,ùÞê|j§£Ô—`«4£BXàF#B?ùv ‰¶Jx§ãUaǹ¶`Rù8±&w/nÛï²Éí,¾¹¾¡ù-Öp¿ðøM±B}pIÃ;¶b b;˜“þöè•÷Zv÷ Ý#6NV;fdù%ÖNa­›ñ<¾žbõÇz1›ÍYå/‹‹?.þõÆ}endstream endobj 5243 0 obj<>/XObject<<>>>>>>endobj 5244 0 obj<>stream xWaoÓHýÞ_1â.§ÆMÓ6¤~᎞*ÁÁ‰œÐ‰ž¢½ŽMí]³»&äßß›Y;©«TÇ;óæÍ›7Ë·£3šâ÷Ïù'kŽÞ,ަéw¸5ÞLéezN‹‚fSš¿:Kçó+ZäòÖ”Ù1õ¿j›©šÖ×Í—$]ëüG“ ყPjR!¸jÕMA­jýbñõhJ“3DÈwª‚Œ ´æ†œ3dªš´Éˆ)‹ëõ£- kkï=ÖIV¤_î3ÉBeÍÁX üµ§*Ðó>y„þ]ÕÝ“€Ã¶ÕwÇÅÝ‹ëëgCüg£Š»ã»O–€´öþ„¼å¼\½2{®N¨QÛ•ÆW‰'ECüƒø{.Œð_˜GôGÎ~aFè…þÂ<Åÿö b”ŽŽ¶3¹4ëQfVÍÏ΃6~­2A»‚ÑM4ÒHv0+RþBÏžì×^•£è½BOo.ˆ5]ÐÓ2™÷ÓrüÉÒ†E´¯?:ÀeM$Tyªó)c¹¬L®PÔ°•F]}ÕY F%“#ÚV”H˜ä¡Vdjöúß¿3°˜Òg`pÏxô ºI£Ð‡÷NX‹±ÐÇ_¨Ø+s˜òä£Em˾Â%öÉfœìV*²n{B[ÛI§ÚZmiS…€Îk«|N*ÏÉè ZÁ´?!Ø`5ºY¡Ï¡Tqâ”"_*§¡"¶Zé°ÑàÓ ˜>(“iO¶ kvc,ÅgµòË5 ÛÕ9}×nKZùªÞRfëÚ ÍÈAÄÐQx}øtTè_6è×ôÆJYšl«¾uš|p]&¥ÐÝq]Ýà ¡Ý›ÛwoƒA0 c]Ý8Õ¶(Gði ;rÄÃì(ñ›j½¬;µdÒrˆ#ÙgàœI‹Òvkfø”RyÊ­XO©¾Ã¨H Ö©²’å ?Uf‹Òá¬b›TÚ Kyå[ë£Uê&*ŸÆJ{0£œ²«q„k`r„ïA²‘ºÝØ¥´à7:ç´è𶆠f’© ®xh„h$ÁçMý±ˆ™¸^´ƒˆ Ñue ñ ÜÀô8vIGk¡UﻆUØ«p:û˜!ñôæ1þ ~2›óìÍæéÖø{Ý`þ°VŒZKœbïZüúE*Ãú®S\—ŒC©ë¶è Ì8¨šË‡‰ôÒ$bà(:sæÜ&û¡g£]o7Z?®œGÝh$—¹×ô;&3×<.Š¡Êöþ\5( ü¤ôƒ=·•Æßç0(Äú3^Rh´“ÝÌWA|x Gãõv„$³u 7æ‰`3’c?ïGé3ž\ë2@0$÷^¹mŠ©ÿ··=L õÇXA …¥Èer8 •Ø!ÜÔd¯ð¥)šW„²Vn…zyŸŒ[‰=pW:©•vT ä…Ó:öÏÖHi˜ýì^íÎóÍjd°-y6âiÀÎ#¶Î’”nÙ[ÿ¨¼Üñ?\³ÎSºá¨—Ìò`ñ%×*Â*éòSÄøö¶ï”Ð.ÿ– "Ç¢dGjlݾ¾CÊCñ®ILìÆ$0.4l×|•à¢ðk×€»)+˜ þ=(C¨Aa8©wwXé;6 Føý½…3å:‡Ä?iy³j7öÈ[Y½)aÄX¸NƒDXSÎûВΑAPFÜL4<É[¬nª ®\«2N¶ÒX•íó(–)`“ß”¸ÊÀ¹qdDpൎÅè¡|ù€ |9„YÕ¸ºc…øŠ÷÷ 3ç|YµTÔj=ÐÁìïÎÈm¬„m‹r|æª6ðÕ(§Ãh`ÃË@Z @Ã=ð£2žQN,äsìÂY,2XN¿[Ì‹ƒœÞ¼ìgr6½H/Ï/éòl½óÓçÛ?'³tJجۭ >„ka|wrÿï#¾<£ú.ºz?ÜõÄ/§óô|'‡‹_\\q”·‹£¿þÎOt½endstream endobj 5245 0 obj<>/XObject<<>>>>/Annots 2510 0 R>>endobj 5246 0 obj<>stream xµXÛrÛF}×WtžÂTDˆAÌ›—+eUµ^+1«¼©ÒË’° wÍ¿ÏéÜèXY—]*Y´šéé>}úBþï*¤ ~Bš&ü/-®&ÁïðKÈ/¿ÿz5M‚ %³$˜RAóY7BNï¯æëâXta˜³Fb¥?8D¹ˆ‚úƒÑ¤9²U‘X†½\P…Á|¨ÈÐN'Ár¨ÈÐ& _ÛYöþNÃkE\Ûjý5½v Ãp,ñôÚ í|ÎuZAb¶ô.–¸Ý ³E á±z©WÂkÆ> ã`A3‘¼¿½ÌwNÄ@; ŠàK8Ðz¿$u&‚\Ê9ö"_Ê^”œñYì\Î;D>(þÈ“ÞÛ^†6ž±·V3ƒW>Ð$ˆÈKþh/s  c$ÏŠv C»ÃÖŽx'QÐL$>ê•aïdʉÔ+'-EE¤N/"Mæ0ë%V ¸1Üâ`fsxëÖ DTÓ’ÏɃb´ M–Ý@D“øâàPflã‹£eœ´0>^ꙵp”±H} qÃ’ïua²Dòc¡‡çNŠ$'ã)[j´ÓdΗvÚx#Á­6^rVz­À-Ñ_2ç½Ðy7ÑE€Ö ¬ûÇzн¤…Ù=ÝÜ-Ádb½C£KІæ­·Òâ&´NGќ޸ÿ•T¹¥·f[çj<ýiýq`J¡˜Š<B«G¨’YS£wÏÚ>gúħXò£·¦ÊžU•™òÒZïX¸hÌC¼9…{8öÍ&Ä'ÆÓi0™£ûùw“¹¼+§åå¯^ÍAßqóó+S¦úØ^Þ;u_VÚîTªU†V”g«l¦Ý·ùøwÞø˜0>»÷矿÷æícôµè  ó`užYÙEÞ´2Å1˵}m@Þl·§Gå„+ /ÏJMï$gßxùwaÒRŸªóQê(>ô¸Ü—ǺrR$¦®øïWfÌûÌ,÷Ú]ÓmYÚJ)Az¯_ýîw›:}õ[î‹£±¯~Ëí§¦¼vÂn?©â˜ëo£EC]iÍh_[Î ivoÕtÈJðM­:hÚë’ c,{Ó“øN«ª¶¯Þì¬Úêñþ®"þ•kŸ¾âf͸i°¾¹k‡Û8Z`X7ƒd}È¥uÄÜ ­v©Í6<1täê#s˜Ìî…á„)ø¥‰*suЦ&w0u¾¥¦*²VÛ&]b ;c™þÊ¥*¶6‰M¶:GÚ´qjkkuY,1gX¥Ë²ýïêOGm³¨üz«Ê3íš*"…²sU–çTšŠÉ‘íK½%‡Nívç¬Üã!Xù bAkR¿Ü‘ªƒ5§¡šq;Ù ó H­.ál»…®ÇÓ€ÖM[A“æq˜kP‹¡b?a†ûƒ4gv¶«,¿^µY£4G ñðaºjö•{s×~I4øj’wš—¾4™Mð¥WägY/8€ÛõÕoW$!ýŒendstream endobj 5247 0 obj<>/XObject<<>>>>>>endobj 5248 0 obj<>stream x•YÛrÛF}×WÌË–iG„‚à%µµU2-gUk'ŽÃ­ìƒ^FÀDL 0̪ýø=Ý3¸zàh+©Dš™¾é>Ýýyå‹þñE°¤£ôjæÍ°Òü§8Ð/" –^ ÂùÌ[á÷µ(”ØÓQ,ùÞœ—ü°^ý·qî´£ª|?ÚXlÖÆ|UÛðý9l¸vȆY¨2"ÆáÅŒ45‘Œk3±¸ìteêF]àåÊê0ÿM4ŽVÂql`ÞzæÐf£qìteêF]àp¼)šöþ­.ÇN+ᎆ˜×f£qØéÊ ÔºÀHó;ÇN+ᎆ˜·ž9´Ùh;]™:vKaµA6 MëÁ:´Á´‰¶Z{¡s£è+b…±v-ŒjòÃùýÆW=]FÄX V=Ž×΃‘ »2ucaòz¸¶œ0Ä豄 8ð2Á÷c4x94Yo;‘¾®ï8®Íâå°Ó•qáÅ"ý09üEÍÔmé—­@_ÑhŒ£š¬·'^Ç Àqm/‡®Ì@ÝX˜¼>_{˹—­€ /vªã¨&ë­ÃFG¤¯ë;Žk³x9ìte\x±H?L ¾ÞX¼‚ “GvÙµÑ ôÆ8ªÉxë²ÑqâÅq ×fðrÙéÊ Ô…Éë‘;µ€ÐïãåØhx§ú1šàš¬·ŽŽH_×w×fñrØéÊ ðz»»ºy¿þLìö˜s—ü£†Ü]4ùí÷ûŸ„<òçR\òJè\DøUl…Ìb±ýáqJ Y$ªû"OÅÇ<®Nrˆ‡‰zR™xNôш<Êè‹ØWY¤“<+^_‹ÇJ‹D‹8WeöJ3µ%Ëäty½ûãj&¦þNM’L«C!µÒ˜Q0“’=%°—cy{C.‹üi¤oÞo„¿ð&¼)2?Æ4°¹ØæY¤ÎäNs††é|é­×õAtë{Ø.ö2B˜0´m£6’-€Ó9‹' GY’{ÆõX”ÕùœZìó‚qI²ô5¸xbwL PŽ2ê«VY™<©ÓET¥ŠÅãE裥þ²ˆ[¼Û{°wÔÃî—ßú&T+x–ð&ß sÕ¸UÒåE¡ÊsžÅäoƒ¸ ¼òù€c™–I†ÿÇ rR““€è¨JÕ³¿WRWÐ艷*’8DÉÐc•œô*j\°"CüY.2…ˆ»@‘;óE™:Ñ]T¦8)ž y>«¢ÏE¢@[OÜžN=OàòNáÒ9…eq¨R•iUô…‚d&²2£´jq¢„'ût—” tnþY%ÈHµß'Q=l“ø(Ÿ€IEt ?_}TΉ¢ŒM¶´HrœçJ“ìA,6¡C[­þÊ÷ë’5ô€³µNÌKg'ó:Áô³vê/ñ]lPh¡7[-)ï?òJaâý 6Ø‹Éß߈»ÿìî>ÿ|û¡ê›ô5Ò@¾^Ï…)ÜOÂŒ¨±ŠN×Eð#l)>}þe{÷îߟïLú©$=Ÿ] î.ã6¨ŠLžlÕ]°\j%cÖ@†§ G48^`Ħµ7/ o{ûáÃÛÛí¿^žEêÅѕǼ:¡†Q_ QSÍßG0ðŸìµp|jx-[}9«Ò}¸¸x¦£:-Û«A1L ™Ðp¤¾Ú¡³dhoÞ×Ö¦^€4m8 RùE½Á~áuwÚ"°•ç󖺑烙;Òú0±ïQªN¤©G»g]‹ÄC‚Kó;¿é1ɧ¤Ð¦Ÿ¯“<Æ“ÞwÞÁ£§o·DON²(9ã¹Ýóª;ÐB'ïÈ#Œ¡6ëyb˜5¾&7J}AC9” Oϳ MB˜Ä\Ìb/3"žùñIR±uÃ`Ž¢7/÷üç¯cF¾V©  ô ¥®{\ª»VoFòY°!¨ÏXó!79çO;Š)/RjŽÙ·SumâÆöÉWÁÊá1U@7s Ñs{4­N:ÁËË~Q!Ó WÈúøåJ ½àAû¦ Š“ý<‡I®¿UšäÆ8Nm4MÁûðš]I¹7y¢uKö)ÏôÂF4x56ŠÍa´iþ4tóUCîÅ|Ê 0p®Ál¡O•I>LéooïòˆŸø>/XObject<<>>>>/Annots 2516 0 R>>endobj 5250 0 obj<>stream x¥XkoÛÈýî_q¿,¢`-V|èµ$Î&ëvÓl7\F#r(͆ä¨Ò²Šþøž{‡ɱÛm‹¶ÉyÝǹçžáß/Bšá_Hñ‚ÿ§åÅ,˜á ÿùÇÏ.¢y,(™…AB%EË¿ýSAŸ/¢u¬†Ñ8šáÉhœ,ƒ5Å«µ¬Mfã¯=}.)‰ìäçòh¼f/—²4ŒWÓ .~N¼QI<>ñèè„üUoÙ# ç³ ¦Õ,XâqEµ¦œgRÅA$¯¢eÿ³žߟoäÈ Ic›áˆg·šãܧ9Yòh³çŽç÷ˆ=§nEáŒÃ!þÉNÏxÏñìoïS›½½¹øÝûçÒM8-Öø#ƒ)3 è&˜mekÑÝäåͯ˜ §eæä?âßöë'w/IU5;MûÚT©Ù«‚šã^SÙº†6®Uª|rCžVªýW;þÍÉö6N£lœ ã’]5ºÎUª5–®¾ý– ³©Um´;ßjFSÀ4á¥_¯ÉM _¶éŽJ8M©-÷…IUs;¯ð–ç8[b"ÏÉ´C ð+5ÎØ 6ìT#s*ÛP©2}IGÝôÑfm¡¦1í”ØkØŸlRYrí~oë†r[‹y[¥ì¶iyæÀÂÚ‘ÛٶȆ%[]éZ5¦Ú>Zy0ÍŽ]‘éã#q” ð±?èZ¿€ÇäÒ†76§=Hæúã)UE!QŒ?Ôj¿g38 À…©uÊááÈwq?R¿Þ}Ç @EÍç+Ä~Ìãýx7žFÁr=ïc"3´O߀¸ÀÄç ¢dç‹aQ X³9ŽáÞ+Î}¾½þÀË£丈LÙd„Ë‘§!˜kİvÌ–³ú`8çž_„óu°˜÷ÛüM^q2Lò«¢Ù"X¬°]8ï·œò"Á“ @Ö<ðô‘Y¦a¬£!4F½”¼#ÓÓ•3f—ØP_\…r¼‰”ÌŸÔ¿}íý™š™~¦KtIü•Mî¢Å’νä±.?p1YÊMG‡R9lÿùRóŠä0Ú[…çãP`M[WÐ(eP[m[Ôºþ?Ê4â$Þ–mј=âaª®M£ªTÓag@å¨ÒÛÂ8SÓ`9?l­Í` r ½ÿÕœkÉÉÞº!'®ÝL},ØÛ.c3ýšnvq®…í’ÿZ#‰Rûž•lí.Ao¹V"μ Ÿ8a÷ê™)uՀ鎌"ÏeÂï?ªjÛª-=ãÜß¾hI8wGi‘^hA£Lþ î•l= É$’Þq>&úŒÇ~:6;[ »Æw=ÏÏaÏc½Ã^©*6ß5¶æß’p®µ­ª7ü"µgÉ?öÉ}MŸOºÑ3îžê€JìæWìÃ^Œ/nûW=ƒO‡¸Óõú» VçµÖw/ŸŽÁé~ÆU/2èÉèWhjY×Yo‘YîdÔél[‹è±ƒ ãiïÑdåô¾tÝh`­²g^ÀB•~áZæÕ}0ý¦lGNZÉ€NàÏ3]ÑAÕ—ËêÀÙâÛ›Š:cxºË̹r;ð¡sUó¯kúRÙÓØÛý^J¤ùvØ`b“õCª÷^l€|ì€ØN-ÎÂôA}0üˆ [ýÇ$û”zØœãþ9ÊF+\S:’ ”+fÌï¼ÉL 0÷$5ß¡¶ dœo9c†/—H ]¿(}v˜5 çVˆäÜÑ|îÛÈ©¹Ð§¢.YE³QÒu #bú©Ö…)Mu¢IÏÄl°’Ìð\ô«^êù(ôÒZ„›ßT²! ,3yŽÌ„}ùŠhõJQ¡YTˆDZÆ—´çúüóŠ¿ÊÛ±_vIWªÜÔ&-ôï‚.BÓEN™õzz¨aFpjÁœÀo/OÉí!„s“âM¦‰Õ+—F)Ú7Üa;ŠD }|ÄÆˆz@ïÖF;Q²úAq•3Ö[‡ÊBc‚ /è#ê‘ÝéÀDF¾D0¢7£@0Q©YžIŸ<ÌCX…þO{;ÈûÀzld»z‘–²¯õ='@L^Û²«xqä]|¿pYqVdAÝÐ¥iÀeR=ÉÆøkpm:ÚMYW€."VÃoî›w:%‚ÊåºøZu÷9âùQÄóA•uŽÉÀ# ¡¼Ó.­8íÏè1 •<"ÜÆ¦:š—ËÓ^ÚîœW_±×¢4—ë`½€¢¥ûÎ8Å’¬[ÈlJ¼³#ð"ŸpñCȱàœ1 1Ym©jK4õ”îUÑCØKLQUsÞü{F÷³y­ãW~NEu‡t×Àb¿'®~Ðx">¡ aSƒ<¦ (Q4"ãJ•Ö¶B5ÔT<6縎ü/éeä{§ôÔB–Mñb Á•Ù RådÂQƒõxád­ãKì‰e½AKóªÄ½®â7Muo!m:o³#nè\o8æ<²RËìJÛ€Þ¢ÂÁ‘UqàK›äÖ‚©%çpl(Nlô¡è£©¦%oè||‹†SNƒ<ðIC|î˜M›[c…&mÄót¾) ¶ÚíYdFUw"jî&!½zEï|óá—oþrýñú¯ßß^ÿéݧ[/TNeIÿaƒ]1Ø œ—ÇW°äÈ—F-û»ÍôªåÞŒu@|CEŸNd™w»ÃĆ“'¬È8D‚:y‹Ô^u´ØßTø Ñ,ZÓb…RöÂ53Ð;›¢J@Þn_„OóT°ä{N÷u%|üu¥£ïîÛÊ×ÛŸßx~2Ÿñ>ßß\üùâ_õþendstream endobj 5251 0 obj<>/XObject<<>>>>>>endobj 5252 0 obj<>stream x¥YûoÜÆþ]Åâ2¢£ï}'·©áêaH£V=§(  X‘{w[ñÕ%éóõ¯ï7³Ë§H%QàÀ‘È×73ßÌÒÿ=›Š þLÅ|EÿùÑÙÄ›àIõ—ÙÓ/bµØx—øi#–So*Œ»³ÍЋú9ެYêuålþË6‹9Ì“ ¬lÈ=_®Ë£ëeyž½í{Q zÛ1=¨ÊÆÑg¤!ÒQ6džŸ/V.äÙºGÏ‹Z 'ëSÇ´uªG•‹£çMC¤£ŒÌO×—(€ßH:?_-ð–R7­ò±ž¡ ¦=/j¶"+Àf³•·ªKaPÕìrC6{Œ4D:ÊœŒ³³t~sÉ «³€õjÊÌf-uCòóùÊõ[yësÏ‹Z 1޾ä *çn‘†HGÙ+!«sˆõjÊô!Æ"í@€Éåb=/j¶¢á í›UÎÝž7 ‘~Ä8’NˆÃêb=†š2uCÒóÍì¹°Ë=Ï«ã}p±G‡YW{,ÔM¯7¨ÌBÕc¥!Ñ ´#¤À—KÇgVìy^ok Ž_ôè±~ö¼¨zaâ:‘ ê²(õiHtt ÄGgGÉ”zžWÇ{Pbw:±qÐ=z¬Ÿ=/jަáÈuY”zŒ4$:(ýe{öþv!¦±Ý‰ÍÔ[NVbµÙx‹ÕLlÌ­ V¬­¾=™¸:JC©8WÈ*S";êÜ?ˆ<ê[n¤Ÿ †ÂOâ,—q.µÓ±Î5~2ÄÑè\ )®Dj’½‘ÔÈ\$Ež9©|·ýÏÙx"ÆS²þU†…ÊD²£W‘'îrqLÌs&v‰q)£ýÊÎÅá‰ÍäFÉና2¤ûý-f?G{$ÅSÈkÎ=q[äfèWe2v;’'¬|Ú«Xi£øþûv¾Œr®ù)UÎIß$™x:‰ªÃDÀÐŽ+bŸ1òÄö b‘åFÇû¬e–TË0KÄ“"›¾Ê2x €ËÕ˜af¯W„Û¸tÒ¨XFPÿ´Ó¡ú3I:A‹õµÎ$ðN±“ë¹6; s.2M R +”ÇQ Å~¯2›jJh ý‡Ú•&Ü­¯D¨ŸŒ4Ö —ðH<ãRÑ™ˆ•ºF’(!oÔf ‹™Žt( £­ªøk¡Ï=T\‰2)U n]hÉ.î(Û\jà „Q¸ßË8ÉÉʦõÍX–DŠõ@&J“-‘‰L¥’*# ,qœüÄPýšV˜¾Lu.Cý?Ih ÿ c ‡Ü'@3¯ì4 çp$ªu¢ÆË°pöY‰SRˆìa€÷»[†Û2Í¡ ô,Z!ýª‰@T´þª¨<¿ëy[¼¨ x‘¡‡w(PAu:³v8‰Íòh9T*c&)…`qP…NíÿbS‹E2%u6_T87Åï-ð\Á7¤×²WÀ“Ì@@·Œ}‹»ÂÂ[¡Ž£Žqi¼œo¨31ruúJI›‚õv¸äŽqkØTçqQ¹‹Á¶ìV¤¤na£ÁùD˜_}“@}RvÄ[ºˆÀÚ-J&ÑM±°ÞŠOðß0ñ¸´ÓO"K•¯w'n'Wúèé’ª*W|e˜Zˆ!"L¦P¤H2Oέe)„hAÇ-4>!jÿ3OãG;Mm 5@"ç©»#&¿¹—A`¶OJr¡”ó™’Ôü$p´¡c^dr_.‡kËð¢xŽ“cì‰/S´#¿Ò’íEŘ&Y¦i´0§‡arD¥b©Ñ4H›KùÎB”VxÉ“ !›çP€-°f°ÿ6ª:vüוWá/P(—Ñ\Ë¿ÁC#¢t¶'¾s&fèæ;,XÁœvjþ¤ng®YI#!B™‰3‹‹ú€â)3`çÒ Ÿ™ˆGÑ|D…IÀØÙ12ò8ê–äèhd:X©ŠB&ŽÅ©sž]& mPíNaòÄpËNµ=È£§çdc$Ã.CÑ+ñòøº„À ùž±Ü…Bl%F:µóDÚK©‘5B†Ý>¡CGÜ­V жö-xÏ{%Ò\ö2@ãÚ¶ƒaÂn’/ѼÏeöL*þñÏ»Ï\è²BcœäXwªò¹ÚCU–Ï>I|6Ř Zþ\.±6ùUEüíáþêæúËÃ}^Ž—s æ},i1fßßNñ±Š×èñã ?ç³ÕÚm¥½s«üµò±›a‹J BëƒÊ™ù›Õ]9Ìmݸ{ÂÎ$Q ªêê­Þ^”ÿÌå×0ÀËð7˜Ó›Õºü7¶Ñ7«b;õ}!”·÷„2mF”þ»ñ­/mOˆ8 A— ÚÃvˆéôfS·FX±\%Xý1Psüÿæ:{hÌì_çÒ²¬äéÌ[OÖh‘¥·´ÛÚ¶Þ.§KüÁÚ•úÍ7I{*5ÉlŠÉ—øŠL-p­2ßè”Öúvç›…·šÍ¡|Z^Ò¢9µ5h ÍÐnCú(°ÀWcRùÝôƒ¸ûi{óùæA|øA|7ý7 ?¶ÕÓ­~3] »çr§Ù»-åtU©ú —'E7OÞJÌIYu¿an¡Ó—ƒ5¾ô¹M„“¿æ¸øAŒœ¿£ßê0+Ç„ Z²°ò¿z*öd°ÞôÓÂ`»peþª·©Ã¾Þ?\?i†öñ=WrX Û-˜U}Ã2‚¦\óÜÕ‹îåÕî\#Œ6ÒVKÌ Oj’ª.yÕPaBx5l7á`\¾âÿC½«×c)¦µ²ZV™óÊeÿ‚ÔÕˆÛ­ß?~䃢c쟣YØ7Ÿ®ïúñ_¯x{\Ðzy#Õ/>èüüéÇ//×ã9*…žŸßq(õ7‰*+?zh{q~ѽ·½­†ß%>¸®Ðwkü£×œÚ•Fñx†Œ×‰Ï—&îC‹Ôd^YŠñš&'_çÞL| þ@†©x…Å„Ò.{Ï,Ÿ)ðQΛÏ,,–SRv³=ûûÙÿäWNendstream endobj 5253 0 obj<>/XObject<<>>>>>>endobj 5254 0 obj<>stream xXmoãÆþî_1¸¶¨±h‰Ô‹¢[N\\|¨­¢(` XS+‰9Šä-IëôïûÌ,)‘ÔÒH‚\ç™÷g^è¯cá¿13þî.FÞ”ã_fÃ?Ð|$Þ?^“Ñ´æ—4»žx7BOkúÜÉÅ8 Ì[Šü›kÈZ¾?…Ú£ Ër)›úAý¦LG]ŸBŸÝÀ ¶Ü ÅÁ8 ¸B±þvlWn9”U¡88M™Žº>„>ô„â`œœ¡ˆWÛ•[eU(NS¦£®Ï¡ûó søG< 0ã$ÐÅ ˆS¾?óf'|õªªÜuiˆt”½b¿º*cCMWÆD¤¨$­j#ăVÆŒ“@[Q–ãPU¹ëà4DÜ“H:!ö««2æ0Ô”é¨ë ”éÓÙØ› &2ÜÄgã$ÐÎØ;¶-˥̆ââ4e¡X‘¶âY0©Béê`œÚŠÞ±]±ʪPœ¦Œ+i{ žo¼‰kOŒ“@Ÿ"}4ñ§C ½OÑ9}r}ãù..°ô>Eú|ÒcÀÁBïSä Oo<\hŠÎNœ8b@è}ŠôɤZ÷]†zŸ"Ý¿v(C ½O‘ƒ>z 8b@è}ŠÎéÁÌGþ¹Óqk:¹lÀÒÛŠdœMÄrg ǥʶ­‹Óé(³2µÇ%çRg'‡‹Ót¡39~\^\ÝOh<¢åš0¾ƒkœœ×ÞdæÓr…lpÅ.ÃÁ.Ø•EI¢vúãò× Ö8Ç0WƒG½'fPº¦b«)J²² e6åN'…ÇÀøÍg,Vë,Ù¹Î_ÒU«a@ÌýƒŠWz­Ê¸8ó÷ÎÒéMÅeî¶Ïþ¸ës˜&oüæêG¿äŽ‹9Á½À‘ýyLßÿ~ ŠôÖ{Þ*£WË"}~ýœ§—³²uÞ¹&×ã)IZž UhN­SClH›"J6’ÚcZlŽmE*îŽh8æª n!µËâHA‡¼è”ÀÎV‡_œñˆK÷´Ôß ï“N6ŶýC¢ÿyñÈÂGž~xx^Ðâeð!/ iJqšl> nZ<Þ½ü-;R¨Ð‡vñ]ñø‚iB*-‹.Nmb mG;xZÜ~~º³Äº,ZG:^!zÕTæz%%1º(M‚Šðëá1è e±¶)Ï=Zn£œT†Bèœu½ÖuTLp=ÒJZÝ/x»Uå[Çl—Ár”ˆ þ©¶ öÕ­*Lt;Kйl4T…¶_m`b+/´ZqæUËÇó~k›Ã›ºg8c!ÀÜ‚’Ñžµ¯]9gÖåî‘­óà° ÍoÊôk~Çiˆ¶œîÂpm´FQY·{LØqgvH`B _.!3îãkîp–A¹ò´4!ƒ‹ ¸¸“#K2Q|°€î¦:><É3mBé²Xàœ2i‰"ó"çjर²õ9:øËZ+ž‘•h vßfFmv²êµ©†XŽF0J…Ê¿P™ÙS„cã0½¥W¼ÊTQh“ä(/ 6xœì—‡šc6ß•f(B‚=QŸ /-üσíbô×ãL¯°Ñ°™¦.K“7²þ¦¸–\=0[®,,+¿ÚÉ÷Fpźª¼ ÚÙ^r€Ó×2úwÛh?8Ãýšc¦æëìÀ|*Ö_á íT‡´¤P%–ð')K)ãRN¹=®Û¶7®^äy_òÌf7Òrà ðGaÛ¯¢ó`Ÿ>šaðá¯+Š#lXPe‘îð-QÍÁzK2šä”åÐç×_uøÎ¼Óa¬ªÉKâö»ï”<Ç`² 6ØAÕçÿ¹¸íBºZû-+×’Í)ò8¨TuM¨+)§mh›p{ YùG! )3i‡!2l•23Ñ¢ý€»‡‹ž)|5¡- Ú#–}ßH FØ gè @®¹Òï¼:1q×e|Im?m¯îë5éã÷ZÓŸqS|7ûlb\KC¿L¸KCùOØïaýz8ç%[Ý*czàgÛ¥ö#A”éhæÕçöd곂Åòâ_ÿæn>endstream endobj 5255 0 obj<>/XObject<<>>>>>>endobj 5256 0 obj<>stream xXOÛHýŸO1BBr«bB”KÅI4$m$~]âÞ]¥H§ÅÞ$¾:Þt½&P¿û½Ùµ`àPŒíÝ™7oÞìò}çø9¤Ö ÿ†³ÁNÃoàaõ¥'tÐû›Œ1öäô”‚ȾoPzÍ÷þ‘DýÙ\i“½ þÝ9èÑ!Þñèý&¿ "ï6–¡ÌHéJEy"ö[ªHÒ\«û8’Ý-É,çr&æÍÄoS#â”ð25ñ8–:£±V3+-ãIJ3^Gf>õÇd¦²œMÎe]ðf­…ó8Åz÷O¼ã "+ÖgÝ%bJo÷JŸ2çzžÅéÄšçihb•ÖW¹jÕñ‡S¡e5¬¯·T¹5’a‚1=xν½—‘·»L;¶ïŽÞó–ö¬Á½Ÿ5;>S™ZOhý¬M¢8#gɉ-Ä[ü[wª¾Há:'­nt3İšg°( %Rd†TJŸ¾d²>ÿµ°°K+,®–0lB¾2:ÒfÌ8dNO*áLš–©˜!çp'ýž‹„Y ll®TÊò9‚ŒüÂnÓÒ¿ox@˜Ïî`YÍÀVE"Š<.AÂ3)Â)͹Vž” ˆn‘Ù\†±H’%#5ÎZpv:6ÌljL¥I¹(ŠFéGp­Ø€DËÏ °«:Jâ;-ôÒ§r%0$UI ÿÂ2|ËÖx25t'ñkŒÔpr\"å‘E±–¡I–mljú-…&«BÓoµpy{qšImF¨S-qjÆàóÞCé1j8òúW·7ƒÀ%êã7%ÕKyÚ·‹û''ïy¢Õ¦cêþåœës»<]•¢TèQFÙœ"¹ʲø.KN‰HIåfžƒ˜¸¡²òÛ$+#3ž.·$ɡõ?‘˜åŽURBØÓ"ûñGe‚ ¼Y@&9)•J½§Ðy›&nI.\?HY”›a—‘÷».º²z6QÙTåID…Ü×§n4 t¾¤¾mZ•æWËb¨lZ"®÷îýæIU'( 1›'E×)'qq-›SîÔÄö6ð;éœ1úrU1¬wKÇ©´Mig…3âˆÝ ´ò‰U4/é$çû±&×ÜÂ?Km)cIn½By= W”®€M…¬{˜&’™BŸìä ˆÒ(üvÔe9RÔÜ,ET~FÞ[ÚÓ2w2!*Û4ÂYì&ÐV7¬ «q‘‹<1ôÖ%ì W)óË Ñíà¦Ó½ø2èÒ5¯ÄŸ‘7èž_Ü\_~-üÈŒ.þjó5èþðµ}ÆßD»»îJ¥*¬5;Å{á°œÿP°p*ÃomG­ç]Åܶõr 3ŽË•==tÒY™¢"*¢ÎÍõ0xò”HèÉ¡ÅìŒv×î‡uÇÜß<ë Wá­ÜÅdT$rü,¤Dž6›nØ:~ˆØ?™ºf~»i-ͽÐ/vñý²Ä÷Z#ÍÂTûq't¢˜8Emt;7ƒ‹Z\›x”'©MPAÜ2­_@ÜY-¾ó4þq+ îmËUëßZBŸµF®[Çíÿµn å3Xïœ.ú×ç—›ª<î^_<}ÿ±û©½CÁà놧EÚQõþÈÉGo˜fµ¬ÑÚI^æQ¿G¡)Ó‰™Ž<®&l“~·gœÏÝë—Ìp­¿Æ¹â¦.ެ>F)JT:AïyŠ#Y‚¸1Í«™°¹ã ÅÇQaðãWp #,|W2Ë–ú¦±`2ï°$®Ím.º’ðWä,³ÕQóåШÀ.Ó°ÉÚž+DÀ›«×øZ\ññÌú·’œíVX—_i”¨:Ãy;pl&Ï[ùFÄé=Î<•‘½ÈŠZÅ÷¸&/m!ôN‹óùáé‘Ü:Æ¿qµGÞï7ý](˜pú¼ÿàx°½w£÷ß»FúôŸÇ¿Õd$"ïè¸Å³ºÁÎ;ÿt­º—endstream endobj 5257 0 obj<>/XObject<<>>>>/Annots 2518 0 R>>endobj 5258 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ÂØÄÅAatv®ñ8Ñçe•é^¥EnýÙò–Žíz.Y~`/á¬Þ©´”êIìŒ0HìF°´×AÈÎÇó7™×Dˆêï»â[CP ?§6æCӊ࡟˜P·óYVÄõNx?õðf&Mô4¼Þ& ×'Ÿ•ŠÙŽe^(SR瑎ã œæ$hÎüæòâ·›CBæT ¤¬’Ð*ûH™3«ó¼ÔÒ¦ÍCZýbTä (‰ÝŽP„u&uq<§êfE­fÚ…>÷Æï4vuœæ÷V[§"᳋CÛyÊg%gÿà-œ,r¹=µésB™.MŽ g+öCcæ ÜrgÈië°ó1«+5æíAñA¨·Œ”fa½¶Cgýý ð~l@lå8€‡fÔy%$z=›ézúóŠx³g·óft¦µQÿ0Se-g£•à„Øs+§Ù"×¢|äL—â5¦d™ˆHbNa# ¶PQ:¾ƒó?¿Üþ|uiÛD#\DÏ)êyTm&ò®”vñpÕ6“A?À™Ô.ò]zW¢Þ‡VÿGèþ‡Yæ%‰z~=úÛ½ŒtÇá¡€¹Ù¨Rއ%…^A’ôÛeéÖ^bÊ!¨Äò”1 WQõPÔ;tÜhîǘX Š’vJ2n³8†pÆH̤Œ^7¾¢$,ÉïJ4¤™!qÍ+¥M¾@±\|Á” |oGíE©ôÊâ¹²ÊßbUcª š¶¥)O#‰ñŽÀ3¡ôxŠk[륨‘SÓt³à­ž‘;Ócc˜´®ý2o¿ /‹¢Rû²ÐŽ·”¤(¼† 4§©}K¤6ï–­‹§žko|н€ü> ¡ñºÑ‘Zú;šEÄë^´o/¼}´{@ÖRcóË$Sïé,BO2¾õ_»Üœüqò˜±¹7endstream endobj 5259 0 obj<>/XObject<<>>>>/Annots 2522 0 R>>endobj 5260 0 obj<>stream x­V]oâF}çW\%ÙÖ‰ÀØ iš‡4KV•ºiº¡­*YBƒ=€7öŒ;c'dWíoï½3ì ÝTUI1¾ßç̹þ³ãƒ‡?> BúóŽçzø ½ùôöá]gº„£Ð@cÏÖÜw—9œ[÷—9øƒ‰;i8ڠá ÒGh.(hã=Ï7nZÇA`ÏÝsÍ…qÜ_RFŸ2înþ0kôfT+èßœƒ?ÆX³%Ž!œî8€YbàÁ,v‚ Üÿþã;`"÷Ÿîã5Ïyÿ‹xy:û؈h¦e"±fЇóì#w8 1¢s­8+S±t©ª¸¬×í8ûÊüI¨7v & áÚö‡yɺçSÎ}š¾aôÙvü_M7%W‚eȸʹ(±I)þKÂþÍv~½`‚èö‚!u2[§4),ĤBC*–Rå&à÷„Ô·hV…T%È%X¤º`̲ì„|ÀôL—Š44"{ (±IŠŸ>|¸}¹•êN&TíÔëñ,YÌa™fü;›Êƒ‰%\@.HäÒ/qúgðe*80ÈY¬$ åzKˆ ƒ°Í³¾,‚lHñ¦v[#G3>/J9³?î¦ÝÛ«÷Óè´m[>âäáLÂ¥™ñü–?ÝþÞ(™ßQ¿ 'gþÜïÇ­ÄÇ©ˆ³ tTïLw}TXM:¨ì@qÒ%RMÀ÷@:õPDìij¸@¸žñ¨âòÇM$€+%U(%m9Ztfo«—òA´®ý¼¶˜´å  .ãòÒÖÑê²Ç-ÏPUÛ*¹6, 5%qÏež c$+)HÎÈÔ[«Qn´mÑówXïž~Œüyî`ì½^y yøœا¥áhDmOg_:ÿ\³}endstream endobj 5261 0 obj<>/XObject<<>>>>/Annots 2527 0 R>>endobj 5262 0 obj<>stream x¥WmoÛ6þž_qsÄi#Ù–'í°]š2ô%.ºaÞ Z¢m6’芒wØßs$¥Dnú©H Xâ‘w÷ÜÝsÇ/{êão@Ã1ÿÇÙ^?ìã ?üx¹7„'4èŸà™Ñð4ú—”nö¼ft<Ÿ?XFá Ù8Z;›QyœV‰¤N}Ú²Óد}qÛa(ÁÎrÚå_ùôðg–þ®s“¥$#Q:§™Lõ†*£ò•ø.fzíü5¤ ABäôæ†þ LÄK•Ë#šU¥]ih3Tj‚U˜+ üÐx,d. ‘†ôÆm>¢TÍJ­SœY;±ã¬Ò~ß,U¼¤¸¢”†¥ Q(iŽÈ-ðɹÈdBa²Åê{ ûB£ÙRm¿T¹ºãº€lšòÂG•'zcB‡ÊÃLyÁ}2µ  ûjâ¥Ì$‰ŒS(nÇ-Tµ.r´ˆc ðŸ # tÞðþWLOh® ¤Ñ0 fª$=û,cD ùBÓn£p×yºîè© ’-PШ§:C,,´?AHn%A¢¤IxL·»§X·YŠòaß rº$ 9ů-ÉZM|¯âÑõe½þiSˆU?*¤¾1üiKnŸ²¯ð/ˆöÙèôgÂâXg+†ó‡­8cÈs®__\¿º¼ù¥\‡¤Þ‹Ž??MÚÖ¶0tÊ4”…a(ò6ç·ÀsGC¾@ÒÁ´»BZ/MY°AÓî¬RiðGêx›“urQªµì@ÀlM)³À%ü60ÕŒ…§‡üwÐRÕìï¹Ý=5<¨JmîzÃl‡ (»MTAÁª†*y|Ü˸âHyWÊܲ‚7‡k[ ȶU "l„(­ïöóq…=ƒOƸRÞ=Ó—_ëóG™âT¦ úýë+Ïõ(ŒÂý5Ìþ>¢3½Új±,i<=Dè@éàö·×ò;®òØR@Ó^Bº_*vi¨Ö˜ÎNí±Ó+ï, ¢~ËÌ—ôÏëÖ‡}’ñRÓÁUI]ÜšŸlH¿KÌ7죧U=wýGšÒv4Ù 1gN–` ÏÍ4YJiȵ‹*^ ©Æ ®pt-AéUɬ¿YJP?çfÍû8‰=è] NëÎx‚fl¹n¡§ºÕºmòZ0°T~5§­®h#Ђ Ú“'òÇÓ©§Ñi—k‰%W…ž‰Yº¥DOPYp+[颴G€“¬Xˇ6%;ojÄ­Ðli­ÐÙ“)ƒÅ骴ZÐ@R y,„ŵ´¹P)¥h?ÅôÐwŠ6ÎÍïàbóÁ ‚»prMQì.ðÏ4„…VÆ|ÒŸº:€I ¹Äö‹äse\§µÌ3OÅÂvÛBιñi[³¾R[ÜdtËÓ.ãQJýwˆlðÊýݳ¤¸IçG$ AýÔ fUZ*Œ6ôìYšÌÉo-‚Ç?€Ù™múÖP:£.¶N£åÍ"Qx—Üܼf™n7ž”2iÁæèÈˎǘ-\ cO¼æÒ8à׆ÂBz5GÞÀ«Á~þîÃÕûsëX.7~§ó¬á–‡‡–‡MD—jßKD…%‰z–c‚‰˜&/Üœ ßßÏg—g´ÅL,dë4µái)|t½½Ùº5ÌÄ^ßZÎ,‘@~DÏdÉ­0Pë"yìI®?&3S*'ã„ç%²38—†®? Bšk i:C2ÚÔTå£@}S±¸eŒÐ3켊;G0êókÒøòp<à`Šúˆ«L業vêž±ù–0 OOyÓDFëvûöƒ+I÷Œ^½½j¯Õו®uЎʉ4q¡-ƒóï#‘¡uˆ\™ÌÊŠÄRu2ãb’ •·Íe0ÛJíuŒ ârn/5öÔ}ÑwµzÁéB‚õÚ—:Ÿ¼–¨ÍÊÈy•Z³9«¶F\Öª§ËzÚ´´–ÊÌpU0ÍÉ<Öß«|Àê.õGáñð˜ÆÑq9tq ¢°O¯w£Æî„ƒw—Cô"ºAï€b?^°ŸÇýqˆ¡Üö®Ññ˜?OöÞíýï}endstream endobj 5263 0 obj<>/XObject<<>>>>/Annots 2563 0 R>>endobj 5264 0 obj<>stream xÅYÛŽÛF}Ÿ¯è·ÈIæ]ÒãîÄ6 ذ7£ÀX`€€"[c^´¼ŒFŸSU$»9ž¬Ç—xgfŽëÒUÕÕÕÔ¯\åà?WùýKŠ+géàúáÒ__]ùÑÒQQ-}U¨õ¿äêæjå̹N´ zD¤ åúÁ2´Xõ=uƒåZEŒXÔÂõ6$jX ƒ åÆbE±çˆ¿«e¤"¤wm ]V;’6&µ¼¶‘µÎšÕnB2É€ÔZÔFË•EÚl°YzËjÃD×õȦ ƒ…!¹Pl±»ZOY Êó¦²6LíÚlä!üÆ.D¸–¤‡.,€<¶`¡6.’j8 Â]ßA±ÒÆ´ÔlX‰~r RCcNBÐ[“àHÚ˜ÔºdtdñÂI©l6ä-Ž=² 2„»¾Kz1kaè 7SÖÂ`WRnÉZ,ì§Q³ø„ÓRÁA’å“×ï7þ‘àÑ'ÊOƒ,|Àj kadÜYQ-¬Áb'##ëJ¤Ü~+£@–{eax… @Ö°&»ë kc²RY±ëHúú 1²24°Oë5¬…%C–5ë>÷x6R‚dECvíÀ+‹µ0Ø EÃb-Lë¥hÖÆ´Þ*Ãb- 6 Pska°ëëµX ƒÝø¨+‹µp¡|—êÕ°6ëMe¹^ƒÕx<À')œD(Ð̰œ‘”² à6Uºë±ÃŒ8ÈúxJžeÖÂ`yCY¬…Á¢;#AF³…)Èþ”•Ô£ù^aŒ¯L^9K×f- åƒ0YÑôåŠg‘ F²"ƒ!±Ï†µ0|FÙÀ Êf´>öÙ§Æ0b͆æ•K>¬¤G‹:!…™‹Z¢¨?¸l±lÈé¸$ˈe- YTØ„e—ýMf%H‚a0dQFÍZ˜4o°Ã,Y #TXèÚfÅ.ö(¯—}ôŸCsIJ†µ0%!"Ÿ +šñŒh¦b÷‰fƒ¡›À±Y š¬hî'0 °^F¢Ù`ò™úœÅZ˜4OYZƒß? µ0 Òlcì{¬ÍÚ¸è‹Ñ²+>“!Ö‚õ2bŸ-L^Q'³X‘FÃU@²fø³0dÑ« kX‘í§?õÙq†³1dQYÞ >pQæH #½áÄëa` {Ĭ…©E†hë”d_kc°1MŒÍ3«ž"<¡2`Î@ò׃àÈýkk ë<±×õü%©†Ýís}´ö–+OmSžèµMfÞFÝ|xýJÅeªÞ%q‘?ÛþaéᡟõÊ…Àž® ¬'#虽¯užY×™nH”h—LÌ~íÊ2+¬~ªÔ8ç®{­ äÍñá"o½ÐQS‰OÝç{S×UqÊr2ÖµJªTOÅ¿»Á-™A°N*ª´Ëÿn{¿5´¸KÕÕ?Æž4n³ªT§ºÚåºh¸D’1Òç¬=ªëŸþºH/pÌ:t+’„G«Ï&|…cjÁÅ;£èçÕy‘ë;KÕ>¿VYÙêz'œ S†ôðA—ºŽ[þ˜è½(»âÁf T{9Q³ò±öXbÞ ú=á²'8½CìiÞb_²S¼€BýϺŽ/|»ÉŠS®É;ݨj¯vUW¦ˆU<>˾™ÜÌÖ}ÄKóì§;—·6n®ï¹´ºò– —ªÚý¡“öóEü ‹|q.â“ÚWµŠÕ¾+Þ_mü‘ªbŸWq«þÁ¡@)•G}që/m£²±›Õu7ÍÃV~³}£î&rçDÓÖäq¿®¯òôÉ2¸ôc¬ÝÎ-yû[×w#¥q£›½ö«L}cÒÉjÉ죙Ù×e[ã¤ã’ý*7Ÿšñwwº®³” ì­nUÚ|[Ã|ªÝq¥¿5ñAÿ˜r«5ŽX,4r ݈û³ñ›ÿú~=w‹>6Ôp,7sJêó—xÍËSÞS/½ Æ‘1<’•óÑѪk ˆëðç‹ÂÅíq>8ÏÌ2ÍI18aŸÆ qtGg|na=Ÿ·ÿÄþ¿¬÷ë|þòÿcÞDú{yÐ7 ó_2Nàm Ç‹ûDŸè{BÍ>6â÷s ·êèA³¼_Ê>¾{€¹í1kTrŒOõTª›¤ÎvZèóS£šîtªê–f¾Ê,å—‚L¬pQÁfÃÀxÁŸ‰.[§i&'pÅ÷†·oÔ>.²ü2—CX¤&r‘ œ¶bÃKõº…q:1T8eHÖéœk3Uy\:j*Øi²«ÓÁ·cܨs–’[qò±¬Î¹N¾vY÷Y+»T—‡¬Ôºnæ`›6¿LüHuu¥j_WÚT'D©ÍxiªSÍ¥iu1[´YûËQ'èžû‹KýŒ}â+^ ñ‹êR|¿Â7‘®ú䥈ig^žà«Mî\ô’ô\Õ© ùV¸œ¤xWÝaç¼Â’JŽmr¬²DË‚šcÕåœH¦ÐÞtÓb8q]§v§ã²[Ä…-ÉÒ¬×CZ¨í4€<‡}þ&+»{lˆûu4ÿþz~ƒ“Ü>“x9œQ·xêrˆÒèÃ-×-Ê(ÕèÏh(ä#f8ôj~u!m ¥ý‰5cÿO¶‹ ÞäPŒó·”+ù¶h:d:©_¡#áOŠ­n©þÓ§8¥fŽ­†-S÷o Èˆmfµî~B˜³œ;(™æ€ÕU%SͨaA«ÞÓ”•vÎïÄеfõ0´¿Ç!  œé¥Ä¡“ ¹•ÜogDwM‡Ž´Èïïq9>Ädi*´BP˦š4'Ç+]§ê¦­òún ,8ýÓäì—}0ùˆ®8}`7gJ[Ñ‹®ß7©uL>ù=9ÐeëƒÆa…º ï÷HáÄÝþªØ<‹Ø«PYu¬Î}ïáÔ“ †$Aê• šWNP\•©Ãô>!rI§xW%ÎR«ž'ŽŒµ¦µë~+o!±;雇u¿•Åò‡“JŠBzCîÉ „+úèÅöêßWF)JÎendstream endobj 5265 0 obj<>/XObject<<>>>>>>endobj 5266 0 obj<>stream x­WmoãDþÞ_1Š„šÓ%Û¼7Á •@®!Šz›õ&Yêx}öºIùõ<³k»±ëpBB×kïÎû3ÏŒ?^Œi„cš.øGí/Fb„'õ¯lË_h<‰%MF±Â÷%eš6|•Æã¹¸öð¡|Îׯ'/-U¥ˆ·2/ÅâÅÊymóñ î|ʃ–º³.ðÁõ¢´<]5ƒé8¨ïw‡âóÒ²BéÐ"é88‘hé:gžŸ/ÆeíštÔ÷;Ãð.µ,Ÿ:T…(:N$ZºÎYççÓ™˜{L®›Åè8¨ïwFá]jY>u¨ QtœH´t}}wqõHœÐÝÝ´X.é.‚ë#´ÒêOVbŒ†ø¥H“léýo·ß½¹û "3ã‹ '31ƒPÿn§i-s£r²ÚjçXDz!úIÉ}L{±¦"%™D”•Z•Lh­)×:¡Mf÷dÍ*ØÚeNú(÷)¤~”zcbh]829É8·ìœà¢~¤s•™µŽh§3-èÎ⪉#˜kx0`ÛÁ±"g/||`ý¡e—›ÑöÉ¦ÎØDTw—bÊY˜p&b:Å·¨ÿY~0[ ò•÷Â45 Yd:‹ÅuÈÂ9˜8¦4CŽ”¦)ùX\ãmÿÊ´<2™ ÕÔÞ'e'MÂ9Š9—à žFš­#dÈÉÍIÖ Äzëô†ò èÙÁYe÷)»ÆÚÿ»ãví¨|Ò_Ec³Î{(F;nD¥2-]ð© UXï ß+ÇùhDwL¦ó"öø€-ƒM( I”JÇñÀ?l}"cŠMòˆÌ ¬¡*r(ß÷몔oG"yÒþæý›G/ý7œ,¾í&tãÓ[á“‹× —QwÒ|?Ýpq×T–ØæÝÇ _5NOY3Y]ºï­5òß¾MCýû7hÏTfHlü,è6!E†[q$·ÛLo: ê÷xZ1EM‘(¾/cãž>gl§r¢Æ+C)’NRî²B¹ãÚí¤C)‚ЉËéæêæí[z’q¡sîϱ=€*@?:+åw2c‡ÖÚÀ,R çdÐK(ËÞÂÄø¿6‰Ž@2ZÉ"@rÏ©§$-Õ.ð𴀡ԃ]ÿÅ„é Å‹qxÂ=¸ÚÍa¡;Ùo_3N¤òµ^p$yÒYޔ唢•A|yŒÌ•èã¿[óTŽ–Al2`Èó0DÊR­©$"Œ _óLUÙëJý-Xb D‘…àLât¶‘ ¶Ø<êÏ+Äuó'èPYÿÝ7ࣗ“ªº nð/…Є§’¯ž*j¡ÞðöªÈ³+“¨¸ˆôÕÆÚ^Åç'´Ë‰{e·dgvú¬™—;U:Âèi͆îz0è X»P3¨Ñô9íÐù(úÔøy’' W€ÐÄ2Ž" ^`‚b!’k‹¹*Ôñ8Ào5à¾*Mƒòå–»V'yä“<ÙG ß$Ä͉ÖÐaNìÁƒŸ*·J[i=_=#®3×B”Ú—lxT°ÞÇã+YH„”WÌëS>›WãØó/f9¸ˆ—€tVöz:³û4n‚øÄéŒçÇð+C|Q{ *­É,gün“éCfÐ!H°Ãì±ê€çŠŸØëX£°ž¢r <ø¯°å·z§ »âEAÕÅ4†"…åEbrñ¥…ö”[…%#Ç7ô§Ÿã¾¢õ¾¤LÊ?˜õ•‡"E'ÊÙì¹Z,^‘}©*2 q[¼2ùáË«žÚiõÈHsÌÜÞ\×&Ðë"ŸÏ^³ ý :ßÙ›^5Þê•„uWL׫(á–>”Õá™þ@CÀþ2<³ ß}t¨×>>üøƒÌ¾¬(¦Ë/`uÒ\Œ±ÜK /³åJF×ÍŠ¬ÚmbþFýtÆÛZ3úZê#O¿0 x ÃS¨÷ÄkWØg±Ìਠ8¢õ³çäPõ2îGˆˆ•:ج\g¶:Ñ<ü£›cgw°´®å:~F É¥#l˜ØPPyÕðD&Ϩ<&³Žsíû°ÎÔ÷ȽŸÂ\½=g 4ßÎðæ—L2/—ôåJŒV3äy.æS~séß&iá— ºy<Æû=?ýÅ·Wˆª ì౸ž€Ãçbtí·¯Íå}Ÿ˜TЪ˜²¦¹;Hg .ôF=ÛŒÕ ™–| 'Æáttÿ†ø½k„Wª€ƒÍ}ÿæ!FOÐ^ýŸgõƒ=ê›7ÜDH,‹›M“MÔqã®w®râ$ÂÀÌK{ív6‚xð©×>u÷ý@íd`¿dz§69[Ÿ´Çº¯Þ-ª,ºÄ¢eÓð´âÔ>Ê¿-öØóºRO—o¿¤õ©!íN¾ý²÷oªj Éñe¯öêݲz±«ÑŠ×c±Zxd1É QNúÆ*ï ö]ë¡á÷ý霆×a8óÖ<-Ät9›/9Œoï.~¾øoYgQendstream endobj 5267 0 obj<>/XObject<<>>>>>>endobj 5268 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ÖÀvü¢ ý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£)«ýå×÷àóƒþ¬’†×‘ÝiØw܃¹«o»úÐ>/XObject<<>>>>>>endobj 5270 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ê/É^©ôÃx¾¬ž¯~ÿ|o•}Åù[ÿ ¯œý×uf”MLµÊôóU'/©²´¦´©òšI |ö/†ë¼å,tY àôæÈyýÚ/“¢`l™éâ„_EXÛøíÿ—n'ê1UAXÔ±'¿/õ†G®ùkÚmÓxK±)¼J¥îã̸ SÎ&}á|æÚoMB*޵ûyå=šÞcfMo¹À¿Ñ±‚rY“=ñûL_CfY®JŠ6ˆpîéc 1ÂË?©§*¼£µ596­«"ö©)Ð…™*„ ƒ0XH M±ŠƒÚYŽ™ùk²½ãŠŽ.Ôý‹á—ÕEp,¯2œOßYÑ8“º=ÂL› W+W›³ïAª™£•KËÀœ /»-¤É±£­za2"5C}ª²÷š\…rÅ"|¨O{c]È‹ÁA)þ ÞC‡“$åÁQÆë’ºq×;ƒHÔè’ÉíÓ"æb£¹²„»âJ“@”f€#EÀ%Œ¡ÀÄ,ý(c÷‚TH%BQ:²öа2(Ä”©ñ¡â1i<¶]üšô 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@ˆq1ôÀ ñ(<Äsþ«sjè £¨&0‹‡Òšýäþ€`ëùTŠæÀ‡šÑ!ÖÀ L¼"sרÖ:Å'aãòMç!Fš—4AL@á¼òiÜYô¦Œ"¡C7}  4†r¤â„Å¥ë%‚¦cšëX®Ý2éí>t¦CÇ,´NDDñVRÅ}‡ÈA˜®ÔvT*ÇP¬p8I1@ølM+´º¶¡‰ŒIç0»"°Ö¡p®@ÉW€+L6 ±k޽/ÆÒôAf9¹›wÄsÿß_FÓÏø2Åu  .XÈìÀ=NîáV# }ìá—%Õá |Ê;Çå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‘oà“Ø+,D‚œ¶LÝBc¦`O+½I‹‚ÛUM±ÇzÁP•ò¼ÒÜ$ËÍ€iÒ½C>FµÃ>AŒï¤`ÎÃ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Þ5_0'øˆ>ŸÍiqÍäc%“j4Åÿ:ùÖÄâXÅÛFÓqx{tdzHkd¨ÁÌ>ÊМ²ÐJoä›^ÐÞ8/¢¾–óžÛŘ½}:ûóÙ˱endstream endobj 5271 0 obj<>/XObject<<>>>>>>endobj 5272 0 obj<>stream x•WkoÛ6ýž_qÑ®¨3XŠ_qÒ°vÍÐOÅPð MQ6‰ÔD*ޱõ¿ï\R¶%oź8ˆmŠ÷}Î!óÇÙ˜Fxi:ç_Yž½YœÒê5]ÜŒè:Ò"§Éˆæ/Æé|~E‹,ìÑB”iJ’K~[ú]¥èOôšÆCZ IâÓlHÞ®éó«óŧ³%cfƒgŸ{_ÿ¯Ÿ‹›±£œd–L¦mfƒÅF‘m|Õx* MÒ/´q/9Z¿œd2I§S— BæÝ*^Óo½ôˆîsoìÖô–ÿ¢»ŽUïÑï½o½b†üÿ6žlNxëY"„8]X.ÈÓ…¬·ÐÏåAeém[ozÉwüˆð&—võ©ç…íâœí’7u*?>°ågôÑ’öÏUÖ9½*yK™%¿Ñÿ1§•p›d’Ž.Å7d¥(‹òÞÛŠÙ8oË6;åür[‹*µÇ…T––’Ϊ¯zÕu]§±NöÄþ{©ýù°ú¤¤×ŠÞ"zPµÓÖÐ4ÍÚý&°õ”l¥ ½ GzÕ'ÂS*”§G@âmœÇ8ݤ—Gi˜Nפ—âÓÞœº…›“ðÉüò„Ç'^»¨éy}­×@ó»×‹›ÿÎàÉ‹t‚×8”K`Ž6k ’>ðÀ9£#®˜ù3nr`=?§¿¼ÿ‘J›5€øJáÈ5UekO¹­©°"c‡ÂdÔ8þT6…×¶wL <*r¢"6à. È‹»€Ö(¥,Œ B¾ân£\ѱߟYÜÈB4XDGO;tf­ŒªEQìPBQQpÎa:$ÂþRT¼ˆfœ Žm•Âljî7Ôà³î¡gÛÈ!õX17œðQ·¹²¶Í+£Û£M-eÑðÒjG™Ê¨t{›Ì†¡¼L;_kX¡×‡êßìZ<ž'2Ôê'CN.–¹†4 ¾6æÔ&˜²QE6ËZ¼û¸ÀôN)ºFåJ8]ìÚãú.‡tž•â^-]˜ã2X‡+ š²ŸÞt}aw¬è[±ãôúÉŽ[=¶Èü7‰ˆÄaö™öFÂ]æC‘¬á¹Ûú¾SÓÐ:µ÷Òlv•’:×*;¢»_l‹Û ½ ªòÑ|j6 ™o Z^@òš«àª²8-X,€½ç¼lQ™q½â eHµEvè"`Ęì•ÐËØf“%ЄL3‚z âæ6,ŸpÉ4;ƒgZBnR‚ 0Ká”âæ¡…Œ ~Yªi•®Ó£#xÎÁ&D A! q·çÃàŠ…Ö±5¸Rh©7¶ }…2khüí€mèÛUÃJ‡¸ˆ‚GìcϯƒNA…[‹*LGÃd>/XObject<<>>>>>>endobj 5274 0 obj<>stream x•W[sÚF~÷¯8Cì; ƒ¸;IJ’ŽŸ:MÜÉCÈ0‹´˜M„VÙ•lÓ¦ýíýÎƒÛ)ö€¤=×ï\õõ¤Küu©7äÿd}Ò‰Æ#Ú}™[Ü€`2ˆFÔ›L"ö†QŒ¤%ˆ;`ß~âA/ YÒ–”Ýa4qºƒú¹—yì„õúçOŠ:rzAm<ä+g§Wrôˆµøƒ'…;胖ǞÄGNœ÷üIQG<æ `ÿ‘#ÇNXÇ.J{Àÿ|srùvBÝÝ,êá© .’f<‰â¨‡€þnU~K"'½ø,“òüæ3øú[¾vÜ_óºüÑR¡­U‹LR©©²’¦ÏŸóåFW†Dz'òRÜJZl(1R”N,Yµ.Àá…S¹%Fß©TZI"­Ý‰0Fl"ºY)Kk±¡…¤µ6’-êP»³`SF° *'«×’a¥mAOžÀ°ÕVU—‚&Zè*O-%+™|Y-’eµjkäÌKœaWÒFAŸ÷{ªs [ Ýå=ª¢û•ÌB™§ìk¢ñ[* ‚eÀ„"x“háVVÉŠ„z#¿VÊÈ”,LP¹Ì¼i>»à… „˜õé̓p¨–›B®EAKвʧ¿ì%-3 ´/Ûh=Y7lu¨dî@v¹ jªÜ?¨S£IÚsÎ[øîô¶!G$“ùm¹bXøÎÓA£-d¢– ÞDK>”FP!ŒXËRšˆ~¹ áðáwø½–îU–ѽ6_Øt• “!}®CP¼dt¬™ÂgŸuqYõ÷ Ö?‡—3¯å@Ûè=àܯÖÄ•6kò¿Žêß ™Íò3@S³yagõ­æ,äö å{gÍPÃû°õã‘—tzÑ»\¹¸<°ƒÝ8'ÜÜEt¬fÍS•UyÌëÓ.ÈA°•8;_£‚tÌ êeø‡ÔËm4Ùƒ#à}¢Óø?"tÚå@SS]¡ÿÏïD6kîÙž—«Úö–šS\cíñ©ïþgJºdØ+¨ª¤ÏUÒÇ/*'m¾÷Íù]:f‡¶%µ%®Kêé]âÆáO/3íÍ÷ŠÈO}œèã7šÎ=ÔÅðbwÛ;¼DC|èÛ'Äâ‘t0ºÅ_xâNç OÚtÌ‹’9Æ8Â0s3•Û00˜¹]¸~ÒÆ^w ƒ›V}·$L3îpÖsÔ3=îGn»àE"ñ4è¼™Æðr=Ù–¦J0šy‚U9F+.1SÐg䉉¦‰mcêÌš5Aͽ²ýyCë ¸~oDQ€:É´­À·r¬0~/q–mw 4ÏR … ÂZé”2eK?„k»<Ûräþ=wõ5ï0XW°1õ¿Ù}àM!4y*¸ŸÛ<0¡y•*4¤±­{·í@ô†RykZ)øj*ð]Ý®X·2Ôø¡L…_oî¤ÙÔ–o×:ZaÆbjìCÇS—haby“±êyÏáµËà ¼à 5a$È` 9ciÛÎ3þJ$Lº–iØà…ÈqË ç¾¥6nü{Ý´V·«æÞAW"‹Ä¢RÖ£stÎ$²!,y.Þ¸þå …‚È„uØb’”CoÅÖU§0· rw77øùx„db{F:¿–¶ ½©LÑ$œ÷Ñ ǼïdY€€ÕÐ`WÀg:/JChbÕ^>súî)@€ÒÕåç1U¾á~§ïzI2縄ÝfÖlÊWnõ€%Àzíæy®S€m¼‘ü|›ÌÅAMV¸Mâ˜W>ìÎ ¼I2ÞmÎ2® ˆÏ6^ˆ]‰yl|@Õï‡AÚ>5ý#tœäW®{èå΄µÚöеÔJýŠ…ä¾Ão#ae×+ôŒ&4÷#lCp‹“¬Í¯º¯uâv;¼ëh—œí¸¢¦ÁÈϘ{Ëtð>{¤úØsæÍÍÉo'ÿB3‹endstream endobj 5275 0 obj<>/XObject<<>>>>>>endobj 5276 0 obj<>stream x½WmoÛ6þž_qp×ÅAcÅ’_ã¾|X–l¶u[‚õC´DÛldQ£h;éÐýö=GJŽ•¸Ý€ kƒÏÝ=÷Ü‘úý ¤6þ‡ÔéóO¼¬Ð«©ºe|³i-íÒÞ“[ÃmT.좢ª3‰É£½¢VD»´QsÅ:ôiÜô#`©æ ËS¬Lnh|„V’±@Ñ»X,÷†ädh×xn–ÌÔRJe6·‹€Þf…•"9ænD0©U ¼$‰4J† ]½²$@Ò¦,k¯‡!›¨ƒâö*V†Š ;¹hÓ0èðäl…á è ½ž»!ká¹vŰšÏÿ¨=>SYœ®I áF ÑÛ*í#ÿXÙ¿*l¨7µÅ 2-rƒ\›PÝ•ÿž[ !¢Lãæ¥k³ßœVÇG¼g4*•ûª¬½yY ÷Sõø(šGÑŸ\ô+z8‘N5ÎÝÀ-åI†rœ{þ‹Í•?AVìð¡GZþdb¨Ýcv/A™‘‡nŠ[9S(´+.fˆ?´¹÷ShÇŸfº†~Tê‡Ñ¶¿‡”zUcȊبÜlÐ11DlŽ0œhÆl9_DEVÕö3Xâ`¸åá#àxk™¢ðÈåóø¨<Ê+¢ÝûéĬä]òŠ*UºÕªÐÂ}§Ó“æT‹V´{â+ NJÔ ÜQí$T)á;#93øÀÌ2.'«_Úû"Wöl…H~°CbŸµ†C'üåFÍée¥/ær©¬ùÓÕgͽ¦Ln&»ê¤Ãq }„† ëQ%¡ žàØÇî3÷÷Õl•UíQy¿£ÖjŒü™Y4P‘§¨­§ˆ5úÎ&|Û©½¢ë³‰ŸsÔÈtÞx‰ªçB}”µh?{_{§R˜F)ÚÈWÅb2ñmm×õMíñuí ‡öÿ¬Ù~]{ÚÞöv“¹Ë—ž}sKêMšg¨8ߦÊ3­ÿˆwp°Ö*ù[À)èû?þ;ÀÃëðæ±\÷k§ÈœÃ¾Dùú5n†Ç öåÿ”óù(*¾ˆ(tY›é¸éÊË"w½äŽX‹Z´ðY—h7xN.ð¡‚Ƀ |êô:=|fôƒÁ©›s|¹æ™EßêØ]Jß_Ùe+j{ëÖÀ·¯¿aÑÙ‹tæ¿*ج×îÈtû~u~uðËÁ_£ 7Yendstream endobj 5277 0 obj<>/XObject<<>>>>>>endobj 5278 0 obj<>stream x•VéoÚHÿÎ_ñ”C!i<øäHÚJmÚl#¥ÚDAê‡eE`²Æcì1®ú¿ï{c0G”„=3¿w_3«Y`â×§I¿`Z3Y»ë¿dŒ œ–ÅÚ`;.³Àê´™ ‡‚M$_ý`¯E$n§<Ïe½eyå~Îsß 1É÷²ÚskJb­¶S²÷ˆ¤¬­ÛPøs·Ö¸5¡ÍèŽÀ6¡Ù±X³Ù‚îP›lB7¨~âDDªÏ£a("½z¯¾„³¿( xðwïüR…¨1¾ŸwŸk&’‘|(‘æúº²;’²²øÉÖúWemÀd‘Pð¤ŸWÎŽµÀÆmHâ 4ݺÝa6s1œ7ïÞÁMè§)|]úÓ8äÄ¥qëdDä’ÆßxÂÏRð!„ž£!KÑ<è&2 &yTp/‰Ÿ¼\å¼¼‚—evXÇs£Ç<§M\gЉ´r8z¨Í\ËCW9ø$ÔéT3”9SOÿ­,E„ÙÃû™Ç¡|%dÄ&¡â, 2¥vA§¿+4öÏã§5W¨ŠŽ³ÊÓæn„˜r`“¬W§Ì?—Lü..p1‡Þy5rR€¹CH¹úî‹è‡޹Bù\,ôÎëÄ|ÉJŽ*ÿßå³\ø€ù¬òì[S¡n¹Q˜ô—j¾®aÂSñ‹®Y^j½¼N’NäâQ)oé4£<²Mì,²Þ9–íÔd•Ëójå¶ÍûÀ°>ðÓ‰a3ÓóOà±ûð©ûíCãEfIc¦±¯&•„Ùd#Ù+"Hb̦¡(_ô3vq ®±#è%2ðqÃ$œhB:Št]®’kS€†ˆ/¹ d¶³yP¿y?In삱˜`±ÿ#Žá(ß“û}¾TØìX0•0ë¿÷SEïG¥dmÇA1dúÚ4l:ÆÝIîÇFY·Xßy7ØkætŽçýEâÇ,X.×ï%–†‘k+0–É-¨ þŠÅŽ.+QÕ¾½ßï¨7õ Šhàë¸é?JƨW–*9Í#J7vÃÓëU8¡Â `—Fwc@t¬ ¯aÔtÀ0 ä½\LŠìp2îËØÐ1:I?¼ÿnØÞ™â“$ðÄÓ;0iù¦²bXKZ­-»òføçà™JÌ9ÜPyÌyBÌÁaf³À罬l„Âd~ð‡u~ 2æ>/XObject<<>>>>>>endobj 5280 0 obj<>stream x…WÛnÛF}÷W ‘‰–HI–¤@sqà‡6ì"(ªBX‘KkŠ«pIËBÛï™Ù%eÅ6Ç2/3³gΜ™]}?Ñ?#J¦ü?Ýœ £Ù>ª[Ü )æd2ŽFÇÑ”*M9l‡ðî>ZÛ1°ñŒu¦'q4‘G£Iû<Ä|â,+ÏŸ õÔ vãUãQ%~í°ÆoÞÞœœ_Ži4¤›4Lç¸È$#\¤½_œk6¦¼¥½mh­î4)ÚÙê?2¥«UQ¨ÚØ’lNŸoúb¶3EAN‹©)3»£Ô–µ2%;ÕkM®®øòtmNWM]Û2:»ù 0sÅÌ žL/žGÌÚ{Sé´¶½+”sÚuÖú Gãƒ=êÔy\•ue³&e¤Þí1ÜØ©³M}tR¨o{½[›tMȹ|JÕ¦@F™¦Ú’½ÓUeøym›UaRÚèzm3Ç”(z÷êÙÕW èfmå*5…©÷>œÇÆéŠq iÀ¹g=DÆ3q.̪R•Ñl©j”ó{"9Ó•¹Ó™ÉX¶•½c(j» _·Õ©É*oJI_ÉÚ`s]ô}-HQ‡~öOS{Ìy¥6šë/µ\OÞGª³© „’²¶T-«=òášÃÈn¹ ª  JRnuÛltYSa¾1Æýäk4¤ô YƼP% î²Þ ï·èµ«¸7§£ÓÅY Æ0Š¢¡ÜŸŸÓMlj·®¼ªRÔq%¨€Ã¥‘H/r­§^ôNÛ(‡Å½‰÷Ï­¥¿ÛªŠ+Ñ–·ü÷µOš‡EŽ49Õ$šN/8 ¯ü(¦O^fÌà¯A](¡HÑx¤ç·:U,!ÎÖK¶Påm£nuË{]!'óŠE ‹Â‘rá’R”êŠ[·ÓOŸu+m^jˆ6™%Èš/tnJY±ÍZ´Ü*ÏëW†ÃZ•*ÏØŽ–fYêj#­Ã/7?õí e†ß=Y<¬Ð…¾S‘)QÎÈŸ[N? ÆÓ†¹/¼÷J½[††ZúøÇ¼ö¸Á fW³:´3ÆdT]Ó#…m¡R Ì%?[Â-tfFèΠ)±V±G9À™Í¶ÐÜ ð!Y!ãO£ã…í£ #Ί!®¼ÂFQ!³ÔN%ä;æ)¯ì†v WJ GPÚáâ½"úÍÖ\/ /D>N¤ 5”–‹pgÑ͇a‰V3ésºÈÃøoKÒ —ÿ/M ÆI¨Je„ÇêKYó2J¡ã¯Uæ"ö(ì<Âxrý#‚Ø4”²ÀT“ï)bŠyrÿ\f¿q &ÞNí#ú²Ö¥tì!žN¨¤ŒzéÚ‚õ…èÞÓ*›ÆÏs—+ZØädjìØÐœÆzÞ1óEkid»óC¹•‡ïaÃZZúh{“­ rî&«lœW¼•`è{ÅòíÓÕKôß…a¨aå¶NÆSðîÅý"ûV»;`ÒVeíÆv͵â{DÂÀ[^çÜ­Õ6€•C…4z§ª0Z“Ã!áwÇÃ1áÀç—“0FÉ<šOfÍ“h’Ìx4@K€¿6…·ïv¬Á(™Eã{FGlo·¨ÂõÎt/;‚<}°$Ó‡Âߺ&œš0 ½ôûËÃÛ®D&,RGoZ6$f N-ÜÁÒæ?¼%ü;M¹À§4øù‰—D‹ž!ÑyRN£$Æ·ôÕx:a÷7'ŸOþê31Œendstream endobj 5281 0 obj<>/XObject<<>>>>>>endobj 5282 0 obj<>stream x­XÛn#7}÷Wü²2"wt±eOy‰'ä%A0Zì«…AuSgº›²eY¿§Š©mq쑚,ÖåÔ9ÅþëbJü7¥ù‚ÊæbRÜßÑé—ÛâÄw‹âÍooŠ)Íæøå4m°v‚Ýù×`-Lœ­ ;ƒ•á“¡õ{>:ÿiyñýÇ ÝsZnhZÜÎïiq?)¦³{ZVrì„–å¨Ö==ÒôX9uxô;ÕéÇÒ>i§¶šþ±õΨv[ë1=<š¶§Å$ýk6Y]Ñû÷WËÏ8醦0·¡ëpÒõt^Ì&·8i´ÜOøéwš­z²:ìð÷h÷Ôj]Qo©²-±@•ý^ÕtYÖÊûKªôÆ´¦7¶¥Ò¶½Â‡v+–ØÃÚª ÛÝïlÅGÈr|cZY³Ù·%ïe'ðlÆî¤xå>5¸§¨¶=Õæ‹–½òôì|Oº1}ãë#}úׯ¿ŒÉl$„ÚÚ/„pô³jºZM=F|¦Ü±G[Ý"“¼í°Ó­lxƒ¨ü¾Ñ°w›‚~RÞ”ª®c±¯€•­yÂnΠr[¬o{O ?T>ÚõgR-’(é•L´ªÁB~ìm»ËNw³÷=²ÓkWê®xr¶ŸWò©²P{öåC:gŸL¥¥~Ôú½kéIÕ{ Š´r¼§1â²Ãæ÷m…¢¹„ß}‡ŠÂÀ¿rÄ™í®OÆûcôY&vœñp0uMk.–³‡6ÖñÅã}d’~T¦Þ»`é7Ûÿ¾þ¬Ë¾ ?SZ8åd᧸cKÕÔc â\§an WÎëzSÐdHæ@êH•q°oÊÀ©dhpÝt5N€å}²A¨#ÖÓÆÙ±õ;’ƒ®HÂ$nUãtUûdWNfhàˆd£œÌâLUñ×m0ZD«³nˆ_°"ÇÀ[\º‰:4JhgTHe|´ûf 8 µ; Ø:5¢ÀwB&X²ñ±ÌI)FÏásbŽØEFϲ˲VWƒ¬uÐd"`œrî8Ýÿ–’zÖ^ êHxì”u(JVí1xÆ4רŽLh~fñ `ñ¥Ó¾³m…€íÀ>øR\½7×µÚ7Ý`”9Amà Ï™déîxBÿ†hãZ6ÁЄ Áy©Ñ€çPÉišðÒÓŽó*»ïOÀÈø<¬VúO. Ø‚©KÓÏLö|$’$#{)XÊfzú·ÎÉØ,eQvµ*Ñ£›¡eøn“lY"z+’Qv}/.E(…Iiã« jÀõÅ=¢’Ö>æ)•cåÛT;®’²ÐÎaX=h\\ÔP6Ô €q ý/Ô¹‹o)lÊÀlrƒ··xûˆûÌÝ‚/&üíz†£l)¯³äŽÊâV_ßñý¤Å‹âœ>Ä*ôOÏwöŸÃ 3Þs;YóÞ `ùÍbÁ_ý¼¼øãâÔø¾endstream endobj 5283 0 obj<>/XObject<<>>>>>>endobj 5284 0 obj<>stream xmT]Û6|÷¯Ø—6NcëlÝ/÷ئ—"E ´´²™J\…ç:¿¾³ÔÇÅ@`Ù—ärfvv¿-¶´ÁgK·;}ªnñÇ~±)6Î?þH7ïïh»¡}ƒ½»G¼Ôy/ÕÒx¦ÐseMKž¿%ë¹c5âI_¹Š$gÇ>œl¿"ŽUñzÿuqóþqN¹.ïrY>eq_¼¥a};®/k¤¬¢xã’âõá%ÅKÏé‡ð Ì1ç»7oÈ´­œ'¹*Zq„Ùê„ÿL‡ õb]dOŸ—¿}~MÆÕôܰgW1¿"¡Ší3“¡gÓ&¦ÆKGñÄTá"®ç{Vd¹mÚ†ÖÛRI"ØÕÖIë9Ï}”Ž£í8¬±ðhÆÎXG}ò½&irlBOG€pÅ(j˜ëóS±&Uf±Â  ]$yÀî®!VR˜w©5Q1´ÈUn. ÝÔµU-sÍcònШ… È‘ ¦dÀ¨™þï7 ´·ÿ|ø‹D/§NêÔ²’6t°¹Â³^­(wÈ ¾Fq³3ÿBkÅÈ&Ø!vö6BÆn[™À«ç oÄ’Kä©K!*NC­Å[%.Bi%¦ª;ñˆM~¹*ߘ®±>Ä,®ÖBÍ¡Žqøf‡NZL 3_¸^=Û¶U tÜ‹‰2 5Ÿ ÁrгÙFiبv'/éx¢ë¶™úêg• ì±ÛDUŠjq¯âTcõÇd8¿‡`üeäµÒÒòÑC¢ÓšL˳©é;{A€Jˆ>é˜çÁ b “A%Wsc•©çÚ^æ:FGκÜÍóaGOÿUÜ«ù‚^üãhBÏy’¼3±:i9yÞ«îrr¦ú^|Äm)èµá«@¿Ì;©aËÀM¿S°]c`_'ÐJ§¸I-›¼„¬½—g[#!Lû\©¡µ8yÉ9D5§úiHn4¸);ø*Q4ýtð0ÆçL0"DFÞŽm_nîŠûÛ{*7å €ÒZ—ņþ”*;£Š)¶õ´wý #c»³aа“[ôÀýfWÜ–(öÞí4ô´_ü½ø÷F endstream endobj 5285 0 obj<>/XObject<<>>>>/Annots 2589 0 R>>endobj 5286 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Žñõè/·û©ç\ôžÀæJØðuPÞ¸X:®dßóÑÓM»¤A;€ŽãPFE_| I ±vtŠß ù¯2þÀûͰ8K¬ Üô7ö{eàa´¤‹ ½>® ïÜs› x(2šuEÿÃdÃ%€±QëUi*tµeu+TÎî=|ùôî+åqº^©öˆp·Ã@àýÏax”‹Ø&I±òBmãä_ñN8»p‰_Â(™Ï…ÀË4ÊfOÌ3„š»|ÛwÚ°)åÙõä÷øy^¥E—)ú¬_ìì>;Xð䈨h›f×3þÏý)o2z¸~úõÁ"ÿu…¦ïøÀ¸ÐúkÙûs‰eÅ1¯5Ýt9ïÂêž¹Û¡_†—ãÊ@EÝU†£iK³æÄ¼Pgs³—Ì·Ã!9ë‡ÿLàBõð90ÿ Çá¤ûýð…“¿'-œ$ïÆ•>{öxPÜžý!ô¶Ã €ýq˜;ß‘‘ý¿ î>(ƒñy.…Á/’æñß DøõJà›§s/9Ÿë“Nþ…j¼Dendstream endobj 5287 0 obj<>/XObject<<>>>>/Annots 2591 0 R>>endobj 5288 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Ó‰HÄ”®LYg œŠLͧ[ﱂ8™a†àÃ5³[½Fug§hƒ~Iªºr‰º#µþNYTÔq"…þª¸>Êѧ¬å¾’éÚºkýmù \7y‘ oTQ¢‰øBɦ"¹„?WÈú$wóñÁ§A¶V™^éŒ]xú¡òu!Ù¨!è3‘rq®N"ÒŸòè‰Ï56~w`8ߊHWÜÝçþü~É;© ¹ÄÅpýïOZœsØñO¼.ÌR¶/CB=¢¨ÂÔ¡Œ(¦Oªý5SßÍ¥Ì2e-n˜Dw²ÑŒÌÒ¿¹ZÉ®h_ÐY†§gÿ}‹ÎA|ôÂý:g®Fæ§NÕŠÞWšs°µÌ\"Gy›ºnÔJß“m›yÿùëÆ+Ó„d î©lñyÕU™ñÇY›ú³OzO|±›„TÌç—ýÜ{,ó0ž»†ùçá®Dýð“Uož9Î/¿5ëélÃä,\uˆŸhº¯MÃŒ¹|pý½f ­r´èÆ]>äP ©@oN¶Ü5‡c7hDZ€eaªµÕ â«G%c:CWº ©a:Àq„o|ý¨j¡Ý§Ëf÷uë§¢¯œ› .£ŸÞñªÑ h\ØÃ•‡ý…v~Ö[´Oé‡Ü˜07‚Èy1IÊ€Tâ“;„‘ y@1 ÅFÑ›÷ïíØnð6'³üî³ Ì;>–[0à—!Ùn…[ èu§‹Ü…¬_øµŠIél'‹ârÆÝm“ò+lxµºTÃ~ 켈ÖH™í±Wzp~£ŽˆïCcJ‡Â‚i‹Å¹ k<í—øÈg9 \ôcv̰Éb|w <:@tÔù„vЃŷ.Ùa™.%¤ª‡È†áB9©Ñ/ðPeìÐE„µy¸G}'n»íñÖ;õ{µ‘h÷lÉM¢Z6¸Ü-K€^~8¦ÕÕá];4‚•@³W[ü¬h8Ü[ù¶„ò¸«Œ•Œv;·=*äØhßH7a£žu”MbìX5Ð{WOcU3—‡áq¤…òP)!ÂG3¥;ظ .{øùÖ}gv0´Pw/¦¿» Û£ôA§øf_vj%…P`HN;ýä"¾²¶+Ù·†Ö†•!&|äD‰+„¡ÛÌH-gy íÏÔ€GMñmh•›äïæ²[t½Er­p9ÍÔ€„æ|I”œŠ‘žÀÛZ\›tpzÿô”ÿì´ÿËÙo§¬/N[˜öÑfýöFóœR\™Ÿ‰‰_ h_ŠZ½’¥´ R¯~ƒøçsÇ×Ïú›Lfâ"½ y:Å?.ÐZŸþy÷6NĄޘ¬Û avB(o_zYƳB»ªâö³[]Læ"M qÖlþœýq3økð?¯f Ñendstream endobj 5289 0 obj<>/XObject<<>>>>>>endobj 5290 0 obj<>stream xVaÚFýί!U!øsÜõÒ ¥i¸æC”VE*tZìܳwÉîŽß7k/Øw\%"Ž=;ûfÞÌ›ùÚÑFOùoRt~[t†Ñ/?fMó_h4¦Å ¶ÓëkZ¤þûI/Fq4¢O:-si_/þë\Ì'4Â7¶Œ'Ñö½ÅFÒß_>ÞRá )ÍŒL\¶“d·2ÉV™´ä`£D!I¯üóçÄ T'"ú¸¢ƒ.kûukOvŸ­å£(¶¹ìöùœ¢LQu–ácO{r'ÍÁm2µf¾¬ö°Ïòœ–’D’Hk³e.©T©4Ômû6K `õ­}áK“Ö–‹à—céS!d ‡-ô‘¤Z½rTZéÁXŽÜ‡{-Ë,wƒc$”è¢*%mÈ:<“6ï‰ê+Æ>ÛP¾ ÞìƒLÉiÀßéIKàݳÔkDY} üõú”9òéqæÀV pêºQÑe,ÝH'®‹÷HšÛG©„MMæªTàX«v"ÔŠ•A)¹ÒH‹’PNùDy§M"ª Õ17¯,Y)L²¡­p›>í7ž¡˜ÔP^)âp]ª]f´*¤r-bvÂd‚Ùï~~¿x÷χû?ß-þè¸Ufšr-R‚óVyöÉf(A$é°•ÈšõTÞ„L_G17Ę;bÅ1þ—ö9Ô÷ÍhF ÞHàæh2žÑ:Iïz“þôîuË@(Ko‰Æ­—µãxF bŠæZ·>×gâÖËúÌätæíä,–Ë“EËAíuÂ/O0ð!ÇÑtzÅñ|ªd“#r«™!Î'X_]xŽÀk(Û't-óè«c)¹¿jûº‡—ý“håä£óÑhl.}¾-–Ö­ {EhžíÓFïY"|Í¥u(jƒßB±™úQJC”ƒŸâpŸ'Å]Oô—OøkqÀyêgþ¤XZûÇ.EùjðÞÚÍHª4\ÝrWó‹J `^,¦ÑKÕô ÁsÒmn˜_HÛVðV õ©|dê4ÞVKø@¿–êAé=ÄM3ó¿ç0£Ž7·>•mäJÏspÍf9Í´ªD/C‰ú6¦y­]/´Û\/E~ªU°½Û-ª ®ä>hÄQÌ56¢9PO>G}1ÒY™øéù ke)S(U‘¸»?©»×oj2þ¤#…ƒB7fL€õÉUWÀ}68ïU²¿×æÁr<‰ƒæ䛇5Û"©–öG[§ÉduëäI×@‹+a/9ÇaL5CA׿KåÑÐS)†s~„€éãÀ‰è›‹B×U „ƒßŽð{DBÁ¤QHUÉCªíKýE-Å(’[ ù ×C.ýŽJ‘ƒ‡µTÜp<Ž÷Þ¡¤±&i|s˜b)F§óSq'òRBAy5‚p&ÐÕ>ƒ¸g6 Ï{]æ)d1¡—ÒpSU ÂÈOét~O<þõK¡`XÃKå9žjµt³dØÊù"®¶­\Ãs L¢·‡p=!ÍÖHü†½ò}3aY=JráØªòÞ=o“'ÇL&Žöy;yó›Â‹m\+Õ™i1¿®W±Ñõ$ºŒ/±dÇø×/ Lè` éw”¼²xýäpQó•õàŠ¹ôÌ*~9œFñ{8¾N®†|êâóWç}²ôendstream endobj 5291 0 obj<>/XObject<<>>>>>>endobj 5292 0 obj<>stream x­VýoâFý¿btUrŽÁ@>ZNºKB©MÒ„(ª©]ì1øÎÞõ­×!¨êÿÞ™õøD®Q[½žϾ÷æí~mõÀ¥¿x#þ÷“ÖÇYËu\¬¿ô'.;ÌBè»0:é9£ÑÌåÂÌo+߈'<í¿œ­¢>‹$ÑñŸ„v&JÌ>·\èö(8hû0ðCå|ï=ìš=ü¸+z@okŒ¿œx¸;qc¶6àÁÃɸغ´ânß+WÜž† €‰yŒeýXEf f‰°%InìÓ Òè›è ù!× ŒÁ$5z@)êt«(ŽÁy† ×S@­•và’òPŽªâ>¹ˆÕ\ÄõüÓ¢òm®ºý¾ãyÄ\ÐÞKTSÍ[WÉ,+›Â›`ã³A-!P9¯˜¸l>Þ+WkG_„íîazIÑòD«•EJ£"¹BUxy»Ì&[湕EÑâVâX`‡ñ²@A˜KÂ\Éâms$<ã§zÅFÇ[Ø”òë5TÒ@g#ð-üXÙc«—ZÛ¶ˆÓŠçŠæ&Læ¨kÊï¨æfY´ J¡ˆ¨ö( RA‚f©éî®âw³N‘$›Ñ…Þß• ŸDœ Ã0‹MZ|N5Ò-¡$Qhˆ#‰Ðâ<‘Ðë—„¼Ô†qOe`I”EP¦U ~ÆW²¶bçÖ(èÀŒE/âŒæ±è9=$ÑkN¥QŠ5&ŠŸ£ÌV_ÑJeP­Ô6¯df„¤žzl³J¤2¼ nʺ‚T=IuÕd<p-¨‘-  ìtE]«Â? T‘Õåq¡À@1œ™ú’j¶ÎnMÝLÇžÓôwÆ~c7Ó ÛÂ¥ƒÙénÉá ÓYûذò1Ïuw6‚¯Þ|Bê'xP:ÞTZa0±p.ÖÙŸw÷Wç~ëürmf÷w|ûpq~U\Í>ÝßÚ¡É픟Ü}˜ÝßÒÅ_ß÷wÛÒÔÕû†Åž¯÷“'Ô†­I ·<7PI¯ü>dÛ†[ÒXÞvDÈøe,Á±ÛÈæÐçÍ3„2RÕËSˆ>-ì–ÉE¨Y²¶mË¿¤ð-ÃÂo†´¯”£´sáãAÓ‘¹?Ã47Y3AŠÜ;ÃýXeøØnDNŽË£fïxà ½!ŒF'N¯8´±6º}Ç…såç|$°óÒé\ZDwŠSµut.›gB+Ρ;r¼>ôÉÅG=ž~1kýÚúæç²Ïendstream endobj 5293 0 obj<>/XObject<<>>>>>>endobj 5294 0 obj<>stream xµW]oÛ6}ϯ¸Èæ Šâرó1¤@—5[ ÛÐ}Ðe3‘H•”l EÿûÎ%%§ö’!+D?/Ï9÷æóÁ)ðsJ“ÿfÕÁÏw£d„Æí» “Û3:Ñ]±³K¼ä¾/Yôi)5­­¨k™ÇÔ™–Öª,i.IÌKI¡Öá±”T´:k”ÑŽ”&AZ4­%­EG…5ý™5b%º5–äFTu)¯ŽîNnGt‘LxûñˆŽÇãd2ÁW?áêô-¹µZôS~â)Æñn‡ŒßRqýÍ ¤0µÔit¸>ŒZýx˜=;q²³vRÔmã0í7Y–†ÖÆ–ùa\¼0÷lonV'Óhþê±?Ö$™ÍÎ9æ G喝J7J/ÊòÑhgØWâÏ1|@9PÏ2jü^à)mਰ’¬t5ب˜¦8WX)oÕÄ„O¾.þºã¡¦µ™t$œ3™Ì{³Ä`J£‡Ö5è ì7m™†ß ù˜µ5 +ªô(¡»¥r”,§ &Ö|ÝÎk¬Ê¼C4Y‰x?s{›59)¡¬Ò¬±J8ÿ÷“‡ܬ„Dì¿.WZkìõ¼ÔdÕbÙÐÒ‡«ò@UçÔBWR7„ã¶:—…Ò2@ñwß/#yáÙŽc³ä¦ð–AZ K%¦Ó8¦Ì”m¥iÜSà’Npg`w˜2šŒHŠ>zðZ,ä±dÕôØîˆçž%g^€Ÿ>üêeæè¦ÿ¹ù4ï@0Orµ+ÊÞÂ.3Q– ‰èÄÍâÈEìC÷VzQ<8JèÝ+GÝ#˜žaX×¥3ïºXÅ•Ó1´hw¬…›ÆÀÌ$8å™îéËñv¢4ÄPá2;ËBè~pïÌ"[n=(0à0¶;±xŒãW~›4pçpÉÌL§ cv³AÆcB>ë(½2Œ0€Øf—˜%™Y ‰r³–ë>|^@AE¼ÀN¨ÌY+‘ŒÐ×^Ï[ V4!Üæ^àü RàEWÒvÛ„çm¨ÙnªûoŸ@Ó_ìaû~‰&ÚÄÝnþúê?Ÿèµ—cX 3 + rÙÚý©¶ÞIµ>æ4z9;ÔÉæz²}ŸÙ‘A뤻ž>Û9åÎ ²DÒ ×é-E௉&Ï5NûëÊ™=T>hΪ`kH½^A.lë {7×,,ï@ÏÐ‰Ì ]†‹26y-‘z!b9E%²WNÙçVY\f)VÞb†ãx¥5ÀPRõüÓ¶Ynk^âßÔÚècT •jÔ*HÞ§ïì~w0‚Á¢‚#°«—ూ…o8OÖ„#×¼Z'’*Q®tB[³Ž}Uèó"NÃvL(y2çÓU²šK ݰ¯d°­ž©}®+ é˽˜1â«à¸œD6…šxV²Yšœém}©´VqEêú£ïòp£ˆ{dÀx`ˆ2Ààœ’G·˜½Ý)3Hlô}0A=¼98Á§x±ZõŽøœ‚ëv^ªÌëo[·@zFÕæ§÷ÞobÿèÒ#º¢MÝoÒ£¸Ã“[¾|0õª ÔØGR®B.H#ÏÖ°àd—Ž'íÍ¡Xî³mÒ¨FámŽ1§Go|Cç:nØ9Ñ~+£PÐH,¶¿÷ÉíEŸ&O/Î’édJ³‹YrêýÈËÇãdD¿˜¬åºÂsC†ŽÃèãóP÷ûä? ‡•xÌt4K&cüƒk=;sÓû»ƒ¿þž©ÿÒendstream endobj 5295 0 obj<>/XObject<<>>>>>>endobj 5296 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®º¿!r#ødZ¡®°ÓôÌÃé4Ge¦ßç^ä†þÝA^Ï®BíèÕròqò ‰tendstream endobj 5297 0 obj<>/XObject<<>>>>>>endobj 5298 0 obj<>stream x•WMoÛ8½çWÌ¥ qTÅI»Ht»-öT,b %ÑJÔ’T·èß7¤¬ZNÓݦ©cSäðÍÌ›7ãN&4Æ¿ Íü›W'o—'ãtŒÅþÅnèåû1]¥3Z®i:¦Å«IºX\Ò²»Æ´Ì“o§ËÏ'c:Çãe‘˜Ü‹ùzþ†²ÔI¿J¦£Éêô÷nÏäpÏïyáe7x,jG×DÓ-N‹Ýe‹7$ØøUC/ßω!­úóé¬s.y'YªÞ©É—’̶–Ö•ª!8åÃ5 b4¡h$q[µ¹³r—÷¶“)O•ØQ.´¦?ÎΨÎÛ6÷Æ:Ú–²ÆG8(­¬sI¹ikO#yC_¤5)ÝJÉHöþO9ØNæ^!~+Y»Ã-µØÈJâx&µÙÒÚXÜæ…Ò.°^ч×ÈýùtÁVfãt–^\ª.¥U^ÄÐÞœ#a%­[­wäÚ¦1ÖË"¥%b-þW°ÈïD@X«Ø}þ jxQ‰àªÐYÙ*_Á.€6ÙgÄa˜Æ¨ÚKËq/.Pn`(75¢ªqz/åZ8G¥’Vؼܥô‰3#œº!ç ž«Äµ9 8 ’¾4v=˜<<]À˜õ[%\jÎ%²†Ó LjË †„8ð8V¸Û9/+Âr¤9jX QŠ9µ—ýìvÈã*A¯@RMÿ¡ÉôõÌ ûë%üÇty¦à¹ø¬EÃÁådMë`–`xJh-Î:WexÓ „ˆnÔ¼"<"´¦m´É„î7b·-‹•rhO& 'ÖTÁb Zg¾÷j•tH2„–ïùÜ"žŒ@—Ž?Ûµ,p‰eî=–壨УЄ×ÇAC &!yq­oSÙ“=ÈÀí§¿>Ѓ°J@ ‚f} sÏèÉ gOÎg27¡';Ó»;Q«$‹íãûl’D™Ù±ƒ²u2¿æV‚X+öŽ5bã`Œ2m„lr;ÜŠ &7´7ÇsI!Ñ…ÂxqŒ*˜9Ž@ÏL-X²Ñ ô+"9¸ÖQ¿ßÅ=3cpB D!8ä‡I| Ì!Û‡êE.ÞttPóú§kLábjzE”Þ"&`5¸Žð°°p_Ý{‹am4F'¬‡Ž²ûÉèp,>ŸNÓÙ Cr‘¼PµæX~ÝŸ oœöèæh™¸MGº•à ™èÏîÂC4‡×qÛ*éW¾îï8TãHïâÚ æ”ÇÍoôˆÓC4„+}kk¾&Üpö˜v7Þòmø8<üÎTþp0EÝâ ‰¥ÝåA«{¦šr¯#¯ž ¤¸¶)ëSÆïfü.¿±žX÷B`¹KZ|ËÈ#üëë‹îËÆ³ ŽÙÚ$ÚÏ8÷ùçîòs”ww™%8¢Dâ+:«ëbrÕ})˜\ÍÓ‹Ù-®&ø8Âêq>MÇôÎä¡»‡©‘£ÆÝç—Ñ¿çgó‹ñ"M1ŃtóË9Ÿþsyò÷É¿ ?ùendstream endobj 5299 0 obj<>/XObject<<>>>>>>endobj 5300 0 obj<>stream xVÁrÓ0½ç+¶‡–´ÁŽc§)-$ e81 ™á€¡£ÚJ"°%W²Û2¾•l'ƲC’ÉLòö­ÞzµOºLÀÃ÷‚™þDéàårà¹þ¹ý’k_yðÌ `¹߃ÙùÄÍÎ`›(–ÑðúúF’ˆ^µæ@~¹V?ar£Ž—_8 ‹1,#’r0/u\xÜReªC:s©\–™Ö”SIrªÿd| ’f­´\äuôiaE–ªDG–2^NË%á*Š÷I+é†Ê”åŒ`¹¤1ÕÚÉhÔ"Æt:N $q\—A`7-X7;رà´Hvð‰Çìn-8÷;ø‹';:0´qµa«² ´îá‹Æw»ÙŒ^,ìlÛvB• ÊtíD v§zmçfa+'½­#1ç|náëfªEÞÔdKæMúM§ÉuÝ ®ÝÄëGŒ¸ÝÄë!n7ñºGˆwt/÷#«|„Eµm <–ðøj z¸Wà 78~PyÃð‡|CáÕhŠÅô©ùÓ)’R’e8¦ Ѐ(X‰$÷êB·åO·q|ß ôžxxˆÖAR¢à„ÇU¯N..D¦§_ÈÑs`k7ÿ@‡áñ‘ \å½TœÃ.N/¡06Sr9{î#ýE n´.'½qçuƽ„Ttöè°—˜‰·AÃ#½ÜrçZÜ££} !«Šüñ±—ñ°h0¾ô¿£2·Dýê%$U°ÞÙÌè%­iUÅŸ¤Å¼—Ao;ó~ï^ã`Cìji”rÐ+J‰µ¬aÔ?Óúœì`8ýCfn¥±ÆÞ3›ó鳩¤ßþ¢œÜQˆðø'‰Pä,axQXIFÑbÃ!s© \p'¥é Õ…Ô.¦àžå<K3<½*»E©qQú@ ÀŒÅÖ–çk¼,!5fýqb&i„ùÝÕñã«s˜ a…·?ÇŸif๋Nþ*!J}È)WLðRË¡ù—ÔÚð5uêN5y‰N_ÅT+1,þ^ÈoÊ(VèÛÚçQ±ÀSAšC‘PU‰yV!¾7uOƒS˜yeÞß¾q|׃×"*RÊs’£&-O›2Ö9+ï–Fÿ¹9oê¢ÍåóÔ›¹u¢ÌéÙ©æ^.ï¿1ùendstream endobj 5301 0 obj<>/XObject<<>>>>>>endobj 5302 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<ÕtŒhÓ`&:žE29g¼(øƒX™føpYÿ¦ ìÔM&«ùSVj Ùt _›fâÁ%¤ ÍÖòPüè (Ûb¯€6߈;|<^` :2ÈÛ£ \ bàSMŠÙ_ ™®¦ì£Ç윆£Ú;*¥+•˜²_­:‡uÊÛcA·ð~©­¶—Jg¨}G â^vˆ¾z,g0uãb7Ú_Y½%8M7€HX«g^›º8 ^p]xAè_rGˆµ{4‹™ø³]ކ0ƒxÉL%=m£ú?±’¡2Š'·¯gåEÝj²Ô]©ä«.ÈN—¯²éÿ ù;ÔaIÈŒøot™øáìkn[@ð"3]_D[Ž){‘5Ê”%šîtÀ¹U>#í 6>ª|…bÍF¨óø HšZn—°TÑg›Ã7©¨ ²oeÎ.ìww×m÷³"¸½E´€å­ïݘ‹øÓ_¿œ‡ž¿ò¤-i%õ@TÒBAëù¹›ÍÈ÷áƒäú–øó˜Ìû[_9.ü¥…ø³ |³TK¿í&N¾z}í˜endstream endobj 5303 0 obj<>/XObject<<>>>>>>endobj 5304 0 obj<>stream xVÛnÛ8}÷W t¡ ¶¢[œ4›M·Í¢OÝE ,`Ð"³H/I95Šþû/²#ÅE›E‡çœ™ñ“üM!ŸÛ¿ª¼_L’8ÁÅý?õç \Å9,jȘ¿MãùüÔ¡XTà6ôúZÅÅ,—ø¡ŒÊS¨¤Ð¾.¾L˜¥ˆ¦=À#˜‘´ìÌïǸ~s£½RÌtJ¸q8ò5ìû(æ÷!døúaí¦!†•‘îÚe%ñ‰}Å›àÓ»cXº¡²[5ìî†áF<*ì[܆ó‡,5ÌÕY–V#"(˜5ÐiF¡V²…Ï•![f¯1Ôb–eqž£24’rݹ}™x”å¼<æÀ9‚cBieåé€$"4܆Ìã—Q1ÍG¨¦Ø‡ÉÏ𨟺œuþðÒì@ÁEOAžÄyŒoþ8;ƒÇ–(I. SÚsÐ3gy+âÂæg¡ÚA7 D1¨»¦Ù¡v›Té$¸‰ü*h%í¦c³OÅÆœÛˆ>‰>pÅ*#•†2ªHÓXƒ{A¼8öäJRÖßéHr <Ž×.>¨¥‚Ç>ýy8a Ïk^­aÃTËî±ÑÁHܸª¢µãÅ}bz Ö/ܺ´eÂXçp[®LGš^ ä˜F-3kIýuqv1\d¼ Ô]u \}ÁÛƒT£#%Ÿi[da kù̶È$ žEì&ÎÓ‘~æOKÅê¡`˜Ý†Ù [N™ÆÂmÈ 9A¥þ•Ý óŠh‰èjRa¹3 ¿zX§­XDz L޳«;Q.Jr¤°Ú¹V©ó@—ê„á-*î¼³'óe_‰ÕbÚÓqhœ¯‹5õÅêEµíòh•Ú’ŽÛÝrKÜBqã*1^c„½ÃöÅšûÎ;²©Ëèdâdj_…?8ÔÕô>àëÜöÁŠþ¢G{YïX`̵U•4ZŠùV÷ÒáR /l‰¢Ü¶À¬mt ¶5ƒì`-ÍõŒ­Á€²š ôèj×'u”ý7\`³ÑTò•u?ZÝ`çÕµ‡2÷ó+” í´3qÏ}5ÓèwP8Éìɶ0Z–âdL?ÀpfÕVrêv/‘ä.£û߀ ÔßFi:ÛxK¼VptÎPÑHÂþ%^N"Ç¿ÕO“ãægc þþ=éæ`ï÷{û<}w ñ‡þß—åì=¸q˜GX /¨÷‹¿Êög‚zN®BKK¯Šø"¿€ùU§~èÚž0Ëâ>Ȫ³í—Øæa·!=»ô¦ñÓ$õf_1Ü4»Hæqžá×0ìÆÅå¥Ýüq1ù{ò?Ãü̹endstream endobj 5305 0 obj<>/XObject<<>>>>>>endobj 5306 0 obj<>stream xµWk‹ÛFý¾¿âRö{Öµ³ÙM“-ùЖC(ÌXÙ“H3Š4ÚÒßÞsg$Ùr¼%-”]ŒwîóÜsFŸÎÆ4Âߘ¦sþ²³W‹³‘áËö¥ØÐÅ툮Ĕ MF4:óùZÄÞjD‹¨o#'ïÔõìE2MW;[«L¹­—ýWËþò|yþì|ñálDÃ1Äõa©cE…­œ6ÊU1›]Ü^Û%4DÀádZìÛ‚2[ÀÔšH—*Ý ‚ùa~ÃÉDL§È¶‰r=~A¯ž¿ä4¨¬ÖQ*ËrÙ¿áσ^¶«í `— ¬òB—,û?…ºN¥¹\šŸ*ëzò÷á7ë¹­t„VÓ½'gI¹NźP‘³EIwZÂJÑ£DIW¡oá' s®U‘ůÜÒ¸JUI Ú붺\ž‹¦­a <ƒKnè¾}Ëóî út¯Ó”d©Ü‘4;2U¶†s›ÐÏÓZ–ˆ€!d×ÿ?ùí©˜ìú**tt E8Œj3sZÝÉ´Rßg–K]à°45¸€x.Fã„ËJ*9mÍj tâ¨4Aoïc?8-Õ€?—Š$šêäGeH–¾FòðRå3ÒáL©Ö¸>##3T”)nN‰1(ígp' ÍÓó±ÛÄЯ&7«\™õ’5t¿Å~¡¿x¡ &jÈWOº$Ù4¸ l_“æ[dòhíK¸µ(‹“„'îC›K(3)lv³É®$èØˆµ”¥ÍW<ŸœZÏæ×Þ y7xéßqàAO§êù°œ®g˜ý6ÇvUº*Á>óÂvg{Ä/b›"‰a¦¥ÅDK½1d¬2‚ëVµƒb<4N&ÓÀ¬É*rät¦-0"î$¼€{òÜίYã´tÒé¨Óç~QMX¼ÖOª3í CgêsžêH»tG…Jä´k'è4PŸe–ƒ%äÚÞÆ÷L¦U{ ½ùÏdú²%ÓÓtϼØfo[³nÓ„}¸ž¾ "&eq#<àþ’­˜»O +VìT*óæôè”^œpùÙÅíSb^jÔoÖ¨ßt$¦b "ÞJÆG,å¡"êí†öË{½YBºçû`L¬„cÖ–†bxm€¤+ùŸ´ãQì —‹ù*äo'-DY=ƒ<UÓI[Aåé‹*,ªàmjòð×£<üÀ|ß/ǃ‘ic -ôÑê<ùß`,ŒæŠ~¤MÊ7é¯MžKÃŽÞ}›WkˆÆuÇ’ÈߊéëžEoxj¡˜S¸õ>£oGÇþ:q®éþƒÇ¾uØûÜ£öH™ß{‘Ê \U#^(ìïZáâ«Ñ[ÀН¦û´ròi@>÷ùvãw+ }¾ªoŠã«K1›Îh~5ãðlñîýÛ_†1¢×6ªZfäcÈ>/XObject<<>>>>>>endobj 5308 0 obj<>stream x}TaoÛ6ýî_q_†É«¥H–í8`k—­ÀŠa¨±~Ðe±“H¤¬z¿~ï(9i†¡Hbäñî½wïîïEF)~2Êwü[v‹Ÿ‹4IqøôaOtóÒ>ÉéPÓ:¥Ý]–ìv·t¨BTJ‡22¥gùýúžŽ¯ÅËçEJq†«êz•ßSÙJaéÿ¯7üróòåTIçíPz¥OœóæaCœ´¦8âu>㈤o´Íñ“,=UÊâK%uâBGIƒ“yC¥ÑÞš–|£ÎqVÆR¿Þ(í¥ud¥¬FxmMGõ ‘Èh—ÌœÖæôN#…¤R8Ic#­$£ñŸrt!ß¾yõŠœª$6£&¡iÆçáiŽJ+…G-¥é÷  ‘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Âéêê¹è[°)–Á 7w”AúÓ¯w܃YU6ä¤gmƒ³¥+‰®Ǩ|ƒ¹BúRº„Þ ~ñp+÷AÚÀªõ1÷bFÀ6âÓ{8ÓÉëL±Uô«%lºâ<°3 ae+xŒ‘ŽêÔxÖdvÒ¶‡XTðy#;'Û3à‘““¹*SÂ$Ï(Ð>úfðÔ :û›ë…OxÂ%3tÀ.Û8&'.+ÚD@ Ç`¶g·…åQ Œ ·‘ÇÍÐV¼~zãœ:rFCØ9 ÷´X®î{^¯ñzä9–mUfàWÝå±’¾ˆÐ}‡é ‡ßq V(K]øÔÅ2,Ïg»ýgE†ƒ­'J´×aØosû…[}ˆ™Ö{vÿ„Åb‹hS,纰Դî…vôšâ4Éöù~?eÝÏÕí7É6ßRžo“l¢øáã»_âu’Ò[SŒ„†›°Ü€ŠŽo§ÌÓ€mé½ì æ¥Zœ$?á"Ût—äkL#dÛÜÞñÑχÅ‹,t(endstream endobj 5309 0 obj<>/XObject<<>>>>/Annots 2638 0 R>>endobj 5310 0 obj<>stream x½YËvÇÝó+:+)– Í@v2#êháH‘à£M6 Œ5¯Ìƒÿ>·ªf¦ –Î<¶)^ß©®êêzuë¿W¾ñðo„þÝWÞÌÃÿ¡>ýøôî*LfžIâdšÂÌãY4€Ü|¸(bn±Ä âæÉ…s¾ç‘Æ÷“Ù|ø–Y…Á†‹™¯Y…Á&sRËzXVa°‹ùd…3*ðÄ(?š-LÂHÔ: ÑÀ'£«0ØxqÌ* véÏ%+¾ðƒ/Ø&F¬Ös¢0 ~s¬Â¤Ö›-5«0ØEHÇãd.Là…dòÄj 6Žô²ÉñRŽÝg9“'–MT¬Â0*œÏ£X…Á&ËY¬Y…iCtRJVa°ËœáX1y!ѸŒ‰c@+Aß#“&Rc°Qˆxs¬,‹Ÿ”~@3bO( 6¡˜Q¬Â`ç3ŠUÀñåXÁFÇz5›äÅÉ*19Ña3b“q< #˜6ÄNt¬Â`8Ç* á(–KEI˜ÏQ@ŒÒª`aP*àþ8±¨Z…ÍU,< ƒ&Qá”ÝÄŠ°— ;bF¼°Â¤6":Va°¨G² “ZާIVc°Á’¼4±bT Ã”Ù$a:p¾ÏG3‘“'¨Ä‹õáo_Â4öÉÁ hY ƒÚ„ãŸ8±(l…{'RlÅöؾON`D«2-丗´I¼É·s¨t¤·cáU#FnÕDÜã{«#GÆC.ÂÌÄDŒ‰±ˆ©¥‰§ íÒ#c'RìAàÓ.åKNpàÁ‰ÔX¶‰e‹m,×RÇŠRt:§”S:p”ØÊDjŒeá88abeY¸ÍXÄhòP¸{2õADJ‘ŸØ „VÅ* ­ ÕHÇrð…\ Ô!âк b€ˆŽ8±(g¯Ô,²:VËŠÊd(6ä„ïÓA¢ÞÑ„C_)‚Ã@³ ‚2 NA¢¶GŠÔ˜ì PͨÆ`Ñzaí´0K8LJsJl­ƒD†ÒiŒÒ˜”R=V¬Â¤”ÚcEé0‚-ùĦ9IA†|Ø)‚ã˜ä-‘ƒ¡„&‹ØÞ‰Q2Pj¨á…ÓÄ¡ édÁ‰äc †cB¥öƒôc¬ªHêŒÁÐö}Ÿ‚ZIj QbÅ*L[¡IE± ƒS‘W¬Â`îKÍ*L,@%«0µ9bűSûÀ8®Xvp€Ÿ”à\uÐn„Ò€&cGŠ ·r¨XÕ5v…Á¢4úšU,¦#Y…i74¸•E-·dRKQL Zc°ˆ#Va° €“Uj±¸xbE-à:ˆ ›qT(Œ…‘çu¬Â`jýŠU,âgçd‹,ƒÉŽU˜N–2À±bòØüÑfPS{÷ÆÂœ<Ž…œ\@»©õ  Í*ˆ€¡Îç8Q9ö÷€Š /R(™ô‡þNuhŽíŽUTcØÑD³ ƒE"ÅšUì‚nneQ;L\2¨Ç‰I Ò²teq¤“Ra³£>8dÆ!ˆB7""Ep˜*xó§¡BA¤yÿΤåÖ|´Mÿ}õ§Z‡_ xÆÒ*x£¸FdEq‚u^~¸³Í]f樂vf±kÚ ~Û¾üOÌÍñ÷ßk¡¯¯}2õåÇÆæY‘•i“Ù–äÈ¡ÞÙ®ËʽéÖ4ÙþЙƒM·¶1»,—oÙ÷ƒwâlÂÔ G«bï§VÉ÷ƒò›ª¨³œÔ§fûP¦E¶1Eµís{¼¹9ãIŠë³|û#½æ>ëæ÷ô«¥ÿšç3£íÒ»G,´YUšjÇ¡taý´ãÑ?‹×帱Ol°nªun‹–³f3Å»ÿæÕ« oÜÞ®jðÚw½Î:SçiXp†¸€?5ø®1}zs³ˆ—¡K.S@R1o¿u¶¤8hM_R2~ÉÊmuÿ—ÔýÔ—%Ÿ]SæŸöÎæU Ï]¿Íª {Q§BéhŒ!¢÷<ƒó‚G:u åm…Ú•W÷×9mßdeg›]ºáâ Ým_n(òÎ4ÐÅÃ÷•ö¨¦½Ë«uš›;ÔÚ~iu7ØQ—–Ý¥õ|¬Ø¯—Vó¹kúM×7—÷Û«Wf“§mûœš¸Øuµ½Þìæ+’÷¼l99QIM…ž’Wèé[³{¦ø€”vÕ¹Åàäíýγ‚ô:Ý|M÷çžæPðö¸êœÞ—ußñéV}G¿Öi“…è„„9{¬{ûmckî¦Ìž4Gý<œÎVöÉi]S¿Ù¦˜UÄ­ Kô+(Þ¨+·oL›unÍ@û-%üs Ÿ4Øñü=ê<Á÷OR¶’?[­ÿ£µ»>j¡-é gƸå·rš9t4#¾O¤r2iÓ¤¦«0áoic~ùåÂðÉ¢}”8“¼?·œ\D儨3<…¥Í¾/ìå[ò›Íƶ<Á‹“Û±wšÂë“JÏÓÂ~¦½óÈÚØml ‹h«Ì©Ÿgbsz üѦ‡¤à›ý#®×2ìlªozšpeð»›·‹-þíÿy›žf'¹SÑpcîíˇ‡õŸvÓ™÷%t²úÂ9þ/ÛvgD륫¼œîs]Þ—¸Me˜èåþrÁpÁð”í(éí÷qÄ0F–Cµ=Ó£Cw~³•÷üA nP\V6Õö„‘áû¡æõ-Þõбvxi£¿~¾–›åMÚÓêÿ0«CÖRCª1¢ü*×ìÆÖiÖü¢÷õíøZçÂG2[ÛnšlrG×ï­iûº®šn|¹‰gæMgöûûWyf!…UiéSr½M›ïr\äå“öWƒ‰C #« µ·[ΩñÙÖÞUùå\§ïÖÖ–#WƒyköM»üa˜Ð ä`óšòcAß"MgæodvÑ\¹ú¼½°¯±¸Ñ£‹Ñµ¡;¤ƒqkk {l ?ÙðaÅx Æ’xF±ÍÌ|±/kÊ Wór/wÐBÑÖØ}Ÿc˃qUNûÔ¯1=«%¦µôD„ÍUËÛ©š¯¿šûÞ& 9e\Äl«òE7“c_OqŒx  ~aøá“mŒ¿òÁ8ÏsN´ðHüíêêßWÿ»é½mendstream endobj 5311 0 obj<>/XObject<<>>>>/Annots 2641 0 R>>endobj 5312 0 obj<>stream x•WkoÛ6ýž_q‘¨ ØòÛuWìC›¦Y€bíZÝ€-Q6IÔHÉ®7ì¿ï\’’­H“‘üZÉÂ*]P®“:“¶OŸ>__Qm¥%A™8H#ei´ˆ·½ª¨ÚJÊô^ÚŠ2¹“YŸ¬ÊËLöÄ2©ÈhopDÈ0’6²FT2a«`Ëx†¤ÚPZqíPgÂBiŸrYmu‚Q$¤¡ÌP"± ¼“Tá,PEYW”ªLF´ÚÊ¢O,ÐV¦Ž«Ú°õ8Þ é’ÏöXg™tjI§“\HàÅ×Cs’bœ\Ÿ¸ÀêµI`T¥ÙáJ$•køYh†½þùئd¯}¤M*bo®uÑ:ÑãBxèXãÓT—HNùÀÅ&4¢Âþ @‘ô® ÊÆF­U±qGœ?íî>¾)KñV”8¯6 á\ÃW Ô4g$²PTJd6¢·ÊØŠ9k×™Ì1l/Rµ§O$Nç¥ÊpÜe¬ãäW"ã5ƒ€1‚‰²q UID¿„^ P\'ôÁÈLå°ذlÜwŠT¸ÀÍCuöÉÔES M¼Ž+õÞe—u%÷öIXI†(Û›SKpbÂ1‰¦S¼%=»Wr‚@‚k;R]‘>0F‹Ås>°b`!I£òª½v… ¡2ñ¹}jÔcƒô?™.¢¸«¢Ç@«cyn}¯¨¸BʉD ú*éÆÉëµîpèâ1#¢2Ô[—¥6U ä;6ÀsŽú´(`|öHoàçë³eÞã†>tM{ÿØ#öÇ—“tR˜Ýþ_ȘôPo·¤*ˆ­¶N ° 6JY—á,mŒÈHûÁíÄ¡}äJVÎ[6ըͶ¢­ÌzlÒƒÀm(¨%ÇàHh(m£±ÁS†ÃbÔyGÅ·úƒ*â¬Î/ÑÀLmÏ9wÜ[PIï¸Îyy|õ÷O¿½«ÇBtØžœ`”ãúèAÅÌ9ÈsÌýŒ›•н6ø¬n9q*hDV×°¶f˜©õmΣñlxñþãe|÷ðuß!_b¶/+5è d櫘[JÞJgЉ‘V㋨!Üܼ…RDÍþŒÞކÐ'å ãòÕD×unˆNsðýÙƒõpA·’Âh/lR{{ð*ìm莕•Yúí¤?! $=ÅxB® ½ Ñ!èü‰ÿG˜x‹àþ{sSœ¿|ÚØíPq?ð>昫\ø˜c®ò¤Æ„ ʾhú§úPˆ\Å¡¼»cuãÓ!7L™Js:<±ÃŽ­ñ—;³÷7li‚üÀ1ĈìM áöc…#Œ:oÞ½Ã8fmv²q<²;éè±ñÚe‹¦!G épë1d Û»Ò6‘†õïRò7øê”\0>²Mð$! M]ÐMÏnõ¾àY­cä;UÔ_ož}5¦¶ðŸÐ&Ži~¸¾h[—sâÁƒ¸Ù: ®ïƒÄU' Þ¬µÎ~B£o-w  CŽšÀé®`MƒöKdu8”:Ä`€ H0¡}[Ú LjtNe&*Ä0gÀ4Ï‘gˆ¶ü75f9߃7“ J¶àêÜ€ÆS0 ÄbŒíwÃèÉQ»{"ƒ2 t&´]Ȧ+7äÁÀâ–qN|¥^úIÂ:Ú›wCÐ;òSD×8á:ÁerfË1º\ýzö%ã¥&endstream endobj 5313 0 obj<>/XObject<<>>>>>>endobj 5314 0 obj<>stream x¥WÛnÛF}÷W šV‰–%GqÒ6@:…‹8IFQñŠ\YS\fwi…)úï=3KR¦rê‹@‘³s=sføngŸÆøÝ§éŒÿÒÕÎÑÙÎ8ãf÷á®hïÙíélÙÙ#\dòéà|© ÊMqmŠ+ KM+›U¹Êu¡VšìB®ýR9‘¿Õi …É!Zù@+Òå­“$‡*YSÈý×ç'¿à:h·P©–£ ,¨¶Õý³·;cíOàÓ@Î\ò­½gJÜ‹þ~¯Ve®ãÓ6œÁ®øÍå®t ¿´UžÑ\‹#m+l%Þ~¬ë³²ùDzÖIpª,-QASV#v“²lTã~ÌdÁ1;òµz•Dˆ£çÒŒ&3NÃt?™$S:ªLžqQT«·) ­MXÒ©ºÖüïúž±–ƒä€õœ2žTî-•Ö{3GÅ‚%d™^i—óõœm´êUž×”[•)–Œ~{Z N8c-@:ËT“›P'tf)³H‡ñCZ;ƒT(±ÑË„O)QŸ pQ^’·°yn×Pü8F1¦CDŽdL8daŠoÙà=c¸=– yÉ«ç­jF3#‡Žß‡?àü¸sðûžÐ9;ÆÏXÃÅ ÷ŒšŸË?ïò—ŸÐe€ì£Ÿ;ô¢éR¥×êJ€ÉEZñËç'G¯[u]ŽòÕîߟPF´Q—¢§ì 9wÊí?íæË£_ŸžAó-7Û6É›µSebñø½Üôk_×Å}IφFœôé4™ÍrN_Ø5š«ÅˆêxÁôa \p鸊È=à\ú/×ð.• º6ÿÛ¼ ¹î'1Þqøhr¶|t¾F2!•¹* *0i|pf^ ™…FWºÐ­šuá0h¹O˜úJ§Ú1ËIW+æ5K©]•&WÁØ"¡S ¦@W€÷p‡ÔÜV¡-’ÐX?JUÁ<´°U!døÝ+g¯œZ­Ø?îÁ!MðDgÉw4¯é¹r®¦s;DG­èéÒ!£ ¯‹!)HþŽ•Óët¹V.|ø"ƒÜf¤0˜”n´óì4(Í÷sz›:„œQ’ti ðšÕž ˽[–Ö…–1„-8p„‘#»7àÀ6k™Æ¡+äˆ?Õ Át"©öQTèõmÏP‰^>…¬d| >"‘ÿ„He²è÷AÈ.Ë¢i„”"¿)àSÂï$£ ã0¿ Ý)nìµ&Q zŠøþ*¨ýÚ\ÑH =ê¬È¤JL?½Ò^ÈՔ酪òMš"Í« yNmÆqÛI‚­ƒÀ4êí&dc·om@¶|´%¼H™¥Á‘Ž˜ˆµÉó.\cô·¢-3+eŠ‹ÁÅým;‹ªH£¥¥ÂÄ) ››0*%êr.FŠ\ˆÍ¶]քΗ fèhÇ•ªÙ3ª4•—ÊTUnsÆ jæŽdŒ¥*Ð'W[ÆÙ·ò[çIÈüž)°iº÷Oë‘ÜæÀÛ¯x\žÖonÀ×<:ûS§~ ÛO¸ડ^.Zø·Ñ îíÑIDà N –[âèy;ôã딘',ñY¾<Ùyž_È5Ú·á)•2ÕåÆ/Ñà#WE&ýÿ-1Ê7žµCê+ýÁ.Æ: otôƒÄmƒB3¸X»~ûðWዺ𠣱À€ýA3҈̺}HÝF8‹Kvº¹ÒF@w¨v×¥·¼.¯K<îÐdï*“^óŠg\¨ûC -ÀÓƒmhå± ða,[æåw;ÐÏgIb.ï9ɼ¾‰ ]Z“…M'yD±ZríÂh “—®(Ù¬@ µ÷Ø)0‹šùçÖ¢œ#Š?›!ÉÞõ¹4?°'¹JmY3>¿>/XObject<<>>>>>>endobj 5316 0 obj<>stream xÅWmoÛ6þž_q(6ÄEcÙ±7;¬I›.@×½4þ(h‰¶ÙJ¢KRuüï÷ÜQ”_–­û°aM‘ØEÞÝór§Ï'ç4ÄÏ9§ü?¯N®ïO†Ù»_nIƒÛ é~µÓøPÈ}|È{÷–æ) ÚÚÆQ­7ô³v%é7AÍK}F [–vCa¥qY弪4­ÍuÑ8MÊc‰#EŶV•É©²EÃΛ@ùJÕK-—¦þDø…oöéýÇ“!õÏG¦çm¥ÃÊÔKÜýÄk¿âƒÛ!]fc|„Å£Q6ã[Ñû†–yÎÁTëRg6}ú°qj¯ý·ƒÆ»Aiæƒ5’\dç“ÁÍO¿¾¦Ù,ÌUèQû¯_ò:ê—ÞæŸtÀ‡Úó׊ú–ª-ߌñ¤:ö%žq6>ç}î1mLYrUŠ&GM¤”_´óÆÖd±ª¹*K]PÊ-bÒ{ì€^Fw(ôÊ6€f®iÑÔyÀVª4aK¦Ðu0Ø •Œ;oLXEo7Ïž¡"A×|vÊW ­ŠÇã2z¥×º.¸êˆPЯT¾Q¥¶È!.ääì`bÀjî”3Ú“oò³à(¯TγXOþSÕ±wvŸy7yAL &l4åϳQvA¿y˜©IW'Xxõ$›$–y—èè è²í. ÏBÆ#‡;öÈt…z‘@ZZä¼Ñe %¸" ×¶°ÿˆÁ‰T¬!#‡ÛRú;¢»±v¦éÖÕÕœõ&³§gOf³úÉáÚÑä0þ#¢¾¤ÜVðÖÎA²NçÚ|Æó--Œó¡ ¤Hœ'PšëÕªÿ½$ÿ2úUŸ*mŽ2¦$²uE¦¦ïïÞÝЬ'r[ejE°@tKQÅx²<Ôr6Ú¿åWÊéл›­ú/âÚݪöÂ;¯ËØ?„W{ô1Šlö”l"ºÙ¹p¶ƒëúõ›»w´PRï÷Qïµ)k ±. ÚÇîüù.ñ•ÐPee=U¡ÖmVº€à¹š†Á’, ²ó>½@¢åÜiT¿5µg4* ØŠHö`ÕûµÎÍÂðþp”DC1^É…ŽÆ.¨÷íc"ìQa@¬b¥ÂŒD’/‰~³BúN£$ºˆ-—f¹ Pfa í µ–žÂÀ¯õ‚¯oaê‚NçÖ†­¸NÉo«¹-™Ù 5ßµ¤Øö0JUÿºK]k'(͵@œZÆž|öãŒ|@¿ëZçà Þÿ~÷fçÿ­Of$\ÊÛ~’R`[BÁUÆGrÌuØè–aåH…rò)-Ób@§ 3úÁn4zÞ©Úb‘£µõÞ°/ÆŒ(&…¥A\¼+¹„!M&%Ðß•ƒ›:Tç*´°RÎwRë¥qaA‰v("]0•y?ð˜wìºaªF›ËË6Økü—ÝO„ûd;•‘©-lËÁ«:^‰Ø:WiêBƒËH(²÷Šn­e'ydÔ1ãËié7ƒWÉÞZUhÇž‹kšÎ§/:]þ\o|ƒ.Š!Ã7n3ȃ!crØ J— ðfÇØ·3Oh[»É£¥>/XObject<<>>>>>>endobj 5318 0 obj<>stream x­WïoÛ6ýž¿â> ¨‹Fò¯ÄM3¬@ê4]€ íÝ€-Q6JtI)Žû×ï)É‘—%-¶¦0lét¼{÷îÝéÛÞøÒxÂÿ“|ïÍlop±ý° êŸ è(Ó,£Ñ€&¯†ñdò’f©·Ð,éýB‹$¡È-…•)É;‘¯´ŒMóízmÅ ?£‹þÒä²?—â»–›þÊš¯2)]_«9E:3†®®žÏ¾î (ÂqÚ#ÿ/j=ÅÎðýþÙ±AF"ŠFã:¢ÞyFåRR°AfÞ¦Çݧz„­°RŽ“¯”FÜ‘ :‡úþ>mLE¹Z,KZÈÒ;ÏŒÖf­ŠIk¥õRÞ¬„¿ÒPå$ÿ´”›´Òò¸ f a4Åã1M{l\ãõ+¶™OEñ¬$mDJÏâ~©3Ï(ÙÁuóä1§ƒ$Î1%¢(LIf…¨êdÌœa¦ Y{lÚSÞrU²ô·~Seaiˆ(©_9˥鯤ÕýÃxxÐWã£I¤UQÝõO7…¸@xÒÆ«’†“WqÊÂ僗¨¾×ÉîÍÛwçï)Œ{… ˆR™‚ÄÜØ’‹±}²ñ(ñúõëÀŠ{ŸâáÄl‰"‡RáËBÒ >a.Áð3aR$“«„C½‘–1ôà'0|ˆP-Ü݃[ZÅô…IÑá’’ —•¾¤2Ýg· $#ÆÊm\)s*ŒÍ…Ö2>’¥Ln˜–™\“+E‘ ›ÂX.¼ q´„o*·žØ5—zç˜f¦å=sØ€áÚ˜RE'|ƒ|ì62Ÿ²åŒ¼ä£iœoL©‰éLYW†&ãK _hÆÐ@ò®”…cVÔ|_«r Ò—VÐJà«*Ð ¹Ç¢%‰ó \®{fHÒSöÞÉ‹{¼3ÿoMëŸ ·ýýY3.²>¡Gô1(ã=-޶n~V&Ot)mÜn¥ÞláwµÂí°éâôúâüͧ“O]<™ý¾Ã’Å­²¦ÈeQÒ­°JÌ5šÆ 8‰®Òº¿Z]ñ%ôò¸Û1gJ!œ’eö§ÂÙG_“X3ïÊ%D¤qÂ߆ÇdSEi¡Ð ÌÑu¥J¤bçIUà†ÊWÂɲ¤5yŠw"«•VM/úãx\تðÃp*~Ì¢ý2z ¬P©ñtD@P‘>EKàM;%ùíÞ°xwK¶33ÏTÁ‚³¥‹¢à±˜³^øùðO‰ÑibŠL-º®{tÕó½võœÇÉN嫽æmÇ7Û_ Ö8<,D éOSÅòÉpRXŒ'î Ç·½VËLTºì¢ÏR}gѸêù¢[ù­ýYƒ¹(’D:(*2ãZ­ [HŒx·@ßÄqæB"(¯+ý³W4„°dØ–¢Ñ„åz<ŒGñ„¦^¯ÂyXg@ý<8BÆôõŒŸ¾xÑEŠÄì꾓LYã‚ò9Z{^ ¸4—˜-Ur³¡úÔ˜.Ñp¡Û˜hLoiWVâ“·œµU%|â2MC©›¬Kq³3‰J¹òh縃ú£•8&8ÁYL'¬M*$´úΓPzî‘S.¤»‰±¼RèM#Ð#ŸóÖtWR.Léö»iׂ·4•æYFsŠíŠ1epLõ1“d«øO5[«E 8›fPĪ¡”ß] ÿl‘}<ŸÂ¸5Jîî~À,l¼°¥è¼Æ¯QÓŸÞî8 Di§EÏÇQ«e³¶q»[·WžÜ‘AžºÃBK) Ï½‹MÛ x7–èE¬~eæ5rKÜÚØ›NöIeÞ#«ð¶`—¸ú€ ÔMYck!Á˜ŒÙÚpÔËBÁmÑßpj—žHO¡¼áb³ òFÿÈ´ÿQVLŸ Cçþâ{ú©²×z»eÎCì¨ÿ‡ MTY'ýÆFXƒQ\¨wØ}¸›õ• ¦!*ÂÑ Û:Í(ŠZ9eEµ-™0àÞûàý¦xQè¬lAN0ƒy…\ç¯55ãß-³&ç=ÑoÒòvèãõšwÕ;ŒâFI%IïÞÉv¼]xN:‰@øÅ¥õÖ‹ à¦=+½d_'v³*¯]i«;j8)pÜ5¼^_~øüiú–U‘_·R™AÆ‚¢%˜·¾GæÂlÂÁAÊš´`~/$ž¤O©ÖCjô½€CŸÅ…¢Ó{ñvÛc‡ KÎLh×îq)Ú#$™ Çz©0 yŸ‚Fg¦Â0˜ox*m8í¨~ âÃñ!M^ÖƒïòËù»hèÔ$UK ~Ûèexëóãö>·ê† Û&ñx„ÉŒQzptÀ—ÞÎöþØûùˆ@:endstream endobj 5319 0 obj<>/XObject<<>>>>/Annots 2644 0 R>>endobj 5320 0 obj<>stream xXïoÛFýî¿bѰ‚ˆ´~زs½HÒ81Æ>[Á}à®È¥´5ÉewIKêáþ÷{3»¤D%E. ‹â.ß̼y󖞌ÅÇb:£Iq2ŠG¸B?ÆôãþÃÉä*~-ÆÓi<…˜]ÆWáC.N>b<õ¾<üŒoÇñì`éÛùÁ³øv%ήGâ*žŠy&{=Žg³K1OÑHÌ“Á Q)›‹H‰ÓÆ)ñΔ™^ý$*«ËZüðÂþO’d¹\¹ÿ.å?¾œÿqrv}€´q„£É4ì>|¼½Ÿ?~~óÛûAÇFè Æ’ÒlŸ œÉ&ƒ±„’ñ·žY="yý ŧpê»8+MK€[Øá€NÓy‡È? þ·„%Kšü4È!OõYKF*RÞÙ _îþpG(~„/cñjJ 9õa%lwwž1­âæ!Ñ•|+.” ¾—R ë¥&œ¨ýƒ+¬9œ4ì±! ¡À÷hȃHXfÈê>÷8ž?ÖXKý.W:f•¯0ÜX»žD=$âÜäkXÞ~àÄ€,z¢’%Ôhäˆwè^•´¯/A ñ¾/ƒôF“ÉïtOâK¼­ 7 ´±kv-qÂëN¬´ç~:ÑÚó˜s8au7!`¤¥%qاâÖ¥:±À+&]wcõSºNâÅËawŽMˆM ±U68âÀEÃÏ’í+×DG¼^ÆP#r@Ýñî[(è¡Q©f)iàžåß È—æÀ?Ð=ÜL¯Hp#[Q³AÖo`.ÓTÓ§Öï‡=@+›É§÷Î ‚…ÞŠé„sLJvÓ?]è 3ôn¡Íb+*~LÏÑí5êö— ›„#-k™Úª¤ñv·çÎà]0ÔZ×ÎýužŽ¢C$Ïþ0Õ /Ÿrß R<ä„w¡¯+²ŽH"¸—%û8ú†:@{Rн€d,0ä|ßÃÖØ4¢Ýw{^xž¶c2:/¦bv5ól%E‹&x[ø«IšÎŒÒ"Œ.oté_uq[ÌB[xÏÚŽsæŒGK¤lßÒÐ6£Y>/XObject<<>>>>/Annots 2646 0 R>>endobj 5322 0 obj<>stream xXÛnãF}÷W„VF,Ž.¶ÆãÅ.àñ%ñbb;cgý" h‘-©cŠÍt“–´_ŸSÕ$%*š…w1Cdߪ«N:Å?ŽÔÇ¿Æü?^õ£>ÞðŸÿùöãÑà4úDƒ~?úLK:Eƒê!¥§£/Ï; d•›ÓÇÛSL¡çvÆD6ĸ»´I™jBÅBoheÒ”Tê--Ô›¦ÂÒT“Ó±]æ&Õ )OãÓÞÔ¤×…μ±™ŽŸ?êSoxŠ»w3ÚØ’”Ó´r*ÏM6',_j•’·³bŃ3ëhµ0ñB¦Ëi™Åpéb‰>‘16`zŒóaPéa×B“WKM©É^ù_¨,Q.©L Ù‹É M7X ŠæìˆžÆÓRm(wúMg…lÈÛÙûÑ]!“Å/&+\#sg§©^z²å©*`"ÂIež[W´¬YZÜ£æÿÕpštu4N¨gGCÂe¨—á¶¾sf=9'¼ýL>üÌ‘ì ÏùgÒ ¢})Mš°+µK馉•Y¢½˜,±+Ïí¢A‹ÎÏy“f½¢§—»·ñeŸËž­t¶œ/Ò y³4©r<‘¿ÄÚW¾_™bA¿ffÑ=ü£Òt³Ø•bßÛ–Ÿ°\Ü«èúë×àÎNR«„‰UxÒaÄß*®^Çp ¬úr©}ÇÒ³{ärbÕÏ&v–ñHÿ6¾6¯~ø¡e‰J‹_q{«¤D 7°¦¾µìeqqÇ8ç4q!%$ZbˆÕ¸ŽÒõ[™e-3g—t ¦6ÇOE™ñÈ~œöÓ+ kx#dœ#$[jb%wg£LFÛ+V“q€—N‚#*Ïšì;†ôV—¾€ISÙœ÷cÏê–oê ×púÒ8xŽ@ùBçþ‚W€Ä*fxÈuFeNŠ2½¢•u¯>WÈ#{Ô—yþbþƒDf0y"”˜Ï@À¿ã©ÊƒÁyEh½Oð'3Zw2">që7ë.¸LÀˆ’ÄR0 À™±3Ä ùÇØŒ8`«ePžB¦ï@K¤3õFèJUgSú-¸>k×AqûJsªQÝt«Ü—p¹èP›,O!Ez6@ú{€üvk,VMU9×DÅáçßÇÓW(dz"ñ;X»S3u Ê– @bI ]Í#˜˜½Mä[œW•ê0}D˜ÉÛ">laPÒ»¥Ñns‹¿TJ›\OÚ¢7´"¨Ä\«S¢$MõÛfÖ÷ÀR¸(Üëÿ,±?×úåÞ®D••äÂeè… µ‰ÊU¢ª®ýª„ŽBöÅ?¤[ÐX«€Â-RXrýÚ6º„èˆÑ#̑ڲ{Àk ï{ÂENƒò*Ó‚‹‡T¹©fŸq\%±Y‰½A°2CÐ2Ð}–\)ö:‘mŒ›–5Mˆð—Ìxí ;xUà&2“^ ¢<‰ZüxÛ§st3ÍCîp†Ñh„§¤{ýðDÿ$F\}ºð0o[!åï­ŠþQ\\@æ“îéä¸=)wð%u>¨É$ëÈÐV³÷øüÑY4†ªÄùÜcECúUzˆ=µÏoE'›-=ZÒ ŠÃÓkfW(ëVD/”dèÕf¾B´ØEÜO°{{sXõnÁ[siö†¼/¼¬÷åpaRGKÆJ 'Õ¾>˜³M^´¿$àÃ@w§-Ü~g¨?tŠ97Vá†ßk>јà„Ô®z)·$@!Ö°²>ä˜Ðm^«0?FO,_B‡Y‚Š›8Ü—] =^fÒèШJ¡‡:á| (*¡3õ‚ÅBÇߘØrOc.UÝΗþ{¡×O}ìtWýdW¸)òÉԗ괳ʮDã"?^»Þ Tš%È dÞ¬ªxS¯ƒæ›†Ò!‰ä©Ê-«Ô}ϰÎh|~…:Á`ë £>ÔyŒ¾7+¤îóMå0¹÷‰{ 󟮤]e¦à2R}×i¾dðʳþ8BÝ–E§çc~uó|ôËÑŸK–ÕTendstream endobj 5323 0 obj<>/XObject<<>>>>/Annots 2649 0 R>>endobj 5324 0 obj<>stream x­VKsÛ6¾ëWì¤qK·$>ôH:=4Näñ¥ÓÖšéE˜\JhA‚@ËžNÿ{ H‰Œœ6™ZJ vûøö[ü9 aFŸâ…ûO‹ÑŒÍè{„îñëí(IBCÍX$Ë9[WîGçëæá‚ÍÏvÉD³•׌,<.œâ»ÍÙYþ@½ƒéú „lrrj±ZÁ&ó¾Ì`“qȲ°®ËÔ UšëÍï£é:vü$JXBÁ ä­ pªòµÅ Di”x€ŸQKx¨…´Q’@Qð23° ”S?hU[Q¢Ù^3XÓ+|âE%ñmsä V”:3r‡F,Ži•W…Êj‰­°“¥}ç]ÐÁóÔný/¾½þ¾·ÍëG3ñ¦c¶X,úOê0&ç½ÛŸv¢6ý#^sø¾nyÛ89¥½9xÞìsÁ­T\Â#ׂ?H|9õCAŸÿ=åVRök#Êá߉´³¦$&LÁàþ·»[Øa‰š[4À¡âBƒÊϪj÷ܺb¢N±² ‘gÓƒÛ¬„²@U΄ƒ À­åéž,Ú=@@à Ú¨à ìÞm‚áBéÜKà ìú`°Ù×fLv7(Rü¤/Žéùo0éWé„7™ª)ßp_ñâ¢à ÿÄŠ9MÑÊ;‘+)ÕÁ|!v*íðûºsgüj»-_õêKÞ/¾ƒ¤-€â´©û¾Ðq×w9U«+—a*©·}p&Í! v7¶o- î!À8h^U÷°™¨R>w–üh-•¥²+ ~ù3i5@¤$-SK‡>W|ÔZiïºç‡º )r‚Ò™(¹>7§Çð¬jHÉ—FQc8Ü ¹EQ[×pƒh ‰ñsèé/g¥C>Q÷õí¹†o+n÷ýR^ýÝ“>¹Òû7+Gÿ½Ò‹XÝ|Qè`,6®˜ç” ¨K+ä±ÎøTI‘ KµÍ„q)̨ Jô i˜h˜îËÉ&BÂSyã‘FVpCôCÓbw*o›:ÏB-j=+œÔÛ‰€q¥T%õ¨&ŠÓMð¶\HÓGÖ‡°GL¥ŒŽ¦–ï¨9L…©ÈÏ)•ÚÞcƒðŽ›>MWÿHˆ² PÏà†Ô6\ %hþ¦Sxßv»¤‘ ]Í]»ˆ²ªÞÞ.¯n#ðÒ¾<·ÞN0çÔØcw]h¤ýð:cŒS6ýõ¡+ìç4áÇw„ézud®p•°y<‡Åò }û;…›…“ˆ.QïUZXZ?Ͼ(ÒFz²l®—®GóÙ‚Å݈—’ÕÒé}ØŒ~ý9 Ü¡endstream endobj 5325 0 obj<>/XObject<<>>>>>>endobj 5326 0 obj<>stream x¥WïoÛ6ýž¿âຨ“ÚŠ$iÚ¢Ú´‚um‡zØ-Ñ6‰TI*®1ìß;RR¢¤Mƒ- C$wïÞ½;}ݛпšð_Zì½™ï“1¶vM‡çc:Mf4_ÑtL'Ï'ÉÉÉ3šgaטæéàQ&WJK:ÿø‘ަûó/{‡çG4ÁÚŠF83šÎê3ƒ MŸ¤Í_ÄM7 ¦Ód6Ã5Ù r’ä7Q”¹|ÉaeƒÒ*í©_¯½x ‡½ÅB÷^~ÑÇ_;Û;éMÃ6ÞŠŸGôÎZcïõöuî¥Õ«+™ï†¤V´3±{n«ÖO5aÄX£Ôhç»&dJ¯ŒRXÚ;VÒÖŠ²”¹*ÝßI¹™Òkê“rú‰'+¿VÊbÛb°Üáf^­¥&Ú)ƒãª¥5•G"ûCÚnìV®y¾£5"ÀµTÜŒ€*+ò Ò®D*‡´2¶ýåç;é‰<§ ýÝ„”ºÉJTìÞƒœÐM÷’^WÚÿ!™CWïµrÁ”¼×H7 áYÛ{?+Áã[V†AÕÝÆTyF¥ƒ¾ƒZ¥[×ü ´ªtÊZp+e€¿RÔ‹|àæwSi@Ã÷5’Äßù2›ï˜"gM>± RX[‡mïtuå$ô¹*KÃÞèm›÷¾èºÏÅ2~›#ýewï ´,¿5×¾3Jp(×HÙå™úP‘ÊùðηœÁñb«òœ–’2µ :ïG#´Ä”–»àc»Â´!¶D·bÅ…L3P ^°À¶ÅüÑtE®üŽsöèøÍ3¦mŽƒweh-„<øá¦Ò‰%ŠÑM¯Ï‡þfÐ>Ú€™âÁºj»ßôêõûËŸ•µY[~‡èW ¯ÒtöêüŽÙ6©5µÜõèÒõVá¿vTð”…®Àó[¡ÖÏ,srŒK¡m£õ©(Ô–[Ö ÃWê1A­¬)°0¤Ì`2KÐS´*«<öù¦×„ShA –M7Êãpee'™,%ê‚)ŸÕI•pÎRiÍÚŠ"Ò ·AQ«Baà 4\MÞîxR§»T8–ׯ, n½ÆF+›nF¡ìÚ²¨Oð  ± j´5ö’ÂÔÁhÉo%s‘}5S ëUŠÀáeB¯%ÆN‡IGjbO‚j=}Ú¦Š.âØ¬eDºëm´ÆtÃq•‹êÇfFcbÆV9ƒám#óÏÙ䘼1<'tþÐ1ö±Òœ~zÜm:‡t6r~‡A(¸zpØø:Ûaéàܘ¹Á·Åßè`ÕÊáùiÝf'§GÉñì˜NN§É³øZÃÚ=š&czkÒªÂ|ÇÆÁ׸{ô,¾è„‘xFgü:Áo ¼éx|’̦xaÃ(|tzÊÞÍ÷~ßûïÓ)endstream endobj 5327 0 obj<>/XObject<<>>>>>>endobj 5328 0 obj<>stream xVÛnÛF}÷W Ü•‰–%[vœ¶@âÔA€ HkµÉƒcE.%¦ä.»KJ¦‹ü{Ïì’”E_Œœë™3—÷Žh„G4™ò/ÌöÞÌöFÁ/Û?fI‡—#: &4‹i<¢éË£`:=¥Yä¤F4 {DddQEóÞa¨?? øÕÁìëÞˆ†G‰zßê'XÀÓaŸ.^¼Ú¢J%…ÂÔ?ܿԚú05Óø_mt«ÿíHmýF•Y^³­_ ÒÿmÞƒüS18ïUhœ÷(Q%9j2Œ_$[õy>w‰^?Ç4DÂÃñ¤†¬÷:µNbÚhóO¢–´IŠc1 J—dWºL#éFT– SQ¡©´’Š•$%7,I[Ôl@—Ú¼YžJÞ Š…^Vá+^ܺÁoÌeÈDÕ¤%h¡—¥Å£-Ó‚6+i¤°„Ÿ³°[¬M’¦"d†øt{ÿúðÁ¿jèqºl$Ôj-M´BÉÕÏ-$åÒÄÚd2 ¼ÒIm‡A;æ/t–‹"Y$iRTôQò¼kþ½")LšHCµ}; «ÏïßÀDF aŽ´¤(‡kTL”ÁŦ ÄærþrEBEÔÉíÆ–‹<ï¸è]²–Šß2Ù®ìEDk¡B™IJ{|LU.me ™9,º4zÃADIvhY`Sl¤T>ŽåË3±„ŸÒ”jµDø¶ÌsmŠ¿—ÄÄèêáxÊøMŽ‚ãà„® S†èPiwÃw8é×!ü¢Üº)VÐ-Ç.@¹Z„vF¯“ˆ‘]].W, ]–©Þ S¹–) g äŒK¶¸FÒ†&Y@µ¦ê¾Ãä°Ih÷w0 W"Gv;ކãq0™`8E=$ý-Ã~ïM ¢H— Œœ›A5¸í´±{|´q—Xd"Ï]ì5H±N‘±çOšÂ/s›»—|MÚF¿öYÌ{ݶÖIä2ñ"™ÊB¶ÒuîýuW­Î»Ñôr×7×HkÞk´ôâëü )‚›Óo­ʽ£6híxØoõc~«ëGýVßå÷öÇüÞ>î÷ÖûíÐfÒÎûÙ ƒçn }ÐòЇº›Lž*w,… ØèŒ>Iƒ>²äYfŸ¦Ð³5ýÚ,‚óó§”ÞqõÎ8?okê¨ð ÌìÏçjÿså'z‡Æ¾ÁxÌr­0vØq߆«Ï³õà48¶±‹•ÀÀêšêà¶Ý“WI–¤¸$jx0óÚ¡ƒ}A¥ò“s‘¨Ã,“Ùë…û·d˜ k¥­÷J³ŸÚ½‚o]6ÛztÇDwæaFC­Ò* ·\¡F› ëÚj^fˆ,ôUÅC«€Ró„à8›ñUïÊçI–•…À@ò¶3J O“µtá·{åβš õ(䣿Þ ‚Ö¨ëqTiÈîLÄ'æÊM[IÜm6@´tN7(avãÄj•÷ì=¯3¾÷¡Ö7'±­NçúÌMÔÁÓ»íbÙTêE¶1n û+ ŒðW¸Sâ*ámˆZÖ×¥HÓ ÅNu(°qëºvbÈÜ÷n  lGº+ÔyÞ‹d.UĤÁ:Á%ê‚ ¥  L‰O|;2¯†!¯s^?óƒ€6ü~»¶=|; E}¾‡f›³»è5Ïê#l<Âé09¡éÙ±?xYÇÁˆÞê𨗙v§ªãe‡§þvwÇ1}òg–»:NFÓ`2Æi‚]}|ö’Óÿ}¶÷ÇÞÿ¬ÿ¸Êendstream endobj 5329 0 obj<>/XObject<<>>>>>>endobj 5330 0 obj<>stream x­–ooÛ6ÆßûSúbP\›‘ÿÆi±m·öbCôÅ<´t¶´Ñ¤FRNŒ¢ûì;¥Ôvw†8ɇ÷üîè¿;Hég£iød›Î»ÛN*Rúçû†Ë›1 R¸]Qìôšr§‡,±¨P:ÌAjúw°•ªFÈ,J¹€+ðEé€>ÚxzFXb!·¥±°35ÜIí{ñ©T hÁ¨Òz~WáFV0Ort™-—´“¢uíüB\ÜþÙI¡?“ ä­µrÜ,Ñ:i3»‘JíàÎʪ ¦¼o´Ú ¸¡íñ^n*…½°ÒåM 31 §†U‡b4¢·úʯßòÖç%Gb:½ 3+kò:CÒ ®ÔkE'ÍèÕ‘¤U­3_ ªü‹ò@‰{uV]PÐ%m‹ûÅý< 2»Õj~ñX.ß×VC–f²±u+ØãГå”èoiß3Q#å;DÕUEHx)õ‹K ¥\FN²BVd°€·œŸ ³Rª6»Ã¾Œ€ëÁ§Ï?@n(‹kÔh ÈLÎì°¸=e AH(A›ËˆsB{Ùø¯–ð„P#jÌù§ð†x’ðëÎä Y/†7£¶xLäç96Ž ÙÙ Å@Ù¡Å *­ yJÿOˆ ÑJ¤6¢gˆºßIû—ÀÒêY´NsÇ@;‚!+B~j†˜$-Vê ®»>/XObject<<>>>>>>endobj 5332 0 obj<>stream x•VïOãFýÎ_1BTŽ8? ª¸ëQ!]«VDêKhc¯“åÖ»éz\TõïÛ]Û‰#8q! ÄÌ̾™yofÿ9Ò?COÝ;-N>ÎOñÛ³¤þÀnã1Ís hz7Œ§ÓšgÞj@ó4Úh‘‘{}¥}^¡l¹¿éR&?_Ì_NúÂ8§‚ôÆã:Hô¨èOnäÙ/9å•J­Ðª$f8U%ÏH(bTZÃÄresm¶ÌdT0¥¸™…Їøz£Q<mÁ›ø7V¬%÷p®ƒEg’~iþ3›)¾}v`“¨ÆÚÚÕγ™ÏK¨’XÉ«Ó{ÉOßoýdueÀþ [r{—Ý`ê"Ÿ¡¾+ïÚyâï<øÎwk_Ÿ¬äjiWÏKîN.®N“DvË8vQŽ;j{oÑRQ’Ô[’|ÃÑâO>^¼ðÔ†öΤÜÑK¦ØÝ½^kp‡›2¦ßy±àæˆ,Myé8±ØQ _¡–àÆ§ž_9m [¯á²vEL5)Ž\ÇÑ;ËTÊ›ˆ•Žp” ƒ³™YVW6¦{iWºZ®t%gpC9`Q¬BX±áW$,¾éÈxI™0H‹@²ú0W„¥ÈËM“/ Ø|ýUéÒqbpa¿!CÉl‰L-8-*!-$ᬂXPÚ^ˆÎÕ®psWt¼*5bb•+m¬ÜÅ¡]w4DIr¿7šºÚŒ‡ñ$¾ñ€›™Ê|Cz銧_q`·ÓÎuOœóE|úûñ·s´À•«r­e+'ûèB¡Â÷ÁÁä†CÍ®Ž9ítE+¶ámξ£Ž?áä7îñÒƒÖôoSZ/ð8öɶÚù¯!.f@·ÌÐŒÖÕBŠôÝ1Þ¤»+kéú]Ô~\–kV$‘ƒ~™¿>#÷RB·U k=©‰Fj‚…Q°Gy:®!¶#sjxÖL刴þZŽÀLÕ “ øžQntñJ¨£@1=椸*3;?×»ä`²DôÌ©Þw×uÉ‹iÒ†ÉÊÆ}iÐ$ä NµQië*RTÒ wh¨%–3s[#¹ø.Ýoƒ>7›f™Ë­Ù;Ýl˜Ž¬Z–bæ`”A¥KÊ0pô+±\M މ’•WÞy+¤D8ÎDÉŠ…XVÌrtWc[ÕÆµÈºö“áŠ~tô¸%º/áNl¶Vã¾ßÝ»± ʇUêú¡’qð°~/ûοUP}xåZ?‹ä‚ð;ÁXµà®çÄë–èC°Ì4tÆWæ±N½2#û[…ÿè÷é#Ouyxî1œwðí=Ót}™:\áÏ'ËvÁHiK¡–€WG9 OæÑ@ SÂ_7ÚD}j]‰÷@íøµuÁÓã³nа8®W˜k{6ø»Õ~nü¡·˜®¬–`n*·ËâʵÄ2)ì>Õ¸­ïtÃÛI|=¾¦éíM< —/·z£x@¿êÔ/WÏ+Wm€ Ö½›pó hz¸€œÙõ`GXSØ“»¡{ôy~ò×ÉÿÍØ+vendstream endobj 5333 0 obj<>/XObject<<>>>>>>endobj 5334 0 obj<>stream x¥WmoÛ6þž_qK;Ô],Å–'q×m× ÖµC\´ ´DÙ\$Q!¥¸Þ¯ßs%ÇÎÚ p"–|¼{îí¹ÓÝÑøÒhÂWœ½ž ÂvfI§WºG4K)ÐärN&ç4KœÔ€fqO~y™Éé4Õú‹š÷Fóç/žÏþ:P0„@Ò{jé%uR…\¹)E>ïíËu"üó¯í©í?RøX0™ÃJÇ^ééÕ˜ØzJ`ÑÈÃî}Ȥ°’ŒL¥¡JSµ’t|óéú7z-¬Ší1Å+QVø1Õ†rm$©_sQ)]„ìØéÕ% #ÖÍš'ìâhŽÃKz_J#*ml#ÖB`±q8fÁW–tJ÷ÒXh£a8 £sræE]i6‹,Û_!ri¼\ÛŠbç8ñæä„tk¥O¢H(¥“ËÔ; Ø“:“´VÕŠÕ´)ð¤WVBÏj„BM¦EBa>#«i£kJtñ¬¢BÊ„ƒ”hXÚÐZ›[çë™!z©Î2½VÅr „.® <©à­ËR› úçÕ‡-Æ)cC "J¬´õïä¤ ãð¢MåyÈE ‘y„"Ü 2ÿpZ¶ ‚à@8ÐþOž?=ðüË—*øáP?à—Ïÿ|àyîÐCUhó4´œD`¢‡¼|ç¸À:¾(E|+–òÛõi% G±‘¢’$‚’_+Y0mõI‚26ÕŠ{~)+Ke&bt¶ãAÏA<<$& f4f?¦\ONÊR"A¶¹*3°£ —¦Y®ñcÊqyïÇæ\ó´¥×%ÊȸR÷†41©mmô™½ø¶ã)G7»s-ˆ¢p4”ô"fϳ‰£Öè‡Î ú׿'ä(”íxAïâŽžÒ D­¦ˆ«y#«<ŸÇ^ñzƒ€¨§u§@ú Wµ£(ï†`oÈ}´5Ȯ6бFê,R…ø “,ã€A7îcpÀDEH+á²Áƒ–»|¦*C|_‘¯Ÿ>á4û«ñah…Bï³~Ä©oñ:F–wµºFAÀ 7(z¨ „±¢LÝrÕ5¹Fµ}eYy„¤*YJ|4ú™4Œ¨¢Î@¯ÜC Ç -$0›.€ÍˆhÊÐrIz‡‚_´wíÉ…Ñ·h‡ºl«{7v FK*uS>Ø+TqKb¡k ÆÅ±‚ƒk±Ù nö«ÂVHÔ CmÚqÇó|‹¨ääP»ní†À£Þ/'g¾Yº!}]`y(±Z,Еo¨¥ô-°í ¿Wº¶íjâ ÅaÃ"‚s‰sp°á¼ËòÃ~ö1äá^sÿ; }ªK®µþNI¸p¤ ˜{ Ž,$âldŽ}„©„´II˜l–•íá ƒ]GÍ¢7,*–W‹®¬,ª&\†t¥õtúZþøÛ‘Ã,Á¾8Ní¨ÆÓ‘x¤d†åvÃî•kIÍÚZL¥Ê[eÀ¬•>/XObject<<>>>>>>endobj 5336 0 obj<>stream x½VMoÛ8½ûW ŒU\[±,Çq\ôýÈÂÀ6Í¢*šƒ/´DÛÜH¤V¤ Eÿ{‡¤¤HªEz($²Eμy3ï‘ÿõ<ãþLÿ†Iï· 7vÇøeý'ÛÂùÍæ®Á&c˜]yîlv AdV!ÓDDyLWNJ²¥ïû÷þ^,îiRÙ_Aóóbñéúþ,ø·w~3÷o`„qG¿Œë\ó¸xÇ vHšÆ,$Š .!yA.©yÆDJ°Ñ°Íi$7ÉîH&iÖNé¸ð…©È•‰Ó‰PÖÑÙËh¨Ø#‰ˆ”b|«wëeX€7ARK<˜ ´ñ+ñ:ð/UìXEÈ:£äÉIRäiÍ]˜½î™4˜[„ªQ@2„cŒ¨@xe]`ÙÍyD3Ã' ý9²-“WàMÝ©î¸î÷\?FŽï¹°ä)v‚`ã±#ú1%&S4“í&èSw>×;¯u½‰àfbÓ)âïú›-€í0l¬KzމR҈ɒ4¦ Æu6nDtOô· ›»9þ£ÉÄõ}Cä< †¢håàVØ1½‚ÂþdTæ±ÂÑÿZµg3r |ïao¡x×zÿ­]mGˆ,¥Ùޤ%)G€i2_[\ƒØ 8&£*Ï8 öo¯B ,)‘ŒJO¤œjC³Q%jS2•—‚Å4f¾b´”ª*Rš`=.kîÀ†ÅôÍ(-¨ê\‹ÔSÆÃ8(ôŸÓõËè<ÝVš–müø9¸û¬ÎÚ]Ò7^Þâšrƒy.×5¸%‡;šÅC²ƒ6'ž$"×Déɬ†ò‘Ä9}ÍHž«jxf6ýá´ ?Ítý²Zñ~»²Ëq'ëf83R—Çí ç·»Úç[¡Úã­^Û¼][»¸a²½ßiJØÐ¦5G·hO–*MàÅlÕ͸Tèh 6µ¼ÅIh{}4#„hŠb¿ô’ÚïKY½»å«‰q¶åÆ45üV rÞ‚öÒN®ƒ5£ê-¨ššƒH‡õ¹ÒY}ªí¾°_V'®ó|–ý2‘YÆ%¶øj?Yòà[{›ë 1P­¯-­Þq@ÆÇ¹¤#å:òÿJx69Çë@I®ÌhNõ´1%›“³í‹L«Î<_§ºç §[ŒTY÷!ËìQ”£•3Øwuýòá¡ý%$ÜLI…£táå-ö£; 5ê—OÁ—ÌU‡×5²8¿™—4o>u/ü ˜ÍñÊ癳ôÓ—å_£‰;†?D˜'”#È«†„žaW.m8¼/L]|ü`îœ(G¼4”÷5s,^Œg®?Á¦ž^ú3èýÓûwÞ"endstream endobj 5337 0 obj<>/XObject<<>>>>>>endobj 5338 0 obj<>stream xµV[OãF}ϯøe%%&‰“ÀRõ¡Ý–‡²Û­W¼XZ ö$veÏxçBˆªþ÷=ã›b@*U dìofΜs¾Ë÷Áœfø™S°v¿q1ø5Ìü^vÔ–N¯ftînh1£õû¹¿^ŸQ˜TQ3 cï^f ¾e†G^& ¯o>} £“ŸN¿§WKš#nCS¬Ÿ.‚f½w-è3Wù„Ö`qB%S¬à†+Ò©Üi²%1ݳÜrŸ®¤"þÀŠ2çõ ‡§‹…À›x#F?w‘- 0Wâ•ÊŽX‰a…¹û4 ^¼B˜r*¤6Ë¢‚¬æ$7dRŽ]ò8c9™}É V’²9×”i2’R&’œÓÆŠØdRà]ÊL{ÍB*î^’‚?sé‰Ãä .z-ÁXV`kÖí×ìTS§mn;žç5-2®¨Œer„ÇÓ1i.Â!šmù¤*lq­p㻽È™K±¥]fRÒ6ޱ¦:‚Ƨ-îŠuǹÛõ[³käÅ)S46ü›¸¯9õøÙ瘣BI;¦ž°1!Á,ûJhC­ij[zðêç¯a_h¯’‹Ø¼‹ãÞ2Ì­éz~—‰8· §aãígÃ~+Ì*…jPôOý_Kä¿}{ú¾ßÛà8§¯¥ò6啜ߤ©c®5,ä…™š´,`° ÉX[UWúUã '#oT™eB£NÕÃ,í[bø;L+éVª<“ÿ!Ñú0;t‡E™ÃÕ¾[®öݵôŠKUõ¶Ü|K|B»,޼?˜QًƸ U¬yŒen ĩЭ‡Mšaå^Z*²mj:ïn$Ùebûréû¿ŒøôBtÄ“oàiüJŽnäΑZùòeà65ÅÑɡŋ6*މ‚VseÎŒ™æNRã*y)µÎîà|”t£8J¸ëhÈ‹ W\ ô¹zûaHL®à.¨› ´ÒÖ5‹gªÑ—Ë«Ë/—7.¤¦j¼Á¢ÿÕèÓh,•p,IêžþPÛx߸¹Cù ê'/Ëä¨h:z¿Àb‡q¤ÿ¶mþº`²œD‘¹Õ¶õøi[?«¹]=?˜ÜHÓ6Ävtñ(|Ú7:+µ¬«/=¶ v0xÒ¶,¥r£Îý“«,®&MÏ| Ÿ¦Úä’äyížè¤)«ç æÅl鯂­—çN¬¿n¯?NþŒ~“1v˜§P‘0L]uäô¬w‚¹¿¢kQZL8GZã»ÑK»E«ÙÚ˜±õòýÒ½º ~W@endstream endobj 5339 0 obj<>/XObject<<>>>>>>endobj 5340 0 obj<>stream x­VÛnÛF}×W ‚6‹ºZqš¦@ëKз4V‘‡¨+r(mMî*Ë¥e%p¿=g–¢.¦Ü¦@aÁÉÙ™3gÎÎ̧VŸzøëÓp,¿8oý:iõ¢^nÿ¹9u¯_Qh’Âz|~i’›Mâö°W÷1/½¶†Ê$™6ó“É_­îõˆú0’ƒÁ(:?ÇÉödÁtóá··T™A0iϵ“ómJ´ãØë;¦Xš1•'ä-ÅŽ•gRòÂuNµQ³Œië©‚ÃŽRë(¶æŽ¸AAÚÐÚ–Nbe /º/^ÐÒÙ¹S9,ê»lïXD’F¼PKïÈ;. osýYRà*Ó+m Ê­cJYqJ³ÒSQ.—¶`‰˜HN¢àˆ3U”é[&p©Í2»þkêΣ¡Ð;~Ñpˆ§¤]z¯Ìœ¯œCâ_^Q·KoBhÜr´‰Û³—¶¿8§Öô¥F¾XÑw =@Â6¯Ih"óú‘5Q|ÑKï\"ŠŽ›ž€ô¢®¬á©Ä¦”ê{$PèÏܳyÚ(b5=iÀ(ô†Äsî£ØþùXØÉÇæ·‡ ¾äÂ;»zæ†Íß0Ÿ€™d YaŒèhÜ÷ µ™ ‘ŒÍÜ/d‰bŽ£zˆ*Ëiû ®òy¤¢5„J1BRË^ÒÖžsJÍwáñ:¡%;è.§™-M‚k±àøBŽ mä2g/®ªRê' ꔿ­éç7ÔƒÍóçxÖô™éÉô¤áZn²µõÑŠsV4Å%'ýÂÙín•÷´,¸¹Ùãíf[˜ÿÆÌÕÐþ/§õíºSÙÿÇQE”¯Í ‰„¢£÷ê[I:¦âZTu?y‘w¤zÜ0_JŸºÑ&f°†®2ÊÙ/,dÈÕWè›2,ªªí·»ºÿÙÒwlÚÙRÅ1hÌÒŒs=_xZ)Ü™1ÊÇ øÛMídÔâ ã‚ï=›B¦ßlM+§Ãˆ9hØrTn‡Á´H§:«Zh÷ºGG»øn6¸ö®Ù–‰¾S˜‘ÖÔÈ6}ù1¯U:Óöž5ÉØYu;m?«f€6 ßÓcÏšê? U?}Û\‰¢ÃVð/埠·mØvçÀ´M˜B¡°xŒŠjsÈÖ¼¥9ÈEÞ¯œZ¢%QZš@ZQÍsáN ²ÙHöÝ ±kátX3Éñ2C=áQ£ë¢æ5ý{{D@5ãjïชdƒ#¢  y” "HXl89%–qyCJØ‚bUŠP¥½Ö ö•˜Ó2ËÖ8êıbT{LX °–xV‰Ì ôæXð &6ûÖvûomŽÍ #)d‰è ­ …Òu¯Ï7¼ z£èlx†]± ÂÊ'ë^gõèÒÆeŽaKˆ¸Ö•qçeuóÿa<ë£á»$îÿèÕ™¿š´~o}Ľ#¼endstream endobj 5341 0 obj<>/XObject<<>>>>/Annots 2652 0 R>>endobj 5342 0 obj<>stream xÕ–Ûnã6†ïýƒ ‹*ØXñAvœö*M“ 7íÖ1PPб+‰*IÙëûîû%ù»íUEG”(rføÍ?ógoHü i<å+.zƒp€'ü3äŸùS/ ‡4šÞ†*h: £vÓKooXÐí4œî½‹¢ŸL†á ¾‹fü÷þî‡ÅÞ>~3óF× ´HaÐô7‰·7qpgÉfz]^‘Ë$ÉO±¬œÒ%e¢LrU¾Q¬Ik•ç´”$’D&ä4É•4ZQUÒPZ—1Ò‹*c‰¥”%\Vr Gª”iªb%KÒoº¦B½eîrñGo@ýá±.­J°˜‘©*yçá56×e¾!ìŒ_Œl%c…Å©.Ó‰¥\}lLøŽ7¸~Ð,³÷#l6…ã1FIðnçì›tÊÉ‚þî,âD>?#úFxgæ~>ÇÂŽsQ¾Éc´y½<±Xl´øø\Ü#6ˆS"?‘®]_§ý¥®ËÄ^¼^~´ôáVÝÞze¿z¯vàöýÙÃéô†½|.ÆbaåIr øk@qNÄYƒm‡àÞBk©^s–&S‚–‰æi—?ñ—G3Û8Í yÌÀEÞà”6À> ʵ#R¢ÒT¤DG‹’ÄJ«ÙèŒ ·©8–ª-ß*¨ éQLE•Ë!=á”’4¿ûééá÷‡ùüçykûšLjUØ7.¼“%¤)íb~œ ]‚ïEà0©öÄ K›ã¹gal4ïå×ç§oí)ˆµ•¦ïOA,sË,#© ¹* >^Uïß¿?±TU² IŠ3Q9 ­Ëîü¼t^øÑayì÷µuºP ¯è©®6ÒNîjDpA)x*4¬j¡²áëÇɶx´0ßë¢ÂšK•+·a:þvi‚å€ ÃáÕÎ#KkðN I‹3û¥s~6l/Û#ižîVN”‘ÐßU·ç?«ûkPmPÊÚ{†ò®–ù0¡8µ¥ SÙnüÿÊûYö]¥u\¡m]UÚ¦+ZÖ¨º¸,Â]!bOCZ Ø¥Ä)œ 6jøÙxSeô Úz-4s+¡‚AØî™‰†±®²£iPL È)•ðØ(¿ :ƒB XÃP^¥aZZç-x·4ŒÐù¾¥?šñmŒ¹ï™ËõŸÕ0N@!±ÜZ¹ŒÅ’_yvAó2Îfü½˜e„ÐåÀ›Ø¨%¾F´UßBCš7`d4puîšfÇ+±ÌÄJ!Y8aVÂ(][º¿æäÝYÓh5Ã}Œukâaœ·mÐo>,œ.®ÉJ ±b‘¨Ðé8î©„µuËSQ ar±‰6ý MN÷t÷áóv€ÿÙœ$…³P\C%Å^$w­ëN.ºühš·F˜Ús›µ‚1Dád<¡)zÜ‘>kB„îõGÃøg×"‡ßLîß4)ößÏy2˜†ãz[œnt;eý_z_ί`‘endstream endobj 5343 0 obj<>/XObject<<>>>>>>endobj 5344 0 obj<>stream x­W]oÛ6}ϯ¸Àmmù+qÚ {h³eÈÓº%h_üÂP´ÅN"]‘rýï;—”äHq›[–EÞÏsνý|4£)þÍh±ä_Y½»=š&S|Ùþ)74¹:¥Ù”n×8»|ƒixrøN­m©h[Z©TªÍfDÚ“Ël•§t§ÈùR9§Rò™ð䶪[G¢T/n?M®–µå!ëãW³! *ÕçJ—¸¾¥'»¦ÊÁÝ|¼þc<ûLQªÖ¢Ê=Ý—b»åww*;mKÒŽíMi<›#ä¡2¶Úd¤ Öy’Â)—Ðí£ˆÈšüàN¯éÁVt/ ‚¶$3a6HÆŠ„Û*ba÷ÛRÚë¢Ëñ{Uæ°ïU¹R%1›7Äî¹tãù’ãXÌ’ódFoÉéb›«¦&¤¾~îÖ€o&§|ïm{R;.VÆÉ\|”Ö VÒ¦Š6ʨRxm •[ç²ã‚ð^ÈŒû`q”SÐk-é’Rá·%¡+Ô¬b’¶f§PuÎh£Ên5×¥-($ ƒ—£P­Bo2Ï ÑejÃÍõ?‡v1·)½N\’9g7O <¥Ã“¦ñ£:ð{†Ûð¤Îj¨ÍêGD_›æ†Tÿ fô+ñ)c7»ë«á@›m…Ç_^@ÿŒ_¯†Ç+©ÐÆ”PË:cº “tµ2Ç#Ìú¾uÌ%Ih7f¢ `mr®ÂI7Lõàö ñ!PBFÝØN‚í=ë¸ãÅ"Y.ÏÙv²"¿h¯sVjáÿ½öYDjÛå=d{IèÚ„Ö: ë@ô±6ÇT(ŸÙô[£ñ ¼il’ŽqV†ƒÔ›ªPƇ —“ËW¯À/¦h 1b “+j´&îRüfÏx •choÀó}¦e¾­A€ 󜵄ϵJ£WÅ'ºìÅ RÀj`5¬Å¸=íD^1ÿÛü™<‚LUÜ©’S Å9–ZÜ—[´†ª=à`/•A?\ðƒëŸžõ·^ê6‡›Ìæ©*ùc*”B ǹ•£B¤\–~)ÂÍzÙ³µzÑðbDìc¦jÀÕ4o{]f99 ó#tØnYÉXpimóÜÞ?# hq#]> D¡öwq‰·ì“. ¾{Oî¨FVŠÔ¬%üaùX6 ¢p>Ÿvˈ=ßµ˜–QÀÑÛ½Š»-Ÿz€÷‚UÓŽŒ(”C·v6ßáÃ~64“ò3.„—<:0=¾&δŠÛD€ih¢„¹ð6vΫ"¡ÐP•OdŸáÓýáYrö{AÍè Ï^ ¹1ÈTÚI °‰g #WA<€ ž9Èv€C, ˆ4ÅH·&êa£:1ãŠ}ƒ| %ˆnöz–*™ ‘céLØgfaíôѼ3ÿûÄcVÔóí¹ñöqV'Íu„†-¡Ëœ'ó®>fìÉ„ÞÞYlOM•yU‰BÞt4PçàHÜ3çúñʉݘ¸£À³¨÷Pð¦…5ÐJYaôA–,æxŠ%Tr11âjñöµ¡|nAâh½ñ¶_'V´v”þ¼À׋B{Û[òn˜;˳‰™#Ý”¶Â"óÌ%«°Ä6ZòÀºb[.é%6ÿUÆéA;rÅ‹Û×NSaa»Ù½oµÑ`Þ—æo ¨¢ü2Ú¤­°âEOrÄûùaáæäêu½rÌ^Ÿ&g‹3Zž&çqí ÿ•˜'SúÍʰ½²rœPçxz|—ºŸØÜϦËd1Dz=íôÍ9›ùýö诣žÏ¾endstream endobj 5345 0 obj<>/XObject<<>>>>/Annots 2654 0 R>>endobj 5346 0 obj<>stream x­VYoÛF~ׯ.@ÁM–]Ô@ëÖižÚÆBýB X‘Cqãå.K.¥Eÿ{g–‡Å QôP—šëûæøk0…€~§0_ñ_” ? 7ü1åï  Ë™?ƒ Kÿ¶~Vð<øis"í®;¸yZÀ4€MBjWwô;môy/)jUÊʉ(vU†Ú‚=昉d 1&Rc<›"´%=ÑIı„TèXa ‚ÞB)õN!üŽ…³ý„‘õa“’¡”9”NKRéÈJ£ÁšÑæÓ €ÉtFNy[„ª$EJ¾" Ò¥ÐÓÆÊ!5wU¡ÞÙrQˆ -ì¡É¤µ‡£{ÖvóÀÚŸs´3Ò<›ùó9b?‹,Wx™JÛÐâp<üÉ-x1…ЇáèûÖΑ7íjõwÀÞ&¤šÕ/ýÕê–¥çSÿ–áÀ—mþÊúÆ[ö'³…¿`é %3/p/MUBIYâtH¥ªÒ‚‚¡a(õ°Õ‰) 2z…¥ Ÿæ—rjàчa/ ‰ö&X& §PRºR;àÚ¸\Ò|a{t vÀe&®úðDF›´þ¦u€`~©-ˆ^ù`èí êc8š 2¹KmC!’©ì[LŒsÏÆü<ˆß5Ì =ÒŽØ0üÝêp¨ý\X¡á(÷52SX¡BïK„Y¶Dû‘þå>ôškc¢Ýû?IùÕô¿.P ìåõuŸ+ÿô‘®¹1o¹Áh'† €±k‹ë{!•Ø=kETê ,Q† ó¸Ôá¨oÍÑI=Ö )ÖÈÈIWºÂëêØï›s~×ÅøfÐeú›;ÝÚªÐDFUQ·´XÖ/.±Ç4¾$Æšo˦ÍÔ¦vÊl…r•ÀÙ¼ÐÜe øBûitM¯» IHù?¢B¡K¨rª¨.«-b n{'ßDÔY/0K Άù[e™"×Õ‰®¨&Ä¿ ÓãER˜ì$ˆKpÊ0ÛâYf<£uÍ‘úßãõ5Ô VPES–@ ½«ÄËpt¹Å³YûP“ýÿ²¥½žÉ%ÝT™¬‹º›…MH½ù4umÁÍ&‚ÍTçãêøúxz‘ÔŠi>7"ã˜àÒCÀó¥Ì1’'…Vò4KDD“ë@wI¶Ïïª>·£ÐƒLAä9•®¤bxdiYyçD4i+HhbÇ.O(ÖÓm Cwê¯G´ðxM¤.À·í©Ý‡¼!D©È©ŽšÝ„דÎ:ï9™!O"“e4•;o¾Öš¯Ü¢pó´nzö,XøËùVëÀ_sï~~yÿn2óøÙDn¿<îÙuê·µìä–ûý™-b¬üùŒæ -îÖ|ù—ÍàÁ¿óendstream endobj 5347 0 obj<>/XObject<<>>>>>>endobj 5348 0 obj<>stream x•WkOãFýž_qµÚª%& ~¢t©ÐV[JRö ìIâÅ™13ãDù÷=wfbÖYÖPˆòpîëÜ{îç¹3¤þ‡4žð#]u~ŸuÉë'³ £«ch6§Ñ€&çx—y¼I»tI…NEAkarñXHJµ1Ò–Ze¹ZÓä–’Dê*¹m)É–2Íç¹Ì(Wþ˃ٷÎÑ*ñYº¿°ÕJ”áò.y—²ÜÈÔåk™Ð•6p.+‡´E%mqrKxˆ]Aì= þp„z»uqn)ܯ–lU–Ú¢”·ÔEFB‘0‹j%U rèʽ–„±!ଠ‡Ü?}„t•Q>G£–iФ ¹ÎÆJ?zXMèüíè˜q\{“~ü†NøÊ}QŽïéy >ÖȽAKÞ€å}‰°ÏnýüvmÐÔ„í‹mI9|Pb%–rT¥0°pÒ[úFÓFXZ —.eÖ›YÔ;Rò’2á„'fŒJ[+Ò°5Iі夲6_(¿kil®ψùóFVºïа.¾Ù)´,¥0„ì_ȹë/…Êú6ϤŸ<]2ÞšJ!·§´.¥ÙïšñªxÀxµÎ䈛q€g¬(/¦Á© MÞò@9sÀæ;¡³õÎ~>ü؉nBEQ/–Ú¨°©Ø_EÃ0 Í+…]× NÍ’i׌*¿C`Y^@Ft$7Q ˆ›…ÂKð‹mB+]ìvõýæyÆ î—Šœ\\j¤pu²sbšcy.~‰ÇÃä49¦­œWÅ Ð&WýÊà Kÿu)¹/¹óЃ6BñrÇz§d*­”Õ´Ñæ)Ê$`or·ô+xÆÙ÷¨Rsm\¥Pg±ííú%ÀÉJ…,Â>%t‰öCß#cê}à¶.*g?€#ª_Š…$M MÝèAªž2éD^ ùÙ%òB}W+®¶©^­´bKVã—¡Æ·³3Z‚{¿Q‡‘s\V)ƒkD\ê *Ž¡ƒÏè¼<-¦_¯ÿÜÁóž«ÜI’óy8Ib— óô¤ô†,”/ 8-óΗÞïã@áå1ÁÎo”sÉTªAEþhp$J–HÔ/p¶d¼Tq Nª¨.'ñð«•Þ³íZ9¹À2\í–!pd@gÉ8ÈýÑ(ñ)ëæ8»ˆ¦ëë»ûîôŽï~ÛÕȇvw­óŒÈ®¬Ä)lìºG×waqöíƒèPÉÍôŽÍfV§ýûs#ïÑÕ”çþhœL&§\‡‡vUhú}£9Àûfºâ;ŒéúK+ĈQEŒ=Š~þ|e„Ém¶*çÿ_X§ÐX }Æt ç¿Ãéú&ÂìÑtvû×§/}(økSe‡0Ù²Fí#ôÛ.*LRÀÙÙ§-¥'†/Ñ“ƒ3Ö~•lóŒ „/Àíõõñ;žFD©pûˆZáxû=8»Š¢c;1owÂb[—-,S, =zØ/´GÞê°tf¿æ—F`j¹ 7tõ©ÛñÒíéú6¢FrucxvœœŒOhr6JNƒ°öõGÉ€þЩ¿±õ7 û¬û§¡ãþD‚†„³¥¾gô8L’ñ¿°¹ÇççìÿiÖù§óâ°.endstream endobj 5349 0 obj<>/XObject<<>>>>>>endobj 5350 0 obj<>stream x¥VÛnÛF}÷WL  d‰"%[QæÁMí"hº‘¢¢cC-%6¼…»¤ªù÷žY^j&b ¶`XäìÌ™3gfçã‰K~]šÍùãÇ'?®NÛÁÃöO¾¥É­C {F«€¦ÍŸ¸ö|þ˜VcåÐÊ·ÂDSõ£ÊûP ÏZ®i8"'r:O«?O&·OȽ´/ÙÍ~ÆÓ…í?Ö̵´:d2Ýü%â,’ª:sI."@9ž^Ú ˜m¬Õ.T¤¤¯Ã4¡0ñ£b# äžd}šÒ€tåQÙt›æ§¹l_è‡Û¦(M?Фw’‚‘é´Š fLl+“yte«ý¶‹É:%‘løйS†öåÉBøÕÑ01—¿¿ø™¢ð}.òƒ]'8«rž³WæÇvéyš”2×a²E²wŒ‰Dž‹é*®‡Ý8mà|c]“ŸÆ1Ëòô}$c0G±HôœŸls+¯Ì¾ûR)ùòÈD"ඈe¢Õˆö»Ðßá¤B"Š” ¥ä† | ´4èðóêÍË—¤e‡‰Ð0U:GThÅä§Q”î9ª!¢’y üª*„éžËü0ó\2— lÀÁ{F§‚­j:h#´à*ÔÜ>Tòx:µg3èzcÇ馈Lze Å‹ÉИEªÂ…H:—LÂÄS™ôC‘/”lR6Îk xèoÐúÔ1ª»‡®Ñ6ZÆ™(Mϰ®Œ“æý‹Ù”"™É]…v¤áP÷x ò¬GËòõ¯¿xÖY˜d…öÞà(BFâç©øàY§×µè ²H HJQ’j°ßÖÅ>õÇ!™ ËrõÇÝ ÆEùzý04=zF˵¾¿[_¯ÿZ†ý(*²é¸^½AÈqä(ˆòÿxVå¡/Ë3×ø®¥‚úǬcß³< §/¦Þ`¨Â¿exVeÃÄ`ˆADðç<¥~xf”@áÅÜ~ê-–.+°Ôþ®;¢pD"5Âê=~æ¾ ß=ȱ–åŠ5î^Þ'¢ïç£>< ºy~n¾v;ϤH™MmÏ™é"ŒˆjpIuøà·øßþ r)!Ôo6!ÛAŒî—‰5 µøžó0WO‚«‡çR=õx\fFO"Îtü`æ5) ]S uØ”{ð;¦E|è›|U©Z»“Ä ÖÒ¨’suI5p&Cº ·†<Ñ.ÝWw†Ä·í%íD)i8éäÑÈ w¦*“ùaÞõ·27ÃÅq¤HÁèÏäNš‘¶wøÝ÷w7¡‡¾Ñ9\iK ŒB‹ÛÓŸœ3,•ÔYÉý½äyRùÕ÷l…ß­W‰ó ‰Å(¨Gð×禒íœåR‘†Odóz}Ÿ¤XžZ¤®Ï5Òš6é×^úLÑ`%ˆí–ò«Îy!U úGSPw¯YúZ ž‡‰Ù9Î?u´ÅÊͰ6è{ÄRÍÜr`¨£kË5i•ÞÅįyòY”úèq¶«âaFŸËó OÄsåyÉ)OÒö¸‰0¹]Ô‹£»¸´¯fW4_`ÕuÍ¢Á›Íxj;ôSê›EJðËùa'®¬Ç+`ë{Œuù’Au)ºræ66³\9¿Yüvòò<5Lendstream endobj 5351 0 obj<>/XObject<<>>>>>>endobj 5352 0 obj<>stream xWmoÛ6þž_qK“VumY²“4mÑ¡X^Š èËVw0-Ñ1[‰ÔHÊiPô¿ïŽ/Š•¤Ù°$ˆbòtw¼{žç˜¿·rÈð;‡éýõÖ/³­,Íp±û¥Ïa|šÁa:…Ù&<ÉÓƒƒÇ0+U³"ø%=zöpöy+ƒQŽ;¥Ûù~cEsÛj ¢oí0¾9ÃïÎ̃bÅ4 P c¡ç.ìœsû‰és3Oæá[Ï‚r3–YQ7kVµÜüõžÃ7Ø>fk¾=„íWâ‹{¾k “´ð«Z¹ç+Q¬xUÑfö½Ÿ1¹g¹¼fû&ñP¾»îãøtèóFxÖÑt š|Xq v% Ôªl+øW¡êFT¼â‡ Íš†—pËVV(‰L‚Ckp]H¬Ö[®+0…f`©ªJ]˜§T•~/G“I:bgËß,ຟý †Eš'7ŠÔÕ†éËíùÃgTˆðuŽ4g½a*Z³KPK¬¿òÜôúBÑž>mp£kÝüë;‹Nãó¼eÆ€°`¨VoÔ¡ç{gyû›ÈØÌ3ºŒÏ{ð’c¹®e K­j8ê9w)ËÅp{>—Ûw9 Î1m:&å­ZëûðòIÉ~„À4OÓI€>xPù"f1“½tšæ ¬0wMÅ „"¹†¶5ÇÀˆÿâ 5‚³b@¤;¥0Cã¢Õšl]L²½ÅC£ð\#.cEð eR(i™k¦[ |}â¨0ì 5Dô“¤@ çktÊ@ò *PÓÆ,ÿ¬, üX:"ƒÈcVan 1@Lñé"þ…,4§Óò2…S¥¡n++šŠ÷RÝto<§–B¢ÇîØÿ!i0+ÕV%±ŽŠd•E²­x ,\/FÂO\ǨÐ×̓‚ø^G×RYà_ Ž5¥WÎ…ìÊc •G>\ª›JÂV—ø§åÒ¿‡%ß@@Ì…W&3*_RIR$© w­'ÎN^“¶úÅjVhE"#äÝú²k/^³fN(À¡L#oÞÏÞ¾ŸÝ"ÙD±Dñq¨ŸŸ#xmHÞ#eéª{5m67cÞ¦æ7„e<€“«By†,.qªÅg^`jã[}÷=FÛÑÜ ÜPuÌú¸V1Aë j´G+íXÏ“‹äv8OÎþÀà psýÑ{®ׇl*w)Ê4( 58Í)úsøp|¾šKóNÕ˜hÍê"`Jn„vì^"ÇX'"¤ÈÉ, ‡Á !,9†"¹AGü+«‘äi½ÀtAkÄbبbj›à K‚¨xùÅ+\´9Àÿpæí†)ëÓºÛ‡KÒâä7ðîÃÙK:Ÿ¥ÉFƒ­T-éÛ ;\»ÉjÞ´öØí?@bÄôã_Þ”‡´C°{ Mb¬;™òÿð' ¹Cì8iù7äE÷žÈ¥³(¿…j‘ࣵ”Ø íO×9¹ÔÕüÂAÉe ‡Ù…y’öNóp ¤pv.•æCXà @Qk :`¼ úüüéuôª²BQNOó>/XObject<<>>>>>>endobj 5354 0 obj<>stream xVmoÛ6þî_qÈRÔImY–c']7 MÚ ù²v«‹b‹ƒ–h›Dj$×òßwGRJdÇkÓ •DòxwÏ ùwg1þÂhB¿iÑ9Ÿvâ(ÆÍ½„Áe gѦ Hb˜¼F“É)L37+†iÚÃïÜVZ°+ ¡»V dYY`zY\Zǃ£é—N ý!®ËºBZ(ªÜªÊꙪæ9Öƒð4ožŽq°õ–ÌŽàßV,?n.ü ìÕÞá‡çOkWÄíÑûöë³ûÛU pµ€5É seWP2Ï–kï+ûÖWæFÖ"ÏaÎ+ÂÖ´â|w7Þš~ø4}臟µ³Œ¢ˆÂ.O€º½€>¦ÛOF½îç——0°¨dj…’€Ï)ËsžõŽ>ÇGð1ø”%—ÏÀ*7ÉX–ÞBeü—Ð?Í Âj"˜R|³RkU Lb0Í6È øÀuî$6$ÔÇK¥eE™ó}æy×O’h4BfÝ×lxsÚ޶k/55ó`k®z­g3yÐnÔ¬{øµw¸AF=upù(úƒãºƒ£atÀ›4对 Å««ÕÀ¡àÅ9І@8ÁeXÈ…’Fd\{Õ¨7 oz Ú ” 3ç:‚«Àà”î÷ªàU°[î-ÉÓÎã𳬝d¾‰Ð¶XF-w²4¹·Áa²²‡mêl½­ Ë â/%í¢"ÉÐNî“ߢ•ÅZ ËÐÚzòÀ y„NÁJTœ$C Áî¡ý³°bÖ­ƒ e BÝ|Å.¤ Ú¬+îñ+ð“#>½x±×U‡×â:GÇçݨµ)zî¹·½ !ïáwH|^x 9rG‚¯ÇÔæÕma€ËTUDôDâ‘V+Ksf :OÝãR«;2 [0Säž0P/ ·–H ¬“jcHŽ“µG%N±oL}©ùPfã-Ë[f½au‰ej–‹0SÚ‰I”†À³Ð ÝF¨¤ït¼ýпùõ›]䉻Àïà~8ü ³!ì…þÛÀ÷­3§nwãpµOúú;ƒšá)åk¶ÁÿŒÁK„;vP- .‚ÛªEívÅ,¬ØŽæ$ñ Ê ¸TIdšåYK” ­ 'X‹·n!grY±%àœ§ Ř8ä“Úbi-ÀmŽÖð»´ …· }ªŠ9Út†Fƒ×òްŠÿà‘ÔlÛ9}§îÑ`Ãè_«*ÏjK!ó  ݪyr}³]„÷J\w늌y }°.ZЈ¤.ù‰]Ë«´ 9ü16Ø>ç‚ù'Hâ“h<ÃdûÃ’N’~ÅðV¥î:ɨZÊ/6~nÿÔ›;˜GáNJʧ‹½¹ÒÒq<‰F ^‚ñ4Ç }z7íüÖù¯vQ=endstream endobj 5355 0 obj<>/XObject<<>>>>>>endobj 5356 0 obj<>stream x¥WïSÛFýÎ_±IÜT¸FØÚL?´ièd:…4xÒ/žaÎÒ .ÈwÊÝÉ@3ýßûöN’±q)m&òýxûöíÛõç ñwDã#þÉ;?Nw†é/»ì%íŸ|K£šX{t|LÓ<|>¤i–ŒGéq:¡imµÒ—ô^Ú’¬,¤•:“Ž”ö†ÞPeð ­Û~ÚÙ?9¤öòi{‡é!ÎK~ ÂÊϵԞ2£‹Ú)£ ?þJÒùïï~¦…P%_P*çI9’Öë(µ“9ÍïÂÊ…ºå5¦x€CèüŒ”NŒ%y+U) P8Ây¹¨Ür_"U`û³ó凳_fIOip8ÛÝrQf¸ž%Ïåm%3šºÛl¦ŸƒØ5Þ‰‚â¸p}FÈ®û¸ºms[€@2¨¸+€zù2‚}·þþ©p–ºŒ< u$5 >êÎ&êÞK^ÆÅ럵4 àP¦«$ ³½Jä— Ï?R{ÚžH¥[^8éõ²…= ~o´™¨ÇáÔÜ X%ìwU(™`sYËv)çyç +‘çæ ŠþOU¿FÒöêná>l8T¤{¶¶³²ð9zG€xCÆVm,˜ãxÒšcèaGô>6)ؾι×ðq[›ÕY– nP¢,ï@:‚º¼ò4—¤%šžíÈp#[JëÛæ½‹=$´–¹”šœÑ9Lƒ¶kwlù^Ó6a2°k‡.;mã ÎÔ^$º« kÑ‹¹ý¹+?ïÚœžÛggê÷Ú2k™ äæ{ñ&FòÞÛY¢5óO ¬ß¯¼»Q—ŒùBéÂ@ÕÌ v¥¸t›Ö:Sèú͹è¢,Î…÷P$sI˜¼]OEÂìr_nøIi 6VÚ™l8 c¢ ÊÎã4·Ė&Áë\а6.M7qù»<—~×Mata^(—±+bîpÞÖ™¯­|pb kË¡aÆAÌA™2Î>”]ÉìšEóATm†½Ûñ5Áñ?ù–¬¶˜Ú|ÂêB¨u. ¥¹!à–¡]âØ\£ÀU oú ñF;Lv5Ðù¸¾½¿ C[ïþI›ÞP‹qöŠŠ ŠûÍv›Üþ—Ú¬D²YlZÞDÁµ:ˆÂ{ÀÔåqŠã^BSÊ¥JVZy%Jõèád™ÿwÂlÊç¡ÂX?÷Õ‰CšÒ3ꊳ.9[%ÈG<.¼>/XObject<<>>>>>>endobj 5358 0 obj<>stream xÅW]oÓH}ﯸeqÛÄÍG®x¥‰…®@+EŠ&ö8˜Ì˜±4¬Øß¾çÎØNJW<­@­ãÌ̽sιçÞ~9êSÿú4ñÿduô|rÔ‹{xÙþp :¿º ~& z4zЧÔ/ÀC%Ö¬¥+”51L>_á@¿8Ê´Xá]s@Dª ¤rNšRo©2©Ì”‘) “’“…tk™Æ¼§‹XÝþ±¢ç¶\’ͨ\be•IJ„+°þK¥œä÷Tá,Tä2QBÓÍÇׯ¨Üæ²›Ê"q*/­£¢tURVNÆ4Y"“ö3á¥P8T™Ìº•à$æ¶*ùxN¨Mg%ÌB#e#V>&‡OE)8X'„äÄÖBK“È»vH´‘Zóïï(Ke”[eJé‡T²ð89zqv¶—ˆ2KéT)%¦+\OøèŒC@½eâÊZ: ïZ&*ç¤é>„˜¨ª¨„M"IdQ0KeVk»)~m"Œãa­Œî`‡ø”F>^ö[“-+&RM#feöÂK¦¼.Ý4:V&¯Ê¾Z[•Òééô„~É:ž¾É_×/gù ‡u¨‡÷ÏžAøí$(4ôöý›7Mˆ!n>Ði±¦gT¬gFnVÖ•BO£éI³Œ…‰eœÄâ³ôëÝÐïÚ‰ß+r0ŒG£'|ÊkèÃ÷ù°\ÚJ4½Û‚ær‡cU0ÉŒ#Wæp§Ä\ËCû³KLòå­XåZ>LÌ£:Î4RHzžèï=žˆÈSõc²ö¸:îwh/¹¨z˜¬À·ý[¢›‘‘¬:á¶ÝÝõ¡AhÝlƒxa[;çú…Fw؆mïN`Mì‡h%gQ•;Vÿ\ïf칚žøRø |ŸRÿ"¾à ã^Ðï°?¥kgo·”hò®­ú²¶oøÝà"Yëï`ƒp¸œæ­”)¼!÷ŸöQô{xÃûVà0‹®–k©)w6‘iå`ÎÞÜ2‘À/½O3‡B–m8x2XXªÅ²ÞjçŸd‚œBßÇí~*-½ØÙxáûÈ¡OÖ׫=¾–Z#iŽ{7Ѹ]Kç³l)ù¤>»A~8œŠ¥Hí&Ê¥(ù^k¦›Þ½£yëFf‡ƒÛÓ[Ž–Ø´mB¸w›@ö±1(.æ®ZQ*!o]Ômc"Ëß1ϯÀ5f†–ÞŒ˜æ8îƒe©ÕJxKÃrÓËÐGíi­ u!t =e´ÐªE¥Ë˜^g´µm„AsÄ-ÙŒ‘ò ÉÁH¹óª¯k¬Oz_0€X¡¡¦¤Q¼dsFâ'êZP79;£.P×ÔÄ¡ÚcµñÀg>.¥©Ñ¬eâ/ŽK¤µ6WvÍÜ¢i‡„îUtÍ:¸³Ð( Ég±~Pˆéy‹ û™òÕôÈÓ,…8y¬Héñʦ•–ÉcÚà(Ù|~Ìm™Ñ½;|„¥ž“Z‹)mf¦{hxïcQŠ9 *\{MJÓaÌ5 ”¶YÖ  “¦pVSÃNB)\$ F„ZÓØq§Œ}5HAG†sÆTæÇ³¢T¥€t­!(‰w“÷½Lv‡LFóɧÍräŒOžÑq/má–Ï€nš©Ñ»‹—IrÈ;ÕtSå¹Å¸R–bj" O\ÿÞöÚú¥Lýgç®Y®eÝ ášÚ2?ttÆïÚ9::Qør¥¶âñâ¶ôOh¯õÓ×ÃAÉoÄšÍ?Zкí|ÝŸµ¾Ý7D Û!Ê—_ ¯©·¤Ö‹w‡W!}Ú‘fR\w÷÷ºñPn(k¹V¶Â˜ÔXÔ<÷èÞ¡µ†ï“㬹p{±£Ðò,ÐJ¥–¥lhŽ]‚WŸ]33»-d9—Ÿ_ë†Ü_Ä—ÃKñEßÏÙ¬¢î îÑï6©ÚfÁڀͅÕÝ'aÜB+Ç#º®ÿ°XÂsa¹ ^{ÙÅúšÀeï‚_½œýyô/Î(`Çendstream endobj 5359 0 obj<>/XObject<<>>>>>>endobj 5360 0 obj<>stream x­VaoÛF ýî_ÁΪ¬¶*ˉ›fؤQ–ë²ÅŠaŒ‹tŠo•%W'Ûq ÿ÷‘w’"YJ»¡K#²øÈÇGÞ‘;C°ðw£1ýùóÎ…Û±L ¿,?ÒxueÁ‰97Û‚ñ›¡9¿7PV¸¾$ËûˆüÎý,I§SÉ3ÏÐOðݪ¹ÁŠEKî~èþݱ`0Dp°ÞLjà/šE¬Oÿ-Ö§“׫«# ÄB ZƒÑ(W˸NÖ|ÅÓ>¬g<†Eš²ù"â§§ºPõªœÝLÎáø¸öŒÂöKqpûþç­<£ñêâgg2q.ß9ï.œ»Éž ƒ<äòb¾VhØÖzðg¾žäQˆX9aVç—[œ±ôA¢ÅÙ´ùº@¯TWú§§lªsõ ÜgMNSž-Ó–qÀC!²ûÿ1t÷¤í¶SÚm•Ç&0lš ÈMó]&xñ²%\_iÂòä4YÏËÝ÷»Z•=š»¼$OÕºt&îÝí-Å*UÓ2Lÿ´þü($óŒ×ç“ëm’U Œé ¼ÛwmÆxÆ¡wã:wçîíÝ$—®™£ª2ÃzTUö[ˆSÉ‹ÇÑaÊ.ùLÁ°`U SgÔñÊqß^·0A9òë÷BÁ£ù¶76 7çó{žNér@«nÙ㺒ÓÞV¹ØÑ·WV"N°¯ùmÕSÙáõQSµ~¸·š.–­%+–ÍÑv¤Fû‰"$ò|öÐûê1èµ³êS¢Í|ýÌi€g<5ÅÕƒ¬â²³0}:Lìb§E±Fô{xq)™þ‡~ÀiÙÒ_Sݶê—ZSÇÞh;Ô;àŽºmãî')[ý–R|©Jï½Yl—³Øaþ d–.}¼ì9à”U“„„y1_³¤˜®ÅÀLBšÍ ÙœCŒ&¸øøöåKðq<+oIŠc: à•gŒPñZ$kÓ ü,0D^°ˆOŽiS`Ñšm¤¢@Ýüzîj^×B7<2¤ƒԈ̘œAF¡Q‡§/H•¥ÄƒQ[‰b¥o X±TLÊÃ*¢ŠXZ]yÏEüdIO"^%¸¬h5"庣³ w´Éè•ÊÐ+‡þ²Ø³ •ý¾aý6ØG>/XObject<<>>>>>>endobj 5362 0 obj<>stream xWÛRÛH}ç+º*d#6–ð…kRP•Éò6àÝÔÖz+5–FH±¬É—¤òï{zF##B.@aYšééîsútënk@}ühtÀá|ëõx«ôq³ýWÞÒî›>#Ç4ìÓÁñ 888¤qdVõizOèOYfªHR­Óü–þ–a¥J 3¡õÎøÓVŸü–FÞö‚N(—ËfÅÄöF½½ÉÎËîª%VYþ)VO<Ðó‡=´Y _`ï ½Ò:½Íç2¯HÅ$ˆÏÏ$Íå|*ˮՅúeõ¦ƒ}wàwÌdYc¡ëþSãÿÄ£ÕÉé¨×±Nîg}rzüGŸONýá·!\KqÖ¬ÏÝ·WðwÛzþÐçs©«²«TåWxùùÅÍøúꟉ×·ûæ˜CÑGÈþh¿AÑ ‚c {5ýÌèj™ËR'iÁwßìÃ%þp/ØãŒ_æ¤ÊH–à¢T«µ…Yjª-U9ã»±îQZQªw(µåÚì1\ÁÒ¹ÈÅ­$­æŒV˜ˆ<ÕsÆPYW”s% ?d)ŸÁ~"]œˆ$ò²^ñÜç3§™œû¾¯ë¢PZÒZÕ”ˆ”ˆëÜ$‰²t&±:Õ/lx÷‰í‡ÁhšG^ÃÞßíçÇ[YMÚ{ ª¥y$W“úâ2lt(eU—9ý¶ø7ýÏfùÿµ›WƒÅpä°õ·•˜!©ÂS¡p0ò.òˆìüÐÝEBE®‰²YÐM&÷£Ÿ§·IES®Q1X ¢,ÅZU‹In–ê 7cZ˜ZÖ4ñÒœÎ&;½SK{^•BW&Ÿ—i•<ðÜ’,a¦´aXt ”þG ÂÄ‹T €iÕ£æ ôj®>‡ä¢‹‚Ãé¡­z댽tÏwwéL@ Ξ?ç€]@.Oaþà¤ãý€µ¹Ó ªmªz4­9¿òþÙ\O}V AÓ|ð7ŠJË$Ešx—eCKþmj\(ò*-h••$6>*peâ%¨è¸Î²5ã à"†ì¿ãÇ2E¦À.”¨ïêT'˜¡&ÃL ümêÔ„”BF8 {®„xÔYÔñˆWÃÄÚU®äޯα_pG,‡j —‰Ìi)I”¸«rXfZ¦UÐ%·€lA0×t¤@å˜æex.Òâ³ÄrY%*b!B¢DȪ†ªcAe.2Èû9f ÁxÂrµ2ê=½úðîâÚÞtÚêdêÞlžIYÀf' \‰¦·!¿ÚÙ"j1‚:ËÕ²ùÑ…-—£ÖzQH„æHB¡¥~`¨“®‡PŒÆß ­n_£ì»½hߎš–48Ú öGûtpÔíøË‚ìƒ>«°æ+Cx¶ŒLØÕþ¡gðò°ß?FC¼9` Æ5o¿o½ßú?½endstream endobj 5363 0 obj<>/XObject<<>>>>>>endobj 5364 0 obj<>stream x•VïoÛ6ýž¿â€:˜3ØŠlÇÎ!A›Õ)´[Z{뇹èh‰²™È¤JRr¼ ÿû)ɉS'Ýâ@°yGêîÞ»wü¶Ó¡Ÿõî?Zìœw Äâú¡g´ÒQУqBÝÇ`08¤qì½BGÍFÞ>{óëÇ?.? 'ÍÉÞ/{ãëý‹êÀšP»Ú½^µ«ùÆK—leZÄ(Ö¦œ"¦9 CB’Ò1×>_¾£XqCRYÊ´*DÌIó„k.#ìP¹´BÎZ4czÊfn%Myd…’-B,.cJ8³¹ÆAJrZˆÙܺðR§‹$š‰±{¯QÙ\+"f±)er–ãT”¹“óNP­vwà¶õ:Áqp@¿qãÜŸ^ãÕf3oç{xò,S†“3KKNsVpd/ù’”ßZZR¥n jrã<…9)Ï{\ýv·ôzÀ"n«óÈÒÓ5¼«ÓBÑã&U".TC{L\Ò۬ŋÖd»UHëßaWßô¸ß¬Ãü/¥O˜ÞÂW€ÂS®Pâ–‰2r¬ˆÔ"KùmU'”°¬_ª9‹W4å\HÁ2“§=ÀÉèŠëÔçvEQÊŒ h¬°QÆ)¯+å €€L¤´F©ÒUËá“{¬8Õ”Dnîž¿ŽF÷†·ŸF›i6q¸™Ór."¥,ˆW¡dˆàqÛƒkÙA‰ *’„õ'C£üöëÜØÚä˜íYe2%ã‡Ä(—  ¼>®ñêz‘£åI8¶/sJ¥LÕÒ€d©ŒkÖe™ÃºU ©†( ¼_æÐ«²1Xqã[îéQuêž" ´q2USn­ïkš5²öÙ]rÇí=œ1:6i¹Û¸ó.Ž3Ošt{z¶håŸÿà vÔjUá[«­WŽn¿ž^sûtå{ú"—^ìŸÝ’UµYYez–»êºQS¨´p°°'ÓªŽ®C­X¸Ä]±˜^9–Z8†TÒ’Tçt™å·Ìá÷2±Ê‹be¿Bžbˆø¤YÉôÏE§EëïÝí}Ó]Ò‘p£°òGÄ ã³'¬ÒÆ¥fY†±V똽z¾J,žÈÎ1°ÎÈ­;–döQÕ¼ú:Yž‰‚Ëš*¾K ºŽò‰Ò ¯äàw©ˆ¾iœüz~$ŽA<…*»^+ðZ½~ñ€ùôq· ÀÅŠ^qÞ½þºÉJǸ†³ý~Ù"ÚIs÷®^ºLÊWôŽ[Ÿ"ÆLQ¨&×T°RR×`­¨åïOí|q§~ç P <µˆ£ðã::9Ù`‡ObÛÞJ…ªý›go›ÂÔñ`¬+®y–2pÜ'©´˜ ‰Dks‹¦¹­ÕÇ_Ò@4\Çp‹à¶`RâÊæÛ¿8ª.}Ýð è÷ú4è‡Á‘¿áB×î!½U‘oA/pnº¼ôm–·“gïVýpôº¸„á‚ÓÝæáxçãοà6Hendstream endobj 5365 0 obj<>/XObject<<>>>>/Annots 2656 0 R>>endobj 5366 0 obj<>stream x­WÛnÛF}÷W R–‹ºÙ²œ¢@Ó´N´€[ è‹€bE.­­I®²KŠVƒäÛ{f—”DÖ·µÚ$ggæÌåÌèÓÑ€úøÐhÌŸ0=ê}<áË€/¿}à'4CJ! üÿ ÍŽöw)]^û7?Ìô8eæ–z×W4Ò<†ÁñdBóÈÙéÓ<ìŒÁU0¦i¶’Få" åéüÏ£Þõ9 ðžOt‡çÁ9Îtf*]'’Þ¿yCj/NÊÒJdQ"#*¬Ên)_Iº‘&!¯ xœ¦Î÷ÓÙ»¦ò cÄêHŠpEa"¬¥µïÄ­ èZ’÷‚­ž‘Ši« ˜ÚHg!ÖI¢KØc•ð’F•åÒÄ"”«D¾­=˜#3d4Ã`4Â]ÔéõÈ®ÄZÚ@Õ:à¨{>û}ú^ê¢ÞxyïgãÌqª£ÁñÍWŸ·ß¨,LŠHÒ«ÊøêUãýñ—êÎÂ’ûIMEëb™¨ÐAdøNšªŸ2y!Š4„$¢,Å¢³8¥ï¨ÿmÃÚ#Ö(†Tþ3§´ŠXƒ•ù‰E®t¶èTFïÏjóÛÅiÓê—æ­Çø^™¾¾%Œþ-f~gÞˆH¶m¹Æûµ–~L ¹¦Ãµ–J¨­¦äƒHgŸ dä¿#õçwH­úK>ãk-û˜Àÿ…“«jÏ]î´Ñ(/¹ˆç`#m‘äè×3O¥k®êùR% …(Ó¼ÕÝêè™>¾ñ|á ¦~¦ý¢ã{­„ ÝPkòÅñ¤*oí¥ }^®ðÉHúP¿€V#îàTeÒR zGd5%Zß9*C{¯tdIÇ$@¹&Wa‘ˆ*XÔ ò]ê|åX·eÛª™{zµ¹ß -è_Z~|ÀànQ\d!󉥨èôú˜ÛꬦRž J‘å;°.<‘¼ð.jŽ]Ú –[$³=Ž¥½ãÊäÁ„0Š6ªáçýbÕ¹^w¹‘IH5Zv}!¶ 4çXã³”¡(Ø irÏC¦:#Nqìj)“2¨E*Ý8N% ®¾ßîD¦wï ª³d‹ f"ÓpÑHØŠxü2Œ]G¢ã\‰l„Qº@ Ôè‘W››"Ì tsÝ:Ãj9`nn>í ŒÝ`9À@ϰvË`l±ôcÀe[d[¯ëVfŒNº·”ÆT»Êž‘e”[Ì‹¼Š±d"•¾´K^õÕðøZÂ5€Ã æemÿ£.‘iƒ–p1’¥0§c%PqU3£§r£6 3áÀ F!M³†›ûžC,ö)4d$rA©L—Ò¸ª÷¹‘©V( ï¶ 4î±éIJl e §=æ°‚FÈ–ÚÜaº<®€Ýá˜IÙm~—ô‹ŽT¼­÷6Ÿ»ŠšUÊ»Sµ N]êÖÚZÅëÒ§£P7|ò}æœÎ ?Ò%P9Ú9«vEobוÇ1&€,:¼AþÕâ´éEqÌ=4JÔjíÉFÁPÒ¸7÷hì¿;n©ÕS¤Œ»l*îÙ¨7fXùÈ„‰¾Ìd½‰bÅsk'á#šB£Ú¸ª)’ËâÖÍ,~Ç~… 0×3Ú<³Ž¾¦Ÿe~b)€Õ:ʵì¹ Ù³)¥."ðK ÆxÝsàëM°†zIª—jè—>¸·=ö±žTû`r\Œðíbr üÎÌ©íñ½äGÌ=Ž•øF¾—î^zm³¸èƒÑ)A^ô'|ò§ùѯGEBÖÛendstream endobj 5367 0 obj<>/XObject<<>>>>>>endobj 5368 0 obj<>stream x}Tmo£Fþî_1:%*ÎÙkÀØqrm•öî\åCÕ6±ÔƲ0,öú€åØ%Žå¿wf¸·Â/bgžÙg^žùÞsÀÆÇñ”>aÚûuѳ™‡o?ÅFsfl ‹\¦7›N¯a/¡ Ê dü/ýžgÃÐÁóÏÒ#\äß¶ð¨ˆõ§³Š'1zðç ÍÞÞb¬õã÷2(¸oÝ­ýþ{X^ˆLÃãâËׇøðYfJe¨yAw/˂ǾuAýþêÕ÷³ïcl®§AÅRÄñXd«–3óØd<‰‹­qÌ> 4t™ _dX¦<ÓmâŠ=¬¼‡×ÕHá¾¾a×ð»ŒD|¤ÕKšÇÎ<!åz'#E°‰=ec·5.›‰}CG_½¿zÿ8é)`endstream endobj 5369 0 obj<>/XObject<<>>>>/Annots 2681 0 R>>endobj 5370 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ˆ?óS*‹B²ýææâïÿêkØóendstream endobj 5371 0 obj<>/XObject<<>>>>/Annots 2683 0 R>>endobj 5372 0 obj<>stream xWaoÛ6ýž_qèPÌAlÚ²cÇéÐmÖdú¡[3Ã<¬´DÙ\$Q)»þ÷{GJräfXÖÁˆmñx÷îÞ{ç¯gMð/¢Ù‚ÿ󳉘à~‰øå·»³ùRD´¸ºÊi¹—Í›Œ>=z›SÍÄõ£/ßÞ?ŠæCVß^R4¡û×.®ñGâoÃñàÓç÷wË‚6ªP•tŠ>þò‘Ô7§ «Ma)­LN7”éu%+­,IK{•e´ß*œÓ;¼º­¢óûÎÆ·(Â_5Åá£öö™Ò!¨ {¾¶”h×Öª„tÁG'4ЦHw›JQ¢œÔ¾ò7€†2VÅž¦Wb*>@‡l‹Å@4§—˜©m-3Z d‘P¥b“çªHT²:§½<Òr†ÖµÎ_e à ɪRzØ’C!sË,;Pf$Pn’:Sˆ¼ßêxË‘ššñÝú@xô¤ÈDU0â>èbCö`Êíê\Цö]ÎÙRÅ:= éð‚¸kÕÞ)kgr‰4X=êJ¹-….4_| 4¦òH;ô¾Ìt¬êàÖÈâ@6®tézɆ’ ¥‹C}Pß;®UfÖPi¬Õk€ +PäóSeM]Å*9àm‹cåº22]<ø¡@ž44U\;‰Øã0™+œã«QL?]?@{S= QPr«Ô×ZW<Ï”Öç6?“z஺L˜ ÇRb”-~tTf˜‘BÇ píµÛR)ã¹AU¾y‚>«n‰áSݘ…öɲ¬ŒŒ·CîþÜéDu}h‡Æw£z|{MÌ fôhºàIžMEÑx˃ÊÃÃÈ„ñ9²¹ßu>z ia´þ¨Ô0ß§cÝ8y2¥ÎÐ-pé„-äâ]ß*|¿è”A$Y)®¾¶œàÝÍÍèÁÓßktcè4U8æòxJs|gM®hM W¯•Û+Ð-q˜ÜÜÒ¨I ‹j·¦A›LIëˆ'ÂãúAõ·^&n¶«óW´ -ÅŒŸ2lS1›á]2 æ¿MÓŒå(6Eª74é"ÎêDÙ/4JKÓ(Fd^fêï}%K··A-ûqFv  ’þã†F¦ýDX’j‡`䓚‹Å⪅)ýîaf¶½ëä<œk¹?N¦×QâsJ¿—ÐiÔÕï! )"b.è ,ž A'?;­n宿òQJ•t5n9ü"à{43ÂÓn?¤l°Üû]Nóy‡ò>drfßlQ‡_ÿ°äáó›16`q çw1v'•BÃü6LMap>yX:}ÃõŽ`ê1 DC˜yÁCjCN«_ò¹j·F¿„£øú% ø°À`éÝ)¿SÃk½o"LÁ)wX˜½c{!÷æ~ÔŒ`ðü¾½bÈV-«0Xp2䉱Ýèy/Q«`2æª8í\`_¾E ë@|Þ†0÷{ØaÇ&XHÐì:ÀÛ铿ú²Y ›M -È÷C€ž>¾§™ˆ.£ùuïë5¾šÞ½¦©¸Š–ÓeÆ9ã%……ûXW‡ŸƒSŸYÈÿhÒ²ùÉ-/Å|6ÇϹ‰XF~¿`ŽŒ¦øø³‰kü.áØ\2O®Ø3ÃHwáWïWÜØw=ãŸOb6Åʈ§çQÄQÞÝŸýzö/X¢~Îendstream endobj 5373 0 obj<>/XObject<<>>>>>>endobj 5374 0 obj<>stream x•V]oÛ6}ϯ¸saÄlÕ–·Ý°‡4Kº–!ƆY¢l¶©’Tœlèß¹¤äEIºu¶aØäåýâ9çêÓÁŒ¦xÏh¾àO^¼]L“)÷_vC//¦ô:™Ó²¤tJ‹7³d±xEË"XMi™D¾54¸º¤h@ áGBƒÕJ¾?Z~8˜Òç–EkvÞZ÷Œ^^Ó Ve0žÌçmÑr+¬8td´ Zä’™•þžLI[³£Ühç3ííŒýHRÓÕOW´ÛÊ|KÒ“tÔ8Q6м!m¼ ÕÈo±Šþ’ƒKYÊœ·¯¿|G~kšÍvuD’%Ý›†¼½Çn[È,åBà’2M.D®2+Š}ã^*…®í2«¥Þà@ïB“¸«Ûßûc>#ç-Þ ë¤Ñ\!ì÷6èÎ*‘:Ò˦ °ã¨¦ô±T!>‹õP†ŠC9‡V #†û„v!A±vÂ"ê˜;¼ÔÖ¬³µº'¤›ší„µÆ&ÊlÈXr²’(<é®÷˜»r q—UµcÞèãf’¦É|£aeŠF‰Î¸s0ò¢¥ÄUŸŸ^ÿq³üåæçËë«ó÷ïi=ö@’îA’å¹åJkEî‘{Ä¿§{Õb5´™'õ¶¬ŽúÀ•åjÔOù«Í›Q[Œ¨}%xõ6>“P€Ë×Z?Sf |¯ V©¨‹—¶¹©DÀL‹¤Ã~҇㎨™‡ Ã[àt l‰γ!`Ä+·™Â¶)»¢‚©ÒŠ^¦Qcïó2CõßĪÞÓ§„äLÒ7mž&xÓ;´)ú Äè„ë÷€­“€°·"Ϙ{ ݈Ha`õVÌ´ :”ié*¦“Dz6µ§ŽÀ¿Ì9¹Ñ•Оٵ‰qo»¸ã'+r“kêÚX4ëQ ,+EèçYãM•y™g ðÛ-lìq@'ØQ6:÷ ¶ ùZ~ô±8”Z1A†U˜Í#'>J(lÚêàykdA5Æß°Éjô,„ÿÄ•Þ+@~|¥ÜѰdA‡³{ztÎ?w­ \†¿ý²Âឯ€_i”2;÷]¼õ‡£ædüOc"!ñЛð\b¿ œ<ªÇNψ¾¥¦‘Á/X_é ¸hŒ“bGÇ}Z!Ô‹Ã¥E’{Š3FÔûŒŠÌgþ¾¶cɬԵ `FÛ Æà8öŽÌúdÎ%tZ’AŃ9FH¸‡-¸Ý]O;½Ø)S¸k9w¯¤—¬¥«ÒŽ‚×*«»úÓ@ÅPÏÖhc! O] eU5žÙüØ´WXVžÀ-M8¥Ü€Æ%xòŒC¾¶'®¦[ÁjeÀ„­˜ ¶Ä‡À!†”ľ¿ÜÒ¨ò‡ì“Ë­¬=:꽨jº„¹ØûÿrŠ‚l…kžAxȲÿw«â ÅE)ãØ,j½,ùù‚‡aÑoý©G2¨ØK¨}¸‡½¶wNyã Emêhh:ÕÉÎëöI+''óZœ¤Q_ÙÙ$M¦ô£ÉVIˆ™Ñœžà¢íäU¤Zîu_lt2]$óòi?™¥¼t¾<øõào"/&Üendstream endobj 5375 0 obj<>/XObject<<>>>>/Annots 2686 0 R>>endobj 5376 0 obj<>stream x­VkSÛFýî_qÇ…©FØ’eœ¶4“’B˜i føâf-­myWÕ×ÿ>çîJ–$ítBˆÑzïîž{÷œsõw«G]üë‘?àßpÑêº]|Ã=þø|Õê¾{Fýçz´ þëf”ÐÇS?èÚ¹šOõ›á‚†Cw°1·1\P¯¸ÁÆäæ³}}oûÇh¤AšÍèôò5õ<M‘Í`8¤Qd’èÒ(t| w}º,UXÄZåG£§ÖéeÇÚø¯ïö±Â¹ iC"“jõ,³BF«BÓíûÛ&À¥wr*ʤ8Õ)ï*,™• ©ŠÜ,I®I$‰^ÊÈ¥·Š÷ÙT„’¦q")‰¿H*æqN¿X@]%2ðºtâ±Qä.tT"^þ#i"9óŒ=r°%Mµ›1>úuk6Òå '";ö¹CõwtN¨êî ×u·‹sb°øî`pÆç=ÄIBI" ež›º˜ªü×\b&e$ÇN»ÊÆMçi{Å:“–·75Á”IÈwƒÊà{!áF&iýóÝç’"{mëÛÂIy*¢Tdb!qG¶5ŸL ü .!SŸn@ŒD‹(V³íŠñÝUtz›s]Îæ¦D‘–9)]P^¦©Î ÒÍ «H‰"~–ɪCù2žÑ’ >“Jf¢ô8OEÎ7â—ócV憧—nÍl–(T¬RÎeøe«C<±iN ·áê&,—FLϽSÎI§Œ´'Á•Ëd(#©@mŽ—y˜ÅË>pÇR Vç!iZÕŽÙl`Ö5ÅʵVÍþ$ Ý6{ÕÊw*ÊÖ÷Å0à¬ÍMt«ð J ý,§2c ß6u>/XObject<<>>>>>>endobj 5378 0 obj<>stream xÕVa7ý~¿b” å²$›K¸ÒRTà® !D!-ª”/ή“5Úµ{÷rQÿ|ߌwslªªŸú¡Ý]{<óæÍ{þr6£)þÍh¾äÿYuöbu6M¦X<þð;z|}A³)­¶Ø»\^Ò*—ï±’W… ´7eI^‡¶lÈXj M[W–noìŽÚ vš—ß¿~ÿôáêóÙãë)]&sŽ—Ni’¦É|ŽOùøÇçuQó^Eô|llV¶¹^GúVUu©ì­þ0ØuÏØ=£y¿Ê¹æc¬¦X]œ¬Æ4Ÿ‘Êó5ï™óF„$ú†Þ¹F#aNûFy£6¥(ÅKIÆÖ-ê ÔZ«3‚ò‡dˆÎ G£ÊmE’Ö#þÅyÜ‹¯×v4ÌèùO”c.}’Γåò —ñBgª šÑ£BRdUcn4eÎfºnÈmýV{çdªÔ‚ÖUÎkÞÝzUR㤓ë]ºZ£,‡jõÝùÀ+µ jgl£}è œ¥œÌÊ‘¶Œ b™pNÎâ­s9×5+V³è3&tìÌ KÓ¾0Y„¶Æi&ŽU•Ω9ÔºR5}¸º¾úpõîåUŸGzÁy¼v{ÔàÏ% ¤_œv–2U–“ÆTZŠ˜l“¯ ‰w1†­-.­=°mp[$§4:8æç¤lN{ìFn{8­ËëÊÝÈaþ=‹1À‹äâ¤Ð„>::¸–BáÚ2'uãLN™×è%Èfõžö^Õè ¦I0AQ.‰&|ãÊ Aáçç~åò½éf¥OK¦á~× ú1ê6Åq“¤d0ICß}0êouów' BÙù‘²ÿSMÀN‡£)P<‘àŸéùƒ~ŠOè¿ü7¢5¦ªoz€É´,OM¡¨ÚxÔ¨Ž2 Ê»ßÞ¾Å'Л§ìÜöÂ= ^·µl`î©x¨›Qn·ë™#3/jÞÚ¬1Î&ôFtœ‡2ˆ+ÌÎâ–^,i=6‰N8Hœ4>4_¥€*xùx9£*ƒUÚ6뇬²\ŠÜ‡ýƒ„ÔsדüÜâ4Fe+›Âë»ð’™Ë2ò}¾HXt¦Pˆ+;ð â»y䢎Á‰¸Òëõ8¡Wº¨s§ /œ}‹Ë¨c©ËsÛ!ÚIk6l†1 wÎA „Šß'há ÛHÂäöÇVJ÷{±•NR‹^4áðe¥c¡ èÎ—Öø¨ƒ/©4ïÓ!¡Ÿ‡(eÊ D–¢`ñ$ „þÔVx Ý«CxÊŒ–z‚dkƒnN°dÅô­ "Œ=O`5¾csö$×}ˆÁ9Ò¬ÓÍï‰5šŸ1“tÉ>2O“4YÒÇÆ·lX°è¿|ôˆ²’ç' £ò¹‹Dèã§7¿°o)¼yÄýD¾97>$`ŒÖEÂ#©)ÄÅû… 770ÕsöQÀ´ÓVûèJ¶vž@!óV/ÎÀ)ݦwNØÃí¡Oº“6C~/enƶ„nÜÑ!ºŒBÙlnâ>2@Çâú~…žSnÂÑó{›¢RÐäØâ1žÆ€G>/XObject<<>>>>>>endobj 5380 0 obj<>stream xVkoÚHýί¸Jùà¨Ø1hºÝR©ìVjw»*Ý~ABÃx ®l±y­vûž™± $‰ñ}{çž3þÙêRˆß.õ‡æg­·ãV„xØ|¨9]݆tôiS/¤áËn0¾ qd½BsªŸH–³TЦ³íì^]Ž´Bò»ðˆ¿/¤šx“ËÓöÿs¨Jdlž'E‰û©þ­3,*ëB•¼ w2[¦bCÿªÒ)Ñ¡$«d—çêöšÌÿ1ùÈç÷úUóÞwY¦Í•ZD”äT,Å2Må:Éç´f[Š•ÌèËï_¿˜¢‡cô{½ ßÇP#ï×7ËÅò)ñ³L” ‹•X‹žë‹¨½¢×”‹5ŸY{å6ðê×±õiÆëS† ƒÚPW|!éâs=w’1M<›¿c“ÙÏÝ䱜?:8$<»˜LòÓ]üñíÓ§WX¢g w`Rgi*¢ šL£ÍQÁt]èþÜùø# ï5…uMßÜ%Ù¾¥ŽyFÈ|¯:­"7–¹šdY˜¾5—KQãr™ßŒÜŸY–Ï"› E+¦†hbyD™(2Âw@eœ m©Ôf{Ì.Õ;ã¶Ïó*xŠMÉÕíËjOÍ–^›½ê÷‚^0 ºôÍætùº•—ççr©äf{ˆ» Ÿ@p2Âà(™Sœ²¢¹¶àåì—ÜY–¦A4<¹AŒö9x;Â0Ô˜r–¡õ¸Ì«GÐB ¥UcY/¾0²ôL—Æn8F>/XObject<<>>>>>>endobj 5382 0 obj<>stream xµV]oÛ6}÷¯¸0Z@AcÕ–c'õЗµË:C3ÄØ^ ´DÛ*$R#E;Á°ÿ¾sIÊŽòQ (†DóãÜsϹ— &4ÆgBÓ9ÿçõàÇå`œŽ1xü2[z{}A“1-7˜;‡‡Âÿއ<É…³ÒR»“dïëµ®èlùuðö»úÉ+#7a¨Û$¡VF¥á¿RÔ’œ*¤©îKµ%½þ*ó–„}²ÙþÑV)-w¥¥BƒÒ-¶µ®j©T$(UÕðáÍÊus/e[ãòVÒ†wÓh’!¦Äÿ.¬-·ª–ª%ÝH#0/³² žõEIì¬h£M.IÞÉܵ¥V¤7>”'‡¬ïÉYµÈÇt•N™Ê çfY:â­H^é?ýÊ÷¤ä¾øøW]ýÐxä×MÓùü’×}”]4–„‘$\«kÑ–;‚Å·,è°“àdì…)źWž~©rf›3P‚¡obd`KÁÒV“v`cC%3.©8žÛ£©à,ˆ½(+>ˆé_3_G-”c\ØBGþăú“UcôÖˆº†R˜rYbÐáyà]HŒ”éXîôs딕-ݯÎÂŒwGEB^§Yš¥säæ¶eþèWY¯qØïeý4pò¼âì:ÌîÐXV kŽédFF4 ø„¤­Ëwüóͧ~-Û“zyŽð®i†#‡¥j%äÖ€Ú<—Ö;Nûzô÷IB޵‘ç„Ìr@O 2¶——({¦BêiãTîE}ã'‡*Øôj*€‘­3*?wÆÀ0 TNMáwíÐ¥tdÉ;Q7• ´¾àŠ×µ.Tô`.Ï( H?kú»;×Sü‹Aƒ8à‡ [ëÄf÷óþyÎWÓ£¯ÚUK7ò]œ2vþMÈ¥Ê+WÈU2Œ Óf× £àe¾Ó4„‘‚سF8 6RJŸõbA¯’ÕF†]«•~9¬©‡¤=›øsj8Ç쯽à$A„ü"ÌÖùº‹r_ ç$Ó­¯„\ÛÔ0ø&Ö°ìÉøÿˆ¹s­¯‚§lEï^<òîu”± ëúÏ ÞíD ©uM£M ËF«‡0Q]þcƒó<-ÝrÎXÿ¼Qµâî{u„û¢î£â÷º,Žj–ÿ ûì©ìC_;E/ì÷É>`ï)äØÚTôß7ö(›u­Í'õÒ—É#¶5 p~M몠Ûk }PhéE,#½ §¾>ÃM%ÐØ¸ÜòLÎ'gq+·w„Øs*mJ›<î6<9äsÖ]iž91A¯bŒ¡;†s¸ Xé5$6¨ßTiQt ×îP~ Þ˜K’¿„[Ïs;Ýž¯ˆÝ×Â*AÅAÕ`ï‡úU„>¹ºHgÓͯ²ô2Ü>/XObject<<>>>>>>endobj 5384 0 obj<>stream xµWÛnÛF}÷W \•‰ÖÅER'nüPÇ•äE€±"Wâ¦ä.³»´¢ý÷žY’Š(Y…£¶!SäîìÌ™33‡_ÔÇï€Fçüç¿NúQ7×vA'W}G#šÌiاó—ƒèüü‚&IXÕ§IÜù‰&©r›Dþ+í¤õ2Á…7$¿‰¼ÈdT¤ÅñäËAŸzlJ:2N M§‡ϱVÆ¥WFOñƒÃ_Z[ùÛÉÕ)±…9õàNo8ªÝé|®Ì<O>•47Yf–J/øÆæ)µ•Í zÃa4!Ää±lž±‰®¢Øë÷$•U\gu\xgeRßnÂíPaÅ" ± —ë h0 ƒöóÂË\j 'ŒÄ&Âs…TTÇíà(7I™­wµpTy0í ™ÓãðWÎuV/»ú’ÿx&×›¶ÌÖ_mZ8$¢“’_Kõ 2DWÑ€³Å…G0…JÏM›Bß1 œm8\1¨©b[çöÝíýï×7Wïï¯>Þ\N®ßßlÛZ¦*N9=±È2ðnMNØö³£úôi°ÍK3É(íJØB¬¶¾• ¢¿¤Nî ‹:œO;‡¯uC2sö‹\YL#ŸZS.Rºû|ý ïpzÜ>ŽØÿ{†¯²vïÅ,“÷ šõÒ“V§R$ÒN;Ã.—ýe%Px¸7>‰¬ä/O´fͲ1õ¶ê0M4A©ÙÉäé&Ön0ÿÝs&uÇÝ®n~Üð¸ä§Îõduºd´m4•¥§`Ãn9RZùmÊ™Ýeù#ëžC56GóÁë‚ÝfÖu«ã×…²ícœú§eñ(xý³¿÷þ@þîÞ}œ¼yÿùæY9tié³ÔOÉãžµÏÉeÞØüq¤wÂß›ÔýhïVÆšÓ.«…NvØo×·¡ÛxÂJzvENå*–f˜¨Å$‘Ž‚ÜÓÐÛ?\ßlRö˜àEÃÑ!KƒfOãH³o™j4’•®¨š\¶ª³ö’§Ñ)«Ö.c¾L:#¨º´Æ9Ê„^”b!©0Ù*7¶€°ÊÛóÆÓh<æ·Ö|[Qœ ç$†Œ5 LvJÒ—Vdè-³/p£g¬ÂàÄ\ZŠUP q,q¤üæ¥v˜Gˆ^;J¤‹­šaµ˜™Ù%)0Ûp΢^è8èî T@–h‚'&V ]¾x±^Úe4)—>5IkuR™äÌEÒ¨–ÍÝä­Ð®À"í³=(A—´´¢(¤m¥¨­.Àb˜‚<FA åV9ü±*†“¡i;À q%òà©Ð û¦Ç]¾Åó¤É°kµTY†H=ŒR§0-¿»Æb>¢OÊúRdí(×îsÒ|Zº`„‡-‰ŠRì Äw(0ÿ,GKžê–XQÀ§»KྐྵSñ +rè†ŽÕ ¢Q4:' ^ñ»p€?yÅ:ñ'û)QYðÂ¥ª€)¿dP×8ã æh@°å`S^¡¨Ö¬‰Ã5¡$ü g. ›–˦˜­c,bPc;æÒbé…¨Œ÷PŠeü­"~‹?'WãúÝ`Ø?ÎFgt>¾ˆ†¡0 ½aÔ§7&.×@sÐÄÕâÞEõÊ…>3Œ.unë„ëÒk¸²¡ßÕÃ)ˆ¶pÖ?FC´*ÔÐÙà‚o½üqð/‹øWîendstream endobj 5385 0 obj<>/XObject<<>>>>>>endobj 5386 0 obj<>stream xVÛnÛ8}ÏW pP[ñ%qR/ö¥i³Û‡]t‘Å~¡%Êb#“ªHÅ5Šþûž!EÅòÆi#ÌËœ9sæòídBcüMh6çoº9y2NÆø±ûW¯éüö‚&cºÏ±wþ™_ÇC:H ¡tBwMU™ÚQnjZK-ká”^Óç??SZ k¥¥BXZI©Id™ÌHiºûòéš$³äbœÐ}!é«Y‘ÉÉá1SµL©-)KÎPm'i#]a2JEYÚ³û¯'cM¦À3HMÍûËݤÂùšÏܼ}KjS•r#µ £B­yÖÙŠÒxQNèT’÷„€'÷áÉÒl_8˜ôà°3Me ã<üB8&R‘ *H~wR·\°E¡3Êk³ñ{϶[¬G^ó€#‚½¤R=HÒðéQîßÜGñwKóš à‰‘2óÔ>h³¥-ˆ$¨µSiSŠ:’ þ;*d¶ð¼¥f³RlÞhXU›ï»èa‰ÇnÕ{yCÛZTøÌ†È8ñ•¤0p%",ÕÆÚQ)ôºëN¬Ö—«…¶€Œø–;ïüùí;bI°VGÓ9kc6…Ä&ôQ‹Uɇ"$¯ }m¦ÉŸàðÅ]”Kမ²¸â]í(“¹hJáj©¸ßÒÎ4´i¬£ <"·5,-½†sPVP“u. ¹\•2¡[U[7ä¼àå}§Ýµ§d*Ïw{ɛɚ2Ú…†A®PvÁwœßŽé:™1Sæ,Ìð– Ú“ËAw÷ï§“Óå…µØx OÌŒüùY2Ÿ_ñù/H0𬠤¥MG@ÚV!€Ðx[ d†!S£³á?Lóñ¦¥x9èÜe8+œ]–¸ Fžm¡Ò"JË++TKȽ¦Ì`ÞuÀl(2ÑÚÞým>B‘¥Bt×¥YA¨%0l+™ª\¥Ñ â„4Ý[èjÍ¿:ççCO8}åˆõÂq)˜xTµkDÙæfW¹&¢c}£øi"˜Øü²á3\.=º5&úû‚MÞÖÚåÝG•ô/2…¹FÚDuþ_ MÍU'? ì0P\ÊÛp@{Æ“ŠòÉýÀ—¨ãùñ¼Ù§c¾÷Ñbçb±µß~ÔyŸ!1=|áàÆE±‹ú@*+G0²,ÏbÙŸúêõ¡kÌ­(­é%¢¯æ*UÜF\Jº.öû`BŸBoÌM‰–‡‚9lí¾GOhA;tŠŸvµÕ¨ÎJ.te,f¥Ñ’ñ†Úÿ¼¬PL4Z%ÐH¿¾<ûE{e„žøúÑ‹\Õ ¤ÞO^Éœ%Ür 41fyÖ6¯Ç<•QëË/v¡ü³—ý]?ãkÈÅô.( c ôãU{:ãýÁµ`î¨,È„é—~:° £71–ÚœÒm?8ÒOjù­äPv6»ÐB’ª¨¶ž—íØ·0ùØgü¤n"ˆÁqÀÀÁQ:EÂÀ{Ë¥>cDö(ôoOóAèj—±«ù)aJ1y‚ªåñáåEŠØ}@ž/Ñ<#ÄÁUòÀ!Ñðüœ3Ý"u´ÜîgM†ôYãg¿•q…EP*ï·FZßù¹ñˆÐDÉ®q ‹ƒy;ßmÕz±ˆ^„Mqz£¾ ¢õv(¤R-s‰Úw6 êÑ‹Hj@˜Y1…Zé+çG5Ÿï~ e%<Šã‚ñëát|‘\Î.i~u\sbVFÓdLLÚt:BdÂÞÑUˆ$džnx¤n¬L µÕ† ºÏ“ÙS®¾œ\óOïOþ9ù)qendstream endobj 5387 0 obj<>/XObject<<>>>>>>endobj 5388 0 obj<>stream xX]oÜF|ׯhìËÉi­[‘ cŸ=äìC88Ì’³Ë±IΚCjµòßSÕávV{@lÁÉùè®®®îæ·£s9Ãßs¹¼âOÑý|t6?ÃÃéŸn%/o_Éù™Ü/±öê ~)õ=~)ŽûÊÊÇ_?ʺó[)j‚ s¹ÇãÒu¶è}—žJÀ¬Y{×ö¶“Þ ¶»N†¶´]½uíJÏò‹/Ø8—;<¶å ¹ øù6¸ÞJp«MÚýâþËÑ™œž_ÀªãÙÿŠ}7Ó–2ã.¿igÒØfa» ~ÉëX;žqñŠgÜÂ`\±®]áú­Ô¶ÿ._µ4Û¹øå-@S@Ž߸ÕÍÍûÑÕø2¡u=Ws:»œ<ß¹•kM-ï¾û.­ zz w.L°ñå\~ÞJi—f¨û“Ìa³²ØÇÞ¶eS×òàº~À%í+g®Õ+\[ÙÎõ¦-p|eðÀ¸~÷Bù|ltwÚ’‘ ˆ‰ó­,På7Œ^ãK·Üfi¬¶2ÎwŸ_ Ã!s¤€‰áD6¬#2•Ý&\dXElp~#¿x³Ë±±¶¥ƒõVà³ k®5ýž98 Á´ Öµ‹Ç„t‚øϾøEbÉôzBòÒùÖa?bßDGF.‹YÃÈuç V­kˆ]ûÜ ýh€gÏöÎdÃ[L4x¼®¯L/?Ô¥d+ k[µÁ–â"ÉÜ{”~ˆof†ò$ œJ ¼± x°¦©m€”)ºêàGÉâÎônzC2 +í£)zlØpÑsdm`Ü\i‘ÈiÃÚtˆEÓ&|uë5Yæ@²—'50Á%§i«¼ýx'«z`pבé\×o¼Ô¦] f…ëz¿RNÍGc^ßµÒYS#§)(VÁ o|kIßÂ#»ö!¸…Ã>gÃM"%›Ëfò½´…Sq@cÔSÜÐÙР¥q7±&l“IQ®îb¸ ßQ(ŸñTCƒXª½‘µßè¡9£Ga 2ò›$xžê0‡‰gË=6D¹«·Ý¿aÜ þ—‰Ç¨àÜ!€Hž¯öŒÖÔxY¢dÖl*WTz¨_¹ŽV_)•I]3ô¾Aróæ­,'Z@e«}X!I-þ %£š•žÌAÔ¦ÄgPK ZÓšÄ. Õ˜zmY«ìÊÀOZ÷z®nÀ{ÀD*Ô£|1bD 3·‡–™G: ù7²ò¾$g˜ßzä–uu|DN•Q –½Q¥¬Lt¤ñ ß,[Îöé•‘&ayyÏzËBÞE”ƒ ³º½VãàÈ{䟑Ƶ®ÅØè§ëFk´Môzâê·ŒfrÓnŠYJ2_[ܧí*açÀµeçãÕ;×’–0mÚ¶§ýnÚG[PÅ“pá^yÓÀª;Ò[Îì‰è1S)ØeÅÑÃÒw²é çвåÐjÝD½z\³„BäÔF’m„AÏ[¨bøš®Èßît嶤DÛK1²Q‚ú-1rÉ#P © ‹4{#L±¦Æ$Z˜â+­ÚÝœ=™ ó©ðn]:{Îá™ °¹‹:3¥[‚‚e.j¤1²yRòk\cVèZN´X!÷™-¡¢µ¨œ®…°m¬½_Ïå˜ûà„Š‡þAÉGz•±ÍAT§ðH~BŸGYí,z]±ïFï3‹˜¾%Ïrco|àD ÆÒøð€¬BnA¼ŽÔ‰lM£eŠïVH†v„&ÁŠîGEÕ¨lfJÀVew æCxTvÑoðÊ1á¡Yh¾¨CE纠½š<¿óðŒ†Æ‚ý•¸a×­ã‚´`fà1j¬˜z1½µ³µF1Tn×ý†-ÑE °Ë¥à”ò©Â¬¯_bÆd˜*T½s€Ê-¿ºûe|È£§}©<Ôâè*f ¸ÂKvf‰Óu~‰O§!‚*ð“K;­ŠòÒæ]ÝÆ¡Ó(É÷è4vöš&Æ€-âÎ[ k[³@? m=CÈìtÅÀ +r 'žÓ7ÑΫ4 %]Þ3?Êô2ßMÓÚxü„í 1ŒìFta :[Åý ÄÚ7…µo5o)wɳݞ~¿ZbbÁ$fYÃ\Žž¦4º˜î³–kI‰=ÁxÛ:ö¨¼Q8ÇL˜fË)êºíDBÔÜ.†’lÆÌ+(˜Gdw˜Æ  ÛDöhœQ‡V§/‡S2VCêQãb†6DS£C{d¡¦S9Ä.Ä•˜E±ŒVy5,q!3wF!¨¬áî‡XªÈ9u"¶XA(bplU1Y´¹xyûFØ]ðÂéÅ'íË‹ùåüR>lZLçL]fhœýÁ¥ÎjáÌùÄݯæ:©ÿf![ˆA‹¶Ÿó\è&ÔéP³ùƒË*!ÔV ôšÁjpŠ Eö²—ÊPˆ˜æÚP%Ià'¦.“Á’Ë`~{”*EFÈèV,Ã̲t?£Ðº ˧o#ZpA.féKßDv¾D‹3k[ñ݃;ñi倊so¾2Tˆ;Ú…Òâ3ãǒʬÃ^D¼\™ntA> ‡Áñ¾¨ÑªL™ü@S;ä ‚AWÂX]cP§¯(§?²4Âêø|Ò>ºˆ& ßaƦf'HsyËÑsi?6U`ð´þ¹ºžíwß4n JT&dH°ÂÊF¿%Yòh¼áЯ˜9Èc–#ýÚCaNïíB%m´­÷HÿÔŽGvÄ…é j¦ª0 °]Aq´;OžP7£>`zÅÅã7(k0Òxœ‡Qï!Í€aa‘w ©äqÉ“!Ót-^¿ÚqjžŠÏÓcZ¯Q‡j÷•"Tˆ¬lý 9‡o èâ=¸Ò\9Á~e;ˆ¸‚U¨~{ou®¡“ *”äÿ+cän½—?®ü^y¼ÐPº—õGŸ þÌçé¾øìϲmÓqï<>¡&tó\í1ÑQÂ’Ïø¤è域_äGÿÿÛ_Þ^5õüúÕüõåk¹º¾ždßqz1?“÷¾¦Z4úôâ,®>ý>ú¢úz!ï÷>Ãrí볫ùå¤м>ÃGÿº?úÏÑ_Öj”endstream endobj 5389 0 obj<>/XObject<<>>>>>>endobj 5390 0 obj<>stream x•Xas7ýž_±Ã@ë ±qì$Ð00!)™i éðÅ3ùN¶w’‘tq\¦ÿ½oW'ۗдBˆO'½Ý}ï튯{‡4ÄïCŸðŸ¢Þ{}µ7 ñáæ/?§'Cz6ÓÕŒFC:9y:À]•²jHWEïaA/Èê]8wælTÆj?éMöŸï_}ÞRÿËÊÞCµ]ö½§ý—qa‚[Y,Þzµè¿Te‰ý'Ø¦ÝøÉÅñÎ3êX4nõ.-ñN¤oT½¬ô­4)¯šÚØ9žªØK+SUÕM¯t3*u¥#/Vüd¡y=-±Qû@&R‘" „½‚«uz8àŸ\üD‡#FƸN8øñh0ÑùM¡—Ñ8Kõ®ªp@z!‡Â/a!^ùdâ‚JãuŽô®<µŽ WgUŠŽÞ¿}@Ê–´ôîÆèíB€®yÁÙãÇÁ«øDOg ˆ!X2õÒù¨¬Vho%.){¯×ÈÈL5UL{mq™¹uHÙΆ’^W§²ñ|`3gŸ³ìupÕµ.ÉXŽb@WŽ£¦Ð‹-3Já<ç¤Zp€ÞêB‡ üš£šQÞTøÑ+*5‡_㘔q&3¥@¦šJg5¨€´sÁÍ´Š×“ÞƒíiŠòÁd¿ƒ(=6ך·Ó4CaÝŠã.\‰X®©J„4›™Bs°µ H³ :œ¦êï*¬?UÆÐ[Ù»}ËD]„_fFЇöÞyzñ‚.^]þòû‡óÉþw–òò¸ðnEWf~zú¦åٯ® Mïê”_ü«s²üôbLùå<ˆÆŠ….¾HzQqJPCä©”EZ¡ð;t¡™w5©R7œO!(æø¶ªœT6ÏH…9ÂI¯Ë¶êÊæúª™/@)+û,E¥k QäýZ‚ú5 ¡ Éb¡9_+Q¶šB©·B4¡$@щ÷L´{+@núl? ©l ²J+óEãèz™ §x£YÃ|͉‹\FªÕšÙÍ+˜tø °“eçÍÜX”v b„ʽºÖ°˜fÙšÞƒÍx•­‡WpÔä=Ø R(­ˆŒk{m©NÔYEíɺLuÊVDRŸŒ€}Ul\LW´¾!!ËBBÆS(Û:¢d3+4i⨛BoC¬:ØE5ŠyǦÏÕScYÆ %Fu+z´=j£ù­aðÎÜ-SSêåp[ÓHO³Ï÷2‘ØÐò@¶·ÚëÀdÎm'cãV0մڱܼ׿¸Éü]ëˆpÏoôPBá®ÀYò…Šæ¤×åêù¦t?h¶úøéòç?fÊTÏÿ§I€šÌ¦[ZØîß„¬d$§ƒ“SÄ5\#/SævÚyê½ekèØÜÕq-@‘‡‡ ±«àÞƒ¹]‰gÙÙJx=7Í4íÙ`ÀèĘð¹|F+€^â•YcSɼ†öm¸wþ8¦w×Ú/´*e`î4­œŠ]nîÌ çLc d2‘jó,ðçãž8¸ yeö–©Æ±k8‚çbå0ŽE*ö#|c¡=ˆm¡l¸š±I”|¨Š47ë3+YÛ`a¥<|qa€Ìø”8€ÉcÞ°¥s&a1^mÐûXíðú|·0¢ÉtŃ•´ ÈJ¢63Qïmމë%Œ“qa¤ÁˆÄšÜJP\ˆk^«€Š¦«ªËÖÚ5 TçÇXzk.&”Í8èlµî$‡ó–º0˜2RR)Y=Âkû¼ö©ob:*y½! ´Û@ÎLkÀåºÛ–¶‰•±•†CvÕͼږ9/i«0l†ú4<Ãý„˜h –p^4Eƒ¢»ÜÊ9²†zƒåÚªšCå¸Lü!"ój+ ÒvVËÁrÐ]¡s_£Ž©S ‹œ±ßèƒ7*ŶÐÉ8ŠˆF8Ea¤Y€>‘Keõ¼B7E¹RµW˜ÞÓ¸—s‚¨:P¤JàÁÁ;´ƒ±tBžl¸Ëådb©£k|NnÏŒIw¾dKq NÀT¨À‚k“ ùç.Ðçe¾É¬ òä#3MnÒ·羈Bi¦fJ®&㻑 »]^½ªpáq"3# N\À  "‡Q|mnøG®g" C<aHgœùƒIÖ˜wÊŸ¢%ÉÂâ®QÁm‡è mou vZ‡JÔª½ rÒÜôÚ¸“R¹Ã%qŠ]4â‹Ø¢ækLÀe@Ìþ°¹µí“Ó’.Z2‰£Òµ7‡Kcmþ-1˜Üñ…]ƒÞèkÒk?`ôù"ÑfÙDjØ0ØE°ÂAÃ)ž.Ãÿ“}´-çY;÷Œ†Gƒãñ1<žñ-†g‚þh0¤7®ç•ȸ¸·§µý§é¿ä–<¦w+t”°0ˤk€qý Ñ7ÒìøÝãáÉ`<Â'†üÑùÕÞo{jŽhendstream endobj 5391 0 obj<>/XObject<<>>>>>>endobj 5392 0 obj<>stream xuSMoÛ0 ½ûWðÖ hTÛqҮǡëP`; 5г"1±6[ôôÑ ÿ~¤¤†Á†?ÈGò=’úSTPòUÁj#·Š/mQª’—GØÃÝóg¨jhwŒÝ<<@k' ­Y¬jµRh#zŒŸÚ_ÅÝs;¾¬ÕpÀâ €p~Ì ´·@9É'í` 8½S‡°ÕÑHœ3Â.ÐÖ4‰#M¯cdk§ß†èá\Jè´Få}×AR|ÇÀvÚ 5&$BìB\9fÝÿËEÊŠö£…íœæô8"×'‹S©‰Àج“#^ÌLÜœù:sûñÇbù—e_Q¹€uØ bNÎ0UKœÙS“C@ŸX³ãTGiˆ!~øí¼“é$BÁKwŠíQЉñlÉù‡Î™îŠÎœBT°â@cp:I% ¹‰¸íó8RHhÕ<ðýXÖ¼ v^‹{øá¢Á¾×)ÿ7žÎÓ½´^–äµý~·Ð‘aÝÎÃØkƒS#¡CoŽ”!v”{žsÝö(<¥C1ÙÇǘ‚óû[Àd‡Å ˜àÜÁ+õs…ÇIÙÃi•ë²QëÕª¦Qr¯o/ß–µ*á‰Lx&ÓH²å»¼—cpjÆõY—µªù€°{]Wöµ-~/!endstream endobj 5393 0 obj<>/XObject<<>>>>/Annots 2699 0 R>>endobj 5394 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 ¸ÑΑ½³ ä0¯Ã)^> !P>‹ÓÇ;kèS>,W¬'×܉( à0’ÐZmtÉ·@Û-€|³-¥­dº©rþøS>¿œ¿9CÀ~±ì±…QÀzL‹zß8ú¿{xEüF—YÞ­=s‡½­…-lÏÿãÎ[sfߤ™¹™ðoåÍóm$Ãr$¡—`B¹•*t‰Î9§ RFaª²¨~ϨéJ›t'[pŸ¡}.L¦µ{T XN¨ªyMÐûÑøÖ¹ò{°&탾#qˆ˜"O¿7—.Ð÷h<Ɇ aIîSÂ4¸Ö4¥kpú)d§§‡×ô|^p÷IYعaJŒtŽ ñâȔٜ‘<©È ;}b7Ï{β¯D&Rv5½S¥ÛªãÄ@ÄLSvŠ®â”j¦7™ÁR!y”ϱ(Þ|è[üEa`©ã¿,©jøéÀm=rI%탻oF »Ó7Ä]‰­èmY=Èqìw,ÑJ~—Áø[м)¢|e‘%ܵ]šç»ƒºy@;a§´Öâ—á®ß6íþ[R±Önڙыñ?+a`¿vÅAÀÖ¿¬N~=ù– ¯endstream endobj 5395 0 obj<>/XObject<<>>>>>>endobj 5396 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áKS£¿ZŸpªuÞTâôFo>c3ï°ÖÔ G¦(‰¬wÕC8÷½8Ãϵq§1#²Ž;Q åÞö°I1N–¦ H}Ó¡{ÎDžO\|¥Q³< ݃/hf%8RŹi”ò–U!hŸ²9m¢*3áztµ³¬žN¯.=Öހ觬Œ3è Í½õÙe•lŒ ‹;ô3ƒøõ9r.ÇÿCÇAm½æý¶ò*Æîú¼çFò;ìšÓ2‰ó©a DÖƒYŠÚô‚D8í¸4^p{®°  ÅvÿyÕtŽ´çU#zmöI„ •†!öšÆ*õµ´êÒjµ§XÐa.²Š›°>[ ÿ‚r¹nPÐWw³ò®$&• óˆÜACí¯ïö)¢ýµ¿‰Î9æ7å3ÖÀûŒõF´£„¿re¤xhù¯¾;A¿çÔ÷6ìÿY<¿$=´Êϸ༉’£•ô5»¿’qz±Ë ž¬–ÝÛ'^ÎØ<Ó"½aI~ïŒ6¥uÖøwÃÀ0詵_·9‡gMB·Â9¿÷=ÍÜ–ŽJÁs09<¾|‰æÓK¼‡0åæIê~Z>þÍ 2endstream endobj 5397 0 obj<>/XObject<<>>>>>>endobj 5398 0 obj<>stream xUMÚ0½ó+æÖ¬²!,Koݪ‡J­ˆÔ ÒÊàn°SÛa»ªö¿wì|@(‹ ˆÈÉøÍÌ{oœ_ƒ1DôC’º_¾|ÊQÑÍîO¯áêáÆ1d+ŠMg3ȸA–IÆán•4–Ik€I(«-jf‘ƒ}-Ñ\d?WÓ2Š'´'ãÁýQ  ·W·——À1/A¦^4+Kd¾‰g„¼Í8©lwÛ¥6ap_õ(N]:_ì´.VW¹Uº®÷mÖï–ê;ì6õ ª7‘¾¿ ×H½/ƒåE-€-ÚâfèYâû¬ÇúHõzq¥tCLÁŒÁó¤°°Äm_qû„ú}BæXãr…F~°`ª²Tš®5BÓPzÎ,ƒã:†û@— V•ÌkUIëWUipr“Ø®è# äç=h\Wd‰gµ® ¾cZ°§â (™ ­Õê`÷2PÁ*X£»Aر¢Bã=Ü^mŽZDFæÛP[„cGØåEH¶¥2j4ƒy™K%JNv~vãºø6¹g#„â³mYàÖb‡’"…«c¥#ïpbæ­faâ&.v#‡IB+xtXlX‰mcä[üé­Ê꩹GrÉ|Ч!f§§6„´Î•{[Âè9HãR™~Ì›_î…‘¯1 ÓôÚÕ²øñå3qS¤ŽôG 0h»jÆÌwðØÕP?m™vÖˆ1F²Èz&9”=6ŸŸAë¹—Ä7ð‚T]™·WK7+éÞÍú©L )d¾Scí¬}v™íľaëg?Ǿ>8Ÿ7•Ô;úš#tÖœiq4 §Éâ›qètâ0‚;•Óa/Ýa ¤!%ëØÑuíšÿ~EL£4Lbz?¦ñÄÝgƒïƒ¿Îw¢endstream endobj 5399 0 obj<>/XObject<<>>>>/Annots 2753 0 R>>endobj 5400 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õ2/ÜŧŸß¹º_»wÓÍÐÿåò7£HÞ ˆ"TH\óËî_EYAÑË_šñKÛÜKEó)Ó‘bgsì¾­_þ+«æîøù?ZáÓg)}}ùql6m×öõØ6;ÊÑ¥~Ù÷}Û–%kü–ÈÖ$?øP&÷ú Ï{S¿îhhÝî¦ýÔnı?$Jq½O²öwîÇjè¶í†fk·¾ëë®]¹nXï7͉×z1ÕlÁô¿aýÄÆ4°wÃ~|žÅKT±À¡wõ;ÿá×|š~‡_œz[Õ6wôzñžñìªÜvSO€Ý©ÿ´o7kÚÖsîÞ„U»}¿nF÷©í×Ãí#Ý8CQLæn)Uá;Žx²àí&&öãªÞ!õÎ_q_nÇz»õý{9t3×?Öœ£óþv߯˜#§¶ón3\Õ÷Õ­¾Úh‹NÊ·ÿea9ÇŠ¦ºŸvRñ›~ò´û8´ýÔŒ§ŽãÅ4îWÓ~<}‘˜«M½Û=‹¥¶¿iÆ;¶:uÑ?ìÓnl®›±ÅÝÈËÍž?Ùêq¬ïN½<÷†ŠÍP¯›µ»~¦c(f·ÍXOÃÉS•¶Ð͛ݶFŒOÜ^ilj:6™g±uÑÕãäÉô ‹ ÙŠyiJ³vÃÕoÍjzd`}ÃľsV]ʰúv?N8±nÝL5ÆD‡!øÐr¥n8©‡×Ø{F'öµãðõî™J gé¬íÝåÝVÓ"úñ ÛÔûðJªð#u^Ü?RËã~¢þà[8î;wvæö»†ëþtê|Ãö®™%^áºyò±|Œ!ï›nï\W÷õç¦kúé~'ž4æûI,Ã=N~¶L?Oj/>åž÷w­…„ì|v;·©ûÏ{DÀm‡Í"²½iwÝq²¾é1­p˜\·#Û鋿߼§'NV÷Œn{Ì,7íV6F+ õN¦ 'Æ›¯«f+W”}?FúÄy‘¿ijty¹y®w…|êÀòÓÕÛGÖêïæûv·j6HëfØ?Ò–?VzL~¿Ñûî}:Áj¿›†®ý^>¯›:Ì«±úêÍç¦Ù :>Ûôóz-Ã?˜t¸øÊ´Ö§ž;ÏYôâÜݶÓû³\É×'ÎùxÊnõRÎÖýñ{œ>W ¹Ú>>/XObject<<>>>>/Annots 2779 0 R>>endobj 5402 0 obj<>stream xÅYÛrÜD}÷W ®Jᯬ»´yKLœÊC S¼øeVšÝè²èbgùzN÷Œ¤‘1äR˜”ËÇGÝÓ÷i)œxÂÅžbú?«N\ÇÅ_è‡G?~~}’øŽ+âtŸ•ð\× *Åûƒ =Ç·X-š$Ftí¤"f¤EgL¢©Z¬#]§N"b$iAúk'²HƒMú²¦ƒÑU²,aH+†ÑŠNý1¨:ƒˆÄåÿsö»©W­Ø£0J„âË*pE7kBs†ÇCœ|t<ÐüZ¥!=ÿ}“u}Ki¸Ré×Óaî›·M> (óñ±/3‘›‰|dV=Ùj+nÎNåÐ78öôæ)9[ôÀ#çâÔ5ÏÍ'=ÔÀ‰†fŒáÇÇ(?nÈÃÇz_çXÿë|c§âûÒãWX‘#z×øÜ T÷”•úÏ3å¡kÛtë:þ¼nÅ‹ ˜KõÌ~—»O¹É©ÕÛŸ:ôÖ`N ÄûáphÚ~Ù„ã­.d]7½¤ þ‘'ÃËa»Å¨ä¹•™zäã^l0%.çì”ÈJÙuŸîÉ8&˜=Ÿ/®¢q»óéEx¥«ócÁ|.®÷EG›É.ü:Ô9~iÕAí7äü¼aºbåó0_ÈäªËÚbƒ íý¯o^Û‰N'R4[³8Ìò¬©H"–CqWô{Q5ØZ•a wlO­qÈ@V¼ÇŒ%‚÷\`œqÝ2>üœ Ù‰;E×y'š’œ˜Tå87ÏÕL·î$ä:âªiE¿Wö“%¶£îvÖ]A*^^&@àñZÝ©Ö1f<¬¡ƒµoaîèÝ ½È°Ê¢es·*Õ­*E®ð‡²Ã.€ a•Ã{-¥w@œzÜÜô'%Û²€Y&_#^`·Üë"cGË®?•ü]!!P|lø'söötYÕãeyÆæ¾”]‘ýÃ:tv:žÍ¸¸Zão8xÿ ê /(>|]òİã¶PwÔ“ò¹n¢ÌÇ„¨½BÜñÆRñ6€€±AZËl)¬sm#³=än_à—ƒl{$}˾Ý×ÂaÍÕ¶¨uX±sÝ+¢lÊõ°Î¼ƒ.QXÖØ*J`geð®…Q”ô;hBäG²&WÜTÎFåiÍb_ìö:÷‹bëäÚú›ïhšfWÒ Û0©¨ä\^²;`çç¨ÌápS+›ÕSÏËŒºo){E¡-e½0ùöÝœÁëžjˆBÝI9Õ”q‹wMú’rI]rùÝw7OÑ_CKÑ­šV¡üb§jÕêvÔÁ©ÅñŸDΩRwª§Œ7=J¦nKõ¡ØeÑ¡;3]ÚDÕh` Èì³®%=oÆÑ4­0„‚ÑÛeàßÔÈÏ6vJ͘î†seMÏ®ç:„—ÜÅ£&;ú‰b†ÊÙ»üojš2Õ>Õ;Ì®šZ JÂæ …«¦%ñ\£ƒÿn%:+49å@ Wv­¬*R;•ä8¶sÌü–â–‹lèú¦*þdû¦§ftª>½ÏQ%Á˜)VP³mJ 7ü‚HH‘ôr[#óÔ+èí™^@õif~d¬øâ]«ÊÞà#ƒ¾(yáDO ØÌŒ Cèç¡®Ésš#äǽËL+ÞA|… €ò³‹gâª(Õs”#,p ñìbŒ'¯KOŒró€Ö6~ñÒЉ|DÆ?íøkÖHŽ¬è‹Ø÷MƯï=[ùøGO¯ú ôÀŽðe-ðõšù1 ½º>ùéä/†Æ endstream endobj 5403 0 obj<>/XObject<<>>>>/Annots 2782 0 R>>endobj 5404 0 obj<>stream x•WïoÛ6ýî¿â°­€ÓØŠl'NÚ®_Ö6`ØZù `$Êb+“%Å Šýï{GR–­üèšeïîÞ½;ÿ3˜PŒß Íæü—¬qãþ7áŸ>ÎâhF'gÑœÖ4™GSÿPÐçÁÎ#>›î~öÛrÇ—shWttÓÜ-3šÆ45‰æóSZ¦îƘ–ÉðÅ·ƒå—ALã Óáϩ̔–ôùrññú|qñáúr±üýzñÇb¹o§tR4©¤ŸäX—…ŒòŸö ^üq/ü*]S&’úʽÒWoøã£ócâ{3Ãl<xÃe.É /Îà{È:WC*8¥+i늭Eb Õ¹¨©*e¢2%+ÿXã+«¦¨•^Ñ;ÊT!©ÊMS¤t#é¦QEM‚}”÷untá”C’wµÔ•2zîbìqmÒ~zø•Võ~ÌCJL*#Zæªê[Gªoë°m¬(»¤Ì…Ùð••âüô¯Û[»ª§Óh6ÒáÑK:Gˆ¯©-ZB/ø'ß×ÿéº>QHÚ'áGet5Ôô+ÅWß—ºC^KknÄMqÄ×Õ$4Ik!Ý5BC.ð烲$ ´¨›9Q83=fµçäi±–ˆËÙ„Ìx à"ˆ€ºE2kÖÎ`×XérÌl‰èZ8‚YçuŸ³\ûÂmgu;^z6í^Ó‹O¶•Ûâ{Üéã,EÞQ–\èçCU#âd%.m†zÞÆÆ¿ÑoT_ÀÝL„bºÆéeíAaô»ãí®XÖ»ÿ…7툲ÓÕÓ—ïÉüö»ìb >×ãу&ãòy>§é³³eÈ„Ù_Q.n¡"JK¥ÅN‡Æ(Z~`WBw¥YT„nÉ1þ¸kоÆô#qc@,ߌN[a߉þ¶Ù÷Rë¤Ì¡;:E¬¶èñtÎ4ŸaEÆ"ü·©ªê¦ÆÝû¹aããhÛ¥•IËZPb cMR§õí6ÇóÜO Nk€—RµW‘íÍ#Úä aMv #гV&På½°°ðþˆ>/XObject<<>>>>>>endobj 5406 0 obj<>stream xW[oG~÷¯8¥‘Œ%vÁ·DÊCªÆ¥Vm*?„*v˜v·3³&üû~g.»€q•#³3çúïœùç䂆ø» ñ5¿‹õÉO““a>ÄbûÏ,èüî’.†4™cïõk|‘þ9¾}!¥vº*$µuÓ+K…(i)J¹R¤KëÄj¥Ëm«ÆP-ŠG±àuW‘ÕNeqÅHÏÉ-…#mI*«’9½£¢*çzÑÁZh®!tÚÇâ“*y·g“/'CÊ.F°¬_`EÉ7Ä‹çwpÎÞ·Ê5u^û½?ýéë*Œž) íŠÔW§J˪¦}¸@F­„S’ê­[bq]Éf¥ìô,§ vw>oôjÅJZ¨RÁZE0Ä‹4z±tðc]Ãx³g¬„—…ÓO¬¼¢Y£W’´£ye8\yÜ;ºdÇ>(ƒ¸YdźF¾ÍÃ2–Èî‰YõÄNz o’„Û|ÌÙ!ˆ£Q>ã—ìÿøÃycÍùL—çª|ŠH!¨²ßëõâo²lcÜ©üøpÿKÒ¶·µ; ¥8:7Õº‹f^Tì뺮Œ#Ÿ¹½O‰‰rÆþ\ôäsÈ ½í¶Mû§ŸãÓÓÁžnzùeÑBÙ·ŸN“àu^œ(­àÇßß,oz5/½+V)Ö ¶&‘Çí{RÆãû†ùÅñ=¢*Mðç-õ|¸® Û;ja@zí »{½1€d7z‘²D!,£w\ *$†Û‡O)P!ÇCSowOôâ‘ÞñÍ!f]f–ãüúú†‘r_È(ƒ(dàa ‚QÏJ~ß²}läx*êSa %Vv8Š%OÕì J4§æºd>ãrâD&lyöö°,y[çT%’›$ä%¤òåc_t' ò™¸D;’f[ŸÑ !ìki0Æ$/ž÷ô\«48•üó–Sƒqò8Ñyæ{jK¡óÌÑ­pð@/m³ NGœvÇ$†_‡ûI*šÄ°ž¬@¢®M%Š%m*óh Ó>“*8ÀákZh+~[m4ø±—†Y¼êð­¥…§Â-%Žõm.ü¨ÏÙÁͨ”ÂHŽmÚ]ÊjcéЯ€ðpýËC‚îkâàñe,ù(/sLíô'Š`‘§’[T.â³[>|™û‹ÅÃ’/Ul÷Tt€ÓR,½ÄrQqâf†D³€6èò]¥V˜+ýßúÔÂpà|5Aæžï;!ò|/h%Ì#Fh vkZȹeci-¶`A‹ÆP¥L°Ú¤kšçÈ*Ck昊d…­Ða>+\v¾·‰ˆ© íÀ€Ýë8¯EZµÑ/.Âiß.« î§è¿ê²ù:=ûþþt~—ˆôâö2¿_Ñ5>oµŒgül” s~³F!û‹±¯ÏÑ0ìÎnÂ}ÌãbDùNÞºÏ[¯†×ùx(újtËKï''žü ´Žò–endstream endobj 5407 0 obj<>/XObject<<>>>>/Annots 2785 0 R>>endobj 5408 0 obj<>stream xXïoÛFýî¿b`4ˆ˜”%ÙjÒ~JÓ81pi{ãr +r%m½ä²»¤eáÐÿ½oöE*vÐÄQ$q9œyóæÍŒÿ<™Ñ9þÎh±äŸ¢:9ÏÏñ ¿Ìøå?øZÎð‰*š_æËøAÓç“ÁÇŠ.^ç³ÁµŸn¶¼A»¡éÕ9½Ît³¦9¬¾™åËå÷tSú'žÓM1ùŽ6EAÙ¯sÊÖ¿]¿£¬ ù(ªF˼xuóÇÉ9e3,¿qðngE“ÃÈõ´svªM!ôTÕ…îJ9möíÖÔóüò)cn+¬,ûšô.X4”ºKÞ8æWÄþ¬)C@Ù|šÜl%ß]´T˜ªuéhm,•FÕj·Êу°{Z[SQ£E‹‹µ¦ŸÓG³“ÒžÑç/רµJ:>°é¤Ã˜·j³mÉ4­2µ£ÝVÖ¤ZR.E6g˜TíZ¡µ,s‚KVâ9òŒö¦£Jìi'ê–âŒmi§Ú-™Z’YûÄP©Úƒ>à û5}’ã"°cL&T*+‹ÖØ}N×lT´€@ºúe;òrgì}ðj§´¦Z" pËJÿ*̱ "¼· k£´´lI«úo‰€zp>!˜ˆQN¿sÜ6¡¡b+‹{>î3le®y}¾¨{5>—X=ñ^‰²Tœ ¡§Sð§<Æ9¿àl|á$±³Ì”–g|hzu™õÔ¢ê3aº¶éZZ#`Ú Ï˜/¶_ ö¨A¢Õ#@\íuu)­+úð ÄÙIÌJˆ?E›ìaŽÁ×ÓpoŸþÈŽ#‹§gìSàK2ÄùÀít©Kݬþ-Bm1|à~V²»¢„&Ap` ¥ õž ”s PÁßw™©ñ|leí‚|A{Àrÿ8|mý敚\×4âä¹ëõ Þœkœx®0¥„žÕ/ÞŠBx¢B×p¥³òöU „‹j%ÁÛb+ê ÎCò¸êp8[@i•ƒÓI,‘c›<裉€ºTûAD®@‰X3¾F޹áLq/½,šÊ$å¤ œ×èñ°¸Ÿ¶•7ûc>°Xqò.<øëÉ铨÷d|Œ«Né6*n¶Ñ_J÷Úhmv$È©JiÁ]?«$ƒÓ«7ÄX¬YYçKÄÅE>Ï/ès IÇN{ºã N¿­IèVÚ§Qc¢i¬¬‚†Ê=jù`‚™éûzH䉪aúˆ×Ðð¼Ì玠æ`L¨"ô¬®õRÝGîyïØGÎT²U:U- tjnòe'Ù’*'wkÙ{lBq%¢PÚVàH…à n0 °¨82°Q˜Âª"p|õ† Ç D¾ƒõ;Ú£þç3§(¾\ðžÛè(A€×ÕÕ:¨e\€a.æÚDb $ÊgŠót';¢™B–¨´¾E¢b°Ù%f˜>3F?pW¡Kp¬ñšCË/0¸p“e 5W€wãÔ˜Ñ}v>ùæê¦ŸeÛ5cR¡e£—ÂêÁJO’¤ôC‚ô?úñIÜ£³b=Œgˆå €;èÙV€ QLFiâ )=6ÉõS ¦±4öH ^_b~é”ñË  Ä“JdÕªc&€P%Q&É ¼Mjß;†qˆ…íI ’Õ ƒ¢Ÿr†¤ÕÊúa•Ç"ukˆ~Ò56À.§àž4þ³ù<_,° ”“ØL“:F¸0Oó5UsW¤ÿO(ú¯¹^-G RC¹/´·¯~|î Ê9ã;ž9Wšn…ø>íï0™+÷cs/þ:vÌotQ;¥ðg:…^„K¾'ñÄ I ÓÀêÅ6Xû%b1Z"ÂÃÔõR[7Ä(ôNf¶wÅÏߨsG¼] ÇòUfÞ8›Á;tGžÂŸLðX ½˜@~ %ö VAoY«{ˆåÛøŽÜNm(kBÓ}2P‘ëÙ'=ì†éZ¿¦}ïöv”þ˜Êþ·ƒL>ò$‘%á}îüÏßþ÷ýÝ»_¹ºþp÷ñÛk䌞³2\>Q@ýâ9›"kÄúÜÿl­OÞ˜é€Òûv¦+ü+õ³Ö Uûpü›Lc ­^Lä’åÆñ"4Àï ¼ÄùÉ.)@ G`Œ¿c­,º ·Á8^ñ®™J·‡RUƒ®C ƒÿ~ l—½ˆgXÔžŒÎŽÇ˜L×Ncœ}?ª À×ny³<:œÓ[çº*´î€iäâåS2CÁ}ë«NMŒ*yÜÁ賓”kÑé¶7  Ù°ÐO”O‡qN½Ñgf…ï~üjxQûùPmC0¯#zóó‹ürqIËåE˜œü,;Çïp~6EWÁÉ~~€ä„³Ù÷¡ÊüH¶ ÜÒ͈~^ Ó?ïò|™/ææ Ó—ó7üÕû›“Ÿü ßêÄ endstream endobj 5409 0 obj<>/XObject<<>>>>>>endobj 5410 0 obj<>stream xÕWQoÛ6~ϯ8æ±êØNÚC†nk¶d“lUé:\®>ž¼¼Yvvº­©q* &Óg´³-ù¶eއ6Ui¹£àðÏ’z°&',©4õ½©7dÖÔXïMZê„ÞÛJó²S8ÊyªÔŽRM¦Î`¯sÞ¥õš˜Ñô|÷&‡ûÕ ^´Ó>]ÓF‡ÀG¥ø­5Ú­­«TáÄŸíV?hw&‹ž¼¡’ÓÝ¡ÃA×¹gGà—S8ËÜ©Lm*Uª,Î÷&´ØÖžî&ªÎéSk‚¦µSõ= ©m ­u¡ôcpŠ å}É!È3Û`G[s ¡0žT ëîN“˜†}º¦ó%ã,5805¥ ²¿>JØ ÅÕ „${¢«T牉O÷©-Mê²·6ì§\7Ng*  <•R­. 5àKžq;­œOèÝLày»)È„dªi؆1},î_ÐÖßv0¯ižœŸáZ·¡uš|Û4À‹Ù´ ( Çév bp’Çtˆ|¬Ì¦Ì°å3œîØXQnÖk°¤>rÇY•ÈQ¨Æw[çÆ‡6˜Òà¿!æ ×Êt~Éà/–É<¹ ?Ä”‚ ò¶ÆîK†Í—‰dk%„æªéMÏ@™ª‹ º Ãá a° ‡ùâè5© ¢Ê’6V{Ú게Pl ž¹¨Kìn…R?fô:Yp4söož,ø–O¾¢FѧŒ5ar}}MÑÒ î59¼îž'k(ÃÝdyw:Ú`¾}Å~ãP¦âÄ"¹¼|Åç½¥ ⃤içÀ-pP›å¹6·i0P ¬k[–v J|>¼/D²‚°éTe÷`ƒÔ3 eŒm©|¸;•ýYŽ$t¢®•ßú›úúÅ+&põüÝ(èÞ´GªÙõÖóg­©‡üÃs˜ß !Þ1>Wô«íˆGµª€ÓÓ{€Œbõ†\ -¨ÒÞ« 4Ý|VP°P¨ 6 )Eo `àÒÓpÜŒüÖqE;<ËEˆ¡üHÜ#„ӳŊ ¤‘OËM^hƒtöàˆ¬óFGkø¡“bæ°úEݳ"@Ï:GÐ*öž€5|TýÑœ<€7H`Qâ혋“„ÞBìr GG>rø–¦R+¤{Cmƒƒ™…Kw“PH½ !÷Œ[ßñ::ÿo;âX¾CÐÉ»|æ,4ÜÎr½fÆ£kˆv¹I¿›ð÷â1àüoÆ ;àõŠÛf|P¥Ô±*·jçQÇœ¶º“¢TåR0Ò]ÀHt,–Hp¬Pf6ý¨3D¦'tw…ˆ‰µ“9›£ØŒ Æ!ÔîëýˆgÀ̉{ýxí¤GRE[¸†Ê•`ÁÚóNaà-Gœ‡Lì•3è1pC䊊C†îR:â:–b Ã&È(-š×ué—åÜœKÃxrç·a|ý\;œ@ «ìfB?Ú­iššË;È$‡&"íªzRðýÑ#7Å MxéqÖäu¥BVpM£pa˜³ÂÄ*— là¹U6ÿçíOÓ®1äð8Ô‰ÞÈÀŠ~•^…, )® !Ÿ0‡„?>™õŽTdÔ‘é9æ!ÈT¦T®gï?l…ÿº×õ„Þ7°ÅçØûWòò á¯DUYTp{ØU©-¯ˆ§ŠÈ­~Xýû¢o} ÁßI9C™ºÅ¾ñ£E¿bŸÖ¹çFÇ`ƒ•ÝPÞß^d(ˆötZŽÍiDiTÜóúf™‚€—zÅY›),D±èw¦ÆÝ]‹¸¸•uÜ>>2öC>¦Á=rWvU=òÅiÜCXÒö¡uRÇ¡i7fßËxÂÂ$\ƒÆ¶äÙ+¦ød†×מXÕ_äbЋ"ÀÆë¡%H¸kpÿG:c’ô#†aVk»Þ•(ž"æ}FåhŒ·Q½ H'%rW‰éDüèGj!–Ús.lùו½mK£&œF#ƒÑ~•eÖÎV{WE÷l¨mrØUó¿Zá&c‘uããDžñpÇ)ã$®Ö`Ð`'‰©qšä·‘ö¯»›Û|¶L.tùêu¼Qˆ.Í“”4kù* ‘ó"TH´¾Š³ªÜV–ô~t#gË‹Ùe²˜ãZƒÑûb1ãGïV'¿ŸüVD3@endstream endobj 5411 0 obj<>/XObject<<>>>>>>endobj 5412 0 obj<>stream x­XaO7ýίU­rQØ=¸ƒ ‰ÚT )JÒ@”VBŠÌ®÷ÎaÏÞØ^ŽË¯ïÛ»aDÒª€ànÏö̼yófÌ—­]ÚÁ÷.MgüS,·^œmíä;xØÿ²síÑîUX;{‚eø/Š‘©*©K¥çTÊ¢Vxe4KkÓR!4µN’_Hzxöyk|cá Ñ/j®•ñiwüˆJeeáÕöŠKÂî‡ç¼g‡²É)-êz½M®ml ÏÆ-Ék/µcw–¦lkIÊQ­ô¥,i¥ü‚„6pÌâÙ…v¿—ìªrO;_ò)G=ak“|:Å»rô3Í‹‚2·'Ék±lj™›îÕ§• Þf'ã…YÊñ…_k¹7Ö|Fhn s Œ]JFY]³auDçç)TƬQøÊ }ꌺ´§Ã/ žNóÙì1o8®îB¾·Ôíõ Â,U#0áHP 2!´’ºTó…'© Ójø8¹•©k³b Ì‹Z.iµ:,÷@¹d„¬Ä\Üñ³gÏH-ca'â;âÌŠB^ˆâ’ÎGKã<3R{Э®©Ο? ç#mrGˆ‰~úÕyPõÙOÛÌI»Û¤4ý>8û8˜}e­±O •;ó”© ºiVBÅ\pB©ÂÑOé‹ExÇôD6v=8Ûüâß*l#…g #Iö†Ù;—Z¢Â Yˆ®²ÊµKUpL—È<}à©6Þ•ÿ>¨¡áž9}äÜ R¯$Ø`%N¥,·ùØ.® 3Í­GÒQÑK®F2¿Š…,.™E•\‘óB—–Ñ1¥‹xfÑ^Æ­³\$›îaÿÝKi}džœÎ Òq g]âep=ʳ#8Ï9ydk^«ç.—Å«49)ë|¤>?×b‰D:ß™ -xj5*£tŨ°,â,ä11z щÒíõÉN6Kü¾¿Nþ) Ò“¤f|ÔKÒ´/žì¯D¬Ì†€¾+k;½¬¥c³o‡ýk {^Cc4à»’¬òÄ–~aqÝ÷Êï,C8ÖSvç‰0$$”ÇÑI¾—å$öÝŒ}{°ÿñœÓ£0M¸yY׎^rývÓáÞ$Sº”0Ë0Ì4¤ó €Ô¬ ºž$uˆ< ¹dÅQüE8lPþã&AWʃ@Fw1BÊÑõÁ m§E³]k|n ˆUJ‘˜‹îaV| €õ )TY³ ©O·vµ‘`º~ÅåŽùŠ•*h½S0ˆÆ9É:ðm +Δ —GËÁ&x\# U)”Aj/\=À!!/Iu£Ì*P™õ±7S²û•£‹€Göoòz]{9`3n¡ÞÃÔûý§-´éÑ£A]˜Ü{SsˆÎ˜ŠÕ¬SëÐ*4Ë-&ÃÎ>èÆ¥8«Ñ‘ãÛ·³¼—þx‰€÷ÖÕàóÿXL|Æë¾vo—ÑÉYŸ~xóÑ<áZ<¼ÛÒM8Ò?vöòýé>Ífùãx!?ýxü:›ä;ôÒ-Ïv¡¿1Šâêìq¼†6¸O‚œŒïïÌòé-e²?ÝåG¯Î¶þÜú°^dÞendstream endobj 5413 0 obj<>/XObject<<>>>>/Annots 2790 0 R>>endobj 5414 0 obj<>stream x…XmÛ6þ¾¿‚¨ƒØZ¿­wSàHÒlnI›í,p %Úf"‰.)­×÷ëûú°Q¹k}0cÕìŒ2Oת´k¯½5A5NµÁ(í –UûÒ4¦<ªÚÕ“½ó^—f2™]«¶,ÕÞ»5Þa1÷NWQìÞx[™ºÑuuöìþËÅTMæKè2ú„ >µ7G¨~4*´Û­ åìt£,þÈÍMÚ)Ü›ÒÖ_EíÇfçjeëÆø½‡’jÛz+_?.ÊÛ¯±¯Ò_ÂˤÄlN%`¸©tS•+ÚÊœÿš©»:ù…˜:7Êmðºègzº ;Måq€Î›V—ðÞï ü&~X›“ê™úMOê ´87à`›Õ„"ÏÕjë¼l Á {“[]*ßÖ:ð,nX’{»Æézí$(X:xÿg¼Äuøáòhù@“Þ Ô‡=*ÆŒFع¶,…F[³n-¾Å¨ ƒ}·‘ãá˜ú§Fa<"Ú@Tm±ŒÚÑ?ðµôJŽe{e·»ö¸¯ ØÐ5Œ°¡á: 0Üz]eꢩë£ú½¶OCët¾³µ ôüty â•EßtY3"| ¨ˆ(/qTrÆQfoêÀ@¶dêžXHžÙZ ˜®– @صhá€æ—h†À½qSœÕagjYúñJHÍÔ­c5ÓóçÎ2 ~Î,›g‹žŠÑßlSá`·Ýa$ƒ‘Jÿ À¡)òçÏ'ø•¯²Ùd–¦ûû?Ôeü%^ó¿¿^ô0š>-§ÓÙ‹étúðìGT”¸‰IZz“¶_­ÿçöü»íéMÚ~}ýãíQýÆÕíÓÉ0Qcð6É‚¤Î’ƒNÄ£‹lµº¦ë^"¦jckd¡ð£Í…àÆx[é/ˆËÁè¯Z ”‰Mà£ã³ÂÌŸÂ@र*—†pÓ¾PÈXC>(ï,) s$è¹ÎÙÂd•Ñu:„æ®ˆÜ ú+Ôˆµ›Aú5=)‚ëÈÞTE`Ö¸­AÊ{&h\òèŽÄ:Í0ª2•£fh¦ÞEòR‡@Ð#q Ýhå[°£Ç;K°²@'[‹éHø‚¦w……©[/ oºÚ•à"›Ÿ§xb_ֈÎ#Èh D[Ã,››"Sÿt24Ø«NÔ$D†ˆì]ÄÛ'ÿô¤Ó×T#-ÞŠ>­î–odð2 4éØ7’iǯ¬¬Á”›IîPƒâÌ&©¥G¦¬tƒªvnËi¹“È;a‡Â ¤Ã#WÆØ¢ ´% ë *ì^ʼ~tÜ`¶}•VÝ–MŒŸ<ïï¼#XøÜec´‘zÉ“Å)¥ÃFâØmšm¤Ï\€ƒs–.‘„Z¶~DÝ·[ݘTÄ}ˆ@*Tȳ>5B›ïˆÌ×ÞK¹¼}ö+¶9“ùŠé¹@ó‡¶ïµŒÊ1VËÉl_ê†"%J§—¶$“Æå£_³6´{³_¦ŒêL çÃÀ;oŸÆÊ4yöðlÜ—éœ~Ú¼ù£EÕC5!¹K©¤jß¡õkà§ï¾v%CZt¾|2ó˜Ñ8+¶Cú,ûƒ¦I`&¹c¡WnÏ ðE磋Âò©Ë¤Ò@¡­A‚JsÒgû+û¤sñ1HZ õÌ‚„5*ht-gú{…{4Ÿ-íM’êuêöÌ“É[éA¥¦êMŸ£ˆît8?ihŒ81ÜX<–ÂTz<0™‘EŽ*¦ÄžI ÓèýNxøN¥^¡éäØfpHìµ£\0/&”~Ñ>èÒ`AÃ$ÁClu€‹ÏÀÍ}ƒ1?f5ª šèÎO±­'Ó¶h¹}ß“®–ô3Sƒ¡Ø¸p3‚šRy g "A.}»R/I£>ßø7¨IÕ¸BÔÀî ö#×òs!݃P ¹§¦ š t‹BBû8©öI(ðøQåºQ¯8H1ç½é†5dˆøà3º&wøq ëhõéóÝÛ—0#“Ð$©P®Ýî8•ÙÊ¢¤q)MCÞpü޹)ežƒU¦~ïGmFœ” ¢–}àPlEÆb`å‹‘ „.{ ŒÐÀ)RÀ°2Œ'пÿ$aŒ<§§¤ùLÁÚD„>ŒDMqñ5œˆŸgW]zhF–‰‹2‡ËÐ3‘ÿ²ã¼úÔ´…u§¦ bÇô@Ágãc”E„·ûl†”!ŒkNeš¿´%å¢!ioD^J¶÷šÇózßbXŽ]ˆH´ìä‘•ïñòíg{rQví§[GÌrõ·uìÇ™œÈó³†×hpÈèUÂ`R1Þ—|üÇA žÐ˜ø‚oΕ±î¥wwS£~\#MàV©`H›©6u×Jb8Õ%«Ü= Úô&‚ 8{ š€í#ðVÈlÜß:ýgõ­1žãž-§V¿¼{YYÊC–Nc7ëGLƒ³Kšnâ7¹pÜWDÝݾÄkšTž$ýžßÛÜ;Ö7•†!‚£ôO0Z{‡#Çœ‡Ðul$ ÝÄY*Þ ÑÎ/Pã(¯¯FYöñáá™Dçt‚ZQsN°‘ú\ÞÞ¤ëùt™]-®Ô ·Œ7ì¡©÷dŽKÍ_\ÞöÃ7aŽk'×¼:Iíö*µÛ2S_ŽE=ß ®¦« \*{®sÊzsñëÅŸìO3endstream endobj 5415 0 obj<>/XObject<<>>>>/Annots 2793 0 R>>endobj 5416 0 obj<>stream xXkoÛ8ýž_qᙢ«‰Wû¡@šG'@7É$™ 0h‰²ÙH¢‡”âxûßçÜKɱ\w§[$0l‘â}Ÿ{.ÿÚÚ£]üíÑàÿã|k7ÚÅþØãÛOü„Žð‘Sÿ : ß3ºÛzù•Óþq´÷²òñ~å9ÌMèíÅ>ííÒ} ‡ïð%9øwÇšìL:¡ñ‚rë49뢤'í¼±…'›ÒŸÆW ‚Ë*16¢/¶¢ÜL¦%Ív––Jõ¨IÑ_•‰)³ö‘žOµ×¤ŸU>Ë´'SJSâP~Åi•˜b²}ÿuk—z{}hÕ-§Æ“×1ï‰ê•þ>¯\t¦Ÿt]]­ÇÝ=\~"?µUí5<ÙG¢T”˜4ÕŽ3ÎWijž ÷­Ž¾Š§ˆT8½½Ô¯­ÂóóšÙâ5l´Î-ÈlpAbµçúÙø’ºìõÖÓµžqf9-ú"¹Ùà@ß‹0R ñ¿ Ù¡Ù_Û•…ìðºä¨zÊuQEôG‘ zÍÃ&óxgç4dþGÎüN“úÁ#ÿwžsÎQ‡õëp³€DûØ©(äÎ’ŸMñúðvL»~n&Ô›-Ê)p¢gé×a÷¥tfÜp{8įËbV•WHæávs¼GžÞ¨r:Ü^‹þRñޏ„W_2;¶yO»~¸¬élrU€§ïÅ3D{³9? þwõ½®J˜êxUßuø•~.[¹Ò$вæP†- Æ.ŽƒÓ7oÞß8•X{o]'"†(NSÄY• 1ðj\Zgö\Ä [9º‘@²‰Ëj5…/¿J:A%™ÜÁYÒÐe6×ÙhñåL§/%´ÈÇ6£ÑèáòjÐ(ˆž­UW‹ß(î@ûÂÜW~ÖÇŸMñH×RY~Å¿Á…”™±SÀ¯€Ù6¸7Ã+íŒÛƒˆ.„©*ª¿ažyËzJ›nõû’uŒ>¹*½ìÀ¦¬ÄŒ!©2½Cè ­j¹Ñl‘P/´é3Ë…ýFA i¬èÚsƒfLíõ£}É=­\f´ÛŽX)øà¨Ÿiǽþqô®ah_ˆ-ÍQ"øÈ²š~4}SU HéXˆECEæSP+0)Ö¡æ"â½F:AÓŽ§ª˜ fr…"ªñ¾Ýì[®‰Nû*+’¥wŒ57Ö¶úYÇZ9 yIÅÔE¨LMí6‘&ŠÁ»÷ iUȨÎDÀˆ.˜" ÈÝBvÕ‹«ìˆõ~{Ñ´ë.ö‚œ„‡ #íR ÁÌà ër•µWHr ˜Âö#ý~4àWÒý•B^7’"ýðáYMú³>/XObject<<>>>>>>endobj 5418 0 obj<>stream x¥WaOGýίFÁgcZ©¡%͇T©â(_ÒõÝÞp·ëìíáXUÿ{ßìÞž9ÜJÜìÌ›73o–oç4Ä×9§ü–ofÃdˆ?¶?ì= n't>¤YÛé2ÿiOXI++–K™‘¨(-DUÉꌄΨ2”ë ͪ¢J¦NMs«d^¬)5ÒVä’$i§DK˜Udr¼À!ï[éûätöõ`p{E磤?šHoÓŠ 竇&rçµ*\_éÈijÊ’1K•ðÙÓ8{qD·µö]þr+¾-ÌžGCÚ!-WJ ­5N踆Îbõ/“1ÅœFÉxŒß²ØÚÑ8æÌãÛCQ.RwçŸôÝé]ªûÞÕ8™N_³yjÑ2A;ˆ¶«‹¼Ãs×qÕŽVÆ>TŒ,u‚B¡p\3îüRÅ“Õ{³»¾¾&U.!/Ï&ȯ—–Óìš@ÜœžˆÑ¤Ã Ž…¨Qg‘¯6cjJø(¬ó}²s3¸yõŠîCÅ[s_ñ¼.zU/9 ö|í*¡ßÌŠeÀ+Õ<°Å𻽔éBhU•ÄZjJ¹b&3•çÒB<™XíY,ÕýÂÅ´¼~Èï,ª”Õãça%Ö¡ŠAµÕ½.Ù¯M3j¾(ëe˜¡Ü˜b†ÒËÞ ú‰Æ‰'x³A¶:ëPÒ\bä|wùÅÊÀö 3ÿʘ!GN(ÍQyQ<ŠIÀk+¸:Ó’Ƚ`æãçþE(^€ÿáŸP’¹T2¬ŠW™‡ð¯Àf‹ îp¥2u6{c'#䢅¨š=ƒÀŽ•¨7—Q¹f¯"Æ·Z9¹Ý 7´òX Ð{À>ã=RÊÒXL I…ßͨìj¡ÒÅ–FڹhÖ»žWõMÓ¤fÉ;2N„å±F·w§ ½‘©`5nû‚´iö-ù®4òåò¦3;ôè §Ð¦¶±Û´§×jÅp0ó¨2I"Mqåàó7;Óy. ÍóW(v¬Ÿ( P°½àS ¯½“0b MdŽ œàÖ_D½›uÒŠ·‰m…ñÍè;4@‡7^dÎY5¯Yšã})€ì®‰°Ó!$À0PEi¡Ïûf08[ë°ýW ±-h1/©Í•* oç]’Ä’ù=VºPã¿:f|E°šÒûõ—Xb¿£Zånl2SC)ã+…[wMŽÿîxm‚¿(¿›Á<€V?è4¶üï…tDüJ2µk„ U»-ØA½»É¸Ó’'¼tÌwöÑG Sücƽé£5ôBC‡Éåd2ê„d„Gô ³¡„¤ðíÒ,¹¹qÉcËÁíesß>¿œ$ã š^^áÓ_Sxú£dH¿˜´æÔêÖýס[xûÒÏ£Úr¿ÏE¥R +6þ›Àá.†Ód<Âÿ*¸¹\Œ=!¿Îþ8øÊ´ôêendstream endobj 5419 0 obj<>/XObject<<>>>>/Annots 2797 0 R>>endobj 5420 0 obj<>stream xÅWÛnÛF}×W Ô–‰ºÑ²¦.×v qj«í‹º"—Ò&$—å.­Aþ½g–]|)’—Ú†R;³3gΜýÓÒ¿COø/HZo€7üoÈÿn.[¾?ôÆäOðL ùG‡ÞQõÓmkó9¡ÃáÄ;ÜøŽÈ÷Oœåxâ «6ŸŒ<ŸÆoÂ^‡Ç8ãœÓõ#>ó'8Ó|övº£ 4ŸSÿb@LjrÑh@““¡7™Ñ4t™ htNOOI~IK/¸¹ÊÔ(»¢Ÿ}ýbè Ó­þ…OCxˆ¨ϽѸòܹŠh¥ JÄ'I"%™ç:'•|+1‹ñÒ5O™Ú®;¹TqL¹ ¤ºß°H¤1b.=º€yà«òâÍ”z£‘7#Áð¹LÚ¿É8Öm6G¬vØ™æ"3|¢»N¢u!¤–pbaìÝ»¯1 ºP¿ýÚØP¥§í.Å*•4ìrv¿lû^eòœEgëÄ÷khï:¡.Š»ƒý-;.F™ãÓàŠµCe(”A,rÕÊueé:5vÛ[±Z‚Ù2YVZ $.žNãUãÙ£7ÖÊ$³†¬¦D‡*ZÁÒà@\Hª*fŠÎÒ¦Ê^•ËÈwøÂ9 s %òµs³¾°$@šF’]ÈÝöT’–i³“… ”± Ì70dïKaÉùÙÊ<¥`!rz‘ »øië㽯ÛM(ÛÇþËK¿3z²i¦ß•:+V†K £hP‘ZW%–Ÿ³XÊ¢¬¡2 aˆZPKǗ¨tþîÇÁöèV®Ë³£„P™Î(dÙ_C¥ºS¡n}ãÞ6BZ‹T‡ —R§!À¨ÈA„̶BÅf›T•¸|,ЯKnez:¥!“É@E*hHLMÁºdŠ,¢ê‹ÛR‘ü졇Ló¼:˧ˆIî§ß§›¦W!"hEä¿î‘»øI’Uà-u‡Ð.ô&¬E@iÐ :‘ ):¤])ìêÔ“çI-/¨êöuH"ä…Ûy&¹­Ò98Wú{¤·{óXÏDìH±Ž¹C:sÕy^ì$³Tsêe+»@)k_”¬V=/<µàΤºÕ ÂD7°"¢‰ TàÝr!SP'Ó¹ct‘SŽtû×Õ%KaKãQ…e-[»àD¹Nèu„yqZù¢Û±tÚèÞüêh}[—ÏðÀqmÃcÔIí\Úº P{³ dÌ€Ö}E—¾Ÿ«Í>d:\Ï['÷¨’›Èk”%ir‰ð]<«ô)Ö"”aÃYìTS–Ë{Lu„¦L©ì‰š/@ "ÅÐæ-÷ˆìðÞ±ƒK›ƒRY®î…u|åXÊ*ÐlEsu_© ªZ–ÅÃj©ì‚Ĥ?L£9„ñ˜@çWØPKC©F°,eæÐcªˆ‹ö0ƒRM°ãÑXÅê°ê_œW6ÂfÙMXǾ7ƶwÆ£rf\‘dZ$;]Á>Âä¬öò¥Ã´²`þ²yÌ 5àCÙzöªjø$„4å¬;Ìý\ONÒMsPº*kÑøíº‰¼C«BaåÙ)UwwŠpüÎhWá†ÛÊŽ÷=·°…ÛïõU¨ôáŠÆÞО°W¾Þ-õÇžßÜ^]¿§6–øz=Ä: ˜9 z BçØBé ½ywÞ¥wo.Ïoºt;½þcÚ…ïw·ïÏoèk½”–M(‹¥‹ëk¬Òþ¨>SÞ¿>ã’ÞØAp¸Ý/LÞ56ÑöókƒÛ™-Ýr šdp-Àøºj)'¦~ÃI!!÷J¶g0± ŠÜ)  ÊÊÅ- ³]¹.V¯ ds¡—½^OE5¨^¹Él¬ÂZÍË?ƒèÚÀ5ðy„µÛµ¦. j±Ñd±œ×ô<“ ·ç&>¡ð-a3„@‡0×é>ëŠ;YëP¹v¾×V¾Úóß¼#»~ÞX›fCYK4³„º úܤ{L=ÊöD &ÈÕ Ö*Ý“sfAUº0õ~„V]HÌé  õ_·&s¢Ù¡” |ݼ(Ñ,¥Ù<¿Í¹Z½FO.lîjYÉÚqµŒ¾w8>¤ÉÑq©Uì©7Â7Ø_uæAˆ˜zœ'Fqy¶wTv„SÂ1]º`4Ÿ=L¼ñ¢‰¶„{~u>mýÞúmÕ¦žendstream endobj 5421 0 obj<>/XObject<<>>>>>>endobj 5422 0 obj<>stream xWýOÛHý¿b„t"\7è} õh¹"UmO¥ªNŠTmìu²°öº»vBþû{³»v½Ò „‚³ofÞ{3þz0¦~Æ4ñoVüus0JGxØÿ±Kz~uBãÝX;{¹ÿ²Á¥©\#ªÆ‘°’*Óв¤Ì©1de)TEY\FøüaÛ¬L5›vˆR’)ˆ?÷‹2Ó꜒D–©\VÐz‹£„sjYuÒâ†ã›Ûƒ ÇÀ8çá,Kfq+³&¥OUalÓV¢‘z›ð=À© ÎÛÒFl +èãçë¿ðRVÒb1ÐäËECµ•k€pøO¹”þ5-m”ÖtÛº†Vbeh÷dHGÑê”>¿zAŒó7œÌèô$¦§ôÁ(dʺ°j—åáä$=áu—Ï/Ÿ=£:.ó9Æ©H†këq!‹­ÇžÒUk9ºÒX™„pVÂÇY[³Ð²¤±wªZ|³B!2SÖZ"Òf[#%œ§R4ÊTtŸÓ71a‚άS¼€¼™ü- Ñy:å 'å$Nñ_>ø¥4y‹åò^ð¶˜$¬ÁwW×o_Ó¯…©e5øêS¶”–ÌŒ$p">ÅIr~ü{<‚™€‚ŠºmÜþ …³ÿwy¦“óx{\±ãøÐ㟦³Ù_ðy%+ÚXQ×2OhÛ՞ɉ¤rå[Ç<‘T´UÆésLrf7­:Ìš2òuÛb6žNÝÅÅ!×(s·~/tþº ?»ïÒ˜ÇÃÛ¶º;L7‡óãoÖÇ{Ó˜²Ã7RkCŸÕù|^&T<µ)&.®ùnÊ®YÎX)î¤ó)k+ÖZ C1PqkYĬ­‡zÌ¥¬±i©2dpmôZæ¬ß\Zle9É™YC/ÉN(@I¼÷¡.ìà LWvÈØAƸ²0µøÚJZ ÝcëX¢"éj™)T­ö&Åôkà_½Ÿü¸`µõ”ì x’þñq£–ôÞ;’7;ÜQ`è! £ûÅY>+NÎF¼ñ»™½á´F7Ø)j±°þF5’ËZÓVÞsUÀ'6]> ¨O½¼G¬¨›t&l G…,ö ´ÄQP”Ì>ÄAJ7(Œ©ô¶ Úç@NY0€xÔPnØvQLéeA4]0ÅC…¼/øÖ:èß#UŽ(ÛlÅÀW%)Xgžh«ãýo×Fã:bÂxYb¯wùù` ÷LBôKæÇµa¿{È–Hª5w2× À˾½€ë¢ïœ>ô­ZdwbÉá‰f/#®á®aå×VŠ!´þ"ï¼ Câó|k)PRô)ôW Móár ¦åp  3‘j¸ d竤Ëj¬&J,"ðŸ%0œ›Á—l4;Gç_ê/ÌÞ}"<2Ηڙ„TÈOÇæ§GhŦGéEÈ<ôí[Þ£¯T; jµ°ÂÂ<"•<‘~&âj/ùÜ®–ÒþlüXþmüãéé9ÚÚéäÉÀߘ ªbý¬ÁFúA5O a˜=0T 3è HQ*Ó>:ð|Ñ*°H®>ª¤— wâ NöèZv þ;ƒ®.ÿÀ1fÄÑ船õîÓÛ·}Þ!ÇžJ;s•Bx½êß™Ê÷í- žŸ0- T´ñ>Î–æØæøÔ<ÁÙSS‚ =#1C)ÓúI§-¢nûàÁa­\¡NîEìGŒ/´­ÂGd소ÓnðK!xÇÆâ1 n€9A?ÊbâäY CWå™ði|q¤A[æTïÏ*^ÈÊñ]´/Ñ;ÙìЧ˜ô¥Z®@ ¹2fäÃ*¶ IÇ ¢Ö’5ýÀPH|z…ìåèq%&1æì¨F÷=½Tè Î «p§Çñ @üYøö—Ã&0„rwc<:´zËçÿa¸FŠœ WñÌàÅ4í1Ä—€ÎZ€ß/÷…\ÃÐR0?ú0 .>“w3>~h,Àx(á&Þð KóAÐÝB-‡¼¾ºÆp¯UÓhŸÌSú¨J¥âIö ùŒRƒëAŸRT­g {ðƒ’xß­ä&LØ–ý,¢Eƨ.ßÃÐV8F$¨Ä; ¿JñÀDwÒÓ ôkø'1Hô<6æÉè$=žÒì|Þ¸Ï 'éˆ^™¬-Árï=¼ Âk‡ga‚ö¯"'t¹{‘ƒVdÕ–þŽÓÑ,Nðâ‚Qøt:ã^ßüsð{í„endstream endobj 5423 0 obj<>/XObject<<>>>>>>endobj 5424 0 obj<>stream xVÛnã6}ÏWÌKP%±ÛòmÛm€nvS䥨"Fûb  %*fV]’²£-úï=C]l9AZØ$q8œË9gô×Ùø )šò?Þœ}Zœ Â^¶óD×wch‘Âvú7‰_ÇMl…q*.2a²’‘?I£ KûµÌ)Ö©ü‰n¯®H¯žeìlH÷)•º \Ê„œö6$h«Uî¤!m(^³RÎÒNd…ìQ¬s«¬îò­ÞHZËl+ÍÅâùl@ýáQi‘ÇNÁšTnIHwð(_Äf›ÉÙöún@ó0âdFØ7…Q„§$8Wy¦rIç7.9Ñàú’nûÖ•™¬B½¼î,†.ï´^hÜ-ÜÑeº¼ ®"2Ò&§eàwÀ"ý©ãèŸú AÕ§^]½s®?®wµÓÕ;ç&e.6*~ä–|Ä–Ë›eû÷bðGÜç±ñ'ø§´‡Â:RoÔd˜^©·½2‚PfŸèQ}ß…(œNg¼üKf5Ii¯Í7ÆÎ^¹5¨çQc׺ÈÙ^”–œ)B…•äÖÚ{¨º¸õŸƒ÷†b¥wh§N€-ÞxÜà¦)OQ6i Zé'ÛH[dŽñm¤°„¿÷ÐmÖ^eY³‘2è*¿é\V¯Nœ.;ÌwÒXàPËp´’„§ÚldV›>#‰ØM¹`Ñ8DñèÁ™"¤í:g»q8fËšx{#¶ Ü-Ùf ꂞ‚³XÙ‚•«ë_K·æ@2aQÅÅë[£w !’&ÄYR.p ÈˆRIJ[í&ñ7ÙVN@@ÐWlaˆ]¬@»—^Ùû~)ÿx¢¨b&K©Î2½·ïSÿææ†vôs£aÕ2X^p¬.ºÞ,|aNÞX)±2 G¯V¶†I³ _z¸”|ùÞ±™…sêà ‹jgä'‰ŽÚDÔFAyIı´½¶G 7Tä^ E¥¾ámäf‘N=W|¥õèòX9BJ·.œßíµ˜·Uµ€Þu#šIVKoÅ^O +%±~»5Ó;Sߘ¼êt¨.c§Bo±à‹<–$=ç2ŽóÇícÕË›n'¢ãÑ] (®¡‘D†qÖ² uîÖp¿®Vó­!ŒÀÈCS ¢Äòú™ÜÉì˜m5™Z—‰–doÒòºÓFh9˜ˆRõû`ésaYivÌB&"8ùR²KHE=BëÃoë‘ËZÂJ’úëæTåh{rº% PHgÔªp]Zÿ7“¸7>[þ¼nK“tC¯n']º+ Šj(‘N¨ ɯhÖZåkQ) Ãz ™bÊœƒ’dBU i“{ zþÈð]8°-8f‹8¦÷ùOú:ÏPýÏÇÄâr L±ªæ&®>sЀvĉ¡Ï9éùÚl ' zÝJ”(©T;Ù0µúà9šnï7¦Ö[žâ¯Ä6 [§¾ÞC µÒÎëù5œC¨¢ MçópV}8=üyÿk賎‹ÌàO0N ¬¬û³JAý°šÐ× ©q“Á4ŒF˜g˜P“hÆÛ¾,Î~?ûBë‘endstream endobj 5425 0 obj<>/XObject<<>>>>>>endobj 5426 0 obj<>stream x•Wkoã6üî_±À¡…“³?ŸÛCó!iSÐמCÑ%Q¶.©ŠT£èï,)É‘òjçaqIÎggé¿F3šâ{F‹%¿âbt±MÃ)v¿ª \Mi.hÒ|JËofárùŽÖ‰‹šÒ:Q¦,Ý¿Ç?îëä˜~“" ´Ê÷TÈ"’•¡ã“£õ—Ñ”‚&%<)ÞŠŠŽ•(äûáÐWEmE”?ðû›zruJ¼lJ0óEƒqüy+ñÎÂGŒý¶þa;mÜÁÔ) 2¶ªc[W’~v•(K™LÈn%ÅZY©¬q#˜º YM‘¤d\²XäÈ¿t,,Æj“©ÍCáÆ‡t5ŒSr×bþæÌßõ8‘¥T /®í¶è*ÂJ[úôùÔªj evë ñÛ·¤K›iu}’ã†S:dëÏŠ'i}¾:O9ï²ë2“L±$<ÌàxÉa}~ì'+*Ë~Ó9J"¬h8ð&¸G£™ƒ Æð…Eqú]eÍ–=¾¹ú6Ü2vº†û@!œä'–õe»·@­49v¶†jt ¥²€ ŒŒo8‚,uà ƒMD"iÎWP!ö´ Dˆ‘¦I°)unÙ_#}Á‡0Ò·!窢UË › éÌ™÷¬j‚glC[hÎòg„O kB¦.Kö.öJo“;È·mVÆ ¼—ÁëÐXÕ•Ö­ŠkI§‡¦{=âLSs“Xn®g 7Œá!9;F§ (LCf=³'zC?{Ì=aw߸L‹ÇU$oÕr°¿}úä¾ÝÎm_p’èöõêY5êÙê4<[œÑrÕÝøúÌÃ)}¯c\ åi( ¼óŸ§!nëô©=.ÃQgÓe¸˜ãà îRg‹?úa=úuô/pC²Lendstream endobj 5427 0 obj<>/XObject<<>>>>>>endobj 5428 0 obj<>stream xVÛnã6}÷W ¶«tƶlÇIÑmº.؇-b / Z¢,v)QKRvÝ¢ýö΢ã[.I@äp8sfÎá|ë a€¿CH§ô—U½Ÿ½àâîŸYÁÕü†#Xh;Í`‘ûý,²$³”]Ãý‡)n­°‹?{Wó1 qŸN\ŽÆlŒg’=àFÀÆð¦9,·ðeëJ]GÀ-l„R æÚ€ø‹W}lu %_ p¥´Á¼îÀŒ¥táˆn±4ů<ñ1ÁgiüC†¸IqåIÓ.•ÌnÖÀ>&?­ÿGÎmÈÚXÁMV>&YÉ |/¨N=¬µÌAÖVô󪡕^‹— ƒ“•@E}z§N‰zåÊÄþõŸOEºô ¥l:½&låŒ×ÐZÒaÔ±>J~ Ð{Ü®æÏ€~ww ~Œ•c¼P½‹ˆ¼ûI‰w/Y<8ݺWl>ó•0çm>/XObject<<>>>>>>endobj 5430 0 obj<>stream x•VÛnÛF}÷W   ‰ÖͲœ¢b7.üT·Ú‡ª+r)nLrÕÝ¥¡è¿÷Ì.I]¢:hØ‘vgv.眙¿Î†4Àß!§ü/)Ïnçgƒx€/»fE÷šÅcšg4Ðt6Œ§Ó+š§þÖ€æI”ÂZº†>к^*¡{­éïóùç³õ‡¸”Fq|þç{þxq?!>ϨçýѸq¹\[IÞ³´$Œ¤ëµLIUN“ \I#L’oIgô¸Åýª»îráÈȬ‰#—K²¢”0Ì¥QNT ¾p¦N\mdL‹‚]ðµÚÖ¢hœµÁŽ8øÚ©B¹-eu•8¥+Kmž©Ò¦E±ýRÙ¯S4ŠÇcT-nnnhI?pÑâ¼uì«Âgª²>¨E´ì¡nG7†_ß·¶^úÊ,"øüß6x£Ç±F29üG;îkƒ™RÙ#•ÑV×”‹¹W‘B=KTQÙW‹ñ¢UJv-ÊEÄù.[œ ²òÍikO­ÿ€›(8 Ùìà‘H¹vöøºõ0׈´¢ÖÐ’†^Õ6€‰R@æ¨ËŒ.O¸:rÔB|4áÆ?8RØËP pI*ë©uqˆÅr9=ýþð“·¾¸¿¦!@—šýÑ”ýŒ'ñ8¾¦ÇŸí1´¥‘À1þÿ"Šš‹*MŒØ6õoÉ^&qˆ§¢»÷ï{\Mð‰9Ur¢©Ê¼;GX£]¥KµÊ™H‰D ü 0PëºN’^~½l ®’_D‰¼^'B×ûaÓü/h>ù?ôÈ"²Ü¶màÊvâÑYނ廓–]YNÛŽQê:/NÞÃÞ«áä&áõÝã´çÁ7âô˗ݶ Ãî#7‹•§)ä!”Žäð¡jd©í€Ui Ó Už©²Nm¢Žˆý¾]ËDe*a‘j-¹ïº*¶ô¦yøMLópÚðàg[½6A/‹Œ9«)Ó‡˜ne"ä^LÌÓTW€%¼“Y\qÛ5¾rz%‹P@Ïð ð†B—V­4vš# Úœ Ä'e›Ãp–z_‘`ä ¸–&RaTÈô\L5Œ•}®¬Ít›5º€ê¾¥;#™‚Û:AgEÄ!m{6ô–~~Ž[Ÿ´¸OÚüÚÒý¤`}ÒêÎcý4¢95Ž€>iû‹J+fa~·&ÀòI“çE4$YÈRVîX‘ý¤JU`eXJÌ…^ë$©e0Aq0š«FÚ¦÷¿Õ)»ƒ¼ÇçáÆ²7‰½ösÞSn¨Ÿ;ÄðÙ;>»:}æë5ûúlORØúº»±›EG™¶•§ƒËÜŸ Ž4¹Œ#«±¾pó9³fì5ÀÛ½‚)æ9¦'(b?ŽÍ®N´ðÃr\†WXì½lõ¨’ÔÒ €¶Hó4/%æþ–gè ÚiÊuáé?#- ŸV8øbðË‹¨ÙÍšä )˜ÿ 5n7\v¿ëìc%ÌR¬)žè‚—:™.νj.¼™PÂ^Cz×Ho“«$ßKòHÝ¢ŠJQÐ,~lŽŽë¿DtžÜ§\Ÿ•ªVm¥Xô”;(7ÌšÞøLüºÙÔÛâE*whm4·m†ý¬éçh0‰/Ç—4Ͱfñìâý¨“šù$xñäg§p·¨é÷ƒÏvä= ;._½Lãñ›¶ˆË‰_ñ>ÍÏ~9û<铼endstream endobj 5431 0 obj<>/XObject<<>>>>>>endobj 5432 0 obj<>stream x½Vmâ6þίÝé®l²··UWêíuÛýÔV‹tª„TÇ!î&vÎv`QÕÿÞ;Bvû¥¼ ðxœ©¹ÓÆ3Jm]±[W•6ZnááóýOÜi≕U! 3Øêr¶à6zòQPT1 )©´ïri¯Cœ1\E :ÆÕñ8Jü•ö×ZbJZ/úR¹ÅÅwívÌép‘çÌÀ·¼1Øg=ôÞ’h6{O~Ǹ8SP[ -%H¿n1gEß`¾L®r—i³a&…’)%ÌùonnB€Éâö×Qw‚ÞÙ¿úY…~Õìjìw‰„ª´Ý;ÊãA–²`¦Øv«Í€ÌZ_gÌOÚÁÙÚã;­á¯N„U½,$÷YS§|©)1´\ô{°[ðp!xû5›(Š:‡üí[y²S„ êÔÆH'ÚqŠ}r/h |ß}ؘ[#:e´Ö‰‰Z³j÷dí| ·ºÚBÊy¢)¿4”jÕr¤¥|©) f!+Ä“\þ;"™ÁƒFÚÉRX‚$ÒÌS-ÿaÎsŒŠñƒTZV.åªÆ:´;_ Ï"[±ò4ª͑ÙϱH›P‡g)û‘H¹7N¦ñ‡khÛ‹ºd:%‘e…w-P"åJi#RO¿…|Ž|c6ÒXlÎR½ ÒzÐ/O“š£ÆÊ§@x_! I :rº‰P£P¬ ¾3*`«øÿKo‚“EŸâû£L·]•>fþ¿ÀHÜìððÀ¢$š\^œc?1+,Øþø³¬|¬oB«þ§øï.ÎLeu±FIøÚ`÷Ó¹Õ8ÊæìPpøƒå8ÞhÈ¡~¦q‚ãH·ÈnÛeã\›”| RXÛ?-2‰`²­Ä°2‚‹T(.ÀÔ…°Ì=¸q†B¶É%’²CÓ@LZ$œIUÕ(_S"A,™s¸SL×\½¦ñ,JÆxoÃ{Çt2"??Î{¿õþxðlendstream endobj 5433 0 obj<>/XObject<<>>>>>>endobj 5434 0 obj<>stream xVmoÛ6þî_q(ÐNžmŶ'm‘[º C?´Ã  ´DÇ\eR#©8FÑÿ¾ç¨¿ÄÍŠ A"‰÷Æçîž»;#âgDÉ”Óuç×Ygñ±ýcïèìvB£!Í–¾ÆCÎñFs)œ$+—Ò’7äW’^üõéßIèŒnz½”®Dáqº4–ÖÆJRká•Ñ$¦ôdî¥ÍÈ”¾‹»³:g·¯i4®<ÆSxŒ’IœÄ£›$SH+¼±®’ÝE7Oâ KßHë…Ò•tm\f;EJ…¦…¤¢Ìq Jo8¢Täù–[â+Ät‹åƒX¹ìSj´S."(Í…s”«/VîMÇ.㄃i0ÇI‚·,ª„o [y ¯,‹s4‹ «î…—Á@û‘(3å"ª…°¾OŠÿ½=ÔùJÕjó¨Ñ§+ökŠßæ]zSÙGvÞ­Ï#…ƒ¯ôíÀ Qkïî›Wz•î›Iãçž±4!?e’^5I¼šG­7·’@© ¤M`ï¤VHÑR'tO9ü1ÕÁóU~¾*¼ÊÒ1.M¢åNi´Ò—VWi~û(©µŽZŸÒ©jíHç[p»£A(ð$žN/8=ŸVRÓÆŠ¢ ÊÓÆØ/u{lM‰*dêŸn’ëëkJQ mÅ%ýɼ{PŽ,’í‹\ô/OˆHˆ¤Ô£ì‘²ŒmÀéà`ª;øÀnd\¡sp0Ÿ„§«®Ð?è ½qÒÕäI ùÍœë¼Ui Ñò«¶9öé”\YÆzRT%| 6~ÑÆƒ|A2 íeɬWqak¥–Vꟃ1ã8Lˆ–,—VIž45½6¬ÒkH°âíCîjº¨âàc‹ÿSí¸ª®Q¼ÓgŽ+ž‡r®Ä› °š'ý«ó q^åyè0›û´Àìc|Ö‚á¿É:…+sŒ¶Œ!&È¡”È _–:äþñ§›ì%r)Ö(Ì­Ï"Ë>gLæMH߇mÞ}šf+‰ÑŽjÁõ·¨ƒKÕã±µNL´-¢€G5 KÌÂ{SÕν”)®¾6³>¢LY°Šº—1½—²@;ìöž¿aø%w0#0$…‡5: ­wƒæÎ’K|- Ô°½€ð?nýÊè ]…é'tŠ% ÙTB+8u§×R£š…dÏ”7éªÌ‘“k¡±g NP2® D;¨¤¬Þ}.ëmk<œÄçÉ9M±û„ÛðR2 Ñ;“–ì8ìPìŒ\É.ª¢þîºt>œÆÉ›ºö|2fåßf?;ÿm#endstream endobj 5435 0 obj<>/XObject<<>>>>>>endobj 5436 0 obj<>stream x•VQoÛ6~÷¯8tH§ k[Ž“e[º-[ß6ÌØ^ ´DÙZ$Q#);nÑýö}GJve;†%Þï>~÷þŒi„¿1Å3þ%åàÝ|0#¼Üÿ3+zûð '4Ï`;»½¥yê÷G4O¢x*bÍÞ¼¡J–ÊÖ2Qörþ×àíÔưa¯«ÉTLáýþçûŸ)·$·Ò(ÒÙ‘ß–;Ä +J5UÚ‘¬k% å¹µ¢R§M¡°aüþþh2Ê6…c3Ù¹µtœá:Ò,~T55,&Û,CDKˆˆ"åJYAxRO²¬ 5¤<£nh-7 Á³çù£B>¹†šGt+b.zÂUODã).ÚtÛPm2°ÁÞ6Ê´¦O]¢~ˆÓ£L&nñªZ\~{laiG¨Ä!Û“ˆˆš%²}î†Oü?÷ß„ÇÃõ]ùRb1›Ýxìmµy´Œð¯;·ÖÚ"õ¢Ð[{÷" ÷÷÷”—µ6®Ã´W o·‰Pq¼¸ìYÌzOl¿¡ï÷>€EtääÍÄ c1= P†u#v½ð¿÷Œüü,(ï=3@£WF– ˆù@qP¯"]¨C‡~I‰®²"Oœ%\lF²Ú-.)ñR1…u±Q)56¯VNFŸúnŠ.Œâ`ý|¢/™úò-´þ‹è4Я%ÆòîŽ×Ž©ùpŽšž›>0ï<9Ë4úÜÂwa(_Á qþöÐÏÀ dSîZC[‰SÐêJÕ,!¹!»+—º°dU-thq\‹ÍSk½aôaY2Ã;b k« jÒ Ç‘X”Ò+ÃA©pgŒ,/×{Vø4£øì²@cu’”± Éd}°ï%Ð¥Vì3±qy‘T|œn,À€ÀedKY”‰bG•²dÛçbÃYÛÜ­ XT.OdÑb¬†´UE1äª^&,+…€âz­L•Uf£[}9G®&3¦I±NAeQÿóÓƒ‡ÌÞ šV}íÐq8+iݬ7 „®„Q‚~Ñ[µQêF4|µà@‹´¿deìð ëØt¨Í;,{Ev^þ‰aa€PS€Ù]r8Ë:Ð-—×(h®yHù1áOjl B@åÐÙxßÍψÒÜ@Üsàø?ÚüìÈ Ýyñ©+È7ëWy•MªèU-s#Ö¯z»ý^îrü.)¤µ4£iÂjâ5’‡¬ÚŽ%yÚònW«TepÇ5Ö}à} ÁØÚ[MÐ~hÍô¼YäÄÞùìpV<)žÙ`pHîuP,'¯Oÿ9¥ ·­bo§â:¾¦Ù͇ïÖ«‰Ñ:iJð×…aÇ´ ÖW7Æç¿°®G3Oðy…FºžÆìýÓ|ðÛà_£é²endstream endobj 5437 0 obj<>/XObject<<>>>>/Annots 2799 0 R>>endobj 5438 0 obj<>stream x…VÛnã6}÷W , ìZŒmÉ—dSí¶ òÐ6ÝèK€€–éX»©%©8F±ÿÞR²%å–‹Šs=sfF?zCà÷¢ ý$yoÀø„>†ôñõªGc6‚ñÏC<°YuÊà¶×<ãítʦÍÛÆoÏf{K¤ûÛ¢áÎùÔpz9€‹`±†Ñ&gC6™La±rA `‘¬È‹Œ[q<ÕizwôÏE*mçŸOßz§—1 Q~ !Ú GQe'¸–p³³%ϽXÓ]8±(Bç«`>ŸCšJ[O GKdÔ_ðK}ǪH‚¨ß<—dëTÛzµNä®`F$J®Z1^MæïåcªJ“íú`7B H ä ÿZ5L°Õ¼(Rù€"\‚Ù¨­„Tâ …«ÜüIZ+ayšHPn)`­J¹ò¢\Tmv`¹‚Û¯¯€£Ø—OŸÚ"uE ³a–lxa…fp«ráÃL"›&XÌUŠmše€! ®ê¬™Çà ÈÎ Ž&d0ŠYĆ1¹†Ûœc©n@hÓb“ V?³”N«ÐêAóÜô!µ„Æ“+„FAi$7FÂ͆? EH'¼ÜQa³ GÆPT°#¸Rh¼tµI]H{(Rù¨²GgZ8Wj üP1çØ»Ef"ÒWjOë@hÞ*ÎïϹMÈÒïÈ,ñÛ4¯Irá].æ>içÕðŸ+jM{`Ì•ƒRq€ð±ŒëÀ¦DWég»@]l„ÄŠ¬a§J;¯ÂÚgÕ÷^i^ŸÌ¥Rð‹r‰lsˆ4£丅§gQûçK® àöíOw<ÞÉàWhѶªÌ0®Ö®£ˆ²Ü`‡e™Ú¾S#Gm¬Å&„S§Î-°/ðèà œžVÏVHÉ\`‹Ã] •õÝÞ™HÝbáü FŸÑЋ_h}Ÿ?µ¸@˜íPÕkˆºÚµ"Þ¿]påšÊ$lM? û`ˆý;ì ~Ð,UiQÌ£F3ÔµÝmh>‘bfâQdÝ^ÂôºšjùM$#ÇF2%NGbc*åÒ¦¿W¨ÛqßÚ¯ERÁm¥Ã.ëzGòK‘c¸Þ1D_×ãñívþ«U™‰Z˜¬î‰Þ-{cÖ1£Nö½ïøÖ¦}eãUÞÿ¥¶Ø¸‡"Ö—-eŽ{‡zà[i,m•þ~ôv*n#66l‹ó¢WÄÇñih‡Õ®û ß²Žì ÝÿŽ_"»×¬xÞÕ8œ+Ý÷ø~íG¡ƒeÆí ‡'TnGSܺBg;B­ÎF [jé—N‡CíÑûŒHÖˆl½o%Zk/´Ïý=zëûû—VI.ðuiåXX£éöyõîð~×4%Xˇƒì¾º´ 42FÂGŸÅ¬ZuÃYÌÆÑ&ñŒMýëMƒp„¯¤¿«¤¤õÈmª$©á$öÒáÔ/(ÿ–¹}_¯;·Çƒ ‹Fø:ïãØ½hý±èýÓû›< ²endstream endobj 5439 0 obj<>/XObject<<>>>>/Annots 2804 0 R>>endobj 5440 0 obj<>stream x•WÛnÛF}×W üD7ÒF”DYn‘MS§~)ÒFE^+r%2&¹,/’Õ¢ÿÞ3»¼:²“Æ¡ÕÎåÌíÌú¯‘KSü¸4_ò?MÅßð/—ýñ~䮄KËåL,)˜Ö‡˜>ŽzÇ„n±Óþ·ð3¸õ„G À½…ªç‰Y}`ÍÞ1¡ÕrpçN=DØ(ºs¾í‰5ûgàõfCÝÞ·7K ïtß®{Y5©Íôúî–Ü­÷Hÿrµ¢u`²>¥µïÌb.\~~õŠrµW¹J}E¾®ÒR¤wŸ•_×ëÏ£×w dÖ™Ìb3Î:TÄ—O* ŸÎW v: N‡ x‹t ÿi)£´ ç2ÄY=Ê$‹UAzO‰Jt~¦D¦ò •–TQzhÑógƒ„EŽð `NÀd¶²Øù‚ UN‚¿öS¹qëDz((B*ò½ôÕ¥4˜t:÷V-ËÕ1ÒUÑÄ1&Iat'±:ª˜Ž‘:quP§\f£=É‚ Z ú‰Ô!$™N9!a9§¯3u›bЭ¤“¨4i3QÔ 4ÀÑ‹l—Gjo|5µõÉT|:éü¡î¯ßõœÞßPÄ(µ±dÁý:S±ø~ØòªÐ›€Ø–|è%亣µtŽfÆÔEèñÈ—<u…y¦Œ¤Ò÷UVÊ]¬âOmZ¬o(Žv¹ÌÏ\YE)ðZdàY3ÀÎdWEq¥OëÌLÏtVW`øTmU4ˆ…BS°š’è½U6Âi³-iZõ/ÏwXa@¤²žs)èS¨xšÐ’ œ‚³Œû½æÖã©i¸bã\}è÷óÕæš 7©FGfY|6•l±¼ŽzOýÿËÀ7Š™eÆø–³Ì®9l¶Þ }ÁyUÕL=™-¹Ý˜¦°!ëÆœVóñý‹x®Ì¼îdùÅÕsp¸’û6«Ï ÷g ø¡Ì@˜Å¸#Õ=uÃÛ’–é˰-³qNÁA~í˜ ×Ú iº¨¨’DæÑß Iט«ÎS´§³®(”GΰFãè£z{Mi…-‹8ã|ÍÄ|ŽSàXÙ;­éŸÆf$p²j‡Y4#Íc¾#þ"¤Ç²í÷E&“‰Íõ !ê7‹tb ÌÅryÃ.ÑI5­”¹L ¦,Ÿ’=jDU(³ ºLbÁ©†¤í|åàò;°C½-k>z&pù;pÃ6ff?Ç”+ujfµFõï G(^¬Jemû‹–­í_²Ç‰†‰íãö Êó‚µç~òã“Â\h-"—ű©èQÆ•º•­Ò2ß×ö€EkmËüà^4Ýá¶JVð‚“îíõ¤eÀ¦úäË”×ů7¦cÃM]¿¨ÇR¥f]%:¨°I6Ž1~Ê{Ûº¸ºg´Hã3óöûÓ¼ºÐ´=c»*åµn½÷OÍó½Õ2.4=¤ú”ò^@›‡2ÀN6s‰¬µS ÑË:åý×ôyîÔVñJÞ\¿ÜòدüJéÇÇ\`f»åc½µ±áðx=l·Q•Û-ð¨í}#xxøR˜5ö¦õ(zóÖÄÐ1Ë@‹#}Cî—Rè«@Š-˜{'{¥a€[íÍõe¶mYll{÷u£7‰<„®ÉRm€ý¼¾[ÕwµÞÜã?ZÄÂ5|Í+l‚ç½Ó~ůó\b5ÒJOn,]óŸ6Þt)æ3ümöûe=ú}ô›gGendstream endobj 5441 0 obj<>/XObject<<>>>>/Annots 2807 0 R>>endobj 5442 0 obj<>stream x­X[oÛ6~ϯ8ouP›±åØI[¬ÃzÉ6`ÀºÅ[_ ´DYl%Q“¨8Þ¯ßwHJ¶Õ,ë°µE/Ïý;ßég3šâçŒæKþgS1Å ÿ6ãß~ýžO(Z\‹%4{1/¿rº={³:pRõ–.n¦t-æ´J)šÒ"Ëå­÷ì”VñˆøÇ}CUm*UÛýzt§dQåJÜs÷p·UvLƒ³FÙõùùêÓÙÅÍ%ÍðPJ(˜Dó `´ÊtCq.›† U«|O™É“†$UF—VÕd ÙLQ[&ªÎ÷ºÜÒÛçÏÉl>©ØÒzä_‡ïîõ‘°xðTãh}N²L(ÑM%mœ)Ve3ÃZp\¨b5÷²Ör“+’q¬`5ü lEÄÈfÒvJÛ†­`£r³›äê^åAÊÔ”¶elµ)A7µ)àHÛ¨úYãý!“Ò½V»1iK…ü [ø€©?SiêBæùþeçØ!/“(ó9²”Œ^¿~M)²q”‚5üìLF,ÂÁ9›q¾Çi*b=ZücŠ¥Áv18˜›É†6J•´«eU©„6{x[+™Ó‡=â[·LšªIFÕH]’LîeiåVq„0]6V–±ÓÞ´KܰVÆ•jêÌw™èrꇎÙ‰#%^ÍT§œü¹5†%9s¥±Ô´Uejë­ænZÛ L´û ‰iK«{W"­Ï…ÏÉ âšHÑ…“hÉ‘ž_ŠKÑ›N~ÅòþnWö|·øö ÷ûª8Õº<•‘©¸”¸çîu“$5z[êT#L–Ї)W ‚GºàKªP8g £KKl%he| q°÷=ÑœiVÛWúFÙgï=ì} Y3„Nã3¦\YÔµEðܘÏÈí¸Qd¯<ô)m(׸ê™6Æfë:n ŸþÆ×…‰ƒô1ûÒ„ÂJƤ¸<:÷‚8]ùª  ˆº²âŽ˜´ß]ÅúŽÃY«B3°Œ å‚(6Þ~„ï4C}tîît©íÝÝ0S¾*]‚Ÿ\êÇA|º¡}I×#ïÐúÜ °b×Í€•Rg*Zåé£×ø.t`ˆNïQ-uçt  Â=~"ev%g§n°ÛåHkïŸJ¹`¬@ íÆ÷€t ð§Á>L–½‡)2 ïp'x$ yÂŽW®xzQ«,Ú ?ѧ‡hºGjÉ—ÙI7·ò`2°áv§·ö?»Yå?ux0zåZª±¦3àëE{sñÆg<ôžQªUž ÞO¼`$…ˆ„&èö€‰©M. Å·tk|^‚ÀÀ¤G"Ú5òjŠÊ ;¹ßlV+h•µm\ƒ§ý:ìûêÇ»¬ŒÑ”Ì  €xvÝ‘Š+Á´¸±Ž@\NCÍ߇ä0Ÿ[·uO$î¶æ_–®7÷ëŸD× ~!ò®YÎþÝØA›z uÅs¹Üƒ*á3¤ÝÌÇpôþ=’áŽmëõgB—†ÌŸt›Ô·œÏs˜ÝÞ›ŸÌ O©¯¿ß÷Pà_«`q¢kpKPQGŽGiàž¸hÝëu鯱ÙrcZLèT¨«€*`‡cs– kÅîHn¸ŸŒELrÉOù1pÊñAÙ3ßR™µÕË‹ È4ÂË So/œªtçøèÈl‘;ƒûÇüœÆèþYÏiÐ:?éB{K£4Üs¿Á ×õÿ–×€´äÚњشˆ¿’Ô °#çd’IQ`pƒK¿û¯ Ebá¶­\rÓœº“Q‰/’C͉y‡ ‹éAü×€!GæNCZÇõS˜†‹¦g–¯›qÎß@¦°[ ¼Ç¸¯ëÏ®.ðϦÝLܳTyR[ÛáL2ì‡L?î‡_YÖÑß9â §w —`Ö„ÃÙ{B‘¿@ÛÇ¢5™ÏÅôŠ–O¢ð•cð·`â [#Z{”ùCJiÀžÊ-,9Š {Š1¢ã6—õ Õ+L¶nÛÂÎá¶Eì)ŽÅSn,ù– ë’_5 ¹?RÊÜG³cå=*}ÌôŸÁdämõ.Ûc³ÛvûÖ)ô#–%Ánx)ÚÆ2!)¼÷oý—ÔÞrÃÆÃÕÖÃÜ!4~ÓDc^›v›q½Ò³›pÇ%Ö#%¶b>/XObject<<>>>>>>endobj 5444 0 obj<>stream x¥VÛnã6}÷W ò²²×Qlù’´ElÒ] i·¾h‰¶¹µH-IÅŠôÛ;CJ²-7n€Í ±83ž9çP_{cá÷&súIóÞí¢7 Gø°ý£×pu?‚›p‹Ìæ0ÿnÎç×°È\Ôi`«‚g|Æê2µðwñ¥7‚Ë1.fà×çê·åžÚäãÝO^]…A&RûÙu¦×æÜzÎak~ò‚Ûß2ÃïžS^X¡¤ïÅ]ÝOÚ\Áe„G“úlÁmiÁìÄúrÍ%×Ìò vš×øsg»aØvëãüjé–à ì®lØÇ8ah¶¬R¥ýžŽx«Û: '9ûV4Ÿ”È`PX}Œ”а!W ¶:Ò‚ÚÉÓ…f†0üùì”N§ø¸uSá<ò‹ ×þî”þ‹iUÊÌÀJid÷øfy±åC+@@Ýh<Îþóøºx¨Z>t[”Ë­H]#fÄAª¤±n˜†AnÖIÜ?…ìŸã”}¼VÆa™*â>¸§M=\hñ„4ŠžÎÖºÚÿxÄ㟟~ö÷+­Êhš©æDÄ´ÁÒv«X†ãmFá®Gw b’Ú9Ž7‹•V9jðAe剒oñóž\tC;çÌ+´¬_Œƒ‹_(417›‹Žty!ŒÊ8¦øÔ÷p qx,˜fŸä×RAoÇãï¼,è2§‹É %¦ŒMuVBãmàà@ÎÇA‡lnÓ㺤Qo¼è§°C‹E –ñCMi<"r™ ë|>ªùÃÐo©VŠ }ñYý2ÓJ ³­kþçpu?¾i_›®Ã1DÓöí%ŽðåÐïÙÄŒ¯gá|2ƒitC2&Z]Fá>¨´Ì¹´H,%)±ž†3Œ¼¼ö¤LÃiῈ\ø8C³Ñ<œDøîŠåfÓkzt·èýÞûÿì(kendstream endobj 5445 0 obj<>/XObject<<>>>>/Annots 2809 0 R>>endobj 5446 0 obj<>stream x­WÛnÛF}÷WL¤¥k‰–(K¶ôÁnê4éÍŠzY‘+ir—æ.#+Aþ½gvIY”¤ê‹s/<3sæœñÝш†øÑxÊ?iq4Œ‡xÂ#þøëÕQry'4ã!4]ÄçÍ_9ÝíÿÕñy<Þ[½ží]èo­Vtz3¤ l›-i2¥éå(žNÏi–ù×i–FÅÖºŠ~¢7Û[W)½šG½?DU×›ÏÞ i0ÂÆ,’¥²&“ØÚ{)EF=:!˜wÞœo[Ò Á‰dܼ'š­%‰…y/)åÃK¡rÛ§…LEm%9¬.Ue™RVBg4 -œÂ‰rëÖFð¯dFZýƒ£wÚlh_gHd MJ['t*É,$5àá °‹7âK”³2_Ƽ2Øí½¤­©i-¥¨s§Ê\Òí߯_Qa²:—ð…#»"Ù– –¦*¨çßvPbT$* ¶óÎîz[±h~Ü÷y 0Û0¢Á¢VÀ Ãã6Ûç_WÉ»ZUÀ$h¡NŸ…](òÞU‚2eS¡4à’ÚÖ œcX#Í…µ|ƒÇ§œ¹ú 3 QIÊd…¢dí¶˜nK™ª¥JEžoŸ3,°zœqªQuœ(jvúkªµ(jU›Úâ¢RêLêtK«J”kÂõ>â&­¾ §7£‹¶‚#äfŒÖÁÅód2¤n Âj[c_™‡W(ÄÓÂ÷ˆ=U.ß‚RÂ!”rëæ¶]žŸ©¢4•ë¾# ' ©EíÙº, ª’rˆòêßZ0£kgص‹í*V‡ç|áöTÂwoÇÐŒ,zÖ¼½wÕ{Á'¹µ} Ì<¿ñ“?÷Yyhzl#´cNnÀdÁ@ª6òÔh'”f |³Jc—–•)Ez'·'ÇzÙ@ƒlLg”óŽþc ®RÐ…zÈjï‰ä¼lúå9•õÄû²ÅbÛ•4°õÄC¦÷8Ëq7‘=ˆïÓ̺>È\ÓK– iOŸ8äbK€  un¸vÖ«©YÈ-·ˆÓ òMÕçŪU|o…ØRöï4¬zK¦‚}¥tÍiÑŽÍCzGg¾ÊÍ#em½ðÜžG×qSÁ>]ÅÌôùqpÄ}iJÎcz‹ 3O`¯!ƒ—­|aõ’ã‰7¡ñY|'0ùßÙð”ÞXåFd–®1Åâ»nh+¬n¥§·PW/¿^ÿ[ = ÇW\ƒ[¢(+@Èx¼{ÁDcš™ÐdêàF -ß $èR{WKù%÷ª¨ ~%§×Ç·w ™š(T–;k¾·¾Ó›I“¡È‡í'€NB9}ðºßD …ÄX±›•Â¥k&·Í1 €abè“|/5mÖøHMQÂвHÄ$Ʀ•‚‚ž¹Ð«Z¬¤éW³Áùªß²Ñï€Uáy@à@µ’¤ëb"Ê08Ûëƒ"7+6:¼æç““0ÚtëwÐlÖ QÀEœá5,hª*­¡UðÎ'ÂæŠ§`-´‘£,П!…˜>l·¯·èâ¥À ÓÌFå9a$Ð6‡¢·P\†* ¨käjõ¸l-¦M GËL¬à°1ÝË#çj‡§N°^†}‡}YvƒÁÌàÐÄÔÞõ4áËomAŸ`ü‚o *~ü=9|Α&<ê==å6¢Ê8÷»;ZÜÞÇv¯àyóó—?:ó2çêJÓ>òå}êlüŠIúI×LÔÎð|ég.ܼRnè ö ,:lwú ‘aè3:¦ÀB–ß è°ý(çêŒÊ~¹zÞ’ßlß„i¬‘\.Ev"´ZÉÿOðÂs//žÞ´cßèâ,žŒ'4½Ø#œˆA‚ÿ^š´fßð£6ÃXvÎÃÜñ-:;NãqÌÉÙß÷ËìèÏ£Bè#endstream endobj 5447 0 obj<>/XObject<<>>>>/Annots 2812 0 R>>endobj 5448 0 obj<>stream x­WÛnÛF}÷W ¡k‰’%_b§~HÒ8õƒ·P¬È¥´1Éev—Vˆ"ÿÞ3»eʱóÒÄ7‰»s93sæèëÞñÿˆ¦§ü•{ãxŒwøÇÿøë=¿C“³sü,èèô8>k_åôiïÍìÁË,it5¦—ñ”fMÆtz~ŸžžÑ,õfÇ4K"Y¨¼¡Kš­•›GóƒƒÙ—½1 ð0*iu/rj©®^ -|pýþµ‡çF“¬„¡_KQÈùÁÆv0À‡=âý0íÎ_îŸÿî_n[ë7‚°|91€z틈.Z…Ù}H¹ºcÞSöy`3£ *ºinEr'–hÆ¢ÒÆµ ö`R –œÉ{¡Ò‰¦©0 þ=8{—ºNÅÏ%@µX€ÒÚ£=ƒßùÕ“h½‘‰àöܶ:XÝ.uƒóL[>¢öPø¾×ˆôâ Æ«L²`êÀøbÄüTñô¾ò“²^É@^;þû­±k»Xz)¿ÛQ9zÅÐwð²h@ ?ž¶ðÁ€T`ƒàd»*K½K´dÊ6º^®@;\…@@u¶.YÅôš šM¥àò”Ÿ$µµ` ½Ùǘ»èŸæ]UQ"JF3Ó5vfËûÿãÖ ¿Á€ìÃHrm"îâÄ„m„‡¸G†b…ÕBÍôƒúbÓnèk2H,X ªaå\u1¥:±q¸k³%CQ©‘_¡wâ•+r_áÎÎFªuv8Xn/}fÐ<y¡­ãå¿4˜¸-T{Sˆè¶™ÁïGß³ºm>Ô<_7¾Ï,¿qƒ„å·y§×{·Í'È.‰uÕ>Æ;6Ká‘Ç7upkÃβÎÔ¿ÅGWçÄr%óž2;OãchÕ‰fkA –*@D}3§Øë´gï.èuޱáæe$ËÛ}éÕV¿¦Êèo@3 .dËÅn úµ`ÈÖòSƒ;\Ô*wÊ/Ì- *ï ~™ úòäµµ:Q‚´õªÆ ¢p]Bþ¬TEY.i˜3‘>V½$¨á‡å2LùÛOi /£×+ÍŒ´Ö–â~æõžJH?dλîgžÄÜI“7 Š×ƒ¬˜®3àé7þÑÀóém–ª„§Ê°¿°£R‰ÚêÆŸÙØÂjÖ/âZ ³@q{a$:ÏQ; øÀíÍϲ$|*ÎùÝV  r9?ð‘ºõa Å¸6Ÿ$|õƒg°4•š$4ö w¶áöË÷™9œKä±` èƒ«é™Øotng„‡/`Q›2<ô¥áéòŸaDOH;qÇê¯+{% Uç.hôVQ>¿ÎCBWZï,èê ƒ“,Dú„—4›XóøáOôÉuÙ&ØÆù²ýH4Ç'Ó:=Ã4óT³~Nð‘õwÔ<ÎP¶AyBñ„³Ã³ ¡ž#€“ñi<€,`òäøœ[çÝlïϽÿæ#Ÿáendstream endobj 5449 0 obj<>/XObject<<>>>>/Annots 2814 0 R>>endobj 5450 0 obj<>stream x­VÝoÛ6÷_q{(æ¶b[¶ãlX€}¥èÃЮ1З¾Ð%±“H”ìºÃþ÷ýŽ(q² ›“‘u<wú}4§~æ¯ù7©F³h†oø2çËû×£x…[Š7—¸V_]EËþ®¤ÛÑýûŠ–ñ:ºº÷ô‡í½„>«ÍéâfF›(¦mF‹­¯æÑz}IÛÔo;£m2¾¾¾¦Œ¾£c>Ž?¾|¹ý4šÑtŽgi÷,j åÌAžÌwœ#GŽ,Ú {6Kþt–‹›%ñvMQât÷%Žßjj IK…Ðé„…ÔT¥i +ÉʦµZ¦Ôzwl £'¼ O”#“5ˆ×†âÈ¿isàxŠ˜#%¢’”YSE´åo3c¥_N·`pvìV¨šS:Ùp¦/Òš˜Y’ŸEU—ò^2D{ºXDq ìÓqR çbú#¤ö×í®T‰_{ð‰¢hÇßñêW®üí£Ç—üB–ë•ÏÐì<}!ý ;³[[`Nî,‹³‡Ñ|ÿ$«[¨‰v²{ôð¿tµL”(Ë#©ª6¶Ø LM:P% þ%F7B1ô'¤2TI í5}©0cB“Ù}’HÃùBÉž`ò¦¤´S©Dx§»nÍ„Ž¦¥TfJ«F¢ÒÔè¯È ¥vªó[8×BPwzf±È5ÖàlÍWý¦‹%ò=åµöÊT:U‰hX—8ì]W˜¶L—£"î$ßAÄ[çUM~—agA#¿ÐòÐ* Ô^CCÏíu…¾—% ó (Y7¹W£Â±AS„…U¨‚]*÷0íæ(PyïT¦ªÚ!ÊK³%í±VìJ9äuÀ¶gn,@B>ß2‘üõ^T&mK|8ðö3-ñØ—ì7<ª*[œÔ5ÅàEz¥åçføìd:t2pì-[H‘Â\3ù¤->pg;XQ×€ZéS/KÐä²¶„v´{Ñ(ƒ0U–PÁ^¶zIÐ'sñO(è€ |–„ç[[˜}Œpæ³ ;Û;Ï‘'A-Q]Ƙ÷ŸP¯Øo~6ñ¿kJoxÔpàGvŠÂ”©Ò¹÷\†ù XÌ &÷½d:rc¨-$¼{ª-Üu€ˆnU¥JaË#ìb’¤Å$ƒ±Ã¹|GêÜ1ìqÿ <¦Äÿ•ªg†úišu ±S°q·¼¸Ùôó~¾YF«xEëÍ: ÊÛo^OxûùÉ$è¥hö¬x^†—ƒ.zzÙù0^FK¼Ùü"+cT -rÉ+8x5CÆÞ¶`ÂÕÊkáçíè×Ñ_z»Â&endstream endobj 5451 0 obj<>/XObject<<>>>>/Annots 2817 0 R>>endobj 5452 0 obj<>stream xW]Û6|¿_±@ê4¶bûrî¥E´i“桟1З Z¢lö(Q%);BÿÞÙ¥$[wiÑ\¾lqÉåìÌìêï«-ñ³¢ë ÿΫ«e¶Ä7ü׊ÿúýÍÕj¹ÊžÓz³Î6TÑjó"[õŸ,½»ún{"q~OÏ^/é6»¦mIë%m^¬²ÍæKÚ²ñ’¶ùìåË—´ÏâÁwªŸlÿºZÒb…'Ål9ù„uüùÙëçÄKZ`ÃÅúºßpöÚyŠM• ‘åãœ*]9ßQ¥jµ×•®#™ZÈëJ™š¦(tÑî¤ÚÏ9ÞkRøãò\ãjemGÁÄVE| t’k©2ûC¤ƒ:ê!Í5'Ÿ×J\~Põ^KV¸›öá`r%©šÜî/ÇŒ8kS‡¨ê\Ï)ǦÐÿ)4YsÏÁ&|•.~‰äb½Î®¯k1Ë­ ~æˆC*‚ý"ÇÐGe[ýõäiÓî¬ÉeëqD)(èø§„ÜÍÆîžÐ’/é:~M'»!2˲ÉWå¼­×Ïîtqa®\é¬u'Sïé×.\-(ü÷Ý™¤- + \ªç|ÛŒÞ\k ¬ÕÔx÷¾`Øi*tˆÞuº|/M¯ž>Mß·yt~À]²9ñÑ3õÑÝëœ)BòÌ!æŒ(„lõ¢qVFoK‚U|?±m~ßÍùI”«á+{0EAl{ö&1*Ukã€Óú9ë{ h¿‡-¹I±!Ì À ”Êô@ Á쬔±´ðhĬ´jŸœF¿WUcõ|¨õÙ™/üD450ú>sèí¾í n’F¡•ÅMãáÒYCµôÔPr w‡Ö¢Á‡šiYbhÉù¹hk޼“ƒáI_ƒCÎT*A‹‹¢~c•¥LœÐ„çZß=¹0Ó—ŽÑÀ¤*}N’g(S5Î3Êà¦Ã¦4ËY+s~pÉUäÄñ-«Ÿ‡#­ÆÖщ . ×r‡žEÃñi|ª´‚"¶]æRžæ% ÃbÑZ'N%¥dÒ…Àƒäð 4æU`˜ÀŸÐ¾ÇØÇþVzW …æÉ¹÷‹Ë‡Aµ¯rF?¡:7ÉÖ2qQËêòp Â2p`èHÉ©ñ<ÐŽ Õ >¡rH•Is4J6Lºƒ"µ-9r’ÉäJ¨•G. ÿNæzÆî3î —U´·n‡Ö68!É[:óþÀ FyÖ”N“¿/Ú¼X'ÄYH+“.”šÙmjHhg7˜ZÑÏÑöê}ËrmœíðÓ€óU v²Û[n ¿Êø# Pì/È‘šD%ÊBhò>°pÞ «¨~fKWLÍJtÑï“ѷЙ9\«áÚGLkZå‡Þ؆ûN€å‰ Xà­ÄåFl–ç®aiê ©# pÝ ×EòJV~ƒØÄA¦Åe4Eˆ+àõùÃn¹Ð¯ÙO’ z¸oû‘x½Ä×7„×Ðl#ȱìÑl—ô½ËÛqãÍ0ê¤Å‹/Óéÿž6n–›ìz1•¹¹‘ ÿ‡íÕoWÿ¤Ré}endstream endobj 5453 0 obj<>/XObject<<>>>>>>endobj 5454 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–-²Ù?Š$†ü¸m”߉¥ FÓ­ö!‚¤<ÿ&ýÓÎí)¹2ñÝ8yQ ó0§jHa\ë‚û÷ºÎlJWÙ‚©˜3ól±ÀS>jN®Fï_Og§«3ª=ZQ¤<13IçÙrùŠÏD×`% (ìšÖ–”–&2T¿UVyUžÑ’XDã'~˜6æãECñjÔ¥ËpºÌ¸Á£‚8xLÔ±ßi¹keVOÈ´Ê¡+“#|쀅ºSÛh=ÿM‡BF£º[ãÖÐ" ‡RI½Á‚mfg-æÞ‹ ºgЩG\‹óóŽ¡'œ´AÛr3´ã:”´5[,´±ù¦0jÒø µ?1Š ãÿü, ÏЄ…nû‰˜lÖÄeë£JúÂÜGÖµzúV •穳yFØóBa¾7‹…¿s‰TLP^ãÕ±þø¾9§c¹ÑÂòúz-|2?š|ê¶=žåÂÅ^ È®XR•¸î¿­Î†×Œ·ÝŽfn… Ž×O ·.P ¥æMw˜¤Û]I§[wåÆ\|00ÇMÜ7Â×mÍM%:ÄÍÛF£67˜è8ßR•®ŒM[³Šñ¦N{—>ãê‡a—7 Qéýêìì'+ôÄ××NYaȃoµé;în5ÂtFînu6¬6¿oKòètÞæò«&ˡտícÝ‹5LÐ{M52B_ òRG`ë¿N­wTˆ(dRßßÊt“§ 1Ây±‚°é´mV‘–¤œÇÂ;Ô+¤AÞÏîÃ!‘ÛZdüTW¹WD¢‡mu|xX‚2›q]ŠoKÕÅJžú¶DþüöªùKjv…ý¿¸¤åÕ4{Uo@Þ#“y6¥·NVü·Tw£Çª«­'¯jîøò@7| ¡îR:ƒD}‰ý—®n—Óe¶˜ã¹zy9çðïîOþ<ùŸ~§endstream endobj 5455 0 obj<>/XObject<<>>>>>>endobj 5456 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œß¾™ßÍoä½ëm5ø^ªÖ„`Cüæp÷ ¸¼y3Ã>`5UÊИA¤N±Y¶¶¾?>ü—¬mg{3Ø F:»?þ¬¶½Ûá…b]ú¡Án6-p|mœïÄt5>[[9ÓF`ðhF«êó?önýî]¶¢D÷œË}cƒ}BaÃ…ôveûÞÖ2x9²"~Á•édi¥õn?¡×Í ~ÅåÄûë?ˆý>ºi-¼ïW<œqQ\\ñ»†Ññ‡¼±‚™œ–ŸJ@,ŒÝzDÒöD…\/coµ×­óv~ùSç4ðPkegzçÇ .¸¦µð;-+¥ïüq ÛÎå#öf¼†Æñc8Þ V‚Û¸Öd2ãÛ™§âû™lìf‰]è?54~3±o[W¹á ­þ#×­æ1p9º'ªŠH£˜œ%¾wk×™V#£tΡÊÅ™K&è˹ür`n™±. O™“øˆ}lWƒÉm+;×#ÙXPÏ@XຬLWaûÆà)|ã†ã…ÍÝ"élÍ Ä’\_!½¿§-_»Õ¡@¤ZÚÆìœï^‘Dˆ÷s8`mÛ‚¼ûèH£Æ²_Z "kqþJìÜ9°î˜¡bw 4lía¶Œ[.7à "l‡xÚ Ö5‹è‰ìììå{<ûê—™+ÓëÉH'/½ß#<ñM´%×l:f˶5ð²ëž: ‚ÆxöìÛ™ìy 2œ€Óqªh{?¶5tmg‘ü¶S H%yNç=Hˆ0”*Uf$ï-h¬Ù´6x•9¾¦8ÖŒ$„4¿›ÞÈHûhªì¹è¹s‘ìðÊÎÕ¶$ðЛ.lMÐàãðÍm·äšß$M´:Ä—Ì&\ùù÷²nGÆg-ùÎuÃÞKkºõhÖ8nðkeÖ<³ûcÑ1-2›bbå%ÃÖ'd…ïŠÛn}néð³á]¦fôÙ\>1•”ø5 €bÄcõU‚>Z,ƒ`ÂòƒVyè<ó”­ DTw‹Lhý^7-yD.Ñ$±œTxžó€Ã ´u ç1ê^û7AED+ƒl>†X±xˆ:!Jÿ¬XhÎÍŠ%fß8Ts†k ´RØÐàÛ1'v‚aÆÁoí<ÿ «‰$P^ÔÆÒé‚$ÿºQájOáØI ßÚ&@™kPq5µÆñƒ#]ø'k:sÑUÒ¨pT$Ä£Å'*‘];vLEÂè-ª‚‘µ÷5I G²ùX©Ó#Ês.“ZÇì», l‚ô@>Îb©°õìÄIþŠHD{xгûꣻƒ ÛƒVçà˜ÈI#׹͸ÑãRDޤûéÄH+Ô” S³E3Tò²²<àÈXGcÇVÇŽÆKžÝôYÉÙ;PÕ>ÚŠúžõ g¹²žÄh+X¸?rÿè¸ÍT$Ž©@ÍD'¿Ê¾‡ÒƒÙ«±Ó¢ŠJöˆæq ö)Æ#^(,ôwJó%¾,'ÈïH€¼©~0åÝI²¤ü‹¢´ ¸ÐòƒÇs'¶GG1Dä,Þè¦ÑM±Új6QZšêêòi£L&Vå7)«fÏ™<Ô‚a"Âɨ…l¼,[ä3Òz22R¬’HdÖèp.C‰E-ìA¢¬ºÚÀfí3ÍÏàïÎ;´¤´984Êt2¬ŽmPlòa„Xè—çÅãÓ6Ä¢ßyÉ-Ü„y\s/b,_ØŽc¡Œ{”ÝwNðÔ8+ƒèJ0à%bîÉÌË&ä µ½¯™QÇTÈAËú*˜M,o1Ö/ž[ S¹G(Å 9Ýœ:÷¥úu¼Öæ Ÿ…1mKþ'Ôò »w5³•e¿á1J´˜%:=IÇ6D˜9ðzس¯š8˜ÆNM–£|·ˆØç ‹æ¼ŠÉUØJUi޹LßDœ‹40ŸcÔáÔ­Éü(éÉË…[Óö“s/X½²O>Р?VÇ¿è`í»ÂÖwšà”ÆlÙñdpZ_1ú`0·,yÑÕG5ª  þC›ëí0.3}6s°õl$xS¡[*Óœ:Å\?»…¦ÄÅ€ÎLó<—0yHïÂApÀ4¬ÀK±ÍdÇ«’±Ó1Îa—‚Ö( ¨‡1-á6Dã§COÅK†©tF*Óg"–$ À2 00¸7ê‚Æ&Âη,käœW±ÆjCµC-]7)[´Q{º)â­Ï‚—+zGt+Ÿò•fi’Ãr?jLËqtgôo ‰8@: a…^QÐîвi„Õ*#Ôa\h+æbEú²+ ?bž˜g‘ÎéÀRt¦pN–aÄ“9„÷¸R¢`´Œ–ÅÂÍueeûN·FЦ[-ËiÓÔÅ=Š»…ˆ»”i‹Ë"Â=Ï @ÔÛƒùƘÁ_è1j‹‹’…—é‡oQBñrmú%| ¢>U,ÓyQ­ïYw !N×[”ûžCÅQ… ééÒíT¿|©]è/_Î^•q?ÏMYj†Ž¢5—ŸuäÈ5HÛ€˜ÚéÅòíÏ”ñ*·8íôœUkà4è:àýÿÙÞ¿´¤_$ŠÔ#Øîeu©ü¨·vúø$xZy¸|b€n–\/øp¾†¾C40ÂüÅ1°¼G÷¾f£°©,Nx¨.Ï¡ïF;-‚)@Xr3«9逩Ô0¢È òD)ÐiÔAº5P‡‹l&u<êòè+ÂÒk_\Óòöï!I›³J}”וïéÂ@ÞS0¼Þdò"`*†O‰8£µîE±2}9øQ×&˜>/XObject<<>>>>>>endobj 5458 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&>=NN’c:ÿ¬Í*‚]T»àE8r_|'Ç0DS>Ú˜Sj¤Ä£€àëÈÕµjÀz"ºÓ°ö@˜º þ³…u¶èBÉ’pöô)k‰¡|B¿L— š#<´åʇ¨\4]Ó&¸„~e.gª.bãk›š]:ôJ½Öu ´»i³‚òØ‚©|qkÒ­ü$ÄjËiªjréEÐ>pgŠ»- pB\©p'h¸,(åªBAƒ¤Àƒ4¤—.b²ÎjhÑÂPê¼Ð|ØÂ?ÉŒ‚›ùèQWüi“Ò£ù~;*{kØT…_séÚ§¨%÷u‘¢¤,³Zä¶ôJ­*S=¬|GªkÍh>zlB€VÿôšÞÿóî²ÛµcÛ˜¿¦k»<=}ÛBí9nÎ;t°öì Ü×®1"¸òm â{ìnšËMÒêÜèAc{à4©V‘GÔ–Fé¼tÊ‚/!†]× ±ü¦ÅHß–[¡\—©P»‰%È &m¿U­êeT9ñ‡P FaJã€ZœWÒÚ£!¡³Ht|Ôa'°Gd©„âjÊö ýF"@]v7`‚>8ŠVuh!~ñ°4´°7Ñ52Z ²ØQV3R»3p"Šr©TwŒq¶`èá3qÐkìÒ: ºÐ-`|P·ŠS¯ZAÁ£™eާYvŸOèF‡àTRsoPtkÕ ½y6¢–Ð%¬7@T/–nÙ‰D×…úkájrÌ+^P¤¦íL1¾Ìb±ýâò9/\D’ƒtÚº 4¦( »# éË…urÊ`ܘtAO¶¡|B6úqßëÜê'°åͨ¾Àj±`beÙ]›øèSÐeÛ&Óô;â²µßUˆ1ýB•8)Ïê¡UOç£!hÏ;å Ÿ }øxùÛu†Eó }|O6€QÙúþÏ]uÄÚÝAÎ2kÌë-† 7^Ч¡£{B' .Î’f³j5@‡ nÓ,œ†"!Ú¬ý}bóŠRxd:<›³ sÝ.i³´¿>Üë&ìHXf°Pàfõ­‘ú dµk×¾8´«É‹öÕc2ÆJ2=¡Ùq»oð˜'ɘÞz]³Ö‰Šq çíáófÁ–mfJ®±7W¹]ÉòѾõ¤¦Š¡–ÈüìÉx–L'X„°Ñœœó¥ó«½¿÷þÔiV}endstream endobj 5459 0 obj<>/XObject<<>>>>>>endobj 5460 0 obj<>stream x­WMsÛ6½ûWàÒZ™Ø²"ÇŽ›žÚ$n2Óô+êôâ DBbPP²Úéï{ ‚6“L¦‡8žX"ìîÛ·oŽž¨þ=Qç—ü­Ú£G³é ‡ÿÂZ]§žÌÕb…µ—WWjQËû™ZT“ó§Ó‹é…úugÂÆèZiW«Ê×F-¯Ó£Åû£³ë§ê Ör÷éüéô)öO^9½l¬[«ÚS%¢Zù ´ª£ÚÛ¦QkãLÐÉà©3ûa¥jMÚøZÖ˜=¨ ©ÓMyaJ“O:VÖmL°I» 6Úº©Zll¤gð‡aÕÝx‡·Ú=´Ùø¤üêA0b±ÑamÔÆÂ³PáOœª·Ù¼èZãR„uT0:Ćýí¶1wøëàl´ÞaœVÁ·*ñ@jp§ÑnÝi˜I‡­‰âW0±k‚QÙ[3¼¸| Á°ŽÞ)‹Õüûðª6uvëà;MÌíÎ4e˜3€•wÍa󷦲+[ePá“„¨^coy "ZeîR6?; KNâì"¬ãыǧýÑsaÁ `ƒCàšŸ\{å?6Þ{v£L˜|—Hž>Óƒ¡ju]«è[£|ÏÍ©zãì%[u@ñDe~ÞÃàr0¡>8Ý2Z> £ùÁ­VtLñUÕº[ ùä±$60U˜FlÉ€%"³z„Ì©Žw#Ô%•Hà6ø%2tèy”¶3ëÆ®-ò–Ó¾Gù$:k 2ˆmä¤ ²-ê '€N¾Ù¤œÕj¤Pß«èÈ™Ú$ß‘^~½)Žc¯5BG`ÆÅl; ²¯QI3¹Ñõ50¤Þ²8X5€È÷¥‰P»¦¦=åõÈg+#¬-™e’jbÇû¡éuaID´ˆõátêtþ·öŽ_™&°Tùå{Tu( á–g7‡ÃÊÊ›GP!MýB¹K&C´läûÖ[— ¨Gœ#üBœ¨½g)„Î/wÖwÐC]¥ h&©%ÚÑcW±Ä)mWmTlüž)ÙìaB¹ÑïÌJ¨¢…zöœ†çð` ¢Ø¿ÁÒåáS±x¨ÚE~Ôͤ‹|Á¾Y[J˜ª¥+|4#orxÿ_S$¿{Òéü’*.­Ÿ š­ÞŠÂ¶÷”â“uÛ®¯ñ.ñ#²Ðzê@Î !ÈB,e]h4–P{iŒS{ô a5H?s*#Qã3»žûÕ(|BÖEö¯O|¡Y†B!”dpí>è-‡]VL‰wX†¼±_Rœ _T@8p\üµîøäþ_!m#W†ÅèI\‘/'ˆÅ¬­,i(_@á"8Ê´v‡™‡—AÝZW£›Å>ȯ´$ÙÛnO~SãXj¿±ÕfäN>‚Q âà·ÁÊ4=v”P”-È»íÖ‡dê/Òâ™zkce´Vƒâ¢™Ïrãe?Ž ^ IÞ-~ÒMw 7ÛFWFTÃÙBë}E³©ÂABSýüùN¦œ“ü%¦€b9Q&USœeó^Ô8Ž0È`Ã>¾‹‡Ãiÿ‹Oæù8  x¯Q%K0¨MLH81ŠLIkÆtγ2Èie"¥šè©™ºšžs„›s†›OÏÏñ­žäaíÚ{õOqƒ^=¹™Ïæ£ ?eJ˦ñoa>ÜLn}?ZûÉæåý}ºNʼnóéåå3ùC ¼Íú"㊴•Ü¢‘u§ƒõ‘þd• ÅÈîBÉ’i,tb/Ò‰ :ð;hp3êjí5¡Écò8_ézgY›É—ò@¹ó–ŒPgcxÉ ¡¬zý˽ÜÜi¶ÄVr7l}mWTÏ¡·J'A“xÖìtÓQfhuäŽ$û†ìBƒPp1r|8Fô&¹ãìúkfšUýURü†Z µ`– <÷îIEßKµà.3méFÌ¥+‘ CfOð‘#?žcÂAî‘ÏÖ´Kõ°5í«èã²¹× ¹çä+ÏU¾ò =]*L¼ª.&›Õº÷쳪$×­ Ë#‘ƒ;Øb:9É<¼ÒKŒsnJÒ­Du_œqŽ‘^$ ½+™¿ÀÍœâå{Bƒ§óéL½ô•\9…FÜiÌ‹OŸñÊÝÏD_¼ž_Ì.§çsÜͱúââ‚§¼Zý~ôµ®[jendstream endobj 5461 0 obj<>/XObject<<>>>>>>endobj 5462 0 obj<>stream x•VÛnã6}ÏW *gÅ·x³i›b›MÚô¡·5Ї80‰²™H¢–¤b{‹þ{ÏP’9·]ذ-“Μ™9s>ïô©‡WŸ†c~GÙÎÏ“^ØÃŸ›3§ƒó÷ÔÐ$ÁÞñÑMb¿Þ£I Gá8ìÓéÁéÛ·´i! %e9¥sÛ™Ü율­|x0 G8|Ò™t*“–– ™ÓZ—)œ$A™ŽËTvI9R–2e­ÊçIã„ÊéZ9K:ÙÜ!RåÖ!kCr%²ÂŸL¼Å…ˆa®q†Ru+É-TíUŽÂ!»5`¿ápˆ§8¸Ó*&+ÝÌ‘ÛD›l\db.iOe]ŠuyJÊ.GWxO;ß·CÜ÷ƆáxüŽ!„¥.Ó˜®XI„§£3úsí:ïÒuéà•40*Ö¼1×$…]ÓNS$ÒXl…Ȉej¾p4—ޤ1ÚØû+¯ž ñää¸üH—¼ Ásvâ C"ºìw{üºê>µØëúåçýòó‹X¾ºj™eO¶°ÈbÚiíšÉkÝÒ4È´udd$sW!“ ë¦ð&¢s˜ßü`]¬ò“7] “K꣦rú©m{]È3Fï˜&øY!ÒÙª‘“1ÍŠ™˜f³*ï|ô¾ž·’=YH*ŒF‚34ò‰êu ÑdOÛ™E‡8SFŽD#û¹*Ê´ê[*'¸TªÑ¢¾ƒ‚ºüªêk{ÐHKT¸¦ÒÊ&šµò¿É%z8|³‰œ–F¡ß,:ƒj§ÓGýÒo%ð†=.ÑmgvUθn»+äÇ©;øð +_.ÉÚíþËÖ6‰<أߵ“ÇuÛUa3®òs©.WâTh•;0?ä$ŒAïÔXMƒ½i'iï eû~9—ËY&Üh4 ¦joÛ ô…‘®49 ðþ˜ß9í qiª£iÐïYõEê¤ÙÄÆÒ±üV®lÕH+‹Ìa ž?ûao‹ÄmëƒK¿bÛ ;xbÈú‘¯)|àSÏB÷!Δë¥ë®ç î´\{ÃTÈTÎj'Õú–‡²(@x"Z„ô«^Ê;iPS<òÌ­õœÆÂæßq—jZs‡*žÒz7¤ ?ã ]F§›¨9ûƒ13¥×6úcŠ X|±M‘>t¢ (:½‘8‰gX>iˢЋ ·ŸXE溜/”ÖÄkÉ‘‚«8ªt ò]@‡ì§HÊÄ"M‚qÍÉÖ(0û áëdXMh÷dùUI™¦Žü3ÆÈß²wŒûKOøÛj íq±[x½æßšR±LžP1 èmUâU×óL‚1½IŠKâsžÕFÎj Ð?…‡ÃCèð÷a¿’¬œ±ýAØ£:*¹¯|é3P(Õîýw•È{U­öÆáp©Çläl²ó×ÎÿóYœ'endstream endobj 5463 0 obj<>/XObject<<>>>>>>endobj 5464 0 obj<>stream x½WkOGýί¸!Œd/~€C‘’*Q›*RUµÕ|ÀÈvÇÞÝ™íÌ,‹Sõ¿÷Ü™];65ªT@6xfïëœ{îåσ ñ=¢É”ÒòàÝì`˜ ñáæÅ®èìý.“ Í–4Òô»Q2¾¢Yn i–ö(~-¥;Rš¬Ð+9ïÏO¯NgwCŒp/ëîñíRøóó…“~Þ}Õ¿ë?^«›ë»›ùéþ ù(ʪ ./7eñÒ.E*é¶V…'|äMEfI…iÚ«¹,*iiYëÔ+£]Bïíê1æ nb ‘¦&“¤MCNÊÒÁ5ÆÞ‡šï‚6“Éf½7oÞ ¾×tÝÙ È$IP®Gý!ßô¿v8ì‡ãçÃñó‡8¾¹Ù1Ë‘ìÕô+˜â?µ­ójo³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çÐh°4,ža©bW M¼=xûuržL“1½ÍXæxæ*ž±Òí„蟋á4™ŒñÏÖ°‹‹WlëÇÙÁoÿÚJ=ùendstream endobj 5465 0 obj<>/XObject<<>>>>>>endobj 5466 0 obj<>stream xÍVÛnã6}÷W ¶5àtmŶb¯›>m·M±/½ .Š~¡EÊæB&U’Šcý÷ž!eÇÊm ¤h5ä\8çœù½7¡1~'”Ïù¯Øõ¾^öÆÙ‹§nC—7cZd9-KšŽiþå$›ÏßÑRF«1-‹T%­…[ ¾nãW×ËO½1&ø*„ŸÏ¤%ow*lµÙÐZ•Ö©GFŸ‹"hk­w7‹2(×±éÿÙ¾"<ø+*á=ÝXKtÌêf]éâqlÚ„=?Ü­.¾êìŠg_Þ\'SÒ>FÓ¼-Á`¿UNoà*%“ÁY÷´×U…ÔÉ©º…’´>PØ**ÖƒÏ.?¼}Kµ³µrÄå²2;&wÅÉý€ìM4…ÑÝÊÆÄ¢Qá”éПýøiO¥6jHë&ÐÁ6äõ®®´ÈÞ„”TX©øY_° ¶)âqdNù@¶Œî6Ê(ÇŽÕ™r8'÷k+ŠîØØsR^yŠ‘ Ð[-ñÆG>(U}€[S£$ÊÄ“Ï &Œ|Ú^ÔO™—(@ƒi¿ÕÅ–Ðqê…œEô­O]C7b[ßl6È2£å ƒk½¥[ÕÆ+PGO·¢j T®ÕFÃ-ßV±{iCzQŠŒ¨zì¤Ög¼ÃÖjØq4¤O n0Á-äJdÈÜäN™›« ðÑtšå9à.ý•M¥¸Žè#`Ê./é=Z(]à©“" ¬.âµ1P" ûm­Vƒ7û~CÀôú:îúðÞïböê F ãæØŒÉO—¹Mmóo¼FÎù§yŒá¿$ŸïmPþš~ñ *‘¸äIx= —g[ï4žà%Àx^” (PG¬‡­H”ôÀ»ß i÷iñÈŸjÏÉè}åíJgw‘'ŽW;üV9) I–gÓEä¯N’7ER;Ú»U!Ùù‡,ÑOmöóníŸIìQÚª²{µãÕÑÒÁÈ«ä¼L/vôÿÅ7$mÛ ec¤rÕY˜i#©*ë£E—UVH%‡LŽhk^4€’5ŠEúúc¨ã&tíš*h°áÙa>£§±%ö/æ5px $ ÎC£SžÝ1µB¦%7rdè<~ƒf3ÔÖ*`ௗäkUè2fÂêÒšÞk7Ö0€5Lì4U*°*ã!Iî1slT`D!{´xœxá²ñ‚(¶ˆŒ‡…ôá¬bÝìY÷[‘x%Œ$Y´#Ödq•ÍòÍ'­âQc4ÍÆô-bÄq–„ %ëÑ»4æWÙ<›²|qO`Òl*ªãe³¤²¿ÙxžåSLÈÂÙlÁKß.{?õþD…Z°endstream endobj 5467 0 obj<>/XObject<<>>>>>>endobj 5468 0 obj<>stream x•UÛnÛ0 }ÏWí8­í:v’^†õa—l{Ù ¶‡yT[n¼Ù–g)סÿ>R¶R8tK‚ÄŠEòðúÝ郇ï>#úDyçå¤ã¹þ¹ýªîábìÁ•À$߃ÑUß.ak”“Èê–k5EYñ’1Œ…¸¹¹ctÿô&?;8}„ŜƤȹš¥Å=ÜñDT^ŸCIJ¬î>4Kô‰¶ VþŸ–(^=á ТŒII¡C;èr~—¥ÑM+6LÒBæZô° {Ï#v7ufã- 8˜¡ã «ÖdÆA²œ暥\rbÁ«L°˜Ç‰Bªj)QI—œ^Œ¯¡ïÓItÎˆØ î+öJçÄWŠ2,S5ƒ®^ǵ¥‰,î€l?D ÃÈ©:˜¯¸TT°„35Ǿ|{ÿR‰@¦ UXÁ꣡ŽOêAS‹FÚ}Á—@õ±t´Ì8“h_h‡Ÿ´Ž “˜SLôò*awáÆAÈ4/3Žîýêâ´Uêø¾¨YTN.âù#Ø^«ª]ëÓ´ˆ²yÌá„4:ãÈwåÎNÚ&m]Ö©ÂWNõØ‘ª$(+{moÚ y0ËFß uÇŠfØOgÓ)ú›NC+ìíû"UJÅTF«¼üÞ÷üÁãiÛ…YVHmZ³Oj·¡Õ½·õ'ìØðLò,qnWvó°6›]EÓøª8ª+™—{. kÛŒÇ-C†«µmžÐÍá,’ÎðBˬãQhÉtÃæÖ8é‰wÉ᫽h)Ü\ãæúØæ7wjJføjhXìY¶I¨pt|K›úâ±'ŽJüööˆ‹¦\íoö ìµôKX]zX´þ†°äÿàÈ:8R,=î8Ì%N-b9+ÖõLQLþÒ“ƒÚ>•.ÎÝÊDI'°sX2lý”ØN?ìüš %¯vœ­‘yz?S¨“tð“቞3]=²8¦®3J8«câc¶_ÿZ —Dgš ÎA‡RÜÓ‹Á“M>â+…ë’4üæX¬;r½_55î_ Üa0Ä ßs/ëQJ#ßñ]^‹hžó‚†(ˆu¼Ãj´sYwø?Þ@Cï)/.ÔÃá5õfÒùÜù ssbŸendstream endobj 5469 0 obj<>/XObject<<>>>>>>endobj 5470 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 2819 0 R>>endobj 5472 0 obj<>stream x•VmoÛF þî_Á//¾H¶ã:+ö!m“"hפµ·C€â,íÛ¤;å^ Cÿ{É“ìÄIn@“À±Dùð!ùPw½ RüÍ`4¡¿¼ê¥,Å;ô‘ÑÇ—÷½qš±!ŒÒ3–Bãá„M»«f½Ç×h==Û?KÖ7óGƒW³‚“˦ló% S˜L36™¼‚y¦0Ï“¼äÖÂnüw4ÿ§— CC‘Ô~QÊü·ƒ{@?—ZC%œt¢ºM¤r U!¶·G¯ƒNNàb›‹ÚI­`ÍUQŠxQˆâ¹/ÆØÁÍï¯éòär b D=Ž:ÔÉ×µP`¸´R­€ÃMãÖCì£-®àí1xÌÆ­´Îßà,¹i.Œù6næ z¸MnÃ%°ô*À¹»Ö÷ øBoƒ9º[ê²Ô÷{r‡~H”¹¦r®`!¦mŽ¥4Ö7+_ åBʇ• ‡l4Â:r›;7Ò­+$9GÈÚì„ÊtOX+ A>à0Ë…w"öÀ…ÚH£AŠ>r}5íXÛe©¹Cžn4¶GÌÁUUk·ROE^Ç,ÕøEÂдÐÜWÊ c|í^þQë}óð‡¨´‰úÿÄ«(ÕŸ´ÃtKA\‹"æÿzµl„YbïÅì_¼r2~æp 1õØñY£²=k,Žzìì›>fûSÉ\Qó_¼ôQãßÂèwrƒ³þ¨Å£Ê@ãYrµò|%¤GµÀÔ&*2ÍZ'ûÁe²µì”&R. 7 ,e)ÂóÒêý$;„G<Œ¾e0:óDÍQ|“Ù׫÷ð±ušm/ø;}N _óû±Ó„3ÈÆlLÊGº7¥¯E23ÔlY[À*‚ùZÉ;/ìat`̦S:q^¢0úÕi‘³eÜ;]áhæÇ¤KF &a®¨#\*håK/áÞðº&™«^`Ó’ˆqFÜyIgŠB’ðð’DΠü×Þ1}N-`Ñ ’(U^úB@!xIïQÖ@{‡' æG“·Ç`ƒ"ã—…TT„‚;~òåÆð¹ž¯1Ž-(¤Í= `+¯¹®*ÜÌ R°ºÜ`È@ü&«a—Ö鈵¥|²#œepEy Ï¿D}¨Õ9t`ºH©¼¥¨+LØæÖb`xÏÒ …•a% 5©'²Ãpåì»@oXÈÑå±Ñ2ìÚv/o1¼ƒ¦ý×7ÂúÒÝ=Yô¸µ;ü[øš°„©„aÝ|?LöÉJFdµ0ØÄ];>~ßx´Õ‡õ‹W¿Öo^c„óFA;èÿ’Á­¸jïy8±íÛµ:VÝJç±õµ @kä-Æ Â|ž+)ÃOã—JëØU®¥qÚ)Q6³ÓÑ)¾“ Yš…ÍOÃ:À+x§óð¢ÐÒ1ä¼}zðª­ÉÿIÂi:a£!  Áé$£óóÞçÞmˆ(Žendstream endobj 5473 0 obj<>/XObject<<>>>>>>endobj 5474 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_Á¿ý-ççÕßãYÁ[™5%VÄ6;A²ç¬ÇKw^<—áVUÝ`‡`ecèg×íš¶]E‹0žám÷ÕbFK%ƒÿ´Nbendstream endobj 5475 0 obj<>/XObject<<>>>>>>endobj 5476 0 obj<>stream x•VïoÛ6ýî¿âfÀ˜bØŠl'Ž»alÙòam‡¸ð#RW‰TI*ŽQôß%ÙµR;I~!â»wïÞñKg~`2¥Ÿ8ïÜÌ;QáÃݳ†óÛfáæ Œ#˜¾…Óé̹Š`ažÍÿëD0ágHåÀ ÅW¹°–­Å2ˆSf ïÄ“­ömǸ¸<û•vžß^mM`ˆG Ç“úˆ`‘ ¥wÁÇ­Kµ€K$¥ŠÔ 62ËÀWy™9YdYV ëA¢ŽÇád‚¹ðàaë„@ ~k!îþ-²LÃB›Œw—g‡ù% 4¦XåðËÁàWa(Çî"Õì§îÁªÈ¬8/”ëÀ;ÉÊïxz* Ä:Ï‘ät²Ï¾f£"˜DÞ—R˜íŽ6­6 žXŽ|yDG‰zÔ’ÃZ¸—¹PI·ËàæŒ|‚~^×Óè ’éKë¬Ì1æ…ÒÎ5l +°šwnu ¹\§Îgã+¬‘ÿTëÓèz¹æ%–¼Nå€ížTqVr]·-DÎ ÊÃzôXQdÛ ÷‡OóŸæðµúô àÌ1ÚŠ\|¤ÖÀv„L~& Ò6‡í­ç»æõ\'Z/ƒ2–ªt/).g[ß·)C”Ê] ÍE$‰ˆ±¡Q/oÈ’kaý ¹H¤BÔ2¤È¬I¢f Á¶¨ª=êŒÆdd~Sr§ÉExŽá^RB¡ ª©9i¼’‚/ ¿Kª*­ƒ6ŸÑ]Šùì&ÃJÙ6*ßµ-\ð<×åbé·#™âþp®ÕÏx:Cëú“)µ²?ª—: GK+±kÚGm†”ðà‹k>BÙÆ’ÉCÂ%¾Áâ^g"ûcÁa…Ñf2ªïkÜ?Æa'p(y©2Η~,>U&¹mlSXœYµpwÎÒûV¿¨~îªzè¿X3ÿŠâ%ÑÏŸ÷mïï£Ú ËEÛ+ÈYl4šŠ†áÈDn±}R‘X®¢Ê;blAµç¤ØÜ1.¬3sŽu±4$ùê2kåg:‰ë/ü¥&dæC¸SÞ fßErØŸJ®…‚Nü¬°§ ’d}%6+ü¯XmÖ«u‚XЃþS;Ì×±f‰WÒY«*ËJýZ~<·_î1/«jÝ‹f⨅#GÍíˆ&éF—ßOÒú®d÷æzš)?J¼2qš|OXS:¯oŠªn:ÆÇ,®FÑ,l¶*ˆ#Z:¿Õƒc4»/'—0EáUu»_Üý5‡ü¡ão8!ðžAÛðBXE¯ªËåqg¼Œ¦ádŒŠ=y9Ðî?ç;ÿìq6pendstream endobj 5477 0 obj<>/XObject<<>>>>/Annots 2821 0 R>>endobj 5478 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™ŽÙÁw³Î/!®»Ëendstream endobj 5479 0 obj<>/XObject<<>>>>/Annots 2824 0 R>>endobj 5480 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ÒÙ?ˆŽiXîW±b+¬b9éŒÀ6ò:H+:žRä­-‘±Äü䙯ªÎ*š—`!KÜDƒê’Èò}â¸ÚÓÙÞÙ«WRx\hþe5Ün ñI„¡}$í¨B;bœ¹U p^r§Ðh¸ÂĨU¡«±yô†ÜdFøD€3ÛTöÞ\rÿ›kt üçµU‚ÊÌS¾Þ”,<‘ÚÎc,ET> ÄðX+YÏjí[ ˆ4wª¼v" >½ “Z:´¨&ôLëpB¨ó—€$\'¹i+g¦Ûírð/gÇ – C[WÏR>sî ;±B?Æ _¤O; ‘~iŽ4WˆbÓ“½Ë¡¤¾@‚8v_”&‡.@ùκ æ]¢akîša£š·›êLß!¡ Ï겪ªqU>lùõé#çžYÑjëoO˜®KEœ¶&l@SfoÎÞ<0Å.Ñ4ÓV—*LB5±ä‚T•ŠÓP¬ŠøÔ˜b N\뜫ˆÎqB}¯ò‚GÆÉÙ;D13]®&@JºÁ¶g¡AA =ááL >s$?l (U޹ ¢ÁŠŒBo m G`•ÿÚ&B ¨ùÙêÓ¯h0€ÙÍâÊÙÙ?§žÿ;[2 5¢Ï\ZyÙ·ÕtÜÙüFHôTÛž^ÓvñÞÜÝê¯?ÿm%Žmc3tDÚ^ ©1eqÜ<þI€„“¬6³mÙëÅv´Âo•ÍÕ‰õÞÅF„ÖËü>ð{2ˆrJ¤v½iì&aªN]‚Z"åLF{@ö@ ϳ6Ê&Ì–íX!ˆx†ÆÒ’k} ¼çÃA;LjQ€†ŽìyžŒ|·“0*ó† 3XpâëpEgkq¢°kÛ¢Z:˱À ÎÏeƒ9®Î'˜{q$‚ÊÍ€ç|ÈšëõdÃørÞZ?¿#°ÏܺuÝ|é¡ܤ.ÃÎfKµãÖ¤(sñã¨X³P·ëñ<…öù@$qß †qÙu“O­H>ãðfñgX_Ÿ¯Û¹,¼¡È¤.€7å͹‰]^àu_Äïåt@Ú‹+XÎÐÑî¦.ËÜüÓ%Ïa"NK7yá bݲæÅJêpØŽbÇÍNÿø :Ü?¤áñ êõeb•…+zçbŸE`<ÌmÁº{ÄsËôú6¼µB˜¨ÁŒM{xK`ÆšùÖûÑÆ_ÿ˜ÇÙendstream endobj 5481 0 obj<>/XObject<<>>>>/Annots 2826 0 R>>endobj 5482 0 obj<>stream x¥WkoÛ6ýî_qa$ˆ²ÚŠ-'N[‡´kºÅ5ÞŠF¢l¶’¨R”oèß¹”hGNÒî‘v(“—÷qιןzcáwL“)ÿÅyoŽð„_Æüòîu/ŠNÃSš‡SÊ)š> 'Í"£ËÞ‹Ù­î”YÐÑùˆc×,¥hDÓ'ãp:=¥YâÌŽhïd,ÕJ&$ R…• iè)Mgz#ޱ' N£¯Î‰¤4„±a4io ²KU‘¼y™ÉV’캔¹( ÏEYf WXM"ËHÇqmŒ,bY‘NÝæÆ<uæ8Ò½0 DXÁ&CúC×Ã[#SUà¾ùzMU[ÖªXp$º´J"óaDF)ŒÈ¥E€ÞC:ׯ»üÔ;°MÖ0ŠÂÉ©K‚ý\'u&ýæÖ(rÀŸµqÎáôüSH…. ¹i¥¿¼n3µ?{cúø„Å‘‹õ[],®Î*~›{ª(k<vïI•âŽO#½ß:.¹X¿2æêRÚKk’y€7ñÕï"«%>ÑfÐuSÊØrá;¯xKØè~Ø6ÒÖ¦ _~{ûö~¿t<ï®öU‘qÕö»®Ë”ÅR[—šÛníº³ï¬~±¨vÐëD2$u‘­IX+âe L³¨sYØ €–K[lÉ…—Ä1•¶ð¼í\ó©çF¶áGÇŒ¨àðÈL‘pÏ ¢BTªâ ÀA—EiÝqP­«•ÎVàK® C¯s,R7t^¢ÎÃakFŒôepàOë á8†ÁeÇ¿Úqïòý›×ôòÑ#çÕ°ZWVæ!½_ʂ֠ZÒÐlët ÚÜMÈNXFh£È­þöQÿ§ZdH‹L:A¬„Q.莺ˆj×\¬‹Êrl;þ„‘I¢¸]j"¦Tg™þ|Ç G€ì˜CVâ rÂÖª£$mBn«Å,þïQ‚ò6ý*³ŸÌçE°7Þ¥Ð?âe=' tÝ¡Ëù;ÄmwÄð«ÝÑ]k(¡‡Â¶øÒ6:úuFÏšnR9åY¥éZ¶ÐLP:C £ëÒõ†€Œk'¿žFÿ£Fó ^ CßUÖ \2ÉBßÕ/ŽÔìbÝ(.äÜKᄀ@›—êOùüñYoš—#Ö5ÚGã\< ûœt‡IÇpAyY5ô‰º]¦†ùIÿÁ) Úøg±®:”dÜBð‚T, Hk»d»þ€öÒŒÛ3º>S‹Ç‚´.bf/¾'ÈÊYW0•©mOŸ…¶*–´ÔŸÝQ$~a—´mã¬ã¹²P³ùá×;øóçÏ}÷ÛÄȃÁÁÏžÑ{m²ä`~è}r€wV0Àë£ó'4†Ë~:ñ#f²Çaäƒo±^5G|gà™é8Üt…ÒÈ•Ò5¤ ‰âÖ ²¬Êœ:CàûªèoÊÁ°WÒXq:Iv²ú2¤3b}”vÍM&Qi*1dm5£ÏR'w;C[fž¡¸@­éfäéH€ ½¨÷Kfƒ›¯Eü‘ïüñ¦ü×ArµXÚMA`º¶›È|–6Åÿz5·3,µC×=|4²¶Å JWçFç͈52µAÙ{UñAÊœ! +C>Sè3ÜÌWX‹kßç—gS 9?¹Ëº¤ö]˜Ýyãyàe­û±ŸÞƒ>ÓºÄhäfŠ£óÇíŽÃ“É MO[>/XObject<<>>>>/Annots 2828 0 R>>endobj 5484 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Øqj:»æÛ?-Î~?ûñ?œendstream endobj 5485 0 obj<>/XObject<<>>>>>>endobj 5486 0 obj<>stream xW[SÚ@}çW|ã2CˆÓ'ªâ0µ––ؾ0ÄdÑܚ݈é¯ï^B6(ê8šìù.g¿Ëáo«*ýîƒ>b?–ßúj´TE¥ó_ñ®¦*Œ 4F7}e4ºÃæ§T0¬ö<ý±~AÎ<]Ø 6«iúâÏeÛÚš1t–—_.—– ½>Ù§A“À^¸ÿÐÛÏ x(­°Çâ+w-€EL2„‡Ã0E´¼õ8¬ÆÓíY¯ËR&™««éX’ô(c=MÏ£'É6 àÑŦI`7 0cå㞦)ºN?d‰ÁVOh·l³X0ãGâ´#?-sáQ2¨HyžrÐ"3‚ürb ×fÞ•áUŸ'á](ü¹ÌKS ³£˜ æÓÖ&Q„»jítPÅÛ‚¢…çZ´@‹W%ŽU/¹-i6SΑùК͆UÂA¿ÐŠq%#Wä›Q1ÁFy¸J™œÛ<ÜÛÝÃqoq\îŸSlDMó| q2oÕÎɰå¨ëšò­äqTJkßÂ(OaäÜ;ºsùh3ãôŒ‹b`qO2Ûåâ§ŽÅ—/™ ‚vœ<Û¢2¹¯(-ÿûfzAd&«„¶è|' à¦ï×mcx™úðøf¦ÉVöõÔ¡Óš3ý ¥¸<ì¢FÄoÓKÐ'15Í#ßN£ßÌF}¾‡×!ÛªTËz?Ø<<˜f«wEÕN…¸\-HºãND (©¬éyšÛÈè•çL…ÞJhÏ‘m’ƒ©k–CY7æöÅ›x1#Bºb×®É@(¾¼>X™Ö^v“šº‚Û0`ˇª¡3æ³Àõ&ûcÙžÎï¡ãÈùóÇ™ê㈠ç÷¥^U¨eÎ9䨏9šãdIlRaœéãY@Pì˜:©ùv1ñàg‡n ?P…˜+*—ßm} Ü€‘FÈ7#¸7}º…319Èä'Ÿe¨ö˜Íž±1­±Ødhƒ[ºw¹ø3{  Ö1Ý1Š84Î’ÖÔ2Ô‡0ºÖ§Î÷4E…»ÐJ|“‘ÀPTŸ‹Ã½kñ©„’:¦l?cä$~\¯Hõ¡:Rt~n¢qGcfåÞhýlý´sûcendstream endobj 5487 0 obj<>/XObject<<>>>>>>endobj 5488 0 obj<>stream x•VmoÛ6þî_qbLqù5n²n:7)Rd]†xè‡jŠŠÙJ¤JÒq½¢ÿ}w”dÇ‘Úa‰‘˜¼;ÞÝs¯Ÿ;#âï&3úð¼óÛ¢3Œ†x¹ýc`py£1,RäžÂ"ñô!,x8™FgÑæZ= ã¤z€›[j™´œ|É ôz‡‹ÁåF(G/§Ñß _×yŽ"…Ñ÷™ÈA*È™ÚÀœn Ë-H n)èÌ…µ¤F§^Œ©U)Ì<¬r¡œíÃz)ù/¬ìŠeÙ f­Hèa†cØåÉ 4ƒÞ¢~E˜ _X^dq^kHdš ƒ;T¡õK…Hʽ *¨i4ýœÇakòg³Âi†“ŽðõË Þ$ÔiWYíGóÚL¿ˆøí$‚[©p¿H6Šå’C.rm6~ÓàÌWúm~¢aàk.šU䋩̘ ªþVk3”5h3öÝ"àm)³°ÒW‰‘à+oî`t±ËÃje9­ö›ñpLN`6«V=ZŸŽÇÑ^kîñÎÿX%ïñ‹2ñþßby2œE“1n•X@'³3zñbÑù³ó/g¬%“endstream endobj 5489 0 obj<>/XObject<<>>>>>>endobj 5490 0 obj<>stream x¥VmOãFþί!ª†˜Äáíz-ÒõNH¨¥%'>\Nhc¯“=l¯»»&¤ÿ½Ï¬í¤ykU‚¿ÌÎ<ûÌì<óÇNŸzøôipÂÿQ¶óóp§ôðpñe&txù†ú! ØžœÑ0öï{4ŒZƒ£àMÒÅS!òXåt3wS“•‘#•;MY™:U¤’„™”™ÌÝ~Ý9¼<¢>¼°ßnxÁsë¶, m%¹©p4×%ME §‘NS¸Sì8¡÷””¹¿³4SnºôK¶Œpk±^R‚EzT?Tázt 8^ÈÃ`0À]ÜD˜ê‘¿Â¨CÑTj·qó8Ú» ¶ëW‚““S^}•ûX…‘J—–ä“ȰÕ@»y!3QÐ xfF9'a«©Ö.yJ•u àfÅJë(V!´Nœðþê½Ö„p€±¤Òʘ×`£œº¸•5©œŠû:1ççç1Gú¼ Šv;»caðm ‘á§¿ûe´¿ mw)Š¡œLÁðδy°Rî{& #\³‡™01·…ŒT2÷„6¥‚Ô—¹Ã†5%êÉûan}IuF Õ‘Èyû±LT.ã`…OPäÚÑ£4sŠU’¨µÙír¥é<£ÜQ|(Yñ ɦj2u”iXªHpùm½5á¯Sù] ‹l´O/ÖýÕ@ÆÁˆ[D‡mz?•Ñ©„8ã` õÒ>\3ÃÛQëf~—÷Þ~ÔÚSyQºÑ>­;%>–¤|as…Ô±ˆöúôªÄ»¹UÊ¥—-¶!lGM‘"JÆåZXÔ?èöÛtÒ˜0’M/‰6Ì\õÞ’¢¿[Q°ýZõ•¶^"ý(Ý•“Y¶£¶ž+ŽnAKhXÒ kLò{ágõÅ©W¼³ÕÅ‚è-q·G–):Úf8ÌÍü˜û[é–¾/ž¢û!Z^hÓÙõ ÏJd=Ò¹*'ëw`w·#JŒäÌ…/½7Ò•&§_>]_o&„èyƒŽÍ' 9½uÏôÂf¿½Q>—U}oÝÙ+¨Wñ5wèÓ8B˓Ǵ aü§ãWQ¹,aÚdÕ‡[jÙZ¼›¢ésó¯Ä±QÂÎÕ!) \7V.î–Ï»‘‰42dLã9ØyF‰1ºf£sœ«ÃKˆ¸Rœ¼êA£¬-ÂùZ· ×lXMª˜¬V‘Ž%,¤Ã*ÚÝ7M©’;QFÀâ$0¥%Ðz…aðž* ^™š^z™¿cÕfc1ÖÜpk¥„÷"Ô“ò 6¡èÚ”ê|" å2’Ö 4p– ö‚b°äpÏ,Îм#ô§9Yé@åÊÆ›Ýt Öj!½¯/$ò[úØŒPUy7ÓƒŸŸôÉryÔ,x‰©«½¸—¦wHX–a.BBPgÈêLbH“‰™'ÁÏSu¦21g‘¬B OX±ˆCF€ƒÜ@Iëd×Xüj®P±¿š¤V3Æ¿f ¢ö»ïA,hÖ ‡¹©òŽ)’ÜL75ºt}âǸ×…eŒg‘Q+Ö% Ñ¡új¼¸j³‹•;tÆÚqôAÕó”?ŽÖ•IBxÞ”ÌB,¹}{ß #-æˆþz7d“ʈŲ2 ·Õ$Wl¬š<ûÛÃ˳ú”÷ÏŽ‚ãÁ1œ‚~5ÃÞÞ]}ì†Aà#?aûa…!£à*ëîi¥óÿgd?îƒó:ëñiý_ w~ÛùqÑ endstream endobj 5491 0 obj<>/XObject<<>>>>>>endobj 5492 0 obj<>stream xWmsÓFþž_±Ì@q2¶b[¶Ú 3@ÍL ´¸åCÝÉœ¥s| ÝÝ)Ž ü÷>{'ÉQÎËØº½}}öÙõ§½õñ3 x¿I¾÷|º×úxØü+.éðlDƒ>M<Á›ÔŸãMÒyFn³’¹XQ"4Í%•V¦ä -…N3In©,ެ$aia²Ì¬-ý¼?ý°wxÖ§ã(fµÃ>õ†Ã(Žñ)í<ÊMZâª)(.Y”Ùlçð¦¬ÐÉ,³ôîýù+6å )Á|jÊ9.ԎÖÊ-I‹\Òã7¥û[d¥| O*¥”WŠ»°¶*]±HDô^>Î2«•Ôg)÷†IY¬¾¶Ì`e©’%ÝV ?/KQídH ²#è7e™ù™8šo| Q+ÆGUBgD¯fûM\uô¹e‹ðz»yt˜.˜!ÿ‹Ù3tѳÌwqV˜üÔglÖ9x8˜íÍ:³Îƒ‡!P¸òå žTé„•]¼6ZÎöq¶ë{Ö“Ù5ð•dlÜ}Ó[ðv3-W™¼x±”ÉÇÆö=o¥cˆ+ví³,¿¶NÖæ^Ëõ¬sgR NypìtçNæ³ÃUºn¿k†w%“ï}Ý©?5±/KPw¿á£&fƒß²g¾ýÍÈßÉO¥Ô rmt"ܬ™ø[ºQúÓ—/þ|yÆr?"t§¦vFêO¡ÝZÌ®R[u¶èÖ½0oÞÔ]±û¤rjË_L#½8Ž&“#îü)Z¹¦¯µ)>Ú$Ñ™*¬ë¢eF¡s‘â‚!+%œBohUÈ+eJ[S¼FÛˆÎdщÊñ=W€p Ô9†3.^Ñr]cbÈ>Ýä!¾›øRH-\ å"zB*ÖÊÊ®§¦Š… \ÈÊ”6E.²lƒ(Lá…¬ÈÙì¢Ô‰SF{¶b ÄÞ iží³/Û|u¼ÞâÏ- )¿é«íõr)´Ò—3g6ÆÖ dœCâ^HYx©à¾mXpÄixfi](ç¤16ªòü)’D®¢÷•SºapÛ¥L@Э †;µ2H¿,P Sa(T ~òpªô R£³M+Ðf¨™,mM 6äJ.Å•$m¨JÁ¢ÌPíÆ›Ù>`¤I¤©âÜ‹¬A]54«PCµäµ/Õw†d3%”îê2÷ÖìIÿŽiÑtHju'M?€~âã6CúnÜ¢áV÷<ß 9e¢Îï BÅnÄÏ8V—À¤L#úÕ¬å•,ºd¨Æ# Î>YÇ@YbU@•0.­D ÑoüFjýnh.ÐŽE#ËØ™uçU |ñY“ Ì@Ó¼P‚w…€÷¦ 8áQ½òt"z¿”ºgë` 19ÛBƒ·ê±nºmÃ!¬2‘øÞoùë×¢¶+ó¢â‘[ g˜h³nö«í.u?Jž>} •'‰ŽºãÐà Á°úðùª`šµ{~%šuú]F£q—Æ0Õ:äK×ÝM÷¿û‡4>¡hmá¸Þp\3o<ŠžD#ú ×ëíÆ-ÁIžVæIËü…n,ÄÆ¯k[ò68Âe°Ä¹Ø€šLab¡¹Ðùt4Nå(S*­*|µ¡w%¬m)'ÐÀ;gn@^k,‚˜:«füÎÊ*¯A-š®ŒJ³©*°ßÁ›¦÷Ä?£1ŽxÚã…=[5btqS„”ÕÈóí6¼1¬x’ •Š4†VwØÂ}?¶fÇWÈ ð1Â&ýºìÓí³P—d¸º€í†ªtÃ7_=¦¹‹|¼ô9[=~T…aÞÆ~ü¸FƒãQ4ŽÇ49žDGá;¯ú½aÔ§S“øÍÞך¯!KAºw0í¡Ó_ Œ¢:-¨|=jªçÛãþ$Їø^0üèåtï½ÿ¦ñ®endstream endobj 5493 0 obj<>/XObject<<>>>>>>endobj 5494 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`¿Ð>nÐPwPù¹ò7H4§?endstream endobj 5495 0 obj<>/XObject<<>>>>>>endobj 5496 0 obj<>stream x¥WýoÓHý½Å€ JÛÄä£_× MQ%hs4w€HemìM³Å±wÝ4wºÿýÞìÚ v“ é ”ÖÞyïÍÛÉ­µñ·C½Cþ f[ï†[m¯‡ËoÙ-½:oӱףᄺm:|ÝñhÚUm ²‹~–ù×Ò\›LÅ·£<þp‘J¼H²æóþC*ƒw$H˹Œù|´ófgx·Õ¦VÁÂ"X&MžÅÔ®¿û·¶VMˆºß!²ÿAÆ·f:j¨8ÍÍh‡žVKüôOmg¼!á¿D”—_YÚ04Sz&L0ýŸ9O’ I+:i¿!E¿ÛØøioocž®<ÚMèY—Iù凉0rVÔÛTë¡´=,ΣDÿt*ƒï£F2ÚÙpšÆÿrÖ?ýÔ?· ëX¶ ¾u„S2¡ §¢7Àˆð›Øç“ë àg©É¾© Ž«ò­>Kòq$7æ?XøOTX?£È§SE¢ºêEù+š2~a û™H™ ÚtèÛÛ˯7£Fñ¸K¿mwüPÍÚ7ëèpÔI|/3ã‡"ËÄbÔØ¶ònòîf±{#›Eæ—~øPM~’Û@øÒfÕ¾©.·Å½:M.A E¶º…4zûÞkÌh*â0B›sϽ:ß'nì œ¦ÕÝ÷öœ« Z%±ˆ¢E“”AgÝN %Å2Z‹lA&¡¢pJ‹¸÷Ü™šÌTœq/±AƤM’ÉrÍÆb¦’®?_¼'†?l•;3™fRËØƒc½Ò PKظV°!Þ˜Iø§%ÐÍÅB“Ši>UÁ´ÌAS bNtQ†M{ê$‰¢dns˜'4Éc8]k2×Hi1‘Ñ‚R™Áfئt%W0#ó›Ãî¼ÂŽ“À¶>ÿÔ‰b`²•ÿÁ ÆwMºOTH»»hŠ&鹺õ _Å“„v ã“HÜêÑN•!Kª%¨ˆŽìá7fšÄ„ÈpXª¦ÕÀÓjˆ—)è´ÄË£!öyd¸ó™ŸU•¤4¥‘€’JìÛ’²( „Á p];…ÕõêKÌ¢¶‚OüŒïG{© ¥2•BFÐR–¸y䣈°5AKj­æ%I¾é(`“µ÷\RÂÒ"¡ùîÓŒÁª~. gƨŒ•™+-[‰-n™&Ö—‚ä¨èh6ÊC>ÂåT ¥Áâ÷W—Ãþ'¿ÿå´?^\]ÖGƒ>¹ñìâúês}—ãr¢2íôC3ñݶ£¬[JŸ2zí"™r7¾XŒ&OKàZA’CÅëØÀ…›Ç2ÓS•2tæ„èÑ';!hØ ‚ê<`ߨäÁ5¶:üÖ’b›žg×QÖÁœÊñv-x—r^ÙÕønÔpÝôd3!Å'Z)“Ð1wR,çe7•"/‹©‘øXá¥JÊ+wlÖ‰\«}VØÒ×*"D«¹^Ë*”¼›yk‚€GÂAõuyq³9FmP‡Š›YÃK¥íôHœ˜ =Mò 9Uéæs‹Š-}?‘ömU DVjNÃj~ä .Î[Ñ›V4Ľ§`éKZë{~C^y7ª ÎÞ™aôc ‹q’_ÛLÄ·Ü*3{& \75þÞâÄн<ôþ˜EüÿボYØ¡¹ä¾°€<á+§{{•DT ·QFàγp‡æ©‰ì<Á}PcÎ]e¶E×!Ä*ÌunÛSØŽcƒÖäî>½¼´VZÝ®×ëáÃCذçMªc…pl×þtŸ†äâ*ÃlôrÒ´ô ¿ú~ê#˜ûý±×añÉ :ßµ$iñ¹bÍ,äfµ• « âf¢u¾°&Ÿv1€¯f7'õÊ9éò±t`0ܵkÙésÆæÕ|Sª™iB \ ™vëól¸¼ÚjD;mÈ1K#ù4oµIÖÒXûº²ìHûËD:Ž‹)õ¸ðøÎñ¾wÐ; Ãã¶wäDÈgµº^›Î’ Ÿ•!ƒªÜêÖ‘ f‡Úú(Ò”ïÙò+nëóÅ­K´½^÷4~pÔãXýáÖ[ÿT¢¥tendstream endobj 5497 0 obj<>/XObject<<>>>>>>endobj 5498 0 obj<>stream x•X]oÛ8}ϯ ‚v× l5q7ÝE¦mRè¤ÙÖƒéƒ-Q6‰ÔTïbÿûž{IÉVÚÙÝéK¼çž{îe?8'ø}*Îfô'¯ÞÌN²|ÙÿãVâÅõ¹8=óïÎ^áCÁÏñ!ݔ¨\y/Ýv,ÂZ‰BùÜé&X'Jü•f+¶Q"—F,•°Ë µQ…h½6+>q4ÿvðâq°Ñ³…ÅhqŸvŒD-sg…6B²ÝZ6™¸†#õ(ë¦Rë¬]fgòôDL¦Óìì ?£ç Ž,FÚ,ŽpΊcñ/:‚×È1Ò¥€ÛÑç_oÞ}k̓rá.¸Åè™6MƋуՅ8>Æñ¿<;‹A¸lpq4“âÏýb×wonçWŸ¾^}y{u7¿ùx»8‚ÇׯfĤX§B댸ýåÇ¿ÿ;‚Ñ7a0βÙì%eúSÖ¶]­¹Õ&('ÖÒU¦lM´5^H§Dãt-®¶@>(S €TÝZÝ´• t¢²›I¥T%’1?KÖOL•m3r³]°S Ç–ân‹ˆ œÙÇ­È+é½ò™øÜ¨\—:—8‘ÝcËwuúž1]U„‘Ó´éR-­™ŸvùMå0È€ü‘0—oÏIXk?„r$d€ÁeT6ÈâÄ, MÈý8Ö[µ¹‹X\~ûÁ©Qdl T9g±RF98ö4h%\.…lš o/+µ8â€^\¿§çÙylÛÉô’>£³ó 4gsèQ³k%Áõ$;ê™óìò’NüÂ}Zt'<µ^ªSn %´G[ç¶&kµU@ øA×uAš°û*X[EB¥¨6‰†Ï‘b,@÷C^Èâ6ä ÚQÒËõX ŽTašR‰R“%øgmk…÷©rÖyld”X:»ñ ßP mÚÚ„óA7{ÉM¾'èÍ»+°ñ½~P1è„´gˆƒ+OH(Q˜Zn¡‰¥l«0[Û:(ygVëj¢5Nám­bR•Žì(HÝÎ]rØõåW#kµK·ò‹£Ã§ôD•8Ž>?¤—ÔN ±Yë|Må3êä·W%ǃ” S²ê›—R –¥¼Ö«u°Â>ŒεÿïZ¼zë)ˆ‹x“Æ´:Ôô2c_“²ÅéŽÅR:þqqÄR·›MOÄmŽ"”‰Üi&-!Z röhx"H ¶ „’~ËŠ† èa¢Rì&—®¶E ŒÆ}Ü‘ET7[PåÁê_@ožx "•åZj[²Ký`[…ÞgŽˆÞÞ+'kn,õØ(ȗɹ öXT·¨¡G§UÊíúL¡a=™ÎúžÏNÅÏü.­!ebϳH¤ö1Ñ)Pȇ¿T+m µ_lɧz™5Û¡ñ‘(u…VP¤[¹€iãѧŠÚR;¢(H–”1(+4‰BX í¶ªfŠö4ÜÄba~P{ú¶!5¢‘bmÁ€ÀS Õ² sáǹ7ùÑå±À˜ÞÜűÀÝÎÆó;›ŠçIÛ£CÚ@(P$žì¶½½†þ ]\U-…LÚ¶´ w¡Ýz=‰xؘ8·YÛÒ@Û8,qza¯cVò:ÄÒ bÅÆXï±ß­ü¡Àn“Ì<Â&÷j»±®èúì§>Gö´RÜ=EËh¥‰¶ÐŽ“)ëÑÄ`BÍ ý ‹cª?Ä3œ²x+R´¨f6í:Íè|9ˆÊÐÙý“XbA ’e˜¢Ð%vQLóD…N¦."E%iuA[.͇­+kï‰wIAc©ú;Ï &å=ÀÎØ@ü£EüƒÌ€áÁ „ì/Ó4ÙG„çåÕUaå¹jBוSÖý70„mC†ÉQXd|oìfßÚÙïl%Ñn¬÷:…µcÔN¸§ 2$…ÒŒ¯q~í‹Òy0Ë)ô]›r‰Öò0‰bØUä§„Q ’š8ÒhIíFHG˜ñ^íé9dxXeª W‚t¹åÅ3~ßáâ9/N\ô s HC7èêŒ¤Ž¢Wû;Å›Rç¸ÃŠòÝ-ߣ¨íX¤•{Úý¿;}rð;Q‘ å‡#Žô¦ˆ£…Yg5æ¿ì”—Op<‡Š;¤“wii]#fûv9Iû­g¬^\_&sÓ“óìâìBÌ^β¾Þ­&ӌ‹ùÃä‰/O^Æq†Ùó*›‰t{íÿ§€Þ½8™egS¬œ˜p/Ïé««ùÁ?þr½â#endstream endobj 5499 0 obj<>/XObject<<>>>>>>endobj 5500 0 obj<>stream x½WÛnÛF}×W ˆ¥‰ÖÅ–íCÒ8`.¢ /й”XS\uwiYß3K.eÊ–M,C ÷2;sæÌ™Õ? ñÑdÊÿñºóvÖFC 6_zI§×oh4¤YеÓ7xHÜ<âpr†Ñ8ÑI*…-µœ‡(­JTô)ónwöwçôú¬±1ŸÁFøu% Êå½Ìye†J#²<Œ/²»4¤R÷²Z¬¥•ÚÐ6ËóÊä´6R¡lû”’²"ÎË6³Êbí«³bѵÒ$Äz“Ë>-³{wpfØÒ£1{™–El3UÐF+«Ø§«ê¤!]FeŒµãq4™à- Ãð«·Ë† ¥ròÆÿ*Ü<Ì K}xkiׇwªG©R¿}úrsÓ§·B÷h!´{wµ=ªçÅ$šN/ØúŒA¼ÝÙU")Ïî€è 3| ÎRR +“—ãIdzèfOè¥éS¯w·å§y×Y`Ä\d„¿ bC\ˆÉ…£ Àí"ÁÓ¼Kƒß‰ÑÀžBl'Š¢ mÏÀƒ8=ýÆGè7ú>úž¡_Ã¸Šˆ•{ÆíYè‰í(ç(|„n I’1›ú$ðb­\o,3-#«Èd c–î˜ó GC&1KÈ”ñ Óû,öÝ¡FÖJc\ÆÙàÚ©SotD· Œ’ºOZ¦RË"–8=/ #EªØ-×êžK¥ª7aŒŠ3¦‡ +ZqìWÕ':?ça…¤ŒH)<Á©ð½mðú6à¸]•†ÌJm™ªZËØæ»y7¢™c«Òw <­•ÀfkÐG!J½Í± w§ï^¿®ÜôYiÊDç”DôYòIÀP>X`UÕt àÁjU‰B@µŒª˜ÛJq©p‹š5†3µS¥æªrBò¡Öéå„Ähöy_Ñ Y°AÔ%|@2§]yM)]­jiÊœå³Ú.èŸS¾O¤éQ)C™þçrž)çññr¾©É8“/ãEßëÐ^À äÝHdÏ÷žˆÚ¥‰¼’ù†”—kYXá:ª¤MG)PŠM R5Äûb)Ë¢)匴“ÍåßÎ/«¤AÕÇÐÄT«µÛÄÊ8íY‹ mW±Øº¦à¢eYƒ\Àú#‘ÒÚXÉû ý€—Õ ÃÕ)"M¬³¦¤Ðy³“5‹GMnŠa ôá-2†ñe¥~ª´›Òº}¢Ø1wm—¹8ðv¸W7·#ç;|zÝhºS„jÌÃî‹áe"?Iâên_’N¸ "Ü)gÜÜ©¼9æÒ<ôÒEãå|¡  9N¿,AÏ( únû†ñcï`•± d®0vÏ^ÿËë9ºÿ„¢nŽ\<û˜=·µh—ýéõe}3]žEç“sš^ýúó×ãhH<_¶ˆê­V.ª›¦¿ý}ëÇÇùpMÆøõí:¿8g[ïg?;ÿ§öÜ`endstream endobj 5501 0 obj<>/XObject<<>>>>>>endobj 5502 0 obj<>stream x¥WÛnÛF}÷W • ‰ÖͲã"}Z'ŠÆEdäE@±"—ÒÆ$W%—’ø÷=³JTì䡾JÜÝÙ™3gÎŒþ½ÓßcšÎù'Î/Þ/.FÑÛ?åš®FtMi‘ÒdDó·ãh>¿¥Ebwh÷É¥ZßÓƒÖtu¹øv1¢áËI»¼å=½e» s~¹×ëñ‘뇷ÄgRbm8™ú«úÓY4E“hFoR)L]Êe¿'j£÷Ô›ö–—ÎÀÌàã36ÿ§ÜÉŒwP)«:3©‚ÌFRZ±Qº m©6ÍV’¨h+KÊÜ‘qVµ!‘Ušb]¡ŠÊž¬D޽I¢ø¸È(S…$œ©s‰ÖlªK’"Þ,&ìÍV”8lpI÷®I/¢§JkÒ5+3…=ò òm†»Ö¸{`ï^ËB–ÂÈ.%’ö*Ëh%ï]ð§‰N&ÑtŠ´%ýD¦m´ÿ¸Ù¿åºÐÕÕóž_-/­…NÊ|N:ÏfÞŠ* ÔP3°™Þý¥ 9°‰FÆí»å% £•Ö™ã˜ùÇHõ½L«Ã=›¶„á¥æõ¥ÿÍÄNÔQ9|ÂΛWØ ^T¦Dr_g郑2€f–H8~ÊeEûtte¶ç`VÌûèH_änp„Èų¤BS%‹ D=6fãȾsYd„½:Ûš€°e©½T×D.¶¤¸fv:ÛÉ$¢/šTJ®i­vð´K·™Š•¡Èjw×WpÌ,GÆ‘Óqu%©®Àfå6±­#ìì¸óZè.äÄkKåÇ…ð²x|æQW¶˜—}GÕe´n–—H,ÿܲ<Üi•œ®.û`ê}~Z<>-lU„7ËK{ÒÊòvÓ•·é)}~Â(! ûSÑÊmõ! î°©(‘U\ª+½C]ræbdÍÊš0 …$6 ÜJ™R”?²5œ^#†M Ð rã¥Ä¯L)»yÚ+³±NôŽÞ“OD_“¡·‡†rÔ6pëÈeKv¦=™¬t¬¬àYóq†'Ò¤ˆ|(êF'UÈŽå0—®Í¶6}J™§ÊÈa—R$ m ¿Œ‚ë!’Ö0^Å:_A×T”êÄ©"á8´p @Zà YÚÛð¢ãÌñ(,£€ •(ˆõØöqr³óQÄf£ªû“:½À.öFŽÐµ=5´Ä³žú™½Ý« œàƒËŒŒX©L™`±Áï\ᨺÁIŸ9ïÁ-A9¯Ú@[(@¶–,ȹfÙÛ -è «»­·A‡g\¡î¢‘Iìœ0R÷(âg±––×X›Ì¢»;®×qµ—›>ЦíQ÷4œì“FQ shõ/œyã}~&Q¥ÄœÁR™ez_ÙàÕVÆ*m ðPÄ ÎîZÆU·|‘ø.Hv LÎÒiÕ³‰ÁPèÊqf;I‘wr"|×ÛXäeÜuüŒ,!•Ðê´ÎŽ])\æq‹T×JŸRåŠülã•ouiûú15}TÛ EUh¦æyN^¶Ñ{V¬T€aôåë§®B$0Št×Á(×ß .!©*v‹ùe±dÄýFž¬Pößꪓžv*DÄö†Sbe±’<Úy–J[“¾ííuñ‹¡½.Ÿ#ú¨÷2áŽ5Óñ¢õÀ1DÙ!|P]=/9ŠV–Α}™†žºðÙžqvˆ< 0 '(”L$Ý"Ùq3¸Âx Ú”ò Ë&\=Ó6Ðu%`ÎÊ8ò†ÿ@ EE—&Ž< m Ö:¢MTšb0 iõXtœÑûÂóþÎÏÿ“Ñ,º™ÞÐüî6šÛbgr 'ш~?ÓÙ ¸î6oÝ'–ðq£Ó‘}«à?ÈÝŒæÑt‚ÏPÐ’›Û9Ûúcqñ÷Å\ÈŸendstream endobj 5503 0 obj<>/XObject<<>>>>/Annots 2831 0 R>>endobj 5504 0 obj<>stream xWaoÛ6ýž_qPT bÅ–;íÖ V†![ ô‹€–h›$j¤Gÿ~ï(J±l·k‹N$Qä»wïÞÿ=Ñ?#Oø7ÎN†áwøcÄÿ|<Ý\‡C§á˜2ІQù«”>Ÿì^ãitNwžÞÍw6t»š5]ÎÞÐè*¼¢ù gO°ý„æ‰;tHó8_…£ˆîër£sÓçª(´)Ïæ_O.gW4Â~o€£nnðbðù˧¤,‰e*©Ôd›ºÂaHó¤­E! Å:‘´–¹4¢” -kr;Ä"§¥ÄÓ¬P)îoU¹¡¥Æ‡‡…Ϥ y¿YeÊ4 P82mäoWkU¾&¬ 6Øt°ƒAQû‘|b&ò„R•KÒE©6Â`P}Ð’Õ™l!É2V+ÓJв2Ò’£ °‡qX)fª·àiieÌÇYZ!°D–B¥–ôŠ‘[Ùm¹8küX<|‘ZM‰²œK±Ê™YQ*ÎR–Ïm3}Dñ¦WØã”Ù÷H ýkT•ȶ‘N Õ–Ñc®·ù Ôƒ¥,~”ù •wÞò>¨¨‹7úKgµ“Ã}úóÃ9•u!3QX$\Æ¢[÷õ ºyxoùm})qJb4T—ÐÎ!ìåltãU1˜†\‡8oM¦>âVéüÌ aÐI§õG…12ÓO€Âbóò`™ºz¨œbÝn‹`qÆäåšR¯Q1¾¢dòSÈÑMø¦e’±¯t Ýñ‘œ¶i‡¹ärû’r#J· ®Œ‘y™Ö/ç·ÅêqÀGPy°‡4ÖÂfUî„Ps]Bt:ïsÔøG+–VT©WöV¥)ÉÜyÍêð”jH_6H>t‘4î²ãOmeRaôsM™„Ñ%¨¾•ÊUS©z”^е”e4/gCº#èˆcˆÂñWI@¼Ö\áé ²†ÞÒ©ÊËÓwC$tpK§OZ%§¸†žÀVd·Ù8œ@~Øì=Ê÷‚ä"P+g„º*;[sn ‡øqÖ.œÂ =¹¢´%Së*…ïòÏÇÉñýPwë%`R-d¦K n7i8Štë0®Dš.EüÈÞ܈©sõsaÖ¶/°€[ÅÞ²&1Ç_¸šÜ[~~þ¸=¶q&jÆ‹»Öà EH÷ýc»ªÀt­+¯ÖÄåàQÖ[m`f]e(.6vH³‹ ÿ'•뢈öUpó W/çß"=Ÿ0;§’Vê‰×º3o§=W€¬µxj:RY±F„K í­ËןQ0R÷îi<NûÛ‰#ø¾_DtW­V` Å"ÍJÄ.ªýaÙ…_ˆÊ-u¬Ñ,·ÜiŒ|R\é»ßàáZ(´XüF¡"<6¼¶ƒìŽ,Ë=Ö5^4¿¸Çv&b£±/8óhðv ?pu³g¨šmÅ-6*ÞPV¡A¢þПӊ‹A@!`:羆Lg!ÝÕ¸ðCÍ ´?(Ìø)%éÁëRè,'´ó™ˆcYÀâóºízùƒN‚óËçB[°º*UºwöY9|Y‘bú:bKkY>`îØp[ÛãàEfEUZ÷2¯$[rÐîf†Æi0×i IsRx£-£ï{Û.n #Fѹ]œýÖ‡³gÂsn \¿<Ðm*Á`«8è#g]ýÒ[=nüÁp <àA¬ó›(œ ¨ø¦œ4r–u)…1â`º`-ö2 Ó`cä)½9 ûŠûF·zåÕF¿¿èó¶ÝÓMB¯ÚYåTðÐ$exúJã dt¯üÍïá› ¢ÇÔ "ýXb¾$ðuó­!Ù÷ò6ýò0ïû™ký¨%NmEý}‰ÜÞÞRAï +Oú"¡«õ(á5í±‹ 8ò´€lËÃG;›.__δ¾¼ær±x_ï×Ä¡ÉûÌ/xŒó&«2•Bñ®–PÚl0 kÔâ&·å9kçähx^¯i2…±w_ýäü‡Ž]?ëF=ÄÑ,Lu|û[åõpŽ£f¿žºòa~ò÷Éåò‡Èendstream endobj 5505 0 obj<>/XObject<<>>>>>>endobj 5506 0 obj<>stream xµWÛnÛF}×WL’ ‰ÖÝN› ˆÑ¨5"-" /Œ%¹”6%w™å²2ÓŸïÌ./"%Ùi€Â†-“sŸ3gÆŸ{ã×fKú’Þý¦7öÆø°þ¡wp³^Àd ›e—¯ñChßã‡`p•~E\?&¹a~Ì}!™.¶ƒ”éd™øÂéãöúzó©w³ž—¦¦cMçhk°ÙsHX L‚Ï!ÏxFÁŽK®™áÀÀ)OX ‡½ö(føÐ9ê)ÿ ©1H•†kHµú[„hÌ/ÀyÇdm"6ºv@´¢2ELo0¾É”âcz—'\šçÌÕivlz°VøKÒ˜ÿPÅpçͨš¶So6ÿÂg*왆ï3£ËrãöúÇ*LjÉÀó¼ÖßXÈdªñw´œ·1„@ÉÌ€{)03´ToÚ5²Áμåò–œ=Hø½0{%ŸÏiµZQ—à'ì€áLk†ÀX:(P}mà$ÔŠâCxõ+c¥ãð»WgämZÛ w^ùñûÖÊvû4÷;bäÓu£‚öhN€¬<Å5Ö_Èõ³ÖTçÌ"«ÑêP­ùç\hŽè%f¦t_8¡šàЪs2´P´(' Îô¶‰ O—1mñGb£Î߯*ýH/áÏŽ„ÁYý‹?æiÊõÿOxùýH©‹M?ç=‹¯ƒÖúÇK>\W*žë ν2û.bÍqhÛã§NËOU]Ÿºª%-~V´ÄM”‰X,é{Hš Vv©–™YðÔ h;1Ô#×uJ¤€Gza²Š¥¾‘”ÞΙ:gÅ2[³†\Míòh ð {GÕ¨[(ÕégGcÚl“NÚ´Ôº±6¤›Ùåñ`ãÈD"b¤y£ÚnêV4‰¶m'„!.Û&bж©£ s _U|BiÕ#Jªé˜#°Ìƒ·¸‚ÉA!R\ãú ÏÍpäCˆr¡$d{•Ç!H…Œ BGTö5Ý­èç¥SâÅ–2ºœµšX;u:ÓYºmº\ܪ?ç'‘æ+Ôª\¹["œÅËåDzc7 •ëÿTÚ×@§L„ »5]ҟͽ ÞðÖÇ8^N>Ë81Ë2ž¹‚TF:sÏŽÛ}Bqâ*ìV -˜x¢­ëX+ÏHþ $Gi1ë**Is±TjásØs‰4ã³|üóá3¤²'$'4‚äâãæ=5†¡¾¶©Ô=ˆ8–…wŽ sìPŒîGÄ«VÈýöÞ<­IësÎ#…7Ê¡ ë‚{>/XObject<<>>>>/Annots 2834 0 R>>endobj 5508 0 obj<>stream x•SMoÛ0 ½ûWð2ÀEkÕ²c'ÙNûhŠ -véE–åDƒ,¥–¼.‡þ÷Qv‚$Î0`°!€ùøH>¾bü(¤¹ÿyÄ$ÆP| è4'sÈf‰¡:Ÿz°¬ƒs»„æ$?{ýTœö¨íî1ÌH E I ùœ’<ŸBQõic(xøvSü î hÖ¡[”¤·ðU*¡EËœ«½Û »ÖüÞWÌZⱆ>>\²”—˜!H½­tRo nM3ŽáF)Á4Ú’eçX©ÂŒA˜®Á?R?i÷UZw‡åÐ+ÿŸÃZ¼tBsq ’Á>Vìû5ñ v{VrrU;SÖxÖ¿d%,Ð0ÞšqÞíúÆ"À(¸-sÀM§*(tVTà T¢–¢•ÖµŒ;(™‡‘Ô¦…½éZ0¯>ßÞ×ï¼O‚ˆ’„¤)Ê£ O žÃå~-Üf½ Þ?ß|¸ä8’Ì“WÂ1©,˜úoüî`§„gk…è1ZÔm¸zXAJéܧ:=e}œÁì º$ž,Í€“XÿxzŒÜ¡/†wÐŽymy(ä:xFS¯×*LqŰðñºÂúˆ,ÎIšàâ¢s6íù<Á·à ðendstream endobj 5509 0 obj<>/XObject<<>>>>/Annots 2844 0 R>>endobj 5510 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ÜŽéîãõ‰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©áTQSPƒfŸ‘ ¦Só¢4¨${²¨ØJ'‰Þ²ƒ•¶4ÒW+Ó–Tš'’KĘZýEf?±sÇxÎß•0 ?DI€0D¤WØb­£æÆêìò)òk"mQݽ6FìikDž3Ž>ï§í€Ø«ªÔÜT&¤¯±gã»]¥¹æFh- § JõRvIîd\ZôÀQÑ0)Ð/h»‘h8¹\À æáá›™H%WÇiqg¹†pR™¹ÚprÔ88L}Ö}âm °CŽÏ„!¤e§Øª5õÌÁ™ªÕÝr™ÑÅû·t÷óÍõ›úÆ'®&b:DçÍ7cÏæ‡A„­ós„kôK‘k7K~G.èýè ÂóõQƸŽP{ºv^Å’çõÁ÷†ßR‰óüÉ~Õ(0Œc±Bf…r€æÚ3*E–ÂÏg-×`^~”–…e檕kÝD-Œ0{ 6dA{]ºµ·À‘¾¯!3ÈŒ{Ùÿ©¼ (¸¨òúŸ*¶_Lg_­s]*WG¹³ŒÃMoº¡xc„n30J B€ˆ ‡kâxz‚x·sUd¨°q*B¯æ”ëÏ/œu¦þ”¤xM­5ß×1± »§áB§Òn+}pŠ.ŽCx.däeOÁeX•Iâ¹ÞÛ»ýåêÆóîY®¿:=ŒûnwŠR4´Ðÿõ'Çj"<¬çecŒìVûb@¯i¹Ç ©˜Š ø¡^¾–x.$ø¨ŽªÐ]Þ0µ¸L’®[»nå ŸW<*k­5ÃÜjJ´ÀöÞHp·{ªvù‰b,•9Òæ³ûÀf¾©˯ænŸó7æ lÿ¾“‹ÂÊûN]ÖÓ.·‰°üÊù·0š¾eþêôôþÅý‹:dÇËþñÔè3Ü9º‹x#ßK+Þ +î;ܬªž[Ç<ýH Í ¿È\»¯@å4&Ïíf²bº ðذ~˜)D­2Œ“²"Ã3ûÊPX÷ñJ¨¤z‡Ôßi°8ðUwÒ¯Þ!û5îãK_è¿óŒ§}NöÝüäÃÉ_UÓb&endstream endobj 5511 0 obj<>/XObject<<>>>>>>endobj 5512 0 obj<>stream x…UMoÛ8½ûW r©ƒÆŠ-Ä=ä°M“¢Àº®‹] ¾ÐÒØfC‘*IÅqý¾¡ä4F› IμyïÍð[oDCüŒh<“ߢê½]ö†ÙŸþø-]ÞMh4¤å±³7x(ÓÿñPô—;Lqïh£ *”¥5“qªä’´%eä|Éþ|ùµwy÷†F“lÒæäsy,ûãi6¦ž WÕÚh»%£ü–iÑ&mOþÀ0È'Ù|.?X (»ß±ŒÝñ éÐæ¸ g™*uÏÔ“´Hn“J¥¨+¦õêçåÛD{¯êš}FËÒu•’o}LCŒrQxV1%á!\¼SQe `ÓÅŽ g£Ò6$gŒÛãDÛÚæ ñ;Èól<ÆKÙ®ñ¯ú¯Þêí’f‹W«óc]Q¡/­úF‡xmª¯Œ¹^.>ß®Î/ÄõÙÓAArv Ú ¡‹:Éõm•Ò]ŸYwÖ–y.û g³Ù•Mdìµ1´eË^E!µUŠ·’,cðv«HéäQФ²ª\cÒ$k©yÉ/zŸªªÑEÒãðÑ#ph‡ô+ò‹Â•+hm££(¦Ï7—7¯_“ hk­‚.(ù@äuìSHcahso›ÆQ;«lIž ìnSÐ‚â¡æ#ÉÉ(á"WR®öîA—b×p€1ÿÐî”þVvÛ( ŒôÀ6•l)úÕ`l9j©$˜B÷Ü`P¥³g hÕ×gô½“fÓÈ–ºà°:ÏèËï%˜µÙŒ ˜À—¡HI·þÊEER]Õ†+t€b ™#{«Doþ)v¯ã.ñXH,•ã€U`BÌe&·“2ÅÈ v-¶ ¤Þ ÿl U‡ÆÀ´©8–Õ§Ûÿ>”¨…—ŸÀˆ‚mÚ…xEœó{ "N«µk"TNU>/XObject<<>>>>/Annots 2898 0 R>>endobj 5514 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<¤;t+ZèSÇù §Tõ¾­ÍË3p·«n›¤rŸá}2\Çùzìo¹NÇ㈅ù?y\ÐÅä'\8%Ÿ ÛOêë†ïÞ?´Muúc€u³Â.4¯êqÓ¯O­D±dg E/ H+¿Ž®ä÷»—þso·Ê)¯Ùý9çÑ‹nw9‡þ0Ò¯»jÀ){?ѧK¬{WÝ÷Ê+Æ~ƒƒošú0eòþ 7×7µß!ëf¨q™ûxj1ýÑ¥$÷ñÇm¿úpê±{S5üâòÅž:`X€¯º}Õè-owõ¶Úq©aéßnªÑ4Øfþû/Û÷Ö>—†Ù¯ðn:q¬Ë~wK/=_܉ã=©Ûš¿¾8WÀ×-ngÛºéeíðÔ³ÌÏf+ Óƒ¦{0¥qw«?£«ÿ6Eüq÷5ÑŠ¿ÚÔ«gЇÓúL‘ªáŠ®hëúº:´çŠvÎC¿zÑÜ5O¾7úôš÷É·Ožùo@ù›ëý#dœóU;äßÌfø×„$=ÏŠ˜¶ËÓåÅ/º¸+Óendstream endobj 5515 0 obj<>/XObject<<>>>>/Annots 2944 0 R>>endobj 5516 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‡ý¾ª[ª®ÄÃ);ôó+|?‹ðŤ<âÅ䞃/ª>½«‹M¹-wx£ÓÞà¬ò£øL'g‰WÇß„ÛvÕ ¾TtSáÝ”íZƒ×ð[žKä`m2¸8¥×åÇÏ#Lùº*óâ«5ëê°YÑ¡)„âg›–š–ß+©[j´ ¸£7ºÿ8u¶i*Äf°…‚Ê+^º¦æØ´Å¶‚‚Ë5R¶)—µìS¼[wÙ¶Ì©kÊS‰ ¶³Ù˜á]‹7ˆï’ÙÞ…[Úg´äo¼Ãj»/±Äöu•M£Kâ•ù(ɨr;å1çñÐжB $ÖݫѥÑGñ~Ò`«{D»Å šqUPàð5qS¢ºªh¦ô\ÝÁ¢G(³¦}FÛìCÔ…„Ÿ#7Ú††Öò鸆ûØ™¸õKÖt#îÿÏØÙiïÀ”Þ´ì ¤'k¼hðÚ™:Å–ä5Ð’$ìÛoqœxpŒk·ÿxø–Å‚¯ÈÁP”þºÿ²Êå]FâÎîOú‡')A]Ý]ë1ÿ•@¿Nij•ç‹“ŸüÁÄ%Oendstream endobj 5517 0 obj<>/XObject<<>>>>>>endobj 5518 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½žŽyéíìì÷³Aºendstream endobj 5519 0 obj<>/XObject<<>>>>/Annots 2949 0 R>>endobj 5520 0 obj<>stream x­W]oÛ6}ϯ¸H;ÄElù+vÓ{غ¦Ëð­ñP PÐms‘D•¤âdÃþûÎ%)Ù²†Nb‘÷óÜs®¾œi„cšÎùZœ’¾á1|üpvu=Jf4ŸÌ’4Íñ3ü•ÓŸ§ùxêŸMvð£ï{Ö¼I³¦á͈®“)-Vð;3Næó״ȼË-ÒÞK²[µ¦©—Ï$ŸDQå2Q¯œh0Æ‘ GÖiJƒ´}œ~õñç­U‚ ·ÃÚša®S‘sµ²‹!"ªùõ|«²~:eÈn„‘YëL7¿»ší7‰Õl`xsE)§8˜LcнmH»4Tå­´),)G…x¦¥¤R¦ÒZažÉiJuQ©\ÒV¹ á ³hŠ7Û¬~¹}×uÕ#]9¥K¾¾–¥4ÂIª´Uüå@•™¬$>Jã™LèvEª¤L×K×o²žpuS]Ú:wÞm!ÊZäT‰µ´„ˆéYצ‰Î(3BÙ¼fÒIS¨Rú«©6F¦Ž¬t¤W18›ÐﺦB­7ŽDn‘éF¦mŠ%þãxéÝ}ºýЉï“zph‘Ú`«çCYæsFܪä* ®@ªõ†ÆH24fÎÙNçÉ8¹¢ß¬*×!»Bgu.»Åå>^á.|hÂÃyÓ :u¥G¥(Pµ¢¶Žû›ŠJ9‘«?eÖ§eê‹Z?¢%Ü6®î)Û+)\mâiŒ+Ë…¯­¤\o¥I~ónºÓ}o3ŽP·Ç€TÈaÖæðÞù)Úa·œ;YZ.$Hp§ŠJ‡qÀtù¥V† wž<¶Sy\ïñÀ`2I¦SBÖ{A À=žô¹ xkUÚ0 b/Ñ\:.I|k[rAIº@ì‰{çiãál[ú˜W«ë¡¤ºªb-ƒ‹h%OU;Kç@±A(ÌÇø–^ü…&kéü—Ÿ‡OòÀB“uz4eQb×Ì9ê[‘:•Ê>ƒ‘ìF×y†IÙŠgK¶’©Z=“Æw½k›ßõÚkúæ“ô\ÂÓtaéä›ÓÎO°z”m…=A° Dœç$j§y¼@¨9ç&žùÊHæ†cºGK#-¼¬¬’ ïD•hðJ¤³¡Û×ôÂG²‡ŒCP¡å{¨Š 6ÌÝ-Ãc¦}f!~fHQÏAíÙ‚óìõ<ÎÚ¹'Æ£ÄÏß5;ÿ*ÍèÎqI=±¢€ÝX9ÒHDß!¶õ)qúQ’¨*£E ¹?£ã;<·øÖÈe­€&ŽÛçË[¦í€@Ïîm[š®P1ï0 dƒû•°²á6ðÒ±€«.¤SÌ;mËj´Q#·dȼF 5ñj‘1f,&,C`žT'p¤@jÈ`ºGiú>È[íítp±w•Ñ|mÀ €'þ€L!ö±£q[z– fˆØÞ¬•š“™ùãûIÕe‰fFrMa˜q_ê(ëA€›a™x¹XÀam½ˆÊ TÞª2¨Í¶)4 ûò¨óGV\Èv¤×ðÄ‚v˜Xãø6°Yº°2pf+í–€N狼«.† “˜¦® DƒaìõÎl–b o‘á›Æ½!_A„ê‹AÆÑq._…úœÞù=Ç7¼»¼ÜsÒzù?³ !¤ýîÅXN0°'Ä×/)ÑT“=Å%Ë$tí³{È#ivÓ·ÿeAå{ êÓÑfÙ9WÔ§§ÿ´¤²©ÿkIÅZ\€P¶FA_=ã ²J̲ۢÙÔ¨ «>†v!‡ýI]%³)^¾¯Æøé÷cÞ‹¼nÿ Óºû·ê‡5&œ¼~ü«Í4r¬—‹Vhwû¿ÏO'xQÅìÌ®g\®÷‹³_Ïþ¶áÿsendstream endobj 5521 0 obj<>/XObject<<>>>>>>endobj 5522 0 obj<>stream x¥XýoãDý½Å( ]*7m®w¤£¨ÒÑ4pBŠ„6ö&ñÕÞ5»ö¥á¯çͬĽè¤ØëÝ™÷Þ¼™íŸGCà¿!'üœý0=D<Üþã–trý††§Ñ)MX=9?‹&4MdÍ€¦qw<‰FôC•fIj–ôK5ßÐÕc©O­ñT™D;ú˜šÄ®=½9;¹O?\ŸÒŸó–ýÑit~Ž=»Û]ݼù‘t³•6ì|`;J=9[-WÙ†|š§™r¼¼\i*œµG^'´NËýjÒLjn­ËU–mz´±^dÇ„H†#c­LÉ[àó¤Š5)º|ÿª’beh®)³*Á–©©’¬ñK»Âiüѵu„#ÈéXc·ÏÚ<ìBéíâK*§)Ñ>vé\'­@ÔÜ~Ö4릑Žã‹ó~ Nðë¤ØšEäæm`»Ä[åìX2¤µu„† åi­³ì[AÁ¯l•%œœšgšÓŸ3§üÎQl² XÌ7­8ËMØÞ6Gã†ÙQ4ãGÒ½x;›ùuº,µ/¿'Ç*iÎè#¡§+M®tsØsïš/vVÖ8šL^ó®SÈÁé\AˆÐ#X(WÐ×q ™"?&hÇ 4ƒ%±Í‹4cÔYý¥6Ú©¼ Ý[qE–ÖOi쬷‹’~K}¥2ºøæšÔì5}ayjä´KýYg¶@H÷e•¤–n.¯z’ŽV ÇXg1#š\™„Óc3?;ŽèÆuœÒ–°]\AÞ¹Úшº´­(P†u,qx° ¥'©/!ÃJ@Ù×v¡âµÔ=‚fšš©wEh‚Ç #ŽEši&`H8Ô8›†xE4ÄzcXiálNOqø’Iq ¤{³ó•ÔŒ`ljHUQdi¬$vfï8I¶@{º¦®çÔ|¶€Ù)Š+_"¤ [ð~A?-ôkiœga³ŒLyM¾Ô…')8+ Ž“¿+´¡ªÀ F¯¥=`E½T8”ðð®(>¦)ÇlAôYÛü„_5²Ãóºüû¯§ÔÅl¥·qãwµ§½KPÛ2e)‰¹Š]-8¦ :å7Q*¿fÇ`ÚÀO«¢°®dˆ/³üÒV̹µ‚ôU¼Ýí£·êÇýŸÑ¥5¯¤unC)›É“í«=¯Ð¨(Úè²ß*ñу֬§%fÞÓ’ÏÛ£ 1“$â‚°žcþTšê}PÑs¼3K´ËÐ1½.™mO¹6U„vÉ%Ý<ì5Šä½:¡L¤gw¨®“Ô¿Vç·Nê°(:p?Á3´D)?HOg‡xôëÍÛTw¹Q_QßÒ׳îØeêfdz~ݘ¢*o!ñÙq-D^#O?¨r5;~"‰mؤqëY.ÍKwâ—\:ýŽÑƒ½y¥Ðã™ugÚ,ƒ[àqéG}ü0¬Ú9ëðÙ»Ì[R8ñæ§w¿L›"ÃŒ¸ ­­½C{»3X%|„«€L÷‹í9øF> °ŠKëRíAiÒ ë!)„(ƒt  ‘|1ºØì0Á/1 ÿÉðûÔ<"øGDz=nïC±×™ZÚt™Š\•èûì°Ê1ùKSäÑ;‚K?ˆ’,“Í ¯ü±`›¥s§Ð ¤•boÙ “ÚC+€°Š™ ÷˜»9·ô“÷õÇáPè†/õ‘ÔÉáTf<«N"ì¼C±¸êÁnLcXS+‚p.¿+\û\ óõGâ@Kú%Œ  êª=¸ÕsîÐGoš©éÖ®yêôUÎS_©Ö0¹¸Ô3\3j¨ cÔóÕ#Ýz…© ¡ì_gš èfœx¥Ì”ä_ë mAödN’ÓœöUVâŒ0Ç̵Ävð|ˆÇÕ÷Hüê«à¡Ñ Fc¹Êƒ|°¸ˆm;ÝÃ3SŒIY/¯öçHþðäz;R9ýg_O››w·iR<ö¹·¥‡Á† ŠÐñµM$Ž qáüÇßW²ò-ÇWßMÙl…ó:zuêêUçHÞ~EL3qZTF.h ò¾p „:×ÖÒwÔéᯠ¡8ñ GÙÌtÚyâØÝ=ðÊx¾os ˜é“x:.º Ó3ŸA´Ü~¹mTNÉÆSñ|hrÞA`·ìpᇗw÷'õ] ÌçEù0¸@,$;Ž!µfú N£³ñMNO£ÁP.ÚrUEŒ¨q…)®¿çÏúÍêþë@ÃúËÍÙ`GáÊqv>᯦G?ý ­ñÂ|endstream endobj 5523 0 obj<>/XObject<<>>>>>>endobj 5524 0 obj<>stream x•WßoÛ6~÷_q6DY-Å?ÇËЇ5kŠ>tÀÅ¿Ðes•H‡¤šÃþ÷Ý(GRí8C‹¢MIÞwß}÷Ýéq0†þÃtF¿Órðn1%#üáþ»†ËûŸa|•\Á"ÇÓ³ùu2ƒEÆgF°H£é,™Âb#áÏjµ‹½‰ï.ïÞ¼Ob»Uz}±ø{pyc™¬Â‹‡p#[Ö‘êÈgýXòÅî½2e)ůÜV¦*W!E-JI RºDÔ×ø˜S6áô2'’s˜ƒ“d:ÅeMLßD¹-d7vÌg§ÉlvCg1ùUÚß`]ɲX#™!È’h—A<¤øþP˜SžžÓÒy¼Tg\ì Ò™´œàº0+QìSü óK…nr¤(˜•#‹ž² ,·øDx²æ¥šÄ%@ÌåUQìâÇJÄl"0z’Åce¼tCÉ:T}/y–s{»ööÖmEyö"£¿jªM /¡”~c2ªh ¢è%ÀEG¦îÊIΠGq¼µ2Wߺq#0[îlÊš"5e)t…Ò2áþ{¾ºg“KÓ’<)¿Á7CxòI¬$àå­Ä‚eŽ‚Îr#ݬ¹/ûÒ8©þv“v ÞmØ äØåAÒÃl«ßÅFø¼ÙÛÇ:ÿuó¿êÍTYéª厵?T\DÔ«è=)ê)êÕ+ìV•ç~§~éFa‡rzŽüAæ9šGW÷¯KŒÔÛÕ³’Ò¨ÁVZS;±¨‚<¾+ïY¶5Õ‡×ñ«À=©5Ä– /¼ ­œ5eOT<½²w²/¬'ÈŒ–q“i2 Ÿ™,œtc u™a£ëx‰¨cL]žùÿ{µŒëó‡œ~ßr'Zu*‘}3z¤vÄW±ó;Zbç.Á6Ï mÙesÏX|ˆÏ'6\Lĵ¼)…]!),&e™NâôgR5מ4Bó„:§0D:˜ŒÆ}¹ËØâð]ͨ coóDnÔàÇ~¶3`†„…ˆª-7†}N¥Ø‘«V}5S©«]úA• ÷–b‡*`ë:ÇQW¹fšuù‰^PÛ~"¼ZÜh¤â W`1=(¥æ‡W.vT^—„ö8÷´Så&W7¢Ð;RQwîž©$v_Þ¹&p_i^o]ê "oaoö¬Ck…j@&pßž#kÜÁZã³;vú¦¦O߆¢¾»\ÇH•¸fÆ\Ký’ÿ¦—¿tî€=ßõ6l²Ç¦ÝgN üüC÷IŒH—ËHÃÛ·0Z^ôþÏJ_Y c†Þº~N÷~ Iêx¼¼IîOþÛÅÚK9 \GÖRK\î%5/¯Uõ½Y³jsŒî[Mä½Å<Ÿ<²²O`ñÓä¥Vu¸ûê .ê&”yNFWÉõô¿}fɈ¿]k>/XObject<<>>>>>>endobj 5526 0 obj<>stream xµVmoÛ6þî_qÈfTicYov°eñ`h¶Öè¾øÃ‰²¹P¤KRq½aÿ}GêÅ‘j§E"A‘wÇ{yî¹û0!ÀŸâ©ýM‹ÁÏËAàxØþQk/˜ù1,sž^…þtz ËÌ °L½ïá|ù÷`¼1©ûêè‰æ(DáÌ^­¼‚0±:ŸA8~üD[Ñ%S^ФØrúâ”-£Jjï8j<:fü¦²éç$5+/YŸ2%ÕÍ„Qû(šÔ±{ñÔ1%ï‰bäžSø‰&Ö•F6T›­Q”ø‰úz|ýꬹ¼'k- £Ü)²ÝÒ ~–02Æ85R@AÍFfr©Àl(2+9ƒŒ„55îø‘ð’ZM+Ó{ˆÈš4a(™WëjÔeƇš®S}áôsɹܡ ðîÏÛ_ Cæ‹BÎ0ÖŒ¦×`vø~/¤y/‘MBäÇ1â'óÆã£wÌl>±ÔxìP3¬ÂnÜìÜù¾ßù2ÁfgøoçPã6œ¶áÇe2YÚ²6õºbÃÿ:ZµãESø‘‹:nÀòFî€Kù¤ªÕÛò~Hj?c„}³ÖªÛà›´Vƒï^Cd3ÕaºUÝʼnƟkܶ&h=—Øk~|ê‘$ôŸ{'ù¢w>güPw[º¶ê·9ìe y Ø€@•Â6c¢…6¼fkQPa.œäŽqЦ”=>Ñ(¨ÖdM;]ú,dº;ù¢1•gŠMv*Øå~KolsÒ2K™TŠGª4C¢B2ʹDˆçJ ªù°­±;_¹p>ŸÌ1µµ|í€xB´ò©i®~’É!£L7ääè´‰¥bc}Õ¦kË»@Të°¢$IÁ÷­e~2†[ƒ¤'-³;¿*Ú­+§KŽÆD[톖"7–¨h± UÆQã‹^?X!E¸®%”9ù¼ÈEiìÜéEŽÍÔ ~ž…K—“Öz$÷M7DÁË-1›ž^—‡µ«NèÐ*=Š\~U”ˆ2²×6å4Ï1p(…a¼.)ýXa˘1m³•aBíPë§óx2]õÆ‹§ãjg˜ý \[4at·™ïPgåúþžh‡{&˜a„³ÐQD™-ÄÈd6³G7ËÁƒÿy3>Çendstream endobj 5527 0 obj<>/XObject<<>>>>>>endobj 5528 0 obj<>stream xÕVmoÛ6þî_qHWDIE/¶’¸/@›&CbËoÃ-Ñ1 IT(*±1ì¿ïŽ”X[‰³~y<ÞËóMàî?uÇ—œú1Lœ…~’œÀ43VLS/•e­A”>}¼†÷Go¦ßÇ—#Ñ`Gxñ(ŠÛ‹Þ5/x1ç ´„¦æ —&WLK…žàº™¯éøŽk`š,ÐμÃð™–7¼÷ï|û’ ‘Šü8Æx3ï'°§a—€'Ôüé 2££™W0QÎ&AN‚On+~ßÅaÿbÅŠ*çû»|iÕp:Ãhžs=ç¼õ9™\}Ùå6öÃQ8>³ÇgFT\ÊxÜ•6NüØÕÄnpU[Ë® d9òG”ìÞ¯»oøT­%›©¹ÐŠ©5œŸ¿yz]ñfžð¹ß~è%vƒ)^îkà«*©Ðù2žæøkF­[ËFÁÍŸ_~&Dpµ`)‡…Èùì€.£bU…–ÌGÂ,2/cšœã©®}¸‘CX ¸­óд^döœk:ÖØ9QÞ,1B”‰ièœô*jðè`r)%"ÒnRμÙA¯k݃ÔÝ©±%;kµã—½^ŠRVó!dCHZJxíîÁí6yPp½”(®UÖÀJ,e­Y‰•” û‰•-YŽ©Þñ’hƒ5œÁ>ÔOҥƻlç˜ÒØòI¤›l³ø~õŽ:>™Lÿºº¸­n±J“`5 ¢y˜ŒG¶ó£hœ|lI†:d¤Âûå÷¯_·í½¤€ådù#[×XšJ¡$ À2 ¥À~›ôíMç¬yß—ÅX+›J††? Ü S,>ßÍ K‘ÚbX[ÈÞhÉÔ£ÐK`iÊëQa›ëxµ‡Õ%ªîa_3ØC ™/d [L-§üìSx¤9‚£ÜƒW ìZë ¼ÌÖþä>ûwçÙ(#@&›yÎa5„õ69þyYé1·zƒñÈÞ^ƒì{ý·u3muðïŠ×s³êyößY½ÿ/‹uÏÀ´£÷̺ïŇ©™L]X)RuÎi¨eFPMÏÛÎ!šÈë—Q¼…’…E «±áy._fïÿj¤-6UĶÚ/ùcWÕv« Šœ½zç$Ç[ æQrj4ÄYnkXüÜ8]ø+|= v=ÖJ×£.wy qe²g›ÃÖ©Ü(ÈVHÇ*%p e†åMICÊ Ž˜^!ÙD  -ÝIh$fðÚm=V41‰ÈŒu³!mÇAÓÄ(†ß±h$Kq–ÑÄôá3 àΔpÌòZ˜Q†R güpã4m)Ü®&­€¿EÑh†zÑ$ÃÝ)Õâa›¸_””ÛÎVJ<à`ë{)ØÚÅFD›-ìv…’9šâ}ó}SU€ï™l‹Ðf«·p|×]]í)â 7é;X²‚÷ݼn Õÿ½J§²§í OGþ8Cr‚¡]uiüE~ŸeÚ8ÍâC‘àòm­N,ÍÌŒÁ9mí¸M›7pqŒp—Ä8>5æÅtðÛà_ Çf6endstream endobj 5529 0 obj<>/XObject<<>>>>/Annots 2951 0 R>>endobj 5530 0 obj<>stream x•W]oÛ6}÷¯¸èà8¶"&ÙÐí¶ú²&@æ! %ÚÖ&‘šHÅ1†í·ï\R²,5MÄ6,“¼<÷Üs™¿Šð7¡Ù’_q>ˆÂ¿ðÇ„?¾|Ì£i¸ EtF”Ó|…×õSF·ƒÓgŒÎgáütôä£Wópz2úáîd;·g¹¥‹›9M"ºÛ×ò__âàëN*:»ûspq|nRïDICÿc³2 \ækYÒdlYŶ*% ¼÷¥( ™ŒÈî$ÅZY©¬q#˜*— YMkIÉA‰Rj¨¬0”ÚƒÞãaŸŸwƒ¤ ›jµ: É1Ç ·\xŠ8¬‘Ö³¡³¤edŸfxà˜G˜¥Ì¤0 A(¼ ùЃÈ*ðXJ¦'¤O€CL¼9o¹–;ñ"•ƒ®h/6sß8>F$ó]‡ì¡¹(ˆÙ0q™®±“ÙéÒf$Q#™Î™°÷e)Ç2s]•.¹‡¦À$@˜ÉX«ìÒ ÈG‘™äd/Ö‰ü±añ*œ±æ¦Hu: g3<%' K5ýÓðÀŠ ˆReéñ÷EôÇOÝc«á± 8 —ËK^W”:©b ¹ë(CÒ1 °m*sµ(Kÿ%ø<60²ûÇû­´«€AÌ6«³oÀ–êW¨s¶¿{|bÔ³)× RAíÑ--û'ÕTÒw©Š‚»†Þx‘¥êͱ¶meSåäáøëºl 0ÒÓFjY˜îÌÆ0‚ރЦ ®L!ãTdC¬#ß>‰í[©d ¡ºÚó9IÆ9ï×o]¶Þ¢-m™rßï¹g™#¦ÇjvúR­Üjµ*ЉÐ;4^Æýg¨Ð<®+m1¢×ê9 ›þb_M/dî÷XwÂxm¿Xx›Wiª©ªÖW?̨ŠwœÞËàD÷ß n¸þ¾üXßõÖªñI>è4!:_>àÈõÿ>÷DhIo‰G{øB\ûûÆÑ8ž.˜-ÃYxI?ŸŸSœáØ‘NÛ­¶˜÷9NRâ3ۧߌNWœf¹9 fÁy_vtÁùtÖ/r¸$¸3äÈ}޳F'†6p!žWTë,=°šHÕ'F"¬@Ï%IÊ~Å–;jÖÔ3/kcz 'Ç/—ØAL•±BÅÂw0Fîl©1`ȦñS Ú-ž êÍÕÂ;ê¨!ÝêmÓ\ 8Ç#ó”H`ƒ' •ç ×§ð95¶×«[Ì¥ë"ž¸ Vg]Yý÷½6t#EïVõ¥&µ2ÿ6€S)X“%âûÛÏ3K™ëùüDÄ" †>hþ9“jkwý_!r  ø09Іè–îÜŽFwÇÙ늯 î2û:^õ8°ÿ©½èùª° ]p‰Eçpßôuå.›kcMu/ܨ?ËóüÒ,Or ¹$÷¦9’.n&W5²ñeÈ—rd°šâÒÐÍcõñ¥ü|¹ºËƒ§ ù‰oû3WÎ3ÀuíÈÇ>·¿ìy?ñ ZBŸÞÍ¢>Ó Vsü| “KxælAË«ÈÛ!Ëd<Å¿"¿è—uÅ¡cÁI5˜;¾ô=èLvI·Ííßyì"‚õN=Á‹ëˆþz7ømð?¯Nƾendstream endobj 5531 0 obj<>/XObject<<>>>>>>endobj 5532 0 obj<>stream x¥VßoÛ6~÷_q袴±"ùwÜ.CÓÖC€>¬­‡½(h’ЏP¢JRqaÿûޤd[Iœ´X8–xüîøÝÝwüÖK!Á߆÷G‹ÞÕ²—Ä ¾Ü}è8_Œ M`™9£É~c޿Јœ.ÿî/&E•¥ /ÛmQÞHnU ·¹b) 6ç@%1&æé¬éOcÙ’E«Ád ]°þ`_@0rë×%|®×Û3‡e8duI­P¥¢9Ô†3 }I©6fp˜ÅCw˜Añpˆ,Òü[-pÏɇ廊$?qÆÎ‡!áWhæóÂØ¸ä›®E,Jõ]E/ÞJþbuÚ¬:ÞX$÷«_¬ªíëÉ ×÷×ß±çvÉð’—76_E÷úî3¢XM¹ñ„20€qTµõìâAC Þ{'toç ž¯óJÒ ÏØè² Ì7Z×ËàQ/®}~UÙoÁ¡ÃxÌrÓ­õ.þð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¯Íô¬ŠîiОßËö‘Y{¾ho„él‡c˜Ìfñ4ÜØÜ!úƒ8÷ŠÖ–gÌÁâø Öýi˜þ2=̽3'x9„{æø"u¯>,{Ÿzÿ˜0óendstream endobj 5533 0 obj<>/XObject<<>>>>/Annots 2954 0 R>>endobj 5534 0 obj<>stream xµWMoÛF½ëW œf‰‘¨HvTEÓÄEÐD…/й”6!¹ê.iE-úßûf—¤HZi|haC0­å|¼yóföÑŒ¦ø™Ñ|É¿q>š†Sü‡?füñþíh¶À#Es|ä4»Z„Wþ!££ÎcNÑlF§ï^­;ÆœE³¥ç7Sºç´N)šÒòå,\.¯h8—SZÇÁßß?]=¿yA3<§4Á¹ ¼ûsÁ6TXX9ÆŸ’Œ´UVªbKï«Í‘âLXKoy83ÁkiÔ½LúƃOé ²Œt‘áM]X•HCƒW_ÁÕlð" Kª´d«½4ÎeH·%tqY’*vðV’(ޤÓs梹KËÿ@¦³h¹Ì7ˆ#­Š¸TˆŠu"J‹ ÜÖnŒŒõ¶PÊÇxà€EA¢ˆ¥-µ¹8ÙyŒ€¥ eÈXû¨— ¦¤ìïâÇA*¨G&\Ô;µG¤U–P*TöñiØËñn' úpwû–öF#&+­¯¬*JiRKJU†uu‰Y)IÐA˜‚K㱕”©Ïrå#h™Å„‰Âù4KùEäûL†jµXÑ]ýöõ4:=¤·Î|E\k÷‘ÚÚȤ¾&4Ÿ˜¬ødY©u§9ÙßBMǽ$üˆB°Aï§¶úmCµã3H–¦lé”6—åN'Ö S³Iói1žV³zÙà®ôW[I¼É±óÍŒFÉw!ÆsÞ ÅÎIP¼Á£nDUÄY•Hz`öt€áâ+Çõ;ûÑEÿk`¦ìä[“åAr„ªù¼Ò«Õ7NDgO´¸7røŸ"ÿ•Ùünc¥¹¯‡—H±Ž0“›îh¨U/–MZ'[AÃ#ž­¢îG(Á‰ X-åê‹L&Ü%Ú™÷ÕÇR)³4¤Ÿ2«IwA}×\'}56'ÏÅ¢Œ-OË>ywÝð®SwÐå#ú¼iOuLÂFp1"/ªW $g#wÓÒ4ó'zÁì^½Q¹0GJŒ8lDü¹È1U¯rà$°Ì°;Lùƒ^7@Ç(&Ç#7tloäÚÖêÄ› •¦’©|ìrÜ–«~Žmq8ØñýIwôæýЬša!=À·¡Û§k‰y,š›Fb™*°FgVÇzÿ½ˆžðàwȽÍv>/XObject<<>>>>>>endobj 5536 0 obj<>stream xµVmoÛ6þî_qèÐNYmE¶b7ñ°k6¯ùTl1P 00Ðeq‘H•¤ìÃþûîH¿I×ÅÐ4/&y|î¹çÞÇÞü7„tB_¼ê½÷’8ÁßÌ .g70Á<ǽ“ëk˜g~=9ÒIœÆ7pûú5¼_ Sj–‰ fâNje/æõ.gW0ÄÍt|0ºŠ¯0@Dôñ@¾?ЇJ¸Bg¶LeÀ1†3 wÚX`F@¥­+·`›ºÖÆáUË-ܸû5†™6 YU—¢2‡­n `kn£áJù b¡œ²ÈÒNή㔀Žé(NSü+‹ÖZfk½ˆ¤r‹‹ï÷Ç1§ÓE^0ßñ݆cÖ-'“7tàÄÅ™‚Æ"´BT üÞ`ø“fËäªp¹6f2¨˜RÂtñµàI³\D“jq1M’á4ùB:Ã}:‘Ÿ..:iFðÍI^­´ÚAGgƒ¾x'ÊR¿8úÀJ¸ûT Jîe%KfÊm»p xɬõ%Cª¤íwð·Ë6Ï´†¿[©ÔͲ”ÜSHE÷U” Ö³[ÌÝÇ^u´^}º#ŽãVø¼Ζ›dHåÞéD(4×™8&õÕµ…j¬Ä¦C•÷Ö†÷2ÚÒ‚ýŒ¯Ž‘Qþd‰ou½…<Üûdi÷¦ Õjß´ -(íàcCŒ0 y)å²ô¿c 5Äp¯Ñd%,õö½ïýà ø s¾é‰ØodÒ²j)W fÚò.µm½ø¶¶5«Î÷uXµZÍçÚZ›ûO\–“æÞ’K,»º:z ­¿Ú¯Ÿ•Õ]™@Åæ}¹åq‰l¡¯°ºÌô½ndYÂJ8Ô:Š¢B ­–­ž«Á©Ær:MáÃ.Æ8¹™žZ~°mh1"Ï>k–-WJ‘ù>ôáIìa'6&#iÅ,Ó›`õ'åò]xä‡,ñ`(st|ù<Ó $É”À0Nï°¾F(V Ð ÿçÄÞþýù!½ A¡ûs§–6í7£k!Ÿ(Ñø¤“å½áò~âëˆ !SǛ۽Øy{>#Ò—¡Fÿ?ô» …ÿÄJ¯:–Çêr.ðÔ¬à'„ݸ€Ï))›š `9>±ôТe¦pŠÀ±ÂbCÛv1εÉ(êƒ2âßO›‡Ä±­Å 6‚‹L(.À4¥°1ÌQ3xÕ…Þµ)$öa«3C/Ò"©KªºAÇÒ˜y`ŜÓ⑋ÅŽx¥C£Ñ c¡ñµ€—“n‹v(­°ƒŠ=™ũ‡.È¥±xÁÑÀ±¼í|×8×»¡l”\Åãt “É$ŒfDü`'ð³æM%”óxª)ì¼ Ïè3¦¿q‚âG?}Æ7)…ùeÞû­÷/Èhendstream endobj 5537 0 obj<>/XObject<<>>>>/Annots 2957 0 R>>endobj 5538 0 obj<>stream x•VmoÛ6þž_qè°UAlÆz‰x[µkŠ~Ø[l_ ´DÅ\$Ñ%©8Þ°ÿ¾‡Ô‹e7N7$HD‘º{î÷é$¤ ~BЧî7-O&l‚7îOèþ|xw2KXBÓË+6¡’ÂIÂÂvUÐÍÉpÝ wkì&ìb°Ç »¢x±),ÇÓ˜EíÊY®±;»`³áî`]R†°ÜXrßר†ìr°ûúv¥UßÑùu‚àè6G:¦WxÈ|ð¿‚AZäB“UdW‚NoÿXñ¹‚•àÅÍï߯2zsvöbÿPç* tÅ×¶r¥©TZ¬ðXr+UE|©jKêAèBñLVwÌ™9¿¾Bz|ãh |A¼‘OŽ+cWÒƵל¾§·müó «ÄfD#Ч{¬^=œŒÐ9§ÓÝi6LZÀG´lÎîr úføÉI]&,(‚F÷2ç9çèæD¬Ë–AÌ €ï–Á;¨„4im ø¤t=¸±œ ÇGÎý¶ÂÖ« œùàû{®—åçu6ôñÌš§â¸Ðz¦ƒ¹|ã¤$u¡í¾C’ ïýºyr5uzêë.ºReu!°¡ý~ïºUwŒCÏý!»â¶+ª—X Xju/*ª×M>M½l‚EqÏï„Ùë°ÍË2n´§\Â!ï] J3z¾“Z$mÛµ` ‡Á]¸¹RŸi2ªM9Oí"pOÕç¢k¬®SK¿£¬@~(é„ìÔzmG v#ÐNŠ<’/èµ´´QúÞ1°á7¸¥‹Bmžï7©—‹ äàç“I8Ÿ¼òÂùuØ]RAwW¾lôò ›=DÛ˧ǼoíHò„åø)Ë»vŸÏ› 8!9þ«ïzÙiÏ'É$œæI–¼zÆwò¤oöï1KŽyk·úèö3uÄæö˜5(A³5Ÿzõzß,k­î4/Ñ"¦ÞÐzNjШ]‡Žü#îí*/dj .Fô†$Ü,íe‹¡@ýmÛAzþ¦ýÿ·Úk®?B¯J8Æã|îžÛ‰å²½ÖÃË„]ÄÌg˜&›ÊIØ8Â(ÿ£Jk7ÊùÉÔaÄxӜϚ~::„^L0žF˜¦ÑþW¾‚ooO~;ù<€Š§endstream endobj 5539 0 obj<>/XObject<<>>>>>>endobj 5540 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± s9Œ§\ºñ4‡øì—gÏÈJù/Ûµœe'á„¥{R”ªêÒ"Ox@c­›•ä´—ÆãF…ô›ÚÊÔŒ*)Í­Å ´•vM–Ú c„G‹ÜœòA²—d§åœÂè BM¹îR€/c1n¹°hcHs…hQ­¼õÔ?>Sl©îà¢ÓïW  4×2±9êøpÆfúa‡qŽÇXç4¸hç®È6¿ý5~’WIѤ’Îk‘ëp}Þ û%¿èorãmRch>ÂÒøß⻞ž±ºIÐ ˜ünáí®–©Ì MY®ýÈôñƒh/cA±˜éI©Îıö¼Ó:~à€¾‡+r.‹¸žz,À¯ñÓch#ú÷´‘o¯¶Ì]­Ápšç‹+çå¨9À÷Ý*zß,wÇmæ…Øw9×ËEPмZ\Í¢h4‹îÈOŨƒõ@Ë/ æ‡.ÛI¸ô{܇=ßhôKö:Ø7Ÿ2^ÓÏôÆCÞlæ“ +¹]ãMW¹zrÛ)yYôu¦Ù$ÍúCÔa|2„ÐÐc®Æ?HirÚžŸ¶Ç NüÃC,»îÉãÙØáÙ @*tJóØè]¾ÔBïh|˜¿ëŠsç~¯gZ2–ó“CŠ3ÈÀFEk kÑ•ª)—À7à{KIP7Àq·O¥¨=ì1¨¶¶ºJ9VsK ÞX¦ó€°º‚´hel:›ñøÏ»<‚ÁIA ØôH”˜œO™ÝîÔ±áÅt ¸ïâݧÙQÏsÏB«P;öÁsî2ë¶ÒQpid±‘Àåeƒë`-wŒÔŽ»sË×ÀFV9ó  `[;út÷Ä1M3[Ô ‰¼´¤–ŸÃÃò ­ÅmªÒ^4¾0Ð}zêæ'QÜ3n üZ;[žU4…)¼›†+öb@¦©kՒ̓F3Ý]ê~Uœk>xÖhµ ¬©À8¸Azòá²B kŽÑÉh{xú 9}DˆÛу®(oÿÖ=Þ=¥(‰âü)ß tôË×ߊ‰_­ñ¿äl ®/Ļչåü sžWçÝ:8’ç>kX<î‹».ú2|æ*åûÝåÐëg#ŸpÈ#$}’aîG¿9Ý©˜iUºà÷=~¸ñmÅoÚ«!Ž&áõøš¦7“ð†‰Ÿe‡qÑk•4%f×!ì ׳—¾ðˆïájäÆmŠºûë:ÂeãPƒÁë—׬ýf~öçÙ1%»žendstream endobj 5541 0 obj<>/XObject<<>>>>/Annots 2960 0 R>>endobj 5542 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;Œ'Æ’IÑnŽí ¹­+3¯” ÷ìffù(°¶ÿ JÏ~Ôdk\ K¬íD@<ÐãØgIA™4Ö@j®Ý¼a8&æ[¨•±4>ìa޲hNülÿƹ£ÐÍËôŒ-› „b¡Q9Ÿk´.‚‚BcÄA†Å)k´µ5Ó…ÅÒÁMPO,©$XåÌ›õ õ@Rçc¹É Dk¬Qd7'¡6/4A£_[°2÷†öˆ°tìòäk²Uð…Ò¥‹–ÃçTbú˜vÏâž1¢4†ˆ½ºÎœí–²÷Ïy˜Í;ä6\‡)ãØxçX.Íé;´ ÆðÍ­!S¦ìæ®àc+*MIÞæÐ4[-%zӢи„z‰²uGEõ „ý½uTO§XËÿ®3w¤ÛˆíE¦ò½¸»õûÁ9à ÒÞ©âpŒ“1LNæËqVc¼(þ,²ºÄjqXˆÊdˆw<·vxꦅSPâ¤1"sH›‘÷l. 6åÌC’]·CÔ\ŒDùÏ'&èÛtðÇà A•endstream endobj 5543 0 obj<>/XObject<<>>>>>>endobj 5544 0 obj<>stream x•WïoÛ6ýž¿â€¢¨Óت$ië%Öv ìöxŠz(‰²ÙJ¤+Rq½uÿûÞ‘’ÙNŠ!AbSGòîÝ»w§/G#âgD“sþMŠ£7³£a4Äbû§\ЋëS i–Áöü5>¤þ9>$½ÙRRVéęҒÒd×jA¢””ˆ<—)Ï>½¸Æ~O§hQn®y—2:X47ôHèv½Ql‹èÚ”ôöä„V¥LU"œ´4ï)µîñECŒÆ ç–ÂQQYG¥tU©)6&'aI`ÁV¹›?âû¯ÍÿÓù‡÷±UiîT*Ó¨vt|ÊŽþ—4ɯ¢Xå²O*£…º“šÜRÙ€v¦r9 Ž éU4áDèxM&ø–öž&­r‰ü8+ÝÍùœÉÞS¥“¼J%]X—Þâq¤®ºn³’…XÍ{ïµ»‘ ,§S˜^ð‰}ïÅtÒÓFHWþž-wÞ§It~þ’ïý`*p„ã@0••üp&e¥)è÷*ÞÐZ¹%!«üßT©D ™ø“LðsÕ&ûqJù¥R€øY@àY “2í5 <Ü߉ý ½“™ÈšÒ)½ X.Å‚S©Ì”ÁÁy°®s  K XEZ®w]\Ðhi¼¿4é.ñ·×£&ÁLdïýå}õÇýÉ_Á¢¥3À[<¡·à9@}0`-ä pçÞ¸˼Rð}ýøv]QLÿÒüxgÓ^”1a©¥_êF?%}œ ÌQækâ:Î|ŒƒñYêÉy4‰Fg^nf¿Ð{'KÁÚnT†±9|}±€±%ªi-óœ>k³Ö”!ÃLH&¦ÉH5ÇD{‰N®ŠX–ZkUŒbóìMU–Á^;Æm%Á!iûƒÌàÍBjx—7ÐÕºÔïÖ† 3Ö²…)±sJ‰Ñ¬Ö/–ÚèÁκwsϘËM$‰´,))i4ðpãC½y%=NÌ­Æ™ BÑ@¯—Po{àJ_̱AÅ–R¤þ‚½Ã»ÊÆÈû:gø×¥X­P`дjµB±AqkO_pµ²\‰^ ¾n(ÉRzK·–RsìH&ðÞ>¬Óß´¡6ÀÐŽ’°Ö„•· s³ì½ÞêXšPB‚Ó T`Iáéà$© ¡ûø£% nÀEå”ÈÕßXarìæ¹q•ÈÛì¶$Drˆ¦m šL½-³É÷UàNO:&n,JkR-uÊ}*-ãÉ&EèÀT ½ûɹùóýϾ6r—èØ$rÎ-(:B ­ æþXë@.Q¦L¿à¶œ<å"«M¢‚& ‡Vç+¢«k#ë`ÃQCu%‡jCy‚1ƒ\}nb0eßC³Vð¡A|]"Àí–ÚÕÔ" ÜVš úÁý•L¥05œ‡¨SˆÏòÖ—ÝmÒ”]98Éø]¨žïlDŠkŒw¦Ô ‰ „‚8!µ`˜Áh<Þ8 9o|ïS‰–ji~ÜŒ¡Å|ogsÆ­'f”Z-oA»çnKig$@píÞ­ˆÝ9L˯nÞ -g{ÖA¸1 YWöy!½xûá•‹þÄó`²äj¸W!÷&0+†ªÚ€ÎzQ‹Ãž²>/XObject<<>>>>>>endobj 5546 0 obj<>stream x}VkoÛ6ýî_qÚ"ˆ²XŠmÙΣ‰¶I:ë’%Â6`Z¢bv’芒e£íß%)–Û1bðò¾ï¹‡þÒé£G}øcý ÓÎû Óóz$ÜüËŸptÝÉç#ˆ1èa|Ú÷Æãc‘Ñê!½TFeÂÉr–ð% ™Ÿ;=¸dDΞȤŒ8T=Ú{O´5 ž.VðçÒxùÓxy8Ð&ggÖæÜ˜¼Õ¦G×CôÉ{l‚¸¿NË™ ¢à9£,² Åœg˜q”ŠGˆs™â®œ­‘ˆÿø™õ´] ;x¾OåFNο”"çØß.l¿Î[ÇŽœ¦0›ôOJ_âÛy¯Z–8?GÿGÑàG‘_‹lSß´Þ€*å ›I*œÓ!B•c ž¨Ø2¦!‰ì K/e‹WøŠo«oXð½í­uTÃÒ›ñ'‘µäÜÈyµ¤Õ\^]€·.€%KÈDxô]þìîðí²Ñ(ëH,Ùq'¨™«¢%ÜMÆ ìèºß ˜ i7™à¿‹a#ü«]<§kYîG ÆÎyŽ9[rÜ¿!L˜R\¡Å\–õ|½žêj#(ºH"D<‡ CGЉḗ÷M?>þ~óxõ÷íÍ]ð8 ®îÞ7wŸ®‚_o.ïÛi9¨ÈMµÐ2Ëô4U%ž<«}Š>]Å´×î`¬uü±ç{ý1>â>ey[Bí‡j»×Co¨M¦BžLdÆj‘˧œ¥T’( B™¦’ÖJêÚt¡˜³ÂöfÆiߪœ-´o´hJº!K:¼V&E€÷yF›š$ë.­©0)é™êD¶”É’Lm7¡½ QØÀtGaqO äj·Çra‰À<8íŠC&îË<Є<7G0©c›vÞ9¾6S1œxž™Æl@€_Ú©ÛRØ51ûø,&Bà Ó6Õ9iV3%um±ÏP›­äZÊÜÄà"4íØJŽð‚ÕnÆZ8c¹îkûê»9>›û;´P€Ê¬HÃÏ5æ˜B,“DVêåÑ4#8§R&XM|È9 Mb8:ª%á0åsYáÁÉd¡W³Ê,$6•îaáNVäÒ«Ý˳³UkÒºkR ½¦M´á¦ß­g*fG̬@Uë7© ¥¡¼&' 4;€¨Eo@3Ïš=šÊÛAœšÿµuÐÕOr²kNÕìZÊÙgzt=|b!UÒç)Ldª`Y!¨©í t×Ìž>—I©47µœ½f™v£˜3Ò“ÅòµGÍÎÁWLïõËh~{ÔÊÖëIM±ý“¡7òGÓ÷±}ÓuSÝ×£G9,5e°BHê4«íÛ'Â2çÈ2'ñý´þQaXjÔ#^Í_ŽNOtÜ« óGç¡ø ×endstream endobj 5547 0 obj<>/XObject<<>>>>/Annots 2962 0 R>>endobj 5548 0 obj<>stream x¥WkoÛ6ýž_q‘¶˜²Æª_q¯ °¦MW`-²ÄC¿h‰ŠØJ¢FJQ¼aÿ}ç’’¥n1`há@yŸçœ{ýçÞ„Æø7¡Ù‚ÿGùÞ8ãþ˜ðÇ廽éÑ,œÑ|1”Óôx‚¿þ)£«½×«WÜ=sC/ÎÇtŒK«„¦cZœàÊâ%­bgxL«(Ãð`õyoL£ žãàY%ó2•\W¹0ÕEeε^P÷ô §? î´6^œÏ‰$4‚³ÑtÖ: >êæTA—õf{HòVšm•ªâ†lªë,¦Ïµ­h¿ÑæËþ’ ?ˆšíLÃÙ )Ä2›u U¬–ãñd9>%|Ò%”ô3½½HA.—gF"?X<2ÐòïIåLG¥VE% YËT7ƒŸ¼ê­v…€Ýåøn>ž,’yœœŽ#îŒ4¼C¬³a±áåÝÀž;Ö÷hh}¶ÛúF˜o¤íìãµwÝõlб÷ muíZE…”1UšDIk©J%ÕE,M¶åvE3²ªM“›mÛ×!Ð¥4¢ÒftzPç5 UY™%‡dš¶¥ÚJ碫Kkãúer}½ËD.«TÇ!k—×iÊx‘-:[-¾ƒ©ù®Z&èSçƒéÒÀ>¬ M?zç'Ä!% øhzÔñb¶gáä%p¨­ý&Š›ZÜHºÐÙ6צL•Í¿îÑ<œsnWŸÞ¿ûÁ:JQ®ã:“dë²Ô¦²9{Yg¯|`Ö¿„"tEÞ•‘Zc÷)Wj#ÁttBeÂpÏ«TT”hC­» WT_dï<¤KdàR* Šë2S¸ç¼¨rQ)]Pi¤•`YÌzÀPr¶†RÝ 8ê_v¢P”ŠL=„eÉ"¶íd¤Ð•ô U’3PËQUÑ æAøHr#I4ÂHÒ 5©,€AF¶³ÝV…U¥®ØN-_œ£ŸÜÜO×¶—áòÉÒôGat–ÁÖŽ.r?Á«!èìùsêšAQ&@4£kNE.0Єn•©j‘Q.ó n%uáD–!GPÔãA¶È™\&hY#¶®:ƒ”€ŸÚ¨LU[_)´PöY4*˸FF({ß7ÖrŠt,Cz½¥X&¢Î*ö¤Aàþ2\¢®ê¦ÐF"Ž&UQÚ1=—¢ðàèï£îÞ¹¼C^‡ø€óîÔ€Bj«q%S_=Í8)@(×ÉLÅ­Ò +[„[©ñÍéÔªÇõ³ŽAÏ’¥k¿&÷"æ[§nWUÄü £Nøµ£u¬Ä`Ì­í×}º@³/sH«Tê’Jºa`rÕ»Ñië$Qè4Ø”kLÑHXiQ7û)úÝÄèïÎ)à„ÚÝÐU£n–Ë7­Z|p°zÛ!d<•Æh³>®ÿøÊvUz´0ø}g:Ž!y.Ö-tÃcÙ ûN†ú–M¸²ßQ–2ÞïiëE…—ˆvx˜Í5d'ªåt×ôèi”íô¶‡£ ¬9£_.Þ;„‰bë¡·£cØpª®‘¨oÒŠ˜v$Џ%øŽ[Ü8¦6V®HÞk‹y?-޽ÞC_æôQä»Õ$<>æv9Z¤‚%²¥ˆtžC wOÅ-ÄZiC:Ã'T¾™¢7P"\ÀF@˜#†Òa7[8 /K°Ur´.p&—ð‚“lÜàåÓ^{ú“ÀnkÓk©[!l]@,Üà¼ßÚ>/XObject<<>>>>/Annots 2964 0 R>>endobj 5550 0 obj<>stream xÝWßo9~ï_1*‡X¤f›lJZ@ºÇŽà*ÝK%äìzÓ];ØÞ†pâ¿oìu~µœº§S«´ñÚã™o¾™ùöÓш†øÑx¿e{4̇Xá¼{yT /ò ù„Z*ÎGù¸ÿÖÐû£Ýï-G£ü|ç鯗;ƒU;§Óé†tYãæÉcüS… ñO™½Wº”äÊQ¹z.É©¹Vµ*…öͺ_tØ!ieÅr)-•¦’4—ZZáeE³5½ÿëÕËRž`ÆwVcÕÔ5?©d-ºtØ„ Çyq‘?¼üx4¤Á¨€3Ùïf%o¤M–ÐlÁšÉÒ´ìžÜ2K¯Œf{u‡«$YÙHᤠ6O§‰r¨ƒbÂÖÇ“ü,Ño²VZé9=kogvgùïå8T e9~Ó¶¸niEé½ìÍ»±Í:ÕøÒØ®+rŸÂVÔ¨™vÍþ/­¹QKÄ;©6–Zé¦"-ZøLS¬ÈÏ¢]6ò$º4Ù䪇癵b}Ï©/rßçŒÑ:gÓûç3Š©ç~qp4§W5­MG+Ó5ìò5PÞñwÇ*-‘MÞÔ7¹@£1w6Öˆ2ܵI.3ÂPçdÈ? ž€î‘Ù}ùÙK]øG•²ˆß·DU!#Z®xp‡³aXbAx*EÓD²«æJ‹4Ñ0dôÖO’(.°¥`ºùxŒoU¢¤×ë ýÍ{9®œlÙÍU†ó›5¢ÓSznŠíJÏ9‘íÒ¯IpæöNS²z•]=|Ú?Âå0Œ¼“\>!8N8ãjó.K¼áƒ§˜_¶²Â…d5ºû5}—ôh'/b .ôaÂ2,»·%Õ½Cügëέ+‚üÉɦü¼õ?¹='úº]ø¶­Ø§l<Î'“sFïz…÷hNÎ4]ìâ1UØÔét˺@¸˜šc¶Cº«¬ÓêSØÇÍ ¼ %ßšªkäÕÜ.atiå2KŒp5á> wçÊ*8¥S¡Û ÷ïä•~4÷CTéø“'Z:æŒ't#þw?`F±aÆkŒ…öºi˜lœ42Sª0ÁVÊ/Ð`úÎŒÎû6O &€8¹qÜ5Êy®ËÔÓÑݾŸ`'$óy?±†tgúV2Ek:íO>uÐʯO¶Éý&SkÚЕt5@'¶`s˜VK£`‰Ý·kÚlš%úf¥êëÜåQZ+ Nc#ú¸_J­^º§¤r™ó£5¹Eàÿ\ú‰ÃˆC8$`¯jv‡;5,½¼5ºv+à°Joº´{Û•¶Pd9môÅŠ ×}o7À lÕI”0•‘N?ð˜GA¤ì…–TØÑÄæ} ›xJêÎuØ qHª‚Ñ~ªÆ±Œ±H Ûxjµ‡õŠ"ɬ"›7Æ#y<% Å"¥•š5_ç8w}g<®¥`)æŽá9«Hå˜nD±4XïP+|¹à“]4‚ºë#Ã| k¥+Ç&ÛL9v•9ÉQHV¦KnøPgÁÆ¾Ž†ìÍŽŸwΛV}a L“—ûÛ“Jæô™¨¬¤ªqhôÚ»UeAXYA*Ø×AÖ}[VÆñ7Å,ôcPÐÌHXM7¢ÁÄaà ˆXi ÂrÁùVØkè I×Ú¬ðÄñðé¯îé’Ó‹($n›Ç{'fÁøF¯ÏÂ<@Jð:ÐtU¯4·Œ‹R2¨š_""Û©y•­ª\ôcý–Àƒ&º%\gV®¬Xµì ÍÑ æ™c€ž‘ˆw%?Xk„úvöêð^’¡Lý_x¥¢ª4Áx/}Ò©˜ÝR–x;B ÄX L +/ÌtË5…i î!7ˆ Bj9¥!Tcσ= AÇ^ŠAÅ©Ç}w¦¼¿"ø[õ²kgÒ:~kÚ(¡0¡ÐÃ0Õf@7¼¤¤+”$—RtµµWÖû­dŠâê6û¡ÖNЮpõÅýxŸ r¿žåÆhr>Á;.t·A‘é7×P¨U>÷Σ ä9z#Zô~þh8ÉÇÞó`e2òÒ‹Ë£?þþ<¶˜endstream endobj 5551 0 obj<>/XObject<<>>>>/Annots 2967 0 R>>endobj 5552 0 obj<>stream xÕWßoÛ6~÷_qõLAU’;IÑm×t{¶¶Æö0-Ñ6ItIÉ®Wôßw¤äXŠ5Ãö0$qDñÈûî×w罘"üÄ4ñoZô¢0Âþˆùãíë^|1 Ç4<‡”àܬrz×Û_c÷bŽövãqŒuGøÄî`ˆ;üÊÝ[cw< Ïöv_LöÀ8DfA¯†G4™õ虋‡4¨¶+YˆUKQQªËµ4•ÅJÒ¼.ÓJéò[K"­j‘“‘UmJâ#Tiz[϶Ø<ž¼ï=¾‚éNCP™ZúW­Ò€´9”š‹ÜŠ…tAùQ«\^¶×ž‡FžDtš$á`€UYŠBNƒ¾²×ªº¶b.Ÿõ§Çt»œÓã'| d›ƒ£ÆÖi ëŠeËjOžú´u^ÑSšczð”"H=£7l]ÒúI¿{k÷–Ö[Ÿ³öÓdŽFcFñœf²ª¤!«óšý ìÍÚ©p{kwãΣ•‘™JEuè-Ê”‘ÐZn]ªÀˆkÞýöãk…cC…Îê\¼ϤU‹× BVK‘@`©s=€Æ ƒô> Rk¥kÛFçP{£ë<£\ëÊÕÍßÅl§jÏë;í¢t_NHc‘Ç3“íZßÈŒæFީΤéfkß%—2³iPUN/£(¾Œ¾k‚S“ŒÁ«&I/oóíY¸F†}éÒînA°¶]>LþYÌa´â:)dYÁÐÚªrÑ¿?—•*mŽI—¢T¶ QfH9—b¥C\?Tˆ*]òIƒD±œƒð™6MÙø\ÐHC7ªÌ,é9µw“X­ò-rÏJŸ¸P´â¼FF»ó]N ý—µ­t¡þ.ï¯Z”]ñ–µP¿ŒYl$Ò·*·Óãлù‚Úi2⌌Â!˜â…€1?¹ü¶^²e!–†C–õÅá…à*EÍ·ðéÙ{Tèt•‹Õ·Iü©’wåÇ4p—m!Ì `»)õ»–f¬Ü§¢ é9‹;.c· ·ë,íŠÁµ JÏÛo¬6Õƒ® m–*]Çtxqij“IÃ!„UÉyá  ¾$¤—º¬Œ°•K{Ú¨jùemÊNmžö™,R½Ú²èeYNqGN—»ÜAò0?ÒI•¶’"ãcÞËŒÕW U¢­4H™üÑ€¬‚|™nýu.T®-•ìt{ÒúWìâÖÁâè¼à#h—Ž¥À 1 :ŒTs}Ò¥$Gb0±ÂÕ¿ÿqØyã®HcdkÐAûWX·ÛÓïC»®6¦Ì™wç}£õŸ+92íÄôA¬Cz톸ðî:~_ž£‚©R(JÐËGÐxgF®é<+®4†•Ñ+ ›Êñ˜ÑõbI ?¹VåwlúÕ£!ÚZL’š>µ~vm˜øôéóÁTÿ*ò#%K´£îš_]?¡Ãk­ÐMwGø'êÎúC#ÝÃía?…®ŒZc shnwÅu;^úÏnùÅiòÅ­q.0¶ž8ºèx,?·dÖLìL>r;þ‚í×k7¢ ö,Œö²M#nù! ôFâÛà ºïÙ˜6k~ç&î ´nß1Ýè Šõ9áÚ¬ãÅ» ¿ “{z݄ۅÈs½ñmsÏ+PïaTÙf:>/XObject<<>>>>>>endobj 5554 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 2969 0 R>>endobj 5556 0 obj<>stream x•V]sÚF}çWܡ㙀@`œNR'¤~èWŒÇudzH ¨•´ê®&žü÷ž»+ɈºöÔö`VÚ½{?Î9÷þÝ h„߀&Sþ ÓÎÈá üñås'˜œùgŒ/ü ¥\ŒýYµJèºs¸NiŒ]ÁÁÛ­U½¦á|D3[¬h<¢éEàO§oiÙkG´½“8 “2’Ô-ö¹LEnü¸{ºø³3¢A€‘çû~k½UqD™\‹BÞyqVPïêç_nw§ßó¶áàÜŠ¸q0žT7zW})—û> Jˇ#Ê…©,¤&³Q;CeNÂབE©3ÚŠ¤”>Í•&ù Ò<‘ïÜ ML|ÁØŸL`ä zOŸÜ>¿vorwÚò=×ì°h=LÚ~·¼^l$¥Êª4U•F’ZQ±‘øbrÆ"¡*s¤ËDŠ Š6"‹I«2 ‹Xex¶EYª´ä©L>g¿vpÌ…$Å)L‹Æ^eÉeË” ‚2´“Iâ2X{&µFöBý+u¶8Mî†=22‹—±–ýÚѬL—("^î 8€MEŸL†Øhí¢ž8gï¹ç{¨7¬·èá|³éûÊôn„¦^!`ɧ2W­žL½†¨…¢9»³9H ü‹–½­ E®¼`™…¥¬þz³h×ܳµ#±TÛ—×NÛIª"Ô¼†g+ðÿO¬ÿJU•çwkñZ†n7ÒB6B¢+öqBjPÒ.`*¶ŒBk±çb§T ¾9hËÿ)iÑΣÁDÿ ï*ßýUt«tu˜¯(S€ŠƒV+“D޶]‡æïŸ òÞqh‡k‹—LŒ|ÞØ5 Üí;\·v¬¼~²– |€—Pb‡LæÂ1¡IØ¡tÕRÀšñ OD”¶¯r8ô bi ¥¯]œ­k„õíãF7 iÖM0°ŽÀ F¨’2…䨌–‰ÕZøz}{õ™åÁ]ù ¬ø²jiU®7öÚJûŽŽ†Ñóó4©Ô¹öÕêÃë4q8©p G·âà+>Ô!³M{¡w­eqAO3ÃÂ|çý$ ?P/­l5f{•Õ×hVµ¶»“îSxРŽ}H†ó x@ÿdØÍü‘í×ÞdêOÑÝB™s7qݸpµÀÔݘú³7 >€ùàÆ0zK'²9ÅZ¢+m-3Ú8·wGÞ,\Ž‹Ýq/ê^ïQc“B(ÉR²úFÌH®b49ÁôÀ®ÄÒjf+PÊvH>ªl+uA—ÃË7oœ €KY¡jäX”ó4^TVŒOì4šKÎrd7·G,LDÞei •Æ_…Mä\ ÌÒ´7×ã“Ç®"—lËŽ$ 0·,Yªò\Ú{U¢[‘Ý Ö˜ÄYÒ·<^5t>†J›/ÎÄGU"O¬&?Öv,g ‡[Úi N–YÿD‘µB½¼ÐíW9¬Çá±á.5rÂÑdr÷ÔVñêiâ¯Çrzà¦yÏÝ)µ]&üÀ0€­:§~çX¯†s º¶=³3ÿ|rNSüv°c Æþˆ>ª°m1<‚œŒ˜n÷à­ã;PñÌQKTYð×'½äC磩?ƒ^`Étd‡¿O‹ÎoXëp4endstream endobj 5557 0 obj<>/XObject<<>>>>>>endobj 5558 0 obj<>stream xÍ–]oÛ6†ïý+‚-p[–íÄÍ>: ]’bÀ.ºÄ]/æ! ¥#‹«Lº$Õ+ºß¾—¢ìز‹®Ø.–Bh‘çã=Ï9ô»Îbüi<ñɲóbÚ‰£nfAƒÛ˜.£1M3Å4ùfM&ÏhšÖ»bš&]¢çdåŸüÝÙôNLý!Þ¤xó±Yãh½ èš­3zMB‘0F¬['þºÖå¼à+ÿjÖчÖ¢” vL+gÜÑ¡¿;v¥Qär¦‚ÕÂ夳zuÌ»T®Ùõ ß&XSž¿d·M’¤ã%V)­ØdÚ,i®K•ZJrNÞJµˆZY¦µ ´`çOκ>0yT ™bíJúá9ÅØqzе¤ïIÍÎfg-³¾VM ï7ù{;".,9år£+ºjÁ7Æhãõi>Ríû#£–)Ù= zÔ(ó(ŠÿFŽ ø…ÅvBA#ú¼Oü·û!¬?Öþ·çä×õÑ&ýѸé°î½T #ÿG6¢ %»\ƒéY– §O´Qÿðû„WNjE@̳§K××Y¿aM$ [Û£µ.i)¹£J+§aÅ%y0[›gº+çÛÎùÞå÷Ž•õ¶çkªŒt€'®ŠBW~…£ð R¸@ä™,ø[Òþ éFÑxŒ‰’v¿~ŠøC‹9gÖGtÿJ$>¿ÖÞ w•C:³n¢•u;Ìž%Æ:ádB¿^ýüú†’xƒ3H9“Šj©gÝ“_½ªÙ?éù—|ïÐФ¡º60BZF$ÙÔ-Dµ“èäÓ=ÔÒdæg(ù΀>/XObject<<>>>>/Annots 2971 0 R>>endobj 5560 0 obj<>stream x•Vmsâ6þž_±ÍôzÎÁyéäÃå×ÌdÚkàzs3Ì0 Ɩ|’B{ùïÝ• ÄÀ¤m^0–¥Õ³Ï>ÏÊߎÚáoº1ý%ùQF8Bmú¸ÿH#Ð;Ã;È¡wv«› †G/ns¸8 Ï^<»½ˆåê9´PˆÑ :Äí0ŽÏ`”º#%€Õ+øûdôçQÍ6Ž¥8ð#K¬Prgüf“ŒƒDIcážÉ9ïk­ôOã“QŒeV$ðÇû»Ï}HŠ‚ÓT¸=¤|&$Ÿ$3føôÉÅ9nÐC>´L¦L§nl|òó Iš ÃI¶ÇøM„í°<÷<׺»Öà(ÿ4‘«f§[qÜJ° a0uÃø•JxAôÀaf\>V2[³–% ž‚Us»P©œ³R:> H–ãcÚžŠã7 æ©]ÃÜÊ™UN;3Cº'ЧT¿¡ ‡á—ÛoÍ.V!ç¶4\7] Ø4ìVª¦9He!9ÒæRøðîÝ! 9wD$ VXL¿J]˨?’T‡ }(U¹ø 倬 8³¥æÆ¡Þ,Z‹6€Š$W‡?±¼È¸qùµ@Ñf¶SØnÆa~¡*Pf÷åt×™J\ìmI7¡cç7ÉAÍü…˜/2ü·X½™_LÅÊJŽ£‚‘•©fh$$€Ò”©Û«Ë…@[°,SK¯fVhÌ“òʼnè+déî}ÞkjhG…!5H‘ 0Û*@ kʈ*Ã2£0å’övÕ1ɳ•Û±@¸WÎ$­™—9—˜J‘óY]&¨k¥SÜ—´Ê8‰@û‰×X]&+aÊ¢PÚnr%­$ MAkXúȤeó §o¶æH…æ¨úGÔ—çg)² Pë˜Õ¦³8y0Ì q ¯¤8‡õm Ã’‘ÿ²Œ§õˆ¯ Y‹³ Ä ÏìÍΓ9Ö^NŠq0>9x<àD‡rÆ}BþO—-¸$fcð‹u:§¦èÞþzµ}š¡äËq5¢F7ާçá†ïËï5ò–a¢2$ù ™}¸¼¼ïßì͘zw]Á ½Ëk_?pHÔ¾#Tðý™? {ÝÄ1¾éù–Dgz³ƒ¯†7*qÝÝ'”5¾³øÙÍ3ì_ŽÆ^‡Ýž¤Ø<â¨G!ú££ßþ/×%™endstream endobj 5561 0 obj<>/XObject<<>>>>/Annots 2973 0 R>>endobj 5562 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ñÓÁ‹wü±7F[wDy”Ü(}ê-­››ñµØÓõ³˜1[kH ð·Xgг ö¹*R•B7Ô*K7êÕ³g*L—œªËr±g=6Ë¥VQ–Ä¢"æ)ÁbÇÛGªsõ×»·×•´y'J &íâ{‚Éá:ÈÔÓM~3?9”ÝñäªUÇéŽüÁ"Ö*_§;¬aÝâ9»…* βÃÂiM¥³ {BúYh8|N‹ úÞÈŸÀЈb:«}¯±“û74ߌ»^âˆ>[\ë)Tèé-5àSüèó¾0É»Õ;¢"h@m³/ˤˆ6º•ÂÅÛxÞ%K}×Êrˆ¶qPv¶R€m ¯£[¤hšüºÿ[g©SzŽQÕ2mLou¶B>TÝØ^ÉM­¶æjŸA{\¸åÏ .ëµ\%/³›JeÃÕ>/¹äR\ES¸Úæ¿,Š,Z”E»ŠŸM”e_êÊC¶³=õô1y_tX|Êôm”–y¼­c]èe×oËøG×ø#ù𤻤•ó'ð” Õ?S1â ÏQ3¨J†™ X¡tpM ’%?OÒB-Ê(.N£„Kc]YThæÛ¸˜ÓÇ„Bc*0n”¾%—ͺöÒÚùÊ(Uz=喇/]¾Xº Å- 'IT—ðe6À®ªt¥‚ÄUj˜HmUCyfŽÌBÑÍ·:ŒV{®¿¨¹tOUÐÕ¼ƒû¿›m¬»êÉ{S8ŸÌO°Ø’²+Læ’â,â{Šˆ¨×d;Oá2=dÙ¹fŸ]ôÔ·náÝEÏ÷ñÛ²sÌ—ØÜ”ðz÷)ÅU£3„bÞ0Z|öùÓ›ëíõKìoFåEÅHÇû{³«zóXxÞ6àÉOÑÌO^úº[8e¡hÇç&`|á²\•±Ú­u¢öi‰|ÀÕˆ„Ø"ÿ8.a™á8ø`çq Ô2Êð#Þß_Ì]Ì¡°Œƒ O™‘k‡Ó~&hLª48.Ç—iö‰ðP#¿ºÂ« ⱇæ:Èjmh½Dß”ÝÜüPZ¸Ñüä°‡ø-È‹.›¡Ðt!)ŠƒW™ ƒ8¦<¤›ü—\½RÁ6¢ÁDs™&šÎi”ܦ_ïÓÕ1‚ÛÛ&Ƀ3£Veºm×AÍA˜‚ì¦ÜÐnÐö RبÿÀ‡™NÉSŸ±í ç*,óWo{Þ2t’|ìˆã îH<œ–?Ú6U•öÍŠU'-÷y¦k¼*(»ù]T¬Í)î{è´'¨ÄÕ&]–Ô•ÛmšÆ­Ÿ¤‘Ùçègu·ŽÂµ="éh‰È£ ™–´.°UÉ*ÖAÁ•‡Š³¸ŠEî©W¶¢Wƒl²³rð?…ò‚ún›Òš÷NP¸Žâe3ª•Lx†\48 Ä ×fðé¹!{ônÔÃû>æ&ÎqoLofG¿ý Ùøímendstream endobj 5563 0 obj<>/XObject<<>>>>/Annots 2975 0 R>>endobj 5564 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 5566 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ÿê“!½³2L»A™Ü:P0F÷Ïâ80™&gÉþ{bÞÖ<ù£O‡Ód2Æ7p;N‡çüèýìà·ƒ¿;ͼ,endstream endobj 5567 0 obj<>/XObject<<>>>>>>endobj 5568 0 obj<>stream x­V]oÛ6}÷¯¸/EdÀ¦m)Q’{X×zëK‹mòb` %Êb'‘šHÍ1Šý÷ÝKŠòG6]‹DQ÷ãðœsõ÷hsü[@’Ò/«G¯V£9›ãâð¯ÝÂly ‹9¬ Ü›ÞãEîžãE=”B‡º«¬œòvÛÕBY°ûFÔ¼i …T"Ÿ€-„ ¯ð®Úñ½’«¼9p\#Õ¶ð{·ÙƒÞ|™e°*1¯*½3.JÑ©ÌJ­Æ«£Ùëïk›.b¬-Êt§¬êŽÀjØèŒÏShm)me& Ô;ºjkKhxËkaEKèZZ+òõø‡ðŽ%i³$Á›ò!;Ñá|¿KÉÒ4­¬Å…ª{ú’OŽI Ð{%ðL4t"Ä`&Ñ •mW h­ãI¿‹`;+z!­P¹_ Ù"äÛÀÏ{Õä$ˆy¸µ<+A‰Ýq $¡îÍ‹™&1(ÂŒm»ÌvhŽˆ’úbðJdczBK3y’ݨ¤äóêÜT:ûËy”éœ ãçq#ÁœV‹Å´†j"ÌM„Ú•(wï’Öˆª8rȯˆ°ÔúË xÙ×ç‰ú̈́쩀jþ47u¹©xÙëæT0èò”îmˆÁëyÏ4gdÅޕɰuòÒ+oÁ[ƒ~„Fæá =Óè̳eðY/”S§MàgÝìIƒ{zª¾¹íÁ±rÖ㪣مSÌÈ­¢)øz èÐÛÞ*+¶8|~$ëé‹uœ©uaq<~ÞR/‡ŸÀ»®ÞˆÖ\ÿiŸ“摟޺@S€š+¾õý£Tqvø @rFDpóÿ!n}$‡àé~‚:ÓzºŸ ŸÝ÷oóãK;/=|ÅJöG„¾Ô;.R‹ìŽV&䃟˜²»ÚŸÒ.º„Ù]ÿÉϯÙMrémÊîhÄýñðö—iÌæðZgîKÌMvŠˆ¥ú½Ó[ÜSß7ó”%1~‹`¸t~Oï¾Y~ýêXØendstream endobj 5569 0 obj<>/XObject<<>>>>>>endobj 5570 0 obj<>stream xÍV]oÛ6}÷¯¸/ÝÔÔ–e;vÒäim—®+¶U@1 À@K”ÍŽ"5‘Jæýï;$õá4E€=, ›—÷žs.ÿÍ(ÁïŒ+÷—•£Wé(‰ öÿê MoºŒ”4Ohõr¯V”æ~UBi=cU%w$”¥ÏôNY¾á5}¹¦é”^ëjGLJ?iw/YeÈênÙóôÓ(¡É qòãŒé}S®¿o­í¶ JLåí6zsN&(`2_´Dé–SŬåµ2TèšÂj@âW·ù†ˆ°PJ}O› +9Õ䆨ÃÚ’bÄtƒÓøß¬¬$¿êN@žÌçñbÈ09Ó­š}Œ»‘€uà¥{(RsÁ½²-«élÝc)’«Û縷½‰‚×aΈ8&CøŸiò%Voš’+kBâ/i6À]và.VñE|No¸äV¨ 1z w!çX‡RèVPÆ­9ån/Ïi½##Õ#…P.šÒ”éœ?ÈöøÛH¸‚AÖ@PÉY F¶Ø9`깓c’ZmÆd¶º~,ÌÁºoĤö2¯[>ÂÙ€û@ÓÌÕ»]墿™wœü4 ¶•®2Ú`ZùÁ§éãõþÆK}çІ±O0ì7uulºo×!ýåÃB}¯m'“¡ÀBeœ>||÷ö{ãˆÁÀO°fËî„»D?&T OW÷8€øX4*‡J”e’âO~ìm!ƒ‡DÐJ-ÖÚ-³>jTcØZö’ƒ"ò¨QpC;Ý£{¡Rüž ·¤‹áFDYò\0ËAsVÀ“¼ÃØtÅkf…Vq€©“œÏÊäŶ¤_$˸«h?ò!1öô–¶œÏy&Yˆoé¹1€'À8ÝFê5`2R{‡Á£×/^x§1{ßuîÓÏ!ˆ1OáÖ‰Ôè³Ë¿w1¢8ö ô#_ÚyX;€p¶ç“!có“½>ÌÔ €g\…èÙáÑaÑI„Óó‰º Bë¾…|‰¯à¸‡uTÍZŠÌ[ÿ^.0Ö¦Œu £ïÂç?jSæ ü×ÓFw€¯ù­Ãò£c ?ÇžàÔ4?na½™Z¿7P¡ŒÈ=·û€ }ùè% ³qlâE_‚`¬€ì@-Žfí„€NÌXãšÜmô©^’k[F#ê/Þ«ë'}Ïï\§r;ÛË# YÂÍ1"uÖÖ!©‰e™Æ©1¥[@é"º­ð ×H‚Hö:{=øBª¯^ j¨9üw¯?ä:Z‡Ð±¹A#WWé‡.Åô;\ €Éœà¨h")܆Ãìñ7ËŽMÏœž»\élÒ½lÛÅìò<^.–´º\ƳðnrTšÌã„ÞèÌ¿V¼ºmàsX=¹Šõæ¹ðOÕ“‡Ê2YÅ‹9^Éð–Õ,qûLG¿ŽþÌ@Vendstream endobj 5571 0 obj<>/XObject<<>>>>>>endobj 5572 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å,¦Á +þíî5´Í§ïòÑ1t ‡W`±QY¦öÌ)C? ÞZ¤Re¤6 Ž¶±0”Ëz«×%±(¸;ܰ+œ3>s•ì2ya]‚éOãò‘túYZ;p#ŸÃãìêRÆ©Èè^T©¸Í$RÌcyló£áˇ3.¥ùD­_ÎKêl¾@¥ñziR`sB[•%\¿{‘íP-Åu‰mòdbú¤ß\î‡óŸêâT?äÜÀO°_sÛ£ôM‚¶î@e'û ú Í4{QCHWñ󥫑ÑFE 0Ü®Ž|ÇxóYšŒÑ´4)ÝPY©û4‘Éúì3˜ÜÔOhrÅD\ïP¦KJD-ø墎·mîÆáÓ‰ o²O£kÞ\pBskî_7e_êp2 †‹)äsÜôÈÊÉ â¾²Æ\a˜!ö¹*𦒎9ö(D,0¼”âTk”y¼X´x (ÞéZåéÄnû‰ùjøa¢!v"IRžD³jŽ&›UDíY1 Ø»üVVí¡7u3c®53²Iѵ_>ʃ-ï …p C»ÛÛ³~Î4Ì(ëC,düç j ‹Mæ%Þz¥à[6~Íø¿W¦NsìS†²Râ=Ðô¬F=<Y#í^ñŒè-¿ÿ? å†öœæed”åÖ»²TUM ý˜)¹9Œ$$ªHÙ 8Ç´“ñÍÖC,;ZJÚo±$¸ÌºÄ®D¬kî4;I¸ØT:6;à+ªýXÌCÎËJÆèï"–/xí߬þzsuùÓÕåÏ7î«WWo]¡½e½^þ ‘¿yó(ñô=¾H_ÐÐ[k|›4E çã`2šÐtA  ²ï~„¯?ªØ,$³ÓEC{º?³-i–ô„ÞdøLi&5ÀnY³¬'C,|ðfž†!c\­N~=ù-Fjendstream endobj 5573 0 obj<>/XObject<<>>>>/Annots 2978 0 R>>endobj 5574 0 obj<>stream xXÛnÛF}×W Ô• ‹u¡¬¶yH(Há8h¬ /‚¹”˜ð¢ðbG-úï=³»¤(zÓ¤E ]8;·33gGùÔsiŒ.M=þó“ÞØãIó’ïh‚o4wgxu§ü:v®(—ö”d¶\83õÌåJàΧΔl’–Jǘ;ŸÁ®ö3õ–m?Zd37ŸLqÐ&iëtÌ™æp׉AKKgbOÈ"i©tŒÕ°ŸNFd1g²HÚ:s&†…³°'ä¹êÌév+d‘hcJ`OhÁ~:˜à,æLBI[§cNÇ0_:s{B³‰³´'d‘hcJ`OHùéD`‚³˜3 Y$mŽ9ƒ‹éÄ %î}k…,’–JÇXûéD`Ds&!‹¤­Ó1gb˜bR:1hÉØs<{BIK¥c¬Ž€ýt"0"‹9“EÒÖé˜;QžËä÷ö%3!¹îy$äÍñ¦¿Ät×k}MÈ/yðÔIþºîV¨ó˜Ö!¸Õ[âC,Æ0»ö«,§òxþ^ú£twIå^Ò—îE‰m,)*HÄâˆ7*¢äÀÒRî$÷¢dy!K*3ð6Œ)™°EYJ{ ƒ9KÒ §`ágy.}œF`Ž‘Nf,}Ò1«à"ŒRI©| ~”öÕÁD”¥Ñ بl$Ò€ÕO X=§Cžír‘PUÈ‚²{™Ç™d@ ‚Í‚âR9)öYH¾Èj‡¡Å1B‹ZR¿®žçxzá d)¢n3d^îY;Ù°ª±(PQ›M©¿6úœ½1ñQG¹­–M=‡—©ç,·\<ÎsÄúðu–ÂdYàv,«²ù¬¡o4òþ_#ãÁk†r3ˆBž’ûc±¹`×öÀÞsÝEÆE~Y¡2׈Rð)JD š -ÅÎLǨ}ÁxüeëEíREPèåÂÌ#›ý6‡§ºó…3^z  YÝ fœfÔ"Q}u¤8áGg™Á0ªEâÓ ÛÌ\Ý úÃáV†Ì"=‚pxXU‚{²òý ä8´fÁh•ño4ÍòDÄñìèË¢ùñ’¶ $ÚíKô‡V1SÏpÐ Qô'BEÆ‘/˜àÀ^|;ÈÏ‚Iÿ'vòÅñèóÑôFæöÝÍ ÜÙQI4´¯FïÄqÃ!?r÷ôr™þPRQY^¢«7ƒ8újØ\`nP­•#FÞb‚Lí'F…²Oè«.-v‚¢ò÷„ü ׋º˜¯¿»$†|oßËøx ȉ'˜ÓÕ׫Î)ªé±Ñ7&›Ä¼ž=\hê1å™´7æ*V˜ãçÑÿÍÁ;”çNøÑ‹uï÷Þ?;³ endstream endobj 5575 0 obj<>/XObject<<>>>>>>endobj 5576 0 obj<>stream x•WksÚFýî_q‡q:˜ñÓŽ?´©ÉL›NÚ~a&³ˆäHZU»2¦þ÷ž»»ÔGÛ€îîÙs_ç.¿_ ¨ÿMù'L®úAOª?ù–†øDã)ÿÜMƒ!¬w”KÚ\9ËxŒí³Á o¼a‚·ãF ƒYÃØ4˜ûsFƒ)Î89Çšà&ÃQ…ÇËO)÷\ÀÙ=^ßäÐpâç‚55Ày‡,ÃþqÏœå0 fÍõgò|ëP£…Á¬¡Ù!„|ö5Ày‡,Þ!k9sè»ÅUï±OwÁˆ Mçƒ`:Ñb ?ú¨ÐEØ&üûøÛ»·ŸäK(3©tÙ¶Ÿq!ò\å·­‡—L†F®)S:2ѳ¤g¶­åÍ77‹§«>u@[í¯Úgû©÷8'6o¨ ]xîH´GÓ`à—Z"ߪ´È2™ˆŒ1zc¿‹÷Œ}±“K)ÒThP3 ]cŠoËv”ÞRZ$–¾ï/oÀÍPÉ%6`xúgm?Ñõ€îé+6Ö ª,'Ïqs‹$‹-ç÷¾…#„O;#(ÌãÁçgõzô-²œ®Éíqc p÷:—y[¡5;²E4^à5øË­ÌñŠ ¡’B¡åòæÜpïÑ=£e»„¾¥wïÃ÷¿ü¸lw® zÞD¾iÊò?kn‚Šcµgn‰¸ÊŒFÅKÏ"Š9Q“ãŒ÷gh¢©}E½“ldušç_xþÁù®VOhwßN®Ä ŽZ‰Eº-ÄÖáv˽x &¶¦®mæ/€™´Ê£m”‚««VH†0˵åÙˆ§I*yøIm¨lÉ^"ÍN­i%9,®=ì°?†“)4j\€ù„j-IYGÞG<¬Pl|$VãT ËéóÃæoù¹AÕĿ̚EÂÌ;¡¤p¤µ:Ô¨Øz=™+ÁŒ‰½Eë $ ƒ¥çeP—œIs”–⋉šè ©ç):Ó=ý Ó­Ù-ÛN7 „TCõƒÁŽpëá²­£?¤ÚØçË›ŽƒkÔQn2Kªÿˆú±c=©tœ,¾ÈþÝ^ÒPï†qu¼¹4HwCa¦Zæ\IhMN“L®ÁÏ+ä–ž ä`%Ñ7,`©ÉôT¥z%ÂÏÜÈ t®ÙöTzm…ÇJ U8‰ïô éá¡>Xl^NzûÚ7ãnÛ&@– éîV– l ™în§mÈg<—-À-ƒNªßtÄJ冲WC\ðd|ø©˜S+•{ÎÑÿ’Šóµ•T€:büä/}î~Æu>W2÷ nšcå¤|_¸m ÐåMu-ËN¥D& W+kYá’·³³ŽËöt6øKºOTzñ=|,oï,Ê[›œGeç¢A×2–¸ _lm÷ñ´Á·¢q0Mhz7Ã<µ7rþ¦Ðâ«Î÷*´÷lÁ×cJß­îÎ\ÿyŸR+ÜÉðs-3|+á+1ßA¦ƒïX\ý|õ7«Š,endstream endobj 5577 0 obj<>/XObject<<>>>>/Annots 2980 0 R>>endobj 5578 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ªqNÃ(°³R–K ZϨ#›·? Þ/™gò‰É”jŒLÈ*ŠU½¥DXA)¸o·‰º“Ä@¢ÐR$[L¬ÖR[¬Ê«º±´E#ýc aKÁ)obÛhI-Ð>X>`óXÅÖï(jFÖe`¬$´Ûn¡q,*ÇŽ©eœ‹‚ba¤ iâägQÖ…üª…q,ÓþhŽÇí±w¬A”J¿N~û‡&1¥TkÉ껦sé5M®LþEªt`Ù3Z<"™6r-´DØ•Œ¥1Bo™úÎíSé1ý~ÿá—ï÷Ô×Z­óD‚ H$\39Ç]ÊÊ ›«Ê©Èñf®»zÃèô(nilëâE‘ él-^«0¦//§êNï„d’z%-¢Z5b…wEo]\ÄÂÆ™4íß;{æKÇÙG*…óa­À4gm¼K{®óŸ'ª¨”1L'7¥Óžó¦ü˜¡ Lk‰Ò‹ T1¶Æ¾ûØ­—ŒM^˜>Y{=³œ-‹³³læ jè|µãi¿og¥ Jk°âÌnÇÙÓEÔ™¬Åù*³ÈM’§©Ôð >’hÍ ƒ‚,¡`œE/á® ¦¸mýæàÂï+Ö*Oh)\‚h‘QZÇ@^ê¾3¸®*ZJ25ÍW¬cm%Ñ%¾Lc•HŒjsí@Ñnˆ¯¾ƒÌºËQ·ÄÄ»z e¡âß±IYëÜ8›ÌÜ¥¼/ŒÓÂf-tÐùà3wæi“dqcRÞñâèóç0‚1NZKÛÕ£D.O·ú·ìñÿŒg³çÞÅp3»ëÚ™áÝ$¼ßR4v½Ë ?B‡ýƒŠ›ýuÊzÅ-ÞÎîOÛ>±ë¾îé Íeª¥ô¼òv€=GhéÑpDà ïðnÞû¹÷7 ’endstream endobj 5579 0 obj<>/XObject<<>>>>/Annots 2983 0 R>>endobj 5580 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’˜d.WÍ /[|´iËúÃ^îÄ^‡À\™ÚfØNF!¡Ùï›®Äek6êz\Öc«ãvâ¥\öJÓίщä8‘ͦ—¸Žå®¬DKCí¸ú#™ƒèÔÂãBÅq$x•Ož¶›‰M¤¬oÎ0±~·£Ò6›QÁhKq[ɾ"Š;¹à¥NJÃ9*ÎÔÿÈadÐ8T‰ó¶*ÄýN«ÓKƒïšýÐÖ2WS"Ú-níJÔÛAl5ïÔÆN£E€ï¤Äð¬;ìj±“O¨¯ñ&-‘]Û ]Xp+Õ–lÅ~/sŠbY£ ê'œ?´Ûa'qš¿‘äÕѪc–šñf‚°o›»2—ùÍÙiahñŸ(£Eë~À•¹„\ô‚žÂÍØ¯ œOÜÐ4˜Ù6jø¬?T§Ù»®ÜÖ´Æ€5Õ‘™øûöE©ÊÄ®«ÚT«œã~ØÈ«|kkd]‰ ¸ïdµ1%bmb¥øÓÊ2›Ù]g#=<Ö˜šB×™}ËxçØÀW=Ãñ—o² ·ÖOzƼ±3ßl8ôW½}"F¿ø—½â%-ãe½ú';ÜYS~U¢qO[åÆníÿÐ&þ’ÎèÏP'úI“úÇžÁ9Ååж¸›ªÃ¹2J{¬’]ÔØ‘y:ÖÝ€=@«/lT¦í_”TÓ2©‡à>Vþöà3“s¸%BBµ¡wMN1~ì?¨´›YTe âc›Fv"ØŸ=ß`ƒ6àÑ«µ–w2€U1 kŠc?ë„YJm5ÒSzAý©Y«[ußÊmìÓÓ9E?ô© ŒUCÞ»:z< ±)—Lz2‹Rºõj5úyô'm#endstream endobj 5581 0 obj<>/XObject<<>>>>/Annots 2985 0 R>>endobj 5582 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áéš»Ä[E~ìG~±4kDÒU ocÝc- ^_ì>C?õçËúÞ}WãÎö…(;V7U"Ú6+ïXVŽP¬Å­hØ¡/“.«ÊÖWp ¶A´aÏrÁæKD~…§ÔûIsî=Û–KÒÂIò!õ ¿#Îg0FÜE^‹ælêŽýmfì¼mŸw쳎ï½ArÉÞ}ü}ùæÝnïÙ_übAü£lB0—6¯ü(ŠÉšÝ ½Êóê|ok‘d>/XObject<<>>>>>>endobj 5584 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çΟ7E¸­bsQ íÆ5w‚ÇYÿ¼ Só˜U•¡ XyìÏùbUTA ‘»à!4efY~o6Q®K\=DåN˜g·¿áR12¤e›Åqv ¶Ç<'Á#¥LP¾ŠùqΚ<-)ükÒfW…I‚ôÑ$ʦ~›UéÇ)šè«ÊÁÀü’gwy$™òÙÕ<0·Yvnç7ÁC´Õ, PÀz™nòð`ÞUi9Zž‘gˆòs™š`³‰¨ZÎÍ!4qT”&ü½ŠPaZ¶Èr©\}¾ü µÒ°Àý»h½cÝцré]Ü…& «2Gu®³ô!Ì €›åÇÞQš´T¤Žvƒüæ& \¢»#fQí÷YŽâXžÌå–Ïʻ̹¬3[<àÁŽÛ(†‘êûű-‹öHª¸Œö°Ö|!%*MTtè ²$ á±áXE­ï©H¨|%BsQZ”a°©‹; Ê¥ÀEßœ6È»¬Š7fÆ{‘ðá°P€VJ*µC&ÎJGÛ¢xqªë<+P;O”Ø6EçpÕ4ç,}ƒá÷åQÔÿ˜™pü(åM_\L­+f’7vÑIôïŒjåÓÍ«Ò=ÎÄy|qE©"ıîü¡3›Áîa>ÌGÎÔã2ûpí~¸ùÛS Õ‹ŽÒR*ÑcÍð˜^ƒ­.ò,Y‘}€拽žH]{]÷‹èKZ%„ö #ªJˆÆÐOGÓ…ß~qù%x}3ï¢.Û‡šS ¥æÒòçæÑb¼~÷Éåë]Sß0 Ÿª664â¾&)¿]e¾Jûd¬çߊùÁ~)sŒ«è_¡u87>¬êchç—8<§ _•9ʲK“Õ*Hlã,(‰Ær°É*ì¡. ¿{¨ö–æÖsBnæ#U’>£â¼{ü È×_×ÝGP/.꺢dG‹1jïê¶|m ¸š'ÿVKJ]ÉM÷¼ óÇÛÙv²ø"º¬ò”ç/Ñfƒœó5ž™Í̤͛Y‰9]•µ#:«@¼Á(J7Ñ‹ÐÕzÝÁ´Ëzs ®>þÜå> 1ùyGC—Kpò ÉÅn"bx ÀîË!\—¹C“G Î<¤™+4²hé†yŽ–K@ ££3ŽîÃ?×”æxç•!¾e÷<îþ?ZPêèå™­;lê¸ì^N˜Ê€ÛÐà’ù«ájxYüÄ+[§ƒÓ(ÝWHÝŸNåÙ_(bË)ÚðìuY|üy9 `ûwï>#Èá—u¸§­·ÚQ¼”¾ÌïÞ’8q>çBY]dy‚¿F^¬Ñ<;uVô0óìœ%uÏΟÕÏA¸zä4ð S&"}¾ÿéðâO­Ç=®Ù!¾MZÌø1†2…ùéb-ª$Ì£µäÍû#?a4­&IƒÇrðëË÷7o±ÜÒÒδƒÜޚ̈́ÑõC°«Tž‰ ¸ù~µïêêJÖÁw©©½8"Éúáy¥Ñá¼ÿøá§ï<òiއ>|ã|Ÿ”ü ü&cM ›ÿ#RíM§ÔQUÌÿÇ Ò‡Úd–º,ŸoW997yüv™sœçc¥ ±Ñø¼â¾åuowÚ"$´çõ •ãqj»Rë3K@V·»Æþ®£‹?ž·ïÊÝq6OvÓQŽÞ¼zßäHá|ÜÂíù‰¼Øa"±E”Dx#”‘Mw,¼1ù¾ñ'‹‘ï4‹{èâ%øM¶ÆÈI±¤00É òð×*oj†3Ú¼[ñ(ËãøVJ7O1r<¼ØÓ€ò]z{}ò÷“ÿ»—•:endstream endobj 5585 0 obj<>/XObject<<>>>>>>endobj 5586 0 obj<>stream xÕWaoÛ6ýî_q•ÂV'qÓ/2Ì-tÁê¸+ h‰¶¹J¤FRq¼_¿GQ’%5¶“¦C1$H ëxº{÷îÝñïÞ) ñsJgc÷¥½_g½a8Ä—õ½¢×ïÞÒéfKØŽßâC\<LJ(8‡oÂËðŒ~g‘V†–JÓŸW>MNfõ^¿ƒóòà`tŽƒÁôv6½¾y÷ar3ŒÕóox^ކTZ&\®ìšÔ’ìšÓ4_l öB®ÚžîÄé¨éûÙôˆïL i¹&«JŸø§4[ñý¾¯¦Ó«/>l¦Ÿ6ìÙöˆçyPxü±ŒíƒÄ=‹„ݶ@yŠ÷»’ƒq7 )<¶©Ð@»¬ü9M"žY¡¤içXWò^‰˜ôâN3aø<(èA¼:Õ§G-Ek¦éÕ2µ} Ãp?/¦Î‹!&w.Bš"+qÏ¥#`Êl‹*ã’[Á{Û~O™ 1½ÊS.-ükNI2Í-‰Úð±c‘v9ºñaÛ°\Ç’Y–̃ïËžŠÓ;ú>§B2ëÒp“iqcBºQHÐD9§E¢¢¯>µˆ% û´È-qird[>݈$¡'oÑ€Ö%T÷ÚÿæE¾z.ȳJЬ$‰4å±`–'[ H*Zƒ= ׯ5$“(¥-h²À—q³ÿä)}Q9™µÊ“¸¨9RÐñ\F®§IId+^É8À‰´ ‚fã™2<>Îu³5wK&:tOͪÛ7;ý¯úœ²„YG·Éx$–"Ú±Ò¡ÁíLɸ ½*ê•0ÈÉW©6’ð^ËSâZ+Ý÷ ì*ꥢ9Nv |ëV#é@+{)sÒV4X¥móàÕBÅÛùIùÅü¤ï‡¢ÓS~†Qyª2«TÖ­Škwt?Z“å–—¼ËÆÅÑI§ƒº;áÞÓ9Òµ#€ÿ¶éÁ­û™Ž'ÜΉF‰@¦Bø!6€Þq¦ˆ´ûZE×M!¹už9óX¬Þ¨Š²¡»u±¼ÞUµyb­ÊCU­v%å?µ0Ÿ×ðhÂÚ%•mMEj ¿tŸÔËA'¶Äøé–ç1îA:œY=G"•f‰°û5¤®&šå‘}j—a0“k±<±?©oÊåÂæZ”GþõÂRáÆ1‚*TC£Þ„h]õ½²j{@µ…ƒÎm+ß®Èh»/‚e¯ÓìHïb?Ö3Í‹µÊµ"—QâT7#@4G¾:<Ûrìq)ï¡ül‘p xmTò~½t&³ÞÇÞ¿:îŠþendstream endobj 5587 0 obj<>/XObject<<>>>>>>endobj 5588 0 obj<>stream x­W]oÛF|÷¯Ø‡¥d‹ú²e® 8©H¿%EQƉä1U8®±êx×J¦q IÜxlD^$Ò$¿Ê¨dݲ4YrÛ,!ûîmTEP¤¡†¯öˆ¢`R›¸qj7kFäP’×TH?•©U‹TÒR¤\$™XÓTº ¡0•óúLÜJ#Öûoåq®\Nï—÷‹o)äNÚÒäE³´¬)e9JÓ¿ªE8†›a+]¦¨fG¤DÍ;({ˆ»›¨OUqá ðËj³ ªTT¤oRi‡ VØ¥P©˜‚L,‰ÜGÆûÉÚHÛgYÖb™m¿ñ¤U½š´ŽÈG#s@ëŸçn· «¾@ôÊÍÊÁ~ VEãÙ|T¾Ç±Ã1;b­¡æFØ\À9¨Íà'/76ÒÕ‹2ùViX©4E¦Ùµ_rΣ±×Wñ¶Ík7’G&ý^ßTÝŠ ~L…DIâ¡*¯& ¼øw—ÝÞý9ã‹„eçÃÎJ~. µ­˜=ÁÂèè T*q…½?ñ×_J…¶Ü•›ßw;åè¼xÝ#ìÜèÕ^Üÿ,wÀó°ÐãÐJ4"Τk]®ÇÓx½@k]ÐõW‘Á÷Ru­+tñã9J uv¬Ð·ÊØ ‰\Á^üb×5ü†EH7èf™F“®¿>¢µ.)S³¹¥Të‚Ù°«×ß×¶´­ ‚Ö5HÆöõ6²Œ•2mj+®ïËøGܨÝm1¨`ZJc¹ã ?Úç\ÃÚ;g Ž=WpÄ,C7‚Â`kãÍD¾¦·üffD†)É7ZÖ ¦*>­ž—qE¤*‡×Ì­æ*bçT¥›Í*ÅÆusÁúm>6—þùãû÷ÛX‘©\ð8äÇ,ä°D§©^1œ¿ß¾p&" þŒ£õŠ'B7ì]9FÊKäˆðæ]²õs·lÖÿ³¤„Ù˜ýY8¬fÓÎ`‡ø¯3—|¼™-ù"œ-Ì’qÐí43)Ó´ðˆÂb|ª+¾í± )‘¢µÎ㘷Ãkëe8 T>iÕ™¥ªc|Q·Mï¤!J~¯3¯Šv·Ïý¼PKº¤»«»»«?&Á+•/J;iu~ÀŽ b¢I]4vyÕÇz8—àeœ€ƒAÀ›ö'­6?hL­>vÖjîò{¢ ¼PB’ì[¬J‰Â[Ó~ßúÚ kž½ÞïÜC;°ªËÞ)úÞÝO‡‡˜²¬9<ú&©ŽÖªÐ¼¢~qb nðgAñ­Ú»ðˆ^õÿT]V‘ŸxûÕ4vœšìþ»C,¯æº¸àÔ^£äÏTœõÊm½E©ÄèIå•>?';DÄêC L%ñ?~6y†^ÙÇ’2÷öÈ“CëÞœU?.úgÇáÉð„F§ý°ïÕÏ…Ø„=úQGî`kåe¨Ý9õB­~Ã¥#¹à0çÓ'½Q8àÇ!JfÔ?ç¥×ãƒßþ‹Þ’endstream endobj 5589 0 obj<>/XObject<<>>>>>>endobj 5590 0 obj<>stream xÅWaoÛ6ýž_q0XMmE¶S§]Ñ]Ût-º[½öC] ´DÙ\$Q%%»Æ°ÿ¾w¤$Gv€öÛ ±Ä#÷îÝ»ó—³ Eø™Ðlοq~öóâ, #¼ìþ˜5]ÞDô8œÑ"¥iDó'“p>¿¦Eâ¬"ZÄÁyµ/e.Êe)…Y/P¼†..蟋¿Ï"O`™Dl± –_‡á“僧=£›'xÖËKúMïHP%mEi]Ä•ÒEoù*2UH:ï;SEE¥Áß¿p%Ûº¼ÀÃ~û¶Dl­èEýËí6*“´ xß'õùž­äݤË`àŒÎ“Ï8èÜ.—Å`DjÔí<>^><~Ù†ß"fdU›‚Tß®ouî/o®ˆw¥4vãé¬ÉTðq# ª6ÊR®“ÑàS¬ó%#,HÚQ–2¡ÂTu]J#< K©Î2½³ô#c‡ìiÎf`Hù¥VFÒð9Ðö²Äo»ùø4x)¶r0üªnÝ?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¼ho.šÎœåžïb¥QG¥Ô¨NÄ»U•ÈÈVX´•Ší±ž9éìm«U‚x«¼ë=6q#ÑZ‘ï`H« ¨<(DUµª!˜#.ÕÎè¥ÈïØèÂ1À6Mï )G’ÍÕÞzQX!Å 9©Ñ¹x2û¸:˜ø5+UÈu¾?A¦1NÐÜL†ë¦»fßÓõ#7F&èmm’\§&î$ÓaHÏ~¢éutºŽ"r‹WÓþV/ó0zúºÐŽv>ã(Ú[ϼBzÅÜUšNL™Ö`S ±@‰yx¾§,64¢ ôY6¨sù8òY¬™@R« †˜6ôFy½H[Ì Þ×¼-Á;¤ð+mFG–àXrdIJlçtdˆ¹„&à‚«²Cq„ôNr©ƒôh;Um\0+a¿ÉÿÃl§ ¸XßEtOþÝùºHk;Õ,ƒÏßýùŠ9i1Ÿ_jDÝëö#¢=™¹îwfݸ³`iððtJØÆq„5:nÅ·’YféýÇ7¯(´ÃTÔÈ„$Þ ûNÐ(‘1Î Œ3Gr ZO¥Š¹‰© •\bQ-Gœa¦íÐh0—ùQ¢í P<[ùyBÉÄó÷ºãœì¬½›ÿ“¸?ô½f3ÿpë´j]š¨>E,xƒ>R£ýøÀô;] (t :‡™4öl©´Ï`W_¾G§µm<\ÔïÖņ§\`¬14ðÕ»iÛ´î¦ÖÕÊa˜ëCí3Ó¾k¢`è|M&­D)¸Â\b, #÷9IS[ G¡œ¨„ú–ê›pÙyÊÝ«%}ãÅ–È”¿OñĘÑVŧ‰ûw›ŒBbÕq½ƒEÛÍ\~EýxF™Ù½aà~v\¥÷Ì+#ÊœvÐa &6t^ßâûÏ”¢jú÷ãFp§ÑUøhöˆæ#?2­ÆÓ0¢—:v“´+Z-×ÛŽ¯½,ùY3¬éÆl7kúâbGÉö›-ð(š‡³)fU šóiį^-Î~?ûT~¯¦endstream endobj 5591 0 obj<>/XObject<<>>>>>>endobj 5592 0 obj<>stream xíXÛnÛF}×W ¦‰ÖŖݺ-:qcÀ5Ú˜i_+r)mLr•]ÒŠZôß{fyÑ¥V}è%±aÅË™á\Ι™õûÎøÒxÂßQÖù&è üÛfFÇW:÷Ç$4Ðäó¡?™œQ;©‘÷Y±ZÈL,BOåa—ø£ \…QÓ²¶G‘ÎmAÑ\::ÊE¶>cÑ£G‘–Ò†Ýnð®3 þVc`èÇ7o_у\Ù{aLXZõ¨=nþ xñ/¬|5Üp·¶u9—ÑÃ}7Cï@勲èQpÿúÅÝë°{QiµAöe­ökóˆ=JÈ=ëø½M£•ïÇW'T‰z¤,½+´ LDF#˜X&*—1‚ b.éM9]Ñ\ŠXJTÊñã\ M:O”Élõ‹:I˜Y™I΀%8‘6FFq.H%MGœ@Å’ù!B9É‘\Jç´TiJSIF(+c¿V°J€—åò ûÀï)4Ų&ƒç4×K“¯¸ }W3Ze,<“´0Ò:çªèæÂÎ/h)ñ2a­šñ1 æe6EÀ°Ë!N¤¨†Ï–óm°¡·]ï`X´©»>lß‚RU©$`/zX‘Uy„_êt_Ò‹ï¯)Ö’ó—õ£Š%”å4U%e¹%ÚÐûRš•ÊgNÛªŸ%']Ö#àzËÝ¥¤YžIÜè2¡…R¢Â‘HÓÆ ëÚÊýI‹¶½e²˜ë˜bÅåMW¨`̸x”¦`cª°„|—)’§áÔ%UÀf‡Tfà®IW°/¹5£û£‘?ƒßñ?‹È- ÿ6¹¶‡ÀOÐþ`H_ÑíÛïF×·Aè™é=õX7œ!UÒä¡÷Œëð,ìöhЃÒÍMØý˜æÐÀp§9ÜiÊAàâ?5ôEmkôé–é±\¢5 ˜*W…)㕬DÙcWðÇ@¤êµm7°Üo}é;éb©é’KÌÉsMmS¬\kÑ»áwAÂ8³±{u!f (¨3j2p?vU}›£3§ÁøþÏ"l ²žBíÈ¡öæÆM¦qÄD8o>Üò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ÝæÇÿÌéR§)®4 âæŠçÆYu±bÕÓÁÄð‡ \H&#wÙ{t~èüv×âendstream endobj 5593 0 obj<>/XObject<<>>>>>>endobj 5594 0 obj<>stream xÕWaSÛFýî_±Ã¸S™ØB–À¤MÛJq eÚ $©:Ì!í –Î9I·ÓÿÞ·:ÉØÆ`𤠲O»{{»OoŸ>´úäá·OÁ€ÿâ´õcØò\‹‹fL{Cž»…#ò=|ÓwƒC “ÊÊ£0v¨úiC‘£è{ò^¢ï¨ÝÇõÙ³¨CuÂ÷­½a¿‰³ïQ¯×Ĺ–s8˜«Kaæ—2+Ì<âµßM—TÔyÁ®½;»јZljÈ'°–£Èi«lV]B€Úq)÷Å–6Âßwemu¥ú¶7Ü'ÎsD=½çõÑPÓ•¤\Œd—>âÃD—Ó„ÄX¨ŒÊ\R1‘dÏŒúVœã‰Œ¯/ÃùLFNÔ±7›è¥"6š M±ÎFʤˆ Š* WHå$Öã]Feãõ8"K*/”§”ý†ê6+Ó5¿o›dïÝó}7ÐöÄùª@Ö©˜¡»ºÉ—‚2Q ƒ«²y—³Î Š'ÂÐîn&Ò»56Ý­²Éí©—j9oÎÞœp¿š†ÃZui±Ü|D€FKþDËEmº^¾:ºxU`źÝdÎßü쟞‡‘ÐÊ,Óér°†„¥É"g'WʨÓ%¯ §³³¨³1¦_Å<;«€ºº]ðà-5B‘Îäm<Q›ãFN]R¥HTÇìµË™iàÝÞÜœ"ðö¶W»›ýqÔ‡œ›– Ķ:±éjî—‚h;¬TŽQÆývf¸çöT^ØÀEË`Âî] //Â×§ç/f¡eìÌ.ÃÓß±ÿ˜†*"È'?7ÒT„öy]^ÍI_½—q‘š b™Heè˜ä‡R!O-T‘ÚTl•ÂŽti³øWÌóÿ'/,we+|yN¨ž\&ŒõÇ z 7ÝØÆŸËŸÁ_˜þ% |<Öˆc2›žýGÌ7?÷ ~ ®mÿwõ8ÍNî·<¡)L¥w†¹3¶*¥X—ÅÐÂf[¨eUÆ­~\Ö¼“_ƒ2]P¢3IsY¸t¡²X2Ï@×$ë"¤J÷ H'™C (°sª†—(¬2JeªÍÜdD€¬þ4b êbM¤0c­Û¡åC3.S&9&Hváø,e2‰C ·™Ñ7*‘U±6Fæ3%S´32R 3Þ¡Zó°1¯!I²:óœÕê3Ô ê,ÓÍ­©×. µ)J($É]L`Q‡[I¦’uST[Š\IÔAÓG£ ùTÖ­sÅpÿtIfµù£Ô8,ªs£UB,Ú~¸G‚u£Ç‘v4’qçÑôÁ‘·"M!«EŽÞÁ W¥Í‹v°¡uc#j… P¢¶ˆ"o ™åJg£ˆPç#]bÂa¬-àÕhñNìfùžÁÄÜã7 ´þìe0I±uÆïN_R¢r«±§kaù¼†¯ïí»Á Œ96ïù®G?鸂¥(àÃ.x«°–½Cû: ÜC·ß§c=bOF$2²Xæ£â$ÙõÀ¸×7l0ð}^: [¿¶þËÿâ,endstream endobj 5595 0 obj<>/XObject<<>>>>>>endobj 5596 0 obj<>stream x•X]oÛÆ}÷¯˜‡´‰¶¤Äqoq×Nä&®£¤ @X‘+iŠËî’V}‹þ÷ž™%)‘Rì{‘O“»3³gfΜåGC:ï!Ïùw¼>z=9:‹Îð°ùË-éôæ'Žh²ÀÚó‹ š$òþŒ&qo|½ŠðòÖš¬ÐŽV*KR“-'_No^Ыxß`ô"z½q¬¼±™JÓ‡>™‚Öf¹*h®)Ó±ö^¹*,Å6»×® ¼²{¯ÒR{*Vª€{ :#_X§*=<⦿¿}CÅC®“A½ÓéÜi¯³Bpq`‡Ï“ô>š,Ö¼ÑiRøã5œª”6êÁ“Éh³2ñªŽÁS¬2´±¨“¾x]Ø4µ‰aciQf1»òb²ôòj¡Óʵ[X·Æ6ã[¡„32ÿ Ø!/[ì8X,ç›]ln 7í}¾|÷éšìükŸî­Ièä$/\ŸüÆ,gŒÃÌd K'cý‹T-ýô¸‘¤‡]T–9Ý•ó¶«ã"¬>¯âéñÓ¶PÑUp³ˆ& rÒÓ›­Äص0í™HKvžXh8º:¹â·úazÑ5h]ì—åYïw£/:® Lòæ.Z曚¢DûØ™E‡Êse\”NGôvñ¤ öÙ‚ÂÂ:³½÷ŸÞ½Û FJœS‡„q©HÙ²º’Ð &QÊ‹b»Î±dnRS<º¯u˵MÊçH£'»r­öqƒq½:ÔI'´pˆlð_ílžÐ§€vÎ:O:‹mÉ€rOJQWÑÂúÆ—iÁ}ʫƠA³×lµ€þ3Ö9·º8eÐ]?“ÙËÀ÷â±û]½üƤ)ºwSÄÉo5\·y¤öF)d`š—gš#ßHâbÔàæ{…É€·1:\1™•à ╎¿1.ØWñŒNª–ªknÀÍÈ/P‡ð½ÞÜ¢ý0ÿ:í&y”Hì&ë"±C#N£>¹O3½ LRwT`”ˆ~E¡ìµæZÀQ˜×ëíÛɰ·ù |¼÷ñþ…yŒ”ÐÙsÝædÞÍeÂÕ.}µKM@ [ŸV Å£&KL,@lVZÄÁ4 ÜêW¶L1Ô7M°…^\™¼nÑú¼Á§aÿÎFöݤrá´ðž'ƒâå™À[‡¦Ë-AYÈn“ùBñÔC°Kåæj©1æB' P©Üm‘¼ƒTA¡9¶£Íé?Jƒ‰ÉqÛ€Z1ÍŒÏñÁaÆœ`øm”g}¡W‹ðÔÜ¢•`¾uеʖ)&SkñÉîùÈ!Kü÷€é€Z ŠzÚhô9þÝeÖà(Œß‚aª±¯$G™% Ð«çÏ[˜ ÄjɈnW8ðºÓ›ºáz7ó7<«åP/Èa CqnJ_²D"³*‘vоѸVW£h<ÆIp·°öç:\ˆ.=3Y^}ª›ýdzL?b[_’7ùr{=Ëg½OÃéqm e[䨳NIzèlúw(:Yì=«Œ¶%â8:?ŶÞòˆ`xÖ*ÿV¡{T*R ¢¬Ái+ër¬ a9£æéÇ?ζYèd*$Wÿ©Öyªþ‡Ê ZÔˆš@Úé¯V(À³«ßæáÙ°O­ ZYpÿ…2oTb_%Ê£ahù_ª¡ßÊs”xØZW(Xd$Ò<$–WÏxåì£hœZcÆ©ò¾R™ÓÞÉZ¹oÓãº|¦ÇÛ7LFûoj Dw³HýþøxcîÁ_È Ñ>*Y_[0•е0S9^‘XFHN„¨ÅdPÐWX‡nÚœö:®øŒáQÓ¹‡&¸³Œñ¨Dê‚ÀÜYÏ‘ð£†Ñ™Øv$øSS\’öŒ’ƒI ÎF€\«ái]à$ûÿ_jÛ–›è: Ç³~‰;T˜–A64ƒJFKȬpBð¹­‡]gMž˜î½YòPÁ@ž±w÷ï«¡ÜþÐÕ•³ž S¬Ú¸5gÞï›n…÷˜Ã1nîë{NýŽ(+otÑÉ#ȵùa5»À¢´ÔТ&Æcèb¾åU–¹ô›8åSÅfÎFÓ5ÁíöÃðûÌQ>ÓÊn!|'‘1KŒˆ·äiC[Éå%fäZä°PnÁB5ØšP¼Y›T!«°)9ád…ÔqΛüžž’‹L#¨~HôÂn'w³Ï×W“w³É‡Ùݧ×_f—ww—_0%2Y—"o<*ù¿8"‘H[‰€ÐÙH?rÊqšýAHœÞ\T>¼x½¿Ä縟¢a~,ñ£èŒ~±±|ùœTX=xâxì£Ý˳óh<Â;Ȱóј÷_OŽ~;úe°*-endstream endobj 5597 0 obj<>/XObject<<>>>>/Annots 2987 0 R>>endobj 5598 0 obj<>stream xÕWmoÛ6þî_qK“LNmE–%K—nÞ h;GIW@€@KTÌF]Šªçûï;R’_'K·}haÁ¨ãñáéžçŽŸ[=°ð×ÇUW˜¶,ÓÂõ×SË–cí™`;¦)8¶kÚåC×­¥G|çöMgéÝâ1…¾Õ7ÝÅ»¥G|çì£o½€òùÚ[¡‘ˆ;Ø=·à½{1ظ¿ôL×Ý/ÒP-ðBàvpusD81 ˆ˜Ú¾±Ùëçì+õ ¿í·_µ½O- º=œá´/4”\„ ÉóŒ¤ôðI*CGjîˆÞ±LMî£YTâkº‹q¢oÀ+`?)k¼yùüvcU¨!NŠ|숺§D’àƒ “àZŠ"”¾‹0‡fÞ+°ôµÃÖífSмH$bD—«ØþZ°%gš’‰oðBúíf:ò,—ÍaøsÅÉ“A7ÿ}ÌÍu!7ôˆ#þˆÆ*€»ç}PùCÓ¹‹¹_¦³ñ–KÚ9&ÿ(l”ÆHFm¼6*›Ú¡,‡"§°Lû˜:<¤yŽ™™K:É!¢˜ä)˨6!¡,H|ô ¹±à©Ö‰ŠfõÕí¾âŒÇÕÚ$%¡à0er ¤LT8ç\í€BÌ“„OYvW#:¬w³`r×¶MÇA^GÆ{oÜžxï†÷.Þ¼þ †ÃÁGß(úkÌ9ìmlwÔ%£ ä¥T«’$ç0áyÎF æ J$E¬×ÞU•ÛÀc£Yµýüi”[øUØøÚö휴H¤ZZ"°` ªËÂöcÜ~@“1 ï bDzI!;àUÑ{ P ½ƒ@¹@©l’}U>JBB34V_¦\Ìowq¼i^*¡šÄŽ,­‡ÊHÉ!î¶©#µ’0%:sý¦™³ÅžPñš‹ìîz+Éäc^$QS.îaTHˆ8ͳŸ%ð Þ¼¿ù½ÊåZÿ•XŽ ‚ âw:ðëœOØ¡ M#~{suõ›Vô *ç‚^úž{è@åaÝ:ø]ºÇª<#ÞûÆ£¦«ÂX³Î^ÅS[¡à ÛÉ J‰¸ûo!8äÕfoýše¬·ž!€ÿÄ[ÍT,mdVêYbq.‰d!DXFAU·gRù)ÑYúRóÛGi¼¶~ ŸÛÁ@#…”þaZ˜mß(»˜‡éÿö1ßùﳑù_âþ 2«n[ÝÌ`5Æ+å¹Lf@2 t‚E«oÕ‰æ&\Æ0ãL j*VëºËPÅZ÷ëtG›U<úÂT£³d‰EDDOÙ]Í[ žò‘°‘ÀcA¦cŽu]€´À»”£;ª:&†8†4¦BùU}LŽMÃÚ’$Q«©v¼zPÂ3Š'Øé_×<ŠûSÍÆU¹êê¤ú`cèÖj÷ü jñl<(í9{à¸õ‡Ë‹®Ç£SªÔ ÂñL¹ÂƱ´ìî—êê¸æ¾Ùsଠì¡nqnõáFíD ç@ §š½g¹¦cãÑ#ãÚ}5tæµ~ký Íðendstream endobj 5599 0 obj<>/XObject<<>>>>>>endobj 5600 0 obj<>stream x•Wko9ýÞ_qU-j€tÈ£ Ù]±x!«… øP œ'1ÌØƒíi’¿ç^ÏäQ*–¥ÄcŸ{ι7ßO†4À¿!'ü•W'Og'ƒl€wßü’]ýNËì‚f ¬žL/³ Í Y3 YÞO²)=wyˆÞØ%]i¯ÃýÙדGW4Ä"~ð|t‘M§x²÷!ð:oHÙ‚|árZë9Õj©Kïšù–J3÷Ê~%¢ÜU•³T{•G“ëŒ^šm)®4­Õ?U¤÷_½¤¥¶Ú«ˆçø=½‰Úãl ù–ÆpÄ ½PMû´u§&hhmÊ’¬ó•*Ë-~‰Ø-ä–€±©´*b/Z8Oj†`|Ò–|céŒ/sFX‡ƒœÀWÍrÂ#Y¾ÙД:k‘Œ@iÑ›aé¢åŒ roæº`"â w7ÆŽ•ú¦q*i¶‚À):REËa¢÷véN•+šR‡>-+[€Gð]é¸rÓÊreXlKs†® 0&¥8 ©Fѹ’7ï¦U¬Ê}åú\Ð#žúôÑØÂ­å«J..”¥lƒ'ÓUk¾Ü1!¢ cP»ð®ØàJÍt†•F¹ÖrS®(¬Ír¯¸ƒê+<¦7ªªKÝÿÉUºÃž=|(›ˆHÎ Üî$êM³q§êQ6ã¢÷[âéü¡ÐOr:_$ЏäŸ×^Õ,€´Á¡+ÆÙdòX„pÀím.;H° 6Ú£‚1šò—‘yy°Å’ÀÚðCò'Œ°£³!½qQ“¶~Ä.©Pôı0 ×ZíׯF˜ë¥±–àÄ,‚¯ÂGZìå° …½4» še¥BìÐÜÖ&C¤…T ÖÇ1I‡%ƒ:p5ÛG4Õ…ý ŽInÈRH„¦®lœŨ;z:])!Ö»—¶9&¢GN€ÅnK»-–gàN-íV×½½ONg ‡ï,Ñ%:mÄ»u§×÷;9—vzúÈöá”X)V1Ù0½¥¯M@ª!amò‘ãóÒJv×QIø >9k8 ÔÜ”&n;Nÿ'+Ìp#™¯c¹wßSÿ:emýüïgïgï^½}É8¸ö(NÑ{š¾|ªÊw: Ósý…òR(2 ³önéUű,oƒQÞŽe Ñ5ÝÑv¥u‘oœ;½+C ™ZY]"ûcž±–¥S”™ÊÒ§7¯EàÙéÑ~÷´-p`û*Èwh`w7yãs^.ýWLš |lÓÝk»ÇuïT5ÑA'PHzð0gZ¯¾76×É…C›üfÝš;™ß àBÍùÚ¬À®o°9uÀP²díB0s¤ða7`åàha úá­x“ZsaoݨãDš°Å[©+µí˜nTÙè› JÉ•°25÷æ¸B Ø!s 㼃¶¶ù2-$TJe— f AÍÝ“{© ‚:âÏ#$ª¸QhïKÙßÄN ©Có` šDÜA£6J¤#ó}w%èzzŸÖ+“¯ðS1ª|•bLaÂ(ÐÒÓ°žš×hx Éâ÷8BÙ\qH¶âëºq;0àiTªÝÜuØïQ›— ce|LyÇaWàþA•¤$}¶Gm=xÈÁt\<Þ4F=\¥m×d4C–9ÿ/ƒçЖ*Û\ BT+ÓÎY%AD0<©?-Óp'Á´çq?Í5ZÔH¼!ÙÌá*ó”4¯Ú×¾èÓéàns°%0¥ˆƒÓ® [4\?~StÜQ¸“wš“ë&]»à2½Ô±ÇÑdW²ŽŽÔezHwº‘z×éºÚ±£cLÿÑn~ ‰–Œ?;‰I$ÍyÊë6ÿÌj¸î¨máǶç ŠîÉÛ¯_÷é©òh®¼üy}_vÛý·Z´ÑÎ÷9k¿4˜i¥‹æAÍNÎ?¿Í-€`ŒÉd3£Á/HÐó¿ˆ/ttC¢,kµ3m 5œ^d—ãKš<ždCæØóç£lÀlöÃáJiõùãÔx~òùçr0ÉÆ#|øº&£K~üÅì䟓Ö´H?endstream endobj 5601 0 obj<>/XObject<<>>>>>>endobj 5602 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ÁÀ_x+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Ô'&Í ¾Œ…wÕÜö&ô!ç2‡•Ømt¢Dˆ¹àdt6^'áãç÷7°1Q+ïsFk 63Þy¾@ãgû B.³°+bÀnv¤o,Žì¸Š[9uœ·ÐX/»“Õš1`0^š –ÊPjd^H‘V)ÝVˆl¶½ªËz^/­X¹ÆKë*þ ÏÞØfødUgè•7™ÛåìîNË\ßݱL¼ŠL–x]gÎ839ÖO&jz‡ …ôœ©Pw6p½Aš?çøùí»³"‹ûçLe–7×xs†ªþ÷à{ãùœ«©·^¯Y{vðhнßêÍÁ. VÒt<óæþœFK·Q¾ðEj>^x>þÛÀè‹é‚¡~ß\üyñ/\Šësendstream endobj 5603 0 obj<>/XObject<<>>>>>>endobj 5604 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 žàYD§ïÚ%m2MW>옳‡Ñ³œÙ«Sz*Ä?ÿäg˵tkÒ­³òsô,£ñÐ,ÊÙùû«“ŸOþô _endstream endobj 5605 0 obj<>/XObject<<>>>>/Annots 2989 0 R>>endobj 5606 0 obj<>stream xVïoÛ6ýî¿âÐ6°‚Ú²-Ç®“aÒ¬4Yg{ÈŠy0hв¹èWIª±1ôï)Ù–×dk‘@°D޻ǻÇG~jô ‹=èéŸ'®ßÅ/ôèÑcrÝþ†øBç#¿[¾Ä0m¼&ÐëüþÁàá;Žþè`ôíì —M¨VПC/€Y„¤†£ÌBË¥ 3îõ‡þ¹À•ÌÈt·Eldû6 ‹XÀÆØJèÓÙßÎø zB íàÌ?Co¶À×,7BA–Í;Z*¦÷î3õ@ØÒ¬ÁA[ÈýÔŠ©¡Ô¼ÐZh0ˆ½dZr Y¼"˜X‚‰#(6F¤Zf©vàÓû›ë°4™BΔ‘¼ˆ™",Ë ÚT‡Ðã!C¡pÍe ôš)"©ŠÔÈD€ÙæQp(±³€%«PF‘P"5àhh¿lQ.52±aI‹T¹°@¢ hjDÆšEŒ ˆ$Vzî¹£@l=¤“ _º¯Uå½ù)`BÉk”Šj„Mˆ™Ö)P§¿ßÇ·Ð;)kf‘+˜ Gþ)_)wè½”)‹PÀ‹©%±~Q>ùR ¶™Á΄:N®2#¸¡å…\<@˜K\ó&ÏôO5èÝÐö_CO‚ÙÌs¯ÂlUèÛùi<Ǥ’?Áe%Ìs*/uËÔw¬pÒǧ&}±1ûMÒ¶ÅïûÃáªé½ë Öì3þ-PœÌÀž——ŠÇÿ­†ŠPò³¿G»ÖÌïSÂ^(WŽæóJétà&É3eª­]ÊÖ©YÒV„HeI)&'ך>N¤‹·v›ƒ$nUëtèˆÀ¸nÿ. eq¤Ìo‹Çeû–øv2TÇ2=4¨Ò;KS:všy¼ý(WÐæ¯_C[˜ï {TŠÙižÌV"%›E¯bð¨XžãIa/e ÊÕ‘ª»Þ‚æù|³9bìÃ,Ãý™äd˜f-­‰fˆnLrÇ[ˆ32r—ýòÈÝ'H¹Uiɹ¢=ˆ›Ñ[ñŽF¢ D¾ZÍ•Ì ÚÕ&Ë{¶xJ|*$¦j&IÔ,Y8Õ¾„)º--G€­Wuüè"·[%–KÅÔÖQ´ˆj Ωqëä" ñ H-Í€2¤ {  Ì,=rìœXjs„‚ç« ’bw–9³~…ß5ü Ô¸4\”ÐsÏ~oÁÖI®..®~½ß\ÿÙœüþöãâæn:»|ÿ~qwyû®ù×üôhÁöªáVLI 5:ö¤‹jlî5­Ôšè ­M *6¤l‘A¥ÐÌ–ÐÚ{{tæÙ[¶qèä? "6îÓî,Ìa7­*rT¨ç²@¥Få ºgþ O÷½‘»7Q«Û^ú~Éx‘àMÂ^1(º™›Û~ã:ð¿/hƒîÐïx;ÃãfŒìݬñ[ã+©<'endstream endobj 5607 0 obj<>/XObject<<>>>>>>endobj 5608 0 obj<>stream x­VioÛFýî_1èÓˆIQ”%ÛJ“IãÂ@Ž6U¬È¥´5ÉeÈe"µéï›]R—-§( _2w9Ç›7oæÃQŸB|õi0âï8?z69 ƒ׿ª9õ®Bº4IqytÙF£sš$öRH“Øû†N&õ®úÝ5¯jf+’Kë" ª™;Þ²â÷ñbâÅ•Fsz%neª2ÉCjOïšÍqí­ù£Gä§?_?'Nþ›ˆüë?½¦®z™ŽEÖËÔ¬ÇõúÁyO.F~¦ŠfIÓéŽ[û^LõB”òý§J”A¼\îܘÇ1ù8¯dBþË]äk÷jP·œ ›ÁW™ÊïþÄ.¹3bxm?´h{¯µ‘dÂP"KY$ ›.h¥›ŠTQ‘eÀR§¸$I7¦lLM¹XÑLR©ùÂd+JTšÊJæ1_«7‘ žhåÛ+#kRæ •AÁc£Ð+&ÙõÛgFÈŸªr‡6ç¶ï kŒ{¶Õ´Ǫ»–Wí‡èXw0x®!†L‹-[G%2õ§L,gwäÜ¢`0€¶'÷¨¸:¬Ü8šz9šrz2Ãþ8|Úæ¶5ä‡ FǶ±»Ôד¤UyS5‚µì4íÚç¿ÚÜg;¦'mßÇ𠟦Þð”ð…Ó“C™|ý»ß½7—"¼<‹§üÊÏî "¸UEò^§ß“åÈx¼E•»sô ïw1—æ×)ôõP>à tG—ÄüsóhØÍ£Á(¸ÄRpcuae‡¸Z‚ú¯¬&×îÍŽÕ<ÉÎ+”´Á[^2QÌ1‡ kYÇMYêÊPŽù¡Jèº*0(”hÑS4§!…á‡Ë„Yç>„Våj‰AˆIVA™Á·¶O¹)5,΄¿©aW+Ãq½ß‘ªˆ³&¹Ó“¹ÄlLº‚¹9¢;%•ÚÒ!\NÎY;¥SUp¬…ƒb´ž*RÄ‹]x<‹ ÎRä<’ æVºu«ót#M—”„å Ýêø½Ãr™ÏXêŸÐo¿ïa´O¢-S]¬kòuF>£¿èsþ™VJB½súû Q–²Äklc½â@!íBcÕeõA§ûËô¢hr(îìÐpf^HQ+(¡H ƒÐCÚž6TZCƒ!¢¹€ÍL‘µqí­E×Nb›YKÚlݬ,w­ä}¡Jˆ®“ƒÔ»§N3ÿ¥&¼äØáGµÈ19±ñ¤èNÖR^…|·ú$_¹59í–qw~‹š«¶]:åðÚ- £•ëåÖ”oð\sU·º¿ãŸmñN l?nRx‘ s öZ}pÍFÅLÃÓºÇù‘]ëìˆO:´Û„ì¶ õ™/ è¥o±ßÞò­îP µ5g]–„Ö¥¯6lùÊîG½«‹V&úgÁp0¤ÑEœ»m1‚~Ô1蘩ÌûQènûçŽÿBœ‡á(Dn¯E—læÅäè—£µ"cendstream endobj 5609 0 obj<>/XObject<<>>>>/Annots 2993 0 R>>endobj 5610 0 obj<>stream xXïoÓHýÞ¿bétA$n~´iË}8•BªJîh_*¡½I–Ú»f×NÈî¿7»¶'P¸Pðzwföͼ7c¾ i€_COøwœ ¢VøÇ¼¿> Σs:]DÊht6ŒÆÕSJwG»Ï‡ÃèlçíÅ$šÐèäGðr0‰†Õ}y¿ãÍ»´ :žèÛïç4Ðä|M>Ÿø˜twãT8Gw² ¿ŸÝ>Pˆõ¤›—³TÅ/ZkDÇÇte´+lÆî½„‘‡îóߪe8„æ¦VÒQ±´¦\,ÉÁ_&³™´nÏÈʨ„¤ˆ—»¦BHÿxËÇÓâç9õá¡?WWêÞ–i¡òTRf’2…³XhšáQ}• )]®;ÛPnÍJ%J/xÑd™è;™ Ž2¡T¹‚̼2DZdºAô’8\F5„ÐýÖ•‹u\]J”•q¡V²G2ZDõ™m&ú£Q4#/IeÁg 3•²7U½©éMˬóôußšB""Qü°H9R°Ê¤æ —ޏûxsý«£Î\Š¢´Òu¢x)´r 8Àá1¡Lñ’OZwédRgsÄW›K YzT:q im›Dž§zè:É·G9ª„Œöï¥Üí\•®0™úK »¦u”ÞeóºòQˆÄþ3c%%²*uϪT\Ðð$:áâ :ç&Ý1ø4 [‰ºZ,<<íÜòþ“èüœ¼Ó’¯ÄÑgÃe„À”s%êEiZHÍu_cK3 €ç{_¢ ‘bŽ{ƒ ì7küFtÃrÕ6µÀ=8ÀÆâT \9Wšý®—Ò'@ÐÚr8ò~Íì3 ”ÌZ3'%•:‘8Ç'®(ЛÞÕóç1>)ð§X›V ¹qNÍTª % hPbˆø »" +‡„¨˜Ê š[)Ù/‡±ï;„20<¯i݃$݇Ĭ~×úêÛ÷í–¦LÒ¦ð>ŸpÕˆª™TAk•¦¬"fBHÙ\5N&‘ÿ%R®»‹'ÃÕ“Cq!@Ì+PÁõh›&<.UŽ7À íæÈäÜš, ‹ áT=tËJÅ’VØ/À€DæÒ×ójÍb1/5” OØš¡6LÒ(°G3¬ôÊ<Ê$¢«PN=ØYÉÔäœ'áu¢)'+¿”P;‡u êî«ÉÐ >Š,Íz·Tͬh ¾C(í-WX`ê¤á)Ò|+ì£×¥»µ”9] ;eÑŸÒµºÓ¶Yâú¢ô‰ôrÌYmÄy#‹ÊH\‰èãRjüÁ;ÈžF’P$ äM R¸::Ö˜¢S%7è8-=©‰EÚ"ÏJX%@l[¤f&R:\‰¹ã ]`ÏRØdÍ)²r&…,{jîˆø1¢)2Ë ”8Œ*ŠÞwn€> ¥*öàgLæ©'¡ø¶í¡þˆ-âO b›†]®7Ž*TpвÏfÆÅv6ôû& ´´½²²UÁL³~¡¬E Õ]ÉY γ•`ŒÔ L>tÕBTÇ€ç-SK±ÂS+E²ó‘}v+tHòÎvÎ,¡SêžçåÖ…ïy­€*l H~,1uymAvÑ!r‰¿S_DÂÏMT> H'DuèrÎÍ’ö˜ä¸%z¨ñƒ C5ûÕˆnü|]äC;ï{Þå!¬“;·o„p,\q¾Ï* E‡z±¾ˆ™)Ãlâ³Qk¡Ò°Œ0Šð<„œ!¿­éé~v怖E‘¿8>¶è0˜H»ðþÇï×W—:yýµh0`MÛL3xeñ‚ÐêQWÇ—ÜTƒ!ÄAÖfjõc¶¡ùAÍÌ#÷wf°ÜXôQp>U­Ü2…°êß.ב„̼ô[`ŽeÃÀ£kT08ÏC3|¾ýðæM}.tÙ›9Lï÷Î0é6EÉB±©¦±z@Sà C æqŒWõí/(¼«ÐS[IUÈJ¡æï¯qŸìŽŽû(ëIÝ÷·Ð\ÙÏ^ÆŒ–}Ю´¹U<¨¦<ªáij“mîÍ UÇÞ­AJÊŠûÐj¦O‡Sª{P_m7µØâ-%C’ÙPKÍ“oMWð éÖÕ€Æúãy„Ø ÿ|·ÆËƒ‡óÍ^zéàÏÅVÍà”çOžÃÉ4Œ!øÀÅ'TÓëScá7ðÁøÒ‚hgRü êN‘ÿÈ>øCp뾋ÛòðÊŽÂIN{+¢oÄÀ’ú“÷ >NPhX £ÀaHU<¡žY¤9&ÿ©‚/Ý¢¹B>/XObject<<>>>>/Annots 2995 0 R>>endobj 5612 0 obj<>stream x•WÛnÛF}×W Q‹–DY¶Sä¡n£Ô/5«ð‹ƒ"‡Ò&$WÝ%­Fúí=³$%’¾Ãp¹»3gng†ÿöF4Äψü©ü†ioè ñFþäß×/=4ôNh49õ†”’ïŸz§Õ*¡Ë^sÝ“‰7jî6Ö)M†ÙØm®±{ä·vÏæ 0‘YÒálB£!Íc;=ÅSäÐâ!ì_­8£0H•-) ß?| ½øÆaþÎR¨3››"̵¡Øè”¾‹»º¼:ÿB•$X«–®íņyâ" s¥3ÊWlxqGið]äbéîV¢ßÏ¿õ†4¤oØ®¡G-¦Ø)b®ïìÐÈ•ÃÙ>u† ŽÅeîþõxzLåvm¦lÆ‘þˆy)§ †A;¬AN†óÂd¦¬µÊr6M33¿ÅÔ–yE±IîÄ¢D-L`î ëi‹Kß{o2w0>Az \<×ât†Ë˜p`Ä–„%ž‰Öß Æñ ]'ìÑoÖ)Ó†iÜ2ìŸižÎ ˆqgH'ž/i4FðÆcÏ÷±Šú‡û4SÞždÇÅ†áÆ•Z®¬öhÿ°òîá¼)jj?¹·÷­ÕºX$*üØzGrçºýžîv6þ{bçç¯ÕÁ¦f˜ÕºÞÖì´Ð~¬õM}YR.ê? ÂÒG¤®¾¹îg¼q(ÃX¥{Šñl‡êÚSöiÉù ¶Kk«ä|é4´¥÷ÿ5hO¤P`8ÈK‚‡vÄnWLUÆtvoÆA‘À[Ú”Ã[ú«(TRD;•·ÒªGŽÎ:lJðÀ20‹` «u’€»9*ÝÑ¥eGÚ‹Ò9ytž“ÊZp„Kn—žÐµ{g»¶F\7 Ç!G½ññ1ô pÎ'až:ôâ(Wð2v°ï5Š£åÉQv»N;8èÚ\ikkê{‡–­¢¦ºK¶ü]w!æH´ÚH;îÞ|,ÀÝÔ–VYbܦ÷“y)ã€Æ±K–vÜþÉІó" rNÐí Ò?¡6I´½jÉ*é hŒîHÕPÐAú}e†V^½{¶Ö_pGÍníP¼ôªüÊê[0šœ’!õÐÓI+&ª,ÔÆÀ9—ÖìBv¥ øu+}So26ÒïHÇ­À–n“râ¨{Dd‡h¿¨ÁHgL`ÃÂÖÓÎ/°±*ýH‰r%޼dví ™˜ëútá&µiÜ;1Ðv6­ÇÁ¾³>Õ†[€•„=Íé¬âÇ]µ+Ó`½f„Ú ü‰Õ;wá ÙàŒ´oäøm¡?RüÛ–…ì¾~ÿL*\©‘Ê)Õ‘ŠUè “lpÒ †Aaeè±¼L9ËÝ!r|ÝåÚRÓ+jk©Ù’(Ö1ÙP¯Ñ™T^j“!YŠ¥å÷F{zK {ô§Þð­ wmÎ÷UYô Çî’£¢S®ìXòT¸rˆ[@]¤kܽ×ú¤,¢µÑ˜ñS)¯|…)´¹« Ù0AfcFéEå‡@löÄ\‹Ÿ)ÎúHýq0N¼#ÿˆ¦'n"–ÜŒñ™ô‡Q²U”å &–òäà¸ì1þÔÇ۸®«‹º¸åðÑpêùc|øa¶™ú#yõyÞû»÷?†w0dendstream endobj 5613 0 obj<>/XObject<<>>>>>>endobj 5614 0 obj<>stream xU]oÛ6}÷¯¸È`@1jÉ–%u‹íyi¶U@1À@AK”ÅN"U’Š—Ýoß½¤äZ³1‰¼‡—ç}ž,aKHRúåÍäM6Y„ \<üÓ;ˆÖ°\@Vblú ·y`+çÙ§I´Æ:.&0Ü~,•ò«Cf ·•*@ÈY]ó"„¬r/¶ %9l 3Bš–ç‚Õðööý݇w`Z kŸÁ¾y{f€/À*ÿ{‡é[! ,`¨ùæËÁBÂû·¿Ì—aÆiØïÅ´—Uy r¥5Ï­ !-×%Ë9”¢æ‡=ìÞºRiêhp§fÆpƒ‡Z C¸šTŒÝã8L|+‚hkªDïö’kS‰öæ/Ö´5Ì¢ 7˜6ªèžˆ>ö¯4ù"øIȼî g'ûTg£èé×Q-wXû{£Ñ¹’ãm·­EîŽzˆÊÙ›ó£êŸ\ÿ:„ဲïú†éQò¸«ë3¤ÔÇ!Ùƒ; ‹„óÄ:¢œÁÎSö­—Ð_$Ý£ƒ 0•|¯¶Ÿˆ&”€oÄs‡‰èÿ-ÁÃs¸}í>ôÿê#¿êGÁì_o`ÖSÿ1ºóûáîu¯D½ô6ÁÑ_Ëø<¼i^s¦éþ\õ'2´´L™ÇI˜¦Wt‡^Æ y—3§eùD Ù‹]Ä=ËM¤‘û‘Õ,ÿ5äD­Ÿ)”|e§T+IÃåtçÇœõáÄŽcšÇa/_š7LHfË´5 JT':‹Á‹JÂ^Ô5ú w.á W‹­fúL¥ö¹V{² ì B´èG¢,¹æÒ¢o5 C&ÙŽ7´by^Iñ¹ãfðï3ºÖ¸> ™×èSðgÌ$z†0)†«Â¢³H‹Ø}£{»ÇàXd$ÙéX'ù¿Ä3à8^4õm÷ç¢ô°ëÉ}Ø=Ã&á8ÅkwŠQ‹1œV‹{œä÷nA>^ðŒ-V+奯5{þÁdãØxä2CÞQÈj%ЧnñáßY­VxW–߃8*2\Ǹߓ™¶Ÿ/HÖð²¤(‚Ÿ•Ĭ­5ÂÜ옶òT¥J£QB?ŠM€1H”Šé™k¸9‡•ï¼ ( ß“Gëëþ ¼¼¾/“KH¯ÒðÊ€Ü÷/ðV员‘4¨%ŠÙGϯ¼/ü‡/i˜Ä¨VTjšÄ”~“M~›üKhfÿendstream endobj 5615 0 obj<>/XObject<<>>>>>>endobj 5616 0 obj<>stream x•VkOÛ0ýÞ_qÅ&‘V«ë$%e*ÁF'¤IÓX¥I[¦ÊML1k’â8ñßw'Фm¥ªH|çœûHî[6Pü³Áõô7Œ[ã%o¾üÈôFމ ãp(xïmâyG……qhôzpÍU.P·X"b6?Ì a1oïZº6ZFh¦I¦ ¼e²3®&Ú$°‚vyðÒÄÑ÷I8ɔԧ'ð\‹ó|R^"" ÎY–Á4­=Õ®2Uê×’3…ÚAÂÿ”¹ tzu°ˆ–)Ây¡pGôý°ðœðµ®p¡nêJ~*•1—‰Xƶ¢[ÕkiΣ¨TZ”}“ï2hE/Ø*Ü%ÖmÈÌQFyv;™²ðw`UÖ'ÐP£ ® /yœ.ùKÖL<ò‰]¶©Ä«O–Ïœ!‘u‡%ŒŸâWS€+Ååxµà 🦙ò™HЦm Ók,Z²$Ħ×Þï4ªÍ 5 „K–•ö¯ÆUë¼ÔRrM «)Q}R“<ž"…ô¦êvf„7kYŠXÌl—Úf룻A·l²RJ¢#˜anXîÆÈ`‘ŠD«\ö˜P·%ÔFŒªŒŸIXku7C±Yý:D]í]=fÂ,žÞ¨úúºX†®ã–+ÑúÌ®½Œ­`•æðíûÕ§¢p¹Ez-FzNyW×ÅYÛ®:’C\Wmd½-pôFvµ{-!§šsÝÁ Â£Àж]Û§ÔöépÃ[òû\H‡üÅ‹9?Üël¸Çªµmº¬ßÙ_‰—6Ã¥‰ïû¦"×Y`˜ãƒ ½'í›Ó†¯Oœ)w:,«½ N7²þ„Ù“¹‚·'‹»- NÉ:cÜÆ†î¿ÒDÑ2o/GoGv²¾\ ÷¦NÄ|ÅÁ®$[f~˜öÿ¦(p;($ÊI«›îå³½c¢>³‹ŽéŽË9uhŸ¹Gà úÕ„ééì:„ÂÇ4Ìcžè'kšhð8ÔÆº;0óåzĦø ôez‡/ 0–øXÉLÛQ¸¾FáÌz®«o]Ž[_[ʽ :endstream endobj 5617 0 obj<>/XObject<<>>>>/Annots 2997 0 R>>endobj 5618 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ŒÏ¥7´Ÿõ«Lùž¤aÌ{‡îÈ |z©!y2 Nù«÷Óίt€#²endstream endobj 5619 0 obj<>/XObject<<>>>>/Annots 3000 0 R>>endobj 5620 0 obj<>stream x¥WkoÛ6ýî_q‘m¨²ÆŠ$?âxk‡4«³¶5îŠm Z¢-6’è’TÜô×ï^Rr,Åv‹ œÐ$ïãÜ×á‡Nþ„ÐÒoœw?Àoè#¤×W^Ø÷0ˆü!äÐë ýÈ-2¸él-qoÐóí½‡%î"¿·µ÷°Ì¡ŽP¶U@2·–¸7ùý­½(B[":{£¾îtïÅtËxëZÂé$€jž.ÐÍáyè‡g0M¬‡LcO¨ùÌË™(fÇã 8Ïáxú¾s: ë{žK®BŸ(YöÓÌ-£Ù±;¶%¾¢ÄÄ{öŒ*9mÐìwM-£ýZà"; ºÚÝ#ù|—ä«K_¦Ìÿ•»¤ZTü%7ï –ó™w#‡áQŠªJ¢gahŸÖzUÀ¼‰T`R©9¬S Lq…áŠkÓó÷<6ˆ;‹oE±¡A䫌ç%0¿m¤¢×%.Üq­Ž(º+iõj¦)‡²H¸Ê셋߯Qí¸2†¿‹9Ûëa &†Áˆî¤HàæíõÕ;²æ"I¦•Ý3¶¾‡•Q'ðçÅ«7/+SgÇ?ÔVØ|ª¹#I×~_ıڒ4;†—›V¼æ¹¼ã; Ù£ºyûM‘‰âö7ÝÐmUŸNê˜R=lEõmÊ1E? [¬8³!%¯`-² XidNÀ±,»ú¤èTeŠ}Ê&‹·Aa Ïf>ysL¡Ä‡‘‹ŒaàN0›ZÔ8Ûh'<ã-k>«¿‰dË»¬¸)Uij¤KÏ…’9%Þ‰MB‰™^;qµÓˆehíÜ8¿•-͕󤄺Äb˜ß¼kdÿ@ÎV+Ê{«Û DêZñáÓæä€ t©‘{ (m®hT¿U‹N¯0z»¤Ôû$‹2§Oet]À’\±ìîeé’&GÁŒZ{sd?L”"N©ƒ(ìøB¡ÀöžM;!r¦naQ±²@Otež †N庀9ÏäÚ‡_äšßq,g±°¶näÐJ\(η¤ÍÏ "’ï&%ò'熼¬¼_"g™_ðõÌ«ëÁéûÍ­»ãàc4çlÈFväRDvД™óIÊC¶ü-¥3äK À NûÙùÐ ü=Úû»ÀFk|–$ âbáA݇ ÓÂ÷•Tl§ä¯¥bÁ`*6e"´—à!FVÃìGff™ïñ8ŒÆðÏ‹7Wÿ _]ÂA‹´gÁʬ"ŒuݶF7ÑŸªü¨YÚRµ =‘\C! Ürí¾ß1®ÑÔf[ðjK4BP[ż@ЇŒ†š^c^ý*u5¾­Ú%Ss¶¬i·ëıÌ2ä…º=\µõc¢VL¾4˜Ý¾14M‰¯ {™cûÏÜôwš¬­˜G[m=GpŒ@Âu¬ÄE±9Ò1"¨5v­‡¾m<Ûe‰³Þ¬9_Á•C.×R‘¦‡kõ“ÈÃÖj—ÉÒž©i9£W< 8Í)GºÔäTm=­*îõùE~´}Kp~¢®;NœËÆñ1qûüå6wvçy¢m»Åâ~´@öˆÜF!݉S¬Æù€ «Æ· Ѓ½3qJþ¨2ÃM_¢g ðýàÿ ¨EÈä6J\ᣃÞMlí[™BrtYâK#Ÿl5Õ8Œ*ֽ࢟ G44q ’OÝÈàg—›j$1X}îl÷̽žöÚA0ô{>ŸPà°7 Û/§?:ÿ5‘œ¥endstream endobj 5621 0 obj<>/XObject<<>>>>/Annots 3002 0 R>>endobj 5622 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 îœz wæw:´WOÛ…¬däN×O]Ùµ»~3ð;ô3_ìå Ö¶öIÐõÛ-ܦAZÝv—¥¯ïö>îýOv\pendstream endobj 5623 0 obj<>/XObject<<>>>>/Annots 3004 0 R>>endobj 5624 0 obj<>stream x•WÛnÛF}÷WLܦc›¦.–¥6›S?4i Á’\J›\…»´¢í·÷Ì.u¡#Û(â¹;sæÌ™Ùá×½Eø×¡Þ€ÿ’b/ #<áK‡/7o÷:ÃN8 þ³>®u{ý0j~åôaoû7ÞûáÙÖÛ—ã-ƒÎj5¥Ó«ˆÎÃ3êF4xóƒ!Sç6¢q¨*ž…Påäpuú£è’ÇŸ÷N¯:«USYu邾kN¥ý$JUˆ|D“C¿ví$¢“̦ÁÅ%ýôë›o¢˜çr4zá6Œ¢oÝXöâìü’·a-0amÂÙýœóRr<èyß!îì7^<¢¶—¼xì}â÷™sÒí5ã™2”èTR"JŠ%)KR%™…šžJ™9­êxyZˆê˧¬.«tz³Ï¨Óe³倣ì ÂN„Œ]URÒU³Ø´1ðâ~Øçå/—”ÊLÔ¹=¦¯ßRRIa¥!AûLìÓÊ!Ù™°ÄhEžË”3td¤ãÏ2q/§¢ŠÅÑh,J¬LCÏ$±©%£¯¥3äq:EX,}utÔØ;0ÀflU'VW.^œþ¦òVVÇdt!­*0ÐÌ畞W lí¤Tãu©-ÉoÊXÒ™¹L”È ËiŒ*§TJ™²šs0—U¦«AÆ7¡· ª6jOˆ ´rë*Á“^Zêší¢¬ñdégË ß*á\ÕF’ÎÜ­OJ׉'ø…‰äŒ´Pª*Эn¥ƒÑÞµ¦÷ñÝœ_NŽ,d‰äQí¸aa˜(Ú¨+iö©É õi ðž" ¬AÍ‚µÉŒi­êä# ”À$i0Y1º5¦/ªïˆve›³–&*ÁY…£¹•Ø[º–q§¡ûû¯jcu¡¾ ® ºZ¡tŽÖÝoÕ¬PÔKÁ™M¥*7“ö¾®ÿãýÍøÅ»1=¡ºÎ\Q(ª”| 0‹²-êcÆZºuÐ, ˜ÂC +€Eâ©ËTVù’ÉyDê¾&®¡ë4UÙ1©lUk¶ ¸›rÆg¢÷³X}A¢€’\s¼%räj¥­“€óü‰ úFúVŽ~Õªë:nåq ‡ ¨vû@ÖÔàJY/›ÀA<½Ó¨Wß]\™‰ª€j\5nL¡Îg:ÝÉHÉ2¡âý-X"½U,> ÈbéÛ¶óÝ@ÈóI¦ŽmŽ{HpªŠ¥]ponz +3SsW­þfBzA‰“$¢fÍ 1­¸Pƒ.!stQ¦-ÔH3gq»·ÂÁÃúáªgàœ]„ºµÑ Q«dF¡ùÞžS\[¶UTTšŒ‹kŽÕ-(›Tz¼?¥ÊÀ8½ÚÆ.ç²s–@R©tˆúj§`¬ÉÌô‚ø?BàÈáz[ÿ£S.-”or5Y>fШp"qÕ6ç)òcL6åDÇ^0r¬ Ñáæº4*†еZ|p"¹ìüpâ-@v‰.ÑHJ¤Þ%¢àucþNi=¡¨› ç.]ë|Ô9Bè§ÕжP™¼ËÉëëï?¾»k¥!½ž{5‡»9V™óÆG=O]\¶8¹F+Ô›Éî¤Û {=ÌyiàbøW’èï•7iÑ5ÊfŒ¤£Î ­ øTæäÒSfÂXN1bÛó{vIÀ¼» ϶·ø‘޳3 ØÉsïêÉoúœŽŽøáÀü„øt•½ zê6·q¤ ’Íš;ÿi-u¿6JçAsk¶ûȶ@Åz)ó¡îæ$±%]ß¼äw8äž×ƒ0ÛXÓü3æIv¹5aóÑùã@uw ´•üZc2 ƒFù÷Ù AK6Ñ혣Þ.û\7´À!‡°”‹Gææ­‰UäÆõ(“ëÑýãzg€Ï¯Ç°Ïœá·°ø½N*†?¸s2vÍsý0 #ÜTõÄÐtt_ªüʇ÷xAÄÍÆ]²@*6{¾ËìÛW¡±¢²díó¼G»¾ {g48?‡¾-ðqÒÅ÷äk Ã¢)òáÉFÁ£_}2ôò½ÿKå,„½.¾iÐg½!ï~3Þûsï?%Bwìendstream endobj 5625 0 obj<>/XObject<<>>>>>>endobj 5626 0 obj<>stream x•VOÛHý?Ÿb”"„Æ8I \(Hå éTzªº^NhcOâ-önê„´â»wfwcâ`z:@!NvfÞ¼y3;ß]ðé· ýÿIãtÔð=Ÿ>,_Òìûpèõa4¥ÃƒÃ®7À(4‡|-™NÆ­DH5ÞúþïCÿvF_{çÝ•]+—3L»Þ ó[%·Æ;öÈšëN—¼…­±ñ·3ìö†ðÏé§‹ág ª\äR+˜Š"έí` FÕéõªÖ(BÀ4Õ)Db>G•ÁQd9}óÇî®ÃFyã–P2qÕc ôä+9È ¦)b‹•ñ°‚í¬¿ký¦¼‹óH³ˆìÉŸGo %îµ Å$Æ×°@vC™t{LB ˆbYóï)>{Æ…# ¡¶ÎSüVÈ)Š"¿RÍV‰ä©îøY¨d2‘)5@Pd¹NL¢0-TÀµYµqÙ UœApÛ½äÐŒhF¬ šìËÜ7q9®$ðÂ…äÎ0Y³ÛE$é 0³²üÜæždÑ}/éò® bŒ¹·j•­ ½õè®úÕžÐ1²Ü˜3‚n?  ëæ©.¯Oé^† qȃemŸ©LÚßhÿ±ß—£¸uÕÕ¨W·¹+¶ÝðÝ~É×ñ ×¢:É«þûuþ™íc8³×ÀpøEkOáâWzõvÝ`è?ô&èOñð¤2a«Ñ÷ë¢ÛÅo€ÚCÓ~Ý|y¬b±¶N(þ¯à êàž(oš±ÛKWáÝžÑóßxûý}Zviïµ×)k¾Óó|x¯ƒ¢ÜF™ R•=Ý9°ºë¼®ïíÃ9ëýÜíSfÚ÷^¿Gû*ÝÁƒþ![Ÿ5~¡L_Bendstream endobj 5627 0 obj<>/XObject<<>>>>>>endobj 5628 0 obj<>stream xWkOGýί¸_ªšÆ^Û˜p”H”BŠE*¸Í$:ÞÛvgÜ™Yç×÷Ü™YÛ 4}BÚÇÜǹçž{÷σ! ð;¤Ñ˜ÿòêàÇéÁ àæöŸ]Pÿj@§Ùˆ¦s¼<>fãñ M‹ðÒ€¦yçí;Òª<œ~>Pï·ŠŽ²³»N%”¾;œ '“Á;âçý«acªóÕzÛlùè ƒ4{ú’Ù÷™óÂúèn/òkõì%«^-¤f éﵨä]çîðïÜÔÚ«J^Zk섦Kåè\«J”ô‰ÒJQlÈÊR '‹„YÌ—æÖTt°;œ ¥éÆã÷ß|µõ°…ýpˆtb¨ÇÄ~¸ˆ½£Q*bç£ñ*—ä—ÂÓí§ë÷” MÚ¬©^æ$Õº¶Ü(½ ‹W¯ÈÌ>ó“¥p4“R#l)‹. ]àíÚ‘ÊIG‚lD‚ä—\®¼2:Kq3G4¹)dð9“䨒vkµèË/¢Z•Òõm=ÛôÙÇý¼ÖùÖLÿꌆGM>c68gÃA6¦Ëj&‹Btƒ£).B¿õ"xŽÆq:w»¤œPȉ³FÞ_p6H IVÂ>¸„C07V’òqK¹¢€‘}Z">¿v&HÒ”%p3–Àˆ\à”§µ*KÙ¦ˆHªèx»!o‚/8ÝÄ("òùýüÃo—w‡|~®tá6vV‰|©´ÁÊyicÄé!½‘?<­ çÛØL8ÅÁÁ;̼xCf.›8\/Kñ(#b:ιjæwT<¢Ga•˜¡˜]ru¾$0‡­ šlLÝJ¼HHÒðÉGiù9ù9¦jb˜ð)ˆM/’)ÂEyÃ÷Y…zÌŽ¢sÀ™BŒ&sÚVÉ|S´¹[ tÁ ¨iYÔ–É®´òJ”ê«`ÖÁ·6–û80BiØZY¶KÈ„´ØÛ=ŸmTbK;²S€ËR[½w|—^b]ÃÎ}¬qªR¥°Y”•9¦WŠZ™çË sBø@Ïq«w4΀+Üïø.Cx²6YZÉ1a«+4ü‰r-6ÜMôkåAÇGÍm™T(®…³°¢ ìÙ–CGÓíµJ("7K+~áØ{ ›ÏT²bÂΤG3FÏym­Ô~‡"J¯EÍ’;Ì8û5èÀ,8¹Gej‡v°’3…ÈÝ€[·J,j%6 ýûï:Á¬VÆ »‘¬!¡ÔÒY$UФ¡#†VÎë¬CY ¨ úÅ ´£qè  ÅÜý­HB›Â·ëwkh.@$C cŠŒ¸=ÚĆv;Ђžø,fì—+aX‘½dq°B£g®Q*o('¿x‰v5èÿ=\š•´í(~6knî.¨ï!šä¾dYd9ó§VAEØMe 5ß@î°a0©ø–x€ŽÕàø3Ž&y°Ê|îZ`±"uŸœ u(Õ§*!ùõ aIH–¤Nävü3l{KíÔŸ>/XObject<<>>>>/Annots 3050 0 R>>endobj 5630 0 obj<>stream x½ZÙnÇ}×Wtž®“XÔìË}¹HÉŽÅÀ/~‘Ci®gaf±¥¿Ï©ª™î"@Š6$VWuumÝòg¾ñðÇ7aB7Í™·òðúâÓ—oÏÂdå™$NV¡iL–㛀Ú\Ÿ¥qQÄœï9D¤Æñýd•ΟeVa°a¶ò5«0Ø$%µ¬‡e›¥Ö gTˆQ~´ÊLÂHÔ: ÑÀ'£«0Ø8;d›û«@ÉŠ/Õæ¬…iU”Æ«Ä$–A/Áx•›„ :Aq™%5ådeyÙ8—só:Aì…! dšUlÂ4%«0Ø<;XYÔfsH°÷cFÎû‚!dجb&µ1©u² “Ú»u¬¨ÅWŠRߣSˆ±Z…‰¥hÒ¬Ã`£`kVa° ›lWµÉ|ètX1{viY¶×’œUq$‡ž"׌T¬õ„ŽÔ˜–M‘7ŠU,Ì‹4«pc?$² ¤Vc°‘O1aYÙ)Ì'´0#q°ÃPFäBÇ* ¥ä@Va¨Åv%«1Ø€bÜ­,Fl9»ŸsÿÌùaL~²¤¸ß—p‰Ø HPÁÆ$ìË)ØhÇÉXNÁÆÀÍ)pp‚ƒMxzYG0HÄî‚ÈVv@”Iù¾Ï rd*G–“ç"ì±j˜â¬)«&KóªŒHrÖ²°ÈYèt¬ÂX8&s+ ÇK–R‘Œ9s#É%ûOLÄÈ‘X|îB¹‰‡¦´@¨D]ÅF-)*Q9 '8s>bËXR½¥·Qˆ‘¤ÔÁ´ÍœàX…Áf!-ìX…%à5K¿` x>+ËF…¹8÷-Àîfád7ŽÔ&!Ðñy•e3q½,ËÀ-;s>05¡%EEÑz7dàgÎÇI˜1è“N£›*r2p‚3燢đ¢q9ÄT;(ˆ=òI†–Ô˜ŽÌ'X– Bȃ’>Æq {DbG($ŽS‹zìV7N( ÃE¨D5‹Ô kLææH$§Vc°h†±bÅGË(Bå$´ÓWIdu%GŠà<ŠÐnà;Ph Q´2XdYv`0H{ß *ˆªItœ‚X#¤&5‹f+QQ9Ñ„ Æ,kIÄf)jÓ0°,=$Î6íÜA±5S$Ùº`bs‹hYÁ"ú%Ë~æi £¹GI*A>0GŠ öC;™u0R:ËG&°¬ˆ.ýѧBØþè+LZ©‚)Va°!oÕÉ* 6¦a@É* Ns² ƒÅ$ÿ;Va°À±!Ç*LuõÐfÙ.wUˆâ;¶k{¬Æ`Q«.ŽUlLeR± “Q¼]++jçîQÛa@ç£ qãÁn,É‚þÒÙÑö4’¥zRûY0ÙK¢ŽQnõ ¹ŸPÁ—«ñ¢Õ±ˆÜüæÞŽbÌ€ÌUYp ’J¨d‰C‡I%FŠU,Zg¦Y…Á"d‹MÆZVaŠ@®XÙê<‹ðÈí»Q„r¨øÔ¹§ TbÑP‘ƒÅ §E5‹ {ÑÂnRlF³»S«1XÚY…i«4í:Y ž¥x2…pR{HS?p¤øhžº>E;X)ˆw”V±ÜkõÀ¯ ý­¹¸ÂGhŒZïðæ`i`Ö[~mðÌzó*LÍõÇŸßš¢ÝÖß®ÿ¯Váç^^ÁÇwô`qGq‚U^½ï˺jª¶è«r Q¢}Rðêm9ŽU{kÆ»ÒôÕíÝhîÊb[öfWÕòY÷êáŒõ†¬çÜÇC˜Œ¥>±g3L>?+Ó5ûª&õ…Ù>´ESmLÓm§º<\æ_W|=#tAõgh?²²ßÚáC7õ§ÙœxìZÓíÌ›ï¿7åýX¶~À§’Ýu=^¥ÎoªÑìëblŽ­üzŽåÂì‹Íçâ¶4û¾ÜU÷'9_Do9@ïs“æ< W^jrNØOA’>šJ4G"ÿ2ʽ§ªÞR˜¡6\¬?›K{àfj)?Ví¶û:àî}ñëšâJÀ‡©mI”ëË®ïóSù¥¬»=Ä®Çi[u'qà¯ï~øåòyšfß‘”¡§ú.€ë~0#¥&2å¦PÞ\PÆ|í‹ý~® ÎUï¸8;ޝ¦vCÙ{l=oëÍ´…âæÕ¾Æ¢nbe;½ ¼ïªv,ûcûñzì§Í8õÏM}WÿÚÈû%sSÃpMU{WöNlsìv¼œÓkƒz]ö%4¯—õDßiä)ú¾x8ö9RÞw_ʾî0mÍîDiÈjQl‹±;z¨’®—vª®cÙPû?IÀ^7E?š%˜^ÔJð»ŒÖKüŒgà«©Ç$Ý›m9U=Œ`4Y£+Kâ.H;Œ ‡=ø}ßÝ?œ(·ß•M×?˜¦h1"5e;¾ÈSÏkº?·ûiäÌþ¹/z PO+Ö4øÌ7ާ¶z¹ì\ÞoÊ=ÏÅw(*tñx|ëÏV¶~Ø—M±ç¢å&ˆwÅh*´@3 ÿ¿ÇMxÑ‹BoVuìú9ïø”ª5__ N±ºFLspîæ®èÍwßÙ·Jt}ž¥W!»Ñ©n'Jªc;û÷¡ÜMõÉšnÌí¶è·§Š¥¹Š›§'êßeÉË.Uëùp ¹ÉËUpŠ0Ê«÷rÍ\=fÏ®"öb×–_ +¶è);Vn;É`>½BàÁ Oß’%®Øü ]eö Ôϧ_K¥+À$ºŒâyó„tø«.®ðd‰J¿Ãcýß‚sYöM1Qÿ¯Yß¡’"Õ÷èTTåªÛ—û¢ê¿!W\\-bÞ"| ³­†ÍDã4Ÿð3Lû}‡!B|¼’ƒßL=fÒ±~ÀxúÇTaÎç ÿÛGŽÂÐ|Óƒ«Ëb(Wæ²èëÊý€ŒîÖ%˻۬c&RººmnÐGÚþ¶©»ö«Ør”]\-/oØP‚ßS'|çý›×Á¿¡ é“Iä‘òËõÙog³i4öendstream endobj 5631 0 obj<>/XObject<<>>>>/Annots 3053 0 R>>endobj 5632 0 obj<>stream x•WmoÛ6þž_q(VÌAbù5‰»}êûôö(h‰¶ÙH¤FRq¼ýù=GJ²¥¸E‡F$‘Ç»çž{îø÷Ù„Æø7¡Ù5ÿO‹³q2Æþ™ðÏŸÏæWÓdNÓ›iòŠ šß,’qý”Óç³ãç‚®Æãäêèë›å‘Á`ÕnhôáMæ°¹\ãìëÅUrMË,:¦e:˜Ý$úÝÊ\J «¤;_~=}˜ÓßyÏp:O l, ­*•g$°3§ÂdU./ÉVš>ßÝ~¤Ê)½!¿•m ¬`c0ôiÞ5; Sze4ýÒ,]$3>oÊN“Ù OÙà'r;µ!ÞOòIe.Õµ4 ;fÉõõ ï¸]GÙAo/.°ÏKípÖ%‰,;é^zqÑ5Ú¸÷cÞaûÿqq¹UŽR+…—>®Uþ °:Ö/;+Ê$}æ›íÜ]ÿôÔßá·ÂSj´JãÌ<'³H¤&“¤¥Ì$馷Å!+“)㓞¸°VZ¹ínN|ɽ©‚Y6šš¢ä=Ç¢:£\éRžvÊoƒ+V:Ïna«¥ÒšE…qx$#Ó7°¼ý(½o(gÕfëi+E&m8å$‘Qàˆ&cyYÇ9IŒv‰× Êe Op݆X\x=j© f&Û>ÜG^©6l„_¹ èï›\u¥ƒÙLY™zc÷ý“õ0ªœå&ùHé4¯2Ù=ºW o$‰° =òïL!Cá>JËõàp¶óL†™#§cRÕ IWÅ ¸ïEºLQ>!ÔZ؉¸8÷©p€3ﶦÊ3v­å º+D^ˆxEn_¬L®ÒÈg¢‹Mðµnœ·4J{œÈ[p¨± Üqâ¿Kš)½ tŒúíµ(àD¤m˨|0KTZ¹–8 êW"ÑL°¥BS›#Æå@pŽŽ}‹œddV_ÙóPÆÒ»OŸzí\!޷⑌In‘<.­PD° ÕBjä°Ý²Ñξ”Ätí8À"pìîqÖÊŽB.Pº9CCêïÈõNÓÚØNº?)]=ÝŸÿ˜~>SwŽƒõ“¦4L[ñ|ós­—4¼=](ýu"tLsL´chؾIœé²£Wi̘A:[ eà*wD0áQØ=­­)¨Ì…ÇÇ‚ÑnþNbõÜ€ùý¦’.VUÔµØ-í¶R³jÂ`]¼2 |oéOÀTcëR,ÄžvB{6Šb·µà-›PGÏCEõ¨Ã}ô>ö^7Bªº8 ¨U®Z 4™‘NÿŒ£Œ}8P¬C†nhƒ±'ƒYÃRl>ØW7OÝ/¢do$¢Þ‡'t „þ‚þ¡ˆ²½JÚ¸zæ£A˜\îÔC+ß›ùiðŒÚ"."bœGÁOM¦A0î8M\œ1ý‡¾È~CrZðMå˪ր­©‡=Ö–Þ¦ïÍ=Ø8…â£ó‹^6ëd÷rø"v»cÇ‚®ºÒèŒC8–ª(î´’ô ãÏjeð‚»àÁiŽ­u—\)SµVPŸv~ì:ÝRûå)™n¨ • Ûîn Oo« •Ó„aýnç˜ÑgTÇŽPºÂIÌÉ!ù¯!ƹ—Vc5œ:nM¿i¨;„•q¬fß—˜tÑ&¤E¿ÁoìÄ!Ëí<Ö`"Fɽ8o)œ¿dÏZЂø´>ìÀ1ž¼*PiZ¦¦¬‚ `Q(2ÔºkD «ÊÒ@B0·§Òò0‰vžn Kè7³“"•œòU°Óñ…® tÏG8¾á bÚrøNk¹£½S*Š×Ãi&X§ÂàÆŠÚUé¼VKŒ:øÃt˜6o®½¹ú‡;-Â:âDŒ­ýKèŽghV~Ï h¶Ûö¯MñðÞÊæùç sµ²¡yaˆÇÅEh®ýÊEîs·g-œÛ ¹ŽCè-çû«ÇQsZn®©|ŸÐ$«V³ïOµj4‹ùfA˜/^*Êÿå¿õë8vp©YôY´Í5zúýÝŸÿú­5 IXrÉ;êu£‹úö;YÌ“«ÙîÞãd1 ×ZNÕpŠ«ý;“V…ĵŒÉÃæáW\=¼‰®œ¾Ÿ_¯“Ù—s0ùz>áï—gœýQ‘ âendstream endobj 5633 0 obj<>/XObject<<>>>>>>endobj 5634 0 obj<>stream x­WÛnÛF}÷W ŒU“’%[Iܧ4WM‹"ê 0`¬È¥´ñ’Ëì’–õÐï™Y’’ì\úP_%r¹;sΙ3£ÏGg4Á÷Íæü“•G?-Ž&é‡?~Eã·zžÎhQÐtBógé|þŒ¹¬šÐ"éûFûŠr×.­¦Û›;åÂëŸ.>M(9ò|tòO÷Ûð[Se¶Í57™ ëÔSü骻•9Ü/œ'¯—­±¹©V$«y§ñÛsâ J°c2›ukMq²“£îˆÃÇFdÍÒ+¿¥Â ð.ž@¡­kç>LhÖªÁ«ªQ¦ ¤ï´ß6k¾[iëœ×ǃKi±wÁ˜ Õ^ãïi‡ÁÙ”1غ–‚)k»z\©ãÆÖÜjÂËpÙç±c ™NÓÙ |ä£'6fE ²#}¯°NM€€ü„VY6Ü^Ýl¼ªÓŒ®¯VwPò—5Õ­ö”è{F"É·•*Í×׿~ÿò77¯~ýåíÕ»›÷”\ÛàÇÖeÊŽ;XÇ_=ìç½Å „Ëù$¶Äon¿ú˜£rû}-ü „7ÆZኙbrwZ‚*u'£.æöšÚYÍAáV–Ƈ†Sj n¨TÛ^4¶¡ÑåÞn¡ÍÖ¤BÏ_Ô!ׂŸØà²[ÝÄÛ½ŽG§u›Ø*ØG‹T•?^X7k¯Uþ`qJW…(‰TÖ´Ê"õó·áTRªô† ç`\E®LÃÚµ6§%T›ëª1 ac¼r]¨Ö6ý|Ò¾Ït tC¨ÚCs®dãÒå-ÊKXÀ¶ŠÖ&1ÕÊ7|.o¾W#iÌá¢+^œ1=g¹¿re‰ºš@ƒ[P푞Éô)N]µwKØÈF‰#uçLN¡QX ¦ª[®aSPíB0°«”>¢±—[y…£|¤˜¡€™*Šâ8Èüá~Õ. ½ ½•nÄL–ø¢ªµ‡¥•ªÊpâ{·aC‰tìÝ¡Ì.·¬9Äê˜"¯?§4•)Áà-δ7 8Ðõˆ…ó¹5 LÕ«êÐTšG‰¯%jæ­Uâ‡rÍÕØ1ꃉTÛ¬¿~Ú±ô‚XÑI23K³géYzN¿FW¤IíYR± ,ÜþÒÓÞù:‹ƒK0>?8ºu´.k.š‡ÔiåPÖmm”Å @nS¢éïìà0¬t±Ôâ£)÷Ž\O@w¿€éüàâôðíÉ!Ò¿¦Cÿz)‰rí½ô¾L›»¨ñ „=ˆ1ƒ@AT8k݈»a|/öŒk¿ú¡AC„RP™Î[â›Ø\n®*#–µÆ73›ŒY°r¬(RÙÚÊ2Èi³Ö±bÐatoa­<î¹å' (¥;çà’#+Ucåœ÷è`7€ëèýf“C8µd¥+ K`TÑßá&q~Ù˜®¼}gHR•X`áîl BÂZZ‰x'ðÐÊûÀ£+÷sñ šEÄ»iޱÊ÷mäÿÖª”£häx¿(/jô’Ú LL5lË¥³—Ä…Ú§ÝÕî•sb3E0ˆýøÀ݇‚«‚nô(öÅegO<`Õ sß‘º†ØÉfDMéÔÖG,²åñ©€¿æ)v  Št ð° …zçÍÊTh]«CˆVõJ}|d8S£7 mW©±xÞÂu»KM\6¦¦ý¡n¸×²‘a:Ë™>Y†b©Å$Y¯g´&\…cˆ@ñ8PT´Šê“ù£·ŠaâÑ÷0«.´mJ¬=±©žQ9mƒ} ½#êèð‚Â(”Aѱx¾ÂqVÜØwcùšçD  ún ðºt Bá]¹ ƒnÛP[绚܋K>næÉÌu"…æÇp¾ÎqËKÌÏT5v’l@M<ïðèŠ3·ïý4s¿uß–c± -ùĬ*çe¯Ýg³=+•’%ÐÞæBÇøíónâ›NÎÓ‹ÙÍŸŸÇAÜmšNàÅYË ò|>/XObject<<>>>>>>endobj 5636 0 obj<>stream xµXmOÜ8þίU‡n+HvÙ…í‹tZzí!¡ö®PõNBª¼‰³ë’Ø©í°lý=c',”¶: %8~™yæ™gÆ|Ù9  ¾h6矬Úyy¾3I'ì?ì’Æ¯é`BçæÎŸá!ïñ^+-Êr³O®©kã$ù•ð´1%yí¥vÊhªLÞ”’”£RéK™ÓZù müJZŒ-¬°ü¾äåÊ=|þygüzBOÓŸ:P2¦³þÊG¿Ð2Ë(q+a±“¼U]ÊÔtOŸÖVÔø39¯L%Ç )¾–r3®­ù,3ïÆ8Ž’²0†..ø lÎÎå# _I¿SêL4¤ó> †ÌÒùü Ï?)`­¤Î؈ÐWzáfªZ•°[8ÔúаϰQ¥–+OKéÃæ…)K³VzI°QÊŠÖ+©ÃDȼ¡˜¸#Èc·K¥9¥ã¶èbAfš2׿ú8­€¥ôèöäGÏÙ¸lžS&4BH¦†E­+fÁ ¯ –ô;¿5`H¶ oÈXÊ•ÅDc7ƒìÆP ê7€?GHZ‹mð°”ZZáéBf‚áà¨ä-*•Á\β©Á« ï‹ZïÕ7b—ÒGÆ}0%C+V2ßçm;g¦Ì·qÓÆVœ"d4>²•Ì.9ö…\“óBçÂæØ†!S\ äˆv 7AÍ‚FãÆYfî¶yXÿTlXÞ³ ¥sƒ\ÃX@×r*˜n‡Æ³cN^Ù’çê¥ ¤Ž”›”^+ë|$,!–‘Ø‘Šw2?ä;F­ Z õ•.v{!Ž-÷*Ý\伈'»æøÿ­·”Jlpå•ùúò¢ôÒj€t%Y`;\+ [ 9}õéôäåûïÿùôç‹ó?¶‰"õ•²FWR{ºV ˆ ˇÒYÙämÎt9õ9¨Ê6ãS:)±9žõé§ÌÙG®’X3ÉB½è6 ¬ìÍã+í-ªG†éÈ$¯2,¯¥ Òx¡ªZ@sÀ¤…š2°PÔu©ºüêÊÙÔC20œŠW#9±%jZy[ˆ×€§ÜÄ”QI-òïQpÓVD~{€)>+Ýj²­bÓ×ÙŽ,t‚ëIÅ´õ®l”yft¡–íGìÈQ„ò\q"ÇòÌ”vü:h¨,DSzj…,nÕ@k¹¦_Œ8X ­üÒ€BެAYY&”Ö±Ík…àh ™Æî†#`<Î\Jwñ8F>£ƒil5’éœetö$=Hè8L<Ût¼·wÓ`3nw)Éô0=äÅ®¢ƒ&u € •TÙå¦ÓÇ”Î&1G@椴µ•øä´¶Ê£ÓÁ0Gêtnzq9TUp§ðVxƒ ÿìH”bp(ˆR}å&ØÂÆÚËM«´9bo¹†–›€÷HÁåwÜo9O•È ÛÒí±j›1Tš{NĶ)kç1žmj±}~˜ö»äÖjII†å (Ý©zª:š„>k—–µ=]èwn"¡Y{9ÀtŸTvd5¼‰ÁY:ííuÞ!'òQÖº3SBÆ[cLÁìhR[sz Þv†ÄìêФ<†ÆÁ®ÍâNõ‡ZðôññÃq¼ÿ©0óÊ7=ƒúpö>›ÚÏ>¼ýèÐåĦ¿Ÿ… ã p€-Í}W ëdhxrï "Œ°q`JèòWÔÆz.SI’ôÒǽÆnHƒŠâpAÁ¶H|Å…9öCmÄc2Ÿa†ÇKôjÒàHÖ Ç’É-oP° ¢%ë-_¤‚ÀrR‡dÞV¬ŠÝNs^D‰ûþmÀ¾N„"ƒOtØ=Z/Y¡Ê¡~‹Æ¯ŒeÌ`K¬æ>õÀ7¡F=F±‰…êÓÛÒ{ÉVw*t[f¹Ãf¢Šô}u›‚ˆ ôËÕ2ƒ†rO½6 8h¹t™U ×…¹âÁÀÒ@øð›ƒpÃÃÝû+”ž¯­8À U=¦vG*£ZF]å›ÑmïbT‚æ"$CÍÆU’Ï*|MPFA•P `g/ƒ8Z EývÇRsI¸ƒ£²ÊkåBsÆh€K+ª”¸@½¡Zõºäå¦b0ˆQzÁ(ó<ŽÜ¨XšPÚKÕ‹M.q'ÌÁ €‚.‹‰Ð²D7| ÜGD×í?Úp ºoïÒOÛ{Ðtr˜ÍŽhþtëûÙÇ“7É4Ð+“5}±¡Èå87y¯÷¡8¤¡Ê…GBóä£É>/XObject<<>>>>>>endobj 5638 0 obj<>stream xXïoÛ6ýž¿âP XŠÚŠc;NZ`ú+[mÅPwý` %Êf#‘IÅñþú½;J²•¦E±¶I‰<Þ½{÷î˜NÎi‚¿ç4[ð¿¼>yµ<™d<ì¿ù5]Ïé|BËkÏñ¡÷øŸ›WM¡i·Ñ–ö®¡ÊØ[þàIßGmƒq–jW4•ÎèÚñSUo+ýâéòóÉÙõ„®²[žNhå‹ì||ž—Mé§Ÿé¬ þ ùëñE7§“ûùdrþ|2™Ü<ýÚ5[\ˆÅÖZû¤Ý~±úæöü‹íí“vûåå×·'÷ g›ûC`âÆàik –¾ˆä‡„o—¸±à;Ë‹Kòe E¥±ª¢Ü!&W‰ái­>#K;­n­\I¯Ÿ=#(nT$©p:uø aA“²{ ÎG^¢²…ò•°±‚}¿B»æ×ˆÀ+otÈh¹1¡ƒ~Ê.ÕZÙö>0w ûf*]ÐjO…)KíµÝShgªJ\ÒE·Öq£=m½Ûj_íI…ÑXçSšj];öL§ì÷À‘¼R! DDB…Š Aù&Ç3ÃÔ­á|2VB¿5X‡Ø¶€@­*WÖjŸÑ;¼ó­«Lܘ\`„gk¯êÀ¢ø jìØÓJœh,6¹.2úÕíôö#>p™WøiÀf‚áóê8‹:ï@+€YÜ­OX Ìi1*‡d©ark@dRÆ@Æk º*ǹ³QÅQ@À`O;gŒˆ+FFâA‰À-/ NØ€8”щˆ¤Äj  ‚¢ÞJ\êÎÈ„^sJ„ÁTª¦Š)yNÈ ½Ç›œÁfèÅFÝÇ *á§GþÖ ”Êa#“Ø•qÇ12ýœ…鼪ÍziÚ)ð.{§C4k55-rêaÉ©Qd}]„&ß0-_¿ÿ=cKg×ÏéügiO\³ËìÂóZ¸Ï¦8Á‹ùx…¼o+Ù¤dçX–ÇÓy6çÝïíaQ*ÙÐl™› µíË=ÐÍéW|øÎ›ûé˜g7OG¶:7¬ŒØæõ?ñȇèüª1UÁ®}Á¶ŒÞÛBm¾U¾OpLÈÀ‹k)u.;.gœÕ!y`wÐ"3­.°Îc¡'·eõ}¹æŠÂ$-Ku‚:8´Ö¨NU¤}!µ¹§ÙT0fZ/E„zYAý! ª†èP”£?d‚ìj9Á^ñ•X®MÝŠíÒ*½ùí7Ä])úTNXj¢6ÄýЄMÛœ2Ä—ôœé“ÖùJ&IåIŠ~7¹wÜÞ^üeBƒi—‰ ™ñU»S{Éé£cir覹ÔÞÏ®¯ZœNæÙÅì‚—‹l.¨³ãi6¡7.oú™Ÿ=̦ÅãËô«™¢/Ú):]  ßvúT‰]LºŸüza1Ÿ³­·Ë“?OþÈíz-endstream endobj 5639 0 obj<>/XObject<<>>>>>>endobj 5640 0 obj<>stream xW]sÛ¶}÷¯ØQn§ô$bdùKÍŒ;£Èv¯¦²œÚJÝÍt(’C €–}}Ï$e)Ê´IÆÉö`÷ìîÁ_GÔÁß#:>ãéêàãä wð²ùaôþú':êÒdÛ³^&™ÿÞ¡IŸÇÝøˆîÊ<—ù‚ÐÜè]Š'¡t! Ý»2“úpòåàýõ aoÔîžÄ'Ø*ÎéE—”AYXÃá•¡¤(”L'uNké–2§™mõÜÕÆp`½ƒwÁyšä4$ó'ý(2J,%”–ÖÒ¬”*#]ð~1M–‚1 Ÿ-‹ £Sa-].–ê…æZ)½¶ä– ø…¥¼‘x^r[ˆœÊr±¦µ6¶HRAIžQ‰EXJý¢xÿKLFN“J¤ö—£Áá<Å!2G½*4ísÄAÊ¢i÷윶ãÆß*¼ý,£™vKïÅÇ]æN˜9˜K%h±ÿXú§éá;Àz![…6ŽC<ð,¿8˜æÉJžûÿ¯ ‚ØúÜ2qH€RÙԈĉŒqµ›àÍ^Bô§‘q…Äò¹ŽÄs²*”ø“÷ŒÓíEÓØÆÚ ú@`Bi=²·oßQºÔ1L(“ó¹0"w?ŸËgdÆ|Ñ–éÙ»×®|ÛžŸw@Ät©óqFmÌ É=!È´°l!ž¥uô"\»½ax `ˆÐ£L#çLõò]MH¶l B•|ä*iÕeõÉyÅT¤ãk¡=”LØÔH_} •Pû#ð̯6ßNud×rAm—*jkúÏ4ú„òº”fz8âi˜¥ƒàÓʇlãß~JÜrz¸ÃˆuËǃR½Z!²ÓÈÓ õýQZûâúÊ·ª8´ýgùøßÄ{[:5Ô¶‡‚ÝÚË·ïˆöX<»-¢Ôìiê¥)ѽ«~æÛI `kðöí‡OFT­U›VLܶ˜n2OU™¡çciê´‘Âú }㟤ŠÏ×TŒÌ­K” “µÃÜÂF’;y¢öíµÿ¸ß“‘k‰-ÕË¿=òHætëYn_'"%g&A =U‡§Ø>|A|’6ܺF§«ZU«[[¦÷:1Vî21VV3~ç#ýº­ë 9¸C¬‡®Éé¨êðÓJg¥"hèìaªgJ¡yïÛ "Pû[Ä=.”•w÷oa»Û‹ªçðX¯1Ŭ-W<==Zƒ“ø¡T¥ êá•” QÊ)nDÂz‰9(•BØE}LÍt™ä t•€±¡³îðskòzoFØR9n~¾KτǶ×?vD ²’¥ƒ—OÂX={†1„‹&Sz¼Æï êUä¼¼/Þ<äé5{ì2¼«5YD`ÛŽÙZ~mõZÝì˜+xa°zQÝ9czMf/¤Þ_w¨³ì¢Ô»ÝøøOYtsy{O?(n—½;áVà›ÕÄNêª`î|†rt²õ²»ýøC@]‹Ú¶w~ŸAmÁ¹W´]úì•Èø¦ÿëU0¯ÃÄH+éÚWH{:Aê¢aø<7Ñ·TIQ–Ž Ö ‹ J7É£ð]€¥Œ÷áÓšñÌ–Pd+|‡ÚASåÚù“4:Çwô”™Ì”ðB§é¼ÍÍýïh·^G'O‰TlÕH»ê£ÓZAc_Ð2ÐÃ è æ¿ÇÈ,´K¨Ä N%ˆ± üÍ̽Ù,aL|ôŒÌ°uiCˆ"†5$²XQµ>RÁ çnpOÍŸ‹&Ù^;6L^GW_[me~8ž\Ý]÷ÁîÂÏ|^†Æ%· îúŸ6û½6|%[9õàéê^R•èïÒ–˜DœäitÜ¥™„Øç¾$² š&··£Í/(ý0®,.@[¨&ý»_®&õ7Øeý`PÛðoÞ;`ñ3“ùtšªX<7÷†ÑpüëfÕž5<™¾Z5FŸ/¯p¶à©=„Vi|UC}ë 7ýÁ‡ã:Q4ü£wVÔÁШ¹x†è©"⦴eçáÇæ¸´²O©q<I«ŒÇ˜õ¾“5á~C2Ïø:׌Zз®Ütð+wè”Áÿþ‡áëH]Ð#J^¨ã®÷’dOI!«\ùLõßEV¿„pÌÔ¢z½µñª¦@Anfx}<êħǧtvŽû^h‰Ü[Úݸƒ‹J :åÎk!Þ” ÖíóÐ!ÿÑ•ü´s#™žg'§¼áÕäà·ƒ¿DdÃ*endstream endobj 5641 0 obj<>/XObject<<>>>>>>endobj 5642 0 obj<>stream x•VýoâFý=ÅHmtDæ3$G©„@ŠŽ„kâS¤UºØk؋٥ö:9þû¾YÛ$æ®RK>´^fgÞ¼y3ë¿ÚÔÂO›º}þ 6G—þQËkasÿ/YQsÒ¢s¯K~Dõ?´½~ÿŒüÐYµÈj?ÑL-‘(™R`6£ÉqLW³Yzâ=jQ£ Ó°6›^ÞÓþsA?/j°™^Ž'¼~˜Þâëââû×O2!³µÊèóO~îð‚¡\f«A”!t¾¶»­ÏÔ¼_'ÃÏ3þ©y7ž‡÷cޞͯçÔ¬€¼Ž~›ÞŽT,¨!µMvƒÇ«8¾Jîü{+›mmw,Ž ˜Š­Š;ŠÅªg4šÌ†×Žˆ jþqFÍyHÍ€šÚÄfe*`üÑìqz;š}¾ãrœ†ƒÅÂñ¹×Åb%µLTðÝþ‹Ò‡~8õâsAU/°Î¶¼X-+© Ô`PqU:ñ¼Å‚ÿÒµ¢ì¨a\&ÓÙ8¯éôÖßM†#<þÐ XåÏiɽÍ;ß¹¿Ý竇}€zL¥%äzÏþ|>áÅâ5«\ˆe°™Mo?æ~gÐV “Ùü&6ÛXz¨,çEpÃÌJ ³üZ®_±õ°Á¸š“q°ˆ¨z£Û-§æZf*É®%NZ©SȺNI¦éöføqL‹ÚÎd´;ÒRÂθg‘¤ÝE*IíâÄ#­R¯ m"­ÝÑFiµ1݈'A|uD²´6[ÉM±#eK!Bµh-©M¶Zs€Hã )«Z†=(»†ãXYKøUÂè8YJà{RzE±±)™“ ~Í&õr >P»çõ˜PÐ9çeXëžaž 5COG´)>/XObject<<>>>>/Annots 3056 0 R>>endobj 5644 0 obj<>stream xÅVMoÛF½ëW ä U™EJ²SôਲaÀ°[‹m/¹¬É¥´Ér©p—v„ ÿ½où%“ޏ—J‚€%ç{ÞÌÛÏ=—&øºäÍí/Lzg‚'öϵ·=ßw¼‰ïÌ)!1sÕIÒº÷øœÐÌ;³Goaˆ¦§ÓBÓ›;nu°ŠïƒG¾ ‡Ù†Æç§äN)ˆÔüä„‚¨ˆeBA8ôއ@.dzÇ$ݳL°;Éõ›àco|î“ !«v<õŠÃåxùö-m:âÄ2NÛíxDw{–Od:O3â_X²“ü]é`B'pSëbêxNÑp<¦õ?—$”áYÌBN±p Ìö‰YkÊ6Ðh8HÒ(‡då¥õÎqœÖy ”ŠÓàkë1ÿŸŠ¢4G(âJ ³ÿµ%2øÖ:V†å:.²ñœù|aƒºNH¦é'b†Ì–Åi2{¹ÚåFÓOUÔ|Žè&7x‡ŽÉœSÓ²[™VŒ€]ë< ÍMÐp:«LÑrËÔ†—†­Î³y]Æ´OsJØ'NLÏ2ôW¨DÄ´•peF…䃀ü6Ò ×šmø+ Ñ¼¿åR¦ýVj!S?›"½~U¶þ; ö; ÂFè;•U]îàâGI³C†B£†¡úaMS©‰!/¦f¦J›¶µáˆ„!¨ÕÃ-FgÑqªä¾±ìЙ1<Ù¡ù&% ZÄ{hê²-˜T2ã:—0¦šzÖ‰L‹Q  h{“f‘P,;ׇecP2Ê5/ÐÙÉa ’$7v't¡Hd(£¸U÷¾;ká–eôËŽ™í‹sv¥-VMì³Vªø ¥gÁ`0_Ÿ:iÃöÚ¶€Ç1ªA¹2BV-Τ…A[#¡m #ô‚BÉ ¼äZ¨ÍŸß/¶Ck~hO‡M°á‡K@ÈX{ ”l2v/bïGÃÖ^?¨×1ĸ •©¢Æy†5•Ù† ©Û ª†þc® =0…V¡Œ‘ÆX‰X„ ˆ©ÁΈt¾Û¡¹b^,¼)–üè¡§HërÃSH•ëÄtÛÌê‡a„Õ‹üÀüð¦ÄPÍ·%Ìj&(ÈÖ§¥Ý ¨F_EÄUžüˆo‹MRj€h…U—NØ[ÆmºLGeðr–î@í¦Úëa9„3xi¥‹xFÅèLÁQÄcÐdù´¾`uÄl]{n `ÙP:jƒÚwG÷?m—*Túã’<ÇõÝÙiAq9¨_ÿ½º]_Þ\S¤XScb“ ÷üžg %úJgW«]]¬nG´nþ F°}µ¾^ÝÒ·z•šMhŽ¡ó›úüi-S]Nê\Ë‚ÓaaA¸?Îu6–iÈd¿ÚT'¸'¾3óf4Ÿ-·¼ ÙÛÑñ×ÀßÓ0·[͈̓+¥¥×.x³ÉÜñ¦¸Ý!õ¹¿°ê« ÷gï_Qìendstream endobj 5645 0 obj<>/XObject<<>>>>/Annots 3058 0 R>>endobj 5646 0 obj<>stream x­WïoÛ6ýî¿âÐ5˜»ÚŠÅI»OmÖ´†v[=Ã2´DÙl(R%)'FÑÿ}ïHɱa]!†cÑäñîÝ»wçO½1ð7¦éœ_yÕe#¬ðÛ˜ß~{Ù›>™d3šÏðLÍÆøŸž4½ëí?ãÛÙ<›ï}û|±g0Zu+:½šÑxD‹7ÏŸàC/ć¼eIÓT~@•¸‘ä')¬EÀ›¤B–ʨ ¬![ÆÞ+ˆK"ÐzK¢®¥pž”!Ak) é¨TZŒc-Ý:ÞÔ.{[ɵ½‡ª|´øØÑp<[ý­mècãù ò&ú–ì¾{ÿú%>éJ‘à kÛÚ[ RkeVñ¦KÊmUãvGbÉ;T¸ÛÇ­ù>t;³Ö‰ÉŒxcƒ|ŠÐs-R ¾} O¼÷ô é~%õsk|HkÊ}1E8@2´Hm„Sb©¥GlbК–’DžKïa¾ñ]Ç·ààñ%vùQæ¾ùÜ©%N+Ã[v`2쵓eO[‘ÆŒk‰„Á?cþ1a‚ψ9Q6çÊç÷Ì€„fX+pÅKf‰Œ`1„ëÇ\=^å>º´ãxGÉ>åkQ#—‡Ð_2˜ìÄÎÃUƒ$ é/Xr² Tç+c‘kðˆ}ÙÝ€r‰§»-¹mtÑ‚¬ iBd,2‚ VFÙà\LïÀµØ Jˇs V6úÐÛgTË¼Ñ 9 [¾X±÷‰‰ÝýˆÄïe]yÀ†âRxy2’ó.Ü–oi|‚sl¥íRèãüã® +Dħ…vÈp-ÄR;›Ë‚‹{i %Û,Ë;QÕZ>M¦Gt‘M™Ôph2ɦS<}>JK-Öôù }ýEŸˆ’otõöíñ7Káèáñú—tUW*ÃxÕ4›ÏÏÙÞë‚ûVNTH¶†£ÄÌ# ²àª\Ñ0‡B ;ò.€’•È»E çtI ƒ(¹jƒn¯ÎJ«µ½Å‰Îû¨Ca[ƒi5¹ækàœ@Öp/t‰.ß¾y·xöfAŸãã}ù±3Áú.ª©d¨h69ø*Ë:f±ªýUà¬p×}6|wý(Zº×ñ#ØÞ¯%@‚#*• PQ¦fqt+ȵi0A¿S®Îß´Üe¤ƒ†¬wy[5ꦽa¢¨´p*.ÛØºR„waFXý¶ZZ­rŠ…¨J…TQÉ$9ÿ™r߯¸ðbi¸÷ˆ«s¥6Ò ÚREuFB+­«¸5)”ŽÊQÉká×ÃÀ²žÚ›¦îD()ªŽU½Ë#º‘Ž%u—ôˆÎ‚ÝâÞië^£ù"€R°• ª–’ú„¸¯rßNæL¬éy6ÍÎèiç{Vñ®Fì»<½|ü˜êv[TcȈ¶7ÐrK,óÈ]j•ur—´.d®;ôZwÃpË1¹=k v¨2<3žq 8„ã•„X1"äDlEžçíðïªuRÙÕ mˆ×òrƒè®^ÿü‚~(m-ÍujàÜŽ–060!“T`>ˆ«°$ÛäæMp]–(1h`@Éö?nϵõòº½ý?Õt;C ˆ£Ý´ÀDÛk]¶ó—¡qBÓ­ØRélÅò ìe§-p™·] ÇÀOÐû:ýáôfnèö¯£-zð c™¥÷ÖéâúÚ< ‡»i¯5UFHÚõ{"ɺBT{P}„¢1èßÛZfE(úª³ZmÀ¿BÊSíŠÇl¬Þ .èwƒ€ã "Yn¹÷T°‰üi¼ÿœì¢K"Æ4ÜâjÌV¢›Aw[‹O˜>bÅûáÐ0§ãhÌ#,OœE$ôšçCT­0psd_a21ÏŽÁûæçãñèâCý9×ùØ"˧Wí”:¾˜egÓ3šŸO²óÔÕ¹v‡ü´øÉæ±GÄäc@?íž'®GјÑåýp†Ù5þhàíg£y6@bPXóÙ/½Xô~íý |ô>endstream endobj 5647 0 obj<>/XObject<<>>>>>>endobj 5648 0 obj<>stream x…VïoÛ6ýž¿âP ¨›ØŠc'Nº Ú¬ÞņzÛ‡¥h‰²ÙR¤FRqÔaÿûÞQ´c¹]‹…,‘wïÞ½ûñ÷Ññ3þË«£W‹£q6ÆËÝnE§ós:Ó¢ÄÙÙ <ñ;òÁb­<ÕV™ Ý ÝHÊ…¡¥¤ÒI©[ª…÷² álc – U–ÒIèšÊÆäAYã)¬E ùPË<ð!'s©î%Á”]~à—¶¤ÐÖ’ž/>Î:ÌoÞ¼¦ãîåå £ÅZ’5ºåcMzÖʬ¨µ C|¨°ðÀD@¹ ¹ ¦t¶B„:K6&çlƒ ¿ýýÍ›Ý1Xp²vÒ#"Ĺl£û:Ë¡ö¬¿ôT5ùš„0+µZæR™\+󠦲`°%±Cб^(p@ø÷ñ!ÊŽ‹µ|…ÌU%4I“Ãк± ¸ö^8õ]’¼¨N$mW*ÇýJVÖ@Q jƒ¯È®tºe»]Æ2º1>HQ ìŠM8±CA>bà´âCOArâ¥ËÜòFi ™Á}!kibÖDFV ›Y0J2¯E(­«èv 2™ i©V#¾}ÝûŒ´ AËôæöyFïT¥´@<‰E plT%L#4Ï…{ù@ŽHÝtz… ¼ªjƒL´ÈGÌbu2áxAP%Ú˜u裌H5!P<µpAåMD×ÃS³’(3O›µ4;»>9IA 7e4jd§¥äÖQ¾f+på»jRŽòT “6N6è-4±–ºÆ»]÷¨.ñÍaÊCøò;>Á…{•M¹•LP–“I6âW1xª œžþ³5ÄmfpzL× ©ÕÜU@òñiïó+áèxníÂâév€':.oŸSߨ3È~¼å÷=Cÿ¦_•¼žœ|ÅotS ‹§dtù¿EkD¥ò;Žá\9þñv€ó_Ã]ܘÜEñW9D@)}ÉÑ6ÂòD}Ù*·KÐ}ì磘…i6›]òç—Ú[8)‰%ȩި°f £jüÚ6­\oD‹zŽAïÚ& ž¥ö˜-Èm/ÿ > _,-Ê-Hãïýo“Û5×CJœ ¥]AØh8¬o'Ñ•Rc‚ÛýdÅ‘.²Á½iñÖÙ½ÚÍ —ë2¿—Îc¥é€¶ …s×Eœ§óÄíˆÇàh2c¦—È£wÁ59&}ß8Ÿ;ÏâÜH…·q¢Fw¸Mé x‰í‘¿Ôݾº«ï:¡wXþ'­óƯÂX4¸XÚ¦ ÁIlœÔµª±¼…Ä4æØ¸ª·yÞ[—öšÖdîD`™ë!­%sÒ¥t•ßÉø<»˜^Ðì"5˜wÞü<šdcúÉæM…e4bà Çîìè²›±k]ЯÝÖé½ϲ)¤ÍMmvþ‚¯½^ývôp¹šendstream endobj 5649 0 obj<>/XObject<<>>>>>>endobj 5650 0 obj<>stream x¥VkoÛ6ýî_qÁƒ›ZЉ’­Ø>4]†ð­Š¡-Š¢lµ©ŠTl£Øß¹ÔÑ’5–؆MRä¹çž{x?O–´Àÿ’Ö¿d1yy3Y„ öÕ†N¯±fA7)ÖF?àKâçñEΤÑÖ=»ù89½>kͨPE¬*K&%AÖUµtu¥Hà])‘Fç‡^ 'ú¥Rh¹5+JM%UBÎÿè ÚfzCn«¨9¯5›fEQ;çj $É*%]v§BžYP°\ýìÚT¤ö¢(sõc·×e¸æWX´Z…ë5~%³;]C_º8þ…a¿i7tòb¼:ÓŽö/ð˜ÿ;=¡¿:"z NNÇÉ­¨èD‹B=ØoÚFü`b ë¿â˜ÀG¸£è‚y»UzÌgslCÌ7%uW‰²TÉÜ'ŠpJ;ëÓ-¬­‹>—ɱdRäùÉÎsM^›ãúœ~~Œy­Ój7\Ô'ùý,Q¥Ò ‹ÆhÚm¤S¶ÐÆÑ›·¯¥ÌRUc*s[=ÏŸ“)]fôûg!ynXoG 7Êæ­rM¼&O¨y—å9$Ìz •Ê•°Th¼ ˆéNäµ" mƒ€^§8{âÅØøÈXmÅ]°SÓNhæ¿ñþ˜Q\µEM‘;”ª%q¼VVYŒ“rì[!„ÇêŒSSîW#c™æ+„ÙtbIn•üÀAd©w–¼ I—¯¦R q Vµ±jÃ4 Ö¥¢Î›hëð(˜ f†^ã­³»ÝÇ};³*øÑcì5[¸dΚg„©iN¶.K6(6ÄÆ wæèÑÖ«zÁÓ¥þµ‹ž H<æDÜ*x¹¶O?êfÜ;¤=},Ç‘F7»cŒ¾Ì9ÐΡÃFJýU™6¿;[™‘p×@í?Z ŒãåÿË Ù*î•gêíð?Cë4/qÎÇÐÆ%Âjè%Ðø×C{E=àLCóì±ÜüÅ4>Ð;û+jÒ{0Ösµ[´]­B‹¥UåÛ•øÐÔíê1y¢ô÷Ç0ù¬‡“=ýDßÇÁÏi×¢!üƒ/ÕjLM;xz}Ù¶ÕË˳ð|}NQ´èÚSnb‚U¸ WF¢Íjk”I€¤šÕÁwîÉl}¢ç£7]3nyÕù" ×+tõX/x藛ɟ“Æ€‹‘endstream endobj 5651 0 obj<>/XObject<<>>>>>>endobj 5652 0 obj<>stream xµVÛnã6}÷W œp [ëKâ¤Û·m›nZ´ˆ>$‹€’(›Y‰Ô’”/ß3¤äÄIë ÛÖ1 Eä gΜ9Ã/½ ñ7¡Ùœ¿YÕû°è“1^îì’Þ]ŸÓdL‹{çßá!ëxÈÍF®¥’Ñ’j™5¥Vù™‚D–Iç”^’ פÎÛ&ó•TªÏ’üJ9Âׯ„Ç$+±¨eNkQ6’r#mŒýL_å[£i¨RË•'¹Åi>¡kcϽ1&SD6[QÕ¥|Ï/ß]é*™qäSl˜N“Ù ÿåƒo胰”v†œÞ9éiKw)eK<ŠO/Ö·í‚8x¯4âU9e¦ª„ÎI‹JRÛtÈB³d>¿äÃmò©ÌDãŒWùo„#m'ôKÍ…M^ræèÕÔiHïÏÑ~Þ4zéú„n™ñ€\/‘}ÁyÔ ”té÷àv¥rCV ÅýÛ(`Ù_÷ÉXê§}Z¡'R)5-Õ¿ÞÐÆŠºFwì}¹„n Ò’¥GX09p›²K*P>ž¨ÎÁŽºh«å…,\á4‚Al¤ 9]ÈCRqµW‚÷ìÝeú² œb‘•ˆ S–fãÞêO>pûŒtB?±A¼Ó íÃòÚª${`vB¿ÅKkÔž8šÍg¹¥3èBÌ ÖX¿N® s$ȤØÄŽ…Ü…Iëòz¡³7…?„ש “ã hsøÏâoaÄ8`unžyvB ¦bxuDz«X<œRºÃÜâx÷Ÿg%ÃRGñ¶T§ûQ¶ßÏY¥€/èFuE8=œ“ñU!ÅÕÕCýð꘣¾f傪æ]j aAÚÉ&¨; Ää– •¶T"g.y[–0Y—àeãY²\fj¬Ù'«m]ªLùr‡£`´¼Ë.t}tôpçF(à‹¶Ò†VtÇ´È[‚-¨ü//Gî)_w|A£ˆÀÑÚüj¼|4Ãè€Y(OìäFçÒ–;æk›"tNù Àf£¥u+U't+ãÀ¬deìŽõ],e…¡‚ËT¼R„ëk´°ŽÜÊX”'‰a]µy:>O.f4¿<ç»Ñí7?¦É˜~4Yþˆe ”¸stÕhv™àJE·ÝÍÒñ®‹ñ<™MqW…¯ùÅ„_ý´èýÞû«Û6 endstream endobj 5653 0 obj<>/XObject<<>>>>>>endobj 5654 0 obj<>stream xV]OÛ0}ﯸC  mÓ–Ž=['$^¦VÚÃ:MnrÓš9qf;-m¿}×vBih@H¶¯ïǹççO« úíB4´qÖºš¶:a‡6Ÿþ©œ?B·Ó”l‡£LwÞiDçažÃõÉ Ä‚iúhz×:÷¡KçöF»×ût'xfL!¬+ L€i`9à½Á\s™ƒLAUƦ¬x¾a,±¬x <…YÂ’­Ì’küÔÇîÀ(ŒlðžÞ £ˆVIàòƒ[® >/XObject<<>>>>>>endobj 5656 0 obj<>stream xV]sâ6}çWÜ™L2dÀ|$íS³-m¦»m˜v:¥–A»¶å•å°Lgÿ{Ï•l§–|Ö½º_çésoL#üŒ)œóo”õîW½Q0ÂÃöŸÙÒÍrD·AH«„&#šßƒù|A«ØYhõ/é^Ú{]Ð;#…•$øéõêcoDÃ1ìbØ•…È(©íÞÿ|jÕosA~õf9%vNhˆàÃIXï?XR%•"‘d5U¥¤¬J­*RI*ßI£¬È#I{ewôøûÃǺYÞÑx»ñ^sÎ)\apG´Ê­4倌L¤‘ðÅç'‘Vü.ò˜„1âPú]šœx—i0å}rz÷öí€,b£vüe"?P¬·¥=¼Ñ“¤Ê#«tN™Úî,¢ER=Áà Š*åÞéÍGÙ2 ¥6$¿ˆ u}ãcc8™aˆÑÄý'­b×Þñº¿ÔšÞ|Y_ë'rsCDYÒæ@…/³Ó÷Ösâ=¯Nz¶m9ízßgW:ŠêÚxÚoZûýùW“.ü¾ãV“Nš6øÂ›¦¿B¦Mã‰\S,­P©ŒÑþÒªºá©ú¬ìºz/#ÁA~0p¡*W‰’Ršú {(ðÈê­äÉ[>/XObject<<>>>>>>endobj 5658 0 obj<>stream x­VÛrÛ6}×WìdjWŽ%š’lù’ÉCãÖ?µhÆU§ „š"´ìÉäß{¼H”'ÍÔ¶dÀ.v÷œ=À‡ÞˆbüŽh2å?¹î½›õâ(Æ`ûe—trsJ£˜f)ÖN/ñ„y<ÈþoÊfF$:_’+‹ÂXOÚQn<}(µW$¥™zÔ‹,<뜮#zoÖÊëµräWÊb Œ¬LÂ#ÂÓû»Û_IŠüGO‰vb½ÐËRxѱ¤źÈÔÕÑìŸÞÉMLÑ„ÃÇ4£ÉoIÿÁè„\!Öó¾Îýüè ¯Æ N¥3ëVˆºžßæ: Þ&ÑtzÎëýúf©1óþ;aéõâ³Ûµó‡Íü·»M)Q2Vxmr‡ÚÊ×Õr¨VQ(aôdJÚè,£¥ò$h#lÎ@ ¬N,eú^ÁB»— UW3ÒW£ñÝÕNÎâË+jàUIN]кd¤ÒTI¯TöDz™«’A§Ì;¾G{¾‘dq+‘˜ ¶X<íâUo¸·‡ÇÌPªCvU”f&Q®àÈ›:Y¬ÊÅZ‘ÉñI¹€ Ñþ—*'ó>óéï&ûŠ\»ôiéE!üöý ?Jí¬hwè$¦ÉS¡†…UR%*—Šl™)Ñ ì%x!Û¬4š²Ó¦Ucò$óLçE ù2H‰q-¼‡¥z”ªñ¯öд݆U°H%yÚ?AµSn8 ^!®R85¤Ú:l° òâ»moX8>åä~ÏlÑ)â@êä«P{®.„ùÉ•(8ʳF?#N<"t.°X$ÔÀ 꽤ŠÇçÃp<å&çÑ$Ø%™BAÅŒu]ðÚÓ(„u­¬È.¬Þbßò9@ E+D™q#”ÞpDRdШ§ÐéæIpF3P‚ £Î}«V‹¯ Ÿ/ô±$œ…Õ8ƒ‚š¶M¸äÓÍÂúiþ×m¦óZî›Õ{Ìû=½¥xÐxÓü6?¢«Êï¼oçGµsœg˜øHŸ:Áµ9wß¼Ò¡Üu#£çŽ3…_rI‡ oçýçÞ»Ù¶´ÈÎ( ´W¨ç¦Ãï7}ýý¦Øå‰6¹á6^oÁVÛ%€Â*_Ú¼‚êÍ3`j€5n"Û­MÅ—=›OaÛ/ÞîV òcYmÂÓÆX¨Ý7ž÷-5$Mè´Ã¢í\Bçt±7Çâ¨èOIÇ”üµ7÷ëJgl„[$œÜ\Ô÷ÇÑÅit69£éÅ4:¯niܺÃqÓÏF–k•û 4l†¿Z=<¯®l•¨Äû2ÑltO£ÉB°¦g!·_f½?zÿžÖMÙendstream endobj 5659 0 obj<>/XObject<<>>>>>>endobj 5660 0 obj<>stream x…V]oÛ6}ϯ¸è–ÕA,Ŷ'íÞÚ-[°‡a˜±b¨‹‚)›$j¢d'ößw.)*–:#iJy?Ï9—Ìi†sJ–ü›'ïV'³x†ÅþO½¡‹ÛÝÄ ­2ZÌhùf/—×´’n׌Vé䔾U¤‹³Õ—“Es¬ÉÉ|Ïxáâö’x%£§£EÒžÜ5d·¦Í%Ý+²M­¬U’š­hÈTª©-é’~ÿp÷mÅNQi¨V¹h´)íVWÔ˜áÎUšÇtWR&Òf KŠL™?áA—gøµ…¡ªR%/lU­BÄ ŽX[ï]”½YÊõƒ"Ÿ åÒ˜„èè|˜ßÆ-’Q%Â,EÁÙT¨fkäØÊøpL+Ž(3µò±ÛF4ªPe3>ù1¥s’ŸÆÎ~­DŽ„¿´¶AåvæyR䚌²ÇÂ5åxg:òÓ‡-r-1î jEªL—¨Àz²×Í–¤Î2d‡dD½i9+»>ëó,¥¨eïx§êÜÉ=B'u®­,Î »Õ-1ý £w‚ÔŒ””—9©GQT¹z2~q´XÄIHK`÷½á]”RB—¡\hõá7I×t3úfUCŠÐÝ ÿóMh=IÓ¦7ÿÝúld jK¯>‚;µúDü¿.>½lšƒ‰¨Ôsë”Øwæ|ÏDßGe³ìkgQgÑ¥çí³3è(‹-9zÐW§ÌKrÝîbziÛª25€ÙÑÌñ/¥(îs`ÈPÖ2~%‰÷`%ÐðyÝôÀÕ*s& s$f„§¹°6¦[SLIgôdZ˜–”©<±¡ Ögw¨pàp–úþ<9pÄqA(XÎpûàL¾ÃmÅSC;¤™×¿19//”-èÔ;Q» 8ÆãÛ·üÜIüMÇéùÍe|•\Ñòz_û .Âeš~0©»9¹ 0Gƒ µß]û;·§òÜQ2(—còÕl' p`]^]ñáW'¿ü”¦Š‹endstream endobj 5661 0 obj<>/XObject<<>>>>/Annots 3060 0 R>>endobj 5662 0 obj<>stream x•VmoãDþž_1*ê‘rÉ^b'N §~8 ¥Ä—Jhcošål¯ÙÝ$tüvžYÛqÜöÑ—(ë™yæíÿ1˜Ò¿SŠþK‹ÁDLð„?¦üñËí`ÏEDÑ4 4K&â²9åt?8=CºXˆÅ©ôä éÕåÑß}·(UAQiKîP¬LîÈ©JZéÕˆRS:)h[YUº|dÍ‚d§C÷¿Þݶ±F]a²m®œ@’,©?eQå°TÈŒ‡±8 g‡¤²A–õa¦VLx¦l®:Z³a™n:ý€~~T§ÄReÍ£•m½Îõ_ŠÝ™­C2™5¹Bæ9eÈD~ R9¯²Î¶«}íµßrQzʼÉU­5¢½Êó‡Pöp5•§ýFúPšL9ewJ°Ö››+š"ckÌÁ8J8uñBÄbÓ·¯_“WHâwµn[rÖ‰k÷´(3å—q +i³}Tö*GÁ8c\(A?˜½Ú);B³’±\Zô@“éPdeݨk#=b —;Í^í­àDZÚæèì6ørí¦¥G- Ð"[ºñ´uukÔ‘‚BsÏÛûý )ÓV¥^#§=öu{½âq‰8ÆHgÃó¦ïš†l#óxÞå/t™æÛLÑY%µ›³¾r–[ŒoÓ\:GË)†¦þ]÷î9o·) “ÏGÞ*•©5®ÓZ[çã} ¿µ"Œ(F3{Y­5òìþ²½÷L¨ž³\Ö¦p¯jFÀ×èÕSŠ#úçe+[o5ù«ú0d}­.‚—·`Ïþ¯ƒú§9®çÿQë`Pkª(¦Y¯ çx–òHŽCž{²¸wê4ë\÷„Áè'1þ´Úi°K~”Ö®ácž¦z¬O$í6f_òLòT´¬)èGfñLy©AË)ôV c¶‡UEUsb• yÖ‰©ÑWi·/®@×éFV^YA÷DÖFj€,Ç4ØÌ‹£½ ` ( 6ó’ý<‰Í‰Ý`zoPWð #é’vÂdw%¥Ê"Ê2ÜjÈì =çx Ð?¸ˆ™"ŒW`pjØu+¥Ê:Ÿ¼:3cPtŽÃ˜ª€8£[U* a¨Ž©ÐåÎä»`ZWX ²«X=ר©ÅK­ÑºP~uhHËT0ï_ó<õ#R®ÃÔîó Ü6IK*× §„t¾÷/ˆ¡J 4Œî’¾êƒiçð¨ñôR`¶®@OÞ.–Øn¨ÈÉ;†l`£Õñž¾GPp¿ç¯NÕv…nk2rÙ$rz9óxNÉå1P87õ8úΤ[N~X'ìHkíñ¢®^¤Qè¦ãKE(ö|’ˆ8ÂÊÅNHæ ßþ~9øyð/0{endstream endobj 5663 0 obj<>/XObject<<>>>>/Annots 3063 0 R>>endobj 5664 0 obj<>stream xWÛnÛF}÷W œ‹ÖÝJÒHÓ:ÍC‹4Ї¨VäÒbBrÙÝ¥.-òï=3)Q•“؆ %wfgΞ93þû¢O=üöi8á¿0»è=<á>¼{}1cŒ†Á2ƒÁ~‘Òû‹£eFÓIë]¿7&a8†ƒÊ [¯3êmÛ£5ÞÞN‚Û#ÛŸfGaJ¬öžnîz4ų˜=š<í“É-Í"I¦G³°Cü“䞶ϯf/zÔíãytx¾TvÞ™_µß~–åÍ݈xwL]xï†{ï—ä2e=žµ¥)Óˆ–šJ§#œF¯ž½óæìyƒÓéŠZdks~ïãAÒÿn6×Ííh»Ã}"mpÙÿ±tž.7Æ~ºüJä4J‡>44ÿë”XDö„'U•Z·.µ=ÿ[Ù?¦ï M'÷|—Ý- Ïy1ù5˜´JîW{X'zC&f)m*ø^6lØ9 Q4/é“ÞWYar<âí¢`¬e²jæW *ìmâ*µ¨Q NÑ(~^Š]uÛMFÝ4Uzäš±BÖ¬“ˆˆ«Œrß*•XD÷”´—J>Á6W…A[R”—Ù8š¸ŒŠÖ*AŒþ"áº2\q£ªéF'¦FE€# _͆ÙÌÐ5é ³õ-mÀ22Yâ5IaúQ*­@–6ѱœUß·4–~便¬ì€ÕDšÙ͈~Ƙ[ºƒ ß3&èÓÛcƒŠcmV€l )$ˆö¬ƒ!¢s)ýg©\ºËöžzÐèÞíw2+칡ï?è \©»>Ð;>B³!‘œTõ¶†iL0"´É’™9“ŽÖ´%Wf˜!’X ´àpZ w¶•Zk\båTÇD®Ð: Ž¦’j/Wî¿’u=7å2MBQø¦ûˆVò¼ðÐŒå •Í;Øq:g‰å×x‘ï9nUîbc3Œ½ˆV¤¥yà%8’KÉT%gQYßÜfE¬r½Yà çIþq¥Ûù wÒZ}n­Ö&‰py©öºò)'Äg=WÛ(nwæ¶?.ÛŽöóμíãŒ1~É¡XyDg®=r¯÷´Vi©Ï†Ê^1Êñ~s7ÝOlýé(Ç4Á?½~5äbÂë‚ýlÂ2ƒš*eÆ £uµ»{[Mæ(ìaÐÉ -ã ½­Æl!ì¸7 †Ȫz2¾e¿Ì.þ¸ø²šendstream endobj 5665 0 obj<>/XObject<<>>>>>>endobj 5666 0 obj<>stream xµVÛnÛF}÷WL•‹ÑͲÓzs뇢-* Qa¬È¡¸1¹Ëî.-«Eþ½gvé •8}ªmÈâ^ffÏ9{†Mi‚ß)Í—ò—7Gß­Ž&ÙƒnK¯/'t‘ÍiUÒlBË7Ól¹<§UWMh•>œ¬ÞMh<ÅS1Ò&Ð¥µ×¾UÍz„oô²<%Un;]ŸÐ?ƒå„Ç¡s†Êñ7iSZøõ`]LòúrA’¥¤1jÏæ}-£UÅžiçTÛ²óÈĤòЩºÞSi;S  £Üšø.°ñÚjlÑÕœ¡^‡QÕ´5ŸÒÞv”+C9» ´A„Âb¯ö_IAC8ƳY6ŸœbtLµUe¯û@™·ƒ“ç@%½3¼»,Ì fw×[¬yQ¦&ƒ§ãp±Žæƒ¹éàéXžžEìg»ã[v ©¢ÐAðé §ª¼VÞÕ0¥@J„^8†‘öÔy.H{Cvóžó@¹5>¸.@·ìL.)2ZI1vçû…^òn˜Øäªõ]­÷'™ ´)–U*e{C ÿðU߀ÑÚé¸!ª'_Ù¹'@=%N%¿¡)B–Ðýx¶”Øóól‘Íèn¬ÛS£ŒÚrÃ& O(ËÙB6|ë½ÍµÔˆ¼¡"VyÕ+¯èP;5Vº¥²VÛCER(v˜h|˜nUÝ1Ù2Ê.m.8°k´aO»ÊJǾÂzS34îˆ\sÐf‰„üÙÕ{yüþÕ«¾ÆŒ®Ê¨H`?M„ËÝÀ=e×âB²£‚AŸÝ îüd'òsºL­³w{Š:‘‚¶Êm€Þ ÜÖ5àâi¾ ­GЄ–óᢆàô¦ ,1í= ]ŸÄ’RšXd$ ˜0=Í\vc‰ËRD'*”›õõÌ"{o¥öG‰"cî8’¹ÙCUO%‹ “1iLFNN£¨.ØFG ꤀ɞë¾DÐÓÕaà-Ÿ7„£æÐ!ÛnSë<î}0YqM¬\Ö'C›ì'h£ÜÇ“âÚg-áÊÈé>_d´Ô1\-ã?‘ôC©¦5·¥w¥”xè/¶ÿèÙâM¼[ï¨R¦8M:mm”4î#zŸ=Ž5†a¨À–è "£Ú‹Ý»“˜EDˆ\|°t¶Ã(.Z¦jBŠÝ#Òßììÿ¨‚,»xj¿÷x™Zé§ôq¸%É„-¢#~šb9Ú$îG¼á=+€Ãþ%ˆ=Kcì®Ô­‡ð“cØ­4rÝ´-o@?Ù.^l höâþ¸¾Ò²qˆÃK\î†Ce‹^õÚ–-Aâ HèãÊk„×<Ë$¡¥Î”Þ .µÑã ƒù2@J(ULUâ{ßAABï –tø"rÑ·ØÙd‘ÍÏhy¾LMç·W?gÙ„~°9âà”↲ /Biíø< 6´)ýöèÍìeáÙd™Ígh|èa˳ úquôûÑ¿§ÿeendstream endobj 5667 0 obj<>/XObject<<>>>>>>endobj 5668 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]„v0¹ˆÏâ1ýõPäyñùpOƸ‚ÎéùkúsÖûØûg(Vendstream endobj 5669 0 obj<>/XObject<<>>>>>>endobj 5670 0 obj<>stream x½VËrÓ0Ýç+î0tpÝØuâÄIaXð*“M!”…j+‰À–Œ%ç1þ;W’Ä!IɆi§ÕëJç>ιþÝê@€?#ýg­·ãVุþSLáòºÆ<]á 1û8ˆ‘&¤R@.¤d÷)% ¡$…S3L•D1Á%¤ìnÎð|)Ÿ‚Zå4#¹ô<Â$sÂcš uÎbH˜ŒK)qžE ÿ|ü³uy}žß³H¼îP'ø}ñ¼T@x¢Tz˜“‚dM¥5ݸàu{þp¨-ß@,²LpÈ À3`¤È(¼Ó+S¼@jïfxmªoîÄ¡G$:˜åèt.ׯùp-  K¢W_Ú·ú¡FÝ Àëvý0ÄYâÌKÐïäÎASX¶ñy+ûÏ-¨,Suwú´ÓH¨¶à5,áV¯ûMo=óbèGÑ@[#²œ3ŒùQ`‡,ï-.·æ®ö)¨* îòÂ= ÉxFɨT° +]3&̺@¨¤ÛeƒÀÝq jà¶ º†|ÖtÜ Ké É8ËDRb«ÌéÛÖA?cz]?€÷".3ʱL°^´Џ=í lXþåË¥D~ØÅ//ž( ô=Æ­/­?=BÊ£endstream endobj 5671 0 obj<>/XObject<<>>>>>>endobj 5672 0 obj<>stream xµVMsÛ6½ëWìxâY±©/[Všé!uì´‡¶i*V&‘„–ÔG<îoï[”MÉVÜCÇ›$‹·oßîâk£Küt©?àß0iü4jt‚>nþص¯N©Û¡Ñ¶ƒ7xˆü:Âæh.)1™£Ð$‰Ñ”g’Ì”Ü\â!Ke¨DLnÊD¤dóXf¤2r†æBG±¤i®C§ŒÆ·¹pd¥Ë­†G+ùƒ&£%-DœË€®Œ%¹IËã£Ñ_t{ÓÌL"JàZlü•žø“•Y;-eó±A&­…×ÐDòvÙ¾êÐ0ès¨=¸ïõ‚~oQ³Ý¢LêˆpH&fò¸ªód"-G¢mø PèGbϸ[öøy[jØñâîÚý-žß÷2sÖ¬™^yÇæŸÌgàQ$c é?ÁÑ“ç~*îj,ÜSf¸ì¿gPp¦¨´7+í«ay·ìOƒ³þ †¸Ítý­ëÏ›_>œô‚xsÌ çk€ãC·(¬O΋{Àž~qÖýî®PÚ`Ðåí—£ÆJãendstream endobj 5673 0 obj<>/XObject<<>>>>>>endobj 5674 0 obj<>stream xåVkoÛ6ýî_qPl…ŒÆŠ,'Jö耬s‚Ê9Ša š¢,¶©QT£èߥNüèÖ û0`q [—W$ï¹çê÷Á}Ƙ$þŸƒïçƒ(Œ(¸½ØN¯#\†Ì3Ä’¯Æa’\`ž6Yæ<@óg…«­†þf87ˆ0ÓXÚŒ}ì"ôx9=Åp`Ò‰™5\.À¬e §(…ÍŒ-°4µN+ð\ð÷R¯ÂƒÉSS/•ÀJ8?Õ"ÚA.†øp È ‹€RðÝKD”óü9ÝK| ½.†GºªJg•¿–U‰£OºÜš5fL¯ÄÔZciåááG±¹{‚Ôÿ™{#ST;¸œ ƒëž©£¼ÍzXa ÑÑ~€Jû€¦CRõ‘Íʧ×gð‘ #bÛ(žtd æÄ®¬ÖÜI£+°ª2\2'R¬¥Ëi’8¦( N¤lwÅðêÅ Xß@ˆ.Jÿ,ˆ•ž·¦v#“:zv¼å\TUˆ7¢™…3Ç»©¥î){ ˜Ú’nÍê„®ü¬Ë ªRp™mˆäMÃ3£”Yû;b€Šv$ Æ© I|ÿÚO¸+ÍQ‡“ 5 ¾|Üï‡~åN|ÎnŽôâ Ö Ó*ùñÚê´BU/+ÒWí£­RrÍÔOªV©½eöÖ‚±žèá˜F •·Äþ;g©ò×Ëw‹ÀQÄŠªVîäÙUcR§âa·ÏŽI«“îüÕo§³ÙëÙ>5w·ØÜ}’>W„AnÖú¤éÍ#º9y•òMâ&Ä%¥°$KSʈ{Ap¯-+É϶x…¸“šÙ°ŽˆW™B¬sF¾¥E–I.…v!~15 ¹Ê]lCNô•)MfE&uO–½ Ñ0-n´¢V•%]鮥—ä(„Ë Yª’ïÛ-|6•:= ÏŸRªß}G¿]ÐAÔñ"ù¯óÂ[ISÀauÎú?Dã“*¹õÖé”Uâ¨Rˆ˜4ÜÓ9F§z#“ž’þà4iÍ öüñ>׺zÐq°ö^4¯ {™]ö2ûˆøÌûäm† É,g)”q0R™eÂ’{¥œ49þ\`Í‘J®mܦôê#7¬+ÿƒ¡`Üš×t@ˆV”Jü…²R/aÙÕO7ÓÖ¢üf·¯N˹Û2/;˜Æ—gáùä }wGÂݛۛQFøÁðº ò˜?ÎücDí6{tѦ“‹0Át{âõçsÏ£$œÄôÖHà%IìCÓùàçÁ‹©ôÔendstream endobj 5675 0 obj<>/XObject<<>>>>/Annots 3066 0 R>>endobj 5676 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Ô^BóM.3‘û-wôpÔ(˜L8lž ûB†A$‹Ðª¥,(1kÏA(4ŽŒT¼iøIÚ¡µyÎì-e" 1¼Ga•) šž3U‘pÂóË¡LQ]æ+Õ>ãϱºÜu”el2 `HD%å’ä*Ķ‘(Š2ÃI±ÈTªÃmh­\âEД®¹G­ešò;£ÉÊ¥DŠðë/UjŸÈSìÕ¦®¼¯ˆç—É}'Á‰¤ÜšPÊ tH9*S¦x£Â¡ÜçÁÔL ÃZx‚¬ü\‚ˆra™¸æ‘¥Üív9/—CUBj˜”Ú”«„óÌLá`ô³ˆ?ÓètÑŠ}õ×B–aYÃd¨0™q9*ÂXøøÜrs >4í2ÉJƒÏX„r'MÔ±渑%|õ'ÌÅl²þá™ Q/äë&„ãÑ +É·Xƒ(4‘„hi«>²eÊÝXàœ/„2vC2Ó­6º…nëŽêøl~” ›sYI{HclMƦêÝ ò‰L­Ç…PôlѦêw†¡Š7äwß ‚á†D{1àDz~*ƒ¬%±h+ w žðƒz-Ú@õñNº{ínÒ{½/GÞ9U:/]ç›Ó>vyûvçàX~ÍÔy{â:k/Ú­™ %Êqòî ˆÞÐY´XèV‡÷? GC@i®¤³Ã9%Ÿ ¿º7tœ­#$|¸Õ™ßkçbG&ßt¨W²H×bu… Z<ª¬À x«’Ð=»äÆ]M@è-¥[”I—˜”Å+ŸÔ«ì*ôÒ)x¢¡A<ëÀ³‚1içoð¾È^†Î­ÍñØ‘üa/´YøŒa{N^' 㟯ÖA†°5˜ l9U2ª)ÊjEÓ#œhì꛼–ü£HK¶…mþÜZ‚t™-yªÅUÁ.ÙçyRB˜lÅË +à[s?=N„ϬÀG÷÷§jžâ˜Ä¤‘´¶¸ør·Æ\z‡Ù5f£¥ÅÖzåvP° ÃÒZ‰ñ^4C¦Ú~«ªçUÜvF@¿áÁZ KvßÅ¦ïƒ O|fü3§H›Tý“&¬@CæïSá_5pý¿[¸¦·ÿ©aOêg½þd\ /hŒ÷^ß?ÿ 3À7¬MèMÒOp® DTEw/«o<Ïžg/zã`8À#/†èx<ä›næ'¿žü ŽÖ Dendstream endobj 5677 0 obj<>/XObject<<>>>>>>endobj 5678 0 obj<>stream xWÛnÛF}÷W Œ¸  ‰ÖÅ–A‘ºqb hPG@^+r)m²Üe¸K9BÐï™åE¢l7AÃàe9—3gÎL¾i„cšÎø7Éþ˜âvÊÝœÓxDó ggÏq‘†÷¸H¢[C~­%ÂÉ.%ùm!sQPbSIxcÞ’ð^$k™’·$ÊU•K㎠Oò«H<ŽäÂ'k:::»ALÁ_¤Œ'S?kcˆb¾ÑprŽH¢9\Š¢Ð*^YC6#ÑÅo®‰ÊTB©ð‚cs$LÚAFäx¤ÌÆê .r["…µ0äT^h\˯~bSf56ÙÁH)›8ÆŽ#«4’@¼rU Lqi ï?ܾ  ÝÖy™Çôa- mmE©Ì”Aü]À™-àÆÀµ@‡ì:ÜÕ÷Ñ;ø4äþ¥È´—ÀF”*@èÈU¨„p‡ækœç¼ŒÆˆ4U\€> êŒ)³ZÛû9@p`¨$ZDXs1Ýp„‹ñ[}rDWñ”é8aLâéwitÒ²k§'úÖæ>¥5?*£E4OôÇ7ÒßSÚüÝòèeY ž)ST~ð˳1ì¼|Ióë¿>¾¾»{w‡ÛRúª4»G/uP”0•-¢cC/é$],Ìñ€­õOÿÛûöDÍl8éÇÜ€òA¬r%˾T""8¤ ­´@O†S^pÂggôji7»ÖDWÖ¤éÐ9 ñìº}ðƳÙ%ƒ÷ÖÞË,ë·ÁýÖV¥éÙ'ªtÀ&IUr»A$¥ª” — ÊöíÙ±û‘Žhò«Ýv²0 r:2Ö·Ù¡%Z„Cî”Qs˜‡¡Ã«bSk˯¥%²Mœ‚ä%­J[м ògœL*¯€{ç÷çÙ¼ˆ’µ(éWçQ.µ–Lò>U¸ØÏÆ`\Cí÷4\uìîh=y@Ä–Q¨8*Íö[p)xMô˜÷ðÑ“t "'(¯´Wî¬(Tƒ[ͧö@V@{/¶Ž 醔BŠôج ÇHìòxÓœ'¨¥…GOV™@§Ãº£H•ƒ­>³¸ã£Eš¨DÒÚÞ‘œ+¿¦º“KôS˜\¹òPòÅéwt§ÆŠ$¿•†>ØR§Ç-ó¢ãšVω‡EÕbåºh;kz_ÆxÔ s}†iwó®(åFÙ B]·)­+0#Ì0óX™ãÖR %ȈÎõ@p¿01®czE,ýÒo™¶©Ê2Yb:wß޵MC]Ú”B3µ´_n€|nÓJËÉQ]˽ÀîQÄkæ.K-Eò™o°ìÅ4*«ÕÚwÃùØÊïâ*ö"áŠ~§D ¬‹–šÙð°u¸kÞKIp'hÛÍ~ñ·¼¿5ün±?è ~Á¤“—”zr ´ÂM¥Jú2îû›S‹x˜ò¬4-@ÝeÝ®gÍRÔ…ýÐõ•®ë²¸=ü'ÂôÛ5Sךµv»)Ö»ÏÎ]€÷»þšºº’œ<ób¯w{Œø§L_ˆáSn_9§V†%äšVÚ.…„K¨I†Éÿîþ7Í»°!<î/(·J-a?\VJ‰ <Þµ–ÙUòè@lk¡Ã®cd"å¶µrÕì×ã«óøbzA³«I­.¼«'ñˆþ´IXÒÃÆa¢ÜõÙá%“-‚h±Ëbenãw>}1šÅÓ þ¿€ƒ³Ù9?z=?úçè?¤IÆendstream endobj 5679 0 obj<>/XObject<<>>>>/Annots 3068 0 R>>endobj 5680 0 obj<>stream xVMoÛ8½ûW Š,V)jÅßI÷–õ6EOÅn ô  )ÚRJ‰*I%õþú}CI¶ÔÔ®±°aØÖpfÞ›™7ü6Ó¯1Mü–ù`ðŒù㟃YŒÇ£I¼ œfóøºù¡é~ðçªcÙ-]ÝáìˆV8^¼Ç—$øÃýæw¥ÊEù »5•¸¼\= ®îf͉Ɉ†“ŽDŸ+_Vž`VåªðTZ#•sY±­O´1†|d<á#çVð¼ÔJUIfC›ª>3á@e zºRîŒÒÎ{±>žÿÒ*\#ÌJj 'Dá=Díw‚­Z'…#Ò${ë×ŒŠ˜™ß£=+`®òµ²YÑ¿Žw¯¼G9˜Gçm%Á º’Z8GõaJ„g¹Õf-ô™¡–T›£V6cúÎ*Wªä×ãH–üØíù¡¬àÖ«›!>@¢6¢Ò'ZT‘ Æ¬vLcI‡ˆrñ•ùD¥LÉ­#ôÃå9á1#\ßãø>ái†ÿU½ˆÞ ©€’Ö éðÓ7ê³²ñ)+RèŒÙ‡ï"/Á;Þ§Ê)”Û§&qô’iM¢,•°äRc½Þ5ù¿'QV„ádÁ³:½Ž¯ã)­j9ø±˜m³5ˆƒ|É|šÔè²LÔ;¤_Tܦ¡K%òà ’ºH• /ŸÂ¶_Éè¢þÝÆŠ(»&û˜nÑ £3‡jl:N%j¶V¨^U$hf€ýìEèMøÕQˆbÔ ÝzÐØV3£7$SQzecZ¥™#¼Å>:bPn‰4yµÚ·þ}H.f÷bÜÇvÕ[Z’6²ÃœZ«\iŠ„»MÁáÆFL79fv“ÈïD¶ºÛQ’Yy}V1ݡٻSõAZ”MB·VÊ[„0þwG®*KãÒKNz}Z¸Ž•rÝCFdÅ dÞaNæ%­w@ˆÑËê}| /ª>ò.Ûõ“VÚ#øzü¼~¢·ýQÅô‹'/ ³~{MïvtLîÙ©‘÷ct&õ¢ÆÛõ²ã*„]hŽ–FÓСÝ ªÆ…Èôülá¯P£RXX` ˆ-CèE`Ÿ/S•œôÍ­z )ûn:z¶RèëÆ+­wÿ‡«ÉÉ úT”[T 7”mÁk‰mTòWQq+õ´®Ye!żsûjµñÃTÉÐe‰b¯‚–Œw¯>/XObject<<>>>>>>endobj 5682 0 obj<>stream x}VmOãFþž_1BIe '!ë•”tâT.U?ÔÚØëd‘íõymÒõ¿÷™µ`â;ˆ¢¬gv^žyfÆßz#òð?¢ÉŒ?AÒûuÞó\·_ù’No¡ãÑ<‚îì~„VŽÓ7›$‰<œ?÷NoÏj½±G'ã3(:ó•„ZL¬C:¢çu.²Læ•iP(ÒBªtIA.E!C·2õFcvy¶FÖÖäÜ=wÏèZ§/2/øŠ°¶ce *4NÁJättÔÆÆ‚{ˆæŠ$ð˜åzË„TJ‰H7tÍO–¹H )cƒÄ9ư„Í×DR¬RI"_–‰L 3¤õJ+î+$«L”ªB&æ‡*ªK‘ï°«{8»;YÜ€\b%ȆÔWiVCú©r‚MHHáò’æ×÷O7_qìÈæ²(ót§ØÉûÙõGt‰ðêJÂxÂ,|ÇwªHŽGþá‘QÿJ5jþ¡Øa=Ò9,)Øó>’¢_¼H7êþè/õ7®0>æ«eëm®å; ÐzN;SªLzíÍ6Í–êEÖ43C$ˆ¥HË -Jt*H·VqLK ön„³M¼0,iA»£`”K Ž#ÿâ®ê)fH@w QZ6R)´S²¼lòªÈßœ¶Y>è5·bM¼¦«Jíܼ¶3í3ŒŽâ შuøÜ¯q²~Uû–c î;|¥é¼nS±þ@³«9™ãûéÁÔp{½¾šíK<*tX­î“wÚÖ¼;ª4ˆKâ b³rÕç¸[Hv‹L&îlvÎ#ì3º0ˆ®t¾7ÿÞ€K¯¿éUJw¥ 5ÝcªoÚîmâƒÁz-x­hÄ"{{_6f™µÙ’MªàZkp<Èõ'{ÏŽ9ný}êZÅzg\Ùðêµ±Ýý*¡~Ýòçôö¢~a]œ¹ÓÉ”fçSwTí_Þÿ'c×£O:°¯@_[nÌ•öÉyÕ4– XÚÕVEÉr%±"SoæNÆxsíg³cu3ïýÞû_úÖ0endstream endobj 5683 0 obj<>/XObject<<>>>>>>endobj 5684 0 obj<>stream x•WmsÚFþίØIëf@0Øi›iRÏd’Ô¦Íf:BZàI§ÞP=Mþ{wï$¨]dì½Üî>û쳫Ó_øô7‚ÉŒÿäóË¢ã{>]¬¿Ô†s®¼ ,Ö0öaöräÍf—°ˆì*aw8„×`2L‚ ƱH7p÷ùæ b“J…¤¨Mž`j`-ˆ4ËÍùâ¾ãÃ`D^"öò«,p‡ª‚6"Ž!EŒØKh dR¤_1[„7°ÎÓЙ6<•X–]‘öÓ<±±ô+y‘ÌW1BOæfÄ9²[^2˜d´àŸ†'àÏ÷#x?ðýŸ7¿•gÄŠƒÿA„±‚ M®RæÂl8Ýp@¹@òÉ¢ô+„«ú¨Æú8:(֔ƲÀÏÀ9~ýJ§+wB§±ÜDoS£¯Ú=%i¡ýÕòüñµ¥+¿y÷›=Î/€ ¹†2OJ™t?o1…BY†QßÉ" L¸EmkÈŒ°Äœm—DBµq+‡Ý½¸\Ý_WõÈüE-=$›I€Î0k‡*sAYȺ–±I?Tj6[Ar¬ô\p†LQ‘*·KVA(#ôà5 W¡ÎcÓ§£Eï%’k+â«5$|΀;Ã")¤ú±øBk8îUöû®ŒÇÞdB=uÏœ¤` [âïàÖêØ®UÈ8´ L®,©;©Ëˆ³ nuMÍß8?sÑ_c«Š=­Š=¹ô.½ü®qïó´²ß „åqá]0Z.ÇZƱ,,5§†LɈhÈ„î–Îj ¨_‚X!ä.€`e K:óZö½öÆi)*£ÝÐðØ *á޵ÉÑŸW÷Ü|ø 2£ ½'ðffi¹’‰ËNÈ!ª z}Å·wÙ4¹Ê&¬r>jÂy,6?ñuôœÊ¿JÿÚÎL‹¤l´$”Ø51—^ìD<¦rÏÛÎËI.öã2:IÆQ¤¶–*¨XpF–…p(èiC*†czœÅ^%ÖM.Nû²+X 1â|5!X4È+‰õN"zMÃ8Ò¦ÓÐpþ„¶Þ mžI&›ØØÌᛲÞóÙTEií’à“e—s¸ùo‹ÄtóשÎcLØ„®>#È[²¢Ë3ã°ÅÑ“ôÑD¨¦e}:{àR‡œWc2WäÉßš„;ص¥à=¦³m‰Œàµõ{“Føw;·‚—¶Î¶ÌÓMIN5kYì[Ìâ Äv˜ÖBiz¢s=B™§¦5<Ú°ý¯êŸl´«{ [¶š×yóÖÉÒ%EV=Ǻ¬–k¤PÝâú gõ ³klkÆùÛ¦ïhžbôh¤áüª|ˆ®.¼éd ³«+ïÒmuøc0ö|¸–¡}³¨7qôôs«—îåÂîK¦åVˆ·n;N•¨·qv„Mý™7Ó[íè5‡ûëí¢ó[ç_AÙÞ£endstream endobj 5685 0 obj<>/XObject<<>>>>>>endobj 5686 0 obj<>stream x½V]oÛF|ׯØ5 ‰Ö·~‰‚&µôE€p:%:Ôs>MùGîZ¯­~ÜÇͧ?vC—ó—4Ò"ÅÚélF‹Ä?ïÓBF£«ºwB'Â&ä µEy±xh]ÎÇ4À*Þ׎ã1vF‹­¢Ôä¹9dzó´œÊ­9ÿ:CÒè½²Ž¥ê€«ÝÎhú”é¤$“’Y?(éJZ+wPJDNHN7´Œø6Ù^a7V8e)K”àˆÎ¨€…É$Q•Æ~Z^Ä“oóª[íÔQ¨23:,ìÓ,1·!“Æ£®’è—:ê2Êôò‚2íºÌÍâ+7 üGº$¯ §vÅ«³)Üêr1·f÷aýÀqAªèR;ÓE…°/x7R]_ÓâæýêíÝ݇»À†™6iÉ*WYèÕ,:ËØÐ5r¶«œY æ9°?k˜ãé1[S¹¢Ë„î=!O¦mUYå®ëi!@{°¼8Æå^Λºô¼Ü£x:½bóÜÇTòß)å ]JLµÎÕy…êûçZpõ¾)Ò¿ÿ¿×éÿ(Ô?P®«ê§+tï,×çÆŸéŸ=>r+,uÎKµΕ>î”Ãwp}fBâ³r¼À¾ÓÃΦ¯Ãi®žïòU ‰Tûn[7ÆÚzÒ´µwÕ}䦆÷lák9T ÎóŒ©Þÿ~û.eKV<¸P »‹ñYú2”|BœÈ´÷^8ñV}‰’ÙNä´yÛd Åé騩ÓJK÷C¡a­T•ˆïLc[ÞR¥UÂ…ø/i …Ðeðcà| |ˆ¹šÌ`šÄ}t684¤ŽY?tio²„:ÂYØé!Û¬â*Ó©¡Ž{ìzMs±)oDòváOòxAc„Ž!E¸{,rÄóD`¸xƒQ6È\‹‡ŠƒˆÐóŠ{›²’Š\ÈFy~Zo„ýKh“8K V'IãS\îñdg|ïiœù`Y(Q¥´YáŒ%”½’°}”3hļZÏ­ËzN‘²aäVI àïV–DYø1 ¾òéÖ12YY«´Ë=ê'„PMÙ=$H2­©/…Ð,]Lw~>•xY€e%¥*ÁíØð䤅ü± ÓœŸïßI¿ªC}xpo…öùñî™Õ-:ìãÉh‚·ž~Ìï=ï ã>½1²Ú"¦Ox#”°¶w<äïÞŒ&ýi<‚)BN§3.ÃÛEë·Ö_NFÓ endstream endobj 5687 0 obj<>/XObject<<>>>>>>endobj 5688 0 obj<>stream xÅWkoÛ6ýž_q±¥«’ÚŠ©“l耶k†E—a† Z¢l62©Š”cØß¹ÔÖš¤èöaqàMÞË{ι:Ò!'ü­ÞLá‹ÍS¾¤³ëshšÐh@“+¼‹ý¼‰‚·¹NZ¤å )eFi's2‹2r!L?]Ã7d./Wj£)Kn%›ƒÎPdôFæ®×=ìvœý훟Éí2I±´Q®2gr²./"Wäæ…«¾Yà²ðÆvÔŽMÀ{$tÜõg¶ú‡‚’T,)—VæS_IáÉûLh«Œù\€U.Þ·"“°k+±[G»,Œ|*”¿¡¤ß`‹ ›ÉH‰”š¨úEÒtèöQ5'Œ*+­{ ±0…û,âµÐËW×bí}2þ±p¢D‚Ÿû|±H¥Žä¡Aàdi+Ó”_?wT1§ô²áF €^èªxûâE z¥W2WNÀKH×R”4‡ùF8ׯÐi‡ö°…HÓ‰(’Ö"d\;1ij¶öûÚÃe8®äÝÂñŸâÀûK~¨o˲TB³€Y™¿-zëòYp¬tV@¬³`cTL§§³ú.éyú¦Þ¾›gsëÑë¯^AxÍ%ô¢éÃïïß×. ¸@ ÍY|¤Óz™ó&MôÊ[œÛÛ2ǰo<ìÈŸÞg®WâhN&líºð°­Eö†+S¤+ÝŠ¥…ÜãWX&—q¯eÊr!Úˆ\‰E*»Ìç{ýv,I—÷b¥òiBžU~fÒ@ÐóCµø!"OÑã$µ8:ö¨u¹(zš¤’¿ÛQtÑMP Ym"ß•èîÃ÷ÅBè])ÚHhÆÖ,8o¡Í=¶¥ƒFüÇ{ ³`vÒvÐZD¹A6îYýÿq=¼±çjvâSà+ð½¢áyxΩY"|JýŽ/ÂKš"XŠ¢¬“kКÁw¢[݉¥ô¥xŸ (É£óðç}²Ñ<àPŽã(`a«X _‰5É{'}A§¬²Fovh%‰(R¤¼¯ÐK©e^vA”Ųȣ…År/â¦æ[%îÖXššZ½¾ Yé uý=¡r+é‘UÈŽï|½Ž6úÙݲÚÚՅɸ|ÈnÕ’úðØ%TE@á“4Tm/ñ¿N¸ù/ •ÆuhSITv¦@ ¹m޵¤o:ñ!¼ùúîíã¾í9ø(¯ÑÊbhAáÚvÕ —ž®)…V÷ôcyŽs¿öõö¸¥° Þ6”UÛä½ríkuñMºäžÇ¤DA¤„èã @ÛbÜ*ŒŸwZ†ê@I^€4¯+€Í¶ym6Ð64†Rál®—²Å"Æ(atÚÑv¥¢­Ð,Ùå1ÁÏ ÕBã˜[v%Œ/@žUûÎjÏA”ìúˆ7(ÔkxýsF&Æ­„1¦ÅîžÇìÕ‚µæÀZmïAQ¶±ïy­4O<Ùb]Šc%0ŽNGR;ˆLÅ”`šCÿäŒÆâ‡âêôÀl&R†¶¯…>Nl”UÜK“ܬ™ƒ:HOWÍ“Â\UM}p†ú/¡¤.ci:”5OÕ"GOjG(ìl…3óL¸UwkÝâmH¯C«Q@‰‹ÑÛLS«*¡36ÕŒÃÕöÉ<•e5næç ÆÚI•œ‰ˆ·GíÏÚv(¿IêÀ¶&¿cÊ}2¢k×´s;*òìSM æMT%O}l¤Õϱ…Ŧ\EÁrÀêߊ,“ðÑPE¾Ï°ÿÑÙõeõ›mxy¾¿¤ÉåU8úᘳ§? ô“‰Š5"÷?6K Xîî_”•½š»u5²¢¤è8’¼÷å`ŽGø ŠV<™\ñÒ»éѯGÿO[eHendstream endobj 5689 0 obj<>/XObject<<>>>>>>endobj 5690 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£`¹•‚–Óá(á'ÅKâ`´Õö,O=¼õ&à–‡ûN~·ˆù}¨Ú7°£â&ãzÓo~{uëâM8 â.ÊØó&·ÎÜŸ:¿wþßGGYendstream endobj 5691 0 obj<>/XObject<<>>>>>>endobj 5692 0 obj<>stream x•V]SÛ8}çWÜ…Ì4,Ä8 èî ý Ó—n·ÍLH'£ØJ¢b[©dÇd2ü÷=W²IÜ„)K;„ttî¹çÞ«Ÿ] ñ¯KýÿÒƒ7Ã0±øôÍÌèì6¤« OÃ)õB\wƒÁà’†±ÛÒ0j[™Ó„îZ‚føÔ ¿Ó³_Ñ™%—’DF2‘©Ìòãáƒ:€ÆM º»1F¬He9]<‡´·FŠÜaaçvVX]‡5Õ†ÖLOQøHë–¢¿†O*‹ »øXqe¬D ¬Öt]Ö'Ÿû‰¿2¨,VK"ùEOÁÀƒÂoæ‡ß`z•‘¬êCºß~ó´¹Ñ+;±¾d C9³Ûs8…MÅiïôú•«Úù¤Hë„ò¹Êf$&ºÈù³%±X-¢9ás>HjN©¸—ø N¤©f!si¦"’Ä™ÏKM±šN¥Ç(_-°UOI°±l@3ÂÖü”Ô”J‰ÿFR®IÄqeý˜j¬¿¥XäÂC`. •„¤¡©Jä)I”B"1 t‘Äønî©TùÔµ¸#I:^ã¨R v*¹Òè€YFEf‹ÅB›\6YÔ×S #ȈŒ÷ÞkUºHVØ”&ó¸ÔŒ$V3S —Ò¬(QyžHD—Í Ô™$ºdá­N¥OA±hè1j‹„ùÏäÀ’Vá>! ‹DÙ¹Dì6nå0TYŒ<¹’ÆFiíè8`سÛkêBç):Q§7`Áû—ÁuÐ¥ÏF?¬(J„µÒú­µexëypΛoáªuûd÷N ÷d@é‚o6PÄ@‡ûL—'ÅÎE¬Ëú&ð"öàT'•òA .'€P§¬è½Q÷ aÞ(iJ1“Íbú,Š„¾Š 8Mò¯`5SdôõÛǵ/$ùÈІ]1´;™Ö“2rMhS$mÒ ¶ È—s…ˆ•“†fãM •ä j»“¤Ñ_Qñ¦*±¡k·¿ÍÁ\2Î4l{Ê*²i,œêqõÆÆè“.O+`K•´ˆ†ÁQw®8à+0±” 8=l*ìœ-]‡¶™^/è÷1KâöÙRÍÆÑÉIGI-¤ëÚGœ{Ö™+Û“χiÄ/çYâW–@0[Êd£„#Å:ø›ªs¾'"»e²¤µrˆŽAs$3‘cøËÌ,ÆEã&îõ b²|Ø¥·ÎÄÔåg¦–Л»Çéžã¾P]³«ncm9¯Kag™k‡Mþîþ=7lðÈF¦Åɸ@Ù»¶äŠUPn¸cêl³ðwoȸÞëû¾·_V²©p`̯èí§4è>8¡ïÉÝÁ[, µêè+*»ì®Ô€³â9îîÛY‘K8˜'nÅy4ºÃùqË8K´Ø £Qó©ñ\*xÄ —ÎJ§§lìÜ}´³â,YÅOë(Eºœ ÍÖ–QÇ£Q‹7Ô»ñ+ï=ÜÁܽåˆn`–Ê[!^b³M‘kËŸyòê&[EI‡ko”|gj¨è~|A¼yšmùÑ2¼^!=¯ =#Áü¸t3}S/£šœU õco«a4ÜJHm L¤²~Ö¡‹ïm!;ª¦2—Ñ=âE„tåÊ”s^X¹ºNwAvVðÒYÿqgäL>,h=¾ ;×¢3ýþçxÔNFÇc°«¢þ¾'3óïˆÃí¨_S¦ñŽE‡HTÜdúºÆÛÍr-¥ïÄϕϙ¢SlKðÊo+ÌÊ5Þœ„º2Öîî³Û«jêv¯Îƒ‹þ ðóÒ'îâ^Ò;9¹W Š÷ªßݹôÔù½Bo0‚cîáÜlîñ wOM~>½I-†7;ÖFÇ t‚~ïLÃÁe——Þþ=øo7üendstream endobj 5693 0 obj<>/XObject<<>>>>/Annots 3071 0 R>>endobj 5694 0 obj<>stream x•Vmo9þž_1 œhã¼’¶ û-T½CGîK¥hãu²¾z׋ímˆ÷Ûof¼¡lh¤Õ*±ç}žgf?vF0Ä¿Lfô/‹ÎP ñ„#z¼»ìŒ§q£Ñ™8¦Ã‘˜6¿ Ì;/’oTXÏ­aðj§bÉ ÆC˜ÄlvIƆ‡ÈàçÁ£äßÎú#<Éâ \(£‚‚+°Ë• ßË|w’±ÎâaTH¶•‚‡yZfFµD¿4¿0"tW9+!jÂç(½p_àsKåP”ÏÁoK[n XYuéUÀÓÚCa‚UZh£SÁÂùÑ ·µK‹B9ÿêʨ[eÃM. ×Òäl¯°˜Î ú˜U>/XObject<<>>>>/Annots 3121 0 R>>endobj 5696 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{b{{¿Àóåtøáǧpü>äsàëfÞ“ÉÏq[Û{4£–M«ŠŸ·Š½çJ “s†šŇïx \;ø®~úSn°”šm÷V}‰G.öþaÎë鞱ϲÂÀfÇÜõ«™ónì:xà_‘«tüW5†ÀÏ^óMß"Å­z-öÎuʨFÖãÓ•_¼qÏñÀyª.rüÚ‘r4îÉf‚Ÿq¢Ðî¶4‹h_ÎÎþ>ûe$úendstream endobj 5697 0 obj<>/XObject<<>>>>>>endobj 5698 0 obj<>stream xX]s·}ׯ¸ãN[z,R%QJßÅJ5IÆnÌi^ôî‚$ª]``)Ñ¿¾ç»$Wt¦“N<1ÍÅ÷ãœsøûÉ…œã¿ ¹œñOQŸ|??9ŸœãËÝÿüJξ“‹«É•Ì—X=»½žÌd^¦5ç2/F—·“ y´Ñ»²-¢qöýü?'gWrÇ|e<½šÜÞâÑ|m‚kÕDí¥Ô¡ðf¡ƒ|ùíñÇ¿1_[U‰ó+eÍWÅÍDÙRâZKã]¡CÅV^Ö¦X‹Õ/•_é(•²«V­°U¡¬,4öÞèÊ5ºœÈƒñ!žŠbTˆåbÊ@Þ襼8_ŠÃßÊ[cWãñ˜‘ct6ÛªªÚŠÞ¸jƒÇ™# c—Î×94cÙAFøX»ñNÛHtRª¨OeÑFælžòz‡³+—¶þøÚè"Š’%²2碶…ÑaÒ½2E ÊÑ]ÜéѹÖE©µ²‘ç¢Jpb9^»ªÄþÛè¼QÕDî„Ô ù­¤Áé(ÎÖµÖ®­J–y¡H¡rîYTg5k”{4^¿"DîR£óUç-ãé-S$Sùìµ×¿·&˜¨·ú6J-P!HE¿¢e:ýTLdoÚ —mŇkµÑ KWUî…¡,Tñ¼ò®µå?x` ô¥²YÁ—X@]¸9V÷r÷ùQÐÓô¯7xJ•?{¸¸í°<¾Ôêrô4ÝÈ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<}üòéìñã=&ÂíítÀ· 2fÞåPxä´ò@";ÚŸÆÃ^×ÞRüYë†xAx1I4zU…è7DÞCf}Â?ëEàÜèùýáC¦é¬ãð(±0×ϨQOJ¹‹²äÀ°\ šIàkÔ+’¥Þ2ÅÆ¸6d‘WÕªr¥ñÐt³ÉÁ½h61$™X+Ž(YiËø»€_¼jÐSBÂÁÒãuL´mB2扢„ä‰ðÇJ{™&Õ÷f%ŸMAÒ³=œÈýÀÛÑFšÖ7.€¶mrÕÔ€<†R•Ê1#×§¾Daé¤VÏÔgNHg7Ð^¦‰ÍƒY¨ƒz¦8¸žòJµV5h ?†_Nç%ÕF½Ø$¡?{¸îú»—üy'‹ÃìGm§—(1€daXë¥Á¨ãîûhÏ€²°FGÓlÑ8Ô@+‰ÌÒoú"wh2[4Hn¿¡Ü—|¡x2*Âõ”opºõ8ß×Î'ä!8ˆY~eŠ·ƒ´šü•(¥;¹çùãÝi,R$;¡Öt$&Ô¹»èF*ØD Õˆ,©__kÜs$—s8?òŒ=Š}7ÒPDK02ØãFî,”Ò:nŽÃÄÑÕHi©hÀÁiòYC$vÎOåûºa0hÇnRC®N7i‚¸IB­’ ôFH äª;[m³Oâ ´‚À…ýSL; OkMžÝÚä‘÷«UY"†B7©Étm kšåt&q=‘³¥¼dm#I»J¥RjÑšŠ® IÞch|÷Ês:ÎJíH&Ë“­üÂD¯<kŒpë-¥lQv{˜üDî)YjÖy´­ä° é$†»®Zƒ]º¤%Djgû¿i®Ò¥âP7;'êî+ph¯ GpKlDMÝ TŠk`£¢Çm††‰éBê³íqÅËG­ãÚ•¤]y˜ÇÓˆ äƒp»BKý5¿><~ÇÏݤ€'‚vƒŽënRèå’÷4\U 0+ÂÝéY!%üøÆ²¦h:.ôÒÖµE˧O‰á~©p•b^÷ƒ¶TfV÷7Ž·¾÷ˆãýôìœYîÆcòè¦n€Ûî:¢ëéÎi€oPNõï ®á‰u®¿v C äx$@RIhæœ5ØËÓ !væHû<ï*ÙN5ì lMlAãøN·¡žûJgWÆ«âsò\{½X8øß"ó¨J½ £W»ÌÐ^øBã&é¬Ð󵯴&ï„8Ý_ªmŠlŸpÇŒÃ;úá­ëJ>¾ê#Šð 8ZApw;ÿm «Aôm7¥ðÕŽ÷rBæ´g#CH …X¨"ï·0*p4ÐÉÖvÅ£•À5ÒÆp|);˜8÷Ø^w|‡@PwÑ'L㪢B0 ¿4«6ûxµÔK”Tè†rЍ 9­`p#su›3èÎàP¸/(n r`¿6@réDÒéü¢¨Úty¬Uáy9mîé©J¸`!–¼„_MäŸî×n58„Vž! èþØtàÚÀ0:YÏrÏ,r2¥-gWrKwZó—le††ÅÅÀÕtTyNð¤hjê@\.\ í’¿¿_Üà÷ Ëk™]_Nòo+dôx:9—\Ñ&ÇÞ¥|§çW“k,ßPÓ¯Ç?]ŸÏ&—Ó|ÍžÝ\ñÅó“ü|†çendstream endobj 5699 0 obj<>/XObject<<>>>>>>endobj 5700 0 obj<>stream x•Wïoã6ýž¿bkPoËŽós·Ÿ¶én[ =\чò¡´D;ìJ¤JRqÜ¢ÿû½Š’mć½ì"±%’3óæÍ›á'4Ç¿ º¼áÿesòíÃɼ˜ãáð˯iökæô°âE7oñ©’øPNÎJgCT6¾yøýdöñª_9¡J—µò*¼/èGKªª ;'cWÎ7òм®UÔEG+SëYm¬&Û5Kí)zU~2vM&`OÐ ¶3Óôb?&ïé~vÿõ×Ô*÷8MUⓦÖëÖ»R‡€Ãm»HÊV´ÖVÃ)HѪ«ë´–´&·"…'øÃüúï¿§Êx]FóÌë±ûž¶w#¤•ëlUЛN¾Ài¯C‹ðͲÖXà©QvK*´83d;a¢nàbYwëµU >œïBóÖEì|ö ´ #é—VÁž³ýà6úYûó„Fr©rçWu¥Æ©[r]dt,ü“÷&™”ÊHŸä€¨üZGª•]wj­÷phpTHR$ßqº<À¶9«§­ J×´H²—$Î>^Üõl™ÞBB$ôqqsK|üÈ%~9½ºKéŽÛVOË'ˆ!§ÂN£*Íà㣪~ïàÝI%„÷WĦ!üVûzKO@®Ë‹V-€ +½Â'«‘™j/TP„Â;FÝ&Ü NÝá1Ÿ@¡t-’øj¤‰ºÇ"]\¥Hƒ]¢)Á'@× ,Ç„&Ú"žÒÕ58…¼½ZX)ÜhàfOnFD’¼BÐ}Dîõ‹‰´°k xdDÅþÆuuF‚ §¦Í“–ð±3%Y aÔ݆‹ ª®Žp òà»2º×³þyX”®Ò¹vÁî}HºÀe£ˆëʬØY)´çGû¤‚f8‹³—> ‘í¥¥Ð©š6^µà bb¶½OZÁTÿ2Pù™"h`Sõƒ‡%ûì>áYÕùt4L£V#A7×";©.¤ºÿ?ÂLwÅ[šB—Q:¬=V¿DZé Ö-`OKoô T¯t(½Y‚™®£@ˆ¡·ú–8+ô„éB޼¼+®P}ÿÄ!ì'/½*„²l”]š´e.À.x ½C±™Äà$L¹FÛ¤l}†ÐR— ˆbo i{”{I—|£…ÂVÕ{ÉãVfÝ¥Ö“êÆçJxºÜJöJƒXvæþœ–Ð?y³»“Û÷©7ñ¶6K¯üVº 'žsXÚºŽeO|Ü/îì+@ö$QSð´amÊOúÕæ“†%Äþ8AAéwé ½Vè}âDé·- ‚öèBËââW òœ3ƒä7V:Vlöpž„;$Ó@¢R¼ÀçÁJ„cø‚^ä<7¾zûøæ]Ê÷œîŠKæÆ‚3¾(./ñ­šœ¥¾¥é4l̺›õ)íþÌfô}í–ȽØÍ…êÙ-Ì»%{‹loÂ='íãã¼™ds0ôSßœF!øsÈ å(RhúópÜðâ KÉxžq¦ÅeqƒŽÕ—_ö.K“ŒÉþ¾IÊ8œ‹’ÚuhÏY¤ü`z’09Yc!7Üý¸E‚4ÚJyHÎ0½°ƒ¨£Q7ªô}š…_ònK}΃‹ŽúÌ@jç>AÎ2wÿ7WŠBd†ý”Ͼ¢{Öõ4Ú±¬SèÊ')βèžýE8€Îþ¦¯f}8À¸ÿ#Á@gK½Fµ¦ð’çÅÇÉ©<=}|“!ØßƒºåZ‘MãžþéÑ]O3¡ß»ÒÓ£›r ¼k4Õ?=ºËX Uýϸ‹ŸŽ[€ó}É/÷ܩ݅óf¦iº¨x>…S+­bç5@ŸžŸ^Œ†RÞÀÇ­G6¨~7PRb4…z‰!³¸íûÕ1OóÒÇÉËã›]_ó ¸I¿½üöÍ뉶.¯Ûó5?Äæ¼qðõ̬1£Ì²ÏG™×/ò$#>/XObject<<>>>>>>endobj 5702 0 obj<>stream xX]sãÆ|ׯ˜ºS2 Q”Ä;Ç•ß唸*®rêT•‡0 `I"`áÝ…H:•ÿžî]"@Ù‰}öQà~ÌôôtôËÕ,ñïܯù'«®>>_-“%ÿ³;¹}š¥äá{|ÈfÍÉïM¸Ãîúù_W·OÝÊ™+ñQ¿yÖh[>¾±4ấ,V8zöƒ%¹NÛÝ®¨w¢Š\ÏÅïµx}ôø ¼|ùû–­Ö¹o¤ðN>}û­4Ê:m%Sµ¤ZLêUQë\ғض®yÖ$w(v²ø,EíµÝªL'Å$‰Dž÷…ë»[1<Óú¦õÒX“ª´$÷DhÅìWÉý=~ÊgΫvškØ;xäOMøyõî/2–«»§EÌUYüªÃcöTwÁìûþÆØd‹;œ¼XÝ'ëõûÉ•çý…°•|Õ§ƒ±9ÐËö¤MoÛ:H >jŸ%›ëD>UÕP Ðï‘:ª@Ùæzʾ›ã˜ ~Þ\.‰[.j|üÇjùÏ‹ã MÓK7³›ãæz3CjóÜ´i©7ד}Ôþ>س]a¾@ubï©i÷ æ‰sé gµd3v¤è)4ôYG£ITQ+P&v±±âXÁñ&Î5q üx»š¤|͆¤ÁPpÁ<öGW±Oâl×5Í'Þþ‘ùªkŽ‹Åâ°‹TÀ ˜Ç> thnœU±÷Yí[K‰‰»fä] A´ÊÙ¢¥1~×>xÃXNGÙ íŒññFÆâèJÕ UŸb÷žÓO蘗ÃÈã ®uŽã+Œ8#²°© &B3C>3À‘ ;ļ™ú‚©ëŒ")Þœq‹k›&ˆ.Á+ʉcÃ`/PEV%¼&tãkU@â!í¤Ä(˜¢ŽÒ ‘cöQgª ‘Ñö €’¼ÙáQmƒ0£.¤:“Q{{ ¹†žCå@ê0zoAìEkà±)F!ž‰²A«À°ø"â­‚å³ñʤ¹WY´¾ì¬i& ‚ã.p¤ÝÝèü;ʲ™Áv¿—þŸÛù~i ¼Ji9ÊÍme˜¬©E›îFÝm {ú±CNÝž×NžèÒ3]¶‚ßv)/°z¯èK‘EÏu“8ÃEB»"OU¢<ðfš~ÿ Úv|£`ÓŠZ ÷'ÎßJãÙ0°ÉÆÌ7ñr¦êbŠæR1.m­±Sü’ïå'}¢;¿û ³À …™øËó_ß:.kÃAòm´ÔsÁ‚¯ø£8ôòúÍø ê]àÕ ¼_þ$ï:ð_]ë•Wªth„:Ô -ß÷Ƙ…†«M'+T%¥ *»kƒƒuÖ56|ŠpËo„,Á£‰£»UÅnï‘[(K½;+Ñï³nk =OAâab äÂÄ4"ÛdzšÐ^¦»Ç¾ŒêÓDåûw6vô N­ûÔAáÅ·§ÉÓ`às00¦×_¸pt‰OzÛ cìý>‡ðˉ QðE¼@3•b¶Ã˜'ÉMÀœ’~†nH@}èVj˜ã»ê‘¶ ('±àL¸‡úÊå1éIø³Õ&Ÿ^J¨"_^(â×º×ÆÕò!y¼”õã:þF‚ ,VÉRþd²À± Ü„Ƶ‹÷|³î~Çq'?[Ý #âæÂÇå:¹_Å·÷õû5}~¾úÛÕ ›à_endstream endobj 5703 0 obj<>/XObject<<>>>>>>endobj 5704 0 obj<>stream xµX]â6}çW\*-«!ØQU©Ugª}©¶*R_öÅI ñ6_uœ¡©öÇ÷^;2" v5 ûÜã{Í=þg4‡þ›ƒ·¤ÿA2úe3š±þñðCí`úü æ.l¶8v¹^Ã&4Ïg° ÆÞš-˜_¸*l”ÅÇÍ·Ñôys|N3wÁ8g¼‰üù×çß §Á r•…e àdI -ì#ЈÙ4Îi^jØÊX€/¶™ÀÓ öŠç9bYˆC"Ð%ã v"Šk2xâAR‹1Šˆ!ZI86!pâßi¶O‰»ß쮞—ÖÀ2©–[)Bð+TT‰ŸÅ2Íw žK…À*AZ|h&%¼‚ˆ¿OàÊ—ZqUAZ&>òͶ',‚HÆ¡)JŽÉ‹]|¡U‰K2« )¤<ÁTaRV¦Z¨-øÉÊ"y…$ËB¦;°5ÀÊšŒ‹½Ü ¿Ü9ˆÕ)Ñב)ÿr*Âc3weźTA—y~ Ç?ÔÐs¨רÁý=8y¥£,mj@™ì R[8:Ëáë¸ÏäãüëÇ&Ií! —Ä%ÖûªÁˆ_å"ácªfS_ðÿbQM¿¨ì›t1¥?¥Í™gÞY±ß=®.’8â~3Z{¯(×஽K)í®¯‡b3Aó¢hqº;á—~»œâ R¡=eøž¥ö<ÆSò˜Àèq5$]°PôbÍg·€¡âNó×y¦ÞgʺIêás“zpnSÀyž®¯W[;ó'Êyz}vr ØY(é³¹7 °‡{›_ÙcîéÇ}#ý¸7è§]w÷¦C£/Í7 ¨§î7œÌ½G«w“€^;[½ÛTt&kïôãÕú9:ÇtÆ[.WÔÈ>½ˆПÓ’d…†BR?}lÖ'æQo“F$æj‡AGØÑWY ‰ÜEûç›Ô“}RÛà~†.#+5$tM»`ìMQú…æè\x|´ÆŸ Ó!Wqæ—ÈÞßjõÚ:[,û ñucúVÜÊ]‰fKbÓo Ú>’h¹B±•)z•º!€iù¤Š¡T¸4ù" ë~O£×2‡ˆ”Ø :E™ç1™¯– ³ôƒò\A‰kŒ qAQ¬g´9i(÷à>Û!¹ÃV1Œw#5J,Ù,\`C\}ÖZI¿ÔbúÂã’ÌšTÈü3Y±”¬§-/ÁØ›òW D®D 3ò$/"ôv~L)ø¹1qÍ"Èwb¥ EÇØÕ£)¬m_ækŽ©âúÐcý˜þÔ©áöX•³š§ad°©"¨¨Ý©‹ö¹M4òÔh‘çÞ<£°–îLñÛÉ®ý*d9¥·˜˜S÷˜“®ÛîµncÏ—{ÇÀ_2žä¸ŽD4‹ª Ë[s™â^M¬v>S¼Ï'Ý5ÚvÙ=ƺÎÁâÔ\5Ðë yÓ?8_Mâ¬ë60ßͽƒù•~8pwpwõpäM>¾õ¢Ø5É‘žÐðUMøú¡þû«`6)Æd^Clú¼®oRæë{ððÌe+{#B7ZŽËfðk” nZ£)¢€_v´³²$ûïÊfKæ¹xQ†Y\®V4ói3úcô?˜^ëáendstream endobj 5705 0 obj<>/XObject<<>>>>>>endobj 5706 0 obj<>stream xíXKo›@¾ó+FéÅ‘ YüÀ¤½UmªÞZ©.ëeÐò*ËVi{f½@âu,Ö®kEj±…ñÂ7ÌÌ÷ÍŒà‡aÁ cG|Yl¼ó b\ìvù\Ýp­1x p®mËqfà›«xlO¶XðnÁ„ ßO^… ‹*\öý ¾¢qqëñÔÅ¥÷Í `Úh)ض´÷Ìp8„Ö¢©¹í5VCBã-‡;[ß0lÅ7ŸðƒE´(@Ó s¯Ò` t^”9eåæ?&Ïn}ØÍO )Öñ›.„ÜÞÓŒ÷Ã:ˆ°£û&¼³„mâï¿:YÒy4¬&ľžØÒ›^‡n‘6™¹ 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í`/UpW7.ˆGÖØîÄšŽ§à¸øaŒ¯‚Áí×OÍ‘Eà}ʪ˜'%-Ã427GD^mÎäïØµ&øîá3Í ^Îy!.›ÇðÝsä“àÏøb<<¸Zçendstream endobj 5707 0 obj<>/XObject<<>>>>>>endobj 5708 0 obj<>stream xíXMs›0½ó+vrrÆæÓ9ö#ÞÚ 3¹ä" 9¥5‘ÀÓLé¯d‚›ÈIX;3é°âíÛ}Ztm¹@ÔÇ/Ô_–[ï‹8D]Üþˆ+89#;$K˜ç®†$éf„Mà‘£…5]5¼ÿ׆#rtœ|·Ø®¦Oë›j‹LËf±âX´¼ÉOÕYÓ…šÛòÓ'îÜw}‚›5j:K9[û€fë2KG(fdŒF£B©– £çXg¢nè KûEµiÓvÖ*ÿfKÅE–óš lìÌ”}ƒÿysïÝd_yó ýêùu£ b(QvûU,Îl¶^Ô¯FásûÕ(î»ÎÇÞUÿå~õä,Í{ nì;@«MOm¤“ó‹ÏŸì™CàCÉšœúU¯,´iÛ3Ò¶£.j^ìøjïà ’C"8—zX@BÇ›©½u³0šëKë«õ¢EZendstream endobj 5709 0 obj<>/XObject<<>>>>>>endobj 5710 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ŸÄJ°;\’N eVJ²FÂ=²$T9Þ·2§ÂÈBæ‰Lh­ì‚ÄÞ9ard*UÒ„ô€A%ŸÄ²Èd—ìB’¨Á”ä1`=r:u3:†Ö!‘»Òæ%i‡–ÃMœ…ï½/lóàaÔj®À™Îý:“´9ZÁRæ–oqÁ!¬T=ÕQ€Ø¸*¤÷`…æ2—Fdd*TçÙÑêRòi^·ÞDë…ŠA`&ÊÈØâüH&ʈµ›m«tN¢(¤0Žl]/'HiÚá–ÔuôwwÚtIÚ8DKÝBè»ôN„™KK™ÈçwÁ¥N€¸ (HÅ×!”´àͧÿˆ²T¥u¹ôA;tÐÊÚ0Dã†iH„€men}ªÍ‰VùNTIxÂm‘A–ìz;¸Y!ðeÙ…°Àjcœs\KÁå̘=Ž­!>Ÿ·ZCbƒüä÷©Öþƒº:䑞‚ËN8‚÷5ȵ4buºê»¡G/¸ î|Ù}¬ Âõ†¿]Y¶•ª¯9¯Ô„À‡êŠ˜ ôdÜœh„{¶¸êrdgR@“œhΜ*wåm[>ŽöRfP.JeÆb—¾Y æÐf ü›nk¨½^¾ ™®<> é;½–+ ™ó[ ëÏ<åÀ—šZ!>‘Óì¸8«Ò7ˆxÚð­DVq»kº?CfH?ëʹ.Ñ/–LS0tÂÀL¤Ù°¬Xú¥âÖ‰´c̦\!ܧ’jYøò9aß­´_³³ÿŽôûá`€oœIg eÚA)ü¢¦—(U=íàÂéå—lÈÝË}Y<:ˆ]ͬwíú,&œò>vÖÑþ汿hÿù4¼/f[ ûqåÇÜ s“…äv×J¥«“%‘³j4å¤ îL,qô/‚Ò*ãn…N £9ÓìF:â†KÓåõ Ñ'µè/·º¨Ét£à«üëxLSgÞÔ·h:e±`­Ð-X^tè¸F^ãÆºAìᢹ¹3[Ÿe5s³èÜ)U›êꔼ‰¶´®ŸíÆ ¥0š¿\ƒ'?nÞ2¼RrBØ!<”Tñ°qîïÞ·Så9“þøÓ÷ßþµŒ?£r­æìè¦a½x„ʃo÷‡ÞxÞ nh4¾ {¾ØÐ#ú¨ãŠ÷7sÙ Zó§ƒ[¯Î¿Yªn¢Q8èc£BŒÆ»øfrñãÅŸ¬§eendstream endobj 5711 0 obj<>/XObject<<>>>>>>endobj 5712 0 obj<>stream xÝWmoÛ6þî_qZ@n*F~SÜôS‹-C?uC  ”D[,dÒ#©8F›ÿÞ;Rrle6ZtÛ‡:/ˆ¨»ãÝ=÷———P”¢¨!þÆÏÉP_ÀîÖ7Н…ÃÅRë¿äŇ½1y‡sæ>Ï.y2Ï"©\6dçœ6ܬí£:œIÈí6!û6¡;-ËsÁ©büq<÷$÷Ód”Î’ëùé=N¾ùÏ¡8[ÉCQê&¯Å÷¡|N¶ä üÌ€œ¬‡cÃÞró}h ¼ø¿À¸ºéÑbÔ­x@ÝüóÔ•E!Å dŽtbÝò > €3»'kxÞ?ãØ¶PàÁÝê î°'Y”“"•â7èGDï§·²‡£m»§ÀÕ¾5)†EÁÒ½Ð<ƒeá[pÀûü‚ /+E­ Ù¹Êè­=Lø˜çtê'ðàMNR&,GÖø± Ð핸C¡(J’v‚Û e)lad.âX:°46;àÎñ¢BåEñ[zD‹Åí¹Ú^øHe t‰UÜÁš0Aœ³®Ë^ÊW8÷ 6F;MW ^£8täÀ„xYŠò%P¶ š Í;W;£ºÓ÷Šlc´óøÈ’|»áîö'Ša¡,&ë…p‹ÂÌÛSkœLÙl2ƒtž6’pÆc–À/ºhˆD^ÖÈ Ò`_ötŸÁšÂ‚ãýÌ’á,IÙdŒÿ\ ¹Óùˆ–~] þ|_`Dçendstream endobj 5713 0 obj<>/XObject<<>>>>>>endobj 5714 0 obj<>stream xÍWÛnÛF}÷W Œ°ãÖͲ¢^€Þ(RÅ’\Ik“»ìîÒ’šæß{fy‘h#uP䡲d“âììÌ™3gÇž i€Ÿ!§üN‹³—gƒx€/»_vC׋ ´\Ãvú YxŽ‹ôÂVZ+½¡ò[ò[I—Ë»³ëœ†Q&“jySÒ¤~Ôúº SzetL cIîEQærÞ.ŸÅcÞp4 h4ŠÇcÜetuuEi&Óœ¢Ï|±?øàh°þor‡b®E!‰_o¤W^çí:›gìB0ÁYío½ºPÚ¯.ã2~â³¶pG[Ø=ÞÕÊ:²f×ß’;™ú'ŽÖRøÊʹܧ²ôœÆ‡ÕJóoÔ^ãö+‘2ÄÍÔ ŸÆñÓÈ|¼H°(¢Á~2Ng"= olˆBuÆñtzËè.ꨈ¡s$¬¤ÔpM½Ì¸M”·á ‘ /, §\èM%6’ “U9VM‰¤ÒšE!3ò†¬t¥Á*\ } &û°('<©È²Ú»zaj6Zý%cZ‚š™ð‚œ7n•F­'á½UIå%)G•«DŽˆï*çacÅŽ*Ò9¬r°Ó›c_ÖוÔÈ9“-j!‘˜‡àØ) qhà†1v@FH^­Š.®A~EC,ç–‹FSÎj<‹'ñ-ýÿôZjiƒy¿"l<‰'lþkYG;cï)9P&×*´ì•È¥¥u¥Kƒy¯Í޶øô‘G„ki¥öÄ$udÖ@‰¼•’4¢re×ϾÙÄQ“}nÌ=a–ŠöàMŠtüpmŒÍ"²*•”›]”Ë™€F!YNõED®ü¡.ƦC‡£ä‚p])äŽ,@rUâÁ7d¬ÛД~0÷¬eO€áÄàïD¦¢r (ó!¤Þ«u€ µÙz¦1¯ÝÚXðøg\U–~¦ ²³¢,yoAi.œ£\ÝstÊý»"ÖÆ cèCHPº²Jr•†µGõCo?(ëAo@ìéE"lP+Ú¯.¿é-ÿn?Ùéï·R‡ , ÖèŒ*E׉º„H:²HPÈš¥Ý¡€ëoº³à%z˜RTѳt„¦;B^û뎗µÉA…€TÛ´Ï@Ä5Y6º:¯O^®§J?§&´´SEž3l½µ§ê?§£ö÷ŒR'ûÁí{ÏY‘Xù5o+Ô·89´º?Yå±k­€?÷÷܃µÒh³ ˜ë*” ÓѶ$Z(ë|Ý[Œ&7‚•´B̹b­ˆ´qécxD­SM ‰ŒeµnFnN–±ÒÜ'aÃ(r¥Lƒ B‡ëm[O 6¿3JC;R$­Äê\¨Æó ô%ÙQÆÜVÍëÛ(¢·Æ+hW AA}!kVâÜF뀎-P¡]ÿ—>/XObject<<>>>>>>endobj 5716 0 obj<>stream x½W]oÛ6}ϯ¸èËœ"Vý‘8nö”.K m3Ä@7ÌCAK´Å†"5R²k ûï;—”ìØÈ°¸†…mñ^Þ{îÇ9úó¨O=üëÓpÄiqôfrÔKzøqóŸ[ЫëSê÷h2ÇÙÑk|ÈÂs|H;7†ª\yªœ0~n]!*eÍ [©TRnW$ ‰,Sü»ÐT ' YIG+áų̀²p"=ÒÊW°Ë‚=?òëbf5˜’‡ÓÆfòxòå¨GÝþ1urøó5½¦4f×ÊÀ9G¦Ò{ë¨öÊ,¢QðGŸæ^3éS§fÁ$<~qÿéæ-½^¥þû+tB—ä ¡5ÍXÒTg'Š"åLaøˆcÚ[šIih!t¢’Y·ûÎ]¼ºF)Ì•åEtŸ´è¨*„YWñ\ èaÓk¬M&^sv€:·YB“|¬LTàÀøqñ=ÃJü[Ž€k«ÓN‚8´@4INú[€]‹…¤ÂfµFL+ëh¶&'(¥t *’iÔ}^›‘'ô ²šŸ®T•ÓR8ek\¾.á…æh€`E™šÏ¥c¼}…‹øáì»ýÇù"üeÖHD™QT|ÓÜÙ‰øR¦ ¹}›Ê>î©‘ 'îìH ÆZË »T®ªá1bn'HùU¥–'¡dwkTÆ4ˆmŠ Ÿñ"FGk»òm€ãdÈ38@ÃÉpˆoY'ž¾ûmòî㺠²ži•R›ýÕÞÏSÛ)­®Ì‚Oœøs4Úý‘6é,­Ê¨ÊL;˜¦G/…[,ÿczüãÎ [+%ôc9í|àŽzù'Û¦øÛë™V©5hSfÅ]&fZfe°Ù–Ú²˜I×Þ÷.À3s‹¶m†ßbÛbz˜m¸ÑÕieÝa†˜Ôê[ìB vU0ÁöX —]I|ÃVÅÒ}&²Êxéª+åxt—ò¹VEiŸaõwˆ-evü“ÑèœG{˜œÕ-‹yùhòºÚ°Ïq›^‡=ûêú51Ç1w#ö3'§É˜GñRúõýmÜ-SðÉÓ$lç÷ušó~âÃ?xJk)˜8ð•ja[§ $ þ,ÀßK¦ª¸<±ÂQ]&ŒÈŸ¸ŽÉÆÉ¿óVRú–"5_jìºz‘s˜¼•Á~m¸+° \ ³Æžçª`ÝPe\”[¯ØýÜ`µÃ …QKFð'[fäÏ€dÃ”í† *%„/Ô â•+3×µ4iLV01T}8Z¾Ë>0¨“è9Üͼ齃@¶¼…²`¬>éXë’ÝÄŒ°TµK!֜ʼ֌烔eĈ™Ä%ÒÎrmkGP+H a3gH½íŒPæØ芦;ÎèΩŒ·”tÅdßbçŸj”ñ˜íÞ[¹é®ÓfšV8¡ºˆ ªh?½ . Bž=¹lÊÀZ\ˆÆGÅö %ÈÖ¨ Ü)³Žg­·B,ë †|[fGÏ•@«¬!âœ*»ëFŠDúÅ.MŠ¢CJ¡sDXF“ÎÓ´" -Ãq£›À ~z v*ÔWVCAšpµS,ø 9ÖOì¨Òêua]™«´‚(’‚$ñ¼s@û3§ä½ß|”q×mÇ”c•CþhŒ"ÒÆ¡7ƒpkT)0x`í…~Æ0z¹{ï'VrÍ=,[¸± ,ºZ.¥¦Ë»›8fQn„H1JmÀ´Ät#à˜OêFD­Š÷,n4¬w›«sx@vöñ7mÛ7Z·{žð[짬ÈhÞ a~Ö¨ûw(;CžÏó-ô Ïáäû[÷™5ÓwÄi!¨a±@'Š­}Óøý` ?† ü{<èåpâÿŠd?-ºÄ(7!L;œ¸LNˆËqB²J“éñsÒoy°;'¯Û½a½— ÏëÉb\˜èÀ a¯c8<¶-Þ]#=(>ÞTøM»6Xdåf¹†…Ð=¿NÌUÊ칑'%;à‚2OÛýJ-&øiWH·‡¸í‰èN¸¢íàôǧÉÙðŒFãAÒ뇗&á.¾Ñ•Mk~9 k‰Ñ‚ ‰§»çQóýpN?±6_K1å|ô¬7J†ƒ8’£ñúyrôËÑ?ßM›endstream endobj 5717 0 obj<>/XObject<<>>>>>>endobj 5718 0 obj<>stream xµWmoÛ6þî_qè—9A¬ø=îö)³“Õ@椉×b€€¡¨HDªÃÿ~w¤'”e;ÉÖ…aïž{î¹ãñg£müÛÞþñ¤ñû¼ÑöÚøåóÙ#œ^¶aäõ`@· ÃÏo8<ƒ¹o¬Ú0çM½N…/øÂònX–\E¹þíhþ£Ñ†V|×h¦|±Óànhö°ÓdŽqK›ÓËÏÐéÈ¢luÊfoä ¼Üé,’9A:½ìa 0ùV·ïõ žýŽgbe?.š\É\ïUvÏC–Áñ‹GÖM¿pc/ãL0-r` Å rV‘!’‘ŽX x|)ÀžGî Œ&~ùÚcÓÛo [ÃÀXŽ7‹Óq*&•EæÚÛ|+ö?×LX«%¬˜Ô p“!º"ûUI÷›"IõºHø–¹€OŸ À˜˜šg]—¤›úØSÒƒ’u›Cèð<ï­„‡ ¼f<Ê!ç*óQ ” ƒ±ËEŠ*ÑËE®×± t¦ËªFÒ=‹hƒœû>Ö]I¬<Ë—‰ÚhpÃ\ âX­À©˜:Äñ^JÇ*]/žU×3ø'û‡4ÄÑT(2CãY¤EoÖ—õIE>LD,´8‚5Í]>ˆ5ƒ+!KñXYmZvGö·B/3™›´c!±S_‘PŸ¤UègÂÂ2H‚ÇžD9õA”áÌ!ߌÓר2VÔ£Šáû<%½àûkºm€éz-X•B¸².Áb_4™ÑNÓÅQ½:©ŒØ‘ûߨô§UÒ,ŽaÓàèó»õåÙéÄž¤³ßXŒ[î"oú(ˆD†sTÆk²õðìúë_×ó x¢ä/=ª:-y?—ŠË\=€ËéíÝÜ`Ø€·ó~ß (®¢QñÂì ûÞ 7€áÙÈ;³œÜ}ŸþÑêzm˜(nÞ%†^B4kÝ:³OwzBÃM%¸= ˜0ÍèF_rÜ…;h½^ßÓHöpÔ'/óÆ×Æ¿œ—¨˜endstream endobj 5719 0 obj<>/XObject<<>>>>>>endobj 5720 0 obj<>stream x½W]sÚJ }çWèÑaÀ5húÚïÎÍm§M:}a¦³Ø"vkïÒÝ%„_i×6Áئ“Lâ­¤=’ΑôFÑ×&3þŽ‹Þóë^FôÏú‡¾'¯ÏaÁõÆÌžÑSâ è!>¡]kiÀ¦r],PƒZ‚ÆU.b,PZ…HæA¶!·ó³ðìú[ïÉëg0³Ï!9Žgä4˜\„Óp o…IÑx«Q™mÎÃs¶â¡ÿ7ü0ægÞò^Ždʆ/4 ‹HÜ+»…”[±È±L£ àÒàŒª/Ôj;/ƒ¥ÝAþß‘"˜Tä¹Ú@L§†ÃÅòÉÈÀ ÝO6èÎâVe ¼Ä-ž†74ðèp™´p‰ò„PíÏ,2ùø >,¾al¡ÿ­°V×™ Ti,\YÉ›¯JS¡¡ÿ©™öát­äjON¨ð”wºÔª8šYӀ컨•·°põvÉ€Ò\û¬XåØ<í“l:0î\ˆï?_^M†T–j-“î†à ]ŽM›‡uÛ­È»a»²JÓÄ4ºˆŽ4ïqB¡›^þœ!¼[6ô%k¾T)+d"tRµÅ<ðM5pœ3àr^fÆÎÏ ³9 "âñ¬ ŒY˜€U¾µ—›`Ú¤YœB, z§°6Þ‹ëj½¦–Í;ø¬š˜ÛTpVt *R³V±Ìé8p¿ ø;¯ïVN ùNá$äPÆDŸ†šƒh\¢F#Íâšú®qÿCØwM>â·)¹W+ÔÂfJV ‘ðâN³í“4CoígHYèMf mž¢Áß玊K+t©nXì H`±mÞþ°·CÊåA}õb¥iàVJ&|ÿ²÷´²& ‡¡û xrÛCÙê‚ Ôq¨¸É¡ÿnMͲݜPQÑóA*þNF®nJÒÚ“ô‘ãa'é7UÝŠîÓ!EwÃ÷‹ŠÎ)u“¦wíµÜ?ßußô-wg-çÿ®SµühUÿ=:\­åGCݯín{ëÒòÓ/ìEÇi9;›e&b- ²»UBKw3Ød6%× Þ5'ÓMÌnƒ Ú¨²iÃ$»À- ¥#?¤ßåJ—S³9ú„\Ð$8b cí–`dÚ< Æ6çoˆoÑ»ZfÚX.ö°&äǾZ–UƳOkAÌÿzh–¥ ŽC`´yýùey†?*ÉŒp?‰ü’gî˜ðXSB±¦n¢Å’4] yƒ!|¨X|À I7Eíts“å9[jAbxd[ì“´õE5~õkÝy8Laöt^ðÐÕ—wo†ã0‚—*¦¥GÒBNšíZtyÛáS~£)ßÙFårî(~ÍÂɘ„ˆ>]LùÔ«ëÞÇÞO‰ù µendstream endobj 5721 0 obj<>/XObject<<>>>>>>endobj 5722 0 obj<>stream xÍWÛnÛF}×W  ‰ÖÅV}hã86à8ií /Œ5¹Œ(“»ìîÊý÷œÙ¥(‰²|AZÛ°ÈÕÎÌÙ¹œ™ý»3¤~‡4žð_Rv~¿ì ¢›æíïÓp@—4y‹§ÔoÀCÒ=’…tÒRîdI;—³ÎÞ14úÝ]ÞÒ]ÊŒ.ÉM%¹u=²ÓœmÓæ9ðQÖ‡ëõÎ[§ô[UI•ÆÝ3œŒvï{”h…§Ï×3™¸+m®’©0´ëâuÛ¬f´ÏЂÛÆáÖ÷wÉiZX#µwß·vGtº±gCcnIiG‚¬*Š=ìœMøRX;/eÊ–¯%¶M˜ÃÉZ† šXÁñ‚‰‘±ð…3ò`á§ž*+‹»µÌ®"å¨Òxxµƒ²çý º}D»q:"w¹Ví½@×ÚòôÂôþn=ú œPwœ‹žºà•'˜äOéæFñij¨®©ÄMÑ*ˆ WÃ@’±Þf<[Â_‚í«E <8†¥åœ(†„ë9:NM` øÚ<%,Ä4íç:…½°°ÒˆŽwi3û¸eþF>¼ÚºHSßùÁß-' Ui+މŒàXƒécH°ùrW€l^~ÁèpþõìŒ'éîçéC cÒó1Âbê-`!|Qj|²ïž ´&çòiÔ¼æÛëð±“?'²ëî4É{QVîH€¹NÿFãúÊÒ¢ñoi=ô+&«Ñø"ïü²î-éÊ‘ë°ÎsSÜÍ!\—PIÊ#v>±\OÄ;ôÏšNÂÏ ¾.ƒa—ê¹ë½ùÉÆ±zƒ‘Ökh£ø·–¶9“hwºÎyÝib1{ øl |ÆÀg5ðÙ7V_ˆ›ÞÑü,B6÷jem@þ {LJõi8ÙÆ49GË¿N?öGÑ€Žt‚;r”ÙŒŽ.v÷æëdÚõ“Ø8,o8L¢ñ÷W|79œðÒ‡ËÎï¦çM$endstream endobj 5723 0 obj<>/XObject<<>>>>>>endobj 5724 0 obj<>stream x­WmOGþίEŠt8æð š´Z‚TDÛØ(_NŠÖw{ö%w»Îî†Výï}fׯ¾Åà»yÛgfgžù¶×§¾û4<៴Úûm²×‹{xxÿËÌèpôõ4É!{rzJ“̽ïÑ$†§ñq|B‡ìO¾ìŽŽ¨ç,y08Š 2-DÉ2”7*­ ­, #©±2£\eI…ª¥Q^.¦É\ZIz!ðòKm¾’VtFÞÂvŽ¢ÑÅå9uÚÞ#ÒÓ/2­m—Ƶ)ÔlóY¨Œì*¢ÐRQʶœ‚žE+s”DËy‘Î]ô•4²¼#AK#uë¡Õ]ñ%û±ëoãÅžý‰ë<‰|쟵ùì™w)v5¥sa¨“Wu—â8NöÛQøll¤M%ê(ü˜Æ¢’$,ÕsùÇ|±òš‹î³Fò6•‹ú¢&ÝÔ‹¡…ôYMSIYa:¼Õ°ØmäcºÒµ|ã\½´íðïAGe zŸ­¼À\––E=§©Æ/ïµôuPÛpÓ¯(4hÂÖʸ¯0m,ÍÅtáYF©’B¡n‚,0´¾"îót³3O›ÔùH„™õ»ÈU—®®//Cˆ7s©Ç‰èF˜BLKIª©¦ˆWç›ãšYSIU#‘ÚEìSá. •õoN v“ÁªÁk¤Š£ð êþhkmë’+7üC'ÈÛNˆ ·¹•xû„M&®èÓùú²nüã@=QËÎl¨½©äïõɵܙÖ]dÔ™6¸‰\¥T¡M*¿áÒ»µŸáG)²çX‰ÛÑ8'?â{É™Ý܃U Í=¯|æÌ…ÚÏÅëZy}NÚÿYhÍÊîÆ5–òë|ué<·-žƒ^Î¥Jeèæ™àYç%TÞÂ.¼ÚÞsÐ= }„'Ǧ!MïjiãPÙ‡ºCY+Lô<ŸŸÿþy|> ºA·qbg×C14œ¶ä}sçWïøñ»_j0…‰,Ë) Ñ{&ôµ³*oAï£[Ó€­3¡Î•\ò?IÔüx¢0¥Út Òž\hð%—9„lèxõnw 6@Îç7 dÌ•8ÉmL£sR%Qh.¢²˜aî0)Ê’ç Ï<+ò\bªæFW¡±ÝŒ­PpŒq_xNy³(E 2á^HLŒya2Žl“ãOï™Õ¢Pì.‰Jœ´o.,d—Ð5Àü¤ Ï´BÑ?^׈Ë\d™g1; XCª±c*”÷câð¢´:ø[p%ðöÄÈµŽ·YK]¢@Z›4•ÖæMYÞ=^Â.›ëª|~¬Hræï‰rˆ-˜ž¼Å)¹F,w§ÔWÕãÁrc;+µÝ5k¿*k0Eb¸búŒ”&‰zKÁJÕš&9·¨”ÛB&Àû7 †ZL5è^°’ðjàH«åÚcjŸbL¨m2EJ£àbº@¦‘]Uð†K¶â-&Å%DÑ‹™'hðÆOZII”*î^¶ºnN¥,¾2û,ì›5²§ñ)—¢A<âSvürÀ3a‹cw×°aãòÌ»céBñ“èÅ‹dÿmKp½hØî‹hT:IÔÞÏÀÐ`ª÷– ú þ¾z•ìÓ?-c„¯-ƒ/3¶†é:ý·¥NÌŸG§«M¨r±iöâ×þÔ úÁ îÑ;:^ëvBVC¿ôÒ¯yÌ‚}ô¸wXFñæäô5kœOöþÚûÉÇE,endstream endobj 5725 0 obj<>/XObject<<>>>>>>endobj 5726 0 obj<>stream xWÛnã6}÷W ( dmE¾ÄëEŸZwSô%hk/ ”DYl$R%){ý÷!u±Ž EžË™33‡Ìƒ1Dø5†éœ¾“rðëz…¾ì~è-Ü=D°§°Î`Áüó8œÏ?Á:uV¬“àîþÔBZ0m0ÈDÁáöîfýï ‚ÑMÓÀÙe› ‡ŸÌf#? Áln~&£»‡U£ :L¦M¢`%JQ0]†`s•æ•V 7Fi`2…ŠiÃñ±(@U\3ËAÉ̈P˜ÐÇÿ ãY8ë3,è4˜.Â9<²Ø2Kø)fɤ¨ê¿p ÀjÎÍ)P‚9  W¡ðFÀ4‡¸…f QEÁ+”4 2È™ÉÁ²˜`Á–ä UÊA¤¬ÿ I„}.ðS¦ca5Ó`ùkË1&“s¬Qiž†°äÚ2![ª'„çÈcqGÑ‘ÀÀ¬…ϰ] ´gÒÕà@!À5úeX€Ú3%K´ê²×†§ä[ªG˜ªFÞ\ƒˆ‰,D]ÓƒqÓcGá\ù¡¹%Ö‡Šo‚GâãVnnNÉvCáö7·µF6)™#Ï¢rŠ­#ýzìÚ™"În6S‘à„xgç‡=éìâAuã8v¤6Ðøw»1’·½-z6ýö=é3‡ð€óÌ¿³²*¸ŸtIÖKHy‚㣨ä%d¸;¡jócèZï÷#ì<®B™ mì2Ez%}Îòô:åLdàGUÍ IàV¢–önB–?rjŒ‹BdãúíUaýÀô£•aShΚÔΩäeÌõ¥^ éI~'5þ£j(Å6·€ç±b¥|»gÒúdUÅqýH¾÷íÃÅ$Ü8ÝÌ×z /Ž"—–&üÊ®xGÊä–ñB BøÚVÑjG]9¨5¤“Š£­[¿C„’œÉ-Ê™ Çb§Kh†ð¨t‰þAY-]&ÁV²8Ã)ć+Ž6:Àœ,) I!r[Â^Ø\Õž¥×Ç}άk ÅKÙá`â™ch¬%;%˜¨•í™ôBwJ ZqûDdžâ‰³áóIé',Z¿-“+ Ì‘J†½º¿==„W„nˆ4’>ã±ý–>¯¸õYI¿ŒÊwdkÅä\¼®È؆¸"ë+bÔ&L.—øB‘<'mW†¸#õ¥.\‘ï\.§{e­Û|ÕåúšÝ¦Yt<*èt+k+ ag;Õ^XañzA“ˆ›klðŽBÛ¢Aí%haž[<-}Ý%Á‘ç5îäÜððÚzÜÁÐÆh/“ýµá—V#ý‚ûx&U>ÚéTþás£68‰‹y¢ÊæÑw䈧¼à–ÓòtúJÏÍ-š#kÍÂûé=Ìãpâ.–«oü>š„ü¦’ºD‰v7B‰ÍðÆ£Oþz}íMö>š‡Ó þ€÷°ùbA1¿¬ þ$ò¸§endstream endobj 5727 0 obj<>/XObject<<>>>>>>endobj 5728 0 obj<>stream xÍWMoÛF½ûW t’ ‰úrÅEnR'F‹­ äbÀX“KqcŠËì.¥Eÿ{ßì’”D)Nz«mÈ$µ»3óæÍ›á—³ ñ;¡ÙœÿâÕÙ/÷gãhŒ‡í‡YÒèæ’&cºOi:¦ù\%~.âþ;™K'- *t")5zE.“T c%9#eD~Ò뢱³dÕS®Š%6 •F—Òä[ªÊDðiõ ²pd5îþ‡ Þ vy~ÿùlLÃÉþô«B¤)–IÄÏG7ohr]²ÓCx=œÌù&éÏÑkú¤Í3lÓF¹Œ„sF=U°66±bÓô2Z,x×*âývNÐçÊ:Ê„Íȉ§\ÚÁÞì%‰8–ÖÊ„*Ë69²`À{Pûï¥c'úç‡.ôÝ¥w/,e ;'øÓ'·¸1îÂ!76¢mH~«2—WÍA‹hV'~8F³î’¾BZÒªˆyߘÍ%œÿÈé¿(ÎéoÞ̘)}ÂÏ Fì…XI¾ÿ™Ú˜‹AŸöÎúæ6»]ù‡ÛðôêÛ[7jy¿-á‘ãÏŽE~vÒbyú´Îÿph8á©4Eóùkí£Üìg;=q H *xgÈ»ÓMqK…” 8JôF®¥Ð&“žäiÓlO*]Ìð.eQ§kЀåÙRmÉfºÊö 4²”ìÔ '†É–‚9ldª¾þ‡\wiˆÄ•[—éâ*ѱõ î ×È$ç˜FÈ»F´ßÓŨqÛS£>{§/|¯éK¥âgÚˆ-£4qôy%I§]HA74Ê ²s\d~óuSë'j­e4åê™Pö;UÒC¿{,P±Z,eoÐ[+ã*‘ƒi§ªøìs½ª ìbÿ2ßf¢X6ã² ‘üª¬ãǬAèØªÈsP0ñò‹[«WÒ)°Ù*½&Å:°böÂîŒ(lªÍªQ‹–Á ihÒêÙØHÃGf:¡•NTªÚ1 åØ#‘] ÄHFM6KáÖÎYø‚|*CÚ(Ä'ò~Ö½FW€›*?r'ì3B>pÆŠ5‚‡0 ü¦T3üMã·ï.Ì£¤&À¤Vjß¼ƒÂ<ât @>è) $ –Â|œ?š8ÍØsû{Wþ¹oM}׺ƒx…óÊ­§ývtÓö®ôIxÖˆÖqáEÓ£EÒÅQèß>á݃;ë#z«KN*(ÆØï%,t=f>dÀÃù„Tá—ù£q}Èð#•Æs­UªM¦âŒyb¥£§à®O–ÝGÃ]VÌÙáRÚêŠbxÔm‘{iì¥Z÷¨`ß'2Ò?’ÝUرú KPb$LÕE`@ `3WÞ ävâÌW(+óÔÎ%Ñ"5‘›ÞÎcÁ}Ê—\F7¢Û …‡a¶Ìq`X·&îîª%—*Ì ºrÜPyh k¥+Èk«Oë^JWj™ñ˜³–ˆ ËSOZMu„9˻¶®ë½éàF;Šÿ Œ~{–luþ['}&! Bì%³[L}[£7ìíçÊ Go«2€ùñ3[ø›t×áúžZ³ê¬…²æìÿ¸5°ûxÂ;Dù(è=M[ñ *rôRËÌdy#°Q`RW†ÁÁŒ­ ^<–lC©8}èݰ ø% É[ò\„vg,®/e¬eÉ‘ÿPÔlËß$áŠØ#8F)N 8ŽY ž^Áyáj¤C}`6ÚX‡¡Ð^×p|§ÝƒÓkaOù?6ôîD¯³qOezíçÿ8ó4w]òHùЯgñAïq™ë'?Ü„qFä§Ôvõ¤s¯mM"voõlþ(’ä±Ô ~`ElFÇpÔu‚7ÃðõÑÝш­×Ó±¤ðÖøîÀ”m-ŸÚuXAxمÇúÄUëSw9rÌHW™‚î>ݾüã·ÃlÖóÛ¢'&óËèÕìÍ“h>ñoV¼m8ÆôNǾ‘ùi‹@]ÃêáëÏ÷Þd_çÑlŠ×{¼¨ÌoøŒ_ïÏþ<ûµÑ6endstream endobj 5729 0 obj<>/XObject<<>>>>>>endobj 5730 0 obj<>stream xXÛrÛ6}÷Wìø¥”#3º8Š“fÒqÓºõL“4§}ˆ25D‚j’ вòõ= P”(Éž(vDâ²8Xœ=»ðÝÑø7¤ñ„’âèçë£A<@cûŸ™ÓóË! taìäR߇$R¥£ÏK5ÿ×È»Z9]ZGÉB:)mŸ>èTâ©OQÈá~Ó¨Oq÷{×ÿ èt8ÂRч«?¦=ny~yÖÀ¡stÆ× e ?¢$Y.D™È”J—¤3 Ó°C>ò@­¸Ê]“¹…p$ÒÔ’4Fì@&·ªœÇt•±}áœQ³ÚI*ž-µ£ÊH+áUî.Vv1G}” •Ë´³=a­4ŽñÂR;ÞKJŸÿ¹úœ4…*…“––Ê-ü|'ò€/¦Oy¾ê“z¢­d¢2¯KÇ'ÒdíÞÈÊc†™èj÷upº…ÜrvÏ~ôf=¶`æ»<½ïP¶ÖúÓw݃¤Ä]4-•¢Z§™¨û(j0WäK±²4“”À·¼Å Aµ@`Íê2a×7˼¢áY 6f %/5á—4ŸÇçt½ª$Ù•u²˜Öö ŽÏ1"üa«¢Êe*Y,‚µ5¿ƒlïž=#·±¢%yz,hMe†Ã/Ò(ÇìïS¥’ˆ€>ø”I#шgæÔº‡œ¦B3 Šé‚aµJ¥ó ¥TÙ¤¶ë0òë•6+æ= jôÍrIXXÆô»^JD]Ÿ€ø ìxñ»X¨ù"ǯ³_!¨YHNG“µ—â!}FlÁ½@«ýÞ»¼¨=ä4ïÝ‹<#8ò¼Y^ÎSÍ„•” '2²‘½ ÖÞ–½Ò›:qèÇñ–äKe¢p,…(KiÀpÇ›c‡u°ÈÁì·¯×8Ç̯û£x<Æ[½Û0øxR´„šF Êõ¼mNdÑéS¢Ç{×€½΂O|ŽÑ¼7áäñÇU¼7%¤O^éàDL¹k’ï´·?›çM£“‡ioÊ9»È4íma€…¬ÛyØÌ—Ñàë—ñàëÖÔõ㱘F£ÖÇ÷˜¿÷vp\¾~}Ò é@ðvŽ‹it‰¹Ì!#÷cmÞÀÖÛCÎÀFš~;ÓÞ[ïüMýàuz4Ž'“—Ì¿¤‚ŠHê²b§¡þ(.„U^ÓPdj^{µÒµóñÒ’JPå?ÎÖH9ÊŒ. ˆÆh2,‚1]"ªE#=Ýôúˆó}mCÇt³%MúéžUP0#]mJH4ç%—…¶©”$‚:Ïõ’…v-­â¢ì@4Ö6D¬Ç&`ž‚®¾ßKQb™å„hÝnêX¨âî*áíÏðà›Î`0°wöf\°Î±2§ ÙÖg¸²3ÊtàÃi¸M¨ñ`k’£ŠÛ]ì½O±kåå£óÃ:sAqaæ{Sér»Âhµ ñ}—#Åí®ô©9yf']îÐü Jœ¦HFŸ?a®ÿ,ôxÅÕN% ^!÷êH0[¡ü„sõÉ9†Ó¾…6ÂP×\7u\3~c‰y¸›ÅÞL#®ñ×nð%>"”ß7Åô·0Jp‰‘ËrÎů™×¡õ‡ì¾w¸ŸFX{¯ð[£ ‘‚r¥kZ H&NM>€â̪pozW0ym#–M~oRa€OUÉŽ)Ý’ãRšL$ˆEÜš¢r&’[§’[K77¿,¹¼âZªÑ œ£á¼´ö›²Gz±€V=8ƒJ2GÆ•³yý&£>Ë7ëöu»Më´û´wÑAyx3Û9‚Þû±{Ž; ô4J´ÁM§Ò%nZp »O…L¨Ìzv¯tm Ù]"`Pž¯OãF^ÃO‹«ÕæÆõe8øÚ4ô÷ûŸF}an°^Îl¥‘œÓ –¾’äàØK¸Ë ௌž#¤p…›îÆßP¨;*4ŠA¥c[­… }» h÷Æ5q(ùºã€ àÒr§4-µ¹ „ÉDðBL\ç™<Þf^¨R¦}KýE1T€Ûœ¿ùtxiýe…B‚hr NÉ‚ |oAäZÖ[Ïšâoú ¶Û¬—é„a qÃM¾Çx6`>¢†ï¡ÛNõe,_¿ÃÎÛ?œÅ/Æ/hòé¼½MŽâý¢¯~Iž6†Á§/CñwèŠöb0‰Ç#\PPà<ï×ë£OGÿMI¯endstream endobj 5731 0 obj<>/XObject<<>>>>>>endobj 5732 0 obj<>stream xåWßoâF~ç¯å‰ ðH¸œî©U{ÕI}¸6HUÕœÐbasö®³»¢}gÖ69/@.oU¢-3³ßüþö¡7†˜~Æ0ñoRô~ž÷â(¦Ãݳ‚wŸb¸‰¦0Ï`ÃìÃ8šÍÞÃ<õR1Ì“¾TâŸiüõãåü¾÷îÓŒé‹ F¤0šL…¾´P µ˜‚T à ”é(‚Ï ÜšDaq[]ÁZ<"!,éܶD¸¨/ Ôþ¾º{eÿ„J½VŠI.ŒpڀΫ‹»þ4¾»ŒÊ(´Á\C!¾yü%y2žÛýL*‘{sCÛh(…q„A¸¯¬ƒ{-¹èô ¾ÊJµë ÿK´J„C%œÔª¹÷°íŒ²1šÌø’éMtÑûL ¤Z%,ß…ÉâWÑ+Ì)L™Îs½á;²JyñSÅñvúÉGO!ÿ›‚l׺ÊS‚è=¥¿Oº’îE‘úè™-Û%#ËJ’8gÅ'¤vÊv"D¹3ó¬qnÜ$Ë£e¬Z¦p»‘+vo!ÒtQRÀš»~{ ·½»ìzë‹É;ûSš’gÐh1ªZrWnÛUíP|aÖéì‚I1?ÌŸXèGd<œåw°2£‹7ÆQ2˜¡A•à™qÚé½e¤0Fl»`†u•Á­/ö…6‹d- ¬ü_J(M6éÖÊ•¥’CH_É}K·¸¸uú^úkžàÿ`ðpm»¢F¶Pd¼õçà¹Ê( ª*–4‰hø,Ÿ½¾}ê<Bˆ4øö@Ùõ2ÔL0óúT ?æAwxÓ {>­,¬À –Ç]»EZgûuRj?A :äÔñÇMýP‰\f2œÆÇü~8îu3¦ýžØY Ãð@=àÏþ4ÑñºV&"Ï·¡ð…_¨ “h©Jˆ&ºxÔ9méCÙsÂY 7ÞÁw,¤In_ êw»O@}·1»Widï5A®uÚí}terÍ´œ¡;•†ðE˜âwIŒhðLs4eÒÚxU„Tr©¾a:ʇXš(x(òƶ°B…D‰-·žÔŒEÁ-z>=‘ÚCOêlÐÝ2¢1LÑ ™“Ù¥®œ7FhТrßs½“ê°(©ö‚M^@[ÿÀ¶ í'bue·:·X»Ò™äR?Q.;4œÅI;Ý?D ÖûWº(/{c‹¶Ð)ßôÔSVvÝõk¸ÛÅ0 Ÿ’è/¤IM°còºäNÐÆòÓ,˜„z¯¿´"ÖíãˆîyE/)Š£.Km¥£{l£›¢ð3Ô½Uìf¹&I¶”ÖêMó™ÄWÑõôf³›úýtû×çßF“(†_tRó¬[–}£ÁWËŽÞó£³y›† ÄÇ)eô6"Ç8~Ô^dzh:¡ç‰Ó‹™Íü:ïýÑûì …Öendstream endobj 5733 0 obj<>/XObject<<>>>>>>endobj 5734 0 obj<>stream xÍXKoÛ8¾ûW rRÚXõ#q“ëf7E/º5°-dn%R%)»î¯ßê‘X¶±rE[83¿yçÛh ú™Â|Á¿Q>úc9š„zÙ~˜Þ=ÝÂtËfX<ÐSìÐCü¹Þ¢‘e¡ˆ¥JA#ö  4Âic!1:‡ëå¿£wOdÍk ܾzѨ@¨ ºÒ( nƒyøÿ"ÒB®c™HŒCxÒð»È‹ o@&}¤1M`<Ñå‚+± f“ÕuHßSþ.B©ÜUð £TôA(’RENj;]fÍ5ºŽÔv5z ü…ö]Ùcº¬&ÓÂt°ž1ØŠ¬Äsw:y‡°:=­½2&×|ÙÉt¹/Þ4OÏ….ž›‹®‚æ5¼qûÕõ!7¬fvËT¶áñBQ=ÃBª(+«°R{øVŠŒü fûDH×WÉ* X ˜8ÌBËà¥ÑÑj$,Ž.rÿEѰûGA›ÖÀrà8²tÂ?ýTî]¨àtõi{âjœ¬½óô„|¯P;p©ÚÒtQ’Lä÷Ÿ!¶ð’¿/«/þéxorÇmr±û\»ª;|Æ×žù}xÎÁW1‡ÖÙÃ"åkTèO.7‰Î2½ãöÕÔ8 ‘P°F(-Æà¨Þ’( 0'©çùŽ…ÎäñÚ¹R0AS+Ÿ¥-4½@Ó×ÁŒ¾ÚžíŒÒÉ:j£ÂÄPÛé zUà;¸rÌ×hFW¹6TQïzs)koßÒèQéM™sr¤ª†¨ÞXš˜N›½Õz¸Ho ô†d%φC1Ti¯ûÙ'ýjüE‘ñ„z¶ tR1Òʺ¡`zåʾx¶Â“Ú¡Õê/Ãä|)Ü`Þ¬õË\ù_ªû¹.C]„ÅH m1RmÐHªÄQ=7KN§å¬q#¶’Öj$•3^­G^ÝaÇ Æ(#oøUƒÆêI;FÇe„õ,E‹˜¶š¨$Ѹ9£…á#µ£M×R.¾R‡£dŒÊñŽUŸi0rŸõëÒ Ô;=ꬦ € w †ÀMØ.'{L óΔJ_þùøèÂVç¸ã­'Òä^È?qI‚¼ !ÂQsU m¸—›2ó× ‘½Ív–¬ž-墠-–¼Çz9z )o™G+¤E–¬¤¨x­EØR€†ÄdÞcÊ´Ål_oÈSEIš4øò “=¹p]¦)acZ0«@ð˜a`'i‘¶È*é¯f@‰œôù1„ÑnPžCR#r‚oíÝž0¡fœá3: séäáš!ÅÒâRß®ô·áÝüïgá=Ï+|áñ,œÀŸ:*Ù>ÚXˆ†‡êìø=/ñqà, BI4Sú-˜ßMá|Fÿ] s‹‡¿úk9ú<úN£½yendstream endobj 5735 0 obj<>/XObject<<>>>>>>endobj 5736 0 obj<>stream xW]w7}÷¯˜7“XcÀÄINÚ4n|Nš~˜ž<”6GÞÕ‚šEÚHZczòã{GÒb;-³¬f4_wîh?Ò§4žò;_}?;fCÜÜþ³ :¹˜Ðéf%d§ÏqQ„u\ä½™¡¥ÐE%éÉì ì${~SËB–ñn«ßëÓÕ‡ËéºQUáHPnªJæ^M¦$o¥t¸§½PZé¥MÈÊJ°ËèÂX’·bUW²ßš<ÏÆìÝhHƒÑ(ñ«h ¥=]j/Ò¾d±‹wi‘ž¦‹_üAÞé}³º>´¯_©d0s—´AðkœM§ÏØlmMÑäˆÓ¯MЏRŸ$ù¥r/Œˆö_l°ûª³D'Ò® ýEé½ÿ¥È~Ág>ßS¢/‡µX)hÝWûºVržB¡³Í»¤Ô&¦¨EÔ^rG+©n$Àå!óˆ–ªî#Ý’J Ï¬he£# •£ÆÉ"ât‹ûÁhÂÅ»Z«Å Ȧ§íÕÇ´ýÇdw¾#ã7ó']wÂN¯—2ÿäH•÷§«Ò£\hº–ŒqS7ˆMËuŒn”h#Ìè²$gúôÕ@blâ6þnõýïïÞel+äðtÄñqlèZ´¦•dtµiÓY Pn»`N‹Cx)<‰º–Âòzô¤Û£Á Î] w G o“Î>pWja!â¥E¯XJhÙÀÅÊ¡‰ÐBŽœÖ#‹:˜©¤(I›ž±‰•¹ÁUSGÀ-HÝZX'Æã3z+(+¨”ëŽ'‰eR”niÖÄåimì§Gzõg«J‹*‰œ^ß•ˆ­­Øh"P¶Ü48ð¢÷[DZm»¨µÙ~+í;‚bÞçOZÎhÅø{_tK,èÀ]9ª³íRgïûù v?È‘Lò¹ØT. Õ»âÄ®Ã)'¡2è#½Î[p Æ%µ‰´1»1ÑÔñ¨EÒÙ[N7e»{g4yne8øóæö.õ¸À0 bW¸sX,aá6ª|@Y#øê6ÎËUÃÊÒX ™×vMl‹H+±éøãæŒ4ZÞòæp?ÞD¯vOíóÉ#G„ÖëÂ4×8Uý$ÈÛÉ“?ñî>©¤%º}ÉL{rãyEÇiá¸O.¯Žë 3}‚6‰›Ç?OÇØÓóIv6>£)¾ŸÅ§$~Œ²!ý`ò†{0¤›ÕÀQzð,>/î=ì$[i$[y¡óÐ gÃi6á)'Ééó1ïòfvôëÑ¿XÀS4endstream endobj 5737 0 obj<>/XObject<<>>>>>>endobj 5738 0 obj<>stream xÕWmOãFþίå JL^ „;݇¾§“Ðõ*RU•"¡Å^ÃÞÙ^ŸwVýï}f×6±‰POª (€½3;óÌ3³Ï~;šÒßSš/ø'ÊŽ~\M ¶å=^MhÎi•ÐlB‹å4\,.h»UZEÝ2– E:7–¢QÒ ]++K‘¾®¾Mh<ÅÊ8¨Òî-áëô”Ø”ÞÑqýâxD)?zw\„ì瘭O¯.i:ãýÇ`<;¯æËp.è—Ê•¥¤Ê#«‚·9#Þ2A‚ãÙYxÆ»¯$%:MõVå÷Oë©(u\E’Œ-ñÂ}–D‰•²â.e«’´Û&ôÞ§ûÞÙ÷³¥“›­º_!ƒ[8[Ítbw£¿òV—·)€ÉzØ Ûeê¢þ si¥!A?Õ1º€Å †+$oŒbºœw½¤`ž“.!‘R,£TÀ«.CºBròQdE*G¤’¾/»;àkP„É:P¹]C|à<î bh=b™ãC¹b1=Pß8hJØTÄРŸXniœÀÉzXïß‹nÒ ~Ûòræ•‘1YÍØÈÒÖ Žeé˜ßBCw"úJÈEgÔ;ó4èE¸)ê…2ìr+{dpôô™<£CúÝøà²CR€ŒÈ$ ÓG¾¡'aŸZªÉÂúÙM)M•ZFê¾&[LI©éÐ96”"õJ|l×]ÅhKØníúìðåiúåEˆ"aìwƒi¿mØ1·¼.¸“Ð>õšàŠË,èùœû ‡² ¯ï»œ Æ>ò(­b‰ßcÐ5"£5nÁ|uWz°Û1ðm¸™Œ2øyêß7£1xEÛö<£û¾¸©÷û®žª5Qýxì·3âs§Åzˆ–{æñÜ)ÿ[îˆ^—¸!Âc…ä·J¡s$æöP|F¯M(Þ ¥OŸ\¯Ÿò½xÿ|b ÒAá;1,ù}*Ÿ§þp=|n{ã¸9½ÝÁãRâPç¼Xa÷¼è<Ýñ‘f…Ê“]"‚æÚÓ/…Àa§hõ¹Åû<ƒ–*Q"€ýûc€ãBšü«9:A¤(•® ±KÃ>o~ÿøaDw^X•i~:Ë\LÂ)H–˜¶Ê>¸DZ4Q© (ŽNuôÝÁ£×\E!!±Ý¶ø¹¬Þ‡£~çðî«?>¿¿-nc]A¢yÛÉÖ<ŽNýÕâqºðRÒñ’>Ce’!ëZ£ —K§ë$7󸔩˪Ñ)¡ntº‘ ‹wE©Â!æð4<Þý˜2`d%´+ºð)gçDg) •|8kE.öÎèç.¦F•{RµÂ¢t¨Š4o|Rûâ}<›…ó9¤| 8¡«pþÓ^$nnø’gW)cOqž*—°ä3ì°¥;Ý`ÙÈ̾¥“)öü˜+« ¨þ”¥ £oyzÕÔ+ÿy£üW»BE"ÿ[à;­¸zô]•öw;H@&´ŸÓ.L€ØT‹fÐ!£“.‚8>°îšëÐ_‹ªkÚŠô+öiãr…±‹v.…úsH=ª¯8<_.™Ž3Ó½UÕ/ºùʲ Ü-¼o‰ÿË壽Qw)àÀk¨è!ýÕDçêË•hTß[pˆÁìƒÄUƒ¯4ÅÈSg=ìîçÌüØ :ñLèš9Þ¼læ5f×Ì“æ]:…Ð2óïnízœùb¼ñšޱ}YT‚en#¥·|ùÛ銶ºJcW$Ü®ª%³¥”¾ÿšÝgîžöCNèk»ó zay=^xD6Ì}úíúš Ûfo¾÷rƒ‘ñlœ8j'B•ˆÕOYwƒÚkûʪTaï½Aƒn€Û`È»»UT>/XObject<<>>>>>>endobj 5740 0 obj<>stream x•WmoÛ6þž_qð>T bÕ/‰›tŸÖ¬íŠõ%[<Å<´DÙÜ$R%©4ÆÐÿ¾çHÉŽRgH#Ð y÷ÜsÏÝÑŸÆ4Âߘ¦3þfÕÁ‹ùÁ(ááöŸ]ÑÓWch^`íìyx‹,¹¶¢£ SoøjÑÞ׋Ãç<}uÒh89ÁÖk•t$È)½*%ÕŠJziÓ¸£ó5ä-ã oaÓo•ó;G|Åçq¨Ij¯¬¤’M™bçÙ=ìZiOûëRêÇ:ý]úÆjG~-I7ÕRÚ¾GRlc˜Fqå-È¢£-çíc‘\}#­gÆûîÁ<½ Xƒù”^KòVTu)©¶&o²˜©è¾TÿHÄ,A5AÉ"aŠŽêc6Gú˜rÓ,‘ÖÛo$ ¾#@x÷æ;¢œƒg‘ptaŸ´Åa_˜ "Îdí‘)áï0¤a œA.ÚxÄ–•M.ó”þp2'ð&+…åŒÒojùXA V~n Âü±ùÛ¯¤Î -môÐÔ^-ÊÅ! ¯š Jw,±{TÔ÷borNã“ÅY F¹èf|“'Ó³Iþh•gñ z+ôª+Iï ŒRöm…úNÏÎxã-Yí¬})ªÝ“5Ÿ Î5umlkRË/Tvf«`–TX–¡¥@‘”VŠ|Ómù߬g½rÄ‚9`TÛÆ!tN°ªŠ )ŸÒ h¤AF"[ã –µøvªR¥°Ìž(â°<”ñ¬)ýT–»½¹£Â”¥ù«­‘¨¹É‚A†å×ìKfŒ™–VÉ¢ÜH*•fžXÎ^ÖŽ´”Ð]€ "RHrŽN» ¨+(H#€'Ïp2ÛŠ2ÓË[™5 ÜÊ’Mí¦Mc;nùJj Nx—*®ì\`(! ïQèC&-ÚÜvºNþ}W e¥pÆZˆlvf¡ =f®Lc3ùô]{ÈHwœx9:Dæ…$ ºúøæ5’éE¬š->´sž¡¼$3UŪbõPl€$ QájXrqQŸ ¦ 3Ú[¨6²€J)$GÑË ¦óÚäÁÄžx¢%ÔSÕ ö!‚Ž0½AüT"•äx² uÑgýN‚禵Aîi'ÇT( A¹\=hU¯mP¨ ÂlG A«Fåòyô>¢³tÊj §™I:â.O~h§ ܵ‚ÀÒu˜’ C2O‚BèòÓü—ïé9Õ*ÛµÓ;¶Ãâø6xÜ ºQÖ7(µ£ÐÒ„ÂA„ç-š}é­Ñ¯Žp}óç_˜}{„Oùî‹E2xó¤ šìWìb¡í¸†KìyBôµ…cØA`¿ÞÔ‹ä=7•#ýÿ_·¥rJ÷û"´>0­_ø5œÄòµ{¡¡³Hl\ vœõ8å¼\סK-¦pæK(fj‘Üç$0²«Ö0,'Ót6{ÆŒÍÑ2î(€Öh¦èh…Bÿã2CÒ¸&+Ã%‹B²Üõ ϸªr •´=ªèÚ“ÖC…¶dQbÜœáëp+ÍŽpœÆÁGvŠ4rc%yo”<Át *À³$ŒÅrá†@U¡VPûÞX±ç±iãdÑ”±PÑenßÙöçÁIz:=¥ÙÙ,…37½á$ÑÏ& ç™ítíqñðY”*Î)ç|H?#‚åÓÑ,N05—Ùù)‡ÿr~ðÛÁ_Ö=endstream endobj 5741 0 obj<>/XObject<<>>>>>>endobj 5742 0 obj<>stream xåXïoÛ6ýž¿â ¨³Øò¯ÔMÛåÚÍ]5í–Å0-Ñ6;‰TIÉŽ1ìß;R’#ÇÉP`ß–‰#“wïÞݽ;÷ËÑø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ýéyõkx~=?§ ~¿C•GKo è—Íg|ÎæB8Ý{Á£²VÈ]³Ôñ0¥ÿ‰çƒI4AIqfòrÂw¼9úåè;½6Žendstream endobj 5743 0 obj<>/XObject<<>>>>>>endobj 5744 0 obj<>stream x½W]oG}÷¯¸òDìš;­ò’6NSUIª EU‰Ð°3,SïÎlgvÁ´Êï¹³,°`œ<Õ¶,`gîǹçž{ùûb@}üh4æ¿$¿x=¹èÇ}|¸ûçRººïÓ]<¢É‚†}¿Äãñ-Md8Õ§IÒ¡ƒŸ¯ÝÉ_}Šx"ž|%•yEzAÓþ|é’¼˜v„KWê/½Ë¨pöqs9íÒ«WÔŸvñâß3¦ˆÂÙÙ")½¢ÁgÏ}Zët– ÷0ƒŸiGO»çΆwÛƒÚ¬­“û螉­òjö°þâZª¬ø® EUúi§ò"U=_JåÜ3XœÁ3Žã'ž¼ý>¼»º¿&æÃ‚"0(޶ êL–ŠÔ£HJòª$» [”ÚORÊHOÖÐz)JÚØŠÖ”TZ’–´áOåVV™Šé­2ʉ,Ûôê“¶Ê$¡TÂAcW“¥0©¢ÄJÕd2dš¦á>»f“ ~{*œ†K©Ej¬/u¿ ërÁ(†×làÝ‚Ä6r*±©ÑÿÀŒ0[ï=ÒÈqâÙZl<%ˆ—8 î¯Î_§Ýúyƒ^‡ƒb:äEÂÓJdZÆ„ '„˜Í©r©}¯•ë§ÏïÞÒZÃy©\®(Þ–K¶2»à%PÊsa$eÚ4 xc]Hýêþ% Þ  Ç Âè.ôãkúÉš…N+p‚Y Z6QÞk“¶sâÛ×¸Ä RêPDŸYû€ã„ò?ŠïŽÌ…6ÓÎ)n¹*—V’ö¨Ž/À0=Ï#EÞæP%¯"ƒŸÃÈÁGæÖB0Ós'Üæ(3àB“À΀9lzåPt¶Ï„ŽLHíh‚Þ«j4Æ£4VvVVK™ó`öA¸’×Ñ‹ –_žRF´æ“ ѾgÑy°¥¾zAŸÀ ­PA"_¨D/Àn_Í¥J‹äÐb)M²/® ;üx¶}<Û]œv.‹ À6Ð¥Fl¿íºEò›|n3:uùqÇ#ëfR-ÀLøã@>þ1ùåÃ{\öxx|¿ãvŬ8u2­OÎøÈ.ÇØ¯Ógò,7…ÊE±ƒså¼Í2žñ´½6ã í\¸©Gë·•UÌíjË=i¡F^­X%™ƒ&õQIr*E@ÊùÀt#ÀÕ-ëz4ª$‚Û!±NÕrVE¦Ù.S|_Aë¦mÍEâÐ\¬ÐÚ>´‹3(¦ 1¦ž—‹0Ðîp³>ܪ5ªòü? î´Û -ØJCDZ2ªŠ`¢h8_–[¯ÚBÈÉ„‚7í¸áš¾\ÚúÁ^}ƒjΑ«p^Iš+ˆB þ$Ì/¶‰Ô\äkp 9» Ûãu}9È¢’Aç`gQ9˜phx§X˜¦OÓ‘¬VSácw­.†‘z”Ðoz~œÉÎê´Ó{»Þ;䓼¾…Ú=Ñ[¯;1Ý#. ñ¼ÈÀ‹#×g±lƒñkåÃÀrj¥‚ i3p;>]³N{ð6pumkþD*AšÃÈ•)ëáóL}“ÇÇcTxT 6¾_-8ž±vÊ–ç§ä ½1%d¶°,ò˜vaDì÷vhC2”|ƺQe¥Ž áAn›è!L &©›å¨ßŒKls¥¸!WöAÉz¸W ¨ˆ±%Ê­’Šé™bNak(uÖj/ v/ôKxQ¼N«rÃÕóÐGÜNP:‘mPSœõb°®Q¡˜Ÿ+,8Ÿ—ˆ9ÏTs!7Œ^hzjà«wŒ‹×N°‚RQ'XëÝF¥Å’³»¢mÓ2É*f>â0UL:åÔhýÉ^FBõx° RB¥SŠ / Aÿ^½¦Hß‚Ö9{ÄÙ¨4|B¬´ûjbIÐÓc~ñW(ÞÇjäš‚ŸÆþ ᪬à×(…%aa'oO—íŽs·Ýl‡ýëøftCãÛëøŽ÷¦q4Œûô³Mt¡_Ù?¾"Ôg£ÛzÐÕkåkåÉ>à¹éãÑk(ÌŽ_Þ²7“‹ß/þƒžŠpendstream endobj 5745 0 obj<>/XObject<<>>>>>>endobj 5746 0 obj<>stream x¥VÛnÛ8}÷W ú¤¸µ|‹/q±»Iœ»­[Ä@±€‚‘(‹]‰TI*ÙnÑï I9vìd›ŽYÎ gÎ9Ã/­>ôðÓ‡á˜þ’²õDzՋ{øróO¯¡;?†~–Oð)uøD—RXÁ ñ›s¸Õ¬ª¸†D¥Tm«ÚÆGËÏ­î¼? N:“˜â.Óh5OÀ¯6h­ÓÐê·Îe©Òºà YÉÕÕy),¦T–J‚hfVàOJô™nñ¤™ÒÀŠTæRNrQ¤ ѵùUßs!÷«JÁd IÁ™¬«'¹ï ¦ñ tÇTÞß%õ§û”…. \Ÿ#«ªU´:ÚíM¥Xç®90ƒG. ukfÞ¦ÓxHô0À ñW iáýW›+9›9Ÿïm¹:‚o´‘Œ Û†‹ý–C» )µ4BÃ+«…\C;Tã7ÚÆ¬Õ«H¾zA0y±:zýˆwKÈD@Õ#!ÐÔ™íÆo³ÅˆËîV‘áˆ^þ¯ÃÂ~ÿPqìZy¯ Ç '=ÝŸö(°êª¹<°ý/&×5[óÐ0Ìv¯–w¹nz‚Í;õˆtu5ßíÚ´\s[k W//>-þlâx§ß=°N€Ô s8é Fñ%a0œÆý^<†·^¨ÐÄŠF~Ì?¼àVIï£*îqìÐÿQØ\øÈÍ&󊸫ÜøÍÄ ‡’¡Ihš‰a™sãWWlP:åÚsu1°êš¯…œ¡©0ÍNÀGUÁž«÷8µ¨ ׬TH¯–ÌËó àALN»§/_6Iºê>‰ô[ŠªkiEÉ綾#™Kel/è$5ÂŽg©dÎú~P¬„”'ÓNˆ±FØ?!“¢6ÈÔ­J'¦±xÖ¡$Æ'ÉÞšZTôçÌâçÁ8c‹Ã(ìÆOŸ¬–NP%ȆK«¿B¥H6i¤Ð;|æºB¦ØžÔù¹?Y†àFÇÓÖ4Ív]vÃúV`1Pì H7¦ ö3$Ô•˜e…Ü¢Ù*LÕk Úlç†a7¸îÙ÷àrèyЀ0Ý,zÝöUÙ;ô}yÿ¾»ëÿnÝys?ìOãÑpãÉ4žøk¡´3ˆ{p¦’ºD;öœðúà­;_~?Fp¾E%„†ƒÅÚ5…àB[G½q<ø›èødJ¯Î—­­k£1Bendstream endobj 5747 0 obj<>/XObject<<>>>>>>endobj 5748 0 obj<>stream x•Wmoã6 þÞ_Áà©óÖæÚ ýp»¶‡`ݵ»æÐ}0(¶œhµ¥œ$7ˆý÷‘’í¤‰ôú’2I‘ɇì÷£tñ»ƒ!ýÄùѯ“£nØÅÃúCÏ¡sÛ…‹p“ú]^öÂáðL'Õ…I@†Ç“¿ŽºpŠ2“„Ž:'0– –‰8Œ;÷pÒ)ez•L:ñ¹p_øêVd< TaS|hCkÕjÃãÓøó–…Ò±‰‚è8:þe×H! ~*ÍEÇðï®:Döo´VúZ˜eÆÖõ] öPÜ]Íÿ6 nþO¦·Çwß¾Þ4ÿ·{Y:Õ…´"ç>°G«…œGA«Õ œN¢ô.Ág ×ï]i¶\rmÞÞÎÓWL‚±hš Ëôœ[+a`Ü!á_-˜L2”ÛÏäãJ̧º´ãR5[K–cB[.ŘË:;{Ù; ìcvÚþ±Âê%N¿ÂäÇ,”™tÊç3@éuÚô°QÝÆÿÞ8ä*)’s]ìPb•ð·Ÿ1)¹Ž‚·¡mnÌ›KÎN•†x!²DsÙpË“ó‚ÍùhdÕ2 dƒÿ›ê¶ÆÖÒÂr`YV¹"r¥µ_7×EŽvë†9T%•¨¯ƒ÷HV?$ûä;eºÔÜÚ5þ;ÞweƒÞvÚ>eœÉbéZÃ4€wÍ3n±êè6èÕPmdÞ,ïHÏA;¯Ë¬¾èS¦ŒóŵãA ;uȈP¡¥'Æûß^w±ãÀÎíÐ…©§ýA9*‚o Ë@*‡¥V17˜'••À*™s,dF%e”îejÅ_rˆˆª7NCÉl5, R¨Ô Ä*ϱeˆº}y3¤1žeA÷i6á“kl³LHîÅV /`EÒX·[‡Ý çFc ‰â¤¢Æ‘–¡Y©RÔHtPz’2¦ö5@ –1c¸©Gä¹1Aó®‘:ú­(ÑKdŒR/L UÈy>#’®L·Áû»×" ö‹3Ž1XUÄ ž„ð„ÐÈ™RÏÀ,¡ASݧ gvÏáRÙ}òA“ÖKVI rI¤<¢c¹Bè=æxyaxR;‡ˆIHYl!ßBE¡–®0ƒS@“‹Yøy•¯Äˆ@=¥Ÿ_cøŒÈ—È™H"±gL”ÒÈÁ(Á3fD Ç”e®ü¶0vˆÈÄ3!-̨‚f³ðœöûá`€ëO 3ÀÃÚ.”öÀúâh ro÷@6üÌ­w1J‹ s€+Á¬°»«ij2¸Ï#~}Àä„*þ½"{d ¹Ý2ë|D/– Œ“õLJ¥Ï]M:lÐz`:¿£¦:Yâ“ÙÕr‡ j7„ÕWPYš«§ OY‘ÑrKœA‚N‡ß#ATY/·ÃAÂÆy_D£€üoÓæè%SÜ5~FÛø{Œ—0iCéKÓÒ¸±eJ“ö5®ÔÙ#ÿf+ÚŠ hNàé´b€v«JaÙ@èñЙHÒøÇöI·É ªU_¥_+þ`ßN3wn/Êï]œ…çƒs^`UûJ&‚<í‡]¸Vq‘#w¸Æ!üq÷Ò§üè\„½n8„ßýrB{<.u›grJ’îywúø/öÊðò’Žn&Gý^•Á9endstream endobj 5749 0 obj<>/XObject<<>>>>>>endobj 5750 0 obj<>stream x•VmoÛ6þž_qßæ´¶bËyk†h»´(Ö­[ê¡(`À ¥“ÍF5‘Š+ ûï{Ž”bËÍÚ,ü"’wÏ=w÷ÿ:šÐ¯ MÏå?Ù½œ£1Þ¿U+:y=¦ËhJ³Œâ1?›Dçç4Ký®1Í’Á?dzÏG'¯Oi‚Ÿ°mOÛmƒÙZ[Úê<§Âl©¬LZ'LÖl˜jËY“.2Sm”Ó¦ÀF·Ö5¦®h[©²äŠ2s|ìCÅq4X:Èê"‘ãÛDWtgtJ)çìxña­Jžü=±œgóc1 ‚9ÐîOyK0Î’ªV“Û͈ì[Þ¼ýÅ—…e×s6LM½Ì™¾<«Îh>Ÿóãû/£Ÿ¾ÐsH몃²:€òÛ:wp8cI XæÇ߇áÙ šÿä£yš‡ùhøYŒ¢¶LžÑ$Þ•âYWŠÓËh2Ž.èÙŽr¾ãœ“2­¸àJ9SÙ~!KŸF§’òUŠ}ÚÔ–”¥ß¾!m‡¤ )2[jǤPãÚYJT©–:×N36cƒ[3•f‹R6™ßQªÊr5ô ƒ‘^pêV PnvõŠÀÒÁÖT·ä ZD£©Ð'yѯJyCKNš‹cÕP®ŠU­VŒ¬¶Û‚Ól Ú¨Á{\…ã*S â˯N^=}Ѭó!1[=;æ¤cÛ.gNzeLJu‘re8«~ €qx­ÁVÓâWÀÓzgYöÝŸ¬åâü’s·ŽºbÙÒC²VwþaE©Iê .èɾ_>›>—¼C“J§ yDê`4.Õ¨Zô:e%p$xæ¹´zS¢“E’Пk‹ÔøÝ Ðü8”„ÚÙ9 Û×JËw¢æKMäǧú'œ4”ê,ã èïã¶ÈAðŸsKÊù2•’V!mWœv™éo‹cNï]á¡m¸Í58—4] ºþ Úþ“'gŸ~¿žúÙ²¸ÏÈ@N†òC¹èÉI¯ó›ëÙŸ7¿-d™êBFÓÞñ7o>Ìÿî"ïiÒ› Ý ñŽzb½¿2¥ ¯}%ÒÙ|O)ÆÂ÷{pí]š)wg:{2%žÏ‰)PšŽäøNš»M­áøÀ0¨ø¦á¸oX˜k3Ú8ž°%˜†2©¾>Ðáü!0ðƒ”áv­œˆT¯i« gý¥ZÚÓiCuy¸Z±««‚^¼{·xÿËá¢çëhoÞ?l®c­5w}sóþ¦³Ö¾}ÙùĘ AR0QÖìN­j¨¦€¤ÕkH’³ª"zY;b…ÝõTÝî4JUòZåïO^ã¤ëP(v\§ú=6SÉmî›ÖËÔ,çMå%ãt W+·5I^qh-Üü0åDg{+&S\ù„t=ÔõX—Ê=¤%ÐËeÍàSÄ$d×bn…†\v×Á‹H.šp0qq «Ý]QÖZ ÷;#Wíw¯ b5åeÝ¢lFYejçºù?îGñeôl?þLc\.¿æÍãK9LmËÀš~½©)y£Jësòºã ŸFgÓ3:¿ŒÃ}BfÂ(ŽÆôóþ´è¸=‡½£‹Ppº´œÏ£ih¾ÅÐõìè£Ù «Rendstream endobj 5751 0 obj<>/XObject<<>>>>>>endobj 5752 0 obj<>stream xVmoâFþίñÉA`ÞàzJ¥kK¢¨RBU²„{½[ïr»kPTõ¿wfmà œ4Š’8¶w^ŸyfÆßk]èàOúúÓÚ/‹Z'ìàËãÅl }w Ý,Ö(;ø„7‰?Ç›8˜eÖÂXÖñ„”°âà4Œpx³åë„ÃZ¸Z|­µïС7¬3;¡Õ³a»7Q]奻 „ç-s ,Ø­>(´,õs±›ÒLg‹3MïØj™‘ƒ&¤Üpù,R(’î@«ÛÃdŠÑˆÍÖA" ÷!…°Ø¢ 0ú©è5úµ·”Kí É ×ê]“¿˜l%9H®6n L%ð5ˤƒ3,厛"ö5 © ¨õâ:+‚\¼ìx¼åñ7¡6Þ²ÊÒ73›,åÊ?ÿ¨ƒÙž©YÂ( óQSJgÎ9ËÜoµ"ð‹0ßeµ£°O”kÂOp/ì÷ñ9 ö¸ŒI˜oç‘@SbZCEWðOYa-@»î ³|I`αÊV³Ñ>“|Â#„ÐV ÿßÂ=w¤ªY·/éOtP®>ŸkĆÊ G×sMzY¡õÈL:Ø@ äHjϵüË µ0ôìC÷N)Ɔ³¢éyS^}EJ_¦Y`Rð¦üpDò”]µùz‹}î»iãñz ÏÆÁߢ´¤ûe¡‚+=&K}ØLº 'ÕæÂ‚QÆi•9–QS[ %h6\{Äú»}J­ŸQ¸YŸΧËÅßc¨7ÁgÓ„z|™ß?áêÍéä2 -ªÿIâ=bFRÇxÝ—óBqŽm×$ š[)(œrUI„û¡$§%q§·mÛÇnÿg8×’K‹<n‰‚6 ˆœMšR©ÅäŠ|døýŒ9õò¥Ñ·JNR¶Cw‚z´*ÃWËke±3™r=[]ÿ1¦ç÷À±ìˆº¼t›Ãàç>µø[Ùî2£°r2ã€uU<Æ=ÀÌ Ž‹óARTQ°#8)ß$–œ©l—oÕw:ýUj›ïâŠ(Ðߪü^Ÿ–7ò¼HüËd²œýþ9ŠöÀk|/h k&d† ô#¾¤uUÀÜm>óx>ŸÍ‹ëÿ¾:NlL›­¬Ã^¥ù`©Ì8ᤈýn¯Bœâoß•½;ºoú70^—Këéùá¾Õ ;ð›ŽýªfdšÔpzçÒ­!}%Av;á&úÐ’|Ïe^è WÜ0§óΠì÷òφa§K†Æ‹Úµÿ·ÌÎ$endstream endobj 5753 0 obj<>/XObject<<>>>>/Annots 3124 0 R>>endobj 5754 0 obj<>stream xXkO#Çýί(ùK¼‘=ør),Ë”ìÞ$xµWZ®P{¦Çîë™îÙîŒ#å¿ßSÝ3clòв€í~TSçT _Æ4¿1Mgü•–G£d„wøÛ˜¿ývs4%#šLN’)•t†w›Ý½?ÛvÙ%¿Ñ9VÏsšŒhv1Nf³3šgáØÍÓ>Ññ·ô®.+ò+Iy­S¯Œ&S{úöøÍüG#ޱ2ÃÊÏVT•´•UÚß÷7ñå h~s÷oþÕlÁma ÷*ÛR]½<î,¤—8G‹Rî¶¶·áãæÂîªÝ¢ö|+}m5Ý}¾½yø÷Oííñˆ?8–ã÷'Ä/sbÏp2mè_?É´öJ/‘¸r”šLÒFUÖduŠ1=G›•JW´°XZ§RrkŽH-€ÔFù#Æúm%KQ¹¿²’p¶ó|îÆØ5yC™Ib`4žp`֌᚞'ãQrNWFçjY[¨ÈU!Ý~*¼ã$9á=—Í­ªDtyÌec'6°««ÊXïHKa‹-ùÔ~K…ÐËZ,% –Rh‡„§ÜX¢qH-3rB+lPšJâñ?¢&®9‹¬õ‡Aº‹¨®HqàP‘›¢0r¡c÷#ÂB鹄æ+é$ €P ¥±<@) º쀴ÈJåW+=Ø‹f‹{”gðMýQ™Bx°Ž~v[HKi$¼[`!…[ðskjZkD¸ ·#b”?–Q$P­‹:[âTCk)£„Ì£´¢(ö¢q[çeIV.ëBX:#[k†1¡k½D†’Zr¸|¸°ž¹LM‰k£“2IBÝîð5ª2P.#1R ºmnaÊ2YIMéÊÇw„òbQHÒ*]³ößÈÖrE÷}Ž1iªÃnÆT“ØËŽ+Å‚KÐ ïß$ô±9¥]-$ºZ*À.Ä㥅¸˜Mé˜|Q®K€Õy®ž6Të kSc¹Zñ:<ò¯{¸J¤&”Ð×”|eŇJúŽx%Ûa4ƒ~nÂÞ=ô‡KÂÆM­ƒ¼\òµ~º¸8X´ÏÒ|¤ô(¬Ú‡Z˜Ìx!œoãË@–¢kÔœ‰þàZÈTÔÀ•ã!|G•4È'T2Ń"È´ßÇ'Þeÿ̳Puˆpõìe»Cƒ4Ÿ`|òV–°°¾Gdr¤Ã ÜnY%š5šÀSe¸ðIë3{L)&¦„à£ÅA2¬ã¦”æÊÇ'\£0ió–×rÓØùIˆ³ÖâѨ uÍñ}­ÜC"ÑVVè(W§‚¦Vq=TÍVøÛôQó¨_€ŽªƒW ž+++Vp²h¯ß ðaoÆÚÉYgUÁ}+ç´©Éqr:=‡³Ÿ†ŸPxíàϼfŒÎp~2C§À»Þ§áÐå~Ý ÛEÃñi2: ¥çÖªê‘˧°®4º.ðÚÖëF<Çâ"S–Ø(þù)^:?dã‘çÀ“Q2=?QÓ’ËhË)–8@ @8§ sB¤P@Ó`[`;Ël{”LDº&®¦æ< pÏeÂÁ3·Øò†ƒ‘ Vw¶¨½áó÷—µƒXŸ¥°”½!v¡C³éBÛ«O.µªòܾb3âÞÔöQ‘¡G¯$ê3®¥ÜŠ%‹ À½ÛÀÐ$RkÂ$1ìŠQeÂØ4BWCãå‚¶Âî#!L|þ( Sñí,Á­ñe³hd…`Ri0…ȇ± &"ð´X¯¤`cajaaŒXÇäB`ŠÎ`’:;†â0ªÜÒÀÈÒŠ2è)¯‹ÐºØ#ðf3ÌÉgô£8ÃÁ“2¹/ÏOðON9Âݵ…Ë«‡Ëßn>ßÎ< âE{ÀÒw7W?^_ýtûñæ/,¿ûôön~°®a%@àx&²è‡÷}7Ä·CE Úž†&Ç툼d÷kšô+y}9¼–+#¾×åþßÃ5éJX‘ÂÙ·^¯°0¬Qèha¢€I@5"Hµup {ƒnJÀ(ïÛÕ(·ÐÆIÄS"?Rð ‘u8LžÏÃ{ÚÙH£g8T8ŠÐO¨s¶_VdÕ í؆~„E{{[3ß9&$2ؽåâdíÉ,Œ`êi‹SŽyÇÇs²Z9ñ˜þéËm3¨#œøl€Ç®Ó9‰œÑ†º¾ÁÆ…:B¸\½ªxzÃXÃÌÝ~µ£ÛóïaþÅIyÒ‘¶-óØÜ†CïuClk‡ÃÙ}kÉ^—(½OþnI¥š1³åÙQˤòµ`<«³O‚ŒpH“Qn<8û×ü"¡÷ã˜,†¡bLرÎöøo\­Ç=¤GifÎe¦–qúç;±펻]£ƒÞð÷^€«74½¦Ù¶ÕCÅð¦aäè{úBÃß©÷ïŸþsqqûñêçOï®èÑÐ<{ûçÛ·w=:Kx¸Œ£ŽSŠy6È Àu³p0U”,+¿P¼¹ÅªS?9wdtŒlk±6ÝPMKc²HÝy;FÌÎÑ-Oiv6KÎFaàÇãá.xgRŒ×ÍØ v2: «‡gñ¡ùOžAOG³d:‰ƒÈÙhÂG\Ï~=ú?X‹Gôendstream endobj 5755 0 obj<>/XObject<<>>>>/Annots 3126 0 R>>endobj 5756 0 obj<>stream x¥XaoÛFýî_1 °Üš´,ÇŠÝ¢Ò&éhÚ\ãCq8ÅŠ\J[“\–»´¬of—”H'iEY¹;3oÞ¼™å'—4Ç¿KºZòÿ¬:™§sü—üñów'‹Å2]Òóëô†*ZÜÌÓëpQÒû“£ËŠ®æótq¸÷ÍÝÑf²c»¡‹7ÏérNw›[Þâ[.Öð%›™\+ò–ܽiHeÞØÚ‘ß*O•Ùl=µºÜ“­Éøôìî÷“9%‹çØ`öOÝj2Žv[þ²·UjOªt–r]˜Z“ªqi”£ÕlÝyì©k~î´,©Ö:g£÷e—o4%IB¹­O=>ñœq«³/ÙØÅ "Ž/»ìgòG÷H_Ó?V³þêövuVô¡&¼ärÁ®þ œ/÷çâdo¹²¹)ö¤U¶%[ÐØÚ,Ûêì>÷ºÖÎwžøqý¨ª¦Ôñi¯O\g¼žìÜò±;C ¥Y'¥ª7Ú<1”T»:KéßN3ØT›ì¾V•¦Â¶üƒÓçT[IDHLJ?ZÏÏ"ÙœÀ ‹ Èi­±4$w«8£{ölð‡cp„ÝûÐÉiO]ó•Ø«îA„RSÛÞÙYxãTmüžbSo8ÜH¾Övø.žÒ½©sl]PÓÚu©+'ì»xs ‘€Ê1½¯#î½ÁÔÔcLÏ"à-uÎŒ*‰Éû¼Ö”ÙªÒ5ÂÞ6Ì3I¢`?Kkï™· ¯~4Îó^CF芿à/X|{{!@¤%6û˜Ó¯ìÂ5”¦ÍÞom}´E£} ÌÜHuv… Sú ÅéºunZjtK%ŠõãÞþ`ÖÁQýè[•˜ÚyU–ŸtøûBø¤òœÿÂBälðMJ0¬¤£”è;óS„?ç,ÔÓHGÑÇ1ž3ÚHO¼‡ (§k?OÍxÉ@tÎ}¸Õ ÒìóÔí6ãÇgBÐ¥µ•P¤;º&‹°ëÌÛªúDwödËPΫ™mX™U¹: lœxóg¹™!n¸¤„cÉ(};D+3,Å`p£‡ r‹Bi»õþ˜éœàÌJó=²Ÿé‹·6g 8¨ªÆa ô%8£}ÓqâÒC? m^vÞJ†ùç”îЩCkúŒ·CT¡5ý; ‰h ý ÷–À°á9A¨®d3×AäD¹®k½;‹á9÷9èÖxî†fSCs2Ló=¨jt 4œaâäX•y\ ‹*ZÛGf.TƸ'DÜ Í§×‘1P¡¢ÃoV}¼«4¶D¯÷¹qM©öÒ¦"pàÖ± Q…Þ‡Vó{K]A"½‹%wÖ«›ôržÞÒÏ]í k{×4¶™ä%•¡á•qYçx¾Ð…/ºº;öÉP˜{€w®÷¿|ÿH72€f§ÓM:­I~ô·omý [ÿη«Ùt(øÆè Èâõî5µ×íOëß?°åÇ)ž µJ‡â q2rUrËdá~‚G-³®q‚%cs„$†÷T‹^cÖ­‚JÈ®c!zãä, $«¬ó$ðÞkÝ8Ú´v'Øÿ+åQ ŽëЇ†²Œ·¥:P+¦6UÇÊòªVæ–½Îu’¸ÈËÇujÒï]©Æõ{yÓ7ò)Ïà Ój±|3Ú70¾»¼óùoηð÷omñ z÷7¶(ÿ¿µÉâõ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}[ÌŸ§×W×´\^áe JŸÕ"Y¤sze³ŽõIäÍâµDx6yÁo6>9B]Ï—éÕ"4Çó+^þúîä_'ÿ¤›"endstream endobj 5757 0 obj<>/XObject<<>>>>/Annots 3128 0 R>>endobj 5758 0 obj<>stream xXÛnÛF}÷W ‰ºÙ²Ó·ÔMÑ&òÁŠ\Ik“\vIJ&Šþ{ÏÌò"Ò6$PäÎ}Ιáß'sšáoNËÿ‡ÉÉ,˜áþ˜óLJw'Ë«EpAó׫`E Ϯܓ«˜>žürwtDι-Mo^Ó|AwÈ^]]Ñ]$"gtŽ–WÁ|ð]9³×)Ez¯c›%:-H¥;MîOòÒúìîádzsNs`‘“Åyp¡£7òЋB²ÌYîÈäBªS1Väš·öºÕu¬Ûnèã§Ûw½·0.±‘Ù˜PƦ9ç{¤œ3؉h¤ÂÐ&™JŽh]‘Š"àÐé­ÓyŽ ±3×ÂMº%Ã$ø(’uš—>ïTA©=:™ÓNí5­5¢dà‡ÊPG‡DÁÜ!Z]¬€]Wα]¶,Ø6+ûສ:úf¨G±ì."†mF¤Ò2ÑΖ°^„*×l vjÚ˜Xç¸f•^ЦIŸÛÛ'•dxjÚ‰ï'zD‘q:,¬CTs:h ß…r[]P¬Òm©¶šòL‡œ&reZ˜Ä›û㺧ŸYâ—ošЧr Ž¼ÍYå˜LAÛô“Ë‚“ÿmÛg!/t–ãÚ‘æzlbõ3+BË¡–9…oë³Ra™BÑp ‘Õ„Wj`‚ "¬ÑhKÄe]–×(J$A$  ˸`‘[j§ ”ÄõôúÕ+ä3Ò°¾Ø‘Ƈvòø5ÁZWd8ÖlÉ® ŸÚ¾òÅPùï&}QÇg¼EQ•ªùŠÍÚ)äö~Åñ4ß¡±P©¢äþ¬¯`9TÐx§ÒêÈ'†þ帞ÕKç2'jXMÜË›CZ7>úRnÛ6´]é•YfºÁŸ à–AçqÚqÝYtBjlY£kâVÉœæT4òòÖiß!ç×ý*Q}a©M5ê;³•!eqáELm¥Ýp%úÖ³ƒ¾à;,€I_×Õ×½ŠËðzœF?†â`ŘB½ ÆÆ8à'GE~e(jU}L­Œ·±!€Ñ°D%jJ3*qR¥‹€Þe\»þðQRæÅPœŠªÊ±røHP/ëMŽ)÷)ôbwF?b2¡2Özk@,Ü~Ó›]K&¹ƒû"X.qN½/ùoåf"–ÁjuÙ0BcoÓãL7Œ`šÄÕZl¤ÃX@Tc*óÌT‰UÀo%°Â–Õ<5ilPm§ÿPtúï0š9@‚)!“‘¨ëLQ!9ýxr÷1ÿIÅöÈ ",ZyX?d³†Y¡> 7ƒžÓ‚L9‘üaÜcC:L†tL,«»÷®mñÏMô¾|˜$:ø¬ŸŠ!9ŒéÈÔÃug‡¡ñmÐr€X(CÁ ”^RV÷Ä%˜-`f†ã8{$ë…¸Áì€n™Že*ȵô>ý¦öJ ø³*v<¦ô¹,ÊíG¥æ4M`\MõpÐ ¸¸ÀDWã¾Km`_`ýé¬èu|sþ}B@üHÎÄ­—dgÕ@òó*ÜZĹF.?ŒJø§‘¤©ã;³àì5ø–{Æ‹î@'£¤Ï`'Q)ȸæ P—@:§á!ÒÎY‡yËÑA¹µ,ÅÍÚ˜jíXÐÇ-c¢‘ SbsxLás(‰‘ï& #X©6扻%-ƒž6˜ÖquÆä ;hå~@×B•=sðdCÀµñ~þÐtÅ¿Q&æ™—I[æ'Øb´¬Á|rìÎmQ×>̱8 ¸yy¢çq™[»Ñ'xòlB?~Ð-^¿º?™<‹úAÏ; âŽ0-OñãÁ«ð: Ùé5fhñgªŸB-H$sµLO*õ÷(Á£<•òÁFD/:µÛRn²' 1µð׬GÁœ>”)ç[ìêÏ×VÃ…í9ô¶u0¹…Ýî'÷`Ý£ÜR”)W˜°âÛÝcB M„ÖñŽ”DWBžX8gÑÙ"ƒE¥ƒ¡=79+í…LêÌ›uÆj¡ô^=j¿,0‚´ãi½õv³0,¹RÂtY> 5d…I¸¦PËH4²ÖglNkby,4Sá#Ló:Û<@@ñ4g¬ZwX:UÂD üÖfìÀ#­\l´“¨´Ku³!úps»a*I¹Ž_H9ƒÊ6âÆCø<©²%j‹®® ÓFæ&Ët$KŠI#^fálû\›¡^î|¶ÐÄÔ‹HŠÆCl™n€o¾ÐPU5HI`:a‹w@\gXÛ”Sßá;u‡©!úíÏ2?yµ\K[Uo¦Übãۘ̕pݰ¶&v ¯:`­idä™Å×üÑbgî±Êëõ-b ¤lF1¿—èÖP`5vsHáûŒAP}äÅýˆý(PÑp!¶ÜºØGïÏÚ!ãÅá.áç'Àe¼˜tâú>ð:;ºôÀ.‘ïó8ùÝv †Þa=÷×~ñãÈp>/XObject<<>>>>>>endobj 5760 0 obj<>stream x­W]sÛ6|÷¯¸‡vF™Z´>lÅí[ª:Ìô#•éCœñ@ $Á&åøßw )SqµõØÒhÀ#x··»8~:ÓcšÎø_–G?/ŽFÙ‹Ý—[ÓÉëgSZ¬h2¢Ùãl6{I‹l¬åÃÐ×:¨‹›£ ÇÍ1F›5¥0úV_—Â+n-ñÙò] îtØ«MÜàêÕ&W®Ùôñv;¥'_‹:ØÜÊÿrgU)“ÿ¿$¤(Š¥·ìròú”¼ ÿp2mð,6ŠVºPžÖÊ('‚ÊÉT9µÕ¶ö ) -åªPP{F?àVY(\ UL ˆB¾r·±…zвŽVø`gá‚–u!¬k±V?1Ü}Ž '“l:còA"?ékŒxñ÷ü¸ødù;úPS'sB„”Õ¬An2Eä_ºÖ¢: Òæ\´rŠnjÐëòï7¿’ö¤>+Y´c "Vø€³eØ©Ðæ–¨€‡†Õ®8 åß„hiçyCcUÊËRåýa`æ­yÛˆm“!åmåp§>Õ‰qDêU‡<Ë•Ö9%Cq_f¥×µC›9« —H¿—_¨M¡¡WÞÒâ MïÄš”Ü‘‚sV[Dø[ Ö#ç?„×B›Ž2 rÜ«e„o{ÑâÇü‰À x„õÊô2jo;€H!Ú£Iç0‘O½ÀG«7+º·µ‹]Fóm„Cb  kÍß¾?æ ˜’"œ5k /ò­ö€]©aXHÀ¨¢AÔ’¯믊X%h4ä—3Zl€58܃†uËŒn'Ì}C°^“°Ô@½—hK¾Œ^£ê³(+æ­ ¼i:+•÷¸ÌR«•–Zf1é¥Ó•tc—þ€v o&Í¡°#X»a< b¯vQO]p¯¹7b+ö¨ð¤cx•ä´v€^!æšð±—lr­–µÉõVG Z„[ýÆÖEÎÊëø Ãa1‰ hVNÉ÷µÚ–=!‡ e°îþ˜xÍ3üà"µÈŸì;IôMg0ÍɘԆ¢4Ùºøœ%7ÿá”kã¬ao‰¼ ÙÓ!(DPR{а—_É&ˆúJÁ7{fôÝFËMC?ðB›ªEoKfÒÀ$Þ©ªð‰½ê>´@~Ü«†›ìš±T…½K´çu#JXÕª—$¯·ûeÍ•É)[.s]мK¯ CÁ9ôùàÆæôç¥ùõâârq=uyq gHj¯€ÇÚÃ9[“•·û5õ^­DwÄbÓ8HGžvÐe°túÛ ÐþÖ[„àíÛçM92žølõWÕ7x….k—ÃÓ‚ZCh‘¹€-Éœ…ñ2 9ø/ë"h%Ï5WW&È÷º¬¬ ”Ô«·êêÛ¶‚ÚCº;&zg÷œ9xµté\ ò¢8iíòv€!6IhYë"$§±é„Ql¼qºƒèVΖ‘ÃS\œ‹iuà3zõ(Ã{ùp1¿¿ÿmñæzþÜ ļŸ«Ó±ò€v/l3ßF`vÓpœŽ1§¤94ž[ŸTZè.ži¨ÂA¯Òl…óV†‡žÆäjrÁL™ã¬ˆù=Ù*À„Hð1è>#vÐ}5æKŒÏ›Ãh|~šMÏh6;m§yŒ‡“lD¿XY—§ÍÁRôðezÑ›žgãQ6ždcz×LÇÌ;fêîµðl4˦¼ƒÂµ_ŽÎx£‹ÅÑ_Gÿ™®>endstream endobj 5761 0 obj<>/XObject<<>>>>/Annots 3133 0 R>>endobj 5762 0 obj<>stream xXmoÛFþî_1È—¨¨IëͲ\ÀÒ4Î84½Ä½â€ÁŠ\J{&¹ÌîR²î×÷™YR;WŽ“û6óÌ33ÏêËÅ„Æø™ÐlÁÿ²êbœŽñ†?&üññýÅüú:Óõò6SEóÛqzÛ=•ôéb6™¦ š.Æø¬h6[¦“îIFOž1ºX¤7§£ËE:=¬O&ƒÑÓgœ;]GOž1:¿œûãÉ#â[ÓÕýœ&cz(àñâäâ(þÈFŸl¥ÉiU’~RUSjO¶ ­²Íß=ü÷âê~LËtÆk§cJ¦Ót6ÃS>ªÔ£¦Äciø¼ÚÞª²ÕiVjUó2Lå_š´ÏN[Y[ú4kšg˜ª±.ø´jË`N&}LÄÐYºXܰoò­ª3SëÕZ³sa£‰÷O|k‚¦Be¦4Aá¹¶®M½¦Àv­É3<ÝšÂl5ù€]|JØD0Ø*gÔŠqëñŠP>ýþóû‡þ_÷‘ªóáLkʦ~üí—g8 ãáA°ä™bOJLä7Nó»ÛÊý%™zk>›_õ“ÎÚ`àMç¼ ~1)ýǶ¤p„Ê·¦;ekô®XÆ ½ëèru„ò*³Ueë´z<÷¹0%€¶Žr”´«6ȳ"¿A<É·U¥à“²Ryo².bƳ›@,8KS°{ôoU®‰¨‡{òøœ3•®¬ÛS¶ÑÙ#‚Ò= ëØyx-æuSAëGO»® §8ùH,åÖ:P©êuË|3uЮA–h÷j˜MŒ,u¤¸{…7)IØžDì¿+Ú²|5„û,6@pgÊ’gW ê> €Îº°¦ =XPZûH*ˆ¶ bÔ1F­,¸¯<™·BÔv¹Tˆº!®šÓ'2Nçéw!e¦jL7U¹ÿ8ͤX©œ:¤U–iï‘L­ÇF±>ñqFßáA §2 M™;]ßíµÿ6Šo@ÝU»^kGì‚*½e?b¾å(˜ÞXäÁE³5y‹¢Ê!¼';‚Ñ:_ý=·DÀp<û?& Þ(íË3ùË£Ÿïß½yøíã»OCH×[ãl]é:P_à8 í é‹:Òp9ànž©-  25H^PH.GfPijÍUÓø'@ÍF9Tò¶T"ÍÁhf/Æñ$=V[ÔÉ ÊNíx…”¤¬õÁV†Ùµâ™‘½™ €kÙ1/qXÓLjÏN>ˆ›ØG‰E©Öý)Ø ››ú’ åT`N—Èf3/^)¿Á€.ËoÇ8K­>âÇJ[ž&͘ÖÉ€a ¾Êt$ô¾êI ñ:ÉÆg‚é%¬È³ÂÙ ±ÂB¶–cÌö×ú ´å"„®ï¬C <¸ÛU»0ñþr€%ª%×îŸaßèJ5]±I{á·,ž©ŠöÞ½J$9“Py­\¶éRù–¸¯-,]®{EÀÒlœNfô“Í„ à!²¼`õ‡®ü“­_K³âº|vŽUƒ®ódEG;ÝDpG)uÇPÙ¼-Aý·­C¡ ܤY]O  °U€(7¤HŽ>¤ ‚†‹[5èÖ–9›ä4Öl/ Êù‚Ê-}¼äœGCÉvBSt×¢0™álŽ ˜3—ã, _î¨R9~DIËb¶f›*‹‹o­æñ·ß?œr\Þy…xrVjK…y‚ñH¨ ~῟E'dGèÆJ4äQø€ìºCÌí,"u¡‰ÐÏE'R#¯‘vµ5¶õ(F;ÀqA&úV«×ó¶6_ZÝ·ïûßTˆ$R;بÆhuöÇ ø–Ëå䀮㛕m®%GpM'™‘oOjê¡¿`uü‹ðM–~É ® ¢Ðÿ˜B'ÇÑ^£òX'IAõéA]j¡ÚJ‡†z{…G™y¦z2 ÉÝ@¦µUÔ(‘gÓ!LÐ/Q”ð¥?œ+7ëÆÒ"CQ5 5%ÕBšQ2»0è²2kF¯qаŒ`&QŽVFq¹ƒÓdϡעÌ;$órÛBÛŸOä‚c+Æ4ÅRúÃáòsPÍiæÜu›Ef}í~nµç„î`€ _r¤˜¼1 u­«©¤;yStL!úëüÀÔÜxt¿!IY©qœºÄl¶§ìôÙÕýà8ö-æKý«?NŒªaeÏ¥„kF²ÖµvR¾vŽ‘X²¹ˆ`\]6,‡X9\™€Ÿdˆ©,@+!áJ¾èDÖHëèu´6"¿;t-T„{@ÜôCèk€+_p—ƒæˆ Îï$H¬ðdùB›Å…tý52‘]Õ¢JwåR !…k΂jðDƒºAw"1Ü0=J–C®¶¸ñð QªÁ9Ú1£OÐ>6­ezKɵ$iײæ°ŽiGŠN²²aƒž½ûª©À¢>6ngÐÓ!݆„>iv?Ç›ÀΠ±0\/n‹P6ò;6BKfàvÜ"3 À— Ù‰/ ¶aw0q9Fr˜û¼O±–ÒïÐêobôq ø‘BèËR@!Ä/ÃòÆ™é,`¨´s4×ìxÙXzÙ òM¨2µ©Új`8 ï`TWh{‰È7"¸‘£fÅ(XiÂP ïV»Â6Eù.Êà䛺àY´\ޱê ÷tòÝÃÅ¿.þL†­endstream endobj 5763 0 obj<>/XObject<<>>>>/Annots 3135 0 R>>endobj 5764 0 obj<>stream x­XÛnÛF}÷W Š u“ÖÅ–•¢íCã8 zIšèCÓ‡¹’¶&¹ìîÒ²þ¾gfIŠbì @¶D-çzΙ¡þ>™Ò?Sš/øVžLÒ ®ð¯)ÿzÿúdvy‘.èr>O'TÒl9M—í»‚>œ ß—4ŸÌÓÙàÓá{|z±8º÷‡Û;ñé6t~sAÓ Ý®×â^ä^d§÷Úyc+OvM~ó:¥Û­¦µ- »3Õ†”Óä´*Š=)òMY*·ç³ak<í¶¶Ðäu`‚v&l)×A™ÂÓJóݶ …©tNZ¹ÂhG¶J¿¾ýë…IfäôZ—𜠚VÊ›Œ^RfsM;ëîØÄjOµu_Dö…7e]è/H?(~A¦ÊŠ&—PÉ5U0¥¦ }8C\œˆëN²ßó4A*‘L(™Î8‚WÑ?¯÷ak«óè žîêv*Q'¸5Þ3M‰àýÓi<þùD²ByÿŸóx2 1ÿù,fã,~±¹Yï%µC¥N3[­Í¦q:UÙÈàÙøì/êN¯M¡SSŽ’ªòñé¾ôŸ¹-Xn+÷Þ뮕>¥w…V¸PÂ`é4{;ô4lU Ã(ÕTéªÚ4j´xª,>ä€i³v¶Ö耭ìÃ')‰‹ä޲­ÎîÆIù­mŠœ|0E!e¼ú;S×`‹ž“ç[ûnµèõÐO¢,mÞ †’0™2?t ôp_ë ²‡Ä7 B¥*v̰ÿÄêÇÓ}GSÉLÒJþà ý™LýøuJ¿oÑØ±GIOís+Uµô]¾gh’?£þ ðPC)Ä@©þ²ÎQƒK¶¯]fËÚ@3"Û7F y¤Œ:˜`-òTZ¢éÖ‡ÑG!žE¾2 ‘ƒ #(•ãtJ\A…¡S•†ö0Jåè;”“¾´­•C¥Fmº·é³÷‚¦€ U¥5± eA¹ÍšRWA‰„„Ü6B‘äÆw¥è!<Ô,?½<8mE­bRÐÞ6Ž<~e\#ü¥ \S•¡ "hû•O+Œ€òaþo$âîOwÃæ •ÙbÙ©xšœ‘.1(Ä-Ï Ž{]01Vx(ªUÈð Qø´ µ‹ìhWŠ;$(¯° C\í[‹{sJf˜b‘Šo+åÔè/­­§]¯MfTA¯r§këM°¹·ÉJøzŽ@"Z)ÚfÈŠQÏš´Ñ¡Ÿ}¸lÐÔôzâpÅŽÐÉXEz A Ý|?‘½ÏU7( „Lrö¡åªÏÊ>#™»8qÊsdÛÆ²#6¾ !ÅÆpk®*p5geˆt„Pr«ôÃÀ©—JŸß¼9Ëû Ÿ/Óé$^Ò˧±8\s0–SÙ/ná¢Åï¹½>¾< ž ÂûNíPô=• à÷Ó—ï¡ ý¸Edȹšj­!I9­-ÓaºÕ¤æâøt üå&óq[ ¾a0yM•£ñb¿ŠD"¯´j‚YóN¬-°ì8ÜA°ÚV HP‘ÿÀ‘„Èån#ê„2êFÌe Û”~Cw?,vû¸¸ÅE > K¬¸™fÄ»À7]VËtÎK¨,³t>Ç»üôe9}W]¹D8žÅÙÞæ¹OؽùõúÕ¯·7o~~õvÌH®[WÇUb^&³yºX\±“·k¨ –ȬAåy%ŒåÊ‹¤ÚÎÈ×*Ó2³¡=Nq—ÈZ pà_Bׯׅâ1±Ï³I­ðÐ#鎮m죽Ϥƒ„€½5££o«ïÆÛ‹À/"5XY°¾nÅ4¹8“ãÌIÊü=ª·¢xà1'~_  Ž2ÀÅT€SÃ|ž°€Ã£D!é'/E‹lKŠqäà1£Ywð°P^ ìß›)º†fƱ¡gàC{ò±`P]Iï¨FwYŽþû§VžíÃø†–¤!²Ûã½@ál-Í?²Õ. ÿ\¾ֹ^ÃǓÀ€ç£Q6Û›ú¶}õ|¸TõÓF%‰Ç¯HéñM”dlg¿ýè ƒ,A)¢Wk¬OÚ:ˆa"2ÒO"+ ö3` #룒ÈY‹¨‹JÝcYfrò¦Ð=åqЃmÁï̆’­.êøA¿1´KÕ²ýêc6¹H/ç—´À÷O iv“ÌðeÔõði„­ úx8¹âïMúEì‚Þ9ûßÁJ‹¦s°Xy$¨ã'îV¾Ú8N)h”3+ì/¶b'—“E:ŸaÙƒý«É_zu{òÛÉ?~(Ðendstream endobj 5765 0 obj<>/XObject<<>>>>>>endobj 5766 0 obj<>stream x­VMoã6½ûW \ðb#Æßq{Û7‹^Š«¶—\hв¹•)—¤’Eÿ{ßP–mÉÙx‹Ö1Y3|3|óùGoDCüh2ç¯ÚöÞ§½¡âåñŸ[ÓíÃw4šŠ)¥9´ç‹™˜SšE!¥j0YˆÑ˜>V&ÓJÚIçñà´&[fÚ¿I?÷n¦4‚2$ã©X,€0H7Æ“×*˜Ò4•3+í)l4e&ϵÓ6\À‘´«G2œ¨‚ö¢62;7ÂT¦Uñ‚,[ ®µÕNt'T!d‡<«Š*3vMOÒ¹*´¿¡¼²Ñ_? --±¬q!‚6Ûii¿o¬SÚÖdZšg¸ŒB¹òÁIß´îÙœNèÓ¤xqôqP7¤ÿ ÚÙ›x{PA‰.ÈÞú‹(¡‡Cœ8 ¸ <0M.›v1²õqޱ*³=±¸†ðÕnWuždQ!0˹¬Š€üॳ·MÊ&1b1Ÿßq 0¸J¦­S?¬qÿö-\:jgß¿M†A•ù9\;Vìþt$µ­øZ><âéÙ„ÍY`º<~u ¤ÝwÏæZ†Êéï­~æX"­tà®dlf” šœ†Üòu¡Båê3úO§}tbÎt='¥ÿ#'´6¿ÿ…™ë¦P OÆ…J]b¯&·¯ïÀþ ãuf¥RÚ¿4 š¯Hm¤]ë+iý;BÜ*ß]µ*¸ì\dñ£yBÔ%õZéIj¥ÖÜŠnqÍALÊ!ÕtF«=} ‘_¢Ÿ~ƒ&eì5o/:r«oË#âZOî(^ÄéWn>¥Ë\¨«äx‘vÚ5Ee¶Û*ð ì¿XX2KJ[ì_g—ÇÚ—¨å–Ær”(4q/£÷ŠÜ 9³N’+éðE‚y½ˆV:œ\äÏ}t…_£uc†³ ýêWë?D”~·Pü~ ŽŽ™˜Ðì¥ç=¢UYP¤°c=d-‡JëÍ"ŽgA¿`üç ‚‡*(8B‘‚þ¦w2‡h´˜ŠÙd†em$棸|úí‡ÉX iYªj‹Í*n9 ´»Z;¹«“í+ºÙp.&cls˜DwÃÃ|H{?÷þ¦Óì endstream endobj 5767 0 obj<>/XObject<<>>>>>>endobj 5768 0 obj<>stream x¥VßOÛ0~ï_qª„T i ¥lÚ0˜¶IˆJ{áÅM.­Yg¶«&þ÷ÝÙ¡I3¶µ HϾ»ï¾û•½!Dô3„ñ„ã¼w1ëEaDÂõ½€£ë¦áf)Œ"˜œ ÃÉäf‰»Á,ôÅÜX-bÛ÷ à-ÈâLKa ¬4£Զäh—*1áþì¡A0$#É ?3i#Ÿé ¨ø 6Uˆ»zÆ*-XûrîµÊý€€ˆbu¿¿é®*ØXÒRkc–ê åÑõ 0Ìâ kXT9Û=º>®/ðñ1tEG¨…•ª¨m´y F£p<&V)rò‚ƒ à+ 8r»D`à‚0UYf“ûýsÿÉ€M60[•˜` ,&—¶þêü‚0 áÙý`—Nó_¨”ÿ‚NxY…;“ÚXiŠcÞHsÂô¨Aiˆ—Bw‹É™jôàä{˜>w ùˆEW+Ea©/ÞÉ<¯¬˜gäÙ·ŽU ‹DÆÂ"hI ŠlåËlKrÊL)bÜRŒ—.uîÎ.Ì­ukp•Sk (ŽU>W¸¸ %Þ°ˆ3e0«Òg¯á}[Õòûf‹L ³vJì³ÀÝÝbÇkÈpàâý«DVF‹WHtçH±¥œîB¥š?˜#y¤4§¨5±cU‡ÙŠñ·c¼¥*S.2 ¹K‚l®ÆHÆŽ•B%-#^±NØß©ù‰«K·ÇXL!ö«‚Fzÿú´ô*Zzôä¬ôßTµÝâ%§Ãß ë­ƒkîŸ"/3<„=?‡÷žyíùû÷ÃŨh¾¸@6v{ÑÄÝ"¸q¨’ø„‘5YÛ|á“sâ3O4,i0¡æèŸ´(K÷ˆ6ß`Áªr 3U¾,½RhÚùVã[ –«¤â¹Yøâ¤w3­÷òpzžŒO`rJ/3~ñÞ}»ùŒÂ>ª˜vuaݲf5ÚòþvpêßNÆÓp8‚O•¤,Q‡5ø€˰ÎI4 Ç#z¡¢•~±èjÖ»íýL)•óendstream endobj 5769 0 obj<>/XObject<<>>>>>>endobj 5770 0 obj<>stream xÍU]oÓ0}ϯ¸š4©{pš&mZĉ—½dñíjHâ`;”ñßwm7mב2&X§Ê½ö9÷ú &ÑgIjÿ‹*x‘Q‘q÷¥na¼œÁ$‚lE±é3Zpç§E1Âïk~‘}ÆËé.ŠÅSŠ{/p¡°0â†>0‚E˜ØýâX‡IB¿øè¬Î+<ƒÝƒw’·%‚µÛLж8(Rw•Éov± ®ºêF–@FŠ—+Àº(¥FºMnOƒ¹s“0Mçv·¼iÊnˆ‚sB“ƒª†ýªÚÀÏßðÙfõ0 ¥lUý.ûq*JÌÕ'çìQX&ÏO÷e%”6/×¢äŽ ƒ¾Œ„ƒ“ê+¨-wüÕ%ÙºŸxK,E‰oÈ}Ì |…µg:„´j¤2CeÎû?à¬Ü\ áôÞ'ã|OÓfGȬ¨™é¬òfÌÖýh4šµô÷Œ„€Aæ·owRp47…䪱ϰö£Ð/›\Ýêý<¾Ån#²¶ÖFÃõH¬ ¯»ë Kh?œÇש‡µqíéŸ.)Ñ Ì<(l„YƒMqÆË!Ñüó‚Ý—¥}Áô)uú+_¨Åö©ˆ£i8Kfή_}zsÉâ0‚W²p ÉndI²}$›û' Y„“.[ÁѪP“+M …ôZPß]?fQ&1=Z¤ñ”eO~ƒ;+ºã¡endstream endobj 5771 0 obj<>/XObject<<>>>>>>endobj 5772 0 obj<>stream xS]Ó0|ϯEªÔ“7mš{„;Š*!"îÅç8Q¾pÜ⿳vrôŠ8m•®cïìÌìú»!¤o„$µ?Ñx¯s/d!½üóÐ{,·+D!ò’Φ×nŸ1Ÿ™S/Þ£çÆHÝ2|de*Ìxß×§f¢–\Óÿt–]åß¼å6DÆ‹‡â˜% ­Š¹?!ùpŸùeÜÍ9UÓ¼‘TµÌÝ•E$ËÒ!èf˜ò§SÖ0QXOºG!aiº±–ç0’<+â•Ýs"JKaÔQ¾(æ’Ê;¢‹®|"Às(g¢k¢+ä¨!À Åx¨”¨ e_s!˜J¢%?Ô‚FµÔ)ØL©ÕµrñŒLùÃvìã&ü¯>~‚1†_TMÔä»!ðT·ÔœGÿ¼§üÛi£yK¡4b¹F´bämIS`'!cáØ†$cQ‚íA“T[y”u×7²5صe§ÇäôY–ÙNå”%¡”BщƒMwyàG®j~_KWÖLÕZ;x=Øþ|ú²{»À«;ü•ÕäÃýa¿·~«3†¼¢ZÊÍídl9 •êûÇû`1)ÅiÓÝ£‰-1¿íÄÒ ¼”3Ÿæ¬Ó§É¬lʈÃ['kÄé†ÅN®Eb‚°Î2-Ù:6ãùoc×aÊ’˜®=IÙD‘{“{½ße±5/endstream endobj 5773 0 obj<>endobj 5774 0 obj<>endobj 5775 0 obj<>endobj 5776 0 obj<>endobj 5777 0 obj<>endobj 5778 0 obj<>endobj 5779 0 obj<>endobj 5780 0 obj<>endobj 5781 0 obj<>endobj 5782 0 obj<>endobj 5783 0 obj<>endobj 5784 0 obj<>endobj 5785 0 obj<>endobj 5786 0 obj<>endobj 5787 0 obj<>endobj 5788 0 obj<>endobj 5789 0 obj<>endobj 5790 0 obj<>endobj 5791 0 obj<>endobj 5792 0 obj<>endobj 5793 0 obj<>endobj 5794 0 obj<>endobj 5795 0 obj<>endobj 5796 0 obj<>endobj 5797 0 obj<>endobj 5798 0 obj<>endobj 5799 0 obj<>endobj 5800 0 obj<>endobj 5801 0 obj<>endobj 5802 0 obj<>endobj 5803 0 obj<>endobj 5804 0 obj<>endobj 5805 0 obj<>endobj 5806 0 obj<>endobj 5807 0 obj<>endobj 5808 0 obj<>endobj 5809 0 obj<>endobj 5810 0 obj<>endobj 5811 0 obj<>endobj 5812 0 obj<>endobj 5813 0 obj<>endobj 5814 0 obj<>endobj 5815 0 obj<>endobj 5816 0 obj<>endobj 5817 0 obj<>endobj 5818 0 obj<>endobj 5819 0 obj<>endobj 5820 0 obj<>endobj 5821 0 obj<>endobj 5822 0 obj<>endobj 5823 0 obj<>endobj 5824 0 obj<>endobj 5825 0 obj<>endobj 5826 0 obj<>endobj 5827 0 obj<>endobj 5828 0 obj<>endobj 5829 0 obj<>endobj 5830 0 obj<>endobj 5831 0 obj<>endobj 5832 0 obj<>endobj 5833 0 obj<>endobj 5834 0 obj<>endobj 5835 0 obj<>endobj 5836 0 obj<>endobj 5837 0 obj<>endobj 5838 0 obj<>endobj 5839 0 obj<>endobj 5840 0 obj<>endobj 5841 0 obj<>endobj 5842 0 obj<>endobj 5843 0 obj<>endobj 5844 0 obj<>endobj 5845 0 obj<>endobj 5846 0 obj<>endobj 5847 0 obj<>endobj 5848 0 obj<>endobj 5849 0 obj<>endobj 5850 0 obj<>endobj 5851 0 obj<>endobj 5852 0 obj<>endobj 5853 0 obj<>endobj 5854 0 obj<>endobj 5855 0 obj<>endobj 5856 0 obj<>endobj 5857 0 obj<>endobj 5858 0 obj<>endobj 5859 0 obj<>endobj 5860 0 obj<>endobj 5861 0 obj<>endobj 5862 0 obj<>endobj 5863 0 obj<>endobj 5864 0 obj<>endobj 5865 0 obj<>endobj 5866 0 obj<>endobj 5867 0 obj<>endobj 5868 0 obj<>endobj 5869 0 obj<>endobj 5870 0 obj<>endobj 5871 0 obj<>endobj 5872 0 obj<>endobj 5873 0 obj<>endobj 5874 0 obj<>endobj 5875 0 obj<>endobj 5876 0 obj<>endobj 5877 0 obj<>endobj 5878 0 obj<>endobj 5879 0 obj<>endobj 5880 0 obj<>endobj 5881 0 obj<>endobj 5882 0 obj<>endobj 5883 0 obj<>endobj 5884 0 obj<>endobj 5885 0 obj<>endobj 5886 0 obj<>endobj 5887 0 obj<>endobj 5888 0 obj<>endobj 5889 0 obj<>endobj 5890 0 obj<>endobj 5891 0 obj<>endobj 5892 0 obj<>endobj 5893 0 obj<>endobj 5894 0 obj<>endobj 5895 0 obj<>endobj 5896 0 obj<>endobj 5897 0 obj<>endobj 5898 0 obj<>endobj 5899 0 obj<>endobj 5900 0 obj<>endobj 5901 0 obj<>endobj 5902 0 obj<>endobj 5903 0 obj<>endobj 5904 0 obj<>endobj 5905 0 obj<>endobj 5906 0 obj<>endobj 5907 0 obj<>endobj 5908 0 obj<>endobj 5909 0 obj<>endobj 5910 0 obj<>endobj 5911 0 obj<>endobj 5912 0 obj<>endobj 5913 0 obj<>endobj 5914 0 obj<>endobj 5915 0 obj<>endobj 5916 0 obj<>endobj 5917 0 obj<>endobj 5918 0 obj<>endobj 5919 0 obj<>endobj 5920 0 obj<>endobj 5921 0 obj<>endobj 5922 0 obj<>endobj 5923 0 obj<>endobj 5924 0 obj<>endobj 5925 0 obj<>endobj 5926 0 obj<>endobj 5927 0 obj<>endobj 5928 0 obj<>endobj 5929 0 obj<>endobj 5930 0 obj<>endobj 5931 0 obj<>endobj 5932 0 obj<>endobj 5933 0 obj<>endobj 5934 0 obj<>endobj 5935 0 obj<>endobj 5936 0 obj<>endobj 5937 0 obj<\(\))/Dest[4551 0 R/XYZ 0 610 0]/Prev 5936 0 R/Next 5938 0 R>>endobj 5938 0 obj<>endobj 5939 0 obj<>endobj 5940 0 obj<>endobj 5941 0 obj<>endobj 5942 0 obj<>endobj 5943 0 obj<>endobj 5944 0 obj<>endobj 5945 0 obj<>endobj 5946 0 obj<>endobj 5947 0 obj<>endobj 5948 0 obj<>endobj 5949 0 obj<>endobj 5950 0 obj<>endobj 5951 0 obj<>endobj 5952 0 obj<>endobj 5953 0 obj<>endobj 5954 0 obj<>endobj 5955 0 obj<>endobj 5956 0 obj<>endobj 5957 0 obj<>endobj 5958 0 obj<>endobj 5959 0 obj<>endobj 5960 0 obj<>endobj 5961 0 obj<>endobj 5962 0 obj<>endobj 5963 0 obj<>endobj 5964 0 obj<>endobj 5965 0 obj<>endobj 5966 0 obj<>endobj 5967 0 obj<>endobj 5968 0 obj<>endobj 5969 0 obj<>endobj 5970 0 obj<>endobj 5971 0 obj<>endobj 5972 0 obj<>endobj 5973 0 obj<>endobj 5974 0 obj<>endobj 5975 0 obj<>endobj 5976 0 obj<>endobj 5977 0 obj<>endobj 5978 0 obj<>endobj 5979 0 obj<>endobj 5980 0 obj<>endobj 5981 0 obj<>endobj 5982 0 obj<>endobj 5983 0 obj<>endobj 5984 0 obj<>endobj 5985 0 obj<>endobj 5986 0 obj<>endobj 5987 0 obj<>endobj 5988 0 obj<>endobj 5989 0 obj<>endobj 5990 0 obj<>endobj 5991 0 obj<>endobj 5992 0 obj<>endobj 5993 0 obj<>endobj 5994 0 obj<>endobj 5995 0 obj<>endobj 5996 0 obj<>endobj 5997 0 obj<>endobj 5998 0 obj<>endobj 5999 0 obj<>endobj 6000 0 obj<>endobj 6001 0 obj<>endobj 6002 0 obj<>endobj 6003 0 obj<>endobj 6004 0 obj<>endobj 6005 0 obj<>endobj 6006 0 obj<>endobj 6007 0 obj<>endobj 6008 0 obj<>endobj 6009 0 obj<>endobj 6010 0 obj<>endobj 6011 0 obj<>endobj 6012 0 obj<>endobj 6013 0 obj<>endobj 6014 0 obj<>endobj 6015 0 obj<>endobj 6016 0 obj<>endobj 6017 0 obj<>endobj 6018 0 obj<>endobj 6019 0 obj<>endobj 6020 0 obj<>endobj 6021 0 obj<>endobj 6022 0 obj<>endobj 6023 0 obj<>endobj 6024 0 obj<>endobj 6025 0 obj<>endobj 6026 0 obj<>endobj 6027 0 obj<>endobj 6028 0 obj<>endobj 6029 0 obj<>endobj 6030 0 obj<>endobj 6031 0 obj<>endobj 6032 0 obj<>endobj 6033 0 obj<>endobj 6034 0 obj<>endobj 6035 0 obj<>endobj 6036 0 obj<>endobj 6037 0 obj<>endobj 6038 0 obj<>endobj 6039 0 obj<>endobj 6040 0 obj<>endobj 6041 0 obj<>endobj 6042 0 obj<>endobj 6043 0 obj<>endobj 6044 0 obj<>endobj 6045 0 obj<>endobj 6046 0 obj<>endobj 6047 0 obj<>endobj 6048 0 obj<>endobj 6049 0 obj<>endobj 6050 0 obj<>endobj 6051 0 obj<>endobj 6052 0 obj<>endobj 6053 0 obj<>endobj 6054 0 obj<>endobj 6055 0 obj<>endobj 6056 0 obj<>endobj 6057 0 obj<>endobj 6058 0 obj<>endobj 6059 0 obj<>endobj 6060 0 obj<>endobj 6061 0 obj<>endobj 6062 0 obj<>endobj 6063 0 obj<>endobj 6064 0 obj<>endobj 6065 0 obj<>endobj 6066 0 obj<>endobj 6067 0 obj<>endobj 6068 0 obj<>endobj 6069 0 obj<>endobj 6070 0 obj<>endobj 6071 0 obj<>endobj 6072 0 obj<>endobj 6073 0 obj<>endobj 6074 0 obj<>endobj 6075 0 obj<>endobj 6076 0 obj<>endobj 6077 0 obj<>endobj 6078 0 obj<>endobj 6079 0 obj<>endobj 6080 0 obj<>endobj 6081 0 obj<>endobj 6082 0 obj<>endobj 6083 0 obj<>endobj 6084 0 obj<>endobj 6085 0 obj<>endobj 6086 0 obj<>endobj 6087 0 obj<>endobj 6088 0 obj<>endobj 6089 0 obj<>endobj 6090 0 obj<>endobj 6091 0 obj<>endobj 6092 0 obj<>endobj 6093 0 obj<>endobj 6094 0 obj<>endobj 6095 0 obj<>endobj 6096 0 obj<>endobj 6097 0 obj<>endobj 6098 0 obj<>endobj 6099 0 obj<>endobj 6100 0 obj<>endobj 6101 0 obj<>endobj 6102 0 obj<>endobj 6103 0 obj<>endobj 6104 0 obj<>endobj 6105 0 obj<>endobj 6106 0 obj<>endobj 6107 0 obj<>endobj 6108 0 obj<>endobj 6109 0 obj<>endobj 6110 0 obj<>endobj 6111 0 obj<>endobj 6112 0 obj<>endobj 6113 0 obj<>endobj 6114 0 obj<>endobj 6115 0 obj<>endobj 6116 0 obj<>endobj 6117 0 obj<>endobj 6118 0 obj<>endobj 6119 0 obj<>endobj 6120 0 obj<>endobj 6121 0 obj<>endobj 6122 0 obj<>endobj 6123 0 obj<>endobj 6124 0 obj<>endobj 6125 0 obj<>endobj 6126 0 obj<>endobj 6127 0 obj<>endobj 6128 0 obj<>endobj 6129 0 obj<>endobj 6130 0 obj<>endobj 6131 0 obj<>endobj 6132 0 obj<>endobj 6133 0 obj<>endobj 6134 0 obj<>endobj 6135 0 obj<>endobj 6136 0 obj<>endobj 6137 0 obj<>endobj 6138 0 obj<>endobj 6139 0 obj<>endobj 6140 0 obj<>endobj 6141 0 obj<>endobj 6142 0 obj<>endobj 6143 0 obj<>endobj 6144 0 obj<>endobj 6145 0 obj<>endobj 6146 0 obj<>endobj 6147 0 obj<>endobj 6148 0 obj<>endobj 6149 0 obj<>endobj 6150 0 obj<>endobj 6151 0 obj<>endobj 6152 0 obj<>endobj 6153 0 obj<>endobj 6154 0 obj<>endobj 6155 0 obj<>endobj 6156 0 obj<>endobj 6157 0 obj<>endobj 6158 0 obj<>endobj 6159 0 obj<>endobj 6160 0 obj<>endobj 6161 0 obj<>endobj 6162 0 obj<>endobj 6163 0 obj<>endobj 6164 0 obj<>endobj 6165 0 obj<>endobj 6166 0 obj<>endobj 6167 0 obj<>endobj 6168 0 obj<>endobj 6169 0 obj<>endobj 6170 0 obj<>endobj 6171 0 obj<>endobj 6172 0 obj<>endobj 6173 0 obj<>endobj 6174 0 obj<>endobj 6175 0 obj<>endobj 6176 0 obj<>endobj 6177 0 obj<>endobj 6178 0 obj<>endobj 6179 0 obj<>endobj 6180 0 obj<>endobj 6181 0 obj<>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< D name comparison)/Dest[4955 0 R/XYZ 0 550 0]/Next 6237 0 R>>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<>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<>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<>1<>23<>24<>29<>35<>40<>45<>80<>132<>137<>155<>161<>209<>222<>225<>236<>244<>248<>254<>279<>289<>317<>324<>332<>338<>348<>434<>444<>470<>477<>479<>490<>502<>532<>544<>547<>602<>604<>662<>695<>]>>>>endobj xref 0 6889 0000000000 65535 f 0000000015 00000 n 0000000189 00000 n 0000001541 00000 n 0000001615 00000 n 0000001694 00000 n 0000001776 00000 n 0000001862 00000 n 0000001940 00000 n 0000002017 00000 n 0000002096 00000 n 0000002173 00000 n 0000002255 00000 n 0000002340 00000 n 0000002399 00000 n 0000024099 00000 n 0000033994 00000 n 0000035287 00000 n 0000035389 00000 n 0000035491 00000 n 0000035593 00000 n 0000035695 00000 n 0000035797 00000 n 0000035898 00000 n 0000036000 00000 n 0000036102 00000 n 0000036204 00000 n 0000036306 00000 n 0000036408 00000 n 0000036510 00000 n 0000036612 00000 n 0000036714 00000 n 0000036816 00000 n 0000036918 00000 n 0000037020 00000 n 0000037122 00000 n 0000037224 00000 n 0000037326 00000 n 0000037428 00000 n 0000037530 00000 n 0000037632 00000 n 0000037733 00000 n 0000037835 00000 n 0000037937 00000 n 0000038039 00000 n 0000038141 00000 n 0000038243 00000 n 0000038345 00000 n 0000038447 00000 n 0000038549 00000 n 0000038651 00000 n 0000038753 00000 n 0000038855 00000 n 0000038957 00000 n 0000039059 00000 n 0000039161 00000 n 0000039263 00000 n 0000039365 00000 n 0000039467 00000 n 0000039569 00000 n 0000039672 00000 n 0000039775 00000 n 0000039878 00000 n 0000039981 00000 n 0000040084 00000 n 0000040186 00000 n 0000040287 00000 n 0000040387 00000 n 0000040487 00000 n 0000040860 00000 n 0000040962 00000 n 0000041064 00000 n 0000041167 00000 n 0000041270 00000 n 0000041373 00000 n 0000041475 00000 n 0000041577 00000 n 0000041679 00000 n 0000041781 00000 n 0000041883 00000 n 0000041985 00000 n 0000042087 00000 n 0000042189 00000 n 0000042291 00000 n 0000042393 00000 n 0000042495 00000 n 0000042597 00000 n 0000042699 00000 n 0000042801 00000 n 0000042902 00000 n 0000043004 00000 n 0000043106 00000 n 0000043208 00000 n 0000043310 00000 n 0000043412 00000 n 0000043514 00000 n 0000043616 00000 n 0000043718 00000 n 0000043820 00000 n 0000043922 00000 n 0000044024 00000 n 0000044127 00000 n 0000044230 00000 n 0000044333 00000 n 0000044436 00000 n 0000044539 00000 n 0000044642 00000 n 0000044745 00000 n 0000044848 00000 n 0000044951 00000 n 0000045054 00000 n 0000045157 00000 n 0000045260 00000 n 0000045363 00000 n 0000045466 00000 n 0000045569 00000 n 0000045672 00000 n 0000045776 00000 n 0000045879 00000 n 0000045981 00000 n 0000046083 00000 n 0000046184 00000 n 0000046586 00000 n 0000046688 00000 n 0000046791 00000 n 0000046894 00000 n 0000046997 00000 n 0000047100 00000 n 0000047203 00000 n 0000047306 00000 n 0000047409 00000 n 0000047512 00000 n 0000047615 00000 n 0000047718 00000 n 0000047821 00000 n 0000047924 00000 n 0000048027 00000 n 0000048130 00000 n 0000048233 00000 n 0000048336 00000 n 0000048439 00000 n 0000048542 00000 n 0000048645 00000 n 0000048748 00000 n 0000048851 00000 n 0000048954 00000 n 0000049057 00000 n 0000049160 00000 n 0000049263 00000 n 0000049366 00000 n 0000049469 00000 n 0000049572 00000 n 0000049675 00000 n 0000049778 00000 n 0000049881 00000 n 0000049984 00000 n 0000050087 00000 n 0000050190 00000 n 0000050293 00000 n 0000050396 00000 n 0000050499 00000 n 0000050602 00000 n 0000050705 00000 n 0000050808 00000 n 0000050911 00000 n 0000051014 00000 n 0000051117 00000 n 0000051220 00000 n 0000051323 00000 n 0000051426 00000 n 0000051529 00000 n 0000051632 00000 n 0000051734 00000 n 0000051835 00000 n 0000051936 00000 n 0000052037 00000 n 0000052478 00000 n 0000052581 00000 n 0000052684 00000 n 0000052787 00000 n 0000052890 00000 n 0000052993 00000 n 0000053096 00000 n 0000053199 00000 n 0000053302 00000 n 0000053405 00000 n 0000053508 00000 n 0000053611 00000 n 0000053714 00000 n 0000053817 00000 n 0000053920 00000 n 0000054023 00000 n 0000054126 00000 n 0000054229 00000 n 0000054332 00000 n 0000054435 00000 n 0000054538 00000 n 0000054641 00000 n 0000054744 00000 n 0000054847 00000 n 0000054950 00000 n 0000055053 00000 n 0000055156 00000 n 0000055259 00000 n 0000055362 00000 n 0000055465 00000 n 0000055568 00000 n 0000055671 00000 n 0000055774 00000 n 0000055877 00000 n 0000055980 00000 n 0000056083 00000 n 0000056186 00000 n 0000056289 00000 n 0000056392 00000 n 0000056495 00000 n 0000056598 00000 n 0000056701 00000 n 0000056804 00000 n 0000056907 00000 n 0000057010 00000 n 0000057113 00000 n 0000057216 00000 n 0000057319 00000 n 0000057421 00000 n 0000057522 00000 n 0000057623 00000 n 0000057724 00000 n 0000058149 00000 n 0000058252 00000 n 0000058355 00000 n 0000058458 00000 n 0000058561 00000 n 0000058664 00000 n 0000058767 00000 n 0000058870 00000 n 0000058973 00000 n 0000059075 00000 n 0000059178 00000 n 0000059281 00000 n 0000059384 00000 n 0000059487 00000 n 0000059590 00000 n 0000059693 00000 n 0000059796 00000 n 0000059899 00000 n 0000060002 00000 n 0000060105 00000 n 0000060208 00000 n 0000060311 00000 n 0000060414 00000 n 0000060517 00000 n 0000060620 00000 n 0000060723 00000 n 0000060826 00000 n 0000060929 00000 n 0000061032 00000 n 0000061135 00000 n 0000061238 00000 n 0000061341 00000 n 0000061444 00000 n 0000061547 00000 n 0000061650 00000 n 0000061753 00000 n 0000061856 00000 n 0000061960 00000 n 0000062064 00000 n 0000062167 00000 n 0000062270 00000 n 0000062373 00000 n 0000062476 00000 n 0000062579 00000 n 0000062682 00000 n 0000062785 00000 n 0000062888 00000 n 0000062991 00000 n 0000063094 00000 n 0000063197 00000 n 0000063299 00000 n 0000063400 00000 n 0000063501 00000 n 0000063602 00000 n 0000064043 00000 n 0000064145 00000 n 0000064248 00000 n 0000064351 00000 n 0000064454 00000 n 0000064557 00000 n 0000064660 00000 n 0000064763 00000 n 0000064866 00000 n 0000064969 00000 n 0000065072 00000 n 0000065175 00000 n 0000065278 00000 n 0000065381 00000 n 0000065484 00000 n 0000065587 00000 n 0000065690 00000 n 0000065793 00000 n 0000065896 00000 n 0000065999 00000 n 0000066102 00000 n 0000066205 00000 n 0000066308 00000 n 0000066411 00000 n 0000066514 00000 n 0000066617 00000 n 0000066720 00000 n 0000066823 00000 n 0000066926 00000 n 0000067029 00000 n 0000067132 00000 n 0000067235 00000 n 0000067338 00000 n 0000067441 00000 n 0000067544 00000 n 0000067646 00000 n 0000067749 00000 n 0000067852 00000 n 0000067955 00000 n 0000068058 00000 n 0000068161 00000 n 0000068264 00000 n 0000068367 00000 n 0000068470 00000 n 0000068573 00000 n 0000068676 00000 n 0000068779 00000 n 0000068882 00000 n 0000068984 00000 n 0000069085 00000 n 0000069494 00000 n 0000069597 00000 n 0000069700 00000 n 0000069803 00000 n 0000069906 00000 n 0000070009 00000 n 0000070112 00000 n 0000070215 00000 n 0000070318 00000 n 0000070421 00000 n 0000070524 00000 n 0000070627 00000 n 0000070730 00000 n 0000070833 00000 n 0000070936 00000 n 0000071039 00000 n 0000071142 00000 n 0000071245 00000 n 0000071348 00000 n 0000071451 00000 n 0000071554 00000 n 0000071657 00000 n 0000071760 00000 n 0000071863 00000 n 0000071966 00000 n 0000072069 00000 n 0000072172 00000 n 0000072275 00000 n 0000072378 00000 n 0000072481 00000 n 0000072584 00000 n 0000072687 00000 n 0000072790 00000 n 0000072893 00000 n 0000072996 00000 n 0000073099 00000 n 0000073202 00000 n 0000073305 00000 n 0000073408 00000 n 0000073511 00000 n 0000073614 00000 n 0000073717 00000 n 0000073820 00000 n 0000073923 00000 n 0000074026 00000 n 0000074129 00000 n 0000074232 00000 n 0000074335 00000 n 0000074437 00000 n 0000074538 00000 n 0000074639 00000 n 0000074740 00000 n 0000075165 00000 n 0000075268 00000 n 0000075371 00000 n 0000075474 00000 n 0000075577 00000 n 0000075680 00000 n 0000075783 00000 n 0000075886 00000 n 0000075989 00000 n 0000076092 00000 n 0000076195 00000 n 0000076298 00000 n 0000076401 00000 n 0000076504 00000 n 0000076607 00000 n 0000076711 00000 n 0000076815 00000 n 0000076919 00000 n 0000077023 00000 n 0000077126 00000 n 0000077230 00000 n 0000077334 00000 n 0000077437 00000 n 0000077541 00000 n 0000077644 00000 n 0000077747 00000 n 0000077850 00000 n 0000077953 00000 n 0000078056 00000 n 0000078159 00000 n 0000078262 00000 n 0000078366 00000 n 0000078470 00000 n 0000078574 00000 n 0000078677 00000 n 0000078781 00000 n 0000078885 00000 n 0000078989 00000 n 0000079093 00000 n 0000079197 00000 n 0000079300 00000 n 0000079403 00000 n 0000079506 00000 n 0000079609 00000 n 0000079713 00000 n 0000079817 00000 n 0000079921 00000 n 0000080024 00000 n 0000080127 00000 n 0000080230 00000 n 0000080332 00000 n 0000080433 00000 n 0000080534 00000 n 0000080635 00000 n 0000081076 00000 n 0000081179 00000 n 0000081282 00000 n 0000081385 00000 n 0000081488 00000 n 0000081591 00000 n 0000081694 00000 n 0000081797 00000 n 0000081900 00000 n 0000082003 00000 n 0000082106 00000 n 0000082209 00000 n 0000082312 00000 n 0000082415 00000 n 0000082518 00000 n 0000082621 00000 n 0000082724 00000 n 0000082827 00000 n 0000082930 00000 n 0000083033 00000 n 0000083136 00000 n 0000083239 00000 n 0000083342 00000 n 0000083445 00000 n 0000083548 00000 n 0000083651 00000 n 0000083754 00000 n 0000083857 00000 n 0000083960 00000 n 0000084063 00000 n 0000084166 00000 n 0000084269 00000 n 0000084372 00000 n 0000084475 00000 n 0000084578 00000 n 0000084681 00000 n 0000084784 00000 n 0000084887 00000 n 0000084990 00000 n 0000085093 00000 n 0000085196 00000 n 0000085299 00000 n 0000085402 00000 n 0000085505 00000 n 0000085608 00000 n 0000085711 00000 n 0000085814 00000 n 0000085917 00000 n 0000086020 00000 n 0000086122 00000 n 0000086223 00000 n 0000086324 00000 n 0000086749 00000 n 0000086852 00000 n 0000086955 00000 n 0000087058 00000 n 0000087161 00000 n 0000087264 00000 n 0000087367 00000 n 0000087470 00000 n 0000087573 00000 n 0000087676 00000 n 0000087779 00000 n 0000087882 00000 n 0000087985 00000 n 0000088088 00000 n 0000088191 00000 n 0000088294 00000 n 0000088397 00000 n 0000088500 00000 n 0000088603 00000 n 0000088706 00000 n 0000088809 00000 n 0000088912 00000 n 0000089015 00000 n 0000089118 00000 n 0000089221 00000 n 0000089324 00000 n 0000089427 00000 n 0000089530 00000 n 0000089633 00000 n 0000089736 00000 n 0000089839 00000 n 0000089942 00000 n 0000090045 00000 n 0000090148 00000 n 0000090252 00000 n 0000090355 00000 n 0000090458 00000 n 0000090561 00000 n 0000090664 00000 n 0000090767 00000 n 0000090870 00000 n 0000090973 00000 n 0000091076 00000 n 0000091179 00000 n 0000091282 00000 n 0000091385 00000 n 0000091488 00000 n 0000091591 00000 n 0000091694 00000 n 0000091796 00000 n 0000091897 00000 n 0000091998 00000 n 0000092099 00000 n 0000092532 00000 n 0000092635 00000 n 0000092738 00000 n 0000092841 00000 n 0000092944 00000 n 0000093047 00000 n 0000093150 00000 n 0000093253 00000 n 0000093356 00000 n 0000093459 00000 n 0000093562 00000 n 0000093665 00000 n 0000093768 00000 n 0000093871 00000 n 0000093974 00000 n 0000094077 00000 n 0000094180 00000 n 0000094283 00000 n 0000094386 00000 n 0000094489 00000 n 0000094592 00000 n 0000094696 00000 n 0000094800 00000 n 0000094903 00000 n 0000095006 00000 n 0000095109 00000 n 0000095212 00000 n 0000095315 00000 n 0000095418 00000 n 0000095522 00000 n 0000095626 00000 n 0000095730 00000 n 0000095834 00000 n 0000095938 00000 n 0000096041 00000 n 0000096144 00000 n 0000096247 00000 n 0000096350 00000 n 0000096453 00000 n 0000096557 00000 n 0000096660 00000 n 0000096763 00000 n 0000096866 00000 n 0000096969 00000 n 0000097072 00000 n 0000097175 00000 n 0000097278 00000 n 0000097382 00000 n 0000097485 00000 n 0000097589 00000 n 0000097691 00000 n 0000097793 00000 n 0000097895 00000 n 0000097997 00000 n 0000098438 00000 n 0000098541 00000 n 0000098645 00000 n 0000098749 00000 n 0000098852 00000 n 0000098955 00000 n 0000099059 00000 n 0000099163 00000 n 0000099267 00000 n 0000099370 00000 n 0000099473 00000 n 0000099576 00000 n 0000099679 00000 n 0000099782 00000 n 0000099885 00000 n 0000099988 00000 n 0000100091 00000 n 0000100194 00000 n 0000100297 00000 n 0000100400 00000 n 0000100503 00000 n 0000100606 00000 n 0000100709 00000 n 0000100812 00000 n 0000100915 00000 n 0000101018 00000 n 0000101121 00000 n 0000101224 00000 n 0000101327 00000 n 0000101430 00000 n 0000101533 00000 n 0000101636 00000 n 0000101739 00000 n 0000101842 00000 n 0000101945 00000 n 0000102048 00000 n 0000102151 00000 n 0000102254 00000 n 0000102357 00000 n 0000102460 00000 n 0000102563 00000 n 0000102666 00000 n 0000102769 00000 n 0000102872 00000 n 0000102975 00000 n 0000103078 00000 n 0000103181 00000 n 0000103284 00000 n 0000103387 00000 n 0000103490 00000 n 0000103593 00000 n 0000103695 00000 n 0000103796 00000 n 0000103897 00000 n 0000103998 00000 n 0000104447 00000 n 0000104550 00000 n 0000104653 00000 n 0000104756 00000 n 0000104859 00000 n 0000104962 00000 n 0000105065 00000 n 0000105168 00000 n 0000105271 00000 n 0000105374 00000 n 0000105477 00000 n 0000105580 00000 n 0000105683 00000 n 0000105786 00000 n 0000105889 00000 n 0000105992 00000 n 0000106095 00000 n 0000106198 00000 n 0000106301 00000 n 0000106404 00000 n 0000106507 00000 n 0000106610 00000 n 0000106713 00000 n 0000106816 00000 n 0000106919 00000 n 0000107022 00000 n 0000107125 00000 n 0000107228 00000 n 0000107331 00000 n 0000107434 00000 n 0000107537 00000 n 0000107640 00000 n 0000107743 00000 n 0000107846 00000 n 0000107949 00000 n 0000108052 00000 n 0000108155 00000 n 0000108258 00000 n 0000108361 00000 n 0000108464 00000 n 0000108567 00000 n 0000108670 00000 n 0000108773 00000 n 0000108876 00000 n 0000108979 00000 n 0000109082 00000 n 0000109185 00000 n 0000109288 00000 n 0000109391 00000 n 0000109493 00000 n 0000109594 00000 n 0000109695 00000 n 0000109796 00000 n 0000110229 00000 n 0000110332 00000 n 0000110435 00000 n 0000110538 00000 n 0000110641 00000 n 0000110744 00000 n 0000110847 00000 n 0000110950 00000 n 0000111053 00000 n 0000111156 00000 n 0000111259 00000 n 0000111362 00000 n 0000111465 00000 n 0000111568 00000 n 0000111671 00000 n 0000111774 00000 n 0000111877 00000 n 0000111980 00000 n 0000112083 00000 n 0000112186 00000 n 0000112289 00000 n 0000112392 00000 n 0000112495 00000 n 0000112598 00000 n 0000112701 00000 n 0000112804 00000 n 0000112907 00000 n 0000113010 00000 n 0000113113 00000 n 0000113216 00000 n 0000113319 00000 n 0000113422 00000 n 0000113525 00000 n 0000113628 00000 n 0000113731 00000 n 0000113834 00000 n 0000113937 00000 n 0000114040 00000 n 0000114143 00000 n 0000114246 00000 n 0000114349 00000 n 0000114452 00000 n 0000114556 00000 n 0000114659 00000 n 0000114763 00000 n 0000114867 00000 n 0000114971 00000 n 0000115075 00000 n 0000115177 00000 n 0000115279 00000 n 0000115381 00000 n 0000115483 00000 n 0000115908 00000 n 0000116011 00000 n 0000116115 00000 n 0000116218 00000 n 0000116322 00000 n 0000116426 00000 n 0000116530 00000 n 0000116634 00000 n 0000116738 00000 n 0000116842 00000 n 0000116946 00000 n 0000117050 00000 n 0000117153 00000 n 0000117256 00000 n 0000117359 00000 n 0000117462 00000 n 0000117565 00000 n 0000117668 00000 n 0000117771 00000 n 0000117874 00000 n 0000117977 00000 n 0000118080 00000 n 0000118183 00000 n 0000118286 00000 n 0000118389 00000 n 0000118492 00000 n 0000118595 00000 n 0000118698 00000 n 0000118801 00000 n 0000118904 00000 n 0000119007 00000 n 0000119110 00000 n 0000119213 00000 n 0000119316 00000 n 0000119419 00000 n 0000119522 00000 n 0000119625 00000 n 0000119728 00000 n 0000119831 00000 n 0000119934 00000 n 0000120037 00000 n 0000120140 00000 n 0000120243 00000 n 0000120346 00000 n 0000120449 00000 n 0000120552 00000 n 0000120655 00000 n 0000120758 00000 n 0000120861 00000 n 0000120963 00000 n 0000121064 00000 n 0000121165 00000 n 0000121266 00000 n 0000121699 00000 n 0000121802 00000 n 0000121905 00000 n 0000122008 00000 n 0000122111 00000 n 0000122214 00000 n 0000122317 00000 n 0000122420 00000 n 0000122523 00000 n 0000122626 00000 n 0000122729 00000 n 0000122832 00000 n 0000122935 00000 n 0000123038 00000 n 0000123141 00000 n 0000123244 00000 n 0000123347 00000 n 0000123450 00000 n 0000123553 00000 n 0000123656 00000 n 0000123759 00000 n 0000123862 00000 n 0000123965 00000 n 0000124068 00000 n 0000124171 00000 n 0000124274 00000 n 0000124377 00000 n 0000124480 00000 n 0000124583 00000 n 0000124686 00000 n 0000124789 00000 n 0000124892 00000 n 0000124995 00000 n 0000125098 00000 n 0000125201 00000 n 0000125304 00000 n 0000125407 00000 n 0000125510 00000 n 0000125613 00000 n 0000125716 00000 n 0000125819 00000 n 0000125922 00000 n 0000126025 00000 n 0000126128 00000 n 0000126232 00000 n 0000126336 00000 n 0000126440 00000 n 0000126544 00000 n 0000126647 00000 n 0000126750 00000 n 0000126852 00000 n 0000126953 00000 n 0000127054 00000 n 0000127155 00000 n 0000127596 00000 n 0000127699 00000 n 0000127802 00000 n 0000127905 00000 n 0000128008 00000 n 0000128111 00000 n 0000128214 00000 n 0000128317 00000 n 0000128420 00000 n 0000128523 00000 n 0000128626 00000 n 0000128729 00000 n 0000128832 00000 n 0000128935 00000 n 0000129038 00000 n 0000129141 00000 n 0000129244 00000 n 0000129347 00000 n 0000129450 00000 n 0000129553 00000 n 0000129656 00000 n 0000129759 00000 n 0000129862 00000 n 0000129965 00000 n 0000130068 00000 n 0000130171 00000 n 0000130274 00000 n 0000130377 00000 n 0000130480 00000 n 0000130583 00000 n 0000130686 00000 n 0000130789 00000 n 0000130892 00000 n 0000130995 00000 n 0000131098 00000 n 0000131201 00000 n 0000131304 00000 n 0000131407 00000 n 0000131510 00000 n 0000131613 00000 n 0000131716 00000 n 0000131819 00000 n 0000131922 00000 n 0000132025 00000 n 0000132128 00000 n 0000132231 00000 n 0000132334 00000 n 0000132438 00000 n 0000132542 00000 n 0000132644 00000 n 0000132745 00000 n 0000132846 00000 n 0000132947 00000 n 0000133380 00000 n 0000133483 00000 n 0000133586 00000 n 0000133689 00000 n 0000133792 00000 n 0000133895 00000 n 0000133998 00000 n 0000134101 00000 n 0000134204 00000 n 0000134307 00000 n 0000134410 00000 n 0000134513 00000 n 0000134616 00000 n 0000134719 00000 n 0000134822 00000 n 0000134925 00000 n 0000135028 00000 n 0000135131 00000 n 0000135234 00000 n 0000135337 00000 n 0000135440 00000 n 0000135543 00000 n 0000135646 00000 n 0000135749 00000 n 0000135852 00000 n 0000135955 00000 n 0000136058 00000 n 0000136161 00000 n 0000136264 00000 n 0000136367 00000 n 0000136470 00000 n 0000136573 00000 n 0000136676 00000 n 0000136780 00000 n 0000136884 00000 n 0000136988 00000 n 0000137092 00000 n 0000137196 00000 n 0000137299 00000 n 0000137402 00000 n 0000137505 00000 n 0000137608 00000 n 0000137711 00000 n 0000137814 00000 n 0000137917 00000 n 0000138020 00000 n 0000138123 00000 n 0000138226 00000 n 0000138329 00000 n 0000138432 00000 n 0000138534 00000 n 0000138635 00000 n 0000139060 00000 n 0000139163 00000 n 0000139266 00000 n 0000139369 00000 n 0000139472 00000 n 0000139575 00000 n 0000139678 00000 n 0000139781 00000 n 0000139884 00000 n 0000139987 00000 n 0000140090 00000 n 0000140193 00000 n 0000140296 00000 n 0000140399 00000 n 0000140502 00000 n 0000140605 00000 n 0000140708 00000 n 0000140811 00000 n 0000140914 00000 n 0000141017 00000 n 0000141120 00000 n 0000141223 00000 n 0000141326 00000 n 0000141429 00000 n 0000141532 00000 n 0000141635 00000 n 0000141738 00000 n 0000141841 00000 n 0000141944 00000 n 0000142048 00000 n 0000142151 00000 n 0000142254 00000 n 0000142358 00000 n 0000142462 00000 n 0000142566 00000 n 0000142670 00000 n 0000142774 00000 n 0000142878 00000 n 0000142982 00000 n 0000143086 00000 n 0000143190 00000 n 0000143294 00000 n 0000143398 00000 n 0000143502 00000 n 0000143606 00000 n 0000143710 00000 n 0000143814 00000 n 0000143918 00000 n 0000144023 00000 n 0000144128 00000 n 0000144233 00000 n 0000144337 00000 n 0000144440 00000 n 0000144543 00000 n 0000144646 00000 n 0000145119 00000 n 0000145223 00000 n 0000145328 00000 n 0000145433 00000 n 0000145538 00000 n 0000145643 00000 n 0000145748 00000 n 0000145853 00000 n 0000145958 00000 n 0000146063 00000 n 0000146168 00000 n 0000146273 00000 n 0000146378 00000 n 0000146482 00000 n 0000146586 00000 n 0000146691 00000 n 0000146796 00000 n 0000146901 00000 n 0000147006 00000 n 0000147111 00000 n 0000147215 00000 n 0000147319 00000 n 0000147423 00000 n 0000147527 00000 n 0000147632 00000 n 0000147736 00000 n 0000147840 00000 n 0000147944 00000 n 0000148048 00000 n 0000148153 00000 n 0000148258 00000 n 0000148363 00000 n 0000148468 00000 n 0000148573 00000 n 0000148677 00000 n 0000148781 00000 n 0000148885 00000 n 0000148989 00000 n 0000149093 00000 n 0000149197 00000 n 0000149301 00000 n 0000149405 00000 n 0000149509 00000 n 0000149613 00000 n 0000149717 00000 n 0000149821 00000 n 0000149925 00000 n 0000150029 00000 n 0000150133 00000 n 0000150237 00000 n 0000150340 00000 n 0000150442 00000 n 0000150544 00000 n 0000150646 00000 n 0000151141 00000 n 0000151245 00000 n 0000151349 00000 n 0000151453 00000 n 0000151557 00000 n 0000151661 00000 n 0000151765 00000 n 0000151869 00000 n 0000151973 00000 n 0000152077 00000 n 0000152181 00000 n 0000152285 00000 n 0000152389 00000 n 0000152493 00000 n 0000152597 00000 n 0000152701 00000 n 0000152805 00000 n 0000152909 00000 n 0000153013 00000 n 0000153117 00000 n 0000153221 00000 n 0000153325 00000 n 0000153429 00000 n 0000153533 00000 n 0000153637 00000 n 0000153741 00000 n 0000153845 00000 n 0000153949 00000 n 0000154053 00000 n 0000154157 00000 n 0000154261 00000 n 0000154365 00000 n 0000154469 00000 n 0000154573 00000 n 0000154677 00000 n 0000154781 00000 n 0000154885 00000 n 0000154989 00000 n 0000155093 00000 n 0000155197 00000 n 0000155301 00000 n 0000155405 00000 n 0000155509 00000 n 0000155613 00000 n 0000155717 00000 n 0000155821 00000 n 0000155925 00000 n 0000156029 00000 n 0000156133 00000 n 0000156237 00000 n 0000156340 00000 n 0000156442 00000 n 0000156544 00000 n 0000156646 00000 n 0000157141 00000 n 0000157245 00000 n 0000157349 00000 n 0000157453 00000 n 0000157557 00000 n 0000157661 00000 n 0000157765 00000 n 0000157869 00000 n 0000157973 00000 n 0000158077 00000 n 0000158181 00000 n 0000158285 00000 n 0000158389 00000 n 0000158493 00000 n 0000158597 00000 n 0000158701 00000 n 0000158805 00000 n 0000158909 00000 n 0000159013 00000 n 0000159117 00000 n 0000159221 00000 n 0000159325 00000 n 0000159429 00000 n 0000159533 00000 n 0000159637 00000 n 0000159741 00000 n 0000159845 00000 n 0000159949 00000 n 0000160053 00000 n 0000160157 00000 n 0000160261 00000 n 0000160366 00000 n 0000160470 00000 n 0000160574 00000 n 0000160678 00000 n 0000160782 00000 n 0000160886 00000 n 0000160990 00000 n 0000161341 00000 n 0000161445 00000 n 0000161549 00000 n 0000161653 00000 n 0000161757 00000 n 0000161861 00000 n 0000161965 00000 n 0000162069 00000 n 0000162173 00000 n 0000162277 00000 n 0000162381 00000 n 0000162485 00000 n 0000162589 00000 n 0000162693 00000 n 0000162797 00000 n 0000162901 00000 n 0000163005 00000 n 0000163109 00000 n 0000163213 00000 n 0000163317 00000 n 0000163421 00000 n 0000163525 00000 n 0000163629 00000 n 0000163733 00000 n 0000163837 00000 n 0000163941 00000 n 0000164045 00000 n 0000164149 00000 n 0000164253 00000 n 0000164357 00000 n 0000164461 00000 n 0000164565 00000 n 0000164669 00000 n 0000164773 00000 n 0000164877 00000 n 0000164981 00000 n 0000165085 00000 n 0000165189 00000 n 0000165292 00000 n 0000165652 00000 n 0000165756 00000 n 0000165860 00000 n 0000165964 00000 n 0000166068 00000 n 0000166172 00000 n 0000166276 00000 n 0000166380 00000 n 0000166484 00000 n 0000166588 00000 n 0000166692 00000 n 0000166796 00000 n 0000166900 00000 n 0000167005 00000 n 0000167110 00000 n 0000167215 00000 n 0000167320 00000 n 0000167425 00000 n 0000167488 00000 n 0000167577 00000 n 0000167629 00000 n 0000167715 00000 n 0000167904 00000 n 0000167966 00000 n 0000168054 00000 n 0000168115 00000 n 0000168203 00000 n 0000168308 00000 n 0000168353 00000 n 0000168417 00000 n 0000168506 00000 n 0000168568 00000 n 0000168657 00000 n 0000168719 00000 n 0000168807 00000 n 0000168912 00000 n 0000168978 00000 n 0000169066 00000 n 0000169119 00000 n 0000169206 00000 n 0000169278 00000 n 0000169383 00000 n 0000169444 00000 n 0000169533 00000 n 0000169658 00000 n 0000169746 00000 n 0000169791 00000 n 0000169895 00000 n 0000169999 00000 n 0000170103 00000 n 0000170208 00000 n 0000170313 00000 n 0000170418 00000 n 0000170523 00000 n 0000170628 00000 n 0000170732 00000 n 0000170836 00000 n 0000170940 00000 n 0000171044 00000 n 0000171148 00000 n 0000171283 00000 n 0000171353 00000 n 0000171442 00000 n 0000171512 00000 n 0000171601 00000 n 0000171670 00000 n 0000171759 00000 n 0000171865 00000 n 0000171953 00000 n 0000172031 00000 n 0000172120 00000 n 0000172173 00000 n 0000172262 00000 n 0000172334 00000 n 0000172438 00000 n 0000172543 00000 n 0000172647 00000 n 0000172752 00000 n 0000172857 00000 n 0000172962 00000 n 0000173067 00000 n 0000173172 00000 n 0000173277 00000 n 0000173382 00000 n 0000173487 00000 n 0000173592 00000 n 0000173696 00000 n 0000173801 00000 n 0000173906 00000 n 0000174011 00000 n 0000174116 00000 n 0000174221 00000 n 0000174325 00000 n 0000174377 00000 n 0000174466 00000 n 0000174571 00000 n 0000174676 00000 n 0000174781 00000 n 0000175006 00000 n 0000175060 00000 n 0000175149 00000 n 0000175202 00000 n 0000175291 00000 n 0000175344 00000 n 0000175433 00000 n 0000175494 00000 n 0000175583 00000 n 0000175651 00000 n 0000175740 00000 n 0000175817 00000 n 0000175906 00000 n 0000175978 00000 n 0000176039 00000 n 0000176128 00000 n 0000176208 00000 n 0000176297 00000 n 0000176349 00000 n 0000176438 00000 n 0000176483 00000 n 0000176587 00000 n 0000176691 00000 n 0000176796 00000 n 0000176901 00000 n 0000177006 00000 n 0000177111 00000 n 0000177216 00000 n 0000177320 00000 n 0000177425 00000 n 0000177530 00000 n 0000177635 00000 n 0000177752 00000 n 0000177856 00000 n 0000177961 00000 n 0000178066 00000 n 0000178171 00000 n 0000178276 00000 n 0000178381 00000 n 0000178486 00000 n 0000178590 00000 n 0000178695 00000 n 0000178800 00000 n 0000178905 00000 n 0000179010 00000 n 0000179115 00000 n 0000179220 00000 n 0000179325 00000 n 0000179429 00000 n 0000179534 00000 n 0000179639 00000 n 0000179744 00000 n 0000179849 00000 n 0000179954 00000 n 0000180058 00000 n 0000180163 00000 n 0000180268 00000 n 0000180373 00000 n 0000180478 00000 n 0000180583 00000 n 0000180688 00000 n 0000180793 00000 n 0000180898 00000 n 0000181003 00000 n 0000181108 00000 n 0000181213 00000 n 0000181318 00000 n 0000181423 00000 n 0000181528 00000 n 0000181632 00000 n 0000181737 00000 n 0000181842 00000 n 0000181947 00000 n 0000182052 00000 n 0000182157 00000 n 0000182262 00000 n 0000182367 00000 n 0000182472 00000 n 0000182576 00000 n 0000182681 00000 n 0000182786 00000 n 0000182891 00000 n 0000182996 00000 n 0000183100 00000 n 0000183205 00000 n 0000183310 00000 n 0000183414 00000 n 0000183517 00000 n 0000183620 00000 n 0000184142 00000 n 0000184247 00000 n 0000184274 00000 n 0000184379 00000 n 0000184406 00000 n 0000184511 00000 n 0000184538 00000 n 0000184643 00000 n 0000184670 00000 n 0000184775 00000 n 0000184880 00000 n 0000184916 00000 n 0000185021 00000 n 0000185048 00000 n 0000185101 00000 n 0000185190 00000 n 0000185243 00000 n 0000185332 00000 n 0000185368 00000 n 0000185473 00000 n 0000185500 00000 n 0000185605 00000 n 0000185632 00000 n 0000185737 00000 n 0000185840 00000 n 0000185876 00000 n 0000185981 00000 n 0000186008 00000 n 0000186113 00000 n 0000186140 00000 n 0000186202 00000 n 0000186291 00000 n 0000186353 00000 n 0000186442 00000 n 0000186478 00000 n 0000186582 00000 n 0000186686 00000 n 0000186790 00000 n 0000186894 00000 n 0000186998 00000 n 0000187103 00000 n 0000187208 00000 n 0000187313 00000 n 0000187417 00000 n 0000187522 00000 n 0000187627 00000 n 0000187732 00000 n 0000187837 00000 n 0000187942 00000 n 0000188047 00000 n 0000188152 00000 n 0000188256 00000 n 0000188360 00000 n 0000188464 00000 n 0000188568 00000 n 0000188672 00000 n 0000188776 00000 n 0000188880 00000 n 0000188984 00000 n 0000189088 00000 n 0000189193 00000 n 0000189298 00000 n 0000189403 00000 n 0000189508 00000 n 0000189612 00000 n 0000189716 00000 n 0000189820 00000 n 0000189924 00000 n 0000190029 00000 n 0000190133 00000 n 0000190237 00000 n 0000190341 00000 n 0000190445 00000 n 0000190549 00000 n 0000190653 00000 n 0000190757 00000 n 0000190861 00000 n 0000190965 00000 n 0000191069 00000 n 0000191174 00000 n 0000191597 00000 n 0000191702 00000 n 0000191729 00000 n 0000191834 00000 n 0000191861 00000 n 0000191966 00000 n 0000191993 00000 n 0000192096 00000 n 0000192123 00000 n 0000192228 00000 n 0000192255 00000 n 0000192360 00000 n 0000192465 00000 n 0000192501 00000 n 0000192605 00000 n 0000192709 00000 n 0000192814 00000 n 0000192919 00000 n 0000193024 00000 n 0000193087 00000 n 0000193192 00000 n 0000193219 00000 n 0000193324 00000 n 0000193351 00000 n 0000193413 00000 n 0000193501 00000 n 0000193528 00000 n 0000193590 00000 n 0000193679 00000 n 0000193706 00000 n 0000193811 00000 n 0000193838 00000 n 0000193943 00000 n 0000194048 00000 n 0000194152 00000 n 0000194197 00000 n 0000194302 00000 n 0000194329 00000 n 0000194434 00000 n 0000194461 00000 n 0000194566 00000 n 0000194671 00000 n 0000194776 00000 n 0000194821 00000 n 0000194926 00000 n 0000195030 00000 n 0000195066 00000 n 0000195171 00000 n 0000195198 00000 n 0000195303 00000 n 0000195330 00000 n 0000195434 00000 n 0000195538 00000 n 0000195642 00000 n 0000195746 00000 n 0000195850 00000 n 0000195954 00000 n 0000196058 00000 n 0000196163 00000 n 0000196268 00000 n 0000196372 00000 n 0000196476 00000 n 0000196580 00000 n 0000196685 00000 n 0000196788 00000 n 0000196932 00000 n 0000197035 00000 n 0000197062 00000 n 0000197166 00000 n 0000197270 00000 n 0000197375 00000 n 0000197480 00000 n 0000197585 00000 n 0000197690 00000 n 0000197794 00000 n 0000197899 00000 n 0000198004 00000 n 0000198109 00000 n 0000198214 00000 n 0000198318 00000 n 0000198423 00000 n 0000198528 00000 n 0000198633 00000 n 0000198738 00000 n 0000198842 00000 n 0000198947 00000 n 0000199127 00000 n 0000199231 00000 n 0000199258 00000 n 0000199363 00000 n 0000199390 00000 n 0000199494 00000 n 0000199599 00000 n 0000199704 00000 n 0000199809 00000 n 0000199914 00000 n 0000200019 00000 n 0000200123 00000 n 0000200228 00000 n 0000200333 00000 n 0000200438 00000 n 0000200546 00000 n 0000200650 00000 n 0000200755 00000 n 0000200860 00000 n 0000200965 00000 n 0000201070 00000 n 0000201175 00000 n 0000201280 00000 n 0000201385 00000 n 0000201490 00000 n 0000201594 00000 n 0000201699 00000 n 0000201804 00000 n 0000201909 00000 n 0000202014 00000 n 0000202119 00000 n 0000202223 00000 n 0000202328 00000 n 0000202433 00000 n 0000202538 00000 n 0000202643 00000 n 0000202748 00000 n 0000202853 00000 n 0000202957 00000 n 0000203062 00000 n 0000203167 00000 n 0000203272 00000 n 0000203377 00000 n 0000203482 00000 n 0000203587 00000 n 0000203691 00000 n 0000203796 00000 n 0000203901 00000 n 0000204006 00000 n 0000204111 00000 n 0000204216 00000 n 0000204321 00000 n 0000204426 00000 n 0000204531 00000 n 0000204636 00000 n 0000204741 00000 n 0000204846 00000 n 0000204951 00000 n 0000205056 00000 n 0000205160 00000 n 0000205265 00000 n 0000205370 00000 n 0000205474 00000 n 0000205578 00000 n 0000205682 00000 n 0000205786 00000 n 0000205889 00000 n 0000205992 00000 n 0000206095 00000 n 0000206590 00000 n 0000206694 00000 n 0000206799 00000 n 0000206904 00000 n 0000207008 00000 n 0000207112 00000 n 0000207217 00000 n 0000207322 00000 n 0000207426 00000 n 0000207530 00000 n 0000207634 00000 n 0000207742 00000 n 0000207847 00000 n 0000207936 00000 n 0000208025 00000 n 0000208126 00000 n 0000208215 00000 n 0000208320 00000 n 0000208374 00000 n 0000208479 00000 n 0000208582 00000 n 0000208618 00000 n 0000208721 00000 n 0000208748 00000 n 0000208853 00000 n 0000208880 00000 n 0000208985 00000 n 0000209012 00000 n 0000209117 00000 n 0000209144 00000 n 0000209247 00000 n 0000209274 00000 n 0000209379 00000 n 0000209484 00000 n 0000209520 00000 n 0000209625 00000 n 0000209730 00000 n 0000209835 00000 n 0000209939 00000 n 0000209993 00000 n 0000210097 00000 n 0000210124 00000 n 0000210228 00000 n 0000210255 00000 n 0000210360 00000 n 0000210387 00000 n 0000210492 00000 n 0000210519 00000 n 0000210624 00000 n 0000210651 00000 n 0000210756 00000 n 0000210783 00000 n 0000210887 00000 n 0000210992 00000 n 0000211028 00000 n 0000211133 00000 n 0000211160 00000 n 0000211265 00000 n 0000211368 00000 n 0000211404 00000 n 0000211509 00000 n 0000211536 00000 n 0000211640 00000 n 0000211745 00000 n 0000211850 00000 n 0000211955 00000 n 0000212060 00000 n 0000212165 00000 n 0000212270 00000 n 0000212375 00000 n 0000212479 00000 n 0000212583 00000 n 0000212688 00000 n 0000212793 00000 n 0000212898 00000 n 0000213003 00000 n 0000213108 00000 n 0000213213 00000 n 0000213375 00000 n 0000213480 00000 n 0000213584 00000 n 0000213620 00000 n 0000213725 00000 n 0000213752 00000 n 0000213857 00000 n 0000213960 00000 n 0000213996 00000 n 0000214101 00000 n 0000214206 00000 n 0000214242 00000 n 0000214347 00000 n 0000214451 00000 n 0000214487 00000 n 0000214591 00000 n 0000214695 00000 n 0000214799 00000 n 0000214902 00000 n 0000214956 00000 n 0000215060 00000 n 0000215164 00000 n 0000215268 00000 n 0000215372 00000 n 0000215476 00000 n 0000215580 00000 n 0000215684 00000 n 0000215788 00000 n 0000215892 00000 n 0000215991 00000 n 0000216096 00000 n 0000216201 00000 n 0000216237 00000 n 0000216303 00000 n 0000216392 00000 n 0000216419 00000 n 0000216523 00000 n 0000216627 00000 n 0000216731 00000 n 0000216835 00000 n 0000216939 00000 n 0000217043 00000 n 0000217147 00000 n 0000217251 00000 n 0000217355 00000 n 0000217460 00000 n 0000217565 00000 n 0000217670 00000 n 0000217775 00000 n 0000217880 00000 n 0000217985 00000 n 0000218090 00000 n 0000218194 00000 n 0000218296 00000 n 0000218476 00000 n 0000218581 00000 n 0000218608 00000 n 0000218712 00000 n 0000218815 00000 n 0000218919 00000 n 0000219023 00000 n 0000219127 00000 n 0000219231 00000 n 0000219335 00000 n 0000219416 00000 n 0000219521 00000 n 0000219548 00000 n 0000219653 00000 n 0000219756 00000 n 0000219792 00000 n 0000219896 00000 n 0000220000 00000 n 0000220104 00000 n 0000220208 00000 n 0000220312 00000 n 0000220416 00000 n 0000220520 00000 n 0000220624 00000 n 0000220728 00000 n 0000220832 00000 n 0000220936 00000 n 0000221040 00000 n 0000221144 00000 n 0000221248 00000 n 0000221352 00000 n 0000221456 00000 n 0000221560 00000 n 0000221731 00000 n 0000221800 00000 n 0000221889 00000 n 0000221916 00000 n 0000221974 00000 n 0000222063 00000 n 0000222125 00000 n 0000222213 00000 n 0000222249 00000 n 0000222352 00000 n 0000222457 00000 n 0000222562 00000 n 0000222667 00000 n 0000222771 00000 n 0000222876 00000 n 0000222981 00000 n 0000223086 00000 n 0000223191 00000 n 0000223296 00000 n 0000223401 00000 n 0000223506 00000 n 0000223610 00000 n 0000223715 00000 n 0000223820 00000 n 0000223925 00000 n 0000224030 00000 n 0000224135 00000 n 0000224240 00000 n 0000224345 00000 n 0000224450 00000 n 0000224555 00000 n 0000224660 00000 n 0000224765 00000 n 0000224870 00000 n 0000224975 00000 n 0000225080 00000 n 0000225185 00000 n 0000225290 00000 n 0000225395 00000 n 0000225500 00000 n 0000225605 00000 n 0000225710 00000 n 0000225814 00000 n 0000225919 00000 n 0000226024 00000 n 0000226129 00000 n 0000226234 00000 n 0000226339 00000 n 0000226444 00000 n 0000226549 00000 n 0000226654 00000 n 0000226759 00000 n 0000226864 00000 n 0000226969 00000 n 0000227073 00000 n 0000227178 00000 n 0000227283 00000 n 0000227388 00000 n 0000227493 00000 n 0000227597 00000 n 0000227700 00000 n 0000227803 00000 n 0000228298 00000 n 0000228402 00000 n 0000228507 00000 n 0000228612 00000 n 0000228657 00000 n 0000228760 00000 n 0000228787 00000 n 0000228892 00000 n 0000228997 00000 n 0000229033 00000 n 0000229138 00000 n 0000229243 00000 n 0000229279 00000 n 0000229383 00000 n 0000229487 00000 n 0000229592 00000 n 0000229697 00000 n 0000229802 00000 n 0000229907 00000 n 0000230011 00000 n 0000230116 00000 n 0000230192 00000 n 0000230281 00000 n 0000230361 00000 n 0000230450 00000 n 0000230554 00000 n 0000230663 00000 n 0000230752 00000 n 0000230878 00000 n 0000230968 00000 n 0000231057 00000 n 0000231084 00000 n 0000231164 00000 n 0000231252 00000 n 0000231279 00000 n 0000231384 00000 n 0000231411 00000 n 0000231515 00000 n 0000231619 00000 n 0000231723 00000 n 0000231827 00000 n 0000231932 00000 n 0000232037 00000 n 0000232142 00000 n 0000232246 00000 n 0000232351 00000 n 0000232456 00000 n 0000232561 00000 n 0000232666 00000 n 0000232770 00000 n 0000232875 00000 n 0000232980 00000 n 0000233085 00000 n 0000233189 00000 n 0000233293 00000 n 0000233398 00000 n 0000233503 00000 n 0000233608 00000 n 0000233713 00000 n 0000233818 00000 n 0000233923 00000 n 0000234028 00000 n 0000234133 00000 n 0000234228 00000 n 0000234317 00000 n 0000234387 00000 n 0000234476 00000 n 0000234540 00000 n 0000234629 00000 n 0000234687 00000 n 0000234776 00000 n 0000234866 00000 n 0000234954 00000 n 0000235058 00000 n 0000235364 00000 n 0000235468 00000 n 0000235573 00000 n 0000235609 00000 n 0000235714 00000 n 0000235819 00000 n 0000235924 00000 n 0000236028 00000 n 0000236133 00000 n 0000236237 00000 n 0000236342 00000 n 0000236423 00000 n 0000236528 00000 n 0000236555 00000 n 0000236660 00000 n 0000236714 00000 n 0000236803 00000 n 0000236856 00000 n 0000236945 00000 n 0000236990 00000 n 0000237095 00000 n 0000237190 00000 n 0000237279 00000 n 0000237315 00000 n 0000237410 00000 n 0000237499 00000 n 0000237526 00000 n 0000237631 00000 n 0000237736 00000 n 0000237772 00000 n 0000237877 00000 n 0000237904 00000 n 0000238009 00000 n 0000238036 00000 n 0000238139 00000 n 0000238166 00000 n 0000238271 00000 n 0000238298 00000 n 0000238403 00000 n 0000238430 00000 n 0000238534 00000 n 0000238639 00000 n 0000238743 00000 n 0000238788 00000 n 0000238892 00000 n 0000238919 00000 n 0000239024 00000 n 0000239051 00000 n 0000239156 00000 n 0000239183 00000 n 0000239287 00000 n 0000239392 00000 n 0000239497 00000 n 0000239601 00000 n 0000239706 00000 n 0000239811 00000 n 0000239916 00000 n 0000240021 00000 n 0000240126 00000 n 0000240230 00000 n 0000240334 00000 n 0000240439 00000 n 0000240544 00000 n 0000240649 00000 n 0000240753 00000 n 0000240857 00000 n 0000240962 00000 n 0000241066 00000 n 0000241171 00000 n 0000241276 00000 n 0000241474 00000 n 0000241579 00000 n 0000241684 00000 n 0000241788 00000 n 0000241866 00000 n 0000241955 00000 n 0000242009 00000 n 0000242114 00000 n 0000242219 00000 n 0000242324 00000 n 0000242369 00000 n 0000242473 00000 n 0000242577 00000 n 0000242681 00000 n 0000242786 00000 n 0000242891 00000 n 0000242996 00000 n 0000243101 00000 n 0000243206 00000 n 0000243311 00000 n 0000243416 00000 n 0000243520 00000 n 0000243624 00000 n 0000243728 00000 n 0000243832 00000 n 0000243936 00000 n 0000244041 00000 n 0000244146 00000 n 0000244251 00000 n 0000244356 00000 n 0000244460 00000 n 0000244564 00000 n 0000244626 00000 n 0000244714 00000 n 0000244797 00000 n 0000244885 00000 n 0000244988 00000 n 0000245093 00000 n 0000245336 00000 n 0000245441 00000 n 0000245546 00000 n 0000245650 00000 n 0000245755 00000 n 0000245860 00000 n 0000245965 00000 n 0000246068 00000 n 0000246171 00000 n 0000246261 00000 n 0000246366 00000 n 0000246471 00000 n 0000246576 00000 n 0000246681 00000 n 0000246786 00000 n 0000246849 00000 n 0000246954 00000 n 0000247059 00000 n 0000247164 00000 n 0000247269 00000 n 0000247323 00000 n 0000247428 00000 n 0000247533 00000 n 0000247637 00000 n 0000247682 00000 n 0000247787 00000 n 0000247892 00000 n 0000247997 00000 n 0000248102 00000 n 0000248156 00000 n 0000248246 00000 n 0000248335 00000 n 0000248425 00000 n 0000248514 00000 n 0000248619 00000 n 0000248724 00000 n 0000248778 00000 n 0000248882 00000 n 0000248986 00000 n 0000249091 00000 n 0000249196 00000 n 0000249300 00000 n 0000249405 00000 n 0000249510 00000 n 0000249615 00000 n 0000249720 00000 n 0000249825 00000 n 0000249930 00000 n 0000250035 00000 n 0000250140 00000 n 0000250245 00000 n 0000250350 00000 n 0000250455 00000 n 0000250506 00000 n 0000250595 00000 n 0000250766 00000 n 0000250870 00000 n 0000250897 00000 n 0000250948 00000 n 0000251037 00000 n 0000251064 00000 n 0000251168 00000 n 0000251272 00000 n 0000251376 00000 n 0000251480 00000 n 0000251585 00000 n 0000251690 00000 n 0000251795 00000 n 0000251900 00000 n 0000252005 00000 n 0000252109 00000 n 0000252213 00000 n 0000252317 00000 n 0000252422 00000 n 0000252527 00000 n 0000252631 00000 n 0000252735 00000 n 0000252839 00000 n 0000252943 00000 n 0000253048 00000 n 0000253153 00000 n 0000253254 00000 n 0000253343 00000 n 0000253550 00000 n 0000253654 00000 n 0000253681 00000 n 0000253786 00000 n 0000253891 00000 n 0000253927 00000 n 0000254031 00000 n 0000254135 00000 n 0000254240 00000 n 0000254345 00000 n 0000254450 00000 n 0000254555 00000 n 0000254660 00000 n 0000254765 00000 n 0000254870 00000 n 0000254975 00000 n 0000255080 00000 n 0000255185 00000 n 0000255289 00000 n 0000255394 00000 n 0000255499 00000 n 0000255604 00000 n 0000255709 00000 n 0000255814 00000 n 0000255919 00000 n 0000256024 00000 n 0000256129 00000 n 0000256234 00000 n 0000256339 00000 n 0000256444 00000 n 0000256549 00000 n 0000256654 00000 n 0000256759 00000 n 0000256864 00000 n 0000256969 00000 n 0000257074 00000 n 0000257179 00000 n 0000257284 00000 n 0000257389 00000 n 0000257494 00000 n 0000257598 00000 n 0000257703 00000 n 0000257808 00000 n 0000257913 00000 n 0000258018 00000 n 0000258123 00000 n 0000258228 00000 n 0000258333 00000 n 0000258438 00000 n 0000258543 00000 n 0000258648 00000 n 0000258753 00000 n 0000258858 00000 n 0000258963 00000 n 0000259068 00000 n 0000259173 00000 n 0000259276 00000 n 0000259379 00000 n 0000259482 00000 n 0000259977 00000 n 0000260082 00000 n 0000260187 00000 n 0000260292 00000 n 0000260397 00000 n 0000260501 00000 n 0000260605 00000 n 0000260710 00000 n 0000260815 00000 n 0000260920 00000 n 0000261025 00000 n 0000261129 00000 n 0000261234 00000 n 0000261339 00000 n 0000261444 00000 n 0000261549 00000 n 0000261654 00000 n 0000261759 00000 n 0000261863 00000 n 0000261968 00000 n 0000262073 00000 n 0000262178 00000 n 0000262283 00000 n 0000262388 00000 n 0000262493 00000 n 0000262598 00000 n 0000262703 00000 n 0000262808 00000 n 0000262913 00000 n 0000263017 00000 n 0000263122 00000 n 0000263227 00000 n 0000263332 00000 n 0000263437 00000 n 0000263542 00000 n 0000263647 00000 n 0000263752 00000 n 0000263857 00000 n 0000263962 00000 n 0000264067 00000 n 0000264172 00000 n 0000264277 00000 n 0000264382 00000 n 0000264486 00000 n 0000264590 00000 n 0000264695 00000 n 0000264800 00000 n 0000264905 00000 n 0000265010 00000 n 0000265115 00000 n 0000265219 00000 n 0000265687 00000 n 0000265790 00000 n 0000265895 00000 n 0000266000 00000 n 0000266045 00000 n 0000266150 00000 n 0000266253 00000 n 0000266358 00000 n 0000266428 00000 n 0000266515 00000 n 0000266623 00000 n 0000266710 00000 n 0000266773 00000 n 0000266878 00000 n 0000266983 00000 n 0000267086 00000 n 0000267131 00000 n 0000267201 00000 n 0000267289 00000 n 0000267316 00000 n 0000267421 00000 n 0000267526 00000 n 0000267562 00000 n 0000267667 00000 n 0000267770 00000 n 0000267875 00000 n 0000267920 00000 n 0000268024 00000 n 0000268130 00000 n 0000268219 00000 n 0000268325 00000 n 0000268412 00000 n 0000268512 00000 n 0000268601 00000 n 0000268696 00000 n 0000268785 00000 n 0000268880 00000 n 0000268968 00000 n 0000269063 00000 n 0000269152 00000 n 0000269233 00000 n 0000269337 00000 n 0000269442 00000 n 0000269546 00000 n 0000269649 00000 n 0000269754 00000 n 0000269817 00000 n 0000269920 00000 n 0000270024 00000 n 0000270060 00000 n 0000270165 00000 n 0000270270 00000 n 0000270306 00000 n 0000270411 00000 n 0000270516 00000 n 0000270552 00000 n 0000270657 00000 n 0000270684 00000 n 0000270788 00000 n 0000270893 00000 n 0000270996 00000 n 0000271099 00000 n 0000271202 00000 n 0000271265 00000 n 0000271370 00000 n 0000271397 00000 n 0000271501 00000 n 0000271584 00000 n 0000271673 00000 n 0000271756 00000 n 0000271843 00000 n 0000271888 00000 n 0000271993 00000 n 0000272020 00000 n 0000272125 00000 n 0000272230 00000 n 0000272334 00000 n 0000272379 00000 n 0000272484 00000 n 0000272573 00000 n 0000272662 00000 n 0000272698 00000 n 0000272780 00000 n 0000272869 00000 n 0000272974 00000 n 0000273078 00000 n 0000273149 00000 n 0000273237 00000 n 0000273291 00000 n 0000273394 00000 n 0000273421 00000 n 0000273524 00000 n 0000273551 00000 n 0000273656 00000 n 0000273683 00000 n 0000273788 00000 n 0000273815 00000 n 0000273920 00000 n 0000273947 00000 n 0000274050 00000 n 0000274077 00000 n 0000274182 00000 n 0000274209 00000 n 0000274314 00000 n 0000274417 00000 n 0000274521 00000 n 0000274626 00000 n 0000274731 00000 n 0000274794 00000 n 0000274896 00000 n 0000274923 00000 n 0000275028 00000 n 0000275131 00000 n 0000275167 00000 n 0000275270 00000 n 0000275297 00000 n 0000275349 00000 n 0000275437 00000 n 0000275504 00000 n 0000275593 00000 n 0000275629 00000 n 0000275734 00000 n 0000275839 00000 n 0000275944 00000 n 0000276049 00000 n 0000276154 00000 n 0000276259 00000 n 0000276331 00000 n 0000276423 00000 n 0000276512 00000 n 0000276617 00000 n 0000276721 00000 n 0000276826 00000 n 0000276880 00000 n 0000276983 00000 n 0000277088 00000 n 0000277193 00000 n 0000277296 00000 n 0000277401 00000 n 0000277506 00000 n 0000277610 00000 n 0000277715 00000 n 0000277819 00000 n 0000277924 00000 n 0000278027 00000 n 0000278132 00000 n 0000278237 00000 n 0000278372 00000 n 0000278476 00000 n 0000278503 00000 n 0000278608 00000 n 0000278713 00000 n 0000278749 00000 n 0000278853 00000 n 0000278958 00000 n 0000279063 00000 n 0000279108 00000 n 0000279212 00000 n 0000279239 00000 n 0000279343 00000 n 0000279448 00000 n 0000279484 00000 n 0000279588 00000 n 0000279693 00000 n 0000279729 00000 n 0000279833 00000 n 0000279860 00000 n 0000279964 00000 n 0000279991 00000 n 0000280096 00000 n 0000280200 00000 n 0000280236 00000 n 0000280340 00000 n 0000280367 00000 n 0000280471 00000 n 0000280498 00000 n 0000280602 00000 n 0000280706 00000 n 0000280811 00000 n 0000280916 00000 n 0000281021 00000 n 0000281126 00000 n 0000281229 00000 n 0000281334 00000 n 0000281439 00000 n 0000281542 00000 n 0000281645 00000 n 0000281762 00000 n 0000281866 00000 n 0000281893 00000 n 0000281998 00000 n 0000282052 00000 n 0000282139 00000 n 0000282175 00000 n 0000282279 00000 n 0000282383 00000 n 0000282488 00000 n 0000282593 00000 n 0000282698 00000 n 0000282803 00000 n 0000282907 00000 n 0000283012 00000 n 0000283117 00000 n 0000283222 00000 n 0000283327 00000 n 0000283432 00000 n 0000283537 00000 n 0000283642 00000 n 0000283747 00000 n 0000283852 00000 n 0000283957 00000 n 0000284062 00000 n 0000284167 00000 n 0000284272 00000 n 0000284377 00000 n 0000284482 00000 n 0000284587 00000 n 0000284691 00000 n 0000284796 00000 n 0000284901 00000 n 0000285006 00000 n 0000285111 00000 n 0000285215 00000 n 0000285320 00000 n 0000285425 00000 n 0000285529 00000 n 0000285634 00000 n 0000285739 00000 n 0000285843 00000 n 0000285948 00000 n 0000286053 00000 n 0000286158 00000 n 0000286209 00000 n 0000286298 00000 n 0000286357 00000 n 0000286446 00000 n 0000286824 00000 n 0000286909 00000 n 0000286998 00000 n 0000287025 00000 n 0000287130 00000 n 0000287157 00000 n 0000287262 00000 n 0000287366 00000 n 0000287471 00000 n 0000287516 00000 n 0000287619 00000 n 0000287646 00000 n 0000287751 00000 n 0000287856 00000 n 0000287892 00000 n 0000287996 00000 n 0000288101 00000 n 0000288205 00000 n 0000288310 00000 n 0000288415 00000 n 0000288519 00000 n 0000288624 00000 n 0000288729 00000 n 0000288833 00000 n 0000288938 00000 n 0000289043 00000 n 0000289148 00000 n 0000289253 00000 n 0000289358 00000 n 0000289463 00000 n 0000289567 00000 n 0000289672 00000 n 0000289777 00000 n 0000289881 00000 n 0000289933 00000 n 0000290022 00000 n 0000290127 00000 n 0000290232 00000 n 0000290328 00000 n 0000290415 00000 n 0000290509 00000 n 0000290596 00000 n 0000290830 00000 n 0000290935 00000 n 0000291040 00000 n 0000291145 00000 n 0000291249 00000 n 0000291354 00000 n 0000291417 00000 n 0000291522 00000 n 0000291549 00000 n 0000291653 00000 n 0000291757 00000 n 0000291861 00000 n 0000291906 00000 n 0000291984 00000 n 0000292071 00000 n 0000292132 00000 n 0000292221 00000 n 0000292257 00000 n 0000292361 00000 n 0000292466 00000 n 0000292571 00000 n 0000292676 00000 n 0000292781 00000 n 0000292886 00000 n 0000292990 00000 n 0000293095 00000 n 0000293200 00000 n 0000293305 00000 n 0000293410 00000 n 0000293515 00000 n 0000293620 00000 n 0000293725 00000 n 0000293830 00000 n 0000293935 00000 n 0000294040 00000 n 0000294145 00000 n 0000294250 00000 n 0000294355 00000 n 0000294460 00000 n 0000294565 00000 n 0000294670 00000 n 0000294775 00000 n 0000294880 00000 n 0000294985 00000 n 0000295090 00000 n 0000295195 00000 n 0000295300 00000 n 0000295405 00000 n 0000295510 00000 n 0000295564 00000 n 0000295653 00000 n 0000295724 00000 n 0000295813 00000 n 0000296128 00000 n 0000296232 00000 n 0000296336 00000 n 0000296441 00000 n 0000296546 00000 n 0000296651 00000 n 0000296755 00000 n 0000296860 00000 n 0000296965 00000 n 0000297070 00000 n 0000297175 00000 n 0000297280 00000 n 0000297385 00000 n 0000297490 00000 n 0000297595 00000 n 0000297700 00000 n 0000297805 00000 n 0000297910 00000 n 0000298015 00000 n 0000298120 00000 n 0000298225 00000 n 0000298330 00000 n 0000298435 00000 n 0000298540 00000 n 0000298608 00000 n 0000298696 00000 n 0000298930 00000 n 0000299035 00000 n 0000299062 00000 n 0000299166 00000 n 0000299270 00000 n 0000299375 00000 n 0000299480 00000 n 0000299585 00000 n 0000299690 00000 n 0000299795 00000 n 0000299900 00000 n 0000300005 00000 n 0000300109 00000 n 0000300214 00000 n 0000300319 00000 n 0000300423 00000 n 0000300528 00000 n 0000300633 00000 n 0000300738 00000 n 0000300843 00000 n 0000300948 00000 n 0000301053 00000 n 0000301158 00000 n 0000301263 00000 n 0000301368 00000 n 0000301473 00000 n 0000301577 00000 n 0000301681 00000 n 0000301785 00000 n 0000301890 00000 n 0000301995 00000 n 0000302100 00000 n 0000302205 00000 n 0000302309 00000 n 0000302414 00000 n 0000302519 00000 n 0000302624 00000 n 0000302729 00000 n 0000302834 00000 n 0000302939 00000 n 0000303043 00000 n 0000303148 00000 n 0000303253 00000 n 0000303358 00000 n 0000303463 00000 n 0000303568 00000 n 0000303673 00000 n 0000303778 00000 n 0000303882 00000 n 0000304314 00000 n 0000304384 00000 n 0000304471 00000 n 0000304498 00000 n 0000304560 00000 n 0000304648 00000 n 0000304675 00000 n 0000304778 00000 n 0000304805 00000 n 0000304910 00000 n 0000305013 00000 n 0000305049 00000 n 0000305153 00000 n 0000305256 00000 n 0000305292 00000 n 0000305393 00000 n 0000305420 00000 n 0000305523 00000 n 0000305550 00000 n 0000305654 00000 n 0000305759 00000 n 0000305864 00000 n 0000305968 00000 n 0000306073 00000 n 0000306178 00000 n 0000306283 00000 n 0000306388 00000 n 0000306493 00000 n 0000306598 00000 n 0000306703 00000 n 0000306808 00000 n 0000306913 00000 n 0000307018 00000 n 0000307123 00000 n 0000307228 00000 n 0000307332 00000 n 0000307437 00000 n 0000307542 00000 n 0000307647 00000 n 0000307752 00000 n 0000307857 00000 n 0000307962 00000 n 0000308067 00000 n 0000308301 00000 n 0000308405 00000 n 0000308432 00000 n 0000308537 00000 n 0000308641 00000 n 0000308677 00000 n 0000308781 00000 n 0000308886 00000 n 0000308991 00000 n 0000309096 00000 n 0000309200 00000 n 0000309305 00000 n 0000309410 00000 n 0000309515 00000 n 0000309620 00000 n 0000309725 00000 n 0000309830 00000 n 0000309935 00000 n 0000310061 00000 n 0000310165 00000 n 0000310269 00000 n 0000310374 00000 n 0000310479 00000 n 0000310584 00000 n 0000310689 00000 n 0000310794 00000 n 0000310899 00000 n 0000311004 00000 n 0000311109 00000 n 0000311213 00000 n 0000311318 00000 n 0000311423 00000 n 0000311528 00000 n 0000311633 00000 n 0000311738 00000 n 0000311843 00000 n 0000311948 00000 n 0000312053 00000 n 0000312158 00000 n 0000312263 00000 n 0000312368 00000 n 0000312473 00000 n 0000312578 00000 n 0000312683 00000 n 0000312788 00000 n 0000312892 00000 n 0000312997 00000 n 0000313102 00000 n 0000313207 00000 n 0000313312 00000 n 0000313417 00000 n 0000313522 00000 n 0000313626 00000 n 0000313731 00000 n 0000313836 00000 n 0000313941 00000 n 0000314046 00000 n 0000314151 00000 n 0000314256 00000 n 0000314361 00000 n 0000314465 00000 n 0000314570 00000 n 0000314675 00000 n 0000314780 00000 n 0000314885 00000 n 0000314989 00000 n 0000315094 00000 n 0000315199 00000 n 0000315304 00000 n 0000315408 00000 n 0000315510 00000 n 0000315613 00000 n 0000316108 00000 n 0000316213 00000 n 0000316318 00000 n 0000316423 00000 n 0000316527 00000 n 0000316632 00000 n 0000316737 00000 n 0000316842 00000 n 0000316947 00000 n 0000317052 00000 n 0000317157 00000 n 0000317261 00000 n 0000317366 00000 n 0000317471 00000 n 0000317576 00000 n 0000317681 00000 n 0000317786 00000 n 0000317891 00000 n 0000317996 00000 n 0000318101 00000 n 0000318205 00000 n 0000318309 00000 n 0000318414 00000 n 0000318519 00000 n 0000318624 00000 n 0000318729 00000 n 0000318972 00000 n 0000319048 00000 n 0000319136 00000 n 0000319163 00000 n 0000319233 00000 n 0000319320 00000 n 0000319347 00000 n 0000319435 00000 n 0000319524 00000 n 0000319612 00000 n 0000319700 00000 n 0000319736 00000 n 0000319806 00000 n 0000319893 00000 n 0000319920 00000 n 0000320025 00000 n 0000320128 00000 n 0000320231 00000 n 0000320276 00000 n 0000320381 00000 n 0000320408 00000 n 0000320512 00000 n 0000320617 00000 n 0000320721 00000 n 0000320826 00000 n 0000320880 00000 n 0000320959 00000 n 0000321047 00000 n 0000321074 00000 n 0000321179 00000 n 0000321206 00000 n 0000321280 00000 n 0000321368 00000 n 0000321395 00000 n 0000321500 00000 n 0000321527 00000 n 0000321581 00000 n 0000321670 00000 n 0000321697 00000 n 0000321802 00000 n 0000321829 00000 n 0000321933 00000 n 0000321960 00000 n 0000322063 00000 n 0000322168 00000 n 0000322204 00000 n 0000322307 00000 n 0000322334 00000 n 0000322437 00000 n 0000322464 00000 n 0000322537 00000 n 0000322626 00000 n 0000322653 00000 n 0000322726 00000 n 0000322815 00000 n 0000322842 00000 n 0000322945 00000 n 0000323049 00000 n 0000323153 00000 n 0000323257 00000 n 0000323361 00000 n 0000323465 00000 n 0000323569 00000 n 0000323627 00000 n 0000323716 00000 n 0000323806 00000 n 0000323910 00000 n 0000324015 00000 n 0000324120 00000 n 0000324225 00000 n 0000324330 00000 n 0000324435 00000 n 0000324540 00000 n 0000324644 00000 n 0000324749 00000 n 0000324853 00000 n 0000324958 00000 n 0000325063 00000 n 0000325168 00000 n 0000325273 00000 n 0000325378 00000 n 0000325483 00000 n 0000325588 00000 n 0000325693 00000 n 0000325798 00000 n 0000325903 00000 n 0000326008 00000 n 0000326113 00000 n 0000326218 00000 n 0000326323 00000 n 0000326428 00000 n 0000326533 00000 n 0000326638 00000 n 0000326743 00000 n 0000326847 00000 n 0000326952 00000 n 0000327057 00000 n 0000327162 00000 n 0000327267 00000 n 0000327371 00000 n 0000327475 00000 n 0000327580 00000 n 0000327685 00000 n 0000327790 00000 n 0000327895 00000 n 0000327999 00000 n 0000328104 00000 n 0000328209 00000 n 0000328314 00000 n 0000328419 00000 n 0000328524 00000 n 0000328629 00000 n 0000328734 00000 n 0000328839 00000 n 0000328944 00000 n 0000329049 00000 n 0000329153 00000 n 0000329256 00000 n 0000329359 00000 n 0000329854 00000 n 0000329959 00000 n 0000330064 00000 n 0000330169 00000 n 0000330274 00000 n 0000330379 00000 n 0000330484 00000 n 0000330589 00000 n 0000330694 00000 n 0000330799 00000 n 0000330904 00000 n 0000331009 00000 n 0000331114 00000 n 0000331219 00000 n 0000331324 00000 n 0000331429 00000 n 0000331534 00000 n 0000331639 00000 n 0000331744 00000 n 0000331849 00000 n 0000331954 00000 n 0000332059 00000 n 0000332164 00000 n 0000332269 00000 n 0000332374 00000 n 0000332478 00000 n 0000332583 00000 n 0000332688 00000 n 0000332793 00000 n 0000332898 00000 n 0000333003 00000 n 0000333108 00000 n 0000333213 00000 n 0000333318 00000 n 0000333422 00000 n 0000333527 00000 n 0000333632 00000 n 0000333737 00000 n 0000333841 00000 n 0000333946 00000 n 0000334051 00000 n 0000334156 00000 n 0000334261 00000 n 0000334366 00000 n 0000334471 00000 n 0000334573 00000 n 0000334996 00000 n 0000335066 00000 n 0000335155 00000 n 0000335225 00000 n 0000335312 00000 n 0000335348 00000 n 0000335453 00000 n 0000335480 00000 n 0000335546 00000 n 0000335633 00000 n 0000335660 00000 n 0000335765 00000 n 0000335870 00000 n 0000335906 00000 n 0000336011 00000 n 0000336114 00000 n 0000336150 00000 n 0000336255 00000 n 0000336282 00000 n 0000336387 00000 n 0000336414 00000 n 0000336519 00000 n 0000336624 00000 n 0000336660 00000 n 0000336765 00000 n 0000336792 00000 n 0000336896 00000 n 0000336923 00000 n 0000337028 00000 n 0000337055 00000 n 0000337160 00000 n 0000337187 00000 n 0000337287 00000 n 0000337375 00000 n 0000337402 00000 n 0000337506 00000 n 0000337533 00000 n 0000337625 00000 n 0000337714 00000 n 0000337741 00000 n 0000337844 00000 n 0000337871 00000 n 0000337974 00000 n 0000338001 00000 n 0000338105 00000 n 0000338132 00000 n 0000338237 00000 n 0000338317 00000 n 0000338406 00000 n 0000338442 00000 n 0000338547 00000 n 0000338574 00000 n 0000338678 00000 n 0000338705 00000 n 0000338808 00000 n 0000338911 00000 n 0000338947 00000 n 0000339050 00000 n 0000339077 00000 n 0000339182 00000 n 0000339209 00000 n 0000339313 00000 n 0000339418 00000 n 0000339523 00000 n 0000339628 00000 n 0000339733 00000 n 0000339838 00000 n 0000339943 00000 n 0000340048 00000 n 0000340153 00000 n 0000340257 00000 n 0000340362 00000 n 0000340467 00000 n 0000340571 00000 n 0000340676 00000 n 0000340781 00000 n 0000340886 00000 n 0000340991 00000 n 0000341096 00000 n 0000341201 00000 n 0000341306 00000 n 0000341411 00000 n 0000341516 00000 n 0000341621 00000 n 0000341726 00000 n 0000341831 00000 n 0000341936 00000 n 0000342041 00000 n 0000342145 00000 n 0000342250 00000 n 0000342355 00000 n 0000342459 00000 n 0000342563 00000 n 0000342667 00000 n 0000342772 00000 n 0000342877 00000 n 0000342982 00000 n 0000343087 00000 n 0000343192 00000 n 0000343297 00000 n 0000343402 00000 n 0000343507 00000 n 0000343611 00000 n 0000343715 00000 n 0000343820 00000 n 0000343924 00000 n 0000344347 00000 n 0000344417 00000 n 0000344506 00000 n 0000344533 00000 n 0000344638 00000 n 0000344741 00000 n 0000344777 00000 n 0000344882 00000 n 0000344909 00000 n 0000345014 00000 n 0000345041 00000 n 0000345145 00000 n 0000345250 00000 n 0000345286 00000 n 0000345390 00000 n 0000345495 00000 n 0000345531 00000 n 0000345634 00000 n 0000345661 00000 n 0000345732 00000 n 0000345821 00000 n 0000345848 00000 n 0000345952 00000 n 0000346056 00000 n 0000346160 00000 n 0000346264 00000 n 0000346369 00000 n 0000346474 00000 n 0000346579 00000 n 0000346684 00000 n 0000346789 00000 n 0000346894 00000 n 0000346999 00000 n 0000347104 00000 n 0000347208 00000 n 0000347313 00000 n 0000347418 00000 n 0000347523 00000 n 0000347628 00000 n 0000347733 00000 n 0000347838 00000 n 0000347942 00000 n 0000348046 00000 n 0000348150 00000 n 0000348255 00000 n 0000348360 00000 n 0000348465 00000 n 0000348570 00000 n 0000348675 00000 n 0000348780 00000 n 0000348884 00000 n 0000348988 00000 n 0000349093 00000 n 0000349198 00000 n 0000349303 00000 n 0000349408 00000 n 0000349513 00000 n 0000349618 00000 n 0000349723 00000 n 0000349828 00000 n 0000349933 00000 n 0000350038 00000 n 0000350143 00000 n 0000350248 00000 n 0000350353 00000 n 0000350458 00000 n 0000350563 00000 n 0000350668 00000 n 0000350772 00000 n 0000350876 00000 n 0000350980 00000 n 0000351439 00000 n 0000351509 00000 n 0000351597 00000 n 0000351624 00000 n 0000351727 00000 n 0000351754 00000 n 0000351859 00000 n 0000351886 00000 n 0000351939 00000 n 0000352028 00000 n 0000352133 00000 n 0000352238 00000 n 0000352283 00000 n 0000352388 00000 n 0000352415 00000 n 0000352451 00000 n 0000352487 00000 n 0000380177 00000 n 0000380222 00000 n 0000380267 00000 n 0000380312 00000 n 0000380357 00000 n 0000380402 00000 n 0000380447 00000 n 0000380492 00000 n 0000380537 00000 n 0000380582 00000 n 0000380627 00000 n 0000380672 00000 n 0000380717 00000 n 0000380762 00000 n 0000380807 00000 n 0000380852 00000 n 0000380897 00000 n 0000380942 00000 n 0000380987 00000 n 0000381032 00000 n 0000381077 00000 n 0000381122 00000 n 0000381167 00000 n 0000381212 00000 n 0000381257 00000 n 0000381302 00000 n 0000381347 00000 n 0000381392 00000 n 0000381437 00000 n 0000381482 00000 n 0000381527 00000 n 0000381572 00000 n 0000381617 00000 n 0000381662 00000 n 0000381707 00000 n 0000381752 00000 n 0000381797 00000 n 0000381842 00000 n 0000381887 00000 n 0000381932 00000 n 0000381977 00000 n 0000382022 00000 n 0000382067 00000 n 0000382112 00000 n 0000382157 00000 n 0000382202 00000 n 0000382247 00000 n 0000382292 00000 n 0000382337 00000 n 0000382382 00000 n 0000382427 00000 n 0000382472 00000 n 0000382517 00000 n 0000382562 00000 n 0000382607 00000 n 0000382652 00000 n 0000382697 00000 n 0000382742 00000 n 0000382787 00000 n 0000382832 00000 n 0000382877 00000 n 0000382922 00000 n 0000382967 00000 n 0000383012 00000 n 0000383057 00000 n 0000383102 00000 n 0000383147 00000 n 0000383192 00000 n 0000383237 00000 n 0000383282 00000 n 0000383327 00000 n 0000383372 00000 n 0000383417 00000 n 0000383462 00000 n 0000383507 00000 n 0000383552 00000 n 0000383597 00000 n 0000383642 00000 n 0000383687 00000 n 0000383732 00000 n 0000383777 00000 n 0000383822 00000 n 0000383867 00000 n 0000383912 00000 n 0000383957 00000 n 0000384002 00000 n 0000384047 00000 n 0000384092 00000 n 0000384137 00000 n 0000384182 00000 n 0000384227 00000 n 0000384272 00000 n 0000384317 00000 n 0000384362 00000 n 0000384407 00000 n 0000384452 00000 n 0000384497 00000 n 0000384542 00000 n 0000384587 00000 n 0000384632 00000 n 0000384677 00000 n 0000384721 00000 n 0000384766 00000 n 0000384811 00000 n 0000384856 00000 n 0000384901 00000 n 0000384946 00000 n 0000384991 00000 n 0000385036 00000 n 0000385081 00000 n 0000385126 00000 n 0000385171 00000 n 0000385216 00000 n 0000385261 00000 n 0000385306 00000 n 0000385351 00000 n 0000385396 00000 n 0000385441 00000 n 0000385486 00000 n 0000385531 00000 n 0000385576 00000 n 0000385621 00000 n 0000385666 00000 n 0000385711 00000 n 0000385756 00000 n 0000385801 00000 n 0000385846 00000 n 0000385891 00000 n 0000385936 00000 n 0000385981 00000 n 0000386026 00000 n 0000386071 00000 n 0000386116 00000 n 0000386161 00000 n 0000386206 00000 n 0000386251 00000 n 0000386296 00000 n 0000386341 00000 n 0000386386 00000 n 0000386431 00000 n 0000386476 00000 n 0000386521 00000 n 0000386566 00000 n 0000386611 00000 n 0000386656 00000 n 0000386701 00000 n 0000386746 00000 n 0000386791 00000 n 0000386836 00000 n 0000386881 00000 n 0000386926 00000 n 0000386971 00000 n 0000387016 00000 n 0000387061 00000 n 0000387106 00000 n 0000387151 00000 n 0000387196 00000 n 0000387241 00000 n 0000387286 00000 n 0000387331 00000 n 0000387376 00000 n 0000387421 00000 n 0000387466 00000 n 0000387511 00000 n 0000387556 00000 n 0000387601 00000 n 0000387646 00000 n 0000387691 00000 n 0000387736 00000 n 0000387781 00000 n 0000387826 00000 n 0000387871 00000 n 0000387916 00000 n 0000387961 00000 n 0000388006 00000 n 0000388051 00000 n 0000388096 00000 n 0000388141 00000 n 0000388186 00000 n 0000388231 00000 n 0000388276 00000 n 0000388321 00000 n 0000388366 00000 n 0000388411 00000 n 0000388456 00000 n 0000388501 00000 n 0000388546 00000 n 0000388591 00000 n 0000388636 00000 n 0000388681 00000 n 0000388726 00000 n 0000388771 00000 n 0000388816 00000 n 0000388861 00000 n 0000388906 00000 n 0000388951 00000 n 0000388996 00000 n 0000389041 00000 n 0000389086 00000 n 0000389130 00000 n 0000389175 00000 n 0000389220 00000 n 0000389265 00000 n 0000389310 00000 n 0000389355 00000 n 0000389400 00000 n 0000389444 00000 n 0000389489 00000 n 0000389534 00000 n 0000389579 00000 n 0000389624 00000 n 0000389669 00000 n 0000389714 00000 n 0000389759 00000 n 0000389804 00000 n 0000389849 00000 n 0000389894 00000 n 0000389939 00000 n 0000389984 00000 n 0000390029 00000 n 0000390074 00000 n 0000390119 00000 n 0000390164 00000 n 0000390209 00000 n 0000390254 00000 n 0000390299 00000 n 0000390344 00000 n 0000390389 00000 n 0000390434 00000 n 0000390479 00000 n 0000390524 00000 n 0000390569 00000 n 0000390614 00000 n 0000390659 00000 n 0000390704 00000 n 0000390749 00000 n 0000390794 00000 n 0000390839 00000 n 0000390884 00000 n 0000390929 00000 n 0000390974 00000 n 0000391019 00000 n 0000391064 00000 n 0000391109 00000 n 0000391154 00000 n 0000391199 00000 n 0000391244 00000 n 0000391289 00000 n 0000391334 00000 n 0000391379 00000 n 0000391424 00000 n 0000391469 00000 n 0000391514 00000 n 0000391559 00000 n 0000391604 00000 n 0000391649 00000 n 0000391694 00000 n 0000391738 00000 n 0000391783 00000 n 0000391828 00000 n 0000391873 00000 n 0000391918 00000 n 0000391963 00000 n 0000392008 00000 n 0000392053 00000 n 0000392098 00000 n 0000392143 00000 n 0000392188 00000 n 0000392233 00000 n 0000392278 00000 n 0000392323 00000 n 0000392368 00000 n 0000392413 00000 n 0000392458 00000 n 0000392503 00000 n 0000392548 00000 n 0000392593 00000 n 0000392638 00000 n 0000392683 00000 n 0000392728 00000 n 0000392773 00000 n 0000392818 00000 n 0000392863 00000 n 0000392908 00000 n 0000392953 00000 n 0000392998 00000 n 0000393043 00000 n 0000393088 00000 n 0000393133 00000 n 0000393178 00000 n 0000393223 00000 n 0000393268 00000 n 0000393313 00000 n 0000393358 00000 n 0000393403 00000 n 0000393448 00000 n 0000393493 00000 n 0000393538 00000 n 0000393583 00000 n 0000393628 00000 n 0000393673 00000 n 0000393718 00000 n 0000393763 00000 n 0000393808 00000 n 0000393853 00000 n 0000393898 00000 n 0000393943 00000 n 0000393988 00000 n 0000394033 00000 n 0000394078 00000 n 0000394123 00000 n 0000394168 00000 n 0000394213 00000 n 0000394258 00000 n 0000394303 00000 n 0000394348 00000 n 0000394393 00000 n 0000394438 00000 n 0000394483 00000 n 0000394528 00000 n 0000394573 00000 n 0000394618 00000 n 0000394663 00000 n 0000394708 00000 n 0000394753 00000 n 0000394798 00000 n 0000394843 00000 n 0000394888 00000 n 0000394933 00000 n 0000394978 00000 n 0000395023 00000 n 0000395068 00000 n 0000395113 00000 n 0000395158 00000 n 0000395203 00000 n 0000395248 00000 n 0000395293 00000 n 0000395338 00000 n 0000395383 00000 n 0000395428 00000 n 0000395473 00000 n 0000395518 00000 n 0000395563 00000 n 0000395608 00000 n 0000395653 00000 n 0000395698 00000 n 0000395743 00000 n 0000395788 00000 n 0000395833 00000 n 0000395878 00000 n 0000395923 00000 n 0000395968 00000 n 0000396013 00000 n 0000396058 00000 n 0000396103 00000 n 0000396148 00000 n 0000396193 00000 n 0000396238 00000 n 0000396283 00000 n 0000396328 00000 n 0000396373 00000 n 0000396418 00000 n 0000396463 00000 n 0000396508 00000 n 0000396553 00000 n 0000396598 00000 n 0000396643 00000 n 0000396688 00000 n 0000396733 00000 n 0000396778 00000 n 0000396823 00000 n 0000396868 00000 n 0000396913 00000 n 0000396958 00000 n 0000397003 00000 n 0000397048 00000 n 0000397093 00000 n 0000397138 00000 n 0000397183 00000 n 0000397228 00000 n 0000397273 00000 n 0000397318 00000 n 0000397363 00000 n 0000397408 00000 n 0000397453 00000 n 0000397498 00000 n 0000397543 00000 n 0000397588 00000 n 0000397633 00000 n 0000397678 00000 n 0000397723 00000 n 0000397768 00000 n 0000397813 00000 n 0000397858 00000 n 0000397903 00000 n 0000397948 00000 n 0000397993 00000 n 0000398038 00000 n 0000398083 00000 n 0000398128 00000 n 0000398173 00000 n 0000398218 00000 n 0000398263 00000 n 0000398308 00000 n 0000398353 00000 n 0000398398 00000 n 0000398443 00000 n 0000398488 00000 n 0000398533 00000 n 0000398578 00000 n 0000398623 00000 n 0000398668 00000 n 0000398713 00000 n 0000398758 00000 n 0000398803 00000 n 0000398848 00000 n 0000398893 00000 n 0000398938 00000 n 0000398983 00000 n 0000399028 00000 n 0000399073 00000 n 0000399118 00000 n 0000399163 00000 n 0000399208 00000 n 0000399253 00000 n 0000399298 00000 n 0000399343 00000 n 0000399388 00000 n 0000399433 00000 n 0000399478 00000 n 0000399523 00000 n 0000399568 00000 n 0000399613 00000 n 0000399658 00000 n 0000399703 00000 n 0000399748 00000 n 0000399793 00000 n 0000399838 00000 n 0000399883 00000 n 0000399928 00000 n 0000399973 00000 n 0000400018 00000 n 0000400063 00000 n 0000400108 00000 n 0000400153 00000 n 0000400198 00000 n 0000400243 00000 n 0000400288 00000 n 0000400333 00000 n 0000400378 00000 n 0000400423 00000 n 0000400468 00000 n 0000400513 00000 n 0000400558 00000 n 0000400603 00000 n 0000400648 00000 n 0000400693 00000 n 0000400738 00000 n 0000400783 00000 n 0000400828 00000 n 0000400873 00000 n 0000400918 00000 n 0000400963 00000 n 0000401008 00000 n 0000401053 00000 n 0000401098 00000 n 0000401143 00000 n 0000401188 00000 n 0000401233 00000 n 0000401278 00000 n 0000401323 00000 n 0000401368 00000 n 0000401413 00000 n 0000401458 00000 n 0000401503 00000 n 0000401548 00000 n 0000401593 00000 n 0000401638 00000 n 0000401683 00000 n 0000401728 00000 n 0000401773 00000 n 0000401818 00000 n 0000401863 00000 n 0000401908 00000 n 0000401953 00000 n 0000401998 00000 n 0000402043 00000 n 0000402088 00000 n 0000402133 00000 n 0000402178 00000 n 0000402223 00000 n 0000402268 00000 n 0000402313 00000 n 0000402358 00000 n 0000402403 00000 n 0000402448 00000 n 0000402493 00000 n 0000402538 00000 n 0000402583 00000 n 0000402628 00000 n 0000402673 00000 n 0000402718 00000 n 0000402763 00000 n 0000402808 00000 n 0000402853 00000 n 0000402898 00000 n 0000402943 00000 n 0000402988 00000 n 0000403033 00000 n 0000403078 00000 n 0000403123 00000 n 0000403168 00000 n 0000403213 00000 n 0000403258 00000 n 0000403303 00000 n 0000403348 00000 n 0000403393 00000 n 0000403438 00000 n 0000403483 00000 n 0000403528 00000 n 0000403573 00000 n 0000403618 00000 n 0000403663 00000 n 0000403708 00000 n 0000403753 00000 n 0000403798 00000 n 0000403843 00000 n 0000403888 00000 n 0000403933 00000 n 0000403978 00000 n 0000404023 00000 n 0000404068 00000 n 0000404113 00000 n 0000404158 00000 n 0000404203 00000 n 0000404248 00000 n 0000404293 00000 n 0000404338 00000 n 0000404383 00000 n 0000404428 00000 n 0000404473 00000 n 0000404518 00000 n 0000404563 00000 n 0000404608 00000 n 0000404653 00000 n 0000404698 00000 n 0000404743 00000 n 0000404788 00000 n 0000404833 00000 n 0000404878 00000 n 0000404923 00000 n 0000404968 00000 n 0000405013 00000 n 0000405058 00000 n 0000405103 00000 n 0000405148 00000 n 0000405193 00000 n 0000405238 00000 n 0000405283 00000 n 0000405328 00000 n 0000405373 00000 n 0000405418 00000 n 0000405463 00000 n 0000405508 00000 n 0000405553 00000 n 0000405598 00000 n 0000405643 00000 n 0000405688 00000 n 0000405733 00000 n 0000405778 00000 n 0000405823 00000 n 0000405868 00000 n 0000405913 00000 n 0000405958 00000 n 0000406003 00000 n 0000406048 00000 n 0000406093 00000 n 0000406138 00000 n 0000406183 00000 n 0000406228 00000 n 0000406273 00000 n 0000406318 00000 n 0000406363 00000 n 0000406408 00000 n 0000406453 00000 n 0000406498 00000 n 0000406543 00000 n 0000406588 00000 n 0000406633 00000 n 0000406678 00000 n 0000406723 00000 n 0000406768 00000 n 0000406813 00000 n 0000406858 00000 n 0000406903 00000 n 0000406948 00000 n 0000406993 00000 n 0000407038 00000 n 0000407083 00000 n 0000407128 00000 n 0000407173 00000 n 0000407218 00000 n 0000407263 00000 n 0000407308 00000 n 0000407353 00000 n 0000407398 00000 n 0000407443 00000 n 0000407488 00000 n 0000407533 00000 n 0000407578 00000 n 0000407623 00000 n 0000407668 00000 n 0000407713 00000 n 0000407758 00000 n 0000407803 00000 n 0000407848 00000 n 0000407893 00000 n 0000407938 00000 n 0000407983 00000 n 0000408028 00000 n 0000408073 00000 n 0000408118 00000 n 0000408163 00000 n 0000408208 00000 n 0000408253 00000 n 0000408298 00000 n 0000408343 00000 n 0000408388 00000 n 0000408433 00000 n 0000408478 00000 n 0000408523 00000 n 0000408568 00000 n 0000408613 00000 n 0000408658 00000 n 0000408703 00000 n 0000408748 00000 n 0000408793 00000 n 0000408838 00000 n 0000408883 00000 n 0000408928 00000 n 0000408973 00000 n 0000409018 00000 n 0000409063 00000 n 0000409108 00000 n 0000409153 00000 n 0000409198 00000 n 0000409243 00000 n 0000409288 00000 n 0000409333 00000 n 0000409378 00000 n 0000409423 00000 n 0000409468 00000 n 0000409513 00000 n 0000409558 00000 n 0000409603 00000 n 0000409648 00000 n 0000409693 00000 n 0000409738 00000 n 0000409783 00000 n 0000409828 00000 n 0000409873 00000 n 0000409918 00000 n 0000409963 00000 n 0000410008 00000 n 0000410053 00000 n 0000410098 00000 n 0000410143 00000 n 0000410188 00000 n 0000410233 00000 n 0000410278 00000 n 0000410322 00000 n 0000410367 00000 n 0000410412 00000 n 0000410457 00000 n 0000410502 00000 n 0000410547 00000 n 0000410592 00000 n 0000410637 00000 n 0000410682 00000 n 0000410727 00000 n 0000410772 00000 n 0000410817 00000 n 0000410862 00000 n 0000410907 00000 n 0000410952 00000 n 0000410997 00000 n 0000411042 00000 n 0000411087 00000 n 0000411132 00000 n 0000411177 00000 n 0000411222 00000 n 0000411267 00000 n 0000411312 00000 n 0000411357 00000 n 0000411402 00000 n 0000411447 00000 n 0000411492 00000 n 0000411537 00000 n 0000411582 00000 n 0000411627 00000 n 0000411672 00000 n 0000411717 00000 n 0000411762 00000 n 0000411807 00000 n 0000411852 00000 n 0000411897 00000 n 0000411942 00000 n 0000411987 00000 n 0000412032 00000 n 0000412077 00000 n 0000412122 00000 n 0000412167 00000 n 0000412212 00000 n 0000412257 00000 n 0000412302 00000 n 0000412347 00000 n 0000412392 00000 n 0000412437 00000 n 0000412482 00000 n 0000412527 00000 n 0000412572 00000 n 0000412617 00000 n 0000412662 00000 n 0000412707 00000 n 0000412752 00000 n 0000412797 00000 n 0000412842 00000 n 0000412887 00000 n 0000412932 00000 n 0000412977 00000 n 0000413022 00000 n 0000413067 00000 n 0000413112 00000 n 0000413157 00000 n 0000413202 00000 n 0000413247 00000 n 0000413292 00000 n 0000413337 00000 n 0000413382 00000 n 0000413427 00000 n 0000413472 00000 n 0000413517 00000 n 0000413562 00000 n 0000413607 00000 n 0000413652 00000 n 0000413697 00000 n 0000413742 00000 n 0000413787 00000 n 0000413832 00000 n 0000413877 00000 n 0000413922 00000 n 0000413967 00000 n 0000414012 00000 n 0000414057 00000 n 0000414102 00000 n 0000414147 00000 n 0000414192 00000 n 0000414237 00000 n 0000414282 00000 n 0000414327 00000 n 0000414372 00000 n 0000414417 00000 n 0000414462 00000 n 0000414507 00000 n 0000414552 00000 n 0000414597 00000 n 0000414642 00000 n 0000414687 00000 n 0000414732 00000 n 0000414777 00000 n 0000414822 00000 n 0000414867 00000 n 0000414912 00000 n 0000414957 00000 n 0000415002 00000 n 0000415047 00000 n 0000415092 00000 n 0000415137 00000 n 0000415182 00000 n 0000415227 00000 n 0000415272 00000 n 0000415317 00000 n 0000415362 00000 n 0000415407 00000 n 0000415452 00000 n 0000415497 00000 n 0000415542 00000 n 0000415587 00000 n 0000415632 00000 n 0000415677 00000 n 0000415722 00000 n 0000415767 00000 n 0000415812 00000 n 0000415857 00000 n 0000415902 00000 n 0000415947 00000 n 0000415992 00000 n 0000416037 00000 n 0000416082 00000 n 0000416127 00000 n 0000416172 00000 n 0000416217 00000 n 0000416262 00000 n 0000416307 00000 n 0000416352 00000 n 0000416397 00000 n 0000416442 00000 n 0000416487 00000 n 0000416532 00000 n 0000416577 00000 n 0000416622 00000 n 0000416667 00000 n 0000416712 00000 n 0000416757 00000 n 0000416802 00000 n 0000416847 00000 n 0000416892 00000 n 0000416937 00000 n 0000416982 00000 n 0000417027 00000 n 0000417072 00000 n 0000417117 00000 n 0000417162 00000 n 0000417207 00000 n 0000417252 00000 n 0000417297 00000 n 0000417342 00000 n 0000417387 00000 n 0000417432 00000 n 0000417477 00000 n 0000417522 00000 n 0000417567 00000 n 0000417612 00000 n 0000417657 00000 n 0000417702 00000 n 0000417747 00000 n 0000417792 00000 n 0000417837 00000 n 0000417882 00000 n 0000417927 00000 n 0000417972 00000 n 0000418017 00000 n 0000418062 00000 n 0000418107 00000 n 0000418152 00000 n 0000418197 00000 n 0000418242 00000 n 0000418287 00000 n 0000418332 00000 n 0000418377 00000 n 0000418422 00000 n 0000418467 00000 n 0000418512 00000 n 0000418557 00000 n 0000418602 00000 n 0000418647 00000 n 0000418692 00000 n 0000418737 00000 n 0000418782 00000 n 0000418827 00000 n 0000418872 00000 n 0000418917 00000 n 0000418962 00000 n 0000419007 00000 n 0000419052 00000 n 0000419097 00000 n 0000419142 00000 n 0000419187 00000 n 0000419232 00000 n 0000419277 00000 n 0000419322 00000 n 0000419367 00000 n 0000419412 00000 n 0000419457 00000 n 0000419502 00000 n 0000419547 00000 n 0000419592 00000 n 0000419637 00000 n 0000419682 00000 n 0000419727 00000 n 0000419772 00000 n 0000419817 00000 n 0000419862 00000 n 0000419907 00000 n 0000419952 00000 n 0000419997 00000 n 0000420042 00000 n 0000420087 00000 n 0000420132 00000 n 0000420177 00000 n 0000420222 00000 n 0000420267 00000 n 0000420312 00000 n 0000420357 00000 n 0000420402 00000 n 0000420447 00000 n 0000420492 00000 n 0000420537 00000 n 0000420582 00000 n 0000420627 00000 n 0000420672 00000 n 0000420717 00000 n 0000420762 00000 n 0000420807 00000 n 0000420852 00000 n 0000420897 00000 n 0000420942 00000 n 0000420987 00000 n 0000421032 00000 n 0000421077 00000 n 0000421122 00000 n 0000421167 00000 n 0000421212 00000 n 0000421257 00000 n 0000421302 00000 n 0000421347 00000 n 0000421392 00000 n 0000421437 00000 n 0000421482 00000 n 0000421527 00000 n 0000421572 00000 n 0000421617 00000 n 0000421662 00000 n 0000421707 00000 n 0000421752 00000 n 0000421797 00000 n 0000421842 00000 n 0000421887 00000 n 0000421932 00000 n 0000421977 00000 n 0000422022 00000 n 0000422067 00000 n 0000422112 00000 n 0000422157 00000 n 0000422202 00000 n 0000422247 00000 n 0000422292 00000 n 0000422337 00000 n 0000422382 00000 n 0000422427 00000 n 0000422472 00000 n 0000422517 00000 n 0000422562 00000 n 0000422607 00000 n 0000422652 00000 n 0000422697 00000 n 0000422742 00000 n 0000422787 00000 n 0000422832 00000 n 0000422877 00000 n 0000422922 00000 n 0000422967 00000 n 0000423012 00000 n 0000423057 00000 n 0000423102 00000 n 0000423147 00000 n 0000423192 00000 n 0000423237 00000 n 0000423282 00000 n 0000423327 00000 n 0000423372 00000 n 0000423417 00000 n 0000423462 00000 n 0000423507 00000 n 0000423552 00000 n 0000423597 00000 n 0000423642 00000 n 0000423687 00000 n 0000423732 00000 n 0000423777 00000 n 0000423822 00000 n 0000423867 00000 n 0000423912 00000 n 0000423957 00000 n 0000424002 00000 n 0000424047 00000 n 0000424092 00000 n 0000424137 00000 n 0000424182 00000 n 0000424227 00000 n 0000424272 00000 n 0000424317 00000 n 0000424362 00000 n 0000424407 00000 n 0000424452 00000 n 0000424497 00000 n 0000424542 00000 n 0000424587 00000 n 0000424632 00000 n 0000424677 00000 n 0000424722 00000 n 0000424767 00000 n 0000424812 00000 n 0000424857 00000 n 0000424902 00000 n 0000424947 00000 n 0000424992 00000 n 0000425037 00000 n 0000425082 00000 n 0000425127 00000 n 0000425172 00000 n 0000425217 00000 n 0000425262 00000 n 0000425307 00000 n 0000425352 00000 n 0000425397 00000 n 0000425442 00000 n 0000425487 00000 n 0000425532 00000 n 0000425577 00000 n 0000425622 00000 n 0000425667 00000 n 0000425712 00000 n 0000425757 00000 n 0000425802 00000 n 0000425847 00000 n 0000425892 00000 n 0000425937 00000 n 0000425982 00000 n 0000426027 00000 n 0000426072 00000 n 0000426117 00000 n 0000426162 00000 n 0000426207 00000 n 0000426252 00000 n 0000426297 00000 n 0000426342 00000 n 0000426387 00000 n 0000426432 00000 n 0000426477 00000 n 0000426522 00000 n 0000426567 00000 n 0000426612 00000 n 0000426657 00000 n 0000426702 00000 n 0000426747 00000 n 0000426792 00000 n 0000426837 00000 n 0000426882 00000 n 0000426927 00000 n 0000426972 00000 n 0000427017 00000 n 0000427062 00000 n 0000427107 00000 n 0000427152 00000 n 0000427197 00000 n 0000427242 00000 n 0000427287 00000 n 0000427332 00000 n 0000427377 00000 n 0000427422 00000 n 0000427467 00000 n 0000427512 00000 n 0000427557 00000 n 0000427602 00000 n 0000427647 00000 n 0000427692 00000 n 0000427737 00000 n 0000427782 00000 n 0000427827 00000 n 0000427872 00000 n 0000427917 00000 n 0000427962 00000 n 0000428007 00000 n 0000428052 00000 n 0000428097 00000 n 0000428142 00000 n 0000428187 00000 n 0000428232 00000 n 0000428277 00000 n 0000428322 00000 n 0000428367 00000 n 0000428412 00000 n 0000428457 00000 n 0000428502 00000 n 0000428547 00000 n 0000428592 00000 n 0000428637 00000 n 0000428682 00000 n 0000428727 00000 n 0000428772 00000 n 0000428817 00000 n 0000428862 00000 n 0000428907 00000 n 0000428952 00000 n 0000428997 00000 n 0000429042 00000 n 0000429087 00000 n 0000429132 00000 n 0000429177 00000 n 0000429222 00000 n 0000429267 00000 n 0000429312 00000 n 0000429357 00000 n 0000429402 00000 n 0000429447 00000 n 0000429492 00000 n 0000429537 00000 n 0000429582 00000 n 0000429627 00000 n 0000429672 00000 n 0000429717 00000 n 0000429762 00000 n 0000429807 00000 n 0000429852 00000 n 0000429897 00000 n 0000429942 00000 n 0000429987 00000 n 0000430032 00000 n 0000430077 00000 n 0000430122 00000 n 0000430167 00000 n 0000430212 00000 n 0000430257 00000 n 0000430302 00000 n 0000430347 00000 n 0000430392 00000 n 0000430437 00000 n 0000430482 00000 n 0000430527 00000 n 0000430572 00000 n 0000430617 00000 n 0000430662 00000 n 0000430707 00000 n 0000430752 00000 n 0000430797 00000 n 0000430842 00000 n 0000430887 00000 n 0000430932 00000 n 0000430977 00000 n 0000431022 00000 n 0000431067 00000 n 0000431112 00000 n 0000431157 00000 n 0000431202 00000 n 0000431247 00000 n 0000431292 00000 n 0000431337 00000 n 0000431382 00000 n 0000431427 00000 n 0000431472 00000 n 0000431517 00000 n 0000431562 00000 n 0000431607 00000 n 0000431652 00000 n 0000431697 00000 n 0000431742 00000 n 0000431787 00000 n 0000431832 00000 n 0000431877 00000 n 0000431922 00000 n 0000431967 00000 n 0000432012 00000 n 0000432057 00000 n 0000432102 00000 n 0000432147 00000 n 0000432192 00000 n 0000432237 00000 n 0000432282 00000 n 0000432327 00000 n 0000432372 00000 n 0000432417 00000 n 0000432462 00000 n 0000432507 00000 n 0000432552 00000 n 0000432597 00000 n 0000439252 00000 n 0000439434 00000 n 0000443620 00000 n 0000443813 00000 n 0000447276 00000 n 0000447470 00000 n 0000451735 00000 n 0000451929 00000 n 0000456287 00000 n 0000456481 00000 n 0000460373 00000 n 0000460567 00000 n 0000464304 00000 n 0000464498 00000 n 0000468426 00000 n 0000468620 00000 n 0000472384 00000 n 0000472578 00000 n 0000476720 00000 n 0000476914 00000 n 0000481285 00000 n 0000481479 00000 n 0000485315 00000 n 0000485509 00000 n 0000489422 00000 n 0000489616 00000 n 0000495033 00000 n 0000495227 00000 n 0000499161 00000 n 0000499355 00000 n 0000503105 00000 n 0000503299 00000 n 0000507185 00000 n 0000507379 00000 n 0000511192 00000 n 0000511386 00000 n 0000515040 00000 n 0000515234 00000 n 0000518935 00000 n 0000519130 00000 n 0000522781 00000 n 0000522976 00000 n 0000526683 00000 n 0000526878 00000 n 0000530883 00000 n 0000531078 00000 n 0000534054 00000 n 0000534251 00000 n 0000535738 00000 n 0000535944 00000 n 0000537987 00000 n 0000538182 00000 n 0000540287 00000 n 0000540482 00000 n 0000542444 00000 n 0000542659 00000 n 0000545239 00000 n 0000545418 00000 n 0000546188 00000 n 0000546385 00000 n 0000548554 00000 n 0000548744 00000 n 0000550713 00000 n 0000550901 00000 n 0000552311 00000 n 0000552510 00000 n 0000554200 00000 n 0000554395 00000 n 0000556512 00000 n 0000556682 00000 n 0000557629 00000 n 0000557835 00000 n 0000560166 00000 n 0000560363 00000 n 0000561632 00000 n 0000561856 00000 n 0000563757 00000 n 0000563972 00000 n 0000566141 00000 n 0000566310 00000 n 0000566834 00000 n 0000567063 00000 n 0000569028 00000 n 0000569218 00000 n 0000570674 00000 n 0000570853 00000 n 0000572286 00000 n 0000572465 00000 n 0000573864 00000 n 0000574054 00000 n 0000575929 00000 n 0000576135 00000 n 0000578952 00000 n 0000579149 00000 n 0000580864 00000 n 0000581068 00000 n 0000583092 00000 n 0000583298 00000 n 0000585282 00000 n 0000585497 00000 n 0000587039 00000 n 0000587218 00000 n 0000589250 00000 n 0000589445 00000 n 0000591401 00000 n 0000591589 00000 n 0000593677 00000 n 0000593890 00000 n 0000595996 00000 n 0000596195 00000 n 0000598256 00000 n 0000598444 00000 n 0000600069 00000 n 0000600248 00000 n 0000601683 00000 n 0000601862 00000 n 0000603384 00000 n 0000603581 00000 n 0000605166 00000 n 0000605363 00000 n 0000607029 00000 n 0000607224 00000 n 0000608570 00000 n 0000608758 00000 n 0000610509 00000 n 0000610697 00000 n 0000613205 00000 n 0000613399 00000 n 0000615729 00000 n 0000615924 00000 n 0000617888 00000 n 0000618092 00000 n 0000619894 00000 n 0000620063 00000 n 0000621322 00000 n 0000621517 00000 n 0000622848 00000 n 0000623027 00000 n 0000624376 00000 n 0000624580 00000 n 0000626099 00000 n 0000626296 00000 n 0000627907 00000 n 0000628095 00000 n 0000629658 00000 n 0000629827 00000 n 0000630744 00000 n 0000630913 00000 n 0000632161 00000 n 0000632349 00000 n 0000633569 00000 n 0000633784 00000 n 0000635701 00000 n 0000635900 00000 n 0000637261 00000 n 0000637451 00000 n 0000639201 00000 n 0000639407 00000 n 0000641141 00000 n 0000641340 00000 n 0000642933 00000 n 0000643130 00000 n 0000645829 00000 n 0000646019 00000 n 0000648422 00000 n 0000648637 00000 n 0000650338 00000 n 0000650517 00000 n 0000651638 00000 n 0000651827 00000 n 0000653400 00000 n 0000653590 00000 n 0000654970 00000 n 0000655175 00000 n 0000656984 00000 n 0000657188 00000 n 0000658765 00000 n 0000658978 00000 n 0000660388 00000 n 0000660592 00000 n 0000661946 00000 n 0000662149 00000 n 0000664096 00000 n 0000664300 00000 n 0000666279 00000 n 0000666474 00000 n 0000667953 00000 n 0000668132 00000 n 0000669233 00000 n 0000669421 00000 n 0000671097 00000 n 0000671285 00000 n 0000672659 00000 n 0000672872 00000 n 0000674935 00000 n 0000675113 00000 n 0000676770 00000 n 0000676949 00000 n 0000678261 00000 n 0000678449 00000 n 0000679593 00000 n 0000679799 00000 n 0000681694 00000 n 0000681863 00000 n 0000683042 00000 n 0000683247 00000 n 0000684977 00000 n 0000685157 00000 n 0000686582 00000 n 0000686797 00000 n 0000688468 00000 n 0000688646 00000 n 0000690037 00000 n 0000690227 00000 n 0000691793 00000 n 0000691997 00000 n 0000693709 00000 n 0000693878 00000 n 0000695178 00000 n 0000695347 00000 n 0000696903 00000 n 0000697072 00000 n 0000698596 00000 n 0000698774 00000 n 0000700147 00000 n 0000700325 00000 n 0000701289 00000 n 0000701458 00000 n 0000702708 00000 n 0000702886 00000 n 0000703996 00000 n 0000704200 00000 n 0000706031 00000 n 0000706200 00000 n 0000707353 00000 n 0000707531 00000 n 0000709072 00000 n 0000709259 00000 n 0000710741 00000 n 0000710928 00000 n 0000712269 00000 n 0000712473 00000 n 0000714015 00000 n 0000714194 00000 n 0000715248 00000 n 0000715443 00000 n 0000717279 00000 n 0000717467 00000 n 0000718991 00000 n 0000719171 00000 n 0000720646 00000 n 0000720834 00000 n 0000721804 00000 n 0000721998 00000 n 0000723656 00000 n 0000723835 00000 n 0000724933 00000 n 0000725148 00000 n 0000726681 00000 n 0000726866 00000 n 0000728338 00000 n 0000728526 00000 n 0000730310 00000 n 0000730480 00000 n 0000730872 00000 n 0000731078 00000 n 0000733131 00000 n 0000733321 00000 n 0000734746 00000 n 0000734936 00000 n 0000736422 00000 n 0000736626 00000 n 0000737948 00000 n 0000738127 00000 n 0000739143 00000 n 0000739358 00000 n 0000741547 00000 n 0000741735 00000 n 0000742941 00000 n 0000743138 00000 n 0000744768 00000 n 0000744946 00000 n 0000746156 00000 n 0000746362 00000 n 0000747851 00000 n 0000748048 00000 n 0000749109 00000 n 0000749315 00000 n 0000750917 00000 n 0000751121 00000 n 0000752726 00000 n 0000752922 00000 n 0000754271 00000 n 0000754467 00000 n 0000755861 00000 n 0000756048 00000 n 0000757317 00000 n 0000757525 00000 n 0000759568 00000 n 0000759747 00000 n 0000760913 00000 n 0000761093 00000 n 0000762513 00000 n 0000762701 00000 n 0000764187 00000 n 0000764366 00000 n 0000765960 00000 n 0000766154 00000 n 0000767631 00000 n 0000767828 00000 n 0000768800 00000 n 0000769006 00000 n 0000770791 00000 n 0000770970 00000 n 0000772236 00000 n 0000772415 00000 n 0000773384 00000 n 0000773572 00000 n 0000774880 00000 n 0000775059 00000 n 0000776445 00000 n 0000776614 00000 n 0000777015 00000 n 0000777212 00000 n 0000779566 00000 n 0000779790 00000 n 0000781909 00000 n 0000782097 00000 n 0000783740 00000 n 0000783928 00000 n 0000785494 00000 n 0000785700 00000 n 0000787109 00000 n 0000787326 00000 n 0000788603 00000 n 0000788827 00000 n 0000790913 00000 n 0000791107 00000 n 0000792585 00000 n 0000792764 00000 n 0000793842 00000 n 0000794030 00000 n 0000795165 00000 n 0000795355 00000 n 0000796970 00000 n 0000797158 00000 n 0000798279 00000 n 0000798457 00000 n 0000799809 00000 n 0000800004 00000 n 0000801911 00000 n 0000802115 00000 n 0000803954 00000 n 0000804123 00000 n 0000805294 00000 n 0000805500 00000 n 0000806879 00000 n 0000807064 00000 n 0000808812 00000 n 0000809002 00000 n 0000810351 00000 n 0000810539 00000 n 0000812034 00000 n 0000812222 00000 n 0000813406 00000 n 0000813593 00000 n 0000815577 00000 n 0000815772 00000 n 0000817469 00000 n 0000817664 00000 n 0000819082 00000 n 0000819295 00000 n 0000821061 00000 n 0000821265 00000 n 0000822742 00000 n 0000822946 00000 n 0000824164 00000 n 0000824359 00000 n 0000825843 00000 n 0000826012 00000 n 0000827148 00000 n 0000827317 00000 n 0000828724 00000 n 0000828912 00000 n 0000830401 00000 n 0000830614 00000 n 0000832361 00000 n 0000832546 00000 n 0000834074 00000 n 0000834262 00000 n 0000835861 00000 n 0000836030 00000 n 0000837397 00000 n 0000837592 00000 n 0000839297 00000 n 0000839482 00000 n 0000840809 00000 n 0000840978 00000 n 0000842460 00000 n 0000842648 00000 n 0000843918 00000 n 0000844108 00000 n 0000845768 00000 n 0000845937 00000 n 0000848268 00000 n 0000848472 00000 n 0000850560 00000 n 0000850739 00000 n 0000851790 00000 n 0000851975 00000 n 0000853508 00000 n 0000853668 00000 n 0000854478 00000 n 0000854702 00000 n 0000856672 00000 n 0000856862 00000 n 0000858604 00000 n 0000858783 00000 n 0000860049 00000 n 0000860264 00000 n 0000862292 00000 n 0000862471 00000 n 0000863635 00000 n 0000863814 00000 n 0000864734 00000 n 0000864929 00000 n 0000866639 00000 n 0000866827 00000 n 0000868103 00000 n 0000868282 00000 n 0000869712 00000 n 0000869891 00000 n 0000871399 00000 n 0000871603 00000 n 0000873127 00000 n 0000873331 00000 n 0000874893 00000 n 0000875088 00000 n 0000876516 00000 n 0000876695 00000 n 0000878148 00000 n 0000878352 00000 n 0000879699 00000 n 0000879868 00000 n 0000880166 00000 n 0000880372 00000 n 0000882067 00000 n 0000882246 00000 n 0000883416 00000 n 0000883595 00000 n 0000884400 00000 n 0000884615 00000 n 0000886420 00000 n 0000886608 00000 n 0000888452 00000 n 0000888631 00000 n 0000890157 00000 n 0000890361 00000 n 0000892400 00000 n 0000892569 00000 n 0000894091 00000 n 0000894295 00000 n 0000896343 00000 n 0000896512 00000 n 0000897783 00000 n 0000897943 00000 n 0000898991 00000 n 0000899170 00000 n 0000900852 00000 n 0000901031 00000 n 0000902724 00000 n 0000902893 00000 n 0000904409 00000 n 0000904615 00000 n 0000906451 00000 n 0000906639 00000 n 0000907944 00000 n 0000908139 00000 n 0000909663 00000 n 0000909862 00000 n 0000911176 00000 n 0000911356 00000 n 0000912503 00000 n 0000912693 00000 n 0000914300 00000 n 0000914490 00000 n 0000915868 00000 n 0000916038 00000 n 0000916326 00000 n 0000916532 00000 n 0000918489 00000 n 0000918668 00000 n 0000920226 00000 n 0000920421 00000 n 0000922913 00000 n 0000923117 00000 n 0000924589 00000 n 0000924795 00000 n 0000926057 00000 n 0000926245 00000 n 0000927902 00000 n 0000928081 00000 n 0000929994 00000 n 0000930173 00000 n 0000932500 00000 n 0000932706 00000 n 0000934697 00000 n 0000934894 00000 n 0000936041 00000 n 0000936238 00000 n 0000938864 00000 n 0000939043 00000 n 0000941081 00000 n 0000941259 00000 n 0000942850 00000 n 0000943038 00000 n 0000944281 00000 n 0000944487 00000 n 0000946353 00000 n 0000946532 00000 n 0000947853 00000 n 0000948032 00000 n 0000949580 00000 n 0000949759 00000 n 0000951058 00000 n 0000951246 00000 n 0000953185 00000 n 0000953364 00000 n 0000954646 00000 n 0000954825 00000 n 0000955885 00000 n 0000956054 00000 n 0000957049 00000 n 0000957219 00000 n 0000957896 00000 n 0000958091 00000 n 0000959945 00000 n 0000960135 00000 n 0000961855 00000 n 0000962024 00000 n 0000962739 00000 n 0000962908 00000 n 0000963771 00000 n 0000963950 00000 n 0000964800 00000 n 0000964979 00000 n 0000966072 00000 n 0000966267 00000 n 0000968074 00000 n 0000968269 00000 n 0000969889 00000 n 0000970079 00000 n 0000971926 00000 n 0000972105 00000 n 0000973347 00000 n 0000973537 00000 n 0000975082 00000 n 0000975272 00000 n 0000976174 00000 n 0000976380 00000 n 0000978369 00000 n 0000978547 00000 n 0000979717 00000 n 0000979911 00000 n 0000981315 00000 n 0000981511 00000 n 0000982884 00000 n 0000983111 00000 n 0000984153 00000 n 0000984322 00000 n 0000985106 00000 n 0000985286 00000 n 0000986558 00000 n 0000986718 00000 n 0000987904 00000 n 0000988073 00000 n 0000989262 00000 n 0000989473 00000 n 0000990288 00000 n 0000990494 00000 n 0000993618 00000 n 0000993814 00000 n 0000995896 00000 n 0000996092 00000 n 0000998242 00000 n 0000998438 00000 n 0001000007 00000 n 0001000231 00000 n 0001002550 00000 n 0001002745 00000 n 0001004711 00000 n 0001004906 00000 n 0001006474 00000 n 0001006678 00000 n 0001008919 00000 n 0001009098 00000 n 0001010372 00000 n 0001010541 00000 n 0001011888 00000 n 0001012083 00000 n 0001013469 00000 n 0001013648 00000 n 0001015285 00000 n 0001015454 00000 n 0001017099 00000 n 0001017294 00000 n 0001018754 00000 n 0001018933 00000 n 0001019994 00000 n 0001020154 00000 n 0001021241 00000 n 0001021410 00000 n 0001023018 00000 n 0001023213 00000 n 0001024948 00000 n 0001025143 00000 n 0001027017 00000 n 0001027212 00000 n 0001028514 00000 n 0001028683 00000 n 0001029923 00000 n 0001030118 00000 n 0001031813 00000 n 0001031993 00000 n 0001033255 00000 n 0001033435 00000 n 0001035281 00000 n 0001035476 00000 n 0001037040 00000 n 0001037246 00000 n 0001039013 00000 n 0001039192 00000 n 0001040384 00000 n 0001040579 00000 n 0001041817 00000 n 0001042041 00000 n 0001044254 00000 n 0001044453 00000 n 0001045973 00000 n 0001046168 00000 n 0001048186 00000 n 0001048392 00000 n 0001050300 00000 n 0001050488 00000 n 0001052662 00000 n 0001052886 00000 n 0001055119 00000 n 0001055288 00000 n 0001055915 00000 n 0001056130 00000 n 0001058722 00000 n 0001058910 00000 n 0001060645 00000 n 0001060840 00000 n 0001062864 00000 n 0001063059 00000 n 0001064867 00000 n 0001065052 00000 n 0001066777 00000 n 0001066990 00000 n 0001068871 00000 n 0001069084 00000 n 0001071320 00000 n 0001071535 00000 n 0001074046 00000 n 0001074261 00000 n 0001076387 00000 n 0001076593 00000 n 0001078699 00000 n 0001078878 00000 n 0001080492 00000 n 0001080680 00000 n 0001082624 00000 n 0001082819 00000 n 0001084575 00000 n 0001084744 00000 n 0001085840 00000 n 0001086046 00000 n 0001087907 00000 n 0001088125 00000 n 0001089865 00000 n 0001090074 00000 n 0001092071 00000 n 0001092305 00000 n 0001094302 00000 n 0001094518 00000 n 0001096621 00000 n 0001096828 00000 n 0001098512 00000 n 0001098690 00000 n 0001099834 00000 n 0001100051 00000 n 0001102132 00000 n 0001102339 00000 n 0001103794 00000 n 0001103972 00000 n 0001104595 00000 n 0001104792 00000 n 0001107426 00000 n 0001107613 00000 n 0001111027 00000 n 0001111222 00000 n 0001113644 00000 n 0001113848 00000 n 0001115877 00000 n 0001116090 00000 n 0001118031 00000 n 0001118226 00000 n 0001120160 00000 n 0001120366 00000 n 0001122642 00000 n 0001122830 00000 n 0001124729 00000 n 0001124917 00000 n 0001126403 00000 n 0001126607 00000 n 0001128134 00000 n 0001128312 00000 n 0001130115 00000 n 0001130294 00000 n 0001131946 00000 n 0001132150 00000 n 0001134438 00000 n 0001134642 00000 n 0001136617 00000 n 0001136805 00000 n 0001138564 00000 n 0001138749 00000 n 0001140530 00000 n 0001140709 00000 n 0001141716 00000 n 0001141895 00000 n 0001143145 00000 n 0001143324 00000 n 0001144727 00000 n 0001144931 00000 n 0001146270 00000 n 0001146465 00000 n 0001148275 00000 n 0001148470 00000 n 0001149990 00000 n 0001150185 00000 n 0001151639 00000 n 0001151843 00000 n 0001153950 00000 n 0001154154 00000 n 0001156003 00000 n 0001156182 00000 n 0001157571 00000 n 0001157756 00000 n 0001159325 00000 n 0001159520 00000 n 0001160856 00000 n 0001161051 00000 n 0001162989 00000 n 0001163193 00000 n 0001165285 00000 n 0001165470 00000 n 0001167058 00000 n 0001167262 00000 n 0001168758 00000 n 0001168953 00000 n 0001170636 00000 n 0001170831 00000 n 0001172067 00000 n 0001172246 00000 n 0001173585 00000 n 0001173780 00000 n 0001175699 00000 n 0001175878 00000 n 0001177670 00000 n 0001177849 00000 n 0001179476 00000 n 0001179664 00000 n 0001181316 00000 n 0001181495 00000 n 0001182982 00000 n 0001183177 00000 n 0001184580 00000 n 0001184765 00000 n 0001186330 00000 n 0001186525 00000 n 0001188238 00000 n 0001188407 00000 n 0001189443 00000 n 0001189638 00000 n 0001191006 00000 n 0001191185 00000 n 0001192586 00000 n 0001192755 00000 n 0001194533 00000 n 0001194728 00000 n 0001196309 00000 n 0001196504 00000 n 0001198098 00000 n 0001198313 00000 n 0001200570 00000 n 0001200749 00000 n 0001202620 00000 n 0001202799 00000 n 0001204113 00000 n 0001204307 00000 n 0001206806 00000 n 0001207000 00000 n 0001209539 00000 n 0001209752 00000 n 0001212567 00000 n 0001212770 00000 n 0001214180 00000 n 0001214393 00000 n 0001216215 00000 n 0001216384 00000 n 0001218012 00000 n 0001218199 00000 n 0001219526 00000 n 0001219721 00000 n 0001221753 00000 n 0001221931 00000 n 0001223501 00000 n 0001223698 00000 n 0001225020 00000 n 0001225215 00000 n 0001226870 00000 n 0001227055 00000 n 0001228561 00000 n 0001228740 00000 n 0001230094 00000 n 0001230289 00000 n 0001231806 00000 n 0001231966 00000 n 0001233151 00000 n 0001233330 00000 n 0001234662 00000 n 0001234841 00000 n 0001236530 00000 n 0001236699 00000 n 0001238097 00000 n 0001238276 00000 n 0001239545 00000 n 0001239714 00000 n 0001241104 00000 n 0001241283 00000 n 0001242774 00000 n 0001242964 00000 n 0001244609 00000 n 0001244778 00000 n 0001246125 00000 n 0001246320 00000 n 0001248197 00000 n 0001248366 00000 n 0001249675 00000 n 0001249854 00000 n 0001251184 00000 n 0001251379 00000 n 0001252777 00000 n 0001252946 00000 n 0001254385 00000 n 0001254600 00000 n 0001256735 00000 n 0001256913 00000 n 0001258489 00000 n 0001258677 00000 n 0001260159 00000 n 0001260338 00000 n 0001261929 00000 n 0001262124 00000 n 0001264220 00000 n 0001264405 00000 n 0001264925 00000 n 0001265149 00000 n 0001267066 00000 n 0001267254 00000 n 0001268495 00000 n 0001268673 00000 n 0001269839 00000 n 0001270042 00000 n 0001271516 00000 n 0001271704 00000 n 0001272903 00000 n 0001273072 00000 n 0001274129 00000 n 0001274298 00000 n 0001275492 00000 n 0001275716 00000 n 0001277398 00000 n 0001277577 00000 n 0001278890 00000 n 0001279069 00000 n 0001279793 00000 n 0001279999 00000 n 0001282501 00000 n 0001282689 00000 n 0001284353 00000 n 0001284532 00000 n 0001286087 00000 n 0001286282 00000 n 0001287988 00000 n 0001288167 00000 n 0001289360 00000 n 0001289529 00000 n 0001290934 00000 n 0001291113 00000 n 0001292633 00000 n 0001292812 00000 n 0001294432 00000 n 0001294611 00000 n 0001295866 00000 n 0001296045 00000 n 0001297132 00000 n 0001297311 00000 n 0001298748 00000 n 0001298927 00000 n 0001300193 00000 n 0001300373 00000 n 0001301873 00000 n 0001302063 00000 n 0001303409 00000 n 0001303604 00000 n 0001304937 00000 n 0001305116 00000 n 0001306282 00000 n 0001306461 00000 n 0001307918 00000 n 0001308113 00000 n 0001309713 00000 n 0001309901 00000 n 0001311469 00000 n 0001311664 00000 n 0001313303 00000 n 0001313491 00000 n 0001315119 00000 n 0001315325 00000 n 0001317348 00000 n 0001317545 00000 n 0001319120 00000 n 0001319308 00000 n 0001320902 00000 n 0001321081 00000 n 0001322906 00000 n 0001323085 00000 n 0001324708 00000 n 0001324914 00000 n 0001327032 00000 n 0001327229 00000 n 0001329857 00000 n 0001330072 00000 n 0001332373 00000 n 0001332572 00000 n 0001335098 00000 n 0001335288 00000 n 0001337529 00000 n 0001337717 00000 n 0001339367 00000 n 0001339591 00000 n 0001341357 00000 n 0001341563 00000 n 0001342820 00000 n 0001343026 00000 n 0001344781 00000 n 0001344987 00000 n 0001347754 00000 n 0001347951 00000 n 0001349896 00000 n 0001350093 00000 n 0001351959 00000 n 0001352149 00000 n 0001354721 00000 n 0001354900 00000 n 0001356417 00000 n 0001356605 00000 n 0001358406 00000 n 0001358603 00000 n 0001360195 00000 n 0001360383 00000 n 0001361586 00000 n 0001361774 00000 n 0001363393 00000 n 0001363581 00000 n 0001365903 00000 n 0001366091 00000 n 0001366987 00000 n 0001367193 00000 n 0001369047 00000 n 0001369260 00000 n 0001370773 00000 n 0001370952 00000 n 0001372288 00000 n 0001372467 00000 n 0001373798 00000 n 0001373977 00000 n 0001375447 00000 n 0001375616 00000 n 0001376594 00000 n 0001376773 00000 n 0001378375 00000 n 0001378554 00000 n 0001379519 00000 n 0001379698 00000 n 0001380794 00000 n 0001380973 00000 n 0001382061 00000 n 0001382240 00000 n 0001383750 00000 n 0001383929 00000 n 0001384956 00000 n 0001385162 00000 n 0001387704 00000 n 0001387899 00000 n 0001389624 00000 n 0001389803 00000 n 0001391410 00000 n 0001391589 00000 n 0001393315 00000 n 0001393503 00000 n 0001395343 00000 n 0001395558 00000 n 0001398040 00000 n 0001398246 00000 n 0001400382 00000 n 0001400577 00000 n 0001401668 00000 n 0001401847 00000 n 0001403395 00000 n 0001403583 00000 n 0001404975 00000 n 0001405154 00000 n 0001406195 00000 n 0001406374 00000 n 0001407604 00000 n 0001407803 00000 n 0001409400 00000 n 0001409579 00000 n 0001410685 00000 n 0001410863 00000 n 0001411925 00000 n 0001412104 00000 n 0001413288 00000 n 0001413492 00000 n 0001414695 00000 n 0001414883 00000 n 0001416340 00000 n 0001416535 00000 n 0001417639 00000 n 0001417827 00000 n 0001419118 00000 n 0001419297 00000 n 0001420616 00000 n 0001420795 00000 n 0001422193 00000 n 0001422372 00000 n 0001423641 00000 n 0001423820 00000 n 0001425224 00000 n 0001425412 00000 n 0001426995 00000 n 0001427164 00000 n 0001428340 00000 n 0001428519 00000 n 0001430230 00000 n 0001430409 00000 n 0001431719 00000 n 0001431914 00000 n 0001433304 00000 n 0001433483 00000 n 0001434459 00000 n 0001434665 00000 n 0001436967 00000 n 0001437162 00000 n 0001438905 00000 n 0001439084 00000 n 0001440363 00000 n 0001440567 00000 n 0001441845 00000 n 0001442033 00000 n 0001443436 00000 n 0001443624 00000 n 0001444719 00000 n 0001444907 00000 n 0001446085 00000 n 0001446273 00000 n 0001447703 00000 n 0001447882 00000 n 0001449318 00000 n 0001449506 00000 n 0001451948 00000 n 0001452127 00000 n 0001454093 00000 n 0001454263 00000 n 0001454843 00000 n 0001455058 00000 n 0001456746 00000 n 0001456934 00000 n 0001458112 00000 n 0001458291 00000 n 0001459068 00000 n 0001459265 00000 n 0001461708 00000 n 0001461923 00000 n 0001464129 00000 n 0001464324 00000 n 0001465814 00000 n 0001466004 00000 n 0001467743 00000 n 0001467947 00000 n 0001470003 00000 n 0001470191 00000 n 0001471989 00000 n 0001472177 00000 n 0001474079 00000 n 0001474274 00000 n 0001476831 00000 n 0001477037 00000 n 0001479285 00000 n 0001479464 00000 n 0001480877 00000 n 0001481072 00000 n 0001482775 00000 n 0001482954 00000 n 0001484714 00000 n 0001484893 00000 n 0001486162 00000 n 0001486331 00000 n 0001487706 00000 n 0001487885 00000 n 0001489009 00000 n 0001489188 00000 n 0001490545 00000 n 0001490724 00000 n 0001491803 00000 n 0001491982 00000 n 0001493078 00000 n 0001493257 00000 n 0001494387 00000 n 0001494582 00000 n 0001495800 00000 n 0001496004 00000 n 0001497574 00000 n 0001497780 00000 n 0001499723 00000 n 0001499912 00000 n 0001501080 00000 n 0001501295 00000 n 0001502886 00000 n 0001503090 00000 n 0001504827 00000 n 0001505012 00000 n 0001506081 00000 n 0001506276 00000 n 0001508135 00000 n 0001508314 00000 n 0001509857 00000 n 0001510045 00000 n 0001512644 00000 n 0001512823 00000 n 0001514365 00000 n 0001514553 00000 n 0001516468 00000 n 0001516647 00000 n 0001518028 00000 n 0001518197 00000 n 0001519780 00000 n 0001519949 00000 n 0001521026 00000 n 0001521205 00000 n 0001522167 00000 n 0001522346 00000 n 0001523577 00000 n 0001523772 00000 n 0001524952 00000 n 0001525121 00000 n 0001526213 00000 n 0001526392 00000 n 0001527581 00000 n 0001527776 00000 n 0001529268 00000 n 0001529463 00000 n 0001531305 00000 n 0001531500 00000 n 0001532928 00000 n 0001533132 00000 n 0001534678 00000 n 0001534866 00000 n 0001535856 00000 n 0001536035 00000 n 0001537269 00000 n 0001537448 00000 n 0001538814 00000 n 0001538993 00000 n 0001540502 00000 n 0001540681 00000 n 0001542025 00000 n 0001542204 00000 n 0001543855 00000 n 0001544052 00000 n 0001546229 00000 n 0001546417 00000 n 0001547707 00000 n 0001547886 00000 n 0001549418 00000 n 0001549624 00000 n 0001551273 00000 n 0001551461 00000 n 0001552685 00000 n 0001552870 00000 n 0001553425 00000 n 0001553631 00000 n 0001555199 00000 n 0001555378 00000 n 0001556382 00000 n 0001556579 00000 n 0001558746 00000 n 0001558943 00000 n 0001561269 00000 n 0001561448 00000 n 0001562966 00000 n 0001563179 00000 n 0001564962 00000 n 0001565152 00000 n 0001567156 00000 n 0001567344 00000 n 0001568714 00000 n 0001568902 00000 n 0001570043 00000 n 0001570240 00000 n 0001571515 00000 n 0001571730 00000 n 0001573104 00000 n 0001573321 00000 n 0001574519 00000 n 0001574713 00000 n 0001576330 00000 n 0001576518 00000 n 0001577642 00000 n 0001577846 00000 n 0001579219 00000 n 0001579407 00000 n 0001580816 00000 n 0001581011 00000 n 0001582358 00000 n 0001582546 00000 n 0001584182 00000 n 0001584370 00000 n 0001585510 00000 n 0001585734 00000 n 0001587533 00000 n 0001587737 00000 n 0001589397 00000 n 0001589610 00000 n 0001591102 00000 n 0001591290 00000 n 0001592323 00000 n 0001592518 00000 n 0001593834 00000 n 0001594003 00000 n 0001595045 00000 n 0001595240 00000 n 0001596540 00000 n 0001596735 00000 n 0001598747 00000 n 0001598951 00000 n 0001600585 00000 n 0001600754 00000 n 0001602083 00000 n 0001602262 00000 n 0001603334 00000 n 0001603522 00000 n 0001604676 00000 n 0001604855 00000 n 0001606379 00000 n 0001606583 00000 n 0001608348 00000 n 0001608527 00000 n 0001610163 00000 n 0001610367 00000 n 0001611666 00000 n 0001611861 00000 n 0001613644 00000 n 0001613839 00000 n 0001615430 00000 n 0001615627 00000 n 0001618018 00000 n 0001618206 00000 n 0001619423 00000 n 0001619611 00000 n 0001621151 00000 n 0001621339 00000 n 0001623051 00000 n 0001623238 00000 n 0001624603 00000 n 0001624790 00000 n 0001626029 00000 n 0001626226 00000 n 0001628298 00000 n 0001628483 00000 n 0001629727 00000 n 0001629915 00000 n 0001631550 00000 n 0001631747 00000 n 0001633438 00000 n 0001633625 00000 n 0001635403 00000 n 0001635607 00000 n 0001636800 00000 n 0001637006 00000 n 0001638556 00000 n 0001638762 00000 n 0001640718 00000 n 0001640914 00000 n 0001642308 00000 n 0001642496 00000 n 0001643496 00000 n 0001643674 00000 n 0001644608 00000 n 0001644802 00000 n 0001646279 00000 n 0001646483 00000 n 0001648067 00000 n 0001648261 00000 n 0001649557 00000 n 0001649761 00000 n 0001651420 00000 n 0001651598 00000 n 0001652862 00000 n 0001653050 00000 n 0001654791 00000 n 0001654997 00000 n 0001657344 00000 n 0001657539 00000 n 0001659314 00000 n 0001659502 00000 n 0001661243 00000 n 0001661422 00000 n 0001663284 00000 n 0001663463 00000 n 0001665405 00000 n 0001665595 00000 n 0001667401 00000 n 0001667580 00000 n 0001669085 00000 n 0001669280 00000 n 0001670438 00000 n 0001670633 00000 n 0001672228 00000 n 0001672407 00000 n 0001673919 00000 n 0001674088 00000 n 0001675418 00000 n 0001675587 00000 n 0001676771 00000 n 0001676950 00000 n 0001677916 00000 n 0001678095 00000 n 0001679305 00000 n 0001679484 00000 n 0001680656 00000 n 0001680835 00000 n 0001682203 00000 n 0001682398 00000 n 0001683642 00000 n 0001683837 00000 n 0001685264 00000 n 0001685443 00000 n 0001686645 00000 n 0001686814 00000 n 0001688020 00000 n 0001688199 00000 n 0001689176 00000 n 0001689355 00000 n 0001690563 00000 n 0001690732 00000 n 0001691738 00000 n 0001691933 00000 n 0001693484 00000 n 0001693663 00000 n 0001695058 00000 n 0001695253 00000 n 0001696428 00000 n 0001696607 00000 n 0001697802 00000 n 0001697990 00000 n 0001699208 00000 n 0001699396 00000 n 0001700447 00000 n 0001700626 00000 n 0001702149 00000 n 0001702328 00000 n 0001703527 00000 n 0001703706 00000 n 0001705238 00000 n 0001705433 00000 n 0001706796 00000 n 0001706993 00000 n 0001709204 00000 n 0001709412 00000 n 0001711606 00000 n 0001711814 00000 n 0001713800 00000 n 0001713988 00000 n 0001716156 00000 n 0001716344 00000 n 0001717776 00000 n 0001717936 00000 n 0001718667 00000 n 0001718827 00000 n 0001719522 00000 n 0001719701 00000 n 0001721086 00000 n 0001721265 00000 n 0001722357 00000 n 0001722536 00000 n 0001723931 00000 n 0001724121 00000 n 0001725830 00000 n 0001726018 00000 n 0001727309 00000 n 0001727497 00000 n 0001728612 00000 n 0001728800 00000 n 0001730095 00000 n 0001730283 00000 n 0001731684 00000 n 0001731872 00000 n 0001733041 00000 n 0001733229 00000 n 0001734854 00000 n 0001735051 00000 n 0001736924 00000 n 0001737112 00000 n 0001738275 00000 n 0001738463 00000 n 0001739607 00000 n 0001739795 00000 n 0001741274 00000 n 0001741462 00000 n 0001743038 00000 n 0001743226 00000 n 0001744683 00000 n 0001744880 00000 n 0001746627 00000 n 0001746806 00000 n 0001748393 00000 n 0001748583 00000 n 0001749708 00000 n 0001749877 00000 n 0001751199 00000 n 0001751389 00000 n 0001752768 00000 n 0001752957 00000 n 0001754017 00000 n 0001754221 00000 n 0001756278 00000 n 0001756493 00000 n 0001758496 00000 n 0001758709 00000 n 0001760830 00000 n 0001761008 00000 n 0001762431 00000 n 0001762646 00000 n 0001764831 00000 n 0001765026 00000 n 0001767080 00000 n 0001767268 00000 n 0001768272 00000 n 0001768450 00000 n 0001769384 00000 n 0001769562 00000 n 0001770179 00000 n 0001770367 00000 n 0001770977 00000 n 0001771036 00000 n 0001771139 00000 n 0001771299 00000 n 0001771417 00000 n 0001771526 00000 n 0001771655 00000 n 0001771764 00000 n 0001771912 00000 n 0001772014 00000 n 0001772131 00000 n 0001772247 00000 n 0001772365 00000 n 0001772482 00000 n 0001772613 00000 n 0001772748 00000 n 0001772875 00000 n 0001772992 00000 n 0001773104 00000 n 0001773220 00000 n 0001773361 00000 n 0001773474 00000 n 0001773598 00000 n 0001773732 00000 n 0001773846 00000 n 0001773947 00000 n 0001774099 00000 n 0001774202 00000 n 0001774319 00000 n 0001774475 00000 n 0001774586 00000 n 0001774708 00000 n 0001774837 00000 n 0001774967 00000 n 0001775068 00000 n 0001775205 00000 n 0001775341 00000 n 0001775483 00000 n 0001775612 00000 n 0001775718 00000 n 0001775884 00000 n 0001776035 00000 n 0001776131 00000 n 0001776294 00000 n 0001776478 00000 n 0001776574 00000 n 0001776686 00000 n 0001776798 00000 n 0001776912 00000 n 0001777023 00000 n 0001777132 00000 n 0001777230 00000 n 0001777378 00000 n 0001777544 00000 n 0001777702 00000 n 0001777834 00000 n 0001777972 00000 n 0001778096 00000 n 0001778232 00000 n 0001778367 00000 n 0001778526 00000 n 0001778650 00000 n 0001778832 00000 n 0001778941 00000 n 0001779063 00000 n 0001779178 00000 n 0001779306 00000 n 0001779411 00000 n 0001779577 00000 n 0001779705 00000 n 0001779840 00000 n 0001779946 00000 n 0001780097 00000 n 0001780237 00000 n 0001780341 00000 n 0001780458 00000 n 0001780572 00000 n 0001780692 00000 n 0001780813 00000 n 0001780923 00000 n 0001781095 00000 n 0001781206 00000 n 0001781328 00000 n 0001781443 00000 n 0001781573 00000 n 0001781692 00000 n 0001781862 00000 n 0001781969 00000 n 0001782105 00000 n 0001782246 00000 n 0001782371 00000 n 0001782470 00000 n 0001782632 00000 n 0001782751 00000 n 0001782872 00000 n 0001783008 00000 n 0001783131 00000 n 0001783243 00000 n 0001783377 00000 n 0001783555 00000 n 0001783688 00000 n 0001783821 00000 n 0001783959 00000 n 0001784109 00000 n 0001784241 00000 n 0001784368 00000 n 0001784531 00000 n 0001784645 00000 n 0001784783 00000 n 0001784902 00000 n 0001785030 00000 n 0001785166 00000 n 0001785311 00000 n 0001785434 00000 n 0001785571 00000 n 0001785727 00000 n 0001785837 00000 n 0001785964 00000 n 0001786089 00000 n 0001786202 00000 n 0001786360 00000 n 0001786482 00000 n 0001786611 00000 n 0001786750 00000 n 0001786886 00000 n 0001787002 00000 n 0001787155 00000 n 0001787269 00000 n 0001787381 00000 n 0001787507 00000 n 0001787647 00000 n 0001787802 00000 n 0001787923 00000 n 0001788059 00000 n 0001788176 00000 n 0001788337 00000 n 0001788457 00000 n 0001788627 00000 n 0001788773 00000 n 0001788896 00000 n 0001789018 00000 n 0001789138 00000 n 0001789241 00000 n 0001789362 00000 n 0001789476 00000 n 0001789599 00000 n 0001789711 00000 n 0001789839 00000 n 0001789968 00000 n 0001790084 00000 n 0001790260 00000 n 0001790444 00000 n 0001790565 00000 n 0001790696 00000 n 0001790836 00000 n 0001790952 00000 n 0001791086 00000 n 0001791206 00000 n 0001791320 00000 n 0001791473 00000 n 0001791585 00000 n 0001791728 00000 n 0001791857 00000 n 0001791994 00000 n 0001792118 00000 n 0001792256 00000 n 0001792410 00000 n 0001792549 00000 n 0001792668 00000 n 0001792809 00000 n 0001792932 00000 n 0001793086 00000 n 0001793190 00000 n 0001793306 00000 n 0001793433 00000 n 0001793552 00000 n 0001793667 00000 n 0001793793 00000 n 0001793963 00000 n 0001794103 00000 n 0001794231 00000 n 0001794360 00000 n 0001794491 00000 n 0001794616 00000 n 0001794768 00000 n 0001794904 00000 n 0001795067 00000 n 0001795169 00000 n 0001795284 00000 n 0001795399 00000 n 0001795498 00000 n 0001795657 00000 n 0001795772 00000 n 0001795897 00000 n 0001796037 00000 n 0001796138 00000 n 0001796295 00000 n 0001796398 00000 n 0001796515 00000 n 0001796635 00000 n 0001796751 00000 n 0001796896 00000 n 0001796985 00000 n 0001797142 00000 n 0001797292 00000 n 0001797396 00000 n 0001797518 00000 n 0001797641 00000 n 0001797770 00000 n 0001797883 00000 n 0001798047 00000 n 0001798164 00000 n 0001798288 00000 n 0001798417 00000 n 0001798567 00000 n 0001798708 00000 n 0001798816 00000 n 0001798931 00000 n 0001799054 00000 n 0001799177 00000 n 0001799315 00000 n 0001799455 00000 n 0001799605 00000 n 0001799722 00000 n 0001799887 00000 n 0001799998 00000 n 0001800118 00000 n 0001800242 00000 n 0001800367 00000 n 0001800481 00000 n 0001800646 00000 n 0001800759 00000 n 0001800893 00000 n 0001801030 00000 n 0001801161 00000 n 0001801308 00000 n 0001801435 00000 n 0001801599 00000 n 0001801697 00000 n 0001801833 00000 n 0001801957 00000 n 0001802111 00000 n 0001802225 00000 n 0001802351 00000 n 0001802517 00000 n 0001802622 00000 n 0001802748 00000 n 0001802868 00000 n 0001802992 00000 n 0001803116 00000 n 0001803238 00000 n 0001803361 00000 n 0001803485 00000 n 0001803609 00000 n 0001803735 00000 n 0001803858 00000 n 0001803982 00000 n 0001804092 00000 n 0001804256 00000 n 0001804368 00000 n 0001804499 00000 n 0001804642 00000 n 0001804794 00000 n 0001804922 00000 n 0001805044 00000 n 0001805205 00000 n 0001805327 00000 n 0001805467 00000 n 0001805636 00000 n 0001805744 00000 n 0001805843 00000 n 0001805973 00000 n 0001806107 00000 n 0001806242 00000 n 0001806366 00000 n 0001806491 00000 n 0001806654 00000 n 0001806817 00000 n 0001806939 00000 n 0001807081 00000 n 0001807211 00000 n 0001807350 00000 n 0001807494 00000 n 0001807633 00000 n 0001807758 00000 n 0001807894 00000 n 0001808058 00000 n 0001808169 00000 n 0001808289 00000 n 0001808413 00000 n 0001808550 00000 n 0001808658 00000 n 0001808808 00000 n 0001808922 00000 n 0001809048 00000 n 0001809194 00000 n 0001809290 00000 n 0001809456 00000 n 0001809559 00000 n 0001809675 00000 n 0001809803 00000 n 0001809943 00000 n 0001810068 00000 n 0001810201 00000 n 0001810325 00000 n 0001810440 00000 n 0001810541 00000 n 0001810699 00000 n 0001810802 00000 n 0001810934 00000 n 0001811062 00000 n 0001811192 00000 n 0001811313 00000 n 0001811428 00000 n 0001811551 00000 n 0001811677 00000 n 0001811844 00000 n 0001811968 00000 n 0001812099 00000 n 0001812230 00000 n 0001812367 00000 n 0001812501 00000 n 0001812644 00000 n 0001812761 00000 n 0001812860 00000 n 0001813021 00000 n 0001813132 00000 n 0001813243 00000 n 0001813369 00000 n 0001813504 00000 n 0001813649 00000 n 0001813764 00000 n 0001813885 00000 n 0001814076 00000 n 0001814171 00000 n 0001814284 00000 n 0001814400 00000 n 0001814520 00000 n 0001814632 00000 n 0001814749 00000 n 0001814867 00000 n 0001814993 00000 n 0001815119 00000 n 0001815242 00000 n 0001815360 00000 n 0001815490 00000 n 0001815611 00000 n 0001815724 00000 n 0001815860 00000 n 0001815973 00000 n 0001816071 00000 n 0001816240 00000 n 0001816375 00000 n 0001816480 00000 n 0001816607 00000 n 0001816740 00000 n 0001816900 00000 n 0001817010 00000 n 0001817133 00000 n 0001817252 00000 n 0001817380 00000 n 0001817504 00000 n 0001817651 00000 n 0001817759 00000 n 0001817919 00000 n 0001818022 00000 n 0001818138 00000 n 0001818254 00000 n 0001818373 00000 n 0001818486 00000 n 0001818672 00000 n 0001818783 00000 n 0001818908 00000 n 0001819044 00000 n 0001819195 00000 n 0001819349 00000 n 0001819481 00000 n 0001819607 00000 n 0001819789 00000 n 0001819893 00000 n 0001820041 00000 n 0001820191 00000 n 0001820306 00000 n 0001820428 00000 n 0001820554 00000 n 0001820705 00000 n 0001820870 00000 n 0001820975 00000 n 0001821095 00000 n 0001821203 00000 n 0001821380 00000 n 0001821486 00000 n 0001821607 00000 n 0001821731 00000 n 0001821856 00000 n 0001821968 00000 n 0001822099 00000 n 0001822258 00000 n 0001822391 00000 n 0001822575 00000 n 0001822693 00000 n 0001822828 00000 n 0001822963 00000 n 0001823108 00000 n 0001823258 00000 n 0001823415 00000 n 0001823514 00000 n 0001823673 00000 n 0001823787 00000 n 0001823910 00000 n 0001824034 00000 n 0001824141 00000 n 0001824239 00000 n 0001824391 00000 n 0001824494 00000 n 0001824629 00000 n 0001824747 00000 n 0001824899 00000 n 0001825017 00000 n 0001825179 00000 n 0001825300 00000 n 0001825456 00000 n 0001825591 00000 n 0001825735 00000 n 0001825893 00000 n 0001826024 00000 n 0001826179 00000 n 0001826289 00000 n 0001826420 00000 n 0001826529 00000 n 0001826651 00000 n 0001826799 00000 n 0001826955 00000 n 0001827115 00000 n 0001827287 00000 n 0001827451 00000 n 0001827638 00000 n 0001827789 00000 n 0001827943 00000 n 0001828061 00000 n 0001828218 00000 n 0001828360 00000 n 0001828475 00000 n 0001828592 00000 n 0001828750 00000 n 0001828861 00000 n 0001828975 00000 n 0001829105 00000 n 0001829221 00000 n 0001829324 00000 n 0001829437 00000 n 0001829587 00000 n 0001829734 00000 n 0001829877 00000 n 0001830013 00000 n 0001830126 00000 n 0001830277 00000 n 0001830374 00000 n 0001830542 00000 n 0001830667 00000 n 0001830819 00000 n 0001830922 00000 n 0001831050 00000 n 0001831201 00000 n 0001831318 00000 n 0001831445 00000 n 0001831584 00000 n 0001831727 00000 n 0001831852 00000 n 0001831982 00000 n 0001832098 00000 n 0001832212 00000 n 0001832324 00000 n 0001832441 00000 n 0001832557 00000 n 0001832714 00000 n 0001832844 00000 n 0001832973 00000 n 0001833100 00000 n 0001833215 00000 n 0001833338 00000 n 0001833467 00000 n 0001833619 00000 n 0001833718 00000 n 0001833881 00000 n 0001834004 00000 n 0001834112 00000 n 0001834272 00000 n 0001834380 00000 n 0001834495 00000 n 0001834614 00000 n 0001834736 00000 n 0001834891 00000 n 0001834992 00000 n 0001835111 00000 n 0001835237 00000 n 0001835378 00000 n 0001835501 00000 n 0001835620 00000 n 0001835776 00000 n 0001835891 00000 n 0001836015 00000 n 0001836136 00000 n 0001836286 00000 n 0001836393 00000 n 0001836515 00000 n 0001836649 00000 n 0001836793 00000 n 0001836902 00000 n 0001837025 00000 n 0001837138 00000 n 0001837316 00000 n 0001837414 00000 n 0001837525 00000 n 0001837648 00000 n 0001837776 00000 n 0001837905 00000 n 0001838054 00000 n 0001838161 00000 n 0001838262 00000 n 0001838417 00000 n 0001838516 00000 n 0001838672 00000 n 0001838777 00000 n 0001838914 00000 n 0001839051 00000 n 0001839184 00000 n 0001839308 00000 n 0001839439 00000 n 0001839589 00000 n 0001839739 00000 n 0001839865 00000 n 0001839971 00000 n 0001840145 00000 n 0001840282 00000 n 0001840398 00000 n 0001840521 00000 n 0001840637 00000 n 0001840794 00000 n 0001840904 00000 n 0001841027 00000 n 0001841153 00000 n 0001841279 00000 n 0001841386 00000 n 0001841501 00000 n 0001841618 00000 n 0001841736 00000 n 0001841858 00000 n 0001842050 00000 n 0001842145 00000 n 0001842277 00000 n 0001842406 00000 n 0001842528 00000 n 0001842649 00000 n 0001842761 00000 n 0001842949 00000 n 0001843106 00000 n 0001843221 00000 n 0001843387 00000 n 0001843497 00000 n 0001843660 00000 n 0001843772 00000 n 0001843892 00000 n 0001844037 00000 n 0001844227 00000 n 0001844368 00000 n 0001844495 00000 n 0001844638 00000 n 0001844754 00000 n 0001844887 00000 n 0001845006 00000 n 0001845192 00000 n 0001845303 00000 n 0001845426 00000 n 0001845556 00000 n 0001845687 00000 n 0001845819 00000 n 0001845939 00000 n 0001846071 00000 n 0001846243 00000 n 0001846358 00000 n 0001846493 00000 n 0001846653 00000 n 0001846785 00000 n 0001846947 00000 n 0001847107 00000 n 0001847229 00000 n 0001847370 00000 n 0001847495 00000 n 0001847624 00000 n 0001847769 00000 n 0001847926 00000 n 0001848050 00000 n 0001848197 00000 n 0001848323 00000 n 0001848448 00000 n 0001848601 00000 n 0001848731 00000 n 0001848860 00000 n 0001849006 00000 n 0001849131 00000 n 0001849251 00000 n 0001849412 00000 n 0001849555 00000 n 0001849719 00000 n 0001849883 00000 n 0001850031 00000 n 0001850184 00000 n 0001850326 00000 n 0001850483 00000 n 0001850634 00000 n 0001850784 00000 n 0001850918 00000 n 0001851090 00000 n 0001851252 00000 n 0001851414 00000 n 0001851546 00000 n 0001851703 00000 n 0001851813 00000 n 0001851963 00000 n 0001852099 00000 n 0001852237 00000 n 0001852340 00000 n 0001852445 00000 n 0001852606 00000 n 0001852716 00000 n 0001852900 00000 n 0001853023 00000 n 0001853154 00000 n 0001853298 00000 n 0001853431 00000 n 0001853579 00000 n 0001853702 00000 n 0001853820 00000 n 0001853915 00000 n 0001854068 00000 n 0001854172 00000 n 0001854327 00000 n 0001854451 00000 n 0001854595 00000 n 0001854728 00000 n 0001854838 00000 n 0001855012 00000 n 0001855112 00000 n 0001855228 00000 n 0001855351 00000 n 0001855477 00000 n 0001855592 00000 n 0001855709 00000 n 0001855827 00000 n 0001855949 00000 n 0001856096 00000 n 0001856228 00000 n 0001856349 00000 n 0001856485 00000 n 0001856627 00000 n 0001856748 00000 n 0001856874 00000 n 0001856982 00000 n 0001857133 00000 n 0001857244 00000 n 0001857365 00000 n 0001857491 00000 n 0001857622 00000 n 0001857781 00000 n 0001857896 00000 n 0001858005 00000 n 0001858178 00000 n 0001858303 00000 n 0001858422 00000 n 0001858577 00000 n 0001858706 00000 n 0001858836 00000 n 0001858946 00000 n 0001859104 00000 n 0001859241 00000 n 0001859330 00000 n 0001859483 00000 n 0001859601 00000 n 0001859721 00000 n 0001859877 00000 n 0001859979 00000 n 0001860102 00000 n 0001860262 00000 n 0001860373 00000 n 0001860509 00000 n 0001860623 00000 n 0001860737 00000 n 0001860854 00000 n 0001860954 00000 n 0001861124 00000 n 0001861225 00000 n 0001861325 00000 n 0001861423 00000 n 0001861588 00000 n 0001861705 00000 n 0001861824 00000 n 0001861937 00000 n 0001862092 00000 n 0001862234 00000 n 0001862339 00000 n 0001862464 00000 n 0001862588 00000 n 0001862712 00000 n 0001862848 00000 n 0001863008 00000 n 0001863121 00000 n 0001863271 00000 n 0001863372 00000 n 0001863523 00000 n 0001863648 00000 n 0001863785 00000 n 0001863909 00000 n 0001864057 00000 n 0001864213 00000 n 0001864337 00000 n 0001864463 00000 n 0001864593 00000 n 0001864702 00000 n 0001864863 00000 n 0001864979 00000 n 0001865115 00000 n 0001865246 00000 n 0001865380 00000 n 0001865552 00000 n 0001865679 00000 n 0001865807 00000 n 0001865924 00000 n 0001866027 00000 n 0001866183 00000 n 0001866287 00000 n 0001866442 00000 n 0001866555 00000 n 0001866688 00000 n 0001866798 00000 n 0001866958 00000 n 0001867058 00000 n 0001867174 00000 n 0001867297 00000 n 0001867423 00000 n 0001867538 00000 n 0001867671 00000 n 0001867793 00000 n 0001867924 00000 n 0001868044 00000 n 0001868180 00000 n 0001868301 00000 n 0001868427 00000 n 0001868577 00000 n 0001868692 00000 n 0001868817 00000 n 0001868936 00000 n 0001869045 00000 n 0001869201 00000 n 0001869300 00000 n 0001869456 00000 n 0001869579 00000 n 0001869712 00000 n 0001869859 00000 n 0001869999 00000 n 0001870122 00000 n 0001870272 00000 n 0001870395 00000 n 0001870576 00000 n 0001870703 00000 n 0001870817 00000 n 0001870984 00000 n 0001871086 00000 n 0001871209 00000 n 0001871325 00000 n 0001871440 00000 n 0001871557 00000 n 0001871675 00000 n 0001871811 00000 n 0001871942 00000 n 0001872058 00000 n 0001872172 00000 n 0001872304 00000 n 0001872427 00000 n 0001872603 00000 n 0001872720 00000 n 0001872841 00000 n 0001872965 00000 n 0001873074 00000 n 0001873233 00000 n 0001873363 00000 n 0001873483 00000 n 0001873621 00000 n 0001873761 00000 n 0001873907 00000 n 0001874016 00000 n 0001874172 00000 n 0001874278 00000 n 0001874413 00000 n 0001874536 00000 n 0001874657 00000 n 0001874779 00000 n 0001874897 00000 n 0001875017 00000 n 0001875136 00000 n 0001875289 00000 n 0001875443 00000 n 0001875565 00000 n 0001875678 00000 n 0001875840 00000 n 0001875942 00000 n 0001876065 00000 n 0001876181 00000 n 0001876299 00000 n 0001876429 00000 n 0001876600 00000 n 0001876709 00000 n 0001876846 00000 n 0001876978 00000 n 0001877096 00000 n 0001877227 00000 n 0001877383 00000 n 0001877494 00000 n 0001877617 00000 n 0001877756 00000 n 0001877882 00000 n 0001878012 00000 n 0001878127 00000 n 0001878233 00000 n 0001878387 00000 n 0001878529 00000 n 0001878634 00000 n 0001878771 00000 n 0001878881 00000 n 0001879029 00000 n 0001879129 00000 n 0001879245 00000 n 0001879368 00000 n 0001879505 00000 n 0001879640 00000 n 0001879747 00000 n 0001879904 00000 n 0001880003 00000 n 0001880159 00000 n 0001880264 00000 n 0001880386 00000 n 0001880524 00000 n 0001880645 00000 n 0001880769 00000 n 0001880905 00000 n 0001881042 00000 n 0001881175 00000 n 0001881349 00000 n 0001881449 00000 n 0001881565 00000 n 0001881688 00000 n 0001881814 00000 n 0001881929 00000 n 0001882046 00000 n 0001882164 00000 n 0001882286 00000 n 0001882433 00000 n 0001882565 00000 n 0001882686 00000 n 0001882808 00000 n 0001882929 00000 n 0001883055 00000 n 0001883178 00000 n 0001883366 00000 n 0001883472 00000 n 0001883631 00000 n 0001883737 00000 n 0001883863 00000 n 0001883987 00000 n 0001884110 00000 n 0001884280 00000 n 0001884391 00000 n 0001884514 00000 n 0001884653 00000 n 0001884779 00000 n 0001884909 00000 n 0001885024 00000 n 0001885130 00000 n 0001885302 00000 n 0001885417 00000 n 0001885553 00000 n 0001885688 00000 n 0001885815 00000 n 0001885977 00000 n 0001886097 00000 n 0001886219 00000 n 0001886344 00000 n 0001886452 00000 n 0001886603 00000 n 0001886714 00000 n 0001886836 00000 n 0001886960 00000 n 0001887076 00000 n 0001887235 00000 n 0001887363 00000 n 0001887519 00000 n 0001887660 00000 n 0001887806 00000 n 0001887942 00000 n 0001888051 00000 n 0001888213 00000 n 0001888323 00000 n 0001888490 00000 n 0001888612 00000 n 0001888748 00000 n 0001888884 00000 n 0001889020 00000 n 0001889150 00000 n 0001889267 00000 n 0001889388 00000 n 0001889534 00000 n 0001889647 00000 n 0001889771 00000 n 0001889886 00000 n 0001890037 00000 n 0001890132 00000 n 0001890253 00000 n 0001890384 00000 n 0001890503 00000 n 0001890628 00000 n 0001890744 00000 n 0001890847 00000 n 0001891002 00000 n 0001891144 00000 n 0001891249 00000 n 0001891386 00000 n 0001891519 00000 n 0001891643 00000 n 0001891764 00000 n 0001891886 00000 n 0001892073 00000 n 0001892186 00000 n 0001892355 00000 n 0001892455 00000 n 0001892571 00000 n 0001892694 00000 n 0001892810 00000 n 0001892925 00000 n 0001893042 00000 n 0001893160 00000 n 0001893282 00000 n 0001893413 00000 n 0001893534 00000 n 0001893656 00000 n 0001893777 00000 n 0001893922 00000 n 0001894046 00000 n 0001894171 00000 n 0001894297 00000 n 0001894456 00000 n 0001894557 00000 n 0001894706 00000 n 0001894815 00000 n 0001894939 00000 n 0001895058 00000 n 0001895170 00000 n 0001895302 00000 n 0001895463 00000 n 0001895586 00000 n 0001895713 00000 n 0001895838 00000 n 0001895948 00000 n 0001896100 00000 n 0001896211 00000 n 0001896331 00000 n 0001896455 00000 n 0001896580 00000 n 0001896708 00000 n 0001896867 00000 n 0001896974 00000 n 0001897102 00000 n 0001897224 00000 n 0001897350 00000 n 0001897476 00000 n 0001897600 00000 n 0001897725 00000 n 0001897851 00000 n 0001897977 00000 n 0001898105 00000 n 0001898230 00000 n 0001898356 00000 n 0001898482 00000 n 0001898610 00000 n 0001898739 00000 n 0001898871 00000 n 0001898992 00000 n 0001899104 00000 n 0001899228 00000 n 0001899389 00000 n 0001899511 00000 n 0001899647 00000 n 0001899772 00000 n 0001899891 00000 n 0001899995 00000 n 0001900118 00000 n 0001900262 00000 n 0001900400 00000 n 0001900562 00000 n 0001900666 00000 n 0001900793 00000 n 0001900954 00000 n 0001901063 00000 n 0001901229 00000 n 0001901350 00000 n 0001901485 00000 n 0001901620 00000 n 0001901755 00000 n 0001901884 00000 n 0001902000 00000 n 0001902158 00000 n 0001902271 00000 n 0001902408 00000 n 0001902525 00000 n 0001902672 00000 n 0001902798 00000 n 0001902922 00000 n 0001903045 00000 n 0001903167 00000 n 0001903289 00000 n 0001903414 00000 n 0001903568 00000 n 0001903710 00000 n 0001903833 00000 n 0001903966 00000 n 0001904087 00000 n 0001904211 00000 n 0001904347 00000 n 0001904484 00000 n 0001904615 00000 n 0001904724 00000 n 0001904913 00000 n 0001905040 00000 n 0001905144 00000 n 0001905318 00000 n 0001905418 00000 n 0001905534 00000 n 0001905657 00000 n 0001905783 00000 n 0001905898 00000 n 0001906015 00000 n 0001906133 00000 n 0001906255 00000 n 0001906402 00000 n 0001906534 00000 n 0001906655 00000 n 0001906777 00000 n 0001906898 00000 n 0001907010 00000 n 0001907195 00000 n 0001907301 00000 n 0001907411 00000 n 0001907543 00000 n 0001907666 00000 n 0001907817 00000 n 0001907928 00000 n 0001908047 00000 n 0001908171 00000 n 0001908312 00000 n 0001908448 00000 n 0001908571 00000 n 0001908695 00000 n 0001908804 00000 n 0001908950 00000 n 0001909140 00000 n 0001909232 00000 n 0001909336 00000 n 0001909503 00000 n 0001909606 00000 n 0001909724 00000 n 0001909844 00000 n 0001910002 00000 n 0001910108 00000 n 0001910222 00000 n 0001910340 00000 n 0001910467 00000 n 0001910587 00000 n 0001910716 00000 n 0001910838 00000 n 0001910943 00000 n 0001911111 00000 n 0001911211 00000 n 0001911324 00000 n 0001911436 00000 n 0001911560 00000 n 0001911698 00000 n 0001911794 00000 n 0001911938 00000 n 0001912066 00000 n 0001912220 00000 n 0001912337 00000 n 0001912461 00000 n 0001912578 00000 n 0001912708 00000 n 0001912822 00000 n 0001912931 00000 n 0001913046 00000 n 0001913216 00000 n 0001913325 00000 n 0001913445 00000 n 0001913573 00000 n 0001913712 00000 n 0001913850 00000 n 0001913989 00000 n 0001914122 00000 n 0001914249 00000 n 0001914372 00000 n 0001914503 00000 n 0001914625 00000 n 0001914814 00000 n 0001914919 00000 n 0001915041 00000 n 0001915221 00000 n 0001915339 00000 n 0001915462 00000 n 0001915593 00000 n 0001915716 00000 n trailer <<3269c666af0815ba87128a71cd260455>]>> startxref 1916764 %%EOF swig-2.0.12/Doc/Manual/android-simple.png0000664000175000017500000001726412275776201020007 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-2.0.12/preinst-swig.in0000775000175000017500000000032612275776201015425 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-2.0.12/CHANGES0000664000175000017500000335452112275776201013446 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 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 conjuction 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 overiddenname -c++ example.i overiddenname: \ 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 Excecution 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 acheive 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 clashings 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. + Depreciate -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 SWIGs 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 Conditionaly compile experimental code with --enable-experiment configure flag. Fix .cvsignore to ignore configrue & 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 staticly 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-2.0.12/LICENSE-UNIVERSITIES0000664000175000017500000001106012275776201015370 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-2.0.12/autogen.sh0000775000175000017500000000111212275776201014432 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-2.0.12/aclocal.m40000664000175000017500000010717112275777512014313 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_path_generic.m4]) swig-2.0.12/CCache/0000775000175000017500000000000012275777524013555 5ustar williamwilliamswig-2.0.12/CCache/test.sh0000775000175000017500000002523412275776201015070 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-2.0.12/CCache/configure.ac0000664000175000017500000000460412275776201016036 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-2.0.12/CCache/unify.c0000664000175000017500000001603012275776201015042 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-2.0.12/CCache/README0000664000175000017500000000125512275776201014427 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-2.0.12/CCache/util.c0000664000175000017500000004140412275776201014670 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-2.0.12/CCache/README.swig0000664000175000017500000000072012275776201015373 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-2.0.12/CCache/ccache-swig.10000664000175000017500000004221412275777524016017 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-2.0.12/CCache/COPYING0000664000175000017500000004307612275776201014611 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-2.0.12/CCache/ccache_swig_config.h.in0000664000175000017500000000005112275776201020102 0ustar williamwilliam#define SWIG_VERSION "@PACKAGE_VERSION@" swig-2.0.12/CCache/ccache.h0000664000175000017500000001101212275776201015116 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-2.0.12/CCache/args.c0000664000175000017500000000454012275776201014647 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-2.0.12/CCache/snprintf.c0000664000175000017500000005346612275776201015571 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-2.0.12/CCache/packaging/0000775000175000017500000000000012275776201015470 5ustar williamwilliamswig-2.0.12/CCache/packaging/README0000664000175000017500000000037312275776201016353 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-2.0.12/CCache/packaging/ccache.spec0000664000175000017500000000133512275776201017554 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-2.0.12/CCache/install-sh0000775000175000017500000001124512275776201015553 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-2.0.12/CCache/cleanup.c0000664000175000017500000001205112275776201015336 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-2.0.12/CCache/execute.c0000664000175000017500000001431412275776201015355 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-2.0.12/CCache/ccache.c0000664000175000017500000010345112275776201015122 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-2.0.12/CCache/mdfour.c0000664000175000017500000001401312275776201015203 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-2.0.12/CCache/ccache.yo0000664000175000017500000004202712275776201015330 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-2.0.12/CCache/stats.c0000664000175000017500000002147512275776201015057 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-2.0.12/CCache/hash.c0000664000175000017500000000332312275776201014634 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-2.0.12/CCache/configure0000775000175000017500000044336312275777517015503 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-2.0.12/CCache/mdfour.h0000664000175000017500000000231112275776201015206 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-2.0.12/CCache/config.h.in0000664000175000017500000000610712275777517015606 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-2.0.12/CCache/Makefile.in0000664000175000017500000000471412275776201015617 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=../../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) # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile docs: $(PACKAGE_NAME).1 web/ccache-man.html $(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(PACKAGE_NAME).1: ccache.yo -yodl2man -o $(PACKAGE_NAME).1 ccache.yo web/ccache-man.html: ccache.yo yodl2html -o web/ccache-man.html ccache.yo install: $(PACKAGE_NAME)$(EXEEXT) $(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) $(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) check : test test: test.sh SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' ./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 $(PACKAGE_NAME).1 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-2.0.12/CCache/web/0000775000175000017500000000000012275776201014321 5ustar williamwilliamswig-2.0.12/CCache/web/index.html0000664000175000017500000001237712275776201016330 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-2.0.12/CCache/debian/0000775000175000017500000000000012275776201014766 5ustar williamwilliamswig-2.0.12/CCache/debian/control0000664000175000017500000000131612275776201016372 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-2.0.12/CCache/debian/watch0000664000175000017500000000007312275776201016017 0ustar williamwilliamversion=2 http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz swig-2.0.12/CCache/debian/dirs0000664000175000017500000000005212275776201015647 0ustar williamwilliamusr/bin usr/lib/ccache usr/share/man/man1 swig-2.0.12/CCache/debian/compat0000664000175000017500000000000212275776201016164 0ustar williamwilliam6 swig-2.0.12/CCache/debian/examples0000664000175000017500000000004512275776201016526 0ustar williamwilliamdebian/update-ccache manage-cache.sh swig-2.0.12/CCache/debian/changelog0000664000175000017500000001637712275776201016656 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-2.0.12/CCache/debian/rules0000664000175000017500000001160112275776201016042 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-2.0.12/CCache/debian/copyright0000664000175000017500000000240612275776201016723 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-2.0.12/CCache/debian/README.Debian0000664000175000017500000000401012275776201017022 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-2.0.12/CCache/debian/docs0000664000175000017500000000000712275776201015636 0ustar williamwilliamREADME swig-2.0.12/CCache/debian/NEWS0000664000175000017500000000164212275776201015470 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-2.0.12/CCache/debian/patches/0000775000175000017500000000000012275776201016415 5ustar williamwilliamswig-2.0.12/CCache/debian/patches/CREDITS0000664000175000017500000000317212275776201017440 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-2.0.12/CCache/debian/patches/02_ccache-compressed.diff0000664000175000017500000007377112275776201023137 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-2.0.12/CCache/debian/patches/05_nfs_fix.diff0000664000175000017500000000230712275776201021211 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-2.0.12/CCache/debian/patches/07_cachedirtag.diff0000664000175000017500000000361012275776201022013 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-2.0.12/CCache/debian/patches/04_ignore_profile.diff0000664000175000017500000000077712275776201022570 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-2.0.12/CCache/debian/patches/14_hardlink_doc.diff0000664000175000017500000000366612275776201022207 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-2.0.12/CCache/debian/patches/13_html_links.diff0000664000175000017500000000222612275776201021720 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-2.0.12/CCache/debian/patches/06_md.diff0000664000175000017500000000422512275776201020157 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-2.0.12/CCache/debian/patches/03_long_options.diff0000664000175000017500000001150412275776201022264 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-2.0.12/CCache/debian/patches/10_lru_cleanup.diff0000664000175000017500000000105712275776201022063 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-2.0.12/CCache/debian/patches/12_cachesize_permissions.diff0000664000175000017500000000374512275776201024153 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-2.0.12/CCache/debian/patches/08_manpage_hyphens.diff0000664000175000017500000000722712275776201022734 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-2.0.12/CCache/debian/patches/11_utimes.diff0000664000175000017500000000460212275776201021060 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-2.0.12/CCache/debian/patches/01_no_home.diff0000664000175000017500000000414212275776201021174 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-2.0.12/CCache/debian/patches/09_respect_ldflags.diff0000664000175000017500000000053612275776201022724 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-2.0.12/CCache/debian/update-ccache0000664000175000017500000000171512275776201017403 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-2.0.12/INSTALL0000664000175000017500000002200512275776201013466 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-2.0.12/Source/0000775000175000017500000000000012275777513013705 5ustar williamwilliamswig-2.0.12/Source/CParse/0000775000175000017500000000000012275777517015066 5ustar williamwilliamswig-2.0.12/Source/CParse/cparse.h0000664000175000017500000000506012275776201016502 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_start_line; extern void Swig_cparse_cplusplus(int); extern void scanner_file(File *); extern void scanner_next_token(int); extern void skip_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); /* 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-2.0.12/Source/CParse/parser.c0000664000175000017500000136333012275777517016537 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 16 "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 *extendhash = 0; /* Hash table of added methods */ 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 int nested_template = 0; /* template class/function definition within a class */ 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; static int max_class_levels = 0; static int class_level = 0; static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- * Assist Functions * ----------------------------------------------------------------------------- */ /* Called by the parser (yyparse) when an error is found.*/ static void yyerror (const char *e) { (void)e; } static 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; } /* 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; } /* 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; static String *class_rename = 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); } } /* 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 (nested_template) { if (!(n && Equal(nodeType(n), "template"))) { return; } /* continue if template function, but not template class, declared within a class */ } 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 (extendmode) { Setattr(n,"isextension","1"); } 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 (!Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]); */ Setattr(n,"ismember","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)) { 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 (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); } } /* 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 */ static void merge_extensions(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); } } static void append_previous_extension(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); } /* Check for unused %extend. Special case, don't report unused extensions for templates */ static void check_extensions() { 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); } } } /* 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; } static List *make_inherit_list(String *clsname, List *names) { 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++) { Node *s; String *base; String *n = Getitem(names,i); /* Try to figure out where this symbol is */ 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; } /* 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; } /* Structures for handling code fragments built for nested classes */ typedef struct Nested { String *code; /* Associated code fragment */ int line; /* line number where it starts */ const char *name; /* Name associated with this nested class */ const char *kind; /* Kind of class */ int unnamed; /* unnamed class */ SwigType *type; /* Datatype associated with the name */ struct Nested *next; /* Next code fragment in list */ } Nested; /* Some internal variables for saving nested class information */ static Nested *nested_list = 0; /* Add a function to the nested list */ static void add_nested(Nested *n) { if (!nested_list) { nested_list = n; } else { Nested *n1 = nested_list; while (n1->next) n1 = n1->next; n1->next = n; } } /* ----------------------------------------------------------------------------- * nested_new_struct() * * Nested struct handling for C code only creates a global struct from the nested struct. * * Nested structure. This is a sick "hack". If we encounter * a nested structure, we're going to grab the text of its definition and * feed it back into the scanner. In the meantime, we need to grab * variable declaration information and generate the associated wrapper * code later. Yikes! * * This really only works in a limited sense. Since we use the * code attached to the nested class to generate both C code * it can't have any SWIG directives in it. It also needs to be parsable * by SWIG or this whole thing is going to puke. * ----------------------------------------------------------------------------- */ static void nested_new_struct(const char *kind, String *struct_code, Node *cpp_opt_declarators) { String *name; String *decl; /* Create a new global struct declaration which is just a copy of the nested struct */ Nested *nested = (Nested *) malloc(sizeof(Nested)); Nested *n = nested; name = Getattr(cpp_opt_declarators, "name"); decl = Getattr(cpp_opt_declarators, "decl"); n->code = NewStringEmpty(); Printv(n->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); n->name = Swig_copy_string(Char(name)); n->line = cparse_start_line; n->type = NewStringEmpty(); n->kind = kind; n->unnamed = 0; SwigType_push(n->type, decl); n->next = 0; /* Repeat for any multiple instances of the nested struct */ { Node *p = cpp_opt_declarators; p = nextSibling(p); while (p) { Nested *nn = (Nested *) malloc(sizeof(Nested)); name = Getattr(p, "name"); decl = Getattr(p, "decl"); nn->code = NewStringEmpty(); Printv(nn->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); nn->name = Swig_copy_string(Char(name)); nn->line = cparse_start_line; nn->type = NewStringEmpty(); nn->kind = kind; nn->unnamed = 0; SwigType_push(nn->type, decl); nn->next = 0; n->next = nn; n = nn; p = nextSibling(p); } } add_nested(nested); } /* ----------------------------------------------------------------------------- * nested_forward_declaration() * * Nested struct handling for C++ code only. * * Treat the nested class/struct/union as a forward declaration until a proper * nested class solution is implemented. * ----------------------------------------------------------------------------- */ 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 (nn && Equal(nodeType(nn), "classforward")) { Node *n = nn; if (GetFlag(n, "feature:nestedworkaround")) { Swig_symbol_remove(n); nn = 0; warned = 1; } else { 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; } /* 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; } } /* Dump all of the nested class declarations to the inline processor * However. We need to do a few name replacements and other munging * first. This function must be called before closing a class! */ static Node *dump_nested(const char *parent) { Nested *n,*n1; Node *ret = 0; Node *last = 0; n = nested_list; if (!parent) { nested_list = 0; return 0; } while (n) { Node *retx; SwigType *nt; /* Token replace the name of the parent class */ Replace(n->code, "$classname", parent, DOH_REPLACE_ANY); /* Fix up the name of the datatype (for building typedefs and other stuff) */ Append(n->type,parent); Append(n->type,"_"); Append(n->type,n->name); /* Add the appropriate declaration to the C++ processor */ retx = new_node("cdecl"); Setattr(retx,"name",n->name); nt = Copy(n->type); Setattr(retx,"type",nt); Delete(nt); Setattr(retx,"nested",parent); if (n->unnamed) { Setattr(retx,"unnamed","1"); } add_symbols(retx); if (ret) { set_nextSibling(last, retx); Delete(retx); } else { ret = retx; } last = retx; /* Strip comments - further code may break in presence of comments. */ strip_comments(Char(n->code)); /* Make all SWIG created typedef structs/unions/classes unnamed else redefinition errors occur - nasty hack alert.*/ { const char* types_array[3] = {"struct", "union", "class"}; int i; for (i=0; i<3; i++) { char* code_ptr = Char(n->code); 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(n->code); 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 = new_node("insert"); String *code = NewStringEmpty(); Wrapper_pretty_print(n->code, code); Setattr(newnode,"code", code); Delete(code); set_nextSibling(last, newnode); Delete(newnode); last = newnode; } /* Dump the code to the scanner */ start_inline(Char(Getattr(last, "code")),n->line); n1 = n->next; Delete(n->code); free(n); n = n1; } nested_list = 0; return ret; } 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); */ 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 (Cmp(Getattr(n,"storage"),"externc") == 0) { 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; } } } /* ----------------------------------------------------------------------------- * tag_nodes() * * Used by the parser to mark subtypes with extra information. * ----------------------------------------------------------------------------- */ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { while (n) { Setattr(n, attrname, value); tag_nodes(firstChild(n), attrname, value); n = nextSibling(n); } } /* Line 268 of yacc.c */ #line 1703 "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, INCLUDE = 262, IMPORT = 263, INSERT = 264, CHARCONST = 265, NUM_INT = 266, NUM_FLOAT = 267, NUM_UNSIGNED = 268, NUM_LONG = 269, NUM_ULONG = 270, NUM_LONGLONG = 271, NUM_ULONGLONG = 272, NUM_BOOL = 273, TYPEDEF = 274, TYPE_INT = 275, TYPE_UNSIGNED = 276, TYPE_SHORT = 277, TYPE_LONG = 278, TYPE_FLOAT = 279, TYPE_DOUBLE = 280, TYPE_CHAR = 281, TYPE_WCHAR = 282, TYPE_VOID = 283, TYPE_SIGNED = 284, TYPE_BOOL = 285, TYPE_COMPLEX = 286, TYPE_TYPEDEF = 287, TYPE_RAW = 288, TYPE_NON_ISO_INT8 = 289, TYPE_NON_ISO_INT16 = 290, TYPE_NON_ISO_INT32 = 291, TYPE_NON_ISO_INT64 = 292, LPAREN = 293, RPAREN = 294, COMMA = 295, SEMI = 296, EXTERN = 297, INIT = 298, LBRACE = 299, RBRACE = 300, PERIOD = 301, CONST_QUAL = 302, VOLATILE = 303, REGISTER = 304, STRUCT = 305, UNION = 306, EQUAL = 307, SIZEOF = 308, MODULE = 309, LBRACKET = 310, RBRACKET = 311, BEGINFILE = 312, ENDOFFILE = 313, ILLEGAL = 314, CONSTANT = 315, NAME = 316, RENAME = 317, NAMEWARN = 318, EXTEND = 319, PRAGMA = 320, FEATURE = 321, VARARGS = 322, ENUM = 323, CLASS = 324, TYPENAME = 325, PRIVATE = 326, PUBLIC = 327, PROTECTED = 328, COLON = 329, STATIC = 330, VIRTUAL = 331, FRIEND = 332, THROW = 333, CATCH = 334, EXPLICIT = 335, USING = 336, NAMESPACE = 337, NATIVE = 338, INLINE = 339, TYPEMAP = 340, EXCEPT = 341, ECHO = 342, APPLY = 343, CLEAR = 344, SWIGTEMPLATE = 345, FRAGMENT = 346, WARN = 347, LESSTHAN = 348, GREATERTHAN = 349, DELETE_KW = 350, LESSTHANOREQUALTO = 351, GREATERTHANOREQUALTO = 352, EQUALTO = 353, NOTEQUALTO = 354, QUESTIONMARK = 355, TYPES = 356, PARMS = 357, NONID = 358, DSTAR = 359, DCNOT = 360, TEMPLATE = 361, OPERATOR = 362, COPERATOR = 363, PARSETYPE = 364, PARSEPARM = 365, PARSEPARMS = 366, CAST = 367, LOR = 368, LAND = 369, OR = 370, XOR = 371, AND = 372, RSHIFT = 373, LSHIFT = 374, MINUS = 375, PLUS = 376, MODULO = 377, SLASH = 378, STAR = 379, LNOT = 380, NOT = 381, UMINUS = 382, DCOLON = 383 }; #endif /* Tokens. */ #define ID 258 #define HBLOCK 259 #define POUND 260 #define STRING 261 #define INCLUDE 262 #define IMPORT 263 #define INSERT 264 #define CHARCONST 265 #define NUM_INT 266 #define NUM_FLOAT 267 #define NUM_UNSIGNED 268 #define NUM_LONG 269 #define NUM_ULONG 270 #define NUM_LONGLONG 271 #define NUM_ULONGLONG 272 #define NUM_BOOL 273 #define TYPEDEF 274 #define TYPE_INT 275 #define TYPE_UNSIGNED 276 #define TYPE_SHORT 277 #define TYPE_LONG 278 #define TYPE_FLOAT 279 #define TYPE_DOUBLE 280 #define TYPE_CHAR 281 #define TYPE_WCHAR 282 #define TYPE_VOID 283 #define TYPE_SIGNED 284 #define TYPE_BOOL 285 #define TYPE_COMPLEX 286 #define TYPE_TYPEDEF 287 #define TYPE_RAW 288 #define TYPE_NON_ISO_INT8 289 #define TYPE_NON_ISO_INT16 290 #define TYPE_NON_ISO_INT32 291 #define TYPE_NON_ISO_INT64 292 #define LPAREN 293 #define RPAREN 294 #define COMMA 295 #define SEMI 296 #define EXTERN 297 #define INIT 298 #define LBRACE 299 #define RBRACE 300 #define PERIOD 301 #define CONST_QUAL 302 #define VOLATILE 303 #define REGISTER 304 #define STRUCT 305 #define UNION 306 #define EQUAL 307 #define SIZEOF 308 #define MODULE 309 #define LBRACKET 310 #define RBRACKET 311 #define BEGINFILE 312 #define ENDOFFILE 313 #define ILLEGAL 314 #define CONSTANT 315 #define NAME 316 #define RENAME 317 #define NAMEWARN 318 #define EXTEND 319 #define PRAGMA 320 #define FEATURE 321 #define VARARGS 322 #define ENUM 323 #define CLASS 324 #define TYPENAME 325 #define PRIVATE 326 #define PUBLIC 327 #define PROTECTED 328 #define COLON 329 #define STATIC 330 #define VIRTUAL 331 #define FRIEND 332 #define THROW 333 #define CATCH 334 #define EXPLICIT 335 #define USING 336 #define NAMESPACE 337 #define NATIVE 338 #define INLINE 339 #define TYPEMAP 340 #define EXCEPT 341 #define ECHO 342 #define APPLY 343 #define CLEAR 344 #define SWIGTEMPLATE 345 #define FRAGMENT 346 #define WARN 347 #define LESSTHAN 348 #define GREATERTHAN 349 #define DELETE_KW 350 #define LESSTHANOREQUALTO 351 #define GREATERTHANOREQUALTO 352 #define EQUALTO 353 #define NOTEQUALTO 354 #define QUESTIONMARK 355 #define TYPES 356 #define PARMS 357 #define NONID 358 #define DSTAR 359 #define DCNOT 360 #define TEMPLATE 361 #define OPERATOR 362 #define COPERATOR 363 #define PARSETYPE 364 #define PARSEPARM 365 #define PARSEPARMS 366 #define CAST 367 #define LOR 368 #define LAND 369 #define OR 370 #define XOR 371 #define AND 372 #define RSHIFT 373 #define LSHIFT 374 #define MINUS 375 #define PLUS 376 #define MODULO 377 #define SLASH 378 #define STAR 379 #define LNOT 380 #define NOT 381 #define UMINUS 382 #define DCOLON 383 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { /* Line 293 of yacc.c */ #line 1647 "parser.y" char *id; List *bases; struct Define { String *val; String *rawval; int type; String *qualifier; String *bitfield; Parm *throws; String *throwf; } dtype; struct { char *type; String *filename; int line; } loc; struct { char *id; SwigType *type; String *defarg; ParmList *parms; short have_parms; ParmList *throws; String *throwf; } 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 2040 "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 2052 "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 55 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 3845 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 129 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 149 /* YYNRULES -- Number of rules. */ #define YYNRULES 470 /* YYNRULES -- Number of states. */ #define YYNSTATES 912 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 383 #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 }; #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, 484, 486, 491, 493, 495, 498, 504, 511, 516, 524, 534, 541, 543, 545, 547, 549, 551, 553, 554, 564, 565, 575, 577, 581, 586, 587, 594, 598, 600, 602, 604, 606, 608, 610, 612, 615, 617, 619, 621, 625, 627, 631, 636, 637, 644, 645, 651, 657, 660, 661, 668, 670, 672, 673, 677, 679, 681, 683, 685, 687, 689, 691, 693, 697, 699, 701, 703, 705, 707, 709, 711, 713, 715, 722, 729, 737, 746, 755, 765, 773, 779, 782, 785, 788, 789, 797, 798, 805, 807, 809, 811, 813, 815, 817, 819, 821, 823, 825, 827, 830, 833, 836, 841, 844, 850, 852, 855, 857, 859, 861, 863, 865, 867, 869, 872, 874, 878, 880, 883, 891, 895, 897, 900, 902, 906, 908, 910, 912, 915, 921, 924, 927, 929, 932, 935, 937, 939, 941, 943, 946, 950, 952, 955, 959, 964, 970, 975, 977, 980, 984, 989, 995, 999, 1004, 1009, 1011, 1014, 1019, 1024, 1030, 1034, 1039, 1044, 1046, 1049, 1052, 1056, 1058, 1061, 1063, 1066, 1070, 1075, 1079, 1084, 1087, 1091, 1095, 1100, 1104, 1108, 1111, 1114, 1116, 1118, 1121, 1123, 1125, 1127, 1129, 1132, 1134, 1137, 1141, 1143, 1145, 1147, 1150, 1153, 1155, 1157, 1160, 1162, 1164, 1167, 1169, 1171, 1173, 1175, 1177, 1179, 1181, 1183, 1185, 1187, 1189, 1191, 1193, 1195, 1196, 1199, 1201, 1203, 1205, 1207, 1213, 1217, 1221, 1223, 1225, 1229, 1231, 1233, 1235, 1237, 1239, 1245, 1247, 1249, 1253, 1258, 1264, 1270, 1277, 1280, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1297, 1299, 1303, 1307, 1311, 1315, 1319, 1323, 1327, 1331, 1335, 1339, 1343, 1347, 1351, 1355, 1359, 1363, 1369, 1372, 1375, 1378, 1381, 1384, 1386, 1387, 1391, 1393, 1395, 1399, 1400, 1404, 1405, 1411, 1413, 1415, 1417, 1419, 1421, 1423, 1425, 1427, 1429, 1431, 1433, 1438, 1444, 1446, 1450, 1454, 1459, 1464, 1468, 1471, 1473, 1475, 1479, 1482, 1486, 1488, 1490, 1492, 1494, 1496, 1499, 1504, 1506, 1510, 1512, 1516, 1520, 1523, 1526, 1529, 1532, 1535, 1540, 1542, 1546, 1548, 1552, 1556, 1559, 1562, 1565, 1568, 1570, 1572, 1574, 1576, 1580, 1582, 1586, 1592, 1594, 1598, 1602, 1608, 1610, 1612 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { 130, 0, -1, 131, -1, 109, 215, 41, -1, 109, 1, -1, 110, 215, 41, -1, 110, 1, -1, 111, 38, 212, 39, 41, -1, 111, 1, 41, -1, 131, 132, -1, 277, -1, 133, -1, 170, -1, 178, -1, 41, -1, 1, -1, 177, -1, 1, 108, -1, 134, -1, 136, -1, 137, -1, 138, -1, 139, -1, 140, -1, 143, -1, 144, -1, 147, -1, 148, -1, 149, -1, 150, -1, 151, -1, 152, -1, 155, -1, 157, -1, 160, -1, 162, -1, 167, -1, 168, -1, 169, -1, -1, 64, 274, 267, 44, 135, 195, 45, -1, 88, 166, 44, 164, 45, -1, 89, 164, 41, -1, 60, 3, 52, 237, 41, -1, 60, 231, 223, 220, 41, -1, 60, 1, 41, -1, 87, 4, -1, 87, 272, -1, 86, 38, 3, 39, 44, -1, 86, 44, -1, 86, 38, 3, 39, 41, -1, 86, 41, -1, 272, 44, 215, 45, -1, 272, -1, 141, -1, 91, 38, 142, 40, 275, 39, 4, -1, 91, 38, 142, 40, 275, 39, 44, -1, 91, 38, 142, 39, 41, -1, -1, 146, 274, 272, 57, 145, 131, 58, -1, 7, -1, 8, -1, 84, 4, -1, 84, 44, -1, 4, -1, 9, 38, 265, 39, 272, -1, 9, 38, 265, 39, 4, -1, 9, 38, 265, 39, 44, -1, 54, 274, 265, -1, 61, 38, 265, 39, -1, 61, 38, 39, -1, 83, 38, 3, 39, 211, 3, 41, -1, 83, 38, 3, 39, 211, 231, 223, 41, -1, 65, 154, 3, 52, 153, -1, 65, 154, 3, -1, 272, -1, 4, -1, 38, 3, 39, -1, 277, -1, 156, 223, 265, 41, -1, 156, 38, 275, 39, 223, 259, 41, -1, 156, 38, 275, 39, 272, 41, -1, 62, -1, 63, -1, 66, 38, 265, 39, 223, 259, 158, -1, 66, 38, 265, 40, 276, 39, 223, 259, 41, -1, 66, 38, 265, 159, 39, 223, 259, 158, -1, 66, 38, 265, 40, 276, 159, 39, 223, 259, 41, -1, 66, 38, 265, 39, 158, -1, 66, 38, 265, 40, 276, 39, 41, -1, 66, 38, 265, 159, 39, 158, -1, 66, 38, 265, 40, 276, 159, 39, 41, -1, 273, -1, 41, -1, 102, 38, 212, 39, 41, -1, 40, 265, 52, 276, -1, 40, 265, 52, 276, 159, -1, 67, 38, 161, 39, 223, 259, 41, -1, 212, -1, 11, 40, 215, -1, 85, 38, 163, 39, 164, 273, -1, 85, 38, 163, 39, 164, 41, -1, 85, 38, 163, 39, 164, 52, 166, 41, -1, 275, -1, 166, 165, -1, 40, 166, 165, -1, 277, -1, 231, 222, -1, 38, 212, 39, -1, 38, 212, 39, 38, 212, 39, -1, 101, 38, 212, 39, 158, -1, 90, 38, 266, 39, 270, 93, 216, 94, 41, -1, 92, 272, -1, 172, -1, 176, -1, 175, -1, -1, 42, 272, 44, 171, 131, 45, -1, 211, 231, 223, 174, 173, -1, 41, -1, 40, 223, 174, 173, -1, 44, -1, 220, -1, 229, 220, -1, 78, 38, 212, 39, 220, -1, 229, 78, 38, 212, 39, 220, -1, 211, 68, 3, 41, -1, 211, 68, 239, 44, 241, 45, 41, -1, 211, 68, 239, 44, 241, 45, 223, 174, 173, -1, 211, 231, 38, 212, 39, 260, -1, 179, -1, 183, -1, 184, -1, 191, -1, 192, -1, 202, -1, -1, 211, 257, 267, 248, 44, 180, 195, 45, 182, -1, -1, 211, 257, 44, 181, 195, 45, 223, 174, 173, -1, 41, -1, 223, 174, 173, -1, 211, 257, 267, 41, -1, -1, 106, 93, 187, 94, 185, 186, -1, 106, 257, 267, -1, 172, -1, 179, -1, 199, -1, 184, -1, 183, -1, 201, -1, 188, -1, 189, 190, -1, 277, -1, 256, -1, 215, -1, 40, 189, 190, -1, 277, -1, 81, 267, 41, -1, 81, 82, 267, 41, -1, -1, 82, 267, 44, 193, 131, 45, -1, -1, 82, 44, 194, 131, 45, -1, 82, 3, 52, 267, 41, -1, 198, 195, -1, -1, 64, 44, 196, 195, 45, 195, -1, 144, -1, 277, -1, -1, 1, 197, 195, -1, 170, -1, 199, -1, 200, -1, 203, -1, 207, -1, 201, -1, 183, -1, 204, -1, 211, 267, 41, -1, 191, -1, 184, -1, 202, -1, 168, -1, 169, -1, 210, -1, 143, -1, 167, -1, 41, -1, 211, 231, 38, 212, 39, 260, -1, 126, 269, 38, 212, 39, 208, -1, 76, 126, 269, 38, 212, 39, 209, -1, 211, 108, 231, 228, 38, 212, 39, 209, -1, 211, 108, 231, 117, 38, 212, 39, 209, -1, 211, 108, 231, 228, 117, 38, 212, 39, 209, -1, 211, 108, 231, 38, 212, 39, 209, -1, 79, 38, 212, 39, 44, -1, 72, 74, -1, 71, 74, -1, 73, 74, -1, -1, 211, 257, 267, 248, 44, 205, 182, -1, -1, 211, 257, 248, 44, 206, 182, -1, 152, -1, 138, -1, 150, -1, 155, -1, 157, -1, 160, -1, 148, -1, 162, -1, 136, -1, 137, -1, 139, -1, 259, 41, -1, 259, 44, -1, 259, 41, -1, 259, 52, 237, 41, -1, 259, 44, -1, 211, 231, 74, 244, 41, -1, 42, -1, 42, 272, -1, 75, -1, 19, -1, 76, -1, 77, -1, 80, -1, 277, -1, 213, -1, 215, 214, -1, 277, -1, 40, 215, 214, -1, 277, -1, 232, 221, -1, 106, 93, 257, 94, 257, 267, 220, -1, 46, 46, 46, -1, 217, -1, 219, 218, -1, 277, -1, 40, 219, 218, -1, 277, -1, 215, -1, 245, -1, 52, 237, -1, 52, 237, 55, 244, 56, -1, 52, 44, -1, 74, 244, -1, 277, -1, 223, 220, -1, 226, 220, -1, 220, -1, 223, -1, 226, -1, 277, -1, 228, 224, -1, 228, 117, 224, -1, 225, -1, 117, 224, -1, 267, 104, 224, -1, 228, 267, 104, 224, -1, 228, 267, 104, 117, 224, -1, 267, 104, 117, 224, -1, 267, -1, 126, 267, -1, 38, 267, 39, -1, 38, 228, 224, 39, -1, 38, 267, 104, 224, 39, -1, 224, 55, 56, -1, 224, 55, 244, 56, -1, 224, 38, 212, 39, -1, 267, -1, 126, 267, -1, 38, 228, 225, 39, -1, 38, 117, 225, 39, -1, 38, 267, 104, 225, 39, -1, 225, 55, 56, -1, 225, 55, 244, 56, -1, 225, 38, 212, 39, -1, 228, -1, 228, 227, -1, 228, 117, -1, 228, 117, 227, -1, 227, -1, 117, 227, -1, 117, -1, 267, 104, -1, 228, 267, 104, -1, 228, 267, 104, 227, -1, 227, 55, 56, -1, 227, 55, 244, 56, -1, 55, 56, -1, 55, 244, 56, -1, 38, 226, 39, -1, 227, 38, 212, 39, -1, 38, 212, 39, -1, 124, 229, 228, -1, 124, 228, -1, 124, 229, -1, 124, -1, 230, -1, 230, 229, -1, 47, -1, 48, -1, 49, -1, 232, -1, 229, 233, -1, 233, -1, 233, 229, -1, 229, 233, 229, -1, 234, -1, 30, -1, 28, -1, 32, 264, -1, 68, 267, -1, 33, -1, 267, -1, 257, 267, -1, 235, -1, 236, -1, 236, 235, -1, 20, -1, 22, -1, 23, -1, 26, -1, 27, -1, 24, -1, 25, -1, 29, -1, 21, -1, 31, -1, 34, -1, 35, -1, 36, -1, 37, -1, -1, 238, 244, -1, 3, -1, 277, -1, 138, -1, 277, -1, 241, 40, 240, 242, 240, -1, 241, 40, 240, -1, 240, 242, 240, -1, 240, -1, 3, -1, 3, 52, 243, -1, 244, -1, 245, -1, 231, -1, 246, -1, 272, -1, 53, 38, 231, 221, 39, -1, 247, -1, 10, -1, 38, 244, 39, -1, 38, 244, 39, 244, -1, 38, 244, 228, 39, 244, -1, 38, 244, 117, 39, 244, -1, 38, 244, 228, 117, 39, 244, -1, 117, 244, -1, 124, 244, -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, 244, 121, 244, -1, 244, 120, 244, -1, 244, 124, 244, -1, 244, 123, 244, -1, 244, 122, 244, -1, 244, 117, 244, -1, 244, 115, 244, -1, 244, 116, 244, -1, 244, 119, 244, -1, 244, 118, 244, -1, 244, 114, 244, -1, 244, 113, 244, -1, 244, 98, 244, -1, 244, 99, 244, -1, 244, 97, 244, -1, 244, 96, 244, -1, 244, 100, 244, 74, 244, -1, 120, 244, -1, 121, 244, -1, 126, 244, -1, 125, 244, -1, 231, 38, -1, 249, -1, -1, 74, 250, 251, -1, 277, -1, 252, -1, 251, 40, 252, -1, -1, 258, 253, 267, -1, -1, 258, 255, 254, 258, 267, -1, 72, -1, 71, -1, 73, -1, 69, -1, 70, -1, 256, -1, 50, -1, 51, -1, 76, -1, 277, -1, 229, -1, 78, 38, 212, 39, -1, 229, 78, 38, 212, 39, -1, 277, -1, 259, 261, 41, -1, 259, 261, 44, -1, 38, 212, 39, 41, -1, 38, 212, 39, 44, -1, 52, 237, 41, -1, 74, 262, -1, 277, -1, 263, -1, 262, 40, 263, -1, 267, 38, -1, 93, 216, 94, -1, 277, -1, 3, -1, 272, -1, 265, -1, 277, -1, 269, 268, -1, 103, 128, 269, 268, -1, 269, -1, 103, 128, 269, -1, 107, -1, 103, 128, 107, -1, 128, 269, 268, -1, 128, 269, -1, 128, 107, -1, 105, 269, -1, 3, 264, -1, 3, 271, -1, 103, 128, 3, 271, -1, 3, -1, 103, 128, 3, -1, 107, -1, 103, 128, 107, -1, 128, 3, 271, -1, 128, 3, -1, 128, 107, -1, 105, 3, -1, 272, 6, -1, 6, -1, 272, -1, 44, -1, 4, -1, 38, 275, 39, -1, 277, -1, 265, 52, 276, -1, 265, 52, 276, 40, 275, -1, 265, -1, 265, 40, 275, -1, 265, 52, 141, -1, 265, 52, 141, 40, 275, -1, 272, -1, 246, -1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 1802, 1802, 1815, 1819, 1822, 1825, 1828, 1831, 1836, 1841, 1846, 1847, 1848, 1849, 1850, 1856, 1872, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1909, 1909, 1995, 2005, 2016, 2037, 2059, 2070, 2079, 2098, 2104, 2110, 2115, 2122, 2129, 2133, 2146, 2155, 2170, 2183, 2183, 2238, 2239, 2246, 2265, 2296, 2300, 2310, 2315, 2333, 2373, 2379, 2392, 2398, 2424, 2430, 2437, 2438, 2441, 2442, 2450, 2496, 2542, 2553, 2556, 2583, 2589, 2595, 2601, 2609, 2615, 2621, 2627, 2635, 2636, 2637, 2640, 2645, 2655, 2691, 2692, 2727, 2744, 2752, 2765, 2790, 2796, 2800, 2803, 2814, 2819, 2832, 2844, 3118, 3128, 3135, 3136, 3140, 3140, 3171, 3232, 3236, 3258, 3264, 3270, 3276, 3282, 3295, 3310, 3320, 3398, 3449, 3450, 3451, 3452, 3453, 3454, 3459, 3459, 3708, 3708, 3831, 3832, 3844, 3862, 3862, 4151, 4157, 4160, 4163, 4166, 4169, 4172, 4177, 4207, 4211, 4214, 4217, 4222, 4226, 4231, 4241, 4272, 4272, 4301, 4301, 4323, 4350, 4365, 4365, 4375, 4376, 4377, 4377, 4393, 4394, 4411, 4412, 4413, 4414, 4415, 4416, 4417, 4418, 4419, 4420, 4421, 4422, 4423, 4424, 4425, 4426, 4435, 4460, 4484, 4515, 4530, 4548, 4567, 4586, 4593, 4600, 4608, 4629, 4629, 4656, 4656, 4692, 4695, 4699, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4712, 4717, 4724, 4732, 4740, 4751, 4757, 4758, 4766, 4767, 4768, 4769, 4770, 4771, 4778, 4789, 4793, 4796, 4800, 4804, 4814, 4822, 4830, 4843, 4847, 4850, 4854, 4858, 4886, 4894, 4905, 4919, 4928, 4936, 4946, 4950, 4954, 4961, 4978, 4995, 5003, 5011, 5020, 5024, 5033, 5044, 5056, 5066, 5079, 5086, 5094, 5110, 5118, 5129, 5140, 5151, 5170, 5178, 5195, 5203, 5210, 5221, 5232, 5243, 5262, 5268, 5274, 5281, 5290, 5293, 5302, 5309, 5316, 5326, 5337, 5348, 5359, 5366, 5373, 5376, 5393, 5403, 5410, 5416, 5421, 5427, 5431, 5437, 5438, 5439, 5445, 5451, 5455, 5456, 5460, 5467, 5470, 5471, 5472, 5473, 5474, 5476, 5479, 5484, 5509, 5512, 5566, 5570, 5574, 5578, 5582, 5586, 5590, 5594, 5598, 5602, 5606, 5610, 5614, 5618, 5624, 5624, 5650, 5651, 5654, 5655, 5659, 5665, 5668, 5672, 5677, 5685, 5697, 5712, 5713, 5732, 5733, 5737, 5742, 5743, 5757, 5764, 5781, 5788, 5795, 5803, 5807, 5813, 5814, 5815, 5816, 5817, 5818, 5819, 5820, 5823, 5827, 5831, 5835, 5839, 5843, 5847, 5851, 5855, 5859, 5863, 5867, 5871, 5875, 5889, 5893, 5897, 5903, 5907, 5911, 5915, 5919, 5935, 5940, 5940, 5941, 5944, 5961, 5970, 5970, 5986, 5986, 6002, 6003, 6004, 6008, 6012, 6018, 6021, 6025, 6031, 6032, 6035, 6040, 6045, 6050, 6057, 6064, 6071, 6079, 6087, 6095, 6096, 6099, 6100, 6103, 6109, 6115, 6118, 6119, 6122, 6123, 6126, 6131, 6135, 6138, 6141, 6144, 6149, 6153, 6156, 6163, 6169, 6178, 6183, 6187, 6190, 6193, 6196, 6201, 6205, 6208, 6211, 6217, 6222, 6225, 6228, 6232, 6237, 6250, 6254, 6259, 6265, 6269, 6274, 6278, 6285, 6288, 6293 }; #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", "INCLUDE", "IMPORT", "INSERT", "CHARCONST", "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", "USING", "NAMESPACE", "NATIVE", "INLINE", "TYPEMAP", "EXCEPT", "ECHO", "APPLY", "CLEAR", "SWIGTEMPLATE", "FRAGMENT", "WARN", "LESSTHAN", "GREATERTHAN", "DELETE_KW", "LESSTHANOREQUALTO", "GREATERTHANOREQUALTO", "EQUALTO", "NOTEQUALTO", "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", "c_enum_forward_decl", "c_enum_decl", "c_constructor_decl", "cpp_declaration", "cpp_class_decl", "@4", "@5", "cpp_opt_declarators", "cpp_forward_class_decl", "cpp_template_decl", "$@6", "cpp_temp_possible", "template_parms", "templateparameters", "templateparameter", "templateparameterstail", "cpp_using_decl", "cpp_namespace_decl", "$@7", "$@8", "cpp_members", "$@9", "$@10", "cpp_member", "cpp_constructor_decl", "cpp_destructor_decl", "cpp_conversion_operator", "cpp_catch_decl", "cpp_protection_decl", "cpp_nested", "@11", "@12", "cpp_swig_directive", "cpp_end", "cpp_vend", "anonymous_bitfield", "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", "primitive_type", "primitive_type_list", "type_specifier", "definetype", "$@13", "ename", "optional_constant_directive", "enumlist", "edecl", "etype", "expr", "valexpr", "exprnum", "exprcompound", "inherit", "raw_inherit", "$@14", "base_list", "base_specifier", "@15", "@16", "access_specifier", "templcpptype", "cpptype", "opt_virtual", "cpp_const", "ctor_end", "ctor_initializer", "mem_initializer_list", "mem_initializer", "template_decl", "idstring", "idstringopt", "idcolon", "idcolontail", "idtemplate", "idcolonnt", "idcolontailnt", "string", "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 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { 0, 129, 130, 130, 130, 130, 130, 130, 130, 131, 131, 132, 132, 132, 132, 132, 132, 132, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 135, 134, 136, 137, 138, 138, 138, 139, 139, 140, 140, 140, 140, 141, 142, 142, 143, 143, 143, 145, 144, 146, 146, 147, 147, 148, 148, 148, 148, 149, 150, 150, 151, 151, 152, 152, 153, 153, 154, 154, 155, 155, 155, 156, 156, 157, 157, 157, 157, 157, 157, 157, 157, 158, 158, 158, 159, 159, 160, 161, 161, 162, 162, 162, 163, 164, 165, 165, 166, 166, 166, 167, 168, 169, 170, 170, 170, 171, 170, 172, 173, 173, 173, 174, 174, 174, 174, 175, 176, 176, 177, 178, 178, 178, 178, 178, 178, 180, 179, 181, 179, 182, 182, 183, 185, 184, 184, 186, 186, 186, 186, 186, 186, 187, 188, 188, 189, 189, 190, 190, 191, 191, 193, 192, 194, 192, 192, 195, 196, 195, 195, 195, 197, 195, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 199, 200, 200, 201, 201, 201, 201, 202, 203, 203, 203, 205, 204, 206, 204, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 208, 208, 209, 209, 209, 210, 211, 211, 211, 211, 211, 211, 211, 211, 212, 213, 213, 214, 214, 215, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 220, 220, 220, 221, 221, 221, 222, 222, 222, 223, 223, 223, 223, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225, 225, 225, 225, 225, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227, 228, 228, 228, 228, 229, 229, 230, 230, 230, 231, 232, 232, 232, 232, 233, 233, 233, 233, 233, 233, 233, 233, 234, 235, 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 238, 237, 239, 239, 240, 240, 241, 241, 241, 241, 242, 242, 243, 244, 244, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 246, 246, 246, 246, 246, 246, 246, 246, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 248, 250, 249, 249, 251, 251, 253, 252, 254, 252, 255, 255, 255, 256, 256, 257, 257, 257, 258, 258, 259, 259, 259, 259, 260, 260, 260, 260, 260, 261, 261, 262, 262, 263, 264, 264, 265, 265, 266, 266, 267, 267, 267, 267, 267, 267, 268, 268, 268, 268, 269, 270, 270, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 273, 273, 273, 274, 274, 275, 275, 275, 275, 275, 275, 276, 276, 277 }; /* 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, 5, 1, 4, 1, 1, 2, 5, 6, 4, 7, 9, 6, 1, 1, 1, 1, 1, 1, 0, 9, 0, 9, 1, 3, 4, 0, 6, 3, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 3, 4, 0, 6, 0, 5, 5, 2, 0, 6, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 7, 8, 8, 9, 7, 5, 2, 2, 2, 0, 7, 0, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 2, 5, 1, 2, 1, 1, 1, 1, 1, 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, 1, 2, 3, 4, 5, 4, 1, 2, 3, 4, 5, 3, 4, 4, 1, 2, 4, 4, 5, 3, 4, 4, 1, 2, 2, 3, 1, 2, 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, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 5, 3, 3, 1, 1, 3, 1, 1, 1, 1, 1, 5, 1, 1, 3, 4, 5, 5, 6, 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, 1, 0, 3, 1, 1, 3, 0, 3, 0, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 3, 3, 4, 4, 3, 2, 1, 1, 3, 2, 3, 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, 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[] = { 470, 0, 0, 0, 0, 0, 10, 4, 470, 323, 331, 324, 325, 328, 329, 326, 327, 314, 330, 313, 332, 470, 317, 333, 334, 335, 336, 0, 304, 305, 306, 410, 411, 0, 407, 408, 0, 0, 438, 0, 0, 302, 470, 309, 312, 320, 321, 409, 0, 318, 436, 6, 0, 0, 470, 1, 15, 64, 60, 61, 0, 226, 14, 223, 470, 0, 0, 82, 83, 470, 470, 0, 0, 225, 227, 228, 0, 229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 18, 19, 20, 21, 22, 23, 24, 25, 470, 26, 27, 28, 29, 30, 31, 32, 0, 33, 34, 35, 36, 37, 38, 12, 113, 115, 114, 16, 13, 130, 131, 132, 133, 134, 135, 0, 230, 470, 444, 429, 315, 0, 316, 0, 0, 3, 308, 303, 470, 337, 0, 0, 287, 301, 0, 253, 236, 470, 259, 470, 285, 281, 273, 250, 310, 322, 319, 0, 0, 434, 5, 8, 0, 231, 470, 233, 17, 0, 456, 224, 0, 0, 461, 0, 470, 0, 307, 0, 0, 0, 0, 78, 0, 470, 470, 0, 0, 470, 163, 0, 0, 62, 63, 0, 0, 51, 49, 46, 47, 470, 0, 470, 0, 470, 470, 0, 112, 470, 470, 0, 0, 0, 0, 0, 0, 273, 470, 0, 0, 356, 364, 365, 366, 367, 368, 369, 370, 371, 0, 0, 0, 0, 0, 0, 0, 0, 244, 0, 239, 470, 351, 307, 0, 350, 352, 355, 353, 241, 238, 439, 437, 0, 311, 470, 287, 0, 0, 281, 318, 248, 246, 0, 293, 0, 350, 249, 470, 0, 260, 286, 265, 299, 300, 274, 251, 470, 0, 252, 470, 0, 283, 257, 282, 265, 288, 443, 442, 441, 0, 0, 232, 235, 430, 0, 431, 455, 116, 464, 0, 68, 45, 337, 0, 470, 70, 0, 0, 0, 74, 0, 0, 0, 98, 0, 0, 159, 0, 470, 161, 0, 0, 103, 0, 0, 0, 107, 254, 255, 256, 42, 0, 104, 106, 432, 0, 433, 54, 0, 53, 0, 0, 152, 470, 156, 409, 154, 145, 0, 430, 0, 0, 0, 0, 0, 0, 0, 265, 0, 470, 0, 340, 470, 470, 138, 319, 0, 0, 362, 389, 390, 363, 392, 391, 428, 0, 240, 243, 393, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 435, 0, 287, 281, 318, 0, 273, 297, 295, 283, 0, 273, 288, 0, 338, 294, 281, 318, 266, 470, 0, 298, 0, 278, 0, 0, 291, 0, 258, 284, 289, 0, 261, 440, 7, 470, 0, 470, 0, 0, 460, 0, 0, 69, 39, 77, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0, 470, 470, 0, 0, 108, 0, 470, 0, 0, 0, 0, 0, 143, 0, 153, 158, 58, 0, 0, 0, 0, 79, 0, 126, 470, 0, 318, 0, 0, 122, 470, 0, 142, 395, 0, 394, 397, 357, 0, 301, 0, 470, 470, 387, 386, 384, 385, 0, 383, 382, 378, 379, 377, 381, 380, 373, 372, 376, 375, 374, 0, 0, 288, 276, 275, 289, 0, 0, 0, 265, 267, 288, 0, 270, 0, 280, 279, 296, 292, 0, 262, 290, 264, 234, 66, 67, 65, 0, 465, 466, 469, 468, 462, 43, 44, 0, 76, 73, 75, 459, 93, 458, 0, 88, 470, 457, 92, 0, 468, 0, 0, 99, 470, 198, 165, 164, 0, 223, 0, 0, 50, 48, 470, 41, 105, 447, 0, 449, 0, 57, 0, 0, 110, 470, 470, 470, 470, 0, 0, 341, 346, 0, 342, 470, 470, 0, 119, 121, 118, 0, 123, 171, 190, 0, 0, 0, 0, 227, 0, 214, 215, 207, 216, 188, 169, 212, 208, 206, 209, 210, 211, 213, 189, 185, 186, 173, 179, 183, 182, 0, 0, 174, 175, 178, 184, 176, 180, 177, 187, 0, 230, 470, 136, 358, 0, 301, 300, 0, 0, 0, 242, 0, 470, 277, 247, 268, 0, 272, 271, 263, 117, 0, 0, 0, 470, 0, 414, 0, 417, 0, 0, 0, 0, 90, 470, 0, 162, 224, 470, 0, 101, 0, 100, 0, 0, 0, 445, 0, 470, 0, 52, 146, 147, 150, 149, 144, 148, 151, 0, 157, 0, 0, 81, 347, 470, 470, 0, 470, 337, 470, 129, 0, 470, 470, 0, 167, 200, 199, 201, 0, 0, 0, 166, 0, 0, 470, 318, 412, 396, 398, 400, 413, 0, 360, 359, 0, 354, 388, 237, 269, 467, 463, 40, 0, 470, 0, 84, 468, 95, 89, 470, 0, 0, 97, 71, 0, 0, 109, 454, 452, 453, 448, 450, 0, 55, 56, 0, 59, 80, 0, 345, 344, 127, 470, 0, 0, 0, 0, 424, 470, 0, 0, 172, 0, 0, 470, 470, 0, 470, 0, 0, 319, 181, 470, 405, 404, 406, 0, 402, 0, 361, 0, 0, 470, 96, 0, 91, 470, 86, 72, 102, 451, 446, 0, 348, 349, 470, 0, 0, 422, 423, 425, 0, 418, 419, 124, 120, 470, 0, 470, 0, 0, 470, 0, 0, 0, 0, 204, 0, 399, 401, 470, 0, 94, 415, 0, 85, 0, 111, 343, 128, 420, 421, 0, 427, 125, 0, 0, 470, 139, 0, 470, 470, 0, 470, 222, 0, 202, 0, 140, 137, 470, 416, 87, 426, 168, 470, 192, 0, 470, 0, 0, 470, 191, 205, 0, 403, 0, 193, 0, 217, 218, 197, 470, 470, 0, 203, 141, 219, 221, 337, 195, 194, 470, 0, 196, 220 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 4, 5, 92, 93, 94, 550, 614, 615, 616, 617, 99, 340, 341, 618, 619, 590, 102, 103, 620, 105, 621, 107, 622, 552, 184, 623, 110, 624, 558, 448, 625, 315, 626, 324, 206, 335, 207, 627, 628, 629, 630, 436, 118, 603, 483, 119, 120, 121, 122, 123, 737, 486, 875, 631, 632, 588, 700, 344, 345, 346, 469, 633, 127, 455, 321, 634, 788, 719, 635, 636, 637, 638, 639, 640, 641, 890, 871, 642, 882, 893, 643, 644, 259, 167, 294, 168, 241, 242, 379, 243, 484, 150, 329, 151, 272, 152, 153, 154, 218, 40, 41, 244, 180, 43, 44, 45, 46, 264, 265, 363, 595, 596, 709, 819, 246, 268, 248, 249, 489, 490, 646, 733, 734, 802, 846, 803, 47, 48, 735, 894, 715, 782, 825, 826, 132, 301, 338, 49, 163, 50, 583, 691, 250, 561, 175, 302, 547, 169 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -782 static const yytype_int16 yypact[] = { 717, 1945, 2069, 87, 80, 2674, -782, -782, -48, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -48, -782, -782, -782, -782, -782, 77, -782, -782, -782, -782, -782, 176, -782, -782, -23, 177, -782, 250, 3576, 819, 877, 819, -782, -782, 3628, -782, 176, -782, 239, -782, 269, 288, 3321, -782, 85, -782, -782, -782, 179, -782, -782, 342, 346, 2193, 354, -782, -782, 346, 361, 375, 384, -782, -782, -782, 391, -782, 308, 192, 407, 152, 433, 316, 530, 3372, 3372, 449, 460, 342, 472, 380, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, 346, -782, -782, -782, -782, -782, -782, -782, 420, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, 3423, -782, 1758, -782, -782, -782, 310, -782, 50, 461, -782, 819, -782, 1475, 432, 1882, 2439, 37, 294, 176, -782, -782, 252, 137, 252, 340, 139, 412, -782, -782, -782, -782, 518, 59, -782, -782, -782, 499, -782, 503, -782, -782, 441, -782, 95, 441, 441, -782, 506, 180, 909, -782, 347, 176, 555, 563, -782, 441, 3270, 3321, 176, 539, 245, -782, 553, 598, -782, -782, 441, 611, -782, -782, -782, 617, 3321, 601, 161, 587, 593, 441, 342, 617, 3321, 3321, 176, 342, 97, 146, 441, 967, 548, 206, 927, 325, -782, -782, -782, -782, -782, -782, -782, -782, -782, 2439, 605, 2439, 2439, 2439, 2439, 2439, 2439, -782, 562, -782, 623, 627, 309, 1716, 25, -782, -782, 617, -782, -782, -782, 239, 575, -782, 2378, 121, 635, 645, 966, 583, -782, 639, 2439, -782, 3573, -782, 1716, 2378, 176, 404, 340, -782, -782, 565, -782, -782, 3321, 2006, -782, 3321, 2130, 37, 404, 340, 594, 1053, -782, -782, 239, 660, 3321, -782, -782, -782, 665, 617, -782, -782, 318, 667, -782, -782, -782, 274, 252, -782, 669, 671, 681, 675, 463, 685, 682, -782, 692, 691, -782, 176, -782, -782, 695, 697, -782, 700, 704, 3372, -782, -782, -782, -782, -782, 3372, -782, -782, -782, 706, -782, -782, 599, 154, 708, 655, -782, 718, -782, 53, -782, -782, 60, 396, 164, 164, 653, 734, 145, 738, 146, 677, 1053, 40, 743, -782, 2563, 1060, -782, 588, 1280, 3474, 1145, -782, -782, -782, -782, -782, -782, 1758, -782, -782, -782, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, -782, 461, 452, 1025, 678, 382, -782, -782, -782, 452, 592, 686, 164, 2439, 1716, -782, 969, 12, -782, 3321, 2254, -782, 758, -782, 3602, 762, -782, 3647, 404, 340, 972, 146, 404, -782, -782, 503, 381, -782, 441, 1407, -782, 763, 769, -782, -782, -782, 589, 402, 1356, 776, 3321, 909, 764, -782, 779, 2775, -782, 438, 3372, 508, 785, 757, 593, 212, 792, 441, 3321, 736, -782, 3321, -782, -782, -782, 164, 256, 146, 33, -782, 1068, -782, 775, 797, 653, 803, 425, -782, 319, 1651, -782, -782, 798, -782, -782, 2439, 2315, 2500, 10, 877, 623, 1082, 1082, 1310, 1310, 2541, 1267, 1162, 1519, 1219, 1145, 1044, 1044, 755, 755, -782, -782, -782, 176, 686, -782, -782, -782, 452, 633, 3676, 642, 686, -782, 146, 808, -782, 3721, -782, -782, -782, -782, 146, 404, 340, 404, -782, -782, -782, 617, 2876, -782, 813, -782, 154, 834, -782, -782, 1651, -782, -782, 617, -782, -782, -782, 810, -782, 715, 617, -782, 799, 122, 673, 402, -782, 715, -782, -782, -782, 2977, 342, 3525, 850, -782, -782, 3321, -782, -782, 299, 731, -782, 771, -782, 836, 838, -782, 584, 718, -782, 715, 100, 146, -782, 882, 51, -782, 1052, 3321, 909, -782, -782, -782, 848, -782, -782, -782, 849, 818, 826, 830, 780, 518, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, -782, 860, 1651, -782, -782, -782, -782, -782, -782, -782, -782, 3168, 866, 837, -782, 1716, 2439, 2500, 1821, 2439, 878, 881, -782, 2439, 252, -782, -782, -782, 767, -782, -782, 404, -782, 441, 441, 876, 3321, 884, 846, 736, -782, 1407, 293, 441, 888, -782, 715, 890, -782, 617, 20, 909, -782, 3372, -782, 895, 933, 73, -782, 79, 1758, 257, -782, -782, -782, -782, -782, -782, -782, -782, 3219, -782, 3078, 897, -782, 887, 775, 775, 811, 3321, -782, 867, -782, 903, 1060, 3321, 1651, -782, -782, -782, -782, 518, 906, 909, -782, 3474, 248, 115, 904, -782, 908, -782, 824, -782, 1651, 1716, 1716, 2439, -782, 1345, -782, -782, -782, -782, -782, 907, 3321, 911, -782, 617, 913, -782, 715, 885, 736, -782, -782, 917, 918, -782, -782, 299, -782, 299, -782, 863, -782, -782, 961, -782, -782, 2439, -782, 882, -782, 1060, 915, 920, 176, 510, -782, 252, 425, 929, -782, 1651, 935, 3321, 1060, 203, 2563, 2439, 941, 588, -782, 837, -782, -782, -782, 176, -782, 926, 1716, 945, 948, 3321, -782, 950, -782, 715, -782, -782, -782, -782, -782, 952, -782, 1716, 775, 425, 532, -782, 957, -782, 962, -782, -782, -782, -782, 252, 963, 3321, 974, 425, 3321, 976, -22, 981, 1507, -782, 971, -782, -782, 837, 922, -782, -782, 997, -782, 996, -782, -782, -782, -782, -782, 176, -782, -782, 1651, 999, 715, -782, 1001, 3321, 3321, 1003, 1052, -782, 922, -782, 176, -782, -782, 1060, -782, -782, -782, -782, 715, -782, 610, 715, 1004, 1008, 3321, -782, -782, 922, -782, 425, -782, 634, -782, -782, -782, 715, 715, 1011, -782, -782, -782, -782, -782, -782, -782, 715, 1013, -782, -782 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -782, -782, -284, -782, -782, -782, -782, 21, 28, 13, 39, -782, 604, -782, 41, 45, -782, -782, -782, 54, -782, 63, -782, 66, -782, -782, 78, -782, 102, -443, -530, 106, -782, 124, -782, -287, 591, -84, 125, 157, 182, 196, -782, 467, -749, -679, -782, -782, -782, -782, 469, -782, -782, -781, -2, 6, -782, -782, -782, -782, 590, 473, 214, -782, -782, -782, -531, -782, -782, -782, 477, -782, 478, 228, -782, -782, -782, -782, -782, -782, -460, -782, -3, -42, -782, 643, 96, 389, -782, 597, 710, -15, 600, -782, -71, 48, -172, -85, -126, -32, -26, -782, 689, 23, -36, -782, 1051, -782, -299, -782, -782, -631, -782, 326, -782, 916, -118, -416, -782, -670, -782, -782, -782, 305, -782, -782, -782, -205, -82, 259, -524, 241, -782, -782, 253, 1092, -123, -782, 761, 44, -107, -782, -157, 781, 542, 215, -183, -419, 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 -471 static const yytype_int16 yytable[] = { 6, 204, 129, 124, 140, 130, 440, 348, 133, 213, 155, 125, 166, 247, 325, 141, 867, 158, 97, 668, 273, 133, 545, 587, 42, 42, 95, 149, 564, 286, 254, 545, 356, 96, 677, 672, 831, 454, 785, 217, 8, 460, 157, 680, 98, 131, 100, 222, 297, 652, 101, 525, 303, 8, 289, 291, 255, 260, 309, 104, 795, 759, 8, 313, 176, -245, 299, 706, 106, 176, 185, 108, 525, 855, 714, 270, 764, 42, 775, 776, 55, 478, 766, 109, -339, 337, 404, 864, 53, 409, 889, 710, 144, -155, 358, 868, 711, 39, 52, 822, 352, 299, 176, 172, 727, 137, 299, 111, 307, 901, 261, 112, 836, 131, 256, 275, 526, 471, 8, -245, 331, 276, 678, 135, 8, 54, 843, 653, 299, 113, 114, 251, 273, 131, 330, 286, 278, 593, 281, 300, 36, 707, 8, 902, 38, 316, 317, -155, 8, 8, 366, 157, 542, 157, 245, 757, 195, 253, 428, 142, 299, 327, 115, 271, 8, 42, 290, 8, 295, 343, 574, 571, 260, 155, -431, 279, 144, 270, 133, 8, 765, 404, 409, 354, 357, 260, 767, 116, 787, 488, 854, 133, 280, 170, 144, 191, 196, 892, 465, 142, 36, 117, 306, 285, 38, 332, 804, 336, 339, 362, 42, 42, 349, 155, 353, 580, 144, 171, 36, 126, 364, 147, 38, 809, 36, 402, 42, 240, 38, 751, 149, 810, 305, 128, 42, 42, 192, 421, 415, 521, 424, 837, 36, 380, 420, 157, 38, 148, 36, 36, 461, 8, 38, 38, 543, 753, 284, 833, 545, 8, 247, 769, 172, 348, 36, 271, 285, 36, 38, 147, 138, 38, 271, 131, 354, 273, 286, 8, 146, 36, 42, 585, 428, 38, 182, 147, 793, 148, 852, 286, 148, 139, 441, 42, 306, 36, 8, 320, 399, 38, 521, 770, 42, 536, 143, 42, 705, 157, 347, 36, 164, 8, 8, 38, 813, 581, 42, 214, 515, 582, 838, 6, 794, 480, 562, 474, 145, 147, 8, 165, 880, 306, 427, 354, 754, 432, 431, 495, 131, 883, 485, 28, 29, 30, 161, 714, 470, 142, 172, -470, 296, 36, 133, 172, 198, 38, 252, 199, 437, 36, 200, 143, 133, 38, 144, 216, 157, 162, 491, 367, 438, 143, 147, 216, 148, 559, 527, 36, 282, 567, 147, 38, 148, 145, 174, 539, 308, 172, 42, 434, 189, 353, 181, 145, 536, 283, 36, 604, 147, 183, 38, 245, 591, -470, 689, 8, 554, 427, 172, 431, 216, 36, 36, 186, 780, 38, 38, 147, 147, 148, 279, 518, 187, 8, 897, 540, 146, 690, 36, 188, 31, 32, 38, 147, 295, 148, 6, 280, 906, 907, 306, 42, 418, 555, 296, 194, 556, 172, 910, 34, 35, 129, 124, 573, 130, 6, 130, 61, 215, 419, 125, 336, 275, 523, 155, 600, 601, 97, 651, 602, 605, 197, 42, 212, 240, 95, 263, 535, 537, 597, 572, 149, 96, 745, 746, 157, 645, 208, 42, 131, 257, 42, 594, 98, 679, 100, 157, 380, 209, 101, -470, -470, 446, 447, 557, 36, 725, 144, 104, 38, 211, 31, 32, 73, 74, 75, 288, 106, 77, 216, 108, 8, 523, 36, -470, 535, 147, 38, 148, 717, 34, 35, 109, 671, 201, 688, 172, 216, 292, 129, 124, 671, 130, 293, 147, 566, 148, 304, 125, 575, 645, 828, 576, 562, 829, 97, 111, 716, 311, 673, 112, 586, 730, 95, 347, 671, 312, 673, 129, 124, 96, 130, 671, 856, 661, 247, 857, 125, 113, 114, 319, 98, 664, 100, 97, 703, 698, 101, 130, 470, 6, 673, 95, 551, 699, 172, 104, 322, 673, 96, 42, 323, 761, 61, 755, 106, 909, 816, 108, 817, 98, 115, 100, 760, 326, 140, 101, 789, 275, 420, 109, 222, 42, 299, 651, 104, 572, 748, 333, 487, 279, 519, -470, 334, 106, 645, 116, 108, 463, 464, 778, 661, 743, 370, 111, 328, 736, 280, 112, 109, 117, 895, 361, 671, 896, 791, 377, 157, 366, 73, 74, 75, 488, 378, 77, 381, 113, 114, 126, 400, 779, 279, 658, 111, 406, 903, 786, 112, 904, 673, 418, 660, 128, 133, 407, 812, 905, 411, 280, 147, 91, 485, 42, 251, 412, 113, 114, 419, 429, 115, 366, 433, 129, 124, 435, 130, 439, 807, 442, 597, 597, 125, 675, 676, 783, 443, 245, 157, 97, 645, 444, 450, 594, 594, 116, 449, 95, 445, 115, 671, 491, 451, 452, 96, 456, 42, 457, 645, 117, 458, 554, 42, 172, 459, 98, 462, 100, 466, 835, 467, 101, 840, 485, 116, 179, 673, 126, 472, 468, 104, 839, 354, 28, 29, 30, 485, 850, 117, 106, 830, 128, 108, 42, 473, 205, 205, 876, 555, 157, 476, 556, 477, 517, 109, 157, 126, 671, 479, 645, 240, 520, 157, 862, 670, 136, 865, 491, 530, 736, 128, 876, 532, 578, 156, 548, 418, 744, 111, 568, 160, 549, 112, 673, 42, 8, 565, 42, 860, 221, 876, 569, 597, 419, 577, 885, 886, 1, 2, 3, 113, 114, 42, 157, 584, 594, 65, 598, 671, 557, 190, 193, 599, 647, 671, 173, 900, 736, 662, 669, 306, 485, 674, 777, 666, 554, 671, 172, 42, 671, 692, 42, 645, 115, 673, 693, 202, 28, 29, 30, 673, 210, 219, 671, 671, 667, 694, 157, 396, 397, 398, 8, 673, 671, 695, 673, 708, 718, 116, 8, 42, 42, 685, 721, 720, 556, 799, 800, 801, 673, 673, 722, 117, 686, 262, 723, 726, 724, 274, 673, 277, 42, -170, 8, 732, 36, 142, 287, 740, 38, 126, 741, 747, 749, 306, 750, 8, 811, 756, 216, 143, 8, 758, 144, 128, 762, 147, 763, 148, 773, 774, 219, 781, 784, 310, 790, 797, 806, 306, 798, 808, 318, 145, 298, 676, 823, 298, 298, 818, 814, 815, 306, 824, 298, 874, 8, 365, 156, 298, 832, 8, 8, 847, 8, 834, 350, 8, 355, 274, 298, 360, 36, 136, 219, 368, 38, 842, 848, 849, 36, 298, 342, 851, 38, 853, 146, 351, 298, 858, 298, 793, 859, 147, 216, 148, 142, 357, 156, 270, 861, 147, 270, 148, 36, 863, 866, 872, 38, 205, 403, 405, 869, 144, 410, 205, 144, 36, 216, 144, 8, 38, 36, 416, 417, 147, 38, 148, 877, 878, 881, 216, 884, 887, 544, 898, 216, 274, 147, 899, 148, 274, 908, 147, 579, 148, 911, 696, 8, 697, 589, 496, 267, 269, 704, 257, 36, 701, 702, 355, 38, 36, 36, 8, 36, 38, 38, 36, 38, 538, 216, 38, 144, 453, 768, 408, 359, 147, 408, 148, 497, 534, 712, 357, 148, 271, 655, 271, 654, 159, 271, 28, 29, 30, 821, 844, 713, 873, 357, 28, 29, 30, 888, 879, 143, 134, 405, 405, 687, 0, 475, 0, 274, 0, 274, 0, 0, 0, 481, 0, 36, 0, 670, 0, 38, 0, 145, 0, 0, 0, 482, 0, 0, 0, 408, 0, 0, 0, 205, 0, 369, 0, 371, 372, 373, 374, 375, 376, 36, 0, 0, 0, 38, 0, 0, 516, 394, 395, 396, 397, 398, 0, 430, 36, 405, 0, 0, 38, 524, 0, 0, 271, 0, 413, 0, 0, 0, 534, 0, 0, 0, 0, 274, 274, 0, 0, 271, 0, 423, 0, 0, 426, 392, 393, 394, 395, 396, 397, 398, 219, 0, 0, 0, 219, 0, 0, 0, 0, 541, 0, 298, 546, 0, 0, 0, 0, 0, 0, 553, 560, 563, 0, 0, 0, 0, 405, 219, 274, 0, 0, 274, 0, 0, 382, 383, 384, 385, 298, 0, 560, 0, 0, 0, 0, 0, 0, 592, 0, 0, 156, 382, 383, 384, 385, 684, 392, 393, 394, 395, 396, 397, 398, 0, 0, 0, 0, 0, 0, 657, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 274, 0, 0, 0, 0, 0, 0, 0, 274, 0, 0, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 382, 383, 384, 385, 492, 0, 0, 0, 0, 0, 0, 219, 0, 522, 0, 0, 0, 0, 729, 0, 529, 391, 392, 393, 394, 395, 396, 397, 398, 0, 0, 560, 0, 0, 0, 0, 0, 0, 682, 274, 560, 0, 0, 0, 296, 0, 219, 172, 382, 383, 384, 385, 224, 225, 226, 227, 228, 229, 230, 231, 205, 382, 383, 384, 385, 386, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 771, 387, 388, 389, 390, 493, 392, 393, 394, 395, 396, 397, 494, 731, 382, 383, 648, 507, 514, 0, 0, 172, 0, 0, 0, 792, 224, 225, 226, 227, 228, 229, 230, 231, 0, 0, 392, 393, 394, 395, 396, 397, 398, 0, 219, 0, 0, 0, 0, 382, 383, 384, 385, 219, 0, 298, 298, 0, 0, 0, 0, 560, 0, 752, 0, 298, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 0, 0, 219, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 219, 0, 0, 219, 796, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 257, 0, 0, 0, 219, 0, 0, 0, 27, 28, 29, 30, 31, 32, 0, 0, 0, 144, 0, 219, 0, 0, 0, 0, 0, 560, 0, 0, 0, 827, 33, 34, 35, 0, 0, 870, 0, 0, 0, 0, 0, 481, 0, 0, 0, 0, 0, 0, 0, 0, 845, 0, 738, 374, 0, 739, 0, 0, 0, 742, 0, 0, 0, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 0, 0, 0, 147, 0, 0, 0, 382, 383, 384, 385, 386, 219, 0, 0, 0, 0, 0, 0, 382, 383, 384, 385, 827, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 219, 0, 891, 390, 391, 392, 393, 394, 395, 396, 397, 398, 0, 0, 0, 0, 0, 0, 0, 219, 606, 0, -470, 57, 805, 0, 58, 59, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 820, 0, 607, 63, 0, 0, -470, 0, -470, -470, -470, -470, -470, 0, 0, 0, 0, 0, 0, 0, 841, 65, 66, 67, 68, 608, 70, 71, 72, -470, -470, -470, 609, 610, 611, 0, 73, 612, 75, 0, 76, 77, 78, 0, 0, 0, 82, 0, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 90, 0, -470, 0, 0, 91, -470, -470, 0, 8, 0, 0, 172, 0, 0, 0, 223, 224, 225, 226, 227, 228, 229, 230, 231, 613, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 0, 0, 0, 0, 27, 28, 29, 30, 31, 32, 0, 233, 382, 383, 384, 385, 386, 0, 0, 0, 0, 0, 0, 0, 8, 0, 33, 34, 35, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 36, 0, 0, 37, 38, 0, 0, 0, 0, 0, 31, 32, 0, 0, 234, 0, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 36, 0, 0, 0, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 266, 0, 0, 0, 0, 0, 0, 147, 7, 0, 8, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 36, 0, 0, 0, 38, 0, 27, 28, 29, 30, 31, 32, 0, 0, 234, 0, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 36, 0, 0, 37, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 422, 0, 0, 0, 0, 0, 0, 0, 51, 0, 8, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 36, 0, 0, 0, 38, 0, 27, 28, 29, 30, 31, 32, 0, 0, 234, 0, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 36, 0, 0, 37, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 425, 0, 0, 0, 0, 0, 0, 0, 177, 0, 178, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 36, 0, 0, 0, 38, 0, 0, 28, 29, 30, 31, 32, 0, 0, 234, 0, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 36, 0, 0, 0, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 528, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 649, 0, 0, 36, 0, 0, 0, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 234, 0, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 257, 0, 36, 0, 0, 0, 38, 0, 27, 28, 29, 30, 31, 32, 0, 0, 234, 144, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 36, 0, 0, 37, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 401, 0, 0, 0, 0, 0, 0, 147, 8, 0, 0, 172, 33, 34, 35, 223, 224, 225, 226, 227, 228, 229, 230, 231, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 232, 0, 0, 0, 36, 0, 0, 0, 38, 28, 29, 30, 31, 32, 0, 233, 0, 0, 234, 0, 0, 235, 236, 0, 0, 237, 238, 239, 8, 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 36, 0, 0, 0, 38, 0, 27, 28, 29, 30, 31, 32, 656, 0, 0, 0, 0, 235, 236, 0, 0, 650, 238, 239, 0, 0, 0, 0, 33, 34, 35, 0, 0, 0, 382, 383, 384, 385, 386, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 36, 0, 0, 37, 38, 0, 0, 0, -2, 56, 0, -470, 57, 0, 353, 58, 59, 60, 0, 0, 0, 147, 0, 0, 0, 0, 0, 61, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, 62, 63, 0, 0, 0, 0, -470, -470, -470, -470, -470, 0, 0, 64, 0, 0, 0, 0, 0, 65, 66, 67, 68, 69, 70, 71, 72, -470, -470, -470, 0, 0, 0, 0, 73, 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 90, 56, -470, -470, 57, 91, -470, 58, 59, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, 62, 63, 0, 0, 570, 0, -470, -470, -470, -470, -470, 0, 0, 64, 0, 0, 0, 0, 0, 65, 66, 67, 68, 69, 70, 71, 72, -470, -470, -470, 0, 0, 0, 0, 73, 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 90, 56, -470, -470, 57, 91, -470, 58, 59, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, 62, 63, 0, 0, 665, 0, -470, -470, -470, -470, -470, 0, 0, 64, 0, 0, 0, 0, 0, 65, 66, 67, 68, 69, 70, 71, 72, -470, -470, -470, 0, 0, 0, 0, 73, 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 90, 56, -470, -470, 57, 91, -470, 58, 59, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, 62, 63, 0, 0, 681, 0, -470, -470, -470, -470, -470, 0, 0, 64, 0, 0, 0, 0, 0, 65, 66, 67, 68, 69, 70, 71, 72, -470, -470, -470, 0, 0, 0, 0, 73, 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 90, 56, -470, -470, 57, 91, -470, 58, 59, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, -470, 0, 0, 0, 62, 63, 0, 0, 0, 0, -470, -470, -470, -470, -470, 0, 0, 64, 0, 0, 0, 772, 0, 65, 66, 67, 68, 69, 70, 71, 72, -470, -470, -470, 0, 0, 0, 0, 73, 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 8, 0, 0, 0, 0, 0, 0, 0, 90, 0, -470, 0, 0, 91, -470, 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, 0, 28, 29, 30, 31, 32, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220, 34, 35, 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, 0, 28, 29, 30, 31, 32, 36, 0, 8, 0, 38, 728, 0, 0, 0, 0, 314, 0, 0, 0, 0, 0, 33, 34, 35, 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, 36, 0, 8, 0, 38, 728, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 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, 36, 0, 8, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 203, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 31, 32, 36, 0, 8, 37, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 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, 0, 28, 29, 30, 31, 32, 36, 0, 8, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220, 34, 35, 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, 0, 28, 29, 30, 31, 32, 36, 0, 683, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 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, 0, 28, 29, 30, 31, 32, 36, 0, 8, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 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, 0, 0, 0, 0, 31, 32, 36, 414, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 0, 9, 10, 11, 12, 13, 14, 15, 16, 0, 18, 531, 20, 0, 0, 23, 24, 25, 26, 0, 0, 0, 382, 383, 384, 385, 386, 0, 0, 0, 0, 0, 36, 0, 0, 0, 38, 0, 0, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 382, 383, 384, 385, 386, 533, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 0, 0, 0, 0, 0, 659, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 382, 383, 384, 385, 386, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 382, 383, 384, 385, 386, 663, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 382, 383, 384, 385, 386, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398 }; #define yypact_value_is_default(yystate) \ ((yystate) == (-782)) #define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_int16 yycheck[] = { 0, 85, 5, 5, 40, 5, 305, 212, 8, 91, 42, 5, 54, 131, 197, 41, 38, 43, 5, 550, 146, 21, 438, 466, 1, 2, 5, 42, 447, 155, 137, 447, 215, 5, 564, 559, 785, 321, 717, 110, 3, 328, 42, 567, 5, 93, 5, 129, 171, 39, 5, 39, 175, 3, 161, 162, 138, 142, 181, 5, 730, 41, 3, 186, 64, 40, 6, 591, 5, 69, 70, 5, 39, 822, 598, 38, 3, 54, 709, 710, 0, 41, 3, 5, 44, 208, 258, 836, 1, 261, 871, 40, 55, 40, 217, 117, 45, 1, 2, 778, 3, 6, 102, 6, 635, 128, 6, 5, 179, 890, 142, 5, 791, 93, 140, 147, 104, 57, 3, 94, 205, 147, 565, 46, 3, 38, 796, 117, 6, 5, 5, 131, 258, 93, 205, 261, 151, 104, 153, 44, 103, 41, 3, 892, 107, 187, 188, 94, 3, 3, 221, 151, 436, 153, 131, 679, 4, 107, 284, 38, 6, 203, 5, 126, 3, 142, 107, 3, 168, 211, 457, 455, 257, 205, 52, 38, 55, 38, 178, 3, 107, 353, 354, 215, 38, 270, 107, 5, 719, 74, 821, 191, 55, 108, 55, 3, 44, 876, 44, 38, 103, 5, 38, 155, 107, 205, 737, 207, 208, 3, 187, 188, 212, 245, 117, 3, 55, 38, 103, 5, 220, 124, 107, 753, 103, 257, 203, 131, 107, 672, 245, 755, 52, 5, 211, 212, 44, 279, 270, 411, 282, 38, 103, 243, 276, 245, 107, 126, 103, 103, 334, 3, 107, 107, 437, 674, 117, 788, 674, 3, 378, 4, 6, 468, 103, 126, 218, 103, 107, 124, 93, 107, 126, 93, 306, 401, 402, 3, 117, 103, 257, 464, 408, 107, 69, 124, 38, 126, 812, 415, 126, 41, 307, 270, 38, 103, 3, 52, 254, 107, 472, 44, 279, 429, 52, 282, 590, 307, 212, 103, 41, 3, 3, 107, 757, 103, 293, 102, 400, 107, 117, 321, 74, 365, 447, 357, 74, 124, 3, 41, 861, 38, 284, 365, 41, 291, 288, 369, 93, 863, 366, 47, 48, 49, 105, 869, 346, 38, 6, 40, 3, 103, 352, 6, 38, 107, 46, 41, 40, 103, 44, 52, 362, 107, 55, 117, 366, 128, 368, 44, 52, 52, 124, 117, 126, 446, 418, 103, 38, 450, 124, 107, 126, 74, 38, 4, 39, 6, 365, 293, 82, 117, 38, 74, 520, 55, 103, 78, 124, 38, 107, 378, 473, 94, 105, 3, 4, 359, 6, 361, 117, 103, 103, 38, 713, 107, 107, 124, 124, 126, 38, 39, 38, 3, 884, 44, 117, 128, 103, 38, 50, 51, 107, 124, 434, 126, 436, 55, 898, 899, 38, 418, 38, 41, 3, 38, 44, 6, 908, 69, 70, 454, 454, 456, 454, 455, 456, 19, 38, 55, 454, 461, 494, 415, 496, 40, 41, 454, 494, 44, 485, 38, 449, 93, 378, 454, 44, 429, 430, 479, 42, 496, 454, 666, 667, 485, 486, 38, 465, 93, 38, 468, 479, 454, 565, 454, 496, 497, 38, 454, 104, 105, 39, 40, 102, 103, 613, 55, 454, 107, 38, 50, 51, 75, 76, 77, 104, 454, 80, 117, 454, 3, 474, 103, 128, 477, 124, 107, 126, 600, 69, 70, 454, 559, 4, 577, 6, 117, 39, 542, 542, 567, 542, 40, 124, 449, 126, 41, 542, 41, 550, 41, 44, 676, 44, 542, 454, 599, 3, 559, 454, 465, 644, 542, 468, 591, 3, 567, 571, 571, 542, 571, 598, 41, 526, 693, 44, 571, 454, 454, 41, 542, 534, 542, 571, 588, 588, 542, 588, 589, 590, 591, 571, 4, 588, 6, 542, 44, 598, 571, 577, 3, 686, 19, 675, 542, 905, 764, 542, 766, 571, 454, 571, 684, 3, 651, 571, 724, 650, 651, 542, 703, 599, 6, 650, 571, 42, 669, 41, 41, 38, 39, 44, 40, 571, 635, 454, 571, 39, 40, 711, 593, 657, 38, 542, 44, 646, 55, 542, 571, 454, 41, 104, 679, 44, 726, 94, 657, 729, 75, 76, 77, 74, 40, 80, 38, 542, 542, 454, 94, 712, 38, 39, 571, 39, 41, 718, 571, 44, 679, 38, 39, 454, 683, 39, 756, 52, 104, 55, 124, 106, 717, 669, 693, 55, 571, 571, 55, 104, 542, 771, 41, 705, 705, 39, 705, 39, 749, 39, 709, 710, 705, 39, 40, 714, 44, 693, 717, 705, 719, 39, 39, 709, 710, 542, 40, 705, 52, 571, 755, 730, 39, 41, 705, 39, 712, 39, 737, 542, 39, 4, 718, 6, 39, 705, 39, 705, 39, 790, 94, 705, 793, 778, 571, 65, 755, 542, 104, 40, 705, 792, 793, 47, 48, 49, 791, 808, 571, 705, 784, 542, 705, 749, 39, 85, 86, 847, 41, 778, 41, 44, 104, 104, 705, 784, 571, 812, 44, 788, 693, 104, 791, 834, 78, 33, 837, 796, 39, 798, 571, 871, 39, 45, 42, 41, 38, 39, 705, 44, 48, 41, 705, 812, 790, 3, 39, 793, 832, 129, 890, 41, 821, 55, 38, 866, 867, 109, 110, 111, 705, 705, 808, 832, 41, 821, 60, 39, 863, 102, 78, 79, 38, 44, 869, 63, 887, 846, 39, 38, 38, 876, 52, 41, 40, 4, 881, 6, 834, 884, 128, 837, 861, 705, 863, 93, 84, 47, 48, 49, 869, 89, 110, 898, 899, 40, 39, 876, 122, 123, 124, 3, 881, 908, 45, 884, 3, 38, 705, 3, 866, 867, 41, 74, 44, 44, 71, 72, 73, 898, 899, 74, 705, 52, 142, 74, 45, 126, 146, 908, 148, 887, 45, 3, 76, 103, 38, 155, 39, 107, 705, 39, 45, 38, 38, 78, 3, 41, 39, 117, 52, 3, 41, 55, 705, 39, 124, 3, 126, 41, 52, 179, 74, 39, 182, 38, 41, 39, 38, 40, 38, 189, 74, 171, 40, 39, 174, 175, 94, 41, 41, 38, 41, 181, 41, 3, 38, 205, 186, 39, 3, 3, 45, 3, 38, 213, 3, 215, 216, 197, 218, 103, 220, 221, 222, 107, 44, 41, 39, 103, 208, 209, 41, 107, 41, 117, 214, 215, 40, 217, 38, 38, 124, 117, 126, 38, 38, 245, 38, 45, 124, 38, 126, 103, 39, 38, 44, 107, 328, 257, 258, 39, 55, 261, 334, 55, 103, 117, 55, 3, 107, 103, 270, 271, 124, 107, 126, 39, 41, 39, 117, 39, 38, 438, 39, 117, 284, 124, 39, 126, 288, 39, 124, 461, 126, 41, 588, 3, 588, 468, 370, 144, 145, 589, 38, 103, 588, 588, 306, 107, 103, 103, 3, 103, 107, 107, 103, 107, 434, 117, 107, 55, 320, 693, 117, 117, 124, 117, 126, 378, 117, 38, 38, 126, 126, 497, 126, 496, 46, 126, 47, 48, 49, 776, 798, 52, 846, 38, 47, 48, 49, 869, 858, 52, 21, 353, 354, 574, -1, 357, -1, 359, -1, 361, -1, -1, -1, 365, -1, 103, -1, 78, -1, 107, -1, 74, -1, -1, -1, 78, -1, -1, -1, 117, -1, -1, -1, 457, -1, 232, -1, 234, 235, 236, 237, 238, 239, 103, -1, -1, -1, 107, -1, -1, 402, 120, 121, 122, 123, 124, -1, 117, 103, 411, -1, -1, 107, 415, -1, -1, 126, -1, 265, -1, -1, -1, 117, -1, -1, -1, -1, 429, 430, -1, -1, 126, -1, 280, -1, -1, 283, 118, 119, 120, 121, 122, 123, 124, 446, -1, -1, -1, 450, -1, -1, -1, -1, 435, -1, 437, 438, -1, -1, -1, -1, -1, -1, 445, 446, 447, -1, -1, -1, -1, 472, 473, 474, -1, -1, 477, -1, -1, 96, 97, 98, 99, 464, -1, 466, -1, -1, -1, -1, -1, -1, 473, -1, -1, 496, 96, 97, 98, 99, 573, 118, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, -1, -1, 515, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 526, -1, -1, -1, -1, -1, -1, -1, 534, -1, -1, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 96, 97, 98, 99, 39, -1, -1, -1, -1, -1, -1, 565, -1, 412, -1, -1, -1, -1, 644, -1, 419, 117, 118, 119, 120, 121, 122, 123, 124, -1, -1, 565, -1, -1, -1, -1, -1, -1, 572, 593, 574, -1, -1, -1, 3, -1, 600, 6, 96, 97, 98, 99, 11, 12, 13, 14, 15, 16, 17, 18, 686, 96, 97, 98, 99, 100, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 703, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 644, 96, 97, 492, 493, 494, -1, -1, 6, -1, -1, -1, 728, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, 118, 119, 120, 121, 122, 123, 124, -1, 675, -1, -1, -1, -1, 96, 97, 98, 99, 684, -1, 666, 667, -1, -1, -1, -1, 672, -1, 674, -1, 676, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, -1, -1, 711, -1, -1, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, 726, -1, -1, 729, 730, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 756, -1, -1, -1, 46, 47, 48, 49, 50, 51, -1, -1, -1, 55, -1, 771, -1, -1, -1, -1, -1, 757, -1, -1, -1, 781, 68, 69, 70, -1, -1, 41, -1, -1, -1, -1, -1, 793, -1, -1, -1, -1, -1, -1, -1, -1, 802, -1, 649, 650, -1, 652, -1, -1, -1, 656, -1, -1, -1, -1, -1, 103, -1, -1, 106, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, 96, 97, 98, 99, 100, 847, -1, -1, -1, -1, -1, -1, 96, 97, 98, 99, 858, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 871, -1, 873, 116, 117, 118, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, -1, -1, -1, 890, 1, -1, 3, 4, 740, -1, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, 774, -1, 41, 42, -1, -1, 45, -1, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, 794, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, 75, 76, 77, -1, 79, 80, 81, -1, -1, -1, 85, -1, 87, 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, -1, -1, -1, 101, -1, 103, -1, -1, 106, 107, 108, -1, 3, -1, -1, 6, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 126, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, -1, -1, -1, -1, 46, 47, 48, 49, 50, 51, -1, 53, 96, 97, 98, 99, 100, -1, -1, -1, -1, -1, -1, -1, 3, -1, 68, 69, 70, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, 103, -1, -1, 106, 107, -1, -1, -1, -1, -1, 50, 51, -1, -1, 117, -1, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 103, -1, -1, -1, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, 124, 1, -1, 3, -1, 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, 103, -1, -1, -1, 107, -1, 46, 47, 48, 49, 50, 51, -1, -1, 117, -1, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 103, -1, -1, 106, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, 1, -1, 3, -1, 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, 103, -1, -1, -1, 107, -1, 46, 47, 48, 49, 50, 51, -1, -1, 117, -1, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 103, -1, -1, 106, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, 1, -1, 3, -1, 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, 103, -1, -1, -1, 107, -1, -1, 47, 48, 49, 50, 51, -1, -1, 117, -1, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 103, -1, -1, -1, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, 103, -1, -1, -1, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 117, -1, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, 103, -1, -1, -1, 107, -1, 46, 47, 48, 49, 50, 51, -1, -1, 117, 55, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 103, -1, -1, 106, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 117, -1, -1, -1, -1, -1, -1, 124, 3, -1, -1, 6, 68, 69, 70, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, 103, -1, -1, -1, 107, 47, 48, 49, 50, 51, -1, 53, -1, -1, 117, -1, -1, 120, 121, -1, -1, 124, 125, 126, 3, -1, 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, 103, -1, -1, -1, 107, -1, 46, 47, 48, 49, 50, 51, 74, -1, -1, -1, -1, 120, 121, -1, -1, 124, 125, 126, -1, -1, -1, -1, 68, 69, 70, -1, -1, -1, 96, 97, 98, 99, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 103, -1, -1, 106, 107, -1, -1, -1, 0, 1, -1, 3, 4, -1, 117, 7, 8, 9, -1, -1, -1, 124, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, 41, 42, -1, -1, -1, -1, 47, 48, 49, 50, 51, -1, -1, 54, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, -1, -1, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, -1, -1, -1, 101, 1, 103, 3, 4, 106, 107, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, 41, 42, -1, -1, 45, -1, 47, 48, 49, 50, 51, -1, -1, 54, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, -1, -1, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, -1, -1, -1, 101, 1, 103, 3, 4, 106, 107, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, 41, 42, -1, -1, 45, -1, 47, 48, 49, 50, 51, -1, -1, 54, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, -1, -1, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, -1, -1, -1, 101, 1, 103, 3, 4, 106, 107, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, 41, 42, -1, -1, 45, -1, 47, 48, 49, 50, 51, -1, -1, 54, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, -1, -1, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, -1, -1, -1, 101, 1, 103, 3, 4, 106, 107, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, 41, 42, -1, -1, -1, -1, 47, 48, 49, 50, 51, -1, -1, 54, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, -1, -1, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 3, -1, -1, -1, -1, -1, -1, -1, 101, -1, 103, -1, -1, 106, 107, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, 48, 49, 50, 51, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, 48, 49, 50, 51, 103, -1, 3, -1, 107, 108, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 48, 49, 50, 51, 103, -1, 3, -1, 107, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 48, 49, 50, 51, 103, -1, 3, 106, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, -1, -1, -1, -1, -1, -1, -1, -1, 47, 48, 49, 50, 51, 103, -1, 3, 106, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, 48, 49, 50, 51, 103, -1, 3, -1, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, 48, 49, 50, 51, 103, -1, 3, -1, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, 48, 49, 50, 51, 103, -1, 3, -1, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 51, 103, 56, -1, -1, 107, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, -1, 20, 21, 22, 23, 24, 25, 26, 27, -1, 29, 56, 31, -1, -1, 34, 35, 36, 37, -1, -1, -1, 96, 97, 98, 99, 100, -1, -1, -1, -1, -1, 103, -1, -1, -1, 107, -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 96, 97, 98, 99, 100, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 97, 98, 99, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 96, 97, 98, 99, 100, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 97, 98, 99, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { 0, 109, 110, 111, 130, 131, 277, 1, 3, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 46, 47, 48, 49, 50, 51, 68, 69, 70, 103, 106, 107, 215, 229, 230, 232, 233, 234, 235, 236, 256, 257, 267, 269, 1, 215, 1, 38, 0, 1, 4, 7, 8, 9, 19, 41, 42, 54, 60, 61, 62, 63, 64, 65, 66, 67, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 101, 106, 132, 133, 134, 136, 137, 138, 139, 140, 143, 144, 146, 147, 148, 149, 150, 151, 152, 155, 156, 157, 160, 162, 167, 168, 169, 170, 172, 175, 176, 177, 178, 179, 183, 184, 191, 192, 202, 211, 277, 93, 264, 277, 264, 46, 267, 128, 93, 41, 233, 229, 38, 52, 55, 74, 117, 124, 126, 220, 221, 223, 225, 226, 227, 228, 267, 277, 229, 235, 267, 105, 128, 268, 41, 41, 212, 213, 215, 277, 108, 38, 6, 272, 38, 274, 277, 1, 3, 231, 232, 38, 274, 38, 154, 277, 38, 38, 38, 82, 267, 3, 44, 267, 38, 4, 44, 38, 38, 41, 44, 4, 272, 38, 166, 231, 164, 166, 38, 38, 272, 38, 93, 257, 274, 38, 117, 223, 228, 267, 68, 231, 257, 10, 11, 12, 13, 14, 15, 16, 17, 18, 38, 53, 117, 120, 121, 124, 125, 126, 215, 216, 217, 219, 231, 232, 244, 245, 246, 247, 272, 277, 46, 107, 269, 257, 229, 38, 117, 212, 226, 228, 267, 44, 237, 238, 56, 244, 245, 244, 38, 126, 224, 227, 267, 228, 229, 267, 220, 38, 55, 220, 38, 55, 117, 224, 227, 267, 104, 269, 107, 269, 39, 40, 214, 277, 3, 265, 272, 6, 44, 265, 275, 265, 41, 52, 38, 223, 39, 265, 267, 3, 3, 265, 11, 161, 212, 212, 267, 41, 52, 194, 44, 3, 163, 275, 3, 212, 44, 222, 223, 226, 277, 41, 40, 165, 277, 265, 266, 277, 141, 142, 272, 212, 187, 188, 189, 215, 256, 277, 267, 272, 3, 117, 228, 267, 275, 38, 265, 117, 267, 104, 3, 239, 277, 38, 223, 44, 267, 244, 38, 244, 244, 244, 244, 244, 244, 94, 40, 218, 277, 38, 96, 97, 98, 99, 100, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 268, 94, 117, 228, 267, 225, 267, 39, 39, 117, 225, 267, 104, 55, 244, 56, 228, 267, 267, 38, 55, 228, 212, 56, 244, 212, 56, 244, 224, 227, 104, 117, 224, 268, 41, 215, 39, 171, 40, 52, 39, 237, 220, 39, 44, 39, 52, 39, 40, 159, 40, 39, 39, 41, 267, 131, 193, 39, 39, 39, 39, 164, 166, 39, 39, 40, 44, 39, 94, 40, 190, 277, 57, 104, 39, 228, 267, 41, 104, 41, 44, 212, 267, 78, 174, 220, 229, 181, 41, 74, 248, 249, 277, 39, 117, 124, 228, 231, 219, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 257, 267, 104, 39, 39, 104, 225, 244, 224, 267, 39, 104, 212, 56, 244, 39, 56, 39, 56, 117, 224, 227, 224, 214, 4, 44, 272, 131, 275, 141, 246, 272, 276, 41, 41, 135, 4, 153, 272, 4, 41, 44, 102, 158, 223, 272, 273, 265, 272, 276, 39, 215, 223, 44, 41, 45, 131, 42, 211, 164, 41, 44, 38, 45, 165, 3, 103, 107, 270, 41, 275, 215, 158, 185, 189, 145, 223, 272, 104, 138, 240, 241, 277, 39, 38, 40, 41, 44, 173, 78, 220, 1, 41, 64, 71, 72, 73, 76, 126, 136, 137, 138, 139, 143, 144, 148, 150, 152, 155, 157, 160, 162, 167, 168, 169, 170, 183, 184, 191, 195, 198, 199, 200, 201, 202, 203, 204, 207, 210, 211, 277, 250, 44, 244, 39, 124, 229, 39, 117, 221, 218, 74, 267, 39, 56, 39, 224, 39, 56, 224, 45, 40, 40, 195, 38, 78, 229, 259, 277, 52, 39, 40, 159, 158, 223, 259, 45, 272, 3, 231, 41, 52, 273, 212, 105, 128, 271, 128, 93, 39, 45, 172, 179, 183, 184, 186, 199, 201, 211, 190, 131, 259, 41, 3, 242, 40, 45, 38, 52, 259, 260, 212, 223, 38, 197, 44, 74, 74, 74, 126, 269, 45, 195, 108, 231, 257, 267, 76, 251, 252, 258, 277, 180, 244, 244, 39, 39, 244, 220, 39, 275, 275, 45, 212, 38, 78, 158, 272, 276, 41, 223, 39, 259, 41, 41, 223, 166, 39, 3, 3, 107, 3, 107, 216, 4, 44, 231, 58, 41, 52, 240, 240, 41, 223, 212, 237, 74, 261, 277, 39, 174, 212, 195, 196, 269, 38, 223, 231, 38, 74, 248, 267, 41, 40, 71, 72, 73, 253, 255, 195, 244, 39, 212, 38, 159, 259, 41, 223, 158, 41, 41, 271, 271, 94, 243, 244, 242, 174, 39, 41, 262, 263, 267, 41, 44, 220, 173, 39, 195, 38, 212, 174, 38, 117, 228, 212, 244, 44, 248, 252, 267, 254, 45, 41, 39, 212, 41, 259, 41, 240, 173, 41, 44, 40, 38, 220, 45, 212, 39, 173, 212, 38, 38, 117, 39, 41, 206, 44, 258, 41, 182, 223, 39, 41, 263, 195, 39, 208, 259, 39, 212, 212, 38, 260, 182, 205, 267, 174, 209, 259, 41, 44, 209, 39, 39, 212, 182, 173, 41, 44, 52, 209, 209, 39, 237, 209, 41 }; #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 1802 "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); check_extensions(); top = (yyvsp[(1) - (1)].node); } break; case 3: /* Line 1806 of yacc.c */ #line 1815 "parser.y" { top = Copy(Getattr((yyvsp[(2) - (3)].p),"type")); Delete((yyvsp[(2) - (3)].p)); } break; case 4: /* Line 1806 of yacc.c */ #line 1819 "parser.y" { top = 0; } break; case 5: /* Line 1806 of yacc.c */ #line 1822 "parser.y" { top = (yyvsp[(2) - (3)].p); } break; case 6: /* Line 1806 of yacc.c */ #line 1825 "parser.y" { top = 0; } break; case 7: /* Line 1806 of yacc.c */ #line 1828 "parser.y" { top = (yyvsp[(3) - (5)].pl); } break; case 8: /* Line 1806 of yacc.c */ #line 1831 "parser.y" { top = 0; } break; case 9: /* Line 1806 of yacc.c */ #line 1836 "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 1841 "parser.y" { (yyval.node) = new_node("top"); } break; case 11: /* Line 1806 of yacc.c */ #line 1846 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 12: /* Line 1806 of yacc.c */ #line 1847 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 13: /* Line 1806 of yacc.c */ #line 1848 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 14: /* Line 1806 of yacc.c */ #line 1849 "parser.y" { (yyval.node) = 0; } break; case 15: /* Line 1806 of yacc.c */ #line 1850 "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 1856 "parser.y" { if ((yyval.node)) { add_symbols((yyval.node)); } (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 17: /* Line 1806 of yacc.c */ #line 1872 "parser.y" { (yyval.node) = 0; skip_decl(); } break; case 18: /* Line 1806 of yacc.c */ #line 1882 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 19: /* Line 1806 of yacc.c */ #line 1883 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 20: /* Line 1806 of yacc.c */ #line 1884 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 21: /* Line 1806 of yacc.c */ #line 1885 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 22: /* Line 1806 of yacc.c */ #line 1886 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 23: /* Line 1806 of yacc.c */ #line 1887 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 24: /* Line 1806 of yacc.c */ #line 1888 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 25: /* Line 1806 of yacc.c */ #line 1889 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 26: /* Line 1806 of yacc.c */ #line 1890 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 27: /* Line 1806 of yacc.c */ #line 1891 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 28: /* Line 1806 of yacc.c */ #line 1892 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 29: /* Line 1806 of yacc.c */ #line 1893 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 30: /* Line 1806 of yacc.c */ #line 1894 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 31: /* Line 1806 of yacc.c */ #line 1895 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 32: /* Line 1806 of yacc.c */ #line 1896 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 33: /* Line 1806 of yacc.c */ #line 1897 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 34: /* Line 1806 of yacc.c */ #line 1898 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 35: /* Line 1806 of yacc.c */ #line 1899 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 36: /* Line 1806 of yacc.c */ #line 1900 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 37: /* Line 1806 of yacc.c */ #line 1901 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 38: /* Line 1806 of yacc.c */ #line 1902 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 39: /* Line 1806 of yacc.c */ #line 1909 "parser.y" { Node *cls; String *clsname; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); if (!classes_typedefs) classes_typedefs = NewHash(); if (!extendhash) extendhash = 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(extendhash,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; extendmode = 1; 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; extendmode = 1; } Classprefix = NewString((yyvsp[(3) - (4)].str)); Namespaceprefix= Swig_symbol_qualifiedscopename(0); Delete(clsname); } break; case 40: /* Line 1806 of yacc.c */ #line 1951 "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 members as extend */ tag_nodes((yyvsp[(6) - (7)].node),"feature:extend",(char*) "1"); 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(extendhash,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(extendhash,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 1995 "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 2005 "parser.y" { (yyval.node) = new_node("clear"); appendChild((yyval.node),(yyvsp[(2) - (3)].p)); } break; case 43: /* Line 1806 of yacc.c */ #line 2016 "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 2037 "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 2059 "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 2070 "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 2079 "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 2098 "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 2104 "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 2110 "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 2115 "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 2122 "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 2129 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"value",(yyvsp[(1) - (1)].id)); } break; case 54: /* Line 1806 of yacc.c */ #line 2133 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 55: /* Line 1806 of yacc.c */ #line 2146 "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 2155 "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 2170 "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 2183 "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 2192 "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 2238 "parser.y" { (yyval.loc).type = (char *) "include"; } break; case 61: /* Line 1806 of yacc.c */ #line 2239 "parser.y" { (yyval.loc).type = (char *) "import"; ++import_mode;} break; case 62: /* Line 1806 of yacc.c */ #line 2246 "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 2265 "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 2296 "parser.y" { (yyval.node) = new_node("insert"); Setattr((yyval.node),"code",(yyvsp[(1) - (1)].str)); } break; case 65: /* Line 1806 of yacc.c */ #line 2300 "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 2310 "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 2315 "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 2333 "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 (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 2373 "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 2379 "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 2392 "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 2398 "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 2424 "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 2430 "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 2437 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); } break; case 76: /* Line 1806 of yacc.c */ #line 2438 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 77: /* Line 1806 of yacc.c */ #line 2441 "parser.y" { (yyval.id) = (yyvsp[(2) - (3)].id); } break; case 78: /* Line 1806 of yacc.c */ #line 2442 "parser.y" { (yyval.id) = (char *) "swig"; } break; case 79: /* Line 1806 of yacc.c */ #line 2450 "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 2496 "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 2542 "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 2553 "parser.y" { (yyval.intvalue) = 1; } break; case 83: /* Line 1806 of yacc.c */ #line 2556 "parser.y" { (yyval.intvalue) = 0; } break; case 84: /* Line 1806 of yacc.c */ #line 2583 "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 2589 "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 2595 "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 2601 "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 2609 "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 2615 "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 2621 "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 2627 "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 2635 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 93: /* Line 1806 of yacc.c */ #line 2636 "parser.y" { (yyval.str) = 0; } break; case 94: /* Line 1806 of yacc.c */ #line 2637 "parser.y" { (yyval.str) = (yyvsp[(3) - (5)].pl); } break; case 95: /* Line 1806 of yacc.c */ #line 2640 "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 2645 "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 2655 "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 2691 "parser.y" { (yyval.pl) = (yyvsp[(1) - (1)].pl); } break; case 99: /* Line 1806 of yacc.c */ #line 2692 "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 2727 "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 2744 "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 2752 "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 2765 "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 2790 "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 2796 "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 2800 "parser.y" { (yyval.p) = 0;} break; case 107: /* Line 1806 of yacc.c */ #line 2803 "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 2814 "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 2819 "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 2832 "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 2844 "parser.y" { Parm *p, *tp; Node *n; Symtab *tscope = 0; int specialized = 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; } if (nnisclass && !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)))) { Swig_error(cparse_file, cparse_line, "Not enough template parameters specified. %d required.\n", ParmList_numrequired(tparms)); } 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; } } templnode = copy_node(nn); /* 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"); } if ((yyvsp[(3) - (9)].id) && !inclass) { /* 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); 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 = make_inherit_list(Getattr(templnode,"name"),baselist); 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 */ if (extendhash) { 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(extendhash,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")); */ merge_extensions(templnode,am); Swig_symbol_setscope(st); append_previous_extension(templnode,am); Delattr(extendhash,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 3118 "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 3128 "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 3135 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 115: /* Line 1806 of yacc.c */ #line 3136 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 116: /* Line 1806 of yacc.c */ #line 3140 "parser.y" { if (Strcmp((yyvsp[(2) - (3)].id),"C") == 0) { cparse_externc = 1; } } break; case 117: /* Line 1806 of yacc.c */ #line 3144 "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 3171 "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); 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 119: /* Line 1806 of yacc.c */ #line 3232 "parser.y" { (yyval.node) = 0; Clear(scanner_ccode); } break; case 120: /* Line 1806 of yacc.c */ #line 3236 "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); 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 121: /* Line 1806 of yacc.c */ #line 3258 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; } break; case 122: /* Line 1806 of yacc.c */ #line 3264 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); (yyval.dtype).qualifier = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; } break; case 123: /* Line 1806 of yacc.c */ #line 3270 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).qualifier = (yyvsp[(1) - (2)].str); (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; } break; case 124: /* Line 1806 of yacc.c */ #line 3276 "parser.y" { (yyval.dtype) = (yyvsp[(5) - (5)].dtype); (yyval.dtype).qualifier = 0; (yyval.dtype).throws = (yyvsp[(3) - (5)].pl); (yyval.dtype).throwf = NewString("1"); } break; case 125: /* Line 1806 of yacc.c */ #line 3282 "parser.y" { (yyval.dtype) = (yyvsp[(6) - (6)].dtype); (yyval.dtype).qualifier = (yyvsp[(1) - (6)].str); (yyval.dtype).throws = (yyvsp[(4) - (6)].pl); (yyval.dtype).throwf = NewString("1"); } break; case 126: /* Line 1806 of yacc.c */ #line 3295 "parser.y" { SwigType *ty = 0; (yyval.node) = new_node("enumforward"); ty = NewStringf("enum %s", (yyvsp[(3) - (4)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (4)].id)); Setattr((yyval.node),"type",ty); Setattr((yyval.node),"sym:weak", "1"); add_symbols((yyval.node)); } break; case 127: /* Line 1806 of yacc.c */ #line 3310 "parser.y" { SwigType *ty = 0; (yyval.node) = new_node("enum"); ty = NewStringf("enum %s", (yyvsp[(3) - (7)].id)); Setattr((yyval.node),"name",(yyvsp[(3) - (7)].id)); Setattr((yyval.node),"type",ty); appendChild((yyval.node),(yyvsp[(5) - (7)].node)); add_symbols((yyval.node)); /* Add to tag space */ add_symbols((yyvsp[(5) - (7)].node)); /* Add enum values to id space */ } break; case 128: /* Line 1806 of yacc.c */ #line 3320 "parser.y" { Node *n; SwigType *ty = 0; String *unnamed = 0; int unnamedinstance = 0; (yyval.node) = new_node("enum"); if ((yyvsp[(3) - (9)].id)) { Setattr((yyval.node),"name",(yyvsp[(3) - (9)].id)); ty = NewStringf("enum %s", (yyvsp[(3) - (9)].id)); } else if ((yyvsp[(7) - (9)].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) - (9)].id) && Cmp((yyvsp[(1) - (9)].id),"typedef") == 0) { Setattr((yyval.node),"name",(yyvsp[(7) - (9)].decl).id); } else { unnamedinstance = 1; } Setattr((yyval.node),"storage",(yyvsp[(1) - (9)].id)); } if ((yyvsp[(7) - (9)].decl).id && Cmp((yyvsp[(1) - (9)].id),"typedef") == 0) { Setattr((yyval.node),"tdname",(yyvsp[(7) - (9)].decl).id); Setattr((yyval.node),"allows_typedef","1"); } appendChild((yyval.node),(yyvsp[(5) - (9)].node)); n = new_node("cdecl"); Setattr(n,"type",ty); Setattr(n,"name",(yyvsp[(7) - (9)].decl).id); Setattr(n,"storage",(yyvsp[(1) - (9)].id)); Setattr(n,"decl",(yyvsp[(7) - (9)].decl).type); Setattr(n,"parms",(yyvsp[(7) - (9)].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[(9) - (9)].node)) { Node *p = (yyvsp[(9) - (9)].node); set_nextSibling(n,p); while (p) { SwigType *cty = Copy(ty); Setattr(p,"type",cty); Setattr(p,"unnamed",unnamed); Setattr(p,"storage",(yyvsp[(1) - (9)].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[(7) - (9)].decl).id && (yyvsp[(3) - (9)].id) && Cmp((yyvsp[(1) - (9)].id),"typedef") == 0) { String *name = NewString((yyvsp[(7) - (9)].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); add_symbols((yyvsp[(5) - (9)].node)); /* Add enum values to id space */ add_symbols(n); Delete(unnamed); } break; case 129: /* Line 1806 of yacc.c */ #line 3398 "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); err = 0; } } if (err) { Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n"); exit(1); } } break; case 130: /* Line 1806 of yacc.c */ #line 3449 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 131: /* Line 1806 of yacc.c */ #line 3450 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 132: /* Line 1806 of yacc.c */ #line 3451 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 133: /* Line 1806 of yacc.c */ #line 3452 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 134: /* Line 1806 of yacc.c */ #line 3453 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 135: /* Line 1806 of yacc.c */ #line 3454 "parser.y" { (yyval.node) = 0; } break; case 136: /* Line 1806 of yacc.c */ #line 3459 "parser.y" { if (nested_template == 0) { String *prefix; List *bases = 0; Node *scope = 0; (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 */ 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)); Setfile(scope,cparse_file); Setline(scope,cparse_line); (yyvsp[(3) - (5)].str) = scope; /* support for old nested classes "pseudo" support, such as: %rename(Ala__Ola) Ala::Ola; class Ala::Ola { public: Ola() {} }; this should disappear when a proper implementation is added. */ if (nscope_inner && Strcmp(nodeType(nscope_inner),"namespace") != 0) { if (Namespaceprefix) { String *name = NewStringf("%s::%s", Namespaceprefix, (yyvsp[(3) - (5)].str)); (yyvsp[(3) - (5)].str) = name; Namespaceprefix = 0; nscope_inner = 0; } } Setattr((yyval.node),"name",(yyvsp[(3) - (5)].str)); Delete(class_rename); class_rename = make_name((yyval.node),(yyvsp[(3) - (5)].str),0); Classprefix = NewString((yyvsp[(3) - (5)].str)); /* Deal with inheritance */ if ((yyvsp[(4) - (5)].bases)) { bases = make_inherit_list((yyvsp[(3) - (5)].str),Getattr((yyvsp[(4) - (5)].bases),"public")); } 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; } Swig_symbol_newscope(); Swig_symbol_setscopename((yyvsp[(3) - (5)].str)); 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); } 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); } } if (class_level >= max_class_levels) { if (!max_class_levels) { max_class_levels = 16; } else { max_class_levels *= 2; } class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } class_decl[class_level++] = (yyval.node); Delete(prefix); inclass = 1; } } break; case 137: /* Line 1806 of yacc.c */ #line 3576 "parser.y" { (void) (yyvsp[(6) - (9)].node); if (nested_template == 0) { Node *p; SwigType *ty; Symtab *cscope = prev_symtab; Node *am = 0; String *scpname = 0; (yyval.node) = class_decl[--class_level]; inclass = 0; /* 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) */ if (extendhash) { String *clsname = Swig_symbol_qualifiedscopename(0); am = Getattr(extendhash,clsname); if (am) { merge_extensions((yyval.node),am); Delattr(extendhash,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) append_previous_extension((yyval.node),am); p = (yyvsp[(9) - (9)].node); if (p) { set_nextSibling((yyval.node),p); } 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); p = nextSibling(p); } /* Class typedefs */ { String *name = (yyvsp[(3) - (9)].str); if ((yyvsp[(9) - (9)].node)) { SwigType *decltype = Getattr((yyvsp[(9) - (9)].node),"decl"); if (Cmp((yyvsp[(1) - (9)].id),"typedef") == 0) { if (!decltype || !Len(decltype)) { String *cname; String *tdscopename; String *class_scope = Swig_symbol_qualifiedscopename(cscope); name = Getattr((yyvsp[(9) - (9)].node),"name"); cname = Copy(name); Setattr((yyval.node),"tdname",cname); tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name); /* Use typedef name as class name */ if (class_rename && (Strcmp(class_rename,(yyvsp[(3) - (9)].str)) == 0)) { Delete(class_rename); class_rename = NewString(name); } if (!classes_typedefs) classes_typedefs = NewHash(); if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) { Setattr(classes_typedefs, tdscopename, (yyval.node)); } Setattr((yyval.node),"decl",decltype); Delete(class_scope); Delete(cname); Delete(tdscopename); } } } appendChild((yyval.node),dump_nested(Char(name))); } 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); } Setattr((yyval.node),"symtab",Swig_symbol_popscope()); Classprefix = 0; 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); add_symbols((yyval.node)); if (nscope) (yyval.node) = nscope; /* 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)); } else { Delete(yyrename); yyrename = Copy(class_rename); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyval.node)); add_symbols((yyvsp[(9) - (9)].node)); } Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } else { (yyval.node) = new_node("class"); Setattr((yyval.node),"kind",(yyvsp[(2) - (9)].id)); Setattr((yyval.node),"name",NewString((yyvsp[(3) - (9)].str))); SetFlag((yyval.node),"nestedtemplateclass"); } } break; case 138: /* Line 1806 of yacc.c */ #line 3708 "parser.y" { String *unnamed; unnamed = make_unnamed(); (yyval.node) = new_node("class"); Setline((yyval.node),cparse_start_line); Setattr((yyval.node),"kind",(yyvsp[(2) - (3)].id)); Setattr((yyval.node),"storage",(yyvsp[(1) - (3)].id)); Setattr((yyval.node),"unnamed",unnamed); Setattr((yyval.node),"allows_typedef","1"); Delete(class_rename); class_rename = make_name((yyval.node),0,0); if (strcmp((yyvsp[(2) - (3)].id),"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { cplus_mode = CPLUS_PUBLIC; } Swig_symbol_newscope(); cparse_start_line = cparse_line; if (class_level >= max_class_levels) { if (!max_class_levels) { max_class_levels = 16; } else { max_class_levels *= 2; } class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } class_decl[class_level++] = (yyval.node); inclass = 1; Classprefix = NewStringEmpty(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } break; case 139: /* Line 1806 of yacc.c */ #line 3742 "parser.y" { String *unnamed; Node *n; (void) (yyvsp[(4) - (9)].node); Classprefix = 0; (yyval.node) = class_decl[--class_level]; inclass = 0; unnamed = Getattr((yyval.node),"unnamed"); /* Check for pure-abstract class */ Setattr((yyval.node),"abstracts", pure_abstracts((yyvsp[(5) - (9)].node))); n = new_node("cdecl"); Setattr(n,"name",(yyvsp[(7) - (9)].decl).id); Setattr(n,"unnamed",unnamed); Setattr(n,"type",unnamed); Setattr(n,"decl",(yyvsp[(7) - (9)].decl).type); Setattr(n,"parms",(yyvsp[(7) - (9)].decl).parms); Setattr(n,"storage",(yyvsp[(1) - (9)].id)); if ((yyvsp[(9) - (9)].node)) { Node *p = (yyvsp[(9) - (9)].node); set_nextSibling(n,p); while (p) { String *type = Copy(unnamed); Setattr(p,"name",(yyvsp[(7) - (9)].decl).id); Setattr(p,"unnamed",unnamed); Setattr(p,"type",type); Delete(type); Setattr(p,"storage",(yyvsp[(1) - (9)].id)); p = nextSibling(p); } } set_nextSibling((yyval.node),n); Delete(n); { /* If a proper typedef name was given, we'll use it to set the scope name */ String *name = 0; if ((yyvsp[(1) - (9)].id) && (strcmp((yyvsp[(1) - (9)].id),"typedef") == 0)) { if (!Len((yyvsp[(7) - (9)].decl).type)) { String *scpname = 0; name = (yyvsp[(7) - (9)].decl).id; Setattr((yyval.node),"tdname",name); Setattr((yyval.node),"name",name); Swig_symbol_setscopename(name); /* If a proper name was given, we use that as the typedef, not unnamed */ Clear(unnamed); Append(unnamed, name); n = nextSibling(n); set_nextSibling((yyval.node),n); /* Check for previous extensions */ if (extendhash) { String *clsname = Swig_symbol_qualifiedscopename(0); Node *am = Getattr(extendhash,clsname); if (am) { /* Merge the extension into the symbol table */ merge_extensions((yyval.node),am); append_previous_extension((yyval.node),am); Delattr(extendhash,clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,(yyval.node)); Delete(scpname); } else { Swig_symbol_setscopename(""); } } appendChild((yyval.node),(yyvsp[(5) - (9)].node)); appendChild((yyval.node),dump_nested(Char(name))); } /* Pop the scope */ Setattr((yyval.node),"symtab",Swig_symbol_popscope()); if (class_rename) { Delete(yyrename); yyrename = NewString(class_rename); } Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols((yyval.node)); add_symbols(n); Delete(unnamed); } break; case 140: /* Line 1806 of yacc.c */ #line 3831 "parser.y" { (yyval.node) = 0; } break; case 141: /* Line 1806 of yacc.c */ #line 3832 "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 142: /* Line 1806 of yacc.c */ #line 3844 "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 143: /* Line 1806 of yacc.c */ #line 3862 "parser.y" { template_parameters = (yyvsp[(3) - (4)].tparms); if (inclass) nested_template++; } break; case 144: /* Line 1806 of yacc.c */ #line 3867 "parser.y" { /* Don't ignore templated functions declared within a class, unless the templated function is within a nested class */ if (nested_template <= 1) { int is_nested_template_class = (yyvsp[(6) - (6)].node) && GetFlag((yyvsp[(6) - (6)].node), "nestedtemplateclass"); if (is_nested_template_class) { (yyval.node) = 0; /* Nested template classes would probably better be ignored like ordinary nested classes using cpp_nested, but that introduces shift/reduce conflicts */ if (cplus_mode == CPLUS_PUBLIC) { /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ String *kind = Getattr((yyvsp[(6) - (6)].node), "kind"); String *name = Getattr((yyvsp[(6) - (6)].node), "name"); (yyval.node) = new_node("template"); Setattr((yyval.node),"kind",kind); Setattr((yyval.node),"name",name); Setattr((yyval.node),"sym:weak", "1"); Setattr((yyval.node),"templatetype","classforward"); Setattr((yyval.node),"templateparms", (yyvsp[(3) - (6)].tparms)); add_symbols((yyval.node)); if (GetFlag((yyval.node), "feature:nestedworkaround")) { Swig_symbol_remove((yyval.node)); (yyval.node) = 0; } else { SWIG_WARN_NODE_BEGIN((yyval.node)); Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested template %s not currently supported (%s ignored).\n", kind, name); SWIG_WARN_NODE_END((yyval.node)); } } Delete((yyvsp[(6) - (6)].node)); } else { 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; } } else { (yyval.node) = 0; } template_parameters = 0; if (inclass) nested_template--; } break; case 145: /* Line 1806 of yacc.c */ #line 4151 "parser.y" { Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); (yyval.node) = 0; } break; case 146: /* Line 1806 of yacc.c */ #line 4157 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 147: /* Line 1806 of yacc.c */ #line 4160 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 148: /* Line 1806 of yacc.c */ #line 4163 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 149: /* Line 1806 of yacc.c */ #line 4166 "parser.y" { (yyval.node) = 0; } break; case 150: /* Line 1806 of yacc.c */ #line 4169 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 151: /* Line 1806 of yacc.c */ #line 4172 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 152: /* Line 1806 of yacc.c */ #line 4177 "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 { /* Swig_error(cparse_file, cparse_line, "Missing template parameter name\n"); $$.rparms = 0; $$.parms = 0; break; */ } } p = nextSibling(p); } } break; case 153: /* Line 1806 of yacc.c */ #line 4207 "parser.y" { set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].pl)); (yyval.pl) = (yyvsp[(1) - (2)].p); } break; case 154: /* Line 1806 of yacc.c */ #line 4211 "parser.y" { (yyval.pl) = 0; } break; case 155: /* Line 1806 of yacc.c */ #line 4214 "parser.y" { (yyval.p) = NewParmWithoutFileLineInfo(NewString((yyvsp[(1) - (1)].id)), 0); } break; case 156: /* Line 1806 of yacc.c */ #line 4217 "parser.y" { (yyval.p) = (yyvsp[(1) - (1)].p); } break; case 157: /* Line 1806 of yacc.c */ #line 4222 "parser.y" { set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].pl)); (yyval.pl) = (yyvsp[(2) - (3)].p); } break; case 158: /* Line 1806 of yacc.c */ #line 4226 "parser.y" { (yyval.pl) = 0; } break; case 159: /* Line 1806 of yacc.c */ #line 4231 "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 160: /* Line 1806 of yacc.c */ #line 4241 "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 161: /* Line 1806 of yacc.c */ #line 4272 "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 162: /* Line 1806 of yacc.c */ #line 4290 "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 163: /* Line 1806 of yacc.c */ #line 4301 "parser.y" { Hash *h; (yyvsp[(1) - (2)].node) = Swig_symbol_current(); h = Swig_symbol_clookup((char *)" ",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 164: /* Line 1806 of yacc.c */ #line 4313 "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 165: /* Line 1806 of yacc.c */ #line 4323 "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 166: /* Line 1806 of yacc.c */ #line 4350 "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)); } else { (yyval.node) = (yyvsp[(2) - (2)].node); } } break; case 167: /* Line 1806 of yacc.c */ #line 4365 "parser.y" { if (cplus_mode != CPLUS_PUBLIC) { Swig_error(cparse_file,cparse_line,"%%extend can only be used in a public section\n"); } } break; case 168: /* Line 1806 of yacc.c */ #line 4369 "parser.y" { (yyval.node) = new_node("extend"); tag_nodes((yyvsp[(4) - (6)].node),"feature:extend",(char*) "1"); appendChild((yyval.node),(yyvsp[(4) - (6)].node)); set_nextSibling((yyval.node),(yyvsp[(6) - (6)].node)); } break; case 169: /* Line 1806 of yacc.c */ #line 4375 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 170: /* Line 1806 of yacc.c */ #line 4376 "parser.y" { (yyval.node) = 0;} break; case 171: /* Line 1806 of yacc.c */ #line 4377 "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 172: /* Line 1806 of yacc.c */ #line 4382 "parser.y" { (yyval.node) = (yyvsp[(3) - (3)].node); } break; case 173: /* Line 1806 of yacc.c */ #line 4393 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 174: /* Line 1806 of yacc.c */ #line 4394 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); if (extendmode) { 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 175: /* Line 1806 of yacc.c */ #line 4411 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 176: /* Line 1806 of yacc.c */ #line 4412 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 177: /* Line 1806 of yacc.c */ #line 4413 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 178: /* Line 1806 of yacc.c */ #line 4414 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 179: /* Line 1806 of yacc.c */ #line 4415 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 180: /* Line 1806 of yacc.c */ #line 4416 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 181: /* Line 1806 of yacc.c */ #line 4417 "parser.y" { (yyval.node) = 0; } break; case 182: /* Line 1806 of yacc.c */ #line 4418 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 183: /* Line 1806 of yacc.c */ #line 4419 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 184: /* Line 1806 of yacc.c */ #line 4420 "parser.y" { (yyval.node) = 0; } break; case 185: /* Line 1806 of yacc.c */ #line 4421 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 186: /* Line 1806 of yacc.c */ #line 4422 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 187: /* Line 1806 of yacc.c */ #line 4423 "parser.y" { (yyval.node) = 0; } break; case 188: /* Line 1806 of yacc.c */ #line 4424 "parser.y" {(yyval.node) = (yyvsp[(1) - (1)].node); } break; case 189: /* Line 1806 of yacc.c */ #line 4425 "parser.y" {(yyval.node) = (yyvsp[(1) - (1)].node); } break; case 190: /* Line 1806 of yacc.c */ #line 4426 "parser.y" { (yyval.node) = 0; } break; case 191: /* Line 1806 of yacc.c */ #line 4435 "parser.y" { if (Classprefix) { 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); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr((yyval.node),"code",code); Delete(code); } SetFlag((yyval.node),"feature:new"); } else { (yyval.node) = 0; } } break; case 192: /* Line 1806 of yacc.c */ #line 4460 "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); add_symbols((yyval.node)); } break; case 193: /* Line 1806 of yacc.c */ #line 4484 "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); if ((yyvsp[(7) - (7)].dtype).val) { Setattr((yyval.node),"value","0"); } 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 194: /* Line 1806 of yacc.c */ #line 4515 "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 195: /* Line 1806 of yacc.c */ #line 4530 "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 196: /* Line 1806 of yacc.c */ #line 4548 "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 197: /* Line 1806 of yacc.c */ #line 4567 "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 198: /* Line 1806 of yacc.c */ #line 4586 "parser.y" { skip_balanced('{','}'); (yyval.node) = 0; } break; case 199: /* Line 1806 of yacc.c */ #line 4593 "parser.y" { (yyval.node) = new_node("access"); Setattr((yyval.node),"kind","public"); cplus_mode = CPLUS_PUBLIC; } break; case 200: /* Line 1806 of yacc.c */ #line 4600 "parser.y" { (yyval.node) = new_node("access"); Setattr((yyval.node),"kind","private"); cplus_mode = CPLUS_PRIVATE; } break; case 201: /* Line 1806 of yacc.c */ #line 4608 "parser.y" { (yyval.node) = new_node("access"); Setattr((yyval.node),"kind","protected"); cplus_mode = CPLUS_PROTECTED; } break; case 202: /* Line 1806 of yacc.c */ #line 4629 "parser.y" { cparse_start_line = cparse_line; skip_balanced('{','}'); (yyval.str) = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } break; case 203: /* Line 1806 of yacc.c */ #line 4633 "parser.y" { (yyval.node) = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { String *name = Copy((yyvsp[(3) - (7)].str)); (yyval.node) = nested_forward_declaration((yyvsp[(1) - (7)].id), (yyvsp[(2) - (7)].id), (yyvsp[(3) - (7)].str), name, (yyvsp[(7) - (7)].node)); } else if ((yyvsp[(7) - (7)].node)) { nested_new_struct((yyvsp[(2) - (7)].id), (yyvsp[(6) - (7)].str), (yyvsp[(7) - (7)].node)); } } Delete((yyvsp[(6) - (7)].str)); } break; case 204: /* Line 1806 of yacc.c */ #line 4656 "parser.y" { cparse_start_line = cparse_line; skip_balanced('{','}'); (yyval.str) = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } break; case 205: /* Line 1806 of yacc.c */ #line 4660 "parser.y" { (yyval.node) = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { String *name = (yyvsp[(6) - (6)].node) ? Copy(Getattr((yyvsp[(6) - (6)].node), "name")) : 0; (yyval.node) = nested_forward_declaration((yyvsp[(1) - (6)].id), (yyvsp[(2) - (6)].id), 0, name, (yyvsp[(6) - (6)].node)); } else { if ((yyvsp[(6) - (6)].node)) { nested_new_struct((yyvsp[(2) - (6)].id), (yyvsp[(5) - (6)].str), (yyvsp[(6) - (6)].node)); } else { Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", (yyvsp[(2) - (6)].id)); } } } Delete((yyvsp[(5) - (6)].str)); } break; case 206: /* Line 1806 of yacc.c */ #line 4692 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 207: /* Line 1806 of yacc.c */ #line 4695 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 208: /* Line 1806 of yacc.c */ #line 4699 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 209: /* Line 1806 of yacc.c */ #line 4702 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 210: /* Line 1806 of yacc.c */ #line 4703 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 211: /* Line 1806 of yacc.c */ #line 4704 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 212: /* Line 1806 of yacc.c */ #line 4705 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 213: /* Line 1806 of yacc.c */ #line 4706 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 214: /* Line 1806 of yacc.c */ #line 4707 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 215: /* Line 1806 of yacc.c */ #line 4708 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 216: /* Line 1806 of yacc.c */ #line 4709 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 217: /* Line 1806 of yacc.c */ #line 4712 "parser.y" { Clear(scanner_ccode); (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; } break; case 218: /* Line 1806 of yacc.c */ #line 4717 "parser.y" { skip_balanced('{','}'); (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; } break; case 219: /* Line 1806 of yacc.c */ #line 4724 "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; } break; case 220: /* Line 1806 of yacc.c */ #line 4732 "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; } break; case 221: /* Line 1806 of yacc.c */ #line 4740 "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; } break; case 222: /* Line 1806 of yacc.c */ #line 4751 "parser.y" { } break; case 223: /* Line 1806 of yacc.c */ #line 4757 "parser.y" { (yyval.id) = "extern"; } break; case 224: /* Line 1806 of yacc.c */ #line 4758 "parser.y" { if (strcmp((yyvsp[(2) - (2)].id),"C") == 0) { (yyval.id) = "externc"; } 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 225: /* Line 1806 of yacc.c */ #line 4766 "parser.y" { (yyval.id) = "static"; } break; case 226: /* Line 1806 of yacc.c */ #line 4767 "parser.y" { (yyval.id) = "typedef"; } break; case 227: /* Line 1806 of yacc.c */ #line 4768 "parser.y" { (yyval.id) = "virtual"; } break; case 228: /* Line 1806 of yacc.c */ #line 4769 "parser.y" { (yyval.id) = "friend"; } break; case 229: /* Line 1806 of yacc.c */ #line 4770 "parser.y" { (yyval.id) = "explicit"; } break; case 230: /* Line 1806 of yacc.c */ #line 4771 "parser.y" { (yyval.id) = 0; } break; case 231: /* Line 1806 of yacc.c */ #line 4778 "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 232: /* Line 1806 of yacc.c */ #line 4789 "parser.y" { set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].pl)); (yyval.pl) = (yyvsp[(1) - (2)].p); } break; case 233: /* Line 1806 of yacc.c */ #line 4793 "parser.y" { (yyval.pl) = 0; } break; case 234: /* Line 1806 of yacc.c */ #line 4796 "parser.y" { set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].pl)); (yyval.pl) = (yyvsp[(2) - (3)].p); } break; case 235: /* Line 1806 of yacc.c */ #line 4800 "parser.y" { (yyval.pl) = 0; } break; case 236: /* Line 1806 of yacc.c */ #line 4804 "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 237: /* Line 1806 of yacc.c */ #line 4814 "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 238: /* Line 1806 of yacc.c */ #line 4822 "parser.y" { SwigType *t = NewString("v(...)"); (yyval.p) = NewParmWithoutFileLineInfo(t, 0); Setfile((yyval.p),cparse_file); Setline((yyval.p),cparse_line); } break; case 239: /* Line 1806 of yacc.c */ #line 4830 "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 240: /* Line 1806 of yacc.c */ #line 4843 "parser.y" { set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].p)); (yyval.p) = (yyvsp[(1) - (2)].p); } break; case 241: /* Line 1806 of yacc.c */ #line 4847 "parser.y" { (yyval.p) = 0; } break; case 242: /* Line 1806 of yacc.c */ #line 4850 "parser.y" { set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].p)); (yyval.p) = (yyvsp[(2) - (3)].p); } break; case 243: /* Line 1806 of yacc.c */ #line 4854 "parser.y" { (yyval.p) = 0; } break; case 244: /* Line 1806 of yacc.c */ #line 4858 "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 245: /* Line 1806 of yacc.c */ #line 4886 "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 246: /* Line 1806 of yacc.c */ #line 4894 "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; } } break; case 247: /* Line 1806 of yacc.c */ #line 4905 "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; } else { (yyval.dtype).val = NewStringf("%s[%s]",(yyvsp[(2) - (5)].dtype).val,(yyvsp[(4) - (5)].dtype).val); } } break; case 248: /* Line 1806 of yacc.c */ #line 4919 "parser.y" { skip_balanced('{','}'); (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; } break; case 249: /* Line 1806 of yacc.c */ #line 4928 "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; } break; case 250: /* Line 1806 of yacc.c */ #line 4936 "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; } break; case 251: /* Line 1806 of yacc.c */ #line 4946 "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 252: /* Line 1806 of yacc.c */ #line 4950 "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 253: /* Line 1806 of yacc.c */ #line 4954 "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 254: /* Line 1806 of yacc.c */ #line 4961 "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 255: /* Line 1806 of yacc.c */ #line 4978 "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 256: /* Line 1806 of yacc.c */ #line 4995 "parser.y" { (yyval.decl).type = 0; (yyval.decl).id = 0; (yyval.decl).parms = 0; } break; case 257: /* Line 1806 of yacc.c */ #line 5003 "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 258: /* Line 1806 of yacc.c */ #line 5011 "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 259: /* Line 1806 of yacc.c */ #line 5020 "parser.y" { (yyval.decl) = (yyvsp[(1) - (1)].decl); if (!(yyval.decl).type) (yyval.decl).type = NewStringEmpty(); } break; case 260: /* Line 1806 of yacc.c */ #line 5024 "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 261: /* Line 1806 of yacc.c */ #line 5033 "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 262: /* Line 1806 of yacc.c */ #line 5044 "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 263: /* Line 1806 of yacc.c */ #line 5056 "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 264: /* Line 1806 of yacc.c */ #line 5066 "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 265: /* Line 1806 of yacc.c */ #line 5079 "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 266: /* Line 1806 of yacc.c */ #line 5086 "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 267: /* Line 1806 of yacc.c */ #line 5094 "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 268: /* Line 1806 of yacc.c */ #line 5110 "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 269: /* Line 1806 of yacc.c */ #line 5118 "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 270: /* Line 1806 of yacc.c */ #line 5129 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (3)].decl); t = NewStringEmpty(); SwigType_add_array(t,(char*)""); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 271: /* Line 1806 of yacc.c */ #line 5140 "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 272: /* Line 1806 of yacc.c */ #line 5151 "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 273: /* Line 1806 of yacc.c */ #line 5170 "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 274: /* Line 1806 of yacc.c */ #line 5178 "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 275: /* Line 1806 of yacc.c */ #line 5195 "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 276: /* Line 1806 of yacc.c */ #line 5203 "parser.y" { (yyval.decl) = (yyvsp[(3) - (4)].decl); if (!(yyval.decl).type) { (yyval.decl).type = NewStringEmpty(); } SwigType_add_reference((yyval.decl).type); } break; case 277: /* Line 1806 of yacc.c */ #line 5210 "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 278: /* Line 1806 of yacc.c */ #line 5221 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (3)].decl); t = NewStringEmpty(); SwigType_add_array(t,(char*)""); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 279: /* Line 1806 of yacc.c */ #line 5232 "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 280: /* Line 1806 of yacc.c */ #line 5243 "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 281: /* Line 1806 of yacc.c */ #line 5262 "parser.y" { (yyval.decl).type = (yyvsp[(1) - (1)].type); (yyval.decl).id = 0; (yyval.decl).parms = 0; (yyval.decl).have_parms = 0; } break; case 282: /* Line 1806 of yacc.c */ #line 5268 "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 283: /* Line 1806 of yacc.c */ #line 5274 "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 284: /* Line 1806 of yacc.c */ #line 5281 "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 285: /* Line 1806 of yacc.c */ #line 5290 "parser.y" { (yyval.decl) = (yyvsp[(1) - (1)].decl); } break; case 286: /* Line 1806 of yacc.c */ #line 5293 "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 287: /* Line 1806 of yacc.c */ #line 5302 "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 288: /* Line 1806 of yacc.c */ #line 5309 "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 289: /* Line 1806 of yacc.c */ #line 5316 "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 290: /* Line 1806 of yacc.c */ #line 5326 "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 291: /* Line 1806 of yacc.c */ #line 5337 "parser.y" { SwigType *t; (yyval.decl) = (yyvsp[(1) - (3)].decl); t = NewStringEmpty(); SwigType_add_array(t,(char*)""); if ((yyval.decl).type) { SwigType_push(t,(yyval.decl).type); Delete((yyval.decl).type); } (yyval.decl).type = t; } break; case 292: /* Line 1806 of yacc.c */ #line 5348 "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 293: /* Line 1806 of yacc.c */ #line 5359 "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,(char*)""); } break; case 294: /* Line 1806 of yacc.c */ #line 5366 "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 295: /* Line 1806 of yacc.c */ #line 5373 "parser.y" { (yyval.decl) = (yyvsp[(2) - (3)].decl); } break; case 296: /* Line 1806 of yacc.c */ #line 5376 "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 297: /* Line 1806 of yacc.c */ #line 5393 "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 298: /* Line 1806 of yacc.c */ #line 5403 "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 299: /* Line 1806 of yacc.c */ #line 5410 "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 300: /* Line 1806 of yacc.c */ #line 5416 "parser.y" { (yyval.type) = NewStringEmpty(); SwigType_add_pointer((yyval.type)); SwigType_push((yyval.type),(yyvsp[(2) - (2)].str)); } break; case 301: /* Line 1806 of yacc.c */ #line 5421 "parser.y" { (yyval.type) = NewStringEmpty(); SwigType_add_pointer((yyval.type)); } break; case 302: /* Line 1806 of yacc.c */ #line 5427 "parser.y" { (yyval.str) = NewStringEmpty(); if ((yyvsp[(1) - (1)].id)) SwigType_add_qualifier((yyval.str),(yyvsp[(1) - (1)].id)); } break; case 303: /* Line 1806 of yacc.c */ #line 5431 "parser.y" { (yyval.str) = (yyvsp[(2) - (2)].str); if ((yyvsp[(1) - (2)].id)) SwigType_add_qualifier((yyval.str),(yyvsp[(1) - (2)].id)); } break; case 304: /* Line 1806 of yacc.c */ #line 5437 "parser.y" { (yyval.id) = "const"; } break; case 305: /* Line 1806 of yacc.c */ #line 5438 "parser.y" { (yyval.id) = "volatile"; } break; case 306: /* Line 1806 of yacc.c */ #line 5439 "parser.y" { (yyval.id) = 0; } break; case 307: /* Line 1806 of yacc.c */ #line 5445 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); Replace((yyval.type),"typename ","", DOH_REPLACE_ANY); } break; case 308: /* Line 1806 of yacc.c */ #line 5451 "parser.y" { (yyval.type) = (yyvsp[(2) - (2)].type); SwigType_push((yyval.type),(yyvsp[(1) - (2)].str)); } break; case 309: /* Line 1806 of yacc.c */ #line 5455 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 310: /* Line 1806 of yacc.c */ #line 5456 "parser.y" { (yyval.type) = (yyvsp[(1) - (2)].type); SwigType_push((yyval.type),(yyvsp[(2) - (2)].str)); } break; case 311: /* Line 1806 of yacc.c */ #line 5460 "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 312: /* Line 1806 of yacc.c */ #line 5467 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); /* Printf(stdout,"primitive = '%s'\n", $$);*/ } break; case 313: /* Line 1806 of yacc.c */ #line 5470 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 314: /* Line 1806 of yacc.c */ #line 5471 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 315: /* Line 1806 of yacc.c */ #line 5472 "parser.y" { (yyval.type) = NewStringf("%s%s",(yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].id)); } break; case 316: /* Line 1806 of yacc.c */ #line 5473 "parser.y" { (yyval.type) = NewStringf("enum %s", (yyvsp[(2) - (2)].str)); } break; case 317: /* Line 1806 of yacc.c */ #line 5474 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; case 318: /* Line 1806 of yacc.c */ #line 5476 "parser.y" { (yyval.type) = (yyvsp[(1) - (1)].str); } break; case 319: /* Line 1806 of yacc.c */ #line 5479 "parser.y" { (yyval.type) = NewStringf("%s %s", (yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].str)); } break; case 320: /* Line 1806 of yacc.c */ #line 5484 "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 321: /* Line 1806 of yacc.c */ #line 5509 "parser.y" { (yyval.ptype) = (yyvsp[(1) - (1)].ptype); } break; case 322: /* Line 1806 of yacc.c */ #line 5512 "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 323: /* Line 1806 of yacc.c */ #line 5566 "parser.y" { (yyval.ptype).type = NewString("int"); (yyval.ptype).us = 0; } break; case 324: /* Line 1806 of yacc.c */ #line 5570 "parser.y" { (yyval.ptype).type = NewString("short"); (yyval.ptype).us = 0; } break; case 325: /* Line 1806 of yacc.c */ #line 5574 "parser.y" { (yyval.ptype).type = NewString("long"); (yyval.ptype).us = 0; } break; case 326: /* Line 1806 of yacc.c */ #line 5578 "parser.y" { (yyval.ptype).type = NewString("char"); (yyval.ptype).us = 0; } break; case 327: /* Line 1806 of yacc.c */ #line 5582 "parser.y" { (yyval.ptype).type = NewString("wchar_t"); (yyval.ptype).us = 0; } break; case 328: /* Line 1806 of yacc.c */ #line 5586 "parser.y" { (yyval.ptype).type = NewString("float"); (yyval.ptype).us = 0; } break; case 329: /* Line 1806 of yacc.c */ #line 5590 "parser.y" { (yyval.ptype).type = NewString("double"); (yyval.ptype).us = 0; } break; case 330: /* Line 1806 of yacc.c */ #line 5594 "parser.y" { (yyval.ptype).us = NewString("signed"); (yyval.ptype).type = 0; } break; case 331: /* Line 1806 of yacc.c */ #line 5598 "parser.y" { (yyval.ptype).us = NewString("unsigned"); (yyval.ptype).type = 0; } break; case 332: /* Line 1806 of yacc.c */ #line 5602 "parser.y" { (yyval.ptype).type = NewString("complex"); (yyval.ptype).us = 0; } break; case 333: /* Line 1806 of yacc.c */ #line 5606 "parser.y" { (yyval.ptype).type = NewString("__int8"); (yyval.ptype).us = 0; } break; case 334: /* Line 1806 of yacc.c */ #line 5610 "parser.y" { (yyval.ptype).type = NewString("__int16"); (yyval.ptype).us = 0; } break; case 335: /* Line 1806 of yacc.c */ #line 5614 "parser.y" { (yyval.ptype).type = NewString("__int32"); (yyval.ptype).us = 0; } break; case 336: /* Line 1806 of yacc.c */ #line 5618 "parser.y" { (yyval.ptype).type = NewString("__int64"); (yyval.ptype).us = 0; } break; case 337: /* Line 1806 of yacc.c */ #line 5624 "parser.y" { /* scanner_check_typedef(); */ } break; case 338: /* Line 1806 of yacc.c */ #line 5624 "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).rawval = 0; } (yyval.dtype).bitfield = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; scanner_ignore_typedef(); } break; case 339: /* Line 1806 of yacc.c */ #line 5650 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 340: /* Line 1806 of yacc.c */ #line 5651 "parser.y" { (yyval.id) = (char *) 0;} break; case 341: /* Line 1806 of yacc.c */ #line 5654 "parser.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 342: /* Line 1806 of yacc.c */ #line 5655 "parser.y" { (yyval.node) = 0; } break; case 343: /* Line 1806 of yacc.c */ #line 5659 "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 344: /* Line 1806 of yacc.c */ #line 5665 "parser.y" { (yyval.node) = (yyvsp[(1) - (3)].node); } break; case 345: /* Line 1806 of yacc.c */ #line 5668 "parser.y" { Setattr((yyvsp[(2) - (3)].node),"_last",(yyvsp[(2) - (3)].node)); (yyval.node) = (yyvsp[(2) - (3)].node); } break; case 346: /* Line 1806 of yacc.c */ #line 5672 "parser.y" { (yyval.node) = 0; } break; case 347: /* Line 1806 of yacc.c */ #line 5677 "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 348: /* Line 1806 of yacc.c */ #line 5685 "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 349: /* Line 1806 of yacc.c */ #line 5697 "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 350: /* Line 1806 of yacc.c */ #line 5712 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 351: /* Line 1806 of yacc.c */ #line 5713 "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 352: /* Line 1806 of yacc.c */ #line 5732 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 353: /* Line 1806 of yacc.c */ #line 5733 "parser.y" { (yyval.dtype).val = NewString((yyvsp[(1) - (1)].id)); (yyval.dtype).type = T_STRING; } break; case 354: /* Line 1806 of yacc.c */ #line 5737 "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 355: /* Line 1806 of yacc.c */ #line 5742 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 356: /* Line 1806 of yacc.c */ #line 5743 "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; } break; case 357: /* Line 1806 of yacc.c */ #line 5757 "parser.y" { (yyval.dtype).val = NewStringf("(%s)",(yyvsp[(2) - (3)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (3)].dtype).type; } break; case 358: /* Line 1806 of yacc.c */ #line 5764 "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 359: /* Line 1806 of yacc.c */ #line 5781 "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 360: /* Line 1806 of yacc.c */ #line 5788 "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 361: /* Line 1806 of yacc.c */ #line 5795 "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 362: /* Line 1806 of yacc.c */ #line 5803 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).val = NewStringf("&%s",(yyvsp[(2) - (2)].dtype).val); } break; case 363: /* Line 1806 of yacc.c */ #line 5807 "parser.y" { (yyval.dtype) = (yyvsp[(2) - (2)].dtype); (yyval.dtype).val = NewStringf("*%s",(yyvsp[(2) - (2)].dtype).val); } break; case 364: /* Line 1806 of yacc.c */ #line 5813 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 365: /* Line 1806 of yacc.c */ #line 5814 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 366: /* Line 1806 of yacc.c */ #line 5815 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 367: /* Line 1806 of yacc.c */ #line 5816 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 368: /* Line 1806 of yacc.c */ #line 5817 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 369: /* Line 1806 of yacc.c */ #line 5818 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 370: /* Line 1806 of yacc.c */ #line 5819 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 371: /* Line 1806 of yacc.c */ #line 5820 "parser.y" { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); } break; case 372: /* Line 1806 of yacc.c */ #line 5823 "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 373: /* Line 1806 of yacc.c */ #line 5827 "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 374: /* Line 1806 of yacc.c */ #line 5831 "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 375: /* Line 1806 of yacc.c */ #line 5835 "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 376: /* Line 1806 of yacc.c */ #line 5839 "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 377: /* Line 1806 of yacc.c */ #line 5843 "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 378: /* Line 1806 of yacc.c */ #line 5847 "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 379: /* Line 1806 of yacc.c */ #line 5851 "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 380: /* Line 1806 of yacc.c */ #line 5855 "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 381: /* Line 1806 of yacc.c */ #line 5859 "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 382: /* Line 1806 of yacc.c */ #line 5863 "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 383: /* Line 1806 of yacc.c */ #line 5867 "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 384: /* Line 1806 of yacc.c */ #line 5871 "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 385: /* Line 1806 of yacc.c */ #line 5875 "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 386: /* Line 1806 of yacc.c */ #line 5889 "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 387: /* Line 1806 of yacc.c */ #line 5893 "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 388: /* Line 1806 of yacc.c */ #line 5897 "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 389: /* Line 1806 of yacc.c */ #line 5903 "parser.y" { (yyval.dtype).val = NewStringf("-%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type; } break; case 390: /* Line 1806 of yacc.c */ #line 5907 "parser.y" { (yyval.dtype).val = NewStringf("+%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type; } break; case 391: /* Line 1806 of yacc.c */ #line 5911 "parser.y" { (yyval.dtype).val = NewStringf("~%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type; } break; case 392: /* Line 1806 of yacc.c */ #line 5915 "parser.y" { (yyval.dtype).val = NewStringf("!%s",(yyvsp[(2) - (2)].dtype).val); (yyval.dtype).type = T_INT; } break; case 393: /* Line 1806 of yacc.c */ #line 5919 "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 394: /* Line 1806 of yacc.c */ #line 5935 "parser.y" { (yyval.bases) = (yyvsp[(1) - (1)].bases); } break; case 395: /* Line 1806 of yacc.c */ #line 5940 "parser.y" { inherit_list = 1; } break; case 396: /* Line 1806 of yacc.c */ #line 5940 "parser.y" { (yyval.bases) = (yyvsp[(3) - (3)].bases); inherit_list = 0; } break; case 397: /* Line 1806 of yacc.c */ #line 5941 "parser.y" { (yyval.bases) = 0; } break; case 398: /* Line 1806 of yacc.c */ #line 5944 "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 399: /* Line 1806 of yacc.c */ #line 5961 "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 400: /* Line 1806 of yacc.c */ #line 5970 "parser.y" { (yyval.intvalue) = cparse_line; } break; case 401: /* Line 1806 of yacc.c */ #line 5972 "parser.y" { (yyval.node) = NewHash(); Setfile((yyval.node),cparse_file); Setline((yyval.node),(yyvsp[(2) - (3)].intvalue)); Setattr((yyval.node),"name",(yyvsp[(3) - (3)].str)); Setfile((yyvsp[(3) - (3)].str),cparse_file); Setline((yyvsp[(3) - (3)].str),(yyvsp[(2) - (3)].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) - (3)].str))); } else { Setattr((yyval.node),"access","public"); } } break; case 402: /* Line 1806 of yacc.c */ #line 5986 "parser.y" { (yyval.intvalue) = cparse_line; } break; case 403: /* Line 1806 of yacc.c */ #line 5988 "parser.y" { (yyval.node) = NewHash(); Setfile((yyval.node),cparse_file); Setline((yyval.node),(yyvsp[(3) - (5)].intvalue)); Setattr((yyval.node),"name",(yyvsp[(5) - (5)].str)); Setfile((yyvsp[(5) - (5)].str),cparse_file); Setline((yyvsp[(5) - (5)].str),(yyvsp[(3) - (5)].intvalue)); Setattr((yyval.node),"access",(yyvsp[(2) - (5)].id)); if (Strcmp((yyvsp[(2) - (5)].id),"public") != 0) { Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile((yyval.node)), Getline((yyval.node)), "%s inheritance from base '%s' (ignored).\n", (yyvsp[(2) - (5)].id), SwigType_namestr((yyvsp[(5) - (5)].str))); } } break; case 404: /* Line 1806 of yacc.c */ #line 6002 "parser.y" { (yyval.id) = (char*)"public"; } break; case 405: /* Line 1806 of yacc.c */ #line 6003 "parser.y" { (yyval.id) = (char*)"private"; } break; case 406: /* Line 1806 of yacc.c */ #line 6004 "parser.y" { (yyval.id) = (char*)"protected"; } break; case 407: /* Line 1806 of yacc.c */ #line 6008 "parser.y" { (yyval.id) = (char*)"class"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 408: /* Line 1806 of yacc.c */ #line 6012 "parser.y" { (yyval.id) = (char *)"typename"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 409: /* Line 1806 of yacc.c */ #line 6018 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 410: /* Line 1806 of yacc.c */ #line 6021 "parser.y" { (yyval.id) = (char*)"struct"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 411: /* Line 1806 of yacc.c */ #line 6025 "parser.y" { (yyval.id) = (char*)"union"; if (!inherit_list) last_cpptype = (yyval.id); } break; case 414: /* Line 1806 of yacc.c */ #line 6035 "parser.y" { (yyval.dtype).qualifier = (yyvsp[(1) - (1)].str); (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; } break; case 415: /* Line 1806 of yacc.c */ #line 6040 "parser.y" { (yyval.dtype).qualifier = 0; (yyval.dtype).throws = (yyvsp[(3) - (4)].pl); (yyval.dtype).throwf = NewString("1"); } break; case 416: /* Line 1806 of yacc.c */ #line 6045 "parser.y" { (yyval.dtype).qualifier = (yyvsp[(1) - (5)].str); (yyval.dtype).throws = (yyvsp[(4) - (5)].pl); (yyval.dtype).throwf = NewString("1"); } break; case 417: /* Line 1806 of yacc.c */ #line 6050 "parser.y" { (yyval.dtype).qualifier = 0; (yyval.dtype).throws = 0; (yyval.dtype).throwf = 0; } break; case 418: /* Line 1806 of yacc.c */ #line 6057 "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; } break; case 419: /* Line 1806 of yacc.c */ #line 6064 "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; } break; case 420: /* Line 1806 of yacc.c */ #line 6071 "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; } break; case 421: /* Line 1806 of yacc.c */ #line 6079 "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; } break; case 422: /* Line 1806 of yacc.c */ #line 6087 "parser.y" { (yyval.decl).have_parms = 0; (yyval.decl).defarg = (yyvsp[(2) - (3)].dtype).val; (yyval.decl).throws = 0; (yyval.decl).throwf = 0; } break; case 427: /* Line 1806 of yacc.c */ #line 6103 "parser.y" { skip_balanced('(',')'); Clear(scanner_ccode); } break; case 428: /* Line 1806 of yacc.c */ #line 6109 "parser.y" { String *s = NewStringEmpty(); SwigType_add_template(s,(yyvsp[(2) - (3)].p)); (yyval.id) = Char(s); scanner_last_id(1); } break; case 429: /* Line 1806 of yacc.c */ #line 6115 "parser.y" { (yyval.id) = (char*)""; } break; case 430: /* Line 1806 of yacc.c */ #line 6118 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 431: /* Line 1806 of yacc.c */ #line 6119 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 432: /* Line 1806 of yacc.c */ #line 6122 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 433: /* Line 1806 of yacc.c */ #line 6123 "parser.y" { (yyval.id) = 0; } break; case 434: /* Line 1806 of yacc.c */ #line 6126 "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 435: /* Line 1806 of yacc.c */ #line 6131 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(3) - (4)].str),(yyvsp[(4) - (4)].str)); Delete((yyvsp[(4) - (4)].str)); } break; case 436: /* Line 1806 of yacc.c */ #line 6135 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].str)); } break; case 437: /* Line 1806 of yacc.c */ #line 6138 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].str)); } break; case 438: /* Line 1806 of yacc.c */ #line 6141 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].str)); } break; case 439: /* Line 1806 of yacc.c */ #line 6144 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].str)); } break; case 440: /* Line 1806 of yacc.c */ #line 6149 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].str)); Delete((yyvsp[(3) - (3)].str)); } break; case 441: /* Line 1806 of yacc.c */ #line 6153 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].str)); } break; case 442: /* Line 1806 of yacc.c */ #line 6156 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].str)); } break; case 443: /* Line 1806 of yacc.c */ #line 6163 "parser.y" { (yyval.str) = NewStringf("::~%s",(yyvsp[(2) - (2)].str)); } break; case 444: /* Line 1806 of yacc.c */ #line 6169 "parser.y" { (yyval.str) = NewStringf("%s%s",(yyvsp[(1) - (2)].id),(yyvsp[(2) - (2)].id)); /* if (Len($2)) { scanner_last_id(1); } */ } break; case 445: /* Line 1806 of yacc.c */ #line 6178 "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 446: /* Line 1806 of yacc.c */ #line 6183 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(3) - (4)].id),(yyvsp[(4) - (4)].str)); Delete((yyvsp[(4) - (4)].str)); } break; case 447: /* Line 1806 of yacc.c */ #line 6187 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); } break; case 448: /* Line 1806 of yacc.c */ #line 6190 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].id)); } break; case 449: /* Line 1806 of yacc.c */ #line 6193 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].str)); } break; case 450: /* Line 1806 of yacc.c */ #line 6196 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(3) - (3)].str)); } break; case 451: /* Line 1806 of yacc.c */ #line 6201 "parser.y" { (yyval.str) = NewStringf("::%s%s",(yyvsp[(2) - (3)].id),(yyvsp[(3) - (3)].str)); Delete((yyvsp[(3) - (3)].str)); } break; case 452: /* Line 1806 of yacc.c */ #line 6205 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].id)); } break; case 453: /* Line 1806 of yacc.c */ #line 6208 "parser.y" { (yyval.str) = NewStringf("::%s",(yyvsp[(2) - (2)].str)); } break; case 454: /* Line 1806 of yacc.c */ #line 6211 "parser.y" { (yyval.str) = NewStringf("::~%s",(yyvsp[(2) - (2)].id)); } break; case 455: /* Line 1806 of yacc.c */ #line 6217 "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 456: /* Line 1806 of yacc.c */ #line 6222 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id);} break; case 457: /* Line 1806 of yacc.c */ #line 6225 "parser.y" { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); } break; case 458: /* Line 1806 of yacc.c */ #line 6228 "parser.y" { skip_balanced('{','}'); (yyval.str) = NewString(scanner_ccode); } break; case 459: /* Line 1806 of yacc.c */ #line 6232 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 460: /* Line 1806 of yacc.c */ #line 6237 "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 461: /* Line 1806 of yacc.c */ #line 6250 "parser.y" { (yyval.node) = 0; } break; case 462: /* Line 1806 of yacc.c */ #line 6254 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); Setattr((yyval.node),"value",(yyvsp[(3) - (3)].id)); } break; case 463: /* Line 1806 of yacc.c */ #line 6259 "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 464: /* Line 1806 of yacc.c */ #line 6265 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (1)].id)); } break; case 465: /* Line 1806 of yacc.c */ #line 6269 "parser.y" { (yyval.node) = NewHash(); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); set_nextSibling((yyval.node),(yyvsp[(3) - (3)].node)); } break; case 466: /* Line 1806 of yacc.c */ #line 6274 "parser.y" { (yyval.node) = (yyvsp[(3) - (3)].node); Setattr((yyval.node),"name",(yyvsp[(1) - (3)].id)); } break; case 467: /* Line 1806 of yacc.c */ #line 6278 "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 468: /* Line 1806 of yacc.c */ #line 6285 "parser.y" { (yyval.id) = (yyvsp[(1) - (1)].id); } break; case 469: /* Line 1806 of yacc.c */ #line 6288 "parser.y" { (yyval.id) = Char((yyvsp[(1) - (1)].dtype).val); } break; /* Line 1806 of yacc.c */ #line 11422 "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 6295 "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-2.0.12/Source/CParse/util.c0000664000175000017500000000470312275776201016200 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"); } } } swig-2.0.12/Source/CParse/templ.c0000664000175000017500000006541012275776201016346 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. Lets 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-2.0.12/Source/CParse/cscanner.c0000664000175000017500000005557112275776201017030 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; /* 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; } /* ---------------------------------------------------------------------------- * 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; } /* ---------------------------------------------------------------------------- * 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_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_CHAR: yylval.str = NewString(Scanner_text(scan)); if (Len(yylval.str) == 0) { Swig_error(cparse_file, cparse_line, "Empty character constant\n"); Printf(stdout,"%d\n", Len(Scanner_text(scan))); } return CHARCONST; /* 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, "virtual") == 0) return (VIRTUAL); 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_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, "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, "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, "using") == 0) { return (USING); } if (strcmp(yytext, "namespace") == 0) { return (NAMESPACE); } } 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-2.0.12/Source/CParse/parser.y0000664000175000017500000057705512275776201016564 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. * ----------------------------------------------------------------------------- */ %{ #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 *extendhash = 0; /* Hash table of added methods */ 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 int nested_template = 0; /* template class/function definition within a class */ 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; static int max_class_levels = 0; static int class_level = 0; static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- * Assist Functions * ----------------------------------------------------------------------------- */ /* Called by the parser (yyparse) when an error is found.*/ static void yyerror (const char *e) { (void)e; } static 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; } /* 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; } /* 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; static String *class_rename = 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); } } /* 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 (nested_template) { if (!(n && Equal(nodeType(n), "template"))) { return; } /* continue if template function, but not template class, declared within a class */ } 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 (extendmode) { Setattr(n,"isextension","1"); } 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 (!Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]); */ Setattr(n,"ismember","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)) { 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 (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); } } /* 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 */ static void merge_extensions(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); } } static void append_previous_extension(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); } /* Check for unused %extend. Special case, don't report unused extensions for templates */ static void check_extensions() { 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); } } } /* 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; } static List *make_inherit_list(String *clsname, List *names) { 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++) { Node *s; String *base; String *n = Getitem(names,i); /* Try to figure out where this symbol is */ 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; } /* 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; } /* Structures for handling code fragments built for nested classes */ typedef struct Nested { String *code; /* Associated code fragment */ int line; /* line number where it starts */ const char *name; /* Name associated with this nested class */ const char *kind; /* Kind of class */ int unnamed; /* unnamed class */ SwigType *type; /* Datatype associated with the name */ struct Nested *next; /* Next code fragment in list */ } Nested; /* Some internal variables for saving nested class information */ static Nested *nested_list = 0; /* Add a function to the nested list */ static void add_nested(Nested *n) { if (!nested_list) { nested_list = n; } else { Nested *n1 = nested_list; while (n1->next) n1 = n1->next; n1->next = n; } } /* ----------------------------------------------------------------------------- * nested_new_struct() * * Nested struct handling for C code only creates a global struct from the nested struct. * * Nested structure. This is a sick "hack". If we encounter * a nested structure, we're going to grab the text of its definition and * feed it back into the scanner. In the meantime, we need to grab * variable declaration information and generate the associated wrapper * code later. Yikes! * * This really only works in a limited sense. Since we use the * code attached to the nested class to generate both C code * it can't have any SWIG directives in it. It also needs to be parsable * by SWIG or this whole thing is going to puke. * ----------------------------------------------------------------------------- */ static void nested_new_struct(const char *kind, String *struct_code, Node *cpp_opt_declarators) { String *name; String *decl; /* Create a new global struct declaration which is just a copy of the nested struct */ Nested *nested = (Nested *) malloc(sizeof(Nested)); Nested *n = nested; name = Getattr(cpp_opt_declarators, "name"); decl = Getattr(cpp_opt_declarators, "decl"); n->code = NewStringEmpty(); Printv(n->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); n->name = Swig_copy_string(Char(name)); n->line = cparse_start_line; n->type = NewStringEmpty(); n->kind = kind; n->unnamed = 0; SwigType_push(n->type, decl); n->next = 0; /* Repeat for any multiple instances of the nested struct */ { Node *p = cpp_opt_declarators; p = nextSibling(p); while (p) { Nested *nn = (Nested *) malloc(sizeof(Nested)); name = Getattr(p, "name"); decl = Getattr(p, "decl"); nn->code = NewStringEmpty(); Printv(nn->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); nn->name = Swig_copy_string(Char(name)); nn->line = cparse_start_line; nn->type = NewStringEmpty(); nn->kind = kind; nn->unnamed = 0; SwigType_push(nn->type, decl); nn->next = 0; n->next = nn; n = nn; p = nextSibling(p); } } add_nested(nested); } /* ----------------------------------------------------------------------------- * nested_forward_declaration() * * Nested struct handling for C++ code only. * * Treat the nested class/struct/union as a forward declaration until a proper * nested class solution is implemented. * ----------------------------------------------------------------------------- */ 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 (nn && Equal(nodeType(nn), "classforward")) { Node *n = nn; if (GetFlag(n, "feature:nestedworkaround")) { Swig_symbol_remove(n); nn = 0; warned = 1; } else { 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; } /* 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; } } /* Dump all of the nested class declarations to the inline processor * However. We need to do a few name replacements and other munging * first. This function must be called before closing a class! */ static Node *dump_nested(const char *parent) { Nested *n,*n1; Node *ret = 0; Node *last = 0; n = nested_list; if (!parent) { nested_list = 0; return 0; } while (n) { Node *retx; SwigType *nt; /* Token replace the name of the parent class */ Replace(n->code, "$classname", parent, DOH_REPLACE_ANY); /* Fix up the name of the datatype (for building typedefs and other stuff) */ Append(n->type,parent); Append(n->type,"_"); Append(n->type,n->name); /* Add the appropriate declaration to the C++ processor */ retx = new_node("cdecl"); Setattr(retx,"name",n->name); nt = Copy(n->type); Setattr(retx,"type",nt); Delete(nt); Setattr(retx,"nested",parent); if (n->unnamed) { Setattr(retx,"unnamed","1"); } add_symbols(retx); if (ret) { set_nextSibling(last, retx); Delete(retx); } else { ret = retx; } last = retx; /* Strip comments - further code may break in presence of comments. */ strip_comments(Char(n->code)); /* Make all SWIG created typedef structs/unions/classes unnamed else redefinition errors occur - nasty hack alert.*/ { const char* types_array[3] = {"struct", "union", "class"}; int i; for (i=0; i<3; i++) { char* code_ptr = Char(n->code); 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(n->code); 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 = new_node("insert"); String *code = NewStringEmpty(); Wrapper_pretty_print(n->code, code); Setattr(newnode,"code", code); Delete(code); set_nextSibling(last, newnode); Delete(newnode); last = newnode; } /* Dump the code to the scanner */ start_inline(Char(Getattr(last, "code")),n->line); n1 = n->next; Delete(n->code); free(n); n = n1; } nested_list = 0; return ret; } 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); */ 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 (Cmp(Getattr(n,"storage"),"externc") == 0) { 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; } } } /* ----------------------------------------------------------------------------- * tag_nodes() * * Used by the parser to mark subtypes with extra information. * ----------------------------------------------------------------------------- */ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { while (n) { Setattr(n, attrname, value); tag_nodes(firstChild(n), attrname, value); n = nextSibling(n); } } %} %union { char *id; List *bases; struct Define { String *val; String *rawval; int type; String *qualifier; String *bitfield; Parm *throws; String *throwf; } dtype; struct { char *type; String *filename; int line; } loc; struct { char *id; SwigType *type; String *defarg; ParmList *parms; short have_parms; ParmList *throws; String *throwf; } 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 %token INCLUDE IMPORT INSERT %token CHARCONST %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 USING %token NAMESPACE %token NATIVE INLINE %token TYPEMAP EXCEPT ECHO APPLY CLEAR SWIGTEMPLATE FRAGMENT %token WARN %token LESSTHAN GREATERTHAN DELETE_KW %token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO %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_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; %type cpp_members cpp_member; %type cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator; %type cpp_swig_directive cpp_temp_possible cpp_nested cpp_opt_declarators ; %type cpp_using_decl cpp_namespace_decl cpp_catch_decl ; %type kwargs options; /* Misc */ %type initializer cpp_const ; %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 type rawtype type_right ; %type base_list inherit raw_inherit; %type definetype def_args etype; %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 ; %type template_parms; %type cpp_end cpp_vend; %type rename_namewarn; %type type_specifier primitive_type_list ; %type fname stringtype; %type featattr; %type optional_constant_directive; %% /* ====================================================================== * 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); check_extensions(); 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; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); if (!classes_typedefs) classes_typedefs = NewHash(); if (!extendhash) extendhash = 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(extendhash,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; extendmode = 1; 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; extendmode = 1; } 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 members as extend */ tag_nodes($6,"feature:extend",(char*) "1"); 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(extendhash,clsname); if (am) { /* Append the members to the previous extend methods */ appendChild(am,$6); } else { appendChild($$,$6); Setattr(extendhash,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 ID 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 ID 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 ID 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 = (char *) "include"; } | IMPORT { $$.type = (char *) "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 (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 ID RPAREN storage_class ID SEMI { $$ = new_node("native"); Setattr($$,"name",$3); Setattr($$,"wrap:name",$6); add_symbols($$); } | NATIVE LPAREN ID 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 ID EQUAL pragma_arg { $$ = new_node("pragma"); Setattr($$,"lang",$2); Setattr($$,"name",$3); Setattr($$,"value",$5); } | PRAGMA pragma_lang ID { $$ = new_node("pragma"); Setattr($$,"lang",$2); Setattr($$,"name",$3); } ; pragma_arg : string { $$ = NewString($1); } | HBLOCK { $$ = $1; } ; pragma_lang : LPAREN ID RPAREN { $$ = $2; } | empty { $$ = (char *) "swig"; } ; /* ------------------------------------------------------------ %rename identifier newname; %rename identifier "newname"; ------------------------------------------------------------ */ 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; $$ = 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; } if (nnisclass && !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)))) { Swig_error(cparse_file, cparse_line, "Not enough template parameters specified. %d required.\n", ParmList_numrequired(tparms)); } 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; } } templnode = copy_node(nn); /* 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"); } if ($3 && !inclass) { /* 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); 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 = make_inherit_list(Getattr(templnode,"name"),baselist); 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 */ if (extendhash) { 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(extendhash,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")); */ merge_extensions(templnode,am); Swig_symbol_setscope(st); append_previous_extension(templnode,am); Delattr(extendhash,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)); } } ; /* ------------------------------------------------------------ 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); 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); } } ; /* 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); 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; } | type_qualifier def_args { $$ = $2; $$.qualifier = $1; $$.throws = 0; $$.throwf = 0; } | THROW LPAREN parms RPAREN def_args { $$ = $5; $$.qualifier = 0; $$.throws = $3; $$.throwf = NewString("1"); } | type_qualifier THROW LPAREN parms RPAREN def_args { $$ = $6; $$.qualifier = $1; $$.throws = $4; $$.throwf = NewString("1"); } ; /* ------------------------------------------------------------ enum Name; ------------------------------------------------------------ */ c_enum_forward_decl : storage_class ENUM ID SEMI { SwigType *ty = 0; $$ = new_node("enumforward"); ty = NewStringf("enum %s", $3); Setattr($$,"name",$3); Setattr($$,"type",ty); Setattr($$,"sym:weak", "1"); add_symbols($$); } ; /* ------------------------------------------------------------ enum { ... } * ------------------------------------------------------------ */ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI { SwigType *ty = 0; $$ = new_node("enum"); ty = NewStringf("enum %s", $3); Setattr($$,"name",$3); Setattr($$,"type",ty); appendChild($$,$5); add_symbols($$); /* Add to tag space */ add_symbols($5); /* Add enum values to id space */ } | storage_class ENUM ename LBRACE enumlist RBRACE declarator initializer c_decl_tail { Node *n; SwigType *ty = 0; String *unnamed = 0; int unnamedinstance = 0; $$ = new_node("enum"); if ($3) { Setattr($$,"name",$3); ty = NewStringf("enum %s", $3); } else if ($7.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",$7.id); } else { unnamedinstance = 1; } Setattr($$,"storage",$1); } if ($7.id && Cmp($1,"typedef") == 0) { Setattr($$,"tdname",$7.id); Setattr($$,"allows_typedef","1"); } appendChild($$,$5); n = new_node("cdecl"); Setattr(n,"type",ty); Setattr(n,"name",$7.id); Setattr(n,"storage",$1); Setattr(n,"decl",$7.type); Setattr(n,"parms",$7.parms); Setattr(n,"unnamed",unnamed); if (unnamedinstance) { SwigType *cty = NewString("enum "); Setattr($$,"type",cty); SetFlag($$,"unnamedinstance"); SetFlag(n,"unnamedinstance"); Delete(cty); } if ($9) { Node *p = $9; 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 ($7.id && $3 && Cmp($1,"typedef") == 0) { String *name = NewString($7.id); Setattr($$, "parser:makename", name); Delete(name); } add_symbols($$); /* Add enum to tag space */ set_nextSibling($$,n); Delete(n); add_symbols($5); /* Add enum values to id space */ 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); 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 { if (nested_template == 0) { String *prefix; List *bases = 0; Node *scope = 0; $$ = 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 */ 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); Setfile(scope,cparse_file); Setline(scope,cparse_line); $3 = scope; /* support for old nested classes "pseudo" support, such as: %rename(Ala__Ola) Ala::Ola; class Ala::Ola { public: Ola() {} }; this should disappear when a proper implementation is added. */ if (nscope_inner && Strcmp(nodeType(nscope_inner),"namespace") != 0) { if (Namespaceprefix) { String *name = NewStringf("%s::%s", Namespaceprefix, $3); $3 = name; Namespaceprefix = 0; nscope_inner = 0; } } Setattr($$,"name",$3); Delete(class_rename); class_rename = make_name($$,$3,0); Classprefix = NewString($3); /* Deal with inheritance */ if ($4) { bases = make_inherit_list($3,Getattr($4,"public")); } 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; } Swig_symbol_newscope(); Swig_symbol_setscopename($3); 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); } 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); } } if (class_level >= max_class_levels) { if (!max_class_levels) { max_class_levels = 16; } else { max_class_levels *= 2; } class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } class_decl[class_level++] = $$; Delete(prefix); inclass = 1; } } cpp_members RBRACE cpp_opt_declarators { (void) $6; if (nested_template == 0) { Node *p; SwigType *ty; Symtab *cscope = prev_symtab; Node *am = 0; String *scpname = 0; $$ = class_decl[--class_level]; inclass = 0; /* Check for pure-abstract class */ Setattr($$,"abstracts", pure_abstracts($7)); /* This bit of code merges in a previously defined %extend directive (if any) */ if (extendhash) { String *clsname = Swig_symbol_qualifiedscopename(0); am = Getattr(extendhash,clsname); if (am) { merge_extensions($$,am); Delattr(extendhash,clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,$$); appendChild($$,$7); if (am) append_previous_extension($$,am); p = $9; if (p) { set_nextSibling($$,p); } 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); p = nextSibling(p); } /* Class typedefs */ { String *name = $3; if ($9) { SwigType *decltype = Getattr($9,"decl"); if (Cmp($1,"typedef") == 0) { if (!decltype || !Len(decltype)) { String *cname; String *tdscopename; String *class_scope = Swig_symbol_qualifiedscopename(cscope); name = Getattr($9,"name"); cname = Copy(name); Setattr($$,"tdname",cname); tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name); /* Use typedef name as class name */ if (class_rename && (Strcmp(class_rename,$3) == 0)) { Delete(class_rename); class_rename = NewString(name); } if (!classes_typedefs) classes_typedefs = NewHash(); if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) { Setattr(classes_typedefs, tdscopename, $$); } Setattr($$,"decl",decltype); Delete(class_scope); Delete(cname); Delete(tdscopename); } } } appendChild($$,dump_nested(Char(name))); } 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); } Setattr($$,"symtab",Swig_symbol_popscope()); Classprefix = 0; 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); add_symbols($$); if (nscope) $$ = nscope; /* but the variable definition in the current scope */ Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($9); } else { Delete(yyrename); yyrename = Copy(class_rename); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($$); add_symbols($9); } Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } else { $$ = new_node("class"); Setattr($$,"kind",$2); Setattr($$,"name",NewString($3)); SetFlag($$,"nestedtemplateclass"); } } /* An unnamed struct, possibly with a typedef */ | storage_class cpptype LBRACE { String *unnamed; unnamed = make_unnamed(); $$ = new_node("class"); Setline($$,cparse_start_line); Setattr($$,"kind",$2); Setattr($$,"storage",$1); Setattr($$,"unnamed",unnamed); Setattr($$,"allows_typedef","1"); Delete(class_rename); 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; if (class_level >= max_class_levels) { if (!max_class_levels) { max_class_levels = 16; } else { max_class_levels *= 2; } class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } class_decl[class_level++] = $$; inclass = 1; Classprefix = NewStringEmpty(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); } cpp_members RBRACE declarator initializer c_decl_tail { String *unnamed; Node *n; (void) $4; Classprefix = 0; $$ = class_decl[--class_level]; inclass = 0; unnamed = Getattr($$,"unnamed"); /* Check for pure-abstract class */ Setattr($$,"abstracts", pure_abstracts($5)); n = new_node("cdecl"); Setattr(n,"name",$7.id); Setattr(n,"unnamed",unnamed); Setattr(n,"type",unnamed); Setattr(n,"decl",$7.type); Setattr(n,"parms",$7.parms); Setattr(n,"storage",$1); if ($9) { Node *p = $9; set_nextSibling(n,p); while (p) { String *type = Copy(unnamed); Setattr(p,"name",$7.id); Setattr(p,"unnamed",unnamed); Setattr(p,"type",type); Delete(type); Setattr(p,"storage",$1); p = nextSibling(p); } } set_nextSibling($$,n); Delete(n); { /* If a proper typedef name was given, we'll use it to set the scope name */ String *name = 0; if ($1 && (strcmp($1,"typedef") == 0)) { if (!Len($7.type)) { String *scpname = 0; name = $7.id; Setattr($$,"tdname",name); Setattr($$,"name",name); Swig_symbol_setscopename(name); /* If a proper name was given, we use that as the typedef, not unnamed */ Clear(unnamed); Append(unnamed, name); n = nextSibling(n); set_nextSibling($$,n); /* Check for previous extensions */ if (extendhash) { String *clsname = Swig_symbol_qualifiedscopename(0); Node *am = Getattr(extendhash,clsname); if (am) { /* Merge the extension into the symbol table */ merge_extensions($$,am); append_previous_extension($$,am); Delattr(extendhash,clsname); } Delete(clsname); } if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,$$); Delete(scpname); } else { Swig_symbol_setscopename(""); } } appendChild($$,$5); appendChild($$,dump_nested(Char(name))); } /* Pop the scope */ Setattr($$,"symtab",Swig_symbol_popscope()); if (class_rename) { Delete(yyrename); yyrename = NewString(class_rename); } Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); add_symbols($$); add_symbols(n); Delete(unnamed); } ; 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 { template_parameters = $3; if (inclass) nested_template++; } cpp_temp_possible { /* Don't ignore templated functions declared within a class, unless the templated function is within a nested class */ if (nested_template <= 1) { int is_nested_template_class = $6 && GetFlag($6, "nestedtemplateclass"); if (is_nested_template_class) { $$ = 0; /* Nested template classes would probably better be ignored like ordinary nested classes using cpp_nested, but that introduces shift/reduce conflicts */ if (cplus_mode == CPLUS_PUBLIC) { /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ String *kind = Getattr($6, "kind"); String *name = Getattr($6, "name"); $$ = new_node("template"); Setattr($$,"kind",kind); Setattr($$,"name",name); Setattr($$,"sym:weak", "1"); Setattr($$,"templatetype","classforward"); Setattr($$,"templateparms", $3); add_symbols($$); if (GetFlag($$, "feature:nestedworkaround")) { Swig_symbol_remove($$); $$ = 0; } else { SWIG_WARN_NODE_BEGIN($$); Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested template %s not currently supported (%s ignored).\n", kind, name); SWIG_WARN_NODE_END($$); } } Delete($6); } else { 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; } } else { $$ = 0; } template_parameters = 0; if (inclass) nested_template--; } | 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_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 { /* 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((char *)" ",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 ID 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); } else { $$ = $2; } } | EXTEND LBRACE { if (cplus_mode != CPLUS_PUBLIC) { Swig_error(cparse_file,cparse_line,"%%extend can only be used in a public section\n"); } } cpp_members RBRACE cpp_members { $$ = new_node("extend"); tag_nodes($4,"feature:extend",(char*) "1"); appendChild($$,$4); set_nextSibling($$,$6); } | 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) { 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_protection_decl { $$ = $1; } | cpp_swig_directive { $$ = $1; } | cpp_conversion_operator { $$ = $1; } | cpp_forward_class_decl { $$ = $1; } | cpp_nested { $$ = $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 (Classprefix) { 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); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); Delete(code); } SetFlag($$,"feature:new"); } 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); 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); if ($7.val) { Setattr($$,"value","0"); } 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 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; } ; /* 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; } ; /* ------------------------------------------------------------ Named nested structs: struct sname { }; struct sname { } id; struct sname : bases { }; struct sname : bases { } id; typedef sname struct { } td; typedef sname struct : bases { } td; Adding inheritance, ie replacing 'ID' with 'idcolon inherit' added one shift/reduce ------------------------------------------------------------ */ cpp_nested : storage_class cpptype idcolon inherit LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { String *name = Copy($3); $$ = nested_forward_declaration($1, $2, $3, name, $7); } else if ($7) { nested_new_struct($2, $6, $7); } } Delete($6); } /* ------------------------------------------------------------ Unnamed/anonymous nested structs: struct { }; struct { } id; struct : bases { }; struct : bases { } id; typedef struct { } td; typedef struct : bases { } td; ------------------------------------------------------------ */ | storage_class cpptype inherit LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { String *name = $6 ? Copy(Getattr($6, "name")) : 0; $$ = nested_forward_declaration($1, $2, 0, name, $6); } else { if ($6) { nested_new_struct($2, $5, $6); } else { Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); } } } Delete($5); } /* This unfortunately introduces 4 shift/reduce conflicts, so instead the somewhat hacky nested_template is used for ignore nested template classes. */ /* | TEMPLATE LESSTHAN template_parms GREATERTHAN cpptype idcolon LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); } SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $5, $6); } } */ ; /* 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); $$.throws = $1.throws; $$.throwf = $1.throwf; } | cpp_const LBRACE { skip_balanced('{','}'); $$.throws = $1.throws; $$.throwf = $1.throwf; } ; cpp_vend : cpp_const SEMI { Clear(scanner_ccode); $$.val = 0; $$.qualifier = $1.qualifier; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; } | cpp_const EQUAL definetype SEMI { Clear(scanner_ccode); $$.val = $3.val; $$.qualifier = $1.qualifier; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; } | cpp_const LBRACE { skip_balanced('{','}'); $$.val = 0; $$.qualifier = $1.qualifier; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; } ; anonymous_bitfield : storage_class type COLON expr SEMI { }; /* ====================================================================== * PRIMITIVES * ====================================================================== */ storage_class : EXTERN { $$ = "extern"; } | EXTERN string { if (strcmp($2,"C") == 0) { $$ = "externc"; } 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"; } | 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; } } | 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; } else { $$.val = NewStringf("%s[%s]",$2.val,$4.val); } } | EQUAL LBRACE { skip_balanced('{','}'); $$.val = 0; $$.rawval = 0; $$.type = T_INT; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; } | COLON expr { $$.val = 0; $$.rawval = 0; $$.type = 0; $$.bitfield = $2.val; $$.throws = 0; $$.throwf = 0; } | empty { $$.val = 0; $$.rawval = 0; $$.type = T_INT; $$.bitfield = 0; $$.throws = 0; $$.throwf = 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; } | 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); } } | 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; } ; 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,(char*)""); 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 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,(char*)""); 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; } } ; 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 AND direct_abstract_declarator { $$ = $3; SwigType_add_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); } } | AND { $$.id = 0; $$.parms = 0; $$.have_parms = 0; $$.type = NewStringEmpty(); SwigType_add_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,(char*)""); 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,(char*)""); } | 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); } | ENUM idcolon { $$ = NewStringf("enum %s", $2); } | TYPE_RAW { $$ = $1; } | idcolon { $$ = $1; } | cpptype idcolon { $$ = NewStringf("%s %s", $1, $2); } ; 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) { $$.rawval = 0; } $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; scanner_ignore_typedef(); } /* | string { $$.val = NewString($1); $$.rawval = NewStringf("\"%(escape)s\"",$$.val); $$.type = T_STRING; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; } */ ; /* Some stuff for handling enums */ ename : ID { $$ = $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 : ID { SwigType *type = NewSwigType(T_INT); $$ = new_node("enumitem"); Setattr($$,"name",$1); Setattr($$,"type",type); SetFlag($$,"feature:immutable"); Delete(type); } | ID 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; } | exprcompound { $$ = $1; } | 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; } /* 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 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); } } | AND 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); } ; 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 { $$ = 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"); } } | opt_virtual access_specifier { $$ = cparse_line; } opt_virtual idcolon { $$ = 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)); } } ; 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 = $$; } ; cpptype : templcpptype { $$ = $1; } | STRUCT { $$ = (char*)"struct"; if (!inherit_list) last_cpptype = $$; } | UNION { $$ = (char*)"union"; if (!inherit_list) last_cpptype = $$; } ; opt_virtual : VIRTUAL | empty ; cpp_const : type_qualifier { $$.qualifier = $1; $$.throws = 0; $$.throwf = 0; } | THROW LPAREN parms RPAREN { $$.qualifier = 0; $$.throws = $3; $$.throwf = NewString("1"); } | type_qualifier THROW LPAREN parms RPAREN { $$.qualifier = $1; $$.throws = $4; $$.throwf = NewString("1"); } | empty { $$.qualifier = 0; $$.throws = 0; $$.throwf = 0; } ; ctor_end : cpp_const ctor_initializer SEMI { Clear(scanner_ccode); $$.have_parms = 0; $$.defarg = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; } | cpp_const ctor_initializer LBRACE { skip_balanced('{','}'); $$.have_parms = 0; $$.defarg = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; } | LPAREN parms RPAREN SEMI { Clear(scanner_ccode); $$.parms = $2; $$.have_parms = 1; $$.defarg = 0; $$.throws = 0; $$.throwf = 0; } | LPAREN parms RPAREN LBRACE { skip_balanced('{','}'); $$.parms = $2; $$.have_parms = 1; $$.defarg = 0; $$.throws = 0; $$.throwf = 0; } | EQUAL definetype SEMI { $$.have_parms = 0; $$.defarg = $2.val; $$.throws = 0; $$.throwf = 0; } ; ctor_initializer : COLON mem_initializer_list | empty ; mem_initializer_list : mem_initializer | mem_initializer_list COMMA mem_initializer ; mem_initializer : idcolon LPAREN { 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*)""; } ; idstring : ID { $$ = $1; } | 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 : ID template_decl { $$ = NewStringf("%s%s",$1,$2); /* if (Len($2)) { scanner_last_id(1); } */ } ; /* Identifier, but no templates */ idcolonnt : ID idcolontailnt { $$ = 0; if (!$$) $$ = NewStringf("%s%s", $1,$2); Delete($2); } | NONID DCOLON ID idcolontailnt { $$ = NewStringf("::%s%s",$3,$4); Delete($4); } | ID { $$ = NewString($1); } | NONID DCOLON ID { $$ = NewStringf("::%s",$3); } | OPERATOR { $$ = NewString($1); } | NONID DCOLON OPERATOR { $$ = NewStringf("::%s",$3); } ; idcolontailnt : DCOLON ID idcolontailnt { $$ = NewStringf("::%s%s",$2,$3); Delete($3); } | DCOLON ID { $$ = NewStringf("::%s",$2); } | DCOLON OPERATOR { $$ = NewStringf("::%s",$2); } | DCNOT ID { $$ = NewStringf("::~%s",$2); } ; /* Concatenated strings */ string : string STRING { $$ = (char *) malloc(strlen($1)+strlen($2)+1); strcpy($$,$1); strcat($$,$2); } | STRING { $$ = $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-2.0.12/Source/CParse/parser.h0000664000175000017500000001747012275777517016544 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, INCLUDE = 262, IMPORT = 263, INSERT = 264, CHARCONST = 265, NUM_INT = 266, NUM_FLOAT = 267, NUM_UNSIGNED = 268, NUM_LONG = 269, NUM_ULONG = 270, NUM_LONGLONG = 271, NUM_ULONGLONG = 272, NUM_BOOL = 273, TYPEDEF = 274, TYPE_INT = 275, TYPE_UNSIGNED = 276, TYPE_SHORT = 277, TYPE_LONG = 278, TYPE_FLOAT = 279, TYPE_DOUBLE = 280, TYPE_CHAR = 281, TYPE_WCHAR = 282, TYPE_VOID = 283, TYPE_SIGNED = 284, TYPE_BOOL = 285, TYPE_COMPLEX = 286, TYPE_TYPEDEF = 287, TYPE_RAW = 288, TYPE_NON_ISO_INT8 = 289, TYPE_NON_ISO_INT16 = 290, TYPE_NON_ISO_INT32 = 291, TYPE_NON_ISO_INT64 = 292, LPAREN = 293, RPAREN = 294, COMMA = 295, SEMI = 296, EXTERN = 297, INIT = 298, LBRACE = 299, RBRACE = 300, PERIOD = 301, CONST_QUAL = 302, VOLATILE = 303, REGISTER = 304, STRUCT = 305, UNION = 306, EQUAL = 307, SIZEOF = 308, MODULE = 309, LBRACKET = 310, RBRACKET = 311, BEGINFILE = 312, ENDOFFILE = 313, ILLEGAL = 314, CONSTANT = 315, NAME = 316, RENAME = 317, NAMEWARN = 318, EXTEND = 319, PRAGMA = 320, FEATURE = 321, VARARGS = 322, ENUM = 323, CLASS = 324, TYPENAME = 325, PRIVATE = 326, PUBLIC = 327, PROTECTED = 328, COLON = 329, STATIC = 330, VIRTUAL = 331, FRIEND = 332, THROW = 333, CATCH = 334, EXPLICIT = 335, USING = 336, NAMESPACE = 337, NATIVE = 338, INLINE = 339, TYPEMAP = 340, EXCEPT = 341, ECHO = 342, APPLY = 343, CLEAR = 344, SWIGTEMPLATE = 345, FRAGMENT = 346, WARN = 347, LESSTHAN = 348, GREATERTHAN = 349, DELETE_KW = 350, LESSTHANOREQUALTO = 351, GREATERTHANOREQUALTO = 352, EQUALTO = 353, NOTEQUALTO = 354, QUESTIONMARK = 355, TYPES = 356, PARMS = 357, NONID = 358, DSTAR = 359, DCNOT = 360, TEMPLATE = 361, OPERATOR = 362, COPERATOR = 363, PARSETYPE = 364, PARSEPARM = 365, PARSEPARMS = 366, CAST = 367, LOR = 368, LAND = 369, OR = 370, XOR = 371, AND = 372, RSHIFT = 373, LSHIFT = 374, MINUS = 375, PLUS = 376, MODULO = 377, SLASH = 378, STAR = 379, LNOT = 380, NOT = 381, UMINUS = 382, DCOLON = 383 }; #endif /* Tokens. */ #define ID 258 #define HBLOCK 259 #define POUND 260 #define STRING 261 #define INCLUDE 262 #define IMPORT 263 #define INSERT 264 #define CHARCONST 265 #define NUM_INT 266 #define NUM_FLOAT 267 #define NUM_UNSIGNED 268 #define NUM_LONG 269 #define NUM_ULONG 270 #define NUM_LONGLONG 271 #define NUM_ULONGLONG 272 #define NUM_BOOL 273 #define TYPEDEF 274 #define TYPE_INT 275 #define TYPE_UNSIGNED 276 #define TYPE_SHORT 277 #define TYPE_LONG 278 #define TYPE_FLOAT 279 #define TYPE_DOUBLE 280 #define TYPE_CHAR 281 #define TYPE_WCHAR 282 #define TYPE_VOID 283 #define TYPE_SIGNED 284 #define TYPE_BOOL 285 #define TYPE_COMPLEX 286 #define TYPE_TYPEDEF 287 #define TYPE_RAW 288 #define TYPE_NON_ISO_INT8 289 #define TYPE_NON_ISO_INT16 290 #define TYPE_NON_ISO_INT32 291 #define TYPE_NON_ISO_INT64 292 #define LPAREN 293 #define RPAREN 294 #define COMMA 295 #define SEMI 296 #define EXTERN 297 #define INIT 298 #define LBRACE 299 #define RBRACE 300 #define PERIOD 301 #define CONST_QUAL 302 #define VOLATILE 303 #define REGISTER 304 #define STRUCT 305 #define UNION 306 #define EQUAL 307 #define SIZEOF 308 #define MODULE 309 #define LBRACKET 310 #define RBRACKET 311 #define BEGINFILE 312 #define ENDOFFILE 313 #define ILLEGAL 314 #define CONSTANT 315 #define NAME 316 #define RENAME 317 #define NAMEWARN 318 #define EXTEND 319 #define PRAGMA 320 #define FEATURE 321 #define VARARGS 322 #define ENUM 323 #define CLASS 324 #define TYPENAME 325 #define PRIVATE 326 #define PUBLIC 327 #define PROTECTED 328 #define COLON 329 #define STATIC 330 #define VIRTUAL 331 #define FRIEND 332 #define THROW 333 #define CATCH 334 #define EXPLICIT 335 #define USING 336 #define NAMESPACE 337 #define NATIVE 338 #define INLINE 339 #define TYPEMAP 340 #define EXCEPT 341 #define ECHO 342 #define APPLY 343 #define CLEAR 344 #define SWIGTEMPLATE 345 #define FRAGMENT 346 #define WARN 347 #define LESSTHAN 348 #define GREATERTHAN 349 #define DELETE_KW 350 #define LESSTHANOREQUALTO 351 #define GREATERTHANOREQUALTO 352 #define EQUALTO 353 #define NOTEQUALTO 354 #define QUESTIONMARK 355 #define TYPES 356 #define PARMS 357 #define NONID 358 #define DSTAR 359 #define DCNOT 360 #define TEMPLATE 361 #define OPERATOR 362 #define COPERATOR 363 #define PARSETYPE 364 #define PARSEPARM 365 #define PARSEPARMS 366 #define CAST 367 #define LOR 368 #define LAND 369 #define OR 370 #define XOR 371 #define AND 372 #define RSHIFT 373 #define LSHIFT 374 #define MINUS 375 #define PLUS 376 #define MODULO 377 #define SLASH 378 #define STAR 379 #define LNOT 380 #define NOT 381 #define UMINUS 382 #define DCOLON 383 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { /* Line 2068 of yacc.c */ #line 1647 "parser.y" char *id; List *bases; struct Define { String *val; String *rawval; int type; String *qualifier; String *bitfield; Parm *throws; String *throwf; } dtype; struct { char *type; String *filename; int line; } loc; struct { char *id; SwigType *type; String *defarg; ParmList *parms; short have_parms; ParmList *throws; String *throwf; } 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 351 "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-2.0.12/Source/README0000664000175000017500000000136612275776201014564 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-2.0.12/Source/Include/0000775000175000017500000000000012275777513015270 5ustar williamwilliamswig-2.0.12/Source/Include/swigconfig.h.in0000664000175000017500000000474112275777513020213 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 Microsofts attempt at deprecating C standard runtime functions */ #if defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE #endif swig-2.0.12/Source/Include/swigwarn.h0000664000175000017500000002764112275776201017305 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 /* -- 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_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 /* -- 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-2.0.12/Source/Modules/0000775000175000017500000000000012275776201015306 5ustar williamwilliamswig-2.0.12/Source/Modules/README0000664000175000017500000000047212275776201016171 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-2.0.12/Source/Modules/clisp.cxx0000664000175000017500000003206212275776201017147 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 = (char *) "\ 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 || (Strcmp(storage, "extern") && Strcmp(storage, "externc")))) 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; // SwigType *type=; String *storage = Getattr(n, "storage"); if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc")))) 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-2.0.12/Source/Modules/cffi.cxx0000664000175000017500000010155412275776201016747 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 = (char *) "\ 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 *storage=Getattr(n,"storage"); // if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc"))) // return SWIG_OK; 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 *storage=Getattr(n,"storage"); // Printf(stdout,"\"%s\" %s)\n",storage,Getattr(n, "sym:name")); // if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc"))) // return SWIG_OK; 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, 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-2.0.12/Source/Modules/d.cxx0000664000175000017500000047571112275776201016274 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 // seperate 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 handeled 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 handeled seperately. * --------------------------------------------------------------------------- */ 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 seperate file, which allows // us to handle imports here. // When working in split proxy module mode, each generated proxy class/enum // is written to a seperate 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); 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 seperate 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 seperate 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 { 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 = (char *) "\ 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-2.0.12/Source/Modules/browser.cxx0000664000175000017500000002607612275776201017530 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 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-2.0.12/Source/Modules/ocaml.cxx0000664000175000017500000016727512275776201017147 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 = (char *) "\ 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 char *ocaml_path = (char *) "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-2.0.12/Source/Modules/chicken.cxx0000664000175000017500000013356512275776201017453 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 = (char *) "\ \ 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 char *chicken_path = (char *) "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, (char *) ""); 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, (char *) ""); 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, (char *) ""); 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, (char *) ""); 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-2.0.12/Source/Modules/lang.cxx0000664000175000017500000033740412275776201016766 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); } /* =============================================================== * 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::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) { Hash *symbols = NewHash(); Setattr(symtabs, "", symbols); // 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 = Getattr(n, "sym:name"); 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; } } } /* -------------------------------------------------------------------------- * use_naturalvar_mode() * -------------------------------------------------------------------------- */ int use_naturalvar_mode(Node *n) { if (Getattr(n, "unnamed")) return 0; int nvar = naturalvar_mode || GetFlag(n, "feature:naturalvar"); if (!nvar) { /* look for feature in the class */ SwigType *ty = Getattr(n, "type"); SwigType *fullty = SwigType_typedef_resolve_all(ty); if (SwigType_isclass(fullty)) { Node *m = Copy(n); SwigType *tys = SwigType_strip_qualifiers(fullty); Swig_features_get(Swig_cparse_features(), 0, tys, 0, m); nvar = GetFlag(m, "feature:naturalvar"); Delete(tys); Delete(m); } Delete(fullty); } return 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; } if (Getattr(options, "nonaturalvar")) { naturalvar_mode = 0; } } } classhash = Getattr(n, "classes"); return emit_children(n); } /* ---------------------------------------------------------------------- * Language::extendDirective() * ---------------------------------------------------------------------- */ int Language::extendDirective(Node *n) { int oldam = Extend; AccessMode oldmode = cplus_mode; Extend = CWRAP_EXTEND; cplus_mode = PUBLIC; emit_children(n); Extend = oldam; cplus_mode = oldmode; 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 ((Cmp(storage, "extern") == 0) || (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 (Cmp(storage, "externc") == 0) { /* 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 (Getattr(n, "nested")) SetFlag(n, "feature:immutable"); if (!CurrentClass) { if ((Cmp(storage, "extern") == 0) || ForceExtern) { f_header = Swig_filebyname("header"); if (AddExtern) { if (f_header) { String *str = SwigType_str(ty, name); Printf(f_header, "extern %s;\n", 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 && Cmp(storage, "static") == 0 && !(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, "classname")) { Setattr(n, "classname", Getattr(CurrentClass, "allocate:smartpointerbase")); } } // 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 { String *storage = Getattr(n, "storage"); 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 ((Cmp(storage, "static") == 0) && !(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 (checkAttribute(n, "storage", "static")) { 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); /* 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); } 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:smartpointerbase"); 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; } 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 (!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; } if (Cmp(kind, "class") == 0) { cplus_mode = PRIVATE; } else { cplus_mode = PUBLIC; } ClassName = Copy(name); ClassPrefix = Copy(symname); 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; String *oldNSpace = NSpace; NSpace = Getattr(n, "sym:nspace"); /* Call classHandler() here */ if (!ImportMode) { int dir = 0; 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); } NSpace = oldNSpace; InClass = 0; CurrentClass = 0; Delete(ClassType); ClassType = 0; Delete(ClassPrefix); ClassPrefix = 0; Delete(ClassName); ClassName = 0; Delete(DirectorClassName); DirectorClassName = 0; return SWIG_OK; } /* ---------------------------------------------------------------------- * Language::classHandler() * ---------------------------------------------------------------------- */ int Language::classHandler(Node *n) { 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"); AccessMode 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 overidden 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); } cplus_mode = old_mode; } } 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) && !(Getattr(n, "template"))) { 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); 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); 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", NIL); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *name = Getattr(n, "name"); /* 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) { functionWrapper(n); } /* Restore parameters */ Setattr(n, "sym:name", symname); Setattr(n, "type", type); Setattr(n, "name", name); /* 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); functionWrapper(n); 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) { Hash *symbols = Getattr(symtabs, scope ? scope : ""); if (!symbols) { // 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); Setattr(topscope_symbols, scope, NewHash()); } 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::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) { 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 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::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-2.0.12/Source/Modules/xml.cxx0000664000175000017500000002071312275776201016635 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-2.0.12/Source/Modules/swigmain.cxx0000664000175000017500000001355012275776201017654 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); } 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"}, {"-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-2.0.12/Source/Modules/php.cxx0000664000175000017500000026203412275776201016630 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 = (char *) "\ 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_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() {\n"); Printf(s_header, " TSRMLS_FETCH();\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, " int thisown;\n"); Append(s_header, "\n"); Append(s_header, " SWIG_ResetError();\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();\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 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_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(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) { // 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,NULL)\n", cname, iname); } /* ------------------------------------------------------------ * 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); 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();\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(); // Not issued for overloaded functions. if (!overloaded) { create_command(iname, wname); } Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); emit_parameter_variables(l, f); /* Attach standard typemaps */ emit_attach_parmmaps(l, f); // 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();\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();\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_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, "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"); /* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */ Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_set')) 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 __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"); 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"); } // 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"); } 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"); } 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%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args); Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\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();\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")) { /* constructor */ { Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); if (((const char *)Char(target))[Len(target) - 2] == '(') { Insert(target, Len(target) - 1, "TSRMLS_D"); } else { Insert(target, Len(target) - 1, " 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 */ { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); if (((const char *)Char(target))[Len(target) - 2] == '(') { Insert(target, Len(target) - 1, "TSRMLS_D"); } else { Insert(target, Len(target) - 1, " 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,\n"); 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) { static const String *amp_result = NewStringf("&%s", Swig_cresult_name()); Replaceall(tm, "$input", amp_result); 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();\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-2.0.12/Source/Modules/directors.cxx0000664000175000017500000002165512275776201020041 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) && !(checkAttribute(n, "staticmemberfunctionHandler:storage", "static") || checkAttribute(n, "storage", "static")) && !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-2.0.12/Source/Modules/s-exp.cxx0000664000175000017500000002404312275776201017071 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-2.0.12/Source/Modules/octave.cxx0000664000175000017500000013535012275776201017322 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" static String *global_name = 0; static String *op_prefix = 0; static const char *usage = (char *) "\ 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], "-global") == 0 || strcmp(argv[i], "-noglobal") == 0) { Printv(stderr, "*** -global/-noglobal are no longer supported\n" "*** global load behaviour is now determined at module load\n" "*** see the Perl section in the manual for details.\n", NIL); SWIG_exit(EXIT_FAILURE); } 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(); } 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) 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-2.0.12/Source/Modules/ruby.cxx0000664000175000017500000032376412275776201017032 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 = (char *) "\ 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) 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, (char *) "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-2.0.12/Source/Modules/modula3.cxx0000664000175000017500000040644412275776201017412 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 = (char *) "\ 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-2.0.12/Source/Modules/tcl8.cxx0000664000175000017500000012076212275776201016714 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 = (char *) "\ 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-2.0.12/Source/Modules/perl5.cxx0000664000175000017500000015555312275776201017077 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 = (char *) "\ 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_header = 0; static File *f_wrappers = 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); } /* 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) { /* 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); 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"); 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 (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); 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); 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; } /* ------------------------------------------------------------ * 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; 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); } /* 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))) { 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 */ Printv(pm, "sub DISOWN {\n", tab4, "my $self = shift;\n", 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); /* Only output the following methods if a class has member data */ Delete(operators); operators = 0; } 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; Language::constructorHandler(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); } Printv(pcode, tab4, "my $pkg = shift;\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"); } }; /* ----------------------------------------------------------------------------- * swig_perl5() - Instantiate module * ----------------------------------------------------------------------------- */ static Language *new_swig_perl5() { return new PERL5(); } extern "C" Language *swig_perl5(void) { return new_swig_perl5(); } swig-2.0.12/Source/Modules/csharp.cxx0000664000175000017500000046140412275776201017323 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_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 *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; 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_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) { /* 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 = Getattr(n, "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); } } } 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 [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, proxy_class_name, 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; } /* ---------------------------------------------------------------------- * 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 = 0; if (nspace || proxy_class_name) { scope = NewString(""); if (nspace) Printf(scope, "%s", nspace); if (proxy_class_name) Printv(scope, nspace ? "." : "", proxy_class_name, NIL); } 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 = NewString(""); if (nspace) Printf(scope, "%s.", nspace); if (proxy_class_name) Printf(scope, "%s.", proxy_class_name); 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; // 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 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 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(), proxy_class_name, "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, Type[] methodTypes) {\n"); Printf(proxy_class_code, " System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | 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(), proxy_class_name, smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); String *wname = Swig_name_wrapper(upcast_method); Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_cppcasts_code, " public static extern IntPtr %s(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; if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); if (!nspace) { full_proxy_class_name = NewStringf("%s", proxy_class_name); 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_proxy_class_name = NewStringf("%s.%s.%s", namespce, nspace, proxy_class_name); full_imclass_name = NewStringf("%s.%s", namespce, imclass_name); } else { full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name); full_imclass_name = NewStringf("%s", imclass_name); } } if (!addSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; 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); Clear(proxy_class_def); Clear(proxy_class_code); destructor_call = NewString(""); proxy_class_constants_code = NewString(""); } Language::classHandler(n); if (proxy_flag) { emitProxyClassDefAndCPPCasts(n); String *csclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // 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); Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); // Write out all the constants if (Len(proxy_class_constants_code) != 0) Printv(f_proxy, proxy_class_constants_code, NIL); Printf(f_proxy, "}\n"); addCloseNamespace(nspace, f_proxy); Delete(f_proxy); f_proxy = NULL; /* 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 = NULL; Delete(full_proxy_class_name); full_proxy_class_name = NULL; Delete(full_imclass_name); full_imclass_name = NULL; Delete(destructor_call); destructor_call = NULL; Delete(proxy_class_constants_code); proxy_class_constants_code = NULL; } 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(), proxy_class_name, 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(), 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 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, proxy_class_name, 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(), 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(""); 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) { if (SwigType_isenum(classnametype)) { String *enumname = getEnumName(classnametype); if (enumname) Replaceall(tm, classnamespecialvariable, enumname); else Replaceall(tm, classnamespecialvariable, NewStringf("int")); } else { String *classname = getProxyName(classnametype); if (classname) { Replaceall(tm, classnamespecialvariable, classname); // getProxyName() works for pointers to classes too } else { // use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved. String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); Replaceall(tm, classnamespecialvariable, descriptor); // Add to hash table so that the type wrapper classes can be created later Setattr(swig_types_hash, descriptor, classnametype); Delete(descriptor); } } } /* ----------------------------------------------------------------------------- * 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); 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 *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "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 (nspace) Insert(qualified_classname, 0, NewStringf("%s.", nspace)); Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_class_code, " public static extern void %s(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(), 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 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 Type[] swigMethodTypes%s = new 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); 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); 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); } /* ------------------------------------------------------------ * 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); } /* ---------------------------------------------------------------------- * 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 *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("); Printf(w->def, "void %s::swig_connect_director(", director_classname); 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", 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); } /* -------------------------------------------------------------------- * 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 *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); Delete(directorname); } }; /* 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 = (char *) "\ 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-2.0.12/Source/Modules/python.cxx0000664000175000017500000053631112275776201017364 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; /* 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 = (char *) "\ 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 = (char *) "\ -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 = (char *) "\ -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\ -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); } } } 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; } /* ------------------------------------------------------------ * importDirective() * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { if (shadow) { String *modname = Getattr(n, "module"); if (modname) { String *import = NewString("import "); // 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); // 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 *options = Getattr(mod, "options"); String *pkg = options ? Getattr(options, "package") : 0; if (pkg) { Printf(import, "%s.", pkg); } // finally, output the name of the imported module if (shadowimport) { if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) { Printf(import, "_%s\n", modname); if (!GetFlagAttr(f_shadow_imports, import)) { if (pkg) { Printf(builtin ? f_shadow_builtin_imports : f_shadow, "import %s.%s\n", pkg, modname); } else { Printf(builtin ? f_shadow_builtin_imports : f_shadow, "import %s\n", modname); } 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) 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 if (tuple_arguments > 0) { 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\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\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\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\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 *importname = NewString(""); String *modname = Getattr(mod, "name"); if (Strcmp(modname, mainmodule) != 0) { // check if the module has a package option Node *options = Getattr(mod, "options"); String *pkg = options ? Getattr(options, "package") : 0; if (pkg) { Printf(importname, "%s.", pkg); } Printf(importname, "%s.", modname); } Append(importname, Getattr(n, "sym:name")); Setattr(n, "python:proxy", 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"); String *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); /* Overide 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-2.0.12/Source/Modules/java.cxx0000664000175000017500000050563312275776201016767 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; 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) { /* 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. * ----------------------------------------------------------------------------- */ 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 = Getattr(n, "sym:name"); if (nspace) { if (package) proxyname = NewStringf("%s.%s.%s", package, nspace, symname); else proxyname = NewStringf("%s.%s", nspace, symname); } else { proxyname = Copy(symname); } Setattr(n, "proxyname", proxyname); Delete(proxyname); } } } 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, proxy_class_name, 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; } /* ---------------------------------------------------------------------- * 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 = 0; if (nspace || proxy_class_name) { scope = NewString(""); if (nspace) Printf(scope, "%s", nspace); if (proxy_class_name) Printv(scope, nspace ? "." : "", proxy_class_name, NIL); } 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 = NewString(""); if (nspace) Printf(scope, "%s.", nspace); if (proxy_class_name) Printf(scope, "%s.", proxy_class_name); 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; // 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 Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", 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(), proxy_class_name, "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(), proxy_class_name, 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; if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); String *nspace = getNSpace(); constructIntermediateClassName(n); if (!nspace) { full_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 (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 (!addSymbol(proxy_class_name, n, nspace)) return SWIG_ERROR; 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); filen = NULL; // 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"); } Clear(proxy_class_def); Clear(proxy_class_code); destructor_call = NewString(""); destructor_throws_clause = NewString(""); proxy_class_constants_code = NewString(""); Delete(output_directory); } Language::classHandler(n); if (proxy_flag) { emitProxyClassDefAndCPPCasts(n); String *javaclazzname = Swig_name_member(getNSpace(), proxy_class_name, ""); // 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); Printv(f_proxy, proxy_class_def, proxy_class_code, NIL); // Write out all the constants if (Len(proxy_class_constants_code) != 0) Printv(f_proxy, proxy_class_constants_code, NIL); Printf(f_proxy, "}\n"); Delete(f_proxy); f_proxy = NULL; /* 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 *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 = NULL; Delete(full_proxy_class_name); full_proxy_class_name = NULL; Delete(full_imclass_name); full_imclass_name = NULL; Delete(destructor_call); destructor_call = NULL; Delete(destructor_throws_clause); destructor_throws_clause = NULL; Delete(proxy_class_constants_code); proxy_class_constants_code = NULL; } 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(), proxy_class_name, 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(), 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; 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, proxy_class_name, 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(), 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 (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 '.' * ----------------------------------------------------------------------------- */ 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); } 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) enumname = NewStringf("%s.%s.%s", package, nspace, symname); else enumname = NewStringf("%s.%s", nspace, symname); } else { enumname = Copy(symname); } } if (!jnidescriptor) { // not cached Setattr(n, "enumname", enumname); 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. * 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 '.' * 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) { if (SwigType_isenum(classnametype)) { String *enumname = getEnumName(classnametype, jnidescriptor); if (enumname) Replaceall(tm, classnamespecialvariable, enumname); else Replaceall(tm, classnamespecialvariable, NewStringf("int")); } else { String *classname = getProxyName(classnametype); if (classname) { Replaceall(tm, classnamespecialvariable, classname); // getProxyName() works for pointers to classes too } else { // use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved. String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); Replaceall(tm, classnamespecialvariable, descriptor); // Add to hash table so that the type wrapper classes can be created later Setattr(swig_types_hash, descriptor, classnametype); Delete(descriptor); } } } /* ----------------------------------------------------------------------------- * 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); 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(), proxy_class_name, "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(), proxy_class_name, "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); } /* --------------------------------------------------------------- * Canonicalize the JNI field descriptor * * Replace the $javapackage 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) { String *pkg_path = Swig_typemap_lookup("javapackage", p, "", 0); SwigType *type = Getattr(p, "type"); if (!pkg_path || Len(pkg_path) == 0) pkg_path = package_path; String *descriptor_out = Copy(descriptor_in); substituteClassname(type, descriptor_out, true); if (Len(pkg_path) > 0 && Strchr(descriptor_out, '.') == NULL) { Replaceall(descriptor_out, "$packagepath", pkg_path); } else { Replaceall(descriptor_out, "$packagepath/", empty_string); Replaceall(descriptor_out, "$packagepath", empty_string); } Replaceall(descriptor_out, ".", "/"); if (pkg_path != package_path) Delete(pkg_path); 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; 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")) { 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); Printf(w->code, "if (jenv->ExceptionCheck() == JNI_TRUE) return $null;\n"); 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\");\n"); 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; } /* ------------------------------------------------------------ * 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); } }; /* 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 = (char *) "\ 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-2.0.12/Source/Modules/uffi.cxx0000664000175000017500000002477112275776201016776 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 = (char *) "\ 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-2.0.12/Source/Modules/overload.cxx0000664000175000017500000006527412275776201017663 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-2.0.12/Source/Modules/allocate.cxx0000664000175000017500000007321512275776201017626 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, "classname", 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")); 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. We need to check a few things here too */ 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 destructor was defined. We need to check a few things here too */ 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 default destructor, 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 destructor was defined. We need to check a few things here too */ 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 default destructor, 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((char *) "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"); inclass = 0; 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 (checkAttribute(n, "storage", "static")) { 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 */ Setattr(inclass, "allocate:has_assign", "1"); Setattr(inclass, "allocate:noassign", "1"); } else if (Strcmp(name, "operator new") == 0) { /* Look for a private new operator */ Setattr(inclass, "allocate:has_new", "1"); Setattr(inclass, "allocate:nonew", "1"); } } else { if (Strcmp(name, "operator =") == 0) { Setattr(inclass, "allocate:has_assign", "1"); } else if (Strcmp(name, "operator new") == 0) { Setattr(inclass, "allocate:has_new", "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:smartpointerbase", base); } 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((char *) "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-2.0.12/Source/Modules/contract.cxx0000664000175000017500000002347612275776201017663 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 && !checkAttribute(n, "storage", "static"))); 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; InClass = 1; CurrentClass = n; emit_children(n); InClass = 0; CurrentClass = 0; return ret; } int Contracts::top(Node *n) { emit_children(n); return SWIG_OK; } swig-2.0.12/Source/Modules/swigmod.h0000664000175000017500000003230712275776201017135 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); 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 Node *classLookup(const SwigType *s); /* 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; /* 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; /* 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) */ int use_naturalvar_mode(Node *n); 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); #endif swig-2.0.12/Source/Modules/r.cxx0000664000175000017500000022745012275776201016305 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 const int MAX_OVERLOAD_ARGS = 5; 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 = (char *)"\ 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 potentialy 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") && 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-2.0.12/Source/Modules/emit.cxx0000664000175000017500000003433512275776201017000 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-2.0.12/Source/Modules/allegrocl.cxx0000664000175000017500000030602512275776201020004 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 = (char *) "\ 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-2.0.12/Source/Modules/utils.cxx0000664000175000017500000001766312275776201017207 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-2.0.12/Source/Modules/mzscheme.cxx0000664000175000017500000006353312275776201017657 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 = (char *) "\ 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 char *mzscheme_path = (char *) "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-2.0.12/Source/Modules/guile.cxx0000664000175000017500000015435612275776201017155 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 = (char *) "\ 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, (char *) ""); 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, (char *) ""); 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_lstr(nctype, 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-2.0.12/Source/Modules/typepass.cxx0000664000175000017500000011605312275776201017710 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; } } 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"); Node *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); } 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) { 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; inclass = oldinclass; /* If in a namespace, patch the class name */ if (nname) { Setattr(n, "name", nname); Delete(nname); } Delete(fname); return SWIG_OK; } /* ------------------------------------------------------------ * namespaceDeclaration() * ------------------------------------------------------------ */ 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; } /* ------------------------------------------------------------ * 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"); 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"); if (!value) value = name; if (Strcmp(value, name) == 0) { String *new_value; if ((nsname || inclass) && cparse_cplusplus) { new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value); } else { new_value = NewString(value); } if ((nsname || inclass) && !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 (!(checkAttribute(c, "storage", "static") || 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-2.0.12/Source/Modules/main.cxx0000664000175000017500000012562312275776201016767 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; } /* 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 char *hpp_extension = (char *) "h"; static char *cpp_extension = (char *) "cxx"; static char *depends_extension = (char *) "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 = (char *) 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, (char *) "=", (char *) " ", 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], "-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], "-nonaturalvar") == 0) { Wrapper_naturalvar_mode_set(0); 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); // 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); 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 (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 (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-2.0.12/Source/Modules/pike.cxx0000664000175000017500000006477512275776201017005 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 = (char *) "\ 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-2.0.12/Source/Modules/go.cxx0000664000175000017500000043343412275776201016452 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; // Name of shared library to import. String *soname; // Size in bits of the C type "long". int long_type_size; // 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_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 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; public: GO():package(NULL), module(NULL), gccgo_flag(false), go_prefix(NULL), soname(NULL), long_type_size(32), 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_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_types(NULL), defined_types(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]) { go_prefix = NewString(argv[i + 1]); Swig_mark_arg(i); Swig_mark_arg(i + 1); i++; } else { Swig_arg_error(); } } 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) { if (argv[i + 1]) { long_type_size = atoi(argv[i + 1]); if (long_type_size != 32 && long_type_size != 64) { Printf(stderr, "-longsize 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], "-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 && !go_prefix) { go_prefix = NewString("go"); } // Add preprocessor symbol to parser. Preprocessor_define("SWIGGO 1", 0); if (gccgo_flag) { Preprocessor_define("SWIGGO_GCCGO 1", 0); } if (long_type_size == 32) { Preprocessor_define("SWIGGO_LONG_TYPE_SIZE 32", 0); } else { Preprocessor_define("SWIGGO_LONG_TYPE_SIZE 64", 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) { soname = Copy(package); Append(soname, ".so"); } // Get filenames. 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_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_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); Printf(f_c_runtime, "#define SWIGMODULE %s\n", module); if (directorsEnabled()) { Printf(f_c_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_c_directors_h); 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); if (!gccgo_flag) { Swig_banner(f_gc_begin); 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); Printf(f_go_runtime, "//extern %sSwigCgocall\n", module); Printf(f_go_runtime, "func SwigCgocall()\n"); Printf(f_go_runtime, "//extern %sSwigCgocallDone\n", module); Printf(f_go_runtime, "func SwigCgocallDone()\n"); Printf(f_go_runtime, "//extern %sSwigCgocallBack\n", module); Printf(f_go_runtime, "func SwigCgocallBack()\n"); Printf(f_go_runtime, "//extern %sSwigCgocallBackDone\n", module); 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_types = NewHash(); defined_types = NewHash(); // Emit code. Language::top(n); // Write out definitions for the types not defined by SWIG. 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_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_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_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) { Printv(f_go_begin, "import \"", modname, "\"\n", NULL); imported_package = modname; saw_import = true; } int r = Language::importDirective(n); imported_package = hold_import; return r; } /* ---------------------------------------------------------------------- * 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, "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_prefix, "_", 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); if (SwigType_type(result) == T_VOID) { Printv(f->def, "void ", fnname, NULL); } else { String *ct = gccgoCTypeForGoValue(n, result, fnname); Printv(f->def, ct, NULL); Delete(ct); } Printv(f->def, " {\n", NULL); Delete(fnname); 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 (Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "static") == 0) { 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, ".", package, ".", 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, "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; } 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(cn); Delete(go_name); Delete(director_struct_name); Delete(go_upcall); } } 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); 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); // Declare the upcall function, which calls the method on the // parent class. if (overname) { Append(upcall_wname, overname); } String *upcall_gc_name = buildGoWrapperName(upcall_name, overname); 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 (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. 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); // Define a function which 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); Delete(upcall_gc_name); } Printv(f_go_wrappers, "}\n\n", NULL); Delete(result_wrapper); // Build the C++ functions. Delete(upcall_wname); 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, ".", package, ".", callback_name, "\");\n", NULL); } Delete(upcall_method_name); 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, "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); Node *e = Language::enumLookup(t); if (e) { ret = goEnumName(e); } else if (Strcmp(t, "enum ") == 0) { ret = NewString("int"); } 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); SwigType_strip_qualifiers(t); if (SwigType_ispointer(t)) { SwigType_del_pointer(t); SwigType_strip_qualifiers(t); } if (SwigType_isreference(t)) { SwigType_del_reference(t); SwigType_strip_qualifiers(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 { ret = SwigType_lstr(t, name); } Delete(q); Delete(t); return ret; } } Delete(q); } } if (Language::enumLookup(t) != NULL || Strcmp(t, "enum ") == 0) { is_int = true; } 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 && (Strcmp(storage, "static") == 0 || 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 = (char *) "\ Go Options (available with -go)\n\ -gccgo - Generate code for gccgo rather than 6g/8g\n\ -go-prefix

- Like gccgo -fgo-prefix option\n\ -longsize - Set size of C/C++ long type--32 or 64 bits\n\ -intgosize - Set size of Go int type--32 or 64 bits\n\ -package - Set name of the Go package to \n\ -soname - Set shared library holding C/C++ code to \n\ \n"; swig-2.0.12/Source/Modules/lua.cxx0000664000175000017500000015306712275776201016627 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); } } /* 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 = (char *) "\ 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\ -nomoduleglobal - Do not register the module name as a global variable \n\ but return the module table from calls to require.\n\ \n"; static int nomoduleglobal = 0; static int elua_ltr = 0; static int eluac_ltr = 0; /* 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_cmd_tab; // table of command names String *s_var_tab; // table of global variables String *s_const_tab; // table of global constants String *s_methods_tab; // table of class methods String *s_attr_tab; // table of class attributes String *s_cls_attr_tab; // table of class static attributes String *s_cls_methods_tab; // table of class static methods String *s_cls_const_tab; // tables of class constants(including enums) String *s_luacode; // luacode to be called during init String *s_dot_get; // table of variable 'get' functions String *s_dot_set; // table of variable 'set' functions String *s_vars_meta_tab; // metatable for variables int have_constructor; int have_destructor; String *destructor_action; String *class_name; String *constructor_name; enum { NO_CPP, VARIABLE, MEMBER_FUNC, CONSTRUCTOR, DESTRUCTOR, MEMBER_VAR, CLASS_CONST, STATIC_FUNC, STATIC_VAR }current; 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_cmd_tab(0), s_var_tab(0), s_const_tab(0), s_methods_tab(0), s_attr_tab(0), s_cls_attr_tab(0), s_cls_methods_tab(0), s_cls_const_tab(0), s_luacode(0), s_dot_get(0), s_dot_set(0), s_vars_meta_tab(0), have_constructor(0), have_destructor(0), destructor_action(0), class_name(0), constructor_name(0), current(NO_CPP) { } /* NEW LANGUAGE NOTE:*********************************************** This is called to initalise 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); } } } /* 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 */ 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_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); /* NEW LANGUAGE NOTE:*********************************************** s_cmd_tab,s_var_tab & s_const_tab hold the names of the fns for registering with SWIG. These will be filled in when the functions/variables are wrapped & then added to the end of the wrappering code just before it is written to file NEW LANGUAGE NOTE:END ************************************************/ // Initialize some variables for the object interface s_cmd_tab = NewString(""); s_var_tab = NewString(""); // s_methods_tab = NewString(""); s_const_tab = NewString(""); s_dot_get = NewString(""); s_dot_set = NewString(""); s_vars_meta_tab = NewString(""); s_luacode = NewString(""); Swig_register_filebyname("luacode", s_luacode); current=NO_CPP; /* 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 (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); if (elua_ltr || eluac_ltr) Printf(f_header, "#define swig_commands %s_map\n\n", module); if (elua_ltr || eluac_ltr) { Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n"); Printf(s_cmd_tab, "#include \"lrotable.h\"\n"); Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n"); if (elua_ltr) Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n"); Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n"); Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n"); Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); if (elua_ltr) { Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n"); Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n"); } } else { Printf(s_cmd_tab, "\nstatic const struct luaL_Reg swig_commands[] = {\n"); Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n"); Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n"); 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"); Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n"); // Done. Close up the module & write to the wrappers if (elua_ltr || eluac_ltr) { Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL); if (elua_ltr) Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL); Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL); Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL); } else { Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL); Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL); Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL); } if (elua_ltr) { /* Generate the metatable */ Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n"); Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL); Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL); Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL); Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL); Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); } if (elua_ltr || eluac_ltr) { /* Final close up of wrappers */ Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL); SwigType_emit_type_table(f_runtime, f_wrappers); } else { Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL); 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 excaped 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(s_cmd_tab); Delete(s_var_tab); Delete(s_const_tab); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); Delete(f_runtime); Delete(f_begin); Delete(s_dot_get); Delete(s_dot_set); Delete(s_vars_meta_tab); /* Done */ return SWIG_OK; } /* ------------------------------------------------------------ * importDirective() * ------------------------------------------------------------ */ virtual int importDirective(Node *n) { return Language::importDirective(n); } /* NEW LANGUAGE NOTE:*********************************************** This is it! you get this one right, and most of your work is done but its going to take soem file to get it working right quite a bit of this is generally boilerplate code (or stuff I dont understand) that which matters will have extra added comments NEW LANGUAGE NOTE:END ************************************************/ /* --------------------------------------------------------------------- * functionWrapper() * * Create a function declaration and register it with the interpreter. * --------------------------------------------------------------------- */ virtual int functionWrapper(Node *n) { REPORT("functionWrapper",n); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); SwigType *d = Getattr(n, "type"); ParmList *l = Getattr(n, "parms"); //Printf(stdout,"functionWrapper %s %s\n",name,iname); Parm *p; String *tm; int i; //Printf(stdout,"functionWrapper %s %s %d\n",name,iname,current); // int returnval=0; // number of arguments returned String *overname = 0; if (Getattr(n, "sym:overloaded")) { overname = Getattr(n, "sym:overname"); } else { if (!addSymbol(iname, n)) { Printf(stderr,"addSymbol(%s) failed\n",iname); return SWIG_ERROR; } } /* NEW LANGUAGE NOTE:*********************************************** the wrapper object holds all the wrappering 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); } /* NEW LANGUAGE NOTE:*********************************************** the format of a lua fn is: static int wrap_XXX(lua_State* L){...} this line adds this into the wrappering 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"); } /* 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; /* 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 on 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 dont 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); } } 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 wrappered 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. */ if (!Getattr(n, "sym:overloaded")) { //REPORT("dispatchFunction", n); // add_method(n, iname, wname, description); if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns String *wrapname = Swig_name_wrapper(iname); if(elua_ltr || eluac_ltr) Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL); else Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL); // Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL); if (getCurrentClass()) { Setattr(n,"luaclassobj:wrap:name", wrapname); } } } else { if (!Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } } Delete(argument_check); Delete(argument_parse); Delete(cleanup); Delete(outarg); // Delete(description); Delete(wname); DelWrapper(f); return SWIG_OK; } /* ------------------------------------------------------------ * 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 nost of the real work in again typemaps: look for %typecheck(SWIG_TYPECHECK_*) in the .swg file NEW LANGUAGE NOTE:END ************************************************/ void 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 *wname = Swig_name_wrapper(symname); //Printf(stdout,"Swig_overload_dispatch %s %s '%s' %d\n",symname,wname,dispatch,maxargs); 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); //add_method(symname,wname,0); if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wname, "},\n", NIL); if (getCurrentClass()) Setattr(n,"luaclassobj:wrap:name", wname); else Delete(wname); DelWrapper(f); Delete(dispatch); Delete(tmp); } /* ------------------------------------------------------------ * 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 *iname = Getattr(n, "sym:name"); current=VARIABLE; // let SWIG generate the wrappers int result = Language::variableWrapper(n); current=NO_CPP; // normally SWIG will generate 2 wrappers, a get and a set // but in certain scenarios (immutable, or if its arrays), it will not String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname)); String *setName = 0; // checking whether it can be set to or not appears to be a very error prone issue // I referred to the Language::variableWrapper() to find this out bool assignable=is_assignable(n) ? true : false; SwigType *type = Getattr(n, "type"); String *tm = Swig_typemap_lookup("globalin", n, iname, 0); if (!tm && SwigType_isarray(type)) assignable=false; Delete(tm); if (assignable) { setName = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, iname)); } else { // how about calling a 'this is not settable' error message? setName = NewString("SWIG_Lua_set_immutable"); // error message //setName = NewString("0"); } // register the variable if (elua_ltr) { Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName); Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName); } else if (eluac_ltr) { Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL); Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL); } else { Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName); } if (getCurrentClass()) { Setattr(n, "luaclassobj:wrap:get", getName); Setattr(n, "luaclassobj:wrap:set", setName); } else { Delete(getName); Delete(setName); } return result; } /* ------------------------------------------------------------ * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { REPORT("constantWrapper", n); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *nsname = Copy(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; /* 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(s_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; } if (cparse_cplusplus && getCurrentClass()) { // Additionally add to class constants Swig_require("luaclassobj_constantWrapper", n, "*sym:name", "luaclassobj:symname", NIL); Setattr(n, "sym:name", Getattr(n, "luaclassobj:symname")); String *cls_nsname = Getattr(n, "sym:name"); if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Replaceall(tm, "$nsname", cls_nsname); Printf(s_cls_const_tab, " %s,\n", tm); } 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 (!addSymbol(wrapname, n)) return SWIG_ERROR; Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wrapname, "},\n", NIL); // return Language::nativeWrapper(n); // this does nothing... 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) { //REPORT("classHandler", n); String *mangled_classname = 0; String *real_classname = 0; constructor_name = 0; have_constructor = 0; have_destructor = 0; destructor_action = 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); // 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 (Getattr(emitted, mangled_classname)) return SWIG_NOWRAP; Setattr(emitted, mangled_classname, "1"); s_attr_tab = NewString(""); Printf(s_attr_tab, "static swig_lua_attribute swig_"); Printv(s_attr_tab, mangled_classname, "_attributes[] = {\n", NIL); s_methods_tab = NewString(""); Printf(s_methods_tab, "static swig_lua_method swig_"); Printv(s_methods_tab, mangled_classname, "_methods[] = {\n", NIL); s_cls_methods_tab = NewString(""); Printf(s_cls_methods_tab, "static swig_lua_method swig_"); Printv(s_cls_methods_tab, mangled_classname, "_cls_methods[] = {\n", NIL); s_cls_attr_tab = NewString(""); Printf(s_cls_attr_tab, "static swig_lua_attribute swig_"); Printv(s_cls_attr_tab, mangled_classname, "_cls_attributes[] = {\n", NIL); s_cls_const_tab = NewString(""); Printf(s_cls_const_tab, "static swig_lua_const_info swig_"); Printv(s_cls_const_tab, mangled_classname, "_cls_constants[] = {\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' 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); // emit a function to be called to delete the object if (have_destructor) { Printv(f_wrappers, "static 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(s_methods_tab, " {0,0}\n};\n"); Printv(f_wrappers, s_methods_tab, NIL); Printf(s_attr_tab, " {0,0,0}\n};\n"); Printv(f_wrappers, s_attr_tab, NIL); Printf(s_cls_attr_tab, " {0,0,0}\n};\n"); Printv(f_wrappers, s_cls_attr_tab, NIL); Printf(s_cls_methods_tab, " {0,0}\n};\n"); Printv(f_wrappers, s_cls_methods_tab, NIL); Printf(s_cls_const_tab, " {0,0,0,0,0,0}\n};\n"); Printv(f_wrappers, s_cls_const_tab, NIL); Delete(s_methods_tab); Delete(s_attr_tab); Delete(s_cls_methods_tab); Delete(s_cls_attr_tab); Delete(s_cls_const_tab); // 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; } // old code: (used the pointer to the base class) //String *bmangle = Swig_name_mangle(bname); //Printf(base_class, "&_wrap_class_%s", bmangle); //Putc(',', base_class); //Delete(bmangle); // new code: stores a null pointer & the name Printf(base_class, "0,"); Printf(base_class_names, "\"%s *\",", SwigType_namestr(bname)); b = Next(b); index++; } } Printv(f_wrappers, "static swig_lua_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL); Delete(base_class); Printv(f_wrappers, "static const char *swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL); Delete(base_class_names); Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); if (have_constructor) { if (elua_ltr) { Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \ Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); } else if (eluac_ltr) { Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \ Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL); Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); } else { 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) { if (eluac_ltr) { Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL); Printv(f_wrappers, ", swig_delete_", class_name, NIL); } else { Printv(f_wrappers, ", swig_delete_", class_name, NIL); } } else { Printf(f_wrappers, ",0"); } Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, { \"%s\", swig_%s_cls_methods, swig_%s_cls_attributes, swig_%s_cls_constants }, swig_%s_bases, swig_%s_base_names };\n\n", mangled_classname, mangled_classname, class_name, mangled_classname, mangled_classname, mangled_classname, mangled_classname, mangled_classname); // Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases };\n\n", NIL); // Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_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"); //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(Getattr(n, "sym:name"), "__unm") == 0) { //Printf(stdout, "unary minus: ignore one argument\n"); SetInt(n, "lua:ignore_args", 1); } String *realname, *rname; current = MEMBER_FUNC; Language::memberfunctionHandler(n); current = NO_CPP; realname = iname ? iname : name; rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname)); if (!Getattr(n, "sym:nextSibling")) { Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); } Delete(rname); return SWIG_OK; } /* ------------------------------------------------------------ * membervariableHandler() * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { // REPORT("membervariableHandler",n); String *symname = Getattr(n, "sym:name"); String *gname, *sname; current = MEMBER_VAR; Language::membervariableHandler(n); current = NO_CPP; gname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); if (!GetFlag(n, "feature:immutable")) { sname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname))); } else { //sname = NewString("0"); sname = NewString("SWIG_Lua_set_immutable"); // error message } Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname); if (eluac_ltr) { Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \ ", LFUNCVAL(", gname, ")", "},\n", NIL); Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \ ", LFUNCVAL(", sname, ")", "},\n", NIL); } Delete(gname); Delete(sname); return SWIG_OK; } /* ------------------------------------------------------------ * constructorHandler() * * Method for adding C++ member constructor * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { // REPORT("constructorHandler", n); current = CONSTRUCTOR; Language::constructorHandler(n); current = NO_CPP; constructor_name = NewString(Getattr(n, "sym:name")); have_constructor = 1; return SWIG_OK; } /* ------------------------------------------------------------ * destructorHandler() * ------------------------------------------------------------ */ virtual int destructorHandler(Node *n) { REPORT("destructorHandler", n); current = DESTRUCTOR; Language::destructorHandler(n); current = NO_CPP; have_destructor = 1; destructor_action = Getattr(n, "wrap:action"); return SWIG_OK; } /* ----------------------------------------------------------------------- * staticmemberfunctionHandler() * * Wrap a static C++ function * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { REPORT("staticmemberfunctionHandler", n); current = STATIC_FUNC; String *symname = Getattr(n, "sym:name"); int result = Language::staticmemberfunctionHandler(n); if (cparse_cplusplus && getCurrentClass()) { Swig_restore(n); } current = NO_CPP; if (result != SWIG_OK) return result; if (Getattr(n, "sym:nextSibling")) return SWIG_OK; Swig_require("luaclassobj_staticmemberfunctionHandler", n, "luaclassobj:wrap:name", NIL); String *name = Getattr(n, "name"); String *rname, *realname; realname = symname ? symname : name; rname = Getattr(n, "luaclassobj:wrap:name"); Printv(s_cls_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); Swig_restore(n); return SWIG_OK; } /* ------------------------------------------------------------ * memberconstantHandler() * * Create a C++ constant * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { REPORT("memberconstantHandler",n); String *symname = Getattr(n, "sym:name"); if (cparse_cplusplus && getCurrentClass()) { Swig_save("luaclassobj_memberconstantHandler", n, "luaclassobj:symname", NIL); Setattr(n, "luaclassobj:symname", symname); } int result = Language::memberconstantHandler(n); if (cparse_cplusplus && getCurrentClass()) Swig_restore(n); return result; } /* --------------------------------------------------------------------- * staticmembervariableHandler() * --------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { REPORT("staticmembervariableHandler",n); current = STATIC_VAR; String *symname = Getattr(n, "sym:name"); int result = Language::staticmembervariableHandler(n); if (result != SWIG_OK) return result; if (Getattr(n, "wrappedasconstant")) return SWIG_OK; Swig_require("luaclassobj_staticmembervariableHandler", n, "luaclassobj:wrap:get", "luaclassobj:wrap:set", NIL); Printf(s_cls_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,Getattr(n,"luaclassobj:wrap:get"), Getattr(n,"luaclassobj:wrap:set")); Swig_restore(n); return SWIG_OK; } /* --------------------------------------------------------------------- * 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; 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_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"); } /* 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); } }; /* 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-2.0.12/Source/Modules/module.cxx0000664000175000017500000000333512275776201017323 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-2.0.12/Source/DOH/0000775000175000017500000000000012275776201014310 5ustar williamwilliamswig-2.0.12/Source/DOH/README0000664000175000017500000001105212275776201015167 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,val) 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 Close(obj) Close 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-2.0.12/Source/DOH/memory.c0000664000175000017500000001434212275776201015770 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-2.0.12/Source/DOH/file.c0000664000175000017500000001724512275776201015404 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-2.0.12/Source/DOH/doh.h0000664000175000017500000004143612275776201015243 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; 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-2.0.12/Source/DOH/fio.c0000664000175000017500000003214712275776201015240 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)) { if (!encodings) encodings = NewHash(); Setattr(encodings, (void *) name, NewVoid((void *) fn, 0)); } /* internal function for processing an encoding */ static DOH *encode(char *name, DOH *s) { DOH *handle, *ns; DOH *(*fn) (DOH *); 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); fn = (DOH *(*)(DOH *)) Data(handle); ns = (*fn) (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-2.0.12/Source/DOH/void.c0000664000175000017500000000577712275776201015435 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-2.0.12/Source/DOH/hash.c0000664000175000017500000003343512275776201015407 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-2.0.12/Source/DOH/dohint.h0000664000175000017500000001137412275776201015754 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-2.0.12/Source/DOH/list.c0000664000175000017500000002275712275776201015444 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-2.0.12/Source/DOH/string.c0000664000175000017500000007047412275776201015776 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->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-2.0.12/Source/DOH/base.c0000664000175000017500000006510212275776201015372 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; DOH *(*builtin) (DOH *); builtin = (DOH *(*)(DOH *)) GetVoid(func, "builtin"); if (!builtin) return 0; result = (*builtin) (args); return result; } swig-2.0.12/Source/Makefile.in0000664000175000017500000012026112275777513015754 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_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/lang.$(OBJEXT) Modules/lua.$(OBJEXT) \ Modules/main.$(OBJEXT) Modules/modula3.$(OBJEXT) \ Modules/module.$(OBJEXT) Modules/mzscheme.$(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/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@ 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@ 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@ 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@ 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@ PLATFLAGS = @PLATFLAGS@ 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_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@ XINCLUDES = @XINCLUDES@ XLIBSW = @XLIBSW@ XMKMF = @XMKMF@ 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/lang.cxx \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ Modules/module.cxx \ Modules/mzscheme.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/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 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 DOHString_or_char 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/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/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/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/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/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/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)/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)/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)/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-2.0.12/Source/Makefile.am0000664000175000017500000001100612275776201015730 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/lang.cxx \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ Modules/module.cxx \ Modules/mzscheme.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/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 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 DOHString_or_char 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-2.0.12/Source/Swig/0000775000175000017500000000000012275776201014607 5ustar williamwilliamswig-2.0.12/Source/Swig/misc.c0000664000175000017500000007742512275776201015725 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_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; } #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); } String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s) { String *result = NewStringEmpty(); const char *p = Char(subst); while (*p) { /* Copy part without substitutions */ const char *q = strchr(p, '\\'); if (!q) { Write(result, p, strlen(p)); break; } Write(result, p, q - p); 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) { Write(result, input + l, r - l); } } 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); } } } 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-2.0.12/Source/Swig/fragment.c0000664000175000017500000001273012275776201016561 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; if (!fragments) { Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name); return; } name = Getattr(n, "value"); if (!name) { name = n; } 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-2.0.12/Source/Swig/scanner.c0000664000175000017500000010025412275776201016406 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 */ }; typedef struct Locator { String *filename; int line_number; struct Locator *next; } Locator; static int follow_locators = 0; /* ----------------------------------------------------------------------------- * 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; return s; } /* ----------------------------------------------------------------------------- * DelScanner() * * Delete a scanner object. * ----------------------------------------------------------------------------- */ void DelScanner(Scanner * s) { assert(s); Delete(s->scanobjs); 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); 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; } /* ----------------------------------------------------------------------------- * 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; int c = 0; state = 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 */ else if ((isalpha(c)) || (c == '_') || (s->idstart && strchr(s->idstart, c))) state = 7; /* Look for single character symbols */ else if (c == '(') return SWIG_TOKEN_LPAREN; else if (c == ')') return SWIG_TOKEN_RPAREN; else if (c == ';') 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 == '{') 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 = 2; /* Possibly a string */ s->start_line = s->line; Clear(s->text); } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ 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 ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_STRING; } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } else state = 2; 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) return SWIG_TOKEN_LESSTHAN; if (c == '<') state = 240; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_GREATERTHAN; if (c == '>') state = 250; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s, 1); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier */ if ((c = nextchar(s)) == 0) state = 71; else if (isalnum(c) || (c == '_') || (c == '$')) { state = 7; } else { retract(s, 1); state = 71; } break; case 71: /* 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 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 7; } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; state = 71; } 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_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-2.0.12/Source/Swig/typeobj.c0000664000175000017500000007476012275776201016445 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 (&) * '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_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_array() * * In addition, there are query functions * * SwigType_ispointer() * SwigType_isreference() * 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 it's 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; } /* ----------------------------------------------------------------------------- * 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-2.0.12/Source/Swig/swigopt.h0000664000175000017500000000156712275776201016465 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-2.0.12/Source/Swig/swigfile.h0000664000175000017500000000400612275776201016571 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-2.0.12/Source/Swig/typesys.c0000664000175000017500000016621512275776201016506 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; 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) { /* 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 return T_POINTER; } if (strncmp(c, "a(", 2) == 0) return T_ARRAY; if (strncmp(c, "r.", 2) == 0) return T_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, "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, "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 specify that the value wrapper is not needed by using * the %feature("novaluewrapper"), in that case the user need to type * * %feature("novaluewrapper") MyOpaqueClass; * class MyOpaqueClass; * * Users can also force the use of the value wrapper by using the * %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); } } 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-2.0.12/Source/Swig/include.c0000664000175000017500000002613512275776201016405 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-2.0.12/Source/Swig/symbol.c0000664000175000017500000017221112275776201016264 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-2.0.12/Source/Swig/swigtree.h0000664000175000017500000000441412275776201016614 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); /* 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-2.0.12/Source/Swig/swig.h0000664000175000017500000005020012275776201015726 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_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_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_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_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 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, String *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 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 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); 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); /* 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-2.0.12/Source/Swig/wrapfunc.c0000664000175000017500000003100212275776201016574 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-2.0.12/Source/Swig/swigscan.h0000664000175000017500000001270512275776201016603 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 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_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-2.0.12/Source/Swig/swigwrap.h0000664000175000017500000000277412275776201016635 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-2.0.12/Source/Swig/getopt.c0000664000175000017500000000701012275776201016253 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-2.0.12/Source/Swig/cwrap.c0000664000175000017500000013642312275776201016100 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" extern int cparse_cplusplus; 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_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 (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) { 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_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 = (char *) "(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); 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 (Cmp(Getattr(n, "storage"), "static") == 0) { String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : 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, "classname") ? Getattr(n, "classname") : 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 (Cmp(Getattr(n, "storage"), "static") != 0) { 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) { ParmList *parms; Parm *prefix_args; Parm *p; ParmList *directorparms; SwigType *type; int use_director; String *directorScope = NewString(nspace); Replace(directorScope, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY); use_director = Swig_directorclass(n); parms = CopyParmList(nonvoid_parms(Getattr(n, "parms"))); /* Prepend the list of prefix_args (if any) */ 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 *name = Getattr(parent, "sym:name"); String *directorname; String *action = NewStringEmpty(); String *tmp_none_comparison = Copy(none_comparison); String *director_call; String *nodirector_call; if (Len(directorScope) > 0) directorname = NewStringf("SwigDirector_%s_%s", directorScope, name); else directorname = NewStringf("SwigDirector_%s", name); 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); Delete(directorname); } 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); Delete(directorScope); 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 (checkAttribute(n, "storage", "static")) { 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-2.0.12/Source/Swig/deprecate.c0000664000175000017500000000753212275776201016716 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-2.0.12/Source/Swig/stype.c0000664000175000017500000010232612275776201016123 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 (&) * '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_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; 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_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_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))) { /* 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_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))) { td = 0; } else { td = SwigType_typedef_resolve(rs); } if (td) { if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(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_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_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-2.0.12/Source/Swig/parms.c0000664000175000017500000001612112275776201016076 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-2.0.12/Source/Swig/naming.c0000664000175000017500000014153712275776201016237 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, String *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 ((Cmp(a_storage, "static") == 0) || (Cmp(b_storage, "static") == 0)) { 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); } /* ----------------------------------------------------------------------------- * 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-2.0.12/Source/Swig/error.c0000664000175000017500000002346712275776201016120 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-2.0.12/Source/Swig/tree.c0000664000175000017500000002354612275776201015724 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); } } /* ----------------------------------------------------------------------------- * 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-2.0.12/Source/Swig/typemap.c0000664000175000017500000017457412275776201016454 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))) { if (!(SwigType_isarray(type) || SwigType_ispointer(type) || SwigType_isreference(type))) { star_type = Copy(ftype); } else { star_type = Copy(type); } if (!SwigType_isreference(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(DOHString * 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-2.0.12/Source/Swig/swigparm.h0000664000175000017500000000276712275776201016625 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-2.0.12/Source/Preprocessor/0000775000175000017500000000000012275776201016364 5ustar williamwilliamswig-2.0.12/Source/Preprocessor/expr.c0000664000175000017500000003032712275776201017513 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-2.0.12/Source/Preprocessor/cpp.c0000664000175000017500000014526512275776201017327 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-2.0.12/Source/Preprocessor/preprocessor.h0000664000175000017500000000273312275776201021270 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-2.0.12/Tools/0000775000175000017500000000000012275776201013536 5ustar williamwilliamswig-2.0.12/Tools/config/0000775000175000017500000000000012275777513015012 5ustar williamwilliamswig-2.0.12/Tools/config/ax_path_generic.m40000664000175000017500000001262212275776201020370 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-2.0.12/Tools/config/depcomp0000755000175000017500000004755612275777513016406 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-2.0.12/Tools/config/install-sh0000755000175000017500000003325612275777513017025 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-2.0.12/Tools/config/ac_compare_version.m40000664000175000017500000000241512275776201021105 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-2.0.12/Tools/config/ax_compare_version.m40000664000175000017500000001465212275776201021140 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-2.0.12/Tools/config/ax_boost_base.m40000664000175000017500000002415312275776201020062 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 20 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` if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then libsubdirs="lib64 lib lib64" fi 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-2.0.12/Tools/config/ylwrap0000755000175000017500000001435712275777513016266 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-2.0.12/Tools/config/ac_define_dir.m40000664000175000017500000000224012275776201017776 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-2.0.12/Tools/config/compile0000755000175000017500000001533712275777513016377 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-2.0.12/Tools/config/missing0000755000175000017500000002415212275777513016413 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-2.0.12/Tools/config/config.guess0000755000175000017500000012743212275777513017341 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-2.0.12/Tools/config/ac_compile_warnings.m40000664000175000017500000000335212275776201021253 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 overidden 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-2.0.12/Tools/config/config.sub0000755000175000017500000010517612275777513017005 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-2.0.12/Tools/mkwindows.sh0000775000175000017500000000775312275776201016133 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-2.0.12/Tools/capitalize0000775000175000017500000000034712275776201015615 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-2.0.12/Tools/swig.gdb0000664000175000017500000000244012275776201015165 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-2.0.12/Tools/pyname_patch.py0000664000175000017500000001166412275776201016570 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-2.0.12/Tools/vcfilter0000775000175000017500000000067112275776201015306 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-2.0.12/Tools/setup.py.tmpl0000664000175000017500000001125712275776201016231 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-2.0.12/Tools/mkdist.py0000775000175000017500000000643412275776201015415 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-2.0.12/Tools/pcre-build.sh0000775000175000017500000000427112275776201016127 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-2.0.12/Tools/check-include-path.pike0000664000175000017500000000110712275776201020037 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-2.0.12/Tools/mkrelease.py0000775000175000017500000000374712275776201016076 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'." swig-2.0.12/configure0000775000175000017500000136002412275777514014363 0ustar williamwilliam#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for swig 2.0.12. # # 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='2.0.12' PACKAGE_STRING='swig 2.0.12' 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_JAVA SKIP_PYTHON3 SKIP_PYTHON SKIP_OCTAVE SKIP_PERL5 SKIP_TCL DLIBPREFIX DDEFAULTVERSION D2COMPILER D1COMPILER GOVERSIONOPTION GOOPT 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 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 XLIBSW XINCLUDES XMKMF LIBC LIBCRYPT LIBM SWILL SWIGLIBS LUA_SO MZSCHEME_SO PHP_SO GUILE_SO TCL_SO PYTHON_SO LINKFORSHARED PLATFLAGS 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 with_libm with_libc with_x 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_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 XMKMF' 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 2.0.12 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 X features: --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR 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 2.0.12:";; 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) 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 --with-x use the X Window System --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-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. XMKMF Path to xmkmf, Makefile generator for X Window System 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 2.0.12 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 2.0.12, 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='2.0.12' 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-90-9*\.0-90-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-90-9*\.0-90-9*\.0-90-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` if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then libsubdirs="lib64 lib lib64" fi 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 PLATFLAGS" >&5 $as_echo_n "checking PLATFLAGS... " >&6; } case $host in *-*-solaris*) if test "$GCC" = yes then PLATFLAGS= else PLATFLAGS= # else PLATFLAGS="-errtags=yes" # Need more work as C examples use ld for linking fi;; *) PLATFLAGS= esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PLATFLAGS" >&5 $as_echo "$PLATFLAGS" >&6; } # 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 #-------------------------------------------------------------------- # Locate the X11 header files and the X11 library archive. Try # the ac_path_x macro first, but if it doesn't find the X stuff # (e.g. because there's no xmkmf program) then check through # a list of possible directories. Under some conditions the # autoconf macro will return an include directory that contains # no include files, so double-check its result just to be safe. #-------------------------------------------------------------------- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5 $as_echo_n "checking for X... " >&6; } # Check whether --with-x was given. if test "${with_x+set}" = set; then : withval=$with_x; fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else case $x_includes,$x_libraries in #( *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=no ac_x_libraries=no rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' incroot: @echo incroot='${INCROOT}' usrlibdir: @echo usrlibdir='${USRLIBDIR}' libdir: @echo libdir='${LIBDIR}' _ACEOF if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. for ac_var in incroot usrlibdir libdir; do eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" done # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl dylib la dll; do if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" && test -f "$ac_im_libdir/libX11.$ac_extension"; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case $ac_im_incroot in /usr/include) ac_x_includes= ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; esac case $ac_im_usrlibdir in /usr/lib | /usr/lib64 | /lib | /lib64) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; esac fi cd .. rm -f -r conftest.dir fi # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include /usr/X11R7/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 /usr/include/X11R7 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include /usr/local/X11R7/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 /usr/local/include/X11R7 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 /usr/include /usr/local/include /usr/unsupported/include /usr/athena/include /usr/local/x11r5/include /usr/lpp/Xamples/include /usr/openwin/include /usr/openwin/share/include' if test "$ac_x_includes" = no; then # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # We can compile using X headers with no special include directory. ac_x_includes= else for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest.err conftest.i conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then # Check for the libraries. # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lX11 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { XrmInitialize () ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else LIBS=$ac_save_LIBS for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl dylib la dll; do if test -r "$ac_dir/libX11.$ac_extension"; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no case $ac_x_includes,$ac_x_libraries in #( no,* | *,no | *\'*) # Didn't find X, or a directory has "'" in its name. ac_cv_have_x="have_x=no";; #( *) # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ ac_x_libraries='$ac_x_libraries'" esac fi ;; #( *) have_x=yes;; esac eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5 $as_echo "$have_x" >&6; } no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes\ ac_x_includes='$x_includes'\ ac_x_libraries='$x_libraries'" { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5 $as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi not_really_there="" if test "$no_x" = ""; then if test "$x_includes" = ""; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else not_really_there="yes" fi rm -f conftest.err conftest.i conftest.$ac_ext else if test ! -r $x_includes/X11/Intrinsic.h; then not_really_there="yes" fi fi fi if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 header files" >&5 $as_echo_n "checking for X11 header files... " >&6; } XINCLUDES="# no special path needed" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else XINCLUDES="" fi rm -f conftest.err conftest.i conftest.$ac_ext if test -z "$XINCLUDES"; then dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" for i in $dirs ; do if test -r $i/X11/Intrinsic.h; then XINCLUDES=" -I$i" break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XINCLUDES" >&5 $as_echo "$XINCLUDES" >&6; } else if test "$x_includes" != ""; then XINCLUDES=-I$x_includes else XINCLUDES="# no special path needed" fi fi if test -z "$XINCLUDES"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: couldn't find any!" >&5 $as_echo "couldn't find any!" >&6; } XINCLUDES="# no include files found" fi if test "$no_x" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 libraries" >&5 $as_echo_n "checking for X11 libraries... " >&6; } XLIBSW= dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/X11R6/lib /usr/lib/X11R6 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" for i in $dirs ; do if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } XLIBSW="-L$i -lX11" break fi done else if test "$x_libraries" = ""; then XLIBSW=-lX11 else XLIBSW="-L$x_libraries -lX11" fi fi if test -z "$XLIBSW" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XCreateWindow in -lXwindow" >&5 $as_echo_n "checking for XCreateWindow in -lXwindow... " >&6; } if ${ac_cv_lib_Xwindow_XCreateWindow+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lXwindow $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 XCreateWindow (); int main () { return XCreateWindow (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Xwindow_XCreateWindow=yes else ac_cv_lib_Xwindow_XCreateWindow=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_Xwindow_XCreateWindow" >&5 $as_echo "$ac_cv_lib_Xwindow_XCreateWindow" >&6; } if test "x$ac_cv_lib_Xwindow_XCreateWindow" = xyes; then : XLIBSW=-lXwindow fi fi if test -z "$XLIBSW" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: couldn't find any! Using -lX11." >&5 $as_echo "couldn't find any! Using -lX11." >&6; } XLIBSW=-lX11 fi # 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 doesn't 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 /usr/lib/ 2>/dev/null` \ `ls -d -r /usr/lib/tcl*/ 2>/dev/null` \ `ls -d /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 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 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 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} "`${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} "`${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/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 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=none for i in $dirs; do if test -r $i/ruby.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5 $as_echo "$i" >&6; } RUBYINCLUDE="-I$i" break fi done if test x"$RUBYARCH" != x""; then RUBYINCLUDE="-I$RUBYDIR -I$RUBYDIR/$RUBYARCH" fi if test "$RUBYINCLUDE" = none; then RUBYINCLUDE="-I$RUBYDIR" { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not locate ruby.h...using $RUBYINCLUDE" >&5 $as_echo "could not locate ruby.h...using $RUBYINCLUDE" >&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; } RUBYINCLUDE="-I$RUBYDIR" RUBYLIB="$RUBYDIR" 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; } RUBYINCLUDE="-I/usr/local/lib/ruby/1.4/arch" RUBYLIB="/usr/local/lib/ruby/1.4/arch" RUBYLINK="-lruby -lm" 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"; 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 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 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 -e 's/^0-9* \(0-9.*\) .*$/\1/' -e 's/.//g'` if 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; } 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 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" 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" ; 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_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 Source/Makefile Examples/Makefile Examples/xml/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/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 Lib/ocaml/swigp4.ml" ac_config_files="$ac_config_files preinst-swig" ac_config_files="$ac_config_files CCache/ccache_swig_config.h" 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 2.0.12, 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 2.0.12 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" ;; "Source/Makefile") CONFIG_FILES="$CONFIG_FILES Source/Makefile" ;; "Examples/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/Makefile" ;; "Examples/xml/Makefile") CONFIG_FILES="$CONFIG_FILES Examples/xml/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/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" ;; "Lib/ocaml/swigp4.ml") CONFIG_FILES="$CONFIG_FILES Lib/ocaml/swigp4.ml" ;; "preinst-swig") CONFIG_FILES="$CONFIG_FILES preinst-swig" ;; "CCache/ccache_swig_config.h") CONFIG_FILES="$CONFIG_FILES CCache/ccache_swig_config.h" ;; *) 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 ;; 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 swig-2.0.12/swig.spec.in0000664000175000017500000000473712275776201014703 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-2.0.12/Examples/0000775000175000017500000000000012275776201014214 5ustar williamwilliamswig-2.0.12/Examples/xml/0000775000175000017500000000000012275776201015014 5ustar williamwilliamswig-2.0.12/Examples/xml/example_p5.i0000664000175000017500000000021712275776201017225 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/xml/example_const.i0000664000175000017500000000113112275776201020023 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-2.0.12/Examples/xml/example_title_add.expected-xml0000664000175000017500000001024412275776201023002 0ustar williamwilliam #include "example.h" Vector addv(Vector &a, Vector &b) { return a+b; } { return a+b; } { return (*self)[index]; } { (*self)[index] = a; } swig-2.0.12/Examples/xml/example.h0000664000175000017500000000022712275776201016621 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-2.0.12/Examples/xml/example_inl.h0000664000175000017500000000011012275776201017452 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-2.0.12/Examples/xml/error.i0000664000175000017500000000005312275776201016315 0ustar williamwilliam%module error enum { RED=10, GREEN, BLUE };swig-2.0.12/Examples/xml/gnarly.expected-xml0000664000175000017500000001730312275776201020635 0ustar williamwilliam { } { WHATEVER MAKES YOU HAPPY AS RESULT } { WHATEVER MAKES YOU HAPPY AS PARAMETER } swig-2.0.12/Examples/xml/example_inl.expected-xml0000664000175000017500000000636512275776201021644 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-2.0.12/Examples/xml/example.i0000664000175000017500000000011312275776201016614 0ustar williamwilliam/* File : example.i */ %module example %apply int *OUTPUT { int *r }; swig-2.0.12/Examples/xml/example_gif.expected-xml0000664000175000017500000026313712275776201021631 0ustar williamwilliam swig-2.0.12/Examples/xml/example_ro.i0000664000175000017500000000011712275776201017320 0ustar williamwilliam/* File : example.i */ %readonly extern int status; extern char path[256]; swig-2.0.12/Examples/xml/example_xml.h0000664000175000017500000000111312275776201017474 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-2.0.12/Examples/xml/example_title_add.i0000664000175000017500000000136112275776201020633 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-2.0.12/Examples/xml/example_p5.expected-xml0000664000175000017500000000141412275776201021374 0ustar williamwilliam #include "example.h" swig-2.0.12/Examples/xml/example_apply.expected-xml0000664000175000017500000015005712275776201022205 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-2.0.12/Examples/xml/example_apply.i0000664000175000017500000000074712275776201020036 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-2.0.12/Examples/xml/example_inl.i0000664000175000017500000000122512275776201017463 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-2.0.12/Examples/xml/example_ro.expected-xml0000664000175000017500000000153112275776201021470 0ustar williamwilliam swig-2.0.12/Examples/xml/example_const.expected-xml0000664000175000017500000000372212275776201022202 0ustar williamwilliam swig-2.0.12/Examples/xml/gnarly.i0000664000175000017500000000202212275776201016456 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-2.0.12/Examples/xml/Makefile.in0000664000175000017500000000207412275776201017064 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-2.0.12/Examples/xml/example.expected-xml0000664000175000017500000000146612275776201020777 0ustar williamwilliam swig-2.0.12/Examples/xml/error.expected-xml0000664000175000017500000000150512275776201020467 0ustar williamwilliam swig-2.0.12/Examples/xml/example_xml.expected-xml0000664000175000017500000016242112275776201021656 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-2.0.12/Examples/xml/example_xml.i0000664000175000017500000000214312275776201017501 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-2.0.12/Examples/r/0000775000175000017500000000000012275776201014455 5ustar williamwilliamswig-2.0.12/Examples/r/class/0000775000175000017500000000000012275776201015562 5ustar williamwilliamswig-2.0.12/Examples/r/class/example.h0000664000175000017500000000114312275776201017365 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-2.0.12/Examples/r/class/example.i0000664000175000017500000000014212275776201017364 0ustar williamwilliam/* File : example.i */ %module example %inline %{ #include "example.h" %} %include "example.h" swig-2.0.12/Examples/r/class/example.cxx0000664000175000017500000000066612275776201017751 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/r/class/runme.R0000664000175000017500000000202212275776201017027 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-2.0.12/Examples/r/class/example.dsp0000664000175000017500000001211312275776201017723 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-2.0.12/Examples/r/class/Makefile0000664000175000017500000000055612275776201017230 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile r_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean swig-2.0.12/Examples/r/simple/0000775000175000017500000000000012275776201015746 5ustar williamwilliamswig-2.0.12/Examples/r/simple/example.c0000664000175000017500000000036712275776201017553 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-2.0.12/Examples/r/simple/example.i0000664000175000017500000000015212275776201017551 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/r/simple/runme.R0000664000175000017500000000055412275776201017223 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-2.0.12/Examples/r/simple/example.dsp0000664000175000017500000001172312275776201020115 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-2.0.12/Examples/r/simple/Makefile0000664000175000017500000000054212275776201017407 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile r_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean swig-2.0.12/Examples/r/check.list0000664000175000017500000000005112275776201016423 0ustar williamwilliam# see top-level Makefile.in class simple swig-2.0.12/Examples/pike/0000775000175000017500000000000012275776201015144 5ustar williamwilliamswig-2.0.12/Examples/pike/template/0000775000175000017500000000000012275776201016757 5ustar williamwilliamswig-2.0.12/Examples/pike/template/example.h0000664000175000017500000000077712275776201020576 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-2.0.12/Examples/pike/template/example.i0000664000175000017500000000051412275776201020564 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-2.0.12/Examples/pike/template/runme.pike0000775000175000017500000000134612275776201020766 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-2.0.12/Examples/pike/template/Makefile0000664000175000017500000000104112275776201020413 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile pike_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile pike_clean swig-2.0.12/Examples/pike/class/0000775000175000017500000000000012275776201016251 5ustar williamwilliamswig-2.0.12/Examples/pike/class/example.h0000664000175000017500000000110612275776201020053 0ustar williamwilliam/* File : example.h */ class Shape { public: Shape(); virtual ~Shape(); double x, y; void move(double dx, double dy); virtual double area() const = 0; virtual double perimeter() const = 0; static int nshapes; }; class Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area() const; virtual double perimeter() const; }; class Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area() const; virtual double perimeter() const; }; swig-2.0.12/Examples/pike/class/example.i0000664000175000017500000000021612275776201020055 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/pike/class/example.cxx0000664000175000017500000000122312275776201020426 0ustar williamwilliam/* File : example.c */ #include "example.h" #include #define M_PI 3.14159265358979323846 // Static member initializer int Shape::nshapes = 0; // Constructor Shape::Shape() { nshapes++; } // Move the shape to a new location void Shape::move(double dx, double dy) { x += dx; y += dy; } // Destructor Shape::~Shape() { nshapes--; } // Circle area double Circle::area() const { return M_PI*radius*radius; } // Circle perimeter double Circle::perimeter() const { return 2*M_PI*radius; } // Square area double Square::area() const { return width*width; } // Square perimeter double Square::perimeter() const { return 4*width; } swig-2.0.12/Examples/pike/class/runme.pike0000775000175000017500000000250612275776201020257 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-2.0.12/Examples/pike/class/Makefile0000664000175000017500000000076412275776201017720 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile pike_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile pike_clean swig-2.0.12/Examples/pike/enum/0000775000175000017500000000000012275776201016110 5ustar williamwilliamswig-2.0.12/Examples/pike/enum/README0000664000175000017500000000056112275776201016772 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-2.0.12/Examples/pike/enum/example.h0000664000175000017500000000031512275776201017713 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-2.0.12/Examples/pike/enum/example.i0000664000175000017500000000021712275776201017715 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/pike/enum/example.cxx0000664000175000017500000000150712275776201020272 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-2.0.12/Examples/pike/enum/runme.pike0000664000175000017500000000165612275776201020120 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-2.0.12/Examples/pike/enum/Makefile0000664000175000017500000000076412275776201017557 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile pike_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile pike_clean swig-2.0.12/Examples/pike/simple/0000775000175000017500000000000012275776201016435 5ustar williamwilliamswig-2.0.12/Examples/pike/simple/example.c0000664000175000017500000000036712275776201020242 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-2.0.12/Examples/pike/simple/example.i0000664000175000017500000000015212275776201020240 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/pike/simple/runme.pike0000664000175000017500000000071512275776201020440 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-2.0.12/Examples/pike/simple/Makefile0000664000175000017500000000071512275776201020100 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile pike_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static clean: $(MAKE) -f $(TOP)/Makefile pike_clean swig-2.0.12/Examples/pike/constants/0000775000175000017500000000000012275776201017160 5ustar williamwilliamswig-2.0.12/Examples/pike/constants/example.i0000664000175000017500000000113512275776201020765 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-2.0.12/Examples/pike/constants/runme.pike0000775000175000017500000000156612275776201021173 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-2.0.12/Examples/pike/constants/Makefile0000664000175000017500000000070412275776201020621 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile pike_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static clean: $(MAKE) -f $(TOP)/Makefile pike_clean swig-2.0.12/Examples/pike/overload/0000775000175000017500000000000012275776201016757 5ustar williamwilliamswig-2.0.12/Examples/pike/overload/example.h0000664000175000017500000000132512275776201020564 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-2.0.12/Examples/pike/overload/example.i0000664000175000017500000000120612275776201020563 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-2.0.12/Examples/pike/overload/example.cxx0000664000175000017500000000571712275776201021150 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-2.0.12/Examples/pike/overload/runme.pike0000664000175000017500000000314512275776201020762 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-2.0.12/Examples/pike/overload/Makefile0000664000175000017500000000077512275776201020430 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lstdc++ -lm check: build $(MAKE) -f $(TOP)/Makefile pike_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: $(MAKE) -f $(TOP)/Makefile pike_clean swig-2.0.12/Examples/pike/check.list0000664000175000017500000000011212275776201017110 0ustar williamwilliam# see top-level Makefile.in class constants enum overload simple template swig-2.0.12/Examples/test-suite/0000775000175000017500000000000012275776201016322 5ustar williamwilliamswig-2.0.12/Examples/test-suite/li_std_wstring.i0000664000175000017500000000277312275776201021540 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-2.0.12/Examples/test-suite/smart_pointer_template_const_overload.i0000664000175000017500000000200612275776201026354 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-2.0.12/Examples/test-suite/anonymous_bitfield.i0000664000175000017500000000035012275776201022364 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-2.0.12/Examples/test-suite/redefined_not.i0000664000175000017500000000036112275776201021301 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-2.0.12/Examples/test-suite/director_stl.i0000664000175000017500000000351412275776201021174 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-2.0.12/Examples/test-suite/evil_diamond_ns.i0000664000175000017500000000133612275776201021631 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-2.0.12/Examples/test-suite/funcptr_cpp.i0000664000175000017500000000245212275776201021022 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-2.0.12/Examples/test-suite/cpp_basic.i0000664000175000017500000000337412275776201020426 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); }; %} %{ 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-2.0.12/Examples/test-suite/director_overload.i0000664000175000017500000000176212275776201022210 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-2.0.12/Examples/test-suite/preproc_line_file.i0000664000175000017500000000344712275776201022164 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-2.0.12/Examples/test-suite/clientdata_prop_a.i0000664000175000017500000000045412275776201022147 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-2.0.12/Examples/test-suite/dynamic_cast.i0000664000175000017500000000313312275776201021132 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-2.0.12/Examples/test-suite/r/0000775000175000017500000000000012275776201016563 5ustar williamwilliamswig-2.0.12/Examples/test-suite/r/rename_simple_runme.R0000664000175000017500000000110612275776201022732 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-2.0.12/Examples/test-suite/r/arrays_dimensionless_runme.R0000664000175000017500000000074612275776201024360 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-2.0.12/Examples/test-suite/r/integers_runme.R0000664000175000017500000000101512275776201021731 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-2.0.12/Examples/test-suite/r/ignore_parameter_runme.R0000664000175000017500000000027012275776201023436 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-2.0.12/Examples/test-suite/r/unions_runme.R0000664000175000017500000000025612275776201021432 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-2.0.12/Examples/test-suite/r/r_double_delete_runme.R0000664000175000017500000000026212275776201023231 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-2.0.12/Examples/test-suite/r/unittest.R0000664000175000017500000000037712275776201020574 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-2.0.12/Examples/test-suite/r/funcptr_runme.R0000664000175000017500000000033012275776201021571 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-2.0.12/Examples/test-suite/r/r_copy_struct_runme.R0000664000175000017500000000154012275776201023013 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-2.0.12/Examples/test-suite/r/r_sexp_runme.R0000664000175000017500000000023212275776201021411 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-2.0.12/Examples/test-suite/r/overload_method_runme.R0000664000175000017500000000042312275776201023266 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-2.0.12/Examples/test-suite/r/simple_array_runme.R0000664000175000017500000000023112275776201022577 0ustar williamwilliamsource("unittest.R") dyn.load(paste("simple_array", .Platform$dynlib.ext, sep="")) source("simple_array.R") cacheMetaData(1) initArray() q(save="no") swig-2.0.12/Examples/test-suite/r/Makefile.in0000664000175000017500000000373312275776201020636 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ else \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \ fi run_multitestcase = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \ else \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \ fi; \ done # Clean clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile 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-2.0.12/Examples/test-suite/r/r_legacy_runme.R0000664000175000017500000000113112275776201021675 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-2.0.12/Examples/test-suite/li_std_pair_using.i0000664000175000017500000000056412275776201022177 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-2.0.12/Examples/test-suite/smart_pointer_const.i0000664000175000017500000000032212275776201022565 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-2.0.12/Examples/test-suite/voidtest.i0000664000175000017500000000051212275776201020333 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-2.0.12/Examples/test-suite/smart_pointer_const2.i0000664000175000017500000000036512275776201022656 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-2.0.12/Examples/test-suite/enum_forward.i0000664000175000017500000000137112275776201021166 0ustar williamwilliam%module enum_forward /* This contains C code that is not valid C++03 and Octave wrappers are always compiled as C++ */ #if !defined(SWIGOCTAVE) %{ 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-2.0.12/Examples/test-suite/director_frob.i0000664000175000017500000000415112275776201021320 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-2.0.12/Examples/test-suite/csharp_features.i0000664000175000017500000000102412275776201021647 0ustar williamwilliam%module csharp_features // 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; }; %} swig-2.0.12/Examples/test-suite/pike/0000775000175000017500000000000012275776201017252 5ustar williamwilliamswig-2.0.12/Examples/test-suite/pike/Makefile.in0000664000175000017500000000220512275776201021316 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: remove the generated .pike file %.clean: @rm -f $*.pike; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile pike_clean swig-2.0.12/Examples/test-suite/varargs_overload.i0000664000175000017500000000175012275776201022037 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-2.0.12/Examples/test-suite/using_extend.i0000664000175000017500000000177012275776201021175 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-2.0.12/Examples/test-suite/swig_examples_lock.h0000664000175000017500000000255312275776201022357 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-2.0.12/Examples/test-suite/samename.i0000664000175000017500000000035512275776201020265 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-2.0.12/Examples/test-suite/director_primitives.i0000664000175000017500000001064312275776201022566 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-2.0.12/Examples/test-suite/extern_c.i0000664000175000017500000000037112275776201020304 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-2.0.12/Examples/test-suite/ruby_naming.i0000664000175000017500000000303512275776201021007 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-2.0.12/Examples/test-suite/types_directive.i0000664000175000017500000000233112275776201021675 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-2.0.12/Examples/test-suite/refcount.h0000664000175000017500000000557312275776201020332 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-2.0.12/Examples/test-suite/name_cxx.i0000664000175000017500000000065212275776201020301 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-2.0.12/Examples/test-suite/preproc.i0000664000175000017500000001620012275776201020145 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-2.0.12/Examples/test-suite/d/0000775000175000017500000000000012275776201016545 5ustar williamwilliamswig-2.0.12/Examples/test-suite/d/nspace_extend_runme.2.d0000664000175000017500000000150612275776201023102 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-2.0.12/Examples/test-suite/d/typemap_namespace_runme.2.d0000664000175000017500000000034012275776201023750 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-2.0.12/Examples/test-suite/d/varargs_runme.2.d0000664000175000017500000000045412275776201021730 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-2.0.12/Examples/test-suite/d/director_basic_runme.2.d0000664000175000017500000000236012275776201023235 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-2.0.12/Examples/test-suite/d/constover_runme.2.d0000664000175000017500000000110012275776201022272 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-2.0.12/Examples/test-suite/d/typemap_namespace_runme.1.d0000664000175000017500000000037712275776201023761 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-2.0.12/Examples/test-suite/d/virtual_poly_runme.1.d0000664000175000017500000000113412275776201023007 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-2.0.12/Examples/test-suite/d/nspace_runme.1.d0000664000175000017500000000544612275776201021541 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-2.0.12/Examples/test-suite/d/li_std_string_runme.2.d0000664000175000017500000000555412275776201023135 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-2.0.12/Examples/test-suite/d/catches_runme.1.d0000664000175000017500000000176512275776201021702 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-2.0.12/Examples/test-suite/d/director_string_runme.2.d0000664000175000017500000000170412275776201023463 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-2.0.12/Examples/test-suite/d/README0000664000175000017500000000035212275776201017425 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-2.0.12/Examples/test-suite/d/overload_complicated_runme.1.d0000664000175000017500000000226712275776201024445 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-2.0.12/Examples/test-suite/d/li_std_except_runme.1.d0000664000175000017500000000216412275776201023110 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-2.0.12/Examples/test-suite/d/aggregate_runme.1.d0000664000175000017500000000117212275776201022206 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-2.0.12/Examples/test-suite/d/preproc_constants_c_runme.2.d0000664000175000017500000000575412275776201024343 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-2.0.12/Examples/test-suite/d/special_variable_macros_runme.1.d0000664000175000017500000000200312275776201025103 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-2.0.12/Examples/test-suite/d/director_ignore_runme.1.d0000664000175000017500000000256012275776201023440 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-2.0.12/Examples/test-suite/d/overload_complicated_runme.2.d0000664000175000017500000000203212275776201024434 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-2.0.12/Examples/test-suite/d/sneaky1_runme.1.d0000664000175000017500000000057012275776201021634 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-2.0.12/Examples/test-suite/d/director_string_runme.1.d0000664000175000017500000000177712275776201023474 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-2.0.12/Examples/test-suite/d/director_primitives_runme.1.d0000664000175000017500000000752612275776201024357 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-2.0.12/Examples/test-suite/d/allprotected_runme.1.d0000664000175000017500000000310112275776201022734 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-2.0.12/Examples/test-suite/d/sizet_runme.1.d0000664000175000017500000000032012275776201021410 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-2.0.12/Examples/test-suite/d/director_primitives_runme.2.d0000664000175000017500000000717012275776201024353 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-2.0.12/Examples/test-suite/d/default_constructor_runme.1.d0000664000175000017500000000123112275776201024345 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-2.0.12/Examples/test-suite/d/director_protected_runme.2.d0000664000175000017500000000170312275776201024145 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-2.0.12/Examples/test-suite/d/constover_runme.1.d0000664000175000017500000000134312275776201022302 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-2.0.12/Examples/test-suite/d/typemap_out_optimal_runme.2.d0000664000175000017500000000020212275776201024345 0ustar williamwilliammodule typemap_out_optimal_runme; import typemap_out_optimal.XX; void main() { XX x; XX.trace = false; x = XX.create(); } swig-2.0.12/Examples/test-suite/d/allprotected_runme.2.d0000664000175000017500000000302312275776201022740 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-2.0.12/Examples/test-suite/d/member_pointer_runme.2.d0000664000175000017500000000217312275776201023272 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-2.0.12/Examples/test-suite/d/sizet_runme.2.d0000664000175000017500000000031412275776201021414 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-2.0.12/Examples/test-suite/d/default_args_runme.1.d0000664000175000017500000000727612275776201022733 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-2.0.12/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d0000664000175000017500000000075412275776201025333 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-2.0.12/Examples/test-suite/d/overload_template_runme.1.d0000664000175000017500000000740212275776201023770 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-2.0.12/Examples/test-suite/d/pointer_reference_runme.1.d0000664000175000017500000000050612275776201023756 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-2.0.12/Examples/test-suite/d/enum_thorough_runme.1.d0000664000175000017500000007657712275776201023170 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-2.0.12/Examples/test-suite/d/li_typemaps_runme.2.d0000664000175000017500000000373412275776201022615 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-2.0.12/Examples/test-suite/d/threads_runme.1.d0000664000175000017500000000340512275776201021713 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-2.0.12/Examples/test-suite/d/typemap_out_optimal_runme.1.d0000664000175000017500000000020212275776201024344 0ustar williamwilliammodule typemap_out_optimal_runme; import typemap_out_optimal.XX; void main() { XX x; XX.trace = false; x = XX.create(); } swig-2.0.12/Examples/test-suite/d/director_ignore_runme.2.d0000664000175000017500000000272612275776201023445 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-2.0.12/Examples/test-suite/d/threads_runme.2.d0000664000175000017500000000254012275776201021713 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-2.0.12/Examples/test-suite/d/li_std_string_runme.1.d0000664000175000017500000000605112275776201023125 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-2.0.12/Examples/test-suite/d/default_constructor_runme.2.d0000664000175000017500000000123312275776201024350 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-2.0.12/Examples/test-suite/d/apply_strings_runme.2.d0000664000175000017500000000072612275776201023163 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-2.0.12/Examples/test-suite/d/member_pointer_runme.1.d0000664000175000017500000000224512275776201023271 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-2.0.12/Examples/test-suite/d/default_args_runme.2.d0000664000175000017500000000621712275776201022726 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-2.0.12/Examples/test-suite/d/li_attribute_runme.2.d0000664000175000017500000000302712275776201022751 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-2.0.12/Examples/test-suite/d/director_classes_runme.1.d0000664000175000017500000001336212275776201023614 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-2.0.12/Examples/test-suite/d/director_alternating_runme.2.d0000664000175000017500000000022312275776201024460 0ustar williamwilliammodule director_alternating_runme; import director_alternating.director_alternating; void main() { assert(getBar().id() == idFromGetBar()); } swig-2.0.12/Examples/test-suite/d/aggregate_runme.2.d0000664000175000017500000000117212275776201022207 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-2.0.12/Examples/test-suite/d/operator_overload_runme.2.d0000664000175000017500000000351012275776201024005 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)); // Unfortunaly, 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-2.0.12/Examples/test-suite/d/director_classic_runme.2.d0000664000175000017500000001077712275776201023610 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-2.0.12/Examples/test-suite/d/enum_thorough_runme.2.d0000664000175000017500000006521712275776201023156 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-2.0.12/Examples/test-suite/d/nspace_extend_runme.1.d0000664000175000017500000000150612275776201023101 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-2.0.12/Examples/test-suite/d/li_std_vector_runme.1.d0000664000175000017500000001225612275776201023125 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-2.0.12/Examples/test-suite/d/throw_exception_runme.1.d0000664000175000017500000000106412275776201023501 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-2.0.12/Examples/test-suite/d/long_long_runme.2.d0000664000175000017500000000153112275776201022236 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-2.0.12/Examples/test-suite/d/li_std_vector_runme.2.d0000664000175000017500000001237212275776201023125 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-2.0.12/Examples/test-suite/d/li_boost_shared_ptr_runme.1.d0000664000175000017500000004143612275776201024314 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-2.0.12/Examples/test-suite/d/sneaky1_runme.2.d0000664000175000017500000000044312275776201021634 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-2.0.12/Examples/test-suite/d/director_alternating_runme.1.d0000664000175000017500000000022312275776201024457 0ustar williamwilliammodule director_alternating_runme; import director_alternating.director_alternating; void main() { assert(getBar().id() == idFromGetBar()); } swig-2.0.12/Examples/test-suite/d/nspace_runme.2.d0000664000175000017500000000516212275776201021535 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-2.0.12/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d0000664000175000017500000000074712275776201025336 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-2.0.12/Examples/test-suite/d/li_attribute_runme.1.d0000664000175000017500000000401312275776201022744 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-2.0.12/Examples/test-suite/d/throw_exception_runme.2.d0000664000175000017500000000106412275776201023502 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-2.0.12/Examples/test-suite/d/varargs_runme.1.d0000664000175000017500000000054612275776201021731 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-2.0.12/Examples/test-suite/d/preproc_constants_runme.1.d0000664000175000017500000000564612275776201024040 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-2.0.12/Examples/test-suite/d/director_classes_runme.2.d0000664000175000017500000001275012275776201023615 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-2.0.12/Examples/test-suite/d/bools_runme.2.d0000664000175000017500000000056112275776201021400 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-2.0.12/Examples/test-suite/d/preproc_constants_runme.2.d0000664000175000017500000000564512275776201024040 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-2.0.12/Examples/test-suite/d/long_long_runme.1.d0000664000175000017500000000166212275776201022242 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-2.0.12/Examples/test-suite/d/d_nativepointers_runme.2.d0000664000175000017500000000166012275776201023640 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-2.0.12/Examples/test-suite/d/d_nativepointers_runme.1.d0000664000175000017500000000166012275776201023637 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-2.0.12/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d0000664000175000017500000004101212275776201024303 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-2.0.12/Examples/test-suite/d/pointer_reference_runme.2.d0000664000175000017500000000047112275776201023760 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-2.0.12/Examples/test-suite/d/apply_strings_runme.1.d0000664000175000017500000000072712275776201023163 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-2.0.12/Examples/test-suite/d/char_strings_runme.2.d0000664000175000017500000001034212275776201022746 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-2.0.12/Examples/test-suite/d/Makefile.in0000664000175000017500000000416312275776201020616 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 TESTSUFFIX = _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 $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ else \ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ 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 $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \ cd $*$(VERSIONSUFFIX) && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ DFLAGS='-of$*_runme' \ DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) `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-2.0.12/Examples/test-suite/d/director_protected_runme.1.d0000664000175000017500000000212312275776201024141 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-2.0.12/Examples/test-suite/d/preproc_constants_c_runme.1.d0000664000175000017500000000575512275776201024343 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-2.0.12/Examples/test-suite/d/special_variable_macros_runme.2.d0000664000175000017500000000131312275776201025107 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-2.0.12/Examples/test-suite/d/li_typemaps_runme.1.d0000664000175000017500000000425112275776201022607 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-2.0.12/Examples/test-suite/d/inherit_target_language_runme.1.d0000664000175000017500000000156312275776201025137 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-2.0.12/Examples/test-suite/d/overload_template_runme.2.d0000664000175000017500000000571112275776201023772 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-2.0.12/Examples/test-suite/d/director_classic_runme.1.d0000664000175000017500000001113312275776201023572 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-2.0.12/Examples/test-suite/d/li_std_except_runme.2.d0000664000175000017500000000165712275776201023117 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-2.0.12/Examples/test-suite/d/director_basic_runme.1.d0000664000175000017500000000261012275776201023232 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-2.0.12/Examples/test-suite/d/virtual_poly_runme.2.d0000664000175000017500000000104412275776201023010 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-2.0.12/Examples/test-suite/d/catches_runme.2.d0000664000175000017500000000176512275776201021703 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-2.0.12/Examples/test-suite/d/inherit_target_language_runme.2.d0000664000175000017500000000156312275776201025140 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-2.0.12/Examples/test-suite/d/char_strings_runme.1.d0000664000175000017500000001160012275776201022743 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-2.0.12/Examples/test-suite/char_constant.i0000664000175000017500000000057412275776201021330 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-2.0.12/Examples/test-suite/callback.i0000664000175000017500000000202312275776201020225 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-2.0.12/Examples/test-suite/director_basic.i0000664000175000017500000000367212275776201021460 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-2.0.12/Examples/test-suite/li_std_except_as_class.i0000664000175000017500000000133212275776201023171 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-2.0.12/Examples/test-suite/li_cpointer.i0000664000175000017500000000034712275776201021007 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-2.0.12/Examples/test-suite/li_boost_shared_ptr.i0000664000175000017500000003205512275776201022526 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-2.0.12/Examples/test-suite/clientdata_prop.list0000664000175000017500000000004412275776201022365 0ustar williamwilliamclientdata_prop_a clientdata_prop_b swig-2.0.12/Examples/test-suite/li_std_vector_ptr.i0000664000175000017500000000075612275776201022231 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-2.0.12/Examples/test-suite/lextype.i0000664000175000017500000000275412275776201020176 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-2.0.12/Examples/test-suite/director_keywords.i0000664000175000017500000000052412275776201022237 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-2.0.12/Examples/test-suite/README0000664000175000017500000000412512275776201017204 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-2.0.12/Examples/test-suite/rename_simple.i0000664000175000017500000000132012275776201021310 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 { 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-2.0.12/Examples/test-suite/preproc_constants.i0000664000175000017500000000501212275776201022240 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-2.0.12/Examples/test-suite/smart_pointer_protected.i0000664000175000017500000000061312275776201023433 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-2.0.12/Examples/test-suite/python/0000775000175000017500000000000012275776201017643 5ustar williamwilliamswig-2.0.12/Examples/test-suite/python/naturalvar_runme.py0000664000175000017500000000020112275776201023573 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-2.0.12/Examples/test-suite/python/static_const_member_2_runme.py0000664000175000017500000000046212275776201025672 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-2.0.12/Examples/test-suite/python/director_profile_runme.py0000664000175000017500000000102412275776201024753 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-2.0.12/Examples/test-suite/python/special_variable_macros_runme.py0000664000175000017500000000124512275776201026256 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-2.0.12/Examples/test-suite/python/input_runme.py0000664000175000017500000000045512275776201022566 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-2.0.12/Examples/test-suite/python/smart_pointer_rename_runme.py0000664000175000017500000000027712275776201025646 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-2.0.12/Examples/test-suite/python/python_nondynamic_runme.py0000664000175000017500000000116412275776201025165 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-2.0.12/Examples/test-suite/python/minherit_runme.py0000664000175000017500000000434112275776201023244 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-2.0.12/Examples/test-suite/python/primitive_types_runme.py0000664000175000017500000002200012275776201024651 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 != 'ho\0la': 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 = 'holac' if t.var_namet != 'holac': 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-2.0.12/Examples/test-suite/python/typemap_delete_runme.py0000664000175000017500000000013412275776201024422 0ustar williamwilliamimport typemap_delete r = typemap_delete.Rect(123) if r.val != 123: raise RuntimeError swig-2.0.12/Examples/test-suite/python/template_ns_runme.py0000664000175000017500000000041612275776201023737 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-2.0.12/Examples/test-suite/python/varargs_runme.py0000664000175000017500000000140612275776201023071 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-2.0.12/Examples/test-suite/python/template_static_runme.py0000664000175000017500000000006212275776201024603 0ustar williamwilliamfrom template_static import * Foo_bar_double(1) swig-2.0.12/Examples/test-suite/python/li_std_pair_using_runme.py0000664000175000017500000000031712275776201025122 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-2.0.12/Examples/test-suite/python/README0000664000175000017500000000075512275776201020532 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-2.0.12/Examples/test-suite/python/director_thread_runme.py0000664000175000017500000000037112275776201024566 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-2.0.12/Examples/test-suite/python/typedef_inherit_runme.py0000664000175000017500000000073312275776201024610 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-2.0.12/Examples/test-suite/python/compactdefaultargs_runme.py0000664000175000017500000000053412275776201025275 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-2.0.12/Examples/test-suite/python/preproc_defined_runme.py0000664000175000017500000000032312275776201024551 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-2.0.12/Examples/test-suite/python/friends_runme.py0000664000175000017500000000124512275776201023057 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-2.0.12/Examples/test-suite/python/multi_import_runme.py0000664000175000017500000000047512275776201024155 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-2.0.12/Examples/test-suite/python/extend_placement_runme.py0000664000175000017500000000161512275776201024745 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-2.0.12/Examples/test-suite/python/profiletest_runme.py0000664000175000017500000000071012275776201023761 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-2.0.12/Examples/test-suite/python/inctest_runme.py0000664000175000017500000000106312275776201023074 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-2.0.12/Examples/test-suite/python/disown_runme.py0000664000175000017500000000043612275776201022731 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-2.0.12/Examples/test-suite/python/template_typedef_runme.py0000664000175000017500000000170312275776201024757 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-2.0.12/Examples/test-suite/python/overload_simple_runme.py0000664000175000017500000000366112275776201024615 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-2.0.12/Examples/test-suite/python/global_namespace_runme.py0000664000175000017500000000165312275776201024704 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-2.0.12/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py0000664000175000017500000000076112275776201026475 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-2.0.12/Examples/test-suite/python/implicittest_runme.py0000664000175000017500000000521112275776201024134 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-2.0.12/Examples/test-suite/python/using1_runme.py0000664000175000017500000000010012275776201022620 0ustar williamwilliamimport using1 if using1.spam(37) != 37: raise RuntimeError swig-2.0.12/Examples/test-suite/python/abstract_access_runme.py0000664000175000017500000000013112275776201024542 0ustar williamwilliamimport abstract_access d = abstract_access.D() if d.do_x() != 1: raise RuntimeError swig-2.0.12/Examples/test-suite/python/li_std_stream_runme.py0000664000175000017500000000027512275776201024260 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-2.0.12/Examples/test-suite/python/default_constructor_runme.py0000664000175000017500000000305512275776201025517 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-2.0.12/Examples/test-suite/python/kwargs_feature_runme.py0000664000175000017500000000166212275776201024441 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-2.0.12/Examples/test-suite/python/constructor_copy_runme.py0000664000175000017500000000062012275776201025040 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-2.0.12/Examples/test-suite/python/char_binary_runme.py0000664000175000017500000000130512275776201023703 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-2.0.12/Examples/test-suite/python/overload_complicated_runme.py0000664000175000017500000000175012275776201025605 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-2.0.12/Examples/test-suite/python/director_exception_runme.py0000664000175000017500000000316112275776201025315 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-2.0.12/Examples/test-suite/python/li_std_vector_runme.py0000664000175000017500000000012112275776201024255 0ustar williamwilliamfrom li_std_vector import * if typedef_test(101) != 101: raise RuntimeError swig-2.0.12/Examples/test-suite/python/virtual_poly_runme.py0000664000175000017500000000114312275776201024153 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-2.0.12/Examples/test-suite/python/template_typedef_cplx_runme.py0000664000175000017500000000306612275776201026011 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-2.0.12/Examples/test-suite/python/li_std_set_runme.py0000664000175000017500000000235412275776201023560 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-2.0.12/Examples/test-suite/python/mod_runme.py0000664000175000017500000000011012275776201022172 0ustar williamwilliamimport mod_a import mod_b c = mod_b.C() d = mod_b.D() d.DoSomething(c) swig-2.0.12/Examples/test-suite/python/python_richcompare_runme.py0000664000175000017500000000565212275776201025330 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-2.0.12/Examples/test-suite/python/li_std_containers_int_runme.py0000664000175000017500000002071112275776201026001 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-2.0.12/Examples/test-suite/python/director_frob_runme.py0000664000175000017500000000017212275776201024246 0ustar williamwilliamfrom director_frob import * foo = Bravo(); s = foo.abs_method(); if s != "Bravo::abs_method()": raise RuntimeError, s swig-2.0.12/Examples/test-suite/python/li_implicit_runme.py0000664000175000017500000000045012275776201023720 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-2.0.12/Examples/test-suite/python/typedef_scope_runme.py0000664000175000017500000000026012275776201024252 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-2.0.12/Examples/test-suite/python/cpp_namespace_runme.py0000664000175000017500000000223312275776201024221 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-2.0.12/Examples/test-suite/python/overload_extendc_runme.py0000664000175000017500000000071712275776201024755 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-2.0.12/Examples/test-suite/python/default_args_runme.py0000664000175000017500000000203612275776201024064 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-2.0.12/Examples/test-suite/python/overload_subtype_runme.py0000664000175000017500000000022512275776201025010 0ustar williamwilliamfrom overload_subtype import * f = Foo() b = Bar() if spam(f) != 1: raise RuntimeError, "foo" if spam(b) != 2: raise RuntimeError, "bar" swig-2.0.12/Examples/test-suite/python/li_cmalloc_runme.py0000664000175000017500000000024212275776201023517 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-2.0.12/Examples/test-suite/python/template_extend2_runme.py0000664000175000017500000000026712275776201024674 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-2.0.12/Examples/test-suite/python/iadd_runme.py0000664000175000017500000000014212275776201022321 0ustar williamwilliamimport iadd f = iadd.Foo() f.AsA.x = 3 f.AsA += f.AsA if f.AsA.x != 6: raise RuntimeError swig-2.0.12/Examples/test-suite/python/memberin_extend_c_runme.py0000664000175000017500000000021712275776201025072 0ustar williamwilliamimport memberin_extend_c t = memberin_extend_c.Person() t.name = "Fred Bloggs" if t.name != "FRED BLOGGS": raise RuntimeError("name wrong") swig-2.0.12/Examples/test-suite/python/li_std_map_runme.py0000664000175000017500000000117712275776201023544 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-2.0.12/Examples/test-suite/python/director_basic_runme.py0000664000175000017500000000263112275776201024401 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-2.0.12/Examples/test-suite/python/constover_runme.py0000664000175000017500000000124412275776201023446 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-2.0.12/Examples/test-suite/python/director_extend_runme.py0000664000175000017500000000107712275776201024612 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-2.0.12/Examples/test-suite/python/abstract_typedef2_runme.py0000664000175000017500000000006412275776201025030 0ustar williamwilliamfrom abstract_typedef2 import * a = A_UF() swig-2.0.12/Examples/test-suite/python/director_enum_runme.py0000664000175000017500000000033512275776201024263 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-2.0.12/Examples/test-suite/python/overload_template_fast_runme.py0000664000175000017500000000670112275776201026152 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-2.0.12/Examples/test-suite/python/class_scope_weird_runme.py0000664000175000017500000000017412275776201025115 0ustar williamwilliamimport class_scope_weird f = class_scope_weird.Foo() g = class_scope_weird.Foo(3) if f.bar(3) != 3: raise RuntimeError swig-2.0.12/Examples/test-suite/python/abstract_typedef_runme.py0000664000175000017500000000014612275776201024747 0ustar williamwilliamfrom abstract_typedef import * e = Engine() a = A() if a.write(e) != 1: raise RuntimeError swig-2.0.12/Examples/test-suite/python/return_const_value_runme.py0000664000175000017500000000046012275776201025344 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-2.0.12/Examples/test-suite/python/using_composition_runme.py0000664000175000017500000000127112275776201025174 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-2.0.12/Examples/test-suite/python/director_nested_runme.py0000664000175000017500000000203412275776201024577 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-2.0.12/Examples/test-suite/python/li_std_vector_extra_runme.py0000664000175000017500000000577712275776201025506 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]= 1 bv[1]= 0 bv[2]= 4 bv[3]= 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-2.0.12/Examples/test-suite/python/using_inherit_runme.py0000664000175000017500000000153312275776201024274 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-2.0.12/Examples/test-suite/python/director_classic_runme.py0000664000175000017500000000630212275776201024740 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-2.0.12/Examples/test-suite/python/extern_c_runme.py0000664000175000017500000000005312275776201023230 0ustar williamwilliamimport extern_c extern_c.RealFunction(2) swig-2.0.12/Examples/test-suite/python/li_boost_shared_ptr_runme.py0000664000175000017500000004360212275776201025455 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-2.0.12/Examples/test-suite/python/rename_pcre_encoder_runme.py0000664000175000017500000000042512275776201025403 0ustar williamwilliamfrom rename_pcre_encoder import * s = SomeWidget() s.putBorderWidth(3) if s.getBorderWidth() != 3: raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),)) s.putSize(4, 5) a = AnotherWidget() a.DoSomething() evt = wxEVTSomeEvent() t = xUnchangedName() swig-2.0.12/Examples/test-suite/python/li_std_vector_ptr_runme.py0000664000175000017500000000017512275776201025153 0ustar williamwilliamfrom li_std_vector_ptr import * ip1 = makeIntPtr(11) ip2 = makeIntPtr(22) vi = IntPtrVector((ip1, ip2)) displayVector(vi) swig-2.0.12/Examples/test-suite/python/struct_rename_runme.py0000664000175000017500000000005612275776201024277 0ustar williamwilliamimport struct_rename b = struct_rename.Bar() swig-2.0.12/Examples/test-suite/python/li_std_carray_runme.py0000664000175000017500000000115012275776201024237 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-2.0.12/Examples/test-suite/python/member_pointer_runme.py0000664000175000017500000000211512275776201024431 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-2.0.12/Examples/test-suite/python/smart_pointer_member_runme.py0000664000175000017500000000044112275776201025637 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-2.0.12/Examples/test-suite/python/director_detect_runme.py0000664000175000017500000000115312275776201024566 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-2.0.12/Examples/test-suite/python/inplaceadd_runme.py0000664000175000017500000000035012275776201023505 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-2.0.12/Examples/test-suite/python/template_type_namespace_runme.py0000664000175000017500000000020112275776201026304 0ustar williamwilliamfrom template_type_namespace import * if type(foo()[0]) != type(""): raise RuntimeError swig-2.0.12/Examples/test-suite/python/director_string_runme.py0000664000175000017500000000070512275776201024626 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-2.0.12/Examples/test-suite/python/li_carrays_runme.py0000664000175000017500000000016612275776201023556 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-2.0.12/Examples/test-suite/python/preproc_include_runme.py0000664000175000017500000000073012275776201024600 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-2.0.12/Examples/test-suite/python/li_std_wstring_runme.py0000664000175000017500000000373512275776201024466 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-2.0.12/Examples/test-suite/python/threads_exception_runme.py0000664000175000017500000000135012275776201025132 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-2.0.12/Examples/test-suite/python/li_attribute_template_runme.py0000664000175000017500000000243412275776201026010 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-2.0.12/Examples/test-suite/python/namespace_class_runme.py0000664000175000017500000000057312275776201024551 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) swig-2.0.12/Examples/test-suite/python/enum_template_runme.py0000664000175000017500000000021512275776201024260 0ustar williamwilliamimport enum_template if enum_template.MakeETest() != 1: raise RuntimeError if enum_template.TakeETest(0) != None: raise RuntimeError swig-2.0.12/Examples/test-suite/python/constructor_rename_runme.py0000664000175000017500000000007312275776201025337 0ustar williamwilliamfrom constructor_rename import * x = RenamedConstructor() swig-2.0.12/Examples/test-suite/python/typemap_arrays_runme.py0000664000175000017500000000013312275776201024460 0ustar williamwilliamfrom typemap_arrays import * if sumA(None) != 60: raise RuntimeError, "Sum is wrong" swig-2.0.12/Examples/test-suite/python/smart_pointer_extend_runme.py0000664000175000017500000000065112275776201025662 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-2.0.12/Examples/test-suite/python/empty_runme.py0000664000175000017500000000001512275776201022555 0ustar williamwilliamimport empty swig-2.0.12/Examples/test-suite/python/li_cstring_runme.py0000664000175000017500000000125512275776201023563 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-2.0.12/Examples/test-suite/python/langobj_runme.py0000664000175000017500000000027112275776201023037 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-2.0.12/Examples/test-suite/python/python_pybuf_runme3.py0000664000175000017500000000175312275776201024242 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-2.0.12/Examples/test-suite/python/unions_runme.py0000664000175000017500000000240712275776201022741 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-2.0.12/Examples/test-suite/python/typename_runme.py0000664000175000017500000000046012275776201023245 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-2.0.12/Examples/test-suite/python/voidtest_runme.py0000664000175000017500000000064312275776201023267 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-2.0.12/Examples/test-suite/python/overload_rename_runme.py0000664000175000017500000000022612275776201024565 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-2.0.12/Examples/test-suite/python/overload_copy_runme.py0000664000175000017500000000006112275776201024265 0ustar williamwilliamfrom overload_copy import * f = Foo() g = Foo(f) swig-2.0.12/Examples/test-suite/python/callback_runme.py0000664000175000017500000000103112275776201023152 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-2.0.12/Examples/test-suite/python/refcount_runme.py0000664000175000017500000000156012275776201023252 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-2.0.12/Examples/test-suite/python/python_overload_simple_cast_runme.py0000664000175000017500000001001312275776201027215 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-2.0.12/Examples/test-suite/python/li_std_wstream_runme.py0000664000175000017500000000031312275776201024440 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-2.0.12/Examples/test-suite/python/preproc_runme.py0000664000175000017500000000032112275776201023071 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-2.0.12/Examples/test-suite/python/swigobject_runme.py0000664000175000017500000000117612275776201023570 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-2.0.12/Examples/test-suite/python/hugemod.pl0000664000175000017500000000237712275776201021641 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-2.0.12/Examples/test-suite/python/typemap_ns_using_runme.py0000664000175000017500000000012412275776201025004 0ustar williamwilliamimport typemap_ns_using if typemap_ns_using.spam(37) != 37: raise RuntimeError swig-2.0.12/Examples/test-suite/python/struct_initialization_runme.py0000664000175000017500000000051712275776201026061 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-2.0.12/Examples/test-suite/python/python_append_runme.py0000664000175000017500000000030612275776201024272 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-2.0.12/Examples/test-suite/python/pointer_reference_runme.py0000664000175000017500000000070512275776201025123 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-2.0.12/Examples/test-suite/python/namespace_typemap_runme.py0000664000175000017500000000244412275776201025122 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-2.0.12/Examples/test-suite/python/complextest_runme.py0000664000175000017500000000046412275776201023776 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-2.0.12/Examples/test-suite/python/enums_runme.py0000664000175000017500000000041212275776201022547 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-2.0.12/Examples/test-suite/python/std_containers_runme.py0000664000175000017500000000375312275776201024452 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 = ((1,0,1),(1,1),(1,1)) 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-2.0.12/Examples/test-suite/python/li_attribute_runme.py0000664000175000017500000000315312275776201024114 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-2.0.12/Examples/test-suite/python/template_typemaps_typedef2_runme.py0000664000175000017500000000206412275776201026764 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-2.0.12/Examples/test-suite/python/director_protected_runme.py0000664000175000017500000000430512275776201025311 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-2.0.12/Examples/test-suite/python/director_abstract_runme.py0000664000175000017500000000227112275776201025123 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-2.0.12/Examples/test-suite/python/smart_pointer_overload_runme.py0000664000175000017500000000051412275776201026204 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-2.0.12/Examples/test-suite/python/default_arg_values_runme.py0000664000175000017500000000035712275776201025264 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-2.0.12/Examples/test-suite/python/li_factory_runme.py0000664000175000017500000000033712275776201023561 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-2.0.12/Examples/test-suite/python/ret_by_value_runme.py0000664000175000017500000000021012275776201024074 0ustar williamwilliamimport ret_by_value a = ret_by_value.get_test() if a.myInt != 100: raise RuntimeError if a.myShort != 200: raise RuntimeError swig-2.0.12/Examples/test-suite/python/funcptr_cpp_runme.py0000664000175000017500000000032312275776201023744 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-2.0.12/Examples/test-suite/python/template_inherit_runme.py0000664000175000017500000000155712275776201024770 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-2.0.12/Examples/test-suite/python/using_protected_runme.py0000664000175000017500000000015412275776201024621 0ustar williamwilliamfrom using_protected import * f = FooBar() f.x = 3 if f.blah(4) != 4: raise RuntimeError, "blah(int)" swig-2.0.12/Examples/test-suite/python/director_wstring_runme.py0000664000175000017500000000065212275776201025016 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-2.0.12/Examples/test-suite/python/fvirtual_runme.py0000664000175000017500000000016712275776201023263 0ustar williamwilliamfrom fvirtual import * sw = NodeSwitch() n = Node() i = sw.addChild(n); if i != 2: raise RuntimeError, "addChild" swig-2.0.12/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py0000664000175000017500000000027512275776201027247 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-2.0.12/Examples/test-suite/python/overload_template_runme.py0000664000175000017500000000667412275776201025146 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-2.0.12/Examples/test-suite/python/struct_value_runme.py0000664000175000017500000000020612275776201024141 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-2.0.12/Examples/test-suite/python/li_std_string_extra_runme.py0000664000175000017500000000734712275776201025505 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-2.0.12/Examples/test-suite/python/typemap_out_optimal_runme.py0000664000175000017500000000011212275776201025510 0ustar williamwilliamfrom typemap_out_optimal import * cvar.XX_debug = False x = XX.create() swig-2.0.12/Examples/test-suite/python/rename_scope_runme.py0000664000175000017500000000024012275776201024057 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-2.0.12/Examples/test-suite/python/overload_numeric_runme.py0000664000175000017500000000242212275776201024760 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-2.0.12/Examples/test-suite/python/template_typedef_cplx3_runme.py0000664000175000017500000000066312275776201026074 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-2.0.12/Examples/test-suite/python/template_typedef_cplx4_runme.py0000664000175000017500000000066312275776201026075 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-2.0.12/Examples/test-suite/python/sneaky1_runme.py0000664000175000017500000000015312275776201022775 0ustar williamwilliamimport sneaky1 x = sneaky1.add(3,4) y = sneaky1.subtract(3,4) z = sneaky1.mul(3,4) w = sneaky1.divide(3,4) swig-2.0.12/Examples/test-suite/python/typemap_namespace_runme.py0000664000175000017500000000021512275776201025114 0ustar williamwilliamfrom typemap_namespace import * if test1("hello") != "hello": raise RuntimeError if test2("hello") != "hello": raise RuntimeError swig-2.0.12/Examples/test-suite/python/inherit_missing_runme.py0000664000175000017500000000061212275776201024615 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-2.0.12/Examples/test-suite/python/li_cdata_runme.py0000664000175000017500000000017412275776201023165 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-2.0.12/Examples/test-suite/python/wrapmacro_runme.py0000664000175000017500000000020012275776201023406 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-2.0.12/Examples/test-suite/python/template_typedef_import_runme.py0000664000175000017500000000071312275776201026351 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-2.0.12/Examples/test-suite/python/extend_variable_runme.py0000664000175000017500000000011012275776201024547 0ustar williamwilliamfrom extend_variable import * if Foo.Bar != 42: raise RuntimeError swig-2.0.12/Examples/test-suite/python/smart_pointer_const_overload_runme.py0000664000175000017500000000405712275776201027420 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-2.0.12/Examples/test-suite/python/typemap_qualifier_strip_runme.py0000664000175000017500000000231012275776201026360 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-2.0.12/Examples/test-suite/python/cpp_enum_runme.py0000664000175000017500000000055212275776201023233 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-2.0.12/Examples/test-suite/python/template_default_arg_runme.py0000664000175000017500000000544212275776201025600 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-2.0.12/Examples/test-suite/python/using_private_runme.py0000664000175000017500000000035712275776201024307 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-2.0.12/Examples/test-suite/python/import_nomodule_runme.py0000664000175000017500000000014112275776201024633 0ustar williamwilliamfrom import_nomodule import * f = create_Foo() test1(f,42) delete_Foo(f) b = Bar() test1(b,37) swig-2.0.12/Examples/test-suite/python/template_ref_type_runme.py0000664000175000017500000000013412275776201025131 0ustar williamwilliamimport template_ref_type xr = template_ref_type.XC() y = template_ref_type.Y() y.find(xr) swig-2.0.12/Examples/test-suite/python/smart_pointer_templatevariables_runme.py0000664000175000017500000000044012275776201030073 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-2.0.12/Examples/test-suite/python/enum_forward_runme.py0000664000175000017500000000035012275776201024111 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-2.0.12/Examples/test-suite/python/primitive_ref_runme.py0000664000175000017500000000117112275776201024267 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(1) != 1: raise RuntimeError if ref_char('x') != 'x': raise RuntimeError if ref_over(0) != 0: raise RuntimeError swig-2.0.12/Examples/test-suite/python/li_std_except_as_class_runme.py0000664000175000017500000000033112275776201026116 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-2.0.12/Examples/test-suite/python/argcargvtest_runme.py0000664000175000017500000000073312275776201024122 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-2.0.12/Examples/test-suite/python/li_cpointer_runme.py0000664000175000017500000000017312275776201023733 0ustar williamwilliamfrom li_cpointer import * p = new_intp() intp_assign(p,3) if intp_value(p) != 3: raise RuntimeError delete_intp(p) swig-2.0.12/Examples/test-suite/python/virtual_derivation_runme.py0000664000175000017500000000022412275776201025333 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-2.0.12/Examples/test-suite/python/smart_pointer_simple_runme.py0000664000175000017500000000026212275776201025662 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-2.0.12/Examples/test-suite/python/typedef_class_runme.py0000664000175000017500000000013712275776201024251 0ustar williamwilliamimport typedef_class a = typedef_class.RealA() a.a = 3 b = typedef_class.B() b.testA(a) swig-2.0.12/Examples/test-suite/python/director_stl_runme.py0000664000175000017500000000072112275776201024120 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-2.0.12/Examples/test-suite/python/template_extend1_runme.py0000664000175000017500000000026712275776201024673 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-2.0.12/Examples/test-suite/python/li_std_pair_extra_runme.py0000664000175000017500000000207512275776201025123 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-2.0.12/Examples/test-suite/python/arrays_global_runme.py0000664000175000017500000000063712275776201024252 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-2.0.12/Examples/test-suite/python/smart_pointer_not_runme.py0000664000175000017500000000073012275776201025171 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-2.0.12/Examples/test-suite/python/pythonswig.supp0000664000175000017500000002344212275776201022774 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-2.0.12/Examples/test-suite/python/li_std_map_member_runme.py0000664000175000017500000000032512275776201025065 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-2.0.12/Examples/test-suite/python/using_extend_runme.py0000664000175000017500000000064512275776201024124 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-2.0.12/Examples/test-suite/python/types_directive_runme.py0000664000175000017500000000053112275776201024624 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-2.0.12/Examples/test-suite/python/template_rename_runme.py0000664000175000017500000000027612275776201024572 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-2.0.12/Examples/test-suite/python/rename_strip_encoder_runme.py0000664000175000017500000000013212275776201025606 0ustar williamwilliamfrom rename_strip_encoder import * s = SomeWidget() a = AnotherWidget() a.DoSomething() swig-2.0.12/Examples/test-suite/python/python_abstractbase_runme3.py0000664000175000017500000000106412275776201025546 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-2.0.12/Examples/test-suite/python/reference_global_vars_runme.py0000664000175000017500000000404412275776201025736 0ustar williamwilliamfrom reference_global_vars import * # const class reference variable if getconstTC().num != 33: raise RuntimeError # primitive reference variables cvar.var_bool = createref_bool(0) if value_bool(cvar.var_bool) != 0: raise RuntimeError cvar.var_bool = createref_bool(1) if value_bool(cvar.var_bool) != 1: 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-2.0.12/Examples/test-suite/python/dynamic_cast_runme.py0000664000175000017500000000025212275776201024060 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-2.0.12/Examples/test-suite/python/li_cwstring_runme.py0000664000175000017500000000120512275776201023745 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-2.0.12/Examples/test-suite/python/Makefile.in0000664000175000017500000001072612275776201021716 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 ifeq (,$(PY3)) SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) else SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX) endif srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ PY2TO3 = 2to3 -x import 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 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) # Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file %$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX) cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 # 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. run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(run_python);\ fi ifeq (,$(PY3)) convert_testcase = else convert_testcase = \ if [ -f $(py2_runme) ]; then \ $(MAKE) -f $(srcdir)/Makefile $(py3_runme); \ fi endif # Clean: remove the generated .py file %.clean: @rm -f $*.py; @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py. @if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile 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-2.0.12/Examples/test-suite/python/director_finalizer_runme.py0000664000175000017500000000105512275776201025302 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-2.0.12/Examples/test-suite/python/grouping_runme.py0000664000175000017500000000033512275776201023256 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-2.0.12/Examples/test-suite/python/cpp_static_runme.py0000664000175000017500000000034412275776201023555 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-2.0.12/Examples/test-suite/python/operbool_runme.py0000664000175000017500000000010212275776201023235 0ustar williamwilliam#!/usr/bin/env python import operbool assert not operbool.Test() swig-2.0.12/Examples/test-suite/python/file_test_runme.py0000664000175000017500000000027212275776201023402 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-2.0.12/Examples/test-suite/python/director_alternating_runme.py0000664000175000017500000000020112275776201025617 0ustar williamwilliamfrom director_alternating import * id = getBar().id() if id != idFromGetBar(): raise RuntimeError, "Got wrong id: " + str(id) swig-2.0.12/Examples/test-suite/python/namespace_virtual_method_runme.py0000664000175000017500000000010512275776201026461 0ustar williamwilliamimport namespace_virtual_method x = namespace_virtual_method.Spam() swig-2.0.12/Examples/test-suite/python/template_construct_runme.py0000664000175000017500000000003212275776201025335 0ustar williamwilliamimport template_construct swig-2.0.12/Examples/test-suite/python/contract_runme.py0000664000175000017500000000427312275776201023246 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-2.0.12/Examples/test-suite/python/import_stl_runme.py0000664000175000017500000000021212275776201023612 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-2.0.12/Examples/test-suite/python/template_tbase_template_runme.py0000664000175000017500000000014612275776201026310 0ustar williamwilliamfrom template_tbase_template import * a = make_Class_dd() if a.test() != "test": raise RuntimeError swig-2.0.12/Examples/test-suite/python/director_unroll_runme.py0000664000175000017500000000034112275776201024627 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-2.0.12/Examples/test-suite/python/using2_runme.py0000664000175000017500000000010012275776201022621 0ustar williamwilliamimport using2 if using2.spam(37) != 37: raise RuntimeError swig-2.0.12/Examples/test-suite/python/template_opaque_runme.py0000664000175000017500000000014112275776201024604 0ustar williamwilliamimport template_opaque v = template_opaque.OpaqueVectorType(10) template_opaque.FillVector(v) swig-2.0.12/Examples/test-suite/python/imports_runme.py0000664000175000017500000000037312275776201023123 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-2.0.12/Examples/test-suite/python/python_varargs_typemap_runme.py0000664000175000017500000000042712275776201026233 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-2.0.12/Examples/test-suite/python/li_std_vector_enum_runme.py0000664000175000017500000000057012275776201025311 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-2.0.12/Examples/test-suite/python/template_matrix_runme.py0000664000175000017500000000017512275776201024625 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-2.0.12/Examples/test-suite/python/extend_template_runme.py0000664000175000017500000000021712275776201024605 0ustar williamwilliamimport extend_template f = extend_template.Foo_0() if f.test1(37) != 37: raise RuntimeError if f.test2(42) != 42: raise RuntimeError swig-2.0.12/Examples/test-suite/python/array_member_runme.py0000664000175000017500000000064012275776201024070 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-2.0.12/Examples/test-suite/python/nested_workaround_runme.py0000664000175000017500000000046112275776201025161 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-2.0.12/Examples/test-suite/python/smart_pointer_multi_runme.py0000664000175000017500000000026512275776201025526 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-2.0.12/Examples/test-suite/python/exception_order_runme.py0000664000175000017500000000122112275776201024610 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-2.0.12/Examples/test-suite/python/extend_template_ns_runme.py0000664000175000017500000000021212275776201025300 0ustar williamwilliamfrom extend_template_ns import * f = Foo_One() if f.test1(37) != 37: raise RuntimeError if f.test2(42) != 42: raise RuntimeError swig-2.0.12/Examples/test-suite/python/abstract_virtual_runme.py0000664000175000017500000000006212275776201024772 0ustar williamwilliamfrom abstract_virtual import * d = D() e = E() swig-2.0.12/Examples/test-suite/python/inout_runme.py0000664000175000017500000000052112275776201022557 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-2.0.12/Examples/test-suite/python/template_typemaps_typedef_runme.py0000664000175000017500000000206312275776201026701 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-2.0.12/Examples/test-suite/python/director_default_runme.py0000664000175000017500000000011512275776201024737 0ustar williamwilliamfrom director_default import * f = Foo() f = Foo(1) f = Bar() f = Bar(1) swig-2.0.12/Examples/test-suite/python/keyword_rename_runme.py0000664000175000017500000000013412275776201024434 0ustar williamwilliam#!/usr/bin/env python import keyword_rename keyword_rename._in(1) keyword_rename._except(1) swig-2.0.12/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py0000664000175000017500000000117312275776201027345 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-2.0.12/Examples/test-suite/python/smart_pointer_typedef_runme.py0000664000175000017500000000026312275776201026032 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-2.0.12/Examples/test-suite/python/class_ignore_runme.py0000664000175000017500000000015712275776201024076 0ustar williamwilliamimport class_ignore a = class_ignore.Bar() if class_ignore.do_blah(a) != "Bar::blah": raise RuntimeError swig-2.0.12/Examples/test-suite/python/overload_extend_runme.py0000664000175000017500000000042112275776201024602 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-2.0.12/Examples/test-suite/python/template_typedef_cplx2_runme.py0000664000175000017500000000322712275776201026072 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-2.0.12/Examples/test-suite/python/autodoc_runme.py0000664000175000017500000001147212275776201023066 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-2.0.12/Examples/test-suite/python/varargs_overload_runme.py0000664000175000017500000000146112275776201024765 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-2.0.12/Examples/test-suite/python/template_ns4_runme.py0000664000175000017500000000013412275776201024020 0ustar williamwilliamfrom template_ns4 import * d = make_Class_DD(); if d.test() != "test": raise RuntimeError swig-2.0.12/Examples/test-suite/python/profiletestc_runme.py0000664000175000017500000000155112275776201024130 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-2.0.12/Examples/test-suite/python/global_ns_arg_runme.py0000664000175000017500000000006612275776201024216 0ustar williamwilliamfrom global_ns_arg import * a = foo(1) b = bar_fn() swig-2.0.12/Examples/test-suite/octave/0000775000175000017500000000000012275776201017603 5ustar williamwilliamswig-2.0.12/Examples/test-suite/octave/struct_rename_runme.m0000664000175000017500000000005112275776201024036 0ustar williamwilliamstruct_rename b = struct_rename.Bar(); swig-2.0.12/Examples/test-suite/octave/minherit_runme.m0000664000175000017500000000405012275776201023005 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-2.0.12/Examples/test-suite/octave/smart_pointer_member_runme.m0000664000175000017500000000050112275776201025400 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-2.0.12/Examples/test-suite/octave/file_test_runme.m0000664000175000017500000000020612275776201023143 0ustar williamwilliamfile_test file_test.nfile("stdout"); cstdout = file_test.GetStdOut(); file_test.nfile(cstdout); file_test.nfile_name("test.dat"); swig-2.0.12/Examples/test-suite/octave/template_typedef_cplx2_runme.m0000664000175000017500000000306412275776201025635 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-2.0.12/Examples/test-suite/octave/primitive_ref_runme.m0000664000175000017500000000105112275776201024030 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-2.0.12/Examples/test-suite/octave/typemap_namespace_runme.m0000664000175000017500000000017712275776201024667 0ustar williamwilliamtypemap_namespace if (!strcmp(test1("hello"),"hello")) error endif if (!strcmp(test2("hello"),"hello")) error endif swig-2.0.12/Examples/test-suite/octave/argcargvtest_runme.m0000664000175000017500000000065712275776201023673 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-2.0.12/Examples/test-suite/octave/overload_extend_runme.m0000664000175000017500000000036512275776201024355 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-2.0.12/Examples/test-suite/octave/class_scope_weird_runme.m0000664000175000017500000000016112275776201024655 0ustar williamwilliamclass_scope_weird f = class_scope_weird.Foo(); g = class_scope_weird.Foo(3); if (f.bar(3) != 3) error endif swig-2.0.12/Examples/test-suite/octave/using2_runme.m0000664000175000017500000000006312275776201022375 0ustar williamwilliamusing2 if (using2.spam(37) != 37) error endif swig-2.0.12/Examples/test-suite/octave/extend_template_runme.m0000664000175000017500000000017512275776201024354 0ustar williamwilliamextend_template f = extend_template.Foo_0(); if (f.test1(37) != 37) error endif if (f.test2(42) != 42) error endif swig-2.0.12/Examples/test-suite/octave/constructor_copy_runme.m0000664000175000017500000000060212275776201024604 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-2.0.12/Examples/test-suite/octave/template_opaque_runme.m0000664000175000017500000000013512275776201024353 0ustar williamwilliamtemplate_opaque v = template_opaque.OpaqueVectorType(10); template_opaque.FillVector(v); swig-2.0.12/Examples/test-suite/octave/template_typedef_cplx_runme.m0000664000175000017500000000270212275776201025551 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-2.0.12/Examples/test-suite/octave/li_attribute_runme.m0000664000175000017500000000265512275776201023666 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-2.0.12/Examples/test-suite/octave/extend_placement_runme.m0000664000175000017500000000165412275776201024514 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-2.0.12/Examples/test-suite/octave/preproc_runme.m0000664000175000017500000000030112275776201022633 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-2.0.12/Examples/test-suite/octave/li_cstring_runme.m0000664000175000017500000000121012275776201023316 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-2.0.12/Examples/test-suite/octave/nondynamic_runme.m0000664000175000017500000000054112275776201023326 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-2.0.12/Examples/test-suite/octave/typedef_class_runme.m0000664000175000017500000000013012275776201024006 0ustar williamwilliamtypedef_class a = typedef_class.RealA(); a.a = 3; b = typedef_class.B(); b.testA(a); swig-2.0.12/Examples/test-suite/octave/extend_variable_runme.m0000664000175000017500000000006512275776201024324 0ustar williamwilliamextend_variable if (Foo.Bar != 42) error endif swig-2.0.12/Examples/test-suite/octave/cpp_enum_runme.m0000664000175000017500000000063312275776201022777 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-2.0.12/Examples/test-suite/octave/li_std_wstring_runme.m0000664000175000017500000000275512275776201024233 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-2.0.12/Examples/test-suite/octave/template_default_arg_runme.m0000664000175000017500000000516012275776201025341 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-2.0.12/Examples/test-suite/octave/return_const_value_runme.m0000664000175000017500000000042412275776201025110 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-2.0.12/Examples/test-suite/octave/member_pointer_runme.m0000664000175000017500000000163212275776201024200 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-2.0.12/Examples/test-suite/octave/imports_runme.m0000664000175000017500000000072012275776201022663 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-2.0.12/Examples/test-suite/octave/template_tbase_template_runme.m0000664000175000017500000000013212275776201026047 0ustar williamwilliamtemplate_tbase_template a = make_Class_dd(); if (!strcmp(a.test(),"test")) error endif swig-2.0.12/Examples/test-suite/octave/overload_complicated_runme.m0000775000175000017500000000164612275776201025360 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-2.0.12/Examples/test-suite/octave/arrays_global_runme.m0000664000175000017500000000064212275776201024012 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-2.0.12/Examples/test-suite/octave/enum_template_runme.m0000664000175000017500000000024112275776201024023 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-2.0.12/Examples/test-suite/octave/compactdefaultargs_runme.m0000664000175000017500000000047212275776201025042 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-2.0.12/Examples/test-suite/octave/typedef_inherit_runme.m0000664000175000017500000000102412275776201024346 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-2.0.12/Examples/test-suite/octave/inctest_runme.m0000664000175000017500000000072612275776201022645 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-2.0.12/Examples/test-suite/octave/template_static_runme.m0000664000175000017500000000004412275776201024347 0ustar williamwilliamtemplate_static Foo_bar_double(1); swig-2.0.12/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m0000664000175000017500000000025212275776201027006 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-2.0.12/Examples/test-suite/octave/template_extend2_runme.m0000664000175000017500000000026212275776201024433 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-2.0.12/Examples/test-suite/octave/swigobject_runme.m0000664000175000017500000000052612275776201023332 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-2.0.12/Examples/test-suite/octave/abstract_typedef2_runme.m0000664000175000017500000000004612275776201024574 0ustar williamwilliamabstract_typedef2 a = A_UF(); swig-2.0.12/Examples/test-suite/octave/wrapmacro_runme.m0000664000175000017500000000017712275776201023167 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-2.0.12/Examples/test-suite/octave/li_std_set_runme.m0000664000175000017500000000200012275776201023310 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-2.0.12/Examples/test-suite/octave/li_std_string_extra_runme.m0000664000175000017500000000661312275776201025244 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-2.0.12/Examples/test-suite/octave/template_typedef_cplx4_runme.m0000664000175000017500000000064712275776201025643 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-2.0.12/Examples/test-suite/octave/li_std_vector_enum_runme.m0000664000175000017500000000057012275776201025055 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-2.0.12/Examples/test-suite/octave/template_typedef_cplx3_runme.m0000664000175000017500000000065012275776201025634 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-2.0.12/Examples/test-suite/octave/varargs_runme.m0000664000175000017500000000060212275776201022632 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-2.0.12/Examples/test-suite/octave/voidtest_runme.m0000664000175000017500000000075112275776201023033 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-2.0.12/Examples/test-suite/octave/smart_pointer_overload_runme.m0000664000175000017500000000043412275776201025751 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-2.0.12/Examples/test-suite/octave/types_directive_runme.m0000664000175000017500000000050412275776201024370 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-2.0.12/Examples/test-suite/octave/virtual_derivation_runme.m0000664000175000017500000000020112275776201025072 0ustar williamwilliamvirtual_derivation # # very innocent example # b = B(3); if (b.get_a() != b.get_b()) error("something is really wrong") endif swig-2.0.12/Examples/test-suite/octave/octave_empty.c0000664000175000017500000000021112275776201022440 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-2.0.12/Examples/test-suite/octave/director_abstract_runme.m0000664000175000017500000000174112275776201024670 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-2.0.12/Examples/test-suite/octave/struct_value_runme.m0000664000175000017500000000017212275776201023707 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-2.0.12/Examples/test-suite/octave/li_cwstring_runme.m0000664000175000017500000000115012275776201023510 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-2.0.12/Examples/test-suite/octave/director_frob_runme.m0000664000175000017500000000015512275776201024013 0ustar williamwilliamdirector_frob foo = Bravo(); s = foo.abs_method(); if (!strcmp(s,"Bravo::abs_method()")) error(s) endif swig-2.0.12/Examples/test-suite/octave/smart_pointer_typedef_runme.m0000664000175000017500000000023612275776201025576 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-2.0.12/Examples/test-suite/octave/typename_runme.m0000664000175000017500000000033112275776201023006 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-2.0.12/Examples/test-suite/octave/template_typedef_import_runme.m0000664000175000017500000000067512275776201026124 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-2.0.12/Examples/test-suite/octave/multi_import_runme.m0000664000175000017500000000043412275776201023714 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-2.0.12/Examples/test-suite/octave/grouping_runme.m0000664000175000017500000000027412275776201023024 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-2.0.12/Examples/test-suite/octave/director_enum_runme.m0000664000175000017500000000031312275776201024023 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-2.0.12/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m0000664000175000017500000000035212275776201027641 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-2.0.12/Examples/test-suite/octave/director_detect_runme.m0000664000175000017500000000122312275776201024330 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-2.0.12/Examples/test-suite/octave/null_pointer_runme.m0000664000175000017500000000004112275776201023674 0ustar williamwilliamnull_pointer; assert(func([])); swig-2.0.12/Examples/test-suite/octave/li_factory_runme.m0000664000175000017500000000030112275776201023314 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-2.0.12/Examples/test-suite/octave/default_constructor_runme.m0000664000175000017500000000255612275776201025270 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-2.0.12/Examples/test-suite/octave/li_cmalloc_runme.m0000664000175000017500000000024012275776201023261 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-2.0.12/Examples/test-suite/octave/sneaky1_runme.m0000664000175000017500000000015012275776201022536 0ustar williamwilliamsneaky1 x = sneaky1.add(3,4); y = sneaky1.subtract(3,4); z = sneaky1.mul(3,4); w = sneaky1.divide(3,4); swig-2.0.12/Examples/test-suite/octave/refcount_runme.m0000664000175000017500000000023112275776201023010 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-2.0.12/Examples/test-suite/octave/smart_pointer_rename_runme.m0000664000175000017500000000024212275776201025402 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-2.0.12/Examples/test-suite/octave/director_basic_runme.m0000664000175000017500000000330612275776201024145 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-2.0.12/Examples/test-suite/octave/naturalvar_runme.m0000664000175000017500000000016312275776201023346 0ustar williamwilliamnaturalvar f = Foo(); b = Bar(); b.f = f; cvar.s = "hello"; b.s = "hello"; if (b.s != cvar.s) error endif swig-2.0.12/Examples/test-suite/octave/director_wstring_runme.m0000664000175000017500000000052612275776201024562 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-2.0.12/Examples/test-suite/octave/std_containers_runme.m0000664000175000017500000000365712275776201024221 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-2.0.12/Examples/test-suite/octave/global_ns_arg_runme.m0000664000175000017500000000005212275776201023755 0ustar williamwilliamglobal_ns_arg a = foo(1); b = bar_fn(); swig-2.0.12/Examples/test-suite/octave/director_stl_runme.m0000664000175000017500000000064712275776201023673 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-2.0.12/Examples/test-suite/octave/samename_runme.m0000664000175000017500000000001112275776201022745 0ustar williamwilliamsamename swig-2.0.12/Examples/test-suite/octave/iadd_runme.m0000775000175000017500000000012712275776201022073 0ustar williamwilliamiadd f = iadd.Foo(); f.AsA.x = 3; f.AsA += f.AsA; if (f.AsA.x != 6) error endif swig-2.0.12/Examples/test-suite/octave/namespace_class_runme.m0000664000175000017500000000056112275776201024312 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-2.0.12/Examples/test-suite/octave/array_member_runme.m0000664000175000017500000000057312275776201023641 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-2.0.12/Examples/test-suite/octave/director_default_runme.m0000664000175000017500000000010412275776201024501 0ustar williamwilliamdirector_default f = Foo(); f = Foo(1); f = Bar(); f = Bar(1); swig-2.0.12/Examples/test-suite/octave/director_nested_runme.m0000664000175000017500000000175212275776201024351 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-2.0.12/Examples/test-suite/octave/inout_runme.m0000664000175000017500000000046112275776201022326 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-2.0.12/Examples/test-suite/octave/li_cpointer_runme.m0000664000175000017500000000015312275776201023475 0ustar williamwilliamli_cpointer p = new_intp(); intp_assign(p,3); if (intp_value(p) != 3) error endif delete_intp(p); swig-2.0.12/Examples/test-suite/octave/template_type_namespace_runme.m0000664000175000017500000000013512275776201026056 0ustar williamwilliamtemplate_type_namespace assert(strcmp(foo()(1),"foo")); swig-2.0.12/Examples/test-suite/octave/template_matrix_runme.m0000664000175000017500000000016112275776201024364 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-2.0.12/Examples/test-suite/octave/overload_extendc_runme.m0000664000175000017500000000063112275776201024514 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-2.0.12/Examples/test-suite/octave/director_string_runme.m0000664000175000017500000000071012275776201024366 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-2.0.12/Examples/test-suite/octave/template_ref_type_runme.m0000664000175000017500000000013012275776201024671 0ustar williamwilliamtemplate_ref_type xr = template_ref_type.XC(); y = template_ref_type.Y(); y.find(xr); swig-2.0.12/Examples/test-suite/octave/inplaceadd_runme.m0000664000175000017500000000030012275776201023244 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-2.0.12/Examples/test-suite/octave/li_carrays_runme.m0000664000175000017500000000014512275776201023317 0ustar williamwilliamli_carrays d = doubleArray(10); d(0) = 7; d(5) = d(0) + 3; if (d(5) + d(0) != 17) error endif swig-2.0.12/Examples/test-suite/octave/unions_runme.m0000664000175000017500000000231612275776201022504 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-2.0.12/Examples/test-suite/octave/using_extend_runme.m0000664000175000017500000000060012275776201023657 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-2.0.12/Examples/test-suite/octave/friends_runme.m0000664000175000017500000000121412275776201022617 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-2.0.12/Examples/test-suite/octave/complextest_runme.m0000664000175000017500000000045012275776201023535 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-2.0.12/Examples/test-suite/octave/using1_runme.m0000664000175000017500000000006312275776201022374 0ustar williamwilliamusing1 if (using1.spam(37) != 37) error endif swig-2.0.12/Examples/test-suite/octave/typemap_ns_using_runme.m0000664000175000017500000000010712275776201024551 0ustar williamwilliamtypemap_ns_using if (typemap_ns_using.spam(37) != 37) error endif swig-2.0.12/Examples/test-suite/octave/cpp_namespace_runme.m0000664000175000017500000000221412275776201023764 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-2.0.12/Examples/test-suite/octave/overload_template_fast_runme.m0000664000175000017500000000625412275776201025721 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-2.0.12/Examples/test-suite/octave/octave_cell_deref_runme.m0000664000175000017500000000020412275776201024610 0ustar williamwilliamoctave_cell_deref; assert(func("hello")); assert(func({"hello"})); c = func2(); assert(strcmp(c{1}, "hello")); assert(c{2} == 4); swig-2.0.12/Examples/test-suite/octave/smart_pointer_simple_runme.m0000664000175000017500000000023512275776201025426 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-2.0.12/Examples/test-suite/octave/li_std_pair_extra_runme.m0000664000175000017500000000326312275776201024667 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-2.0.12/Examples/test-suite/octave/template_rename_runme.m0000664000175000017500000000027712275776201024337 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-2.0.12/Examples/test-suite/octave/template_extend1_runme.m0000664000175000017500000000026212275776201024432 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-2.0.12/Examples/test-suite/octave/template_ns_runme.m0000664000175000017500000000035412275776201023504 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-2.0.12/Examples/test-suite/octave/ret_by_value_runme.m0000664000175000017500000000016612275776201023652 0ustar williamwilliamret_by_value a = ret_by_value.get_test(); if (a.myInt != 100) error endif if (a.myShort != 200) error endif swig-2.0.12/Examples/test-suite/octave/director_extend_runme.m0000664000175000017500000000027712275776201024357 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-2.0.12/Examples/test-suite/octave/profiletest_runme.m0000664000175000017500000000071012275776201023525 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-2.0.12/Examples/test-suite/octave/contract_runme.m0000664000175000017500000000433012275776201023004 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-2.0.12/Examples/test-suite/octave/octave_dim_runme.m0000664000175000017500000000105712275776201023304 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-2.0.12/Examples/test-suite/octave/preproc_constants_runme.m0000664000175000017500000000102512275776201024733 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-2.0.12/Examples/test-suite/octave/template_ns4_runme.m0000664000175000017500000000011712275776201023565 0ustar williamwilliamtemplate_ns4 d = make_Class_DD(); if (!strcmp(d.test(),"test")) error endif swig-2.0.12/Examples/test-suite/octave/reference_global_vars_runme.m0000664000175000017500000000374412275776201025510 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-2.0.12/Examples/test-suite/octave/li_std_vector_runme.m0000664000175000017500000000020412275776201024023 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-2.0.12/Examples/test-suite/octave/director_classic_runme.m0000664000175000017500000000455312275776201024512 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-2.0.12/Examples/test-suite/octave/smart_pointer_not_runme.m0000664000175000017500000000072612275776201024742 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-2.0.12/Examples/test-suite/octave/using_protected_runme.m0000664000175000017500000000013212275776201024361 0ustar williamwilliamusing_protected f = FooBar(); f.x = 3; if (f.blah(4) != 4) error("blah(int)") endif swig-2.0.12/Examples/test-suite/octave/abstract_virtual_runme.m0000664000175000017500000000004712275776201024541 0ustar williamwilliamabstract_virtual d = D(); e = E(); swig-2.0.12/Examples/test-suite/octave/constover_runme.m0000664000175000017500000000117212275776201023212 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-2.0.12/Examples/test-suite/octave/using_inherit_runme.m0000664000175000017500000000142112275776201024034 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-2.0.12/Examples/test-suite/octave/fvirtual_runme.m0000664000175000017500000000014512275776201023023 0ustar williamwilliamfvirtual sw = NodeSwitch(); n = Node(); i = sw.addChild(n); if (i != 2) error("addChild") endif swig-2.0.12/Examples/test-suite/octave/overload_subtype_runme.m0000664000175000017500000000017512275776201024560 0ustar williamwilliamoverload_subtype f = Foo(); b = Bar(); if (spam(f) != 1) error("foo") endif if (spam(b) != 2) error("bar") endif swig-2.0.12/Examples/test-suite/octave/input_runme.m0000664000175000017500000000030712275776201022326 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-2.0.12/Examples/test-suite/octave/li_std_carray_runme.m0000664000175000017500000000104512275776201024006 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-2.0.12/Examples/test-suite/octave/exception_order_runme.m0000664000175000017500000000160212275776201024357 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-2.0.12/Examples/test-suite/octave/virtual_poly_runme.m0000664000175000017500000000110012275776201023710 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-2.0.12/Examples/test-suite/octave/li_std_stream_runme.m0000664000175000017500000000021512275776201024016 0ustar williamwilliamli_std_stream a = A(); o = ostringstream(); o << a << " " << 2345 << " " << 1.435; if (o.str() != "A class 2345 1.435") error endif swig-2.0.12/Examples/test-suite/octave/smart_pointer_multi_runme.m0000664000175000017500000000024112275776201025264 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-2.0.12/Examples/test-suite/octave/using_private_runme.m0000664000175000017500000000032112275776201024042 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-2.0.12/Examples/test-suite/octave/class_ignore_runme.m0000664000175000017500000000015112275776201023634 0ustar williamwilliamclass_ignore a = class_ignore.Bar(); if (!strcmp(class_ignore.do_blah(a),"Bar::blah")) error endif swig-2.0.12/Examples/test-suite/octave/template_typedef_runme.m0000664000175000017500000000174512275776201024531 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-2.0.12/Examples/test-suite/octave/dynamic_cast_runme.m0000664000175000017500000000026512275776201023630 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-2.0.12/Examples/test-suite/octave/callback_runme.m0000664000175000017500000000071712275776201022730 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-2.0.12/Examples/test-suite/octave/Makefile.in0000664000175000017500000000427412275776201021657 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(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 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-2.0.12/Examples/test-suite/octave/default_args_runme.m0000664000175000017500000000200512275776201023624 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-2.0.12/Examples/test-suite/octave/template_inherit_runme.m0000664000175000017500000000160512275776201024526 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-2.0.12/Examples/test-suite/octave/abstract_typedef_runme.m0000664000175000017500000000012312275776201024506 0ustar williamwilliamabstract_typedef e = Engine(); a = A(); if (a.write(e) != 1) error endif swig-2.0.12/Examples/test-suite/octave/empty_runme.m0000664000175000017500000000000712275776201022322 0ustar williamwilliamempty swig-2.0.12/Examples/test-suite/octave/static_const_member_2_runme.m0000664000175000017500000000043212275776201025433 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-2.0.12/Examples/test-suite/octave/abstract_access_runme.m0000664000175000017500000000011512275776201024310 0ustar williamwilliamabstract_access d = abstract_access.D(); if (d.do_x() != 1) error endif swig-2.0.12/Examples/test-suite/octave/typedef_scope_runme.m0000664000175000017500000000030212275776201024013 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-2.0.12/Examples/test-suite/octave/director_unroll_runme.m0000664000175000017500000000032512275776201024375 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-2.0.12/Examples/test-suite/octave/li_std_wstream_runme.m0000664000175000017500000000023512275776201024207 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-2.0.12/Examples/test-suite/octave/import_nomodule_runme.m0000664000175000017500000000013012275776201024375 0ustar williamwilliamimport_nomodule f = create_Foo(); test1(f,42); delete_Foo(f); b = Bar(); test1(b,37); swig-2.0.12/Examples/test-suite/octave/rename_scope_runme.m0000664000175000017500000000021312275776201023623 0ustar williamwilliamrename_scope a = Natural_UP(); b = Natural_BP(); if (a.rtest() != 1) error endif if (b.rtest() != 1) error endif f = @equals; swig-2.0.12/Examples/test-suite/octave/namespace_typemap_runme.m0000664000175000017500000000227312275776201024666 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-2.0.12/Examples/test-suite/octave/overload_simple_cast_runme.m0000664000175000017500000000754412275776201025377 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-2.0.12/Examples/test-suite/octave/template_construct_runme.m0000664000175000017500000000002312275776201025101 0ustar williamwilliamtemplate_construct swig-2.0.12/Examples/test-suite/octave/li_implicit_runme.m0000664000175000017500000000042212275776201023463 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-2.0.12/Examples/test-suite/octave/enums_runme.m0000664000175000017500000000034312275776201022316 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-2.0.12/Examples/test-suite/octave/mod_runme.m0000664000175000017500000000007612275776201021751 0ustar williamwilliammod_a mod_b c = mod_b.C(); d = mod_b.D(); d.DoSomething(c); swig-2.0.12/Examples/test-suite/octave/overload_simple_runme.m0000664000175000017500000000404012275776201024351 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-2.0.12/Examples/test-suite/octave/inherit_missing_runme.m0000664000175000017500000000070012275776201024357 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-2.0.12/Examples/test-suite/octave/overload_copy_runme.m0000664000175000017500000000004512275776201024033 0ustar williamwilliamoverload_copy f = Foo(); g = Foo(f); swig-2.0.12/Examples/test-suite/octave/extend_template_ns_runme.m0000664000175000017500000000016212275776201025050 0ustar williamwilliamextend_template_ns f = Foo_One(); if (f.test1(37) != 37) error endif if (f.test2(42) != 42) error endif swig-2.0.12/Examples/test-suite/octave/overload_rename_runme.m0000664000175000017500000000023312275776201024327 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-2.0.12/Examples/test-suite/octave/smart_pointer_extend_runme.m0000664000175000017500000000057712275776201025435 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-2.0.12/Examples/test-suite/octave/overload_template_runme.m0000664000175000017500000000606212275776201024701 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-2.0.12/Examples/test-suite/octave/using_composition_runme.m0000664000175000017500000000122312275776201024735 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-2.0.12/Examples/test-suite/octave/namespace_virtual_method_runme.m0000664000175000017500000000010012275776201026220 0ustar williamwilliamnamespace_virtual_method x = namespace_virtual_method.Spam(); swig-2.0.12/Examples/test-suite/template_int_const.i0000664000175000017500000000205612275776201022372 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-2.0.12/Examples/test-suite/conversion_ns_template.i0000664000175000017500000000240712275776201023257 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-2.0.12/Examples/test-suite/typemap_template.i0000664000175000017500000000230312275776201022044 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-2.0.12/Examples/test-suite/char_binary.i0000664000175000017500000000077512275776201020766 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-2.0.12/Examples/test-suite/typename.i0000664000175000017500000000072212275776201020317 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-2.0.12/Examples/test-suite/java_lib_arrays_dimensionless.i0000664000175000017500000000202012275776201024552 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-2.0.12/Examples/test-suite/csharp_typemaps.i0000664000175000017500000000565712275776201021713 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 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-2.0.12/Examples/test-suite/template_explicit.i0000664000175000017500000000255712275776201022221 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-2.0.12/Examples/test-suite/iadd.i0000664000175000017500000000133412275776201017376 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-2.0.12/Examples/test-suite/using_private.i0000664000175000017500000000071312275776201021354 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-2.0.12/Examples/test-suite/csharp_lib_arrays.i0000664000175000017500000000263512275776201022171 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-2.0.12/Examples/test-suite/abstract_access.i0000664000175000017500000000071112275776201021617 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-2.0.12/Examples/test-suite/li_reference.i0000664000175000017500000000471612275776201021126 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-2.0.12/Examples/test-suite/template_default_arg_virtual_destructor.i0000664000175000017500000000115312275776201026670 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-2.0.12/Examples/test-suite/const_const_2.i0000664000175000017500000000053512275776201021254 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-2.0.12/Examples/test-suite/overload_subtype.i0000664000175000017500000000023512275776201022062 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-2.0.12/Examples/test-suite/virtual_destructor.i0000664000175000017500000000066712275776201022451 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-2.0.12/Examples/test-suite/catches.i0000664000175000017500000000146212275776201020111 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-2.0.12/Examples/test-suite/template_qualifier.i0000664000175000017500000000030712275776201022350 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-2.0.12/Examples/test-suite/typedef_inherit.i0000664000175000017500000000125612275776201021662 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-2.0.12/Examples/test-suite/template_typemaps_typedef.i0000664000175000017500000000770012275776201023755 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-2.0.12/Examples/test-suite/multi_import_a.i0000664000175000017500000000026012275776201021516 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-2.0.12/Examples/test-suite/director_unroll.i0000664000175000017500000000120512275776201021700 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-2.0.12/Examples/test-suite/nested_workaround.i0000664000175000017500000000157212275776201022236 0ustar williamwilliam%module nested_workaround // Similar to "Nested classes" documentation example. class Inner { int val; public: Inner(int v = 0) : val(v) {} void setValue(int v) { val = v; } int getValue() const { return val; } }; %nestedworkaround Outer::Inner; %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; } }; %} // We've fooled SWIG into thinking that Inner is a global class, so now we need // to trick the C++ compiler into understanding this apparent global type. %{ typedef Outer::Inner Inner; %} swig-2.0.12/Examples/test-suite/director_alternating.i0000664000175000017500000000144512275776201022703 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-2.0.12/Examples/test-suite/name.i0000664000175000017500000000073112275776201017415 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-2.0.12/Examples/test-suite/derived_nested.i0000664000175000017500000000122312275776201021456 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 { 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-2.0.12/Examples/test-suite/template_tbase_template.i0000664000175000017500000000210612275776201023357 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-2.0.12/Examples/test-suite/wallkw.i0000664000175000017500000000135312275776201017777 0ustar williamwilliam%module wallkw // test the -Wallkw option %warnfilter(SWIGWARN_PARSE_KEYWORD) clone; // 'clone' is a php keyword, renamed as '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-2.0.12/Examples/test-suite/template_typedef_import.list0000664000175000017500000000005712275776201024146 0ustar williamwilliamtemplate_typedef_cplx2 template_typedef_import swig-2.0.12/Examples/test-suite/guile/0000775000175000017500000000000012275776201017427 5ustar williamwilliamswig-2.0.12/Examples/test-suite/guile/cpp_enum_runme.scm0000664000175000017500000000046512275776201023154 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-2.0.12/Examples/test-suite/guile/README0000664000175000017500000000020712275776201020306 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.scm appended after the testcase name will be detected and run. swig-2.0.12/Examples/test-suite/guile/char_constant_runme.scm0000664000175000017500000000050412275776201024166 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-2.0.12/Examples/test-suite/guile/contract_runme.scm0000664000175000017500000000051412275776201023156 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-2.0.12/Examples/test-suite/guile/unions_runme.scm0000664000175000017500000000067212275776201022661 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-2.0.12/Examples/test-suite/guile/li_std_string_runme.scm0000664000175000017500000000075312275776201024212 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 ; locale must be set explicitly ; The setlocale call below takes care of that (setlocale LC_ALL "") (load "../schemerunme/li_std_string.scm") swig-2.0.12/Examples/test-suite/guile/testsuite.scm0000664000175000017500000000210712275776201022164 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-2.0.12/Examples/test-suite/guile/imports_runme.scm0000664000175000017500000000115112275776201023034 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-2.0.12/Examples/test-suite/guile/cpp_namespace_runme.scm0000664000175000017500000000017512275776201024142 0ustar williamwilliam(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace")) (load "../schemerunme/cpp_namespace.scm") swig-2.0.12/Examples/test-suite/guile/name_runme.scm0000664000175000017500000000045112275776201022261 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-2.0.12/Examples/test-suite/guile/import_nomodule_runme.scm0000664000175000017500000000020312275776201024550 0ustar williamwilliam(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule")) (load "../schemerunme/import_nomodule.scm") swig-2.0.12/Examples/test-suite/guile/overload_copy_runme.scm0000664000175000017500000000017512275776201024211 0ustar williamwilliam(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy")) (load "../schemerunme/overload_copy.scm") swig-2.0.12/Examples/test-suite/guile/list_vector_runme.scm0000664000175000017500000000047612275776201023705 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-2.0.12/Examples/test-suite/guile/constover_runme.scm0000664000175000017500000000016112275776201023361 0ustar williamwilliam(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover")) (load "../schemerunme/constover.scm") swig-2.0.12/Examples/test-suite/guile/overload_extend_runme.scm0000664000175000017500000000020312275776201024516 0ustar williamwilliam(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend")) (load "../schemerunme/overload_extend.scm") swig-2.0.12/Examples/test-suite/guile/overload_simple_runme.scm0000664000175000017500000000051212275776201024523 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-2.0.12/Examples/test-suite/guile/inherit_missing_runme.scm0000664000175000017500000000020312275776201024527 0ustar williamwilliam(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing")) (load "../schemerunme/inherit_missing.scm") swig-2.0.12/Examples/test-suite/guile/casts_runme.scm0000664000175000017500000000045412275776201022461 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-2.0.12/Examples/test-suite/guile/overload_complicated_runme.scm0000664000175000017500000000115512275776201025522 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-2.0.12/Examples/test-suite/guile/guile_ext_test_runme.scm0000664000175000017500000000103312275776201024362 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-2.0.12/Examples/test-suite/guile/throw_exception_runme.scm0000664000175000017500000000330012275776201024556 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-2.0.12/Examples/test-suite/guile/overload_subtype_runme.scm0000664000175000017500000000051512275776201024730 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-2.0.12/Examples/test-suite/guile/dynamic_cast_runme.scm0000664000175000017500000000017212275776201023777 0ustar williamwilliam(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast")) (load "../schemerunme/dynamic_cast.scm") swig-2.0.12/Examples/test-suite/guile/guile_ext_test_external.cxx0000664000175000017500000000066112275776201025104 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-2.0.12/Examples/test-suite/guile/integers_runme.scm0000664000175000017500000000063512275776201023165 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-2.0.12/Examples/test-suite/guile/Makefile.in0000664000175000017500000000275112275776201021501 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: @rm -f $*-guile clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile guile_clean swig-2.0.12/Examples/test-suite/guile/li_typemaps_runme.scm0000664000175000017500000000130712275776201023670 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-2.0.12/Examples/test-suite/guile/multivalue_runme.scm0000664000175000017500000000055212275776201023532 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-2.0.12/Examples/test-suite/guile/typedef_inherit_runme.scm0000664000175000017500000000020312275776201024516 0ustar williamwilliam(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit")) (load "../schemerunme/typedef_inherit.scm") swig-2.0.12/Examples/test-suite/guile/reference_global_vars_runme.scm0000664000175000017500000000026412275776201025654 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-2.0.12/Examples/test-suite/guile/typename_runme.scm0000664000175000017500000000026312275776201023164 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-2.0.12/Examples/test-suite/guile/pointer_in_out_runme.scm0000664000175000017500000000050712275776201024400 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-2.0.12/Examples/test-suite/guile/class_ignore_runme.scm0000664000175000017500000000017212275776201024011 0ustar williamwilliam(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore")) (load "../schemerunme/class_ignore.scm") swig-2.0.12/Examples/test-suite/director_thread.i0000664000175000017500000000324212275776201021637 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-2.0.12/Examples/test-suite/import_stl.list0000664000175000017500000000003212275776201021406 0ustar williamwilliamimport_stl_a import_stl_b swig-2.0.12/Examples/test-suite/constants.i0000664000175000017500000000014612275776201020511 0ustar williamwilliam%module constants %inline %{ struct A { A(double) { } }; const A b123(3.0); %} swig-2.0.12/Examples/test-suite/director_enum.i0000664000175000017500000000414612275776201021340 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-2.0.12/Examples/test-suite/conversion.i0000664000175000017500000000023512275776201020661 0ustar williamwilliam%module conversion %rename(toFoo) Bar::operator Foo(); %inline %{ struct Foo { }; struct Bar { operator Foo () { return Foo(); } }; %} swig-2.0.12/Examples/test-suite/using_pointers.i0000664000175000017500000000134212275776201021544 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-2.0.12/Examples/test-suite/mod.h0000664000175000017500000000036212275776201017253 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-2.0.12/Examples/test-suite/intermediary_classname.i0000664000175000017500000000501112275776201023213 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-2.0.12/Examples/test-suite/template_ns2.i0000664000175000017500000000044112275776201021070 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-2.0.12/Examples/test-suite/member_pointer.i0000664000175000017500000000614612275776201021512 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-2.0.12/Examples/test-suite/virtual_vs_nonvirtual_base.i0000664000175000017500000000151312275776201024145 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-2.0.12/Examples/test-suite/preproc_include_h2.i0000664000175000017500000000002112275776201022233 0ustar williamwilliam#define const2 2 swig-2.0.12/Examples/test-suite/grouping.i0000664000175000017500000000054312275776201020330 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-2.0.12/Examples/test-suite/using_namespace_loop.i0000664000175000017500000000023712275776201022670 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-2.0.12/Examples/test-suite/li_cdata_carrays.i0000664000175000017500000000015612275776201021762 0ustar williamwilliam%module li_cdata_carrays %include %array_class(int, intArray); %include %cdata(int); swig-2.0.12/Examples/test-suite/template_typedef_cplx2.h0000664000175000017500000001102412275776201023134 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-2.0.12/Examples/test-suite/csharp_exceptions.i0000664000175000017500000002000312275776201022210 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-2.0.12/Examples/test-suite/enum_thorough.i0000664000175000017500000010145212275776201021362 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-2.0.12/Examples/test-suite/schemerunme/0000775000175000017500000000000012275776201020635 5ustar williamwilliamswig-2.0.12/Examples/test-suite/schemerunme/typedef_inherit.scm0000664000175000017500000000060512275776201024524 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-2.0.12/Examples/test-suite/schemerunme/overload_simple.scm0000664000175000017500000000341512275776201024530 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-2.0.12/Examples/test-suite/schemerunme/class_ignore.scm0000664000175000017500000000015212275776201024007 0ustar williamwilliam(define a (new-Bar)) (if (not (string=? (Bar-blah a) "Bar::blah")) (error "Wrong string")) (exit 0) swig-2.0.12/Examples/test-suite/schemerunme/dynamic_cast.scm0000664000175000017500000000026712275776201024004 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-2.0.12/Examples/test-suite/schemerunme/li_typemaps.scm0000664000175000017500000000262312275776201023672 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-2.0.12/Examples/test-suite/schemerunme/unions.scm0000664000175000017500000000206112275776201022653 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-2.0.12/Examples/test-suite/schemerunme/cpp_enum.scm0000664000175000017500000000052712275776201023153 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-2.0.12/Examples/test-suite/schemerunme/constover.scm0000664000175000017500000000124112275776201023361 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-2.0.12/Examples/test-suite/schemerunme/multivalue.scm0000664000175000017500000000071312275776201023531 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-2.0.12/Examples/test-suite/schemerunme/typename.scm0000664000175000017500000000040012275776201023155 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-2.0.12/Examples/test-suite/schemerunme/li_typemaps_proxy.scm0000664000175000017500000000261512275776201025134 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-2.0.12/Examples/test-suite/schemerunme/contract.scm0000664000175000017500000000060612275776201023160 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-2.0.12/Examples/test-suite/schemerunme/list_vector.scm0000664000175000017500000000155712275776201023706 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-2.0.12/Examples/test-suite/schemerunme/pointer_in_out.scm0000664000175000017500000000040012275776201024370 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-2.0.12/Examples/test-suite/schemerunme/li_std_string.scm0000664000175000017500000000274212275776201024212 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-2.0.12/Examples/test-suite/schemerunme/cpp_namespace.scm0000664000175000017500000000172312275776201024142 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-2.0.12/Examples/test-suite/schemerunme/char_constant.scm0000664000175000017500000000013312275776201024164 0ustar williamwilliam(if (and (char? (CHAR-CONSTANT)) (string? (STRING-CONSTANT))) (exit 0) (exit 1)) swig-2.0.12/Examples/test-suite/schemerunme/imports.scm0000664000175000017500000000064312275776201023041 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-2.0.12/Examples/test-suite/schemerunme/overload_complicated.scm0000664000175000017500000000050412275776201025517 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-2.0.12/Examples/test-suite/schemerunme/overload_extend.scm0000664000175000017500000000035212275776201024523 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-2.0.12/Examples/test-suite/schemerunme/overload_subtype.scm0000664000175000017500000000016312275776201024727 0ustar williamwilliam(if (not (= (spam (new-Foo)) 1)) (error "foo")) (if (not (= (spam (new-Bar)) 2)) (error "bar")) (exit 0) swig-2.0.12/Examples/test-suite/schemerunme/import_nomodule.scm0000664000175000017500000000012212275776201024550 0ustar williamwilliam(define f (create-Foo)) (test1 f 42) (define b (new-Bar)) (test1 b 37) (exit 0) swig-2.0.12/Examples/test-suite/schemerunme/integers.scm0000664000175000017500000000426012275776201023163 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 unsigned-long-identity 0 unsigned-long-max) ;;; long long not implemented in Guile and MzScheme. (check-range signed-long-long-identity signed-long-long-min signed-long-long-max) (check-range unsigned-long-long-identity 0 unsigned-long-long-max) ) (exit 0) swig-2.0.12/Examples/test-suite/schemerunme/casts.scm0000664000175000017500000000025412275776201022457 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-2.0.12/Examples/test-suite/schemerunme/name.scm0000664000175000017500000000003612275776201022260 0ustar williamwilliam(foo-2) bar-2 Baz-2 (exit 0) swig-2.0.12/Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm0000664000175000017500000000124112275776201027004 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-2.0.12/Examples/test-suite/schemerunme/unions_proxy.scm0000664000175000017500000000174112275776201024120 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-2.0.12/Examples/test-suite/schemerunme/global_vars.scm0000664000175000017500000000077612275776201023646 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-2.0.12/Examples/test-suite/schemerunme/inherit_missing.scm0000664000175000017500000000044312275776201024535 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-2.0.12/Examples/test-suite/schemerunme/reference_global_vars.scm0000664000175000017500000000402512275776201025653 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-2.0.12/Examples/test-suite/schemerunme/overload_copy.scm0000664000175000017500000000006612275776201024210 0ustar williamwilliam(define f (new-Foo)) (define g (new-Foo f)) (exit 0) swig-2.0.12/Examples/test-suite/schemerunme/global_vars_proxy.scm0000664000175000017500000000106412275776201025076 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-2.0.12/Examples/test-suite/disown.i0000664000175000017500000000127712275776201020006 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-2.0.12/Examples/test-suite/immutable_values.i0000664000175000017500000000040412275776201022030 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-2.0.12/Examples/test-suite/go/0000775000175000017500000000000012275776201016727 5ustar williamwilliamswig-2.0.12/Examples/test-suite/go/keyword_rename_runme.go0000664000175000017500000000015112275776201023474 0ustar williamwilliampackage main import "./keyword_rename" func main() { keyword_rename.Xgo(1) keyword_rename.Xchan(1) } swig-2.0.12/Examples/test-suite/go/smart_pointer_member_runme.go0000664000175000017500000000051712275776201024704 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-2.0.12/Examples/test-suite/go/director_exception_runme.go0000664000175000017500000000322312275776201024355 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-2.0.12/Examples/test-suite/go/class_ignore_runme.go0000664000175000017500000000024412275776201023134 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-2.0.12/Examples/test-suite/go/typemap_ns_using_runme.go0000664000175000017500000000015712275776201024053 0ustar williamwilliampackage main import "./typemap_ns_using" func main() { if typemap_ns_using.Spam(37) != 37 { panic(0) } } swig-2.0.12/Examples/test-suite/go/director_unroll_runme.go0000664000175000017500000000050512275776201023672 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-2.0.12/Examples/test-suite/go/abstract_access_runme.go0000664000175000017500000000020012275776201023600 0ustar williamwilliampackage main import "./abstract_access" func main() { d := abstract_access.NewD() if d.Do_x() != 1 { panic(d.Do_x()) } } swig-2.0.12/Examples/test-suite/go/struct_rename_runme.go0000664000175000017500000000012412275776201023334 0ustar williamwilliampackage main import "./struct_rename" func main() { _ = struct_rename.NewBar() } swig-2.0.12/Examples/test-suite/go/varargs_runme.go0000664000175000017500000000060212275776201022127 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-2.0.12/Examples/test-suite/go/unions_runme.go0000664000175000017500000000230012275776201021772 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-2.0.12/Examples/test-suite/go/virtual_derivation_runme.go0000664000175000017500000000025412275776201024377 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-2.0.12/Examples/test-suite/go/director_abstract_runme.go0000664000175000017500000000212512275776201024162 0ustar williamwilliampackage main import "./director_abstract" type MyFoo struct{} func (p *MyFoo) Ping() string { return "MyFoo::ping()" } func f1() { a := director_abstract.NewDirectorFoo(&MyFoo{}) if a.Ping() != "MyFoo::ping()" { panic(a.Ping()) } if a.Pong() != "Foo::pong();MyFoo::ping()" { panic(a.Pong()) } } type MyExample1 struct{} func (p *MyExample1) Color(r, g, b byte) int { return int(r) } type MyExample2 struct{} func (p *MyExample2) Color(r, g, b byte) int { return int(g) } type MyExample3 struct{} func (p *MyExample3) Color(r, g, b byte) int { return int(b) } func f2() { me1 := director_abstract.NewDirectorExample1(&MyExample1{}) if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 { println(director_abstract.Example1Get_color(me1, 1, 2, 3)) panic(0) } me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2) if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 { panic(0) } me3 := director_abstract.NewDirectorExample3_i(&MyExample3{}) if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 { panic(0) } } func main() { f1() f2() } swig-2.0.12/Examples/test-suite/go/director_basic_runme.go0000664000175000017500000000352512275776201023445 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-2.0.12/Examples/test-suite/go/li_attribute_runme.go0000664000175000017500000000323612275776201023157 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-2.0.12/Examples/test-suite/go/director_extend_runme.go0000664000175000017500000000064212275776201023650 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-2.0.12/Examples/test-suite/go/extend_template_ns_runme.go0000664000175000017500000000023712275776201024350 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-2.0.12/Examples/test-suite/go/profiletest_runme.go0000664000175000017500000000107412275776201023026 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-2.0.12/Examples/test-suite/go/abstract_typedef2_runme.go0000664000175000017500000000013112275776201024064 0ustar williamwilliampackage main import "./abstract_typedef2" func main() { abstract_typedef2.NewA_UF() } swig-2.0.12/Examples/test-suite/go/template_type_namespace_runme.go0000664000175000017500000000014012275776201025347 0ustar williamwilliampackage main import . "./template_type_namespace" func main() { if Foo().Get(0) == "" { } } swig-2.0.12/Examples/test-suite/go/empty_runme.go0000664000175000017500000000006212275776201021620 0ustar williamwilliampackage main import _ "./empty" func main() { } swig-2.0.12/Examples/test-suite/go/cpp_enum_runme.go0000664000175000017500000000064412275776201022276 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-2.0.12/Examples/test-suite/go/li_std_vector_ptr_runme.go0000664000175000017500000000026212275776201024211 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-2.0.12/Examples/test-suite/go/array_member_runme.go0000664000175000017500000000071512275776201023134 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-2.0.12/Examples/test-suite/go/rename_simple_runme.go0000664000175000017500000000161012275776201023302 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-2.0.12/Examples/test-suite/go/compactdefaultargs_runme.go0000664000175000017500000000076612275776201024345 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-2.0.12/Examples/test-suite/go/enum_template_runme.go0000664000175000017500000000021012275776201023314 0ustar williamwilliampackage main import "./enum_template" func main() { if enum_template.MakeETest() != 1 { panic(0) } enum_template.TakeETest(0) } swig-2.0.12/Examples/test-suite/go/template_static_runme.go0000664000175000017500000000011612275776201023644 0ustar williamwilliampackage main import . "./template_static" func main() { FooBar_double(1) } swig-2.0.12/Examples/test-suite/go/struct_initialization_runme.go0000664000175000017500000000055312275776201025122 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-2.0.12/Examples/test-suite/go/constover_runme.go0000664000175000017500000000140212275776201022503 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-2.0.12/Examples/test-suite/go/using_private_runme.go0000664000175000017500000000036612275776201023350 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-2.0.12/Examples/test-suite/go/director_classic_runme.go0000664000175000017500000000643012275776201024003 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-2.0.12/Examples/test-suite/go/multi_import_runme.go0000664000175000017500000000064512275776201023215 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-2.0.12/Examples/test-suite/go/default_args_runme.go0000664000175000017500000000050012275776201023117 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-2.0.12/Examples/test-suite/go/template_typedef_cplx3_runme.go0000664000175000017500000000072312275776201025132 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-2.0.12/Examples/test-suite/go/using_extend_runme.go0000664000175000017500000000065112275776201023162 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-2.0.12/Examples/test-suite/go/minherit_runme.go0000664000175000017500000000445712275776201022315 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-2.0.12/Examples/test-suite/go/extend_placement_runme.go0000664000175000017500000000210012275776201023774 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-2.0.12/Examples/test-suite/go/smart_pointer_multi_runme.go0000664000175000017500000000033512275776201024565 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-2.0.12/Examples/test-suite/go/wrapmacro_runme.go0000664000175000017500000000025212275776201022456 0ustar williamwilliampackage main import "./wrapmacro" func main() { a := 2 b := -1 wrapmacro.Maximum(a, b) wrapmacro.Maximum(a/7.0, -b*256) wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1) } swig-2.0.12/Examples/test-suite/go/friends_runme.go0000664000175000017500000000140112275776201022112 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-2.0.12/Examples/test-suite/go/using_protected_runme.go0000664000175000017500000000020712275776201023661 0ustar williamwilliampackage main import . "./using_protected" func main() { f := NewFooBar() f.SetX(3) if f.Blah(4) != 4 { panic("blah(int)") } } swig-2.0.12/Examples/test-suite/go/overload_copy_runme.go0000664000175000017500000000013012275776201023323 0ustar williamwilliampackage main import . "./overload_copy" func main() { f := NewFoo() _ = NewFoo(f) } swig-2.0.12/Examples/test-suite/go/member_pointer_runme.go0000664000175000017500000000172612275776201023501 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-2.0.12/Examples/test-suite/go/overload_template_fast_runme.go0000664000175000017500000000606112275776201025212 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-2.0.12/Examples/test-suite/go/varargs_overload_runme.go0000664000175000017500000000126412275776201024027 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-2.0.12/Examples/test-suite/go/template_default_arg_runme.go0000664000175000017500000000537612275776201024647 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-2.0.12/Examples/test-suite/go/namespace_typemap_runme.go0000664000175000017500000000234612275776201024164 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-2.0.12/Examples/test-suite/go/smart_pointer_rename_runme.go0000664000175000017500000000032212275776201024676 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-2.0.12/Examples/test-suite/go/inherit_missing_runme.go0000664000175000017500000000061512275776201023661 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-2.0.12/Examples/test-suite/go/smart_pointer_extend_runme.go0000664000175000017500000000071712275776201024726 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-2.0.12/Examples/test-suite/go/overload_complicated_runme.go0000664000175000017500000000174712275776201024654 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-2.0.12/Examples/test-suite/go/refcount_runme.go0000664000175000017500000000067012275776201022314 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-2.0.12/Examples/test-suite/go/return_const_value_runme.go0000664000175000017500000000041012275776201024400 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-2.0.12/Examples/test-suite/go/li_carrays_runme.go0000664000175000017500000000026512275776201022617 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-2.0.12/Examples/test-suite/go/director_frob_runme.go0000664000175000017500000000022412275776201023305 0ustar williamwilliampackage main import . "./director_frob" func main() { foo := NewBravo() s := foo.Abs_method() if s != "Bravo::abs_method()" { panic(s) } } swig-2.0.12/Examples/test-suite/go/director_alternating_runme.go0000664000175000017500000000020012275776201024657 0ustar williamwilliampackage main import . "./director_alternating" func main() { id := GetBar().Id() if id != IdFromGetBar() { panic(id) } } swig-2.0.12/Examples/test-suite/go/abstract_virtual_runme.go0000664000175000017500000000015512275776201024036 0ustar williamwilliampackage main import "./abstract_virtual" func main() { abstract_virtual.NewD() abstract_virtual.NewE() } swig-2.0.12/Examples/test-suite/go/using2_runme.go0000664000175000017500000000013312275776201021670 0ustar williamwilliampackage main import "./using2" func main() { if using2.Spam(37) != 37 { panic(0) } } swig-2.0.12/Examples/test-suite/go/using_composition_runme.go0000664000175000017500000000133012275776201024231 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-2.0.12/Examples/test-suite/go/rename_strip_encoder_runme.go0000664000175000017500000000020012275776201024643 0ustar williamwilliampackage main import . "./rename_strip_encoder" func main() { _ = NewSomeWidget() a := NewAnotherWidget() a.DoSomething() } swig-2.0.12/Examples/test-suite/go/extern_c_runme.go0000664000175000017500000000011512275776201022270 0ustar williamwilliampackage main import "./extern_c" func main() { extern_c.RealFunction(2) } swig-2.0.12/Examples/test-suite/go/typedef_scope_runme.go0000664000175000017500000000033512275776201023316 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-2.0.12/Examples/test-suite/go/special_variable_macros_runme.go0000664000175000017500000000137012275776201025316 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-2.0.12/Examples/test-suite/go/template_typedef_import_runme.go0000664000175000017500000000133412275776201025412 0ustar williamwilliampackage main import "template_typedef_cplx2" import "template_typedef_import" func main() { // this is OK s := template_typedef_import.NewSin() s.Get_base_value() s.Get_value() s.Get_arith_value() template_typedef_import.My_func_r(s) template_typedef_cplx2.Make_Multiplies_double_double_double_double(s, s) z := template_typedef_import.NewCSin() z.Get_base_value() z.Get_value() z.Get_arith_value() template_typedef_import.My_func_c(z) template_typedef_cplx2.Make_Multiplies_complex_complex_complex_complex(z, z) // Here we fail d := template_typedef_cplx2.Make_Identity_double() template_typedef_import.My_func_r(d) c := template_typedef_cplx2.Make_Identity_complex() template_typedef_import.My_func_c(c) } swig-2.0.12/Examples/test-suite/go/mod_runme.go0000664000175000017500000000022112275776201021236 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-2.0.12/Examples/test-suite/go/global_ns_arg_runme.go0000664000175000017500000000011412275776201023251 0ustar williamwilliampackage main import . "./global_ns_arg" func main() { Foo(1) Bar_fn() } swig-2.0.12/Examples/test-suite/go/static_const_member_2_runme.go0000664000175000017500000000051612275776201024733 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-2.0.12/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go0000664000175000017500000000034512275776201026306 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-2.0.12/Examples/test-suite/go/typemap_namespace_runme.go0000664000175000017500000000023312275776201024155 0ustar williamwilliampackage main import . "./typemap_namespace" func main() { if Test1("hello") != "hello" { panic(0) } if Test2("hello") != "hello" { panic(0) } } swig-2.0.12/Examples/test-suite/go/typemap_out_optimal_runme.go0000664000175000017500000000014312275776201024555 0ustar williamwilliampackage main import . "./typemap_out_optimal" func main() { SetXXDebug(false) _ = XXCreate() } swig-2.0.12/Examples/test-suite/go/namespace_class_runme.go0000664000175000017500000000033112275776201023602 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-2.0.12/Examples/test-suite/go/overload_subtype_runme.go0000664000175000017500000000024712275776201024055 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-2.0.12/Examples/test-suite/go/director_default_runme.go0000664000175000017500000000015012275776201023777 0ustar williamwilliampackage main import . "./director_default" func main() { NewFoo() NewFoo(1) NewBar() NewBar(1) } swig-2.0.12/Examples/test-suite/go/constructor_copy_runme.go0000664000175000017500000000065512275776201024111 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-2.0.12/Examples/test-suite/go/reference_global_vars_runme.go0000664000175000017500000000431512275776201025000 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-2.0.12/Examples/test-suite/go/extend_template_runme.go0000664000175000017500000000025012275776201023643 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-2.0.12/Examples/test-suite/go/memberin_extend_c_runme.go0000664000175000017500000000026612275776201024137 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-2.0.12/Examples/test-suite/go/input_runme.go0000664000175000017500000000022712275776201021624 0ustar williamwilliampackage main import . "./input" func main() { f := NewFoo() if f.Foo(2) != 4 { panic(0) } if Sfoo("Hello") != "Hello world" { panic(0) } } swig-2.0.12/Examples/test-suite/go/template_opaque_runme.go0000664000175000017500000000021012275776201023642 0ustar williamwilliampackage main import "./template_opaque" func main() { v := template_opaque.NewOpaqueVectorType(10) template_opaque.FillVector(v) } swig-2.0.12/Examples/test-suite/go/overload_rename_runme.go0000664000175000017500000000040012275776201023620 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-2.0.12/Examples/test-suite/go/preproc_runme.go0000664000175000017500000000035512275776201022141 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-2.0.12/Examples/test-suite/go/director_nested_runme.go0000664000175000017500000000246012275776201023643 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-2.0.12/Examples/test-suite/go/disown_runme.go0000664000175000017500000000013412275776201021765 0ustar williamwilliampackage main import . "./disown" func main() { a := NewA() b := NewB() b.Acquire(a) } swig-2.0.12/Examples/test-suite/go/char_binary_runme.go0000664000175000017500000000065412275776201022752 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-2.0.12/Examples/test-suite/go/extend_variable_runme.go0000664000175000017500000000013512275776201023617 0ustar williamwilliampackage main import . "./extend_variable" func main() { if FooBar != 42 { panic(0) } } swig-2.0.12/Examples/test-suite/go/template_ns_runme.go0000664000175000017500000000047212275776201023002 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-2.0.12/Examples/test-suite/go/grouping_runme.go0000664000175000017500000000033712275776201022321 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-2.0.12/Examples/test-suite/go/exception_order_runme.go0000664000175000017500000000145012275776201023655 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-2.0.12/Examples/test-suite/go/director_detect_runme.go0000664000175000017500000000141112275776201023624 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-2.0.12/Examples/test-suite/go/rename_scope_runme.go0000664000175000017500000000027212275776201023125 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-2.0.12/Examples/test-suite/go/ret_by_value_runme.go0000664000175000017500000000025012275776201023141 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-2.0.12/Examples/test-suite/go/arrays_global_runme.go0000664000175000017500000000064212275776201023307 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-2.0.12/Examples/test-suite/go/template_inherit_runme.go0000664000175000017500000000153712275776201024027 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-2.0.12/Examples/test-suite/go/dynamic_cast_runme.go0000664000175000017500000000036112275776201023122 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-2.0.12/Examples/test-suite/go/virtual_poly_runme.go0000664000175000017500000000116312275776201023216 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-2.0.12/Examples/test-suite/go/director_thread_runme.go0000664000175000017500000000057512275776201023635 0ustar williamwilliampackage main import . "./director_thread" type Derived struct { abi Foo } // From Foo func (p *Derived) Do_foo() { p.abi.SetVal(p.abi.GetVal() - 1) } func main() { // FIXME: This test fails until we fix callbacks from a // different thread. return p := &Derived{nil} d := NewDirectorFoo(p) p.abi = d d.Run() if d.GetVal() >= 0 { panic(d.GetVal()) } d.Stop() } swig-2.0.12/Examples/test-suite/go/inctest_runme.go0000664000175000017500000000045712275776201022143 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-2.0.12/Examples/test-suite/go/cpp_namespace_runme.go0000664000175000017500000000220712275776201023263 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-2.0.12/Examples/test-suite/go/nested_workaround_runme.go0000664000175000017500000000052612275776201024224 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-2.0.12/Examples/test-suite/go/template_tbase_template_runme.go0000664000175000017500000000020112275776201025341 0ustar williamwilliampackage main import . "./template_tbase_template" func main() { a := Make_Class_dd() if a.Test() != "test" { panic(0) } } swig-2.0.12/Examples/test-suite/go/sneaky1_runme.go0000664000175000017500000000022612275776201022037 0ustar williamwilliampackage main import "./sneaky1" func main() { _ = sneaky1.Add(3, 4) _ = sneaky1.Subtract(3, 4) _ = sneaky1.Mul(3, 4) _ = sneaky1.Divide(3, 4) } swig-2.0.12/Examples/test-suite/go/overload_simple_runme.go0000664000175000017500000000344512275776201023656 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-2.0.12/Examples/test-suite/go/smart_pointer_typedef_runme.go0000664000175000017500000000032512275776201025072 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-2.0.12/Examples/test-suite/go/class_scope_weird_runme.go0000664000175000017500000000024312275776201024153 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-2.0.12/Examples/test-suite/go/template_typedef_cplx4_runme.go0000664000175000017500000000072312275776201025133 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-2.0.12/Examples/test-suite/go/fvirtual_runme.go0000664000175000017500000000022612275776201022320 0ustar williamwilliampackage main import . "./fvirtual" func main() { sw := NewNodeSwitch() n := NewNode() i := sw.AddChild(n) if i != 2 { panic("addChild") } } swig-2.0.12/Examples/test-suite/go/using1_runme.go0000664000175000017500000000013312275776201021667 0ustar williamwilliampackage main import "./using1" func main() { if using1.Spam(37) != 37 { panic(0) } } swig-2.0.12/Examples/test-suite/go/director_finalizer_runme.go0000664000175000017500000000064612275776201024350 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-2.0.12/Examples/test-suite/go/abstract_typedef_runme.go0000664000175000017500000000024312275776201024006 0ustar williamwilliampackage main import "./abstract_typedef" func main() { e := abstract_typedef.NewEngine() a := abstract_typedef.NewA() if !a.Write(e) { panic("failed") } } swig-2.0.12/Examples/test-suite/go/template_ns4_runme.go0000664000175000017500000000016612275776201023066 0ustar williamwilliampackage main import . "./template_ns4" func main() { d := Make_Class_DD() if d.Test() != "test" { panic(0) } } swig-2.0.12/Examples/test-suite/go/smart_pointer_templatevariables_runme.go0000664000175000017500000000046612275776201027144 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-2.0.12/Examples/test-suite/go/typename_runme.go0000664000175000017500000000026612275776201022312 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-2.0.12/Examples/test-suite/go/imports_runme.go0000664000175000017500000000034412275776201022162 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-2.0.12/Examples/test-suite/go/using_inherit_runme.go0000664000175000017500000000165312275776201023340 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-2.0.12/Examples/test-suite/go/template_ref_type_runme.go0000664000175000017500000000021012275776201024165 0ustar williamwilliampackage main import "./template_ref_type" func main() { xr := template_ref_type.NewXC() y := template_ref_type.NewY() y.Find(xr) } swig-2.0.12/Examples/test-suite/go/voidtest_runme.go0000664000175000017500000000054112275776201022325 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-2.0.12/Examples/test-suite/go/template_rename_runme.go0000664000175000017500000000036012275776201023625 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-2.0.12/Examples/test-suite/go/default_constructor_runme.go0000664000175000017500000000060312275776201024554 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-2.0.12/Examples/test-suite/go/director_string_runme.go0000664000175000017500000000112112275776201023660 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-2.0.12/Examples/test-suite/go/smart_pointer_overload_runme.go0000664000175000017500000000050612275776201025246 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-2.0.12/Examples/test-suite/go/smart_pointer_simple_runme.go0000664000175000017500000000032412275776201024722 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-2.0.12/Examples/test-suite/go/director_protected_runme.go0000664000175000017500000000262112275776201024351 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-2.0.12/Examples/test-suite/go/Makefile.in0000664000175000017500000000621512275776201021000 0ustar williamwilliam####################################################################### # Makefile for Go test-suite ####################################################################### LANGUAGE = go GO = @GO@ GOGCC = @GOGCC@ GO1 = @GO1@ 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) %.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 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ if $(GOGCC) ; then \ $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ fi && \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi run_multi_testcase = \ if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(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$(SO); done`; \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${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 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 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-2.0.12/Examples/test-suite/go/li_std_map_runme.go0000664000175000017500000000067312275776201022605 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-2.0.12/Examples/test-suite/go/naturalvar_runme.go0000664000175000017500000000025212275776201022642 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-2.0.12/Examples/test-suite/go/namespace_virtual_method_runme.go0000664000175000017500000000015312275776201025525 0ustar williamwilliampackage main import "./namespace_virtual_method" func main() { _ = namespace_virtual_method.NewSpam() } swig-2.0.12/Examples/test-suite/go/contract_runme.go0000664000175000017500000000651112275776201022304 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-2.0.12/Examples/test-suite/go/primitive_ref_runme.go0000664000175000017500000000110112275776201023321 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-2.0.12/Examples/test-suite/go/li_cdata_runme.go0000664000175000017500000000026412275776201022226 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-2.0.12/Examples/test-suite/go/director_profile_runme.go0000664000175000017500000000135212275776201024020 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-2.0.12/Examples/test-suite/go/overload_template_runme.go0000664000175000017500000000605412275776201024177 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-2.0.12/Examples/test-suite/go/template_extend1_runme.go0000664000175000017500000000032512275776201023727 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-2.0.12/Examples/test-suite/go/enums_runme.go0000664000175000017500000000042112275776201021610 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-2.0.12/Examples/test-suite/go/template_extend2_runme.go0000664000175000017500000000032512275776201023730 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-2.0.12/Examples/test-suite/go/li_cpointer_runme.go0000664000175000017500000000022512275776201022772 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-2.0.12/Examples/test-suite/go/typedef_inherit_runme.go0000664000175000017500000000072612275776201023653 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-2.0.12/Examples/test-suite/go/overload_extendc_runme.go0000664000175000017500000000070612275776201024014 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-2.0.12/Examples/test-suite/go/cpp_static_runme.go0000664000175000017500000000043612275776201022620 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-2.0.12/Examples/test-suite/go/director_enum_runme.go0000664000175000017500000000056112275776201023325 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-2.0.12/Examples/test-suite/go/typedef_class_runme.go0000664000175000017500000000021212275776201023304 0ustar williamwilliampackage main import "./typedef_class" func main() { a := typedef_class.NewRealA() a.SetA(3) b := typedef_class.NewB() b.TestA(a) } swig-2.0.12/Examples/test-suite/go/import_nomodule_runme.go0000664000175000017500000000021212275776201023673 0ustar williamwilliampackage main import . "./import_nomodule" func main() { f := Create_Foo() Test1(f, 42) Delete_Foo(f) b := NewBar() Test1(b, 37) } swig-2.0.12/Examples/test-suite/go/threads_exception_runme.go0000664000175000017500000000153112275776201024174 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-2.0.12/Examples/test-suite/go/li_cmalloc_runme.go0000664000175000017500000000042312275776201022561 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-2.0.12/Examples/test-suite/go/overload_extend_runme.go0000664000175000017500000000051512275776201023647 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-2.0.12/Examples/test-suite/go/struct_value_runme.go0000664000175000017500000000031312275776201023201 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-2.0.12/Examples/test-suite/class_forward.i0000664000175000017500000000013112275776201021320 0ustar williamwilliam%module class_forward %inline %{ struct A { class B; }; class C : public A { }; %} swig-2.0.12/Examples/test-suite/template_ns.i0000664000175000017500000000164512275776201021015 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-2.0.12/Examples/test-suite/register_par.i0000664000175000017500000000016712275776201021166 0ustar williamwilliam%module register_par // bug # 924413 %inline { void clear_tree_flags(register struct tree *tp, register int i) {} } swig-2.0.12/Examples/test-suite/allprotected.i0000664000175000017500000000513112275776201021156 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-2.0.12/Examples/test-suite/integers.i0000664000175000017500000000305312275776201020315 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-2.0.12/Examples/test-suite/threads.i0000664000175000017500000000105212275776201020124 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-2.0.12/Examples/test-suite/template_template_parameters.i0000664000175000017500000000227212275776201024430 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-2.0.12/Examples/test-suite/extend_special_variables.i0000664000175000017500000000124412275776201023514 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-2.0.12/Examples/test-suite/struct_value.i0000664000175000017500000000015612275776201021216 0ustar williamwilliam%module struct_value %inline %{ struct Foo { int x; }; struct Bar { Foo a; struct Foo b; }; %} swig-2.0.12/Examples/test-suite/evil_diamond_prop.i0000664000175000017500000000156312275776201022173 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-2.0.12/Examples/test-suite/pointer_reference.i0000664000175000017500000000201512275776201022170 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-2.0.12/Examples/test-suite/template_enum_typedef.i0000664000175000017500000000143212275776201023053 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-2.0.12/Examples/test-suite/default_constructor.i0000664000175000017500000000562312275776201022573 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-2.0.12/Examples/test-suite/li_std_vector_member_var.i0000664000175000017500000000067712275776201023545 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-2.0.12/Examples/test-suite/rename_pcre_enum.i0000664000175000017500000000253612275776201022006 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-2.0.12/Examples/test-suite/template_typedef_import.i0000664000175000017500000000073012275776201023421 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-2.0.12/Examples/test-suite/template_typedef_cplx2.i0000664000175000017500000000015712275776201023142 0ustar williamwilliam%module template_typedef_cplx2 %{ #include "template_typedef_cplx2.h" %} %include "template_typedef_cplx2.h" swig-2.0.12/Examples/test-suite/overload_rename.i0000664000175000017500000000044212275776201021636 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-2.0.12/Examples/test-suite/li_stdint.i0000664000175000017500000000443012275776201020466 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-2.0.12/Examples/test-suite/namespace_typemap.i0000664000175000017500000001215212275776201022170 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-2.0.12/Examples/test-suite/python_director.i0000664000175000017500000000047412275776201021715 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-2.0.12/Examples/test-suite/sizet.i0000664000175000017500000000120112275776201017624 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-2.0.12/Examples/test-suite/namespace_typedef_class.i0000664000175000017500000000021612275776201023334 0ustar williamwilliam%module namespace_typedef_class %inline %{ namespace ns { struct S1 { int n; }; typedef struct { int n; } S2; } %} swig-2.0.12/Examples/test-suite/preproc_include_d withspace.h0000664000175000017500000000003112275776201024115 0ustar williamwilliam int multiply40(int a); swig-2.0.12/Examples/test-suite/typedef_reference.i0000664000175000017500000000030212275776201022145 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-2.0.12/Examples/test-suite/template_typedef.i0000664000175000017500000001073012275776201022030 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-2.0.12/Examples/test-suite/typemap_arrays.i0000664000175000017500000000123012275776201021530 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-2.0.12/Examples/test-suite/preproc_constants_c.i0000664000175000017500000000015412275776201022544 0ustar williamwilliam%module preproc_constants_c %define true 1 %enddef %define false 0 %enddef %include "preproc_constants.i" swig-2.0.12/Examples/test-suite/ruby_track_objects_directors.i0000664000175000017500000000072412275776201024433 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-2.0.12/Examples/test-suite/cplusplus_throw.i0000664000175000017500000000102612275776201021750 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-2.0.12/Examples/test-suite/li_cwstring.i0000664000175000017500000000351512275776201021024 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-2.0.12/Examples/test-suite/kwargs_feature.i0000664000175000017500000000332612275776201021511 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-2.0.12/Examples/test-suite/packageoption.h0000664000175000017500000000015612275776201021321 0ustar williamwilliamstruct Base { virtual int vmethod() { return 1; } int basemethod() { return 1; } virtual ~Base() {} }; swig-2.0.12/Examples/test-suite/template_extend1.i0000664000175000017500000000104412275776201021736 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-2.0.12/Examples/test-suite/global_scope_types.i0000664000175000017500000000217712275776201022360 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-2.0.12/Examples/test-suite/multi_import_b.i0000664000175000017500000000021512275776201021517 0ustar williamwilliam%module multi_import_b %include multi_import_c.i %{ #include "multi_import.h" %} class YYY : public XXX { public: int testy(); }; swig-2.0.12/Examples/test-suite/member_template.i0000664000175000017500000000062212275776201021636 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-2.0.12/Examples/test-suite/template_ns_inherit.i0000664000175000017500000000110012275776201022521 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-2.0.12/Examples/test-suite/private_assign.i0000664000175000017500000000167612275776201021524 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-2.0.12/Examples/test-suite/li_carrays.i0000664000175000017500000000100012275776201020613 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-2.0.12/Examples/test-suite/import_nomodule.i0000664000175000017500000000200612275776201021706 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-2.0.12/Examples/test-suite/director_nspace.i0000664000175000017500000000321112275776201021635 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) %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-2.0.12/Examples/test-suite/director_profile.i0000664000175000017500000000136012275776201022027 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-2.0.12/Examples/test-suite/li_constraints.i0000664000175000017500000000076012275776201021532 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-2.0.12/Examples/test-suite/r_overload_array.i0000664000175000017500000000065212275776201022031 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-2.0.12/Examples/test-suite/unions.i0000664000175000017500000000126312275776201020011 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-2.0.12/Examples/test-suite/li_cdata.i0000664000175000017500000000013712275776201020235 0ustar williamwilliam%module li_cdata %include %cdata(int); %cdata(double); void *malloc(size_t size); swig-2.0.12/Examples/test-suite/arrays_global_twodim.i0000664000175000017500000000311212275776201022675 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-2.0.12/Examples/test-suite/aggregate.i0000664000175000017500000000170012275776201020420 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-2.0.12/Examples/test-suite/director_namespace_clash.i0000664000175000017500000000047012275776201023476 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-2.0.12/Examples/test-suite/li_cstring.i0000664000175000017500000000331612275776201020634 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-2.0.12/Examples/test-suite/null_pointer.i0000664000175000017500000000033112275776201021203 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-2.0.12/Examples/test-suite/java_prepost.i0000664000175000017500000000630112275776201021171 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-2.0.12/Examples/test-suite/li_std_functors.i0000664000175000017500000000110512275776201021672 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-2.0.12/Examples/test-suite/class_ignore.i0000664000175000017500000000134612275776201021150 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-2.0.12/Examples/test-suite/template_using.i0000664000175000017500000000045012275776201021513 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-2.0.12/Examples/test-suite/enum_thorough_simple.i0000664000175000017500000000030412275776201022725 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-2.0.12/Examples/test-suite/features.i0000664000175000017500000001547712275776201020330 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-2.0.12/Examples/test-suite/sneaky1.i0000664000175000017500000000042512275776201020050 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-2.0.12/Examples/test-suite/allprotected_not.i0000664000175000017500000000174112275776201022041 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-2.0.12/Examples/test-suite/insert_directive.i0000664000175000017500000000135112275776201022036 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-2.0.12/Examples/test-suite/namespace_spaces.i0000664000175000017500000000106212275776201021765 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-2.0.12/Examples/test-suite/enum_var.i0000664000175000017500000000011212275776201020302 0ustar williamwilliam%module enum_var %inline %{ enum Fruit { APPLE, PEAR }; Fruit test; %} swig-2.0.12/Examples/test-suite/class_scope_weird.i0000664000175000017500000000202612275776201022164 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-2.0.12/Examples/test-suite/enum_thorough_typesafe.i0000664000175000017500000000033612275776201023261 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-2.0.12/Examples/test-suite/li_std_multimap.i0000664000175000017500000000044512275776201021665 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-2.0.12/Examples/test-suite/clientdata_prop_b.i0000664000175000017500000000062512275776201022150 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-2.0.12/Examples/test-suite/typemap_self.i0000664000175000017500000000107212275776201021164 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-2.0.12/Examples/test-suite/struct_rename.i0000664000175000017500000000013512275776201021346 0ustar williamwilliam%module struct_rename %rename(Bar) Foo; %inline %{ typedef struct { int x; } Foo; %} swig-2.0.12/Examples/test-suite/li_std_containers_int.i0000664000175000017500000000027512275776201023055 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-2.0.12/Examples/test-suite/redefined.i0000664000175000017500000000304212275776201020420 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-2.0.12/Examples/test-suite/namespace_union.i0000664000175000017500000000213612275776201021642 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-2.0.12/Examples/test-suite/operbool.i0000664000175000017500000000022712275776201020316 0ustar williamwilliam%module operbool %rename(operator_bool) operator bool(); %inline %{ class Test { public: operator bool() { return false; } }; %} swig-2.0.12/Examples/test-suite/compactdefaultargs.i0000664000175000017500000000160312275776201022344 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-2.0.12/Examples/test-suite/memberin_extend.i0000664000175000017500000000122512275776201021641 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-2.0.12/Examples/test-suite/typedef_sizet.i0000664000175000017500000000015412275776201021352 0ustar williamwilliam%module typedef_sizet typedef unsigned long long size_t; %inline %{ size_t size(size_t x) {return x; } %} swig-2.0.12/Examples/test-suite/li_std_vector_enum.i0000664000175000017500000000062412275776201022362 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-2.0.12/Examples/test-suite/template_typedef_cplx5.i0000664000175000017500000000055712275776201023151 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-2.0.12/Examples/test-suite/typedef_class.i0000664000175000017500000000063612275776201021326 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-2.0.12/Examples/test-suite/java_throws.i0000664000175000017500000001174112275776201021027 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-2.0.12/Examples/test-suite/empty.i0000664000175000017500000000001612275776201017627 0ustar williamwilliam%module empty swig-2.0.12/Examples/test-suite/template_default_vw.i0000664000175000017500000000050112275776201022523 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-2.0.12/Examples/test-suite/li_std_string.i0000664000175000017500000000606612275776201021350 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-2.0.12/Examples/test-suite/clientdata_prop_b.h0000664000175000017500000000106412275776201022145 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-2.0.12/Examples/test-suite/li_std_stack.i0000664000175000017500000000015412275776201021137 0ustar williamwilliam// test of std::stack %module li_std_stack %include std_stack.i %template( IntStack ) std::stack< int >; swig-2.0.12/Examples/test-suite/namespace_template.i0000664000175000017500000000327212275776201022327 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-2.0.12/Examples/test-suite/typedef_struct.i0000664000175000017500000000130112275776201021533 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-2.0.12/Examples/test-suite/director_extend.i0000664000175000017500000000227712275776201021666 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-2.0.12/Examples/test-suite/implicittest.i0000664000175000017500000000366112275776201021214 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-2.0.12/Examples/test-suite/memberin_extend_c.i0000664000175000017500000000116612275776201022147 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-2.0.12/Examples/test-suite/common.mk0000664000175000017500000003753612275776201020161 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 = $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/ # # 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 \ overload_complicated \ template_default_pointer \ template_expr # 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_rename \ enum_scope_template \ enum_template \ enum_thorough \ enum_var \ 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_carrays \ li_cdata \ li_cpointer \ li_stdint \ 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 \ nested_class \ nested_comment \ nested_workaround \ newobject1 \ null_pointer \ operator_overload \ operator_overload_break \ operator_pointer_ref \ operbool \ ordering \ 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 \ 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_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_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_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 \ 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 \ 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 # # 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 # C test cases. (Can be run individually using: make testcase.ctest) C_TEST_CASES += \ arrays \ bom_utf8 \ char_constant \ const_const \ constant_expr \ empty \ enums \ enum_forward \ enum_macro \ extern_declaration \ funcptr \ function_typedef \ immutable_values \ inctest \ integers \ keyword_rename \ lextype \ li_carrays \ li_cdata \ li_cmalloc \ li_constraints \ li_cpointer \ li_math \ long_long \ memberin_extend_c \ name \ nested \ 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 \ 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) ####################################################################### # The following applies for all module languages ####################################################################### all: $(BROKEN_TEST_CASES) $(NOT_BROKEN_TEST_CASES) check: $(NOT_BROKEN_TEST_CASES) # 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 broken: $(BROKEN_TEST_CASES) swig_and_compile_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile 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 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 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 \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ TARGET="$*_wrap_hdr.h" \ $(LANGUAGE)$(VARIANT)_externalhdr; \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ else \ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; ####################################################################### # Clean ####################################################################### clean: $(ALL_CLEAN) distclean: clean @rm -f Makefile .PHONY: all check partialcheck broken clean distclean swig-2.0.12/Examples/test-suite/simutry.i0000664000175000017500000000300712275776201020210 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-2.0.12/Examples/test-suite/arrayref.i0000664000175000017500000000022012275776201020301 0ustar williamwilliam// A function that passes arrays by reference %module arrayref %inline %{ void foo(const int (&x)[10]) { } void bar(int (&x)[10]) { } %} swig-2.0.12/Examples/test-suite/multi_import_c.i0000664000175000017500000000004612275776201021522 0ustar williamwilliamclass XXX { public: int testx(); }; swig-2.0.12/Examples/test-suite/multi_import.h0000664000175000017500000000026512275776201021222 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-2.0.12/Examples/test-suite/li_attribute_template.i0000664000175000017500000000434712275776201023066 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-2.0.12/Examples/test-suite/li_math.i0000664000175000017500000000026612275776201020115 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-2.0.12/Examples/test-suite/template_arg_replace.i0000664000175000017500000000046212275776201022635 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-2.0.12/Examples/test-suite/template_specialization_defarg.i0000664000175000017500000000220012275776201024707 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-2.0.12/Examples/test-suite/threads_exception.i0000664000175000017500000000211212275776201022200 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-2.0.12/Examples/test-suite/ordering.i0000664000175000017500000000065512275776201020313 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-2.0.12/Examples/test-suite/java_lib_arrays.i0000664000175000017500000000353712275776201021634 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) 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-2.0.12/Examples/test-suite/lua/newobject1_runme.lua0000664000175000017500000000066412275776201023063 0ustar williamwilliamrequire("import") -- the import fn import("newobject1") -- import code foo1 = newobject1.Foo_makeFoo() -- lua doesnt yet support static fns properly assert(newobject1.Foo_fooCount() == 1) -- lua doesnt yet support static fns properly 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-2.0.12/Examples/test-suite/lua/dynamic_cast_runme.lua0000664000175000017500000000060212275776201023450 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-2.0.12/Examples/test-suite/lua/li_std_string_runme.lua0000664000175000017500000001020112275776201023652 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-2.0.12/Examples/test-suite/lua/enums_runme.lua0000664000175000017500000000122412275776201022142 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) -- no point in checking fns, C will allow any value swig-2.0.12/Examples/test-suite/lua/voidtest_runme.lua0000664000175000017500000000142412275776201022656 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-2.0.12/Examples/test-suite/lua/overload_simple_runme.lua0000664000175000017500000000232312275776201024200 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-2.0.12/Examples/test-suite/lua/overload_template_runme.lua0000664000175000017500000000436712275776201024534 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-2.0.12/Examples/test-suite/lua/operator_overload_runme.lua0000664000175000017500000000556412275776201024554 0ustar williamwilliam-- demo of lua swig capacilities (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: skiping -- 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++ expectes 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)") --[[ /* 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-2.0.12/Examples/test-suite/lua/lua_no_module_global_runme.lua0000664000175000017500000000155512275776201025164 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-2.0.12/Examples/test-suite/lua/member_pointer_runme.lua0000664000175000017500000000215012275776201024021 0ustar williamwilliam--Example using pointers to member functions require("import") -- the import fn import("member_pointer") -- import code for k,v in pairs(member_pointer) do _G[k]=v end function check(what, expected, actual) assert(expected == actual,"Failed: "..what.." Expected: "..expected.." Actual: "..actual) 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)) -- Try the variables -- these have to still be part of the 'member_pointer' table memberPtr = member_pointer.areavar memberPtr = member_pointer.perimetervar check ("Square area ", 100.0, do_op(s,member_pointer.areavar)) check ("Square perim", 40.0, do_op(s,member_pointer.perimetervar)) -- Modify one of the variables member_pointer.areavar = perim_pt check ("Square perimeter", 40.0, do_op(s,member_pointer.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-2.0.12/Examples/test-suite/lua/disown_runme.lua0000664000175000017500000000105412275776201022317 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-2.0.12/Examples/test-suite/lua/multi_import_runme.lua0000664000175000017500000000073312275776201023543 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-2.0.12/Examples/test-suite/lua/li_typemaps_runme.lua0000664000175000017500000000247512275776201023352 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-2.0.12/Examples/test-suite/lua/exception_order_runme.lua0000664000175000017500000000223712275776201024211 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-2.0.12/Examples/test-suite/lua/Makefile.in0000664000175000017500000000312712275776201021153 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra lua code) %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile 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-2.0.12/Examples/test-suite/lua/smart_pointer_overload_runme.lua0000664000175000017500000000066112275776201025600 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-2.0.12/Examples/test-suite/lua/import.lua0000664000175000017500000000152012275776201021116 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 verion 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: initalising 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 endswig-2.0.12/Examples/test-suite/lua/imports_runme.lua0000664000175000017500000000202312275776201022506 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-2.0.12/Examples/test-suite/lua/char_strings_runme.lua0000664000175000017500000000065512275776201023510 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-2.0.12/Examples/test-suite/lua/pointer_reference_runme.lua0000664000175000017500000000053412275776201024514 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-2.0.12/Examples/test-suite/mzscheme/0000775000175000017500000000000012275776201020135 5ustar williamwilliamswig-2.0.12/Examples/test-suite/mzscheme/README0000664000175000017500000000020712275776201021014 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.scm appended after the testcase name will be detected and run. swig-2.0.12/Examples/test-suite/mzscheme/char_constant_runme.scm0000664000175000017500000000020012275776201024665 0ustar williamwilliam(load-extension "char_constant.so") (if (and (char? (CHAR-CONSTANT)) (string? (STRING-CONSTANT))) (exit 0) (exit 1)) swig-2.0.12/Examples/test-suite/mzscheme/unions_runme.scm0000664000175000017500000000211712275776201023363 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-2.0.12/Examples/test-suite/mzscheme/imports_runme.scm0000664000175000017500000000074412275776201023551 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-2.0.12/Examples/test-suite/mzscheme/name_runme.scm0000664000175000017500000000040312275776201022764 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-2.0.12/Examples/test-suite/mzscheme/casts_runme.scm0000664000175000017500000000011312275776201023157 0ustar williamwilliam(load-extension "casts.so") (define x (new-B)) (A-hello x) (exit 0) swig-2.0.12/Examples/test-suite/mzscheme/integers_runme.scm0000664000175000017500000000032712275776201023671 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-2.0.12/Examples/test-suite/mzscheme/Makefile.in0000664000175000017500000000215112275776201022201 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile mzscheme_clean swig-2.0.12/Examples/test-suite/chicken_ext_test.i0000664000175000017500000000071712275776201022024 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-2.0.12/Examples/test-suite/template_methods.i0000664000175000017500000000551612275776201022041 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-2.0.12/Examples/test-suite/java_enums.i0000664000175000017500000000323412275776201020626 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-2.0.12/Examples/test-suite/namespace_class.i0000664000175000017500000001071312275776201021617 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 { }; } } %} // %copyctor doesn't work with nested class workaround %nocopyctor; %inline %{ class Ala { public : Ala() {} class Ola { public: Ola() {} void eek() {} }; template static void hi() { } }; %} %rename(Ala__Ola) Ala::Ola; class Ala::Ola { public: Ola() {} void eek() {} }; %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-2.0.12/Examples/test-suite/template_enum_ns_inherit.i0000664000175000017500000000164412275776201023562 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-2.0.12/Examples/test-suite/nested.i0000664000175000017500000000174012275776201017760 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-2.0.12/Examples/test-suite/destructor_reprotected.i0000664000175000017500000000044312275776201023273 0ustar williamwilliam%module destructor_reprotected %inline { struct A { A() { } virtual ~A() { } }; struct B : A { protected: B() { } ~B() { } }; struct C : B { C() { } ~C() { } }; } swig-2.0.12/Examples/test-suite/director_protected.i0000664000175000017500000000411212275776201022356 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-2.0.12/Examples/test-suite/li_factory.i0000664000175000017500000000203312275776201020625 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-2.0.12/Examples/test-suite/li_std_string_extra.i0000664000175000017500000000152512275776201022546 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-2.0.12/Examples/test-suite/template_specialization_enum.i0000664000175000017500000000171012275776201024430 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-2.0.12/Examples/test-suite/preproc_include_b.h0000664000175000017500000000014612275776201022152 0ustar williamwilliam int multiply20(int a); #define PREPROC_INCLUDE_C "preproc_include_c.h" #include PREPROC_INCLUDE_C swig-2.0.12/Examples/test-suite/argout.i0000664000175000017500000000144612275776201020002 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-2.0.12/Examples/test-suite/ocaml/0000775000175000017500000000000012275776201017415 5ustar williamwilliamswig-2.0.12/Examples/test-suite/ocaml/minherit_runme.ml0000664000175000017500000000720712275776201023002 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-2.0.12/Examples/test-suite/ocaml/README0000664000175000017500000000020612275776201020273 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-2.0.12/Examples/test-suite/ocaml/class_ignore_runme.ml0000664000175000017500000000024112275776201023622 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-2.0.12/Examples/test-suite/ocaml/typedef_mptr_runme.ml0000664000175000017500000000075512275776201023666 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-2.0.12/Examples/test-suite/ocaml/overload_copy_runme.ml0000664000175000017500000000011112275776201024013 0ustar williamwilliamopen Swig open Overload_copy let f = new_Foo C_void let g = new_Foo f swig-2.0.12/Examples/test-suite/ocaml/voidtest_runme.ml0000664000175000017500000000023112275776201023012 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-2.0.12/Examples/test-suite/ocaml/unions_runme.ml0000664000175000017500000000203112275776201022464 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-2.0.12/Examples/test-suite/ocaml/varargs_runme.ml0000664000175000017500000000043412275776201022623 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-2.0.12/Examples/test-suite/ocaml/makedebugtop0000775000175000017500000000101012275776201022002 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-2.0.12/Examples/test-suite/ocaml/throw_exception_runme.ml0000664000175000017500000000135512275776201024402 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-2.0.12/Examples/test-suite/ocaml/newobject1_runme.ml0000664000175000017500000000144212275776201023217 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-2.0.12/Examples/test-suite/ocaml/using_protected_runme.ml0000664000175000017500000000026512275776201024356 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-2.0.12/Examples/test-suite/ocaml/typename_runme.ml0000664000175000017500000000047112275776201023001 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-2.0.12/Examples/test-suite/ocaml/imports_runme.ml0000664000175000017500000000042412275776201022652 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-2.0.12/Examples/test-suite/ocaml/name_runme.ml0000664000175000017500000000020012275776201022065 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-2.0.12/Examples/test-suite/ocaml/Makefile.in0000664000175000017500000000422612275776201021466 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(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 ocaml_clean swig-2.0.12/Examples/test-suite/ocaml/sneaky1_runme.ml0000664000175000017500000000041712275776201022532 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-2.0.12/Examples/test-suite/li_boost_intrusive_ptr.i0000664000175000017500000004611212275776201023307 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. %module li_boost_intrusive_ptr %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived; %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived; %{ template void intrusive_ptr_add_ref(const T* r) { r->addref(); } template void intrusive_ptr_release(const T* r) { r->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; } 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; } 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; } }; %} %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-2.0.12/Examples/test-suite/smart_pointer_overload.i0000664000175000017500000000076112275776201023261 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-2.0.12/Examples/test-suite/keyword_rename.i0000664000175000017500000000072512275776201021513 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) %} swig-2.0.12/Examples/test-suite/abstract_typedef2.i0000664000175000017500000000163712275776201022110 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-2.0.12/Examples/test-suite/overload_template.i0000664000175000017500000001266412275776201022213 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-2.0.12/Examples/test-suite/typemap_namespace.i0000664000175000017500000000243412275776201022172 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-2.0.12/Examples/test-suite/static_const_member.i0000664000175000017500000000102512275776201022516 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-2.0.12/Examples/test-suite/stl_new.i0000664000175000017500000000163012275776201020147 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-2.0.12/Examples/test-suite/smart_pointer_simple.i0000664000175000017500000000031512275776201022732 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-2.0.12/Examples/test-suite/rename.h0000664000175000017500000000200112275776201017733 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-2.0.12/Examples/test-suite/mod.list0000664000175000017500000000001412275776201017771 0ustar williamwilliammod_a mod_b swig-2.0.12/Examples/test-suite/template_array_numeric.i0000664000175000017500000000054512275776201023233 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-2.0.12/Examples/test-suite/li_boost_shared_ptr_bits.i0000664000175000017500000000507712275776201023553 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-2.0.12/Examples/test-suite/nspace_extend.i0000664000175000017500000000264512275776201021323 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) #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-2.0.12/Examples/test-suite/template_default_qualify.i0000664000175000017500000000175312275776201023553 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-2.0.12/Examples/test-suite/contract.i0000664000175000017500000000714312275776201020316 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-2.0.12/Examples/test-suite/template_rename.i0000664000175000017500000000163012275776201021636 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-2.0.12/Examples/test-suite/preproc_include_g.h0000664000175000017500000000003112275776201022150 0ustar williamwilliam int multiply70(int a); swig-2.0.12/Examples/test-suite/overload_method.i0000664000175000017500000000050012275776201021642 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-2.0.12/Examples/test-suite/typedef_mptr.i0000664000175000017500000000161012275776201021174 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-2.0.12/Examples/test-suite/template_nested_typemaps.i0000664000175000017500000000242612275776201023577 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-2.0.12/Examples/test-suite/abstract_signature.i0000664000175000017500000000107012275776201022356 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-2.0.12/Examples/test-suite/prefix.i0000664000175000017500000000026212275776201017771 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-2.0.12/Examples/test-suite/special_variables.i0000664000175000017500000000601612275776201022147 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-2.0.12/Examples/test-suite/using1.i0000664000175000017500000000050512275776201017702 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-2.0.12/Examples/test-suite/default_arg_values.i0000664000175000017500000000121112275776201022323 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-2.0.12/Examples/test-suite/template_construct.i0000664000175000017500000000033412275776201022413 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-2.0.12/Examples/test-suite/template_typemaps_typedef2.i0000664000175000017500000001004212275776201024030 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-2.0.12/Examples/test-suite/rename_pcre_encoder.i0000664000175000017500000000120412275776201022450 0ustar williamwilliam%module rename_pcre_encoder // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // Replace "Set" and "Get" prefixes with "put" and "get" respectively. %rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) ""; %rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) ""; %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 { }; %} swig-2.0.12/Examples/test-suite/template_default_arg.i0000664000175000017500000000744312275776201022654 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-2.0.12/Examples/test-suite/enum_thorough_typeunsafe.i0000664000175000017500000000030712275776201023622 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-2.0.12/Examples/test-suite/uffi/0000775000175000017500000000000012275776201017253 5ustar williamwilliamswig-2.0.12/Examples/test-suite/uffi/Makefile.in0000664000175000017500000000231012275776201021314 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra uffi code) %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile uffi_clean swig-2.0.12/Examples/test-suite/overload_extend.i0000664000175000017500000000177212275776201021665 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-2.0.12/Examples/test-suite/global_namespace.i0000664000175000017500000000437012275776201021754 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-2.0.12/Examples/test-suite/template_inherit_abstract.i0000664000175000017500000000271412275776201023720 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-2.0.12/Examples/test-suite/valuewrapper_const.i0000664000175000017500000000106112275776201022415 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-2.0.12/Examples/test-suite/template_typedef_ns.i0000664000175000017500000000040112275776201022522 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-2.0.12/Examples/test-suite/preproc_include_f withspace.h0000664000175000017500000000003112275776201024117 0ustar williamwilliam int multiply60(int a); swig-2.0.12/Examples/test-suite/enums.i0000664000175000017500000000332212275776201017623 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-2.0.12/Examples/test-suite/csharp/0000775000175000017500000000000012275776201017602 5ustar williamwilliamswig-2.0.12/Examples/test-suite/csharp/overload_complicated_runme.cs0000664000175000017500000000257412275776201025526 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-2.0.12/Examples/test-suite/csharp/rename_simple_runme.cs0000664000175000017500000000203412275776201024156 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-2.0.12/Examples/test-suite/csharp/long_long_runme.cs0000664000175000017500000000203412275776201023314 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-2.0.12/Examples/test-suite/csharp/director_classic_runme.cs0000664000175000017500000001432412275776201024657 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-2.0.12/Examples/test-suite/csharp/README0000664000175000017500000000340312275776201020462 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-2.0.12/Examples/test-suite/csharp/inherit_target_language_runme.cs0000664000175000017500000000116212275776201026212 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-2.0.12/Examples/test-suite/csharp/enum_thorough_simple_runme.cs0000664000175000017500000010546512275776201025606 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-2.0.12/Examples/test-suite/csharp/aggregate_runme.cs0000664000175000017500000000154712275776201023274 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-2.0.12/Examples/test-suite/csharp/csharp_exceptions_runme.cs0000664000175000017500000003370212275776201025065 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-2.0.12/Examples/test-suite/csharp/director_basic_runme.cs0000664000175000017500000000305312275776201024314 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-2.0.12/Examples/test-suite/csharp/csharp_attributes_runme.cs0000664000175000017500000002705712275776201025100 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-2.0.12/Examples/test-suite/csharp/sneaky1_runme.cs0000664000175000017500000000073212275776201022714 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-2.0.12/Examples/test-suite/csharp/director_ignore_runme.cs0000664000175000017500000000332212275776201024515 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-2.0.12/Examples/test-suite/csharp/special_variable_macros_runme.cs0000664000175000017500000000173012275776201026171 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-2.0.12/Examples/test-suite/csharp/sizet_runme.cs0000664000175000017500000000043312275776201022475 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-2.0.12/Examples/test-suite/csharp/li_std_except_runme.cs0000664000175000017500000000303112275776201024162 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-2.0.12/Examples/test-suite/csharp/director_nspace_runme.cs0000664000175000017500000000141212275776201024501 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-2.0.12/Examples/test-suite/csharp/typemap_out_optimal_runme.cs0000664000175000017500000000031312275776201025427 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-2.0.12/Examples/test-suite/csharp/li_attribute_runme.cs0000664000175000017500000000432012275776201024025 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-2.0.12/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs0000664000175000017500000011122712275776201026126 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-2.0.12/Examples/test-suite/csharp/overload_template_runme.cs0000664000175000017500000001164312275776201025052 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-2.0.12/Examples/test-suite/csharp/imports_runme.cs0000664000175000017500000000105512275776201023035 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-2.0.12/Examples/test-suite/csharp/csharp_typemaps_runme.cs0000664000175000017500000000705212275776201024545 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-2.0.12/Examples/test-suite/chicken/README0000664000175000017500000000126112275776201020606 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-2.0.12/Examples/test-suite/chicken/global_vars_runme_proxy.ss0000664000175000017500000000010512275776201025233 0ustar williamwilliam(require 'global_vars) (load "../schemerunme/global_vars_proxy.scm") swig-2.0.12/Examples/test-suite/chicken/testsuite.ss0000664000175000017500000000103412275776201022324 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-2.0.12/Examples/test-suite/chicken/li_std_string_runme_proxy.ss0000664000175000017500000000257612275776201025622 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-2.0.12/Examples/test-suite/chicken/newobject1_runme_proxy.ss0000664000175000017500000000057712275776201025016 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-2.0.12/Examples/test-suite/chicken/char_constant_runme.ss0000664000175000017500000000010712275776201024327 0ustar williamwilliam(load "char_constant.so") (include "../schemerunme/char_constant.scm") swig-2.0.12/Examples/test-suite/chicken/newobject2_runme.ss0000664000175000017500000000072212275776201023546 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-2.0.12/Examples/test-suite/chicken/cpp_enum_runme.ss0000664000175000017500000000007512275776201023313 0ustar williamwilliam(load "cpp_enum.so") (include "../schemerunme/cpp_enum.scm") swig-2.0.12/Examples/test-suite/chicken/overload_simple_runme.ss0000664000175000017500000000011312275776201024662 0ustar williamwilliam(load "overload_simple.so") (include "../schemerunme/overload_simple.scm") swig-2.0.12/Examples/test-suite/chicken/overload_simple_runme_proxy.ss0000664000175000017500000000321512275776201026131 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-2.0.12/Examples/test-suite/chicken/overload_copy_runme.ss0000664000175000017500000000010712275776201024346 0ustar williamwilliam(load "overload_copy.so") (include "../schemerunme/overload_copy.scm") swig-2.0.12/Examples/test-suite/chicken/typedef_inherit_runme.ss0000664000175000017500000000011312275776201024660 0ustar williamwilliam(load "typedef_inherit.so") (include "../schemerunme/typedef_inherit.scm") swig-2.0.12/Examples/test-suite/chicken/inherit_missing_runme.ss0000664000175000017500000000011312275776201024671 0ustar williamwilliam(load "inherit_missing.so") (include "../schemerunme/inherit_missing.scm") swig-2.0.12/Examples/test-suite/chicken/contract_runme.ss0000664000175000017500000000012612275776201023317 0ustar williamwilliam(load "contract.so") (include "testsuite.ss") (include "../schemerunme/contract.scm") swig-2.0.12/Examples/test-suite/chicken/global_vars_runme.ss0000664000175000017500000000007712275776201024002 0ustar williamwilliam(require 'global_vars) (load "../schemerunme/global_vars.scm") swig-2.0.12/Examples/test-suite/chicken/multivalue_runme.ss0000664000175000017500000000014612275776201023673 0ustar williamwilliam;; this doesn't work yet :( (load "multivalue.so") (include "../schemerunme/multivalue.scm") (exit 0) swig-2.0.12/Examples/test-suite/chicken/list_vector_runme.ss0000664000175000017500000000010312275776201024032 0ustar williamwilliam(load "list_vector.so") (include "../schemerunme/list_vector.scm") swig-2.0.12/Examples/test-suite/chicken/dynamic_cast_runme.ss0000664000175000017500000000010512275776201024135 0ustar williamwilliam(load "dynamic_cast.so") (include "../schemerunme/dynamic_cast.scm") swig-2.0.12/Examples/test-suite/chicken/newobject2_runme_proxy.ss0000664000175000017500000000073712275776201025015 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-2.0.12/Examples/test-suite/chicken/overload_extend_runme_proxy.ss0000664000175000017500000000037212275776201026130 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-2.0.12/Examples/test-suite/chicken/throw_exception_runme.ss0000664000175000017500000000211312275776201024721 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-2.0.12/Examples/test-suite/chicken/name_runme.ss0000664000175000017500000000006512275776201022424 0ustar williamwilliam(load "name.so") (include "../schemerunme/name.scm") swig-2.0.12/Examples/test-suite/chicken/casts_runme.ss0000664000175000017500000000006712275776201022623 0ustar williamwilliam(load "casts.so") (include "../schemerunme/casts.scm") swig-2.0.12/Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss0000664000175000017500000000012712275776201027150 0ustar williamwilliam(require 'multiple_inheritance) (load "../schemerunme/multiple_inheritance_proxy.scm") swig-2.0.12/Examples/test-suite/chicken/overload_subtype_runme.ss0000664000175000017500000000011512275776201025066 0ustar williamwilliam(load "overload_subtype.so") (include "../schemerunme/overload_subtype.scm") swig-2.0.12/Examples/test-suite/chicken/cpp_namespace_runme.ss0000664000175000017500000000010712275776201024277 0ustar williamwilliam(load "cpp_namespace.so") (include "../schemerunme/cpp_namespace.scm") swig-2.0.12/Examples/test-suite/chicken/reference_global_vars_runme.ss0000664000175000017500000000012712275776201026014 0ustar williamwilliam(load "reference_global_vars.so") (include "../schemerunme/reference_global_vars.scm") swig-2.0.12/Examples/test-suite/chicken/overload_copy_runme_proxy.ss0000664000175000017500000000013112275776201025604 0ustar williamwilliam(load "./overload_copy.so") (define f (make )) (define g (make f)) (exit 0) swig-2.0.12/Examples/test-suite/chicken/li_typemaps_runme.ss0000664000175000017500000000056112275776201024033 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-2.0.12/Examples/test-suite/chicken/typename_runme.ss0000664000175000017500000000007512275776201023327 0ustar williamwilliam(load "typename.so") (include "../schemerunme/typename.scm") swig-2.0.12/Examples/test-suite/chicken/cpp_basic_runme_proxy.ss0000664000175000017500000000351112275776201024667 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-2.0.12/Examples/test-suite/chicken/unions_runme_proxy.ss0000664000175000017500000000007712275776201024263 0ustar williamwilliam(load "unions.so") (include "../schemerunme/unions_proxy.scm") swig-2.0.12/Examples/test-suite/chicken/li_std_string_runme.ss0000664000175000017500000000010712275776201024345 0ustar williamwilliam(load "li_std_string.so") (include "../schemerunme/li_std_string.scm") swig-2.0.12/Examples/test-suite/chicken/unions_runme.ss0000664000175000017500000000007112275776201023014 0ustar williamwilliam(load "unions.so") (include "../schemerunme/unions.scm") swig-2.0.12/Examples/test-suite/chicken/chicken_ext_test_external.cxx0000664000175000017500000000077712275776201025712 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-2.0.12/Examples/test-suite/chicken/overload_extend_runme.ss0000664000175000017500000000011312275776201024660 0ustar williamwilliam(load "overload_extend.so") (include "../schemerunme/overload_extend.scm") swig-2.0.12/Examples/test-suite/chicken/li_typemaps_runme_proxy.ss0000664000175000017500000000057212275776201025276 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-2.0.12/Examples/test-suite/chicken/class_ignore_runme.ss0000664000175000017500000000010512275776201024147 0ustar williamwilliam(load "class_ignore.so") (include "../schemerunme/class_ignore.scm") swig-2.0.12/Examples/test-suite/chicken/chicken_ext_test_runme.ss0000664000175000017500000000010412275776201025021 0ustar williamwilliam(load "chicken_ext_test.so") (define a (test-create)) (A-hello a) swig-2.0.12/Examples/test-suite/chicken/pointer_in_out_runme.ss0000664000175000017500000000011112275776201024531 0ustar williamwilliam(load "pointer_in_out.so") (include "../schemerunme/pointer_in_out.scm") swig-2.0.12/Examples/test-suite/chicken/overload_subtype_runme_proxy.ss0000664000175000017500000000030212275776201026325 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-2.0.12/Examples/test-suite/chicken/member_pointer_runme.ss0000664000175000017500000000142212275776201024511 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-2.0.12/Examples/test-suite/chicken/Makefile.in0000664000175000017500000000476012275776201022002 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 $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.cppproxy; \ fi %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.cproxy; \ fi %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.multiproxy; \ fi %.externaltest: $(setup) +$(swig_and_compile_external) $(run_testcase) %.cppproxy: echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" +$(swig_and_compile_cpp) $(run_testcase) %.cproxy: echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" +$(swig_and_compile_c) $(run_testcase) %.multiproxy: echo "$(ACTION)ing testcase $* (with run test) under chicken 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile chicken_clean rm -f *.scm swig-2.0.12/Examples/test-suite/chicken/import_nomodule_runme.ss0000664000175000017500000000011312275776201024712 0ustar williamwilliam(load "import_nomodule.so") (include "../schemerunme/import_nomodule.scm") swig-2.0.12/Examples/test-suite/chicken/constover_runme.ss0000664000175000017500000000007712275776201023531 0ustar williamwilliam(load "constover.so") (include "../schemerunme/constover.scm") swig-2.0.12/Examples/test-suite/chicken/imports_runme.ss0000664000175000017500000000012312275776201023174 0ustar williamwilliam(load "imports_a.so") (load "imports_b.so") (include "../schemerunme/imports.scm") swig-2.0.12/Examples/test-suite/chicken/overload_complicated_runme.ss0000664000175000017500000000012512275776201025660 0ustar williamwilliam(load "overload_complicated.so") (include "../schemerunme/overload_complicated.scm") swig-2.0.12/Examples/test-suite/valuewrapper.i0000664000175000017500000000036212275776201021212 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-2.0.12/Examples/test-suite/throw_exception.i0000664000175000017500000000346112275776201021721 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-2.0.12/Examples/test-suite/typemap_global_scope.i0000664000175000017500000002041612275776201022667 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-2.0.12/Examples/test-suite/template_typedef_cplx.i0000664000175000017500000001115412275776201023057 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-2.0.12/Examples/test-suite/primitive_ref.i0000664000175000017500000000123312275776201021337 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-2.0.12/Examples/test-suite/inherit_target_language.i0000664000175000017500000000511612275776201023352 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-2.0.12/Examples/test-suite/return_const_value.i0000664000175000017500000000160112275776201022413 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-2.0.12/Examples/test-suite/java_pragmas.i0000664000175000017500000000252112275776201021127 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-2.0.12/Examples/test-suite/inctest.i0000664000175000017500000000120612275776201020144 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-2.0.12/Examples/test-suite/director_protected_overloaded.i0000664000175000017500000000076012275776201024567 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-2.0.12/Examples/test-suite/using_directive_and_declaration.i0000664000175000017500000000341712275776201025053 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-2.0.12/Examples/test-suite/director_exception.i0000664000175000017500000000341712275776201022372 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 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-2.0.12/Examples/test-suite/name_warnings.i0000664000175000017500000000245312275776201021330 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-2.0.12/Examples/test-suite/lua_no_module_global.i0000664000175000017500000000015012275776201022632 0ustar williamwilliam%module lua_no_module_global %{ const char *hi_mom() { return "hi mom!"; } %} const char *hi_mom(); swig-2.0.12/Examples/test-suite/smart_pointer_namespace2.i0000664000175000017500000000201412275776201023455 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-2.0.12/Examples/test-suite/simple_array.i0000664000175000017500000000102612275776201021162 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-2.0.12/Examples/test-suite/li_std_combinations.i0000664000175000017500000000151512275776201022521 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-2.0.12/Examples/test-suite/extern_declaration.i0000664000175000017500000000151712275776201022352 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-2.0.12/Examples/test-suite/import_stl_b.i0000664000175000017500000000032412275776201021170 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-2.0.12/Examples/test-suite/template_extend_overload_2.i0000664000175000017500000000235112275776201023773 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-2.0.12/Examples/test-suite/li_typemaps_apply.i0000664000175000017500000000315512275776201022233 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-2.0.12/Examples/test-suite/operator_overload.i0000664000175000017500000002272412275776201022231 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++ equivilents __pow__ for power operator __str__ converts object to a string (should return a const char*) __concat__ for contatenation (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-2.0.12/Examples/test-suite/bools.i0000664000175000017500000000227112275776201017614 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-2.0.12/Examples/test-suite/extend.i0000664000175000017500000000154412275776201017767 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-2.0.12/Examples/test-suite/packageoption_a.i0000664000175000017500000000026512275776201021623 0ustar williamwilliam%module(package="CommonPackage") "packageoption_a"; %inline %{ class A { public: int testInt() { return 2;} }; %} %{ #include "packageoption.h" %} %include "packageoption.h" swig-2.0.12/Examples/test-suite/director_string.i0000664000175000017500000000177312275776201021705 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-2.0.12/Examples/test-suite/li_std_carray.i0000664000175000017500000000023012275776201021306 0ustar williamwilliam%module li_std_carray %include %template(Vector3) std::carray; %template(Matrix3) std::carray, 3>; swig-2.0.12/Examples/test-suite/template_opaque.i0000664000175000017500000000127112275776201021662 0ustar williamwilliam%module template_opaque %include "std_vector.i" %{ namespace A { struct OpaqueStruct { }; } 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-2.0.12/Examples/test-suite/arrays_global.i0000664000175000017500000000337112275776201021321 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-2.0.12/Examples/test-suite/smart_pointer_templatevariables.i0000664000175000017500000000211512275776201025145 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-2.0.12/Examples/test-suite/long_long.i0000664000175000017500000000237412275776201020460 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-2.0.12/Examples/test-suite/template_typedef_inherit.i0000664000175000017500000000260412275776201023553 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-2.0.12/Examples/test-suite/python_nondynamic.i0000664000175000017500000000142112275776201022232 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-2.0.12/Examples/test-suite/namespace_nested.i0000664000175000017500000000256212275776201021777 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-2.0.12/Examples/test-suite/typemap_template_parm_typedef.i0000664000175000017500000000251312275776201024606 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-2.0.12/Examples/test-suite/li_std_pair_lang_object.i0000664000175000017500000000022212275776201023310 0ustar williamwilliam%module li_std_pair_lang_object %include namespace std { %template(ValuePair) pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; } swig-2.0.12/Examples/test-suite/ignore_parameter.i0000664000175000017500000000217512275776201022024 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-2.0.12/Examples/test-suite/cffi/0000775000175000017500000000000012275776201017231 5ustar williamwilliamswig-2.0.12/Examples/test-suite/cffi/Makefile.in0000664000175000017500000000231012275776201021272 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra cffi code) %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile cffi_clean swig-2.0.12/Examples/test-suite/typedef_funcptr.i0000664000175000017500000000103512275776201021674 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-2.0.12/Examples/test-suite/template_typedef_class_template.i0000664000175000017500000000310412275776201025105 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-2.0.12/Examples/test-suite/inherit_same_name.i0000664000175000017500000000050412275776201022142 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-2.0.12/Examples/test-suite/import_nomodule.h0000664000175000017500000000004412275776201021705 0ustar williamwilliamclass Foo { }; typedef int Integer; swig-2.0.12/Examples/test-suite/li_std_stream.i0000664000175000017500000000147112275776201021330 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-2.0.12/Examples/test-suite/mod_a.i0000664000175000017500000000027312275776201017555 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-2.0.12/Examples/test-suite/director_using.i0000664000175000017500000000234412275776201021517 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-2.0.12/Examples/test-suite/complextest.i0000664000175000017500000000150712275776201021046 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-2.0.12/Examples/test-suite/constructor_copy.i0000664000175000017500000000420712275776201022116 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) #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 { public: Flow(int i) {} }; class FlowFlow { public: FlowFlow(int 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-2.0.12/Examples/test-suite/li_attribute.i0000664000175000017500000000457612275776201021177 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-2.0.12/Examples/test-suite/pointer_in_out.i0000664000175000017500000000122712275776201021533 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-2.0.12/Examples/test-suite/nested_comment.i0000664000175000017500000000135112275776201021500 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-2.0.12/Examples/test-suite/refcount.i0000664000175000017500000000323512275776201020324 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-2.0.12/Examples/test-suite/smart_pointer_static.i0000664000175000017500000000057512275776201022740 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-2.0.12/Examples/test-suite/preproc_include.i0000664000175000017500000000226312275776201021654 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-2.0.12/Examples/test-suite/traits.i0000664000175000017500000000010412275776201017775 0ustar williamwilliam%module traits %include typemaps/traits.swg %fragment("Traits"); swig-2.0.12/Examples/test-suite/java_director_assumeoverride.i0000664000175000017500000000106212275776201024424 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-2.0.12/Examples/test-suite/overload_copy.i0000664000175000017500000000024112275776201021336 0ustar williamwilliam// Tests copy constructor %module overload_copy #ifndef SWIG_NO_OVERLOAD %inline %{ class Foo { public: Foo() { } Foo(const Foo &) { } }; %} #endif swig-2.0.12/Examples/test-suite/li_std_queue.i0000664000175000017500000000015412275776201021156 0ustar williamwilliam// test of std::queue %module li_std_queue %include std_queue.i %template( IntQueue ) std::queue< int >; swig-2.0.12/Examples/test-suite/extend_template.i0000664000175000017500000000055412275776201021662 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-2.0.12/Examples/test-suite/using_inherit.i0000664000175000017500000000174512275776201021352 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-2.0.12/Examples/test-suite/add_link.i0000664000175000017500000000020112275776201020232 0ustar williamwilliam%module add_link %extend Foo { Foo *blah() { return new Foo(); } }; %inline %{ class Foo { public: Foo() { }; }; %} swig-2.0.12/Examples/test-suite/template_using_directive_and_declaration_forward.i0000664000175000017500000000620112275776201030464 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; template class Thing1 {}; 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; template class Thing2 {}; 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; template class Thing3 {}; 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; template class Thing4 {}; 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; template class Thing5 {}; 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; template 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) {} } } %} %template(Thing1Int) Thing1; %template(Thing2Int) Thing2; %template(Thing3Int) Thing3; %template(Thing4Int) Thing4; %template(Thing5Int) Thing5; %template(Thing7Int) Thing7; swig-2.0.12/Examples/test-suite/csharp_prepost.i0000664000175000017500000001660412275776201021537 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="IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "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 { IntPtr cPtr = $imcall; CDate tempDate = (cPtr == 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-2.0.12/Examples/test-suite/smart_pointer_inherit.i0000664000175000017500000000371312275776201023110 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 { }; %} #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-2.0.12/Examples/test-suite/mixed_types.i0000664000175000017500000000633412275776201021034 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-2.0.12/Examples/test-suite/long_long_apply.i0000664000175000017500000000506512275776201021665 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-2.0.12/Examples/test-suite/java_director.i0000664000175000017500000000527412275776201021320 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-2.0.12/Examples/test-suite/java_constants.i0000664000175000017500000000121712275776201021512 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-2.0.12/Examples/test-suite/preproc_defined.i0000664000175000017500000000337612275776201021635 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-2.0.12/Examples/test-suite/ruby_keywords.i0000664000175000017500000000413312275776201021405 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-2.0.12/Examples/test-suite/template_nested.i0000664000175000017500000000712012275776201021651 0ustar williamwilliam%module template_nested // Test nested templates - that is template classes and template methods within a class. %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterClass::Inner1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterClass::Inner2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate3; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedStruct; 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) {} }; 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; } 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; } }; } %} %template(T_NormalTemplateNormalClass) ns::NormalTemplate; %template(T_OuterTMethodNormalClass) ns::OuterClass::InnerTMethod; %template(T_TemplateFuncs1Int) ns::TemplateFuncs::templateMethod1; %template(T_TemplateFuncs2Double) ns::TemplateFuncs::templateMethod2; %template(T_NestedOuterTemplateDouble) ns::OuterTemplate; swig-2.0.12/Examples/test-suite/expressions.i0000664000175000017500000000020712275776201021055 0ustar williamwilliam%module expressions %inline %{ struct A { A() : k( 20/(5-1) ) {} A(int i) : k( 20/(5-1)*i /* comment */ ) {} int k; }; %} swig-2.0.12/Examples/test-suite/inplaceadd.i0000664000175000017500000000067612275776201020571 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-2.0.12/Examples/test-suite/valuewrapper_base.i0000664000175000017500000000103612275776201022203 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-2.0.12/Examples/test-suite/sym.i0000664000175000017500000000073112275776201017305 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-2.0.12/Examples/test-suite/errors/0000775000175000017500000000000012275776201017636 5ustar williamwilliamswig-2.0.12/Examples/test-suite/errors/cpp_private_defvalue.i0000664000175000017500000000013112275776201024172 0ustar williamwilliam%module xxx class foo { static const int BAR = 42; public: int blah(int x = BAR); }; swig-2.0.12/Examples/test-suite/errors/swig_identifier.i0000664000175000017500000000007312275776201023163 0ustar williamwilliam%module xxx %rename("foo bar") foobar; int foobar(int); swig-2.0.12/Examples/test-suite/errors/c_bad_name.i0000664000175000017500000000003712275776201022040 0ustar williamwilliam%module xxx %name() int foo; swig-2.0.12/Examples/test-suite/errors/cpp_using_not.i0000664000175000017500000000006212275776201022655 0ustar williamwilliam%module xxx int blah; using namespace blah; swig-2.0.12/Examples/test-suite/errors/cpp_missing_rtemplate.i0000664000175000017500000000005212275776201024375 0ustar williamwilliam%module xxx int foo(vector; swig-2.0.12/Examples/test-suite/errors/cpp_private_inherit.i0000664000175000017500000000013412275776201024044 0ustar williamwilliam%module xxx class Foo { }; class Bar : private Foo { }; class Spam : protected Foo { }; swig-2.0.12/Examples/test-suite/errors/c_extra_rblock.i0000664000175000017500000000004412275776201022767 0ustar williamwilliam%module xxx int foo(int x); %} swig-2.0.12/Examples/test-suite/errors/pp_missing_file.i0000664000175000017500000000005412275776201023156 0ustar williamwilliam%module test %include "missing_filename.i" swig-2.0.12/Examples/test-suite/errors/swig_typemap_copy.i0000664000175000017500000000004612275776201023552 0ustar williamwilliam%module xxx %typemap(in) int = blah; swig-2.0.12/Examples/test-suite/errors/cpp_overload_const.i0000664000175000017500000000046412275776201023677 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-2.0.12/Examples/test-suite/errors/pp_macro_rparen.i0000664000175000017500000000004512275776201023156 0ustar williamwilliam%module xxx #define foo(a,x 3 swig-2.0.12/Examples/test-suite/errors/pp_pragma.i0000664000175000017500000000004712275776201021757 0ustar williamwilliam%module xxx #pragma SWIG rubbish() swig-2.0.12/Examples/test-suite/errors/c_deprecated.i0000664000175000017500000000006512275776201022413 0ustar williamwilliam%module xxx int foo(%val int *x, %out int *y); swig-2.0.12/Examples/test-suite/errors/pp_macro_badchar.i0000664000175000017500000000010212275776201023245 0ustar williamwilliam%module xxx #define f@oo(a,x) a + x #define foo(a@,x) a + x swig-2.0.12/Examples/test-suite/errors/pp_unterm_char.i0000664000175000017500000000004312275776201023013 0ustar williamwilliam%module xxx const char x = 'H swig-2.0.12/Examples/test-suite/errors/cpp_inherit.i0000664000175000017500000000102212275776201022307 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-2.0.12/Examples/test-suite/errors/pp_macro_missing_expression.i0000664000175000017500000000026112275776201025617 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-2.0.12/Examples/test-suite/errors/c_class.i0000664000175000017500000000004412275776201021415 0ustar williamwilliam%module xxx int class(int x); swig-2.0.12/Examples/test-suite/errors/c_default_error.i0000664000175000017500000000005012275776201023142 0ustar williamwilliam%module xxx int foo(int x = 42 || 3); swig-2.0.12/Examples/test-suite/errors/cpp_inline_namespace.i0000664000175000017500000000010012275776201024133 0ustar williamwilliam%module xxx namespace foo { %inline %{ int bar(int x) { } %} } swig-2.0.12/Examples/test-suite/errors/pp_defined.i0000664000175000017500000000006612275776201022107 0ustar williamwilliam%module xxx #if defined() #endif #if defined #endif swig-2.0.12/Examples/test-suite/errors/swig_typemap_warn.i0000664000175000017500000000057512275776201023556 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-2.0.12/Examples/test-suite/errors/c_extra_rbrace.i0000664000175000017500000000004012275776201022745 0ustar williamwilliam%module xxx int foo(int); } swig-2.0.12/Examples/test-suite/errors/expected.log0000664000175000017500000006152112275776201022147 0ustar williamwilliamSWIG error and warning test. opts= ----------------------------------------------------------- :::::::::::::::::::::::::::::::: c_bad_name.i ::::::::::::::::::::::::::::::::::: c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead. c_bad_name.i:3: Error: Missing argument to %name directive. :::::::::::::::::::::::::::::::: c_bad_native.i ::::::::::::::::::::::::::::::::::: c_bad_native.i:3: Error: %native declaration 'foo' is not a function. :::::::::::::::::::::::::::::::: c_class.i ::::::::::::::::::::::::::::::::::: c_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' :::::::::::::::::::::::::::::::: c_default_error.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: c_deprecated.i ::::::::::::::::::::::::::::::::::: c_deprecated.i:3: Warning 102: %val directive deprecated (ignored). c_deprecated.i:3: Warning 103: %out directive deprecated (ignored). :::::::::::::::::::::::::::::::: c_empty_char.i ::::::::::::::::::::::::::::::::::: c_empty_char.i:3: Error: Empty character constant 0 :::::::::::::::::::::::::::::::: c_enum_badvalue.i ::::::::::::::::::::::::::::::::::: c_enum_badvalue.i:6: Error: Type error. Expecting an integral type :::::::::::::::::::::::::::::::: c_extra_rblock.i ::::::::::::::::::::::::::::::::::: c_extra_rblock.i:5: Error: Syntax error in input(1). :::::::::::::::::::::::::::::::: c_extra_rbrace.i ::::::::::::::::::::::::::::::::::: c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}' :::::::::::::::::::::::::::::::: c_extra_unsigned.i ::::::::::::::::::::::::::::::::::: c_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. :::::::::::::::::::::::::::::::: c_insert_missing.i ::::::::::::::::::::::::::::::::::: c_insert_missing.i:3: Error: Couldn't find 'missing_file.i'. :::::::::::::::::::::::::::::::: c_long_short.i ::::::::::::::::::::::::::::::::::: c_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. :::::::::::::::::::::::::::::::: c_missing_rbrace.i ::::::::::::::::::::::::::::::::::: c_missing_rbrace.i:3: Error: Missing '}'. Reached end of input. c_missing_rbrace.i:3: Error: Syntax error in input(1). :::::::::::::::::::::::::::::::: c_missing_semi.i ::::::::::::::::::::::::::::::::::: c_missing_semi.i:3: Error: Syntax error in input(1). :::::::::::::::::::::::::::::::: c_redefine.i ::::::::::::::::::::::::::::::::::: c_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'. :::::::::::::::::::::::::::::::: c_varargs.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: c_varargs_neg.i ::::::::::::::::::::::::::::::::::: c_varargs_neg.i:3: Error: Argument count in %varargs must be positive. :::::::::::::::::::::::::::::::: nomodule.i ::::::::::::::::::::::::::::::::::: No module name specified using %module or -module. :::::::::::::::::::::::::::::::: pp_badeval.i ::::::::::::::::::::::::::::::::::: pp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+' pp_badeval.i:4: Warning 202: Error: 'Expected an expression' :::::::::::::::::::::::::::::::: pp_constant.i ::::::::::::::::::::::::::::::::::: pp_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). :::::::::::::::::::::::::::::::: pp_defined.i ::::::::::::::::::::::::::::::::::: pp_defined.i:6: Error: No arguments given to defined() pp_defined.i:6: Error: Missing expression for #if. :::::::::::::::::::::::::::::::: pp_deprecated.i ::::::::::::::::::::::::::::::::::: pp_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. :::::::::::::::::::::::::::::::: pp_illegal_argument.i ::::::::::::::::::::::::::::::::::: pp_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 :::::::::::::::::::::::::::::::: pp_macro_args.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: pp_macro_badchar.i ::::::::::::::::::::::::::::::::::: pp_macro_badchar.i:4: Error: Illegal character in macro argument name :::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i ::::::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined' :::::::::::::::::::::::::::::::: pp_macro_expansion.i ::::::::::::::::::::::::::::::::::: pp_macro_expansion.i:9: Error: Macro 'MACRO2' expects 2 arguments :::::::::::::::::::::::::::::::: pp_macro_expansion_multiline.i ::::::::::::::::::::::::::::::::::: pp_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 *). :::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i ::::::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo' pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3). :::::::::::::::::::::::::::::::: pp_macro_missing_expression.i ::::::::::::::::::::::::::::::::::: pp_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. :::::::::::::::::::::::::::::::: pp_macro_unexpected_tokens.i ::::::::::::::::::::::::::::::::::: pp_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. :::::::::::::::::::::::::::::::: pp_macro_nargs.i ::::::::::::::::::::::::::::::::::: pp_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 :::::::::::::::::::::::::::::::: pp_macro_redef.i ::::::::::::::::::::::::::::::::::: pp_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'. :::::::::::::::::::::::::::::::: pp_macro_rparen.i ::::::::::::::::::::::::::::::::::: pp_macro_rparen.i:3: Error: Missing ')' in macro parameters :::::::::::::::::::::::::::::::: pp_macro_unterminated.i ::::::::::::::::::::::::::::::::::: pp_macro_unterminated.i:5: Error: Unterminated call invoking macro 'foo' :::::::::::::::::::::::::::::::: pp_misplaced_elif.i ::::::::::::::::::::::::::::::::::: pp_misplaced_elif.i:4: Error: Misplaced #elif. pp_misplaced_elif.i:6: Error: Extraneous #endif. :::::::::::::::::::::::::::::::: pp_misplaced_else.i ::::::::::::::::::::::::::::::::::: pp_misplaced_else.i:4: Error: Misplaced #else. pp_misplaced_else.i:6: Error: Extraneous #endif. :::::::::::::::::::::::::::::::: pp_missing_enddef.i ::::::::::::::::::::::::::::::::::: pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3 :::::::::::::::::::::::::::::::: pp_missing_endif.i ::::::::::::::::::::::::::::::::::: pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3 :::::::::::::::::::::::::::::::: pp_missing_file.i ::::::::::::::::::::::::::::::::::: pp_missing_file.i:3: Error: Unable to find 'missing_filename.i' :::::::::::::::::::::::::::::::: pp_missing_rblock.i ::::::::::::::::::::::::::::::::::: pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3 :::::::::::::::::::::::::::::::: pp_pragma.i ::::::::::::::::::::::::::::::::::: pp_pragma.i:4: Error: Unknown SWIG pragma: rubbish() :::::::::::::::::::::::::::::::: pp_unterm_char.i ::::::::::::::::::::::::::::::::::: pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4 :::::::::::::::::::::::::::::::: pp_unterm_comment.i ::::::::::::::::::::::::::::::::::: pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3 :::::::::::::::::::::::::::::::: pp_unterm_string.i ::::::::::::::::::::::::::::::::::: pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4 :::::::::::::::::::::::::::::::: pp_variable_args.i ::::::::::::::::::::::::::::::::::: pp_variable_args.i:6: Error: Variable length macro argument must be last parameter :::::::::::::::::::::::::::::::: swig_apply_nargs.i ::::::::::::::::::::::::::::::::::: swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match. :::::::::::::::::::::::::::::::: swig_extend.i ::::::::::::::::::::::::::::::::::: swig_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_identifier.i ::::::::::::::::::::::::::::::::::: swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier. :::::::::::::::::::::::::::::::: swig_insert_bad.i ::::::::::::::::::::::::::::::::::: swig_insert_bad.i:5: Error: Unknown target 'foobar' for %insert directive. :::::::::::::::::::::::::::::::: swig_typemap_copy.i ::::::::::::::::::::::::::::::::::: swig_typemap_copy.i:3: Error: Can't copy typemap (in) blah = int :::::::::::::::::::::::::::::::: swig_typemap_old.i ::::::::::::::::::::::::::::::::::: swig_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_typemap_warn.i ::::::::::::::::::::::::::::::::::: 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 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 :::::::::::::::::::::::::::::::: cpp_bad_extern.i ::::::::::::::::::::::::::::::::::: cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL". cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL". :::::::::::::::::::::::::::::::: cpp_extend_destructors.i ::::::::::::::::::::::::::::::::::: cpp_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. :::::::::::::::::::::::::::::::: cpp_extend_redefine.i ::::::::::::::::::::::::::::::::::: cpp_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'. :::::::::::::::::::::::::::::::: cpp_extend_undefined.i ::::::::::::::::::::::::::::::::::: cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo. :::::::::::::::::::::::::::::::: cpp_inline_namespace.i ::::::::::::::::::::::::::::::::::: cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed. :::::::::::::::::::::::::::::::: cpp_inherit.i ::::::::::::::::::::::::::::::::::: cpp_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. :::::::::::::::::::::::::::::::: cpp_macro_locator.i ::::::::::::::::::::::::::::::::::: cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one". cpp_macro_locator.i:96: Warning 204: CPP #warning, "an inline warning message 2". cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored) cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored, cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *). cpp_macro_locator.i:61: Warning 509: Overloaded method overload2(int const *) effectively ignored, cpp_macro_locator.i:60: Warning 509: as it is shadowed by overload2(int *). cpp_macro_locator.i:64: Warning 509: Overloaded method Klass1::methodX(int const *) effectively ignored, cpp_macro_locator.i:64: Warning 509: as it is shadowed by Klass1::methodX(int *). cpp_macro_locator.i:68: Warning 509: Overloaded method overload3(int const *) effectively ignored, cpp_macro_locator.i:67: Warning 509: as it is shadowed by overload3(int *). cpp_macro_locator.i:90: Warning 509: Overloaded method overload4(int const *) effectively ignored, cpp_macro_locator.i:89: Warning 509: as it is shadowed by overload4(int *). cpp_macro_locator.i:94: Warning 509: Overloaded method overloadinline1(int const *) effectively ignored, cpp_macro_locator.i:93: Warning 509: as it is shadowed by overloadinline1(int *). cpp_macro_locator.i:95: Warning 509: Overloaded method Klass2::methodX(int const *) effectively ignored, cpp_macro_locator.i:95: Warning 509: as it is shadowed by Klass2::methodX(int *). cpp_macro_locator.i:98: Warning 509: Overloaded method overloadinline2(int const *) effectively ignored, cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *). cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored, cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *). :::::::::::::::::::::::::::::::: cpp_missing_rparenthesis.i ::::::::::::::::::::::::::::::::::: cpp_missing_rparenthesis.i:5: Error: Missing ')'. Reached end of input. cpp_missing_rparenthesis.i:5: Error: Syntax error in input(3). :::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i ::::::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i:4: Error: Syntax error in input(1). :::::::::::::::::::::::::::::::: cpp_namespace_alias.i ::::::::::::::::::::::::::::::::::: cpp_namespace_alias.i:8: Warning 308: Namespace alias 'B' not allowed here. Assuming 'blah' :::::::::::::::::::::::::::::::: cpp_namespace_aliasnot.i ::::::::::::::::::::::::::::::::::: cpp_namespace_aliasnot.i:4: Error: 'blah' is not a namespace :::::::::::::::::::::::::::::::: cpp_namespace_aliasundef.i ::::::::::::::::::::::::::::::::::: cpp_namespace_aliasundef.i:3: Error: Unknown namespace 'blah' :::::::::::::::::::::::::::::::: cpp_nested.i ::::::::::::::::::::::::::::::::::: cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored) cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored) :::::::::::::::::::::::::::::::: cpp_no_access.i ::::::::::::::::::::::::::::::::::: cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored). :::::::::::::::::::::::::::::::: cpp_no_return_type.i ::::::::::::::::::::::::::::::::::: cpp_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. :::::::::::::::::::::::::::::::: cpp_nobase.i ::::::::::::::::::::::::::::::::::: cpp_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. :::::::::::::::::::::::::::::::: cpp_overload.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: cpp_overload_const.i ::::::::::::::::::::::::::::::::::: cpp_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 *). :::::::::::::::::::::::::::::::: cpp_private_defvalue.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: cpp_private_inherit.i ::::::::::::::::::::::::::::::::::: cpp_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). :::::::::::::::::::::::::::::::: cpp_recursive_typedef.i ::::::::::::::::::::::::::::::::::: :1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on... :::::::::::::::::::::::::::::::: cpp_shared_ptr.i ::::::::::::::::::::::::::::::::::: cpp_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. :::::::::::::::::::::::::::::::: cpp_template_argname.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: cpp_template_nargs.i ::::::::::::::::::::::::::::::::::: cpp_template_nargs.i:5: Error: Template 'blah' undefined. cpp_template_nargs.i:6: Error: Template 'blah' undefined. :::::::::::::::::::::::::::::::: cpp_template_not.i ::::::::::::::::::::::::::::::::::: cpp_template_not.i:5: Error: 'blah' is not defined as a template. (cdecl) :::::::::::::::::::::::::::::::: cpp_template_partial.i ::::::::::::::::::::::::::::::::::: cpp_template_partial.i:3: Warning 317: Specialization of non-template 'vector'. :::::::::::::::::::::::::::::::: cpp_template_repeat.i ::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: cpp_template_undef.i ::::::::::::::::::::::::::::::::::: cpp_template_undef.i:3: Error: Template 'blah' undefined. :::::::::::::::::::::::::::::::: cpp_using_not.i ::::::::::::::::::::::::::::::::::: cpp_using_not.i:4: Error: 'blah' is not a namespace. :::::::::::::::::::::::::::::::: cpp_using_undef.i ::::::::::::::::::::::::::::::::::: cpp_using_undef.i:4: Error: Nothing known about namespace 'foo' cpp_using_undef.i:3: Warning 315: Nothing known about 'foo::bar'. swig-2.0.12/Examples/test-suite/errors/make.sh0000775000175000017500000000460112275776201021113 0ustar williamwilliam#!/bin/sh echo "---------------------------------------" echo "Testing SWIG error and warning messages" echo "---------------------------------------" SWIG='../../../preinst-swig' # Files run in C mode CFILES=' c_bad_name c_bad_native c_class c_default_error c_deprecated c_empty_char c_enum_badvalue c_extra_rblock c_extra_rbrace c_extra_unsigned c_insert_missing c_long_short c_missing_rbrace c_missing_semi c_redefine c_varargs c_varargs_neg nomodule pp_badeval pp_constant pp_defined pp_deprecated pp_illegal_argument pp_macro_args pp_macro_badchar pp_macro_defined_unterminated pp_macro_expansion pp_macro_expansion_multiline pp_macro_inline_unterminated pp_macro_missing_expression pp_macro_unexpected_tokens pp_macro_nargs pp_macro_redef pp_macro_rparen pp_macro_unterminated pp_misplaced_elif pp_misplaced_else pp_missing_enddef pp_missing_endif pp_missing_file pp_missing_rblock pp_pragma pp_unterm_char pp_unterm_comment pp_unterm_string pp_variable_args swig_apply_nargs swig_extend swig_identifier swig_insert_bad swig_typemap_copy swig_typemap_old swig_typemap_warn ' # Files run in C++ mode CPPFILES=' cpp_bad_extern cpp_extend_destructors cpp_extend_redefine cpp_extend_undefined cpp_inline_namespace cpp_inherit cpp_macro_locator cpp_missing_rparenthesis cpp_missing_rtemplate cpp_namespace_alias cpp_namespace_aliasnot cpp_namespace_aliasundef cpp_nested cpp_no_access cpp_no_return_type cpp_nobase cpp_overload cpp_overload_const cpp_private_defvalue cpp_private_inherit cpp_recursive_typedef cpp_shared_ptr cpp_template_argname cpp_template_nargs cpp_template_not cpp_template_partial cpp_template_repeat cpp_template_undef cpp_using_not cpp_using_undef ' LOGFILE='test.log' SWIGOPT=$* rm -f ${LOGFILE} echo "SWIG error and warning test. opts=${SWIGOPT}" >> ${LOGFILE} echo "-----------------------------------------------------------" >> ${LOGFILE} for i in ${CFILES}; do echo " Testing : ${i}.i"; echo "" >> ${LOGFILE}; echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE}; ${SWIG} -python -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1 done for i in ${CPPFILES}; do echo " Testing : ${i}.i"; echo "" >> ${LOGFILE} echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE}; ${SWIG} -python -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1 done echo "" echo "Results written to '${LOGFILE}'" swig-2.0.12/Examples/test-suite/errors/cpp_extend_undefined.i0000664000175000017500000000006412275776201024162 0ustar williamwilliam%module xxx %extend foo { int bar() { } }; swig-2.0.12/Examples/test-suite/errors/c_missing_rbrace.i0000664000175000017500000000005612275776201023302 0ustar williamwilliam%module xxx int foo(int x) { int y; swig-2.0.12/Examples/test-suite/errors/cpp_no_access.i0000664000175000017500000000004212275776201022603 0ustar williamwilliam%module xxx class Bar : foo { }; swig-2.0.12/Examples/test-suite/errors/pp_macro_args.i0000664000175000017500000000006312275776201022623 0ustar williamwilliam%module xxx #define foo(a,x) a x #if foo #endif swig-2.0.12/Examples/test-suite/errors/cpp_macro_locator.i0000664000175000017500000000356712275776201023511 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-2.0.12/Examples/test-suite/errors/cpp_nested.i0000664000175000017500000000015612275776201022136 0ustar williamwilliam%module xxx class Foo { public: class Bar { }; }; class Spam { public: class Grok { } x; }; swig-2.0.12/Examples/test-suite/errors/pp_macro_redef.i0000664000175000017500000000017412275776201022757 0ustar williamwilliam%module xxx #define foo(a,x) a+x #define foo 4 /* Should not generate an error */ #define foo 4 swig-2.0.12/Examples/test-suite/errors/pp_macro_unexpected_tokens.i0000664000175000017500000000035012275776201025415 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-2.0.12/Examples/test-suite/errors/cpp_overload.i0000664000175000017500000000024212275776201022463 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-2.0.12/Examples/test-suite/errors/swig_insert_bad.i0000664000175000017500000000005712275776201023155 0ustar williamwilliam%module xxx %insert("foobar") %{ some code %} swig-2.0.12/Examples/test-suite/errors/pp_unterm_string.i0000664000175000017500000000004712275776201023410 0ustar williamwilliam%module xxx const char *x = "Hello swig-2.0.12/Examples/test-suite/errors/pp_missing_rblock.i0000664000175000017500000000003212275776201023507 0ustar williamwilliam%module xxx %{ int x; swig-2.0.12/Examples/test-suite/errors/pp_deprecated.i0000664000175000017500000000012212275776201022602 0ustar williamwilliam%module xxx %extern ext; #warning Print this warning #error This is an error swig-2.0.12/Examples/test-suite/errors/cpp_namespace_alias.i0000664000175000017500000000011312275776201023752 0ustar williamwilliam%module xxx namespace blah { } namespace B = blah; namespace B { } swig-2.0.12/Examples/test-suite/errors/pp_misplaced_else.i0000664000175000017500000000004312275776201023455 0ustar williamwilliam%module xxx #else int x; #endif swig-2.0.12/Examples/test-suite/errors/cpp_template_repeat.i0000664000175000017500000000015312275776201024024 0ustar williamwilliam%module xxx template T blah(T x) { }; %template(iblah) blah; %template(iiblah) blah; swig-2.0.12/Examples/test-suite/errors/cpp_nobase.i0000664000175000017500000000011412275776201022115 0ustar williamwilliam%module xxx class Foo : public Bar { }; class Spam : public Bar { }; swig-2.0.12/Examples/test-suite/errors/pp_missing_enddef.i0000664000175000017500000000004312275776201023462 0ustar williamwilliam%module xxx %define FOO int x; swig-2.0.12/Examples/test-suite/errors/cpp_shared_ptr.i0000664000175000017500000000050612275776201023006 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-2.0.12/Examples/test-suite/errors/cpp_extend_destructors.i0000664000175000017500000000240212275776201024600 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-2.0.12/Examples/test-suite/errors/c_varargs.i0000664000175000017500000000004212275776201021753 0ustar williamwilliam%module xxx int foo(int x, ...); swig-2.0.12/Examples/test-suite/errors/cpp_no_return_type.i0000664000175000017500000000012712275776201023726 0ustar williamwilliam%module xxx struct R {}; struct S { R() {} }; typedef struct U { UU() {} } UU; swig-2.0.12/Examples/test-suite/errors/c_long_short.i0000664000175000017500000000016412275776201022471 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-2.0.12/Examples/test-suite/errors/cpp_missing_rparenthesis.i0000664000175000017500000000013312275776201025107 0ustar williamwilliam%module xxx %inline %{ class Klass { Klass(int i) : m_i( { } }; %} void something() { } swig-2.0.12/Examples/test-suite/errors/pp_misplaced_elif.i0000664000175000017500000000005412275776201023446 0ustar williamwilliam%module xxx #elif foo == 3 int x; #endif swig-2.0.12/Examples/test-suite/errors/pp_illegal_argument.i0000664000175000017500000000021312275776201024016 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-2.0.12/Examples/test-suite/errors/cpp_namespace_aliasundef.i0000664000175000017500000000004112275776201024774 0ustar williamwilliam%module xxx namespace B = blah; swig-2.0.12/Examples/test-suite/errors/c_empty_char.i0000664000175000017500000000004312275776201022442 0ustar williamwilliam%module xxx int foo(int x = ''); swig-2.0.12/Examples/test-suite/errors/swig_apply_nargs.i0000664000175000017500000000013312275776201023355 0ustar williamwilliam%module xxx %typemap(in) (char *str, int len) { } %apply (char *str, int len) { int x }; swig-2.0.12/Examples/test-suite/errors/c_bad_native.i0000664000175000017500000000004512275776201022405 0ustar williamwilliam%module xxx %native(foo) int foo; swig-2.0.12/Examples/test-suite/errors/c_missing_semi.i0000664000175000017500000000005412275776201022777 0ustar williamwilliam%module xxx int foo(int) int bar(int,int); swig-2.0.12/Examples/test-suite/errors/pp_macro_unterminated.i0000664000175000017500000000006112275776201024364 0ustar williamwilliam%module xxx #define foo(a,x) a+x foo(3, swig-2.0.12/Examples/test-suite/errors/pp_unterm_comment.i0000664000175000017500000000003112275776201023535 0ustar williamwilliam%module xxx /* Hello swig-2.0.12/Examples/test-suite/errors/cpp_recursive_typedef.i0000664000175000017500000000007312275776201024401 0ustar williamwilliam%module cpp_recursive_typedef typedef std::set pds; swig-2.0.12/Examples/test-suite/errors/pp_macro_defined_unterminated.i0000664000175000017500000000004412275776201026043 0ustar williamwilliam%module xxx #if defined(a #endif swig-2.0.12/Examples/test-suite/errors/pp_macro_nargs.i0000664000175000017500000000021112275776201022774 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-2.0.12/Examples/test-suite/errors/pp_badeval.i0000664000175000017500000000006312275776201022104 0ustar williamwilliam%module xxx #if FOO==4 #elif FOO==4+ #endif swig-2.0.12/Examples/test-suite/errors/pp_macro_expansion_multiline.i0000664000175000017500000000075212275776201025762 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-2.0.12/Examples/test-suite/errors/c_extra_unsigned.i0000664000175000017500000000015312275776201023330 0ustar williamwilliam%module xxx int foo(unsigned unsigned int x); int bar(signed signed y); int spam(unsigned signed int x); swig-2.0.12/Examples/test-suite/errors/cpp_template_not.i0000664000175000017500000000007012275776201023342 0ustar williamwilliam%module xxx int blah; %template(blahi) blah; swig-2.0.12/Examples/test-suite/errors/cpp_using_undef.i0000664000175000017500000000006712275776201023163 0ustar williamwilliam%module xxx using foo::bar; using namespace foo; swig-2.0.12/Examples/test-suite/errors/pp_constant.i0000664000175000017500000000136312275776201022343 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-2.0.12/Examples/test-suite/errors/pp_macro_inline_unterminated.i0000664000175000017500000000012712275776201025725 0ustar williamwilliam%module xxx %define foo(a,x) int ii; %enddef %inline %{ struct Struct { foo(2, }; %} swig-2.0.12/Examples/test-suite/errors/cpp_template_argname.i0000664000175000017500000000005312275776201024155 0ustar williamwilliam%module xxx template T blah(T x); swig-2.0.12/Examples/test-suite/errors/pp_macro_expansion.i0000664000175000017500000000023112275776201023670 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-2.0.12/Examples/test-suite/errors/c_insert_missing.i0000664000175000017500000000006112275776201023344 0ustar williamwilliam%module xxx %insert("header") "missing_file.i"; swig-2.0.12/Examples/test-suite/errors/cpp_template_partial.i0000664000175000017500000000006612275776201024203 0ustar williamwilliam%module xxx template class vector { }; swig-2.0.12/Examples/test-suite/errors/nomodule.i0000664000175000017500000000004312275776201021627 0ustar williamwilliam/* No module name */ int foo(int); swig-2.0.12/Examples/test-suite/errors/c_varargs_neg.i0000664000175000017500000000010012275776201022577 0ustar williamwilliam%module xxx %varargs(0,int x = 0) foo; int foo(int x, ...); swig-2.0.12/Examples/test-suite/errors/pp_variable_args.i0000664000175000017500000000010012275776201023277 0ustar williamwilliam%module xxx %define VARARGS_WRONG(a, x, ..., b) xxx %enddef swig-2.0.12/Examples/test-suite/errors/cpp_template_nargs.i0000664000175000017500000000016412275776201023660 0ustar williamwilliam%module xxx template T blah(T x) { }; %template(blahi) blah; %template(blahf) blah<>; swig-2.0.12/Examples/test-suite/errors/cpp_bad_extern.i0000664000175000017500000000012712275776201022765 0ustar williamwilliam%module xxx extern "INTERCAL" { int foo(int); }; extern "INTERCAL" int blah(int); swig-2.0.12/Examples/test-suite/errors/c_enum_badvalue.i0000664000175000017500000000007512275776201023123 0ustar williamwilliam%module xxx enum stuff { FOO = 'x', BAR = 3.14159 }; swig-2.0.12/Examples/test-suite/errors/swig_typemap_old.i0000664000175000017500000000007412275776201023357 0ustar williamwilliam%module xxx %typemap(in) int x { $source; $target; } swig-2.0.12/Examples/test-suite/errors/cpp_namespace_aliasnot.i0000664000175000017500000000005312275776201024476 0ustar williamwilliam%module xxx int blah; namespace B = blah; swig-2.0.12/Examples/test-suite/errors/swig_extend.i0000664000175000017500000000133612275776201022333 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-2.0.12/Examples/test-suite/errors/cpp_extend_redefine.i0000664000175000017500000000022112275776201023775 0ustar williamwilliam%module xxx %extend foo { int bar() { } }; struct foo { int bar(); int spam(); }; %extend foo { int spam(); }; swig-2.0.12/Examples/test-suite/errors/c_redefine.i0000664000175000017500000000020212275776201022065 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-2.0.12/Examples/test-suite/python_varargs_typemap.i0000664000175000017500000000320612275776201023302 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-2.0.12/Examples/test-suite/r_sexp.i0000664000175000017500000000024312275776201017773 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-2.0.12/Examples/test-suite/template_basic.i0000664000175000017500000000214112275776201021446 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-2.0.12/Examples/test-suite/template_arg_scope.i0000664000175000017500000000026712275776201022336 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-2.0.12/Examples/test-suite/template_ns_enum2.i0000664000175000017500000000113412275776201022114 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-2.0.12/Examples/test-suite/clientdata_prop_a.h0000664000175000017500000000021012275776201022134 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-2.0.12/Examples/test-suite/director_binary_string.i0000664000175000017500000000253512275776201023246 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-2.0.12/Examples/test-suite/cast_operator.i0000664000175000017500000000036012275776201021340 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-2.0.12/Examples/test-suite/rename3.i0000664000175000017500000000453112275776201020031 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-2.0.12/Examples/test-suite/li_windows.i0000664000175000017500000000615712275776201020663 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-2.0.12/Examples/test-suite/char_strings.i0000664000175000017500000001116612275776201021167 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-2.0.12/Examples/test-suite/enum_plus.i0000664000175000017500000000025112275776201020501 0ustar williamwilliam%module enum_plus %warnfilter(SWIGWARN_RUBY_WRONG_NAME) iFoo; /* Ruby, wrong constant name */ %inline %{ struct iFoo { enum { Phoo = +50 }; }; %} swig-2.0.12/Examples/test-suite/mod_b.i0000664000175000017500000000022212275776201017550 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-2.0.12/Examples/test-suite/li_std_map.i0000664000175000017500000000517612275776201020620 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-2.0.12/Examples/test-suite/li_std_pair.i0000664000175000017500000000305312275776201020766 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-2.0.12/Examples/test-suite/argcargvtest.i0000664000175000017500000000060312275776201021167 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-2.0.12/Examples/test-suite/octave_dim.i0000664000175000017500000000443612275776201020615 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-2.0.12/Examples/test-suite/r_legacy.i0000664000175000017500000000226212275776201020263 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-2.0.12/Examples/test-suite/extend_template_ns.i0000664000175000017500000000070012275776201022353 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-2.0.12/Examples/test-suite/java_typemaps_typewrapper.i0000664000175000017500000000343112275776201024002 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-2.0.12/Examples/test-suite/arrays_dimensionless.i0000664000175000017500000001111712275776201022732 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-2.0.12/Examples/test-suite/cpp_enum.i0000664000175000017500000000253712275776201020311 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-2.0.12/Examples/test-suite/template_default2.i0000664000175000017500000000172512275776201022102 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-2.0.12/Examples/test-suite/casts.i0000664000175000017500000000022512275776201017610 0ustar williamwilliam%module casts %inline %{ class A { public: A() {} void hello() { } }; class B : public A { public: B() {} }; %} swig-2.0.12/Examples/test-suite/template_inherit.i0000664000175000017500000000155112275776201022033 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-2.0.12/Examples/test-suite/template_ns3.i0000664000175000017500000000045512275776201021076 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-2.0.12/Examples/test-suite/rename_strip_encoder.i0000664000175000017500000000031412275776201022661 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-2.0.12/Examples/test-suite/using2.i0000664000175000017500000000057212275776201017707 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-2.0.12/Examples/test-suite/php/0000775000175000017500000000000012275776201017111 5ustar williamwilliamswig-2.0.12/Examples/test-suite/php/director_classic_runme.php0000664000175000017500000000671312275776201024353 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-2.0.12/Examples/test-suite/php/director_default_runme.php0000664000175000017500000000062512275776201024352 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/arrays_global_twodim_runme.php0000664000175000017500000000135012275776201025233 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/typemap_ns_using_runme.php0000664000175000017500000000031612275776201024414 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/newobject1_runme.php0000664000175000017500000000062512275776201023074 0ustar williamwilliammakeMore(); check::equal(get_class($bar), "Foo", "regular failed"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/director_frob_runme.php0000664000175000017500000000146612275776201023662 0ustar williamwilliamabs_method(); check::equal($s, "Bravo::abs_method()", "s failed"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/arrayptr_runme.php0000664000175000017500000000031612275776201022674 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_finalizer_runme.php0000664000175000017500000000177212275776201024715 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-2.0.12/Examples/test-suite/php/director_unroll_runme.php0000664000175000017500000000066212275776201024242 0ustar williamwilliamset($a); $c = $b->get(); check::equal($a->this, $c->this, "this failed"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/director_profile_runme.php0000664000175000017500000000160212275776201024362 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-2.0.12/Examples/test-suite/php/casts_runme.php0000664000175000017500000000044612275776201022151 0ustar williamwilliamhello(); check::done(); ?> swig-2.0.12/Examples/test-suite/php/li_std_vector_member_var_runme.php0000664000175000017500000000123212275776201026065 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-2.0.12/Examples/test-suite/php/threads_exception_runme.php0000775000175000017500000000147312275776201024550 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-2.0.12/Examples/test-suite/php/director_string_runme.php0000664000175000017500000000151712275776201024235 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-2.0.12/Examples/test-suite/php/pointer_reference_runme.php0000664000175000017500000000074112275776201024530 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-2.0.12/Examples/test-suite/php/template_arg_typename_runme.php0000664000175000017500000000064112275776201025377 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/extend_template_runme.php0000664000175000017500000000032112275776201024206 0ustar williamwilliamtest1(2),"test1"); check::equal(3,$foo->test2(3),"test2"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/typedef_reference_runme.php0000664000175000017500000000054212275776201024507 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_nested_runme.php0000664000175000017500000000312712275776201024210 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-2.0.12/Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php0000664000175000017500000000033712275776201026504 0ustar williamwilliamgetInner()->get(), $fail->getInner()->get(), "should both be 10"); ?> swig-2.0.12/Examples/test-suite/php/li_factory_runme.php0000664000175000017500000000105312275776201023162 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-2.0.12/Examples/test-suite/php/template_construct_runme.php0000664000175000017500000000027512275776201024753 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_stl_runme.php0000664000175000017500000000177212275776201023534 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-2.0.12/Examples/test-suite/php/primitive_ref_runme.php0000664000175000017500000000242312275776201023675 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/conversion_ns_template_runme.php0000664000175000017500000000032412275776201025607 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/class_ignore_runme.php0000664000175000017500000000047212275776201023503 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/add_link_runme.php0000664000175000017500000000065212275776201022600 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-2.0.12/Examples/test-suite/php/wrapmacro_runme.php0000664000175000017500000000046612275776201023031 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_basic_runme.php0000664000175000017500000000227612275776201024013 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-2.0.12/Examples/test-suite/php/extend_template_ns_runme.php0000664000175000017500000000035512275776201024715 0ustar williamwilliamtest1(2),"test1"); check::equal(3,$foo->test2(3),"test2"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/director_extend_runme.php0000664000175000017500000000074112275776201024214 0ustar williamwilliamdummy(), 666, "1st call"); check::equal($m->dummy(), 666, "2st call"); // Locked system check::done(); ?> swig-2.0.12/Examples/test-suite/php/overload_rename_runme.php0000664000175000017500000000047012275776201024173 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/import_nomodule_runme.php0000664000175000017500000000062412275776201024246 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/overload_return_type_runme.php0000664000175000017500000000051512275776201025304 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-2.0.12/Examples/test-suite/php/arrays_global_runme.php0000664000175000017500000000164612275776201023660 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/evil_diamond_runme.php0000664000175000017500000000050712275776201023464 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/li_carrays_runme.php0000664000175000017500000000137212275776201023163 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-2.0.12/Examples/test-suite/php/abstract_inherit_runme.php0000664000175000017500000000055412275776201024361 0ustar williamwilliamblah(),"spam object method"); //check::equal(0,Spam::blah($spam),"spam class method"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/smart_pointer_rename_runme.php0000664000175000017500000000143012275776201025243 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-2.0.12/Examples/test-suite/php/conversion_runme.php0000664000175000017500000000031412275776201023213 0ustar williamwilliamtoFoo(); check::classname("foo",$foo); check::done(); ?> swig-2.0.12/Examples/test-suite/php/valuewrapper_base_runme.php0000664000175000017500000000041712275776201024541 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/using1_runme.php0000664000175000017500000000030412275776201022233 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/using2_runme.php0000664000175000017500000000030412275776201022234 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/prefix_runme.php0000664000175000017500000000050012275776201022320 0ustar williamwilliamget_self(); check::done(); ?> swig-2.0.12/Examples/test-suite/php/arrays_runme.php0000664000175000017500000000157012275776201022334 0ustar williamwilliamarray_c="abc"; check::equal($as->array_c,"a",'$as->array_c=="a"'); check::done(); ?> swig-2.0.12/Examples/test-suite/php/director_protected_runme.php0000664000175000017500000000435612275776201024724 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-2.0.12/Examples/test-suite/php/autodoc_runme.php0000664000175000017500000000034412275776201022467 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/li_std_string_runme.php0000664000175000017500000000225112275776201023674 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-2.0.12/Examples/test-suite/php/arrays_scope_runme.php0000664000175000017500000000042312275776201023521 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/rename_scope_runme.php0000664000175000017500000000116312275776201023471 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/tests.php0000664000175000017500000001643712275776201020777 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_thread_runme.php0000664000175000017500000000071612275776201024176 0ustar williamwilliamval = $this->val - 1; } } $d = new Derived(); $d->run(); if ($d->val >= 0) { check::fail($d->val); } $d->stop(); check::done(); ?> swig-2.0.12/Examples/test-suite/php/grouping_runme.php0000664000175000017500000000121212275776201022656 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_detect_runme.php0000664000175000017500000000210212275776201024166 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-2.0.12/Examples/test-suite/php/director_abstract_runme.php0000664000175000017500000000324712275776201024534 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-2.0.12/Examples/test-suite/php/abstract_inherit_ok_runme.php0000664000175000017500000000027312275776201025050 0ustar williamwilliamblah(),"spam object method"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/exception_order_runme.php0000664000175000017500000000152512275776201024224 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-2.0.12/Examples/test-suite/php/cpp_static_runme.php0000664000175000017500000000054112275776201023161 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/enum_scope_template_runme.php0000664000175000017500000000110312275776201025053 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/sym_runme.php0000664000175000017500000000077512275776201021651 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-2.0.12/Examples/test-suite/php/director_exception_runme.php0000664000175000017500000000322312275776201024721 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-2.0.12/Examples/test-suite/php/evil_diamond_prop_runme.php0000664000175000017500000000171712275776201024530 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-2.0.12/Examples/test-suite/php/ignore_parameter_runme.php0000664000175000017500000000231112275776201024350 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-2.0.12/Examples/test-suite/php/Makefile.in0000664000175000017500000000407612275776201021165 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ fi # Clean: remove the generated .php file %.clean: @rm -f $*.php; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean swig-2.0.12/Examples/test-suite/php/skel.php0000664000175000017500000000033312275776201020557 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/argout_runme.php0000664000175000017500000000202012275776201022323 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/evil_diamond_ns_runme.php0000664000175000017500000000056312275776201024166 0ustar williamwilliam swig-2.0.12/Examples/test-suite/php/director_enum_runme.php0000664000175000017500000000104212275776201023664 0ustar williamwilliamsay_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed"); check::done(); ?> swig-2.0.12/Examples/test-suite/php/conversion_namespace_runme.php0000664000175000017500000000032612275776201025232 0ustar williamwilliamtoFoo(); check::classname("foo",$foo); check::done(); ?> swig-2.0.12/Examples/test-suite/php/char_strings_runme.php0000664000175000017500000000456712275776201023532 0ustar williamwilliam swig-2.0.12/Examples/test-suite/director_nested.i0000664000175000017500000000267612275776201021664 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-2.0.12/Examples/test-suite/nspace.i0000664000175000017500000000573312275776201017755 0ustar williamwilliam// Test the nspace feature %module nspace // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) #if defined(SWIGJAVA) SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) #endif %nspace; %nonspace Outer::Inner2::NoNSpacePlease; %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 {}; } // 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-2.0.12/Examples/test-suite/pure_virtual.i0000664000175000017500000000310112275776201021210 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-2.0.12/Examples/test-suite/exception_order.i0000664000175000017500000000371612275776201021674 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-2.0.12/Examples/test-suite/overload_complicated.i0000664000175000017500000000560612275776201022662 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-2.0.12/Examples/test-suite/nested_class.i0000664000175000017500000001323412275776201021146 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; }; /////////////////////////////////////////// #ifdef 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]; #ifdef 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; } InnerSameName; InnerSameName* makeInnerSameName() { return 0; } }; %} // Ignore nested struct instance %ignore Outer2::IgnoreMeInstance; %{ struct Outer2 { struct IgnoreMe { int xx; }; }; %} struct Outer2 { struct IgnoreMe { int xx; } IgnoreMeInstance; }; swig-2.0.12/Examples/test-suite/abstract_virtual.i0000664000175000017500000000235612275776201022053 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-2.0.12/Examples/test-suite/clisp/0000775000175000017500000000000012275776201017434 5ustar williamwilliamswig-2.0.12/Examples/test-suite/clisp/Makefile.in0000664000175000017500000000231612275776201021503 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra clisp code) %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile clisp_clean swig-2.0.12/Examples/test-suite/cpp_broken.i0000664000175000017500000000014312275776201020614 0ustar williamwilliam%module cpp_broken // bug #940318 %inline %{ typedef enum { eZero = 0 #define ONE 1 } EFoo; %} swig-2.0.12/Examples/test-suite/profiletest.i0000664000175000017500000000131712275776201021036 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-2.0.12/Examples/test-suite/preproc_include_h1.i0000664000175000017500000000002112275776201022232 0ustar williamwilliam#define const1 1 swig-2.0.12/Examples/test-suite/abstract_inherit.i0000664000175000017500000000145012275776201022021 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-2.0.12/Examples/test-suite/preproc_include_e withspace.h0000664000175000017500000000003112275776201024116 0ustar williamwilliam int multiply50(int a); swig-2.0.12/Examples/test-suite/virtual_derivation.i0000664000175000017500000000151412275776201022407 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-2.0.12/Examples/test-suite/evil_diamond.i0000664000175000017500000000126112275776201021126 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-2.0.12/Examples/test-suite/fvirtual.i0000664000175000017500000000126612275776201020335 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-2.0.12/Examples/test-suite/constover.i0000664000175000017500000000132312275776201020515 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-2.0.12/Examples/test-suite/r_copy_struct.i0000664000175000017500000000142712275776201021377 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-2.0.12/Examples/test-suite/enum_rename.i0000664000175000017500000000046512275776201020774 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-2.0.12/Examples/test-suite/naturalvar.i0000664000175000017500000000055212275776201020655 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-2.0.12/Examples/test-suite/cpp_nodefault.i0000664000175000017500000000072212275776201021320 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-2.0.12/Examples/test-suite/template_default_inherit.i0000664000175000017500000000100412275776201023530 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-2.0.12/Examples/test-suite/ruby_li_std_speed.i0000664000175000017500000000100512275776201022167 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-2.0.12/Examples/test-suite/namespace_extend.i0000664000175000017500000000070712275776201022003 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-2.0.12/Examples/test-suite/imports.list0000664000175000017500000000002412275776201020710 0ustar williamwilliamimports_a imports_b swig-2.0.12/Examples/test-suite/typemap_out_optimal.i0000664000175000017500000000216512275776201022573 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-2.0.12/Examples/test-suite/extern_throws.i0000664000175000017500000000047712275776201021417 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-2.0.12/Examples/test-suite/ret_by_value.i0000664000175000017500000000045612275776201021161 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-2.0.12/Examples/test-suite/template_ns_scope.i0000664000175000017500000000111712275776201022200 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-2.0.12/Examples/test-suite/constant_expr.i0000664000175000017500000000027512275776201021367 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-2.0.12/Examples/test-suite/enum_template.i0000664000175000017500000000150012275776201021327 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-2.0.12/Examples/test-suite/typemap_manyargs.i0000664000175000017500000000142712275776201022060 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-2.0.12/Examples/test-suite/template_base_template.i0000664000175000017500000000145012275776201023174 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-2.0.12/Examples/test-suite/arrays.i0000664000175000017500000000307612275776201020003 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-2.0.12/Examples/test-suite/template_default_class_parms_typedef.i0000664000175000017500000000612512275776201026126 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-2.0.12/Examples/test-suite/namespace_forward_declaration.i0000664000175000017500000000112612275776201024521 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-2.0.12/Examples/test-suite/multiple_inheritance.i0000664000175000017500000000371512275776201022706 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-2.0.12/Examples/test-suite/wrapmacro.i0000664000175000017500000000253612275776201020475 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-2.0.12/Examples/test-suite/inherit.i0000664000175000017500000000046712275776201020145 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-2.0.12/Examples/test-suite/director_abstract.i0000664000175000017500000000704712275776201022202 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-2.0.12/Examples/test-suite/python_pybuf.i0000664000175000017500000000224212275776201021222 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-2.0.12/Examples/test-suite/director_overload2.i0000664000175000017500000000064112275776201022265 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-2.0.12/Examples/test-suite/template_typedef_fnc.i0000664000175000017500000000035512275776201022660 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-2.0.12/Examples/test-suite/kind.i0000664000175000017500000000203612275776201017422 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-2.0.12/Examples/test-suite/template_ns_enum.i0000664000175000017500000000047612275776201022042 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-2.0.12/Examples/test-suite/template_typedef_ptr.i0000664000175000017500000000115012275776201022711 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-2.0.12/Examples/test-suite/bloody_hell.i0000664000175000017500000000056612275776201020777 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-2.0.12/Examples/test-suite/li_std_list.i0000664000175000017500000000133512275776201021007 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-2.0.12/Examples/test-suite/ruby_track_objects.i0000664000175000017500000000327112275776201022355 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-2.0.12/Examples/test-suite/smart_pointer_extend.i0000664000175000017500000000317612275776201022740 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-2.0.12/Examples/test-suite/inctest.h0000664000175000017500000000005012275776201020137 0ustar williamwilliamint IntegerMember; double DoubleMember; swig-2.0.12/Examples/test-suite/director_constructor.i0000664000175000017500000000054312275776201022756 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-2.0.12/Examples/test-suite/director_classic.i0000664000175000017500000000203412275776201022007 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-2.0.12/Examples/test-suite/perl5/0000775000175000017500000000000012275776201017351 5ustar williamwilliamswig-2.0.12/Examples/test-suite/perl5/imports_runme.pl0000664000175000017500000000012212275776201022604 0ustar williamwilliamuse imports_b; use imports_a; $x = imports_bc::new_B(); imports_ac::A_hello($x); swig-2.0.12/Examples/test-suite/perl5/default_constructor_runme.pl0000664000175000017500000000370012275776201025205 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-2.0.12/Examples/test-suite/perl5/import_nomodule_runme.pl0000664000175000017500000000045112275776201024330 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-2.0.12/Examples/test-suite/perl5/wrapmacro_runme.pl0000775000175000017500000000050512275776201023112 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-2.0.12/Examples/test-suite/perl5/run-perl-test.pl0000775000175000017500000000037312275776201022435 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-2.0.12/Examples/test-suite/perl5/README0000664000175000017500000000130012275776201020223 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 and Test::Harness are two of the standard perl test harness tools. Support has been added for these modules as of 1.3.28. If adding a new test to this suite, please use Test::More. Currently converted test cases include: * operator_overload * operator_overload_break * package * overload_simple * apply_strings * char_strings * default_args * enum_thorough * global_vars * import_nomodule * inherit * li_cdata_carrays * li_std_string * member_pointer * multiple_inheritance * primitive_ref * template_default_arg * unions * voidtest swig-2.0.12/Examples/test-suite/perl5/template_typedef_cplx_runme.pl0000664000175000017500000000251112275776201025474 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-2.0.12/Examples/test-suite/perl5/member_pointer_runme.pl0000664000175000017500000000253712275776201024132 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-2.0.12/Examples/test-suite/perl5/sneaky1_runme.pl0000775000175000017500000000042512275776201022473 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-2.0.12/Examples/test-suite/perl5/typedef_class_runme.pl0000775000175000017500000000056312275776201023750 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-2.0.12/Examples/test-suite/perl5/array_member_runme.pl0000664000175000017500000000117412275776201023564 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-2.0.12/Examples/test-suite/perl5/overload_simple_runme.pl0000664000175000017500000001262712275776201024310 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-2.0.12/Examples/test-suite/perl5/char_strings_runme.pl0000664000175000017500000000057512275776201023611 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-2.0.12/Examples/test-suite/perl5/typename_runme.pl0000775000175000017500000000064712275776201022750 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-2.0.12/Examples/test-suite/perl5/operator_overload_runme.pl0000664000175000017500000000727412275776201024654 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-2.0.12/Examples/test-suite/perl5/li_std_string_runme.pl0000664000175000017500000001001112275776201023751 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-2.0.12/Examples/test-suite/perl5/naturalvar_runme.pl0000775000175000017500000000061012275776201023273 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-2.0.12/Examples/test-suite/perl5/using2_runme.pl0000775000175000017500000000027312275776201022330 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-2.0.12/Examples/test-suite/perl5/disown_runme.pl0000664000175000017500000000016012275776201022414 0ustar williamwilliamuse disown; if (1) { $a = new disown::A(); $b = new disown::B(); $c = $b->acquire($a); } swig-2.0.12/Examples/test-suite/perl5/minherit_runme.pl0000775000175000017500000000247512275776201022746 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-2.0.12/Examples/test-suite/perl5/li_carrays_runme.pl0000664000175000017500000000352712275776201023253 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-2.0.12/Examples/test-suite/perl5/enum_thorough_runme.pl0000664000175000017500000005745212275776201024014 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-2.0.12/Examples/test-suite/perl5/voidtest_runme.pl0000664000175000017500000000076212275776201022762 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-2.0.12/Examples/test-suite/perl5/contract_runme.pl0000775000175000017500000000501612275776201022736 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-2.0.12/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl0000775000175000017500000000262312275776201025565 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-2.0.12/Examples/test-suite/perl5/exception_order_runme.pl0000664000175000017500000000100412275776201024300 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-2.0.12/Examples/test-suite/perl5/typemap_namespace_runme.pl0000664000175000017500000000040112275776201024602 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-2.0.12/Examples/test-suite/perl5/template_default_arg_runme.pl0000664000175000017500000000753212275776201025273 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-2.0.12/Examples/test-suite/perl5/template_typedef_cplx3_runme.pl0000664000175000017500000000217712275776201025567 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-2.0.12/Examples/test-suite/perl5/overload_copy_runme.pl0000664000175000017500000000012512275776201023757 0ustar williamwilliam use overload_copy; $f = new overload_copy::Foo(); $g = new overload_copy::Foo($f); swig-2.0.12/Examples/test-suite/perl5/rename_scope_runme.pl0000775000175000017500000000053312275776201023560 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-2.0.12/Examples/test-suite/perl5/unions_runme.pl0000664000175000017500000000231212275776201022425 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-2.0.12/Examples/test-suite/perl5/packageoption_runme.pl0000664000175000017500000000075612275776201023750 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-2.0.12/Examples/test-suite/perl5/multiple_inheritance_runme.pl0000664000175000017500000000046212275776201025322 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-2.0.12/Examples/test-suite/perl5/varargs_runme.pl0000664000175000017500000000061112275776201022557 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-2.0.12/Examples/test-suite/perl5/class_ignore_runme.pl0000775000175000017500000000040212275776201023563 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-2.0.12/Examples/test-suite/perl5/aggregate_runme.pl0000664000175000017500000000116412275776201023044 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-2.0.12/Examples/test-suite/perl5/ignore_parameter_runme.pl0000775000175000017500000000252012275776201024441 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-2.0.12/Examples/test-suite/perl5/li_std_except_runme.pl0000775000175000017500000000363612275776201023755 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-2.0.12/Examples/test-suite/perl5/return_const_value_runme.pl0000775000175000017500000000047612275776201025047 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-2.0.12/Examples/test-suite/perl5/using1_runme.pl0000775000175000017500000000027312275776201022327 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-2.0.12/Examples/test-suite/perl5/template_ref_type_runme.pl0000664000175000017500000000016412275776201024625 0ustar williamwilliamuse template_ref_type; my $xr = template_ref_type::XC->new(); my $y = template_ref_type::Y->new(); $y->find($xr); swig-2.0.12/Examples/test-suite/perl5/inherit_runme.pl0000664000175000017500000000027412275776201022561 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-2.0.12/Examples/test-suite/perl5/apply_strings_runme.pl0000664000175000017500000000056012275776201024013 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-2.0.12/Examples/test-suite/perl5/grouping_runme.pl0000775000175000017500000000052712275776201022755 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-2.0.12/Examples/test-suite/perl5/inctest_runme.pl0000664000175000017500000000036312275776201022567 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-2.0.12/Examples/test-suite/perl5/operator_overload_break_runme.pl0000664000175000017500000000150612275776201026010 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-2.0.12/Examples/test-suite/perl5/apply_signed_char_runme.pl0000664000175000017500000000147712275776201024600 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-2.0.12/Examples/test-suite/perl5/inherit_missing_runme.pl0000775000175000017500000000073612275776201024320 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-2.0.12/Examples/test-suite/perl5/ret_by_value_runme.pl0000664000175000017500000000037612275776201023602 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-2.0.12/Examples/test-suite/perl5/primitive_types_runme.pl0000775000175000017500000002320112275776201024351 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, "ho\0la", "namet"); $t->{var_namet} = $primitive_types::def_namet; is($t->{var_namet}, $primitive_types::def_namet, "namet"); $t->{var_namet} = 'holac'; is($t->{var_namet}, 'holac', "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-2.0.12/Examples/test-suite/perl5/default_args_runme.pl0000664000175000017500000000565712275776201023571 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-2.0.12/Examples/test-suite/perl5/char_binary_runme.pl0000775000175000017500000000136212275776201023402 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-2.0.12/Examples/test-suite/perl5/enum_template_runme.pl0000775000175000017500000000040212275776201023752 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-2.0.12/Examples/test-suite/perl5/Makefile.in0000664000175000017500000000252712275776201021424 0ustar williamwilliam####################################################################### # Makefile for perl5 test-suite ####################################################################### LANGUAGE = perl5 PERL = @PERL@ SCRIPTSUFFIX = _runme.pl TEST_RUNNER = 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: remove the generated .pm file %.clean: @rm -f $*.pm; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile perl5_clean swig-2.0.12/Examples/test-suite/perl5/reference_global_vars_runme.pl0000775000175000017500000000465512275776201025442 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-2.0.12/Examples/test-suite/perl5/profiletest_runme.pl0000664000175000017500000000022412275776201023452 0ustar williamwilliamuse profiletest; $a = profiletestc::new_A(); $b = profiletestc::new_B(); for ($i = 0; $i < 100000; $i++) { $a = profiletestc::B_fn($b, $a); } swig-2.0.12/Examples/test-suite/perl5/sizet_runme.pl0000775000175000017500000000056412275776201022262 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-2.0.12/Examples/test-suite/perl5/global_vars_runme.pl0000664000175000017500000000037412275776201023413 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-2.0.12/Examples/test-suite/perl5/preproc_runme.pl0000775000175000017500000000042612275776201022573 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-2.0.12/Examples/test-suite/perl5/virtual_poly_runme.pl0000664000175000017500000000124012275776201023642 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-2.0.12/Examples/test-suite/perl5/li_typemaps_runme.pl0000664000175000017500000000454212275776201023447 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-2.0.12/Examples/test-suite/perl5/dynamic_cast_runme.pl0000664000175000017500000000044712275776201023557 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-2.0.12/Examples/test-suite/perl5/primitive_ref_runme.pl0000664000175000017500000000130612275776201023760 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-2.0.12/Examples/test-suite/perl5/li_cdata_carrays_runme.pl0000664000175000017500000000052612275776201024403 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-2.0.12/Examples/test-suite/perl5/li_reference_runme.pl0000664000175000017500000000273412275776201023544 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-2.0.12/Examples/test-suite/smart_pointer_templatemethods.i0000664000175000017500000000157212275776201024646 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-2.0.12/Examples/test-suite/global_vars.i0000664000175000017500000000061212275776201020766 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; %} swig-2.0.12/Examples/test-suite/template_const_ref.i0000664000175000017500000000035612275776201022355 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-2.0.12/Examples/test-suite/input.i0000664000175000017500000000127112275776201017634 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-2.0.12/Examples/test-suite/java_pgcpp.i0000664000175000017500000000354412275776201020614 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-2.0.12/Examples/test-suite/packageoption_b.i0000664000175000017500000000017012275776201021617 0ustar williamwilliam%module(package="CommonPackage") "packageoption_b"; %inline %{ class B { public: int testInt() { return 4; } }; %} swig-2.0.12/Examples/test-suite/php_namewarn_rename.i0000664000175000017500000000063212275776201022503 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 %inline %{ int Exception() { return 13; } void Empty() {} class stdClass { }; class directory { }; struct Hello { void empty() {} }; %} swig-2.0.12/Examples/test-suite/overload_return_type.i0000664000175000017500000000065412275776201022754 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-2.0.12/Examples/test-suite/constructor_explicit.i0000664000175000017500000000044412275776201022764 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-2.0.12/Examples/test-suite/member_funcptr_galore.i0000664000175000017500000000717312275776201023045 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-2.0.12/Examples/test-suite/using_namespace.i0000664000175000017500000000256212275776201021642 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-2.0.12/Examples/test-suite/newobject2.i0000664000175000017500000000125712275776201020543 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-2.0.12/Examples/test-suite/bom_utf8.i0000664000175000017500000000015612275776201020221 0ustar williamwilliam%module bom_utf8 /* Test for UTF8 BOM at start of file */ %inline %{ struct NotALotHere { int n; }; %} swig-2.0.12/Examples/test-suite/primitive_types.i0000664000175000017500000003067112275776201021737 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',0, 'l','a'}; 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-2.0.12/Examples/test-suite/li_std_vector_extra.i0000664000175000017500000000563312275776201022546 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-2.0.12/Examples/test-suite/smart_pointer_multi.i0000664000175000017500000000076012275776201022577 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-2.0.12/Examples/test-suite/typemap_directorout.i0000664000175000017500000000512212275776201022576 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 SWIGPHP %typemap(directorout, warning="PHP directorout typemaps need fixing") MyType &Class1::foo2, MyType &foo1 %{ /* special start */ /*$input = 0;*/ /* special end */ %} /* Patch to make $input work same as other languages. Then $input needs changing to &$input in most (maybe all) typemaps. --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2631,8 +2631,7 @@ done: if (!is_void) { tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); if (tm != 0) { - static const String *amp_result = NewStringf("&%s", Swig_cresult_name()); - Replaceall(tm, "$input", amp_result); + Replaceall(tm, "$input", Swig_cresult_name()); char temp[24]; sprintf(temp, "%d", idx); Replaceall(tm, "$argnum", temp); */ #endif #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-2.0.12/Examples/test-suite/template_typedef_cplx4.i0000664000175000017500000000143312275776201023142 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-2.0.12/Examples/test-suite/typedef_scope.i0000664000175000017500000000063212275776201021326 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-2.0.12/Examples/test-suite/java_jnitypes.i0000664000175000017500000000220512275776201021341 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-2.0.12/Examples/test-suite/template_ref_type.i0000664000175000017500000000051012275776201022200 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-2.0.12/Examples/test-suite/guile_ext_test.i0000664000175000017500000000060112275776201021515 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-2.0.12/Examples/test-suite/smart_pointer_member.i0000664000175000017500000000144412275776201022714 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-2.0.12/Examples/test-suite/template_partial_arg.i0000664000175000017500000000051412275776201022654 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-2.0.12/Examples/test-suite/rename2.i0000664000175000017500000000463512275776201020035 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-2.0.12/Examples/test-suite/template_default.i0000664000175000017500000000620412275776201022015 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-2.0.12/Examples/test-suite/shared_ptr_wrapper.h0000664000175000017500000000572212275776201022374 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-2.0.12/Examples/test-suite/d_nativepointers.i0000664000175000017500000000121612275776201022051 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-2.0.12/Examples/test-suite/li_std_deque.i0000664000175000017500000000135112275776201021135 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-2.0.12/Examples/test-suite/template_arg_typename.i0000664000175000017500000000075412275776201023050 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-2.0.12/Examples/test-suite/symbol_clash.i0000664000175000017500000000060112275776201021150 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-2.0.12/Examples/test-suite/testdir/0000775000175000017500000000000012275776201020000 5ustar williamwilliamswig-2.0.12/Examples/test-suite/testdir/README0000664000175000017500000000033112275776201020655 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-2.0.12/Examples/test-suite/testdir/inctest/0000775000175000017500000000000012275776201021451 5ustar williamwilliamswig-2.0.12/Examples/test-suite/testdir/inctest/test.i0000664000175000017500000000007412275776201022603 0ustar williamwilliam %include "subdir1/subinc1.i" %include "subdir2/subinc2.i" swig-2.0.12/Examples/test-suite/testdir/inctest/subdir1/0000775000175000017500000000000012275776201023022 5ustar williamwilliamswig-2.0.12/Examples/test-suite/testdir/inctest/subdir1/subinc1.i0000664000175000017500000000017712275776201024545 0ustar williamwilliam// %include twice to check include header guards %include "hello.i" %include "hello.i" %import "imports.i" %import "imports.i" swig-2.0.12/Examples/test-suite/testdir/inctest/subdir1/hello.i0000664000175000017500000000033412275776201024277 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-2.0.12/Examples/test-suite/testdir/inctest/subdir1/imports.i0000664000175000017500000000015112275776201024666 0ustar williamwilliam#ifndef subdir1_imports_i_ #define subdir1_imports_i_ typedef int Integer; #endif //subdir1_imports_i_ swig-2.0.12/Examples/test-suite/testdir/inctest/subdir2/0000775000175000017500000000000012275776201023023 5ustar williamwilliamswig-2.0.12/Examples/test-suite/testdir/inctest/subdir2/hello.i0000664000175000017500000000040712275776201024301 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-2.0.12/Examples/test-suite/testdir/inctest/subdir2/imports.i0000664000175000017500000000016212275776201024671 0ustar williamwilliam#ifndef subdir2_imports_i_ #define subdir2_imports_i_ typedef char * TypedefString; #endif //subdir2_imports_i_ swig-2.0.12/Examples/test-suite/testdir/inctest/subdir2/subinc2.i0000664000175000017500000000005012275776201024535 0ustar williamwilliam%include "hello.i" %import "imports.i" swig-2.0.12/Examples/test-suite/tag_no_clash_with_variable.i0000664000175000017500000000074612275776201024024 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-2.0.12/Examples/test-suite/swigobject.i0000664000175000017500000000041312275776201020632 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-2.0.12/Examples/test-suite/li_typemaps.i0000664000175000017500000001167712275776201021036 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-2.0.12/Examples/test-suite/static_array_member.i0000664000175000017500000000042012275776201022504 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-2.0.12/Examples/test-suite/java/0000775000175000017500000000000012275776201017243 5ustar williamwilliamswig-2.0.12/Examples/test-suite/java/inctest_runme.java0000664000175000017500000000100312275776201022757 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-2.0.12/Examples/test-suite/java/varargs_runme.java0000664000175000017500000000163712275776201022770 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-2.0.12/Examples/test-suite/java/ret_by_value_runme.java0000664000175000017500000000172712275776201024003 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-2.0.12/Examples/test-suite/java/li_std_vector_runme.java0000664000175000017500000000243112275776201024154 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-2.0.12/Examples/test-suite/java/using_pointers_runme.java0000664000175000017500000000142712275776201024370 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-2.0.12/Examples/test-suite/java/overload_complicated_runme.java0000664000175000017500000000340612275776201025476 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-2.0.12/Examples/test-suite/java/README0000664000175000017500000000106712275776201020127 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 SWIGs 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 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-2.0.12/Examples/test-suite/java/nested_structs_runme.java0000664000175000017500000000267312275776201024375 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_inner2 inner2 = outer.getInner2(); Outer_inner3 inner3 = outer.getInner3(); Outer_inner4 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"); Outer_inside1 inside1 = outer.getInside1(); Outer_inside2 inside2 = outer.getInside2(); Outer_inside3 inside3 = outer.getInside3(); Outer_inside4 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"); } } swig-2.0.12/Examples/test-suite/java/java_constants_runme.java0000664000175000017500000000140712275776201024333 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-2.0.12/Examples/test-suite/java/java_director_runme.java0000664000175000017500000000460312275776201024133 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); } } 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 */ System.gc(); System.runFinalization(); // Give the finalizers a chance to run try { Thread.sleep(50); } catch (InterruptedException e) { } /* Watch the Quux objects formerly in the QuuxContainer object get reaped */ System.gc(); System.runFinalization(); instances = Quux.instances(); if (instances != 0) throw new RuntimeException("Quux instances should be 0, actually " + instances); /* 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-2.0.12/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java0000664000175000017500000011465012275776201026451 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-2.0.12/Examples/test-suite/java/inherit_target_language_runme.java0000664000175000017500000000162712275776201026175 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-2.0.12/Examples/test-suite/java/java_throws_runme.java0000664000175000017500000000601412275776201023644 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-2.0.12/Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java0000664000175000017500000001077212275776201027407 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-2.0.12/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java0000664000175000017500000000543412275776201033313 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-2.0.12/Examples/test-suite/java/java_enums_runme.java0000664000175000017500000000276112275776201023452 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-2.0.12/Examples/test-suite/java/template_namespace_forward_declaration_runme.java0000664000175000017500000000156412275776201031242 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-2.0.12/Examples/test-suite/java/smart_pointer_const_overload_runme.java0000664000175000017500000000464112275776201027310 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-2.0.12/Examples/test-suite/java/typemap_out_optimal_runme.java0000664000175000017500000000075312275776201025414 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-2.0.12/Examples/test-suite/java/member_pointer_runme.java0000664000175000017500000000352412275776201024327 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-2.0.12/Examples/test-suite/java/java_lib_various_runme.java0000664000175000017500000000607612275776201024644 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-2.0.12/Examples/test-suite/java/dynamic_cast_runme.java0000664000175000017500000000127712275776201023761 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")) { System.err.println("Failed!"); System.exit(1); } } } swig-2.0.12/Examples/test-suite/java/template_default_arg_runme.java0000664000175000017500000001231712275776201025470 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-2.0.12/Examples/test-suite/java/director_primitives_runme.java0000664000175000017500000001133112275776201025401 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-2.0.12/Examples/test-suite/java/rname_runme.java0000664000175000017500000000166312275776201022424 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-2.0.12/Examples/test-suite/java/director_string_runme.java0000664000175000017500000000266212275776201024523 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-2.0.12/Examples/test-suite/java/curiously_recurring_template_pattern_runme.java0000664000175000017500000000156712275776201031073 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-2.0.12/Examples/test-suite/java/imports_runme.java0000664000175000017500000000116412275776201023013 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-2.0.12/Examples/test-suite/java/li_std_except_runme.java0000664000175000017500000000522512275776201024146 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-2.0.12/Examples/test-suite/java/template_partial_specialization_typedef_runme.java0000664000175000017500000000217512275776201031466 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-2.0.12/Examples/test-suite/java/director_exception_runme.java0000664000175000017500000000153212275776201025206 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-2.0.12/Examples/test-suite/java/memberin_extend_runme.java0000664000175000017500000000137612275776201024470 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-2.0.12/Examples/test-suite/java/namespace_forward_declaration_runme.java0000664000175000017500000000142712275776201027345 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-2.0.12/Examples/test-suite/java/director_protected_runme.java0000664000175000017500000000742312275776201025206 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-2.0.12/Examples/test-suite/java/template_methods_runme.java0000664000175000017500000000240012275776201024646 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-2.0.12/Examples/test-suite/java/wallkw_runme.java0000664000175000017500000000156012275776201022617 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-2.0.12/Examples/test-suite/java/director_nspace_runme.java0000664000175000017500000000233712275776201024465 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-2.0.12/Examples/test-suite/java/li_typemaps_runme.java0000664000175000017500000000715712275776201023654 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-2.0.12/Examples/test-suite/java/char_strings_runme.java0000664000175000017500000001323312275776201024004 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-2.0.12/Examples/test-suite/inherit_missing.i0000664000175000017500000000145412275776201021673 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-2.0.12/Examples/test-suite/overload_simple.i0000664000175000017500000000715612275776201021671 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-2.0.12/Examples/test-suite/multivalue.i0000664000175000017500000000221612275776201020664 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-2.0.12/Examples/test-suite/defvalue_constructor.i0000664000175000017500000000023612275776201022735 0ustar williamwilliam%module defvalue_constructor %inline %{ namespace Foo { class Bar {}; class Baz { public: Baz(Bar b = Bar()) {} }; } %} swig-2.0.12/Examples/test-suite/cpp_static.i0000664000175000017500000000064112275776201020626 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-2.0.12/Examples/test-suite/overload_numeric.i0000664000175000017500000000221312275776201022027 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-2.0.12/Examples/test-suite/tcl/0000775000175000017500000000000012275776201017104 5ustar williamwilliamswig-2.0.12/Examples/test-suite/tcl/enum_thorough_runme.tcl0000664000175000017500000000065112275776201023703 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-2.0.12/Examples/test-suite/tcl/README0000664000175000017500000000020712275776201017763 0ustar williamwilliamSee ../README for common README file. Any testcases which have _runme.tcl appended after the testcase name will be detected and run. swig-2.0.12/Examples/test-suite/tcl/li_std_string_runme.tcl0000664000175000017500000000143112275776201023661 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-2.0.12/Examples/test-suite/tcl/overload_simple_runme.tcl0000664000175000017500000000522712275776201024210 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-2.0.12/Examples/test-suite/tcl/member_pointer_runme.tcl0000664000175000017500000000200412275776201024021 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-2.0.12/Examples/test-suite/tcl/newobject2_runme.tcl0000664000175000017500000000102512275776201023056 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-2.0.12/Examples/test-suite/tcl/primitive_ref_runme.tcl0000664000175000017500000000163012275776201023662 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-2.0.12/Examples/test-suite/tcl/import_nomodule_runme.tcl0000664000175000017500000000022412275776201024230 0ustar williamwilliam if [ catch { load ./import_nomodule[info sharedlibextension] import_nomodule} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } swig-2.0.12/Examples/test-suite/tcl/overload_copy_runme.tcl0000664000175000017500000000026112275776201023662 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-2.0.12/Examples/test-suite/tcl/union_parameter_runme.tcl0000664000175000017500000000214612275776201024211 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-2.0.12/Examples/test-suite/tcl/clientdata_prop_runme.tcl0000664000175000017500000000202412275776201024164 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-2.0.12/Examples/test-suite/tcl/imports_runme.tcl0000664000175000017500000000105412275776201022513 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-2.0.12/Examples/test-suite/tcl/disown_runme.tcl0000664000175000017500000000052512275776201022323 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-2.0.12/Examples/test-suite/tcl/profiletest_runme.tcl0000664000175000017500000000024412275776201023356 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-2.0.12/Examples/test-suite/tcl/unions_runme.tcl0000664000175000017500000000372212275776201022335 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-2.0.12/Examples/test-suite/tcl/reference_global_vars_runme.tcl0000664000175000017500000000464412275776201025337 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-2.0.12/Examples/test-suite/tcl/null_pointer_runme.tcl0000664000175000017500000000066612275776201023540 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-2.0.12/Examples/test-suite/tcl/Makefile.in0000664000175000017500000000230312275776201021147 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile tcl_clean swig-2.0.12/Examples/test-suite/tcl/primitive_types_runme.tcl0000664000175000017500000000176212275776201024260 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-2.0.12/Examples/test-suite/tcl/newobject1_runme.tcl0000664000175000017500000000117012275776201023056 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-2.0.12/Examples/test-suite/tcl/bools_runme.tcl0000664000175000017500000000255312275776201022141 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-2.0.12/Examples/test-suite/protected_rename.i0000664000175000017500000000046412275776201022020 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-2.0.12/Examples/test-suite/template_static.i0000664000175000017500000000110212275776201021650 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-2.0.12/Examples/test-suite/varargs.i0000664000175000017500000000165512275776201020150 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-2.0.12/Examples/test-suite/python_richcompare.i0000664000175000017500000000232312275776201022371 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-2.0.12/Examples/test-suite/namespace_virtual_method.i0000664000175000017500000000106712275776201023542 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-2.0.12/Examples/test-suite/imports_a.h0000664000175000017500000000112712275776201020471 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-2.0.12/Examples/test-suite/using_directive_and_declaration_forward.i0000664000175000017500000000502012275776201026567 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; class Thing1 {}; 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; class Thing2 {}; 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; class Thing3 {}; 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; class Thing4 {}; 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; class Thing5 {}; 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; 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-2.0.12/Examples/test-suite/typemap_qualifier_strip.i0000664000175000017500000000234312275776201023437 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-2.0.12/Examples/test-suite/li_boost_shared_ptr_template.i0000664000175000017500000000400012275776201024406 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-2.0.12/Examples/test-suite/autodoc.i0000664000175000017500000000717512275776201020144 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-2.0.12/Examples/test-suite/array_typedef_memberin.i0000664000175000017500000000166012275776201023213 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-2.0.12/Examples/test-suite/packageoption.list0000664000175000017500000000006012275776201022037 0ustar williamwilliampackageoption_a packageoption_b packageoption_c swig-2.0.12/Examples/test-suite/li_implicit.i0000664000175000017500000000051212275776201020770 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-2.0.12/Examples/test-suite/director_classes.i0000664000175000017500000001115112275776201022023 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-2.0.12/Examples/test-suite/director_ignore.i0000664000175000017500000000731212275776201021655 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-2.0.12/Examples/test-suite/template_namespace_forward_declaration.i0000664000175000017500000000144212275776201026415 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-2.0.12/Examples/test-suite/smart_pointer_not.i0000664000175000017500000000114512275776201022243 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-2.0.12/Examples/test-suite/imports_b.h0000664000175000017500000000070012275776201020466 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-2.0.12/Examples/test-suite/enum_scope_template.i0000664000175000017500000000060512275776201022525 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-2.0.12/Examples/test-suite/director_default.i0000664000175000017500000000262712275776201022022 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-2.0.12/Examples/test-suite/java_nspacewithoutpackage.i0000664000175000017500000000127512275776201023713 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-2.0.12/Examples/test-suite/li_std_except.i0000664000175000017500000000315212275776201021323 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-2.0.12/Examples/test-suite/template_partial_specialization_typedef.i0000664000175000017500000001162412275776201026645 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-2.0.12/Examples/test-suite/imports_a.i0000664000175000017500000000073312275776201020474 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-2.0.12/Examples/test-suite/director_wstring.i0000664000175000017500000000237012275776201022066 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-2.0.12/Examples/test-suite/typemap_array_qualifiers.i0000664000175000017500000000360412275776201023600 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-2.0.12/Examples/test-suite/using_protected.i0000664000175000017500000000054012275776201021671 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-2.0.12/Examples/test-suite/funcptr.i0000664000175000017500000000205112275776201020153 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-2.0.12/Examples/test-suite/constructor_ignore.i0000664000175000017500000000105012275776201022420 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-2.0.12/Examples/test-suite/template_typedef_rec.i0000664000175000017500000000346412275776201022667 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-2.0.12/Examples/test-suite/fragments.i0000664000175000017500000000061612275776201020465 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-2.0.12/Examples/test-suite/conversion_namespace.i0000664000175000017500000000030512275776201022673 0ustar williamwilliam%module conversion_namespace %rename(toFoo) oss::Bar::operator Foo(); %inline %{ namespace oss { struct Foo { }; struct Bar { operator Foo () { return Foo(); } }; } %} swig-2.0.12/Examples/test-suite/director_redefined.i0000664000175000017500000000120412275776201022311 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-2.0.12/Examples/test-suite/inout.i0000664000175000017500000000174412275776201017640 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-2.0.12/Examples/test-suite/typemap_ns_using.i0000664000175000017500000000047112275776201022062 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-2.0.12/Examples/test-suite/template_default_class_parms.i0000664000175000017500000000140112275776201024376 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-2.0.12/Examples/test-suite/using_composition.i0000664000175000017500000000265412275776201022253 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-2.0.12/Examples/test-suite/rename4.i0000664000175000017500000000637512275776201020042 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-2.0.12/Examples/test-suite/function_typedef.i0000664000175000017500000000041512275776201022041 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-2.0.12/Examples/test-suite/template_virtual.i0000664000175000017500000000146212275776201022060 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-2.0.12/Examples/test-suite/namespace_enum.i0000664000175000017500000000034712275776201021460 0ustar williamwilliam%module namespace_enum %inline %{ namespace Foo { enum Swig { LAGER, STOUT, ALE }; class Bar { public: enum Speed { SLOW, FAST }; }; } %} swig-2.0.12/Examples/test-suite/overload_extendc.i0000664000175000017500000000067512275776201022031 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-2.0.12/Examples/test-suite/template_ns4.i0000664000175000017500000000312212275776201021071 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-2.0.12/Examples/test-suite/curiously_recurring_template_pattern.i0000664000175000017500000000200712275776201026241 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-2.0.12/Examples/test-suite/rename_scope.i0000664000175000017500000000223612275776201021137 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-2.0.12/Examples/test-suite/apply_strings.i0000664000175000017500000000441712275776201021400 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-2.0.12/Examples/test-suite/preproc_include_c.h0000664000175000017500000000003112275776201022144 0ustar williamwilliam int multiply30(int a); swig-2.0.12/Examples/test-suite/director_wombat.i0000664000175000017500000000233212275776201021660 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-2.0.12/Examples/test-suite/preproc_include_h3.i0000664000175000017500000000002112275776201022234 0ustar williamwilliam#define const3 3 swig-2.0.12/Examples/test-suite/abstract_typedef.i0000664000175000017500000000201712275776201022017 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-2.0.12/Examples/test-suite/template_typedef_funcptr.i0000664000175000017500000000241712275776201023574 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-2.0.12/Examples/test-suite/overload_template_fast.i0000664000175000017500000000011512275776201023214 0ustar williamwilliam%module overload_template_fast %fastdispatch; %include overload_template.i swig-2.0.12/Examples/test-suite/special_variable_macros.i0000664000175000017500000001463412275776201023335 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(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-2.0.12/Examples/test-suite/return_value_scope.i0000664000175000017500000000043312275776201022400 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-2.0.12/Examples/test-suite/static_const_member_2.i0000664000175000017500000000261712275776201022747 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-2.0.12/Examples/test-suite/struct_initialization_cpp.i0000664000175000017500000000021612275776201023770 0ustar williamwilliam// Test declaration and initialization of structs (C++ code) %module struct_initialization_cpp %include "struct_initialization.i" // C code swig-2.0.12/Examples/test-suite/director_detect.i0000664000175000017500000000206512275776201021642 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-2.0.12/Examples/test-suite/exception_partial_info.i0000664000175000017500000000162112275776201023221 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-2.0.12/Examples/test-suite/inline_initializer.i0000664000175000017500000000016712275776201022361 0ustar williamwilliam%module inline_initializer %inline %{ class Foo { int x; public: Foo(int a); }; Foo::Foo(int a) : x(a) { } %} swig-2.0.12/Examples/test-suite/template_enum.i0000664000175000017500000000164612275776201021342 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-2.0.12/Examples/test-suite/li_std_map_member.i0000664000175000017500000000044312275776201022137 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-2.0.12/Examples/test-suite/multi_import.list0000664000175000017500000000003612275776201021742 0ustar williamwilliammulti_import_a multi_import_b swig-2.0.12/Examples/test-suite/minherit.i0000664000175000017500000000300412275776201020310 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-2.0.12/Examples/test-suite/union_parameter.i0000664000175000017500000000205612275776201021667 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-2.0.12/Examples/test-suite/csharp_attributes.i0000664000175000017500000000407012275776201022223 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-2.0.12/Examples/test-suite/typemap_numinputs.i0000664000175000017500000000072012275776201022274 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-2.0.12/Examples/test-suite/friends.i0000664000175000017500000000575212275776201020137 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-2.0.12/Examples/test-suite/imports_b.i0000664000175000017500000000177112275776201020500 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-2.0.12/Examples/test-suite/constant_pointers.i0000664000175000017500000000715312275776201022256 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-2.0.12/Examples/test-suite/java_lib_various.i0000664000175000017500000000230612275776201022014 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-2.0.12/Examples/test-suite/template_forward.i0000664000175000017500000000312712275776201022036 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-2.0.12/Examples/test-suite/template_classes.i0000664000175000017500000000106712275776201022030 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-2.0.12/Examples/test-suite/template_whitespace.i0000664000175000017500000000107712275776201022530 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-2.0.12/Examples/test-suite/rename_camel.i0000664000175000017500000000223012275776201021101 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-2.0.12/Examples/d/0000775000175000017500000000000012275776201014437 5ustar williamwilliamswig-2.0.12/Examples/d/class/0000775000175000017500000000000012275776201015544 5ustar williamwilliamswig-2.0.12/Examples/d/class/d1/0000775000175000017500000000000012275776201016050 5ustar williamwilliamswig-2.0.12/Examples/d/class/d1/runme.d0000664000175000017500000000345412275776201017351 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-2.0.12/Examples/d/class/example.h0000664000175000017500000000113112275776201017344 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-2.0.12/Examples/d/class/example.i0000664000175000017500000000021612275776201017350 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/d/class/example.cxx0000664000175000017500000000066612275776201017733 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/d/class/Makefile0000664000175000017500000000135312275776201017206 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/class/d2/0000775000175000017500000000000012275776201016051 5ustar williamwilliamswig-2.0.12/Examples/d/class/d2/runme.d0000664000175000017500000000325012275776201017344 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-2.0.12/Examples/d/enum/0000775000175000017500000000000012275776201015403 5ustar williamwilliamswig-2.0.12/Examples/d/enum/d1/0000775000175000017500000000000012275776201015707 5ustar williamwilliamswig-2.0.12/Examples/d/enum/d1/runme.d0000664000175000017500000000203512275776201017202 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-2.0.12/Examples/d/enum/example.h0000664000175000017500000000032612275776201017210 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-2.0.12/Examples/d/enum/example.i0000664000175000017500000000021712275776201017210 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/d/enum/example.cxx0000664000175000017500000000151112275776201017560 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-2.0.12/Examples/d/enum/Makefile0000664000175000017500000000135312275776201017045 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/enum/d2/0000775000175000017500000000000012275776201015710 5ustar williamwilliamswig-2.0.12/Examples/d/enum/d2/runme.d0000664000175000017500000000171212275776201017204 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-2.0.12/Examples/d/simple/0000775000175000017500000000000012275776201015730 5ustar williamwilliamswig-2.0.12/Examples/d/simple/example.c0000664000175000017500000000036712275776201017535 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-2.0.12/Examples/d/simple/d1/0000775000175000017500000000000012275776201016234 5ustar williamwilliamswig-2.0.12/Examples/d/simple/d1/runme.d0000664000175000017500000000101112275776201017520 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-2.0.12/Examples/d/simple/example.i0000664000175000017500000000015212275776201017533 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/d/simple/Makefile0000664000175000017500000000134312275776201017371 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/simple/d2/0000775000175000017500000000000012275776201016235 5ustar williamwilliamswig-2.0.12/Examples/d/simple/d2/runme.d0000664000175000017500000000072412275776201017533 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-2.0.12/Examples/d/constants/0000775000175000017500000000000012275776201016453 5ustar williamwilliamswig-2.0.12/Examples/d/constants/d1/0000775000175000017500000000000012275776201016757 5ustar williamwilliamswig-2.0.12/Examples/d/constants/d1/runme.d0000664000175000017500000000211212275776201020246 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-2.0.12/Examples/d/constants/example.i0000664000175000017500000000144212275776201020261 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-2.0.12/Examples/d/constants/Makefile0000664000175000017500000000131412275776201020112 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/constants/d2/0000775000175000017500000000000012275776201016760 5ustar williamwilliamswig-2.0.12/Examples/d/constants/d2/runme.d0000664000175000017500000000175312275776201020261 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-2.0.12/Examples/d/constants/example.d0000664000175000017500000000142312275776201020253 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-2.0.12/Examples/d/extend/0000775000175000017500000000000012275776201015726 5ustar williamwilliamswig-2.0.12/Examples/d/extend/d1/0000775000175000017500000000000012275776201016232 5ustar williamwilliamswig-2.0.12/Examples/d/extend/d1/runme.d0000664000175000017500000000617712275776201017540 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 overidden 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-2.0.12/Examples/d/extend/example.h0000664000175000017500000000257212275776201017540 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", 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-2.0.12/Examples/d/extend/example.i0000664000175000017500000000035312275776201017534 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-2.0.12/Examples/d/extend/example.cxx0000664000175000017500000000006012275776201020101 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/d/extend/Makefile0000664000175000017500000000135312275776201017370 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/extend/d2/0000775000175000017500000000000012275776201016233 5ustar williamwilliamswig-2.0.12/Examples/d/extend/d2/runme.d0000664000175000017500000000605312275776201017532 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 overidden 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-2.0.12/Examples/d/check.list0000664000175000017500000000013312275776201016406 0ustar williamwilliam# See top-level Makefile.in. callback class constants enum extend funcptr simple variables swig-2.0.12/Examples/d/funcptr/0000775000175000017500000000000012275776201016120 5ustar williamwilliamswig-2.0.12/Examples/d/funcptr/example.c0000664000175000017500000000037012275776201017717 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-2.0.12/Examples/d/funcptr/d1/0000775000175000017500000000000012275776201016424 5ustar williamwilliamswig-2.0.12/Examples/d/funcptr/d1/runme.d0000664000175000017500000000241212275776201017716 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-2.0.12/Examples/d/funcptr/example.h0000664000175000017500000000026312275776201017725 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-2.0.12/Examples/d/funcptr/example.i0000664000175000017500000000056012275776201017726 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-2.0.12/Examples/d/funcptr/Makefile0000664000175000017500000000140412275776201017557 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile 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 DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/funcptr/d2/0000775000175000017500000000000012275776201016425 5ustar williamwilliamswig-2.0.12/Examples/d/funcptr/d2/runme.d0000664000175000017500000000150712275776201017723 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-2.0.12/Examples/d/callback/0000775000175000017500000000000012275776201016173 5ustar williamwilliamswig-2.0.12/Examples/d/callback/d1/0000775000175000017500000000000012275776201016477 5ustar williamwilliamswig-2.0.12/Examples/d/callback/d1/runme.d0000664000175000017500000000142312275776201017772 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-2.0.12/Examples/d/callback/example.h0000664000175000017500000000107112275776201017776 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-2.0.12/Examples/d/callback/example.i0000664000175000017500000000031212275776201017774 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-2.0.12/Examples/d/callback/example.cxx0000664000175000017500000000006012275776201020346 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/d/callback/Makefile0000664000175000017500000000135312275776201017635 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/callback/d2/0000775000175000017500000000000012275776201016500 5ustar williamwilliamswig-2.0.12/Examples/d/callback/d2/runme.d0000664000175000017500000000133112275776201017771 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-2.0.12/Examples/d/variables/0000775000175000017500000000000012275776201016407 5ustar williamwilliamswig-2.0.12/Examples/d/variables/example.c0000664000175000017500000000454212275776201020213 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/d/variables/d1/0000775000175000017500000000000012275776201016713 5ustar williamwilliamswig-2.0.12/Examples/d/variables/d1/runme.d0000664000175000017500000000516012275776201020210 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-2.0.12/Examples/d/variables/example.h0000664000175000017500000000007512275776201020215 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/d/variables/example.i0000664000175000017500000000174512275776201020223 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-2.0.12/Examples/d/variables/Makefile0000664000175000017500000000134312275776201020050 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 d_run build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean swig-2.0.12/Examples/d/variables/d2/0000775000175000017500000000000012275776201016714 5ustar williamwilliamswig-2.0.12/Examples/d/variables/d2/runme.d0000664000175000017500000000466312275776201020220 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-2.0.12/Examples/modula3/0000775000175000017500000000000012275776201015560 5ustar williamwilliamswig-2.0.12/Examples/modula3/class/0000775000175000017500000000000012275776201016665 5ustar williamwilliamswig-2.0.12/Examples/modula3/class/example.h0000664000175000017500000000123112275776201020466 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) const = 0; virtual double perimeter (void) const = 0; protected: static int nshapes; }; class Circle:public Shape { private: double radius; public: Circle (double r):radius (r) { }; virtual double area (void) const; virtual double perimeter (void) const; }; class Square:public Shape { private: double width; public: Square (double w):width (w) { }; virtual double area (void) const; virtual double perimeter (void) const; }; swig-2.0.12/Examples/modula3/class/example.i0000664000175000017500000000206612275776201020476 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-2.0.12/Examples/modula3/class/example.cxx0000664000175000017500000000066612275776201021054 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/modula3/class/Makefile0000664000175000017500000000116212275776201020325 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 modula3_run build: $(MAKE) -f $(TOP)/Makefile 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 modula3_clean swig-2.0.12/Examples/modula3/class/swig.tmpl0000664000175000017500000000037312275776201020537 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-2.0.12/Examples/modula3/enum/0000775000175000017500000000000012275776201016524 5ustar williamwilliamswig-2.0.12/Examples/modula3/enum/example.h0000664000175000017500000000421612275776201020333 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-2.0.12/Examples/modula3/enum/example.i0000664000175000017500000000572112275776201020336 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-2.0.12/Examples/modula3/enum/example.cxx0000664000175000017500000000122712275776201020705 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-2.0.12/Examples/modula3/enum/Makefile0000664000175000017500000000124312275776201020164 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 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 SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile modula3_clean swig-2.0.12/Examples/modula3/simple/0000775000175000017500000000000012275776201017051 5ustar williamwilliamswig-2.0.12/Examples/modula3/simple/example.c0000664000175000017500000000036712275776201020656 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-2.0.12/Examples/modula3/simple/example.i0000664000175000017500000000015212275776201020654 0ustar williamwilliam/* File : example.i */ %module Example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/modula3/simple/Makefile0000664000175000017500000000071612275776201020515 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile modula3_clean swig-2.0.12/Examples/modula3/typemap/0000775000175000017500000000000012275776201017237 5ustar williamwilliamswig-2.0.12/Examples/modula3/typemap/example.i0000664000175000017500000000660412275776201021052 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-2.0.12/Examples/modula3/typemap/Makefile0000664000175000017500000000071612275776201020703 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile modula3_clean swig-2.0.12/Examples/modula3/reference/0000775000175000017500000000000012275776201017516 5ustar williamwilliamswig-2.0.12/Examples/modula3/reference/example.h0000664000175000017500000000061712275776201021326 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-2.0.12/Examples/modula3/reference/example.i0000664000175000017500000000130612275776201021323 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-2.0.12/Examples/modula3/reference/example.cxx0000664000175000017500000000161112275776201021674 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 %x (%g,%g,%g)", (int)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-2.0.12/Examples/modula3/reference/Makefile0000664000175000017500000000072312275776201021160 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 check: build $(MAKE) -f $(TOP)/Makefile modula3_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile modula3_clean swig-2.0.12/Examples/modula3/check.list0000664000175000017500000000011212275776201017524 0ustar williamwilliam# see top-level Makefile.in class enum exception reference simple typemap swig-2.0.12/Examples/modula3/exception/0000775000175000017500000000000012275776201017556 5ustar williamwilliamswig-2.0.12/Examples/modula3/exception/example.h0000664000175000017500000000123012275776201021356 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-2.0.12/Examples/modula3/exception/example.i0000664000175000017500000000205312275776201021363 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-2.0.12/Examples/modula3/exception/Makefile0000664000175000017500000000114312275776201021215 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 modula3_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp # $(MAKE) -f $(TOP)/Makefile MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 clean: $(MAKE) -f $(TOP)/Makefile modula3_clean swig-2.0.12/Examples/README0000664000175000017500000000342412275776201015077 0ustar williamwilliamSWIG Examples The "perl5", "python", "tcl", "guile", "java", "mzscheme", "ruby", and "chicken" directories 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. The Examples directory is currently quite incomplete because it is being reorganized. A more complete set of examples can be found in the SWIG1.1p5 distribution (most of which should still work with SWIG1.3). 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 concering 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-2.0.12/Examples/python/0000775000175000017500000000000012275776201015535 5ustar williamwilliamswig-2.0.12/Examples/python/std_vector/0000775000175000017500000000000012275776201017711 5ustar williamwilliamswig-2.0.12/Examples/python/std_vector/example.h0000664000175000017500000000111612275776201021514 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-2.0.12/Examples/python/std_vector/example.i0000664000175000017500000000047512275776201021524 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-2.0.12/Examples/python/std_vector/Makefile0000664000175000017500000000107612275776201021355 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/std_vector/runme.py0000664000175000017500000000114512275776201021412 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-2.0.12/Examples/python/varargs/0000775000175000017500000000000012275776201017202 5ustar williamwilliamswig-2.0.12/Examples/python/varargs/example.i0000664000175000017500000000332112275776201021006 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-2.0.12/Examples/python/varargs/Makefile0000664000175000017500000000074112275776201020644 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/varargs/runme.py0000664000175000017500000000130012275776201020674 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-2.0.12/Examples/python/smartptr/0000775000175000017500000000000012275776201017411 5ustar williamwilliamswig-2.0.12/Examples/python/smartptr/example.h0000664000175000017500000000111512275776201021213 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-2.0.12/Examples/python/smartptr/example.i0000664000175000017500000000044712275776201021223 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-2.0.12/Examples/python/smartptr/example.cxx0000664000175000017500000000071612275776201021574 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-2.0.12/Examples/python/smartptr/smartptr.h0000664000175000017500000000034712275776201021442 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-2.0.12/Examples/python/smartptr/Makefile0000664000175000017500000000111112275776201021043 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/smartptr/runme.py0000664000175000017500000000205512275776201021113 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-2.0.12/Examples/python/import_template/0000775000175000017500000000000012275776201020742 5ustar williamwilliamswig-2.0.12/Examples/python/import_template/spam.h0000664000175000017500000000066612275776201022063 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-2.0.12/Examples/python/import_template/README0000664000175000017500000000165212275776201021626 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-2.0.12/Examples/python/import_template/spam.i0000664000175000017500000000014612275776201022055 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" %template(intSpam) Spam; swig-2.0.12/Examples/python/import_template/bar.i0000664000175000017500000000014312275776201021656 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" %template(intBar) Bar; swig-2.0.12/Examples/python/import_template/base.i0000664000175000017500000000012412275776201022023 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h %template(intBase) Base; swig-2.0.12/Examples/python/import_template/foo.i0000664000175000017500000000014212275776201021674 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" %template(intFoo) Foo; swig-2.0.12/Examples/python/import_template/foo.h0000664000175000017500000000055112275776201021677 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-2.0.12/Examples/python/import_template/base.h0000664000175000017500000000050112275776201022021 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-2.0.12/Examples/python/import_template/Makefile0000664000175000017500000000135412275776201022405 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f foo.py bar.py spam.py base.py swig-2.0.12/Examples/python/import_template/bar.h0000664000175000017500000000055212275776201021661 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-2.0.12/Examples/python/import_template/runme.py0000664000175000017500000000335212275776201022445 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-2.0.12/Examples/python/template/0000775000175000017500000000000012275776201017350 5ustar williamwilliamswig-2.0.12/Examples/python/template/example.h0000664000175000017500000000077712275776201021167 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-2.0.12/Examples/python/template/example.i0000664000175000017500000000051412275776201021155 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-2.0.12/Examples/python/template/Makefile0000664000175000017500000000107612275776201021014 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/template/runme.py0000664000175000017500000000074212275776201021053 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-2.0.12/Examples/python/contract/0000775000175000017500000000000012275776201017352 5ustar williamwilliamswig-2.0.12/Examples/python/contract/example.c0000664000175000017500000000047212275776201021154 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-2.0.12/Examples/python/contract/example.i0000664000175000017500000000040212275776201021153 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-2.0.12/Examples/python/contract/example.dsp0000664000175000017500000001210112275776201021510 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-2.0.12/Examples/python/contract/Makefile0000664000175000017500000000104212275776201021007 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/contract/runme.py0000664000175000017500000000055612275776201021060 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-2.0.12/Examples/python/class/0000775000175000017500000000000012275776201016642 5ustar williamwilliamswig-2.0.12/Examples/python/class/example.h0000664000175000017500000000114312275776201020445 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-2.0.12/Examples/python/class/example.i0000664000175000017500000000021612275776201020446 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/python/class/example.cxx0000664000175000017500000000066612275776201021031 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/python/class/index.html0000664000175000017500000001066412275776201020646 0ustar williamwilliam SWIG:Examples:python:class SWIG/Examples/python/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++ -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)
    

  • To access member data, a pair of accessor functions are used. For example:
    example.Shape_x_set(c,15)    # Set member data
    x = example.Shape_x_get(c)    # Get member data
    
    Note: when accessing member data, the name of the class in which the member data was must be used. In this case, Shape_x_get() and Shape_x_set() are used since 'x' was defined in Shape.

  • To invoke a member function, you simply do this
    print "The area is ", example.Shape_area(c)
    

  • Type checking knows about the inheritance structure of C++. For example:
    example.Shape_area(c)       # Works (c is a Shape)
    example.Circle_area(c)      # Works (c is a Circle)
    example.Square_area(c)      # Fails (c is definitely not a Square)
    

  • To invoke a destructor, simply do this
    example.delete_Shape(c)     # Deletes a shape
    
    (Note: destructors are currently not inherited. This might change later).

  • 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

  • This low-level interface is not the only way to handle C++ code. Proxy classes provide a much higher-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.

  • A wide variety of C++ features are not currently supported by SWIG. Here is the short and incomplete list:

    • Overloaded methods and functions. SWIG wrappers don't know how to resolve name conflicts so you must give an alternative name to any overloaded method name using the %name directive like this:
      void foo(int a);  
      %name(foo2) void foo(double a, double b);
      

    • Overloaded operators. Not supported at all. The only workaround for this is to write a helper function. For example:
      %inline %{
          Vector *vector_add(Vector *a, Vector *b) {
                ... whatever ...
          }
      %}
      

    • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).

    • Dave's snide remark: Like a large bottle of strong Tequilla, it's better to use C++ in moderation.

    swig-2.0.12/Examples/python/class/example.dsp0000664000175000017500000001222112275776201021003 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-2.0.12/Examples/python/class/Makefile0000664000175000017500000000102112275776201020274 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/class/runme.py0000664000175000017500000000175312275776201020350 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() print "\nGuess I'll clean up now" # Note: this invokes the virtual destructor del c del s s = 3 print example.cvar.Shape_nshapes,"shapes remain" print "Goodbye" swig-2.0.12/Examples/python/pointer/0000775000175000017500000000000012275776201017215 5ustar williamwilliamswig-2.0.12/Examples/python/pointer/example.c0000664000175000017500000000036112275776201021014 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-2.0.12/Examples/python/pointer/example.i0000664000175000017500000000117612275776201021027 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-2.0.12/Examples/python/pointer/index.html0000664000175000017500000000657512275776201021227 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-2.0.12/Examples/python/pointer/Makefile0000664000175000017500000000075212275776201020661 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/pointer/runme.py0000664000175000017500000000162612275776201020722 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-2.0.12/Examples/python/swigrun/0000775000175000017500000000000012275776201017233 5ustar williamwilliamswig-2.0.12/Examples/python/swigrun/example.h0000664000175000017500000000265212275776201021044 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", 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-2.0.12/Examples/python/swigrun/example.i0000664000175000017500000000040312275776201021035 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-2.0.12/Examples/python/swigrun/example.cxx0000664000175000017500000000057512275776201021421 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", ty); if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) { c_ptr = 0; } else { Py_XINCREF(py_obj); } return c_ptr; } swig-2.0.12/Examples/python/swigrun/Makefile0000664000175000017500000000122512275776201020673 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(SWIG) -python -external-runtime $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f swigpyrun.h swig-2.0.12/Examples/python/swigrun/runme.py0000664000175000017500000000121612275776201020733 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-2.0.12/Examples/python/docstrings/0000775000175000017500000000000012275776201017714 5ustar williamwilliamswig-2.0.12/Examples/python/docstrings/example.h0000664000175000017500000000005412275776201021517 0ustar williamwilliamclass Foo { public: void bar(); }; swig-2.0.12/Examples/python/docstrings/example.i0000664000175000017500000000042412275776201021521 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-2.0.12/Examples/python/docstrings/example.cxx0000664000175000017500000000005212275776201022070 0ustar williamwilliam#include "example.h" void Foo::bar() {} swig-2.0.12/Examples/python/docstrings/Makefile0000664000175000017500000000112112275776201021347 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = -O check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/docstrings/runme.py0000664000175000017500000000020212275776201021406 0ustar williamwilliam# file: runme.py import example print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')" swig-2.0.12/Examples/python/enum/0000775000175000017500000000000012275776201016501 5ustar williamwilliamswig-2.0.12/Examples/python/enum/example.h0000664000175000017500000000031512275776201020304 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-2.0.12/Examples/python/enum/example.i0000664000175000017500000000021712275776201020306 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/python/enum/example.cxx0000664000175000017500000000150712275776201020663 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-2.0.12/Examples/python/enum/index.html0000664000175000017500000000146612275776201020505 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-2.0.12/Examples/python/enum/Makefile0000664000175000017500000000102112275776201020133 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/enum/runme.py0000664000175000017500000000145112275776201020202 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-2.0.12/Examples/python/exceptproxy/0000775000175000017500000000000012275776201020127 5ustar williamwilliamswig-2.0.12/Examples/python/exceptproxy/example.h0000664000175000017500000000207012275776201021732 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-2.0.12/Examples/python/exceptproxy/example.i0000664000175000017500000000645412275776201021745 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-2.0.12/Examples/python/exceptproxy/Makefile0000664000175000017500000000107612275776201021573 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/exceptproxy/runme.py0000664000175000017500000000121712275776201021630 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-2.0.12/Examples/python/simple/0000775000175000017500000000000012275776201017026 5ustar williamwilliamswig-2.0.12/Examples/python/simple/example.c0000664000175000017500000000036712275776201020633 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-2.0.12/Examples/python/simple/example.i0000664000175000017500000000015212275776201020631 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/python/simple/index.html0000664000175000017500000000325612275776201021031 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-2.0.12/Examples/python/simple/example.dsp0000664000175000017500000001210112275776201021164 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-2.0.12/Examples/python/simple/Makefile0000664000175000017500000000075212275776201020472 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/simple/runme.py0000664000175000017500000000055612275776201020534 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-2.0.12/Examples/python/constants/0000775000175000017500000000000012275776201017551 5ustar williamwilliamswig-2.0.12/Examples/python/constants/example.i0000664000175000017500000000113512275776201021356 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-2.0.12/Examples/python/constants/index.html0000664000175000017500000000363212275776201021552 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-2.0.12/Examples/python/constants/Makefile0000664000175000017500000000074112275776201021213 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/constants/runme.py0000664000175000017500000000152312275776201021252 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-2.0.12/Examples/python/extend/0000775000175000017500000000000012275776201017024 5ustar williamwilliamswig-2.0.12/Examples/python/extend/example.h0000664000175000017500000000257512275776201020641 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", 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-2.0.12/Examples/python/extend/example.i0000664000175000017500000000040312275776201020626 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-2.0.12/Examples/python/extend/example.cxx0000664000175000017500000000006012275776201021177 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/python/extend/index.html0000664000175000017500000000045412275776201021024 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-2.0.12/Examples/python/extend/Makefile0000664000175000017500000000113712275776201020466 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/extend/runme.py0000664000175000017500000000627512275776201020536 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-2.0.12/Examples/python/performance/0000775000175000017500000000000012275776201020036 5ustar williamwilliamswig-2.0.12/Examples/python/performance/harness.py0000664000175000017500000000144512275776201022057 0ustar williamwilliam#!/usr/bin/env import 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-2.0.12/Examples/python/performance/func/0000775000175000017500000000000012275776201020771 5ustar williamwilliamswig-2.0.12/Examples/python/performance/func/Simple.i0000664000175000017500000000014212275776201022371 0ustar williamwilliam%inline %{ class MyClass { public: MyClass () {} ~MyClass () {} void func () {} }; %} swig-2.0.12/Examples/python/performance/func/Makefile0000664000175000017500000000147712275776201022442 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-2.0.12/Examples/python/performance/func/runme.py0000664000175000017500000000025312275776201022471 0ustar williamwilliam#!/usr/bin/env import sys sys.path.append('..') import harness def proc (mod) : x = mod.MyClass() for i in range(10000000) : x.func() harness.run(proc) swig-2.0.12/Examples/python/performance/constructor/0000775000175000017500000000000012275776201022423 5ustar williamwilliamswig-2.0.12/Examples/python/performance/constructor/Simple.i0000664000175000017500000000014212275776201024023 0ustar williamwilliam%inline %{ class MyClass { public: MyClass () {} ~MyClass () {} void func () {} }; %} swig-2.0.12/Examples/python/performance/constructor/Makefile0000664000175000017500000000147712275776201024074 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-2.0.12/Examples/python/performance/constructor/runme.py0000664000175000017500000000023512275776201024123 0ustar williamwilliam#!/usr/bin/env import sys sys.path.append('..') import harness def proc (mod) : for i in range(1000000) : x = mod.MyClass() harness.run(proc) swig-2.0.12/Examples/python/performance/hierarchy/0000775000175000017500000000000012275776201022014 5ustar williamwilliamswig-2.0.12/Examples/python/performance/hierarchy/Simple.i0000664000175000017500000000075012275776201023421 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-2.0.12/Examples/python/performance/hierarchy/Makefile0000664000175000017500000000147712275776201023465 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-2.0.12/Examples/python/performance/hierarchy/runme.py0000664000175000017500000000024512275776201023515 0ustar williamwilliam#!/usr/bin/env import sys sys.path.append('..') import harness def proc (mod) : x = mod.H() for i in range(10000000) : x.func() harness.run(proc) swig-2.0.12/Examples/python/performance/Makefile0000664000175000017500000000144512275776201021502 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-2.0.12/Examples/python/performance/operator/0000775000175000017500000000000012275776201021671 5ustar williamwilliamswig-2.0.12/Examples/python/performance/operator/Simple.i0000664000175000017500000000017712275776201023301 0ustar williamwilliam%inline %{ class MyClass { public: MyClass () {} ~MyClass () {} MyClass& operator+ (int i) { return *this; } }; %} swig-2.0.12/Examples/python/performance/operator/Makefile0000664000175000017500000000147712275776201023342 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-2.0.12/Examples/python/performance/operator/runme.py0000664000175000017500000000025412275776201023372 0ustar williamwilliam#!/usr/bin/env import sys sys.path.append('..') import harness def proc (mod) : x = mod.MyClass() for i in range(10000000) : x = x + i harness.run(proc) swig-2.0.12/Examples/python/performance/hierarchy_operator/0000775000175000017500000000000012275776201023727 5ustar williamwilliamswig-2.0.12/Examples/python/performance/hierarchy_operator/Simple.i0000664000175000017500000000102412275776201025327 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-2.0.12/Examples/python/performance/hierarchy_operator/Makefile0000664000175000017500000000147712275776201025400 0ustar williamwilliamTOP = ../../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f $(TARGET)_*.py swig-2.0.12/Examples/python/performance/hierarchy_operator/runme.py0000664000175000017500000000024312275776201025426 0ustar williamwilliam#!/usr/bin/env import sys sys.path.append('..') import harness def proc (mod) : x = mod.H() for i in range(10000000) : x += i harness.run(proc) swig-2.0.12/Examples/python/reference/0000775000175000017500000000000012275776201017473 5ustar williamwilliamswig-2.0.12/Examples/python/reference/example.h0000664000175000017500000000064512275776201021304 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-2.0.12/Examples/python/reference/example.i0000664000175000017500000000134412275776201021302 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-2.0.12/Examples/python/reference/example.cxx0000664000175000017500000000160412275776201021653 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)", 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-2.0.12/Examples/python/reference/index.html0000664000175000017500000000633512275776201021477 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-2.0.12/Examples/python/reference/Makefile0000664000175000017500000000102112275776201021125 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/reference/runme.py0000664000175000017500000000240312275776201021172 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-2.0.12/Examples/python/functor/0000775000175000017500000000000012275776201017215 5ustar williamwilliamswig-2.0.12/Examples/python/functor/example.i0000664000175000017500000000111312275776201021016 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-2.0.12/Examples/python/functor/Makefile0000664000175000017500000000105112275776201020652 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/functor/runme.py0000664000175000017500000000053112275776201020714 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-2.0.12/Examples/python/libffi/0000775000175000017500000000000012275776201016770 5ustar williamwilliamswig-2.0.12/Examples/python/libffi/example.i0000664000175000017500000000763212275776201020605 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-2.0.12/Examples/python/libffi/Makefile0000664000175000017500000000077712275776201020443 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/check.list0000664000175000017500000000042212275776201017505 0ustar williamwilliam# see top-level Makefile.in callback class constants contract docstrings enum exception exceptproxy extend funcptr funcptr2 functor import import_template java #libffi multimap operator pointer reference simple smartptr std_vector std_map swigrun template varargs variables swig-2.0.12/Examples/python/funcptr2/0000775000175000017500000000000012275776201017300 5ustar williamwilliamswig-2.0.12/Examples/python/funcptr2/example.c0000664000175000017500000000037012275776201021077 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-2.0.12/Examples/python/funcptr2/example.h0000664000175000017500000000026312275776201021105 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-2.0.12/Examples/python/funcptr2/example.i0000664000175000017500000000053712275776201021112 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-2.0.12/Examples/python/funcptr2/Makefile0000664000175000017500000000075212275776201020744 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/funcptr2/runme.py0000664000175000017500000000123112275776201020775 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-2.0.12/Examples/python/index.html0000664000175000017500000000636612275776201017545 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 or in the most excellent (and shamelessly plugged) Python Essential Reference:

      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-2.0.12/Examples/python/exception/0000775000175000017500000000000012275776201017533 5ustar williamwilliamswig-2.0.12/Examples/python/exception/example.h0000664000175000017500000000201312275776201021333 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-2.0.12/Examples/python/exception/example.i0000664000175000017500000000024712275776201021343 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-2.0.12/Examples/python/exception/Makefile0000664000175000017500000000100612275776201021170 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/exception/runme.py0000664000175000017500000000104712275776201021235 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-2.0.12/Examples/python/funcptr/0000775000175000017500000000000012275776201017216 5ustar williamwilliamswig-2.0.12/Examples/python/funcptr/example.c0000664000175000017500000000037012275776201021015 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-2.0.12/Examples/python/funcptr/example.h0000664000175000017500000000026312275776201021023 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-2.0.12/Examples/python/funcptr/example.i0000664000175000017500000000056012275776201021024 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-2.0.12/Examples/python/funcptr/index.html0000664000175000017500000000370612275776201021221 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-2.0.12/Examples/python/funcptr/Makefile0000664000175000017500000000075212275776201020662 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/funcptr/runme.py0000664000175000017500000000103712275776201020717 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-2.0.12/Examples/python/java/0000775000175000017500000000000012275776201016456 5ustar williamwilliamswig-2.0.12/Examples/python/java/example.i0000664000175000017500000000012212275776201020256 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-2.0.12/Examples/python/java/Makefile0000664000175000017500000000103612275776201020116 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp clean: $(MAKE) -f $(TOP)/Makefile python_clean rm -f $(TARGET).py rm -f *.class Example.h Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example swig-2.0.12/Examples/python/java/Example.java0000664000175000017500000000075012275776201020716 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-2.0.12/Examples/python/java/runme.py0000664000175000017500000000035712275776201020163 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-2.0.12/Examples/python/std_map/0000775000175000017500000000000012275776201017164 5ustar williamwilliamswig-2.0.12/Examples/python/std_map/example.h0000664000175000017500000000053012275776201020766 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-2.0.12/Examples/python/std_map/example.i0000664000175000017500000000121612275776201020771 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-2.0.12/Examples/python/std_map/Makefile0000664000175000017500000000107612275776201020630 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/std_map/runme.py0000664000175000017500000000207612275776201020671 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-2.0.12/Examples/python/multimap/0000775000175000017500000000000012275776201017365 5ustar williamwilliamswig-2.0.12/Examples/python/multimap/example.c0000664000175000017500000000164012275776201021165 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-2.0.12/Examples/python/multimap/example.i0000664000175000017500000000674612275776201021207 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 it's 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-2.0.12/Examples/python/multimap/example.dsp0000664000175000017500000001210112275776201021523 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-2.0.12/Examples/python/multimap/Makefile0000664000175000017500000000075212275776201021031 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/multimap/runme.py0000664000175000017500000000055112275776201021066 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-2.0.12/Examples/python/operator/0000775000175000017500000000000012275776201017370 5ustar williamwilliamswig-2.0.12/Examples/python/operator/example.h0000664000175000017500000000147312275776201021201 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-2.0.12/Examples/python/operator/example.i0000664000175000017500000000127112275776201021176 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-2.0.12/Examples/python/operator/Makefile0000664000175000017500000000105112275776201021025 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/operator/runme.py0000664000175000017500000000045712275776201021076 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-2.0.12/Examples/python/callback/0000775000175000017500000000000012275776201017271 5ustar williamwilliamswig-2.0.12/Examples/python/callback/example.h0000664000175000017500000000077612275776201021107 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-2.0.12/Examples/python/callback/example.i0000664000175000017500000000031212275776201021072 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-2.0.12/Examples/python/callback/example.cxx0000664000175000017500000000006012275776201021444 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/python/callback/index.html0000664000175000017500000000045012275776201021265 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-2.0.12/Examples/python/callback/Makefile0000664000175000017500000000113712275776201020733 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/callback/runme.py0000664000175000017500000000230112275776201020765 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 "------------------------------------------" # Lets 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-2.0.12/Examples/python/import/0000775000175000017500000000000012275776201017047 5ustar williamwilliamswig-2.0.12/Examples/python/import/spam.dsp0000664000175000017500000001162212275776201020521 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-2.0.12/Examples/python/import/spam.h0000664000175000017500000000061412275776201020161 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-2.0.12/Examples/python/import/README0000664000175000017500000000242112275776201017726 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-2.0.12/Examples/python/import/spam.i0000664000175000017500000000011012275776201020151 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-2.0.12/Examples/python/import/bar.i0000664000175000017500000000010612275776201017762 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-2.0.12/Examples/python/import/base.i0000664000175000017500000000006612275776201020135 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-2.0.12/Examples/python/import/foo.dsp0000664000175000017500000001157012275776201020346 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-2.0.12/Examples/python/import/base.dsp0000664000175000017500000001162212275776201020473 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-2.0.12/Examples/python/import/foo.i0000664000175000017500000000010512275776201020000 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-2.0.12/Examples/python/import/foo.h0000664000175000017500000000050512275776201020003 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-2.0.12/Examples/python/import/base.h0000664000175000017500000000045112275776201020132 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-2.0.12/Examples/python/import/Makefile0000664000175000017500000000135412275776201020512 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f foo.py bar.py spam.py base.py swig-2.0.12/Examples/python/import/example.dsw0000664000175000017500000000206412275776201021223 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-2.0.12/Examples/python/import/bar.h0000664000175000017500000000050612275776201017765 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-2.0.12/Examples/python/import/runme.py0000664000175000017500000000330312275776201020546 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-2.0.12/Examples/python/import/bar.dsp0000664000175000017500000001157012275776201020327 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-2.0.12/Examples/python/variables/0000775000175000017500000000000012275776201017505 5ustar williamwilliamswig-2.0.12/Examples/python/variables/example.c0000664000175000017500000000456512275776201021316 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/python/variables/example.h0000664000175000017500000000007512275776201021313 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/python/variables/example.i0000664000175000017500000000203012275776201021305 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-2.0.12/Examples/python/variables/index.html0000664000175000017500000000756212275776201021514 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-2.0.12/Examples/python/variables/Makefile0000664000175000017500000000075212275776201021151 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile python_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean swig-2.0.12/Examples/python/variables/runme.py0000664000175000017500000000402712275776201021210 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-2.0.12/Examples/octave/0000775000175000017500000000000012275776201015475 5ustar williamwilliamswig-2.0.12/Examples/octave/template/0000775000175000017500000000000012275776201017310 5ustar williamwilliamswig-2.0.12/Examples/octave/template/example.h0000664000175000017500000000077612275776201021126 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-2.0.12/Examples/octave/template/example.i0000664000175000017500000000051712275776201021120 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-2.0.12/Examples/octave/template/Makefile0000664000175000017500000000061712275776201020754 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/template/runme.m0000664000175000017500000000066312275776201020621 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-2.0.12/Examples/octave/contract/0000775000175000017500000000000012275776201017312 5ustar williamwilliamswig-2.0.12/Examples/octave/contract/example.c0000664000175000017500000000047012275776201021112 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-2.0.12/Examples/octave/contract/example.i0000664000175000017500000000040612275776201021117 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-2.0.12/Examples/octave/contract/Makefile0000664000175000017500000000053412275776201020754 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/contract/runme.m0000664000175000017500000000060312275776201020615 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-2.0.12/Examples/octave/class/0000775000175000017500000000000012275776201016602 5ustar williamwilliamswig-2.0.12/Examples/octave/class/example.h0000664000175000017500000000113112275776201020402 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-2.0.12/Examples/octave/class/example.i0000664000175000017500000000022112275776201020402 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/octave/class/example.cxx0000664000175000017500000000066612275776201020771 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/octave/class/Makefile0000664000175000017500000000064612275776201020250 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/class/runme.m0000664000175000017500000000177112275776201020114 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-2.0.12/Examples/octave/pointer/0000775000175000017500000000000012275776201017155 5ustar williamwilliamswig-2.0.12/Examples/octave/pointer/example.c0000664000175000017500000000036112275776201020754 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-2.0.12/Examples/octave/pointer/example.i0000664000175000017500000000117612275776201020767 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-2.0.12/Examples/octave/pointer/Makefile0000664000175000017500000000053412275776201020617 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/pointer/runme.m0000664000175000017500000000166212275776201020466 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-2.0.12/Examples/octave/enum/0000775000175000017500000000000012275776201016441 5ustar williamwilliamswig-2.0.12/Examples/octave/enum/example.h0000664000175000017500000000031412275776201020243 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-2.0.12/Examples/octave/enum/example.i0000664000175000017500000000022212275776201020242 0ustar williamwilliam/* File : example.i */ %module swigexample %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/octave/enum/example.cxx0000664000175000017500000000150712275776201020623 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-2.0.12/Examples/octave/enum/Makefile0000664000175000017500000000064612275776201020107 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/enum/runme.m0000664000175000017500000000167512275776201017756 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-2.0.12/Examples/octave/module_load/0000775000175000017500000000000012275776201017761 5ustar williamwilliamswig-2.0.12/Examples/octave/module_load/example.c0000664000175000017500000000013512275776201021557 0ustar williamwilliam/* File : example.c */ #include "example.h" int ivar = 47; int ifunc() { return ivar; } swig-2.0.12/Examples/octave/module_load/example.h0000664000175000017500000000006612275776201021567 0ustar williamwilliam/* File: example.h */ extern int ivar; int ifunc(); swig-2.0.12/Examples/octave/module_load/example.i0000664000175000017500000000017112275776201021565 0ustar williamwilliam/* File : example.i */ /* module name given on cmdline */ %{ #include "example.h" %} extern "C" int ivar; int ifunc(); swig-2.0.12/Examples/octave/module_load/Makefile0000664000175000017500000000104512275776201021421 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' SWIGOPT='-module $$(TARGET)' INTERFACE='$(INTERFACE)' octave $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean rm -f $(TARGET).m swig-2.0.12/Examples/octave/module_load/runme.m0000664000175000017500000000317612275776201021274 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-2.0.12/Examples/octave/simple/0000775000175000017500000000000012275776201016766 5ustar williamwilliamswig-2.0.12/Examples/octave/simple/example.c0000664000175000017500000000036512275776201020571 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-2.0.12/Examples/octave/simple/example.i0000664000175000017500000000015612275776201020575 0ustar williamwilliam/* File : example.i */ %module swigexample %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/octave/simple/Makefile0000664000175000017500000000053412275776201020430 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/simple/runme.m0000664000175000017500000000055012275776201020272 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-2.0.12/Examples/octave/constants/0000775000175000017500000000000012275776201017511 5ustar williamwilliamswig-2.0.12/Examples/octave/constants/example.i0000664000175000017500000000113712275776201021320 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-2.0.12/Examples/octave/constants/Makefile0000664000175000017500000000063212275776201021152 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/constants/runme.m0000664000175000017500000000165512275776201021024 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-2.0.12/Examples/octave/extend/0000775000175000017500000000000012275776201016764 5ustar williamwilliamswig-2.0.12/Examples/octave/extend/example.h0000664000175000017500000000257312275776201020577 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", 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-2.0.12/Examples/octave/extend/example.i0000664000175000017500000000040612275776201020571 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-2.0.12/Examples/octave/extend/example.cxx0000664000175000017500000000005712275776201021145 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/octave/extend/Makefile0000664000175000017500000000064612275776201020432 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/extend/runme.m0000664000175000017500000000570412275776201020276 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-2.0.12/Examples/octave/reference/0000775000175000017500000000000012275776201017433 5ustar williamwilliamswig-2.0.12/Examples/octave/reference/example.h0000664000175000017500000000063712275776201021245 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-2.0.12/Examples/octave/reference/example.i0000664000175000017500000000134212275776201021240 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-2.0.12/Examples/octave/reference/example.cxx0000664000175000017500000000160312275776201021612 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)", 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-2.0.12/Examples/octave/reference/Makefile0000664000175000017500000000064612275776201021101 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/reference/runme.m0000664000175000017500000000237312275776201020744 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-2.0.12/Examples/octave/functor/0000775000175000017500000000000012275776201017155 5ustar williamwilliamswig-2.0.12/Examples/octave/functor/example.i0000664000175000017500000000111312275776201020756 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-2.0.12/Examples/octave/functor/Makefile0000664000175000017500000000061712275776201020621 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/functor/runme.m0000664000175000017500000000047612275776201020470 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-2.0.12/Examples/octave/check.list0000664000175000017500000000024412275776201017447 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-2.0.12/Examples/octave/funcptr2/0000775000175000017500000000000012275776201017240 5ustar williamwilliamswig-2.0.12/Examples/octave/funcptr2/example.c0000664000175000017500000000037012275776201021037 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-2.0.12/Examples/octave/funcptr2/example.h0000664000175000017500000000026212275776201021044 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-2.0.12/Examples/octave/funcptr2/example.i0000664000175000017500000000054212275776201021046 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-2.0.12/Examples/octave/funcptr2/Makefile0000664000175000017500000000053412275776201020702 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/funcptr2/runme.m0000664000175000017500000000127712275776201020553 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-2.0.12/Examples/octave/funcptr/0000775000175000017500000000000012275776201017156 5ustar williamwilliamswig-2.0.12/Examples/octave/funcptr/example.c0000664000175000017500000000037012275776201020755 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-2.0.12/Examples/octave/funcptr/example.h0000664000175000017500000000026212275776201020762 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-2.0.12/Examples/octave/funcptr/example.i0000664000175000017500000000056312275776201020767 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-2.0.12/Examples/octave/funcptr/Makefile0000664000175000017500000000053412275776201020620 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/funcptr/runme.m0000664000175000017500000000105012275776201020456 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-2.0.12/Examples/octave/operator/0000775000175000017500000000000012275776201017330 5ustar williamwilliamswig-2.0.12/Examples/octave/operator/example.h0000664000175000017500000000171612275776201021141 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-2.0.12/Examples/octave/operator/example.i0000664000175000017500000000113412275776201021134 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-2.0.12/Examples/octave/operator/Makefile0000664000175000017500000000061712275776201020774 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/operator/runme.m0000664000175000017500000000101412275776201020630 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-2.0.12/Examples/octave/callback/0000775000175000017500000000000012275776201017231 5ustar williamwilliamswig-2.0.12/Examples/octave/callback/example.h0000664000175000017500000000101712275776201021034 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-2.0.12/Examples/octave/callback/example.i0000664000175000017500000000031512275776201021035 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-2.0.12/Examples/octave/callback/example.cxx0000664000175000017500000000005712275776201021412 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/octave/callback/Makefile0000664000175000017500000000064612275776201020677 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = swigexample INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/callback/runme.m0000664000175000017500000000305312275776201020536 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-2.0.12/Examples/octave/variables/0000775000175000017500000000000012275776201017445 5ustar williamwilliamswig-2.0.12/Examples/octave/variables/example.c0000664000175000017500000000454112275776201021250 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/octave/variables/example.h0000664000175000017500000000007412275776201021252 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/octave/variables/example.i0000664000175000017500000000217012275776201021252 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-2.0.12/Examples/octave/variables/Makefile0000664000175000017500000000053412275776201021107 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = swigexample INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile octave_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave clean: $(MAKE) -f $(TOP)/Makefile octave_clean swig-2.0.12/Examples/octave/variables/runme.m0000664000175000017500000000446012275776201020755 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-2.0.12/Examples/contract/0000775000175000017500000000000012275776201016031 5ustar williamwilliamswig-2.0.12/Examples/contract/simple_cxx/0000775000175000017500000000000012275776201020204 5ustar williamwilliamswig-2.0.12/Examples/contract/simple_cxx/runme3.py0000664000175000017500000000222512275776201021770 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-2.0.12/Examples/contract/simple_cxx/example.h0000664000175000017500000000113412275776201022007 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-2.0.12/Examples/contract/simple_cxx/runme2.py0000664000175000017500000000160412275776201021767 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-2.0.12/Examples/contract/simple_cxx/example.i0000664000175000017500000000066312275776201022016 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-2.0.12/Examples/contract/simple_cxx/runme1.py0000664000175000017500000000120512275776201021763 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-2.0.12/Examples/contract/simple_cxx/example.cxx0000664000175000017500000000075512275776201022372 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-2.0.12/Examples/contract/simple_c/0000775000175000017500000000000012275776201017624 5ustar williamwilliamswig-2.0.12/Examples/contract/simple_c/example.c0000664000175000017500000000034012275776201021420 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-2.0.12/Examples/contract/simple_c/runme2.py0000664000175000017500000000047012275776201021407 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-2.0.12/Examples/contract/simple_c/example.i0000664000175000017500000000050112275776201021425 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-2.0.12/Examples/contract/simple_c/runme1.py0000664000175000017500000000036512275776201021411 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-2.0.12/Examples/guile/0000775000175000017500000000000012275776201015321 5ustar williamwilliamswig-2.0.12/Examples/guile/std_vector/0000775000175000017500000000000012275776201017475 5ustar williamwilliamswig-2.0.12/Examples/guile/std_vector/example.h0000664000175000017500000000111612275776201021300 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-2.0.12/Examples/guile/std_vector/example.i0000664000175000017500000000047512275776201021310 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-2.0.12/Examples/guile/std_vector/runme.scm0000664000175000017500000000250212275776201021326 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-2.0.12/Examples/guile/std_vector/Makefile0000664000175000017500000000076012275776201021140 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile guile_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/guile/README0000664000175000017500000000111212275776201016174 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-2.0.12/Examples/guile/port/0000775000175000017500000000000012275776201016305 5ustar williamwilliamswig-2.0.12/Examples/guile/port/README0000664000175000017500000000020712275776201017164 0ustar williamwilliamThis example illustrates the translation from Scheme file ports to temporary FILE streams. Read the source and run ./port -s runme.scm swig-2.0.12/Examples/guile/port/example.c0000664000175000017500000000045212275776201020105 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-2.0.12/Examples/guile/port/example.i0000664000175000017500000000030012275776201020103 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-2.0.12/Examples/guile/port/runme.scm0000664000175000017500000000221712275776201020141 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-2.0.12/Examples/guile/port/Makefile0000664000175000017500000000063412275776201017750 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = port INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean rm -f test.out swig-2.0.12/Examples/guile/class/0000775000175000017500000000000012275776201016426 5ustar williamwilliamswig-2.0.12/Examples/guile/class/example.h0000664000175000017500000000113112275776201020226 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-2.0.12/Examples/guile/class/example.i0000664000175000017500000000021512275776201020231 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/guile/class/example.cxx0000664000175000017500000000066612275776201020615 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/guile/class/runme.scm0000664000175000017500000000300412275776201020255 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-2.0.12/Examples/guile/class/Makefile0000664000175000017500000000077412275776201020076 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile guile_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/guile/simple/0000775000175000017500000000000012275776201016612 5ustar williamwilliamswig-2.0.12/Examples/guile/simple/README0000664000175000017500000000025012275776201017467 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-2.0.12/Examples/guile/simple/example.c0000664000175000017500000000045612275776201020416 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-2.0.12/Examples/guile/simple/example.i0000664000175000017500000000036512275776201020423 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-2.0.12/Examples/guile/simple/runme.scm0000664000175000017500000000117012275776201020443 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-2.0.12/Examples/guile/simple/Makefile0000664000175000017500000000062012275776201020250 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my-guile INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/guile/constants/0000775000175000017500000000000012275776201017335 5ustar williamwilliamswig-2.0.12/Examples/guile/constants/example.i0000664000175000017500000000116112275776201021141 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-2.0.12/Examples/guile/constants/runme.scm0000664000175000017500000000217012275776201021167 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-2.0.12/Examples/guile/constants/Makefile0000664000175000017500000000060712275776201021000 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = my-guile INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/guile/multivalue/0000775000175000017500000000000012275776201017510 5ustar williamwilliamswig-2.0.12/Examples/guile/multivalue/example.c0000664000175000017500000000051612275776201021311 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-2.0.12/Examples/guile/multivalue/example.i0000664000175000017500000000174412275776201021323 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-2.0.12/Examples/guile/multivalue/runme.scm0000664000175000017500000000411112275776201021337 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-2.0.12/Examples/guile/multivalue/Makefile0000664000175000017500000000074612275776201021157 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile guile_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/guile/matrix/0000775000175000017500000000000012275776201016625 5ustar williamwilliamswig-2.0.12/Examples/guile/matrix/README0000664000175000017500000000040412275776201017503 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-2.0.12/Examples/guile/matrix/example.i0000664000175000017500000000040312275776201020427 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-2.0.12/Examples/guile/matrix/vector.h0000664000175000017500000000014012275776201020273 0ustar williamwilliam #include typedef struct { double x; double y; double z; double w; } Vector; swig-2.0.12/Examples/guile/matrix/vector.i0000664000175000017500000000062012275776201020277 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-2.0.12/Examples/guile/matrix/matrix.c0000664000175000017500000000156012275776201020277 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-2.0.12/Examples/guile/matrix/runme.scm0000775000175000017500000001222012275776201020457 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-2.0.12/Examples/guile/matrix/vector.c0000664000175000017500000000144112275776201020273 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-2.0.12/Examples/guile/matrix/Makefile0000664000175000017500000000067712275776201020277 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = matrix.c vector.c TARGET = matrix INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-lm' guile_augmented clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/guile/matrix/matrix.i0000664000175000017500000000127612275776201020311 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-2.0.12/Examples/guile/check.list0000664000175000017500000000013612275776201017273 0ustar williamwilliam# see top-level Makefile.in constants class port simple std_vector matrix multimap multivalue swig-2.0.12/Examples/guile/multimap/0000775000175000017500000000000012275776201017151 5ustar williamwilliamswig-2.0.12/Examples/guile/multimap/example.c0000664000175000017500000000164012275776201020751 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-2.0.12/Examples/guile/multimap/example.i0000664000175000017500000000447512275776201020770 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-2.0.12/Examples/guile/multimap/runme.scm0000664000175000017500000000077712275776201021016 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-2.0.12/Examples/guile/multimap/Makefile0000664000175000017500000000074612275776201020620 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile guile_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean swig-2.0.12/Examples/go/0000775000175000017500000000000012275776201014621 5ustar williamwilliamswig-2.0.12/Examples/go/template/0000775000175000017500000000000012275776201016434 5ustar williamwilliamswig-2.0.12/Examples/go/template/runme.go0000664000175000017500000000116712275776201020116 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-2.0.12/Examples/go/template/example.h0000664000175000017500000000077712275776201020253 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-2.0.12/Examples/go/template/example.i0000664000175000017500000000051412275776201020241 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-2.0.12/Examples/go/template/index.html0000664000175000017500000000444012275776201020433 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

    Lets 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-2.0.12/Examples/go/template/Makefile0000664000175000017500000000066412275776201020102 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/class/0000775000175000017500000000000012275776201015726 5ustar williamwilliamswig-2.0.12/Examples/go/class/runme.go0000664000175000017500000000303712275776201017406 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-2.0.12/Examples/go/class/example.h0000664000175000017500000000114312275776201017531 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-2.0.12/Examples/go/class/example.i0000664000175000017500000000021612275776201017532 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/go/class/example.cxx0000664000175000017500000000066612275776201020115 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/go/class/index.html0000664000175000017500000001100212275776201017715 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-2.0.12/Examples/go/class/Makefile0000664000175000017500000000065612275776201017375 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/pointer/0000775000175000017500000000000012275776201016301 5ustar williamwilliamswig-2.0.12/Examples/go/pointer/runme.go0000664000175000017500000000174112275776201017761 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-2.0.12/Examples/go/pointer/example.c0000664000175000017500000000036112275776201020100 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-2.0.12/Examples/go/pointer/example.i0000664000175000017500000000117612275776201020113 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-2.0.12/Examples/go/pointer/index.html0000664000175000017500000000567512275776201020313 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-2.0.12/Examples/go/pointer/Makefile0000664000175000017500000000066312275776201017746 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/enum/0000775000175000017500000000000012275776201015565 5ustar williamwilliamswig-2.0.12/Examples/go/enum/runme.go0000664000175000017500000000130112275776201017235 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-2.0.12/Examples/go/enum/example.h0000664000175000017500000000032612275776201017372 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-2.0.12/Examples/go/enum/example.i0000664000175000017500000000021712275776201017372 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/go/enum/example.cxx0000664000175000017500000000151112275776201017742 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-2.0.12/Examples/go/enum/index.html0000664000175000017500000000170512275776201017565 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-2.0.12/Examples/go/enum/Makefile0000664000175000017500000000067712275776201017237 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/simple/0000775000175000017500000000000012275776201016112 5ustar williamwilliamswig-2.0.12/Examples/go/simple/runme.go0000664000175000017500000000064012275776201017567 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-2.0.12/Examples/go/simple/example.c0000664000175000017500000000036712275776201017717 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-2.0.12/Examples/go/simple/example.i0000664000175000017500000000015212275776201017715 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/go/simple/index.html0000664000175000017500000000617212275776201020115 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-2.0.12/Examples/go/simple/Makefile0000664000175000017500000000062112275776201017551 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/constants/0000775000175000017500000000000012275776201016635 5ustar williamwilliamswig-2.0.12/Examples/go/constants/runme.go0000664000175000017500000000123712275776201020315 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-2.0.12/Examples/go/constants/example.i0000664000175000017500000000113312275776201020440 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-2.0.12/Examples/go/constants/index.html0000664000175000017500000000313012275776201020627 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-2.0.12/Examples/go/constants/Makefile0000664000175000017500000000066012275776201020277 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/extend/0000775000175000017500000000000012275776201016110 5ustar williamwilliamswig-2.0.12/Examples/go/extend/runme.go0000664000175000017500000000545412275776201017575 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 overidden // 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-2.0.12/Examples/go/extend/example.h0000664000175000017500000000257512275776201017725 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", 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-2.0.12/Examples/go/extend/example.i0000664000175000017500000000040312275776201017712 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-2.0.12/Examples/go/extend/example.cxx0000664000175000017500000000006012275776201020263 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/go/extend/index.html0000664000175000017500000000075312275776201020112 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-2.0.12/Examples/go/extend/Makefile0000664000175000017500000000067712275776201017562 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/reference/0000775000175000017500000000000012275776201016557 5ustar williamwilliamswig-2.0.12/Examples/go/reference/runme.go0000664000175000017500000000316012275776201020234 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-2.0.12/Examples/go/reference/example.h0000664000175000017500000000064512275776201020370 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-2.0.12/Examples/go/reference/example.i0000664000175000017500000000131012275776201020357 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-2.0.12/Examples/go/reference/example.cxx0000664000175000017500000000160412275776201020737 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)", 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-2.0.12/Examples/go/reference/index.html0000664000175000017500000000627612275776201020567 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-2.0.12/Examples/go/reference/Makefile0000664000175000017500000000067712275776201020231 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/check.list0000664000175000017500000000017612275776201016577 0ustar williamwilliam# see top-level Makefile.in callback class constants enum extend funcptr multimap pointer reference simple template variables swig-2.0.12/Examples/go/index.html0000664000175000017500000000467512275776201016632 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-2.0.12/Examples/go/funcptr/0000775000175000017500000000000012275776201016302 5ustar williamwilliamswig-2.0.12/Examples/go/funcptr/runme.go0000664000175000017500000000112512275776201017756 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-2.0.12/Examples/go/funcptr/example.c0000664000175000017500000000037012275776201020101 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-2.0.12/Examples/go/funcptr/example.h0000664000175000017500000000026312275776201020107 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-2.0.12/Examples/go/funcptr/example.i0000664000175000017500000000056012275776201020110 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-2.0.12/Examples/go/funcptr/index.html0000664000175000017500000000345412275776201020305 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-2.0.12/Examples/go/funcptr/Makefile0000664000175000017500000000066312275776201017747 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/multimap/0000775000175000017500000000000012275776201016451 5ustar williamwilliamswig-2.0.12/Examples/go/multimap/runme.go0000664000175000017500000000072712275776201020134 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-2.0.12/Examples/go/multimap/example.c0000664000175000017500000000164012275776201020251 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-2.0.12/Examples/go/multimap/example.i0000664000175000017500000000413612275776201020262 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-2.0.12/Examples/go/multimap/Makefile0000664000175000017500000000066312275776201020116 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/callback/0000775000175000017500000000000012275776201016355 5ustar williamwilliamswig-2.0.12/Examples/go/callback/runme.go0000664000175000017500000000144512275776201020036 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-2.0.12/Examples/go/callback/example.h0000664000175000017500000000102012275776201020152 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-2.0.12/Examples/go/callback/example.i0000664000175000017500000000031212275776201020156 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-2.0.12/Examples/go/callback/example.cxx0000664000175000017500000000006012275776201020530 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/go/callback/index.html0000664000175000017500000000416612275776201020361 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-2.0.12/Examples/go/callback/Makefile0000664000175000017500000000067712275776201020027 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/go/variables/0000775000175000017500000000000012275776201016571 5ustar williamwilliamswig-2.0.12/Examples/go/variables/runme.go0000664000175000017500000000410012275776201020241 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-2.0.12/Examples/go/variables/example.c0000664000175000017500000000456512275776201020402 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/go/variables/example.h0000664000175000017500000000007512275776201020377 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/go/variables/example.i0000664000175000017500000000174512275776201020405 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-2.0.12/Examples/go/variables/index.html0000664000175000017500000000450512275776201020572 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-2.0.12/Examples/go/variables/Makefile0000664000175000017500000000066312275776201020236 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean swig-2.0.12/Examples/lua/0000775000175000017500000000000012275776201014775 5ustar williamwilliamswig-2.0.12/Examples/lua/embed2/0000775000175000017500000000000012275776201016133 5ustar williamwilliamswig-2.0.12/Examples/lua/embed2/embed2.c0000664000175000017500000001625212275776201017443 0ustar williamwilliam/* embed2.c some more test for an embeded 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 wrappered 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 /* the SWIG wrappered 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 involded. (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_pushstring(L, "add"); /* function name */ lua_gettable(L, LUA_GLOBALSINDEX); /* function to be called */ if (!lua_isfunction(L,-1)) { printf("[C] error: cannot find function 'add'\n"); lua_settop(L,top); // reset 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); // reset return 0; } // check results if (!lua_isnumber(L,-1)) { printf("[C] error: returned value is not a number\n"); lua_settop(L,top); // reset return 0; } *res=(int)lua_tonumber(L,-1); lua_settop(L,top); /* reset stack */ return 1; // ok } /* 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 its 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"); printf("[C] lets load the file 'runme.lua'\n"); printf("[C] any lua code in this file will be executed\n"); if (luaL_loadfile(L, "runme.lua") || 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] lets 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] lets 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-2.0.12/Examples/lua/embed2/example.c0000664000175000017500000000052212275776201017731 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-2.0.12/Examples/lua/embed2/runme.lua0000664000175000017500000000130712275776201017765 0ustar williamwilliamprint "[lua] This is runme.lua" -- test program for embeded lua -- we do not need to load the library, as it was already in the intrepreter -- but lets 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-2.0.12/Examples/lua/embed2/example.i0000664000175000017500000000020112275776201017731 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; extern void greeting(); %}swig-2.0.12/Examples/lua/embed2/Makefile0000664000175000017500000000107212275776201017573 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed2 SRCS = example.c INTERFACE = example.i LUA_INTERP = embed2.c # 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 TARGET='$(TARGET)' lua_embed_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean rm -f $(TARGET) swig-2.0.12/Examples/lua/arrays/0000775000175000017500000000000012275776201016276 5ustar williamwilliamswig-2.0.12/Examples/lua/arrays/example.c0000664000175000017500000000077012275776201020101 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-2.0.12/Examples/lua/arrays/runme.lua0000664000175000017500000000336012275776201020131 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 lets 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-2.0.12/Examples/lua/arrays/example.i0000664000175000017500000000234712275776201020111 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-2.0.12/Examples/lua/arrays/Makefile0000664000175000017500000000071012275776201017734 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/funcptr3/0000775000175000017500000000000012275776201016541 5ustar williamwilliamswig-2.0.12/Examples/lua/funcptr3/example.c0000664000175000017500000000037012275776201020340 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-2.0.12/Examples/lua/funcptr3/runme.lua0000664000175000017500000000262412275776201020376 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-2.0.12/Examples/lua/funcptr3/example.h0000664000175000017500000000026312275776201020346 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-2.0.12/Examples/lua/funcptr3/example.i0000664000175000017500000000306712275776201020354 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 /* 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 its lua_dostring() In lua 5.1.X its 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 wrappered library\n"); luaopen_example(L); printf("[C] all looks ok\n"); printf("\n"); printf("[C] lets load the file 'runme.lua'\n"); printf("[C] any lua code in this file will be executed\n"); if (luaL_loadfile(L, "runme.lua") || 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] lets 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] Lets 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] Lets 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-2.0.12/Examples/lua/embed/example.c0000664000175000017500000000052212275776201017647 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-2.0.12/Examples/lua/embed/runme.lua0000664000175000017500000000175712275776201017714 0ustar williamwilliamprint "[lua] This is runme.lua" -- test program for embeded lua -- we do not need to load the library, as it was already in the intrepreter -- but lets 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-2.0.12/Examples/lua/embed/example.i0000664000175000017500000000020112275776201017647 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; extern void greeting(); %}swig-2.0.12/Examples/lua/embed/Makefile0000664000175000017500000000107012275776201017507 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed SRCS = example.c INTERFACE = example.i LUA_INTERP = embed.c # 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 TARGET='$(TARGET)' lua_embed_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean rm -f $(TARGET) swig-2.0.12/Examples/lua/embed3/0000775000175000017500000000000012275776201016134 5ustar williamwilliamswig-2.0.12/Examples/lua/embed3/runme.lua0000664000175000017500000000207512275776201017771 0ustar williamwilliamprint "[lua] This is runme.lua" -- test program for embeded lua -- we do not need to load the library, as it was already in the intrepreter -- but lets 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 embed program expects a function void onEvent(Event) -- this is it function onEvent(e) print("[Lua] onEvent with event",e.mType) -- lets 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-2.0.12/Examples/lua/embed3/example.h0000664000175000017500000000064712275776201017747 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 lets have a few classes to do this. */ class Event { public: enum {STARTUP,KEYPRESS,MOUSEPRESS,SHUTDOWN} mType; // etc }; swig-2.0.12/Examples/lua/embed3/example.i0000664000175000017500000000013112275776201017734 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "example.h" swig-2.0.12/Examples/lua/embed3/Makefile0000664000175000017500000000134312275776201017575 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 TARGET='$(TARGET)' lua_embed_run build: $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: $(MAKE) -f $(TOP)/Makefile lua_clean rm -f swigluarun.h $(TARGET) swig-2.0.12/Examples/lua/embed3/example.cpp0000664000175000017500000000055712275776201020302 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-2.0.12/Examples/lua/embed3/embed3.cpp0000664000175000017500000001156412275776201020006 0ustar williamwilliam/* embed3.cpp A C++ embeded 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 } /* The SWIG external runtime is generated by using. swig -lua -externalruntime swigluarun.h It contains useful function used by SWIG in its wrappering SWIG_TypeQuery() SWIG_NewPointerObj() */ #include "swigluarun.h" // the SWIG external runtime /* the SWIG wrappered 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_pushstring(L, "onEvent"); /* function name */ lua_gettable(L, LUA_GLOBALSINDEX); /* 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++] lets 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 lets 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 printf("[C++] now lets load the file 'runme.lua'\n"); printf("[C++] any lua code in this file will be executed\n"); if (luaL_loadfile(L, "runme.lua") || 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++] Lets 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-2.0.12/Examples/lua/functest/0000775000175000017500000000000012275776201016630 5ustar williamwilliamswig-2.0.12/Examples/lua/functest/example.c0000664000175000017500000000041312275776201020425 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-2.0.12/Examples/lua/functest/runme.lua0000664000175000017500000000122512275776201020461 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-2.0.12/Examples/lua/functest/example.i0000664000175000017500000000077012275776201020441 0ustar williamwilliam/* File : example.i */ %module example %include "typemaps.i" // you must have this for the typemaps for ptrs // basic function testing // %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-2.0.12/Examples/lua/functest/Makefile0000664000175000017500000000072612275776201020275 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/class/0000775000175000017500000000000012275776201016102 5ustar williamwilliamswig-2.0.12/Examples/lua/class/runme.lua0000664000175000017500000000246512275776201017742 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 s = 3 -- call gc to make sure they are collected collectgarbage() print(example.Shape_nshapes,"shapes remain") print "Goodbye" swig-2.0.12/Examples/lua/class/example.h0000664000175000017500000000114312275776201017705 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-2.0.12/Examples/lua/class/example.i0000664000175000017500000000021612275776201017706 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/lua/class/example.cxx0000664000175000017500000000066612275776201020271 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/lua/class/Makefile0000664000175000017500000000075712275776201017553 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/pointer/0000775000175000017500000000000012275776201016455 5ustar williamwilliamswig-2.0.12/Examples/lua/pointer/example.c0000664000175000017500000000036112275776201020254 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-2.0.12/Examples/lua/pointer/runme.lua0000664000175000017500000000233212275776201020306 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-2.0.12/Examples/lua/pointer/example.i0000664000175000017500000000115512275776201020264 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-2.0.12/Examples/lua/pointer/Makefile0000664000175000017500000000072612275776201020122 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/lua.c0000664000175000017500000002335512275776201015732 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-2.0.12/Examples/lua/dual/0000775000175000017500000000000012275776201015722 5ustar williamwilliamswig-2.0.12/Examples/lua/dual/example.i0000664000175000017500000000013512275776201017526 0ustar williamwilliam/* File : example.i */ %module example %inline %{ struct Foo{ int i; }; %} swig-2.0.12/Examples/lua/dual/example2.i0000664000175000017500000000012212275776201017604 0ustar williamwilliam/* File : example2.i */ %module example2 %inline %{ struct Bar{ int i; }; %} swig-2.0.12/Examples/lua/dual/Makefile0000664000175000017500000000135212275776201017363 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = dual CXXSRCS = 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 TARGET='$(TARGET)' lua_embed_run build: $(SWIG) -lua -external-runtime $(SWIG) -c++ -lua $(SWIGOPT) example2.i $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: $(MAKE) -f $(TOP)/Makefile lua_clean rm -f swigluarun.h $(TARGET) swig-2.0.12/Examples/lua/dual/dual.cpp0000664000175000017500000000607712275776201017365 0ustar williamwilliam/* dual.cpp a test for multiple modules and multiple intrepreters staticly linked together. Earlier version of lua bindings for SWIG would fail if staticly 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 wrappered 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);} 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",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",pModule,pTypeInfo); pTypeInfo2 = SWIG_TypeQuery(L,"Bar *"); DEBUG2(" Type (Bar*) is %s\n",pTypeInfo2==0?"unknown":"known"); DEBUG3(" Module %p typeinfo(Bar*) %p\n",pModule,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-2.0.12/Examples/lua/simple/0000775000175000017500000000000012275776201016266 5ustar williamwilliamswig-2.0.12/Examples/lua/simple/example.c0000664000175000017500000000036712275776201020073 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-2.0.12/Examples/lua/simple/runme.lua0000664000175000017500000000107612275776201020123 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-2.0.12/Examples/lua/simple/example.i0000664000175000017500000000015112275776201020070 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %}swig-2.0.12/Examples/lua/simple/Makefile0000664000175000017500000000071012275776201017724 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/constants/0000775000175000017500000000000012275776201017011 5ustar williamwilliamswig-2.0.12/Examples/lua/constants/runme.lua0000664000175000017500000000230512275776201020642 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-2.0.12/Examples/lua/constants/example.i0000664000175000017500000000113512275776201020616 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-2.0.12/Examples/lua/constants/Makefile0000664000175000017500000000073112275776201020452 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/functor/0000775000175000017500000000000012275776201016455 5ustar williamwilliamswig-2.0.12/Examples/lua/functor/runme.lua0000664000175000017500000000122312275776201020304 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-2.0.12/Examples/lua/functor/example.i0000664000175000017500000000112412275776201020260 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-2.0.12/Examples/lua/functor/Makefile0000664000175000017500000000100712275776201020113 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/check.list0000664000175000017500000000022612275776201016747 0ustar williamwilliam# see top-level Makefile.in arrays class constants dual embed embed2 embed3 exception funcptr3 functest functor import owner pointer simple variables swig-2.0.12/Examples/lua/exception/0000775000175000017500000000000012275776201016773 5ustar williamwilliamswig-2.0.12/Examples/lua/exception/runme.lua0000664000175000017500000000421612275776201020627 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 lets 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 lets 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-2.0.12/Examples/lua/exception/example.h0000664000175000017500000000201412275776201020574 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-2.0.12/Examples/lua/exception/example.i0000664000175000017500000000051412275776201020600 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-2.0.12/Examples/lua/exception/Makefile0000664000175000017500000000074412275776201020440 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/import.lua0000664000175000017500000000234012275776201017011 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 verion 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 -- capitialising 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: initalising 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 endswig-2.0.12/Examples/lua/owner/0000775000175000017500000000000012275776201016127 5ustar williamwilliamswig-2.0.12/Examples/lua/owner/runme.lua0000664000175000017500000000627012275776201017765 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, lets test Lua's ownership of C++ objects" print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)") print "\nLets 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 lets 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 "\nLets 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 "\nLets 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 till 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 "thats all folks!" swig-2.0.12/Examples/lua/owner/example.h0000664000175000017500000000227512275776201017741 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-2.0.12/Examples/lua/owner/example.i0000664000175000017500000000141412275776201017734 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-2.0.12/Examples/lua/owner/example.cxx0000664000175000017500000000247712275776201020320 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",this);} ShapeOwner::~ShapeOwner() { printf(" ~ShapeOwner(%p)\n",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-2.0.12/Examples/lua/owner/Makefile0000664000175000017500000000075712275776201017600 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/import/0000775000175000017500000000000012275776201016307 5ustar williamwilliamswig-2.0.12/Examples/lua/import/spam.h0000664000175000017500000000063212275776201017421 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-2.0.12/Examples/lua/import/README0000664000175000017500000000211512275776201017166 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-2.0.12/Examples/lua/import/runme.lua0000664000175000017500000000375212275776201020147 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-2.0.12/Examples/lua/import/spam.i0000664000175000017500000000011012275776201017411 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-2.0.12/Examples/lua/import/bar.i0000664000175000017500000000010612275776201017222 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-2.0.12/Examples/lua/import/base.i0000664000175000017500000000006612275776201017375 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-2.0.12/Examples/lua/import/foo.i0000664000175000017500000000010512275776201017240 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-2.0.12/Examples/lua/import/foo.h0000664000175000017500000000052312275776201017243 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-2.0.12/Examples/lua/import/base.h0000664000175000017500000000044312275776201017373 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-2.0.12/Examples/lua/import/Makefile0000664000175000017500000000124212275776201017746 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/lua/import/bar.h0000664000175000017500000000052312275776201017224 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-2.0.12/Examples/lua/variables/0000775000175000017500000000000012275776201016745 5ustar williamwilliamswig-2.0.12/Examples/lua/variables/example.c0000664000175000017500000000456512275776201020556 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/lua/variables/runme.lua0000664000175000017500000000450112275776201020576 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-2.0.12/Examples/lua/variables/example.h0000664000175000017500000000007512275776201020553 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/lua/variables/example.i0000664000175000017500000000174512275776201020561 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-2.0.12/Examples/lua/variables/Makefile0000664000175000017500000000071012275776201020403 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile lua_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean swig-2.0.12/Examples/mzscheme/0000775000175000017500000000000012275776201016027 5ustar williamwilliamswig-2.0.12/Examples/mzscheme/std_vector/0000775000175000017500000000000012275776201020203 5ustar williamwilliamswig-2.0.12/Examples/mzscheme/std_vector/example.h0000664000175000017500000000111612275776201022006 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-2.0.12/Examples/mzscheme/std_vector/example.i0000664000175000017500000000047512275776201022016 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-2.0.12/Examples/mzscheme/std_vector/runme.scm0000664000175000017500000000247712275776201022047 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-2.0.12/Examples/mzscheme/std_vector/Makefile0000664000175000017500000000074612275776201021652 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 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 mzscheme_clean swig-2.0.12/Examples/mzscheme/simple/0000775000175000017500000000000012275776201017320 5ustar williamwilliamswig-2.0.12/Examples/mzscheme/simple/README0000664000175000017500000000004212275776201020174 0ustar williamwilliamSimple example from users manual. swig-2.0.12/Examples/mzscheme/simple/example.c0000664000175000017500000000056612275776201021126 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-2.0.12/Examples/mzscheme/simple/example.i0000664000175000017500000000041012275776201021120 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-2.0.12/Examples/mzscheme/simple/runme.scm0000664000175000017500000000076612275776201021163 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-2.0.12/Examples/mzscheme/simple/Makefile0000664000175000017500000000060012275776201020754 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile mzscheme_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean swig-2.0.12/Examples/mzscheme/check.list0000664000175000017500000000006712275776201020004 0ustar williamwilliam# see top-level Makefile.in multimap simple std_vector swig-2.0.12/Examples/mzscheme/multimap/0000775000175000017500000000000012275776201017657 5ustar williamwilliamswig-2.0.12/Examples/mzscheme/multimap/example.c0000664000175000017500000000164012275776201021457 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-2.0.12/Examples/mzscheme/multimap/example.i0000664000175000017500000000420512275776201021465 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-2.0.12/Examples/mzscheme/multimap/runme.scm0000664000175000017500000000063112275776201021511 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-2.0.12/Examples/mzscheme/multimap/Makefile0000664000175000017500000000060012275776201021313 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile mzscheme_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean swig-2.0.12/Examples/ocaml/0000775000175000017500000000000012275776201015307 5ustar williamwilliamswig-2.0.12/Examples/ocaml/std_string/0000775000175000017500000000000012275776201017467 5ustar williamwilliamswig-2.0.12/Examples/ocaml/std_string/README0000664000175000017500000000117012275776201020346 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-2.0.12/Examples/ocaml/std_string/runme.ml0000664000175000017500000000115112275776201021145 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-2.0.12/Examples/ocaml/std_string/example.h0000664000175000017500000000225612275776201021300 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-2.0.12/Examples/ocaml/std_string/example.i0000664000175000017500000000033312275776201021273 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-2.0.12/Examples/ocaml/std_string/Makefile0000664000175000017500000000113412275776201021126 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean swig-2.0.12/Examples/ocaml/std_vector/0000775000175000017500000000000012275776201017463 5ustar williamwilliamswig-2.0.12/Examples/ocaml/std_vector/runme.ml0000664000175000017500000000140312275776201021141 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-2.0.12/Examples/ocaml/std_vector/example.h0000664000175000017500000000117212275776201021270 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-2.0.12/Examples/ocaml/std_vector/example.i0000664000175000017500000000055212275776201021272 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-2.0.12/Examples/ocaml/std_vector/Makefile0000664000175000017500000000113412275776201021122 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean swig-2.0.12/Examples/ocaml/contract/0000775000175000017500000000000012275776201017124 5ustar williamwilliamswig-2.0.12/Examples/ocaml/contract/example.i0000664000175000017500000000040312275776201020726 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-2.0.12/Examples/ocaml/contract/example_prog.ml0000664000175000017500000000035312275776201022141 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-2.0.12/Examples/ocaml/contract/Makefile0000664000175000017500000000162412275776201020567 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 TARGET='$(TARGET)' ocaml_run build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean swig-2.0.12/Examples/ocaml/argout_ref/0000775000175000017500000000000012275776201017444 5ustar williamwilliamswig-2.0.12/Examples/ocaml/argout_ref/example.c0000664000175000017500000000046712275776201021252 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-2.0.12/Examples/ocaml/argout_ref/example.i0000664000175000017500000000020312275776201021244 0ustar williamwilliam/* File : example.i */ %module example %{ extern "C" void factor(int &x, int &y); %} extern "C" void factor(int &x, int &y); swig-2.0.12/Examples/ocaml/argout_ref/example_prog.ml0000664000175000017500000000125512275776201022463 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-2.0.12/Examples/ocaml/argout_ref/Makefile0000664000175000017500000000134512275776201021107 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 TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean swig-2.0.12/Examples/ocaml/string_from_ptr/0000775000175000017500000000000012275776201020525 5ustar williamwilliamswig-2.0.12/Examples/ocaml/string_from_ptr/foolib.i0000664000175000017500000000045012275776201022150 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-2.0.12/Examples/ocaml/string_from_ptr/example_prog.ml0000664000175000017500000000164112275776201023543 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-2.0.12/Examples/ocaml/string_from_ptr/Makefile0000664000175000017500000000177212275776201022174 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 TARGET='$(TARGET)' ocaml_run build: static static_top static: $(MAKE) -f $(TOP)/Makefile 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 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 SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean swig-2.0.12/Examples/ocaml/scoped_enum/0000775000175000017500000000000012275776201017610 5ustar williamwilliamswig-2.0.12/Examples/ocaml/scoped_enum/README0000664000175000017500000000011112275776201020461 0ustar williamwilliamThis tests our handling of scoped enums. Run with argument Tag1 or Tag2.swig-2.0.12/Examples/ocaml/scoped_enum/example.i0000664000175000017500000000007112275776201021413 0ustar williamwilliam%module example %{ #include "foo.h" %} %include "foo.h"swig-2.0.12/Examples/ocaml/scoped_enum/example_prog.ml0000664000175000017500000000013412275776201022622 0ustar williamwilliamopen Swig open Example let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2) swig-2.0.12/Examples/ocaml/scoped_enum/foo.h0000664000175000017500000000015512275776201020545 0ustar williamwilliamnamespace foo { enum Bar { Tag1, Tag2 }; static void f( Bar b ) { printf( "b = %d\n", (int)b ); } } swig-2.0.12/Examples/ocaml/scoped_enum/Makefile0000664000175000017500000000164012275776201021251 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 TARGET='$(TARGET)' ocaml_run build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean swig-2.0.12/Examples/ocaml/simple/0000775000175000017500000000000012275776201016600 5ustar williamwilliamswig-2.0.12/Examples/ocaml/simple/example.c0000664000175000017500000000036712275776201020405 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-2.0.12/Examples/ocaml/simple/example.i0000664000175000017500000000015212275776201020403 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/ocaml/simple/example_prog.ml0000664000175000017500000000100712275776201021612 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-2.0.12/Examples/ocaml/simple/index.html0000664000175000017500000000325612275776201020603 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-2.0.12/Examples/ocaml/simple/Makefile0000664000175000017500000000164612275776201020247 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 TARGET='$(TARGET)' ocaml_run build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean swig-2.0.12/Examples/ocaml/shapes/0000775000175000017500000000000012275776201016572 5ustar williamwilliamswig-2.0.12/Examples/ocaml/shapes/example.c0000664000175000017500000000244712275776201020400 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-2.0.12/Examples/ocaml/shapes/example.h0000664000175000017500000000062712275776201020403 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-2.0.12/Examples/ocaml/shapes/example.i0000664000175000017500000000022612275776201020377 0ustar williamwilliam/* File : example.i */ %module(directors="1") example #ifndef SWIGSEXP %{ #include "example.h" %} #endif %feature("director"); %include "example.h" swig-2.0.12/Examples/ocaml/shapes/example_prog.ml0000664000175000017500000000405512275776201021612 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-2.0.12/Examples/ocaml/shapes/Makefile0000664000175000017500000000201212275776201020225 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 TARGET='$(TARGET)' ocaml_run build: static static_top static: $(MAKE) -f $(TOP)/Makefile 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 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 SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean swig-2.0.12/Examples/ocaml/strings_test/0000775000175000017500000000000012275776201020037 5ustar williamwilliamswig-2.0.12/Examples/ocaml/strings_test/runme.ml0000664000175000017500000000117212275776201021520 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-2.0.12/Examples/ocaml/strings_test/example.h0000664000175000017500000000154712275776201021652 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-2.0.12/Examples/ocaml/strings_test/example.i0000664000175000017500000000025412275776201021645 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-2.0.12/Examples/ocaml/strings_test/Makefile0000664000175000017500000000140212275776201021474 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run build: static top static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean swig-2.0.12/Examples/ocaml/check.list0000664000175000017500000000016412275776201017262 0ustar williamwilliam# see top-level Makefile.in simple std_string std_vector stl argout_ref shapes contract scoped_enum string_from_ptr swig-2.0.12/Examples/ocaml/stl/0000775000175000017500000000000012275776201016111 5ustar williamwilliamswig-2.0.12/Examples/ocaml/stl/runme.ml0000664000175000017500000000042412275776201017571 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-2.0.12/Examples/ocaml/stl/example.h0000664000175000017500000000055612275776201017723 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-2.0.12/Examples/ocaml/stl/example.i0000664000175000017500000000024012275776201017712 0ustar williamwilliam%module example %{ #include "example.h" %} #define ENABLE_CHARPTR_ARRAY #define ENABLE_STRING_VECTOR %include stl.i %feature("director"); %include example.h swig-2.0.12/Examples/ocaml/stl/Makefile0000664000175000017500000000165312275776201017556 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run build: static static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp director: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_director dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean swig-2.0.12/Examples/csharp/0000775000175000017500000000000012275776201015474 5ustar williamwilliamswig-2.0.12/Examples/csharp/arrays/0000775000175000017500000000000012275776201016775 5ustar williamwilliamswig-2.0.12/Examples/csharp/arrays/example.c0000664000175000017500000000076512275776201020604 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-2.0.12/Examples/csharp/arrays/example.h0000664000175000017500000000020012275776201020571 0ustar williamwilliam void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); void myArraySwap( int* array1, int* array2, int nitems ); swig-2.0.12/Examples/csharp/arrays/example.i0000664000175000017500000000165112275776201020605 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-2.0.12/Examples/csharp/arrays/runme.cs0000664000175000017500000000226512275776201020457 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-2.0.12/Examples/csharp/arrays/Makefile0000664000175000017500000000103312275776201020432 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -unsafe -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/template/0000775000175000017500000000000012275776201017307 5ustar williamwilliamswig-2.0.12/Examples/csharp/template/example.h0000664000175000017500000000077712275776201021126 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-2.0.12/Examples/csharp/template/example.i0000664000175000017500000000051412275776201021114 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-2.0.12/Examples/csharp/template/example.sln0000664000175000017500000000272512275776201021466 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/template/runme.cs0000664000175000017500000000145512275776201020771 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-2.0.12/Examples/csharp/template/Makefile0000664000175000017500000000102312275776201020743 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/template/example-cs.csproj0000664000175000017500000000762712275776201022603 0ustar williamwilliam swig-2.0.12/Examples/csharp/template/example-vc.vcproj0000664000175000017500000000761312275776201022604 0ustar williamwilliam swig-2.0.12/Examples/csharp/class/0000775000175000017500000000000012275776201016601 5ustar williamwilliamswig-2.0.12/Examples/csharp/class/example.h0000664000175000017500000000114312275776201020404 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-2.0.12/Examples/csharp/class/example.i0000664000175000017500000000021612275776201020405 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/csharp/class/example.sln0000664000175000017500000000272512275776201020760 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/class/example.cxx0000664000175000017500000000066612275776201020770 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/csharp/class/runme.cs0000664000175000017500000000432712275776201020264 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 swig-2.0.12/Examples/csharp/class/example-vc.vcproj0000664000175000017500000000767612275776201022107 0ustar williamwilliam swig-2.0.12/Examples/csharp/enum/0000775000175000017500000000000012275776201016440 5ustar williamwilliamswig-2.0.12/Examples/csharp/enum/example.h0000664000175000017500000000032612275776201020245 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-2.0.12/Examples/csharp/enum/example.i0000664000175000017500000000021712275776201020245 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/csharp/enum/example.sln0000664000175000017500000000272512275776201020617 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/enum/example.cxx0000664000175000017500000000151112275776201020615 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-2.0.12/Examples/csharp/enum/runme.cs0000664000175000017500000000223312275776201020115 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-2.0.12/Examples/csharp/enum/Makefile0000664000175000017500000000103712275776201020101 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/enum/example-cs.csproj0000664000175000017500000000705312275776201021725 0ustar williamwilliam swig-2.0.12/Examples/csharp/enum/example-vc.vcproj0000664000175000017500000000767612275776201021746 0ustar williamwilliam swig-2.0.12/Examples/csharp/simple/0000775000175000017500000000000012275776201016765 5ustar williamwilliamswig-2.0.12/Examples/csharp/simple/example.c0000664000175000017500000000036712275776201020572 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-2.0.12/Examples/csharp/simple/example.i0000664000175000017500000000015212275776201020570 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/csharp/simple/example.sln0000664000175000017500000000250012275776201021133 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual C++ Express 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 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|Any CPU {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|Any CPU {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}.Release|Win32.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/simple/runme.cs0000664000175000017500000000104412275776201020441 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-2.0.12/Examples/csharp/simple/Makefile0000664000175000017500000000102312275776201020421 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/simple/example-cs.csproj0000664000175000017500000000633512275776201022254 0ustar williamwilliam swig-2.0.12/Examples/csharp/simple/example-vc.vcproj0000664000175000017500000001133612275776201022257 0ustar williamwilliam swig-2.0.12/Examples/csharp/extend/0000775000175000017500000000000012275776201016763 5ustar williamwilliamswig-2.0.12/Examples/csharp/extend/example.h0000664000175000017500000000257512275776201020600 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", 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-2.0.12/Examples/csharp/extend/example.i0000664000175000017500000000040312275776201020565 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-2.0.12/Examples/csharp/extend/example.sln0000664000175000017500000000272512275776201021142 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/extend/example.cxx0000664000175000017500000000006012275776201021136 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/csharp/extend/runme.cs0000664000175000017500000000646212275776201020450 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 overidden 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-2.0.12/Examples/csharp/extend/Makefile0000664000175000017500000000103712275776201020424 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/extend/example-cs.csproj0000664000175000017500000000734112275776201022250 0ustar williamwilliam swig-2.0.12/Examples/csharp/extend/example-vc.vcproj0000664000175000017500000000767612275776201022271 0ustar williamwilliam swig-2.0.12/Examples/csharp/reference/0000775000175000017500000000000012275776201017432 5ustar williamwilliamswig-2.0.12/Examples/csharp/reference/example.h0000664000175000017500000000064512275776201021243 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-2.0.12/Examples/csharp/reference/example.i0000664000175000017500000000131412275776201021236 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-2.0.12/Examples/csharp/reference/example.sln0000664000175000017500000000272512275776201021611 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/reference/example.cxx0000664000175000017500000000160412275776201021612 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)", 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-2.0.12/Examples/csharp/reference/runme.cs0000664000175000017500000000464512275776201021120 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-2.0.12/Examples/csharp/reference/Makefile0000664000175000017500000000103712275776201021073 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/reference/example-cs.csproj0000664000175000017500000000706412275776201022721 0ustar williamwilliam swig-2.0.12/Examples/csharp/reference/example-vc.vcproj0000664000175000017500000000767612275776201022740 0ustar williamwilliam swig-2.0.12/Examples/csharp/check.list0000664000175000017500000000015212275776201017444 0ustar williamwilliam# see top-level Makefile.in arrays callback class enum extend funcptr reference simple template variables swig-2.0.12/Examples/csharp/funcptr/0000775000175000017500000000000012275776201017155 5ustar williamwilliamswig-2.0.12/Examples/csharp/funcptr/example.c0000664000175000017500000000037012275776201020754 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-2.0.12/Examples/csharp/funcptr/example.h0000664000175000017500000000026312275776201020762 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-2.0.12/Examples/csharp/funcptr/example.i0000664000175000017500000000056012275776201020763 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-2.0.12/Examples/csharp/funcptr/example.sln0000664000175000017500000000272512275776201021334 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/funcptr/runme.cs0000664000175000017500000000157012275776201020635 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-2.0.12/Examples/csharp/funcptr/Makefile0000664000175000017500000000102312275776201020611 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/funcptr/example-cs.csproj0000664000175000017500000000663112275776201022443 0ustar williamwilliam swig-2.0.12/Examples/csharp/funcptr/example-vc.vcproj0000664000175000017500000000766612275776201022462 0ustar williamwilliam swig-2.0.12/Examples/csharp/callback/0000775000175000017500000000000012275776201017230 5ustar williamwilliamswig-2.0.12/Examples/csharp/callback/example.h0000664000175000017500000000107112275776201021033 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-2.0.12/Examples/csharp/callback/example.i0000664000175000017500000000031212275776201021031 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-2.0.12/Examples/csharp/callback/example.sln0000664000175000017500000000272512275776201021407 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/callback/example.cxx0000664000175000017500000000006012275776201021403 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/csharp/callback/runme.cs0000664000175000017500000000163112275776201020706 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-2.0.12/Examples/csharp/callback/Makefile0000664000175000017500000000104612275776201020671 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -debug -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/callback/example-cs.csproj0000664000175000017500000000706112275776201022514 0ustar williamwilliam swig-2.0.12/Examples/csharp/callback/example-vc.vcproj0000664000175000017500000000767612275776201022536 0ustar williamwilliam swig-2.0.12/Examples/csharp/variables/0000775000175000017500000000000012275776201017444 5ustar williamwilliamswig-2.0.12/Examples/csharp/variables/example.c0000664000175000017500000000456512275776201021255 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/csharp/variables/example.h0000664000175000017500000000007512275776201021252 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/csharp/variables/example.i0000664000175000017500000000174512275776201021260 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-2.0.12/Examples/csharp/variables/example.sln0000664000175000017500000000272512275776201021623 0ustar williamwilliamMicrosoft Visual Studio Solution File, Format Version 8.00 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}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal swig-2.0.12/Examples/csharp/variables/runme.cs0000664000175000017500000000544412275776201021130 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-2.0.12/Examples/csharp/variables/Makefile0000664000175000017500000000102312275776201021100 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe check: build $(MAKE) -f $(TOP)/Makefile csharp_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile clean: $(MAKE) -f $(TOP)/Makefile csharp_clean swig-2.0.12/Examples/csharp/variables/example-cs.csproj0000664000175000017500000000710112275776201022723 0ustar williamwilliam swig-2.0.12/Examples/csharp/variables/example-vc.vcproj0000664000175000017500000000757712275776201022752 0ustar williamwilliam swig-2.0.12/Examples/chicken/0000775000175000017500000000000012275776201015620 5ustar williamwilliamswig-2.0.12/Examples/chicken/README0000664000175000017500000000106312275776201016500 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-2.0.12/Examples/chicken/class/0000775000175000017500000000000012275776201016725 5ustar williamwilliamswig-2.0.12/Examples/chicken/class/example.h0000664000175000017500000000126112275776201020531 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; enum SomeEnum { First = 0, Second, Third, Last = 1000 }; }; 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-2.0.12/Examples/chicken/class/runme-lowlevel.scm0000664000175000017500000000310612275776201022406 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-2.0.12/Examples/chicken/class/example.i0000664000175000017500000000021612275776201020531 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/chicken/class/example.cxx0000664000175000017500000000066612275776201021114 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/chicken/class/Makefile0000664000175000017500000000237112275776201020370 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = CXXSRCS = example.cxx TARGET = class INCLUDE = SWIGOPT = CFLAGS = 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 CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run $(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run build: $(TARGET) $(TARGET)_proxy $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ 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 \ 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 chicken_clean rm -f example.scm rm -f $(TARGET) swig-2.0.12/Examples/chicken/class/runme-tinyclos.scm0000664000175000017500000000315612275776201022426 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-2.0.12/Examples/chicken/simple/0000775000175000017500000000000012275776201017111 5ustar williamwilliamswig-2.0.12/Examples/chicken/simple/README0000664000175000017500000000004212275776201017765 0ustar williamwilliamSimple example from users manual. swig-2.0.12/Examples/chicken/simple/example.c0000664000175000017500000000056612275776201020717 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-2.0.12/Examples/chicken/simple/example.i0000664000175000017500000000041012275776201020711 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-2.0.12/Examples/chicken/simple/runme.scm0000664000175000017500000000075712275776201020754 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-2.0.12/Examples/chicken/simple/Makefile0000664000175000017500000000142512275776201020553 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = example.c CXXSRCS = TARGET = simple INCLUDE = SWIGOPT = CFLAGS = VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ 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 chicken_clean rm -f example.scm example-generic.scm example-clos.scm rm -f $(TARGET) swig-2.0.12/Examples/chicken/constants/0000775000175000017500000000000012275776201017634 5ustar williamwilliamswig-2.0.12/Examples/chicken/constants/example.i0000664000175000017500000000133112275776201021437 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-2.0.12/Examples/chicken/constants/runme.scm0000664000175000017500000000114612275776201021470 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-2.0.12/Examples/chicken/constants/Makefile0000664000175000017500000000135112275776201021274 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = CXXSRCS = TARGET = constants INCLUDE = SWIGOPT = CFLAGS = VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ 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 chicken_clean rm -f example.scm rm -f $(TARGET) swig-2.0.12/Examples/chicken/egg/0000775000175000017500000000000012275776201016362 5ustar williamwilliamswig-2.0.12/Examples/chicken/egg/README0000664000175000017500000000134112275776201017241 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-2.0.12/Examples/chicken/egg/multi.setup0000664000175000017500000000020112275776201020567 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-2.0.12/Examples/chicken/egg/single.setup0000664000175000017500000000014212275776201020722 0ustar williamwilliam(run (csc -s -o single.so single.scm single_wrap.cxx)) (install-extension 'single '("single.so")) swig-2.0.12/Examples/chicken/egg/single.i0000664000175000017500000000010212275776201020006 0ustar williamwilliam%module single %inline %{ class Foo { public: int a; }; %} swig-2.0.12/Examples/chicken/egg/multi_init.scm0000664000175000017500000000005412275776201021242 0ustar williamwilliam(declare (uses mod1)) (declare (uses mod2)) swig-2.0.12/Examples/chicken/egg/mod2.i0000664000175000017500000000022312275776201017372 0ustar williamwilliam%module mod2 %import "mod1.i" %{ class Bar { public: int b; }; %} %inline %{ class Bar2 : public Bar { public: int c; }; %} swig-2.0.12/Examples/chicken/egg/Makefile0000664000175000017500000000212312275776201020020 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-2.0.12/Examples/chicken/egg/mod1.i0000664000175000017500000000010012275776201017363 0ustar williamwilliam%module mod1 %inline %{ class Bar { public: int b; }; %} swig-2.0.12/Examples/chicken/egg/test.scm0000664000175000017500000000047412275776201020052 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-2.0.12/Examples/chicken/overload/0000775000175000017500000000000012275776201017433 5ustar williamwilliamswig-2.0.12/Examples/chicken/overload/README0000664000175000017500000000012212275776201020306 0ustar williamwilliamOverloading example from Chapter 5.14 of SWIG Core Documentation for version 1.3. swig-2.0.12/Examples/chicken/overload/example.h0000664000175000017500000000033612275776201021241 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-2.0.12/Examples/chicken/overload/example.i0000664000175000017500000000053512275776201021243 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-2.0.12/Examples/chicken/overload/example.cxx0000664000175000017500000000104112275776201021606 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-2.0.12/Examples/chicken/overload/runme.scm0000664000175000017500000000204512275776201021266 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-2.0.12/Examples/chicken/overload/Makefile0000664000175000017500000000141312275776201021072 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = CXXSRCS = example.cxx TARGET = overload INCLUDE = SWIGOPT = -proxy -unhideprimitive CFLAGS = VARIANT = # uncomment the following lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ 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 chicken_clean rm -f example.scm rm -f $(TARGET) swig-2.0.12/Examples/chicken/check.list0000664000175000017500000000010512275776201017566 0ustar williamwilliam# see top-level Makefile.in class constants multimap overload simple swig-2.0.12/Examples/chicken/multimap/0000775000175000017500000000000012275776201017450 5ustar williamwilliamswig-2.0.12/Examples/chicken/multimap/example.c0000664000175000017500000000164012275776201021250 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-2.0.12/Examples/chicken/multimap/example.i0000664000175000017500000000463412275776201021264 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-2.0.12/Examples/chicken/multimap/runme.scm0000664000175000017500000000270612275776201021307 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-2.0.12/Examples/chicken/multimap/Makefile0000664000175000017500000000136212275776201021112 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig INTERFACE = example.i SRCS = example.c CXXSRCS = TARGET = multimap INCLUDE = SWIGOPT = CFLAGS = VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm #VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ 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 chicken_clean rm -f example.scm rm -f $(TARGET) swig-2.0.12/Examples/php/0000775000175000017500000000000012275776201015003 5ustar williamwilliamswig-2.0.12/Examples/php/class/0000775000175000017500000000000012275776201016110 5ustar williamwilliamswig-2.0.12/Examples/php/class/example.h0000664000175000017500000000126212275776201017715 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; 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); }; swig-2.0.12/Examples/php/class/example.i0000664000175000017500000000021612275776201017714 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/php/class/example.cxx0000664000175000017500000000110512275776201020264 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; } swig-2.0.12/Examples/php/class/runme.php0000664000175000017500000000257512275776201017760 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::get_nshapes() . " shapes remain\n"; print "Goodbye\n"; ?> swig-2.0.12/Examples/php/class/Makefile0000664000175000017500000000105012275776201017544 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/pragmas/0000775000175000017500000000000012275776201016435 5ustar williamwilliamswig-2.0.12/Examples/php/pragmas/example.i0000664000175000017500000000073612275776201020250 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-2.0.12/Examples/php/pragmas/include.php0000664000175000017500000000012312275776201020565 0ustar williamwilliam swig-2.0.12/Examples/php/pragmas/runme.php0000775000175000017500000000004212275776201020273 0ustar williamwilliam swig-2.0.12/Examples/php/pragmas/Makefile0000664000175000017500000000101012275776201020065 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/pointer/0000775000175000017500000000000012275776201016463 5ustar williamwilliamswig-2.0.12/Examples/php/pointer/example.c0000664000175000017500000000037312275776201020265 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-2.0.12/Examples/php/pointer/example.i0000664000175000017500000000117212275776201020271 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-2.0.12/Examples/php/pointer/runme.php0000664000175000017500000000134012275776201020320 0ustar williamwilliam swig-2.0.12/Examples/php/pointer/Makefile0000664000175000017500000000102212275776201020116 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/enum/0000775000175000017500000000000012275776201015747 5ustar williamwilliamswig-2.0.12/Examples/php/enum/example.h0000664000175000017500000000031512275776201017552 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-2.0.12/Examples/php/enum/example.i0000664000175000017500000000022012275776201017546 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/php/enum/example.cxx0000664000175000017500000000151112275776201020124 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-2.0.12/Examples/php/enum/runme.php0000664000175000017500000000126612275776201017613 0ustar williamwilliam swig-2.0.12/Examples/php/enum/Makefile0000664000175000017500000000106112275776201017405 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/simple/0000775000175000017500000000000012275776201016274 5ustar williamwilliamswig-2.0.12/Examples/php/simple/example.c0000664000175000017500000000050312275776201020071 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-2.0.12/Examples/php/simple/example.i0000664000175000017500000000017412275776201020103 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; void print_Foo(); %} swig-2.0.12/Examples/php/simple/runme.php0000775000175000017500000000065712275776201020146 0ustar williamwilliam swig-2.0.12/Examples/php/simple/Makefile0000664000175000017500000000102212275776201017727 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/constants/0000775000175000017500000000000012275776201017017 5ustar williamwilliamswig-2.0.12/Examples/php/constants/example.i0000664000175000017500000000114112275776201020621 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-2.0.12/Examples/php/constants/runme.php0000664000175000017500000000162012275776201020655 0ustar williamwilliam swig-2.0.12/Examples/php/constants/Makefile0000664000175000017500000000101012275776201020447 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/extend/0000775000175000017500000000000012275776201016272 5ustar williamwilliamswig-2.0.12/Examples/php/extend/example.h0000664000175000017500000000257512275776201020107 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", 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-2.0.12/Examples/php/extend/example.i0000664000175000017500000000040312275776201020074 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-2.0.12/Examples/php/extend/example.cxx0000664000175000017500000000006012275776201020445 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/php/extend/index.html0000664000175000017500000000044312275776201020270 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-2.0.12/Examples/php/extend/runme.php0000664000175000017500000000601012275776201020126 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-2.0.12/Examples/php/extend/Makefile0000664000175000017500000000107512275776201017735 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/cpointer/0000775000175000017500000000000012275776201016626 5ustar williamwilliamswig-2.0.12/Examples/php/cpointer/example.c0000664000175000017500000000037312275776201020430 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-2.0.12/Examples/php/cpointer/example.i0000664000175000017500000000114012275776201020427 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-2.0.12/Examples/php/cpointer/runme.php0000664000175000017500000000176212275776201020473 0ustar williamwilliam swig-2.0.12/Examples/php/cpointer/Makefile0000664000175000017500000000102212275776201020261 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/reference/0000775000175000017500000000000012275776201016741 5ustar williamwilliamswig-2.0.12/Examples/php/reference/example.h0000664000175000017500000000065112275776201020547 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-2.0.12/Examples/php/reference/example.i0000664000175000017500000000162712275776201020554 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",$self,index); return (*$self)[index]; } void set(int index, Vector &a) { (*$self)[index] = a; } } }; swig-2.0.12/Examples/php/reference/example.cxx0000664000175000017500000000212512275776201021120 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)", this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; printf("VectorArray new: self=%p\n",this); } VectorArray::~VectorArray() { printf("VectorArray delete: self=%p\n",this); delete [] items; } Vector &VectorArray::operator[](int index) { printf("VectorArray: read[%d] self=%p\n",index,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,this); return maxsize; } swig-2.0.12/Examples/php/reference/runme.php0000664000175000017500000000203612275776201020601 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-2.0.12/Examples/php/reference/Makefile0000664000175000017500000000105012275776201020375 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/sync/0000775000175000017500000000000012275776201015757 5ustar williamwilliamswig-2.0.12/Examples/php/sync/example.h0000664000175000017500000000014212275776201017560 0ustar williamwilliamextern char *s; extern int x; class Sync { public: int x; char *s; void printer(void); }; swig-2.0.12/Examples/php/sync/example.i0000664000175000017500000000010212275776201017555 0ustar williamwilliam%module example %{ #include "example.h" %} %include "example.h" swig-2.0.12/Examples/php/sync/example.cxx0000664000175000017500000000044112275776201020135 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-2.0.12/Examples/php/sync/runme.php0000664000175000017500000000027412275776201017621 0ustar williamwilliamprinter(); ?> swig-2.0.12/Examples/php/sync/Makefile0000664000175000017500000000105012275776201017413 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/check.list0000664000175000017500000000031412275776201016753 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-2.0.12/Examples/php/proxy/0000775000175000017500000000000012275776201016164 5ustar williamwilliamswig-2.0.12/Examples/php/proxy/example.h0000664000175000017500000000136412275776201017774 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-2.0.12/Examples/php/proxy/example.i0000664000175000017500000000025112275776201017767 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-2.0.12/Examples/php/proxy/example.cxx0000664000175000017500000000120412275776201020340 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-2.0.12/Examples/php/proxy/runme.php0000664000175000017500000000314612275776201020027 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-2.0.12/Examples/php/proxy/Makefile0000664000175000017500000000105012275776201017620 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/overloading/0000775000175000017500000000000012275776201017314 5ustar williamwilliamswig-2.0.12/Examples/php/overloading/example.h0000664000175000017500000000155312275776201021124 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-2.0.12/Examples/php/overloading/example.i0000664000175000017500000000013112275776201021114 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} %include "example.h" swig-2.0.12/Examples/php/overloading/example.cxx0000664000175000017500000000161112275776201021472 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-2.0.12/Examples/php/overloading/runme.php0000664000175000017500000000243412275776201021156 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-2.0.12/Examples/php/overloading/Makefile0000664000175000017500000000105012275776201020750 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/disown/0000775000175000017500000000000012275776201016306 5ustar williamwilliamswig-2.0.12/Examples/php/disown/example.h0000664000175000017500000000163412275776201020116 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-2.0.12/Examples/php/disown/example.i0000664000175000017500000000026512275776201020116 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-2.0.12/Examples/php/disown/example.cxx0000664000175000017500000000144312275776201020467 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-2.0.12/Examples/php/disown/runme.php0000664000175000017500000000213212275776201020143 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-2.0.12/Examples/php/disown/Makefile0000664000175000017500000000105012275776201017742 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/funcptr/0000775000175000017500000000000012275776201016464 5ustar williamwilliamswig-2.0.12/Examples/php/funcptr/example.c0000664000175000017500000000033012275776201020257 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-2.0.12/Examples/php/funcptr/example.h0000664000175000017500000000022212275776201020264 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-2.0.12/Examples/php/funcptr/example.i0000664000175000017500000000052012275776201020266 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-2.0.12/Examples/php/funcptr/runme.php0000664000175000017500000000116212275776201020323 0ustar williamwilliam swig-2.0.12/Examples/php/funcptr/Makefile0000664000175000017500000000102212275776201020117 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/value/0000775000175000017500000000000012275776201016117 5ustar williamwilliamswig-2.0.12/Examples/php/value/example.c0000664000175000017500000000040512275776201017715 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-2.0.12/Examples/php/value/example.h0000664000175000017500000000024612275776201017725 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-2.0.12/Examples/php/value/example.i0000664000175000017500000000043712275776201017730 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", v, v->x, v->y, v->z); } %} swig-2.0.12/Examples/php/value/runme.php0000664000175000017500000000134012275776201017754 0ustar williamwilliam swig-2.0.12/Examples/php/value/Makefile0000664000175000017500000000103312275776201017554 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/callback/0000775000175000017500000000000012275776201016537 5ustar williamwilliamswig-2.0.12/Examples/php/callback/example.h0000664000175000017500000000077612275776201020355 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-2.0.12/Examples/php/callback/example.i0000664000175000017500000000031212275776201020340 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-2.0.12/Examples/php/callback/example.cxx0000664000175000017500000000006012275776201020712 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/php/callback/index.html0000664000175000017500000000043612275776201020537 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-2.0.12/Examples/php/callback/runme.php0000664000175000017500000000165512275776201020405 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-2.0.12/Examples/php/callback/Makefile0000664000175000017500000000107512275776201020202 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/php/variables/0000775000175000017500000000000012275776201016753 5ustar williamwilliamswig-2.0.12/Examples/php/variables/example.c0000664000175000017500000000466212275776201020562 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 ? cstrvar : "(null)"); printf("iptrvar = %p\n", iptrvar); printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]); printf("ptptr = %p %s\n", 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-2.0.12/Examples/php/variables/example.h0000664000175000017500000000147712275776201020570 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-2.0.12/Examples/php/variables/example.i0000664000175000017500000000167212275776201020566 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-2.0.12/Examples/php/variables/runme.php0000664000175000017500000000453412275776201020620 0ustar williamwilliam swig-2.0.12/Examples/php/variables/Makefile0000664000175000017500000000102212275776201020406 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i LIBS = SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile php_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static clean: $(MAKE) -f $(TOP)/Makefile php_clean swig-2.0.12/Examples/index.html0000664000175000017500000000271212275776201016213 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-2.0.12/Examples/perl5/0000775000175000017500000000000012275776201015243 5ustar williamwilliamswig-2.0.12/Examples/perl5/class/0000775000175000017500000000000012275776201016350 5ustar williamwilliamswig-2.0.12/Examples/perl5/class/example.h0000664000175000017500000000141212275776201020152 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); }; typedef Square TSquare; class CFoo { public: static Square MakeSquare(void) {return Square(4.0);}; static TSquare MakeTSquare(void) {return Square(4.0);}; }; swig-2.0.12/Examples/perl5/class/example.i0000664000175000017500000000021712275776201020155 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/perl5/class/example.cxx0000664000175000017500000000066612275776201020537 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/perl5/class/index.html0000664000175000017500000001031012275776201020340 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++ -python 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 = example::new_Circle(10.0);
      

    • To access member data, a pair of accessor functions are used. For example:
      example::Shape_x_set($c,15);    # Set member data
      $x = example::Shape_x_get($c);   # Get member data
      
      Note: when accessing member data, the name of the class in which the data member is defined is used. For example Shape_x_get().

    • To invoke a member function, you simply do this
      print "The area is ", example::Shape_area($c);
      

    • Type checking knows about the inheritance structure of C++. For example:
      example::Shape_area($c);       # Works (c is a Shape)
      example::Circle_area($c);      # Works (c is a Circle)
      example::Square_area($c);      # Fails (c is definitely not a Square)
      

    • To invoke a destructor, simply do this
      example::delete_Shape($c);     # Deletes a shape
      

    • Static member variables are wrapped as C global variables. For example:
      $n = $example::Shape_nshapes;     # Get a static data member
      $example::Shapes_nshapes = 13;   # Set a static data member
      

    General Comments

    • This low-level interface is not the only way to handle C++ code. Proxy classes provide a much higher-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.

    • A wide variety of C++ features are not currently supported by SWIG. Here is the short and incomplete list:

      • Overloaded methods and functions. SWIG wrappers don't know how to resolve name conflicts so you must give an alternative name to any overloaded method name using the %name directive like this:
        void foo(int a);  
        %name(foo2) void foo(double a, double b);
        

      • Overloaded operators. Not supported at all. The only workaround for this is to write a helper function. For example:
        %inline %{
            Vector *vector_add(Vector *a, Vector *b) {
                  ... whatever ...
            }
        %}
        

      • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).

      swig-2.0.12/Examples/perl5/class/example.dsp0000664000175000017500000001213312275776201020513 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-2.0.12/Examples/perl5/class/runme.pl0000664000175000017500000000264612275776201020043 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-2.0.12/Examples/perl5/class/Makefile0000664000175000017500000000077012275776201020014 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/pointer/0000775000175000017500000000000012275776201016723 5ustar williamwilliamswig-2.0.12/Examples/perl5/pointer/example.c0000664000175000017500000000036612275776201020527 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-2.0.12/Examples/perl5/pointer/example.i0000664000175000017500000000121012275776201020522 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-2.0.12/Examples/perl5/pointer/index.html0000664000175000017500000000665512275776201020734 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-2.0.12/Examples/perl5/pointer/runme.pl0000664000175000017500000000172212275776201020410 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-2.0.12/Examples/perl5/pointer/Makefile0000664000175000017500000000101112275776201020354 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/simple/0000775000175000017500000000000012275776201016534 5ustar williamwilliamswig-2.0.12/Examples/perl5/simple/example.c0000664000175000017500000000036712275776201020341 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-2.0.12/Examples/perl5/simple/example.i0000664000175000017500000000015212275776201020337 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/perl5/simple/index.html0000664000175000017500000000342312275776201020533 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-2.0.12/Examples/perl5/simple/example.dsp0000664000175000017500000001201312275776201020674 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-2.0.12/Examples/perl5/simple/runme.pl0000664000175000017500000000057212275776201020223 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-2.0.12/Examples/perl5/simple/Makefile0000664000175000017500000000101112275776201020165 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/constants/0000775000175000017500000000000012275776201017257 5ustar williamwilliamswig-2.0.12/Examples/perl5/constants/example.i0000664000175000017500000000113512275776201021064 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-2.0.12/Examples/perl5/constants/index.html0000664000175000017500000000310612275776201021254 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-2.0.12/Examples/perl5/constants/runme.pl0000664000175000017500000000164612275776201020751 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-2.0.12/Examples/perl5/constants/Makefile0000664000175000017500000000077612275776201020731 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/constants2/0000775000175000017500000000000012275776201017341 5ustar williamwilliamswig-2.0.12/Examples/perl5/constants2/example.i0000664000175000017500000000113512275776201021146 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-2.0.12/Examples/perl5/constants2/runme.pl0000664000175000017500000000114412275776201021024 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-2.0.12/Examples/perl5/constants2/Makefile0000664000175000017500000000100512275776201020775 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -const check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/reference/0000775000175000017500000000000012275776201017201 5ustar williamwilliamswig-2.0.12/Examples/perl5/reference/example.h0000664000175000017500000000064512275776201021012 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-2.0.12/Examples/perl5/reference/example.i0000664000175000017500000000131412275776201021005 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-2.0.12/Examples/perl5/reference/example.cxx0000664000175000017500000000160412275776201021361 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)", 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-2.0.12/Examples/perl5/reference/index.html0000664000175000017500000000626312275776201021205 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-2.0.12/Examples/perl5/reference/runme.pl0000664000175000017500000000353112275776201020666 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-2.0.12/Examples/perl5/reference/Makefile0000664000175000017500000000107112275776201020640 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = -noproxy check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/check.list0000664000175000017500000000022212275776201017211 0ustar williamwilliam# see top-level Makefile.in class constants constants2 funcptr import java multimap multiple_inheritance pointer reference simple value variables swig-2.0.12/Examples/perl5/index.html0000664000175000017500000000464112275776201017245 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.

      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-2.0.12/Examples/perl5/funcptr/0000775000175000017500000000000012275776201016724 5ustar williamwilliamswig-2.0.12/Examples/perl5/funcptr/example.c0000664000175000017500000000037012275776201020523 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-2.0.12/Examples/perl5/funcptr/example.h0000664000175000017500000000026312275776201020531 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-2.0.12/Examples/perl5/funcptr/example.i0000664000175000017500000000056012275776201020532 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-2.0.12/Examples/perl5/funcptr/index.html0000664000175000017500000000370112275776201020722 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-2.0.12/Examples/perl5/funcptr/runme.pl0000664000175000017500000000113312275776201020405 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-2.0.12/Examples/perl5/funcptr/Makefile0000664000175000017500000000101112275776201020355 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/xmlstring/0000775000175000017500000000000012275776201017272 5ustar williamwilliamswig-2.0.12/Examples/perl5/xmlstring/example.h0000664000175000017500000000071112275776201021075 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-2.0.12/Examples/perl5/xmlstring/example.i0000664000175000017500000000013112275776201021072 0ustar williamwilliam%module example %include %{ #include "example.h" %} %include example.h swig-2.0.12/Examples/perl5/xmlstring/example.cxx0000664000175000017500000000002512275776201021446 0ustar williamwilliam#include "example.h" swig-2.0.12/Examples/perl5/xmlstring/xmlstring.i0000664000175000017500000000633312275776201021500 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; } } %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, "", INT_MIN, INT_MAX); swig-2.0.12/Examples/perl5/xmlstring/runme.pl0000664000175000017500000000016712275776201020761 0ustar williamwilliamuse example; $e1 = new example::XMLChTest(); $e1->set("hello"); print $e1->get(),"\n"; print $e1->get_first(),"\n"; swig-2.0.12/Examples/perl5/xmlstring/Makefile0000664000175000017500000000105612275776201020734 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 perl5_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/java/0000775000175000017500000000000012275776201016164 5ustar williamwilliamswig-2.0.12/Examples/perl5/java/example.i0000664000175000017500000000012312275776201017765 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-2.0.12/Examples/perl5/java/runme.pl0000664000175000017500000000072012275776201017646 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-2.0.12/Examples/perl5/java/Makefile0000664000175000017500000000110312275776201017617 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile perl5_clean rm -f *.class Example.h Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example swig-2.0.12/Examples/perl5/java/Example.java0000664000175000017500000000075012275776201020424 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-2.0.12/Examples/perl5/multimap/0000775000175000017500000000000012275776201017073 5ustar williamwilliamswig-2.0.12/Examples/perl5/multimap/example.c0000664000175000017500000000164012275776201020673 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-2.0.12/Examples/perl5/multimap/example.i0000664000175000017500000000400712275776201020701 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-2.0.12/Examples/perl5/multimap/example.dsp0000664000175000017500000001201312275776201021233 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-2.0.12/Examples/perl5/multimap/runme.pl0000664000175000017500000000060012275776201020552 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-2.0.12/Examples/perl5/multimap/Makefile0000664000175000017500000000101112275776201020524 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/multiple_inheritance/0000775000175000017500000000000012275776201021447 5ustar williamwilliamswig-2.0.12/Examples/perl5/multiple_inheritance/example.h0000664000175000017500000000061012275776201023250 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-2.0.12/Examples/perl5/multiple_inheritance/example.i0000664000175000017500000000021512275776201023252 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/perl5/multiple_inheritance/runme.pl0000664000175000017500000000035312275776201023133 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-2.0.12/Examples/perl5/multiple_inheritance/Makefile0000664000175000017500000000075212275776201023113 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/inline/0000775000175000017500000000000012275776201016521 5ustar williamwilliamswig-2.0.12/Examples/perl5/inline/README0000664000175000017500000000006112275776201017376 0ustar williamwilliamThis example requires the Inline::SWIG package. swig-2.0.12/Examples/perl5/inline/runme.pl0000664000175000017500000000133312275776201020204 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-2.0.12/Examples/perl5/inline/Makefile0000664000175000017500000000015312275776201020160 0ustar williamwilliamrun: $(MAKE) -f $(TOP)/Makefile perl5_run clean: $(MAKE) -f $(TOP)/Makefile perl5_clean rm -rf _Inline swig-2.0.12/Examples/perl5/value/0000775000175000017500000000000012275776201016357 5ustar williamwilliamswig-2.0.12/Examples/perl5/value/example.c0000664000175000017500000000037512275776201020163 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-2.0.12/Examples/perl5/value/example.h0000664000175000017500000000011012275776201020153 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-2.0.12/Examples/perl5/value/example.i0000664000175000017500000000124312275776201020164 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", v, v->x, v->y, v->z); } %} swig-2.0.12/Examples/perl5/value/index.html0000664000175000017500000000554412275776201020364 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-2.0.12/Examples/perl5/value/runme.pl0000664000175000017500000000133712275776201020046 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-2.0.12/Examples/perl5/value/Makefile0000664000175000017500000000101112275776201020010 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/import/0000775000175000017500000000000012275776201016555 5ustar williamwilliamswig-2.0.12/Examples/perl5/import/spam.dsp0000664000175000017500000001153412275776201020231 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-2.0.12/Examples/perl5/import/spam.h0000664000175000017500000000061412275776201017667 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-2.0.12/Examples/perl5/import/README0000664000175000017500000000241712275776201017441 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-2.0.12/Examples/perl5/import/spam.i0000664000175000017500000000011012275776201017657 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-2.0.12/Examples/perl5/import/bar.i0000664000175000017500000000010612275776201017470 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-2.0.12/Examples/perl5/import/base.i0000664000175000017500000000007312275776201017641 0ustar williamwilliam%module baseclass %{ #include "base.h" %} %include base.h swig-2.0.12/Examples/perl5/import/foo.dsp0000664000175000017500000001150212275776201020047 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-2.0.12/Examples/perl5/import/base.dsp0000664000175000017500000001154612275776201020206 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-2.0.12/Examples/perl5/import/foo.i0000664000175000017500000000010512275776201017506 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-2.0.12/Examples/perl5/import/foo.h0000664000175000017500000000050512275776201017511 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-2.0.12/Examples/perl5/import/base.h0000664000175000017500000000045112275776201017640 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-2.0.12/Examples/perl5/import/runme.pl0000664000175000017500000000357112275776201020246 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-2.0.12/Examples/perl5/import/Makefile0000664000175000017500000000126212275776201020216 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/perl5/import/example.dsw0000664000175000017500000000206412275776201020731 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-2.0.12/Examples/perl5/import/bar.h0000664000175000017500000000050612275776201017473 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-2.0.12/Examples/perl5/import/bar.dsp0000664000175000017500000001150212275776201020030 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-2.0.12/Examples/perl5/variables/0000775000175000017500000000000012275776201017213 5ustar williamwilliamswig-2.0.12/Examples/perl5/variables/example.c0000664000175000017500000000456512275776201021024 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/perl5/variables/example.h0000664000175000017500000000007512275776201021021 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/perl5/variables/example.i0000664000175000017500000000203012275776201021013 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-2.0.12/Examples/perl5/variables/index.html0000664000175000017500000000434112275776201021212 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-2.0.12/Examples/perl5/variables/runme.pl0000664000175000017500000000373412275776201020705 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-2.0.12/Examples/perl5/variables/Makefile0000664000175000017500000000101112275776201020644 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile perl5_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: $(MAKE) -f $(TOP)/Makefile perl5_clean swig-2.0.12/Examples/java/0000775000175000017500000000000012275776201015135 5ustar williamwilliamswig-2.0.12/Examples/java/template/0000775000175000017500000000000012275776201016750 5ustar williamwilliamswig-2.0.12/Examples/java/template/runme.java0000664000175000017500000000207012275776201020740 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-2.0.12/Examples/java/template/example.h0000664000175000017500000000077712275776201020567 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-2.0.12/Examples/java/template/example.i0000664000175000017500000000051412275776201020555 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-2.0.12/Examples/java/template/index.html0000664000175000017500000000441312275776201020747 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

      Lets 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-2.0.12/Examples/java/template/Makefile0000664000175000017500000000074212275776201020413 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/class/0000775000175000017500000000000012275776201016242 5ustar williamwilliamswig-2.0.12/Examples/java/class/runme.java0000664000175000017500000000443112275776201020235 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.

      • A wide variety of C++ features are not currently supported by SWIG. Here is the short and incomplete list:

        • Overloaded methods and functions. SWIG wrappers don't know how to resolve name conflicts so you must give an alternative name to any overloaded method name using the %name directive like this:
          void foo(int a);  
          %name(foo2) void foo(double a, double b);
          

        • Overloaded operators. Not supported at all. The only workaround for this is to write a helper function. For example:
          %inline %{
              Vector *vector_add(Vector *a, Vector *b) {
                    ... whatever ...
              }
          %}
          

        • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).

      swig-2.0.12/Examples/java/class/example.dsp0000664000175000017500000001267712275776201020422 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-2.0.12/Examples/java/class/Makefile0000664000175000017500000000075512275776201017711 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/pointer/0000775000175000017500000000000012275776201016615 5ustar williamwilliamswig-2.0.12/Examples/java/pointer/runme.java0000664000175000017500000000337312275776201020614 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-2.0.12/Examples/java/pointer/example.c0000664000175000017500000000036112275776201020414 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-2.0.12/Examples/java/pointer/example.i0000664000175000017500000000117612275776201020427 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-2.0.12/Examples/java/pointer/index.html0000664000175000017500000000713312275776201020616 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-2.0.12/Examples/java/pointer/Makefile0000664000175000017500000000074112275776201020257 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/enum/0000775000175000017500000000000012275776201016101 5ustar williamwilliamswig-2.0.12/Examples/java/enum/runme.java0000664000175000017500000000264712275776201020103 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-2.0.12/Examples/java/enum/example.h0000664000175000017500000000032612275776201017706 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-2.0.12/Examples/java/enum/example.i0000664000175000017500000000037212275776201017710 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-2.0.12/Examples/java/enum/example.cxx0000664000175000017500000000151112275776201020256 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-2.0.12/Examples/java/enum/index.html0000664000175000017500000000125412275776201020100 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-2.0.12/Examples/java/enum/Makefile0000664000175000017500000000075512275776201017550 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/simple/0000775000175000017500000000000012275776201016426 5ustar williamwilliamswig-2.0.12/Examples/java/simple/runme.java0000664000175000017500000000145612275776201020425 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-2.0.12/Examples/java/simple/example.c0000664000175000017500000000036712275776201020233 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-2.0.12/Examples/java/simple/example.i0000664000175000017500000000015212275776201020231 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/java/simple/index.html0000664000175000017500000000420712275776201020426 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-2.0.12/Examples/java/simple/example.dsp0000664000175000017500000001255712275776201020603 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-2.0.12/Examples/java/simple/Makefile0000664000175000017500000000074112275776201020070 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/constants/0000775000175000017500000000000012275776201017151 5ustar williamwilliamswig-2.0.12/Examples/java/constants/runme.java0000664000175000017500000000320012275776201021135 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-2.0.12/Examples/java/constants/example.i0000664000175000017500000000131412275776201020755 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-2.0.12/Examples/java/constants/index.html0000664000175000017500000000331612275776201021151 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-2.0.12/Examples/java/constants/Makefile0000664000175000017500000000074212275776201020614 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/typemap/0000775000175000017500000000000012275776201016614 5ustar williamwilliamswig-2.0.12/Examples/java/typemap/runme.java0000664000175000017500000000123712275776201020610 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-2.0.12/Examples/java/typemap/example.i0000664000175000017500000000563212275776201020427 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-2.0.12/Examples/java/typemap/index.html0000664000175000017500000000120512275776201020607 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-2.0.12/Examples/java/typemap/Makefile0000664000175000017500000000073012275776201020254 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/extend/0000775000175000017500000000000012275776201016424 5ustar williamwilliamswig-2.0.12/Examples/java/extend/runme.java0000664000175000017500000000713012275776201020416 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 overidden 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-2.0.12/Examples/java/extend/example.h0000664000175000017500000000257512275776201020241 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", 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-2.0.12/Examples/java/extend/example.i0000664000175000017500000000040312275776201020226 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-2.0.12/Examples/java/extend/example.cxx0000664000175000017500000000006012275776201020577 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/java/extend/index.html0000664000175000017500000000044612275776201020425 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-2.0.12/Examples/java/extend/Makefile0000664000175000017500000000075512275776201020073 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/reference/0000775000175000017500000000000012275776201017073 5ustar williamwilliamswig-2.0.12/Examples/java/reference/runme.java0000664000175000017500000000531712275776201021072 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-2.0.12/Examples/java/reference/example.h0000664000175000017500000000064512275776201020704 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-2.0.12/Examples/java/reference/example.i0000664000175000017500000000131412275776201020677 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-2.0.12/Examples/java/reference/example.cxx0000664000175000017500000000160412275776201021253 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)", 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-2.0.12/Examples/java/reference/index.html0000664000175000017500000000633412275776201021076 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-2.0.12/Examples/java/reference/Makefile0000664000175000017500000000075512275776201020542 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/native/0000775000175000017500000000000012275776201016423 5ustar williamwilliamswig-2.0.12/Examples/java/native/runme.java0000664000175000017500000000122112275776201020410 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-2.0.12/Examples/java/native/example.i0000664000175000017500000000201612275776201020227 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-2.0.12/Examples/java/native/index.html0000664000175000017500000000172112275776201020421 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-2.0.12/Examples/java/native/Makefile0000664000175000017500000000073012275776201020063 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/check.list0000664000175000017500000000021512275776201017105 0ustar williamwilliam# see top-level Makefile.in callback class constants enum extend funcptr multimap native pointer reference simple template typemap variables swig-2.0.12/Examples/java/index.html0000664000175000017500000000477512275776201017147 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-2.0.12/Examples/java/funcptr/0000775000175000017500000000000012275776201016616 5ustar williamwilliamswig-2.0.12/Examples/java/funcptr/runme.java0000664000175000017500000000222612275776201020611 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-2.0.12/Examples/java/funcptr/example.c0000664000175000017500000000037012275776201020415 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-2.0.12/Examples/java/funcptr/example.h0000664000175000017500000000026312275776201020423 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-2.0.12/Examples/java/funcptr/example.i0000664000175000017500000000056012275776201020424 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-2.0.12/Examples/java/funcptr/index.html0000664000175000017500000000377312275776201020625 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-2.0.12/Examples/java/funcptr/Makefile0000664000175000017500000000074112275776201020260 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/multimap/0000775000175000017500000000000012275776201016765 5ustar williamwilliamswig-2.0.12/Examples/java/multimap/runme.java0000664000175000017500000000160512275776201020760 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-2.0.12/Examples/java/multimap/example.c0000664000175000017500000000164012275776201020565 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-2.0.12/Examples/java/multimap/example.i0000664000175000017500000000626612275776201020604 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-2.0.12/Examples/java/multimap/example.dsp0000664000175000017500000001255712275776201021142 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-2.0.12/Examples/java/multimap/Makefile0000664000175000017500000000074112275776201020427 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/callback/0000775000175000017500000000000012275776201016671 5ustar williamwilliamswig-2.0.12/Examples/java/callback/runme.java0000664000175000017500000000265212275776201020667 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-2.0.12/Examples/java/callback/example.h0000664000175000017500000000102012275776201020466 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-2.0.12/Examples/java/callback/example.i0000664000175000017500000000031212275776201020472 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-2.0.12/Examples/java/callback/example.cxx0000664000175000017500000000006012275776201021044 0ustar williamwilliam/* File : example.cxx */ #include "example.h" swig-2.0.12/Examples/java/callback/index.html0000664000175000017500000000044712275776201020673 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-2.0.12/Examples/java/callback/Makefile0000664000175000017500000000075512275776201020340 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/java/variables/0000775000175000017500000000000012275776201017105 5ustar williamwilliamswig-2.0.12/Examples/java/variables/runme.java0000664000175000017500000000734212275776201021104 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-2.0.12/Examples/java/variables/example.c0000664000175000017500000000456512275776201020716 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/java/variables/example.h0000664000175000017500000000007512275776201020713 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/java/variables/example.i0000664000175000017500000000174512275776201020721 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-2.0.12/Examples/java/variables/index.html0000664000175000017500000000564212275776201021111 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-2.0.12/Examples/java/variables/Makefile0000664000175000017500000000074112275776201020547 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean swig-2.0.12/Examples/Makefile.in0000664000175000017500000017354212275776201016275 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 SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ # INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method # # 'method' describes what is being built. #--------------------------------------------------------------- TARGET = CC = @CC@ CXX = @CXX@ CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@ prefix = @prefix@ exec_prefix= @exec_prefix@ SRCS = INCLUDES = LIBS = INTERFACE = INTERFACEDIR = INTERFACEPATH = $(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 # X11 options XLIB = @XLIBSW@ XINCLUDE = @XINCLUDES@ 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 = $(RUNME).tcl # ----------------------------------------------------------- # Build a new version of the tclsh shell # ----------------------------------------------------------- tclsh: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) tclsh_cpp: $(SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) # ----------------------------------------------------------- # Build a new copy of wish # ----------------------------------------------------------- wish: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) wish_cpp: $(SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) # ----------------------------------------------------------- # Build a Tcl dynamic loadable module (you might need to tweak this) # ----------------------------------------------------------- tcl: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------- # Build a Tcl7.5 dynamic loadable module for C++ # ----------------------------------------------------------- tcl_cpp: $(SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CFLAGS) $(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@ *@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 = $(RUNME).pl # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) # ---------------------------------------------------------------- perl5: $(SRCS) $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C++) # ---------------------------------------------------------------- perl5_cpp: $(SRCS) $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(LIBS) -o $(TARGET)$(SO) # ---------------------------------------------------------------- # Build a statically linked Perl5 executable # ---------------------------------------------------------------- perl5_static: $(SRCS) $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) perl5_static_cpp: $(SRCS) $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(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 ###### ################################################################## # Make sure these locate your Python installation ifeq (,$(PY3)) PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ PYTHON_LIB = @PYLIB@ PYTHON = @PYTHON@ else PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@ PYTHON_LIB = @PY3LIB@ PYTHON = @PYTHON3@ 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: $(SRCS) $(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- python_cpp: $(SRCS) $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCS) $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(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) $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE) $(RUNME)3.py: $(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 [ -f $(RUNME).py ]; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi ################################################################## ##### 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 = $(RUNME).m # ---------------------------------------------------------------- # Build a C dynamically loadable module # Note: Octave requires C++ compiler when compiling C wrappers # ---------------------------------------------------------------- octave: $(SRCS) $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CSRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- octave_cpp: $(SRCS) $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CXXSHARED) -g $(CFLAGS) $(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 = $(RUNME).scm #------------------------------------------------------------------ # Build a dynamically loaded module with passive linkage #------------------------------------------------------------------ guile: $(SRCS) $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@ guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) # ----------------------------------------------------------------- # Build Guile interpreter augmented with extra functions # ----------------------------------------------------------------- guile_augmented: $(SWIG) -guile $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- # Build statically linked Guile interpreter # ----------------------------------------------------------------- guile_static: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(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: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(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: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(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@ # ---------------------------------------------------------------- # Build a java dynamically loadable module (C) # ---------------------------------------------------------------- java: $(SRCS) $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) # ---------------------------------------------------------------- # Build a java dynamically loadable module (C++) # ---------------------------------------------------------------- java_cpp: $(SRCS) $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) # ---------------------------------------------------------------- # Compile java files # ---------------------------------------------------------------- java_compile: $(SRCS) $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(JAVASRCS) # ----------------------------------------------------------------- # Run java example # ----------------------------------------------------------------- java_run: env LD_LIBRARY_PATH=. $(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@ ################################################################## ##### ANDROID ###### ################################################################## ANDROID = android ANDROID_NDK_BUILD = ndk-build ANDROID_ADB = adb ANT = ant TARGETID = 1 # ---------------------------------------------------------------- # Build an Android dynamically loadable module (C) # ---------------------------------------------------------------- android: $(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: $(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: 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: $(SRCS) $(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \ # $(OBJS) $(IOBJS) $(LIBS) modula3_cpp: $(SRCS) $(SWIG) -modula3 -c++ $(SWIGOPT) $(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: $(SRCS) $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCS) $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- # Run mzscheme example # ----------------------------------------------------------------- mzscheme_run: env LD_LIBRARY_PATH=. $(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@ *@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: $(SRCS) $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(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: $(SRCS) $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -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: $(SRCS) $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(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: $(SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(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: $(SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(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: $(SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC $(CXXSHARED) $(CFLAGS) -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 = $(RUNME).rb # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- ruby: $(SRCS) $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- ruby_cpp: $(SRCS) $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) ruby_cpp_static: $(SRCS) $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(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@ *@SO@ ################################################################## ##### PHP ###### ################################################################## PHP = @PHP@ PHP_INCLUDE = @PHPINC@ PHP_SO = @PHP_SO@ PHP_SCRIPT = $(RUNME).php # ------------------------------------------------------------------- # Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- php: $(SRCS) $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # -------------------------------------------------------------------- # Build a PHP dynamically loadable module (C++) # -------------------------------------------------------------------- php_cpp: $(SRCS) $(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE) $(CXXSHARED) $(CFLAGS) $(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@ *@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: $(SRCS) $(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- pike_cpp: $(SRCS) $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) pike_cpp_static: $(SRCS) $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(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 staticly) 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: $(SRCS) $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CC) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCS) $(CHICKEN_COMPILED_SCHEME) $(LDSHARED) $(CFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \ $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) chicken_direct_cpp: $(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) $(CFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CHICKEN_COMPILED_SCHEME) $(CXXSHARED) $(CFLAGS) $(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: $(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) $(CFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCS) \ $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN) $(CC) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \ $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) chicken_static_cpp: $(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) $(CFLAGS) $(CHICKEN_CFLAGS) \ $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) \ $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN) $(CXX) $(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) $(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) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) # ----------------------------------------------------------------- # Run CHICKEN example # ----------------------------------------------------------------- chicken_run: env LD_LIBRARY_PATH=. $(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@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPSO = @CSHARPSO@ CSHARP_RUNME = ./$(RUNME).exe # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C) # ---------------------------------------------------------------- csharp: $(SRCS) $(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C++) # ---------------------------------------------------------------- csharp_cpp: $(SRCS) $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) # ---------------------------------------------------------------- # Compile CSharp files # ---------------------------------------------------------------- csharp_compile: $(SRCS) $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) # ----------------------------------------------------------------- # Run CSharp example # ----------------------------------------------------------------- csharp_run: env LD_LIBRARY_PATH=. $(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 = $(RUNME).lua # Extra code for lua static link LUA_INTERP = ../lua.c # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- lua: $(SRCS) $(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module # ----------------------------------------------------------------- lua_cpp: $(SRCS) $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) # ----------------------------------------------------------------- # Build statically linked Lua interpreter # ----------------------------------------------------------------- lua_static: $(SRCS) $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) lua_static_cpp: $(SRCS) $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(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) $(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@ *@SO@ ################################################################## ##### ALLEGRO CL ###### ################################################################## ALLEGROCL = @ALLEGROCLBIN@ ALLEGROCL_SCRIPT=$(RUNME).lisp allegrocl: $(SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_cpp: $(SRCS) $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_cpp: $(SRCS) $(SWIG) -c++ -clisp $(SWIGOPT) $(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: $(SRCS) $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_cpp: $(SRCS) $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_cpp: $(SRCS) $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(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: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) ifneq ($(SRCS),) $(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) # ---------------------------------------------------------------- # Build a R dynamically loadable module (C++) # ---------------------------------------------------------------- r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) ifneq ($(CXXSRCS),) $(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES) endif +( PKG_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@ 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` 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 dynamically loadable module (C) # ---------------------------------------------------------------- go: $(SRCS) $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS) if ! $(GOGCC) ; then \ $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ fi # ---------------------------------------------------------------- # Build a Go dynamically loadable module (C++) # ---------------------------------------------------------------- go_cpp: $(SRCS) $(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS) if ! $(GOGCC) ; then \ $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \ $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ fi # ----------------------------------------------------------------- # Running a Go example # ----------------------------------------------------------------- go_run: runme.go $(GO) $(GOCOMPILEARG) runme.go if $(GOGCC) ; then \ $(COMPILETOOL) $(GO) -o runme runme.@OBJEXT@ $(GOGCCOBJS) $(LIBPREFIX)$(TARGET)$(SO); \ else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ fi env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(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: $(SRCS) $(SWIGD) $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C++ module # ---------------------------------------------------------------- d_cpp: $(SRCS) $(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(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: $(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-2.0.12/Examples/ruby/0000775000175000017500000000000012275776201015175 5ustar williamwilliamswig-2.0.12/Examples/ruby/exception_class/0000775000175000017500000000000012275776201020360 5ustar williamwilliamswig-2.0.12/Examples/ruby/exception_class/example.h0000664000175000017500000000140112275776201022160 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-2.0.12/Examples/ruby/exception_class/example.i0000664000175000017500000000311012275776201022160 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-2.0.12/Examples/ruby/exception_class/Makefile0000664000175000017500000000075112275776201022023 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/exception_class/runme.rb0000664000175000017500000000117512275776201022037 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-2.0.12/Examples/ruby/std_vector/0000775000175000017500000000000012275776201017351 5ustar williamwilliamswig-2.0.12/Examples/ruby/std_vector/example.h0000664000175000017500000000111612275776201021154 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-2.0.12/Examples/ruby/std_vector/example.i0000664000175000017500000000047512275776201021164 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-2.0.12/Examples/ruby/std_vector/Makefile0000664000175000017500000000104112275776201021005 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/std_vector/runme.rb0000664000175000017500000000126412275776201021027 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-2.0.12/Examples/ruby/import_template/0000775000175000017500000000000012275776201020402 5ustar williamwilliamswig-2.0.12/Examples/ruby/import_template/spam.h0000664000175000017500000000070412275776201021514 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-2.0.12/Examples/ruby/import_template/README0000664000175000017500000000165012275776201021264 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-2.0.12/Examples/ruby/import_template/spam.i0000664000175000017500000000014612275776201021515 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" %template(IntSpam) Spam; swig-2.0.12/Examples/ruby/import_template/bar.i0000664000175000017500000000014312275776201021316 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" %template(IntBar) Bar; swig-2.0.12/Examples/ruby/import_template/base.i0000664000175000017500000000012412275776201021463 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h %template(IntBase) Base; swig-2.0.12/Examples/ruby/import_template/foo.i0000664000175000017500000000014212275776201021334 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" %template(IntFoo) Foo; swig-2.0.12/Examples/ruby/import_template/foo.h0000664000175000017500000000056712275776201021346 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-2.0.12/Examples/ruby/import_template/base.h0000664000175000017500000000051712275776201021470 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-2.0.12/Examples/ruby/import_template/Makefile0000664000175000017500000000125012275776201022040 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/import_template/runme.rb0000664000175000017500000000333512275776201022061 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-2.0.12/Examples/ruby/import_template/bar.h0000664000175000017500000000057012275776201021321 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-2.0.12/Examples/ruby/template/0000775000175000017500000000000012275776201017010 5ustar williamwilliamswig-2.0.12/Examples/ruby/template/example.h0000664000175000017500000000077712275776201020627 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-2.0.12/Examples/ruby/template/example.i0000664000175000017500000000055212275776201020617 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-2.0.12/Examples/ruby/template/Makefile0000664000175000017500000000104112275776201020444 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/template/runme.rb0000664000175000017500000000065512275776201020471 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-2.0.12/Examples/ruby/class/0000775000175000017500000000000012275776201016302 5ustar williamwilliamswig-2.0.12/Examples/ruby/class/example.h0000664000175000017500000000114312275776201020105 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-2.0.12/Examples/ruby/class/example.i0000664000175000017500000000021612275776201020106 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/ruby/class/example.cxx0000664000175000017500000000066612275776201020471 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/ruby/class/index.html0000664000175000017500000000764112275776201020307 0ustar williamwilliam SWIG:Examples:ruby:class SWIG/Examples/ruby/class/

    Wrapping a simple C++ class

    This example illustrates C++ class wrapping performed by SWIG. C++ classes are simply transformed into Ruby classes that provide methods to access 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++ -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 Ruby interpreter, the corresponding C++ destructor is automatically invoked. (Note: destructors are currently not inherited. This might change later. Until then, use -make_default).

    • 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 provides 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.

    • A wide variety of C++ features are not currently supported by SWIG. Here is the short and incomplete list:

      • Overloaded methods and functions. SWIG wrappers don't know how to resolve name conflicts so you must give an alternative name to any overloaded method name using the %name directive like this:
        void foo(int a);  
        %name(foo2) void foo(double a, double b);
        

      • Overloaded operators. Not supported at all. The only workaround for this is to write a helper function. For example:
        %inline %{
            Vector *vector_add(Vector *a, Vector *b) {
                  ... whatever ...
            }
        %}
        

      • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).

    • Dave's snide remark: Like a large bottle of strong Tequilla, it's better to use C++ in moderation.

    swig-2.0.12/Examples/ruby/class/example.dsp0000664000175000017500000001225712275776201020454 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-2.0.12/Examples/ruby/class/Makefile0000664000175000017500000000076412275776201017751 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/class/runme.rb0000664000175000017500000000232512275776201017757 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. print "\n", Example::Shape.nshapes," shapes remain\n" print "Goodbye\n" swig-2.0.12/Examples/ruby/pointer/0000775000175000017500000000000012275776201016655 5ustar williamwilliamswig-2.0.12/Examples/ruby/pointer/example.c0000664000175000017500000000036112275776201020454 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-2.0.12/Examples/ruby/pointer/example.i0000664000175000017500000000117612275776201020467 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-2.0.12/Examples/ruby/pointer/index.html0000664000175000017500000000660112275776201020655 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-2.0.12/Examples/ruby/pointer/Makefile0000664000175000017500000000071512275776201020320 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/pointer/runme.rb0000664000175000017500000000167712275776201020343 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-2.0.12/Examples/ruby/enum/0000775000175000017500000000000012275776201016141 5ustar williamwilliamswig-2.0.12/Examples/ruby/enum/example.h0000664000175000017500000000031512275776201017744 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-2.0.12/Examples/ruby/enum/example.i0000664000175000017500000000021712275776201017746 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/ruby/enum/example.cxx0000664000175000017500000000150712275776201020323 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-2.0.12/Examples/ruby/enum/index.html0000664000175000017500000000145412275776201020142 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-2.0.12/Examples/ruby/enum/Makefile0000664000175000017500000000076412275776201017610 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/enum/runme.rb0000664000175000017500000000156012275776201017616 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-2.0.12/Examples/ruby/simple/0000775000175000017500000000000012275776201016466 5ustar williamwilliamswig-2.0.12/Examples/ruby/simple/example.c0000664000175000017500000000036712275776201020273 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-2.0.12/Examples/ruby/simple/example.i0000664000175000017500000000015212275776201020271 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/ruby/simple/index.html0000664000175000017500000000320012275776201020456 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-2.0.12/Examples/ruby/simple/example.dsp0000664000175000017500000001213712275776201020635 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-2.0.12/Examples/ruby/simple/Makefile0000664000175000017500000000071512275776201020131 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/simple/runme.rb0000775000175000017500000000054312275776201020146 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-2.0.12/Examples/ruby/constants/0000775000175000017500000000000012275776201017211 5ustar williamwilliamswig-2.0.12/Examples/ruby/constants/example.i0000664000175000017500000000113512275776201021016 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-2.0.12/Examples/ruby/constants/index.html0000664000175000017500000000351612275776201021213 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-2.0.12/Examples/ruby/constants/Makefile0000664000175000017500000000070412275776201020652 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/constants/runme.rb0000775000175000017500000000160712275776201020673 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-2.0.12/Examples/ruby/free_function/0000775000175000017500000000000012275776201020023 5ustar williamwilliamswig-2.0.12/Examples/ruby/free_function/example.h0000664000175000017500000000154612275776201021635 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-2.0.12/Examples/ruby/free_function/example.i0000664000175000017500000000161512275776201021633 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-2.0.12/Examples/ruby/free_function/example.cxx0000664000175000017500000000206412275776201022204 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-2.0.12/Examples/ruby/free_function/example.dsp0000664000175000017500000001225712275776201022175 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-2.0.12/Examples/ruby/free_function/Makefile0000664000175000017500000000076412275776201021472 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/free_function/runme.rb0000664000175000017500000000166512275776201021506 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-2.0.12/Examples/ruby/reference/0000775000175000017500000000000012275776201017133 5ustar williamwilliamswig-2.0.12/Examples/ruby/reference/example.h0000664000175000017500000000064512275776201020744 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-2.0.12/Examples/ruby/reference/example.i0000664000175000017500000000131412275776201020737 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-2.0.12/Examples/ruby/reference/example.cxx0000664000175000017500000000160412275776201021313 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)", 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-2.0.12/Examples/ruby/reference/index.html0000664000175000017500000000632312275776201021134 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-2.0.12/Examples/ruby/reference/Makefile0000664000175000017500000000076412275776201020602 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/reference/runme.rb0000664000175000017500000000231112275776201020603 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-2.0.12/Examples/ruby/mark_function/0000775000175000017500000000000012275776201020034 5ustar williamwilliamswig-2.0.12/Examples/ruby/mark_function/example.h0000664000175000017500000000154612275776201021646 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-2.0.12/Examples/ruby/mark_function/example.i0000664000175000017500000000136112275776201021642 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-2.0.12/Examples/ruby/mark_function/example.cxx0000664000175000017500000000167012275776201022217 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-2.0.12/Examples/ruby/mark_function/example.dsp0000664000175000017500000001225712275776201022206 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-2.0.12/Examples/ruby/mark_function/Makefile0000664000175000017500000000076412275776201021503 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/mark_function/runme.rb0000664000175000017500000000065512275776201021515 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-2.0.12/Examples/ruby/functor/0000775000175000017500000000000012275776201016655 5ustar williamwilliamswig-2.0.12/Examples/ruby/functor/example.i0000664000175000017500000000111312275776201020456 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-2.0.12/Examples/ruby/functor/Makefile0000664000175000017500000000073312275776201020320 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/functor/runme.rb0000664000175000017500000000052612275776201020333 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-2.0.12/Examples/ruby/check.list0000664000175000017500000000034712275776201017153 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-2.0.12/Examples/ruby/funcptr2/0000775000175000017500000000000012275776201016740 5ustar williamwilliamswig-2.0.12/Examples/ruby/funcptr2/example.c0000664000175000017500000000037012275776201020537 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-2.0.12/Examples/ruby/funcptr2/example.h0000664000175000017500000000026312275776201020545 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-2.0.12/Examples/ruby/funcptr2/example.i0000664000175000017500000000053712275776201020552 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-2.0.12/Examples/ruby/funcptr2/Makefile0000664000175000017500000000071512275776201020403 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/funcptr2/runme.rb0000664000175000017500000000122412275776201020412 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-2.0.12/Examples/ruby/overloading/0000775000175000017500000000000012275776201017506 5ustar williamwilliamswig-2.0.12/Examples/ruby/overloading/example.h0000664000175000017500000000132512275776201021313 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-2.0.12/Examples/ruby/overloading/example.i0000664000175000017500000000105312275776201021312 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-2.0.12/Examples/ruby/overloading/example.cxx0000664000175000017500000000643212275776201021672 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-2.0.12/Examples/ruby/overloading/Makefile0000664000175000017500000000076412275776201021155 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/overloading/runme.rb0000664000175000017500000000347212275776201021167 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-2.0.12/Examples/ruby/hashargs/0000775000175000017500000000000012275776201016775 5ustar williamwilliamswig-2.0.12/Examples/ruby/hashargs/example.i0000664000175000017500000000201712275776201020602 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-2.0.12/Examples/ruby/hashargs/Makefile0000664000175000017500000000077012275776201020441 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/hashargs/runme.rb0000775000175000017500000000076112275776201020457 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-2.0.12/Examples/ruby/index.html0000664000175000017500000000472312275776201017200 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-2.0.12/Examples/ruby/funcptr/0000775000175000017500000000000012275776201016656 5ustar williamwilliamswig-2.0.12/Examples/ruby/funcptr/example.c0000664000175000017500000000033012275776201020451 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-2.0.12/Examples/ruby/funcptr/example.h0000664000175000017500000000026312275776201020463 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-2.0.12/Examples/ruby/funcptr/example.i0000664000175000017500000000052012275776201020460 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-2.0.12/Examples/ruby/funcptr/index.html0000664000175000017500000000366212275776201020662 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-2.0.12/Examples/ruby/funcptr/Makefile0000664000175000017500000000071512275776201020321 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/funcptr/runme.rb0000664000175000017500000000112312275776201020326 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-2.0.12/Examples/ruby/java/0000775000175000017500000000000012275776201016116 5ustar williamwilliamswig-2.0.12/Examples/ruby/java/example.i0000664000175000017500000000012212275776201017716 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-2.0.12/Examples/ruby/java/Makefile0000664000175000017500000000105212275776201017554 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile ruby_clean rm -f *.class Example.h Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example swig-2.0.12/Examples/ruby/java/runme.rb0000664000175000017500000000046012275776201017571 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-2.0.12/Examples/ruby/java/Example.java0000664000175000017500000000075012275776201020356 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-2.0.12/Examples/ruby/multimap/0000775000175000017500000000000012275776201017025 5ustar williamwilliamswig-2.0.12/Examples/ruby/multimap/example.c0000664000175000017500000000164012275776201020625 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-2.0.12/Examples/ruby/multimap/example.i0000664000175000017500000000416612275776201020641 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-2.0.12/Examples/ruby/multimap/example.dsp0000664000175000017500000001213712275776201021174 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-2.0.12/Examples/ruby/multimap/Makefile0000664000175000017500000000071512275776201020470 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/multimap/runme.rb0000775000175000017500000000056412275776201020510 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-2.0.12/Examples/ruby/operator/0000775000175000017500000000000012275776201017030 5ustar williamwilliamswig-2.0.12/Examples/ruby/operator/example.h0000664000175000017500000000147312275776201020641 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-2.0.12/Examples/ruby/operator/example.i0000664000175000017500000000104012275776201020630 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-2.0.12/Examples/ruby/operator/Makefile0000664000175000017500000000101412275776201020464 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/operator/runme.rb0000664000175000017500000000063012275776201020502 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-2.0.12/Examples/ruby/value/0000775000175000017500000000000012275776201016311 5ustar williamwilliamswig-2.0.12/Examples/ruby/value/example.c0000664000175000017500000000037512275776201020115 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-2.0.12/Examples/ruby/value/example.h0000664000175000017500000000011012275776201020105 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-2.0.12/Examples/ruby/value/example.i0000664000175000017500000000124312275776201020116 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", v, v->x, v->y, v->z); } %} swig-2.0.12/Examples/ruby/value/index.html0000664000175000017500000000515112275776201020310 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-2.0.12/Examples/ruby/value/Makefile0000664000175000017500000000071512275776201017754 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/value/runme.rb0000664000175000017500000000131312275776201017762 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-2.0.12/Examples/ruby/import/0000775000175000017500000000000012275776201016507 5ustar williamwilliamswig-2.0.12/Examples/ruby/import/spam.dsp0000664000175000017500000001166012275776201020163 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-2.0.12/Examples/ruby/import/spam.h0000664000175000017500000000063212275776201017621 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-2.0.12/Examples/ruby/import/README0000664000175000017500000000241712275776201017373 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-2.0.12/Examples/ruby/import/spam.i0000664000175000017500000000011012275776201017611 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-2.0.12/Examples/ruby/import/bar.i0000664000175000017500000000010612275776201017422 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-2.0.12/Examples/ruby/import/base.i0000664000175000017500000000006612275776201017575 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-2.0.12/Examples/ruby/import/foo.dsp0000664000175000017500000001162612275776201020010 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-2.0.12/Examples/ruby/import/base.dsp0000664000175000017500000001166012275776201020135 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-2.0.12/Examples/ruby/import/foo.i0000664000175000017500000000010512275776201017440 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-2.0.12/Examples/ruby/import/foo.h0000664000175000017500000000052312275776201017443 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-2.0.12/Examples/ruby/import/base.h0000664000175000017500000000044312275776201017573 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-2.0.12/Examples/ruby/import/Makefile0000664000175000017500000000125012275776201020145 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/import/runme.rb0000664000175000017500000000321412275776201020162 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-2.0.12/Examples/ruby/import/example.dsw0000664000175000017500000000206412275776201020663 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-2.0.12/Examples/ruby/import/bar.h0000664000175000017500000000052312275776201017424 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-2.0.12/Examples/ruby/import/bar.dsp0000664000175000017500000001162612275776201017771 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-2.0.12/Examples/ruby/variables/0000775000175000017500000000000012275776201017145 5ustar williamwilliamswig-2.0.12/Examples/ruby/variables/example.c0000664000175000017500000000456512275776201020756 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/ruby/variables/example.h0000664000175000017500000000007512275776201020753 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/ruby/variables/example.i0000664000175000017500000000202712275776201020753 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-2.0.12/Examples/ruby/variables/index.html0000664000175000017500000000675212275776201021154 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-2.0.12/Examples/ruby/variables/Makefile0000664000175000017500000000071512275776201020610 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile ruby_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: $(MAKE) -f $(TOP)/Makefile ruby_clean swig-2.0.12/Examples/ruby/variables/runme.rb0000664000175000017500000000356412275776201020630 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-2.0.12/Examples/tcl/0000775000175000017500000000000012275776201014776 5ustar williamwilliamswig-2.0.12/Examples/tcl/std_vector/0000775000175000017500000000000012275776201017152 5ustar williamwilliamswig-2.0.12/Examples/tcl/std_vector/runme.tcl0000664000175000017500000000174512275776201021013 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-2.0.12/Examples/tcl/std_vector/example.h0000664000175000017500000000111612275776201020755 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-2.0.12/Examples/tcl/std_vector/example.i0000664000175000017500000000047512275776201020765 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-2.0.12/Examples/tcl/std_vector/Makefile0000664000175000017500000000100212275776201020603 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = my_tclsh DLTARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/contract/0000775000175000017500000000000012275776201016613 5ustar williamwilliamswig-2.0.12/Examples/tcl/contract/runme.tcl0000664000175000017500000000057712275776201020456 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-2.0.12/Examples/tcl/contract/example.c0000664000175000017500000000047212275776201020415 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-2.0.12/Examples/tcl/contract/example.i0000664000175000017500000000040212275776201020414 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-2.0.12/Examples/tcl/contract/example.dsp0000664000175000017500000001176112275776201020764 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-2.0.12/Examples/tcl/contract/Makefile0000664000175000017500000000102612275776201020252 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/class/0000775000175000017500000000000012275776201016103 5ustar williamwilliamswig-2.0.12/Examples/tcl/class/runme.tcl0000664000175000017500000000213612275776201017737 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-2.0.12/Examples/tcl/class/example.h0000664000175000017500000000114312275776201017706 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-2.0.12/Examples/tcl/class/example.i0000664000175000017500000000021712275776201017710 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/tcl/class/example.cxx0000664000175000017500000000066612275776201020272 0ustar williamwilliam/* File : example.c */ #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 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-2.0.12/Examples/tcl/class/index.html0000664000175000017500000001253512275776201020106 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 a 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.

    • A wide variety of C++ features are not currently supported by SWIG. Here is the short and incomplete list:

      • Overloaded methods and functions. SWIG wrappers don't know how to resolve name conflicts so you must give an alternative name to any overloaded method name using the %name directive like this:
        void foo(int a);  
        %name(foo2) void foo(double a, double b);
        

      • Overloaded operators. Not supported at all. The only workaround for this is to write a helper function. For example:
        %inline %{
            Vector *vector_add(Vector *a, Vector *b) {
                  ... whatever ...
            }
        %}
        

      • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).

      swig-2.0.12/Examples/tcl/class/example.dsp0000664000175000017500000001210112275776201020241 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-2.0.12/Examples/tcl/class/Makefile0000664000175000017500000000076312275776201017551 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/class/runme2.tcl0000664000175000017500000000323312275776201020020 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-2.0.12/Examples/tcl/pointer/0000775000175000017500000000000012275776201016456 5ustar williamwilliamswig-2.0.12/Examples/tcl/pointer/runme.tcl0000664000175000017500000000164312275776201020314 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-2.0.12/Examples/tcl/pointer/example.c0000664000175000017500000000036112275776201020255 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-2.0.12/Examples/tcl/pointer/example.i0000664000175000017500000000117712275776201020271 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-2.0.12/Examples/tcl/pointer/index.html0000664000175000017500000000661412275776201020462 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-2.0.12/Examples/tcl/pointer/Makefile0000664000175000017500000000073712275776201020125 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/enum/0000775000175000017500000000000012275776201015742 5ustar williamwilliamswig-2.0.12/Examples/tcl/enum/runme.tcl0000664000175000017500000000125212275776201017574 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-2.0.12/Examples/tcl/enum/example.h0000664000175000017500000000031512275776201017545 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-2.0.12/Examples/tcl/enum/example.i0000664000175000017500000000021712275776201017547 0ustar williamwilliam/* File : example.i */ %module example %{ #include "example.h" %} /* Let's just grab the original header file here */ %include "example.h" swig-2.0.12/Examples/tcl/enum/example.cxx0000664000175000017500000000150712275776201020124 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-2.0.12/Examples/tcl/enum/index.html0000664000175000017500000000145312275776201017742 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-2.0.12/Examples/tcl/enum/Makefile0000664000175000017500000000076312275776201017410 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/simple/0000775000175000017500000000000012275776201016267 5ustar williamwilliamswig-2.0.12/Examples/tcl/simple/runme.tcl0000664000175000017500000000057712275776201020132 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-2.0.12/Examples/tcl/simple/example.c0000664000175000017500000000036712275776201020074 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-2.0.12/Examples/tcl/simple/example.i0000664000175000017500000000015212275776201020072 0ustar williamwilliam/* File : example.i */ %module example %inline %{ extern int gcd(int x, int y); extern double Foo; %} swig-2.0.12/Examples/tcl/simple/index.html0000664000175000017500000000317212275776201020267 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-2.0.12/Examples/tcl/simple/example.dsp0000664000175000017500000001176112275776201020440 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-2.0.12/Examples/tcl/simple/Makefile0000664000175000017500000000073712275776201017736 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/constants/0000775000175000017500000000000012275776201017012 5ustar williamwilliamswig-2.0.12/Examples/tcl/constants/runme.tcl0000664000175000017500000000135212275776201020645 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-2.0.12/Examples/tcl/constants/example.i0000664000175000017500000000113512275776201020617 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-2.0.12/Examples/tcl/constants/index.html0000664000175000017500000000346512275776201021017 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-2.0.12/Examples/tcl/constants/Makefile0000664000175000017500000000072512275776201020456 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/reference/0000775000175000017500000000000012275776201016734 5ustar williamwilliamswig-2.0.12/Examples/tcl/reference/runme.tcl0000664000175000017500000000300512275776201020564 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-2.0.12/Examples/tcl/reference/example.h0000664000175000017500000000064512275776201020545 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-2.0.12/Examples/tcl/reference/example.i0000664000175000017500000000131412275776201020540 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-2.0.12/Examples/tcl/reference/example.cxx0000664000175000017500000000160412275776201021114 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)", 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-2.0.12/Examples/tcl/reference/index.html0000664000175000017500000000633312275776201020736 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-2.0.12/Examples/tcl/reference/Makefile0000664000175000017500000000076312275776201020402 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/check.list0000664000175000017500000000022412275776201016746 0ustar williamwilliam# see top-level Makefile.in class constants contract enum funcptr import java multimap operator pointer reference simple std_vector value variables swig-2.0.12/Examples/tcl/index.html0000664000175000017500000000373012275776201016776 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-2.0.12/Examples/tcl/funcptr/0000775000175000017500000000000012275776201016457 5ustar williamwilliamswig-2.0.12/Examples/tcl/funcptr/runme.tcl0000664000175000017500000000100212275776201020302 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-2.0.12/Examples/tcl/funcptr/example.c0000664000175000017500000000037012275776201020256 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-2.0.12/Examples/tcl/funcptr/example.h0000664000175000017500000000026312275776201020264 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-2.0.12/Examples/tcl/funcptr/example.i0000664000175000017500000000056012275776201020265 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-2.0.12/Examples/tcl/funcptr/index.html0000664000175000017500000000367512275776201020467 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-2.0.12/Examples/tcl/funcptr/Makefile0000664000175000017500000000073712275776201020126 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/java/0000775000175000017500000000000012275776201015717 5ustar williamwilliamswig-2.0.12/Examples/tcl/java/runme.tcl0000664000175000017500000000044012275776201017547 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-2.0.12/Examples/tcl/java/example.i0000664000175000017500000000012112275776201017516 0ustar williamwilliam%module example %include %{ #include "Example.h" %} %include Example.h swig-2.0.12/Examples/tcl/java/Makefile0000664000175000017500000000110412275776201017353 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ TCL_CXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp clean: $(MAKE) -f $(TOP)/Makefile tcl_clean rm -f *.class Example.h run: tclsh runme.tcl Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example swig-2.0.12/Examples/tcl/java/Example.java0000664000175000017500000000075012275776201020157 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-2.0.12/Examples/tcl/multimap/0000775000175000017500000000000012275776201016626 5ustar williamwilliamswig-2.0.12/Examples/tcl/multimap/runme.tcl0000664000175000017500000000056012275776201020461 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-2.0.12/Examples/tcl/multimap/example.c0000664000175000017500000000164012275776201020426 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-2.0.12/Examples/tcl/multimap/example.i0000664000175000017500000000344412275776201020440 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-2.0.12/Examples/tcl/multimap/example.dsp0000664000175000017500000001176112275776201020777 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-2.0.12/Examples/tcl/multimap/Makefile0000664000175000017500000000073712275776201020275 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/operator/0000775000175000017500000000000012275776201016631 5ustar williamwilliamswig-2.0.12/Examples/tcl/operator/runme.tcl0000664000175000017500000000073512275776201020470 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-2.0.12/Examples/tcl/operator/example.h0000664000175000017500000000147312275776201020442 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-2.0.12/Examples/tcl/operator/example.i0000664000175000017500000000120612275776201020435 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-2.0.12/Examples/tcl/operator/Makefile0000664000175000017500000000075012275776201020273 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = TARGET = example INTERFACE = example.i LIBS = -lm check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/value/0000775000175000017500000000000012275776201016112 5ustar williamwilliamswig-2.0.12/Examples/tcl/value/runme.tcl0000664000175000017500000000130712275776201017745 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-2.0.12/Examples/tcl/value/example.c0000664000175000017500000000037512275776201017716 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-2.0.12/Examples/tcl/value/example.h0000664000175000017500000000011012275776201017706 0ustar williamwilliam/* File : example.h */ typedef struct { double x, y, z; } Vector; swig-2.0.12/Examples/tcl/value/example.i0000664000175000017500000000124312275776201017717 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", v, v->x, v->y, v->z); } %} swig-2.0.12/Examples/tcl/value/index.html0000664000175000017500000000524412275776201020114 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-2.0.12/Examples/tcl/value/Makefile0000664000175000017500000000073712275776201017561 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/import/0000775000175000017500000000000012275776201016310 5ustar williamwilliamswig-2.0.12/Examples/tcl/import/spam.dsp0000664000175000017500000001147712275776201017772 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-2.0.12/Examples/tcl/import/runme.tcl0000664000175000017500000000371012275776201020143 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-2.0.12/Examples/tcl/import/spam.h0000664000175000017500000000061412275776201017422 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-2.0.12/Examples/tcl/import/README0000664000175000017500000000223212275776201017167 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-2.0.12/Examples/tcl/import/spam.i0000664000175000017500000000011012275776201017412 0ustar williamwilliam%module spam %{ #include "spam.h" %} %import bar.i %include "spam.h" swig-2.0.12/Examples/tcl/import/bar.i0000664000175000017500000000010612275776201017223 0ustar williamwilliam%module bar %{ #include "bar.h" %} %import base.i %include "bar.h" swig-2.0.12/Examples/tcl/import/base.i0000664000175000017500000000006612275776201017376 0ustar williamwilliam%module base %{ #include "base.h" %} %include base.h swig-2.0.12/Examples/tcl/import/foo.dsp0000664000175000017500000001145012275776201017604 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-2.0.12/Examples/tcl/import/base.dsp0000664000175000017500000001150212275776201017731 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-2.0.12/Examples/tcl/import/foo.i0000664000175000017500000000010512275776201017241 0ustar williamwilliam%module foo %{ #include "foo.h" %} %import base.i %include "foo.h" swig-2.0.12/Examples/tcl/import/foo.h0000664000175000017500000000050512275776201017244 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-2.0.12/Examples/tcl/import/base.h0000664000175000017500000000045112275776201017373 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-2.0.12/Examples/tcl/import/Makefile0000664000175000017500000000124212275776201017747 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/tcl/import/example.dsw0000664000175000017500000000206412275776201020464 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-2.0.12/Examples/tcl/import/bar.h0000664000175000017500000000050612275776201017226 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-2.0.12/Examples/tcl/import/bar.dsp0000664000175000017500000001145012275776201017565 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-2.0.12/Examples/tcl/variables/0000775000175000017500000000000012275776201016746 5ustar williamwilliamswig-2.0.12/Examples/tcl/variables/runme.tcl0000664000175000017500000000304712275776201020604 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-2.0.12/Examples/tcl/variables/example.c0000664000175000017500000000456512275776201020557 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 ? cstrvar : "(null)"); 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-2.0.12/Examples/tcl/variables/example.h0000664000175000017500000000007512275776201020554 0ustar williamwilliam/* File: example.h */ typedef struct { int x,y; } Point; swig-2.0.12/Examples/tcl/variables/example.i0000664000175000017500000000203012275776201020546 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-2.0.12/Examples/tcl/variables/index.html0000664000175000017500000000555312275776201020753 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-2.0.12/Examples/tcl/variables/Makefile0000664000175000017500000000073712275776201020415 0ustar williamwilliamTOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = my_tclsh DLTARGET = example INTERFACE = example.i check: build $(MAKE) -f $(TOP)/Makefile tcl_run build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile tcl_clean swig-2.0.12/Examples/s-exp/0000775000175000017500000000000012275776201015250 5ustar williamwilliamswig-2.0.12/Examples/s-exp/uffi.lisp0000664000175000017500000003272412275776201017102 0ustar williamwilliam;;; This is experimental code that uses the s-expression ;;; representation of a C/C++ library interface to generate Foreign ;;; Function Interface definitions for use with Kevin Rosenberg's ;;; UFFI. ;;; ;;; Written by Matthias Koeppe (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-2.0.12/Examples/android/0000775000175000017500000000000012275776201015634 5ustar williamwilliamswig-2.0.12/Examples/android/class/0000775000175000017500000000000012275776201016741 5ustar williamwilliamswig-2.0.12/Examples/android/class/res/0000775000175000017500000000000012275776201017532 5ustar williamwilliamswig-2.0.12/Examples/android/class/res/values/0000775000175000017500000000000012275776201021031 5ustar williamwilliamswig-2.0.12/Examples/android/class/res/values/strings.xml0000664000175000017500000000015712275776201023247 0ustar williamwilliam SwigClass swig-2.0.12/Examples/android/class/res/layout/0000775000175000017500000000000012275776201021047 5ustar williamwilliamswig-2.0.12/Examples/android/class/res/layout/main.xml0000664000175000017500000000132212275776201022513 0ustar williamwilliam