From 84e1302e221a0752bcdd5991e152de42f6158910 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Thu, 16 Aug 2012 21:17:51 +0800 Subject: [PATCH] import source from 1.3.40 Signed-off-by: Gui Chen --- ANNOUNCE | 37 + CCache/COPYING | 339 + CCache/Makefile.in | 73 + CCache/README | 31 + CCache/README.swig | 8 + CCache/args.c | 91 + CCache/ccache-swig.1 | 453 + CCache/ccache.c | 1388 + CCache/ccache.h | 205 + CCache/ccache.yo | 422 + CCache/ccache_swig_config.h.in | 1 + CCache/cleanup.c | 193 + CCache/config.h.in | 115 + CCache/configure | 5653 +++ CCache/configure.in | 87 + CCache/debian/NEWS | 22 + CCache/debian/README.Debian | 59 + CCache/debian/changelog | 221 + CCache/debian/compat | 1 + CCache/debian/control | 20 + CCache/debian/copyright | 29 + CCache/debian/dirs | 3 + CCache/debian/docs | 1 + CCache/debian/examples | 2 + CCache/debian/patches/01_no_home.diff | 100 + CCache/debian/patches/02_ccache-compressed.diff | 1026 + CCache/debian/patches/03_long_options.diff | 133 + CCache/debian/patches/04_ignore_profile.diff | 13 + CCache/debian/patches/05_nfs_fix.diff | 45 + CCache/debian/patches/06_md.diff | 77 + CCache/debian/patches/07_cachedirtag.diff | 75 + CCache/debian/patches/08_manpage_hyphens.diff | 89 + CCache/debian/patches/09_respect_ldflags.diff | 11 + CCache/debian/patches/10_lru_cleanup.diff | 23 + CCache/debian/patches/11_utimes.diff | 85 + .../debian/patches/12_cachesize_permissions.diff | 83 + CCache/debian/patches/13_html_links.diff | 33 + CCache/debian/patches/14_hardlink_doc.diff | 48 + CCache/debian/patches/CREDITS | 47 + CCache/debian/rules | 141 + CCache/debian/update-ccache | 43 + CCache/debian/watch | 2 + CCache/execute.c | 286 + CCache/hash.c | 80 + CCache/install-sh | 238 + CCache/mdfour.c | 284 + CCache/mdfour.h | 36 + CCache/packaging/README | 5 + CCache/packaging/ccache.spec | 37 + CCache/snprintf.c | 962 + CCache/stats.c | 361 + CCache/test.sh | 452 + CCache/unify.c | 307 + CCache/util.c | 884 + CCache/web/index.html | 158 + CHANGES | 20309 ++++++++ CHANGES.current | 257 + Doc/Devel/cmdopt.html | 79 + Doc/Devel/engineering.html | 411 + Doc/Devel/file.html | 181 + Doc/Devel/index.html | 30 + Doc/Devel/internals.html | 1102 + Doc/Devel/migrate.txt | 140 + Doc/Devel/parm.html | 102 + Doc/Devel/runtime.txt | 169 + Doc/Devel/scanner.html | 288 + Doc/Devel/tree.html | 265 + Doc/Devel/wrapobj.html | 223 + Doc/Manual/Allegrocl.html | 2150 + Doc/Manual/Arguments.html | 496 + Doc/Manual/CCache.html | 475 + Doc/Manual/CSharp.html | 2360 + Doc/Manual/Chicken.html | 598 + Doc/Manual/Contents.html | 1610 + Doc/Manual/Contract.html | 274 + Doc/Manual/Customization.html | 1147 + Doc/Manual/Extending.html | 3788 ++ Doc/Manual/Guile.html | 895 + Doc/Manual/Introduction.html | 462 + Doc/Manual/Java.html | 7759 +++ Doc/Manual/Library.html | 1781 + Doc/Manual/Lisp.html | 802 + Doc/Manual/Lua.html | 1598 + Doc/Manual/Makefile | 70 + Doc/Manual/Modula3.html | 1067 + Doc/Manual/Modules.html | 348 + Doc/Manual/Mzscheme.html | 71 + Doc/Manual/Ocaml.html | 991 + Doc/Manual/Octave.html | 836 + Doc/Manual/Perl5.html | 3001 ++ Doc/Manual/Php.html | 1252 + Doc/Manual/Pike.html | 245 + Doc/Manual/Preface.html | 251 + Doc/Manual/Preprocessor.html | 491 + Doc/Manual/Python.html | 5213 ++ Doc/Manual/R.html | 160 + Doc/Manual/README | 21 + Doc/Manual/Ruby.html | 10745 ++++ Doc/Manual/SWIG.html | 3077 ++ Doc/Manual/SWIGDocumentation.html | 50041 +++++++++++++++++++ Doc/Manual/SWIGDocumentation.pdf | Bin 0 -> 1844733 bytes Doc/Manual/SWIGPlus.html | 4843 ++ Doc/Manual/Scripting.html | 474 + Doc/Manual/Sections.html | 86 + Doc/Manual/Tcl.html | 3436 ++ Doc/Manual/Typemaps.html | 4066 ++ Doc/Manual/Varargs.html | 925 + Doc/Manual/Warnings.html | 580 + Doc/Manual/Windows.html | 377 + Doc/Manual/ch11.1.png | Bin 0 -> 2492 bytes Doc/Manual/ch11.2.png | Bin 0 -> 2624 bytes Doc/Manual/ch11.3.png | Bin 0 -> 2942 bytes Doc/Manual/ch12.1.png | Bin 0 -> 3605 bytes Doc/Manual/ch2.1.png | Bin 0 -> 3146 bytes Doc/Manual/ch9.table.2.png | Bin 0 -> 3821 bytes Doc/Manual/chapters | 36 + Doc/Manual/fixstyle.py | 25 + Doc/Manual/index.html | 18 + Doc/Manual/makechap.py | 213 + Doc/Manual/maketoc.py | 37 + Doc/Manual/margin-left.patch | 269 + Doc/Manual/style.css | 84 + Doc/Manual/swig16.png | Bin 0 -> 5538 bytes Doc/Manual/swightml.book | 39 + Doc/Manual/swigpdf.book | 39 + Doc/README | 6 + Examples/GIFPlot/Chicken/check.list | 3 + Examples/GIFPlot/Chicken/full/Makefile | 28 + Examples/GIFPlot/Chicken/full/README | 6 + Examples/GIFPlot/Chicken/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Chicken/full/gifplot.i | 26 + Examples/GIFPlot/Chicken/full/test-gifplot.scm | 66 + Examples/GIFPlot/Chicken/simple/Makefile | 28 + Examples/GIFPlot/Chicken/simple/README | 5 + Examples/GIFPlot/Chicken/simple/simple.i | 34 + Examples/GIFPlot/Chicken/simple/test-simple.scm | 29 + Examples/GIFPlot/Common-Lisp/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Common-Lisp/full/gifplot.i | 21 + Examples/GIFPlot/Common-Lisp/full/runme.lisp | 59 + Examples/GIFPlot/Guile/check.list | 3 + Examples/GIFPlot/Guile/full/Makefile | 28 + Examples/GIFPlot/Guile/full/README | 8 + Examples/GIFPlot/Guile/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Guile/full/gifplot.i | 21 + Examples/GIFPlot/Guile/full/runme.scm | 66 + Examples/GIFPlot/Guile/simple/Makefile | 28 + Examples/GIFPlot/Guile/simple/README | 11 + Examples/GIFPlot/Guile/simple/runme.scm | 30 + Examples/GIFPlot/Guile/simple/simple.i | 34 + Examples/GIFPlot/Include/gifplot.h | 333 + Examples/GIFPlot/Interface/gifplot.i | 264 + Examples/GIFPlot/Java/check.list | 4 + Examples/GIFPlot/Java/full/Makefile | 20 + Examples/GIFPlot/Java/full/README | 8 + Examples/GIFPlot/Java/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Java/full/gifplot.i | 15 + Examples/GIFPlot/Java/full/runme.java | 75 + Examples/GIFPlot/Java/shadow/Makefile | 21 + Examples/GIFPlot/Java/shadow/README | 5 + Examples/GIFPlot/Java/shadow/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Java/shadow/runme.java | 76 + Examples/GIFPlot/Java/simple/Makefile | 21 + Examples/GIFPlot/Java/simple/README | 5 + Examples/GIFPlot/Java/simple/runme.java | 41 + Examples/GIFPlot/Java/simple/simple.i | 38 + Examples/GIFPlot/Lib/Makefile.in | 22 + Examples/GIFPlot/Lib/color.c | 143 + Examples/GIFPlot/Lib/font.c | 705 + Examples/GIFPlot/Lib/frame.c | 924 + Examples/GIFPlot/Lib/gif.c | 672 + Examples/GIFPlot/Lib/matrix.c | 343 + Examples/GIFPlot/Lib/pixmap.c | 159 + Examples/GIFPlot/Lib/plot2d.c | 445 + Examples/GIFPlot/Lib/plot3d.c | 2181 + Examples/GIFPlot/Makefile.in | 23 + Examples/GIFPlot/Ocaml/check.list | 3 + Examples/GIFPlot/Ocaml/full/Makefile | 33 + Examples/GIFPlot/Ocaml/full/README | 8 + Examples/GIFPlot/Ocaml/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Ocaml/full/gifplot.i | 15 + Examples/GIFPlot/Ocaml/full/runme.ml | 87 + Examples/GIFPlot/Ocaml/simple/Makefile | 33 + Examples/GIFPlot/Ocaml/simple/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Ocaml/simple/runme.ml | 35 + Examples/GIFPlot/Ocaml/simple/simple.i | 33 + Examples/GIFPlot/Perl5/check.list | 4 + Examples/GIFPlot/Perl5/full/Makefile | 24 + Examples/GIFPlot/Perl5/full/README | 8 + Examples/GIFPlot/Perl5/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Perl5/full/gifplot.i | 15 + Examples/GIFPlot/Perl5/full/runme.pl | 68 + Examples/GIFPlot/Perl5/shadow/Makefile | 25 + Examples/GIFPlot/Perl5/shadow/README | 2 + Examples/GIFPlot/Perl5/shadow/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Perl5/shadow/runme.pl | 68 + Examples/GIFPlot/Perl5/simple/Makefile | 24 + Examples/GIFPlot/Perl5/simple/README | 5 + Examples/GIFPlot/Perl5/simple/runme.pl | 28 + Examples/GIFPlot/Perl5/simple/simple.i | 38 + Examples/GIFPlot/Php/check.list | 3 + Examples/GIFPlot/Php/full/Makefile | 20 + Examples/GIFPlot/Php/full/README | 4 + Examples/GIFPlot/Php/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Php/full/gifplot.i | 15 + Examples/GIFPlot/Php/full/runme.php | 78 + Examples/GIFPlot/Php/shadow/Makefile | 19 + Examples/GIFPlot/Php/shadow/README | 2 + Examples/GIFPlot/Php/shadow/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Php/shadow/runme.php | 79 + Examples/GIFPlot/Php/simple/Makefile | 20 + Examples/GIFPlot/Php/simple/README | 5 + Examples/GIFPlot/Php/simple/runme.php | 32 + Examples/GIFPlot/Php/simple/simple.i | 38 + Examples/GIFPlot/Pike/check.list | 2 + Examples/GIFPlot/Pike/simple/Makefile | 24 + Examples/GIFPlot/Pike/simple/README | 5 + Examples/GIFPlot/Pike/simple/runme.pike | 30 + Examples/GIFPlot/Pike/simple/simple.i | 38 + Examples/GIFPlot/Python/check.list | 4 + Examples/GIFPlot/Python/full/Makefile | 26 + Examples/GIFPlot/Python/full/README | 8 + Examples/GIFPlot/Python/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Python/full/gifplot.i | 15 + Examples/GIFPlot/Python/full/runme.py | 64 + Examples/GIFPlot/Python/shadow/Makefile | 27 + Examples/GIFPlot/Python/shadow/README | 8 + Examples/GIFPlot/Python/shadow/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Python/shadow/runme.py | 62 + Examples/GIFPlot/Python/simple/Makefile | 26 + Examples/GIFPlot/Python/simple/README | 5 + Examples/GIFPlot/Python/simple/runme.py | 27 + Examples/GIFPlot/Python/simple/simple.i | 38 + Examples/GIFPlot/README | 59 + Examples/GIFPlot/Ruby/check.list | 4 + Examples/GIFPlot/Ruby/full/Makefile | 24 + Examples/GIFPlot/Ruby/full/README | 8 + Examples/GIFPlot/Ruby/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Ruby/full/gifplot.i | 15 + Examples/GIFPlot/Ruby/full/runme.rb | 66 + Examples/GIFPlot/Ruby/shadow/Makefile | 25 + Examples/GIFPlot/Ruby/shadow/README | 5 + Examples/GIFPlot/Ruby/shadow/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Ruby/shadow/runme.rb | 66 + Examples/GIFPlot/Ruby/simple/Makefile | 24 + Examples/GIFPlot/Ruby/simple/README | 5 + Examples/GIFPlot/Ruby/simple/runme.rb | 27 + Examples/GIFPlot/Ruby/simple/simple.i | 38 + Examples/GIFPlot/Tcl/check.list | 4 + Examples/GIFPlot/Tcl/full/Makefile | 24 + Examples/GIFPlot/Tcl/full/README | 8 + Examples/GIFPlot/Tcl/full/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Tcl/full/gifplot.i | 15 + Examples/GIFPlot/Tcl/full/runme.tcl | 67 + Examples/GIFPlot/Tcl/mandel/Makefile | 24 + Examples/GIFPlot/Tcl/mandel/README | 6 + Examples/GIFPlot/Tcl/mandel/cmap | Bin 0 -> 768 bytes Examples/GIFPlot/Tcl/mandel/display.tcl | 68 + Examples/GIFPlot/Tcl/mandel/mandel.i | 47 + Examples/GIFPlot/Tcl/mandel/mandel.tcl | 170 + Examples/GIFPlot/Tcl/simple/Makefile | 24 + Examples/GIFPlot/Tcl/simple/README | 5 + Examples/GIFPlot/Tcl/simple/runme.tcl | 27 + Examples/GIFPlot/Tcl/simple/simple.i | 38 + Examples/Makefile.in | 1138 + Examples/README | 49 + Examples/chicken/README | 12 + Examples/chicken/check.list | 6 + Examples/chicken/class/Makefile | 38 + Examples/chicken/class/example.cxx | 28 + Examples/chicken/class/example.h | 46 + Examples/chicken/class/example.i | 10 + Examples/chicken/class/test-lowlevel-class.scm | 76 + Examples/chicken/class/test-tinyclos-class.scm | 76 + Examples/chicken/constants/Makefile | 30 + Examples/chicken/constants/example.i | 27 + Examples/chicken/constants/test-constants.scm | 16 + Examples/chicken/egg/Makefile | 39 + Examples/chicken/egg/README | 19 + Examples/chicken/egg/mod1.i | 8 + Examples/chicken/egg/mod2.i | 17 + Examples/chicken/egg/multi.setup | 2 + Examples/chicken/egg/multi_init.scm | 2 + Examples/chicken/egg/single.i | 8 + Examples/chicken/egg/single.setup | 2 + Examples/chicken/egg/test.scm | 18 + Examples/chicken/multimap/Makefile | 30 + Examples/chicken/multimap/example.c | 53 + Examples/chicken/multimap/example.i | 96 + Examples/chicken/multimap/test-multimap.scm | 59 + Examples/chicken/overload/Makefile | 30 + Examples/chicken/overload/README | 2 + Examples/chicken/overload/example.cxx | 33 + Examples/chicken/overload/example.h | 14 + Examples/chicken/overload/example.i | 16 + Examples/chicken/overload/test-overload.scm | 45 + Examples/chicken/simple/Makefile | 30 + Examples/chicken/simple/README | 1 + Examples/chicken/simple/example.c | 24 + Examples/chicken/simple/example.i | 16 + Examples/chicken/simple/test-simple.scm | 28 + Examples/chicken/zlib/Makefile | 28 + Examples/chicken/zlib/README.html | 1666 + Examples/chicken/zlib/example.i | 76 + Examples/chicken/zlib/test-zlib.scm | 41 + Examples/contract/simple_c/example.c | 11 + Examples/contract/simple_c/example.i | 19 + Examples/contract/simple_c/runme1.py | 17 + Examples/contract/simple_c/runme2.py | 20 + Examples/contract/simple_cxx/example.cxx | 30 + Examples/contract/simple_cxx/example.h | 34 + Examples/contract/simple_cxx/example.i | 28 + Examples/contract/simple_cxx/runme1.py | 33 + Examples/contract/simple_cxx/runme2.py | 44 + Examples/contract/simple_cxx/runme3.py | 57 + Examples/csharp/arrays/Makefile | 20 + Examples/csharp/arrays/example.c | 22 + Examples/csharp/arrays/example.h | 4 + Examples/csharp/arrays/example.i | 45 + Examples/csharp/arrays/runme.cs | 43 + Examples/csharp/callback/Makefile | 20 + Examples/csharp/callback/example-cs.csproj | 99 + Examples/csharp/callback/example-vc.vcproj | 158 + Examples/csharp/callback/example.cxx | 4 + Examples/csharp/callback/example.h | 24 + Examples/csharp/callback/example.i | 13 + Examples/csharp/callback/example.sln | 30 + Examples/csharp/callback/runme.cs | 46 + Examples/csharp/check.list | 11 + Examples/csharp/class/Makefile | 20 + Examples/csharp/class/example-cs.csproj | 104 + Examples/csharp/class/example-vc.vcproj | 158 + Examples/csharp/class/example.cxx | 28 + Examples/csharp/class/example.h | 39 + Examples/csharp/class/example.i | 10 + Examples/csharp/class/example.sln | 30 + Examples/csharp/class/runme.cs | 66 + Examples/csharp/enum/Makefile | 20 + Examples/csharp/enum/example-cs.csproj | 99 + Examples/csharp/enum/example-vc.vcproj | 158 + Examples/csharp/enum/example.cxx | 37 + Examples/csharp/enum/example.h | 13 + Examples/csharp/enum/example.i | 11 + Examples/csharp/enum/example.sln | 30 + Examples/csharp/enum/runme.cs | 31 + Examples/csharp/extend/Makefile | 20 + Examples/csharp/extend/example-cs.csproj | 104 + Examples/csharp/extend/example-vc.vcproj | 158 + Examples/csharp/extend/example.cxx | 4 + Examples/csharp/extend/example.h | 56 + Examples/csharp/extend/example.i | 15 + Examples/csharp/extend/example.sln | 30 + Examples/csharp/extend/runme.cs | 77 + Examples/csharp/funcptr/Makefile | 20 + Examples/csharp/funcptr/example-cs.csproj | 94 + Examples/csharp/funcptr/example-vc.vcproj | 160 + Examples/csharp/funcptr/example.c | 19 + Examples/csharp/funcptr/example.h | 9 + Examples/csharp/funcptr/example.i | 16 + Examples/csharp/funcptr/example.sln | 30 + Examples/csharp/funcptr/runme.cs | 27 + Examples/csharp/reference/Makefile | 20 + Examples/csharp/reference/example-cs.csproj | 99 + Examples/csharp/reference/example-vc.vcproj | 158 + Examples/csharp/reference/example.cxx | 46 + Examples/csharp/reference/example.h | 26 + Examples/csharp/reference/example.i | 46 + Examples/csharp/reference/example.sln | 30 + Examples/csharp/reference/runme.cs | 73 + Examples/csharp/simple/Makefile | 20 + Examples/csharp/simple/example-cs.csproj | 89 + Examples/csharp/simple/example-vc.vcproj | 222 + Examples/csharp/simple/example.c | 18 + Examples/csharp/simple/example.i | 7 + Examples/csharp/simple/example.sln | 26 + Examples/csharp/simple/runme.cs | 25 + Examples/csharp/template/Makefile | 20 + Examples/csharp/template/example-cs.csproj | 109 + Examples/csharp/template/example-vc.vcproj | 157 + Examples/csharp/template/example.h | 32 + Examples/csharp/template/example.i | 17 + Examples/csharp/template/example.sln | 30 + Examples/csharp/template/runme.cs | 39 + Examples/csharp/variables/Makefile | 20 + Examples/csharp/variables/example-cs.csproj | 99 + Examples/csharp/variables/example-vc.vcproj | 157 + Examples/csharp/variables/example.c | 91 + Examples/csharp/variables/example.h | 6 + Examples/csharp/variables/example.i | 49 + Examples/csharp/variables/example.sln | 30 + Examples/csharp/variables/runme.cs | 82 + Examples/guile/Makefile.in | 40 + Examples/guile/README | 17 + Examples/guile/check.list | 7 + Examples/guile/constants/Makefile | 17 + Examples/guile/constants/constants.scm | 10 + Examples/guile/constants/example.i | 27 + Examples/guile/matrix/Makefile | 18 + Examples/guile/matrix/README | 13 + Examples/guile/matrix/main.c | 24 + Examples/guile/matrix/matrix.c | 61 + Examples/guile/matrix/matrix.i | 36 + Examples/guile/matrix/matrix.scm | 210 + Examples/guile/matrix/package.i | 20 + Examples/guile/matrix/vector.c | 44 + Examples/guile/matrix/vector.h | 10 + Examples/guile/matrix/vector.i | 22 + Examples/guile/multimap/Makefile | 18 + Examples/guile/multimap/example.c | 53 + Examples/guile/multimap/example.i | 87 + Examples/guile/multimap/runme.scm | 30 + Examples/guile/multivalue/Makefile | 18 + Examples/guile/multivalue/example.c | 18 + Examples/guile/multivalue/example.i | 32 + Examples/guile/multivalue/runme.scm | 66 + Examples/guile/port/Makefile | 18 + Examples/guile/port/README | 2 + Examples/guile/port/port.c | 18 + Examples/guile/port/port.i | 15 + Examples/guile/port/port.scm | 32 + Examples/guile/simple/Makefile | 19 + Examples/guile/simple/README | 9 + Examples/guile/simple/example.c | 21 + Examples/guile/simple/example.i | 14 + Examples/guile/simple/example.scm | 28 + Examples/guile/std_vector/Makefile | 18 + Examples/guile/std_vector/example.h | 25 + Examples/guile/std_vector/example.i | 17 + Examples/guile/std_vector/runme.scm | 54 + Examples/index.html | 58 + Examples/java/callback/Makefile | 18 + Examples/java/callback/example.cxx | 4 + Examples/java/callback/example.h | 23 + Examples/java/callback/example.i | 13 + Examples/java/callback/index.html | 20 + Examples/java/callback/runme.java | 56 + Examples/java/check.list | 15 + Examples/java/class/Makefile | 18 + Examples/java/class/example.cxx | 28 + Examples/java/class/example.dsp | 162 + Examples/java/class/example.h | 39 + Examples/java/class/example.i | 10 + Examples/java/class/index.html | 197 + Examples/java/class/runme.java | 70 + Examples/java/constants/Makefile | 18 + Examples/java/constants/example.i | 30 + Examples/java/constants/index.html | 52 + Examples/java/constants/runme.java | 44 + Examples/java/enum/Makefile | 18 + Examples/java/enum/example.cxx | 37 + Examples/java/enum/example.h | 13 + Examples/java/enum/example.i | 14 + Examples/java/enum/index.html | 29 + Examples/java/enum/runme.java | 38 + Examples/java/extend/Makefile | 18 + Examples/java/extend/example.cxx | 4 + Examples/java/extend/example.h | 56 + Examples/java/extend/example.i | 15 + Examples/java/extend/index.html | 19 + Examples/java/extend/runme.java | 88 + Examples/java/funcptr/Makefile | 18 + Examples/java/funcptr/example.c | 19 + Examples/java/funcptr/example.h | 9 + Examples/java/funcptr/example.i | 16 + Examples/java/funcptr/index.html | 91 + Examples/java/funcptr/runme.java | 33 + Examples/java/index.html | 65 + Examples/java/multimap/Makefile | 18 + Examples/java/multimap/example.c | 53 + Examples/java/multimap/example.dsp | 158 + Examples/java/multimap/example.i | 109 + Examples/java/multimap/runme.java | 40 + Examples/java/native/Makefile | 18 + Examples/java/native/example.i | 56 + Examples/java/native/index.html | 33 + Examples/java/native/runme.java | 19 + Examples/java/pointer/Makefile | 18 + Examples/java/pointer/example.c | 16 + Examples/java/pointer/example.i | 30 + Examples/java/pointer/index.html | 165 + Examples/java/pointer/runme.java | 55 + Examples/java/reference/Makefile | 18 + Examples/java/reference/example.cxx | 46 + Examples/java/reference/example.h | 26 + Examples/java/reference/example.i | 46 + Examples/java/reference/index.html | 147 + Examples/java/reference/runme.java | 79 + Examples/java/simple/Makefile | 18 + Examples/java/simple/example.c | 18 + Examples/java/simple/example.dsp | 158 + Examples/java/simple/example.i | 7 + Examples/java/simple/index.html | 108 + Examples/java/simple/runme.java | 32 + Examples/java/template/Makefile | 18 + Examples/java/template/example.h | 32 + Examples/java/template/example.i | 17 + Examples/java/template/index.html | 102 + Examples/java/template/runme.java | 45 + Examples/java/typemap/Makefile | 18 + Examples/java/typemap/example.i | 101 + Examples/java/typemap/index.html | 32 + Examples/java/typemap/runme.java | 26 + Examples/java/variables/Makefile | 18 + Examples/java/variables/example.c | 91 + Examples/java/variables/example.h | 6 + Examples/java/variables/example.i | 49 + Examples/java/variables/index.html | 85 + Examples/java/variables/runme.java | 97 + Examples/lua/arrays/Makefile | 18 + Examples/lua/arrays/example.c | 25 + Examples/lua/arrays/example.i | 42 + Examples/lua/arrays/runme.lua | 74 + Examples/lua/check.list | 17 + Examples/lua/class/Makefile | 19 + Examples/lua/class/example.cxx | 28 + Examples/lua/class/example.h | 39 + Examples/lua/class/example.i | 10 + Examples/lua/class/runme.lua | 62 + Examples/lua/constants/Makefile | 19 + Examples/lua/constants/example.i | 27 + Examples/lua/constants/runme.lua | 35 + Examples/lua/dual/Makefile | 21 + Examples/lua/dual/dual.cpp | 109 + Examples/lua/dual/example.i | 10 + Examples/lua/dual/example2.i | 10 + Examples/lua/embed/Makefile | 18 + Examples/lua/embed/embed.c | 85 + Examples/lua/embed/example.c | 22 + Examples/lua/embed/example.i | 8 + Examples/lua/embed/runme.lua | 40 + Examples/lua/embed2/Makefile | 18 + Examples/lua/embed2/embed2.c | 233 + Examples/lua/embed2/example.c | 22 + Examples/lua/embed2/example.i | 8 + Examples/lua/embed2/runme.lua | 27 + Examples/lua/embed3/Makefile | 20 + Examples/lua/embed3/embed3.cpp | 146 + Examples/lua/embed3/example.cpp | 25 + Examples/lua/embed3/example.h | 24 + Examples/lua/embed3/example.i | 8 + Examples/lua/embed3/runme.lua | 35 + Examples/lua/exception/Makefile | 19 + Examples/lua/exception/example.h | 53 + Examples/lua/exception/example.i | 17 + Examples/lua/exception/runme.lua | 96 + Examples/lua/funcptr3/Makefile | 19 + Examples/lua/funcptr3/example.c | 19 + Examples/lua/funcptr3/example.h | 9 + Examples/lua/funcptr3/example.i | 69 + Examples/lua/funcptr3/runme.lua | 54 + Examples/lua/functest/Makefile | 19 + Examples/lua/functest/example.c | 25 + Examples/lua/functest/example.i | 13 + Examples/lua/functest/runme.lua | 20 + Examples/lua/functor/Makefile | 20 + Examples/lua/functor/example.i | 29 + Examples/lua/functor/runme.lua | 24 + Examples/lua/import.lua | 42 + Examples/lua/import/Makefile | 19 + Examples/lua/import/README | 36 + Examples/lua/import/bar.h | 21 + Examples/lua/import/bar.i | 9 + Examples/lua/import/base.h | 16 + Examples/lua/import/base.i | 6 + Examples/lua/import/foo.h | 21 + Examples/lua/import/foo.i | 8 + Examples/lua/import/runme.lua | 103 + Examples/lua/import/spam.h | 24 + Examples/lua/import/spam.i | 9 + Examples/lua/lua.c | 439 + Examples/lua/owner/Makefile | 19 + Examples/lua/owner/example.cxx | 69 + Examples/lua/owner/example.h | 54 + Examples/lua/owner/example.i | 32 + Examples/lua/owner/runme.lua | 104 + Examples/lua/pointer/Makefile | 19 + Examples/lua/pointer/example.c | 16 + Examples/lua/pointer/example.i | 35 + Examples/lua/pointer/runme.lua | 48 + Examples/lua/simple/Makefile | 18 + Examples/lua/simple/example.c | 18 + Examples/lua/simple/example.i | 7 + Examples/lua/simple/runme.lua | 35 + Examples/lua/variables/Makefile | 18 + Examples/lua/variables/example.c | 91 + Examples/lua/variables/example.h | 6 + Examples/lua/variables/example.i | 49 + Examples/lua/variables/runme.lua | 81 + Examples/modula3/check.list | 7 + Examples/modula3/class/Makefile | 25 + Examples/modula3/class/example.cxx | 28 + Examples/modula3/class/example.h | 44 + Examples/modula3/class/example.i | 32 + Examples/modula3/class/swig.tmpl | 11 + Examples/modula3/enum/Makefile | 26 + Examples/modula3/enum/example.cxx | 32 + Examples/modula3/enum/example.h | 83 + Examples/modula3/enum/example.i | 72 + Examples/modula3/exception/Makefile | 23 + Examples/modula3/exception/example.h | 18 + Examples/modula3/exception/example.i | 43 + Examples/modula3/reference/Makefile | 21 + Examples/modula3/reference/example.cxx | 46 + Examples/modula3/reference/example.h | 22 + Examples/modula3/reference/example.i | 32 + Examples/modula3/simple/Makefile | 21 + Examples/modula3/simple/example.c | 18 + Examples/modula3/simple/example.i | 7 + Examples/modula3/typemap/Makefile | 21 + Examples/modula3/typemap/example.i | 90 + Examples/mzscheme/check.list | 3 + Examples/mzscheme/multimap/Makefile | 13 + Examples/mzscheme/multimap/example.c | 53 + Examples/mzscheme/multimap/example.i | 91 + Examples/mzscheme/multimap/example.scm | 27 + Examples/mzscheme/simple/Makefile | 13 + Examples/mzscheme/simple/README | 1 + Examples/mzscheme/simple/example.c | 24 + Examples/mzscheme/simple/example.i | 16 + Examples/mzscheme/simple/example.scm | 24 + Examples/mzscheme/std_vector/Makefile | 19 + Examples/mzscheme/std_vector/example.h | 25 + Examples/mzscheme/std_vector/example.i | 17 + Examples/mzscheme/std_vector/example.scm | 54 + Examples/ocaml/argout_ref/Makefile | 27 + Examples/ocaml/argout_ref/example.c | 19 + Examples/ocaml/argout_ref/example.i | 4 + Examples/ocaml/argout_ref/example_prog.ml | 26 + Examples/ocaml/check.list | 10 + Examples/ocaml/contract/Makefile | 33 + Examples/ocaml/contract/example.i | 18 + Examples/ocaml/contract/example_prog.ml | 7 + Examples/ocaml/scoped_enum/Makefile | 33 + Examples/ocaml/scoped_enum/README | 1 + Examples/ocaml/scoped_enum/example.i | 7 + Examples/ocaml/scoped_enum/example_prog.ml | 4 + Examples/ocaml/scoped_enum/foo.h | 5 + Examples/ocaml/shapes/Makefile | 34 + Examples/ocaml/shapes/example.c | 48 + Examples/ocaml/shapes/example.h | 18 + Examples/ocaml/shapes/example.i | 10 + Examples/ocaml/shapes/example_prog.ml | 76 + Examples/ocaml/simple/Makefile | 33 + Examples/ocaml/simple/example.c | 18 + Examples/ocaml/simple/example.i | 7 + Examples/ocaml/simple/example_prog.ml | 33 + Examples/ocaml/simple/index.html | 97 + Examples/ocaml/std_string/Makefile | 23 + Examples/ocaml/std_string/README | 13 + Examples/ocaml/std_string/example.h | 36 + Examples/ocaml/std_string/example.i | 12 + Examples/ocaml/std_string/runme.ml | 24 + Examples/ocaml/std_vector/Makefile | 23 + Examples/ocaml/std_vector/example.h | 25 + Examples/ocaml/std_vector/example.i | 15 + Examples/ocaml/std_vector/runme.ml | 35 + Examples/ocaml/stl/Makefile | 33 + Examples/ocaml/stl/example.h | 17 + Examples/ocaml/stl/example.i | 12 + Examples/ocaml/stl/runme.ml | 13 + Examples/ocaml/string_from_ptr/Makefile | 34 + Examples/ocaml/string_from_ptr/example_prog.ml | 23 + Examples/ocaml/string_from_ptr/foolib.i | 16 + Examples/ocaml/strings_test/Makefile | 28 + Examples/ocaml/strings_test/example.h | 37 + Examples/ocaml/strings_test/example.i | 14 + Examples/ocaml/strings_test/runme.ml | 17 + Examples/octave/callback/Makefile | 21 + Examples/octave/callback/example.cxx | 4 + Examples/octave/callback/example.h | 23 + Examples/octave/callback/example.i | 13 + Examples/octave/callback/runme.m | 63 + Examples/octave/check.list | 16 + Examples/octave/class/Makefile | 21 + Examples/octave/class/example.cxx | 28 + Examples/octave/class/example.h | 39 + Examples/octave/class/example.i | 10 + Examples/octave/class/runme.m | 52 + Examples/octave/constants/Makefile | 21 + Examples/octave/constants/example.i | 27 + Examples/octave/constants/runme.m | 29 + Examples/octave/contract/Makefile | 19 + Examples/octave/contract/example.c | 23 + Examples/octave/contract/example.i | 21 + Examples/octave/contract/runme.m | 22 + Examples/octave/enum/Makefile | 21 + Examples/octave/enum/example.cxx | 37 + Examples/octave/enum/example.h | 13 + Examples/octave/enum/example.i | 11 + Examples/octave/enum/runme.m | 32 + Examples/octave/extend/Makefile | 21 + Examples/octave/extend/example.cxx | 4 + Examples/octave/extend/example.h | 56 + Examples/octave/extend/example.i | 15 + Examples/octave/extend/runme.m | 74 + Examples/octave/funcptr/Makefile | 19 + Examples/octave/funcptr/example.c | 19 + Examples/octave/funcptr/example.h | 9 + Examples/octave/funcptr/example.i | 16 + Examples/octave/funcptr/runme.m | 21 + Examples/octave/funcptr2/Makefile | 19 + Examples/octave/funcptr2/example.c | 19 + Examples/octave/funcptr2/example.h | 9 + Examples/octave/funcptr2/example.i | 18 + Examples/octave/funcptr2/runme.m | 24 + Examples/octave/functor/Makefile | 21 + Examples/octave/functor/example.i | 29 + Examples/octave/functor/runme.m | 18 + Examples/octave/operator/Makefile | 21 + Examples/octave/operator/example.h | 36 + Examples/octave/operator/example.i | 24 + Examples/octave/operator/runme.m | 24 + Examples/octave/pointer/Makefile | 19 + Examples/octave/pointer/example.c | 16 + Examples/octave/pointer/example.i | 30 + Examples/octave/pointer/runme.m | 42 + Examples/octave/reference/Makefile | 21 + Examples/octave/reference/example.cxx | 46 + Examples/octave/reference/example.h | 26 + Examples/octave/reference/example.i | 48 + Examples/octave/reference/runme.m | 63 + Examples/octave/simple/Makefile | 19 + Examples/octave/simple/example.c | 18 + Examples/octave/simple/example.i | 7 + Examples/octave/simple/runme.m | 22 + Examples/octave/template/Makefile | 21 + Examples/octave/template/example.h | 32 + Examples/octave/template/example.i | 17 + Examples/octave/template/runme.m | 37 + Examples/octave/variables/Makefile | 19 + Examples/octave/variables/example.c | 91 + Examples/octave/variables/example.h | 6 + Examples/octave/variables/example.i | 53 + Examples/octave/variables/runme.m | 75 + Examples/perl5/check.list | 14 + Examples/perl5/class/Makefile | 19 + Examples/perl5/class/example.cxx | 28 + Examples/perl5/class/example.dsp | 152 + Examples/perl5/class/example.h | 47 + Examples/perl5/class/example.i | 11 + Examples/perl5/class/index.html | 208 + Examples/perl5/class/runme.pl | 60 + Examples/perl5/constants/Makefile | 18 + Examples/perl5/constants/example.i | 27 + Examples/perl5/constants/index.html | 53 + Examples/perl5/constants/runme.pl | 29 + Examples/perl5/constants2/Makefile | 18 + Examples/perl5/constants2/example.i | 27 + Examples/perl5/constants2/runme.pl | 16 + Examples/perl5/funcptr/Makefile | 18 + Examples/perl5/funcptr/example.c | 19 + Examples/perl5/funcptr/example.h | 9 + Examples/perl5/funcptr/example.i | 16 + Examples/perl5/funcptr/index.html | 90 + Examples/perl5/funcptr/runme.pl | 21 + Examples/perl5/import/Makefile | 20 + Examples/perl5/import/README | 39 + Examples/perl5/import/bar.dsp | 144 + Examples/perl5/import/bar.h | 22 + Examples/perl5/import/bar.i | 9 + Examples/perl5/import/base.dsp | 144 + Examples/perl5/import/base.h | 18 + Examples/perl5/import/base.i | 6 + Examples/perl5/import/example.dsw | 65 + Examples/perl5/import/foo.dsp | 144 + Examples/perl5/import/foo.h | 21 + Examples/perl5/import/foo.i | 8 + Examples/perl5/import/runme.pl | 116 + Examples/perl5/import/spam.dsp | 144 + Examples/perl5/import/spam.h | 24 + Examples/perl5/import/spam.i | 9 + Examples/perl5/index.html | 98 + Examples/perl5/inline/Makefile | 7 + Examples/perl5/inline/README | 2 + Examples/perl5/inline/runme.pl | 34 + Examples/perl5/java/Example.java | 29 + Examples/perl5/java/Makefile | 26 + Examples/perl5/java/example.i | 10 + Examples/perl5/java/runme.pl | 29 + Examples/perl5/multimap/Makefile | 18 + Examples/perl5/multimap/example.c | 53 + Examples/perl5/multimap/example.dsp | 148 + Examples/perl5/multimap/example.i | 93 + Examples/perl5/multimap/runme.pl | 28 + Examples/perl5/multiple_inheritance/Makefile | 19 + Examples/perl5/multiple_inheritance/example.h | 31 + Examples/perl5/multiple_inheritance/example.i | 9 + Examples/perl5/multiple_inheritance/runme.pl | 16 + Examples/perl5/pointer/Makefile | 18 + Examples/perl5/pointer/example.c | 16 + Examples/perl5/pointer/example.i | 30 + Examples/perl5/pointer/index.html | 171 + Examples/perl5/pointer/runme.pl | 44 + Examples/perl5/reference/Makefile | 20 + Examples/perl5/reference/example.cxx | 46 + Examples/perl5/reference/example.h | 26 + Examples/perl5/reference/example.i | 46 + Examples/perl5/reference/index.html | 146 + Examples/perl5/reference/runme.pl | 74 + Examples/perl5/simple/Makefile | 18 + Examples/perl5/simple/example.c | 18 + Examples/perl5/simple/example.dsp | 148 + Examples/perl5/simple/example.i | 7 + Examples/perl5/simple/index.html | 99 + Examples/perl5/simple/runme.pl | 23 + Examples/perl5/value/Makefile | 18 + Examples/perl5/value/example.c | 15 + Examples/perl5/value/example.h | 5 + Examples/perl5/value/example.i | 32 + Examples/perl5/value/index.html | 126 + Examples/perl5/value/runme.pl | 38 + Examples/perl5/variables/Makefile | 18 + Examples/perl5/variables/example.c | 91 + Examples/perl5/variables/example.h | 6 + Examples/perl5/variables/example.i | 51 + Examples/perl5/variables/index.html | 63 + Examples/perl5/variables/runme.pl | 73 + Examples/perl5/xmlstring/Makefile | 23 + Examples/perl5/xmlstring/example.cxx | 1 + Examples/perl5/xmlstring/example.h | 36 + Examples/perl5/xmlstring/example.i | 10 + Examples/perl5/xmlstring/runme.pl | 8 + Examples/perl5/xmlstring/xmlstring.i | 111 + Examples/php/callback/Makefile | 22 + Examples/php/callback/example.cxx | 4 + Examples/php/callback/example.h | 22 + Examples/php/callback/example.i | 13 + Examples/php/callback/index.html | 19 + Examples/php/callback/runme.php | 47 + Examples/php/check.list | 19 + Examples/php/class/Makefile | 24 + Examples/php/class/example.cxx | 39 + Examples/php/class/example.h | 38 + Examples/php/class/example.i | 10 + Examples/php/class/runme.php | 60 + Examples/php/constants/Makefile | 24 + Examples/php/constants/example.i | 26 + Examples/php/constants/runme.php | 28 + Examples/php/cpointer/Makefile | 24 + Examples/php/cpointer/example.c | 16 + Examples/php/cpointer/example.i | 26 + Examples/php/cpointer/runme.php | 45 + Examples/php/disown/Makefile | 24 + Examples/php/disown/example.cxx | 51 + Examples/php/disown/example.h | 50 + Examples/php/disown/example.i | 12 + Examples/php/disown/runme.php | 49 + Examples/php/enum/Makefile | 24 + Examples/php/enum/example.cxx | 37 + Examples/php/enum/example.h | 13 + Examples/php/enum/example.i | 12 + Examples/php/enum/runme.php | 32 + Examples/php/extend/Makefile | 22 + Examples/php/extend/example.cxx | 4 + Examples/php/extend/example.h | 56 + Examples/php/extend/example.i | 15 + Examples/php/extend/index.html | 19 + Examples/php/extend/runme.php | 76 + Examples/php/funcptr/Makefile | 24 + Examples/php/funcptr/example.c | 17 + Examples/php/funcptr/example.h | 7 + Examples/php/funcptr/example.i | 15 + Examples/php/funcptr/runme.php | 24 + Examples/php/overloading/Makefile | 24 + Examples/php/overloading/example.cxx | 55 + Examples/php/overloading/example.h | 46 + Examples/php/overloading/example.i | 8 + Examples/php/overloading/runme.php | 59 + Examples/php/pointer/Makefile | 24 + Examples/php/pointer/example.c | 16 + Examples/php/pointer/example.i | 24 + Examples/php/pointer/runme.php | 35 + Examples/php/pragmas/Makefile | 24 + Examples/php/pragmas/example.i | 31 + Examples/php/pragmas/include.php | 7 + Examples/php/pragmas/runme.php | 5 + Examples/php/proxy/Makefile | 24 + Examples/php/proxy/example.cxx | 43 + Examples/php/proxy/example.h | 43 + Examples/php/proxy/example.i | 12 + Examples/php/proxy/runme.php | 68 + Examples/php/reference/Makefile | 24 + Examples/php/reference/example.cxx | 49 + Examples/php/reference/example.h | 26 + Examples/php/reference/example.i | 47 + Examples/php/reference/runme-proxy.php4 | 79 + Examples/php/reference/runme.php | 49 + Examples/php/simple/Makefile | 24 + Examples/php/simple/example.c | 23 + Examples/php/simple/example.i | 10 + Examples/php/simple/runme.php | 25 + Examples/php/sync/Makefile | 24 + Examples/php/sync/example.cxx | 13 + Examples/php/sync/example.h | 9 + Examples/php/sync/example.i | 7 + Examples/php/sync/runme.php | 15 + Examples/php/value/Makefile | 24 + Examples/php/value/example.c | 13 + Examples/php/value/example.h | 8 + Examples/php/value/example.i | 17 + Examples/php/value/runme.php | 43 + Examples/php/variables/Makefile | 24 + Examples/php/variables/example.c | 95 + Examples/php/variables/example.h | 34 + Examples/php/variables/example.i | 44 + Examples/php/variables/runme.php | 96 + Examples/php/variables/runme.php4.old | 80 + Examples/pike/check.list | 5 + Examples/pike/class/Makefile | 19 + Examples/pike/class/example.cxx | 46 + Examples/pike/class/example.h | 35 + Examples/pike/class/example.i | 10 + Examples/pike/class/runme.pike | 53 + Examples/pike/constants/Makefile | 18 + Examples/pike/constants/example.i | 27 + Examples/pike/constants/runme.pike | 24 + Examples/pike/enum/Makefile | 19 + Examples/pike/enum/README | 13 + Examples/pike/enum/example.cxx | 37 + Examples/pike/enum/example.h | 13 + Examples/pike/enum/example.i | 11 + Examples/pike/enum/runme.pike | 28 + Examples/pike/overload/Makefile | 19 + Examples/pike/overload/example.cxx | 115 + Examples/pike/overload/example.h | 41 + Examples/pike/overload/example.i | 28 + Examples/pike/overload/runme.pike | 83 + Examples/pike/simple/Makefile | 18 + Examples/pike/simple/example.c | 18 + Examples/pike/simple/example.i | 7 + Examples/pike/simple/runme.pike | 20 + Examples/pike/template/Makefile | 20 + Examples/pike/template/example.h | 32 + Examples/pike/template/example.i | 17 + Examples/pike/template/runme.pike | 33 + Examples/python/callback/Makefile | 22 + Examples/python/callback/example.cxx | 4 + Examples/python/callback/example.h | 22 + Examples/python/callback/example.i | 13 + Examples/python/callback/index.html | 19 + Examples/python/callback/runme.py | 56 + Examples/python/check.list | 29 + Examples/python/class/Makefile | 21 + Examples/python/class/example.cxx | 28 + Examples/python/class/example.dsp | 152 + Examples/python/class/example.h | 39 + Examples/python/class/example.i | 10 + Examples/python/class/index.html | 216 + Examples/python/class/runme.py | 51 + Examples/python/constants/Makefile | 20 + Examples/python/constants/example.i | 27 + Examples/python/constants/index.html | 67 + Examples/python/constants/runme.py | 27 + Examples/python/contract/Makefile | 20 + Examples/python/contract/example.c | 23 + Examples/python/contract/example.dsp | 148 + Examples/python/contract/example.i | 21 + Examples/python/contract/runme.py | 30 + Examples/python/docstrings/Makefile | 24 + Examples/python/docstrings/example.cxx | 4 + Examples/python/docstrings/example.h | 4 + Examples/python/docstrings/example.i | 14 + Examples/python/docstrings/runme.py | 6 + Examples/python/enum/Makefile | 21 + Examples/python/enum/example.cxx | 37 + Examples/python/enum/example.h | 13 + Examples/python/enum/example.i | 11 + Examples/python/enum/index.html | 35 + Examples/python/enum/runme.py | 31 + Examples/python/exception/Makefile | 21 + Examples/python/exception/example.h | 53 + Examples/python/exception/example.i | 12 + Examples/python/exception/runme.py | 36 + Examples/python/exceptproxy/Makefile | 22 + Examples/python/exceptproxy/example.h | 54 + Examples/python/exceptproxy/example.i | 114 + Examples/python/exceptproxy/runme.py | 45 + Examples/python/extend/Makefile | 22 + Examples/python/extend/example.cxx | 4 + Examples/python/extend/example.h | 56 + Examples/python/extend/example.i | 15 + Examples/python/extend/index.html | 19 + Examples/python/extend/runme.py | 81 + Examples/python/funcptr/Makefile | 20 + Examples/python/funcptr/example.c | 19 + Examples/python/funcptr/example.h | 9 + Examples/python/funcptr/example.i | 16 + Examples/python/funcptr/index.html | 90 + Examples/python/funcptr/runme.py | 20 + Examples/python/funcptr2/Makefile | 20 + Examples/python/funcptr2/example.c | 19 + Examples/python/funcptr2/example.h | 9 + Examples/python/funcptr2/example.i | 18 + Examples/python/funcptr2/runme.py | 24 + Examples/python/functor/Makefile | 22 + Examples/python/functor/example.i | 29 + Examples/python/functor/runme.py | 17 + Examples/python/import/Makefile | 22 + Examples/python/import/README | 39 + Examples/python/import/bar.dsp | 144 + Examples/python/import/bar.h | 22 + Examples/python/import/bar.i | 9 + Examples/python/import/base.dsp | 144 + Examples/python/import/base.h | 18 + Examples/python/import/base.i | 6 + Examples/python/import/example.dsw | 65 + Examples/python/import/foo.dsp | 144 + Examples/python/import/foo.h | 21 + Examples/python/import/foo.i | 8 + Examples/python/import/runme.py | 111 + Examples/python/import/spam.dsp | 144 + Examples/python/import/spam.h | 24 + Examples/python/import/spam.i | 9 + Examples/python/import_template/Makefile | 22 + Examples/python/import_template/README | 30 + Examples/python/import_template/bar.h | 22 + Examples/python/import_template/bar.i | 11 + Examples/python/import_template/base.h | 18 + Examples/python/import_template/base.i | 7 + Examples/python/import_template/foo.h | 21 + Examples/python/import_template/foo.i | 10 + Examples/python/import_template/runme.py | 111 + Examples/python/import_template/spam.h | 24 + Examples/python/import_template/spam.i | 10 + Examples/python/index.html | 112 + Examples/python/java/Example.java | 29 + Examples/python/java/Makefile | 25 + Examples/python/java/example.i | 9 + Examples/python/java/runme.py | 16 + Examples/python/libffi/Makefile | 20 + Examples/python/libffi/example.i | 176 + Examples/python/multimap/Makefile | 20 + Examples/python/multimap/example.c | 53 + Examples/python/multimap/example.dsp | 148 + Examples/python/multimap/example.i | 121 + Examples/python/multimap/runme.py | 27 + Examples/python/operator/Makefile | 22 + Examples/python/operator/example.h | 36 + Examples/python/operator/example.i | 28 + Examples/python/operator/runme.py | 21 + Examples/python/pointer/Makefile | 20 + Examples/python/pointer/example.c | 16 + Examples/python/pointer/example.i | 30 + Examples/python/pointer/index.html | 171 + Examples/python/pointer/runme.py | 44 + Examples/python/reference/Makefile | 21 + Examples/python/reference/example.cxx | 46 + Examples/python/reference/example.h | 26 + Examples/python/reference/example.i | 48 + Examples/python/reference/index.html | 147 + Examples/python/reference/runme.py | 63 + Examples/python/simple/Makefile | 20 + Examples/python/simple/example.c | 18 + Examples/python/simple/example.dsp | 148 + Examples/python/simple/example.i | 7 + Examples/python/simple/index.html | 97 + Examples/python/simple/runme.py | 30 + Examples/python/smartptr/Makefile | 22 + Examples/python/smartptr/example.cxx | 31 + Examples/python/smartptr/example.h | 39 + Examples/python/smartptr/example.i | 20 + Examples/python/smartptr/runme.py | 55 + Examples/python/smartptr/smartptr.h | 13 + Examples/python/std_map/Makefile | 25 + Examples/python/std_map/example.h | 17 + Examples/python/std_map/example.i | 27 + Examples/python/std_map/runme.py | 82 + Examples/python/std_vector/Makefile | 22 + Examples/python/std_vector/example.h | 25 + Examples/python/std_vector/example.i | 17 + Examples/python/std_vector/runme.py | 36 + Examples/python/swigrun/Makefile | 25 + Examples/python/swigrun/example.cxx | 20 + Examples/python/swigrun/example.h | 58 + Examples/python/swigrun/example.i | 15 + Examples/python/swigrun/runme.py | 28 + Examples/python/template/Makefile | 22 + Examples/python/template/example.h | 32 + Examples/python/template/example.i | 17 + Examples/python/template/runme.py | 34 + Examples/python/varargs/Makefile | 20 + Examples/python/varargs/example.i | 65 + Examples/python/varargs/runme.py | 34 + Examples/python/variables/Makefile | 20 + Examples/python/variables/example.c | 91 + Examples/python/variables/example.h | 6 + Examples/python/variables/example.i | 51 + Examples/python/variables/index.html | 100 + Examples/python/variables/runme.py | 75 + Examples/python/weave/Makefile | 22 + Examples/python/weave/README | 25 + Examples/python/weave/example.h | 18 + Examples/python/weave/example.i | 15 + Examples/python/weave/runme.py | 72 + Examples/python/weave/swigptr2.py | 3556 ++ Examples/r/check.list | 3 + Examples/r/class/Makefile | 18 + Examples/r/class/example.cxx | 28 + Examples/r/class/example.dsp | 152 + Examples/r/class/example.h | 39 + Examples/r/class/example.i | 9 + Examples/r/class/runme.R | 49 + Examples/r/simple/Makefile | 16 + Examples/r/simple/example.c | 18 + Examples/r/simple/example.dsp | 148 + Examples/r/simple/example.i | 7 + Examples/r/simple/runme.R | 24 + Examples/ruby/check.list | 23 + Examples/ruby/class/Makefile | 19 + Examples/ruby/class/example.cxx | 28 + Examples/ruby/class/example.dsp | 154 + Examples/ruby/class/example.h | 39 + Examples/ruby/class/example.i | 10 + Examples/ruby/class/index.html | 199 + Examples/ruby/class/runme.rb | 49 + Examples/ruby/constants/Makefile | 18 + Examples/ruby/constants/example.i | 27 + Examples/ruby/constants/index.html | 64 + Examples/ruby/constants/runme.rb | 25 + Examples/ruby/enum/Makefile | 19 + Examples/ruby/enum/example.cxx | 37 + Examples/ruby/enum/example.h | 13 + Examples/ruby/enum/example.i | 11 + Examples/ruby/enum/index.html | 35 + Examples/ruby/enum/runme.rb | 30 + Examples/ruby/exception_class/Makefile | 19 + Examples/ruby/exception_class/example.h | 51 + Examples/ruby/exception_class/example.i | 46 + Examples/ruby/exception_class/runme.rb | 45 + Examples/ruby/free_function/Makefile | 19 + Examples/ruby/free_function/example.cxx | 67 + Examples/ruby/free_function/example.dsp | 154 + Examples/ruby/free_function/example.h | 49 + Examples/ruby/free_function/example.i | 41 + Examples/ruby/free_function/runme.rb | 46 + Examples/ruby/funcptr/Makefile | 18 + Examples/ruby/funcptr/example.c | 17 + Examples/ruby/funcptr/example.h | 9 + Examples/ruby/funcptr/example.i | 15 + Examples/ruby/funcptr/index.html | 90 + Examples/ruby/funcptr/runme.rb | 21 + Examples/ruby/funcptr2/Makefile | 18 + Examples/ruby/funcptr2/example.c | 19 + Examples/ruby/funcptr2/example.h | 9 + Examples/ruby/funcptr2/example.i | 18 + Examples/ruby/funcptr2/runme.rb | 22 + Examples/ruby/functor/Makefile | 18 + Examples/ruby/functor/example.i | 26 + Examples/ruby/functor/runme.rb | 17 + Examples/ruby/hashargs/Makefile | 20 + Examples/ruby/hashargs/example.i | 36 + Examples/ruby/hashargs/runme.rb | 26 + Examples/ruby/import/Makefile | 19 + Examples/ruby/import/README | 39 + Examples/ruby/import/bar.dsp | 146 + Examples/ruby/import/bar.h | 21 + Examples/ruby/import/bar.i | 9 + Examples/ruby/import/base.dsp | 146 + Examples/ruby/import/base.h | 16 + Examples/ruby/import/base.i | 6 + Examples/ruby/import/example.dsw | 65 + Examples/ruby/import/foo.dsp | 146 + Examples/ruby/import/foo.h | 21 + Examples/ruby/import/foo.i | 8 + Examples/ruby/import/runme.rb | 90 + Examples/ruby/import/spam.dsp | 146 + Examples/ruby/import/spam.h | 24 + Examples/ruby/import/spam.i | 9 + Examples/ruby/import_template/Makefile | 19 + Examples/ruby/import_template/README | 30 + Examples/ruby/import_template/bar.h | 22 + Examples/ruby/import_template/bar.i | 11 + Examples/ruby/import_template/base.h | 18 + Examples/ruby/import_template/base.i | 7 + Examples/ruby/import_template/foo.h | 21 + Examples/ruby/import_template/foo.i | 10 + Examples/ruby/import_template/runme.rb | 92 + Examples/ruby/import_template/spam.h | 24 + Examples/ruby/import_template/spam.i | 10 + Examples/ruby/index.html | 94 + Examples/ruby/java/Example.java | 29 + Examples/ruby/java/Makefile | 26 + Examples/ruby/java/example.i | 9 + Examples/ruby/java/runme.rb | 18 + Examples/ruby/mark_function/Makefile | 19 + Examples/ruby/mark_function/example.cxx | 61 + Examples/ruby/mark_function/example.dsp | 154 + Examples/ruby/mark_function/example.h | 49 + Examples/ruby/mark_function/example.i | 37 + Examples/ruby/mark_function/runme.rb | 23 + Examples/ruby/multimap/Makefile | 18 + Examples/ruby/multimap/example.c | 53 + Examples/ruby/multimap/example.dsp | 150 + Examples/ruby/multimap/example.i | 92 + Examples/ruby/multimap/runme.rb | 22 + Examples/ruby/operator/Makefile | 20 + Examples/ruby/operator/example.h | 36 + Examples/ruby/operator/example.i | 26 + Examples/ruby/operator/runme.rb | 25 + Examples/ruby/overloading/Makefile | 19 + Examples/ruby/overloading/example.cxx | 125 + Examples/ruby/overloading/example.h | 41 + Examples/ruby/overloading/example.i | 24 + Examples/ruby/overloading/runme.rb | 88 + Examples/ruby/pointer/Makefile | 18 + Examples/ruby/pointer/example.c | 16 + Examples/ruby/pointer/example.i | 30 + Examples/ruby/pointer/index.html | 171 + Examples/ruby/pointer/runme.rb | 45 + Examples/ruby/reference/Makefile | 19 + Examples/ruby/reference/example.cxx | 46 + Examples/ruby/reference/example.h | 26 + Examples/ruby/reference/example.i | 46 + Examples/ruby/reference/index.html | 147 + Examples/ruby/reference/runme.rb | 60 + Examples/ruby/simple/Makefile | 18 + Examples/ruby/simple/example.c | 18 + Examples/ruby/simple/example.dsp | 150 + Examples/ruby/simple/example.i | 7 + Examples/ruby/simple/index.html | 97 + Examples/ruby/simple/runme.rb | 21 + Examples/ruby/std_vector/Makefile | 20 + Examples/ruby/std_vector/example.h | 25 + Examples/ruby/std_vector/example.i | 17 + Examples/ruby/std_vector/runme.rb | 36 + Examples/ruby/template/Makefile | 20 + Examples/ruby/template/example.h | 32 + Examples/ruby/template/example.i | 21 + Examples/ruby/template/runme.rb | 25 + Examples/ruby/value/Makefile | 18 + Examples/ruby/value/example.c | 15 + Examples/ruby/value/example.h | 5 + Examples/ruby/value/example.i | 32 + Examples/ruby/value/index.html | 114 + Examples/ruby/value/runme.rb | 32 + Examples/ruby/variables/Makefile | 18 + Examples/ruby/variables/example.c | 91 + Examples/ruby/variables/example.h | 6 + Examples/ruby/variables/example.i | 50 + Examples/ruby/variables/index.html | 94 + Examples/ruby/variables/runme.rb | 77 + Examples/s-exp/uffi.lisp | 450 + Examples/tcl/check.list | 16 + Examples/tcl/class/Makefile | 19 + Examples/tcl/class/example.cxx | 28 + Examples/tcl/class/example.dsp | 152 + Examples/tcl/class/example.h | 39 + Examples/tcl/class/example.i | 11 + Examples/tcl/class/index.html | 274 + Examples/tcl/class/runme.tcl | 50 + Examples/tcl/class/runme2.tcl | 70 + Examples/tcl/constants/Makefile | 19 + Examples/tcl/constants/example.i | 27 + Examples/tcl/constants/index.html | 61 + Examples/tcl/constants/runme.tcl | 26 + Examples/tcl/contract/Makefile | 20 + Examples/tcl/contract/example.c | 23 + Examples/tcl/contract/example.dsp | 148 + Examples/tcl/contract/example.i | 21 + Examples/tcl/contract/runme.tcl | 22 + Examples/tcl/enum/Makefile | 19 + Examples/tcl/enum/example.cxx | 37 + Examples/tcl/enum/example.h | 13 + Examples/tcl/enum/example.i | 11 + Examples/tcl/enum/index.html | 35 + Examples/tcl/enum/runme.tcl | 32 + Examples/tcl/funcptr/Makefile | 19 + Examples/tcl/funcptr/example.c | 19 + Examples/tcl/funcptr/example.h | 9 + Examples/tcl/funcptr/example.i | 16 + Examples/tcl/funcptr/index.html | 90 + Examples/tcl/funcptr/runme.tcl | 21 + Examples/tcl/import/Makefile | 20 + Examples/tcl/import/README | 37 + Examples/tcl/import/bar.dsp | 144 + Examples/tcl/import/bar.h | 22 + Examples/tcl/import/bar.i | 9 + Examples/tcl/import/base.dsp | 144 + Examples/tcl/import/base.h | 18 + Examples/tcl/import/base.i | 6 + Examples/tcl/import/example.dsw | 65 + Examples/tcl/import/foo.dsp | 144 + Examples/tcl/import/foo.h | 21 + Examples/tcl/import/foo.i | 8 + Examples/tcl/import/runme.tcl | 114 + Examples/tcl/import/spam.dsp | 144 + Examples/tcl/import/spam.h | 24 + Examples/tcl/import/spam.i | 9 + Examples/tcl/index.html | 70 + Examples/tcl/java/Example.java | 29 + Examples/tcl/java/Makefile | 26 + Examples/tcl/java/example.i | 8 + Examples/tcl/java/runme.tcl | 15 + Examples/tcl/multimap/Makefile | 19 + Examples/tcl/multimap/example.c | 53 + Examples/tcl/multimap/example.dsp | 148 + Examples/tcl/multimap/example.i | 80 + Examples/tcl/multimap/runme.tcl | 24 + Examples/tcl/operator/Makefile | 19 + Examples/tcl/operator/example.h | 36 + Examples/tcl/operator/example.i | 28 + Examples/tcl/operator/runme.tcl | 30 + Examples/tcl/pointer/Makefile | 19 + Examples/tcl/pointer/example.c | 16 + Examples/tcl/pointer/example.i | 31 + Examples/tcl/pointer/index.html | 171 + Examples/tcl/pointer/runme.tcl | 47 + Examples/tcl/reference/Makefile | 19 + Examples/tcl/reference/example.cxx | 46 + Examples/tcl/reference/example.h | 26 + Examples/tcl/reference/example.i | 46 + Examples/tcl/reference/index.html | 147 + Examples/tcl/reference/runme.tcl | 76 + Examples/tcl/simple/Makefile | 19 + Examples/tcl/simple/example.c | 18 + Examples/tcl/simple/example.dsp | 148 + Examples/tcl/simple/example.i | 7 + Examples/tcl/simple/index.html | 97 + Examples/tcl/simple/runme.tcl | 22 + Examples/tcl/std_vector/Makefile | 20 + Examples/tcl/std_vector/example.h | 25 + Examples/tcl/std_vector/example.i | 17 + Examples/tcl/std_vector/runme.tcl | 40 + Examples/tcl/value/Makefile | 19 + Examples/tcl/value/example.c | 15 + Examples/tcl/value/example.h | 5 + Examples/tcl/value/example.i | 32 + Examples/tcl/value/index.html | 122 + Examples/tcl/value/runme.tcl | 39 + Examples/tcl/variables/Makefile | 19 + Examples/tcl/variables/example.c | 91 + Examples/tcl/variables/example.h | 6 + Examples/tcl/variables/example.i | 51 + Examples/tcl/variables/index.html | 76 + Examples/tcl/variables/runme.tcl | 76 + Examples/test-suite/README | 42 + Examples/test-suite/abstract_access.i | 36 + Examples/test-suite/abstract_inherit.i | 62 + Examples/test-suite/abstract_inherit_ok.i | 22 + Examples/test-suite/abstract_signature.i | 26 + Examples/test-suite/abstract_typedef.i | 56 + Examples/test-suite/abstract_typedef2.i | 60 + Examples/test-suite/abstract_virtual.i | 67 + Examples/test-suite/access_change.i | 51 + Examples/test-suite/add_link.i | 20 + Examples/test-suite/aggregate.i | 37 + Examples/test-suite/allegrocl/Makefile.in | 126 + Examples/test-suite/allowexcept.i | 73 + Examples/test-suite/allprotected.i | 78 + Examples/test-suite/anonymous_bitfield.i | 17 + Examples/test-suite/apply_signed_char.i | 37 + Examples/test-suite/apply_strings.i | 78 + Examples/test-suite/argcargvtest.i | 23 + Examples/test-suite/argout.i | 37 + Examples/test-suite/array_member.i | 74 + Examples/test-suite/array_typedef_memberin.i | 12 + Examples/test-suite/arrayref.i | 14 + Examples/test-suite/arrays.i | 72 + Examples/test-suite/arrays_dimensionless.i | 69 + Examples/test-suite/arrays_global.i | 95 + Examples/test-suite/arrays_global_twodim.i | 61 + Examples/test-suite/arrays_scope.i | 19 + Examples/test-suite/bloody_hell.i | 18 + Examples/test-suite/bools.i | 64 + Examples/test-suite/callback.i | 72 + Examples/test-suite/cast_operator.i | 20 + Examples/test-suite/casts.i | 21 + Examples/test-suite/catches.i | 33 + Examples/test-suite/cffi/Makefile.in | 51 + Examples/test-suite/char_constant.i | 20 + Examples/test-suite/char_strings.i | 177 + Examples/test-suite/chicken/Makefile.in | 99 + Examples/test-suite/chicken/README | 11 + Examples/test-suite/chicken/casts_runme.ss | 2 + Examples/test-suite/chicken/char_constant_runme.ss | 2 + .../test-suite/chicken/chicken_ext_test_runme.ss | 5 + Examples/test-suite/chicken/class_ignore_runme.ss | 2 + .../chicken/clientdata_prop_runme_proxy.ss | 95 + Examples/test-suite/chicken/constover_runme.ss | 2 + Examples/test-suite/chicken/contract_runme.ss | 3 + .../test-suite/chicken/cpp_basic_runme_proxy.ss | 64 + Examples/test-suite/chicken/cpp_enum_runme.ss | 2 + Examples/test-suite/chicken/cpp_namespace_runme.ss | 2 + Examples/test-suite/chicken/dynamic_cast_runme.ss | 2 + Examples/test-suite/chicken/ext_test_external.cxx | 22 + Examples/test-suite/chicken/global_vars_runme.ss | 2 + .../test-suite/chicken/global_vars_runme_proxy.ss | 2 + .../test-suite/chicken/import_nomodule_runme.ss | 2 + Examples/test-suite/chicken/imports_runme.ss | 3 + .../test-suite/chicken/inherit_missing_runme.ss | 2 + Examples/test-suite/chicken/li_std_string_runme.ss | 2 + .../chicken/li_std_string_runme_proxy.ss | 47 + Examples/test-suite/chicken/li_typemaps_runme.ss | 12 + .../test-suite/chicken/li_typemaps_runme_proxy.ss | 13 + Examples/test-suite/chicken/list_vector_runme.ss | 2 + .../test-suite/chicken/member_pointer_runme.ss | 28 + .../chicken/multiple_inheritance_runme_proxy.ss | 2 + Examples/test-suite/chicken/multivalue_runme.ss | 4 + Examples/test-suite/chicken/name_runme.ss | 2 + .../test-suite/chicken/newobject1_runme_proxy.ss | 30 + Examples/test-suite/chicken/newobject2_runme.ss | 29 + .../test-suite/chicken/newobject2_runme_proxy.ss | 29 + .../chicken/overload_complicated_runme.ss | 2 + Examples/test-suite/chicken/overload_copy_runme.ss | 2 + .../chicken/overload_copy_runme_proxy.ss | 6 + .../test-suite/chicken/overload_extend_runme.ss | 2 + .../chicken/overload_extend_runme_proxy.ss | 14 + .../test-suite/chicken/overload_simple_runme.ss | 2 + .../chicken/overload_simple_runme_proxy.ss | 56 + .../test-suite/chicken/overload_subtype_runme.ss | 2 + .../chicken/overload_subtype_runme_proxy.ss | 12 + .../test-suite/chicken/pointer_in_out_runme.ss | 2 + .../chicken/reference_global_vars_runme.ss | 2 + Examples/test-suite/chicken/testsuite.ss | 12 + .../test-suite/chicken/throw_exception_runme.ss | 29 + .../test-suite/chicken/typedef_inherit_runme.ss | 2 + Examples/test-suite/chicken/typename_runme.ss | 2 + Examples/test-suite/chicken/unions_runme.ss | 2 + Examples/test-suite/chicken/unions_runme_proxy.ss | 2 + Examples/test-suite/chicken_ext_test.i | 21 + Examples/test-suite/class_ignore.i | 47 + Examples/test-suite/class_scope_weird.i | 50 + Examples/test-suite/clientdata_prop.list | 2 + Examples/test-suite/clientdata_prop_a.h | 12 + Examples/test-suite/clientdata_prop_a.i | 12 + Examples/test-suite/clientdata_prop_b.h | 38 + Examples/test-suite/clientdata_prop_b.i | 20 + Examples/test-suite/clisp/Makefile.in | 51 + Examples/test-suite/common.mk | 561 + Examples/test-suite/compactdefaultargs.i | 38 + Examples/test-suite/complextest.i | 61 + Examples/test-suite/const_const.i | 13 + Examples/test-suite/const_const_2.i | 21 + Examples/test-suite/constant_pointers.i | 155 + Examples/test-suite/constants.i | 16 + Examples/test-suite/constover.i | 38 + Examples/test-suite/constructor_copy.i | 158 + Examples/test-suite/constructor_exception.i | 27 + Examples/test-suite/constructor_explicit.i | 19 + Examples/test-suite/constructor_ignore.i | 36 + Examples/test-suite/constructor_value.i | 15 + Examples/test-suite/contract.i | 233 + Examples/test-suite/conversion.i | 11 + Examples/test-suite/conversion_namespace.i | 14 + Examples/test-suite/conversion_ns_template.i | 76 + Examples/test-suite/cplusplus_throw.i | 28 + Examples/test-suite/cpp_basic.i | 107 + Examples/test-suite/cpp_broken.i | 75 + Examples/test-suite/cpp_enum.i | 43 + Examples/test-suite/cpp_namespace.i | 105 + Examples/test-suite/cpp_nodefault.i | 40 + Examples/test-suite/cpp_static.i | 26 + Examples/test-suite/cpp_typedef.i | 46 + Examples/test-suite/csharp/Makefile.in | 89 + Examples/test-suite/csharp/README | 42 + Examples/test-suite/csharp/aggregate_runme.cs | 28 + Examples/test-suite/csharp/allprotected_runme.cs | 71 + Examples/test-suite/csharp/apply_strings_runme.cs | 16 + Examples/test-suite/csharp/bools_runme.cs | 29 + Examples/test-suite/csharp/catches_runme.cs | 66 + Examples/test-suite/csharp/char_strings_runme.cs | 145 + Examples/test-suite/csharp/constover_runme.cs | 34 + .../test-suite/csharp/csharp_attributes_runme.cs | 239 + .../test-suite/csharp/csharp_exceptions_runme.cs | 342 + .../test-suite/csharp/csharp_lib_arrays_runme.cs | 70 + Examples/test-suite/csharp/csharp_prepost_runme.cs | 70 + .../test-suite/csharp/csharp_typemaps_runme.cs | 113 + Examples/test-suite/csharp/default_args_runme.cs | 143 + .../test-suite/csharp/default_constructor_runme.cs | 24 + Examples/test-suite/csharp/director_basic_runme.cs | 74 + .../test-suite/csharp/director_classes_runme.cs | 180 + .../test-suite/csharp/director_classic_runme.cs | 314 + .../test-suite/csharp/director_ignore_runme.cs | 57 + .../test-suite/csharp/director_primitives_runme.cs | 127 + .../test-suite/csharp/director_protected_runme.cs | 72 + .../test-suite/csharp/director_string_runme.cs | 53 + Examples/test-suite/csharp/enum_thorough_runme.cs | 410 + .../csharp/enum_thorough_simple_runme.cs | 410 + .../csharp/enum_thorough_typesafe_runme.cs | 410 + .../test-suite/csharp/exception_order_runme.cs | 48 + Examples/test-suite/csharp/imports_runme.cs | 18 + .../csharp/inherit_target_language_runme.cs | 24 + .../csharp/intermediary_classname_runme.cs | 21 + Examples/test-suite/csharp/li_attribute_runme.cs | 78 + .../test-suite/csharp/li_boost_shared_ptr_runme.cs | 589 + Examples/test-suite/csharp/li_std_except_runme.cs | 24 + Examples/test-suite/csharp/li_std_map_runme.cs | 243 + Examples/test-suite/csharp/li_std_string_runme.cs | 100 + Examples/test-suite/csharp/li_std_vector_runme.cs | 638 + Examples/test-suite/csharp/li_std_wstring_runme.cs | 76 + Examples/test-suite/csharp/li_typemaps_runme.cs | 101 + Examples/test-suite/csharp/long_long_runme.cs | 41 + Examples/test-suite/csharp/member_pointer_runme.cs | 47 + .../test-suite/csharp/operator_overload_runme.cs | 46 + .../csharp/overload_complicated_runme.cs | 55 + .../test-suite/csharp/overload_template_runme.cs | 152 + .../test-suite/csharp/pointer_reference_runme.cs | 18 + Examples/test-suite/csharp/sizet_runme.cs | 18 + Examples/test-suite/csharp/sneaky1_runme.cs | 20 + .../csharp/special_variable_macros_runme.cs | 22 + Examples/test-suite/csharp/threads_runme.cs | 61 + .../test-suite/csharp/throw_exception_runme.cs | 24 + .../test-suite/csharp/typemap_namespace_runme.cs | 16 + .../test-suite/csharp/typemap_out_optimal_runme.cs | 13 + Examples/test-suite/csharp/varargs_runme.cs | 20 + Examples/test-suite/csharp/virtual_poly_runme.cs | 51 + Examples/test-suite/csharp_attributes.i | 48 + Examples/test-suite/csharp_exceptions.i | 241 + Examples/test-suite/csharp_features.i | 24 + Examples/test-suite/csharp_lib_arrays.i | 61 + Examples/test-suite/csharp_prepost.i | 192 + Examples/test-suite/csharp_typemaps.i | 103 + Examples/test-suite/default_args.i | 243 + Examples/test-suite/default_constructor.i | 170 + Examples/test-suite/defvalue_constructor.i | 14 + Examples/test-suite/derived_byvalue.i | 91 + Examples/test-suite/derived_nested.i | 15 + Examples/test-suite/destructor_reprotected.i | 41 + Examples/test-suite/director_abstract.i | 200 + Examples/test-suite/director_basic.i | 144 + Examples/test-suite/director_classes.i | 104 + Examples/test-suite/director_classic.i | 53 + Examples/test-suite/director_constructor.i | 37 + Examples/test-suite/director_default.i | 66 + Examples/test-suite/director_detect.i | 72 + Examples/test-suite/director_enum.i | 86 + Examples/test-suite/director_exception.i | 112 + Examples/test-suite/director_extend.i | 54 + Examples/test-suite/director_finalizer.i | 42 + Examples/test-suite/director_frob.i | 106 + Examples/test-suite/director_ignore.i | 96 + Examples/test-suite/director_namespace_clash.i | 21 + Examples/test-suite/director_nested.i | 86 + Examples/test-suite/director_overload.i | 47 + Examples/test-suite/director_primitives.i | 88 + Examples/test-suite/director_profile.i | 64 + Examples/test-suite/director_protected.i | 148 + .../test-suite/director_protected_overloaded.i | 21 + Examples/test-suite/director_redefined.i | 50 + Examples/test-suite/director_stl.i | 80 + Examples/test-suite/director_string.i | 58 + Examples/test-suite/director_thread.i | 102 + Examples/test-suite/director_unroll.i | 40 + Examples/test-suite/director_using.i | 67 + Examples/test-suite/director_wombat.i | 49 + Examples/test-suite/director_wstring.i | 60 + Examples/test-suite/disown.i | 47 + Examples/test-suite/dynamic_cast.i | 76 + Examples/test-suite/empty.i | 1 + Examples/test-suite/enum_plus.i | 12 + Examples/test-suite/enum_scope_template.i | 20 + Examples/test-suite/enum_template.i | 43 + Examples/test-suite/enum_thorough.i | 553 + Examples/test-suite/enum_thorough_proper.i | 7 + Examples/test-suite/enum_thorough_simple.i | 7 + Examples/test-suite/enum_thorough_typesafe.i | 9 + Examples/test-suite/enum_thorough_typeunsafe.i | 7 + Examples/test-suite/enum_var.i | 8 + Examples/test-suite/enums.i | 81 + Examples/test-suite/errors/c_bad_name.i | 4 + Examples/test-suite/errors/c_bad_native.i | 5 + Examples/test-suite/errors/c_class.i | 8 + Examples/test-suite/errors/c_default_error.i | 4 + Examples/test-suite/errors/c_deprecated.i | 8 + Examples/test-suite/errors/c_empty_char.i | 4 + Examples/test-suite/errors/c_enum_badvalue.i | 7 + Examples/test-suite/errors/c_extra_rblock.i | 8 + Examples/test-suite/errors/c_extra_rbrace.i | 7 + Examples/test-suite/errors/c_extra_unsigned.i | 6 + Examples/test-suite/errors/c_insert_missing.i | 3 + Examples/test-suite/errors/c_long_short.i | 6 + Examples/test-suite/errors/c_missing_rbrace.i | 10 + Examples/test-suite/errors/c_missing_semi.i | 4 + Examples/test-suite/errors/c_redefine.i | 20 + Examples/test-suite/errors/c_varargs.i | 3 + Examples/test-suite/errors/c_varargs_neg.i | 7 + Examples/test-suite/errors/cpp_bad_extern.i | 7 + Examples/test-suite/errors/cpp_extend_redefine.i | 23 + Examples/test-suite/errors/cpp_extend_undefined.i | 6 + Examples/test-suite/errors/cpp_inline_namespace.i | 7 + Examples/test-suite/errors/cpp_missing_rtemplate.i | 11 + Examples/test-suite/errors/cpp_namespace_alias.i | 14 + .../test-suite/errors/cpp_namespace_aliasnot.i | 4 + .../test-suite/errors/cpp_namespace_aliasundef.i | 3 + Examples/test-suite/errors/cpp_nested.i | 13 + Examples/test-suite/errors/cpp_no_access.i | 4 + Examples/test-suite/errors/cpp_nobase.i | 7 + Examples/test-suite/errors/cpp_overload.i | 15 + Examples/test-suite/errors/cpp_private_defvalue.i | 7 + Examples/test-suite/errors/cpp_private_inherit.i | 11 + Examples/test-suite/errors/cpp_template_argname.i | 8 + Examples/test-suite/errors/cpp_template_nargs.i | 10 + Examples/test-suite/errors/cpp_template_not.i | 9 + Examples/test-suite/errors/cpp_template_partial.i | 4 + Examples/test-suite/errors/cpp_template_repeat.i | 7 + Examples/test-suite/errors/cpp_template_undef.i | 7 + Examples/test-suite/errors/cpp_using_not.i | 9 + Examples/test-suite/errors/cpp_using_undef.i | 9 + Examples/test-suite/errors/make.sh | 103 + Examples/test-suite/errors/nomodule.i | 2 + Examples/test-suite/errors/pp_badeval.i | 11 + Examples/test-suite/errors/pp_defined.i | 7 + Examples/test-suite/errors/pp_macro_args.i | 7 + Examples/test-suite/errors/pp_macro_badchar.i | 5 + Examples/test-suite/errors/pp_macro_nargs.i | 16 + Examples/test-suite/errors/pp_macro_redef.i | 8 + Examples/test-suite/errors/pp_macro_rparen.i | 3 + Examples/test-suite/errors/pp_macro_unterminated.i | 7 + Examples/test-suite/errors/pp_misplaced_elif.i | 7 + Examples/test-suite/errors/pp_misplaced_else.i | 7 + Examples/test-suite/errors/pp_missing_enddef.i | 7 + Examples/test-suite/errors/pp_missing_endif.i | 6 + Examples/test-suite/errors/pp_missing_file.i | 3 + Examples/test-suite/errors/pp_missing_rblock.i | 7 + Examples/test-suite/errors/pp_unterm_char.i | 7 + Examples/test-suite/errors/pp_unterm_comment.i | 6 + Examples/test-suite/errors/pp_unterm_string.i | 6 + Examples/test-suite/errors/swig_apply_nargs.i | 6 + Examples/test-suite/errors/swig_identifier.i | 6 + Examples/test-suite/errors/swig_insert_bad.i | 5 + Examples/test-suite/errors/swig_typemap_copy.i | 3 + Examples/test-suite/errors/swig_typemap_old.i | 6 + Examples/test-suite/evil_diamond.i | 26 + Examples/test-suite/evil_diamond_ns.i | 27 + Examples/test-suite/evil_diamond_prop.i | 39 + Examples/test-suite/exception_order.i | 111 + Examples/test-suite/exception_partial_info.i | 51 + Examples/test-suite/extend.i | 53 + Examples/test-suite/extend_default.i | 133 + Examples/test-suite/extend_placement.i | 107 + Examples/test-suite/extend_template.i | 26 + Examples/test-suite/extend_template_ns.i | 32 + Examples/test-suite/extend_variable.i | 103 + Examples/test-suite/extern_declaration.i | 31 + Examples/test-suite/extern_namespace.i | 23 + Examples/test-suite/extern_throws.i | 18 + Examples/test-suite/features.i | 181 + Examples/test-suite/file_test.i | 21 + Examples/test-suite/fragments.i | 36 + Examples/test-suite/friends.i | 178 + Examples/test-suite/funcptr.i | 60 + Examples/test-suite/function_typedef.i | 20 + Examples/test-suite/fvirtual.i | 21 + Examples/test-suite/global_namespace.i | 60 + Examples/test-suite/global_ns_arg.i | 15 + Examples/test-suite/global_vars.i | 31 + Examples/test-suite/grouping.i | 31 + Examples/test-suite/guile/Makefile.in | 56 + Examples/test-suite/guile/README | 4 + Examples/test-suite/guile/casts_runme.scm | 5 + Examples/test-suite/guile/char_constant_runme.scm | 5 + Examples/test-suite/guile/class_ignore_runme.scm | 2 + Examples/test-suite/guile/constover_runme.scm | 2 + Examples/test-suite/guile/contract_runme.scm | 6 + Examples/test-suite/guile/cpp_enum_runme.scm | 5 + Examples/test-suite/guile/cpp_namespace_runme.scm | 2 + Examples/test-suite/guile/dynamic_cast_runme.scm | 2 + .../test-suite/guile/import_nomodule_runme.scm | 2 + Examples/test-suite/guile/imports_runme.scm | 11 + .../test-suite/guile/inherit_missing_runme.scm | 2 + Examples/test-suite/guile/integers_runme.scm | 11 + Examples/test-suite/guile/li_std_string_runme.scm | 5 + Examples/test-suite/guile/li_typemaps_runme.scm | 18 + Examples/test-suite/guile/list_vector_runme.scm | 5 + Examples/test-suite/guile/multivalue_runme.scm | 7 + Examples/test-suite/guile/name_runme.scm | 5 + .../guile/overload_complicated_runme.scm | 21 + Examples/test-suite/guile/overload_copy_runme.scm | 2 + .../test-suite/guile/overload_extend_runme.scm | 2 + .../test-suite/guile/overload_simple_runme.scm | 5 + .../test-suite/guile/overload_subtype_runme.scm | 5 + Examples/test-suite/guile/pointer_in_out_runme.scm | 5 + .../guile/reference_global_vars_runme.scm | 3 + Examples/test-suite/guile/testsuite.scm | 37 + .../test-suite/guile/throw_exception_runme.scm | 45 + .../test-suite/guile/typedef_inherit_runme.scm | 2 + Examples/test-suite/guile/typename_runme.scm | 3 + Examples/test-suite/guile/unions_runme.scm | 8 + Examples/test-suite/guilescm/Makefile.in | 49 + Examples/test-suite/guilescm/ext_test_external.cxx | 24 + .../guilescm/guilescm_ext_test_runme.scm | 19 + Examples/test-suite/guilescm_ext_test.i | 19 + Examples/test-suite/iadd.i | 58 + Examples/test-suite/ignore_parameter.i | 42 + Examples/test-suite/ignore_template_constructor.i | 45 + Examples/test-suite/immutable.i | 20 + Examples/test-suite/implicittest.i | 68 + Examples/test-suite/import_nomodule.h | 2 + Examples/test-suite/import_nomodule.i | 42 + Examples/test-suite/imports.list | 2 + Examples/test-suite/imports_a.h | 21 + Examples/test-suite/imports_a.i | 15 + Examples/test-suite/imports_b.h | 31 + Examples/test-suite/imports_b.i | 47 + Examples/test-suite/inctest.h | 2 + Examples/test-suite/inctest.i | 35 + Examples/test-suite/inherit.i | 19 + Examples/test-suite/inherit_missing.i | 51 + Examples/test-suite/inherit_same_name.i | 16 + Examples/test-suite/inherit_target_language.i | 73 + Examples/test-suite/inherit_void_arg.i | 18 + Examples/test-suite/inline_initializer.i | 12 + Examples/test-suite/inout.i | 48 + Examples/test-suite/inplaceadd.i | 40 + Examples/test-suite/input.i | 41 + Examples/test-suite/insert_directive.i | 38 + Examples/test-suite/integers.i | 20 + Examples/test-suite/intermediary_classname.i | 82 + Examples/test-suite/java/Makefile.in | 90 + Examples/test-suite/java/README | 6 + Examples/test-suite/java/aggregate_runme.java | 39 + Examples/test-suite/java/allprotected_runme.java | 74 + .../test-suite/java/apply_signed_char_runme.java | 36 + Examples/test-suite/java/apply_strings_runme.java | 24 + Examples/test-suite/java/array_member_runme.java | 35 + .../java/arrays_global_twodim_runme.java | 33 + Examples/test-suite/java/char_strings_runme.java | 153 + Examples/test-suite/java/cpp_typedef_runme.java | 34 + Examples/test-suite/java/default_args_runme.java | 150 + .../test-suite/java/default_constructor_runme.java | 32 + .../test-suite/java/director_abstract_runme.java | 46 + Examples/test-suite/java/director_basic_runme.java | 72 + .../test-suite/java/director_classes_runme.java | 207 + .../test-suite/java/director_classic_runme.java | 318 + .../test-suite/java/director_default_runme.java | 51 + Examples/test-suite/java/director_enum_runme.java | 54 + .../test-suite/java/director_exception_runme.java | 34 + Examples/test-suite/java/director_frob_runme.java | 39 + .../test-suite/java/director_ignore_runme.java | 40 + .../test-suite/java/director_primitives_runme.java | 138 + .../test-suite/java/director_protected_runme.java | 85 + .../test-suite/java/director_string_runme.java | 56 + .../test-suite/java/director_thread_runme.java | 36 + .../test-suite/java/director_unroll_runme.java | 34 + .../test-suite/java/director_wombat_runme.java | 94 + Examples/test-suite/java/dynamic_cast_runme.java | 29 + .../java/enum_thorough_proper_runme.java | 421 + Examples/test-suite/java/enum_thorough_runme.java | 421 + .../java/enum_thorough_simple_runme.java | 421 + .../java/enum_thorough_typeunsafe_runme.java | 421 + Examples/test-suite/java/extend_default_runme.java | 226 + .../test-suite/java/extern_declaration_runme.java | 21 + .../test-suite/java/global_namespace_runme.java | 25 + .../test-suite/java/ignore_parameter_runme.java | 36 + Examples/test-suite/java/imports_runme.java | 24 + Examples/test-suite/java/inctest_runme.java | 21 + .../java/inherit_target_language_runme.java | 35 + .../java/intermediary_classname_runme.java | 24 + Examples/test-suite/java/java_constants_runme.java | 29 + Examples/test-suite/java/java_director_runme.java | 75 + Examples/test-suite/java/java_enums_runme.java | 54 + Examples/test-suite/java/java_jnitypes_runme.java | 57 + .../java/java_lib_arrays_dimensionless_runme.java | 62 + .../test-suite/java/java_lib_arrays_runme.java | 165 + .../test-suite/java/java_lib_various_runme.java | 83 + Examples/test-suite/java/java_pgcpp_runme.java | 32 + Examples/test-suite/java/java_pragmas_runme.java | 15 + Examples/test-suite/java/java_prepost_runme.java | 28 + Examples/test-suite/java/java_throws_runme.java | 123 + .../test-suite/java/java_typemaps_proxy_runme.java | 81 + .../java/java_typemaps_typewrapper_runme.java | 45 + .../java/li_boost_intrusive_ptr_runme.java | 701 + .../test-suite/java/li_boost_shared_ptr_runme.java | 603 + Examples/test-suite/java/li_carrays_runme.java | 88 + Examples/test-suite/java/li_std_except_runme.java | 29 + Examples/test-suite/java/li_std_string_runme.java | 108 + Examples/test-suite/java/li_std_vector_runme.java | 36 + Examples/test-suite/java/li_typemaps_runme.java | 125 + Examples/test-suite/java/long_long_runme.java | 83 + Examples/test-suite/java/member_pointer_runme.java | 58 + .../test-suite/java/memberin_extend_runme.java | 26 + Examples/test-suite/java/minherit2_runme.java | 32 + .../java/multiple_inheritance_runme.java | 32 + .../test-suite/java/operator_overload_runme.java | 113 + .../java/overload_complicated_runme.java | 63 + .../test-suite/java/overload_template_runme.java | 160 + .../test-suite/java/pointer_reference_runme.java | 23 + Examples/test-suite/java/primitive_ref_runme.java | 64 + Examples/test-suite/java/profiletest_runme.java | 15 + Examples/test-suite/java/rename1_runme.java | 75 + Examples/test-suite/java/rename2_runme.java | 75 + Examples/test-suite/java/rename3_runme.java | 75 + Examples/test-suite/java/rename4_runme.java | 75 + Examples/test-suite/java/ret_by_value_runme.java | 33 + Examples/test-suite/java/rname_runme.java | 38 + Examples/test-suite/java/sizet_runme.java | 24 + .../java/special_variable_macros_runme.java | 32 + .../test-suite/java/special_variables_runme.java | 53 + .../test-suite/java/template_classes_runme.java | 25 + .../java/template_default_arg_runme.java | 156 + .../java/template_default_class_parms_runme.java | 43 + .../test-suite/java/template_methods_runme.java | 44 + .../java/template_template_parameters_runme.java | 28 + .../test-suite/java/typemap_namespace_runme.java | 21 + .../test-suite/java/typemap_out_optimal_runme.java | 21 + Examples/test-suite/java/unions_runme.java | 68 + Examples/test-suite/java/using_pointers_runme.java | 32 + Examples/test-suite/java/varargs_runme.java | 35 + Examples/test-suite/java/virtual_poly_runme.java | 61 + Examples/test-suite/java/wallkw_runme.java | 25 + Examples/test-suite/java_constants.i | 35 + Examples/test-suite/java_director.i | 124 + Examples/test-suite/java_enums.i | 60 + Examples/test-suite/java_jnitypes.i | 29 + Examples/test-suite/java_lib_arrays.i | 56 + .../test-suite/java_lib_arrays_dimensionless.i | 26 + Examples/test-suite/java_lib_various.i | 51 + Examples/test-suite/java_pgcpp.i | 56 + Examples/test-suite/java_pragmas.i | 50 + Examples/test-suite/java_prepost.i | 91 + Examples/test-suite/java_throws.i | 187 + Examples/test-suite/java_typemaps_proxy.i | 129 + Examples/test-suite/java_typemaps_typewrapper.i | 65 + Examples/test-suite/keyword_rename.i | 32 + Examples/test-suite/kind.i | 34 + Examples/test-suite/langobj.i | 41 + Examples/test-suite/lextype.i | 54 + Examples/test-suite/li_attribute.i | 139 + Examples/test-suite/li_boost_intrusive_ptr.i | 494 + Examples/test-suite/li_boost_shared_ptr.i | 418 + Examples/test-suite/li_boost_shared_ptr_bits.i | 25 + Examples/test-suite/li_carrays.i | 28 + Examples/test-suite/li_cdata.i | 8 + Examples/test-suite/li_cdata_carrays.i | 8 + Examples/test-suite/li_cmalloc.i | 12 + Examples/test-suite/li_constraints.i | 35 + Examples/test-suite/li_cpointer.i | 10 + Examples/test-suite/li_cstring.i | 98 + Examples/test-suite/li_cwstring.i | 98 + Examples/test-suite/li_factory.i | 49 + Examples/test-suite/li_implicit.i | 23 + Examples/test-suite/li_math.i | 7 + Examples/test-suite/li_reference.i | 52 + Examples/test-suite/li_std_carray.i | 8 + Examples/test-suite/li_std_combinations.i | 15 + Examples/test-suite/li_std_deque.i | 47 + Examples/test-suite/li_std_except.i | 39 + Examples/test-suite/li_std_functors.i | 18 + Examples/test-suite/li_std_list.i | 46 + Examples/test-suite/li_std_map.i | 111 + Examples/test-suite/li_std_multimap.i | 25 + Examples/test-suite/li_std_pair.i | 62 + Examples/test-suite/li_std_pair_extra.i | 210 + Examples/test-suite/li_std_pair_lang_object.i | 8 + Examples/test-suite/li_std_queue.i | 16 + Examples/test-suite/li_std_set.i | 40 + Examples/test-suite/li_std_stack.i | 16 + Examples/test-suite/li_std_stream.i | 59 + Examples/test-suite/li_std_string.i | 149 + Examples/test-suite/li_std_string_extra.i | 55 + Examples/test-suite/li_std_vector.i | 117 + Examples/test-suite/li_std_vector_extra.i | 147 + Examples/test-suite/li_std_vector_ptr.i | 29 + Examples/test-suite/li_std_vectora.i | 65 + Examples/test-suite/li_std_wstream.i | 59 + Examples/test-suite/li_std_wstring.i | 89 + Examples/test-suite/li_stdint.i | 67 + Examples/test-suite/li_typemaps.i | 109 + Examples/test-suite/li_windows.i | 97 + Examples/test-suite/list_vector.i | 153 + Examples/test-suite/long_long.i | 40 + Examples/test-suite/long_long_apply.i | 77 + Examples/test-suite/lua/Makefile.in | 64 + Examples/test-suite/lua/abstract_access_runme.lua | 17 + Examples/test-suite/lua/cpp_basic_runme.lua | 64 + Examples/test-suite/lua/disown_runme.lua | 12 + Examples/test-suite/lua/dynamic_cast_runme.lua | 15 + Examples/test-suite/lua/enums_runme.lua | 20 + Examples/test-suite/lua/exception_order_runme.lua | 45 + .../lua/exception_partial_info_runme.lua | 12 + Examples/test-suite/lua/import.lua | 28 + Examples/test-suite/lua/import_nomodule_runme.lua | 14 + Examples/test-suite/lua/imports_runme.lua | 28 + Examples/test-suite/lua/li_carrays_runme.lua | 29 + Examples/test-suite/lua/li_std_except_runme.lua | 16 + Examples/test-suite/lua/li_std_pair_runme.lua | 34 + Examples/test-suite/lua/li_std_string_runme.lua | 113 + Examples/test-suite/lua/li_std_vector_runme.lua | 66 + Examples/test-suite/lua/li_typemaps_runme.lua | 40 + Examples/test-suite/lua/member_pointer_runme.lua | 43 + Examples/test-suite/lua/multi_import_runme.lua | 16 + Examples/test-suite/lua/newobject1_runme.lua | 16 + Examples/test-suite/lua/newobject2_runme.lua | 16 + .../test-suite/lua/operator_overload_runme.lua | 157 + Examples/test-suite/lua/overload_simple_runme.lua | 55 + .../lua/overload_template_fast_runme.lua | 81 + .../test-suite/lua/overload_template_runme.lua | 81 + .../test-suite/lua/pointer_reference_runme.lua | 11 + Examples/test-suite/lua/primitive_ref_runme.lua | 32 + Examples/test-suite/lua/ret_by_value_runme.lua | 6 + Examples/test-suite/lua/sizet_runme.lua | 9 + .../lua/smart_pointer_overload_runme.lua | 14 + .../test-suite/lua/template_default_arg_runme.lua | 63 + Examples/test-suite/lua/voidtest_runme.lua | 37 + Examples/test-suite/member_pointer.i | 101 + Examples/test-suite/member_template.i | 28 + Examples/test-suite/memberin1.i | 63 + Examples/test-suite/memberin_extend.i | 22 + Examples/test-suite/minherit.i | 77 + Examples/test-suite/minherit2.i | 94 + Examples/test-suite/mixed_types.i | 164 + Examples/test-suite/mod.h | 34 + Examples/test-suite/mod.list | 2 + Examples/test-suite/mod_a.i | 24 + Examples/test-suite/mod_b.i | 22 + Examples/test-suite/multi_import.h | 17 + Examples/test-suite/multi_import.list | 2 + Examples/test-suite/multi_import_a.i | 15 + Examples/test-suite/multi_import_b.i | 13 + Examples/test-suite/multi_import_c.i | 5 + Examples/test-suite/multiple_inheritance.i | 92 + Examples/test-suite/multivalue.i | 52 + Examples/test-suite/mzscheme/Makefile.in | 48 + Examples/test-suite/mzscheme/README | 4 + Examples/test-suite/mzscheme/casts_runme.scm | 7 + .../test-suite/mzscheme/char_constant_runme.scm | 6 + Examples/test-suite/mzscheme/imports_runme.scm | 16 + Examples/test-suite/mzscheme/integers_runme.scm | 9 + Examples/test-suite/mzscheme/name_runme.scm | 10 + Examples/test-suite/mzscheme/unions_runme.scm | 38 + Examples/test-suite/name.i | 28 + Examples/test-suite/name_cxx.i | 31 + Examples/test-suite/name_warnings.i | 71 + Examples/test-suite/namespace_class.i | 302 + Examples/test-suite/namespace_enum.i | 24 + Examples/test-suite/namespace_extend.i | 34 + Examples/test-suite/namespace_nested.i | 101 + Examples/test-suite/namespace_spaces.i | 26 + Examples/test-suite/namespace_template.i | 84 + Examples/test-suite/namespace_typedef_class.i | 18 + Examples/test-suite/namespace_typemap.i | 258 + Examples/test-suite/namespace_union.i | 28 + Examples/test-suite/namespace_virtual_method.i | 41 + Examples/test-suite/naturalvar.i | 40 + Examples/test-suite/nested.i | 33 + Examples/test-suite/nested_comment.i | 34 + Examples/test-suite/nested_structs.i | 22 + Examples/test-suite/newobject1.i | 51 + Examples/test-suite/newobject2.i | 47 + Examples/test-suite/null_pointer.i | 10 + Examples/test-suite/ocaml/Makefile.in | 83 + Examples/test-suite/ocaml/README | 2 + Examples/test-suite/ocaml/class_ignore_runme.ml | 7 + Examples/test-suite/ocaml/imports_runme.ml | 10 + Examples/test-suite/ocaml/makedebugtop | 21 + Examples/test-suite/ocaml/minherit_runme.ml | 131 + Examples/test-suite/ocaml/name_runme.ml | 9 + Examples/test-suite/ocaml/newobject1_runme.ml | 26 + Examples/test-suite/ocaml/overload_copy_runme.ml | 5 + Examples/test-suite/ocaml/sneaky1_runme.ml | 9 + Examples/test-suite/ocaml/throw_exception_runme.ml | 28 + Examples/test-suite/ocaml/typedef_mptr_runme.ml | 16 + Examples/test-suite/ocaml/typename_runme.ml | 12 + Examples/test-suite/ocaml/unions_runme.ml | 28 + Examples/test-suite/ocaml/using_protected_runme.ml | 8 + Examples/test-suite/ocaml/varargs_runme.ml | 11 + Examples/test-suite/ocaml/voidtest_runme.ml | 8 + Examples/test-suite/octave/Makefile.in | 90 + Examples/test-suite/octave/abstract_access_runme.m | 7 + .../test-suite/octave/abstract_typedef2_runme.m | 8 + .../test-suite/octave/abstract_typedef_runme.m | 12 + .../test-suite/octave/abstract_virtual_runme.m | 7 + Examples/test-suite/octave/argcargvtest_runme.m | 29 + Examples/test-suite/octave/array_member_runme.m | 25 + Examples/test-suite/octave/arrays_global_runme.m | 19 + Examples/test-suite/octave/callback_runme.m | 40 + Examples/test-suite/octave/class_ignore_runme.m | 7 + .../test-suite/octave/class_scope_weird_runme.m | 7 + .../test-suite/octave/compactdefaultargs_runme.m | 24 + Examples/test-suite/octave/complextest_runme.m | 19 + Examples/test-suite/octave/constover_runme.m | 34 + .../test-suite/octave/constructor_copy_runme.m | 44 + Examples/test-suite/octave/contract_runme.m | 135 + Examples/test-suite/octave/cpp_enum_runme.m | 27 + Examples/test-suite/octave/cpp_namespace_runme.m | 55 + Examples/test-suite/octave/default_args_runme.m | 86 + .../test-suite/octave/default_constructor_runme.m | 111 + .../test-suite/octave/director_abstract_runme.m | 44 + Examples/test-suite/octave/director_basic_runme.m | 110 + .../test-suite/octave/director_classic_runme.m | 98 + .../test-suite/octave/director_default_runme.m | 10 + Examples/test-suite/octave/director_detect_runme.m | 36 + Examples/test-suite/octave/director_enum_runme.m | 10 + Examples/test-suite/octave/director_extend_runme.m | 12 + Examples/test-suite/octave/director_frob_runme.m | 9 + Examples/test-suite/octave/director_nested_runme.m | 39 + Examples/test-suite/octave/director_stl_runme.m | 31 + Examples/test-suite/octave/director_string_runme.m | 27 + Examples/test-suite/octave/director_unroll_runme.m | 16 + .../test-suite/octave/director_wstring_runme.m | 21 + Examples/test-suite/octave/dynamic_cast_runme.m | 14 + Examples/test-suite/octave/empty_runme.m | 2 + Examples/test-suite/octave/enum_template_runme.m | 13 + Examples/test-suite/octave/enums_runme.m | 7 + Examples/test-suite/octave/exception_order_runme.m | 44 + .../test-suite/octave/extend_placement_runme.m | 46 + .../test-suite/octave/extend_template_ns_runme.m | 10 + Examples/test-suite/octave/extend_template_runme.m | 10 + Examples/test-suite/octave/extend_variable_runme.m | 6 + Examples/test-suite/octave/file_test_runme.m | 9 + Examples/test-suite/octave/friends_runme.m | 46 + Examples/test-suite/octave/fvirtual_runme.m | 10 + Examples/test-suite/octave/global_ns_arg_runme.m | 5 + Examples/test-suite/octave/grouping_runme.m | 15 + Examples/test-suite/octave/iadd_runme.m | 10 + Examples/test-suite/octave/import_nomodule_runme.m | 8 + Examples/test-suite/octave/imports_runme.m | 19 + Examples/test-suite/octave/inctest_runme.m | 24 + Examples/test-suite/octave/inherit_missing_runme.m | 22 + Examples/test-suite/octave/inout_runme.m | 27 + Examples/test-suite/octave/inplaceadd_runme.m | 24 + Examples/test-suite/octave/input_runme.m | 22 + Examples/test-suite/octave/li_attribute_runme.m | 85 + .../test-suite/octave/li_boost_shared_ptr_runme.m | 478 + Examples/test-suite/octave/li_carrays_runme.m | 10 + Examples/test-suite/octave/li_cmalloc_runme.m | 17 + Examples/test-suite/octave/li_cpointer_runme.m | 12 + Examples/test-suite/octave/li_cstring_runme.m | 39 + Examples/test-suite/octave/li_cwstring_runme.m | 38 + Examples/test-suite/octave/li_factory_runme.m | 13 + Examples/test-suite/octave/li_implicit_runme.m | 20 + Examples/test-suite/octave/li_std_carray_runme.m | 52 + Examples/test-suite/octave/li_std_map_runme.m | 61 + .../test-suite/octave/li_std_pair_extra_runme.m | 69 + Examples/test-suite/octave/li_std_set_runme.m | 96 + Examples/test-suite/octave/li_std_stream_runme.m | 13 + .../test-suite/octave/li_std_string_extra_runme.m | 162 + Examples/test-suite/octave/li_std_vector_runme.m | 11 + Examples/test-suite/octave/li_std_wstream_runme.m | 14 + Examples/test-suite/octave/li_std_wstring_runme.m | 90 + Examples/test-suite/octave/member_pointer_runme.m | 45 + Examples/test-suite/octave/minherit_runme.m | 86 + Examples/test-suite/octave/mod_runme.m | 7 + Examples/test-suite/octave/multi_import_runme.m | 24 + Examples/test-suite/octave/namespace_class_runme.m | 39 + .../test-suite/octave/namespace_typemap_runme.m | 106 + .../octave/namespace_virtual_method_runme.m | 4 + Examples/test-suite/octave/naturalvar_runme.m | 14 + Examples/test-suite/octave/nondynamic_runme.m | 36 + Examples/test-suite/octave/null_pointer_runme.m | 3 + .../test-suite/octave/octave_cell_deref_runme.m | 8 + .../test-suite/octave/overload_complicated_runme.m | 58 + Examples/test-suite/octave/overload_copy_runme.m | 3 + Examples/test-suite/octave/overload_extend_runme.m | 19 + .../test-suite/octave/overload_extendc_runme.m | 30 + Examples/test-suite/octave/overload_rename_runme.m | 8 + .../test-suite/octave/overload_simple_cast_runme.m | 229 + Examples/test-suite/octave/overload_simple_runme.m | 125 + .../test-suite/octave/overload_subtype_runme.m | 13 + .../octave/overload_template_fast_runme.m | 188 + .../test-suite/octave/overload_template_runme.m | 184 + Examples/test-suite/octave/preproc_runme.m | 18 + Examples/test-suite/octave/primitive_ref_runme.m | 53 + Examples/test-suite/octave/primitive_types_runme.m | 402 + Examples/test-suite/octave/profiletest_runme.m | 32 + Examples/test-suite/octave/refcount_runme.m | 15 + .../octave/reference_global_vars_runme.m | 91 + Examples/test-suite/octave/rename_scope_runme.m | 15 + Examples/test-suite/octave/ret_by_value_runme.m | 10 + .../test-suite/octave/return_const_value_runme.m | 11 + .../test-suite/octave/smart_pointer_extend_runme.m | 41 + .../test-suite/octave/smart_pointer_member_runme.m | 39 + .../test-suite/octave/smart_pointer_multi_runme.m | 17 + .../octave/smart_pointer_multi_typedef_runme.m | 18 + .../test-suite/octave/smart_pointer_not_runme.m | 42 + .../octave/smart_pointer_overload_runme.m | 27 + .../test-suite/octave/smart_pointer_rename_runme.m | 17 + .../test-suite/octave/smart_pointer_simple_runme.m | 15 + .../octave/smart_pointer_templatevariables_runme.m | 19 + .../octave/smart_pointer_typedef_runme.m | 15 + Examples/test-suite/octave/sneaky1_runme.m | 5 + .../octave/static_const_member_2_runme.m | 18 + Examples/test-suite/octave/std_containers_runme.m | 135 + Examples/test-suite/octave/struct_rename_runme.m | 4 + Examples/test-suite/octave/struct_value_runme.m | 13 + Examples/test-suite/octave/swigobject_runme.m | 28 + .../test-suite/octave/template_construct_runme.m | 1 + .../test-suite/octave/template_default_arg_runme.m | 117 + .../test-suite/octave/template_extend1_runme.m | 12 + .../test-suite/octave/template_extend2_runme.m | 12 + .../test-suite/octave/template_inherit_runme.m | 68 + Examples/test-suite/octave/template_matrix_runme.m | 6 + Examples/test-suite/octave/template_ns4_runme.m | 6 + Examples/test-suite/octave/template_ns_runme.m | 21 + Examples/test-suite/octave/template_opaque_runme.m | 7 + .../test-suite/octave/template_ref_type_runme.m | 5 + Examples/test-suite/octave/template_rename_runme.m | 12 + Examples/test-suite/octave/template_static_runme.m | 3 + .../octave/template_tbase_template_runme.m | 6 + .../octave/template_type_namespace_runme.m | 5 + .../octave/template_typedef_cplx2_runme.m | 103 + .../octave/template_typedef_cplx3_runme.m | 34 + .../octave/template_typedef_cplx4_runme.m | 33 + .../octave/template_typedef_cplx_runme.m | 92 + .../octave/template_typedef_import_runme.m | 34 + .../test-suite/octave/template_typedef_runme.m | 51 + Examples/test-suite/octave/typedef_class_runme.m | 7 + Examples/test-suite/octave/typedef_inherit_runme.m | 27 + Examples/test-suite/octave/typedef_scope_runme.m | 14 + .../test-suite/octave/typemap_namespace_runme.m | 10 + .../test-suite/octave/typemap_ns_using_runme.m | 5 + Examples/test-suite/octave/typename_runme.m | 13 + Examples/test-suite/octave/types_directive_runme.m | 15 + Examples/test-suite/octave/unions_runme.m | 49 + Examples/test-suite/octave/using1_runme.m | 5 + Examples/test-suite/octave/using2_runme.m | 5 + .../test-suite/octave/using_composition_runme.m | 43 + Examples/test-suite/octave/using_extend_runme.m | 27 + Examples/test-suite/octave/using_inherit_runme.m | 61 + Examples/test-suite/octave/using_private_runme.m | 16 + Examples/test-suite/octave/using_protected_runme.m | 8 + Examples/test-suite/octave/varargs_runme.m | 23 + .../test-suite/octave/virtual_derivation_runme.m | 9 + Examples/test-suite/octave/virtual_poly_runme.m | 44 + Examples/test-suite/octave/voidtest_runme.m | 38 + Examples/test-suite/octave/wrapmacro_runme.m | 8 + Examples/test-suite/octave_cell_deref.i | 15 + Examples/test-suite/operator_overload.i | 358 + Examples/test-suite/operator_overload_break.i | 63 + Examples/test-suite/operbool.i | 12 + Examples/test-suite/ordering.i | 30 + Examples/test-suite/overload_complicated.i | 72 + Examples/test-suite/overload_copy.i | 16 + Examples/test-suite/overload_extend.i | 65 + Examples/test-suite/overload_extendc.i | 21 + Examples/test-suite/overload_rename.i | 28 + Examples/test-suite/overload_simple.i | 205 + Examples/test-suite/overload_subtype.i | 17 + Examples/test-suite/overload_template.i | 210 + Examples/test-suite/overload_template_fast.i | 5 + Examples/test-suite/packageoption.h | 6 + Examples/test-suite/packageoption.list | 3 + Examples/test-suite/packageoption_a.i | 16 + Examples/test-suite/packageoption_b.i | 10 + Examples/test-suite/packageoption_c.i | 13 + Examples/test-suite/perl5/Makefile.in | 61 + Examples/test-suite/perl5/README | 32 + Examples/test-suite/perl5/Test/Builder.pm | 1591 + Examples/test-suite/perl5/Test/More.pm | 1448 + Examples/test-suite/perl5/aggregate_runme.pl | 22 + .../test-suite/perl5/apply_signed_char_runme.pl | 26 + Examples/test-suite/perl5/apply_strings_runme.pl | 11 + Examples/test-suite/perl5/array_member_runme.pl | 28 + Examples/test-suite/perl5/char_strings_runme.pl | 15 + Examples/test-suite/perl5/class_ignore_runme.pl | 12 + Examples/test-suite/perl5/contract_runme.pl | 78 + Examples/test-suite/perl5/default_args_runme.pl | 85 + .../test-suite/perl5/default_constructor_runme.pl | 51 + Examples/test-suite/perl5/disown_runme.pl | 10 + Examples/test-suite/perl5/dynamic_cast_runme.pl | 13 + Examples/test-suite/perl5/enum_template_runme.pl | 12 + Examples/test-suite/perl5/enum_thorough_runme.pl | 409 + Examples/test-suite/perl5/exception_order_runme.pl | 25 + Examples/test-suite/perl5/global_vars_runme.pl | 11 + Examples/test-suite/perl5/grouping_runme.pl | 17 + .../test-suite/perl5/ignore_parameter_runme.pl | 33 + Examples/test-suite/perl5/import_nomodule_runme.pl | 13 + Examples/test-suite/perl5/imports_runme.pl | 5 + Examples/test-suite/perl5/inctest_runme.pl | 12 + Examples/test-suite/perl5/inherit_missing_runme.pl | 20 + Examples/test-suite/perl5/inherit_runme.pl | 9 + Examples/test-suite/perl5/li_carrays_runme.pl | 72 + .../test-suite/perl5/li_cdata_carrays_runme.pl | 14 + Examples/test-suite/perl5/li_reference_runme.pl | 36 + Examples/test-suite/perl5/li_std_except_runme.pl | 46 + Examples/test-suite/perl5/li_std_string_runme.pl | 113 + Examples/test-suite/perl5/li_typemaps_runme.pl | 82 + Examples/test-suite/perl5/member_pointer_runme.pl | 51 + Examples/test-suite/perl5/minherit_runme.pl | 72 + .../test-suite/perl5/multiple_inheritance_runme.pl | 12 + Examples/test-suite/perl5/naturalvar_runme.pl | 22 + .../perl5/operator_overload_break_runme.pl | 55 + .../test-suite/perl5/operator_overload_runme.pl | 175 + Examples/test-suite/perl5/overload_copy_runme.pl | 5 + Examples/test-suite/perl5/overload_simple_runme.pl | 191 + Examples/test-suite/perl5/packageoption_runme.pl | 24 + Examples/test-suite/perl5/preproc_runme.pl | 14 + Examples/test-suite/perl5/primitive_ref_runme.pl | 18 + Examples/test-suite/perl5/primitive_types_runme.pl | 282 + Examples/test-suite/perl5/profiletest_runme.pl | 8 + .../perl5/reference_global_vars_runme.pl | 80 + Examples/test-suite/perl5/rename_scope_runme.pl | 15 + Examples/test-suite/perl5/ret_by_value_runme.pl | 12 + .../test-suite/perl5/return_const_value_runme.pl | 13 + Examples/test-suite/perl5/run-perl-test.pl | 15 + Examples/test-suite/perl5/sizet_runme.pl | 18 + Examples/test-suite/perl5/sneaky1_runme.pl | 13 + .../test-suite/perl5/template_default_arg_runme.pl | 111 + .../test-suite/perl5/template_ref_type_runme.pl | 6 + .../perl5/template_typedef_cplx2_runme.pl | 53 + .../perl5/template_typedef_cplx3_runme.pl | 41 + .../perl5/template_typedef_cplx_runme.pl | 49 + Examples/test-suite/perl5/typedef_class_runme.pl | 16 + .../test-suite/perl5/typemap_namespace_runme.pl | 9 + Examples/test-suite/perl5/typename_runme.pl | 17 + Examples/test-suite/perl5/unions_runme.pl | 42 + Examples/test-suite/perl5/using1_runme.pl | 10 + Examples/test-suite/perl5/using2_runme.pl | 10 + Examples/test-suite/perl5/varargs_runme.pl | 18 + Examples/test-suite/perl5/virtual_poly_runme.pl | 36 + Examples/test-suite/perl5/voidtest_runme.pl | 20 + Examples/test-suite/perl5/wrapmacro_runme.pl | 14 + Examples/test-suite/php/Makefile.in | 61 + .../test-suite/php/abstract_inherit_ok_runme.php | 12 + Examples/test-suite/php/abstract_inherit_runme.php | 14 + Examples/test-suite/php/add_link_runme.php | 22 + Examples/test-suite/php/argout_runme.php | 37 + Examples/test-suite/php/arrayptr_runme.php | 14 + Examples/test-suite/php/arrays_global_runme.php | 19 + .../test-suite/php/arrays_global_twodim_runme.php | 22 + Examples/test-suite/php/arrays_runme.php | 18 + Examples/test-suite/php/arrays_scope_runme.php | 16 + Examples/test-suite/php/casts_runme.php | 18 + Examples/test-suite/php/char_strings_runme.php | 43 + Examples/test-suite/php/class_ignore_runme.php | 16 + .../test-suite/php/conversion_namespace_runme.php | 13 + .../php/conversion_ns_template_runme.php | 10 + Examples/test-suite/php/conversion_runme.php | 13 + Examples/test-suite/php/cpp_static_runme.php | 14 + .../test-suite/php/director_abstract_runme.php | 62 + Examples/test-suite/php/director_basic_runme.php | 58 + Examples/test-suite/php/director_classic_runme.php | 150 + Examples/test-suite/php/director_default_runme.php | 20 + Examples/test-suite/php/director_detect_runme.php | 55 + Examples/test-suite/php/director_enum_runme.php | 25 + .../test-suite/php/director_exception_runme.php | 78 + Examples/test-suite/php/director_extend_runme.php | 24 + .../test-suite/php/director_finalizer_runme.php | 61 + Examples/test-suite/php/director_frob_runme.php | 19 + Examples/test-suite/php/director_nested_runme.php | 74 + Examples/test-suite/php/director_profile_runme.php | 53 + .../test-suite/php/director_protected_runme.php | 54 + Examples/test-suite/php/director_stl_runme.php | 60 + Examples/test-suite/php/director_string_runme.php | 34 + Examples/test-suite/php/director_thread_runme.php | 29 + Examples/test-suite/php/director_unroll_runme.php | 29 + .../test-suite/php/enum_scope_template_runme.php | 15 + Examples/test-suite/php/evil_diamond_ns_runme.php | 18 + .../test-suite/php/evil_diamond_prop_runme.php | 38 + Examples/test-suite/php/evil_diamond_runme.php | 16 + .../test-suite/php/extend_template_ns_runme.php | 12 + Examples/test-suite/php/extend_template_runme.php | 12 + Examples/test-suite/php/grouping_runme.php | 22 + Examples/test-suite/php/ignore_parameter_runme.php | 38 + Examples/test-suite/php/import_nomodule_runme.php | 20 + Examples/test-suite/php/li_carrays_runme.php | 22 + Examples/test-suite/php/li_factory_runme.php | 22 + Examples/test-suite/php/li_std_string_runme.php | 31 + Examples/test-suite/php/newobject1_runme.php | 19 + Examples/test-suite/php/overload_rename_runme.php | 19 + .../test-suite/php/pointer_reference_runme.php | 15 + Examples/test-suite/php/prefix_runme.php | 18 + Examples/test-suite/php/primitive_ref_runme.php | 25 + Examples/test-suite/php/rename_scope_runme.php | 16 + Examples/test-suite/php/skel.php | 15 + .../test-suite/php/smart_pointer_rename_runme.php | 27 + Examples/test-suite/php/sym_runme.php | 22 + .../test-suite/php/template_arg_typename_runme.php | 18 + .../test-suite/php/template_construct_runme.php | 11 + Examples/test-suite/php/tests.php | 232 + .../test-suite/php/typedef_reference_runme.php | 13 + Examples/test-suite/php/typemap_ns_using_runme.php | 9 + Examples/test-suite/php/using1_runme.php | 9 + Examples/test-suite/php/using2_runme.php | 9 + .../test-suite/php/valuewrapper_base_runme.php | 13 + Examples/test-suite/php_namewarn_rename.i | 23 + Examples/test-suite/pike/Makefile.in | 49 + Examples/test-suite/pointer_in_out.i | 35 + Examples/test-suite/pointer_reference.i | 44 + Examples/test-suite/prefix.i | 14 + Examples/test-suite/preproc.i | 344 + Examples/test-suite/primitive_ref.i | 47 + Examples/test-suite/primitive_types.i | 617 + Examples/test-suite/private_assign.i | 71 + Examples/test-suite/profiletest.i | 65 + Examples/test-suite/protected_rename.i | 19 + Examples/test-suite/pure_virtual.i | 82 + Examples/test-suite/python/Makefile.in | 171 + Examples/test-suite/python/README | 8 + .../test-suite/python/abstract_access_runme.py | 6 + .../test-suite/python/abstract_typedef2_runme.py | 8 + .../test-suite/python/abstract_typedef_runme.py | 11 + .../test-suite/python/abstract_virtual_runme.py | 6 + Examples/test-suite/python/argcargvtest_runme.py | 27 + Examples/test-suite/python/array_member_runme.py | 21 + Examples/test-suite/python/arrays_global_runme.py | 20 + Examples/test-suite/python/callback_runme.py | 31 + Examples/test-suite/python/class_ignore_runme.py | 6 + .../test-suite/python/class_scope_weird_runme.py | 6 + .../test-suite/python/compactdefaultargs_runme.py | 20 + Examples/test-suite/python/complextest_runme.py | 17 + Examples/test-suite/python/constover_runme.py | 38 + .../test-suite/python/constructor_copy_runme.py | 38 + Examples/test-suite/python/contract_runme.py | 143 + Examples/test-suite/python/cpp_enum_runme.py | 23 + Examples/test-suite/python/cpp_namespace_runme.py | 45 + Examples/test-suite/python/cpp_static_runme.py | 7 + Examples/test-suite/python/default_args_runme.py | 64 + .../test-suite/python/default_constructor_runme.py | 111 + .../test-suite/python/director_abstract_runme.py | 68 + Examples/test-suite/python/director_basic_runme.py | 98 + .../test-suite/python/director_classic_runme.py | 142 + .../test-suite/python/director_default_runme.py | 9 + .../test-suite/python/director_detect_runme.py | 36 + Examples/test-suite/python/director_enum_runme.py | 12 + .../test-suite/python/director_exception_runme.py | 77 + .../test-suite/python/director_extend_runme.py | 20 + .../test-suite/python/director_finalizer_runme.py | 48 + Examples/test-suite/python/director_frob_runme.py | 7 + .../test-suite/python/director_nested_runme.py | 63 + .../test-suite/python/director_profile_runme.py | 41 + .../test-suite/python/director_protected_runme.py | 88 + Examples/test-suite/python/director_stl_runme.py | 39 + .../test-suite/python/director_string_runme.py | 29 + .../test-suite/python/director_thread_runme.py | 18 + .../test-suite/python/director_unroll_runme.py | 19 + .../test-suite/python/director_wstring_runme.py | 28 + Examples/test-suite/python/disown_runme.py | 25 + Examples/test-suite/python/dynamic_cast_runme.py | 12 + Examples/test-suite/python/empty_runme.py | 1 + Examples/test-suite/python/enum_template_runme.py | 7 + Examples/test-suite/python/enums_runme.py | 7 + .../test-suite/python/exception_order_runme.py | 41 + .../test-suite/python/extend_placement_runme.py | 46 + .../test-suite/python/extend_template_ns_runme.py | 7 + .../test-suite/python/extend_template_runme.py | 8 + .../test-suite/python/extend_variable_runme.py | 4 + Examples/test-suite/python/file_test_runme.py | 10 + Examples/test-suite/python/friends_runme.py | 28 + Examples/test-suite/python/fvirtual_runme.py | 9 + Examples/test-suite/python/global_ns_arg_runme.py | 5 + Examples/test-suite/python/grouping_runme.py | 13 + Examples/test-suite/python/hugemod.pl | 55 + Examples/test-suite/python/iadd_runme.py | 9 + .../test-suite/python/import_nomodule_runme.py | 8 + Examples/test-suite/python/imports_runme.py | 17 + Examples/test-suite/python/inctest_runme.py | 32 + .../test-suite/python/inherit_missing_runme.py | 19 + Examples/test-suite/python/inout_runme.py | 22 + Examples/test-suite/python/inplaceadd_runme.py | 20 + Examples/test-suite/python/input_runme.py | 20 + Examples/test-suite/python/keyword_rename_runme.py | 4 + Examples/test-suite/python/langobj_runme.py | 13 + Examples/test-suite/python/li_attribute_runme.py | 74 + .../python/li_boost_shared_ptr_bits_runme.py | 20 + .../test-suite/python/li_boost_shared_ptr_runme.py | 544 + Examples/test-suite/python/li_carrays_runme.py | 9 + Examples/test-suite/python/li_cmalloc_runme.py | 14 + Examples/test-suite/python/li_cpointer_runme.py | 10 + Examples/test-suite/python/li_cstring_runme.py | 32 + Examples/test-suite/python/li_cwstring_runme.py | 29 + Examples/test-suite/python/li_factory_runme.py | 11 + Examples/test-suite/python/li_implicit_runme.py | 17 + Examples/test-suite/python/li_std_carray_runme.py | 41 + Examples/test-suite/python/li_std_map_runme.py | 58 + .../test-suite/python/li_std_pair_extra_runme.py | 59 + Examples/test-suite/python/li_std_set_runme.py | 96 + Examples/test-suite/python/li_std_stream_runme.py | 14 + .../test-suite/python/li_std_string_extra_runme.py | 132 + .../test-suite/python/li_std_vector_extra_runme.py | 156 + .../test-suite/python/li_std_vector_ptr_runme.py | 8 + Examples/test-suite/python/li_std_wstream_runme.py | 13 + Examples/test-suite/python/li_std_wstring_runme.py | 76 + Examples/test-suite/python/member_pointer_runme.py | 43 + Examples/test-suite/python/minherit_runme.py | 71 + Examples/test-suite/python/mod_runme.py | 6 + Examples/test-suite/python/multi_import_runme.py | 18 + .../test-suite/python/namespace_class_runme.py | 34 + .../test-suite/python/namespace_typemap_runme.py | 82 + .../python/namespace_virtual_method_runme.py | 3 + Examples/test-suite/python/naturalvar_runme.py | 12 + Examples/test-suite/python/operbool_runme.py | 4 + .../python/overload_complicated_runme.py | 47 + Examples/test-suite/python/overload_copy_runme.py | 3 + .../test-suite/python/overload_extend_runme.py | 14 + .../test-suite/python/overload_extendc_runme.py | 22 + .../test-suite/python/overload_rename_runme.py | 8 + .../test-suite/python/overload_simple_runme.py | 102 + .../test-suite/python/overload_subtype_runme.py | 11 + .../python/overload_template_fast_runme.py | 145 + .../test-suite/python/overload_template_runme.py | 145 + Examples/test-suite/python/preproc_runme.py | 14 + Examples/test-suite/python/primitive_ref_runme.py | 40 + .../test-suite/python/primitive_types_runme.py | 353 + Examples/test-suite/python/profiletest_runme.py | 32 + Examples/test-suite/python/profiletestc_runme.py | 54 + .../python/python_abstractbase_runme3.py | 8 + Examples/test-suite/python/python_append_runme.py | 4 + Examples/test-suite/python/python_kwargs_runme.py | 67 + .../test-suite/python/python_nondynamic_runme.py | 39 + .../python/python_overload_simple_cast_runme.py | 192 + Examples/test-suite/python/python_pybuf_runme3.py | 42 + Examples/test-suite/python/pythonswig.supp | 463 + Examples/test-suite/python/refcount_runme.py | 32 + .../python/reference_global_vars_runme.py | 74 + Examples/test-suite/python/rename_scope_runme.py | 12 + .../python/rename_strip_encoder_runme.py | 6 + Examples/test-suite/python/ret_by_value_runme.py | 8 + .../test-suite/python/return_const_value_runme.py | 12 + .../python/smart_pointer_extend_runme.py | 34 + .../python/smart_pointer_member_runme.py | 30 + .../test-suite/python/smart_pointer_multi_runme.py | 15 + .../python/smart_pointer_multi_typedef_runme.py | 15 + .../test-suite/python/smart_pointer_not_runme.py | 42 + .../python/smart_pointer_overload_runme.py | 21 + .../python/smart_pointer_rename_runme.py | 13 + .../python/smart_pointer_simple_runme.py | 13 + .../smart_pointer_templatevariables_runme.py | 17 + .../python/smart_pointer_typedef_runme.py | 13 + Examples/test-suite/python/sneaky1_runme.py | 5 + .../python/special_variable_macros_runme.py | 16 + .../python/static_const_member_2_runme.py | 16 + Examples/test-suite/python/std_containers_runme.py | 119 + Examples/test-suite/python/struct_rename_runme.py | 3 + Examples/test-suite/python/struct_value_runme.py | 9 + Examples/test-suite/python/swigobject_runme.py | 34 + .../test-suite/python/template_construct_runme.py | 1 + .../python/template_default_arg_runme.py | 98 + .../test-suite/python/template_extend1_runme.py | 10 + .../test-suite/python/template_extend2_runme.py | 10 + .../test-suite/python/template_inherit_runme.py | 53 + .../test-suite/python/template_matrix_runme.py | 6 + Examples/test-suite/python/template_ns4_runme.py | 5 + Examples/test-suite/python/template_ns_runme.py | 17 + .../test-suite/python/template_opaque_runme.py | 6 + .../test-suite/python/template_ref_type_runme.py | 5 + .../test-suite/python/template_rename_runme.py | 12 + .../test-suite/python/template_static_runme.py | 3 + .../python/template_tbase_template_runme.py | 5 + .../python/template_type_namespace_runme.py | 5 + .../python/template_typedef_cplx2_runme.py | 94 + .../python/template_typedef_cplx3_runme.py | 34 + .../python/template_typedef_cplx4_runme.py | 34 + .../python/template_typedef_cplx_runme.py | 87 + .../python/template_typedef_import_runme.py | 34 + .../test-suite/python/template_typedef_runme.py | 46 + Examples/test-suite/python/typedef_class_runme.py | 7 + .../test-suite/python/typedef_inherit_runme.py | 23 + Examples/test-suite/python/typedef_scope_runme.py | 12 + .../test-suite/python/typemap_namespace_runme.py | 8 + .../test-suite/python/typemap_ns_using_runme.py | 4 + .../test-suite/python/typemap_out_optimal_runme.py | 5 + Examples/test-suite/python/typename_runme.py | 12 + .../test-suite/python/types_directive_runme.py | 12 + Examples/test-suite/python/unions_runme.py | 51 + Examples/test-suite/python/using1_runme.py | 4 + Examples/test-suite/python/using2_runme.py | 4 + .../test-suite/python/using_composition_runme.py | 34 + Examples/test-suite/python/using_extend_runme.py | 21 + Examples/test-suite/python/using_inherit_runme.py | 49 + Examples/test-suite/python/using_private_runme.py | 13 + .../test-suite/python/using_protected_runme.py | 7 + Examples/test-suite/python/varargs_runme.py | 18 + .../test-suite/python/virtual_derivation_runme.py | 8 + Examples/test-suite/python/virtual_poly_runme.py | 38 + Examples/test-suite/python/voidtest_runme.py | 29 + Examples/test-suite/python/wrapmacro_runme.py | 7 + Examples/test-suite/python_abstractbase.i | 18 + Examples/test-suite/python_append.i | 32 + Examples/test-suite/python_autodoc.i | 95 + Examples/test-suite/python_kwargs.i | 112 + Examples/test-suite/python_nondynamic.i | 58 + Examples/test-suite/python_overload_simple_cast.i | 4 + Examples/test-suite/python_pybuf.i | 64 + Examples/test-suite/r/Makefile.in | 72 + Examples/test-suite/r/arrays_dimensionless_runme.R | 20 + Examples/test-suite/r/funcptr_runme.R | 7 + Examples/test-suite/r/ignore_parameter_runme.R | 10 + Examples/test-suite/r/integers_runme.R | 20 + Examples/test-suite/r/r_copy_struct_runme.R | 58 + Examples/test-suite/r/r_double_delete_runme.R | 9 + Examples/test-suite/r/r_legacy_runme.R | 30 + Examples/test-suite/r/simple_array_runme.R | 9 + Examples/test-suite/r/unions_runme.R | 12 + Examples/test-suite/r/unittest.R | 9 + Examples/test-suite/r_copy_struct.i | 93 + Examples/test-suite/r_double_delete.i | 14 + Examples/test-suite/r_legacy.i | 98 + Examples/test-suite/redefined.i | 107 + Examples/test-suite/refcount.h | 198 + Examples/test-suite/refcount.i | 104 + Examples/test-suite/reference_global_vars.i | 65 + Examples/test-suite/register_par.i | 6 + Examples/test-suite/rename.h | 44 + Examples/test-suite/rename1.i | 63 + Examples/test-suite/rename2.i | 65 + Examples/test-suite/rename3.i | 75 + Examples/test-suite/rename4.i | 108 + Examples/test-suite/rename_camel.i | 68 + Examples/test-suite/rename_scope.i | 68 + Examples/test-suite/rename_strip_encoder.i | 16 + Examples/test-suite/restrict_cplusplus.i | 7 + Examples/test-suite/ret_by_value.i | 19 + Examples/test-suite/return_const_value.i | 45 + Examples/test-suite/return_value_scope.i | 28 + Examples/test-suite/rname.i | 57 + Examples/test-suite/ruby/Makefile.in | 72 + Examples/test-suite/ruby/README | 4 + Examples/test-suite/ruby/abstract_access_runme.rb | 34 + .../test-suite/ruby/abstract_inherit_ok_runme.rb | 48 + Examples/test-suite/ruby/abstract_inherit_runme.rb | 61 + .../test-suite/ruby/abstract_signature_runme.rb | 62 + .../test-suite/ruby/abstract_typedef2_runme.rb | 17 + Examples/test-suite/ruby/abstract_typedef_runme.rb | 23 + Examples/test-suite/ruby/abstract_virtual_runme.rb | 16 + Examples/test-suite/ruby/access_change_runme.rb | 46 + Examples/test-suite/ruby/add_link_runme.rb | 20 + Examples/test-suite/ruby/aggregate_runme.rb | 37 + .../test-suite/ruby/anonymous_bitfield_runme.rb | 35 + .../test-suite/ruby/apply_signed_char_runme.rb | 45 + Examples/test-suite/ruby/apply_strings_runme.rb | 61 + Examples/test-suite/ruby/argout_runme.rb | 42 + Examples/test-suite/ruby/array_member_runme.rb | 36 + Examples/test-suite/ruby/arrays_global_runme.rb | 15 + Examples/test-suite/ruby/arrays_runme.rb | 25 + Examples/test-suite/ruby/bools_runme.rb | 82 + Examples/test-suite/ruby/cast_operator_runme.rb | 17 + Examples/test-suite/ruby/casts_runme.rb | 23 + Examples/test-suite/ruby/char_constant_runme.rb | 34 + Examples/test-suite/ruby/check_missing_tests.rb | 53 + Examples/test-suite/ruby/class_ignore_runme.rb | 21 + Examples/test-suite/ruby/const_const_runme.rb | 14 + Examples/test-suite/ruby/constover_runme.rb | 55 + Examples/test-suite/ruby/cpp_namespace_runme.rb | 62 + .../test-suite/ruby/default_constructor_runme.rb | 153 + .../test-suite/ruby/director_abstract_runme.rb | 42 + Examples/test-suite/ruby/director_basic_runme.rb | 36 + .../test-suite/ruby/director_constructor_runme.rb | 37 + Examples/test-suite/ruby/director_default_runme.rb | 30 + Examples/test-suite/ruby/director_detect_runme.rb | 54 + .../test-suite/ruby/director_exception_runme.rb | 70 + Examples/test-suite/ruby/director_frob_runme.rb | 17 + Examples/test-suite/ruby/director_nested_runme.rb | 54 + .../test-suite/ruby/director_protected_runme.rb | 45 + Examples/test-suite/ruby/director_string_runme.rb | 24 + Examples/test-suite/ruby/director_unroll_runme.rb | 28 + Examples/test-suite/ruby/director_wombat_runme.rb | 60 + Examples/test-suite/ruby/disown_runme.rb | 20 + Examples/test-suite/ruby/dynamic_cast_runme.rb | 24 + Examples/test-suite/ruby/enum_thorough_runme.rb | 19 + Examples/test-suite/ruby/enums_runme.rb | 34 + .../test-suite/ruby/extend_template_ns_runme.rb | 23 + Examples/test-suite/ruby/extend_template_runme.rb | 21 + Examples/test-suite/ruby/friends_runme.rb | 19 + Examples/test-suite/ruby/function_typedef_runme.rb | 11 + Examples/test-suite/ruby/grouping_runme.rb | 26 + Examples/test-suite/ruby/ignore_parameter_runme.rb | 34 + Examples/test-suite/ruby/imports_runme.rb | 20 + Examples/test-suite/ruby/inherit_missing_runme.rb | 31 + Examples/test-suite/ruby/integers_runme.rb | 21 + Examples/test-suite/ruby/li_carrays_runme.rb | 36 + Examples/test-suite/ruby/li_cstring_runme.rb | 22 + Examples/test-suite/ruby/li_factory_runme.rb | 38 + Examples/test-suite/ruby/li_math_runme.rb | 13 + Examples/test-suite/ruby/li_std_deque_runme.rb | 55 + Examples/test-suite/ruby/li_std_functors_runme.rb | 70 + Examples/test-suite/ruby/li_std_map_runme.rb | 51 + Examples/test-suite/ruby/li_std_multimap_runme.rb | 27 + .../ruby/li_std_pair_lang_object_runme.rb | 19 + Examples/test-suite/ruby/li_std_pair_runme.rb | 57 + Examples/test-suite/ruby/li_std_queue_runme.rb | 32 + Examples/test-suite/ruby/li_std_set_runme.rb | 63 + Examples/test-suite/ruby/li_std_speed2_runme.rb | 67 + Examples/test-suite/ruby/li_std_stack_runme.rb | 30 + Examples/test-suite/ruby/li_std_stream_runme.rb | 22 + Examples/test-suite/ruby/li_std_string_runme.rb | 144 + Examples/test-suite/ruby/li_std_vector_runme.rb | 122 + Examples/test-suite/ruby/member_pointer_runme.rb | 54 + Examples/test-suite/ruby/minherit_runme.rb | 89 + .../test-suite/ruby/namespace_typemap_runme.rb | 44 + Examples/test-suite/ruby/newobject1_runme.rb | 33 + Examples/test-suite/ruby/newobject2_runme.rb | 27 + Examples/test-suite/ruby/overload_copy_runme.rb | 17 + Examples/test-suite/ruby/overload_extend_runme.rb | 19 + Examples/test-suite/ruby/overload_extendc_runme.rb | 18 + Examples/test-suite/ruby/overload_simple_runme.rb | 130 + Examples/test-suite/ruby/overload_subtype_runme.rb | 26 + .../test-suite/ruby/overload_template_runme.rb | 17 + Examples/test-suite/ruby/primitive_ref_runme.rb | 38 + Examples/test-suite/ruby/primitive_types_runme.rb | 98 + Examples/test-suite/ruby/profiletest_runme.rb | 20 + Examples/test-suite/ruby/refcount_runme.rb | 21 + .../test-suite/ruby/reference_global_vars_runme.rb | 104 + Examples/test-suite/ruby/rename_scope_runme.rb | 21 + Examples/test-suite/ruby/ruby_keywords_runme.rb | 159 + .../test-suite/ruby/ruby_li_std_speed_runme.rb | 85 + Examples/test-suite/ruby/ruby_naming_runme.rb | 115 + .../ruby/ruby_track_objects_directors_runme.rb | 39 + .../test-suite/ruby/ruby_track_objects_runme.rb | 117 + .../test-suite/ruby/smart_pointer_const_runme.rb | 24 + .../test-suite/ruby/smart_pointer_multi_runme.rb | 26 + .../ruby/smart_pointer_multi_typedef_runme.rb | 25 + .../test-suite/ruby/smart_pointer_not_runme.rb | 55 + .../ruby/smart_pointer_overload_runme.rb | 27 + .../test-suite/ruby/smart_pointer_rename_runme.rb | 23 + .../test-suite/ruby/smart_pointer_simple_runme.rb | 24 + .../test-suite/ruby/smart_pointer_typedef_runme.rb | 24 + Examples/test-suite/ruby/sneaky1_runme.rb | 17 + .../test-suite/ruby/static_const_member_2_runme.rb | 23 + Examples/test-suite/ruby/std_containers_runme.rb | 119 + Examples/test-suite/ruby/stl_new_runme.rb | 117 + Examples/test-suite/ruby/struct_value_runme.rb | 21 + Examples/test-suite/ruby/swig_assert.rb | 141 + Examples/test-suite/ruby/swig_gc.rb | 70 + .../test-suite/ruby/template_construct_runme.rb | 13 + Examples/test-suite/ruby/template_extend1_runme.rb | 19 + Examples/test-suite/ruby/template_extend2_runme.rb | 19 + Examples/test-suite/ruby/template_inherit_runme.rb | 51 + Examples/test-suite/ruby/template_ns4_runme.rb | 15 + Examples/test-suite/ruby/template_ns_runme.rb | 26 + Examples/test-suite/ruby/template_rename_runme.rb | 23 + .../ruby/template_tbase_template_runme.rb | 18 + .../ruby/template_type_namespace_runme.rb | 18 + .../ruby/template_typedef_cplx2_runme.rb | 81 + .../ruby/template_typedef_cplx3_runme.rb | 46 + .../ruby/template_typedef_cplx4_runme.rb | 46 + .../test-suite/ruby/template_typedef_cplx_runme.rb | 77 + Examples/test-suite/ruby/throw_exception_runme.rb | 41 + Examples/test-suite/ruby/typedef_inherit_runme.rb | 38 + Examples/test-suite/ruby/typedef_scope_runme.rb | 24 + .../test-suite/ruby/typemap_namespace_runme.rb | 18 + Examples/test-suite/ruby/typemap_ns_using_runme.rb | 15 + Examples/test-suite/ruby/typename_runme.rb | 25 + Examples/test-suite/ruby/unions_runme.rb | 65 + Examples/test-suite/ruby/using1_runme.rb | 15 + Examples/test-suite/ruby/using2_runme.rb | 15 + .../test-suite/ruby/using_composition_runme.rb | 56 + Examples/test-suite/ruby/using_extend_runme.rb | 36 + Examples/test-suite/ruby/using_inherit_runme.rb | 74 + Examples/test-suite/ruby/using_private_runme.rb | 30 + Examples/test-suite/ruby/using_protected_runme.rb | 22 + Examples/test-suite/ruby/varargs_runme.rb | 26 + .../test-suite/ruby/virtual_derivation_runme.rb | 18 + Examples/test-suite/ruby/virtual_poly_runme.rb | 33 + Examples/test-suite/ruby/voidtest_runme.rb | 24 + Examples/test-suite/ruby_keywords.i | 65 + Examples/test-suite/ruby_li_std_speed.i | 26 + Examples/test-suite/ruby_naming.i | 107 + Examples/test-suite/ruby_track_objects.i | 125 + Examples/test-suite/ruby_track_objects_directors.i | 44 + Examples/test-suite/samename.i | 22 + Examples/test-suite/samename_runme.m | 1 + Examples/test-suite/schemerunme/casts.scm | 8 + Examples/test-suite/schemerunme/char_constant.scm | 4 + Examples/test-suite/schemerunme/class_ignore.scm | 6 + Examples/test-suite/schemerunme/constover.scm | 26 + Examples/test-suite/schemerunme/contract.scm | 14 + Examples/test-suite/schemerunme/cpp_enum.scm | 21 + Examples/test-suite/schemerunme/cpp_namespace.scm | 42 + Examples/test-suite/schemerunme/dynamic_cast.scm | 11 + Examples/test-suite/schemerunme/global_vars.scm | 31 + .../test-suite/schemerunme/global_vars_proxy.scm | 31 + .../test-suite/schemerunme/import_nomodule.scm | 7 + Examples/test-suite/schemerunme/imports.scm | 13 + .../test-suite/schemerunme/inherit_missing.scm | 14 + Examples/test-suite/schemerunme/integers.scm | 28 + Examples/test-suite/schemerunme/li_std_string.scm | 46 + Examples/test-suite/schemerunme/li_typemaps.scm | 45 + .../test-suite/schemerunme/li_typemaps_proxy.scm | 45 + Examples/test-suite/schemerunme/list_vector.scm | 26 + .../schemerunme/multiple_inheritance_proxy.scm | 31 + Examples/test-suite/schemerunme/multivalue.scm | 19 + Examples/test-suite/schemerunme/name.scm | 5 + .../schemerunme/overload_complicated.scm | 16 + Examples/test-suite/schemerunme/overload_copy.scm | 4 + .../test-suite/schemerunme/overload_extend.scm | 12 + .../test-suite/schemerunme/overload_simple.scm | 51 + .../test-suite/schemerunme/overload_subtype.scm | 7 + Examples/test-suite/schemerunme/pointer_in_out.scm | 13 + .../schemerunme/reference_global_vars.scm | 59 + .../test-suite/schemerunme/typedef_inherit.scm | 19 + Examples/test-suite/schemerunme/typename.scm | 12 + Examples/test-suite/schemerunme/unions.scm | 36 + Examples/test-suite/schemerunme/unions_proxy.scm | 37 + Examples/test-suite/shared_ptr_wrapper.h | 100 + Examples/test-suite/simple_array.i | 42 + Examples/test-suite/simutry.i | 98 + Examples/test-suite/sizeof_pointer.i | 19 + Examples/test-suite/sizet.i | 52 + Examples/test-suite/smart_pointer_const.i | 19 + Examples/test-suite/smart_pointer_const2.i | 20 + Examples/test-suite/smart_pointer_extend.i | 132 + Examples/test-suite/smart_pointer_inherit.i | 76 + Examples/test-suite/smart_pointer_member.i | 56 + Examples/test-suite/smart_pointer_multi.i | 39 + Examples/test-suite/smart_pointer_multi_typedef.i | 45 + Examples/test-suite/smart_pointer_namespace.i | 78 + Examples/test-suite/smart_pointer_namespace2.i | 80 + Examples/test-suite/smart_pointer_not.i | 39 + Examples/test-suite/smart_pointer_overload.i | 28 + Examples/test-suite/smart_pointer_protected.i | 33 + Examples/test-suite/smart_pointer_rename.i | 25 + Examples/test-suite/smart_pointer_simple.i | 19 + Examples/test-suite/smart_pointer_static.i | 24 + .../test-suite/smart_pointer_templatemethods.i | 52 + .../test-suite/smart_pointer_templatevariables.i | 39 + Examples/test-suite/smart_pointer_typedef.i | 21 + Examples/test-suite/sneaky1.i | 29 + Examples/test-suite/special_variable_macros.i | 179 + Examples/test-suite/special_variables.i | 90 + Examples/test-suite/static_array_member.i | 12 + Examples/test-suite/static_const_member.i | 17 + Examples/test-suite/static_const_member_2.i | 76 + Examples/test-suite/std_containers.i | 207 + Examples/test-suite/stl_new.i | 29 + Examples/test-suite/struct_rename.i | 11 + Examples/test-suite/struct_value.i | 14 + Examples/test-suite/swig_examples_lock.h | 70 + Examples/test-suite/swigobject.i | 25 + Examples/test-suite/sym.i | 24 + Examples/test-suite/tag_no_clash_with_variable.i | 33 + Examples/test-suite/tcl/Makefile.in | 57 + Examples/test-suite/tcl/README | 4 + Examples/test-suite/tcl/bools_runme.tcl | 73 + Examples/test-suite/tcl/clientdata_prop_runme.tcl | 88 + Examples/test-suite/tcl/disown_runme.tcl | 16 + Examples/test-suite/tcl/enum_thorough_runme.tcl | 9 + Examples/test-suite/tcl/import_nomodule_runme.tcl | 4 + Examples/test-suite/tcl/imports_runme.tcl | 19 + Examples/test-suite/tcl/li_std_string_runme.tcl | 21 + Examples/test-suite/tcl/member_pointer_runme.tcl | 46 + Examples/test-suite/tcl/newobject1_runme.tcl | 28 + Examples/test-suite/tcl/newobject2_runme.tcl | 27 + Examples/test-suite/tcl/overload_copy_runme.tcl | 12 + Examples/test-suite/tcl/overload_simple_runme.tcl | 166 + Examples/test-suite/tcl/primitive_ref_runme.tcl | 19 + Examples/test-suite/tcl/primitive_types_runme.tcl | 33 + Examples/test-suite/tcl/profiletest_runme.tcl | 8 + .../test-suite/tcl/reference_global_vars_runme.tcl | 108 + Examples/test-suite/tcl/union_parameter_runme.tcl | 36 + Examples/test-suite/tcl/unions_runme.tcl | 63 + Examples/test-suite/template.i | 52 + Examples/test-suite/template_arg_replace.i | 14 + Examples/test-suite/template_arg_scope.i | 16 + Examples/test-suite/template_arg_typename.i | 26 + Examples/test-suite/template_array_numeric.i | 26 + Examples/test-suite/template_base_template.i | 41 + Examples/test-suite/template_classes.i | 52 + Examples/test-suite/template_const_ref.i | 14 + Examples/test-suite/template_construct.i | 15 + Examples/test-suite/template_default.i | 216 + Examples/test-suite/template_default2.i | 44 + Examples/test-suite/template_default_arg.i | 126 + Examples/test-suite/template_default_class_parms.i | 33 + Examples/test-suite/template_default_inherit.i | 25 + Examples/test-suite/template_default_pointer.i | 12 + Examples/test-suite/template_default_qualify.i | 56 + Examples/test-suite/template_default_vw.i | 24 + Examples/test-suite/template_enum.i | 41 + Examples/test-suite/template_enum_ns_inherit.i | 48 + Examples/test-suite/template_enum_typedef.i | 39 + Examples/test-suite/template_explicit.i | 60 + Examples/test-suite/template_expr.i | 57 + Examples/test-suite/template_extend1.i | 26 + Examples/test-suite/template_extend2.i | 28 + Examples/test-suite/template_extend_overload.i | 44 + Examples/test-suite/template_extend_overload_2.i | 121 + Examples/test-suite/template_forward.i | 71 + Examples/test-suite/template_inherit.i | 41 + Examples/test-suite/template_inherit_abstract.i | 67 + Examples/test-suite/template_int_const.i | 50 + Examples/test-suite/template_matrix.i | 71 + Examples/test-suite/template_methods.i | 100 + Examples/test-suite/template_ns.i | 35 + Examples/test-suite/template_ns2.i | 16 + Examples/test-suite/template_ns3.i | 21 + Examples/test-suite/template_ns4.i | 77 + Examples/test-suite/template_ns_enum.i | 18 + Examples/test-suite/template_ns_enum2.i | 38 + Examples/test-suite/template_ns_inherit.i | 30 + Examples/test-suite/template_ns_scope.i | 38 + Examples/test-suite/template_opaque.i | 41 + Examples/test-suite/template_partial_arg.i | 21 + Examples/test-suite/template_qualifier.i | 15 + Examples/test-suite/template_ref_type.i | 27 + Examples/test-suite/template_rename.i | 49 + Examples/test-suite/template_retvalue.i | 32 + Examples/test-suite/template_specialization.i | 37 + .../test-suite/template_specialization_defarg.i | 95 + Examples/test-suite/template_specialization_enum.i | 63 + Examples/test-suite/template_static.i | 33 + Examples/test-suite/template_tbase_template.i | 49 + Examples/test-suite/template_template_parameters.i | 39 + Examples/test-suite/template_type_namespace.i | 14 + Examples/test-suite/template_typedef.i | 179 + Examples/test-suite/template_typedef_cplx.i | 178 + Examples/test-suite/template_typedef_cplx2.h | 175 + Examples/test-suite/template_typedef_cplx2.i | 7 + Examples/test-suite/template_typedef_cplx3.i | 37 + Examples/test-suite/template_typedef_cplx4.i | 44 + Examples/test-suite/template_typedef_cplx5.i | 22 + Examples/test-suite/template_typedef_fnc.i | 14 + Examples/test-suite/template_typedef_funcptr.i | 53 + Examples/test-suite/template_typedef_import.i | 37 + Examples/test-suite/template_typedef_import.list | 2 + Examples/test-suite/template_typedef_ns.i | 18 + Examples/test-suite/template_typedef_ptr.i | 38 + Examples/test-suite/template_typedef_rec.i | 113 + Examples/test-suite/template_typemaps.i | 62 + Examples/test-suite/template_using.i | 17 + Examples/test-suite/template_virtual.i | 34 + Examples/test-suite/template_whitespace.i | 22 + Examples/test-suite/testdir/subdir1/hello.i | 24 + Examples/test-suite/testdir/subdir1/imports.i | 6 + Examples/test-suite/testdir/subdir1/subinc1.i | 5 + Examples/test-suite/testdir/subdir2/hello.i | 24 + Examples/test-suite/testdir/subdir2/imports.i | 6 + Examples/test-suite/testdir/subdir2/subinc2.i | 3 + Examples/test-suite/testdir/test.i | 4 + Examples/test-suite/threads.i | 23 + Examples/test-suite/throw_exception.i | 79 + Examples/test-suite/traits.i | 6 + Examples/test-suite/typedef_array_member.i | 25 + Examples/test-suite/typedef_class.i | 16 + Examples/test-suite/typedef_funcptr.i | 27 + Examples/test-suite/typedef_inherit.i | 49 + Examples/test-suite/typedef_mptr.i | 34 + Examples/test-suite/typedef_reference.i | 10 + Examples/test-suite/typedef_scope.i | 37 + Examples/test-suite/typedef_sizet.i | 6 + Examples/test-suite/typedef_struct.i | 43 + Examples/test-suite/typemap_namespace.i | 49 + Examples/test-suite/typemap_ns_using.i | 21 + Examples/test-suite/typemap_numinputs.i | 37 + Examples/test-suite/typemap_out_optimal.i | 38 + Examples/test-suite/typemap_self.i | 47 + Examples/test-suite/typemap_subst.i | 73 + Examples/test-suite/typemap_variables.i | 69 + Examples/test-suite/typemap_various.i | 57 + Examples/test-suite/typename.i | 34 + Examples/test-suite/types_directive.i | 54 + Examples/test-suite/uffi/Makefile.in | 51 + Examples/test-suite/union_parameter.i | 41 + Examples/test-suite/union_scope.i | 13 + Examples/test-suite/unions.i | 42 + Examples/test-suite/using1.i | 22 + Examples/test-suite/using2.i | 27 + Examples/test-suite/using_composition.i | 49 + Examples/test-suite/using_extend.i | 51 + Examples/test-suite/using_inherit.i | 54 + Examples/test-suite/using_namespace.i | 76 + Examples/test-suite/using_pointers.i | 36 + Examples/test-suite/using_private.i | 25 + Examples/test-suite/using_protected.i | 17 + Examples/test-suite/valuewrapper.i | 17 + Examples/test-suite/valuewrapper_base.i | 28 + Examples/test-suite/valuewrapper_const.i | 30 + Examples/test-suite/valuewrapper_opaque.i | 253 + Examples/test-suite/varargs.i | 38 + Examples/test-suite/virtual_derivation.i | 67 + Examples/test-suite/virtual_destructor.i | 22 + Examples/test-suite/virtual_poly.i | 204 + Examples/test-suite/voidtest.i | 23 + Examples/test-suite/wallkw.i | 16 + Examples/test-suite/wrapmacro.i | 62 + Examples/xml/Makefile.in | 54 + Examples/xml/error.expected-xml | 24 + Examples/xml/error.i | 2 + Examples/xml/example.expected-xml | 23 + Examples/xml/example.h | 3 + Examples/xml/example.i | 8 + Examples/xml/example_apply.expected-xml | 1486 + Examples/xml/example_apply.i | 23 + Examples/xml/example_const.expected-xml | 51 + Examples/xml/example_const.i | 26 + Examples/xml/example_gif.expected-xml | 2338 + Examples/xml/example_gif.i | 329 + Examples/xml/example_inl.expected-xml | 104 + Examples/xml/example_inl.h | 5 + Examples/xml/example_inl.i | 30 + Examples/xml/example_p5.expected-xml | 24 + Examples/xml/example_p5.i | 11 + Examples/xml/example_ro.expected-xml | 23 + Examples/xml/example_ro.i | 6 + Examples/xml/example_title_add.expected-xml | 119 + Examples/xml/example_title_add.i | 47 + Examples/xml/example_xml.expected-xml | 1624 + Examples/xml/example_xml.h | 39 + Examples/xml/example_xml.i | 69 + Examples/xml/gnarly.expected-xml | 206 + Examples/xml/gnarly.i | 63 + FUTURE | 335 + INSTALL | 226 + LICENSE | 95 + Lib/allegrocl/allegrocl.swg | 601 + Lib/allegrocl/inout_typemaps.i | 111 + Lib/allegrocl/longlongs.i | 36 + Lib/allegrocl/std_list.i | 233 + Lib/allegrocl/std_string.i | 218 + Lib/allegrocl/typemaps.i | 4 + Lib/allkw.swg | 31 + Lib/attribute.i | 24 + Lib/carrays.i | 120 + Lib/cdata.i | 83 + Lib/cffi/cffi.swg | 286 + Lib/chicken/chicken.swg | 774 + Lib/chicken/chickenkw.swg | 31 + Lib/chicken/chickenrun.swg | 378 + Lib/chicken/extra-install.list | 3 + Lib/chicken/multi-generic.scm | 152 + Lib/chicken/std_string.i | 100 + Lib/chicken/swigclosprefix.scm | 31 + Lib/chicken/tinyclos-multi-generic.patch | 150 + Lib/chicken/typemaps.i | 318 + Lib/clisp/clisp.swg | 35 + Lib/cmalloc.i | 113 + Lib/constraints.i | 227 + Lib/cpointer.i | 183 + Lib/csharp/arrays_csharp.i | 140 + Lib/csharp/boost_shared_ptr.i | 233 + Lib/csharp/csharp.swg | 997 + Lib/csharp/csharphead.swg | 329 + Lib/csharp/csharpkw.swg | 94 + Lib/csharp/director.swg | 50 + Lib/csharp/enums.swg | 89 + Lib/csharp/enumsimple.swg | 91 + Lib/csharp/enumtypesafe.swg | 133 + Lib/csharp/std_common.i | 5 + Lib/csharp/std_deque.i | 1 + Lib/csharp/std_except.i | 33 + Lib/csharp/std_map.i | 312 + Lib/csharp/std_pair.i | 37 + Lib/csharp/std_string.i | 114 + Lib/csharp/std_vector.i | 432 + Lib/csharp/std_wstring.i | 117 + Lib/csharp/stl.i | 15 + Lib/csharp/typemaps.i | 295 + Lib/csharp/wchar.i | 105 + Lib/cstring.i | 15 + Lib/cwstring.i | 14 + Lib/exception.i | 277 + Lib/gcj/cni.i | 43 + Lib/gcj/cni.swg | 17 + Lib/gcj/javaprims.i | 422 + Lib/guile/Makefile | 4 + Lib/guile/common.scm | 76 + Lib/guile/cplusplus.i | 25 + Lib/guile/extra-install.list | 2 + Lib/guile/ghinterface.i | 39 + Lib/guile/guile.i | 36 + Lib/guile/guile_gh.swg | 74 + Lib/guile/guile_gh_run.swg | 261 + Lib/guile/guile_scm.swg | 53 + Lib/guile/guile_scm_run.swg | 485 + Lib/guile/guilemain.i | 47 + Lib/guile/interpreter.i | 62 + Lib/guile/list-vector.i | 491 + Lib/guile/pointer-in-out.i | 105 + Lib/guile/ports.i | 56 + Lib/guile/std_common.i | 27 + Lib/guile/std_deque.i | 1 + Lib/guile/std_except.i | 12 + Lib/guile/std_map.i | 1351 + Lib/guile/std_pair.i | 871 + Lib/guile/std_string.i | 90 + Lib/guile/std_vector.i | 413 + Lib/guile/stl.i | 15 + Lib/guile/swigrun.i | 49 + Lib/guile/typemaps.i | 454 + Lib/intrusive_ptr.i | 95 + Lib/inttypes.i | 94 + Lib/java/arrays_java.i | 391 + Lib/java/boost_intrusive_ptr.i | 460 + Lib/java/boost_shared_ptr.i | 196 + Lib/java/director.swg | 191 + Lib/java/enums.swg | 120 + Lib/java/enumsimple.swg | 74 + Lib/java/enumtypesafe.swg | 121 + Lib/java/enumtypeunsafe.swg | 75 + Lib/java/java.swg | 1214 + Lib/java/javahead.swg | 104 + Lib/java/javakw.swg | 70 + Lib/java/std_common.i | 5 + Lib/java/std_deque.i | 1 + Lib/java/std_except.i | 33 + Lib/java/std_map.i | 179 + Lib/java/std_pair.i | 37 + Lib/java/std_string.i | 120 + Lib/java/std_vector.i | 88 + Lib/java/std_wstring.i | 175 + Lib/java/stl.i | 13 + Lib/java/typemaps.i | 449 + Lib/java/various.i | 151 + Lib/linkruntime.c | 22 + Lib/lua/_std_common.i | 96 + Lib/lua/carrays.i | 8 + Lib/lua/lua.swg | 235 + Lib/lua/lua_fnptr.i | 128 + Lib/lua/luarun.swg | 778 + Lib/lua/luaruntime.swg | 77 + Lib/lua/luatypemaps.swg | 380 + Lib/lua/std_common.i | 5 + Lib/lua/std_deque.i | 1 + Lib/lua/std_except.i | 43 + Lib/lua/std_map.i | 63 + Lib/lua/std_pair.i | 45 + Lib/lua/std_string.i | 155 + Lib/lua/std_vector.i | 134 + Lib/lua/stl.i | 13 + Lib/lua/typemaps.i | 562 + Lib/lua/wchar.i | 46 + Lib/math.i | 85 + Lib/modula3/modula3.swg | 750 + Lib/modula3/modula3head.swg | 67 + Lib/modula3/typemaps.i | 77 + Lib/mzscheme/Makefile | 4 + Lib/mzscheme/mzrun.swg | 511 + Lib/mzscheme/mzscheme.swg | 58 + Lib/mzscheme/std_common.i | 23 + Lib/mzscheme/std_deque.i | 1 + Lib/mzscheme/std_map.i | 1351 + Lib/mzscheme/std_pair.i | 873 + Lib/mzscheme/std_string.i | 60 + Lib/mzscheme/std_vector.i | 436 + Lib/mzscheme/stl.i | 14 + Lib/mzscheme/typemaps.i | 354 + Lib/ocaml/carray.i | 136 + Lib/ocaml/class.swg | 66 + Lib/ocaml/cstring.i | 271 + Lib/ocaml/director.swg | 103 + Lib/ocaml/extra-install.list | 5 + Lib/ocaml/libswigocaml.h | 20 + Lib/ocaml/ocaml.i | 61 + Lib/ocaml/ocaml.swg | 602 + Lib/ocaml/ocamldec.swg | 172 + Lib/ocaml/ocamlkw.swg | 64 + Lib/ocaml/preamble.swg | 17 + Lib/ocaml/std_common.i | 22 + Lib/ocaml/std_complex.i | 65 + Lib/ocaml/std_deque.i | 31 + Lib/ocaml/std_list.i | 222 + Lib/ocaml/std_map.i | 173 + Lib/ocaml/std_pair.i | 37 + Lib/ocaml/std_string.i | 179 + Lib/ocaml/std_vector.i | 92 + Lib/ocaml/stl.i | 15 + Lib/ocaml/swig.ml | 159 + Lib/ocaml/swig.mli | 61 + Lib/ocaml/swigp4.ml.in | 118 + Lib/ocaml/typecheck.i | 179 + Lib/ocaml/typemaps.i | 319 + Lib/ocaml/typeregister.swg | 2 + Lib/octave/attribute.i | 1 + Lib/octave/boost_shared_ptr.i | 305 + Lib/octave/carrays.i | 5 + Lib/octave/cdata.i | 1 + Lib/octave/cmalloc.i | 1 + Lib/octave/director.swg | 3 + Lib/octave/exception.i | 6 + Lib/octave/factory.i | 1 + Lib/octave/implicit.i | 7 + Lib/octave/octave.swg | 8 + Lib/octave/octcomplex.swg | 95 + Lib/octave/octcontainer.swg | 628 + Lib/octave/octfragments.swg | 1 + Lib/octave/octiterators.swg | 360 + Lib/octave/octopers.swg | 88 + Lib/octave/octprimtypes.swg | 232 + Lib/octave/octrun.swg | 1399 + Lib/octave/octruntime.swg | 104 + Lib/octave/octstdcommon.swg | 226 + Lib/octave/octtypemaps.swg | 97 + Lib/octave/octuserdir.swg | 72 + Lib/octave/std_alloc.i | 1 + Lib/octave/std_basic_string.i | 87 + Lib/octave/std_carray.i | 56 + Lib/octave/std_char_traits.i | 1 + Lib/octave/std_common.i | 41 + Lib/octave/std_complex.i | 22 + Lib/octave/std_container.i | 2 + Lib/octave/std_deque.i | 25 + Lib/octave/std_except.i | 1 + Lib/octave/std_map.i | 151 + Lib/octave/std_pair.i | 129 + Lib/octave/std_string.i | 1 + Lib/octave/std_vector.i | 26 + Lib/octave/stl.i | 6 + Lib/octave/typemaps.i | 1 + Lib/perl5/Makefile.in | 138 + Lib/perl5/Makefile.pl | 21 + Lib/perl5/attribute.i | 1 + Lib/perl5/carrays.i | 2 + Lib/perl5/cdata.i | 1 + Lib/perl5/cmalloc.i | 1 + Lib/perl5/cni.i | 12 + Lib/perl5/cpointer.i | 1 + Lib/perl5/cstring.i | 1 + Lib/perl5/exception.i | 5 + Lib/perl5/extra-install.list | 2 + Lib/perl5/factory.i | 1 + Lib/perl5/jstring.i | 48 + Lib/perl5/noembed.h | 102 + Lib/perl5/perl5.swg | 42 + Lib/perl5/perlerrors.swg | 49 + Lib/perl5/perlfragments.swg | 23 + Lib/perl5/perlhead.swg | 102 + Lib/perl5/perlinit.swg | 76 + Lib/perl5/perlkw.swg | 251 + Lib/perl5/perlmacros.swg | 2 + Lib/perl5/perlmain.i | 85 + Lib/perl5/perlopers.swg | 54 + Lib/perl5/perlprimtypes.swg | 328 + Lib/perl5/perlrun.swg | 500 + Lib/perl5/perlruntime.swg | 8 + Lib/perl5/perlstrings.swg | 59 + Lib/perl5/perltypemaps.swg | 92 + Lib/perl5/perluserdir.swg | 2 + Lib/perl5/reference.i | 264 + Lib/perl5/std_common.i | 29 + Lib/perl5/std_deque.i | 1 + Lib/perl5/std_except.i | 1 + Lib/perl5/std_list.i | 368 + Lib/perl5/std_map.i | 175 + Lib/perl5/std_pair.i | 37 + Lib/perl5/std_string.i | 2 + Lib/perl5/std_vector.i | 571 + Lib/perl5/stl.i | 14 + Lib/perl5/typemaps.i | 374 + Lib/php/const.i | 53 + Lib/php/director.swg | 198 + Lib/php/factory.i | 109 + Lib/php/globalvar.i | 331 + Lib/php/php.swg | 417 + Lib/php/phpinit.swg | 12 + Lib/php/phpkw.swg | 484 + Lib/php/phppointers.i | 42 + Lib/php/phprun.swg | 263 + Lib/php/std_common.i | 13 + Lib/php/std_deque.i | 1 + Lib/php/std_map.i | 179 + Lib/php/std_pair.i | 37 + Lib/php/std_string.i | 90 + Lib/php/std_vector.i | 105 + Lib/php/stl.i | 15 + Lib/php/typemaps.i | 265 + Lib/php/utils.i | 78 + Lib/pike/pike.swg | 317 + Lib/pike/pikekw.swg | 55 + Lib/pike/pikerun.swg | 73 + Lib/pike/std_string.i | 63 + Lib/pointer.i | 14 + Lib/python/Makefile.in | 135 + Lib/python/README | 105 + Lib/python/argcargv.i | 92 + Lib/python/attribute.i | 1 + Lib/python/boost_shared_ptr.i | 313 + Lib/python/carrays.i | 9 + Lib/python/ccomplex.i | 29 + Lib/python/cdata.i | 1 + Lib/python/cmalloc.i | 1 + Lib/python/cni.i | 2 + Lib/python/complex.i | 6 + Lib/python/cpointer.i | 1 + Lib/python/cstring.i | 1 + Lib/python/cwstring.i | 3 + Lib/python/defarg.swg | 37 + Lib/python/director.swg | 475 + Lib/python/embed.i | 115 + Lib/python/embed15.i | 118 + Lib/python/exception.i | 6 + Lib/python/factory.i | 1 + Lib/python/file.i | 45 + Lib/python/implicit.i | 7 + Lib/python/jstring.i | 72 + Lib/python/pyabc.i | 10 + Lib/python/pyapi.swg | 50 + Lib/python/pybackward.swg | 45 + Lib/python/pybuffer.i | 107 + Lib/python/pyclasses.swg | 146 + Lib/python/pycomplex.swg | 86 + Lib/python/pycontainer.swg | 824 + Lib/python/pydocs.swg | 18 + Lib/python/pyerrors.swg | 70 + Lib/python/pyfragments.swg | 23 + Lib/python/pyhead.swg | 148 + Lib/python/pyinit.swg | 352 + Lib/python/pyiterators.swg | 393 + Lib/python/pymacros.swg | 4 + Lib/python/pyname_compat.i | 88 + Lib/python/pyopers.swg | 136 + Lib/python/pyprimtypes.swg | 292 + Lib/python/pyrun.swg | 1584 + Lib/python/pyruntime.swg | 13 + Lib/python/pystdcommon.swg | 259 + Lib/python/pystrings.swg | 103 + Lib/python/python.swg | 59 + Lib/python/pythonkw.swg | 136 + Lib/python/pythreads.swg | 66 + Lib/python/pytuplehlp.swg | 8 + Lib/python/pytypemaps.swg | 98 + Lib/python/pyuserdir.swg | 245 + Lib/python/pywstrings.swg | 63 + Lib/python/std_alloc.i | 1 + Lib/python/std_basic_string.i | 103 + Lib/python/std_carray.i | 54 + Lib/python/std_char_traits.i | 1 + Lib/python/std_common.i | 44 + Lib/python/std_complex.i | 22 + Lib/python/std_container.i | 2 + Lib/python/std_deque.i | 27 + Lib/python/std_except.i | 1 + Lib/python/std_ios.i | 3 + Lib/python/std_iostream.i | 8 + Lib/python/std_list.i | 28 + Lib/python/std_map.i | 257 + Lib/python/std_multimap.i | 79 + Lib/python/std_multiset.i | 41 + Lib/python/std_pair.i | 139 + Lib/python/std_set.i | 55 + Lib/python/std_sstream.i | 1 + Lib/python/std_streambuf.i | 1 + Lib/python/std_string.i | 1 + Lib/python/std_vector.i | 27 + Lib/python/std_vectora.i | 31 + Lib/python/std_wios.i | 1 + Lib/python/std_wiostream.i | 10 + Lib/python/std_wsstream.i | 1 + Lib/python/std_wstreambuf.i | 1 + Lib/python/std_wstring.i | 3 + Lib/python/stl.i | 7 + Lib/python/typemaps.i | 151 + Lib/python/wchar.i | 21 + Lib/r/cdata.i | 1 + Lib/r/exception.i | 8 + Lib/r/r.swg | 256 + Lib/r/rcontainer.swg | 198 + Lib/r/rfragments.swg | 174 + Lib/r/rkw.swg | 32 + Lib/r/ropers.swg | 70 + Lib/r/rrun.swg | 367 + Lib/r/rstdcommon.swg | 216 + Lib/r/rtype.swg | 188 + Lib/r/srun.swg | 150 + Lib/r/std_alloc.i | 1 + Lib/r/std_common.i | 2 + Lib/r/std_container.i | 2 + Lib/r/std_deque.i | 1 + Lib/r/std_except.i | 1 + Lib/r/std_pair.i | 1 + Lib/r/std_string.i | 1 + Lib/r/std_vector.i | 10 + Lib/r/stl.i | 8 + Lib/r/typemaps.i | 1 + Lib/ruby/Makefile.swig | 42 + Lib/ruby/argcargv.i | 48 + Lib/ruby/attribute.i | 1 + Lib/ruby/carrays.i | 6 + Lib/ruby/cdata.i | 1 + Lib/ruby/cmalloc.i | 1 + Lib/ruby/cni.i | 2 + Lib/ruby/cpointer.i | 1 + Lib/ruby/cstring.i | 1 + Lib/ruby/director.swg | 382 + Lib/ruby/embed.i | 16 + Lib/ruby/exception.i | 5 + Lib/ruby/extconf.rb | 9 + Lib/ruby/extra-install.list | 3 + Lib/ruby/factory.i | 1 + Lib/ruby/file.i | 39 + Lib/ruby/jstring.i | 44 + Lib/ruby/progargcargv.i | 34 + Lib/ruby/ruby.swg | 72 + Lib/ruby/rubyapi.swg | 36 + Lib/ruby/rubyautodoc.swg | 110 + Lib/ruby/rubyclasses.swg | 395 + Lib/ruby/rubycomplex.swg | 129 + Lib/ruby/rubycontainer.swg | 1107 + Lib/ruby/rubycontainer_extended.swg | 139 + Lib/ruby/rubydef.swg | 1 + Lib/ruby/rubyerrors.swg | 154 + Lib/ruby/rubyfragments.swg | 23 + Lib/ruby/rubyhead.swg | 148 + Lib/ruby/rubyinit.swg | 1 + Lib/ruby/rubyiterators.swg | 935 + Lib/ruby/rubykw.swg | 72 + Lib/ruby/rubymacros.swg | 13 + Lib/ruby/rubyopers.swg | 55 + Lib/ruby/rubyprimtypes.swg | 220 + Lib/ruby/rubyrun.swg | 444 + Lib/ruby/rubyruntime.swg | 9 + Lib/ruby/rubystdautodoc.swg | 37 + Lib/ruby/rubystdcommon.swg | 265 + Lib/ruby/rubystdfunctors.swg | 162 + Lib/ruby/rubystrings.swg | 61 + Lib/ruby/rubytracking.swg | 160 + Lib/ruby/rubytypemaps.swg | 62 + Lib/ruby/rubyuserdir.swg | 10 + Lib/ruby/rubywstrings.swg | 76 + Lib/ruby/std_alloc.i | 1 + Lib/ruby/std_basic_string.i | 97 + Lib/ruby/std_char_traits.i | 1 + Lib/ruby/std_common.i | 44 + Lib/ruby/std_complex.i | 22 + Lib/ruby/std_container.i | 2 + Lib/ruby/std_deque.i | 30 + Lib/ruby/std_except.i | 1 + Lib/ruby/std_functors.i | 29 + Lib/ruby/std_ios.i | 14 + Lib/ruby/std_iostream.i | 12 + Lib/ruby/std_list.i | 41 + Lib/ruby/std_map.i | 417 + Lib/ruby/std_multimap.i | 226 + Lib/ruby/std_multiset.i | 50 + Lib/ruby/std_pair.i | 207 + Lib/ruby/std_queue.i | 33 + Lib/ruby/std_set.i | 213 + Lib/ruby/std_sstream.i | 2 + Lib/ruby/std_stack.i | 35 + Lib/ruby/std_streambuf.i | 1 + Lib/ruby/std_string.i | 9 + Lib/ruby/std_vector.i | 52 + Lib/ruby/std_vectora.i | 36 + Lib/ruby/std_wstring.i | 3 + Lib/ruby/stl.i | 15 + Lib/ruby/timeval.i | 64 + Lib/ruby/typemaps.i | 317 + Lib/runtime.swg | 38 + Lib/shared_ptr.i | 61 + Lib/std/README | 22 + Lib/std/_std_deque.i | 126 + Lib/std/std_alloc.i | 77 + Lib/std/std_basic_string.i | 270 + Lib/std/std_carray.swg | 64 + Lib/std/std_char_traits.i | 140 + Lib/std/std_common.i | 238 + Lib/std/std_container.i | 109 + Lib/std/std_deque.i | 127 + Lib/std/std_except.i | 68 + Lib/std/std_ios.i | 260 + Lib/std/std_iostream.i | 339 + Lib/std/std_list.i | 148 + Lib/std/std_map.i | 124 + Lib/std/std_multimap.i | 87 + Lib/std/std_multiset.i | 83 + Lib/std/std_pair.i | 163 + Lib/std/std_queue.i | 129 + Lib/std/std_set.i | 119 + Lib/std/std_sstream.i | 195 + Lib/std/std_stack.i | 128 + Lib/std/std_streambuf.i | 94 + Lib/std/std_string.i | 13 + Lib/std/std_vector.i | 184 + Lib/std/std_vectora.i | 7 + Lib/std/std_wios.i | 7 + Lib/std/std_wiostream.i | 7 + Lib/std/std_wsstream.i | 7 + Lib/std/std_wstreambuf.i | 7 + Lib/std/std_wstring.i | 14 + Lib/std_except.i | 58 + Lib/stdint.i | 109 + Lib/stl.i | 10 + Lib/swig.swg | 686 + Lib/swigarch.i | 65 + Lib/swigerrors.swg | 16 + Lib/swiginit.swg | 236 + Lib/swiglabels.swg | 108 + Lib/swigrun.i | 11 + Lib/swigrun.swg | 583 + Lib/swigwarn.swg | 262 + Lib/swigwarnings.swg | 128 + Lib/tcl/Makefile.in | 133 + Lib/tcl/attribute.i | 1 + Lib/tcl/carrays.i | 4 + Lib/tcl/cdata.i | 1 + Lib/tcl/cmalloc.i | 1 + Lib/tcl/cni.i | 2 + Lib/tcl/cpointer.i | 1 + Lib/tcl/cstring.i | 1 + Lib/tcl/cwstring.i | 2 + Lib/tcl/exception.i | 6 + Lib/tcl/factory.i | 1 + Lib/tcl/jstring.i | 42 + Lib/tcl/mactclinit.c | 93 + Lib/tcl/mactkinit.c | 236 + Lib/tcl/std_common.i | 20 + Lib/tcl/std_deque.i | 1 + Lib/tcl/std_except.i | 1 + Lib/tcl/std_map.i | 173 + Lib/tcl/std_pair.i | 37 + Lib/tcl/std_string.i | 2 + Lib/tcl/std_vector.i | 422 + Lib/tcl/std_wstring.i | 2 + Lib/tcl/stl.i | 14 + Lib/tcl/tcl8.swg | 45 + Lib/tcl/tclapi.swg | 107 + Lib/tcl/tclerrors.swg | 76 + Lib/tcl/tclfragments.swg | 22 + Lib/tcl/tclinit.swg | 119 + Lib/tcl/tclinterp.i | 20 + Lib/tcl/tclkw.swg | 10 + Lib/tcl/tclmacros.swg | 4 + Lib/tcl/tclopers.swg | 46 + Lib/tcl/tclprimtypes.swg | 239 + Lib/tcl/tclresult.i | 30 + Lib/tcl/tclrun.swg | 695 + Lib/tcl/tclruntime.swg | 15 + Lib/tcl/tclsh.i | 88 + Lib/tcl/tclstrings.swg | 31 + Lib/tcl/tcltypemaps.swg | 89 + Lib/tcl/tcluserdir.swg | 5 + Lib/tcl/tclwstrings.swg | 70 + Lib/tcl/typemaps.i | 467 + Lib/tcl/wish.i | 149 + Lib/typemaps/README | 54 + Lib/typemaps/attribute.swg | 286 + Lib/typemaps/carrays.swg | 117 + Lib/typemaps/cdata.swg | 78 + Lib/typemaps/cmalloc.swg | 113 + Lib/typemaps/cpointer.swg | 160 + Lib/typemaps/cstring.swg | 9 + Lib/typemaps/cstrings.swg | 292 + Lib/typemaps/cwstring.swg | 10 + Lib/typemaps/enumint.swg | 28 + Lib/typemaps/exception.swg | 89 + Lib/typemaps/factory.swg | 88 + Lib/typemaps/fragments.swg | 458 + Lib/typemaps/implicit.swg | 208 + Lib/typemaps/inoutlist.swg | 296 + Lib/typemaps/misctypes.swg | 21 + Lib/typemaps/primtypes.swg | 321 + Lib/typemaps/ptrtypes.swg | 211 + Lib/typemaps/std_except.swg | 96 + Lib/typemaps/std_string.swg | 27 + Lib/typemaps/std_strings.swg | 82 + Lib/typemaps/std_wstring.swg | 26 + Lib/typemaps/string.swg | 24 + Lib/typemaps/strings.swg | 594 + Lib/typemaps/swigmacros.swg | 245 + Lib/typemaps/swigobject.swg | 37 + Lib/typemaps/swigtype.swg | 604 + Lib/typemaps/swigtypemaps.swg | 170 + Lib/typemaps/traits.swg | 307 + Lib/typemaps/typemaps.swg | 160 + Lib/typemaps/valtypes.swg | 216 + Lib/typemaps/void.swg | 84 + Lib/typemaps/wstring.swg | 25 + Lib/uffi/uffi.swg | 103 + Lib/wchar.i | 14 + Lib/windows.i | 152 + Lib/xml/typemaps.i | 3 + Lib/xml/xml.swg | 1 + Makefile.in | 547 + Misc/fileheader | 10 + NEW | 267 + README | 575 + Source/CParse/cparse.h | 74 + Source/CParse/cscanner.c | 930 + Source/CParse/parser.c | 10438 ++++ Source/CParse/parser.h | 351 + Source/CParse/parser.y | 6066 +++ Source/CParse/templ.c | 675 + Source/CParse/util.c | 88 + Source/DOH/README | 118 + Source/DOH/base.c | 943 + Source/DOH/doh.h | 442 + Source/DOH/dohint.h | 133 + Source/DOH/file.c | 299 + Source/DOH/fio.c | 589 + Source/DOH/hash.c | 551 + Source/DOH/list.c | 377 + Source/DOH/memory.c | 220 + Source/DOH/string.c | 1158 + Source/DOH/void.c | 96 + Source/Include/swigconfig.h.in | 93 + Source/Include/swigwarn.h | 261 + Source/Makefile.am | 144 + Source/Makefile.in | 1072 + Source/Modules/README | 9 + Source/Modules/allegrocl.cxx | 3222 ++ Source/Modules/allocate.cxx | 955 + Source/Modules/browser.cxx | 413 + Source/Modules/cffi.cxx | 1081 + Source/Modules/chicken.cxx | 1552 + Source/Modules/clisp.cxx | 509 + Source/Modules/contract.cxx | 354 + Source/Modules/csharp.cxx | 3960 ++ Source/Modules/directors.cxx | 288 + Source/Modules/emit.cxx | 512 + Source/Modules/guile.cxx | 1759 + Source/Modules/java.cxx | 4166 ++ Source/Modules/lang.cxx | 3431 ++ Source/Modules/lua.cxx | 1226 + Source/Modules/main.cxx | 1251 + Source/Modules/modula3.cxx | 3987 ++ Source/Modules/module.cxx | 57 + Source/Modules/mzscheme.cxx | 834 + Source/Modules/ocaml.cxx | 1866 + Source/Modules/octave.cxx | 1425 + Source/Modules/overload.cxx | 792 + Source/Modules/perl5.cxx | 1768 + Source/Modules/php.cxx | 2739 + Source/Modules/pike.cxx | 903 + Source/Modules/python.cxx | 4067 ++ Source/Modules/r.cxx | 2745 + Source/Modules/ruby.cxx | 3427 ++ Source/Modules/s-exp.cxx | 394 + Source/Modules/swigmain.cxx | 202 + Source/Modules/swigmod.h | 391 + Source/Modules/tcl8.cxx | 1306 + Source/Modules/typepass.cxx | 1164 + Source/Modules/uffi.cxx | 398 + Source/Modules/utils.cxx | 98 + Source/Modules/xml.cxx | 320 + Source/Preprocessor/cpp.c | 1854 + Source/Preprocessor/expr.c | 436 + Source/Preprocessor/preprocessor.h | 38 + Source/README | 25 + Source/Swig/cwrap.c | 1462 + Source/Swig/deprecate.c | 105 + Source/Swig/error.c | 277 + Source/Swig/fragment.c | 181 + Source/Swig/getopt.c | 107 + Source/Swig/include.c | 383 + Source/Swig/misc.c | 1156 + Source/Swig/naming.c | 1652 + Source/Swig/parms.c | 196 + Source/Swig/scanner.c | 1227 + Source/Swig/stype.c | 1105 + Source/Swig/swig.h | 403 + Source/Swig/swigfile.h | 40 + Source/Swig/swigopt.h | 16 + Source/Swig/swigparm.h | 29 + Source/Swig/swigscan.h | 108 + Source/Swig/swigtree.h | 50 + Source/Swig/swigwrap.h | 29 + Source/Swig/symbol.c | 1916 + Source/Swig/tree.c | 376 + Source/Swig/typemap.c | 1936 + Source/Swig/typeobj.c | 1095 + Source/Swig/typesys.c | 2074 + Source/Swig/warn.c | 34 + Source/Swig/wrapfunc.c | 518 + TODO | 378 + Tools/WAD/CHANGES | 25 + Tools/WAD/COPYING | 504 + Tools/WAD/HACK | 78 + Tools/WAD/Include/wad.h | 269 + Tools/WAD/Makefile.in | 46 + Tools/WAD/Misc/fileheader | 28 + Tools/WAD/Papers/README | 5 + Tools/WAD/Prebuilt/linux/Makefile.in | 11 + Tools/WAD/Prebuilt/solaris/Makefile.in | 11 + Tools/WAD/Python/Makefile.in | 54 + Tools/WAD/Python/python.c | 221 + Tools/WAD/Python/type.c | 277 + Tools/WAD/Python/wadpyinit.cxx | 45 + Tools/WAD/README | 376 + Tools/WAD/Tcl/Makefile.in | 54 + Tools/WAD/Tcl/wadtcl.c | 122 + Tools/WAD/Tcl/wadtclinit.cxx | 38 + Tools/WAD/Test/Makefile.in | 44 + Tools/WAD/Test/README | 5 + Tools/WAD/Test/death.py | 65 + Tools/WAD/Test/death.tcl | 65 + Tools/WAD/Test/debug.c | 119 + Tools/WAD/Test/debug.i | 9 + Tools/WAD/Test/debug.py | 35 + Tools/WAD/Test/debug.tcl | 25 + Tools/WAD/Test/foo.py | 31 + Tools/WAD/Test/wadpm.py | 49 + Tools/WAD/Test/wpm.py | 280 + Tools/WAD/Wad/Makefile.in | 73 + Tools/WAD/Wad/debug.c | 98 + Tools/WAD/Wad/default.c | 311 + Tools/WAD/Wad/demangle.c | 36 + Tools/WAD/Wad/elf.c | 428 + Tools/WAD/Wad/init.c | 113 + Tools/WAD/Wad/io.c | 107 + Tools/WAD/Wad/libwadpl.pm | 8 + Tools/WAD/Wad/main.cxx | 14 + Tools/WAD/Wad/makehandler.py | 20 + Tools/WAD/Wad/memory.c | 174 + Tools/WAD/Wad/object.c | 303 + Tools/WAD/Wad/return.c | 69 + Tools/WAD/Wad/segment.c | 227 + Tools/WAD/Wad/signal.c | 520 + Tools/WAD/Wad/stab.c | 682 + Tools/WAD/Wad/stack.c | 309 + Tools/WAD/Wad/string.c | 131 + Tools/WAD/Wad/vars.c | 271 + Tools/WAD/Wad/wadhandler.pl | 36 + Tools/WAD/Wad/wadpl.cxx | 176 + Tools/WAD/configure | 5187 ++ Tools/WAD/configure.in | 365 + Tools/capitalize | 5 + Tools/check-include-path.pike | 20 + Tools/config/ac_compare_version.m4 | 40 + Tools/config/ac_compile_warnings.m4 | 56 + Tools/config/ac_define_dir.m4 | 35 + Tools/config/compile | 142 + Tools/config/config.guess | 1526 + Tools/config/config.sub | 1658 + Tools/config/depcomp | 589 + Tools/config/install-sh | 519 + Tools/config/missing | 367 + Tools/config/ylwrap | 223 + Tools/mkdist.py | 65 + Tools/mkrelease.py | 39 + Tools/mkwindows.sh | 111 + Tools/pyname_patch.py | 123 + Tools/setup.py.tmpl | 139 + Tools/swig.spec.1 | 42 + Tools/vcfilter | 10 + Win/README.txt | 1 + aclocal.m4 | 905 + autogen.sh | 15 + configure | 12698 +++++ configure.in | 2193 + packaging/swig-1.3.23-pylib.patch | 29 + packaging/swig-rpmlintrc | 3 + packaging/swig.changes | 21 + packaging/swig.spec | 62 + preinst-swig.in | 7 + swig.spec.in | 70 + vms/aaareadme.txt | 18 + vms/build_end.com | 21 + vms/build_init.com | 13 + vms/build_swig.com | 1 + vms/genbuild.py | 155 + vms/logicals.com | 18 + vms/scripts/build_all.com | 15 + vms/scripts/compil_cparse.com | 98 + vms/scripts/compil_doh.com | 106 + vms/scripts/compil_modules1_1.com | 132 + vms/scripts/compil_preprocessor.com | 94 + vms/scripts/compil_swig.com | 122 + vms/swigconfig.h | 2 + 3626 files changed, 508331 insertions(+) create mode 100644 ANNOUNCE create mode 100644 CCache/COPYING create mode 100644 CCache/Makefile.in create mode 100644 CCache/README create mode 100644 CCache/README.swig create mode 100644 CCache/args.c create mode 100644 CCache/ccache-swig.1 create mode 100644 CCache/ccache.c create mode 100644 CCache/ccache.h create mode 100644 CCache/ccache.yo create mode 100644 CCache/ccache_swig_config.h.in create mode 100644 CCache/cleanup.c create mode 100644 CCache/config.h.in create mode 100755 CCache/configure create mode 100644 CCache/configure.in create mode 100644 CCache/debian/NEWS create mode 100644 CCache/debian/README.Debian create mode 100644 CCache/debian/changelog create mode 100644 CCache/debian/compat create mode 100644 CCache/debian/control create mode 100644 CCache/debian/copyright create mode 100644 CCache/debian/dirs create mode 100644 CCache/debian/docs create mode 100644 CCache/debian/examples create mode 100644 CCache/debian/patches/01_no_home.diff create mode 100644 CCache/debian/patches/02_ccache-compressed.diff create mode 100644 CCache/debian/patches/03_long_options.diff create mode 100644 CCache/debian/patches/04_ignore_profile.diff create mode 100644 CCache/debian/patches/05_nfs_fix.diff create mode 100644 CCache/debian/patches/06_md.diff create mode 100644 CCache/debian/patches/07_cachedirtag.diff create mode 100644 CCache/debian/patches/08_manpage_hyphens.diff create mode 100644 CCache/debian/patches/09_respect_ldflags.diff create mode 100644 CCache/debian/patches/10_lru_cleanup.diff create mode 100644 CCache/debian/patches/11_utimes.diff create mode 100644 CCache/debian/patches/12_cachesize_permissions.diff create mode 100644 CCache/debian/patches/13_html_links.diff create mode 100644 CCache/debian/patches/14_hardlink_doc.diff create mode 100644 CCache/debian/patches/CREDITS create mode 100644 CCache/debian/rules create mode 100644 CCache/debian/update-ccache create mode 100644 CCache/debian/watch create mode 100644 CCache/execute.c create mode 100644 CCache/hash.c create mode 100755 CCache/install-sh create mode 100644 CCache/mdfour.c create mode 100644 CCache/mdfour.h create mode 100644 CCache/packaging/README create mode 100644 CCache/packaging/ccache.spec create mode 100644 CCache/snprintf.c create mode 100644 CCache/stats.c create mode 100755 CCache/test.sh create mode 100644 CCache/unify.c create mode 100644 CCache/util.c create mode 100644 CCache/web/index.html create mode 100644 CHANGES create mode 100644 CHANGES.current create mode 100644 Doc/Devel/cmdopt.html create mode 100644 Doc/Devel/engineering.html create mode 100644 Doc/Devel/file.html create mode 100644 Doc/Devel/index.html create mode 100644 Doc/Devel/internals.html create mode 100644 Doc/Devel/migrate.txt create mode 100644 Doc/Devel/parm.html create mode 100644 Doc/Devel/runtime.txt create mode 100644 Doc/Devel/scanner.html create mode 100644 Doc/Devel/tree.html create mode 100644 Doc/Devel/wrapobj.html create mode 100644 Doc/Manual/Allegrocl.html create mode 100644 Doc/Manual/Arguments.html create mode 100644 Doc/Manual/CCache.html create mode 100644 Doc/Manual/CSharp.html create mode 100644 Doc/Manual/Chicken.html create mode 100644 Doc/Manual/Contents.html create mode 100644 Doc/Manual/Contract.html create mode 100644 Doc/Manual/Customization.html create mode 100644 Doc/Manual/Extending.html create mode 100644 Doc/Manual/Guile.html create mode 100644 Doc/Manual/Introduction.html create mode 100644 Doc/Manual/Java.html create mode 100644 Doc/Manual/Library.html create mode 100644 Doc/Manual/Lisp.html create mode 100644 Doc/Manual/Lua.html create mode 100644 Doc/Manual/Makefile create mode 100644 Doc/Manual/Modula3.html create mode 100644 Doc/Manual/Modules.html create mode 100644 Doc/Manual/Mzscheme.html create mode 100644 Doc/Manual/Ocaml.html create mode 100644 Doc/Manual/Octave.html create mode 100644 Doc/Manual/Perl5.html create mode 100644 Doc/Manual/Php.html create mode 100644 Doc/Manual/Pike.html create mode 100644 Doc/Manual/Preface.html create mode 100644 Doc/Manual/Preprocessor.html create mode 100644 Doc/Manual/Python.html create mode 100644 Doc/Manual/R.html create mode 100644 Doc/Manual/README create mode 100644 Doc/Manual/Ruby.html create mode 100644 Doc/Manual/SWIG.html create mode 100644 Doc/Manual/SWIGDocumentation.html create mode 100644 Doc/Manual/SWIGDocumentation.pdf create mode 100644 Doc/Manual/SWIGPlus.html create mode 100644 Doc/Manual/Scripting.html create mode 100644 Doc/Manual/Sections.html create mode 100644 Doc/Manual/Tcl.html create mode 100644 Doc/Manual/Typemaps.html create mode 100644 Doc/Manual/Varargs.html create mode 100644 Doc/Manual/Warnings.html create mode 100644 Doc/Manual/Windows.html create mode 100644 Doc/Manual/ch11.1.png create mode 100644 Doc/Manual/ch11.2.png create mode 100644 Doc/Manual/ch11.3.png create mode 100644 Doc/Manual/ch12.1.png create mode 100644 Doc/Manual/ch2.1.png create mode 100644 Doc/Manual/ch9.table.2.png create mode 100644 Doc/Manual/chapters create mode 100644 Doc/Manual/fixstyle.py create mode 100644 Doc/Manual/index.html create mode 100644 Doc/Manual/makechap.py create mode 100644 Doc/Manual/maketoc.py create mode 100644 Doc/Manual/margin-left.patch create mode 100644 Doc/Manual/style.css create mode 100644 Doc/Manual/swig16.png create mode 100644 Doc/Manual/swightml.book create mode 100644 Doc/Manual/swigpdf.book create mode 100644 Doc/README create mode 100644 Examples/GIFPlot/Chicken/check.list create mode 100644 Examples/GIFPlot/Chicken/full/Makefile create mode 100644 Examples/GIFPlot/Chicken/full/README create mode 100644 Examples/GIFPlot/Chicken/full/cmap create mode 100644 Examples/GIFPlot/Chicken/full/gifplot.i create mode 100644 Examples/GIFPlot/Chicken/full/test-gifplot.scm create mode 100644 Examples/GIFPlot/Chicken/simple/Makefile create mode 100644 Examples/GIFPlot/Chicken/simple/README create mode 100644 Examples/GIFPlot/Chicken/simple/simple.i create mode 100644 Examples/GIFPlot/Chicken/simple/test-simple.scm create mode 100644 Examples/GIFPlot/Common-Lisp/full/cmap create mode 100644 Examples/GIFPlot/Common-Lisp/full/gifplot.i create mode 100644 Examples/GIFPlot/Common-Lisp/full/runme.lisp create mode 100644 Examples/GIFPlot/Guile/check.list create mode 100644 Examples/GIFPlot/Guile/full/Makefile create mode 100644 Examples/GIFPlot/Guile/full/README create mode 100644 Examples/GIFPlot/Guile/full/cmap create mode 100644 Examples/GIFPlot/Guile/full/gifplot.i create mode 100644 Examples/GIFPlot/Guile/full/runme.scm create mode 100644 Examples/GIFPlot/Guile/simple/Makefile create mode 100644 Examples/GIFPlot/Guile/simple/README create mode 100644 Examples/GIFPlot/Guile/simple/runme.scm create mode 100644 Examples/GIFPlot/Guile/simple/simple.i create mode 100644 Examples/GIFPlot/Include/gifplot.h create mode 100644 Examples/GIFPlot/Interface/gifplot.i create mode 100644 Examples/GIFPlot/Java/check.list create mode 100644 Examples/GIFPlot/Java/full/Makefile create mode 100644 Examples/GIFPlot/Java/full/README create mode 100644 Examples/GIFPlot/Java/full/cmap create mode 100644 Examples/GIFPlot/Java/full/gifplot.i create mode 100644 Examples/GIFPlot/Java/full/runme.java create mode 100644 Examples/GIFPlot/Java/shadow/Makefile create mode 100644 Examples/GIFPlot/Java/shadow/README create mode 100644 Examples/GIFPlot/Java/shadow/cmap create mode 100644 Examples/GIFPlot/Java/shadow/runme.java create mode 100644 Examples/GIFPlot/Java/simple/Makefile create mode 100644 Examples/GIFPlot/Java/simple/README create mode 100644 Examples/GIFPlot/Java/simple/runme.java create mode 100644 Examples/GIFPlot/Java/simple/simple.i create mode 100644 Examples/GIFPlot/Lib/Makefile.in create mode 100644 Examples/GIFPlot/Lib/color.c create mode 100644 Examples/GIFPlot/Lib/font.c create mode 100644 Examples/GIFPlot/Lib/frame.c create mode 100644 Examples/GIFPlot/Lib/gif.c create mode 100644 Examples/GIFPlot/Lib/matrix.c create mode 100644 Examples/GIFPlot/Lib/pixmap.c create mode 100644 Examples/GIFPlot/Lib/plot2d.c create mode 100644 Examples/GIFPlot/Lib/plot3d.c create mode 100644 Examples/GIFPlot/Makefile.in create mode 100644 Examples/GIFPlot/Ocaml/check.list create mode 100644 Examples/GIFPlot/Ocaml/full/Makefile create mode 100644 Examples/GIFPlot/Ocaml/full/README create mode 100644 Examples/GIFPlot/Ocaml/full/cmap create mode 100644 Examples/GIFPlot/Ocaml/full/gifplot.i create mode 100644 Examples/GIFPlot/Ocaml/full/runme.ml create mode 100644 Examples/GIFPlot/Ocaml/simple/Makefile create mode 100644 Examples/GIFPlot/Ocaml/simple/cmap create mode 100644 Examples/GIFPlot/Ocaml/simple/runme.ml create mode 100644 Examples/GIFPlot/Ocaml/simple/simple.i create mode 100644 Examples/GIFPlot/Perl5/check.list create mode 100644 Examples/GIFPlot/Perl5/full/Makefile create mode 100644 Examples/GIFPlot/Perl5/full/README create mode 100644 Examples/GIFPlot/Perl5/full/cmap create mode 100644 Examples/GIFPlot/Perl5/full/gifplot.i create mode 100644 Examples/GIFPlot/Perl5/full/runme.pl create mode 100644 Examples/GIFPlot/Perl5/shadow/Makefile create mode 100644 Examples/GIFPlot/Perl5/shadow/README create mode 100644 Examples/GIFPlot/Perl5/shadow/cmap create mode 100644 Examples/GIFPlot/Perl5/shadow/runme.pl create mode 100644 Examples/GIFPlot/Perl5/simple/Makefile create mode 100644 Examples/GIFPlot/Perl5/simple/README create mode 100644 Examples/GIFPlot/Perl5/simple/runme.pl create mode 100644 Examples/GIFPlot/Perl5/simple/simple.i create mode 100644 Examples/GIFPlot/Php/check.list create mode 100644 Examples/GIFPlot/Php/full/Makefile create mode 100644 Examples/GIFPlot/Php/full/README create mode 100644 Examples/GIFPlot/Php/full/cmap create mode 100644 Examples/GIFPlot/Php/full/gifplot.i create mode 100644 Examples/GIFPlot/Php/full/runme.php create mode 100644 Examples/GIFPlot/Php/shadow/Makefile create mode 100644 Examples/GIFPlot/Php/shadow/README create mode 100644 Examples/GIFPlot/Php/shadow/cmap create mode 100644 Examples/GIFPlot/Php/shadow/runme.php create mode 100644 Examples/GIFPlot/Php/simple/Makefile create mode 100644 Examples/GIFPlot/Php/simple/README create mode 100644 Examples/GIFPlot/Php/simple/runme.php create mode 100644 Examples/GIFPlot/Php/simple/simple.i create mode 100644 Examples/GIFPlot/Pike/check.list create mode 100644 Examples/GIFPlot/Pike/simple/Makefile create mode 100644 Examples/GIFPlot/Pike/simple/README create mode 100644 Examples/GIFPlot/Pike/simple/runme.pike create mode 100644 Examples/GIFPlot/Pike/simple/simple.i create mode 100644 Examples/GIFPlot/Python/check.list create mode 100644 Examples/GIFPlot/Python/full/Makefile create mode 100644 Examples/GIFPlot/Python/full/README create mode 100644 Examples/GIFPlot/Python/full/cmap create mode 100644 Examples/GIFPlot/Python/full/gifplot.i create mode 100644 Examples/GIFPlot/Python/full/runme.py create mode 100644 Examples/GIFPlot/Python/shadow/Makefile create mode 100644 Examples/GIFPlot/Python/shadow/README create mode 100644 Examples/GIFPlot/Python/shadow/cmap create mode 100644 Examples/GIFPlot/Python/shadow/runme.py create mode 100644 Examples/GIFPlot/Python/simple/Makefile create mode 100644 Examples/GIFPlot/Python/simple/README create mode 100644 Examples/GIFPlot/Python/simple/runme.py create mode 100644 Examples/GIFPlot/Python/simple/simple.i create mode 100644 Examples/GIFPlot/README create mode 100644 Examples/GIFPlot/Ruby/check.list create mode 100644 Examples/GIFPlot/Ruby/full/Makefile create mode 100644 Examples/GIFPlot/Ruby/full/README create mode 100644 Examples/GIFPlot/Ruby/full/cmap create mode 100644 Examples/GIFPlot/Ruby/full/gifplot.i create mode 100644 Examples/GIFPlot/Ruby/full/runme.rb create mode 100644 Examples/GIFPlot/Ruby/shadow/Makefile create mode 100644 Examples/GIFPlot/Ruby/shadow/README create mode 100644 Examples/GIFPlot/Ruby/shadow/cmap create mode 100644 Examples/GIFPlot/Ruby/shadow/runme.rb create mode 100644 Examples/GIFPlot/Ruby/simple/Makefile create mode 100644 Examples/GIFPlot/Ruby/simple/README create mode 100644 Examples/GIFPlot/Ruby/simple/runme.rb create mode 100644 Examples/GIFPlot/Ruby/simple/simple.i create mode 100644 Examples/GIFPlot/Tcl/check.list create mode 100644 Examples/GIFPlot/Tcl/full/Makefile create mode 100644 Examples/GIFPlot/Tcl/full/README create mode 100644 Examples/GIFPlot/Tcl/full/cmap create mode 100644 Examples/GIFPlot/Tcl/full/gifplot.i create mode 100644 Examples/GIFPlot/Tcl/full/runme.tcl create mode 100644 Examples/GIFPlot/Tcl/mandel/Makefile create mode 100644 Examples/GIFPlot/Tcl/mandel/README create mode 100644 Examples/GIFPlot/Tcl/mandel/cmap create mode 100644 Examples/GIFPlot/Tcl/mandel/display.tcl create mode 100644 Examples/GIFPlot/Tcl/mandel/mandel.i create mode 100644 Examples/GIFPlot/Tcl/mandel/mandel.tcl create mode 100644 Examples/GIFPlot/Tcl/simple/Makefile create mode 100644 Examples/GIFPlot/Tcl/simple/README create mode 100644 Examples/GIFPlot/Tcl/simple/runme.tcl create mode 100644 Examples/GIFPlot/Tcl/simple/simple.i create mode 100644 Examples/Makefile.in create mode 100644 Examples/README create mode 100644 Examples/chicken/README create mode 100644 Examples/chicken/check.list create mode 100644 Examples/chicken/class/Makefile create mode 100644 Examples/chicken/class/example.cxx create mode 100644 Examples/chicken/class/example.h create mode 100644 Examples/chicken/class/example.i create mode 100644 Examples/chicken/class/test-lowlevel-class.scm create mode 100644 Examples/chicken/class/test-tinyclos-class.scm create mode 100644 Examples/chicken/constants/Makefile create mode 100644 Examples/chicken/constants/example.i create mode 100644 Examples/chicken/constants/test-constants.scm create mode 100644 Examples/chicken/egg/Makefile create mode 100644 Examples/chicken/egg/README create mode 100644 Examples/chicken/egg/mod1.i create mode 100644 Examples/chicken/egg/mod2.i create mode 100644 Examples/chicken/egg/multi.setup create mode 100644 Examples/chicken/egg/multi_init.scm create mode 100644 Examples/chicken/egg/single.i create mode 100644 Examples/chicken/egg/single.setup create mode 100644 Examples/chicken/egg/test.scm create mode 100644 Examples/chicken/multimap/Makefile create mode 100644 Examples/chicken/multimap/example.c create mode 100644 Examples/chicken/multimap/example.i create mode 100644 Examples/chicken/multimap/test-multimap.scm create mode 100644 Examples/chicken/overload/Makefile create mode 100644 Examples/chicken/overload/README create mode 100644 Examples/chicken/overload/example.cxx create mode 100644 Examples/chicken/overload/example.h create mode 100644 Examples/chicken/overload/example.i create mode 100644 Examples/chicken/overload/test-overload.scm create mode 100644 Examples/chicken/simple/Makefile create mode 100644 Examples/chicken/simple/README create mode 100644 Examples/chicken/simple/example.c create mode 100644 Examples/chicken/simple/example.i create mode 100644 Examples/chicken/simple/test-simple.scm create mode 100644 Examples/chicken/zlib/Makefile create mode 100644 Examples/chicken/zlib/README.html create mode 100644 Examples/chicken/zlib/example.i create mode 100644 Examples/chicken/zlib/test-zlib.scm create mode 100644 Examples/contract/simple_c/example.c create mode 100644 Examples/contract/simple_c/example.i create mode 100644 Examples/contract/simple_c/runme1.py create mode 100644 Examples/contract/simple_c/runme2.py create mode 100644 Examples/contract/simple_cxx/example.cxx create mode 100644 Examples/contract/simple_cxx/example.h create mode 100644 Examples/contract/simple_cxx/example.i create mode 100644 Examples/contract/simple_cxx/runme1.py create mode 100644 Examples/contract/simple_cxx/runme2.py create mode 100644 Examples/contract/simple_cxx/runme3.py create mode 100644 Examples/csharp/arrays/Makefile create mode 100644 Examples/csharp/arrays/example.c create mode 100644 Examples/csharp/arrays/example.h create mode 100644 Examples/csharp/arrays/example.i create mode 100644 Examples/csharp/arrays/runme.cs create mode 100644 Examples/csharp/callback/Makefile create mode 100644 Examples/csharp/callback/example-cs.csproj create mode 100644 Examples/csharp/callback/example-vc.vcproj create mode 100644 Examples/csharp/callback/example.cxx create mode 100644 Examples/csharp/callback/example.h create mode 100644 Examples/csharp/callback/example.i create mode 100644 Examples/csharp/callback/example.sln create mode 100644 Examples/csharp/callback/runme.cs create mode 100644 Examples/csharp/check.list create mode 100644 Examples/csharp/class/Makefile create mode 100644 Examples/csharp/class/example-cs.csproj create mode 100644 Examples/csharp/class/example-vc.vcproj create mode 100644 Examples/csharp/class/example.cxx create mode 100644 Examples/csharp/class/example.h create mode 100644 Examples/csharp/class/example.i create mode 100644 Examples/csharp/class/example.sln create mode 100644 Examples/csharp/class/runme.cs create mode 100644 Examples/csharp/enum/Makefile create mode 100644 Examples/csharp/enum/example-cs.csproj create mode 100644 Examples/csharp/enum/example-vc.vcproj create mode 100644 Examples/csharp/enum/example.cxx create mode 100644 Examples/csharp/enum/example.h create mode 100644 Examples/csharp/enum/example.i create mode 100644 Examples/csharp/enum/example.sln create mode 100644 Examples/csharp/enum/runme.cs create mode 100644 Examples/csharp/extend/Makefile create mode 100644 Examples/csharp/extend/example-cs.csproj create mode 100644 Examples/csharp/extend/example-vc.vcproj create mode 100644 Examples/csharp/extend/example.cxx create mode 100644 Examples/csharp/extend/example.h create mode 100644 Examples/csharp/extend/example.i create mode 100644 Examples/csharp/extend/example.sln create mode 100644 Examples/csharp/extend/runme.cs create mode 100644 Examples/csharp/funcptr/Makefile create mode 100644 Examples/csharp/funcptr/example-cs.csproj create mode 100644 Examples/csharp/funcptr/example-vc.vcproj create mode 100644 Examples/csharp/funcptr/example.c create mode 100644 Examples/csharp/funcptr/example.h create mode 100644 Examples/csharp/funcptr/example.i create mode 100644 Examples/csharp/funcptr/example.sln create mode 100644 Examples/csharp/funcptr/runme.cs create mode 100644 Examples/csharp/reference/Makefile create mode 100644 Examples/csharp/reference/example-cs.csproj create mode 100644 Examples/csharp/reference/example-vc.vcproj create mode 100644 Examples/csharp/reference/example.cxx create mode 100644 Examples/csharp/reference/example.h create mode 100644 Examples/csharp/reference/example.i create mode 100644 Examples/csharp/reference/example.sln create mode 100644 Examples/csharp/reference/runme.cs create mode 100644 Examples/csharp/simple/Makefile create mode 100644 Examples/csharp/simple/example-cs.csproj create mode 100644 Examples/csharp/simple/example-vc.vcproj create mode 100644 Examples/csharp/simple/example.c create mode 100644 Examples/csharp/simple/example.i create mode 100644 Examples/csharp/simple/example.sln create mode 100644 Examples/csharp/simple/runme.cs create mode 100644 Examples/csharp/template/Makefile create mode 100644 Examples/csharp/template/example-cs.csproj create mode 100644 Examples/csharp/template/example-vc.vcproj create mode 100644 Examples/csharp/template/example.h create mode 100644 Examples/csharp/template/example.i create mode 100644 Examples/csharp/template/example.sln create mode 100644 Examples/csharp/template/runme.cs create mode 100644 Examples/csharp/variables/Makefile create mode 100644 Examples/csharp/variables/example-cs.csproj create mode 100644 Examples/csharp/variables/example-vc.vcproj create mode 100644 Examples/csharp/variables/example.c create mode 100644 Examples/csharp/variables/example.h create mode 100644 Examples/csharp/variables/example.i create mode 100644 Examples/csharp/variables/example.sln create mode 100644 Examples/csharp/variables/runme.cs create mode 100644 Examples/guile/Makefile.in create mode 100644 Examples/guile/README create mode 100644 Examples/guile/check.list create mode 100644 Examples/guile/constants/Makefile create mode 100644 Examples/guile/constants/constants.scm create mode 100644 Examples/guile/constants/example.i create mode 100644 Examples/guile/matrix/Makefile create mode 100644 Examples/guile/matrix/README create mode 100644 Examples/guile/matrix/main.c create mode 100644 Examples/guile/matrix/matrix.c create mode 100644 Examples/guile/matrix/matrix.i create mode 100644 Examples/guile/matrix/matrix.scm create mode 100644 Examples/guile/matrix/package.i create mode 100644 Examples/guile/matrix/vector.c create mode 100644 Examples/guile/matrix/vector.h create mode 100644 Examples/guile/matrix/vector.i create mode 100644 Examples/guile/multimap/Makefile create mode 100644 Examples/guile/multimap/example.c create mode 100644 Examples/guile/multimap/example.i create mode 100644 Examples/guile/multimap/runme.scm create mode 100644 Examples/guile/multivalue/Makefile create mode 100644 Examples/guile/multivalue/example.c create mode 100644 Examples/guile/multivalue/example.i create mode 100644 Examples/guile/multivalue/runme.scm create mode 100644 Examples/guile/port/Makefile create mode 100644 Examples/guile/port/README create mode 100644 Examples/guile/port/port.c create mode 100644 Examples/guile/port/port.i create mode 100644 Examples/guile/port/port.scm create mode 100644 Examples/guile/simple/Makefile create mode 100644 Examples/guile/simple/README create mode 100644 Examples/guile/simple/example.c create mode 100644 Examples/guile/simple/example.i create mode 100644 Examples/guile/simple/example.scm create mode 100644 Examples/guile/std_vector/Makefile create mode 100644 Examples/guile/std_vector/example.h create mode 100644 Examples/guile/std_vector/example.i create mode 100644 Examples/guile/std_vector/runme.scm create mode 100644 Examples/index.html create mode 100644 Examples/java/callback/Makefile create mode 100644 Examples/java/callback/example.cxx create mode 100644 Examples/java/callback/example.h create mode 100644 Examples/java/callback/example.i create mode 100644 Examples/java/callback/index.html create mode 100644 Examples/java/callback/runme.java create mode 100644 Examples/java/check.list create mode 100644 Examples/java/class/Makefile create mode 100644 Examples/java/class/example.cxx create mode 100644 Examples/java/class/example.dsp create mode 100644 Examples/java/class/example.h create mode 100644 Examples/java/class/example.i create mode 100644 Examples/java/class/index.html create mode 100644 Examples/java/class/runme.java create mode 100644 Examples/java/constants/Makefile create mode 100644 Examples/java/constants/example.i create mode 100644 Examples/java/constants/index.html create mode 100644 Examples/java/constants/runme.java create mode 100644 Examples/java/enum/Makefile create mode 100644 Examples/java/enum/example.cxx create mode 100644 Examples/java/enum/example.h create mode 100644 Examples/java/enum/example.i create mode 100644 Examples/java/enum/index.html create mode 100644 Examples/java/enum/runme.java create mode 100644 Examples/java/extend/Makefile create mode 100644 Examples/java/extend/example.cxx create mode 100644 Examples/java/extend/example.h create mode 100644 Examples/java/extend/example.i create mode 100644 Examples/java/extend/index.html create mode 100644 Examples/java/extend/runme.java create mode 100644 Examples/java/funcptr/Makefile create mode 100644 Examples/java/funcptr/example.c create mode 100644 Examples/java/funcptr/example.h create mode 100644 Examples/java/funcptr/example.i create mode 100644 Examples/java/funcptr/index.html create mode 100644 Examples/java/funcptr/runme.java create mode 100644 Examples/java/index.html create mode 100644 Examples/java/multimap/Makefile create mode 100644 Examples/java/multimap/example.c create mode 100644 Examples/java/multimap/example.dsp create mode 100644 Examples/java/multimap/example.i create mode 100644 Examples/java/multimap/runme.java create mode 100644 Examples/java/native/Makefile create mode 100644 Examples/java/native/example.i create mode 100644 Examples/java/native/index.html create mode 100644 Examples/java/native/runme.java create mode 100644 Examples/java/pointer/Makefile create mode 100644 Examples/java/pointer/example.c create mode 100644 Examples/java/pointer/example.i create mode 100644 Examples/java/pointer/index.html create mode 100644 Examples/java/pointer/runme.java create mode 100644 Examples/java/reference/Makefile create mode 100644 Examples/java/reference/example.cxx create mode 100644 Examples/java/reference/example.h create mode 100644 Examples/java/reference/example.i create mode 100644 Examples/java/reference/index.html create mode 100644 Examples/java/reference/runme.java create mode 100644 Examples/java/simple/Makefile create mode 100644 Examples/java/simple/example.c create mode 100644 Examples/java/simple/example.dsp create mode 100644 Examples/java/simple/example.i create mode 100644 Examples/java/simple/index.html create mode 100644 Examples/java/simple/runme.java create mode 100644 Examples/java/template/Makefile create mode 100644 Examples/java/template/example.h create mode 100644 Examples/java/template/example.i create mode 100644 Examples/java/template/index.html create mode 100644 Examples/java/template/runme.java create mode 100644 Examples/java/typemap/Makefile create mode 100644 Examples/java/typemap/example.i create mode 100644 Examples/java/typemap/index.html create mode 100644 Examples/java/typemap/runme.java create mode 100644 Examples/java/variables/Makefile create mode 100644 Examples/java/variables/example.c create mode 100644 Examples/java/variables/example.h create mode 100644 Examples/java/variables/example.i create mode 100644 Examples/java/variables/index.html create mode 100644 Examples/java/variables/runme.java create mode 100644 Examples/lua/arrays/Makefile create mode 100644 Examples/lua/arrays/example.c create mode 100644 Examples/lua/arrays/example.i create mode 100644 Examples/lua/arrays/runme.lua create mode 100644 Examples/lua/check.list create mode 100644 Examples/lua/class/Makefile create mode 100644 Examples/lua/class/example.cxx create mode 100644 Examples/lua/class/example.h create mode 100644 Examples/lua/class/example.i create mode 100644 Examples/lua/class/runme.lua create mode 100644 Examples/lua/constants/Makefile create mode 100644 Examples/lua/constants/example.i create mode 100644 Examples/lua/constants/runme.lua create mode 100644 Examples/lua/dual/Makefile create mode 100644 Examples/lua/dual/dual.cpp create mode 100644 Examples/lua/dual/example.i create mode 100644 Examples/lua/dual/example2.i create mode 100644 Examples/lua/embed/Makefile create mode 100644 Examples/lua/embed/embed.c create mode 100644 Examples/lua/embed/example.c create mode 100644 Examples/lua/embed/example.i create mode 100644 Examples/lua/embed/runme.lua create mode 100644 Examples/lua/embed2/Makefile create mode 100644 Examples/lua/embed2/embed2.c create mode 100644 Examples/lua/embed2/example.c create mode 100644 Examples/lua/embed2/example.i create mode 100644 Examples/lua/embed2/runme.lua create mode 100644 Examples/lua/embed3/Makefile create mode 100644 Examples/lua/embed3/embed3.cpp create mode 100644 Examples/lua/embed3/example.cpp create mode 100644 Examples/lua/embed3/example.h create mode 100644 Examples/lua/embed3/example.i create mode 100644 Examples/lua/embed3/runme.lua create mode 100644 Examples/lua/exception/Makefile create mode 100644 Examples/lua/exception/example.h create mode 100644 Examples/lua/exception/example.i create mode 100644 Examples/lua/exception/runme.lua create mode 100644 Examples/lua/funcptr3/Makefile create mode 100644 Examples/lua/funcptr3/example.c create mode 100644 Examples/lua/funcptr3/example.h create mode 100644 Examples/lua/funcptr3/example.i create mode 100644 Examples/lua/funcptr3/runme.lua create mode 100644 Examples/lua/functest/Makefile create mode 100644 Examples/lua/functest/example.c create mode 100644 Examples/lua/functest/example.i create mode 100644 Examples/lua/functest/runme.lua create mode 100644 Examples/lua/functor/Makefile create mode 100644 Examples/lua/functor/example.i create mode 100644 Examples/lua/functor/runme.lua create mode 100644 Examples/lua/import.lua create mode 100644 Examples/lua/import/Makefile create mode 100644 Examples/lua/import/README create mode 100644 Examples/lua/import/bar.h create mode 100644 Examples/lua/import/bar.i create mode 100644 Examples/lua/import/base.h create mode 100644 Examples/lua/import/base.i create mode 100644 Examples/lua/import/foo.h create mode 100644 Examples/lua/import/foo.i create mode 100644 Examples/lua/import/runme.lua create mode 100644 Examples/lua/import/spam.h create mode 100644 Examples/lua/import/spam.i create mode 100644 Examples/lua/lua.c create mode 100644 Examples/lua/owner/Makefile create mode 100644 Examples/lua/owner/example.cxx create mode 100644 Examples/lua/owner/example.h create mode 100644 Examples/lua/owner/example.i create mode 100644 Examples/lua/owner/runme.lua create mode 100644 Examples/lua/pointer/Makefile create mode 100644 Examples/lua/pointer/example.c create mode 100644 Examples/lua/pointer/example.i create mode 100644 Examples/lua/pointer/runme.lua create mode 100644 Examples/lua/simple/Makefile create mode 100644 Examples/lua/simple/example.c create mode 100644 Examples/lua/simple/example.i create mode 100644 Examples/lua/simple/runme.lua create mode 100644 Examples/lua/variables/Makefile create mode 100644 Examples/lua/variables/example.c create mode 100644 Examples/lua/variables/example.h create mode 100644 Examples/lua/variables/example.i create mode 100644 Examples/lua/variables/runme.lua create mode 100644 Examples/modula3/check.list create mode 100644 Examples/modula3/class/Makefile create mode 100644 Examples/modula3/class/example.cxx create mode 100644 Examples/modula3/class/example.h create mode 100644 Examples/modula3/class/example.i create mode 100644 Examples/modula3/class/swig.tmpl create mode 100644 Examples/modula3/enum/Makefile create mode 100644 Examples/modula3/enum/example.cxx create mode 100644 Examples/modula3/enum/example.h create mode 100644 Examples/modula3/enum/example.i create mode 100644 Examples/modula3/exception/Makefile create mode 100644 Examples/modula3/exception/example.h create mode 100644 Examples/modula3/exception/example.i create mode 100644 Examples/modula3/reference/Makefile create mode 100644 Examples/modula3/reference/example.cxx create mode 100644 Examples/modula3/reference/example.h create mode 100644 Examples/modula3/reference/example.i create mode 100644 Examples/modula3/simple/Makefile create mode 100644 Examples/modula3/simple/example.c create mode 100644 Examples/modula3/simple/example.i create mode 100644 Examples/modula3/typemap/Makefile create mode 100644 Examples/modula3/typemap/example.i create mode 100644 Examples/mzscheme/check.list create mode 100644 Examples/mzscheme/multimap/Makefile create mode 100644 Examples/mzscheme/multimap/example.c create mode 100644 Examples/mzscheme/multimap/example.i create mode 100644 Examples/mzscheme/multimap/example.scm create mode 100644 Examples/mzscheme/simple/Makefile create mode 100644 Examples/mzscheme/simple/README create mode 100644 Examples/mzscheme/simple/example.c create mode 100644 Examples/mzscheme/simple/example.i create mode 100644 Examples/mzscheme/simple/example.scm create mode 100644 Examples/mzscheme/std_vector/Makefile create mode 100644 Examples/mzscheme/std_vector/example.h create mode 100644 Examples/mzscheme/std_vector/example.i create mode 100644 Examples/mzscheme/std_vector/example.scm create mode 100644 Examples/ocaml/argout_ref/Makefile create mode 100644 Examples/ocaml/argout_ref/example.c create mode 100644 Examples/ocaml/argout_ref/example.i create mode 100644 Examples/ocaml/argout_ref/example_prog.ml create mode 100644 Examples/ocaml/check.list create mode 100644 Examples/ocaml/contract/Makefile create mode 100644 Examples/ocaml/contract/example.i create mode 100644 Examples/ocaml/contract/example_prog.ml create mode 100644 Examples/ocaml/scoped_enum/Makefile create mode 100644 Examples/ocaml/scoped_enum/README create mode 100644 Examples/ocaml/scoped_enum/example.i create mode 100644 Examples/ocaml/scoped_enum/example_prog.ml create mode 100644 Examples/ocaml/scoped_enum/foo.h create mode 100644 Examples/ocaml/shapes/Makefile create mode 100644 Examples/ocaml/shapes/example.c create mode 100644 Examples/ocaml/shapes/example.h create mode 100644 Examples/ocaml/shapes/example.i create mode 100644 Examples/ocaml/shapes/example_prog.ml create mode 100644 Examples/ocaml/simple/Makefile create mode 100644 Examples/ocaml/simple/example.c create mode 100644 Examples/ocaml/simple/example.i create mode 100644 Examples/ocaml/simple/example_prog.ml create mode 100644 Examples/ocaml/simple/index.html create mode 100644 Examples/ocaml/std_string/Makefile create mode 100644 Examples/ocaml/std_string/README create mode 100644 Examples/ocaml/std_string/example.h create mode 100644 Examples/ocaml/std_string/example.i create mode 100644 Examples/ocaml/std_string/runme.ml create mode 100644 Examples/ocaml/std_vector/Makefile create mode 100644 Examples/ocaml/std_vector/example.h create mode 100644 Examples/ocaml/std_vector/example.i create mode 100644 Examples/ocaml/std_vector/runme.ml create mode 100644 Examples/ocaml/stl/Makefile create mode 100644 Examples/ocaml/stl/example.h create mode 100644 Examples/ocaml/stl/example.i create mode 100644 Examples/ocaml/stl/runme.ml create mode 100644 Examples/ocaml/string_from_ptr/Makefile create mode 100644 Examples/ocaml/string_from_ptr/example_prog.ml create mode 100644 Examples/ocaml/string_from_ptr/foolib.i create mode 100644 Examples/ocaml/strings_test/Makefile create mode 100644 Examples/ocaml/strings_test/example.h create mode 100644 Examples/ocaml/strings_test/example.i create mode 100644 Examples/ocaml/strings_test/runme.ml create mode 100644 Examples/octave/callback/Makefile create mode 100644 Examples/octave/callback/example.cxx create mode 100644 Examples/octave/callback/example.h create mode 100644 Examples/octave/callback/example.i create mode 100644 Examples/octave/callback/runme.m create mode 100644 Examples/octave/check.list create mode 100644 Examples/octave/class/Makefile create mode 100644 Examples/octave/class/example.cxx create mode 100644 Examples/octave/class/example.h create mode 100644 Examples/octave/class/example.i create mode 100644 Examples/octave/class/runme.m create mode 100644 Examples/octave/constants/Makefile create mode 100644 Examples/octave/constants/example.i create mode 100644 Examples/octave/constants/runme.m create mode 100644 Examples/octave/contract/Makefile create mode 100644 Examples/octave/contract/example.c create mode 100644 Examples/octave/contract/example.i create mode 100644 Examples/octave/contract/runme.m create mode 100644 Examples/octave/enum/Makefile create mode 100644 Examples/octave/enum/example.cxx create mode 100644 Examples/octave/enum/example.h create mode 100644 Examples/octave/enum/example.i create mode 100644 Examples/octave/enum/runme.m create mode 100644 Examples/octave/extend/Makefile create mode 100644 Examples/octave/extend/example.cxx create mode 100644 Examples/octave/extend/example.h create mode 100644 Examples/octave/extend/example.i create mode 100644 Examples/octave/extend/runme.m create mode 100644 Examples/octave/funcptr/Makefile create mode 100644 Examples/octave/funcptr/example.c create mode 100644 Examples/octave/funcptr/example.h create mode 100644 Examples/octave/funcptr/example.i create mode 100644 Examples/octave/funcptr/runme.m create mode 100644 Examples/octave/funcptr2/Makefile create mode 100644 Examples/octave/funcptr2/example.c create mode 100644 Examples/octave/funcptr2/example.h create mode 100644 Examples/octave/funcptr2/example.i create mode 100644 Examples/octave/funcptr2/runme.m create mode 100644 Examples/octave/functor/Makefile create mode 100644 Examples/octave/functor/example.i create mode 100644 Examples/octave/functor/runme.m create mode 100644 Examples/octave/operator/Makefile create mode 100644 Examples/octave/operator/example.h create mode 100644 Examples/octave/operator/example.i create mode 100644 Examples/octave/operator/runme.m create mode 100644 Examples/octave/pointer/Makefile create mode 100644 Examples/octave/pointer/example.c create mode 100644 Examples/octave/pointer/example.i create mode 100644 Examples/octave/pointer/runme.m create mode 100644 Examples/octave/reference/Makefile create mode 100644 Examples/octave/reference/example.cxx create mode 100644 Examples/octave/reference/example.h create mode 100644 Examples/octave/reference/example.i create mode 100644 Examples/octave/reference/runme.m create mode 100644 Examples/octave/simple/Makefile create mode 100644 Examples/octave/simple/example.c create mode 100644 Examples/octave/simple/example.i create mode 100644 Examples/octave/simple/runme.m create mode 100644 Examples/octave/template/Makefile create mode 100644 Examples/octave/template/example.h create mode 100644 Examples/octave/template/example.i create mode 100644 Examples/octave/template/runme.m create mode 100644 Examples/octave/variables/Makefile create mode 100644 Examples/octave/variables/example.c create mode 100644 Examples/octave/variables/example.h create mode 100644 Examples/octave/variables/example.i create mode 100644 Examples/octave/variables/runme.m create mode 100644 Examples/perl5/check.list create mode 100644 Examples/perl5/class/Makefile create mode 100644 Examples/perl5/class/example.cxx create mode 100644 Examples/perl5/class/example.dsp create mode 100644 Examples/perl5/class/example.h create mode 100644 Examples/perl5/class/example.i create mode 100644 Examples/perl5/class/index.html create mode 100644 Examples/perl5/class/runme.pl create mode 100644 Examples/perl5/constants/Makefile create mode 100644 Examples/perl5/constants/example.i create mode 100644 Examples/perl5/constants/index.html create mode 100644 Examples/perl5/constants/runme.pl create mode 100644 Examples/perl5/constants2/Makefile create mode 100644 Examples/perl5/constants2/example.i create mode 100644 Examples/perl5/constants2/runme.pl create mode 100644 Examples/perl5/funcptr/Makefile create mode 100644 Examples/perl5/funcptr/example.c create mode 100644 Examples/perl5/funcptr/example.h create mode 100644 Examples/perl5/funcptr/example.i create mode 100644 Examples/perl5/funcptr/index.html create mode 100644 Examples/perl5/funcptr/runme.pl create mode 100644 Examples/perl5/import/Makefile create mode 100644 Examples/perl5/import/README create mode 100644 Examples/perl5/import/bar.dsp create mode 100644 Examples/perl5/import/bar.h create mode 100644 Examples/perl5/import/bar.i create mode 100644 Examples/perl5/import/base.dsp create mode 100644 Examples/perl5/import/base.h create mode 100644 Examples/perl5/import/base.i create mode 100644 Examples/perl5/import/example.dsw create mode 100644 Examples/perl5/import/foo.dsp create mode 100644 Examples/perl5/import/foo.h create mode 100644 Examples/perl5/import/foo.i create mode 100644 Examples/perl5/import/runme.pl create mode 100644 Examples/perl5/import/spam.dsp create mode 100644 Examples/perl5/import/spam.h create mode 100644 Examples/perl5/import/spam.i create mode 100644 Examples/perl5/index.html create mode 100644 Examples/perl5/inline/Makefile create mode 100644 Examples/perl5/inline/README create mode 100644 Examples/perl5/inline/runme.pl create mode 100644 Examples/perl5/java/Example.java create mode 100644 Examples/perl5/java/Makefile create mode 100644 Examples/perl5/java/example.i create mode 100644 Examples/perl5/java/runme.pl create mode 100644 Examples/perl5/multimap/Makefile create mode 100644 Examples/perl5/multimap/example.c create mode 100644 Examples/perl5/multimap/example.dsp create mode 100644 Examples/perl5/multimap/example.i create mode 100644 Examples/perl5/multimap/runme.pl create mode 100644 Examples/perl5/multiple_inheritance/Makefile create mode 100644 Examples/perl5/multiple_inheritance/example.h create mode 100644 Examples/perl5/multiple_inheritance/example.i create mode 100644 Examples/perl5/multiple_inheritance/runme.pl create mode 100644 Examples/perl5/pointer/Makefile create mode 100644 Examples/perl5/pointer/example.c create mode 100644 Examples/perl5/pointer/example.i create mode 100644 Examples/perl5/pointer/index.html create mode 100644 Examples/perl5/pointer/runme.pl create mode 100644 Examples/perl5/reference/Makefile create mode 100644 Examples/perl5/reference/example.cxx create mode 100644 Examples/perl5/reference/example.h create mode 100644 Examples/perl5/reference/example.i create mode 100644 Examples/perl5/reference/index.html create mode 100644 Examples/perl5/reference/runme.pl create mode 100644 Examples/perl5/simple/Makefile create mode 100644 Examples/perl5/simple/example.c create mode 100644 Examples/perl5/simple/example.dsp create mode 100644 Examples/perl5/simple/example.i create mode 100644 Examples/perl5/simple/index.html create mode 100644 Examples/perl5/simple/runme.pl create mode 100644 Examples/perl5/value/Makefile create mode 100644 Examples/perl5/value/example.c create mode 100644 Examples/perl5/value/example.h create mode 100644 Examples/perl5/value/example.i create mode 100644 Examples/perl5/value/index.html create mode 100644 Examples/perl5/value/runme.pl create mode 100644 Examples/perl5/variables/Makefile create mode 100644 Examples/perl5/variables/example.c create mode 100644 Examples/perl5/variables/example.h create mode 100644 Examples/perl5/variables/example.i create mode 100644 Examples/perl5/variables/index.html create mode 100644 Examples/perl5/variables/runme.pl create mode 100644 Examples/perl5/xmlstring/Makefile create mode 100644 Examples/perl5/xmlstring/example.cxx create mode 100644 Examples/perl5/xmlstring/example.h create mode 100644 Examples/perl5/xmlstring/example.i create mode 100644 Examples/perl5/xmlstring/runme.pl create mode 100644 Examples/perl5/xmlstring/xmlstring.i create mode 100644 Examples/php/callback/Makefile create mode 100644 Examples/php/callback/example.cxx create mode 100644 Examples/php/callback/example.h create mode 100644 Examples/php/callback/example.i create mode 100644 Examples/php/callback/index.html create mode 100644 Examples/php/callback/runme.php create mode 100644 Examples/php/check.list create mode 100644 Examples/php/class/Makefile create mode 100644 Examples/php/class/example.cxx create mode 100644 Examples/php/class/example.h create mode 100644 Examples/php/class/example.i create mode 100644 Examples/php/class/runme.php create mode 100644 Examples/php/constants/Makefile create mode 100644 Examples/php/constants/example.i create mode 100644 Examples/php/constants/runme.php create mode 100644 Examples/php/cpointer/Makefile create mode 100644 Examples/php/cpointer/example.c create mode 100644 Examples/php/cpointer/example.i create mode 100644 Examples/php/cpointer/runme.php create mode 100644 Examples/php/disown/Makefile create mode 100644 Examples/php/disown/example.cxx create mode 100644 Examples/php/disown/example.h create mode 100644 Examples/php/disown/example.i create mode 100644 Examples/php/disown/runme.php create mode 100644 Examples/php/enum/Makefile create mode 100644 Examples/php/enum/example.cxx create mode 100644 Examples/php/enum/example.h create mode 100644 Examples/php/enum/example.i create mode 100644 Examples/php/enum/runme.php create mode 100644 Examples/php/extend/Makefile create mode 100644 Examples/php/extend/example.cxx create mode 100644 Examples/php/extend/example.h create mode 100644 Examples/php/extend/example.i create mode 100644 Examples/php/extend/index.html create mode 100644 Examples/php/extend/runme.php create mode 100644 Examples/php/funcptr/Makefile create mode 100644 Examples/php/funcptr/example.c create mode 100644 Examples/php/funcptr/example.h create mode 100644 Examples/php/funcptr/example.i create mode 100644 Examples/php/funcptr/runme.php create mode 100644 Examples/php/overloading/Makefile create mode 100644 Examples/php/overloading/example.cxx create mode 100644 Examples/php/overloading/example.h create mode 100644 Examples/php/overloading/example.i create mode 100644 Examples/php/overloading/runme.php create mode 100644 Examples/php/pointer/Makefile create mode 100644 Examples/php/pointer/example.c create mode 100644 Examples/php/pointer/example.i create mode 100644 Examples/php/pointer/runme.php create mode 100644 Examples/php/pragmas/Makefile create mode 100644 Examples/php/pragmas/example.i create mode 100644 Examples/php/pragmas/include.php create mode 100755 Examples/php/pragmas/runme.php create mode 100644 Examples/php/proxy/Makefile create mode 100644 Examples/php/proxy/example.cxx create mode 100644 Examples/php/proxy/example.h create mode 100644 Examples/php/proxy/example.i create mode 100644 Examples/php/proxy/runme.php create mode 100644 Examples/php/reference/Makefile create mode 100644 Examples/php/reference/example.cxx create mode 100644 Examples/php/reference/example.h create mode 100644 Examples/php/reference/example.i create mode 100644 Examples/php/reference/runme-proxy.php4 create mode 100644 Examples/php/reference/runme.php create mode 100644 Examples/php/simple/Makefile create mode 100644 Examples/php/simple/example.c create mode 100644 Examples/php/simple/example.i create mode 100755 Examples/php/simple/runme.php create mode 100644 Examples/php/sync/Makefile create mode 100644 Examples/php/sync/example.cxx create mode 100644 Examples/php/sync/example.h create mode 100644 Examples/php/sync/example.i create mode 100644 Examples/php/sync/runme.php create mode 100644 Examples/php/value/Makefile create mode 100644 Examples/php/value/example.c create mode 100644 Examples/php/value/example.h create mode 100644 Examples/php/value/example.i create mode 100644 Examples/php/value/runme.php create mode 100644 Examples/php/variables/Makefile create mode 100644 Examples/php/variables/example.c create mode 100644 Examples/php/variables/example.h create mode 100644 Examples/php/variables/example.i create mode 100644 Examples/php/variables/runme.php create mode 100644 Examples/php/variables/runme.php4.old create mode 100644 Examples/pike/check.list create mode 100644 Examples/pike/class/Makefile create mode 100644 Examples/pike/class/example.cxx create mode 100644 Examples/pike/class/example.h create mode 100644 Examples/pike/class/example.i create mode 100755 Examples/pike/class/runme.pike create mode 100644 Examples/pike/constants/Makefile create mode 100644 Examples/pike/constants/example.i create mode 100755 Examples/pike/constants/runme.pike create mode 100644 Examples/pike/enum/Makefile create mode 100644 Examples/pike/enum/README create mode 100644 Examples/pike/enum/example.cxx create mode 100644 Examples/pike/enum/example.h create mode 100644 Examples/pike/enum/example.i create mode 100644 Examples/pike/enum/runme.pike create mode 100644 Examples/pike/overload/Makefile create mode 100644 Examples/pike/overload/example.cxx create mode 100644 Examples/pike/overload/example.h create mode 100644 Examples/pike/overload/example.i create mode 100644 Examples/pike/overload/runme.pike create mode 100644 Examples/pike/simple/Makefile create mode 100644 Examples/pike/simple/example.c create mode 100644 Examples/pike/simple/example.i create mode 100644 Examples/pike/simple/runme.pike create mode 100644 Examples/pike/template/Makefile create mode 100644 Examples/pike/template/example.h create mode 100644 Examples/pike/template/example.i create mode 100755 Examples/pike/template/runme.pike create mode 100644 Examples/python/callback/Makefile create mode 100644 Examples/python/callback/example.cxx create mode 100644 Examples/python/callback/example.h create mode 100644 Examples/python/callback/example.i create mode 100644 Examples/python/callback/index.html create mode 100644 Examples/python/callback/runme.py create mode 100644 Examples/python/check.list create mode 100644 Examples/python/class/Makefile create mode 100644 Examples/python/class/example.cxx create mode 100644 Examples/python/class/example.dsp create mode 100644 Examples/python/class/example.h create mode 100644 Examples/python/class/example.i create mode 100644 Examples/python/class/index.html create mode 100644 Examples/python/class/runme.py create mode 100644 Examples/python/constants/Makefile create mode 100644 Examples/python/constants/example.i create mode 100644 Examples/python/constants/index.html create mode 100644 Examples/python/constants/runme.py create mode 100644 Examples/python/contract/Makefile create mode 100644 Examples/python/contract/example.c create mode 100644 Examples/python/contract/example.dsp create mode 100644 Examples/python/contract/example.i create mode 100644 Examples/python/contract/runme.py create mode 100644 Examples/python/docstrings/Makefile create mode 100644 Examples/python/docstrings/example.cxx create mode 100644 Examples/python/docstrings/example.h create mode 100644 Examples/python/docstrings/example.i create mode 100644 Examples/python/docstrings/runme.py create mode 100644 Examples/python/enum/Makefile create mode 100644 Examples/python/enum/example.cxx create mode 100644 Examples/python/enum/example.h create mode 100644 Examples/python/enum/example.i create mode 100644 Examples/python/enum/index.html create mode 100644 Examples/python/enum/runme.py create mode 100644 Examples/python/exception/Makefile create mode 100644 Examples/python/exception/example.h create mode 100644 Examples/python/exception/example.i create mode 100644 Examples/python/exception/runme.py create mode 100644 Examples/python/exceptproxy/Makefile create mode 100644 Examples/python/exceptproxy/example.h create mode 100644 Examples/python/exceptproxy/example.i create mode 100644 Examples/python/exceptproxy/runme.py create mode 100644 Examples/python/extend/Makefile create mode 100644 Examples/python/extend/example.cxx create mode 100644 Examples/python/extend/example.h create mode 100644 Examples/python/extend/example.i create mode 100644 Examples/python/extend/index.html create mode 100644 Examples/python/extend/runme.py create mode 100644 Examples/python/funcptr/Makefile create mode 100644 Examples/python/funcptr/example.c create mode 100644 Examples/python/funcptr/example.h create mode 100644 Examples/python/funcptr/example.i create mode 100644 Examples/python/funcptr/index.html create mode 100644 Examples/python/funcptr/runme.py create mode 100644 Examples/python/funcptr2/Makefile create mode 100644 Examples/python/funcptr2/example.c create mode 100644 Examples/python/funcptr2/example.h create mode 100644 Examples/python/funcptr2/example.i create mode 100644 Examples/python/funcptr2/runme.py create mode 100644 Examples/python/functor/Makefile create mode 100644 Examples/python/functor/example.i create mode 100644 Examples/python/functor/runme.py create mode 100644 Examples/python/import/Makefile create mode 100644 Examples/python/import/README create mode 100644 Examples/python/import/bar.dsp create mode 100644 Examples/python/import/bar.h create mode 100644 Examples/python/import/bar.i create mode 100644 Examples/python/import/base.dsp create mode 100644 Examples/python/import/base.h create mode 100644 Examples/python/import/base.i create mode 100644 Examples/python/import/example.dsw create mode 100644 Examples/python/import/foo.dsp create mode 100644 Examples/python/import/foo.h create mode 100644 Examples/python/import/foo.i create mode 100644 Examples/python/import/runme.py create mode 100644 Examples/python/import/spam.dsp create mode 100644 Examples/python/import/spam.h create mode 100644 Examples/python/import/spam.i create mode 100644 Examples/python/import_template/Makefile create mode 100644 Examples/python/import_template/README create mode 100644 Examples/python/import_template/bar.h create mode 100644 Examples/python/import_template/bar.i create mode 100644 Examples/python/import_template/base.h create mode 100644 Examples/python/import_template/base.i create mode 100644 Examples/python/import_template/foo.h create mode 100644 Examples/python/import_template/foo.i create mode 100644 Examples/python/import_template/runme.py create mode 100644 Examples/python/import_template/spam.h create mode 100644 Examples/python/import_template/spam.i create mode 100644 Examples/python/index.html create mode 100644 Examples/python/java/Example.java create mode 100644 Examples/python/java/Makefile create mode 100644 Examples/python/java/example.i create mode 100644 Examples/python/java/runme.py create mode 100644 Examples/python/libffi/Makefile create mode 100644 Examples/python/libffi/example.i create mode 100644 Examples/python/multimap/Makefile create mode 100644 Examples/python/multimap/example.c create mode 100644 Examples/python/multimap/example.dsp create mode 100644 Examples/python/multimap/example.i create mode 100644 Examples/python/multimap/runme.py create mode 100644 Examples/python/operator/Makefile create mode 100644 Examples/python/operator/example.h create mode 100644 Examples/python/operator/example.i create mode 100644 Examples/python/operator/runme.py create mode 100644 Examples/python/pointer/Makefile create mode 100644 Examples/python/pointer/example.c create mode 100644 Examples/python/pointer/example.i create mode 100644 Examples/python/pointer/index.html create mode 100644 Examples/python/pointer/runme.py create mode 100644 Examples/python/reference/Makefile create mode 100644 Examples/python/reference/example.cxx create mode 100644 Examples/python/reference/example.h create mode 100644 Examples/python/reference/example.i create mode 100644 Examples/python/reference/index.html create mode 100644 Examples/python/reference/runme.py create mode 100644 Examples/python/simple/Makefile create mode 100644 Examples/python/simple/example.c create mode 100644 Examples/python/simple/example.dsp create mode 100644 Examples/python/simple/example.i create mode 100644 Examples/python/simple/index.html create mode 100644 Examples/python/simple/runme.py create mode 100644 Examples/python/smartptr/Makefile create mode 100644 Examples/python/smartptr/example.cxx create mode 100644 Examples/python/smartptr/example.h create mode 100644 Examples/python/smartptr/example.i create mode 100644 Examples/python/smartptr/runme.py create mode 100644 Examples/python/smartptr/smartptr.h create mode 100644 Examples/python/std_map/Makefile create mode 100644 Examples/python/std_map/example.h create mode 100644 Examples/python/std_map/example.i create mode 100644 Examples/python/std_map/runme.py create mode 100644 Examples/python/std_vector/Makefile create mode 100644 Examples/python/std_vector/example.h create mode 100644 Examples/python/std_vector/example.i create mode 100644 Examples/python/std_vector/runme.py create mode 100644 Examples/python/swigrun/Makefile create mode 100644 Examples/python/swigrun/example.cxx create mode 100644 Examples/python/swigrun/example.h create mode 100644 Examples/python/swigrun/example.i create mode 100644 Examples/python/swigrun/runme.py create mode 100644 Examples/python/template/Makefile create mode 100644 Examples/python/template/example.h create mode 100644 Examples/python/template/example.i create mode 100644 Examples/python/template/runme.py create mode 100644 Examples/python/varargs/Makefile create mode 100644 Examples/python/varargs/example.i create mode 100644 Examples/python/varargs/runme.py create mode 100644 Examples/python/variables/Makefile create mode 100644 Examples/python/variables/example.c create mode 100644 Examples/python/variables/example.h create mode 100644 Examples/python/variables/example.i create mode 100644 Examples/python/variables/index.html create mode 100644 Examples/python/variables/runme.py create mode 100644 Examples/python/weave/Makefile create mode 100644 Examples/python/weave/README create mode 100644 Examples/python/weave/example.h create mode 100644 Examples/python/weave/example.i create mode 100644 Examples/python/weave/runme.py create mode 100644 Examples/python/weave/swigptr2.py create mode 100644 Examples/r/check.list create mode 100644 Examples/r/class/Makefile create mode 100644 Examples/r/class/example.cxx create mode 100644 Examples/r/class/example.dsp create mode 100644 Examples/r/class/example.h create mode 100644 Examples/r/class/example.i create mode 100644 Examples/r/class/runme.R create mode 100644 Examples/r/simple/Makefile create mode 100644 Examples/r/simple/example.c create mode 100644 Examples/r/simple/example.dsp create mode 100644 Examples/r/simple/example.i create mode 100644 Examples/r/simple/runme.R create mode 100644 Examples/ruby/check.list create mode 100644 Examples/ruby/class/Makefile create mode 100644 Examples/ruby/class/example.cxx create mode 100644 Examples/ruby/class/example.dsp create mode 100644 Examples/ruby/class/example.h create mode 100644 Examples/ruby/class/example.i create mode 100644 Examples/ruby/class/index.html create mode 100644 Examples/ruby/class/runme.rb create mode 100644 Examples/ruby/constants/Makefile create mode 100644 Examples/ruby/constants/example.i create mode 100644 Examples/ruby/constants/index.html create mode 100755 Examples/ruby/constants/runme.rb create mode 100644 Examples/ruby/enum/Makefile create mode 100644 Examples/ruby/enum/example.cxx create mode 100644 Examples/ruby/enum/example.h create mode 100644 Examples/ruby/enum/example.i create mode 100644 Examples/ruby/enum/index.html create mode 100644 Examples/ruby/enum/runme.rb create mode 100644 Examples/ruby/exception_class/Makefile create mode 100644 Examples/ruby/exception_class/example.h create mode 100644 Examples/ruby/exception_class/example.i create mode 100644 Examples/ruby/exception_class/runme.rb create mode 100644 Examples/ruby/free_function/Makefile create mode 100644 Examples/ruby/free_function/example.cxx create mode 100644 Examples/ruby/free_function/example.dsp create mode 100644 Examples/ruby/free_function/example.h create mode 100644 Examples/ruby/free_function/example.i create mode 100644 Examples/ruby/free_function/runme.rb create mode 100644 Examples/ruby/funcptr/Makefile create mode 100644 Examples/ruby/funcptr/example.c create mode 100644 Examples/ruby/funcptr/example.h create mode 100644 Examples/ruby/funcptr/example.i create mode 100644 Examples/ruby/funcptr/index.html create mode 100644 Examples/ruby/funcptr/runme.rb create mode 100644 Examples/ruby/funcptr2/Makefile create mode 100644 Examples/ruby/funcptr2/example.c create mode 100644 Examples/ruby/funcptr2/example.h create mode 100644 Examples/ruby/funcptr2/example.i create mode 100644 Examples/ruby/funcptr2/runme.rb create mode 100644 Examples/ruby/functor/Makefile create mode 100644 Examples/ruby/functor/example.i create mode 100644 Examples/ruby/functor/runme.rb create mode 100644 Examples/ruby/hashargs/Makefile create mode 100644 Examples/ruby/hashargs/example.i create mode 100755 Examples/ruby/hashargs/runme.rb create mode 100644 Examples/ruby/import/Makefile create mode 100644 Examples/ruby/import/README create mode 100644 Examples/ruby/import/bar.dsp create mode 100644 Examples/ruby/import/bar.h create mode 100644 Examples/ruby/import/bar.i create mode 100644 Examples/ruby/import/base.dsp create mode 100644 Examples/ruby/import/base.h create mode 100644 Examples/ruby/import/base.i create mode 100644 Examples/ruby/import/example.dsw create mode 100644 Examples/ruby/import/foo.dsp create mode 100644 Examples/ruby/import/foo.h create mode 100644 Examples/ruby/import/foo.i create mode 100644 Examples/ruby/import/runme.rb create mode 100644 Examples/ruby/import/spam.dsp create mode 100644 Examples/ruby/import/spam.h create mode 100644 Examples/ruby/import/spam.i create mode 100644 Examples/ruby/import_template/Makefile create mode 100644 Examples/ruby/import_template/README create mode 100644 Examples/ruby/import_template/bar.h create mode 100644 Examples/ruby/import_template/bar.i create mode 100644 Examples/ruby/import_template/base.h create mode 100644 Examples/ruby/import_template/base.i create mode 100644 Examples/ruby/import_template/foo.h create mode 100644 Examples/ruby/import_template/foo.i create mode 100644 Examples/ruby/import_template/runme.rb create mode 100644 Examples/ruby/import_template/spam.h create mode 100644 Examples/ruby/import_template/spam.i create mode 100644 Examples/ruby/index.html create mode 100644 Examples/ruby/java/Example.java create mode 100644 Examples/ruby/java/Makefile create mode 100644 Examples/ruby/java/example.i create mode 100644 Examples/ruby/java/runme.rb create mode 100644 Examples/ruby/mark_function/Makefile create mode 100644 Examples/ruby/mark_function/example.cxx create mode 100644 Examples/ruby/mark_function/example.dsp create mode 100644 Examples/ruby/mark_function/example.h create mode 100644 Examples/ruby/mark_function/example.i create mode 100644 Examples/ruby/mark_function/runme.rb create mode 100644 Examples/ruby/multimap/Makefile create mode 100644 Examples/ruby/multimap/example.c create mode 100644 Examples/ruby/multimap/example.dsp create mode 100644 Examples/ruby/multimap/example.i create mode 100755 Examples/ruby/multimap/runme.rb create mode 100644 Examples/ruby/operator/Makefile create mode 100644 Examples/ruby/operator/example.h create mode 100644 Examples/ruby/operator/example.i create mode 100644 Examples/ruby/operator/runme.rb create mode 100644 Examples/ruby/overloading/Makefile create mode 100644 Examples/ruby/overloading/example.cxx create mode 100644 Examples/ruby/overloading/example.h create mode 100644 Examples/ruby/overloading/example.i create mode 100644 Examples/ruby/overloading/runme.rb create mode 100644 Examples/ruby/pointer/Makefile create mode 100644 Examples/ruby/pointer/example.c create mode 100644 Examples/ruby/pointer/example.i create mode 100644 Examples/ruby/pointer/index.html create mode 100644 Examples/ruby/pointer/runme.rb create mode 100644 Examples/ruby/reference/Makefile create mode 100644 Examples/ruby/reference/example.cxx create mode 100644 Examples/ruby/reference/example.h create mode 100644 Examples/ruby/reference/example.i create mode 100644 Examples/ruby/reference/index.html create mode 100644 Examples/ruby/reference/runme.rb create mode 100644 Examples/ruby/simple/Makefile create mode 100644 Examples/ruby/simple/example.c create mode 100644 Examples/ruby/simple/example.dsp create mode 100644 Examples/ruby/simple/example.i create mode 100644 Examples/ruby/simple/index.html create mode 100755 Examples/ruby/simple/runme.rb create mode 100644 Examples/ruby/std_vector/Makefile create mode 100644 Examples/ruby/std_vector/example.h create mode 100644 Examples/ruby/std_vector/example.i create mode 100644 Examples/ruby/std_vector/runme.rb create mode 100644 Examples/ruby/template/Makefile create mode 100644 Examples/ruby/template/example.h create mode 100644 Examples/ruby/template/example.i create mode 100644 Examples/ruby/template/runme.rb create mode 100644 Examples/ruby/value/Makefile create mode 100644 Examples/ruby/value/example.c create mode 100644 Examples/ruby/value/example.h create mode 100644 Examples/ruby/value/example.i create mode 100644 Examples/ruby/value/index.html create mode 100644 Examples/ruby/value/runme.rb create mode 100644 Examples/ruby/variables/Makefile create mode 100644 Examples/ruby/variables/example.c create mode 100644 Examples/ruby/variables/example.h create mode 100644 Examples/ruby/variables/example.i create mode 100644 Examples/ruby/variables/index.html create mode 100644 Examples/ruby/variables/runme.rb create mode 100644 Examples/s-exp/uffi.lisp create mode 100644 Examples/tcl/check.list create mode 100644 Examples/tcl/class/Makefile create mode 100644 Examples/tcl/class/example.cxx create mode 100644 Examples/tcl/class/example.dsp create mode 100644 Examples/tcl/class/example.h create mode 100644 Examples/tcl/class/example.i create mode 100644 Examples/tcl/class/index.html create mode 100644 Examples/tcl/class/runme.tcl create mode 100644 Examples/tcl/class/runme2.tcl create mode 100644 Examples/tcl/constants/Makefile create mode 100644 Examples/tcl/constants/example.i create mode 100644 Examples/tcl/constants/index.html create mode 100644 Examples/tcl/constants/runme.tcl create mode 100644 Examples/tcl/contract/Makefile create mode 100644 Examples/tcl/contract/example.c create mode 100644 Examples/tcl/contract/example.dsp create mode 100644 Examples/tcl/contract/example.i create mode 100644 Examples/tcl/contract/runme.tcl create mode 100644 Examples/tcl/enum/Makefile create mode 100644 Examples/tcl/enum/example.cxx create mode 100644 Examples/tcl/enum/example.h create mode 100644 Examples/tcl/enum/example.i create mode 100644 Examples/tcl/enum/index.html create mode 100644 Examples/tcl/enum/runme.tcl create mode 100644 Examples/tcl/funcptr/Makefile create mode 100644 Examples/tcl/funcptr/example.c create mode 100644 Examples/tcl/funcptr/example.h create mode 100644 Examples/tcl/funcptr/example.i create mode 100644 Examples/tcl/funcptr/index.html create mode 100644 Examples/tcl/funcptr/runme.tcl create mode 100644 Examples/tcl/import/Makefile create mode 100644 Examples/tcl/import/README create mode 100644 Examples/tcl/import/bar.dsp create mode 100644 Examples/tcl/import/bar.h create mode 100644 Examples/tcl/import/bar.i create mode 100644 Examples/tcl/import/base.dsp create mode 100644 Examples/tcl/import/base.h create mode 100644 Examples/tcl/import/base.i create mode 100644 Examples/tcl/import/example.dsw create mode 100644 Examples/tcl/import/foo.dsp create mode 100644 Examples/tcl/import/foo.h create mode 100644 Examples/tcl/import/foo.i create mode 100644 Examples/tcl/import/runme.tcl create mode 100644 Examples/tcl/import/spam.dsp create mode 100644 Examples/tcl/import/spam.h create mode 100644 Examples/tcl/import/spam.i create mode 100644 Examples/tcl/index.html create mode 100644 Examples/tcl/java/Example.java create mode 100644 Examples/tcl/java/Makefile create mode 100644 Examples/tcl/java/example.i create mode 100644 Examples/tcl/java/runme.tcl create mode 100644 Examples/tcl/multimap/Makefile create mode 100644 Examples/tcl/multimap/example.c create mode 100644 Examples/tcl/multimap/example.dsp create mode 100644 Examples/tcl/multimap/example.i create mode 100644 Examples/tcl/multimap/runme.tcl create mode 100644 Examples/tcl/operator/Makefile create mode 100644 Examples/tcl/operator/example.h create mode 100644 Examples/tcl/operator/example.i create mode 100644 Examples/tcl/operator/runme.tcl create mode 100644 Examples/tcl/pointer/Makefile create mode 100644 Examples/tcl/pointer/example.c create mode 100644 Examples/tcl/pointer/example.i create mode 100644 Examples/tcl/pointer/index.html create mode 100644 Examples/tcl/pointer/runme.tcl create mode 100644 Examples/tcl/reference/Makefile create mode 100644 Examples/tcl/reference/example.cxx create mode 100644 Examples/tcl/reference/example.h create mode 100644 Examples/tcl/reference/example.i create mode 100644 Examples/tcl/reference/index.html create mode 100644 Examples/tcl/reference/runme.tcl create mode 100644 Examples/tcl/simple/Makefile create mode 100644 Examples/tcl/simple/example.c create mode 100644 Examples/tcl/simple/example.dsp create mode 100644 Examples/tcl/simple/example.i create mode 100644 Examples/tcl/simple/index.html create mode 100644 Examples/tcl/simple/runme.tcl create mode 100644 Examples/tcl/std_vector/Makefile create mode 100644 Examples/tcl/std_vector/example.h create mode 100644 Examples/tcl/std_vector/example.i create mode 100644 Examples/tcl/std_vector/runme.tcl create mode 100644 Examples/tcl/value/Makefile create mode 100644 Examples/tcl/value/example.c create mode 100644 Examples/tcl/value/example.h create mode 100644 Examples/tcl/value/example.i create mode 100644 Examples/tcl/value/index.html create mode 100644 Examples/tcl/value/runme.tcl create mode 100644 Examples/tcl/variables/Makefile create mode 100644 Examples/tcl/variables/example.c create mode 100644 Examples/tcl/variables/example.h create mode 100644 Examples/tcl/variables/example.i create mode 100644 Examples/tcl/variables/index.html create mode 100644 Examples/tcl/variables/runme.tcl create mode 100644 Examples/test-suite/README create mode 100644 Examples/test-suite/abstract_access.i create mode 100644 Examples/test-suite/abstract_inherit.i create mode 100644 Examples/test-suite/abstract_inherit_ok.i create mode 100644 Examples/test-suite/abstract_signature.i create mode 100644 Examples/test-suite/abstract_typedef.i create mode 100644 Examples/test-suite/abstract_typedef2.i create mode 100644 Examples/test-suite/abstract_virtual.i create mode 100644 Examples/test-suite/access_change.i create mode 100644 Examples/test-suite/add_link.i create mode 100644 Examples/test-suite/aggregate.i create mode 100644 Examples/test-suite/allegrocl/Makefile.in create mode 100644 Examples/test-suite/allowexcept.i create mode 100644 Examples/test-suite/allprotected.i create mode 100644 Examples/test-suite/anonymous_bitfield.i create mode 100644 Examples/test-suite/apply_signed_char.i create mode 100644 Examples/test-suite/apply_strings.i create mode 100644 Examples/test-suite/argcargvtest.i create mode 100644 Examples/test-suite/argout.i create mode 100644 Examples/test-suite/array_member.i create mode 100644 Examples/test-suite/array_typedef_memberin.i create mode 100644 Examples/test-suite/arrayref.i create mode 100644 Examples/test-suite/arrays.i create mode 100644 Examples/test-suite/arrays_dimensionless.i create mode 100644 Examples/test-suite/arrays_global.i create mode 100644 Examples/test-suite/arrays_global_twodim.i create mode 100644 Examples/test-suite/arrays_scope.i create mode 100644 Examples/test-suite/bloody_hell.i create mode 100644 Examples/test-suite/bools.i create mode 100644 Examples/test-suite/callback.i create mode 100644 Examples/test-suite/cast_operator.i create mode 100644 Examples/test-suite/casts.i create mode 100644 Examples/test-suite/catches.i create mode 100644 Examples/test-suite/cffi/Makefile.in create mode 100644 Examples/test-suite/char_constant.i create mode 100644 Examples/test-suite/char_strings.i create mode 100644 Examples/test-suite/chicken/Makefile.in create mode 100644 Examples/test-suite/chicken/README create mode 100644 Examples/test-suite/chicken/casts_runme.ss create mode 100644 Examples/test-suite/chicken/char_constant_runme.ss create mode 100644 Examples/test-suite/chicken/chicken_ext_test_runme.ss create mode 100644 Examples/test-suite/chicken/class_ignore_runme.ss create mode 100644 Examples/test-suite/chicken/clientdata_prop_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/constover_runme.ss create mode 100644 Examples/test-suite/chicken/contract_runme.ss create mode 100644 Examples/test-suite/chicken/cpp_basic_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/cpp_enum_runme.ss create mode 100644 Examples/test-suite/chicken/cpp_namespace_runme.ss create mode 100644 Examples/test-suite/chicken/dynamic_cast_runme.ss create mode 100644 Examples/test-suite/chicken/ext_test_external.cxx create mode 100644 Examples/test-suite/chicken/global_vars_runme.ss create mode 100644 Examples/test-suite/chicken/global_vars_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/import_nomodule_runme.ss create mode 100644 Examples/test-suite/chicken/imports_runme.ss create mode 100644 Examples/test-suite/chicken/inherit_missing_runme.ss create mode 100644 Examples/test-suite/chicken/li_std_string_runme.ss create mode 100644 Examples/test-suite/chicken/li_std_string_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/li_typemaps_runme.ss create mode 100644 Examples/test-suite/chicken/li_typemaps_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/list_vector_runme.ss create mode 100644 Examples/test-suite/chicken/member_pointer_runme.ss create mode 100644 Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/multivalue_runme.ss create mode 100644 Examples/test-suite/chicken/name_runme.ss create mode 100644 Examples/test-suite/chicken/newobject1_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/newobject2_runme.ss create mode 100644 Examples/test-suite/chicken/newobject2_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/overload_complicated_runme.ss create mode 100644 Examples/test-suite/chicken/overload_copy_runme.ss create mode 100644 Examples/test-suite/chicken/overload_copy_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/overload_extend_runme.ss create mode 100644 Examples/test-suite/chicken/overload_extend_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/overload_simple_runme.ss create mode 100644 Examples/test-suite/chicken/overload_simple_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/overload_subtype_runme.ss create mode 100644 Examples/test-suite/chicken/overload_subtype_runme_proxy.ss create mode 100644 Examples/test-suite/chicken/pointer_in_out_runme.ss create mode 100644 Examples/test-suite/chicken/reference_global_vars_runme.ss create mode 100644 Examples/test-suite/chicken/testsuite.ss create mode 100644 Examples/test-suite/chicken/throw_exception_runme.ss create mode 100644 Examples/test-suite/chicken/typedef_inherit_runme.ss create mode 100644 Examples/test-suite/chicken/typename_runme.ss create mode 100644 Examples/test-suite/chicken/unions_runme.ss create mode 100644 Examples/test-suite/chicken/unions_runme_proxy.ss create mode 100644 Examples/test-suite/chicken_ext_test.i create mode 100644 Examples/test-suite/class_ignore.i create mode 100644 Examples/test-suite/class_scope_weird.i create mode 100644 Examples/test-suite/clientdata_prop.list create mode 100644 Examples/test-suite/clientdata_prop_a.h create mode 100644 Examples/test-suite/clientdata_prop_a.i create mode 100644 Examples/test-suite/clientdata_prop_b.h create mode 100644 Examples/test-suite/clientdata_prop_b.i create mode 100644 Examples/test-suite/clisp/Makefile.in create mode 100644 Examples/test-suite/common.mk create mode 100644 Examples/test-suite/compactdefaultargs.i create mode 100644 Examples/test-suite/complextest.i create mode 100644 Examples/test-suite/const_const.i create mode 100644 Examples/test-suite/const_const_2.i create mode 100644 Examples/test-suite/constant_pointers.i create mode 100644 Examples/test-suite/constants.i create mode 100644 Examples/test-suite/constover.i create mode 100644 Examples/test-suite/constructor_copy.i create mode 100644 Examples/test-suite/constructor_exception.i create mode 100644 Examples/test-suite/constructor_explicit.i create mode 100644 Examples/test-suite/constructor_ignore.i create mode 100644 Examples/test-suite/constructor_value.i create mode 100644 Examples/test-suite/contract.i create mode 100644 Examples/test-suite/conversion.i create mode 100644 Examples/test-suite/conversion_namespace.i create mode 100644 Examples/test-suite/conversion_ns_template.i create mode 100644 Examples/test-suite/cplusplus_throw.i create mode 100644 Examples/test-suite/cpp_basic.i create mode 100644 Examples/test-suite/cpp_broken.i create mode 100644 Examples/test-suite/cpp_enum.i create mode 100644 Examples/test-suite/cpp_namespace.i create mode 100644 Examples/test-suite/cpp_nodefault.i create mode 100644 Examples/test-suite/cpp_static.i create mode 100644 Examples/test-suite/cpp_typedef.i create mode 100644 Examples/test-suite/csharp/Makefile.in create mode 100644 Examples/test-suite/csharp/README create mode 100644 Examples/test-suite/csharp/aggregate_runme.cs create mode 100644 Examples/test-suite/csharp/allprotected_runme.cs create mode 100644 Examples/test-suite/csharp/apply_strings_runme.cs create mode 100644 Examples/test-suite/csharp/bools_runme.cs create mode 100644 Examples/test-suite/csharp/catches_runme.cs create mode 100644 Examples/test-suite/csharp/char_strings_runme.cs create mode 100644 Examples/test-suite/csharp/constover_runme.cs create mode 100644 Examples/test-suite/csharp/csharp_attributes_runme.cs create mode 100644 Examples/test-suite/csharp/csharp_exceptions_runme.cs create mode 100644 Examples/test-suite/csharp/csharp_lib_arrays_runme.cs create mode 100644 Examples/test-suite/csharp/csharp_prepost_runme.cs create mode 100644 Examples/test-suite/csharp/csharp_typemaps_runme.cs create mode 100644 Examples/test-suite/csharp/default_args_runme.cs create mode 100644 Examples/test-suite/csharp/default_constructor_runme.cs create mode 100644 Examples/test-suite/csharp/director_basic_runme.cs create mode 100644 Examples/test-suite/csharp/director_classes_runme.cs create mode 100644 Examples/test-suite/csharp/director_classic_runme.cs create mode 100644 Examples/test-suite/csharp/director_ignore_runme.cs create mode 100644 Examples/test-suite/csharp/director_primitives_runme.cs create mode 100644 Examples/test-suite/csharp/director_protected_runme.cs create mode 100644 Examples/test-suite/csharp/director_string_runme.cs create mode 100644 Examples/test-suite/csharp/enum_thorough_runme.cs create mode 100644 Examples/test-suite/csharp/enum_thorough_simple_runme.cs create mode 100644 Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs create mode 100644 Examples/test-suite/csharp/exception_order_runme.cs create mode 100644 Examples/test-suite/csharp/imports_runme.cs create mode 100644 Examples/test-suite/csharp/inherit_target_language_runme.cs create mode 100644 Examples/test-suite/csharp/intermediary_classname_runme.cs create mode 100644 Examples/test-suite/csharp/li_attribute_runme.cs create mode 100644 Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs create mode 100644 Examples/test-suite/csharp/li_std_except_runme.cs create mode 100644 Examples/test-suite/csharp/li_std_map_runme.cs create mode 100644 Examples/test-suite/csharp/li_std_string_runme.cs create mode 100644 Examples/test-suite/csharp/li_std_vector_runme.cs create mode 100644 Examples/test-suite/csharp/li_std_wstring_runme.cs create mode 100644 Examples/test-suite/csharp/li_typemaps_runme.cs create mode 100644 Examples/test-suite/csharp/long_long_runme.cs create mode 100644 Examples/test-suite/csharp/member_pointer_runme.cs create mode 100644 Examples/test-suite/csharp/operator_overload_runme.cs create mode 100644 Examples/test-suite/csharp/overload_complicated_runme.cs create mode 100644 Examples/test-suite/csharp/overload_template_runme.cs create mode 100644 Examples/test-suite/csharp/pointer_reference_runme.cs create mode 100644 Examples/test-suite/csharp/sizet_runme.cs create mode 100644 Examples/test-suite/csharp/sneaky1_runme.cs create mode 100644 Examples/test-suite/csharp/special_variable_macros_runme.cs create mode 100644 Examples/test-suite/csharp/threads_runme.cs create mode 100644 Examples/test-suite/csharp/throw_exception_runme.cs create mode 100644 Examples/test-suite/csharp/typemap_namespace_runme.cs create mode 100644 Examples/test-suite/csharp/typemap_out_optimal_runme.cs create mode 100644 Examples/test-suite/csharp/varargs_runme.cs create mode 100644 Examples/test-suite/csharp/virtual_poly_runme.cs create mode 100644 Examples/test-suite/csharp_attributes.i create mode 100644 Examples/test-suite/csharp_exceptions.i create mode 100644 Examples/test-suite/csharp_features.i create mode 100644 Examples/test-suite/csharp_lib_arrays.i create mode 100644 Examples/test-suite/csharp_prepost.i create mode 100644 Examples/test-suite/csharp_typemaps.i create mode 100644 Examples/test-suite/default_args.i create mode 100644 Examples/test-suite/default_constructor.i create mode 100644 Examples/test-suite/defvalue_constructor.i create mode 100644 Examples/test-suite/derived_byvalue.i create mode 100644 Examples/test-suite/derived_nested.i create mode 100644 Examples/test-suite/destructor_reprotected.i create mode 100644 Examples/test-suite/director_abstract.i create mode 100644 Examples/test-suite/director_basic.i create mode 100644 Examples/test-suite/director_classes.i create mode 100644 Examples/test-suite/director_classic.i create mode 100644 Examples/test-suite/director_constructor.i create mode 100644 Examples/test-suite/director_default.i create mode 100644 Examples/test-suite/director_detect.i create mode 100644 Examples/test-suite/director_enum.i create mode 100644 Examples/test-suite/director_exception.i create mode 100644 Examples/test-suite/director_extend.i create mode 100644 Examples/test-suite/director_finalizer.i create mode 100644 Examples/test-suite/director_frob.i create mode 100644 Examples/test-suite/director_ignore.i create mode 100644 Examples/test-suite/director_namespace_clash.i create mode 100644 Examples/test-suite/director_nested.i create mode 100644 Examples/test-suite/director_overload.i create mode 100644 Examples/test-suite/director_primitives.i create mode 100644 Examples/test-suite/director_profile.i create mode 100644 Examples/test-suite/director_protected.i create mode 100644 Examples/test-suite/director_protected_overloaded.i create mode 100644 Examples/test-suite/director_redefined.i create mode 100644 Examples/test-suite/director_stl.i create mode 100644 Examples/test-suite/director_string.i create mode 100644 Examples/test-suite/director_thread.i create mode 100644 Examples/test-suite/director_unroll.i create mode 100644 Examples/test-suite/director_using.i create mode 100644 Examples/test-suite/director_wombat.i create mode 100644 Examples/test-suite/director_wstring.i create mode 100644 Examples/test-suite/disown.i create mode 100644 Examples/test-suite/dynamic_cast.i create mode 100644 Examples/test-suite/empty.i create mode 100644 Examples/test-suite/enum_plus.i create mode 100644 Examples/test-suite/enum_scope_template.i create mode 100644 Examples/test-suite/enum_template.i create mode 100644 Examples/test-suite/enum_thorough.i create mode 100644 Examples/test-suite/enum_thorough_proper.i create mode 100644 Examples/test-suite/enum_thorough_simple.i create mode 100644 Examples/test-suite/enum_thorough_typesafe.i create mode 100644 Examples/test-suite/enum_thorough_typeunsafe.i create mode 100644 Examples/test-suite/enum_var.i create mode 100644 Examples/test-suite/enums.i create mode 100644 Examples/test-suite/errors/c_bad_name.i create mode 100644 Examples/test-suite/errors/c_bad_native.i create mode 100644 Examples/test-suite/errors/c_class.i create mode 100644 Examples/test-suite/errors/c_default_error.i create mode 100644 Examples/test-suite/errors/c_deprecated.i create mode 100644 Examples/test-suite/errors/c_empty_char.i create mode 100644 Examples/test-suite/errors/c_enum_badvalue.i create mode 100644 Examples/test-suite/errors/c_extra_rblock.i create mode 100644 Examples/test-suite/errors/c_extra_rbrace.i create mode 100644 Examples/test-suite/errors/c_extra_unsigned.i create mode 100644 Examples/test-suite/errors/c_insert_missing.i create mode 100644 Examples/test-suite/errors/c_long_short.i create mode 100644 Examples/test-suite/errors/c_missing_rbrace.i create mode 100644 Examples/test-suite/errors/c_missing_semi.i create mode 100644 Examples/test-suite/errors/c_redefine.i create mode 100644 Examples/test-suite/errors/c_varargs.i create mode 100644 Examples/test-suite/errors/c_varargs_neg.i create mode 100644 Examples/test-suite/errors/cpp_bad_extern.i create mode 100644 Examples/test-suite/errors/cpp_extend_redefine.i create mode 100644 Examples/test-suite/errors/cpp_extend_undefined.i create mode 100644 Examples/test-suite/errors/cpp_inline_namespace.i create mode 100644 Examples/test-suite/errors/cpp_missing_rtemplate.i create mode 100644 Examples/test-suite/errors/cpp_namespace_alias.i create mode 100644 Examples/test-suite/errors/cpp_namespace_aliasnot.i create mode 100644 Examples/test-suite/errors/cpp_namespace_aliasundef.i create mode 100644 Examples/test-suite/errors/cpp_nested.i create mode 100644 Examples/test-suite/errors/cpp_no_access.i create mode 100644 Examples/test-suite/errors/cpp_nobase.i create mode 100644 Examples/test-suite/errors/cpp_overload.i create mode 100644 Examples/test-suite/errors/cpp_private_defvalue.i create mode 100644 Examples/test-suite/errors/cpp_private_inherit.i create mode 100644 Examples/test-suite/errors/cpp_template_argname.i create mode 100644 Examples/test-suite/errors/cpp_template_nargs.i create mode 100644 Examples/test-suite/errors/cpp_template_not.i create mode 100644 Examples/test-suite/errors/cpp_template_partial.i create mode 100644 Examples/test-suite/errors/cpp_template_repeat.i create mode 100644 Examples/test-suite/errors/cpp_template_undef.i create mode 100644 Examples/test-suite/errors/cpp_using_not.i create mode 100644 Examples/test-suite/errors/cpp_using_undef.i create mode 100755 Examples/test-suite/errors/make.sh create mode 100644 Examples/test-suite/errors/nomodule.i create mode 100644 Examples/test-suite/errors/pp_badeval.i create mode 100644 Examples/test-suite/errors/pp_defined.i create mode 100644 Examples/test-suite/errors/pp_macro_args.i create mode 100644 Examples/test-suite/errors/pp_macro_badchar.i create mode 100644 Examples/test-suite/errors/pp_macro_nargs.i create mode 100644 Examples/test-suite/errors/pp_macro_redef.i create mode 100644 Examples/test-suite/errors/pp_macro_rparen.i create mode 100644 Examples/test-suite/errors/pp_macro_unterminated.i create mode 100644 Examples/test-suite/errors/pp_misplaced_elif.i create mode 100644 Examples/test-suite/errors/pp_misplaced_else.i create mode 100644 Examples/test-suite/errors/pp_missing_enddef.i create mode 100644 Examples/test-suite/errors/pp_missing_endif.i create mode 100644 Examples/test-suite/errors/pp_missing_file.i create mode 100644 Examples/test-suite/errors/pp_missing_rblock.i create mode 100644 Examples/test-suite/errors/pp_unterm_char.i create mode 100644 Examples/test-suite/errors/pp_unterm_comment.i create mode 100644 Examples/test-suite/errors/pp_unterm_string.i create mode 100644 Examples/test-suite/errors/swig_apply_nargs.i create mode 100644 Examples/test-suite/errors/swig_identifier.i create mode 100644 Examples/test-suite/errors/swig_insert_bad.i create mode 100644 Examples/test-suite/errors/swig_typemap_copy.i create mode 100644 Examples/test-suite/errors/swig_typemap_old.i create mode 100644 Examples/test-suite/evil_diamond.i create mode 100644 Examples/test-suite/evil_diamond_ns.i create mode 100644 Examples/test-suite/evil_diamond_prop.i create mode 100644 Examples/test-suite/exception_order.i create mode 100644 Examples/test-suite/exception_partial_info.i create mode 100644 Examples/test-suite/extend.i create mode 100644 Examples/test-suite/extend_default.i create mode 100644 Examples/test-suite/extend_placement.i create mode 100644 Examples/test-suite/extend_template.i create mode 100644 Examples/test-suite/extend_template_ns.i create mode 100644 Examples/test-suite/extend_variable.i create mode 100644 Examples/test-suite/extern_declaration.i create mode 100644 Examples/test-suite/extern_namespace.i create mode 100644 Examples/test-suite/extern_throws.i create mode 100644 Examples/test-suite/features.i create mode 100644 Examples/test-suite/file_test.i create mode 100644 Examples/test-suite/fragments.i create mode 100644 Examples/test-suite/friends.i create mode 100644 Examples/test-suite/funcptr.i create mode 100644 Examples/test-suite/function_typedef.i create mode 100644 Examples/test-suite/fvirtual.i create mode 100644 Examples/test-suite/global_namespace.i create mode 100644 Examples/test-suite/global_ns_arg.i create mode 100644 Examples/test-suite/global_vars.i create mode 100644 Examples/test-suite/grouping.i create mode 100644 Examples/test-suite/guile/Makefile.in create mode 100644 Examples/test-suite/guile/README create mode 100644 Examples/test-suite/guile/casts_runme.scm create mode 100644 Examples/test-suite/guile/char_constant_runme.scm create mode 100644 Examples/test-suite/guile/class_ignore_runme.scm create mode 100644 Examples/test-suite/guile/constover_runme.scm create mode 100644 Examples/test-suite/guile/contract_runme.scm create mode 100644 Examples/test-suite/guile/cpp_enum_runme.scm create mode 100644 Examples/test-suite/guile/cpp_namespace_runme.scm create mode 100644 Examples/test-suite/guile/dynamic_cast_runme.scm create mode 100644 Examples/test-suite/guile/import_nomodule_runme.scm create mode 100644 Examples/test-suite/guile/imports_runme.scm create mode 100644 Examples/test-suite/guile/inherit_missing_runme.scm create mode 100644 Examples/test-suite/guile/integers_runme.scm create mode 100644 Examples/test-suite/guile/li_std_string_runme.scm create mode 100644 Examples/test-suite/guile/li_typemaps_runme.scm create mode 100644 Examples/test-suite/guile/list_vector_runme.scm create mode 100644 Examples/test-suite/guile/multivalue_runme.scm create mode 100644 Examples/test-suite/guile/name_runme.scm create mode 100644 Examples/test-suite/guile/overload_complicated_runme.scm create mode 100644 Examples/test-suite/guile/overload_copy_runme.scm create mode 100644 Examples/test-suite/guile/overload_extend_runme.scm create mode 100644 Examples/test-suite/guile/overload_simple_runme.scm create mode 100644 Examples/test-suite/guile/overload_subtype_runme.scm create mode 100644 Examples/test-suite/guile/pointer_in_out_runme.scm create mode 100644 Examples/test-suite/guile/reference_global_vars_runme.scm create mode 100644 Examples/test-suite/guile/testsuite.scm create mode 100644 Examples/test-suite/guile/throw_exception_runme.scm create mode 100644 Examples/test-suite/guile/typedef_inherit_runme.scm create mode 100644 Examples/test-suite/guile/typename_runme.scm create mode 100644 Examples/test-suite/guile/unions_runme.scm create mode 100644 Examples/test-suite/guilescm/Makefile.in create mode 100644 Examples/test-suite/guilescm/ext_test_external.cxx create mode 100644 Examples/test-suite/guilescm/guilescm_ext_test_runme.scm create mode 100644 Examples/test-suite/guilescm_ext_test.i create mode 100644 Examples/test-suite/iadd.i create mode 100644 Examples/test-suite/ignore_parameter.i create mode 100644 Examples/test-suite/ignore_template_constructor.i create mode 100644 Examples/test-suite/immutable.i create mode 100644 Examples/test-suite/implicittest.i create mode 100644 Examples/test-suite/import_nomodule.h create mode 100644 Examples/test-suite/import_nomodule.i create mode 100644 Examples/test-suite/imports.list create mode 100644 Examples/test-suite/imports_a.h create mode 100644 Examples/test-suite/imports_a.i create mode 100644 Examples/test-suite/imports_b.h create mode 100644 Examples/test-suite/imports_b.i create mode 100644 Examples/test-suite/inctest.h create mode 100644 Examples/test-suite/inctest.i create mode 100644 Examples/test-suite/inherit.i create mode 100644 Examples/test-suite/inherit_missing.i create mode 100644 Examples/test-suite/inherit_same_name.i create mode 100644 Examples/test-suite/inherit_target_language.i create mode 100644 Examples/test-suite/inherit_void_arg.i create mode 100644 Examples/test-suite/inline_initializer.i create mode 100644 Examples/test-suite/inout.i create mode 100644 Examples/test-suite/inplaceadd.i create mode 100644 Examples/test-suite/input.i create mode 100644 Examples/test-suite/insert_directive.i create mode 100644 Examples/test-suite/integers.i create mode 100644 Examples/test-suite/intermediary_classname.i create mode 100644 Examples/test-suite/java/Makefile.in create mode 100644 Examples/test-suite/java/README create mode 100644 Examples/test-suite/java/aggregate_runme.java create mode 100644 Examples/test-suite/java/allprotected_runme.java create mode 100644 Examples/test-suite/java/apply_signed_char_runme.java create mode 100644 Examples/test-suite/java/apply_strings_runme.java create mode 100644 Examples/test-suite/java/array_member_runme.java create mode 100644 Examples/test-suite/java/arrays_global_twodim_runme.java create mode 100644 Examples/test-suite/java/char_strings_runme.java create mode 100644 Examples/test-suite/java/cpp_typedef_runme.java create mode 100644 Examples/test-suite/java/default_args_runme.java create mode 100644 Examples/test-suite/java/default_constructor_runme.java create mode 100644 Examples/test-suite/java/director_abstract_runme.java create mode 100644 Examples/test-suite/java/director_basic_runme.java create mode 100644 Examples/test-suite/java/director_classes_runme.java create mode 100644 Examples/test-suite/java/director_classic_runme.java create mode 100644 Examples/test-suite/java/director_default_runme.java create mode 100644 Examples/test-suite/java/director_enum_runme.java create mode 100644 Examples/test-suite/java/director_exception_runme.java create mode 100644 Examples/test-suite/java/director_frob_runme.java create mode 100644 Examples/test-suite/java/director_ignore_runme.java create mode 100644 Examples/test-suite/java/director_primitives_runme.java create mode 100644 Examples/test-suite/java/director_protected_runme.java create mode 100644 Examples/test-suite/java/director_string_runme.java create mode 100644 Examples/test-suite/java/director_thread_runme.java create mode 100644 Examples/test-suite/java/director_unroll_runme.java create mode 100644 Examples/test-suite/java/director_wombat_runme.java create mode 100644 Examples/test-suite/java/dynamic_cast_runme.java create mode 100644 Examples/test-suite/java/enum_thorough_proper_runme.java create mode 100644 Examples/test-suite/java/enum_thorough_runme.java create mode 100644 Examples/test-suite/java/enum_thorough_simple_runme.java create mode 100644 Examples/test-suite/java/enum_thorough_typeunsafe_runme.java create mode 100644 Examples/test-suite/java/extend_default_runme.java create mode 100644 Examples/test-suite/java/extern_declaration_runme.java create mode 100644 Examples/test-suite/java/global_namespace_runme.java create mode 100644 Examples/test-suite/java/ignore_parameter_runme.java create mode 100644 Examples/test-suite/java/imports_runme.java create mode 100644 Examples/test-suite/java/inctest_runme.java create mode 100644 Examples/test-suite/java/inherit_target_language_runme.java create mode 100644 Examples/test-suite/java/intermediary_classname_runme.java create mode 100644 Examples/test-suite/java/java_constants_runme.java create mode 100644 Examples/test-suite/java/java_director_runme.java create mode 100644 Examples/test-suite/java/java_enums_runme.java create mode 100644 Examples/test-suite/java/java_jnitypes_runme.java create mode 100644 Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java create mode 100644 Examples/test-suite/java/java_lib_arrays_runme.java create mode 100644 Examples/test-suite/java/java_lib_various_runme.java create mode 100644 Examples/test-suite/java/java_pgcpp_runme.java create mode 100644 Examples/test-suite/java/java_pragmas_runme.java create mode 100644 Examples/test-suite/java/java_prepost_runme.java create mode 100644 Examples/test-suite/java/java_throws_runme.java create mode 100644 Examples/test-suite/java/java_typemaps_proxy_runme.java create mode 100644 Examples/test-suite/java/java_typemaps_typewrapper_runme.java create mode 100644 Examples/test-suite/java/li_boost_intrusive_ptr_runme.java create mode 100644 Examples/test-suite/java/li_boost_shared_ptr_runme.java create mode 100644 Examples/test-suite/java/li_carrays_runme.java create mode 100644 Examples/test-suite/java/li_std_except_runme.java create mode 100644 Examples/test-suite/java/li_std_string_runme.java create mode 100644 Examples/test-suite/java/li_std_vector_runme.java create mode 100644 Examples/test-suite/java/li_typemaps_runme.java create mode 100644 Examples/test-suite/java/long_long_runme.java create mode 100644 Examples/test-suite/java/member_pointer_runme.java create mode 100644 Examples/test-suite/java/memberin_extend_runme.java create mode 100644 Examples/test-suite/java/minherit2_runme.java create mode 100644 Examples/test-suite/java/multiple_inheritance_runme.java create mode 100644 Examples/test-suite/java/operator_overload_runme.java create mode 100644 Examples/test-suite/java/overload_complicated_runme.java create mode 100644 Examples/test-suite/java/overload_template_runme.java create mode 100644 Examples/test-suite/java/pointer_reference_runme.java create mode 100644 Examples/test-suite/java/primitive_ref_runme.java create mode 100644 Examples/test-suite/java/profiletest_runme.java create mode 100644 Examples/test-suite/java/rename1_runme.java create mode 100644 Examples/test-suite/java/rename2_runme.java create mode 100644 Examples/test-suite/java/rename3_runme.java create mode 100644 Examples/test-suite/java/rename4_runme.java create mode 100644 Examples/test-suite/java/ret_by_value_runme.java create mode 100644 Examples/test-suite/java/rname_runme.java create mode 100644 Examples/test-suite/java/sizet_runme.java create mode 100644 Examples/test-suite/java/special_variable_macros_runme.java create mode 100644 Examples/test-suite/java/special_variables_runme.java create mode 100644 Examples/test-suite/java/template_classes_runme.java create mode 100644 Examples/test-suite/java/template_default_arg_runme.java create mode 100644 Examples/test-suite/java/template_default_class_parms_runme.java create mode 100644 Examples/test-suite/java/template_methods_runme.java create mode 100644 Examples/test-suite/java/template_template_parameters_runme.java create mode 100644 Examples/test-suite/java/typemap_namespace_runme.java create mode 100644 Examples/test-suite/java/typemap_out_optimal_runme.java create mode 100644 Examples/test-suite/java/unions_runme.java create mode 100644 Examples/test-suite/java/using_pointers_runme.java create mode 100644 Examples/test-suite/java/varargs_runme.java create mode 100644 Examples/test-suite/java/virtual_poly_runme.java create mode 100644 Examples/test-suite/java/wallkw_runme.java create mode 100644 Examples/test-suite/java_constants.i create mode 100644 Examples/test-suite/java_director.i create mode 100644 Examples/test-suite/java_enums.i create mode 100644 Examples/test-suite/java_jnitypes.i create mode 100644 Examples/test-suite/java_lib_arrays.i create mode 100644 Examples/test-suite/java_lib_arrays_dimensionless.i create mode 100644 Examples/test-suite/java_lib_various.i create mode 100644 Examples/test-suite/java_pgcpp.i create mode 100644 Examples/test-suite/java_pragmas.i create mode 100644 Examples/test-suite/java_prepost.i create mode 100644 Examples/test-suite/java_throws.i create mode 100644 Examples/test-suite/java_typemaps_proxy.i create mode 100644 Examples/test-suite/java_typemaps_typewrapper.i create mode 100644 Examples/test-suite/keyword_rename.i create mode 100644 Examples/test-suite/kind.i create mode 100644 Examples/test-suite/langobj.i create mode 100644 Examples/test-suite/lextype.i create mode 100644 Examples/test-suite/li_attribute.i create mode 100644 Examples/test-suite/li_boost_intrusive_ptr.i create mode 100644 Examples/test-suite/li_boost_shared_ptr.i create mode 100644 Examples/test-suite/li_boost_shared_ptr_bits.i create mode 100644 Examples/test-suite/li_carrays.i create mode 100644 Examples/test-suite/li_cdata.i create mode 100644 Examples/test-suite/li_cdata_carrays.i create mode 100644 Examples/test-suite/li_cmalloc.i create mode 100644 Examples/test-suite/li_constraints.i create mode 100644 Examples/test-suite/li_cpointer.i create mode 100644 Examples/test-suite/li_cstring.i create mode 100644 Examples/test-suite/li_cwstring.i create mode 100644 Examples/test-suite/li_factory.i create mode 100644 Examples/test-suite/li_implicit.i create mode 100644 Examples/test-suite/li_math.i create mode 100644 Examples/test-suite/li_reference.i create mode 100644 Examples/test-suite/li_std_carray.i create mode 100644 Examples/test-suite/li_std_combinations.i create mode 100644 Examples/test-suite/li_std_deque.i create mode 100644 Examples/test-suite/li_std_except.i create mode 100644 Examples/test-suite/li_std_functors.i create mode 100644 Examples/test-suite/li_std_list.i create mode 100644 Examples/test-suite/li_std_map.i create mode 100644 Examples/test-suite/li_std_multimap.i create mode 100644 Examples/test-suite/li_std_pair.i create mode 100644 Examples/test-suite/li_std_pair_extra.i create mode 100644 Examples/test-suite/li_std_pair_lang_object.i create mode 100644 Examples/test-suite/li_std_queue.i create mode 100644 Examples/test-suite/li_std_set.i create mode 100644 Examples/test-suite/li_std_stack.i create mode 100644 Examples/test-suite/li_std_stream.i create mode 100644 Examples/test-suite/li_std_string.i create mode 100644 Examples/test-suite/li_std_string_extra.i create mode 100644 Examples/test-suite/li_std_vector.i create mode 100644 Examples/test-suite/li_std_vector_extra.i create mode 100644 Examples/test-suite/li_std_vector_ptr.i create mode 100644 Examples/test-suite/li_std_vectora.i create mode 100644 Examples/test-suite/li_std_wstream.i create mode 100644 Examples/test-suite/li_std_wstring.i create mode 100644 Examples/test-suite/li_stdint.i create mode 100644 Examples/test-suite/li_typemaps.i create mode 100644 Examples/test-suite/li_windows.i create mode 100644 Examples/test-suite/list_vector.i create mode 100644 Examples/test-suite/long_long.i create mode 100644 Examples/test-suite/long_long_apply.i create mode 100644 Examples/test-suite/lua/Makefile.in create mode 100644 Examples/test-suite/lua/abstract_access_runme.lua create mode 100644 Examples/test-suite/lua/cpp_basic_runme.lua create mode 100644 Examples/test-suite/lua/disown_runme.lua create mode 100644 Examples/test-suite/lua/dynamic_cast_runme.lua create mode 100644 Examples/test-suite/lua/enums_runme.lua create mode 100644 Examples/test-suite/lua/exception_order_runme.lua create mode 100644 Examples/test-suite/lua/exception_partial_info_runme.lua create mode 100644 Examples/test-suite/lua/import.lua create mode 100644 Examples/test-suite/lua/import_nomodule_runme.lua create mode 100644 Examples/test-suite/lua/imports_runme.lua create mode 100644 Examples/test-suite/lua/li_carrays_runme.lua create mode 100644 Examples/test-suite/lua/li_std_except_runme.lua create mode 100644 Examples/test-suite/lua/li_std_pair_runme.lua create mode 100644 Examples/test-suite/lua/li_std_string_runme.lua create mode 100644 Examples/test-suite/lua/li_std_vector_runme.lua create mode 100644 Examples/test-suite/lua/li_typemaps_runme.lua create mode 100644 Examples/test-suite/lua/member_pointer_runme.lua create mode 100644 Examples/test-suite/lua/multi_import_runme.lua create mode 100644 Examples/test-suite/lua/newobject1_runme.lua create mode 100644 Examples/test-suite/lua/newobject2_runme.lua create mode 100644 Examples/test-suite/lua/operator_overload_runme.lua create mode 100644 Examples/test-suite/lua/overload_simple_runme.lua create mode 100644 Examples/test-suite/lua/overload_template_fast_runme.lua create mode 100644 Examples/test-suite/lua/overload_template_runme.lua create mode 100644 Examples/test-suite/lua/pointer_reference_runme.lua create mode 100644 Examples/test-suite/lua/primitive_ref_runme.lua create mode 100644 Examples/test-suite/lua/ret_by_value_runme.lua create mode 100644 Examples/test-suite/lua/sizet_runme.lua create mode 100644 Examples/test-suite/lua/smart_pointer_overload_runme.lua create mode 100644 Examples/test-suite/lua/template_default_arg_runme.lua create mode 100644 Examples/test-suite/lua/voidtest_runme.lua create mode 100644 Examples/test-suite/member_pointer.i create mode 100644 Examples/test-suite/member_template.i create mode 100644 Examples/test-suite/memberin1.i create mode 100644 Examples/test-suite/memberin_extend.i create mode 100644 Examples/test-suite/minherit.i create mode 100644 Examples/test-suite/minherit2.i create mode 100644 Examples/test-suite/mixed_types.i create mode 100644 Examples/test-suite/mod.h create mode 100644 Examples/test-suite/mod.list create mode 100644 Examples/test-suite/mod_a.i create mode 100644 Examples/test-suite/mod_b.i create mode 100644 Examples/test-suite/multi_import.h create mode 100644 Examples/test-suite/multi_import.list create mode 100644 Examples/test-suite/multi_import_a.i create mode 100644 Examples/test-suite/multi_import_b.i create mode 100644 Examples/test-suite/multi_import_c.i create mode 100644 Examples/test-suite/multiple_inheritance.i create mode 100644 Examples/test-suite/multivalue.i create mode 100644 Examples/test-suite/mzscheme/Makefile.in create mode 100644 Examples/test-suite/mzscheme/README create mode 100644 Examples/test-suite/mzscheme/casts_runme.scm create mode 100644 Examples/test-suite/mzscheme/char_constant_runme.scm create mode 100644 Examples/test-suite/mzscheme/imports_runme.scm create mode 100644 Examples/test-suite/mzscheme/integers_runme.scm create mode 100644 Examples/test-suite/mzscheme/name_runme.scm create mode 100644 Examples/test-suite/mzscheme/unions_runme.scm create mode 100644 Examples/test-suite/name.i create mode 100644 Examples/test-suite/name_cxx.i create mode 100644 Examples/test-suite/name_warnings.i create mode 100644 Examples/test-suite/namespace_class.i create mode 100644 Examples/test-suite/namespace_enum.i create mode 100644 Examples/test-suite/namespace_extend.i create mode 100644 Examples/test-suite/namespace_nested.i create mode 100644 Examples/test-suite/namespace_spaces.i create mode 100644 Examples/test-suite/namespace_template.i create mode 100644 Examples/test-suite/namespace_typedef_class.i create mode 100644 Examples/test-suite/namespace_typemap.i create mode 100644 Examples/test-suite/namespace_union.i create mode 100644 Examples/test-suite/namespace_virtual_method.i create mode 100644 Examples/test-suite/naturalvar.i create mode 100644 Examples/test-suite/nested.i create mode 100644 Examples/test-suite/nested_comment.i create mode 100644 Examples/test-suite/nested_structs.i create mode 100644 Examples/test-suite/newobject1.i create mode 100644 Examples/test-suite/newobject2.i create mode 100644 Examples/test-suite/null_pointer.i create mode 100644 Examples/test-suite/ocaml/Makefile.in create mode 100644 Examples/test-suite/ocaml/README create mode 100644 Examples/test-suite/ocaml/class_ignore_runme.ml create mode 100644 Examples/test-suite/ocaml/imports_runme.ml create mode 100755 Examples/test-suite/ocaml/makedebugtop create mode 100644 Examples/test-suite/ocaml/minherit_runme.ml create mode 100644 Examples/test-suite/ocaml/name_runme.ml create mode 100644 Examples/test-suite/ocaml/newobject1_runme.ml create mode 100644 Examples/test-suite/ocaml/overload_copy_runme.ml create mode 100644 Examples/test-suite/ocaml/sneaky1_runme.ml create mode 100644 Examples/test-suite/ocaml/throw_exception_runme.ml create mode 100644 Examples/test-suite/ocaml/typedef_mptr_runme.ml create mode 100644 Examples/test-suite/ocaml/typename_runme.ml create mode 100644 Examples/test-suite/ocaml/unions_runme.ml create mode 100644 Examples/test-suite/ocaml/using_protected_runme.ml create mode 100644 Examples/test-suite/ocaml/varargs_runme.ml create mode 100644 Examples/test-suite/ocaml/voidtest_runme.ml create mode 100644 Examples/test-suite/octave/Makefile.in create mode 100644 Examples/test-suite/octave/abstract_access_runme.m create mode 100644 Examples/test-suite/octave/abstract_typedef2_runme.m create mode 100644 Examples/test-suite/octave/abstract_typedef_runme.m create mode 100644 Examples/test-suite/octave/abstract_virtual_runme.m create mode 100644 Examples/test-suite/octave/argcargvtest_runme.m create mode 100644 Examples/test-suite/octave/array_member_runme.m create mode 100644 Examples/test-suite/octave/arrays_global_runme.m create mode 100644 Examples/test-suite/octave/callback_runme.m create mode 100644 Examples/test-suite/octave/class_ignore_runme.m create mode 100644 Examples/test-suite/octave/class_scope_weird_runme.m create mode 100644 Examples/test-suite/octave/compactdefaultargs_runme.m create mode 100644 Examples/test-suite/octave/complextest_runme.m create mode 100644 Examples/test-suite/octave/constover_runme.m create mode 100644 Examples/test-suite/octave/constructor_copy_runme.m create mode 100644 Examples/test-suite/octave/contract_runme.m create mode 100644 Examples/test-suite/octave/cpp_enum_runme.m create mode 100644 Examples/test-suite/octave/cpp_namespace_runme.m create mode 100644 Examples/test-suite/octave/default_args_runme.m create mode 100644 Examples/test-suite/octave/default_constructor_runme.m create mode 100644 Examples/test-suite/octave/director_abstract_runme.m create mode 100644 Examples/test-suite/octave/director_basic_runme.m create mode 100644 Examples/test-suite/octave/director_classic_runme.m create mode 100644 Examples/test-suite/octave/director_default_runme.m create mode 100644 Examples/test-suite/octave/director_detect_runme.m create mode 100644 Examples/test-suite/octave/director_enum_runme.m create mode 100644 Examples/test-suite/octave/director_extend_runme.m create mode 100644 Examples/test-suite/octave/director_frob_runme.m create mode 100644 Examples/test-suite/octave/director_nested_runme.m create mode 100644 Examples/test-suite/octave/director_stl_runme.m create mode 100644 Examples/test-suite/octave/director_string_runme.m create mode 100644 Examples/test-suite/octave/director_unroll_runme.m create mode 100644 Examples/test-suite/octave/director_wstring_runme.m create mode 100644 Examples/test-suite/octave/dynamic_cast_runme.m create mode 100644 Examples/test-suite/octave/empty_runme.m create mode 100644 Examples/test-suite/octave/enum_template_runme.m create mode 100644 Examples/test-suite/octave/enums_runme.m create mode 100644 Examples/test-suite/octave/exception_order_runme.m create mode 100644 Examples/test-suite/octave/extend_placement_runme.m create mode 100644 Examples/test-suite/octave/extend_template_ns_runme.m create mode 100644 Examples/test-suite/octave/extend_template_runme.m create mode 100644 Examples/test-suite/octave/extend_variable_runme.m create mode 100644 Examples/test-suite/octave/file_test_runme.m create mode 100644 Examples/test-suite/octave/friends_runme.m create mode 100644 Examples/test-suite/octave/fvirtual_runme.m create mode 100644 Examples/test-suite/octave/global_ns_arg_runme.m create mode 100644 Examples/test-suite/octave/grouping_runme.m create mode 100755 Examples/test-suite/octave/iadd_runme.m create mode 100644 Examples/test-suite/octave/import_nomodule_runme.m create mode 100644 Examples/test-suite/octave/imports_runme.m create mode 100644 Examples/test-suite/octave/inctest_runme.m create mode 100644 Examples/test-suite/octave/inherit_missing_runme.m create mode 100644 Examples/test-suite/octave/inout_runme.m create mode 100644 Examples/test-suite/octave/inplaceadd_runme.m create mode 100644 Examples/test-suite/octave/input_runme.m create mode 100644 Examples/test-suite/octave/li_attribute_runme.m create mode 100644 Examples/test-suite/octave/li_boost_shared_ptr_runme.m create mode 100644 Examples/test-suite/octave/li_carrays_runme.m create mode 100644 Examples/test-suite/octave/li_cmalloc_runme.m create mode 100644 Examples/test-suite/octave/li_cpointer_runme.m create mode 100644 Examples/test-suite/octave/li_cstring_runme.m create mode 100644 Examples/test-suite/octave/li_cwstring_runme.m create mode 100644 Examples/test-suite/octave/li_factory_runme.m create mode 100644 Examples/test-suite/octave/li_implicit_runme.m create mode 100644 Examples/test-suite/octave/li_std_carray_runme.m create mode 100644 Examples/test-suite/octave/li_std_map_runme.m create mode 100644 Examples/test-suite/octave/li_std_pair_extra_runme.m create mode 100644 Examples/test-suite/octave/li_std_set_runme.m create mode 100644 Examples/test-suite/octave/li_std_stream_runme.m create mode 100644 Examples/test-suite/octave/li_std_string_extra_runme.m create mode 100644 Examples/test-suite/octave/li_std_vector_runme.m create mode 100644 Examples/test-suite/octave/li_std_wstream_runme.m create mode 100644 Examples/test-suite/octave/li_std_wstring_runme.m create mode 100644 Examples/test-suite/octave/member_pointer_runme.m create mode 100644 Examples/test-suite/octave/minherit_runme.m create mode 100644 Examples/test-suite/octave/mod_runme.m create mode 100644 Examples/test-suite/octave/multi_import_runme.m create mode 100644 Examples/test-suite/octave/namespace_class_runme.m create mode 100644 Examples/test-suite/octave/namespace_typemap_runme.m create mode 100644 Examples/test-suite/octave/namespace_virtual_method_runme.m create mode 100644 Examples/test-suite/octave/naturalvar_runme.m create mode 100644 Examples/test-suite/octave/nondynamic_runme.m create mode 100644 Examples/test-suite/octave/null_pointer_runme.m create mode 100644 Examples/test-suite/octave/octave_cell_deref_runme.m create mode 100755 Examples/test-suite/octave/overload_complicated_runme.m create mode 100644 Examples/test-suite/octave/overload_copy_runme.m create mode 100644 Examples/test-suite/octave/overload_extend_runme.m create mode 100644 Examples/test-suite/octave/overload_extendc_runme.m create mode 100644 Examples/test-suite/octave/overload_rename_runme.m create mode 100644 Examples/test-suite/octave/overload_simple_cast_runme.m create mode 100644 Examples/test-suite/octave/overload_simple_runme.m create mode 100644 Examples/test-suite/octave/overload_subtype_runme.m create mode 100644 Examples/test-suite/octave/overload_template_fast_runme.m create mode 100644 Examples/test-suite/octave/overload_template_runme.m create mode 100644 Examples/test-suite/octave/preproc_runme.m create mode 100644 Examples/test-suite/octave/primitive_ref_runme.m create mode 100644 Examples/test-suite/octave/primitive_types_runme.m create mode 100644 Examples/test-suite/octave/profiletest_runme.m create mode 100644 Examples/test-suite/octave/refcount_runme.m create mode 100644 Examples/test-suite/octave/reference_global_vars_runme.m create mode 100644 Examples/test-suite/octave/rename_scope_runme.m create mode 100644 Examples/test-suite/octave/ret_by_value_runme.m create mode 100644 Examples/test-suite/octave/return_const_value_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_extend_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_member_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_multi_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_not_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_overload_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_rename_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_simple_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_templatevariables_runme.m create mode 100644 Examples/test-suite/octave/smart_pointer_typedef_runme.m create mode 100644 Examples/test-suite/octave/sneaky1_runme.m create mode 100644 Examples/test-suite/octave/static_const_member_2_runme.m create mode 100644 Examples/test-suite/octave/std_containers_runme.m create mode 100644 Examples/test-suite/octave/struct_rename_runme.m create mode 100644 Examples/test-suite/octave/struct_value_runme.m create mode 100644 Examples/test-suite/octave/swigobject_runme.m create mode 100644 Examples/test-suite/octave/template_construct_runme.m create mode 100644 Examples/test-suite/octave/template_default_arg_runme.m create mode 100644 Examples/test-suite/octave/template_extend1_runme.m create mode 100644 Examples/test-suite/octave/template_extend2_runme.m create mode 100644 Examples/test-suite/octave/template_inherit_runme.m create mode 100644 Examples/test-suite/octave/template_matrix_runme.m create mode 100644 Examples/test-suite/octave/template_ns4_runme.m create mode 100644 Examples/test-suite/octave/template_ns_runme.m create mode 100644 Examples/test-suite/octave/template_opaque_runme.m create mode 100644 Examples/test-suite/octave/template_ref_type_runme.m create mode 100644 Examples/test-suite/octave/template_rename_runme.m create mode 100644 Examples/test-suite/octave/template_static_runme.m create mode 100644 Examples/test-suite/octave/template_tbase_template_runme.m create mode 100644 Examples/test-suite/octave/template_type_namespace_runme.m create mode 100644 Examples/test-suite/octave/template_typedef_cplx2_runme.m create mode 100644 Examples/test-suite/octave/template_typedef_cplx3_runme.m create mode 100644 Examples/test-suite/octave/template_typedef_cplx4_runme.m create mode 100644 Examples/test-suite/octave/template_typedef_cplx_runme.m create mode 100644 Examples/test-suite/octave/template_typedef_import_runme.m create mode 100644 Examples/test-suite/octave/template_typedef_runme.m create mode 100644 Examples/test-suite/octave/typedef_class_runme.m create mode 100644 Examples/test-suite/octave/typedef_inherit_runme.m create mode 100644 Examples/test-suite/octave/typedef_scope_runme.m create mode 100644 Examples/test-suite/octave/typemap_namespace_runme.m create mode 100644 Examples/test-suite/octave/typemap_ns_using_runme.m create mode 100644 Examples/test-suite/octave/typename_runme.m create mode 100644 Examples/test-suite/octave/types_directive_runme.m create mode 100644 Examples/test-suite/octave/unions_runme.m create mode 100644 Examples/test-suite/octave/using1_runme.m create mode 100644 Examples/test-suite/octave/using2_runme.m create mode 100644 Examples/test-suite/octave/using_composition_runme.m create mode 100644 Examples/test-suite/octave/using_extend_runme.m create mode 100644 Examples/test-suite/octave/using_inherit_runme.m create mode 100644 Examples/test-suite/octave/using_private_runme.m create mode 100644 Examples/test-suite/octave/using_protected_runme.m create mode 100644 Examples/test-suite/octave/varargs_runme.m create mode 100644 Examples/test-suite/octave/virtual_derivation_runme.m create mode 100644 Examples/test-suite/octave/virtual_poly_runme.m create mode 100644 Examples/test-suite/octave/voidtest_runme.m create mode 100644 Examples/test-suite/octave/wrapmacro_runme.m create mode 100644 Examples/test-suite/octave_cell_deref.i create mode 100644 Examples/test-suite/operator_overload.i create mode 100644 Examples/test-suite/operator_overload_break.i create mode 100644 Examples/test-suite/operbool.i create mode 100644 Examples/test-suite/ordering.i create mode 100644 Examples/test-suite/overload_complicated.i create mode 100644 Examples/test-suite/overload_copy.i create mode 100644 Examples/test-suite/overload_extend.i create mode 100644 Examples/test-suite/overload_extendc.i create mode 100644 Examples/test-suite/overload_rename.i create mode 100644 Examples/test-suite/overload_simple.i create mode 100644 Examples/test-suite/overload_subtype.i create mode 100644 Examples/test-suite/overload_template.i create mode 100644 Examples/test-suite/overload_template_fast.i create mode 100644 Examples/test-suite/packageoption.h create mode 100644 Examples/test-suite/packageoption.list create mode 100644 Examples/test-suite/packageoption_a.i create mode 100644 Examples/test-suite/packageoption_b.i create mode 100644 Examples/test-suite/packageoption_c.i create mode 100644 Examples/test-suite/perl5/Makefile.in create mode 100644 Examples/test-suite/perl5/README create mode 100644 Examples/test-suite/perl5/Test/Builder.pm create mode 100644 Examples/test-suite/perl5/Test/More.pm create mode 100644 Examples/test-suite/perl5/aggregate_runme.pl create mode 100644 Examples/test-suite/perl5/apply_signed_char_runme.pl create mode 100644 Examples/test-suite/perl5/apply_strings_runme.pl create mode 100644 Examples/test-suite/perl5/array_member_runme.pl create mode 100644 Examples/test-suite/perl5/char_strings_runme.pl create mode 100755 Examples/test-suite/perl5/class_ignore_runme.pl create mode 100755 Examples/test-suite/perl5/contract_runme.pl create mode 100644 Examples/test-suite/perl5/default_args_runme.pl create mode 100644 Examples/test-suite/perl5/default_constructor_runme.pl create mode 100644 Examples/test-suite/perl5/disown_runme.pl create mode 100644 Examples/test-suite/perl5/dynamic_cast_runme.pl create mode 100755 Examples/test-suite/perl5/enum_template_runme.pl create mode 100644 Examples/test-suite/perl5/enum_thorough_runme.pl create mode 100644 Examples/test-suite/perl5/exception_order_runme.pl create mode 100644 Examples/test-suite/perl5/global_vars_runme.pl create mode 100755 Examples/test-suite/perl5/grouping_runme.pl create mode 100755 Examples/test-suite/perl5/ignore_parameter_runme.pl create mode 100644 Examples/test-suite/perl5/import_nomodule_runme.pl create mode 100644 Examples/test-suite/perl5/imports_runme.pl create mode 100644 Examples/test-suite/perl5/inctest_runme.pl create mode 100755 Examples/test-suite/perl5/inherit_missing_runme.pl create mode 100644 Examples/test-suite/perl5/inherit_runme.pl create mode 100644 Examples/test-suite/perl5/li_carrays_runme.pl create mode 100644 Examples/test-suite/perl5/li_cdata_carrays_runme.pl create mode 100644 Examples/test-suite/perl5/li_reference_runme.pl create mode 100755 Examples/test-suite/perl5/li_std_except_runme.pl create mode 100644 Examples/test-suite/perl5/li_std_string_runme.pl create mode 100644 Examples/test-suite/perl5/li_typemaps_runme.pl create mode 100644 Examples/test-suite/perl5/member_pointer_runme.pl create mode 100755 Examples/test-suite/perl5/minherit_runme.pl create mode 100644 Examples/test-suite/perl5/multiple_inheritance_runme.pl create mode 100755 Examples/test-suite/perl5/naturalvar_runme.pl create mode 100644 Examples/test-suite/perl5/operator_overload_break_runme.pl create mode 100644 Examples/test-suite/perl5/operator_overload_runme.pl create mode 100644 Examples/test-suite/perl5/overload_copy_runme.pl create mode 100644 Examples/test-suite/perl5/overload_simple_runme.pl create mode 100644 Examples/test-suite/perl5/packageoption_runme.pl create mode 100755 Examples/test-suite/perl5/preproc_runme.pl create mode 100644 Examples/test-suite/perl5/primitive_ref_runme.pl create mode 100755 Examples/test-suite/perl5/primitive_types_runme.pl create mode 100644 Examples/test-suite/perl5/profiletest_runme.pl create mode 100755 Examples/test-suite/perl5/reference_global_vars_runme.pl create mode 100755 Examples/test-suite/perl5/rename_scope_runme.pl create mode 100644 Examples/test-suite/perl5/ret_by_value_runme.pl create mode 100755 Examples/test-suite/perl5/return_const_value_runme.pl create mode 100755 Examples/test-suite/perl5/run-perl-test.pl create mode 100755 Examples/test-suite/perl5/sizet_runme.pl create mode 100755 Examples/test-suite/perl5/sneaky1_runme.pl create mode 100644 Examples/test-suite/perl5/template_default_arg_runme.pl create mode 100644 Examples/test-suite/perl5/template_ref_type_runme.pl create mode 100755 Examples/test-suite/perl5/template_typedef_cplx2_runme.pl create mode 100644 Examples/test-suite/perl5/template_typedef_cplx3_runme.pl create mode 100644 Examples/test-suite/perl5/template_typedef_cplx_runme.pl create mode 100755 Examples/test-suite/perl5/typedef_class_runme.pl create mode 100644 Examples/test-suite/perl5/typemap_namespace_runme.pl create mode 100755 Examples/test-suite/perl5/typename_runme.pl create mode 100644 Examples/test-suite/perl5/unions_runme.pl create mode 100755 Examples/test-suite/perl5/using1_runme.pl create mode 100755 Examples/test-suite/perl5/using2_runme.pl create mode 100644 Examples/test-suite/perl5/varargs_runme.pl create mode 100644 Examples/test-suite/perl5/virtual_poly_runme.pl create mode 100644 Examples/test-suite/perl5/voidtest_runme.pl create mode 100755 Examples/test-suite/perl5/wrapmacro_runme.pl create mode 100644 Examples/test-suite/php/Makefile.in create mode 100644 Examples/test-suite/php/abstract_inherit_ok_runme.php create mode 100644 Examples/test-suite/php/abstract_inherit_runme.php create mode 100644 Examples/test-suite/php/add_link_runme.php create mode 100644 Examples/test-suite/php/argout_runme.php create mode 100644 Examples/test-suite/php/arrayptr_runme.php create mode 100644 Examples/test-suite/php/arrays_global_runme.php create mode 100644 Examples/test-suite/php/arrays_global_twodim_runme.php create mode 100644 Examples/test-suite/php/arrays_runme.php create mode 100644 Examples/test-suite/php/arrays_scope_runme.php create mode 100644 Examples/test-suite/php/casts_runme.php create mode 100644 Examples/test-suite/php/char_strings_runme.php create mode 100644 Examples/test-suite/php/class_ignore_runme.php create mode 100644 Examples/test-suite/php/conversion_namespace_runme.php create mode 100644 Examples/test-suite/php/conversion_ns_template_runme.php create mode 100644 Examples/test-suite/php/conversion_runme.php create mode 100644 Examples/test-suite/php/cpp_static_runme.php create mode 100644 Examples/test-suite/php/director_abstract_runme.php create mode 100644 Examples/test-suite/php/director_basic_runme.php create mode 100644 Examples/test-suite/php/director_classic_runme.php create mode 100644 Examples/test-suite/php/director_default_runme.php create mode 100644 Examples/test-suite/php/director_detect_runme.php create mode 100644 Examples/test-suite/php/director_enum_runme.php create mode 100644 Examples/test-suite/php/director_exception_runme.php create mode 100644 Examples/test-suite/php/director_extend_runme.php create mode 100644 Examples/test-suite/php/director_finalizer_runme.php create mode 100644 Examples/test-suite/php/director_frob_runme.php create mode 100644 Examples/test-suite/php/director_nested_runme.php create mode 100644 Examples/test-suite/php/director_profile_runme.php create mode 100644 Examples/test-suite/php/director_protected_runme.php create mode 100644 Examples/test-suite/php/director_stl_runme.php create mode 100644 Examples/test-suite/php/director_string_runme.php create mode 100644 Examples/test-suite/php/director_thread_runme.php create mode 100644 Examples/test-suite/php/director_unroll_runme.php create mode 100644 Examples/test-suite/php/enum_scope_template_runme.php create mode 100644 Examples/test-suite/php/evil_diamond_ns_runme.php create mode 100644 Examples/test-suite/php/evil_diamond_prop_runme.php create mode 100644 Examples/test-suite/php/evil_diamond_runme.php create mode 100644 Examples/test-suite/php/extend_template_ns_runme.php create mode 100644 Examples/test-suite/php/extend_template_runme.php create mode 100644 Examples/test-suite/php/grouping_runme.php create mode 100644 Examples/test-suite/php/ignore_parameter_runme.php create mode 100644 Examples/test-suite/php/import_nomodule_runme.php create mode 100644 Examples/test-suite/php/li_carrays_runme.php create mode 100644 Examples/test-suite/php/li_factory_runme.php create mode 100644 Examples/test-suite/php/li_std_string_runme.php create mode 100644 Examples/test-suite/php/newobject1_runme.php create mode 100644 Examples/test-suite/php/overload_rename_runme.php create mode 100644 Examples/test-suite/php/pointer_reference_runme.php create mode 100644 Examples/test-suite/php/prefix_runme.php create mode 100644 Examples/test-suite/php/primitive_ref_runme.php create mode 100644 Examples/test-suite/php/rename_scope_runme.php create mode 100644 Examples/test-suite/php/skel.php create mode 100644 Examples/test-suite/php/smart_pointer_rename_runme.php create mode 100644 Examples/test-suite/php/sym_runme.php create mode 100644 Examples/test-suite/php/template_arg_typename_runme.php create mode 100644 Examples/test-suite/php/template_construct_runme.php create mode 100644 Examples/test-suite/php/tests.php create mode 100644 Examples/test-suite/php/typedef_reference_runme.php create mode 100644 Examples/test-suite/php/typemap_ns_using_runme.php create mode 100644 Examples/test-suite/php/using1_runme.php create mode 100644 Examples/test-suite/php/using2_runme.php create mode 100644 Examples/test-suite/php/valuewrapper_base_runme.php create mode 100644 Examples/test-suite/php_namewarn_rename.i create mode 100644 Examples/test-suite/pike/Makefile.in create mode 100644 Examples/test-suite/pointer_in_out.i create mode 100644 Examples/test-suite/pointer_reference.i create mode 100644 Examples/test-suite/prefix.i create mode 100644 Examples/test-suite/preproc.i create mode 100644 Examples/test-suite/primitive_ref.i create mode 100644 Examples/test-suite/primitive_types.i create mode 100644 Examples/test-suite/private_assign.i create mode 100644 Examples/test-suite/profiletest.i create mode 100644 Examples/test-suite/protected_rename.i create mode 100644 Examples/test-suite/pure_virtual.i create mode 100644 Examples/test-suite/python/Makefile.in create mode 100644 Examples/test-suite/python/README create mode 100644 Examples/test-suite/python/abstract_access_runme.py create mode 100644 Examples/test-suite/python/abstract_typedef2_runme.py create mode 100644 Examples/test-suite/python/abstract_typedef_runme.py create mode 100644 Examples/test-suite/python/abstract_virtual_runme.py create mode 100644 Examples/test-suite/python/argcargvtest_runme.py create mode 100644 Examples/test-suite/python/array_member_runme.py create mode 100644 Examples/test-suite/python/arrays_global_runme.py create mode 100644 Examples/test-suite/python/callback_runme.py create mode 100644 Examples/test-suite/python/class_ignore_runme.py create mode 100644 Examples/test-suite/python/class_scope_weird_runme.py create mode 100644 Examples/test-suite/python/compactdefaultargs_runme.py create mode 100644 Examples/test-suite/python/complextest_runme.py create mode 100644 Examples/test-suite/python/constover_runme.py create mode 100644 Examples/test-suite/python/constructor_copy_runme.py create mode 100644 Examples/test-suite/python/contract_runme.py create mode 100644 Examples/test-suite/python/cpp_enum_runme.py create mode 100644 Examples/test-suite/python/cpp_namespace_runme.py create mode 100644 Examples/test-suite/python/cpp_static_runme.py create mode 100644 Examples/test-suite/python/default_args_runme.py create mode 100644 Examples/test-suite/python/default_constructor_runme.py create mode 100644 Examples/test-suite/python/director_abstract_runme.py create mode 100644 Examples/test-suite/python/director_basic_runme.py create mode 100644 Examples/test-suite/python/director_classic_runme.py create mode 100644 Examples/test-suite/python/director_default_runme.py create mode 100644 Examples/test-suite/python/director_detect_runme.py create mode 100644 Examples/test-suite/python/director_enum_runme.py create mode 100644 Examples/test-suite/python/director_exception_runme.py create mode 100644 Examples/test-suite/python/director_extend_runme.py create mode 100644 Examples/test-suite/python/director_finalizer_runme.py create mode 100644 Examples/test-suite/python/director_frob_runme.py create mode 100644 Examples/test-suite/python/director_nested_runme.py create mode 100644 Examples/test-suite/python/director_profile_runme.py create mode 100644 Examples/test-suite/python/director_protected_runme.py create mode 100644 Examples/test-suite/python/director_stl_runme.py create mode 100644 Examples/test-suite/python/director_string_runme.py create mode 100644 Examples/test-suite/python/director_thread_runme.py create mode 100644 Examples/test-suite/python/director_unroll_runme.py create mode 100644 Examples/test-suite/python/director_wstring_runme.py create mode 100644 Examples/test-suite/python/disown_runme.py create mode 100644 Examples/test-suite/python/dynamic_cast_runme.py create mode 100644 Examples/test-suite/python/empty_runme.py create mode 100644 Examples/test-suite/python/enum_template_runme.py create mode 100644 Examples/test-suite/python/enums_runme.py create mode 100644 Examples/test-suite/python/exception_order_runme.py create mode 100644 Examples/test-suite/python/extend_placement_runme.py create mode 100644 Examples/test-suite/python/extend_template_ns_runme.py create mode 100644 Examples/test-suite/python/extend_template_runme.py create mode 100644 Examples/test-suite/python/extend_variable_runme.py create mode 100644 Examples/test-suite/python/file_test_runme.py create mode 100644 Examples/test-suite/python/friends_runme.py create mode 100644 Examples/test-suite/python/fvirtual_runme.py create mode 100644 Examples/test-suite/python/global_ns_arg_runme.py create mode 100644 Examples/test-suite/python/grouping_runme.py create mode 100644 Examples/test-suite/python/hugemod.pl create mode 100755 Examples/test-suite/python/iadd_runme.py create mode 100644 Examples/test-suite/python/import_nomodule_runme.py create mode 100644 Examples/test-suite/python/imports_runme.py create mode 100644 Examples/test-suite/python/inctest_runme.py create mode 100644 Examples/test-suite/python/inherit_missing_runme.py create mode 100644 Examples/test-suite/python/inout_runme.py create mode 100644 Examples/test-suite/python/inplaceadd_runme.py create mode 100644 Examples/test-suite/python/input_runme.py create mode 100644 Examples/test-suite/python/keyword_rename_runme.py create mode 100644 Examples/test-suite/python/langobj_runme.py create mode 100644 Examples/test-suite/python/li_attribute_runme.py create mode 100644 Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py create mode 100644 Examples/test-suite/python/li_boost_shared_ptr_runme.py create mode 100644 Examples/test-suite/python/li_carrays_runme.py create mode 100644 Examples/test-suite/python/li_cmalloc_runme.py create mode 100644 Examples/test-suite/python/li_cpointer_runme.py create mode 100644 Examples/test-suite/python/li_cstring_runme.py create mode 100644 Examples/test-suite/python/li_cwstring_runme.py create mode 100644 Examples/test-suite/python/li_factory_runme.py create mode 100644 Examples/test-suite/python/li_implicit_runme.py create mode 100644 Examples/test-suite/python/li_std_carray_runme.py create mode 100644 Examples/test-suite/python/li_std_map_runme.py create mode 100644 Examples/test-suite/python/li_std_pair_extra_runme.py create mode 100644 Examples/test-suite/python/li_std_set_runme.py create mode 100644 Examples/test-suite/python/li_std_stream_runme.py create mode 100644 Examples/test-suite/python/li_std_string_extra_runme.py create mode 100644 Examples/test-suite/python/li_std_vector_extra_runme.py create mode 100644 Examples/test-suite/python/li_std_vector_ptr_runme.py create mode 100644 Examples/test-suite/python/li_std_wstream_runme.py create mode 100644 Examples/test-suite/python/li_std_wstring_runme.py create mode 100644 Examples/test-suite/python/member_pointer_runme.py create mode 100644 Examples/test-suite/python/minherit_runme.py create mode 100644 Examples/test-suite/python/mod_runme.py create mode 100644 Examples/test-suite/python/multi_import_runme.py create mode 100644 Examples/test-suite/python/namespace_class_runme.py create mode 100644 Examples/test-suite/python/namespace_typemap_runme.py create mode 100644 Examples/test-suite/python/namespace_virtual_method_runme.py create mode 100644 Examples/test-suite/python/naturalvar_runme.py create mode 100644 Examples/test-suite/python/operbool_runme.py create mode 100755 Examples/test-suite/python/overload_complicated_runme.py create mode 100644 Examples/test-suite/python/overload_copy_runme.py create mode 100644 Examples/test-suite/python/overload_extend_runme.py create mode 100644 Examples/test-suite/python/overload_extendc_runme.py create mode 100644 Examples/test-suite/python/overload_rename_runme.py create mode 100644 Examples/test-suite/python/overload_simple_runme.py create mode 100644 Examples/test-suite/python/overload_subtype_runme.py create mode 100644 Examples/test-suite/python/overload_template_fast_runme.py create mode 100644 Examples/test-suite/python/overload_template_runme.py create mode 100644 Examples/test-suite/python/preproc_runme.py create mode 100644 Examples/test-suite/python/primitive_ref_runme.py create mode 100644 Examples/test-suite/python/primitive_types_runme.py create mode 100644 Examples/test-suite/python/profiletest_runme.py create mode 100644 Examples/test-suite/python/profiletestc_runme.py create mode 100644 Examples/test-suite/python/python_abstractbase_runme3.py create mode 100644 Examples/test-suite/python/python_append_runme.py create mode 100644 Examples/test-suite/python/python_kwargs_runme.py create mode 100644 Examples/test-suite/python/python_nondynamic_runme.py create mode 100644 Examples/test-suite/python/python_overload_simple_cast_runme.py create mode 100644 Examples/test-suite/python/python_pybuf_runme3.py create mode 100644 Examples/test-suite/python/pythonswig.supp create mode 100644 Examples/test-suite/python/refcount_runme.py create mode 100644 Examples/test-suite/python/reference_global_vars_runme.py create mode 100644 Examples/test-suite/python/rename_scope_runme.py create mode 100644 Examples/test-suite/python/rename_strip_encoder_runme.py create mode 100644 Examples/test-suite/python/ret_by_value_runme.py create mode 100644 Examples/test-suite/python/return_const_value_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_extend_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_member_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_multi_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_multi_typedef_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_not_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_overload_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_rename_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_simple_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_templatevariables_runme.py create mode 100644 Examples/test-suite/python/smart_pointer_typedef_runme.py create mode 100644 Examples/test-suite/python/sneaky1_runme.py create mode 100644 Examples/test-suite/python/special_variable_macros_runme.py create mode 100644 Examples/test-suite/python/static_const_member_2_runme.py create mode 100644 Examples/test-suite/python/std_containers_runme.py create mode 100644 Examples/test-suite/python/struct_rename_runme.py create mode 100644 Examples/test-suite/python/struct_value_runme.py create mode 100644 Examples/test-suite/python/swigobject_runme.py create mode 100644 Examples/test-suite/python/template_construct_runme.py create mode 100644 Examples/test-suite/python/template_default_arg_runme.py create mode 100644 Examples/test-suite/python/template_extend1_runme.py create mode 100644 Examples/test-suite/python/template_extend2_runme.py create mode 100644 Examples/test-suite/python/template_inherit_runme.py create mode 100644 Examples/test-suite/python/template_matrix_runme.py create mode 100644 Examples/test-suite/python/template_ns4_runme.py create mode 100644 Examples/test-suite/python/template_ns_runme.py create mode 100644 Examples/test-suite/python/template_opaque_runme.py create mode 100644 Examples/test-suite/python/template_ref_type_runme.py create mode 100644 Examples/test-suite/python/template_rename_runme.py create mode 100644 Examples/test-suite/python/template_static_runme.py create mode 100644 Examples/test-suite/python/template_tbase_template_runme.py create mode 100644 Examples/test-suite/python/template_type_namespace_runme.py create mode 100644 Examples/test-suite/python/template_typedef_cplx2_runme.py create mode 100644 Examples/test-suite/python/template_typedef_cplx3_runme.py create mode 100644 Examples/test-suite/python/template_typedef_cplx4_runme.py create mode 100644 Examples/test-suite/python/template_typedef_cplx_runme.py create mode 100644 Examples/test-suite/python/template_typedef_import_runme.py create mode 100644 Examples/test-suite/python/template_typedef_runme.py create mode 100644 Examples/test-suite/python/typedef_class_runme.py create mode 100644 Examples/test-suite/python/typedef_inherit_runme.py create mode 100644 Examples/test-suite/python/typedef_scope_runme.py create mode 100644 Examples/test-suite/python/typemap_namespace_runme.py create mode 100644 Examples/test-suite/python/typemap_ns_using_runme.py create mode 100644 Examples/test-suite/python/typemap_out_optimal_runme.py create mode 100644 Examples/test-suite/python/typename_runme.py create mode 100644 Examples/test-suite/python/types_directive_runme.py create mode 100644 Examples/test-suite/python/unions_runme.py create mode 100644 Examples/test-suite/python/using1_runme.py create mode 100644 Examples/test-suite/python/using2_runme.py create mode 100644 Examples/test-suite/python/using_composition_runme.py create mode 100644 Examples/test-suite/python/using_extend_runme.py create mode 100644 Examples/test-suite/python/using_inherit_runme.py create mode 100644 Examples/test-suite/python/using_private_runme.py create mode 100644 Examples/test-suite/python/using_protected_runme.py create mode 100644 Examples/test-suite/python/varargs_runme.py create mode 100644 Examples/test-suite/python/virtual_derivation_runme.py create mode 100644 Examples/test-suite/python/virtual_poly_runme.py create mode 100644 Examples/test-suite/python/voidtest_runme.py create mode 100644 Examples/test-suite/python/wrapmacro_runme.py create mode 100644 Examples/test-suite/python_abstractbase.i create mode 100644 Examples/test-suite/python_append.i create mode 100644 Examples/test-suite/python_autodoc.i create mode 100644 Examples/test-suite/python_kwargs.i create mode 100644 Examples/test-suite/python_nondynamic.i create mode 100644 Examples/test-suite/python_overload_simple_cast.i create mode 100644 Examples/test-suite/python_pybuf.i create mode 100644 Examples/test-suite/r/Makefile.in create mode 100644 Examples/test-suite/r/arrays_dimensionless_runme.R create mode 100644 Examples/test-suite/r/funcptr_runme.R create mode 100644 Examples/test-suite/r/ignore_parameter_runme.R create mode 100644 Examples/test-suite/r/integers_runme.R create mode 100644 Examples/test-suite/r/r_copy_struct_runme.R create mode 100644 Examples/test-suite/r/r_double_delete_runme.R create mode 100644 Examples/test-suite/r/r_legacy_runme.R create mode 100644 Examples/test-suite/r/simple_array_runme.R create mode 100644 Examples/test-suite/r/unions_runme.R create mode 100644 Examples/test-suite/r/unittest.R create mode 100644 Examples/test-suite/r_copy_struct.i create mode 100644 Examples/test-suite/r_double_delete.i create mode 100644 Examples/test-suite/r_legacy.i create mode 100644 Examples/test-suite/redefined.i create mode 100644 Examples/test-suite/refcount.h create mode 100644 Examples/test-suite/refcount.i create mode 100644 Examples/test-suite/reference_global_vars.i create mode 100644 Examples/test-suite/register_par.i create mode 100644 Examples/test-suite/rename.h create mode 100644 Examples/test-suite/rename1.i create mode 100644 Examples/test-suite/rename2.i create mode 100644 Examples/test-suite/rename3.i create mode 100644 Examples/test-suite/rename4.i create mode 100644 Examples/test-suite/rename_camel.i create mode 100644 Examples/test-suite/rename_scope.i create mode 100644 Examples/test-suite/rename_strip_encoder.i create mode 100644 Examples/test-suite/restrict_cplusplus.i create mode 100644 Examples/test-suite/ret_by_value.i create mode 100644 Examples/test-suite/return_const_value.i create mode 100644 Examples/test-suite/return_value_scope.i create mode 100644 Examples/test-suite/rname.i create mode 100644 Examples/test-suite/ruby/Makefile.in create mode 100644 Examples/test-suite/ruby/README create mode 100755 Examples/test-suite/ruby/abstract_access_runme.rb create mode 100644 Examples/test-suite/ruby/abstract_inherit_ok_runme.rb create mode 100644 Examples/test-suite/ruby/abstract_inherit_runme.rb create mode 100644 Examples/test-suite/ruby/abstract_signature_runme.rb create mode 100644 Examples/test-suite/ruby/abstract_typedef2_runme.rb create mode 100644 Examples/test-suite/ruby/abstract_typedef_runme.rb create mode 100644 Examples/test-suite/ruby/abstract_virtual_runme.rb create mode 100755 Examples/test-suite/ruby/access_change_runme.rb create mode 100755 Examples/test-suite/ruby/add_link_runme.rb create mode 100644 Examples/test-suite/ruby/aggregate_runme.rb create mode 100755 Examples/test-suite/ruby/anonymous_bitfield_runme.rb create mode 100755 Examples/test-suite/ruby/apply_signed_char_runme.rb create mode 100755 Examples/test-suite/ruby/apply_strings_runme.rb create mode 100755 Examples/test-suite/ruby/argout_runme.rb create mode 100644 Examples/test-suite/ruby/array_member_runme.rb create mode 100644 Examples/test-suite/ruby/arrays_global_runme.rb create mode 100755 Examples/test-suite/ruby/arrays_runme.rb create mode 100644 Examples/test-suite/ruby/bools_runme.rb create mode 100755 Examples/test-suite/ruby/cast_operator_runme.rb create mode 100755 Examples/test-suite/ruby/casts_runme.rb create mode 100644 Examples/test-suite/ruby/char_constant_runme.rb create mode 100755 Examples/test-suite/ruby/check_missing_tests.rb create mode 100755 Examples/test-suite/ruby/class_ignore_runme.rb create mode 100755 Examples/test-suite/ruby/const_const_runme.rb create mode 100755 Examples/test-suite/ruby/constover_runme.rb create mode 100755 Examples/test-suite/ruby/cpp_namespace_runme.rb create mode 100755 Examples/test-suite/ruby/default_constructor_runme.rb create mode 100644 Examples/test-suite/ruby/director_abstract_runme.rb create mode 100644 Examples/test-suite/ruby/director_basic_runme.rb create mode 100644 Examples/test-suite/ruby/director_constructor_runme.rb create mode 100644 Examples/test-suite/ruby/director_default_runme.rb create mode 100644 Examples/test-suite/ruby/director_detect_runme.rb create mode 100644 Examples/test-suite/ruby/director_exception_runme.rb create mode 100644 Examples/test-suite/ruby/director_frob_runme.rb create mode 100644 Examples/test-suite/ruby/director_nested_runme.rb create mode 100644 Examples/test-suite/ruby/director_protected_runme.rb create mode 100644 Examples/test-suite/ruby/director_string_runme.rb create mode 100644 Examples/test-suite/ruby/director_unroll_runme.rb create mode 100644 Examples/test-suite/ruby/director_wombat_runme.rb create mode 100644 Examples/test-suite/ruby/disown_runme.rb create mode 100755 Examples/test-suite/ruby/dynamic_cast_runme.rb create mode 100755 Examples/test-suite/ruby/enum_thorough_runme.rb create mode 100644 Examples/test-suite/ruby/enums_runme.rb create mode 100644 Examples/test-suite/ruby/extend_template_ns_runme.rb create mode 100644 Examples/test-suite/ruby/extend_template_runme.rb create mode 100644 Examples/test-suite/ruby/friends_runme.rb create mode 100755 Examples/test-suite/ruby/function_typedef_runme.rb create mode 100644 Examples/test-suite/ruby/grouping_runme.rb create mode 100644 Examples/test-suite/ruby/ignore_parameter_runme.rb create mode 100755 Examples/test-suite/ruby/imports_runme.rb create mode 100644 Examples/test-suite/ruby/inherit_missing_runme.rb create mode 100755 Examples/test-suite/ruby/integers_runme.rb create mode 100644 Examples/test-suite/ruby/li_carrays_runme.rb create mode 100755 Examples/test-suite/ruby/li_cstring_runme.rb create mode 100644 Examples/test-suite/ruby/li_factory_runme.rb create mode 100755 Examples/test-suite/ruby/li_math_runme.rb create mode 100644 Examples/test-suite/ruby/li_std_deque_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_functors_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_map_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_multimap_runme.rb create mode 100644 Examples/test-suite/ruby/li_std_pair_lang_object_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_pair_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_queue_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_set_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_speed2_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_stack_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_stream_runme.rb create mode 100644 Examples/test-suite/ruby/li_std_string_runme.rb create mode 100755 Examples/test-suite/ruby/li_std_vector_runme.rb create mode 100644 Examples/test-suite/ruby/member_pointer_runme.rb create mode 100644 Examples/test-suite/ruby/minherit_runme.rb create mode 100755 Examples/test-suite/ruby/namespace_typemap_runme.rb create mode 100644 Examples/test-suite/ruby/newobject1_runme.rb create mode 100644 Examples/test-suite/ruby/newobject2_runme.rb create mode 100755 Examples/test-suite/ruby/overload_copy_runme.rb create mode 100755 Examples/test-suite/ruby/overload_extend_runme.rb create mode 100755 Examples/test-suite/ruby/overload_extendc_runme.rb create mode 100755 Examples/test-suite/ruby/overload_simple_runme.rb create mode 100644 Examples/test-suite/ruby/overload_subtype_runme.rb create mode 100755 Examples/test-suite/ruby/overload_template_runme.rb create mode 100755 Examples/test-suite/ruby/primitive_ref_runme.rb create mode 100644 Examples/test-suite/ruby/primitive_types_runme.rb create mode 100644 Examples/test-suite/ruby/profiletest_runme.rb create mode 100644 Examples/test-suite/ruby/refcount_runme.rb create mode 100644 Examples/test-suite/ruby/reference_global_vars_runme.rb create mode 100644 Examples/test-suite/ruby/rename_scope_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_keywords_runme.rb create mode 100755 Examples/test-suite/ruby/ruby_li_std_speed_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_naming_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_track_objects_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_const_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_multi_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_not_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_overload_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_rename_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_simple_runme.rb create mode 100644 Examples/test-suite/ruby/smart_pointer_typedef_runme.rb create mode 100755 Examples/test-suite/ruby/sneaky1_runme.rb create mode 100644 Examples/test-suite/ruby/static_const_member_2_runme.rb create mode 100755 Examples/test-suite/ruby/std_containers_runme.rb create mode 100755 Examples/test-suite/ruby/stl_new_runme.rb create mode 100644 Examples/test-suite/ruby/struct_value_runme.rb create mode 100755 Examples/test-suite/ruby/swig_assert.rb create mode 100755 Examples/test-suite/ruby/swig_gc.rb create mode 100644 Examples/test-suite/ruby/template_construct_runme.rb create mode 100644 Examples/test-suite/ruby/template_extend1_runme.rb create mode 100644 Examples/test-suite/ruby/template_extend2_runme.rb create mode 100755 Examples/test-suite/ruby/template_inherit_runme.rb create mode 100755 Examples/test-suite/ruby/template_ns4_runme.rb create mode 100755 Examples/test-suite/ruby/template_ns_runme.rb create mode 100755 Examples/test-suite/ruby/template_rename_runme.rb create mode 100644 Examples/test-suite/ruby/template_tbase_template_runme.rb create mode 100644 Examples/test-suite/ruby/template_type_namespace_runme.rb create mode 100644 Examples/test-suite/ruby/template_typedef_cplx2_runme.rb create mode 100644 Examples/test-suite/ruby/template_typedef_cplx3_runme.rb create mode 100644 Examples/test-suite/ruby/template_typedef_cplx4_runme.rb create mode 100644 Examples/test-suite/ruby/template_typedef_cplx_runme.rb create mode 100644 Examples/test-suite/ruby/throw_exception_runme.rb create mode 100755 Examples/test-suite/ruby/typedef_inherit_runme.rb create mode 100755 Examples/test-suite/ruby/typedef_scope_runme.rb create mode 100755 Examples/test-suite/ruby/typemap_namespace_runme.rb create mode 100644 Examples/test-suite/ruby/typemap_ns_using_runme.rb create mode 100755 Examples/test-suite/ruby/typename_runme.rb create mode 100644 Examples/test-suite/ruby/unions_runme.rb create mode 100644 Examples/test-suite/ruby/using1_runme.rb create mode 100644 Examples/test-suite/ruby/using2_runme.rb create mode 100644 Examples/test-suite/ruby/using_composition_runme.rb create mode 100644 Examples/test-suite/ruby/using_extend_runme.rb create mode 100644 Examples/test-suite/ruby/using_inherit_runme.rb create mode 100644 Examples/test-suite/ruby/using_private_runme.rb create mode 100644 Examples/test-suite/ruby/using_protected_runme.rb create mode 100644 Examples/test-suite/ruby/varargs_runme.rb create mode 100644 Examples/test-suite/ruby/virtual_derivation_runme.rb create mode 100644 Examples/test-suite/ruby/virtual_poly_runme.rb create mode 100644 Examples/test-suite/ruby/voidtest_runme.rb create mode 100644 Examples/test-suite/ruby_keywords.i create mode 100644 Examples/test-suite/ruby_li_std_speed.i create mode 100644 Examples/test-suite/ruby_naming.i create mode 100644 Examples/test-suite/ruby_track_objects.i create mode 100644 Examples/test-suite/ruby_track_objects_directors.i create mode 100644 Examples/test-suite/samename.i create mode 100644 Examples/test-suite/samename_runme.m create mode 100644 Examples/test-suite/schemerunme/casts.scm create mode 100644 Examples/test-suite/schemerunme/char_constant.scm create mode 100644 Examples/test-suite/schemerunme/class_ignore.scm create mode 100644 Examples/test-suite/schemerunme/constover.scm create mode 100644 Examples/test-suite/schemerunme/contract.scm create mode 100644 Examples/test-suite/schemerunme/cpp_enum.scm create mode 100644 Examples/test-suite/schemerunme/cpp_namespace.scm create mode 100644 Examples/test-suite/schemerunme/dynamic_cast.scm create mode 100644 Examples/test-suite/schemerunme/global_vars.scm create mode 100644 Examples/test-suite/schemerunme/global_vars_proxy.scm create mode 100644 Examples/test-suite/schemerunme/import_nomodule.scm create mode 100644 Examples/test-suite/schemerunme/imports.scm create mode 100644 Examples/test-suite/schemerunme/inherit_missing.scm create mode 100644 Examples/test-suite/schemerunme/integers.scm create mode 100644 Examples/test-suite/schemerunme/li_std_string.scm create mode 100644 Examples/test-suite/schemerunme/li_typemaps.scm create mode 100644 Examples/test-suite/schemerunme/li_typemaps_proxy.scm create mode 100644 Examples/test-suite/schemerunme/list_vector.scm create mode 100644 Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm create mode 100644 Examples/test-suite/schemerunme/multivalue.scm create mode 100644 Examples/test-suite/schemerunme/name.scm create mode 100644 Examples/test-suite/schemerunme/overload_complicated.scm create mode 100644 Examples/test-suite/schemerunme/overload_copy.scm create mode 100644 Examples/test-suite/schemerunme/overload_extend.scm create mode 100644 Examples/test-suite/schemerunme/overload_simple.scm create mode 100644 Examples/test-suite/schemerunme/overload_subtype.scm create mode 100644 Examples/test-suite/schemerunme/pointer_in_out.scm create mode 100644 Examples/test-suite/schemerunme/reference_global_vars.scm create mode 100644 Examples/test-suite/schemerunme/typedef_inherit.scm create mode 100644 Examples/test-suite/schemerunme/typename.scm create mode 100644 Examples/test-suite/schemerunme/unions.scm create mode 100644 Examples/test-suite/schemerunme/unions_proxy.scm create mode 100644 Examples/test-suite/shared_ptr_wrapper.h create mode 100644 Examples/test-suite/simple_array.i create mode 100644 Examples/test-suite/simutry.i create mode 100644 Examples/test-suite/sizeof_pointer.i create mode 100644 Examples/test-suite/sizet.i create mode 100644 Examples/test-suite/smart_pointer_const.i create mode 100644 Examples/test-suite/smart_pointer_const2.i create mode 100644 Examples/test-suite/smart_pointer_extend.i create mode 100644 Examples/test-suite/smart_pointer_inherit.i create mode 100644 Examples/test-suite/smart_pointer_member.i create mode 100644 Examples/test-suite/smart_pointer_multi.i create mode 100644 Examples/test-suite/smart_pointer_multi_typedef.i create mode 100644 Examples/test-suite/smart_pointer_namespace.i create mode 100644 Examples/test-suite/smart_pointer_namespace2.i create mode 100644 Examples/test-suite/smart_pointer_not.i create mode 100644 Examples/test-suite/smart_pointer_overload.i create mode 100644 Examples/test-suite/smart_pointer_protected.i create mode 100644 Examples/test-suite/smart_pointer_rename.i create mode 100644 Examples/test-suite/smart_pointer_simple.i create mode 100644 Examples/test-suite/smart_pointer_static.i create mode 100644 Examples/test-suite/smart_pointer_templatemethods.i create mode 100644 Examples/test-suite/smart_pointer_templatevariables.i create mode 100644 Examples/test-suite/smart_pointer_typedef.i create mode 100644 Examples/test-suite/sneaky1.i create mode 100644 Examples/test-suite/special_variable_macros.i create mode 100644 Examples/test-suite/special_variables.i create mode 100644 Examples/test-suite/static_array_member.i create mode 100644 Examples/test-suite/static_const_member.i create mode 100644 Examples/test-suite/static_const_member_2.i create mode 100644 Examples/test-suite/std_containers.i create mode 100644 Examples/test-suite/stl_new.i create mode 100644 Examples/test-suite/struct_rename.i create mode 100644 Examples/test-suite/struct_value.i create mode 100644 Examples/test-suite/swig_examples_lock.h create mode 100644 Examples/test-suite/swigobject.i create mode 100644 Examples/test-suite/sym.i create mode 100644 Examples/test-suite/tag_no_clash_with_variable.i create mode 100644 Examples/test-suite/tcl/Makefile.in create mode 100644 Examples/test-suite/tcl/README create mode 100644 Examples/test-suite/tcl/bools_runme.tcl create mode 100644 Examples/test-suite/tcl/clientdata_prop_runme.tcl create mode 100644 Examples/test-suite/tcl/disown_runme.tcl create mode 100644 Examples/test-suite/tcl/enum_thorough_runme.tcl create mode 100644 Examples/test-suite/tcl/import_nomodule_runme.tcl create mode 100644 Examples/test-suite/tcl/imports_runme.tcl create mode 100644 Examples/test-suite/tcl/li_std_string_runme.tcl create mode 100644 Examples/test-suite/tcl/member_pointer_runme.tcl create mode 100644 Examples/test-suite/tcl/newobject1_runme.tcl create mode 100644 Examples/test-suite/tcl/newobject2_runme.tcl create mode 100644 Examples/test-suite/tcl/overload_copy_runme.tcl create mode 100644 Examples/test-suite/tcl/overload_simple_runme.tcl create mode 100644 Examples/test-suite/tcl/primitive_ref_runme.tcl create mode 100644 Examples/test-suite/tcl/primitive_types_runme.tcl create mode 100644 Examples/test-suite/tcl/profiletest_runme.tcl create mode 100644 Examples/test-suite/tcl/reference_global_vars_runme.tcl create mode 100644 Examples/test-suite/tcl/union_parameter_runme.tcl create mode 100644 Examples/test-suite/tcl/unions_runme.tcl create mode 100644 Examples/test-suite/template.i create mode 100644 Examples/test-suite/template_arg_replace.i create mode 100644 Examples/test-suite/template_arg_scope.i create mode 100644 Examples/test-suite/template_arg_typename.i create mode 100644 Examples/test-suite/template_array_numeric.i create mode 100644 Examples/test-suite/template_base_template.i create mode 100644 Examples/test-suite/template_classes.i create mode 100644 Examples/test-suite/template_const_ref.i create mode 100644 Examples/test-suite/template_construct.i create mode 100644 Examples/test-suite/template_default.i create mode 100644 Examples/test-suite/template_default2.i create mode 100644 Examples/test-suite/template_default_arg.i create mode 100644 Examples/test-suite/template_default_class_parms.i create mode 100644 Examples/test-suite/template_default_inherit.i create mode 100644 Examples/test-suite/template_default_pointer.i create mode 100644 Examples/test-suite/template_default_qualify.i create mode 100644 Examples/test-suite/template_default_vw.i create mode 100644 Examples/test-suite/template_enum.i create mode 100644 Examples/test-suite/template_enum_ns_inherit.i create mode 100644 Examples/test-suite/template_enum_typedef.i create mode 100644 Examples/test-suite/template_explicit.i create mode 100644 Examples/test-suite/template_expr.i create mode 100644 Examples/test-suite/template_extend1.i create mode 100644 Examples/test-suite/template_extend2.i create mode 100644 Examples/test-suite/template_extend_overload.i create mode 100644 Examples/test-suite/template_extend_overload_2.i create mode 100644 Examples/test-suite/template_forward.i create mode 100644 Examples/test-suite/template_inherit.i create mode 100644 Examples/test-suite/template_inherit_abstract.i create mode 100644 Examples/test-suite/template_int_const.i create mode 100644 Examples/test-suite/template_matrix.i create mode 100644 Examples/test-suite/template_methods.i create mode 100644 Examples/test-suite/template_ns.i create mode 100644 Examples/test-suite/template_ns2.i create mode 100644 Examples/test-suite/template_ns3.i create mode 100644 Examples/test-suite/template_ns4.i create mode 100644 Examples/test-suite/template_ns_enum.i create mode 100644 Examples/test-suite/template_ns_enum2.i create mode 100644 Examples/test-suite/template_ns_inherit.i create mode 100644 Examples/test-suite/template_ns_scope.i create mode 100644 Examples/test-suite/template_opaque.i create mode 100644 Examples/test-suite/template_partial_arg.i create mode 100644 Examples/test-suite/template_qualifier.i create mode 100644 Examples/test-suite/template_ref_type.i create mode 100644 Examples/test-suite/template_rename.i create mode 100644 Examples/test-suite/template_retvalue.i create mode 100644 Examples/test-suite/template_specialization.i create mode 100644 Examples/test-suite/template_specialization_defarg.i create mode 100644 Examples/test-suite/template_specialization_enum.i create mode 100644 Examples/test-suite/template_static.i create mode 100644 Examples/test-suite/template_tbase_template.i create mode 100644 Examples/test-suite/template_template_parameters.i create mode 100644 Examples/test-suite/template_type_namespace.i create mode 100644 Examples/test-suite/template_typedef.i create mode 100644 Examples/test-suite/template_typedef_cplx.i create mode 100644 Examples/test-suite/template_typedef_cplx2.h create mode 100644 Examples/test-suite/template_typedef_cplx2.i create mode 100644 Examples/test-suite/template_typedef_cplx3.i create mode 100644 Examples/test-suite/template_typedef_cplx4.i create mode 100644 Examples/test-suite/template_typedef_cplx5.i create mode 100644 Examples/test-suite/template_typedef_fnc.i create mode 100644 Examples/test-suite/template_typedef_funcptr.i create mode 100644 Examples/test-suite/template_typedef_import.i create mode 100644 Examples/test-suite/template_typedef_import.list create mode 100644 Examples/test-suite/template_typedef_ns.i create mode 100644 Examples/test-suite/template_typedef_ptr.i create mode 100644 Examples/test-suite/template_typedef_rec.i create mode 100644 Examples/test-suite/template_typemaps.i create mode 100644 Examples/test-suite/template_using.i create mode 100644 Examples/test-suite/template_virtual.i create mode 100644 Examples/test-suite/template_whitespace.i create mode 100644 Examples/test-suite/testdir/subdir1/hello.i create mode 100644 Examples/test-suite/testdir/subdir1/imports.i create mode 100644 Examples/test-suite/testdir/subdir1/subinc1.i create mode 100644 Examples/test-suite/testdir/subdir2/hello.i create mode 100644 Examples/test-suite/testdir/subdir2/imports.i create mode 100644 Examples/test-suite/testdir/subdir2/subinc2.i create mode 100644 Examples/test-suite/testdir/test.i create mode 100644 Examples/test-suite/threads.i create mode 100644 Examples/test-suite/throw_exception.i create mode 100644 Examples/test-suite/traits.i create mode 100644 Examples/test-suite/typedef_array_member.i create mode 100644 Examples/test-suite/typedef_class.i create mode 100644 Examples/test-suite/typedef_funcptr.i create mode 100644 Examples/test-suite/typedef_inherit.i create mode 100644 Examples/test-suite/typedef_mptr.i create mode 100644 Examples/test-suite/typedef_reference.i create mode 100644 Examples/test-suite/typedef_scope.i create mode 100644 Examples/test-suite/typedef_sizet.i create mode 100644 Examples/test-suite/typedef_struct.i create mode 100644 Examples/test-suite/typemap_namespace.i create mode 100644 Examples/test-suite/typemap_ns_using.i create mode 100644 Examples/test-suite/typemap_numinputs.i create mode 100644 Examples/test-suite/typemap_out_optimal.i create mode 100644 Examples/test-suite/typemap_self.i create mode 100644 Examples/test-suite/typemap_subst.i create mode 100644 Examples/test-suite/typemap_variables.i create mode 100644 Examples/test-suite/typemap_various.i create mode 100644 Examples/test-suite/typename.i create mode 100644 Examples/test-suite/types_directive.i create mode 100644 Examples/test-suite/uffi/Makefile.in create mode 100644 Examples/test-suite/union_parameter.i create mode 100644 Examples/test-suite/union_scope.i create mode 100644 Examples/test-suite/unions.i create mode 100644 Examples/test-suite/using1.i create mode 100644 Examples/test-suite/using2.i create mode 100644 Examples/test-suite/using_composition.i create mode 100644 Examples/test-suite/using_extend.i create mode 100644 Examples/test-suite/using_inherit.i create mode 100644 Examples/test-suite/using_namespace.i create mode 100644 Examples/test-suite/using_pointers.i create mode 100644 Examples/test-suite/using_private.i create mode 100644 Examples/test-suite/using_protected.i create mode 100644 Examples/test-suite/valuewrapper.i create mode 100644 Examples/test-suite/valuewrapper_base.i create mode 100644 Examples/test-suite/valuewrapper_const.i create mode 100644 Examples/test-suite/valuewrapper_opaque.i create mode 100644 Examples/test-suite/varargs.i create mode 100644 Examples/test-suite/virtual_derivation.i create mode 100644 Examples/test-suite/virtual_destructor.i create mode 100644 Examples/test-suite/virtual_poly.i create mode 100644 Examples/test-suite/voidtest.i create mode 100644 Examples/test-suite/wallkw.i create mode 100644 Examples/test-suite/wrapmacro.i create mode 100644 Examples/xml/Makefile.in create mode 100644 Examples/xml/error.expected-xml create mode 100644 Examples/xml/error.i create mode 100644 Examples/xml/example.expected-xml create mode 100644 Examples/xml/example.h create mode 100644 Examples/xml/example.i create mode 100644 Examples/xml/example_apply.expected-xml create mode 100644 Examples/xml/example_apply.i create mode 100644 Examples/xml/example_const.expected-xml create mode 100644 Examples/xml/example_const.i create mode 100644 Examples/xml/example_gif.expected-xml create mode 100644 Examples/xml/example_gif.i create mode 100644 Examples/xml/example_inl.expected-xml create mode 100644 Examples/xml/example_inl.h create mode 100644 Examples/xml/example_inl.i create mode 100644 Examples/xml/example_p5.expected-xml create mode 100644 Examples/xml/example_p5.i create mode 100644 Examples/xml/example_ro.expected-xml create mode 100644 Examples/xml/example_ro.i create mode 100644 Examples/xml/example_title_add.expected-xml create mode 100644 Examples/xml/example_title_add.i create mode 100644 Examples/xml/example_xml.expected-xml create mode 100644 Examples/xml/example_xml.h create mode 100644 Examples/xml/example_xml.i create mode 100644 Examples/xml/gnarly.expected-xml create mode 100644 Examples/xml/gnarly.i create mode 100644 FUTURE create mode 100644 INSTALL create mode 100644 LICENSE create mode 100644 Lib/allegrocl/allegrocl.swg create mode 100644 Lib/allegrocl/inout_typemaps.i create mode 100644 Lib/allegrocl/longlongs.i create mode 100644 Lib/allegrocl/std_list.i create mode 100644 Lib/allegrocl/std_string.i create mode 100644 Lib/allegrocl/typemaps.i create mode 100644 Lib/allkw.swg create mode 100644 Lib/attribute.i create mode 100644 Lib/carrays.i create mode 100644 Lib/cdata.i create mode 100644 Lib/cffi/cffi.swg create mode 100644 Lib/chicken/chicken.swg create mode 100644 Lib/chicken/chickenkw.swg create mode 100644 Lib/chicken/chickenrun.swg create mode 100644 Lib/chicken/extra-install.list create mode 100644 Lib/chicken/multi-generic.scm create mode 100644 Lib/chicken/std_string.i create mode 100644 Lib/chicken/swigclosprefix.scm create mode 100644 Lib/chicken/tinyclos-multi-generic.patch create mode 100644 Lib/chicken/typemaps.i create mode 100644 Lib/clisp/clisp.swg create mode 100644 Lib/cmalloc.i create mode 100644 Lib/constraints.i create mode 100644 Lib/cpointer.i create mode 100644 Lib/csharp/arrays_csharp.i create mode 100644 Lib/csharp/boost_shared_ptr.i create mode 100644 Lib/csharp/csharp.swg create mode 100644 Lib/csharp/csharphead.swg create mode 100644 Lib/csharp/csharpkw.swg create mode 100644 Lib/csharp/director.swg create mode 100644 Lib/csharp/enums.swg create mode 100644 Lib/csharp/enumsimple.swg create mode 100644 Lib/csharp/enumtypesafe.swg create mode 100644 Lib/csharp/std_common.i create mode 100644 Lib/csharp/std_deque.i create mode 100644 Lib/csharp/std_except.i create mode 100644 Lib/csharp/std_map.i create mode 100644 Lib/csharp/std_pair.i create mode 100644 Lib/csharp/std_string.i create mode 100644 Lib/csharp/std_vector.i create mode 100644 Lib/csharp/std_wstring.i create mode 100644 Lib/csharp/stl.i create mode 100644 Lib/csharp/typemaps.i create mode 100644 Lib/csharp/wchar.i create mode 100644 Lib/cstring.i create mode 100644 Lib/cwstring.i create mode 100644 Lib/exception.i create mode 100644 Lib/gcj/cni.i create mode 100644 Lib/gcj/cni.swg create mode 100644 Lib/gcj/javaprims.i create mode 100644 Lib/guile/Makefile create mode 100644 Lib/guile/common.scm create mode 100644 Lib/guile/cplusplus.i create mode 100644 Lib/guile/extra-install.list create mode 100644 Lib/guile/ghinterface.i create mode 100644 Lib/guile/guile.i create mode 100644 Lib/guile/guile_gh.swg create mode 100644 Lib/guile/guile_gh_run.swg create mode 100644 Lib/guile/guile_scm.swg create mode 100644 Lib/guile/guile_scm_run.swg create mode 100644 Lib/guile/guilemain.i create mode 100644 Lib/guile/interpreter.i create mode 100644 Lib/guile/list-vector.i create mode 100644 Lib/guile/pointer-in-out.i create mode 100644 Lib/guile/ports.i create mode 100644 Lib/guile/std_common.i create mode 100644 Lib/guile/std_deque.i create mode 100644 Lib/guile/std_except.i create mode 100644 Lib/guile/std_map.i create mode 100644 Lib/guile/std_pair.i create mode 100644 Lib/guile/std_string.i create mode 100644 Lib/guile/std_vector.i create mode 100644 Lib/guile/stl.i create mode 100644 Lib/guile/swigrun.i create mode 100644 Lib/guile/typemaps.i create mode 100644 Lib/intrusive_ptr.i create mode 100644 Lib/inttypes.i create mode 100644 Lib/java/arrays_java.i create mode 100644 Lib/java/boost_intrusive_ptr.i create mode 100644 Lib/java/boost_shared_ptr.i create mode 100644 Lib/java/director.swg create mode 100644 Lib/java/enums.swg create mode 100644 Lib/java/enumsimple.swg create mode 100644 Lib/java/enumtypesafe.swg create mode 100644 Lib/java/enumtypeunsafe.swg create mode 100644 Lib/java/java.swg create mode 100644 Lib/java/javahead.swg create mode 100644 Lib/java/javakw.swg create mode 100644 Lib/java/std_common.i create mode 100644 Lib/java/std_deque.i create mode 100644 Lib/java/std_except.i create mode 100644 Lib/java/std_map.i create mode 100644 Lib/java/std_pair.i create mode 100644 Lib/java/std_string.i create mode 100644 Lib/java/std_vector.i create mode 100644 Lib/java/std_wstring.i create mode 100644 Lib/java/stl.i create mode 100644 Lib/java/typemaps.i create mode 100644 Lib/java/various.i create mode 100644 Lib/linkruntime.c create mode 100644 Lib/lua/_std_common.i create mode 100644 Lib/lua/carrays.i create mode 100644 Lib/lua/lua.swg create mode 100644 Lib/lua/lua_fnptr.i create mode 100644 Lib/lua/luarun.swg create mode 100644 Lib/lua/luaruntime.swg create mode 100644 Lib/lua/luatypemaps.swg create mode 100644 Lib/lua/std_common.i create mode 100644 Lib/lua/std_deque.i create mode 100644 Lib/lua/std_except.i create mode 100644 Lib/lua/std_map.i create mode 100644 Lib/lua/std_pair.i create mode 100644 Lib/lua/std_string.i create mode 100644 Lib/lua/std_vector.i create mode 100644 Lib/lua/stl.i create mode 100644 Lib/lua/typemaps.i create mode 100644 Lib/lua/wchar.i create mode 100644 Lib/math.i create mode 100644 Lib/modula3/modula3.swg create mode 100644 Lib/modula3/modula3head.swg create mode 100644 Lib/modula3/typemaps.i create mode 100644 Lib/mzscheme/Makefile create mode 100644 Lib/mzscheme/mzrun.swg create mode 100644 Lib/mzscheme/mzscheme.swg create mode 100644 Lib/mzscheme/std_common.i create mode 100644 Lib/mzscheme/std_deque.i create mode 100644 Lib/mzscheme/std_map.i create mode 100644 Lib/mzscheme/std_pair.i create mode 100644 Lib/mzscheme/std_string.i create mode 100644 Lib/mzscheme/std_vector.i create mode 100644 Lib/mzscheme/stl.i create mode 100644 Lib/mzscheme/typemaps.i create mode 100644 Lib/ocaml/carray.i create mode 100644 Lib/ocaml/class.swg create mode 100644 Lib/ocaml/cstring.i create mode 100644 Lib/ocaml/director.swg create mode 100644 Lib/ocaml/extra-install.list create mode 100644 Lib/ocaml/libswigocaml.h create mode 100644 Lib/ocaml/ocaml.i create mode 100644 Lib/ocaml/ocaml.swg create mode 100644 Lib/ocaml/ocamldec.swg create mode 100644 Lib/ocaml/ocamlkw.swg create mode 100644 Lib/ocaml/preamble.swg create mode 100644 Lib/ocaml/std_common.i create mode 100644 Lib/ocaml/std_complex.i create mode 100644 Lib/ocaml/std_deque.i create mode 100644 Lib/ocaml/std_list.i create mode 100644 Lib/ocaml/std_map.i create mode 100644 Lib/ocaml/std_pair.i create mode 100644 Lib/ocaml/std_string.i create mode 100644 Lib/ocaml/std_vector.i create mode 100644 Lib/ocaml/stl.i create mode 100644 Lib/ocaml/swig.ml create mode 100644 Lib/ocaml/swig.mli create mode 100644 Lib/ocaml/swigp4.ml.in create mode 100644 Lib/ocaml/typecheck.i create mode 100644 Lib/ocaml/typemaps.i create mode 100644 Lib/ocaml/typeregister.swg create mode 100644 Lib/octave/attribute.i create mode 100644 Lib/octave/boost_shared_ptr.i create mode 100644 Lib/octave/carrays.i create mode 100644 Lib/octave/cdata.i create mode 100644 Lib/octave/cmalloc.i create mode 100644 Lib/octave/director.swg create mode 100644 Lib/octave/exception.i create mode 100644 Lib/octave/factory.i create mode 100644 Lib/octave/implicit.i create mode 100644 Lib/octave/octave.swg create mode 100644 Lib/octave/octcomplex.swg create mode 100644 Lib/octave/octcontainer.swg create mode 100644 Lib/octave/octfragments.swg create mode 100644 Lib/octave/octiterators.swg create mode 100644 Lib/octave/octopers.swg create mode 100644 Lib/octave/octprimtypes.swg create mode 100644 Lib/octave/octrun.swg create mode 100644 Lib/octave/octruntime.swg create mode 100644 Lib/octave/octstdcommon.swg create mode 100644 Lib/octave/octtypemaps.swg create mode 100644 Lib/octave/octuserdir.swg create mode 100644 Lib/octave/std_alloc.i create mode 100644 Lib/octave/std_basic_string.i create mode 100644 Lib/octave/std_carray.i create mode 100644 Lib/octave/std_char_traits.i create mode 100644 Lib/octave/std_common.i create mode 100644 Lib/octave/std_complex.i create mode 100644 Lib/octave/std_container.i create mode 100644 Lib/octave/std_deque.i create mode 100644 Lib/octave/std_except.i create mode 100644 Lib/octave/std_map.i create mode 100644 Lib/octave/std_pair.i create mode 100644 Lib/octave/std_string.i create mode 100644 Lib/octave/std_vector.i create mode 100644 Lib/octave/stl.i create mode 100644 Lib/octave/typemaps.i create mode 100644 Lib/perl5/Makefile.in create mode 100644 Lib/perl5/Makefile.pl create mode 100644 Lib/perl5/attribute.i create mode 100644 Lib/perl5/carrays.i create mode 100644 Lib/perl5/cdata.i create mode 100644 Lib/perl5/cmalloc.i create mode 100644 Lib/perl5/cni.i create mode 100644 Lib/perl5/cpointer.i create mode 100644 Lib/perl5/cstring.i create mode 100644 Lib/perl5/exception.i create mode 100644 Lib/perl5/extra-install.list create mode 100644 Lib/perl5/factory.i create mode 100644 Lib/perl5/jstring.i create mode 100644 Lib/perl5/noembed.h create mode 100644 Lib/perl5/perl5.swg create mode 100644 Lib/perl5/perlerrors.swg create mode 100644 Lib/perl5/perlfragments.swg create mode 100644 Lib/perl5/perlhead.swg create mode 100644 Lib/perl5/perlinit.swg create mode 100644 Lib/perl5/perlkw.swg create mode 100644 Lib/perl5/perlmacros.swg create mode 100644 Lib/perl5/perlmain.i create mode 100644 Lib/perl5/perlopers.swg create mode 100644 Lib/perl5/perlprimtypes.swg create mode 100644 Lib/perl5/perlrun.swg create mode 100644 Lib/perl5/perlruntime.swg create mode 100644 Lib/perl5/perlstrings.swg create mode 100644 Lib/perl5/perltypemaps.swg create mode 100644 Lib/perl5/perluserdir.swg create mode 100644 Lib/perl5/reference.i create mode 100644 Lib/perl5/std_common.i create mode 100644 Lib/perl5/std_deque.i create mode 100644 Lib/perl5/std_except.i create mode 100644 Lib/perl5/std_list.i create mode 100644 Lib/perl5/std_map.i create mode 100644 Lib/perl5/std_pair.i create mode 100644 Lib/perl5/std_string.i create mode 100644 Lib/perl5/std_vector.i create mode 100644 Lib/perl5/stl.i create mode 100644 Lib/perl5/typemaps.i create mode 100644 Lib/php/const.i create mode 100644 Lib/php/director.swg create mode 100644 Lib/php/factory.i create mode 100644 Lib/php/globalvar.i create mode 100644 Lib/php/php.swg create mode 100644 Lib/php/phpinit.swg create mode 100644 Lib/php/phpkw.swg create mode 100644 Lib/php/phppointers.i create mode 100644 Lib/php/phprun.swg create mode 100644 Lib/php/std_common.i create mode 100644 Lib/php/std_deque.i create mode 100644 Lib/php/std_map.i create mode 100644 Lib/php/std_pair.i create mode 100644 Lib/php/std_string.i create mode 100644 Lib/php/std_vector.i create mode 100644 Lib/php/stl.i create mode 100644 Lib/php/typemaps.i create mode 100644 Lib/php/utils.i create mode 100644 Lib/pike/pike.swg create mode 100644 Lib/pike/pikekw.swg create mode 100644 Lib/pike/pikerun.swg create mode 100644 Lib/pike/std_string.i create mode 100644 Lib/pointer.i create mode 100644 Lib/python/Makefile.in create mode 100644 Lib/python/README create mode 100644 Lib/python/argcargv.i create mode 100644 Lib/python/attribute.i create mode 100644 Lib/python/boost_shared_ptr.i create mode 100644 Lib/python/carrays.i create mode 100644 Lib/python/ccomplex.i create mode 100644 Lib/python/cdata.i create mode 100644 Lib/python/cmalloc.i create mode 100644 Lib/python/cni.i create mode 100644 Lib/python/complex.i create mode 100644 Lib/python/cpointer.i create mode 100644 Lib/python/cstring.i create mode 100644 Lib/python/cwstring.i create mode 100644 Lib/python/defarg.swg create mode 100644 Lib/python/director.swg create mode 100644 Lib/python/embed.i create mode 100644 Lib/python/embed15.i create mode 100644 Lib/python/exception.i create mode 100644 Lib/python/factory.i create mode 100644 Lib/python/file.i create mode 100644 Lib/python/implicit.i create mode 100644 Lib/python/jstring.i create mode 100644 Lib/python/pyabc.i create mode 100644 Lib/python/pyapi.swg create mode 100644 Lib/python/pybackward.swg create mode 100644 Lib/python/pybuffer.i create mode 100644 Lib/python/pyclasses.swg create mode 100644 Lib/python/pycomplex.swg create mode 100644 Lib/python/pycontainer.swg create mode 100644 Lib/python/pydocs.swg create mode 100644 Lib/python/pyerrors.swg create mode 100644 Lib/python/pyfragments.swg create mode 100644 Lib/python/pyhead.swg create mode 100644 Lib/python/pyinit.swg create mode 100644 Lib/python/pyiterators.swg create mode 100644 Lib/python/pymacros.swg create mode 100644 Lib/python/pyname_compat.i create mode 100644 Lib/python/pyopers.swg create mode 100644 Lib/python/pyprimtypes.swg create mode 100644 Lib/python/pyrun.swg create mode 100644 Lib/python/pyruntime.swg create mode 100644 Lib/python/pystdcommon.swg create mode 100644 Lib/python/pystrings.swg create mode 100644 Lib/python/python.swg create mode 100644 Lib/python/pythonkw.swg create mode 100644 Lib/python/pythreads.swg create mode 100644 Lib/python/pytuplehlp.swg create mode 100644 Lib/python/pytypemaps.swg create mode 100644 Lib/python/pyuserdir.swg create mode 100644 Lib/python/pywstrings.swg create mode 100644 Lib/python/std_alloc.i create mode 100644 Lib/python/std_basic_string.i create mode 100644 Lib/python/std_carray.i create mode 100644 Lib/python/std_char_traits.i create mode 100644 Lib/python/std_common.i create mode 100644 Lib/python/std_complex.i create mode 100644 Lib/python/std_container.i create mode 100644 Lib/python/std_deque.i create mode 100644 Lib/python/std_except.i create mode 100644 Lib/python/std_ios.i create mode 100644 Lib/python/std_iostream.i create mode 100644 Lib/python/std_list.i create mode 100644 Lib/python/std_map.i create mode 100644 Lib/python/std_multimap.i create mode 100644 Lib/python/std_multiset.i create mode 100644 Lib/python/std_pair.i create mode 100644 Lib/python/std_set.i create mode 100644 Lib/python/std_sstream.i create mode 100644 Lib/python/std_streambuf.i create mode 100644 Lib/python/std_string.i create mode 100644 Lib/python/std_vector.i create mode 100644 Lib/python/std_vectora.i create mode 100644 Lib/python/std_wios.i create mode 100644 Lib/python/std_wiostream.i create mode 100644 Lib/python/std_wsstream.i create mode 100644 Lib/python/std_wstreambuf.i create mode 100644 Lib/python/std_wstring.i create mode 100644 Lib/python/stl.i create mode 100644 Lib/python/typemaps.i create mode 100644 Lib/python/wchar.i create mode 100644 Lib/r/cdata.i create mode 100644 Lib/r/exception.i create mode 100644 Lib/r/r.swg create mode 100644 Lib/r/rcontainer.swg create mode 100644 Lib/r/rfragments.swg create mode 100644 Lib/r/rkw.swg create mode 100644 Lib/r/ropers.swg create mode 100644 Lib/r/rrun.swg create mode 100644 Lib/r/rstdcommon.swg create mode 100644 Lib/r/rtype.swg create mode 100644 Lib/r/srun.swg create mode 100644 Lib/r/std_alloc.i create mode 100644 Lib/r/std_common.i create mode 100644 Lib/r/std_container.i create mode 100644 Lib/r/std_deque.i create mode 100644 Lib/r/std_except.i create mode 100644 Lib/r/std_pair.i create mode 100644 Lib/r/std_string.i create mode 100644 Lib/r/std_vector.i create mode 100644 Lib/r/stl.i create mode 100644 Lib/r/typemaps.i create mode 100644 Lib/ruby/Makefile.swig create mode 100644 Lib/ruby/argcargv.i create mode 100644 Lib/ruby/attribute.i create mode 100644 Lib/ruby/carrays.i create mode 100644 Lib/ruby/cdata.i create mode 100644 Lib/ruby/cmalloc.i create mode 100644 Lib/ruby/cni.i create mode 100644 Lib/ruby/cpointer.i create mode 100644 Lib/ruby/cstring.i create mode 100644 Lib/ruby/director.swg create mode 100644 Lib/ruby/embed.i create mode 100644 Lib/ruby/exception.i create mode 100644 Lib/ruby/extconf.rb create mode 100644 Lib/ruby/extra-install.list create mode 100644 Lib/ruby/factory.i create mode 100644 Lib/ruby/file.i create mode 100644 Lib/ruby/jstring.i create mode 100644 Lib/ruby/progargcargv.i create mode 100644 Lib/ruby/ruby.swg create mode 100644 Lib/ruby/rubyapi.swg create mode 100644 Lib/ruby/rubyautodoc.swg create mode 100644 Lib/ruby/rubyclasses.swg create mode 100644 Lib/ruby/rubycomplex.swg create mode 100644 Lib/ruby/rubycontainer.swg create mode 100644 Lib/ruby/rubycontainer_extended.swg create mode 100644 Lib/ruby/rubydef.swg create mode 100644 Lib/ruby/rubyerrors.swg create mode 100644 Lib/ruby/rubyfragments.swg create mode 100644 Lib/ruby/rubyhead.swg create mode 100644 Lib/ruby/rubyinit.swg create mode 100644 Lib/ruby/rubyiterators.swg create mode 100644 Lib/ruby/rubykw.swg create mode 100644 Lib/ruby/rubymacros.swg create mode 100644 Lib/ruby/rubyopers.swg create mode 100644 Lib/ruby/rubyprimtypes.swg create mode 100644 Lib/ruby/rubyrun.swg create mode 100644 Lib/ruby/rubyruntime.swg create mode 100644 Lib/ruby/rubystdautodoc.swg create mode 100644 Lib/ruby/rubystdcommon.swg create mode 100644 Lib/ruby/rubystdfunctors.swg create mode 100644 Lib/ruby/rubystrings.swg create mode 100644 Lib/ruby/rubytracking.swg create mode 100644 Lib/ruby/rubytypemaps.swg create mode 100644 Lib/ruby/rubyuserdir.swg create mode 100644 Lib/ruby/rubywstrings.swg create mode 100644 Lib/ruby/std_alloc.i create mode 100644 Lib/ruby/std_basic_string.i create mode 100644 Lib/ruby/std_char_traits.i create mode 100644 Lib/ruby/std_common.i create mode 100644 Lib/ruby/std_complex.i create mode 100644 Lib/ruby/std_container.i create mode 100644 Lib/ruby/std_deque.i create mode 100644 Lib/ruby/std_except.i create mode 100644 Lib/ruby/std_functors.i create mode 100644 Lib/ruby/std_ios.i create mode 100644 Lib/ruby/std_iostream.i create mode 100644 Lib/ruby/std_list.i create mode 100644 Lib/ruby/std_map.i create mode 100644 Lib/ruby/std_multimap.i create mode 100644 Lib/ruby/std_multiset.i create mode 100644 Lib/ruby/std_pair.i create mode 100644 Lib/ruby/std_queue.i create mode 100644 Lib/ruby/std_set.i create mode 100644 Lib/ruby/std_sstream.i create mode 100644 Lib/ruby/std_stack.i create mode 100644 Lib/ruby/std_streambuf.i create mode 100644 Lib/ruby/std_string.i create mode 100644 Lib/ruby/std_vector.i create mode 100644 Lib/ruby/std_vectora.i create mode 100644 Lib/ruby/std_wstring.i create mode 100644 Lib/ruby/stl.i create mode 100644 Lib/ruby/timeval.i create mode 100644 Lib/ruby/typemaps.i create mode 100644 Lib/runtime.swg create mode 100644 Lib/shared_ptr.i create mode 100644 Lib/std/README create mode 100644 Lib/std/_std_deque.i create mode 100644 Lib/std/std_alloc.i create mode 100644 Lib/std/std_basic_string.i create mode 100644 Lib/std/std_carray.swg create mode 100644 Lib/std/std_char_traits.i create mode 100644 Lib/std/std_common.i create mode 100644 Lib/std/std_container.i create mode 100644 Lib/std/std_deque.i create mode 100644 Lib/std/std_except.i create mode 100644 Lib/std/std_ios.i create mode 100644 Lib/std/std_iostream.i create mode 100644 Lib/std/std_list.i create mode 100644 Lib/std/std_map.i create mode 100644 Lib/std/std_multimap.i create mode 100644 Lib/std/std_multiset.i create mode 100644 Lib/std/std_pair.i create mode 100644 Lib/std/std_queue.i create mode 100644 Lib/std/std_set.i create mode 100644 Lib/std/std_sstream.i create mode 100644 Lib/std/std_stack.i create mode 100644 Lib/std/std_streambuf.i create mode 100644 Lib/std/std_string.i create mode 100644 Lib/std/std_vector.i create mode 100644 Lib/std/std_vectora.i create mode 100644 Lib/std/std_wios.i create mode 100644 Lib/std/std_wiostream.i create mode 100644 Lib/std/std_wsstream.i create mode 100644 Lib/std/std_wstreambuf.i create mode 100644 Lib/std/std_wstring.i create mode 100644 Lib/std_except.i create mode 100644 Lib/stdint.i create mode 100644 Lib/stl.i create mode 100644 Lib/swig.swg create mode 100644 Lib/swigarch.i create mode 100644 Lib/swigerrors.swg create mode 100644 Lib/swiginit.swg create mode 100644 Lib/swiglabels.swg create mode 100644 Lib/swigrun.i create mode 100644 Lib/swigrun.swg create mode 100644 Lib/swigwarn.swg create mode 100644 Lib/swigwarnings.swg create mode 100644 Lib/tcl/Makefile.in create mode 100644 Lib/tcl/attribute.i create mode 100644 Lib/tcl/carrays.i create mode 100644 Lib/tcl/cdata.i create mode 100644 Lib/tcl/cmalloc.i create mode 100644 Lib/tcl/cni.i create mode 100644 Lib/tcl/cpointer.i create mode 100644 Lib/tcl/cstring.i create mode 100644 Lib/tcl/cwstring.i create mode 100644 Lib/tcl/exception.i create mode 100644 Lib/tcl/factory.i create mode 100644 Lib/tcl/jstring.i create mode 100644 Lib/tcl/mactclinit.c create mode 100644 Lib/tcl/mactkinit.c create mode 100644 Lib/tcl/std_common.i create mode 100644 Lib/tcl/std_deque.i create mode 100644 Lib/tcl/std_except.i create mode 100644 Lib/tcl/std_map.i create mode 100644 Lib/tcl/std_pair.i create mode 100644 Lib/tcl/std_string.i create mode 100644 Lib/tcl/std_vector.i create mode 100644 Lib/tcl/std_wstring.i create mode 100644 Lib/tcl/stl.i create mode 100644 Lib/tcl/tcl8.swg create mode 100644 Lib/tcl/tclapi.swg create mode 100644 Lib/tcl/tclerrors.swg create mode 100644 Lib/tcl/tclfragments.swg create mode 100644 Lib/tcl/tclinit.swg create mode 100644 Lib/tcl/tclinterp.i create mode 100644 Lib/tcl/tclkw.swg create mode 100644 Lib/tcl/tclmacros.swg create mode 100644 Lib/tcl/tclopers.swg create mode 100644 Lib/tcl/tclprimtypes.swg create mode 100644 Lib/tcl/tclresult.i create mode 100644 Lib/tcl/tclrun.swg create mode 100644 Lib/tcl/tclruntime.swg create mode 100644 Lib/tcl/tclsh.i create mode 100644 Lib/tcl/tclstrings.swg create mode 100644 Lib/tcl/tcltypemaps.swg create mode 100644 Lib/tcl/tcluserdir.swg create mode 100644 Lib/tcl/tclwstrings.swg create mode 100644 Lib/tcl/typemaps.i create mode 100644 Lib/tcl/wish.i create mode 100644 Lib/typemaps/README create mode 100644 Lib/typemaps/attribute.swg create mode 100644 Lib/typemaps/carrays.swg create mode 100644 Lib/typemaps/cdata.swg create mode 100644 Lib/typemaps/cmalloc.swg create mode 100644 Lib/typemaps/cpointer.swg create mode 100644 Lib/typemaps/cstring.swg create mode 100644 Lib/typemaps/cstrings.swg create mode 100644 Lib/typemaps/cwstring.swg create mode 100644 Lib/typemaps/enumint.swg create mode 100644 Lib/typemaps/exception.swg create mode 100644 Lib/typemaps/factory.swg create mode 100644 Lib/typemaps/fragments.swg create mode 100644 Lib/typemaps/implicit.swg create mode 100644 Lib/typemaps/inoutlist.swg create mode 100644 Lib/typemaps/misctypes.swg create mode 100644 Lib/typemaps/primtypes.swg create mode 100644 Lib/typemaps/ptrtypes.swg create mode 100644 Lib/typemaps/std_except.swg create mode 100644 Lib/typemaps/std_string.swg create mode 100644 Lib/typemaps/std_strings.swg create mode 100644 Lib/typemaps/std_wstring.swg create mode 100644 Lib/typemaps/string.swg create mode 100644 Lib/typemaps/strings.swg create mode 100644 Lib/typemaps/swigmacros.swg create mode 100644 Lib/typemaps/swigobject.swg create mode 100644 Lib/typemaps/swigtype.swg create mode 100644 Lib/typemaps/swigtypemaps.swg create mode 100644 Lib/typemaps/traits.swg create mode 100644 Lib/typemaps/typemaps.swg create mode 100644 Lib/typemaps/valtypes.swg create mode 100644 Lib/typemaps/void.swg create mode 100644 Lib/typemaps/wstring.swg create mode 100644 Lib/uffi/uffi.swg create mode 100644 Lib/wchar.i create mode 100644 Lib/windows.i create mode 100644 Lib/xml/typemaps.i create mode 100644 Lib/xml/xml.swg create mode 100644 Makefile.in create mode 100644 Misc/fileheader create mode 100644 NEW create mode 100644 README create mode 100644 Source/CParse/cparse.h create mode 100644 Source/CParse/cscanner.c create mode 100644 Source/CParse/parser.c create mode 100644 Source/CParse/parser.h create mode 100644 Source/CParse/parser.y create mode 100644 Source/CParse/templ.c create mode 100644 Source/CParse/util.c create mode 100644 Source/DOH/README create mode 100644 Source/DOH/base.c create mode 100644 Source/DOH/doh.h create mode 100644 Source/DOH/dohint.h create mode 100644 Source/DOH/file.c create mode 100644 Source/DOH/fio.c create mode 100644 Source/DOH/hash.c create mode 100644 Source/DOH/list.c create mode 100644 Source/DOH/memory.c create mode 100644 Source/DOH/string.c create mode 100644 Source/DOH/void.c create mode 100644 Source/Include/swigconfig.h.in create mode 100644 Source/Include/swigwarn.h create mode 100644 Source/Makefile.am create mode 100644 Source/Makefile.in create mode 100644 Source/Modules/README create mode 100644 Source/Modules/allegrocl.cxx create mode 100644 Source/Modules/allocate.cxx create mode 100644 Source/Modules/browser.cxx create mode 100644 Source/Modules/cffi.cxx create mode 100644 Source/Modules/chicken.cxx create mode 100644 Source/Modules/clisp.cxx create mode 100644 Source/Modules/contract.cxx create mode 100644 Source/Modules/csharp.cxx create mode 100644 Source/Modules/directors.cxx create mode 100644 Source/Modules/emit.cxx create mode 100644 Source/Modules/guile.cxx create mode 100644 Source/Modules/java.cxx create mode 100644 Source/Modules/lang.cxx create mode 100644 Source/Modules/lua.cxx create mode 100644 Source/Modules/main.cxx create mode 100644 Source/Modules/modula3.cxx create mode 100644 Source/Modules/module.cxx create mode 100644 Source/Modules/mzscheme.cxx create mode 100644 Source/Modules/ocaml.cxx create mode 100644 Source/Modules/octave.cxx create mode 100644 Source/Modules/overload.cxx create mode 100644 Source/Modules/perl5.cxx create mode 100644 Source/Modules/php.cxx create mode 100644 Source/Modules/pike.cxx create mode 100644 Source/Modules/python.cxx create mode 100644 Source/Modules/r.cxx create mode 100644 Source/Modules/ruby.cxx create mode 100644 Source/Modules/s-exp.cxx create mode 100644 Source/Modules/swigmain.cxx create mode 100644 Source/Modules/swigmod.h create mode 100644 Source/Modules/tcl8.cxx create mode 100644 Source/Modules/typepass.cxx create mode 100644 Source/Modules/uffi.cxx create mode 100644 Source/Modules/utils.cxx create mode 100644 Source/Modules/xml.cxx create mode 100644 Source/Preprocessor/cpp.c create mode 100644 Source/Preprocessor/expr.c create mode 100644 Source/Preprocessor/preprocessor.h create mode 100644 Source/README create mode 100644 Source/Swig/cwrap.c create mode 100644 Source/Swig/deprecate.c create mode 100644 Source/Swig/error.c create mode 100644 Source/Swig/fragment.c create mode 100644 Source/Swig/getopt.c create mode 100644 Source/Swig/include.c create mode 100644 Source/Swig/misc.c create mode 100644 Source/Swig/naming.c create mode 100644 Source/Swig/parms.c create mode 100644 Source/Swig/scanner.c create mode 100644 Source/Swig/stype.c create mode 100644 Source/Swig/swig.h create mode 100644 Source/Swig/swigfile.h create mode 100644 Source/Swig/swigopt.h create mode 100644 Source/Swig/swigparm.h create mode 100644 Source/Swig/swigscan.h create mode 100644 Source/Swig/swigtree.h create mode 100644 Source/Swig/swigwrap.h create mode 100644 Source/Swig/symbol.c create mode 100644 Source/Swig/tree.c create mode 100644 Source/Swig/typemap.c create mode 100644 Source/Swig/typeobj.c create mode 100644 Source/Swig/typesys.c create mode 100644 Source/Swig/warn.c create mode 100644 Source/Swig/wrapfunc.c create mode 100644 TODO create mode 100644 Tools/WAD/CHANGES create mode 100644 Tools/WAD/COPYING create mode 100644 Tools/WAD/HACK create mode 100644 Tools/WAD/Include/wad.h create mode 100644 Tools/WAD/Makefile.in create mode 100644 Tools/WAD/Misc/fileheader create mode 100644 Tools/WAD/Papers/README create mode 100644 Tools/WAD/Prebuilt/linux/Makefile.in create mode 100644 Tools/WAD/Prebuilt/solaris/Makefile.in create mode 100644 Tools/WAD/Python/Makefile.in create mode 100644 Tools/WAD/Python/python.c create mode 100644 Tools/WAD/Python/type.c create mode 100644 Tools/WAD/Python/wadpyinit.cxx create mode 100644 Tools/WAD/README create mode 100644 Tools/WAD/Tcl/Makefile.in create mode 100644 Tools/WAD/Tcl/wadtcl.c create mode 100644 Tools/WAD/Tcl/wadtclinit.cxx create mode 100644 Tools/WAD/Test/Makefile.in create mode 100644 Tools/WAD/Test/README create mode 100644 Tools/WAD/Test/death.py create mode 100644 Tools/WAD/Test/death.tcl create mode 100644 Tools/WAD/Test/debug.c create mode 100644 Tools/WAD/Test/debug.i create mode 100644 Tools/WAD/Test/debug.py create mode 100644 Tools/WAD/Test/debug.tcl create mode 100644 Tools/WAD/Test/foo.py create mode 100644 Tools/WAD/Test/wadpm.py create mode 100644 Tools/WAD/Test/wpm.py create mode 100644 Tools/WAD/Wad/Makefile.in create mode 100644 Tools/WAD/Wad/debug.c create mode 100644 Tools/WAD/Wad/default.c create mode 100644 Tools/WAD/Wad/demangle.c create mode 100644 Tools/WAD/Wad/elf.c create mode 100644 Tools/WAD/Wad/init.c create mode 100644 Tools/WAD/Wad/io.c create mode 100644 Tools/WAD/Wad/libwadpl.pm create mode 100644 Tools/WAD/Wad/main.cxx create mode 100755 Tools/WAD/Wad/makehandler.py create mode 100644 Tools/WAD/Wad/memory.c create mode 100644 Tools/WAD/Wad/object.c create mode 100644 Tools/WAD/Wad/return.c create mode 100644 Tools/WAD/Wad/segment.c create mode 100644 Tools/WAD/Wad/signal.c create mode 100644 Tools/WAD/Wad/stab.c create mode 100644 Tools/WAD/Wad/stack.c create mode 100644 Tools/WAD/Wad/string.c create mode 100644 Tools/WAD/Wad/vars.c create mode 100644 Tools/WAD/Wad/wadhandler.pl create mode 100644 Tools/WAD/Wad/wadpl.cxx create mode 100755 Tools/WAD/configure create mode 100644 Tools/WAD/configure.in create mode 100755 Tools/capitalize create mode 100644 Tools/check-include-path.pike create mode 100644 Tools/config/ac_compare_version.m4 create mode 100644 Tools/config/ac_compile_warnings.m4 create mode 100644 Tools/config/ac_define_dir.m4 create mode 100755 Tools/config/compile create mode 100755 Tools/config/config.guess create mode 100755 Tools/config/config.sub create mode 100755 Tools/config/depcomp create mode 100755 Tools/config/install-sh create mode 100755 Tools/config/missing create mode 100755 Tools/config/ylwrap create mode 100755 Tools/mkdist.py create mode 100755 Tools/mkrelease.py create mode 100755 Tools/mkwindows.sh create mode 100644 Tools/pyname_patch.py create mode 100644 Tools/setup.py.tmpl create mode 100644 Tools/swig.spec.1 create mode 100755 Tools/vcfilter create mode 100644 Win/README.txt create mode 100644 aclocal.m4 create mode 100755 autogen.sh create mode 100755 configure create mode 100644 configure.in create mode 100644 packaging/swig-1.3.23-pylib.patch create mode 100644 packaging/swig-rpmlintrc create mode 100644 packaging/swig.changes create mode 100644 packaging/swig.spec create mode 100755 preinst-swig.in create mode 100644 swig.spec.in create mode 100644 vms/aaareadme.txt create mode 100644 vms/build_end.com create mode 100644 vms/build_init.com create mode 100644 vms/build_swig.com create mode 100644 vms/genbuild.py create mode 100644 vms/logicals.com create mode 100644 vms/scripts/build_all.com create mode 100644 vms/scripts/compil_cparse.com create mode 100644 vms/scripts/compil_doh.com create mode 100644 vms/scripts/compil_modules1_1.com create mode 100644 vms/scripts/compil_preprocessor.com create mode 100644 vms/scripts/compil_swig.com create mode 100644 vms/swigconfig.h diff --git a/ANNOUNCE b/ANNOUNCE new file mode 100644 index 0000000..64e195d --- /dev/null +++ b/ANNOUNCE @@ -0,0 +1,37 @@ +*** ANNOUNCE: SWIG 1.3.40 (18 August 2009) *** + +http://www.swig.org + + +We're pleased to announce SWIG-1.3.40, the latest installment in the +SWIG development effort. SWIG-1.3.40 includes a number of bug fixes +and enhancements. + +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 languages including Perl, Python, Tcl, Ruby, PHP, Java, +Scheme (Guile, MzScheme, CHICKEN), Ocaml, Lua, Pike, C#, 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-1.3.40.tar.gz + +A Windows version is also available at + + http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip + +Please report problems with this release to the swig-dev mailing list, +details at http://www.swig.org/mail.html. + +--- The SWIG Developers + diff --git a/CCache/COPYING b/CCache/COPYING new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/CCache/COPYING @@ -0,0 +1,339 @@ + 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. diff --git a/CCache/Makefile.in b/CCache/Makefile.in new file mode 100644 index 0000000..29cf8db --- /dev/null +++ b/CCache/Makefile.in @@ -0,0 +1,73 @@ +datarootdir = @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 + mkdir -p man + yodl2html -o web/ccache-man.html ccache.yo + +install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 + ${INSTALLCMD} -d $(DESTDIR)${bindir} + ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) + ${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) + +distclean-docs: + rm -f $(PACKAGE_NAME).1 web/ccache-man.html + +check : test + +test: test.sh + SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' ./test.sh + +check: test + +distclean: clean distclean-docs + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h + +# 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 diff --git a/CCache/README b/CCache/README new file mode 100644 index 0000000..6e68a6e --- /dev/null +++ b/CCache/README @@ -0,0 +1,31 @@ +This 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 + diff --git a/CCache/README.swig b/CCache/README.swig new file mode 100644 index 0000000..aea0f3d --- /dev/null +++ b/CCache/README.swig @@ -0,0 +1,8 @@ +This 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. diff --git a/CCache/args.c b/CCache/args.c new file mode 100644 index 0000000..31e5471 --- /dev/null +++ b/CCache/args.c @@ -0,0 +1,91 @@ +/* + 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++; + } + } +} diff --git a/CCache/ccache-swig.1 b/CCache/ccache-swig.1 new file mode 100644 index 0000000..292873a --- /dev/null +++ b/CCache/ccache-swig.1 @@ -0,0 +1,453 @@ +.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 "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\&. +.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 "ccache-swig -s" 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 "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\&. +.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 +"which gcc" 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 "interesting" 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 \&'--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 +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\&'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 +"$HOME/\&.ccache"\&. +.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\&'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\&. +.IP +.IP "\fBCCACHE_CC\fP" +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\&. +.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 +\&'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 +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\&'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\&. +.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: "-E" redefines product from "object" to "source (stdout)" +when -E and -c is used together\&. +.IP +.IP "\fBCCACHE_SWIG\fP" +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\&'\&. +.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 +"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% +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 +\&'distcc\&' and ccache will prefix the command line used with the +compiler with the command \&'distcc\&'\&. +.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\&'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 "chmod g+s `find $CCACHE_DIR -type d`" 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\&'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\&'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 + diff --git a/CCache/ccache.c b/CCache/ccache.c new file mode 100644 index 0000000..d1696da --- /dev/null +++ b/CCache/ccache.c @@ -0,0 +1,1388 @@ +/* + 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); + } + + free(stderr_file); + if (passfail == -1) { + close(fd_stderr); + unlink(stderr_file); + return; + } + } + + /* 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; +} diff --git a/CCache/ccache.h b/CCache/ccache.h new file mode 100644 index 0000000..668ce82 --- /dev/null +++ b/CCache/ccache.h @@ -0,0 +1,205 @@ +#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); +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 */ +#ifdef __CYGWIN__ +#undef HAVE_MKSTEMP +#endif diff --git a/CCache/ccache.yo b/CCache/ccache.yo new file mode 100644 index 0000000..2477662 --- /dev/null +++ b/CCache/ccache.yo @@ -0,0 +1,422 @@ +whenman( +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( + + + + +)) diff --git a/CCache/ccache_swig_config.h.in b/CCache/ccache_swig_config.h.in new file mode 100644 index 0000000..bbb205f --- /dev/null +++ b/CCache/ccache_swig_config.h.in @@ -0,0 +1 @@ +#define SWIG_VERSION "@PACKAGE_VERSION@" diff --git a/CCache/cleanup.c b/CCache/cleanup.c new file mode 100644 index 0000000..9931228 --- /dev/null +++ b/CCache/cleanup.c @@ -0,0 +1,193 @@ +/* + 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(void) +{ + unsigned i; + + if (num_files > 1) { + /* sort in ascending data order */ + qsort(files, num_files, sizeof(struct files *), + (COMPAR_FN_T)files_compare); + } + + /* 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) +{ + 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(); + + 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]); + 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); +} diff --git a/CCache/config.h.in b/CCache/config.h.in new file mode 100644 index 0000000..893f98b --- /dev/null +++ b/CCache/config.h.in @@ -0,0 +1,115 @@ +/* config.h.in. Generated from configure.in 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 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 diff --git a/CCache/configure b/CCache/configure new file mode 100755 index 0000000..ddc25ec --- /dev/null +++ b/CCache/configure @@ -0,0 +1,5653 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61 for ccache-swig 0.0. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 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=: + # Zsh 3.x and 4.x performs 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 + + + + +# PATH needs CR +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); 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 +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 +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=: +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 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, 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= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='ccache-swig' +PACKAGE_TARNAME='ccache-swig' +PACKAGE_VERSION='0.0' +PACKAGE_STRING='ccache-swig 0.0' +PACKAGE_BUGREPORT='' + +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='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +CPP +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +GREP +EGREP +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + 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 +# 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=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_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=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_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=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 ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +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 + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +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 + 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 .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# 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 -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + 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 .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + 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-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 C/C++/Objective 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. + +_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" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 + 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.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 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 +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.61. 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=. + 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=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$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 + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export 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 + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_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 + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + 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'; { (exit 1); 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 + +# 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 + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + 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. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`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. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +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 + + # Get version from SWIG in ccache_swig_config.h.in + + + +{ echo "$as_me:$LINENO: Configuring ccache" >&5 +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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out 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. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.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 + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$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 +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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" + 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +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 +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + 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 { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f 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 +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + 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 { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +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 + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +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. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +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 +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$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 $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm -f conftest.sed + # for program_transform_name + + +cat >>confdefs.h <<\_ACEOF +#define _GNU_SOURCE 1 +_ACEOF + + +# 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=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `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 + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$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 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 + 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$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 + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$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 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 + 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$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 + +{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_time=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6; } +if test "${ac_cv_header_sys_wait_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_sys_wait_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_sys_wait_h=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6; } +if test $ac_cv_header_sys_wait_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF + +fi + + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + 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 + ac_count=`expr $ac_count + 1` + 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 + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + 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 + ac_count=`expr $ac_count + 1` + 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 + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 >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 "$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 >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 "$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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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 <$ac_header> +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header 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 <$ac_header> +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; 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 core 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 $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header 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 <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.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: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `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=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 $ac_func (); +/* 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_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_func in gethostname getpwuid +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 $ac_func (); +/* 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_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_func in utimes +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 $ac_func (); +/* 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_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +{ echo "$as_me:$LINENO: checking for compar_fn_t in stdlib.h" >&5 +echo $ECHO_N "checking for compar_fn_t in stdlib.h... $ECHO_C" >&6; } +if test "${ccache_cv_COMPAR_FN_T+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ccache_cv_COMPAR_FN_T=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ccache_cv_COMPAR_FN_T=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ccache_cv_COMPAR_FN_T" >&5 +echo "${ECHO_T}$ccache_cv_COMPAR_FN_T" >&6; } +if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_COMPAR_FN_T 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for C99 vsnprintf" >&5 +echo $ECHO_N "checking for C99 vsnprintf... $ECHO_C" >&6; } +if test "${ccache_cv_HAVE_C99_VSNPRINTF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +if test "$cross_compiling" = yes; then + ccache_cv_HAVE_C99_VSNPRINTF=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ccache_cv_HAVE_C99_VSNPRINTF=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ccache_cv_HAVE_C99_VSNPRINTF=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ccache_cv_HAVE_C99_VSNPRINTF" >&5 +echo "${ECHO_T}$ccache_cv_HAVE_C99_VSNPRINTF" >&6; } +if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_C99_VSNPRINTF 1 +_ACEOF + +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 + 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 { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; 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 core 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 { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.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;} + + ;; +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 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 +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +# 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_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 + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +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= +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=`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. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $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} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## 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=: + # Zsh 3.x and 4.x performs 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 + + + + +# PATH needs CR +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); 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 +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 +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=: +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 + +# 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.61. 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 + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet 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 ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +ccache-swig config.status 0.0 +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 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' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +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=$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 ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + 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. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$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 +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# 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" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + 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= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 52; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ 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[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[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="$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 || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$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 "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + 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 || +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" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`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 || +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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 +# 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= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + 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 + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;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 +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +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 "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then 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. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" + ;; + + + esac + +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# 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 || { (exit 1); exit 1; } +fi + diff --git a/CCache/configure.in b/CCache/configure.in new file mode 100644 index 0000000..dfbf86d --- /dev/null +++ b/CCache/configure.in @@ -0,0 +1,87 @@ +dnl 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 diff --git a/CCache/debian/NEWS b/CCache/debian/NEWS new file mode 100644 index 0000000..be245dc --- /dev/null +++ b/CCache/debian/NEWS @@ -0,0 +1,22 @@ +ccache (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 diff --git a/CCache/debian/README.Debian b/CCache/debian/README.Debian new file mode 100644 index 0000000..5478bb7 --- /dev/null +++ b/CCache/debian/README.Debian @@ -0,0 +1,59 @@ +Installing 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 diff --git a/CCache/debian/changelog b/CCache/debian/changelog new file mode 100644 index 0000000..45500d4 --- /dev/null +++ b/CCache/debian/changelog @@ -0,0 +1,221 @@ +ccache (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 + diff --git a/CCache/debian/compat b/CCache/debian/compat new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/CCache/debian/compat @@ -0,0 +1 @@ +6 diff --git a/CCache/debian/control b/CCache/debian/control new file mode 100644 index 0000000..0b7e572 --- /dev/null +++ b/CCache/debian/control @@ -0,0 +1,20 @@ +Source: 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. diff --git a/CCache/debian/copyright b/CCache/debian/copyright new file mode 100644 index 0000000..7ac791d --- /dev/null +++ b/CCache/debian/copyright @@ -0,0 +1,29 @@ +This 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. diff --git a/CCache/debian/dirs b/CCache/debian/dirs new file mode 100644 index 0000000..8ceb4c4 --- /dev/null +++ b/CCache/debian/dirs @@ -0,0 +1,3 @@ +usr/bin +usr/lib/ccache +usr/share/man/man1 diff --git a/CCache/debian/docs b/CCache/debian/docs new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/CCache/debian/docs @@ -0,0 +1 @@ +README diff --git a/CCache/debian/examples b/CCache/debian/examples new file mode 100644 index 0000000..fc54922 --- /dev/null +++ b/CCache/debian/examples @@ -0,0 +1,2 @@ +debian/update-ccache +manage-cache.sh diff --git a/CCache/debian/patches/01_no_home.diff b/CCache/debian/patches/01_no_home.diff new file mode 100644 index 0000000..019634c --- /dev/null +++ b/CCache/debian/patches/01_no_home.diff @@ -0,0 +1,100 @@ +--- 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; + } + diff --git a/CCache/debian/patches/02_ccache-compressed.diff b/CCache/debian/patches/02_ccache-compressed.diff new file mode 100644 index 0000000..5740c2c --- /dev/null +++ b/CCache/debian/patches/02_ccache-compressed.diff @@ -0,0 +1,1026 @@ +Index: 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 diff --git a/CCache/debian/patches/03_long_options.diff b/CCache/debian/patches/03_long_options.diff new file mode 100644 index 0000000..3235c38 --- /dev/null +++ b/CCache/debian/patches/03_long_options.diff @@ -0,0 +1,133 @@ +Index: 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 diff --git a/CCache/debian/patches/04_ignore_profile.diff b/CCache/debian/patches/04_ignore_profile.diff new file mode 100644 index 0000000..5683750 --- /dev/null +++ b/CCache/debian/patches/04_ignore_profile.diff @@ -0,0 +1,13 @@ +diff -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) { diff --git a/CCache/debian/patches/05_nfs_fix.diff b/CCache/debian/patches/05_nfs_fix.diff new file mode 100644 index 0000000..662d976 --- /dev/null +++ b/CCache/debian/patches/05_nfs_fix.diff @@ -0,0 +1,45 @@ +--- 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 diff --git a/CCache/debian/patches/06_md.diff b/CCache/debian/patches/06_md.diff new file mode 100644 index 0000000..3f68850 --- /dev/null +++ b/CCache/debian/patches/06_md.diff @@ -0,0 +1,77 @@ +--- 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 */ diff --git a/CCache/debian/patches/07_cachedirtag.diff b/CCache/debian/patches/07_cachedirtag.diff new file mode 100644 index 0000000..683b48d --- /dev/null +++ b/CCache/debian/patches/07_cachedirtag.diff @@ -0,0 +1,75 @@ +Index: 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 diff --git a/CCache/debian/patches/08_manpage_hyphens.diff b/CCache/debian/patches/08_manpage_hyphens.diff new file mode 100644 index 0000000..55ced4a --- /dev/null +++ b/CCache/debian/patches/08_manpage_hyphens.diff @@ -0,0 +1,89 @@ +Index: 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" diff --git a/CCache/debian/patches/09_respect_ldflags.diff b/CCache/debian/patches/09_respect_ldflags.diff new file mode 100644 index 0000000..0ce2c2d --- /dev/null +++ b/CCache/debian/patches/09_respect_ldflags.diff @@ -0,0 +1,11 @@ +--- 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 diff --git a/CCache/debian/patches/10_lru_cleanup.diff b/CCache/debian/patches/10_lru_cleanup.diff new file mode 100644 index 0000000..24463e5 --- /dev/null +++ b/CCache/debian/patches/10_lru_cleanup.diff @@ -0,0 +1,23 @@ +--- 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) { diff --git a/CCache/debian/patches/11_utimes.diff b/CCache/debian/patches/11_utimes.diff new file mode 100644 index 0000000..2886bf3 --- /dev/null +++ b/CCache/debian/patches/11_utimes.diff @@ -0,0 +1,85 @@ +--- 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( diff --git a/CCache/debian/patches/12_cachesize_permissions.diff b/CCache/debian/patches/12_cachesize_permissions.diff new file mode 100644 index 0000000..28801b7 --- /dev/null +++ b/CCache/debian/patches/12_cachesize_permissions.diff @@ -0,0 +1,83 @@ +--- 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); diff --git a/CCache/debian/patches/13_html_links.diff b/CCache/debian/patches/13_html_links.diff new file mode 100644 index 0000000..dadf1b6 --- /dev/null +++ b/CCache/debian/patches/13_html_links.diff @@ -0,0 +1,33 @@ +--- 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: diff --git a/CCache/debian/patches/14_hardlink_doc.diff b/CCache/debian/patches/14_hardlink_doc.diff new file mode 100644 index 0000000..bd9e25b --- /dev/null +++ b/CCache/debian/patches/14_hardlink_doc.diff @@ -0,0 +1,48 @@ +Index: 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: +

    \n" + if subsubsection: + index += "\n" + if subsection: + index += "\n" + if section == 1: + index += "
      \n" + + index += """
    • %s\n""" % (headingname,prevheadingtext) + subsection = 0 + subsubsection = 0 + subsubsubsection = 0 + skipspace = 1 + continue + m = h3.match(s) + if m: + prevheadingtext = m.group(2) + nameindex += 1 + subsection += 1 + headingname = getheadingname(m) + result.append("""

      %d.%d.%d %s

      """ % (headingname,num,section, subsection, prevheadingtext)) + + if subsubsubsection: + index += "
    \n" + if subsubsection: + index += "\n" + if subsection == 1: + index += "
      \n" + + index += """
    • %s\n""" % (headingname,prevheadingtext) + subsubsection = 0 + skipspace = 1 + continue + m = h4.match(s) + if m: + prevheadingtext = m.group(2) + nameindex += 1 + subsubsection += 1 + + headingname = getheadingname(m) + result.append("""

      %d.%d.%d.%d %s

      """ % (headingname,num,section, subsection, subsubsection, prevheadingtext)) + + if subsubsubsection: + index += "
    \n" + if subsubsection == 1: + index += "
      \n" + + index += """
    • %s\n""" % (headingname,prevheadingtext) + subsubsubsection = 0 + skipspace = 1 + continue + m = h5.match(s) + if m: + prevheadingtext = m.group(2) + nameindex += 1 + subsubsubsection += 1 + headingname = getheadingname(m) + result.append("""
      %d.%d.%d.%d.%d %s
      """ % (headingname,num,section, subsection, subsubsection, subsubsubsection, prevheadingtext)) + + if subsubsubsection == 1: + index += "
        \n" + + index += """
      • %s\n""" % (headingname,prevheadingtext) + skipspace = 1 + continue + + result.append(s) + +if subsubsubsection: + index += "
      \n" + +if subsubsection: + index += "
    \n" + +if subsection: + index += "\n" + +if section: + index += "\n" + +index += "
  • \n\n" + +data = "\n".join(result) + +data = data.replace("@INDEX@",index) + "\n"; + +# Write the file back out +open(filename,"w").write(data) + +# Print the TOC data to stdout correcting the anchor links for external referencing + +index = index.replace("
  • %d %s\n""" % (filename,filenamebase,num,name) +print index + diff --git a/Doc/Manual/maketoc.py b/Doc/Manual/maketoc.py new file mode 100644 index 0000000..c78bcfd --- /dev/null +++ b/Doc/Manual/maketoc.py @@ -0,0 +1,37 @@ +#!/usr/local/bin/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, """ + + +""" + + diff --git a/Doc/Manual/margin-left.patch b/Doc/Manual/margin-left.patch new file mode 100644 index 0000000..70f087b --- /dev/null +++ b/Doc/Manual/margin-left.patch @@ -0,0 +1,269 @@ +# +# Patch managed by http://www.holgerschurig.de/patcher.html +# +# This patch is against htmldoc 1.8.24, and it hacks in support for +# correctly indenting the

    sections in the SWIG manual. +# This patch should only be used until the 1.9 branch of htmldoc +# stabalizes, since the 1.9 branch includes true CSS1 support. +# +# This patch only affects the PDF generation, an unpatched htmldoc +# creates the one-page html documentation just fine. +# +--- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left ++++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx +@@ -158,6 +158,7 @@ + # undef page_t + #endif // __hpux + ++extern int lookup_div_class(uchar *); + + /* + * Constants... +@@ -4188,9 +4189,24 @@ + para->child = para->last_child = NULL; + } + +- parse_doc(t->child, left, right, bottom, top, x, y, page, NULL, ++ { ++ int num_indent = 0; ++ uchar *cname; ++ ++ if (cname = htmlGetVariable(t, (uchar *)"class")) { ++ num_indent = lookup_div_class(cname); ++ *left += 5.0f * num_indent; ++ *x = *left; ++ } ++ ++ parse_doc(t->child, left, right, bottom, top, x, y, page, NULL, + needspace); + ++ if (num_indent > 0) { ++ *left -= 5.0f * num_indent; ++ } ++ } ++ + if (para->child != NULL) + { + parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace); +--- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left ++++ htmldoc-1.8.24/htmldoc/htmldoc.cxx +@@ -62,6 +62,8 @@ + const char *__XOS2RedirRoot(const char *); + } + #endif ++ ++extern void parse_style(char *); + + + /* +@@ -2140,6 +2142,10 @@ + } + else if (strcmp(temp, "--cookies") == 0) + file_cookies(temp2); ++ else if (strcmp(temp, "--stylesheet") == 0) ++ { ++ parse_style(temp2); ++ } + } + } + +--- /dev/null ++++ htmldoc-1.8.24/htmldoc/style.cxx +@@ -0,0 +1,185 @@ ++/* Extreamly simple parsing routines for CSS style sheets. ++ * We only parse div.class { } sections, and only look ++ * for margin-left: em; ++ * ++ * Copyright (C) 2005 John Lenz ++ * ++ * Released under GNU GPL v2 or above. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "types.h" ++ ++#define BUFF_SIZE 512 ++ ++struct div_entry { ++ uchar class_name[BUFF_SIZE]; ++ int indent; ++ struct div_entry *next; ++}; ++ ++static struct div_entry *head = 0; ++ ++/* These are the parsing states */ ++#define IGNORE_TILL_SEMI 0 ++#define IGNORE_TILL_CLOSE_BRACE 1 ++#define READING_DIV 2 ++#define READING_CLASS 3 ++#define READING_ATTRIBUTE 4 ++#define READING_NUM 5 ++#define CHECKING_ONLY_DIV 6 ++ ++static int at_eof = 0; ++ ++static int strucmp(uchar *a, uchar *b) { ++ int i; ++ for (i = 0; a[i] && b[i]; i++) { ++ if (a[i] < b[i]) return -1; ++ if (a[i] > b[i]) return 1; ++ } ++ /* This isn't right, but who cares...*/ ++ if (a[i] || b[i]) return 1; ++ return 0; ++} ++ ++static int read_word(FILE *f, const char *word) { ++ char c; ++ for (int idx = 0; word[idx]; idx++) { ++ c = getc(f); ++ if (c == EOF) { ++ at_eof = 1; ++ return 0; ++ } ++ if (c != word[idx]) ++ return 0; ++ } ++ return 1; ++} ++ ++int lookup_div_class(uchar *name) { ++ struct div_entry *node = head; ++ ++ while (node) { ++ if (strucmp(node->class_name, name) == 0) ++ return node->indent; ++ node = node->next; ++ } ++ ++ return 0; ++} ++ ++void parse_style(char *fname) { ++ FILE *f; ++ char c; ++ int state; ++ struct div_entry *cur = 0; ++ int class_idx = 0; ++ char num[BUFF_SIZE]; ++ int num_idx = 0; ++ ++ if (!fname) return; ++ ++ f = fopen(fname, "r"); ++ if (!f) { ++ fprintf(stderr, "Unable to parse style\n"); ++ return; ++ } ++ ++ state = READING_DIV; ++ while (!at_eof && (c = getc(f)) != EOF) { ++ switch (state) { ++ ++ case IGNORE_TILL_SEMI: ++ if (c == ';') ++ state = READING_ATTRIBUTE; ++ break; ++ ++ case IGNORE_TILL_CLOSE_BRACE: ++ if (c == '}') ++ state = READING_DIV; ++ break; ++ ++ case READING_DIV: ++ if (c != ' ' && c != '\t' && c != '\n') { ++ if (c == 'd' && read_word(f, "iv.")) { ++ state = READING_CLASS; ++ cur = (struct div_entry *) malloc(sizeof(struct div_entry)); ++ memset(cur, 0, sizeof(struct div_entry)); ++ class_idx = 0; ++ } else ++ state = IGNORE_TILL_CLOSE_BRACE; ++ } ++ break; ++ ++ case READING_CLASS: ++ if (isalpha(c)) { ++ if (class_idx >= BUFF_SIZE-1) { ++ fprintf(stderr, "class size %s too long\n", cur->class_name); ++ free(cur); ++ state = IGNORE_TILL_CLOSE_BRACE; ++ } else { ++ cur->class_name[class_idx++] = c; ++ } ++ } else { ++ if (c == '{') { ++ cur->next = head; ++ head = cur; ++ state = READING_ATTRIBUTE; ++ } else ++ state = CHECKING_ONLY_DIV; ++ } ++ break; ++ ++ case READING_ATTRIBUTE: ++ if (c != ' ' && c != '\t' && c != '\n') { ++ if (c == '}') ++ state = READING_DIV; ++ else { ++ if (c == 'm' && read_word(f, "argin-left:")) { ++ num_idx = 0; ++ memset(num, 0, sizeof(num)); ++ state = READING_NUM; ++ } else { ++ state = IGNORE_TILL_SEMI; ++ } ++ } ++ } ++ break; ++ ++ case READING_NUM: ++ if (isdigit(c)) { ++ if (num_idx >= BUFF_SIZE - 1) { ++ fprintf(stderr, "Number too long\n"); ++ state = IGNORE_TILL_SEMI; ++ } else { ++ num[num_idx++] = c; ++ } ++ } else if (c != ' ' && c != '\t') { ++ if (num_idx > 0 && c == 'e' && read_word(f, "m")) ++ cur->indent = atoi(num); ++ state = IGNORE_TILL_SEMI; ++ } ++ break; ++ ++ case CHECKING_ONLY_DIV: ++ if (c != ' ' && c != '\t' && c != '\n') { ++ if (c == '{') { ++ cur->next = head; ++ head = cur; ++ state = READING_ATTRIBUTE; ++ } else { ++ free(cur); ++ state = IGNORE_TILL_CLOSE_BRACE; ++ } ++ } ++ break; ++ } ++ } ++ ++ fclose(f); ++} +--- htmldoc-1.8.24/htmldoc/Makefile~margin-left ++++ htmldoc-1.8.24/htmldoc/Makefile +@@ -35,7 +35,7 @@ + + OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \ + http-addr.o http-support.o image.o iso8859.o license.o md5.o \ +- progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o ++ progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o + + + # + diff --git a/Doc/Manual/style.css b/Doc/Manual/style.css new file mode 100644 index 0000000..02329e5 --- /dev/null +++ b/Doc/Manual/style.css @@ -0,0 +1,84 @@ +div.sectiontoc { + border-style: dotted; + border-width: 2px; + padding: 2pt; +} + +h2 { + padding: 3px; + color: #000000; + border-bottom: 2px + solid #dddddd; +} + +h3, h4 { + margin-left: 1em; +} + +p,li,table,dl { + margin-left: 2em; + margin-right: 2em; +} + +div.indent { + margin-left: 4em; + margin-right: 4em; +} + +div.code { + border-style: solid; + border-width: 1px; + padding: 2pt; + margin-left: 4em; + margin-right: 4em; + background-color: #F0FFFF; +} + +div.targetlang { + border-style: solid; + border-width: 1px; + padding: 2pt; + margin-left: 4em; + margin-right: 4em; + background-color: #d7f6bb; +} + + +div.shell { + border-style: solid; + border-width: 1px; + padding: 2pt; + margin-left: 4em; + margin-right: 4em; + background-color: #DCDCDC; +} + +div.diagram { + border-style: solid; + border-width: 1px; + padding: 2pt; + margin-left: 4em; + margin-right: 4em; + background-color: #FFEBCD; +} + +ul li p { + margin-left: 0; + margin-right: 0; +} + +ol li p { + margin-left: 0; + margin-right: 0; +} + +dl dd p { + margin-left: 0; + margin-right: 0; +} + +div.indent p { + margin-left: 0; + margin-right: 0; +} + diff --git a/Doc/Manual/swig16.png b/Doc/Manual/swig16.png new file mode 100644 index 0000000000000000000000000000000000000000..73f3adc3eeb9bb2f29948147f07656965037650f GIT binary patch literal 5538 zcmdUyi$Bx-|NnQegPGH8%p96ihLLj)rOlaYmmv|krjj}2np0F)eQe~EoT4OZM#w2S zHHT^@IYdz-L>H1I7CN6U-?^yU?_c=scH8m&+~f6pJ|Fk@^YwnGx>1}Y5jX?@0FZQX zws#l3my4eJ;9$|KQjS>H`N3{PWL0`T6;Fc6LXP9@W;?e)jCyojZ5Fe*KCJeZ_*E-s;=p+q8)&*#g_%d=RlsHmu}t}YuJo0~UpN=r+N%KZQ0Au5N-WQy`n zNJvObOceDeDJdyAIXNXIB{elQEiFydne_DZ^XJcJWMpJ!W{P^1ot>SNlOyVIZf6n>DskxY&KhDD2Kx-DJdx}ExmsIy2z38 z^74v`iW@g>R9042RaJ>BuBoZ1t*sTcuCA``)~#Fh_4N%64I*conwpxMn? ztccKh|Ni}l4<9~${P^k9ClO;`zI+kk`t94d@87@w`0+!8_rL%CD!-I(47`7a#j9oyPl zmmj4VrKpquSNdBQxbd?^?5d941VL9f1j+LI@x^of^jllQVPh9ku3#%8A}m?TI(?7_ zei^JU(HrWVHtUaFd3*YY1$dx1R4CIoDtpa*^H7!b!TWiy`iJAQC1W|a+Kl>d_;D8E z8bSYwa;{iwjgAg<6vL0_-y$SJTL=3l5x7#}JFb>#t}@QC^C;tEvG&xUH_x z@DfNx(zEOQbHZlGWot}azknvYB<0AXi6yJ`G))~5@3+(SqB()ONTXu6BQ^t5tq;b{ z3b^(v*-tehHGPc$2~QCG=-42DE#05*5wlrRt98sCBy%`jL;W_%ZU})(5_-YukZ6vP zpo=|a{@@r&;A)teavwn#}rB z4L_&yS#Dj3es^XIT9XEG$)j09of#moN-SuD0*;^vHN$4ivLNaf`nFGtF`Ad+{a#B2 z7{dqv@=YA~UE^ZLQxnESsTfli@aGi&77Z2lmQS)%dGBDW9FG0-^ z-~h>sZv24Oe09Ef>?$zFo~ep9>k3r(uMqWTMYdtaNptMVLD`mqq#*iX41MNs9m_aA z9MZ*YYr|!t1xPTtP9q@E`mWgePO!G7{;;Ti>nHZN@gXcaS6Jr<9?-$xCWEBtCK6e& z$YN`-g(vSal;hIqq>tg82irT?JV`83l1Z>|(eWd7+E0Mjm7FYKZ zzNpXW7?;lixkC;ZvnD}gq>Mt9A&D>NR|^hya${Ik8SAta==6=UB2mgLj=!J}ll*hD zk_ScMIlNWs09HARoq<%~7{U~`P04`O^b+;RrWJTreGPs_=m+BUj8N-g4oU6t?ZpHO zL9qd*%Y(H+rTQ#odxV>u0yc~E4EWxhV5p+D6hSA8>BW0u*#<}A9gGb7)m~{>ykfN% z&xA|$zir(!mo?ru>W9uTsKK8QpFMV1e^I!R4*xYJIKt8_OR0r4;KyLivdp)(;D@CI zh&tZ*TIw&^ZYExH3X9ju!R*jf3s`t`y}zeo z5gwt%^#oD<3e)*kM3M^UM=O7dU~cHiJmNsl=%yNP_-`AfU49{zZCUYlVICf#=H3lm zv@uLH zzMtZRiY%t34#&xXH6OIUb!pFUIYk972biqs?yE3Z2cb={97;9^y zEVb&w63d+2yjwNYm1c>w5QxcC(E<7!Eu{U$8NA} zJK)6X@p-Od%e5rPg?eM58DX(|(ZvB-lpiXXoolMSYJx$gB$8#*vHiSYlHV4M5! zEOk$}JerZgtF9!1KPXFcUW*w!3*@g@Z+ab5zJu_RYv%_$1|#$3Y@lMtwesCOJm*-s ztF*v0Q2Kb}jwxf68AFUyY=ol@&7Fk)m(;}J9WBzlra^!+%LpdG3ryoiKNe055&6rg znDQLLfl0}w*D1CdI3EfySG9({6A|m=zy>b{W<|E=l~jnAG#gtm50FDoxFv{VSNP2` z+LpSjM#hME3uKD0qQVF!|Eubla?mBhj#{-zpOo(;HF&j6*s-qz0gpVN!bSwEb!To` zUsA90-Y+L}*6adFJXd0VYv8HU8M#8+F>KT2#3k}EF|++NhB2atnXJNdP|_sbYWihS zOnC~f+CQ<())@_k2+-$wy2xC-zwEvXK(j&Gq#6wkYDi?q6RHhhP5&EK{-}6jma3~q z>jyV*>na%Nf|`*WFWd2vx9pS+-=j` ztg=CARJlI!YpU(Hnn6B_<3S#VIJ;J*+CmfJ#dBO>=!J~F9iKwdrj|Vukm@Ad@eEE{ zy6ujTl$7MgYr~~vBUsbmK6ja%WGohc8syfm6woU7OID|G8*s_SHVHv$QYn$xbx%FB z{SLN7jtg%BmD}hW$;awNu@joUe5+9bjAB+wHEPY# zj)9QMil^$%(SVh6gbu>gLI#RWx*r%0yLJ8#A9tzo6sCpzcysrY=8Y>O+rOUOXz8@t zDO_$xrrS6=ghN#KpR!a8G++=C&=KOGsP=?*OD-(9R2nJfplS)lFnYxzYpfISmxzP< zSwdy^t3fhmLDY+~Zk`v7s0pV29p?kxvTRR2^&bBG{UbE8lOv3`>AV1aD@+A*}Zy*Jsi*C%Btqf0&~c-rTAVcyXARUo9o zkOmY^;USl9j_%&NIlE%ZRTYlZDJvK1W{oTPy*%JNpTA&1Hw?jzTCrM_*)oui56*t{ z`#8z{Vpgj86iG-X4QKfmR2r^HD{3^d#@ ze>dxhDUpY;$HoYF4km*|A@b?t;c4}h$fGlVZ!P1oJ-mRgWAx~6#E3_Vz6k1CQ3JhR zUV~@wr8900vGV`5kk2d4_c9->|YhPG)w2E;jzrPDaMRax34e&={U3g)Nl0;hylOU%1iJ^-F znaULj;4r*IPaQpBqE`cD5w_r!ac zTO0;l;1t%>bHsP;%4`Q{Xx~dG968Q=p*s2`P~hbe*Z>*fjMp}MAqjSS#W+`(z>%@3 z`q#G`I#3ygn_|)Biu6)gFykE1{a;YjZ4G*3@6|2d*j~LVvSYf+LGpPAeKQ-S&=Zo5 zj%UcR=;R8#wYZ6)+V!gyC3k8XBr{gFZH@_kbU7-_0Ofwtwo(B@-~J+d_g+=(N@O!{ z1jp^qF$n^{+G68ieddhzaWkrBEZ0}94bfu7%CKT7nXDRDe&NePe`l0WATmJ*LHY-) zCwvy;1SFp!zen~-+0Q0MvVq24OBK+?zu+y#V-mXH?iG(yOTwUtxxy zpI_u0{!;u~GzR*iU1}fPLpnWF-eI5n#BbAPD86w(#3QGv2(e|hG*M9}ax9XZj3A!{ z5-hnTmdHFYOIbk==r~C1Ro=c9muL<6=Grq9mmW9Rk*&^c1)0B9sp3>27C>Pk1iXJm?41G;fk zFpGx3G1K+w^0ixg(8+eZX2~edN7!J7x-(wby6wy0+E-G~ovM6UC=Pzj$huc9ela zP5F*i#VTmgje@{C&Qqs%#A0(kEKp2h?IqAdHp$!n$Hwd;6c(SY#&A<5h^jgR|4)zu zmFj&#e7vKXl~j!Yhy4KM9OPX%!$v-MSM3@uOF?fgyg*SZy=*SJ(uEIf8=N+ag*uB1 zdjj9-CRAZ4JAcP$9G(XOyu}x!s{Gg- zsiFiPSq&KWffeUp=Yx=Pre{{R(Fmk(Uc;97Y)|&MQ=2mp9rc?uA;p2}{SKRZkf+DR zzt5~2(a`ofW-7L+FQlj(9%UPcjcI7&AwKanj1Vsq`}Mtiy>~*2gq?GT*p)?)LMCy? z9#b8D>My2lT_r1`R}zdltp5Y}gjiPq literal 0 HcmV?d00001 diff --git a/Doc/Manual/swightml.book b/Doc/Manual/swightml.book new file mode 100644 index 0000000..1bf3ab5 --- /dev/null +++ b/Doc/Manual/swightml.book @@ -0,0 +1,39 @@ +#HTMLDOC 1.8.24 +-t html -f SWIGDocumentation.html --book --toclevels 4 --no-numbered --toctitle "Table of Contents" --title --titleimage swig16.png --linkcolor #0000ff --linkstyle underline --size Universal --left 0.50in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --nup 1 --tocheader .t. --tocfooter ..i --portrait --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=0 --fontsize 10.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 10.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680 +Sections.html +Preface.html +Introduction.html +Windows.html +Scripting.html +SWIG.html +SWIGPlus.html +Preprocessor.html +Library.html +Arguments.html +Typemaps.html +Customization.html +Contract.html +Varargs.html +Warnings.html +Modules.html +CCache.html +Allegrocl.html +CSharp.html +Chicken.html +Guile.html +Java.html +Lisp.html +Lua.html +Modula3.html +Mzscheme.html +Ocaml.html +Octave.html +Perl5.html +Php.html +Pike.html +Python.html +Ruby.html +Tcl.html +R.html +Extending.html + diff --git a/Doc/Manual/swigpdf.book b/Doc/Manual/swigpdf.book new file mode 100644 index 0000000..aa09099 --- /dev/null +++ b/Doc/Manual/swigpdf.book @@ -0,0 +1,39 @@ +#HTMLDOC 1.8.24 +-t pdf13 -f SWIGDocumentation.pdf --book --toclevels 4 --no-numbered --toctitle "Table of Contents" --title --titleimage swig16.png --linkcolor #0000ff --linkstyle underline --size Universal --left 0.50in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --nup 1 --tocheader .t. --tocfooter ..i --portrait --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=0 --fontsize 10.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 10.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680 --stylesheet style.css +Sections.html +Preface.html +Introduction.html +Windows.html +Scripting.html +SWIG.html +SWIGPlus.html +Preprocessor.html +Library.html +Arguments.html +Typemaps.html +Customization.html +Contract.html +Varargs.html +Warnings.html +Modules.html +CCache.html +Allegrocl.html +CSharp.html +Chicken.html +Guile.html +Java.html +Lisp.html +Lua.html +Modula3.html +Mzscheme.html +Ocaml.html +Octave.html +Perl5.html +Php.html +Pike.html +Python.html +Ruby.html +Tcl.html +R.html +Extending.html + diff --git a/Doc/README b/Doc/README new file mode 100644 index 0000000..f7a4939 --- /dev/null +++ b/Doc/README @@ -0,0 +1,6 @@ +Doc/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. + diff --git a/Examples/GIFPlot/Chicken/check.list b/Examples/GIFPlot/Chicken/check.list new file mode 100644 index 0000000..e75ee58 --- /dev/null +++ b/Examples/GIFPlot/Chicken/check.list @@ -0,0 +1,3 @@ +# see top-level Makefile.in +full +simple diff --git a/Examples/GIFPlot/Chicken/full/Makefile b/Examples/GIFPlot/Chicken/full/Makefile new file mode 100644 index 0000000..2ae4fd7 --- /dev/null +++ b/Examples/GIFPlot/Chicken/full/Makefile @@ -0,0 +1,28 @@ +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = gifplot.i +SRCS = +CXXSRCS = +TARGET = gifplot +INCLUDE = -I. -I../../Include +SWIGOPT = -I../../Include +CFLAGS = +VARIANT = +LIBS = -L../.. -lgifplot -lm + +# comment the following two lines to build a dynamic so file +CHICKEN_MAIN = test-gifplot.scm +VARIANT = _static + +all:: $(TARGET) + +$(TARGET): $(INTERFACE) $(SRCS) + $(MAKE) -f $(TOP)/Makefile \ + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + +clean:: + $(MAKE) -f $(TOP)/Makefile chicken_clean + rm -f gifplot.scm image.gif + rm -f $(TARGET) diff --git a/Examples/GIFPlot/Chicken/full/README b/Examples/GIFPlot/Chicken/full/README new file mode 100644 index 0000000..e5ddd7a --- /dev/null +++ b/Examples/GIFPlot/Chicken/full/README @@ -0,0 +1,6 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The Scheme program 'test-gifplot.scm' does something a +little more interesting. You'll have to go look at the header file to +get a complete listing of the functions. + +`make' will build a static binary. Run ./gifplot to test it. diff --git a/Examples/GIFPlot/Chicken/full/cmap b/Examples/GIFPlot/Chicken/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICexact (round (max (min cc 239) 0))))) + (gifplot:Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy) + z3 x (+ y dy) z4 + (gifplot:int->Pixel (+ c 16)))) + (y-loop (+ y dy) (+ j 1))))) + (x-loop (+ x dx) (+ i 1))))))) + +(display "Making a nice 3D plot...\n") +(drawsolid) + +(gifplot:FrameBuffer-writeGIF frame cmap "image.gif") +(display "Wrote image.gif\n") diff --git a/Examples/GIFPlot/Chicken/simple/Makefile b/Examples/GIFPlot/Chicken/simple/Makefile new file mode 100644 index 0000000..484e583 --- /dev/null +++ b/Examples/GIFPlot/Chicken/simple/Makefile @@ -0,0 +1,28 @@ +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = simple.i +SRCS = +CXXSRCS = +TARGET = simple +INCLUDE = -I. -I../../Include +SWIGOPT = -I../../Include +CFLAGS = +VARIANT = +LIBS = -L../.. -lgifplot -lm + +# comment the following two lines to build a dynamic so file +CHICKEN_MAIN = test-simple.scm +VARIANT = _static + +all:: $(TARGET) + +$(TARGET): $(INTERFACE) $(SRCS) + $(MAKE) -f $(TOP)/Makefile \ + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + +clean:: + $(MAKE) -f $(TOP)/Makefile chicken_clean + rm -f simple.scm image.gif + rm -f $(TARGET) diff --git a/Examples/GIFPlot/Chicken/simple/README b/Examples/GIFPlot/Chicken/simple/README new file mode 100644 index 0000000..3b138f3 --- /dev/null +++ b/Examples/GIFPlot/Chicken/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. + +`make' will build an exe. Run ./simple to test it. diff --git a/Examples/GIFPlot/Chicken/simple/simple.i b/Examples/GIFPlot/Chicken/simple/simple.i new file mode 100644 index 0000000..23ac8a8 --- /dev/null +++ b/Examples/GIFPlot/Chicken/simple/simple.i @@ -0,0 +1,34 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned int Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants, which we redefine (from gifplot.h) so + that SWIG sees them */ +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + diff --git a/Examples/GIFPlot/Chicken/simple/test-simple.scm b/Examples/GIFPlot/Chicken/simple/test-simple.scm new file mode 100644 index 0000000..43250d8 --- /dev/null +++ b/Examples/GIFPlot/Chicken/simple/test-simple.scm @@ -0,0 +1,29 @@ +;;; Draw some simple shapes + +(declare (uses simple)) + +(display "Drawing some basic shapes\n") + +(define cmap (simple:new-ColorMap #f)) +(define f (simple:new-FrameBuffer 400 400)) + +;; Clear the picture +(simple:FrameBuffer-clear f (simple:BLACK)) + +;; Make a red box +(simple:FrameBuffer-box f 40 40 200 200 (simple:RED)) + +;; Make a blue circle +(simple:FrameBuffer-circle f 200 200 40 (simple:BLUE)) + +;; Make green line +(simple:FrameBuffer-line f 10 390 390 200 (simple:GREEN)) + +;; Write an image out to disk + +(simple:FrameBuffer-writeGIF f cmap "image.gif") +(display "Wrote image.gif\n") + +(simple:delete-FrameBuffer f) +(simple:delete-ColorMap cmap) + diff --git a/Examples/GIFPlot/Common-Lisp/full/cmap b/Examples/GIFPlot/Common-Lisp/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC +#include +#include +#include +#include +#include + +#ifndef GIFPLOT_H + +#ifdef SWIG +%nodefault; +#endif + +/* Pixel is 8-bits */ + +typedef unsigned char Pixel; +typedef float Zvalue; + +/* ------------------------------------------------------------------------ + ColorMap + + Definition and methods for colormaps + ------------------------------------------------------------------------ */ + +typedef struct ColorMap { + unsigned char *cmap; + char *name; +} ColorMap; + +extern ColorMap *new_ColorMap(char *filename); +extern void delete_ColorMap(ColorMap *c); +extern void ColorMap_default(ColorMap *c); +extern void ColorMap_assign(ColorMap *c, int index, int r, int g, int b); +extern int ColorMap_getitem(ColorMap *c, int index); +extern void ColorMap_setitem(ColorMap *c, int index, int value); +extern int ColorMap_write(ColorMap *c, char *filename); + +/* Some default colors */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + +/*------------------------------------------------------------------------- + FrameBuffer + + This structure defines a simple 8 bit framebuffer. + ------------------------------------------------------------------------- */ + +typedef struct FrameBuffer { + Pixel **pixels; + Zvalue **zbuffer; + unsigned int height; + unsigned int width; + int xmin; /* These are used for clipping */ + int ymin; + int xmax; + int ymax; +} FrameBuffer; + +#define ZMIN 1e+36 + +/* FrameBuffer Methods */ + +extern FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +extern void delete_FrameBuffer(FrameBuffer *frame); +extern int FrameBuffer_resize(FrameBuffer *frame, int width, int height); +extern void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +extern void FrameBuffer_plot(FrameBuffer *frame, int x, int y, Pixel color); +extern void FrameBuffer_horizontal(FrameBuffer *frame, int xmin, int xmax, int y, Pixel color); +extern void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, Pixel c1, Pixel c2); +extern void FrameBuffer_vertical(FrameBuffer *frame, int ymin, int ymax, int x, Pixel color); +extern void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +extern void FrameBuffer_solidbox(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +extern void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); +extern void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +extern void FrameBuffer_solidcircle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +extern void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +extern void FrameBuffer_setclip(FrameBuffer *frame, int xmin, int ymin, int xmax, int ymax); +extern void FrameBuffer_noclip(FrameBuffer *frame); +extern int FrameBuffer_makeGIF(FrameBuffer *frame, ColorMap *cmap, void *buffer, unsigned int maxsize); +extern int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); +extern void FrameBuffer_zresize(FrameBuffer *f, int width, int height); +extern void FrameBuffer_zclear(FrameBuffer *f); +extern void FrameBuffer_solidtriangle(FrameBuffer *f, int x1, int y1, int x2, int y2, int x3, int y3, Pixel c); +extern void FrameBuffer_interptriangle(FrameBuffer *f, int tx1, int ty1, Pixel c1, + int tx2, int ty2, Pixel c2, int tx3, int ty3, Pixel c3); + +#define HORIZONTAL 1 +#define VERTICAL 2 + +extern void FrameBuffer_drawchar(FrameBuffer *frame, int x, int y, int fgcolor, int bgcolor, char chr, int orientation); +extern void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation); + +/* ------------------------------------------------------------------------ + PixMap + + The equivalent of "bit-maps". + ------------------------------------------------------------------------ */ + +typedef struct PixMap { + int width; + int height; + int centerx; + int centery; + int *map; +} PixMap; + +/* PIXMAP methods */ + +extern PixMap *new_PixMap(int width, int height, int centerx, int centery); +extern void delete_PixMap(PixMap *pm); +extern void PixMap_set(PixMap *pm, int x, int y, int pix); +extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor); + +#define GIFPLOT_TRANSPARENT 0 +#define GIFPLOT_FOREGROUND 1 +#define GIFPLOT_BACKGROUND 2 + +/* ------------------------------------------------------------------------ + Plot2D + + Definition and methods for 2D plots. + ------------------------------------------------------------------------ */ + +typedef struct Plot2D { + FrameBuffer *frame; /* what frame buffer are we using */ + int view_xmin; /* Minimum coordinates of view region */ + int view_ymin; + int view_xmax; /* Maximum coordinates of view region */ + int view_ymax; + double xmin; /* Minimum coordinates of plot region */ + double ymin; + double xmax; /* Maximum coordinates of plot region */ + double ymax; + int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ + int yscale; + double dx; /* Private scaling parameters */ + double dy; +} Plot2D; + +/* 2D Plot methods */ + +extern Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); +extern void delete_Plot2D(Plot2D *p2); +extern Plot2D *Plot2D_copy(Plot2D *p2); +extern void Plot2D_clear(Plot2D *p2, Pixel c); +extern void Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax); +extern void Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax); +extern void Plot2D_setscale(Plot2D *p2, int xscale, int yscale); +extern void Plot2D_plot(Plot2D *p2, double x, double y, Pixel color); +extern void Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); +extern void Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color); +extern void Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); +extern void Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color); +extern void Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color); +extern void Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); +extern void Plot2D_start(Plot2D *p2); +extern void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); +extern void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel c); +extern void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c); +extern void Plot2D_triangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); +extern void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); +extern void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, + double x2, double y2, Pixel c2, + double x3, double y3, Pixel c3); + +#define LINEAR 10 +#define LOG 11 + +/* ----------------------------------------------------------------------- + Matrix + + Operations on 4x4 transformation matrices and vectors. + Matrices are represented as a double array of 16 elements + ----------------------------------------------------------------------- */ + +typedef double *Matrix; +typedef struct GL_Vector { + double x; + double y; + double z; + double w; +} GL_Vector; + +extern Matrix new_Matrix(); +extern void delete_Matrix(Matrix a); +extern Matrix Matrix_copy(Matrix a); +extern void Matrix_multiply(Matrix a, Matrix b, Matrix c); +extern void Matrix_identity(Matrix a); +extern void Matrix_zero(Matrix a); +extern void Matrix_transpose(Matrix a, Matrix result); +extern void Matrix_invert(Matrix a, Matrix inva); +extern void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t); +extern void Matrix_transform4(Matrix a, double rx, double ry, double rz, + double rw, GL_Vector *t); + +extern void Matrix_print(Matrix a); +extern void Matrix_translate(Matrix a, double tx, double ty, double tz); +extern void Matrix_rotatex(Matrix a, double deg); +extern void Matrix_rotatey(Matrix a, double deg); +extern void Matrix_rotatez(Matrix a, double deg); + +/* ----------------------------------------------------------------------- + Plot3D + + Data Structure for 3-D plots + ------------------------------------------------------------------------ */ + +typedef struct Plot3D { + FrameBuffer *frame; /* Frame buffer being used */ + int view_xmin; /* Viewing region */ + int view_ymin; + int view_xmax; + int view_ymax; + double xmin; /* Bounding box */ + double ymin; + double zmin; + double xmax; + double ymax; + double zmax; + double xcenter; /* Center point */ + double ycenter; + double zcenter; + double fovy; /* Field of view */ + double aspect; /* Aspect ratio */ + double znear; /* near "clipping" plane */ + double zfar; /* far "clipping" plane */ + Matrix center_mat; /* Matrix used for centering the model */ + Matrix model_mat; /* Model rotation matrix */ + Matrix view_mat; /* Viewing matrix */ + Matrix fullmodel_mat; /* Full model matrix. Used by sphere plot */ + Matrix trans_mat; /* Total transformation matrix */ + double lookatz; /* Where is the z-lookat point */ + double xshift; /* Used for translation and stuff */ + double yshift; + double zoom; + int width; + int height; + int pers_mode; /* Perspective mode (private) */ + double ortho_left,ortho_right,ortho_bottom,ortho_top; +} Plot3D; + +extern Plot3D *new_Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, + double xmax, double ymax, double zmax); +extern void delete_Plot3D(Plot3D *p3); +extern Plot3D *Plot3D_copy(Plot3D *p3); +extern void Plot3D_clear(Plot3D *p3, Pixel Color); +extern void Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar); +extern void Plot3D_ortho(Plot3D *p3, double left, double right, double top, double bottom); +extern void Plot3D_lookat(Plot3D *p3, double z); +extern void Plot3D_autoperspective(Plot3D *p3, double fovy); +extern void Plot3D_autoortho(Plot3D *p3); +extern void Plot3D_rotx(Plot3D *p3, double deg); +extern void Plot3D_roty(Plot3D *p3, double deg); +extern void Plot3D_rotz(Plot3D *p3, double deg); +extern void Plot3D_rotl(Plot3D *p3, double deg); +extern void Plot3D_rotr(Plot3D *p3, double deg); +extern void Plot3D_rotd(Plot3D *p3, double deg); +extern void Plot3D_rotu(Plot3D *p3, double deg); +extern void Plot3D_rotc(Plot3D *p3, double deg); +extern void Plot3D_zoom(Plot3D *p3, double percent); +extern void Plot3D_left(Plot3D *p3, double percent); +extern void Plot3D_right(Plot3D *p3, double percent); +extern void Plot3D_down(Plot3D *p3, double percent); +extern void Plot3D_up(Plot3D *p3, double percent); +extern void Plot3D_center(Plot3D *p3, double cx, double cy); + +extern void Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color); + +extern void Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax); +extern void Plot3D_start(Plot3D *p3); +extern void Plot3D_line(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, Pixel color); +extern void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, Pixel color); +extern void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, Pixel color); + +extern void Plot3D_interptriangle(Plot3D *p3, + double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3); + +extern void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel color); + +extern void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel color); + +extern void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3, + double x4, double y4, double z4, Pixel c4); + + +extern void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c); + +extern void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c, Pixel bc); + +extern PixMap PixMap_SQUARE; +extern PixMap PixMap_TRIANGLE; +extern PixMap PixMap_CROSS; + +#endif +#define GIFPLOT_H + + + diff --git a/Examples/GIFPlot/Interface/gifplot.i b/Examples/GIFPlot/Interface/gifplot.i new file mode 100644 index 0000000..fdf661c --- /dev/null +++ b/Examples/GIFPlot/Interface/gifplot.i @@ -0,0 +1,264 @@ +// +// Graphics module +// +%module gifplot +%{ +#include "gifplot.h" +%} + +#if defined(SWIGJAVA ) || defined(SWIGPHP) + %rename(make_default) ColorMap::default(); +#endif + +%rename(__getitem__) ColorMap::getitem(int index); +%rename(__setitem__) ColorMap::setitem(int index, int value); + +/* Pixel is 8-bits */ + +typedef unsigned char Pixel; +typedef float Zvalue; + +/* ------------------------------------------------------------------------ + ColorMap + + Definition and methods for colormaps + ------------------------------------------------------------------------ */ + +typedef struct ColorMap { + char *name; + +// +// %extend adds some C methods to this structure to make it +// look like a C++ class in Python. +// These are really named things like ColorMap_default, ColorMap_assign, etc... + + %extend { + ColorMap(char *filename); + ~ColorMap(); + void default(); + void assign(int index,int r, int g, int b); + int getitem(int index); + void setitem(int index, int value); + int write(char *filename); + } +} ColorMap; + +/* Some default colors */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + +/*------------------------------------------------------------------------- + FrameBuffer + + This structure defines a simple 8 bit framebuffer. + ------------------------------------------------------------------------- */ + +typedef struct FrameBuffer { + unsigned int height; + unsigned int width; + int xmin; /* These are used for clipping */ + int ymin; + int xmax; + int ymax; + %extend { + FrameBuffer(unsigned int width, unsigned int height); + ~FrameBuffer(); + void resize(int width, int height); + void clear(Pixel color); + void plot(int x, int y, Pixel color); + void horizontal(int xmin, int xmax, int y, Pixel color); + void horizontalinterp(int xmin, int xmax, int y, Pixel c1, Pixel c2); + void vertical(int ymin, int ymax, int x, Pixel color); + void box(int x1, int y1, int x2, int y2, Pixel color); + void solidbox(int x1, int y1, int x2, int y2, Pixel color); + void interpbox(int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); + void circle(int x1, int y1, int radius, Pixel color); + void solidcircle(int x1, int y1, int radius, Pixel color); + void line(int x1, int y1, int x2, int y2, Pixel color); + void setclip(int xmin, int ymin, int xmax, int ymax); + void noclip(); + int makeGIF(ColorMap *cmap, void *buffer, unsigned int maxsize); + void zresize(int width, int height); + void zclear(); + void drawchar(int x, int y, int fgcolor, int bgcolor, char chr, int orientation); + void drawstring(int x, int y, int fgcolor, int bgcolor, char *text, int orientation); + void drawpixmap(PixMap *pm, int x, int y, int fgcolor, int bgcolor); + int writeGIF(ColorMap *cmap, char *filename); + } +} FrameBuffer; + +#define HORIZONTAL 1 +#define VERTICAL 2 + +/* -------------------------------------------------------------------------- + PixMap + + The equivalent of "bit-maps". + -------------------------------------------------------------------------- */ + +/* PIXMAP methods */ + +extern PixMap *new_PixMap(int width, int height, int centerx, int centery); +extern void delete_PixMap(PixMap *pm); +extern void PixMap_set(PixMap *pm, int x, int y, int pix); + +#define GIFPLOT_TRANSPARENT 0 +#define GIFPLOT_FOREGROUND 1 +#define GIFPLOT_BACKGROUND 2 + +/* -------------------------------------------------------------------------- + Plot2D + + Definition and methods for 2D plots. + --------------------------------------------------------------------------- */ + +typedef struct Plot2D { + FrameBuffer *frame; + int view_xmin; /* Minimum coordinates of view region */ + int view_ymin; + int view_xmax; /* Maximum coordinates of view region */ + int view_ymax; + double xmin; /* Minimum coordinates of plot region */ + double ymin; + double xmax; /* Maximum coordinates of plot region */ + double ymax; + int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ + int yscale; + %extend { + Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); + ~Plot2D(); + Plot2D *copy(); + void clear(Pixel c); + void setview(int vxmin, int vymin, int vxmax, int vymax); + void setrange(double xmin, double ymin, double xmax, double ymax); + void setscale(int xscale, int yscale); + void plot(double x, double y, Pixel color); + void box(double x1, double y1, double x2, double y2, Pixel color); + void solidbox(double x1, double y1, double x2, double y2, Pixel color); + void interpbox(double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); + + void circle(double x, double y, double radius, Pixel color); + void solidcircle(double x, double y, double radius, Pixel color); + void line(double x1, double y1, double x2, double y2, Pixel color); + void start(); + void drawpixmap(PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); + void xaxis(double x, double y, double xtick, int ticklength, Pixel color); + void yaxis(double x, double y, double ytick, int ticklength, Pixel color); + void triangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); + + void solidtriangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); + + void interptriangle(double x1, double y1, Pixel c1, + double x2, double y2, Pixel c2, + double x3, double y3, Pixel c3); + + } +} Plot2D; + +#define LINEAR 10 +#define LOG 11 + +/* ------------------------------------------------------------------------------ + Plot3D + + Data Structure for 3-D plots + ------------------------------------------------------------------------------ */ + +typedef struct Plot3D { + FrameBuffer *frame; + int view_xmin; /* Viewing region */ + int view_ymin; + int view_xmax; + int view_ymax; + double xmin; /* Bounding box */ + double ymin; + double zmin; + double xmax; + double ymax; + double zmax; + double xcenter; /* Center point */ + double ycenter; + double zcenter; + double fovy; /* Field of view */ + double aspect; /* Aspect ratio */ + double znear; /* near "clipping" plane */ + double zfar; /* far "clipping" plane */ + double lookatz; /* Where is the z-lookat point */ + double xshift; /* Used for translation and stuff */ + double yshift; + %extend { + Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax); + ~Plot3D(); + Plot3D *copy(); + void clear(Pixel bgcolor); + void perspective( double fovy, double znear, double zfar); + void lookat( double z); + void autoperspective( double fovy); + void ortho(double left, double right, double bottom, double top); + void autoortho(); + void rotx( double deg); + void roty( double deg); + void rotz( double deg); + void rotl( double deg); + void rotr( double deg); + void rotd( double deg); + void rotu( double deg); + void rotc( double deg); + void zoom( double percent); + void left( double percent); + void right( double percent); + void down( double percent); + void up( double percent); + void center( double cx, double cy); + void plot( double x, double y, double z, Pixel Color); + void setview( int vxmin, int vymin, int vxmax, int vymax); + void start(); + void line( double x1, double y1, double z1, + double x2, double y2, double z2, Pixel color); + void triangle( double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, Pixel color); + void solidtriangle( double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, Pixel color); + void interptriangle(double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3); + void quad( double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel color); + void solidquad( double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel color); + void interpquad( double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3, + double x4, double y4, double z4, Pixel c4); + void solidsphere( double x, double y, double z, double radius,Pixel c); + void outlinesphere( double x, double y, double z, double radius,Pixel c, Pixel bc); + } +} Plot3D; + +#ifndef SWIGJAVA +/* These directives create constants of a specific type. They + do not correspond to any C variable or declared constant in the + header file */ +%constant PixMap * SQUARE = &PixMap_SQUARE; +%constant PixMap * TRIANGLE = &PixMap_TRIANGLE; +%constant PixMap * CROSS = &PixMap_CROSS; +#endif + + + + diff --git a/Examples/GIFPlot/Java/check.list b/Examples/GIFPlot/Java/check.list new file mode 100644 index 0000000..13de977 --- /dev/null +++ b/Examples/GIFPlot/Java/check.list @@ -0,0 +1,4 @@ +# see top-level Makefile.in +full +shadow +simple diff --git a/Examples/GIFPlot/Java/full/Makefile b/Examples/GIFPlot/Java/full/Makefile new file mode 100644 index 0000000..8f16723 --- /dev/null +++ b/Examples/GIFPlot/Java/full/Makefile @@ -0,0 +1,20 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Include -noproxy +SRCS = +TARGET = gifplot +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README new file mode 100644 index 0000000..93463ea --- /dev/null +++ b/Examples/GIFPlot/Java/full/README @@ -0,0 +1,8 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The program 'runme.java' does something a little more +interesting. After doing a make, run it using 'java runme'. You'll have to go +look at the header file to get a complete listing of the functions. + +Note the differences in the runme.java files between this example and the +'full' example. This example does not use shadow classes. + diff --git a/Examples/GIFPlot/Java/full/cmap b/Examples/GIFPlot/Java/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) c = 239; + gifplot.Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16)); + y = y + dy; + } + x = x + dx; + } + + gifplot.FrameBuffer_writeGIF(frame,cmap,"image.gif"); + System.out.println( "Wrote image.gif" ); + } + + // Here is the function to plot + public static double func(double x, double y) { + return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y)); + } +} diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile new file mode 100644 index 0000000..8062c27 --- /dev/null +++ b/Examples/GIFPlot/Java/shadow/Makefile @@ -0,0 +1,21 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -outcurrentdir +SRCS = +TARGET = gifplot +INTERFACEDIR = ../../Interface/ +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README new file mode 100644 index 0000000..b06c5a8 --- /dev/null +++ b/Examples/GIFPlot/Java/shadow/README @@ -0,0 +1,5 @@ +This example uses the file in ../../Interface/gifplot.i to build +an interface with shadow classes. After doing a make, run the program runme, ie: 'java runme'. + +Note the differences in the runme.java files between this example and the +'full' example. This example uses the shadow classes. diff --git a/Examples/GIFPlot/Java/shadow/cmap b/Examples/GIFPlot/Java/shadow/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) c = 239; + p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16)); + y = y + dy; + } + x = x + dx; + } + + frame.writeGIF(cmap,"image.gif"); + System.out.println( "Wrote image.gif" ); + } + + // Here is the function to plot + public static double func(double x, double y) { + return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y)); + } +} diff --git a/Examples/GIFPlot/Java/simple/Makefile b/Examples/GIFPlot/Java/simple/Makefile new file mode 100644 index 0000000..d707fd4 --- /dev/null +++ b/Examples/GIFPlot/Java/simple/Makefile @@ -0,0 +1,21 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -noproxy +SRCS = +TARGET = simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README new file mode 100644 index 0000000..13ff496 --- /dev/null +++ b/Examples/GIFPlot/Java/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. After doing a make, run the java program, ie 'java runme'. + + diff --git a/Examples/GIFPlot/Java/simple/runme.java b/Examples/GIFPlot/Java/simple/runme.java new file mode 100644 index 0000000..2d8d2bb --- /dev/null +++ b/Examples/GIFPlot/Java/simple/runme.java @@ -0,0 +1,41 @@ + +public class runme { + + static { + try { + System.loadLibrary("simple"); + } 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[]) { + + // Draw some simple shapes + System.out.println( "Drawing some basic shapes" ); + + SWIGTYPE_p_ColorMap cmap = simple.new_ColorMap(null); + SWIGTYPE_p_FrameBuffer f = simple.new_FrameBuffer(400,400); + + // Clear the picture + simple.FrameBuffer_clear(f,(short)simple.BLACK); + + // Make a red box + simple.FrameBuffer_box(f,40,40,200,200,(short)simple.RED); + + // Make a blue circle + simple.FrameBuffer_circle(f,200,200,40,(short)simple.BLUE); + + // Make green line + simple.FrameBuffer_line(f,10,390,390,200, (short)simple.GREEN); + + // Write an image out to disk + + simple.FrameBuffer_writeGIF(f,cmap,"image.gif"); + System.out.println( "Wrote image.gif" ); + + simple.delete_FrameBuffer(f); + simple.delete_ColorMap(cmap); + } +} diff --git a/Examples/GIFPlot/Java/simple/simple.i b/Examples/GIFPlot/Java/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Java/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/GIFPlot/Lib/Makefile.in b/Examples/GIFPlot/Lib/Makefile.in new file mode 100644 index 0000000..9db828e --- /dev/null +++ b/Examples/GIFPlot/Lib/Makefile.in @@ -0,0 +1,22 @@ +CC = @CC@ +CCSHARED= @CCSHARED@ +INCLUDES= -I../Include +CFLAGS = -O +SRCS = frame.c color.c plot2d.c plot3d.c font.c pixmap.c matrix.c gif.c +OBJS = $(SRCS:.c=.@OBJEXT@) +AR = @AR@ +RANLIB = @RANLIB@ +TARGET = ../libgifplot.a + +.c.@OBJEXT@: + $(CC) $(CCSHARED) $(INCLUDES) $(CFLAGS) -c -o $*.@OBJEXT@ $< + +all: $(OBJS) + @rm -f ../libgifplot.a + $(AR) cr $(TARGET) $(OBJS) + $(RANLIB) $(TARGET) + +clean: + rm -f *.@OBJEXT@ *~ $(TARGET) + +check: all diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c new file mode 100644 index 0000000..7d79bac --- /dev/null +++ b/Examples/GIFPlot/Lib/color.c @@ -0,0 +1,143 @@ +/* ----------------------------------------------------------------------------- + * color.c + * + * Colormaps + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define COLORMAP +#include "gifplot.h" +#include + +/* ------------------------------------------------------------------------ + ColorMap *new_ColorMap(char *filename) + + Read a colormap from a file. + ------------------------------------------------------------------------ */ + +ColorMap *new_ColorMap(char *filename) { + ColorMap *c; + FILE *cm; + void ColorMap_default(ColorMap *); + + if (!filename) { + c = (ColorMap *) malloc(sizeof(ColorMap)); + c->cmap = (unsigned char *) malloc(768*sizeof(char)); + c->name = 0; + ColorMap_default(c); + return c; + } + if (strlen(filename) == 0) { + c = (ColorMap *) malloc(sizeof(ColorMap)); + c->cmap = (unsigned char *) malloc(768*sizeof(char)); + ColorMap_default(c); + return c; + } + if ((cm = fopen(filename,"rb")) == NULL) { + return (ColorMap *) 0; + } + c = (ColorMap *) malloc(sizeof(ColorMap)); + c->cmap = (unsigned char *) malloc(768*sizeof(char)); + if (fread(c->cmap, 768, 1, cm) != 1) { + free((char *)c->cmap); + free((char *)c); + fclose(cm); + return (ColorMap *) 0; + } + fclose(cm); + c->name = (char *) malloc(strlen(filename)+1); + strcpy(c->name, filename); + ColorMap_default(c); + return c; +} + +/* -------------------------------------------------------------------------- + delete_ColorMap(ColorMap *cm) + + Destroy a ColorMap + -------------------------------------------------------------------------- */ + +void delete_ColorMap(ColorMap *cm) { + if (cm) { + free((char *)cm->cmap); + if (cm->name) + free((char *)cm->name); + free((char *)cm); + } +} + +/* -------------------------------------------------------------------------- + ColorMap_default(ColorMap *cm) + + This function fills in default values for the first 8 entries of the + colormap. These are *fixed* values---used internally. + -------------------------------------------------------------------------- */ + +void ColorMap_default(ColorMap *cm) { + unsigned char *r,*g,*b; + if (cm) { + r = cm->cmap; + g = cm->cmap+256; + b = cm->cmap+512; + + r[0] = 0; g[0] = 0; b[0] = 0; /* BLACK */ + r[1] = 255; g[1] = 255; b[1] = 255; /* WHITE */ + r[2] = 255; g[2] = 0; b[2] = 0; /* RED */ + r[3] = 0; g[3] = 255; b[3] = 0; /* GREEN */ + r[4] = 0; g[4] = 0; b[4] = 255; /* BLUE */ + r[5] = 255; g[5] = 255; b[5] = 0; /* YELLOW */ + r[6] = 0; g[6] = 255; b[6] = 255; /* CYAN */ + r[7] = 255; g[7] = 0; b[7] = 255; /* MAGENTA */ + } +} + +void ColorMap_assign(ColorMap *cm, int index, int r, int g, int b) { + unsigned char *rb,*gb,*bb; + + rb = cm->cmap; + gb = cm->cmap+256; + bb = cm->cmap+512; + + rb[index] = r; + gb[index] = g; + bb[index] = b; +} + +int ColorMap_getitem(ColorMap *cm, int index) { + if ((index < 0) && (index >= 768)) return -1; + return cm->cmap[index]; +} + +void ColorMap_setitem(ColorMap *cm, int index, int value) { + if ((index < 0) && (index >= 768)) return; + cm->cmap[index]=value; +} + +/* -------------------------------------------------------------------- + ColorMap_write(ColorMap *cm, char *filename) + + Write out a colormap to disk. + -------------------------------------------------------------------- */ + +int ColorMap_write(ColorMap *cm, char *filename) { + + FILE *f; + if (!cm) return -1; + if (!filename) return -1; + if (strlen(filename) == 0) return -1; + + f = fopen(filename,"w"); + + if (fwrite(cm->cmap,768,1,f) != 1) { + fclose(f); + return -1; + } + fclose(f); + return 0; +} + +#undef COLORMAP diff --git a/Examples/GIFPlot/Lib/font.c b/Examples/GIFPlot/Lib/font.c new file mode 100644 index 0000000..b30ee9b --- /dev/null +++ b/Examples/GIFPlot/Lib/font.c @@ -0,0 +1,705 @@ +/* ----------------------------------------------------------------------------- + * font.c + * + * Some basic fonts. + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define FONT +#include "gifplot.h" + +static char Char_A[80] = "\ +...x....\ +...x....\ +..x.x...\ +..x.x...\ +.x...x..\ +.xxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +........"; + +static char Char_B[80] = "\ +xxxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +xxxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +xxxxxx..\ +........"; + +static char Char_C[80] = "\ +..xxxx..\ +.x....x.\ +x.......\ +x.......\ +x.......\ +x.......\ +x.......\ +.x....x.\ +..xxxx..\ +........"; + +static char Char_D[80] = "\ +xxxxx...\ +x....x..\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x....x..\ +xxxxx...\ +........"; +static char Char_E[80] = "\ +xxxxxxx.\ +x.......\ +x.......\ +x.......\ +xxxxx...\ +x.......\ +x.......\ +x.......\ +xxxxxxx.\ +........"; +static char Char_F[80] = "\ +xxxxxxx.\ +x.......\ +x.......\ +x.......\ +xxxxx...\ +x.......\ +x.......\ +x.......\ +x.......\ +........"; +static char Char_G[80] = "\ +.xxxxx..\ +x.....x.\ +x.......\ +x.......\ +x...xxx.\ +x.....x.\ +x.....x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_H[80] = "\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +xxxxxxx.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +........"; +static char Char_I[80] = "\ +xxxxxxx.\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +xxxxxxx.\ +........"; +static char Char_J[80] = "\ +......x.\ +......x.\ +......x.\ +......x.\ +......x.\ +......x.\ +x.....x.\ +.x...x..\ +..xxx...\ +........"; +static char Char_K[80] = "\ +x.....x.\ +x....x..\ +x...x...\ +x..x....\ +xxx.....\ +x..x....\ +x...x...\ +x....x..\ +x.....x.\ +........"; +static char Char_L[80] = "\ +x.......\ +x.......\ +x.......\ +x.......\ +x.......\ +x.......\ +x.......\ +x.......\ +xxxxxxx.\ +........"; +static char Char_M[80] = "\ +x.....x.\ +xx...xx.\ +xx...xx.\ +x.x.x.x.\ +x.x.x.x.\ +x..x..x.\ +x..x..x.\ +x.....x.\ +x.....x.\ +........"; +static char Char_N[80] = "\ +x.....x.\ +xx....x.\ +x.x...x.\ +x.x...x.\ +x..x..x.\ +x...x.x.\ +x...x.x.\ +x....xx.\ +x.....x.\ +........"; +static char Char_O[80] = "\ +.xxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_P[80] = "\ +xxxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +xxxxxx..\ +x.......\ +x.......\ +x.......\ +x.......\ +........"; +static char Char_Q[80] = "\ +.xxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x...x.x.\ +x....x..\ +.xxxx.x.\ +........"; +static char Char_R[80] = "\ +xxxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +xxxxxx..\ +x..x....\ +x...x...\ +x....x..\ +x.....x.\ +........"; +static char Char_S[80] = "\ +.xxxxx..\ +x.....x.\ +x.......\ +x.......\ +.xxxxx..\ +......x.\ +......x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_T[80] = "\ +xxxxxxx.\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +........"; +static char Char_U[80] = "\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_V[80] = "\ +x.....x.\ +x.....x.\ +.x...x..\ +.x...x..\ +..x.x...\ +..x.x...\ +...x....\ +...x....\ +...x....\ +........"; +static char Char_W[80] = "\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x.....x.\ +x..x..x.\ +x..x..x.\ +x.x.x.x.\ +.x...x..\ +........"; +static char Char_X[80] = "\ +x.....x.\ +x.....x.\ +.x...x..\ +..x.x...\ +...x....\ +..x.x...\ +.x...x..\ +x.....x.\ +x.....x.\ +........"; +static char Char_Y[80] = "\ +x.....x.\ +x.....x.\ +.x...x..\ +..x.x...\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +........"; +static char Char_Z[80] = "\ +xxxxxxx.\ +......x.\ +.....x..\ +....x...\ +...x....\ +..x.....\ +.x......\ +x.......\ +xxxxxxx.\ +........"; +static char Char_0[80] = "\ +.xxxxx..\ +x....xx.\ +x...x.x.\ +x..x..x.\ +x..x..x.\ +x.x...x.\ +x.x...x.\ +xx....x.\ +.xxxxx..\ +........"; +static char Char_1[80] = "\ +...x....\ +..xx....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +...x....\ +..xxx...\ +........"; +static char Char_2[80] = "\ +..xxxx..\ +.x....x.\ +x.....x.\ +.....x..\ +....x...\ +...x....\ +..x.....\ +.x......\ +xxxxxxx.\ +........"; +static char Char_3[80] = "\ +.xxxxx..\ +x.....x.\ +......x.\ +......x.\ +...xxx..\ +......x.\ +......x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_4[80] = "\ +....xx..\ +...x.x..\ +..x..x..\ +.x...x..\ +xxxxxxx.\ +.....x..\ +.....x..\ +.....x..\ +.....x..\ +........"; +static char Char_5[80] = "\ +xxxxxxx.\ +x.......\ +x.......\ +x.......\ +xxxxxx..\ +......x.\ +......x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_6[80] = "\ +....xxx.\ +..xx....\ +.x......\ +x.......\ +x.xxx...\ +xx...x..\ +x.....x.\ +.x...x..\ +..xxx...\ +........"; +static char Char_7[80] = "\ +xxxxxxx.\ +x.....x.\ +.....x..\ +....x...\ +...x....\ +..x.....\ +.x......\ +x.......\ +x.......\ +........"; +static char Char_8[80] = "\ +.xxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +.xxxxx..\ +x.....x.\ +x.....x.\ +x.....x.\ +.xxxxx..\ +........"; +static char Char_9[80] = "\ +..xxxx..\ +.x....x.\ +x.....x.\ +x....xx.\ +.xxxx.x.\ +......x.\ +......x.\ +....xx..\ +.xxx....\ +........"; +static char Char_MINUS[80] = "\ +........\ +........\ +........\ +........\ +.xxxxxx.\ +........\ +........\ +........\ +........\ +........"; +static char Char_PLUS[80] = "\ +........\ +........\ +...x....\ +...x....\ +.xxxxx..\ +...x....\ +...x....\ +........\ +........\ +........"; +static char Char_EQUAL[80] = "\ +........\ +........\ +........\ +.xxxxx..\ +........\ +.xxxxx..\ +........\ +........\ +........\ +........"; +static char Char_LPAREN[80] = "\ +....x...\ +...x....\ +..x.....\ +.x......\ +.x......\ +.x......\ +..x.....\ +...x....\ +....x...\ +........"; +static char Char_RPAREN[80] = "\ +...x....\ +....x...\ +.....x..\ +......x.\ +......x.\ +......x.\ +.....x..\ +....x...\ +...x....\ +........"; +static char Char_QUOTE[80] = "\ +..x.x...\ +..x.x...\ +........\ +........\ +........\ +........\ +........\ +........\ +........\ +........"; +static char Char_COLON[80] = "\ +........\ +........\ +...xx...\ +...xx...\ +........\ +...xx...\ +...xx...\ +........\ +........\ +........"; +static char Char_PERIOD[80] = "\ +........\ +........\ +........\ +........\ +........\ +........\ +........\ +...xx...\ +...xx...\ +........"; +static char Char_COMMA[80] = "\ +........\ +........\ +........\ +........\ +........\ +........\ +...xx...\ +...xx...\ +....x...\ +...x...."; + +static char Char_SLASH[80] = "\ +........\ +......x.\ +.....x..\ +....x...\ +...x....\ +..x.....\ +.x......\ +x.......\ +........\ +........"; + +static char Char_SPACE[80] = "\ +........\ +........\ +........\ +........\ +........\ +........\ +........\ +........\ +........\ +........"; + +static char *GP_Font[128]; +static int InitGP_Font = 0; + +static void initGP_Fonts(void) { + + int i; + for (i = 0; i < 128; i++) + GP_Font[i] = (char *) 0; + + GP_Font['A'] = GP_Font['a'] = Char_A; + GP_Font['B'] = GP_Font['b'] = Char_B; + GP_Font['C'] = GP_Font['c'] = Char_C; + GP_Font['D'] = GP_Font['d'] = Char_D; + GP_Font['E'] = GP_Font['e'] = Char_E; + GP_Font['F'] = GP_Font['f'] = Char_F; + GP_Font['G'] = GP_Font['g'] = Char_G; + GP_Font['H'] = GP_Font['h'] = Char_H; + GP_Font['I'] = GP_Font['i'] = Char_I; + GP_Font['J'] = GP_Font['j'] = Char_J; + GP_Font['K'] = GP_Font['k'] = Char_K; + GP_Font['L'] = GP_Font['l'] = Char_L; + GP_Font['M'] = GP_Font['m'] = Char_M; + GP_Font['N'] = GP_Font['n'] = Char_N; + GP_Font['O'] = GP_Font['o'] = Char_O; + GP_Font['P'] = GP_Font['p'] = Char_P; + GP_Font['Q'] = GP_Font['q'] = Char_Q; + GP_Font['R'] = GP_Font['r'] = Char_R; + GP_Font['S'] = GP_Font['s'] = Char_S; + GP_Font['T'] = GP_Font['t'] = Char_T; + GP_Font['U'] = GP_Font['u'] = Char_U; + GP_Font['V'] = GP_Font['v'] = Char_V; + GP_Font['W'] = GP_Font['w'] = Char_W; + GP_Font['X'] = GP_Font['x'] = Char_X; + GP_Font['Y'] = GP_Font['y'] = Char_Y; + GP_Font['Z'] = GP_Font['z'] = Char_Z; + GP_Font['0'] = Char_0; + GP_Font['1'] = Char_1; + GP_Font['2'] = Char_2; + GP_Font['3'] = Char_3; + GP_Font['4'] = Char_4; + GP_Font['5'] = Char_5; + GP_Font['6'] = Char_6; + GP_Font['7'] = Char_7; + GP_Font['8'] = Char_8; + GP_Font['9'] = Char_9; + GP_Font['.'] = Char_PERIOD; + GP_Font[','] = Char_COMMA; + GP_Font['='] = Char_EQUAL; + GP_Font['-'] = Char_MINUS; + GP_Font['+'] = Char_PLUS; + GP_Font['\"'] = Char_QUOTE; + GP_Font['('] = Char_LPAREN; + GP_Font[')'] = Char_RPAREN; + GP_Font[':'] = Char_COLON; + GP_Font['/'] = Char_SLASH; + GP_Font[' '] = Char_SPACE; + InitGP_Font = 1; +} + +/* ----------------------------------------------------------------------- + void FrameBuffer_drawchar(FrameBuffer *f, int x, int y, Pixel fgcolor, Pixel bgcolor, char chr, int orientation) + + Draws a character at location x, y with given color and orientation parameters. + Orientation can either be HORIZONTAL or VERTICAL + ----------------------------------------------------------------------- */ +void FrameBuffer_drawchar(FrameBuffer *f, int x, int y, int fgcolor, + int bgcolor, char chr, int orientation) { + + Pixel c, bc,*p,*p1; + char *ch; + int i,j; + int xpixels,ypixels; + + if (!InitGP_Font) initGP_Fonts(); + + c = (Pixel) fgcolor; + bc = (Pixel) bgcolor; + xpixels = f->width; + ypixels = f->height; + + if (orientation == HORIZONTAL) { + if ((x < f->xmin) || (x > f->xmax-8) || + (y < f->ymin) || (y > f->ymax-10)) return; + + ch = GP_Font[(int) chr]; + if (!ch) return; + p = &f->pixels[y+9][x]; + for (i = 0; i < 10; i++) { + p1 = p; + for (j = 0; j< 8; j++) { + if (*(ch++) == 'x') *p= c; + else if (bgcolor >= 0) + *p = bc; + p++; + } + p = (p1 - xpixels); + } + } else { + if ((x < f->xmin+10) || (x >= f->xmax) || + (y < f->ymin) || (y > f->ymax-8)) return; + + ch = GP_Font[(int) chr]; + if (!ch) return; + p = &f->pixels[y][x-9]; + for (i = 0; i < 10; i++) { + p1 = p; + for (j = 0; j< 8; j++) { + if (*(ch++) == 'x') *p= c; + else if (bgcolor >= 0) + *p = bc; + p+=xpixels; + } + p = p1 + 1; + } + } +} + +/* ---------------------------------------------------------------------- + void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, + int bgcolor, char *text, int orientation) + + Draws an ASCII string on the framebuffer. Can be oriented either horizontally + or vertically. + ---------------------------------------------------------------------- */ + +void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation) { + + char *c; + int x1, y1; + int xpixels, ypixels; + + x1 = x; + y1 = y; + xpixels = f->width; + ypixels = f->height; + c = text; + while (*c) { + if (*c == '\n') { + if (orientation == HORIZONTAL) { + x1 = x; y1= y1- 10*xpixels; + } else { + y1 = y; x1= x1 + 10*ypixels; + } + } else { + FrameBuffer_drawchar(f, x1,y1,fgcolor, bgcolor,*c, orientation); + if (orientation == HORIZONTAL) { + x1+=8; + if (x1 >= (xpixels-8)) { + x1 = x; y1= y1- 10;} + if (y1 < 0) return; + } else { + y1 += 8; + if (y1 >= (ypixels-8)) { + y1 = y; x1 = x1 + 10;} + if (x1 > (xpixels-10)) return; + } + } + c++; + } +} + + + + + + + + diff --git a/Examples/GIFPlot/Lib/frame.c b/Examples/GIFPlot/Lib/frame.c new file mode 100644 index 0000000..e006f0d --- /dev/null +++ b/Examples/GIFPlot/Lib/frame.c @@ -0,0 +1,924 @@ +/* ----------------------------------------------------------------------------- + * frame.c + * + * Frame buffer management + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define FRAME +#include "gifplot.h" +#include + +/* ------------------------------------------------------------------------ + FrameBuffer *new_FrameBuffer(int width, int height) + + Creates a new framebuffer for storing data. + ------------------------------------------------------------------------ */ + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height) { + + FrameBuffer *f; + int FrameBuffer_resize(FrameBuffer *f, int width, int height); + + /* Create a new frame buffer */ + + f = (FrameBuffer *) malloc(sizeof(FrameBuffer)); + f->pixels = (Pixel **) 0; + f->zbuffer = (Zvalue **) 0; + /* Set its size */ + + if (FrameBuffer_resize(f, width, height) == -1) { + free((char *) f); + return (FrameBuffer *) 0; + } + + f->xmin = 0; + f->ymin = 0; + f->xmax = width; + f->ymax = height; + return f; +} + +/* ------------------------------------------------------------------------ + void delete_FrameBuffer(FrameBuffer *f) + + Destroys the given framebuffer + ------------------------------------------------------------------------ */ + +void delete_FrameBuffer(FrameBuffer *f) { + + if (f) { + if (f->pixels) { + free((char *) f->pixels[0]); + free((char *) f->pixels); + } + if (f->zbuffer) { + free((char *) f->zbuffer[0]); + free((char *) f->zbuffer); + } + free((char *)f); + } +} + +/* ------------------------------------------------------------------------ + int *FrameBuffer_resize(FrameBuffer *f, int width, int height) + + Resize the given framebuffer. Returns 0 on success, -1 on failure. + ------------------------------------------------------------------------ */ + +int FrameBuffer_resize(FrameBuffer *f, int width, int height) { + int i; + if ((f) && (width > 0) && (height > 0)) { + if (f->pixels) { + free((char *)f->pixels[0]); + free((char *)f->pixels); + } + f->pixels = (Pixel **) malloc (height*sizeof(Pixel *)); + if (!f->pixels) return -1; + f->pixels[0] = (Pixel *) malloc(height*width*sizeof(Pixel)); + if (!f->pixels[0]) { + free((char *)f->pixels); + return -1; + } + for (i = 0; i < height; i++) + f->pixels[i] = f->pixels[0] + i*width; + f->width = width; + f->height = height; + if (f->zbuffer) { + FrameBuffer_zresize(f,width,height); + } + return 0; + } else { + return -1; + } +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_clear(FrameBuffer *f, Pixel color) + + Clears the current FrameBuffer + ------------------------------------------------------------------------ */ + +void FrameBuffer_clear(FrameBuffer *f, Pixel color) { + Pixel *p; + unsigned int i; + p = &f->pixels[0][0]; + + for (i = 0; i < f->width*f->height; i++, p++) + *p = color; +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_plot(FrameBuffer *f, int x1, int y1, Pixel color) + + Plots a point and does a bounds check. + ------------------------------------------------------------------------ */ + +void FrameBuffer_plot(FrameBuffer *f, int x1, int y1, Pixel color) { + + if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax)) + return; + f->pixels[y1][x1] = color; + +} + +/* ------------------------------------------------------------------------ + FrameBuffer_horizontal(Framebuffer *f, int xmin, int xmax, int y, Pixel color) + + Draw a horizontal line (clipped) + ------------------------------------------------------------------------ */ + +void FrameBuffer_horizontal(FrameBuffer *f, int xmin, int xmax, int y, Pixel color) { + + Pixel *p; + int i; + + if ((y < f->ymin) || (y >= f->ymax)) return; + if (xmin < f->xmin) xmin = f->xmin; + if (xmax >= f->xmax) xmax = f->xmax - 1; + + p = &f->pixels[y][xmin]; + for (i = xmin; i <= xmax; i++, p++) + *p = color; + +} + +/* ------------------------------------------------------------------------ + FrameBuffer_horizontalinterp(Framebuffer *f, int xmin, int xmax, int y, + Pixel c1, Pixel c2) + + Draw a horizontal line (clipped) with color interpolation. + ------------------------------------------------------------------------ */ + +void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, + Pixel c1, Pixel c2) { + + Pixel *p; + int i; + double mc; + int x1; + if ((y < f->ymin) || (y >= f->ymax)) return; + + x1 = xmin; + if (xmin < f->xmin) xmin = f->xmin; + if (xmax >= f->xmax) xmax = f->xmax - 1; + if (xmax < f->xmin) return; + if (xmin >= f->xmax) return; + + if (xmin != xmax) + mc = (double)(c2 - c1)/(double) (xmax - xmin); + else + mc = 0.0; + + p = &f->pixels[y][xmin]; + for (i = xmin; i <= xmax; i++, p++) + *p = (Pixel) (mc*(i-x1) + c1); + +} + + +/* ------------------------------------------------------------------------ + FrameBuffer_vertical(Framebuffer *f, int xmin, int xmax, int y, Pixel color) + + Draw a Vertical line (clipped) + ------------------------------------------------------------------------ */ + +void FrameBuffer_vertical(FrameBuffer *f, int ymin, int ymax, int x, Pixel color) { + + Pixel *p; + int i; + + if ((x < f->xmin) || (x >= f->xmax)) return; + if (ymax < f->ymin) return; + if (ymin > f->ymax) return; + if (ymin < f->ymin) ymin = f->ymin; + if (ymax >= f->ymax) ymax = f->ymax - 1; + + p = &f->pixels[ymin][x]; + for (i = 0; i <= (ymax - ymin); i++, p+=f->width) + *p = color; + +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_box(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) + + Makes an outline box. + ------------------------------------------------------------------------ */ + +void FrameBuffer_box(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) { + + int xt, yt; + + /* Make sure points are in correct order */ + + if (x2 < x1) { + xt = x2; + x2 = x1; + x1 = xt; + } + if (y2 < y1) { + yt = y2; + y2 = y1; + y1 = yt; + } + + /* Draw lower edge */ + + FrameBuffer_horizontal(f,x1,x2,y1,color); + + /* Draw upper edge */ + + FrameBuffer_horizontal(f,x1,x2,y2,color); + + /* Draw left side */ + + FrameBuffer_vertical(f,y1,y2,x1,color); + + /* Draw right side */ + + FrameBuffer_vertical(f,y1,y2,x2,color); + +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_solidbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) + + Makes an solid box. + ------------------------------------------------------------------------ */ + +void FrameBuffer_solidbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) { + + int xt, yt; + + /* Make sure points are in correct order */ + + if (x2 < x1) { + xt = x2; + x2 = x1; + x1 = xt; + } + if (y2 < y1) { + yt = y2; + y2 = y1; + y1 = yt; + } + + /* Now perform some clipping */ + + if (y1 < f->ymin) y1 = f->ymin; + if (y2 >= f->ymax) y2 = f->ymax - 1; + + /* Fill it in using horizontal lines */ + + for (yt = y1; yt <= y2; yt++) + FrameBuffer_horizontal(f,x1,x2,yt,color); + +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2 + Pixel c1, Pixel c2, Pixel c3, Pixel c4) + + Makes a box with interpolated color. Colors are assigned as follows : + (x1,y1) = c1 + (x1,y2) = c2 + (x2,y1) = c3 + (x2,y2) = c4 + ------------------------------------------------------------------------ */ + +void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, + Pixel c1, Pixel c2, Pixel c3, Pixel c4) { + + int xt, yt; + Pixel ct; + double mc1,mc2; + int ystart; + /* Make sure points are in correct order */ + + if (x2 < x1) { + xt = x2; + x2 = x1; + x1 = xt; + ct = c1; + c1 = c3; + c3 = ct; + ct = c2; + c2 = c4; + c4 = ct; + } + if (y2 < y1) { + yt = y2; + y2 = y1; + y1 = yt; + ct = c1; + c1 = c2; + c2 = ct; + ct = c3; + c3 = c4; + c4 = ct; + } + + /* Now perform some clipping */ + + ystart = y1; + mc1 = (double) (c2 - c1)/(double) (y2 - y1); + mc2 = (double) (c4 - c3)/(double) (y2 - y1); + if (y1 < f->ymin) y1 = f->ymin; + if (y2 >= f->ymax) y2 = f->ymax - 1; + + /* Fill it in using horizontal lines */ + + for (yt = y1; yt <= y2; yt++) + FrameBuffer_horizontalinterp(f,x1,x2,yt,(Pixel) ((mc1*(yt - ystart)) + c1), + (Pixel) ((mc2*(yt-ystart))+c3)); + +} + +/* --------------------------------------------------------------------------- + FrameBuffer_line(FrameBuffer *f, int x1, int y1, int x2, int y2, color) + + Draws a line on the framebuffer using the Bresenham line algorithm. The + line is clipped to fit within the current view window. + ---------------------------------------------------------------------------- */ + +void FrameBuffer_line(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c) { + + int dx,dy,dxneg,dyneg, inc1,inc2,di; + int x, y, xpixels, ypixels, xt, yt; + Pixel *p; + double m; + int end1 = 0, end2 = 0; + + /* Need to figure out where in the heck this line is */ + + dx = x2 - x1; + dy = y2 - y1; + + if (dx == 0) { + /* Draw a Vertical Line */ + if (y1 < y2) + FrameBuffer_vertical(f,y1,y2,x1,c); + else + FrameBuffer_vertical(f,y2,y1,x1,c); + return; + } + if (dy == 0) { + /* Draw a Horizontal Line */ + if (x1 < x2) + FrameBuffer_horizontal(f,x1,x2,y1,c); + else + FrameBuffer_horizontal(f,x2,x1,y1,c); + return; + } + + /* Figure out where in the heck these lines are using the + Cohen-Sutherland Line Clipping Scheme. */ + + end1 = ((x1 - f->xmin) < 0) | + (((f->xmax- 1 - x1) < 0) << 1) | + (((y1 - f->ymin) < 0) << 2) | + (((f->ymax-1 - y1) < 0) << 3); + + end2 = ((x2 - f->xmin) < 0) | + (((f->xmax-1 - x2) < 0) << 1) | + (((y2 - f->ymin) < 0) << 2) | + (((f->ymax-1 - y2) < 0) << 3); + + if (end1 & end2) return; /* Nope : Not visible */ + + /* Make sure points have a favorable orientation */ + + if (x1 > x2) { + xt = x1; + x1 = x2; + x2 = xt; + yt = y1; + y1 = y2; + y2 = yt; + } + + /* Clip against the boundaries */ + m = (y2 - y1)/(double) (x2-x1); + if (x1 < f->xmin) { + y1 = (int) ((f->xmin - x1)*m + y1); + x1 = (int) f->xmin; + } + if (x2 >= f->xmax) { + y2 = (int) ((f->xmax -1 -x1)*m + y1); + x2 = (int) (f->xmax - 1); + } + + if (y1 > y2) { + xt = x1; + x1 = x2; + x2 = xt; + yt = y1; + y1 = y2; + y2 = yt; + } + + m = 1/m; + if (y1 < f->ymin) { + x1 = (int) ((f->ymin - y1)*m + x1); + y1 = (int) f->ymin; + } + if (y2 >= f->ymax) { + x2 = (int) ((f->ymax-1-y1)*m + x1); + y2 = (int) (f->ymax-1); + } + + if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax) || + (x2 < f->xmin) || (x2 >= f->xmax) || (y2 < f->ymin) || (y2 >= f->ymax)) return; + + dx = x2 - x1; + dy = y2 - y1; + xpixels = f->width; + ypixels = f->height; + + dxneg = (dx < 0) ? 1 : 0; + dyneg = (dy < 0) ? 1 : 0; + + dx = abs(dx); + dy = abs(dy); + if (dx >= dy) { + /* Slope between -1 and 1. */ + if (dxneg) { + x = x1; + y = y1; + x1 = x2; + y1 = y2; + x2 = x; + y2 = y; + dyneg = !dyneg; + } + inc1 = 2*dy; + inc2 = 2*(dy-dx); + di = 2*dy-dx; + + /* Draw a line using x as independent variable */ + + p = &f->pixels[y1][x1]; + x = x1; + while (x <= x2) { + *(p++) = c; + if (di < 0) { + di = di + inc1; + } else { + if (dyneg) { + p = p - xpixels; + di = di + inc2; + } else { + p = p + xpixels; + di = di + inc2; + } + } + x++; + } + } else { + /* Slope < -1 or > 1 */ + if (dyneg) { + x = x1; + y = y1; + x1 = x2; + y1 = y2; + x2 = x; + y2 = y; + dxneg = !dxneg; + } + inc1 = 2*dx; + inc2 = 2*(dx-dy); + di = 2*dx-dy; + + /* Draw a line using y as independent variable */ + + p = &f->pixels[y1][x1]; + y = y1; + while (y <= y2) { + *p = c; + p = p + xpixels; + if (di < 0) { + di = di + inc1; + } else { + if (dxneg) { + p = p - 1; + di = di + inc2; + } else { + p = p + 1; + di = di + inc2; + } + } + y++; + } + } +} + + +/* ------------------------------------------------------------------------- + FrameBuffer_circle(FrameBuffer f, int xc, int yc, int radius, Pixel c) + + Create an outline circle + ------------------------------------------------------------------------- */ + +#define plot_circle(x,y,c) \ + if ((x >= xmin) && (x < xmax) && \ + (y >= ymin) && (y < ymax)) \ + pixels[y][x] = c; + +void FrameBuffer_circle(FrameBuffer *f, int xc, int yc, int radius, Pixel c) { + + int xpixels, ypixels, x, y, p; + int xmin, ymin, xmax, ymax; + Pixel **pixels; + + if (radius <= 0) return; + xpixels = f->width; + ypixels = f->height; + pixels = f->pixels; + xmin = f->xmin; + ymin = f->ymin; + xmax = f->xmax; + ymax = f->ymax; + x = 0; + y = radius; + p = 3-2*radius; + while (x <= y) { + plot_circle(xc+x,yc+y,c); + plot_circle(xc-x,yc+y,c); + plot_circle(xc+x,yc-y,c); + plot_circle(xc-x,yc-y,c); + plot_circle(xc+y,yc+x,c); + plot_circle(xc-y,yc+x,c); + plot_circle(xc+y,yc-x,c); + plot_circle(xc-y,yc-x,c); + if (p < 0) p = p + 4*x + 6; + else { + p = p + 4*(x-y) + 10; + y = y -1; + } + x++; + } +} + + +/* ------------------------------------------------------------------------- + FrameBuffer_solidcircle(FrameBuffer f, int xc, int yc, int radius, Pixel c) + + Create an filled circle + ------------------------------------------------------------------------- */ + + +#define fill_circle(x,y,c) \ + x1 = xc - x; \ + x2 = xc + x; \ + FrameBuffer_horizontal(f,x1,x2,y,c); + +void FrameBuffer_solidcircle(FrameBuffer *f, int xc, int yc, int radius, Pixel c) { + + int xpixels, ypixels, x, y, p; + int x1,x2; + int xmin, ymin, xmax, ymax; + Pixel **pixels; + + if (radius <= 0) return; + xpixels = f->width; + ypixels = f->height; + pixels = f->pixels; + xmin = f->xmin; + ymin = f->ymin; + xmax = f->xmax; + ymax = f->ymax; + x = 0; + y = radius; + p = 3-2*radius; + while (x <= y) { + fill_circle(x,yc+y,c); + fill_circle(x,yc-y,c); + fill_circle(y,yc+x,c); + fill_circle(y,yc-x,c); + if (p < 0) p = p + 4*x + 6; + else { + p = p + 4*(x-y) + 10; + y = y -1; + } + x++; + } +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_setclip(f,xmin,ymin,xmax,ymax) + + Set clipping region for plotting + ------------------------------------------------------------------------ */ + +void FrameBuffer_setclip(FrameBuffer *f, int xmin, int ymin, int xmax, int ymax) { + + if (xmin >= xmax) return; + if (ymin >= ymax) return; + + if (xmin < 0) xmin = 0; + if (ymin < 0) ymin = 0; + if (xmax > (int) f->width) xmax = f->width; + if (ymax > (int) f->height) ymax = f->height; + + f->xmin = xmin; + f->ymin = ymin; + f->xmax = xmax; + f->ymax = ymax; +} + +/* ------------------------------------------------------------------------ + void FrameBuffer_noclip(f) + + Disable clipping region + ------------------------------------------------------------------------ */ + +void FrameBuffer_noclip(FrameBuffer *f) { + f->xmin = 0; + f->ymin = 0; + f->xmax = f->width; + f->ymax = f->height; +} + + +/* ------------------------------------------------------------------------ + FrameBuffer_zresize(FrameBuffer *f, int width, int height) + + This function resizes the framebuffer's zbuffer. If none exist, it + creates a new one. + ------------------------------------------------------------------------ */ + +void FrameBuffer_zresize(FrameBuffer *f, int width, int height) { + int i; + + if (f->zbuffer) { + free((char *)f->zbuffer[0]); + free((char *)f->zbuffer); + } + f->zbuffer = (Zvalue **) malloc(height*sizeof(Zvalue *)); + f->zbuffer[0] = (Zvalue *) malloc(height*width*sizeof(Zvalue)); + for (i = 0; i < height; i++) + f->zbuffer[i] = f->zbuffer[0]+i*width; +} + +/* ------------------------------------------------------------------------ + FrameBuffer_zclear(FrameBuffer *f) + + Clears the z-buffer for a particular frame. Sets all of the z-values to + ZMIN. + ------------------------------------------------------------------------- */ + +void FrameBuffer_zclear(FrameBuffer *f) { + unsigned int i,j; + if (f) { + if (f->zbuffer) { + for (i = 0; i < f->width; i++) + for (j = 0; j < f->height; j++) + f->zbuffer[j][i] = ZMIN; + } + } +} + + + +/* ------------------------------------------------------------------------- + FrameBuffer_solidtriangle(FrameBuffer *f, int tx1, int ty2, + int tx2, int ty2, + int tx3, int ty3, Pixel color) + + This function draws a 2D filled triangle. + + General idea : + 1. Transform the three points into screen coordinates + 2. Order three points vertically on screen. + 3. Check for degenerate cases (where 3 points are colinear). + 4. Fill in the resulting triangle using horizontal lines. + -------------------------------------------------------------------------- */ + +void FrameBuffer_solidtriangle(FrameBuffer *f, int tx1, int ty1, + int tx2, int ty2, + int tx3, int ty3, Pixel color) { + int tempx, tempy; + double m1,m2,m3; + int y; + int ix1, ix2; + + /* Figure out which point has the greatest "y" value */ + + if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ + tempx = tx1; + tempy = ty1; + tx1 = tx2; + ty1 = ty2; + tx2 = tempx; + ty2 = tempy; + } + if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ + tempx = tx1; + tempy = ty1; + tx1 = tx3; + ty1 = ty3; + tx3 = tempx; + ty3 = tempy; + } + if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ + tempx = tx2; + tempy = ty2; + tx2 = tx3; + ty2 = ty3; + tx3 = tempx; + ty3 = tempy; + } + + /* Points are now order so that t_1 is the highest point, t_2 is the + middle point, and t_3 is the lowest point */ + + /* Check for degenerate cases here */ + + if ((ty1 == ty2) && (ty2 == ty3)) { + + /* Points are aligned horizontally. Handle as a special case */ + /* Just draw three lines using the outline color */ + + FrameBuffer_line(f,tx1,ty1,tx2,ty2,color); + FrameBuffer_line(f,tx1,ty1,tx3,ty3,color); + FrameBuffer_line(f,tx2,ty2,tx3,ty3,color); + + } else { + + if (ty2 < ty1) { + /* First process line segments between (x1,y1)-(x2,y2) + And between (x1,y1),(x3,y3) */ + + m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + + y = ty1; + while (y >= ty2) { + /* Calculate x values from slope */ + ix1 = (int) (m1*(y-ty1)+0.5) + tx1; + ix2 = (int) (m2*(y-ty1)+0.5) + tx1; + if (ix1 > ix2) + FrameBuffer_horizontal(f,ix2,ix1,y,color); + else + FrameBuffer_horizontal(f,ix1,ix2,y,color); + y--; + } + } + if (ty3 < ty2) { + /* Draw lower half of the triangle */ + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); + y = ty2; + while (y >= ty3) { + ix1 = (int) (m3*(y-ty2)+0.5)+tx2; + ix2 = (int) (m2*(y-ty1)+0.5)+tx1; + if (ix1 > ix2) + FrameBuffer_horizontal(f,ix2,ix1,y,color); + else + FrameBuffer_horizontal(f,ix1,ix2,y,color); + y--; + } + } + } +} + +/* ------------------------------------------------------------------------- + FrameBuffer_interptriangle(FrameBuffer *f, + int tx1, int ty2, Pixel c1, + int tx2, int ty2, Pixel c2, + int tx3, int ty3, Pixel c3) + + This function draws a filled triangle with color + interpolation. + + General idea : + 1. Transform the three points into screen coordinates + 2. Order three points vertically on screen. + 3. Check for degenerate cases (where 3 points are colinear). + 4. Fill in the resulting triangle using horizontal lines. + 5. Colors are interpolated between end points + -------------------------------------------------------------------------- */ + +void FrameBuffer_interptriangle(FrameBuffer *f, + int tx1, int ty1, Pixel c1, + int tx2, int ty2, Pixel c2, + int tx3, int ty3, Pixel c3) { + int tempx, tempy; + double m1,m2,m3; + double mc1,mc2,mc3; + Pixel ic1,ic2,tempc; + int y; + int ix1, ix2; + + /* Figure out which point has the greatest "y" value */ + + if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ + tempx = tx1; + tempy = ty1; + tempc = c1; + tx1 = tx2; + ty1 = ty2; + c1 = c2; + tx2 = tempx; + ty2 = tempy; + c2 = tempc; + } + if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ + tempx = tx1; + tempy = ty1; + tempc = c1; + tx1 = tx3; + ty1 = ty3; + c1 = c3; + tx3 = tempx; + ty3 = tempy; + c3 = tempc; + } + if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ + tempx = tx2; + tempy = ty2; + tempc = c2; + tx2 = tx3; + ty2 = ty3; + c2 = c3; + tx3 = tempx; + ty3 = tempy; + c3 = tempc; + } + + /* Points are now order so that t_1 is the highest point, t_2 is the + middle point, and t_3 is the lowest point */ + + /* Check for degenerate cases here */ + + if ((ty1 == ty2) && (ty2 == ty3)) { + + /* Points are aligned horizontally. Handle as a special case */ + /* Just draw three lines using the outline color */ + + if (tx2 > tx1) + FrameBuffer_horizontalinterp(f,tx1,tx2,ty1,c1,c2); + else + FrameBuffer_horizontalinterp(f,tx2,tx1,ty1,c2,c1); + if (tx3 > tx1) + FrameBuffer_horizontalinterp(f,tx1,tx3,ty1,c1,c3); + else + FrameBuffer_horizontalinterp(f,tx3,tx1,ty1,c3,c1); + if (tx3 > tx2) + FrameBuffer_horizontalinterp(f,tx2,tx3,ty2,c2,c3); + else + FrameBuffer_horizontalinterp(f,tx3,tx2,ty2,c3,c2); + + } else { + + /* First process line segments between (x1,y1)-(x2,y2) + And between (x1,y1),(x3,y3) */ + + if (ty2 < ty1) { + m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + mc1 = (c2 - c1)/(double) (ty2 - ty1); + mc2 = (c3 - c1)/(double) (ty3 - ty1); + + y = ty1; + while (y >= ty2) { + /* Calculate x values from slope */ + ix1 = (int) (m1*(y-ty1)+0.5) + tx1; + ix2 = (int) (m2*(y-ty1)+0.5) + tx1; + ic1 = (int) (mc1*(y-ty1) + c1); + ic2 = (int) (mc2*(y-ty1) + c1); + if (ix1 > ix2) + FrameBuffer_horizontalinterp(f,ix2,ix1,y,ic2,ic1); + else + FrameBuffer_horizontalinterp(f,ix1,ix2,y,ic1,ic2); + y--; + } + } + if (ty3 < ty2) { + /* Draw lower half of the triangle */ + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + mc2 = (c3 - c1)/(double) (ty3 - ty1); + m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); + mc3 = (c3 - c2)/(double) (ty3 - ty2); + y = ty2; + while (y >= ty3) { + ix1 = (int) (m3*(y-ty2)+0.5)+tx2; + ix2 = (int) (m2*(y-ty1)+0.5)+tx1; + ic1 = (int) (mc3*(y-ty2)+c2); + ic2 = (int) (mc2*(y-ty1)+c1); + if (ix1 > ix2) + FrameBuffer_horizontalinterp(f,ix2,ix1,y,ic2,ic1); + else + FrameBuffer_horizontalinterp(f,ix1,ix2,y,ic1,ic2); + y--; + } + } + } +} + + diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c new file mode 100644 index 0000000..7953e5c --- /dev/null +++ b/Examples/GIFPlot/Lib/gif.c @@ -0,0 +1,672 @@ + +/********************************************************************** + * GIFPlot 0.0 + * + * Dave Beazley + * + * Department of Computer Science Theoretical Division (T-11) + * University of Utah Los Alamos National Laboratory + * Salt Lake City, Utah 84112 Los Alamos, New Mexico 87545 + * beazley@cs.utah.edu beazley@lanl.gov + * + * Copyright (c) 1996 + * The Regents of the University of California and the University of Utah + * 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. + * + **************************************************************************/ + +/******************************************************************* + * Creates a GIF format file. + * + * Dave Beazley (T-11) + * August 11, 1995 + * + * Rather than writing directly to files, this module fills out + * output buffer. + * + * Note : To save memory, this routine uses approximately 50K of the + * output buffer as temporary storage (for hash tables and compression codes). + * The remainder of the output buffer is used to store the final image. + * This feature allows GIF images to be created with no additional + * memory overhead. + * + * -- Revision History + * $Log$ + * Revision 1.2 2003/09/01 16:23:31 beazley + * Restored the 'mojo'. + * + * Revision 1.2 1996/09/25 22:39:30 dmb + * Fixed prototypes and use of void pointers for compatibility with the Cray T3D + * + * Revision 1.1 1996/09/10 17:44:00 dmb + * Initial revision + * + * Revision 1.2 1995/08/31 14:46:07 beazley + * Minor changes to support comments and a few bug fixes. + * + * + ******************************************************************/ + + +/* + * xvgifwr.c - handles writing of GIF files. based on flgife.c and + * flgifc.c from the FBM Library, by Michael Maudlin + * + * Contains: + * WriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle, + * comment) + * + * Note: slightly brain-damaged, in that it'll only write non-interlaced + * GIF files (in the interests of speed, or something) + * + */ + + + +/***************************************************************** + * Portions of this code Copyright (C) 1989 by Michael Mauldin. + * Permission is granted to use this file in whole or in + * part for any purpose, educational, recreational or commercial, + * provided that this copyright notice is retained unchanged. + * This software is available to all free of charge by anonymous + * FTP and in the UUNET archives. + * + * + * Authors: Michael Mauldin (mlm@cs.cmu.edu) + * David Rowley (mgardi@watdcsu.waterloo.edu) + * + * Based on: compress.c - File compression ala IEEE Computer, June 1984. + * + * Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) + * Jim McKie (decvax!mcvax!jim) + * Steve Davies (decvax!vax135!petsd!peora!srd) + * Ken Turkowski (decvax!decwrl!turtlevax!ken) + * James A. Woods (decvax!ihnp4!ames!jaw) + * Joe Orost (decvax!vax135!petsd!joe) + *****************************************************************/ + +#include "gifplot.h" +#include +typedef long int count_int; +typedef unsigned char byte; + +static int gif_error; +static unsigned char *op; +static int Width, Height; +static int curx, cury; +static int Interlace; + +static void putgifword(int); +static void compress(int, byte **, int); +static void output_GIF(int); +static void cl_block(void); +static void cl_hash(count_int); +static void char_init(void); +static void char_out(int); +static void flush_char(void); +static void *OutBuffer; +static int OutBufSize; +static FrameBuffer *GIF_frame; + +static unsigned char pc2nc[256],r1[256],g1[256],b1[256]; + +/*************************************************************/ +int FrameBuffer_makeGIF(FrameBuffer *f, ColorMap *c, void *outbuffer, unsigned int outbufsize) +{ + int RWidth, RHeight; + int LeftOfs, TopOfs; + int ColorMapSize, InitCodeSize, Background, BitsPerPixel; + int i,j,nc; + char *rmap, *gmap, *bmap; + char *cmap; + int count; + + Interlace = 0; + Background = 0; + OutBuffer = outbuffer; + OutBufSize = outbufsize; + GIF_frame = f; + cmap = (char *) c->cmap; + + op = (unsigned char *) outbuffer; + gif_error = 0; + for (i=0; i<256; i++) { pc2nc[i] = r1[i] = g1[i] = b1[i] = 0; } + + /* compute number of unique colors */ + nc = 0; + rmap = &cmap[0]; + gmap = &cmap[256]; + bmap = &cmap[512]; + + for (i=0; i<256; i++) { + /* see if color #i is already used */ + for (j=0; j= nc) break; + + BitsPerPixel = i; + + ColorMapSize = 1 << BitsPerPixel; + + RWidth = Width = f->width; + RHeight = Height = f->height; + LeftOfs = TopOfs = 0; + + if (BitsPerPixel <= 1) InitCodeSize = 2; + else InitCodeSize = BitsPerPixel; + + curx = 0; + cury = f->height - 1; + + strcpy((char *) op,"GIF89a"); /* Put in GIF magic number */ + op+=6; + putgifword(RWidth); /* screen descriptor */ + putgifword(RHeight); + + i = 0x80; /* Yes, there is a color map */ + i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */ + i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */ + *(op++) = i; + *(op++) = Background; /* background color */ + *(op++) = 0; + for (i=0; ipixels, f->width*f->height); + + *(op++) = 0; + *(op++) = ';'; + + count = (op - (unsigned char *) OutBuffer); + if (gif_error) return -1; + else return count; +} + +/******************************/ +static void putgifword(w) +int w; +{ + /* writes a 16-bit integer in GIF order (LSB first) */ + *(op++) = w & 0xff; + *(op++) = (w>>8)&0xff; +} + +/***********************************************************************/ + + +static unsigned long cur_accum = 0; +static int cur_bits = 0; + + + + +#define GP_BITS 12 /* BITS was already defined on some systems */ + +#define HSIZE 5003 /* 80% occupancy */ + +typedef unsigned char char_type; + +static int n_bits; /* number of bits/code */ +static int maxbits = GP_BITS; /* user settable max # bits/code */ +static int maxcode; /* maximum code, given n_bits */ +static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */ + +#define MAXCODE(n_bits) ( (1 << (n_bits)) - 1) + +static count_int *htab; +static unsigned short *codetab; +static int GIFOutBufSize; + +/* static count_int htab [HSIZE]; +static unsigned short codetab [HSIZE]; */ + +#define HashTabOf(i) htab[i] +#define CodeTabOf(i) codetab[i] + +static int hsize = HSIZE; /* for dynamic table sizing */ + +/* + * To save much memory, we overlay the table used by compress() with those + * used by decompress(). The tab_prefix table is the same size and type + * as the codetab. The tab_suffix table needs 2**BITS characters. We + * get this from the beginning of htab. The output stack uses the rest + * of htab, and contains characters. There is plenty of room for any + * possible stack (stack used to be 8000 characters). + */ + +#define tab_prefixof(i) CodeTabOf(i) +#define tab_suffixof(i) ((char_type *)(htab))[i] +#define de_stack ((char_type *)&tab_suffixof(1<= GIF_frame->width) { + curx = 0; + cury--; + } + len--; + + hshift = 0; + for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L ) + hshift++; + hshift = 8 - hshift; /* set hash code range bound */ + + hsize_reg = hsize; + cl_hash( (count_int) hsize_reg); /* clear hash table */ + + output_GIF(ClearCode); + while (len) { + c = pc2nc[data[cury][curx]]; + curx++; + if (curx >= GIF_frame->width) { + curx = 0; + cury--; + } + len--; + + fcode = (long) ( ( (long) c << maxbits) + ent); + i = (((int) c << hshift) ^ ent); /* xor hashing */ + + if ( HashTabOf (i) == fcode ) { + ent = CodeTabOf (i); + continue; + } + + if ( (long)HashTabOf (i) < 0 ) /* empty slot */ + goto nomatch; + + disp = hsize_reg - i; /* secondary hash (after G. Knott) */ + if ( i == 0 ) + disp = 1; + +probe: + if ( (i -= disp) < 0 ) + i += hsize_reg; + + if ( HashTabOf (i) == fcode ) { + ent = CodeTabOf (i); + continue; + } + + if ( (long)HashTabOf (i) >= 0 ) + goto probe; + +nomatch: + output_GIF(ent); + out_count++; + ent = c; + + if ( free_ent < maxmaxcode ) { + CodeTabOf (i) = free_ent++; /* code -> hashtable */ + HashTabOf (i) = fcode; + } + else + cl_block(); + + } + /* Put out the final code */ + output_GIF(ent); + output_GIF(EOFCode); +} + + +/***************************************************************** + * TAG( output_GIF ) + * + * Output the given code. + * Inputs: + * code: A n_bits-bit integer. If == -1, then EOF. This assumes + * that n_bits =< (long)wordsize - 1. + * Outputs: + * Outputs code to the file. + * Assumptions: + * Chars are 8 bits long. + * Algorithm: + * Maintain a BITS character long buffer (so that 8 codes will + * fit in it exactly). Use the VAX insv instruction to insert each + * code in turn. When the buffer fills up empty it and start over. + */ + +static +unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, + 0x001F, 0x003F, 0x007F, 0x00FF, + 0x01FF, 0x03FF, 0x07FF, 0x0FFF, + 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; + +static void output_GIF(code) +int code; +{ + cur_accum &= masks[cur_bits]; + + if (cur_bits > 0) + cur_accum |= ((long)code << cur_bits); + else + cur_accum = code; + + cur_bits += n_bits; + + while( cur_bits >= 8 ) { + char_out( (int) (cur_accum & 0xff) ); + cur_accum >>= 8; + cur_bits -= 8; + } + + /* + * If the next entry is going to be too big for the code size, + * then increase it, if possible. + */ + + if (free_ent > maxcode || clear_flg) { + + if( clear_flg ) { + maxcode = MAXCODE (n_bits = g_init_bits); + clear_flg = 0; + } + else { + n_bits++; + if ( n_bits == maxbits ) + maxcode = maxmaxcode; + else + maxcode = MAXCODE(n_bits); + } + } + + if( code == EOFCode ) { + /* At EOF, write the rest of the buffer */ + while( cur_bits > 0 ) { + char_out( (int)(cur_accum & 0xff) ); + cur_accum >>= 8; + cur_bits -= 8; + } + + flush_char(); + } +} + + +/********************************/ +static void cl_block () /* table clear for block compress */ +{ + /* Clear out the hash table */ + + cl_hash ( (count_int) hsize ); + free_ent = ClearCode + 2; + clear_flg = 1; + + output_GIF(ClearCode); +} + + +/********************************/ +static void cl_hash(hsize) /* reset code table */ +register count_int hsize; +{ + register count_int *htab_p = htab+hsize; + register long i; + register long m1 = -1; + + i = hsize - 16; + do { /* might use Sys V memset(3) here */ + *(htab_p-16) = m1; + *(htab_p-15) = m1; + *(htab_p-14) = m1; + *(htab_p-13) = m1; + *(htab_p-12) = m1; + *(htab_p-11) = m1; + *(htab_p-10) = m1; + *(htab_p-9) = m1; + *(htab_p-8) = m1; + *(htab_p-7) = m1; + *(htab_p-6) = m1; + *(htab_p-5) = m1; + *(htab_p-4) = m1; + *(htab_p-3) = m1; + *(htab_p-2) = m1; + *(htab_p-1) = m1; + htab_p -= 16; + } while ((i -= 16) >= 0); + + for ( i += 16; i > 0; i-- ) + *--htab_p = m1; +} + + +/****************************************************************************** + * + * GIF Specific routines + * + ******************************************************************************/ + +/* + * Number of characters so far in this 'packet' + */ +static int a_count; + +/* + * Set up the 'byte output' routine + */ +static void char_init() +{ + a_count = 0; +} + +/* + * Define the storage for the packet accumulator + */ +static char accum[ 256 ]; + +/* + * Add a character to the end of the current packet, and if it is 254 + * characters, flush the packet to disk. + */ +static void char_out(c) +int c; +{ + accum[ a_count++ ] = c; + if( a_count >= 254 ) + flush_char(); +} + +/* + * Flush the packet to disk, and reset the accumulator + */ +static void flush_char() +{ + if (gif_error) return; + if( a_count > 0 ) { + *(op++) = a_count; + memcpy(op,accum,a_count); + op+=a_count; + a_count = 0; + + if (op > (unsigned char *) ((char *) OutBuffer + (GIFOutBufSize - 2048))) { + gif_error = 1; + } + } +} + + +/* ---------------------------------------------------------------------- + int FrameBuffer_writeGIF(char *filename) + + Write a GIF file to filename + ----------------------------------------------------------------------- */ + +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) { + + FILE *file; + void *buffer; + int nbytes; + int bufsize; + + file = fopen(filename,"wb"); + if (file == NULL) return -1; + + bufsize = (f->width*f->height*3)/2; + buffer = (void *) malloc(bufsize); + nbytes = FrameBuffer_makeGIF(f,c,buffer,bufsize); + if (nbytes == -1) { + free(buffer); + fclose(file); + return -1; + } + if (fwrite(buffer,nbytes,1,file) != 1) { + free(buffer); + fclose(file); + return -1; + } + fclose(file); + free(buffer); + return 0; +} + + + + + diff --git a/Examples/GIFPlot/Lib/matrix.c b/Examples/GIFPlot/Lib/matrix.c new file mode 100644 index 0000000..ef0cf3a --- /dev/null +++ b/Examples/GIFPlot/Lib/matrix.c @@ -0,0 +1,343 @@ +/* ----------------------------------------------------------------------------- + * matrix.c + * + * Some 4x4 matrix operations + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define MATRIX +#include "gifplot.h" +#include + +/* ------------------------------------------------------------------------ + Matrix new_Matrix() + + Create a new 4x4 matrix. + ------------------------------------------------------------------------ */ +Matrix +new_Matrix() { + Matrix m; + m = (Matrix) malloc(16*sizeof(double)); + return m; +} + +/* ------------------------------------------------------------------------ + delete_Matrix(Matrix *m); + + Destroy a matrix + ------------------------------------------------------------------------ */ + +void +delete_Matrix(Matrix m) { + if (m) + free((char *) m); +} + +/* ------------------------------------------------------------------------ + Matrix Matrix_copy(Matrix a) + + Makes a copy of matrix a and returns it. + ------------------------------------------------------------------------ */ + +Matrix Matrix_copy(Matrix a) { + int i; + Matrix r = 0; + if (a) { + r = new_Matrix(); + if (r) { + for (i = 0; i < 16; i++) + r[i] = a[i]; + } + } + return r; +} + +/* ------------------------------------------------------------------------ + Matrix_multiply(Matrix a, Matrix b, Matrix c) + + Multiplies a*b = c + c may be one of the source matrices + ------------------------------------------------------------------------ */ +void +Matrix_multiply(Matrix a, Matrix b, Matrix c) { + double temp[16]; + int i,j,k; + + for (i =0; i < 4; i++) + for (j = 0; j < 4; j++) { + temp[i*4+j] = 0.0; + for (k = 0; k < 4; k++) + temp[i*4+j] += a[i*4+k]*b[k*4+j]; + } + for (i = 0; i < 16; i++) + c[i] = temp[i]; +} + +/* ------------------------------------------------------------------------ + Matrix_identity(Matrix a) + + Puts an identity matrix in matrix a + ------------------------------------------------------------------------ */ + +void +Matrix_identity(Matrix a) { + int i; + for (i = 0; i < 16; i++) a[i] = 0; + a[0] = 1; + a[5] = 1; + a[10] = 1; + a[15] = 1; +} + +/* ------------------------------------------------------------------------ + Matrix_zero(Matrix a) + + Puts a zero matrix in matrix a + ------------------------------------------------------------------------ */ +void +Matrix_zero(Matrix a) { + int i; + for (i = 0; i < 16; i++) a[i] = 0; +} + +/* ------------------------------------------------------------------------ + Matrix_transpose(Matrix a, Matrix result) + + Transposes matrix a and puts it in result. + ------------------------------------------------------------------------ */ +void +Matrix_transpose(Matrix a, Matrix result) { + double temp[16]; + int i,j; + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + temp[4*i+j] = a[4*j+i]; + + for (i = 0; i < 16; i++) + result[i] = temp[i]; +} + + +/* ------------------------------------------------------------------------ + Matrix_gauss(Matrix a, Matrix b) + + Solves ax=b for x, using Gaussian elimination. Destroys a. + Really only used for calculating inverses of 4x4 transformation + matrices. + ------------------------------------------------------------------------ */ + +void Matrix_gauss(Matrix a, Matrix b) { + int ipiv[4], indxr[4], indxc[4]; + int i,j,k,l,ll; + int irow=0, icol=0; + double big, pivinv; + double dum; + for (j = 0; j < 4; j++) + ipiv[j] = 0; + for (i = 0; i < 4; i++) { + big = 0; + for (j = 0; j < 4; j++) { + if (ipiv[j] != 1) { + for (k = 0; k < 4; k++) { + if (ipiv[k] == 0) { + if (fabs(a[4*j+k]) >= big) { + big = fabs(a[4*j+k]); + irow = j; + icol = k; + } + } else if (ipiv[k] > 1) + return; /* Singular matrix */ + } + } + } + ipiv[icol] = ipiv[icol]+1; + if (irow != icol) { + for (l = 0; l < 4; l++) { + dum = a[4*irow+l]; + a[4*irow+l] = a[4*icol+l]; + a[4*icol+l] = dum; + } + for (l = 0; l < 4; l++) { + dum = b[4*irow+l]; + b[4*irow+l] = b[4*icol+l]; + b[4*icol+l] = dum; + } + } + indxr[i] = irow; + indxc[i] = icol; + if (a[4*icol+icol] == 0) return; + pivinv = 1.0/a[4*icol+icol]; + a[4*icol+icol] = 1.0; + for (l = 0; l < 4; l++) + a[4*icol+l] = a[4*icol+l]*pivinv; + for (l = 0; l < 4; l++) + b[4*icol+l] = b[4*icol+l]*pivinv; + for (ll = 0; ll < 4; ll++) { + if (ll != icol) { + dum = a[4*ll+icol]; + a[4*ll+icol] = 0; + for (l = 0; l < 4; l++) + a[4*ll+l] = a[4*ll+l] - a[4*icol+l]*dum; + for (l = 0; l < 4; l++) + b[4*ll+l] = b[4*ll+l] - b[4*icol+l]*dum; + } + } + } + for (l = 3; l >= 0; l--) { + if (indxr[l] != indxc[l]) { + for (k = 0; k < 4; k++) { + dum = a[4*k+indxr[l]]; + a[4*k+indxr[l]] = a[4*k+indxc[l]]; + a[4*k+indxc[l]] = dum; + } + } + } +} + +/* ------------------------------------------------------------------------ + Matrix_invert(Matrix a, Matrix inva) + + Inverts Matrix a and places the result in inva. + Relies on the Gaussian Elimination code above. (See Numerical recipes). + ------------------------------------------------------------------------ */ +void +Matrix_invert(Matrix a, Matrix inva) { + + double temp[16]; + int i; + + for (i = 0; i < 16; i++) + temp[i] = a[i]; + Matrix_identity(inva); + Matrix_gauss(temp,inva); +} + +/* ------------------------------------------------------------------------ + Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t) + + Transform a vector. a*r ----> t + ------------------------------------------------------------------------ */ + +void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t) { + + double rx, ry, rz, rw; + + rx = r->x; + ry = r->y; + rz = r->z; + rw = r->w; + t->x = a[0]*rx + a[1]*ry + a[2]*rz + a[3]*rw; + t->y = a[4]*rx + a[5]*ry + a[6]*rz + a[7]*rw; + t->z = a[8]*rx + a[9]*ry + a[10]*rz + a[11]*rw; + t->w = a[12]*rx + a[13]*ry + a[14]*rz + a[15]*rw; +} + +/* ------------------------------------------------------------------------ + Matrix_transform4(Matrix a, double x, double y, double z, double w, GL_Vector *t) + + Transform a vector from a point specified as 4 doubles + ------------------------------------------------------------------------ */ + +void Matrix_transform4(Matrix a, double rx, double ry, double rz, double rw, + GL_Vector *t) { + + t->x = a[0]*rx + a[1]*ry + a[2]*rz + a[3]*rw; + t->y = a[4]*rx + a[5]*ry + a[6]*rz + a[7]*rw; + t->z = a[8]*rx + a[9]*ry + a[10]*rz + a[11]*rw; + t->w = a[12]*rx + a[13]*ry + a[14]*rz + a[15]*rw; +} + +/* --------------------------------------------------------------------- + Matrix_translate(Matrix a, double tx, double ty, double tz) + + Put a translation matrix in Matrix a + ---------------------------------------------------------------------- */ + +void Matrix_translate(Matrix a, double tx, double ty, double tz) { + Matrix_identity(a); + a[3] = tx; + a[7] = ty; + a[11] = tz; + a[15] = 1; +} + +/* ----------------------------------------------------------------------- + Matrix_rotatex(Matrix a, double deg) + + Produce an x-rotation matrix for given angle in degrees. + ----------------------------------------------------------------------- */ +void +Matrix_rotatex(Matrix a, double deg) { + double r; + + r = 3.1415926*deg/180.0; + Matrix_zero(a); + a[0] = 1.0; + a[5] = cos(r); + a[6] = -sin(r); + a[9] = sin(r); + a[10] = cos(r); + a[15] = 1.0; +} + +/* ----------------------------------------------------------------------- + Matrix_rotatey(Matrix a, double deg) + + Produce an y-rotation matrix for given angle in degrees. + ----------------------------------------------------------------------- */ +void +Matrix_rotatey(Matrix a, double deg) { + double r; + + r = 3.1415926*deg/180.0; + Matrix_zero(a); + a[0] = cos(r); + a[2] = sin(r); + a[5] = 1.0; + a[8] = -sin(r); + a[10] = cos(r); + a[15] = 1; + +} +/* ----------------------------------------------------------------------- + Matrix_RotateZ(Matrix a, double deg) + + Produce an z-rotation matrix for given angle in degrees. + ----------------------------------------------------------------------- */ +void +Matrix_rotatez(Matrix a, double deg) { + double r; + + r = 3.1415926*deg/180.0; + Matrix_zero(a); + a[0] = cos(r); + a[1] = -sin(r); + a[4] = sin(r); + a[5] = cos(r); + a[10] = 1.0; + a[15] = 1.0; +} + + +/* A debugging routine */ + +void Matrix_set(Matrix a, int i, int j, double val) { + a[4*j+i] = val; +} + +void Matrix_print(Matrix a) { + int i,j; + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + fprintf(stdout,"%10f ",a[4*i+j]); + } + fprintf(stdout,"\n"); + } + fprintf(stdout,"\n"); +} + diff --git a/Examples/GIFPlot/Lib/pixmap.c b/Examples/GIFPlot/Lib/pixmap.c new file mode 100644 index 0000000..a55cf04 --- /dev/null +++ b/Examples/GIFPlot/Lib/pixmap.c @@ -0,0 +1,159 @@ +/* ----------------------------------------------------------------------------- + * pixmap.c + * + * Pixel maps (i.e., bitmaps) + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define PIXMAP +#include "gifplot.h" + +/* ----------------------------------------------------------------------- + PixMap *new_PixMap(int width, int height, int centerx, int centery) + + Create a new pixmap of given size + ----------------------------------------------------------------------- */ +PixMap *new_PixMap(int width, int height, int centerx, int centery) { + PixMap *pm; + if ((width > 0) && (height > 0)) { + pm = (PixMap *) malloc(sizeof(PixMap)); + pm->width = width; + pm->height = height; + pm->centerx = centerx; + pm->centery = centery; + pm->map = (int *) malloc(height*width*sizeof(int)); + return pm; + } + return (PixMap *) 0; +} + +/* -------------------------------------------------------------------------- + void delete_PixMap(PixMap *pm) + + Destroy a pixmap + -------------------------------------------------------------------------- */ + +void delete_PixMap(PixMap *pm) { + if (pm) { + free((char *) pm->map); + free((char *) pm); + } +} + +/* --------------------------------------------------------------------------- + void PixMap_set(PixMap *pm, int x, int y, int pix) + + Set a pixel in the bitmap + --------------------------------------------------------------------------- */ +void +PixMap_set(PixMap *pm, int x, int y, int pix) { + if ((x < 0) || (x>=pm->width)) return; + if ((y < 0) || (y>=pm->height)) return; + + pm->map[pm->width*y + x] = pix; +} + +/* ----------------------------------------------------------------------------- + void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor) + + Draw a pixmap onto the framebuffer. This is somewhat optimized for speed. + ------------------------------------------------------------------------------ */ + +void +FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor) { + + int startx, starty; /* Starting location on framebuffer */ + int startpixx = 0, startpixy = 0; /* Starting location in pixmap */ + int endx, endy; /* Ending location on framebuffer */ + int i,j, px, py; + int c; + + startx = x - pm->centerx; + starty = y + pm->centery; + endx = startx + pm->width; + endy = starty - pm->height; + + /* Figure out if we need to clip */ + + if (startx < f->xmin) { + startpixx = f->xmin - startx; + startx = f->xmin; + } + if (starty >= f->ymax) { + startpixy = starty - f->ymax; + starty = f->ymax-1; + } + if (endx >= f->xmax) { + endx = f->xmax-1; + } + if (endy < f->ymin) { + endy = f->ymin; + } + py = startpixy; + for (j = starty; j >= endy; j--) { + px = startpixx; + for (i = startx; i < endx; i++) { + c = pm->map[py*pm->width + px]; + switch (c) { + case GIFPLOT_FOREGROUND: + f->pixels[j][i] = fgcolor; + break; + case GIFPLOT_BACKGROUND: + f->pixels[j][i] = bgcolor; + break; + default: + break; + } + px++; + } + py++; + } +} + +/************************************************************************** + * Some common PixMaps (for plotting) + * + **************************************************************************/ + +int _SQUARE_MAP[] = { + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0 }; + +PixMap PixMap_SQUARE = { 8,8,4,4, _SQUARE_MAP}; + +int _TRIANGLE_MAP[] = { + 0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,1,1,1,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,1,1,1,0,0, + 1,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 }; + +PixMap PixMap_TRIANGLE = { 8,8,4,4,_TRIANGLE_MAP}; + +int _CROSS_MAP[] = { + 0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,0, + 1,1,1,1,1,1,1,0, + 0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,0, + 0,0,0,0,0,0,0,0 }; + +PixMap PixMap_CROSS = { 8,8,4,4,_CROSS_MAP}; + + + diff --git a/Examples/GIFPlot/Lib/plot2d.c b/Examples/GIFPlot/Lib/plot2d.c new file mode 100644 index 0000000..e78107b --- /dev/null +++ b/Examples/GIFPlot/Lib/plot2d.c @@ -0,0 +1,445 @@ +/* ----------------------------------------------------------------------------- + * plot2d.c + * + * 2-Dimensional plotting + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define PLOT2D + +#include "gifplot.h" + +/* ------------------------------------------------------------------------ + Plot2D *new_Plot2D(FrameBuffer *frame, xmin, ymin, xmax, ymax) + + Create a new 2D plot with given minimum and maximum coordinates. + ------------------------------------------------------------------------ */ +Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin,double xmax,double ymax) { + Plot2D *p2; + if (frame) { + if (xmax <= xmin) return (Plot2D *) 0; + if (ymax <= ymin) return (Plot2D *) 0; + p2 = (Plot2D *) malloc(sizeof(Plot2D)); + p2->frame = frame; + p2->xmin = xmin; + p2->ymin = ymin; + p2->xmax = xmax; + p2->ymax = ymax; + p2->view_xmin = 0; + p2->view_xmax = frame->width; + p2->view_ymin = 0; + p2->view_ymax = frame->height; + p2->xscale = LINEAR; + p2->yscale = LINEAR; + p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); + p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); + return p2; + } + return (Plot2D *) 0; +} + +/* ---------------------------------------------------------------------------- + delete_Plot2D(Plot2D *p2) + + Delete a 2D plot + ---------------------------------------------------------------------------- */ +void +delete_Plot2D(Plot2D *p2) { + if (p2) + free((char *) p2); +} + +/* ----------------------------------------------------------------------------- + Plot2D *Plot2D_copy(Plot2D *p2) + + Makes a copy of the Plot2D data structure. + ----------------------------------------------------------------------------- */ + +Plot2D *Plot2D_copy(Plot2D *p2) { + Plot2D *c2; + if (p2) { + c2 = (Plot2D *) malloc(sizeof(Plot2D)); + if (c2) { + c2->frame = p2->frame; + c2->view_xmin = p2->view_xmin; + c2->view_ymin = p2->view_ymin; + c2->view_xmax = p2->view_xmax; + c2->view_ymax = p2->view_ymax; + c2->xmin = p2->xmin; + c2->ymin = p2->ymin; + c2->xmax = p2->xmax; + c2->ymax = p2->ymax; + c2->xscale = p2->xscale; + c2->yscale = p2->yscale; + c2->dx = p2->dx; + c2->dy = p2->dy; + } + return c2; + } else { + return (Plot2D *) 0; + } +} + +/* ----------------------------------------------------------------------------- + Plot2D_clear(Plot2D *p2, Pixel c) + + Clear the region assigned to this plot to the given color. + -------------------------------------------------------------------------- */ + +void Plot2D_clear(Plot2D *p2, Pixel c) { + int i,j; + for (i = p2->view_xmin; i < p2->view_xmax; i++) + for (j = p2->view_ymin; j < p2->view_ymax; j++) { + p2->frame->pixels[j][i] = c; + } +} + +/* ------------------------------------------------------------------------------ + Plot2D_setview + + Sets the plot region on the framebuffer + ------------------------------------------------------------------------------ */ + +void +Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax) { + if (p2) { + p2->view_xmin = vxmin; + p2->view_ymin = vymin; + p2->view_xmax = vxmax; + p2->view_ymax = vymax; + p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); + p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); + FrameBuffer_setclip(p2->frame,vxmin,vymin,vxmax,vymax); + } +} + +/* ------------------------------------------------------------------------------- + Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax) + + Sets the plotting range. + ------------------------------------------------------------------------------- */ + +void +Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax) { + if (p2) { + p2->xmin = xmin; + p2->ymin = ymin; + p2->xmax = xmax; + p2->ymax = ymax; + p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); + p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); + } +} + +/* ------------------------------------------------------------------------------- + Plot2D_setscale(Plot2D *p2, int xscale, int yscale) + + Sets the plotting scaling method + ------------------------------------------------------------------------------- */ + +void +Plot2D_setscale(Plot2D *p2, int xscale, int yscale) { + if (p2) { + p2->xscale = xscale; + p2->yscale = yscale; + } +} + +/* ---------------------------------------------------------------------------- + Plot2D_transform(Plot2D *p2, double x, double y, int *px, int *py) + + Transforms x,y into screen coordinates px and py. Result is returned + in px and py. Rounds to the nearest pixel instead of truncating. + ----------------------------------------------------------------------------- */ + +void +Plot2D_transform(Plot2D *p2, double x, double y, int *px, int *py) { + if (p2) { + *px = p2->view_xmin + (int) (p2->dx*(x-p2->xmin) + 0.5); + *py = p2->view_ymin + (int) (p2->dy*(y-p2->ymin) + 0.5); + } +} + +/* ------------------------------------------------------------------------------- + Plot2D_plot(Plot2D *p2, double x, double y, Pixel color) + + Plot a 2D Point of a given color + ------------------------------------------------------------------------------- */ +void +Plot2D_plot(Plot2D *p2, double x, double y, Pixel color) { + int px, py; + + Plot2D_transform(p2,x,y,&px,&py); + FrameBuffer_plot(p2->frame, px, py, color); +} + +/* ------------------------------------------------------------------------------- + Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel Color) + + Plot an outline box on the 2D plot + ------------------------------------------------------------------------------- */ +void +Plot2D_box(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color) { + int ix1, ix2,iy1, iy2; + + Plot2D_transform(p2,x1,y1,&ix1,&iy1); + Plot2D_transform(p2,x2,y2,&ix2,&iy2); + FrameBuffer_box(p2->frame,ix1,iy1,ix2,iy2,color); +} + +/* ------------------------------------------------------------------------------- + Plot2D_solidbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel Color) + + Plot a solid box box on the 2D plot + ------------------------------------------------------------------------------- */ +void +Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color) { + int ix1, ix2,iy1, iy2; + + Plot2D_transform(p2,x1,y1,&ix1,&iy1); + Plot2D_transform(p2,x2,y2,&ix2,&iy2); + FrameBuffer_solidbox(p2->frame,ix1,iy1,ix2,iy2,color); +} + +/* ------------------------------------------------------------------------------- + Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, + Pixel c1, Pixel c2, Pixel c3, Pixel c4) + + Plot a color-interpolated box on the 2D plot + ------------------------------------------------------------------------------- */ +void +Plot2D_interpbox(Plot2D *p2, double x1, double y1,double x2, double y2, + Pixel c1, Pixel c2, Pixel c3, Pixel c4) { + int ix1, ix2,iy1, iy2; + + Plot2D_transform(p2,x1,y1,&ix1,&iy1); + Plot2D_transform(p2,x2,y2,&ix2,&iy2); + FrameBuffer_interpbox(p2->frame,ix1,iy1,ix2,iy2,c1,c2,c3,c4); +} + +/* ------------------------------------------------------------------------------- + Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color) + + Make an outline circle on the 2D plot. + ------------------------------------------------------------------------------- */ +void +Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color) { + int ix, iy, ir; + + Plot2D_transform(p2,x,y,&ix,&iy); + ir = p2->dx * radius; /* This is really incorrect. Will need ellipse */ + if (ir > 1) + FrameBuffer_circle(p2->frame,ix,iy,ir,color); + else + FrameBuffer_plot(p2->frame,ix,iy,color); + +} + +/* ------------------------------------------------------------------------------- + Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color) + + Make an solid circle on the 2D plot. + ------------------------------------------------------------------------------- */ +void +Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color) { + int ix, iy, ir; + + Plot2D_transform(p2,x,y,&ix,&iy); + ir = p2->dx * radius; /* This is really incorrect. Will need ellipse */ + if (ir > 1) + FrameBuffer_solidcircle(p2->frame,ix,iy,ir,color); + else + FrameBuffer_plot(p2->frame,ix,iy,color); +} + +/* ------------------------------------------------------------------------------- + Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color) + + Draw a line + ------------------------------------------------------------------------------- */ + +void +Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color) { + int ix1, ix2, iy1, iy2; + + Plot2D_transform(p2,x1,y1,&ix1,&iy1); + Plot2D_transform(p2,x2,y2,&ix2,&iy2); + FrameBuffer_line(p2->frame,ix1,iy1,ix2,iy2,color); +} + + + +/* ------------------------------------------------------------------------------- + Plot2D_start(Plot2D *p2) + + This should be called before starting to make a 2D plot. It will change + the viewport coordinates for the framebuffer and do other stuff. + ------------------------------------------------------------------------------- */ + +void Plot2D_start(Plot2D *p2) { + if (p2) { + FrameBuffer_setclip(p2->frame, p2->view_xmin,p2->view_ymin,p2->view_xmax, p2->view_ymax); + p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); + p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); + } +} + +/* -------------------------------------------------------------------------- + void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor) + + Draw a pixel map at the given coordinates. (Used for putting symbols on 2D + plots). + -------------------------------------------------------------------------- */ +void +Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor) { + int ix, iy; + + Plot2D_transform(p2,x,y,&ix,&iy); + FrameBuffer_drawpixmap(p2->frame,pm,ix,iy,color,bgcolor); +} + +/* ---------------------------------------------------------------------------- + void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel color) + + Draw an X axis bar at location x,y with ticks spaced every xtick units. + Ticks are spaced starting at "x" + ----------------------------------------------------------------------------- */ + +void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel color) { + int ix, iy,iy2; + double xt; + + /* Draw a line fox the axis */ + + Plot2D_line(p2,p2->xmin,y,p2->xmax,y,color); + xt = x; + while (xt >= p2->xmin) { + Plot2D_transform(p2,xt,y,&ix,&iy); + iy2 = iy+ticklength; + iy = iy-ticklength; + FrameBuffer_line(p2->frame,ix,iy,ix,iy2,color); + xt = xt - xtick; + } + xt = x + xtick; + while (xt < p2->xmax) { + Plot2D_transform(p2,xt,y,&ix,&iy); + iy2 = iy+ticklength; + iy = iy-ticklength; + FrameBuffer_line(p2->frame,ix,iy,ix,iy2,color); + xt = xt + xtick; + } +} + + +/* ---------------------------------------------------------------------------- + void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c) + + Draw an Y axis bar at location x,y with ticks spaced every xtick units. + Ticks are spaced starting at "y" + ----------------------------------------------------------------------------- */ + +void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel color) { + int ix, iy, ix2; + double yt; + + /* Draw a line fox the axis */ + + Plot2D_line(p2,x,p2->ymin,x,p2->ymax,color); + yt = y; + while (yt >= p2->ymin) { + Plot2D_transform(p2,x,yt,&ix,&iy); + ix2 = ix+ticklength; + ix = ix-ticklength; + FrameBuffer_line(p2->frame,ix,iy,ix2,iy,color); + yt = yt - ytick; + } + yt = y + ytick; + while (yt < p2->ymax) { + Plot2D_transform(p2,x,yt,&ix,&iy); + ix2 = ix+ticklength; + ix = ix-ticklength; + FrameBuffer_line(p2->frame,ix,iy,ix2,iy,color); + yt = yt + ytick; + } +} + + +/* ------------------------------------------------------------------------- + Plot2D_triangle(Plot2D *p2, double x1, double y1, + double x2, double y2, + double x3, double y3, + Pixel fillcolor) + + This function draws a 2D outline triangle. + -------------------------------------------------------------------------- */ + +void Plot2D_triangle(Plot2D *p2, double x1, double y1, + double x2, double y2, + double x3, double y3, Pixel color) { + + Plot2D_line(p2,x1,y1,x2,y2,color); + Plot2D_line(p2,x2,y2,x3,y3,color); + Plot2D_line(p2,x3,y3,x1,y1,color); + +} + + +/* ------------------------------------------------------------------------- + Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, + double x2, double y2, + double x3, double y3, + Pixel color) + + This function draws a 2D filled triangle. Can be used to + draw other primitives such as quadralaterals, etc... + + -------------------------------------------------------------------------- */ + +void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, + + double x2, double y2, + double x3, double y3, Pixel color) { + + int tx1, tx2, tx3, ty1, ty2, ty3; + + /* Transform the three points into screen coordinates */ + + Plot2D_transform(p2,x1,y1,&tx1,&ty1); + Plot2D_transform(p2,x2,y2,&tx2,&ty2); + Plot2D_transform(p2,x3,y3,&tx3,&ty3); + + FrameBuffer_solidtriangle(p2->frame,tx1,ty1,tx2,ty2,tx3,ty3,color); + +} + +/* ------------------------------------------------------------------------- + Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, + double x2, double y2, Pixel c2, + double x3, double y3, Pixel c3); + + This function draws a 2D filled triangle with color interpolation. + Can be used to draw other primitives such as quadralaterals, etc... + -------------------------------------------------------------------------- */ + +void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, + double x2, double y2, Pixel c2, + double x3, double y3, Pixel c3) { + + int tx1, tx2, tx3, ty1, ty2, ty3; + + /* Transform the three points into screen coordinates */ + + Plot2D_transform(p2,x1,y1,&tx1,&ty1); + Plot2D_transform(p2,x2,y2,&tx2,&ty2); + Plot2D_transform(p2,x3,y3,&tx3,&ty3); + + FrameBuffer_interptriangle(p2->frame,tx1,ty1,c1,tx2,ty2,c2,tx3,ty3,c3); + +} + + + diff --git a/Examples/GIFPlot/Lib/plot3d.c b/Examples/GIFPlot/Lib/plot3d.c new file mode 100644 index 0000000..387e420 --- /dev/null +++ b/Examples/GIFPlot/Lib/plot3d.c @@ -0,0 +1,2181 @@ +/* ----------------------------------------------------------------------------- + * plot3d.c + * + * Three-dimensional plotting. + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * Copyright (C) 1995-1996 + * + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#define PLOT3D +#include "gifplot.h" +#include +#include + +#define ORTHO 1 +#define PERSPECTIVE 2 +/* ------------------------------------------------------------------------ + Plot3D *new_Plot3D(FrameBuffer *f, double xmin, double ymin, double zmin, + double xmax, double ymax, double zmax) + + Creates a new 3D plot. Min and max coordinates are primarily used to + pick some default parameters. Returns NULL on failure + ------------------------------------------------------------------------- */ + +Plot3D *new_Plot3D(FrameBuffer *f, double xmin, double ymin, double zmin, + double xmax, double ymax, double zmax) { + + Plot3D *p3; + void Plot3D_maketransform(Plot3D *p3); + + /* Check to make sure the framebuffer and min/max parameters are valid */ + + if (!f) return (Plot3D *) 0; + if ((xmin > xmax) || (ymin > ymax) || (zmin > zmax)) return (Plot3D *) 0; + + p3 = (Plot3D *) malloc(sizeof(Plot3D)); + p3->frame = f; + p3->xmin = xmin; + p3->ymin = ymin; + p3->zmin = zmin; + p3->xmax = xmax; + p3->ymax = ymax; + p3->zmax = zmax; + + /* Set view region to the entire size of the framebuffer */ + + p3->view_xmin = 0; + p3->view_ymin = 0; + p3->view_xmax = f->width; + p3->view_ymax = f->height; + p3->width = f->width; + p3->height = f->height; + + /* Calculate a center point based off the min and max coordinates given */ + + p3->xcenter = (xmax - xmin)/2.0 + xmin; + p3->ycenter = (ymax - ymin)/2.0 + ymin; + p3->zcenter = (zmax - zmin)/2.0 + zmin; + + /* Calculate the aspect ratio of the viewing region */ + + p3->aspect = (double) f->width/(double) f->height; + + /* Set default view parameters */ + p3->xshift = 1.0; + p3->yshift = 1.0; + p3->zoom = 0.5; + p3->fovy = 40.0; /* 40 degree field of view */ + + /* Create matrices */ + + p3->model_mat = new_Matrix(); + p3->view_mat = new_Matrix(); + p3->center_mat = new_Matrix(); + p3->fullmodel_mat = new_Matrix(); + p3->trans_mat = new_Matrix(); + p3->pers_mode = ORTHO; + + FrameBuffer_zresize(p3->frame,p3->width, p3->height); + Matrix_identity(p3->view_mat); + Matrix_identity(p3->model_mat); + Matrix_translate(p3->center_mat, -p3->xcenter,-p3->ycenter,-p3->zcenter); + Plot3D_maketransform(p3); + return p3; +} + +/* --------------------------------------------------------------------- + delete_Plot3D(Plot3D *p3) + + Deletes a 3D plot + --------------------------------------------------------------------- */ + +void delete_Plot3D(Plot3D *p3) { + if (p3) { + delete_Matrix(p3->view_mat); + delete_Matrix(p3->model_mat); + delete_Matrix(p3->trans_mat); + free((char *) p3); + } +} + +/* --------------------------------------------------------------------- + Plot3D *Plot3D_copy(Plot3D *p3) + + This makes a copy of the 3D plot structure and returns a pointer to it. + --------------------------------------------------------------------- */ + +Plot3D *Plot3D_copy(Plot3D *p3) { + Plot3D *c3; + if (p3) { + c3 = (Plot3D *) malloc(sizeof(Plot3D)); + if (c3) { + c3->frame = p3->frame; + c3->view_xmin = p3->view_xmin; + c3->view_ymin = p3->view_ymin; + c3->view_xmax = p3->view_xmax; + c3->view_ymax = p3->view_ymax; + c3->xmin = p3->xmin; + c3->ymin = p3->ymin; + c3->zmin = p3->zmin; + c3->xmax = p3->xmax; + c3->ymax = p3->ymax; + c3->zmax = p3->zmax; + c3->xcenter = p3->xcenter; + c3->ycenter = p3->ycenter; + c3->zcenter = p3->zcenter; + c3->fovy = p3->fovy; + c3->aspect = p3->aspect; + c3->znear = p3->znear; + c3->zfar = p3->zfar; + c3->center_mat = Matrix_copy(p3->center_mat); + c3->model_mat = Matrix_copy(p3->model_mat); + c3->view_mat = Matrix_copy(p3->view_mat); + c3->fullmodel_mat = Matrix_copy(p3->fullmodel_mat); + c3->trans_mat = Matrix_copy(p3->trans_mat); + c3->lookatz = p3->lookatz; + c3->xshift = p3->xshift; + c3->yshift = p3->yshift; + c3->zoom = p3->zoom; + c3->width = p3->width; + c3->height = p3->height; + c3->pers_mode = p3->pers_mode; + } + return c3; + } else { + return (Plot3D *) 0; + } +} + +/* ---------------------------------------------------------------------- + Plot3D_clear(Plot3D *p3, Pixel bgcolor) + + Clear the pixel and zbuffer only for the view region of this image. + ---------------------------------------------------------------------- */ +void +Plot3D_clear(Plot3D *p3, Pixel bgcolor) { + int i,j; + + for (i = p3->view_xmin; i < p3->view_xmax; i++) + for (j = p3->view_ymin; j < p3->view_ymax; j++) { + p3->frame->pixels[j][i] = bgcolor; + p3->frame->zbuffer[j][i] = ZMIN; + } +} + +/* --------------------------------------------------------------------- + Plot3D_maketransform(Plot3D *p3) + + This function builds the total 3D transformation matrix from a + collection of components. + + Trans = View * Rotation * Center + + Where View is the viewing transformation matrix, Rotation is the + model rotation matrix, Center is the translation matrix used to + center the Model at the origin. + --------------------------------------------------------------------- */ + +void +Plot3D_maketransform(Plot3D *p3) { + + Matrix_multiply(p3->model_mat,p3->center_mat, p3->fullmodel_mat); + Matrix_multiply(p3->view_mat,p3->fullmodel_mat, p3->trans_mat); +} + +/* --------------------------------------------------------------------- + Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar) + + Sets up the perspective viewing transformation. Assumes "lookat" + has already been called. + --------------------------------------------------------------------- */ + +void +Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar) { + double theta; + double mat[16]; + + p3->fovy = fovy; + p3->znear = znear; + p3->zfar = zfar; + + theta = 3.1415926*fovy/180.0; + + Matrix_identity(mat); + mat[0] = cos(theta/2.0)/(sin(theta/2.0)*p3->aspect); + mat[5] = cos(theta/2.0)/(sin(theta/2.0)); + mat[10] = -(zfar + znear)/(zfar-znear); + mat[14] = -1.0; + mat[11] = -(2*zfar*znear)/(zfar - znear); + mat[15] = 0.0; + + /* Update the view transformation matrix */ + + Matrix_multiply(mat,p3->view_mat,p3->view_mat); + + /* Update the global transformation matrix */ + + Plot3D_maketransform(p3); + p3->pers_mode = PERSPECTIVE; + +} + +/* --------------------------------------------------------------------- + Plot3D_lookat(Plot3D *p3, double z) + + A greatly simplified version of (lookat). Specifies the position + of the viewpoint. (can be used for moving image in or out). + + Destroys the current viewing transformation matrix, so it will have + to be recalculated. + --------------------------------------------------------------------- */ + +void +Plot3D_lookat(Plot3D *p3, double z) { + if (p3) { + Matrix_translate(p3->view_mat, 0,0,-z); + p3->lookatz = z; + Plot3D_maketransform(p3); + } +} + +/* ------------------------------------------------------------------------- + Plot3D_autoperspective(Plot3D *p3, double fovy) + + Automatically figures out a semi-decent viewpoint given the + min,max parameters currently set for this image + ------------------------------------------------------------------------- */ + +void +Plot3D_autoperspective(Plot3D *p3, double fovy) { + + /* Make a perspective transformation matrix for this system */ + + double zfar; + double znear; + double d, dmax; + double cx,cy,cz; + double xmin,xmax,ymin,ymax,zmin,zmax; + + xmin = p3->xmin; + ymin = p3->ymin; + zmin = p3->zmin; + xmax = p3->xmax; + ymax = p3->ymax; + zmax = p3->zmax; + cx = p3->xcenter; + cy = p3->ycenter; + cz = p3->zcenter; + + /* Calculate longest point from center point */ + + dmax = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); + d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); + if (d > dmax) dmax = d; + d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); + if (d > dmax) dmax = d; + d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); + if (d > dmax) dmax = d; + d = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + + dmax = sqrt(dmax); + d = p3->lookatz; + + znear = d - dmax; + zfar = znear+1.5*dmax; + Plot3D_perspective(p3, fovy,znear,zfar); + +} + + +/* --------------------------------------------------------------------- + Plot3D_ortho(Plot3D *p3, double left, double right, double bottom, double top) + + Sets up an orthographic viewing transformation. + --------------------------------------------------------------------- */ + +void +Plot3D_ortho(Plot3D *p3, double left, double right, double bottom, double top) { + + + Matrix_identity(p3->view_mat); + p3->view_mat[0] = (2.0/(right - left))/p3->aspect; + p3->view_mat[5] = 2.0/(top - bottom); + p3->view_mat[10] = -1; + p3->view_mat[15] = 1.0; + p3->view_mat[3] = -(right+left)/(right-left); + p3->view_mat[7] = -(top+bottom)/(top-bottom); + + /* Update the global transformation matrix */ + + Plot3D_maketransform(p3); + p3->pers_mode = ORTHO; + p3->ortho_left = left; + p3->ortho_right = right; + p3->ortho_bottom = bottom; + p3->ortho_top = top; + +} + +/* --------------------------------------------------------------------- + Plot3D_autoortho(Plot3D *p3) + + Automatically pick an orthographic projection that's probably + pretty good. + --------------------------------------------------------------------- */ + +void +Plot3D_autoortho(Plot3D *p3) { + + /* Make a perspective transformation matrix for this system */ + + double d, dmax; + double cx,cy,cz; + double xmin,xmax,ymin,ymax,zmin,zmax; + + xmin = p3->xmin; + ymin = p3->ymin; + zmin = p3->zmin; + xmax = p3->xmax; + ymax = p3->ymax; + zmax = p3->zmax; + cx = p3->xcenter; + cy = p3->ycenter; + cz = p3->zcenter; + + /* Calculate longest point from center point */ + + dmax = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); + d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); + if (d > dmax) dmax = d; + d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); + if (d > dmax) dmax = d; + d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); + if (d > dmax) dmax = d; + d = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); + if (d > dmax) dmax = d; + + dmax = sqrt(dmax); + + Plot3D_ortho(p3,-dmax,dmax,-dmax,dmax); + +} + + + +/* ------------------------------------------------------------------------- + Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax) + + Sets the viewport for this 3D graph. Will recalculate all of the + local viewing transformation matrices accordingly. + ------------------------------------------------------------------------- */ +void +Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax) { + if (p3) { + if ((vxmin > vxmax) || (vymin >vymax)) return; + p3->view_xmin = vxmin; + p3->view_ymin = vymin; + p3->view_xmax = vxmax; + p3->view_ymax = vymax; + p3->width = (vxmax - vxmin); + p3->height = (vymax - vymin); + p3->aspect = (double) p3->width/(double) p3->height; + + /* Fix up the viewing transformation matrix */ + + if (p3->pers_mode == PERSPECTIVE) { + Plot3D_lookat(p3,p3->lookatz); + Plot3D_perspective(p3,p3->fovy,p3->znear,p3->zfar); + } else { + Plot3D_ortho(p3,p3->ortho_left,p3->ortho_right,p3->ortho_bottom, p3->ortho_top); + } + FrameBuffer_setclip(p3->frame,vxmin,vymin,vxmax,vymax); + } +} + +/* --------------------------------------------------------------------------- + Plot2D_start(Plot2D *p3) + + Set up viewing region and other parameters for this image. + --------------------------------------------------------------------------- */ + +void +Plot3D_start(Plot3D *p3) { + if (p3) + FrameBuffer_setclip(p3->frame, p3->view_xmin,p3->view_ymin,p3->view_xmax, p3->view_ymax); + +} + +/* ------------------------------------------------------------------------- + Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color) + + Plot a 3D point + ------------------------------------------------------------------------- */ + +void +Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel color) { + + GL_Vector t; + int ix, iy; + double invw; + FrameBuffer *f; + + /* Perform a transformation */ + + Matrix_transform4(p3->trans_mat,x,y,z,1,&t); + + /* Scale the coordinates into unit cube */ + + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; +#ifdef GL_DEBUG + fprintf(stdout,"t.x = %g, t.y = %g, t.z = %g\n", t.x,t.y,t.z); +#endif + /* Calculate the x and y coordinates */ + + ix = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5); + iy = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5); + + if ((ix >= 0) && (ix < p3->width) && + (iy >= 0) && (ix < p3->height)) { + ix += p3->view_xmin; + iy += p3->view_ymin; + f = p3->frame; + if (t.z <= f->zbuffer[iy][ix]) { + f->pixels[iy][ix] = color; + f->zbuffer[iy][ix] = t.z; + } + } +} + +/* ---------------------------------------------------------------------- + Plot3D_rotx(Plot3D *p3, double deg) + + Rotate the model around its x axis. + ---------------------------------------------------------------------- */ + +void +Plot3D_rotx(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatex(temp,deg); /* Construct a x rotation matrix */ + Matrix_multiply(p3->model_mat,temp,p3->model_mat); + Plot3D_maketransform(p3); + +} + +/* ---------------------------------------------------------------------- + Plot3D_roty(Plot3D *p3, double deg) + + Rotate the model around its y axis. + ---------------------------------------------------------------------- */ + +void +Plot3D_roty(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatey(temp,deg); /* Construct a y rotation matrix */ + Matrix_multiply(p3->model_mat,temp,p3->model_mat); + Plot3D_maketransform(p3); + +} + +/* ---------------------------------------------------------------------- + Plot3D_rotz(Plot3D *p3, double deg) + + Rotate the model around its z axis. + ---------------------------------------------------------------------- */ + +void +Plot3D_rotz(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatez(temp,deg); /* Construct a z rotation matrix */ + Matrix_multiply(p3->model_mat,temp,p3->model_mat); + Plot3D_maketransform(p3); + +} + + +/* ---------------------------------------------------------------------- + Plot3D_rotd(Plot3D *p3, double deg) + + Rotate the model down + ---------------------------------------------------------------------- */ + +void +Plot3D_rotd(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatex(temp,deg); /* Construct a x rotation matrix */ + Matrix_multiply(temp, p3->model_mat,p3->model_mat); + Plot3D_maketransform(p3); + +} + + +/* ---------------------------------------------------------------------- + Plot3D_rotu(Plot3D *p3, double deg) + + Rotate the model up + ---------------------------------------------------------------------- */ + +void +Plot3D_rotu(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatex(temp,-deg); /* Construct a x rotation matrix */ + Matrix_multiply(temp,p3->model_mat,p3->model_mat); + Plot3D_maketransform(p3); + +} + + +/* ---------------------------------------------------------------------- + Plot3D_rotr(Plot3D *p3, double deg) + + Rotate the model down + ---------------------------------------------------------------------- */ + +void +Plot3D_rotr(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatey(temp,deg); /* Construct a y rotation matrix */ + Matrix_multiply(temp, p3->model_mat,p3->model_mat); + Plot3D_maketransform(p3); + +} + + +/* ---------------------------------------------------------------------- + Plot3D_rotl(Plot3D *p3, double deg) + + Rotate the model left + ---------------------------------------------------------------------- */ + +void +Plot3D_rotl(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatey(temp,-deg); /* Construct a y rotation matrix */ + Matrix_multiply(temp,p3->model_mat,p3->model_mat); + Plot3D_maketransform(p3); + +} + + +/* ---------------------------------------------------------------------- + Plot3D_rotc(Plot3D *p3, double deg) + + Rotate the model around center point + ---------------------------------------------------------------------- */ + +void +Plot3D_rotc(Plot3D *p3, double deg) { + double temp[16]; + + Matrix_rotatez(temp,-deg); /* Construct a z rotation matrix */ + Matrix_multiply(temp,p3->model_mat,p3->model_mat); + Plot3D_maketransform(p3); +} + +/* ------------------------------------------------------------------------- + Plot3D_zoom(Plot3D *p3, double percent) + + Zooms in or out the current image. percent defines a percentage of + zoom. + + Zooming is actually done by adjusting the perspective field of view + instead of scaling the model or moving in the viewpoint. This + seems to work the best. + ------------------------------------------------------------------------- */ + +void +Plot3D_zoom(Plot3D *p3, double percent) { + + double scale; + double dx; + if (percent <= 0) return; + scale = percent/100.0; + + dx = (1.0/scale - 1.0)/(2*p3->zoom); /* Don't even ask where this came from */ + p3->xshift += dx; + p3->yshift += dx; + p3->zoom = p3->zoom*scale; + +#ifdef OLD + p3->fovy = p3->fovy*scale; + if (p3->fovy > 170.0) p3->fovy = 170.0; + if (p3->fovy == 0) p3->fovy = 0.0001; + Plot3D_lookat(p3,p3->lookatz); + Plot3D_perspective(p3,p3->fovy,p3->znear,p3->zfar); +#endif +} + +/* -------------------------------------------------------------------------- + Plot3D_left(Plot3D *p3, double s) + + Shifts the image to the left by s units. This is a little funky. + + s is scaled so that s = 100 equals one full screen. + -------------------------------------------------------------------------- */ +void +Plot3D_left(Plot3D *p3, double s) { + p3->xshift -= (s/100.0)/p3->zoom; +} + +/* -------------------------------------------------------------------------- + Plot3D_right(Plot3D *p3, double s) + + Shifts the image to the right by s units. + + s is scaled so that s = 100 equals one full screen. + -------------------------------------------------------------------------- */ +void +Plot3D_right(Plot3D *p3, double s) { + p3->xshift += (s/100.0)/p3->zoom; +} + +/* -------------------------------------------------------------------------- + Plot3D_up(Plot3D *p3, double s) + + Shifts the image up left by s units. + + s is scaled so that s = 100 equals one full screen. + -------------------------------------------------------------------------- */ +void +Plot3D_up(Plot3D *p3, double s) { + p3->yshift += (s/100.0)/p3->zoom; +} + +/* -------------------------------------------------------------------------- + Plot3D_down(Plot3D *p3, double s) + + Shifts the image down by s units. + + s is scaled so that s = 100 equals one full screen. + -------------------------------------------------------------------------- */ +void +Plot3D_down(Plot3D *p3, double s) { + p3->yshift -= (s/100.0)/p3->zoom; +} + +/* ------------------------------------------------------------------------- + Plot3D_center(Plot3D *p3, double cx, double cy) + + Centers the image on a point in the range (0,0) - (100,100) + ------------------------------------------------------------------------- */ +void +Plot3D_center(Plot3D *p3, double cx, double cy) { + Plot3D_left(p3,cx-50); + Plot3D_down(p3,cy-50); +} + + + +/*************************************************************************** + * 3d Primitives * + ***************************************************************************/ + +/* ------------------------------------------------------------------------- + Plot3D_horizontal(Plot3D *p3, int xmin, int xmax, int y, double z1, double z2, Pixel color) + + Draws a "Horizontal" line on the framebuffer between two screen coordinates, + but also supplies z-values and zbuffering. This function probably isn't + too useful by itself, but will be used by a number of other primitives. + -------------------------------------------------------------------------- */ + +void Plot3D_horizontal(Plot3D *p3, int xmin, int xmax, int y, Zvalue z1, Zvalue z2, Pixel color) { + Pixel *p; + FrameBuffer *f; + int i; + Zvalue *zbuf,z,mz; + int startx, endx; + + f = p3->frame; + if ((y < f->ymin) || (y >= f->ymax)) return; + if (xmin > f->xmax) return; + if (xmin < f->xmin) startx = f->xmin; + else startx = xmin; + if (xmax < f->xmin) return; + if (xmax >= f->xmax) endx = f->xmax - 1; + else endx = xmax; + + /* Calculate z slope */ + + if (xmax != xmin) { + mz = (Zvalue) ((double) (z2 - z1)/(double) (xmax - xmin)); + } else { + mz = 0; + } + + /* Draw it */ + + p = &f->pixels[y][startx]; + zbuf = &f->zbuffer[y][startx]; + z = (Zvalue) (mz*(startx-xmin) + z1); + for (i = startx; i <= endx; i++, p++, zbuf++,z+=mz) { + if (z <= *zbuf) { + *p = color; + *zbuf = z; + } + } +} + + +/* ------------------------------------------------------------------------- + Plot3D_vertical(Plot3D *p3, int ymin, int ymax, int x, double z1, double z2, Pixel color) + + Draws a "Vertical" line on the framebuffer between two screen coordinates, + but also supplies z-values and zbuffering. This function probably isn't + too useful by itself, but will be used by a number of other primitives. + -------------------------------------------------------------------------- */ + +void Plot3D_vertical(Plot3D *p3, int ymin, int ymax, int x, Zvalue z1, Zvalue z2, Pixel color) { + Pixel *p; + FrameBuffer *f; + int i; + Zvalue *zbuf,z,mz; + int starty, endy; + + f = p3->frame; + if ((x < f->xmin) || (x >= f->xmax)) return; + if (ymin >= f->ymax) return; + if (ymin < f->ymin) starty = f->ymin; + else starty = ymin; + if (ymax < f->ymin) return; + if (ymax >= f->ymax) endy = f->ymax - 1; + else endy = ymax; + + /* Calculate z slope */ + + mz = (double) (z2 - z1)/(double) (ymax - ymin); + + /* Draw it */ + + p = &f->pixels[starty][x]; + zbuf = &f->zbuffer[starty][x]; + for (i = starty; i <= endy; i++, p+=f->width, zbuf+=f->width) { + z = (Zvalue) (mz*(i-ymin) + z1); + if (z <= *zbuf) { + *p = color; + *zbuf = z; + } + } +} + +/* ------------------------------------------------------------------------------- + Plot3D_linetransform(Plot3D *p3, int x1, int y1, Zvalue z1, + int x2, int y2, Zvalue z2, Pixel c) + + Draw a 3D line between points that have already been transformed into + 3D space. + + Uses a Bresenham line algorithm, but with linear interpolation between + Zvalues. + ------------------------------------------------------------------------------- */ + +void +Plot3D_linetransform(Plot3D *p3, int x1, int y1, Zvalue z1, int x2, int y2, Zvalue z2, Pixel c) { + + int orig_x1, orig_y1, orig_x2,orig_y2; + Zvalue zt; + + /* Bresenham line drawing parameters */ + FrameBuffer *f; + int dx,dy,dxneg,dyneg, inc1,inc2,di; + int x, y, xpixels, ypixels, xt, yt; + Pixel *p; + double m; + int end1 = 0, end2 = 0; + Zvalue *zbuf,mz,z; + + f = p3->frame; + + /* Need to figure out where in the heck this line is */ + + dx = x2 - x1; + dy = y2 - y1; + + if ((dx == 0) && (dy == 0)) { + if ((x1 < f->xmin) || (x1 >= f->xmax) || + (y1 < f->ymin) || (y1 >= f->ymax)) return; + if (z1 <= f->zbuffer[y1][x1]) { + f->pixels[y1][x1] = c; + } + return; + } + if (dx == 0) { + /* Draw a Vertical Line */ + if (y1 < y2) + Plot3D_vertical(p3,y1,y2,x1,z1,z2,c); + else + Plot3D_vertical(p3,y2,y1,x1,z2,z1,c); + return; + } + if (dy == 0) { + /* Draw a Horizontal Line */ + if (x1 < x2) + Plot3D_horizontal(p3,x1,x2,y1,z1,z2,c); + else + Plot3D_horizontal(p3,x2,x1,y1,z2,z1,c); + return; + } + + /* Figure out where in the heck these lines are using the + Cohen-Sutherland Line Clipping Scheme. */ + + end1 = ((x1 - f->xmin) < 0) | + (((f->xmax- 1 - x1) < 0) << 1) | + (((y1 - f->ymin) < 0) << 2) | + (((f->ymax-1 - y1) < 0) << 3); + + end2 = ((x2 - f->xmin) < 0) | + (((f->xmax-1 - x2) < 0) << 1) | + (((y2 - f->ymin) < 0) << 2) | + (((f->ymax-1 - y2) < 0) << 3); + + if (end1 & end2) return; /* Nope : Not visible */ + + /* Make sure points have a favorable orientation */ + + if (x1 > x2) { + xt = x1; + x1 = x2; + x2 = xt; + yt = y1; + y1 = y2; + y2 = yt; + zt = z1; + z1 = z2; + z2 = zt; + } + + /* Save original points before we clip them off */ + orig_x1 = x1; + orig_y1 = y1; + orig_x2 = x2; + orig_y2 = y2; + + /* Clip against the boundaries */ + m = (y2 - y1)/(double) (x2-x1); + if (x1 < f->xmin) { + y1 = (f->xmin - x1)*m + y1; + x1 = f->xmin; + } + if (x2 >= f->xmax) { + y2 = (f->xmax -1 -x1)*m + y1; + x2 = f->xmax - 1; + } + + if (y1 > y2) { + xt = x1; + x1 = x2; + x2 = xt; + yt = y1; + y1 = y2; + y2 = yt; + zt = z1; + z1 = z2; + z2 = zt; + + /* Swap original points */ + + xt = orig_x1; + orig_x1 = orig_x2; + orig_x2 = xt; + yt = orig_y1; + orig_y1 = orig_y2; + orig_y2 = yt; + } + + m = 1/m; + if (y1 < f->ymin) { + x1 = (f->ymin - y1)*m + x1; + y1 = f->ymin; + } + if (y2 >= f->ymax) { + x2 = (f->ymax-1-y1)*m + x1; + y2 = f->ymax-1; + } + + if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax) || + (x2 < f->xmin) || (x2 >= f->xmax) || (y2 < f->ymin) || (y2 >= f->ymax)) return; + + dx = x2 - x1; + dy = y2 - y1; + xpixels = f->width; + ypixels = f->height; + + dxneg = (dx < 0) ? 1 : 0; + dyneg = (dy < 0) ? 1 : 0; + + dx = abs(dx); + dy = abs(dy); + if (dx >= dy) { + /* Slope between -1 and 1. */ + mz = (z2 - z1)/(orig_x2 - orig_x1); /* Z interpolation slope */ + if (dxneg) { + x = x1; + y = y1; + x1 = x2; + y1 = y2; + x2 = x; + y2 = y; + dyneg = !dyneg; + } + inc1 = 2*dy; + inc2 = 2*(dy-dx); + di = 2*dy-dx; + + /* Draw a line using x as independent variable */ + + p = &f->pixels[y1][x1]; + zbuf = &f->zbuffer[y1][x1]; + x = x1; + while (x <= x2) { + /* Do a z-buffer check */ + z = mz*(x-orig_x1)+z1; + if (z <= *zbuf){ + *p = c; + *zbuf = z; + } + p++; + zbuf++; + if (di < 0) { + di = di + inc1; + } else { + if (dyneg) { + p = p - xpixels; + zbuf = zbuf - xpixels; + di = di + inc2; + } else { + p = p + xpixels; + zbuf = zbuf + xpixels; + di = di + inc2; + } + } + x++; + } + } else { + /* Slope < -1 or > 1 */ + mz = (z2 - z1)/(double) (orig_y2 - orig_y1); + if (dyneg) { + x = x1; + y = y1; + x1 = x2; + y1 = y2; + x2 = x; + y2 = y; + dxneg = !dxneg; + } + inc1 = 2*dx; + inc2 = 2*(dx-dy); + di = 2*dx-dy; + + /* Draw a line using y as independent variable */ + + p = &f->pixels[y1][x1]; + zbuf = &f->zbuffer[y1][x1]; + y = y1; + while (y <= y2) { + /* Do a z-buffer check */ + z = mz*(y-orig_y1)+z1; + if (z <= *zbuf) { + *p = c; + *zbuf = z; + } + p = p + xpixels; + zbuf = zbuf + xpixels; + if (di < 0) { + di = di + inc1; + } else { + if (dxneg) { + p = p - 1; + zbuf = zbuf - 1; + di = di + inc2; + } else { + p = p + 1; + zbuf = zbuf + 1; + di = di + inc2; + } + } + y++; + } + } +} + +/* --------------------------------------------------------------------------- + Plot3D_line(Plot3D *p3, double x1, double y1, double z1, double x2, double y2, double z2,int color) + + Draws a line in 3D space. This is done as follows (for lack of a better + method). + + 1. The points (x1,y1,z1) and (x2,y2,z2) are transformed into screen coordinates + 2. We draw the line using a modified Bresenham line algorithm. + 3. Zbuffer values are linearly interpolated between the two points. + ---------------------------------------------------------------------------- */ + +void +Plot3D_line(Plot3D *p3, double fx1, double fy1, double fz1, double fx2, double fy2, + double fz2, Pixel c) { + + /* 3D Transformation parameters */ + GL_Vector t; + double invw; + int x1,y1,x2,y2; + Zvalue z1,z2; + + /* Transform the two points into screen coordinates */ + + Matrix_transform4(p3->trans_mat,fx1,fy1,fz1,1,&t); /* Point 1 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + x1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + y1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + z1 = t.z; + + Matrix_transform4(p3->trans_mat,fx2,fy2,fz2,1,&t); /* Point 2 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + x2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + y2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + z2 = t.z; + Plot3D_linetransform(p3,x1,y1,z1,x2,y2,z2,c); +} + + +/* ------------------------------------------------------------------------- + Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + Pixel fillcolor) + + This function draws a 3D z-buffered outline triangle. + -------------------------------------------------------------------------- */ + +void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, Pixel color) { + + int tx1, tx2, tx3, ty1, ty2, ty3; + Zvalue tz1, tz2, tz3; + GL_Vector t; + double invw; + + /* Transform the three points into screen coordinates */ + + Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz1 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz2 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz3 = (Zvalue) t.z; + + + Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); + Plot3D_linetransform(p3,tx1,ty1,tz1,tx3,ty3,tz3,color); + Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); +} + + +/* ------------------------------------------------------------------------- + Plot3D_solidtriangletransform(Plot3D *p3, int tx1, int ty2, Zvalue tz1, + int tx2, int ty2, Zvalue tz2, + int tx3, int ty3, Zvalue tz3, Pixel color) + + This function draws a 3D z-buffered filled triangle. Assumes three + points have already been transformed into screen coordinates. + + General idea : + 1. Transform the three points into screen coordinates + 2. Order three points vertically on screen. + 3. Check for degenerate cases (where 3 points are colinear). + 4. Fill in the resulting triangle using horizontal lines. + -------------------------------------------------------------------------- */ + +void Plot3D_solidtriangletransform(Plot3D *p3, int tx1, int ty1, Zvalue tz1, + int tx2, int ty2, Zvalue tz2, + int tx3, int ty3, Zvalue tz3, Pixel color) { + int tempx, tempy; + Zvalue tempz; + double m1,m2,m3, mz1, mz2, mz3; + int y; + int ix1, ix2; + Zvalue zz1, zz2; + FrameBuffer *f; + register double fy1,fy2; + register Zvalue fz1,fz2; + + f = p3->frame; + + /* Check for degenerate cases here */ + + if ((ty1 == ty2) && (ty2 == ty3)) { + if (tx2 < tx1) { /* Swap points 1 and 2 if 2 is higher */ + tempx = tx1; + tempz = tz1; + tx1 = tx2; + tz1 = tz2; + tx2 = tempx; + tz2 = tempz; + } + if (tx3 < tx1) { /* Swap points 1 and 3 if 3 is higher */ + tempx = tx1; + tempz = tz1; + tx1 = tx3; + tz1 = tz3; + tx3 = tempx; + tz3 = tempz; + } + if (tx3 < tx2) { /* Swap points 2 and 3 if 3 is higher */ + tempx = tx2; + tempz = tz2; + tx2 = tx3; + tz2 = tz3; + tx3 = tempx; + tz3 = tempz; + } + + /* Points are aligned horizontally. Handle as a special case */ + /* Just draw three lines using the outline color */ + + Plot3D_horizontal(p3,tx1,tx2,ty1,tz1,tz3,color); + + /* Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); + Plot3D_linetransform(p3,tx1,ty1,tz1,tx3,ty3,tz3,color); + Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); + */ + + return; + } + + /* Figure out which point has the greatest "y" value */ + + if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ + tempx = tx1; + tempy = ty1; + tempz = tz1; + tx1 = tx2; + ty1 = ty2; + tz1 = tz2; + tx2 = tempx; + ty2 = tempy; + tz2 = tempz; + } + if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ + tempx = tx1; + tempy = ty1; + tempz = tz1; + tx1 = tx3; + ty1 = ty3; + tz1 = tz3; + tx3 = tempx; + ty3 = tempy; + tz3 = tempz; + } + if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ + tempx = tx2; + tempy = ty2; + tempz = tz2; + tx2 = tx3; + ty2 = ty3; + tz2 = tz3; + tx3 = tempx; + ty3 = tempy; + tz3 = tempz; + } + + /* Points are now order so that t_1 is the highest point, t_2 is the + middle point, and t_3 is the lowest point */ + + if (ty2 < ty1) { + /* First process line segments between (x1,y1)-(x2,y2) + And between (x1,y1),(x3,y3) */ + + m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + mz1 = (tz2 - tz1)/(double) (ty2 - ty1); + mz2 = (tz3 - tz1)/(double) (ty3 - ty1); + + y = ty1; + fy1 = m1*(y-ty1)+0.5 + tx1; + fy2 = m2*(y-ty1)+0.5 + tx1; + fz1 = mz1*(y-ty1) + tz1; + fz2 = mz2*(y-ty1) + tz1; + while (y >= ty2) { + /* Replace with bresenham scheme */ + /* Calculate x values from slope */ + ix1 = (int) fy1; + ix2 = (int) fy2; + zz1 = fz1; + zz2 = fz2; + fy1-= m1; + fy2-= m2; + fz1-= mz1; + fz2-= mz2; + if (ix1 > ix2) + Plot3D_horizontal(p3,ix2,ix1,y,zz2,zz1,color); + else + Plot3D_horizontal(p3,ix1,ix2,y,zz1,zz2,color); + y--; + } + } + if (ty3 < ty2) { + /* Draw lower half of the triangle */ + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); + mz2 = (tz3 - tz1)/(double) (ty3 - ty1); + mz3 = (tz3 - tz2)/(double) (ty3 - ty2); + y = ty2; + while (y >= ty3) { + ix1 = (int) (m3*(y-ty2)+0.5)+tx2; + ix2 = (int) (m2*(y-ty1)+0.5)+tx1; + zz1 = mz3*(y-ty2)+tz2; + zz2 = mz2*(y-ty1)+tz1; + if (ix1 > ix2) + Plot3D_horizontal(p3,ix2,ix1,y,zz2,zz1,color); + else + Plot3D_horizontal(p3,ix1,ix2,y,zz1,zz2,color); + y--; + } + } +} + +/* ------------------------------------------------------------------------- + Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + Pixel color) + + This function draws a 3D z-buffered filled triangle. Can be used to + draw other primitives such as quadralaterals, etc... + + This function simply transforms the given points and calls + Plot3D_SolidTriangleTransform(). + -------------------------------------------------------------------------- */ + +void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, Pixel color) { + + int tx1, tx2, tx3, ty1, ty2, ty3; + Zvalue tz1, tz2, tz3; + GL_Vector t; + double invw; + Matrix a; + register double xshift, yshift, zoom, width, height, view_xmin, view_ymin; + + a = p3->trans_mat; + xshift = p3->xshift; + yshift = p3->yshift; + zoom = p3->zoom; + height = p3->height; + width = p3->width; + view_xmin = p3->view_xmin; + view_ymin = p3->view_ymin; + + /* Transform the three points into screen coordinates */ + + t.w = a[12]*x1 + a[13]*y1 + a[14]*z1 + a[15]; + invw = 1.0/t.w; + t.x = (a[0]*x1 + a[1]*y1 + a[2]*z1 + a[3])*invw; + t.y = (a[4]*x1 + a[5]*y1 + a[6]*z1 + a[7])*invw; + t.z = (a[8]*x1 + a[9]*y1 + a[10]*z1 + a[11])*invw; + + tx1 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; + ty1 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; + tz1 = (Zvalue) t.z; + + + t.w = a[12]*x2 + a[13]*y2 + a[14]*z2 + a[15]; + invw = 1.0/t.w; + t.x = (a[0]*x2 + a[1]*y2 + a[2]*z2 + a[3])*invw; + t.y = (a[4]*x2 + a[5]*y2 + a[6]*z2 + a[7])*invw; + t.z = (a[8]*x2 + a[9]*y2 + a[10]*z2 + a[11])*invw; + tx2 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; + ty2 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; + tz2 = (Zvalue) t.z; + + t.w = a[12]*x3 + a[13]*y3 + a[14]*z3 + a[15]; + invw = 1.0/t.w; + t.x = (a[0]*x3 + a[1]*y3 + a[2]*z3 + a[3])*invw; + t.y = (a[4]*x3 + a[5]*y3 + a[6]*z3 + a[7])*invw; + t.z = (a[8]*x3 + a[9]*y3 + a[10]*z3 + a[11])*invw; + tx3 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; + ty3 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; + tz3 = (Zvalue) t.z; + + Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,tx3,ty3,tz3,color); + +} + + +/* ------------------------------------------------------------------------- + Plot3D_horizontalinterp(Plot3D *p3, int xmin, int xmax, int y, + double z1, double z2, Pixel c1, Pixel c2) + + Draws a "Horizontal" line on the framebuffer between two screen coordinates, + but also supplies z-values and zbuffering. Performs a color interpolation + between c1 and c2. This is primarily used by the SolidTriangleInterp() + function to give the illusion of smooth surfaces. + -------------------------------------------------------------------------- */ + +void Plot3D_horizontalinterp(Plot3D *p3, int xmin, int xmax, int y, + Zvalue z1, Zvalue z2, Pixel c1, Pixel c2) { + Pixel *p; + FrameBuffer *f; + int i; + Zvalue *zbuf,z,mz; + double mc; + int startx, endx; + double invdx; + + f = p3->frame; + if ((y < f->ymin) || (y >= f->ymax)) return; + if (xmin >= f->xmax) return; + if (xmin < f->xmin) startx = f->xmin; + else startx = xmin; + if (xmax < f->xmin) return; + if (xmax >= f->xmax) endx = f->xmax - 1; + else endx = xmax; + + /* Calculate z slope */ + if (xmax != xmin) { + invdx = 1.0/(double) (xmax-xmin); + } else { + invdx = 0; + } + + mz = (Zvalue) (z2 - z1)*invdx; + + /* Calculate c slope */ + + mc = (double) (c2 - c1)*invdx; + + /* Draw it */ + + p = &f->pixels[y][startx]; + zbuf = &f->zbuffer[y][startx]; + for (i = startx; i <= endx; i++, p++, zbuf++) { + z = (Zvalue) (mz*(i-xmin) + z1); + if (z <= *zbuf) { + *p = (Pixel) (mc*(i-xmin)+c1); + *zbuf = z; + } + } +} + +/* ------------------------------------------------------------------------- + Plot3D_interptriangletransform(Plot3D *p3, + int tx1, int ty2, Zvalue tz1, Pixel c1, + int tx2, int ty2, Zvalue tz2, Pixel c2, + int tx3, int ty3, Zvalue tz3, Pixel c3) + + This function draws a 3D z-buffered filled triangle with color + interpolation. Assumes three points have already been transformed + into screen coordinates. + + General idea : + 1. Transform the three points into screen coordinates + 2. Order three points vertically on screen. + 3. Check for degenerate cases (where 3 points are colinear). + 4. Fill in the resulting triangle using horizontal lines. + 5. Colors are interpolated between end points + -------------------------------------------------------------------------- */ + +void Plot3D_interptriangletransform(Plot3D *p3, + int tx1, int ty1, Zvalue tz1, Pixel c1, + int tx2, int ty2, Zvalue tz2, Pixel c2, + int tx3, int ty3, Zvalue tz3, Pixel c3) { + int tempx, tempy; + Zvalue tempz; + double m1,m2,m3, mz1, mz2, mz3; + double mc1,mc2,mc3; + Pixel ic1,ic2,tempc; + int y; + int ix1, ix2; + Zvalue zz1, zz2; + FrameBuffer *f; + + f = p3->frame; + + /* Figure out which point has the greatest "y" value */ + + if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ + tempx = tx1; + tempy = ty1; + tempz = tz1; + tempc = c1; + tx1 = tx2; + ty1 = ty2; + tz1 = tz2; + c1 = c2; + tx2 = tempx; + ty2 = tempy; + tz2 = tempz; + c2 = tempc; + } + if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ + tempx = tx1; + tempy = ty1; + tempz = tz1; + tempc = c1; + tx1 = tx3; + ty1 = ty3; + tz1 = tz3; + c1 = c3; + tx3 = tempx; + ty3 = tempy; + tz3 = tempz; + c3 = tempc; + } + if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ + tempx = tx2; + tempy = ty2; + tempz = tz2; + tempc = c2; + tx2 = tx3; + ty2 = ty3; + tz2 = tz3; + c2 = c3; + tx3 = tempx; + ty3 = tempy; + tz3 = tempz; + c3 = tempc; + } + + /* Points are now order so that t_1 is the highest point, t_2 is the + middle point, and t_3 is the lowest point */ + + /* Check for degenerate cases here */ + + if ((ty1 == ty2) && (ty2 == ty3)) { + + /* Points are aligned horizontally. Handle as a special case */ + /* Just draw three lines using the outline color */ + + if (tx2 > tx1) + Plot3D_horizontalinterp(p3,tx1,tx2,ty1,tz1,tz2,c1,c2); + else + Plot3D_horizontalinterp(p3,tx2,tx1,ty1,tz2,tz1,c2,c1); + if (tx3 > tx1) + Plot3D_horizontalinterp(p3,tx1,tx3,ty1,tz1,tz3,c1,c3); + else + Plot3D_horizontalinterp(p3,tx3,tx1,ty1,tz3,tz1,c3,c1); + if (tx3 > tx2) + Plot3D_horizontalinterp(p3,tx2,tx3,ty2,tz2,tz3,c2,c3); + else + Plot3D_horizontalinterp(p3,tx3,tx2,ty2,tz3,tz2,c3,c2); + + } else { + + /* First process line segments between (x1,y1)-(x2,y2) + And between (x1,y1),(x3,y3) */ + + if (ty2 < ty1) { + m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + mz1 = (tz2 - tz1)/(double) (ty2 - ty1); + mz2 = (tz3 - tz1)/(double) (ty3 - ty1); + mc1 = (c2 - c1)/(double) (ty2 - ty1); + mc2 = (c3 - c1)/(double) (ty3 - ty1); + + y = ty1; + while (y >= ty2) { + /* Calculate x values from slope */ + ix1 = (int) (m1*(y-ty1)+0.5) + tx1; + ix2 = (int) (m2*(y-ty1)+0.5) + tx1; + zz1 = mz1*(y-ty1) + tz1; + zz2 = mz2*(y-ty1) + tz1; + ic1 = mc1*(y-ty1) + c1; + ic2 = mc2*(y-ty1) + c1; + if (ix1 > ix2) + Plot3D_horizontalinterp(p3,ix2,ix1,y,zz2,zz1,ic2,ic1); + else + Plot3D_horizontalinterp(p3,ix1,ix2,y,zz1,zz2,ic1,ic2); + y--; + } + } + if (ty3 < ty2) { + /* Draw lower half of the triangle */ + m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); + mz2 = (tz3 - tz1)/(double) (ty3 - ty1); + mc2 = (c3 - c1)/(double) (ty3 - ty1); + m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); + mz3 = (tz3 - tz2)/(double) (ty3 - ty2); + mc3 = (c3 - c2)/(double) (ty3 - ty2); + y = ty2; + while (y >= ty3) { + ix1 = (int) (m3*(y-ty2)+0.5)+tx2; + ix2 = (int) (m2*(y-ty1)+0.5)+tx1; + zz1 = mz3*(y-ty2)+tz2; + zz2 = mz2*(y-ty1)+tz1; + ic1 = mc3*(y-ty2)+c2; + ic2 = mc2*(y-ty1)+c1; + if (ix1 > ix2) + Plot3D_horizontalinterp(p3,ix2,ix1,y,zz2,zz1,ic2,ic1); + else + Plot3D_horizontalinterp(p3,ix1,ix2,y,zz1,zz2,ic1,ic2); + y--; + } + } + } +} + +/* ------------------------------------------------------------------------- + Plot3D_interptriangle(Plot3D *p3, + double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3) + + This function draws a 3D z-buffered filled triangle with color + interpolation. + + This function simply transforms the given points and calls + Plot3D_InterpTriangleTransform(). + -------------------------------------------------------------------------- */ + +void Plot3D_interptriangle(Plot3D *p3, + double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3) { + + int tx1, tx2, tx3, ty1, ty2, ty3; + Zvalue tz1, tz2, tz3; + GL_Vector t; + double invw; + + /* Transform the three points into screen coordinates */ + + Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz1 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz2 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz3 = (Zvalue) t.z; + + Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx2,ty2,tz2,c2,tx3,ty3,tz3,c3); +} + +/* ------------------------------------------------------------------------- + Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel fillcolor) + + This function draws a 3D outlined Quadralateral. Used primarily for + drawing meshes and other things. + + Plotting is done in the following order : + (x1,y1,z1) --> (x2,y2,z2) + (x2,y2,z2) --> (x3,y3,z3) + (x3,y3,z3) --> (x4,y4,z4) + (x4,y4,z4) --> (x1,y1,z1) + -------------------------------------------------------------------------- */ + +void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel color) { + + int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; + Zvalue tz1, tz2, tz3, tz4; + GL_Vector t; + double invw; + + /* Transform the three points into screen coordinates */ + + Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz1 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz2 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz3 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz4 = (Zvalue) t.z; + + Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); + Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); + Plot3D_linetransform(p3,tx3,ty3,tz3,tx4,ty4,tz4,color); + Plot3D_linetransform(p3,tx4,ty4,tz4,tx1,ty1,tz1,color); + +} + + +/* ------------------------------------------------------------------------- + Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel fillcolor) + + This function draws a 3D solid Quadralateral. Uses the function + Plot3D_SolidTriangleTransform() to fill in the region. + + Plotting is done in the following order : + (x1,y1,z1) --> (x2,y2,z2) + (x2,y2,z2) --> (x3,y3,z3) + (x3,y3,z3) --> (x4,y4,z4) + (x4,y4,z4) --> (x1,y1,z1) + -------------------------------------------------------------------------- */ + +void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, + double x2, double y2, double z2, + double x3, double y3, double z3, + double x4, double y4, double z4, + Pixel color) { + + int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; + Zvalue tz1, tz2, tz3, tz4; + GL_Vector t; + double invw; + + /* Transform the three points into screen coordinates */ + + Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz1 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz2 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz3 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz4 = (Zvalue) t.z; + + Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,tx3,ty3,tz3,color); + Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx4,ty4,tz4,tx3,ty3,tz3,color); +} + +/* ------------------------------------------------------------------------- + Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3, + double x4, double y4, double z4, Pixel c4) + + This function draws a 3D color-interpolated Quadralateral. Uses the function + Plot3D_InterpTriangleTransform() to fill in the region. + + Plotting is done in the following order : + (x1,y1,z1) --> (x2,y2,z2) + (x2,y2,z2) --> (x3,y3,z3) + (x3,y3,z3) --> (x4,y4,z4) + (x4,y4,z4) --> (x1,y1,z1) + -------------------------------------------------------------------------- */ + +void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, + double x2, double y2, double z2, Pixel c2, + double x3, double y3, double z3, Pixel c3, + double x4, double y4, double z4, Pixel c4) { + + + int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; + Zvalue tz1, tz2, tz3, tz4; + GL_Vector t; + double invw; + + /* Transform the three points into screen coordinates */ + + Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz1 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz2 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz3 = (Zvalue) t.z; + + Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ + invw = 1.0/t.w; + t.x = t.x *invw; + t.y = t.y *invw; + t.z = t.z *invw; + tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz4 = (Zvalue) t.z; + + Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx2,ty2,tz2,c2,tx3,ty3,tz3,c3); + Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx4,ty4,tz4,c4,tx3,ty3,tz3,c3); + +} + +/* -------------------------------------------------------------------------- + Plot3D_solidsphere(Plot3 *p3, double x, double y, double z, double radius, + Pixel c) + + Makes a 3D sphere at x,y,z with given radius and color. + + Basic strategy : + 1. Transform point to screen coordinates + 2. Figure out what the radius is in screen coordinates + 3. Use bresenham algorithm for large spheres + 4. Use bitmaps for small spheres + -------------------------------------------------------------------------- */ + +/* This is used to fill in spheres */ +static int s_xmin; +static int s_ymin; +static int s_xmax; +static int s_ymax; +static Pixel **s_pixels; +static Zvalue **s_zbuffer; + +void Plot3D_spherehorizontal(int xmin, int xmax, int y, Zvalue z, Pixel color) { + int i; + int startx, endx; + Pixel *p; + Zvalue *zbuf; + + if ((y < s_ymin) || (y >= s_ymax)) return; + if (xmin < s_xmin) startx = s_xmin; + else startx = xmin; + if (xmax >= s_xmax) endx = s_xmax - 1; + else endx = xmax; + + /* Draw it */ + + p = &s_pixels[y][xmin]; + zbuf = &s_zbuffer[y][xmin]; + for (i = startx; i <= endx; i++, p++, zbuf++) { + if (z <= *zbuf) { + *p = color; + *zbuf = z; + } + } +} + +void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius, + Pixel c) { + + GL_Vector t,r; + double rad; + int tx,ty, irad; + Zvalue tz; + double invw; + int ix, iy, ix1,ix2,p; + FrameBuffer *f; + + /* First transform the point into model coordinates */ + + Matrix_transform4(p3->fullmodel_mat,x,y,z,1,&t); + + /* Now transform two points in order to find proper sphere radius */ + + Matrix_transform4(p3->view_mat,t.x+radius,t.y,t.z,t.w,&r); /* transform radius */ + Matrix_transform4(p3->view_mat,t.x,t.y,t.z,t.w,&t); + + invw = 1.0/t.w; + t.x = t.x*invw; + t.y = t.y*invw; + t.z = t.z*invw; + invw = 1.0/r.w; + r.x = r.x*invw; + r.y = r.y*invw; + r.z = r.z*invw; + invw = 1.0/r.w; + + rad = fabs(t.x - r.x); + + /* Transform everything into screen coordinates */ + + tx = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz = (Zvalue) t.z; + irad = (int) (p3->zoom*(rad*p3->width + 0.5)); + + /* This is only a temporary solution (maybe). */ + +#define fill_zcircle(x,y,c) \ + ix1 = tx - x; \ + ix2 = tx + x; \ + if (ix1 < s_xmin) ix1 = s_xmin; \ + if (ix2 >= s_xmax) ix2 = s_xmax; \ + Plot3D_spherehorizontal(ix1,ix2,y,tz,c); + + f = p3->frame; + s_xmin = f->xmin; + s_ymin = f->ymin; + s_xmax = f->xmax; + s_ymax = f->ymax; + s_pixels = f->pixels; + s_zbuffer = f->zbuffer; + if (irad <= 1) { + /* Plot a single pixel */ + if ((tx >= f->xmin) && (tx < f->xmax)) { + if ((ty >= f->ymin) && (ty ymax)) { + if (tz <= f->zbuffer[ty][tx]) { + f->pixels[ty][tx] = c; + f->zbuffer[ty][tx] = tz; + } + } + } + return; + } + ix = 0; + iy = irad; + p = 3-2*irad; + while (ix <= iy) { + fill_zcircle(ix,ty+iy,c); + fill_zcircle(ix,ty-iy,c); + fill_zcircle(iy,ty+ix,c); + fill_zcircle(iy,ty-ix,c); + if (p < 0) p = p + 4*ix + 6; + else { + p = p + 4*(ix-iy) + 10; + iy = iy -1; + } + ix++; + } +} + + +/* -------------------------------------------------------------------- + Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, + double radius, Pixel color, Pixel bc) + + Draws an outlined sphere. + -------------------------------------------------------------------- */ + +void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, + double radius, Pixel c, Pixel bc) +{ + GL_Vector t,r; + double rad; + int tx,ty, irad; + Zvalue tz; + double invw; + int ix, iy, ix1,ix2,p; + + FrameBuffer *f; + + /* First transform the point into model coordinates */ + + Matrix_transform4(p3->fullmodel_mat,x,y,z,1,&t); + + /* Now transform two points in order to find proper sphere radius */ + + Matrix_transform4(p3->view_mat,t.x+radius,t.y,t.z,t.w,&r); /* transform radius */ + Matrix_transform4(p3->view_mat,t.x,t.y,t.z,t.w,&t); + + invw = 1.0/t.w; + t.x = t.x*invw; + t.y = t.y*invw; + t.z = t.z*invw; + invw = 1.0/r.w; + r.x = r.x*invw; + r.y = r.y*invw; + r.z = r.z*invw; + invw = 1.0/r.w; + + rad = fabs(t.x - r.x); + + /* Transform everything into screen coordinates */ + + tx = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; + ty = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; + tz = (Zvalue) t.z; + irad = (int) (p3->zoom*(rad*p3->width + 0.5)); + + /* This is only a temporary solution (maybe). */ +#define plot_zcircle(x,y,c) \ + if ((x >= s_xmin) && (x < s_xmax) && \ + (y >= s_ymin) && (y < s_ymax)) {\ + if (tz <= s_zbuffer[y][x]) { \ + s_pixels[y][x] = c; \ + s_zbuffer[y][x] = tz; } \ + } + + f = p3->frame; + s_xmin = f->xmin; + s_ymin = f->ymin; + s_xmax = f->xmax; + s_ymax = f->ymax; + s_pixels = f->pixels; + s_zbuffer = f->zbuffer; + + if (irad <= 1) { + /* Plot a single pixel */ + if ((tx >= f->xmin) && (tx < f->xmax)) { + if ((ty >= f->ymin) && (ty ymax)) { + if (tz <= f->zbuffer[ty][tx]) { + f->pixels[ty][tx] = c; + f->zbuffer[ty][tx] = tz; + } + } + } + return; + } + ix = 0; + iy = irad; + p = 3-2*irad; + while (ix <= iy) { + fill_zcircle(ix,ty+iy,c); + fill_zcircle(ix,ty-iy,c); + fill_zcircle(iy,ty+ix,c); + fill_zcircle(iy,ty-ix,c); + + plot_zcircle(tx+ix,ty+iy,bc); + plot_zcircle(tx-ix,ty+iy,bc); + plot_zcircle(tx+ix,ty-iy,bc); + plot_zcircle(tx-ix,ty-iy,bc); + plot_zcircle(tx+iy,ty+ix,bc); + plot_zcircle(tx-iy,ty+ix,bc); + plot_zcircle(tx+iy,ty-ix,bc); + plot_zcircle(tx-iy,ty-ix,bc); + if (p < 0) p = p + 4*ix + 6; + else { + p = p + 4*(ix-iy) + 10; + iy = iy -1; + } + ix++; + } +} + +/* QUAD Test + Test out quad functions for graphing */ + +double zf(double x, double y) { + return cos(sqrt(x*x + y*y)*10.0)/(sqrt(x*x+y*y)+1); +} + +void Quad_Test(Plot3D *p3, int npoints) { + int i,j; + double dx; + double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,za; + int c; + dx = 2.0/npoints; + + + for (i = 0; i < npoints; i++) + for (j = 0; j < npoints; j++) { + x1 = i*dx + -1.0; + y1 = j*dx + -1.0; + x2 = x1 + dx; + x3 = x1 + dx; + x4 = x1; + y2 = y1; + y3 = y1 + dx; + y4 = y1 + dx; + z1 = zf(x1,y1); + z2 = zf(x2,y2); + z3 = zf(x3,y3); + z4 = zf(x4,y4); + za = 0.25*(z1+z2+z3+z4); + c = 16+((za + 1)*120); + if (c > 254) c = 254; + Plot3D_quad(p3,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,(Pixel) c); + } +} + + +void Quad_SolidTest(Plot3D *p3, int npoints) { + int i,j; + double dx; + double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,za; + int c; + dx = 2.0/npoints; + + + for (i = 0; i < npoints; i++) + for (j = 0; j < npoints; j++) { + x1 = i*dx + -1.0; + y1 = j*dx + -1.0; + x2 = x1 + dx; + x3 = x1 + dx; + x4 = x1; + y2 = y1; + y3 = y1 + dx; + y4 = y1 + dx; + z1 = zf(x1,y1); + z2 = zf(x2,y2); + z3 = zf(x3,y3); + z4 = zf(x4,y4); + za = 0.25*(z1+z2+z3+z4); + c = 16+((za + 1)*120); + if (c > 254) c = 254; + Plot3D_solidquad(p3,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,(Pixel) c); + } +} + + + +void Quad_InterpTest(Plot3D *p3, int npoints) { + int i,j; + double dx; + double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4; + int c1,c2,c3,c4; + dx = 2.0/npoints; + + + for (i = 0; i < npoints; i++) + for (j = 0; j < npoints; j++) { + x1 = i*dx + -1.0; + y1 = j*dx + -1.0; + x2 = x1 + dx; + x3 = x1 + dx; + x4 = x1; + y2 = y1; + y3 = y1 + dx; + y4 = y1 + dx; + z1 = zf(x1,y1); + z2 = zf(x2,y2); + z3 = zf(x3,y3); + z4 = zf(x4,y4); + c1 = 16+((z1 + 1)*120); + c2 = 16+((z2 + 1)*120); + c3 = 16+((z3 + 1)*120); + c4 = 16+((z4 + 1)*120); + if (c1 > 254) c1 = 254; + if (c2 > 254) c2 = 254; + if (c3 > 254) c3 = 254; + if (c4 > 254) c4 = 254; + Plot3D_interpquad(p3,x1,y1,z1,(Pixel) c1,x2,y2,z2,(Pixel) c2,x3,y3,z3,(Pixel) c3,x4,y4,z4,(Pixel) c4); + } +} + + + + + + + + + + + + diff --git a/Examples/GIFPlot/Makefile.in b/Examples/GIFPlot/Makefile.in new file mode 100644 index 0000000..4e51360 --- /dev/null +++ b/Examples/GIFPlot/Makefile.in @@ -0,0 +1,23 @@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +RANLIB = @RANLIB@ +OPT = + +INSTALL = ../install-sh -c +INSTALL_DATA = ${INSTALL} -m 644 +SHELL = /bin/sh + +all: + cd Lib && $(MAKE) OPT="$(OPT)" + +install: + $(INSTALL_DATA) Include/gifplot.h $(prefix)/include/gifplot.h + $(INSTALL_DATA) libgifplot.a $(exec_prefix)/lib/libgifplot.a + $(RANLIB) $(exec_prefix)/lib/libgifplot.a + +clean:: + rm -f *.@OBJEXT@ *~ libgifplot.a *_wrap* *_man* + cd Lib && $(MAKE) clean + rm -f config.log config.status config.cache + +check: all diff --git a/Examples/GIFPlot/Ocaml/check.list b/Examples/GIFPlot/Ocaml/check.list new file mode 100644 index 0000000..e75ee58 --- /dev/null +++ b/Examples/GIFPlot/Ocaml/check.list @@ -0,0 +1,3 @@ +# see top-level Makefile.in +full +simple diff --git a/Examples/GIFPlot/Ocaml/full/Makefile b/Examples/GIFPlot/Ocaml/full/Makefile new file mode 100644 index 0000000..4f35c43 --- /dev/null +++ b/Examples/GIFPlot/Ocaml/full/Makefile @@ -0,0 +1,33 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Include +SRCS = +TARGET = gifcaml +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot -lm +INCLUDES = -I../../Include +MLFILE = gifplot.ml +IOBJS = runme.cmo +PROGFILE = runme.ml + +all:: static + +static:: + $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ + IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ + SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static + +dynamic:: + $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ + IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ + SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_dynamic + +clean:: + $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Ocaml/full/README b/Examples/GIFPlot/Ocaml/full/README new file mode 100644 index 0000000..4a2b400 --- /dev/null +++ b/Examples/GIFPlot/Ocaml/full/README @@ -0,0 +1,8 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The ocaml program 'runme.ml' does something a little more +interesting. You'll have to go look at the header file to get a complete +listing of the functions. + + + + diff --git a/Examples/GIFPlot/Ocaml/full/cmap b/Examples/GIFPlot/Ocaml/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC C_float x) + [ x ; y ; z1 ; + (x +. dx) ; y ; z2 ; + (x +. dx) ; (y +. dy) ; z3 ; + x ; (y +. dx) ; z4 ; + (float_of_int (c + 16)) ]))) ; + y_loop (y +. dy) (j + 1) + end in + begin + y_loop ymin 0 ; + x_loop (x +. dx) (i + 1) + end + end in + x_loop xmin 0 + end + +let _ = print_endline "Making a nice 3D plot..." +let _ = drawsolid () + +let _ = _FrameBuffer_writeGIF (C_list [ frame ; cmap ; C_string "image.gif" ]) +let _ = print_endline "Write image.gif" diff --git a/Examples/GIFPlot/Ocaml/simple/Makefile b/Examples/GIFPlot/Ocaml/simple/Makefile new file mode 100644 index 0000000..50492ef --- /dev/null +++ b/Examples/GIFPlot/Ocaml/simple/Makefile @@ -0,0 +1,33 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Include +SRCS = +TARGET = gifsimple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot -lm +INCLUDES = -I../../Include +MLFILE = simple.ml +IOBJS = simple_wrap.o simple.cmo runme.cmo +PROGFILE = runme.ml + +all:: static + +static:: + $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ + IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ + SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static + +dynamic:: + $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ + IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ + SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static + +clean:: + $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Ocaml/simple/cmap b/Examples/GIFPlot/Ocaml/simple/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) { $c = 239; } + Plot3D_solidquad($p3,$x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); + $y = $y + $dy; + } + $x = $x + $dx; + } +} + +print "Making a nice 3D plot...\n"; +drawsolid(); + +FrameBuffer_writeGIF($frame,$cmap,"image.gif"); +print "Wrote image.gif\n"; + diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile new file mode 100644 index 0000000..c39eac5 --- /dev/null +++ b/Examples/GIFPlot/Perl5/shadow/Makefile @@ -0,0 +1,25 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -outcurrentdir +SRCS = +TARGET = gifplot +INTERFACEDIR = ../../Interface/ +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot -lm +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5 + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='myperl' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5_static + +clean:: + $(MAKE) -f $(TOP)/Makefile perl5_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Perl5/shadow/README b/Examples/GIFPlot/Perl5/shadow/README new file mode 100644 index 0000000..ab12e34 --- /dev/null +++ b/Examples/GIFPlot/Perl5/shadow/README @@ -0,0 +1,2 @@ +This example use the file in ../../Interface/gifplot.i to build +an interface with shadow classes. Run the script 'runme.pl'. diff --git a/Examples/GIFPlot/Perl5/shadow/cmap b/Examples/GIFPlot/Perl5/shadow/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICclear($BLACK); + +$p3 = new gifplot::Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax); +$p3->lookat(2*($zmax-$zmin)); +$p3->autoperspective(40); +$p3->rotu(60); +$p3->rotr(30); +$p3->rotd(10); + +sub drawsolid { + $p3->clear($BLACK); + $p3->start(); + my $dx = 1.0*($xmax-$xmin)/$nxpoints; + my $dy = 1.0*($ymax-$ymin)/$nypoints; + my $cscale = 240.0/($zmax-$zmin); + my $x = $xmin; + for ($i = 0; $i < $nxpoints; $i++) { + my $y = $ymin; + for ($j = 0; $j < $nypoints; $j++) { + my $z1 = func($x,$y); + my $z2 = func($x+$dx,$y); + my $z3 = func($x+$dx,$y+$dy); + my $z4 = func($x,$y+$dy); + my $c1 = $cscale*($z1-$zmin); + my $c2 = $cscale*($z2-$zmin); + my $c3 = $cscale*($z3-$zmin); + my $c4 = $cscale*($z4-$zmin); + my $c = ($c1+$c2+$c3+$c4)/4; + if ($c < 0) { $c = 0; } + if ($c > 239) { $c = 239; } + $p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); + $y = $y + $dy; + } + $x = $x + $dx; + } +} + +print "Making a nice 3D plot...\n"; +drawsolid(); + +$frame->writeGIF($cmap,"image.gif"); +print "Wrote image.gif\n"; + diff --git a/Examples/GIFPlot/Perl5/simple/Makefile b/Examples/GIFPlot/Perl5/simple/Makefile new file mode 100644 index 0000000..36a8fa9 --- /dev/null +++ b/Examples/GIFPlot/Perl5/simple/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = +SRCS = +TARGET = simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static + +clean:: + $(MAKE) -f $(TOP)/Makefile perl5_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Perl5/simple/README b/Examples/GIFPlot/Perl5/simple/README new file mode 100644 index 0000000..c2c799a --- /dev/null +++ b/Examples/GIFPlot/Perl5/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. The script 'runme.pl' runs the example. + + diff --git a/Examples/GIFPlot/Perl5/simple/runme.pl b/Examples/GIFPlot/Perl5/simple/runme.pl new file mode 100644 index 0000000..f28255e --- /dev/null +++ b/Examples/GIFPlot/Perl5/simple/runme.pl @@ -0,0 +1,28 @@ +# Draw some simple shapes +print "Drawing some basic shapes\n"; + +use simple; + +$cmap = simple::new_ColorMap(); +$f = simple::new_FrameBuffer(400,400); + +# Clear the picture +simple::FrameBuffer_clear($f,$simple::BLACK); + +# Make a red box +simple::FrameBuffer_box($f,40,40,200,200,$simple::RED); + +# Make a blue circle +simple::FrameBuffer_circle($f,200,200,40,$simple::BLUE); + +# Make green line +simple::FrameBuffer_line($f,10,390,390,200, $simple::GREEN); + +# Write an image out to disk + +simple::FrameBuffer_writeGIF($f,$cmap,"image.gif"); +print "Wrote image.gif\n"; + +simple::delete_FrameBuffer($f); +simple::delete_ColorMap($cmap); + diff --git a/Examples/GIFPlot/Perl5/simple/simple.i b/Examples/GIFPlot/Perl5/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Perl5/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/GIFPlot/Php/check.list b/Examples/GIFPlot/Php/check.list new file mode 100644 index 0000000..e75ee58 --- /dev/null +++ b/Examples/GIFPlot/Php/check.list @@ -0,0 +1,3 @@ +# see top-level Makefile.in +full +simple diff --git a/Examples/GIFPlot/Php/full/Makefile b/Examples/GIFPlot/Php/full/Makefile new file mode 100644 index 0000000..e33e7a7 --- /dev/null +++ b/Examples/GIFPlot/Php/full/Makefile @@ -0,0 +1,20 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Include -noproxy +SRCS = +TARGET = php_gifplot +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot -lm +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php + +clean:: + $(MAKE) -f $(TOP)/Makefile php_clean + rm -f *.gif + rm -f php_gifplot.h + +check: all diff --git a/Examples/GIFPlot/Php/full/README b/Examples/GIFPlot/Php/full/README new file mode 100644 index 0000000..f8d38d9 --- /dev/null +++ b/Examples/GIFPlot/Php/full/README @@ -0,0 +1,4 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The script 'runme.php3' does something a little more +interesting. You'll have to go look at the header file to get a complete +listing of the functions. diff --git a/Examples/GIFPlot/Php/full/cmap b/Examples/GIFPlot/Php/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) { $c = 239; } + Plot3D_solidquad($p3, $x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); + $y = $y + $dy; + } + $x = $x + $dx; + } +} + +print "Making a nice 3D plot...\n"; +drawsolid(); + +FrameBuffer_writeGIF($frame, $cmap,"image.gif"); +print "Wrote image.gif\n"; + +?> diff --git a/Examples/GIFPlot/Php/shadow/Makefile b/Examples/GIFPlot/Php/shadow/Makefile new file mode 100644 index 0000000..df8ee30 --- /dev/null +++ b/Examples/GIFPlot/Php/shadow/Makefile @@ -0,0 +1,19 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Interface +SRCS = +TARGET = php_gifplot +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot -lm +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php + +clean:: + $(MAKE) -f $(TOP)/Makefile php_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Php/shadow/README b/Examples/GIFPlot/Php/shadow/README new file mode 100644 index 0000000..3e91f7d --- /dev/null +++ b/Examples/GIFPlot/Php/shadow/README @@ -0,0 +1,2 @@ +This example use the file in ../../Interface/gifplot.i to build +an interface with shadow classes. Run the script 'runme.php3'. diff --git a/Examples/GIFPlot/Php/shadow/cmap b/Examples/GIFPlot/Php/shadow/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICclear(BLACK); + + +$p3 = new Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax); +$p3->lookat(2*($zmax-$zmin)); +$p3->autoperspective(40); +$p3->rotu(60); +$p3->rotr(30); +$p3->rotd(10); + +function drawsolid() { + global $xmax; + global $xmin; + global $ymax; + global $ymin; + global $zmin; + global $zmax; + global $nxpoints; + global $nypoints; + global $p3; + + $p3->clear(BLACK); + $p3->start(); + $dx = 1.0*($xmax-$xmin)/$nxpoints; + $dy = 1.0*($ymax-$ymin)/$nypoints; + $cscale = 240.0/($zmax-$zmin); + $x = $xmin; + for ($i = 0; $i < $nxpoints; $i++) { + $y = $ymin; + for ($j = 0; $j < $nypoints; $j++) { + $z1 = func($x,$y); + $z2 = func($x+$dx,$y); + $z3 = func($x+$dx,$y+$dy); + $z4 = func($x,$y+$dy); + $c1 = $cscale*($z1-$zmin); + $c2 = $cscale*($z2-$zmin); + $c3 = $cscale*($z3-$zmin); + $c4 = $cscale*($z4-$zmin); + $c = ($c1+$c2+$c3+$c4)/4; + if ($c < 0) { $c = 0; } + if ($c > 239) { $c = 239; } + $p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); + $y = $y + $dy; + } + $x = $x + $dx; + } +} + +print "Making a nice 3D plot...\n"; +drawsolid(); + +$frame->writeGIF($cmap,"image.gif"); +print "Wrote image.gif\n"; + +?> diff --git a/Examples/GIFPlot/Php/simple/Makefile b/Examples/GIFPlot/Php/simple/Makefile new file mode 100644 index 0000000..e60b641 --- /dev/null +++ b/Examples/GIFPlot/Php/simple/Makefile @@ -0,0 +1,20 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -noproxy +SRCS = +TARGET = php_simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php + +clean:: + $(MAKE) -f $(TOP)/Makefile php_clean + rm -f *.gif + rm -f php_simple.h + +check: all diff --git a/Examples/GIFPlot/Php/simple/README b/Examples/GIFPlot/Php/simple/README new file mode 100644 index 0000000..c2c799a --- /dev/null +++ b/Examples/GIFPlot/Php/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. The script 'runme.pl' runs the example. + + diff --git a/Examples/GIFPlot/Php/simple/runme.php b/Examples/GIFPlot/Php/simple/runme.php new file mode 100644 index 0000000..cf21a09 --- /dev/null +++ b/Examples/GIFPlot/Php/simple/runme.php @@ -0,0 +1,32 @@ + + diff --git a/Examples/GIFPlot/Php/simple/simple.i b/Examples/GIFPlot/Php/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Php/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/GIFPlot/Pike/check.list b/Examples/GIFPlot/Pike/check.list new file mode 100644 index 0000000..d38998c --- /dev/null +++ b/Examples/GIFPlot/Pike/check.list @@ -0,0 +1,2 @@ +# see top-level Makefile.in +simple diff --git a/Examples/GIFPlot/Pike/simple/Makefile b/Examples/GIFPlot/Pike/simple/Makefile new file mode 100644 index 0000000..d339e03 --- /dev/null +++ b/Examples/GIFPlot/Pike/simple/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = +SRCS = +TARGET = simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static + +clean:: + $(MAKE) -f $(TOP)/Makefile pike_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Pike/simple/README b/Examples/GIFPlot/Pike/simple/README new file mode 100644 index 0000000..177b363 --- /dev/null +++ b/Examples/GIFPlot/Pike/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. The script 'runme.pike' runs the example. + + diff --git a/Examples/GIFPlot/Pike/simple/runme.pike b/Examples/GIFPlot/Pike/simple/runme.pike new file mode 100644 index 0000000..0e70235 --- /dev/null +++ b/Examples/GIFPlot/Pike/simple/runme.pike @@ -0,0 +1,30 @@ +int main() +{ + // Draw some simple shapes + write("Drawing some basic shapes\n"); + + .simple.ColorMap cmap = .simple.new_ColorMap(); + .simple.FrameBuffer f = .simple.new_FrameBuffer(400, 400); + + // Clear the picture + .simple.FrameBuffer_clear(f, .simple.BLACK); + + // Make a red box + .simple.FrameBuffer_box(f, 40, 40, 200, 200, .simple.RED); + + // Make a blue circle + .simple.FrameBuffer_circle(f, 200, 200, 40, .simple.BLUE); + + // Make green line + .simple.FrameBuffer_line(f, 10, 390, 390, 200, .simple.GREEN); + + // Write an image out to disk + .simple.FrameBuffer_writeGIF(f, cmap, "image.gif"); + write("Wrote image.gif\n"); + + .simple.delete_FrameBuffer(f); + .simple.delete_ColorMap(cmap); + + return 0; +} + diff --git a/Examples/GIFPlot/Pike/simple/simple.i b/Examples/GIFPlot/Pike/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Pike/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/GIFPlot/Python/check.list b/Examples/GIFPlot/Python/check.list new file mode 100644 index 0000000..13de977 --- /dev/null +++ b/Examples/GIFPlot/Python/check.list @@ -0,0 +1,4 @@ +# see top-level Makefile.in +full +shadow +simple diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile new file mode 100644 index 0000000..83a7c86 --- /dev/null +++ b/Examples/GIFPlot/Python/full/Makefile @@ -0,0 +1,26 @@ +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +SWIGOPT = -I../../Include +SRCS = +TARGET = gifplot +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mypython' INTERFACE='$(INTERFACE)' python_static + +clean:: + $(MAKE) -f $(TOP)/Makefile python_clean + rm -f $(TARGET).py + rm -f *.gif + +check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/full/README b/Examples/GIFPlot/Python/full/README new file mode 100644 index 0000000..52971e4 --- /dev/null +++ b/Examples/GIFPlot/Python/full/README @@ -0,0 +1,8 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The script 'runme.py' does something a little more +interesting. You'll have to go look at the header file to get a complete +listing of the functions. + + + + diff --git a/Examples/GIFPlot/Python/full/cmap b/Examples/GIFPlot/Python/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 : c = 239 + Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) + y = y + dy + x = x + dx + +print "Making a nice 3D plot..." +drawsolid() + +FrameBuffer_writeGIF(frame,cmap,"image.gif") +print "Wrote image.gif" + diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile new file mode 100644 index 0000000..3ae9a98 --- /dev/null +++ b/Examples/GIFPlot/Python/shadow/Makefile @@ -0,0 +1,27 @@ +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +SWIGOPT = -outcurrentdir +SRCS = +TARGET = gifplot +INTERFACEDIR = ../../Interface/ +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mypython' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python_static + +clean:: + $(MAKE) -f $(TOP)/Makefile python_clean + rm -f $(TARGET).py + rm -f *.gif + +check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/shadow/README b/Examples/GIFPlot/Python/shadow/README new file mode 100644 index 0000000..aa761e2 --- /dev/null +++ b/Examples/GIFPlot/Python/shadow/README @@ -0,0 +1,8 @@ +This example illustrates Python shadow classes. Take a look at +the file GIFPlot/Interface/gifplot.i + + + + + + diff --git a/Examples/GIFPlot/Python/shadow/cmap b/Examples/GIFPlot/Python/shadow/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 : c = 239 + p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) + y = y + dy + x = x + dx + +print "Making a nice 3D plot..." +drawsolid() + +frame.writeGIF(cmap,"image.gif") +print "Wrote image.gif" + diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile new file mode 100644 index 0000000..9fc9a6c --- /dev/null +++ b/Examples/GIFPlot/Python/simple/Makefile @@ -0,0 +1,26 @@ +TOP = ../../.. +SWIG = $(TOP)/../preinst-swig +SWIGOPT = +SRCS = +TARGET = simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mypython' INTERFACE='$(INTERFACE)' python_static + +clean:: + $(MAKE) -f $(TOP)/Makefile python_clean + rm -f $(TARGET).py + rm -f *.gif + +check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/simple/README b/Examples/GIFPlot/Python/simple/README new file mode 100644 index 0000000..22152c6 --- /dev/null +++ b/Examples/GIFPlot/Python/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. The script 'runme.py' runs the example. + + diff --git a/Examples/GIFPlot/Python/simple/runme.py b/Examples/GIFPlot/Python/simple/runme.py new file mode 100644 index 0000000..dade677 --- /dev/null +++ b/Examples/GIFPlot/Python/simple/runme.py @@ -0,0 +1,27 @@ +# Draw some simple shapes +print "Drawing some basic shapes" +import simple + +cmap = simple.new_ColorMap() +f = simple.new_FrameBuffer(400,400) + +# Clear the picture +simple.FrameBuffer_clear(f,simple.BLACK) + +# Make a red box +simple.FrameBuffer_box(f,40,40,200,200,simple.RED) + +# Make a blue circle +simple.FrameBuffer_circle(f,200,200,40,simple.BLUE) + +# Make green line +simple.FrameBuffer_line(f,10,390,390,200, simple.GREEN) + +# Write an image out to disk + +simple.FrameBuffer_writeGIF(f,cmap,"image.gif") +print "Wrote image.gif" + +simple.delete_FrameBuffer(f) +simple.delete_ColorMap(cmap) + diff --git a/Examples/GIFPlot/Python/simple/simple.i b/Examples/GIFPlot/Python/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Python/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/GIFPlot/README b/Examples/GIFPlot/README new file mode 100644 index 0000000..ac1025a --- /dev/null +++ b/Examples/GIFPlot/README @@ -0,0 +1,59 @@ +GIFPlot +======= + +To illustrate various SWIG features, the following examples involve +building an interface to a small, but somewhat useful graphics library +for creating 2D and 3D images in the form of GIF files. The Perl, +Python, Tcl, Java, Ruby etc. directories contain various examples specific to +those languages. + +This library was originally developed as part of the SPaSM molecular +dynamics project at Los Alamos National Laboratory. However, due to +patent enforcement issues related to LZW encoding and a general lack +of time on the part of the author, the library was never officially +released. On the plus side, a number of people have found it to be a +useful easter egg within the SWIG distribution :-). + + +DUE TO PATENT RESTRICTIONS ON THE LZW COMPRESSION ALGORITHM, THIS +LIBRARY ONLY PRODUCES UNCOMPRESSED GIF FILES. SO THERE. + + +Building the Library +==================== + +In order to run the examples, it is first necessary to build the GIFPlot +C library. To do this, simply run make: + + make + +Running the Examples +==================== + +Once the library has been built, go to your chosen language directory, +that is, Perl, Python, Tcl, Java, Ruby etc. Each example should have a +README file with a description. + +Each example can be compiled using the makefile in each example directory. This +makefile uses the top level makefile in the "Examples" directory of the distribution. +If the example doesn't compile, you will need to adjust the settings in this file. + +Documentation +============= + +Read the source Luke. The examples should be pretty much self-explanatory. +The header file Include/gifplot.h contains the full API. + +The original documentation for the library can be found online at: + + http://www.dabeaz.com/gifplot/index.html + + +Let me know what you think! +=========================== +If you found this example to be useful, confusing, or otherwise, I would like to know +about it. Suggestions for improvement are welcome. + +-- Dave (dave@dabeaz.com) + + diff --git a/Examples/GIFPlot/Ruby/check.list b/Examples/GIFPlot/Ruby/check.list new file mode 100644 index 0000000..13de977 --- /dev/null +++ b/Examples/GIFPlot/Ruby/check.list @@ -0,0 +1,4 @@ +# see top-level Makefile.in +full +shadow +simple diff --git a/Examples/GIFPlot/Ruby/full/Makefile b/Examples/GIFPlot/Ruby/full/Makefile new file mode 100644 index 0000000..5af8bc8 --- /dev/null +++ b/Examples/GIFPlot/Ruby/full/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Include +SRCS = +TARGET = gifplot +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static + +clean:: + $(MAKE) -f $(TOP)/Makefile ruby_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Ruby/full/README b/Examples/GIFPlot/Ruby/full/README new file mode 100644 index 0000000..22af6cb --- /dev/null +++ b/Examples/GIFPlot/Ruby/full/README @@ -0,0 +1,8 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The script 'runme.rb' does something a little more +interesting. You'll have to go look at the header file to get a complete +listing of the functions. + + + + diff --git a/Examples/GIFPlot/Ruby/full/cmap b/Examples/GIFPlot/Ruby/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 + Plot3D_solidquad(P3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) + y = y + dy + end + x = x + dx + end +end + +puts "Making a nice 3D plot..." +drawsolid() + +FrameBuffer_writeGIF(frame,cmap,"image.gif") +puts "Wrote image.gif" diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile new file mode 100644 index 0000000..8cbea2a --- /dev/null +++ b/Examples/GIFPlot/Ruby/shadow/Makefile @@ -0,0 +1,25 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -outcurrentdir +SRCS = +TARGET = gifplot +INTERFACEDIR = ../../Interface/ +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='myruby' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby_static + +clean:: + $(MAKE) -f $(TOP)/Makefile ruby_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Ruby/shadow/README b/Examples/GIFPlot/Ruby/shadow/README new file mode 100644 index 0000000..7a33e13 --- /dev/null +++ b/Examples/GIFPlot/Ruby/shadow/README @@ -0,0 +1,5 @@ +This example illustrates Ruby shadow classes. Take a look at +the file GIFPlot/Interface/gifplot.i + +Actually Ruby module of SWIG needs no shadow class. But this example +is named "shadow" in order to be consistent with other languages. diff --git a/Examples/GIFPlot/Ruby/shadow/cmap b/Examples/GIFPlot/Ruby/shadow/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 + P3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) + y = y + dy + end + x = x + dx + end +end + +puts "Making a nice 3D plot..." +drawsolid() + +frame.writeGIF(cmap,"image.gif") +puts "Wrote image.gif" + diff --git a/Examples/GIFPlot/Ruby/simple/Makefile b/Examples/GIFPlot/Ruby/simple/Makefile new file mode 100644 index 0000000..f7ca1a7 --- /dev/null +++ b/Examples/GIFPlot/Ruby/simple/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = +SRCS = +TARGET = simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static + +clean:: + $(MAKE) -f $(TOP)/Makefile ruby_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Ruby/simple/README b/Examples/GIFPlot/Ruby/simple/README new file mode 100644 index 0000000..9b51038 --- /dev/null +++ b/Examples/GIFPlot/Ruby/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. The script 'runme.rb' runs the example. + + diff --git a/Examples/GIFPlot/Ruby/simple/runme.rb b/Examples/GIFPlot/Ruby/simple/runme.rb new file mode 100644 index 0000000..e8bf5a4 --- /dev/null +++ b/Examples/GIFPlot/Ruby/simple/runme.rb @@ -0,0 +1,27 @@ +# Draw some simple shapes +puts "Drawing some basic shapes" +require 'simple' + +cmap = Simple.new_ColorMap() +f = Simple.new_FrameBuffer(400,400) + +# Clear the picture +Simple.FrameBuffer_clear(f,Simple::BLACK) + +# Make a red box +Simple.FrameBuffer_box(f,40,40,200,200,Simple::RED) + +# Make a blue circle +Simple.FrameBuffer_circle(f,200,200,40,Simple::BLUE) + +# Make green line +Simple.FrameBuffer_line(f,10,390,390,200, Simple::GREEN) + +# Write an image out to disk + +Simple.FrameBuffer_writeGIF(f,cmap,"image.gif") +puts "Wrote image.gif" + +Simple.delete_FrameBuffer(f) +Simple.delete_ColorMap(cmap) + diff --git a/Examples/GIFPlot/Ruby/simple/simple.i b/Examples/GIFPlot/Ruby/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Ruby/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/GIFPlot/Tcl/check.list b/Examples/GIFPlot/Tcl/check.list new file mode 100644 index 0000000..2b6e3d2 --- /dev/null +++ b/Examples/GIFPlot/Tcl/check.list @@ -0,0 +1,4 @@ +# see top-level Makefile.in +full +mandel +simple diff --git a/Examples/GIFPlot/Tcl/full/Makefile b/Examples/GIFPlot/Tcl/full/Makefile new file mode 100644 index 0000000..0c016e3 --- /dev/null +++ b/Examples/GIFPlot/Tcl/full/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Include +SRCS = +TARGET = gifplot +INTERFACE = gifplot.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh + +clean:: + $(MAKE) -f $(TOP)/Makefile tcl_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Tcl/full/README b/Examples/GIFPlot/Tcl/full/README new file mode 100644 index 0000000..bdba4e8 --- /dev/null +++ b/Examples/GIFPlot/Tcl/full/README @@ -0,0 +1,8 @@ +This example runs the entire gifplot.h header file through SWIG without +any changes. The script 'runme.tcl' does something a little more +interesting. You'll have to go look at the header file to get a complete +listing of the functions. + + + + diff --git a/Examples/GIFPlot/Tcl/full/cmap b/Examples/GIFPlot/Tcl/full/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239} { set c 239 } + Plot3D_solidquad $p3 $x $y $z1 [expr {$x+$dx}] $y $z2 [expr {$x+$dx}] [expr {$y+$dy}] $z3 $x [expr {$y+$dy}] $z4 [expr {$c+16}] + set y [expr {$y + $dy}] + } + set x [expr {$x + $dx}] + } +} + +puts "Making a nice 3D plot..." +drawsolid + +FrameBuffer_writeGIF $frame $cmap "image.gif" +puts "Wrote image.gif" + diff --git a/Examples/GIFPlot/Tcl/mandel/Makefile b/Examples/GIFPlot/Tcl/mandel/Makefile new file mode 100644 index 0000000..9280d7b --- /dev/null +++ b/Examples/GIFPlot/Tcl/mandel/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Interface +SRCS = +TARGET = gifplot +INTERFACE = mandel.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mywish' INTERFACE='$(INTERFACE)' wish + +clean:: + $(MAKE) -f $(TOP)/Makefile tcl_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Tcl/mandel/README b/Examples/GIFPlot/Tcl/mandel/README new file mode 100644 index 0000000..a533d09 --- /dev/null +++ b/Examples/GIFPlot/Tcl/mandel/README @@ -0,0 +1,6 @@ +Kill lots of time exploring the Mandelbrot set. This example uses +the full SWIG interface file located in ../../Interface. To run +the program, type 'wish mandel.tcl'. + + + diff --git a/Examples/GIFPlot/Tcl/mandel/cmap b/Examples/GIFPlot/Tcl/mandel/cmap new file mode 100644 index 0000000000000000000000000000000000000000..a20c331a9573dd8443380680bfe2cc428780d8a9 GIT binary patch literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC {BoxBegin %W %x %y} + bind $c {BoxDrag %W %x %y} + bind $c "BoxFinish %W %x %y $p2 $mxmin $mymin $mxmax $mymax $func" +} + +proc BoxBegin {w x y} { + global box + set box(anchor) [list $x $y] + catch {unset box(last)} +} + +proc BoxDrag { w x y} { + global box + catch {$w delete $box(last)} + set box(last) [eval {$w create rect} $box(anchor) {$x $y -tag box -outline white}] +} + +proc BoxFinish {w x y p2 mxmin mymin mxmax mymax func } { + global box + set start $box(anchor) + set x1 [lrange $start 0 0] + set y1 [lrange $start 1 1] + catch {$w delete $box(last)} +# Call the handler function + $func $p2 $mxmin $mymin $mxmax $mymax $x1 $y1 $x $y +} + +proc display_image {filename p2 handler} { + global __imageno __images + set i [image create photo -file $filename] + set tl .image$__imageno + toplevel $tl + frame $tl.img + frame $tl.button + + set width [image width $i] + set height [image height $i] + canvas $tl.img.c -width [expr {$width+0}] -height [expr {$height+0}] + pack $tl.img.c + $tl.img.c create image 0 0 -image $i -anchor nw + label $tl.button.label -text $filename + pack $tl.button.label -side left + button $tl.button.dismiss -text "Dismiss" -command "dismiss $tl $i" -width 10 + pack $tl.button.dismiss -side right + pack $tl.img $tl.button -side top -fill x + BoxInit $tl.img.c $p2 [$p2 cget -xmin] [$p2 cget -ymin] [$p2 cget -xmax] [$p2 cget -ymax] $handler + bind $tl "dismiss $tl $i" + bind $tl "dismiss $tl $i" + + # Bind some actions to the canvas + + incr __imageno 1 +} + +proc test {} { + puts "hello" +} + diff --git a/Examples/GIFPlot/Tcl/mandel/mandel.i b/Examples/GIFPlot/Tcl/mandel/mandel.i new file mode 100644 index 0000000..0b19f47 --- /dev/null +++ b/Examples/GIFPlot/Tcl/mandel/mandel.i @@ -0,0 +1,47 @@ +// Special module to run the mandlebrot set +%module gifplot +%include gifplot.i + +%inline %{ + +void mandel(Plot2D *p2, int tol) { + double scalingx; + double scalingy; + double zr,zi,ztr,zti,cr,ci; + double cscale; + int i,j,n; + FrameBuffer *f; + + f = p2->frame; + scalingx = (p2->xmax-p2->xmin)/f->width; + scalingy = (p2->ymax-p2->ymin)/f->height; + + cscale = 239.0/tol; + printf("working...\n"); + for (i = 0; i < f->width; i++) { + for (j = 0; j < f->height; j++) { + zr = scalingx*i + p2->xmin; + zi = scalingy*j + p2->ymin; + cr = zr; + ci = zi; + n = 0; + while (n < tol) { + ztr = zr*zr-zi*zi + cr; + zti = 2*zr*zi + ci; + zr = ztr; + zi = zti; + if (ztr*ztr + zti*zti > 20) break; + n = n + 1; + } + + if (n >= tol) FrameBuffer_plot(f,i,j,BLACK); + else FrameBuffer_plot(f,i,j,16+(int) (n*cscale)); + } + if ((i % 10) == 0) printf("%d\n",i); + } + +} + +%} + + diff --git a/Examples/GIFPlot/Tcl/mandel/mandel.tcl b/Examples/GIFPlot/Tcl/mandel/mandel.tcl new file mode 100644 index 0000000..3e1600b --- /dev/null +++ b/Examples/GIFPlot/Tcl/mandel/mandel.tcl @@ -0,0 +1,170 @@ +catch { load ./gifplot[info sharedlibextension] } +source display.tcl +set tcl_precision 17 +set f [FrameBuffer -args 400 400] +set cmap [ColorMap -args cmap] +set p2 [Plot2D -args $f -3 -2 1 2] + +set xmin -3 +set xmax 1 +set ymin -2.0 +set ymax 2.0 +set tolerance 240 +set filename mandel.gif + +# Make a plot from the above parms + +proc make_plot {} { + global p2 cmap tolerance + global xmin ymin xmax ymax filename + $p2 setrange $xmin $ymin $xmax $ymax + $p2 start + . config -cursor watch + update + mandel $p2 $tolerance + . config -cursor arrow + [$p2 cget -frame] writeGIF $cmap $filename + display_image $filename $p2 set_zoom +} + + +# Take some screen coordinates and set global min and max values + +proc set_zoom {p2 mxmin mymin mxmax mymax x1 y1 x2 y2} { + global xmin ymin xmax ymax + + set frame [$p2 cget -frame] + set width [$frame cget -width] + set height [$frame cget -height] + + if {$x1 < 0} {set x1 0} + if {$x1 > ($width)} {set x1 $width} + if {$x2 < 0} {set x2 0} + if {$x2 > ($width)} {set x2 $width} + if {$x1 < $x2} {set ixmin $x1; set ixmax $x2} {set ixmin $x2; set ixmax $x1} + + if {$y1 < 0} {set y1 0} + if {$y1 > ($height)} {set y1 $height} + if {$y2 < 0} {set y2 0} + if {$y2 > ($height)} {set y2 $height} + if {$y1 < $y2} {set iymin $y1; set iymax $y2} {set iymin $y2; set iymax $y1} + + # Now determine new min and max values based on screen location + + set xmin [expr {$mxmin + ($mxmax-$mxmin)*($ixmin)/($width)}] + set xmax [expr {$mxmin + ($mxmax-$mxmin)*($ixmax)/($width)}] + set ymin [expr {$mymin + ($mymax-$mymin)*(($height)-($iymax))/($height)}] + set ymax [expr {$mymin + ($mymax-$mymin)*(($height)-($iymin))/($height)}] + + catch {make_plot} +} + +# Box drag constrained to a square +proc BoxDrag { w x y} { + global box + catch {$w delete $box(last)} + set x1 [lrange $box(anchor) 0 0] + set y1 [lrange $box(anchor) 1 1] + set dx [expr {$x - $x1}] + set dy [expr {$y - $y1}] + if {abs($dy) > abs($dx)} {set dx $dy} + set newx [expr {$x1 + $dx}] + set newy [expr {$y1 + $dx}] + set box(last) [eval {$w create rect} $box(anchor) {$newx $newy -tag box -outline white}] +} + + +proc BoxFinish {w x y p2 mxmin mymin mxmax mymax func } { + global box + set start $box(anchor) + set x1 [lrange $box(anchor) 0 0] + set y1 [lrange $box(anchor) 1 1] + set dx [expr {$x - $x1}] + set dy [expr {$y - $y1}] + if {($dx == 0) || ($dy == 0)} { + catch {$w delete $box(last)} + return + } + if {abs($dy) > abs($dx)} {set dx $dy} + set newx [expr {$x1 + $dx}] + set newy [expr {$y1 + $dx}] + $w config -cursor watch + update +# Call the handler function + $func $p2 $mxmin $mymin $mxmax $mymax $x1 $y1 $newx $newy + catch {$w delete $box(last)} + $w config -cursor arrow +} + + +# Create a few frames + +wm title . Mandelbrot +frame .title -relief groove -borderwidth 1 +label .title.name -text "Mandelbrot Set" +button .title.quit -text "Quit" -command "exit" +button .title.about -text "About" -command "about" +pack .title.name -side left +pack .title.quit .title.about -side right + +frame .func -relief groove -borderwidth 1 + +frame .func.xrange +label .func.xrange.xrlabel -text "X range" -width 12 +entry .func.xrange.xmin -textvar xmin -width 8 +label .func.xrange.xtolabel -text "to" +entry .func.xrange.xmax -textvar xmax -width 8 +pack .func.xrange.xrlabel .func.xrange.xmin .func.xrange.xtolabel .func.xrange.xmax -side left + +frame .func.yrange +label .func.yrange.yrlabel -text "Y range" -width 12 +entry .func.yrange.ymin -textvar ymin -width 8 +label .func.yrange.ytolabel -text "to" +entry .func.yrange.ymax -textvar ymax -width 8 +pack .func.yrange.yrlabel .func.yrange.ymin .func.yrange.ytolabel .func.yrange.ymax -side left + +frame .func.npoints +label .func.npoints.label -text "Tolerance " -width 12 +entry .func.npoints.npoints -textvar tolerance -width 8 +scale .func.npoints.scale -from 0 -to 2500 -variable tolerance -orient horizontal -showvalue false \ + -sliderlength 13 -bigincrement 10 -resolution 10 +pack .func.npoints.label .func.npoints.npoints .func.npoints.scale -side left + +pack .func.xrange .func.yrange .func.npoints -side top -fill x + +# Filename dialog + +frame .save -relief groove -borderwidth 1 + +frame .save.file +label .save.file.label -text "Save as" -width 12 +entry .save.file.filename -textvar filename -width 20 +pack .save.file.label .save.file.filename -side left +pack .save.file -side left -fill x +button .save.go -text "Plot" -command "make_plot" +pack .save.go -side right + +bind .save.file.filename {make_plot} + +pack .title .func .save -side top -fill both + +proc about { } { + toplevel .about -width 350 + + message .about.m -text "\ +Mandelbrot Set\n\n\ +Copyright (c) 1997\n\ +Dave Beazley\n\ +University of Utah\n\n\ +Creates a plot of the Mandelbrot set. Any displayed image can be zoomed by clicking and \ +dragging. Although the main calculation is written in C, it may take awhile for each \ +image to be calculated (be patient). Image quality can be improved at the expense of speed \ +by increasing the tolerance value.\n" + +button .about.okay -text "Ok" -command {destroy .about} + +pack .about.m .about.okay -side top +focus .about.okay +} + +make_plot diff --git a/Examples/GIFPlot/Tcl/simple/Makefile b/Examples/GIFPlot/Tcl/simple/Makefile new file mode 100644 index 0000000..752d79c --- /dev/null +++ b/Examples/GIFPlot/Tcl/simple/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +SWIG = $(TOP)/../swig +SWIGOPT = +SRCS = +TARGET = simple +INTERFACE = simple.i +LIBS = -L../.. -lgifplot +INCLUDES = -I../../Include + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ + TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh + +clean:: + $(MAKE) -f $(TOP)/Makefile tcl_clean + rm -f *.gif + +check: all diff --git a/Examples/GIFPlot/Tcl/simple/README b/Examples/GIFPlot/Tcl/simple/README new file mode 100644 index 0000000..d6b291c --- /dev/null +++ b/Examples/GIFPlot/Tcl/simple/README @@ -0,0 +1,5 @@ +This is a very minimalistic example in which just a few functions +and constants from library are wrapped and used to draw some simple +shapes. The script 'runme.tcl' runs the example. + + diff --git a/Examples/GIFPlot/Tcl/simple/runme.tcl b/Examples/GIFPlot/Tcl/simple/runme.tcl new file mode 100644 index 0000000..e3f4126 --- /dev/null +++ b/Examples/GIFPlot/Tcl/simple/runme.tcl @@ -0,0 +1,27 @@ +# Draw some simple shapes +puts "Drawing some basic shapes" + +catch { load ./simple[info sharedlibextension] simple} + +set cmap [new_ColorMap] +set f [new_FrameBuffer 400 400] + +# Clear the picture +FrameBuffer_clear $f $BLACK + +# Make a red box +FrameBuffer_box $f 40 40 200 200 $RED + +# Make a blue circle +FrameBuffer_circle $f 200 200 40 $BLUE + +# Make green line +FrameBuffer_line $f 10 390 390 200 $GREEN + +# Write an image out to disk +FrameBuffer_writeGIF $f $cmap image.gif +puts "Wrote image.gif" + +delete_FrameBuffer $f +delete_ColorMap $cmap + diff --git a/Examples/GIFPlot/Tcl/simple/simple.i b/Examples/GIFPlot/Tcl/simple/simple.i new file mode 100644 index 0000000..457bc4c --- /dev/null +++ b/Examples/GIFPlot/Tcl/simple/simple.i @@ -0,0 +1,38 @@ +/* This example shows a very simple interface wrapping a few + primitive declarations */ + +%module simple +%{ +#include "gifplot.h" +%} + +typedef unsigned char Pixel; + +/* Here are a few useful functions */ + +ColorMap *new_ColorMap(char *filename = 0); +void delete_ColorMap(ColorMap *cmap); + +FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); +void delete_FrameBuffer(FrameBuffer *frame); +void FrameBuffer_clear(FrameBuffer *frame, Pixel color); +void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); +void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); +int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); + +/* And some useful constants */ + +#define BLACK 0 +#define WHITE 1 +#define RED 2 +#define GREEN 3 +#define BLUE 4 +#define YELLOW 5 +#define CYAN 6 +#define MAGENTA 7 + + + + + diff --git a/Examples/Makefile.in b/Examples/Makefile.in new file mode 100644 index 0000000..16f3cfb --- /dev/null +++ b/Examples/Makefile.in @@ -0,0 +1,1138 @@ +# ------------------------------------------------------------ +# 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 varibles, 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 = @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= + +# X11 options + +XLIB = @XLIBSW@ +XINCLUDE = @XINCLUDES@ + +IWRAP = $(INTERFACE:.i=_wrap.i) +ISRCS = $(IWRAP:.i=.c) +ICXXSRCS = $(IWRAP:.i=.cxx) +IOBJS = $(IWRAP:.i=.@OBJEXT@) + +################################################################## +# 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@) + +################################################################## +##### Tcl/Tk ###### +################################################################## + +# Set these to your local copy of Tcl/Tk. + +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@ + +# ----------------------------------------------------------- +# 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) + +# ----------------------------------------------------------------- +# 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@ + +# ---------------------------------------------------------------- +# Build a Perl5 dynamically loadable module (C) +# ---------------------------------------------------------------- + +perl5: $(SRCS) + $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(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) -I$(PERL5_INCLUDE) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(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_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) + +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) + +# ----------------------------------------------------------------- +# 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 = runme3.py +endif + +PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` + +python_run: $(PYSCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null + +runme3.py: runme.py + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + +# ----------------------------------------------------------------- +# Cleaning the python examples +# ----------------------------------------------------------------- + +python_clean: + rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ + if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi + + +################################################################## +##### OCTAVE ###### +################################################################## + +# Make sure these locate your Octave installation +OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@ +OCTAVE_LIB = + +# Extra Octave specific dynamic linking options +OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@ +OCTAVE_SO = @OCTAVE_SO@ + +# ---------------------------------------------------------------- +# 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) -I$(OCTAVE_INCLUDE) + $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(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) -I$(OCTAVE_INCLUDE) + $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) + +# ----------------------------------------------------------------- +# Cleaning the octave examples +# ----------------------------------------------------------------- + +octave_clean: + 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_INCLUDE = @GUILEINCLUDE@ +GUILE_LIB = @GUILELIB@ +GUILE_SO = @GUILE_SO@ +GUILE_LIBPREFIX = lib + +#------------------------------------------------------------------ +# Build a dynamically loaded module with passive linkage and the scm interface +#------------------------------------------------------------------ +guile: $(SRCS) + $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + +guile_cpp: $(SRCS) + $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + +guile_externalhdr: + $(SWIG) -guile -external-runtime $(TARGET) + +#------------------------------------------------------------------ +# Build a dynamically loaded module with passive linkage and the gh interface +#------------------------------------------------------------------ +guile_gh: $(SRCS) + $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + +guile_gh_cpp: $(SRCS) + $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + +# ----------------------------------------------------------------- +# Build a dynamically loadable module with passive linkage +# ----------------------------------------------------------------- + +guile_passive: $(SRCS) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + +guile_passive_cpp: $(SRCS) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + +# ----------------------------------------------------------------- +# Build statically linked Guile interpreter +# ----------------------------------------------------------------- + +GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) + +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_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(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_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + +guile_simple: $(SRCS) + $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) + $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ + $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(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_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + +# ----------------------------------------------------------------- +# 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@ + +# ---------------------------------------------------------------- +# 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) + +# ----------------------------------------------------------------- +# 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@ + +################################################################## +##### 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) + +# ----------------------------------------------------------------- +# Cleaning the modula3 examples +# ----------------------------------------------------------------- + +modula3_clean: + rm -f *_wrap* *.i3 *.m3 + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ + +################################################################## +##### MZSCHEME ###### +################################################################## + +MZC = @MZC@ +MZDYNOBJ = @MZDYNOBJ@ +MZSCHEME_SO = @MZSCHEME_SO@ + +# ---------------------------------------------------------------- +# 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) + +# ----------------------------------------------------------------- +# 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)' -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)' + +ocaml_static_cpp_toplevel: $(SRCS) + $(OCAMLCORE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) + cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) + $(OCC) -cc '$(CXX)' -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) 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)' + +ocaml_dynamic_cpp: $(SRCS) + $(OCAMLCORE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) + cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) + $(OCC) -cc '$(CXX)' -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)' + +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@ + +# ---------------------------------------------------------------- +# 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)$(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)$(SO) + +# ----------------------------------------------------------------- +# Build statically linked Ruby interpreter +# +# These should only be used in conjunction with the %include embed.i +# library file +# ----------------------------------------------------------------- + +RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) + +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) + + +# ----------------------------------------------------------------- +# Cleaning the Ruby examples +# ----------------------------------------------------------------- + +ruby_clean: + rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ + +################################################################## +##### PHP ###### +################################################################## + +# ------------------------------------------------------------------- +# Build a PHP dynamically loadable module (C) +# ------------------------------------------------------------------- + +PHP_INCLUDE = @PHPINC@ +PHP_SO = @PHP_SO@ + +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=@PHP@ +PHPSCRIPT ?= runme.php + +php_run: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) + +# ----------------------------------------------------------------- +# 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_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H +PIKE_INCLUDE = @PIKEINCLUDE@ +PIKE_LIB = @PIKELIB@ +PIKE_DLNK = @PIKEDYNAMICLINKING@ + +# ---------------------------------------------------------------- +# 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_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) + +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) + +# ----------------------------------------------------------------- +# 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_LIBOPTS = @CHICKENLIB@ $(SYSLIBS) +CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) +CHICKEN_CFLAGS = @CHICKENOPTS@ +CHICKENOPTS = -quiet +CHICKEN_MAIN = + +# 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) + +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@ + +# ---------------------------------------------------------------- +# 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) + +# ----------------------------------------------------------------- +# 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@ + +# 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) + +# ----------------------------------------------------------------- +# Cleaning the lua examples +# ----------------------------------------------------------------- + +lua_clean: + rm -f *_wrap* *~ .~* mylua@EXEEXT@ + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ + +################################################################## +##### ALLEGRO CL ###### +################################################################## + +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) + +allegrocl_clean: + rm -f *_wrap* *~ .~* + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ + +################################################################## +##### CLISP ###### +################################################################## + +clisp: $(SRCS) + $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) + +clisp_cpp: $(SRCS) + $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) + +clisp_clean: + rm -f *_wrap* *~ .~* + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ + +################################################################## +##### CFFI ###### +################################################################## + +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) + +cffi_clean: + rm -f *_wrap* *~ .~* + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ + +################################################################## +##### UFFI ###### +################################################################## + +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) + +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: $(SRCS) + $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) + +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +r_cpp: $(CXXSRCS) + $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) + +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) + +r_clean: + rm -f *_wrap* *~ .~* + rm -f core @EXTRA_CLEAN@ + rm -f *.@OBJEXT@ *@SO@ NAMESPACE + rm -f $(RRSRC) runme.Rout .RData + diff --git a/Examples/README b/Examples/README new file mode 100644 index 0000000..0747547 --- /dev/null +++ b/Examples/README @@ -0,0 +1,49 @@ +SWIG 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 "GIFPlot" directory contains a more +complicated example that illustrates some of SWIG's more advanced +capabilities. + +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. diff --git a/Examples/chicken/README b/Examples/chicken/README new file mode 100644 index 0000000..d4f91ba --- /dev/null +++ b/Examples/chicken/README @@ -0,0 +1,12 @@ +This 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. diff --git a/Examples/chicken/check.list b/Examples/chicken/check.list new file mode 100644 index 0000000..9ea022b --- /dev/null +++ b/Examples/chicken/check.list @@ -0,0 +1,6 @@ +# see top-level Makefile.in +class +constants +multimap +overload +simple diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile new file mode 100644 index 0000000..1261ec5 --- /dev/null +++ b/Examples/chicken/class/Makefile @@ -0,0 +1,38 @@ +TOP = ../.. +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 = test-lowlevel-class.scm +#CHICKEN_MAIN = test-tinyclos-class.scm +#VARIANT = _static + +all:: $(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) + +check:: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm diff --git a/Examples/chicken/class/example.cxx b/Examples/chicken/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/chicken/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/chicken/class/example.h b/Examples/chicken/class/example.h new file mode 100644 index 0000000..210ba98 --- /dev/null +++ b/Examples/chicken/class/example.h @@ -0,0 +1,46 @@ +/* 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); +}; + + + + + diff --git a/Examples/chicken/class/example.i b/Examples/chicken/class/example.i new file mode 100644 index 0000000..75700b3 --- /dev/null +++ b/Examples/chicken/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/chicken/class/test-lowlevel-class.scm b/Examples/chicken/class/test-lowlevel-class.scm new file mode 100644 index 0000000..7c59c0a --- /dev/null +++ b/Examples/chicken/class/test-lowlevel-class.scm @@ -0,0 +1,76 @@ +;; 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) diff --git a/Examples/chicken/class/test-tinyclos-class.scm b/Examples/chicken/class/test-tinyclos-class.scm new file mode 100644 index 0000000..5ba1d6a --- /dev/null +++ b/Examples/chicken/class/test-tinyclos-class.scm @@ -0,0 +1,76 @@ +;; 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) diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile new file mode 100644 index 0000000..81308fc --- /dev/null +++ b/Examples/chicken/constants/Makefile @@ -0,0 +1,30 @@ +TOP = ../.. +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 = test-constants.scm +#VARIANT = _static + +all:: $(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) + +check:: + csi test-constants.scm diff --git a/Examples/chicken/constants/example.i b/Examples/chicken/constants/example.i new file mode 100644 index 0000000..0995c19 --- /dev/null +++ b/Examples/chicken/constants/example.i @@ -0,0 +1,27 @@ +/* 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; diff --git a/Examples/chicken/constants/test-constants.scm b/Examples/chicken/constants/test-constants.scm new file mode 100644 index 0000000..1b10b26 --- /dev/null +++ b/Examples/chicken/constants/test-constants.scm @@ -0,0 +1,16 @@ +;; 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) diff --git a/Examples/chicken/egg/Makefile b/Examples/chicken/egg/Makefile new file mode 100644 index 0000000..bdf71b1 --- /dev/null +++ b/Examples/chicken/egg/Makefile @@ -0,0 +1,39 @@ +SWIG = ../../../preinst-swig + +all: 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 + +# complie 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 + +check: + cd eggs/install && csi ../../test.scm diff --git a/Examples/chicken/egg/README b/Examples/chicken/egg/README new file mode 100644 index 0000000..b5df0e6 --- /dev/null +++ b/Examples/chicken/egg/README @@ -0,0 +1,19 @@ +These 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. diff --git a/Examples/chicken/egg/mod1.i b/Examples/chicken/egg/mod1.i new file mode 100644 index 0000000..6a2940b --- /dev/null +++ b/Examples/chicken/egg/mod1.i @@ -0,0 +1,8 @@ +%module mod1 + +%inline %{ +class Bar { + public: + int b; +}; +%} diff --git a/Examples/chicken/egg/mod2.i b/Examples/chicken/egg/mod2.i new file mode 100644 index 0000000..e9ae4a6 --- /dev/null +++ b/Examples/chicken/egg/mod2.i @@ -0,0 +1,17 @@ +%module mod2 + +%import "mod1.i" + +%{ +class Bar { + public: + int b; +}; +%} + +%inline %{ + class Bar2 : public Bar { + public: + int c; + }; +%} diff --git a/Examples/chicken/egg/multi.setup b/Examples/chicken/egg/multi.setup new file mode 100644 index 0000000..95aeb00 --- /dev/null +++ b/Examples/chicken/egg/multi.setup @@ -0,0 +1,2 @@ +(run (csc -s -o multi.so multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx)) +(install-extension 'multi '("multi.so")) diff --git a/Examples/chicken/egg/multi_init.scm b/Examples/chicken/egg/multi_init.scm new file mode 100644 index 0000000..600491d --- /dev/null +++ b/Examples/chicken/egg/multi_init.scm @@ -0,0 +1,2 @@ +(declare (uses mod1)) +(declare (uses mod2)) diff --git a/Examples/chicken/egg/single.i b/Examples/chicken/egg/single.i new file mode 100644 index 0000000..46266b4 --- /dev/null +++ b/Examples/chicken/egg/single.i @@ -0,0 +1,8 @@ +%module single + +%inline %{ +class Foo { + public: + int a; +}; +%} diff --git a/Examples/chicken/egg/single.setup b/Examples/chicken/egg/single.setup new file mode 100644 index 0000000..4b503ec --- /dev/null +++ b/Examples/chicken/egg/single.setup @@ -0,0 +1,2 @@ +(run (csc -s -o single.so single.scm single_wrap.cxx)) +(install-extension 'single '("single.so")) diff --git a/Examples/chicken/egg/test.scm b/Examples/chicken/egg/test.scm new file mode 100644 index 0000000..4ec94ed --- /dev/null +++ b/Examples/chicken/egg/test.scm @@ -0,0 +1,18 @@ +(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) diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile new file mode 100644 index 0000000..dace61a --- /dev/null +++ b/Examples/chicken/multimap/Makefile @@ -0,0 +1,30 @@ +TOP = ../.. +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 = test-multimap.scm +#VARIANT = _static + +all:: $(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) + +check:: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm diff --git a/Examples/chicken/multimap/example.c b/Examples/chicken/multimap/example.c new file mode 100644 index 0000000..b8360fa --- /dev/null +++ b/Examples/chicken/multimap/example.c @@ -0,0 +1,53 @@ +/* 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); + } +} diff --git a/Examples/chicken/multimap/example.i b/Examples/chicken/multimap/example.i new file mode 100644 index 0000000..02567f4 --- /dev/null +++ b/Examples/chicken/multimap/example.i @@ -0,0 +1,96 @@ +/* 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; +}; +%} diff --git a/Examples/chicken/multimap/test-multimap.scm b/Examples/chicken/multimap/test-multimap.scm new file mode 100644 index 0000000..3a6b46e --- /dev/null +++ b/Examples/chicken/multimap/test-multimap.scm @@ -0,0 +1,59 @@ +;; run with './multimap test-multimap.scm' +;; 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) diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile new file mode 100644 index 0000000..48ec43a --- /dev/null +++ b/Examples/chicken/overload/Makefile @@ -0,0 +1,30 @@ +TOP = ../.. +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 = test-overload.scm +#VARIANT = _static + +all:: $(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) + +check:: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm diff --git a/Examples/chicken/overload/README b/Examples/chicken/overload/README new file mode 100644 index 0000000..9487c3f --- /dev/null +++ b/Examples/chicken/overload/README @@ -0,0 +1,2 @@ +Overloading example from Chapter 5.14 of SWIG Core Documentation for +version 1.3. diff --git a/Examples/chicken/overload/example.cxx b/Examples/chicken/overload/example.cxx new file mode 100644 index 0000000..65e7439 --- /dev/null +++ b/Examples/chicken/overload/example.cxx @@ -0,0 +1,33 @@ +/* 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); +} diff --git a/Examples/chicken/overload/example.h b/Examples/chicken/overload/example.h new file mode 100644 index 0000000..1c135d5 --- /dev/null +++ b/Examples/chicken/overload/example.h @@ -0,0 +1,14 @@ +/* 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); +}; diff --git a/Examples/chicken/overload/example.i b/Examples/chicken/overload/example.i new file mode 100644 index 0000000..23a2998 --- /dev/null +++ b/Examples/chicken/overload/example.i @@ -0,0 +1,16 @@ +/* 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" + diff --git a/Examples/chicken/overload/test-overload.scm b/Examples/chicken/overload/test-overload.scm new file mode 100644 index 0000000..168490f --- /dev/null +++ b/Examples/chicken/overload/test-overload.scm @@ -0,0 +1,45 @@ +;; 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) diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile new file mode 100644 index 0000000..bb78142 --- /dev/null +++ b/Examples/chicken/simple/Makefile @@ -0,0 +1,30 @@ +TOP = ../.. +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 = test-simple.scm +#VARIANT = _static + +all:: $(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) + +check:: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm diff --git a/Examples/chicken/simple/README b/Examples/chicken/simple/README new file mode 100644 index 0000000..07e8da0 --- /dev/null +++ b/Examples/chicken/simple/README @@ -0,0 +1 @@ +Simple example from users manual. diff --git a/Examples/chicken/simple/example.c b/Examples/chicken/simple/example.c new file mode 100644 index 0000000..f2b0747 --- /dev/null +++ b/Examples/chicken/simple/example.c @@ -0,0 +1,24 @@ +/* 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); +} diff --git a/Examples/chicken/simple/example.i b/Examples/chicken/simple/example.i new file mode 100644 index 0000000..5b3e955 --- /dev/null +++ b/Examples/chicken/simple/example.i @@ -0,0 +1,16 @@ +/* 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(); +%} diff --git a/Examples/chicken/simple/test-simple.scm b/Examples/chicken/simple/test-simple.scm new file mode 100644 index 0000000..05aa870 --- /dev/null +++ b/Examples/chicken/simple/test-simple.scm @@ -0,0 +1,28 @@ +;; 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) diff --git a/Examples/chicken/zlib/Makefile b/Examples/chicken/zlib/Makefile new file mode 100644 index 0000000..7207014 --- /dev/null +++ b/Examples/chicken/zlib/Makefile @@ -0,0 +1,28 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = example.i +SRCS = +CXXSRCS = +TARGET = zlib +INCLUDE = +SWIGOPT = -I/usr/include +CFLAGS = +VARIANT = +LIBS = -lz +VARIANT = _direct + +all:: $(TARGET) + +$(TARGET): $(INTERFACE) $(SRCS) + $(MAKE) -f $(TOP)/Makefile \ + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + +clean:: + $(MAKE) -f $(TOP)/Makefile chicken_clean + rm -f example.scm + rm -f $(TARGET) + +check:: + csi test-zlib.scm diff --git a/Examples/chicken/zlib/README.html b/Examples/chicken/zlib/README.html new file mode 100644 index 0000000..b082a31 --- /dev/null +++ b/Examples/chicken/zlib/README.html @@ -0,0 +1,1666 @@ + + + + zlib - Chicken - SWIG example + + +

    zlib - Chicken - SWIG

    + +

    Table of Contents

    + Building the example
    + zlib.h
    + How the zlib wrapper was developed
    + +

    Building the example

    + + zlib must be installed for this example to work.
    + + Just type make to build this example.
    + + If zlib is not installed in /usr/lib and /usr/include, then do + something similar to the following: + +
    +
    make SWIGOPT="-I/usr/local/include" LIBS="-L/usr/local/lib -lz"
    +
    + +

    zlib.h

    +
    +
    +001: /* zlib.h -- interface of the 'zlib' general purpose compression library
    +002:   version 1.1.4, March 11th, 2002
    +003: 
    +004:   Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
    +005: 
    +006:   This software is provided 'as-is', without any express or implied
    +007:   warranty.  In no event will the authors be held liable for any damages
    +008:   arising from the use of this software.
    +009: 
    +010:   Permission is granted to anyone to use this software for any purpose,
    +011:   including commercial applications, and to alter it and redistribute it
    +012:   freely, subject to the following restrictions:
    +013: 
    +014:   1. The origin of this software must not be misrepresented; you must not
    +015:      claim that you wrote the original software. If you use this software
    +016:      in a product, an acknowledgment in the product documentation would be
    +017:      appreciated but is not required.
    +018:   2. Altered source versions must be plainly marked as such, and must not be
    +019:      misrepresented as being the original software.
    +020:   3. This notice may not be removed or altered from any source distribution.
    +021: 
    +022:   Jean-loup Gailly        Mark Adler
    +023:   jloup@gzip.org          madler@alumni.caltech.edu
    +024: 
    +025: 
    +026:   The data format used by the zlib library is described by RFCs (Request for
    +027:   Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
    +028:   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
    +029: */
    +030: 
    +031: #ifndef _ZLIB_H
    +032: #define _ZLIB_H
    +033: 
    +034: #include "zconf.h"
    +035: 
    +036: #ifdef __cplusplus
    +037: extern "C" {
    +038: #endif
    +039: 
    +040: #define ZLIB_VERSION "1.1.4"
    +041: 
    +042: /* 
    +043:      The 'zlib' compression library provides in-memory compression and
    +044:   decompression functions, including integrity checks of the uncompressed
    +045:   data.  This version of the library supports only one compression method
    +046:   (deflation) but other algorithms will be added later and will have the same
    +047:   stream interface.
    +048: 
    +049:      Compression can be done in a single step if the buffers are large
    +050:   enough (for example if an input file is mmap'ed), or can be done by
    +051:   repeated calls of the compression function.  In the latter case, the
    +052:   application must provide more input and/or consume the output
    +053:   (providing more output space) before each call.
    +054: 
    +055:      The library also supports reading and writing files in gzip (.gz) format
    +056:   with an interface similar to that of stdio.
    +057: 
    +058:      The library does not install any signal handler. The decoder checks
    +059:   the consistency of the compressed data, so the library should never
    +060:   crash even in case of corrupted input.
    +061: */
    +062: 
    +063: typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
    +064: typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
    +065: 
    +066: struct internal_state;
    +067: 
    +068: typedef struct z_stream_s {
    +069:     Bytef    *next_in;  /* next input byte */
    +070:     uInt     avail_in;  /* number of bytes available at next_in */
    +071:     uLong    total_in;  /* total nb of input bytes read so far */
    +072: 
    +073:     Bytef    *next_out; /* next output byte should be put there */
    +074:     uInt     avail_out; /* remaining free space at next_out */
    +075:     uLong    total_out; /* total nb of bytes output so far */
    +076: 
    +077:     char     *msg;      /* last error message, NULL if no error */
    +078:     struct internal_state FAR *state; /* not visible by applications */
    +079: 
    +080:     alloc_func zalloc;  /* used to allocate the internal state */
    +081:     free_func  zfree;   /* used to free the internal state */
    +082:     voidpf     opaque;  /* private data object passed to zalloc and zfree */
    +083: 
    +084:     int     data_type;  /* best guess about the data type: ascii or binary */
    +085:     uLong   adler;      /* adler32 value of the uncompressed data */
    +086:     uLong   reserved;   /* reserved for future use */
    +087: } z_stream;
    +088: 
    +089: typedef z_stream FAR *z_streamp;
    +090: 
    +091: /*
    +092:    The application must update next_in and avail_in when avail_in has
    +093:    dropped to zero. It must update next_out and avail_out when avail_out
    +094:    has dropped to zero. The application must initialize zalloc, zfree and
    +095:    opaque before calling the init function. All other fields are set by the
    +096:    compression library and must not be updated by the application.
    +097: 
    +098:    The opaque value provided by the application will be passed as the first
    +099:    parameter for calls of zalloc and zfree. This can be useful for custom
    +100:    memory management. The compression library attaches no meaning to the
    +101:    opaque value.
    +102: 
    +103:    zalloc must return Z_NULL if there is not enough memory for the object.
    +104:    If zlib is used in a multi-threaded application, zalloc and zfree must be
    +105:    thread safe.
    +106: 
    +107:    On 16-bit systems, the functions zalloc and zfree must be able to allocate
    +108:    exactly 65536 bytes, but will not be required to allocate more than this
    +109:    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
    +110:    pointers returned by zalloc for objects of exactly 65536 bytes *must*
    +111:    have their offset normalized to zero. The default allocation function
    +112:    provided by this library ensures this (see zutil.c). To reduce memory
    +113:    requirements and avoid any allocation of 64K objects, at the expense of
    +114:    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
    +115: 
    +116:    The fields total_in and total_out can be used for statistics or
    +117:    progress reports. After compression, total_in holds the total size of
    +118:    the uncompressed data and may be saved for use in the decompressor
    +119:    (particularly if the decompressor wants to decompress everything in
    +120:    a single step).
    +121: */
    +122: 
    +123:                         /* constants */
    +124: 
    +125: #define Z_NO_FLUSH      0
    +126: #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
    +127: #define Z_SYNC_FLUSH    2
    +128: #define Z_FULL_FLUSH    3
    +129: #define Z_FINISH        4
    +130: /* Allowed flush values; see deflate() below for details */
    +131: 
    +132: #define Z_OK            0
    +133: #define Z_STREAM_END    1
    +134: #define Z_NEED_DICT     2
    +135: #define Z_ERRNO        (-1)
    +136: #define Z_STREAM_ERROR (-2)
    +137: #define Z_DATA_ERROR   (-3)
    +138: #define Z_MEM_ERROR    (-4)
    +139: #define Z_BUF_ERROR    (-5)
    +140: #define Z_VERSION_ERROR (-6)
    +141: /* Return codes for the compression/decompression functions. Negative
    +142:  * values are errors, positive values are used for special but normal events.
    +143:  */
    +144: 
    +145: #define Z_NO_COMPRESSION         0
    +146: #define Z_BEST_SPEED             1
    +147: #define Z_BEST_COMPRESSION       9
    +148: #define Z_DEFAULT_COMPRESSION  (-1)
    +149: /* compression levels */
    +150: 
    +151: #define Z_FILTERED            1
    +152: #define Z_HUFFMAN_ONLY        2
    +153: #define Z_DEFAULT_STRATEGY    0
    +154: /* compression strategy; see deflateInit2() below for details */
    +155: 
    +156: #define Z_BINARY   0
    +157: #define Z_ASCII    1
    +158: #define Z_UNKNOWN  2
    +159: /* Possible values of the data_type field */
    +160: 
    +161: #define Z_DEFLATED   8
    +162: /* The deflate compression method (the only one supported in this version) */
    +163: 
    +164: #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
    +165: 
    +166: #define zlib_version zlibVersion()
    +167: /* for compatibility with versions < 1.0.2 */
    +168: 
    +169:                         /* basic functions */
    +170: 
    +171: ZEXTERN const char * ZEXPORT zlibVersion OF((void));
    +172: /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
    +173:    If the first character differs, the library code actually used is
    +174:    not compatible with the zlib.h header file used by the application.
    +175:    This check is automatically made by deflateInit and inflateInit.
    +176:  */
    +177: 
    +178: /* 
    +179: ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
    +180: 
    +181:      Initializes the internal stream state for compression. The fields
    +182:    zalloc, zfree and opaque must be initialized before by the caller.
    +183:    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
    +184:    use default allocation functions.
    +185: 
    +186:      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
    +187:    1 gives best speed, 9 gives best compression, 0 gives no compression at
    +188:    all (the input data is simply copied a block at a time).
    +189:    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
    +190:    compression (currently equivalent to level 6).
    +191: 
    +192:      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
    +193:    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
    +194:    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
    +195:    with the version assumed by the caller (ZLIB_VERSION).
    +196:    msg is set to null if there is no error message.  deflateInit does not
    +197:    perform any compression: this will be done by deflate().
    +198: */
    +199: 
    +200: 
    +201: ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
    +202: /*
    +203:     deflate compresses as much data as possible, and stops when the input
    +204:   buffer becomes empty or the output buffer becomes full. It may introduce some
    +205:   output latency (reading input without producing any output) except when
    +206:   forced to flush.
    +207: 
    +208:     The detailed semantics are as follows. deflate performs one or both of the
    +209:   following actions:
    +210: 
    +211:   - Compress more input starting at next_in and update next_in and avail_in
    +212:     accordingly. If not all input can be processed (because there is not
    +213:     enough room in the output buffer), next_in and avail_in are updated and
    +214:     processing will resume at this point for the next call of deflate().
    +215: 
    +216:   - Provide more output starting at next_out and update next_out and avail_out
    +217:     accordingly. This action is forced if the parameter flush is non zero.
    +218:     Forcing flush frequently degrades the compression ratio, so this parameter
    +219:     should be set only when necessary (in interactive applications).
    +220:     Some output may be provided even if flush is not set.
    +221: 
    +222:   Before the call of deflate(), the application should ensure that at least
    +223:   one of the actions is possible, by providing more input and/or consuming
    +224:   more output, and updating avail_in or avail_out accordingly; avail_out
    +225:   should never be zero before the call. The application can consume the
    +226:   compressed output when it wants, for example when the output buffer is full
    +227:   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
    +228:   and with zero avail_out, it must be called again after making room in the
    +229:   output buffer because there might be more output pending.
    +230: 
    +231:     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
    +232:   flushed to the output buffer and the output is aligned on a byte boundary, so
    +233:   that the decompressor can get all input data available so far. (In particular
    +234:   avail_in is zero after the call if enough output space has been provided
    +235:   before the call.)  Flushing may degrade compression for some compression
    +236:   algorithms and so it should be used only when necessary.
    +237: 
    +238:     If flush is set to Z_FULL_FLUSH, all output is flushed as with
    +239:   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
    +240:   restart from this point if previous compressed data has been damaged or if
    +241:   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
    +242:   the compression.
    +243: 
    +244:     If deflate returns with avail_out == 0, this function must be called again
    +245:   with the same value of the flush parameter and more output space (updated
    +246:   avail_out), until the flush is complete (deflate returns with non-zero
    +247:   avail_out).
    +248: 
    +249:     If the parameter flush is set to Z_FINISH, pending input is processed,
    +250:   pending output is flushed and deflate returns with Z_STREAM_END if there
    +251:   was enough output space; if deflate returns with Z_OK, this function must be
    +252:   called again with Z_FINISH and more output space (updated avail_out) but no
    +253:   more input data, until it returns with Z_STREAM_END or an error. After
    +254:   deflate has returned Z_STREAM_END, the only possible operations on the
    +255:   stream are deflateReset or deflateEnd.
    +256:   
    +257:     Z_FINISH can be used immediately after deflateInit if all the compression
    +258:   is to be done in a single step. In this case, avail_out must be at least
    +259:   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
    +260:   Z_STREAM_END, then it must be called again as described above.
    +261: 
    +262:     deflate() sets strm->adler to the adler32 checksum of all input read
    +263:   so far (that is, total_in bytes).
    +264: 
    +265:     deflate() may update data_type if it can make a good guess about
    +266:   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
    +267:   binary. This field is only for information purposes and does not affect
    +268:   the compression algorithm in any manner.
    +269: 
    +270:     deflate() returns Z_OK if some progress has been made (more input
    +271:   processed or more output produced), Z_STREAM_END if all input has been
    +272:   consumed and all output has been produced (only when flush is set to
    +273:   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
    +274:   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
    +275:   (for example avail_in or avail_out was zero).
    +276: */
    +277: 
    +278: 
    +279: ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
    +280: /*
    +281:      All dynamically allocated data structures for this stream are freed.
    +282:    This function discards any unprocessed input and does not flush any
    +283:    pending output.
    +284: 
    +285:      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
    +286:    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
    +287:    prematurely (some input or output was discarded). In the error case,
    +288:    msg may be set but then points to a static string (which must not be
    +289:    deallocated).
    +290: */
    +291: 
    +292: 
    +293: /* 
    +294: ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
    +295: 
    +296:      Initializes the internal stream state for decompression. The fields
    +297:    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
    +298:    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
    +299:    value depends on the compression method), inflateInit determines the
    +300:    compression method from the zlib header and allocates all data structures
    +301:    accordingly; otherwise the allocation will be deferred to the first call of
    +302:    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
    +303:    use default allocation functions.
    +304: 
    +305:      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
    +306:    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
    +307:    version assumed by the caller.  msg is set to null if there is no error
    +308:    message. inflateInit does not perform any decompression apart from reading
    +309:    the zlib header if present: this will be done by inflate().  (So next_in and
    +310:    avail_in may be modified, but next_out and avail_out are unchanged.)
    +311: */
    +312: 
    +313: 
    +314: ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
    +315: /*
    +316:     inflate decompresses as much data as possible, and stops when the input
    +317:   buffer becomes empty or the output buffer becomes full. It may some
    +318:   introduce some output latency (reading input without producing any output)
    +319:   except when forced to flush.
    +320: 
    +321:   The detailed semantics are as follows. inflate performs one or both of the
    +322:   following actions:
    +323: 
    +324:   - Decompress more input starting at next_in and update next_in and avail_in
    +325:     accordingly. If not all input can be processed (because there is not
    +326:     enough room in the output buffer), next_in is updated and processing
    +327:     will resume at this point for the next call of inflate().
    +328: 
    +329:   - Provide more output starting at next_out and update next_out and avail_out
    +330:     accordingly.  inflate() provides as much output as possible, until there
    +331:     is no more input data or no more space in the output buffer (see below
    +332:     about the flush parameter).
    +333: 
    +334:   Before the call of inflate(), the application should ensure that at least
    +335:   one of the actions is possible, by providing more input and/or consuming
    +336:   more output, and updating the next_* and avail_* values accordingly.
    +337:   The application can consume the uncompressed output when it wants, for
    +338:   example when the output buffer is full (avail_out == 0), or after each
    +339:   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
    +340:   must be called again after making room in the output buffer because there
    +341:   might be more output pending.
    +342: 
    +343:     If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
    +344:   output as possible to the output buffer. The flushing behavior of inflate is
    +345:   not specified for values of the flush parameter other than Z_SYNC_FLUSH
    +346:   and Z_FINISH, but the current implementation actually flushes as much output
    +347:   as possible anyway.
    +348: 
    +349:     inflate() should normally be called until it returns Z_STREAM_END or an
    +350:   error. However if all decompression is to be performed in a single step
    +351:   (a single call of inflate), the parameter flush should be set to
    +352:   Z_FINISH. In this case all pending input is processed and all pending
    +353:   output is flushed; avail_out must be large enough to hold all the
    +354:   uncompressed data. (The size of the uncompressed data may have been saved
    +355:   by the compressor for this purpose.) The next operation on this stream must
    +356:   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
    +357:   is never required, but can be used to inform inflate that a faster routine
    +358:   may be used for the single inflate() call.
    +359: 
    +360:      If a preset dictionary is needed at this point (see inflateSetDictionary
    +361:   below), inflate sets strm-adler to the adler32 checksum of the
    +362:   dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise 
    +363:   it sets strm->adler to the adler32 checksum of all output produced
    +364:   so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
    +365:   an error code as described below. At the end of the stream, inflate()
    +366:   checks that its computed adler32 checksum is equal to that saved by the
    +367:   compressor and returns Z_STREAM_END only if the checksum is correct.
    +368: 
    +369:     inflate() returns Z_OK if some progress has been made (more input processed
    +370:   or more output produced), Z_STREAM_END if the end of the compressed data has
    +371:   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
    +372:   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
    +373:   corrupted (input stream not conforming to the zlib format or incorrect
    +374:   adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
    +375:   (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
    +376:   enough memory, Z_BUF_ERROR if no progress is possible or if there was not
    +377:   enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
    +378:   case, the application may then call inflateSync to look for a good
    +379:   compression block.
    +380: */
    +381: 
    +382: 
    +383: ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
    +384: /*
    +385:      All dynamically allocated data structures for this stream are freed.
    +386:    This function discards any unprocessed input and does not flush any
    +387:    pending output.
    +388: 
    +389:      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
    +390:    was inconsistent. In the error case, msg may be set but then points to a
    +391:    static string (which must not be deallocated).
    +392: */
    +393: 
    +394:                         /* Advanced functions */
    +395: 
    +396: /*
    +397:     The following functions are needed only in some special applications.
    +398: */
    +399: 
    +400: /*   
    +401: ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
    +402:                                      int  level,
    +403:                                      int  method,
    +404:                                      int  windowBits,
    +405:                                      int  memLevel,
    +406:                                      int  strategy));
    +407: 
    +408:      This is another version of deflateInit with more compression options. The
    +409:    fields next_in, zalloc, zfree and opaque must be initialized before by
    +410:    the caller.
    +411: 
    +412:      The method parameter is the compression method. It must be Z_DEFLATED in
    +413:    this version of the library.
    +414: 
    +415:      The windowBits parameter is the base two logarithm of the window size
    +416:    (the size of the history buffer).  It should be in the range 8..15 for this
    +417:    version of the library. Larger values of this parameter result in better
    +418:    compression at the expense of memory usage. The default value is 15 if
    +419:    deflateInit is used instead.
    +420: 
    +421:      The memLevel parameter specifies how much memory should be allocated
    +422:    for the internal compression state. memLevel=1 uses minimum memory but
    +423:    is slow and reduces compression ratio; memLevel=9 uses maximum memory
    +424:    for optimal speed. The default value is 8. See zconf.h for total memory
    +425:    usage as a function of windowBits and memLevel.
    +426: 
    +427:      The strategy parameter is used to tune the compression algorithm. Use the
    +428:    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
    +429:    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
    +430:    string match).  Filtered data consists mostly of small values with a
    +431:    somewhat random distribution. In this case, the compression algorithm is
    +432:    tuned to compress them better. The effect of Z_FILTERED is to force more
    +433:    Huffman coding and less string matching; it is somewhat intermediate
    +434:    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
    +435:    the compression ratio but not the correctness of the compressed output even
    +436:    if it is not set appropriately.
    +437: 
    +438:       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    +439:    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
    +440:    method). msg is set to null if there is no error message.  deflateInit2 does
    +441:    not perform any compression: this will be done by deflate().
    +442: */
    +443:                             
    +444: ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
    +445:                                              const Bytef *dictionary,
    +446:                                              uInt  dictLength));
    +447: /*
    +448:      Initializes the compression dictionary from the given byte sequence
    +449:    without producing any compressed output. This function must be called
    +450:    immediately after deflateInit, deflateInit2 or deflateReset, before any
    +451:    call of deflate. The compressor and decompressor must use exactly the same
    +452:    dictionary (see inflateSetDictionary).
    +453: 
    +454:      The dictionary should consist of strings (byte sequences) that are likely
    +455:    to be encountered later in the data to be compressed, with the most commonly
    +456:    used strings preferably put towards the end of the dictionary. Using a
    +457:    dictionary is most useful when the data to be compressed is short and can be
    +458:    predicted with good accuracy; the data can then be compressed better than
    +459:    with the default empty dictionary.
    +460: 
    +461:      Depending on the size of the compression data structures selected by
    +462:    deflateInit or deflateInit2, a part of the dictionary may in effect be
    +463:    discarded, for example if the dictionary is larger than the window size in
    +464:    deflate or deflate2. Thus the strings most likely to be useful should be
    +465:    put at the end of the dictionary, not at the front.
    +466: 
    +467:      Upon return of this function, strm->adler is set to the Adler32 value
    +468:    of the dictionary; the decompressor may later use this value to determine
    +469:    which dictionary has been used by the compressor. (The Adler32 value
    +470:    applies to the whole dictionary even if only a subset of the dictionary is
    +471:    actually used by the compressor.)
    +472: 
    +473:      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
    +474:    parameter is invalid (such as NULL dictionary) or the stream state is
    +475:    inconsistent (for example if deflate has already been called for this stream
    +476:    or if the compression method is bsort). deflateSetDictionary does not
    +477:    perform any compression: this will be done by deflate().
    +478: */
    +479: 
    +480: ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
    +481:                                     z_streamp source));
    +482: /*
    +483:      Sets the destination stream as a complete copy of the source stream.
    +484: 
    +485:      This function can be useful when several compression strategies will be
    +486:    tried, for example when there are several ways of pre-processing the input
    +487:    data with a filter. The streams that will be discarded should then be freed
    +488:    by calling deflateEnd.  Note that deflateCopy duplicates the internal
    +489:    compression state which can be quite large, so this strategy is slow and
    +490:    can consume lots of memory.
    +491: 
    +492:      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    +493:    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
    +494:    (such as zalloc being NULL). msg is left unchanged in both source and
    +495:    destination.
    +496: */
    +497: 
    +498: ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
    +499: /*
    +500:      This function is equivalent to deflateEnd followed by deflateInit,
    +501:    but does not free and reallocate all the internal compression state.
    +502:    The stream will keep the same compression level and any other attributes
    +503:    that may have been set by deflateInit2.
    +504: 
    +505:       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    +506:    stream state was inconsistent (such as zalloc or state being NULL).
    +507: */
    +508: 
    +509: ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
    +510: 				      int level,
    +511: 				      int strategy));
    +512: /*
    +513:      Dynamically update the compression level and compression strategy.  The
    +514:    interpretation of level and strategy is as in deflateInit2.  This can be
    +515:    used to switch between compression and straight copy of the input data, or
    +516:    to switch to a different kind of input data requiring a different
    +517:    strategy. If the compression level is changed, the input available so far
    +518:    is compressed with the old level (and may be flushed); the new level will
    +519:    take effect only at the next call of deflate().
    +520: 
    +521:      Before the call of deflateParams, the stream state must be set as for
    +522:    a call of deflate(), since the currently available input may have to
    +523:    be compressed and flushed. In particular, strm->avail_out must be non-zero.
    +524: 
    +525:      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
    +526:    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
    +527:    if strm->avail_out was zero.
    +528: */
    +529: 
    +530: /*   
    +531: ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    +532:                                      int  windowBits));
    +533: 
    +534:      This is another version of inflateInit with an extra parameter. The
    +535:    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
    +536:    before by the caller.
    +537: 
    +538:      The windowBits parameter is the base two logarithm of the maximum window
    +539:    size (the size of the history buffer).  It should be in the range 8..15 for
    +540:    this version of the library. The default value is 15 if inflateInit is used
    +541:    instead. If a compressed stream with a larger window size is given as
    +542:    input, inflate() will return with the error code Z_DATA_ERROR instead of
    +543:    trying to allocate a larger window.
    +544: 
    +545:       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    +546:    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
    +547:    memLevel). msg is set to null if there is no error message.  inflateInit2
    +548:    does not perform any decompression apart from reading the zlib header if
    +549:    present: this will be done by inflate(). (So next_in and avail_in may be
    +550:    modified, but next_out and avail_out are unchanged.)
    +551: */
    +552: 
    +553: ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
    +554:                                              const Bytef *dictionary,
    +555:                                              uInt  dictLength));
    +556: /*
    +557:      Initializes the decompression dictionary from the given uncompressed byte
    +558:    sequence. This function must be called immediately after a call of inflate
    +559:    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
    +560:    can be determined from the Adler32 value returned by this call of
    +561:    inflate. The compressor and decompressor must use exactly the same
    +562:    dictionary (see deflateSetDictionary).
    +563: 
    +564:      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
    +565:    parameter is invalid (such as NULL dictionary) or the stream state is
    +566:    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
    +567:    expected one (incorrect Adler32 value). inflateSetDictionary does not
    +568:    perform any decompression: this will be done by subsequent calls of
    +569:    inflate().
    +570: */
    +571: 
    +572: ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
    +573: /* 
    +574:     Skips invalid compressed data until a full flush point (see above the
    +575:   description of deflate with Z_FULL_FLUSH) can be found, or until all
    +576:   available input is skipped. No output is provided.
    +577: 
    +578:     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
    +579:   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
    +580:   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
    +581:   case, the application may save the current current value of total_in which
    +582:   indicates where valid compressed data was found. In the error case, the
    +583:   application may repeatedly call inflateSync, providing more input each time,
    +584:   until success or end of the input data.
    +585: */
    +586: 
    +587: ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
    +588: /*
    +589:      This function is equivalent to inflateEnd followed by inflateInit,
    +590:    but does not free and reallocate all the internal decompression state.
    +591:    The stream will keep attributes that may have been set by inflateInit2.
    +592: 
    +593:       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    +594:    stream state was inconsistent (such as zalloc or state being NULL).
    +595: */
    +596: 
    +597: 
    +598:                         /* utility functions */
    +599: 
    +600: /*
    +601:      The following utility functions are implemented on top of the
    +602:    basic stream-oriented functions. To simplify the interface, some
    +603:    default options are assumed (compression level and memory usage,
    +604:    standard memory allocation functions). The source code of these
    +605:    utility functions can easily be modified if you need special options.
    +606: */
    +607: 
    +608: ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
    +609:                                  const Bytef *source, uLong sourceLen));
    +610: /*
    +611:      Compresses the source buffer into the destination buffer.  sourceLen is
    +612:    the byte length of the source buffer. Upon entry, destLen is the total
    +613:    size of the destination buffer, which must be at least 0.1% larger than
    +614:    sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
    +615:    compressed buffer.
    +616:      This function can be used to compress a whole file at once if the
    +617:    input file is mmap'ed.
    +618:      compress returns Z_OK if success, Z_MEM_ERROR if there was not
    +619:    enough memory, Z_BUF_ERROR if there was not enough room in the output
    +620:    buffer.
    +621: */
    +622: 
    +623: ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
    +624:                                   const Bytef *source, uLong sourceLen,
    +625:                                   int level));
    +626: /*
    +627:      Compresses the source buffer into the destination buffer. The level
    +628:    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    +629:    length of the source buffer. Upon entry, destLen is the total size of the
    +630:    destination buffer, which must be at least 0.1% larger than sourceLen plus
    +631:    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
    +632: 
    +633:      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    +634:    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    +635:    Z_STREAM_ERROR if the level parameter is invalid.
    +636: */
    +637: 
    +638: ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
    +639:                                    const Bytef *source, uLong sourceLen));
    +640: /*
    +641:      Decompresses the source buffer into the destination buffer.  sourceLen is
    +642:    the byte length of the source buffer. Upon entry, destLen is the total
    +643:    size of the destination buffer, which must be large enough to hold the
    +644:    entire uncompressed data. (The size of the uncompressed data must have
    +645:    been saved previously by the compressor and transmitted to the decompressor
    +646:    by some mechanism outside the scope of this compression library.)
    +647:    Upon exit, destLen is the actual size of the compressed buffer.
    +648:      This function can be used to decompress a whole file at once if the
    +649:    input file is mmap'ed.
    +650: 
    +651:      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    +652:    enough memory, Z_BUF_ERROR if there was not enough room in the output
    +653:    buffer, or Z_DATA_ERROR if the input data was corrupted.
    +654: */
    +655: 
    +656: 
    +657: typedef voidp gzFile;
    +658: 
    +659: ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
    +660: /*
    +661:      Opens a gzip (.gz) file for reading or writing. The mode parameter
    +662:    is as in fopen ("rb" or "wb") but can also include a compression level
    +663:    ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
    +664:    Huffman only compression as in "wb1h". (See the description
    +665:    of deflateInit2 for more information about the strategy parameter.)
    +666: 
    +667:      gzopen can be used to read a file which is not in gzip format; in this
    +668:    case gzread will directly read from the file without decompression.
    +669: 
    +670:      gzopen returns NULL if the file could not be opened or if there was
    +671:    insufficient memory to allocate the (de)compression state; errno
    +672:    can be checked to distinguish the two cases (if errno is zero, the
    +673:    zlib error is Z_MEM_ERROR).  */
    +674: 
    +675: ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
    +676: /*
    +677:      gzdopen() associates a gzFile with the file descriptor fd.  File
    +678:    descriptors are obtained from calls like open, dup, creat, pipe or
    +679:    fileno (in the file has been previously opened with fopen).
    +680:    The mode parameter is as in gzopen.
    +681:      The next call of gzclose on the returned gzFile will also close the
    +682:    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
    +683:    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
    +684:      gzdopen returns NULL if there was insufficient memory to allocate
    +685:    the (de)compression state.
    +686: */
    +687: 
    +688: ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
    +689: /*
    +690:      Dynamically update the compression level or strategy. See the description
    +691:    of deflateInit2 for the meaning of these parameters.
    +692:      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
    +693:    opened for writing.
    +694: */
    +695: 
    +696: ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
    +697: /*
    +698:      Reads the given number of uncompressed bytes from the compressed file.
    +699:    If the input file was not in gzip format, gzread copies the given number
    +700:    of bytes into the buffer.
    +701:      gzread returns the number of uncompressed bytes actually read (0 for
    +702:    end of file, -1 for error). */
    +703: 
    +704: ZEXTERN int ZEXPORT    gzwrite OF((gzFile file, 
    +705: 				   const voidp buf, unsigned len));
    +706: /*
    +707:      Writes the given number of uncompressed bytes into the compressed file.
    +708:    gzwrite returns the number of uncompressed bytes actually written
    +709:    (0 in case of error).
    +710: */
    +711: 
    +712: ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
    +713: /*
    +714:      Converts, formats, and writes the args to the compressed file under
    +715:    control of the format string, as in fprintf. gzprintf returns the number of
    +716:    uncompressed bytes actually written (0 in case of error).
    +717: */
    +718: 
    +719: ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
    +720: /*
    +721:       Writes the given null-terminated string to the compressed file, excluding
    +722:    the terminating null character.
    +723:       gzputs returns the number of characters written, or -1 in case of error.
    +724: */
    +725: 
    +726: ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
    +727: /*
    +728:       Reads bytes from the compressed file until len-1 characters are read, or
    +729:    a newline character is read and transferred to buf, or an end-of-file
    +730:    condition is encountered.  The string is then terminated with a null
    +731:    character.
    +732:       gzgets returns buf, or Z_NULL in case of error.
    +733: */
    +734: 
    +735: ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
    +736: /*
    +737:       Writes c, converted to an unsigned char, into the compressed file.
    +738:    gzputc returns the value that was written, or -1 in case of error.
    +739: */
    +740: 
    +741: ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
    +742: /*
    +743:       Reads one byte from the compressed file. gzgetc returns this byte
    +744:    or -1 in case of end of file or error.
    +745: */
    +746: 
    +747: ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
    +748: /*
    +749:      Flushes all pending output into the compressed file. The parameter
    +750:    flush is as in the deflate() function. The return value is the zlib
    +751:    error number (see function gzerror below). gzflush returns Z_OK if
    +752:    the flush parameter is Z_FINISH and all output could be flushed.
    +753:      gzflush should be called only when strictly necessary because it can
    +754:    degrade compression.
    +755: */
    +756: 
    +757: ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
    +758: 				      z_off_t offset, int whence));
    +759: /* 
    +760:       Sets the starting position for the next gzread or gzwrite on the
    +761:    given compressed file. The offset represents a number of bytes in the
    +762:    uncompressed data stream. The whence parameter is defined as in lseek(2);
    +763:    the value SEEK_END is not supported.
    +764:      If the file is opened for reading, this function is emulated but can be
    +765:    extremely slow. If the file is opened for writing, only forward seeks are
    +766:    supported; gzseek then compresses a sequence of zeroes up to the new
    +767:    starting position.
    +768: 
    +769:       gzseek returns the resulting offset location as measured in bytes from
    +770:    the beginning of the uncompressed stream, or -1 in case of error, in
    +771:    particular if the file is opened for writing and the new starting position
    +772:    would be before the current position.
    +773: */
    +774: 
    +775: ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
    +776: /*
    +777:      Rewinds the given file. This function is supported only for reading.
    +778: 
    +779:    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
    +780: */
    +781: 
    +782: ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
    +783: /*
    +784:      Returns the starting position for the next gzread or gzwrite on the
    +785:    given compressed file. This position represents a number of bytes in the
    +786:    uncompressed data stream.
    +787: 
    +788:    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
    +789: */
    +790: 
    +791: ZEXTERN int ZEXPORT gzeof OF((gzFile file));
    +792: /*
    +793:      Returns 1 when EOF has previously been detected reading the given
    +794:    input stream, otherwise zero.
    +795: */
    +796: 
    +797: ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
    +798: /*
    +799:      Flushes all pending output if necessary, closes the compressed file
    +800:    and deallocates all the (de)compression state. The return value is the zlib
    +801:    error number (see function gzerror below).
    +802: */
    +803: 
    +804: ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
    +805: /*
    +806:      Returns the error message for the last error which occurred on the
    +807:    given compressed file. errnum is set to zlib error number. If an
    +808:    error occurred in the file system and not in the compression library,
    +809:    errnum is set to Z_ERRNO and the application may consult errno
    +810:    to get the exact error code.
    +811: */
    +812: 
    +813:                         /* checksum functions */
    +814: 
    +815: /*
    +816:      These functions are not related to compression but are exported
    +817:    anyway because they might be useful in applications using the
    +818:    compression library.
    +819: */
    +820: 
    +821: ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
    +822: 
    +823: /*
    +824:      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
    +825:    return the updated checksum. If buf is NULL, this function returns
    +826:    the required initial value for the checksum.
    +827:    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
    +828:    much faster. Usage example:
    +829: 
    +830:      uLong adler = adler32(0L, Z_NULL, 0);
    +831: 
    +832:      while (read_buffer(buffer, length) != EOF) {
    +833:        adler = adler32(adler, buffer, length);
    +834:      }
    +835:      if (adler != original_adler) error();
    +836: */
    +837: 
    +838: ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
    +839: /*
    +840:      Update a running crc with the bytes buf[0..len-1] and return the updated
    +841:    crc. If buf is NULL, this function returns the required initial value
    +842:    for the crc. Pre- and post-conditioning (one's complement) is performed
    +843:    within this function so it shouldn't be done by the application.
    +844:    Usage example:
    +845: 
    +846:      uLong crc = crc32(0L, Z_NULL, 0);
    +847: 
    +848:      while (read_buffer(buffer, length) != EOF) {
    +849:        crc = crc32(crc, buffer, length);
    +850:      }
    +851:      if (crc != original_crc) error();
    +852: */
    +853: 
    +854: 
    +855:                         /* various hacks, don't look :) */
    +856: 
    +857: /* deflateInit and inflateInit are macros to allow checking the zlib version
    +858:  * and the compiler's view of z_stream:
    +859:  */
    +860: ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
    +861:                                      const char *version, int stream_size));
    +862: ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
    +863:                                      const char *version, int stream_size));
    +864: ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
    +865:                                       int windowBits, int memLevel,
    +866:                                       int strategy, const char *version,
    +867:                                       int stream_size));
    +868: ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
    +869:                                       const char *version, int stream_size));
    +870: #define deflateInit(strm, level) \
    +871:         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
    +872: #define inflateInit(strm) \
    +873:         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
    +874: #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
    +875:         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
    +876:                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
    +877: #define inflateInit2(strm, windowBits) \
    +878:         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
    +879: 
    +880: 
    +881: #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
    +882:     struct internal_state {int dummy;}; /* hack for buggy compilers */
    +883: #endif
    +884: 
    +885: ZEXTERN const char   * ZEXPORT zError           OF((int err));
    +886: ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
    +887: ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
    +888: 
    +889: #ifdef __cplusplus
    +890: }
    +891: #endif
    +892: 
    +893: #endif /* _ZLIB_H */
    +      
    +
    + +

    How the zlib wrapper was developed

    + +

    Attempt #1

    +
    +
    +/* File : example.i */
    +%module example
    +%{
    +/* Put headers and other declarations here */
    +#include "zlib.h"
    +%}
    +
    +%include typemaps.i
    +
    +%include "zlib.h"
    +      
    +
    + + The result is: + +
    +
    +% swig -chicken -I/usr/include example.i
    +/usr/include/zlib.h:63: Syntax error in input.
    +/usr/include/zlib.h:78: Syntax error in input.
    +/usr/include/zlib.h:80: Syntax error in input.
    +      
    +
    + + The first problem we see is that the macro OF(...) is + not defined. + +

    Attempt #2

    + + We make sure to include zconf.h so that SWIG can see the + definition of OF(...). We try again. + +
    +
    +/* File : example.i */
    +%module example
    +%{
    +/* Put headers and other declarations here */
    +#include "zlib.h"
    +%}
    +
    +%include typemaps.i
    +
    +%include "zconf.h"
    +%include "zlib.h"
    +      
    +
    + + The result is: + +
    +
    +% swig -chicken -I/usr/include example.i
    +      
    +
    + + This seems to work! But we should take a peek inside the generated + example_wrap.c to see what the names of the Scheme + procedures will be. + +
    +
    +% grep C_intern example_wrap.c
    +  C_word err = C_intern2 (&a, errorhook);
    +    sym = C_intern (&a, 21, "example:max-mem-level");
    +    sym = C_intern (&a, 17, "example:max-wbits");
    +    sym = C_intern (&a, 16, "example:seek-set");
    +    sym = C_intern (&a, 16, "example:seek-cur");
    +    sym = C_intern (&a, 16, "example:seek-end");
    +    sym = C_intern (&a, 20, "example:zlib-version");
    +    sym = C_intern (&a, 28, "example:z-stream-next-in-set");
    +    sym = C_intern (&a, 28, "example:z-stream-next-in-get");
    +    sym = C_intern (&a, 29, "example:z-stream-avail-in-set");
    +    sym = C_intern (&a, 29, "example:z-stream-avail-in-get");
    +    sym = C_intern (&a, 29, "example:z-stream-total-in-set");
    +    sym = C_intern (&a, 29, "example:z-stream-total-in-get");
    +    sym = C_intern (&a, 29, "example:z-stream-next-out-set");
    +    sym = C_intern (&a, 29, "example:z-stream-next-out-get");
    +    sym = C_intern (&a, 30, "example:z-stream-avail-out-set");
    +    sym = C_intern (&a, 30, "example:z-stream-avail-out-get");
    +    sym = C_intern (&a, 30, "example:z-stream-total-out-set");
    +    sym = C_intern (&a, 30, "example:z-stream-total-out-get");
    +    sym = C_intern (&a, 24, "example:z-stream-msg-set");
    +    sym = C_intern (&a, 24, "example:z-stream-msg-get");
    +    sym = C_intern (&a, 26, "example:z-stream-state-set");
    +    sym = C_intern (&a, 26, "example:z-stream-state-get");
    +    sym = C_intern (&a, 27, "example:z-stream-zalloc-set");
    +    sym = C_intern (&a, 27, "example:z-stream-zalloc-get");
    +    sym = C_intern (&a, 26, "example:z-stream-zfree-set");
    +    sym = C_intern (&a, 26, "example:z-stream-zfree-get");
    +    sym = C_intern (&a, 27, "example:z-stream-opaque-set");
    +    sym = C_intern (&a, 27, "example:z-stream-opaque-get");
    +    sym = C_intern (&a, 30, "example:z-stream-data-type-set");
    +    sym = C_intern (&a, 30, "example:z-stream-data-type-get");
    +    sym = C_intern (&a, 26, "example:z-stream-adler-set");
    +    sym = C_intern (&a, 26, "example:z-stream-adler-get");
    +    sym = C_intern (&a, 29, "example:z-stream-reserved-set");
    +    sym = C_intern (&a, 29, "example:z-stream-reserved-get");
    +    sym = C_intern (&a, 20, "example:new-z-stream");
    +    sym = C_intern (&a, 23, "example:delete-z-stream");
    +    sym = C_intern (&a, 18, "example:z-no-flush");
    +    sym = C_intern (&a, 23, "example:z-partial-flush");
    +    sym = C_intern (&a, 20, "example:z-sync-flush");
    +    sym = C_intern (&a, 20, "example:z-full-flush");
    +    sym = C_intern (&a, 16, "example:z-finish");
    +    sym = C_intern (&a, 12, "example:z-ok");
    +    sym = C_intern (&a, 20, "example:z-stream-end");
    +    sym = C_intern (&a, 19, "example:z-need-dict");
    +    sym = C_intern (&a, 15, "example:z-errno");
    +    sym = C_intern (&a, 22, "example:z-stream-error");
    +    sym = C_intern (&a, 20, "example:z-data-error");
    +    sym = C_intern (&a, 19, "example:z-mem-error");
    +    sym = C_intern (&a, 19, "example:z-buf-error");
    +    sym = C_intern (&a, 23, "example:z-version-error");
    +    sym = C_intern (&a, 24, "example:z-no-compression");
    +    sym = C_intern (&a, 20, "example:z-best-speed");
    +    sym = C_intern (&a, 26, "example:z-best-compression");
    +    sym = C_intern (&a, 29, "example:z-default-compression");
    +    sym = C_intern (&a, 18, "example:z-filtered");
    +    sym = C_intern (&a, 22, "example:z-huffman-only");
    +    sym = C_intern (&a, 26, "example:z-default-strategy");
    +    sym = C_intern (&a, 16, "example:z-binary");
    +    sym = C_intern (&a, 15, "example:z-ascii");
    +    sym = C_intern (&a, 17, "example:z-unknown");
    +    sym = C_intern (&a, 18, "example:z-deflated");
    +    sym = C_intern (&a, 14, "example:z-null");
    +    sym = C_intern (&a, 19, "example:zlibversion");
    +    sym = C_intern (&a, 15, "example:deflate");
    +    sym = C_intern (&a, 18, "example:deflateend");
    +    sym = C_intern (&a, 15, "example:inflate");
    +    sym = C_intern (&a, 18, "example:inflateend");
    +    sym = C_intern (&a, 28, "example:deflatesetdictionary");
    +    sym = C_intern (&a, 19, "example:deflatecopy");
    +    sym = C_intern (&a, 20, "example:deflatereset");
    +    sym = C_intern (&a, 21, "example:deflateparams");
    +    sym = C_intern (&a, 28, "example:inflatesetdictionary");
    +    sym = C_intern (&a, 19, "example:inflatesync");
    +    sym = C_intern (&a, 20, "example:inflatereset");
    +    sym = C_intern (&a, 16, "example:compress");
    +    sym = C_intern (&a, 17, "example:compress2");
    +    sym = C_intern (&a, 18, "example:uncompress");
    +    sym = C_intern (&a, 14, "example:gzopen");
    +    sym = C_intern (&a, 15, "example:gzdopen");
    +    sym = C_intern (&a, 19, "example:gzsetparams");
    +    sym = C_intern (&a, 14, "example:gzread");
    +    sym = C_intern (&a, 15, "example:gzwrite");
    +    sym = C_intern (&a, 16, "example:gzprintf");
    +    sym = C_intern (&a, 14, "example:gzputs");
    +    sym = C_intern (&a, 14, "example:gzgets");
    +    sym = C_intern (&a, 14, "example:gzputc");
    +    sym = C_intern (&a, 14, "example:gzgetc");
    +    sym = C_intern (&a, 15, "example:gzflush");
    +    sym = C_intern (&a, 14, "example:gzseek");
    +    sym = C_intern (&a, 16, "example:gzrewind");
    +    sym = C_intern (&a, 14, "example:gztell");
    +    sym = C_intern (&a, 13, "example:gzeof");
    +    sym = C_intern (&a, 15, "example:gzclose");
    +    sym = C_intern (&a, 15, "example:gzerror");
    +    sym = C_intern (&a, 15, "example:adler32");
    +    sym = C_intern (&a, 13, "example:crc32");
    +    sym = C_intern (&a, 20, "example:deflateinit-");
    +    sym = C_intern (&a, 20, "example:inflateinit-");
    +    sym = C_intern (&a, 21, "example:deflateinit2-");
    +    sym = C_intern (&a, 21, "example:inflateinit2-");
    +    sym = C_intern (&a, 32, "example:internal-state-dummy-set");
    +    sym = C_intern (&a, 32, "example:internal-state-dummy-get");
    +    sym = C_intern (&a, 26, "example:new-internal-state");
    +    sym = C_intern (&a, 29, "example:delete-internal-state");
    +    sym = C_intern (&a, 14, "example:zerror");
    +    sym = C_intern (&a, 24, "example:inflatesyncpoint");
    +    sym = C_intern (&a, 21, "example:get-crc-table");
    +      
    +
    + + In fact, we want the Scheme procedure names to begin with + zlib instead of example. For + example:zlib-version, we want + zlib-version. And we want dashes when the case + switches to/from upper/lowercase; ex. the function + deflateEnd() should be the Scheme procedure + zlib-deflate-end. + +

    Attempt #3

    + + We make sure to add -prefix zlib -mixed to the + swig command line, and we rename + ZLIB_VERSION to VERSION. We try again. + +
    +
    +/* File : example.i */
    +%module example
    +%{
    +/* Put headers and other declarations here */
    +#include "zlib.h"
    +%}
    +
    +%include typemaps.i
    +
    +%rename(VERSION) ZLIB_VERSION;
    +
    +%include "zconf.h"
    +%include "zlib.h"
    +      
    +
    + + The result is: + +
    +
    +% swig -chicken -prefix zlib -mixed -I/usr/include example.i
    +% grep C_intern example_wrap.c
    +  C_word err = C_intern2 (&a, errorhook);
    +    sym = C_intern (&a, 18, "zlib:max-mem-level");
    +    sym = C_intern (&a, 14, "zlib:max-wbits");
    +    sym = C_intern (&a, 13, "zlib:seek-set");
    +    sym = C_intern (&a, 13, "zlib:seek-cur");
    +    sym = C_intern (&a, 13, "zlib:seek-end");
    +    sym = C_intern (&a, 12, "zlib:version");
    +    sym = C_intern (&a, 25, "zlib:z-stream-next-in-set");
    +    sym = C_intern (&a, 25, "zlib:z-stream-next-in-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-total-in-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-total-in-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-next-out-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-next-out-get");
    +    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-set");
    +    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-get");
    +    sym = C_intern (&a, 27, "zlib:z-stream-total-out-set");
    +    sym = C_intern (&a, 27, "zlib:z-stream-total-out-get");
    +    sym = C_intern (&a, 21, "zlib:z-stream-msg-set");
    +    sym = C_intern (&a, 21, "zlib:z-stream-msg-get");
    +    sym = C_intern (&a, 23, "zlib:z-stream-state-set");
    +    sym = C_intern (&a, 23, "zlib:z-stream-state-get");
    +    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-set");
    +    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-get");
    +    sym = C_intern (&a, 23, "zlib:z-stream-zfree-set");
    +    sym = C_intern (&a, 23, "zlib:z-stream-zfree-get");
    +    sym = C_intern (&a, 24, "zlib:z-stream-opaque-set");
    +    sym = C_intern (&a, 24, "zlib:z-stream-opaque-get");
    +    sym = C_intern (&a, 27, "zlib:z-stream-data-type-set");
    +    sym = C_intern (&a, 27, "zlib:z-stream-data-type-get");
    +    sym = C_intern (&a, 23, "zlib:z-stream-adler-set");
    +    sym = C_intern (&a, 23, "zlib:z-stream-adler-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-reserved-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-reserved-get");
    +    sym = C_intern (&a, 17, "zlib:new-z-stream");
    +    sym = C_intern (&a, 20, "zlib:delete-z-stream");
    +    sym = C_intern (&a, 15, "zlib:z-no-flush");
    +    sym = C_intern (&a, 20, "zlib:z-partial-flush");
    +    sym = C_intern (&a, 17, "zlib:z-sync-flush");
    +    sym = C_intern (&a, 17, "zlib:z-full-flush");
    +    sym = C_intern (&a, 13, "zlib:z-finish");
    +    sym = C_intern (&a, 9, "zlib:z-ok");
    +    sym = C_intern (&a, 17, "zlib:z-stream-end");
    +    sym = C_intern (&a, 16, "zlib:z-need-dict");
    +    sym = C_intern (&a, 12, "zlib:z-errno");
    +    sym = C_intern (&a, 19, "zlib:z-stream-error");
    +    sym = C_intern (&a, 17, "zlib:z-data-error");
    +    sym = C_intern (&a, 16, "zlib:z-mem-error");
    +    sym = C_intern (&a, 16, "zlib:z-buf-error");
    +    sym = C_intern (&a, 20, "zlib:z-version-error");
    +    sym = C_intern (&a, 21, "zlib:z-no-compression");
    +    sym = C_intern (&a, 17, "zlib:z-best-speed");
    +    sym = C_intern (&a, 23, "zlib:z-best-compression");
    +    sym = C_intern (&a, 26, "zlib:z-default-compression");
    +    sym = C_intern (&a, 15, "zlib:z-filtered");
    +    sym = C_intern (&a, 19, "zlib:z-huffman-only");
    +    sym = C_intern (&a, 23, "zlib:z-default-strategy");
    +    sym = C_intern (&a, 13, "zlib:z-binary");
    +    sym = C_intern (&a, 12, "zlib:z-ascii");
    +    sym = C_intern (&a, 14, "zlib:z-unknown");
    +    sym = C_intern (&a, 15, "zlib:z-deflated");
    +    sym = C_intern (&a, 11, "zlib:z-null");
    +    sym = C_intern (&a, 17, "zlib:zlib-version");
    +    sym = C_intern (&a, 12, "zlib:deflate");
    +    sym = C_intern (&a, 16, "zlib:deflate-end");
    +    sym = C_intern (&a, 12, "zlib:inflate");
    +    sym = C_intern (&a, 16, "zlib:inflate-end");
    +    sym = C_intern (&a, 27, "zlib:deflate-set-dictionary");
    +    sym = C_intern (&a, 17, "zlib:deflate-copy");
    +    sym = C_intern (&a, 18, "zlib:deflate-reset");
    +    sym = C_intern (&a, 19, "zlib:deflate-params");
    +    sym = C_intern (&a, 27, "zlib:inflate-set-dictionary");
    +    sym = C_intern (&a, 17, "zlib:inflate-sync");
    +    sym = C_intern (&a, 18, "zlib:inflate-reset");
    +    sym = C_intern (&a, 13, "zlib:compress");
    +    sym = C_intern (&a, 14, "zlib:compress2");
    +    sym = C_intern (&a, 15, "zlib:uncompress");
    +    sym = C_intern (&a, 11, "zlib:gzopen");
    +    sym = C_intern (&a, 12, "zlib:gzdopen");
    +    sym = C_intern (&a, 16, "zlib:gzsetparams");
    +    sym = C_intern (&a, 11, "zlib:gzread");
    +    sym = C_intern (&a, 12, "zlib:gzwrite");
    +    sym = C_intern (&a, 13, "zlib:gzprintf");
    +    sym = C_intern (&a, 11, "zlib:gzputs");
    +    sym = C_intern (&a, 11, "zlib:gzgets");
    +    sym = C_intern (&a, 11, "zlib:gzputc");
    +    sym = C_intern (&a, 11, "zlib:gzgetc");
    +    sym = C_intern (&a, 12, "zlib:gzflush");
    +    sym = C_intern (&a, 11, "zlib:gzseek");
    +    sym = C_intern (&a, 13, "zlib:gzrewind");
    +    sym = C_intern (&a, 11, "zlib:gztell");
    +    sym = C_intern (&a, 10, "zlib:gzeof");
    +    sym = C_intern (&a, 12, "zlib:gzclose");
    +    sym = C_intern (&a, 12, "zlib:gzerror");
    +    sym = C_intern (&a, 12, "zlib:adler32");
    +    sym = C_intern (&a, 10, "zlib:crc32");
    +    sym = C_intern (&a, 18, "zlib:deflate-init-");
    +    sym = C_intern (&a, 18, "zlib:inflate-init-");
    +    sym = C_intern (&a, 19, "zlib:deflate-init2-");
    +    sym = C_intern (&a, 19, "zlib:inflate-init2-");
    +    sym = C_intern (&a, 29, "zlib:internal-state-dummy-set");
    +    sym = C_intern (&a, 29, "zlib:internal-state-dummy-get");
    +    sym = C_intern (&a, 23, "zlib:new-internal-state");
    +    sym = C_intern (&a, 26, "zlib:delete-internal-state");
    +    sym = C_intern (&a, 12, "zlib:ze-rror");
    +    sym = C_intern (&a, 23, "zlib:inflate-sync-point");
    +    sym = C_intern (&a, 18, "zlib:get-crc-table");
    +      
    +
    + + Much better. The only problem is the identifier + zlib:ze-rror, and we are missing + zlib:deflate-init and zlib:inflate-init + because they are defined as macros (see macro definitions). + +

    Attempt #4

    + + We make sure to rename zError to + z_error, and we inline some helper functions for the + zlib:...-init macros. We try again. + +
    +
    +/* File : example.i */
    +%module example
    +%{
    +/* Put headers and other declarations here */
    +#include "zlib.h"
    +%}
    +
    +%include typemaps.i
    +
    +%rename(VERSION) ZLIB_VERSION;
    +%rename(z_error) zError;
    +
    +%include "zconf.h"
    +%include "zlib.h"
    +
    +%inline %{
    +/* %inline blocks are seen by SWIG and are inserted into the header
    +   portion of example_wrap.c, so that they are also seen by the C
    +   compiler. */
    +int deflate_init(z_streamp strm, int level) {
    +  return deflateInit(strm,level); /* call macro */
    +}
    +int inflate_init(z_streamp strm) {
    +  return inflateInit(strm); /* call macro */
    +}
    +%}
    +
    +
    +      
    +
    + + The result is: + +
    +
    +% swig -chicken -prefix zlib -mixed -I/usr/include example.i
    +% grep C_intern example_wrap.c
    +  C_word err = C_intern2 (&a, errorhook);
    +    sym = C_intern (&a, 18, "zlib:max-mem-level");
    +    sym = C_intern (&a, 14, "zlib:max-wbits");
    +    sym = C_intern (&a, 13, "zlib:seek-set");
    +    sym = C_intern (&a, 13, "zlib:seek-cur");
    +    sym = C_intern (&a, 13, "zlib:seek-end");
    +    sym = C_intern (&a, 12, "zlib:version");
    +    sym = C_intern (&a, 25, "zlib:z-stream-next-in-set");
    +    sym = C_intern (&a, 25, "zlib:z-stream-next-in-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-total-in-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-total-in-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-next-out-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-next-out-get");
    +    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-set");
    +    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-get");
    +    sym = C_intern (&a, 27, "zlib:z-stream-total-out-set");
    +    sym = C_intern (&a, 27, "zlib:z-stream-total-out-get");
    +    sym = C_intern (&a, 21, "zlib:z-stream-msg-set");
    +    sym = C_intern (&a, 21, "zlib:z-stream-msg-get");
    +    sym = C_intern (&a, 23, "zlib:z-stream-state-set");
    +    sym = C_intern (&a, 23, "zlib:z-stream-state-get");
    +    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-set");
    +    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-get");
    +    sym = C_intern (&a, 23, "zlib:z-stream-zfree-set");
    +    sym = C_intern (&a, 23, "zlib:z-stream-zfree-get");
    +    sym = C_intern (&a, 24, "zlib:z-stream-opaque-set");
    +    sym = C_intern (&a, 24, "zlib:z-stream-opaque-get");
    +    sym = C_intern (&a, 27, "zlib:z-stream-data-type-set");
    +    sym = C_intern (&a, 27, "zlib:z-stream-data-type-get");
    +    sym = C_intern (&a, 23, "zlib:z-stream-adler-set");
    +    sym = C_intern (&a, 23, "zlib:z-stream-adler-get");
    +    sym = C_intern (&a, 26, "zlib:z-stream-reserved-set");
    +    sym = C_intern (&a, 26, "zlib:z-stream-reserved-get");
    +    sym = C_intern (&a, 17, "zlib:new-z-stream");
    +    sym = C_intern (&a, 20, "zlib:delete-z-stream");
    +    sym = C_intern (&a, 15, "zlib:z-no-flush");
    +    sym = C_intern (&a, 20, "zlib:z-partial-flush");
    +    sym = C_intern (&a, 17, "zlib:z-sync-flush");
    +    sym = C_intern (&a, 17, "zlib:z-full-flush");
    +    sym = C_intern (&a, 13, "zlib:z-finish");
    +    sym = C_intern (&a, 9, "zlib:z-ok");
    +    sym = C_intern (&a, 17, "zlib:z-stream-end");
    +    sym = C_intern (&a, 16, "zlib:z-need-dict");
    +    sym = C_intern (&a, 12, "zlib:z-errno");
    +    sym = C_intern (&a, 19, "zlib:z-stream-error");
    +    sym = C_intern (&a, 17, "zlib:z-data-error");
    +    sym = C_intern (&a, 16, "zlib:z-mem-error");
    +    sym = C_intern (&a, 16, "zlib:z-buf-error");
    +    sym = C_intern (&a, 20, "zlib:z-version-error");
    +    sym = C_intern (&a, 21, "zlib:z-no-compression");
    +    sym = C_intern (&a, 17, "zlib:z-best-speed");
    +    sym = C_intern (&a, 23, "zlib:z-best-compression");
    +    sym = C_intern (&a, 26, "zlib:z-default-compression");
    +    sym = C_intern (&a, 15, "zlib:z-filtered");
    +    sym = C_intern (&a, 19, "zlib:z-huffman-only");
    +    sym = C_intern (&a, 23, "zlib:z-default-strategy");
    +    sym = C_intern (&a, 13, "zlib:z-binary");
    +    sym = C_intern (&a, 12, "zlib:z-ascii");
    +    sym = C_intern (&a, 14, "zlib:z-unknown");
    +    sym = C_intern (&a, 15, "zlib:z-deflated");
    +    sym = C_intern (&a, 11, "zlib:z-null");
    +    sym = C_intern (&a, 17, "zlib:zlib-version");
    +    sym = C_intern (&a, 12, "zlib:deflate");
    +    sym = C_intern (&a, 16, "zlib:deflate-end");
    +    sym = C_intern (&a, 12, "zlib:inflate");
    +    sym = C_intern (&a, 16, "zlib:inflate-end");
    +    sym = C_intern (&a, 27, "zlib:deflate-set-dictionary");
    +    sym = C_intern (&a, 17, "zlib:deflate-copy");
    +    sym = C_intern (&a, 18, "zlib:deflate-reset");
    +    sym = C_intern (&a, 19, "zlib:deflate-params");
    +    sym = C_intern (&a, 27, "zlib:inflate-set-dictionary");
    +    sym = C_intern (&a, 17, "zlib:inflate-sync");
    +    sym = C_intern (&a, 18, "zlib:inflate-reset");
    +    sym = C_intern (&a, 13, "zlib:compress");
    +    sym = C_intern (&a, 14, "zlib:compress2");
    +    sym = C_intern (&a, 15, "zlib:uncompress");
    +    sym = C_intern (&a, 11, "zlib:gzopen");
    +    sym = C_intern (&a, 12, "zlib:gzdopen");
    +    sym = C_intern (&a, 16, "zlib:gzsetparams");
    +    sym = C_intern (&a, 11, "zlib:gzread");
    +    sym = C_intern (&a, 12, "zlib:gzwrite");
    +    sym = C_intern (&a, 13, "zlib:gzprintf");
    +    sym = C_intern (&a, 11, "zlib:gzputs");
    +    sym = C_intern (&a, 11, "zlib:gzgets");
    +    sym = C_intern (&a, 11, "zlib:gzputc");
    +    sym = C_intern (&a, 11, "zlib:gzgetc");
    +    sym = C_intern (&a, 12, "zlib:gzflush");
    +    sym = C_intern (&a, 11, "zlib:gzseek");
    +    sym = C_intern (&a, 13, "zlib:gzrewind");
    +    sym = C_intern (&a, 11, "zlib:gztell");
    +    sym = C_intern (&a, 10, "zlib:gzeof");
    +    sym = C_intern (&a, 12, "zlib:gzclose");
    +    sym = C_intern (&a, 12, "zlib:gzerror");
    +    sym = C_intern (&a, 12, "zlib:adler32");
    +    sym = C_intern (&a, 10, "zlib:crc32");
    +    sym = C_intern (&a, 18, "zlib:deflate-init-");
    +    sym = C_intern (&a, 18, "zlib:inflate-init-");
    +    sym = C_intern (&a, 19, "zlib:deflate-init2-");
    +    sym = C_intern (&a, 19, "zlib:inflate-init2-");
    +    sym = C_intern (&a, 29, "zlib:internal-state-dummy-set");
    +    sym = C_intern (&a, 29, "zlib:internal-state-dummy-get");
    +    sym = C_intern (&a, 23, "zlib:new-internal-state");
    +    sym = C_intern (&a, 26, "zlib:delete-internal-state");
    +    sym = C_intern (&a, 12, "zlib:z-error");
    +    sym = C_intern (&a, 23, "zlib:inflate-sync-point");
    +    sym = C_intern (&a, 18, "zlib:get-crc-table");
    +    sym = C_intern (&a, 17, "zlib:deflate-init");
    +    sym = C_intern (&a, 17, "zlib:inflate-init");
    +      
    +
    + + Perfect! Now let's integrate this zlib extension into a + CHICKEN interpreter. To save some time, in this + Examples/chicken/zlib directory: +
      +
    1. Backup the original example.i.
    2. +
    3. Copy and paste the example.i text from above and + put it into the file called example.i
    4. +
    5. Run 'make' as per Building the + example.
    6. +
    7. Run the resultant executable zlib.
    8. +
    + + The interpreter interaction is as follows: + +
    +
    +% ./zlib
    +zlib
    +
    +  A SWIG example for the CHICKEN compiler
    +  Author: Jonah Beckford, February 2003
    +
    +Scheme Procedures:
    +
    +zlib:max-mem-level
    +zlib:max-wbits
    +zlib:seek-set
    +zlib:seek-cur
    +zlib:seek-end
    +zlib:version
    +zlib:z-stream-next-in-set
    +zlib:z-stream-next-in-get
    +zlib:z-stream-avail-in-set
    +...
    +zlib:get-crc-table
    +zlib:deflate-init
    +zlib:inflate-init
    +; This is the CHICKEN interpreter - Version 0, Build 1095 - windows-cygwin-x86
    +; (c)2000-2003 Felix L. Winkelmann
    +>>> (define s (zlib:new-z-stream))
    +>>> s
    +#<tagged pointer #<c++ "z_stream *">(#<pointer 6d9290>)>
    +>>> (zlib:z-stream-next-in-get s)
    +#f
    +>>> (zlib:z-stream-next-in-set s "some dummy stream data")
    +Error: Type error. Expected _p_Bytef: "bad argument type"
    +>>> (exit)
    +      
    +
    + + Apparently we cannot use Scheme strings as Bytef *. The SWIG + manual shows many ways how to handle strings and byte arrays, but + to be simplistic, let's just make the Bytef * look + like a char *, which is automatically handled as a + string by SWIG CHICKEN. + +

    Attempt #5

    + + We make sure to add an %apply construct so that Bytef + * is handled the same as char * to SWIG. We + try again. + +
    +
    +/* File : example.i */
    +%module example
    +%{
    +/* Put headers and other declarations here */
    +#include "zlib.h"
    +%}
    +
    +%include typemaps.i
    +
    +%rename(VERSION) ZLIB_VERSION;
    +%rename(z_error) zError;
    +%apply char * { Bytef * };
    +
    +%include "zconf.h"
    +%include "zlib.h"
    +
    +%inline %{
    +/* %inline blocks are seen by SWIG and are inserted into the header
    +   portion of example_wrap.c, so that they are also seen by the C
    +   compiler. */
    +int deflate_init(z_streamp strm, int level) {
    +  return deflateInit(strm,level); /* call macro */
    +}
    +int inflate_init(z_streamp strm) {
    +  return inflateInit(strm); /* call macro */
    +}
    +%}
    +      
    +
    + + Build the example once more.
    + + The interpreter interaction is as follows: + +
    +
    +% ./zlib
    +zlib
    +
    +  A SWIG example for the CHICKEN compiler
    +  Author: Jonah Beckford, February 2003
    +
    +Scheme Procedures:
    +
    +zlib:max-mem-level
    +zlib:max-wbits
    +zlib:seek-set
    +zlib:seek-cur
    +zlib:seek-end
    +zlib:version
    +zlib:z-stream-next-in-set
    +zlib:z-stream-next-in-get
    +zlib:z-stream-avail-in-set
    +...
    +zlib:get-crc-table
    +zlib:deflate-init
    +zlib:inflate-init
    +; This is the CHICKEN interpreter - Version 0, Build 1095 - windows-cygwin-x86
    +; (c)2000-2003 Felix L. Winkelmann
    +>>> (define s (zlib:new-z-stream))
    +Init zstream
    +>>> (zlib:z-stream-zalloc-set s #f) 
    +>>> (zlib:z-stream-zfree-set s #f)
    +>>> (zlib:z-stream-opaque-set s #f)
    +>>> (zlib:deflate-init s (zlib:z-default-compression))
    +0
    +Deflate something small so we don't need to loop/stream data
    +>>> (define in "some dummy data")
    +>>> (define out (make-string 1000))
    +>>> (zlib:z-stream-next-in-set s in)
    +>>> (zlib:z-stream-avail-in-set s (string-length in))
    +>>> (zlib:z-stream-next-out-set s out)
    +>>> (zlib:z-stream-avail-out-set s (string-length out))
    +>>> (zlib:deflate s (zlib:z-finish))
    +1 ;; (zlib:z-stream-end) == 1, which is good
    +>>> (zlib:z-stream-total-out-get s)
    +23.
    +>>> out
    +"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        "
    +      
    +
    + + We see the problem ... the compression is occurring as it should, + but we cannot see any of the compressed output. This is because + when SWIG CHICKEN passes a Scheme string to a C function, it + duplicates the string before calling the C function. We want to + save the memory address that + zlib:z-stream-next-out-set is using, so we can + display this later. While we are at it, we can foresee that + compress, compress2 and + uncompress will all need some finessing to work with + mutating strings. + +

    Attempt #6

    + + When we have to finesse strings, we must use typemaps. As well, + we define some functions to save and restore the + next_out element. We try again. + +
    +
    +/* File : example.i */
    +%module example
    +%{
    +/* Put headers and other declarations here */
    +#include "zlib.h"
    +%}
    +
    +%include typemaps.i
    +
    +%rename(VERSION) ZLIB_VERSION;
    +%rename(z_error) zError;
    +%apply char * { Bytef * };
    +	
    +/* Allow the sourceLen to be automatically filled in from the length
    +   of the 'source' string */
    +%typemap(in) (const Bytef *source, uLong sourceLen)
    +%{  if (!C_swig_is_string ($input)) {
    +    swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
    +  }
    +  $2 = (uLong) C_header_size ($input);
    +  $1 = C_c_string ($input);
    +%}
    +
    +/* Allocate space the size of which is determined by the Scheme
    +   integer argument, and make a temporary integer so we can set
    +   destLen. */
    +%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len)
    +%{  if (!C_swig_is_fixnum ($input)) {
    +    swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer");
    +  }
    +  len = (uLong) C_unfix ($input);
    +  $2 = &len;
    +  $1 = (char *) malloc (*$2);
    +%}
    +
    +/* Return the mutated string as a new object. */
    +%typemap(argout) (Bytef *dest, uLongf *destLen) 
    +(C_word *scmstr) 
    +%{  scmstr = C_alloc (C_SIZEOF_STRING (*$2));
    +  SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
    +  free ($1);
    +%}
    +	
    +%include "zconf.h"
    +%include "zlib.h"
    +	
    +/* Ignore destLen as an input argument, and make a temporary integer so
    +   we can set destLen. */
    +%typemap(in, numinputs=0) uLongf *destLen (uLong len)
    +"$1 = &len;";
    +
    +/* Return a sized string as a new object. */
    +%typemap(argout)
    +(void *outstr, uLongf *destLen) (C_word *scmstr) 
    +%{  scmstr = C_alloc (C_SIZEOF_STRING (*$2));
    +  SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
    +%}
    +	
    +%inline %{
    +/* %inline blocks are seen by SWIG and are inserted into the header
    +   portion of example_wrap.c, so that they are also seen by the C
    +   compiler. */
    +int deflate_init(z_streamp strm, int level) {
    +  return deflateInit(strm,level); /* call macro */
    +}
    +int inflate_init(z_streamp strm) {
    +  return inflateInit(strm); /* call macro */
    +}
    +void* z_stream_save_next_out(z_streamp strm) {
    +  return (void*) strm->next_out;
    +}
    +void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) {
    +  *destLen = strm->next_out - (Bytef*)outstr;
    +}
    +%}
    +      
    +
    + + And that's it. Try building the entire example from the + Makefile. Run ./zlib test-zlib.scm to test it out. + + + diff --git a/Examples/chicken/zlib/example.i b/Examples/chicken/zlib/example.i new file mode 100644 index 0000000..dd962ad --- /dev/null +++ b/Examples/chicken/zlib/example.i @@ -0,0 +1,76 @@ +/* File : example.i */ +%module example +%{ +/* Put headers and other declarations here */ +#include "zlib.h" +%} + +%include typemaps.i + +%rename(VERSION) ZLIB_VERSION; +%rename(z_error) zError; +%apply char * { Bytef * }; + +/* Allow the sourceLen to be automatically filled in from the length + of the 'source' string */ +%typemap(in) (const Bytef *source, uLong sourceLen) +%{ if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string"); + } + $2 = (uLong) C_header_size ($input); + $1 = C_c_string ($input); +%} + +/* Allocate space the size of which is determined by the Scheme + integer argument, and make a temporary integer so we can set + destLen. */ +%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len) +%{ if (!C_swig_is_fixnum ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer"); + } + len = (uLong) C_unfix ($input); + $2 = &len; + $1 = (char *) malloc (*$2); +%} + +/* Return the mutated string as a new object. */ +%typemap(argout) (Bytef *dest, uLongf *destLen) +(C_word *scmstr) +%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2)); + SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1)); + free ($1); +%} + +%include "zconf.h" +%include "zlib.h" + +/* Ignore destLen as an input argument, and make a temporary integer so + we can set destLen. */ +%typemap(numinputs=0) uLongf *destLen (uLong len) +"$1 = &len;"; + +/* Return a sized string as a new object. */ +%typemap(argout) +(void *outstr, uLongf *destLen) (C_word *scmstr) +%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2)); + SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1)); +%} + +%inline %{ +/* %inline blocks are seen by SWIG and are inserted into the header + portion of example_wrap.c, so that they are also seen by the C + compiler. */ +int deflate_init(z_streamp strm, int level) { + return deflateInit(strm,level); /* call macro */ +} +int inflate_init(z_streamp strm) { + return inflateInit(strm); /* call macro */ +} +void* z_stream_save_next_out(z_streamp strm) { + return (void*) strm->next_out; +} +void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) { + *destLen = strm->next_out - (Bytef*)outstr; +} +%} + diff --git a/Examples/chicken/zlib/test-zlib.scm b/Examples/chicken/zlib/test-zlib.scm new file mode 100644 index 0000000..a13d801 --- /dev/null +++ b/Examples/chicken/zlib/test-zlib.scm @@ -0,0 +1,41 @@ +(load-library 'example "./zlib.so") + +;; Init zstream +(define s (new-z-stream)) +(z-stream-zalloc-set s #f) +(z-stream-zfree-set s #f) +(z-stream-opaque-set s #f) +(deflate-init s (Z-DEFAULT-COMPRESSION)) + +;; Deflate something small so we don't need to loop/stream data +(define in "some pony et jumping et jack et flash et had a jack pony") +(define out (make-string 1000)) +(printf "to be compressed: ~A~%to be compressed bytes: ~A~%~%" in (string-length in)) +(z-stream-next-in-set s in) +(z-stream-avail-in-set s (string-length in)) +(z-stream-next-out-set s out) +(z-stream-avail-out-set s (string-length out)) +(let* + ((saved-out (z-stream-save-next-out s)) + (ret (deflate s (Z-FINISH)))) + (cond + ((= ret (Z-STREAM-END)) + (printf "deflated properly!~%compressed bytes: ~A~%compressed stream: ~A~%" + (z-stream-total-out-get s) (z-stream-get-next-chunk s saved-out))) + ((= ret (Z-OK)) + (display "only partial deflation ... not enough output space\n")) + (else + (printf "deflate error(~D): ~A ~%" ret (z-stream-msg-get s))))) + +;; Use simple compress routine, and set max output size to 100 +(newline) +(call-with-values (lambda () (compress 100 in)) + (lambda (ret compressed) + (cond + ((= ret (Z-OK)) + (printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%" + (string-length compressed) compressed)) + (else + (printf "compress error(~D): ~A ~%" ret (z-error ret)))))) + +(exit 0) diff --git a/Examples/contract/simple_c/example.c b/Examples/contract/simple_c/example.c new file mode 100644 index 0000000..85a3e14 --- /dev/null +++ b/Examples/contract/simple_c/example.c @@ -0,0 +1,11 @@ +#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; +} diff --git a/Examples/contract/simple_c/example.i b/Examples/contract/simple_c/example.i new file mode 100644 index 0000000..49df09a --- /dev/null +++ b/Examples/contract/simple_c/example.i @@ -0,0 +1,19 @@ +/* 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); +%} diff --git a/Examples/contract/simple_c/runme1.py b/Examples/contract/simple_c/runme1.py new file mode 100644 index 0000000..abd8df6 --- /dev/null +++ b/Examples/contract/simple_c/runme1.py @@ -0,0 +1,17 @@ +import 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) diff --git a/Examples/contract/simple_c/runme2.py b/Examples/contract/simple_c/runme2.py new file mode 100644 index 0000000..48d4a3f --- /dev/null +++ b/Examples/contract/simple_c/runme2.py @@ -0,0 +1,20 @@ +import 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) diff --git a/Examples/contract/simple_cxx/example.cxx b/Examples/contract/simple_cxx/example.cxx new file mode 100644 index 0000000..e3dd2ca --- /dev/null +++ b/Examples/contract/simple_cxx/example.cxx @@ -0,0 +1,30 @@ +#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; +} diff --git a/Examples/contract/simple_cxx/example.h b/Examples/contract/simple_cxx/example.h new file mode 100644 index 0000000..64b7684 --- /dev/null +++ b/Examples/contract/simple_cxx/example.h @@ -0,0 +1,34 @@ +/* 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); +}; diff --git a/Examples/contract/simple_cxx/example.i b/Examples/contract/simple_cxx/example.i new file mode 100644 index 0000000..9b47409 --- /dev/null +++ b/Examples/contract/simple_cxx/example.i @@ -0,0 +1,28 @@ +%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" diff --git a/Examples/contract/simple_cxx/runme1.py b/Examples/contract/simple_cxx/runme1.py new file mode 100644 index 0000000..9028d02 --- /dev/null +++ b/Examples/contract/simple_cxx/runme1.py @@ -0,0 +1,33 @@ +import 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) diff --git a/Examples/contract/simple_cxx/runme2.py b/Examples/contract/simple_cxx/runme2.py new file mode 100644 index 0000000..5f9c0df --- /dev/null +++ b/Examples/contract/simple_cxx/runme2.py @@ -0,0 +1,44 @@ +import 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() diff --git a/Examples/contract/simple_cxx/runme3.py b/Examples/contract/simple_cxx/runme3.py new file mode 100644 index 0000000..a663732 --- /dev/null +++ b/Examples/contract/simple_cxx/runme3.py @@ -0,0 +1,57 @@ +import 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) diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile new file mode 100644 index 0000000..b3446d8 --- /dev/null +++ b/Examples/csharp/arrays/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -unsafe -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/arrays/example.c b/Examples/csharp/arrays/example.c new file mode 100644 index 0000000..2498e1f --- /dev/null +++ b/Examples/csharp/arrays/example.c @@ -0,0 +1,22 @@ +/* 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; + } +} + diff --git a/Examples/csharp/arrays/example.h b/Examples/csharp/arrays/example.h new file mode 100644 index 0000000..113b92c --- /dev/null +++ b/Examples/csharp/arrays/example.h @@ -0,0 +1,4 @@ + +void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); +void myArraySwap( int* array1, int* array2, int nitems ); + diff --git a/Examples/csharp/arrays/example.i b/Examples/csharp/arrays/example.i new file mode 100644 index 0000000..488565a --- /dev/null +++ b/Examples/csharp/arrays/example.i @@ -0,0 +1,45 @@ +/* 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); +} +%} + + diff --git a/Examples/csharp/arrays/runme.cs b/Examples/csharp/arrays/runme.cs new file mode 100644 index 0000000..c2b8a6b --- /dev/null +++ b/Examples/csharp/arrays/runme.cs @@ -0,0 +1,43 @@ +using 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(); + } +} + diff --git a/Examples/csharp/callback/Makefile b/Examples/csharp/callback/Makefile new file mode 100644 index 0000000..51b163b --- /dev/null +++ b/Examples/csharp/callback/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -debug -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/callback/example-cs.csproj b/Examples/csharp/callback/example-cs.csproj new file mode 100644 index 0000000..5fc3452 --- /dev/null +++ b/Examples/csharp/callback/example-cs.csproj @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/callback/example-vc.vcproj b/Examples/csharp/callback/example-vc.vcproj new file mode 100644 index 0000000..7c0b8ef --- /dev/null +++ b/Examples/csharp/callback/example-vc.vcproj @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/callback/example.cxx b/Examples/csharp/callback/example.cxx new file mode 100644 index 0000000..450d756 --- /dev/null +++ b/Examples/csharp/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/csharp/callback/example.h b/Examples/csharp/callback/example.h new file mode 100644 index 0000000..38d25a0 --- /dev/null +++ b/Examples/csharp/callback/example.h @@ -0,0 +1,24 @@ +/* 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(); } +}; + diff --git a/Examples/csharp/callback/example.i b/Examples/csharp/callback/example.i new file mode 100644 index 0000000..90beda0 --- /dev/null +++ b/Examples/csharp/callback/example.i @@ -0,0 +1,13 @@ +/* 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" + diff --git a/Examples/csharp/callback/example.sln b/Examples/csharp/callback/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/callback/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/callback/runme.cs b/Examples/csharp/callback/runme.cs new file mode 100644 index 0000000..a104b1a --- /dev/null +++ b/Examples/csharp/callback/runme.cs @@ -0,0 +1,46 @@ +using 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()"); + } +} + diff --git a/Examples/csharp/check.list b/Examples/csharp/check.list new file mode 100644 index 0000000..5454d85 --- /dev/null +++ b/Examples/csharp/check.list @@ -0,0 +1,11 @@ +# see top-level Makefile.in +arrays +callback +class +enum +extend +funcptr +reference +simple +template +variables diff --git a/Examples/csharp/class/Makefile b/Examples/csharp/class/Makefile new file mode 100644 index 0000000..20f0dd5 --- /dev/null +++ b/Examples/csharp/class/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/class/example-cs.csproj b/Examples/csharp/class/example-cs.csproj new file mode 100644 index 0000000..0b9ea2e --- /dev/null +++ b/Examples/csharp/class/example-cs.csproj @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/class/example-vc.vcproj b/Examples/csharp/class/example-vc.vcproj new file mode 100644 index 0000000..7c0b8ef --- /dev/null +++ b/Examples/csharp/class/example-vc.vcproj @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/class/example.cxx b/Examples/csharp/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/csharp/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/csharp/class/example.h b/Examples/csharp/class/example.h new file mode 100644 index 0000000..46d9013 --- /dev/null +++ b/Examples/csharp/class/example.h @@ -0,0 +1,39 @@ +/* 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); +}; + + + + + diff --git a/Examples/csharp/class/example.i b/Examples/csharp/class/example.i new file mode 100644 index 0000000..75700b3 --- /dev/null +++ b/Examples/csharp/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/csharp/class/example.sln b/Examples/csharp/class/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/class/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/class/runme.cs b/Examples/csharp/class/runme.cs new file mode 100644 index 0000000..9088031 --- /dev/null +++ b/Examples/csharp/class/runme.cs @@ -0,0 +1,66 @@ +// 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 + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/enum/example-vc.vcproj b/Examples/csharp/enum/example-vc.vcproj new file mode 100644 index 0000000..7c0b8ef --- /dev/null +++ b/Examples/csharp/enum/example-vc.vcproj @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/enum/example.cxx b/Examples/csharp/enum/example.cxx new file mode 100644 index 0000000..df7bb63 --- /dev/null +++ b/Examples/csharp/enum/example.cxx @@ -0,0 +1,37 @@ +/* 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"); + } +} diff --git a/Examples/csharp/enum/example.h b/Examples/csharp/enum/example.h new file mode 100644 index 0000000..9119cd9 --- /dev/null +++ b/Examples/csharp/enum/example.h @@ -0,0 +1,13 @@ +/* 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); + diff --git a/Examples/csharp/enum/example.i b/Examples/csharp/enum/example.i new file mode 100644 index 0000000..23ee8a8 --- /dev/null +++ b/Examples/csharp/enum/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ + +%include "example.h" + diff --git a/Examples/csharp/enum/example.sln b/Examples/csharp/enum/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/enum/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/enum/runme.cs b/Examples/csharp/enum/runme.cs new file mode 100644 index 0000000..42ba896 --- /dev/null +++ b/Examples/csharp/enum/runme.cs @@ -0,0 +1,31 @@ +using 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); + } +} diff --git a/Examples/csharp/extend/Makefile b/Examples/csharp/extend/Makefile new file mode 100644 index 0000000..20f0dd5 --- /dev/null +++ b/Examples/csharp/extend/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/extend/example-cs.csproj b/Examples/csharp/extend/example-cs.csproj new file mode 100644 index 0000000..4e88746 --- /dev/null +++ b/Examples/csharp/extend/example-cs.csproj @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/extend/example-vc.vcproj b/Examples/csharp/extend/example-vc.vcproj new file mode 100644 index 0000000..7c0b8ef --- /dev/null +++ b/Examples/csharp/extend/example-vc.vcproj @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/extend/example.cxx b/Examples/csharp/extend/example.cxx new file mode 100644 index 0000000..450d756 --- /dev/null +++ b/Examples/csharp/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/csharp/extend/example.h b/Examples/csharp/extend/example.h new file mode 100644 index 0000000..b27ab97 --- /dev/null +++ b/Examples/csharp/extend/example.h @@ -0,0 +1,56 @@ +/* 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; + } +}; + diff --git a/Examples/csharp/extend/example.i b/Examples/csharp/extend/example.i new file mode 100644 index 0000000..c8ec32e --- /dev/null +++ b/Examples/csharp/extend/example.i @@ -0,0 +1,15 @@ +/* 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" + diff --git a/Examples/csharp/extend/example.sln b/Examples/csharp/extend/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/extend/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/extend/runme.cs b/Examples/csharp/extend/runme.cs new file mode 100644 index 0000000..825dcdb --- /dev/null +++ b/Examples/csharp/extend/runme.cs @@ -0,0 +1,77 @@ +// 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" ); + } +} diff --git a/Examples/csharp/funcptr/Makefile b/Examples/csharp/funcptr/Makefile new file mode 100644 index 0000000..2233004 --- /dev/null +++ b/Examples/csharp/funcptr/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/funcptr/example-cs.csproj b/Examples/csharp/funcptr/example-cs.csproj new file mode 100644 index 0000000..5ff0d9d --- /dev/null +++ b/Examples/csharp/funcptr/example-cs.csproj @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/funcptr/example-vc.vcproj b/Examples/csharp/funcptr/example-vc.vcproj new file mode 100644 index 0000000..03047bf --- /dev/null +++ b/Examples/csharp/funcptr/example-vc.vcproj @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/funcptr/example.c b/Examples/csharp/funcptr/example.c new file mode 100644 index 0000000..5c4a3da --- /dev/null +++ b/Examples/csharp/funcptr/example.c @@ -0,0 +1,19 @@ +/* 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; diff --git a/Examples/csharp/funcptr/example.h b/Examples/csharp/funcptr/example.h new file mode 100644 index 0000000..9936e24 --- /dev/null +++ b/Examples/csharp/funcptr/example.h @@ -0,0 +1,9 @@ +/* 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); + diff --git a/Examples/csharp/funcptr/example.i b/Examples/csharp/funcptr/example.i new file mode 100644 index 0000000..8b3bef6 --- /dev/null +++ b/Examples/csharp/funcptr/example.i @@ -0,0 +1,16 @@ +/* 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); + diff --git a/Examples/csharp/funcptr/example.sln b/Examples/csharp/funcptr/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/funcptr/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/funcptr/runme.cs b/Examples/csharp/funcptr/runme.cs new file mode 100644 index 0000000..ba2e228 --- /dev/null +++ b/Examples/csharp/funcptr/runme.cs @@ -0,0 +1,27 @@ + +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() ); + } +} diff --git a/Examples/csharp/reference/Makefile b/Examples/csharp/reference/Makefile new file mode 100644 index 0000000..20f0dd5 --- /dev/null +++ b/Examples/csharp/reference/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/reference/example-cs.csproj b/Examples/csharp/reference/example-cs.csproj new file mode 100644 index 0000000..e55912b --- /dev/null +++ b/Examples/csharp/reference/example-cs.csproj @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/reference/example-vc.vcproj b/Examples/csharp/reference/example-vc.vcproj new file mode 100644 index 0000000..7c0b8ef --- /dev/null +++ b/Examples/csharp/reference/example-vc.vcproj @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/reference/example.cxx b/Examples/csharp/reference/example.cxx new file mode 100644 index 0000000..8a513bf --- /dev/null +++ b/Examples/csharp/reference/example.cxx @@ -0,0 +1,46 @@ +/* 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; +} + diff --git a/Examples/csharp/reference/example.h b/Examples/csharp/reference/example.h new file mode 100644 index 0000000..4915adb --- /dev/null +++ b/Examples/csharp/reference/example.h @@ -0,0 +1,26 @@ +/* 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(); +}; + + + + diff --git a/Examples/csharp/reference/example.i b/Examples/csharp/reference/example.i new file mode 100644 index 0000000..6daa3b1 --- /dev/null +++ b/Examples/csharp/reference/example.i @@ -0,0 +1,46 @@ +/* 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; + } + } +}; + + + + diff --git a/Examples/csharp/reference/example.sln b/Examples/csharp/reference/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/reference/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/reference/runme.cs b/Examples/csharp/reference/runme.cs new file mode 100644 index 0000000..499ddea --- /dev/null +++ b/Examples/csharp/reference/runme.cs @@ -0,0 +1,73 @@ +// 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(); + } +} diff --git a/Examples/csharp/simple/Makefile b/Examples/csharp/simple/Makefile new file mode 100644 index 0000000..2233004 --- /dev/null +++ b/Examples/csharp/simple/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/simple/example-cs.csproj b/Examples/csharp/simple/example-cs.csproj new file mode 100644 index 0000000..d801057 --- /dev/null +++ b/Examples/csharp/simple/example-cs.csproj @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/simple/example-vc.vcproj b/Examples/csharp/simple/example-vc.vcproj new file mode 100644 index 0000000..14f5004 --- /dev/null +++ b/Examples/csharp/simple/example-vc.vcproj @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/simple/example.c b/Examples/csharp/simple/example.c new file mode 100644 index 0000000..1c2af78 --- /dev/null +++ b/Examples/csharp/simple/example.c @@ -0,0 +1,18 @@ +/* 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; +} + + diff --git a/Examples/csharp/simple/example.i b/Examples/csharp/simple/example.i new file mode 100644 index 0000000..24093b9 --- /dev/null +++ b/Examples/csharp/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/csharp/simple/example.sln b/Examples/csharp/simple/example.sln new file mode 100644 index 0000000..9967f7e --- /dev/null +++ b/Examples/csharp/simple/example.sln @@ -0,0 +1,26 @@ +Microsoft 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 diff --git a/Examples/csharp/simple/runme.cs b/Examples/csharp/simple/runme.cs new file mode 100644 index 0000000..26106c6 --- /dev/null +++ b/Examples/csharp/simple/runme.cs @@ -0,0 +1,25 @@ +using 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); + } +} diff --git a/Examples/csharp/template/Makefile b/Examples/csharp/template/Makefile new file mode 100644 index 0000000..3f3bbe6 --- /dev/null +++ b/Examples/csharp/template/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/template/example-cs.csproj b/Examples/csharp/template/example-cs.csproj new file mode 100644 index 0000000..b51122b --- /dev/null +++ b/Examples/csharp/template/example-cs.csproj @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/template/example-vc.vcproj b/Examples/csharp/template/example-vc.vcproj new file mode 100644 index 0000000..867e694 --- /dev/null +++ b/Examples/csharp/template/example-vc.vcproj @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/template/example.h b/Examples/csharp/template/example.h new file mode 100644 index 0000000..7401df6 --- /dev/null +++ b/Examples/csharp/template/example.h @@ -0,0 +1,32 @@ +/* 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 +}; + diff --git a/Examples/csharp/template/example.i b/Examples/csharp/template/example.i new file mode 100644 index 0000000..8f94c4d --- /dev/null +++ b/Examples/csharp/template/example.i @@ -0,0 +1,17 @@ +/* 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; + diff --git a/Examples/csharp/template/example.sln b/Examples/csharp/template/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/template/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/template/runme.cs b/Examples/csharp/template/runme.cs new file mode 100644 index 0000000..b2a8e6a --- /dev/null +++ b/Examples/csharp/template/runme.cs @@ -0,0 +1,39 @@ +// 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); + } + } +} diff --git a/Examples/csharp/variables/Makefile b/Examples/csharp/variables/Makefile new file mode 100644 index 0000000..2233004 --- /dev/null +++ b/Examples/csharp/variables/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -out:runme.exe + +all:: csharp + +csharp:: + $(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 + +check: all diff --git a/Examples/csharp/variables/example-cs.csproj b/Examples/csharp/variables/example-cs.csproj new file mode 100644 index 0000000..f0e0159 --- /dev/null +++ b/Examples/csharp/variables/example-cs.csproj @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/variables/example-vc.vcproj b/Examples/csharp/variables/example-vc.vcproj new file mode 100644 index 0000000..be0dfc7 --- /dev/null +++ b/Examples/csharp/variables/example-vc.vcproj @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/variables/example.c b/Examples/csharp/variables/example.c new file mode 100644 index 0000000..aa4ffe9 --- /dev/null +++ b/Examples/csharp/variables/example.c @@ -0,0 +1,91 @@ +/* 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); +} diff --git a/Examples/csharp/variables/example.h b/Examples/csharp/variables/example.h new file mode 100644 index 0000000..0f7e895 --- /dev/null +++ b/Examples/csharp/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/csharp/variables/example.i b/Examples/csharp/variables/example.i new file mode 100644 index 0000000..591b871 --- /dev/null +++ b/Examples/csharp/variables/example.i @@ -0,0 +1,49 @@ +/* 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(); +%} + diff --git a/Examples/csharp/variables/example.sln b/Examples/csharp/variables/example.sln new file mode 100644 index 0000000..28b9851 --- /dev/null +++ b/Examples/csharp/variables/example.sln @@ -0,0 +1,30 @@ +Microsoft 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 diff --git a/Examples/csharp/variables/runme.cs b/Examples/csharp/variables/runme.cs new file mode 100644 index 0000000..3d19b6a --- /dev/null +++ b/Examples/csharp/variables/runme.cs @@ -0,0 +1,82 @@ +// 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) ); + } +} diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in new file mode 100644 index 0000000..a110955 --- /dev/null +++ b/Examples/guile/Makefile.in @@ -0,0 +1,40 @@ +# Makefile for Guile. Used by all of the example programs. + +subdirs = simple matrix port constants multimap multivalue + +top_srcdir = @top_srcdir@ +SWIG = ../$(top_srcdir)/preinst-swig +CC = @CC@ +CXX = @CXX@ +CFLAGS = @PLATFLAGS@ +GUILEINCLUDE = @GUILEINCLUDE@ +GUILELINK = @GUILELINK@ +SWIGOPT = + +WRAP = $(IFILE:.i=_wrap.c) +CXXWRAP = $(IFILE:.i=_wrap.cxx) + +SO = @SO@ + +all: + for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done + +clean:: + for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done + rm -f *~ .~* + +guile_clean: + rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core my-guile $(TARGET) + +# This is meant to be used w/ "make -f ../Makefile" from subdirs. +# Doesn't make sense to use it from here. + +sub-all:: + $(SWIG) -guile $(SWIGOPT) $(IFILE) + $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK) + +sub-all-cxx:: + $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) + $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILEINCLUDE) $(GUILELINK) + +# Makefile ends here diff --git a/Examples/guile/README b/Examples/guile/README new file mode 100644 index 0000000..acec777 --- /dev/null +++ b/Examples/guile/README @@ -0,0 +1,17 @@ +This directory contains examples for Guile. + +constants -- handling #define and %constant literals +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. + +If you want to put the wrapped functions into an own module, +statically or dynamically linked, see the Examples/GIFPlot/Guile +directory. diff --git a/Examples/guile/check.list b/Examples/guile/check.list new file mode 100644 index 0000000..d35b2d6 --- /dev/null +++ b/Examples/guile/check.list @@ -0,0 +1,7 @@ +# see top-level Makefile.in +constants +matrix +simple +port +multimap +multivalue diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile new file mode 100644 index 0000000..70243c7 --- /dev/null +++ b/Examples/guile/constants/Makefile @@ -0,0 +1,17 @@ +SRCS = +TARGET = my-guile +IFILE = example.i +MKDIR = .. + +all:: + $(MAKE) -f $(MKDIR)/Makefile \ + SRCS='$(SRCS)' \ + TARGET=$(TARGET) \ + IFILE=$(IFILE) \ + sub-all + +clean:: + $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean + +check: all + ./my-guile -s constants.scm diff --git a/Examples/guile/constants/constants.scm b/Examples/guile/constants/constants.scm new file mode 100644 index 0000000..5220150 --- /dev/null +++ b/Examples/guile/constants/constants.scm @@ -0,0 +1,10 @@ +(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 (= (iconst) 37) (exit 1)) +(or (< (abs (- (fconst) 3.14)) 0.00001) (exit 1)) +(exit 0) diff --git a/Examples/guile/constants/example.i b/Examples/guile/constants/example.i new file mode 100644 index 0000000..0b602e5 --- /dev/null +++ b/Examples/guile/constants/example.i @@ -0,0 +1,27 @@ +/* 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 diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile new file mode 100644 index 0000000..5df2c65 --- /dev/null +++ b/Examples/guile/matrix/Makefile @@ -0,0 +1,18 @@ +SRCS = matrix.c vector.c +TARGET = matrix +IFILE = package.i +MKDIR = .. + + +all:: + $(MAKE) -f $(MKDIR)/Makefile \ + SRCS='$(SRCS)' \ + TARGET=$(TARGET) \ + IFILE=$(IFILE) \ + MODULE=$(MODULE) \ + sub-all + +clean:: + $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean + +check: all diff --git a/Examples/guile/matrix/README b/Examples/guile/matrix/README new file mode 100644 index 0000000..dc19577 --- /dev/null +++ b/Examples/guile/matrix/README @@ -0,0 +1,13 @@ +Matrix example. To run the example, execute the program 'matrix' and +type the following : + + (load "matrix.scm") + (do-test 0) + +Alternatively, use the command-line: + + ./matrix -e do-test -s matrix.scm + +Or, if your operating system is spiffy enough: + + ./matrix.scm diff --git a/Examples/guile/matrix/main.c b/Examples/guile/matrix/main.c new file mode 100644 index 0000000..88209ae --- /dev/null +++ b/Examples/guile/matrix/main.c @@ -0,0 +1,24 @@ +#include +extern int matrix_init(Tcl_Interp *); /* Init function from matrix.i */ + +int main() { + + int code; + char input[1024]; + Tcl_Interp *interp; + + interp = Tcl_CreateInterp(); + + /* Initialize the wrappers */ + + if (matrix_init(interp) == TCL_ERROR) + exit(0); + + fprintf(stdout,"matrix > "); + while(fgets(input, 1024, stdin) != NULL) { + code = Tcl_Eval(interp, input); + fprintf(stdout,"%s\n",interp->result); + fprintf(stdout,"matrix > "); + } +} + diff --git a/Examples/guile/matrix/matrix.c b/Examples/guile/matrix/matrix.c new file mode 100644 index 0000000..6ce1009 --- /dev/null +++ b/Examples/guile/matrix/matrix.c @@ -0,0 +1,61 @@ +/* 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]; +} + + + + + + + diff --git a/Examples/guile/matrix/matrix.i b/Examples/guile/matrix/matrix.i new file mode 100644 index 0000000..d61f0dc --- /dev/null +++ b/Examples/guile/matrix/matrix.i @@ -0,0 +1,36 @@ +// +// 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*/ + +} diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/matrix.scm new file mode 100644 index 0000000..18e5284 --- /dev/null +++ b/Examples/guile/matrix/matrix.scm @@ -0,0 +1,210 @@ +#!./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) () (begin + (add-two M (car ML) 0 0) + (add-mat M (cdr ML))))) + +(define (cleanup ML) + (if (null? ML) () (begin + (destroy-matrix (car ML)) + (cleanup (cdr ML))))) + +(define (make-random ML) ; Put random values in them + (if (null? ML) () (begin + (randmat (car ML)) + (make-random (cdr ML))))) + +(define (mul-mat m ML) + (if (null? ML) () (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)) + +;;; matrix.scm ends here diff --git a/Examples/guile/matrix/package.i b/Examples/guile/matrix/package.i new file mode 100644 index 0000000..aaa5551 --- /dev/null +++ b/Examples/guile/matrix/package.i @@ -0,0 +1,20 @@ +// FILE : package.i +// See the SWIG users manual + +/*** Matrix and vector package ***/ + +%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(); diff --git a/Examples/guile/matrix/vector.c b/Examples/guile/matrix/vector.c new file mode 100644 index 0000000..3012993 --- /dev/null +++ b/Examples/guile/matrix/vector.c @@ -0,0 +1,44 @@ +/* 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; + +} + + + diff --git a/Examples/guile/matrix/vector.h b/Examples/guile/matrix/vector.h new file mode 100644 index 0000000..a6b5f35 --- /dev/null +++ b/Examples/guile/matrix/vector.h @@ -0,0 +1,10 @@ + +#include + +typedef struct { + double x; + double y; + double z; + double w; +} Vector; + diff --git a/Examples/guile/matrix/vector.i b/Examples/guile/matrix/vector.i new file mode 100644 index 0000000..b6c2ef9 --- /dev/null +++ b/Examples/guile/matrix/vector.i @@ -0,0 +1,22 @@ +// +// 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 */ + +} diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile new file mode 100644 index 0000000..dc9c66d --- /dev/null +++ b/Examples/guile/multimap/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(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 + +check: all diff --git a/Examples/guile/multimap/example.c b/Examples/guile/multimap/example.c new file mode 100644 index 0000000..b8360fa --- /dev/null +++ b/Examples/guile/multimap/example.c @@ -0,0 +1,53 @@ +/* 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); + } +} diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i new file mode 100644 index 0000000..7337d1e --- /dev/null +++ b/Examples/guile/multimap/example.i @@ -0,0 +1,87 @@ +/* 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; + SCM *v; + if (!(SCM_NIMP($input) && SCM_VECTORP($input))) { + SWIG_exception(SWIG_ValueError, "Expecting a vector"); + return 0; + } + $1 = SCM_LENGTH($input); + if ($1 == 0) { + SWIG_exception(SWIG_ValueError, "Vector must contain at least 1 element"); + } + $2 = (char **) malloc(($1+1)*sizeof(char *)); + v = SCM_VELTS($input); + for (i = 0; i < $1; i++) { + if (!(SCM_NIMP(v[i]) && SCM_STRINGP(v[i]))) { + free($2); + SWIG_exception(SWIG_ValueError, "Vector items must be strings"); + return 0; + } + $2[i] = SCM_CHARS(v[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 (!(SCM_NIMP($input) && SCM_STRINGP($input))) { + SWIG_exception(SWIG_ValueError, "Expecting a string"); + } + $1 = SCM_CHARS($input); + $2 = SCM_LENGTH($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) { + size_t temp; + $1 = gh_scm2newstr($input,&temp); + $2 = temp; +} + +/* Return the mutated string as a new object. */ + +%typemap(argout) (char *str, int len) { + SWIG_APPEND_VALUE(gh_str2scm($1,$2)); + if ($1) scm_must_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); + + diff --git a/Examples/guile/multimap/runme.scm b/Examples/guile/multimap/runme.scm new file mode 100644 index 0000000..edc1972 --- /dev/null +++ b/Examples/guile/multimap/runme.scm @@ -0,0 +1,30 @@ +;;; Test out some multi-argument typemaps + +(use-modules (example)) + +; 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) + + diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile new file mode 100644 index 0000000..dc9c66d --- /dev/null +++ b/Examples/guile/multivalue/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(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 + +check: all diff --git a/Examples/guile/multivalue/example.c b/Examples/guile/multivalue/example.c new file mode 100644 index 0000000..c9ebad1 --- /dev/null +++ b/Examples/guile/multivalue/example.c @@ -0,0 +1,18 @@ +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; +} + diff --git a/Examples/guile/multivalue/example.i b/Examples/guile/multivalue/example.i new file mode 100644 index 0000000..1353894 --- /dev/null +++ b/Examples/guile/multivalue/example.i @@ -0,0 +1,32 @@ +/* -*- 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); + diff --git a/Examples/guile/multivalue/runme.scm b/Examples/guile/multivalue/runme.scm new file mode 100644 index 0000000..73eb5af --- /dev/null +++ b/Examples/guile/multivalue/runme.scm @@ -0,0 +1,66 @@ +;;;; Show the three different ways to deal with multiple return values + +(use-modules (example)) + +;;; 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)) + diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile new file mode 100644 index 0000000..824f3f8 --- /dev/null +++ b/Examples/guile/port/Makefile @@ -0,0 +1,18 @@ +SRCS = port.c +TARGET = port +IFILE = port.i +MKDIR = .. + + +all:: + $(MAKE) -f $(MKDIR)/Makefile \ + SRCS='$(SRCS)' \ + TARGET=$(TARGET) \ + IFILE=$(IFILE) \ + MODULE=$(MODULE) \ + sub-all + +clean:: + $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean + +check: all diff --git a/Examples/guile/port/README b/Examples/guile/port/README new file mode 100644 index 0000000..5ed0199 --- /dev/null +++ b/Examples/guile/port/README @@ -0,0 +1,2 @@ +This example illustrates the translation from Scheme file ports to +temporary FILE streams. Read the source and run ./port -s port.scm diff --git a/Examples/guile/port/port.c b/Examples/guile/port/port.c new file mode 100644 index 0000000..95867b6 --- /dev/null +++ b/Examples/guile/port/port.c @@ -0,0 +1,18 @@ +#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; +} diff --git a/Examples/guile/port/port.i b/Examples/guile/port/port.i new file mode 100644 index 0000000..eb75391 --- /dev/null +++ b/Examples/guile/port/port.i @@ -0,0 +1,15 @@ +%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); +%} diff --git a/Examples/guile/port/port.scm b/Examples/guile/port/port.scm new file mode 100644 index 0000000..68e9b8e --- /dev/null +++ b/Examples/guile/port/port.scm @@ -0,0 +1,32 @@ +;; 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 + (write args) (newline))) + +;; Read from a file port. Note that it is a bad idea to mix Scheme and +;; C input because of buffering. +(with-input-from-file "test.out" + (lambda () + (display (read-int (current-input-port))) + (newline))) + diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile new file mode 100644 index 0000000..702b5bb --- /dev/null +++ b/Examples/guile/simple/Makefile @@ -0,0 +1,19 @@ +SRCS = example.c +TARGET = my-guile +IFILE = example.i +MKDIR = .. + +all: $(TARGET) + +$(TARGET): + $(MAKE) -f $(MKDIR)/Makefile \ + SRCS='$(SRCS)' \ + TARGET=$(TARGET) \ + IFILE=$(IFILE) \ + sub-all + +clean:: + $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean + +check: $(TARGET) + ./$(TARGET) -s example.scm > /dev/null diff --git a/Examples/guile/simple/README b/Examples/guile/simple/README new file mode 100644 index 0000000..982216e --- /dev/null +++ b/Examples/guile/simple/README @@ -0,0 +1,9 @@ +A very simple example. + +To run it, start the program 'my-guile' and type: + + (load "example.scm") + +Alternatively, you can use the shell command: + + ./my-guile -s example.scm diff --git a/Examples/guile/simple/example.c b/Examples/guile/simple/example.c new file mode 100644 index 0000000..dcafc4d --- /dev/null +++ b/Examples/guile/simple/example.c @@ -0,0 +1,21 @@ +/* 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); +} diff --git a/Examples/guile/simple/example.i b/Examples/guile/simple/example.i new file mode 100644 index 0000000..1a9930a --- /dev/null +++ b/Examples/guile/simple/example.i @@ -0,0 +1,14 @@ +/* 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 diff --git a/Examples/guile/simple/example.scm b/Examples/guile/simple/example.scm new file mode 100644 index 0000000..9408b1a --- /dev/null +++ b/Examples/guile/simple/example.scm @@ -0,0 +1,28 @@ +;;; example.scm + +(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)))) + +;;; example.scm ends here diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile new file mode 100644 index 0000000..2733fb0 --- /dev/null +++ b/Examples/guile/std_vector/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp + +clean:: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean + +check: all diff --git a/Examples/guile/std_vector/example.h b/Examples/guile/std_vector/example.h new file mode 100644 index 0000000..4f0dac7 --- /dev/null +++ b/Examples/guile/std_vector/example.h @@ -0,0 +1,25 @@ +/* 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)); +} + + diff --git a/Examples/guile/std_vector/example.i b/Examples/guile/std_vector/example.i new file mode 100644 index 0000000..aa58b66 --- /dev/null +++ b/Examples/guile/std_vector/example.i @@ -0,0 +1,17 @@ +/* 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" + diff --git a/Examples/guile/std_vector/runme.scm b/Examples/guile/std_vector/runme.scm new file mode 100644 index 0000000..77443a1 --- /dev/null +++ b/Examples/guile/std_vector/runme.scm @@ -0,0 +1,54 @@ +;; run with mzscheme -r example.scm + +(use-modules (example)) + +; 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) + diff --git a/Examples/index.html b/Examples/index.html new file mode 100644 index 0000000..f8b614a --- /dev/null +++ b/Examples/index.html @@ -0,0 +1,58 @@ + + +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. + +

    Real Life

    + +The GIFPlot directory contains examples that illustrate the use of SWIG with +a moderately complex C library for creating GIF images. Many of these +examples illustrate more advanced SWIG features. + + + + + diff --git a/Examples/java/callback/Makefile b/Examples/java/callback/Makefile new file mode 100644 index 0000000..14c3017 --- /dev/null +++ b/Examples/java/callback/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/callback/example.cxx b/Examples/java/callback/example.cxx new file mode 100644 index 0000000..450d756 --- /dev/null +++ b/Examples/java/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/java/callback/example.h b/Examples/java/callback/example.h new file mode 100644 index 0000000..1a0e8c4 --- /dev/null +++ b/Examples/java/callback/example.h @@ -0,0 +1,23 @@ +/* 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(); } +}; + diff --git a/Examples/java/callback/example.i b/Examples/java/callback/example.i new file mode 100644 index 0000000..90beda0 --- /dev/null +++ b/Examples/java/callback/example.i @@ -0,0 +1,13 @@ +/* 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" + diff --git a/Examples/java/callback/index.html b/Examples/java/callback/index.html new file mode 100644 index 0000000..c254520 --- /dev/null +++ b/Examples/java/callback/index.html @@ -0,0 +1,20 @@ + + +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. +

    + +
    + + diff --git a/Examples/java/callback/runme.java b/Examples/java/callback/runme.java new file mode 100644 index 0000000..4090f0a --- /dev/null +++ b/Examples/java/callback/runme.java @@ -0,0 +1,56 @@ +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[] 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()"); + } +} + diff --git a/Examples/java/check.list b/Examples/java/check.list new file mode 100644 index 0000000..9728342 --- /dev/null +++ b/Examples/java/check.list @@ -0,0 +1,15 @@ +# see top-level Makefile.in +callback +class +constants +enum +extend +funcptr +multimap +native +pointer +reference +simple +template +typemap +variables diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile new file mode 100644 index 0000000..14c3017 --- /dev/null +++ b/Examples/java/class/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/class/example.cxx b/Examples/java/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/java/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/java/class/example.dsp b/Examples/java/class/example.dsp new file mode 100644 index 0000000..fbe87e7 --- /dev/null +++ b/Examples/java/class/example.dsp @@ -0,0 +1,162 @@ +# 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 diff --git a/Examples/java/class/example.h b/Examples/java/class/example.h new file mode 100644 index 0000000..46d9013 --- /dev/null +++ b/Examples/java/class/example.h @@ -0,0 +1,39 @@ +/* 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); +}; + + + + + diff --git a/Examples/java/class/example.i b/Examples/java/class/example.i new file mode 100644 index 0000000..75700b3 --- /dev/null +++ b/Examples/java/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/java/class/index.html b/Examples/java/class/index.html new file mode 100644 index 0000000..cf9130c --- /dev/null +++ b/Examples/java/class/index.html @@ -0,0 +1,197 @@ + + +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). + +
      +
    + +
    + + diff --git a/Examples/java/class/runme.java b/Examples/java/class/runme.java new file mode 100644 index 0000000..e1ea0d7 --- /dev/null +++ b/Examples/java/class/runme.java @@ -0,0 +1,70 @@ +// 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: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). +
    + +
    + + + + diff --git a/Examples/java/constants/runme.java b/Examples/java/constants/runme.java new file mode 100644 index 0000000..2c67d86 --- /dev/null +++ b/Examples/java/constants/runme.java @@ -0,0 +1,44 @@ +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[]) + { + 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)"); + } + } +} diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile new file mode 100644 index 0000000..14c3017 --- /dev/null +++ b/Examples/java/enum/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/enum/example.cxx b/Examples/java/enum/example.cxx new file mode 100644 index 0000000..df7bb63 --- /dev/null +++ b/Examples/java/enum/example.cxx @@ -0,0 +1,37 @@ +/* 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"); + } +} diff --git a/Examples/java/enum/example.h b/Examples/java/enum/example.h new file mode 100644 index 0000000..9119cd9 --- /dev/null +++ b/Examples/java/enum/example.h @@ -0,0 +1,13 @@ +/* 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); + diff --git a/Examples/java/enum/example.i b/Examples/java/enum/example.i new file mode 100644 index 0000000..fb65689 --- /dev/null +++ b/Examples/java/enum/example.i @@ -0,0 +1,14 @@ +/* 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" + diff --git a/Examples/java/enum/index.html b/Examples/java/enum/index.html new file mode 100644 index 0000000..20daf26 --- /dev/null +++ b/Examples/java/enum/index.html @@ -0,0 +1,29 @@ + + +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. + + +

    + +
    + + diff --git a/Examples/java/enum/runme.java b/Examples/java/enum/runme.java new file mode 100644 index 0000000..56e49af --- /dev/null +++ b/Examples/java/enum/runme.java @@ -0,0 +1,38 @@ + +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); + } +} diff --git a/Examples/java/extend/Makefile b/Examples/java/extend/Makefile new file mode 100644 index 0000000..14c3017 --- /dev/null +++ b/Examples/java/extend/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/extend/example.cxx b/Examples/java/extend/example.cxx new file mode 100644 index 0000000..450d756 --- /dev/null +++ b/Examples/java/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/java/extend/example.h b/Examples/java/extend/example.h new file mode 100644 index 0000000..b27ab97 --- /dev/null +++ b/Examples/java/extend/example.h @@ -0,0 +1,56 @@ +/* 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; + } +}; + diff --git a/Examples/java/extend/example.i b/Examples/java/extend/example.i new file mode 100644 index 0000000..c8ec32e --- /dev/null +++ b/Examples/java/extend/example.i @@ -0,0 +1,15 @@ +/* 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" + diff --git a/Examples/java/extend/index.html b/Examples/java/extend/index.html new file mode 100644 index 0000000..c7c2c12 --- /dev/null +++ b/Examples/java/extend/index.html @@ -0,0 +1,19 @@ + + +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. + +


    + + diff --git a/Examples/java/extend/runme.java b/Examples/java/extend/runme.java new file mode 100644 index 0000000..629bb14 --- /dev/null +++ b/Examples/java/extend/runme.java @@ -0,0 +1,88 @@ +// 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" ); + + } +} diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile new file mode 100644 index 0000000..968c92c --- /dev/null +++ b/Examples/java/funcptr/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/funcptr/example.c b/Examples/java/funcptr/example.c new file mode 100644 index 0000000..5c4a3da --- /dev/null +++ b/Examples/java/funcptr/example.c @@ -0,0 +1,19 @@ +/* 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; diff --git a/Examples/java/funcptr/example.h b/Examples/java/funcptr/example.h new file mode 100644 index 0000000..9936e24 --- /dev/null +++ b/Examples/java/funcptr/example.h @@ -0,0 +1,9 @@ +/* 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); + diff --git a/Examples/java/funcptr/example.i b/Examples/java/funcptr/example.i new file mode 100644 index 0000000..8b3bef6 --- /dev/null +++ b/Examples/java/funcptr/example.i @@ -0,0 +1,16 @@ +/* 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); + diff --git a/Examples/java/funcptr/index.html b/Examples/java/funcptr/index.html new file mode 100644 index 0000000..56d3baa --- /dev/null +++ b/Examples/java/funcptr/index.html @@ -0,0 +1,91 @@ + + +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. +
    + +
    + + + + + + diff --git a/Examples/java/funcptr/runme.java b/Examples/java/funcptr/runme.java new file mode 100644 index 0000000..cd34c1b --- /dev/null +++ b/Examples/java/funcptr/runme.java @@ -0,0 +1,33 @@ + +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() ); + } +} diff --git a/Examples/java/index.html b/Examples/java/index.html new file mode 100644 index 0000000..007e14d --- /dev/null +++ b/Examples/java/index.html @@ -0,0 +1,65 @@ + + +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. + + + + diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile new file mode 100644 index 0000000..968c92c --- /dev/null +++ b/Examples/java/multimap/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/multimap/example.c b/Examples/java/multimap/example.c new file mode 100644 index 0000000..b8360fa --- /dev/null +++ b/Examples/java/multimap/example.c @@ -0,0 +1,53 @@ +/* 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); + } +} diff --git a/Examples/java/multimap/example.dsp b/Examples/java/multimap/example.dsp new file mode 100644 index 0000000..8e1f841 --- /dev/null +++ b/Examples/java/multimap/example.dsp @@ -0,0 +1,158 @@ +# 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 diff --git a/Examples/java/multimap/example.i b/Examples/java/multimap/example.i new file mode 100644 index 0000000..8d67282 --- /dev/null +++ b/Examples/java/multimap/example.i @@ -0,0 +1,109 @@ +/* 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); + + diff --git a/Examples/java/multimap/runme.java b/Examples/java/multimap/runme.java new file mode 100644 index 0000000..738330e --- /dev/null +++ b/Examples/java/multimap/runme.java @@ -0,0 +1,40 @@ + +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]); + } +} + + + + + + + diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile new file mode 100644 index 0000000..92afbd4 --- /dev/null +++ b/Examples/java/native/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/native/example.i b/Examples/java/native/example.i new file mode 100644 index 0000000..851b6fd --- /dev/null +++ b/Examples/java/native/example.i @@ -0,0 +1,56 @@ +/* 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); diff --git a/Examples/java/native/index.html b/Examples/java/native/index.html new file mode 100644 index 0000000..1ca51c1 --- /dev/null +++ b/Examples/java/native/index.html @@ -0,0 +1,33 @@ + + +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. +
    + +
    + + diff --git a/Examples/java/native/runme.java b/Examples/java/native/runme.java new file mode 100644 index 0000000..e9a18b2 --- /dev/null +++ b/Examples/java/native/runme.java @@ -0,0 +1,19 @@ + +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 + } +} diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile new file mode 100644 index 0000000..968c92c --- /dev/null +++ b/Examples/java/pointer/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/pointer/example.c b/Examples/java/pointer/example.c new file mode 100644 index 0000000..b877d9a --- /dev/null +++ b/Examples/java/pointer/example.c @@ -0,0 +1,16 @@ +/* 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; +} diff --git a/Examples/java/pointer/example.i b/Examples/java/pointer/example.i new file mode 100644 index 0000000..a8ac794 --- /dev/null +++ b/Examples/java/pointer/example.i @@ -0,0 +1,30 @@ +/* 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); + + + + diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html new file mode 100644 index 0000000..e20fe33 --- /dev/null +++ b/Examples/java/pointer/index.html @@ -0,0 +1,165 @@ + + +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. + +
    + +
    + + diff --git a/Examples/java/pointer/runme.java b/Examples/java/pointer/runme.java new file mode 100644 index 0000000..f32f980 --- /dev/null +++ b/Examples/java/pointer/runme.java @@ -0,0 +1,55 @@ + +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]); + } +} diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile new file mode 100644 index 0000000..14c3017 --- /dev/null +++ b/Examples/java/reference/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/reference/example.cxx b/Examples/java/reference/example.cxx new file mode 100644 index 0000000..8a513bf --- /dev/null +++ b/Examples/java/reference/example.cxx @@ -0,0 +1,46 @@ +/* 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; +} + diff --git a/Examples/java/reference/example.h b/Examples/java/reference/example.h new file mode 100644 index 0000000..4915adb --- /dev/null +++ b/Examples/java/reference/example.h @@ -0,0 +1,26 @@ +/* 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(); +}; + + + + diff --git a/Examples/java/reference/example.i b/Examples/java/reference/example.i new file mode 100644 index 0000000..6daa3b1 --- /dev/null +++ b/Examples/java/reference/example.i @@ -0,0 +1,46 @@ +/* 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; + } + } +}; + + + + diff --git a/Examples/java/reference/index.html b/Examples/java/reference/index.html new file mode 100644 index 0000000..33c80c5 --- /dev/null +++ b/Examples/java/reference/index.html @@ -0,0 +1,147 @@ + + +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. + +
    + +
    + + diff --git a/Examples/java/reference/runme.java b/Examples/java/reference/runme.java new file mode 100644 index 0000000..6a2d9bf --- /dev/null +++ b/Examples/java/reference/runme.java @@ -0,0 +1,79 @@ +// 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(); + } +} diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile new file mode 100644 index 0000000..968c92c --- /dev/null +++ b/Examples/java/simple/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/simple/example.c b/Examples/java/simple/example.c new file mode 100644 index 0000000..1c2af78 --- /dev/null +++ b/Examples/java/simple/example.c @@ -0,0 +1,18 @@ +/* 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; +} + + diff --git a/Examples/java/simple/example.dsp b/Examples/java/simple/example.dsp new file mode 100644 index 0000000..8e1f841 --- /dev/null +++ b/Examples/java/simple/example.dsp @@ -0,0 +1,158 @@ +# 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 diff --git a/Examples/java/simple/example.i b/Examples/java/simple/example.i new file mode 100644 index 0000000..24093b9 --- /dev/null +++ b/Examples/java/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/java/simple/index.html b/Examples/java/simple/index.html new file mode 100644 index 0000000..9729e6d --- /dev/null +++ b/Examples/java/simple/index.html @@ -0,0 +1,108 @@ + + +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);
      +
      +
      +
    + +
    + + diff --git a/Examples/java/simple/runme.java b/Examples/java/simple/runme.java new file mode 100644 index 0000000..92880e8 --- /dev/null +++ b/Examples/java/simple/runme.java @@ -0,0 +1,32 @@ + +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()); + } +} diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile new file mode 100644 index 0000000..2b3d35c --- /dev/null +++ b/Examples/java/template/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/template/example.h b/Examples/java/template/example.h new file mode 100644 index 0000000..7401df6 --- /dev/null +++ b/Examples/java/template/example.h @@ -0,0 +1,32 @@ +/* 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 +}; + diff --git a/Examples/java/template/example.i b/Examples/java/template/example.i new file mode 100644 index 0000000..8f94c4d --- /dev/null +++ b/Examples/java/template/example.i @@ -0,0 +1,17 @@ +/* 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; + diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html new file mode 100644 index 0000000..f4408e5 --- /dev/null +++ b/Examples/java/template/index.html @@ -0,0 +1,102 @@ + + +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));
    +
    +
    + +
    + + diff --git a/Examples/java/template/runme.java b/Examples/java/template/runme.java new file mode 100644 index 0000000..5d1097b --- /dev/null +++ b/Examples/java/template/runme.java @@ -0,0 +1,45 @@ +// 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); + } + } +} diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile new file mode 100644 index 0000000..92afbd4 --- /dev/null +++ b/Examples/java/typemap/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/typemap/example.i b/Examples/java/typemap/example.i new file mode 100644 index 0000000..7c97e66 --- /dev/null +++ b/Examples/java/typemap/example.i @@ -0,0 +1,101 @@ +/* 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); + diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html new file mode 100644 index 0000000..5dd5919 --- /dev/null +++ b/Examples/java/typemap/index.html @@ -0,0 +1,32 @@ + + +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. +
    + +
    + + diff --git a/Examples/java/typemap/runme.java b/Examples/java/typemap/runme.java new file mode 100644 index 0000000..fcbcc30 --- /dev/null +++ b/Examples/java/typemap/runme.java @@ -0,0 +1,26 @@ + +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); + } +} diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile new file mode 100644 index 0000000..968c92c --- /dev/null +++ b/Examples/java/variables/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/java/variables/example.c b/Examples/java/variables/example.c new file mode 100644 index 0000000..aa4ffe9 --- /dev/null +++ b/Examples/java/variables/example.c @@ -0,0 +1,91 @@ +/* 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); +} diff --git a/Examples/java/variables/example.h b/Examples/java/variables/example.h new file mode 100644 index 0000000..0f7e895 --- /dev/null +++ b/Examples/java/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/java/variables/example.i b/Examples/java/variables/example.i new file mode 100644 index 0000000..591b871 --- /dev/null +++ b/Examples/java/variables/example.i @@ -0,0 +1,49 @@ +/* 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(); +%} + diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html new file mode 100644 index 0000000..07b19d4 --- /dev/null +++ b/Examples/java/variables/index.html @@ -0,0 +1,85 @@ + + +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. +
    + + + +
    diff --git a/Examples/java/variables/runme.java b/Examples/java/variables/runme.java new file mode 100644 index 0000000..361a30f --- /dev/null +++ b/Examples/java/variables/runme.java @@ -0,0 +1,97 @@ +// 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()) ); + } +} diff --git a/Examples/lua/arrays/Makefile b/Examples/lua/arrays/Makefile new file mode 100644 index 0000000..bb9cf0b --- /dev/null +++ b/Examples/lua/arrays/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(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 + +check: all diff --git a/Examples/lua/arrays/example.c b/Examples/lua/arrays/example.c new file mode 100644 index 0000000..56c7b19 --- /dev/null +++ b/Examples/lua/arrays/example.c @@ -0,0 +1,25 @@ +/* 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); +} diff --git a/Examples/lua/arrays/example.i b/Examples/lua/arrays/example.i new file mode 100644 index 0000000..197a5a2 --- /dev/null +++ b/Examples/lua/arrays/example.i @@ -0,0 +1,42 @@ +/* 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); +%} \ No newline at end of file diff --git a/Examples/lua/arrays/runme.lua b/Examples/lua/arrays/runme.lua new file mode 100644 index 0000000..b0f5cfc --- /dev/null +++ b/Examples/lua/arrays/runme.lua @@ -0,0 +1,74 @@ +---- 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) + diff --git a/Examples/lua/check.list b/Examples/lua/check.list new file mode 100644 index 0000000..6862e44 --- /dev/null +++ b/Examples/lua/check.list @@ -0,0 +1,17 @@ +# see top-level Makefile.in +arrays +class +constants +dual +embed +embed2 +embed3 +exception +funcptr3 +functest +functor +import +owner +pointer +simple +variables diff --git a/Examples/lua/class/Makefile b/Examples/lua/class/Makefile new file mode 100644 index 0000000..44888f6 --- /dev/null +++ b/Examples/lua/class/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm + +all:: + $(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 + +check: all diff --git a/Examples/lua/class/example.cxx b/Examples/lua/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/lua/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/lua/class/example.h b/Examples/lua/class/example.h new file mode 100644 index 0000000..46d9013 --- /dev/null +++ b/Examples/lua/class/example.h @@ -0,0 +1,39 @@ +/* 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); +}; + + + + + diff --git a/Examples/lua/class/example.i b/Examples/lua/class/example.i new file mode 100644 index 0000000..75700b3 --- /dev/null +++ b/Examples/lua/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/lua/class/runme.lua b/Examples/lua/class/runme.lua new file mode 100644 index 0000000..2c3ad8c --- /dev/null +++ b/Examples/lua/class/runme.lua @@ -0,0 +1,62 @@ +-- 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" diff --git a/Examples/lua/constants/Makefile b/Examples/lua/constants/Makefile new file mode 100644 index 0000000..4204545 --- /dev/null +++ b/Examples/lua/constants/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +LIBS = + +all:: + $(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 + +check: all diff --git a/Examples/lua/constants/example.i b/Examples/lua/constants/example.i new file mode 100644 index 0000000..4f7b1a4 --- /dev/null +++ b/Examples/lua/constants/example.i @@ -0,0 +1,27 @@ +/* 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; + + diff --git a/Examples/lua/constants/runme.lua b/Examples/lua/constants/runme.lua new file mode 100644 index 0000000..751e7d6 --- /dev/null +++ b/Examples/lua/constants/runme.lua @@ -0,0 +1,35 @@ +-- 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) diff --git a/Examples/lua/dual/Makefile b/Examples/lua/dual/Makefile new file mode 100644 index 0000000..b4e28f3 --- /dev/null +++ b/Examples/lua/dual/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +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 +all:: + $(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 + +check: all + diff --git a/Examples/lua/dual/dual.cpp b/Examples/lua/dual/dual.cpp new file mode 100644 index 0000000..d2a9eca --- /dev/null +++ b/Examples/lua/dual/dual.cpp @@ -0,0 +1,109 @@ +/* +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; +} diff --git a/Examples/lua/dual/example.i b/Examples/lua/dual/example.i new file mode 100644 index 0000000..5e573dd --- /dev/null +++ b/Examples/lua/dual/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%inline %{ + +struct Foo{ + int i; +}; + +%} diff --git a/Examples/lua/dual/example2.i b/Examples/lua/dual/example2.i new file mode 100644 index 0000000..9449664 --- /dev/null +++ b/Examples/lua/dual/example2.i @@ -0,0 +1,10 @@ +/* File : example2.i */ +%module example2 + +%inline %{ + +struct Bar{ + int i; +}; + +%} diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile new file mode 100644 index 0000000..51d0e61 --- /dev/null +++ b/Examples/lua/embed/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +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 +all:: + $(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 + +check: all + diff --git a/Examples/lua/embed/embed.c b/Examples/lua/embed/embed.c new file mode 100644 index 0000000..55ea099 --- /dev/null +++ b/Examples/lua/embed/embed.c @@ -0,0 +1,85 @@ +/* embed.c a simple test for an embeded interpreter + +The idea is that we wrapper a few simple function (example.c) +and write our own app to call it. + +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 + +*/ + +#include +#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; +} diff --git a/Examples/lua/embed/example.c b/Examples/lua/embed/example.c new file mode 100644 index 0000000..c6c6d7b --- /dev/null +++ b/Examples/lua/embed/example.c @@ -0,0 +1,22 @@ +/* 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"); +} diff --git a/Examples/lua/embed/example.i b/Examples/lua/embed/example.i new file mode 100644 index 0000000..7784b8e --- /dev/null +++ b/Examples/lua/embed/example.i @@ -0,0 +1,8 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +extern void greeting(); +%} \ No newline at end of file diff --git a/Examples/lua/embed/runme.lua b/Examples/lua/embed/runme.lua new file mode 100644 index 0000000..e02fd1d --- /dev/null +++ b/Examples/lua/embed/runme.lua @@ -0,0 +1,40 @@ +print "[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 + + + + + + diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile new file mode 100644 index 0000000..5f267d9 --- /dev/null +++ b/Examples/lua/embed2/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +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 +all:: + $(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 + +check: all + diff --git a/Examples/lua/embed2/embed2.c b/Examples/lua/embed2/embed2.c new file mode 100644 index 0000000..dac527e --- /dev/null +++ b/Examples/lua/embed2/embed2.c @@ -0,0 +1,233 @@ +/* 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; +} diff --git a/Examples/lua/embed2/example.c b/Examples/lua/embed2/example.c new file mode 100644 index 0000000..c6c6d7b --- /dev/null +++ b/Examples/lua/embed2/example.c @@ -0,0 +1,22 @@ +/* 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"); +} diff --git a/Examples/lua/embed2/example.i b/Examples/lua/embed2/example.i new file mode 100644 index 0000000..7784b8e --- /dev/null +++ b/Examples/lua/embed2/example.i @@ -0,0 +1,8 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +extern void greeting(); +%} \ No newline at end of file diff --git a/Examples/lua/embed2/runme.lua b/Examples/lua/embed2/runme.lua new file mode 100644 index 0000000..73af9c5 --- /dev/null +++ b/Examples/lua/embed2/runme.lua @@ -0,0 +1,27 @@ +print "[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 + + diff --git a/Examples/lua/embed3/Makefile b/Examples/lua/embed3/Makefile new file mode 100644 index 0000000..def3528 --- /dev/null +++ b/Examples/lua/embed3/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +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 +all:: + $(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 + +check: all + diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp new file mode 100644 index 0000000..e5e0e0a --- /dev/null +++ b/Examples/lua/embed3/embed3.cpp @@ -0,0 +1,146 @@ +/* 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; +} diff --git a/Examples/lua/embed3/example.cpp b/Examples/lua/embed3/example.cpp new file mode 100644 index 0000000..a8264f3 --- /dev/null +++ b/Examples/lua/embed3/example.cpp @@ -0,0 +1,25 @@ +/* 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); +} + diff --git a/Examples/lua/embed3/example.h b/Examples/lua/embed3/example.h new file mode 100644 index 0000000..41c13e9 --- /dev/null +++ b/Examples/lua/embed3/example.h @@ -0,0 +1,24 @@ +/* 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 +}; diff --git a/Examples/lua/embed3/example.i b/Examples/lua/embed3/example.i new file mode 100644 index 0000000..032805c --- /dev/null +++ b/Examples/lua/embed3/example.i @@ -0,0 +1,8 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +%include "example.h" diff --git a/Examples/lua/embed3/runme.lua b/Examples/lua/embed3/runme.lua new file mode 100644 index 0000000..3a44bd2 --- /dev/null +++ b/Examples/lua/embed3/runme.lua @@ -0,0 +1,35 @@ +print "[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") +end \ No newline at end of file diff --git a/Examples/lua/exception/Makefile b/Examples/lua/exception/Makefile new file mode 100644 index 0000000..8657f19 --- /dev/null +++ b/Examples/lua/exception/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +LIBS = -lm + +all:: + $(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 + +check: all diff --git a/Examples/lua/exception/example.h b/Examples/lua/exception/example.h new file mode 100644 index 0000000..5148a59 --- /dev/null +++ b/Examples/lua/exception/example.h @@ -0,0 +1,53 @@ +/* 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 + diff --git a/Examples/lua/exception/example.i b/Examples/lua/exception/example.i new file mode 100644 index 0000000..09cd9e8 --- /dev/null +++ b/Examples/lua/exception/example.i @@ -0,0 +1,17 @@ +/* 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" + diff --git a/Examples/lua/exception/runme.lua b/Examples/lua/exception/runme.lua new file mode 100644 index 0000000..39b2d6d --- /dev/null +++ b/Examples/lua/exception/runme.lua @@ -0,0 +1,96 @@ +-- 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) diff --git a/Examples/lua/funcptr3/Makefile b/Examples/lua/funcptr3/Makefile new file mode 100644 index 0000000..ac0fff4 --- /dev/null +++ b/Examples/lua/funcptr3/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +LIBS = + +all:: + $(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 + +check: all diff --git a/Examples/lua/funcptr3/example.c b/Examples/lua/funcptr3/example.c new file mode 100644 index 0000000..5c4a3da --- /dev/null +++ b/Examples/lua/funcptr3/example.c @@ -0,0 +1,19 @@ +/* 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; diff --git a/Examples/lua/funcptr3/example.h b/Examples/lua/funcptr3/example.h new file mode 100644 index 0000000..9936e24 --- /dev/null +++ b/Examples/lua/funcptr3/example.h @@ -0,0 +1,9 @@ +/* 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); + diff --git a/Examples/lua/funcptr3/example.i b/Examples/lua/funcptr3/example.i new file mode 100644 index 0000000..319b227 --- /dev/null +++ b/Examples/lua/funcptr3/example.i @@ -0,0 +1,69 @@ +/* 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 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; + + + + diff --git a/Examples/lua/functor/runme.lua b/Examples/lua/functor/runme.lua new file mode 100644 index 0000000..adf124a --- /dev/null +++ b/Examples/lua/functor/runme.lua @@ -0,0 +1,24 @@ +-- 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)") + diff --git a/Examples/lua/import.lua b/Examples/lua/import.lua new file mode 100644 index 0000000..b2a40b0 --- /dev/null +++ b/Examples/lua/import.lua @@ -0,0 +1,42 @@ +-- 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 +end \ No newline at end of file diff --git a/Examples/lua/import/Makefile b/Examples/lua/import/Makefile new file mode 100644 index 0000000..8f692d1 --- /dev/null +++ b/Examples/lua/import/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SWIGOPT = +LIBS = + +all:: + $(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 + +check: all diff --git a/Examples/lua/import/README b/Examples/lua/import/README new file mode 100644 index 0000000..1a52e3c --- /dev/null +++ b/Examples/lua/import/README @@ -0,0 +1,36 @@ +This 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 + + diff --git a/Examples/lua/import/bar.h b/Examples/lua/import/bar.h new file mode 100644 index 0000000..1c99f28 --- /dev/null +++ b/Examples/lua/import/bar.h @@ -0,0 +1,21 @@ +#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); + } +}; + + diff --git a/Examples/lua/import/bar.i b/Examples/lua/import/bar.i new file mode 100644 index 0000000..5816cbe --- /dev/null +++ b/Examples/lua/import/bar.i @@ -0,0 +1,9 @@ +%module bar +%{ +#include "bar.h" +%} + +%import base.i +%include "bar.h" + + diff --git a/Examples/lua/import/base.h b/Examples/lua/import/base.h new file mode 100644 index 0000000..fec0f32 --- /dev/null +++ b/Examples/lua/import/base.h @@ -0,0 +1,16 @@ +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); + } +}; + + diff --git a/Examples/lua/import/base.i b/Examples/lua/import/base.i new file mode 100644 index 0000000..f6e19ef --- /dev/null +++ b/Examples/lua/import/base.i @@ -0,0 +1,6 @@ +%module base +%{ +#include "base.h" +%} + +%include base.h diff --git a/Examples/lua/import/foo.h b/Examples/lua/import/foo.h new file mode 100644 index 0000000..1abe2c0 --- /dev/null +++ b/Examples/lua/import/foo.h @@ -0,0 +1,21 @@ +#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); + } +}; + + diff --git a/Examples/lua/import/foo.i b/Examples/lua/import/foo.i new file mode 100644 index 0000000..27feb2e --- /dev/null +++ b/Examples/lua/import/foo.i @@ -0,0 +1,8 @@ +%module foo +%{ +#include "foo.h" +%} + +%import base.i +%include "foo.h" + diff --git a/Examples/lua/import/runme.lua b/Examples/lua/import/runme.lua new file mode 100644 index 0000000..9cd7ae0 --- /dev/null +++ b/Examples/lua/import/runme.lua @@ -0,0 +1,103 @@ +# 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 diff --git a/Examples/lua/import/spam.h b/Examples/lua/import/spam.h new file mode 100644 index 0000000..57db845 --- /dev/null +++ b/Examples/lua/import/spam.h @@ -0,0 +1,24 @@ +#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); + } +}; + + diff --git a/Examples/lua/import/spam.i b/Examples/lua/import/spam.i new file mode 100644 index 0000000..d3d9121 --- /dev/null +++ b/Examples/lua/import/spam.i @@ -0,0 +1,9 @@ +%module spam +%{ +#include "spam.h" +%} + +%import bar.i +%include "spam.h" + + diff --git a/Examples/lua/lua.c b/Examples/lua/lua.c new file mode 100644 index 0000000..b0c0729 --- /dev/null +++ b/Examples/lua/lua.c @@ -0,0 +1,439 @@ +/* +** $Id: lua.c 7470 2005-09-20 19:35:23Z wsfulton $ +** 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; +} + diff --git a/Examples/lua/owner/Makefile b/Examples/lua/owner/Makefile new file mode 100644 index 0000000..1fe68ec --- /dev/null +++ b/Examples/lua/owner/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm + +all:: + $(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 + +check: all diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx new file mode 100644 index 0000000..d6caeef --- /dev/null +++ b/Examples/lua/owner/example.cxx @@ -0,0 +1,69 @@ +/* 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; +} diff --git a/Examples/lua/owner/example.h b/Examples/lua/owner/example.h new file mode 100644 index 0000000..b005680 --- /dev/null +++ b/Examples/lua/owner/example.h @@ -0,0 +1,54 @@ +/* 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 +}; + + diff --git a/Examples/lua/owner/example.i b/Examples/lua/owner/example.i new file mode 100644 index 0000000..4e7c331 --- /dev/null +++ b/Examples/lua/owner/example.i @@ -0,0 +1,32 @@ +/* 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" + diff --git a/Examples/lua/owner/runme.lua b/Examples/lua/owner/runme.lua new file mode 100644 index 0000000..d2d8a9c --- /dev/null +++ b/Examples/lua/owner/runme.lua @@ -0,0 +1,104 @@ +-- 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!" \ No newline at end of file diff --git a/Examples/lua/pointer/Makefile b/Examples/lua/pointer/Makefile new file mode 100644 index 0000000..ac0fff4 --- /dev/null +++ b/Examples/lua/pointer/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +LIBS = + +all:: + $(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 + +check: all diff --git a/Examples/lua/pointer/example.c b/Examples/lua/pointer/example.c new file mode 100644 index 0000000..b877d9a --- /dev/null +++ b/Examples/lua/pointer/example.c @@ -0,0 +1,16 @@ +/* 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; +} diff --git a/Examples/lua/pointer/example.i b/Examples/lua/pointer/example.i new file mode 100644 index 0000000..d49365b --- /dev/null +++ b/Examples/lua/pointer/example.i @@ -0,0 +1,35 @@ +/* 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); +%} + + + + diff --git a/Examples/lua/pointer/runme.lua b/Examples/lua/pointer/runme.lua new file mode 100644 index 0000000..8deee67 --- /dev/null +++ b/Examples/lua/pointer/runme.lua @@ -0,0 +1,48 @@ +---- 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) diff --git a/Examples/lua/simple/Makefile b/Examples/lua/simple/Makefile new file mode 100644 index 0000000..f181818 --- /dev/null +++ b/Examples/lua/simple/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(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 + +check: all diff --git a/Examples/lua/simple/example.c b/Examples/lua/simple/example.c new file mode 100644 index 0000000..1c2af78 --- /dev/null +++ b/Examples/lua/simple/example.c @@ -0,0 +1,18 @@ +/* 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; +} + + diff --git a/Examples/lua/simple/example.i b/Examples/lua/simple/example.i new file mode 100644 index 0000000..86ae9f3 --- /dev/null +++ b/Examples/lua/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} \ No newline at end of file diff --git a/Examples/lua/simple/runme.lua b/Examples/lua/simple/runme.lua new file mode 100644 index 0000000..1e5a139 --- /dev/null +++ b/Examples/lua/simple/runme.lua @@ -0,0 +1,35 @@ +---- 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) + + + + + + + + + diff --git a/Examples/lua/variables/Makefile b/Examples/lua/variables/Makefile new file mode 100644 index 0000000..f181818 --- /dev/null +++ b/Examples/lua/variables/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(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 + +check: all diff --git a/Examples/lua/variables/example.c b/Examples/lua/variables/example.c new file mode 100644 index 0000000..aa4ffe9 --- /dev/null +++ b/Examples/lua/variables/example.c @@ -0,0 +1,91 @@ +/* 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); +} diff --git a/Examples/lua/variables/example.h b/Examples/lua/variables/example.h new file mode 100644 index 0000000..0f7e895 --- /dev/null +++ b/Examples/lua/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/lua/variables/example.i b/Examples/lua/variables/example.i new file mode 100644 index 0000000..591b871 --- /dev/null +++ b/Examples/lua/variables/example.i @@ -0,0 +1,49 @@ +/* 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(); +%} + diff --git a/Examples/lua/variables/runme.lua b/Examples/lua/variables/runme.lua new file mode 100644 index 0000000..05b2d3f --- /dev/null +++ b/Examples/lua/variables/runme.lua @@ -0,0 +1,81 @@ +---- 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)) + diff --git a/Examples/modula3/check.list b/Examples/modula3/check.list new file mode 100644 index 0000000..37ac8c1 --- /dev/null +++ b/Examples/modula3/check.list @@ -0,0 +1,7 @@ +# see top-level Makefile.in +class +enum +exception +reference +simple +typemap diff --git a/Examples/modula3/class/Makefile b/Examples/modula3/class/Makefile new file mode 100644 index 0000000..bf929a0 --- /dev/null +++ b/Examples/modula3/class/Makefile @@ -0,0 +1,25 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +PLATFORM = LINUXLIBC6 +INTERFACE = example.i +SWIGOPT = -c++ +MODULA3SRCS = *.[im]3 + +all:: modula3 + +modula3:: + $(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 + +check: all diff --git a/Examples/modula3/class/example.cxx b/Examples/modula3/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/modula3/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/modula3/class/example.h b/Examples/modula3/class/example.h new file mode 100644 index 0000000..9c1f479 --- /dev/null +++ b/Examples/modula3/class/example.h @@ -0,0 +1,44 @@ +/* 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; +}; diff --git a/Examples/modula3/class/example.i b/Examples/modula3/class/example.i new file mode 100644 index 0000000..2fafadb --- /dev/null +++ b/Examples/modula3/class/example.i @@ -0,0 +1,32 @@ +/* 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" diff --git a/Examples/modula3/class/swig.tmpl b/Examples/modula3/class/swig.tmpl new file mode 100644 index 0000000..e3e9bf1 --- /dev/null +++ b/Examples/modula3/class/swig.tmpl @@ -0,0 +1,11 @@ + +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 diff --git a/Examples/modula3/enum/Makefile b/Examples/modula3/enum/Makefile new file mode 100644 index 0000000..b5bf8f6 --- /dev/null +++ b/Examples/modula3/enum/Makefile @@ -0,0 +1,26 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +CONSTNUMERIC = example_const +SWIGOPT = -c++ +MODULA3SRCS = *.[im]3 + +all:: modula3 + +modula3:: + $(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 + +check: all diff --git a/Examples/modula3/enum/example.cxx b/Examples/modula3/enum/example.cxx new file mode 100644 index 0000000..bd808ff --- /dev/null +++ b/Examples/modula3/enum/example.cxx @@ -0,0 +1,32 @@ +/* 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); +} diff --git a/Examples/modula3/enum/example.h b/Examples/modula3/enum/example.h new file mode 100644 index 0000000..2f44a6c --- /dev/null +++ b/Examples/modula3/enum/example.h @@ -0,0 +1,83 @@ +/* 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); diff --git a/Examples/modula3/enum/example.i b/Examples/modula3/enum/example.i new file mode 100644 index 0000000..f5947b3 --- /dev/null +++ b/Examples/modula3/enum/example.i @@ -0,0 +1,72 @@ +/* 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" diff --git a/Examples/modula3/exception/Makefile b/Examples/modula3/exception/Makefile new file mode 100644 index 0000000..2518a22 --- /dev/null +++ b/Examples/modula3/exception/Makefile @@ -0,0 +1,23 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = +MODULA3SRCS = *.[im]3 +MODULA3FLAGS= -o runme + +all:: modula3 + +modula3:: + $(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 + +check: all diff --git a/Examples/modula3/exception/example.h b/Examples/modula3/exception/example.h new file mode 100644 index 0000000..0e9e0e8 --- /dev/null +++ b/Examples/modula3/exception/example.h @@ -0,0 +1,18 @@ +/* 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); diff --git a/Examples/modula3/exception/example.i b/Examples/modula3/exception/example.i new file mode 100644 index 0000000..92a716f --- /dev/null +++ b/Examples/modula3/exception/example.i @@ -0,0 +1,43 @@ +/* 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" diff --git a/Examples/modula3/reference/Makefile b/Examples/modula3/reference/Makefile new file mode 100644 index 0000000..b31577a --- /dev/null +++ b/Examples/modula3/reference/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = -c++ +MODULA3SRCS = *.[im]3 + +all:: modula3 + +modula3:: + $(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 + +check: all diff --git a/Examples/modula3/reference/example.cxx b/Examples/modula3/reference/example.cxx new file mode 100644 index 0000000..649b016 --- /dev/null +++ b/Examples/modula3/reference/example.cxx @@ -0,0 +1,46 @@ +/* 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; +} + diff --git a/Examples/modula3/reference/example.h b/Examples/modula3/reference/example.h new file mode 100644 index 0000000..0a9cd44 --- /dev/null +++ b/Examples/modula3/reference/example.h @@ -0,0 +1,22 @@ +/* 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(); +}; diff --git a/Examples/modula3/reference/example.i b/Examples/modula3/reference/example.i new file mode 100644 index 0000000..0020909 --- /dev/null +++ b/Examples/modula3/reference/example.i @@ -0,0 +1,32 @@ +/* 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" diff --git a/Examples/modula3/simple/Makefile b/Examples/modula3/simple/Makefile new file mode 100644 index 0000000..834521f --- /dev/null +++ b/Examples/modula3/simple/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = +MODULA3SRCS = *.[im]3 + +all:: modula3 + +modula3:: + $(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 + +check: all diff --git a/Examples/modula3/simple/example.c b/Examples/modula3/simple/example.c new file mode 100644 index 0000000..1c2af78 --- /dev/null +++ b/Examples/modula3/simple/example.c @@ -0,0 +1,18 @@ +/* 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; +} + + diff --git a/Examples/modula3/simple/example.i b/Examples/modula3/simple/example.i new file mode 100644 index 0000000..1694e6d --- /dev/null +++ b/Examples/modula3/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module Example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/modula3/typemap/Makefile b/Examples/modula3/typemap/Makefile new file mode 100644 index 0000000..834521f --- /dev/null +++ b/Examples/modula3/typemap/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = +MODULA3SRCS = *.[im]3 + +all:: modula3 + +modula3:: + $(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 + +check: all diff --git a/Examples/modula3/typemap/example.i b/Examples/modula3/typemap/example.i new file mode 100644 index 0000000..2f454ef --- /dev/null +++ b/Examples/modula3/typemap/example.i @@ -0,0 +1,90 @@ +/* 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); diff --git a/Examples/mzscheme/check.list b/Examples/mzscheme/check.list new file mode 100644 index 0000000..ae728ea --- /dev/null +++ b/Examples/mzscheme/check.list @@ -0,0 +1,3 @@ +# see top-level Makefile.in +multimap +simple diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile new file mode 100644 index 0000000..a3cfb8f --- /dev/null +++ b/Examples/mzscheme/multimap/Makefile @@ -0,0 +1,13 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme +clean:: + $(MAKE) -f $(TOP)/Makefile mzscheme_clean + +check: all diff --git a/Examples/mzscheme/multimap/example.c b/Examples/mzscheme/multimap/example.c new file mode 100644 index 0000000..b8360fa --- /dev/null +++ b/Examples/mzscheme/multimap/example.c @@ -0,0 +1,53 @@ +/* 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); + } +} diff --git a/Examples/mzscheme/multimap/example.i b/Examples/mzscheme/multimap/example.i new file mode 100644 index 0000000..515948a --- /dev/null +++ b/Examples/mzscheme/multimap/example.i @@ -0,0 +1,91 @@ +/* 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); + + diff --git a/Examples/mzscheme/multimap/example.scm b/Examples/mzscheme/multimap/example.scm new file mode 100644 index 0000000..ac9f642 --- /dev/null +++ b/Examples/mzscheme/multimap/example.scm @@ -0,0 +1,27 @@ +;; run with mzscheme -r example.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) \ No newline at end of file diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile new file mode 100644 index 0000000..a3cfb8f --- /dev/null +++ b/Examples/mzscheme/simple/Makefile @@ -0,0 +1,13 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme +clean:: + $(MAKE) -f $(TOP)/Makefile mzscheme_clean + +check: all diff --git a/Examples/mzscheme/simple/README b/Examples/mzscheme/simple/README new file mode 100644 index 0000000..07e8da0 --- /dev/null +++ b/Examples/mzscheme/simple/README @@ -0,0 +1 @@ +Simple example from users manual. diff --git a/Examples/mzscheme/simple/example.c b/Examples/mzscheme/simple/example.c new file mode 100644 index 0000000..f2b0747 --- /dev/null +++ b/Examples/mzscheme/simple/example.c @@ -0,0 +1,24 @@ +/* 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); +} diff --git a/Examples/mzscheme/simple/example.i b/Examples/mzscheme/simple/example.i new file mode 100644 index 0000000..5b3e955 --- /dev/null +++ b/Examples/mzscheme/simple/example.i @@ -0,0 +1,16 @@ +/* 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(); +%} diff --git a/Examples/mzscheme/simple/example.scm b/Examples/mzscheme/simple/example.scm new file mode 100644 index 0000000..8e20345 --- /dev/null +++ b/Examples/mzscheme/simple/example.scm @@ -0,0 +1,24 @@ +;; run with mzscheme -r example.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)) diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile new file mode 100644 index 0000000..e187269 --- /dev/null +++ b/Examples/mzscheme/std_vector/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +GPP = `which g++` +MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc + +all:: + $(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 + +check: all diff --git a/Examples/mzscheme/std_vector/example.h b/Examples/mzscheme/std_vector/example.h new file mode 100644 index 0000000..4f0dac7 --- /dev/null +++ b/Examples/mzscheme/std_vector/example.h @@ -0,0 +1,25 @@ +/* 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)); +} + + diff --git a/Examples/mzscheme/std_vector/example.i b/Examples/mzscheme/std_vector/example.i new file mode 100644 index 0000000..aa58b66 --- /dev/null +++ b/Examples/mzscheme/std_vector/example.i @@ -0,0 +1,17 @@ +/* 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" + diff --git a/Examples/mzscheme/std_vector/example.scm b/Examples/mzscheme/std_vector/example.scm new file mode 100644 index 0000000..0e4ac3f --- /dev/null +++ b/Examples/mzscheme/std_vector/example.scm @@ -0,0 +1,54 @@ +;; run with mzscheme -r example.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) + diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile new file mode 100644 index 0000000..8a260fe --- /dev/null +++ b/Examples/ocaml/argout_ref/Makefile @@ -0,0 +1,27 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +MLFILE = example.ml +PROGFILE = example_prog.ml +OBJS = example.o + +all:: 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 + +check: all diff --git a/Examples/ocaml/argout_ref/example.c b/Examples/ocaml/argout_ref/example.c new file mode 100644 index 0000000..6f095cd --- /dev/null +++ b/Examples/ocaml/argout_ref/example.c @@ -0,0 +1,19 @@ +/* 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; +} diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i new file mode 100644 index 0000000..a0be05f --- /dev/null +++ b/Examples/ocaml/argout_ref/example.i @@ -0,0 +1,4 @@ +/* File : example.i */ +%module example + +extern "C" void factor(int &x, int &y); diff --git a/Examples/ocaml/argout_ref/example_prog.ml b/Examples/ocaml/argout_ref/example_prog.ml new file mode 100644 index 0000000..c6de345 --- /dev/null +++ b/Examples/ocaml/argout_ref/example_prog.ml @@ -0,0 +1,26 @@ +(* 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)) diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list new file mode 100644 index 0000000..cbdf270 --- /dev/null +++ b/Examples/ocaml/check.list @@ -0,0 +1,10 @@ +# see top-level Makefile.in +simple +std_string +std_vector +stl +argout_ref +shapes +contract +scoped_enum +string_from_ptr diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile new file mode 100644 index 0000000..8e0f2a4 --- /dev/null +++ b/Examples/ocaml/contract/Makefile @@ -0,0 +1,33 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +MLFILE = example.ml +PROGFILE = example_prog.ml +OBJS = + +all:: 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 + +check: all diff --git a/Examples/ocaml/contract/example.i b/Examples/ocaml/contract/example.i new file mode 100644 index 0000000..28d9dd7 --- /dev/null +++ b/Examples/ocaml/contract/example.i @@ -0,0 +1,18 @@ +%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); \ No newline at end of file diff --git a/Examples/ocaml/contract/example_prog.ml b/Examples/ocaml/contract/example_prog.ml new file mode 100644 index 0000000..748109c --- /dev/null +++ b/Examples/ocaml/contract/example_prog.ml @@ -0,0 +1,7 @@ +open 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) diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile new file mode 100644 index 0000000..45c5edc --- /dev/null +++ b/Examples/ocaml/scoped_enum/Makefile @@ -0,0 +1,33 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +MLFILE = example.ml +PROGFILE = example_prog.ml +OBJS = + +all:: 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 + +check: all diff --git a/Examples/ocaml/scoped_enum/README b/Examples/ocaml/scoped_enum/README new file mode 100644 index 0000000..88b6693 --- /dev/null +++ b/Examples/ocaml/scoped_enum/README @@ -0,0 +1 @@ +This tests our handling of scoped enums. Run with argument Tag1 or Tag2. \ No newline at end of file diff --git a/Examples/ocaml/scoped_enum/example.i b/Examples/ocaml/scoped_enum/example.i new file mode 100644 index 0000000..de553f8 --- /dev/null +++ b/Examples/ocaml/scoped_enum/example.i @@ -0,0 +1,7 @@ +%module example + +%{ +#include "foo.h" +%} + +%include "foo.h" \ No newline at end of file diff --git a/Examples/ocaml/scoped_enum/example_prog.ml b/Examples/ocaml/scoped_enum/example_prog.ml new file mode 100644 index 0000000..e19bb34 --- /dev/null +++ b/Examples/ocaml/scoped_enum/example_prog.ml @@ -0,0 +1,4 @@ +open Swig +open Example + +let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2) diff --git a/Examples/ocaml/scoped_enum/foo.h b/Examples/ocaml/scoped_enum/foo.h new file mode 100644 index 0000000..8238cb6 --- /dev/null +++ b/Examples/ocaml/scoped_enum/foo.h @@ -0,0 +1,5 @@ +namespace foo { + enum Bar { Tag1, Tag2 }; + static void f( Bar b ) { printf( "b = %d\n", (int)b ); } +} + diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile new file mode 100644 index 0000000..31f9934 --- /dev/null +++ b/Examples/ocaml/shapes/Makefile @@ -0,0 +1,34 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SWIGOPT = +SRCS = example.c +TARGET = example +INTERFACE = example.i +MLFILE = example.ml +PROGFILE = example_prog.ml +OBJS = example.o + +all:: 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 + +check: all diff --git a/Examples/ocaml/shapes/example.c b/Examples/ocaml/shapes/example.c new file mode 100644 index 0000000..bf0fff9 --- /dev/null +++ b/Examples/ocaml/shapes/example.c @@ -0,0 +1,48 @@ +/* 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; } diff --git a/Examples/ocaml/shapes/example.h b/Examples/ocaml/shapes/example.h new file mode 100644 index 0000000..4b16444 --- /dev/null +++ b/Examples/ocaml/shapes/example.h @@ -0,0 +1,18 @@ +#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 ); +}; + +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 diff --git a/Examples/ocaml/shapes/example.i b/Examples/ocaml/shapes/example.i new file mode 100644 index 0000000..ac0fa4a --- /dev/null +++ b/Examples/ocaml/shapes/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module(directors="1") example +#ifndef SWIGSEXP +%{ + #include "example.h" +%} +#endif + +%feature("director"); +%include "example.h" diff --git a/Examples/ocaml/shapes/example_prog.ml b/Examples/ocaml/shapes/example_prog.ml new file mode 100644 index 0000000..b9e3515 --- /dev/null +++ b/Examples/ocaml/shapes/example_prog.ml @@ -0,0 +1,76 @@ +(* 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) ;; diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile new file mode 100644 index 0000000..4b85bf3 --- /dev/null +++ b/Examples/ocaml/simple/Makefile @@ -0,0 +1,33 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +MLFILE = example.ml +PROGFILE = example_prog.ml +OBJS = example.o + +all:: 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 + +check: all diff --git a/Examples/ocaml/simple/example.c b/Examples/ocaml/simple/example.c new file mode 100644 index 0000000..1c2af78 --- /dev/null +++ b/Examples/ocaml/simple/example.c @@ -0,0 +1,18 @@ +/* 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; +} + + diff --git a/Examples/ocaml/simple/example.i b/Examples/ocaml/simple/example.i new file mode 100644 index 0000000..24093b9 --- /dev/null +++ b/Examples/ocaml/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/ocaml/simple/example_prog.ml b/Examples/ocaml/simple/example_prog.ml new file mode 100644 index 0000000..cc3b973 --- /dev/null +++ b/Examples/ocaml/simple/example_prog.ml @@ -0,0 +1,33 @@ +(* 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) + + + + + + + + + diff --git a/Examples/ocaml/simple/index.html b/Examples/ocaml/simple/index.html new file mode 100644 index 0000000..dace471 --- /dev/null +++ b/Examples/ocaml/simple/index.html @@ -0,0 +1,97 @@ + + +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
      +
      +
      +
    + +
    + + diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile new file mode 100644 index 0000000..e5a8017 --- /dev/null +++ b/Examples/ocaml/std_string/Makefile @@ -0,0 +1,23 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +PROGFILE = runme.ml + +all default:: 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 + +check: all diff --git a/Examples/ocaml/std_string/README b/Examples/ocaml/std_string/README new file mode 100644 index 0000000..5665530 --- /dev/null +++ b/Examples/ocaml/std_string/README @@ -0,0 +1,13 @@ +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; ] diff --git a/Examples/ocaml/std_string/example.h b/Examples/ocaml/std_string/example.h new file mode 100644 index 0000000..60de984 --- /dev/null +++ b/Examples/ocaml/std_string/example.h @@ -0,0 +1,36 @@ +/* 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; +} diff --git a/Examples/ocaml/std_string/example.i b/Examples/ocaml/std_string/example.i new file mode 100644 index 0000000..7b144ea --- /dev/null +++ b/Examples/ocaml/std_string/example.i @@ -0,0 +1,12 @@ +/* -*- 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" diff --git a/Examples/ocaml/std_string/runme.ml b/Examples/ocaml/std_string/runme.ml new file mode 100644 index 0000000..199dbe5 --- /dev/null +++ b/Examples/ocaml/std_string/runme.ml @@ -0,0 +1,24 @@ +(* 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 diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile new file mode 100644 index 0000000..e5a8017 --- /dev/null +++ b/Examples/ocaml/std_vector/Makefile @@ -0,0 +1,23 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +PROGFILE = runme.ml + +all default:: 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 + +check: all diff --git a/Examples/ocaml/std_vector/example.h b/Examples/ocaml/std_vector/example.h new file mode 100644 index 0000000..b753592 --- /dev/null +++ b/Examples/ocaml/std_vector/example.h @@ -0,0 +1,25 @@ +/* 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)); +} + + diff --git a/Examples/ocaml/std_vector/example.i b/Examples/ocaml/std_vector/example.i new file mode 100644 index 0000000..60285e5 --- /dev/null +++ b/Examples/ocaml/std_vector/example.i @@ -0,0 +1,15 @@ +/* -*- 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" diff --git a/Examples/ocaml/std_vector/runme.ml b/Examples/ocaml/std_vector/runme.ml new file mode 100644 index 0000000..feb70dd --- /dev/null +++ b/Examples/ocaml/std_vector/runme.ml @@ -0,0 +1,35 @@ +(* 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 ()) diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile new file mode 100644 index 0000000..fa4333e --- /dev/null +++ b/Examples/ocaml/stl/Makefile @@ -0,0 +1,33 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +PROGFILE = runme.ml + +all default:: 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 + +check: all diff --git a/Examples/ocaml/stl/example.h b/Examples/ocaml/stl/example.h new file mode 100644 index 0000000..df5762b --- /dev/null +++ b/Examples/ocaml/stl/example.h @@ -0,0 +1,17 @@ +/* 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() ); +} diff --git a/Examples/ocaml/stl/example.i b/Examples/ocaml/stl/example.i new file mode 100644 index 0000000..19a80a6 --- /dev/null +++ b/Examples/ocaml/stl/example.i @@ -0,0 +1,12 @@ +%module example +%{ +#include "example.h" +%} + +#define ENABLE_CHARPTR_ARRAY +#define ENABLE_STRING_VECTOR +%include stl.i + +%feature("director"); + +%include example.h diff --git a/Examples/ocaml/stl/runme.ml b/Examples/ocaml/stl/runme.ml new file mode 100644 index 0000000..2fa5d20 --- /dev/null +++ b/Examples/ocaml/stl/runme.ml @@ -0,0 +1,13 @@ +(* 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) diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile new file mode 100644 index 0000000..350d973 --- /dev/null +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -0,0 +1,34 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SWIGOPT = -c++ +SRCS = +TARGET = example +INTERFACE = foolib.i +MLFILE = foolib.ml +PROGFILE = example_prog.ml +OBJS = + +all:: 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 + +check: all diff --git a/Examples/ocaml/string_from_ptr/example_prog.ml b/Examples/ocaml/string_from_ptr/example_prog.ml new file mode 100644 index 0000000..8069dc2 --- /dev/null +++ b/Examples/ocaml/string_from_ptr/example_prog.ml @@ -0,0 +1,23 @@ +(* 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 diff --git a/Examples/ocaml/string_from_ptr/foolib.i b/Examples/ocaml/string_from_ptr/foolib.i new file mode 100644 index 0000000..86e0880 --- /dev/null +++ b/Examples/ocaml/string_from_ptr/foolib.i @@ -0,0 +1,16 @@ +%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 ); diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile new file mode 100644 index 0000000..8d1f96e --- /dev/null +++ b/Examples/ocaml/strings_test/Makefile @@ -0,0 +1,28 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +PROGFILE = runme.ml + +all default:: 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 + +check: all diff --git a/Examples/ocaml/strings_test/example.h b/Examples/ocaml/strings_test/example.h new file mode 100644 index 0000000..3417981 --- /dev/null +++ b/Examples/ocaml/strings_test/example.h @@ -0,0 +1,37 @@ +/* -*- mode: c++ -*- */ +/* File : example.h -- Tests all string typemaps */ + +void takes_std_string( std::string in ) { + cout << "takes_std_string( \"" << in << "\" );" << endl; +} + +std::string gives_std_string() { + time_t t; + + return std::string( asctime( localtime( &t ) ) ); +} + +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 *&ptr ) { + char *pout = strchr( ptr, '.' ); + if( pout ) ptr = pout + 1; + else ptr = "foo"; +} + +/* + * Local-Variables: + * c-indentation-style: "stroustrup" + * End: + */ diff --git a/Examples/ocaml/strings_test/example.i b/Examples/ocaml/strings_test/example.i new file mode 100644 index 0000000..be9eabf --- /dev/null +++ b/Examples/ocaml/strings_test/example.i @@ -0,0 +1,14 @@ +%module example +%{ +#include +#include + +using std::cin; +using std::cout; +using std::endl; +using std::string; + +#include "example.h" +%} + +%include example.h diff --git a/Examples/ocaml/strings_test/runme.ml b/Examples/ocaml/strings_test/runme.ml new file mode 100644 index 0000000..0eb5637 --- /dev/null +++ b/Examples/ocaml/strings_test/runme.ml @@ -0,0 +1,17 @@ +(* 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"))) ^ " >>") diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile new file mode 100644 index 0000000..2bce9df --- /dev/null +++ b/Examples/octave/callback/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/callback/example.cxx b/Examples/octave/callback/example.cxx new file mode 100644 index 0000000..450d756 --- /dev/null +++ b/Examples/octave/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/octave/callback/example.h b/Examples/octave/callback/example.h new file mode 100644 index 0000000..1a0e8c4 --- /dev/null +++ b/Examples/octave/callback/example.h @@ -0,0 +1,23 @@ +/* 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(); } +}; + diff --git a/Examples/octave/callback/example.i b/Examples/octave/callback/example.i new file mode 100644 index 0000000..90beda0 --- /dev/null +++ b/Examples/octave/callback/example.i @@ -0,0 +1,13 @@ +/* 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" + diff --git a/Examples/octave/callback/runme.m b/Examples/octave/callback/runme.m new file mode 100644 index 0000000..b87925e --- /dev/null +++ b/Examples/octave/callback/runme.m @@ -0,0 +1,63 @@ +# file: runme.m + +# This file illustrates the cross language polymorphism using directors. + +example + +OctCallback=@() subclass(example.Callback(), \ + 'run',@(self) printf("OctCallback.run()\n")); + +# Create an Caller instance + +caller = example.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 = example.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++ example.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"); + diff --git a/Examples/octave/check.list b/Examples/octave/check.list new file mode 100644 index 0000000..1e66081 --- /dev/null +++ b/Examples/octave/check.list @@ -0,0 +1,16 @@ +# see top-level Makefile.in +callback +class +constants +contract +enum +extend +funcptr +funcptr2 +functor +operator +pointer +reference +simple +template +variables diff --git a/Examples/octave/class/Makefile b/Examples/octave/class/Makefile new file mode 100644 index 0000000..2bce9df --- /dev/null +++ b/Examples/octave/class/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/class/example.cxx b/Examples/octave/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/octave/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/octave/class/example.h b/Examples/octave/class/example.h new file mode 100644 index 0000000..46d9013 --- /dev/null +++ b/Examples/octave/class/example.h @@ -0,0 +1,39 @@ +/* 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); +}; + + + + + diff --git a/Examples/octave/class/example.i b/Examples/octave/class/example.i new file mode 100644 index 0000000..75700b3 --- /dev/null +++ b/Examples/octave/class/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/octave/class/runme.m b/Examples/octave/class/runme.m new file mode 100644 index 0000000..c833a70 --- /dev/null +++ b/Examples/octave/class/runme.m @@ -0,0 +1,52 @@ +# file: runme.m + +# This file illustrates the proxy class C++ interface generated +# by SWIG. + +example + +# ----- Object creation ----- + +printf("Creating some objects:\n"); +c = example.Circle(10) +s = example.Square(10) + +# ----- Access a static member ----- + +printf("\nA total of %i shapes were created\n", example.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", example.Shape.nshapes); +printf("Goodbye\n"); + + diff --git a/Examples/octave/constants/Makefile b/Examples/octave/constants/Makefile new file mode 100644 index 0000000..4d80c6f --- /dev/null +++ b/Examples/octave/constants/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/constants/example.i b/Examples/octave/constants/example.i new file mode 100644 index 0000000..4f7b1a4 --- /dev/null +++ b/Examples/octave/constants/example.i @@ -0,0 +1,27 @@ +/* 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; + + diff --git a/Examples/octave/constants/runme.m b/Examples/octave/constants/runme.m new file mode 100644 index 0000000..3228587 --- /dev/null +++ b/Examples/octave/constants/runme.m @@ -0,0 +1,29 @@ +# file: runme.m + +example + +printf("ICONST = %i (should be 42)\n", example.ICONST); +printf("FCONST = %f (should be 2.1828)\n", example.FCONST); +printf("CCONST = %s (should be 'x')\n", example.CCONST); +printf("CCONST2 = %s (this should be on a new line)\n", example.CCONST2); +printf("SCONST = %s (should be 'Hello World')\n", example.SCONST); +printf("SCONST2 = %s (should be '\"Hello World\"')\n", example.SCONST2); +printf("EXPR = %f (should be 48.5484)\n", example.EXPR); +printf("iconst = %i (should be 37)\n", example.iconst); +printf("fconst = %f (should be 3.14)\n", example.fconst); + +try + printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", example.EXTERN); +catch + printf("EXTERN isn't defined (good)\n"); +end_try_catch + +try + printf("FOO = %i (Arg! This shouldn't printf(anything)\n", example.FOO); +catch + printf("FOO isn't defined (good)\n"); +end_try_catch + + + + diff --git a/Examples/octave/contract/Makefile b/Examples/octave/contract/Makefile new file mode 100644 index 0000000..627b0a9 --- /dev/null +++ b/Examples/octave/contract/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/contract/example.c b/Examples/octave/contract/example.c new file mode 100644 index 0000000..1a64454 --- /dev/null +++ b/Examples/octave/contract/example.c @@ -0,0 +1,23 @@ +/* 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); +} + + diff --git a/Examples/octave/contract/example.i b/Examples/octave/contract/example.i new file mode 100644 index 0000000..8fd1a80 --- /dev/null +++ b/Examples/octave/contract/example.i @@ -0,0 +1,21 @@ +/* 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; +%} diff --git a/Examples/octave/contract/runme.m b/Examples/octave/contract/runme.m new file mode 100644 index 0000000..62b7232 --- /dev/null +++ b/Examples/octave/contract/runme.m @@ -0,0 +1,22 @@ +# file: runme.m + +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 +printf("Foo = %f\n", example.cvar.Foo); + +# Change its value +example.cvar.Foo = 3.1415926; + +# See if the change took effect +printf("Foo = %f\n", example.cvar.Foo); + diff --git a/Examples/octave/enum/Makefile b/Examples/octave/enum/Makefile new file mode 100644 index 0000000..2bce9df --- /dev/null +++ b/Examples/octave/enum/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/enum/example.cxx b/Examples/octave/enum/example.cxx new file mode 100644 index 0000000..6785e57 --- /dev/null +++ b/Examples/octave/enum/example.cxx @@ -0,0 +1,37 @@ +/* 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"); + } +} diff --git a/Examples/octave/enum/example.h b/Examples/octave/enum/example.h new file mode 100644 index 0000000..525d62a --- /dev/null +++ b/Examples/octave/enum/example.h @@ -0,0 +1,13 @@ +/* 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); + diff --git a/Examples/octave/enum/example.i b/Examples/octave/enum/example.i new file mode 100644 index 0000000..23ee8a8 --- /dev/null +++ b/Examples/octave/enum/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ + +%include "example.h" + diff --git a/Examples/octave/enum/runme.m b/Examples/octave/enum/runme.m new file mode 100644 index 0000000..a749e81 --- /dev/null +++ b/Examples/octave/enum/runme.m @@ -0,0 +1,32 @@ +# file: runme.m + +example + +# ----- Object creation ----- + +# Print out the value of some enums +printf("*** color ***\n"); +printf(" RED = %i\n", example.RED); +printf(" BLUE = %i\n", example.BLUE); +printf(" GREEN = %i\n", example.GREEN); + +printf("\n*** Foo::speed ***\n"); +printf(" Foo_IMPULSE = %i\n", example.Foo_IMPULSE); +printf(" Foo_WARP = %i\n", example.Foo_WARP); +printf(" Foo_LUDICROUS = %i\n", example.Foo_LUDICROUS); + +printf("\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) + +printf("\nTesting use of enum with class method\n"); +f = example.Foo(); + +f.enum_test(example.Foo_IMPULSE); +f.enum_test(example.Foo_WARP); +f.enum_test(example.Foo_LUDICROUS); + + diff --git a/Examples/octave/extend/Makefile b/Examples/octave/extend/Makefile new file mode 100644 index 0000000..2bce9df --- /dev/null +++ b/Examples/octave/extend/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/extend/example.cxx b/Examples/octave/extend/example.cxx new file mode 100644 index 0000000..450d756 --- /dev/null +++ b/Examples/octave/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/octave/extend/example.h b/Examples/octave/extend/example.h new file mode 100644 index 0000000..b27ab97 --- /dev/null +++ b/Examples/octave/extend/example.h @@ -0,0 +1,56 @@ +/* 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; + } +}; + diff --git a/Examples/octave/extend/example.i b/Examples/octave/extend/example.i new file mode 100644 index 0000000..c8ec32e --- /dev/null +++ b/Examples/octave/extend/example.i @@ -0,0 +1,15 @@ +/* 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" + diff --git a/Examples/octave/extend/runme.m b/Examples/octave/extend/runme.m new file mode 100644 index 0000000..c64c082 --- /dev/null +++ b/Examples/octave/extend/runme.m @@ -0,0 +1,74 @@ +# file: runme.m + +# This file illustrates the cross language polymorphism using directors. + +example + + +# CEO class, which overrides Employee::getPosition(). + +CEO=@(name) subclass(example.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 = 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); +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"); + diff --git a/Examples/octave/funcptr/Makefile b/Examples/octave/funcptr/Makefile new file mode 100644 index 0000000..627b0a9 --- /dev/null +++ b/Examples/octave/funcptr/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/funcptr/example.c b/Examples/octave/funcptr/example.c new file mode 100644 index 0000000..5c4a3da --- /dev/null +++ b/Examples/octave/funcptr/example.c @@ -0,0 +1,19 @@ +/* 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; diff --git a/Examples/octave/funcptr/example.h b/Examples/octave/funcptr/example.h new file mode 100644 index 0000000..9936e24 --- /dev/null +++ b/Examples/octave/funcptr/example.h @@ -0,0 +1,9 @@ +/* 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); + diff --git a/Examples/octave/funcptr/example.i b/Examples/octave/funcptr/example.i new file mode 100644 index 0000000..8b3bef6 --- /dev/null +++ b/Examples/octave/funcptr/example.i @@ -0,0 +1,16 @@ +/* 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); + diff --git a/Examples/octave/funcptr/runme.m b/Examples/octave/funcptr/runme.m new file mode 100644 index 0000000..455311c --- /dev/null +++ b/Examples/octave/funcptr/runme.m @@ -0,0 +1,21 @@ +# file: runme.m + +example + +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", example.do_op(a,b,example.ADD)); +printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB)); +printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL)); + +printf("Here is what the C callback function objects look like in Octave\n"); +example.ADD +example.SUB +example.MUL + diff --git a/Examples/octave/funcptr2/Makefile b/Examples/octave/funcptr2/Makefile new file mode 100644 index 0000000..627b0a9 --- /dev/null +++ b/Examples/octave/funcptr2/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/funcptr2/example.c b/Examples/octave/funcptr2/example.c new file mode 100644 index 0000000..5c4a3da --- /dev/null +++ b/Examples/octave/funcptr2/example.c @@ -0,0 +1,19 @@ +/* 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; diff --git a/Examples/octave/funcptr2/example.h b/Examples/octave/funcptr2/example.h new file mode 100644 index 0000000..9936e24 --- /dev/null +++ b/Examples/octave/funcptr2/example.h @@ -0,0 +1,9 @@ +/* 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); + diff --git a/Examples/octave/funcptr2/example.i b/Examples/octave/funcptr2/example.i new file mode 100644 index 0000000..681775a --- /dev/null +++ b/Examples/octave/funcptr2/example.i @@ -0,0 +1,18 @@ +/* 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); + diff --git a/Examples/octave/funcptr2/runme.m b/Examples/octave/funcptr2/runme.m new file mode 100644 index 0000000..1d3d8f7 --- /dev/null +++ b/Examples/octave/funcptr2/runme.m @@ -0,0 +1,24 @@ +# file: runme.m + +example + +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", example.do_op(a,b,example.ADD)); +printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB)); +printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL)); + +printf("Here is what the C callback function objects look like in Octave\n"); +example.ADD +example.SUB +example.MUL + +printf("Call the functions directly...\n"); +printf(" add(a,b) = %i\n", example.add(a,b)); +printf(" sub(a,b) = %i\n", example.sub(a,b)); diff --git a/Examples/octave/functor/Makefile b/Examples/octave/functor/Makefile new file mode 100644 index 0000000..d910de5 --- /dev/null +++ b/Examples/octave/functor/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/functor/example.i b/Examples/octave/functor/example.i new file mode 100644 index 0000000..2fd3817 --- /dev/null +++ b/Examples/octave/functor/example.i @@ -0,0 +1,29 @@ +/* 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; + + + + diff --git a/Examples/octave/functor/runme.m b/Examples/octave/functor/runme.m new file mode 100644 index 0000000..65dabcc --- /dev/null +++ b/Examples/octave/functor/runme.m @@ -0,0 +1,18 @@ +# Operator overloading example +example + +a = example.intSum(0); +b = example.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() + + diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile new file mode 100644 index 0000000..6e625d5 --- /dev/null +++ b/Examples/octave/operator/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).m + +check: all diff --git a/Examples/octave/operator/example.h b/Examples/octave/operator/example.h new file mode 100644 index 0000000..526f262 --- /dev/null +++ b/Examples/octave/operator/example.h @@ -0,0 +1,36 @@ +/* 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; } +}; + + + + + diff --git a/Examples/octave/operator/example.i b/Examples/octave/operator/example.i new file mode 100644 index 0000000..d4bba5c --- /dev/null +++ b/Examples/octave/operator/example.i @@ -0,0 +1,24 @@ +/* File : example.i */ +%module example +#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ +%{ +#include "example.h" +%} + +/* 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); + } +}; + + diff --git a/Examples/octave/operator/runme.m b/Examples/octave/operator/runme.m new file mode 100644 index 0000000..e0f5906 --- /dev/null +++ b/Examples/octave/operator/runme.m @@ -0,0 +1,24 @@ +# Operator overloading example +example + +a = example.ComplexVal(2,3); +b = example.ComplexVal(-5,10); + +printf("a = %s\n",a); +printf("b = %s\n",b); + +c = a + b; +printf("c = %s\n",c); +printf("a*b = %s\n",a*b); +printf("a-c = %s\n",a-c); + +e = example.ComplexVal(a-c); +printf("e = %s\n",e); + +# Big expression +f = ((a+b)*(c+b*e)) + (-a); +printf("f = %s\n",f); + +# paren overloading +printf("a(3)= %s\n",a(3)); + diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile new file mode 100644 index 0000000..627b0a9 --- /dev/null +++ b/Examples/octave/pointer/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/pointer/example.c b/Examples/octave/pointer/example.c new file mode 100644 index 0000000..b877d9a --- /dev/null +++ b/Examples/octave/pointer/example.c @@ -0,0 +1,16 @@ +/* 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; +} diff --git a/Examples/octave/pointer/example.i b/Examples/octave/pointer/example.i new file mode 100644 index 0000000..a8ac794 --- /dev/null +++ b/Examples/octave/pointer/example.i @@ -0,0 +1,30 @@ +/* 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); + + + + diff --git a/Examples/octave/pointer/runme.m b/Examples/octave/pointer/runme.m new file mode 100644 index 0000000..c36df72 --- /dev/null +++ b/Examples/octave/pointer/runme.m @@ -0,0 +1,42 @@ +# file: runme.m + +example; + +# First create some objects using the pointer library. +printf("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); + +a,b,c + +# Call the add() function with some pointers +example.add(a,b,c); + +# Now get the result +r = example.intp_value(c); +printf(" 37 + 42 = %i\n",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. + +printf("Trying the typemap library\n"); +r = example.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] = example.divide(42,37); +printf(" 42/37 = %d remainder %d\n",q,r); + + + diff --git a/Examples/octave/reference/Makefile b/Examples/octave/reference/Makefile new file mode 100644 index 0000000..2bce9df --- /dev/null +++ b/Examples/octave/reference/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/reference/example.cxx b/Examples/octave/reference/example.cxx new file mode 100644 index 0000000..8a513bf --- /dev/null +++ b/Examples/octave/reference/example.cxx @@ -0,0 +1,46 @@ +/* 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; +} + diff --git a/Examples/octave/reference/example.h b/Examples/octave/reference/example.h new file mode 100644 index 0000000..4915adb --- /dev/null +++ b/Examples/octave/reference/example.h @@ -0,0 +1,26 @@ +/* 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(); +}; + + + + diff --git a/Examples/octave/reference/example.i b/Examples/octave/reference/example.i new file mode 100644 index 0000000..8c95b32 --- /dev/null +++ b/Examples/octave/reference/example.i @@ -0,0 +1,48 @@ +/* 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; + } + } +}; + + + + diff --git a/Examples/octave/reference/runme.m b/Examples/octave/reference/runme.m new file mode 100644 index 0000000..f59c8eb --- /dev/null +++ b/Examples/octave/reference/runme.m @@ -0,0 +1,63 @@ +# file: runme.m + +# This file illustrates the manipulation of C++ references in Octave + +example + +# ----- Object creation ----- + +printf("Creating some objects:\n"); +a = example.Vector(3,4,5) +b = example.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 = example.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 = example.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,example.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 + diff --git a/Examples/octave/simple/Makefile b/Examples/octave/simple/Makefile new file mode 100644 index 0000000..627b0a9 --- /dev/null +++ b/Examples/octave/simple/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/simple/example.c b/Examples/octave/simple/example.c new file mode 100644 index 0000000..1c2af78 --- /dev/null +++ b/Examples/octave/simple/example.c @@ -0,0 +1,18 @@ +/* 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; +} + + diff --git a/Examples/octave/simple/example.i b/Examples/octave/simple/example.i new file mode 100644 index 0000000..24093b9 --- /dev/null +++ b/Examples/octave/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/octave/simple/runme.m b/Examples/octave/simple/runme.m new file mode 100644 index 0000000..8dc5eaa --- /dev/null +++ b/Examples/octave/simple/runme.m @@ -0,0 +1,22 @@ +# file: runme.m + +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 +example.cvar.Foo + +# Change its value +example.cvar.Foo = 3.1415926 + +# See if the change took effect +printf("Foo = %f\n", example.cvar.Foo); + diff --git a/Examples/octave/template/Makefile b/Examples/octave/template/Makefile new file mode 100644 index 0000000..3d7445a --- /dev/null +++ b/Examples/octave/template/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/template/example.h b/Examples/octave/template/example.h new file mode 100644 index 0000000..7401df6 --- /dev/null +++ b/Examples/octave/template/example.h @@ -0,0 +1,32 @@ +/* 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 +}; + diff --git a/Examples/octave/template/example.i b/Examples/octave/template/example.i new file mode 100644 index 0000000..8f94c4d --- /dev/null +++ b/Examples/octave/template/example.i @@ -0,0 +1,17 @@ +/* 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; + diff --git a/Examples/octave/template/runme.m b/Examples/octave/template/runme.m new file mode 100644 index 0000000..a9891d4 --- /dev/null +++ b/Examples/octave/template/runme.m @@ -0,0 +1,37 @@ +# file: runme.m + +example + +# Call some templated functions +example.maxint(3,7) +example.maxdouble(3.14,2.18) + +# Create some class + +iv = example.vecint(100) +dv = example.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 + + diff --git a/Examples/octave/variables/Makefile b/Examples/octave/variables/Makefile new file mode 100644 index 0000000..627b0a9 --- /dev/null +++ b/Examples/octave/variables/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static + +clean:: + $(MAKE) -f $(TOP)/Makefile octave_clean + rm -f $(TARGET).py + +check: all diff --git a/Examples/octave/variables/example.c b/Examples/octave/variables/example.c new file mode 100644 index 0000000..aa4ffe9 --- /dev/null +++ b/Examples/octave/variables/example.c @@ -0,0 +1,91 @@ +/* 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); +} diff --git a/Examples/octave/variables/example.h b/Examples/octave/variables/example.h new file mode 100644 index 0000000..0f7e895 --- /dev/null +++ b/Examples/octave/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/octave/variables/example.i b/Examples/octave/variables/example.i new file mode 100644 index 0000000..639b6c7 --- /dev/null +++ b/Examples/octave/variables/example.i @@ -0,0 +1,53 @@ +/* File : example.i */ +%module example +%{ +#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(); +%} + diff --git a/Examples/octave/variables/runme.m b/Examples/octave/variables/runme.m new file mode 100644 index 0000000..db88b18 --- /dev/null +++ b/Examples/octave/variables/runme.m @@ -0,0 +1,75 @@ +# file: runme.m + +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 + +printf("Variables (values printed from Octave)\n"); + +printf("ivar = %i\n", example.cvar.ivar); +printf("svar = %i\n", example.cvar.svar); +printf("lvar = %i\n", example.cvar.lvar); +printf("uivar = %i\n", example.cvar.uivar); +printf("usvar = %i\n", example.cvar.usvar); +printf("ulvar = %i\n", example.cvar.ulvar); +printf("scvar = %i\n", example.cvar.scvar); +printf("ucvar = %i\n", example.cvar.ucvar); +printf("fvar = %i\n", example.cvar.fvar); +printf("dvar = %i\n", example.cvar.dvar); +printf("cvar = %s\n", example.cvar.cvar); +printf("strvar = %s\n", example.cvar.strvar); +#printf("cstrvar = %s\n", example.cvar.cstrvar); +example.cvar.iptrvar +printf("name = %i\n", example.cvar.name); +printf("ptptr = %s\n", example.Point_print(example.cvar.ptptr)); +#printf("pt = %s\n", example.cvar.Point_print(example.cvar.pt)); + +printf("\nVariables (values printed from C)\n"); + +example.print_vars(); + +printf("\nNow I'm going to try and modify some read only variables\n"); + +printf(" Tring to set 'path'\n"); +try + example.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 + example.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"); + +example.cvar.pt = example.cvar.ptptr; + +printf("The new value is %s\n", example.Point_print(example.cvar.pt)); + + + diff --git a/Examples/perl5/check.list b/Examples/perl5/check.list new file mode 100644 index 0000000..e15f02e --- /dev/null +++ b/Examples/perl5/check.list @@ -0,0 +1,14 @@ +# see top-level Makefile.in +class +constants +constants2 +funcptr +import +java +multimap +multiple_inheritance +pointer +reference +simple +value +variables diff --git a/Examples/perl5/class/Makefile b/Examples/perl5/class/Makefile new file mode 100644 index 0000000..f533617 --- /dev/null +++ b/Examples/perl5/class/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm + +all:: + $(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 + +check: all diff --git a/Examples/perl5/class/example.cxx b/Examples/perl5/class/example.cxx new file mode 100644 index 0000000..1e8e203 --- /dev/null +++ b/Examples/perl5/class/example.cxx @@ -0,0 +1,28 @@ +/* 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; +} diff --git a/Examples/perl5/class/example.dsp b/Examples/perl5/class/example.dsp new file mode 100644 index 0000000..b5ccd19 --- /dev/null +++ b/Examples/perl5/class/example.dsp @@ -0,0 +1,152 @@ +# 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 diff --git a/Examples/perl5/class/example.h b/Examples/perl5/class/example.h new file mode 100644 index 0000000..b0671d5 --- /dev/null +++ b/Examples/perl5/class/example.h @@ -0,0 +1,47 @@ +/* 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);}; +}; + + + + + diff --git a/Examples/perl5/class/example.i b/Examples/perl5/class/example.i new file mode 100644 index 0000000..23ee8a8 --- /dev/null +++ b/Examples/perl5/class/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ + +%include "example.h" + diff --git a/Examples/perl5/class/index.html b/Examples/perl5/class/index.html new file mode 100644 index 0000000..58a50ad --- /dev/null +++ b/Examples/perl5/class/index.html @@ -0,0 +1,208 @@ + + +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

    + +