summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rw-r--r--Examples/GIFPlot/.cvsignore1
-rw-r--r--Examples/GIFPlot/Common-Lisp/full/cmap (renamed from Examples/GIFPlot/Java/cmap)bin768 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Common-Lisp/full/gifplot.i21
-rw-r--r--Examples/GIFPlot/Common-Lisp/full/runme.lisp59
-rw-r--r--Examples/GIFPlot/Guile/check.list3
-rw-r--r--Examples/GIFPlot/Guile/full/.cvsignore3
-rw-r--r--Examples/GIFPlot/Guile/full/Makefile9
-rw-r--r--Examples/GIFPlot/Guile/simple/.cvsignore4
-rw-r--r--Examples/GIFPlot/Guile/simple/Makefile9
-rw-r--r--Examples/GIFPlot/Include/gifplot.h10
-rw-r--r--Examples/GIFPlot/Interface/gifplot.i39
-rw-r--r--Examples/GIFPlot/Java/Makefile18
-rw-r--r--Examples/GIFPlot/Java/README30
-rw-r--r--Examples/GIFPlot/Java/check.list4
-rw-r--r--Examples/GIFPlot/Java/cm15bin768 -> 0 bytes
-rw-r--r--Examples/GIFPlot/Java/full/.cvsignore7
-rw-r--r--Examples/GIFPlot/Java/full/Makefile20
-rw-r--r--Examples/GIFPlot/Java/full/README8
-rw-r--r--Examples/GIFPlot/Java/full/cmapbin0 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Java/full/gifplot.i15
-rw-r--r--Examples/GIFPlot/Java/full/main.java75
-rw-r--r--Examples/GIFPlot/Java/gifplot.i273
-rw-r--r--Examples/GIFPlot/Java/ortho.java107
-rw-r--r--Examples/GIFPlot/Java/shadow.java22
-rw-r--r--Examples/GIFPlot/Java/shadow/.cvsignore7
-rw-r--r--Examples/GIFPlot/Java/shadow/Makefile20
-rw-r--r--Examples/GIFPlot/Java/shadow/README5
-rw-r--r--Examples/GIFPlot/Java/shadow/cmapbin0 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Java/shadow/main.java76
-rw-r--r--Examples/GIFPlot/Java/simple.java22
-rw-r--r--Examples/GIFPlot/Java/simple/.cvsignore7
-rw-r--r--Examples/GIFPlot/Java/simple/Makefile21
-rw-r--r--Examples/GIFPlot/Java/simple/README5
-rw-r--r--Examples/GIFPlot/Java/simple/main.java41
-rw-r--r--Examples/GIFPlot/Java/simple/simple.i38
-rw-r--r--Examples/GIFPlot/LICENSE41
-rw-r--r--Examples/GIFPlot/Lib/.cvsignore1
-rw-r--r--Examples/GIFPlot/Lib/Makefile.in12
-rw-r--r--Examples/GIFPlot/Lib/pixmap.c4
-rw-r--r--Examples/GIFPlot/Makefile.in4
-rw-r--r--Examples/GIFPlot/Ocaml/check.list3
-rw-r--r--Examples/GIFPlot/Ocaml/full/Makefile26
-rw-r--r--Examples/GIFPlot/Ocaml/full/README8
-rw-r--r--Examples/GIFPlot/Ocaml/full/cmapbin0 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Ocaml/full/gifplot.i15
-rw-r--r--Examples/GIFPlot/Ocaml/full/runme.ml86
-rw-r--r--Examples/GIFPlot/Ocaml/simple/Makefile26
-rw-r--r--Examples/GIFPlot/Ocaml/simple/cmapbin0 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Ocaml/simple/runme.ml34
-rw-r--r--Examples/GIFPlot/Ocaml/simple/simple.i33
-rw-r--r--Examples/GIFPlot/Perl/check.list4
-rw-r--r--Examples/GIFPlot/Perl/full/.cvsignore5
-rw-r--r--Examples/GIFPlot/Perl/full/Makefile9
-rw-r--r--Examples/GIFPlot/Perl/shadow/.cvsignore5
-rw-r--r--Examples/GIFPlot/Perl/shadow/Makefile9
-rw-r--r--Examples/GIFPlot/Perl/simple/.cvsignore5
-rw-r--r--Examples/GIFPlot/Perl/simple/Makefile9
-rw-r--r--Examples/GIFPlot/Php/check.list3
-rw-r--r--Examples/GIFPlot/Php/full/Makefile19
-rw-r--r--Examples/GIFPlot/Php/full/README4
-rw-r--r--Examples/GIFPlot/Php/full/cmapbin0 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Php/full/gifplot.i15
-rw-r--r--Examples/GIFPlot/Php/full/runme.php478
-rw-r--r--Examples/GIFPlot/Php/shadow/Makefile19
-rw-r--r--Examples/GIFPlot/Php/shadow/README2
-rw-r--r--Examples/GIFPlot/Php/shadow/cmapbin0 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Php/shadow/runme.php479
-rw-r--r--Examples/GIFPlot/Php/simple/Makefile19
-rw-r--r--Examples/GIFPlot/Php/simple/README5
-rw-r--r--Examples/GIFPlot/Php/simple/runme.php432
-rw-r--r--Examples/GIFPlot/Php/simple/simple.i38
-rw-r--r--Examples/GIFPlot/Pike/check.list2
-rw-r--r--Examples/GIFPlot/Pike/simple/.cvsignore4
-rw-r--r--Examples/GIFPlot/Pike/simple/Makefile24
-rw-r--r--Examples/GIFPlot/Pike/simple/README5
-rw-r--r--Examples/GIFPlot/Pike/simple/runme.pike30
-rw-r--r--Examples/GIFPlot/Pike/simple/simple.i38
-rw-r--r--Examples/GIFPlot/Python/check.list4
-rw-r--r--Examples/GIFPlot/Python/full/.cvsignore4
-rw-r--r--Examples/GIFPlot/Python/full/Makefile12
-rw-r--r--Examples/GIFPlot/Python/full/runme.py4
-rw-r--r--Examples/GIFPlot/Python/shadow/.cvsignore6
-rw-r--r--Examples/GIFPlot/Python/shadow/Makefile14
-rw-r--r--Examples/GIFPlot/Python/simple/.cvsignore4
-rw-r--r--Examples/GIFPlot/Python/simple/Makefile10
-rw-r--r--Examples/GIFPlot/README4
-rw-r--r--Examples/GIFPlot/Ruby/check.list4
-rw-r--r--Examples/GIFPlot/Ruby/full/.cvsignore4
-rw-r--r--Examples/GIFPlot/Ruby/full/Makefile9
-rw-r--r--Examples/GIFPlot/Ruby/shadow/.cvsignore4
-rw-r--r--Examples/GIFPlot/Ruby/shadow/Makefile9
-rw-r--r--Examples/GIFPlot/Ruby/simple/.cvsignore4
-rw-r--r--Examples/GIFPlot/Ruby/simple/Makefile9
-rw-r--r--Examples/GIFPlot/Tcl/check.list4
-rw-r--r--Examples/GIFPlot/Tcl/full/.cvsignore4
-rw-r--r--Examples/GIFPlot/Tcl/full/Makefile9
-rw-r--r--Examples/GIFPlot/Tcl/mandel/.cvsignore4
-rw-r--r--Examples/GIFPlot/Tcl/mandel/Makefile9
-rw-r--r--Examples/GIFPlot/Tcl/simple/.cvsignore4
-rw-r--r--Examples/GIFPlot/Tcl/simple/Makefile9
-rwxr-xr-xExamples/GIFPlot/configure1299
-rw-r--r--Examples/GIFPlot/configure.in52
-rw-r--r--Examples/Makefile.in477
-rw-r--r--Examples/README2
-rw-r--r--Examples/guile/Makefile.in23
-rw-r--r--Examples/guile/README14
-rw-r--r--Examples/guile/check.list7
-rw-r--r--Examples/guile/constants/.cvsignore2
-rw-r--r--Examples/guile/constants/Makefile17
-rw-r--r--Examples/guile/constants/constants.scm10
-rw-r--r--Examples/guile/constants/example.i27
-rw-r--r--Examples/guile/matrix/Makefile4
-rw-r--r--Examples/guile/matrix/README2
-rw-r--r--Examples/guile/matrix/matrix.c2
-rw-r--r--Examples/guile/matrix/matrix.i3
-rw-r--r--Examples/guile/matrix/package.i3
-rw-r--r--Examples/guile/matrix/vector.c2
-rw-r--r--Examples/guile/multimap/Makefile18
-rw-r--r--Examples/guile/multimap/example.c53
-rw-r--r--Examples/guile/multimap/example.i75
-rw-r--r--Examples/guile/multimap/runme.scm30
-rw-r--r--Examples/guile/multivalue/Makefile18
-rw-r--r--Examples/guile/multivalue/example.c18
-rw-r--r--Examples/guile/multivalue/example.i26
-rw-r--r--Examples/guile/multivalue/runme.scm66
-rw-r--r--Examples/guile/port/Makefile4
-rw-r--r--Examples/guile/port/port.i4
-rw-r--r--Examples/guile/simple/Makefile11
-rw-r--r--Examples/guile/simple/README2
-rw-r--r--Examples/guile/simple/example.c2
-rw-r--r--Examples/guile/simple/example.scm33
-rw-r--r--Examples/guile/std_vector/.cvsignore1
-rw-r--r--Examples/guile/std_vector/Makefile18
-rw-r--r--Examples/guile/std_vector/example.h25
-rw-r--r--Examples/guile/std_vector/example.i17
-rw-r--r--Examples/guile/std_vector/runme.scm54
-rw-r--r--Examples/index.html6
-rw-r--r--Examples/java/check.list14
-rw-r--r--Examples/java/class/.cvsignore11
-rw-r--r--Examples/java/class/Makefile18
-rw-r--r--Examples/java/class/example.cxx28
-rw-r--r--Examples/java/class/example.dsp162
-rw-r--r--Examples/java/class/example.h39
-rw-r--r--Examples/java/class/example.i10
-rw-r--r--Examples/java/class/index.html199
-rw-r--r--Examples/java/class/main.java70
-rw-r--r--Examples/java/constants/.cvsignore11
-rw-r--r--Examples/java/constants/Makefile18
-rw-r--r--Examples/java/constants/example.i27
-rw-r--r--Examples/java/constants/index.html53
-rw-r--r--Examples/java/constants/main.java44
-rw-r--r--Examples/java/enum/.cvsignore11
-rw-r--r--Examples/java/enum/Makefile18
-rw-r--r--Examples/java/enum/example.cxx37
-rw-r--r--Examples/java/enum/example.h13
-rw-r--r--Examples/java/enum/example.i13
-rw-r--r--Examples/java/enum/index.html37
-rw-r--r--Examples/java/enum/main.java39
-rw-r--r--Examples/java/funcptr/.cvsignore11
-rw-r--r--Examples/java/funcptr/Makefile18
-rw-r--r--Examples/java/funcptr/example.c19
-rw-r--r--Examples/java/funcptr/example.h7
-rw-r--r--Examples/java/funcptr/example.i16
-rw-r--r--Examples/java/funcptr/index.html93
-rw-r--r--Examples/java/funcptr/main.java33
-rw-r--r--Examples/java/index.html68
-rw-r--r--Examples/java/mpointer/Makefile18
-rw-r--r--Examples/java/mpointer/example.cxx45
-rw-r--r--Examples/java/mpointer/example.h50
-rw-r--r--Examples/java/mpointer/example.i16
-rw-r--r--Examples/java/mpointer/main.java61
-rw-r--r--Examples/java/multimap/.cvsignore11
-rw-r--r--Examples/java/multimap/Makefile18
-rw-r--r--Examples/java/multimap/example.c53
-rw-r--r--Examples/java/multimap/example.i101
-rw-r--r--Examples/java/multimap/main.java40
-rw-r--r--Examples/java/native/.cvsignore11
-rw-r--r--Examples/java/native/Makefile7
-rw-r--r--Examples/java/native/README6
-rw-r--r--Examples/java/native/example.i14
-rw-r--r--Examples/java/native/index.html33
-rw-r--r--Examples/java/native/main.java6
-rw-r--r--Examples/java/pointer/.cvsignore11
-rw-r--r--Examples/java/pointer/Makefile18
-rw-r--r--Examples/java/pointer/example.c16
-rw-r--r--Examples/java/pointer/example.i24
-rw-r--r--Examples/java/pointer/index.html167
-rw-r--r--Examples/java/pointer/main.java55
-rw-r--r--Examples/java/reference/.cvsignore11
-rw-r--r--Examples/java/reference/Makefile18
-rw-r--r--Examples/java/reference/example.cxx41
-rw-r--r--Examples/java/reference/example.h26
-rw-r--r--Examples/java/reference/example.i46
-rw-r--r--Examples/java/reference/index.html149
-rw-r--r--Examples/java/reference/main.java79
-rw-r--r--Examples/java/simple/.cvsignore11
-rw-r--r--Examples/java/simple/Makefile7
-rw-r--r--Examples/java/simple/README8
-rw-r--r--Examples/java/simple/example.c30
-rw-r--r--Examples/java/simple/example.dsp158
-rw-r--r--Examples/java/simple/example.i10
-rw-r--r--Examples/java/simple/index.html110
-rw-r--r--Examples/java/simple/main.java36
-rw-r--r--Examples/java/template/.cvsignore11
-rw-r--r--Examples/java/template/Makefile18
-rw-r--r--Examples/java/template/example.h32
-rw-r--r--Examples/java/template/example.i17
-rw-r--r--Examples/java/template/index.html104
-rw-r--r--Examples/java/template/main.java45
-rw-r--r--Examples/java/typemap/.cvsignore11
-rw-r--r--Examples/java/typemap/Makefile7
-rw-r--r--Examples/java/typemap/README8
-rw-r--r--Examples/java/typemap/index.html34
-rw-r--r--Examples/java/typemap/main.java3
-rw-r--r--Examples/java/variables/.cvsignore11
-rw-r--r--Examples/java/variables/Makefile18
-rw-r--r--Examples/java/variables/example.c86
-rw-r--r--Examples/java/variables/example.h6
-rw-r--r--Examples/java/variables/example.i44
-rw-r--r--Examples/java/variables/index.html85
-rw-r--r--Examples/java/variables/main.java98
-rw-r--r--Examples/mzscheme/check.list3
-rw-r--r--Examples/mzscheme/multimap/Makefile13
-rw-r--r--Examples/mzscheme/multimap/example.c53
-rw-r--r--Examples/mzscheme/multimap/example.i81
-rw-r--r--Examples/mzscheme/multimap/example.scm27
-rw-r--r--Examples/mzscheme/simple/.cvsignore1
-rw-r--r--Examples/mzscheme/simple/Makefile2
-rw-r--r--Examples/mzscheme/std_vector/.cvsignore1
-rw-r--r--Examples/mzscheme/std_vector/Makefile19
-rw-r--r--Examples/mzscheme/std_vector/example.h25
-rw-r--r--Examples/mzscheme/std_vector/example.i17
-rw-r--r--Examples/mzscheme/std_vector/example.scm54
-rw-r--r--Examples/ocaml/check.list2
-rw-r--r--Examples/ocaml/simple/Makefile21
-rw-r--r--Examples/ocaml/simple/example.c18
-rw-r--r--Examples/ocaml/simple/example.dsp148
-rw-r--r--Examples/ocaml/simple/example.i5
-rw-r--r--Examples/ocaml/simple/example_prog.ml37
-rw-r--r--Examples/ocaml/simple/index.html99
-rw-r--r--Examples/perl5/check.list13
-rw-r--r--Examples/perl5/class/.cvsignore10
-rw-r--r--Examples/perl5/class/Makefile2
-rw-r--r--Examples/perl5/class/example.cxx10
-rw-r--r--Examples/perl5/class/example.dsp150
-rw-r--r--Examples/perl5/class/example.h12
-rw-r--r--Examples/perl5/class/example.pl6
-rw-r--r--Examples/perl5/class/index.html29
-rw-r--r--Examples/perl5/constants/.cvsignore10
-rw-r--r--Examples/perl5/constants/Makefile2
-rw-r--r--Examples/perl5/constants/example.i7
-rw-r--r--Examples/perl5/constants2/.cvsignore10
-rw-r--r--Examples/perl5/constants2/Makefile18
-rw-r--r--Examples/perl5/constants2/example.i27
-rw-r--r--Examples/perl5/constants2/example.pl16
-rw-r--r--Examples/perl5/funcptr/.cvsignore10
-rw-r--r--Examples/perl5/funcptr/Makefile2
-rw-r--r--Examples/perl5/funcptr/example.c2
-rw-r--r--Examples/perl5/funcptr/example.i7
-rw-r--r--Examples/perl5/import/.cvsignore14
-rw-r--r--Examples/perl5/import/Makefile21
-rw-r--r--Examples/perl5/import/README28
-rw-r--r--Examples/perl5/import/bar.h22
-rw-r--r--Examples/perl5/import/bar.i9
-rw-r--r--Examples/perl5/import/base.h18
-rw-r--r--Examples/perl5/import/base.i6
-rw-r--r--Examples/perl5/import/foo.h21
-rw-r--r--Examples/perl5/import/foo.i8
-rw-r--r--Examples/perl5/import/runme.pl116
-rw-r--r--Examples/perl5/import/spam.h24
-rw-r--r--Examples/perl5/import/spam.i9
-rw-r--r--Examples/perl5/index.html3
-rw-r--r--Examples/perl5/multimap/.cvsignore10
-rw-r--r--Examples/perl5/multimap/Makefile18
-rw-r--r--Examples/perl5/multimap/example.c53
-rw-r--r--Examples/perl5/multimap/example.dsp146
-rw-r--r--Examples/perl5/multimap/example.i81
-rwxr-xr-xExamples/perl5/multimap/example.pl28
-rw-r--r--Examples/perl5/pointer/.cvsignore10
-rw-r--r--Examples/perl5/pointer/Makefile2
-rw-r--r--Examples/perl5/pointer/example.i3
-rw-r--r--Examples/perl5/pointer/example.pl16
-rw-r--r--Examples/perl5/reference/.cvsignore10
-rw-r--r--Examples/perl5/reference/Makefile2
-rw-r--r--Examples/perl5/reference/example.i2
-rw-r--r--Examples/perl5/shadow/.cvsignore10
-rw-r--r--Examples/perl5/shadow/Makefile2
-rw-r--r--Examples/perl5/shadow/example.cxx8
-rw-r--r--Examples/perl5/shadow/example.h14
-rw-r--r--Examples/perl5/shadow/example.pl21
-rw-r--r--Examples/perl5/simple/.cvsignore10
-rw-r--r--Examples/perl5/simple/Makefile2
-rw-r--r--Examples/perl5/simple/example.dsp146
-rw-r--r--Examples/perl5/value/.cvsignore10
-rw-r--r--Examples/perl5/value/Makefile2
-rw-r--r--Examples/perl5/variables/.cvsignore10
-rw-r--r--Examples/perl5/variables/Makefile2
-rw-r--r--Examples/perl5/variables/example.i4
-rw-r--r--Examples/perl5/variables/index.html10
-rw-r--r--Examples/php4/Makefile.php30
-rw-r--r--Examples/php4/check.list13
-rwxr-xr-xExamples/php4/class/BUILD.sh4
-rw-r--r--Examples/php4/class/Makefile.old17
-rw-r--r--Examples/php4/class/example.cxx28
-rw-r--r--Examples/php4/class/example.h39
-rw-r--r--Examples/php4/class/example.i10
-rw-r--r--Examples/php4/class/runme.php458
-rwxr-xr-xExamples/php4/constants/BUILD.sh4
-rw-r--r--Examples/php4/constants/Makefile.old15
-rw-r--r--Examples/php4/constants/example.i26
-rw-r--r--Examples/php4/constants/runme.php428
-rwxr-xr-xExamples/php4/enum/BUILD.sh4
-rw-r--r--Examples/php4/enum/Makefile.old17
-rw-r--r--Examples/php4/enum/example.cxx37
-rw-r--r--Examples/php4/enum/example.h13
-rw-r--r--Examples/php4/enum/example.i12
-rw-r--r--Examples/php4/enum/runme.php432
-rwxr-xr-xExamples/php4/funcptr/BUILD.sh4
-rw-r--r--Examples/php4/funcptr/Makefile.old15
-rw-r--r--Examples/php4/funcptr/example.c17
-rw-r--r--Examples/php4/funcptr/example.h7
-rw-r--r--Examples/php4/funcptr/example.i15
-rw-r--r--Examples/php4/funcptr/runme.php424
-rwxr-xr-xExamples/php4/pointer/BUILD.sh4
-rw-r--r--Examples/php4/pointer/Makefile.old15
-rw-r--r--Examples/php4/pointer/example.c16
-rw-r--r--Examples/php4/pointer/example.i26
-rw-r--r--Examples/php4/pointer/runme.php445
-rwxr-xr-xExamples/php4/reference/BUILD.sh4
-rw-r--r--Examples/php4/reference/Makefile.old17
-rw-r--r--Examples/php4/reference/example.cxx44
-rw-r--r--Examples/php4/reference/example.h26
-rw-r--r--Examples/php4/reference/example.i44
-rw-r--r--Examples/php4/reference/runme.php478
-rwxr-xr-xExamples/php4/shadow/BUILD.sh4
-rw-r--r--Examples/php4/shadow/Makefile.old16
-rw-r--r--Examples/php4/shadow/example.cxx28
-rw-r--r--Examples/php4/shadow/example.h43
-rw-r--r--Examples/php4/shadow/example.i11
-rw-r--r--Examples/php4/shadow/runme.php458
-rwxr-xr-xExamples/php4/simple/BUILD.sh4
-rw-r--r--Examples/php4/simple/Makefile.old15
-rw-r--r--Examples/php4/simple/example.c18
-rw-r--r--Examples/php4/simple/example.i5
-rwxr-xr-xExamples/php4/simple/runme.php424
-rwxr-xr-xExamples/php4/sync/BUILD.sh4
-rw-r--r--Examples/php4/sync/Makefile.old15
-rw-r--r--Examples/php4/sync/example.cxx13
-rw-r--r--Examples/php4/sync/example.h9
-rw-r--r--Examples/php4/sync/example.i7
-rw-r--r--Examples/php4/sync/runme.php415
-rwxr-xr-xExamples/php4/value/BUILD.sh4
-rw-r--r--Examples/php4/value/Makefile.old15
-rw-r--r--Examples/php4/value/example.c15
-rw-r--r--Examples/php4/value/example.h5
-rw-r--r--Examples/php4/value/example.i31
-rw-r--r--Examples/php4/value/runme.php435
-rwxr-xr-xExamples/php4/variables/BUILD.sh4
-rw-r--r--Examples/php4/variables/Makefile.old15
-rw-r--r--Examples/php4/variables/example.c90
-rw-r--r--Examples/php4/variables/example.h6
-rw-r--r--Examples/php4/variables/example.i45
-rw-r--r--Examples/php4/variables/runme.php471
-rw-r--r--Examples/php4/variables/runme.php4.old80
-rw-r--r--Examples/pike/check.list8
-rwxr-xr-xExamples/pike/class/.cvsignore9
-rwxr-xr-xExamples/pike/class/Makefile19
-rwxr-xr-xExamples/pike/class/example.cxx48
-rwxr-xr-xExamples/pike/class/example.h35
-rwxr-xr-xExamples/pike/class/example.i10
-rwxr-xr-xExamples/pike/class/runme.pike61
-rwxr-xr-xExamples/pike/constants/.cvsignore9
-rwxr-xr-xExamples/pike/constants/Makefile18
-rwxr-xr-xExamples/pike/constants/example.i27
-rwxr-xr-xExamples/pike/constants/runme.pike24
-rw-r--r--Examples/pike/enum/.cvsignore9
-rw-r--r--Examples/pike/enum/Makefile19
-rw-r--r--Examples/pike/enum/example.cxx37
-rw-r--r--Examples/pike/enum/example.h13
-rw-r--r--Examples/pike/enum/example.i11
-rw-r--r--Examples/pike/enum/runme.pike27
-rw-r--r--Examples/pike/overload/.cvsignore4
-rw-r--r--Examples/pike/overload/Makefile19
-rwxr-xr-xExamples/pike/overload/example.cxx115
-rwxr-xr-xExamples/pike/overload/example.h41
-rw-r--r--Examples/pike/overload/example.i28
-rw-r--r--Examples/pike/overload/runme.pike83
-rw-r--r--Examples/pike/simple/.cvsignore9
-rw-r--r--Examples/pike/simple/Makefile18
-rw-r--r--Examples/pike/simple/example.c18
-rw-r--r--Examples/pike/simple/example.i5
-rw-r--r--Examples/pike/simple/runme.pike20
-rwxr-xr-xExamples/pike/template/.cvsignore1
-rwxr-xr-xExamples/pike/template/Makefile20
-rwxr-xr-xExamples/pike/template/example.h32
-rwxr-xr-xExamples/pike/template/example.i17
-rwxr-xr-xExamples/pike/template/runme.pike33
-rw-r--r--Examples/python/check.list23
-rw-r--r--Examples/python/class/.cvsignore9
-rw-r--r--Examples/python/class/Makefile3
-rw-r--r--Examples/python/class/example.cxx10
-rw-r--r--Examples/python/class/example.dsp152
-rw-r--r--Examples/python/class/example.h14
-rw-r--r--Examples/python/class/example.py67
-rw-r--r--Examples/python/class/index.html41
-rw-r--r--Examples/python/class/runme.py51
-rw-r--r--Examples/python/constants/.cvsignore9
-rw-r--r--Examples/python/constants/Makefile3
-rw-r--r--Examples/python/constants/example.i16
-rw-r--r--Examples/python/constants/runme.py (renamed from Examples/python/constants/example.py)2
-rw-r--r--Examples/python/enum/.cvsignore9
-rw-r--r--Examples/python/enum/Makefile3
-rw-r--r--Examples/python/enum/example.py30
-rw-r--r--Examples/python/enum/runme.py31
-rw-r--r--Examples/python/exception/Makefile20
-rw-r--r--Examples/python/exception/example.h37
-rw-r--r--Examples/python/exception/example.i12
-rw-r--r--Examples/python/exception/runme.py29
-rw-r--r--Examples/python/exceptshadow/.cvsignore10
-rw-r--r--Examples/python/exceptshadow/Makefile21
-rw-r--r--Examples/python/exceptshadow/example.h51
-rw-r--r--Examples/python/exceptshadow/example.i83
-rw-r--r--Examples/python/exceptshadow/runme.py45
-rw-r--r--Examples/python/funcattr/.cvsignore10
-rw-r--r--Examples/python/funcattr/Makefile21
-rw-r--r--Examples/python/funcattr/example.i17
-rw-r--r--Examples/python/funcattr/index.html22
-rw-r--r--Examples/python/funcattr/runme.py17
-rw-r--r--Examples/python/funcptr/.cvsignore9
-rw-r--r--Examples/python/funcptr/Makefile3
-rw-r--r--Examples/python/funcptr/example.c2
-rw-r--r--Examples/python/funcptr/example.i7
-rw-r--r--Examples/python/funcptr/runme.py (renamed from Examples/python/funcptr/example.py)0
-rw-r--r--Examples/python/funcptr2/.cvsignore9
-rw-r--r--Examples/python/funcptr2/Makefile19
-rw-r--r--Examples/python/funcptr2/example.c19
-rw-r--r--Examples/python/funcptr2/example.h7
-rw-r--r--Examples/python/funcptr2/example.i18
-rw-r--r--Examples/python/funcptr2/runme.py20
-rw-r--r--Examples/python/functor/.cvsignore10
-rw-r--r--Examples/python/functor/Makefile21
-rw-r--r--Examples/python/functor/example.i29
-rw-r--r--Examples/python/functor/runme.py17
-rw-r--r--Examples/python/import/.cvsignore13
-rw-r--r--Examples/python/import/Makefile22
-rw-r--r--Examples/python/import/README28
-rw-r--r--Examples/python/import/bar.h22
-rw-r--r--Examples/python/import/bar.i9
-rw-r--r--Examples/python/import/base.h18
-rw-r--r--Examples/python/import/base.i6
-rw-r--r--Examples/python/import/foo.h21
-rw-r--r--Examples/python/import/foo.i8
-rw-r--r--Examples/python/import/runme.py111
-rw-r--r--Examples/python/import/spam.h24
-rw-r--r--Examples/python/import/spam.i9
-rw-r--r--Examples/python/import_template/.cvsignore10
-rw-r--r--Examples/python/import_template/Makefile22
-rw-r--r--Examples/python/import_template/README30
-rw-r--r--Examples/python/import_template/bar.h22
-rw-r--r--Examples/python/import_template/bar.i11
-rw-r--r--Examples/python/import_template/base.h18
-rw-r--r--Examples/python/import_template/base.i7
-rw-r--r--Examples/python/import_template/foo.h21
-rw-r--r--Examples/python/import_template/foo.i10
-rw-r--r--Examples/python/import_template/runme.py111
-rw-r--r--Examples/python/import_template/spam.h24
-rw-r--r--Examples/python/import_template/spam.i10
-rw-r--r--Examples/python/index.html6
-rw-r--r--Examples/python/libffi/Makefile19
-rw-r--r--Examples/python/libffi/example.i176
-rw-r--r--Examples/python/mpointer/.cvsignore10
-rw-r--r--Examples/python/mpointer/Makefile21
-rw-r--r--Examples/python/mpointer/example.cxx45
-rw-r--r--Examples/python/mpointer/example.h50
-rw-r--r--Examples/python/mpointer/example.i16
-rw-r--r--Examples/python/mpointer/runme.py51
-rw-r--r--Examples/python/multimap/.cvsignore9
-rw-r--r--Examples/python/multimap/Makefile19
-rw-r--r--Examples/python/multimap/example.c53
-rw-r--r--Examples/python/multimap/example.dsp148
-rw-r--r--Examples/python/multimap/example.i83
-rw-r--r--Examples/python/multimap/runme.py27
-rw-r--r--Examples/python/operator/.cvsignore10
-rw-r--r--Examples/python/operator/Makefile21
-rw-r--r--Examples/python/operator/example.h36
-rw-r--r--Examples/python/operator/example.i28
-rw-r--r--Examples/python/operator/runme.py21
-rw-r--r--Examples/python/overload_feature/.cvsignore2
-rw-r--r--Examples/python/pointer/.cvsignore9
-rw-r--r--Examples/python/pointer/Makefile3
-rw-r--r--Examples/python/pointer/example.i3
-rw-r--r--Examples/python/pointer/runme.py (renamed from Examples/python/pointer/example.py)16
-rw-r--r--Examples/python/reference/.cvsignore9
-rw-r--r--Examples/python/reference/Makefile3
-rw-r--r--Examples/python/reference/example.i4
-rw-r--r--Examples/python/reference/runme.py (renamed from Examples/python/reference/example.py)38
-rw-r--r--Examples/python/shadow/.cvsignore10
-rw-r--r--Examples/python/shadow/Makefile12
-rw-r--r--Examples/python/simple/.cvsignore9
-rw-r--r--Examples/python/simple/Makefile3
-rw-r--r--Examples/python/simple/example.dsp148
-rw-r--r--Examples/python/simple/runme.py (renamed from Examples/python/simple/example.py)0
-rw-r--r--Examples/python/smartptr/Makefile21
-rw-r--r--Examples/python/smartptr/example.cxx28
-rw-r--r--Examples/python/smartptr/example.h39
-rw-r--r--Examples/python/smartptr/example.i20
-rw-r--r--Examples/python/smartptr/runme.py55
-rw-r--r--Examples/python/smartptr/smartptr.h13
-rw-r--r--Examples/python/std_vector/.cvsignore10
-rw-r--r--Examples/python/std_vector/Makefile21
-rw-r--r--Examples/python/std_vector/example.h25
-rw-r--r--Examples/python/std_vector/example.i17
-rw-r--r--Examples/python/std_vector/runme.py36
-rw-r--r--Examples/python/template/.cvsignore10
-rw-r--r--Examples/python/template/Makefile21
-rw-r--r--Examples/python/template/example.h32
-rw-r--r--Examples/python/template/example.i17
-rw-r--r--Examples/python/template/runme.py34
-rw-r--r--Examples/python/value/.cvsignore9
-rw-r--r--Examples/python/value/Makefile3
-rw-r--r--Examples/python/varargs/Makefile19
-rw-r--r--Examples/python/varargs/example.i65
-rw-r--r--Examples/python/varargs/runme.py34
-rw-r--r--Examples/python/variables/.cvsignore9
-rw-r--r--Examples/python/variables/Makefile3
-rw-r--r--Examples/python/variables/example.i4
-rw-r--r--Examples/python/variables/index.html10
-rw-r--r--Examples/python/variables/runme.py (renamed from Examples/python/variables/example.py)0
-rw-r--r--Examples/ruby/check.list21
-rw-r--r--Examples/ruby/class/.cvsignore9
-rw-r--r--Examples/ruby/class/Makefile2
-rw-r--r--Examples/ruby/class/example.cxx10
-rw-r--r--Examples/ruby/class/example.dsp154
-rw-r--r--Examples/ruby/class/example.h14
-rw-r--r--Examples/ruby/class/index.html20
-rw-r--r--Examples/ruby/constants/.cvsignore9
-rw-r--r--Examples/ruby/constants/Makefile2
-rw-r--r--Examples/ruby/constants/example.i7
-rwxr-xr-x[-rw-r--r--]Examples/ruby/constants/runme.rb (renamed from Examples/ruby/constants/run.rb)0
-rw-r--r--Examples/ruby/enum/.cvsignore9
-rw-r--r--Examples/ruby/enum/Makefile2
-rw-r--r--Examples/ruby/funcptr/.cvsignore9
-rw-r--r--Examples/ruby/funcptr/Makefile2
-rw-r--r--Examples/ruby/funcptr/example.i6
-rw-r--r--Examples/ruby/funcptr2/.cvsignore9
-rw-r--r--Examples/ruby/funcptr2/Makefile18
-rw-r--r--Examples/ruby/funcptr2/example.c19
-rw-r--r--Examples/ruby/funcptr2/example.h7
-rw-r--r--Examples/ruby/funcptr2/example.i18
-rw-r--r--Examples/ruby/funcptr2/runme.rb18
-rw-r--r--Examples/ruby/functor/.cvsignore2
-rw-r--r--Examples/ruby/functor/Makefile18
-rw-r--r--Examples/ruby/functor/example.i26
-rw-r--r--Examples/ruby/functor/runme.rb17
-rw-r--r--Examples/ruby/hashargs/.cvsignore1
-rwxr-xr-xExamples/ruby/hashargs/Makefile20
-rwxr-xr-xExamples/ruby/hashargs/example.i36
-rwxr-xr-xExamples/ruby/hashargs/runme.rb26
-rw-r--r--Examples/ruby/import/.cvsignore4
-rw-r--r--Examples/ruby/import/Makefile20
-rw-r--r--Examples/ruby/import/README28
-rw-r--r--Examples/ruby/import/bar.h21
-rw-r--r--Examples/ruby/import/bar.i9
-rw-r--r--Examples/ruby/import/base.h16
-rw-r--r--Examples/ruby/import/base.i6
-rw-r--r--Examples/ruby/import/foo.h21
-rw-r--r--Examples/ruby/import/foo.i8
-rw-r--r--Examples/ruby/import/runme.rb90
-rw-r--r--Examples/ruby/import/spam.h24
-rw-r--r--Examples/ruby/import/spam.i9
-rw-r--r--Examples/ruby/import_template/.cvsignore4
-rw-r--r--Examples/ruby/import_template/Makefile20
-rw-r--r--Examples/ruby/import_template/README30
-rw-r--r--Examples/ruby/import_template/bar.h22
-rw-r--r--Examples/ruby/import_template/bar.i11
-rw-r--r--Examples/ruby/import_template/base.h18
-rw-r--r--Examples/ruby/import_template/base.i7
-rw-r--r--Examples/ruby/import_template/foo.h21
-rw-r--r--Examples/ruby/import_template/foo.i10
-rw-r--r--Examples/ruby/import_template/runme.rb92
-rw-r--r--Examples/ruby/import_template/spam.h24
-rw-r--r--Examples/ruby/import_template/spam.i10
-rw-r--r--Examples/ruby/index.html6
-rw-r--r--Examples/ruby/mpointer/.cvsignore2
-rw-r--r--Examples/ruby/mpointer/Makefile20
-rw-r--r--Examples/ruby/mpointer/example.cxx45
-rw-r--r--Examples/ruby/mpointer/example.h47
-rw-r--r--Examples/ruby/mpointer/example.i15
-rw-r--r--Examples/ruby/mpointer/runme.rb48
-rw-r--r--Examples/ruby/multimap/.cvsignore2
-rw-r--r--Examples/ruby/multimap/Makefile18
-rw-r--r--Examples/ruby/multimap/example.c53
-rw-r--r--Examples/ruby/multimap/example.dsp150
-rw-r--r--Examples/ruby/multimap/example.i83
-rwxr-xr-xExamples/ruby/multimap/runme.rb22
-rw-r--r--Examples/ruby/operator/.cvsignore2
-rw-r--r--Examples/ruby/operator/Makefile20
-rw-r--r--Examples/ruby/operator/example.h36
-rw-r--r--Examples/ruby/operator/example.i23
-rw-r--r--Examples/ruby/operator/runme.rb25
-rw-r--r--Examples/ruby/overloading/.cvsignore1
-rw-r--r--Examples/ruby/overloading/Makefile19
-rw-r--r--Examples/ruby/overloading/example.cxx125
-rw-r--r--Examples/ruby/overloading/example.h41
-rw-r--r--Examples/ruby/overloading/example.i24
-rw-r--r--Examples/ruby/overloading/runme.rb88
-rw-r--r--Examples/ruby/pointer/.cvsignore9
-rw-r--r--Examples/ruby/pointer/Makefile2
-rw-r--r--Examples/ruby/pointer/example.i3
-rw-r--r--Examples/ruby/pointer/runme.rb17
-rw-r--r--Examples/ruby/reference/.cvsignore9
-rw-r--r--Examples/ruby/reference/Makefile2
-rw-r--r--Examples/ruby/reference/example.i2
-rw-r--r--Examples/ruby/simple/.cvsignore9
-rw-r--r--Examples/ruby/simple/Makefile2
-rw-r--r--Examples/ruby/simple/example.dsp150
-rwxr-xr-x[-rw-r--r--]Examples/ruby/simple/runme.rb (renamed from Examples/ruby/simple/run.rb)0
-rw-r--r--Examples/ruby/std_vector/.cvsignore1
-rw-r--r--Examples/ruby/std_vector/Makefile20
-rw-r--r--Examples/ruby/std_vector/example.h25
-rw-r--r--Examples/ruby/std_vector/example.i17
-rw-r--r--Examples/ruby/std_vector/runme.rb36
-rw-r--r--Examples/ruby/template/.cvsignore9
-rw-r--r--Examples/ruby/template/Makefile20
-rw-r--r--Examples/ruby/template/example.h32
-rw-r--r--Examples/ruby/template/example.i17
-rw-r--r--Examples/ruby/template/runme.rb25
-rw-r--r--Examples/ruby/value/.cvsignore9
-rw-r--r--Examples/ruby/value/Makefile2
-rw-r--r--Examples/ruby/variables/.cvsignore9
-rw-r--r--Examples/ruby/variables/Makefile2
-rw-r--r--Examples/ruby/variables/example.i4
-rw-r--r--Examples/ruby/variables/index.html10
-rw-r--r--Examples/ruby/variables/runme.rb38
-rw-r--r--Examples/s-exp/uffi.lisp349
-rw-r--r--Examples/tcl/check.list13
-rw-r--r--Examples/tcl/class/.cvsignore9
-rw-r--r--Examples/tcl/class/Makefile2
-rw-r--r--Examples/tcl/class/example.cxx10
-rw-r--r--Examples/tcl/class/example.dsp152
-rw-r--r--Examples/tcl/class/example.h12
-rw-r--r--Examples/tcl/class/example1.tcl7
-rw-r--r--Examples/tcl/class/example2.tcl2
-rw-r--r--Examples/tcl/class/index.html29
-rw-r--r--Examples/tcl/constants/.cvsignore9
-rw-r--r--Examples/tcl/constants/Makefile2
-rw-r--r--Examples/tcl/constants/example.i7
-rw-r--r--Examples/tcl/enum/.cvsignore9
-rw-r--r--Examples/tcl/enum/Makefile2
-rw-r--r--Examples/tcl/funcptr/.cvsignore9
-rw-r--r--Examples/tcl/funcptr/Makefile2
-rw-r--r--Examples/tcl/funcptr/example.c2
-rw-r--r--Examples/tcl/funcptr/example.i7
-rw-r--r--Examples/tcl/import/.cvsignore4
-rw-r--r--Examples/tcl/import/Makefile22
-rw-r--r--Examples/tcl/import/README28
-rw-r--r--Examples/tcl/import/bar.h22
-rw-r--r--Examples/tcl/import/bar.i9
-rw-r--r--Examples/tcl/import/base.h18
-rw-r--r--Examples/tcl/import/base.i6
-rw-r--r--Examples/tcl/import/foo.h21
-rw-r--r--Examples/tcl/import/foo.i8
-rw-r--r--Examples/tcl/import/runme.tcl121
-rw-r--r--Examples/tcl/import/spam.h24
-rw-r--r--Examples/tcl/import/spam.i9
-rw-r--r--Examples/tcl/index.html4
-rw-r--r--Examples/tcl/multimap/.cvsignore9
-rw-r--r--Examples/tcl/multimap/Makefile19
-rw-r--r--Examples/tcl/multimap/example.c53
-rw-r--r--Examples/tcl/multimap/example.dsp148
-rw-r--r--Examples/tcl/multimap/example.i68
-rw-r--r--Examples/tcl/multimap/example.tcl25
-rw-r--r--Examples/tcl/operator/.cvsignore9
-rw-r--r--Examples/tcl/operator/Makefile19
-rw-r--r--Examples/tcl/operator/example.h36
-rw-r--r--Examples/tcl/operator/example.i28
-rw-r--r--Examples/tcl/operator/runme.tcl31
-rw-r--r--Examples/tcl/pointer/.cvsignore9
-rw-r--r--Examples/tcl/pointer/Makefile2
-rw-r--r--Examples/tcl/pointer/example.i4
-rw-r--r--Examples/tcl/pointer/example.tcl17
-rw-r--r--Examples/tcl/reference/.cvsignore9
-rw-r--r--Examples/tcl/reference/Makefile2
-rw-r--r--Examples/tcl/reference/example.i2
-rw-r--r--Examples/tcl/simple/.cvsignore9
-rw-r--r--Examples/tcl/simple/Makefile2
-rw-r--r--Examples/tcl/simple/example.dsp148
-rw-r--r--Examples/tcl/value/.cvsignore9
-rw-r--r--Examples/tcl/value/Makefile2
-rw-r--r--Examples/tcl/variables/.cvsignore9
-rw-r--r--Examples/tcl/variables/Makefile2
-rw-r--r--Examples/tcl/variables/example.i8
-rw-r--r--Examples/tcl/variables/index.html10
-rw-r--r--Examples/test-suite/README42
-rw-r--r--Examples/test-suite/abstract_inherit.i20
-rw-r--r--Examples/test-suite/abstract_inherit_ok.i21
-rw-r--r--Examples/test-suite/abstract_signature.i25
-rw-r--r--Examples/test-suite/abstract_typedef.i52
-rw-r--r--Examples/test-suite/add_link.i20
-rw-r--r--Examples/test-suite/anonymous_arg.i12
-rw-r--r--Examples/test-suite/argout.i37
-rw-r--r--Examples/test-suite/arrayptr.i12
-rw-r--r--Examples/test-suite/arrays.i52
-rw-r--r--Examples/test-suite/arrays_global.i37
-rw-r--r--Examples/test-suite/arrays_global_twodim.i42
-rw-r--r--Examples/test-suite/arrays_scope.i19
-rw-r--r--Examples/test-suite/bool_default.i9
-rw-r--r--Examples/test-suite/casts.i21
-rw-r--r--Examples/test-suite/char_constant.i11
-rw-r--r--Examples/test-suite/class_ignore.i20
-rw-r--r--Examples/test-suite/common.mk291
-rw-r--r--Examples/test-suite/const_const.i13
-rw-r--r--Examples/test-suite/const_const_2.i21
-rw-r--r--Examples/test-suite/constant_pointers.i74
-rw-r--r--Examples/test-suite/constover.i38
-rw-r--r--Examples/test-suite/constructor_exception.i27
-rw-r--r--Examples/test-suite/constructor_explicit.i13
-rw-r--r--Examples/test-suite/constructor_value.i15
-rw-r--r--Examples/test-suite/conversion.i11
-rw-r--r--Examples/test-suite/conversion_namespace.i14
-rw-r--r--Examples/test-suite/conversion_ns_template.i49
-rw-r--r--Examples/test-suite/cplusplus_throw.i22
-rw-r--r--Examples/test-suite/cpp_enum.i27
-rw-r--r--Examples/test-suite/cpp_enum_scope.i17
-rw-r--r--Examples/test-suite/cpp_namespace.i104
-rw-r--r--Examples/test-suite/cpp_nodefault.i42
-rw-r--r--Examples/test-suite/cpp_static.i24
-rw-r--r--Examples/test-suite/cpp_typedef.i46
-rw-r--r--Examples/test-suite/default_cast.i6
-rw-r--r--Examples/test-suite/default_constructor.i109
-rw-r--r--Examples/test-suite/default_ns.i23
-rw-r--r--Examples/test-suite/default_ref.i12
-rw-r--r--Examples/test-suite/defineop.i22
-rw-r--r--Examples/test-suite/defines.i18
-rw-r--r--Examples/test-suite/dynamic_cast.i65
-rw-r--r--Examples/test-suite/enum.i26
-rw-r--r--Examples/test-suite/enum_scope.i16
-rw-r--r--Examples/test-suite/enum_scope_template.i20
-rw-r--r--Examples/test-suite/enum_var.i8
-rw-r--r--Examples/test-suite/errors/c_bad_name.i4
-rw-r--r--Examples/test-suite/errors/c_bad_native.i5
-rw-r--r--Examples/test-suite/errors/c_class.i8
-rw-r--r--Examples/test-suite/errors/c_default_error.i4
-rw-r--r--Examples/test-suite/errors/c_deprecated.i8
-rw-r--r--Examples/test-suite/errors/c_empty_char.i4
-rw-r--r--Examples/test-suite/errors/c_enum_badvalue.i7
-rw-r--r--Examples/test-suite/errors/c_extra_rblock.i8
-rw-r--r--Examples/test-suite/errors/c_extra_rbrace.i7
-rw-r--r--Examples/test-suite/errors/c_extra_unsigned.i6
-rw-r--r--Examples/test-suite/errors/c_insert_missing.i3
-rw-r--r--Examples/test-suite/errors/c_long_short.i6
-rw-r--r--Examples/test-suite/errors/c_missing_rbrace.i10
-rw-r--r--Examples/test-suite/errors/c_missing_semi.i4
-rw-r--r--Examples/test-suite/errors/c_redefine.i20
-rw-r--r--Examples/test-suite/errors/c_varargs.i3
-rw-r--r--Examples/test-suite/errors/c_varargs_neg.i7
-rw-r--r--Examples/test-suite/errors/cpp_bad_extern.i7
-rw-r--r--Examples/test-suite/errors/cpp_extend_redefine.i23
-rw-r--r--Examples/test-suite/errors/cpp_extend_undefined.i6
-rw-r--r--Examples/test-suite/errors/cpp_inline_namespace.i7
-rw-r--r--Examples/test-suite/errors/cpp_missing_rtemplate.i11
-rw-r--r--Examples/test-suite/errors/cpp_namespace_alias.i14
-rw-r--r--Examples/test-suite/errors/cpp_namespace_aliasnot.i4
-rw-r--r--Examples/test-suite/errors/cpp_namespace_aliasundef.i3
-rw-r--r--Examples/test-suite/errors/cpp_nested.i13
-rw-r--r--Examples/test-suite/errors/cpp_no_access.i4
-rw-r--r--Examples/test-suite/errors/cpp_nobase.i7
-rw-r--r--Examples/test-suite/errors/cpp_overload.i15
-rw-r--r--Examples/test-suite/errors/cpp_private_defvalue.i7
-rw-r--r--Examples/test-suite/errors/cpp_private_inherit.i11
-rw-r--r--Examples/test-suite/errors/cpp_template_argname.i8
-rw-r--r--Examples/test-suite/errors/cpp_template_nargs.i10
-rw-r--r--Examples/test-suite/errors/cpp_template_not.i9
-rw-r--r--Examples/test-suite/errors/cpp_template_partial.i4
-rw-r--r--Examples/test-suite/errors/cpp_template_repeat.i7
-rw-r--r--Examples/test-suite/errors/cpp_template_undef.i7
-rw-r--r--Examples/test-suite/errors/cpp_using_not.i9
-rw-r--r--Examples/test-suite/errors/cpp_using_undef.i9
-rwxr-xr-xExamples/test-suite/errors/make.sh103
-rw-r--r--Examples/test-suite/errors/nomodule.i2
-rw-r--r--Examples/test-suite/errors/pp_badeval.i11
-rw-r--r--Examples/test-suite/errors/pp_defined.i7
-rw-r--r--Examples/test-suite/errors/pp_macro_args.i7
-rw-r--r--Examples/test-suite/errors/pp_macro_badchar.i5
-rw-r--r--Examples/test-suite/errors/pp_macro_nargs.i16
-rw-r--r--Examples/test-suite/errors/pp_macro_redef.i8
-rw-r--r--Examples/test-suite/errors/pp_macro_rparen.i3
-rw-r--r--Examples/test-suite/errors/pp_macro_unterminated.i7
-rw-r--r--Examples/test-suite/errors/pp_misplaced_elif.i7
-rw-r--r--Examples/test-suite/errors/pp_misplaced_else.i7
-rw-r--r--Examples/test-suite/errors/pp_missing_enddef.i7
-rw-r--r--Examples/test-suite/errors/pp_missing_endif.i6
-rw-r--r--Examples/test-suite/errors/pp_missing_file.i3
-rw-r--r--Examples/test-suite/errors/pp_missing_rblock.i7
-rw-r--r--Examples/test-suite/errors/pp_unterm_char.i7
-rw-r--r--Examples/test-suite/errors/pp_unterm_comment.i6
-rw-r--r--Examples/test-suite/errors/pp_unterm_string.i6
-rw-r--r--Examples/test-suite/errors/swig_apply_nargs.i6
-rw-r--r--Examples/test-suite/errors/swig_identifier.i6
-rw-r--r--Examples/test-suite/errors/swig_insert_bad.i5
-rw-r--r--Examples/test-suite/errors/swig_typemap_copy.i3
-rw-r--r--Examples/test-suite/errors/swig_typemap_old.i6
-rw-r--r--Examples/test-suite/evil_diamond.i23
-rw-r--r--Examples/test-suite/evil_diamond_ns.i24
-rw-r--r--Examples/test-suite/evil_diamond_prop.i36
-rw-r--r--Examples/test-suite/explicit.i15
-rw-r--r--Examples/test-suite/extend_template.i26
-rw-r--r--Examples/test-suite/extend_template_ns.i32
-rw-r--r--Examples/test-suite/grouping.i31
-rw-r--r--Examples/test-suite/guile/.cvsignore2
-rw-r--r--Examples/test-suite/guile/Makefile44
-rw-r--r--Examples/test-suite/guile/README4
-rw-r--r--Examples/test-suite/guile/casts_runme.scm13
-rw-r--r--Examples/test-suite/guile/char_constant_runme.scm9
-rw-r--r--Examples/test-suite/guile/imports_runme.scm19
-rw-r--r--Examples/test-suite/guile/list_vector_runme.scm28
-rw-r--r--Examples/test-suite/guile/multivalue_runme.scm24
-rw-r--r--Examples/test-suite/guile/name_runme.scm10
-rw-r--r--Examples/test-suite/guile/overload_complicated_runme.scm18
-rw-r--r--Examples/test-suite/guile/overload_simple_runme.scm56
-rw-r--r--Examples/test-suite/guile/overload_subtype_runme.scm12
-rw-r--r--Examples/test-suite/guile/pointer_in_out_runme.scm18
-rw-r--r--Examples/test-suite/guile/unions_runme.scm41
-rw-r--r--Examples/test-suite/ignore_parameter.i42
-rw-r--r--Examples/test-suite/import_nomodule.h2
-rw-r--r--Examples/test-suite/import_nomodule.i24
-rw-r--r--Examples/test-suite/imports.list2
-rw-r--r--Examples/test-suite/imports_a.h7
-rw-r--r--Examples/test-suite/imports_a.i12
-rw-r--r--Examples/test-suite/imports_b.h11
-rw-r--r--Examples/test-suite/imports_b.i14
-rw-r--r--Examples/test-suite/inherit_missing.i43
-rw-r--r--Examples/test-suite/java/.cvsignore185
-rw-r--r--Examples/test-suite/java/Makefile72
-rw-r--r--Examples/test-suite/java/README6
-rw-r--r--Examples/test-suite/java/arrays_global_twodim_runme.java33
-rw-r--r--Examples/test-suite/java/cpp_typedef_runme.java30
-rw-r--r--Examples/test-suite/java/dynamic_cast_runme.java29
-rw-r--r--Examples/test-suite/java/ignore_parameter_runme.java36
-rw-r--r--Examples/test-suite/java/imports_runme.java24
-rw-r--r--Examples/test-suite/java/java_constants_runme.java29
-rw-r--r--Examples/test-suite/java/java_jnitypes_runme.java57
-rw-r--r--Examples/test-suite/java/java_lib_arrays_runme.java150
-rw-r--r--Examples/test-suite/java/java_pragmas_runme.java15
-rw-r--r--Examples/test-suite/java/java_throws_runme.java46
-rw-r--r--Examples/test-suite/java/java_typemaps_proxy_runme.java48
-rw-r--r--Examples/test-suite/java/java_typemaps_typewrapper_runme.java45
-rw-r--r--Examples/test-suite/java/lib_typemaps_runme.java85
-rw-r--r--Examples/test-suite/java/long_long_runme.java50
-rw-r--r--Examples/test-suite/java/primitive_ref_runme.java64
-rw-r--r--Examples/test-suite/java/ret_by_value_runme.java33
-rw-r--r--Examples/test-suite/java/template_classes_runme.java25
-rw-r--r--Examples/test-suite/java/unions_runme.java68
-rw-r--r--Examples/test-suite/java_constants.i30
-rw-r--r--Examples/test-suite/java_jnitypes.i29
-rw-r--r--Examples/test-suite/java_lib_arrays.i11
-rw-r--r--Examples/test-suite/java_pragmas.i48
-rw-r--r--Examples/test-suite/java_throws.i41
-rw-r--r--Examples/test-suite/java_typemaps_proxy.i53
-rw-r--r--Examples/test-suite/java_typemaps_typewrapper.i57
-rw-r--r--Examples/test-suite/kind.i34
-rw-r--r--Examples/test-suite/lib_carrays.i9
-rw-r--r--Examples/test-suite/lib_cdata.i8
-rw-r--r--Examples/test-suite/lib_cmalloc.i12
-rw-r--r--Examples/test-suite/lib_constraints.i32
-rw-r--r--Examples/test-suite/lib_cpointer.i10
-rw-r--r--Examples/test-suite/lib_cstring.i88
-rw-r--r--Examples/test-suite/lib_math.i2
-rw-r--r--Examples/test-suite/lib_std_deque.i47
-rw-r--r--Examples/test-suite/lib_std_string.i20
-rw-r--r--Examples/test-suite/lib_std_vector.i47
-rw-r--r--Examples/test-suite/lib_typemaps.i95
-rw-r--r--Examples/test-suite/list_vector.i153
-rw-r--r--Examples/test-suite/long_long.i40
-rw-r--r--Examples/test-suite/macro_2.i22
-rw-r--r--Examples/test-suite/member_template.i20
-rw-r--r--Examples/test-suite/memberin1.i63
-rw-r--r--Examples/test-suite/minherit.i80
-rw-r--r--Examples/test-suite/multivalue.i52
-rw-r--r--Examples/test-suite/mzscheme/.cvsignore1
-rw-r--r--Examples/test-suite/mzscheme/Makefile40
-rw-r--r--Examples/test-suite/mzscheme/README4
-rw-r--r--Examples/test-suite/mzscheme/casts_runme.scm7
-rw-r--r--Examples/test-suite/mzscheme/char_constant_runme.scm6
-rw-r--r--Examples/test-suite/mzscheme/import_runme.scm16
-rw-r--r--Examples/test-suite/mzscheme/name_runme.scm10
-rw-r--r--Examples/test-suite/mzscheme/unions_runme.scm38
-rw-r--r--Examples/test-suite/name.i26
-rw-r--r--Examples/test-suite/name_cxx.i16
-rw-r--r--Examples/test-suite/name_inherit.i13
-rw-r--r--Examples/test-suite/namespace_enum.i24
-rw-r--r--Examples/test-suite/namespace_extend.i34
-rw-r--r--Examples/test-suite/namespace_nested.i59
-rw-r--r--Examples/test-suite/namespace_template.i78
-rw-r--r--Examples/test-suite/namespace_typemap.i229
-rw-r--r--Examples/test-suite/nested.i34
-rw-r--r--Examples/test-suite/newobject1.i51
-rw-r--r--Examples/test-suite/newobject2.i38
-rw-r--r--Examples/test-suite/ocaml/Makefile64
-rw-r--r--Examples/test-suite/ocaml/README2
-rw-r--r--Examples/test-suite/ocaml/class_ignore_runme.ml6
-rwxr-xr-xExamples/test-suite/ocaml/makedebugtop21
-rw-r--r--Examples/test-suite/ocaml/newobject1_runme.ml25
-rw-r--r--Examples/test-suite/ocaml/overload_copy_runme.ml4
-rw-r--r--Examples/test-suite/ocaml/results180
-rw-r--r--Examples/test-suite/ocaml/sneaky1_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/throw_exception_runme.ml27
-rw-r--r--Examples/test-suite/ocaml/typename_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/unions_runme.ml27
-rw-r--r--Examples/test-suite/overload_complicated.i21
-rw-r--r--Examples/test-suite/overload_copy.i16
-rw-r--r--Examples/test-suite/overload_extend.i16
-rw-r--r--Examples/test-suite/overload_extendc.i16
-rw-r--r--Examples/test-suite/overload_simple.i92
-rw-r--r--Examples/test-suite/overload_subtype.i17
-rw-r--r--Examples/test-suite/overload_template.i19
-rw-r--r--Examples/test-suite/perl5/.cvsignore4
-rw-r--r--Examples/test-suite/perl5/Makefile42
-rw-r--r--Examples/test-suite/perl5/README4
-rw-r--r--Examples/test-suite/perl5/import_nomodule_runme.pl7
-rw-r--r--Examples/test-suite/perl5/imports_runme.pl5
-rw-r--r--Examples/test-suite/perl5/overload_copy_runme.pl5
-rw-r--r--Examples/test-suite/perl5/overload_simple_runme.pl120
-rw-r--r--Examples/test-suite/perl5/primitive_ref_runme.pl38
-rw-r--r--Examples/test-suite/perl5/unions_runme.pl54
-rw-r--r--Examples/test-suite/php4/Makefile67
-rw-r--r--Examples/test-suite/php4/abstract_inherit_ok_runme.php413
-rw-r--r--Examples/test-suite/php4/abstract_inherit_runme.php414
-rw-r--r--Examples/test-suite/php4/add_link_runme.php423
-rw-r--r--Examples/test-suite/php4/anonymous_arg_runme.php413
-rw-r--r--Examples/test-suite/php4/argout_runme.php437
-rw-r--r--Examples/test-suite/php4/arrayptr_runme.php415
-rw-r--r--Examples/test-suite/php4/arrays_global_runme.php416
-rw-r--r--Examples/test-suite/php4/arrays_global_twodim_runme.php425
-rw-r--r--Examples/test-suite/php4/arrays_runme.php422
-rw-r--r--Examples/test-suite/php4/arrays_scope_runme.php417
-rw-r--r--Examples/test-suite/php4/bool_default_runme.php420
-rw-r--r--Examples/test-suite/php4/casts_runme.php419
-rw-r--r--Examples/test-suite/php4/class_ignore_runme.php419
-rw-r--r--Examples/test-suite/php4/conversion_namespace_runme.php414
-rw-r--r--Examples/test-suite/php4/conversion_ns_template_runme.php410
-rw-r--r--Examples/test-suite/php4/conversion_runme.php414
-rw-r--r--Examples/test-suite/php4/cpp_static_runme.php415
-rw-r--r--Examples/test-suite/php4/enum_scope_runme.php417
-rw-r--r--Examples/test-suite/php4/enum_scope_template_runme.php417
-rw-r--r--Examples/test-suite/php4/evil_diamond_ns_runme.php419
-rw-r--r--Examples/test-suite/php4/evil_diamond_prop_runme.php438
-rw-r--r--Examples/test-suite/php4/evil_diamond_runme.php417
-rw-r--r--Examples/test-suite/php4/extend_template_ns_runme.php413
-rw-r--r--Examples/test-suite/php4/extend_template_runme.php413
-rw-r--r--Examples/test-suite/php4/grouping_runme.php424
-rw-r--r--Examples/test-suite/php4/ignore_parameter_runme.php439
-rw-r--r--Examples/test-suite/php4/lib_carrays_runme.php415
-rw-r--r--Examples/test-suite/php4/rename_scope_runme.php417
-rw-r--r--Examples/test-suite/php4/skel.php415
-rw-r--r--Examples/test-suite/php4/smart_pointer_rename_runme.php428
-rw-r--r--Examples/test-suite/php4/sym_runme.php423
-rw-r--r--Examples/test-suite/php4/template_arg_typename_runme.php419
-rw-r--r--Examples/test-suite/php4/template_construct_runme.php411
-rw-r--r--Examples/test-suite/php4/tests.php4217
-rw-r--r--Examples/test-suite/php4/typedef_reference_runme.php413
-rw-r--r--Examples/test-suite/php4/typemap_ns_using_runme.php49
-rw-r--r--Examples/test-suite/php4/using1_runme.php49
-rw-r--r--Examples/test-suite/php4/using2_runme.php49
-rw-r--r--Examples/test-suite/php4/valuewrapper_base_runme.php414
-rw-r--r--Examples/test-suite/pike/Makefile44
-rw-r--r--Examples/test-suite/pointer_in_out.i35
-rw-r--r--Examples/test-suite/pointer_reference.i17
-rw-r--r--Examples/test-suite/preproc_1.i10
-rw-r--r--Examples/test-suite/preproc_2.i22
-rw-r--r--Examples/test-suite/preproc_3.i6
-rw-r--r--Examples/test-suite/primitive_ref.i26
-rw-r--r--Examples/test-suite/private_assign.i21
-rw-r--r--Examples/test-suite/pure_virtual.i74
-rw-r--r--Examples/test-suite/python/.cvsignore5
-rw-r--r--Examples/test-suite/python/Makefile44
-rw-r--r--Examples/test-suite/python/README4
-rw-r--r--Examples/test-suite/python/abstract_typedef_runme.py11
-rw-r--r--Examples/test-suite/python/class_ignore_runme.py6
-rw-r--r--Examples/test-suite/python/constover_runme.py38
-rw-r--r--Examples/test-suite/python/cpp_namespace_runme.py45
-rw-r--r--Examples/test-suite/python/default_constructor_runme.py96
-rw-r--r--Examples/test-suite/python/dynamic_cast_runme.py12
-rw-r--r--Examples/test-suite/python/enum_runme.py7
-rw-r--r--Examples/test-suite/python/extend_template_ns_runme.py7
-rw-r--r--Examples/test-suite/python/extend_template_runme.py8
-rw-r--r--Examples/test-suite/python/grouping_runme.py13
-rw-r--r--Examples/test-suite/python/import_nomodule_runme.py7
-rw-r--r--Examples/test-suite/python/imports_runme.py9
-rw-r--r--Examples/test-suite/python/inherit_missing_runme.py17
-rw-r--r--Examples/test-suite/python/lib_std_vector_runme.py17
-rw-r--r--Examples/test-suite/python/minherit_runme.py71
-rw-r--r--Examples/test-suite/python/namespace_typemap_runme.py82
-rw-r--r--Examples/test-suite/python/overload_copy_runme.py3
-rw-r--r--Examples/test-suite/python/overload_extend_runme.py11
-rw-r--r--Examples/test-suite/python/overload_extendc_runme.py11
-rw-r--r--Examples/test-suite/python/overload_simple_runme.py97
-rw-r--r--Examples/test-suite/python/overload_subtype_runme.py11
-rw-r--r--Examples/test-suite/python/overload_template_runme.py5
-rw-r--r--Examples/test-suite/python/primitive_ref_runme.py37
-rw-r--r--Examples/test-suite/python/rename_scope_runme.py10
-rw-r--r--Examples/test-suite/python/smart_pointer_multi_runme.py15
-rw-r--r--Examples/test-suite/python/smart_pointer_multi_typedef_runme.py15
-rw-r--r--Examples/test-suite/python/smart_pointer_not_runme.py42
-rw-r--r--Examples/test-suite/python/smart_pointer_overload_runme.py21
-rw-r--r--Examples/test-suite/python/smart_pointer_rename_runme.py13
-rw-r--r--Examples/test-suite/python/smart_pointer_simple_runme.py13
-rw-r--r--Examples/test-suite/python/smart_pointer_typedef_runme.py13
-rw-r--r--Examples/test-suite/python/sneaky1_runme.py5
-rw-r--r--Examples/test-suite/python/static_const_member_2_runme.py15
-rw-r--r--Examples/test-suite/python/struct_value_runme.py9
-rw-r--r--Examples/test-suite/python/template_construct_runme.py1
-rw-r--r--Examples/test-suite/python/template_inherit_runme.py53
-rw-r--r--Examples/test-suite/python/template_ns4_runme.py5
-rw-r--r--Examples/test-suite/python/template_ns_runme.py17
-rw-r--r--Examples/test-suite/python/template_rename_runme.py12
-rw-r--r--Examples/test-suite/python/template_tbase_template_runme.py5
-rw-r--r--Examples/test-suite/python/template_type_namespace_runme.py5
-rw-r--r--Examples/test-suite/python/template_typedef_cplx2_runme.py95
-rw-r--r--Examples/test-suite/python/template_typedef_cplx3_runme.py34
-rw-r--r--Examples/test-suite/python/template_typedef_cplx4_runme.py34
-rw-r--r--Examples/test-suite/python/template_typedef_cplx_runme.py88
-rw-r--r--Examples/test-suite/python/template_typedef_import_runme.py35
-rw-r--r--Examples/test-suite/python/template_typedef_runme.py33
-rw-r--r--Examples/test-suite/python/typedef_inherit_runme.py23
-rw-r--r--Examples/test-suite/python/typedef_scope_runme.py12
-rw-r--r--Examples/test-suite/python/typemap_namespace_runme.py8
-rw-r--r--Examples/test-suite/python/typemap_ns_using_runme.py4
-rw-r--r--Examples/test-suite/python/typename_runme.py12
-rw-r--r--Examples/test-suite/python/unions_runme.py51
-rw-r--r--Examples/test-suite/python/using1_runme.py4
-rw-r--r--Examples/test-suite/python/using2_runme.py4
-rw-r--r--Examples/test-suite/python/using_composition_runme.py11
-rw-r--r--Examples/test-suite/python/using_extend_runme.py17
-rw-r--r--Examples/test-suite/python/using_inherit_runme.py8
-rw-r--r--Examples/test-suite/python/using_private_runme.py7
-rw-r--r--Examples/test-suite/python/using_protected_runme.py7
-rw-r--r--Examples/test-suite/python/voidtest_runme.py7
-rw-r--r--Examples/test-suite/rename_default.i27
-rw-r--r--Examples/test-suite/rename_scope.i49
-rw-r--r--Examples/test-suite/ret_by_value.i19
-rw-r--r--Examples/test-suite/return_value_scope.i28
-rw-r--r--Examples/test-suite/rname.i48
-rw-r--r--Examples/test-suite/ruby/.cvsignore3
-rw-r--r--Examples/test-suite/ruby/Makefile41
-rw-r--r--Examples/test-suite/ruby/README4
-rwxr-xr-xExamples/test-suite/ruby/class_ignore_runme.rb10
-rwxr-xr-xExamples/test-suite/ruby/constover_runme.rb44
-rwxr-xr-xExamples/test-suite/ruby/cpp_namespace_runme.rb51
-rwxr-xr-xExamples/test-suite/ruby/default_constructor_runme.rb94
-rwxr-xr-xExamples/test-suite/ruby/dynamic_cast_runme.rb13
-rwxr-xr-xExamples/test-suite/ruby/enum_runme.rb6
-rw-r--r--Examples/test-suite/ruby/extend_template_ns_runme.rb12
-rw-r--r--Examples/test-suite/ruby/extend_template_runme.rb10
-rw-r--r--Examples/test-suite/ruby/grouping_runme.rb15
-rwxr-xr-xExamples/test-suite/ruby/imports_runme.rb9
-rw-r--r--Examples/test-suite/ruby/inherit_missing_runme.rb20
-rwxr-xr-xExamples/test-suite/ruby/lib_std_vector_runme.rb17
-rwxr-xr-xExamples/test-suite/ruby/namespace_typemap_runme.rb33
-rw-r--r--Examples/test-suite/ruby/newobject1_runme.rb15
-rw-r--r--Examples/test-suite/ruby/newobject2_runme.rb15
-rwxr-xr-xExamples/test-suite/ruby/overload_copy_runme.rb6
-rwxr-xr-xExamples/test-suite/ruby/overload_extend_runme.rb8
-rwxr-xr-xExamples/test-suite/ruby/overload_extendc_runme.rb7
-rwxr-xr-xExamples/test-suite/ruby/overload_simple_runme.rb119
-rw-r--r--Examples/test-suite/ruby/overload_subtype_runme.rb15
-rwxr-xr-xExamples/test-suite/ruby/overload_template_runme.rb6
-rwxr-xr-xExamples/test-suite/ruby/primitive_ref_runme.rb27
-rw-r--r--Examples/test-suite/ruby/rename_scope_runme.rb10
-rw-r--r--Examples/test-suite/ruby/smart_pointer_const_runme.rb13
-rw-r--r--Examples/test-suite/ruby/smart_pointer_multi_runme.rb15
-rw-r--r--Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb14
-rw-r--r--Examples/test-suite/ruby/smart_pointer_not_runme.rb44
-rw-r--r--Examples/test-suite/ruby/smart_pointer_overload_runme.rb16
-rw-r--r--Examples/test-suite/ruby/smart_pointer_rename_runme.rb12
-rw-r--r--Examples/test-suite/ruby/smart_pointer_simple_runme.rb13
-rw-r--r--Examples/test-suite/ruby/smart_pointer_typedef_runme.rb13
-rwxr-xr-xExamples/test-suite/ruby/sneaky1_runme.rb6
-rwxr-xr-xExamples/test-suite/ruby/template_inherit_runme.rb40
-rwxr-xr-xExamples/test-suite/ruby/template_ns4_runme.rb4
-rwxr-xr-xExamples/test-suite/ruby/template_ns_runme.rb15
-rwxr-xr-xExamples/test-suite/ruby/template_rename_runme.rb12
-rwxr-xr-xExamples/test-suite/ruby/typedef_inherit_runme.rb27
-rwxr-xr-xExamples/test-suite/ruby/typedef_scope_runme.rb13
-rwxr-xr-xExamples/test-suite/ruby/typemap_namespace_runme.rb7
-rwxr-xr-xExamples/test-suite/ruby/typename_runme.rb14
-rw-r--r--Examples/test-suite/ruby/unions_runme.rb54
-rw-r--r--Examples/test-suite/sizeof_pointer.i19
-rw-r--r--Examples/test-suite/smart_pointer_const.i19
-rw-r--r--Examples/test-suite/smart_pointer_multi.i39
-rw-r--r--Examples/test-suite/smart_pointer_multi_typedef.i45
-rw-r--r--Examples/test-suite/smart_pointer_not.i39
-rw-r--r--Examples/test-suite/smart_pointer_overload.i24
-rw-r--r--Examples/test-suite/smart_pointer_protected.i29
-rw-r--r--Examples/test-suite/smart_pointer_rename.i25
-rw-r--r--Examples/test-suite/smart_pointer_simple.i19
-rw-r--r--Examples/test-suite/smart_pointer_typedef.i21
-rw-r--r--Examples/test-suite/sneaky1.i29
-rw-r--r--Examples/test-suite/static_array_member.i12
-rw-r--r--Examples/test-suite/static_const_member.i17
-rw-r--r--Examples/test-suite/static_const_member_2.i53
-rw-r--r--Examples/test-suite/struct_value.i14
-rw-r--r--Examples/test-suite/sym.i24
-rw-r--r--Examples/test-suite/tcl/.cvsignore3
-rw-r--r--Examples/test-suite/tcl/Makefile41
-rw-r--r--Examples/test-suite/tcl/README4
-rw-r--r--Examples/test-suite/tcl/import_nomodule_runme.tcl10
-rw-r--r--Examples/test-suite/tcl/imports_runme.tcl26
-rw-r--r--Examples/test-suite/tcl/overload_copy_runme.tcl18
-rw-r--r--Examples/test-suite/tcl/overload_simple_runme.tcl172
-rw-r--r--Examples/test-suite/tcl/primitive_ref_runme.tcl25
-rw-r--r--Examples/test-suite/tcl/unions_runme.tcl69
-rw-r--r--Examples/test-suite/template.i46
-rw-r--r--Examples/test-suite/template_arg_scope.i16
-rw-r--r--Examples/test-suite/template_arg_typename.i26
-rw-r--r--Examples/test-suite/template_base_template.i35
-rw-r--r--Examples/test-suite/template_classes.i30
-rw-r--r--Examples/test-suite/template_const_ref.i14
-rw-r--r--Examples/test-suite/template_construct.i15
-rw-r--r--Examples/test-suite/template_default.i10
-rw-r--r--Examples/test-suite/template_default2.i44
-rw-r--r--Examples/test-suite/template_default_arg.i34
-rw-r--r--Examples/test-suite/template_default_inherit.i25
-rw-r--r--Examples/test-suite/template_default_qualify.i56
-rw-r--r--Examples/test-suite/template_enum.i15
-rw-r--r--Examples/test-suite/template_enum_ns_inherit.i48
-rw-r--r--Examples/test-suite/template_enum_typedef.i39
-rw-r--r--Examples/test-suite/template_forward.i20
-rw-r--r--Examples/test-suite/template_inherit.i40
-rw-r--r--Examples/test-suite/template_inherit_abstract.i59
-rw-r--r--Examples/test-suite/template_int_const.i50
-rw-r--r--Examples/test-suite/template_ns.i35
-rw-r--r--Examples/test-suite/template_ns2.i16
-rw-r--r--Examples/test-suite/template_ns3.i21
-rw-r--r--Examples/test-suite/template_ns4.i66
-rw-r--r--Examples/test-suite/template_ns_enum.i18
-rw-r--r--Examples/test-suite/template_ns_enum2.i38
-rw-r--r--Examples/test-suite/template_ns_inherit.i30
-rw-r--r--Examples/test-suite/template_ns_scope.i38
-rw-r--r--Examples/test-suite/template_qualifier.i15
-rw-r--r--Examples/test-suite/template_rename.i24
-rw-r--r--Examples/test-suite/template_retvalue.i32
-rw-r--r--Examples/test-suite/template_specialization.i40
-rw-r--r--Examples/test-suite/template_static.i16
-rw-r--r--Examples/test-suite/template_tbase_template.i43
-rw-r--r--Examples/test-suite/template_type_namespace.i14
-rw-r--r--Examples/test-suite/template_typedef.i156
-rw-r--r--Examples/test-suite/template_typedef_cplx.i159
-rw-r--r--Examples/test-suite/template_typedef_cplx2.h156
-rw-r--r--Examples/test-suite/template_typedef_cplx2.i7
-rw-r--r--Examples/test-suite/template_typedef_cplx3.i37
-rw-r--r--Examples/test-suite/template_typedef_cplx4.i44
-rw-r--r--Examples/test-suite/template_typedef_import.i37
-rw-r--r--Examples/test-suite/template_typedef_import.list2
-rw-r--r--Examples/test-suite/template_virtual.i32
-rw-r--r--Examples/test-suite/template_whitespace.i22
-rw-r--r--Examples/test-suite/throw_exception.i29
-rw-r--r--Examples/test-suite/typedef_array_member.i10
-rw-r--r--Examples/test-suite/typedef_funcptr.i26
-rw-r--r--Examples/test-suite/typedef_inherit.i41
-rw-r--r--Examples/test-suite/typedef_mptr.i34
-rw-r--r--Examples/test-suite/typedef_reference.i10
-rw-r--r--Examples/test-suite/typedef_scope.i21
-rw-r--r--Examples/test-suite/typemap_namespace.i39
-rw-r--r--Examples/test-suite/typemap_ns_using.i21
-rw-r--r--Examples/test-suite/typemap_subst.i54
-rw-r--r--Examples/test-suite/typename.i34
-rw-r--r--Examples/test-suite/union_scope.i13
-rw-r--r--Examples/test-suite/unions.i35
-rw-r--r--Examples/test-suite/using1.i22
-rw-r--r--Examples/test-suite/using2.i22
-rw-r--r--Examples/test-suite/using_composition.i24
-rw-r--r--Examples/test-suite/using_extend.i37
-rw-r--r--Examples/test-suite/using_inherit.i17
-rw-r--r--Examples/test-suite/using_namespace.i56
-rw-r--r--Examples/test-suite/using_private.i17
-rw-r--r--Examples/test-suite/using_protected.i17
-rw-r--r--Examples/test-suite/valuewrapper_base.i28
-rw-r--r--Examples/test-suite/virtual_destructor.i16
-rw-r--r--Examples/test-suite/voidtest.i16
1180 files changed, 30149 insertions, 2629 deletions
diff --git a/Examples/GIFPlot/.cvsignore b/Examples/GIFPlot/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/Examples/GIFPlot/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/Examples/GIFPlot/Java/cmap b/Examples/GIFPlot/Common-Lisp/full/cmap
index a20c331a9..a20c331a9 100644
--- a/Examples/GIFPlot/Java/cmap
+++ b/Examples/GIFPlot/Common-Lisp/full/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Common-Lisp/full/gifplot.i b/Examples/GIFPlot/Common-Lisp/full/gifplot.i
new file mode 100644
index 000000000..e5c15aa2b
--- /dev/null
+++ b/Examples/GIFPlot/Common-Lisp/full/gifplot.i
@@ -0,0 +1,21 @@
+/* Oh what the heck, let's just grab the whole darn header file
+ and see what happens. */
+
+%module gifplot
+%{
+
+/* Note: You still need this part because the %include directive
+ merely causes SWIG to interpret the contents of a file. It doesn't
+ include the right include headers for the resulting C code */
+
+#include "gifplot.h"
+
+%}
+
+/* Pixel is typedef'd to unsigned char, and SWIG will translate this
+ type into Scheme characters. We would like to translate Pixels to
+ Scheme integers instead, so: */
+
+SIMPLE_MAP(Pixel, gh_scm2int, gh_int2scm, integer);
+
+%include gifplot.h
diff --git a/Examples/GIFPlot/Common-Lisp/full/runme.lisp b/Examples/GIFPlot/Common-Lisp/full/runme.lisp
new file mode 100644
index 000000000..48f804201
--- /dev/null
+++ b/Examples/GIFPlot/Common-Lisp/full/runme.lisp
@@ -0,0 +1,59 @@
+;;; Plot a 3D function
+
+;; Here is the function to plot
+(defun func (x y)
+ (* 5
+ (cos (* 2 (sqrt (+ (* x x) (* y y)))))
+ (exp (* -0.3 (sqrt (+ (* x x) (* y y)))))))
+
+;; Here are some plotting parameters
+(defvar xmin -5D0)
+(defvar xmax 5D0)
+(defvar ymin -5D0)
+(defvar ymax 5D0)
+(defvar zmin -5D0)
+(defvar zmax 5D0)
+
+;; Grid resolution
+(defvar nxpoints 60)
+(defvar nypoints 60)
+
+(defun drawsolid (p3)
+ (Plot3D-clear p3 0)
+ (Plot3D-start p3)
+ (let ((dx (/ (- xmax xmin) nxpoints))
+ (dy (/ (- ymax ymin) nypoints))
+ (cscale (/ 240 (- zmax zmin))))
+ (loop for x from xmin by dx
+ repeat nxpoints
+ do (loop for y from ymin by dy
+ repeat nypoints
+ do (let* ((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)))
+ (cc (/ (+ c1 c2 c3 c4) 4))
+ (c (round (max (min cc 239) 0))))
+ (Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy)
+ z3 x (+ y dy) z4 (+ c 16)))))))
+
+(defun action (cmap-filename)
+ (let ((cmap (new-ColorMap cmap-filename))
+ (frame (new-FrameBuffer 500 500)))
+ (format t "Making a nice 3D plot...~%")
+ (FrameBuffer-clear frame 0)
+ (let ((p3 (new-Plot3D frame xmin ymin zmin xmax ymax zmax)))
+ (Plot3D-lookat p3 (* 2 (- zmax zmin)))
+ (Plot3D-autoperspective p3 40D0)
+ (Plot3D-rotu p3 60D0)
+ (Plot3D-rotr p3 30D0)
+ (Plot3D-rotd p3 10D0)
+ (drawsolid p3))
+ (FrameBuffer-writeGIF frame cmap "/tmp/image.gif")
+ (format t "Wrote image.gif~%")))
+
+
diff --git a/Examples/GIFPlot/Guile/check.list b/Examples/GIFPlot/Guile/check.list
new file mode 100644
index 000000000..e75ee586a
--- /dev/null
+++ b/Examples/GIFPlot/Guile/check.list
@@ -0,0 +1,3 @@
+# see top-level Makefile.in
+full
+simple
diff --git a/Examples/GIFPlot/Guile/full/.cvsignore b/Examples/GIFPlot/Guile/full/.cvsignore
new file mode 100644
index 000000000..7b4d35ff7
--- /dev/null
+++ b/Examples/GIFPlot/Guile/full/.cvsignore
@@ -0,0 +1,3 @@
+gifplot-guile
+gifplot_wrap.c
+image.gif
diff --git a/Examples/GIFPlot/Guile/full/Makefile b/Examples/GIFPlot/Guile/full/Makefile
index 608e394da..1fcdf58d2 100644
--- a/Examples/GIFPlot/Guile/full/Makefile
+++ b/Examples/GIFPlot/Guile/full/Makefile
@@ -5,23 +5,24 @@ SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot -lm
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all:: static
dynamic::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
static::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
clean::
- rm -f *_wrap* *.o *~ *.so gifguile .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Guile/simple/.cvsignore b/Examples/GIFPlot/Guile/simple/.cvsignore
new file mode 100644
index 000000000..46c5ec496
--- /dev/null
+++ b/Examples/GIFPlot/Guile/simple/.cvsignore
@@ -0,0 +1,4 @@
+gifguile
+image.gif
+simple-guile
+simple_wrap.c
diff --git a/Examples/GIFPlot/Guile/simple/Makefile b/Examples/GIFPlot/Guile/simple/Makefile
index f3397cf22..7986214a0 100644
--- a/Examples/GIFPlot/Guile/simple/Makefile
+++ b/Examples/GIFPlot/Guile/simple/Makefile
@@ -5,23 +5,24 @@ SRCS =
TARGET = simple
INTERFACE = simple.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all:: static
dynamic::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
static::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
clean::
- rm -f *_wrap* *.o *~ *.so gifguile .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Include/gifplot.h b/Examples/GIFPlot/Include/gifplot.h
index f0fb3b183..921a5b63b 100644
--- a/Examples/GIFPlot/Include/gifplot.h
+++ b/Examples/GIFPlot/Include/gifplot.h
@@ -18,6 +18,10 @@
#ifndef GIFPLOT_H
+#ifdef SWIG
+%pragma no_default
+#endif
+
/* Pixel is 8-bits */
typedef unsigned char Pixel;
@@ -125,9 +129,9 @@ 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 TRANSPARENT 0
-#define FOREGROUND 1
-#define BACKGROUND 2
+#define GIFPLOT_TRANSPARENT 0
+#define GIFPLOT_FOREGROUND 1
+#define GIFPLOT_BACKGROUND 2
/* ------------------------------------------------------------------------
Plot2D
diff --git a/Examples/GIFPlot/Interface/gifplot.i b/Examples/GIFPlot/Interface/gifplot.i
index 69a7cdbb9..57784f35f 100644
--- a/Examples/GIFPlot/Interface/gifplot.i
+++ b/Examples/GIFPlot/Interface/gifplot.i
@@ -11,8 +11,6 @@
typedef unsigned char Pixel;
typedef float Zvalue;
-%disabledoc
-
/* ------------------------------------------------------------------------
ColorMap
@@ -23,14 +21,14 @@ typedef struct ColorMap {
char *name;
//
-// %addmethods adds some C methods to this structure to make it
+// %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...
- %addmethods {
+ %extend {
ColorMap(char *filename);
~ColorMap();
-#ifdef SWIGJAVA
+#if defined(SWIGJAVA ) || defined(SWIGPHP4)
%name(make_default) void default();
#else
void default();
@@ -44,16 +42,6 @@ typedef struct ColorMap {
/* Some default colors */
-#ifdef SWIGJAVA
-const Pixel BLACK = 0;
-const Pixel WHITE = 1;
-const Pixel RED = 2;
-const Pixel GREEN = 3;
-const Pixel BLUE = 4;
-const Pixel YELLOW = 5;
-const Pixel CYAN = 6;
-const Pixel MAGENTA = 7;
-#else
#define BLACK 0
#define WHITE 1
#define RED 2
@@ -62,7 +50,6 @@ const Pixel MAGENTA = 7;
#define YELLOW 5
#define CYAN 6
#define MAGENTA 7
-#endif
/*-------------------------------------------------------------------------
FrameBuffer
@@ -77,7 +64,7 @@ typedef struct FrameBuffer {
int ymin;
int xmax;
int ymax;
- %addmethods {
+ %extend {
FrameBuffer(unsigned int width, unsigned int height);
~FrameBuffer();
void resize(int width, int height);
@@ -119,9 +106,9 @@ 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 TRANSPARENT 0
-#define FOREGROUND 1
-#define BACKGROUND 2
+#define GIFPLOT_TRANSPARENT 0
+#define GIFPLOT_FOREGROUND 1
+#define GIFPLOT_BACKGROUND 2
/* --------------------------------------------------------------------------
Plot2D
@@ -141,7 +128,7 @@ typedef struct Plot2D {
double ymax;
int xscale; /* Type of scaling (LINEAR, LOG, etc..) */
int yscale;
- %addmethods {
+ %extend {
Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax);
~Plot2D();
Plot2D *copy();
@@ -203,7 +190,7 @@ typedef struct Plot3D {
double lookatz; /* Where is the z-lookat point */
double xshift; /* Used for translation and stuff */
double yshift;
- %addmethods {
+ %extend {
Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
~Plot3D();
Plot3D *copy();
@@ -264,13 +251,11 @@ typedef struct Plot3D {
/* 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;
+%constant PixMap * SQUARE = &PixMap_SQUARE;
+%constant PixMap * TRIANGLE = &PixMap_TRIANGLE;
+%constant PixMap * CROSS = &PixMap_CROSS;
#endif
-%enabledoc
-
diff --git a/Examples/GIFPlot/Java/Makefile b/Examples/GIFPlot/Java/Makefile
deleted file mode 100644
index 6017e1a77..000000000
--- a/Examples/GIFPlot/Java/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-TOP = ../..
-SWIG = $(TOP)/../swig -shadow
-SWIGOPT = -I../Include
-SRCS =
-TARGET = libjgifplot
-INTERFACE = gifplot.i
-LIBS = -L.. -lgifplot -lm
-INCLUDE = -I../Include
-
-all::
- $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-
-clean::
- rm -f *_wrap* *.o *~ *.so .~* core *.gif *.class ColorMap.java FrameBuffer.java Plot2D.java Plot3D.java gifplot.java
-
-check: all
diff --git a/Examples/GIFPlot/Java/README b/Examples/GIFPlot/Java/README
deleted file mode 100644
index 30058e52b..000000000
--- a/Examples/GIFPlot/Java/README
+++ /dev/null
@@ -1,30 +0,0 @@
-The gifplot example does not work straight out of the box,
-I had to change ../Interface/gifplot.i slightly for java.
-
-a)
-The colors (e.g. BLACK) where defined as:
-
- #define BLACK 0
-
-and the functions expect 'Pixel color' where Pixel is a unsigned char.
-#define constants contain no type information and are translated to integer
-constants. Because of that, you have to cast every Pixel to a byte in java.
-
-Changing the definition to:
- const Pixel BLACK = 0;
-fixes this.
-
-b)
-The definitions:
-
-const PixMap *SQUARE = &PixMap_SQUARE;
-const PixMap *TRIANGLE = &PixMap_TRIANGLE;
-const PixMap *CROSS = &PixMap_CROSS;
-
-don't work.
-The wrapper code expects actual variables SQUARE, etc. and they are not
-defined in gifplot.h.
-
-c)
-In shadow mode the method ColorMap::default() clashes with the reserved name
-default.
diff --git a/Examples/GIFPlot/Java/check.list b/Examples/GIFPlot/Java/check.list
new file mode 100644
index 000000000..13de977af
--- /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/cm15 b/Examples/GIFPlot/Java/cm15
deleted file mode 100644
index 7a8cd99b5..000000000
--- a/Examples/GIFPlot/Java/cm15
+++ /dev/null
Binary files differ
diff --git a/Examples/GIFPlot/Java/full/.cvsignore b/Examples/GIFPlot/Java/full/.cvsignore
new file mode 100644
index 000000000..2ef5d25c2
--- /dev/null
+++ b/Examples/GIFPlot/Java/full/.cvsignore
@@ -0,0 +1,7 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Java/full/Makefile b/Examples/GIFPlot/Java/full/Makefile
new file mode 100644
index 000000000..8f167237d
--- /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 000000000..f536864de
--- /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 'main.java' does something a little more
+interesting. After doing a make, run it using 'java main'. You'll have to go
+look at the header file to get a complete listing of the functions.
+
+Note the differences in the main.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 000000000..a20c331a9
--- /dev/null
+++ b/Examples/GIFPlot/Java/full/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Java/full/gifplot.i b/Examples/GIFPlot/Java/full/gifplot.i
new file mode 100644
index 000000000..5a7f5008f
--- /dev/null
+++ b/Examples/GIFPlot/Java/full/gifplot.i
@@ -0,0 +1,15 @@
+/* Oh what the heck, let's just grab the whole darn header file
+ and see what happens. */
+
+%module gifplot
+%{
+
+/* Note: You still need this part because the %include directive
+ merely causes SWIG to interpret the contents of a file. It doesn't
+ include the right include headers for the resulting C code */
+
+#include "gifplot.h"
+
+%}
+
+%include gifplot.h
diff --git a/Examples/GIFPlot/Java/full/main.java b/Examples/GIFPlot/Java/full/main.java
new file mode 100644
index 000000000..8fb65c86d
--- /dev/null
+++ b/Examples/GIFPlot/Java/full/main.java
@@ -0,0 +1,75 @@
+// Plot a 3D function
+import java.lang.Math;
+
+public class main {
+
+ static {
+ try {
+ System.loadLibrary("gifplot");
+ } 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[]) {
+
+ // Here are some plotting parameters
+ double xmin = -5.0;
+ double xmax = 5.0;
+ double ymin = -5.0;
+ double ymax = 5.0;
+ double zmin = -5.0;
+ double zmax = 5.0;
+
+ // Grid resolution
+ int nxpoints = 60;
+ int nypoints = 60;
+
+ SWIGTYPE_p_ColorMap cmap = gifplot.new_ColorMap("cmap");
+ SWIGTYPE_p_FrameBuffer frame = gifplot.new_FrameBuffer(500,500);
+ gifplot.FrameBuffer_clear(frame,(short)gifplot.BLACK);
+
+ SWIGTYPE_p_Plot3D p3 = gifplot.new_Plot3D(frame,xmin,ymin,zmin,xmax,ymax,zmax);
+ gifplot.Plot3D_lookat(p3,2*(zmax-zmin));
+ gifplot.Plot3D_autoperspective(p3,40);
+ gifplot.Plot3D_rotu(p3,60);
+ gifplot.Plot3D_rotr(p3,30);
+ gifplot.Plot3D_rotd(p3,10);
+
+ System.out.println( "Making a nice 3D plot..." );
+ gifplot.Plot3D_clear(p3,(short)gifplot.BLACK);
+ gifplot.Plot3D_start(p3);
+ double dx = 1.0*(xmax-xmin)/nxpoints;
+ double dy = 1.0*(ymax-ymin)/nypoints;
+ double cscale = 240.0/(zmax-zmin);
+ double x = xmin;
+ for (int i = 0; i < nxpoints; i++) {
+ double y = ymin;
+ for (int j = 0; j < nypoints; j++) {
+ double z1 = func(x,y);
+ double z2 = func(x+dx,y);
+ double z3 = func(x+dx,y+dy);
+ double z4 = func(x,y+dy);
+ double c1 = cscale*(z1-zmin);
+ double c2 = cscale*(z2-zmin);
+ double c3 = cscale*(z3-zmin);
+ double c4 = cscale*(z4-zmin);
+ double c = (c1+c2+c3+c4)/4;
+ if (c < 0) c = 0;
+ if (c > 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/gifplot.i b/Examples/GIFPlot/Java/gifplot.i
deleted file mode 100644
index b8f17f657..000000000
--- a/Examples/GIFPlot/Java/gifplot.i
+++ /dev/null
@@ -1,273 +0,0 @@
-//
-// Graphics module
-//
-%module gifplot
-%{
-#include "gifplot.h"
-%}
-
-/* Pixel is 8-bits */
-
-typedef unsigned char Pixel;
-typedef float Zvalue;
-
-%disabledoc
-
-/* ------------------------------------------------------------------------
- ColorMap
-
- Definition and methods for colormaps
- ------------------------------------------------------------------------ */
-
-typedef struct ColorMap {
- char *name;
-
-//
-// %addmethods 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...
-
- %addmethods {
- ColorMap(char *filename);
- ~ColorMap();
-#ifdef SWIGJAVA
- %name(make_default) void default();
-#else
- void default();
-#endif
- void assign(int index,int r, int g, int b);
- %name(__getitem__) int getitem(int index);
- %name(__setitem__) void setitem(int index, int value);
- int write(char *filename);
- }
-} ColorMap;
-
-/* Some default colors */
-
-#ifdef SWIGJAVA
-const Pixel BLACK = 0;
-const Pixel WHITE = 1;
-const Pixel RED = 2;
-const Pixel GREEN = 3;
-const Pixel BLUE = 4;
-const Pixel YELLOW = 5;
-const Pixel CYAN = 6;
-const Pixel MAGENTA = 7;
-#else
-#define BLACK 0
-#define WHITE 1
-#define RED 2
-#define GREEN 3
-#define BLUE 4
-#define YELLOW 5
-#define CYAN 6
-#define MAGENTA 7
-#endif
-
-/*-------------------------------------------------------------------------
- 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;
- %addmethods {
- 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 TRANSPARENT 0
-#define FOREGROUND 1
-#define 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;
- %addmethods {
- 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;
- %addmethods {
- 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
-const PixMap *SQUARE = &PixMap_SQUARE;
-const PixMap *TRIANGLE = &PixMap_TRIANGLE;
-const PixMap *CROSS = &PixMap_CROSS;
-#endif
-
-%enabledoc
-
-
-
-
diff --git a/Examples/GIFPlot/Java/ortho.java b/Examples/GIFPlot/Java/ortho.java
deleted file mode 100644
index 78d1d2cdd..000000000
--- a/Examples/GIFPlot/Java/ortho.java
+++ /dev/null
@@ -1,107 +0,0 @@
-import gifplot;
-
-public class ortho {
-
- static {
- System.loadLibrary("jgifplot");
- };
-
- public static double func(double x, double y) {
- double r;
- double f;
- r = Math.sqrt(x*x + y*y);
-
- f = (Math.sin(0.30*r*x)+Math.cos(0.30*r*y))/(1.0+r);
- return f;
- }
-
- public static void main(String argv[]) {
-
- FrameBuffer f;
- Plot3D p3;
- ColorMap cm;
-
- double x,y;
- double dx,dy;
- double z1,z2,z3,z4;
- int c1,c2,c3,c4;
-
- /* Create a framebuffer */
-
- f = new FrameBuffer(700,400);
-
- /* Load a colormap */
-
- cm = new ColorMap("cm15");
-
- /* Create a new 2D image */
-
- f.clear(gifplot.BLACK);
- p3 = new Plot3D(f,-6.3,-6.3,-1.5,6.3,6.3,1.5);
-
- /* Set viewing region in 2D plot */
-
- p3.setview(50,50,650,350);
-
- /* Set how far away from the image we are */
- p3.lookat(20);
-
- /* Set the field of view for the perspective */
-
-
-// Plot3D_autoperspective(p3,40);
-
- p3.autoortho();
-
- /* Now make a plot of a 3D function */
-
- /* Make a frame */
-
- f.noclip();
- f.box(49,49,650,350,gifplot.WHITE);
- p3.start(); /* Always call this prior to making an image */
- p3.clear(gifplot.BLACK);
- p3.rotu(60);
- p3.rotz(40);
- x = -6.3;
- dx = 0.25;
- while (x < 6.3) {
- y = -6.3;
- dy = 0.25;
- while (y < 6.3) {
- z1 = func(x,y);
- z2 = func(x+dx,y);
- z3 = func(x+dx,y+dy);
- z4 = func(x,y+dy);
- c1 = (int) ((z1 + 1.0)*120) + 16;
- if (c1 < 16) c1 = 16;
- if (c1 > 254) c1 = 254;
-
- c2 = (int) ((z2 + 1.0)*120) + 16;
- if (c2 < 16) c2 = 16;
- if (c2 > 254) c2 = 254;
-
- c3 = (int) ((z3 + 1.0)*120) + 16;
- if (c3 < 16) c3 = 16;
- if (c3 > 254) c3 = 254;
-
- c4 = (int) ((z4 + 1.0)*120) + 16;
- if (c4 < 16) c4 = 16;
- if (c4 > 254) c4= 254;
-
- p3.interpquad(x,y,z1,(byte) c1,
- x+dx,y,z2,(byte) c2,
- x+dx,y+dy,z3,(byte) c3,
- x,y+dy,z4,(byte) c4);
- y = y + dy;
- }
- x = x + dx;
- }
-
- /* Make a GIF file */
-
- f.writeGIF(cm,"plot.gif");
-
- System.out.println("Image written to 'plot.gif'");
- }
-}
diff --git a/Examples/GIFPlot/Java/shadow.java b/Examples/GIFPlot/Java/shadow.java
deleted file mode 100644
index 34e9bf6f9..000000000
--- a/Examples/GIFPlot/Java/shadow.java
+++ /dev/null
@@ -1,22 +0,0 @@
-import gifplot;
-
-public class shadow {
-
- static {
- System.loadLibrary("jgifplot");
- }
-
- public static void main(String argv[]) {
- FrameBuffer fb = new FrameBuffer(300, 300);
- ColorMap cm = new ColorMap("cmap");
-
- fb.clear(gifplot.BLACK);
- fb.drawstring(50, 50, gifplot.WHITE, gifplot.BLACK, "Hello world", gifplot.VERTICAL);
- fb.solidbox(200, 200, 220, 240, gifplot.BLUE);
- fb.line(0, 290, 293, 50, gifplot.RED);
- fb.circle(100, 100, 10, gifplot.YELLOW);
- fb.writeGIF(cm, "plot.gif");
-
- System.out.println("Image written to 'plot.gif'");
- }
-}
diff --git a/Examples/GIFPlot/Java/shadow/.cvsignore b/Examples/GIFPlot/Java/shadow/.cvsignore
new file mode 100644
index 000000000..2ef5d25c2
--- /dev/null
+++ b/Examples/GIFPlot/Java/shadow/.cvsignore
@@ -0,0 +1,7 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile
new file mode 100644
index 000000000..e513b9b5a
--- /dev/null
+++ b/Examples/GIFPlot/Java/shadow/Makefile
@@ -0,0 +1,20 @@
+TOP = ../../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -I../../Interface
+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/shadow/README b/Examples/GIFPlot/Java/shadow/README
new file mode 100644
index 000000000..4adbde306
--- /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 main, ie: 'java main'.
+
+Note the differences in the main.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 000000000..a20c331a9
--- /dev/null
+++ b/Examples/GIFPlot/Java/shadow/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Java/shadow/main.java b/Examples/GIFPlot/Java/shadow/main.java
new file mode 100644
index 000000000..fbcf6e792
--- /dev/null
+++ b/Examples/GIFPlot/Java/shadow/main.java
@@ -0,0 +1,76 @@
+// Plot a 3D function
+
+import java.lang.Math;
+
+public class main {
+
+ static {
+ try {
+ System.loadLibrary("gifplot");
+ } 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[]) {
+
+ // Here are some plotting parameters
+ double xmin = -5.0;
+ double xmax = 5.0;
+ double ymin = -5.0;
+ double ymax = 5.0;
+ double zmin = -5.0;
+ double zmax = 5.0;
+
+ // Grid resolution
+ int nxpoints = 60;
+ int nypoints = 60;
+
+ ColorMap cmap = new ColorMap("cmap");
+ FrameBuffer frame = new FrameBuffer(500,500);
+ frame.clear((short)gifplot.BLACK);
+
+ Plot3D 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);
+
+ System.out.println( "Making a nice 3D plot..." );
+ p3.clear((short)gifplot.BLACK);
+ p3.start();
+ double dx = 1.0*(xmax-xmin)/nxpoints;
+ double dy = 1.0*(ymax-ymin)/nypoints;
+ double cscale = 240.0/(zmax-zmin);
+ double x = xmin;
+ for (int i = 0; i < nxpoints; i++) {
+ double y = ymin;
+ for (int j = 0; j < nypoints; j++) {
+ double z1 = func(x,y);
+ double z2 = func(x+dx,y);
+ double z3 = func(x+dx,y+dy);
+ double z4 = func(x,y+dy);
+ double c1 = cscale*(z1-zmin);
+ double c2 = cscale*(z2-zmin);
+ double c3 = cscale*(z3-zmin);
+ double c4 = cscale*(z4-zmin);
+ double 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,(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.java b/Examples/GIFPlot/Java/simple.java
deleted file mode 100644
index b5a243206..000000000
--- a/Examples/GIFPlot/Java/simple.java
+++ /dev/null
@@ -1,22 +0,0 @@
-import gifplot;
-
-public class simple {
-
- static {
- System.loadLibrary("jgifplot");
- }
-
- public static void main(String argv[]) {
- long f = gifplot.new_FrameBuffer(300, 300);
- long c = gifplot.new_ColorMap("cmap");
-
- gifplot.FrameBuffer_clear(f, gifplot.BLACK);
- gifplot.FrameBuffer_drawstring(f, 50, 50, gifplot.WHITE, gifplot.BLACK, "Hello world", gifplot.HORIZONTAL);
- gifplot.FrameBuffer_solidbox(f, 200, 200, 220, 240, gifplot.BLUE);
- gifplot.FrameBuffer_line(f, 0, 290, 293, 50, gifplot.RED);
- gifplot.FrameBuffer_circle(f, 100, 100, 10, gifplot.YELLOW);
- gifplot.FrameBuffer_writeGIF(f, c, "plot.gif");
-
- System.out.println("Image written to 'plot.gif'");
- }
-}
diff --git a/Examples/GIFPlot/Java/simple/.cvsignore b/Examples/GIFPlot/Java/simple/.cvsignore
new file mode 100644
index 000000000..2ef5d25c2
--- /dev/null
+++ b/Examples/GIFPlot/Java/simple/.cvsignore
@@ -0,0 +1,7 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Java/simple/Makefile b/Examples/GIFPlot/Java/simple/Makefile
new file mode 100644
index 000000000..d707fd458
--- /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 000000000..1fb8453f0
--- /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 main'.
+
+
diff --git a/Examples/GIFPlot/Java/simple/main.java b/Examples/GIFPlot/Java/simple/main.java
new file mode 100644
index 000000000..b165a4baa
--- /dev/null
+++ b/Examples/GIFPlot/Java/simple/main.java
@@ -0,0 +1,41 @@
+
+public class main {
+
+ 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 000000000..457bc4c09
--- /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/LICENSE b/Examples/GIFPlot/LICENSE
deleted file mode 100644
index 95d776626..000000000
--- a/Examples/GIFPlot/LICENSE
+++ /dev/null
@@ -1,41 +0,0 @@
-
-/**********************************************************************
- * 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.
- *
- **************************************************************************/
diff --git a/Examples/GIFPlot/Lib/.cvsignore b/Examples/GIFPlot/Lib/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/Examples/GIFPlot/Lib/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/Examples/GIFPlot/Lib/Makefile.in b/Examples/GIFPlot/Lib/Makefile.in
index 46e85e9d4..1cc6c4ffe 100644
--- a/Examples/GIFPlot/Lib/Makefile.in
+++ b/Examples/GIFPlot/Lib/Makefile.in
@@ -1,14 +1,14 @@
CC = @CC@
-INCLUDE = -I../Include
+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=.o)
+OBJS = $(SRCS:.c=.@OBJEXT@)
AR = @AR@
RANLIB = @RANLIB@
TARGET = ../libgifplot.a
-.c.o:
- $(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
+.c.@OBJEXT@:
+ $(CC) $(INCLUDES) $(CFLAGS) -c -o $*.@OBJEXT@ $<
all: $(OBJS)
@rm -f ../libgifplot.a
@@ -16,6 +16,6 @@ all: $(OBJS)
$(RANLIB) $(TARGET)
clean:
- rm -f *.o *~ $(TARGET)
-
+ rm -f *.@OBJEXT@ *~ $(TARGET)
+check: all
diff --git a/Examples/GIFPlot/Lib/pixmap.c b/Examples/GIFPlot/Lib/pixmap.c
index ff8e0bff0..a55cf041f 100644
--- a/Examples/GIFPlot/Lib/pixmap.c
+++ b/Examples/GIFPlot/Lib/pixmap.c
@@ -99,10 +99,10 @@ FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, in
for (i = startx; i < endx; i++) {
c = pm->map[py*pm->width + px];
switch (c) {
- case FOREGROUND:
+ case GIFPLOT_FOREGROUND:
f->pixels[j][i] = fgcolor;
break;
- case BACKGROUND:
+ case GIFPLOT_BACKGROUND:
f->pixels[j][i] = bgcolor;
break;
default:
diff --git a/Examples/GIFPlot/Makefile.in b/Examples/GIFPlot/Makefile.in
index 292c93e21..74c1d8253 100644
--- a/Examples/GIFPlot/Makefile.in
+++ b/Examples/GIFPlot/Makefile.in
@@ -16,8 +16,8 @@ install:
$(RANLIB) $(exec_prefix)/lib/libgifplot.a
clean::
- rm -f *.o *~ libgifplot.a *_wrap* *_man*
+ 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 000000000..e75ee586a
--- /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 000000000..5b1e907f3
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/full/Makefile
@@ -0,0 +1,26 @@
+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
+
+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 000000000..4a2b400b5
--- /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 000000000..a20c331a9
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/full/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Ocaml/full/gifplot.i b/Examples/GIFPlot/Ocaml/full/gifplot.i
new file mode 100644
index 000000000..22f4df672
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/full/gifplot.i
@@ -0,0 +1,15 @@
+/* Oh what the heck, let's just grab the whole darn header file
+ and see what happens. */
+
+%module gifplot
+%{
+
+/* Note: You still need this part because the %include directive
+ merely causes SWIG to interpret the contents of a file. It doesn't
+ include the right include headers for the resulting C code */
+
+#include "gifplot.h"
+%}
+
+typedef int Pixel;
+%include gifplot.h
diff --git a/Examples/GIFPlot/Ocaml/full/runme.ml b/Examples/GIFPlot/Ocaml/full/runme.ml
new file mode 100644
index 000000000..7b9dc806f
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/full/runme.ml
@@ -0,0 +1,86 @@
+(* Plot a 3D Function *)
+
+(* Use the wrapped GIFPlot library *)
+open Gifplot
+open Int32
+
+(* Here is the function to plot *)
+let func x y =
+ 5.0 *.
+ (cos (2.0 *. (sqrt (x *. x) +. (y *. y)))) *.
+ (exp (-0.3 *. (sqrt (x *. x) +. (y *. y))))
+
+(* Here are some plotting parameters *)
+
+let xmin = -5.0
+let xmax = 5.0
+let ymin = -5.0
+let ymax = 5.0
+let zmin = -5.0
+let zmax = 5.0
+
+(* Grid resolution *)
+let nxpoints = 60
+let nypoints = 60
+
+let cmap = _new_ColorMap (C_string "cmap")
+let frame = _new_FrameBuffer (C_list [ C_int 500 ;
+ C_int 500 ])
+let _ = _FrameBuffer_clear (C_list [ frame ; _BLACK ])
+
+let p2 = _new_Plot3D (C_list [ frame ;
+ C_float xmin ; C_float ymin ; C_float zmin ;
+ C_float xmax ; C_float ymax ; C_float zmax ])
+let _ = _Plot3D_lookat (C_list [ p2 ; C_float (2.0 *. (zmax -. zmin)) ])
+let _ = _Plot3D_autoperspective (C_list [ p2 ; C_float 40.0 ])
+let _ = _Plot3D_rotu (C_list [ p2 ; C_float 60.0 ])
+let _ = _Plot3D_rotr (C_list [ p2 ; C_float 30.0 ])
+let _ = _Plot3D_rotd (C_list [ p2 ; C_float 10.0 ])
+
+let drawsolid () =
+ begin
+ _Plot3D_clear (C_list [ p2 ; _BLACK ]) ;
+ _Plot3D_start p2 ;
+ let dx = ((xmax -. xmin) /. (float_of_int nxpoints))
+ and dy = ((ymax -. ymin) /. (float_of_int nypoints))
+ and cscale = (240.0 /. (zmax -. zmin)) in
+ let rec x_loop x i =
+ if i < nxpoints then
+ begin
+ let rec y_loop y j =
+ begin
+ if j < nypoints then
+ let z1 = func x y
+ and z2 = func (x +. dx) y
+ and z3 = func (x +. dx) (y +. dy)
+ and z4 = func x (y +. dy) in
+ let c1 = cscale *. (z1 -. zmin)
+ and c2 = cscale *. (z2 -. zmin)
+ and c3 = cscale *. (z3 -. zmin)
+ and c4 = cscale *. (z4 -. zmin) in
+ let cc = (c1 +. c2 +. c3 +. c4) /. 4.0 in
+ let c = (max (min (int_of_float cc) 239) 0) in
+ _Plot3D_solidquad
+ (C_list (p2 ::
+ (List.map
+ (fun x -> 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 000000000..52d2a49a4
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/simple/Makefile
@@ -0,0 +1,26 @@
+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
+
+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 000000000..a20c331a9
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/simple/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Ocaml/simple/runme.ml b/Examples/GIFPlot/Ocaml/simple/runme.ml
new file mode 100644
index 000000000..b89f4f195
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/simple/runme.ml
@@ -0,0 +1,34 @@
+(* Draw some simple shapes *)
+
+(* Use the wrapped GIFPlot library *)
+open Simple
+open Int32
+
+let _ = print_endline "Drawing some basic shapes"
+
+let cmap = _new_ColorMap (C_string "cmap")
+let f = _new_FrameBuffer (C_list [ C_int 400 ; C_int 400 ])
+
+(* Clear the picture *)
+let _ = _FrameBuffer_clear (C_list [ f ; _BLACK ])
+
+(* Make a red box *)
+let _ = _FrameBuffer_box
+ (C_list [ f ; C_int 40 ; C_int 40 ; C_int 200 ; C_int 200 ; _RED ])
+
+(* Make a blue circle *)
+let _ = _FrameBuffer_circle
+ (C_list [ f ; C_int 200 ; C_int 200 ; C_int 40 ; _BLUE ])
+
+(* Make green line *)
+let _ = _FrameBuffer_line
+ (C_list [ f ; C_int 10 ; C_int 390 ; C_int 390 ; C_int 200 ; _GREEN ])
+
+(* Write an image out to disk *)
+
+let _ = _FrameBuffer_writeGIF (C_list [ f ; cmap ; C_string "image.gif" ])
+let _ = print_endline "Wrote image.gif"
+
+let _ = _delete_FrameBuffer f
+let _ = _delete_ColorMap cmap
+
diff --git a/Examples/GIFPlot/Ocaml/simple/simple.i b/Examples/GIFPlot/Ocaml/simple/simple.i
new file mode 100644
index 000000000..33297f491
--- /dev/null
+++ b/Examples/GIFPlot/Ocaml/simple/simple.i
@@ -0,0 +1,33 @@
+/* This example shows a very simple interface wrapping a few
+ primitive declarations */
+
+%module simple
+%{
+#include "gifplot.h"
+%}
+
+typedef 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 */
+
+#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/Perl/check.list b/Examples/GIFPlot/Perl/check.list
new file mode 100644
index 000000000..13de977af
--- /dev/null
+++ b/Examples/GIFPlot/Perl/check.list
@@ -0,0 +1,4 @@
+# see top-level Makefile.in
+full
+shadow
+simple
diff --git a/Examples/GIFPlot/Perl/full/.cvsignore b/Examples/GIFPlot/Perl/full/.cvsignore
new file mode 100644
index 000000000..5c954b6b3
--- /dev/null
+++ b/Examples/GIFPlot/Perl/full/.cvsignore
@@ -0,0 +1,5 @@
+gifplot.pm
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Perl/full/Makefile b/Examples/GIFPlot/Perl/full/Makefile
index e86b8ccfd..456819d10 100644
--- a/Examples/GIFPlot/Perl/full/Makefile
+++ b/Examples/GIFPlot/Perl/full/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot -lm
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o *~ *.so myperl *.pm .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Perl/shadow/.cvsignore b/Examples/GIFPlot/Perl/shadow/.cvsignore
new file mode 100644
index 000000000..5c954b6b3
--- /dev/null
+++ b/Examples/GIFPlot/Perl/shadow/.cvsignore
@@ -0,0 +1,5 @@
+gifplot.pm
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Perl/shadow/Makefile b/Examples/GIFPlot/Perl/shadow/Makefile
index 99d3f951a..568edb33f 100644
--- a/Examples/GIFPlot/Perl/shadow/Makefile
+++ b/Examples/GIFPlot/Perl/shadow/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot -lm
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o *~ *.so myperl *.pm .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Perl/simple/.cvsignore b/Examples/GIFPlot/Perl/simple/.cvsignore
new file mode 100644
index 000000000..ca1792db1
--- /dev/null
+++ b/Examples/GIFPlot/Perl/simple/.cvsignore
@@ -0,0 +1,5 @@
+simple.pm
+simple_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Perl/simple/Makefile b/Examples/GIFPlot/Perl/simple/Makefile
index 850795a56..36a8fa938 100644
--- a/Examples/GIFPlot/Perl/simple/Makefile
+++ b/Examples/GIFPlot/Perl/simple/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = simple
INTERFACE = simple.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o *~ *.so myperl *.pm .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Php/check.list b/Examples/GIFPlot/Php/check.list
new file mode 100644
index 000000000..e75ee586a
--- /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 000000000..880d05303
--- /dev/null
+++ b/Examples/GIFPlot/Php/full/Makefile
@@ -0,0 +1,19 @@
+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)' php4
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php4_clean
+ rm -f *.gif
+
+check: all
diff --git a/Examples/GIFPlot/Php/full/README b/Examples/GIFPlot/Php/full/README
new file mode 100644
index 000000000..f8d38d9af
--- /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 000000000..a20c331a9
--- /dev/null
+++ b/Examples/GIFPlot/Php/full/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Php/full/gifplot.i b/Examples/GIFPlot/Php/full/gifplot.i
new file mode 100644
index 000000000..5a7f5008f
--- /dev/null
+++ b/Examples/GIFPlot/Php/full/gifplot.i
@@ -0,0 +1,15 @@
+/* Oh what the heck, let's just grab the whole darn header file
+ and see what happens. */
+
+%module gifplot
+%{
+
+/* Note: You still need this part because the %include directive
+ merely causes SWIG to interpret the contents of a file. It doesn't
+ include the right include headers for the resulting C code */
+
+#include "gifplot.h"
+
+%}
+
+%include gifplot.h
diff --git a/Examples/GIFPlot/Php/full/runme.php4 b/Examples/GIFPlot/Php/full/runme.php4
new file mode 100644
index 000000000..de5371ee8
--- /dev/null
+++ b/Examples/GIFPlot/Php/full/runme.php4
@@ -0,0 +1,78 @@
+<?
+
+# Plot a 3D function
+require "gifplot.php";
+
+# Here is the function to plot
+function func($x, $y) {
+ return 5*cos(2*sqrt($x*$x+$y*$y))*exp(-0.3*sqrt($x*$x+$y*$y));
+}
+
+# Here are some plotting parameters
+$xmin = -5.0;
+$xmax = 5.0;
+$ymin = -5.0;
+$ymax = 5.0;
+$zmin = -5.0;
+$zmax = 5.0;
+
+# Grid resolution
+$nxpoints = 60;
+$nypoints = 60;
+
+$cmap = new_ColorMap("cmap");
+$frame = new_FrameBuffer(500,500);
+FrameBuffer_clear($frame, BLACK);
+
+$p3 = new_Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax);
+Plot3D_lookat($p3, 2*($zmax-$zmin));
+Plot3D_autoperspective($p3, 40);
+Plot3D_rotu($p3, 60);
+Plot3D_rotr($p3, 30);
+Plot3D_rotd($p3, 10);
+
+function drawsolid() {
+ global $p3;
+ global $xmax;
+ global $xmin;
+ global $ymax;
+ global $ymin;
+ global $zmin;
+ global $zmax;
+ global $nxpoints;
+ global $nypoints;
+
+ Plot3D_clear($p3, BLACK);
+ Plot3D_start($p3);
+ $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; }
+ 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 000000000..5627e53a0
--- /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)' php4
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php4_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 000000000..3e91f7d59
--- /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 000000000..a20c331a9
--- /dev/null
+++ b/Examples/GIFPlot/Php/shadow/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Php/shadow/runme.php4 b/Examples/GIFPlot/Php/shadow/runme.php4
new file mode 100644
index 000000000..3dffba050
--- /dev/null
+++ b/Examples/GIFPlot/Php/shadow/runme.php4
@@ -0,0 +1,79 @@
+<?
+
+# Plot a 3D function
+include("gifplot.php");
+
+# Here is the function to plot
+function func($x, $y) {
+ return 5*cos(2*sqrt($x*$x+$y*$y))*exp(-0.3*sqrt($x*$x+$y*$y));
+}
+
+# Here are some plotting parameters
+$xmin = -5.0;
+$xmax = 5.0;
+$ymin = -5.0;
+$ymax = 5.0;
+$zmin = -5.0;
+$zmax = 5.0;
+
+# Grid resolution
+$nxpoints = 60;
+$nypoints = 60;
+
+$cmap = new ColorMap("cmap");
+$frame = new FrameBuffer(500,500);
+$frame->clear(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 000000000..e49e22043
--- /dev/null
+++ b/Examples/GIFPlot/Php/simple/Makefile
@@ -0,0 +1,19 @@
+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)' php4
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php4_clean
+ rm -f *.gif
+
+check: all
diff --git a/Examples/GIFPlot/Php/simple/README b/Examples/GIFPlot/Php/simple/README
new file mode 100644
index 000000000..c2c799a70
--- /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.php4 b/Examples/GIFPlot/Php/simple/runme.php4
new file mode 100644
index 000000000..cf21a0927
--- /dev/null
+++ b/Examples/GIFPlot/Php/simple/runme.php4
@@ -0,0 +1,32 @@
+<?
+
+# Draw some simple shapes
+print "Drawing some basic shapes\n";
+
+require "simple.php";
+
+$cmap = new_ColorMap();
+$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");
+print "Wrote image.gif\n";
+
+delete_FrameBuffer($f);
+delete_ColorMap($cmap);
+
+?>
+
diff --git a/Examples/GIFPlot/Php/simple/simple.i b/Examples/GIFPlot/Php/simple/simple.i
new file mode 100644
index 000000000..457bc4c09
--- /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 000000000..d38998cab
--- /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/.cvsignore b/Examples/GIFPlot/Pike/simple/.cvsignore
new file mode 100644
index 000000000..0c4113eb0
--- /dev/null
+++ b/Examples/GIFPlot/Pike/simple/.cvsignore
@@ -0,0 +1,4 @@
+simple_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Pike/simple/Makefile b/Examples/GIFPlot/Pike/simple/Makefile
new file mode 100644
index 000000000..d339e0333
--- /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 000000000..177b3633b
--- /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 000000000..0e70235f1
--- /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 000000000..457bc4c09
--- /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 000000000..13de977af
--- /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/.cvsignore b/Examples/GIFPlot/Python/full/.cvsignore
new file mode 100644
index 000000000..c5d112b05
--- /dev/null
+++ b/Examples/GIFPlot/Python/full/.cvsignore
@@ -0,0 +1,4 @@
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile
index 361717c5c..ae927b72b 100644
--- a/Examples/GIFPlot/Python/full/Makefile
+++ b/Examples/GIFPlot/Python/full/Makefile
@@ -1,23 +1,25 @@
TOP = ../../..
SWIG = $(TOP)/../swig
-SWIGOPT = -I../../Include
+SWIGOPT = -I../../Include
SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Python/full/runme.py b/Examples/GIFPlot/Python/full/runme.py
index 1c73cec69..9f4ada602 100644
--- a/Examples/GIFPlot/Python/full/runme.py
+++ b/Examples/GIFPlot/Python/full/runme.py
@@ -1,5 +1,7 @@
# Plot a 3D function
-from gifplot import *
+# This example uses the low-level C interface.
+
+from _gifplot import *
from math import *
# Here is the function to plot
diff --git a/Examples/GIFPlot/Python/shadow/.cvsignore b/Examples/GIFPlot/Python/shadow/.cvsignore
new file mode 100644
index 000000000..7533bf0c4
--- /dev/null
+++ b/Examples/GIFPlot/Python/shadow/.cvsignore
@@ -0,0 +1,6 @@
+gifplot.py
+gifplot.pyc
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile
index 82097b7e9..1f5014895 100644
--- a/Examples/GIFPlot/Python/shadow/Makefile
+++ b/Examples/GIFPlot/Python/shadow/Makefile
@@ -1,23 +1,25 @@
TOP = ../../..
SWIG = $(TOP)/../swig
-SWIGOPT = -I../../Interface -shadow
+SWIGOPT = -I../../Interface
SRCS =
-TARGET = gifplotc
+TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Python/simple/.cvsignore b/Examples/GIFPlot/Python/simple/.cvsignore
new file mode 100644
index 000000000..0c4113eb0
--- /dev/null
+++ b/Examples/GIFPlot/Python/simple/.cvsignore
@@ -0,0 +1,4 @@
+simple_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile
index e9b708633..5eb0344e8 100644
--- a/Examples/GIFPlot/Python/simple/Makefile
+++ b/Examples/GIFPlot/Python/simple/Makefile
@@ -5,19 +5,21 @@ SRCS =
TARGET = simple
INTERFACE = simple.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/README b/Examples/GIFPlot/README
index 7960a6f98..73ecddd76 100644
--- a/Examples/GIFPlot/README
+++ b/Examples/GIFPlot/README
@@ -4,7 +4,7 @@ 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, and Ruby directories contain various examples specific to
+Python, Tcl, Java and Ruby directories contain various examples specific to
those languages.
This library was originally developed as part of the SPaSM molecular
@@ -36,7 +36,7 @@ On Windows, you can probably just do this:
Running the Examples
====================
-Once the library has been built, go the Perl, Python, Tcl, or Ruby directory
+Once the library has been built, go the Perl, Python, Tcl, Java or Ruby directory
to see various SWIG examples. Each example should have a README file with a
description.
diff --git a/Examples/GIFPlot/Ruby/check.list b/Examples/GIFPlot/Ruby/check.list
new file mode 100644
index 000000000..13de977af
--- /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/.cvsignore b/Examples/GIFPlot/Ruby/full/.cvsignore
new file mode 100644
index 000000000..c5d112b05
--- /dev/null
+++ b/Examples/GIFPlot/Ruby/full/.cvsignore
@@ -0,0 +1,4 @@
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Ruby/full/Makefile b/Examples/GIFPlot/Ruby/full/Makefile
index 251fcb282..5af8bc832 100644
--- a/Examples/GIFPlot/Ruby/full/Makefile
+++ b/Examples/GIFPlot/Ruby/full/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Ruby/shadow/.cvsignore b/Examples/GIFPlot/Ruby/shadow/.cvsignore
new file mode 100644
index 000000000..c5d112b05
--- /dev/null
+++ b/Examples/GIFPlot/Ruby/shadow/.cvsignore
@@ -0,0 +1,4 @@
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile
index a0f6b6325..ea382ea88 100644
--- a/Examples/GIFPlot/Ruby/shadow/Makefile
+++ b/Examples/GIFPlot/Ruby/shadow/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Ruby/simple/.cvsignore b/Examples/GIFPlot/Ruby/simple/.cvsignore
new file mode 100644
index 000000000..0c4113eb0
--- /dev/null
+++ b/Examples/GIFPlot/Ruby/simple/.cvsignore
@@ -0,0 +1,4 @@
+simple_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Ruby/simple/Makefile b/Examples/GIFPlot/Ruby/simple/Makefile
index 7d44e5f0b..f7ca1a7d8 100644
--- a/Examples/GIFPlot/Ruby/simple/Makefile
+++ b/Examples/GIFPlot/Ruby/simple/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = simple
INTERFACE = simple.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Tcl/check.list b/Examples/GIFPlot/Tcl/check.list
new file mode 100644
index 000000000..2b6e3d28a
--- /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/.cvsignore b/Examples/GIFPlot/Tcl/full/.cvsignore
new file mode 100644
index 000000000..c5d112b05
--- /dev/null
+++ b/Examples/GIFPlot/Tcl/full/.cvsignore
@@ -0,0 +1,4 @@
+gifplot_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Tcl/full/Makefile b/Examples/GIFPlot/Tcl/full/Makefile
index c14250a27..0c016e364 100644
--- a/Examples/GIFPlot/Tcl/full/Makefile
+++ b/Examples/GIFPlot/Tcl/full/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o *~ *.so mytclsh .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Tcl/mandel/.cvsignore b/Examples/GIFPlot/Tcl/mandel/.cvsignore
new file mode 100644
index 000000000..0d9d6a601
--- /dev/null
+++ b/Examples/GIFPlot/Tcl/mandel/.cvsignore
@@ -0,0 +1,4 @@
+mandel_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Tcl/mandel/Makefile b/Examples/GIFPlot/Tcl/mandel/Makefile
index 703812129..9280d7bb2 100644
--- a/Examples/GIFPlot/Tcl/mandel/Makefile
+++ b/Examples/GIFPlot/Tcl/mandel/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = gifplot
INTERFACE = mandel.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='mywish' INTERFACE='$(INTERFACE)' wish
clean::
- rm -f *_wrap* *.o *~ *.so mywish .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Tcl/simple/.cvsignore b/Examples/GIFPlot/Tcl/simple/.cvsignore
new file mode 100644
index 000000000..0c4113eb0
--- /dev/null
+++ b/Examples/GIFPlot/Tcl/simple/.cvsignore
@@ -0,0 +1,4 @@
+simple_wrap.c
+*.so
+*.dll
+*.gif
diff --git a/Examples/GIFPlot/Tcl/simple/Makefile b/Examples/GIFPlot/Tcl/simple/Makefile
index 9a49d7e89..752d79c10 100644
--- a/Examples/GIFPlot/Tcl/simple/Makefile
+++ b/Examples/GIFPlot/Tcl/simple/Makefile
@@ -5,19 +5,20 @@ SRCS =
TARGET = simple
INTERFACE = simple.i
LIBS = -L../.. -lgifplot
-INCLUDE = -I../../Include
+INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
+ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o *~ *.so mytclsh .~* core *.gif
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+ rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/configure b/Examples/GIFPlot/configure
deleted file mode 100755
index 3997b4d84..000000000
--- a/Examples/GIFPlot/configure
+++ /dev/null
@@ -1,1299 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-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=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -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 ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$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" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- 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)
- # 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 << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --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
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$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" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- 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)
- 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" ;;
-
- -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 ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- 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 "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=Include/gifplot.h
-
-# 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 its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- 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
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-# Set name for machine-dependent library files
-
-echo $ac_n "checking MACHDEP""... $ac_c" 1>&6
-echo "configure:530: checking MACHDEP" >&5
-if test -z "$MACHDEP"
-then
- if test -f /usr/lib/NextStep/software_version; then
- set X `hostinfo | grep 'NeXT Mach.*:' | \
- sed -e 's/://' -e 's/\./_/'` && \
- ac_sys_system=next && ac_sys_release=$4
- MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
- else
- ac_sys_system=`uname -s`
- if test "$ac_sys_system" = "AIX" ; then
- ac_sys_release=`uname -v`
- else
- ac_sys_release=`uname -r`
- fi
- ac_md_system=`echo $ac_sys_system |
- tr -d '/ ' | tr '[A-Z]' '[a-z]'`
- ac_md_release=`echo $ac_sys_release |
- tr -d '/ ' | sed 's/\..*//'`
- MACHDEP="$ac_md_system$ac_md_release"
- fi
- case MACHDEP in
- '') MACHDEP=unknown;;
- esac
-fi
-echo "$ac_t""$MACHDEP" 1>&6
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:568: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-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 $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:598: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_prog_rejected=no
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_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 $# -gt 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
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- if test -z "$CC"; then
- case "`uname -s`" in
- *win32* | *WIN32*)
- # Extract the first word of "cl", so it can be a program name with args.
-set dummy cl; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:649: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="cl"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
- ;;
- esac
- fi
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:681: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 692 "configure"
-#include "confdefs.h"
-
-main(){return(0);}
-EOF
-if { (eval echo configure:697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- ac_cv_prog_cc_works=yes
- # If we can't run a trivial program, we are probably using a cross compiler.
- if (./conftest; exit) 2>/dev/null; then
- ac_cv_prog_cc_cross=no
- else
- ac_cv_prog_cc_cross=yes
- fi
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- ac_cv_prog_cc_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-if test $ac_cv_prog_cc_works = no; then
- { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:723: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:728: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
-else
- GCC=
-fi
-
-ac_test_CFLAGS="${CFLAGS+set}"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS=
-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:756: checking whether ${CC-cc} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_g=yes
-else
- ac_cv_prog_cc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&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
-
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:790: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-for ac_prog in ar aal
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:823: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_AR="$ac_prog"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-AR="$ac_cv_prog_AR"
-if test -n "$AR"; then
- echo "$ac_t""$AR" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-test -n "$AR" && break
-done
-test -n "$AR" || AR="ar"
-
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:855: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 870 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 887 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -nologo -E"
- cat > conftest.$ac_ext <<EOF
-#line 904 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:935: checking for ANSI C header files" >&5
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 940 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:948: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 965 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- 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 <<EOF
-#line 983 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- 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 <<EOF
-#line 1004 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#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)) exit(2);
-exit (0); }
-
-EOF
-if { (eval echo configure:1015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- :
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_header_stdc=no
-fi
-rm -fr conftest*
-fi
-
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# 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. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# 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.
-(set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote substitution
- # turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- -e "s/'/'\\\\''/g" \
- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
- ;;
- esac >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-cat > conftest.defs <<\EOF
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
-s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
-s%\[%\\&%g
-s%\]%\\&%g
-s%\$%$$%g
-EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
-rm -f conftest.defs
-
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-
-trap 'rm -fr `echo "Makefile Lib/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@MACHDEP@%$MACHDEP%g
-s%@CC@%$CC%g
-s%@RANLIB@%$RANLIB%g
-s%@AR@%$AR%g
-s%@CPP@%$CPP%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile Lib/Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
-
-
-
-
-
-
diff --git a/Examples/GIFPlot/configure.in b/Examples/GIFPlot/configure.in
deleted file mode 100644
index 271399590..000000000
--- a/Examples/GIFPlot/configure.in
+++ /dev/null
@@ -1,52 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(Include/gifplot.h)
-AC_PREREQ(2.0)
-
-# Set name for machine-dependent library files
-AC_SUBST(MACHDEP)
-AC_MSG_CHECKING(MACHDEP)
-if test -z "$MACHDEP"
-then
- if test -f /usr/lib/NextStep/software_version; then
- set X `hostinfo | grep 'NeXT Mach.*:' | \
- sed -e 's/://' -e 's/\./_/'` && \
- ac_sys_system=next && ac_sys_release=$4
- MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
- else
- ac_sys_system=`uname -s`
- if test "$ac_sys_system" = "AIX" ; then
- ac_sys_release=`uname -v`
- else
- ac_sys_release=`uname -r`
- fi
- ac_md_system=`echo $ac_sys_system |
- tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
- ac_md_release=`echo $ac_sys_release |
- tr -d '[/ ]' | sed 's/\..*//'`
- MACHDEP="$ac_md_system$ac_md_release"
- fi
- case MACHDEP in
- '') MACHDEP=unknown;;
- esac
-fi
-AC_MSG_RESULT($MACHDEP)
-
-AC_LANG_C
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_RANLIB
-AC_SUBST(AR)
-AC_CHECK_PROGS(AR, ar aal, ar)
-
-dnl Checks for header files.
-AC_HEADER_STDC
-dnl Checks for library functions.
-
-AC_OUTPUT(Makefile Lib/Makefile)
-
-
-
-
-
-
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 6ae82386d..cd0dcb336 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -12,10 +12,10 @@
# certain packages have been installed. Set the prefixes
# accordingly.
#
-# 2. To use this makefile, simply set SRCS, INTERFACE, INCLUDE, LIBS,
+# 2. To use this makefile, simply set SRCS, INTERFACE, INCLUDES, LIBS,
# TARGET, and do a
# $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \
-# INCLUDE='$(INCLUDE) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \
+# INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \
# TARGET='$(TARGET)' method
#
# 'method' describes what is being built.
@@ -28,11 +28,12 @@ CFLAGS =
prefix = @prefix@
exec_prefix= @exec_prefix@
SRCS =
-INCLUDE =
+INCLUDES =
LIBS =
INTERFACE =
SWIGOPT =
-SWIG = SWIG
+SWIG = swig@release_suffix@
+RUNTIMEDIR = $(exec_prefix)/lib
LIBM = @LIBM@
LIBC = @LIBC@
@@ -47,7 +48,10 @@ libtool_link = $(TOP)/../Tools/libtool --mode link
XLIB = @XLIBSW@
XINCLUDE = @XINCLUDES@
-ISRCS = $(INTERFACE:.i=_wrap.c)
+IWRAP = $(INTERFACE:.i=_wrap.i)
+ISRCS = $(IWRAP:.i=.c)
+ICXXSRCS = $(IWRAP:.i=.cxx)
+IOBJS = $(IWRAP:.i=.@OBJEXT@)
##################################################################
# Dynamic loading for C++
@@ -68,15 +72,13 @@ CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
SO= @SO@
LDSHARED= @LDSHARED@
CCSHARED= @CCSHARED@
-CXXSHARED= @LDSHARED@
+CXXSHARED= @CXXSHARED@
# This is used for building shared libraries with a number of C++
# compilers. If it doesn't work, comment it out.
+@TRYLINKINGWITHCXX@
-CXXSHARED= @CXX@ -shared
-
-OBJS = $(SRCS:.c=.o) $(CXXSRCS:.cxx=.o)
-IOBJS = $(ISRCS:.c=.o)
+OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@)
##################################################################
##### Tcl/Tk ######
@@ -86,9 +88,12 @@ IOBJS = $(ISRCS:.c=.o)
TCL_INCLUDE = @TCLINCLUDE@
TCL_LIB = @TCLLIB@
-TCL_OPTS = -ltcl @LIBS@
+TCL_OPTS = @LIBS@
TK_OPTS = -ltk -ltcl @LIBS@
+# Extra Tcl specific dynamic linking options
+TCL_DLNK = @TCLDYNAMICLINKING@
+
# -----------------------------------------------------------
# Build a new version of the tclsh shell
# -----------------------------------------------------------
@@ -96,12 +101,12 @@ TK_OPTS = -ltk -ltcl @LIBS@
tclsh: $(SRCS)
$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE)
- $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) $(TCL_INCLUDE) \
+ $(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 $(INTERFACE)
- $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ISRCS) $(INCLUDE) $(TCL_INCLUDE) \
+ $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
# -----------------------------------------------------------
@@ -110,13 +115,13 @@ tclsh_cpp: $(SRCS)
wish: $(SRCS)
$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE)
- $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) $(TCL_INCLUDE) \
+ $(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 $(INTERFACE)
- $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ISRCS) $(INCLUDE) $(TCL_INCLUDE) \
+ $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET)
# -----------------------------------------------------------
@@ -125,8 +130,8 @@ wish_cpp: $(SRCS)
tcl: $(SRCS)
$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) $(TCL_INCLUDE)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(TARGET)$(SO)
# -----------------------------------------------------------
# Build a Tcl7.5 dynamic loadable module for C++
@@ -134,8 +139,31 @@ tcl: $(SRCS)
tcl_cpp: $(SRCS)
$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ISRCS) $(INCLUDE) $(TCL_INCLUDE)
- $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+
+# -----------------------------------------------------------
+# Build a Tcl7.5 dynamic loadable module, linked against SWIG runtime lib
+# -----------------------------------------------------------
+
+TCL_RUNTIME=-L$(RUNTIMEDIR) -lswigtcl8@release_suffix@
+
+tcl_multi: $(SRCS)
+ $(SWIG) -c -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(TCL_RUNTIME) $(TCL_DLNK) $(LIBS) -o $(TARGET)$(SO)
+
+tcl_multi_cpp: $(SRCS)
+ $(SWIG) -c -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(TCL_RUNTIME) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Cleaning the Tcl examples
+# -----------------------------------------------------------------
+
+tcl_clean:
+ rm -f *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core mytclsh@EXEEXT@
##################################################################
##### PERL 5 ######
@@ -147,6 +175,8 @@ tcl_cpp: $(SRCS)
PERL5_INCLUDE= @PERL5EXT@
+# Extra Perl specific dynamic linking options
+PERL5_DLNK = @PERL5DYNAMICLINKING@
# ----------------------------------------------------------------
# Build a Perl5 dynamically loadable module (C)
@@ -154,8 +184,8 @@ PERL5_INCLUDE= @PERL5EXT@
perl5: $(SRCS)
$(SWIG) -perl5 $(SWIGOPT) $(INTERFACE)
- $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) -I$(PERL5_INCLUDE)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
+ $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a Perl5 dynamically loadable module (C++)
@@ -163,30 +193,52 @@ perl5: $(SRCS)
perl5_cpp: $(SRCS)
$(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ISRCS) $(INCLUDE) -I$(PERL5_INCLUDE)
- $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a Perl5 dynamically loadable module, linked against SWIG runtime lib
+# ----------------------------------------------------------------
+
+PERL5_RUNTIME=-L$(RUNTIMEDIR) -lswigpl@release_suffix@
+
+perl5_multi: $(SRCS)
+ $(SWIG) -c -perl5 $(SWIGOPT) $(INTERFACE)
+ $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PERL5_RUNTIME) $(PERL5_DLNK) $(LIBS) -o $(TARGET)$(SO)
+
+perl5_multi_cpp: $(SRCS)
+ $(SWIG) -c -perl5 -c++ $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PERL5_RUNTIME) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a module from existing XS C source code. (ie. from xsubpp).
# ----------------------------------------------------------------
perl5_xs: $(SRCS)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDE) -I$(PERL5_INCLUDE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
$(LDSHARED) $(OBJS) $(LIBS) -o $(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a statically linked Perl5 executable
# ----------------------------------------------------------------
-PERL5_LIB = -L$(PERL5_INCLUDE) -lperl @LIBS@ $(SYSLIBS)
+PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS)
perl5_static: $(SRCS)
$(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACE)
- $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDE) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+ $(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) $(INTERFACE)
- $(CXX) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ISRCS) $(INCLUDE) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+ $(CXX) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+# -----------------------------------------------------------------
+# Cleaning the Perl5 examples
+# -----------------------------------------------------------------
+
+perl5_clean:
+ rm -f *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core myperl@EXEEXT@ *.pm
##################################################################
##### PYTHON ######
@@ -196,14 +248,17 @@ perl5_static_cpp: $(SRCS)
PYTHON_INCLUDE= -DHAVE_CONFIG_H @PYINCLUDE@
PYTHON_LIB = @PYLIB@
+# Extra Python specific dynamic linking options
+PYTHON_DLNK = @PYTHONDYNAMICLINKING@
+
# ----------------------------------------------------------------
# Build a C dynamically loadable module
# ----------------------------------------------------------------
python: $(SRCS)
$(SWIG) -python $(SWIGOPT) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDE) $(PYTHON_INCLUDE)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)module$(SO)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o _$(TARGET)$(SO)
# -----------------------------------------------------------------
# Build a C++ dynamically loadable module
@@ -211,8 +266,25 @@ python: $(SRCS)
python_cpp: $(SRCS)
$(SWIG) -c++ -python $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) $(PYTHON_INCLUDE)
- $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)module$(SO)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o _$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a dynamically loadable module, linked against SWIG Runtime lib
+# -----------------------------------------------------------------
+
+PYTHON_RUNTIME=-L$(RUNTIMEDIR) -lswigpy@release_suffix@
+
+python_multi: $(SRCS)
+ $(SWIG) -c -python $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PYTHON_RUNTIME) $(PYTHON_DLNK) $(LIBS) -o _$(TARGET)$(SO)
+
+python_multi_cpp: $(SRCS)
+ $(SWIG) -c -c++ -python $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PYTHON_RUNTIME) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o _$(TARGET)$(SO)
+
# -----------------------------------------------------------------
# Build statically linked Python interpreter
@@ -227,14 +299,20 @@ PYTHON_LIBOPTS = @PYLINK@ @LIBS@ $(TKINTER) $(SYSLIBS)
python_static: $(SRCS)
$(SWIG) -python -lembed.i $(SWIGOPT) $(INTERFACE)
- $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDE) \
+ $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
python_static_cpp: $(SRCS)
$(SWIG) -c++ -python -lembed.i $(SWIGOPT) $(INTERFACE)
- $(CXX) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) \
+ $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
+# -----------------------------------------------------------------
+# Cleaning the python examples
+# -----------------------------------------------------------------
+
+python_clean:
+ rm -f *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core mypython@EXEEXT@ *.pyc
##################################################################
##### GUILE ######
@@ -250,7 +328,7 @@ GUILE_LIB = @GUILELIB@
guile: $(SRCS)
$(SWIG) -guile -Linkage ltdlmod $(SWIGOPT) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDE) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
$(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o lib$(TARGET)$(SO)
# -----------------------------------------------------------------
@@ -259,9 +337,40 @@ guile: $(SRCS)
guile_cpp: $(SRCS)
$(SWIG) -c++ -guile -Linkage ltdlmod $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDE) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(CXXSRCS)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o lib$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a dynamically loadable module with passive linkage
+# -----------------------------------------------------------------
+
+guile_passive: $(SRCS)
+ $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
$(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o lib$(TARGET)$(SO)
+guile_passive_cpp: $(SRCS)
+ $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o lib$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a dynamically loadable module with passive linkage,
+# linked against SWIG runtime lib
+# -----------------------------------------------------------------
+
+GUILE_RUNTIME=-L$(RUNTIMEDIR) -lswigguile@release_suffix@
+
+guile_passive_multi: $(SRCS)
+ $(SWIG) -c -guile -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(GUILE_RUNTIME) $(LIBS) -o lib$(TARGET)$(SO)
+
+guile_passive_multi_cpp: $(SRCS)
+ $(SWIG) -c -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(GUILE_RUNTIME) $(LIBS) $(CPP_DLLIBS) -o lib$(TARGET)$(SO)
+
# -----------------------------------------------------------------
# Build statically linked Guile interpreter
# -----------------------------------------------------------------
@@ -270,16 +379,32 @@ GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS)
guile_static: $(SRCS)
$(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE)
- $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDE) \
+ $(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) $(INTERFACE)
- $(CXX) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) \
+ $(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) $(INTERFACE)
+ $(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) $(INTERFACE)
+ $(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 *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core my-guile@EXEEXT@ $(TARGET)@EXEEXT@
##################################################################
##### JAVA ######
@@ -288,17 +413,20 @@ guile_static_cpp: $(SRCS)
# 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/<arch-osname>.
-
JAVA_INCLUDE= @JAVAINC@
+# Extra Java specific dynamic linking options
+JAVA_DLNK = @JAVADYNAMICLINKING@
+JAVALIBPREFIX = @JAVALIBRARYPREFIX@
+
# ----------------------------------------------------------------
# Build a java dynamically loadable module (C)
# ----------------------------------------------------------------
java: $(SRCS)
$(SWIG) -java $(SWIGOPT) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) $(JAVA_INCLUDE)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVALIBPREFIX)$(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a java dynamically loadable module (C++)
@@ -306,30 +434,130 @@ java: $(SRCS)
java_cpp: $(SRCS)
$(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ISRCS) $(INCLUDE) $(JAVA_INCLUDE)
- $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVALIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a java dynamically loadable module
+# ----------------------------------------------------------------
+
+java_multi: $(SRCS)
+ $(SWIG) -java $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVALIBPREFIX)$(TARGET)$(SO)
+
+java_multi_cpp: $(SRCS)
+ $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVALIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Cleaning the java examples
+# -----------------------------------------------------------------
+
+java_clean:
+ rm -f *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core *.class `find . -name \*.java | grep -v main.java`
##################################################################
##### MZSCHEME ######
##################################################################
+MZC = test -n "@MZC@" && @MZC@
+
# ----------------------------------------------------------------
-# Build a C dynamically loadable module
+# Build a C/C++ dynamically loadable module
# ----------------------------------------------------------------
-MZC = test -n "@MZC@" && @MZC@
-
mzscheme: $(SRCS)
$(SWIG) -mzscheme $(SWIGOPT) $(INTERFACE)
- $(MZC) --cc $(ISRCS) $(SRCS)
+ $(MZC) ++ccf "$(INCLUDES)" --cc $(ISRCS) $(SRCS)
$(MZC) --ld $(TARGET)$(SO) $(OBJS) $(IOBJS)
+mzscheme_cpp: $(SRCS)
+ $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
+ $(MZC) ++ccf "$(INCLUDES)" --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(MZC) --ld $(TARGET)$(SO) $(OBJS) $(IOBJS) $(CPP_DLLIBS)
+
+# ----------------------------------------------------------------
+# Build a dynamically loadable module, linked against SWIG runtime
+# ----------------------------------------------------------------
+
+MZSCHEME_RUNTIME=-L$(RUNTIMEDIR) -lswigmz@release_suffix@
+
+mzscheme_multi: $(SRCS)
+ $(SWIG) -c -mzscheme $(SWIGOPT) $(INTERFACE)
+ $(MZC) ++ccf "$(INCLUDES)" --cc $(ISRCS) $(SRCS)
+ $(MZC) --ld $(TARGET)$(SO) $(OBJS) $(IOBJS) $(MZSCHEME_RUNTIME)
+
+mzscheme_multi_cpp: $(SRCS)
+ $(SWIG) -c -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
+ $(MZC) ++ccf "$(INCLUDES)" --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(MZC) --ld $(TARGET)$(SO) $(OBJS) $(IOBJS) $(MZSCHEME_RUNTIME) $(CPP_DLLIBS)
+
+# -----------------------------------------------------------------
+# Cleaning the mzscheme examples
+# -----------------------------------------------------------------
+
+mzscheme_clean:
+ rm -f *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core
+
+##################################################################
+##### Ocaml #####
+##################################################################
+
+OCC=@OCAMLC@
+NOLINK ?= false
+
+ocaml_static: $(SRCS)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
+ $(OCC) -g -c -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
+ $(OCC) -g -c $(INTERFACE:%.i=%.mli)
+ $(OCC) -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) -c $(PROGFILE)
+ $(NOLINK) || $(OCC) -g -custom -o $(TARGET) \
+ $(INTERFACE:%.i=%.cmo) \
+ $(PROGFILE:%.ml=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
+
+ocaml_static_cpp: $(SRCS)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) \
+ $(INTERFACE)
+ cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
+ $(OCC) -g -c -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) -c $(PROGFILE)
+ $(NOLINK) || $(OCC) -g -custom -o $(TARGET) $(INTERFACE:%.i=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) -cclib "$(LIBS)"
+
+ocaml_static_multi_cpp: $(SRCS)
+ $(SWIG) -c -ocaml -c++ $(SWIGOPT) \
+ $(INTERFACE)
+ cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
+ $(OCC) -g -c -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) -c $(PROGFILE)
+ $(NOLINK) || $(OCC) -g -custom -o $(TARGET) $(INTERFACE:%.i=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) -cclib "$(LIBS)"
+
+ocaml_clean:
+ rm -f *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core *.cmo *.cmi $(MLFILE) $(MLFILE)i
+
##################################################################
##### RUBY ######
##################################################################
# Make sure these locate your Ruby installation
-RUBY_INCLUDE= -DHAVE_CONFIG_H @RUBYINCLUDE@
+RUBY_CFLAGS= @RUBYCCDLFLAGS@ -DHAVE_CONFIG_H
+RUBY_INCLUDE= @RUBYINCLUDE@
+RUBY_LIB = @RUBYLIB@
+RUBY_DLNK = @RUBYDYNAMICLINKING@
# ----------------------------------------------------------------
# Build a C dynamically loadable module
@@ -337,8 +565,8 @@ RUBY_INCLUDE= -DHAVE_CONFIG_H @RUBYINCLUDE@
ruby: $(SRCS)
$(SWIG) -ruby $(SWIGOPT) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDE) $(RUBY_INCLUDE)
- $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(TARGET)$(SO)
# -----------------------------------------------------------------
# Build a C++ dynamically loadable module
@@ -346,8 +574,24 @@ ruby: $(SRCS)
ruby_cpp: $(SRCS)
$(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) $(RUBY_INCLUDE)
- $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a dynamically loadable module, linked against SWIG runtime lib
+# -----------------------------------------------------------------
+
+RUBY_RUNTIME=-L$(RUNTIMEDIR) -lswigrb@release_suffix@
+
+ruby_multi: $(SRCS)
+ $(SWIG) -c -ruby $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(RUBY_RUNTIME) $(RUBY_DLNK) $(LIBS) -o $(TARGET)$(SO)
+
+ruby_multi_cpp: $(SRCS)
+ $(SWIG) -c -c++ -ruby $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(RUBY_RUNTIME) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
# -----------------------------------------------------------------
# Build statically linked Ruby interpreter
@@ -356,29 +600,140 @@ ruby_cpp: $(SRCS)
# library file
# -----------------------------------------------------------------
-RUBY_LIB = @RUBYLIB@
RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS)
ruby_static: $(SRCS)
$(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACE)
- $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDE) \
+ $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
-ruby_static_cpp: $(SRCS)
+ruby_cpp_static: $(SRCS)
$(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACE)
- $(CXX) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDE) \
+ $(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 *.@OBJEXT@ *@SO@ *_wrap* *~ .~* core myruby@EXEEXT@ *.pm
+
+##################################################################
+##### PHP ######
+##################################################################
+
+# -------------------------------------------------------------------
+# Build a PHP4 dynamically loadable module (C)
+# -------------------------------------------------------------------
+
+PHP4_INCLUDE = @PHP4INC@
+
+php4: $(SRCS)
+ $(SWIG) -php4 -cppext cxx $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP4_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
+
+# --------------------------------------------------------------------
+# Build a PHP4 dynamically loadable module (C++)
+# --------------------------------------------------------------------
+
+php4_cpp: $(SRCS)
+ $(SWIG) -php4 -cppext cxx -c++ $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP4_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+
+# ---------------------------------------------------------------------
+# Build a dynamically loadable module, linked against SWIG Runtime lib
+# ---------------------------------------------------------------------
+
+PHP4_RUNTIME=-L$(RUNTIMEDIR) -lswigphp4@release_suffix@
+
+php4_multi: $(SRCS)
+ $(SWIG) -c -php4 -cppext cxx $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PHP4_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PHP4_RUNTIME) $(PHP4_DLNK) $(LIBS) -o $(TARGET)module$(SO)
+
+php4_multi_cpp: $(SRCS)
+ $(SWIG) -c -c++ -php4 -cppext cxx $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PHP4_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PHP4_RUNTIME) $(PHP4_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)module$(SO)
+
+# -----------------------------------------------------------------
+# Cleaning the PHP4 examples
+# -----------------------------------------------------------------
+
+php4_clean:
+ rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core *.php
+
##################################################################
-##### SWIG ######
+##### Pike ######
##################################################################
-# Build a new SWIG extension
+# 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) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# -----------------------------------------------------------------
-SWIGINCLUDE = -I${prefix}/include
-SWIGLIB = -L${exec_prefix}/lib
+pike_cpp: $(SRCS)
+ $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a dynamically loadable module, linked against SWIG runtime lib
+# -----------------------------------------------------------------
+
+PIKE_RUNTIME=-L$(RUNTIMEDIR) -lswigpike@release_suffix@
+
+pike_multi: $(SRCS)
+ $(SWIG) -c -pike $(SWIGOPT) $(INTERFACE)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE)
+ $(LDSHARED) $(OBJS) $(IOBJS) $(PIKE_RUNTIME) $(PIKE_DLNK) $(LIBS) -o $(TARGET)$(SO)
+
+pike_multi_cpp: $(SRCS)
+ $(SWIG) -c -c++ -pike $(SWIGOPT) $(INTERFACE)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
+ $(CXXSHARED) $(OBJS) $(IOBJS) $(PIKE_RUNTIME) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(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) $(INTERFACE)
+ $(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) $(INTERFACE)
+ $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
+
+# -----------------------------------------------------------------
+# Cleaning the Pike examples
+# -----------------------------------------------------------------
-swig: $(SRCS)
- $(CXX) $(SRCS) $(SWIGINCLUDE) $(INCLUDE) $(SWIGLIB) $(LIBS) -lswig -o $(TARGET)
+pike_clean:
+ rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core mypike@EXEEXT@
diff --git a/Examples/README b/Examples/README
index 3a476a79a..c18d30ed7 100644
--- a/Examples/README
+++ b/Examples/README
@@ -37,8 +37,6 @@ the rules of thumb for making C++ work:
This can be set by modifying the setting of CPP_DLLIBS in the
Makefile.
- - RTM (sorry)
-
*** Special note for SWIG Maintainers ***
diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in
index 1c31a6725..b97249c06 100644
--- a/Examples/guile/Makefile.in
+++ b/Examples/guile/Makefile.in
@@ -1,27 +1,38 @@
# Makefile for Guile. Used by all of the example programs.
-subdirs = simple matrix
+subdirs = simple matrix port constants multimap multivalue
top_srcdir = @top_srcdir@
-
+SWIG = ../$(top_srcdir)/swig@release_suffix@
+CC = @CC@
+CXX = @CXX@
+CFLAGS = @CFLAGS@
GUILEINCLUDE = @GUILEINCLUDE@
GUILELINK = @GUILELINK@
+SWIGOPT =
WRAP = $(IFILE:.i=_wrap.c)
+CXXWRAP = $(IFILE:.i=_wrap.cxx)
all:
for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done
clean::
- cd simple; make clean
- cd matrix; make 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::
- ../$(top_srcdir)/swig -guile $(IFILE)
- $(CC) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK)
+ $(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
index e006d02ce..acec7773b 100644
--- a/Examples/guile/README
+++ b/Examples/guile/README
@@ -1,11 +1,17 @@
This directory contains examples for Guile.
-simple - The simple example from the user manual.
-matrix - A very simple Matrix example.
+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<int> and vector<double>
+
Note that the examples in this directory build a special version of
-Guile which includes the wrapped functions in the top-level module.
+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.
+directory.
diff --git a/Examples/guile/check.list b/Examples/guile/check.list
new file mode 100644
index 000000000..d35b2d693
--- /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/.cvsignore b/Examples/guile/constants/.cvsignore
new file mode 100644
index 000000000..7d0f67de1
--- /dev/null
+++ b/Examples/guile/constants/.cvsignore
@@ -0,0 +1,2 @@
+example_wrap.c
+my-guile
diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile
new file mode 100644
index 000000000..70243c75e
--- /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 000000000..5220150f1
--- /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 000000000..0b602e5ab
--- /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
index bbe78539a..5df2c6515 100644
--- a/Examples/guile/matrix/Makefile
+++ b/Examples/guile/matrix/Makefile
@@ -1,4 +1,3 @@
-CC = gcc
SRCS = matrix.c vector.c
TARGET = matrix
IFILE = package.i
@@ -10,11 +9,10 @@ all::
SRCS='$(SRCS)' \
TARGET=$(TARGET) \
IFILE=$(IFILE) \
- CC=$(CC) \
MODULE=$(MODULE) \
sub-all
clean::
- rm -f matrix *_wrap* *~ .~* core
+ $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
check: all
diff --git a/Examples/guile/matrix/README b/Examples/guile/matrix/README
index 7776129f7..dc1957719 100644
--- a/Examples/guile/matrix/README
+++ b/Examples/guile/matrix/README
@@ -1,7 +1,7 @@
Matrix example. To run the example, execute the program 'matrix' and
type the following :
- (load 'matrix.scm)
+ (load "matrix.scm")
(do-test 0)
Alternatively, use the command-line:
diff --git a/Examples/guile/matrix/matrix.c b/Examples/guile/matrix/matrix.c
index 7ecb6ddd4..6ce10098b 100644
--- a/Examples/guile/matrix/matrix.c
+++ b/Examples/guile/matrix/matrix.c
@@ -1,4 +1,6 @@
/* FILE : matrix.c : some simple 4x4 matrix operations */
+#include <stdlib.h>
+#include <stdio.h>
double **new_matrix() {
diff --git a/Examples/guile/matrix/matrix.i b/Examples/guile/matrix/matrix.i
index 25f44cc47..3ff8ec7ac 100644
--- a/Examples/guile/matrix/matrix.i
+++ b/Examples/guile/matrix/matrix.i
@@ -12,7 +12,8 @@ double get_m(double **M, int i, int j) {
}
%}
-%section "Matrix Operations"
+/*** Matrix Operations ***/
+
extern double **new_matrix();
/* Creates a new matrix and returns a pointer to it */
diff --git a/Examples/guile/matrix/package.i b/Examples/guile/matrix/package.i
index c820a3494..aaa55511c 100644
--- a/Examples/guile/matrix/package.i
+++ b/Examples/guile/matrix/package.i
@@ -1,7 +1,8 @@
// FILE : package.i
// See the SWIG users manual
-%title "Matrix and vector package"
+/*** Matrix and vector package ***/
+
%module Matrix
%{
#include <math.h>
diff --git a/Examples/guile/matrix/vector.c b/Examples/guile/matrix/vector.c
index cdb726ad5..3012993f8 100644
--- a/Examples/guile/matrix/vector.c
+++ b/Examples/guile/matrix/vector.c
@@ -1,5 +1,7 @@
/* File : vector.c */
+#include <stdlib.h>
+#include <stdio.h>
#include "vector.h"
Vector *createv(double x, double y, double z, double w) {
diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile
new file mode 100644
index 000000000..1ab46d030
--- /dev/null
+++ b/Examples/guile/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..d135481af
--- /dev/null
+++ b/Examples/guile/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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 000000000..e9cb6507d
--- /dev/null
+++ b/Examples/guile/multimap/example.i
@@ -0,0 +1,75 @@
+/* File : example.i */
+%module example
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(guile,in) (int argc, char *argv[]) {
+ int i;
+ SCM *v;
+ if (!(SCM_NIMP($input) && SCM_VECTORP($input))) {
+ SWIG_exception(SWIG_ValueError, "Expecting a vector");
+ return;
+ }
+ $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;
+ }
+ $2[i] = SCM_CHARS(v[i]);
+ }
+ $2[i] = 0;
+}
+
+%typemap(guile,freearg) (int argc, char *argv[]) {
+ free($2);
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(guile,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(guile,in) (char *str, int len) {
+ $1 = gh_scm2newstr($input,&$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(guile,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 000000000..edc197259
--- /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 000000000..1ab46d030
--- /dev/null
+++ b/Examples/guile/multivalue/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..c9ebad1ae
--- /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 000000000..abc2a6fbc
--- /dev/null
+++ b/Examples/guile/multivalue/example.i
@@ -0,0 +1,26 @@
+/* -*- c -*- */
+
+%module 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; 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 000000000..73eb5affa
--- /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
index 668c66bd3..824f3f823 100644
--- a/Examples/guile/port/Makefile
+++ b/Examples/guile/port/Makefile
@@ -1,4 +1,3 @@
-CC = gcc
SRCS = port.c
TARGET = port
IFILE = port.i
@@ -10,11 +9,10 @@ all::
SRCS='$(SRCS)' \
TARGET=$(TARGET) \
IFILE=$(IFILE) \
- CC=$(CC) \
MODULE=$(MODULE) \
sub-all
clean::
- rm -f $(TARGET) *_wrap* *~ .~* core test.out
+ $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
check: all
diff --git a/Examples/guile/port/port.i b/Examples/guile/port/port.i
index 553cfba23..eb7539173 100644
--- a/Examples/guile/port/port.i
+++ b/Examples/guile/port/port.i
@@ -1,3 +1,5 @@
+%module port
+
%include guilemain.i
/* Include the required FILE * typemaps */
@@ -7,5 +9,7 @@
#include <stdio.h>
%}
+%inline %{
void print_int(FILE *f, int i);
int read_int(FILE *f);
+%}
diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile
index 151dcc4b3..702b5bb96 100644
--- a/Examples/guile/simple/Makefile
+++ b/Examples/guile/simple/Makefile
@@ -1,18 +1,19 @@
-CC = gcc
SRCS = example.c
TARGET = my-guile
IFILE = example.i
MKDIR = ..
-all::
+all: $(TARGET)
+
+$(TARGET):
$(MAKE) -f $(MKDIR)/Makefile \
SRCS='$(SRCS)' \
TARGET=$(TARGET) \
IFILE=$(IFILE) \
- CC=$(CC) \
sub-all
clean::
- rm -f *_wrap* my-guile *~ .~* core
+ $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
-check: all
+check: $(TARGET)
+ ./$(TARGET) -s example.scm > /dev/null
diff --git a/Examples/guile/simple/README b/Examples/guile/simple/README
index 3ca6e40cf..982216eaa 100644
--- a/Examples/guile/simple/README
+++ b/Examples/guile/simple/README
@@ -2,7 +2,7 @@ A very simple example.
To run it, start the program 'my-guile' and type:
- (load 'example.scm)
+ (load "example.scm")
Alternatively, you can use the shell command:
diff --git a/Examples/guile/simple/example.c b/Examples/guile/simple/example.c
index 0e6b284b6..dcafc4dc4 100644
--- a/Examples/guile/simple/example.c
+++ b/Examples/guile/simple/example.c
@@ -1,7 +1,7 @@
/* Simple example from documentation */
/* File : example.c */
-#include </usr/include/time.h>
+#include <time.h>
double My_variable = 3.0;
diff --git a/Examples/guile/simple/example.scm b/Examples/guile/simple/example.scm
index 7356aad74..9408b1aa6 100644
--- a/Examples/guile/simple/example.scm
+++ b/Examples/guile/simple/example.scm
@@ -1,23 +1,14 @@
-;;;
-;;; Guile script for simple example.
-;;; Is a little clumsy since I'm not the greatest scheme programmer.
-;;;
+;;; example.scm
-(display (get-time))
-(display "My variable = ")
-(display (My-variable))
-(newline)
+(define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'?
+ (for-each display args)
+ (newline))
-(define (facts x max)
- (if (< x max)
- (begin
- (display (string-append (number->string x) " factorial is "
- (number->string (fact x))))
- (newline)
- (facts (+ x 1) max))))
-
-(facts 0 14)
+(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)
@@ -27,9 +18,11 @@
(mods i imax (+ j 1) jmax))
(mods (+ i 1) imax 1 jmax))))
-(mods 1 250 1 250)
+(mods 1 150 1 150)
+
+(mdisplay-newline "My-variable = " (My-variable))
-(display (string-append "My-variable = " (number->string (My-variable))))
-(newline)
+(exit (and (= 1932053504 (fact 13))
+ (= 745470.0 (My-variable))))
;;; example.scm ends here
diff --git a/Examples/guile/std_vector/.cvsignore b/Examples/guile/std_vector/.cvsignore
new file mode 100644
index 000000000..bd7dd8a57
--- /dev/null
+++ b/Examples/guile/std_vector/.cvsignore
@@ -0,0 +1 @@
+example_wrap.cxx
diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile
new file mode 100644
index 000000000..fb491c2e7
--- /dev/null
+++ b/Examples/guile/std_vector/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..4f0dac70d
--- /dev/null
+++ b/Examples/guile/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h */
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<double> half(const std::vector<double>& v) {
+ std::vector<double> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::vector<double>& v) {
+ // would you believe this is the same as the above?
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+
diff --git a/Examples/guile/std_vector/example.i b/Examples/guile/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /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<int>;
+ %template(DoubleVector) vector<double>;
+}
+
+/* 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 000000000..77443a156
--- /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<int>
+(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<double>
+(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<double> in place
+(halve-in-place v)
+(print-DoubleVector v)
+(delete-DoubleVector v)
+
diff --git a/Examples/index.html b/Examples/index.html
index 7737e1bdc..1458e8dee 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -41,11 +41,13 @@ language:
<li><a href="perl5/index.html">Perl5</a>
<li><a href="tcl/index.html">Tcl</a>
<li><a href="guile/">Guile</a>
-<li><a href="java/">Java</a>
-<li><a href="mzscheme/">Mzscheme</a>
+<li><a href="java/index.html">Java</a>
+<li><a href="mzscheme">Mzscheme</a>
<li><a href="ruby/index.html">Ruby</a>
</ul>
+If your target platform is Windows, make sure you also see the <a href="../Doc/Manual/Windows.html">Windows</a> page in the main manual.
+
<h2>Real Life</h2>
The <a href="GIFPlot/">GIFPlot</a> directory contains examples that illustrate the use of SWIG with
diff --git a/Examples/java/check.list b/Examples/java/check.list
new file mode 100644
index 000000000..c2272cde4
--- /dev/null
+++ b/Examples/java/check.list
@@ -0,0 +1,14 @@
+# see top-level Makefile.in
+class
+constants
+enum
+funcptr
+mpointer
+multimap
+native
+pointer
+reference
+simple
+template
+typemap
+variables
diff --git a/Examples/java/class/.cvsignore b/Examples/java/class/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/class/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile
new file mode 100644
index 000000000..69fb4e670
--- /dev/null
+++ b/Examples/java/class/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..1e8e203dd
--- /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 000000000..36f0e9ef1
--- /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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.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 000000000..46d901361
--- /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 000000000..75700b305
--- /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 000000000..0360ce9ee
--- /dev/null
+++ b/Examples/java/class/index.html
@@ -0,0 +1,199 @@
+<html>
+<head>
+<title>SWIG:Examples:java:class</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/class/</tt>
+<hr>
+
+<H2>Wrapping a simple C++ class</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+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.
+
+<h2>The C++ Code</h2>
+
+Suppose you have some C++ classes described by the following (and admittedly lame)
+header file:
+
+<blockquote>
+<pre>
+/* 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();
+};
+</pre>
+</blockquote>
+
+<h2>The SWIG interface</h2>
+
+A simple SWIG interface for this can be built by simply grabbing the header file
+like this:
+
+<blockquote>
+<pre>
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+</pre>
+</blockquote>
+
+Note: when creating a C++ extension, you must run SWIG with the <tt>-c++</tt> option like this:
+<blockquote>
+<pre>
+% swig -c++ -java example.i
+</pre>
+</blockquote>
+
+<h2>A sample Java program</h2>
+
+Click <a href="main.java">here</a> to see a Java program that calls the C++ functions from Java.
+
+<h2>Key points</h2>
+
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+Circle c = new Circle(10);
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, a pair of accessor functions are used.
+For example:
+
+<blockquote>
+<pre>
+c.setX(15); // Set member data
+x = c.getX(); // Get member data
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a member function, you simply do this
+
+<blockquote>
+<pre>
+System.out.println( "The area is " + c.area() );
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a destructor, simply do this
+
+<blockquote>
+<pre>
+c.delete(); // Deletes a shape
+</pre>
+</blockquote>
+
+<p>
+<li>Static member variables are wrapped with java static get and set access functions. For example:
+
+<blockquote>
+<pre>
+n = Shape.getNshapes(); // Get a static data member
+Shape.setNshapes(13); // Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+
+<h2>General Comments</h2>
+
+<ul>
+<li>This high-level interface using shadow 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 shadow classes far better fits the java programming paradigm.
+
+<p>
+<li>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.
+
+<p>
+<li>A wide variety of C++ features are not currently supported by SWIG. Here is the
+short and incomplete list:
+
+<p>
+<ul>
+<li>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:
+
+<blockquote>
+<pre>
+void foo(int a);
+%name(foo2) void foo(double a, double b);
+</pre>
+</blockquote>
+
+<p>
+<li>Overloaded operators. Not supported at all. The only workaround for this is
+to write a helper function. For example:
+
+<blockquote>
+<pre>
+%inline %{
+ Vector *vector_add(Vector *a, Vector *b) {
+ ... whatever ...
+ }
+%}
+</pre>
+</blockquote>
+
+<p>
+<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
+
+</ul>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/class/main.java b/Examples/java/class/main.java
new file mode 100644
index 000000000..8ef35db6d
--- /dev/null
+++ b/Examples/java/class/main.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 main {
+ 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<shapes.length; i++)
+ {
+ System.out.println( " " + shapes[i].toString() );
+ System.out.println( " area = " + shapes[i].area() );
+ System.out.println( " perimeter = " + shapes[i].perimeter() );
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+
+ System.out.println( "\nGuess I'll clean up now" );
+
+ // Note: this invokes the virtual destructor
+ // You could leave this to the garbage collector
+ c.delete();
+ s.delete();
+
+ System.out.println( Shape.getNshapes() + " shapes remain" );
+ System.out.println( "Goodbye" );
+ }
+}
diff --git a/Examples/java/constants/.cvsignore b/Examples/java/constants/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/constants/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/constants/Makefile b/Examples/java/constants/Makefile
new file mode 100644
index 000000000..75ec0045a
--- /dev/null
+++ b/Examples/java/constants/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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/constants/example.i b/Examples/java/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/Examples/java/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/java/constants/index.html b/Examples/java/constants/index.html
new file mode 100644
index 000000000..390acc649
--- /dev/null
+++ b/Examples/java/constants/index.html
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>SWIG:Examples:java:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/java/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+When SWIG encounters C preprocessor macros and C declarations that look like constants,
+it creates Java constant with an identical value. Click <a href="example.i">here</a>
+to see a SWIG interface with some constant declarations in it.
+
+<h2>Accessing Constants from Java</h2>
+
+Click <a href="main.java">here</a> to see a Java program that prints out the values
+of the constants contained in the above file.
+
+<h2>Key points</h2>
+
+<ul>
+<li>The values of preprocessor macros are converted into Java constants.
+<li>Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
+<li>Character constants such as 'x' are converted into Java strings.
+<li>C string literals such as "Hello World" are converted into Java strings.
+<li>Macros that are not fully defined are simply ignored. For example:
+<blockquote>
+<pre>
+#define EXTERN extern
+</pre>
+</blockquote>
+is ignored because SWIG has no idea what type of variable this would be.
+
+<p>
+<li>Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
+
+<li>Certain C declarations involving 'const' are also turned into Java constants.
+<li>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).
+</ul>
+
+<hr>
+
+
+</body>
+</html>
diff --git a/Examples/java/constants/main.java b/Examples/java/constants/main.java
new file mode 100644
index 000000000..7130c3d70
--- /dev/null
+++ b/Examples/java/constants/main.java
@@ -0,0 +1,44 @@
+import java.lang.reflect.*;
+
+public class main {
+ 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/.cvsignore b/Examples/java/enum/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/enum/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile
new file mode 100644
index 000000000..69fb4e670
--- /dev/null
+++ b/Examples/java/enum/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..df7bb6328
--- /dev/null
+++ b/Examples/java/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include <stdio.h>
+
+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 000000000..525d62afc
--- /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, WARP, LUDICROUS };
+ 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 000000000..4c873824c
--- /dev/null
+++ b/Examples/java/enum/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%pragma make_default
+
+/* 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 000000000..cd81244e3
--- /dev/null
+++ b/Examples/java/enum/index.html
@@ -0,0 +1,37 @@
+<html>
+<head>
+<title>SWIG:Examples:java:enum</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/enum/</tt>
+<hr>
+
+<H2>Wrapping enumerations</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example tests SWIG's ability to wrap enumerations. By default, SWIG
+converts enumeration specifications into integer constants. Further use
+of enumerated types are handled as integers.
+
+<ul>
+<li><a href="example.h">example.h</a>. Header file containing some enums.
+<li><a href="example.i">example.i</a>. Interface file.
+<li><a href="main.java">main.java</a>. Sample Java program.
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>SWIG allows arbitrary integers to be passed as enum values. However,
+the result of passing an integer not corresponding to any of the values
+specified in the <tt>enum</tt> specification is undefined.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/enum/main.java b/Examples/java/enum/main.java
new file mode 100644
index 000000000..b1098c7b1
--- /dev/null
+++ b/Examples/java/enum/main.java
@@ -0,0 +1,39 @@
+
+public class main {
+ 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(" RED = " + example.RED);
+ System.out.println(" BLUE = " + example.BLUE);
+ System.out.println(" GREEN = " + example.GREEN);
+
+ System.out.println("\n*** Foo::speed ***");
+ System.out.println(" Foo::IMPULSE = " + Foo.IMPULSE);
+ System.out.println(" Foo::WARP = " + Foo.WARP);
+ System.out.println(" Foo::LUDICROUS = " + Foo.LUDICROUS);
+
+ System.out.println("\nTesting use of enums with functions\n");
+
+ example.enum_test(example.RED, Foo.IMPULSE);
+ example.enum_test(example.BLUE, Foo.WARP);
+ example.enum_test(example.GREEN, Foo.LUDICROUS);
+ example.enum_test(1234,5678);
+
+ System.out.println( "\nTesting use of enum with class method" );
+ Foo f = new Foo();
+
+ f.enum_test(Foo.IMPULSE);
+ f.enum_test(Foo.WARP);
+ f.enum_test(Foo.LUDICROUS);
+ }
+}
diff --git a/Examples/java/funcptr/.cvsignore b/Examples/java/funcptr/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/funcptr/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile
new file mode 100644
index 000000000..b1f254ed3
--- /dev/null
+++ b/Examples/java/funcptr/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..5c4a3dabf
--- /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 000000000..58989db79
--- /dev/null
+++ b/Examples/java/funcptr/example.h
@@ -0,0 +1,7 @@
+/* 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);
+
diff --git a/Examples/java/funcptr/example.i b/Examples/java/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /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 000000000..06d9008bf
--- /dev/null
+++ b/Examples/java/funcptr/index.html
@@ -0,0 +1,93 @@
+<html>
+<head>
+<title>SWIG:Examples:java:funcptr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/funcptr/</tt>
+<hr>
+
+<H2>Pointers to Functions</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+Okay, just what in the heck does SWIG do with a declaration like this?
+
+<blockquote>
+<pre>
+int do_op(int a, int b, int (*op)(int, int));
+</pre>
+</blockquote>
+
+Well, it creates a wrapper as usual. Of course, that does raise some
+questions about the third argument (the pointer to a function).
+
+<p>
+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:
+
+<blockquote>
+<pre>
+/* Some callback function */
+int add(int a, int b) {
+ return a+b;
+}
+...
+int r = do_op(x,y,add);
+</pre>
+</blockquote>
+
+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:
+
+<blockquote>
+<pre>
+%constant(int (*)(int,int)) ADD = add;
+</pre>
+</blockquote>
+
+Now, in a Java program, you would do this:
+
+<blockquote>
+<pre>
+int r = do_op(x,y, example.ADD)
+</pre>
+</blockquote>
+where <tt>example</tt> is the module name.
+
+<h2>An Example</h2>
+
+Here are some files that illustrate this with a simple example:
+
+<ul>
+<li><a href="example.c">example.c</a>
+<li><a href="example.h">example.h</a>
+<li><a href="example.i">example.i</a> (SWIG interface)
+<li><a href="main.java">main.java</a> (Sample program)
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>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.
+
+<p>
+<li>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.
+</ul>
+
+<hr>
+</body>
+</html>
+
+
+
+
diff --git a/Examples/java/funcptr/main.java b/Examples/java/funcptr/main.java
new file mode 100644
index 000000000..cf81f92b4
--- /dev/null
+++ b/Examples/java/funcptr/main.java
@@ -0,0 +1,33 @@
+
+public class main {
+
+ 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 000000000..547a78af9
--- /dev/null
+++ b/Examples/java/index.html
@@ -0,0 +1,68 @@
+<html>
+<head>
+<title>SWIG:Examples:java</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Java Examples</H1>
+
+<tt>$Header$</tt><br>
+
+<p>
+The following examples illustrate the use of SWIG with Java.
+
+<ul>
+<li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
+be used to wrap a C function, a global variable, and a constant.
+<li><a href="native/index.html">native</a>. Comparing the manual and the SWIG approach to calling native code.
+<li><a href="typemap/index.html">typemap</a>. Modifying the Java module's default behaviour by using typemaps.
+<li><a href="constants/index.html">constants</a>. This shows how preprocessor macros and
+certain C declarations are turned into constants.
+<li><a href="variables/index.html">variables</a>. An example showing how to access C global variables.
+<li><a href="enum/index.html">enum</a>. Wrapping enumerations.
+<li><a href="class/index.html">class</a>. How to wrap a simple C++ class.
+<li><a href="reference/index.html">reference</a>. C++ references.
+<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
+<li><a href="template/index.html">template</a>. C++ templates.
+<li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
+</ul>
+
+<h2>Running the examples</h2>
+Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
+
+On Unix most of the examples work by making the Makefile before executing the program main.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.
+<p>
+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.
+<p>
+A Unix example:
+<blockquote>
+<pre>
+$ make
+$ export LD_LIBRARY_PATH=. #ksh
+$ java main
+</pre>
+</blockquote>
+<p>
+
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Solaris
+</ul>
+
+The examples have been extensively tested using Sun's JDK on:
+
+<ul>
+<li>Sparc Solaris 2.6.
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+sending a message to <a href="mailto:swig-dev@cs.uchicago.edu">swig-dev@cs.uchicago.edu</a>.
+</body>
+</html>
+
+
diff --git a/Examples/java/mpointer/Makefile b/Examples/java/mpointer/Makefile
new file mode 100644
index 000000000..69fb4e670
--- /dev/null
+++ b/Examples/java/mpointer/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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/mpointer/example.cxx b/Examples/java/mpointer/example.cxx
new file mode 100644
index 000000000..1a6bb666a
--- /dev/null
+++ b/Examples/java/mpointer/example.cxx
@@ -0,0 +1,45 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+
+/* 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;
+}
+
+double do_op(Shape *s, double (Shape::*m)(void)) {
+ return (s->*m)();
+}
+
+double (Shape::*areapt())(void) {
+ return &Shape::area;
+}
+
+double (Shape::*perimeterpt())(void) {
+ return &Shape::perimeter;
+}
+
+/* Member pointer variables */
+double (Shape::*areavar)(void) = &Shape::area;
+double (Shape::*perimetervar)(void) = &Shape::perimeter;
+
diff --git a/Examples/java/mpointer/example.h b/Examples/java/mpointer/example.h
new file mode 100644
index 000000000..110fe91c1
--- /dev/null
+++ b/Examples/java/mpointer/example.h
@@ -0,0 +1,50 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+extern double do_op(Shape *s, double (Shape::*m)(void));
+
+/* Functions that return member pointers */
+
+extern double (Shape::*areapt())(void);
+extern double (Shape::*perimeterpt())(void);
+
+/* Global variables that are member pointers */
+extern double (Shape::*areavar)(void);
+extern double (Shape::*perimetervar)(void);
+
+
+
diff --git a/Examples/java/mpointer/example.i b/Examples/java/mpointer/example.i
new file mode 100644
index 000000000..238792be8
--- /dev/null
+++ b/Examples/java/mpointer/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Some constants */
+
+%constant double (Shape::*AREAPT)(void) = &Shape::area;
+%constant double (Shape::*PERIMPT)(void) = &Shape::perimeter;
+%constant double (Shape::*NULLPT)(void) = 0;
+
diff --git a/Examples/java/mpointer/main.java b/Examples/java/mpointer/main.java
new file mode 100644
index 000000000..ab6cdf159
--- /dev/null
+++ b/Examples/java/mpointer/main.java
@@ -0,0 +1,61 @@
+// Example using pointers to member functions
+
+public class main {
+ 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[])
+ {
+ // Get the pointers
+
+ SWIGTYPE_m_Shape__f_void__double area_pt = example.areapt();
+ SWIGTYPE_m_Shape__f_void__double perim_pt = example.perimeterpt();
+
+ System.out.println( "area_pt =" + area_pt );
+ System.out.println( "perim_pt = " + perim_pt );
+
+ // Create some objects
+
+ Circle c = new Circle(4);
+ Square s = new Square(10);
+
+ // Do some calculations
+
+ System.out.println( "Circle area = " + example.do_op(c,area_pt) );
+ System.out.println( "Circle perim = " + example.do_op(c,perim_pt) );
+ System.out.println( "Square area = " + example.do_op(s,area_pt) );
+ System.out.println( "Square perim = " + example.do_op(s,perim_pt) );
+
+ System.out.println( "areavar = " + example.getAreavar() );
+ System.out.println( "perimetervar = " + example.getPerimetervar() );
+
+ // Try the variables
+ System.out.println( "Circle area = " + example.do_op(c,example.getAreavar()) );
+ System.out.println( "Circle perim = " + example.do_op(c,example.getPerimetervar()) );
+ System.out.println( "Square area = " + example.do_op(s,example.getAreavar()) );
+ System.out.println( "Square perim = " + example.do_op(s,example.getPerimetervar()) );
+
+ // Modify one of the variables
+ example.setAreavar(perim_pt);
+
+ System.out.println( "Circle perimeter = " + example.do_op(c,example.getAreavar()) );
+
+ // Try the constants
+
+ System.out.println( "example.AREAPT =" + example.AREAPT );
+ System.out.println( "example.PERIMPT=" + example.PERIMPT );
+ System.out.println( "example.NULLPT =" + example.NULLPT );
+
+ System.out.println( "Circle area = " + example.do_op(c,example.AREAPT) );
+ System.out.println( "Circle perim = " + example.do_op(c,example.PERIMPT) );
+ System.out.println( "Square area = " + example.do_op(s,example.AREAPT) );
+ System.out.println( "Square perim = " + example.do_op(s,example.PERIMPT) );
+
+ }
+}
diff --git a/Examples/java/multimap/.cvsignore b/Examples/java/multimap/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/multimap/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile
new file mode 100644
index 000000000..b1f254ed3
--- /dev/null
+++ b/Examples/java/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..d135481af
--- /dev/null
+++ b/Examples/java/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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.i b/Examples/java/multimap/example.i
new file mode 100644
index 000000000..6b0743001
--- /dev/null
+++ b/Examples/java/multimap/example.i
@@ -0,0 +1,101 @@
+/* File : example.i */
+%module example
+
+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/main.java b/Examples/java/multimap/main.java
new file mode 100644
index 000000000..331ac6b89
--- /dev/null
+++ b/Examples/java/multimap/main.java
@@ -0,0 +1,40 @@
+
+public class main {
+
+ 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/.cvsignore b/Examples/java/native/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/native/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile
index 1bd5ddd3a..e8b93c0d3 100644
--- a/Examples/java/native/Makefile
+++ b/Examples/java/native/Makefile
@@ -1,17 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../swig
-SWIGOPT =
SRCS =
-TARGET = libexample
+TARGET = example
INTERFACE = example.i
+SWIGOPT = -noproxy
all:: java
java::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
- rm -f *_wrap* example.java *.class *.o *~ .~* core *.so *.sl so_locations
+ $(MAKE) -f $(TOP)/Makefile java_clean
check: all
diff --git a/Examples/java/native/README b/Examples/java/native/README
deleted file mode 100644
index 2b5bbcdb4..000000000
--- a/Examples/java/native/README
+++ /dev/null
@@ -1,6 +0,0 @@
-type:
-make
-javac *.java
-export LD_LIBRARY_PATH=. # sh
-setenv LD_LIBRARY_PATH . # csh
-java main
diff --git a/Examples/java/native/example.i b/Examples/java/native/example.i
index 331a2265b..76ae9eea8 100644
--- a/Examples/java/native/example.i
+++ b/Examples/java/native/example.i
@@ -18,17 +18,17 @@ Point *point_create(int x, int y) {
return p;
}
-/* this function will be wrapped by jswig */
+/* this function will be wrapped by SWIG */
char *point_toString1(Point *p) {
- char buf[80];
+ static char buf[80];
sprintf(buf, "(%d,%d)", p->x, p->y);
- return strdup(buf); /* memory leak */
+ return buf;
}
/* this one we wrapped manually*/
-JNIEXPORT jstring JNICALL Java_example_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) {
+JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) {
Point * p;
char buf[80];
jstring result;
@@ -45,10 +45,8 @@ JNIEXPORT jstring JNICALL Java_example_point_1toString2(JNIEnv *jenv, jclass jcl
Point *point_create(int x, int y);
char *point_toString1(Point *p);
-/*
- Use %new to free the memory returned by point_toString1
- %new 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 000000000..1942d7440
--- /dev/null
+++ b/Examples/java/native/index.html
@@ -0,0 +1,33 @@
+<html>
+<head>
+<title>SWIG:Examples:java:native</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/native/</tt>
+<hr>
+
+<H2>SWIG wrapped and manually wrapped functions in Java</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example compares wrapping a c global function using the manual way and the SWIG way.
+
+<ul>
+<li><a href="example.i">example.i</a>. Interface file comparing code wrapped by SWIG and wrapped manually.
+<li><a href="main.java">main.java</a>. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>SWIG writes all the awkward JNI code for you. You just have to tell SWIG which functions to wrap.
+<li>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.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/native/main.java b/Examples/java/native/main.java
index 444d53b58..f4760bb3d 100644
--- a/Examples/java/native/main.java
+++ b/Examples/java/native/main.java
@@ -1,4 +1,3 @@
-import example;
public class main {
@@ -6,14 +5,15 @@ public class main {
try {
System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
- System.err.println("Cannot load the native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + 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[]) {
- long p = example.point_create(1, 2);
+ 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/.cvsignore b/Examples/java/pointer/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/pointer/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile
new file mode 100644
index 000000000..b1f254ed3
--- /dev/null
+++ b/Examples/java/pointer/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..b877d9a5b
--- /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 000000000..4483b0f77
--- /dev/null
+++ b/Examples/java/pointer/example.i
@@ -0,0 +1,24 @@
+/* File : example.i */
+%module example
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include 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 000000000..2be8d38d7
--- /dev/null
+++ b/Examples/java/pointer/index.html
@@ -0,0 +1,167 @@
+<html>
+<head>
+<title>SWIG:Examples:java:pointer</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/java/pointer/</tt>
+<hr>
+
+<H2>Simple Pointer Handling</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+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:
+
+<blockquote>
+<pre>
+void add(int *x, int *y, int *r) {
+ *r = *x + *y;
+}
+</pre>
+</blockquote>
+
+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?
+<p>
+
+
+<h2>Possible Solutions</h2>
+
+<ul>
+<li>Write some helper functions to explicitly create objects. For
+example:
+
+<blockquote>
+<pre>
+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);
+}
+</pre>
+</blockquote>
+
+<p>
+<li>The SWIG pointer library provides an easier way. <br>
+For example, in the interface file
+you would do this:
+
+<blockquote>
+<pre>
+%include cpointer.i
+%pointer_functions(int, intp);
+</pre>
+</blockquote>
+
+and from Java you would use pointers like this:
+
+<blockquote>
+<pre>
+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);
+</pre>
+</blockquote>
+
+<p>
+<li>Use the SWIG typemap library. This library allows you to completely
+change the way arguments are processed by SWIG. For example:
+
+<blockquote>
+<pre>
+%include "typemaps.i"
+void add(int *INPUT, int *INPUT, int *OUTPUT);
+</pre>
+</blockquote>
+
+And in a Java program:
+
+<blockquote>
+<pre>
+int[] r = {0};
+example.sub(37,42,r);
+System.out.println("Result =" + r[0]);
+</pre>
+</blockquote>
+Needless to say, this is substantially easier although a bit unusual.
+
+<p>
+<li>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:
+
+<blockquote>
+<pre>
+%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 ...
+</pre>
+</blockquote>
+
+</ul>
+
+<h2>Example</h2>
+
+The following example illustrates the use of these features for pointer
+extraction.
+
+<ul>
+<li> <a href="example.c">example.c</a> (C Source)
+<li> <a href="example.i">example.i</a> (Swig interface)
+<li> <a href="main.java">main.java</a> (Java program)
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>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.
+
+<p>
+<li>More documentation on the typemaps.i and cpointer.i library files can be
+found in the SWIG user manual. The files also contain documentation.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/pointer/main.java b/Examples/java/pointer/main.java
new file mode 100644
index 000000000..e96e02eaa
--- /dev/null
+++ b/Examples/java/pointer/main.java
@@ -0,0 +1,55 @@
+
+public class main {
+
+ 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/.cvsignore b/Examples/java/reference/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/reference/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile
new file mode 100644
index 000000000..69fb4e670
--- /dev/null
+++ b/Examples/java/reference/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..384e40bb7
--- /dev/null
+++ b/Examples/java/reference/example.cxx
@@ -0,0 +1,41 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+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)", 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 000000000..4915adb1b
--- /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 000000000..e71f297bf
--- /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 000000000..946bda0fa
--- /dev/null
+++ b/Examples/java/reference/index.html
@@ -0,0 +1,149 @@
+<html>
+<head>
+<title>SWIG:Examples:java:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+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.
+
+<h2>Some examples</h2>
+
+References are most commonly used as function parameter. For example,
+you might have an operator like this:
+
+<blockquote>
+<pre>
+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;
+}
+</pre>
+</blockquote>
+
+or a function:
+
+<blockquote>
+<pre>
+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;
+}
+</pre>
+</blockquote>
+
+In these cases, SWIG transforms everything into a pointer and creates a wrapper
+that looks like this:
+
+<blockquote>
+<pre>
+Vector wrap_addv(Vector *a, Vector *b) {
+ return addv(*a,*b);
+}
+</pre>
+</blockquote>
+
+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:
+
+<blockquote>
+<pre>
+Vector &operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &get(int index);
+</pre>
+</blockquote>
+
+For functions returning references, a wrapper like this is created:
+
+<blockquote>
+<pre>
+Vector *wrap_Object_get(Object *self, int index) {
+ Vector &result = self->get(index);
+ return &result;
+}
+</pre>
+</blockquote>
+
+The following <a href="example.h">header file</a> contains some class
+definitions with some operators and use of references.
+
+<h2>SWIG Interface</h2>
+
+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 <tt>addv()</tt> function above. Array access can be handled
+with a pair of set/get functions like this:
+
+<blockquote>
+<pre>
+class VectorArray {
+public:
+ ...
+ %addmethods {
+ Vector &get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*self)[index] = a;
+ }
+ }
+ ...
+}
+</pre>
+</blockquote>
+
+Click <a href="example.i">here</a> to see a SWIG interface file with these additions.
+
+<h2>Sample Java program</h2>
+
+Click <a href="main.java">here</a> to see a Java program that manipulates some C++ references.
+
+<h2>Notes:</h2>
+
+<ul>
+<li>C++ references primarily provide notational convenience for C++
+source code. However, Java only supports the 'x.a'
+notation so it doesn't much matter.
+
+<p>
+<li>When a program returns a reference, a pointer is returned.
+Unlike return by value, memory is not allocated to hold the
+return result.
+
+<p>
+<li>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.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/reference/main.java b/Examples/java/reference/main.java
new file mode 100644
index 000000000..4fd354761
--- /dev/null
+++ b/Examples/java/reference/main.java
@@ -0,0 +1,79 @@
+// This example illustrates the manipulation of C++ references in Java.
+
+public class main {
+ 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/.cvsignore b/Examples/java/simple/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/simple/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile
index f55601b9c..b1f254ed3 100644
--- a/Examples/java/simple/Makefile
+++ b/Examples/java/simple/Makefile
@@ -1,17 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../swig
SRCS = example.c
-TARGET = libexample
+TARGET = example
INTERFACE = example.i
-SWIGOPT =
+SWIGOPT =
all:: java
java::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
- rm -f *_wrap* *.o core *~ *.so *.class example.java
+ $(MAKE) -f $(TOP)/Makefile java_clean
check: all
diff --git a/Examples/java/simple/README b/Examples/java/simple/README
deleted file mode 100644
index b52b7d7b0..000000000
--- a/Examples/java/simple/README
+++ /dev/null
@@ -1,8 +0,0 @@
-Simple example from users manual.
-
-type:
-make
-javac *.java
-export LD_LIBRARY_PATH=. # sh
-setenv LD_LIBRARY_PATH . # csh
-java main
diff --git a/Examples/java/simple/example.c b/Examples/java/simple/example.c
index f2b074781..1c2af789c 100644
--- a/Examples/java/simple/example.c
+++ b/Examples/java/simple/example.c
@@ -1,24 +1,18 @@
-/* Simple example from documentation */
/* File : example.c */
-#include <time.h>
+/* A global variable */
+double Foo = 3.0;
-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);
+/* 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;
}
-char *get_time() {
- long ltime;
- time(&ltime);
- return ctime(&ltime);
-}
diff --git a/Examples/java/simple/example.dsp b/Examples/java/simple/example.dsp
new file mode 100644
index 000000000..7228d6cbb
--- /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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.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
index b7b678776..6702abb1e 100644
--- a/Examples/java/simple/example.i
+++ b/Examples/java/simple/example.i
@@ -1,11 +1,5 @@
/* File : example.i */
%module example
-%{
-/* Put headers and other declarations here */
-%}
-
-extern double My_variable;
-extern int fact(int);
-%name(mod) extern int my_mod(int n, int m);
-extern char *get_time();
+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 000000000..ac06b7302
--- /dev/null
+++ b/Examples/java/simple/index.html
@@ -0,0 +1,110 @@
+<html>
+<head>
+<title>SWIG:Examples:java:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/simple/</tt>
+<hr>
+
+<H2>Simple Java Example</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example illustrates how you can hook Java to a very simple C program containing
+a function and a global variable.
+
+<h2>The C Code</h2>
+
+Suppose you have the following C code:
+
+<blockquote>
+<pre>
+/* 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;
+}
+</pre>
+</blockquote>
+
+<h2>The SWIG interface</h2>
+
+Here is a simple SWIG interface file:
+
+<blockquote>
+<pre>
+/* File: example.i */
+%module example
+
+extern int gcd(int x, int y);
+extern double Foo;
+</pre>
+</blockquote>
+
+<h2>Compilation</h2>
+
+<ol>
+<li><tt>swig -java <a href="example.i">example.i</a></tt>
+<p>
+<li>Compile <tt><a href="example_wrap.c">example_wrap.c</a></tt> and <tt><a href="example.c">example.c</a></tt>
+to create the extension <tt>libexample.so (unix)</tt>.
+</ol>
+
+<h2>Using the extension</h2>
+
+Click <a href="main.java">here</a> to see a program that calls our C functions from Java.
+<p>
+Compile the java files <tt><a href="example.java">example.java</a></tt> and <tt><a href="main.java">main.java</a></tt>
+to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
+<blockquote>
+<pre>
+export LD_LIBRARY_PATH=. #ksh
+javac *.java
+java main
+</pre>
+</blockquote>
+
+<h2>Key points</h2>
+
+<ul>
+<li>Use the <tt>loadLibrary</tt> statement from java to load and access the generated java classes. For example:
+<blockquote>
+<pre>
+System.loadLibrary("example");
+</pre>
+</blockquote>
+
+<li>C functions work just like Java functions. For example:
+<blockquote>
+<pre>
+int g = example.gcd(42,105);
+</pre>
+</blockquote>
+
+<li>C global variables are accessed through get and set functions in the module class. For example:
+<blockquote>
+<pre>
+double a = example.get_Foo();
+example.set_Foo(20.0);
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/simple/main.java b/Examples/java/simple/main.java
index bbebfb660..6d224a4dc 100644
--- a/Examples/java/simple/main.java
+++ b/Examples/java/simple/main.java
@@ -1,4 +1,3 @@
-import example;
public class main {
@@ -6,27 +5,28 @@ public class main {
try {
System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
- System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + 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(example.get_time());
-
- System.out.println("My Variable = " + example.get_My_variable());
-
- for(int i=0; i<14; i++) {
- System.out.println("" + i + " factorial is " + example.fact(i));
- }
-
- for(int i=1; i<100; i++) {
- for(int j=1; j<100; j++) {
- int n = example.mod(i, j);
- example.set_My_variable(example.get_My_variable() + n);
- }
- }
-
- System.out.println("My_variable = " + example.get_My_variable());
+ // 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/.cvsignore b/Examples/java/template/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/template/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile
new file mode 100644
index 000000000..75ec0045a
--- /dev/null
+++ b/Examples/java/template/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..4d9a58c54
--- /dev/null
+++ b/Examples/java/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template<class T> T max(T a, T b) { return a>b ? a : b; }
+
+template<class T> 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 000000000..8f94c4da1
--- /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<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html
new file mode 100644
index 000000000..f8fcce08e
--- /dev/null
+++ b/Examples/java/template/index.html
@@ -0,0 +1,104 @@
+<html>
+<head>
+<title>SWIG:Examples:java:template</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/template/</tt>
+<hr>
+
+<H2>C++ template support</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example illustrates how C++ templates can be used from Java using SWIG.
+
+<h2>The C++ Code</h2>
+
+Lets take a templated function and a templated class as follows:
+
+<blockquote>
+<pre>
+/* File : example.h */
+
+// Some template definitions
+
+template<class T> T max(T a, T b) { return a&gt;b ? a : b; }
+
+template<class T> 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-&gt;get(index);
+ }
+ void setitem(int index, T val) {
+ self-&gt;set(index,val);
+ }
+ }
+#endif
+};
+</pre>
+</blockquote>
+The %addmethods is used for a neater interface from Java as the functions <tt>get</tt> and <tt>set</tt> use C++ references to primitive types. These are tricky to use from Java as they end up as a pointer in Java (Java long).
+
+<h2>The SWIG interface</h2>
+
+A simple SWIG interface for this can be built by simply grabbing the header file
+like this:
+
+<blockquote>
+<pre>
+/* 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<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+</pre>
+</blockquote>
+
+Note that SWIG parses the templated function <tt>max</tt> and templated class <tt>vector</tt> 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.
+
+<h2>A sample Java program</h2>
+
+Click <a href="main.java">here</a> to see a Java program that calls the C++ functions from Java.
+
+<h2>Notes</h2>
+Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive.
+
+<blockquote>
+<pre>
+vecdouble dv = new vecdouble(1000);
+dv.setitem(i, 12.34));
+</pre>
+</blockquote>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/template/main.java b/Examples/java/template/main.java
new file mode 100644
index 000000000..9129fcf2a
--- /dev/null
+++ b/Examples/java/template/main.java
@@ -0,0 +1,45 @@
+// This example illustrates how C++ templates can be used from Java.
+
+public class main {
+ 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/.cvsignore b/Examples/java/typemap/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/typemap/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile
index ddba664d9..e8b93c0d3 100644
--- a/Examples/java/typemap/Makefile
+++ b/Examples/java/typemap/Makefile
@@ -1,17 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../swig
SRCS =
-TARGET = libexample
+TARGET = example
INTERFACE = example.i
-SWIGOPT =
+SWIGOPT = -noproxy
all:: java
java::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
clean::
- rm -f *_wrap* *.o core *~ *.so *.class example.java
+ $(MAKE) -f $(TOP)/Makefile java_clean
check: all
diff --git a/Examples/java/typemap/README b/Examples/java/typemap/README
deleted file mode 100644
index 67dabbfdc..000000000
--- a/Examples/java/typemap/README
+++ /dev/null
@@ -1,8 +0,0 @@
-Example of a typemap to handle return values in char * arguments.
-
-type:
-make
-javac *.java
-export LD_LIBRARY_PATH=. # sh
-setenv LD_LIBRARY_PATH . # csh
-java main
diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html
new file mode 100644
index 000000000..259f42953
--- /dev/null
+++ b/Examples/java/typemap/index.html
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>SWIG:Examples:java:typemap</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/typemap/</tt>
+<hr>
+
+<H2>Typemaps in Java</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example shows how typemaps can be used to modify the default behaviour of the Java SWIG module.
+
+<ul>
+<li><a href="example.i">example.i</a>. Interface file.
+<li><a href="main.java">main.java</a>. Sample Java program.
+</ul>
+
+<h2>Notes</h2>
+
+<ul>
+<li>Shows how to pass strings to Java from c and visa versa.
+<li>Typemaps can modify the default behaviour of the Java SWIG module.
+<li>The default c to java mapping can be modified using typemaps.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/java/typemap/main.java b/Examples/java/typemap/main.java
index f7da20cdc..bd9a4e1b6 100644
--- a/Examples/java/typemap/main.java
+++ b/Examples/java/typemap/main.java
@@ -1,4 +1,3 @@
-import example;
public class main {
@@ -6,7 +5,7 @@ public class main {
try {
System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
- System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + 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);
}
}
diff --git a/Examples/java/variables/.cvsignore b/Examples/java/variables/.cvsignore
new file mode 100644
index 000000000..49312b8c6
--- /dev/null
+++ b/Examples/java/variables/.cvsignore
@@ -0,0 +1,11 @@
+*.class
+*.java
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile
new file mode 100644
index 000000000..b1f254ed3
--- /dev/null
+++ b/Examples/java/variables/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..37e9feb33
--- /dev/null
+++ b/Examples/java/variables/example.c
@@ -0,0 +1,86 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+#include <stdio.h>
+#include <stdlib.h>
+#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 = 0;
+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 = %x\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %x (%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 000000000..0f7e89594
--- /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 000000000..91bd0679d
--- /dev/null
+++ b/Examples/java/variables/example.i
@@ -0,0 +1,44 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char *cstrvar;
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+
+
+/* Some read-only variables */
+
+%immutable;
+extern int status;
+extern char path[256];
+%mutable;
+
+/* Some helper functions to make it easier to test */
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+
+
+
+
diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html
new file mode 100644
index 000000000..efb6f9d9b
--- /dev/null
+++ b/Examples/java/variables/index.html
@@ -0,0 +1,85 @@
+<html>
+<head>
+<title>SWIG:Examples:java:variables</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/java/variables/</tt>
+<hr>
+
+<H2>Wrapping C Global Variables</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+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 <a href="example.i">here</a> to see a SWIG interface with some variable
+declarations in it.
+
+<h2>Manipulating Variables from Java</h2>
+
+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
+
+<blockquote>
+<pre>
+double foo;
+</pre>
+</blockquote>
+
+will be accessed in the Java module as
+<blockquote>
+<pre>
+example.get_foo();
+example.set_foo(12.3);
+</pre>
+</blockquote>
+
+Click <a href="main.java">here</a> to see the example program that updates and prints
+out the values of the variables using this technique.
+
+<h2>Key points</h2>
+
+<ul>
+<li>When a global variable has the type "<tt>char *</tt>", 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 <tt>free()</tt> or <tt>delete</tt> (the choice of which depends
+on whether or not SWIG was run with the -c++ option).
+<li><tt>signed char</tt> and <tt>unsigned char</tt> are handled as small 8-bit integers.
+<li>String array variables such as '<tt>char name[256]</tt>' 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.
+<li>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.
+</ul>
+
+<h2>Creating read-only variables</h2>
+
+The <tt>%immutable</tt> and <tt>%mutable</tt> directives can be used to
+specify a collection of read-only variables. For example:
+
+<blockquote>
+<pre>
+%immutable;
+int status;
+double blah;
+...
+%mutable;
+</pre>
+</blockquote>
+
+The <tt>%immutable</tt> directive remains in effect until it is explicitly disabled
+using the <tt>%mutable</tt> directive.
+
+<h2>Comments</h2>
+<ul>
+<li>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.
+</ul>
+
+</body>
+</html>
+<hr>
diff --git a/Examples/java/variables/main.java b/Examples/java/variables/main.java
new file mode 100644
index 000000000..f0a760b00
--- /dev/null
+++ b/Examples/java/variables/main.java
@@ -0,0 +1,98 @@
+// This example illustrates global variable access from Java.
+
+import java.lang.reflect.*;
+
+public class main {
+ 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.setCstrvar("Goodbye");
+ 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/mzscheme/check.list b/Examples/mzscheme/check.list
new file mode 100644
index 000000000..ae728ea43
--- /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 000000000..5ac93f8f0
--- /dev/null
+++ b/Examples/mzscheme/multimap/Makefile
@@ -0,0 +1,13 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..d135481af
--- /dev/null
+++ b/Examples/mzscheme/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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 000000000..6ca7dc33e
--- /dev/null
+++ b/Examples/mzscheme/multimap/example.i
@@ -0,0 +1,81 @@
+/* File : example.i */
+%module example
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(mzscheme,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(mzscheme,freear) (int argc, char *argv[]) {
+ free($2);
+}
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(mzscheme,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(mzscheme,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(mzscheme,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 000000000..ac9f64283
--- /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/.cvsignore b/Examples/mzscheme/simple/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/Examples/mzscheme/simple/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile
index c8e5242b3..5ac93f8f0 100644
--- a/Examples/mzscheme/simple/Makefile
+++ b/Examples/mzscheme/simple/Makefile
@@ -8,6 +8,6 @@ all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
clean::
- rm -f *_wrap* *.o core *~ *.so
+ $(MAKE) -f $(TOP)/Makefile mzscheme_clean
check: all
diff --git a/Examples/mzscheme/std_vector/.cvsignore b/Examples/mzscheme/std_vector/.cvsignore
new file mode 100644
index 000000000..bd7dd8a57
--- /dev/null
+++ b/Examples/mzscheme/std_vector/.cvsignore
@@ -0,0 +1 @@
+example_wrap.cxx
diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile
new file mode 100644
index 000000000..587173b44
--- /dev/null
+++ b/Examples/mzscheme/std_vector/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../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 000000000..4f0dac70d
--- /dev/null
+++ b/Examples/mzscheme/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h */
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<double> half(const std::vector<double>& v) {
+ std::vector<double> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::vector<double>& v) {
+ // would you believe this is the same as the above?
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+
diff --git a/Examples/mzscheme/std_vector/example.i b/Examples/mzscheme/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /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<int>;
+ %template(DoubleVector) vector<double>;
+}
+
+/* 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 000000000..0e4ac3f97
--- /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<int>
+(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<double>
+(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<double> in place
+(halve-in-place v)
+(print-doublevector v)
+(delete-doublevector v)
+
diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list
new file mode 100644
index 000000000..d38998cab
--- /dev/null
+++ b/Examples/ocaml/check.list
@@ -0,0 +1,2 @@
+# see top-level Makefile.in
+simple
diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile
new file mode 100644
index 000000000..bac7edf47
--- /dev/null
+++ b/Examples/ocaml/simple/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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
+
+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 000000000..1c2af789c
--- /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.dsp b/Examples/ocaml/simple/example.dsp
new file mode 100644
index 000000000..e905647a5
--- /dev/null
+++ b/Examples/ocaml/simple/example.dsp
@@ -0,0 +1,148 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PYTHON_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 "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PYTHON_LIB) /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/ocaml/simple/example.i b/Examples/ocaml/simple/example.i
new file mode 100644
index 000000000..6702abb1e
--- /dev/null
+++ b/Examples/ocaml/simple/example.i
@@ -0,0 +1,5 @@
+/* File : example.i */
+%module example
+
+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 000000000..5dafdc219
--- /dev/null
+++ b/Examples/ocaml/simple/example_prog.ml
@@ -0,0 +1,37 @@
+(* example_prog.ml *)
+
+open Example
+
+(* Call our gcd() function *)
+
+exception NoReturn
+
+let single_int x =
+ match x with C_int a -> a | _ -> raise NoReturn
+let get_float x =
+ match x with C_float f -> f | C_double f -> f | _ -> raise NoReturn
+
+let x = 42
+let y = 105
+let g = single_int (_gcd (C_list [ C_int x ; C_int y ]))
+let _ = Printf.printf "The gcd of %d and %d is %d\n" x y g
+
+(* Manipulate the Foo global variable *)
+
+(* Output its current value *)
+let _ = Printf.printf "Foo = %f\n" (get_float (_Foo C_void))
+
+(* Change its value *)
+let _ = _Foo (C_float 3.1415926)
+
+(* See if the change took effect *)
+let _ = Printf.printf "Foo = %f\n" (get_float (_Foo C_void))
+
+
+
+
+
+
+
+
+
diff --git a/Examples/ocaml/simple/index.html b/Examples/ocaml/simple/index.html
new file mode 100644
index 000000000..9638708cc
--- /dev/null
+++ b/Examples/ocaml/simple/index.html
@@ -0,0 +1,99 @@
+<html>
+<head>
+<title>SWIG:Examples:python:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/simple/</tt>
+<hr>
+
+<H2>Simple Python Example</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example illustrates how you can hook Python to a very simple C program containing
+a function and a global variable.
+
+<h2>The C Code</h2>
+
+Suppose you have the following C code:
+
+<blockquote>
+<pre>
+/* 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;
+}
+</pre>
+</blockquote>
+
+<h2>The SWIG interface</h2>
+
+Here is a simple SWIG interface file:
+
+<blockquote>
+<pre>
+/* File: example.i */
+%module example
+
+extern int gcd(int x, int y);
+extern double Foo;
+</pre>
+</blockquote>
+
+<h2>Compilation</h2>
+
+<ol>
+<li><tt>swig -python <a href="example.i">example.i</a></tt>
+<p>
+<li>Compile <tt><a href="example_wrap.c">example_wrap.c</a></tt> and <tt><a href="example.c">example.c</a></tt>
+to create the extension <tt>examplemodule.so</tt>.
+</ol>
+
+<h2>Using the extension</h2>
+
+Click <a href="example.py">here</a> to see a script that calls our C functions from Python.
+
+<h2>Key points</h2>
+
+<ul>
+<li>Use the <tt>import</tt> statement to load your extension module from Python. For example:
+<blockquote>
+<pre>
+import example
+</pre>
+</blockquote>
+
+<li>C functions work just like Python functions. For example:
+<blockquote>
+<pre>
+g = example.gcd(42,105)
+</pre>
+</blockquote>
+
+<li>C global variables are accessed through a special variable called 'cvar'. For example:
+<blockquote>
+<pre>
+a = example.cvar.Foo
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/perl5/check.list b/Examples/perl5/check.list
new file mode 100644
index 000000000..abaa4e017
--- /dev/null
+++ b/Examples/perl5/check.list
@@ -0,0 +1,13 @@
+# see top-level Makefile.in
+class
+constants
+constants2
+funcptr
+import
+multimap
+pointer
+reference
+shadow
+simple
+value
+variables
diff --git a/Examples/perl5/class/.cvsignore b/Examples/perl5/class/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/class/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/class/Makefile b/Examples/perl5/class/Makefile
index e0483a897..8b8ae7f72 100644
--- a/Examples/perl5/class/Makefile
+++ b/Examples/perl5/class/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so myperl *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/class/example.cxx b/Examples/perl5/class/example.cxx
index 21582f4d1..1e8e203dd 100644
--- a/Examples/perl5/class/example.cxx
+++ b/Examples/perl5/class/example.cxx
@@ -1,7 +1,7 @@
/* File : example.c */
#include "example.h"
-#include <math.h>
+#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area() {
+double Circle::area(void) {
return M_PI*radius*radius;
}
-double Circle::perimeter() {
+double Circle::perimeter(void) {
return 2*M_PI*radius;
}
-double Square::area() {
+double Square::area(void) {
return width*width;
}
-double Square::perimeter() {
+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 000000000..2d7734aca
--- /dev/null
+++ b/Examples/perl5/class/example.dsp
@@ -0,0 +1,150 @@
+# 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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PERL5_INCLUDE)/perl.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PERL5_INCLUDE)/perl.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 on
+ ..\..\..\swig -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 on
+ ..\..\..\swig -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
index 849071dd3..46d901361 100644
--- a/Examples/perl5/class/example.h
+++ b/Examples/perl5/class/example.h
@@ -10,8 +10,8 @@ public:
};
double x, y;
void move(double dx, double dy);
- virtual double area() = 0;
- virtual double perimeter() = 0;
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
static int nshapes;
};
@@ -20,8 +20,8 @@ private:
double radius;
public:
Circle(double r) : radius(r) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
class Square : public Shape {
@@ -29,8 +29,8 @@ private:
double width;
public:
Square(double w) : width(w) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
diff --git a/Examples/perl5/class/example.pl b/Examples/perl5/class/example.pl
index c14160e92..02e7a889b 100644
--- a/Examples/perl5/class/example.pl
+++ b/Examples/perl5/class/example.pl
@@ -20,12 +20,12 @@ print "\nA total of $example::Shape_nshapes shapes were created\n";
# ----- Member data access -----
-# Set the location of the object
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
example::Shape_x_set($c, 20);
example::Shape_y_set($c, 30);
-
-# Now use the same functions in the base class
example::Shape_x_set($s,-10);
example::Shape_y_set($s,5);
diff --git a/Examples/perl5/class/index.html b/Examples/perl5/class/index.html
index 05627e8fb..8ca90bf55 100644
--- a/Examples/perl5/class/index.html
+++ b/Examples/perl5/class/index.html
@@ -109,14 +109,13 @@ For example:
<blockquote>
<pre>
-example::Circle_x_set($c,15); # Set member data
+example::Shape_x_set($c,15); # Set member data
$x = example::Shape_x_get($c); # Get member data
</pre>
</blockquote>
-Note: when accessing member data, the name of the base class or the derived class can be
-used in the function name as shown above. Of course, it would probably be more
-proper to just use the base class version such as <tt>Shape_x_get()</tt>
+Note: when accessing member data, the name of the class in which
+the data member is defined is used. For example <tt>Shape_x_get()</tt>.
<p>
<li>To invoke a member function, you simply do this
@@ -204,28 +203,6 @@ to write a helper function. For example:
<p>
<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
-<p>
-<li>Templates. Not supported at all. SWIG throws out anything that looks like a template.
-You can work around the problem by aliasing a template class behind a typedef however.
-For example:
-
-<blockquote>
-<pre>
-%{
-typedef vector<int> IntVector;
-%}
-
-class IntVector {
-public:
- ... methods ...
-};
-</pre>
-</blockquote>
-</ul>
-<p>
-<li>There is no guarantee that an extremely complex C++ application will be able to compile
-as a Python extension. Sorry.
-
</ul>
<hr>
diff --git a/Examples/perl5/constants/.cvsignore b/Examples/perl5/constants/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/constants/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/constants/Makefile b/Examples/perl5/constants/Makefile
index 428f9f5cd..c1e2bf29e 100644
--- a/Examples/perl5/constants/Makefile
+++ b/Examples/perl5/constants/Makefile
@@ -13,6 +13,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o core *~ *.so *.pm myperl
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/constants/example.i b/Examples/perl5/constants/example.i
index 29a1a7f11..4f7b1a4d7 100644
--- a/Examples/perl5/constants/example.i
+++ b/Examples/perl5/constants/example.i
@@ -19,8 +19,9 @@
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
-/* The following statements also produce constants */
-const int iconst = 37;
-const double fconst = 3.14;
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
diff --git a/Examples/perl5/constants2/.cvsignore b/Examples/perl5/constants2/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/constants2/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/constants2/Makefile b/Examples/perl5/constants2/Makefile
new file mode 100644
index 000000000..50b3fe046
--- /dev/null
+++ b/Examples/perl5/constants2/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT = -const
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/Examples/perl5/constants2/example.i b/Examples/perl5/constants2/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/Examples/perl5/constants2/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/perl5/constants2/example.pl b/Examples/perl5/constants2/example.pl
new file mode 100644
index 000000000..65682e68b
--- /dev/null
+++ b/Examples/perl5/constants2/example.pl
@@ -0,0 +1,16 @@
+# file: example.pl
+
+use example;
+
+print "ICONST = ", example::ICONST, " (should be 42)\n";
+print "FCONST = ", example::FCONST, " (should be 2.1828)\n";
+print "CCONST = ", example::CCONST, " (should be 'x')\n";
+print "CCONST2 = ", example::CCONST2," (this should be on a new line)\n";
+print "SCONST = ", example::SCONST, " (should be 'Hello World')\n";
+print "SCONST2 = ", example::SCONST2, " (should be '\"Hello World\"')\n";
+print "EXPR = ", example::EXPR, " (should be 48.5484)\n";
+print "iconst = ", example::iconst, " (should be 37)\n";
+print "fconst = ", example::fconst, " (should be 3.14)\n";
+
+
+
diff --git a/Examples/perl5/funcptr/.cvsignore b/Examples/perl5/funcptr/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/funcptr/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/funcptr/Makefile b/Examples/perl5/funcptr/Makefile
index e5944f9af..ef644a35f 100644
--- a/Examples/perl5/funcptr/Makefile
+++ b/Examples/perl5/funcptr/Makefile
@@ -13,6 +13,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o core *~ *.so *.pm myperl
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/funcptr/example.c b/Examples/perl5/funcptr/example.c
index 99583b72e..5c4a3dabf 100644
--- a/Examples/perl5/funcptr/example.c
+++ b/Examples/perl5/funcptr/example.c
@@ -15,3 +15,5 @@ int sub(int a, int b) {
int mul(int a, int b) {
return a*b;
}
+
+int (*funcvar)(int,int) = add;
diff --git a/Examples/perl5/funcptr/example.i b/Examples/perl5/funcptr/example.i
index 73cc6eb8c..8b3bef678 100644
--- a/Examples/perl5/funcptr/example.i
+++ b/Examples/perl5/funcptr/example.i
@@ -8,8 +8,9 @@
extern int do_op(int a, int b, int (*op)(int, int));
/* Now install a bunch of "ops" as constants */
-%constant(int (*)(int,int)) ADD = add;
-%constant(int (*)(int,int)) SUB = sub;
-%constant(int (*)(int,int)) MUL = mul;
+%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/perl5/import/.cvsignore b/Examples/perl5/import/.cvsignore
new file mode 100644
index 000000000..96e7844ab
--- /dev/null
+++ b/Examples/perl5/import/.cvsignore
@@ -0,0 +1,14 @@
+baseclass.pm
+example.pm
+foo.pm
+bar.pm
+spam.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/import/Makefile b/Examples/perl5/import/Makefile
new file mode 100644
index 000000000..fb66eb38e
--- /dev/null
+++ b/Examples/perl5/import/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -c -shadow
+#If your system requires linking with the runtime libraries then set the directory location here
+RUNTIMEDIR =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='baseclass' INTERFACE='base.i' perl5_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='foo' INTERFACE='foo.i' perl5_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='bar' INTERFACE='bar.i' perl5_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='spam' INTERFACE='spam.i' perl5_multi_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/Examples/perl5/import/README b/Examples/perl5/import/README
new file mode 100644
index 000000000..64faee271
--- /dev/null
+++ b/Examples/perl5/import/README
@@ -0,0 +1,28 @@
+This example tests the SWIG run-time libraries and use of the
+%import directive to work with multiple modules.
+
+Use 'perl runme.pl' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is working correctly, all of the modules will load
+correctly and type checking will work correctly. The
+example requires the use of the SWIG run-time libraries
+which must be built and properly installed.
+
+
+
+
diff --git a/Examples/perl5/import/bar.h b/Examples/perl5/import/bar.h
new file mode 100644
index 000000000..fa4185f1f
--- /dev/null
+++ b/Examples/perl5/import/bar.h
@@ -0,0 +1,22 @@
+#include "base.h"
+
+class Bar : public Base {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual void A() {
+ printf("I'm Bar::A\n");
+ }
+ void B() {
+ printf("I'm Bar::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Bar *fromBase(Base *b) {
+ return dynamic_cast<Bar *>(b);
+ }
+
+};
+
+
diff --git a/Examples/perl5/import/bar.i b/Examples/perl5/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/Examples/perl5/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/Examples/perl5/import/base.h b/Examples/perl5/import/base.h
new file mode 100644
index 000000000..be3cdef7d
--- /dev/null
+++ b/Examples/perl5/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/Examples/perl5/import/base.i b/Examples/perl5/import/base.i
new file mode 100644
index 000000000..dc99383a7
--- /dev/null
+++ b/Examples/perl5/import/base.i
@@ -0,0 +1,6 @@
+%module baseclass
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/Examples/perl5/import/foo.h b/Examples/perl5/import/foo.h
new file mode 100644
index 000000000..dd5184031
--- /dev/null
+++ b/Examples/perl5/import/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+class Foo : public Base {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual void A() {
+ printf("I'm Foo::A\n");
+ }
+ void B() {
+ printf("I'm Foo::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Foo *fromBase(Base *b) {
+ return dynamic_cast<Foo *>(b);
+ }
+};
+
+
diff --git a/Examples/perl5/import/foo.i b/Examples/perl5/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/Examples/perl5/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/Examples/perl5/import/runme.pl b/Examples/perl5/import/runme.pl
new file mode 100644
index 000000000..ea71f3dc1
--- /dev/null
+++ b/Examples/perl5/import/runme.pl
@@ -0,0 +1,116 @@
+# file: runme.pl
+# Test various properties of classes defined in separate modules
+
+print "Testing the %import directive\n";
+use baseclass;
+use foo;
+use bar;
+use spam;
+
+# Create some objects
+
+print "Creating some objects\n";
+
+$a = new baseclass::Base();
+$b = new foo::Foo();
+$c = new bar::Bar();
+$d = new spam::Spam();
+
+# Try calling some methods
+print "Testing some methods\n";
+print "Should see 'Base::A' ---> ";
+$a->A();
+print "Should see 'Base::B' ---> ";
+$a->B();
+
+print "Should see 'Foo::A' ---> ";
+$b->A();
+print "Should see 'Foo::B' ---> ";
+$b->B();
+
+print "Should see 'Bar::A' ---> ";
+$c->A();
+print "Should see 'Bar::B' ---> ";
+$c->B();
+
+print "Should see 'Spam::A' ---> ";
+$d->A();
+print "Should see 'Spam::B' ---> ";
+$d->B();
+
+# Try some casts
+
+print "\nTesting some casts\n";
+
+$x = $a->toBase();
+print "Should see 'Base::A' ---> ";
+$x->A();
+print "Should see 'Base::B' ---> ";
+$x->B();
+
+$x = $b->toBase();
+print "Should see 'Foo::A' ---> ";
+$x->A();
+
+print "Should see 'Base::B' ---> ";
+$x->B();
+
+$x = $c->toBase();
+print "Should see 'Bar::A' ---> ";
+$x->A();
+
+print "Should see 'Base::B' ---> ";
+$x->B();
+
+$x = $d->toBase();
+print "Should see 'Spam::A' ---> ";
+$x->A();
+
+print "Should see 'Base::B' ---> ";
+$x->B();
+
+$x = $d->toBar();
+print "Should see 'Bar::B' ---> ";
+$x->B();
+
+print "\nTesting some dynamic casts\n";
+$x = $d->toBase();
+
+print " Spam -> Base -> Foo : ";
+$y = foo::Foo_fromBase($x);
+if ($y) {
+ print "bad swig\n";
+} else {
+ print "good swig\n";
+}
+
+print " Spam -> Base -> Bar : ";
+$y = bar::Bar_fromBase($x);
+if ($y) {
+ print "good swig\n";
+} else {
+ print "bad swig\n";
+}
+
+print " Spam -> Base -> Spam : ";
+$y = spam::Spam_fromBase($x);
+if ($y) {
+ print "good swig\n";
+} else {
+ print "bad swig\n";
+}
+
+print " Foo -> Spam : ";
+#print $b;
+$y = spam::Spam_fromBase($b);
+print $y;
+if ($y) {
+ print "bad swig\n";
+} else {
+ print "good swig\n";
+}
+
+
+
+
+
diff --git a/Examples/perl5/import/spam.h b/Examples/perl5/import/spam.h
new file mode 100644
index 000000000..b4e7a2646
--- /dev/null
+++ b/Examples/perl5/import/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+class Spam : public Bar {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual void A() {
+ printf("I'm Spam::A\n");
+ }
+ void B() {
+ printf("I'm Spam::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ virtual Bar *toBar() {
+ return static_cast<Bar *>(this);
+ }
+ static Spam *fromBase(Base *b) {
+ return dynamic_cast<Spam *>(b);
+ }
+};
+
+
diff --git a/Examples/perl5/import/spam.i b/Examples/perl5/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/Examples/perl5/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/Examples/perl5/index.html b/Examples/perl5/index.html
index 9f6556cd6..119f7b241 100644
--- a/Examples/perl5/index.html
+++ b/Examples/perl5/index.html
@@ -66,7 +66,8 @@ The examples have been extensively tested on the following platforms:
<li>Solaris
</ul>
-<p>
+Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
+
The most recent version of Perl used for testing is as follows:
<blockquote>
diff --git a/Examples/perl5/multimap/.cvsignore b/Examples/perl5/multimap/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/multimap/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/multimap/Makefile b/Examples/perl5/multimap/Makefile
new file mode 100644
index 000000000..ef644a35f
--- /dev/null
+++ b/Examples/perl5/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' perl5
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/Examples/perl5/multimap/example.c b/Examples/perl5/multimap/example.c
new file mode 100644
index 000000000..d135481af
--- /dev/null
+++ b/Examples/perl5/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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/perl5/multimap/example.dsp b/Examples/perl5/multimap/example.dsp
new file mode 100644
index 000000000..d3a197f0c
--- /dev/null
+++ b/Examples/perl5/multimap/example.dsp
@@ -0,0 +1,146 @@
+# 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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PERL5_INCLUDE)/perl.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PERL5_INCLUDE)/perl.lib /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo on
+ ..\..\..\swig -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo on
+ ..\..\..\swig -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/perl5/multimap/example.i b/Examples/perl5/multimap/example.i
new file mode 100644
index 000000000..c162c0019
--- /dev/null
+++ b/Examples/perl5/multimap/example.i
@@ -0,0 +1,81 @@
+/* File : example.i */
+%module example
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(perl5,in) (int argc, char *argv[]) {
+ AV *tempav;
+ SV **tv;
+ I32 len;
+ int i;
+ if (!SvROK($input)) {
+ SWIG_exception(SWIG_ValueError,"$input is not an array.");
+ }
+ if (SvTYPE(SvRV($input)) != SVt_PVAV) {
+ SWIG_exception(SWIG_ValueError,"$input is not an array.");
+ }
+ tempav = (AV*)SvRV($input);
+ len = av_len(tempav);
+ $1 = (int) len+1;
+ $2 = (char **) malloc($1*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ tv = av_fetch(tempav, i, 0);
+ $2[i] = (char *) SvPV(*tv,PL_na);
+ }
+ $2[i] = 0;
+}
+
+%typemap(perl5,freearg) (int argc, char *argv[]) {
+ free($2);
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(perl5,in) (char *bytes, int len) {
+ unsigned int temp;
+ $1 = (char *) SvPV($input, temp);
+ $2 = (int) temp;
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(perl5,in) (char *str, int len) {
+ unsigned int templen;
+ char *temp;
+ temp = (char *) SvPV($input,templen);
+ $2 = (int) templen;
+ $1 = (char *) malloc($2+1);
+ memmove($1,temp,$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(perl5,argout) (char *str, int len) {
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $result = sv_newmortal();
+ sv_setpvn((SV*)ST(argvi++),$1,$2);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/Examples/perl5/multimap/example.pl b/Examples/perl5/multimap/example.pl
new file mode 100755
index 000000000..9c86633f9
--- /dev/null
+++ b/Examples/perl5/multimap/example.pl
@@ -0,0 +1,28 @@
+# file: example.pl
+
+use example;
+
+# Call our gcd() function
+
+$x = 42;
+$y = 105;
+$g = example::gcd($x,$y);
+print "The gcd of $x and $y is $g\n";
+
+# Call the gcdmain() function
+@a = ("gcdmain","42","105");
+example::gcdmain(\@a);
+
+# Call the count function
+print example::count("Hello World", "l"),"\n";
+
+# Call the capitize function
+
+print example::capitalize("hello world"),"\n";
+
+
+
+
+
+
+
diff --git a/Examples/perl5/pointer/.cvsignore b/Examples/perl5/pointer/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/pointer/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/pointer/Makefile b/Examples/perl5/pointer/Makefile
index e5944f9af..ef644a35f 100644
--- a/Examples/perl5/pointer/Makefile
+++ b/Examples/perl5/pointer/Makefile
@@ -13,6 +13,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o core *~ *.so *.pm myperl
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/pointer/example.i b/Examples/perl5/pointer/example.i
index 2ed2b5bbf..4483b0f77 100644
--- a/Examples/perl5/pointer/example.i
+++ b/Examples/perl5/pointer/example.i
@@ -6,7 +6,8 @@
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
-%include pointer.i
+%include cpointer.i
+%pointer_functions(int, intp);
/* Next we'll use some typemaps */
diff --git a/Examples/perl5/pointer/example.pl b/Examples/perl5/pointer/example.pl
index dc18144cf..9d9711dd0 100644
--- a/Examples/perl5/pointer/example.pl
+++ b/Examples/perl5/pointer/example.pl
@@ -4,9 +4,11 @@ use example;
# First create some objects using the pointer library.
print "Testing the pointer library\n";
-$a = example::ptrcreate("int",37);
-$b = example::ptrcreate("int",42);
-$c = example::ptrcreate("int");
+$a = example::new_intp();
+$b = example::new_intp();
+$c = example::new_intp();
+example::intp_assign($a,37);
+example::intp_assign($b,42);
print " a = $a\n";
print " b = $b\n";
@@ -16,13 +18,13 @@ print " c = $c\n";
example::add($a,$b,$c);
# Now get the result
-$r = example::ptrvalue($c);
+$r = example::intp_value($c);
print " 37 + 42 = $r\n";
# Clean up the pointers
-example::ptrfree($a);
-example::ptrfree($b);
-example::ptrfree($c);
+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
diff --git a/Examples/perl5/reference/.cvsignore b/Examples/perl5/reference/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/reference/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/reference/Makefile b/Examples/perl5/reference/Makefile
index e0483a897..8b8ae7f72 100644
--- a/Examples/perl5/reference/Makefile
+++ b/Examples/perl5/reference/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so myperl *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/reference/example.i b/Examples/perl5/reference/example.i
index 8538326f6..e71f297bf 100644
--- a/Examples/perl5/reference/example.i
+++ b/Examples/perl5/reference/example.i
@@ -31,7 +31,7 @@ public:
int size();
/* This wrapper provides an alternative to the [] operator */
- %addmethods {
+ %extend {
Vector &get(int index) {
return (*self)[index];
}
diff --git a/Examples/perl5/shadow/.cvsignore b/Examples/perl5/shadow/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/shadow/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/shadow/Makefile b/Examples/perl5/shadow/Makefile
index 36f9d099c..99b6c40c1 100644
--- a/Examples/perl5/shadow/Makefile
+++ b/Examples/perl5/shadow/Makefile
@@ -15,6 +15,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so myperl *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/shadow/example.cxx b/Examples/perl5/shadow/example.cxx
index 21582f4d1..d7f5046fe 100644
--- a/Examples/perl5/shadow/example.cxx
+++ b/Examples/perl5/shadow/example.cxx
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area() {
+double Circle::area(void) {
return M_PI*radius*radius;
}
-double Circle::perimeter() {
+double Circle::perimeter(void) {
return 2*M_PI*radius;
}
-double Square::area() {
+double Square::area(void) {
return width*width;
}
-double Square::perimeter() {
+double Square::perimeter(void) {
return 4*width;
}
diff --git a/Examples/perl5/shadow/example.h b/Examples/perl5/shadow/example.h
index 849071dd3..1f6f8b304 100644
--- a/Examples/perl5/shadow/example.h
+++ b/Examples/perl5/shadow/example.h
@@ -10,8 +10,8 @@ public:
};
double x, y;
void move(double dx, double dy);
- virtual double area() = 0;
- virtual double perimeter() = 0;
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
static int nshapes;
};
@@ -20,8 +20,9 @@ private:
double radius;
public:
Circle(double r) : radius(r) { };
- virtual double area();
- virtual double perimeter();
+ ~Circle() { };
+ virtual double area(void);
+ virtual double perimeter(void);
};
class Square : public Shape {
@@ -29,8 +30,9 @@ private:
double width;
public:
Square(double w) : width(w) { };
- virtual double area();
- virtual double perimeter();
+ ~Square() { }
+ virtual double area(void);
+ virtual double perimeter(void);
};
diff --git a/Examples/perl5/shadow/example.pl b/Examples/perl5/shadow/example.pl
index be26415f2..7cc334e6a 100644
--- a/Examples/perl5/shadow/example.pl
+++ b/Examples/perl5/shadow/example.pl
@@ -16,18 +16,18 @@ print " Created square $s\n";
# ----- Access a static member -----
-print "\nA total of $example::Shape_nshapes shapes were created\n";
+print "\nA total of $example::Shape::nshapes shapes were created\n";
# ----- Member data access -----
-# Set the location of the object
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
-$c->{'x'} = 20;
-$c->{'y'} = 30;
-
-# Now use the same functions in the base class
-$s->{'x'} = -10;
-$s->{'y'} = 5;
+$c->{x} = 20;
+$c->{y} = 30;
+$s->{x} = -10;
+$s->{y} = 5;
print "\nHere is their current position:\n";
print " Circle = (",$c->{x},",", $c->{y},")\n";
@@ -41,17 +41,16 @@ foreach $o ($c,$s) {
print " area = ", $o->area(), "\n";
print " perimeter = ", $o->perimeter(), "\n";
}
-# Notice how the Shape_area() and Shape_perimeter() functions really
-# invoke the appropriate virtual method on each object.
# ----- Delete everything -----
print "\nGuess I'll clean up now\n";
# Note: this invokes the virtual destructor
+
$c->DESTROY();
$s->DESTROY();
-print $example::Shape_nshapes," shapes remain\n";
+print $example::Shape::nshapes," shapes remain\n";
print "Goodbye\n";
diff --git a/Examples/perl5/simple/.cvsignore b/Examples/perl5/simple/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/simple/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/simple/Makefile b/Examples/perl5/simple/Makefile
index e5944f9af..ef644a35f 100644
--- a/Examples/perl5/simple/Makefile
+++ b/Examples/perl5/simple/Makefile
@@ -13,6 +13,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o core *~ *.so *.pm myperl
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/simple/example.dsp b/Examples/perl5/simple/example.dsp
new file mode 100644
index 000000000..d3a197f0c
--- /dev/null
+++ b/Examples/perl5/simple/example.dsp
@@ -0,0 +1,146 @@
+# 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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PERL5_INCLUDE)/perl.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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PERL5_INCLUDE)/perl.lib /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo on
+ ..\..\..\swig -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo on
+ ..\..\..\swig -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/perl5/value/.cvsignore b/Examples/perl5/value/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/value/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/value/Makefile b/Examples/perl5/value/Makefile
index e5944f9af..ef644a35f 100644
--- a/Examples/perl5/value/Makefile
+++ b/Examples/perl5/value/Makefile
@@ -13,6 +13,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o core *~ *.so *.pm myperl
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/variables/.cvsignore b/Examples/perl5/variables/.cvsignore
new file mode 100644
index 000000000..618145e24
--- /dev/null
+++ b/Examples/perl5/variables/.cvsignore
@@ -0,0 +1,10 @@
+example.pm
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/perl5/variables/Makefile b/Examples/perl5/variables/Makefile
index e5944f9af..ef644a35f 100644
--- a/Examples/perl5/variables/Makefile
+++ b/Examples/perl5/variables/Makefile
@@ -13,6 +13,6 @@ static::
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
- rm -f *_wrap* *.o core *~ *.so *.pm myperl
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
check: all
diff --git a/Examples/perl5/variables/example.i b/Examples/perl5/variables/example.i
index 35eafc2c0..91bd0679d 100644
--- a/Examples/perl5/variables/example.i
+++ b/Examples/perl5/variables/example.i
@@ -27,10 +27,10 @@ extern Point pt;
/* Some read-only variables */
-%readonly {
+%immutable;
extern int status;
extern char path[256];
-}
+%mutable;
/* Some helper functions to make it easier to test */
extern void print_vars();
diff --git a/Examples/perl5/variables/index.html b/Examples/perl5/variables/index.html
index a278445fe..a6d015dd2 100644
--- a/Examples/perl5/variables/index.html
+++ b/Examples/perl5/variables/index.html
@@ -27,21 +27,21 @@ Click <a href="example.pl">here</a> to see a script that updates and prints some
<h2>Creating read-only variables</h2>
-The <tt>%readonly</tt> and <tt>%readwrite</tt> directives can be used to
+The <tt>%immutable</tt> and <tt>%mutable</tt> directives can be used to
specify a collection of read-only variables. For example:
<blockquote>
<pre>
-%readonly
+%immutable;
int status;
double blah;
...
-%readwrite
+%mutable;
</pre>
</blockquote>
-The <tt>%readonly</tt> directive remains in effect until it is explicitly disabled
-using the <tt>%readwrite</tt> directive.
+The <tt>%immutable</tt> directive remains in effect until it is explicitly disabled
+using the <tt>%mutable</tt> directive.
<h2>Notes:</h2>
diff --git a/Examples/php4/Makefile.php b/Examples/php4/Makefile.php
new file mode 100644
index 000000000..ed9d786e5
--- /dev/null
+++ b/Examples/php4/Makefile.php
@@ -0,0 +1,30 @@
+CRUD=acinclude.m4 aclocal.m4 config.cache config.h config.h.in config.log \
+ config.m4 config.nice config.status config.sub configure configure.in \
+ config_vars.mk config.guess CREDITS dynlib.m4 *.so *.lo *.o *.slo \
+ install-sh libs.mk libtool ltmain.sh Makefile Makefile.in missing \
+ mkinstalldirs php_example.h php_example.la *_wrap.c* example.php \
+ build modules .deps .libs conftest conftest.c
+
+all: check
+
+check: BUILD.sh
+ ./BUILD.sh
+# SWIG=$(SWIG) ./BUILD.sh
+
+# This one is fun! How do we know what shouldn't be there?
+clean:
+ rm -fr $(CRUD)
+
+BUILD.sh:
+ echo "-------------------------------------------------"
+ echo `pwd`"/BUILD.sh missing!"
+ echo "I need BUILD.sh file to show me how to invoke swig"
+ echo "It usually looks like this:"
+ echo
+ echo "swig -php -phpfull -c++ <extra options> example.i"
+ echo "# and then the rest is always the same..."
+ echo "phpize && ./configure && make && make install"
+ echo
+ echo
+ exit 1
+
diff --git a/Examples/php4/check.list b/Examples/php4/check.list
new file mode 100644
index 000000000..2eef45816
--- /dev/null
+++ b/Examples/php4/check.list
@@ -0,0 +1,13 @@
+# see top-level Makefile.in
+# (see also top-level configure.in kludge)
+class
+constants
+enum
+funcptr
+pointer
+reference
+shadow
+simple
+sync
+value
+variables
diff --git a/Examples/php4/class/BUILD.sh b/Examples/php4/class/BUILD.sh
new file mode 100755
index 000000000..99ee15273
--- /dev/null
+++ b/Examples/php4/class/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -c++ -noproxy -withcxx example.cxx example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/class/Makefile.old b/Examples/php4/class/Makefile.old
new file mode 100644
index 000000000..cc44776e9
--- /dev/null
+++ b/Examples/php4/class/Makefile.old
@@ -0,0 +1,17 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = php_example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' \
+ php4_cpp
+
+clean::
+ rm -f *_wrap* *.o *~ *.so .~* core *.php php_example.h
+
+check: all
diff --git a/Examples/php4/class/example.cxx b/Examples/php4/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/Examples/php4/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/php4/class/example.h b/Examples/php4/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/Examples/php4/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/php4/class/example.i b/Examples/php4/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/Examples/php4/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/php4/class/runme.php4 b/Examples/php4/class/runme.php4
new file mode 100644
index 000000000..653ced256
--- /dev/null
+++ b/Examples/php4/class/runme.php4
@@ -0,0 +1,58 @@
+<?php
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+require("example.php");
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = new_Circle(10);
+print " Created circle $c\n";
+$s = new_Square(10);
+print " Created square $s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of " . nshapes() . " shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+Shape_x_set($c, 20);
+Shape_y_set($c, 30);
+Shape_x_set($s,-10);
+Shape_y_set($s,5);
+
+print "\nHere is their current position:\n";
+print " Circle = (" . Shape_x_get($c) . "," . Shape_y_get($c) . ")\n";
+print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach (array($c,$s) as $o) {
+ print " $o\n";
+ print " area = " . Shape_area($o) . "\n";
+ print " perimeter = " . Shape_perimeter($o) . "\n";
+ }
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+delete_Shape($c);
+delete_Shape($s);
+
+print nshapes() . " shapes remain\n";
+print "Goodbye\n";
+
+?>
diff --git a/Examples/php4/constants/BUILD.sh b/Examples/php4/constants/BUILD.sh
new file mode 100755
index 000000000..19b79dbc6
--- /dev/null
+++ b/Examples/php4/constants/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -c++ -noproxy example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/constants/Makefile.old b/Examples/php4/constants/Makefile.old
new file mode 100644
index 000000000..54af9e8d0
--- /dev/null
+++ b/Examples/php4/constants/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = php_example
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php *.h
+
+check: all
diff --git a/Examples/php4/constants/example.i b/Examples/php4/constants/example.i
new file mode 100644
index 000000000..0098a893a
--- /dev/null
+++ b/Examples/php4/constants/example.i
@@ -0,0 +1,26 @@
+/* File : example.i */
+%module example
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following statements also produce constants */
+%constant int iconst = 37;
+%constant double fconst = 3.14;
+
+
diff --git a/Examples/php4/constants/runme.php4 b/Examples/php4/constants/runme.php4
new file mode 100644
index 000000000..cea06485f
--- /dev/null
+++ b/Examples/php4/constants/runme.php4
@@ -0,0 +1,28 @@
+<?php
+
+require "example.php";
+
+print "ICONST = " . ICONST . " (should be 42)\n";
+print "FCONST = " . FCONST . " (should be 2.1828)\n";
+print "CCONST = " . CCONST . " (should be 'x')\n";
+print "CCONST2 = " . CCONST2 . " (this should be on a new line)\n";
+print "SCONST = " . SCONST . " (should be 'Hello World')\n";
+print "SCONST2 = " . SCONST2 . " (should be '\"Hello World\"')\n";
+print "EXPR = " . EXPR . " (should be 48.5484)\n";
+print "iconst = " . iconst . " (should be 37)\n";
+print "fconst = " . fconst . " (should be 3.14)\n";
+
+if (EXTERN!="EXTERN") {
+ print "EXTERN = " . EXTERN . " (Arg! This shouldn't print anything)\n";
+} else {
+ print "EXTERN defaults to 'EXTERN', it probably isn't defined (good)\n";
+}
+
+if (FOO!="FOO") {
+ print "FOO = " . FOO . "(Arg! This shouldn't print anything)\n";
+} else {
+ print "FOO defaults to 'FOO', it probably isn't defined (good)\n";
+}
+
+
+?>
diff --git a/Examples/php4/enum/BUILD.sh b/Examples/php4/enum/BUILD.sh
new file mode 100755
index 000000000..cccb24029
--- /dev/null
+++ b/Examples/php4/enum/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -c++ -noproxy -withcxx example.cxx example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/enum/Makefile.old b/Examples/php4/enum/Makefile.old
new file mode 100644
index 000000000..cc4574bea
--- /dev/null
+++ b/Examples/php4/enum/Makefile.old
@@ -0,0 +1,17 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = php_example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'\
+ php4_cpp
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php
+
+check: all
diff --git a/Examples/php4/enum/example.cxx b/Examples/php4/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/Examples/php4/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include <stdio.h>
+
+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/php4/enum/example.h b/Examples/php4/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/Examples/php4/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/php4/enum/example.i b/Examples/php4/enum/example.i
new file mode 100644
index 000000000..abf254731
--- /dev/null
+++ b/Examples/php4/enum/example.i
@@ -0,0 +1,12 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/Examples/php4/enum/runme.php4 b/Examples/php4/enum/runme.php4
new file mode 100644
index 000000000..55b0bc4c3
--- /dev/null
+++ b/Examples/php4/enum/runme.php4
@@ -0,0 +1,32 @@
+<?php
+
+require "example.php";
+
+# ----- Object creation -----
+
+# Print out the value of some enums
+print "*** color ***";
+print " RED =" . RED;
+print " BLUE =" . BLUE;
+print " GREEN =" . GREEN;
+
+print "\n*** Foo::speed ***";
+print " Foo_IMPULSE =" . Foo_IMPULSE;
+print " Foo_WARP =" . Foo_WARP;
+print " Foo_LUDICROUS =" . Foo_LUDICROUS;
+
+print "\nTesting use of enums with functions\n";
+
+enum_test(RED, Foo_IMPULSE);
+enum_test(BLUE, Foo_WARP);
+enum_test(GREEN, Foo_LUDICROUS);
+enum_test(1234,5678);
+
+print "\nTesting use of enum with class method\n";
+$f = new_Foo();
+
+Foo_enum_test($f,Foo_IMPULSE);
+Foo_enum_test($f,Foo_WARP);
+Foo_enum_test($f,Foo_LUDICROUS);
+
+?>
diff --git a/Examples/php4/funcptr/BUILD.sh b/Examples/php4/funcptr/BUILD.sh
new file mode 100755
index 000000000..881e5881f
--- /dev/null
+++ b/Examples/php4/funcptr/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -noproxy -withc example.c example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/funcptr/Makefile.old b/Examples/php4/funcptr/Makefile.old
new file mode 100644
index 000000000..c48cc7bd5
--- /dev/null
+++ b/Examples/php4/funcptr/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = php_example
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php php_example.h
+
+check: all
diff --git a/Examples/php4/funcptr/example.c b/Examples/php4/funcptr/example.c
new file mode 100644
index 000000000..99583b72e
--- /dev/null
+++ b/Examples/php4/funcptr/example.c
@@ -0,0 +1,17 @@
+/* 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;
+}
diff --git a/Examples/php4/funcptr/example.h b/Examples/php4/funcptr/example.h
new file mode 100644
index 000000000..58989db79
--- /dev/null
+++ b/Examples/php4/funcptr/example.h
@@ -0,0 +1,7 @@
+/* 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);
+
diff --git a/Examples/php4/funcptr/example.i b/Examples/php4/funcptr/example.i
new file mode 100644
index 000000000..39390da27
--- /dev/null
+++ b/Examples/php4/funcptr/example.i
@@ -0,0 +1,15 @@
+/* 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;
+
+
diff --git a/Examples/php4/funcptr/runme.php4 b/Examples/php4/funcptr/runme.php4
new file mode 100644
index 000000000..712d4147c
--- /dev/null
+++ b/Examples/php4/funcptr/runme.php4
@@ -0,0 +1,24 @@
+<?php
+
+require "example.php";
+
+$a = 37;
+$b = 42;
+
+# Now call our C function with a bunch of callbacks
+
+print "Trying some C callback functions\n";
+print " a = $a\n";
+print " b = $b\n";
+print " ADD(a,b) = ". do_op($a,$b,ADD)."\n";
+print " SUB(a,b) = ". do_op($a,$b,SUB)."\n";
+print " MUL(a,b) = ". do_op($a,$b,MUL)."\n";
+
+print "Here is what the C callback function objects look like in php\n";
+print "Using swig style string pointers as we need them registered as constants\n";
+print " ADD = " . ADD . "\n";
+print " SUB = " . SUB . "\n";
+print " MUL = " . MUL . "\n";
+
+?>
+
diff --git a/Examples/php4/pointer/BUILD.sh b/Examples/php4/pointer/BUILD.sh
new file mode 100755
index 000000000..881e5881f
--- /dev/null
+++ b/Examples/php4/pointer/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -noproxy -withc example.c example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/pointer/Makefile.old b/Examples/php4/pointer/Makefile.old
new file mode 100644
index 000000000..c48cc7bd5
--- /dev/null
+++ b/Examples/php4/pointer/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = php_example
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php php_example.h
+
+check: all
diff --git a/Examples/php4/pointer/example.c b/Examples/php4/pointer/example.c
new file mode 100644
index 000000000..3326dec3e
--- /dev/null
+++ b/Examples/php4/pointer/example.c
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(double *x, double *y, double *result) {
+ *result = *x + *y;
+}
+
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/Examples/php4/pointer/example.i b/Examples/php4/pointer/example.i
new file mode 100644
index 000000000..52e6df190
--- /dev/null
+++ b/Examples/php4/pointer/example.i
@@ -0,0 +1,26 @@
+/* File : example.i */
+%module example
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+
+%include 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/php4/pointer/runme.php4 b/Examples/php4/pointer/runme.php4
new file mode 100644
index 000000000..48f0ad631
--- /dev/null
+++ b/Examples/php4/pointer/runme.php4
@@ -0,0 +1,45 @@
+<?php
+
+ require "example.php";
+
+ # First create some objects using the pointer library.
+
+ print "Testing the pointer library\n";
+
+ $a = new_intp();
+ $b = new_intp();
+ $c = new_intp();
+ intp_assign($a,37);
+ intp_assign($b,42);
+
+ print " a = $a\n";
+ print " b = $b\n";
+ print " c = $c\n";
+
+ # Call the add() function wuth some pointers
+ add($a,$b,$c);
+
+ # Now get the result
+ $r = intp_value($c);
+
+ print " 37 + 42 = $r\n";
+
+ # Clean up the pointers
+ delete_intp($a);
+ delete_intp($b);
+ delete_intp($c);
+
+ # Now try the typemap library
+ # This should be much easier. Now how it is no longer
+ # necessary to manufacture pointers.
+
+ print "Trying the typemap library\n";
+ $r = sub(37,42);
+ print " 37 - 42 = $r\n";
+
+ # Now try the version with multiple return values
+ # print "Testing multiple return values\n";
+ # ($q,$r) = divide(42,37);
+ # print " 42/37 = $q remainder $r\n";
+
+?>
diff --git a/Examples/php4/reference/BUILD.sh b/Examples/php4/reference/BUILD.sh
new file mode 100755
index 000000000..cccb24029
--- /dev/null
+++ b/Examples/php4/reference/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -c++ -noproxy -withcxx example.cxx example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/reference/Makefile.old b/Examples/php4/reference/Makefile.old
new file mode 100644
index 000000000..7465de804
--- /dev/null
+++ b/Examples/php4/reference/Makefile.old
@@ -0,0 +1,17 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = php_example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php4_cpp
+
+clean::
+ rm -f *_wrap* *.o *~ *.so .~* core php_example.h *.php
+
+check: all
diff --git a/Examples/php4/reference/example.cxx b/Examples/php4/reference/example.cxx
new file mode 100644
index 000000000..a37660666
--- /dev/null
+++ b/Examples/php4/reference/example.cxx
@@ -0,0 +1,44 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+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)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+printf("Vectorarray new: self=%p\n",this);
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+printf("Vectorarray: read[%d] self=%p\n",index,this);
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+printf("Vectorarray: size %d self=%p\n",maxsize,this);
+ return maxsize;
+}
+
diff --git a/Examples/php4/reference/example.h b/Examples/php4/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/Examples/php4/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/php4/reference/example.i b/Examples/php4/reference/example.i
new file mode 100644
index 000000000..73e8c62ec
--- /dev/null
+++ b/Examples/php4/reference/example.i
@@ -0,0 +1,44 @@
+/* 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) {
+printf("%p %d\n",self,index);
+ return (*self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*self)[index] = a;
+ }
+ }
+};
+
diff --git a/Examples/php4/reference/runme.php4 b/Examples/php4/reference/runme.php4
new file mode 100644
index 000000000..ecf9ce507
--- /dev/null
+++ b/Examples/php4/reference/runme.php4
@@ -0,0 +1,78 @@
+<?php
+
+# This file illustrates the manipulation of C++ references in Php.
+# This uses the low-level interface. Shadow classes work differently.
+
+require "example.php";
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$a = new_Vector(3,4,5);
+$b = new_Vector(10,11,12);
+
+print " Created a: $a " . Vector_print($a) . "\n";
+print " Created b: $b " . Vector_print($b) . "\n";
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+print "Adding a+b\n";
+$c = addv($a,$b);
+print " a+b =". Vector_print($c)."\n";
+
+# Note: Unless we free the result, a memory leak will occur
+delete_Vector($c);
+
+# ----- Create a vector array -----
+
+# Note: Using the high-level interface here
+print "Creating an array of vectors\n";
+$va = new_VectorArray(10);
+
+print " va: $va size=".VectorArray_size($va)."\n";
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of $a and $b to the vector array
+VectorArray_set($va,0,$a);
+VectorArray_set($va,1,$b);
+
+VectorArray_get($va,0);
+# This will work, but it will cause a memory leak!
+
+VectorArray_set($va,2,addv($a,$b));
+
+# The non-leaky way to do it
+
+$c = addv($a,$b);
+VectorArray_set($va,3,$c);
+delete_Vector($c);
+
+# Get some values from the array
+
+print "Getting some array values\n";
+for ($i = 0; $i < 5; $i++) {
+print "do $i\n";
+ print " va($i) = ". Vector_print(VectorArray_get($va,$i)). "\n";
+}
+
+# Watch under resource meter to check on this
+#print "Making sure we don't leak memory.\n";
+#for ($i = 0; $i < 1000000; $i++) {
+# $c = VectorArray_get($va,$i % 10);
+#}
+
+# ----- Clean up -----
+print "Cleaning up\n";
+# wants fixing FIXME
+#delete_VectorArray($va);
+delete_Vector($a);
+delete_Vector($b);
+
+?>
diff --git a/Examples/php4/shadow/BUILD.sh b/Examples/php4/shadow/BUILD.sh
new file mode 100755
index 000000000..99b520879
--- /dev/null
+++ b/Examples/php4/shadow/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -c++ -withcxx example.cxx example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/shadow/Makefile.old b/Examples/php4/shadow/Makefile.old
new file mode 100644
index 000000000..4878e8abe
--- /dev/null
+++ b/Examples/php4/shadow/Makefile.old
@@ -0,0 +1,16 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = php_example
+INTERFACE = example.i
+LIBS = -lm
+#SWIGOPT = -proxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4_cpp
+
+clean::
+ rm -f *_wrap* *.o *~ *.so .~* core *.php php_example.h
+
+check: all
diff --git a/Examples/php4/shadow/example.cxx b/Examples/php4/shadow/example.cxx
new file mode 100644
index 000000000..d7f5046fe
--- /dev/null
+++ b/Examples/php4/shadow/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+
+/* 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/php4/shadow/example.h b/Examples/php4/shadow/example.h
new file mode 100644
index 000000000..226ec3a9b
--- /dev/null
+++ b/Examples/php4/shadow/example.h
@@ -0,0 +1,43 @@
+/* File : example.h */
+
+#include <stdio.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) { };
+ ~Circle() { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ ~Square() { }
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+
+
+
diff --git a/Examples/php4/shadow/example.i b/Examples/php4/shadow/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/Examples/php4/shadow/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/php4/shadow/runme.php4 b/Examples/php4/shadow/runme.php4
new file mode 100644
index 000000000..bd10dad6e
--- /dev/null
+++ b/Examples/php4/shadow/runme.php4
@@ -0,0 +1,58 @@
+<?php
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+include("example.php");
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = new Circle(10);
+print " Created circle $c\n";
+$s = new Square(10);
+print " Created square $s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of " . Shape::nshapes() . " shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+$c->x = 20;
+$c->y = 30;
+$s->x = -10;
+$s->y = 5;
+
+print "\nHere is their current position:\n";
+print " Circle = (" . $c->x . "," . $c->y . ")\n";
+print " Square = (" . $s->x . "," . $s->y . ")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach (array($c,$s) as $o) {
+ print " ".get_class($o)." $o\n";
+ print " area = " . $o->area() . "\n";
+ print " perimeter = " . $o->perimeter() . "\n";
+ }
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+
+# This causes a seq fault, possibly php trying to call destructor twice ?
+#$c->_destroy();
+#$s->_destroy();
+
+print Shape::nshapes() . " shapes remain\n";
+print "Goodbye\n";
+
+?>
diff --git a/Examples/php4/simple/BUILD.sh b/Examples/php4/simple/BUILD.sh
new file mode 100755
index 000000000..881e5881f
--- /dev/null
+++ b/Examples/php4/simple/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -noproxy -withc example.c example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/simple/Makefile.old b/Examples/php4/simple/Makefile.old
new file mode 100644
index 000000000..816da0c2b
--- /dev/null
+++ b/Examples/php4/simple/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = libexample
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php
+
+check: all
diff --git a/Examples/php4/simple/example.c b/Examples/php4/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/php4/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/php4/simple/example.i b/Examples/php4/simple/example.i
new file mode 100644
index 000000000..6702abb1e
--- /dev/null
+++ b/Examples/php4/simple/example.i
@@ -0,0 +1,5 @@
+/* File : example.i */
+%module example
+
+extern int gcd(int x, int y);
+extern double Foo;
diff --git a/Examples/php4/simple/runme.php4 b/Examples/php4/simple/runme.php4
new file mode 100755
index 000000000..825c44891
--- /dev/null
+++ b/Examples/php4/simple/runme.php4
@@ -0,0 +1,24 @@
+<?php
+
+require "example.php";
+
+# Call our gcd() function
+
+$x = 42;
+$y = 105;
+$g = gcd($x,$y);
+print "The gcd of $x and $y is $g\n";
+
+# Manipulate the Foo global variable
+
+# Output its current value
+print "Foo = " . $Foo . "\n";
+
+# Change its value
+$Foo = 3.1415926;
+
+# See if the change took effect ( this isn't a good example for php, see
+# manual for why. )
+print "Foo = " . $Foo . "\n";
+
+?>
diff --git a/Examples/php4/sync/BUILD.sh b/Examples/php4/sync/BUILD.sh
new file mode 100755
index 000000000..99b520879
--- /dev/null
+++ b/Examples/php4/sync/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -c++ -withcxx example.cxx example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/sync/Makefile.old b/Examples/php4/sync/Makefile.old
new file mode 100644
index 000000000..3418f733f
--- /dev/null
+++ b/Examples/php4/sync/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = libexample
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4_cpp
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php php_example.h
+
+check: all
diff --git a/Examples/php4/sync/example.cxx b/Examples/php4/sync/example.cxx
new file mode 100644
index 000000000..47378924b
--- /dev/null
+++ b/Examples/php4/sync/example.cxx
@@ -0,0 +1,13 @@
+#include "example.h"
+#include <stdio.h>
+
+int x = 42;
+char *s = "Test";
+
+void Sync::printer(void) {
+
+ printf("The value of global s is %s\n", s);
+ printf("The value of global x is %d\n", x);
+ printf("The value of class s is %s\n", s);
+ printf("The value of class x is %d\n", x);
+};
diff --git a/Examples/php4/sync/example.h b/Examples/php4/sync/example.h
new file mode 100644
index 000000000..d67ec21dc
--- /dev/null
+++ b/Examples/php4/sync/example.h
@@ -0,0 +1,9 @@
+extern char *s;
+extern int x;
+
+class Sync {
+ public:
+ int x;
+ char *s;
+ void printer(void);
+};
diff --git a/Examples/php4/sync/example.i b/Examples/php4/sync/example.i
new file mode 100644
index 000000000..17ff87cf3
--- /dev/null
+++ b/Examples/php4/sync/example.i
@@ -0,0 +1,7 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
diff --git a/Examples/php4/sync/runme.php4 b/Examples/php4/sync/runme.php4
new file mode 100644
index 000000000..a7c43474f
--- /dev/null
+++ b/Examples/php4/sync/runme.php4
@@ -0,0 +1,15 @@
+<?
+
+// Load module and PHP classes.
+include("example.php");
+
+echo "Got new object\n";
+echo "Got string $s and value $x \n";
+
+$s = new Sync();
+echo "Got new object\n";
+
+$s->printer();
+
+?>
+
diff --git a/Examples/php4/value/BUILD.sh b/Examples/php4/value/BUILD.sh
new file mode 100755
index 000000000..881e5881f
--- /dev/null
+++ b/Examples/php4/value/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -noproxy -withc example.c example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/value/Makefile.old b/Examples/php4/value/Makefile.old
new file mode 100644
index 000000000..c48cc7bd5
--- /dev/null
+++ b/Examples/php4/value/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = php_example
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php php_example.h
+
+check: all
diff --git a/Examples/php4/value/example.c b/Examples/php4/value/example.c
new file mode 100644
index 000000000..4ed2fe10a
--- /dev/null
+++ b/Examples/php4/value/example.c
@@ -0,0 +1,15 @@
+/* File : example.c */
+
+#include "example.h"
+
+double dot_product(Vector a, Vector b) {
+ return (a.x*b.x + a.y*b.y + a.z*b.z);
+}
+
+Vector vector_add(Vector a, Vector b) {
+ Vector r;
+ r.x = a.x + b.x;
+ r.y = a.y + b.y;
+ r.z = a.z + b.z;
+ return r;
+}
diff --git a/Examples/php4/value/example.h b/Examples/php4/value/example.h
new file mode 100644
index 000000000..212cf4bdb
--- /dev/null
+++ b/Examples/php4/value/example.h
@@ -0,0 +1,5 @@
+/* File : example.h */
+
+typedef struct {
+ double x, y, z;
+} Vector;
diff --git a/Examples/php4/value/example.i b/Examples/php4/value/example.i
new file mode 100644
index 000000000..db3d5b96b
--- /dev/null
+++ b/Examples/php4/value/example.i
@@ -0,0 +1,31 @@
+// Tests SWIG's handling of pass-by-value for complex datatypes
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Some functions that manipulate Vectors by value */
+extern double dot_product(Vector a, Vector b);
+extern Vector vector_add(Vector a, Vector b);
+
+/* Include this because the vector_add() function will leak memory */
+void free(void *);
+
+/* Some helper functions for our interface */
+%inline %{
+
+Vector *new_Vector(double x, double y, double z) {
+ /* We use the Zend memory manager */
+ Vector *v = (Vector *) emalloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+}
+
+void vector_print(Vector *v) {
+ printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+%}
+
diff --git a/Examples/php4/value/runme.php4 b/Examples/php4/value/runme.php4
new file mode 100644
index 000000000..80cb88408
--- /dev/null
+++ b/Examples/php4/value/runme.php4
@@ -0,0 +1,35 @@
+<?php
+
+ require "example.php";
+
+
+ $v = new_vector(1.0,2.0,3.0);
+ $w = new_vector(10.0,11.0,12.0);
+
+ echo "I just created the following vector\n";
+ vector_print($v);
+ vector_print($w);
+
+ echo "\nNow I'm going to compute the dot product\n";
+
+ $d = dot_product($v, $w);
+
+ echo "dot product = $d (should be 68)\n";
+
+ echo "\nNow I'm going to add the vectors together\n";
+
+ $r = vector_add($v, $w);
+
+ vector_print($r);
+
+ echo "The value should be (11,13,15)\n";
+
+ echo "\nNow I'm going to clean up the return result\n";
+
+# free($r);
+
+ echo "Good\n";
+
+?>
+
+
diff --git a/Examples/php4/variables/BUILD.sh b/Examples/php4/variables/BUILD.sh
new file mode 100755
index 000000000..881e5881f
--- /dev/null
+++ b/Examples/php4/variables/BUILD.sh
@@ -0,0 +1,4 @@
+#! /bin/sh -e
+
+${SWIG:=swig} -php4 -phpfull -noproxy -withc example.c example.i
+phpize && ./configure && make clean && make
diff --git a/Examples/php4/variables/Makefile.old b/Examples/php4/variables/Makefile.old
new file mode 100644
index 000000000..c48cc7bd5
--- /dev/null
+++ b/Examples/php4/variables/Makefile.old
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = php_example
+INTERFACE = example.i
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+
+clean::
+ rm -f *_wrap* *.o core *~ *.so *.php php_example.h
+
+check: all
diff --git a/Examples/php4/variables/example.c b/Examples/php4/variables/example.c
new file mode 100644
index 000000000..856895951
--- /dev/null
+++ b/Examples/php4/variables/example.c
@@ -0,0 +1,90 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+#include <stdio.h>
+#include <stdlib.h>
+#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 = 0;
+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 = %x\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %x (%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;
+}
+
+int value_int(int *value) {
+ return *value;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/Examples/php4/variables/example.h b/Examples/php4/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/Examples/php4/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/Examples/php4/variables/example.i b/Examples/php4/variables/example.i
new file mode 100644
index 000000000..fca392adf
--- /dev/null
+++ b/Examples/php4/variables/example.i
@@ -0,0 +1,45 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char *cstrvar;
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+
+/* Some read-only variables */
+
+%immutable;
+extern int status;
+extern char path[256];
+%mutable;
+
+/* Some helper functions to make it easier to test */
+extern void print_vars();
+extern int *new_int(int value);
+extern int value_ent(int *value);
+
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+
+
+
+
diff --git a/Examples/php4/variables/runme.php4 b/Examples/php4/variables/runme.php4
new file mode 100644
index 000000000..98e4ac6d2
--- /dev/null
+++ b/Examples/php4/variables/runme.php4
@@ -0,0 +1,71 @@
+<?php
+
+ require "example.php";
+ /* Try to set the values of some global variables */
+
+ ivar_set(42);
+ svar_set(-31000);
+ lvar_set(65537);
+ uivar_set(123456);
+ usvar_set(61000);
+ ulvar_set(654321);
+ scvar_set(-13);
+ ucvar_set(251);
+ cvar_set("S");
+ fvar_set(3.14159);
+ dvar_set(2.1828);
+ strvar_set("Hello World");
+ cstrvar_set("Goodbye");
+ iptrvar_set(new_int(37));
+ ptptr_set(new_point(37,42));
+ name_set("Bill");
+
+ echo "Variables (values printed from PHP)\n";
+
+ echo "ivar = ".ivar_get()."\n";
+ echo "svar = ".svar_get()."\n";
+ echo "lvar = ".lvar_get()."\n";
+ echo "uivar = ".uivar_get()."\n";
+ echo "usvar = ".usvar_get()."\n";
+ echo "ulvar = ".ulvar_get()."\n";
+ echo "scvar = ".scvar_get()."\n";
+ echo "ucvar = ".ucvar_get()."\n";
+ echo "cvar = ".cvar_get()."\n";
+ echo "fvar = ".fvar_get()."\n";
+ echo "dvar = ".dvar_get()."\n";
+ echo "strvar = ".strvar_get()."\n";
+ echo "cstrvar = ".cstrvar_get()."\n";
+ echo "iptrvar = ".iptrvar_get()."\n";
+ echo "name = ".name_get()."\n";
+ echo "ptptr = ".ptptr_get() , point_print(ptptr_get()) , "\n";
+ echo "pt = ".pt_get(), point_print(pt_get()) , "\n";
+
+ echo "\nVariables (values printed from C)\n";
+
+ print_vars();
+
+ echo "\nI'm going to try and update a structure variable.\n";
+
+ pt_set(ptptr_get());
+
+ echo "The new value is \n";
+
+ pt_print();
+
+ echo "You should see the value", point_print(ptptr_get()), "\n";
+
+ echo "\nNow I'm going to try and modify some read only variables\n";
+
+ echo "Trying to set 'path'\n";
+
+ //path_set("Whoa!");
+ echo "Path = ".path_get()."\n";
+
+ echo "Trying to set 'status'\n";
+
+ /* And this */
+ //status_set(0);
+ echo "Status = ".status_get()."\n";
+
+?>
+
diff --git a/Examples/php4/variables/runme.php4.old b/Examples/php4/variables/runme.php4.old
new file mode 100644
index 000000000..9a6bfb386
--- /dev/null
+++ b/Examples/php4/variables/runme.php4.old
@@ -0,0 +1,80 @@
+<?php
+### THIS VERSION was written for when php global vars fakingly mirrored
+### the wrapped global vars, but it was very inefficient.
+### For now we don't do this (pending some changes to php itself) so
+### we use accessor functions instead; WE KEEP THIS version around ready
+### for when those php changes are made and we can switch back.
+### Specifically we want $_GLOBALS variable overloading like object
+### property overloading
+
+ require "example.php";
+
+ /* Try to set the values of some global variables */
+
+ $ivar = 42;
+ $svar = -31000;
+ $lvar = 65537;
+ $uivar = 123456;
+ $usvar = 61000;
+ $ulvar = 654321;
+ $scvar = -13;
+ $ucvar = 251;
+ $cvar = "S";
+ $fvar = 3.14159;
+ $dvar = 2.1828;
+ $strvar = "Hello World";
+ $cstrvar = "Goodbye";
+ $iptrvar = new_int(37);
+ $ptptr = new_point(37,42);
+ $name = "Bill";
+
+ echo "Variables (values printed from PHP)\n";
+
+ echo "ivar = $ivar\n";
+ echo "svar = $svar\n";
+ echo "lvar = $lvar\n";
+ echo "uivar = $uivar\n";
+ echo "usvar = $usvar\n";
+ echo "ulvar = $ulvar\n";
+ echo "scvar = $scvar\n";
+ echo "ucvar = $ucvar\n";
+ echo "cvar = $cvar\n";
+ echo "fvar = $fvar\n";
+ echo "dvar = $dvar\n";
+ echo "strvar = $strvar\n";
+ echo "cstrvar = $cstrvar\n";
+ echo "iptrvar = $iptrvar\n";
+ echo "name = $name\n";
+ echo "ptptr = $ptptr" , point_print($ptptr) , "\n";
+ echo "pt = $pt" , point_print($pt) , "\n";
+
+ echo "\nVariables (values printed from C)\n";
+
+ print_vars();
+
+ echo "\nI'm going to try and update a structure variable.\n";
+
+ $pt = $ptptr;
+
+ echo "The new value is \n";
+
+ pt_print();
+
+ echo "You should see the value", point_print($ptptr), "\n";
+
+ echo "\nNow I'm going to try and modify some read only variables\n";
+
+ echo "Trying to set 'path'\n";
+
+ /* Sadly this works */
+ $path = "Whoa!";
+ echo "Path = $path\n";
+
+ echo "Trying to set 'status'\n";
+
+ /* And this */
+ $status = 0;
+ echo "Status = $status\n";
+
+?>
+
diff --git a/Examples/pike/check.list b/Examples/pike/check.list
new file mode 100644
index 000000000..b6474884d
--- /dev/null
+++ b/Examples/pike/check.list
@@ -0,0 +1,8 @@
+# see top-level Makefile.in
+class
+constants
+enum
+operator
+overload
+simple
+template
diff --git a/Examples/pike/class/.cvsignore b/Examples/pike/class/.cvsignore
new file mode 100755
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/pike/class/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile
new file mode 100755
index 000000000..c06d68011
--- /dev/null
+++ b/Examples/pike/class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all:
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
+check: all
diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx
new file mode 100755
index 000000000..c1708aa90
--- /dev/null
+++ b/Examples/pike/class/example.cxx
@@ -0,0 +1,48 @@
+/* File : example.c */
+
+#include "example.h"
+
+#include <stdio.h>
+
+#define M_PI 3.14159265358979323846
+
+// Static member initializer
+int Shape::nshapes = 0;
+
+// Constructor
+Shape::Shape() {
+ // printf("Shape::Shape(), this = 0x%08x\n", this);
+ nshapes++;
+}
+
+// Move the shape to a new location
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+// Destructor
+Shape::~Shape() {
+ // printf("Shape::~Shape(), this = 0x%08x\n", this);
+ nshapes--;
+}
+
+// Circle area
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+// Circle perimeter
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+// Square area
+double Square::area() {
+ return width*width;
+}
+
+// Square perimeter
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h
new file mode 100755
index 000000000..6f5ac06d9
--- /dev/null
+++ b/Examples/pike/class/example.h
@@ -0,0 +1,35 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape();
+ virtual ~Shape();
+ 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/pike/class/example.i b/Examples/pike/class/example.i
new file mode 100755
index 000000000..75700b305
--- /dev/null
+++ b/Examples/pike/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/pike/class/runme.pike b/Examples/pike/class/runme.pike
new file mode 100755
index 000000000..dd334accb
--- /dev/null
+++ b/Examples/pike/class/runme.pike
@@ -0,0 +1,61 @@
+import .example;
+
+int main()
+{
+ // ----- Object creation -----
+
+ write("Creating some objects:\n");
+ Circle c = Circle(10.0);
+ // write(" Created circle " + (string) c + ".\n");
+ write(" Created circle.\n");
+ Square s = Square(10.0);
+ // write(" Created square " + (string) s + ".\n");
+ write(" Created square.\n");
+
+ // ----- Access a static member -----
+
+ // write("\nA total of " + Shape->nshapes + " shapes were created\n");
+
+ // ----- Member data access -----
+
+ // Set the location of the object
+
+ // c->x = 20.0;
+ // c->y = 30.0;
+ c->x_set(20.0);
+ c->y_set(30.0);
+
+ // s->x = -10.0;
+ // s->y = 5.0;
+ s->x_set(-10.0);
+ s->y_set(5.0);
+
+ write("\nHere is their current position:\n");
+ // write(sprintf(" Circle = (%f, %f)\n", c->x, c->y));
+ // write(sprintf(" Square = (%f, %f)\n", s->x, s->y));
+ write(sprintf(" Circle = (%f, %f)\n", c->x_get(), c->y_get()));
+ write(sprintf(" Square = (%f, %f)\n", s->x_get(), s->y_get()));
+
+ // ----- Call some methods -----
+
+ write("\nHere are some properties of the shapes:\n");
+ write(" The circle:\n");
+ write(sprintf(" area = %f.\n", c->area()));
+ write(sprintf(" perimeter = %f.\n", c->perimeter()));
+ // write(" " + (string) s + ".\n");
+ write(" The square:\n");
+ write(sprintf(" area = %f.\n", s->area()));
+ write(sprintf(" perimeter = %f.\n", s->perimeter()));
+
+ write("\nGuess I'll clean up now\n");
+
+ // Note: this invokes the virtual destructor
+ // del c;
+ // del s;
+
+ // s = 3;
+ // write(sprintf("%d shapes remain\n", Shape->nshapes));
+ write("Goodbye\n");
+
+ return 0;
+}
diff --git a/Examples/pike/constants/.cvsignore b/Examples/pike/constants/.cvsignore
new file mode 100755
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/pike/constants/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile
new file mode 100755
index 000000000..bac67449f
--- /dev/null
+++ b/Examples/pike/constants/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
+check: all
diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i
new file mode 100755
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/Examples/pike/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/pike/constants/runme.pike b/Examples/pike/constants/runme.pike
new file mode 100755
index 000000000..e5a894f1e
--- /dev/null
+++ b/Examples/pike/constants/runme.pike
@@ -0,0 +1,24 @@
+int main()
+{
+ write(sprintf("ICONST = %d (should be 42)\n", .example.ICONST));
+ write(sprintf("FCONST = %f (should be 2.1828)\n", .example.FCONST));
+ write(sprintf("CCONST = %c (should be 'x')\n", .example.CCONST));
+ write(sprintf("CCONST2 = %c (this should be on a new line)\n", .example.CCONST2));
+ write(sprintf("SCONST = %s (should be 'Hello World')\n", .example.SCONST));
+ write(sprintf("SCONST2 = %s (should be '\"Hello World\"')\n", .example.SCONST2));
+ write(sprintf("EXPR = %f (should be 48.5484)\n", .example.EXPR));
+ write(sprintf("iconst = %d (should be 37)\n", .example.iconst));
+ write(sprintf("fconst = %f (should be 3.14)\n", .example.fconst));
+
+ if (search(indices(.example), "EXTERN") == -1)
+ write("EXTERN isn't defined (good)\n");
+ else
+ write("EXTERN is defined (bad)\n");
+
+ if (search(indices(.example), "FOO") == -1)
+ write("FOO isn't defined (good)\n");
+ else
+ write("FOO is defined (bad)\n");
+
+ return 0;
+}
diff --git a/Examples/pike/enum/.cvsignore b/Examples/pike/enum/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/pike/enum/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/pike/enum/Makefile b/Examples/pike/enum/Makefile
new file mode 100644
index 000000000..34db27dff
--- /dev/null
+++ b/Examples/pike/enum/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
+check: all
diff --git a/Examples/pike/enum/example.cxx b/Examples/pike/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/Examples/pike/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.c */
+
+#include "example.h"
+#include <stdio.h>
+
+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/pike/enum/example.h b/Examples/pike/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/Examples/pike/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/pike/enum/example.i b/Examples/pike/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/Examples/pike/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/pike/enum/runme.pike b/Examples/pike/enum/runme.pike
new file mode 100644
index 000000000..7cde8d839
--- /dev/null
+++ b/Examples/pike/enum/runme.pike
@@ -0,0 +1,27 @@
+int main()
+{
+ write("*** color ***\n");
+ write(" RED = " + .example.RED + "\n");
+ write(" BLUE = " + .example.BLUE + "\n");
+ write(" GREEN = " + .example.GREEN + "\n");
+
+ write("\n*** Foo::speed ***\n");
+ write(" Foo_IMPULSE = " + .example.Foo.IMPULSE + "\n");
+ write(" Foo_WARP = " + .example.Foo.WARP + "\n");
+ write(" Foo_LUDICROUS = " + .example.Foo.LUDICROUS + "\n");
+
+ write("\nTesting use of enums with functions\n\n");
+
+ .example.enum_test(.example.RED, .example.Foo.IMPULSE);
+ .example.enum_test(.example.BLUE, .example.Foo.WARP);
+ .example.enum_test(.example.GREEN, .example.Foo.LUDICROUS);
+
+ write("\nTesting use of enum with class method\n");
+ .example.Foo f = .example.Foo();
+
+ f->enum_test(.example.Foo.IMPULSE);
+ f->enum_test(.example.Foo.WARP);
+ f->enum_test(.example.Foo.LUDICROUS);
+
+ return 0;
+}
diff --git a/Examples/pike/overload/.cvsignore b/Examples/pike/overload/.cvsignore
new file mode 100644
index 000000000..138171619
--- /dev/null
+++ b/Examples/pike/overload/.cvsignore
@@ -0,0 +1,4 @@
+example.o
+example.so
+example_wrap.cxx
+example_wrap.o
diff --git a/Examples/pike/overload/Makefile b/Examples/pike/overload/Makefile
new file mode 100644
index 000000000..a5a4eb3d4
--- /dev/null
+++ b/Examples/pike/overload/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lstdc++ -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
+check: all
diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx
new file mode 100755
index 000000000..3760fdd49
--- /dev/null
+++ b/Examples/pike/overload/example.cxx
@@ -0,0 +1,115 @@
+#include <iostream>
+
+#include "example.h"
+
+// Overloaded constructors for class Bar
+Bar::Bar() {
+ std::cout << "Called Bar::Bar()" << std::endl;
+}
+
+Bar::Bar(const Bar&) {
+ std::cout << "Called Bar::Bar(const Bar&)" << std::endl;
+}
+
+Bar::Bar(double x) {
+ std::cout << "Called Bar::Bar(double) with x = " << x << std::endl;
+}
+
+Bar::Bar(double x, char *y) {
+ std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl;
+}
+
+Bar::Bar(int x, int y) {
+ std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl;
+}
+
+Bar::Bar(char *x) {
+ std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl;
+}
+
+Bar::Bar(int x) {
+ std::cout << "Called Bar::Bar(int) with x = " << x << std::endl;
+}
+
+Bar::Bar(long x) {
+ std::cout << "Called Bar::Bar(long) with x = " << x << std::endl;
+}
+
+Bar::Bar(Bar *x) {
+ std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl;
+}
+
+// Overloaded member functions
+void Bar::foo(const Bar& x) {
+ std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl;
+}
+
+void Bar::foo(double x) {
+ std::cout << "Called Bar::foo(double) with x = " << x << std::endl;
+}
+
+void Bar::foo(double x, char *y) {
+ std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl;
+}
+
+void Bar::foo(int x, int y) {
+ std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl;
+}
+
+void Bar::foo(char *x) {
+ std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl;
+}
+
+void Bar::foo(int x) {
+ std::cout << "Called Bar::foo(int) with x = " << x << std::endl;
+}
+
+void Bar::foo(long x) {
+ std::cout << "Called Bar::foo(long) with x = " << x << std::endl;
+}
+
+void Bar::foo(Bar *x) {
+ std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl;
+}
+
+void Bar::spam(int x, int y, int z) {
+ std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl;
+}
+
+void Bar::spam(double x, int y, int z) {
+ std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl;
+}
+
+// Overloaded global methods
+void foo(const Bar& x) {
+ std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl;
+}
+
+void foo(double x) {
+ std::cout << "Called foo(double) with x = " << x << std::endl;
+}
+
+void foo(double x, char *y) {
+ std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl;
+}
+
+void foo(int x, int y) {
+ std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl;
+}
+
+void foo(char *x) {
+ std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl;
+}
+
+void foo(int x) {
+ std::cout << "Called foo(int) with x = " << x << std::endl;
+}
+
+void foo(long x) {
+ std::cout << "Called foo(long) with x = " << x << std::endl;
+}
+
+void foo(Bar *x) {
+ std::cout << "Called foo(Bar *) with x = " << x << std::endl;
+}
+
diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h
new file mode 100755
index 000000000..e47a122ee
--- /dev/null
+++ b/Examples/pike/overload/example.h
@@ -0,0 +1,41 @@
+#ifndef EXAMPLE_H
+#define EXAMPLE_H
+
+class Bar {
+public:
+ Bar();
+ Bar(const Bar&);
+ Bar(double);
+ Bar(double, char *);
+ Bar(int, int);
+ Bar(char *);
+ Bar(long);
+ Bar(int);
+ Bar(Bar *);
+
+ void foo(const Bar&);
+ void foo(double);
+ void foo(double, char *);
+ void foo(int, int);
+ void foo(char *);
+ void foo(long);
+ void foo(int);
+ void foo(Bar *);
+
+ void spam(int x, int y=2, int z=3);
+ void spam(double x, int y=2, int z=3);
+};
+
+void foo(const Bar&);
+void foo(double);
+void foo(double, char *);
+void foo(int, int);
+void foo(char *);
+void foo(int);
+void foo(long);
+void foo(Bar *);
+
+void spam(int x, int y=2, int z=3);
+void spam(double x, int y=2, int z=3);
+
+#endif
diff --git a/Examples/pike/overload/example.i b/Examples/pike/overload/example.i
new file mode 100644
index 000000000..ddcd006be
--- /dev/null
+++ b/Examples/pike/overload/example.i
@@ -0,0 +1,28 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/**
+ * These overloaded declarations conflict with other overloads (as far as
+ * SWIG's Ruby module's implementation for overloaded methods is concerned).
+ * One option is use the %rename directive to rename the conflicting methods;
+ * here, we're just using %ignore to avoid wrapping some of the overloaded
+ * functions altogether.
+ */
+
+%ignore Bar;
+
+%ignore Bar::Bar(Bar *);
+%ignore Bar::Bar(long);
+
+%ignore Bar::foo(const Bar&);
+%ignore Bar::foo(long);
+
+%ignore ::foo(const Bar&);
+%ignore ::foo(int);
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Examples/pike/overload/runme.pike b/Examples/pike/overload/runme.pike
new file mode 100644
index 000000000..d30e947b3
--- /dev/null
+++ b/Examples/pike/overload/runme.pike
@@ -0,0 +1,83 @@
+// import .example;
+
+int main()
+{
+ // This should invoke foo(double)
+ .example.foo(3.14159);
+
+ // This should invoke foo(double, char *)
+ .example.foo(3.14159, "Pi");
+
+ // This should invoke foo(int, int)
+ .example.foo(3, 4);
+
+ // This should invoke foo(char *)
+ .example.foo("This is a test");
+
+ // This should invoke foo(long)
+ .example.foo(42);
+
+ /*
+ // This should invoke Bar::Bar() followed by foo(Bar *)
+ foo(Bar.new);
+
+ // Skip a line
+ write("\n");
+
+ // This should invoke Bar::Bar(double)
+ Bar.new(3.14159);
+
+ // This should invoke Bar::Bar(double, char *)
+ Bar.new(3.14159, "Pi");
+
+ // This should invoke Bar::Bar(int, int)
+ Bar.new(3, 4);
+
+ // This should invoke Bar::Bar(char *)
+ Bar.new("This is a test");
+
+ // This should invoke Bar::Bar(int)
+ Bar.new(42);
+
+ // This should invoke Bar::Bar() for the input argument,
+ // followed by Bar::Bar(const Bar&).
+ Bar.new(Bar.new);
+
+ // Skip a line
+ write("\n");
+ */
+
+ // Construct a new Bar instance (invokes Bar::Bar())
+ /*
+ bar = Bar.new;
+
+ // This should invoke Bar::foo(double)
+ bar.foo(3.14159);
+
+ // This should invoke Bar::foo(double, char *)
+ bar.foo(3.14159, "Pi");
+
+ // This should invoke Bar::foo(int, int)
+ bar.foo(3, 4);
+
+ // This should invoke Bar::foo(char *)
+ bar.foo("This is a test");
+
+ // This should invoke Bar::foo(int)
+ bar.foo(42);
+
+ // This should invoke Bar::Bar() to construct the input
+ // argument, followed by Bar::foo(Bar *).
+ bar.foo(Example::Bar.new);
+
+ // This should invoke Bar::spam(int x, int y, int z)
+ bar.spam(1);
+
+ // This should invoke Bar::spam(double x, int y, int z)
+ bar.spam(3.14159);
+ */
+
+ write("Goodbye\n");
+
+ return 0;
+}
diff --git a/Examples/pike/simple/.cvsignore b/Examples/pike/simple/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/pike/simple/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/pike/simple/Makefile b/Examples/pike/simple/Makefile
new file mode 100644
index 000000000..10b8873e1
--- /dev/null
+++ b/Examples/pike/simple/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
+check: all
diff --git a/Examples/pike/simple/example.c b/Examples/pike/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/pike/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/pike/simple/example.i b/Examples/pike/simple/example.i
new file mode 100644
index 000000000..e338cd54c
--- /dev/null
+++ b/Examples/pike/simple/example.i
@@ -0,0 +1,5 @@
+/* File : example.i */
+%module example
+
+extern int gcd(int x, int y);
+/* extern double Foo; */
diff --git a/Examples/pike/simple/runme.pike b/Examples/pike/simple/runme.pike
new file mode 100644
index 000000000..be4033598
--- /dev/null
+++ b/Examples/pike/simple/runme.pike
@@ -0,0 +1,20 @@
+int main()
+{
+ /* Call our gcd() function */
+ int x = 42;
+ int y = 105;
+ int g = .example.gcd(x, y);
+ write(sprintf("The gcd of %d and %d is %d\n", x, y, g));
+
+ /* Manipulate the Foo global variable */
+ /* Output its current value */
+ /* write(sprintf("Foo = %f\n", .example.Foo_get())); */
+
+ /* Change its value */
+ /* .example.Foo_set(3.1415926); */
+
+ /* See if the change took effect */
+ /* write(sprintf("Foo = %f\n", .example.Foo_get())); */
+
+ return 0;
+}
diff --git a/Examples/pike/template/.cvsignore b/Examples/pike/template/.cvsignore
new file mode 100755
index 000000000..bd7dd8a57
--- /dev/null
+++ b/Examples/pike/template/.cvsignore
@@ -0,0 +1 @@
+example_wrap.cxx
diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile
new file mode 100755
index 000000000..1bba9bb2f
--- /dev/null
+++ b/Examples/pike/template/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' pike_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
+check: all
diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h
new file mode 100755
index 000000000..4d9a58c54
--- /dev/null
+++ b/Examples/pike/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template<class T> T max(T a, T b) { return a>b ? a : b; }
+
+template<class T> 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/pike/template/example.i b/Examples/pike/template/example.i
new file mode 100755
index 000000000..8f94c4da1
--- /dev/null
+++ b/Examples/pike/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<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
diff --git a/Examples/pike/template/runme.pike b/Examples/pike/template/runme.pike
new file mode 100755
index 000000000..36825c3e3
--- /dev/null
+++ b/Examples/pike/template/runme.pike
@@ -0,0 +1,33 @@
+int main()
+{
+ // Call some templated functions
+ write(sprintf("%d\n", .example.maxint(3, 7)));
+ write(sprintf("%f\n", .example.maxdouble(3.14, 2.18)));
+
+ // Create some objects
+ .example.vecint iv = .example.vecint(100);
+ .example.vecdouble dv = .example.vecdouble(1000);
+
+ for (int i = 0; i < 100; i++) {
+ iv->setitem(i, 2*i);
+ }
+
+ for (int i = 0; i < 1000; i++) {
+ dv->setitem(i, 1.0/(i+1));
+ }
+
+ int isum = 0;
+ for (int i = 0; i < 100; i++) {
+ isum += iv->getitem(i);
+ }
+
+ write(sprintf("%d\n", isum));
+
+ float fsum = 0.0;
+ for (int i = 0; i < 1000; i++) {
+ fsum += dv->getitem(i);
+ }
+ write(sprintf("%f\n", fsum));
+
+ return 0;
+}
diff --git a/Examples/python/check.list b/Examples/python/check.list
new file mode 100644
index 000000000..9577bf9b3
--- /dev/null
+++ b/Examples/python/check.list
@@ -0,0 +1,23 @@
+# see top-level Makefile.in
+class
+constants
+enum
+exceptshadow
+funcattr
+funcptr
+funcptr2
+functor
+import
+import
+template
+mpointer
+multimap
+operator
+pointer
+reference
+shadow
+simple
+smartptr
+template
+value
+variables
diff --git a/Examples/python/class/.cvsignore b/Examples/python/class/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/class/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile
index 71af176f9..19580883e 100644
--- a/Examples/python/class/Makefile
+++ b/Examples/python/class/Makefile
@@ -14,6 +14,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/class/example.cxx b/Examples/python/class/example.cxx
index 21582f4d1..1e8e203dd 100644
--- a/Examples/python/class/example.cxx
+++ b/Examples/python/class/example.cxx
@@ -1,7 +1,7 @@
/* File : example.c */
#include "example.h"
-#include <math.h>
+#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area() {
+double Circle::area(void) {
return M_PI*radius*radius;
}
-double Circle::perimeter() {
+double Circle::perimeter(void) {
return 2*M_PI*radius;
}
-double Square::area() {
+double Square::area(void) {
return width*width;
}
-double Square::perimeter() {
+double Square::perimeter(void) {
return 4*width;
}
diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp
new file mode 100644
index 000000000..78bb44c81
--- /dev/null
+++ b/Examples/python/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 "$(PYTHON_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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(PYTHON_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 "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(PYTHON_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 PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/class/example.h b/Examples/python/class/example.h
index c0f9b1d57..46d901361 100644
--- a/Examples/python/class/example.h
+++ b/Examples/python/class/example.h
@@ -10,8 +10,8 @@ public:
};
double x, y;
void move(double dx, double dy);
- virtual double area() = 0;
- virtual double perimeter() = 0;
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
static int nshapes;
};
@@ -20,17 +20,17 @@ private:
double radius;
public:
Circle(double r) : radius(r) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
-
+
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
diff --git a/Examples/python/class/example.py b/Examples/python/class/example.py
deleted file mode 100644
index a8c80502a..000000000
--- a/Examples/python/class/example.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# file: example.py
-
-# This file illustrates the low-level C++ interface
-# created by SWIG. In this case, all of our C++ classes
-# get converted into function calls.
-
-import example
-
-# ----- Object creation -----
-
-print "Creating some objects:"
-c = example.new_Circle(10)
-print " Created circle", c
-s = example.new_Square(10)
-print " Created square", s
-
-# ----- Access a static member -----
-
-print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
-
-# ----- Member data access -----
-
-# Set the location of the object
-
-
-example.Shape_x_set(c, 20)
-example.Shape_y_set(c, 30)
-example.Shape_x_set(s,-10)
-example.Shape_y_set(s,5)
-
-print "\nHere is their current position:"
-print " Circle = (%f, %f)" % (example.Shape_x_get(c), example.Shape_y_get(c))
-print " Square = (%f, %f)" % (example.Shape_x_get(s), example.Shape_y_get(s))
-
-# ----- Call some methods -----
-
-print "\nHere are some properties of the shapes:"
-for o in [c,s]:
- print " ", o
- print " area = ", example.Shape_area(o)
- print " perimeter = ", example.Shape_perimeter(o)
-
-# Notice how the Shape_area() and Shape_perimeter() functions really
-# invoke the appropriate virtual method on each object.
-
-# ----- Try to cause a type error -----
-
-print "\nI'm going to try and break the type system"
-try:
- # Bad script!
- Square_area(c) # Try to invoke Square method on a Circle
- print " Bad bad SWIG!"
-except:
- print " Well, it didn't work. Good SWIG."
-
-
-# ----- Delete everything -----
-
-print "\nGuess I'll clean up now"
-
-# Note: this invokes the virtual destructor
-example.delete_Shape(c)
-example.delete_Shape(s)
-
-print example.cvar.Shape_nshapes,"shapes remain"
-print "Goodbye"
-
diff --git a/Examples/python/class/index.html b/Examples/python/class/index.html
index 3529b3ca9..2ec53b0bb 100644
--- a/Examples/python/class/index.html
+++ b/Examples/python/class/index.html
@@ -109,14 +109,14 @@ For example:
<blockquote>
<pre>
-example.Circle_x_set(c,15) # Set member data
+example.Shape_x_set(c,15) # Set member data
x = example.Shape_x_get(c) # Get member data
</pre>
</blockquote>
-Note: when accessing member data, the name of the base class or the derived class can be
-used in the function name as shown above. Of course, it would probably be more
-proper to just use the base class version such as <tt>Shape_x_get()</tt>
+Note: when accessing member data, the name of the class in which
+the member data was must be used. In this case, <tt>Shape_x_get()</tt>
+and <tt>Shape_x_set()</tt> are used since 'x' was defined in Shape.
<p>
<li>To invoke a member function, you simply do this
@@ -164,13 +164,14 @@ example.cvar.Shapes_nshapes = 13 # Set a static data member
<h2>General Comments</h2>
<ul>
-<li>This low-level interface is not the only way to handle C++ code. Shadow classes
-provide a much higher-level interface.
+<li>This low-level interface is not the only way to handle C++ code.
+Shadow classes provide a much higher-level interface.
<p>
-<li>SWIG *does* know how to properly perform upcasting of objects in an inheritance
-hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass
-an object of a derived class to any function involving a base class.
+<li>SWIG *does* know how to properly perform upcasting of objects in
+an inheritance hierarchy (including multiple inheritance). Therefore
+it is perfectly safe to pass an object of a derived class to any
+function involving a base class.
<p>
<li>A wide variety of C++ features are not currently supported by SWIG. Here is the
@@ -207,28 +208,6 @@ to write a helper function. For example:
<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
<p>
-<li>Templates. Not supported at all. SWIG throws out anything that looks like a template.
-You can work around the problem by aliasing a template class behind a typedef however.
-For example:
-
-<blockquote>
-<pre>
-%{
-typedef vector<int> IntVector;
-%}
-
-class IntVector {
-public:
- ... methods ...
-};
-</pre>
-</blockquote>
-</ul>
-<p>
-<li>There is no guarantee that an extremely complex C++ application will be able to compile
-as a Python extension. Sorry.
-
-<p>
<li>Dave's snide remark: Like a large bottle of strong Tequilla, it's better to
use C++ in moderation.
diff --git a/Examples/python/class/runme.py b/Examples/python/class/runme.py
new file mode 100644
index 000000000..42a5aa363
--- /dev/null
+++ b/Examples/python/class/runme.py
@@ -0,0 +1,51 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+import example
+
+# ----- Object creation -----
+
+print "Creating some objects:"
+c = example.Circle(10)
+print " Created circle", c
+s = example.Square(10)
+print " Created square", s
+
+# ----- Access a static member -----
+
+print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print "\nHere is their current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+print " Square = (%f, %f)" % (s.x,s.y)
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:"
+for o in [c,s]:
+ print " ", o
+ print " area = ", o.area()
+ print " perimeter = ", o.perimeter()
+
+print "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print example.cvar.Shape_nshapes,"shapes remain"
+print "Goodbye"
+
diff --git a/Examples/python/constants/.cvsignore b/Examples/python/constants/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/constants/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile
index 453bbc6ee..5b726c2b1 100644
--- a/Examples/python/constants/Makefile
+++ b/Examples/python/constants/Makefile
@@ -13,6 +13,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/constants/example.i b/Examples/python/constants/example.i
index 7d69a4d47..4f7b1a4d7 100644
--- a/Examples/python/constants/example.i
+++ b/Examples/python/constants/example.i
@@ -19,19 +19,9 @@
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
-/* The following statements also produce constants */
-const int iconst = 37;
-const double fconst = 3.14;
-
-%constant(double) PI = 3.14159;
-
-/* Test address of operator */
-
-%{
-static double blah = 1.2345;
-%}
-
-%constant(double *) blahptr = &blah;
+/* The following directives also produce constants */
+%constant int iconst = 37;
+%constant double fconst = 3.14;
diff --git a/Examples/python/constants/example.py b/Examples/python/constants/runme.py
index 5c1b00154..f13c4c373 100644
--- a/Examples/python/constants/example.py
+++ b/Examples/python/constants/runme.py
@@ -11,7 +11,7 @@ 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)"
-print "PI =", example.PI, "(should be 3.14159)"
+
try:
print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)"
except AttributeError:
diff --git a/Examples/python/enum/.cvsignore b/Examples/python/enum/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/enum/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile
index 71af176f9..19580883e 100644
--- a/Examples/python/enum/Makefile
+++ b/Examples/python/enum/Makefile
@@ -14,6 +14,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/enum/example.py b/Examples/python/enum/example.py
deleted file mode 100644
index 92979783e..000000000
--- a/Examples/python/enum/example.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# file: example.py
-
-import example
-
-# ----- Object creation -----
-
-# Print out the value of some enums
-print "*** color ***"
-print " RED =", example.RED
-print " BLUE =", example.BLUE
-print " GREEN =", example.GREEN
-
-print "\n*** Foo::speed ***"
-print " Foo_IMPULSE =", example.Foo_IMPULSE
-print " Foo_WARP =", example.Foo_WARP
-print " Foo_LUDICROUS =", example.Foo_LUDICROUS
-
-print "\nTesting use of enums with functions\n"
-
-example.enum_test(example.RED, example.Foo_IMPULSE)
-example.enum_test(example.BLUE, example.Foo_WARP)
-example.enum_test(example.GREEN, example.Foo_LUDICROUS)
-example.enum_test(1234,5678)
-
-print "\nTesting use of enum with class method"
-f = example.new_Foo()
-
-example.Foo_enum_test(f,example.Foo_IMPULSE)
-example.Foo_enum_test(f,example.Foo_WARP)
-example.Foo_enum_test(f,example.Foo_LUDICROUS)
diff --git a/Examples/python/enum/runme.py b/Examples/python/enum/runme.py
new file mode 100644
index 000000000..e90f5d66f
--- /dev/null
+++ b/Examples/python/enum/runme.py
@@ -0,0 +1,31 @@
+# file: example.py
+
+import example
+
+# ----- Object creation -----
+
+# Print out the value of some enums
+print "*** color ***"
+print " RED =", example.RED
+print " BLUE =", example.BLUE
+print " GREEN =", example.GREEN
+
+print "\n*** Foo::speed ***"
+print " Foo_IMPULSE =", example.Foo.IMPULSE
+print " Foo_WARP =", example.Foo.WARP
+print " Foo_LUDICROUS =", example.Foo.LUDICROUS
+
+print "\nTesting use of enums with functions\n"
+
+example.enum_test(example.RED, example.Foo.IMPULSE)
+example.enum_test(example.BLUE, example.Foo.WARP)
+example.enum_test(example.GREEN, example.Foo.LUDICROUS)
+example.enum_test(1234,5678)
+
+print "\nTesting use of enum with class method"
+f = example.Foo()
+
+f.enum_test(example.Foo.IMPULSE)
+f.enum_test(example.Foo.WARP)
+f.enum_test(example.Foo.LUDICROUS)
+
diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile
new file mode 100644
index 000000000..3e5d97bb0
--- /dev/null
+++ b/Examples/python/exception/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/exception/example.h b/Examples/python/exception/example.h
new file mode 100644
index 000000000..47526434c
--- /dev/null
+++ b/Examples/python/exception/example.h
@@ -0,0 +1,37 @@
+/* File : example.h */
+
+#include <string>
+
+class Exc {
+public:
+ Exc(int c, const char *m) {
+ code = c;
+ strncpy(msg,m,256);
+ }
+ int code;
+ char msg[256];
+};
+
+class Test {
+public:
+ int simple() throw(int) {
+ throw(37);
+ }
+ int message() throw(const char *) {
+ throw("I died.");
+ }
+ int hosed() throw(Exc) {
+ throw(Exc(42,"Hosed"));
+ }
+ 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"));
+ }
+};
+
+
+
+
+
+
diff --git a/Examples/python/exception/example.i b/Examples/python/exception/example.i
new file mode 100644
index 000000000..08672c3a8
--- /dev/null
+++ b/Examples/python/exception/example.i
@@ -0,0 +1,12 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/python/exception/runme.py b/Examples/python/exception/runme.py
new file mode 100644
index 000000000..436958984
--- /dev/null
+++ b/Examples/python/exception/runme.py
@@ -0,0 +1,29 @@
+# file: runme.py
+
+# Throw a lot of exceptions
+
+import example
+
+t = example.Test()
+try:
+ t.simple()
+except RuntimeError,e:
+ print e.args[0]
+
+try:
+ t.message()
+except RuntimeError,e:
+ print e.args[0]
+
+try:
+ t.hosed()
+except example.Exc,e:
+ print e.code, e.msg
+
+for i in range(1,4):
+ try:
+ t.multi(i)
+ except RuntimeError,e:
+ print e.args[0]
+ except example.Exc,e:
+ print e.code, e.msg
diff --git a/Examples/python/exceptshadow/.cvsignore b/Examples/python/exceptshadow/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/exceptshadow/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/exceptshadow/Makefile b/Examples/python/exceptshadow/Makefile
new file mode 100644
index 000000000..f00af7dba
--- /dev/null
+++ b/Examples/python/exceptshadow/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/exceptshadow/example.h b/Examples/python/exceptshadow/example.h
new file mode 100644
index 000000000..cd2f17214
--- /dev/null
+++ b/Examples/python/exceptshadow/example.h
@@ -0,0 +1,51 @@
+/* File : example.h */
+
+// A simple exception
+class EmptyError { };
+class FullError {
+ public:
+ int maxsize;
+ FullError(int m) : maxsize(m) { }
+};
+
+template<typename T> class Queue {
+ int maxsize;
+ T *items;
+ int nitems;
+ int last;
+ public:
+ Queue(int size) {
+ maxsize = size;
+ items = new T[size];
+ nitems = 0;
+ last = 0;
+ }
+ ~Queue() {
+ delete [] items;
+ }
+ void enqueue(T x) throw(FullError) {
+ if (nitems == maxsize) {
+ throw FullError(maxsize);
+ }
+ items[last] = x;
+ last = (last + 1) % maxsize;
+ nitems++;
+ }
+ T dequeue() throw(EmptyError) {
+ T x;
+ if (nitems == 0) throw EmptyError();
+ x = items[(last + maxsize - nitems) % maxsize];
+ nitems--;
+ return x;
+ }
+ int length() {
+ return nitems;
+ }
+};
+
+
+
+
+
+
+
diff --git a/Examples/python/exceptshadow/example.i b/Examples/python/exceptshadow/example.i
new file mode 100644
index 000000000..34f1c8840
--- /dev/null
+++ b/Examples/python/exceptshadow/example.i
@@ -0,0 +1,83 @@
+/* This is a rather sophisticated example that illustrates exception handling,
+ templates, and shadow classes.
+
+ (i) The %exception directive is used to attach exception handlers
+ to specific methods.
+
+ (ii) Exception classes are automatically converted to shadow class
+ objects.
+
+ (iii) The %template directive is used to expand the templates
+*/
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Define some exception handlers for specific methods. In
+ the header file, the enqueue method throws FullError and
+ the dequeue method throws EmptyError. Since we don't
+ want to define an exception handler for everything, we
+ simply write a handler each method individually.
+
+ Note: the *::enqueue syntax means that we simply define
+ the handler for any class with this method defined.
+*/
+
+%exception *::enqueue {
+ try {
+ $action
+ } catch(FullError e) {
+ FullError *ecopy = new FullError(e);
+ PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_FullError, 1);
+ PyErr_SetObject((PyObject *) SWIGTYPE_p_FullError->clientdata, err);
+ return NULL;
+ }
+}
+
+/* Some notes about the code above:
+
+ (0) $action gets replaced with the actual method call.
+
+ (1) We are going to return a copy of the exception object (FullError)
+ to pass back to the Python interpreter. This is why the copy
+ constructor is being called.
+
+ (2) The SWIG_NewPointerObj() call automatically wraps the exception object
+ into a shadow class. The SWIGTYPE_p_FullError is the type-descriptor
+ used for type checking. The "1" indicates that Python will have
+ ownership of the resulting object.
+
+ (3) The PyErr_SetObject call sets the Python exception. However,
+ the SWIGTYPE_p_FullError->clientdata reference may not be
+ obvious. This is actually the Python shadow class object
+ for FullError. Recall that in Python, exceptions are defined
+ as classes. Therefore, this works perfectly as the argument to
+ PyErr_SetObject()! A neat trick perhaps.
+*/
+
+%exception *::dequeue {
+ try {
+ $action
+ } catch(EmptyError e) {
+ EmptyError *ecopy = new EmptyError(e);
+ PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_EmptyError, 1);
+ PyErr_SetObject((PyObject *) SWIGTYPE_p_EmptyError->clientdata, err);
+ return NULL;
+ }
+}
+
+/* Grab the original header file */
+%include "example.h"
+
+/* Instantiate a few templates */
+
+%template(intQueue) Queue<int>;
+%template(doubleQueue) Queue<double>;
+
+
+
+
+
diff --git a/Examples/python/exceptshadow/runme.py b/Examples/python/exceptshadow/runme.py
new file mode 100644
index 000000000..a2ae55584
--- /dev/null
+++ b/Examples/python/exceptshadow/runme.py
@@ -0,0 +1,45 @@
+# file: runme.py
+import example
+
+q = example.intQueue(10)
+
+print "Inserting items into intQueue"
+
+try:
+ for i in range(0,100):
+ q.enqueue(i)
+except example.FullError,e:
+ print "Maxsize is", e.maxsize
+
+print "Removing items"
+
+try:
+ while 1:
+ q.dequeue()
+except example.EmptyError,e:
+ pass
+
+
+q = example.doubleQueue(1000)
+
+print "Inserting items into doubleQueue"
+
+try:
+ for i in range(0,10000):
+ q.enqueue(i*1.5)
+except example.FullError,e:
+ print "Maxsize is", e.maxsize
+
+print "Removing items"
+
+try:
+ while 1:
+ q.dequeue()
+except example.EmptyError,e:
+ pass
+
+
+
+
+
+
diff --git a/Examples/python/funcattr/.cvsignore b/Examples/python/funcattr/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/funcattr/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/funcattr/Makefile b/Examples/python/funcattr/Makefile
new file mode 100644
index 000000000..f00af7dba
--- /dev/null
+++ b/Examples/python/funcattr/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/funcattr/example.i b/Examples/python/funcattr/example.i
new file mode 100644
index 000000000..666ddff4d
--- /dev/null
+++ b/Examples/python/funcattr/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+/* Turn all data attributes into a pair of accessor functions.
+ In this case, a data attribute foo is accessed using
+ foo() and changed using set_foo(). The format strings
+ in %attributefunc() can be used to precisely determine
+ the format of the get/set functions */
+
+%attributefunc(%s,set_%s)
+
+%inline %{
+class Vector {
+public:
+ double x,y,z;
+};
+%}
diff --git a/Examples/python/funcattr/index.html b/Examples/python/funcattr/index.html
new file mode 100644
index 000000000..f89f90ca6
--- /dev/null
+++ b/Examples/python/funcattr/index.html
@@ -0,0 +1,22 @@
+<html>
+<head>
+<title>SWIG:Examples:python:funcattr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/funcattr/</tt>
+<hr>
+
+<H2>Turning Attributes into Functions</H2>
+
+<tt>$Header$</tt><br>
+
+<p>
+This example shows how you can turn data attributes into member functions.
+
+<hr>
+</body>
+</html>
+
diff --git a/Examples/python/funcattr/runme.py b/Examples/python/funcattr/runme.py
new file mode 100644
index 000000000..59432e142
--- /dev/null
+++ b/Examples/python/funcattr/runme.py
@@ -0,0 +1,17 @@
+# file: runme.py
+
+import example
+
+# Create an object
+v = example.Vector()
+
+print "Setting some values"
+# Set some values (using functions instead of attributes)
+v.set_x(3.5)
+v.set_y(4.0)
+v.set_z(10.5)
+
+# Get some values
+print v
+print v.x(), v.y(), v.z()
+
diff --git a/Examples/python/funcptr/.cvsignore b/Examples/python/funcptr/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/funcptr/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile
index e495cfa9a..754c4a029 100644
--- a/Examples/python/funcptr/Makefile
+++ b/Examples/python/funcptr/Makefile
@@ -13,6 +13,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/funcptr/example.c b/Examples/python/funcptr/example.c
index 99583b72e..5c4a3dabf 100644
--- a/Examples/python/funcptr/example.c
+++ b/Examples/python/funcptr/example.c
@@ -15,3 +15,5 @@ int sub(int a, int b) {
int mul(int a, int b) {
return a*b;
}
+
+int (*funcvar)(int,int) = add;
diff --git a/Examples/python/funcptr/example.i b/Examples/python/funcptr/example.i
index 73cc6eb8c..8b3bef678 100644
--- a/Examples/python/funcptr/example.i
+++ b/Examples/python/funcptr/example.i
@@ -8,8 +8,9 @@
extern int do_op(int a, int b, int (*op)(int, int));
/* Now install a bunch of "ops" as constants */
-%constant(int (*)(int,int)) ADD = add;
-%constant(int (*)(int,int)) SUB = sub;
-%constant(int (*)(int,int)) MUL = mul;
+%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/python/funcptr/example.py b/Examples/python/funcptr/runme.py
index a85551bed..a85551bed 100644
--- a/Examples/python/funcptr/example.py
+++ b/Examples/python/funcptr/runme.py
diff --git a/Examples/python/funcptr2/.cvsignore b/Examples/python/funcptr2/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/funcptr2/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile
new file mode 100644
index 000000000..754c4a029
--- /dev/null
+++ b/Examples/python/funcptr2/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/funcptr2/example.c b/Examples/python/funcptr2/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/Examples/python/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/python/funcptr2/example.h b/Examples/python/funcptr2/example.h
new file mode 100644
index 000000000..58989db79
--- /dev/null
+++ b/Examples/python/funcptr2/example.h
@@ -0,0 +1,7 @@
+/* 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);
+
diff --git a/Examples/python/funcptr2/example.i b/Examples/python/funcptr2/example.i
new file mode 100644
index 000000000..81a66146a
--- /dev/null
+++ b/Examples/python/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/python/funcptr2/runme.py b/Examples/python/funcptr2/runme.py
new file mode 100644
index 000000000..a85551bed
--- /dev/null
+++ b/Examples/python/funcptr2/runme.py
@@ -0,0 +1,20 @@
+# file: example.py
+
+import example
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+print "Trying some C callback functions"
+print " a =", a
+print " b =", b
+print " ADD(a,b) =", example.do_op(a,b,example.ADD)
+print " SUB(a,b) =", example.do_op(a,b,example.SUB)
+print " MUL(a,b) =", example.do_op(a,b,example.MUL)
+
+print "Here is what the C callback function objects look like in Python"
+print " ADD =", example.ADD
+print " SUB =", example.SUB
+print " MUL =", example.MUL
diff --git a/Examples/python/functor/.cvsignore b/Examples/python/functor/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/functor/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile
new file mode 100644
index 000000000..dbc78cd8d
--- /dev/null
+++ b/Examples/python/functor/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/functor/example.i b/Examples/python/functor/example.i
new file mode 100644
index 000000000..2fd38176f
--- /dev/null
+++ b/Examples/python/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 T> 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<int>;
+%template(doubleSum) Sum<double>;
+
+
+
+
diff --git a/Examples/python/functor/runme.py b/Examples/python/functor/runme.py
new file mode 100644
index 000000000..8fc0f2ff2
--- /dev/null
+++ b/Examples/python/functor/runme.py
@@ -0,0 +1,17 @@
+# Operator overloading example
+import example
+import math
+
+a = example.intSum(0)
+b = example.doubleSum(100.0)
+
+# Use the objects. They should be callable just like a normal
+# python function.
+
+for i in range(0,100):
+ a(i) # Note: function call
+ b(math.sqrt(i)) # Note: function call
+
+print a.result()
+print b.result()
+
diff --git a/Examples/python/import/.cvsignore b/Examples/python/import/.cvsignore
new file mode 100644
index 000000000..f5a4b68aa
--- /dev/null
+++ b/Examples/python/import/.cvsignore
@@ -0,0 +1,13 @@
+bar.py
+base.py
+foo.py
+spam.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile
new file mode 100644
index 000000000..780c87e88
--- /dev/null
+++ b/Examples/python/import/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -c
+#If your system requires linking with the runtime libraries then set the directory location here
+RUNTIMEDIR =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='base' INTERFACE='base.i' python_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='foo' INTERFACE='foo.i' python_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='bar' INTERFACE='bar.i' python_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='spam' INTERFACE='spam.i' python_multi_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ @rm -f foo.py bar.py spam.py base.py
+
+check: all
diff --git a/Examples/python/import/README b/Examples/python/import/README
new file mode 100644
index 000000000..2f6aa54d6
--- /dev/null
+++ b/Examples/python/import/README
@@ -0,0 +1,28 @@
+This example tests the SWIG run-time libraries and use of the
+%import directive to work with multiple modules.
+
+Use 'python runme.py' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is working correctly, all of the modules will load
+correctly and type checking will work correctly. The
+example requires the use of the SWIG run-time libraries
+which must be built and properly installed.
+
+
+
+
diff --git a/Examples/python/import/bar.h b/Examples/python/import/bar.h
new file mode 100644
index 000000000..fa4185f1f
--- /dev/null
+++ b/Examples/python/import/bar.h
@@ -0,0 +1,22 @@
+#include "base.h"
+
+class Bar : public Base {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual void A() {
+ printf("I'm Bar::A\n");
+ }
+ void B() {
+ printf("I'm Bar::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Bar *fromBase(Base *b) {
+ return dynamic_cast<Bar *>(b);
+ }
+
+};
+
+
diff --git a/Examples/python/import/bar.i b/Examples/python/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/Examples/python/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/Examples/python/import/base.h b/Examples/python/import/base.h
new file mode 100644
index 000000000..be3cdef7d
--- /dev/null
+++ b/Examples/python/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/Examples/python/import/base.i b/Examples/python/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/Examples/python/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/Examples/python/import/foo.h b/Examples/python/import/foo.h
new file mode 100644
index 000000000..dd5184031
--- /dev/null
+++ b/Examples/python/import/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+class Foo : public Base {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual void A() {
+ printf("I'm Foo::A\n");
+ }
+ void B() {
+ printf("I'm Foo::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Foo *fromBase(Base *b) {
+ return dynamic_cast<Foo *>(b);
+ }
+};
+
+
diff --git a/Examples/python/import/foo.i b/Examples/python/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/Examples/python/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/Examples/python/import/runme.py b/Examples/python/import/runme.py
new file mode 100644
index 000000000..6b800ecb8
--- /dev/null
+++ b/Examples/python/import/runme.py
@@ -0,0 +1,111 @@
+# file: runme.py
+# Test various properties of classes defined in separate modules
+
+print "Testing the %import directive"
+import base
+import foo
+import bar
+import spam
+
+# Create some objects
+
+print "Creating some objects"
+
+a = base.Base()
+b = foo.Foo()
+c = bar.Bar()
+d = spam.Spam()
+
+# Try calling some methods
+print "Testing some methods"
+print "",
+print "Should see 'Base::A' ---> ",
+a.A()
+print "Should see 'Base::B' ---> ",
+a.B()
+
+print "Should see 'Foo::A' ---> ",
+b.A()
+print "Should see 'Foo::B' ---> ",
+b.B()
+
+print "Should see 'Bar::A' ---> ",
+c.A()
+print "Should see 'Bar::B' ---> ",
+c.B()
+
+print "Should see 'Spam::A' ---> ",
+d.A()
+print "Should see 'Spam::B' ---> ",
+d.B()
+
+# Try some casts
+
+print "\nTesting some casts\n"
+print "",
+
+x = a.toBase()
+print "Should see 'Base::A' ---> ",
+x.A()
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = b.toBase()
+print "Should see 'Foo::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = c.toBase()
+print "Should see 'Bar::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = d.toBase()
+print "Should see 'Spam::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = d.toBar()
+print "Should see 'Bar::B' ---> ",
+x.B()
+
+print "\nTesting some dynamic casts\n"
+x = d.toBase()
+
+print " Spam -> Base -> Foo : ",
+y = foo.Foo_fromBase(x)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+print " Spam -> Base -> Bar : ",
+y = bar.Bar_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Spam -> Base -> Spam : ",
+y = spam.Spam_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Foo -> Spam : ",
+y = spam.Spam_fromBase(b)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+
+
+
diff --git a/Examples/python/import/spam.h b/Examples/python/import/spam.h
new file mode 100644
index 000000000..b4e7a2646
--- /dev/null
+++ b/Examples/python/import/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+class Spam : public Bar {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual void A() {
+ printf("I'm Spam::A\n");
+ }
+ void B() {
+ printf("I'm Spam::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ virtual Bar *toBar() {
+ return static_cast<Bar *>(this);
+ }
+ static Spam *fromBase(Base *b) {
+ return dynamic_cast<Spam *>(b);
+ }
+};
+
+
diff --git a/Examples/python/import/spam.i b/Examples/python/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/Examples/python/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/Examples/python/import_template/.cvsignore b/Examples/python/import_template/.cvsignore
new file mode 100644
index 000000000..457218f0d
--- /dev/null
+++ b/Examples/python/import_template/.cvsignore
@@ -0,0 +1,10 @@
+base.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile
new file mode 100644
index 000000000..780c87e88
--- /dev/null
+++ b/Examples/python/import_template/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -c
+#If your system requires linking with the runtime libraries then set the directory location here
+RUNTIMEDIR =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='base' INTERFACE='base.i' python_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='foo' INTERFACE='foo.i' python_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='bar' INTERFACE='bar.i' python_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='spam' INTERFACE='spam.i' python_multi_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ @rm -f foo.py bar.py spam.py base.py
+
+check: all
diff --git a/Examples/python/import_template/README b/Examples/python/import_template/README
new file mode 100644
index 000000000..ec3d6ca49
--- /dev/null
+++ b/Examples/python/import_template/README
@@ -0,0 +1,30 @@
+This example tests the SWIG run-time libraries and use of the
+%import directive to work with multiple modules. However,
+unlike the import example, this uses templates to really
+stress test the type-system.
+
+Use 'python runme.py' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is working correctly, all of the modules will load
+correctly and type checking will work correctly. The
+example requires the use of the SWIG run-time libraries
+which must be built and properly installed.
+
+
+
+
diff --git a/Examples/python/import_template/bar.h b/Examples/python/import_template/bar.h
new file mode 100644
index 000000000..500b67a3c
--- /dev/null
+++ b/Examples/python/import_template/bar.h
@@ -0,0 +1,22 @@
+#include "base.h"
+
+template<class T> class Bar : public Base<T> {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual void A() {
+ printf("I'm Bar::A\n");
+ }
+ void B() {
+ printf("I'm Bar::B\n");
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+ static Bar<T> *fromBase(Base<T> *b) {
+ return dynamic_cast<Bar<T> *>(b);
+ }
+
+};
+
+
diff --git a/Examples/python/import_template/bar.i b/Examples/python/import_template/bar.i
new file mode 100644
index 000000000..155c08d34
--- /dev/null
+++ b/Examples/python/import_template/bar.i
@@ -0,0 +1,11 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+%template(intBar) Bar<int>;
+
+
diff --git a/Examples/python/import_template/base.h b/Examples/python/import_template/base.h
new file mode 100644
index 000000000..a56441e14
--- /dev/null
+++ b/Examples/python/import_template/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+template<class T> class Base {
+ public:
+ Base() { };
+ ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+};
+
+
diff --git a/Examples/python/import_template/base.i b/Examples/python/import_template/base.i
new file mode 100644
index 000000000..a6da06339
--- /dev/null
+++ b/Examples/python/import_template/base.i
@@ -0,0 +1,7 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
+%template(intBase) Base<int>;
diff --git a/Examples/python/import_template/foo.h b/Examples/python/import_template/foo.h
new file mode 100644
index 000000000..3df13d20d
--- /dev/null
+++ b/Examples/python/import_template/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+template<class T> class Foo : public Base<T> {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual void A() {
+ printf("I'm Foo::A\n");
+ }
+ void B() {
+ printf("I'm Foo::B\n");
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+ static Foo<T> *fromBase(Base<T> *b) {
+ return dynamic_cast<Foo<T> *>(b);
+ }
+};
+
+
diff --git a/Examples/python/import_template/foo.i b/Examples/python/import_template/foo.i
new file mode 100644
index 000000000..e271672cd
--- /dev/null
+++ b/Examples/python/import_template/foo.i
@@ -0,0 +1,10 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
+%template(intFoo) Foo<int>;
+
diff --git a/Examples/python/import_template/runme.py b/Examples/python/import_template/runme.py
new file mode 100644
index 000000000..0d5aded14
--- /dev/null
+++ b/Examples/python/import_template/runme.py
@@ -0,0 +1,111 @@
+# file: runme.py
+# Test various properties of classes defined in separate modules
+
+print "Testing the %import directive with templates"
+import base
+import foo
+import bar
+import spam
+
+# Create some objects
+
+print "Creating some objects"
+
+a = base.intBase()
+b = foo.intFoo()
+c = bar.intBar()
+d = spam.intSpam()
+
+# Try calling some methods
+print "Testing some methods"
+print "",
+print "Should see 'Base::A' ---> ",
+a.A()
+print "Should see 'Base::B' ---> ",
+a.B()
+
+print "Should see 'Foo::A' ---> ",
+b.A()
+print "Should see 'Foo::B' ---> ",
+b.B()
+
+print "Should see 'Bar::A' ---> ",
+c.A()
+print "Should see 'Bar::B' ---> ",
+c.B()
+
+print "Should see 'Spam::A' ---> ",
+d.A()
+print "Should see 'Spam::B' ---> ",
+d.B()
+
+# Try some casts
+
+print "\nTesting some casts\n"
+print "",
+
+x = a.toBase()
+print "Should see 'Base::A' ---> ",
+x.A()
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = b.toBase()
+print "Should see 'Foo::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = c.toBase()
+print "Should see 'Bar::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = d.toBase()
+print "Should see 'Spam::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = d.toBar()
+print "Should see 'Bar::B' ---> ",
+x.B()
+
+print "\nTesting some dynamic casts\n"
+x = d.toBase()
+
+print " Spam -> Base -> Foo : ",
+y = foo.intFoo_fromBase(x)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+print " Spam -> Base -> Bar : ",
+y = bar.intBar_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Spam -> Base -> Spam : ",
+y = spam.intSpam_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Foo -> Spam : ",
+y = spam.intSpam_fromBase(b)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+
+
+
diff --git a/Examples/python/import_template/spam.h b/Examples/python/import_template/spam.h
new file mode 100644
index 000000000..c72f49a32
--- /dev/null
+++ b/Examples/python/import_template/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+template<class T> class Spam : public Bar<T> {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual void A() {
+ printf("I'm Spam::A\n");
+ }
+ void B() {
+ printf("I'm Spam::B\n");
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+ virtual Bar<T> *toBar() {
+ return static_cast<Bar<T> *>(this);
+ }
+ static Spam<T> *fromBase(Base<T> *b) {
+ return dynamic_cast<Spam<T> *>(b);
+ }
+};
+
+
diff --git a/Examples/python/import_template/spam.i b/Examples/python/import_template/spam.i
new file mode 100644
index 000000000..dd94b0350
--- /dev/null
+++ b/Examples/python/import_template/spam.i
@@ -0,0 +1,10 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+%template(intSpam) Spam<int>;
+
diff --git a/Examples/python/index.html b/Examples/python/index.html
index fcf607895..dc0110716 100644
--- a/Examples/python/index.html
+++ b/Examples/python/index.html
@@ -35,7 +35,11 @@ certain C declarations are turned into constants.
</pre>
</blockquote>
-<li>The compilation of examples is done using the file <tt>Example/Makefile</tt>. This
+<li>
+Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
+</li>
+
+<li>On Unix the compilation of examples is done using the file <tt>Example/Makefile</tt>. This
makefile performs a manual module compilation which is platform specific. Typically,
the steps look like this (Linux):
diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile
new file mode 100644
index 000000000..7a20396b8
--- /dev/null
+++ b/Examples/python/libffi/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/libffi/example.i b/Examples/python/libffi/example.i
new file mode 100644
index 000000000..9a29ec04e
--- /dev/null
+++ b/Examples/python/libffi/example.i
@@ -0,0 +1,176 @@
+/* File : example.i */
+%module example
+
+%{
+#include <unistd.h>
+#include <ffi.h>
+%}
+
+/* A wrapper for execlp() using libffi to handle an arbitrary
+ number of arguments */
+
+%typemap(in) (...) {
+ char **argv;
+ int argc;
+ int i;
+
+ argc = PyTuple_Size(varargs);
+ argv = (char **) malloc(sizeof(char *)*(argc+1));
+ for (i = 0; i < argc; i++) {
+ PyObject *o = PyTuple_GetItem(varargs,i);
+ if (!PyString_Check(o)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ argv[i] = PyString_AsString(o);
+ }
+ argv[i] = NULL;
+ $1 = (void *) argv;
+}
+
+/* Rewrite the function call, using libffi */
+%feature("action") execlp {
+ int i, vc;
+ ffi_cif cif;
+ ffi_type **types;
+ void **values;
+ char **args;
+
+ vc = PyTuple_Size(varargs);
+ types = (ffi_type **) malloc((vc+3)*sizeof(ffi_type *));
+ values = (void **) malloc((vc+3)*sizeof(void *));
+ args = (char **) arg3;
+
+ /* Set up path parameter */
+ types[0] = &ffi_type_pointer;
+ values[0] = &arg1;
+
+ /* Set up first argument */
+ types[1] = &ffi_type_pointer;
+ values[1] = &arg2;
+
+ /* Set up rest of parameters */
+ for (i = 0; i <= vc; i++) {
+ types[2+i] = &ffi_type_pointer;
+ values[2+i] = &args[i];
+ }
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+3,
+ &ffi_type_uint, types) == FFI_OK) {
+ ffi_call(&cif, (void (*)()) execlp, &result, values);
+ } else {
+ PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
+ free(types);
+ free(values);
+ free(arg3);
+ return NULL;
+ }
+ free(types);
+ free(values);
+ free(arg3);
+}
+
+int execlp(const char *path, const char *arg1, ...);
+
+
+/* A wrapper for printf() using libffi */
+
+%{
+ typedef struct {
+ int type;
+ union {
+ int ivalue;
+ double dvalue;
+ void *pvalue;
+ } val;
+ } vtype;
+ enum { VT_INT, VT_DOUBLE, VT_POINTER };
+ %}
+
+%typemap(in) (const char *fmt, ...) {
+ vtype *argv;
+ int argc;
+ int i;
+
+ $1 = PyString_AsString($input);
+
+ argc = PyTuple_Size(varargs);
+ argv = (vtype *) malloc(argc*sizeof(vtype));
+ for (i = 0; i < argc; i++) {
+ PyObject *o = PyTuple_GetItem(varargs,i);
+ if (PyInt_Check(o)) {
+ argv[i].type = VT_INT;
+ argv[i].val.ivalue = PyInt_AsLong(o);
+ } else if (PyFloat_Check(o)) {
+ argv[i].type = VT_DOUBLE;
+ argv[i].val.dvalue = PyFloat_AsDouble(o);
+ } else if (PyString_Check(o)) {
+ argv[i].type = VT_POINTER;
+ argv[i].val.pvalue = (void *) PyString_AsString(o);
+ } else {
+ PyErr_SetString(PyExc_ValueError,"Unsupported argument type");
+ free(argv);
+ return NULL;
+ }
+ }
+
+ $2 = (void *) argv;
+}
+
+/* Rewrite the function call, using libffi */
+%feature("action") printf {
+ int i, vc;
+ ffi_cif cif;
+ ffi_type **types;
+ void **values;
+ vtype *args;
+
+ vc = PyTuple_Size(varargs);
+ types = (ffi_type **) malloc((vc+1)*sizeof(ffi_type *));
+ values = (void **) malloc((vc+1)*sizeof(void *));
+ args = (vtype *) arg2;
+
+ /* Set up fmt parameter */
+ types[0] = &ffi_type_pointer;
+ values[0] = &arg1;
+
+ /* Set up rest of parameters */
+ for (i = 0; i < vc; i++) {
+ switch(args[i].type) {
+ case VT_INT:
+ types[1+i] = &ffi_type_uint;
+ values[1+i] = &args[i].val.ivalue;
+ break;
+ case VT_DOUBLE:
+ types[1+i] = &ffi_type_double;
+ values[1+i] = &args[i].val.dvalue;
+ break;
+ case VT_POINTER:
+ types[1+i] = &ffi_type_pointer;
+ values[1+i] = &args[i].val.pvalue;
+ break;
+ default:
+ abort(); /* Whoa! We're seriously hosed */
+ break;
+ }
+ }
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, vc+1,
+ &ffi_type_uint, types) == FFI_OK) {
+ ffi_call(&cif, (void (*)()) printf, &result, values);
+ } else {
+ PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
+ free(types);
+ free(values);
+ free(args);
+ return NULL;
+ }
+ free(types);
+ free(values);
+ free(args);
+}
+
+int printf(const char *fmt, ...);
+
+
+
+
+
diff --git a/Examples/python/mpointer/.cvsignore b/Examples/python/mpointer/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/mpointer/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/mpointer/Makefile b/Examples/python/mpointer/Makefile
new file mode 100644
index 000000000..343f04f54
--- /dev/null
+++ b/Examples/python/mpointer/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/mpointer/example.cxx b/Examples/python/mpointer/example.cxx
new file mode 100644
index 000000000..1a6bb666a
--- /dev/null
+++ b/Examples/python/mpointer/example.cxx
@@ -0,0 +1,45 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+
+/* 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;
+}
+
+double do_op(Shape *s, double (Shape::*m)(void)) {
+ return (s->*m)();
+}
+
+double (Shape::*areapt())(void) {
+ return &Shape::area;
+}
+
+double (Shape::*perimeterpt())(void) {
+ return &Shape::perimeter;
+}
+
+/* Member pointer variables */
+double (Shape::*areavar)(void) = &Shape::area;
+double (Shape::*perimetervar)(void) = &Shape::perimeter;
+
diff --git a/Examples/python/mpointer/example.h b/Examples/python/mpointer/example.h
new file mode 100644
index 000000000..110fe91c1
--- /dev/null
+++ b/Examples/python/mpointer/example.h
@@ -0,0 +1,50 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+extern double do_op(Shape *s, double (Shape::*m)(void));
+
+/* Functions that return member pointers */
+
+extern double (Shape::*areapt())(void);
+extern double (Shape::*perimeterpt())(void);
+
+/* Global variables that are member pointers */
+extern double (Shape::*areavar)(void);
+extern double (Shape::*perimetervar)(void);
+
+
+
diff --git a/Examples/python/mpointer/example.i b/Examples/python/mpointer/example.i
new file mode 100644
index 000000000..238792be8
--- /dev/null
+++ b/Examples/python/mpointer/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Some constants */
+
+%constant double (Shape::*AREAPT)(void) = &Shape::area;
+%constant double (Shape::*PERIMPT)(void) = &Shape::perimeter;
+%constant double (Shape::*NULLPT)(void) = 0;
+
diff --git a/Examples/python/mpointer/runme.py b/Examples/python/mpointer/runme.py
new file mode 100644
index 000000000..0d20093aa
--- /dev/null
+++ b/Examples/python/mpointer/runme.py
@@ -0,0 +1,51 @@
+# Example using pointers to member functions
+
+import example
+
+# Get the pointers
+
+area_pt = example.areapt()
+perim_pt = example.perimeterpt()
+
+print "area_pt =", area_pt
+print "perim_pt = ", perim_pt
+
+# Create some objects
+
+c = example.Circle(4)
+s = example.Square(10)
+
+# Do some calculations
+
+print "Circle area = ", example.do_op(c,area_pt)
+print "Circle perim = ", example.do_op(c,perim_pt)
+print "Square area = ", example.do_op(s,area_pt)
+print "Square perim = ", example.do_op(s,perim_pt)
+
+print "cvar.areavar =", example.cvar.areavar
+print "cvar.perimetervar =", example.cvar.perimetervar
+
+# Try the variables
+print "Circle area = ", example.do_op(c,example.cvar.areavar)
+print "Circle perim = ", example.do_op(c,example.cvar.perimetervar)
+print "Square area = ", example.do_op(s,example.cvar.areavar)
+print "Square perim = ", example.do_op(s,example.cvar.perimetervar)
+
+# Modify one of the variables
+example.cvar.areavar = perim_pt
+
+print "Circle perimeter = ", example.do_op(c,example.cvar.areavar)
+
+# Try the constants
+
+print "example.AREAPT =", example.AREAPT
+print "example.PERIMPT=", example.PERIMPT
+print "example.NULLPT =", example.NULLPT
+
+print "Circle area = ", example.do_op(c,example.AREAPT)
+print "Circle perim = ", example.do_op(c,example.PERIMPT)
+print "Square area = ", example.do_op(s,example.AREAPT)
+print "Square perim = ", example.do_op(s,example.PERIMPT)
+
+
+
diff --git a/Examples/python/multimap/.cvsignore b/Examples/python/multimap/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/multimap/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile
new file mode 100644
index 000000000..754c4a029
--- /dev/null
+++ b/Examples/python/multimap/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/multimap/example.c b/Examples/python/multimap/example.c
new file mode 100644
index 000000000..d135481af
--- /dev/null
+++ b/Examples/python/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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/python/multimap/example.dsp b/Examples/python/multimap/example.dsp
new file mode 100644
index 000000000..e905647a5
--- /dev/null
+++ b/Examples/python/multimap/example.dsp
@@ -0,0 +1,148 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PYTHON_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 "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(PYTHON_LIB) /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i
new file mode 100644
index 000000000..d95b3b141
--- /dev/null
+++ b/Examples/python/multimap/example.i
@@ -0,0 +1,83 @@
+/* File : example.i */
+%module example
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in,fragment="t_output_helper") (int argc, char *argv[]) {
+ int i;
+ if (!PyList_Check($input)) {
+ SWIG_exception(SWIG_ValueError, "Expecting a list");
+ return NULL;
+ }
+ $1 = PyList_Size($input);
+ if ($1 == 0) {
+ SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
+ return NULL;
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ PyObject *s = PyList_GetItem($input,i);
+ if (!PyString_Check(s)) {
+ SWIG_exception(SWIG_ValueError, "List items must be strings");
+ free($2);
+ return NULL;
+ }
+ $2[i] = PyString_AsString(s);
+ }
+ $2[i] = 0;
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(python,in) (char *bytes, int len) {
+ if (!PyString_Check($input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ $1 = PyString_AsString($input);
+ $2 = PyString_Size($input);
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+/* Since str is modified, we make a copy of the Python object
+ so that we don't violate it's mutability */
+
+%typemap(python,in) (char *str, int len) {
+ $2 = PyString_Size($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,PyString_AsString($input),$2);
+}
+
+/* Return the mutated string as a new object. The t_output_helper
+ function takes an object and appends it to the output object
+ to create a tuple */
+
+%typemap(python,argout) (char *str, int len) {
+ PyObject *o;
+ o = PyString_FromStringAndSize($1,$2);
+ $result = t_output_helper($result,o);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ return NULL;
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/Examples/python/multimap/runme.py b/Examples/python/multimap/runme.py
new file mode 100644
index 000000000..95669c4bb
--- /dev/null
+++ b/Examples/python/multimap/runme.py
@@ -0,0 +1,27 @@
+# file: example.py
+
+import example
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = example.gcd(x,y)
+print "The gcd of %d and %d is %d" % (x,y,g)
+
+# Call the gcdmain() function
+example.gcdmain(["gcdmain","42","105"])
+
+# Call the count function
+print example.count("Hello World", "l")
+
+# Call the capitalize function
+
+print example.capitalize("hello world")
+
+
+
+
+
+
+
diff --git a/Examples/python/operator/.cvsignore b/Examples/python/operator/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/operator/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile
new file mode 100644
index 000000000..dbc78cd8d
--- /dev/null
+++ b/Examples/python/operator/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/operator/example.h b/Examples/python/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/Examples/python/operator/example.h
@@ -0,0 +1,36 @@
+/* File : example.h */
+#include <math.h>
+
+class Complex {
+private:
+ double rpart, ipart;
+public:
+ Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
+ Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
+ Complex &operator=(const Complex &c) {
+ rpart = c.rpart;
+ ipart = c.ipart;
+ return *this;
+ }
+ Complex operator+(const Complex &c) const {
+ return Complex(rpart+c.rpart, ipart+c.ipart);
+ }
+ Complex operator-(const Complex &c) const {
+ return Complex(rpart-c.rpart, ipart-c.ipart);
+ }
+ Complex operator*(const Complex &c) const {
+ return Complex(rpart*c.rpart - ipart*c.ipart,
+ rpart*c.ipart + c.rpart*ipart);
+ }
+ Complex operator-() const {
+ return Complex(-rpart, -ipart);
+ }
+
+ double re() const { return rpart; }
+ double im() const { return ipart; }
+};
+
+
+
+
+
diff --git a/Examples/python/operator/example.i b/Examples/python/operator/example.i
new file mode 100644
index 000000000..f46619501
--- /dev/null
+++ b/Examples/python/operator/example.i
@@ -0,0 +1,28 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* This header file is a little tough to handle because it has overloaded
+ operators and constructors. We're going to try and deal with that here */
+
+/* This turns the copy constructor in a function ComplexCopy() that can
+ be called */
+
+%rename(ComplexCopy) Complex::Complex(Complex const &);
+
+/* Now grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend Complex {
+ char *__str__() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", self->re(), self->im());
+ return temp;
+ }
+};
+
+
diff --git a/Examples/python/operator/runme.py b/Examples/python/operator/runme.py
new file mode 100644
index 000000000..3687a38de
--- /dev/null
+++ b/Examples/python/operator/runme.py
@@ -0,0 +1,21 @@
+# Operator overloading example
+import example
+
+a = example.Complex(2,3)
+b = example.Complex(-5,10)
+
+print "a =",a
+print "b =",b
+
+c = a + b
+print "c =",c
+print "a*b =",a*b
+print "a-c =",a-c
+
+e = example.ComplexCopy(a-c)
+print "e =",e
+
+# Big expression
+f = ((a+b)*(c+b*e)) + (-a)
+print "f =",f
+
diff --git a/Examples/python/overload_feature/.cvsignore b/Examples/python/overload_feature/.cvsignore
new file mode 100644
index 000000000..572904d30
--- /dev/null
+++ b/Examples/python/overload_feature/.cvsignore
@@ -0,0 +1,2 @@
+example.py
+
diff --git a/Examples/python/pointer/.cvsignore b/Examples/python/pointer/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/pointer/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile
index e495cfa9a..754c4a029 100644
--- a/Examples/python/pointer/Makefile
+++ b/Examples/python/pointer/Makefile
@@ -13,6 +13,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/pointer/example.i b/Examples/python/pointer/example.i
index 2ed2b5bbf..4483b0f77 100644
--- a/Examples/python/pointer/example.i
+++ b/Examples/python/pointer/example.i
@@ -6,7 +6,8 @@
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
-%include pointer.i
+%include cpointer.i
+%pointer_functions(int, intp);
/* Next we'll use some typemaps */
diff --git a/Examples/python/pointer/example.py b/Examples/python/pointer/runme.py
index c7363ab3a..1e405851e 100644
--- a/Examples/python/pointer/example.py
+++ b/Examples/python/pointer/runme.py
@@ -4,9 +4,11 @@ import example;
# First create some objects using the pointer library.
print "Testing the pointer library";
-a = example.ptrcreate("int",37);
-b = example.ptrcreate("int",42);
-c = example.ptrcreate("int");
+a = example.new_intp();
+b = example.new_intp();
+c = example.new_intp();
+example.intp_assign(a,37);
+example.intp_assign(b,42);
print " a =",a
print " b =",b
@@ -16,13 +18,13 @@ print " c =",c
example.add(a,b,c)
# Now get the result
-r = example.ptrvalue(c)
+r = example.intp_value(c)
print " 37 + 42 =",r
# Clean up the pointers
-example.ptrfree(a)
-example.ptrfree(b)
-example.ptrfree(c)
+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
diff --git a/Examples/python/reference/.cvsignore b/Examples/python/reference/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/reference/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile
index 71af176f9..19580883e 100644
--- a/Examples/python/reference/Makefile
+++ b/Examples/python/reference/Makefile
@@ -14,6 +14,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/reference/example.i b/Examples/python/reference/example.i
index 8538326f6..5be92914f 100644
--- a/Examples/python/reference/example.i
+++ b/Examples/python/reference/example.i
@@ -8,6 +8,8 @@
#include "example.h"
%}
+%rename(cprint) print;
+
class Vector {
public:
Vector(double x, double y, double z);
@@ -31,7 +33,7 @@ public:
int size();
/* This wrapper provides an alternative to the [] operator */
- %addmethods {
+ %extend {
Vector &get(int index) {
return (*self)[index];
}
diff --git a/Examples/python/reference/example.py b/Examples/python/reference/runme.py
index dae49f181..10a2dee12 100644
--- a/Examples/python/reference/example.py
+++ b/Examples/python/reference/runme.py
@@ -8,11 +8,11 @@ import example
# ----- Object creation -----
print "Creating some objects:"
-a = example.new_Vector(3,4,5)
-b = example.new_Vector(10,11,12)
+a = example.Vector(3,4,5)
+b = example.Vector(10,11,12)
-print " Created",example.Vector_print(a)
-print " Created",example.Vector_print(b)
+print " Created",a.cprint()
+print " Created",b.cprint()
# ----- Call an overloaded operator -----
@@ -24,49 +24,41 @@ print " Created",example.Vector_print(b)
print "Adding a+b"
c = example.addv(a,b)
-print " a+b =", example.Vector_print(c)
+print " a+b =", c.cprint()
# Note: Unless we free the result, a memory leak will occur
-example.delete_Vector(c)
+del c
# ----- Create a vector array -----
# Note: Using the high-level interface here
print "Creating an array of vectors"
-va = example.new_VectorArray(10)
+va = example.VectorArray(10)
print " va = ",va
# ----- Set some values in the array -----
# These operators copy the value of $a and $b to the vector array
-example.VectorArray_set(va,0,a)
-example.VectorArray_set(va,1,b)
+va.set(0,a)
+va.set(1,b)
-# This will work, but it will cause a memory leak!
-
-example.VectorArray_set(va,2,example.addv(a,b))
-
-# The non-leaky way to do it
-
-c = example.addv(a,b)
-example.VectorArray_set(va,3,c)
-example.delete_Vector(c)
+va.set(2,example.addv(a,b))
# Get some values from the array
print "Getting some array values"
for i in range(0,5):
- print " va(%d) = %s" % (i, example.Vector_print(example.VectorArray_get(va,i)))
+ print " va(%d) = %s" % (i, va.get(i).cprint())
# Watch under resource meter to check on this
print "Making sure we don't leak memory."
for i in xrange(0,1000000):
- c = example.VectorArray_get(va,i % 10)
+ c = va.get(i % 10)
# ----- Clean up -----
print "Cleaning up"
-example.delete_VectorArray(va)
-example.delete_Vector(a)
-example.delete_Vector(b)
+del va
+del a
+del b
diff --git a/Examples/python/shadow/.cvsignore b/Examples/python/shadow/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/shadow/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/shadow/Makefile b/Examples/python/shadow/Makefile
index 908edc992..343f04f54 100644
--- a/Examples/python/shadow/Makefile
+++ b/Examples/python/shadow/Makefile
@@ -1,19 +1,21 @@
TOP = ../..
-SWIG = $(TOP)/../swig -shadow
+SWIG = $(TOP)/../swig
CXXSRCS = example.cxx
-TARGET = examplec
+TARGET = example
INTERFACE = example.i
LIBS = -lm
+SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/simple/.cvsignore b/Examples/python/simple/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/simple/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile
index e495cfa9a..754c4a029 100644
--- a/Examples/python/simple/Makefile
+++ b/Examples/python/simple/Makefile
@@ -13,6 +13,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp
new file mode 100644
index 000000000..9b0078861
--- /dev/null
+++ b/Examples/python/simple/example.dsp
@@ -0,0 +1,148 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(PYTHON_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 "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/simple/example.py b/Examples/python/simple/runme.py
index 381f7ce58..381f7ce58 100644
--- a/Examples/python/simple/example.py
+++ b/Examples/python/simple/runme.py
diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile
new file mode 100644
index 000000000..343f04f54
--- /dev/null
+++ b/Examples/python/smartptr/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/smartptr/example.cxx b/Examples/python/smartptr/example.cxx
new file mode 100644
index 000000000..21582f4d1
--- /dev/null
+++ b/Examples/python/smartptr/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/Examples/python/smartptr/example.h b/Examples/python/smartptr/example.h
new file mode 100644
index 000000000..c0f9b1d57
--- /dev/null
+++ b/Examples/python/smartptr/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() = 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();
+};
+
+
+
+
+
diff --git a/Examples/python/smartptr/example.i b/Examples/python/smartptr/example.i
new file mode 100644
index 000000000..83da4f144
--- /dev/null
+++ b/Examples/python/smartptr/example.i
@@ -0,0 +1,20 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+#include "smartptr.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Grab smart pointer template */
+
+%include "smartptr.h"
+
+/* Instantiate smart-pointers */
+
+%template(ShapePtr) SmartPtr<Shape>;
+
+
diff --git a/Examples/python/smartptr/runme.py b/Examples/python/smartptr/runme.py
new file mode 100644
index 000000000..15e5232e2
--- /dev/null
+++ b/Examples/python/smartptr/runme.py
@@ -0,0 +1,55 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+import example
+
+# ----- Object creation -----
+
+print "Creating some objects:"
+cc = example.Circle(10)
+c = example.ShapePtr(cc)
+print " Created circle", c
+ss = example.Square(10)
+s = example.ShapePtr(ss)
+print " Created square", s
+
+# ----- Access a static member -----
+
+print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print "\nHere is their current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+print " Square = (%f, %f)" % (s.x,s.y)
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:"
+for o in [c,s]:
+ print " ", o
+ print " area = ", o.area()
+ print " perimeter = ", o.perimeter()
+
+print "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+del c
+del s
+del cc
+del ss
+
+s = 3
+print example.cvar.Shape_nshapes,"shapes remain"
+print "Goodbye"
+
diff --git a/Examples/python/smartptr/smartptr.h b/Examples/python/smartptr/smartptr.h
new file mode 100644
index 000000000..2ffa1ca0e
--- /dev/null
+++ b/Examples/python/smartptr/smartptr.h
@@ -0,0 +1,13 @@
+template<class T> class SmartPtr {
+public:
+ SmartPtr(T *realPtr = 0) { pointee = realPtr; }
+ T *operator->() const {
+ return pointee;
+ }
+ T &operator*() const {
+ return *pointee;
+ }
+private:
+ T *pointee;
+};
+
diff --git a/Examples/python/std_vector/.cvsignore b/Examples/python/std_vector/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/std_vector/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile
new file mode 100644
index 000000000..f00af7dba
--- /dev/null
+++ b/Examples/python/std_vector/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/std_vector/example.h b/Examples/python/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/Examples/python/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h */
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<double> half(const std::vector<double>& v) {
+ std::vector<double> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::vector<double>& v) {
+ // would you believe this is the same as the above?
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+
diff --git a/Examples/python/std_vector/example.i b/Examples/python/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/Examples/python/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<int>;
+ %template(DoubleVector) vector<double>;
+}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/python/std_vector/runme.py b/Examples/python/std_vector/runme.py
new file mode 100644
index 000000000..d248ccbbb
--- /dev/null
+++ b/Examples/python/std_vector/runme.py
@@ -0,0 +1,36 @@
+# file: runme.py
+
+import example
+
+# Call average with a Python list...
+
+print example.average([1,2,3,4])
+
+# ... or a wrapped std::vector<int>
+
+v = example.IntVector(4)
+for i in range(len(v)):
+ v[i] = i+1
+print example.average(v)
+
+
+# half will return a Python list.
+# Call it with a Python tuple...
+
+print example.half((1.0, 1.5, 2.0, 2.5, 3.0))
+
+# ... or a wrapped std::vector<double>
+
+v = example.DoubleVector()
+for i in [1,2,3,4]:
+ v.append(i)
+print example.half(v)
+
+
+# now halve a wrapped std::vector<double> in place
+
+example.halve_in_place(v)
+for i in range(len(v)):
+ print v[i], "; ",
+print
+
diff --git a/Examples/python/template/.cvsignore b/Examples/python/template/.cvsignore
new file mode 100644
index 000000000..d29d3bb46
--- /dev/null
+++ b/Examples/python/template/.cvsignore
@@ -0,0 +1,10 @@
+example.py
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile
new file mode 100644
index 000000000..f00af7dba
--- /dev/null
+++ b/Examples/python/template/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/template/example.h b/Examples/python/template/example.h
new file mode 100644
index 000000000..4d9a58c54
--- /dev/null
+++ b/Examples/python/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template<class T> T max(T a, T b) { return a>b ? a : b; }
+
+template<class T> 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/python/template/example.i b/Examples/python/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/Examples/python/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<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
diff --git a/Examples/python/template/runme.py b/Examples/python/template/runme.py
new file mode 100644
index 000000000..05940bc67
--- /dev/null
+++ b/Examples/python/template/runme.py
@@ -0,0 +1,34 @@
+# file: runme.py
+
+import example
+
+# Call some templated functions
+print example.maxint(3,7)
+print example.maxdouble(3.14,2.18)
+
+# Create some class
+
+iv = example.vecint(100)
+dv = example.vecdouble(1000)
+
+for i in range(0,100):
+ iv.setitem(i,2*i)
+
+for i in range(0,1000):
+ dv.setitem(i, 1.0/(i+1))
+
+sum = 0
+for i in range(0,100):
+ sum = sum + iv.getitem(i)
+
+print sum
+
+sum = 0.0
+for i in range(0,1000):
+ sum = sum + dv.getitem(i)
+print sum
+
+del iv
+del dv
+
+
diff --git a/Examples/python/value/.cvsignore b/Examples/python/value/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/value/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/value/Makefile b/Examples/python/value/Makefile
index e495cfa9a..754c4a029 100644
--- a/Examples/python/value/Makefile
+++ b/Examples/python/value/Makefile
@@ -13,6 +13,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile
new file mode 100644
index 000000000..5b726c2b1
--- /dev/null
+++ b/Examples/python/varargs/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/Examples/python/varargs/example.i b/Examples/python/varargs/example.i
new file mode 100644
index 000000000..323bb82ee
--- /dev/null
+++ b/Examples/python/varargs/example.i
@@ -0,0 +1,65 @@
+/* File : example.i */
+%module example
+
+%{
+#include <stdarg.h>
+%}
+
+/* This example illustrates SWIG's handling of varargs functions.
+ By default, variable length arguments are simply ignored. This
+ is generally appropriate for wrapping I/O functions like printf.
+ You can simply format a string in the scripting language, and
+ pass it directly */
+
+int printf(const char *fmt, ...);
+
+/* Since passing a format string might be dangerous. Here is a slightly
+ different way of wrapping a printf style function */
+
+#if 1
+/* Replace ... with char *. */
+%varargs(char *) fprintf;
+
+/* Ignore the format string, but set it to %s */
+%typemap(ignore) const char *fmt {
+ $1 = "%s";
+}
+#else
+/* An alternative approach using typemaps */
+%typemap(in) (const char *fmt, ...) {
+ $1 = "%s";
+ $2 = (void *) PyString_AsString($input);
+}
+#endif
+
+/* Typemap just to make the example work */
+%typemap(in) FILE * "$1 = PyFile_AsFile($input);";
+
+int fprintf(FILE *, const char *fmt, ...);
+
+/* Here is somewhat different example. A variable length argument
+ function that takes a NULL-terminated list of arguments. We
+ can use a slightly different form of %varargs that specifies
+ a default value and a maximum number of arguments.
+ */
+
+/* Maximum of 20 arguments with default value NULL */
+
+%varargs(20, char *x = NULL) printv;
+
+%inline %{
+void printv(char *s, ...) {
+ va_list ap;
+ char *x;
+ fputs(s,stdout);
+ fputc(' ',stdout);
+ va_start(ap, s);
+ while ((x = va_arg(ap, char *))) {
+ fputs(x,stdout);
+ fputc(' ',stdout);
+ }
+ va_end(ap);
+ fputc('\n',stdout);
+}
+%}
+
diff --git a/Examples/python/varargs/runme.py b/Examples/python/varargs/runme.py
new file mode 100644
index 000000000..c79b8b120
--- /dev/null
+++ b/Examples/python/varargs/runme.py
@@ -0,0 +1,34 @@
+# file: example.py
+
+import sys
+import example
+
+# Call printf
+example.printf("Hello World. I'm printf\n")
+
+# Note: We call printf, but use *python* string formatting
+for i in range(0,10):
+ example.printf("i is %d\n" % i)
+
+# This will probably be garbled because %d is interpreted by C
+example.printf("The value is %d\n")
+
+# Call fprintf
+example.fprintf(sys.stdout,"Hello World. I'm fprintf\n")
+for i in range(0,10):
+ example.fprintf(sys.stdout,"i is %d\n" % i)
+
+# This won't be garbled since %d is not interpreted
+example.fprintf(sys.stdout,"The value is %d\n")
+
+# This function calls our NULL-terminated function
+
+example.printv("Hello","World","this","is","a","test.")
+
+
+
+
+
+
+
+
diff --git a/Examples/python/variables/.cvsignore b/Examples/python/variables/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/python/variables/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile
index e495cfa9a..754c4a029 100644
--- a/Examples/python/variables/Makefile
+++ b/Examples/python/variables/Makefile
@@ -13,6 +13,7 @@ static::
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
- rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
check: all
diff --git a/Examples/python/variables/example.i b/Examples/python/variables/example.i
index 35eafc2c0..91bd0679d 100644
--- a/Examples/python/variables/example.i
+++ b/Examples/python/variables/example.i
@@ -27,10 +27,10 @@ extern Point pt;
/* Some read-only variables */
-%readonly {
+%immutable;
extern int status;
extern char path[256];
-}
+%mutable;
/* Some helper functions to make it easier to test */
extern void print_vars();
diff --git a/Examples/python/variables/index.html b/Examples/python/variables/index.html
index 12cacbf64..3bdf705f5 100644
--- a/Examples/python/variables/index.html
+++ b/Examples/python/variables/index.html
@@ -69,21 +69,21 @@ Getting the "value" returns a pointer to the global variable. Setting the value
<h2>Creating read-only variables</h2>
-The <tt>%readonly</tt> and <tt>%readwrite</tt> directives can be used to
+The <tt>%immutable</tt> and <tt>%mutable</tt> directives can be used to
specify a collection of read-only variables. For example:
<blockquote>
<pre>
-%readonly
+%immutable;
int status;
double blah;
...
-%readwrite
+%mutable;
</pre>
</blockquote>
-The <tt>%readonly</tt> directive remains in effect until it is explicitly disabled
-using the <tt>%readwrite</tt> directive.
+The <tt>%immutable</tt> directive remains in effect until it is explicitly disabled
+using the <tt>%mutable</tt> directive.
<h2>Comments</h2>
<ul>
diff --git a/Examples/python/variables/example.py b/Examples/python/variables/runme.py
index 7aab7a38f..7aab7a38f 100644
--- a/Examples/python/variables/example.py
+++ b/Examples/python/variables/runme.py
diff --git a/Examples/ruby/check.list b/Examples/ruby/check.list
new file mode 100644
index 000000000..2041cd5c4
--- /dev/null
+++ b/Examples/ruby/check.list
@@ -0,0 +1,21 @@
+# see top-level Makefile.in
+class
+constants
+enum
+funcptr
+funcptr2
+functor
+hashargs
+import
+template
+mpointer
+multimap
+operator
+overloading
+pointer
+reference
+simple
+std_vector
+template
+value
+variables
diff --git a/Examples/ruby/class/.cvsignore b/Examples/ruby/class/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/class/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/class/Makefile b/Examples/ruby/class/Makefile
index 01ce757ff..ab8928c0e 100644
--- a/Examples/ruby/class/Makefile
+++ b/Examples/ruby/class/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/class/example.cxx b/Examples/ruby/class/example.cxx
index 21582f4d1..1e8e203dd 100644
--- a/Examples/ruby/class/example.cxx
+++ b/Examples/ruby/class/example.cxx
@@ -1,7 +1,7 @@
/* File : example.c */
#include "example.h"
-#include <math.h>
+#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area() {
+double Circle::area(void) {
return M_PI*radius*radius;
}
-double Circle::perimeter() {
+double Circle::perimeter(void) {
return 2*M_PI*radius;
}
-double Square::area() {
+double Square::area(void) {
return width*width;
}
-double Square::perimeter() {
+double Square::perimeter(void) {
return 4*width;
}
diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp
new file mode 100644
index 000000000..d6afbb8b5
--- /dev/null
+++ b/Examples/ruby/class/example.dsp
@@ -0,0 +1,154 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept /EXPORT:Init_example
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" /EXPORT:Init_example
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/ruby/class/example.h b/Examples/ruby/class/example.h
index c0f9b1d57..46d901361 100644
--- a/Examples/ruby/class/example.h
+++ b/Examples/ruby/class/example.h
@@ -10,8 +10,8 @@ public:
};
double x, y;
void move(double dx, double dy);
- virtual double area() = 0;
- virtual double perimeter() = 0;
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
static int nshapes;
};
@@ -20,17 +20,17 @@ private:
double radius;
public:
Circle(double r) : radius(r) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
-
+
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
diff --git a/Examples/ruby/class/index.html b/Examples/ruby/class/index.html
index 5e8e8c852..381bbd4f8 100644
--- a/Examples/ruby/class/index.html
+++ b/Examples/ruby/class/index.html
@@ -188,29 +188,9 @@ to write a helper function. For example:
<p>
<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
-<p>
-<li>Templates. Not supported at all. SWIG throws out anything that looks like a template.
-You can work around the problem by aliasing a template class behind a typedef however.
-For example:
-
-<blockquote>
-<pre>
-%{
-typedef vector<int> IntVector;
-%}
-
-class IntVector {
-public:
- ... methods ...
-};
-</pre>
-</blockquote>
</ul>
<p>
-<li>There is no guarantee that an extremely complex C++ application will be able to compile
-as a Ruby extension. Sorry.
-<p>
<li>Dave's snide remark: Like a large bottle of strong Tequilla, it's better to
use C++ in moderation.
diff --git a/Examples/ruby/constants/.cvsignore b/Examples/ruby/constants/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/constants/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/constants/Makefile b/Examples/ruby/constants/Makefile
index f6ec694b7..0dcb02f0d 100644
--- a/Examples/ruby/constants/Makefile
+++ b/Examples/ruby/constants/Makefile
@@ -13,6 +13,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/constants/example.i b/Examples/ruby/constants/example.i
index 29a1a7f11..14eb23cad 100644
--- a/Examples/ruby/constants/example.i
+++ b/Examples/ruby/constants/example.i
@@ -19,8 +19,9 @@
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
-/* The following statements also produce constants */
-const int iconst = 37;
-const double fconst = 3.14;
+/* The following directives also produce constants */
+
+%constant int Iconst = 37;
+%constant double Fconst = 3.14;
diff --git a/Examples/ruby/constants/run.rb b/Examples/ruby/constants/runme.rb
index f0d5a89e7..f0d5a89e7 100644..100755
--- a/Examples/ruby/constants/run.rb
+++ b/Examples/ruby/constants/runme.rb
diff --git a/Examples/ruby/enum/.cvsignore b/Examples/ruby/enum/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/enum/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/enum/Makefile b/Examples/ruby/enum/Makefile
index 01ce757ff..ab8928c0e 100644
--- a/Examples/ruby/enum/Makefile
+++ b/Examples/ruby/enum/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/funcptr/.cvsignore b/Examples/ruby/funcptr/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/funcptr/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/funcptr/Makefile b/Examples/ruby/funcptr/Makefile
index cd0fdf300..0a59614c4 100644
--- a/Examples/ruby/funcptr/Makefile
+++ b/Examples/ruby/funcptr/Makefile
@@ -13,6 +13,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/funcptr/example.i b/Examples/ruby/funcptr/example.i
index 73cc6eb8c..39390da27 100644
--- a/Examples/ruby/funcptr/example.i
+++ b/Examples/ruby/funcptr/example.i
@@ -8,8 +8,8 @@
extern int do_op(int a, int b, int (*op)(int, int));
/* Now install a bunch of "ops" as constants */
-%constant(int (*)(int,int)) ADD = add;
-%constant(int (*)(int,int)) SUB = sub;
-%constant(int (*)(int,int)) MUL = mul;
+%constant int (*ADD)(int,int) = add;
+%constant int (*SUB)(int,int) = sub;
+%constant int (*MUL)(int,int) = mul;
diff --git a/Examples/ruby/funcptr2/.cvsignore b/Examples/ruby/funcptr2/.cvsignore
new file mode 100644
index 000000000..c50c39e9f
--- /dev/null
+++ b/Examples/ruby/funcptr2/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+*.dll
+*.dsw
+*.ncb
+*.opt
+*.plg
+Release
+Debug
diff --git a/Examples/ruby/funcptr2/Makefile b/Examples/ruby/funcptr2/Makefile
new file mode 100644
index 000000000..0a59614c4
--- /dev/null
+++ b/Examples/ruby/funcptr2/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/funcptr2/example.c b/Examples/ruby/funcptr2/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/Examples/ruby/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/ruby/funcptr2/example.h b/Examples/ruby/funcptr2/example.h
new file mode 100644
index 000000000..58989db79
--- /dev/null
+++ b/Examples/ruby/funcptr2/example.h
@@ -0,0 +1,7 @@
+/* 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);
+
diff --git a/Examples/ruby/funcptr2/example.i b/Examples/ruby/funcptr2/example.i
new file mode 100644
index 000000000..81a66146a
--- /dev/null
+++ b/Examples/ruby/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/ruby/funcptr2/runme.rb b/Examples/ruby/funcptr2/runme.rb
new file mode 100644
index 000000000..9a2f65166
--- /dev/null
+++ b/Examples/ruby/funcptr2/runme.rb
@@ -0,0 +1,18 @@
+require 'example'
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+puts "Trying some C callback functions"
+puts " a = #{a}"
+puts " b = #{b}"
+puts " ADD(a,b) = #{Example.do_op(a,b,Example::ADD)}"
+puts " SUB(a,b) = #{Example.do_op(a,b,Example::SUB)}"
+puts " MUL(a,b) = #{Example.do_op(a,b,Example::MUL)}"
+
+puts "Here is what the C callback function objects look like in Ruby"
+puts " ADD = #{Example::ADD}"
+puts " SUB = #{Example::SUB}"
+puts " MUL = #{Example::MUL}"
diff --git a/Examples/ruby/functor/.cvsignore b/Examples/ruby/functor/.cvsignore
new file mode 100644
index 000000000..f0cef3048
--- /dev/null
+++ b/Examples/ruby/functor/.cvsignore
@@ -0,0 +1,2 @@
+example_wrap.cxx
+example.dll
diff --git a/Examples/ruby/functor/Makefile b/Examples/ruby/functor/Makefile
new file mode 100644
index 000000000..bac6f4dd3
--- /dev/null
+++ b/Examples/ruby/functor/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/functor/example.i b/Examples/ruby/functor/example.i
new file mode 100644
index 000000000..903c9786c
--- /dev/null
+++ b/Examples/ruby/functor/example.i
@@ -0,0 +1,26 @@
+/* File : example.i */
+%module example
+
+%inline %{
+// From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514
+template<class T> class Sum {
+ T res;
+public:
+ Sum(T i = 0) : res(i) { }
+ void operator() (T x) { res += x; }
+ T result() const { return res; }
+};
+
+%}
+
+/**
+ * Rename the application operator to call() for Ruby.
+ * Note: this is normally automatic, but if you had to do it yourself
+ * you would use this directive:
+ *
+ * %rename(call) *::operator();
+ */
+
+// Instantiate a few versions
+%template(IntSum) Sum<int>;
+%template(DoubleSum) Sum<double>;
diff --git a/Examples/ruby/functor/runme.rb b/Examples/ruby/functor/runme.rb
new file mode 100644
index 000000000..3f78dcecc
--- /dev/null
+++ b/Examples/ruby/functor/runme.rb
@@ -0,0 +1,17 @@
+# Operator overloading example
+require 'example'
+
+a = Example::IntSum.new(0)
+b = Example::DoubleSum.new(100.0)
+
+# Use the objects. They should be callable just like a normal
+# Ruby function.
+
+(0..100).each do |i|
+ a.call(i) # note: function call
+ b.call(Math.sqrt(i)) # note: function call
+end
+
+puts a.result
+puts b.result
+
diff --git a/Examples/ruby/hashargs/.cvsignore b/Examples/ruby/hashargs/.cvsignore
new file mode 100644
index 000000000..11550eb76
--- /dev/null
+++ b/Examples/ruby/hashargs/.cvsignore
@@ -0,0 +1 @@
+example_wrap.c
diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile
new file mode 100755
index 000000000..4da07722f
--- /dev/null
+++ b/Examples/ruby/hashargs/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i
new file mode 100755
index 000000000..159bbd32a
--- /dev/null
+++ b/Examples/ruby/hashargs/example.i
@@ -0,0 +1,36 @@
+%module example
+
+%typemap(in) (int nattributes, const char **names, const int *values) (VALUE keys_ary, int i, VALUE key, VALUE val) {
+ Check_Type($input, T_HASH);
+ $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
+ $2 = NULL;
+ $3 = NULL;
+ if ($1 > 0) {
+ $2 = (char **) malloc($1*sizeof(char *));
+ $3 = (int *) malloc($1*sizeof(int));
+ keys_ary = rb_funcall($input, rb_intern("keys"), 0, NULL);
+ for (i = 0; i < $1; i++) {
+ key = rb_ary_entry(keys_ary, i);
+ val = rb_hash_aref($input, key);
+ Check_Type(key, T_STRING);
+ Check_Type(val, T_FIXNUM);
+ $2[i] = STR2CSTR(key);
+ $3[i] = NUM2INT(val);
+ }
+ }
+}
+
+%typemap(freearg) (int nattributes, const char **names, const int *values) {
+ free((void *) $2);
+ free((void *) $3);
+}
+
+%inline %{
+void setVitalStats(const char *person, int nattributes, const char **names, const int *values) {
+ int i;
+ printf("Name: %s\n", person);
+ for (i = 0; i < nattributes; i++) {
+ printf(" %s => %d\n", names[i], values[i]);
+ }
+}
+%}
diff --git a/Examples/ruby/hashargs/runme.rb b/Examples/ruby/hashargs/runme.rb
new file mode 100755
index 000000000..0b06f6934
--- /dev/null
+++ b/Examples/ruby/hashargs/runme.rb
@@ -0,0 +1,26 @@
+require 'example'
+
+include Example
+
+# Pass arguments in as one or more key-value pairs
+setVitalStats("Fred",
+ 'age' => 42,
+ 'weight' => 270
+ )
+
+# The order doesn't matter
+setVitalStats("Sally",
+ 'age' => 29,
+ 'weight' => 115,
+ 'height' => 72
+ )
+
+# Can also pass a hash directly
+params = {
+ 'ears' => 2,
+ 'eyes' => 2
+}
+setVitalStats("Bob", params)
+
+# An empty hash is fine too
+setVitalStats("Joe", {})
diff --git a/Examples/ruby/import/.cvsignore b/Examples/ruby/import/.cvsignore
new file mode 100644
index 000000000..02f077192
--- /dev/null
+++ b/Examples/ruby/import/.cvsignore
@@ -0,0 +1,4 @@
+bar_wrap.cxx
+base_wrap.cxx
+foo_wrap.cxx
+spam_wrap.cxx
diff --git a/Examples/ruby/import/Makefile b/Examples/ruby/import/Makefile
new file mode 100644
index 000000000..68151eba1
--- /dev/null
+++ b/Examples/ruby/import/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -c
+#If your system requires linking with the runtime libraries then set the directory location here
+RUNTIMEDIR = /usr/local/lib
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='base' INTERFACE='base.i' ruby_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='foo' INTERFACE='foo.i' ruby_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='bar' INTERFACE='bar.i' ruby_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='spam' INTERFACE='spam.i' ruby_multi_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/import/README b/Examples/ruby/import/README
new file mode 100644
index 000000000..0d18a2513
--- /dev/null
+++ b/Examples/ruby/import/README
@@ -0,0 +1,28 @@
+This example tests the SWIG run-time libraries and use of the
+%import directive to work with multiple modules.
+
+Use 'ruby runme.rb' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is working correctly, all of the modules will load
+correctly and type checking will work correctly. The
+example requires the use of the SWIG run-time libraries
+which must be built and properly installed.
+
+
+
+
diff --git a/Examples/ruby/import/bar.h b/Examples/ruby/import/bar.h
new file mode 100644
index 000000000..1c99f28e6
--- /dev/null
+++ b/Examples/ruby/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<Base *>(this);
+ }
+ static Bar *fromBase(Base *b) {
+ return dynamic_cast<Bar *>(b);
+ }
+};
+
+
diff --git a/Examples/ruby/import/bar.i b/Examples/ruby/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/Examples/ruby/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/Examples/ruby/import/base.h b/Examples/ruby/import/base.h
new file mode 100644
index 000000000..44f98f747
--- /dev/null
+++ b/Examples/ruby/import/base.h
@@ -0,0 +1,16 @@
+class Base {
+ public:
+ Base() { };
+ ~Base() { };
+ virtual const char * A() const {
+ return "Base::A";
+ }
+ const char * B() const {
+ return "Base::B";
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/Examples/ruby/import/base.i b/Examples/ruby/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/Examples/ruby/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/Examples/ruby/import/foo.h b/Examples/ruby/import/foo.h
new file mode 100644
index 000000000..1abe2c0d8
--- /dev/null
+++ b/Examples/ruby/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<Base *>(this);
+ }
+ static Foo *fromBase(Base *b) {
+ return dynamic_cast<Foo *>(b);
+ }
+};
+
+
diff --git a/Examples/ruby/import/foo.i b/Examples/ruby/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/Examples/ruby/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/Examples/ruby/import/runme.rb b/Examples/ruby/import/runme.rb
new file mode 100644
index 000000000..32ca482d6
--- /dev/null
+++ b/Examples/ruby/import/runme.rb
@@ -0,0 +1,90 @@
+# file: runme.rb
+# Test various properties of classes defined in separate modules
+
+puts "Testing the %import directive"
+
+require 'base'
+require 'foo'
+require 'bar'
+require 'spam'
+
+# Create some objects
+
+puts "Creating some objects"
+
+a = Base::Base.new
+b = Foo::Foo.new
+c = Bar::Bar.new
+d = Spam::Spam.new
+
+# Try calling some methods
+puts "Testing some methods"
+puts "Should see 'Base::A' ---> #{a.A}"
+puts "Should see 'Base::B' ---> #{a.B}"
+
+puts "Should see 'Foo::A' ---> #{b.A}"
+puts "Should see 'Foo::B' ---> #{b.B}"
+
+puts "Should see 'Bar::A' ---> #{c.A}"
+puts "Should see 'Bar::B' ---> #{c.B}"
+
+puts "Should see 'Spam::A' ---> #{d.A}"
+puts "Should see 'Spam::B' ---> #{d.B}"
+
+# Try some casts
+
+puts "\nTesting some casts\n"
+
+x = a.toBase
+puts "Should see 'Base::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = b.toBase
+puts "Should see 'Foo::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = c.toBase
+puts "Should see 'Bar::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = d.toBase
+puts "Should see 'Spam::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = d.toBar
+puts "Should see 'Bar::B' ---> #{x.B}"
+
+puts "\nTesting some dynamic casts\n"
+x = d.toBase
+
+puts " Spam -> Base -> Foo : "
+y = Foo::Foo.fromBase(x)
+if y != nil
+ puts "bad swig"
+else
+ puts "good swig"
+end
+
+puts " Spam -> Base -> Bar : "
+y = Bar::Bar.fromBase(x)
+if y != nil
+ puts "good swig"
+else
+ puts "bad swig"
+end
+
+puts " Spam -> Base -> Spam : "
+y = Spam::Spam.fromBase(x)
+if y != nil
+ puts "good swig"
+else
+ puts "bad swig"
+end
+
+puts " Foo -> Spam : "
+y = Spam::Spam.fromBase(b)
+if y != nil
+ puts "bad swig"
+else
+ puts "good swig"
+end
diff --git a/Examples/ruby/import/spam.h b/Examples/ruby/import/spam.h
new file mode 100644
index 000000000..57db84563
--- /dev/null
+++ b/Examples/ruby/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<Base *>(this);
+ }
+ virtual Bar *toBar() {
+ return static_cast<Bar *>(this);
+ }
+ static Spam *fromBase(Base *b) {
+ return dynamic_cast<Spam *>(b);
+ }
+};
+
+
diff --git a/Examples/ruby/import/spam.i b/Examples/ruby/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/Examples/ruby/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/Examples/ruby/import_template/.cvsignore b/Examples/ruby/import_template/.cvsignore
new file mode 100644
index 000000000..02f077192
--- /dev/null
+++ b/Examples/ruby/import_template/.cvsignore
@@ -0,0 +1,4 @@
+bar_wrap.cxx
+base_wrap.cxx
+foo_wrap.cxx
+spam_wrap.cxx
diff --git a/Examples/ruby/import_template/Makefile b/Examples/ruby/import_template/Makefile
new file mode 100644
index 000000000..68151eba1
--- /dev/null
+++ b/Examples/ruby/import_template/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -c
+#If your system requires linking with the runtime libraries then set the directory location here
+RUNTIMEDIR = /usr/local/lib
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='base' INTERFACE='base.i' ruby_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='foo' INTERFACE='foo.i' ruby_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='bar' INTERFACE='bar.i' ruby_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='spam' INTERFACE='spam.i' ruby_multi_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/import_template/README b/Examples/ruby/import_template/README
new file mode 100644
index 000000000..53c9f8309
--- /dev/null
+++ b/Examples/ruby/import_template/README
@@ -0,0 +1,30 @@
+This example tests the SWIG run-time libraries and use of the
+%import directive to work with multiple modules. However,
+unlike the import example, this uses templates to really
+stress test the type-system.
+
+Use 'ruby runme.rb' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is working correctly, all of the modules will load
+correctly and type checking will work correctly. The
+example requires the use of the SWIG run-time libraries
+which must be built and properly installed.
+
+
+
+
diff --git a/Examples/ruby/import_template/bar.h b/Examples/ruby/import_template/bar.h
new file mode 100644
index 000000000..1aa907dfc
--- /dev/null
+++ b/Examples/ruby/import_template/bar.h
@@ -0,0 +1,22 @@
+#include "base.h"
+
+template<class T> class Bar : public Base<T> {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual const char * A() const {
+ return "Bar::A";
+ }
+ const char * B() const {
+ return "Bar::B";
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+ static Bar<T> *fromBase(Base<T> *b) {
+ return dynamic_cast<Bar<T> *>(b);
+ }
+
+};
+
+
diff --git a/Examples/ruby/import_template/bar.i b/Examples/ruby/import_template/bar.i
new file mode 100644
index 000000000..357de0db9
--- /dev/null
+++ b/Examples/ruby/import_template/bar.i
@@ -0,0 +1,11 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+%template(IntBar) Bar<int>;
+
+
diff --git a/Examples/ruby/import_template/base.h b/Examples/ruby/import_template/base.h
new file mode 100644
index 000000000..4302aeda2
--- /dev/null
+++ b/Examples/ruby/import_template/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+template<class T> class Base {
+ public:
+ Base() { };
+ ~Base() { };
+ virtual const char * A() const {
+ return "Base::A";
+ }
+ const char * B() const {
+ return "Base::B";
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+};
+
+
diff --git a/Examples/ruby/import_template/base.i b/Examples/ruby/import_template/base.i
new file mode 100644
index 000000000..bcf1a5f7d
--- /dev/null
+++ b/Examples/ruby/import_template/base.i
@@ -0,0 +1,7 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
+%template(IntBase) Base<int>;
diff --git a/Examples/ruby/import_template/foo.h b/Examples/ruby/import_template/foo.h
new file mode 100644
index 000000000..626257462
--- /dev/null
+++ b/Examples/ruby/import_template/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+template<class T> class Foo : public Base<T> {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual const char * A() const {
+ return "Foo::A";
+ }
+ const char * B() const {
+ return "Foo::B";
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+ static Foo<T> *fromBase(Base<T> *b) {
+ return dynamic_cast<Foo<T> *>(b);
+ }
+};
+
+
diff --git a/Examples/ruby/import_template/foo.i b/Examples/ruby/import_template/foo.i
new file mode 100644
index 000000000..37e655ea2
--- /dev/null
+++ b/Examples/ruby/import_template/foo.i
@@ -0,0 +1,10 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
+%template(IntFoo) Foo<int>;
+
diff --git a/Examples/ruby/import_template/runme.rb b/Examples/ruby/import_template/runme.rb
new file mode 100644
index 000000000..b9ca19f77
--- /dev/null
+++ b/Examples/ruby/import_template/runme.rb
@@ -0,0 +1,92 @@
+# file: runme.rb
+# Test various properties of classes defined in separate modules
+
+puts "Testing the %import directive with templates"
+
+require 'base'
+require 'foo'
+require 'bar'
+require 'spam'
+
+# Create some objects
+
+puts "Creating some objects"
+
+a = Base::IntBase.new
+b = Foo::IntFoo.new
+c = Bar::IntBar.new
+d = Spam::IntSpam.new
+
+# Try calling some methods
+puts "Testing some methods"
+puts ""
+puts "Should see 'Base::A' ---> #{a.A}"
+puts "Should see 'Base::B' ---> #{a.B}"
+
+puts "Should see 'Foo::A' ---> #{b.A}"
+puts "Should see 'Foo::B' ---> #{b.B}"
+
+puts "Should see 'Bar::A' ---> #{c.A}"
+puts "Should see 'Bar::B' ---> #{c.B}"
+
+puts "Should see 'Spam::A' ---> #{d.A}"
+puts "Should see 'Spam::B' ---> #{d.B}"
+
+# Try some casts
+
+puts "\nTesting some casts\n"
+puts ""
+
+x = a.toBase
+puts "Should see 'Base::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = b.toBase
+puts "Should see 'Foo::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = c.toBase
+puts "Should see 'Bar::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = d.toBase
+puts "Should see 'Spam::A' ---> #{x.A}"
+puts "Should see 'Base::B' ---> #{x.B}"
+
+x = d.toBar
+puts "Should see 'Bar::B' ---> #{x.B}"
+
+puts "\nTesting some dynamic casts\n"
+x = d.toBase
+
+puts " Spam -> Base -> Foo : "
+y = Foo::IntFoo.fromBase(x)
+if y != nil
+ puts "bad swig"
+else
+ puts "good swig"
+end
+
+puts " Spam -> Base -> Bar : "
+y = Bar::IntBar.fromBase(x)
+if y != nil
+ puts "good swig"
+else
+ puts "bad swig"
+end
+
+puts " Spam -> Base -> Spam : "
+y = Spam::IntSpam.fromBase(x)
+if y != nil
+ puts "good swig"
+else
+ puts "bad swig"
+end
+
+puts " Foo -> Spam : "
+y = Spam::IntSpam.fromBase(b)
+if y != nil
+ puts "bad swig"
+else
+ puts "good swig"
+end
diff --git a/Examples/ruby/import_template/spam.h b/Examples/ruby/import_template/spam.h
new file mode 100644
index 000000000..a27b08829
--- /dev/null
+++ b/Examples/ruby/import_template/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+template<class T> class Spam : public Bar<T> {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual const char * A() const {
+ return "Spam::A";
+ }
+ const char * B() const {
+ return "Spam::B";
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+ virtual Bar<T> *toBar() {
+ return static_cast<Bar<T> *>(this);
+ }
+ static Spam<T> *fromBase(Base<T> *b) {
+ return dynamic_cast<Spam<T> *>(b);
+ }
+};
+
+
diff --git a/Examples/ruby/import_template/spam.i b/Examples/ruby/import_template/spam.i
new file mode 100644
index 000000000..ff0ca113e
--- /dev/null
+++ b/Examples/ruby/import_template/spam.i
@@ -0,0 +1,10 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+%template(IntSpam) Spam<int>;
+
diff --git a/Examples/ruby/index.html b/Examples/ruby/index.html
index 19d34d8c3..e6c752f1e 100644
--- a/Examples/ruby/index.html
+++ b/Examples/ruby/index.html
@@ -36,7 +36,11 @@ certain C declarations are turned into constants.
</pre>
</blockquote>
-<li>The compilation of examples is done using the file <tt>Example/Makefile</tt>. This
+<li>
+Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
+</li>
+
+<li>On Unix the compilation of examples is done using the file <tt>Example/Makefile</tt>. This
makefile performs a manual module compilation which is platform specific. Typically,
the steps look like this (Linux):
diff --git a/Examples/ruby/mpointer/.cvsignore b/Examples/ruby/mpointer/.cvsignore
new file mode 100644
index 000000000..f0cef3048
--- /dev/null
+++ b/Examples/ruby/mpointer/.cvsignore
@@ -0,0 +1,2 @@
+example_wrap.cxx
+example.dll
diff --git a/Examples/ruby/mpointer/Makefile b/Examples/ruby/mpointer/Makefile
new file mode 100644
index 000000000..27cb6d6bd
--- /dev/null
+++ b/Examples/ruby/mpointer/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/mpointer/example.cxx b/Examples/ruby/mpointer/example.cxx
new file mode 100644
index 000000000..1a6bb666a
--- /dev/null
+++ b/Examples/ruby/mpointer/example.cxx
@@ -0,0 +1,45 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+
+/* 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;
+}
+
+double do_op(Shape *s, double (Shape::*m)(void)) {
+ return (s->*m)();
+}
+
+double (Shape::*areapt())(void) {
+ return &Shape::area;
+}
+
+double (Shape::*perimeterpt())(void) {
+ return &Shape::perimeter;
+}
+
+/* Member pointer variables */
+double (Shape::*areavar)(void) = &Shape::area;
+double (Shape::*perimetervar)(void) = &Shape::perimeter;
+
diff --git a/Examples/ruby/mpointer/example.h b/Examples/ruby/mpointer/example.h
new file mode 100644
index 000000000..b90e14353
--- /dev/null
+++ b/Examples/ruby/mpointer/example.h
@@ -0,0 +1,47 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+extern double do_op(Shape *s, double (Shape::*m)(void));
+
+/* Functions that return member pointers */
+
+extern double (Shape::*areapt())(void);
+extern double (Shape::*perimeterpt())(void);
+
+/* Global variables that are member pointers */
+extern double (Shape::*areavar)(void);
+extern double (Shape::*perimetervar)(void);
diff --git a/Examples/ruby/mpointer/example.i b/Examples/ruby/mpointer/example.i
new file mode 100644
index 000000000..253a224dc
--- /dev/null
+++ b/Examples/ruby/mpointer/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Some constants */
+
+%constant double (Shape::*AREAPT)(void) = &Shape::area;
+%constant double (Shape::*PERIMPT)(void) = &Shape::perimeter;
+%constant double (Shape::*NULLPT)(void) = 0;
diff --git a/Examples/ruby/mpointer/runme.rb b/Examples/ruby/mpointer/runme.rb
new file mode 100644
index 000000000..e11aa68cb
--- /dev/null
+++ b/Examples/ruby/mpointer/runme.rb
@@ -0,0 +1,48 @@
+# Example using pointers to member functions
+
+require 'example'
+
+# Get the pointers
+
+area_pt = Example::areapt
+perim_pt = Example::perimeterpt
+
+puts "area_pt = #{area_pt}"
+puts "perim_pt = #{perim_pt}"
+
+# Create some objects
+
+c = Example::Circle.new(4)
+s = Example::Square.new(10)
+
+# Do some calculations
+
+puts "Circle area = #{Example::do_op(c, area_pt)}"
+puts "Circle perim = #{Example::do_op(c, perim_pt)}"
+puts "Square area = #{Example::do_op(s, area_pt)}"
+puts "Square perim = #{Example::do_op(s, perim_pt)}"
+
+puts "areavar = #{Example::areavar}"
+puts "perimetervar = #{Example::perimetervar}"
+
+# Try the variables
+puts "Circle area = #{Example::do_op(c, Example::areavar)}"
+puts "Circle perim = #{Example::do_op(c, Example::perimetervar)}"
+puts "Square area = #{Example::do_op(s, Example::areavar)}"
+puts "Square perim = #{Example::do_op(s, Example::perimetervar)}"
+
+# Modify one of the variables
+Example::areavar = perim_pt
+
+puts "Circle perimeter = #{Example::do_op(c, Example::areavar)}"
+
+# Try the constants
+
+puts "Example::AREAPT = #{Example::AREAPT}"
+puts "Example::PERIMPT= #{Example::PERIMPT}"
+puts "Example::NULLPT = #{Example::NULLPT}"
+
+puts "Circle area = #{Example::do_op(c, Example::AREAPT)}"
+puts "Circle perim = #{Example::do_op(c, Example::PERIMPT)}"
+puts "Square area = #{Example::do_op(s, Example::AREAPT)}"
+puts "Square perim = #{Example::do_op(s, Example::PERIMPT)}"
diff --git a/Examples/ruby/multimap/.cvsignore b/Examples/ruby/multimap/.cvsignore
new file mode 100644
index 000000000..a52fc6147
--- /dev/null
+++ b/Examples/ruby/multimap/.cvsignore
@@ -0,0 +1,2 @@
+example_wrap.c
+example.dll
diff --git a/Examples/ruby/multimap/Makefile b/Examples/ruby/multimap/Makefile
new file mode 100644
index 000000000..0a59614c4
--- /dev/null
+++ b/Examples/ruby/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/multimap/example.c b/Examples/ruby/multimap/example.c
new file mode 100644
index 000000000..d135481af
--- /dev/null
+++ b/Examples/ruby/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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/ruby/multimap/example.dsp b/Examples/ruby/multimap/example.dsp
new file mode 100644
index 000000000..ece612973
--- /dev/null
+++ b/Examples/ruby/multimap/example.dsp
@@ -0,0 +1,150 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(RUBY_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 "$(RUBY_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 odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(RUBY_LIB) /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo **WARNING** I could not get Ruby (1.6.4) and SWIG to work under Visual Studio (6)
+ echo on
+ ..\..\..\swig -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo **WARNING** I could not get Ruby (1.6.4) and SWIG to work under Visual Studio (6)
+ echo on
+ ..\..\..\swig -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/ruby/multimap/example.i b/Examples/ruby/multimap/example.i
new file mode 100644
index 000000000..48ee3d0b5
--- /dev/null
+++ b/Examples/ruby/multimap/example.i
@@ -0,0 +1,83 @@
+%module example
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in) (int argc, char *argv[]) {
+ int i;
+
+ if (TYPE($input) != T_ARRAY) {
+ SWIG_exception(SWIG_ValueError, "Expected an array");
+ }
+ $1 = RARRAY($input)->len;
+ if ($1 == 0) {
+ SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ VALUE s = rb_ary_entry($input,i);
+ if (TYPE(s) != T_STRING) {
+ free($2);
+ SWIG_exception(SWIG_ValueError, "List items must be strings");
+ }
+ $2[i] = STR2CSTR(s);
+ }
+ $2[i] = 0;
+}
+
+%typemap(freearg) (int argc, char *argv[]) {
+ free($2);
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+ if (TYPE($input) != T_STRING) {
+ SWIG_exception(SWIG_ValueError, "Expected a string");
+ }
+ $1 = STR2CSTR($input);
+ $2 = RSTRING($input)->len;
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len) {
+ char *temp;
+ if (TYPE($input) != T_STRING) {
+ SWIG_exception(SWIG_ValueError,"Expected a string");
+ }
+ temp = STR2CSTR($input);
+ $2 = RSTRING($input)->len;
+ $1 = (char *) malloc($2+1);
+ memmove($1,temp,$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(argout, fragment="output_helper") (char *str, int len) {
+ VALUE o;
+ o = rb_str_new($1,$2);
+ $result = output_helper($result,o);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/Examples/ruby/multimap/runme.rb b/Examples/ruby/multimap/runme.rb
new file mode 100755
index 000000000..3b2dfa05f
--- /dev/null
+++ b/Examples/ruby/multimap/runme.rb
@@ -0,0 +1,22 @@
+# file: run.rb
+
+require 'example'
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = Example.gcd(x,y)
+printf "The gcd of %d and %d is %d\n",x,y,g
+
+# Call the gcdmain() function
+Example.gcdmain(["gcdmain","42","105"])
+
+# Call the count function
+
+printf "%d\n",Example.count("Hello World","l")
+
+# Call the capitalize function
+
+printf "%s\n",Example.capitalize("hello world")
+
diff --git a/Examples/ruby/operator/.cvsignore b/Examples/ruby/operator/.cvsignore
new file mode 100644
index 000000000..f0cef3048
--- /dev/null
+++ b/Examples/ruby/operator/.cvsignore
@@ -0,0 +1,2 @@
+example_wrap.cxx
+example.dll
diff --git a/Examples/ruby/operator/Makefile b/Examples/ruby/operator/Makefile
new file mode 100644
index 000000000..43c0c1596
--- /dev/null
+++ b/Examples/ruby/operator/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' ruby_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/operator/example.h b/Examples/ruby/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/Examples/ruby/operator/example.h
@@ -0,0 +1,36 @@
+/* File : example.h */
+#include <math.h>
+
+class Complex {
+private:
+ double rpart, ipart;
+public:
+ Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
+ Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
+ Complex &operator=(const Complex &c) {
+ rpart = c.rpart;
+ ipart = c.ipart;
+ return *this;
+ }
+ Complex operator+(const Complex &c) const {
+ return Complex(rpart+c.rpart, ipart+c.ipart);
+ }
+ Complex operator-(const Complex &c) const {
+ return Complex(rpart-c.rpart, ipart-c.ipart);
+ }
+ Complex operator*(const Complex &c) const {
+ return Complex(rpart*c.rpart - ipart*c.ipart,
+ rpart*c.ipart + c.rpart*ipart);
+ }
+ Complex operator-() const {
+ return Complex(-rpart, -ipart);
+ }
+
+ double re() const { return rpart; }
+ double im() const { return ipart; }
+};
+
+
+
+
+
diff --git a/Examples/ruby/operator/example.i b/Examples/ruby/operator/example.i
new file mode 100644
index 000000000..8d86694b3
--- /dev/null
+++ b/Examples/ruby/operator/example.i
@@ -0,0 +1,23 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* This header file is a little tough to handle because it has overloaded
+ operators and constructors. We're going to try and deal with that here */
+
+/* Grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend Complex {
+ char *__str__() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", self->re(), self->im());
+ return temp;
+ }
+};
+
+
diff --git a/Examples/ruby/operator/runme.rb b/Examples/ruby/operator/runme.rb
new file mode 100644
index 000000000..518d91e9e
--- /dev/null
+++ b/Examples/ruby/operator/runme.rb
@@ -0,0 +1,25 @@
+# Operator overloading example
+require 'example'
+
+include Example
+
+a = Complex.new(2, 3)
+b = Complex.new(-5, 10)
+
+puts "a = #{a}"
+puts "b = #{b}"
+
+c = a + b
+puts "c = #{c}"
+puts "a*b = #{a*b}"
+puts "a-c = #{a-c}"
+
+# This should invoke Complex's copy constructor
+e = Complex.new(a-c)
+e = a - c
+puts "e = #{e}"
+
+# Big expression
+f = ((a+b)*(c+b*e)) + (-a)
+puts "f = #{f}"
+
diff --git a/Examples/ruby/overloading/.cvsignore b/Examples/ruby/overloading/.cvsignore
new file mode 100644
index 000000000..bd7dd8a57
--- /dev/null
+++ b/Examples/ruby/overloading/.cvsignore
@@ -0,0 +1 @@
+example_wrap.cxx
diff --git a/Examples/ruby/overloading/Makefile b/Examples/ruby/overloading/Makefile
new file mode 100644
index 000000000..ab8928c0e
--- /dev/null
+++ b/Examples/ruby/overloading/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/overloading/example.cxx b/Examples/ruby/overloading/example.cxx
new file mode 100644
index 000000000..49d998d5a
--- /dev/null
+++ b/Examples/ruby/overloading/example.cxx
@@ -0,0 +1,125 @@
+#include <iostream>
+
+#include "example.h"
+
+// Overloaded constructors for class Bar
+Bar::Bar() {
+ std::cout << "Called Bar::Bar()" << std::endl;
+}
+
+Bar::Bar(const Bar&) {
+ std::cout << "Called Bar::Bar(const Bar&)" << std::endl;
+}
+
+Bar::Bar(double x) {
+ std::cout << "Called Bar::Bar(double) with x = " << x << std::endl;
+}
+
+Bar::Bar(double x, char *y) {
+ std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl;
+}
+
+Bar::Bar(int x, int y) {
+ std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl;
+}
+
+Bar::Bar(char *x) {
+ std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl;
+}
+
+Bar::Bar(int x) {
+ std::cout << "Called Bar::Bar(int) with x = " << x << std::endl;
+}
+
+Bar::Bar(long x) {
+ std::cout << "Called Bar::Bar(long) with x = " << x << std::endl;
+}
+
+Bar::Bar(Bar *x) {
+ std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl;
+}
+
+// Overloaded member functions
+void Bar::foo(const Bar& x) {
+ std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl;
+}
+
+void Bar::foo(double x) {
+ std::cout << "Called Bar::foo(double) with x = " << x << std::endl;
+}
+
+void Bar::foo(double x, char *y) {
+ std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl;
+}
+
+void Bar::foo(int x, int y) {
+ std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl;
+}
+
+void Bar::foo(char *x) {
+ std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl;
+}
+
+void Bar::foo(int x) {
+ std::cout << "Called Bar::foo(int) with x = " << x << std::endl;
+}
+
+void Bar::foo(long x) {
+ std::cout << "Called Bar::foo(long) with x = " << x << std::endl;
+}
+
+void Bar::foo(Bar *x) {
+ std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl;
+}
+
+void Bar::spam(int x, int y, int z) {
+ std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl;
+}
+
+void Bar::spam(double x, int y, int z) {
+ std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl;
+}
+
+// Overloaded global methods
+void foo(const Bar& x) {
+ std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl;
+}
+
+void foo(double x) {
+ std::cout << "Called foo(double) with x = " << x << std::endl;
+}
+
+void foo(double x, char *y) {
+ std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl;
+}
+
+void foo(int x, int y) {
+ std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl;
+}
+
+void foo(char *x) {
+ std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl;
+}
+
+void foo(int x) {
+ std::cout << "Called foo(int) with x = " << x << std::endl;
+}
+
+void foo(long x) {
+ std::cout << "Called foo(long) with x = " << x << std::endl;
+}
+
+void foo(Bar *x) {
+ std::cout << "Called foo(Bar *) with x = " << x << std::endl;
+}
+
+// Overloaded global spam() functions
+void spam(int x, int y, int z) {
+ std::cout << "Called spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl;
+}
+
+void spam(double x, int y, int z) {
+ std::cout << "Called spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl;
+}
+
+
diff --git a/Examples/ruby/overloading/example.h b/Examples/ruby/overloading/example.h
new file mode 100644
index 000000000..e47a122ee
--- /dev/null
+++ b/Examples/ruby/overloading/example.h
@@ -0,0 +1,41 @@
+#ifndef EXAMPLE_H
+#define EXAMPLE_H
+
+class Bar {
+public:
+ Bar();
+ Bar(const Bar&);
+ Bar(double);
+ Bar(double, char *);
+ Bar(int, int);
+ Bar(char *);
+ Bar(long);
+ Bar(int);
+ Bar(Bar *);
+
+ void foo(const Bar&);
+ void foo(double);
+ void foo(double, char *);
+ void foo(int, int);
+ void foo(char *);
+ void foo(long);
+ void foo(int);
+ void foo(Bar *);
+
+ void spam(int x, int y=2, int z=3);
+ void spam(double x, int y=2, int z=3);
+};
+
+void foo(const Bar&);
+void foo(double);
+void foo(double, char *);
+void foo(int, int);
+void foo(char *);
+void foo(int);
+void foo(long);
+void foo(Bar *);
+
+void spam(int x, int y=2, int z=3);
+void spam(double x, int y=2, int z=3);
+
+#endif
diff --git a/Examples/ruby/overloading/example.i b/Examples/ruby/overloading/example.i
new file mode 100644
index 000000000..17ad66997
--- /dev/null
+++ b/Examples/ruby/overloading/example.i
@@ -0,0 +1,24 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+/**
+ * These overloaded declarations conflict with other overloads (as far as
+ * SWIG's Ruby module's implementation for overloaded methods is concerned).
+ * One option is use the %rename directive to rename the conflicting methods;
+ * here, we're just using %ignore to avoid wrapping some of the overloaded
+ * functions altogether.
+ */
+
+%ignore Bar::Bar(Bar *);
+%ignore Bar::Bar(long);
+
+%ignore Bar::foo(const Bar&);
+%ignore Bar::foo(long);
+
+%ignore ::foo(const Bar&);
+%ignore ::foo(int);
+
+%include example.h
diff --git a/Examples/ruby/overloading/runme.rb b/Examples/ruby/overloading/runme.rb
new file mode 100644
index 000000000..9f1233347
--- /dev/null
+++ b/Examples/ruby/overloading/runme.rb
@@ -0,0 +1,88 @@
+require 'example'
+
+# This should invoke foo(double)
+Example.foo(3.14159)
+
+# This should invoke foo(double, char *)
+Example.foo(3.14159, "Pi")
+
+# This should invoke foo(int, int)
+Example.foo(3, 4)
+
+# This should invoke foo(char *)
+Example.foo("This is a test")
+
+# This should invoke foo(long)
+Example.foo(42)
+
+# This should invoke Bar::Bar() followed by foo(Bar *)
+Example.foo(Example::Bar.new)
+
+# Skip a line
+puts ""
+
+# Each of the following three calls should invoke spam(int, int, int)
+Example.spam(3)
+Example.spam(3, 4)
+Example.spam(3, 4, 5)
+
+# Skip a line
+puts ""
+
+# Each of the following three calls should invoke spam(double, int, int)
+Example.spam(3.0)
+Example.spam(3.0, 4)
+Example.spam(3.0, 4, 5)
+
+# Skip a line
+puts ""
+
+# This should invoke Bar::Bar(double)
+Example::Bar.new(3.14159)
+
+# This should invoke Bar::Bar(double, char *)
+Example::Bar.new(3.14159, "Pi")
+
+# This should invoke Bar::Bar(int, int)
+Example::Bar.new(3, 4)
+
+# This should invoke Bar::Bar(char *)
+Example::Bar.new("This is a test")
+
+# This should invoke Bar::Bar(int)
+Example::Bar.new(42)
+
+# This should invoke Bar::Bar() for the input argument,
+# followed by Bar::Bar(const Bar&).
+Example::Bar.new(Example::Bar.new)
+
+# Skip a line
+puts ""
+
+# Construct a new Bar instance (invokes Bar::Bar())
+bar = Example::Bar.new
+
+# This should invoke Bar::foo(double)
+bar.foo(3.14159)
+
+# This should invoke Bar::foo(double, char *)
+bar.foo(3.14159, "Pi")
+
+# This should invoke Bar::foo(int, int)
+bar.foo(3, 4)
+
+# This should invoke Bar::foo(char *)
+bar.foo("This is a test")
+
+# This should invoke Bar::foo(int)
+bar.foo(42)
+
+# This should invoke Bar::Bar() to construct the input
+# argument, followed by Bar::foo(Bar *).
+bar.foo(Example::Bar.new)
+
+# This should invoke Bar::spam(int x, int y, int z)
+bar.spam(1)
+
+# This should invoke Bar::spam(double x, int y, int z)
+bar.spam(3.14159)
diff --git a/Examples/ruby/pointer/.cvsignore b/Examples/ruby/pointer/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/pointer/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/pointer/Makefile b/Examples/ruby/pointer/Makefile
index cd0fdf300..0a59614c4 100644
--- a/Examples/ruby/pointer/Makefile
+++ b/Examples/ruby/pointer/Makefile
@@ -13,6 +13,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/pointer/example.i b/Examples/ruby/pointer/example.i
index 2ed2b5bbf..4483b0f77 100644
--- a/Examples/ruby/pointer/example.i
+++ b/Examples/ruby/pointer/example.i
@@ -6,7 +6,8 @@
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
-%include pointer.i
+%include cpointer.i
+%pointer_functions(int, intp);
/* Next we'll use some typemaps */
diff --git a/Examples/ruby/pointer/runme.rb b/Examples/ruby/pointer/runme.rb
index b1c3af4b3..d696b026f 100644
--- a/Examples/ruby/pointer/runme.rb
+++ b/Examples/ruby/pointer/runme.rb
@@ -4,9 +4,12 @@ require 'example'
# First create some objects using the pointer library.
print "Testing the pointer library\n"
-a = Example::ptrcreate("int", 37)
-b = Example::ptrcreate("int", 42)
-c = Example::ptrcreate("int");
+a = Example::new_intp()
+b = Example::new_intp()
+c = Example::new_intp()
+
+Example::intp_assign(a,37)
+Example::intp_assign(b,42)
print " a = #{a}\n"
print " b = #{b}\n"
@@ -16,13 +19,13 @@ print " c = #{c}\n"
Example::add(a, b, c)
# Now get the result
-r = Example::ptrvalue(c)
+r = Example::intp_value(c)
print " 37 + 42 = #{r}\n"
# Clean up the pointers
-Example::ptrfree(a)
-Example::ptrfree(b)
-Example::ptrfree(c)
+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
diff --git a/Examples/ruby/reference/.cvsignore b/Examples/ruby/reference/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/reference/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/reference/Makefile b/Examples/ruby/reference/Makefile
index 01ce757ff..ab8928c0e 100644
--- a/Examples/ruby/reference/Makefile
+++ b/Examples/ruby/reference/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/reference/example.i b/Examples/ruby/reference/example.i
index 8538326f6..e71f297bf 100644
--- a/Examples/ruby/reference/example.i
+++ b/Examples/ruby/reference/example.i
@@ -31,7 +31,7 @@ public:
int size();
/* This wrapper provides an alternative to the [] operator */
- %addmethods {
+ %extend {
Vector &get(int index) {
return (*self)[index];
}
diff --git a/Examples/ruby/simple/.cvsignore b/Examples/ruby/simple/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/simple/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/simple/Makefile b/Examples/ruby/simple/Makefile
index cd0fdf300..0a59614c4 100644
--- a/Examples/ruby/simple/Makefile
+++ b/Examples/ruby/simple/Makefile
@@ -13,6 +13,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/simple/example.dsp b/Examples/ruby/simple/example.dsp
new file mode 100644
index 000000000..a68073c51
--- /dev/null
+++ b/Examples/ruby/simple/example.dsp
@@ -0,0 +1,150 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept /EXPORT:Init_example
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll" /EXPORT:Init_example
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/ruby/simple/run.rb b/Examples/ruby/simple/runme.rb
index 373de123c..373de123c 100644..100755
--- a/Examples/ruby/simple/run.rb
+++ b/Examples/ruby/simple/runme.rb
diff --git a/Examples/ruby/std_vector/.cvsignore b/Examples/ruby/std_vector/.cvsignore
new file mode 100644
index 000000000..bd7dd8a57
--- /dev/null
+++ b/Examples/ruby/std_vector/.cvsignore
@@ -0,0 +1 @@
+example_wrap.cxx
diff --git a/Examples/ruby/std_vector/Makefile b/Examples/ruby/std_vector/Makefile
new file mode 100644
index 000000000..6b0d049a5
--- /dev/null
+++ b/Examples/ruby/std_vector/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' ruby_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/std_vector/example.h b/Examples/ruby/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/Examples/ruby/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h */
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<double> half(const std::vector<double>& v) {
+ std::vector<double> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::vector<double>& v) {
+ // would you believe this is the same as the above?
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+
diff --git a/Examples/ruby/std_vector/example.i b/Examples/ruby/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/Examples/ruby/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<int>;
+ %template(DoubleVector) vector<double>;
+}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb
new file mode 100644
index 000000000..1529d38c6
--- /dev/null
+++ b/Examples/ruby/std_vector/runme.rb
@@ -0,0 +1,36 @@
+# file: runme.rb
+
+require 'example'
+
+# Call average with a Ruby array...
+
+puts Example::average([1,2,3,4])
+
+# ... or a wrapped std::vector<int>
+
+v = Example::IntVector.new(4)
+0.upto(v.length-1) { |i| v[i] = i+1 }
+puts Example::average(v)
+
+
+# half will return a Ruby array.
+# Call it with a Ruby array...
+
+w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0])
+0.upto(w.length-1) { |i| print w[i],"; " }
+puts
+
+# ... or a wrapped std::vector<double>
+
+v = Example::DoubleVector.new
+[1,2,3,4].each { |i| v.push(i) }
+w = Example::half(v)
+0.upto(w.length-1) { |i| print w[i],"; " }
+puts
+
+# now halve a wrapped std::vector<double> in place
+
+Example::halve_in_place(v)
+0.upto(v.length-1) { |i| print v[i],"; " }
+puts
+
diff --git a/Examples/ruby/template/.cvsignore b/Examples/ruby/template/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/template/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/template/Makefile b/Examples/ruby/template/Makefile
new file mode 100644
index 000000000..6b0d049a5
--- /dev/null
+++ b/Examples/ruby/template/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../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)' ruby_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/Examples/ruby/template/example.h b/Examples/ruby/template/example.h
new file mode 100644
index 000000000..4d9a58c54
--- /dev/null
+++ b/Examples/ruby/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template<class T> T max(T a, T b) { return a>b ? a : b; }
+
+template<class T> 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/ruby/template/example.i b/Examples/ruby/template/example.i
new file mode 100644
index 000000000..8036701ea
--- /dev/null
+++ b/Examples/ruby/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<int>;
+%template(maxdouble) max<double>;
+%template(Vecint) vector<int>;
+%template(Vecdouble) vector<double>;
+
diff --git a/Examples/ruby/template/runme.rb b/Examples/ruby/template/runme.rb
new file mode 100644
index 000000000..6c9c4ebc2
--- /dev/null
+++ b/Examples/ruby/template/runme.rb
@@ -0,0 +1,25 @@
+# file: runme.rb
+
+require 'example'
+
+# Call some templated functions
+puts Example::maxint(3, 7)
+puts Example::maxdouble(3.14, 2.18)
+
+# Create some class
+
+iv = Example::Vecint.new(100)
+dv = Example::Vecdouble.new(1000)
+
+100.times { |i| iv.setitem(i, 2*i) }
+
+1000.times { |i| dv.setitem(i, 1.0/(i+1)) }
+
+sum = 0
+100.times { |i| sum = sum + iv.getitem(i) }
+
+puts sum
+
+sum = 0.0
+1000.times { |i| sum = sum + dv.getitem(i) }
+puts sum
diff --git a/Examples/ruby/value/.cvsignore b/Examples/ruby/value/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/value/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/value/Makefile b/Examples/ruby/value/Makefile
index cd0fdf300..0a59614c4 100644
--- a/Examples/ruby/value/Makefile
+++ b/Examples/ruby/value/Makefile
@@ -13,6 +13,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/variables/.cvsignore b/Examples/ruby/variables/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/ruby/variables/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/ruby/variables/Makefile b/Examples/ruby/variables/Makefile
index cd0fdf300..0a59614c4 100644
--- a/Examples/ruby/variables/Makefile
+++ b/Examples/ruby/variables/Makefile
@@ -13,6 +13,6 @@ static::
TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
clean::
- rm -f *_wrap* *.o *~ *.so myruby .~* core
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
check: all
diff --git a/Examples/ruby/variables/example.i b/Examples/ruby/variables/example.i
index d62f973da..91bd0679d 100644
--- a/Examples/ruby/variables/example.i
+++ b/Examples/ruby/variables/example.i
@@ -27,10 +27,10 @@ extern Point pt;
/* Some read-only variables */
-%readonly
+%immutable;
extern int status;
extern char path[256];
-%readwrite
+%mutable;
/* Some helper functions to make it easier to test */
extern void print_vars();
diff --git a/Examples/ruby/variables/index.html b/Examples/ruby/variables/index.html
index df144d32b..d0dd76211 100644
--- a/Examples/ruby/variables/index.html
+++ b/Examples/ruby/variables/index.html
@@ -68,21 +68,21 @@ Getting the "value" returns a pointer to the global variable. Setting the value
<h2>Creating read-only variables</h2>
-The <tt>%readonly</tt> and <tt>%readwrite</tt> directives can be used to
+The <tt>%immutable</tt> and <tt>%mutable</tt> directives can be used to
specify a collection of read-only variables. For example:
<blockquote>
<pre>
-%readonly
+%immutable;
int status;
double blah;
...
-%readwrite
+%mutable;
</pre>
</blockquote>
-The <tt>%readonly</tt> directive remains in effect until it is explicitly disabled
-using the <tt>%readwrite</tt> directive.
+The <tt>%immutable</tt> directive remains in effect until it is explicitly disabled
+using the <tt>%mutable</tt> directive.
<h2>Comments</h2>
<ul>
diff --git a/Examples/ruby/variables/runme.rb b/Examples/ruby/variables/runme.rb
index ab73a35e4..cbb6b0df7 100644
--- a/Examples/ruby/variables/runme.rb
+++ b/Examples/ruby/variables/runme.rb
@@ -25,23 +25,23 @@ Example.name = "Bill"
puts "Variables (values printed from Ruby)"
-print "ivar = ", Example.ivar, "\n"
-print "svar = ", Example.svar, "\n"
-print "lvar = ", Example.lvar, "\n"
-print "uivar = ", Example.uivar, "\n"
-print "usvar = ", Example.usvar, "\n"
-print "ulvar = ", Example.ulvar, "\n"
-print "scvar = ", Example.scvar, "\n"
-print "ucvar = ", Example.ucvar, "\n"
-print "fvar = ", Example.fvar, "\n"
-print "dvar = ", Example.dvar, "\n"
-print "cvar = ", Example.cvar, "\n"
-print "strvar = ", Example.strvar, "\n"
-print "cstrvar = ", Example.cstrvar, "\n"
-print "iptrvar = ", Example.iptrvar, "\n"
-print "name = ", Example.name, "\n"
-print "ptptr = ", Example.ptptr, " ", Example.Point_print(Example.ptptr), "\n"
-print "pt = ", Example.pt, " ", Example.Point_print(Example.pt), "\n"
+puts "ivar = #{Example.ivar}"
+puts "svar = #{Example.svar}"
+puts "lvar = #{Example.lvar}"
+puts "uivar = #{Example.uivar}"
+puts "usvar = #{Example.usvar}"
+puts "ulvar = #{Example.ulvar}"
+puts "scvar = #{Example.scvar}"
+puts "ucvar = #{Example.ucvar}"
+puts "fvar = #{Example.fvar}"
+puts "dvar = #{Example.dvar}"
+puts "cvar = #{Example.cvar}"
+puts "strvar = #{Example.strvar}"
+puts "cstrvar = #{Example.cstrvar}"
+puts "iptrvar = #{Example.iptrvar}"
+puts "name = #{Example.name}"
+puts "ptptr = #{Example.ptptr} (#{Example.Point_print(Example.ptptr)})"
+puts "pt = #{Example.pt} (#{Example.Point_print(Example.pt)})"
puts "\nVariables (values printed from C)"
@@ -66,13 +66,13 @@ rescue NameError
end
-print "\nI'm going to try and update a structure variable.\n\n"
+puts "\nI'm going to try and update a structure variable.\n"
Example.pt = Example.ptptr
puts "The new value is"
Example.pt_print()
-print "You should see the value ", Example.Point_print(Example.ptptr), "\n"
+puts "You should see the value #{Example.Point_print(Example.ptptr)}"
diff --git a/Examples/s-exp/uffi.lisp b/Examples/s-exp/uffi.lisp
new file mode 100644
index 000000000..3869f10e4
--- /dev/null
+++ b/Examples/s-exp/uffi.lisp
@@ -0,0 +1,349 @@
+;;; This is experimental code that uses the s-expression
+;;; representation of a C/C++ library interface to generate Foreign
+;;; Function Interface definitions for use with Kevin Rosenberg's
+;;; UFFI.
+;;;
+;;; Written by Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
+
+(require 'port) ; from CLOCC
+
+(in-package :cl-user)
+
+(require 'uffi)
+
+;; Interaction with the SWIG binary
+
+(defvar *swig-source-directory* #p"/home/mkoeppe/s/swig1.3/")
+
+(defvar *swig-program* (merge-pathnames "swig-1.3" *swig-source-directory*))
+
+(defun run-swig (swig-interface-file-name &key directory-search-list module
+ ignore-errors)
+ (setf (port:getenv :SWIG_LIB)
+ (namestring (merge-pathnames "Lib" *swig-source-directory*)))
+ (let ((temp-file-name "/tmp/swig.lsp"))
+ (let ((process
+ (port:run-prog (namestring *swig-program*)
+ :output t
+ :args `("-sexp"
+ ,@(mapcar (lambda (dir)
+ (concatenate 'string
+ "-I" (namestring dir)))
+ directory-search-list)
+ ,@(and module
+ `("-module" ,module))
+ "-o" ,temp-file-name
+ ,(namestring swig-interface-file-name)))))
+ #+cmu (unless (or (zerop (ext:process-exit-code process))
+ ignore-errors)
+ (error "Process swig exited abnormally"))
+ (with-open-file (s temp-file-name)
+ (read s)))))
+
+;; Type system
+
+(defun parse-swigtype (type-string &key start end junk-ok)
+ "Parse TYPE-STRING as SWIG's internal representation of C/C++
+types. Return two values: The type description (an improper list) and
+the terminating index into TYPE-STRING."
+ ;; SWIG's internal representation is described in Source/Swig/stype.c
+ (unless start
+ (setq start 0))
+ (unless end
+ (setq end (length type-string)))
+ (flet ((prefix-match (prefix)
+ (let ((position (mismatch prefix type-string :start2 start :end2 end)))
+ (or (not position)
+ (= position (length prefix)))))
+ (bad-type-error (reason)
+ (error "Bad SWIG type (~A): ~A" reason
+ (subseq type-string start end)))
+ (type-char (index)
+ (and (< index (length type-string))
+ (char type-string index)))
+ (cons-and-recurse (prefix start end)
+ (multiple-value-bind (type-description index)
+ (parse-swigtype type-string :start start :end end
+ :junk-ok junk-ok)
+ (values (cons prefix type-description)
+ index))))
+ (cond
+ ((prefix-match "p.") ; pointer
+ (cons-and-recurse '* (+ start 2) end))
+ ((prefix-match "r.") ; C++ reference
+ (cons-and-recurse '& (+ start 2) end))
+ ((prefix-match "a(") ; array
+ (let ((closing-paren (find #\) type-string
+ :start (+ start 2)
+ :end end)))
+ (unless closing-paren
+ (bad-type-error "missing right paren"))
+ (unless (eql (type-char (+ closing-paren 1)) #\.)
+ (bad-type-error "missing dot"))
+ (cons-and-recurse (list 'ARRAY (subseq type-string (+ start 2) closing-paren))
+ (+ closing-paren 2) end)))
+ ((prefix-match "q(") ; qualifier (const, volatile)
+ (let ((closing-paren (find #\) type-string
+ :start (+ start 2)
+ :end end)))
+ (unless closing-paren
+ (bad-type-error "missing right paren"))
+ (unless (eql (type-char (+ closing-paren 1)) #\.)
+ (bad-type-error "missing dot"))
+ (cons-and-recurse (list 'QUALIFIER (subseq type-string (+ start 2) closing-paren))
+ (+ closing-paren 2) end)))
+ ((prefix-match "m(") ; C++ member pointer
+ (multiple-value-bind (class-type class-end-index)
+ (parse-swigtype type-string :junk-ok t
+ :start (+ start 2) :end end)
+ (unless (eql (type-char class-end-index) #\))
+ (bad-type-error "missing right paren"))
+ (unless (eql (type-char (+ class-end-index 1)) #\.)
+ (bad-type-error "missing dot"))
+ (cons-and-recurse (list 'MEMBER-POINTER class-type)
+ (+ class-end-index 2) end)))
+ ((prefix-match "f(") ; function
+ (loop with index = (+ start 2)
+ until (eql (type-char index) #\))
+ collect (multiple-value-bind (arg-type arg-end-index)
+ (parse-swigtype type-string :junk-ok t
+ :start index :end end)
+ (case (type-char arg-end-index)
+ (#\, (setq index (+ arg-end-index 1)))
+ (#\) (setq index arg-end-index))
+ (otherwise (bad-type-error "comma or right paren expected")))
+ arg-type)
+ into arg-types
+ finally (unless (eql (type-char (+ index 1)) #\.)
+ (bad-type-error "missing dot"))
+ (return (cons-and-recurse (cons 'FUNCTION arg-types)
+ (+ index 2) end))))
+ (t (let ((junk-position (position-if (lambda (char)
+ (member char '(#\, #\( #\) #\.)))
+ type-string
+ :start start :end end)))
+ (cond (junk-position ; found junk
+ (unless junk-ok
+ (bad-type-error "trailing junk"))
+ (values (subseq type-string start junk-position)
+ junk-position))
+ (t
+ (values (subseq type-string start end)
+ end))))))))
+
+(defun swigtype-function-p (swigtype)
+ "Check whether SWIGTYPE designates a function. If so, the second
+value is the list of argument types, and the third value is the return
+type."
+ (if (and (consp swigtype)
+ (consp (first swigtype))
+ (eql (first (first swigtype)) 'FUNCTION))
+ (values t (rest (first swigtype)) (rest swigtype))
+ (values nil nil nil)))
+
+
+;; UFFI
+
+(defvar *uffi-definitions* '())
+
+(defconstant *uffi-default-primitive-type-alist*
+ '(("char" . :char)
+ ("unsigned char" . :unsigned-byte)
+ ("signed char" . :byte)
+ ("short" . :short)
+ ("signed short" . :short)
+ ("unsigned short" . :unsigned-short)
+ ("int" . :int)
+ ("signed int" . :int)
+ ("unsigned int" . :unsigned-int)
+ ("long" . :long)
+ ("signed long" . :long)
+ ("unsigned long" . :unsigned-long)
+ ("float" . :float)
+ ("double" . :double)
+ ((* . "char") . :cstring)
+ ((* . "void") . :pointer-void)
+ ("void" . :void)))
+
+(defvar *uffi-primitive-type-alist* *uffi-default-primitive-type-alist*)
+
+(defun uffi-type-spec (type-list)
+ "Return the UFFI type spec equivalent to TYPE-LIST, or NIL if there
+is no representation."
+ (let ((primitive-type-pair
+ (assoc type-list *uffi-primitive-type-alist* :test 'equal)))
+ (cond
+ (primitive-type-pair
+ (cdr primitive-type-pair))
+ ((and (consp type-list)
+ (eql (first type-list) '*))
+ (let ((base-type-spec (uffi-type-spec (rest type-list))))
+ (cond
+ ((not base-type-spec)
+ :pointer-void)
+ (t
+ (list '* base-type-spec)))))
+ (t nil))))
+
+;; Parse tree
+
+(defvar *uffi-output* nil)
+
+(defun emit-uffi-definition (uffi-definition)
+ (format *uffi-output* "~&~S~%" uffi-definition)
+ (push uffi-definition *uffi-definitions*))
+
+(defun make-cl-symbol (c-identifier)
+ (intern (substitute #\- #\_ (string-upcase c-identifier))))
+
+(defvar *class-scope* '() "A stack of names of nested C++ classes.")
+
+(defvar *struct-fields* '())
+
+(defgeneric handle-node (node-type &key &allow-other-keys)
+ (:documentation "Handle a node of SWIG's parse tree of a C/C++ program"))
+
+(defmethod handle-node ((node-type t) &key &allow-other-keys)
+ ;; do nothing for unknown node types
+ nil)
+
+(defmethod handle-node ((node-type (eql 'cdecl)) &key name decl storage parms type &allow-other-keys)
+ (let ((swigtype (parse-swigtype (concatenate 'string decl type))))
+ (let ((*print-pretty* nil)) ; or FUNCTION would be printed as #' by cmucl
+ (format *uffi-output* "~&;; C Declaration: ~A ~A ~A ~A~%;; with-parms ~W~%;; of-type ~W~%"
+ storage type name decl parms swigtype))
+ (multiple-value-bind (function-p arg-swigtype-list return-swigtype)
+ (swigtype-function-p swigtype)
+ (declare (ignore arg-swigtype-list))
+ (cond
+ ((and (null *class-scope*) function-p) ; ordinary top-level function
+ (let ((uffi-arg-list
+ (mapcar (lambda (param)
+ (destructuring-bind (&key name type &allow-other-keys) param
+ (let ((uffi-type (uffi-type-spec (parse-swigtype type))))
+ (unless uffi-type
+ (format *uffi-output* "~&;; Warning: Cannot handle type ~S of argument `~A'~%"
+ type name)
+ (return-from handle-node))
+ `(,(make-cl-symbol name) ,uffi-type))))
+ parms))
+ (uffi-return-type
+ (uffi-type-spec return-swigtype)))
+ (unless uffi-return-type
+ (format *uffi-output* "~&;; Warning: Cannot handle return type `~S'~%"
+ return-swigtype)
+ (return-from handle-node))
+ (emit-uffi-definition `(UFFI:DEF-FUNCTION ,name ,uffi-arg-list :RETURNING ,uffi-return-type))))
+
+ ((and (not (null *class-scope*)) (null (rest *class-scope*))
+ (not function-p)) ; class/struct member (no nested structs)
+ (let ((uffi-type (uffi-type-spec swigtype)))
+ (unless uffi-type
+ (format *uffi-output* "~&;; Warning: Cannot handle type ~S of struct field `~A'~%"
+ type name)
+ (return-from handle-node))
+ (push `(,(make-cl-symbol name) ,uffi-type) *struct-fields*)))))))
+
+(defmethod handle-node ((node-type (eql 'class)) &key name children kind &allow-other-keys)
+ (format *uffi-output* "~&;; Class ~A~%" name)
+ (let ((*class-scope* (cons name *class-scope*))
+ (*struct-fields* '()))
+ (dolist (child children)
+ (apply 'handle-node child))
+ (emit-uffi-definition `(,(if (string= kind "union")
+ 'UFFI:DEF-UNION
+ 'UFFI:DEF-STRUCT)
+ ,(make-cl-symbol name) ,@(nreverse *struct-fields*)))))
+
+(defmethod handle-node ((node-type (eql 'top)) &key children &allow-other-keys)
+ (dolist (child children)
+ (apply 'handle-node child)))
+
+(defmethod handle-node ((node-type (eql 'include)) &key name children &allow-other-keys)
+ (format *uffi-output* ";; INCLUDE ~A~%" name)
+ (dolist (child children)
+ (apply 'handle-node child)))
+
+;;(defun compute-uffi-definitions (swig-interface)
+;; (let ((*uffi-definitions* '()))
+;; (handle-node swig-interface)
+;; *uffi-definitions*))
+
+;; Test instances
+
+#+ignore
+(defvar *gifplot-interface*
+ (run-swig (merge-pathnames "Examples/GIFPlot/Interface/gifplot.i"
+ *swig-source-directory*)
+ :directory-search-list (list (merge-pathnames "Examples/GIFPlot/Interface/" *swig-source-directory*))))
+
+(defvar *simple-gifplot-interface*
+ (run-swig (merge-pathnames "Examples/GIFPlot/Include/gifplot.h"
+ *swig-source-directory*)
+ :directory-search-list (list (merge-pathnames "Examples/GIFPlot/Interface/" *swig-source-directory*))
+ :module "gifplot"))
+
+(defvar *cplex-glue-directory* #p"/home/mkoeppe/cvs/cplex-glue/")
+
+(defvar *cplex-glue-interface*
+ (run-swig (merge-pathnames "cplex.i" *cplex-glue-directory*)
+ :directory-search-list (list (merge-pathnames "Lib/guile"
+ *swig-source-directory*)
+ *cplex-glue-directory*)
+ :ignore-errors t))
+
+
+
+(require 'uffi)
+
+;;(let ((*uffi-primitive-type-alist* (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*)))
+;; (eval (cons 'progn (compute-uffi-definitions *simple-gifplot-interface*))))
+
+
+(with-open-file (f "/tmp/swig-uffi.lisp" :direction :output)
+ (let ((*uffi-definitions* '())
+ (*uffi-output* f)
+ (*uffi-primitive-type-alist*
+ (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*)))
+ (apply 'handle-node *simple-gifplot-interface*)))
+
+#+cplex
+(with-open-file (f "/tmp/swig-uffi.lisp" :direction :output)
+ (let ((*uffi-definitions* '())
+ (*uffi-output* f)
+ (*uffi-primitive-type-alist*
+ (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*)))
+ (apply 'handle-node *cplex-glue-interface*)))
+
+(compile-file "/tmp/swig-uffi.lisp")
+
+(load "/tmp/swig-uffi.lisp")
+
+(uffi:load-foreign-library (merge-pathnames "Examples/GIFPlot/libgifplot.a"
+ *swig-source-directory*))
+
+(load (merge-pathnames "Examples/GIFPlot/Common-Lisp/full/runme.lisp" *swig-source-directory*))
+
+(action (namestring (merge-pathnames "Examples/GIFPlot/Common-Lisp/full/cmap"
+ *swig-source-directory*)))
+
+;;;; TODO:
+
+;; * How to do type lookups? Is everything important that SWIG knows
+;; about the types written out? What to make of typemaps?
+;;
+;; * Wrapped functions should probably automatically COERCE their
+;; arguments (as of type DOUBLE-FLOAT), to make the functions more
+;; flexible?
+;;
+;; * Why are the functions created by FFI interpreted?
+;;
+;; * We can't deal with more complicated structs and C++ classes
+;; directly with the FFI; we have to emit SWIG wrappers that access
+;; those classes.
+;;
+;; * A CLOS layer where structure fields are mapped as slots. It
+;; looks like we need MOP functions to implement this.
+;;
+;; * Maybe modify SWIG so that key-value hashes are distinguished from
+;; value-value hashes.
diff --git a/Examples/tcl/check.list b/Examples/tcl/check.list
new file mode 100644
index 000000000..7301d2f83
--- /dev/null
+++ b/Examples/tcl/check.list
@@ -0,0 +1,13 @@
+# see top-level Makefile.in
+class
+constants
+enum
+funcptr
+import
+multimap
+operator
+pointer
+reference
+simple
+value
+variables
diff --git a/Examples/tcl/class/.cvsignore b/Examples/tcl/class/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/class/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/class/Makefile b/Examples/tcl/class/Makefile
index 942f4cf8f..7d3d5f9cb 100644
--- a/Examples/tcl/class/Makefile
+++ b/Examples/tcl/class/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mytclsh *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/class/example.cxx b/Examples/tcl/class/example.cxx
index 21582f4d1..1e8e203dd 100644
--- a/Examples/tcl/class/example.cxx
+++ b/Examples/tcl/class/example.cxx
@@ -1,7 +1,7 @@
/* File : example.c */
#include "example.h"
-#include <math.h>
+#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area() {
+double Circle::area(void) {
return M_PI*radius*radius;
}
-double Circle::perimeter() {
+double Circle::perimeter(void) {
return 2*M_PI*radius;
}
-double Square::area() {
+double Square::area(void) {
return width*width;
}
-double Square::perimeter() {
+double Square::perimeter(void) {
return 4*width;
}
diff --git a/Examples/tcl/class/example.dsp b/Examples/tcl/class/example.dsp
new file mode 100644
index 000000000..0eeb9d4dd
--- /dev/null
+++ b/Examples/tcl/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 "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/tcl/class/example.h b/Examples/tcl/class/example.h
index 849071dd3..46d901361 100644
--- a/Examples/tcl/class/example.h
+++ b/Examples/tcl/class/example.h
@@ -10,8 +10,8 @@ public:
};
double x, y;
void move(double dx, double dy);
- virtual double area() = 0;
- virtual double perimeter() = 0;
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
static int nshapes;
};
@@ -20,8 +20,8 @@ private:
double radius;
public:
Circle(double r) : radius(r) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
class Square : public Shape {
@@ -29,8 +29,8 @@ private:
double width;
public:
Square(double w) : width(w) { };
- virtual double area();
- virtual double perimeter();
+ virtual double area(void);
+ virtual double perimeter(void);
};
diff --git a/Examples/tcl/class/example1.tcl b/Examples/tcl/class/example1.tcl
index f766a4f92..358dbf143 100644
--- a/Examples/tcl/class/example1.tcl
+++ b/Examples/tcl/class/example1.tcl
@@ -22,11 +22,11 @@ puts "\nA total of $Shape_nshapes shapes were created"
# ----- Member data access -----
# Set the location of the object
+# Note: the base class must be used since that's where x and y
+# were declared.
Shape_x_set $c 20
Shape_y_set $c 30
-
-# Now use the same functions in the base class
Shape_x_set $s -10
Shape_y_set $s 5
@@ -69,6 +69,3 @@ delete_Shape $s
puts "$Shape_nshapes shapes remain"
puts "Goodbye"
-
-
-
diff --git a/Examples/tcl/class/example2.tcl b/Examples/tcl/class/example2.tcl
index 6ea166df6..9f7a3b8f3 100644
--- a/Examples/tcl/class/example2.tcl
+++ b/Examples/tcl/class/example2.tcl
@@ -11,7 +11,7 @@ catch { load ./example.dll example} ;# Windows
puts "Creating some objects:"
Circle c 10
puts " Created circle [c cget -this]"
-Circle s 10
+Square s 10
puts " Created square [s cget -this]"
# ----- Access a static member -----
diff --git a/Examples/tcl/class/index.html b/Examples/tcl/class/index.html
index 00bd4e870..c3069ced6 100644
--- a/Examples/tcl/class/index.html
+++ b/Examples/tcl/class/index.html
@@ -120,14 +120,13 @@ For example:
<blockquote>
<pre>
-Circle_x_set $c 15 ;# Set member data
+Shape_x_set $c 15 ;# Set member data
set x [Shape_x_get $c] ;# Get member data
</pre>
</blockquote>
-Note: when accessing member data, the name of the base class or the derived class can be
-used in the function name as shown above. Of course, it would probably be more
-proper to just use the base class version such as <tt>Shape_x_get</tt>
+Note: when accessing member data, the name of the base class must
+be used such as <tt>Shape_x_get</tt>
<p>
<li>To invoke a member function, you simply do this
@@ -270,28 +269,6 @@ to write a helper function. For example:
<p>
<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
-<p>
-<li>Templates. Not supported at all. SWIG throws out anything that looks like a template.
-You can work around the problem by aliasing a template class behind a typedef however.
-For example:
-
-<blockquote>
-<pre>
-%{
-typedef vector<int> IntVector;
-%}
-
-class IntVector {
-public:
- ... methods ...
-};
-</pre>
-</blockquote>
-</ul>
-<p>
-<li>There is no guarantee that an extremely complex C++ application will be able to compile
-as a Python extension. Sorry.
-
</ul>
<hr>
diff --git a/Examples/tcl/constants/.cvsignore b/Examples/tcl/constants/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/constants/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/constants/Makefile b/Examples/tcl/constants/Makefile
index bb509b03f..ef0486c0b 100644
--- a/Examples/tcl/constants/Makefile
+++ b/Examples/tcl/constants/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o my_tclsh *~ .~* core *.so *.sl
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/constants/example.i b/Examples/tcl/constants/example.i
index 29a1a7f11..4f7b1a4d7 100644
--- a/Examples/tcl/constants/example.i
+++ b/Examples/tcl/constants/example.i
@@ -19,8 +19,9 @@
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
-/* The following statements also produce constants */
-const int iconst = 37;
-const double fconst = 3.14;
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
diff --git a/Examples/tcl/enum/.cvsignore b/Examples/tcl/enum/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/enum/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/enum/Makefile b/Examples/tcl/enum/Makefile
index 942f4cf8f..7d3d5f9cb 100644
--- a/Examples/tcl/enum/Makefile
+++ b/Examples/tcl/enum/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mytclsh *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/funcptr/.cvsignore b/Examples/tcl/funcptr/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/funcptr/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/funcptr/Makefile b/Examples/tcl/funcptr/Makefile
index fcb994d09..6efb6fb84 100644
--- a/Examples/tcl/funcptr/Makefile
+++ b/Examples/tcl/funcptr/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o my_tclsh *~ .~* core *.so *.sl
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/funcptr/example.c b/Examples/tcl/funcptr/example.c
index 99583b72e..5c4a3dabf 100644
--- a/Examples/tcl/funcptr/example.c
+++ b/Examples/tcl/funcptr/example.c
@@ -15,3 +15,5 @@ int sub(int a, int b) {
int mul(int a, int b) {
return a*b;
}
+
+int (*funcvar)(int,int) = add;
diff --git a/Examples/tcl/funcptr/example.i b/Examples/tcl/funcptr/example.i
index 73cc6eb8c..8b3bef678 100644
--- a/Examples/tcl/funcptr/example.i
+++ b/Examples/tcl/funcptr/example.i
@@ -8,8 +8,9 @@
extern int do_op(int a, int b, int (*op)(int, int));
/* Now install a bunch of "ops" as constants */
-%constant(int (*)(int,int)) ADD = add;
-%constant(int (*)(int,int)) SUB = sub;
-%constant(int (*)(int,int)) MUL = mul;
+%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/tcl/import/.cvsignore b/Examples/tcl/import/.cvsignore
new file mode 100644
index 000000000..02f077192
--- /dev/null
+++ b/Examples/tcl/import/.cvsignore
@@ -0,0 +1,4 @@
+bar_wrap.cxx
+base_wrap.cxx
+foo_wrap.cxx
+spam_wrap.cxx
diff --git a/Examples/tcl/import/Makefile b/Examples/tcl/import/Makefile
new file mode 100644
index 000000000..b0c0a8f0e
--- /dev/null
+++ b/Examples/tcl/import/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIGOPT = -c
+#If your system requires linking with the runtime libraries then set the directory location here
+RUNTIMEDIR =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='base' INTERFACE='base.i' tcl_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='foo' INTERFACE='foo.i' tcl_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='bar' INTERFACE='bar.i' tcl_multi_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ RUNTIMEDIR='$(RUNTIMEDIR)' TARGET='spam' INTERFACE='spam.i' tcl_multi_cpp
+
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+
+check: all
diff --git a/Examples/tcl/import/README b/Examples/tcl/import/README
new file mode 100644
index 000000000..25d0e98ec
--- /dev/null
+++ b/Examples/tcl/import/README
@@ -0,0 +1,28 @@
+This example tests the SWIG run-time libraries and use of the
+%import directive to work with multiple modules.
+
+Use 'tclsh runme.tcl' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is working correctly, all of the modules will load
+correctly and type checking will work correctly. The
+example requires the use of the SWIG run-time libraries
+which must be built and properly installed.
+
+
+
+
diff --git a/Examples/tcl/import/bar.h b/Examples/tcl/import/bar.h
new file mode 100644
index 000000000..fa4185f1f
--- /dev/null
+++ b/Examples/tcl/import/bar.h
@@ -0,0 +1,22 @@
+#include "base.h"
+
+class Bar : public Base {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual void A() {
+ printf("I'm Bar::A\n");
+ }
+ void B() {
+ printf("I'm Bar::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Bar *fromBase(Base *b) {
+ return dynamic_cast<Bar *>(b);
+ }
+
+};
+
+
diff --git a/Examples/tcl/import/bar.i b/Examples/tcl/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/Examples/tcl/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/Examples/tcl/import/base.h b/Examples/tcl/import/base.h
new file mode 100644
index 000000000..be3cdef7d
--- /dev/null
+++ b/Examples/tcl/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/Examples/tcl/import/base.i b/Examples/tcl/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/Examples/tcl/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/Examples/tcl/import/foo.h b/Examples/tcl/import/foo.h
new file mode 100644
index 000000000..dd5184031
--- /dev/null
+++ b/Examples/tcl/import/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+class Foo : public Base {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual void A() {
+ printf("I'm Foo::A\n");
+ }
+ void B() {
+ printf("I'm Foo::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Foo *fromBase(Base *b) {
+ return dynamic_cast<Foo *>(b);
+ }
+};
+
+
diff --git a/Examples/tcl/import/foo.i b/Examples/tcl/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/Examples/tcl/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/Examples/tcl/import/runme.tcl b/Examples/tcl/import/runme.tcl
new file mode 100644
index 000000000..f69f82dec
--- /dev/null
+++ b/Examples/tcl/import/runme.tcl
@@ -0,0 +1,121 @@
+# file: runme.py
+# Test various properties of classes defined in separate modules
+
+puts "Testing the %import directive"
+catch { load ./base.so base}
+catch { load ./base.dll base} ;# Windows
+
+catch { load ./foo.so foo}
+catch { load ./foo.dll foo} ;# Windows
+
+catch { load ./bar.so bar}
+catch { load ./bar.dll bar} ;# Windows
+
+catch { load ./spam.so spam}
+catch { load ./spam.dll spam} ;# Windows
+
+# Create some objects
+
+puts "Creating some objects"
+
+set a [Base]
+set b [Foo]
+set c [Bar]
+set d [Spam]
+
+# Try calling some methods
+puts "Testing some methods"
+puts "Should see 'Base::A' ---> "
+$a A
+puts "Should see 'Base::B' ---> "
+$a B
+
+puts "Should see 'Foo::A' ---> "
+$b A
+puts "Should see 'Foo::B' ---> "
+$b B
+
+puts "Should see 'Bar::A' ---> "
+$c A
+puts "Should see 'Bar::B' ---> "
+$c B
+
+puts "Should see 'Spam::A' ---> "
+$d A
+puts "Should see 'Spam::B' ---> "
+$d B
+
+# Try some casts
+
+puts "\nTesting some casts\n"
+
+Base x -this [$a toBase]
+puts "Should see 'Base::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Base x -this [$b toBase]
+puts "Should see 'Foo::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Base x -this [$c toBase]
+puts "Should see 'Bar::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Base x -this [$d toBase]
+puts "Should see 'Spam::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Bar x -this [$d toBar]
+puts "Should see 'Bar::B' ---> "
+x B
+rename x ""
+
+puts "\nTesting some dynamic casts\n"
+Base x -this [$d toBase]
+
+puts "Spam -> Base -> Foo : "
+set y [Foo_fromBase [x cget -this]]
+if {$y != "NULL"} {
+ puts "bad swig"
+} {
+ puts "good swig"
+}
+
+puts "Spam -> Base -> Bar : "
+set y [Bar_fromBase [x cget -this]]
+if {$y != "NULL"} {
+ puts "good swig"
+} {
+ puts "bad swig"
+}
+
+puts "Spam -> Base -> Spam : "
+set y [Spam_fromBase [x cget -this]]
+if {$y != "NULL"} {
+ puts "good swig"
+} {
+ puts "bad swig"
+}
+
+puts "Foo -> Spam : "
+set y [Spam_fromBase $b]
+if {$y != "NULL"} {
+ puts "bad swig"
+} {
+ puts "good swig"
+}
+
+
+
diff --git a/Examples/tcl/import/spam.h b/Examples/tcl/import/spam.h
new file mode 100644
index 000000000..b4e7a2646
--- /dev/null
+++ b/Examples/tcl/import/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+class Spam : public Bar {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual void A() {
+ printf("I'm Spam::A\n");
+ }
+ void B() {
+ printf("I'm Spam::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ virtual Bar *toBar() {
+ return static_cast<Bar *>(this);
+ }
+ static Spam *fromBase(Base *b) {
+ return dynamic_cast<Spam *>(b);
+ }
+};
+
+
diff --git a/Examples/tcl/import/spam.i b/Examples/tcl/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/Examples/tcl/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/Examples/tcl/index.html b/Examples/tcl/index.html
index 2fbb3c78e..2c1e0f98e 100644
--- a/Examples/tcl/index.html
+++ b/Examples/tcl/index.html
@@ -35,6 +35,10 @@ certain C declarations are turned into constants.
</pre>
</blockquote>
+<li>
+Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
+</li>
+
<li>The compilation of examples is done using the file <tt>Example/Makefile</tt>. This
makefile performs a manual module compilation which is platform specific. Typically,
the steps look like this (Linux):
diff --git a/Examples/tcl/multimap/.cvsignore b/Examples/tcl/multimap/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/multimap/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/multimap/Makefile b/Examples/tcl/multimap/Makefile
new file mode 100644
index 000000000..6efb6fb84
--- /dev/null
+++ b/Examples/tcl/multimap/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+SRCS = example.c
+TARGET = my_tclsh
+DLTARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+
+check: all
diff --git a/Examples/tcl/multimap/example.c b/Examples/tcl/multimap/example.c
new file mode 100644
index 000000000..d135481af
--- /dev/null
+++ b/Examples/tcl/multimap/example.c
@@ -0,0 +1,53 @@
+/* File : example.c */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* 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] = 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/tcl/multimap/example.dsp b/Examples/tcl/multimap/example.dsp
new file mode 100644
index 000000000..419d50f54
--- /dev/null
+++ b/Examples/tcl/multimap/example.dsp
@@ -0,0 +1,148 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(TCL_LIB) /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib $(TCL_LIB) /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/tcl/multimap/example.i b/Examples/tcl/multimap/example.i
new file mode 100644
index 000000000..afe7ed7f9
--- /dev/null
+++ b/Examples/tcl/multimap/example.i
@@ -0,0 +1,68 @@
+/* File : example.i */
+%module example
+%include exception.i
+
+extern int gcd(int x, int y);
+
+%typemap(tcl8,in) (int argc, char *argv[]) {
+ Tcl_Obj **listobjv = 0;
+ int i;
+ if (Tcl_ListObjGetElements(interp,$input, &$1, &listobjv) == TCL_ERROR) {
+ SWIG_exception(SWIG_ValueError,"Expected a list");
+ return TCL_ERROR;
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ $2[i] = Tcl_GetStringFromObj(listobjv[i],0);
+ }
+ $2[i] = 0;
+}
+
+%typemap(tcl8,freearg) char *argv[] {
+ if ($1) {
+ free($1);
+ }
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(tcl8,in) (char *bytes, int len) {
+ $1 = Tcl_GetStringFromObj($input,&$2);
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(tcl8,in) (char *str, int len) {
+ char *temp;
+ temp = Tcl_GetStringFromObj($input,&$2);
+ $1 = (char *) malloc($2+1);
+ memmove($1,temp,$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(tcl8,argout) (char *str, int len) {
+ Tcl_Obj *o;
+ o = Tcl_NewStringObj($1,$2);
+ Tcl_ListObjAppendElement(interp,$result,o);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ return TCL_ERROR;
+ }
+}
+
+extern void circle(double cx, double cy);
diff --git a/Examples/tcl/multimap/example.tcl b/Examples/tcl/multimap/example.tcl
new file mode 100644
index 000000000..ae61ce7e8
--- /dev/null
+++ b/Examples/tcl/multimap/example.tcl
@@ -0,0 +1,25 @@
+# file: example.tcl
+# Try to load as a dynamic module.
+
+catch { load ./example.so example}
+catch { load ./example.dll example} ;# Windows
+
+# Call our gcd() function
+set x 42
+set y 105
+set g [gcd $x $y]
+puts "The gcd of $x and $y is $g"
+
+# call the gcdmain
+gcdmain "gcdmain 42 105"
+
+
+# call count
+set c [count "Hello World" l]
+puts $c
+
+# call capitalize
+
+set c [capitalize "helloworld"]
+puts $c
+
diff --git a/Examples/tcl/operator/.cvsignore b/Examples/tcl/operator/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/operator/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/operator/Makefile b/Examples/tcl/operator/Makefile
new file mode 100644
index 000000000..da2a152be
--- /dev/null
+++ b/Examples/tcl/operator/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+
+check: all
diff --git a/Examples/tcl/operator/example.h b/Examples/tcl/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/Examples/tcl/operator/example.h
@@ -0,0 +1,36 @@
+/* File : example.h */
+#include <math.h>
+
+class Complex {
+private:
+ double rpart, ipart;
+public:
+ Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
+ Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
+ Complex &operator=(const Complex &c) {
+ rpart = c.rpart;
+ ipart = c.ipart;
+ return *this;
+ }
+ Complex operator+(const Complex &c) const {
+ return Complex(rpart+c.rpart, ipart+c.ipart);
+ }
+ Complex operator-(const Complex &c) const {
+ return Complex(rpart-c.rpart, ipart-c.ipart);
+ }
+ Complex operator*(const Complex &c) const {
+ return Complex(rpart*c.rpart - ipart*c.ipart,
+ rpart*c.ipart + c.rpart*ipart);
+ }
+ Complex operator-() const {
+ return Complex(-rpart, -ipart);
+ }
+
+ double re() const { return rpart; }
+ double im() const { return ipart; }
+};
+
+
+
+
+
diff --git a/Examples/tcl/operator/example.i b/Examples/tcl/operator/example.i
new file mode 100644
index 000000000..f108edb4b
--- /dev/null
+++ b/Examples/tcl/operator/example.i
@@ -0,0 +1,28 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* This header file is a little tough to handle because it has overloaded
+ operators and constructors. We're going to try and deal with that here */
+
+/* This turns the copy constructor in a function ComplexCopy() that can
+ be called */
+
+%rename(ComplexCopy) Complex::Complex(Complex const &);
+
+/* Now grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend Complex {
+ char *str() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", self->re(), self->im());
+ return temp;
+ }
+};
+
+
diff --git a/Examples/tcl/operator/runme.tcl b/Examples/tcl/operator/runme.tcl
new file mode 100644
index 000000000..f76daffe1
--- /dev/null
+++ b/Examples/tcl/operator/runme.tcl
@@ -0,0 +1,31 @@
+# Operator overloading example
+
+catch { load ./example.so example}
+catch { load ./example.dll example} ;# Windows
+
+set a [Complex -args 2 3]
+set b [Complex -args -5 10]
+
+puts "a = $a [$a str]"
+puts "b = $b [$b str]"
+
+set c [$a + $b]
+Complex -this $c
+puts "c = $c [$c str]"
+
+set d [$a * $b]
+Complex -this $d
+puts "a*b = [$d str]"
+
+# Alternative calling convention
+set e [Complex_- $a $c]
+puts "a-c = [Complex_str $e]"
+
+set f [new_ComplexCopy $e]
+Complex -this $f
+puts "f = [$f str]"
+
+# Call assignment operator
+$c = $f
+puts "c = [$c str]"
+
diff --git a/Examples/tcl/pointer/.cvsignore b/Examples/tcl/pointer/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/pointer/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/pointer/Makefile b/Examples/tcl/pointer/Makefile
index fcb994d09..6efb6fb84 100644
--- a/Examples/tcl/pointer/Makefile
+++ b/Examples/tcl/pointer/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o my_tclsh *~ .~* core *.so *.sl
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/pointer/example.i b/Examples/tcl/pointer/example.i
index 2ed2b5bbf..841a2de4c 100644
--- a/Examples/tcl/pointer/example.i
+++ b/Examples/tcl/pointer/example.i
@@ -6,7 +6,9 @@
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
-%include pointer.i
+
+%include cpointer.i
+%pointer_functions(int, intp);
/* Next we'll use some typemaps */
diff --git a/Examples/tcl/pointer/example.tcl b/Examples/tcl/pointer/example.tcl
index d953a55a5..b67583caf 100644
--- a/Examples/tcl/pointer/example.tcl
+++ b/Examples/tcl/pointer/example.tcl
@@ -5,9 +5,12 @@ catch { load ./example.dll example} ;# Windows
# First create some objects using the pointer library.
puts "Testing the pointer library"
-set a [ptrcreate int 37]
-set b [ptrcreate int 42]
-set c [ptrcreate int] ;# Memory for result
+set a [new_intp]
+set b [new_intp]
+set c [new_intp] ;# Memory for result
+
+intp_assign $a 37
+intp_assign $b 42
puts " a = $a"
puts " b = $b"
@@ -17,13 +20,13 @@ puts " c = $c"
add $a $b $c
# Now get the result
-set r [ptrvalue $c]
+set r [intp_value $c]
puts " 37 + 42 = $r"
# Clean up the pointers
-ptrfree $a
-ptrfree $b
-ptrfree $c
+delete_intp $a
+delete_intp $b
+delete_intp $c
# Now try the typemap library
# This should be much easier. Now how it is no longer
diff --git a/Examples/tcl/reference/.cvsignore b/Examples/tcl/reference/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/reference/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/reference/Makefile b/Examples/tcl/reference/Makefile
index 942f4cf8f..7d3d5f9cb 100644
--- a/Examples/tcl/reference/Makefile
+++ b/Examples/tcl/reference/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
clean::
- rm -f *_wrap* *.o *~ *.so mytclsh *.pyc .~* core
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/reference/example.i b/Examples/tcl/reference/example.i
index 8538326f6..e71f297bf 100644
--- a/Examples/tcl/reference/example.i
+++ b/Examples/tcl/reference/example.i
@@ -31,7 +31,7 @@ public:
int size();
/* This wrapper provides an alternative to the [] operator */
- %addmethods {
+ %extend {
Vector &get(int index) {
return (*self)[index];
}
diff --git a/Examples/tcl/simple/.cvsignore b/Examples/tcl/simple/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/simple/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/simple/Makefile b/Examples/tcl/simple/Makefile
index fcb994d09..6efb6fb84 100644
--- a/Examples/tcl/simple/Makefile
+++ b/Examples/tcl/simple/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o my_tclsh *~ .~* core *.so *.sl
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/simple/example.dsp b/Examples/tcl/simple/example.dsp
new file mode 100644
index 000000000..0f83e360a
--- /dev/null
+++ b/Examples/tcl/simple/example.dsp
@@ -0,0 +1,148 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 odbc32.lib odbccp32.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/tcl/value/.cvsignore b/Examples/tcl/value/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/value/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/value/Makefile b/Examples/tcl/value/Makefile
index fcb994d09..6efb6fb84 100644
--- a/Examples/tcl/value/Makefile
+++ b/Examples/tcl/value/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o my_tclsh *~ .~* core *.so *.sl
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/variables/.cvsignore b/Examples/tcl/variables/.cvsignore
new file mode 100644
index 000000000..5f25c5b9a
--- /dev/null
+++ b/Examples/tcl/variables/.cvsignore
@@ -0,0 +1,9 @@
+*_wrap.c
+*_wrap.cxx
+example.dll
+example.dsw
+example.ncb
+example.opt
+example.plg
+Release
+Debug
diff --git a/Examples/tcl/variables/Makefile b/Examples/tcl/variables/Makefile
index fcb994d09..6efb6fb84 100644
--- a/Examples/tcl/variables/Makefile
+++ b/Examples/tcl/variables/Makefile
@@ -14,6 +14,6 @@ static::
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
clean::
- rm -f *_wrap* *.o my_tclsh *~ .~* core *.so *.sl
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
check: all
diff --git a/Examples/tcl/variables/example.i b/Examples/tcl/variables/example.i
index c1e614cec..91bd0679d 100644
--- a/Examples/tcl/variables/example.i
+++ b/Examples/tcl/variables/example.i
@@ -27,10 +27,10 @@ extern Point pt;
/* Some read-only variables */
-%readonly {
- extern int status;
- extern char path[256];
-}
+%immutable;
+extern int status;
+extern char path[256];
+%mutable;
/* Some helper functions to make it easier to test */
extern void print_vars();
diff --git a/Examples/tcl/variables/index.html b/Examples/tcl/variables/index.html
index 368332b14..f299fbfa8 100644
--- a/Examples/tcl/variables/index.html
+++ b/Examples/tcl/variables/index.html
@@ -47,21 +47,21 @@ Getting the "value" returns a pointer to the global variable. Setting the value
<h2>Creating read-only variables</h2>
-The <tt>%readonly</tt> and <tt>%readwrite</tt> directives can be used to
+The <tt>%immutable</tt> and <tt>%mutable</tt> directives can be used to
specify a collection of read-only variables. For example:
<blockquote>
<pre>
-%readonly
+%immutable;
int status;
double blah;
...
-%readwrite
+%mutable;
</pre>
</blockquote>
-The <tt>%readonly</tt> directive remains in effect until it is explicitly disabled
-using the <tt>%readwrite</tt> directive.
+The <tt>%immutable</tt> directive remains in effect until it is explicitly disabled
+using the <tt>%mutable</tt> directive.
<h2>Comments</h2>
<ul>
diff --git a/Examples/test-suite/README b/Examples/test-suite/README
new file mode 100644
index 000000000..96dea942c
--- /dev/null
+++ b/Examples/test-suite/README
@@ -0,0 +1,42 @@
+SWIG testsuite README file
+--------------------------
+
+This testsuite is here to ensure SWIG can handle a wide range of c/c++
+syntax. The testsuite comprises many testcases in this directory. Each
+test case is tested under each of the language modules thereby
+thoroughly testing all of SWIG. It ensures that each of the language
+modules are at a similar standard.
+
+Those modules that support shadow classes run the tests producing
+shadow classes to test the full language module functionality.
+
+Some test cases need a runtime test. These need implementing in each
+of the language modules. The language modules look for a file in the
+language specific test-suite directory which has _runme appended after
+the testcase name. If one is found it will be run as part of the test.
+
+Some language modules add to this common set of test cases for
+language specific tests. These can be found in the appropriate
+language test-suite directory. There is also a README in each of the
+language module directories.
+
+For each testcase a message showing which testcase is being tested is
+displayed. Nothing else is printed unless the test fails.
+
+
+Some Developer Guidelines
+-------------------------
+
+Note that the whole test suite need not be run each time a testcase is
+modified. An individual testcase may be run by going to the language
+module test-suite directory and using make testcasename.xxx where xxx
+is the type of test (eg cpptest). See common.mk. make -s doesn't print
+any junk on the screen and is useful for emulating the way make check
+works from the SWIG root directory.
+
+If there are runtime tests needed, don't print anything unless there
+is an error in which case stderr is suggested.
+
+Please set the name of the module to the same name as the testcase,
+otherwise modules will not be found.
+
diff --git a/Examples/test-suite/abstract_inherit.i b/Examples/test-suite/abstract_inherit.i
new file mode 100644
index 000000000..5610c72d3
--- /dev/null
+++ b/Examples/test-suite/abstract_inherit.i
@@ -0,0 +1,20 @@
+%module abstract_inherit
+
+%warnfilter(403) Spam;
+%warnfilter(403) Bar;
+
+%inline %{
+
+class Foo {
+public:
+ virtual int blah() = 0;
+};
+
+class Bar : public Foo { };
+
+class Spam: public Foo {
+public:
+ Spam() { }
+};
+
+%}
diff --git a/Examples/test-suite/abstract_inherit_ok.i b/Examples/test-suite/abstract_inherit_ok.i
new file mode 100644
index 000000000..04715bad3
--- /dev/null
+++ b/Examples/test-suite/abstract_inherit_ok.i
@@ -0,0 +1,21 @@
+%module abstract_inherit_ok
+
+%feature("notabstract") Spam;
+%warnfilter(403) Spam;
+
+%inline %{
+
+class Foo {
+public:
+ virtual int blah() = 0;
+};
+
+class Spam: public Foo {
+public:
+ Spam() { }
+#ifndef SWIG
+ int blah() { return 0; }
+#endif
+};
+
+%}
diff --git a/Examples/test-suite/abstract_signature.i b/Examples/test-suite/abstract_signature.i
new file mode 100644
index 000000000..50ccbfc7a
--- /dev/null
+++ b/Examples/test-suite/abstract_signature.i
@@ -0,0 +1,25 @@
+%module abstract_signature
+
+%warnfilter(801) abstract_foo; // Ruby, wrong class name
+%warnfilter(801) abstract_bar; // Ruby, wrong class name
+
+%inline %{
+class abstract_foo
+{
+public:
+ abstract_foo() { };
+ virtual ~abstract_foo() { };
+ virtual int meth(int meth_param) = 0;
+};
+
+
+class abstract_bar : public abstract_foo
+{
+public:
+ abstract_bar() { };
+
+ virtual ~abstract_bar() { };
+ int meth(int meth_param_1, int meth_param_2) { return 0; }
+};
+
+%}
diff --git a/Examples/test-suite/abstract_typedef.i b/Examples/test-suite/abstract_typedef.i
new file mode 100644
index 000000000..89107dfc2
--- /dev/null
+++ b/Examples/test-suite/abstract_typedef.i
@@ -0,0 +1,52 @@
+%module abstract_typedef
+
+
+%inline %{
+ struct Engine
+ {
+ };
+
+ struct Object
+ {
+ virtual bool write(Engine& archive) const = 0;
+ };
+
+ typedef Engine PersEngine;
+ typedef Object PersClassBase;
+
+
+ class A : public PersClassBase
+ {
+ // This works always
+ // bool write(Engine& archive) const;
+
+ // This doesn't with Swig 1.3.17.
+ // But it works fine with 1.3.16
+ bool write(PersEngine& archive) const
+ {
+ return true;
+ }
+
+
+ };
+
+%}
+
+
+/*
+
+Problem related to the direct comparison of strings
+in the file allocate.cxx (line 55)
+
+ ......
+ String *local_decl = Getattr(dn,"decl");
+ if (local_decl && !Strcmp(local_decl, base_decl)) {
+ ......
+
+with the direct string comparison, no equivalent types
+are checked and the two 'write' functions appear to be
+different because
+
+ "q(const).f(r.bss::PersEngine)." != "q(const).f(r.bss::Engine)."
+
+*/
diff --git a/Examples/test-suite/add_link.i b/Examples/test-suite/add_link.i
new file mode 100644
index 000000000..dfd4b376d
--- /dev/null
+++ b/Examples/test-suite/add_link.i
@@ -0,0 +1,20 @@
+%module add_link
+
+%extend Foo {
+Foo *blah() {
+ return new Foo();
+}
+};
+
+
+%inline %{
+class Foo {
+public:
+ Foo() { };
+};
+
+%}
+
+
+
+
diff --git a/Examples/test-suite/anonymous_arg.i b/Examples/test-suite/anonymous_arg.i
new file mode 100644
index 000000000..b2417fda2
--- /dev/null
+++ b/Examples/test-suite/anonymous_arg.i
@@ -0,0 +1,12 @@
+/* This interface file checks whether the SWIG parses anonymous
+ arguments with default values. Bug reported by Annalisa Terracina
+ <annalisa.terracina@datamat.it> on 2001-07-03.
+*/
+
+%module anonymous_arg
+
+void foo(int = 7771);
+
+%{
+ void foo(int x) {}
+%}
diff --git a/Examples/test-suite/argout.i b/Examples/test-suite/argout.i
new file mode 100644
index 000000000..1584a9728
--- /dev/null
+++ b/Examples/test-suite/argout.i
@@ -0,0 +1,37 @@
+/* This interface file checks how well SWIG handles passing data back
+ through arguments WITHOUT returning it seperatly; for the cases where
+ maybe multiple values are passed by refernce and all want changing */
+
+%module argout
+
+%include cpointer.i
+%pointer_functions(int,intp);
+
+%inline %{
+// returns old value
+int incp(int *value) {
+ return (*value)++;
+}
+
+// returns old value
+int incr(int &value) {
+ return value++;
+}
+
+typedef int & IntRef;
+// returns old value
+int inctr(IntRef value) {
+ return value++;
+}
+
+// example of the old DB login type routines where you keep
+// a void* which it points to its opaque struct when you login
+// So login function takes a void**
+void voidhandle(void** handle) {
+ *handle=(void*)"Here it is";
+}
+char * handle(void* handle) {
+ return (char *)handle;
+}
+
+%}
diff --git a/Examples/test-suite/arrayptr.i b/Examples/test-suite/arrayptr.i
new file mode 100644
index 000000000..b7fe29af2
--- /dev/null
+++ b/Examples/test-suite/arrayptr.i
@@ -0,0 +1,12 @@
+// A module with a function that involves pointers to arrays
+
+%module arrayptr
+
+%inline %{
+
+void foo(int (*x)[10]) {
+
+}
+%}
+
+
diff --git a/Examples/test-suite/arrays.i b/Examples/test-suite/arrays.i
new file mode 100644
index 000000000..57912905d
--- /dev/null
+++ b/Examples/test-suite/arrays.i
@@ -0,0 +1,52 @@
+/*
+This test case tests that various types of arrays are working.
+*/
+
+%module arrays
+%pragma make_default
+
+%inline %{
+#define ARRAY_LEN 2
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+typedef struct {
+ char array_c [ARRAY_LEN];
+ signed char array_sc[ARRAY_LEN];
+ unsigned char array_uc[ARRAY_LEN];
+ short array_s [ARRAY_LEN];
+ unsigned short array_us[ARRAY_LEN];
+ int array_i [ARRAY_LEN];
+ unsigned int array_ui[ARRAY_LEN];
+ long array_l [ARRAY_LEN];
+ unsigned long array_ul[ARRAY_LEN];
+ long long array_ll[ARRAY_LEN];
+ float array_f [ARRAY_LEN];
+ double array_d [ARRAY_LEN];
+ SimpleStruct array_struct[ARRAY_LEN];
+ SimpleStruct* array_structpointers[ARRAY_LEN];
+ int* array_ipointers [ARRAY_LEN];
+ finger array_enum[ARRAY_LEN];
+ finger* array_enumpointers[ARRAY_LEN];
+ const int array_const_i[ARRAY_LEN];
+} ArrayStruct;
+
+void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN]) {}
+
+/* Pointer helper functions used in the Java run test */
+int* newintpointer() {
+ return (int*)malloc(sizeof(int));
+}
+void setintfrompointer(int* intptr, int value) {
+ *intptr = value;
+}
+int getintfrompointer(int* intptr) {
+ return *intptr;
+}
+
+%}
+
diff --git a/Examples/test-suite/arrays_global.i b/Examples/test-suite/arrays_global.i
new file mode 100644
index 000000000..c5140acc8
--- /dev/null
+++ b/Examples/test-suite/arrays_global.i
@@ -0,0 +1,37 @@
+/*
+This test case tests that various types of arrays are working.
+*/
+
+%module arrays_global
+%pragma make_default
+
+%inline %{
+#define ARRAY_LEN 2
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+char array_c [ARRAY_LEN];
+signed char array_sc[ARRAY_LEN];
+unsigned char array_uc[ARRAY_LEN];
+short array_s [ARRAY_LEN];
+unsigned short array_us[ARRAY_LEN];
+int array_i [ARRAY_LEN];
+unsigned int array_ui[ARRAY_LEN];
+long array_l [ARRAY_LEN];
+unsigned long array_ul[ARRAY_LEN];
+long long array_ll[ARRAY_LEN];
+float array_f [ARRAY_LEN];
+double array_d [ARRAY_LEN];
+SimpleStruct array_struct[ARRAY_LEN];
+SimpleStruct* array_structpointers[ARRAY_LEN];
+int* array_ipointers [ARRAY_LEN];
+finger array_enum[ARRAY_LEN];
+finger* array_enumpointers[ARRAY_LEN];
+const int array_const_i[ARRAY_LEN] = {10, 20};
+
+%}
+
diff --git a/Examples/test-suite/arrays_global_twodim.i b/Examples/test-suite/arrays_global_twodim.i
new file mode 100644
index 000000000..0cacceb3e
--- /dev/null
+++ b/Examples/test-suite/arrays_global_twodim.i
@@ -0,0 +1,42 @@
+/*
+Two dimension arrays
+*/
+
+%module arrays_global_twodim
+
+%inline %{
+#define ARRAY_LEN_X 2
+#define ARRAY_LEN_Y 4
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+char array_c [ARRAY_LEN_X][ARRAY_LEN_Y];
+signed char array_sc[ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned char array_uc[ARRAY_LEN_X][ARRAY_LEN_Y];
+short array_s [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y];
+int array_i [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned int array_ui[ARRAY_LEN_X][ARRAY_LEN_Y];
+long array_l [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned long array_ul[ARRAY_LEN_X][ARRAY_LEN_Y];
+long long array_ll[ARRAY_LEN_X][ARRAY_LEN_Y];
+float array_f [ARRAY_LEN_X][ARRAY_LEN_Y];
+double array_d [ARRAY_LEN_X][ARRAY_LEN_Y];
+SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y];
+SimpleStruct* array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
+int* array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y];
+finger array_enum[ARRAY_LEN_X][ARRAY_LEN_Y];
+finger* array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
+const int array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} };
+
+void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {}
+
+int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
+ return array[x][y];
+}
+%}
+
diff --git a/Examples/test-suite/arrays_scope.i b/Examples/test-suite/arrays_scope.i
new file mode 100644
index 000000000..164f7ec32
--- /dev/null
+++ b/Examples/test-suite/arrays_scope.i
@@ -0,0 +1,19 @@
+%module arrays_scope
+
+%inline %{
+
+enum { ASIZE = 256 };
+namespace foo {
+ enum { BSIZE = 512 };
+ class Bar {
+ public:
+ enum { CSIZE = 768 };
+ int adata[ASIZE];
+ int bdata[BSIZE];
+ int cdata[CSIZE];
+ void blah(int x[ASIZE], int y[BSIZE], int z[CSIZE]) { };
+ };
+}
+
+%}
+
diff --git a/Examples/test-suite/bool_default.i b/Examples/test-suite/bool_default.i
new file mode 100644
index 000000000..b04035c1a
--- /dev/null
+++ b/Examples/test-suite/bool_default.i
@@ -0,0 +1,9 @@
+// [ 548272] Default arguments
+%module bool_default
+
+%inline %{
+
+bool foo(bool x = true) {
+ return !x;
+}
+%}
diff --git a/Examples/test-suite/casts.i b/Examples/test-suite/casts.i
new file mode 100644
index 000000000..4893756f0
--- /dev/null
+++ b/Examples/test-suite/casts.i
@@ -0,0 +1,21 @@
+%module casts
+
+%inline %{
+
+class A {
+ public:
+ A() {}
+
+ void hello()
+ {
+ }
+};
+
+class B : public A
+{
+ public:
+ B() {}
+
+};
+
+%}
diff --git a/Examples/test-suite/char_constant.i b/Examples/test-suite/char_constant.i
new file mode 100644
index 000000000..bcbc0680d
--- /dev/null
+++ b/Examples/test-suite/char_constant.i
@@ -0,0 +1,11 @@
+/* This interface file tests whether character constants are correctly
+ wrapped as procedures returning Scheme characters (rather than
+ Scheme strings).
+*/
+
+%module char_constant
+
+#define CHAR_CONSTANT 'x'
+
+#define STRING_CONSTANT "xyzzy"
+
diff --git a/Examples/test-suite/class_ignore.i b/Examples/test-suite/class_ignore.i
new file mode 100644
index 000000000..4929fca68
--- /dev/null
+++ b/Examples/test-suite/class_ignore.i
@@ -0,0 +1,20 @@
+%module class_ignore
+
+%ignore Foo;
+
+%inline %{
+class Foo {
+public:
+ virtual char *blah() = 0;
+};
+
+class Bar : public Foo {
+public:
+ virtual char *blah() { return (char *) "Bar::blah"; }
+};
+
+char *do_blah(Foo *f) {
+ return f->blah();
+}
+%}
+
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
new file mode 100644
index 000000000..f2bf9b303
--- /dev/null
+++ b/Examples/test-suite/common.mk
@@ -0,0 +1,291 @@
+#######################################################################
+# $Header$
+#
+# SWIG test suite makefile.
+# The test suite comprises many different test cases, which have
+# typically produced bugs in the past. The aim is to have the test
+# cases compiling for every language modules. Some testcase have
+# a runtime test which is written in each of the module's language.
+#
+# This makefile runs SWIG on the testcases, compiles the c/c++ code
+# then builds the object code for use by the language.
+# To complete a test in a language follow these guidelines:
+# 1) Add testcases to CPP_TEST_CASES (c++) or C_TEST_CASES (c) or
+# MULTI_CPP_TEST_CASES (multi-module c++ tests)
+# 2) If not already done, create a makefile which:
+# a) Defines LANGUAGE matching a language rule in Examples/Makefile,
+# for example LANGUAGE = java
+# b) Define rules for %.ctest, %.cpptest, %.multicpptest and %.clean.
+#
+# The variables below can be overridden after including this makefile
+#######################################################################
+
+#######################################################################
+# Variables
+#######################################################################
+TOP = ../..
+SWIG = $(TOP)/../swig
+SWIG_LIB = $(TOP)/../Lib
+TEST_SUITE = test-suite
+CXXSRCS =
+CSRCS =
+TARGETPREFIX =
+TARGETSUFFIX =
+SWIGOPT = -I$(TOP)/$(TEST_SUITE)
+INCLUDES = -I$(TOP)/$(TEST_SUITE)
+RUNTIMEDIR = ../$(TOP)/Runtime/.libs
+DYNAMIC_LIB_PATH = $(RUNTIMEDIR):.
+
+# Please keep test cases in alphabetical order.
+#
+# EXCEPTION: PLEASE PUT BROKEN TEST CASES AT THE TOP OF THIS LIST.
+
+# C++ test cases. (Can be run individually using make testcase.cpptest.)
+
+CPP_TEST_BROKEN = \
+ abstract_typedef \
+ namespace_nested \
+ template_default_arg \
+ using_namespace
+
+CPP_TEST_CASES += $(CPP_TEST_BROKEN)
+
+CPP_TEST_CASES += \
+ abstract_inherit \
+ abstract_inherit_ok \
+ abstract_signature \
+ add_link \
+ anonymous_arg \
+ argout \
+ arrays_global \
+ arrays_global_twodim \
+ arrays_scope \
+ bool_default \
+ casts \
+ class_ignore \
+ const_const_2 \
+ constant_pointers \
+ constover \
+ constructor_exception \
+ constructor_explicit \
+ constructor_value \
+ conversion \
+ conversion_namespace \
+ conversion_ns_template \
+ cplusplus_throw \
+ cpp_enum \
+ cpp_enum_scope \
+ cpp_enum_scope \
+ cpp_namespace \
+ cpp_nodefault \
+ cpp_static \
+ cpp_typedef \
+ default_cast \
+ default_constructor \
+ default_ns \
+ default_ref \
+ dynamic_cast \
+ enum_scope \
+ enum_scope_template \
+ enum_var \
+ evil_diamond \
+ evil_diamond_ns \
+ evil_diamond_prop \
+ explicit \
+ extend_template \
+ extend_template_ns \
+ grouping \
+ ignore_parameter \
+ import_nomodule \
+ inherit_missing \
+ kind \
+ lib_carrays \
+ lib_cdata \
+ lib_cpointer \
+ lib_std_deque \
+ lib_std_string \
+ lib_std_vector \
+ lib_typemaps \
+ member_template \
+ minherit \
+ name_cxx \
+ name_inherit \
+ namespace_enum \
+ namespace_extend \
+ namespace_template \
+ namespace_typemap \
+ newobject1 \
+ overload_complicated \
+ overload_copy \
+ overload_extend \
+ overload_simple \
+ overload_subtype \
+ overload_template \
+ pointer_reference \
+ primitive_ref \
+ private_assign \
+ pure_virtual \
+ rename_default \
+ rename_default \
+ rename_scope \
+ return_value_scope \
+ rname \
+ smart_pointer_const \
+ smart_pointer_multi \
+ smart_pointer_multi_typedef \
+ smart_pointer_not \
+ smart_pointer_overload \
+ smart_pointer_protected \
+ smart_pointer_rename \
+ smart_pointer_simple \
+ smart_pointer_typedef \
+ static_array_member \
+ static_const_member \
+ static_const_member_2 \
+ struct_value \
+ template \
+ template_arg_scope \
+ template_arg_typename \
+ template_base_template \
+ template_classes \
+ template_const_ref \
+ template_construct \
+ template_default \
+ template_default2 \
+ template_default_inherit \
+ template_default_qualify \
+ template_enum \
+ template_enum_ns_inherit \
+ template_enum_typedef \
+ template_forward \
+ template_inherit \
+ template_inherit_abstract \
+ template_int_const \
+ template_ns \
+ template_ns2 \
+ template_ns3 \
+ template_ns4 \
+ template_ns_enum \
+ template_ns_enum2 \
+ template_ns_inherit \
+ template_ns_scope \
+ template_qualifier \
+ template_qualifier \
+ template_rename \
+ template_retvalue \
+ template_specialization \
+ template_static \
+ template_tbase_template \
+ template_type_namespace \
+ template_typedef \
+ template_typedef_cplx \
+ template_typedef_cplx2 \
+ template_typedef_cplx3 \
+ template_typedef_cplx4 \
+ template_virtual \
+ template_whitespace \
+ throw_exception \
+ typedef_array_member \
+ typedef_funcptr \
+ typedef_inherit \
+ typedef_mptr \
+ typedef_reference \
+ typedef_scope \
+ typemap_namespace \
+ typemap_ns_using \
+ typename \
+ union_scope \
+ using1 \
+ using2 \
+ using_composition \
+ using_extend \
+ using_inherit \
+ using_private \
+ using_protected \
+ valuewrapper_base \
+ virtual_destructor \
+ voidtest
+
+# C test cases. (Can be run individually using make testcase.ctest.)
+C_TEST_CASES += \
+ arrayptr \
+ arrays \
+ char_constant \
+ const_const \
+ defineop \
+ defines \
+ enum \
+ lib_carrays \
+ lib_cdata \
+ lib_cmalloc \
+ lib_constraints \
+ lib_cpointer \
+ lib_math \
+ long_long \
+ macro_2 \
+ name \
+ nested \
+ newobject2 \
+ overload_extendc \
+ preproc_1 \
+ preproc_2 \
+ preproc_3 \
+ ret_by_value \
+ sizeof_pointer \
+ sneaky1 \
+ typemap_subst \
+ unions
+
+
+MULTI_CPP_TEST_CASES += \
+ imports \
+ template_typedef_import
+
+ALL_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
+ $(C_TEST_CASES:=.ctest) \
+ $(MULTI_CPP_TEST_CASES:=.multicpptest)
+ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \
+ $(C_TEST_CASES:=.clean) \
+ $(MULTI_CPP_TEST_CASES:=.clean)
+
+#######################################################################
+# The following applies for all module languages
+#######################################################################
+all: $(ALL_TEST_CASES)
+
+check: all
+
+swig_and_compile_cpp = \
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS="$(CXXSRCS)" SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ $(LANGUAGE)$(VARIANT)_cpp
+
+swig_and_compile_c = \
+ $(MAKE) -f $(TOP)/Makefile CSRCS="$(CSRCS)" SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ $(LANGUAGE)$(VARIANT)
+
+swig_and_compile_multi_cpp = \
+ for f in `cat $(TOP)/$(TEST_SUITE)/$*.list` ; do \
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS="$(CXXSRCS)" SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" RUNTIMEDIR="$(RUNTIMEDIR)" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ NOLINK=true $(LANGUAGE)$(VARIANT)_multi_cpp; \
+ done
+
+setup = \
+ @if [ -f $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "Checking testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "Checking testcase $* under $(LANGUAGE)" ; \
+ fi;
+
+
+
+#######################################################################
+# Clean
+#######################################################################
+clean: $(ALL_CLEAN)
+
diff --git a/Examples/test-suite/const_const.i b/Examples/test-suite/const_const.i
new file mode 100644
index 000000000..7c1c92d22
--- /dev/null
+++ b/Examples/test-suite/const_const.i
@@ -0,0 +1,13 @@
+/* This interface file tests whether SWIG handles types like
+ "const int *const" right.
+
+ SWIG 1.3a5 signals a syntax error.
+*/
+
+%module const_const
+
+%typemap(in) const int *const { $1 = NULL; }
+
+%inline %{
+void foo(const int *const i) {}
+%}
diff --git a/Examples/test-suite/const_const_2.i b/Examples/test-suite/const_const_2.i
new file mode 100644
index 000000000..9094262a6
--- /dev/null
+++ b/Examples/test-suite/const_const_2.i
@@ -0,0 +1,21 @@
+/* This interface file tests whether SWIG handles doubly constant
+ methods right. SF Bug #216057 against Swig 1.3a5, reported by
+ Mike Romberg <romberg@users.sf.net>
+*/
+
+%module const_const_2
+
+%inline %{
+class Spam {
+public:
+ Spam() {}
+};
+
+class Eggs {
+ public:
+ Eggs() {}
+
+ const Spam *spam(void) const { return new Spam(); }
+};
+
+ %}
diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i
new file mode 100644
index 000000000..7edc6d4fd
--- /dev/null
+++ b/Examples/test-suite/constant_pointers.i
@@ -0,0 +1,74 @@
+/*
+This testcase primarily test constant pointers, eg int* const. Only a getter is expected to be produced when wrapping constant pointer variables. A number of other const issues are also tested.
+*/
+
+%module constant_pointers
+
+%inline %{
+
+int GlobalInt;
+const int ConstInt=2;
+int* GlobalIntPtr=&GlobalInt;
+int* const GlobalConstIntPtr=&GlobalInt;
+#define ARRAY_SIZE 2
+
+class ParametersTest {
+public:
+ void param1(int* a) {}
+ void param2(const int* a) {}
+ void param3(int* const a) {}
+ void param4(int const a) {}
+ void param5(const int a) {}
+ void param6(int& a) {}
+ void param7(const int& a) {}
+ void param8(int const& a) {}
+ void param9(int*& a) {}
+ void param10(int* const& a) {}
+ void param11(const int* const a) {}
+
+ void param_array1(int* a[ARRAY_SIZE]) {}
+ void param_array2(const int* a[ARRAY_SIZE]) {}
+ void param_array3(int* const a[ARRAY_SIZE]) {}
+ void param_array4(int const a[ARRAY_SIZE]) {}
+ void param_array5(const int a[ARRAY_SIZE]) {}
+ void param_array6(const int* const a[ARRAY_SIZE]) {}
+};
+
+class MemberVariablesTest {
+public:
+ int* member1;
+ ParametersTest* member2;
+ int* const member3;
+ ParametersTest* const member4;
+
+ int* array_member1[ARRAY_SIZE];
+ ParametersTest* array_member2[ARRAY_SIZE];
+ int* const array_member3[ARRAY_SIZE];
+ ParametersTest* const array_member4[ARRAY_SIZE];
+ MemberVariablesTest() : member3(NULL), member4(NULL) {}
+};
+void foo(const int *const i) {}
+
+typedef int *typedef1, typedef2, *const typedef3;
+int int1, int2=2, *int3, *const int4 = &GlobalInt;
+
+class ReturnValuesTest {
+public:
+ typedef1 td1;
+ typedef2 td2;
+ int int1, int2, *const int3, *int4, array1[ARRAY_SIZE], *const array2[ARRAY_SIZE];
+ int ret1() {return 5;}
+ const int ret2() {return 5;}
+ int ret3() {return 5;}
+ const int* ret4() {return &ConstInt;}
+ int* const ret5() {return &GlobalInt;}
+
+ void ret6(int*& a) {}
+ int*& ret7() {return GlobalIntPtr;}
+ ReturnValuesTest() : int3(NULL) {}
+};
+
+const int* globalRet1() {return &GlobalInt;};
+int* const globalRet2() {return &GlobalInt;};
+
+%}
diff --git a/Examples/test-suite/constover.i b/Examples/test-suite/constover.i
new file mode 100644
index 000000000..06f9ac7e2
--- /dev/null
+++ b/Examples/test-suite/constover.i
@@ -0,0 +1,38 @@
+// This test checks SWIG's code generation for C++ functions
+// and methods that differ only in constness.
+
+%module constover
+
+%rename(test_pconst) test(const char *);
+%rename(test_constm) test(char *) const;
+%rename(test_pconstm) test(const char *) const;
+
+%inline %{
+
+char *test(char *x) {
+ return (char *) "test";
+}
+
+char *test(const char *x) {
+ return (char *) "test_pconst";
+}
+
+ class Foo {
+ public:
+ Foo() { }
+ char *test(char *x) {
+ return (char *) "test";
+ }
+ char *test(const char *x) {
+ return (char *) "test_pconst";
+ }
+ char *test(char *x) const {
+ return (char *) "test_constmethod";
+ }
+ char *test(const char *x) const {
+ return (char *) "test_pconstmethod";
+ }
+ };
+
+%}
+
diff --git a/Examples/test-suite/constructor_exception.i b/Examples/test-suite/constructor_exception.i
new file mode 100644
index 000000000..9904e4e1e
--- /dev/null
+++ b/Examples/test-suite/constructor_exception.i
@@ -0,0 +1,27 @@
+%module constructor_exception
+
+%inline %{
+class Error {
+};
+
+class Object {
+public:
+ Object(int x) {
+ if (x < 0) {
+ throw Error();
+ }
+ }
+};
+
+class Test {
+ Object o;
+public:
+ Test(int x) try : o(x) { }
+ catch (Error &e) {
+ }
+ catch (int y) {
+ }
+ catch (...) {
+ }
+};
+%}
diff --git a/Examples/test-suite/constructor_explicit.i b/Examples/test-suite/constructor_explicit.i
new file mode 100644
index 000000000..f7fc534f2
--- /dev/null
+++ b/Examples/test-suite/constructor_explicit.i
@@ -0,0 +1,13 @@
+%module constructor_explicit
+%inline %{
+
+class Foo {
+public:
+ explicit Foo() { }
+};
+
+Foo test(Foo x) {
+ return x;
+}
+
+%}
diff --git a/Examples/test-suite/constructor_value.i b/Examples/test-suite/constructor_value.i
new file mode 100644
index 000000000..b5c56d031
--- /dev/null
+++ b/Examples/test-suite/constructor_value.i
@@ -0,0 +1,15 @@
+%module constructor_value
+%inline %{
+
+class Foo {
+public:
+Foo(int a) {};
+};
+
+class Bar {
+public:
+Bar(Foo ci) {}
+};
+
+%}
+
diff --git a/Examples/test-suite/conversion.i b/Examples/test-suite/conversion.i
new file mode 100644
index 000000000..bad6c147a
--- /dev/null
+++ b/Examples/test-suite/conversion.i
@@ -0,0 +1,11 @@
+%module conversion
+%rename(toFoo) Bar::operator Foo();
+
+%inline %{
+ struct Foo {
+ };
+ struct Bar {
+ operator Foo () { return Foo(); }
+ };
+%}
+
diff --git a/Examples/test-suite/conversion_namespace.i b/Examples/test-suite/conversion_namespace.i
new file mode 100644
index 000000000..70d4b9ebc
--- /dev/null
+++ b/Examples/test-suite/conversion_namespace.i
@@ -0,0 +1,14 @@
+%module conversion_namespace
+%rename(toFoo) oss::Bar::operator oss::Foo();
+
+%inline %{
+ namespace oss
+ {
+ struct Foo {
+ };
+ struct Bar {
+ operator Foo () { return Foo(); }
+ };
+ }
+%}
+
diff --git a/Examples/test-suite/conversion_ns_template.i b/Examples/test-suite/conversion_ns_template.i
new file mode 100644
index 000000000..34102f98f
--- /dev/null
+++ b/Examples/test-suite/conversion_ns_template.i
@@ -0,0 +1,49 @@
+%module conversion_ns_template
+%{
+ namespace oss
+ {
+ enum Test {One, Two};
+ template <Test>
+ struct Foo {
+ };
+ template <Test T>
+ struct Bar {
+ operator int() { return 0; }
+ operator int&() { static int num = 0; return num; }
+ operator Foo<T>() { return Foo<T>(); }
+ operator Foo<T>&() { return *(new Foo<T>()); }
+ };
+ }
+%}
+
+ namespace oss
+ {
+ enum Test {One, Two};
+
+ template <Test>
+ struct Foo {
+ };
+
+ // these two works
+ %rename(hello1) Bar<One>::operator int&();
+ %ignore Bar<One>::operator int();
+
+ // these don't
+ %rename(hello2) Bar<One>::operator Foo<oss::One>&();
+ %ignore Bar<One>::operator Foo<oss::One>();
+
+ template <Test T>
+ struct Bar {
+ operator int();
+ operator int&();
+ operator Foo<T>();
+ operator Foo<T>&();
+ };
+ }
+
+
+namespace oss
+{
+ %template(Foo_One) Foo<One>;
+ %template(Bar_One) Bar<One>;
+}
diff --git a/Examples/test-suite/cplusplus_throw.i b/Examples/test-suite/cplusplus_throw.i
new file mode 100644
index 000000000..268ddc6d0
--- /dev/null
+++ b/Examples/test-suite/cplusplus_throw.i
@@ -0,0 +1,22 @@
+/* This interface file checks whether the SWIG parses the throw
+ directive in combination with the const directive. Bug reported by
+ Scott B. Drummonds, 08 June 2001.
+*/
+
+%module cplusplus_throw
+
+%pragma no_default
+
+%inline %{
+
+class Foo { };
+
+class Bar {
+public:
+ void baz() const { };
+ void foo() throw (Foo) { };
+ void bazfoo() const throw (int) { };
+};
+
+%}
+
diff --git a/Examples/test-suite/cpp_enum.i b/Examples/test-suite/cpp_enum.i
new file mode 100644
index 000000000..a66cda1c8
--- /dev/null
+++ b/Examples/test-suite/cpp_enum.i
@@ -0,0 +1,27 @@
+/*
+The primary purpose of this testcase is to ensure that enums used along with the 'enum' keyword compile under c++.
+*/
+
+%module cpp_enum
+
+%inline %{
+
+enum SOME_ENUM {ENUM_ONE, ENUM_TWO};
+
+struct StructWithEnums {
+ StructWithEnums() : some_enum(ENUM_ONE) {};
+ enum SOME_ENUM some_enum;
+ void enum_test1(enum SOME_ENUM param1, enum SOME_ENUM* param2, enum SOME_ENUM& param3) {};
+ void enum_test2(SOME_ENUM param1, SOME_ENUM* param2, SOME_ENUM& param3) {};
+
+ SOME_ENUM enum_test3() { return ENUM_ONE; };
+ enum SOME_ENUM enum_test4() { return ENUM_TWO; };
+
+ SOME_ENUM* enum_test5() { return &some_enum; };
+ enum SOME_ENUM* enum_test6() { return &some_enum; };
+
+ SOME_ENUM& enum_test7() { return some_enum; };
+ enum SOME_ENUM& enum_test8() { return some_enum; };
+};
+
+%}
diff --git a/Examples/test-suite/cpp_enum_scope.i b/Examples/test-suite/cpp_enum_scope.i
new file mode 100644
index 000000000..af3c96b70
--- /dev/null
+++ b/Examples/test-suite/cpp_enum_scope.i
@@ -0,0 +1,17 @@
+%module cpp_enum_scope
+
+// This tests to make sure default arguments are handled correctly
+// when scoped.
+
+%inline %{
+enum flavor { BITTER, SWEET };
+
+class Foo {
+public:
+ enum speed { FAST, SLOW };
+
+ // Note: default values should be Foo::FAST and SWEET
+ void blah(speed s = FAST, flavor f = SWEET) {};
+};
+
+%}
diff --git a/Examples/test-suite/cpp_namespace.i b/Examples/test-suite/cpp_namespace.i
new file mode 100644
index 000000000..39e506fe3
--- /dev/null
+++ b/Examples/test-suite/cpp_namespace.i
@@ -0,0 +1,104 @@
+// C++ namespace tests
+
+%module cpp_namespace
+
+%inline %{
+ typedef int Bad;
+
+ /* A very basic namespace */
+ namespace example {
+ typedef char *Bad;
+
+ int fact(int n) {
+ if (n <= 0) return 1;
+ else return n*fact(n-1);
+ }
+ int Foo = 42;
+
+ class Test {
+ public:
+ Test() { };
+ ~Test() { };
+ char *method() {
+ return (char *) "Test::method";
+ }
+ };
+ typedef Test *TestPtr;
+ void weird(Bad x, ::Bad y) { };
+ }
+
+ char *do_method(example::TestPtr t) {
+ return t->method();
+ }
+
+ namespace ex = example;
+
+ char *do_method2(ex::TestPtr t) {
+ return t->method();
+ }
+
+%}
+
+// Some more complicated namespace examples
+
+%inline %{
+namespace Foo {
+ typedef int Integer;
+ class Test2 {
+ public:
+ virtual char *method() {
+ return (char *) "Test2::method";
+ }
+ };
+ typedef Test2 *Test2Ptr;
+}
+
+namespace Foo2 {
+ using Foo::Integer;
+ using Foo::Test2;
+ class Test3 : public Test2 {
+ public:
+ virtual char *method() {
+ return (char *) "Test3::method";
+ }
+ };
+ typedef Test3 *Test3Ptr;
+ typedef Test3 Test3Alt;
+}
+
+namespace Foo3 {
+ using namespace Foo2;
+ class Test4 : public Test3 {
+ public:
+ virtual char *method() {
+ return (char *) "Test4::method";
+ }
+ };
+ Integer foo3(Integer x) { return x; }
+ typedef Test4 *Test4Ptr;
+
+}
+
+using Foo2::Test3Alt;
+using Foo3::Integer;
+
+class Test5 : public Test3Alt {
+public:
+ virtual char *method() {
+ return (char *) "Test5::method";
+ }
+};
+
+char *do_method3(Foo::Test2 *t, Integer x) {
+ return t->method();
+}
+
+%}
+
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/cpp_nodefault.i b/Examples/test-suite/cpp_nodefault.i
new file mode 100644
index 000000000..fc2703618
--- /dev/null
+++ b/Examples/test-suite/cpp_nodefault.i
@@ -0,0 +1,42 @@
+// This file tests SWIG pass/return by value for
+// a class with no default constructor
+
+%module cpp_nodefault
+
+%inline %{
+
+class Foo {
+public:
+ int a;
+ Foo(int x, int y) { }
+ ~Foo() {
+ printf("Destroying foo\n");
+ }
+};
+
+Foo create(int x, int y) {
+ return Foo(x,y);
+}
+
+typedef Foo Foo_t;
+
+void consume(Foo f, Foo_t g) {}
+
+class Bar {
+public:
+ void consume(Foo f, Foo_t g) {}
+ Foo create(int x, int y) {
+ return Foo(x,y);
+ }
+};
+
+
+%}
+
+%{
+Foo gvar = Foo(3,4);
+%}
+
+Foo gvar;
+
+
diff --git a/Examples/test-suite/cpp_static.i b/Examples/test-suite/cpp_static.i
new file mode 100644
index 000000000..5009cf528
--- /dev/null
+++ b/Examples/test-suite/cpp_static.i
@@ -0,0 +1,24 @@
+/*
+Testcase to test c++ static member variables and static functions.
+Tests Sourceforge bug #444748.
+*/
+
+%module cpp_static
+
+%inline %{
+
+class StaticMemberTest {
+public:
+ static int static_int;
+};
+
+class StaticFunctionTest {
+public:
+ static void static_func() {};
+};
+
+%}
+
+%{
+int StaticMemberTest::static_int;
+%}
diff --git a/Examples/test-suite/cpp_typedef.i b/Examples/test-suite/cpp_typedef.i
new file mode 100644
index 000000000..f869f4d9c
--- /dev/null
+++ b/Examples/test-suite/cpp_typedef.i
@@ -0,0 +1,46 @@
+// This file tests SWIG's tracking of C++ typedef declarations
+
+%module cpp_typedef
+
+%{
+
+class Bar {
+public:
+};
+%}
+
+%inline %{
+class Foo {
+public:
+ typedef Bar SomeBar;
+ typedef SomeBar SomeOtherBar;
+ SomeOtherBar bar() {
+ SomeOtherBar b;
+ return b;
+ }
+ static SomeOtherBar sbar() {
+ SomeOtherBar b;
+ return b;
+ }
+};
+
+// Test that the correct types are used for typedef struct declarations
+typedef struct {
+} UnnamedStruct;
+
+typedef struct NamedStruct {
+} TypedefNamedStruct;
+
+typedef TypedefNamedStruct DoubleTypedef;
+
+class Test {
+public:
+ UnnamedStruct test1(UnnamedStruct a) {return a;};
+ struct NamedStruct test2(struct NamedStruct a) {return a;};
+ TypedefNamedStruct test3(TypedefNamedStruct a) {return a;};
+ DoubleTypedef test4(DoubleTypedef a) {return a;};
+};
+
+%}
+
+
diff --git a/Examples/test-suite/default_cast.i b/Examples/test-suite/default_cast.i
new file mode 100644
index 000000000..661e8bc7f
--- /dev/null
+++ b/Examples/test-suite/default_cast.i
@@ -0,0 +1,6 @@
+%module default_cast
+
+%inline %{
+void foo(const char *m = (const char *) NULL) { };
+%}
+
diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i
new file mode 100644
index 000000000..3d9fe8bed
--- /dev/null
+++ b/Examples/test-suite/default_constructor.i
@@ -0,0 +1,109 @@
+// This module tests default constructor generation under a
+// number of different conditions
+
+%module default_constructor
+
+%warnfilter(802, 813) EB; /* Ruby, Java multiple inheritance */
+%warnfilter(802, 813) AD; /* Ruby, Java multiple inheritance */
+%warnfilter(510) F; /* friend function */
+
+%inline %{
+
+/* A class with a public default constructor */
+class A {
+public:
+ A() { };
+};
+
+/* This class should get default constructor/destructors */
+class AA : public A {
+};
+
+/* A class with a public constructor, but not default */
+
+class B {
+private:
+ B() { }
+public:
+ B(int x, int y) { }
+};
+
+/* This class should get no default constructor, but a destructor */
+class BB : public B {
+};
+
+/* A class with a protected constructor */
+class C {
+protected:
+ C() { };
+public:
+};
+
+/* This class does get a default constructor/destructor */
+class CC : public C {
+};
+
+
+/* A class with a private constructor */
+class D {
+private:
+ D() { };
+public:
+ void foo() { };
+};
+
+/* This class does not get a default constructor */
+class DD: public D {
+
+};
+
+/* No default constructor. A is okay, but D is not */
+class AD: public A, public D {
+
+};
+
+/* This class has a default constructor because of optional arguments */
+class E {
+public:
+ E(int x = 0, int y = 0) { }
+};
+
+/* This should get a default constructor */
+class EE : public E {
+};
+
+/* This class should not get a default constructor. B doesn't have one */
+
+class EB : public E, public B {
+
+};
+
+/* A class with a private destructor */
+
+class F {
+private:
+ ~F() { }
+public:
+ void foo(int, int) { }
+ friend void bar(F *);
+};
+
+void bar(F *) { }
+
+class FFF : public F {
+};
+
+/* A class with a protected destructor */
+class G {
+protected:
+ ~G() { }
+};
+
+class GG : public G {
+};
+
+%}
+
+
+
+
diff --git a/Examples/test-suite/default_ns.i b/Examples/test-suite/default_ns.i
new file mode 100644
index 000000000..3b03d9515
--- /dev/null
+++ b/Examples/test-suite/default_ns.i
@@ -0,0 +1,23 @@
+%module default_ns
+%inline %{
+namespace AType
+{
+ enum AType
+ {
+ NoType
+ };
+}
+
+void dummy(AType::AType aType = AType::NoType) {}
+
+
+namespace A {
+ namespace B {
+ int CONST_NUM = 10;
+ }
+ int function(int i = B::CONST_NUM) { return 0; }
+}
+
+%}
+
+
diff --git a/Examples/test-suite/default_ref.i b/Examples/test-suite/default_ref.i
new file mode 100644
index 000000000..25d20cd69
--- /dev/null
+++ b/Examples/test-suite/default_ref.i
@@ -0,0 +1,12 @@
+%module default_ref
+
+%inline %{
+#include <string>
+
+void test1(const int &x = 42) {
+}
+
+void test2(const std::string &x = "hello") {
+}
+%}
+
diff --git a/Examples/test-suite/defineop.i b/Examples/test-suite/defineop.i
new file mode 100644
index 000000000..d11ff3026
--- /dev/null
+++ b/Examples/test-suite/defineop.i
@@ -0,0 +1,22 @@
+/*
+This testcase tests operators for defines
+*/
+
+%module defineop
+
+#define A1 1 + 2
+#define A2 3 - 4
+#define A3 5 * 6
+#define A4 7 / 8
+#define A5 9 >> 10
+#define A6 11 << 12
+#define A7 13 & 14
+#define A8 15 | 16
+#define A9 17 ^ 18
+#define A10 19 && 20
+#define A11 21 || 21
+#define A12 ~22
+#define A13 !23
+
+
+
diff --git a/Examples/test-suite/defines.i b/Examples/test-suite/defines.i
new file mode 100644
index 000000000..70a1db6df
--- /dev/null
+++ b/Examples/test-suite/defines.i
@@ -0,0 +1,18 @@
+/*
+This testcase tests for embedded defines and embedded %constants
+*/
+
+%module defines
+%pragma make_default
+
+%inline %{
+
+typedef struct EmbeddedDefines {
+ int dummy;
+#define EMBEDDED_DEFINE 44
+#ifdef SWIG
+%constant EMBEDDED_SWIG_CONSTANT = 55;
+#endif
+} EmbeddedDefines;
+
+%}
diff --git a/Examples/test-suite/dynamic_cast.i b/Examples/test-suite/dynamic_cast.i
new file mode 100644
index 000000000..bae28f3cf
--- /dev/null
+++ b/Examples/test-suite/dynamic_cast.i
@@ -0,0 +1,65 @@
+/* File : example.i */
+%module dynamic_cast
+
+#ifndef SWIGJAVA
+%apply SWIGTYPE *DYNAMIC { Foo * };
+#endif
+
+%inline %{
+
+class Foo {
+public:
+ virtual Foo *blah() {
+ return this;
+ }
+};
+%}
+
+#ifdef SWIGJAVA
+%typemap(out) Foo *blah {
+ Bar *downcast = dynamic_cast<Bar *>($1);
+ *(Bar **)&$result = downcast;
+}
+
+%typemap(javaout) Foo * {
+ return new Bar($jnicall, $owner);
+ }
+#endif
+
+%inline %{
+
+class Bar : public Foo {
+public:
+ virtual Foo *blah() {
+ return (Foo *) this;
+ }
+ virtual char * test() {
+ return (char *) "Bar::test";
+ }
+};
+
+char *do_test(Bar *b) {
+ return b->test();
+}
+%}
+
+#ifndef SWIGJAVA
+// A general purpose function for dynamic casting of a Foo *
+%{
+static swig_type_info *
+Foo_dynamic(void **ptr) {
+ Bar *b;
+ b = dynamic_cast<Bar *>((Foo *) *ptr);
+ if (b) {
+ *ptr = (void *) b;
+ return SWIGTYPE_p_Bar;
+ }
+ return 0;
+}
+%}
+
+// Register the above casting function
+DYNAMIC_CAST(SWIGTYPE_p_Foo, Foo_dynamic);
+
+#endif
+
diff --git a/Examples/test-suite/enum.i b/Examples/test-suite/enum.i
new file mode 100644
index 000000000..bcd606c58
--- /dev/null
+++ b/Examples/test-suite/enum.i
@@ -0,0 +1,26 @@
+/* Test whether anonymous enums are supported well. */
+
+%module "enum"
+
+%inline %{
+
+typedef enum {
+ CSP_ITERATION_FWD,
+ CSP_ITERATION_BWD
+} foo1;
+
+typedef enum foo2 {
+ ABCDE = 0,
+ FGHJI = 1
+} foo3;
+
+void
+bar1(foo1 x) {}
+
+void
+bar2(enum foo2 x) {}
+
+void
+bar3(foo3 x) {}
+
+%}
diff --git a/Examples/test-suite/enum_scope.i b/Examples/test-suite/enum_scope.i
new file mode 100644
index 000000000..4afc231c6
--- /dev/null
+++ b/Examples/test-suite/enum_scope.i
@@ -0,0 +1,16 @@
+%module enum_scope
+
+#ifdef SWIGPHP
+// php internal naming conflict
+%rename (chops) chop;
+#endif
+
+%inline %{
+class Tree {
+public:
+enum types {Oak, Fir, Cedar};
+void chop(enum types type) {}
+};
+enum Tree::types chop(enum Tree::types type) { return type; }
+
+%}
diff --git a/Examples/test-suite/enum_scope_template.i b/Examples/test-suite/enum_scope_template.i
new file mode 100644
index 000000000..b6b156bd7
--- /dev/null
+++ b/Examples/test-suite/enum_scope_template.i
@@ -0,0 +1,20 @@
+%module enum_scope_template
+
+#ifdef SWIGPHP
+// php internal naming conflict
+%rename (chops) chop;
+#endif
+
+%inline %{
+
+template<class T> class Tree {
+public:
+ enum types {Oak, Fir, Cedar};
+ void chop(enum types type) {}
+};
+enum Tree<int>::types chop(enum Tree<int>::types type) { return type; }
+
+%}
+
+%template(TreeInt) Tree<int>;
+
diff --git a/Examples/test-suite/enum_var.i b/Examples/test-suite/enum_var.i
new file mode 100644
index 000000000..c8626d803
--- /dev/null
+++ b/Examples/test-suite/enum_var.i
@@ -0,0 +1,8 @@
+%module enum_var
+
+%inline %{
+
+enum Fruit { APPLE, PEAR };
+Fruit test;
+
+%}
diff --git a/Examples/test-suite/errors/c_bad_name.i b/Examples/test-suite/errors/c_bad_name.i
new file mode 100644
index 000000000..43ccb4d18
--- /dev/null
+++ b/Examples/test-suite/errors/c_bad_name.i
@@ -0,0 +1,4 @@
+%module xxx
+
+%name() int foo;
+
diff --git a/Examples/test-suite/errors/c_bad_native.i b/Examples/test-suite/errors/c_bad_native.i
new file mode 100644
index 000000000..4d09e04b0
--- /dev/null
+++ b/Examples/test-suite/errors/c_bad_native.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%native(foo) int foo;
+
+
diff --git a/Examples/test-suite/errors/c_class.i b/Examples/test-suite/errors/c_class.i
new file mode 100644
index 000000000..cd168f67b
--- /dev/null
+++ b/Examples/test-suite/errors/c_class.i
@@ -0,0 +1,8 @@
+%module xxx
+
+int class(int x);
+
+
+
+
+
diff --git a/Examples/test-suite/errors/c_default_error.i b/Examples/test-suite/errors/c_default_error.i
new file mode 100644
index 000000000..f6220e11d
--- /dev/null
+++ b/Examples/test-suite/errors/c_default_error.i
@@ -0,0 +1,4 @@
+%module xxx
+
+int foo(int x = 42 || 3);
+
diff --git a/Examples/test-suite/errors/c_deprecated.i b/Examples/test-suite/errors/c_deprecated.i
new file mode 100644
index 000000000..27e74397f
--- /dev/null
+++ b/Examples/test-suite/errors/c_deprecated.i
@@ -0,0 +1,8 @@
+%module xxx
+
+int foo(%val int *x, %out int *y);
+
+
+
+
+
diff --git a/Examples/test-suite/errors/c_empty_char.i b/Examples/test-suite/errors/c_empty_char.i
new file mode 100644
index 000000000..0a669af86
--- /dev/null
+++ b/Examples/test-suite/errors/c_empty_char.i
@@ -0,0 +1,4 @@
+%module xxx
+
+int foo(int x = '');
+
diff --git a/Examples/test-suite/errors/c_enum_badvalue.i b/Examples/test-suite/errors/c_enum_badvalue.i
new file mode 100644
index 000000000..8649c03e0
--- /dev/null
+++ b/Examples/test-suite/errors/c_enum_badvalue.i
@@ -0,0 +1,7 @@
+%module xxx
+
+enum stuff {
+ FOO = 'x',
+ BAR = 3.14159
+};
+
diff --git a/Examples/test-suite/errors/c_extra_rblock.i b/Examples/test-suite/errors/c_extra_rblock.i
new file mode 100644
index 000000000..3e8e86a19
--- /dev/null
+++ b/Examples/test-suite/errors/c_extra_rblock.i
@@ -0,0 +1,8 @@
+%module xxx
+
+int foo(int x);
+
+%}
+
+
+
diff --git a/Examples/test-suite/errors/c_extra_rbrace.i b/Examples/test-suite/errors/c_extra_rbrace.i
new file mode 100644
index 000000000..0228f9b1d
--- /dev/null
+++ b/Examples/test-suite/errors/c_extra_rbrace.i
@@ -0,0 +1,7 @@
+%module xxx
+
+int foo(int);
+
+}
+
+
diff --git a/Examples/test-suite/errors/c_extra_unsigned.i b/Examples/test-suite/errors/c_extra_unsigned.i
new file mode 100644
index 000000000..f5728cf0c
--- /dev/null
+++ b/Examples/test-suite/errors/c_extra_unsigned.i
@@ -0,0 +1,6 @@
+%module xxx
+
+int foo(unsigned unsigned int x);
+int bar(signed signed y);
+int spam(unsigned signed int x);
+
diff --git a/Examples/test-suite/errors/c_insert_missing.i b/Examples/test-suite/errors/c_insert_missing.i
new file mode 100644
index 000000000..35755ccd8
--- /dev/null
+++ b/Examples/test-suite/errors/c_insert_missing.i
@@ -0,0 +1,3 @@
+%module xxx
+
+%insert("header") "missing_file.i";
diff --git a/Examples/test-suite/errors/c_long_short.i b/Examples/test-suite/errors/c_long_short.i
new file mode 100644
index 000000000..f05831a8f
--- /dev/null
+++ b/Examples/test-suite/errors/c_long_short.i
@@ -0,0 +1,6 @@
+%module xxx
+
+int foo(long short x);
+int bar(short long y);
+int spam(long long long x);
+int grok(short short int x);
diff --git a/Examples/test-suite/errors/c_missing_rbrace.i b/Examples/test-suite/errors/c_missing_rbrace.i
new file mode 100644
index 000000000..381d5008d
--- /dev/null
+++ b/Examples/test-suite/errors/c_missing_rbrace.i
@@ -0,0 +1,10 @@
+%module xxx
+
+int foo(int x) {
+ int y;
+
+
+
+
+
+
diff --git a/Examples/test-suite/errors/c_missing_semi.i b/Examples/test-suite/errors/c_missing_semi.i
new file mode 100644
index 000000000..fc20e1db1
--- /dev/null
+++ b/Examples/test-suite/errors/c_missing_semi.i
@@ -0,0 +1,4 @@
+%module xxx
+int foo(int)
+int bar(int,int);
+
diff --git a/Examples/test-suite/errors/c_redefine.i b/Examples/test-suite/errors/c_redefine.i
new file mode 100644
index 000000000..818d70722
--- /dev/null
+++ b/Examples/test-suite/errors/c_redefine.i
@@ -0,0 +1,20 @@
+%module xxx
+
+int foo(int x, int y);
+int foo;
+
+int bar(int x);
+
+struct bar {
+ int y;
+};
+
+%rename(bar) spam;
+
+int spam(int);
+
+
+
+
+
+
diff --git a/Examples/test-suite/errors/c_varargs.i b/Examples/test-suite/errors/c_varargs.i
new file mode 100644
index 000000000..88f9c2e7d
--- /dev/null
+++ b/Examples/test-suite/errors/c_varargs.i
@@ -0,0 +1,3 @@
+%module xxx
+
+int foo(int x, ...);
diff --git a/Examples/test-suite/errors/c_varargs_neg.i b/Examples/test-suite/errors/c_varargs_neg.i
new file mode 100644
index 000000000..a88d8b712
--- /dev/null
+++ b/Examples/test-suite/errors/c_varargs_neg.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%varargs(0,int x = 0) foo;
+int foo(int x, ...);
+
+
+
diff --git a/Examples/test-suite/errors/cpp_bad_extern.i b/Examples/test-suite/errors/cpp_bad_extern.i
new file mode 100644
index 000000000..b6895a536
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_bad_extern.i
@@ -0,0 +1,7 @@
+%module xxx
+
+extern "INTERCAL" {
+ int foo(int);
+};
+
+extern "INTERCAL" int blah(int);
diff --git a/Examples/test-suite/errors/cpp_extend_redefine.i b/Examples/test-suite/errors/cpp_extend_redefine.i
new file mode 100644
index 000000000..dfe8fe48a
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_extend_redefine.i
@@ -0,0 +1,23 @@
+%module xxx
+
+%extend foo {
+ int bar() {
+ }
+};
+
+struct foo {
+ int bar();
+ int spam();
+};
+
+%extend foo {
+ int spam();
+};
+
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_extend_undefined.i b/Examples/test-suite/errors/cpp_extend_undefined.i
new file mode 100644
index 000000000..808a74878
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_extend_undefined.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%extend foo {
+ int bar() {
+ }
+};
diff --git a/Examples/test-suite/errors/cpp_inline_namespace.i b/Examples/test-suite/errors/cpp_inline_namespace.i
new file mode 100644
index 000000000..d92746ae0
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inline_namespace.i
@@ -0,0 +1,7 @@
+%module xxx
+
+namespace foo {
+%inline %{
+int bar(int x) { }
+%}
+}
diff --git a/Examples/test-suite/errors/cpp_missing_rtemplate.i b/Examples/test-suite/errors/cpp_missing_rtemplate.i
new file mode 100644
index 000000000..2d87eecf1
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_missing_rtemplate.i
@@ -0,0 +1,11 @@
+%module xxx
+
+
+int foo(vector<int);
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_namespace_alias.i b/Examples/test-suite/errors/cpp_namespace_alias.i
new file mode 100644
index 000000000..1e45972e6
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_namespace_alias.i
@@ -0,0 +1,14 @@
+%module xxx
+
+namespace blah {
+}
+
+namespace B = blah;
+
+namespace B {
+}
+
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_namespace_aliasnot.i b/Examples/test-suite/errors/cpp_namespace_aliasnot.i
new file mode 100644
index 000000000..c52f8c1f9
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_namespace_aliasnot.i
@@ -0,0 +1,4 @@
+%module xxx
+
+int blah;
+namespace B = blah;
diff --git a/Examples/test-suite/errors/cpp_namespace_aliasundef.i b/Examples/test-suite/errors/cpp_namespace_aliasundef.i
new file mode 100644
index 000000000..25b5b7f57
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_namespace_aliasundef.i
@@ -0,0 +1,3 @@
+%module xxx
+
+namespace B = blah;
diff --git a/Examples/test-suite/errors/cpp_nested.i b/Examples/test-suite/errors/cpp_nested.i
new file mode 100644
index 000000000..625812e7d
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_nested.i
@@ -0,0 +1,13 @@
+%module xxx
+
+class Foo {
+public:
+ class Bar {
+ };
+};
+
+class Spam {
+public:
+ class Grok {
+ } x;
+};
diff --git a/Examples/test-suite/errors/cpp_no_access.i b/Examples/test-suite/errors/cpp_no_access.i
new file mode 100644
index 000000000..e04ad9d55
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_no_access.i
@@ -0,0 +1,4 @@
+%module xxx
+
+class Bar : foo {
+};
diff --git a/Examples/test-suite/errors/cpp_nobase.i b/Examples/test-suite/errors/cpp_nobase.i
new file mode 100644
index 000000000..70e6d684c
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_nobase.i
@@ -0,0 +1,7 @@
+%module xxx
+
+class Foo : public Bar {
+};
+
+class Spam : public Bar<int> {
+};
diff --git a/Examples/test-suite/errors/cpp_overload.i b/Examples/test-suite/errors/cpp_overload.i
new file mode 100644
index 000000000..34fa3cc25
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_overload.i
@@ -0,0 +1,15 @@
+%module xxx
+int foo(int x);
+int foo(double x);
+
+class Foo {
+public:
+ int bar(int);
+ int bar(double);
+};
+
+class Spam {
+public:
+ Spam();
+ Spam(int);
+};
diff --git a/Examples/test-suite/errors/cpp_private_defvalue.i b/Examples/test-suite/errors/cpp_private_defvalue.i
new file mode 100644
index 000000000..15542c7bc
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_private_defvalue.i
@@ -0,0 +1,7 @@
+%module xxx
+
+class foo {
+static const int BAR = 42;
+public:
+ int blah(int x = BAR);
+};
diff --git a/Examples/test-suite/errors/cpp_private_inherit.i b/Examples/test-suite/errors/cpp_private_inherit.i
new file mode 100644
index 000000000..e8267e98f
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_private_inherit.i
@@ -0,0 +1,11 @@
+%module xxx
+
+class Foo {
+};
+
+class Bar : private Foo {
+};
+
+class Spam : protected Foo {
+};
+
diff --git a/Examples/test-suite/errors/cpp_template_argname.i b/Examples/test-suite/errors/cpp_template_argname.i
new file mode 100644
index 000000000..b87c115c1
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_argname.i
@@ -0,0 +1,8 @@
+%module xxx
+
+template<T> T blah(T x);
+
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_template_nargs.i b/Examples/test-suite/errors/cpp_template_nargs.i
new file mode 100644
index 000000000..1a4fbdc20
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_nargs.i
@@ -0,0 +1,10 @@
+%module xxx
+
+template<typename T> T blah(T x) { };
+
+%template(blahi) blah<int,double>;
+%template(blahf) blah<>;
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_template_not.i b/Examples/test-suite/errors/cpp_template_not.i
new file mode 100644
index 000000000..c8df700b5
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_not.i
@@ -0,0 +1,9 @@
+%module xxx
+
+int blah;
+
+%template(blahi) blah<int>;
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_template_partial.i b/Examples/test-suite/errors/cpp_template_partial.i
new file mode 100644
index 000000000..04ae9055e
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_partial.i
@@ -0,0 +1,4 @@
+%module xxx
+
+template<class T> class vector<T *> {
+};
diff --git a/Examples/test-suite/errors/cpp_template_repeat.i b/Examples/test-suite/errors/cpp_template_repeat.i
new file mode 100644
index 000000000..e63ffe8d9
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_repeat.i
@@ -0,0 +1,7 @@
+%module xxx
+
+template<class T> T blah(T x) { };
+
+%template(iblah) blah<int>;
+%template(iiblah) blah<int>;
+
diff --git a/Examples/test-suite/errors/cpp_template_undef.i b/Examples/test-suite/errors/cpp_template_undef.i
new file mode 100644
index 000000000..2c0afbecc
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_undef.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%template(blahi) blah<int>;
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_using_not.i b/Examples/test-suite/errors/cpp_using_not.i
new file mode 100644
index 000000000..2d5b6bf61
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_not.i
@@ -0,0 +1,9 @@
+%module xxx
+
+int blah;
+using namespace blah;
+
+
+
+
+
diff --git a/Examples/test-suite/errors/cpp_using_undef.i b/Examples/test-suite/errors/cpp_using_undef.i
new file mode 100644
index 000000000..bc0c8c797
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_undef.i
@@ -0,0 +1,9 @@
+%module xxx
+
+using foo::bar;
+using namespace foo;
+
+
+
+
+
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
new file mode 100755
index 000000000..0c9bd443e
--- /dev/null
+++ b/Examples/test-suite/errors/make.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+echo "---------------------------------------"
+echo "Testing SWIG error and warning messages"
+echo "---------------------------------------"
+
+SWIG='../../../swig -I../../../Lib'
+
+# Files run in C mode
+CFILES='
+c_bad_name
+c_bad_native
+c_class
+c_default_error
+c_deprecated
+c_empty_char
+c_enum_badvalue
+c_extra_rblock
+c_extra_rbrace
+c_extra_unsigned
+c_insert_missing
+c_long_short
+c_missing_rbrace
+c_missing_semi
+c_redefine
+c_varargs
+c_varargs_neg
+nomodule
+pp_badeval
+pp_defined
+pp_macro_args
+pp_macro_badchar
+pp_macro_nargs
+pp_macro_redef
+pp_macro_rparen
+pp_macro_unterminated
+pp_misplaced_elif
+pp_misplaced_else
+pp_missing_enddef
+pp_missing_endif
+pp_missing_file
+pp_missing_rblock
+pp_unterm_char
+pp_unterm_comment
+pp_unterm_string
+swig_apply_nargs
+swig_identifier
+swig_insert_bad
+swig_typemap_copy
+swig_typemap_old
+'
+
+# Files run in C++ mode
+CPPFILES='
+cpp_bad_extern
+cpp_extend_redefine
+cpp_extend_undefined
+cpp_inline_namespace
+cpp_missing_rtemplate
+cpp_namespace_alias
+cpp_namespace_aliasnot
+cpp_namespace_aliasundef
+cpp_nested
+cpp_no_access
+cpp_nobase
+cpp_overload
+cpp_private_defvalue
+cpp_private_inherit
+cpp_template_argname
+cpp_template_nargs
+cpp_template_not
+cpp_template_partial
+cpp_template_repeat
+cpp_template_undef
+cpp_using_not
+cpp_using_undef
+'
+
+LOGFILE='test.log'
+SWIGOPT=$*
+
+rm -f ${LOGFILE}
+
+echo "SWIG error and warning test. opts=${SWIGOPT}" >> ${LOGFILE}
+echo "-----------------------------------------------------------" >> ${LOGFILE}
+
+for i in ${CFILES}; do
+ echo " Testing : ${i}.i";
+ echo "" >> ${LOGFILE};
+ echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
+ ${SWIG} -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+done
+
+for i in ${CPPFILES}; do
+ echo " Testing : ${i}.i";
+ echo "" >> ${LOGFILE}
+ echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
+ ${SWIG} -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+done
+
+echo ""
+echo "Results written to '${LOGFILE}'"
+
+
diff --git a/Examples/test-suite/errors/nomodule.i b/Examples/test-suite/errors/nomodule.i
new file mode 100644
index 000000000..6341be3fd
--- /dev/null
+++ b/Examples/test-suite/errors/nomodule.i
@@ -0,0 +1,2 @@
+/* No module name */
+int foo(int);
diff --git a/Examples/test-suite/errors/pp_badeval.i b/Examples/test-suite/errors/pp_badeval.i
new file mode 100644
index 000000000..aca397c7c
--- /dev/null
+++ b/Examples/test-suite/errors/pp_badeval.i
@@ -0,0 +1,11 @@
+%module xxx
+
+#if FOO==4
+#elif FOO==4+
+#endif
+
+
+
+
+
+
diff --git a/Examples/test-suite/errors/pp_defined.i b/Examples/test-suite/errors/pp_defined.i
new file mode 100644
index 000000000..e2f343079
--- /dev/null
+++ b/Examples/test-suite/errors/pp_defined.i
@@ -0,0 +1,7 @@
+%module xxx
+
+#if defined()
+#endif
+
+#if defined
+#endif
diff --git a/Examples/test-suite/errors/pp_macro_args.i b/Examples/test-suite/errors/pp_macro_args.i
new file mode 100644
index 000000000..8bbbfb104
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_args.i
@@ -0,0 +1,7 @@
+%module xxx
+
+#define foo(a,x) a x
+
+#if foo
+#endif
+
diff --git a/Examples/test-suite/errors/pp_macro_badchar.i b/Examples/test-suite/errors/pp_macro_badchar.i
new file mode 100644
index 000000000..276011559
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_badchar.i
@@ -0,0 +1,5 @@
+%module xxx
+
+#define f@oo(a,x) a + x
+#define foo(a@,x) a + x
+
diff --git a/Examples/test-suite/errors/pp_macro_nargs.i b/Examples/test-suite/errors/pp_macro_nargs.i
new file mode 100644
index 000000000..15e434877
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_nargs.i
@@ -0,0 +1,16 @@
+%module xxx
+
+#define foo(a,x) a x
+#define bar(x) x
+#define spam() /**/
+
+foo(3)
+foo(3,4,5)
+bar()
+bar(2,3)
+spam(1)
+
+
+
+
+
diff --git a/Examples/test-suite/errors/pp_macro_redef.i b/Examples/test-suite/errors/pp_macro_redef.i
new file mode 100644
index 000000000..e0910e60e
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_redef.i
@@ -0,0 +1,8 @@
+%module xxx
+
+#define foo(a,x) a+x
+#define foo 4
+
+/* Should not generate an error */
+#define foo 4
+
diff --git a/Examples/test-suite/errors/pp_macro_rparen.i b/Examples/test-suite/errors/pp_macro_rparen.i
new file mode 100644
index 000000000..cbb04fb87
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_rparen.i
@@ -0,0 +1,3 @@
+%module xxx
+
+#define foo(a,x 3
diff --git a/Examples/test-suite/errors/pp_macro_unterminated.i b/Examples/test-suite/errors/pp_macro_unterminated.i
new file mode 100644
index 000000000..d0e32d726
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_unterminated.i
@@ -0,0 +1,7 @@
+%module xxx
+
+#define foo(a,x) a+x
+
+foo(3,
+
+
diff --git a/Examples/test-suite/errors/pp_misplaced_elif.i b/Examples/test-suite/errors/pp_misplaced_elif.i
new file mode 100644
index 000000000..5e656f020
--- /dev/null
+++ b/Examples/test-suite/errors/pp_misplaced_elif.i
@@ -0,0 +1,7 @@
+%module xxx
+
+
+#elif foo == 3
+int x;
+#endif
+
diff --git a/Examples/test-suite/errors/pp_misplaced_else.i b/Examples/test-suite/errors/pp_misplaced_else.i
new file mode 100644
index 000000000..ad299466f
--- /dev/null
+++ b/Examples/test-suite/errors/pp_misplaced_else.i
@@ -0,0 +1,7 @@
+%module xxx
+
+
+#else
+int x;
+#endif
+
diff --git a/Examples/test-suite/errors/pp_missing_enddef.i b/Examples/test-suite/errors/pp_missing_enddef.i
new file mode 100644
index 000000000..e13deef27
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_enddef.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%define FOO
+int x;
+
+
+
diff --git a/Examples/test-suite/errors/pp_missing_endif.i b/Examples/test-suite/errors/pp_missing_endif.i
new file mode 100644
index 000000000..e83496fb2
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endif.i
@@ -0,0 +1,6 @@
+%module xxx
+
+#ifdef FOO
+int x;
+
+
diff --git a/Examples/test-suite/errors/pp_missing_file.i b/Examples/test-suite/errors/pp_missing_file.i
new file mode 100644
index 000000000..5e3f0ea27
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_file.i
@@ -0,0 +1,3 @@
+%module test
+
+%include "missing_filename.i"
diff --git a/Examples/test-suite/errors/pp_missing_rblock.i b/Examples/test-suite/errors/pp_missing_rblock.i
new file mode 100644
index 000000000..55c3cc808
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_rblock.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%{
+int x;
+
+
+
diff --git a/Examples/test-suite/errors/pp_unterm_char.i b/Examples/test-suite/errors/pp_unterm_char.i
new file mode 100644
index 000000000..9b028fd3d
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterm_char.i
@@ -0,0 +1,7 @@
+%module xxx
+
+
+const char x = 'H
+
+
+
diff --git a/Examples/test-suite/errors/pp_unterm_comment.i b/Examples/test-suite/errors/pp_unterm_comment.i
new file mode 100644
index 000000000..f9cdb8257
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterm_comment.i
@@ -0,0 +1,6 @@
+%module xxx
+
+/* Hello
+
+
+
diff --git a/Examples/test-suite/errors/pp_unterm_string.i b/Examples/test-suite/errors/pp_unterm_string.i
new file mode 100644
index 000000000..31ed8d4bb
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterm_string.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+const char *x = "Hello
+
+
diff --git a/Examples/test-suite/errors/swig_apply_nargs.i b/Examples/test-suite/errors/swig_apply_nargs.i
new file mode 100644
index 000000000..bb1519c1e
--- /dev/null
+++ b/Examples/test-suite/errors/swig_apply_nargs.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%typemap(in) (char *str, int len) {
+}
+
+%apply (char *str, int len) { int x };
diff --git a/Examples/test-suite/errors/swig_identifier.i b/Examples/test-suite/errors/swig_identifier.i
new file mode 100644
index 000000000..3ad07362d
--- /dev/null
+++ b/Examples/test-suite/errors/swig_identifier.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%rename("foo bar") foobar;
+
+int foobar(int);
+
diff --git a/Examples/test-suite/errors/swig_insert_bad.i b/Examples/test-suite/errors/swig_insert_bad.i
new file mode 100644
index 000000000..e2dd8a93e
--- /dev/null
+++ b/Examples/test-suite/errors/swig_insert_bad.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%insert("foobar") %{
+some code
+%}
diff --git a/Examples/test-suite/errors/swig_typemap_copy.i b/Examples/test-suite/errors/swig_typemap_copy.i
new file mode 100644
index 000000000..17607f2fb
--- /dev/null
+++ b/Examples/test-suite/errors/swig_typemap_copy.i
@@ -0,0 +1,3 @@
+%module xxx
+
+%typemap(in) int = blah;
diff --git a/Examples/test-suite/errors/swig_typemap_old.i b/Examples/test-suite/errors/swig_typemap_old.i
new file mode 100644
index 000000000..c27ff5533
--- /dev/null
+++ b/Examples/test-suite/errors/swig_typemap_old.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%typemap(in) int x {
+ $source;
+ $target;
+}
diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i
new file mode 100644
index 000000000..8644c24c9
--- /dev/null
+++ b/Examples/test-suite/evil_diamond.i
@@ -0,0 +1,23 @@
+%module evil_diamond
+
+%warnfilter(801) foo; // Ruby, wrong class name
+%warnfilter(801) bar; // Ruby, wrong class name
+%warnfilter(801) baz; // Ruby, wrong class name
+%warnfilter(801,802,813) spam; // Ruby, wrong class name; Ruby & Java, multiple inheritance
+
+%inline %{
+
+class foo { };
+
+class bar : public foo {
+};
+
+class baz : public foo {
+};
+
+class spam : public bar, public baz {
+};
+
+foo *test(foo *f) { return f; }
+%}
+
diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i
new file mode 100644
index 000000000..067805a79
--- /dev/null
+++ b/Examples/test-suite/evil_diamond_ns.i
@@ -0,0 +1,24 @@
+%module evil_diamond_ns
+
+%warnfilter(801) Blah::foo; // Ruby, wrong class name
+%warnfilter(801) Blah::bar; // Ruby, wrong class name
+%warnfilter(801) Blah::baz; // Ruby, wrong class name
+%warnfilter(801,802,813) Blah::spam; // Ruby, wrong class name; Ruby & Java, multiple inheritance
+
+%inline %{
+namespace Blah {
+class foo { };
+
+class bar : public foo {
+};
+
+class baz : public foo {
+};
+
+class spam : public bar, public baz {
+};
+
+foo *test(foo *f) { return f; }
+}
+%}
+
diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i
new file mode 100644
index 000000000..d28a57ca2
--- /dev/null
+++ b/Examples/test-suite/evil_diamond_prop.i
@@ -0,0 +1,36 @@
+%module evil_diamond_prop
+
+%warnfilter(801) foo; // Ruby, wrong class name
+%warnfilter(801) bar; // Ruby, wrong class name
+%warnfilter(801) baz; // Ruby, wrong class name
+%warnfilter(801,802,813) spam; // Ruby, wrong class name; Ruby & Java, multiple inheritance
+
+%inline %{
+
+class foo {
+ public:
+ int _foo;
+ foo() : _foo(1) {}
+};
+
+class bar : public foo {
+ public:
+ int _bar;
+ bar() : _bar(2) {}
+};
+
+class baz : public foo {
+ public:
+ int _baz;
+ baz() : _baz(3) {}
+};
+
+class spam : public bar, public baz {
+ public:
+ int _spam;
+ spam() : _spam(4) {}
+};
+
+foo *test(foo *f) { return f; }
+%}
+
diff --git a/Examples/test-suite/explicit.i b/Examples/test-suite/explicit.i
new file mode 100644
index 000000000..738dffc41
--- /dev/null
+++ b/Examples/test-suite/explicit.i
@@ -0,0 +1,15 @@
+/* Swig 1.3.6 fails to understand the "explicit" keyword.
+ SF Bug #445233, reported by Krzysztof Kozminski
+ <kozminski@users.sf.net>.
+*/
+
+%module "explicit"
+
+%inline %{
+
+class A {
+ public:
+ explicit A(int) {};
+};
+
+%}
diff --git a/Examples/test-suite/extend_template.i b/Examples/test-suite/extend_template.i
new file mode 100644
index 000000000..a39ac546d
--- /dev/null
+++ b/Examples/test-suite/extend_template.i
@@ -0,0 +1,26 @@
+%module extend_template
+%module xxx
+namespace oss { // this doesn't
+ %extend Foo<0> {
+ int test1(int x) { return x; }
+ }
+}
+
+%extend oss::Foo<0> { // this doesn't
+ int test2(int x) { return x; }
+};
+
+
+%inline %{
+ namespace oss
+ {
+ template <int>
+ struct Foo {
+ };
+ }
+%}
+
+namespace oss
+{
+ %template(Foo_0) Foo<0>;
+}
diff --git a/Examples/test-suite/extend_template_ns.i b/Examples/test-suite/extend_template_ns.i
new file mode 100644
index 000000000..3712f2c8f
--- /dev/null
+++ b/Examples/test-suite/extend_template_ns.i
@@ -0,0 +1,32 @@
+%module extend_template_ns
+%inline %{
+namespace oss
+{
+ enum Test {One, Two};
+}
+%}
+
+namespace oss {
+ %extend Foo<One> { //************ this doesn't work
+ int test1(int x) { return x; }
+ };
+}
+
+%extend oss::Foo<oss::One> { //******** this works
+int test2(int x) { return x; }
+};
+
+%inline %{
+namespace oss
+{
+ template <Test>
+ struct Foo {
+ };
+ }
+%}
+
+namespace oss
+{
+%template(Foo_One) Foo<One>;
+}
+
diff --git a/Examples/test-suite/grouping.i b/Examples/test-suite/grouping.i
new file mode 100644
index 000000000..5632231d0
--- /dev/null
+++ b/Examples/test-suite/grouping.i
@@ -0,0 +1,31 @@
+%module grouping
+
+%inline %{
+
+typedef int Integer;
+
+int (test1)(int x) {
+ return x;
+}
+
+int *(test2)(int x) {
+ static int y;
+ y = x;
+ return &y;
+}
+
+int (test3) = 37;
+
+typedef Integer (UnaryOp)(Integer);
+
+Integer do_unary(Integer x, UnaryOp *f) {
+ return (*f)(x);
+}
+
+int negate(int x) {
+ return -x;
+}
+
+%}
+
+%constant UnaryOp *NEGATE = negate;
diff --git a/Examples/test-suite/guile/.cvsignore b/Examples/test-suite/guile/.cvsignore
new file mode 100644
index 000000000..1242e8c7e
--- /dev/null
+++ b/Examples/test-suite/guile/.cvsignore
@@ -0,0 +1,2 @@
+*wrap*
+*-guile
diff --git a/Examples/test-suite/guile/Makefile b/Examples/test-suite/guile/Makefile
new file mode 100644
index 000000000..a39bcaf0e
--- /dev/null
+++ b/Examples/test-suite/guile/Makefile
@@ -0,0 +1,44 @@
+#######################################################################
+# $Header$
+# Makefile for guile test-suite
+#######################################################################
+
+LANGUAGE = guile
+VARIANT = _passive
+SCRIPTSUFFIX = _runme.scm
+
+C_TEST_CASES = long_long list_vector pointer_in_out multivalue
+
+include ../common.mk
+
+# Overridden variables here
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.scm appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.scm ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH guile -l $*\_runme.scm;) \
+ fi;
+
+# Clean
+%.clean:
+ @rm -f $*-guile
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile guile_clean
diff --git a/Examples/test-suite/guile/README b/Examples/test-suite/guile/README
new file mode 100644
index 000000000..37432ea4b
--- /dev/null
+++ b/Examples/test-suite/guile/README
@@ -0,0 +1,4 @@
+See ../README for common README file.
+
+Any testcases which have _runme.scm appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/guile/casts_runme.scm b/Examples/test-suite/guile/casts_runme.scm
new file mode 100644
index 000000000..17e7725f6
--- /dev/null
+++ b/Examples/test-suite/guile/casts_runme.scm
@@ -0,0 +1,13 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_test_module" (dynamic-link "./libcasts.so"))
+
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG/Guile runtime code gets the
+;; source and the target of a cast the wrong way around.
+
+(A-hello x)
+
+(exit 0)
diff --git a/Examples/test-suite/guile/char_constant_runme.scm b/Examples/test-suite/guile/char_constant_runme.scm
new file mode 100644
index 000000000..2cc89b051
--- /dev/null
+++ b/Examples/test-suite/guile/char_constant_runme.scm
@@ -0,0 +1,9 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_test_module" (dynamic-link "./libchar_constant.so"))
+
+(if (and (char? (CHAR-CONSTANT))
+ (string? (STRING-CONSTANT)))
+ (exit 0)
+ (exit 1))
diff --git a/Examples/test-suite/guile/imports_runme.scm b/Examples/test-suite/guile/imports_runme.scm
new file mode 100644
index 000000000..030fbfd61
--- /dev/null
+++ b/Examples/test-suite/guile/imports_runme.scm
@@ -0,0 +1,19 @@
+;;; This file is part of a test for SF bug #231619.
+;;; It shows that the %import directive does not work properly in SWIG
+;;; 1.3a5: Type information is not properly generated if a base class
+;;; comes from an %import-ed file.
+
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a.so"))
+(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b.so"))
+
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG runtime code does not know
+;; that x (an instance of class B) can be passed to methods of class A.
+
+(A-hello x)
+
+(exit 0)
diff --git a/Examples/test-suite/guile/list_vector_runme.scm b/Examples/test-suite/guile/list_vector_runme.scm
new file mode 100644
index 000000000..1957c9a7f
--- /dev/null
+++ b/Examples/test-suite/guile/list_vector_runme.scm
@@ -0,0 +1,28 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_test_module" (dynamic-link "./liblist_vector.so"))
+
+(define-macro (check form)
+ `(if (not ,form)
+ (error "Check failed: " ',form)))
+
+(check (= (sum-list '(1 3 4 6 7)) 21))
+(check (= (sum-vector #(2 4 6 7 9)) 28))
+(check (equal? (one-to-seven-list) '(1 2 3 4 5 6 7)))
+(check (equal? (one-to-seven-vector) #(1 2 3 4 5 6 7)))
+
+(check (= (sum-list2 '(1 3 4 6 7)) 21))
+(check (= (sum-vector2 #(2 4 6 7 9)) 28))
+(check (equal? (one-to-seven-list2) '(1 2 3 4 5 6 7)))
+(check (equal? (one-to-seven-vector2) #(1 2 3 4 5 6 7)))
+
+(check (= (sum-lists '(1 2 3) '(4 5 6) '(7 8 9)) 45))
+(check (= (sum-lists2 '(1 2 3) '(4 5 6) '(7 8 9)) 45))
+(check (equal? (call-with-values produce-lists list)
+ '(#(0 1 2 3 4)
+ #(0 1 4 9 16)
+ #(0.0 1.5 3.0 4.5 6.0))))
+
+
+(exit 0)
diff --git a/Examples/test-suite/guile/multivalue_runme.scm b/Examples/test-suite/guile/multivalue_runme.scm
new file mode 100644
index 000000000..910935801
--- /dev/null
+++ b/Examples/test-suite/guile/multivalue_runme.scm
@@ -0,0 +1,24 @@
+;;;; Automatic test of multiple return values
+
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_test_module" (dynamic-link "./libmultivalue.so"))
+
+(let ((quotient/remainder (divide-l 37 5)))
+ (if (not (equal? quotient/remainder '(7 2)))
+ (exit 1)))
+
+(let ((quotient-remainder-vector (divide-v 41 7)))
+ (if (not (equal? quotient-remainder-vector #(5 6)))
+ (exit 1)))
+
+(call-with-values (lambda ()
+ (divide-mv 91 13))
+ (lambda (quotient remainder)
+ (if (not (and (= quotient 7)
+ (= remainder 0)))
+ (exit 1))))
+
+(exit 0)
+
diff --git a/Examples/test-suite/guile/name_runme.scm b/Examples/test-suite/guile/name_runme.scm
new file mode 100644
index 000000000..a7121b9d9
--- /dev/null
+++ b/Examples/test-suite/guile/name_runme.scm
@@ -0,0 +1,10 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_test_module" (dynamic-link "./libname.so"))
+
+(foo-2)
+bar-2
+Baz-2
+
+(exit 0)
diff --git a/Examples/test-suite/guile/overload_complicated_runme.scm b/Examples/test-suite/guile/overload_complicated_runme.scm
new file mode 100644
index 000000000..0423aafbd
--- /dev/null
+++ b/Examples/test-suite/guile/overload_complicated_runme.scm
@@ -0,0 +1,18 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated.so"))
+
+(define-macro (check form)
+ `(if (not ,form)
+ (error "Check failed: " ',form)))
+
+;; Check first method
+(check (= (foo 1 2 "bar" 4) 15))
+
+;; Check second method
+(check (= (foo 1 2) 4811.4))
+(check (= (foo 1 2 3.2) 4797.2))
+(check (= (foo 1 2 3.2 #\Q) 4798.2))
+
+(exit 0)
diff --git a/Examples/test-suite/guile/overload_simple_runme.scm b/Examples/test-suite/guile/overload_simple_runme.scm
new file mode 100644
index 000000000..abe95069a
--- /dev/null
+++ b/Examples/test-suite/guile/overload_simple_runme.scm
@@ -0,0 +1,56 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple.so"))
+
+(if (not (string=? (foo 3) "foo:int"))
+ (error "foo(int)"))
+
+(if (not (string=? (foo 3.01) "foo:double"))
+ (error "foo(double)"))
+
+(if (not (string=? (foo "hello") "foo:char *"))
+ (error "foo(char *)"))
+
+(let ((f (new-Foo))
+ (b (new-Bar))
+ (s (new-Spam)))
+ (if (not (string=? (foo f) "foo:Foo *"))
+ (error "foo(Foo *)"))
+ (if (not (string=? (foo b) "foo:Bar *"))
+ (error "foo(Bar *)"))
+ ;; Test member functions
+ (if (not (string=? (Spam-foo s 3) "foo:int"))
+ (error "Spam::foo(int)"))
+ (if (not (string=? (Spam-foo s 3.01) "foo:double"))
+ (error "Spam::foo(double)"))
+ (if (not (string=? (Spam-foo s "hello") "foo:char *"))
+ (error "Spam::foo(char *)"))
+ (if (not (string=? (Spam-foo s f) "foo:Foo *"))
+ (error "Spam::foo(Foo *)"))
+ (if (not (string=? (Spam-foo s b) "foo:Bar *"))
+ (error "Spam::foo(Bar *)"))
+ ;; Test static member functions
+ (if (not (string=? (Spam-bar 3) "bar:int"))
+ (error "Spam::bar(int)"))
+ (if (not (string=? (Spam-bar 3.01) "bar:double"))
+ (error "Spam::bar(double)"))
+ (if (not (string=? (Spam-bar "hello") "bar:char *"))
+ (error "Spam::bar(char *)"))
+ (if (not (string=? (Spam-bar f) "bar:Foo *"))
+ (error "Spam::bar(Foo *)"))
+ (if (not (string=? (Spam-bar b) "bar:Bar *"))
+ (error "Spam::bar(Bar *)"))
+ ;; Test constructors
+ (if (not (string=? (Spam-type-get (new-Spam)) "none"))
+ (error "Spam()"))
+ (if (not (string=? (Spam-type-get (new-Spam 3)) "int"))
+ (error "Spam(int)"))
+ (if (not (string=? (Spam-type-get (new-Spam 3.4)) "double"))
+ (error "Spam(double)"))
+ (if (not (string=? (Spam-type-get (new-Spam "hello")) "char *"))
+ (error "Spam(char *)"))
+ (if (not (string=? (Spam-type-get (new-Spam b)) "Bar *"))
+ (error "Spam(Bar *)")))
+
+(exit 0)
diff --git a/Examples/test-suite/guile/overload_subtype_runme.scm b/Examples/test-suite/guile/overload_subtype_runme.scm
new file mode 100644
index 000000000..14737f144
--- /dev/null
+++ b/Examples/test-suite/guile/overload_subtype_runme.scm
@@ -0,0 +1,12 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype.so"))
+
+(if (not (= (spam (new-Foo)) 1))
+ (error "foo"))
+
+(if (not (= (spam (new-Bar)) 2))
+ (error "bar"))
+
+(exit 0)
diff --git a/Examples/test-suite/guile/pointer_in_out_runme.scm b/Examples/test-suite/guile/pointer_in_out_runme.scm
new file mode 100644
index 000000000..68ce0aa3b
--- /dev/null
+++ b/Examples/test-suite/guile/pointer_in_out_runme.scm
@@ -0,0 +1,18 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out.so"))
+
+(define-macro (check form)
+ `(if (not ,form)
+ (error "Check failed: " ',form)))
+
+(define p (produce-int-pointer 47 11))
+
+(check (= (consume-int-pointer p) 47))
+
+(define q (frobnicate-int-pointer p))
+
+(check (= (consume-int-pointer q) 11))
+
+(exit 0)
diff --git a/Examples/test-suite/guile/unions_runme.scm b/Examples/test-suite/guile/unions_runme.scm
new file mode 100644
index 000000000..ce2caa8b3
--- /dev/null
+++ b/Examples/test-suite/guile/unions_runme.scm
@@ -0,0 +1,41 @@
+;;; This is the union runtime testcase. It ensures that values within a
+;;; union embedded within a struct can be set and read correctly.
+
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions.so"))
+
+;; Create new instances of SmallStruct and BigStruct for later use
+(define small (new-SmallStruct))
+(SmallStruct-jill-set small 200)
+
+(define big (new-BigStruct))
+(BigStruct-smallstruct-set big small)
+(BigStruct-jack-set big 300)
+
+;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+;; Ensure values in EmbeddedUnionTest are set correctly for each.
+(define eut (new-EmbeddedUnionTest))
+
+;; First check the SmallStruct in EmbeddedUnionTest
+(EmbeddedUnionTest-number-set eut 1)
+(EmbeddedUnionTest-uni-small-set (EmbeddedUnionTest-uni-get eut)
+ small)
+(let ((Jill1 (SmallStruct-jill-get
+ (EmbeddedUnionTest-uni-small-get
+ (EmbeddedUnionTest-uni-get eut)))))
+ (if (not (= Jill1 200))
+ (begin
+ (display "Runtime test 1 failed.")
+ (exit 1))))
+
+(let ((Num1 (EmbeddedUnionTest-number-get eut)))
+ (if (not (= Num1 1))
+ (begin
+ (display "Runtime test 2 failed.")
+ (exit 1))))
+
+;; that should do
+
+(exit 0)
diff --git a/Examples/test-suite/ignore_parameter.i b/Examples/test-suite/ignore_parameter.i
new file mode 100644
index 000000000..f64a4b32e
--- /dev/null
+++ b/Examples/test-suite/ignore_parameter.i
@@ -0,0 +1,42 @@
+// Test for %typemap(ignore)
+
+%module ignore_parameter
+
+%typemap(in,numinputs=0) char* a "static char* hi = \"hello\"; $1 = hi;";
+%typemap(in,numinputs=0) int bb "$1 = 101;";
+%typemap(in,numinputs=0) double ccc "$1 = 8.8;";
+
+%typemap(freearg) char* a ""; // ensure freearg is not generated (needed for Java at least)
+
+%inline %{
+// global function tests
+char* jaguar(char* a, int b, double c) { return a; }
+int lotus(char* aa, int bb, double cc) { return bb; }
+double tvr(char* aaa, int bbb, double ccc) { return ccc; }
+int ferrari(int bb) { return bb; }
+
+// member function tests
+struct SportsCars {
+ char* daimler(char* a, int b, double c) { return a; }
+ int astonmartin(char* aa, int bb, double cc) { return bb; }
+ double bugatti(char* aaa, int bbb, double ccc) { return ccc; }
+ int lamborghini(int bb) { return bb; }
+};
+
+// constructor tests
+struct MiniCooper {
+ MiniCooper(char* a, int b, double c) {}
+};
+struct MorrisMinor {
+ MorrisMinor(char* aa, int bb, double cc) {}
+};
+struct FordAnglia {
+ FordAnglia(char* aaa, int bbb, double ccc) {}
+};
+struct AustinAllegro {
+ AustinAllegro(int bb) {}
+};
+%}
+
+
+
diff --git a/Examples/test-suite/import_nomodule.h b/Examples/test-suite/import_nomodule.h
new file mode 100644
index 000000000..2e80e72bb
--- /dev/null
+++ b/Examples/test-suite/import_nomodule.h
@@ -0,0 +1,2 @@
+class Foo { };
+typedef int Integer;
diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i
new file mode 100644
index 000000000..e280455f3
--- /dev/null
+++ b/Examples/test-suite/import_nomodule.i
@@ -0,0 +1,24 @@
+%module import_nomodule
+%{
+#include "import_nomodule.h"
+%}
+
+%import "import_nomodule.h"
+
+#ifndef SWIGJAVA
+// The proxy class does not have Bar derived from Foo, yet an instance of Bar can successfully be passed to a proxy function taking a Foo pointer.
+// This violation of the type system is not possible in Java due to its static type checking.
+%inline %{
+Foo *create_Foo() {
+ return new Foo();
+}
+
+void test1(Foo *f, Integer x) { };
+
+class Bar : public Foo { };
+
+%}
+#endif
+
+
+
diff --git a/Examples/test-suite/imports.list b/Examples/test-suite/imports.list
new file mode 100644
index 000000000..36c0802fb
--- /dev/null
+++ b/Examples/test-suite/imports.list
@@ -0,0 +1,2 @@
+imports_a
+imports_b
diff --git a/Examples/test-suite/imports_a.h b/Examples/test-suite/imports_a.h
new file mode 100644
index 000000000..ea006b12c
--- /dev/null
+++ b/Examples/test-suite/imports_a.h
@@ -0,0 +1,7 @@
+class A {
+ public:
+ A() {}
+
+ void hello()
+ {}
+};
diff --git a/Examples/test-suite/imports_a.i b/Examples/test-suite/imports_a.i
new file mode 100644
index 000000000..56e1f0e5d
--- /dev/null
+++ b/Examples/test-suite/imports_a.i
@@ -0,0 +1,12 @@
+/* This file is part of a test for SF bug #231619.
+ It shows that the %import directive does not work properly in SWIG
+ 1.3a5: Type information is not properly generated if a base class
+ comes from an %import-ed file. */
+
+%module imports_a
+
+%{
+ #include "imports_a.h"
+%}
+
+%include "imports_a.h"
diff --git a/Examples/test-suite/imports_b.h b/Examples/test-suite/imports_b.h
new file mode 100644
index 000000000..ecc8d4e2f
--- /dev/null
+++ b/Examples/test-suite/imports_b.h
@@ -0,0 +1,11 @@
+#include "imports_a.h"
+
+class B : public A
+{
+ public:
+ B() {};
+
+ void bye()
+ {} ;
+};
+
diff --git a/Examples/test-suite/imports_b.i b/Examples/test-suite/imports_b.i
new file mode 100644
index 000000000..48c51c625
--- /dev/null
+++ b/Examples/test-suite/imports_b.i
@@ -0,0 +1,14 @@
+/* This file is part of a test for SF bug #231619.
+ It shows that the %import directive does not work properly in SWIG
+ 1.3a5: Type information is not properly generated if a base class
+ comes from an %import-ed file. */
+
+%module imports_b
+
+%{
+#include "imports_b.h"
+%}
+
+%import "imports_a.i"
+
+%include "imports_b.h"
diff --git a/Examples/test-suite/inherit_missing.i b/Examples/test-suite/inherit_missing.i
new file mode 100644
index 000000000..ecde360bf
--- /dev/null
+++ b/Examples/test-suite/inherit_missing.i
@@ -0,0 +1,43 @@
+// Tests handling of inheritance when a base class isn't provided to SWIG
+%module inherit_missing
+
+%warnfilter(402);
+
+%{
+/* Define the class internally, but don't tell SWIG about it */
+class Foo {
+public:
+ virtual char *blah() {
+ return (char *) "Foo::blah";
+ }
+};
+%}
+
+/* Forward declaration. Says that Foo is a class, but doesn't provide a definition */
+
+class Foo;
+
+%inline %{
+
+class Bar : public Foo {
+ public:
+ virtual char *blah() {
+ return (char *) "Bar::blah";
+ };
+};
+
+class Spam : public Bar {
+ public:
+ virtual char *blah() {
+ return (char *) "Spam::blah";
+ };
+};
+
+Foo *new_Foo() {
+ return new Foo();
+}
+
+char *do_blah(Foo *f) {
+ return f->blah();
+}
+%}
diff --git a/Examples/test-suite/java/.cvsignore b/Examples/test-suite/java/.cvsignore
new file mode 100644
index 000000000..f51eef359
--- /dev/null
+++ b/Examples/test-suite/java/.cvsignore
@@ -0,0 +1,185 @@
+abstract_inherit
+abstract_inherit_ok
+add_link
+anonymous_arg
+argout
+arrayptr
+arrays
+arrays_global
+arrays_global_twodim
+arrays_scope
+bool_default
+casts
+char_constant
+class_ignore
+constant_pointers
+constover
+constructor_exception
+constructor_explicit
+constructor_value
+const_const
+const_const_2
+conversion
+conversion_namespace
+conversion_ns_template
+cplusplus_throw
+cpp_enum
+cpp_enum_scope
+cpp_namespace
+cpp_nodefault
+cpp_static
+cpp_typedef
+CVS
+default_cast
+default_constructor
+default_ns
+default_ref
+defineop
+defines
+dynamic_cast
+enum
+enum_scope
+enum_scope_template
+enum_var
+evil_diamond
+evil_diamond_ns
+evil_diamond_prop
+explicit
+extend_template
+extend_template_ns
+grouping
+ignore_parameter
+imports
+import_nomodule
+inherit_missing
+java_constants
+java_pragmas
+java_throws
+java_typemaps_proxy
+java_typemaps_typewrapper
+kind
+lib_carrays
+lib_cdata
+lib_cmalloc
+lib_constraints
+lib_cpointer
+lib_math
+lib_std_deque
+lib_std_string
+lib_std_vector
+lib_typemaps
+long_long
+macro_2
+member_template
+minherit
+name
+namespace_enum
+namespace_extend
+namespace_nested
+namespace_template
+namespace_typemap
+name_cxx
+name_inherit
+nested
+newobject1
+newobject2
+overload_complicated
+overload_copy
+overload_extend
+overload_extendc
+overload_simple
+overload_subtype
+overload_template
+pointer_reference
+preproc_1
+preproc_2
+preproc_3
+primitive_ref
+private_assign
+pure_virtual
+rename_default
+rename_scope
+return_value_scope
+ret_by_value
+rname
+sizeof_pointer
+smart_pointer_const
+smart_pointer_multi
+smart_pointer_multi_typedef
+smart_pointer_not
+smart_pointer_overload
+smart_pointer_protected
+smart_pointer_rename
+smart_pointer_simple
+smart_pointer_typedef
+sneaky1
+static_array_member
+static_const_member
+static_const_member_2
+struct_value
+template
+template_arg_scope
+template_arg_typename
+template_base_template
+template_classes
+template_construct
+template_const_ref
+template_default
+template_default2
+template_default_inherit
+template_default_qualify
+template_enum
+template_enum_ns_inherit
+template_enum_typedef
+template_forward
+template_inherit
+template_inherit_abstract
+template_int_const
+template_ns
+template_ns2
+template_ns3
+template_ns4
+template_ns_enum
+template_ns_enum2
+template_ns_inherit
+template_ns_scope
+template_qualifier
+template_rename
+template_retvalue
+template_specialization
+template_static
+template_tbase_template
+template_typedef
+template_typedef_cplx
+template_typedef_cplx2
+template_typedef_cplx3
+template_typedef_cplx4
+template_typedef_import
+template_type_namespace
+template_virtual
+template_whitespace
+throw_exception
+typedef_funcptr
+typedef_inherit
+typedef_mptr
+typedef_reference
+typedef_scope
+typemap_namespace
+typemap_ns_using
+typemap_subst
+typename
+unions
+union_scope
+using1
+using2
+using_composition
+using_extend
+using_inherit
+using_namespace
+using_private
+using_protected
+valuewrapper_base
+virtual_destructor
+voidtest
+
+*.class
diff --git a/Examples/test-suite/java/Makefile b/Examples/test-suite/java/Makefile
new file mode 100644
index 000000000..6cc4c6440
--- /dev/null
+++ b/Examples/test-suite/java/Makefile
@@ -0,0 +1,72 @@
+#######################################################################
+# $Header$
+# Makefile for java test-suite
+#######################################################################
+
+LANGUAGE = java
+SCRIPTSUFFIX = _runme.java
+
+C_TEST_CASES = \
+ java_lib_arrays
+
+CPP_TEST_CASES = \
+ java_constants \
+ java_jnitypes \
+ java_pragmas \
+ java_throws \
+ java_typemaps_proxy \
+ java_typemaps_typewrapper
+
+include ../common.mk
+
+# Overridden variables here
+TOP = ../../..
+SWIGOPT = -I$(TOP)/$(TEST_SUITE) -package $*
+#Target prefix cannot be used on Windows
+#TARGETPREFIX = lib
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ (cd $*; $(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ (cd $*; $(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ (cd $*; $(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Makes a directory for the testcase if it does not exist
+setup = \
+ @if [ -f $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "Checking testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "Checking testcase $* under $(LANGUAGE)" ; \
+ fi; \
+ if [ ! -d $* ]; then \
+ mkdir $*; \
+ fi;
+
+# Compiles java files then runs the testcase. A testcase is only run if
+# a file is found which has _runme.java appended after the testcase name.
+# Note Java uses LD_LIBRARY_PATH under Unix and PATH under Cygwin.
+run_testcase = \
+ (cd $*; javac *.java; ); \
+ if [ -f $*\_runme.java ]; then ( \
+ javac $*\_runme.java; \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" java $*\_runme;) \
+ fi;
+
+# Clean: remove testcase directories
+%.clean:
+ @if [ -d $* ]; then \
+ rm -rf $*; \
+ fi;
+
+clean:
+ @rm -f *.class
diff --git a/Examples/test-suite/java/README b/Examples/test-suite/java/README
new file mode 100644
index 000000000..b8b7416d9
--- /dev/null
+++ b/Examples/test-suite/java/README
@@ -0,0 +1,6 @@
+See ../README for common README file.
+
+The Java implementation of the test-suite is a little different to the other languages in that all of SWIGs output goes into a subdirectory named after the individual test case. This is so that all the shadow classes can be compiled as Java classes have to go into separate files. Otherwise the Makefile wouldn't know which .java files would be relevant to the testcase. For this to work the testcase must go into a Java package.
+
+Any testcases which have _runme.java appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/java/arrays_global_twodim_runme.java b/Examples/test-suite/java/arrays_global_twodim_runme.java
new file mode 100644
index 000000000..2cbc0138a
--- /dev/null
+++ b/Examples/test-suite/java/arrays_global_twodim_runme.java
@@ -0,0 +1,33 @@
+// Two dimension arrays test
+
+import arrays_global_twodim.*;
+
+public class arrays_global_twodim_runme {
+ static {
+ try {
+ System.loadLibrary("arrays_global_twodim");
+ } 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_a_4__int constintarray2d = arrays_global_twodim.getArray_const_i();
+ SWIGTYPE_p_a_4__int intarray2d = arrays_global_twodim.getArray_i();
+
+ // Set all the non const int array members from the const int array members and check
+ arrays_global_twodim.setArray_i(constintarray2d);
+
+ int count = 10;
+ for (int x=0; x<arrays_global_twodim.ARRAY_LEN_X; x++) {
+ for (int y=0; y<arrays_global_twodim.ARRAY_LEN_Y; y++) {
+ if ( arrays_global_twodim.get_2d_array(intarray2d, x, y) != count++) {
+ System.out.println("Value incorrect array_i[" + x + "][" + y + "]");
+ System.exit(1);
+ }
+ }
+ }
+ }
+}
diff --git a/Examples/test-suite/java/cpp_typedef_runme.java b/Examples/test-suite/java/cpp_typedef_runme.java
new file mode 100644
index 000000000..38153fac2
--- /dev/null
+++ b/Examples/test-suite/java/cpp_typedef_runme.java
@@ -0,0 +1,30 @@
+
+// This is the cpp_typedef runtime testcase. It checks that shadow classes are
+// generated for typedef'd types.
+
+import cpp_typedef.*;
+
+public class cpp_typedef_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp_typedef");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ Test test = new Test();
+ UnnamedStruct unnamed = new UnnamedStruct();
+ TypedefNamedStruct named = new TypedefNamedStruct();
+
+ UnnamedStruct unnamed2 = test.test1(unnamed);
+ TypedefNamedStruct named2 = test.test2(named);
+ TypedefNamedStruct named3 = test.test3(named);
+ TypedefNamedStruct named4 = test.test4(named);
+ }
+}
+
diff --git a/Examples/test-suite/java/dynamic_cast_runme.java b/Examples/test-suite/java/dynamic_cast_runme.java
new file mode 100644
index 000000000..be1f97b35
--- /dev/null
+++ b/Examples/test-suite/java/dynamic_cast_runme.java
@@ -0,0 +1,29 @@
+
+import dynamic_cast.*;
+
+public class dynamic_cast_runme {
+ static {
+ try {
+ System.loadLibrary("dynamic_cast");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ Foo f = new Foo();
+ Bar b = new Bar();
+
+ Foo x = f.blah();
+ Foo y = b.blah();
+
+ // Note it is possible to downcast y with a Java cast.
+ String a = dynamic_cast.do_test((Bar)y);
+ if (!a.equals("Bar::test")) {
+ System.err.println("Failed!");
+ System.exit(1);
+ }
+ }
+}
diff --git a/Examples/test-suite/java/ignore_parameter_runme.java b/Examples/test-suite/java/ignore_parameter_runme.java
new file mode 100644
index 000000000..7dbcb06db
--- /dev/null
+++ b/Examples/test-suite/java/ignore_parameter_runme.java
@@ -0,0 +1,36 @@
+// Runtime test checking the %typemap(ignore) macro
+
+import ignore_parameter.*;
+
+public class ignore_parameter_runme {
+ static {
+ try {
+ System.loadLibrary("ignore_parameter");
+ } 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[])
+ {
+ // Compilation will ensure the number of arguments and type are correct.
+ // Then check the return value is the same as the value given to the ignored parameter.
+ if (!ignore_parameter.jaguar(200, 0.0).equals("hello")) { System.err.println("Runtime Error in jaguar()");}
+ if (ignore_parameter.lotus("fast", 0.0) != 101) { System.err.println("Runtime Error in lotus()");}
+ if (ignore_parameter.tvr("fast", 200) != 8.8) { System.err.println("Runtime Error in tvr()");}
+ if (ignore_parameter.ferrari() != 101) { System.err.println("Runtime Error in ferrari()");}
+
+ SportsCars sc = new SportsCars();
+ if (!sc.daimler(200, 0.0).equals("hello")) { System.err.println("Runtime Error in daimler()");}
+ if (sc.astonmartin("fast", 0.0) != 101) { System.err.println("Runtime Error in astonmartin()");}
+ if (sc.bugatti("fast", 200) != 8.8) { System.err.println("Runtime Error in bugatti()");}
+ if (sc.lamborghini() != 101) { System.err.println("Runtime Error in lamborghini()");}
+
+ // Check constructors are also generated correctly
+ MiniCooper mc = new MiniCooper(200, 0.0);
+ MorrisMinor mm = new MorrisMinor("slow", 0.0);
+ FordAnglia fa = new FordAnglia("slow", 200);
+ AustinAllegro aa = new AustinAllegro();
+ }
+}
diff --git a/Examples/test-suite/java/imports_runme.java b/Examples/test-suite/java/imports_runme.java
new file mode 100644
index 000000000..b82862b67
--- /dev/null
+++ b/Examples/test-suite/java/imports_runme.java
@@ -0,0 +1,24 @@
+
+// This is the imports runtime testcase. It shows that the %import directive
+// is working correctly
+
+import imports.*;
+
+public class imports_runme {
+
+ static {
+ try {
+ System.loadLibrary("imports_a");
+ System.loadLibrary("imports_b");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ B b = new B();
+ b.hello(); //call member function in A which is in a different SWIG generated library.
+ }
+}
diff --git a/Examples/test-suite/java/java_constants_runme.java b/Examples/test-suite/java/java_constants_runme.java
new file mode 100644
index 000000000..be2ece08a
--- /dev/null
+++ b/Examples/test-suite/java/java_constants_runme.java
@@ -0,0 +1,29 @@
+
+import java_constants.*;
+
+public class java_constants_runme {
+ static {
+ try {
+ System.loadLibrary("java_constants");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ int number = 200;
+
+ // Switch statement will only compile if these constants are initialised
+ // from a constant Java value, that is not from a function call
+ switch(number) {
+ case java_constants.CHINA:
+ break;
+ case java_constants.BRISTOLS:
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/Examples/test-suite/java/java_jnitypes_runme.java b/Examples/test-suite/java/java_jnitypes_runme.java
new file mode 100644
index 000000000..a4950d9bd
--- /dev/null
+++ b/Examples/test-suite/java/java_jnitypes_runme.java
@@ -0,0 +1,57 @@
+
+import java_jnitypes.*;
+
+public class java_jnitypes_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_jnitypes");
+ } 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 class Test {
+ }
+
+ public static void main(String argv[]) {
+
+ Test test = new Test();
+ boolean booleanArray[] = new boolean[] {true, false};
+ char charArray[] = new char[] {10, 20};
+ byte byteArray[] = new byte[] {'A', 'B'};
+ short shortArray[] = new short[] {10, 20};
+ int intArray[] = new int[] {10, 20};
+ long longArray[] = new long[] {10, 20};
+ float floatArray[] = new float[] {(float)10.0, (float)20.0};
+ double doubleArray[] = new double[] {10.0, 20.0};
+ Test objectArray[] = new Test[] {new Test(), test};
+
+ if (java_jnitypes.jnifunc(true) != true) testFailed("jboolean");
+ if (java_jnitypes.jnifunc(100) != 100) testFailed("jchar");
+ if (java_jnitypes.jnifunc('A') != 'A') testFailed("jbyte");
+ if (java_jnitypes.jnifunc(100) != 100) testFailed("jshort");
+ if (java_jnitypes.jnifunc(100) != 100) testFailed("jint");
+ if (java_jnitypes.jnifunc(100) != 100) testFailed("jlong");
+ if (java_jnitypes.jnifunc(100) != 100) testFailed("jfloat");
+ if (java_jnitypes.jnifunc(100.0) != 100) testFailed("jdouble");
+ if (java_jnitypes.jnifunc("100") != "100") testFailed("jstring");
+ if (java_jnitypes.jnifunc(test) != test) testFailed("jobject");
+ if (java_jnitypes.jnifunc(booleanArray)[1] != false) testFailed("jbooleanArray");
+ if (java_jnitypes.jnifunc(charArray)[1] != 20) testFailed("jcharArray");
+ if (java_jnitypes.jnifunc(byteArray)[1] != 'B') testFailed("jbyteArray");
+ if (java_jnitypes.jnifunc(shortArray)[1] != 20) testFailed("jshortArray");
+ if (java_jnitypes.jnifunc(intArray)[1] != 20) testFailed("jintArray");
+ if (java_jnitypes.jnifunc(longArray)[1] != 20) testFailed("jlongArray");
+ if (java_jnitypes.jnifunc(floatArray)[1] != 20.0) testFailed("jfloatArray");
+ if (java_jnitypes.jnifunc(doubleArray)[1] != 20.0) testFailed("jdoubleArray");
+ if (java_jnitypes.jnifunc(objectArray)[1] != test) testFailed("jobjectArray");
+
+ }
+
+ public static void testFailed(String str) {
+ System.err.println(str + " test failed");
+ System.exit(1);
+ }
+}
diff --git a/Examples/test-suite/java/java_lib_arrays_runme.java b/Examples/test-suite/java/java_lib_arrays_runme.java
new file mode 100644
index 000000000..9490e5e2f
--- /dev/null
+++ b/Examples/test-suite/java/java_lib_arrays_runme.java
@@ -0,0 +1,150 @@
+
+// This is the java_lib_arrays runtime testcase. It ensures that a getter and a setter has
+// been produced for array members and that they function as expected. It is a
+// pretty comprehensive test for all the Java array library typemaps.
+
+import java_lib_arrays.*;
+
+public class java_lib_arrays_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_lib_arrays");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // Check array member variables
+ ArrayStruct as = new ArrayStruct();
+
+ // Create arrays for all the array types that ArrayStruct can handle
+ String array_c = "X";
+ byte[] array_sc = {10, 20};
+ short[] array_uc = {101, 201};
+ short[] array_s = {1002, 2002};
+ int[] array_us = {1003, 2003};
+ int[] array_i = {1004, 2004};
+ long[] array_ui = {1005, 2005};
+ int[] array_l = {1006, 2006};
+ long[] array_ul = {1007, 2007};
+ long[] array_ll = {1008, 2008};
+ float[] array_f = {1009.1f, 2009.1f};
+ double[] array_d = {1010.2f, 2010.2f};
+ int[] array_enum = {java_lib_arrays.Three, java_lib_arrays.Four};
+
+ SimpleStruct[] array_struct={new SimpleStruct(), new SimpleStruct()};
+ array_struct[0].setDouble_field(222.333);
+ array_struct[1].setDouble_field(444.555);
+
+ // Now set the array members and check that they have been set correctly
+ as.setArray_c(array_c);
+ check_string(array_c, as.getArray_c());
+
+ as.setArray_sc(array_sc);
+ check_byte_array(array_sc, as.getArray_sc());
+
+ as.setArray_uc(array_uc);
+ check_short_array(array_uc, as.getArray_uc());
+
+ as.setArray_s(array_s);
+ check_short_array(array_s, as.getArray_s());
+
+ as.setArray_us(array_us);
+ check_int_array(array_us, as.getArray_us());
+
+ as.setArray_i(array_i);
+ check_int_array(array_i, as.getArray_i());
+
+ as.setArray_ui(array_ui);
+ check_long_array(array_ui, as.getArray_ui());
+
+ as.setArray_l(array_l);
+ check_int_array(array_l, as.getArray_l());
+
+ as.setArray_ul(array_ul);
+ check_long_array(array_ul, as.getArray_ul());
+
+ as.setArray_ll(array_ll);
+ check_long_array(array_ll, as.getArray_ll());
+
+ as.setArray_f(array_f);
+ check_float_array(array_f, as.getArray_f());
+
+ as.setArray_d(array_d);
+ check_double_array(array_d, as.getArray_d());
+
+ as.setArray_enum(array_enum);
+ check_int_array(array_enum, as.getArray_enum());
+
+ as.setArray_struct(array_struct);
+ check_struct_array(array_struct, as.getArray_struct());
+ }
+
+ // Functions to check that the array values were set correctly
+ public static void check_string(String original, String checking) {
+ if (!checking.equals(original)) {
+ System.err.println("Runtime test failed. checking = [" + checking + "]");
+ System.exit(1);
+ }
+ }
+ public static void check_byte_array(byte[] original, byte[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ System.err.println("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ System.exit(1);
+ }
+ }
+ }
+ public static void check_short_array(short[] original, short[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ System.err.println("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ System.exit(1);
+ }
+ }
+ }
+ public static void check_int_array(int[] original, int[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ System.err.println("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ System.exit(1);
+ }
+ }
+ }
+ public static void check_long_array(long[] original, long[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ System.err.println("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ System.exit(1);
+ }
+ }
+ }
+ public static void check_float_array(float[] original, float[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ System.err.println("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ System.exit(1);
+ }
+ }
+ }
+ public static void check_double_array(double[] original, double[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ System.err.println("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ System.exit(1);
+ }
+ }
+ }
+ public static void check_struct_array(SimpleStruct[] original, SimpleStruct[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i].getDouble_field() != original[i].getDouble_field()) {
+ System.err.println("Runtime test failed. checking[" + i + "].double_field=" + checking[i].getDouble_field());
+ System.exit(1);
+ }
+ }
+ }
+}
diff --git a/Examples/test-suite/java/java_pragmas_runme.java b/Examples/test-suite/java/java_pragmas_runme.java
new file mode 100644
index 000000000..311141159
--- /dev/null
+++ b/Examples/test-suite/java/java_pragmas_runme.java
@@ -0,0 +1,15 @@
+
+import java_pragmas.*;
+
+public class java_pragmas_runme {
+
+ // No system.loadLibrary() as the JNI class will do this
+
+ public static void main(String argv[])
+ {
+ // Call a JNI class function. Normally this is not possible as the class is protected, however, the jniclassmodifiers pragma has changed this.
+ long int_pointer = java_pragmasJNI.get_int_pointer();
+
+ java_pragmas.added_function("hello");
+ }
+}
diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java
new file mode 100644
index 000000000..63b6497bc
--- /dev/null
+++ b/Examples/test-suite/java/java_throws_runme.java
@@ -0,0 +1,46 @@
+
+import java_throws.*;
+
+public class java_throws_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_throws");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // Check the exception classes in the main typemaps
+ boolean pass = false;
+
+ // This won't compile unless all of these exceptions are in the throw clause
+ try {
+ short s = java_throws.full_of_exceptions(10);
+ }
+ catch (ClassNotFoundException e) {}
+ catch (NoSuchFieldException e) { pass = true; }
+ catch (InstantiationException e) {}
+ catch (CloneNotSupportedException e) {}
+ catch (IllegalAccessException e) {}
+
+ if (!pass) {
+ System.err.println("Test 1 failed");
+ System.exit(1);
+ }
+
+ // Check the exception class in the throw typemap
+ try {
+ java_throws.throw_spec_function(100);
+ }
+ catch (IllegalAccessException e) { pass = true; }
+
+ if (!pass) {
+ System.err.println("Test 2 failed");
+ System.exit(1);
+ }
+ }
+}
diff --git a/Examples/test-suite/java/java_typemaps_proxy_runme.java b/Examples/test-suite/java/java_typemaps_proxy_runme.java
new file mode 100644
index 000000000..997e5b8d1
--- /dev/null
+++ b/Examples/test-suite/java/java_typemaps_proxy_runme.java
@@ -0,0 +1,48 @@
+
+// This is the java_typemaps_proxy runtime testcase. Contrived example checks that the pure Java code from the Java typemaps compiles.
+
+import java_typemaps_proxy.*;
+
+public class java_typemaps_proxy_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_typemaps_proxy");
+ } 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[]) {
+
+ Greeting greet = new Greeting();
+ Farewell bye = new Farewell();
+
+ // Check that pure Java methods have been added
+ greet.sayhello();
+ bye.saybye(new java.math.BigDecimal(java.math.BigInteger.ONE));
+
+ // No finalize method so may as well delete manually
+ bye.delete();
+
+ // Check that Greeting is derived from Exception
+ try {
+ throw new Greeting();
+ } catch (Greeting g) {
+ String msg = g.getMessage();
+ }
+
+ // Check that Greeting has implemented the EventListener interface
+ Greeting.cheerio(greet);
+
+ // The default getCPtr() call in each method will through an exception if null is passed.
+ // Make sure the modified version works with and without null objects.
+ Greeting.ciao(null);
+ Greeting.ciao(greet);
+
+ // Create a NULL pointer for Farewell using the constructor with changed modifiers
+ Farewell nullFarewell = new Farewell(0, false);
+ }
+}
+
diff --git a/Examples/test-suite/java/java_typemaps_typewrapper_runme.java b/Examples/test-suite/java/java_typemaps_typewrapper_runme.java
new file mode 100644
index 000000000..f6769fe20
--- /dev/null
+++ b/Examples/test-suite/java/java_typemaps_typewrapper_runme.java
@@ -0,0 +1,45 @@
+
+// This is the java_typemaps_typewrapper runtime testcase. Contrived example checks that the pure Java code generated from the Java typemaps compiles.
+
+import java_typemaps_typewrapper.*;
+
+public class java_typemaps_typewrapper_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_typemaps_typewrapper");
+ } 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_Greeting greet = SWIGTYPE_p_Greeting.CreateNullPointer();
+ SWIGTYPE_p_Farewell bye = SWIGTYPE_p_Farewell.CreateNullPointer();
+
+ // Check that pure Java methods have been added
+ greet.sayhello();
+ bye.saybye(new java.math.BigDecimal(java.math.BigInteger.ONE));
+
+ // Check that SWIGTYPE_p_Greeting is derived from Exception
+ try {
+ throw SWIGTYPE_p_Greeting.CreateNullPointer();
+ } catch (SWIGTYPE_p_Greeting g) {
+ String msg = g.getMessage();
+ }
+
+ // Check that SWIGTYPE_p_Greeting has implemented the EventListener interface
+ SWIGTYPE_p_Greeting.cheerio(greet);
+
+ // The default getCPtr() call in each method will through an exception if null is passed.
+ // Make sure the modified version works with and without null objects.
+ java_typemaps_typewrapper.solong(null);
+ java_typemaps_typewrapper.solong(bye);
+
+ // Create a NULL pointer for Farewell using the constructor with changed modifiers
+ SWIGTYPE_p_Farewell nullFarewell = new SWIGTYPE_p_Farewell(0, false);
+ }
+}
+
diff --git a/Examples/test-suite/java/lib_typemaps_runme.java b/Examples/test-suite/java/lib_typemaps_runme.java
new file mode 100644
index 000000000..443886748
--- /dev/null
+++ b/Examples/test-suite/java/lib_typemaps_runme.java
@@ -0,0 +1,85 @@
+
+// Check a few of the INPUT, OUTPUT and INOUT typemaps.
+
+import lib_typemaps.*;
+import java.math.*;
+
+public class lib_typemaps_runme {
+
+ static {
+ try {
+ System.loadLibrary("lib_typemaps");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // Check double INPUT typemaps
+ if (lib_typemaps.in_double(22.22) != 22.22) exit_test("in_double");
+ if (lib_typemaps.inr_double(22.22) != 22.22) exit_test("inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double[] var = {44.44};
+ lib_typemaps.out_double(22.22, var);
+ if (var[0] != 22.22) exit_test("out_double");
+ }
+ {
+ double[] var = {44.44};
+ lib_typemaps.outr_double(22.22, var);
+ if (var[0] != 22.22) exit_test("outr_double");
+ }
+
+ // Check double INOUT typemaps
+ {
+ double[] var = {44.44};
+ lib_typemaps.inout_double(var);
+ if (var[0] != 44.44) exit_test("inout_double");
+ }
+ {
+ double[] var = {44.44};
+ lib_typemaps.inoutr_double(var);
+ if (var[0] != 44.44) exit_test("inoutr_double");
+ }
+
+
+ // Check unsigned long long INPUT typemaps
+ BigInteger forty = new BigInteger("40");
+ BigInteger twenty = new BigInteger("20");
+ if (!lib_typemaps.in_ulonglong(twenty).equals(twenty)) exit_test("in_ulonglong");
+ if (!lib_typemaps.inr_ulonglong(twenty).equals(twenty)) exit_test("inr_ulonglong");
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ lib_typemaps.out_ulonglong(twenty, var);
+ if (!var[0].equals(twenty)) exit_test("out_ulonglong");
+ }
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ lib_typemaps.outr_ulonglong(twenty, var);
+ if (!var[0].equals(twenty)) exit_test("outr_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ lib_typemaps.inout_ulonglong(var);
+ if (!var[0].equals(forty)) exit_test("inout_ulonglong");
+ }
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ lib_typemaps.inoutr_ulonglong(var);
+ if (!var[0].equals(forty)) exit_test("inoutr_ulonglong");
+ }
+ }
+
+ private static void exit_test(String funcName) {
+ System.err.println("Test FAILED in function " + funcName);
+ System.exit(1);
+ }
+}
+
diff --git a/Examples/test-suite/java/long_long_runme.java b/Examples/test-suite/java/long_long_runme.java
new file mode 100644
index 000000000..2be4cb125
--- /dev/null
+++ b/Examples/test-suite/java/long_long_runme.java
@@ -0,0 +1,50 @@
+
+// This is the long_long runtime testcase. It checks that the long long and
+// unsigned long long types map correctly to long and BigInteger respectively.
+
+import long_long.*;
+import java.math.*;
+
+public class long_long_runme {
+
+ static {
+ try {
+ System.loadLibrary("long_long");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ check_ll(0L);
+ check_ll(0x7FFFFFFFFFFFFFFFL);
+ check_ll(-10);
+
+ check_ull(new BigInteger("0"));
+ check_ull(new BigInteger("127"));
+ check_ull(new BigInteger("128"));
+ check_ull(new BigInteger("9223372036854775807")); //0x7FFFFFFFFFFFFFFFL
+ check_ull(new BigInteger("18446744073709551615")); //0xFFFFFFFFFFFFFFFFL
+ }
+
+ public static void check_ll(long ll) {
+ long_long.setLl(ll);
+ long ll_check = long_long.getLl();
+ if (ll != ll_check) {
+ System.err.println("Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check);
+ System.exit(1);
+ }
+ }
+
+ public static void check_ull(BigInteger ull) {
+ long_long.setUll(ull);
+ BigInteger ull_check = long_long.getUll();
+ if (ull.compareTo(ull_check) != 0) {
+ System.err.println("Runtime test using unsigned long long failed. ull=" + ull.toString() + " ull_check=" + ull_check.toString());
+ System.exit(1);
+ }
+ }
+}
+
diff --git a/Examples/test-suite/java/primitive_ref_runme.java b/Examples/test-suite/java/primitive_ref_runme.java
new file mode 100644
index 000000000..ec28c8616
--- /dev/null
+++ b/Examples/test-suite/java/primitive_ref_runme.java
@@ -0,0 +1,64 @@
+// Check that C++ primitive types that are passed by const reference work when
+// passed by value from Java
+
+import primitive_ref.*;
+import java.math.*;
+
+public class primitive_ref_runme {
+
+ static {
+ try {
+ System.loadLibrary("primitive_ref");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ if (primitive_ref.ref_int(3) != 3) {
+ System.err.println( "ref_int failed!" );
+ }
+ if (primitive_ref.ref_uint(3) != 3) {
+ System.err.println( "ref_uint failed!" );
+ }
+ if (primitive_ref.ref_short((short)3) != 3) {
+ System.err.println( "ref_short failed!" );
+ }
+ if (primitive_ref.ref_ushort(3) != 3) {
+ System.err.println( "ref_ushort failed!" );
+ }
+ if (primitive_ref.ref_long(3) != 3) {
+ System.err.println( "ref_long failed!" );
+ }
+ if (primitive_ref.ref_ulong(3) != 3) {
+ System.err.println( "ref_ulong failed!" );
+ }
+ if (primitive_ref.ref_schar((byte)3) != 3) {
+ System.err.println( "ref_schar failed!" );
+ }
+ if (primitive_ref.ref_uchar((short)3) != 3) {
+ System.err.println( "ref_uchar failed!" );
+ }
+ if (primitive_ref.ref_bool(true) != true) {
+ System.err.println( "ref_bool failed!" );
+ }
+ if (primitive_ref.ref_float((float)3.5) != 3.5) {
+ System.err.println( "ref_float failed!" );
+ }
+ if (primitive_ref.ref_double(3.5) != 3.5) {
+ System.err.println( "ref_double failed!" );
+ }
+ if (primitive_ref.ref_char('x') != 'x') {
+ System.err.println( "ref_char failed!" );
+ }
+ if (primitive_ref.ref_longlong(3) != '3') {
+ System.err.println( "ref_longlong failed!" );
+ }
+ BigInteger bi = new BigInteger("18446744073709551615"); //0xFFFFFFFFFFFFFFFFL
+ if (bi.compareTo(primitive_ref.ref_ulonglong(bi)) != 0) {
+ System.err.println( "ref_ulonglong failed!" );
+ }
+ }
+}
diff --git a/Examples/test-suite/java/ret_by_value_runme.java b/Examples/test-suite/java/ret_by_value_runme.java
new file mode 100644
index 000000000..44bb69796
--- /dev/null
+++ b/Examples/test-suite/java/ret_by_value_runme.java
@@ -0,0 +1,33 @@
+
+// This is the ret_by_value runtime testcase. It checks that SWIG handles
+// return by value okay.
+
+import ret_by_value.*;
+
+public class ret_by_value_runme {
+
+ static {
+ try {
+ System.loadLibrary("ret_by_value");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // Get the test class. Note that this constructor will ensure that the memory created
+ // in the wrapper is owned by the test class.
+ test tst = ret_by_value.get_test();
+
+ if (tst.getMyInt() != 100 || tst.getMyShort() != 200) {
+ System.err.println("Runtime test failed. myInt=" + tst.getMyInt() + " myShort=" + tst.getMyShort());
+ System.exit(1);
+ }
+
+ // Delete memory manually, it should not be deleted again by the test class finalizer
+ tst.delete();
+ }
+}
+
diff --git a/Examples/test-suite/java/template_classes_runme.java b/Examples/test-suite/java/template_classes_runme.java
new file mode 100644
index 000000000..d81f7988d
--- /dev/null
+++ b/Examples/test-suite/java/template_classes_runme.java
@@ -0,0 +1,25 @@
+
+// This is the template_classes runtime testcase. It checks that SWIG handles a templated
+// class used by another templated class, in particular that the shadow classes can be used.
+
+import template_classes.*;
+
+public class template_classes_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_classes");
+ } 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[]) {
+
+ RectangleInt rectint = new RectangleInt();
+ PointInt pi = rectint.getPoint();
+ int x = pi.getX();
+ }
+}
+
diff --git a/Examples/test-suite/java/unions_runme.java b/Examples/test-suite/java/unions_runme.java
new file mode 100644
index 000000000..16a5b3b87
--- /dev/null
+++ b/Examples/test-suite/java/unions_runme.java
@@ -0,0 +1,68 @@
+
+// This is the union runtime testcase. It ensures that values within a
+// union embedded within a struct can be set and read correctly.
+
+import unions.*;
+
+public class unions_runme {
+
+ static {
+ try {
+ System.loadLibrary("unions");
+ } 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 new instances of SmallStruct and BigStruct for later use
+ SmallStruct small = new SmallStruct();
+ small.setJill((short)200);
+
+ BigStruct big = new BigStruct();
+ big.setSmallstruct(small);
+ big.setJack(300);
+
+ // Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+ // Ensure values in EmbeddedUnionTest are set correctly for each.
+ EmbeddedUnionTest eut = new EmbeddedUnionTest();
+
+ // First check the SmallStruct in EmbeddedUnionTest
+ eut.setNumber(1);
+ eut.getUni().setSmall(small);
+ short Jill1 = eut.getUni().getSmall().getJill();
+ if (Jill1 != 200) {
+ System.err.println("Runtime test1 failed. eut.uni.small.jill=" + Jill1);
+ System.exit(1);
+ }
+
+ int Num1 = eut.getNumber();
+ if (Num1 != 1) {
+ System.err.println("Runtime test2 failed. eut.number=" + Num1);
+ System.exit(1);
+ }
+
+ // Secondly check the BigStruct in EmbeddedUnionTest
+ eut.setNumber(2);
+ eut.getUni().setBig(big);
+ int Jack1 = eut.getUni().getBig().getJack();
+ if (Jack1 != 300) {
+ System.err.println("Runtime test3 failed. eut.uni.big.jack=" + Jack1);
+ System.exit(1);
+ }
+
+ short Jill2 = eut.getUni().getBig().getSmallstruct().getJill();
+ if (Jill2 != 200) {
+ System.err.println("Runtime test4 failed. eut.uni.big.smallstruct.jill=" + Jill2);
+ System.exit(1);
+ }
+
+ int Num2 = eut.getNumber();
+ if (Num2 != 2) {
+ System.err.println("Runtime test5 failed. eut.number=" + Num2);
+ System.exit(1);
+ }
+}
+}
diff --git a/Examples/test-suite/java_constants.i b/Examples/test-suite/java_constants.i
new file mode 100644
index 000000000..d3cd48f17
--- /dev/null
+++ b/Examples/test-suite/java_constants.i
@@ -0,0 +1,30 @@
+
+// This testcase uses the %javaconst directive to control how constants are initialised
+
+%module java_constants
+
+
+%constant short DIPSTICK=100;
+
+// Set default Java const code generation
+%javaconst(1);
+
+// Modify the code generation to use JNI function call initialisation for some difficult cases
+%javaconst(0) TOM;
+%javaconst(0) ORCHESTRA_STALLS;
+%javaconst(0) PORKY;
+
+%inline %{
+#define CHINA 2*100
+#define TOM 300ULL
+#define ORCHESTRA_STALLS 400LL
+#define JAM_JAR "500"
+#define OXO '6'
+#define PORKY !7
+%}
+
+%constant int BRISTOLS=800;
+
+%javaconst(0);
+%constant long long ROSY=900LL;
+
diff --git a/Examples/test-suite/java_jnitypes.i b/Examples/test-suite/java_jnitypes.i
new file mode 100644
index 000000000..bc405793d
--- /dev/null
+++ b/Examples/test-suite/java_jnitypes.i
@@ -0,0 +1,29 @@
+
+// This testcase tests the JNI types
+
+%module java_jnitypes
+
+%inline %{
+
+jboolean jnifunc(jboolean in) { return in; }
+jchar jnifunc(jchar in) { return in; }
+jbyte jnifunc(jbyte in) { return in; }
+jshort jnifunc(jshort in) { return in; }
+jint jnifunc(jint in) { return in; }
+jlong jnifunc(jlong in) { return in; }
+jfloat jnifunc(jfloat in) { return in; }
+jdouble jnifunc(jdouble in) { return in; }
+jstring jnifunc(jstring in) { return in; }
+jobject jnifunc(jobject in) { return in; }
+jbooleanArray jnifunc(jbooleanArray in) { return in; }
+jcharArray jnifunc(jcharArray in) { return in; }
+jbyteArray jnifunc(jbyteArray in) { return in; }
+jshortArray jnifunc(jshortArray in) { return in; }
+jintArray jnifunc(jintArray in) { return in; }
+jlongArray jnifunc(jlongArray in) { return in; }
+jfloatArray jnifunc(jfloatArray in) { return in; }
+jdoubleArray jnifunc(jdoubleArray in) { return in; }
+jobjectArray jnifunc(jobjectArray in) { return in; }
+
+%}
+
diff --git a/Examples/test-suite/java_lib_arrays.i b/Examples/test-suite/java_lib_arrays.i
new file mode 100644
index 000000000..724edb87c
--- /dev/null
+++ b/Examples/test-suite/java_lib_arrays.i
@@ -0,0 +1,11 @@
+/* Testcase for the Java array typemaps which are not used by default. */
+%module java_lib_arrays
+
+/* Use the Java library typemaps */
+%include "arrays_java.i"
+
+JAVA_ARRAYSOFCLASSES(SimpleStruct)
+%apply ARRAYSOFENUMS[ANY] { finger[ANY] }
+
+%include "arrays.i"
+
diff --git a/Examples/test-suite/java_pragmas.i b/Examples/test-suite/java_pragmas.i
new file mode 100644
index 000000000..5e86c08ad
--- /dev/null
+++ b/Examples/test-suite/java_pragmas.i
@@ -0,0 +1,48 @@
+
+// Test case uses all the Java pragmas which are for tailoring the generated JNI class and Java module class.
+
+%module java_pragmas
+
+%pragma(java) jniclassimports=%{
+import java.lang.*; // For Exception
+%}
+
+%pragma(java) jniclassclassmodifiers="public"
+%pragma(java) jniclassbase="Exception"
+%pragma(java) jniclassinterfaces="Cloneable"
+
+%pragma(java) jniclasscode=%{
+ // jniclasscode pragma code: Static block so that the JNI class loads the C++ DLL/shared object when the class is loaded
+ static {
+ try {
+ System.loadLibrary("java_pragmas");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+%}
+
+
+%pragma(java) moduleimports=%{
+import java.io.*; // For Serializable
+%}
+
+%pragma(java) moduleclassmodifiers="public final"
+%pragma(java) modulebase="Object"
+%pragma(java) moduleinterfaces="Serializable"
+
+%pragma(java) modulecode=%{
+ public static void added_function(String s) {
+ // Added function
+ }
+%}
+
+
+%inline %{
+int *get_int_pointer() {
+ static int number = 10;
+ return &number;
+}
+%}
+
diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i
new file mode 100644
index 000000000..7f342410c
--- /dev/null
+++ b/Examples/test-suite/java_throws.i
@@ -0,0 +1,41 @@
+// Test to check the exception classes in the throws attribute of the typemaps is working
+
+%module java_throws
+
+// Exceptions are chosen at random but are ones which have to have a try catch block to compile
+%typemap(in, throws=" ClassNotFoundException") int num {
+ $1 = (int)$input;
+}
+%typemap(freearg, throws="InstantiationException ") int num "/*not written*/"
+%typemap(argout, throws="CloneNotSupportedException ") int num "/*not written*/"
+%typemap(check, throws="NoSuchFieldException") int num {
+ if ($input == 10) {
+ jenv->ExceptionClear();
+ jclass excep = jenv->FindClass("java/lang/NoSuchFieldException");
+ if (excep)
+ jenv->ThrowNew(excep, "Value of 10 not acceptable");
+ }
+}
+
+// Duplicate exceptions should be removed from the generated throws clause
+%typemap(out, throws="IllegalAccessException, NoSuchFieldException, CloneNotSupportedException ") short {
+ $result = (jshort)$1;
+}
+
+%inline %{
+short full_of_exceptions(int num) {
+ return 0;
+}
+%}
+
+
+%typemap(throws, throws="IllegalAccessException") int {
+ jclass excep = jenv->FindClass("java/lang/IllegalAccessException");
+ if (excep)
+ jenv->ThrowNew(excep, "Test exception");
+ return $null;
+}
+%inline %{
+void throw_spec_function(int value) throw (int) { throw (int)0; }
+%}
+
diff --git a/Examples/test-suite/java_typemaps_proxy.i b/Examples/test-suite/java_typemaps_proxy.i
new file mode 100644
index 000000000..e5b317b0b
--- /dev/null
+++ b/Examples/test-suite/java_typemaps_proxy.i
@@ -0,0 +1,53 @@
+/* Tests the Java specific directives */
+
+%module java_typemaps_proxy
+
+
+%typemap(javaimports) SWIGTYPE "import java.math.*;";
+%typemap(javacode) Farewell %{
+ public void saybye(BigDecimal num_times) {
+ // BigDecimal requires the java.math library
+ }
+%}
+%typemap(javaclassmodifiers) Farewell "public final";
+
+%typemap(javaimports) Greeting %{
+import java.util.*; // for EventListener
+import java.lang.*; // for Exception
+%};
+
+%typemap(javabase) Greeting "Exception";
+%typemap(javainterfaces) Greeting "EventListener";
+%typemap(javacode) Greeting %{
+ // Pure Java code generated using %typemap(javacode)
+ public void sayhello() {
+ hello();
+ }
+
+ public static void cheerio(EventListener e) {
+ }
+%}
+
+// Create a new getCPtr() function which takes Java null
+%typemap(javagetcptr) Greeting %{
+ public static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+// get rid of the finalize method for Farewell
+%typemap(javafinalize) Farewell "";
+
+// Make the pointer constructor public
+%typemap(javaptrconstructormodifiers) Farewell "public";
+
+
+%inline %{
+class Greeting {
+public:
+ void hello() {}
+ static void ciao(Greeting* g) {}
+};
+class Farewell {
+};
+%}
diff --git a/Examples/test-suite/java_typemaps_typewrapper.i b/Examples/test-suite/java_typemaps_typewrapper.i
new file mode 100644
index 000000000..b8fd4cb92
--- /dev/null
+++ b/Examples/test-suite/java_typemaps_typewrapper.i
@@ -0,0 +1,57 @@
+/* Contrived example to test the Java specific directives on the type wrapper classes */
+
+%module java_typemaps_typewrapper
+
+
+%typemap(javaimports) SWIGTYPE * "import java.math.*;";
+%typemap(javacode) Farewell * %{
+ public static $javaclassname CreateNullPointer() {
+ return new $javaclassname();
+ }
+ public void saybye(BigDecimal num_times) {
+ // BigDecimal requires the java.math library
+ }
+%}
+%typemap(javaclassmodifiers) Farewell * "public final";
+
+%typemap(javaimports) Greeting * %{
+import java.util.*; // for EventListener
+import java.lang.*; // for Exception
+%};
+
+%typemap(javabase) Greeting * "Exception";
+%typemap(javainterfaces) Greeting * "EventListener";
+%typemap(javacode) Greeting * %{
+ // Pure Java code generated using %typemap(javacode)
+ public static $javaclassname CreateNullPointer() {
+ return new $javaclassname();
+ }
+
+ public void sayhello() {
+ $javaclassname.cheerio(new $javaclassname());
+ }
+
+ public static void cheerio(EventListener e) {
+ }
+%}
+
+// Create a new getCPtr() function which takes Java null
+%typemap(javagetcptr) Farewell * %{
+ public static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+// Make the pointer constructor public
+%typemap(javaptrconstructormodifiers) Farewell * "public";
+
+
+%{
+class Greeting {};
+class Farewell {};
+%}
+
+%inline %{
+ Greeting* solong(Farewell* f) { return NULL; }
+%}
+
diff --git a/Examples/test-suite/kind.i b/Examples/test-suite/kind.i
new file mode 100644
index 000000000..faaf4c369
--- /dev/null
+++ b/Examples/test-suite/kind.i
@@ -0,0 +1,34 @@
+/*
+ * This interface file tests whether the language modules handle the kind when declared
+ * with the function/member name, especially when used with shadow classes.
+*/
+
+%module kind
+
+%warnfilter(801) foo; /* Ruby, wrong class name */
+%warnfilter(801) bar; /* Ruby, wrong class name */
+%warnfilter(801) uni; /* Ruby, wrong class name */
+%warnfilter(801) test; /* Ruby, wrong class name */
+
+%inline %{
+
+class foo {};
+struct bar {};
+union uni {};
+
+struct test {
+ void foofn(class foo myfoo1, foo myfoo2, class foo* myfoo3, foo* myfoo4, class foo& myfoo5, foo& myfoo6) {}
+ void barfn(struct bar mybar1, bar mybar2, struct bar* mybar3, bar* mybar4, struct bar& mybar5, bar& mybar6) {}
+ void unifn(union uni myuni1, uni myuni2, union uni* myuni3, uni* myuni4, union myuni& myuni5, myuni& myuni6) {}
+
+ class foo myFooMember;
+ struct bar myBarMember;
+ union uni myUniMember;
+
+ class foo* mypFooMember;
+ struct bar* mypBarMember;
+ union uni* mypUniMember;
+};
+
+%}
+
diff --git a/Examples/test-suite/lib_carrays.i b/Examples/test-suite/lib_carrays.i
new file mode 100644
index 000000000..ef2f9abed
--- /dev/null
+++ b/Examples/test-suite/lib_carrays.i
@@ -0,0 +1,9 @@
+%module lib_carrays
+
+%warnfilter(801) doubleArray; /* Ruby, wrong class name */
+
+%include "carrays.i"
+
+%array_functions(int,intArray);
+%array_class(double, doubleArray);
+
diff --git a/Examples/test-suite/lib_cdata.i b/Examples/test-suite/lib_cdata.i
new file mode 100644
index 000000000..8a26d94b3
--- /dev/null
+++ b/Examples/test-suite/lib_cdata.i
@@ -0,0 +1,8 @@
+%module lib_cdata
+
+%include "cdata.i"
+
+%cdata(int);
+%cdata(double);
+
+
diff --git a/Examples/test-suite/lib_cmalloc.i b/Examples/test-suite/lib_cmalloc.i
new file mode 100644
index 000000000..f37cf6373
--- /dev/null
+++ b/Examples/test-suite/lib_cmalloc.i
@@ -0,0 +1,12 @@
+%module lib_cmalloc
+
+%warnfilter(801) sizeof_int; /* Ruby, wrong constant name */
+%warnfilter(801) sizeof_double; /* Ruby, wrong constant name */
+%warnfilter(801) sizeof_intp; /* Ruby, wrong constant name */
+
+%include "cmalloc.i"
+
+%allocators(int);
+%allocators(double);
+%allocators(void);
+%allocators(int *, intp);
diff --git a/Examples/test-suite/lib_constraints.i b/Examples/test-suite/lib_constraints.i
new file mode 100644
index 000000000..4cef26700
--- /dev/null
+++ b/Examples/test-suite/lib_constraints.i
@@ -0,0 +1,32 @@
+%module lib_constraints
+%include constraints.i
+
+%inline %{
+void test_nonnegative(double NONNEGATIVE) {
+}
+
+void test_nonpositive(double NONPOSITIVE) {
+}
+
+void test_positive(double POSITIVE) {
+}
+
+void test_negative(double POSITIVE) {
+}
+
+void test_nonzero(double NONZERO) {
+}
+
+void test_nonnull(void *NONNULL) {
+}
+
+void test_align8(void *ALIGN8) {
+}
+
+void test_align4(void *ALIGN4) {
+}
+
+void test_align2(void *ALIGN2) {
+}
+%}
+
diff --git a/Examples/test-suite/lib_cpointer.i b/Examples/test-suite/lib_cpointer.i
new file mode 100644
index 000000000..e1e6f48f9
--- /dev/null
+++ b/Examples/test-suite/lib_cpointer.i
@@ -0,0 +1,10 @@
+%module lib_cpointer
+
+%warnfilter(801) doublep; /* Ruby, wrong class name */
+
+%include "cpointer.i"
+
+%pointer_functions(int,intp);
+%pointer_class(double,doublep);
+%pointer_cast(int, unsigned int, int_to_uint);
+
diff --git a/Examples/test-suite/lib_cstring.i b/Examples/test-suite/lib_cstring.i
new file mode 100644
index 000000000..4ddbe2920
--- /dev/null
+++ b/Examples/test-suite/lib_cstring.i
@@ -0,0 +1,88 @@
+%module lib_cstring
+
+%include "cstring.i"
+
+#ifndef _CSTRING_UNIMPL
+
+%cstring_input_binary(char *in, int n);
+%cstring_bounded_output(char *out1, 512);
+%cstring_chunk_output(char *out2, 128);
+%cstring_bounded_mutable(char *out3, 512);
+%cstring_mutable(char *out4, 32);
+%cstring_output_maxsize(char *out5, int max);
+%cstring_output_withsize(char *out6, int *size);
+%cstring_output_allocate(char **out7, delete [] $1);
+%cstring_output_allocate_size(char **out8, int *size, delete [] $1);
+
+%inline %{
+
+int count(char *in, int n, char c) {
+ int r = 0;
+ while (n > 0) {
+ if (*in == c) {
+ r++;
+ }
+ in++;
+ }
+ return r;
+}
+
+void test1(char *out1) {
+ strcpy(out1,"Hello World");
+}
+
+void test2(char *out2) {
+ int i;
+ for (i = 0; i < 128; i++) {
+ *out2 = (char) i;
+ out2++;
+ }
+}
+
+void test3(char *out3) {
+ strcat(out3,"-suffix");
+}
+
+void test4(char *out4) {
+ strcat(out4,"-suffix");
+}
+
+void test5(char *out5, int max) {
+ int i;
+ for (i = strlen(out5); i < max; i++) {
+ out5[i] = 'x';
+ }
+}
+
+void test6(char *out6, int *size) {
+ int i;
+ for (i = 0; i < (*size/2); i++) {
+ out6[i] = 'x';
+ }
+ *size = (*size/2);
+}
+
+void test7(char **out7) {
+ *out7 = new char[64];
+ strcat(*out7,"Hello world!");
+}
+
+void test8(char **out8, int *sz) {
+ int i;
+ *out8 = new char[128];
+ for (i = 0; i < 128; i++) {
+ *out8[i] = (char) i;
+ }
+}
+
+%}
+
+#endif
+
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/lib_math.i b/Examples/test-suite/lib_math.i
new file mode 100644
index 000000000..8e5cd0db6
--- /dev/null
+++ b/Examples/test-suite/lib_math.i
@@ -0,0 +1,2 @@
+%module lib_math
+%include math.i
diff --git a/Examples/test-suite/lib_std_deque.i b/Examples/test-suite/lib_std_deque.i
new file mode 100644
index 000000000..c0cfee020
--- /dev/null
+++ b/Examples/test-suite/lib_std_deque.i
@@ -0,0 +1,47 @@
+%module lib_std_deque
+
+%include "std_deque.i"
+
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+
+namespace std {
+ %template(IntDeque) deque<int>;
+}
+
+%template(DoubleDeque) std::deque<double>;
+
+%inline %{
+typedef float Real;
+%}
+
+namespace std {
+ %template(RealDeque) deque<Real>;
+}
+
+%inline %{
+
+double average(std::deque<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::deque<float> half(const std::deque<float>& v) {
+ std::deque<float> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::deque<double>& v) {
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+%}
+
+
+
+
diff --git a/Examples/test-suite/lib_std_string.i b/Examples/test-suite/lib_std_string.i
new file mode 100644
index 000000000..bcbf3ba75
--- /dev/null
+++ b/Examples/test-suite/lib_std_string.i
@@ -0,0 +1,20 @@
+%module lib_std_string
+%include "std_string.i"
+
+%inline %{
+
+std::string test_value(std::string x) {
+ return x;
+}
+
+std::string *test_pointer(std::string *x) {
+ return x;
+}
+
+std::string test_reference(std::string &x) {
+ return x;
+}
+
+%}
+
+
diff --git a/Examples/test-suite/lib_std_vector.i b/Examples/test-suite/lib_std_vector.i
new file mode 100644
index 000000000..faff99b1f
--- /dev/null
+++ b/Examples/test-suite/lib_std_vector.i
@@ -0,0 +1,47 @@
+%module lib_std_vector
+
+%include "std_vector.i"
+
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+
+namespace std {
+ %template(IntVector) vector<int>;
+}
+
+%template(DoubleVector) std::vector<double>;
+
+%inline %{
+typedef float Real;
+%}
+
+namespace std {
+ %template(RealVector) vector<Real>;
+}
+
+%inline %{
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<float> half(const std::vector<float>& v) {
+ std::vector<float> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::vector<double>& v) {
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+%}
+
+
+
+
diff --git a/Examples/test-suite/lib_typemaps.i b/Examples/test-suite/lib_typemaps.i
new file mode 100644
index 000000000..da4e48e28
--- /dev/null
+++ b/Examples/test-suite/lib_typemaps.i
@@ -0,0 +1,95 @@
+%module lib_typemaps
+
+%include "typemaps.i"
+
+%inline %{
+
+bool in_bool(bool *INPUT) { return *INPUT; }
+int in_int(int *INPUT) { return *INPUT; }
+long in_long(long *INPUT) { return *INPUT; }
+short in_short(short *INPUT) { return *INPUT; }
+unsigned int in_uint(unsigned int *INPUT) { return *INPUT; }
+unsigned short in_ushort(unsigned short *INPUT) { return *INPUT; }
+unsigned long in_ulong(unsigned long *INPUT) { return *INPUT; }
+unsigned char in_uchar(unsigned char *INPUT) { return *INPUT; }
+signed char in_schar(signed char *INPUT) { return *INPUT; }
+float in_float(float *INPUT) { return *INPUT; }
+double in_double(double *INPUT) { return *INPUT; }
+long long in_longlong(long long *INPUT) { return *INPUT; }
+unsigned long long in_ulonglong(unsigned long long *INPUT) { return *INPUT; }
+
+bool inr_bool(bool &INPUT) { return INPUT; }
+int inr_int(int &INPUT) { return INPUT; }
+long inr_long(long &INPUT) { return INPUT; }
+short inr_short(short &INPUT) { return INPUT; }
+unsigned int inr_uint(unsigned int &INPUT) { return INPUT; }
+unsigned short inr_ushort(unsigned short &INPUT) { return INPUT; }
+unsigned long inr_ulong(unsigned long &INPUT) { return INPUT; }
+unsigned char inr_uchar(unsigned char &INPUT) { return INPUT; }
+signed char inr_schar(signed char &INPUT) { return INPUT; }
+float inr_float(float &INPUT) { return INPUT; }
+double inr_double(double &INPUT) { return INPUT; }
+long long inr_longlong(long long &INPUT) { return INPUT; }
+unsigned long long inr_ulonglong(unsigned long long &INPUT) { return INPUT; }
+
+void out_bool(bool x, bool *OUTPUT) { *OUTPUT = x; }
+void out_int(int x, int *OUTPUT) { *OUTPUT = x; }
+void out_short(short x, short *OUTPUT) { *OUTPUT = x; }
+void out_long(long x, long *OUTPUT) { *OUTPUT = x; }
+void out_uint(unsigned int x, unsigned int *OUTPUT) { *OUTPUT = x; }
+void out_ushort(unsigned short x, unsigned short *OUTPUT) { *OUTPUT = x; }
+void out_ulong(unsigned long x, unsigned long *OUTPUT) { *OUTPUT = x; }
+void out_uchar(unsigned char x, unsigned char *OUTPUT) { *OUTPUT = x; }
+void out_schar(signed char x, signed char *OUTPUT) { *OUTPUT = x; }
+void out_float(float x, float *OUTPUT) { *OUTPUT = x; }
+void out_double(double x, double *OUTPUT) { *OUTPUT = x; }
+void out_longlong(long long x, long long *OUTPUT) { *OUTPUT = x; }
+void out_ulonglong(unsigned long long x, unsigned long long *OUTPUT) { *OUTPUT = x; }
+
+void outr_bool(bool x, bool &OUTPUT) { OUTPUT = x; }
+void outr_int(int x, int &OUTPUT) { OUTPUT = x; }
+void outr_short(short x, short &OUTPUT) { OUTPUT = x; }
+void outr_long(long x, long &OUTPUT) { OUTPUT = x; }
+void outr_uint(unsigned int x, unsigned int &OUTPUT) { OUTPUT = x; }
+void outr_ushort(unsigned short x, unsigned short &OUTPUT) { OUTPUT = x; }
+void outr_ulong(unsigned long x, unsigned long &OUTPUT) { OUTPUT = x; }
+void outr_uchar(unsigned char x, unsigned char &OUTPUT) { OUTPUT = x; }
+void outr_schar(signed char x, signed char &OUTPUT) { OUTPUT = x; }
+void outr_float(float x, float &OUTPUT) { OUTPUT = x; }
+void outr_double(double x, double &OUTPUT) { OUTPUT = x; }
+void outr_longlong(long long x, long long &OUTPUT) { OUTPUT = x; }
+void outr_ulonglong(unsigned long long x, unsigned long long &OUTPUT) { OUTPUT = x; }
+
+void inout_bool(bool *INOUT) { *INOUT = *INOUT; }
+void inout_int(int *INOUT) { *INOUT = *INOUT; }
+void inout_short(short *INOUT) { *INOUT = *INOUT; }
+void inout_long(long *INOUT) { *INOUT = *INOUT; }
+void inout_uint(unsigned int *INOUT) { *INOUT = *INOUT; }
+void inout_ushort(unsigned short *INOUT) { *INOUT = *INOUT; }
+void inout_ulong(unsigned long *INOUT) { *INOUT = *INOUT; }
+void inout_uchar(unsigned char *INOUT) { *INOUT = *INOUT; }
+void inout_schar(signed char *INOUT) { *INOUT = *INOUT; }
+void inout_float(float *INOUT) { *INOUT = *INOUT; }
+void inout_double(double *INOUT) { *INOUT = *INOUT; }
+void inout_longlong(long long *INOUT) { *INOUT = *INOUT; }
+void inout_ulonglong(unsigned long long *INOUT) { *INOUT = *INOUT; }
+
+void inoutr_bool(bool &INOUT) { INOUT = INOUT; }
+void inoutr_int(int &INOUT) { INOUT = INOUT; }
+void inoutr_short(short &INOUT) { INOUT = INOUT; }
+void inoutr_long(long &INOUT) { INOUT = INOUT; }
+void inoutr_uint(unsigned int &INOUT) { INOUT = INOUT; }
+void inoutr_ushort(unsigned short &INOUT) { INOUT = INOUT; }
+void inoutr_ulong(unsigned long &INOUT) { INOUT = INOUT; }
+void inoutr_uchar(unsigned char &INOUT) { INOUT = INOUT; }
+void inoutr_schar(signed char &INOUT) { INOUT = INOUT; }
+void inoutr_float(float &INOUT) { INOUT = INOUT; }
+void inoutr_double(double &INOUT) { INOUT = INOUT; }
+void inoutr_longlong(long long &INOUT) { INOUT = INOUT; }
+void inoutr_ulonglong(unsigned long long &INOUT) { INOUT = INOUT; }
+
+%}
+
+
+
+
diff --git a/Examples/test-suite/list_vector.i b/Examples/test-suite/list_vector.i
new file mode 100644
index 000000000..5cc30e982
--- /dev/null
+++ b/Examples/test-suite/list_vector.i
@@ -0,0 +1,153 @@
+/* -*- c -*- */
+
+%module test
+
+%include "list-vector.i"
+
+%multiple_values
+
+/* The ordinary, well behaved multi-typemap. */
+double sum_list(int LISTLENINPUT, double *LISTINPUT);
+double sum_vector(int VECTORLENINPUT, double *VECTORINPUT);
+void one_to_seven_list(int *LISTLENOUTPUT, int **LISTOUTPUT);
+void one_to_seven_vector(int *VECTORLENOUTPUT, int **VECTOROUTPUT);
+
+/* Variants with `size_t' instead of `int' length. */
+double sum_list2(size_t LISTLENINPUT, double *LISTINPUT);
+double sum_vector2(size_t VECTORLENINPUT, double *VECTORINPUT);
+void one_to_seven_list2(size_t *LISTLENOUTPUT, int **LISTOUTPUT);
+void one_to_seven_vector2(size_t *VECTORLENOUTPUT, int **VECTOROUTPUT);
+
+/* Parallel variants */
+
+double sum_lists(int PARALLEL_LISTLENINPUT,
+ double *PARALLEL_LISTINPUT,
+ int *PARALLEL_LISTINPUT,
+ int *PARALLEL_LISTINPUT);
+double sum_lists2(size_t PARALLEL_LISTLENINPUT,
+ double *PARALLEL_LISTINPUT,
+ int *PARALLEL_LISTINPUT,
+ int *PARALLEL_LISTINPUT);
+void produce_lists(int *PARALLEL_VECTORLENOUTPUT,
+ int **PARALLEL_VECTOROUTPUT,
+ int **PARALLEL_VECTOROUTPUT,
+ double **PARALLEL_VECTOROUTPUT);
+
+%{
+ double sum_list(int length, double *item)
+ {
+ int i;
+ double res = 0.0;
+ for (i = 0; i<length; i++)
+ res += item[i];
+ return res;
+ }
+
+ double sum_list2(size_t length, double *item)
+ {
+ size_t i;
+ double res = 0.0;
+ for (i = 0; i<length; i++)
+ res += item[i];
+ return res;
+ }
+
+
+ double sum_vector(int length, double *item)
+ {
+ int i;
+ double res = 0.0;
+ for (i = 0; i<length; i++)
+ res += item[i];
+ return res;
+ }
+
+ double sum_vector2(size_t length, double *item)
+ {
+ size_t i;
+ double res = 0.0;
+ for (i = 0; i<length; i++)
+ res += item[i];
+ return res;
+ }
+
+
+ void one_to_seven_list(int *length_p, int **list_p)
+ {
+ int i;
+ *length_p = 7;
+ *list_p = malloc(7 * sizeof(int));
+ for (i = 0; i<7; i++)
+ (*list_p)[i] = i+1;
+ }
+
+ void one_to_seven_list2(size_t *length_p, int **list_p)
+ {
+ size_t i;
+ *length_p = 7;
+ *list_p = malloc(7 * sizeof(int));
+ for (i = 0; i<7; i++)
+ (*list_p)[i] = i+1;
+ }
+
+ void one_to_seven_vector(int *length_p, int **list_p)
+ {
+ int i;
+ *length_p = 7;
+ *list_p = malloc(7 * sizeof(int));
+ for (i = 0; i<7; i++)
+ (*list_p)[i] = i+1;
+ }
+
+ void one_to_seven_vector2(size_t *length_p, int **list_p)
+ {
+ size_t i;
+ *length_p = 7;
+ *list_p = malloc(7 * sizeof(int));
+ for (i = 0; i<7; i++)
+ (*list_p)[i] = i+1;
+ }
+
+double sum_lists(int len,
+ double *list1,
+ int *list2,
+ int *list3)
+{
+ int i;
+ double sum;
+ for (i = 0; i<len; i++)
+ sum += (list1[i] + list2[i] + list3[i]);
+ return sum;
+}
+
+double sum_lists2(size_t len,
+ double *list1,
+ int *list2,
+ int *list3)
+{
+ size_t i;
+ double sum;
+ for (i = 0; i<len; i++)
+ sum += (list1[i] + list2[i] + list3[i]);
+ return sum;
+}
+
+void produce_lists(int *len_p,
+ int **list1_p,
+ int **list2_p,
+ double **list3_p)
+{
+ int i;
+ *len_p = 5;
+ *list1_p = malloc(sizeof(int) * 5);
+ *list2_p = malloc(sizeof(int) * 5);
+ *list3_p = malloc(sizeof(double) * 5);
+ for (i = 0; i<5; i++) {
+ (*list1_p)[i] = i;
+ (*list2_p)[i] = i*i;
+ (*list3_p)[i] = 1.5*i;
+ }
+}
+
+
+%}
diff --git a/Examples/test-suite/long_long.i b/Examples/test-suite/long_long.i
new file mode 100644
index 000000000..edda88870
--- /dev/null
+++ b/Examples/test-suite/long_long.i
@@ -0,0 +1,40 @@
+/* This interface file tests whether SWIG handles the new ISO C
+ long long types.
+*/
+
+%module long_long
+
+%warnfilter(801) lconst1; /* Ruby, wrong constant name */
+%warnfilter(801) lconst2; /* Ruby, wrong constant name */
+%warnfilter(801) lconst3; /* Ruby, wrong constant name */
+%warnfilter(801) lconst4; /* Ruby, wrong constant name */
+%warnfilter(801) lconst5; /* Ruby, wrong constant name */
+%warnfilter(801) lconst6; /* Ruby, wrong constant name */
+
+%inline %{
+void foo1(long long x) {}
+void foo2(long long int x) {}
+void foo3(signed long long int x) {}
+void foo4(unsigned long long int x) {}
+void foo5(signed long long x) {}
+void foo6(unsigned long long x) {}
+
+long long bar1() {return 0;}
+long long int bar2() {return 0;}
+signed long long int bar3() {return 0;}
+unsigned long long int bar4() {return 0;}
+signed long long bar5() {return 0;}
+unsigned long long bar6() {return 0;}
+
+long long ll;
+unsigned long long ull;
+%}
+
+%constant long long lconst1 = 1234567890LL;
+%constant unsigned long long lconst2 = 1234567890ULL;
+
+%constant lconst3 = 1234567LL;
+%constant lconst4 = 1234567ULL;
+
+#define lconst5 987654321LL
+#define lconst6 987654321ULL
diff --git a/Examples/test-suite/macro_2.i b/Examples/test-suite/macro_2.i
new file mode 100644
index 000000000..1862bc75a
--- /dev/null
+++ b/Examples/test-suite/macro_2.i
@@ -0,0 +1,22 @@
+/* This interface file tests whether SWIG's extended C
+ preprocessor is working right.
+
+ In this example, SWIG 1.3a5 reports missing macro arguments, which
+ is bogus.
+*/
+
+%define FOO(C_TYPE, GETLENGTH)
+ /* nothing */
+%enddef
+
+%define BAR(XYZZY)
+ FOO(XYZZY, 1)
+%enddef
+
+BAR(int)
+
+%module macro_2
+
+%inline %{
+ int dummy_var;
+%}
diff --git a/Examples/test-suite/member_template.i b/Examples/test-suite/member_template.i
new file mode 100644
index 000000000..aafbd98f3
--- /dev/null
+++ b/Examples/test-suite/member_template.i
@@ -0,0 +1,20 @@
+%module member_template
+
+%inline %{
+template<class T> T max(T x, T y, T z) { return (x > y) ? x : y; }
+
+template<class T> class Foo {
+ public:
+ template<class S> S max(S x, S y) { return (x > y) ? x : y; }
+};
+
+%}
+
+%extend Foo {
+ %template(maxi) max<int>;
+ %template(maxd) max<double>;
+};
+
+%template(Fooint) Foo<int>;
+%template(Foodouble) Foo<double>;
+
diff --git a/Examples/test-suite/memberin1.i b/Examples/test-suite/memberin1.i
new file mode 100644
index 000000000..920323044
--- /dev/null
+++ b/Examples/test-suite/memberin1.i
@@ -0,0 +1,63 @@
+%module memberin1
+
+%{
+class String {
+private:
+ char *str;
+public:
+ // Constructor
+ String(const char *s = 0) : str(0) {
+ if (s != 0) {
+ str = new char[strlen(s) + 1];
+ strcpy(str, s);
+ }
+ }
+
+ // Copy constructor
+ String(const String& other) {
+ delete [] str;
+ str = 0;
+ if (other.str != 0) {
+ str = new char[strlen(other.str) + 1];
+ strcpy(str, other.str);
+ }
+ }
+
+ // Assignment operator
+ String& operator=(const String& other) {
+ if (&other != this) {
+ delete [] str;
+ str = 0;
+ if (other.str != 0) {
+ str = new char[strlen(other.str) + 1];
+ strcpy(str, other.str);
+ }
+ }
+ return *this;
+ }
+
+ // String contents
+ const char *c_str() const { return str; }
+
+ // Destructor
+ ~String() { delete [] str; }
+};
+%}
+
+#ifdef SWIGRUBY
+%typemap(in) String {
+ Check_Type($input, T_STRING);
+ $1 = String(STR2CSTR($input));
+}
+#endif
+
+%typemap(memberin) String {
+ $1 = $input;
+}
+
+%inline %{
+struct Person {
+ String name;
+};
+%}
+
diff --git a/Examples/test-suite/minherit.i b/Examples/test-suite/minherit.i
new file mode 100644
index 000000000..0300f7199
--- /dev/null
+++ b/Examples/test-suite/minherit.i
@@ -0,0 +1,80 @@
+// This module tests multiple inheritance, typedef handling, and some
+// truly horrible parts of the SWIG type system. This is only tested
+// for Python since not all language modules support multiple-inheritance.
+// However, if it works for Python, things should be working for other
+// modules.
+
+%module minherit
+
+#ifdef SWIGPYTHON
+
+%inline %{
+
+class Foo {
+private:
+ int x;
+public:
+ Foo() { x = 1; }
+ virtual int xget() { return x; };
+};
+typedef Foo *FooPtr;
+
+FooPtr toFooPtr(Foo *f) { return f; }
+
+class Bar {
+private:
+ int y;
+public:
+ Bar() { y = 2; }
+ virtual int yget() { return y; }
+};
+
+typedef Bar *BarPtr;
+BarPtr toBarPtr(Bar *f) { return f; }
+
+class FooBar : public Foo, public Bar {
+private:
+ int z;
+public:
+ FooBar() { z = 3; }
+ virtual int zget() { return z; }
+};
+
+typedef FooBar *FooBarPtr;
+FooBarPtr toFooBarPtr(FooBar *f) { return f; }
+
+class Spam: public FooBar {
+private:
+ int w;
+public:
+ Spam() { w = 4; }
+ virtual int wget() { return w; }
+};
+
+typedef Spam *SpamPtr;
+SpamPtr toSpamPtr(Spam *f) { return f; }
+
+int xget(FooPtr f) {
+ return f->xget();
+}
+
+int yget(BarPtr f) {
+ return f->yget();
+}
+
+int zget(FooBarPtr f) {
+ return f->zget();
+}
+
+int wget(SpamPtr f) {
+ return f->wget();
+}
+%}
+
+#endif
+
+
+
+
+
+
diff --git a/Examples/test-suite/multivalue.i b/Examples/test-suite/multivalue.i
new file mode 100644
index 000000000..6cb3c3d7d
--- /dev/null
+++ b/Examples/test-suite/multivalue.i
@@ -0,0 +1,52 @@
+/* -*- c -*- */
+
+%module test
+
+#ifdef SWIGGUILE
+
+/* Multiple values as lists. By default, if more than one value is to
+be returned, a list of the values is created and returned; to switch
+back to this behavior, use: */
+%values_as_list;
+
+void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
+
+/* Multiple values as vectors. By issueing: */
+%values_as_vector;
+/* vectors instead of lists will be used. */
+
+void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
+
+/* Multiple values for multiple-value continuations.
+ (This is the most elegant way.) By issueing: */
+%multiple_values;
+/* multiple values are passed to the multiple-value
+ continuation, as created by `call-with-values' or the
+ convenience macro `receive'. (See the Scheme file.) */
+
+void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
+
+#endif
+
+%{
+
+void divide_l(int a, int b, int *quotient_p, int *remainder_p)
+{
+ *quotient_p = a/b;
+ *remainder_p = a%b;
+}
+
+void divide_v(int a, int b, int *quotient_p, int *remainder_p)
+{
+ *quotient_p = a/b;
+ *remainder_p = a%b;
+}
+
+void divide_mv(int a, int b, int *quotient_p, int *remainder_p)
+{
+ *quotient_p = a/b;
+ *remainder_p = a%b;
+}
+
+%}
+
diff --git a/Examples/test-suite/mzscheme/.cvsignore b/Examples/test-suite/mzscheme/.cvsignore
new file mode 100644
index 000000000..597965c42
--- /dev/null
+++ b/Examples/test-suite/mzscheme/.cvsignore
@@ -0,0 +1 @@
+*wrap.c*
diff --git a/Examples/test-suite/mzscheme/Makefile b/Examples/test-suite/mzscheme/Makefile
new file mode 100644
index 000000000..ead394b57
--- /dev/null
+++ b/Examples/test-suite/mzscheme/Makefile
@@ -0,0 +1,40 @@
+#######################################################################
+# $Header$
+# Makefile for mzscheme test-suite
+#######################################################################
+
+LANGUAGE = mzscheme
+SCRIPTSUFFIX = _runme.scm
+
+include ../common.mk
+
+# Overridden variables here
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.scm appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.scm ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH mzscheme -r $*\_runme.scm;) \
+ fi;
+
+# Clean
+%.clean:
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile mzscheme_clean
diff --git a/Examples/test-suite/mzscheme/README b/Examples/test-suite/mzscheme/README
new file mode 100644
index 000000000..37432ea4b
--- /dev/null
+++ b/Examples/test-suite/mzscheme/README
@@ -0,0 +1,4 @@
+See ../README for common README file.
+
+Any testcases which have _runme.scm appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/mzscheme/casts_runme.scm b/Examples/test-suite/mzscheme/casts_runme.scm
new file mode 100644
index 000000000..3aaa62dc6
--- /dev/null
+++ b/Examples/test-suite/mzscheme/casts_runme.scm
@@ -0,0 +1,7 @@
+(load-extension "casts.so")
+
+(define x (new-B))
+
+(A-hello x)
+
+(exit 0)
diff --git a/Examples/test-suite/mzscheme/char_constant_runme.scm b/Examples/test-suite/mzscheme/char_constant_runme.scm
new file mode 100644
index 000000000..4e3ed47ca
--- /dev/null
+++ b/Examples/test-suite/mzscheme/char_constant_runme.scm
@@ -0,0 +1,6 @@
+(load-extension "char_constant.so")
+
+(if (and (char? (CHAR-CONSTANT))
+ (string? (STRING-CONSTANT)))
+ (exit 0)
+ (exit 1))
diff --git a/Examples/test-suite/mzscheme/import_runme.scm b/Examples/test-suite/mzscheme/import_runme.scm
new file mode 100644
index 000000000..8e8f27339
--- /dev/null
+++ b/Examples/test-suite/mzscheme/import_runme.scm
@@ -0,0 +1,16 @@
+;;; This file is part of a test for SF bug #231619.
+;;; It shows that the %import directive does not work properly in SWIG
+;;; 1.3a5: Type information is not properly generated if a base class
+;;; comes from an %import-ed file.
+
+(load-extension "libimports_a.so")
+(load-extension "libimports_b.so")
+
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG runtime code does not know
+;; that x (an instance of class B) can be passed to methods of class A.
+
+(A-hello x)
+
+(exit 0)
diff --git a/Examples/test-suite/mzscheme/name_runme.scm b/Examples/test-suite/mzscheme/name_runme.scm
new file mode 100644
index 000000000..1782c6481
--- /dev/null
+++ b/Examples/test-suite/mzscheme/name_runme.scm
@@ -0,0 +1,10 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(load-extension "./name.so")
+
+(foo-2)
+bar-2
+Baz-2
+
+(exit 0)
diff --git a/Examples/test-suite/mzscheme/unions_runme.scm b/Examples/test-suite/mzscheme/unions_runme.scm
new file mode 100644
index 000000000..c44847cfc
--- /dev/null
+++ b/Examples/test-suite/mzscheme/unions_runme.scm
@@ -0,0 +1,38 @@
+;;; This is the union runtime testcase. It ensures that values within a
+;;; union embedded within a struct can be set and read correctly.
+
+(load-extension "unions.so")
+
+;; Create new instances of SmallStruct and BigStruct for later use
+(define small (new-SmallStruct))
+(SmallStruct-jill-set small 200)
+
+(define big (new-BigStruct))
+(BigStruct-smallstruct-set big small)
+(BigStruct-jack-set big 300)
+
+;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+;; Ensure values in EmbeddedUnionTest are set correctly for each.
+(define eut (new-EmbeddedUnionTest))
+
+;; First check the SmallStruct in EmbeddedUnionTest
+(EmbeddedUnionTest-number-set eut 1)
+(EmbeddedUnionTest-uni-small-set (EmbeddedUnionTest-uni-get eut)
+ small)
+(let ((Jill1 (SmallStruct-jill-get
+ (EmbeddedUnionTest-uni-small-get
+ (EmbeddedUnionTest-uni-get eut)))))
+ (if (not (= Jill1 200))
+ (begin
+ (display "Runtime test 1 failed.")
+ (exit 1))))
+
+(let ((Num1 (EmbeddedUnionTest-number-get eut)))
+ (if (not (= Num1 1))
+ (begin
+ (display "Runtime test 2 failed.")
+ (exit 1))))
+
+;; that should do
+
+(exit 0)
diff --git a/Examples/test-suite/name.i b/Examples/test-suite/name.i
new file mode 100644
index 000000000..8af8cd68b
--- /dev/null
+++ b/Examples/test-suite/name.i
@@ -0,0 +1,26 @@
+/* This interface file tests whether SWIG/Guile handle the %rename and
+ %name directives, which was not the case in 1.3a5.
+*/
+
+%module name
+
+#ifdef SWIGGUILE
+%rename foo_1 "foo-2";
+#else
+%rename foo_1 "foo_2";
+#endif
+%inline %{
+void foo_1() {}
+%}
+
+#ifdef SWIGGUILE
+%name("bar-2")
+#else
+%name("bar_2")
+#endif
+%inline %{
+int bar_1 = 17;
+%}
+
+%name("Baz_2")
+%constant int Baz_1 = 47;
diff --git a/Examples/test-suite/name_cxx.i b/Examples/test-suite/name_cxx.i
new file mode 100644
index 000000000..3b6965487
--- /dev/null
+++ b/Examples/test-suite/name_cxx.i
@@ -0,0 +1,16 @@
+/* This interface files tests whether SWIG handles overloaded
+ renamed functions.
+*/
+
+%module name_cxx
+
+%name("bar_int")
+%inline %{
+void bar(int i) {}
+%}
+
+%name("bar_double")
+%inline %{
+void bar(double i) {}
+%}
+
diff --git a/Examples/test-suite/name_inherit.i b/Examples/test-suite/name_inherit.i
new file mode 100644
index 000000000..3ce40d145
--- /dev/null
+++ b/Examples/test-suite/name_inherit.i
@@ -0,0 +1,13 @@
+%module name_inherit
+%{
+class A {
+};
+
+class B : public A {
+};
+
+%}
+
+%name(AA) class A { };
+class B : public A { };
+
diff --git a/Examples/test-suite/namespace_enum.i b/Examples/test-suite/namespace_enum.i
new file mode 100644
index 000000000..82a97c630
--- /dev/null
+++ b/Examples/test-suite/namespace_enum.i
@@ -0,0 +1,24 @@
+%module namespace_enum
+
+%inline %{
+
+namespace Foo {
+ enum Swig {
+ LAGER,
+ STOUT,
+ ALE
+ };
+
+ class Bar {
+ public:
+ enum Speed {
+ SLOW,
+ FAST
+ };
+ };
+}
+
+%}
+
+
+ \ No newline at end of file
diff --git a/Examples/test-suite/namespace_extend.i b/Examples/test-suite/namespace_extend.i
new file mode 100644
index 000000000..52ec0fb57
--- /dev/null
+++ b/Examples/test-suite/namespace_extend.i
@@ -0,0 +1,34 @@
+%module namespace_extend
+
+%warnfilter(801) bar; /* Ruby, wrong class name */
+
+%{
+namespace foo {
+ class bar {
+ public:
+ };
+}
+foo::bar *new_foo_bar() {
+ return new foo::bar;
+}
+void delete_foo_bar(foo::bar *self) {
+ delete self;
+}
+int foo_bar_blah(foo::bar *self, int x) {
+ return x;
+}
+%}
+
+namespace foo {
+ class bar {
+ public:
+ %extend {
+ bar();
+ ~bar();
+ int blah(int x);
+ };
+ };
+}
+
+
+
diff --git a/Examples/test-suite/namespace_nested.i b/Examples/test-suite/namespace_nested.i
new file mode 100644
index 000000000..ec75c19a6
--- /dev/null
+++ b/Examples/test-suite/namespace_nested.i
@@ -0,0 +1,59 @@
+%module namespace_nested
+
+%warnfilter(801) hello::hi::hi0; /* Ruby, wrong class name */
+%warnfilter(801) oss::hi1<hello::Hi0 >; /* Ruby, wrong class name */
+
+%inline %{
+ namespace hello
+ {
+ namespace hi
+ {
+ struct hi0
+ {
+ };
+ }
+
+ template <class _T1>
+ struct Hi : _T1
+ {
+ };
+ }
+
+%}
+
+namespace hello
+{
+ %template(Hi_hi0) Hi<hi::hi0>;
+}
+
+
+%inline %{
+
+ namespace hello
+ {
+ //
+ // This works
+ //
+ // typedef Hi<hello::hi::hi0> Hi0;
+
+ //
+ // This doesn't work
+ //
+ typedef Hi<hi::hi0> Hi0;
+ };
+
+
+ namespace oss
+ {
+ template <class _T>
+ struct hi1 : _T
+ {
+ };
+ }
+
+%}
+
+namespace oss
+{
+ %template(hi1_hi0) hi1<hello::Hi0 >;
+}
diff --git a/Examples/test-suite/namespace_template.i b/Examples/test-suite/namespace_template.i
new file mode 100644
index 000000000..1a0cfb6b2
--- /dev/null
+++ b/Examples/test-suite/namespace_template.i
@@ -0,0 +1,78 @@
+/* Tests the use of %template with namespaces */
+
+%module namespace_template
+
+%warnfilter(801) vector<int>; /* Ruby, wrong class name */
+%warnfilter(801) test2::vector<short>; /* Ruby, wrong class name */
+%warnfilter(801) test3::vector<long>; /* Ruby, wrong class name */
+%warnfilter(801) vector<test4::Integer>; /* Ruby, wrong class name */
+
+%{
+namespace test {
+ template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
+ template<typename T> class vector {
+ public:
+ vector() { }
+ ~vector() { }
+ char * blah(T x) {
+ return (char *) "vector::blah";
+ }
+ };
+}
+
+namespace test2 {
+ using namespace test;
+}
+
+namespace test3 {
+ using test::max;
+ using test::vector;
+}
+
+using namespace test2;
+namespace T4 = test;
+%}
+
+namespace test {
+ template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
+ template<typename T> class vector {
+ public:
+ vector() { }
+ ~vector() { }
+ char * blah(T x) {
+ return (char *) "vector::blah";
+ }
+ };
+}
+
+using namespace test;
+%template(maxint) max<int>;
+%template(vectorint) vector<int>;
+
+namespace test2 {
+ using namespace test;
+ %template(maxshort) max<short>;
+ %template(vectorshort) vector<short>;
+}
+
+namespace test3 {
+ using test::max;
+ using test::vector;
+ %template(maxlong) max<long>;
+ %template(vectorlong) vector<long>;
+}
+
+%inline %{
+
+namespace test4 {
+ using namespace test;
+ typedef int Integer;
+}
+
+%}
+
+namespace test4 {
+ %template(maxInteger) max<Integer>;
+ %template(vectorInteger) vector<Integer>;
+}
+
diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i
new file mode 100644
index 000000000..97af110c0
--- /dev/null
+++ b/Examples/test-suite/namespace_typemap.i
@@ -0,0 +1,229 @@
+// This tests SWIG's handling of typemaps and namespaces
+%module namespace_typemap
+
+%{
+namespace test {
+ /* A minimalistic string class */
+ class string {
+ char *data;
+ public:
+ string() {
+ data = 0;
+ }
+ string(const char *s) {
+ data = new char[strlen(s)+1];
+ strcpy(data,s);
+ }
+ ~string() {
+ if (data) delete [] data;
+ }
+ char *c_str() {
+ return data;
+ };
+ };
+
+ /* A minimalistic complex class */
+ class complex {
+ double re;
+ double im;
+ public:
+ complex(double r = 0, double i = 0) {
+ re = r;
+ im = i;
+ }
+ double real() {
+ return re;
+ }
+ double imag() {
+ return im;
+ }
+ };
+}
+ %}
+
+/* SWIG interface tests */
+
+#ifdef SWIGPYTHON
+%typemap(in) test::complex * {
+ if (PyComplex_Check($input)) {
+ $1 = new complex(PyComplex_RealAsDouble($input),
+ PyComplex_ImagAsDouble($input));
+ } else {
+ PyErr_SetString(PyExc_TypeError,"Expected complex.\n");
+ return NULL;
+ }
+}
+%typemap(freearg) test::complex * {
+ delete $1;
+}
+#endif
+
+namespace test {
+ class string;
+#ifdef SWIGPYTHON
+ %typemap(in) string * {
+ $1 = new string(PyString_AsString($input));
+ }
+ %typemap(freearg) string * {
+ delete $1;
+ }
+#endif
+#ifdef SWIGRUBY
+ %typemap(in) string * {
+ $1 = new string(STR2CSTR($input));
+ }
+ %typemap(freearg) string * {
+ delete $1;
+ }
+#endif
+}
+
+%inline %{
+ namespace test {
+ class string;
+ class complex;
+
+ /* Functions in the namespace itself */
+ char *stest1(string *s) {
+ return s->c_str();
+ }
+ double ctest1(complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test2 {
+ using test::string;
+ using test::complex;
+
+ /* Functions in another namespace */
+ char *stest2(string *s) {
+ return s->c_str();
+ }
+ double ctest2(complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test3 {
+ using namespace test;
+
+ char *stest3(string *s) {
+ return s->c_str();
+ }
+ double ctest3(complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test4 {
+ using namespace test2;
+
+ char *stest4(string *s) {
+ return s->c_str();
+ }
+ double ctest4(complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test5 {
+ using namespace test3;
+
+ char *stest5(string *s) {
+ return s->c_str();
+ }
+ double ctest5(complex *c) {
+ return c->real();
+ }
+ }
+
+ char *stest6(test::string *s) {
+ return s->c_str();
+ }
+ double ctest6(test::complex *c) {
+ return c->real();
+ }
+
+ char *stest7(test2::string *s) {
+ return s->c_str();
+ }
+ double ctest7(test2::complex *c) {
+ return c->real();
+ }
+
+ char *stest8(test3::string *s) {
+ return s->c_str();
+ }
+ double ctest8(test3::complex *c) {
+ return c->real();
+ }
+
+ char *stest9(test4::string *s) {
+ return s->c_str();
+ }
+ double ctest9(test4::complex *c) {
+ return c->real();
+ }
+
+ char *stest10(test5::string *s) {
+ return s->c_str();
+ }
+ double ctest10(test5::complex *c) {
+ return c->real();
+ }
+
+ namespace test11 = test;
+
+ char *stest11(test11::string *s) {
+ return s->c_str();
+ }
+ double ctest11(test11::complex *c) {
+ return c->real();
+ }
+
+ using namespace test2;
+ using test::complex;
+
+ char *stest12(string *s) {
+ return s->c_str();
+ }
+ double ctest12(complex *c) {
+ return c->real();
+ }
+%}
+
+namespace Split {
+#ifdef SWIGPYTHON
+ %typemap(in) PosInteger {
+ $1 = PyInt_AsLong($input);
+ if ($1 < 0) {
+ PyErr_SetString(PyExc_ValueError,"domain error\n");
+ return NULL;
+ }
+ }
+#endif
+#ifdef SWIGRUBY
+ %typemap(in) PosInteger {
+ $1 = NUM2INT($input);
+ if ($1 < 0) {
+ rb_raise(rb_eRangeError, "domain error");
+ }
+ }
+#endif
+};
+
+%inline %{
+ namespace Split {
+ typedef int PosInteger;
+ PosInteger ttest1(PosInteger x) {
+ return x;
+ };
+ }
+%}
+
+
+
+
+
+
diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i
new file mode 100644
index 000000000..7771fe7be
--- /dev/null
+++ b/Examples/test-suite/nested.i
@@ -0,0 +1,34 @@
+/*
+This testcase tests that nested structs/unions work. Named structs/unions declared within
+a struct produced redefinition errors in SWIG 1.3.6 as reported by SF bug #447488.
+Also tests reported error when a #define placed in a deeply embedded struct/union.
+*/
+
+%module nested
+%pragma make_default
+
+%inline %{
+
+struct TestStruct {
+ int a;
+};
+
+typedef struct OuterStruct {
+ union {
+
+ struct outer_nested_struct {
+ union inner_nested_union {
+#define BAD_STYLE 1
+ int red;
+ struct TestStruct green;
+ } InnerNestedUnion;
+
+ struct inner_nested_struct {
+ int blue;
+ } InnerNestedStruct;
+ } OuterNestedStruct;
+
+ } EmbeddedUnion;
+} OuterStruct;
+
+%}
diff --git a/Examples/test-suite/newobject1.i b/Examples/test-suite/newobject1.i
new file mode 100644
index 000000000..b5b018b2f
--- /dev/null
+++ b/Examples/test-suite/newobject1.i
@@ -0,0 +1,51 @@
+/**
+ * The purpose of this test is to confirm that a language module
+ * correctly handles the case when C++ class member functions (of both
+ * the static and non-static persuasion) have been tagged with the
+ * %newobject directive.
+ */
+
+%module newobject1
+
+%newobject Foo::makeFoo();
+%newobject Foo::makeMore();
+
+%inline %{
+class Foo
+{
+private:
+ Foo(const Foo&);
+ Foo& operator=(const Foo&);
+private:
+ static int m_fooCount;
+protected:
+ Foo() {
+ m_fooCount++;
+ }
+public:
+ // Factory function (static)
+ static Foo *makeFoo() {
+ return new Foo;
+ }
+
+ // Factory function (regular)
+ Foo *makeMore() {
+ return new Foo;
+ }
+
+ // Return the number of instances
+ static int fooCount() {
+ return m_fooCount;
+ }
+
+ // Destructor
+ ~Foo() {
+ m_fooCount--;
+ }
+};
+%}
+
+%{
+// Static member initialization (not wrapped)
+int Foo::m_fooCount = 0;
+%}
diff --git a/Examples/test-suite/newobject2.i b/Examples/test-suite/newobject2.i
new file mode 100644
index 000000000..bbe94a50e
--- /dev/null
+++ b/Examples/test-suite/newobject2.i
@@ -0,0 +1,38 @@
+/**
+ * The purpose of this test is to confirm that a language module
+ * correctly handles the case when a C function has been tagged with the
+ * %newobject directive.
+ */
+
+%module newobject2
+
+%{
+/* Global initialization (not wrapped) */
+int g_fooCount = 0;
+%}
+
+%newobject makeFoo();
+
+%inline %{
+/* Struct definition */
+typedef struct {} Foo;
+
+/* Make one */
+Foo *makeFoo() {
+ Foo *foo = (Foo *) malloc(sizeof(Foo));
+ g_fooCount++;
+ return foo;
+}
+
+/* Return the number of instances */
+int fooCount() {
+ return g_fooCount;
+}
+%}
+
+%extend Foo {
+ ~Foo() {
+ free((void *) self);
+ g_fooCount--;
+ }
+}
diff --git a/Examples/test-suite/ocaml/Makefile b/Examples/test-suite/ocaml/Makefile
new file mode 100644
index 000000000..9c9a182bf
--- /dev/null
+++ b/Examples/test-suite/ocaml/Makefile
@@ -0,0 +1,64 @@
+LANGUAGE = ocaml
+VARIANT = _static
+SCRIPTSUFFIX = _runme.ml
+
+C_TEST_CASES =
+
+run_testcase = \
+ if [ -f $*\_runme.ml ] ; then \
+ (ocamlc -c $*\_runme.ml ; \
+ ocamlc -custom -g -o runme $*\.cmo $*\_runme.cmo $*\_wrap.o ; \
+ ./runme) ; \
+ fi ;
+
+check_quant:
+ cat /dev/null > testing
+ cat /dev/null > success
+ cat /dev/null > results
+ $(MAKE) check
+ echo "Failed:" >> results
+ for element in `cat testing` ; do \
+ if grep $$element success >/dev/null 2>/dev/null ; then \
+ : ; \
+ else \
+ echo $$element >> results ; \
+ fi ; \
+ done
+ echo "Success:" >> results
+ cat success >> results
+
+include ../common.mk
+
+%.cpptest:
+ echo $@ >> testing
+ $(setup) \
+ ($(swig_and_compile_cpp); ) ; \
+ $(run_testcase) \
+ if [ -f $(@:%.cpptest=%_wrap.o) ] ; then \
+ echo $@ >> success ; \
+ fi
+
+%.ctest:
+ echo $@ >> testing
+ $(setup) \
+ ($(swig_and_compile_c); ) ; \
+ $(run_testcase) \
+ if [ -f $(@:%.ctest=%_wrap.o) ] ; then \
+ echo $@ >> success ; \
+ fi
+
+%.multicpptest:
+ echo $@ >> testing
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ) ; \
+ $(run_testcase) \
+ if [ -f $(@:%.multicpptest=%_a_wrap.o) ] ; then \
+ echo $@ >> success ; \
+ fi
+
+%.clean:
+ @rm -f $*.ml $*.mli;
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile ocaml_clean
+
diff --git a/Examples/test-suite/ocaml/README b/Examples/test-suite/ocaml/README
new file mode 100644
index 000000000..3fdea6252
--- /dev/null
+++ b/Examples/test-suite/ocaml/README
@@ -0,0 +1,2 @@
+I stole most of these runme's from the ruby runme scripts, since the current
+ocaml interface mirrors the ruby interface in many ways.
diff --git a/Examples/test-suite/ocaml/class_ignore_runme.ml b/Examples/test-suite/ocaml/class_ignore_runme.ml
new file mode 100644
index 000000000..846643aa8
--- /dev/null
+++ b/Examples/test-suite/ocaml/class_ignore_runme.ml
@@ -0,0 +1,6 @@
+open Class_ignore
+
+let a = new_Bar C_void
+let _ = (if _do_blah a <> C_string "Bar::blah" then
+ raise (Failure "We didn't really get a bar object."))
+
diff --git a/Examples/test-suite/ocaml/makedebugtop b/Examples/test-suite/ocaml/makedebugtop
new file mode 100755
index 000000000..8d712801c
--- /dev/null
+++ b/Examples/test-suite/ocaml/makedebugtop
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Usage: makedebugtop test_name.c[pp]test
+#
+# Creates an ocaml toplevel for debugging based on a .cpptest or .ctest
+# file.
+#
+
+OCAMLINC=/usr/local/lib/ocaml
+swigtest=$1
+thetest=`echo $1 | sed -e 's/\.c[p]*test//g'`
+cppopt=""
+if echo $swigtest | grep -s cpptest ; then
+ cppopt=-xc++
+fi
+
+echo "Making the test"
+make $swigtest
+echo "Building ${thetest}_top"
+gcc -c -g $cppopt -I$OCAMLINC ${thetest}_wrap.c
+ocamlmktop -cclib -g -custom ${thetest}_wrap.o ${thetest}.cmo -o ${thetest}_top
diff --git a/Examples/test-suite/ocaml/newobject1_runme.ml b/Examples/test-suite/ocaml/newobject1_runme.ml
new file mode 100644
index 000000000..247545690
--- /dev/null
+++ b/Examples/test-suite/ocaml/newobject1_runme.ml
@@ -0,0 +1,25 @@
+open Newobject1
+
+exception RuntimeError of string * int
+
+let foo1 = ref (_Foo_makeFoo C_void)
+let _ = if get_int (_Foo_fooCount C_void) != 1 then
+ raise (RuntimeError ("(1) Foo.fooCount != 1",
+ get_int (_Foo_fooCount C_void)))
+
+let foo2 = ref ((invoke !foo1) "makeMore" C_void)
+let _ = if get_int (_Foo_fooCount C_void) != 2 then
+ raise (RuntimeError ("(2) Foo.fooCount != 2",
+ get_int (_Foo_fooCount C_void)))
+
+let _ = begin
+ foo1 := C_void ; Gc.full_major () ;
+ (if get_int (_Foo_fooCount C_void) != 1 then
+ raise (RuntimeError ("(3) Foo.fooCount != 1",
+ get_int (_Foo_fooCount C_void)))) ;
+
+ foo2 := C_void ; Gc.full_major () ;
+ (if get_int (_Foo_fooCount C_void) != 0 then
+ raise (RuntimeError ("(4) Foo.fooCount != 0",
+ get_int (_Foo_fooCount C_void)))) ;
+end
diff --git a/Examples/test-suite/ocaml/overload_copy_runme.ml b/Examples/test-suite/ocaml/overload_copy_runme.ml
new file mode 100644
index 000000000..c48f15b17
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_copy_runme.ml
@@ -0,0 +1,4 @@
+open Overload_copy
+
+let f = new_Foo C_void
+let g = new_Foo f
diff --git a/Examples/test-suite/ocaml/results b/Examples/test-suite/ocaml/results
new file mode 100644
index 000000000..7ee0f1a9c
--- /dev/null
+++ b/Examples/test-suite/ocaml/results
@@ -0,0 +1,180 @@
+Failed:
+template_typedef_import.multicpptest
+Success:
+template_specialization.cpptest
+default_cast.cpptest
+import_nomodule.cpptest
+struct_value.cpptest
+abstract_inherit.cpptest
+abstract_inherit_ok.cpptest
+add_link.cpptest
+anonymous_arg.cpptest
+argout.cpptest
+arrays_global.cpptest
+arrays_global_twodim.cpptest
+arrays_scope.cpptest
+bool_default.cpptest
+casts.cpptest
+class_ignore.cpptest
+const_const_2.cpptest
+constant_pointers.cpptest
+constover.cpptest
+constructor_exception.cpptest
+constructor_explicit.cpptest
+constructor_value.cpptest
+conversion.cpptest
+conversion_namespace.cpptest
+conversion_ns_template.cpptest
+cplusplus_throw.cpptest
+cpp_enum.cpptest
+cpp_enum_scope.cpptest
+cpp_namespace.cpptest
+cpp_nodefault.cpptest
+cpp_static.cpptest
+cpp_typedef.cpptest
+default_constructor.cpptest
+default_ns.cpptest
+default_ref.cpptest
+dynamic_cast.cpptest
+enum_scope.cpptest
+enum_scope_template.cpptest
+enum_var.cpptest
+evil_diamond.cpptest
+evil_diamond_ns.cpptest
+evil_diamond_prop.cpptest
+explicit.cpptest
+extend_template.cpptest
+extend_template_ns.cpptest
+grouping.cpptest
+ignore_parameter.cpptest
+inherit_missing.cpptest
+kind.cpptest
+lib_carrays.cpptest
+lib_cdata.cpptest
+lib_cpointer.cpptest
+lib_std_deque.cpptest
+lib_std_string.cpptest
+lib_std_vector.cpptest
+lib_typemaps.cpptest
+member_template.cpptest
+minherit.cpptest
+name_cxx.cpptest
+name_inherit.cpptest
+namespace_enum.cpptest
+namespace_extend.cpptest
+namespace_template.cpptest
+namespace_typemap.cpptest
+newobject1.cpptest
+overload_complicated.cpptest
+overload_copy.cpptest
+overload_extend.cpptest
+overload_simple.cpptest
+overload_subtype.cpptest
+overload_template.cpptest
+pointer_reference.cpptest
+primitive_ref.cpptest
+private_assign.cpptest
+pure_virtual.cpptest
+rename_default.cpptest
+rename_scope.cpptest
+return_value_scope.cpptest
+rname.cpptest
+smart_pointer_const.cpptest
+smart_pointer_multi.cpptest
+smart_pointer_multi_typedef.cpptest
+smart_pointer_not.cpptest
+smart_pointer_overload.cpptest
+smart_pointer_protected.cpptest
+smart_pointer_rename.cpptest
+smart_pointer_simple.cpptest
+smart_pointer_typedef.cpptest
+static_array_member.cpptest
+static_const_member.cpptest
+static_const_member_2.cpptest
+template.cpptest
+template_arg_scope.cpptest
+template_arg_typename.cpptest
+template_base_template.cpptest
+template_classes.cpptest
+template_const_ref.cpptest
+template_construct.cpptest
+template_default.cpptest
+template_default2.cpptest
+template_default_inherit.cpptest
+template_default_qualify.cpptest
+template_enum.cpptest
+template_enum_ns_inherit.cpptest
+template_enum_typedef.cpptest
+template_forward.cpptest
+template_inherit.cpptest
+template_inherit_abstract.cpptest
+template_int_const.cpptest
+template_ns.cpptest
+template_ns2.cpptest
+template_ns3.cpptest
+template_ns4.cpptest
+template_ns_enum.cpptest
+template_ns_enum2.cpptest
+template_ns_inherit.cpptest
+template_ns_scope.cpptest
+template_qualifier.cpptest
+template_rename.cpptest
+template_retvalue.cpptest
+template_static.cpptest
+template_tbase_template.cpptest
+template_type_namespace.cpptest
+template_typedef.cpptest
+template_typedef_cplx.cpptest
+template_typedef_cplx2.cpptest
+template_typedef_cplx3.cpptest
+template_typedef_cplx4.cpptest
+template_virtual.cpptest
+template_whitespace.cpptest
+throw_exception.cpptest
+typedef_funcptr.cpptest
+typedef_inherit.cpptest
+typedef_mptr.cpptest
+typedef_reference.cpptest
+typedef_scope.cpptest
+typemap_namespace.cpptest
+typemap_ns_using.cpptest
+typename.cpptest
+union_scope.cpptest
+using1.cpptest
+using2.cpptest
+using_composition.cpptest
+using_extend.cpptest
+using_inherit.cpptest
+using_private.cpptest
+using_protected.cpptest
+valuewrapper_base.cpptest
+virtual_destructor.cpptest
+voidtest.cpptest
+arrayptr.ctest
+arrays.ctest
+char_constant.ctest
+const_const.ctest
+defineop.ctest
+defines.ctest
+enum.ctest
+lib_carrays.ctest
+lib_cdata.ctest
+lib_cmalloc.ctest
+lib_constraints.ctest
+lib_cpointer.ctest
+lib_math.ctest
+long_long.ctest
+macro_2.ctest
+name.ctest
+nested.ctest
+newobject2.ctest
+overload_extendc.ctest
+preproc_1.ctest
+preproc_2.ctest
+preproc_3.ctest
+ret_by_value.ctest
+sizeof_pointer.ctest
+sneaky1.ctest
+typemap_subst.ctest
+unions.ctest
+imports.multicpptest
diff --git a/Examples/test-suite/ocaml/sneaky1_runme.ml b/Examples/test-suite/ocaml/sneaky1_runme.ml
new file mode 100644
index 000000000..37678b38e
--- /dev/null
+++ b/Examples/test-suite/ocaml/sneaky1_runme.ml
@@ -0,0 +1,8 @@
+(* Stolen from ruby test cases *)
+
+open Sneaky1
+
+let x = Sneaky1._add (C_list [ C_int 3; C_int 4 ])
+let y = Sneaky1._sub (C_list [ C_int 3; C_int 4 ])
+let z = Sneaky1._mul (C_list [ C_int 3; C_int 4 ])
+let w = Sneaky1._divide (C_list [ C_int 3; C_int 4 ])
diff --git a/Examples/test-suite/ocaml/throw_exception_runme.ml b/Examples/test-suite/ocaml/throw_exception_runme.ml
new file mode 100644
index 000000000..49ce884c4
--- /dev/null
+++ b/Examples/test-suite/ocaml/throw_exception_runme.ml
@@ -0,0 +1,27 @@
+(* Throw exception test *)
+
+open Throw_exception
+
+let x = new_Foo C_void ;;
+let _ =
+ try
+ (invoke x) "test_int" C_void
+ with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
+ try
+ (invoke x) "test_msg" C_void
+ with (Failure "Exception(0): Dead\n") ->
+ try
+ (invoke x) "test_cls" C_void
+ with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
+ try
+ (invoke x) "test_multi" (C_int 1)
+ with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
+ try
+ (invoke x) "test_multi" (C_int 2)
+ with (Failure "Exception(0): Dead\n") ->
+ try
+ (invoke x) "test_multi" (C_int 3)
+ with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
+ exit 0
+
+let _ = exit 1
diff --git a/Examples/test-suite/ocaml/typename_runme.ml b/Examples/test-suite/ocaml/typename_runme.ml
new file mode 100644
index 000000000..15b5eac25
--- /dev/null
+++ b/Examples/test-suite/ocaml/typename_runme.ml
@@ -0,0 +1,11 @@
+(* Fun with type names -- stolen from the ruby runme *)
+
+open Typename
+
+let f = new_Foo C_void
+let b = new_Bar C_void
+
+let x = _twoFoo f
+let _ = match x with C_double f -> () | _ -> raise (Failure "not a float")
+let y = _twoBar b
+let _ = match y with C_int i -> () | _ -> raise (Failure "not an int")
diff --git a/Examples/test-suite/ocaml/unions_runme.ml b/Examples/test-suite/ocaml/unions_runme.ml
new file mode 100644
index 000000000..b1ddf3fce
--- /dev/null
+++ b/Examples/test-suite/ocaml/unions_runme.ml
@@ -0,0 +1,27 @@
+(* Test the unions example... *)
+
+open Unions
+
+let a = new_SmallStruct C_void
+let b = new_BigStruct C_void
+let c = new_UnionTest C_void
+let d = new_EmbeddedUnionTest C_void
+
+let _ = (invoke a) "jill_set" (C_short 3)
+let _ = (invoke b) "jack_set" (C_char 'a') (* Int conversion *)
+let _ = (invoke b) "smallstruct_set" a (* Put a in b *)
+let _ = (invoke c) "bs_set" b
+
+let _ = if get_int ((invoke a) "jill_get" C_void) != 3 then
+ raise (Failure "jill value is not preserved")
+let _ = if get_int ((invoke b) "jack_get" C_void) != (int_of_char 'a') then
+ raise (Failure "jack value is not preserved")
+let _ = if get_int ((invoke ((invoke b) "smallstruct_get" C_void))
+ "jill_get" C_void) != 3 then
+ raise (Failure "jill value is not embedded in bigstruct")
+let _ = if get_int ((invoke ((invoke c) "bs_get" C_void))
+ "jack_get" C_void) != (int_of_char 'a') then
+ raise (Failure "union set of bigstruct did not take")
+let _ = if get_int ((invoke ((invoke c) "ss_get" C_void))
+ "jill_get" C_void) != (int_of_char 'a') then
+ raise (Failure "corresponding union values are not the same")
diff --git a/Examples/test-suite/overload_complicated.i b/Examples/test-suite/overload_complicated.i
new file mode 100644
index 000000000..2050e1945
--- /dev/null
+++ b/Examples/test-suite/overload_complicated.i
@@ -0,0 +1,21 @@
+// A complicated test of overloaded functions
+%module overload_complicated
+
+#ifndef SWIG_NO_OVERLOAD
+
+%typemap(in, numinputs=0) int l { $1 = 4711; }
+
+%inline %{
+
+double foo(int, int, char *, int) {
+ return 15;
+}
+
+double foo(int i, int j, double k = 17.4, int l = 18, char m = 'P') {
+ return i + j + k + l + (int) m;
+}
+
+%}
+
+#endif
+
diff --git a/Examples/test-suite/overload_copy.i b/Examples/test-suite/overload_copy.i
new file mode 100644
index 000000000..a685f76e2
--- /dev/null
+++ b/Examples/test-suite/overload_copy.i
@@ -0,0 +1,16 @@
+// Tests copy constructor
+%module overload_copy
+
+#ifndef SWIG_NO_OVERLOAD
+%inline %{
+
+class Foo {
+public:
+ Foo() { }
+ Foo(const Foo &) { }
+};
+
+%}
+
+#endif
+
diff --git a/Examples/test-suite/overload_extend.i b/Examples/test-suite/overload_extend.i
new file mode 100644
index 000000000..0498bde1b
--- /dev/null
+++ b/Examples/test-suite/overload_extend.i
@@ -0,0 +1,16 @@
+%module overload_extend
+
+%inline %{
+struct Foo {
+};
+%}
+
+%extend Foo {
+ int test(int x) { x = 0; return 1; }
+ int test(char *s) { s = 0; return 2; }
+ int test(double x, double y) { x = 0; y = 0; return 3; }
+};
+
+
+
+
diff --git a/Examples/test-suite/overload_extendc.i b/Examples/test-suite/overload_extendc.i
new file mode 100644
index 000000000..e03b3f160
--- /dev/null
+++ b/Examples/test-suite/overload_extendc.i
@@ -0,0 +1,16 @@
+%module overload_extendc
+
+%inline %{
+typedef struct Foo {
+} Foo;
+%}
+
+%extend Foo {
+ int test(int x) { x = 0; return 1; }
+ int test(char *s) { s = 0; return 2; }
+ int test(double x, double y) { x = 0; y = 0; return 3; }
+};
+
+
+
+
diff --git a/Examples/test-suite/overload_simple.i b/Examples/test-suite/overload_simple.i
new file mode 100644
index 000000000..27df10911
--- /dev/null
+++ b/Examples/test-suite/overload_simple.i
@@ -0,0 +1,92 @@
+// Simple tests of overloaded functions
+%module overload_simple
+
+#ifndef SWIG_NO_OVERLOAD
+%immutable Spam::type;
+
+%inline %{
+
+struct Foo {
+};
+
+struct Bar {
+};
+
+char *foo(int) {
+ return (char*) "foo:int";
+}
+
+char *foo(double) {
+ return (char*) "foo:double";
+}
+
+char *foo(char *) {
+ return (char*) "foo:char *";
+}
+
+char *foo(Foo *) {
+ return (char*) "foo:Foo *";
+}
+char *foo(Bar *) {
+ return (char *) "foo:Bar *";
+}
+char *foo(void *) {
+ return (char *) "foo:void *";
+}
+
+class Spam {
+public:
+ Spam() { type = "none"; }
+ Spam(int) { type = "int"; }
+ Spam(double) { type = "double"; }
+ Spam(char *) { type = "char *"; }
+ Spam(Foo *) { type = "Foo *"; }
+ Spam(Bar *) { type = "Bar *"; }
+ Spam(void *) { type = "void *"; }
+ const char *type;
+
+char *foo(int) {
+ return (char*) "foo:int";
+}
+char *foo(double) {
+ return (char*) "foo:double";
+}
+char *foo(char *) {
+ return (char*) "foo:char *";
+}
+char *foo(Foo *) {
+ return (char*) "foo:Foo *";
+}
+char *foo(Bar *) {
+ return (char *) "foo:Bar *";
+}
+char *foo(void *) {
+ return (char *) "foo:void *";
+}
+
+static char *bar(int) {
+ return (char*) "bar:int";
+}
+static char *bar(double) {
+ return (char*) "bar:double";
+}
+static char *bar(char *) {
+ return (char*) "bar:char *";
+}
+static char *bar(Foo *) {
+ return (char*) "bar:Foo *";
+}
+static char *bar(Bar *) {
+ return (char *) "bar:Bar *";
+}
+static char *bar(void *) {
+ return (char *) "bar:void *";
+}
+};
+%}
+
+%include cmalloc.i
+%malloc(void);
+
+#endif
+
diff --git a/Examples/test-suite/overload_subtype.i b/Examples/test-suite/overload_subtype.i
new file mode 100644
index 000000000..3d9645d7b
--- /dev/null
+++ b/Examples/test-suite/overload_subtype.i
@@ -0,0 +1,17 @@
+%module overload_subtype
+
+%inline %{
+
+class Foo {};
+class Bar : public Foo {};
+
+
+int spam(Foo *f) {
+ return 1;
+}
+
+int spam(Bar *b) {
+ return 2;
+}
+
+%}
diff --git a/Examples/test-suite/overload_template.i b/Examples/test-suite/overload_template.i
new file mode 100644
index 000000000..01a1dd633
--- /dev/null
+++ b/Examples/test-suite/overload_template.i
@@ -0,0 +1,19 @@
+%module overload_template
+%inline %{
+
+int foo() {
+ return 3;
+}
+template <class T>
+ int foo(int x) {
+ return x;
+ }
+
+template<class T>
+ T max(T a, T b) { return (a > b) ? a : b; }
+%}
+
+
+%template(max) max<int>;
+%template(max) max<double>;
+
diff --git a/Examples/test-suite/perl5/.cvsignore b/Examples/test-suite/perl5/.cvsignore
new file mode 100644
index 000000000..e32f11c0b
--- /dev/null
+++ b/Examples/test-suite/perl5/.cvsignore
@@ -0,0 +1,4 @@
+*wrap*
+*.pm
+*.so
+*.dll
diff --git a/Examples/test-suite/perl5/Makefile b/Examples/test-suite/perl5/Makefile
new file mode 100644
index 000000000..d8ee34446
--- /dev/null
+++ b/Examples/test-suite/perl5/Makefile
@@ -0,0 +1,42 @@
+#######################################################################
+# $Header$
+# Makefile for perl5 test-suite
+#######################################################################
+
+LANGUAGE = perl5
+SCRIPTSUFFIX = _runme.pl
+
+include ../common.mk
+
+# Overridden variables here
+SWIGOPT = -shadow -I$(TOP)/$(TEST_SUITE)
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.pl appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.pl ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH perl $*\_runme.pl;) \
+ fi;
+
+# Clean: remove the generated .pm file
+%.clean:
+ @rm -f $*.pm;
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
diff --git a/Examples/test-suite/perl5/README b/Examples/test-suite/perl5/README
new file mode 100644
index 000000000..649cca90a
--- /dev/null
+++ b/Examples/test-suite/perl5/README
@@ -0,0 +1,4 @@
+See ../README for common README file.
+
+Any testcases which have _runme.pl appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/perl5/import_nomodule_runme.pl b/Examples/test-suite/perl5/import_nomodule_runme.pl
new file mode 100644
index 000000000..965d10582
--- /dev/null
+++ b/Examples/test-suite/perl5/import_nomodule_runme.pl
@@ -0,0 +1,7 @@
+use import_nomodule;
+
+$f = import_nomodule::create_Foo();
+import_nomodule::test1($f,42);
+
+$b = new import_nomodule::Bar();
+import_nomodule::test1($b,37);
diff --git a/Examples/test-suite/perl5/imports_runme.pl b/Examples/test-suite/perl5/imports_runme.pl
new file mode 100644
index 000000000..fd730fedf
--- /dev/null
+++ b/Examples/test-suite/perl5/imports_runme.pl
@@ -0,0 +1,5 @@
+use imports_b;
+use imports_a;
+
+$x = imports_bc::new_B();
+imports_ac::A_hello($x);
diff --git a/Examples/test-suite/perl5/overload_copy_runme.pl b/Examples/test-suite/perl5/overload_copy_runme.pl
new file mode 100644
index 000000000..06d03f5e6
--- /dev/null
+++ b/Examples/test-suite/perl5/overload_copy_runme.pl
@@ -0,0 +1,5 @@
+
+use overload_copy;
+
+$f = new overload_copy::Foo();
+$g = new overload_copy::Foo($f);
diff --git a/Examples/test-suite/perl5/overload_simple_runme.pl b/Examples/test-suite/perl5/overload_simple_runme.pl
new file mode 100644
index 000000000..5e348fba1
--- /dev/null
+++ b/Examples/test-suite/perl5/overload_simple_runme.pl
@@ -0,0 +1,120 @@
+use overload_simple;
+
+$f = new overload_simple::Foo();
+$b = new overload_simple::Bar();
+$v = overload_simple::malloc_void(32);
+
+if (overload_simple::foo(3) != "foo:int") {
+ die("foo(int)");
+}
+
+if (overload_simple::foo(3.0) != "foo:double") {
+ die("foo(double)");
+}
+
+if (overload_simple::foo("hello") != "foo:char *") {
+ die("foo(char *)");
+}
+
+if (overload_simple::foo($f) != "foo:Foo *") {
+ die("foo(Foo *)");
+}
+
+if (overload_simple::foo($b) != "foo:Bar *") {
+ die("foo(Bar *)");
+}
+
+if (overload_simple::foo($v) != "foo:void *") {
+ die("foo(void *)");
+}
+
+$s = new overload_simple::Spam();
+
+if ($s->foo(3) != "foo:int") {
+ die("Spam::foo(int)");
+}
+
+if ($s->foo(3.0) != "foo:double") {
+ die("Spam::foo(double)");
+}
+
+if ($s->foo("hello") != "foo:char *") {
+ die("Spam::foo(char *)");
+}
+
+if ($s->foo($f) != "foo:Foo *") {
+ die("Spam::foo(Foo *)");
+}
+
+if ($s->foo($b) != "foo:Bar *") {
+ die("Spam::foo(Bar *)");
+}
+
+if ($s->foo($v) != "foo:void *") {
+ die("Spam::foo(void *)");
+}
+
+if (overload_simple::Spam::bar(3) != "bar:int") {
+ die("Spam::bar(int)");
+}
+
+if (overload_simple::Spam::bar(3.0) != "bar:double") {
+ die("Spam::bar(double)");
+}
+
+if (overload_simple::Spam::bar("hello") != "bar:char *") {
+ die("Spam::bar(char *)");
+}
+
+if (overload_simple::Spam::bar($f) != "bar:Foo *") {
+ die("Spam::bar(Foo *)");
+}
+
+if (overload_simple::Spam::bar($b) != "bar:Bar *") {
+ die("Spam::bar(Bar *)");
+}
+
+if (overload_simple::Spam::bar($v) != "bar:void *") {
+ die("Spam::bar(void *)");
+}
+
+# Test constructors
+
+$s = new overload_simple::Spam();
+if ($s->{type} != "none") {
+ die("Spam()");
+}
+
+$s = new overload_simple::Spam(3);
+if ($s->{type} != "int") {
+ die("Spam(int)");
+}
+
+$s = new overload_simple::Spam(3.0);
+if ($s->{type} != "double") {
+ die("Spam(double)");
+}
+
+$s = new overload_simple::Spam("hello");
+if ($s->{type} != "char *") {
+ die("Spam(char *)");
+}
+
+$s = new overload_simple::Spam($f);
+if ($s->{type} != "Foo *") {
+ die("Spam(Foo *)");
+}
+
+$s = new overload_simple::Spam($b);
+if ($s->{type} != "Bar *") {
+ die("Spam(Bar *)");
+}
+
+$s = new overload_simple::Spam($v);
+if ($s->{type} != "void *") {
+ die("Spam(void *)");
+}
+
+
+
+
diff --git a/Examples/test-suite/perl5/primitive_ref_runme.pl b/Examples/test-suite/perl5/primitive_ref_runme.pl
new file mode 100644
index 000000000..727b3ec6e
--- /dev/null
+++ b/Examples/test-suite/perl5/primitive_ref_runme.pl
@@ -0,0 +1,38 @@
+use primitive_ref;
+
+if (primitive_ref::ref_int(3) != 3) {
+ print "ref_int failed!\n";
+}
+if (primitive_ref::ref_uint(3) != 3) {
+ print "ref_uint failed!\n";
+}
+if (primitive_ref::ref_short(3) != 3) {
+ print "ref_short failed!\n";
+}
+if (primitive_ref::ref_ushort(3) != 3) {
+ print "ref_ushort failed!\n";
+}
+if (primitive_ref::ref_long(3) != 3) {
+ print "ref_long failed!\n";
+}
+if (primitive_ref::ref_ulong(3) != 3) {
+ print "ref_ulong failed!\n";
+}
+if (primitive_ref::ref_schar(3) != 3) {
+ print "ref_schar failed!\n";
+}
+if (primitive_ref::ref_uchar(3) != 3) {
+ print "ref_uchar failed!\n";
+}
+if (primitive_ref::ref_bool(1) != 1) {
+ print "ref_bool failed!\n";
+}
+if (primitive_ref::ref_float(3.5) != 3.5) {
+ print "ref_float failed!\n";
+}
+if (primitive_ref::ref_double(3.5) != 3.5) {
+ print "ref_double failed!\n";
+}
+if (primitive_ref::ref_char('x') != 'x') {
+ print "ref_char failed!\n";
+}
diff --git a/Examples/test-suite/perl5/unions_runme.pl b/Examples/test-suite/perl5/unions_runme.pl
new file mode 100644
index 000000000..fca499f0e
--- /dev/null
+++ b/Examples/test-suite/perl5/unions_runme.pl
@@ -0,0 +1,54 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+use unions;
+
+# Create new instances of SmallStruct and BigStruct for later use
+$small = new unions::SmallStruct();
+$small->{jill} = 200;
+
+$big = new unions::BigStruct();
+$big->{smallstruct} = $small;
+$big->{jack} = 300;
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+$eut = new unions::EmbeddedUnionTest();
+
+# First check the SmallStruct in EmbeddedUnionTest
+$eut->{number} = 1;
+$eut->{uni}->{small} = $small;
+$Jill1 = $eut->{uni}->{small}->{jill};
+if ($Jill1 != 200) {
+ print "Runtime test1 failed. eut.uni.small.jill=" , $Jill1, "\n";
+ exit 1;
+}
+
+$Num1 = $eut->{number};
+if ($Num1 != 1) {
+ print "Runtime test2 failed. eut.number=" , $Num1, "\n";
+ exit 1;
+}
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+$eut->{number} = 2;
+$eut->{uni}->{big} = $big;
+$Jack1 = $eut->{uni}->{big}->{jack};
+if ($Jack1 != 300) {
+ print "Runtime test3 failed. eut.uni.big.jack=" , $Jack1, "\n";
+ exit 1;
+}
+
+$Jill2 = $eut->{uni}->{big}->{smallstruct}->{jill};
+if ($Jill2 != 200) {
+ print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , $Jill2, "\n";
+ exit 1;
+}
+
+$Num2 = $eut->{number};
+if ($Num2 != 2) {
+ print "Runtime test5 failed. eut.number=" , $Num2, "\n";
+ exit 1;
+}
+
diff --git a/Examples/test-suite/php4/Makefile b/Examples/test-suite/php4/Makefile
new file mode 100644
index 000000000..e286f9d5e
--- /dev/null
+++ b/Examples/test-suite/php4/Makefile
@@ -0,0 +1,67 @@
+#######################################################################
+# Makefile for php4 test-suite
+#######################################################################
+
+LANGUAGE = php4
+SCRIPTSUFFIX = _runme.php4
+
+include ../common.mk
+
+# Overridden variables here
+SWIGOPT = -I$(TOP)/../Lib -I$(TOP)/$(TEST_SUITE)
+TARGETPREFIX = php_
+
+makecpptests:
+ @bash -ec 'for test in $(CPP_TEST_CASES) ; do make clean && make $${test}.cpptest; done'
+
+maketests: makecpptests makectests
+
+makectests:
+ @bash -ec 'for test in $(C_TEST_CASES) ; do make clean && make $${test}.cpptest; done'
+
+runcpptests:
+ @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then make clean && make $${test}.cpptest; fi ; done'
+
+runctests:
+ @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then make clean && make $${test}.cpptest; fi; done'
+
+runtests: runcpptests runctests
+
+# write out tests without a _runme.php4
+missingcpptests:
+ @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
+
+missingctests:
+ @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
+
+missingtests: missingcpptests missingctests
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.php4 appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.php4 ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH php -q -d extension_dir=. $*\_runme.php4;) \
+ fi;
+
+# Clean: remove the generated .php file
+%.clean:
+ @rm -f $*.php;
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile php4_clean
diff --git a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 b/Examples/test-suite/php4/abstract_inherit_ok_runme.php4
new file mode 100644
index 000000000..b03755a00
--- /dev/null
+++ b/Examples/test-suite/php4/abstract_inherit_ok_runme.php4
@@ -0,0 +1,13 @@
+<?php
+
+require "tests.php4";
+require "abstract_inherit_ok.php";
+
+check::classes(array(foo,spam));
+$spam=new Spam();
+
+check::equal(0,$spam->blah(),"spam object method");
+check::equal(0,Spam::blah($spam),"spam class method");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/abstract_inherit_runme.php4 b/Examples/test-suite/php4/abstract_inherit_runme.php4
new file mode 100644
index 000000000..358d2741f
--- /dev/null
+++ b/Examples/test-suite/php4/abstract_inherit_runme.php4
@@ -0,0 +1,14 @@
+<?php
+
+require "tests.php4";
+require "abstract_inherit.php";
+
+check::classes(array(foo,bar,spam));
+// This constructor attempt should fail as there isn't one
+//$spam=new Spam();
+
+//check::equal(0,$spam->blah(),"spam object method");
+//check::equal(0,Spam::blah($spam),"spam class method");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/add_link_runme.php4 b/Examples/test-suite/php4/add_link_runme.php4
new file mode 100644
index 000000000..aca3267b6
--- /dev/null
+++ b/Examples/test-suite/php4/add_link_runme.php4
@@ -0,0 +1,23 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "add_link.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(foo));
+
+$foo=new foo();
+check::is_a($foo,foo);
+
+$foo_blah=$foo->blah();
+check::is_a($foo_blah,foo);
+
+//fails, can't be called as a class method, should allow and make it nil?
+//$class_foo_blah=foo::blah();
+//check::is_a($class_foo_blah,foo);
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/anonymous_arg_runme.php4 b/Examples/test-suite/php4/anonymous_arg_runme.php4
new file mode 100644
index 000000000..6d9d9670b
--- /dev/null
+++ b/Examples/test-suite/php4/anonymous_arg_runme.php4
@@ -0,0 +1,13 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "anonymous_arg.php";
+
+check::functions(array(foo));
+// these two should perform without error
+foo();
+foo(7);
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/argout_runme.php4 b/Examples/test-suite/php4/argout_runme.php4
new file mode 100644
index 000000000..adb9dfbc2
--- /dev/null
+++ b/Examples/test-suite/php4/argout_runme.php4
@@ -0,0 +1,37 @@
+<?php
+
+require "tests.php4";
+require "argout.php";
+
+check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));
+
+$ip=copy_intp(42);
+check::equal(42,incp($ip),"42==incp($ip)");
+check::equal(43,intp_value($ip),"43=$ip");
+
+$p=2;
+check::equal(2,incp(&$p),"2==incp($p)");
+check::equal(3,$p,"3==$p");
+
+$r=7;
+check::equal(7,incr(&$r),"7==incr($r)");
+check::equal(8,$r,"8==$r");
+
+$tr=4;
+check::equal(4,inctr(&$tr),"4==incr($tr)");
+check::equal(5,$tr,"5==$tr");
+
+# Check the voidhandle call, first with null
+unset($handle);
+voidhandle(&$handle);
+check::resource($handle,"_p_void",'$handle is not _p_void');
+$handledata=handle($handle);
+check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
+
+unset($handle);
+// without reference, should fatal error so can't test here
+//voidhandle($handle);
+//check::isnull($handle,'$handle not null');
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/arrayptr_runme.php4 b/Examples/test-suite/php4/arrayptr_runme.php4
new file mode 100644
index 000000000..c057a6772
--- /dev/null
+++ b/Examples/test-suite/php4/arrayptr_runme.php4
@@ -0,0 +1,15 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "arrayptr.php";
+
+// No new functions
+check::functions(array(foo));
+// No new classes
+check::classes(array());
+// now new vars
+check::globals(array());
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/arrays_global_runme.php4 b/Examples/test-suite/php4/arrays_global_runme.php4
new file mode 100644
index 000000000..07d3be6ef
--- /dev/null
+++ b/Examples/test-suite/php4/arrays_global_runme.php4
@@ -0,0 +1,16 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "arrays_global.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(simplestruct));
+check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i));
+check::set(array_c,"hac");
+check::equal("ha",check::get(array_c,"ha"),"set array_c");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/arrays_global_twodim_runme.php4 b/Examples/test-suite/php4/arrays_global_twodim_runme.php4
new file mode 100644
index 000000000..799dfdc2d
--- /dev/null
+++ b/Examples/test-suite/php4/arrays_global_twodim_runme.php4
@@ -0,0 +1,25 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "arrays_global_twodim.php";
+
+// No new functions
+check::functions(array(fn_taking_arrays,get_2d_array));
+// No new classes
+check::classes(array(simplestruct));
+check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i));
+$a1=array(10,11,12,13);
+$a2=array(14,15,16,17);
+$a=array($a1,$a2);
+
+$_a=check::get(array_const_i);
+
+for($x=0;$x<count($a1);$x++) {
+ for($y=0;$y<2;$y++) {
+ check::equal($a[$y][$x],get_2d_array($_a,$y,$x),"check array $x,$y");
+ }
+}
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/arrays_runme.php4 b/Examples/test-suite/php4/arrays_runme.php4
new file mode 100644
index 000000000..ee240e58f
--- /dev/null
+++ b/Examples/test-suite/php4/arrays_runme.php4
@@ -0,0 +1,22 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "arrays.php";
+
+// No new functions
+check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer));
+// No new classes
+check::classes(array(simplestruct,arraystruct));
+// now new vars
+check::globals(array());
+
+$ss=new simplestruct();
+check::classname(simplestruct,$ss);
+
+$as=new arraystruct();
+$as->array_c="abc";
+check::equal($as->array_c,"ab",'$as->array_c=="ab"');
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/arrays_scope_runme.php4 b/Examples/test-suite/php4/arrays_scope_runme.php4
new file mode 100644
index 000000000..7d2172c72
--- /dev/null
+++ b/Examples/test-suite/php4/arrays_scope_runme.php4
@@ -0,0 +1,17 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "arrays_scope.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(bar));
+// now new vars
+check::globals(array());
+
+$bar=new bar();
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/bool_default_runme.php4 b/Examples/test-suite/php4/bool_default_runme.php4
new file mode 100644
index 000000000..42eadea4f
--- /dev/null
+++ b/Examples/test-suite/php4/bool_default_runme.php4
@@ -0,0 +1,20 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "bool_default.php";
+
+// No new functions
+check::functions(array(foo));
+// No new classes
+check::classes(array());
+// now new vars
+check::globals(array());
+
+check::equal(false,foo(),"foo()==false");
+check::equal(false,foo(1),"foo(1)==false");
+check::equal(false,foo(true),"foo(true)==false");
+check::equal(true,foo(false),"foo(false)==true");
+check::equal(true,foo(0),"foo(0)==true");
+check::done();
+?>
diff --git a/Examples/test-suite/php4/casts_runme.php4 b/Examples/test-suite/php4/casts_runme.php4
new file mode 100644
index 000000000..bcda296af
--- /dev/null
+++ b/Examples/test-suite/php4/casts_runme.php4
@@ -0,0 +1,19 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "casts.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(a,b));
+// now new vars
+check::globals(array());
+
+# Make sure $b inherites hello() from class A
+$b=new B();
+$b->hello();
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/class_ignore_runme.php4 b/Examples/test-suite/php4/class_ignore_runme.php4
new file mode 100644
index 000000000..2a202fe1b
--- /dev/null
+++ b/Examples/test-suite/php4/class_ignore_runme.php4
@@ -0,0 +1,19 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "class_ignore.php";
+
+// No new functions
+check::functions(array(do_blah));
+// No new classes
+check::classes(array(bar));
+// now new vars
+check::globals(array());
+
+$bar=new bar();
+do_blah($bar);
+check::classparent($bar,"");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/conversion_namespace_runme.php4 b/Examples/test-suite/php4/conversion_namespace_runme.php4
new file mode 100644
index 000000000..50f1539ec
--- /dev/null
+++ b/Examples/test-suite/php4/conversion_namespace_runme.php4
@@ -0,0 +1,14 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "conversion_namespace.php";
+
+check::classes(array("foo","bar"));
+$bar=new Bar;
+check::classname("bar",$bar);
+$foo=$bar->toFoo();
+check::classname("foo",$foo);
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/conversion_ns_template_runme.php4 b/Examples/test-suite/php4/conversion_ns_template_runme.php4
new file mode 100644
index 000000000..3493a3521
--- /dev/null
+++ b/Examples/test-suite/php4/conversion_ns_template_runme.php4
@@ -0,0 +1,10 @@
+<?php
+
+require "tests.php4";
+require "conversion_ns_template.php";
+
+check::classes(array("foo_one","bar_one"));
+// this is too hard, I'm not sure what to test for,
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/conversion_runme.php4 b/Examples/test-suite/php4/conversion_runme.php4
new file mode 100644
index 000000000..ef2a11c9d
--- /dev/null
+++ b/Examples/test-suite/php4/conversion_runme.php4
@@ -0,0 +1,14 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "conversion.php";
+
+check::classes(array("foo","bar"));
+$bar=new Bar;
+check::classname("bar",$bar);
+$foo=$bar->toFoo();
+check::classname("foo",$foo);
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/cpp_static_runme.php4 b/Examples/test-suite/php4/cpp_static_runme.php4
new file mode 100644
index 000000000..da42efd91
--- /dev/null
+++ b/Examples/test-suite/php4/cpp_static_runme.php4
@@ -0,0 +1,15 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "cpp_static.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(staticmembertest,staticfunctiontest));
+// now new vars
+check::globals(array());
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/enum_scope_runme.php4 b/Examples/test-suite/php4/enum_scope_runme.php4
new file mode 100644
index 000000000..eaa0c0179
--- /dev/null
+++ b/Examples/test-suite/php4/enum_scope_runme.php4
@@ -0,0 +1,17 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "enum_scope.php";
+
+check::classes("tree");
+check::functions("chops");
+check::equal(0,Tree_Oak,"0==Tree_Oak");
+check::equal(1,Tree_Fir,"1==Tree_Fir");
+check::equal(2,Tree_Cedar,"2==Tree_Cedar");
+check::equal(Tree_Oak,chops(Tree_Oak),"Tree_Oak==chops(Tree_Oak)");
+check::equal(Tree_Fir,chops(Tree_Fir),"Tree_Fir==chops(Tree_Fir)");
+check::equal(Tree_Cedar,chops(Tree_Cedar),"Tree_Cedar==chops(Tree_Cedar)");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/enum_scope_template_runme.php4 b/Examples/test-suite/php4/enum_scope_template_runme.php4
new file mode 100644
index 000000000..5f5d53540
--- /dev/null
+++ b/Examples/test-suite/php4/enum_scope_template_runme.php4
@@ -0,0 +1,17 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "enum_scope_template.php";
+
+check::classes("treeint");
+check::functions("chops");
+check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
+check::equal(1,TreeInt_Fir,"0==TreeInt_Fir");
+check::equal(2,TreeInt_Cedar,"0==TreeInt_Cedar");
+check::equal(TreeInt_Oak,chops(TreeInt_Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
+check::equal(TreeInt_Fir,chops(TreeInt_Fir),"TreeInt_Fir==chops(TreeInt_Fir)");
+check::equal(TreeInt_Cedar,chops(TreeInt_Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/evil_diamond_ns_runme.php4 b/Examples/test-suite/php4/evil_diamond_ns_runme.php4
new file mode 100644
index 000000000..ba24e9b00
--- /dev/null
+++ b/Examples/test-suite/php4/evil_diamond_ns_runme.php4
@@ -0,0 +1,19 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "evil_diamond_ns.php";
+
+check::classes(array("foo","bar","baz","spam"));
+check::functions("test");
+check::is_a("bar","foo");
+check::is_a("baz","foo");
+check::is_a("spam","foo");
+check::is_a("spam","bar");
+//No multiple inheritance
+//check::is_a("spam","baz");
+$spam=new spam();
+$_spam=test($spam);
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/evil_diamond_prop_runme.php4 b/Examples/test-suite/php4/evil_diamond_prop_runme.php4
new file mode 100644
index 000000000..971f98c10
--- /dev/null
+++ b/Examples/test-suite/php4/evil_diamond_prop_runme.php4
@@ -0,0 +1,38 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "evil_diamond_prop.php";
+
+check::classes(array("foo","bar","baz","spam"));
+check::functions("test");
+check::is_a("bar","foo");
+check::is_a("baz","foo");
+check::is_a("spam","foo");
+check::is_a("spam","bar");
+//No multiple inheritance introspection yet
+//check::is_a("spam","baz");
+
+$foo=new foo();
+check::is_a($foo,"foo");
+check::equal(1,$foo->_foo,"1==foo->_foo");
+
+$bar=new bar();
+check::is_a($bar,"bar");
+check::equal(1,$bar->_foo,"1==bar->_foo");
+check::equal(2,$bar->_bar,"2==bar->_bar");
+
+$baz=new baz();
+check::is_a($baz,"baz");
+check::equal(1,$baz->_foo,"1==baz->_foo");
+check::equal(3,$baz->_baz,"3==baz->_baz");
+
+$spam=new spam();
+check::is_a($spam,"spam");
+check::equal(1,$spam->_foo,"1==spam->_foo");
+check::equal(2,$spam->_bar,"2==spam->_bar");
+check::equal(3,$spam->_baz,"3==spam->_baz");
+check::equal(4,$spam->_spam,"4==spam->_spam");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/evil_diamond_runme.php4 b/Examples/test-suite/php4/evil_diamond_runme.php4
new file mode 100644
index 000000000..45da10115
--- /dev/null
+++ b/Examples/test-suite/php4/evil_diamond_runme.php4
@@ -0,0 +1,17 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "evil_diamond.php";
+
+check::classes(array("foo","bar","baz","spam"));
+check::functions("test");
+check::is_a("bar","foo");
+check::is_a("baz","foo");
+check::is_a("spam","foo");
+check::is_a("spam","bar");
+//No multiple inheritance
+//check::is_a("spam","baz");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/extend_template_ns_runme.php4 b/Examples/test-suite/php4/extend_template_ns_runme.php4
new file mode 100644
index 000000000..e15170e7e
--- /dev/null
+++ b/Examples/test-suite/php4/extend_template_ns_runme.php4
@@ -0,0 +1,13 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "extend_template_ns.php";
+
+check::classes(array("foo_one"));
+$foo=new Foo_One();
+check::equal(2,$foo->test1(2),"test1");
+check::equal(3,$foo->test2(3),"test2");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/extend_template_runme.php4 b/Examples/test-suite/php4/extend_template_runme.php4
new file mode 100644
index 000000000..93944f616
--- /dev/null
+++ b/Examples/test-suite/php4/extend_template_runme.php4
@@ -0,0 +1,13 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "extend_template.php";
+
+check::classes(array("foo_0"));
+$foo=new Foo_0();
+check::equal(2,$foo->test1(2),"test1");
+check::equal(3,$foo->test2(3),"test2");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/grouping_runme.php4 b/Examples/test-suite/php4/grouping_runme.php4
new file mode 100644
index 000000000..832b3df0e
--- /dev/null
+++ b/Examples/test-suite/php4/grouping_runme.php4
@@ -0,0 +1,24 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "grouping.php";
+
+check::functions(array("test1","test2","do_unary","negate"));
+check::equal(5,test1(5),"5==test1(5)");
+check::resource(test2(7),"_p_int","_p_int==test2(7)");
+check::globals(array(test3));
+
+//check::equal(37,test3_get(),'37==test3_get()');
+check::equal(37,check::get("test3"),'37==get(test3)');
+//test3_set(38);
+check::set(test3,38);
+//check::equal(38,test3_get(),'38==test3_get() after test3_set(37)');
+check::equal(38,check::get(test3),'38==get(test3) after set(test)');
+
+check::equal(-5,negate(5),"-5==negate(5)");
+check::functionref(NEGATE,"_p_UnaryOp","NEGATE=_p_UnaryOp");
+check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/ignore_parameter_runme.php4 b/Examples/test-suite/php4/ignore_parameter_runme.php4
new file mode 100644
index 000000000..8a2bf899e
--- /dev/null
+++ b/Examples/test-suite/php4/ignore_parameter_runme.php4
@@ -0,0 +1,39 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "ignore_parameter.php";
+
+// No new functions
+check::functions(array(jaguar,lotus,tvr,ferrari));
+// No new classes
+check::classes(array(sportscars,minicooper,morrisminor,fordanglia,austinallegro));
+// now new vars
+check::globals(array());
+
+check::equal(jaguar(2,3.4),"hello",'jaguar(2,3.4)=="hello"');
+check::equal(lotus("eek",3.4),101,'lotus("eek",3.4)==101');
+check::equal(tvr("eek",2),8.8,'tvr("eek",2)==8.8');
+check::equal(ferrari(),101,'ferrari(2)==101');
+
+$sc=new sportscars();
+check::classname("sportscars",$sc);
+check::equal($sc->daimler(2,3.4),"hello",'$sc->daimler(2,3.4)=="hello"');
+check::equal($sc->astonmartin("eek",3.4),101,'$sc->mastonmartin("eek",3.4)==101');
+check::equal($sc->bugatti("eek",2),8.8,'$sc->bugatti("eek",2)==8.8');
+check::equal($sc->lamborghini(),101,'$sc->lamborghini(2)==101');
+
+$mc=new minicooper(2,3.4);
+check::classname("minicooper",$mc);
+
+$mm=new morrisminor("eek",3.4);
+check::classname("morrisminor",$mm);
+
+$fa=new fordanglia("eek",2);
+check::classname("fordanglia",$fa);
+
+$aa=new austinallegro();
+check::classname("austinallegro",$aa);
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/lib_carrays_runme.php4 b/Examples/test-suite/php4/lib_carrays_runme.php4
new file mode 100644
index 000000000..134dbc251
--- /dev/null
+++ b/Examples/test-suite/php4/lib_carrays_runme.php4
@@ -0,0 +1,15 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "lib_carrays.php";
+
+// No new functions
+check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem));
+// No new classes
+check::classes(array(doublearray));
+// now new vars
+check::globals(array());
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/rename_scope_runme.php4 b/Examples/test-suite/php4/rename_scope_runme.php4
new file mode 100644
index 000000000..0be22ee96
--- /dev/null
+++ b/Examples/test-suite/php4/rename_scope_runme.php4
@@ -0,0 +1,17 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "rename_scope.php";
+
+check::classes(array("interface_up","interface_bp","natural_up","natural_bp"));
+
+check::classmethods("Interface_UP",array("interface_up"));
+check::classmethods("Interface_BP",array("interface_bp"));
+check::classmethods("Natural_UP",array("interface_up","natural_up","rtest"));
+check::classmethods("Natural_BP",array("interface_bp","natural_bp","rtest"));
+check::classparent("Natural_UP","interface_up");
+check::classparent("Natural_BP","interface_bp");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/skel.php4 b/Examples/test-suite/php4/skel.php4
new file mode 100644
index 000000000..d6f33758d
--- /dev/null
+++ b/Examples/test-suite/php4/skel.php4
@@ -0,0 +1,15 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "____.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array());
+// now new vars
+check::globals(array());
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/smart_pointer_rename_runme.php4 b/Examples/test-suite/php4/smart_pointer_rename_runme.php4
new file mode 100644
index 000000000..a8b600ab2
--- /dev/null
+++ b/Examples/test-suite/php4/smart_pointer_rename_runme.php4
@@ -0,0 +1,28 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "smart_pointer_rename.php";
+
+check::classes(array("foo","bar"));
+check::classmethods("foo",array("foo","ftest1","ftest2"));
+check::classmethods("bar",array("__deref__","bar","test","ftest1","ftest2"));
+$foo=new foo();
+check::classname("foo",$foo);
+$bar=new bar($foo);
+check::classname("bar",$bar);
+
+# check foo's ftest1, ftest2
+check::equal(1,$foo->ftest1(1),"foo->ftest1");
+check::equal(2,$foo->ftest2(1,2),"foo->ftest2");
+
+# check bar's ftest1, ftest2, ftest
+check::equal(1,$bar->ftest1(1),"bar->ftest1");
+check::equal(2,$bar->ftest2(1,2),"bar->ftest2");
+check::equal(3,$bar->test(),"bar->test");
+
+# check deref returns foo
+check::classname("foo",$bar->__deref__());
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/sym_runme.php4 b/Examples/test-suite/php4/sym_runme.php4
new file mode 100644
index 000000000..ce89ea4b2
--- /dev/null
+++ b/Examples/test-suite/php4/sym_runme.php4
@@ -0,0 +1,23 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "sym.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(flim,flam));
+// now new vars
+check::globals(array());
+
+$flim=new flim();
+$flam=new flam();
+
+check::equal($flim->hulahoops(),"flim-jam","flim()->hulahoops==flim-jam");
+check::equal($flim->jar(),"flim-jar","flim()->jar==flim-jar");
+check::equal($flam->jam(),"flam-jam","flam()->jam==flam-jam");
+check::equal($flam->jar(),"flam-jar","flam()->jar==flam-jar");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/template_arg_typename_runme.php4 b/Examples/test-suite/php4/template_arg_typename_runme.php4
new file mode 100644
index 000000000..eb83badb6
--- /dev/null
+++ b/Examples/test-suite/php4/template_arg_typename_runme.php4
@@ -0,0 +1,19 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "template_arg_typename.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(unaryfunction_bool_bool,boolunaryfunction_bool));
+$ufbb=new unaryfunction_bool_bool();
+check::is_a($ufbb,"unaryfunction_bool_bool");
+
+unset($whatisthis);
+$bufb=new boolunaryfunction_bool(&$whatisthis);
+check::is_a($bufb,"boolunaryfunction_bool");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/template_construct_runme.php4 b/Examples/test-suite/php4/template_construct_runme.php4
new file mode 100644
index 000000000..95316832d
--- /dev/null
+++ b/Examples/test-suite/php4/template_construct_runme.php4
@@ -0,0 +1,11 @@
+<?php
+
+require "tests.php4";
+require "template_construct.php";
+
+check::classes(array(foo_int));
+$foo_int=new foo_int(3);
+check::is_a($foo_int,"foo_int","Made a foo_int");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/tests.php4 b/Examples/test-suite/php4/tests.php4
new file mode 100644
index 000000000..13c732042
--- /dev/null
+++ b/Examples/test-suite/php4/tests.php4
@@ -0,0 +1,217 @@
+<?php
+
+// do we have true global vars or just GETSET functions?
+// Used to filter out get/set global functions to fake vars...
+define(GETSET,1);
+
+$_original_functions=get_defined_functions();
+$_original_globals=1;
+$_original_classes=get_declared_classes();
+$_original_globals=array_keys($GLOBALS);
+
+class check {
+ function get_extra_classes($ref=FALSE) {
+ static $extra;
+ global $_original_classes;
+ if ($ref===FALSE) $f=$_original_classes;
+ if (! is_array($extra)) {
+ $df=array_flip(get_declared_classes());
+ foreach($_original_classes as $class) unset($df[$class]);
+ $extra=array_keys($df);
+ }
+ return $extra;
+ }
+
+ function get_extra_functions($ref=FALSE,$gs=false) {
+ static $extra;
+ static $extrags; // for get/setters
+ global $_original_functions;
+ if ($ref===FALSE) $f=$_original_functions;
+ if (! is_array($extra) || $gs) {
+ $extra=array();
+ $extrags=array();
+ $df=get_defined_functions();
+ $df=array_flip($df[internal]);
+ foreach($_original_functions[internal] as $func) unset($df[$func]);
+ // Now chop out any get/set accessors
+ foreach(array_keys($df) as $func) if (GETSET && ereg('_[gs]et$',$func)) $extrags[]=$func;
+ else $extra[]=$func;
+// $extra=array_keys($df);
+ }
+ if ($gs) return $extrags;
+ return $extra;
+ }
+
+ function get_extra_globals($ref=FALSE) {
+ static $extra;
+ global $_original_globals;
+ if (! is_array($extra)) {
+ if (GETSET) {
+ $_extra=array();
+ foreach(check::get_extra_functions(false,1) as $global) {
+ if (ereg('^(.*)_[sg]et$',$global,$match)) $_extra[$match[1]]=1;
+ }
+ $extra=array_keys($_extra);
+ } else {
+ if ($ref===FALSE) $ref=$_original_globals;
+ if (! is_array($extra)) {
+ $df=array_flip(array_keys($GLOBALS));
+ foreach($_original_globals as $func) unset($df[$func]);
+ // MASK xxxx_LOADED__ variables
+ foreach(array_keys($df) as $func) if (ereg('_LOADED__$',$func)) unset($df[$func]);
+ $extra=array_keys($df);
+ }
+ }
+ }
+ return $extra;
+ }
+
+ function classname($string,$object) {
+ if ($string!=($classname=get_class($object))) return check::fail("Object: $object is of class %s not class %s",$classname,$string);
+ return TRUE;
+ }
+
+ function classmethods($classname,$methods) {
+ if (is_object($classname)) $classname=get_class($classname);
+ $classmethods=array_flip(get_class_methods($classname));
+ $missing=array();
+ $extra=array();
+ foreach($methods as $method) {
+ if (! isset($classmethods[$method])) $missing[]=$method;
+ else unset($classmethods[$method]);
+ }
+ $extra=array_keys($classmethods);
+ if ($missing) $message[]="does not have these methods:\n ".join(",",$missing);
+ if ($extra) $message[]="does have these extra methods:\n ".join(",",$extra);
+ if ($message) {
+ return check::fail("Class %s %s\nFull class list:\n %s\n",$classname,join("\nbut ",$message),join("\n ",get_class_methods($classname)));
+ }
+ return TRUE;
+ }
+
+ function set($var,$value) {
+ $func=$var."_set";
+ if (GETSET) $func($value);
+ else $_GLOBALS[$var]=$value;
+ }
+
+ function &get($var) {
+ $func=$var."_get";
+ if (GETSET) return $func();
+ else return $_GLOBALS[$var];
+ }
+
+ function is_a($a,$b) {
+ if (is_object($a)) $a=strtolower(get_class($a));
+ if (is_object($b)) $a=strtolower(get_class($b));
+ $parents=array();
+ $c=$a;
+ while($c!=$b && $c) {
+ $parents[]=$c;
+ $c=strtolower(get_parent_class($c));
+ }
+ if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierachy:\n %s\n",join("\n ",$parents));
+ return TRUE;
+ }
+
+ function classparent($a,$b) {
+ if (is_object($a)) $a=get_class($a);
+ if (is_object($b)) $a=get_class($b);
+ $parent=get_parent_class($a);
+
+ if ($parent!=$b) return check::fail("Class $a parent not actually $b but $parent");
+ return TRUE;
+ }
+
+ function classes($classes) {
+ if (! is_array($classes)) $classes=array($classes);
+ $message=array();
+ $missing=array();
+ $extra=array_flip(check::get_extra_classes());
+ foreach($classes as $class) {
+ if (! class_exists($class)) $missing[]=$class;
+ else unset($extra[$class]);
+ }
+ if ($missing) $message[]=sprintf("Classes missing: %s",join(",",$missing));
+ if ($extra) $message[]=sprintf("These extra classes are defined: %s",join(",",array_keys($extra)));
+ if ($message) return check::fail(join("\n ",$message));
+ return TRUE;
+ }
+
+ function functions($functions) {
+ if (! is_array($functions)) $functions=array($functions);
+ $message=array();
+ $missing=array();
+ $extra=array_flip(check::get_extra_functions());
+
+ foreach ($functions as $func) {
+ if (! function_exists($func)) $missing[]=$func;
+ else unset($extra[$func]);
+ }
+ if ($missing) $message[]=sprintf("Functions missing: %s",join(",",$missing));
+ if ($extra) $message[]=sprintf("These extra methods are defined: %s",join(",",array_keys($extra)));
+ if ($message) return check::fail(join("\n ",$message));
+ return TRUE;
+ }
+
+ function globals($globals) {
+ if (! is_array($globals)) $globals=array($globals);
+ $message=array();
+ $missing=array();
+ $extra=array_flip(check::get_extra_globals());
+ foreach ($globals as $glob) {
+ if (GETSET) {
+ if (! isset($extra[$glob])) $missing[]=$glob;
+ else unset($extra[$glob]);
+ } else {
+ if (! isset($GLOBALS[$glob])) $missing[]=$glob;
+ else unset($extra[$glob]);
+ }
+ }
+ if ($missing) $message[]=sprintf("Globals missing: %s",join(",",$missing));
+ if ($extra) $message[]=sprintf("These extra globals are defined: %s",join(",",array_keys($extra)));
+ if ($message) return check::fail(join("\n ",$message));
+ return TRUE;
+
+ }
+
+ function functionref($a,$type,$message) {
+ if (! eregi("^_[a-f0-9]+$type$",$a)) return check::fail($message);
+ return TRUE;
+ }
+
+ function equal($a,$b,$message) {
+ if (! ($a===$b)) return check::fail($message);
+ return TRUE;
+ }
+
+ function resource($a,$b,$message) {
+ $resource=trim(check::var_dump($a));
+ if (! eregi("^resource\([0-9]+\) of type \($b\)",$resource)) return check::fail($message);
+ return TRUE;
+ }
+
+ function isnull($a,$message) {
+ $value=trim(check::var_dump($a));
+ return check::equal($value,"NULL",$message);
+ }
+
+ function var_dump($arg) {
+ ob_start();
+ var_dump($arg);
+ $result=ob_get_contents();
+ ob_end_clean();
+ return $result;
+ }
+
+ function fail($pattern) {
+ $args=func_get_args();
+ print("Failed on: ".call_user_func_array("sprintf",$args)."\n");
+ exit(1);
+ }
+
+ function done() {
+ print $_SERVER[argv][0]." ok\n";
+ }
+}
+?>
diff --git a/Examples/test-suite/php4/typedef_reference_runme.php4 b/Examples/test-suite/php4/typedef_reference_runme.php4
new file mode 100644
index 000000000..2c64efce6
--- /dev/null
+++ b/Examples/test-suite/php4/typedef_reference_runme.php4
@@ -0,0 +1,13 @@
+<?php
+
+require "tests.php4";
+require "typedef_reference.php";
+
+check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value));
+$int2=copy_intp(2);
+check::equal(2,somefunc($int2)," test passing intp to somefunc");
+$int3=copy_intp(3);
+check::equal(3,otherfunc($int3)," test passing intp to otherfunc");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/typemap_ns_using_runme.php4 b/Examples/test-suite/php4/typemap_ns_using_runme.php4
new file mode 100644
index 000000000..44403d138
--- /dev/null
+++ b/Examples/test-suite/php4/typemap_ns_using_runme.php4
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php4";
+require "typemap_ns_using.php";
+if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
+if (! 3==spam(3)) die("spam function not working right\n");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/using1_runme.php4 b/Examples/test-suite/php4/using1_runme.php4
new file mode 100644
index 000000000..ed7e32b06
--- /dev/null
+++ b/Examples/test-suite/php4/using1_runme.php4
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php4";
+require "using1.php";
+if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
+if (! 3==spam(3)) die("spam function not working right\n");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/using2_runme.php4 b/Examples/test-suite/php4/using2_runme.php4
new file mode 100644
index 000000000..e57f0ce9a
--- /dev/null
+++ b/Examples/test-suite/php4/using2_runme.php4
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php4";
+require "using2.php";
+if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
+if (! 3==spam(3)) die("spam function not working right\n");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php4/valuewrapper_base_runme.php4 b/Examples/test-suite/php4/valuewrapper_base_runme.php4
new file mode 100644
index 000000000..3cbef0dbb
--- /dev/null
+++ b/Examples/test-suite/php4/valuewrapper_base_runme.php4
@@ -0,0 +1,14 @@
+<?php
+// Sample test file
+
+require "tests.php4";
+require "valuewrapper_base.php";
+
+check::classes(array("base","interface_bp"));
+check::functions("make_interface_bp");
+
+$ibp=make_interface_bp();
+check::classname("interface_bp",$ibp);
+
+check::done();
+?>
diff --git a/Examples/test-suite/pike/Makefile b/Examples/test-suite/pike/Makefile
new file mode 100644
index 000000000..477230808
--- /dev/null
+++ b/Examples/test-suite/pike/Makefile
@@ -0,0 +1,44 @@
+#######################################################################
+# $Header$
+# Makefile for Pike test-suite
+#######################################################################
+
+LANGUAGE = pike
+SCRIPTSUFFIX = _runme.pike
+
+include ../common.mk
+
+# Overridden variables here
+TARGETSUFFIX =
+SWIGOPT = -I$(TOP)/$(TEST_SUITE)
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.pike appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.pike ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH pike $*\_runme.pike;) \
+ fi;
+
+# Clean: remove the generated .pike file
+%.clean:
+ @rm -f $*.pike;
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile pike_clean
+
diff --git a/Examples/test-suite/pointer_in_out.i b/Examples/test-suite/pointer_in_out.i
new file mode 100644
index 000000000..f4b1ed440
--- /dev/null
+++ b/Examples/test-suite/pointer_in_out.i
@@ -0,0 +1,35 @@
+/* This file tests the pointer-in-out typemap library,
+ currently only available for Guile. */
+
+%module pointer_in_out
+
+%include "pointer-in-out.i"
+
+TYPEMAP_POINTER_INPUT_OUTPUT(int *, int-pointer);
+
+int consume_int_pointer(int **INPUT);
+void produce_int_pointer(int **OUTPUT, int value1, int value2);
+void frobnicate_int_pointer(int **INOUT);
+
+%{
+
+int consume_int_pointer(int **INPUT)
+{
+ return **INPUT;
+}
+
+void produce_int_pointer(int **OUTPUT, int value1, int value2)
+{
+ int *foo = malloc(2 * sizeof(int));
+ foo[0] = value1;
+ foo[1] = value2;
+ *OUTPUT = foo;
+}
+
+void frobnicate_int_pointer(int **INOUT)
+{
+ /* advance the pointer */
+ (*INOUT)++;
+}
+
+%}
diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i
new file mode 100644
index 000000000..5d233e5a7
--- /dev/null
+++ b/Examples/test-suite/pointer_reference.i
@@ -0,0 +1,17 @@
+/* This interface file tests whether SWIG handles pointer-reference
+ (*&) arguments.
+
+ SWIG 1.3a5 signals a syntax error.
+*/
+
+%module pointer_reference
+
+#ifdef SWIGGUILE
+/* A silly testing typemap for feeding a doubly indirect integer */
+%typemap(in) int *&XYZZY (int temp1, int *temp2)
+ "temp1 = gh_scm2int($input); temp2 = &temp1; $1 = &temp2;";
+#endif
+
+%inline %{
+void foo(int *&XYZZY) {}
+%}
diff --git a/Examples/test-suite/preproc_1.i b/Examples/test-suite/preproc_1.i
new file mode 100644
index 000000000..134cae666
--- /dev/null
+++ b/Examples/test-suite/preproc_1.i
@@ -0,0 +1,10 @@
+/* This interface file tests whether SWIG's extended C
+ preprocessor is working right.
+
+ In this example, SWIG 1.3.6 chokes on "//" in a #define with a
+ syntax error.
+*/
+
+%module preproc_1
+
+#define SLASHSLASH "//"
diff --git a/Examples/test-suite/preproc_2.i b/Examples/test-suite/preproc_2.i
new file mode 100644
index 000000000..ca5e4c1cb
--- /dev/null
+++ b/Examples/test-suite/preproc_2.i
@@ -0,0 +1,22 @@
+/* This SWIG -*- c -*- interface is to test for some strange
+ preprocessor bug.
+
+ I get syntax errors unless I remove the apostrophe in the comment
+ or the sharp-sign substitution. (The apostrophe seems to disable
+ sharp-sign substitution.)
+*/
+
+%module preproc_2;
+
+%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(SCM_TYPE)
+
+ /* Don't check for NULL pointers (override checks). */
+
+ %typemap(argout, doc="($arg <vector of <" #SCM_TYPE ">>)")
+ int *VECTORLENOUTPUT
+ {
+ }
+
+%enddef
+
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(boolean)
diff --git a/Examples/test-suite/preproc_3.i b/Examples/test-suite/preproc_3.i
new file mode 100644
index 000000000..f6135f3a2
--- /dev/null
+++ b/Examples/test-suite/preproc_3.i
@@ -0,0 +1,6 @@
+%module preproc_3
+
+#define Sum( A, B, \
+ C) \
+ A + B + C
+
diff --git a/Examples/test-suite/primitive_ref.i b/Examples/test-suite/primitive_ref.i
new file mode 100644
index 000000000..f6a7070c8
--- /dev/null
+++ b/Examples/test-suite/primitive_ref.i
@@ -0,0 +1,26 @@
+// Tests passing of references to primitive datatypes
+%module primitive_ref
+
+%define ref(type,name)
+%inline %{
+const type &ref_##name(const type &x) {
+ static type y = x;
+ return y;
+}
+%}
+%enddef
+
+ref(int,int);
+ref(unsigned int, uint);
+ref(short, short);
+ref(unsigned short, ushort);
+ref(long,long);
+ref(unsigned long, ulong);
+ref(signed char, schar);
+ref(unsigned char, uchar);
+ref(char, char);
+ref(float, float);
+ref(double, double);
+ref(bool, bool);
+ref(long long, longlong);
+ref(unsigned long long, ulonglong);
diff --git a/Examples/test-suite/private_assign.i b/Examples/test-suite/private_assign.i
new file mode 100644
index 000000000..6f95df0fb
--- /dev/null
+++ b/Examples/test-suite/private_assign.i
@@ -0,0 +1,21 @@
+// A class with a private assignment operator.
+// This is rare, but sometimes used with singletons and
+// objects that have complicated state.
+
+%module private_assign
+
+%inline %{
+ class Foo {
+ private:
+ Foo &operator=(const Foo &f) {
+ return *this;
+ }
+ public:
+ void bar() { }
+ };
+
+ Foo blah() {
+ return Foo();
+ };
+%}
+
diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i
new file mode 100644
index 000000000..1dd148041
--- /dev/null
+++ b/Examples/test-suite/pure_virtual.i
@@ -0,0 +1,74 @@
+/* SF Bug #445219, submitted by Krzysztof Kozminski
+ <kozminski@users.sf.net>.
+
+ Swig 1.3.6 gets confused by pure virtual destructors,
+ as in this file:
+*/
+
+%module pure_virtual
+
+%warnfilter(802) E; /* Ruby, multiple inheritance */
+
+%nodefault C;
+%nodefault E;
+
+%inline %{
+
+class A {
+ public:
+ A() { };
+ virtual ~A() = 0;
+ virtual void something() = 0;
+ virtual void method() = 0;
+};
+
+class B : public A {
+public:
+ B() {};
+ virtual ~B() { };
+ virtual void something() { };
+ virtual void method() { };
+};
+
+/* class C is abstract because it doesn't define all methods in A */
+class C : public A {
+ public:
+ virtual ~C() { };
+ virtual void method() { };
+}
+;
+
+/* class D is not abstract, it defines everything */
+class D : public C {
+ public:
+ virtual ~D() { };
+ virtual void something() { };
+}
+;
+
+/* Another abstract class */
+class AA {
+ public:
+ virtual void method2() = 0;
+};
+
+/* Multiple inheritance between two abstract classes */
+#ifndef SWIGJAVA
+class E : public C, public AA {
+public:
+ virtual void something() { };
+};
+
+/* Fill in method from AA. This class should be constructable */
+class F : public E {
+ public:
+ virtual void method2() { }
+};
+#endif
+
+%}
+
+%{
+A::~A() {}
+%}
+
diff --git a/Examples/test-suite/python/.cvsignore b/Examples/test-suite/python/.cvsignore
new file mode 100644
index 000000000..0e238873e
--- /dev/null
+++ b/Examples/test-suite/python/.cvsignore
@@ -0,0 +1,5 @@
+*wrap*
+*.py
+*.pyc
+*.so
+*.dll
diff --git a/Examples/test-suite/python/Makefile b/Examples/test-suite/python/Makefile
new file mode 100644
index 000000000..6c563548c
--- /dev/null
+++ b/Examples/test-suite/python/Makefile
@@ -0,0 +1,44 @@
+#######################################################################
+# $Header$
+# Makefile for python test-suite
+#######################################################################
+
+LANGUAGE = python
+SCRIPTSUFFIX = _runme.py
+
+include ../common.mk
+
+# Overridden variables here
+TARGETSUFFIX =
+SWIGOPT = -I$(TOP)/$(TEST_SUITE)
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.py appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.py ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH python $*\_runme.py;) \
+ fi;
+
+# Clean: remove the generated .py file
+%.clean:
+ @rm -f $*.py;
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile python_clean
+
diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README
new file mode 100644
index 000000000..b86ec5289
--- /dev/null
+++ b/Examples/test-suite/python/README
@@ -0,0 +1,4 @@
+See ../README for common README file.
+
+Any testcases which have _runme.py appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/python/abstract_typedef_runme.py b/Examples/test-suite/python/abstract_typedef_runme.py
new file mode 100644
index 000000000..15d70aa42
--- /dev/null
+++ b/Examples/test-suite/python/abstract_typedef_runme.py
@@ -0,0 +1,11 @@
+from abstract_typedef import *
+e = Engine()
+
+a = A()
+
+
+if a.write(e) != 1:
+ raise RuntimeError
+
+
+
diff --git a/Examples/test-suite/python/class_ignore_runme.py b/Examples/test-suite/python/class_ignore_runme.py
new file mode 100644
index 000000000..782fc07e1
--- /dev/null
+++ b/Examples/test-suite/python/class_ignore_runme.py
@@ -0,0 +1,6 @@
+import class_ignore
+
+a = class_ignore.Bar()
+
+if class_ignore.do_blah(a) != "Bar::blah":
+ raise RuntimeError
diff --git a/Examples/test-suite/python/constover_runme.py b/Examples/test-suite/python/constover_runme.py
new file mode 100644
index 000000000..5c5419706
--- /dev/null
+++ b/Examples/test-suite/python/constover_runme.py
@@ -0,0 +1,38 @@
+import constover
+import sys
+error = 0
+
+p = constover.test("test")
+if p != "test":
+ print "test failed!"
+ error = 1
+
+p = constover.test_pconst("test")
+if p != "test_pconst":
+ print "test_pconst failed!"
+ error = 1
+
+f = constover.Foo()
+p = f.test("test")
+if p != "test":
+ print "member-test failed!"
+ error = 1
+
+p = f.test_pconst("test")
+if p != "test_pconst":
+ print "member-test_pconst failed!"
+ error = 1
+
+p = f.test_constm("test")
+if p != "test_constmethod":
+ print "member-test_constm failed!"
+ error = 1
+
+p = f.test_pconstm("test")
+if p != "test_pconstmethod":
+ print "member-test_pconstm failed!"
+ error = 1
+
+sys.exit(error)
+
+
diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py
new file mode 100644
index 000000000..3108b4f47
--- /dev/null
+++ b/Examples/test-suite/python/cpp_namespace_runme.py
@@ -0,0 +1,45 @@
+# Note: This example assumes that namespaces are flattened
+import cpp_namespace
+
+n = cpp_namespace.fact(4)
+if n != 24:
+ raise "Bad return value!"
+
+if cpp_namespace.cvar.Foo != 42:
+ raise "Bad variable value!"
+
+t = cpp_namespace.Test()
+if t.method() != "Test::method":
+ raise "Bad method return value!"
+
+if cpp_namespace.do_method(t) != "Test::method":
+ raise "Bad return value!"
+
+if cpp_namespace.do_method2(t) != "Test::method":
+ raise "Bad return value!"
+
+cpp_namespace.weird("hello", 4)
+
+del t
+
+t2 = cpp_namespace.Test2()
+t3 = cpp_namespace.Test3()
+t4 = cpp_namespace.Test4()
+t5 = cpp_namespace.Test5()
+
+if cpp_namespace.foo3(42) != 42:
+ raise "Bad return value!"
+
+if cpp_namespace.do_method3(t2,40) != "Test2::method":
+ raise "Bad return value!"
+
+if cpp_namespace.do_method3(t3,40) != "Test3::method":
+ raise "Bad return value!"
+
+if cpp_namespace.do_method3(t4,40) != "Test4::method":
+ raise "Bad return value!"
+
+if cpp_namespace.do_method3(t5,40) != "Test5::method":
+ raise "Bad return value!"
+
+
diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py
new file mode 100644
index 000000000..d7d811d4c
--- /dev/null
+++ b/Examples/test-suite/python/default_constructor_runme.py
@@ -0,0 +1,96 @@
+import _default_constructor
+
+dc = _default_constructor
+
+a = dc.new_A
+del_a = dc.delete_A
+
+aa = dc.new_AA
+del_aa = dc.delete_AA
+
+b = dc.new_B
+del_b = dc.delete_B
+
+try:
+ bb = dc.new_BB;
+ print "Whoa. new_BB created."
+except AttributeError:
+ pass
+
+del_bb = dc.delete_BB
+
+try:
+ c = dc.new_C
+ print "Whoa. new_C created."
+except AttributeError:
+ pass
+
+del_c = dc.delete_C
+
+cc = dc.new_CC
+del_cc = dc.delete_CC
+
+try:
+ d = dc.new_D;
+ print "Whoa. new_D created"
+except AttributeError:
+ pass
+
+del_d = dc.delete_D
+
+try:
+ dd = dc.new_DD
+ print "Whoa. new_DD created"
+except AttributeError:
+ pass
+
+dd = dc.delete_DD
+
+try:
+ ad = dc.new_AD
+ print "Whoa. new_AD created"
+except AttributeError:
+ pass
+
+del_ad = dc.delete_AD
+
+e = dc.new_E
+del_e = dc.delete_E
+
+ee = dc.new_EE
+del_ee = dc.delete_EE
+
+try:
+ eb = dc.new_EB
+ print "Whoa. new_EB created"
+except AttributeError:
+ pass
+
+del_eb = dc.delete_EB
+
+f = dc.new_F
+
+try:
+ del_f = dc.delete_F
+ print "Whoa. delete_F created"
+except AttributeError:
+ pass
+
+ff = dc.new_FFF
+try:
+ del_ff = dc.delete_FFF
+ print "Whoa. delete_FFF created"
+except AttributeError:
+ pass
+
+g = dc.new_G
+
+try:
+ del_g = dc.delete_G
+ print "Whoa. delete_G created"
+except AttributeError:
+ pass
+
+gg = dc.new_GG
+del_gg = dc.delete_GG
+
diff --git a/Examples/test-suite/python/dynamic_cast_runme.py b/Examples/test-suite/python/dynamic_cast_runme.py
new file mode 100644
index 000000000..68b06db50
--- /dev/null
+++ b/Examples/test-suite/python/dynamic_cast_runme.py
@@ -0,0 +1,12 @@
+import dynamic_cast
+
+f = dynamic_cast.Foo()
+b = dynamic_cast.Bar()
+
+x = f.blah()
+y = b.blah()
+
+a = dynamic_cast.do_test(y)
+if a != "Bar::test":
+ print "Failed!!"
+
diff --git a/Examples/test-suite/python/enum_runme.py b/Examples/test-suite/python/enum_runme.py
new file mode 100644
index 000000000..6581167de
--- /dev/null
+++ b/Examples/test-suite/python/enum_runme.py
@@ -0,0 +1,7 @@
+
+import _enum
+
+_enum.bar2(1)
+_enum.bar3(1)
+_enum.bar1(1)
+
diff --git a/Examples/test-suite/python/extend_template_ns_runme.py b/Examples/test-suite/python/extend_template_ns_runme.py
new file mode 100644
index 000000000..5c5feac66
--- /dev/null
+++ b/Examples/test-suite/python/extend_template_ns_runme.py
@@ -0,0 +1,7 @@
+from extend_template_ns import *
+f = Foo_One()
+if f.test1(37) != 37:
+ raise RuntimeError
+
+if f.test2(42) != 42:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/extend_template_runme.py b/Examples/test-suite/python/extend_template_runme.py
new file mode 100644
index 000000000..be6e2fc98
--- /dev/null
+++ b/Examples/test-suite/python/extend_template_runme.py
@@ -0,0 +1,8 @@
+import extend_template
+
+f = extend_template.Foo_0()
+if f.test1(37) != 37:
+ raise RuntimeError
+
+if f.test2(42) != 42:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/grouping_runme.py b/Examples/test-suite/python/grouping_runme.py
new file mode 100644
index 000000000..13f8c8c92
--- /dev/null
+++ b/Examples/test-suite/python/grouping_runme.py
@@ -0,0 +1,13 @@
+import grouping
+
+x = grouping.test1(42)
+if x != 42:
+ raise RuntimeError
+
+grouping.test2(42)
+
+x = grouping.do_unary(37, grouping.NEGATE)
+if x != -37:
+ raise RuntimeError
+
+grouping.cvar.test3 = 42
diff --git a/Examples/test-suite/python/import_nomodule_runme.py b/Examples/test-suite/python/import_nomodule_runme.py
new file mode 100644
index 000000000..41fc9d5ba
--- /dev/null
+++ b/Examples/test-suite/python/import_nomodule_runme.py
@@ -0,0 +1,7 @@
+from import_nomodule import *
+
+f = create_Foo()
+test1(f,42)
+
+b = Bar()
+test1(b,37)
diff --git a/Examples/test-suite/python/imports_runme.py b/Examples/test-suite/python/imports_runme.py
new file mode 100644
index 000000000..db2d32d3a
--- /dev/null
+++ b/Examples/test-suite/python/imports_runme.py
@@ -0,0 +1,9 @@
+# This is the import runtime testcase.
+
+import _imports_a
+import _imports_b
+import sys
+
+x = _imports_b.new_B()
+_imports_a.A_hello(x)
+
diff --git a/Examples/test-suite/python/inherit_missing_runme.py b/Examples/test-suite/python/inherit_missing_runme.py
new file mode 100644
index 000000000..60e606401
--- /dev/null
+++ b/Examples/test-suite/python/inherit_missing_runme.py
@@ -0,0 +1,17 @@
+import inherit_missing
+
+a = inherit_missing.new_Foo()
+b = inherit_missing.Bar()
+c = inherit_missing.Spam()
+
+x = inherit_missing.do_blah(a)
+if x != "Foo::blah":
+ print "Whoa! Bad return", x
+
+x = inherit_missing.do_blah(b)
+if x != "Bar::blah":
+ print "Whoa! Bad return", x
+
+x = inherit_missing.do_blah(c)
+if x != "Spam::blah":
+ print "Whoa! Bad return", x
diff --git a/Examples/test-suite/python/lib_std_vector_runme.py b/Examples/test-suite/python/lib_std_vector_runme.py
new file mode 100644
index 000000000..1b196f550
--- /dev/null
+++ b/Examples/test-suite/python/lib_std_vector_runme.py
@@ -0,0 +1,17 @@
+from lib_std_vector import *
+
+iv = IntVector(4)
+for i in range(0,4):
+ iv[i] = i
+
+x = average(iv)
+y = average([1,2,3,4])
+
+a = half([10,10.5,11,11.5])
+
+dv = DoubleVector(10)
+for i in range(0,10):
+ dv[i] = i/2.0
+
+halve_in_place(dv)
+
diff --git a/Examples/test-suite/python/minherit_runme.py b/Examples/test-suite/python/minherit_runme.py
new file mode 100644
index 000000000..d7ad0b36b
--- /dev/null
+++ b/Examples/test-suite/python/minherit_runme.py
@@ -0,0 +1,71 @@
+
+import minherit
+
+a = minherit.Foo()
+b = minherit.Bar()
+c = minherit.FooBar()
+d = minherit.Spam()
+
+if a.xget() != 1:
+ raise RuntimeError, "Bad attribute value"
+
+if b.yget() != 2:
+ raise RuntimeError, "Bad attribute value"
+
+if c.xget() != 1 or c.yget() != 2 or c.zget() != 3:
+ raise RuntimeError, "Bad attribute value"
+
+if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4:
+ raise RuntimeError, "Bad attribute value"
+
+
+if minherit.xget(a) != 1:
+ raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a))
+
+if minherit.yget(b) != 2:
+ raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b))
+
+if minherit.xget(c) != 1 or minherit.yget(c) != 2 or minherit.zget(c) != 3:
+ raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(c), minherit.yget(c), minherit.zget(c))
+
+if minherit.xget(d) != 1 or minherit.yget(d) != 2 or minherit.zget(d) != 3 or minherit.wget(d) != 4:
+ raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d))
+
+# Cleanse all of the pointers and see what happens
+
+aa = minherit.toFooPtr(a)
+bb = minherit.toBarPtr(b)
+cc = minherit.toFooBarPtr(c)
+dd = minherit.toSpamPtr(d)
+
+if aa.xget() != 1:
+ raise RuntimeError, "Bad attribute value"
+
+if bb.yget() != 2:
+ raise RuntimeError, "Bad attribute value"
+
+if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3:
+ raise RuntimeError, "Bad attribute value"
+
+if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4:
+ raise RuntimeError, "Bad attribute value"
+
+if minherit.xget(aa) != 1:
+ raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa))
+
+if minherit.yget(bb) != 2:
+ raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb))
+
+if minherit.xget(cc) != 1 or minherit.yget(cc) != 2 or minherit.zget(cc) != 3:
+ raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(cc), minherit.yget(cc), minherit.zget(cc))
+
+if minherit.xget(dd) != 1 or minherit.yget(dd) != 2 or minherit.zget(dd) != 3 or minherit.wget(dd) != 4:
+ raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd))
+
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/python/namespace_typemap_runme.py b/Examples/test-suite/python/namespace_typemap_runme.py
new file mode 100644
index 000000000..682ad3bb1
--- /dev/null
+++ b/Examples/test-suite/python/namespace_typemap_runme.py
@@ -0,0 +1,82 @@
+from namespace_typemap import *
+
+if stest1("hello") != "hello":
+ raise RuntimeError
+
+if stest2("hello") != "hello":
+ raise RuntimeError
+
+if stest3("hello") != "hello":
+ raise RuntimeError
+
+if stest4("hello") != "hello":
+ raise RuntimeError
+
+if stest5("hello") != "hello":
+ raise RuntimeError
+
+if stest6("hello") != "hello":
+ raise RuntimeError
+
+if stest7("hello") != "hello":
+ raise RuntimeError
+
+if stest8("hello") != "hello":
+ raise RuntimeError
+
+if stest9("hello") != "hello":
+ raise RuntimeError
+
+if stest10("hello") != "hello":
+ raise RuntimeError
+
+if stest11("hello") != "hello":
+ raise RuntimeError
+
+if stest12("hello") != "hello":
+ raise RuntimeError
+
+c = complex(2,3)
+r = c.real
+
+if ctest1(c) != r:
+ raise RuntimeError
+
+if ctest2(c) != r:
+ raise RuntimeError
+
+if ctest3(c) != r:
+ raise RuntimeError
+
+if ctest4(c) != r:
+ raise RuntimeError
+
+if ctest5(c) != r:
+ raise RuntimeError
+
+if ctest6(c) != r:
+ raise RuntimeError
+
+if ctest7(c) != r:
+ raise RuntimeError
+
+if ctest8(c) != r:
+ raise RuntimeError
+
+if ctest9(c) != r:
+ raise RuntimeError
+
+if ctest10(c) != r:
+ raise RuntimeError
+
+if ctest11(c) != r:
+ raise RuntimeError
+
+if ctest12(c) != r:
+ raise RuntimeError
+
+try:
+ ttest1(-14)
+ raise RuntimeError
+except ValueError:
+ pass
diff --git a/Examples/test-suite/python/overload_copy_runme.py b/Examples/test-suite/python/overload_copy_runme.py
new file mode 100644
index 000000000..6ccf4013e
--- /dev/null
+++ b/Examples/test-suite/python/overload_copy_runme.py
@@ -0,0 +1,3 @@
+from overload_copy import *
+f = Foo()
+g = Foo(f)
diff --git a/Examples/test-suite/python/overload_extend_runme.py b/Examples/test-suite/python/overload_extend_runme.py
new file mode 100644
index 000000000..9fb6920c3
--- /dev/null
+++ b/Examples/test-suite/python/overload_extend_runme.py
@@ -0,0 +1,11 @@
+import overload_extend
+
+f = overload_extend.Foo()
+if f.test(3) != 1:
+ raise RuntimeError
+if f.test("hello") != 2:
+ raise RuntimeError
+if f.test(3.5,2.5) != 3:
+ raise RuntimeError
+
+
diff --git a/Examples/test-suite/python/overload_extendc_runme.py b/Examples/test-suite/python/overload_extendc_runme.py
new file mode 100644
index 000000000..9fb6920c3
--- /dev/null
+++ b/Examples/test-suite/python/overload_extendc_runme.py
@@ -0,0 +1,11 @@
+import overload_extend
+
+f = overload_extend.Foo()
+if f.test(3) != 1:
+ raise RuntimeError
+if f.test("hello") != 2:
+ raise RuntimeError
+if f.test(3.5,2.5) != 3:
+ raise RuntimeError
+
+
diff --git a/Examples/test-suite/python/overload_simple_runme.py b/Examples/test-suite/python/overload_simple_runme.py
new file mode 100644
index 000000000..737ed23eb
--- /dev/null
+++ b/Examples/test-suite/python/overload_simple_runme.py
@@ -0,0 +1,97 @@
+from overload_simple import *
+
+if foo(3) != "foo:int":
+ raise RuntimeError, "foo(int)"
+
+if foo(3.0) != "foo:double":
+ raise RuntimeError, "foo(double)"
+
+if foo("hello") != "foo:char *":
+ raise RuntimeError, "foo(char *)"
+
+f = Foo()
+b = Bar()
+
+if foo(f) != "foo:Foo *":
+ raise RuntimeError, "foo(Foo *)"
+
+if foo(b) != "foo:Bar *":
+ raise RuntimeError, "foo(Bar *)"
+
+v = malloc_void(32)
+
+if foo(v) != "foo:void *":
+ raise RuntimeError, "foo(void *)"
+
+s = Spam()
+
+if s.foo(3) != "foo:int":
+ raise RuntimeError, "Spam::foo(int)"
+
+if s.foo(3.0) != "foo:double":
+ raise RuntimeError, "Spam::foo(double)"
+
+if s.foo("hello") != "foo:char *":
+ raise RuntimeError, "Spam::foo(char *)"
+
+if s.foo(f) != "foo:Foo *":
+ raise RuntimeError, "Spam::foo(Foo *)"
+
+if s.foo(b) != "foo:Bar *":
+ raise RuntimeError, "Spam::foo(Bar *)"
+
+if s.foo(v) != "foo:void *":
+ raise RuntimeError, "Spam::foo(void *)"
+
+if Spam_bar(3) != "bar:int":
+ raise RuntimeError, "Spam::bar(int)"
+
+if Spam_bar(3.0) != "bar:double":
+ raise RuntimeError, "Spam::bar(double)"
+
+if Spam_bar("hello") != "bar:char *":
+ raise RuntimeError, "Spam::bar(char *)"
+
+if Spam_bar(f) != "bar:Foo *":
+ raise RuntimeError, "Spam::bar(Foo *)"
+
+if Spam_bar(b) != "bar:Bar *":
+ raise RuntimeError, "Spam::bar(Bar *)"
+
+if Spam_bar(v) != "bar:void *":
+ raise RuntimeError, "Spam::bar(void *)"
+
+# Test constructors
+
+s = Spam()
+if s.type != "none":
+ raise RuntimeError, "Spam()"
+
+s = Spam(3)
+if s.type != "int":
+ raise RuntimeError, "Spam(int)"
+
+s = Spam(3.4)
+if s.type != "double":
+ raise RuntimeError, "Spam(double)"
+
+s = Spam("hello")
+if s.type != "char *":
+ raise RuntimeError, "Spam(char *)"
+
+s = Spam(f)
+if s.type != "Foo *":
+ raise RuntimeError, "Spam(Foo *)"
+
+s = Spam(b)
+if s.type != "Bar *":
+ raise RuntimeError, "Spam(Bar *)"
+
+s = Spam(v)
+if s.type != "void *":
+ raise RuntimeError, "Spam(void *)"
+
+
+
+
+
diff --git a/Examples/test-suite/python/overload_subtype_runme.py b/Examples/test-suite/python/overload_subtype_runme.py
new file mode 100644
index 000000000..6bf77dc59
--- /dev/null
+++ b/Examples/test-suite/python/overload_subtype_runme.py
@@ -0,0 +1,11 @@
+from overload_subtype import *
+
+f = Foo()
+b = Bar()
+
+if spam(f) != 1:
+ raise RuntimeError, "foo"
+
+if spam(b) != 2:
+ raise RuntimeError, "bar"
+
diff --git a/Examples/test-suite/python/overload_template_runme.py b/Examples/test-suite/python/overload_template_runme.py
new file mode 100644
index 000000000..1398dd739
--- /dev/null
+++ b/Examples/test-suite/python/overload_template_runme.py
@@ -0,0 +1,5 @@
+from overload_template import *
+f = foo()
+
+a = max(3,4)
+b = max(3.4,5.2)
diff --git a/Examples/test-suite/python/primitive_ref_runme.py b/Examples/test-suite/python/primitive_ref_runme.py
new file mode 100644
index 000000000..236019b7c
--- /dev/null
+++ b/Examples/test-suite/python/primitive_ref_runme.py
@@ -0,0 +1,37 @@
+from primitive_ref import *
+
+if ref_int(3) != 3:
+ raise RuntimeError
+
+if ref_uint(3) != 3:
+ raise RuntimeError
+
+if ref_short(3) != 3:
+ raise RuntimeError
+
+if ref_ushort(3) != 3:
+ raise RuntimeError
+
+if ref_long(3) != 3:
+ raise RuntimeError
+
+if ref_ulong(3) != 3:
+ raise RuntimeError
+
+if ref_schar(3) != 3:
+ raise RuntimeError
+
+if ref_uchar(3) != 3:
+ raise RuntimeError
+
+if ref_float(3.5) != 3.5:
+ raise RuntimeError
+
+if ref_double(3.5) != 3.5:
+ raise RuntimeError
+
+if ref_bool(1) != 1:
+ raise RuntimeError
+
+if ref_char('x') != 'x':
+ raise RuntimeError
diff --git a/Examples/test-suite/python/rename_scope_runme.py b/Examples/test-suite/python/rename_scope_runme.py
new file mode 100644
index 000000000..75521d38b
--- /dev/null
+++ b/Examples/test-suite/python/rename_scope_runme.py
@@ -0,0 +1,10 @@
+from rename_scope import *
+
+a = Natural_UP()
+b = Natural_BP()
+
+if a.rtest() != 1:
+ raise RuntimeError
+
+if b.rtest() != 1:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/smart_pointer_multi_runme.py b/Examples/test-suite/python/smart_pointer_multi_runme.py
new file mode 100644
index 000000000..c17053055
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_multi_runme.py
@@ -0,0 +1,15 @@
+from smart_pointer_multi import *
+
+f = Foo()
+b = Bar(f)
+s = Spam(b)
+g = Grok(b)
+
+s.x = 3
+if s.getx() != 3:
+ raise RuntimeError
+
+g.x = 4
+if g.getx() != 4:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py b/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py
new file mode 100644
index 000000000..ebf4c9b09
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py
@@ -0,0 +1,15 @@
+from smart_pointer_multi_typedef import *
+
+f = Foo()
+b = Bar(f)
+s = Spam(b)
+g = Grok(b)
+
+s.x = 3
+if s.getx() != 3:
+ raise RuntimeError
+
+g.x = 4
+if g.getx() != 4:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/smart_pointer_not_runme.py b/Examples/test-suite/python/smart_pointer_not_runme.py
new file mode 100644
index 000000000..4c90b376b
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_not_runme.py
@@ -0,0 +1,42 @@
+from smart_pointer_not import *
+
+f = Foo()
+b = Bar(f)
+s = Spam(f)
+g = Grok(f)
+
+try:
+ x = b.x
+ print "Error! b.x"
+except:
+ pass
+
+try:
+ x = s.x
+ print "Error! s.x"
+except:
+ pass
+
+try:
+ x = g.x
+ print "Error! g.x"
+except:
+ pass
+
+try:
+ x = b.getx()
+ print "Error! b.getx()"
+except:
+ pass
+
+try:
+ x = s.getx()
+ print "Error! s.getx()"
+except:
+ pass
+
+try:
+ x = g.getx()
+ print "Error! g.getx()"
+except:
+ pass
diff --git a/Examples/test-suite/python/smart_pointer_overload_runme.py b/Examples/test-suite/python/smart_pointer_overload_runme.py
new file mode 100644
index 000000000..c9fd3a5b0
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_overload_runme.py
@@ -0,0 +1,21 @@
+from smart_pointer_overload import *
+
+f = Foo()
+b = Bar(f)
+
+
+if f.test(3) != 1:
+ raise RuntimeError
+if f.test(3.5) != 2:
+ raise RuntimeError
+if f.test("hello") != 3:
+ raise RuntimeError
+
+if b.test(3) != 1:
+ raise RuntimeError
+if b.test(3.5) != 2:
+ raise RuntimeError
+if b.test("hello") != 3:
+ raise RuntimeError
+
+
diff --git a/Examples/test-suite/python/smart_pointer_rename_runme.py b/Examples/test-suite/python/smart_pointer_rename_runme.py
new file mode 100644
index 000000000..c6d22273c
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_rename_runme.py
@@ -0,0 +1,13 @@
+from smart_pointer_rename import *
+
+f = Foo()
+b = Bar(f)
+
+if b.test() != 3:
+ raise RuntimeError
+
+if b.ftest1(1) != 1:
+ raise RuntimeError
+
+if b.ftest2(2,3) != 2:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/smart_pointer_simple_runme.py b/Examples/test-suite/python/smart_pointer_simple_runme.py
new file mode 100644
index 000000000..95b678aae
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_simple_runme.py
@@ -0,0 +1,13 @@
+from smart_pointer_simple import *
+
+f = Foo()
+b = Bar(f)
+
+b.x = 3
+if b.getx() != 3:
+ raise RuntimeError
+
+fp = b.__deref__()
+fp.x = 4
+if fp.getx() != 4:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/smart_pointer_typedef_runme.py b/Examples/test-suite/python/smart_pointer_typedef_runme.py
new file mode 100644
index 000000000..eee0537f4
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_typedef_runme.py
@@ -0,0 +1,13 @@
+from smart_pointer_typedef import *
+
+f = Foo()
+b = Bar(f)
+
+b.x = 3
+if b.getx() != 3:
+ raise RuntimeError
+
+fp = b.__deref__()
+fp.x = 4
+if fp.getx() != 4:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/sneaky1_runme.py b/Examples/test-suite/python/sneaky1_runme.py
new file mode 100644
index 000000000..7823e77ea
--- /dev/null
+++ b/Examples/test-suite/python/sneaky1_runme.py
@@ -0,0 +1,5 @@
+import sneaky1
+x = sneaky1.add(3,4)
+y = sneaky1.sub(3,4)
+z = sneaky1.mul(3,4)
+w = sneaky1.divide(3,4)
diff --git a/Examples/test-suite/python/static_const_member_2_runme.py b/Examples/test-suite/python/static_const_member_2_runme.py
new file mode 100644
index 000000000..738daf465
--- /dev/null
+++ b/Examples/test-suite/python/static_const_member_2_runme.py
@@ -0,0 +1,15 @@
+from static_const_member_2 import *
+
+c = Test_int()
+try:
+ a = c.forward_field
+ a = c.current_profile
+ a = c.RightIndex
+ a = Test_int.backward_field
+ a = Test_int.LeftIndex
+ a = Test_int.cavity_flags
+except:
+ print "Failed!!"
+
+
+
diff --git a/Examples/test-suite/python/struct_value_runme.py b/Examples/test-suite/python/struct_value_runme.py
new file mode 100644
index 000000000..727996f53
--- /dev/null
+++ b/Examples/test-suite/python/struct_value_runme.py
@@ -0,0 +1,9 @@
+import struct_value
+
+b = struct_value.Bar()
+
+b.a.x = 3
+if b.a.x != 3: raise RuntimeError
+
+b.b.x = 3
+if b.b.x != 3: raise RuntimeError
diff --git a/Examples/test-suite/python/template_construct_runme.py b/Examples/test-suite/python/template_construct_runme.py
new file mode 100644
index 000000000..3409fdd62
--- /dev/null
+++ b/Examples/test-suite/python/template_construct_runme.py
@@ -0,0 +1 @@
+import template_construct
diff --git a/Examples/test-suite/python/template_inherit_runme.py b/Examples/test-suite/python/template_inherit_runme.py
new file mode 100644
index 000000000..bb1465a2b
--- /dev/null
+++ b/Examples/test-suite/python/template_inherit_runme.py
@@ -0,0 +1,53 @@
+from template_inherit import *
+a = FooInt()
+b = FooDouble()
+c = BarInt()
+d = BarDouble()
+e = FooUInt()
+f = BarUInt()
+
+if a.blah() != "Foo":
+ raise ValueError
+
+if b.blah() != "Foo":
+ raise ValueError
+
+if e.blah() != "Foo":
+ raise ValueError
+
+if c.blah() != "Bar":
+ raise ValueError
+
+if d.blah() != "Bar":
+ raise ValueError
+
+if f.blah() != "Bar":
+ raise ValueError
+
+if c.foomethod() != "foomethod":
+ raise ValueError
+
+if d.foomethod() != "foomethod":
+ raise ValueError
+
+if f.foomethod() != "foomethod":
+ raise ValueError
+
+if invoke_blah_int(a) != "Foo":
+ raise ValueError
+
+if invoke_blah_int(c) != "Bar":
+ raise ValueError
+
+if invoke_blah_double(b) != "Foo":
+ raise ValueError
+
+if invoke_blah_double(d) != "Bar":
+ raise ValueError
+
+if invoke_blah_uint(e) != "Foo":
+ raise ValueError
+
+if invoke_blah_uint(f) != "Bar":
+ raise ValueError
+
diff --git a/Examples/test-suite/python/template_ns4_runme.py b/Examples/test-suite/python/template_ns4_runme.py
new file mode 100644
index 000000000..81107b493
--- /dev/null
+++ b/Examples/test-suite/python/template_ns4_runme.py
@@ -0,0 +1,5 @@
+from template_ns4 import *
+
+d = make_Class_DD();
+if d.test() != "test":
+ raise RuntimeError
diff --git a/Examples/test-suite/python/template_ns_runme.py b/Examples/test-suite/python/template_ns_runme.py
new file mode 100644
index 000000000..20cc9b99c
--- /dev/null
+++ b/Examples/test-suite/python/template_ns_runme.py
@@ -0,0 +1,17 @@
+from template_ns import *
+p1 = pairii(2,3)
+p2 = pairii(p1)
+
+if p2.first != 2:
+ raise RuntimeError
+if p2.second != 3:
+ raise RuntimeError
+
+p3 = pairdd(3.5,2.5)
+p4 = pairdd(p3)
+
+if p4.first != 3.5:
+ raise RuntimeError
+
+if p4.second != 2.5:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/template_rename_runme.py b/Examples/test-suite/python/template_rename_runme.py
new file mode 100644
index 000000000..1fd45ba03
--- /dev/null
+++ b/Examples/test-suite/python/template_rename_runme.py
@@ -0,0 +1,12 @@
+import template_rename
+
+i = template_rename.iFoo()
+d = template_rename.dFoo()
+
+a = i.blah_test(4)
+b = i.spam_test(5)
+c = i.grok_test(6)
+
+x = d.blah_test(7)
+y = d.spam(8)
+z = d.grok_test(9)
diff --git a/Examples/test-suite/python/template_tbase_template_runme.py b/Examples/test-suite/python/template_tbase_template_runme.py
new file mode 100644
index 000000000..d13c5f2c2
--- /dev/null
+++ b/Examples/test-suite/python/template_tbase_template_runme.py
@@ -0,0 +1,5 @@
+from template_tbase_template import *
+
+a = make_Class_dd()
+if a.test() != "test":
+ raise RuntimeError
diff --git a/Examples/test-suite/python/template_type_namespace_runme.py b/Examples/test-suite/python/template_type_namespace_runme.py
new file mode 100644
index 000000000..19ea5f5ce
--- /dev/null
+++ b/Examples/test-suite/python/template_type_namespace_runme.py
@@ -0,0 +1,5 @@
+from template_type_namespace import *
+
+if type(foo()[0]) != type(""):
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py
new file mode 100644
index 000000000..51a1d4e97
--- /dev/null
+++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py
@@ -0,0 +1,95 @@
+import string
+from template_typedef_cplx2 import *
+
+#
+# double case
+#
+
+try:
+ d = make_Identity_double()
+ a = d.this
+except:
+ print d, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % d)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print d, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ e = make_Multiplies_double_double_double_double(d, d)
+ a = e.this
+except:
+ print e, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % e)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print e, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+#
+# complex case
+#
+
+try:
+ c = make_Identity_complex()
+ a = c.this
+except:
+ print c, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % c)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print c, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ f = make_Multiplies_complex_complex_complex_complex(c, c)
+ a = f.this
+except:
+ print f, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % f)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print f, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+#
+# Mix case
+#
+
+try:
+ g = make_Multiplies_double_double_complex_complex(d, c)
+ a = g.this
+except:
+ print g, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % g)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print g, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+try:
+ h = make_Multiplies_complex_complex_double_double(c, d)
+ a = h.this
+except:
+ print h, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % g)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print g, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ a = g.get_value()
+except:
+ print g, "has not get_value() method"
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/template_typedef_cplx3_runme.py b/Examples/test-suite/python/template_typedef_cplx3_runme.py
new file mode 100644
index 000000000..b8ac1b6ef
--- /dev/null
+++ b/Examples/test-suite/python/template_typedef_cplx3_runme.py
@@ -0,0 +1,34 @@
+import string
+from template_typedef_cplx3 import *
+
+#
+# this is OK
+#
+
+
+s = Sin()
+s.get_base_value()
+s.get_value()
+s.get_arith_value()
+my_func_r(s)
+make_Multiplies_double_double_double_double(s,s)
+
+z = CSin()
+z.get_base_value()
+z.get_value()
+z.get_arith_value()
+my_func_c(z)
+make_Multiplies_complex_complex_complex_complex(z,z)
+
+#
+# Here we fail
+#
+d = make_Identity_double()
+my_func_r(d)
+
+c = make_Identity_complex()
+my_func_c(c)
+
+
+
+
diff --git a/Examples/test-suite/python/template_typedef_cplx4_runme.py b/Examples/test-suite/python/template_typedef_cplx4_runme.py
new file mode 100644
index 000000000..faeca219f
--- /dev/null
+++ b/Examples/test-suite/python/template_typedef_cplx4_runme.py
@@ -0,0 +1,34 @@
+import string
+from template_typedef_cplx4 import *
+
+#
+# this is OK
+#
+
+
+s = Sin()
+s.get_base_value()
+s.get_value()
+s.get_arith_value()
+my_func_r(s)
+make_Multiplies_double_double_double_double(s,s)
+
+z = CSin()
+z.get_base_value()
+z.get_value()
+z.get_arith_value()
+my_func_c(z)
+make_Multiplies_complex_complex_complex_complex(z,z)
+
+#
+# Here we fail
+#
+d = make_Identity_double()
+my_func_r(d)
+
+c = make_Identity_complex()
+my_func_c(c)
+
+
+
+
diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py
new file mode 100644
index 000000000..baf9fad01
--- /dev/null
+++ b/Examples/test-suite/python/template_typedef_cplx_runme.py
@@ -0,0 +1,88 @@
+import string
+from template_typedef_cplx import *
+
+#
+# double case
+#
+
+try:
+ d = make_Identity_double()
+ a = d.this
+except:
+ print d, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % d)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print d, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ e = make_Multiplies_double_double_double_double(d, d)
+ a = e.this
+except:
+ print e, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % e)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print e, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+#
+# complex case
+#
+
+try:
+ c = make_Identity_complex()
+ a = c.this
+except:
+ print c, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % c)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print c, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ f = make_Multiplies_complex_complex_complex_complex(c, c)
+ a = f.this
+except:
+ print f, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % f)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print f, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+#
+# Mix case
+#
+
+try:
+ g = make_Multiplies_double_double_complex_complex(d, c)
+ a = g.this
+except:
+ print g, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % g)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print g, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+try:
+ h = make_Multiplies_complex_complex_double_double(c, d)
+ a = h.this
+except:
+ print h, "is not an instance"
+ raise RuntimeError
+
+s = string.split('%s' % g)[1]
+if string.find(s, 'ArithUnaryFunction') == -1:
+ print g, "is not an ArithUnaryFunction"
+ raise RuntimeError
diff --git a/Examples/test-suite/python/template_typedef_import_runme.py b/Examples/test-suite/python/template_typedef_import_runme.py
new file mode 100644
index 000000000..48d88eda0
--- /dev/null
+++ b/Examples/test-suite/python/template_typedef_import_runme.py
@@ -0,0 +1,35 @@
+import string
+from template_typedef_cplx2 import *
+from template_typedef_import import *
+
+#
+# this is OK
+#
+
+
+s = Sin()
+s.get_base_value()
+s.get_value()
+s.get_arith_value()
+my_func_r(s)
+make_Multiplies_double_double_double_double(s,s)
+
+z = CSin()
+z.get_base_value()
+z.get_value()
+z.get_arith_value()
+my_func_c(z)
+make_Multiplies_complex_complex_complex_complex(z,z)
+
+#
+# Here we fail
+#
+d = make_Identity_double()
+my_func_r(d)
+
+c = make_Identity_complex()
+my_func_c(c)
+
+
+
+
diff --git a/Examples/test-suite/python/template_typedef_runme.py b/Examples/test-suite/python/template_typedef_runme.py
new file mode 100644
index 000000000..cf73d5919
--- /dev/null
+++ b/Examples/test-suite/python/template_typedef_runme.py
@@ -0,0 +1,33 @@
+from template_typedef import *
+
+d = make_Identity_float()
+c = make_Identity_real()
+
+
+try:
+ a = d.this
+ a = c.this
+except:
+ raise RuntimeError
+
+try:
+ e = make_Multiplies_float_float_float_float(d, d)
+ a = e.this
+except:
+ print e, "is not an instance"
+ raise RuntimeError
+
+try:
+ f = make_Multiplies_real_real_real_real(c, c)
+ a = f.this
+except:
+ print f, "is not an instance"
+ raise RuntimeError
+
+try:
+ g = make_Multiplies_float_float_real_real(d, c)
+ a = g.this
+except:
+ print g, "is not an instance"
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/typedef_inherit_runme.py b/Examples/test-suite/python/typedef_inherit_runme.py
new file mode 100644
index 000000000..6b7f2d872
--- /dev/null
+++ b/Examples/test-suite/python/typedef_inherit_runme.py
@@ -0,0 +1,23 @@
+import typedef_inherit
+
+a = typedef_inherit.Foo()
+b = typedef_inherit.Bar()
+
+x = typedef_inherit.do_blah(a)
+if x != "Foo::blah":
+ print "Whoa! Bad return", x
+
+x = typedef_inherit.do_blah(b)
+if x != "Bar::blah":
+ print "Whoa! Bad return", x
+
+c = typedef_inherit.Spam()
+d = typedef_inherit.Grok()
+
+x = typedef_inherit.do_blah2(c)
+if x != "Spam::blah":
+ print "Whoa! Bad return", x
+
+x = typedef_inherit.do_blah2(d)
+if x != "Grok::blah":
+ print "Whoa! Bad return", x
diff --git a/Examples/test-suite/python/typedef_scope_runme.py b/Examples/test-suite/python/typedef_scope_runme.py
new file mode 100644
index 000000000..37bfc97b1
--- /dev/null
+++ b/Examples/test-suite/python/typedef_scope_runme.py
@@ -0,0 +1,12 @@
+import typedef_scope
+
+b = typedef_scope.Bar()
+x = b.test1(42,"hello")
+if x != 42:
+ print "Failed!!"
+
+x = b.test2(42,"hello")
+if x != "hello":
+ print "Failed!!"
+
+
diff --git a/Examples/test-suite/python/typemap_namespace_runme.py b/Examples/test-suite/python/typemap_namespace_runme.py
new file mode 100644
index 000000000..581a0f437
--- /dev/null
+++ b/Examples/test-suite/python/typemap_namespace_runme.py
@@ -0,0 +1,8 @@
+from typemap_namespace import *
+
+if test1("hello") != "hello":
+ raise RuntimeError
+
+if test2("hello") != "hello":
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/typemap_ns_using_runme.py b/Examples/test-suite/python/typemap_ns_using_runme.py
new file mode 100644
index 000000000..802ea7f56
--- /dev/null
+++ b/Examples/test-suite/python/typemap_ns_using_runme.py
@@ -0,0 +1,4 @@
+import typemap_ns_using
+
+if typemap_ns_using.spam(37) != 37:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/typename_runme.py b/Examples/test-suite/python/typename_runme.py
new file mode 100644
index 000000000..59a0f1f76
--- /dev/null
+++ b/Examples/test-suite/python/typename_runme.py
@@ -0,0 +1,12 @@
+import typename
+import types
+f = typename.Foo()
+b = typename.Bar()
+
+x = typename.twoFoo(f)
+if not isinstance(x,types.FloatType):
+ print "Wrong return type!"
+y = typename.twoBar(b)
+if not isinstance(y,types.IntType):
+ print "Wrong return type!"
+
diff --git a/Examples/test-suite/python/unions_runme.py b/Examples/test-suite/python/unions_runme.py
new file mode 100644
index 000000000..d59e2429e
--- /dev/null
+++ b/Examples/test-suite/python/unions_runme.py
@@ -0,0 +1,51 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+import unions
+import sys
+import string
+
+# Create new instances of SmallStruct and BigStruct for later use
+small = unions.SmallStruct()
+small.jill = 200
+
+big = unions.BigStruct()
+big.smallstruct = small
+big.jack = 300
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+eut = unions.EmbeddedUnionTest()
+
+# First check the SmallStruct in EmbeddedUnionTest
+eut.number = 1
+eut.uni.small = small
+Jill1 = eut.uni.small.jill
+if (Jill1 != 200):
+ print "Runtime test1 failed. eut.uni.small.jill=" , Jill1
+ sys.exit(1)
+
+Num1 = eut.number
+if (Num1 != 1):
+ print "Runtime test2 failed. eut.number=" , Num1
+ sys.exit(1)
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+eut.number = 2
+eut.uni.big = big
+Jack1 = eut.uni.big.jack
+if (Jack1 != 300):
+ print "Runtime test3 failed. eut.uni.big.jack=" , Jack1
+ sys.exit(1)
+
+Jill2 = eut.uni.big.smallstruct.jill
+if (Jill2 != 200):
+ print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2
+ sys.exit(1)
+
+Num2 = eut.number
+if (Num2 != 2):
+ print "Runtime test5 failed. eut.number=" , Num2
+ sys.exit(1)
+
diff --git a/Examples/test-suite/python/using1_runme.py b/Examples/test-suite/python/using1_runme.py
new file mode 100644
index 000000000..5556c1b6a
--- /dev/null
+++ b/Examples/test-suite/python/using1_runme.py
@@ -0,0 +1,4 @@
+import using1
+
+if using1.spam(37) != 37:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/using2_runme.py b/Examples/test-suite/python/using2_runme.py
new file mode 100644
index 000000000..cf657d734
--- /dev/null
+++ b/Examples/test-suite/python/using2_runme.py
@@ -0,0 +1,4 @@
+import using2
+
+if using2.spam(37) != 37:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/using_composition_runme.py b/Examples/test-suite/python/using_composition_runme.py
new file mode 100644
index 000000000..866453a2a
--- /dev/null
+++ b/Examples/test-suite/python/using_composition_runme.py
@@ -0,0 +1,11 @@
+from using_composition import *
+
+f = FooBar()
+if f.blah(3) != 3:
+ raise RuntimeError,"blah(int)"
+
+if f.blah(3.5) != 3.5:
+ raise RuntimeError,"blah(double)"
+
+if f.blah("hello") != "hello":
+ raise RuntimeError,"blah(char *)"
diff --git a/Examples/test-suite/python/using_extend_runme.py b/Examples/test-suite/python/using_extend_runme.py
new file mode 100644
index 000000000..1ddc4baa1
--- /dev/null
+++ b/Examples/test-suite/python/using_extend_runme.py
@@ -0,0 +1,17 @@
+from using_extend import *
+
+f = FooBar()
+if f.blah(3) != 3:
+ raise RuntimeError,"blah(int)"
+
+if f.blah(3.5) != 3.5:
+ raise RuntimeError,"blah(double)"
+
+if f.blah("hello") != "hello":
+ raise RuntimeError,"blah(char *)"
+
+if f.blah(3,4) != 7:
+ raise RuntimeError,"blah(int,int)"
+
+if f.blah(3.5,7.5) != (3.5+7.5):
+ raise RuntimeError,"blah(double,double)"
diff --git a/Examples/test-suite/python/using_inherit_runme.py b/Examples/test-suite/python/using_inherit_runme.py
new file mode 100644
index 000000000..15fee6698
--- /dev/null
+++ b/Examples/test-suite/python/using_inherit_runme.py
@@ -0,0 +1,8 @@
+from using_inherit import *
+
+b = Bar()
+if b.test(3) != 3:
+ raise RuntimeError,"test(int)"
+
+if b.test(3.5) != 3.5:
+ raise RuntimeError, "test(double)"
diff --git a/Examples/test-suite/python/using_private_runme.py b/Examples/test-suite/python/using_private_runme.py
new file mode 100644
index 000000000..3d33ed985
--- /dev/null
+++ b/Examples/test-suite/python/using_private_runme.py
@@ -0,0 +1,7 @@
+from using_private import *
+
+f = FooBar()
+f.x = 3
+
+if f.blah(4) != 4:
+ raise RuntimeError, "blah(int)"
diff --git a/Examples/test-suite/python/using_protected_runme.py b/Examples/test-suite/python/using_protected_runme.py
new file mode 100644
index 000000000..525a1cde4
--- /dev/null
+++ b/Examples/test-suite/python/using_protected_runme.py
@@ -0,0 +1,7 @@
+from using_protected import *
+
+f = FooBar()
+f.x = 3
+
+if f.blah(4) != 4:
+ raise RuntimeError, "blah(int)"
diff --git a/Examples/test-suite/python/voidtest_runme.py b/Examples/test-suite/python/voidtest_runme.py
new file mode 100644
index 000000000..e1f46b176
--- /dev/null
+++ b/Examples/test-suite/python/voidtest_runme.py
@@ -0,0 +1,7 @@
+import voidtest
+
+voidtest.globalfunc()
+f = voidtest.Foo()
+f.memberfunc()
+
+voidtest.Foo_staticmemberfunc()
diff --git a/Examples/test-suite/rename_default.i b/Examples/test-suite/rename_default.i
new file mode 100644
index 000000000..67094660e
--- /dev/null
+++ b/Examples/test-suite/rename_default.i
@@ -0,0 +1,27 @@
+// Here's a nice little test for renaming, symbol table management, and default arguments
+
+%module rename_default
+
+// Rename a class member
+%rename(bar2) Foo::bar;
+
+%inline %{
+
+// Define a class
+class Foo {
+public:
+ static int bar;
+ static int spam;
+
+ // Use a renamed member as a default argument. SWIG has to resolve
+ // bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong.
+
+ void method1(int x = bar) {}
+
+ // Use unrenamed member as default
+ void method2(int x = spam) {}
+};
+int Foo::bar = 1;
+int Foo::spam = 2;
+%}
+
diff --git a/Examples/test-suite/rename_scope.i b/Examples/test-suite/rename_scope.i
new file mode 100644
index 000000000..adcf2be05
--- /dev/null
+++ b/Examples/test-suite/rename_scope.i
@@ -0,0 +1,49 @@
+%module rename_scope
+
+%inline
+%{
+ namespace oss
+ {
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ template <Polarization P>
+ struct Interface
+ {
+ };
+ }
+%}
+
+namespace oss
+{
+ // Interface
+ %template(Interface_UP) Interface<UnaryPolarization>;
+ %template(Interface_BP) Interface<BinaryPolarization>;
+
+}
+%inline
+%{
+ namespace oss
+ {
+ namespace interfaces
+ {
+ template <Polarization P>
+ struct Natural : Interface<P>
+ {
+ int test(void) { return 1; }
+ };
+ }
+ }
+%}
+
+namespace oss
+{
+ namespace interfaces
+ {
+ %rename(rtest) Natural<UnaryPolarization>::test;
+ %rename(rtest) Natural<oss::BinaryPolarization>::test;
+
+ // Natural
+ %template(Natural_UP) Natural<UnaryPolarization>;
+ %template(Natural_BP) Natural<BinaryPolarization>;
+ }
+}
diff --git a/Examples/test-suite/ret_by_value.i b/Examples/test-suite/ret_by_value.i
new file mode 100644
index 000000000..273336e00
--- /dev/null
+++ b/Examples/test-suite/ret_by_value.i
@@ -0,0 +1,19 @@
+/* Simple test to check SWIG's handling of return by value */
+
+%module ret_by_value
+
+%warnfilter(801) test; /* Ruby, wrong class name */
+
+%inline %{
+
+typedef struct {
+ int myInt;
+ short myShort;
+} test;
+
+test get_test() {
+ test myTest = {100, 200};
+ return myTest;
+}
+
+%}
diff --git a/Examples/test-suite/return_value_scope.i b/Examples/test-suite/return_value_scope.i
new file mode 100644
index 000000000..d7d97a10a
--- /dev/null
+++ b/Examples/test-suite/return_value_scope.i
@@ -0,0 +1,28 @@
+%module return_value_scope
+%inline %{
+
+namespace Hell {
+class Foo {
+public:
+ Foo(int) { };
+};
+
+class Bar {
+public:
+ typedef Foo fooref;
+};
+
+class Spam {
+public:
+ typedef Bar base;
+ typedef base::fooref rettype;
+ rettype test() {
+ return rettype(1);
+ }
+};
+}
+%}
+
+
+
+
diff --git a/Examples/test-suite/rname.i b/Examples/test-suite/rname.i
new file mode 100644
index 000000000..ad0a75d19
--- /dev/null
+++ b/Examples/test-suite/rname.i
@@ -0,0 +1,48 @@
+// This module tests various facets of the %rename directive
+
+%module rname
+
+/* Applied everywhere */
+%rename(foo_i) foo(int);
+%rename(foo_d) foo(double);
+
+/* Applied only to global scope */
+
+%rename(foo_s) ::foo(short);
+
+/* Applied only to class scope */
+
+%rename(foo_u) *::foo(unsigned);
+
+/* Rename classes in a class hierarchy */
+%rename (RenamedBase) Base;
+%rename (RenamedDerived) Derived;
+
+%inline %{
+class Bar {
+public:
+ char *foo(int) { return (char *) "Bar::foo-int"; }
+ char *foo(double) { return (char *) "Bar::foo-double"; }
+ char *foo(short) { return (char *) "Bar::foo-short"; }
+ char *foo(unsigned) { return (char *) "Bar::foo-unsigned"; }
+};
+
+char *foo(int) { return (char *) "foo-int"; }
+char *foo(double) { return (char *) "foo-double"; }
+char *foo(short) { return (char *) "foo-short"; }
+char *foo(unsigned) { return (char *) "foo-unsigned"; }
+
+class Base {
+public:
+ Base(){};
+ virtual ~Base(){};
+};
+class Derived : public Base {
+public:
+ Derived(){}
+ ~Derived(){}
+ void fn(Derived derived, Base* basePtr, Base& baseRef){} // test renamed classes in a function
+};
+
+
+%}
diff --git a/Examples/test-suite/ruby/.cvsignore b/Examples/test-suite/ruby/.cvsignore
new file mode 100644
index 000000000..09e0b6c2e
--- /dev/null
+++ b/Examples/test-suite/ruby/.cvsignore
@@ -0,0 +1,3 @@
+*wrap*
+*.so
+*.dll
diff --git a/Examples/test-suite/ruby/Makefile b/Examples/test-suite/ruby/Makefile
new file mode 100644
index 000000000..eec1f10a4
--- /dev/null
+++ b/Examples/test-suite/ruby/Makefile
@@ -0,0 +1,41 @@
+#######################################################################
+# $Header$
+# Makefile for ruby test-suite
+#######################################################################
+
+LANGUAGE = ruby
+SCRIPTSUFFIX = _runme.rb
+
+include ../common.mk
+
+# Overridden variables here
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.rb appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.rb ]; then ( \
+ ruby $*\_runme.rb;) \
+ fi;
+
+# Clean
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
diff --git a/Examples/test-suite/ruby/README b/Examples/test-suite/ruby/README
new file mode 100644
index 000000000..c4ace93e6
--- /dev/null
+++ b/Examples/test-suite/ruby/README
@@ -0,0 +1,4 @@
+See ../README for common README file.
+
+Any testcases which have _runme.rb appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/ruby/class_ignore_runme.rb b/Examples/test-suite/ruby/class_ignore_runme.rb
new file mode 100755
index 000000000..0b47a7fad
--- /dev/null
+++ b/Examples/test-suite/ruby/class_ignore_runme.rb
@@ -0,0 +1,10 @@
+require 'class_ignore'
+
+a = Class_ignore::Bar.new
+
+# Even though we didn't wrap the Foo class, this call
+# to do_blah() should succeed.
+
+if Class_ignore.do_blah(a) != "Bar::blah"
+ raise RuntimeError
+end
diff --git a/Examples/test-suite/ruby/constover_runme.rb b/Examples/test-suite/ruby/constover_runme.rb
new file mode 100755
index 000000000..04d516b75
--- /dev/null
+++ b/Examples/test-suite/ruby/constover_runme.rb
@@ -0,0 +1,44 @@
+require 'constover'
+
+error = 0
+
+p = Constover.test("test")
+if p != "test"
+ puts "test failed!"
+ error = 1
+end
+
+p = Constover.test_pconst("test")
+if p != "test_pconst"
+ puts "test_pconst failed!"
+ error = 1
+end
+
+f = Constover::Foo.new
+p = f.test("test")
+if p != "test"
+ print "member-test failed!"
+ error = 1
+end
+
+p = f.test_pconst("test")
+if p != "test_pconst"
+ print "member-test_pconst failed!"
+ error = 1
+end
+
+p = f.test_constm("test")
+if p != "test_constmethod"
+ print "member-test_constm failed!"
+ error = 1
+end
+
+p = f.test_pconstm("test")
+if p != "test_pconstmethod"
+ print "member-test_pconstm failed!"
+ error = 1
+end
+
+exit(error)
+
+
diff --git a/Examples/test-suite/ruby/cpp_namespace_runme.rb b/Examples/test-suite/ruby/cpp_namespace_runme.rb
new file mode 100755
index 000000000..db44b45f0
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp_namespace_runme.rb
@@ -0,0 +1,51 @@
+# Note: This example assumes that namespaces are flattened
+require 'cpp_namespace'
+
+n = Cpp_namespace.fact(4)
+if n != 24
+ raise "Bad return value!"
+end
+
+if Cpp_namespace.Foo != 42
+ raise "Bad variable value!"
+end
+
+t = Cpp_namespace::Test.new
+if t.method() != "Test::method"
+ raise "Bad method return value!"
+end
+
+if Cpp_namespace.do_method(t) != "Test::method"
+ raise "Bad return value!"
+end
+
+if Cpp_namespace.do_method2(t) != "Test::method"
+ raise "Bad return value!"
+end
+
+Cpp_namespace.weird("hello", 4)
+
+t2 = Cpp_namespace::Test2.new
+t3 = Cpp_namespace::Test3.new
+t4 = Cpp_namespace::Test4.new
+t5 = Cpp_namespace::Test5.new
+
+if Cpp_namespace.foo3(42) != 42
+ raise "Bad return value!"
+end
+
+if Cpp_namespace.do_method3(t2, 40) != "Test2::method"
+ raise "Bad return value!"
+end
+
+if Cpp_namespace.do_method3(t3, 40) != "Test3::method"
+ raise "Bad return value!"
+end
+
+if Cpp_namespace.do_method3(t4, 40) != "Test4::method"
+ raise "Bad return value!"
+end
+
+if Cpp_namespace.do_method3(t5, 40) != "Test5::method"
+ raise "Bad return value!"
+end
diff --git a/Examples/test-suite/ruby/default_constructor_runme.rb b/Examples/test-suite/ruby/default_constructor_runme.rb
new file mode 100755
index 000000000..fc1f42937
--- /dev/null
+++ b/Examples/test-suite/ruby/default_constructor_runme.rb
@@ -0,0 +1,94 @@
+require 'default_constructor'
+
+include Default_constructor
+
+# Ruby 1.6 raises NameError if you try to call Class.new where no constructor
+# is defined; Ruby 1.7 changed this to NoMethodError
+
+NoConstructorError = Kernel.const_defined?("NoMethodError") ? NoMethodError : NameError
+
+# This should be no problem
+a = A.new
+
+# Nor should this
+aa = AA.new
+
+# The default constructor for B is private, so this should raise an exception
+begin
+ b = B.new
+rescue ArgumentError
+ # pass
+end
+
+# The two-argument constructor for B should work
+b = B.new(3, 4)
+
+# BB shouldn't inherit B's default constructor, so this should raise an exception
+begin
+ bb = BB.new
+ puts "Whoa. new BB created."
+rescue NoConstructorError
+ # pass
+end
+
+# C's constructor is protected, so this should raise an exception
+begin
+ c = C.new
+ print "Whoa. new C created."
+rescue NoConstructorError
+ # pass
+end
+
+# CC gets a default constructor, so no problem here
+cc = CC.new
+
+# D's constructor is private, so this should fail
+begin
+ d = D.new
+ puts "Whoa. new D created"
+rescue NoConstructorError
+ # pass
+end
+
+# DD shouldn't get a default constructor, so this should fail
+begin
+ dd = DD.new
+ puts "Whoa. new DD created"
+rescue NoConstructorError
+ # pass
+end
+
+# AD shouldn't get a default constructor, so this should fail
+begin
+ ad = AD.new
+ puts "Whoa. new AD created"
+rescue NoConstructorError
+ # pass
+end
+
+# Both of the arguments to E's constructor have default values,
+# so this should be fine.
+e = E.new
+
+# EE should get a default constructor
+ee = EE.new
+
+# EB should not get a default constructor (because B doesn't have one)
+begin
+ eb = EB.new
+ puts "Whoa. new EB created"
+rescue NoConstructorError
+ # pass
+end
+
+# This should work fine
+f = F.new
+
+# This should work fine
+ff = FFF.new
+
+# This should work fine
+g = G.new
+
+# This should work fine
+gg = GG.new
diff --git a/Examples/test-suite/ruby/dynamic_cast_runme.rb b/Examples/test-suite/ruby/dynamic_cast_runme.rb
new file mode 100755
index 000000000..a7f327bb6
--- /dev/null
+++ b/Examples/test-suite/ruby/dynamic_cast_runme.rb
@@ -0,0 +1,13 @@
+require 'dynamic_cast'
+
+f = Dynamic_cast::Foo.new
+b = Dynamic_cast::Bar.new
+
+x = f.blah
+y = b.blah
+
+a = Dynamic_cast.do_test(y)
+if a != "Bar::test"
+ puts "Failed!!"
+end
+
diff --git a/Examples/test-suite/ruby/enum_runme.rb b/Examples/test-suite/ruby/enum_runme.rb
new file mode 100755
index 000000000..9ea9a29e2
--- /dev/null
+++ b/Examples/test-suite/ruby/enum_runme.rb
@@ -0,0 +1,6 @@
+require 'enum'
+
+Enum.bar2(1)
+Enum.bar3(1)
+Enum.bar1(1)
+
diff --git a/Examples/test-suite/ruby/extend_template_ns_runme.rb b/Examples/test-suite/ruby/extend_template_ns_runme.rb
new file mode 100644
index 000000000..a30959bb2
--- /dev/null
+++ b/Examples/test-suite/ruby/extend_template_ns_runme.rb
@@ -0,0 +1,12 @@
+require 'extend_template_ns'
+
+include Extend_template_ns
+
+f = Foo_One.new
+if f.test1(37) != 37
+ raise RuntimeError
+end
+
+if f.test2(42) != 42
+ raise RuntimeError
+end
diff --git a/Examples/test-suite/ruby/extend_template_runme.rb b/Examples/test-suite/ruby/extend_template_runme.rb
new file mode 100644
index 000000000..8787de7dc
--- /dev/null
+++ b/Examples/test-suite/ruby/extend_template_runme.rb
@@ -0,0 +1,10 @@
+require 'extend_template'
+
+f = Extend_template::Foo_0.new
+if f.test1(37) != 37
+ raise RuntimeError
+end
+
+if f.test2(42) != 42
+ raise RuntimeError
+end
diff --git a/Examples/test-suite/ruby/grouping_runme.rb b/Examples/test-suite/ruby/grouping_runme.rb
new file mode 100644
index 000000000..13cf48943
--- /dev/null
+++ b/Examples/test-suite/ruby/grouping_runme.rb
@@ -0,0 +1,15 @@
+require 'grouping'
+
+x = Grouping.test1(42)
+if x != 42
+ raise RuntimeError
+end
+
+Grouping.test2(42)
+
+x = Grouping.do_unary(37, Grouping::NEGATE)
+if x != -37
+ raise RuntimeError
+end
+
+Grouping.test3 = 42
diff --git a/Examples/test-suite/ruby/imports_runme.rb b/Examples/test-suite/ruby/imports_runme.rb
new file mode 100755
index 000000000..0290bbad2
--- /dev/null
+++ b/Examples/test-suite/ruby/imports_runme.rb
@@ -0,0 +1,9 @@
+# This is the import runtime testcase.
+
+require 'imports_a'
+require 'imports_b'
+
+x = Imports_b::B.new
+
+x.hello
+
diff --git a/Examples/test-suite/ruby/inherit_missing_runme.rb b/Examples/test-suite/ruby/inherit_missing_runme.rb
new file mode 100644
index 000000000..476ef0f7c
--- /dev/null
+++ b/Examples/test-suite/ruby/inherit_missing_runme.rb
@@ -0,0 +1,20 @@
+require 'inherit_missing'
+
+a = Inherit_missing.new_Foo()
+b = Inherit_missing::Bar.new
+c = Inherit_missing::Spam.new
+
+x = Inherit_missing.do_blah(a)
+if x != "Foo::blah"
+ puts "Whoa! Bad return #{x}"
+end
+
+x = Inherit_missing.do_blah(b)
+if x != "Bar::blah"
+ puts "Whoa! Bad return #{x}"
+end
+
+x = Inherit_missing.do_blah(c)
+if x != "Spam::blah"
+ puts "Whoa! Bad return #{x}"
+end
diff --git a/Examples/test-suite/ruby/lib_std_vector_runme.rb b/Examples/test-suite/ruby/lib_std_vector_runme.rb
new file mode 100755
index 000000000..587495f8d
--- /dev/null
+++ b/Examples/test-suite/ruby/lib_std_vector_runme.rb
@@ -0,0 +1,17 @@
+require 'lib_std_vector'
+
+include Lib_std_vector
+
+iv = IntVector.new(4)
+0.upto(3) { |i| iv[i] = i }
+
+x = average(iv)
+y = average([1, 2, 3, 4])
+
+a = half([10, 10.5, 11, 11.5])
+
+dv = DoubleVector.new(10)
+0.upto(9) { |i| dv[i] = i/2.0 }
+
+halve_in_place(dv)
+
diff --git a/Examples/test-suite/ruby/namespace_typemap_runme.rb b/Examples/test-suite/ruby/namespace_typemap_runme.rb
new file mode 100755
index 000000000..6416d615a
--- /dev/null
+++ b/Examples/test-suite/ruby/namespace_typemap_runme.rb
@@ -0,0 +1,33 @@
+require 'namespace_typemap'
+
+include Namespace_typemap
+
+raise RuntimeError if stest1("hello") != "hello"
+
+raise RuntimeError if stest2("hello") != "hello"
+
+raise RuntimeError if stest3("hello") != "hello"
+
+raise RuntimeError if stest4("hello") != "hello"
+
+raise RuntimeError if stest5("hello") != "hello"
+
+raise RuntimeError if stest6("hello") != "hello"
+
+raise RuntimeError if stest7("hello") != "hello"
+
+raise RuntimeError if stest8("hello") != "hello"
+
+raise RuntimeError if stest9("hello") != "hello"
+
+raise RuntimeError if stest10("hello") != "hello"
+
+raise RuntimeError if stest11("hello") != "hello"
+
+raise RuntimeError if stest12("hello") != "hello"
+
+begin
+ ttest1(-14)
+ raise RuntimeError
+rescue RangeError
+end
diff --git a/Examples/test-suite/ruby/newobject1_runme.rb b/Examples/test-suite/ruby/newobject1_runme.rb
new file mode 100644
index 000000000..35f77faa2
--- /dev/null
+++ b/Examples/test-suite/ruby/newobject1_runme.rb
@@ -0,0 +1,15 @@
+require 'newobject1'
+
+include Newobject1
+
+foo1 = Foo.makeFoo
+raise RuntimeError if Foo.fooCount != 1
+
+foo2 = foo1.makeMore
+raise RuntimeError if Foo.fooCount != 2
+
+foo1 = nil ; GC.start
+raise RuntimeError if Foo.fooCount != 1
+
+foo2 = nil ; GC.start
+raise RuntimeError if Foo.fooCount != 0
diff --git a/Examples/test-suite/ruby/newobject2_runme.rb b/Examples/test-suite/ruby/newobject2_runme.rb
new file mode 100644
index 000000000..4519b123e
--- /dev/null
+++ b/Examples/test-suite/ruby/newobject2_runme.rb
@@ -0,0 +1,15 @@
+require 'newobject2'
+
+include Newobject2
+
+foo1 = makeFoo
+raise RuntimeError if fooCount != 1
+
+foo2 = makeFoo
+raise RuntimeError if fooCount != 2
+
+foo1 = nil ; GC.start
+raise RuntimeError if fooCount != 1
+
+foo2 = nil ; GC.start
+raise RuntimeError if fooCount != 0
diff --git a/Examples/test-suite/ruby/overload_copy_runme.rb b/Examples/test-suite/ruby/overload_copy_runme.rb
new file mode 100755
index 000000000..2c555a62b
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_copy_runme.rb
@@ -0,0 +1,6 @@
+require 'overload_copy'
+
+include Overload_copy
+
+f = Foo.new
+g = Foo.new(f)
diff --git a/Examples/test-suite/ruby/overload_extend_runme.rb b/Examples/test-suite/ruby/overload_extend_runme.rb
new file mode 100755
index 000000000..2d252a62a
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_extend_runme.rb
@@ -0,0 +1,8 @@
+require 'overload_extend'
+
+f = Overload_extend::Foo.new
+
+raise RuntimeError if f.test(3) != 1
+raise RuntimeError if f.test("hello") != 2
+raise RuntimeError if f.test(3.5,2.5) != 3
+
diff --git a/Examples/test-suite/ruby/overload_extendc_runme.rb b/Examples/test-suite/ruby/overload_extendc_runme.rb
new file mode 100755
index 000000000..354062a5d
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_extendc_runme.rb
@@ -0,0 +1,7 @@
+require 'overload_extend'
+
+f = Overload_extend::Foo.new
+
+raise RuntimeError if f.test(3) != 1
+raise RuntimeError if f.test("hello") != 2
+raise RuntimeError if f.test(3.5,2.5) != 3
diff --git a/Examples/test-suite/ruby/overload_simple_runme.rb b/Examples/test-suite/ruby/overload_simple_runme.rb
new file mode 100755
index 000000000..3fd292a76
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_simple_runme.rb
@@ -0,0 +1,119 @@
+require 'overload_simple'
+
+include Overload_simple
+
+if foo(3) != "foo:int"
+ raise RuntimeError, "foo(int)"
+end
+
+if foo(3.0) != "foo:double"
+ raise RuntimeError, "foo(double)"
+end
+
+if foo("hello") != "foo:char *"
+ raise RuntimeError, "foo(char *)"
+end
+
+f = Foo.new
+b = Bar.new
+
+if foo(f) != "foo:Foo *"
+ raise RuntimeError, "foo(Foo *)"
+end
+
+if foo(b) != "foo:Bar *"
+ raise RuntimeError, "foo(Bar *)"
+end
+
+v = malloc_void(32)
+
+if foo(v) != "foo:void *"
+ raise RuntimeError, "foo(void *)"
+end
+
+s = Spam.new
+
+if s.foo(3) != "foo:int"
+ raise RuntimeError, "Spam::foo(int)"
+end
+
+if s.foo(3.0) != "foo:double"
+ raise RuntimeError, "Spam::foo(double)"
+end
+
+if s.foo("hello") != "foo:char *"
+ raise RuntimeError, "Spam::foo(char *)"
+end
+
+if s.foo(f) != "foo:Foo *"
+ raise RuntimeError, "Spam::foo(Foo *)"
+end
+
+if s.foo(b) != "foo:Bar *"
+ raise RuntimeError, "Spam::foo(Bar *)"
+end
+
+if s.foo(v) != "foo:void *"
+ raise RuntimeError, "Spam::foo(void *)"
+end
+
+if Spam.bar(3) != "bar:int"
+ raise RuntimeError, "Spam::bar(int)"
+end
+
+if Spam.bar(3.0) != "bar:double"
+ raise RuntimeError, "Spam::bar(double)"
+end
+
+if Spam.bar("hello") != "bar:char *"
+ raise RuntimeError, "Spam::bar(char *)"
+end
+
+if Spam.bar(f) != "bar:Foo *"
+ raise RuntimeError, "Spam::bar(Foo *)"
+end
+
+if Spam.bar(b) != "bar:Bar *"
+ raise RuntimeError, "Spam::bar(Bar *)"
+end
+
+if Spam.bar(v) != "bar:void *"
+ raise RuntimeError, "Spam::bar(void *)"
+end
+
+# Test constructors
+
+s = Spam.new
+if s.type != "none"
+ raise RuntimeError, "Spam()"
+end
+
+s = Spam.new(3)
+if s.type != "int"
+ raise RuntimeError, "Spam(int)"
+end
+
+s = Spam.new(3.4)
+if s.type != "double"
+ raise RuntimeError, "Spam(double)"
+end
+
+s = Spam.new("hello")
+if s.type != "char *"
+ raise RuntimeError, "Spam(char *)"
+end
+
+s = Spam.new(f)
+if s.type != "Foo *"
+ raise RuntimeError, "Spam(Foo *)"
+end
+
+s = Spam.new(b)
+if s.type != "Bar *"
+ raise RuntimeError, "Spam(Bar *)"
+end
+
+s = Spam.new(v)
+if s.type != "void *"
+ raise RuntimeError, "Spam(void *)"
+end
diff --git a/Examples/test-suite/ruby/overload_subtype_runme.rb b/Examples/test-suite/ruby/overload_subtype_runme.rb
new file mode 100644
index 000000000..9737c851c
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_subtype_runme.rb
@@ -0,0 +1,15 @@
+require 'overload_subtype'
+
+include Overload_subtype
+
+f = Foo.new
+b = Bar.new
+
+if spam(f) != 1
+ raise RuntimeError, "foo"
+end
+
+if spam(b) != 2
+ raise RuntimeError, "bar"
+end
+
diff --git a/Examples/test-suite/ruby/overload_template_runme.rb b/Examples/test-suite/ruby/overload_template_runme.rb
new file mode 100755
index 000000000..d01887bf4
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_template_runme.rb
@@ -0,0 +1,6 @@
+require 'overload_template'
+
+f = Overload_template.foo()
+
+a = Overload_template.max(3,4)
+b = Overload_template.max(3.4,5.2)
diff --git a/Examples/test-suite/ruby/primitive_ref_runme.rb b/Examples/test-suite/ruby/primitive_ref_runme.rb
new file mode 100755
index 000000000..11bf37439
--- /dev/null
+++ b/Examples/test-suite/ruby/primitive_ref_runme.rb
@@ -0,0 +1,27 @@
+require 'primitive_ref'
+
+include Primitive_ref
+
+raise RuntimeError if ref_int(3) != 3
+
+raise RuntimeError if ref_uint(3) != 3
+
+raise RuntimeError if ref_short(3) != 3
+
+raise RuntimeError if ref_ushort(3) != 3
+
+raise RuntimeError if ref_long(3) != 3
+
+raise RuntimeError if ref_ulong(3) != 3
+
+raise RuntimeError if ref_schar(3) != 3
+
+raise RuntimeError if ref_uchar(3) != 3
+
+raise RuntimeError if ref_float(3.5) != 3.5
+
+raise RuntimeError if ref_double(3.5) != 3.5
+
+raise RuntimeError if ref_bool(true) != true
+
+raise RuntimeError if ref_char('x') != 'x'
diff --git a/Examples/test-suite/ruby/rename_scope_runme.rb b/Examples/test-suite/ruby/rename_scope_runme.rb
new file mode 100644
index 000000000..ea4fa94a6
--- /dev/null
+++ b/Examples/test-suite/ruby/rename_scope_runme.rb
@@ -0,0 +1,10 @@
+require 'rename_scope'
+
+include Rename_scope
+
+a = Natural_UP.new
+b = Natural_BP.new
+
+raise RuntimeError if a.rtest() != 1
+
+raise RuntimeError if b.rtest() != 1
diff --git a/Examples/test-suite/ruby/smart_pointer_const_runme.rb b/Examples/test-suite/ruby/smart_pointer_const_runme.rb
new file mode 100644
index 000000000..cb852cfe0
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_const_runme.rb
@@ -0,0 +1,13 @@
+require 'smart_pointer_const'
+
+include Smart_pointer_const
+
+f = Foo.new
+b = Bar.new(f)
+
+b.x = 3
+raise RuntimeError if b.getx() != 3
+
+fp = b.__deref__()
+fp.x = 4
+raise RuntimeError if fp.getx() != 4
diff --git a/Examples/test-suite/ruby/smart_pointer_multi_runme.rb b/Examples/test-suite/ruby/smart_pointer_multi_runme.rb
new file mode 100644
index 000000000..96b937a85
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_multi_runme.rb
@@ -0,0 +1,15 @@
+require 'smart_pointer_multi'
+
+include Smart_pointer_multi
+
+f = Foo.new
+b = Bar.new(f)
+s = Spam.new(b)
+g = Grok.new(b)
+
+s.x = 3
+raise RuntimeError if s.getx() != 3
+
+g.x = 4
+raise RuntimeError if g.getx() != 4
+
diff --git a/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb b/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb
new file mode 100644
index 000000000..52ddb44f4
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb
@@ -0,0 +1,14 @@
+require 'smart_pointer_multi_typedef'
+
+include Smart_pointer_multi_typedef
+
+f = Foo.new
+b = Bar.new(f)
+s = Spam.new(b)
+g = Grok.new(b)
+
+s.x = 3
+raise RuntimeError if s.getx() != 3
+
+g.x = 4
+raise RuntimeError if g.getx() != 4
diff --git a/Examples/test-suite/ruby/smart_pointer_not_runme.rb b/Examples/test-suite/ruby/smart_pointer_not_runme.rb
new file mode 100644
index 000000000..fcc306115
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_not_runme.rb
@@ -0,0 +1,44 @@
+require 'smart_pointer_not'
+
+include Smart_pointer_not
+
+f = Foo.new
+b = Bar.new(f)
+s = Spam.new(f)
+g = Grok.new(f)
+
+begin
+ x = b.x
+ puts "Error! b.x"
+rescue NameError
+end
+
+begin
+ x = s.x
+ puts "Error! s.x"
+rescue NameError
+end
+
+begin
+ x = g.x
+ puts "Error! g.x"
+rescue NameError
+end
+
+begin
+ x = b.getx()
+ puts "Error! b.getx()"
+rescue NameError
+end
+
+begin
+ x = s.getx()
+ puts "Error! s.getx()"
+rescue NameError
+end
+
+begin
+ x = g.getx()
+ puts "Error! g.getx()"
+rescue NameError
+end
diff --git a/Examples/test-suite/ruby/smart_pointer_overload_runme.rb b/Examples/test-suite/ruby/smart_pointer_overload_runme.rb
new file mode 100644
index 000000000..c32991331
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_overload_runme.rb
@@ -0,0 +1,16 @@
+require 'smart_pointer_overload'
+
+include Smart_pointer_overload
+
+f = Foo.new
+b = Bar.new(f)
+
+
+raise RuntimeError if f.test(3) != 1
+raise RuntimeError if f.test(3.5) != 2
+raise RuntimeError if f.test("hello") != 3
+
+raise RuntimeError if b.test(3) != 1
+raise RuntimeError if b.test(3.5) != 2
+raise RuntimeError if b.test("hello") != 3
+
diff --git a/Examples/test-suite/ruby/smart_pointer_rename_runme.rb b/Examples/test-suite/ruby/smart_pointer_rename_runme.rb
new file mode 100644
index 000000000..0ff378a4c
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_rename_runme.rb
@@ -0,0 +1,12 @@
+require 'smart_pointer_rename'
+
+include Smart_pointer_rename
+
+f = Foo.new
+b = Bar.new(f)
+
+raise RuntimeError if b.test() != 3
+
+raise RuntimeError if b.ftest1(1) != 1
+
+raise RuntimeError if b.ftest2(2,3) != 2
diff --git a/Examples/test-suite/ruby/smart_pointer_simple_runme.rb b/Examples/test-suite/ruby/smart_pointer_simple_runme.rb
new file mode 100644
index 000000000..b2a54b819
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_simple_runme.rb
@@ -0,0 +1,13 @@
+require 'smart_pointer_simple'
+
+include Smart_pointer_simple
+
+f = Foo.new
+b = Bar.new(f)
+
+b.x = 3
+raise RuntimeError if b.getx() != 3
+
+fp = b.__deref__()
+fp.x = 4
+raise RuntimeError if fp.getx() != 4
diff --git a/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb b/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb
new file mode 100644
index 000000000..137723078
--- /dev/null
+++ b/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb
@@ -0,0 +1,13 @@
+require 'smart_pointer_typedef'
+
+include Smart_pointer_typedef
+
+f = Foo.new
+b = Bar.new(f)
+
+b.x = 3
+raise RuntimeError if b.getx() != 3
+
+fp = b.__deref__()
+fp.x = 4
+raise RuntimeError if fp.getx() != 4
diff --git a/Examples/test-suite/ruby/sneaky1_runme.rb b/Examples/test-suite/ruby/sneaky1_runme.rb
new file mode 100755
index 000000000..731e27b97
--- /dev/null
+++ b/Examples/test-suite/ruby/sneaky1_runme.rb
@@ -0,0 +1,6 @@
+require 'sneaky1'
+
+x = Sneaky1.add(3, 4)
+y = Sneaky1.sub(3, 4)
+z = Sneaky1.mul(3, 4)
+w = Sneaky1.divide(3, 4)
diff --git a/Examples/test-suite/ruby/template_inherit_runme.rb b/Examples/test-suite/ruby/template_inherit_runme.rb
new file mode 100755
index 000000000..e2c947495
--- /dev/null
+++ b/Examples/test-suite/ruby/template_inherit_runme.rb
@@ -0,0 +1,40 @@
+require 'template_inherit'
+
+include Template_inherit
+
+a = FooInt.new
+b = FooDouble.new
+c = BarInt.new
+d = BarDouble.new
+e = FooUInt.new
+f = BarUInt.new
+
+raise ValueError if a.blah() != "Foo"
+
+raise ValueError if b.blah() != "Foo"
+
+raise ValueError if e.blah() != "Foo"
+
+raise ValueError if c.blah() != "Bar"
+
+raise ValueError if d.blah() != "Bar"
+
+raise ValueError if f.blah() != "Bar"
+
+raise ValueError if c.foomethod() != "foomethod"
+
+raise ValueError if d.foomethod() != "foomethod"
+
+raise ValueError if f.foomethod() != "foomethod"
+
+raise ValueError if invoke_blah_int(a) != "Foo"
+
+raise ValueError if invoke_blah_int(c) != "Bar"
+
+raise ValueError if invoke_blah_double(b) != "Foo"
+
+raise ValueError if invoke_blah_double(d) != "Bar"
+
+raise ValueError if invoke_blah_uint(e) != "Foo"
+
+raise ValueError if invoke_blah_uint(f) != "Bar"
diff --git a/Examples/test-suite/ruby/template_ns4_runme.rb b/Examples/test-suite/ruby/template_ns4_runme.rb
new file mode 100755
index 000000000..5c55ff94f
--- /dev/null
+++ b/Examples/test-suite/ruby/template_ns4_runme.rb
@@ -0,0 +1,4 @@
+require 'template_ns4'
+
+d = Template_ns4.make_Class_DD()
+raise RuntimeError if d.test() != "test"
diff --git a/Examples/test-suite/ruby/template_ns_runme.rb b/Examples/test-suite/ruby/template_ns_runme.rb
new file mode 100755
index 000000000..d69e8e3d4
--- /dev/null
+++ b/Examples/test-suite/ruby/template_ns_runme.rb
@@ -0,0 +1,15 @@
+require 'template_ns'
+
+include Template_ns
+
+p1 = Pairii.new(2, 3)
+p2 = Pairii.new(p1)
+
+raise RuntimeError if p2.first != 2
+raise RuntimeError if p2.second != 3
+
+p3 = Pairdd.new(3.5, 2.5)
+p4 = Pairdd.new(p3)
+
+raise RuntimeError if p4.first != 3.5
+raise RuntimeError if p4.second != 2.5
diff --git a/Examples/test-suite/ruby/template_rename_runme.rb b/Examples/test-suite/ruby/template_rename_runme.rb
new file mode 100755
index 000000000..04be6c94d
--- /dev/null
+++ b/Examples/test-suite/ruby/template_rename_runme.rb
@@ -0,0 +1,12 @@
+require 'template_rename'
+
+i = Template_rename::IFoo.new
+d = Template_rename::DFoo.new
+
+a = i.blah_test(4)
+b = i.spam_test(5)
+c = i.grok_test(6)
+
+x = d.blah_test(7)
+y = d.spam(8)
+z = d.grok_test(9)
diff --git a/Examples/test-suite/ruby/typedef_inherit_runme.rb b/Examples/test-suite/ruby/typedef_inherit_runme.rb
new file mode 100755
index 000000000..591b9efdb
--- /dev/null
+++ b/Examples/test-suite/ruby/typedef_inherit_runme.rb
@@ -0,0 +1,27 @@
+require 'typedef_inherit'
+
+a = Typedef_inherit::Foo.new
+b = Typedef_inherit::Bar.new
+
+x = Typedef_inherit.do_blah(a)
+if x != "Foo::blah"
+ puts "Whoa! Bad return #{x}"
+end
+
+x = Typedef_inherit.do_blah(b)
+if x != "Bar::blah"
+ puts "Whoa! Bad return #{x}"
+end
+
+c = Typedef_inherit::Spam.new
+d = Typedef_inherit::Grok.new
+
+x = Typedef_inherit.do_blah2(c)
+if x != "Spam::blah"
+ puts "Whoa! Bad return #{x}"
+end
+
+x = Typedef_inherit.do_blah2(d)
+if x != "Grok::blah"
+ puts "Whoa! Bad return #{x}"
+end
diff --git a/Examples/test-suite/ruby/typedef_scope_runme.rb b/Examples/test-suite/ruby/typedef_scope_runme.rb
new file mode 100755
index 000000000..db7a9f2c9
--- /dev/null
+++ b/Examples/test-suite/ruby/typedef_scope_runme.rb
@@ -0,0 +1,13 @@
+require 'typedef_scope'
+
+b = Typedef_scope::Bar.new
+
+x = b.test1(42, "hello")
+if x != 42
+ puts "Failed!!"
+end
+
+x = b.test2(42, "hello")
+if x != "hello"
+ puts "Failed!!"
+end
diff --git a/Examples/test-suite/ruby/typemap_namespace_runme.rb b/Examples/test-suite/ruby/typemap_namespace_runme.rb
new file mode 100755
index 000000000..57986348d
--- /dev/null
+++ b/Examples/test-suite/ruby/typemap_namespace_runme.rb
@@ -0,0 +1,7 @@
+require 'typemap_namespace'
+
+include Typemap_namespace
+
+raise RuntimeError if test1("hello") != "hello"
+
+raise RuntimeError if test2("hello") != "hello"
diff --git a/Examples/test-suite/ruby/typename_runme.rb b/Examples/test-suite/ruby/typename_runme.rb
new file mode 100755
index 000000000..689499f12
--- /dev/null
+++ b/Examples/test-suite/ruby/typename_runme.rb
@@ -0,0 +1,14 @@
+require 'typename'
+
+f = Typename::Foo.new
+b = Typename::Bar.new
+
+x = Typename.twoFoo(f)
+unless x.is_a? Float
+ puts "Wrong return type!"
+end
+
+y = Typename.twoBar(b)
+unless y.is_a? Integer
+ puts "Wrong return type!"
+end
diff --git a/Examples/test-suite/ruby/unions_runme.rb b/Examples/test-suite/ruby/unions_runme.rb
new file mode 100644
index 000000000..17344f7e5
--- /dev/null
+++ b/Examples/test-suite/ruby/unions_runme.rb
@@ -0,0 +1,54 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+require 'unions'
+
+# Create new instances of SmallStruct and BigStruct for later use
+small = Unions::SmallStruct.new()
+small.jill = 200
+
+big = Unions::BigStruct.new()
+big.smallstruct = small
+big.jack = 300
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+eut = Unions::EmbeddedUnionTest.new()
+
+# First check the SmallStruct in EmbeddedUnionTest
+eut.number = 1
+eut.uni.small = small
+Jill1 = eut.uni.small.jill
+if (Jill1 != 200)
+ print "Runtime test1 failed. eut.uni.small.jill=" , Jill1 , "\n"
+ exit 1
+end
+
+Num1 = eut.number
+if (Num1 != 1)
+ print "Runtime test2 failed. eut.number=" , Num1 , "\n"
+ exit 1
+end
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+eut.number = 2
+eut.uni.big = big
+Jack1 = eut.uni.big.jack
+if (Jack1 != 300)
+ print "Runtime test3 failed. eut.uni.big.jack=" , Jack1 , "\n"
+ exit 1
+end
+
+Jill2 = eut.uni.big.smallstruct.jill
+if (Jill2 != 200)
+ print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2 , "\n"
+ exit 1
+end
+
+Num2 = eut.number
+if (Num2 != 2)
+ print "Runtime test5 failed. eut.number=" , Num2 , "\n"
+ exit 1
+end
+
diff --git a/Examples/test-suite/sizeof_pointer.i b/Examples/test-suite/sizeof_pointer.i
new file mode 100644
index 000000000..993ba4de5
--- /dev/null
+++ b/Examples/test-suite/sizeof_pointer.i
@@ -0,0 +1,19 @@
+/*
+This testcase tests whether the sizeof operator on a pointer is working.
+*/
+
+%module sizeof_pointer
+
+%inline %{
+
+#define NO_PROBLEM sizeof(char)
+#define STAR_PROBLEM sizeof(char*)
+#define STAR_STAR_PROBLEM sizeof(char**)
+
+typedef struct SizeofPointerTest {
+ unsigned char array1[NO_PROBLEM];
+ unsigned char array2[STAR_PROBLEM];
+ unsigned char array3[STAR_STAR_PROBLEM];
+} SizeofPointerTest;
+
+%}
diff --git a/Examples/test-suite/smart_pointer_const.i b/Examples/test-suite/smart_pointer_const.i
new file mode 100644
index 000000000..3100a021e
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_const.i
@@ -0,0 +1,19 @@
+%module smart_pointer_const
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() const { return x; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+};
+%}
+
+
diff --git a/Examples/test-suite/smart_pointer_multi.i b/Examples/test-suite/smart_pointer_multi.i
new file mode 100644
index 000000000..4b0aa0e4b
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_multi.i
@@ -0,0 +1,39 @@
+// Test cases for classes that do *NOT* result in smart-pointer wrapping
+%module smart_pointer_multi
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() { return x; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+};
+
+class Spam {
+ Bar *b;
+public:
+ Spam(Bar *b) : b(b) { }
+ Bar operator->() {
+ return *b;
+ }
+};
+
+class Grok {
+ Bar *b;
+public:
+ Grok(Bar *b) : b(b) { }
+ Bar &operator->() {
+ return *b;
+ }
+};
+
+%}
+
+
diff --git a/Examples/test-suite/smart_pointer_multi_typedef.i b/Examples/test-suite/smart_pointer_multi_typedef.i
new file mode 100644
index 000000000..ed32b703a
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_multi_typedef.i
@@ -0,0 +1,45 @@
+// Test cases for classes that do *NOT* result in smart-pointer wrapping
+%module smart_pointer_multi_typedef
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() { return x; }
+};
+
+typedef Foo FooObj;
+typedef FooObj *FooPtr;
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ FooPtr operator->() {
+ return f;
+ }
+};
+
+typedef Bar BarObj;
+typedef Bar &BarRef;
+
+class Spam {
+ Bar *b;
+public:
+ Spam(Bar *b) : b(b) { }
+ BarObj operator->() {
+ return *b;
+ }
+};
+
+class Grok {
+ Bar *b;
+public:
+ Grok(Bar *b) : b(b) { }
+ BarRef operator->() {
+ return *b;
+ }
+};
+
+%}
+
+
diff --git a/Examples/test-suite/smart_pointer_not.i b/Examples/test-suite/smart_pointer_not.i
new file mode 100644
index 000000000..712aa48fb
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_not.i
@@ -0,0 +1,39 @@
+// Test cases for classes that do *NOT* result in smart-pointer wrapping
+%module smart_pointer_not
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() { return x; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ Foo operator->() {
+ return *f;
+ }
+};
+
+class Spam {
+ Foo *f;
+public:
+ Spam(Foo *f) : f(f) { }
+ Foo &operator->() {
+ return *f;
+ }
+};
+
+class Grok {
+ Foo *f;
+public:
+ Grok(Foo *f) : f(f) { }
+ Foo **operator->() {
+ return &f;
+ }
+};
+
+%}
+
+
diff --git a/Examples/test-suite/smart_pointer_overload.i b/Examples/test-suite/smart_pointer_overload.i
new file mode 100644
index 000000000..ffc2097be
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_overload.i
@@ -0,0 +1,24 @@
+%module smart_pointer_overload
+
+#ifndef SWIG_NO_OVERLOAD
+
+%inline %{
+struct Foo {
+ int x;
+ int test(int x) { x = 0; return 1; }
+ int test(double x) { x = 0; return 2; }
+ int test(char *s) { s = 0; return 3; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+};
+%}
+
+#endif
+
diff --git a/Examples/test-suite/smart_pointer_protected.i b/Examples/test-suite/smart_pointer_protected.i
new file mode 100644
index 000000000..8f33d9484
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_protected.i
@@ -0,0 +1,29 @@
+%module smart_pointer_protected
+
+%inline %{
+
+ namespace hi
+ {
+ struct A
+ {
+ virtual int value(A*) = 0;
+ };
+
+ struct B : A
+ {
+ protected:
+ int value(A*)
+ {
+ return 1;
+ }
+ };
+
+ struct C
+ {
+ hi::B* operator->() const { return new hi::B(); }
+ };
+ }
+
+
+%}
+
diff --git a/Examples/test-suite/smart_pointer_rename.i b/Examples/test-suite/smart_pointer_rename.i
new file mode 100644
index 000000000..b137ffe71
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_rename.i
@@ -0,0 +1,25 @@
+%module smart_pointer_rename
+
+%rename(ftest1) Foo::test(int);
+%rename(ftest2) Foo::test(int,int);
+
+%inline %{
+
+class Foo {
+public:
+ int test(int) { return 1; }
+ int test(int,int) { return 2; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *_f) : f(_f) { }
+ Foo *operator->() { return f; }
+ int test() { return 3; }
+};
+
+%}
+
+
+
diff --git a/Examples/test-suite/smart_pointer_simple.i b/Examples/test-suite/smart_pointer_simple.i
new file mode 100644
index 000000000..ceb499c41
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_simple.i
@@ -0,0 +1,19 @@
+%module smart_pointer_simple
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() { return x; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+};
+%}
+
+
diff --git a/Examples/test-suite/smart_pointer_typedef.i b/Examples/test-suite/smart_pointer_typedef.i
new file mode 100644
index 000000000..d4e874f5c
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_typedef.i
@@ -0,0 +1,21 @@
+%module smart_pointer_typedef
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() { return x; }
+};
+
+typedef Foo *FooPtr;
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ FooPtr operator->() {
+ return f;
+ }
+};
+%}
+
+
diff --git a/Examples/test-suite/sneaky1.i b/Examples/test-suite/sneaky1.i
new file mode 100644
index 000000000..bacf4a978
--- /dev/null
+++ b/Examples/test-suite/sneaky1.i
@@ -0,0 +1,29 @@
+%module sneaky1
+
+%{
+int add(int x, int y) {
+ return x+y;
+}
+
+int sub(int x, int y) {
+ return x-y;
+}
+int mul(int x, int y) {
+ return x*y;
+}
+
+int divide(int x, int y) {
+ return x/y;
+}
+%}
+
+%inline %{
+typedef int binop(int,int);
+%}
+
+binop add,sub,mul,divide;
+
+
+
+
+
diff --git a/Examples/test-suite/static_array_member.i b/Examples/test-suite/static_array_member.i
new file mode 100644
index 000000000..8a7cfefae
--- /dev/null
+++ b/Examples/test-suite/static_array_member.i
@@ -0,0 +1,12 @@
+/* This interface file checks whether the SWIG parser handles static
+ array members of classes. Bug reported by Annalisa Terracina
+ <annalisa.terracina@datamat.it> on 2001-07-03.
+*/
+
+%module static_array_member
+
+%pragma no_default
+class RB {
+ static char *rberror[];
+};
+
diff --git a/Examples/test-suite/static_const_member.i b/Examples/test-suite/static_const_member.i
new file mode 100644
index 000000000..99dc89bd1
--- /dev/null
+++ b/Examples/test-suite/static_const_member.i
@@ -0,0 +1,17 @@
+/* Swig 1.3.6 does not understand initialization of static class
+ constants like this. SF Bug #445221, reported by Krzysztof
+ Kozminski <kozminski@users.sf.net>.
+*/
+
+%module static_const_member
+
+%inline %{
+
+class X {
+public:
+ static const int PN = 0;
+ static const int CN = 1;
+ static const int EN = 2;
+};
+
+%}
diff --git a/Examples/test-suite/static_const_member_2.i b/Examples/test-suite/static_const_member_2.i
new file mode 100644
index 000000000..3bd08b820
--- /dev/null
+++ b/Examples/test-suite/static_const_member_2.i
@@ -0,0 +1,53 @@
+%module static_const_member_2
+
+%warnfilter(801) oss::modules::CavityPackFlags::forward_field;
+%warnfilter(801) oss::modules::CavityPackFlags::backward_field;
+%warnfilter(801) oss::modules::Test::current_profile;
+
+%inline %{
+ namespace oss
+ {
+ namespace modules
+ {
+ struct CavityPackFlags
+ {
+ typedef unsigned int viewflags;
+ static const viewflags forward_field = 1 << 0;
+ static const viewflags backward_field = 1 << 1;
+ static const viewflags cavity_flags;
+ static viewflags flags;
+ static const int &reftest;
+ };
+
+ template <class T>
+ struct Test : CavityPackFlags
+ {
+ enum {LeftIndex, RightIndex};
+ static const viewflags current_profile = 1 << 2;
+ };
+ }
+ }
+
+%}
+
+%{
+
+int refvalue = 42;
+const int &oss::modules::CavityPackFlags::reftest = refvalue;
+
+%}
+
+%{
+ using oss::modules::CavityPackFlags;
+
+ const CavityPackFlags::viewflags
+ CavityPackFlags::cavity_flags =
+ CavityPackFlags::forward_field | CavityPackFlags::backward_field;
+
+ CavityPackFlags::viewflags
+ CavityPackFlags::flags = 0;
+
+%}
+
+%template(Test_int) oss::modules::Test<int>;
+
diff --git a/Examples/test-suite/struct_value.i b/Examples/test-suite/struct_value.i
new file mode 100644
index 000000000..bf944e2c5
--- /dev/null
+++ b/Examples/test-suite/struct_value.i
@@ -0,0 +1,14 @@
+%module struct_value
+
+%inline %{
+
+struct Foo {
+ int x;
+};
+
+struct Bar {
+ Foo a;
+ struct Foo b;
+};
+
+%}
diff --git a/Examples/test-suite/sym.i b/Examples/test-suite/sym.i
new file mode 100644
index 000000000..83226cbaa
--- /dev/null
+++ b/Examples/test-suite/sym.i
@@ -0,0 +1,24 @@
+%module sym
+// make sure different classes are allowed to have methods of the same name
+// that we properly qualify wrappers in the C namespace to avoid collisions
+
+%rename(hulahoops) Flim::Jam();
+
+%inline %{
+
+class Flim {
+public:
+ Flim() { }
+ const char * Jam() { return "flim-jam"; }
+ const char * Jar() { return "flim-jar"; }
+};
+
+class Flam {
+public:
+ Flam() { }
+ const char * Jam() { return "flam-jam"; }
+ const char * Jar() { return "flam-jar"; }
+};
+
+%}
+
diff --git a/Examples/test-suite/tcl/.cvsignore b/Examples/test-suite/tcl/.cvsignore
new file mode 100644
index 000000000..09e0b6c2e
--- /dev/null
+++ b/Examples/test-suite/tcl/.cvsignore
@@ -0,0 +1,3 @@
+*wrap*
+*.so
+*.dll
diff --git a/Examples/test-suite/tcl/Makefile b/Examples/test-suite/tcl/Makefile
new file mode 100644
index 000000000..4e54379e0
--- /dev/null
+++ b/Examples/test-suite/tcl/Makefile
@@ -0,0 +1,41 @@
+#######################################################################
+# $Header$
+# Makefile for tcl test-suite
+#######################################################################
+
+LANGUAGE = tcl
+SCRIPTSUFFIX = _runme.tcl
+
+include ../common.mk
+
+# Overridden variables here
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup) \
+ ($(swig_and_compile_cpp); ); \
+ $(run_testcase)
+
+%.ctest:
+ $(setup) \
+ ($(swig_and_compile_c); ); \
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup) \
+ ($(swig_and_compile_multi_cpp); ); \
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.tcl appended after the testcase name.
+run_testcase = \
+ if [ -f $*\_runme.tcl ]; then ( \
+ env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH tclsh $*\_runme.tcl;) \
+ fi;
+
+# Clean
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
diff --git a/Examples/test-suite/tcl/README b/Examples/test-suite/tcl/README
new file mode 100644
index 000000000..c36c3aa9a
--- /dev/null
+++ b/Examples/test-suite/tcl/README
@@ -0,0 +1,4 @@
+See ../README for common README file.
+
+Any testcases which have _runme.tcl appended after the testcase name will be detected and run.
+
diff --git a/Examples/test-suite/tcl/import_nomodule_runme.tcl b/Examples/test-suite/tcl/import_nomodule_runme.tcl
new file mode 100644
index 000000000..f53429b55
--- /dev/null
+++ b/Examples/test-suite/tcl/import_nomodule_runme.tcl
@@ -0,0 +1,10 @@
+
+if { [ string match $tcl_platform(platform) "windows" ] == 1 } {
+ if [ catch { load ./import_nomodule.dll import_nomodule} err_msg ] {
+ puts stderr "Could not load dll:\n$err_msg"
+ }
+} else {
+ if [ catch { load ./import_nomodule.so import_nomodule} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ }
+}
diff --git a/Examples/test-suite/tcl/imports_runme.tcl b/Examples/test-suite/tcl/imports_runme.tcl
new file mode 100644
index 000000000..c20cbad84
--- /dev/null
+++ b/Examples/test-suite/tcl/imports_runme.tcl
@@ -0,0 +1,26 @@
+
+# This is the imports runtime testcase.
+
+if { [ string match $tcl_platform(os) Windows* ] == 1 } {
+ if [ catch { load ./imports_a.dll imports_a} err_msg ] { ;# Windows
+ puts stderr "Could not load dll:\n$err_msg"
+ exit 1
+ }
+ if [ catch { load ./imports_b.dll imports_b} err_msg ] { ;# Windows
+ puts stderr "Could not load dll:\n$err_msg"
+ exit 1
+ }
+} else {
+ if [ catch { load ./imports_a.so imports_a} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+ }
+ if [ catch { load ./imports_b.so imports_b} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+ }
+}
+
+set x [new_B]
+A_hello $x
+
diff --git a/Examples/test-suite/tcl/overload_copy_runme.tcl b/Examples/test-suite/tcl/overload_copy_runme.tcl
new file mode 100644
index 000000000..32b62f2a9
--- /dev/null
+++ b/Examples/test-suite/tcl/overload_copy_runme.tcl
@@ -0,0 +1,18 @@
+
+if { [ string match $tcl_platform(platform) "windows" ] == 1 } {
+ if [ catch { load ./overload_copy.dll overload_copy} err_msg ] {
+ puts stderr "Could not load dll:\n$err_msg"
+ }
+} else {
+ if [ catch { load ./overload_copy.so overload_copy} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ }
+}
+
+Foo f
+Foo g [f cget -this]
+
+
+
+
+
diff --git a/Examples/test-suite/tcl/overload_simple_runme.tcl b/Examples/test-suite/tcl/overload_simple_runme.tcl
new file mode 100644
index 000000000..b8fa63553
--- /dev/null
+++ b/Examples/test-suite/tcl/overload_simple_runme.tcl
@@ -0,0 +1,172 @@
+
+if { [ string match $tcl_platform(platform) "windows" ] == 1 } {
+ if [ catch { load ./overload_simple.dll overload_simple} err_msg ] {
+ puts stderr "Could not load dll:\n$err_msg"
+ }
+} else {
+ if [ catch { load ./overload_simple.so overload_simple} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ }
+}
+
+set f [new_Foo]
+set b [new_Bar]
+set v [malloc_void 32]
+
+set x [foo 3]
+if {$x != "foo:int"} {
+ puts stderr "foo(int) test failed"
+ exit 1
+}
+
+set x [foo 3.4]
+if {$x != "foo:double"} {
+ puts stderr "foo(double) test failed"
+ exit 1
+}
+
+set x [foo hello]
+if {$x != "foo:char *"} {
+ puts stderr "foo(char *) test failed"
+ exit 1
+}
+
+set x [foo $f]
+if {$x != "foo:Foo *"} {
+ puts stderr "foo(Foo *) test failed"
+ exit 1
+}
+
+set x [foo $b]
+if {$x != "foo:Bar *"} {
+ puts stderr "foo(Bar *) test failed"
+ exit 1
+}
+
+set x [foo $v]
+if {$x != "foo:void *"} {
+ puts stderr "foo(void *) test failed"
+ exit 1
+}
+
+Spam s
+
+set x [s foo 3]
+if {$x != "foo:int"} {
+ puts stderr "Spam::foo(int) test failed"
+ exit 1
+}
+
+set x [s foo 3.4]
+if {$x != "foo:double"} {
+ puts stderr "Spam::foo(double) test failed"
+ exit 1
+}
+
+set x [s foo hello]
+if {$x != "foo:char *"} {
+ puts stderr "Spam::foo(char *) test failed"
+ exit 1
+}
+
+set x [s foo $f]
+if {$x != "foo:Foo *"} {
+ puts stderr "Spam::foo(Foo *) test failed"
+ exit 1
+}
+
+set x [s foo $b]
+if {$x != "foo:Bar *"} {
+ puts stderr "Spam::foo(Bar *) test failed"
+ exit 1
+}
+
+set x [s foo $v]
+if {$x != "foo:void *"} {
+ puts stderr "Spam::foo(void *) test failed"
+ exit 1
+}
+
+
+set x [Spam_bar 3]
+if {$x != "bar:int"} {
+ puts stderr "Spam::bar(int) test failed"
+ exit 1
+}
+
+set x [Spam_bar 3.4]
+if {$x != "bar:double"} {
+ puts stderr "Spam::bar(double) test failed"
+ exit 1
+}
+
+set x [Spam_bar hello]
+if {$x != "bar:char *"} {
+ puts stderr "Spam::bar(char *) test failed"
+ exit 1
+}
+
+set x [Spam_bar $f]
+if {$x != "bar:Foo *"} {
+ puts stderr "Spam::bar(Foo *) test failed"
+ exit 1
+}
+
+set x [Spam_bar $b]
+if {$x != "bar:Bar *"} {
+ puts stderr "Spam::bar(Bar *) test failed"
+ exit 1
+}
+
+set x [Spam_bar $v]
+if {$x != "bar:void *"} {
+ puts stderr "Spam::bar(void *) test failed"
+ exit 1
+}
+
+Spam s
+set x [s cget -type]
+if {$x != "none"} {
+ puts stderr "Spam() test failed"
+}
+
+Spam s 3
+set x [s cget -type]
+if {$x != "int"} {
+ puts stderr "Spam(int) test failed"
+}
+
+Spam s 3.4
+set x [s cget -type]
+if {$x != "double"} {
+ puts stderr "Spam(double) test failed"
+}
+
+Spam s hello
+set x [s cget -type]
+if {$x != "char *"} {
+ puts stderr "Spam(char *) test failed"
+}
+
+Spam s $f
+set x [s cget -type]
+if {$x != "Foo *"} {
+ puts stderr "Spam(Foo *) test failed"
+}
+
+Spam s $b
+set x [s cget -type]
+if {$x != "Bar *"} {
+ puts stderr "Spam(Bar *) test failed"
+}
+
+Spam s $v
+set x [s cget -type]
+if {$x != "void *"} {
+ puts stderr "Spam(void *) test failed"
+}
+
+
+
+
+
diff --git a/Examples/test-suite/tcl/primitive_ref_runme.tcl b/Examples/test-suite/tcl/primitive_ref_runme.tcl
new file mode 100644
index 000000000..b4de97fd1
--- /dev/null
+++ b/Examples/test-suite/tcl/primitive_ref_runme.tcl
@@ -0,0 +1,25 @@
+# Primitive ref testcase. Tests to make sure references to
+# primitive types are passed by value
+
+if { [ string match $tcl_platform(platform) "windows" ] == 1 } {
+ if [ catch { load ./primitive_ref.dll primitive_ref} err_msg ] {
+ puts stderr "Could not load dll:\n$err_msg"
+ }
+} else {
+ if [ catch { load ./primitive_ref.so primitive_ref} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ }
+}
+
+if { [ref_int 3] != 3 } { puts stderr "ref_int failed" }
+if { [ref_uint 3] != 3 } { puts stderr "ref_uint failed" }
+if { [ref_short 3] != 3 } { puts stderr "ref_short failed" }
+if { [ref_ushort 3] != 3 } { puts stderr "ref_ushort failed" }
+if { [ref_long 3] != 3 } { puts stderr "ref_long failed" }
+if { [ref_ulong 3] != 3 } { puts stderr "ref_ulong failed" }
+if { [ref_schar 3] != 3 } { puts stderr "ref_schar failed" }
+if { [ref_uchar 3] != 3 } { puts stderr "ref_uchar failed" }
+if { [ref_float 3.5] != 3.5 } { puts stderr "ref_float failed" }
+if { [ref_double 3.5] != 3.5 } { puts stderr "ref_double failed" }
+if { [ref_char x] != "x" } { puts stderr "ref_char failed" }
+
diff --git a/Examples/test-suite/tcl/unions_runme.tcl b/Examples/test-suite/tcl/unions_runme.tcl
new file mode 100644
index 000000000..7238698f5
--- /dev/null
+++ b/Examples/test-suite/tcl/unions_runme.tcl
@@ -0,0 +1,69 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+if { [ string match $tcl_platform(platform) "windows" ] == 1 } {
+ if [ catch { load ./unions.dll unions} err_msg ] {
+ puts stderr "Could not load dll:\n$err_msg"
+ }
+} else {
+ if [ catch { load ./unions.so unions} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ }
+}
+
+# Create new instances of SmallStruct and BigStruct for later use
+SmallStruct small
+small configure -jill 200
+
+BigStruct big
+big configure -smallstruct [small cget -this]
+big configure -jack 300
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+EmbeddedUnionTest eut
+
+# First check the SmallStruct in EmbeddedUnionTest
+eut configure -number 1
+
+#eut.uni.small = small
+EmbeddedUnionTest_uni_small_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [small cget -this]
+
+#Jill1 = eut.uni.small.jill
+set Jill1 [SmallStruct_jill_get [EmbeddedUnionTest_uni_small_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
+if {$Jill1 != 200} {
+ puts stderr "Runtime test1 failed. eut.uni.small.jill=$Jill1"
+ exit 1
+}
+
+set Num1 [eut cget -number]
+if {$Num1 != 1} {
+ puts stderr "Runtime test2 failed. eut.number=$Num1"
+ exit 1
+}
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+eut configure -number 2
+#eut.uni.big = big
+EmbeddedUnionTest_uni_big_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [big cget -this]
+#Jack1 = eut.uni.big.jack
+set Jack1 [BigStruct_jack_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
+if {$Jack1 != 300} {
+ puts stderr "Runtime test3 failed. eut.uni.big.jack=$Jack1"
+ exit 1
+}
+
+#Jill2 = eut.uni.big.smallstruct.jill
+set Jill2 [SmallStruct_jill_get [BigStruct_smallstruct_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] ]
+if {$Jill2 != 200} {
+ puts stderr "Runtime test4 failed. eut.uni.big.smallstruct.jill=$Jill2"
+ exit 1
+}
+
+set Num2 [eut cget -number]
+if {$Num2 != 2} {
+ puts stderr "Runtime test5 failed. eut.number=$Num2"
+ exit 1
+}
+
diff --git a/Examples/test-suite/template.i b/Examples/test-suite/template.i
new file mode 100644
index 000000000..68a9aadd1
--- /dev/null
+++ b/Examples/test-suite/template.i
@@ -0,0 +1,46 @@
+/* File : example.i */
+%module "template"
+
+%warnfilter(801) vector<int>; /* Ruby, wrong class name */
+%warnfilter(801) vector<double>; /* Ruby, wrong class name */
+%warnfilter(801) vector<int (*)[10]>; /* Ruby, wrong class name */
+
+/* Let's just grab the original header file here */
+
+%inline %{
+
+template<class T> T max(const T a, const T b) { return a>b ? a : b; }
+
+template<class T> class vector {
+ T *v;
+ int sz;
+ public:
+ vector(int _sz) {
+ v = new T[_sz];
+ sz = _sz;
+ }
+ T &get(int index) {
+ return v[index];
+ }
+ void set(int index, T &val) {
+ v[index] = val;
+ }
+ // This really doesn't do anything except test const handling
+ void testconst(const T x) { }
+};
+
+%}
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
+/* Now try to break constness */
+
+%template(maxintp) max<int (*)[10]>;
+%template(vecintp) vector<int (*)[10]>;
+
+
diff --git a/Examples/test-suite/template_arg_scope.i b/Examples/test-suite/template_arg_scope.i
new file mode 100644
index 000000000..36b593c3d
--- /dev/null
+++ b/Examples/test-suite/template_arg_scope.i
@@ -0,0 +1,16 @@
+%module template_arg_scope
+%inline %{
+
+template<class T> class Foo {
+};
+
+class Bar {
+public:
+ Bar();
+ void spam(Foo<Bar> *x);
+};
+Bar::Bar() {}
+void Bar::spam(Foo<Bar> *x) {}
+
+%}
+
diff --git a/Examples/test-suite/template_arg_typename.i b/Examples/test-suite/template_arg_typename.i
new file mode 100644
index 000000000..0f4c88793
--- /dev/null
+++ b/Examples/test-suite/template_arg_typename.i
@@ -0,0 +1,26 @@
+%module template_arg_typename
+
+%inline %{
+
+
+ template <class ArgType, class ResType>
+ struct UnaryFunction
+ {
+ typedef void* vptr_type;
+ };
+
+ template <class ArgType>
+ struct BoolUnaryFunction : UnaryFunction<ArgType, bool>
+
+ {
+ typedef UnaryFunction<ArgType, bool> base;
+ BoolUnaryFunction(const typename base::vptr_type* vptrf) {}
+
+ };
+
+
+%}
+
+
+%template(UnaryFunction_bool_bool) UnaryFunction<bool, bool>;
+%template(BoolUnaryFunction_bool) BoolUnaryFunction<bool>;
diff --git a/Examples/test-suite/template_base_template.i b/Examples/test-suite/template_base_template.i
new file mode 100644
index 000000000..846240fc8
--- /dev/null
+++ b/Examples/test-suite/template_base_template.i
@@ -0,0 +1,35 @@
+%module template_base_template
+
+%warnfilter(801) traits<double, double>; /* Ruby, wrong class name */
+
+%inline %{
+ template <class ArgType, class ResType>
+ struct traits
+ {
+ typedef ArgType arg_type;
+ typedef ResType res_type;
+ };
+
+ template <class ArgType, class ResType>
+ struct Function
+ {
+ };
+
+ // Egad!
+ template <class AF, class AG>
+ struct Class
+ : Function<typename traits<AF, AG>::arg_type,
+ typename traits<AF, AG>::res_type>
+ {
+ };
+
+%}
+
+%template(traits_dd) traits <double, double>;
+%template(Function_dd) Function <double, double>;
+%template(Class_dd) Class <double, double>;
+
+
+
+
+
diff --git a/Examples/test-suite/template_classes.i b/Examples/test-suite/template_classes.i
new file mode 100644
index 000000000..346fc0d23
--- /dev/null
+++ b/Examples/test-suite/template_classes.i
@@ -0,0 +1,30 @@
+/* File : template_classes.i */
+/* Tests the use of one templated class within another */
+
+%module template_classes
+
+%inline %{
+
+template <class T>
+class Point {
+public:
+ T getX() {return x;}
+private:
+ T x;
+};
+
+template <class T>
+class Rectangle {
+public:
+ Point<T>& getPoint() {return point;}
+ void setPoint(Point<T>& value) {point = value;}
+private:
+ Point<T> point;
+};
+
+%}
+
+%template(PointInt) Point<int>;
+%template(RectangleInt) Rectangle<int>;
+
+
diff --git a/Examples/test-suite/template_const_ref.i b/Examples/test-suite/template_const_ref.i
new file mode 100644
index 000000000..196ca9005
--- /dev/null
+++ b/Examples/test-suite/template_const_ref.i
@@ -0,0 +1,14 @@
+%module template_const_ref
+%inline %{
+template <class T> class Foo {
+public:
+ char *bar(const T &obj) {
+ return (char *) "Foo::bar";
+ }
+};
+class Bar { };
+%}
+
+%template(Foob) Foo<const Bar *>;
+%template(Fooi) Foo<const int *>;
+
diff --git a/Examples/test-suite/template_construct.i b/Examples/test-suite/template_construct.i
new file mode 100644
index 000000000..a6e8c3c33
--- /dev/null
+++ b/Examples/test-suite/template_construct.i
@@ -0,0 +1,15 @@
+%module template_construct
+
+// Tests templates to make sure an extra <> in a constructor is ok.
+
+%inline %{
+template<class T>
+class Foo {
+ T y;
+public:
+ Foo<T>(T x) : y(x) { }
+};
+
+%}
+
+%template(Foo_int) Foo<int>;
diff --git a/Examples/test-suite/template_default.i b/Examples/test-suite/template_default.i
new file mode 100644
index 000000000..9de4eab38
--- /dev/null
+++ b/Examples/test-suite/template_default.i
@@ -0,0 +1,10 @@
+%module template_default
+%inline %{
+template <class T1, class T2 = T1>
+class A
+{
+};
+ %}
+
+%template(A_ii) A<int, int>;
+%template(A_d) A<double>;
diff --git a/Examples/test-suite/template_default2.i b/Examples/test-suite/template_default2.i
new file mode 100644
index 000000000..0bcd47652
--- /dev/null
+++ b/Examples/test-suite/template_default2.i
@@ -0,0 +1,44 @@
+%module template_default2
+
+%warnfilter(801) oss::traits; // Ruby, wrong class name
+
+%inline %{
+ namespace oss
+ {
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ template <Polarization P>
+ struct Interface
+ {
+ };
+
+ struct traits
+ {
+ static const Polarization pmode = UnaryPolarization;
+ };
+
+ template <class C,
+ Polarization P = C::pmode,
+ class Base = Interface<P> > // **** problem here *****
+ struct Module : Base
+ {
+ };
+
+ }
+%}
+
+namespace oss
+{
+ %template(Interface_UP) Interface<UnaryPolarization>;
+
+ // This works
+ %template(Module_UP1) Module<traits,
+ UnaryPolarization,
+ Interface<UnaryPolarization> >;
+
+ // These don't
+ %template(Module_UP2) Module<traits, UnaryPolarization>;
+ %template(Module_UP3) Module<traits>;
+}
+
+
diff --git a/Examples/test-suite/template_default_arg.i b/Examples/test-suite/template_default_arg.i
new file mode 100644
index 000000000..1b3612f73
--- /dev/null
+++ b/Examples/test-suite/template_default_arg.i
@@ -0,0 +1,34 @@
+%module template_default_arg
+
+%warnfilter(801) hi; /* Ruby, wrong class name */
+
+%inline %{
+ template <class T>
+ struct Hello
+ {
+ typedef unsigned int size_type;
+
+ // This works
+ // Hello(size_type n = Hello<T>::size_type(0) ) { }
+
+ // This doesn't
+ Hello(size_type n = size_type(0) ) { }
+
+ };
+%}
+
+%template(Hello_int) Hello<int>;
+
+%inline %{
+
+ struct hi : Hello<int>
+ {
+ hi(size_type n) : Hello<int>(n)
+ {
+ }
+
+ };
+%}
+
+
+
diff --git a/Examples/test-suite/template_default_inherit.i b/Examples/test-suite/template_default_inherit.i
new file mode 100644
index 000000000..442ac77c6
--- /dev/null
+++ b/Examples/test-suite/template_default_inherit.i
@@ -0,0 +1,25 @@
+%module template_default_inherit
+
+%warnfilter(801) A::nindex; /* Ruby, wrong constant name */
+
+%inline %{
+ template <class C>
+ struct A
+ {
+ typedef unsigned int size_type;
+ static const size_type nindex = static_cast<size_type>(-1);
+
+ };
+
+ template <class C>
+ struct B : A<C>
+ {
+ typedef typename A<C>::size_type size_type;
+ void say_hi(size_type index = nindex) {}
+ };
+
+%}
+
+%template(A_int) A<int>;
+%template(B_int) B<int>;
+
diff --git a/Examples/test-suite/template_default_qualify.i b/Examples/test-suite/template_default_qualify.i
new file mode 100644
index 000000000..7a411d130
--- /dev/null
+++ b/Examples/test-suite/template_default_qualify.i
@@ -0,0 +1,56 @@
+// Tests typename qualification and constant resolution in default
+// template arguments. Another Marcelo special.. :-).
+
+%module template_default_qualify
+
+%warnfilter(801) etraits; /* Ruby, wrong class name */
+
+%inline %{
+ namespace oss
+ {
+
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ template <Polarization P>
+ struct Interface
+ {
+ };
+
+ namespace modules
+ {
+
+ template <class traits, class base = Interface<traits::pmode> >
+ // *** problem here ****
+ struct Module : base
+ {
+ };
+ }
+ }
+ struct etraits
+ {
+ static const oss::Polarization pmode = oss::UnaryPolarization;
+ };
+
+%}
+
+namespace oss
+{
+ %template(Interface_UP) Interface<UnaryPolarization>;
+ namespace modules
+ {
+ %template(Module_etraits) Module<etraits>;
+ }
+}
+
+%inline %{
+ namespace oss
+ {
+ namespace modules
+ {
+ struct HModule1 : Module<etraits>
+ {
+ };
+ }
+ }
+%}
+
diff --git a/Examples/test-suite/template_enum.i b/Examples/test-suite/template_enum.i
new file mode 100644
index 000000000..9f6eeeb6f
--- /dev/null
+++ b/Examples/test-suite/template_enum.i
@@ -0,0 +1,15 @@
+%module template_enum
+
+%warnfilter(801) foo<int>; /* Ruby, wrong class name */
+%warnfilter(801) foo<double>; /* Ruby, wrong class name */
+
+%inline %{
+template<class T> class foo {
+public:
+ enum { FOO, BAR };
+};
+%}
+
+%template(foo_i) foo<int>;
+%template(foo_d) foo<double>;
+
diff --git a/Examples/test-suite/template_enum_ns_inherit.i b/Examples/test-suite/template_enum_ns_inherit.i
new file mode 100644
index 000000000..8992eef6d
--- /dev/null
+++ b/Examples/test-suite/template_enum_ns_inherit.i
@@ -0,0 +1,48 @@
+%module template_enum_ns_inherit
+%inline %{
+
+ namespace oss
+ {
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ template <Polarization P>
+ struct Interface
+ {
+ };
+
+ template <Polarization P, class C>
+ struct Module
+ {
+ };
+
+ }
+
+%}
+
+namespace oss
+{
+ %template(Interface_UP) Interface<UnaryPolarization>;
+ %template(Module_UPIUP) Module<UnaryPolarization,Interface<UnaryPolarization> >;
+}
+
+%inline %{
+ namespace oss
+ {
+ namespace hello
+ {
+ struct HInterface1 :
+ Interface<oss::UnaryPolarization> // this works (with fullns qualification)
+ {
+ };
+
+ struct HInterface2 :
+ Interface<UnaryPolarization> // this doesn't work
+ {
+ };
+
+ struct HModule1 : Module<UnaryPolarization, Interface<UnaryPolarization> > {
+ };
+
+ }
+ }
+%} \ No newline at end of file
diff --git a/Examples/test-suite/template_enum_typedef.i b/Examples/test-suite/template_enum_typedef.i
new file mode 100644
index 000000000..f1c15f182
--- /dev/null
+++ b/Examples/test-suite/template_enum_typedef.i
@@ -0,0 +1,39 @@
+%module template_enum_typedef
+
+%warnfilter(801) oss::etraits; /* Ruby, wrong class name */
+
+%inline %{
+
+ namespace oss
+ {
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ template <Polarization P>
+ struct Interface
+ {
+ };
+
+ struct etraits
+ {
+ static const Polarization pmode = UnaryPolarization;
+ };
+
+
+ template <class Traits>
+ struct Module
+ {
+ typedef Traits traits;
+ static const Polarization P = traits::pmode;
+
+ void get(Interface<P> arg) { }; // Here P is only replace by traits::pmode
+
+ };
+ }
+
+%}
+
+namespace oss
+{
+ %template(Interface_UP) Interface<UnaryPolarization>;
+ %template(Module_UP) Module<etraits>;
+}
diff --git a/Examples/test-suite/template_forward.i b/Examples/test-suite/template_forward.i
new file mode 100644
index 000000000..edf679568
--- /dev/null
+++ b/Examples/test-suite/template_forward.i
@@ -0,0 +1,20 @@
+%module template_forward
+
+%{
+namespace foo {
+template<class T> class bar { };
+}
+%}
+
+namespace foo {
+ template<class T> class bar;
+};
+
+%inline %{
+namespace foo {
+ double test1(const bar<double> &x) { return 0; }
+ bar<double> test2() {
+ return bar<double>();
+ }
+}
+%}
diff --git a/Examples/test-suite/template_inherit.i b/Examples/test-suite/template_inherit.i
new file mode 100644
index 000000000..e02ec5233
--- /dev/null
+++ b/Examples/test-suite/template_inherit.i
@@ -0,0 +1,40 @@
+/* File : example.i */
+%module template_inherit
+
+/* This example tests template inheritance to see if it actually works */
+
+%inline %{
+
+template<class T> class Foo {
+public:
+ virtual char *blah() {
+ return (char *) "Foo";
+ }
+ virtual char *foomethod() {
+ return (char *) "foomethod";
+ }
+};
+
+template<class T> class Bar : public Foo<T> {
+public:
+ virtual char *blah() {
+ return (char *) "Bar";
+ }
+};
+
+template<class T> char *invoke_blah(Foo<T> *x) {
+ return x->blah();
+}
+%}
+
+%template(FooInt) Foo<int>;
+%template(FooDouble) Foo<double>;
+%template(FooUInt) Foo<unsigned int>;
+%template(BarInt) Bar<int>;
+%template(BarDouble) Bar<double>;
+%template(BarUInt) Bar<unsigned>;
+%template(invoke_blah_int) invoke_blah<int>;
+%template(invoke_blah_double) invoke_blah<double>;
+%template(invoke_blah_uint) invoke_blah<int unsigned>;
+
+
diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i
new file mode 100644
index 000000000..8cd0b998d
--- /dev/null
+++ b/Examples/test-suite/template_inherit_abstract.i
@@ -0,0 +1,59 @@
+%module template_inherit_abstract
+
+%warnfilter(801) oss::test; /* Ruby, wrong class name */
+%warnfilter(802, 813) oss::Module; /* Ruby & Java, multiple inheritance */
+
+%inline %{
+
+ namespace oss
+ {
+ template <class C>
+ struct Wrap
+ {
+ };
+
+ struct ModuleBase
+ {
+ virtual ~ModuleBase() {}
+ virtual int get() = 0;
+ };
+
+ template <class C>
+ struct Module : C, ModuleBase
+ {
+ protected:
+ Module() {}
+ };
+
+ template <class C>
+ struct HModule : Module<Wrap<C> >
+ {
+ // virtual int get(); // declaration here works
+
+ protected:
+ HModule() {}
+ };
+ }
+
+ struct B
+ {
+ };
+
+%}
+
+namespace oss
+{
+ %template(Wrap_B) Wrap<B>;
+ %template(Module_B) Module<Wrap<B> >;
+ %template(HModule_B) HModule<B>;
+}
+
+%inline %{
+ namespace oss
+ {
+ struct test : HModule<B>
+ {
+ virtual int get() {return 0;} // declaration here breaks swig
+ };
+ }
+%}
diff --git a/Examples/test-suite/template_int_const.i b/Examples/test-suite/template_int_const.i
new file mode 100644
index 000000000..7b9eea5f8
--- /dev/null
+++ b/Examples/test-suite/template_int_const.i
@@ -0,0 +1,50 @@
+%module template_int_const
+
+%warnfilter(801) interface_traits; /* Ruby, wrong class name */
+%warnfilter(801) module_traits; /* Ruby, wrong class name */
+
+%inline %{
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+ struct interface_traits
+ {
+ static const Polarization polarization = UnaryPolarization;
+ };
+ template <Polarization P>
+ struct Interface
+ {
+ };
+
+ typedef unsigned int Category;
+ struct module_traits
+ {
+ static const Category category = 1;
+ };
+
+ template <Category C>
+ struct Module
+ {
+ };
+%}
+
+%template(Interface_UP) Interface<UnaryPolarization>;
+%template(Module_1) Module<1>;
+
+%inline %{
+ struct ExtInterface1 :
+ Interface<UnaryPolarization> // works
+ {
+ };
+ struct ExtInterface2 :
+ Interface<interface_traits::polarization> // doesn't work
+ {
+ };
+ struct ExtModule1 :
+ Module<1> // works
+ {
+ };
+ struct ExtModule2 :
+ Module<module_traits::category> // doesn't work
+ {
+ };
+%}
+
diff --git a/Examples/test-suite/template_ns.i b/Examples/test-suite/template_ns.i
new file mode 100644
index 000000000..90af05fac
--- /dev/null
+++ b/Examples/test-suite/template_ns.i
@@ -0,0 +1,35 @@
+// Tests the use of the %template directive with fully
+// qualified scope names
+
+%module template_ns
+
+%warnfilter(801) std::pair<int, int>; /* Ruby, wrong class name */
+%warnfilter(801) std::pair<double, double>; /* Ruby, wrong class name */
+
+%ignore std::pair::pair();
+
+%inline %{
+namespace std
+{
+template <class _T1, class _T2>
+struct pair {
+ typedef _T1 first_type;
+ typedef _T2 second_type;
+
+ _T1 first;
+ _T2 second;
+ pair() : first(_T1()), second(_T2()) {}
+ pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
+ template <class _U1, class _U2>
+ pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
+};
+}
+%}
+
+// Add copy constructor
+%extend std::pair {
+ %template(pair) pair<_T1,_T2>;
+};
+
+%template(pairii) std::pair<int,int>;
+%template(pairdd) std::pair<double,double>;
diff --git a/Examples/test-suite/template_ns2.i b/Examples/test-suite/template_ns2.i
new file mode 100644
index 000000000..f35d32654
--- /dev/null
+++ b/Examples/test-suite/template_ns2.i
@@ -0,0 +1,16 @@
+// Tests compilation of uninstantiated templates in a namespace
+
+%module template_ns2
+
+%inline %{
+
+namespace foo {
+ template<class T> class bar {
+ };
+ bar<int> *test1(bar<int> *x) { return x; }
+ typedef int Integer;
+
+ bar<Integer *> *test2(bar<Integer *> *x) { return x; }
+}
+%}
+
diff --git a/Examples/test-suite/template_ns3.i b/Examples/test-suite/template_ns3.i
new file mode 100644
index 000000000..0cc08b551
--- /dev/null
+++ b/Examples/test-suite/template_ns3.i
@@ -0,0 +1,21 @@
+%module template_ns3
+
+%warnfilter(801) foo::bar<int>; /* Ruby, wrong class name */
+
+%inline %{
+namespace foo {
+ typedef int Integer;
+
+ template<class T> class bar {
+ public:
+ Integer test(Integer x) { return x; }
+ };
+
+}
+%}
+
+%template(bari) foo::bar<int>;
+
+
+
+
diff --git a/Examples/test-suite/template_ns4.i b/Examples/test-suite/template_ns4.i
new file mode 100644
index 000000000..3769f8d0b
--- /dev/null
+++ b/Examples/test-suite/template_ns4.i
@@ -0,0 +1,66 @@
+%module template_ns4
+
+%inline %{
+ namespace hello {
+
+ class Double {
+ };
+
+ template <class ArgType, class ResType>
+ struct Function
+ {
+ char *test() { return (char *) "test"; }
+ };
+
+ template <class AF, class RF>
+ struct ArithFunction : Function<AF, RF>
+ {
+ };
+
+ template <class ArgType, class ResType>
+ struct traits
+ {
+ };
+
+ template <class ArgType>
+ struct traits<ArgType, double>
+ {
+ typedef ArgType arg_type;
+ typedef double res_type;
+ typedef ArithFunction<ArgType, double> base;
+ };
+
+ template <class ArgType>
+ struct traits<ArgType, Double>
+ {
+ typedef ArgType arg_type;
+ typedef Double res_type;
+ typedef ArithFunction<ArgType, Double> base;
+ };
+
+ template <class AF, class RF>
+ class Class : public ArithFunction< typename traits<AF, RF>::arg_type,
+ typename traits<AF, RF>::res_type >
+ {
+ };
+
+ template <class AF, class RF>
+ typename traits<AF, RF>::base
+ make_Class()
+ {
+ return Class<AF, RF>();
+ }
+
+ }
+%}
+ namespace hello {
+ //
+ // This complains only when using a namespace
+ //
+ %template() traits<Double,Double>;
+ %template(Function_DD) Function <Double, Double>;
+ %template(ArithFunction_DD) ArithFunction <Double, Double>;
+ %template(Class_DD) Class <Double, Double>;
+ %template(make_Class_DD) make_Class <Double, Double>;
+ }
+
diff --git a/Examples/test-suite/template_ns_enum.i b/Examples/test-suite/template_ns_enum.i
new file mode 100644
index 000000000..4c73e5067
--- /dev/null
+++ b/Examples/test-suite/template_ns_enum.i
@@ -0,0 +1,18 @@
+%module template_ns_enum
+%inline %{
+ namespace hello {
+ enum Hello { Hi, Hola };
+
+ template <Hello H>
+ struct traits
+ {
+ typedef double value_type;
+ };
+
+ traits<Hi>::value_type say_hi()
+ {
+ return traits<Hi>::value_type(1);
+ }
+
+ }
+%}
diff --git a/Examples/test-suite/template_ns_enum2.i b/Examples/test-suite/template_ns_enum2.i
new file mode 100644
index 000000000..616100423
--- /dev/null
+++ b/Examples/test-suite/template_ns_enum2.i
@@ -0,0 +1,38 @@
+%module template_ns_enum2
+
+%inline %{
+
+ namespace hi
+ {
+ enum Hello { Hi, Hola };
+
+ template <Hello>
+ struct traits
+ {
+ };
+
+ template <>
+ struct traits<Hi>
+ {
+ typedef int value_type;
+ };
+
+ template <>
+ struct traits<Hola>
+ {
+ typedef double value_type;
+ };
+
+ struct B
+ {
+ const traits<Hola>::value_type&
+ eval(const traits<Hola>::value_type& e) const;
+
+ };
+ const traits<Hola>::value_type&
+ B::eval(const traits<Hola>::value_type& e) const {
+ return e;
+ }
+ }
+
+%}
diff --git a/Examples/test-suite/template_ns_inherit.i b/Examples/test-suite/template_ns_inherit.i
new file mode 100644
index 000000000..fb336541a
--- /dev/null
+++ b/Examples/test-suite/template_ns_inherit.i
@@ -0,0 +1,30 @@
+// Submitted by Marcelo Matus
+%module template_ns_inherit
+
+%inline %{
+ namespace hello {
+ typedef double Double;
+ }
+ namespace hello
+ {
+ template <class ArgType, class ResType>
+ class VUnaryFunction
+ {};
+
+ template <class ArgType, class ResType>
+ class UnaryFunction : public VUnaryFunction<ArgType, ResType>
+ {};
+ }
+
+%}
+
+namespace hello
+{
+ %template(VUnaryFunction_id) VUnaryFunction<int, Double>;
+ %template(UnaryFunction_id) UnaryFunction<int, Double>;
+}
+
+
+
+
+
diff --git a/Examples/test-suite/template_ns_scope.i b/Examples/test-suite/template_ns_scope.i
new file mode 100644
index 000000000..928f628d2
--- /dev/null
+++ b/Examples/test-suite/template_ns_scope.i
@@ -0,0 +1,38 @@
+%module template_ns_scope
+// Tests a scoping bug reported by Marcelo Matus.
+
+%inline %{
+ namespace hi {
+ enum Hello { Hi, Hola };
+
+ template <Hello h>
+ struct A
+ {
+ public:
+ A() {} // *** Here, the const. breaks swig ***
+ // *** swig works without it ***
+ };
+
+ namespace hello
+ {
+ template <Hello H>
+ struct B : A<H>
+ {
+ int say_hi() { return 0; }
+ };
+ }
+ }
+
+%}
+namespace hi
+{
+ %template(A_Hi) A<Hi>;
+ namespace hello
+ {
+ %template(B_Hi) B<Hi>;
+ }
+}
+
+
+
+
diff --git a/Examples/test-suite/template_qualifier.i b/Examples/test-suite/template_qualifier.i
new file mode 100644
index 000000000..1c3b46fbc
--- /dev/null
+++ b/Examples/test-suite/template_qualifier.i
@@ -0,0 +1,15 @@
+%module template_qualifier
+
+/* Stroustruo, 3rd Ed, C.13.6 */
+%inline %{
+class X {
+public:
+ template<int> X *xalloc() { return new X(); }
+};
+
+%}
+
+%extend X {
+%template(xalloc_int) xalloc<200>;
+};
+
diff --git a/Examples/test-suite/template_rename.i b/Examples/test-suite/template_rename.i
new file mode 100644
index 000000000..8d3574e81
--- /dev/null
+++ b/Examples/test-suite/template_rename.i
@@ -0,0 +1,24 @@
+%module template_rename
+
+%warnfilter(801) Foo<int>; /* Ruby, wrong class name */
+%warnfilter(801) Foo<double>; /* Ruby, wrong class name */
+
+%rename(blah_test) Foo::blah(int);
+%rename(spam_test) Foo<int>::spam(int);
+%rename(grok_test) Foo::grok(int);
+%rename(groki_test) Foo<int>::grok(int);
+
+%inline %{
+
+template<class T> class Foo {
+public:
+ int blah(int x) { return x; }
+ int spam(int x) { return x; }
+ int grok(int x) { return x; }
+};
+
+%}
+
+%template(iFoo) Foo<int>;
+%template(dFoo) Foo<double>;
+
diff --git a/Examples/test-suite/template_retvalue.i b/Examples/test-suite/template_retvalue.i
new file mode 100644
index 000000000..9c15fea65
--- /dev/null
+++ b/Examples/test-suite/template_retvalue.i
@@ -0,0 +1,32 @@
+%module template_retvalue
+%inline %{
+
+ enum Hello
+ {
+ Hi, Hola
+ };
+
+ struct C
+ {
+ C(int) {}
+ };
+
+ template <Hello>
+ class A
+ {
+ public:
+ A(int) {}
+ };
+
+
+ template <Hello h>
+ struct B
+ {
+ C get_c() { return C(0); } // this works
+ A<h> get_a() { return A<h>(0); } // this doesn't
+ };
+
+ %}
+
+%template(A_Hi) A<Hi>;
+%template(B_Hola) B<Hola>;
diff --git a/Examples/test-suite/template_specialization.i b/Examples/test-suite/template_specialization.i
new file mode 100644
index 000000000..b14cbb939
--- /dev/null
+++ b/Examples/test-suite/template_specialization.i
@@ -0,0 +1,40 @@
+%module template_specialization
+
+%rename(__not__) *::operator!() const;
+
+#ifdef SWIGJAVA
+%rename(negate) *::operator-() const;
+#endif
+
+%inline %{
+
+ namespace vfncs {
+
+ template <class ArgType>
+ struct UnaryFunction
+ {
+ UnaryFunction operator-() const { return *this; }
+ };
+
+ template <>
+ struct UnaryFunction<bool>
+ {
+ // This works
+ // UnaryFunction<bool> operator!() const;
+
+ // This doesn't
+ UnaryFunction operator!() const { return *this; }
+
+ // Does this?
+ void foo(UnaryFunction) { }
+
+ };
+
+ }
+%}
+
+namespace vfncs {
+
+ %template(UnaryFunction_double) UnaryFunction<double>;
+ %template(UnaryFunction_bool) UnaryFunction<bool>;
+}
diff --git a/Examples/test-suite/template_static.i b/Examples/test-suite/template_static.i
new file mode 100644
index 000000000..087cb3db2
--- /dev/null
+++ b/Examples/test-suite/template_static.i
@@ -0,0 +1,16 @@
+%module template_static
+
+%warnfilter(801) foo<int>; /* Ruby, wrong class name */
+%warnfilter(801) foo<double>; /* Ruby, wrong class name */
+
+%inline %{
+template<class T> class foo {
+public:
+ static int test;
+};
+template<class T> int foo<T>::test = 0;
+%}
+
+%template(foo_i) foo<int>;
+%template(foo_d) foo<double>;
+
diff --git a/Examples/test-suite/template_tbase_template.i b/Examples/test-suite/template_tbase_template.i
new file mode 100644
index 000000000..1d57ca070
--- /dev/null
+++ b/Examples/test-suite/template_tbase_template.i
@@ -0,0 +1,43 @@
+%module template_tbase_template
+
+%warnfilter(801) traits<Double, Double>; /* Ruby, wrong class name */
+
+%inline %{
+ typedef double Double;
+
+
+ template <class ArgType, class ResType>
+ struct Function
+ {
+ char *test() { return (char *) "test"; }
+ };
+
+ template <class ArgType, class ResType>
+ struct traits
+ {
+ typedef ArgType arg_type;
+ typedef ResType res_type;
+ typedef Function<ArgType, double> base;
+ };
+
+ // Egad!
+ template <class AF, class AG>
+ struct Class
+ : Function<typename traits<AF, AG>::arg_type,
+ typename traits<AF, AG>::res_type>
+ {
+ };
+
+ template <class AF, class RF>
+ typename traits<AF, RF>::base
+ make_Class()
+ {
+ return Class<AF, RF>();
+ }
+
+%}
+
+%template(traits_dd) traits <Double, Double>;
+%template(Function_dd) Function <Double, Double>;
+%template(Class_dd) Class <Double, Double>;
+%template(make_Class_dd) make_Class<Double,Double>;
diff --git a/Examples/test-suite/template_type_namespace.i b/Examples/test-suite/template_type_namespace.i
new file mode 100644
index 000000000..719647361
--- /dev/null
+++ b/Examples/test-suite/template_type_namespace.i
@@ -0,0 +1,14 @@
+%module template_type_namespace
+
+%warnfilter(801) std::vector<std::string>; // Ruby, wrong class name
+
+%include std_string.i
+%include std_vector.i
+
+%template(string_vector) std::vector<std::string>;
+
+%inline %{
+ std::vector<std::string> foo() {
+ return std::vector<std::string>(1,"foo");
+ }
+%}
diff --git a/Examples/test-suite/template_typedef.i b/Examples/test-suite/template_typedef.i
new file mode 100644
index 000000000..1d58d53bd
--- /dev/null
+++ b/Examples/test-suite/template_typedef.i
@@ -0,0 +1,156 @@
+%module template_typedef
+
+//
+// Change this to #if 1 to test the 'test'
+//
+#if 0
+
+#define real double
+%{
+#define real double
+%}
+
+#else
+
+%inline %{
+ typedef double real;
+%}
+
+#endif
+
+
+%inline %{
+
+ // typedef double real;
+
+ namespace vfncs {
+
+ struct UnaryFunctionBase
+ {
+ };
+
+ template <class ArgType, class ResType>
+ class UnaryFunction;
+
+ template <class ArgType, class ResType>
+ class ArithUnaryFunction;
+
+ template <class ArgType, class ResType>
+ struct UnaryFunction : UnaryFunctionBase
+ {
+ };
+
+ template <class ArgType, class ResType>
+ struct ArithUnaryFunction : UnaryFunction<ArgType, ResType>
+ {
+ };
+
+ template <class ArgType, class ResType>
+ struct unary_func_traits
+ {
+ typedef ArithUnaryFunction<ArgType, ResType > base;
+ };
+
+ template <class ArgType>
+ inline
+ typename unary_func_traits< ArgType, ArgType >::base
+ make_Identity()
+ {
+ return typename unary_func_traits< ArgType, ArgType >::base();
+ }
+
+ template <class Arg1, class Arg2>
+ struct arith_traits
+ {
+ };
+
+ template<>
+ struct arith_traits< float, float >
+ {
+
+ typedef float argument_type;
+ typedef float result_type;
+ static const char* const arg_type = "float";
+ static const char* const res_type = "float";
+ };
+
+ template<>
+ struct arith_traits< real, real >
+ {
+
+ typedef real argument_type;
+ typedef real result_type;
+ static const char* const arg_type = "real";
+ static const char* const res_type = "real";
+ };
+
+ template<>
+ struct arith_traits< real, float >
+ {
+ typedef float argument_type;
+ typedef real result_type;
+ static const char* const arg_type = "float";
+ static const char* const res_type = "real";
+ };
+
+ template<>
+ struct arith_traits< float, real >
+ {
+ typedef float argument_type;
+ typedef real result_type;
+ static const char* const arg_type = "float";
+ static const char* const res_type = "real";
+ };
+
+ template <class AF, class RF, class AG, class RG>
+ inline
+ ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
+ typename arith_traits< RF, RG >::result_type >
+ make_Multiplies(const ArithUnaryFunction<AF, RF>& f,
+ const ArithUnaryFunction<AG, RG >& g)
+ {
+ return
+ ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
+ typename arith_traits< RF, RG >::result_type>();
+ }
+
+ }
+
+%}
+
+namespace vfncs {
+ %template(UnaryFunction_float_float) UnaryFunction<float, float >;
+ %template(ArithUnaryFunction_float_float) ArithUnaryFunction<float, float >;
+ %template() unary_func_traits<float, float >;
+ %template() arith_traits<float, float >;
+ %template(make_Identity_float) make_Identity<float >;
+
+ %template(UnaryFunction_real_real) UnaryFunction<real, real >;
+ %template(ArithUnaryFunction_real_real) ArithUnaryFunction<real, real >;
+
+ %template() unary_func_traits<real, real >;
+ %template() arith_traits<real, real >;
+ %template(make_Identity_real) make_Identity<real >;
+
+ /* [beazley] Added this part */
+ %template() unary_func_traits<float,real>;
+ %template(UnaryFunction_float_real) UnaryFunction<float,real>;
+ %template(ArithUnaryFunction_float_real) ArithUnaryFunction<float,real>;
+
+ /* */
+
+ %template() arith_traits<real, float >;
+ %template() arith_traits<float, real >;
+ %template() arith_traits<float, float >;
+
+ %template(make_Multiplies_float_float_real_real)
+ make_Multiplies<float, float, real, real>;
+
+ %template(make_Multiplies_float_float_float_float)
+ make_Multiplies<float, float, float, float>;
+
+ %template(make_Multiplies_real_real_real_real)
+ make_Multiplies<real, real, real, real>;
+
+}
+
diff --git a/Examples/test-suite/template_typedef_cplx.i b/Examples/test-suite/template_typedef_cplx.i
new file mode 100644
index 000000000..104e59910
--- /dev/null
+++ b/Examples/test-suite/template_typedef_cplx.i
@@ -0,0 +1,159 @@
+%module template_typedef_cplx
+
+//
+// Change this to #if 1 to test the 'test'
+//
+#if 0
+
+%{
+#include <complex>
+typedef std::complex<double> cmplx;
+%}
+
+%inline %{
+ typedef cmplx Complex;
+%}
+
+#else
+
+%inline %{
+#include <complex>
+ typedef std::complex<double> Complex;
+%}
+
+#endif
+
+
+%inline %{
+
+ namespace vfncs {
+
+ struct UnaryFunctionBase
+ {
+ };
+
+ template <class ArgType, class ResType>
+ class UnaryFunction;
+
+ template <class ArgType, class ResType>
+ class ArithUnaryFunction;
+
+ template <class ArgType, class ResType>
+ struct UnaryFunction : UnaryFunctionBase
+ {
+ };
+
+ template <class ArgType, class ResType>
+ struct ArithUnaryFunction : UnaryFunction<ArgType, ResType>
+ {
+ };
+
+ template <class ArgType, class ResType>
+ struct unary_func_traits
+ {
+ typedef ArithUnaryFunction<ArgType, ResType > base;
+ };
+
+ template <class ArgType>
+ inline
+ typename unary_func_traits< ArgType, ArgType >::base
+ make_Identity()
+ {
+ return typename unary_func_traits< ArgType, ArgType >::base();
+ }
+
+ template <class Arg1, class Arg2>
+ struct arith_traits
+ {
+ };
+
+ template<>
+ struct arith_traits< double, double >
+ {
+
+ typedef double argument_type;
+ typedef double result_type;
+ static const char* const arg_type = "double";
+ static const char* const res_type = "double";
+ };
+
+ template<>
+ struct arith_traits< Complex, Complex >
+ {
+
+ typedef Complex argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type = "complex";
+ static const char* const res_type = "complex";
+ };
+
+ template<>
+ struct arith_traits< Complex, double >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type = "double";
+ static const char* const res_type = "complex";
+ };
+
+ template<>
+ struct arith_traits< double, Complex >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type = "double";
+ static const char* const res_type = "complex";
+ };
+
+ template <class AF, class RF, class AG, class RG>
+ inline
+ ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
+ typename arith_traits< RF, RG >::result_type >
+ make_Multiplies(const ArithUnaryFunction<AF, RF>& f,
+ const ArithUnaryFunction<AG, RG >& g)
+ {
+ return
+ ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
+ typename arith_traits< RF, RG >::result_type>();
+ }
+ }
+%}
+
+namespace vfncs {
+ %template(UnaryFunction_double_double) UnaryFunction<double, double >;
+ %template(ArithUnaryFunction_double_double) ArithUnaryFunction<double, double >;
+ %template() unary_func_traits<double, double >;
+ %template() arith_traits<double, double >;
+ %template(make_Identity_double) make_Identity<double >;
+
+ %template(UnaryFunction_complex_complex) UnaryFunction<Complex, Complex >;
+ %template(ArithUnaryFunction_complex_complex) ArithUnaryFunction<Complex, Complex >;
+
+ %template() unary_func_traits<Complex, Complex >;
+ %template() arith_traits<Complex, Complex >;
+ %template(make_Identity_complex) make_Identity<Complex >;
+
+ /* [beazley] Added this part */
+ %template() unary_func_traits<double,Complex>;
+ %template(UnaryFunction_double_complex) UnaryFunction<double,Complex>;
+ %template(ArithUnaryFunction_double_complex) ArithUnaryFunction<double,Complex>;
+
+ /* */
+
+ %template() arith_traits<Complex, double >;
+ %template() arith_traits<double, Complex >;
+
+ %template(make_Multiplies_double_double_complex_complex)
+ make_Multiplies<double, double, Complex, Complex>;
+
+ %template(make_Multiplies_double_double_double_double)
+ make_Multiplies<double, double, double, double>;
+
+ %template(make_Multiplies_complex_complex_complex_complex)
+ make_Multiplies<Complex, Complex, Complex, Complex>;
+
+ %template(make_Multiplies_complex_complex_double_double)
+ make_Multiplies<Complex, Complex, double, double>;
+
+}
+
diff --git a/Examples/test-suite/template_typedef_cplx2.h b/Examples/test-suite/template_typedef_cplx2.h
new file mode 100644
index 000000000..df19e5ad6
--- /dev/null
+++ b/Examples/test-suite/template_typedef_cplx2.h
@@ -0,0 +1,156 @@
+#ifndef ___typedef_import_h__
+#define ___typedef_import_h__
+
+#ifdef SWIG
+%module template_typedef_cplx2;
+#endif
+
+#include <complex>
+typedef std::complex<double> Complex;
+
+namespace vfncs {
+
+ struct UnaryFunctionBase
+ {
+ int get_base_value()
+ {
+ return 0;
+ }
+ };
+
+ template <class ArgType, class ResType>
+ class UnaryFunction;
+
+ template <class ArgType, class ResType>
+ class ArithUnaryFunction;
+
+ template <class ArgType, class ResType>
+ struct UnaryFunction : UnaryFunctionBase
+ {
+ int get_value()
+ {
+ return 1;
+ }
+ };
+
+ template <class ArgType, class ResType>
+ struct ArithUnaryFunction : UnaryFunction<ArgType, ResType>
+ {
+ int get_arith_value()
+ {
+ return 2;
+ }
+ };
+
+ template <class ArgType, class ResType>
+ struct unary_func_traits
+ {
+ typedef ArithUnaryFunction<ArgType, ResType > base;
+ };
+
+ template <class ArgType>
+ inline
+ typename unary_func_traits< ArgType, ArgType >::base
+ make_Identity()
+ {
+ return typename unary_func_traits< ArgType, ArgType >::base();
+ }
+
+ template <class Arg1, class Arg2>
+ struct arith_traits
+ {
+ };
+
+ template<>
+ struct arith_traits< double, double >
+ {
+ typedef double argument_type;
+ typedef double result_type;
+ static const char* const arg_type = "double";
+ static const char* const res_type = "double";
+ };
+
+ template<>
+ struct arith_traits< Complex, Complex >
+ {
+
+ typedef Complex argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type = "complex";
+ static const char* const res_type = "complex";
+ };
+
+ template<>
+ struct arith_traits< Complex, double >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type = "double";
+ static const char* const res_type = "complex";
+ };
+
+ template<>
+ struct arith_traits< double, Complex >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type = "double";
+ static const char* const res_type = "complex";
+ };
+
+ template <class AF, class RF, class AG, class RG>
+ inline
+ ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
+ typename arith_traits< RF, RG >::result_type >
+ make_Multiplies(const ArithUnaryFunction<AF, RF>& f,
+ const ArithUnaryFunction<AG, RG >& g)
+ {
+ return
+ ArithUnaryFunction<typename arith_traits< AF, AG >::argument_type,
+ typename arith_traits< RF, RG >::result_type>();
+ }
+}
+
+#ifdef SWIG
+
+namespace vfncs {
+ %template(UnaryFunction_double_double) UnaryFunction<double, double >;
+ %template(ArithUnaryFunction_double_double) ArithUnaryFunction<double, double >;
+ %template() unary_func_traits<double, double >;
+ %template() arith_traits<double, double >;
+ %template(make_Identity_double) make_Identity<double >;
+
+ %template(UnaryFunction_complex_complex) UnaryFunction<Complex, Complex >;
+ %template(ArithUnaryFunction_complex_complex) ArithUnaryFunction<Complex, Complex >;
+
+ %template() unary_func_traits<Complex, Complex >;
+ %template() arith_traits<Complex, Complex >;
+ %template(make_Identity_complex) make_Identity<Complex >;
+
+ /* [beazley] Added this part */
+ %template() unary_func_traits<double,Complex>;
+ %template(UnaryFunction_double_complex) UnaryFunction<double,Complex>;
+ %template(ArithUnaryFunction_double_complex) ArithUnaryFunction<double,Complex>;
+
+ /* */
+
+ %template() arith_traits<Complex, double >;
+ %template() arith_traits<double, Complex >;
+
+ %template(make_Multiplies_double_double_complex_complex)
+ make_Multiplies<double, double, Complex, Complex>;
+
+ %template(make_Multiplies_double_double_double_double)
+ make_Multiplies<double, double, double, double>;
+
+ %template(make_Multiplies_complex_complex_complex_complex)
+ make_Multiplies<Complex, Complex, Complex, Complex>;
+
+ %template(make_Multiplies_complex_complex_double_double)
+ make_Multiplies<Complex, Complex, double, double>;
+
+}
+
+#endif
+
+#endif //___template_typedef_h__
diff --git a/Examples/test-suite/template_typedef_cplx2.i b/Examples/test-suite/template_typedef_cplx2.i
new file mode 100644
index 000000000..6f99e8996
--- /dev/null
+++ b/Examples/test-suite/template_typedef_cplx2.i
@@ -0,0 +1,7 @@
+%module template_typedef_cplx2
+
+%{
+#include "template_typedef_cplx2.h"
+%}
+
+%include "template_typedef_cplx2.h"
diff --git a/Examples/test-suite/template_typedef_cplx3.i b/Examples/test-suite/template_typedef_cplx3.i
new file mode 100644
index 000000000..71fcf5e3e
--- /dev/null
+++ b/Examples/test-suite/template_typedef_cplx3.i
@@ -0,0 +1,37 @@
+%module template_typedef_cplx3
+%{
+#include "template_typedef_cplx2.h"
+%}
+
+%include "template_typedef_cplx2.h"
+
+%inline %{
+
+ typedef vfncs::ArithUnaryFunction<double, double> RFunction;
+ typedef vfncs::ArithUnaryFunction<Complex, Complex> CFunction;
+
+
+ int my_func_r(RFunction* hello)
+ {
+ return 0;
+ }
+
+ int my_func_c(CFunction* hello)
+ {
+ return 1;
+ }
+
+ struct Sin : RFunction
+ {
+ };
+
+ struct CSin : CFunction
+ {
+ };
+
+%}
+
+
+
+
+
diff --git a/Examples/test-suite/template_typedef_cplx4.i b/Examples/test-suite/template_typedef_cplx4.i
new file mode 100644
index 000000000..a2457acdf
--- /dev/null
+++ b/Examples/test-suite/template_typedef_cplx4.i
@@ -0,0 +1,44 @@
+%module template_typedef_cplx4
+%{
+#include "template_typedef_cplx2.h"
+%}
+
+%include "template_typedef_cplx2.h"
+
+%inline %{
+
+ typedef vfncs::ArithUnaryFunction<double, double> RFunction;
+ // **** these two work ****
+ // typedef vfncs::ArithUnaryFunction<Complex, Complex > CFunction;
+ // typedef vfncs::ArithUnaryFunction<std::complex<double>, std::complex<double> > CFunction;
+
+ // **** these ones don't ***
+ // typedef vfncs::ArithUnaryFunction<Complex, std::complex<double> > CFunction;
+ typedef vfncs::ArithUnaryFunction<std::complex<double>, Complex > CFunction;
+
+
+
+ int my_func_r(RFunction* hello)
+ {
+ return 0;
+ }
+
+ int my_func_c(CFunction* hello)
+ {
+ return 1;
+ }
+
+ struct Sin : RFunction
+ {
+ };
+
+ struct CSin : CFunction
+ {
+ };
+
+%}
+
+
+
+
+
diff --git a/Examples/test-suite/template_typedef_import.i b/Examples/test-suite/template_typedef_import.i
new file mode 100644
index 000000000..10bc61763
--- /dev/null
+++ b/Examples/test-suite/template_typedef_import.i
@@ -0,0 +1,37 @@
+%module template_typedef_import
+%{
+#include "template_typedef_cplx2.h"
+%}
+
+%import "template_typedef_cplx2.h"
+
+%inline %{
+
+ typedef vfncs::ArithUnaryFunction<double, double> RFunction;
+ typedef vfncs::ArithUnaryFunction<Complex, Complex> CFunction;
+
+
+ int my_func_r(RFunction* hello)
+ {
+ return 0;
+ }
+
+ int my_func_c(CFunction* hello)
+ {
+ return 1;
+ }
+
+ struct Sin : RFunction
+ {
+ };
+
+ struct CSin : CFunction
+ {
+ };
+
+%}
+
+
+
+
+
diff --git a/Examples/test-suite/template_typedef_import.list b/Examples/test-suite/template_typedef_import.list
new file mode 100644
index 000000000..c7622b4da
--- /dev/null
+++ b/Examples/test-suite/template_typedef_import.list
@@ -0,0 +1,2 @@
+template_typedef_cplx2
+template_typedef_import
diff --git a/Examples/test-suite/template_virtual.i b/Examples/test-suite/template_virtual.i
new file mode 100644
index 000000000..cc5949a4f
--- /dev/null
+++ b/Examples/test-suite/template_virtual.i
@@ -0,0 +1,32 @@
+%module template_virtual
+
+// Submitted by Marcelo Matus
+// assertion emmitted with templates + derivation + pure virtual member
+// allocate.cxx:47: int Allocate::is_abstract_inherit(Node*, Node*):
+// Assertion `dn' failed.
+
+%inline %{
+
+ template <class T>
+ class A
+ {
+ public:
+ virtual void say_hi() = 0; // only fails with pure virtual methods
+
+ virtual void say_hello(); // this works fine
+
+ protected:
+ A() { } // defined protected as swig generates constructor by default
+ };
+
+ template <class T>
+ class B : public A<T>
+ {
+ protected:
+ B() { } // defined protected as swig generates constructor by default
+ };
+
+%}
+
+%template(A_int) A<int>;
+%template(B_int) B<int>; // !!!! it crashes right here !!!!!
diff --git a/Examples/test-suite/template_whitespace.i b/Examples/test-suite/template_whitespace.i
new file mode 100644
index 000000000..ea3d28a1a
--- /dev/null
+++ b/Examples/test-suite/template_whitespace.i
@@ -0,0 +1,22 @@
+/* This interface file tests whether whitespace in angle brackets
+ effects the SWIG types. SF Bug #221917, reported by
+ burchanb@cs.tamu.edu. */
+
+%module template_whitespace
+
+%{
+template<class T> class vector {
+};
+template<class T, class U> class map {
+};
+%}
+
+//%typemap(in) vector<int> "$target = new vector<int>();";
+//%typemap(in) vector<unsigned int> "$target = new vector<unsigned int>();";
+//%typemap(in) map<int,int> "$target = new map<int, int>();";
+
+%inline %{
+void foo(vector<int > v) {}
+void var(vector<unsigned int> v) {}
+void baz(map < int , int > p) {}
+%}
diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i
new file mode 100644
index 000000000..0c170a5f3
--- /dev/null
+++ b/Examples/test-suite/throw_exception.i
@@ -0,0 +1,29 @@
+%module throw_exception
+
+// Tests SWIG's automatic exception mechanism
+
+%inline %{
+
+class Error {
+};
+
+class Foo {
+public:
+ void test_int() throw(int) {
+ throw 37;
+ }
+ void test_msg() throw(const char *) {
+ throw "Dead";
+ }
+ void test_cls() throw(Error) {
+ throw Error();
+ }
+ void test_multi(int x) throw(int, const char *, Error) {
+ if (x == 1) throw 37;
+ if (x == 2) throw "Dead";
+ if (x == 3) throw Error();
+ }
+};
+
+ %}
+
diff --git a/Examples/test-suite/typedef_array_member.i b/Examples/test-suite/typedef_array_member.i
new file mode 100644
index 000000000..8663fd335
--- /dev/null
+++ b/Examples/test-suite/typedef_array_member.i
@@ -0,0 +1,10 @@
+%module typedef_array_member
+%inline %{
+
+typedef char amember[20];
+
+struct Foo {
+ amember x;
+};
+
+%}
diff --git a/Examples/test-suite/typedef_funcptr.i b/Examples/test-suite/typedef_funcptr.i
new file mode 100644
index 000000000..9ef220282
--- /dev/null
+++ b/Examples/test-suite/typedef_funcptr.i
@@ -0,0 +1,26 @@
+// Tests typedef through function pointers
+
+%module typedef_funcptr
+
+%warnfilter(801) addf; /* Ruby, wrong constant name */
+%warnfilter(801) subf; /* Ruby, wrong constant name */
+
+%{
+int addf(int x, int y) {
+ return x+y;
+}
+int subf(int x, int y) {
+ return x-y;
+}
+%}
+
+%inline %{
+typedef int Integer;
+
+Integer do_op(Integer x, Integer y, Integer (*op)(Integer, Integer)) {
+ return (*op)(x,y);
+}
+%}
+
+%constant int addf(int x, int y);
+%constant Integer subf(Integer x, Integer y);
diff --git a/Examples/test-suite/typedef_inherit.i b/Examples/test-suite/typedef_inherit.i
new file mode 100644
index 000000000..c22253a32
--- /dev/null
+++ b/Examples/test-suite/typedef_inherit.i
@@ -0,0 +1,41 @@
+// Inheritance through a typedef name
+%module typedef_inherit
+
+%inline %{
+class Foo {
+public:
+ virtual char *blah() {
+ return (char *) "Foo::blah";
+ }
+};
+
+typedef Foo FooObj;
+
+class Bar : public FooObj {
+ public:
+ virtual char *blah() {
+ return (char *) "Bar::blah";
+ };
+};
+
+char *do_blah(FooObj *f) {
+ return f->blah();
+}
+
+typedef struct {
+ virtual char *blah() {
+ return (char *) "Spam::blah";
+ }
+} Spam;
+
+struct Grok : public Spam {
+ virtual char *blah() {
+ return (char *) "Grok::blah";
+ }
+};
+
+char *do_blah2(Spam *s) {
+ return s->blah();
+}
+%}
+
diff --git a/Examples/test-suite/typedef_mptr.i b/Examples/test-suite/typedef_mptr.i
new file mode 100644
index 000000000..5e64c8ac7
--- /dev/null
+++ b/Examples/test-suite/typedef_mptr.i
@@ -0,0 +1,34 @@
+// Tests typedef through member pointers
+
+%module typedef_mptr
+
+#ifdef SWIGPYTHON
+
+%inline %{
+
+class Foo {
+public:
+ int add(int x, int y) {
+ return x+y;
+ }
+ int sub(int x, int y) {
+ return x-y;
+ }
+ int do_op(int x, int y, int (Foo::*op)(int, int)) {
+ return (this->*op)(x,y);
+ }
+};
+
+typedef Foo FooObj;
+typedef int Integer;
+
+Integer do_op(Foo *f, Integer x, Integer y, Integer (FooObj::*op)(Integer, Integer)) {
+ return f->do_op(x,y,op);
+}
+%}
+#endif
+
+#ifdef SWIGPYTHON
+%constant int (Foo::*add)(int,int) = &Foo::add;
+%constant Integer (FooObj::*sub)(Integer,Integer) = &FooObj::sub;
+#endif
diff --git a/Examples/test-suite/typedef_reference.i b/Examples/test-suite/typedef_reference.i
new file mode 100644
index 000000000..5146317a1
--- /dev/null
+++ b/Examples/test-suite/typedef_reference.i
@@ -0,0 +1,10 @@
+%module typedef_reference
+
+%include cpointer.i
+%pointer_functions(int, intp);
+
+%inline %{
+ typedef int & IntRef;
+ int somefunc(IntRef i) { return i; }
+ int otherfunc(int &i) { return i; }
+%}
diff --git a/Examples/test-suite/typedef_scope.i b/Examples/test-suite/typedef_scope.i
new file mode 100644
index 000000000..65adc8df8
--- /dev/null
+++ b/Examples/test-suite/typedef_scope.i
@@ -0,0 +1,21 @@
+// Tests some subtle issues of typedef scoping in C++
+
+%module typedef_scope
+
+%inline %{
+
+typedef char * FooType;
+class Bar {
+public:
+ typedef int FooType;
+ FooType test1(FooType n, ::FooType data) {
+ return n;
+ }
+ ::FooType test2(FooType n, ::FooType data) {
+ return data;
+ }
+};
+%}
+
+
+
diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i
new file mode 100644
index 000000000..1c312bcfa
--- /dev/null
+++ b/Examples/test-suite/typemap_namespace.i
@@ -0,0 +1,39 @@
+%module typemap_namespace
+
+/* Secret typedefs */
+%{
+namespace Foo {
+ typedef char Str1;
+ typedef char Str2;
+}
+%}
+
+namespace Foo {
+ struct Str1;
+ struct Str2;
+
+#ifdef SWIGJAVA
+ %typemap(jni) Str1 * = char *;
+ %typemap(jtype) Str1 * = char *;
+ %typemap(jstype) Str1 * = char *;
+ %typemap(freearg) Str1 * = char *;
+ %typemap(javain) Str1 * = char *;
+ %typemap(javaout) Str1 * = char *;
+#endif
+ %typemap(in) Str1 * = char *;
+ %apply char * { Str2 * };
+}
+
+%inline %{
+namespace Foo {
+ char *test1(Str1 *s) {
+ return s;
+ }
+ char *test2(Str2 *s) {
+ return s;
+ }
+}
+%}
+
+
+
diff --git a/Examples/test-suite/typemap_ns_using.i b/Examples/test-suite/typemap_ns_using.i
new file mode 100644
index 000000000..6f3357016
--- /dev/null
+++ b/Examples/test-suite/typemap_ns_using.i
@@ -0,0 +1,21 @@
+%module typemap_ns_using
+
+%warnfilter(801) X::_FooImpl; /* Ruby, wrong class name */
+
+%inline %{
+namespace X {
+ typedef int Integer;
+
+ class _FooImpl {
+ public:
+ typedef Integer value_type;
+ };
+ typedef _FooImpl Foo;
+}
+
+using X::Foo;
+
+int spam(Foo::value_type x) { return x; }
+
+%}
+
diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i
new file mode 100644
index 000000000..f9bc8dd6e
--- /dev/null
+++ b/Examples/test-suite/typemap_subst.i
@@ -0,0 +1,54 @@
+/* This interface file tests for type-related typemap substitutions.
+ */
+
+%module typemap_subst
+
+%warnfilter(801) xyzzy; /* Ruby, wrong class name */
+
+%inline %{
+ struct xyzzy {
+ int member;
+ };
+%}
+
+%typemap(in) const struct xyzzy **TEST
+ ($type temp, $*type startemp, $&type amptemp, $basetype basetemp)
+{
+ { /* Test C type name substitutions */
+ $ltype a = (struct xyzzy **) NULL;
+ const struct xyzzy **b = ($type) NULL;
+ $&ltype c = (struct xyzzy ***) NULL;
+ const struct xyzzy ***d = ($&type) NULL;
+ $*ltype e = *a;
+ $basetype f;
+ f.member = 42;
+ }
+ { /* Test locals */
+ basetemp.member = 0;
+ startemp = &basetemp;
+ temp = &startemp;
+ amptemp = &temp;
+ }
+ /* Java module doesn't seem to use SWIG's type system? */
+ { /* Test descriptors */
+ void *desc = $descriptor;
+ void *stardesc = $*descriptor;
+ void *ampdesc = $&descriptor;
+ }
+ { /* Test mangled names */
+ void *desc = SWIGTYPE$mangle;
+ void *stardesc = SWIGTYPE$*mangle;
+ void *ampdesc = SWIGTYPE$&mangle;
+ }
+ $1 = ($ltype) temp;
+}
+
+#ifndef SWIGJAVA
+%inline %{
+ void foo(const struct xyzzy **TEST) {}
+%}
+#endif
+
+
+
+
diff --git a/Examples/test-suite/typename.i b/Examples/test-suite/typename.i
new file mode 100644
index 000000000..4253e0846
--- /dev/null
+++ b/Examples/test-suite/typename.i
@@ -0,0 +1,34 @@
+%module "typename"
+
+// Tests the typename handling in templates.
+
+%inline %{
+class Foo {
+public:
+ typedef double Number;
+ Number blah() {
+ return 2.1828;
+ }
+};
+
+class Bar {
+public:
+ typedef int Number;
+ Number blah() {
+ return 42;
+ }
+};
+
+template<typename T> typename T::Number twoblah(T &obj) {
+ return 2*(obj.blah());
+}
+
+Bar::Number spam() { return 3; }
+
+%}
+
+%template(twoFoo) twoblah<Foo>;
+%template(twoBar) twoblah<Bar>;
+
+
+ \ No newline at end of file
diff --git a/Examples/test-suite/union_scope.i b/Examples/test-suite/union_scope.i
new file mode 100644
index 000000000..b58585c2a
--- /dev/null
+++ b/Examples/test-suite/union_scope.i
@@ -0,0 +1,13 @@
+%module union_scope
+
+%warnfilter(801) nRState; // Ruby, wrong class name
+%warnfilter(801) nRState_rstate; // Ruby, wrong class name
+
+%inline %{
+class nRState {
+public:
+ union {
+ int i;
+ } rstate;
+};
+%}
diff --git a/Examples/test-suite/unions.i b/Examples/test-suite/unions.i
new file mode 100644
index 000000000..b5f162b89
--- /dev/null
+++ b/Examples/test-suite/unions.i
@@ -0,0 +1,35 @@
+/*
+This testcase checks that unions can be set and read.
+*/
+
+%module unions
+%pragma make_default
+
+%inline %{
+
+typedef struct SmallStruct {
+ short jill;
+} SmallStruct;
+
+typedef struct BigStruct {
+ int jack;
+ SmallStruct smallstruct;
+} BigStruct;
+
+/* This union is just to check the parser */
+typedef union {
+ BigStruct bs;
+ SmallStruct ss;
+} UnionTest;
+
+/* This union checks the parser and will be used in a runtime test */
+typedef struct {
+ union
+ {
+ BigStruct big;
+ SmallStruct small;
+ } uni;
+ int number;
+} EmbeddedUnionTest;
+
+%}
diff --git a/Examples/test-suite/using1.i b/Examples/test-suite/using1.i
new file mode 100644
index 000000000..cd1fe8aac
--- /dev/null
+++ b/Examples/test-suite/using1.i
@@ -0,0 +1,22 @@
+%module using1
+
+%warnfilter(801) X::_FooImpl; /* Ruby, wrong class name */
+
+%inline %{
+
+namespace X {
+ typedef int Integer;
+
+ class _FooImpl {
+ public:
+ typedef Integer value_type;
+ };
+ typedef _FooImpl Foo;
+}
+
+namespace Y = X;
+using namespace Y;
+
+int spam(Foo::value_type x) { return x; }
+
+%}
diff --git a/Examples/test-suite/using2.i b/Examples/test-suite/using2.i
new file mode 100644
index 000000000..29fee1b1c
--- /dev/null
+++ b/Examples/test-suite/using2.i
@@ -0,0 +1,22 @@
+%module using2
+
+%warnfilter(801) X::_FooImpl; /* Ruby, wrong class name */
+
+%inline %{
+
+namespace X {
+ typedef int Integer;
+
+ class _FooImpl {
+ public:
+ typedef Integer value_type;
+ };
+ typedef _FooImpl Foo;
+}
+
+namespace Y = X;
+using Y::Foo;
+
+int spam(Foo::value_type x) { return x; }
+
+%}
diff --git a/Examples/test-suite/using_composition.i b/Examples/test-suite/using_composition.i
new file mode 100644
index 000000000..c7cff1d9d
--- /dev/null
+++ b/Examples/test-suite/using_composition.i
@@ -0,0 +1,24 @@
+%module using_composition
+
+%warnfilter(802, 813) FooBar; // Ruby, Java multiple inheritance
+
+%inline %{
+class Foo {
+public:
+ int blah(int x) { return x; }
+ char *blah(char *x) { return x; }
+};
+
+class Bar {
+public:
+ double blah(double x) { return x; }
+};
+
+class FooBar : public Foo, public Bar {
+public:
+ using Foo::blah;
+ using Bar::blah;
+ char *blah(char *x) { return x; }
+};
+
+%}
diff --git a/Examples/test-suite/using_extend.i b/Examples/test-suite/using_extend.i
new file mode 100644
index 000000000..8bc670e83
--- /dev/null
+++ b/Examples/test-suite/using_extend.i
@@ -0,0 +1,37 @@
+%module using_extend
+
+%warnfilter(802, 813) FooBar; // Ruby, Java multiple inheritance
+
+%extend Foo {
+ int blah(int x, int y) {
+ return x+y;
+ }
+};
+
+%extend Bar {
+ double blah(double x, double y) {
+ return x+y;
+ }
+};
+
+%inline %{
+class Foo {
+public:
+ int blah(int x) { return x; }
+ char *blah(char *x) { return x; }
+};
+
+class Bar {
+public:
+ double blah(double x) { return x; }
+};
+
+class FooBar : public Foo, public Bar {
+public:
+ using Foo::blah;
+ using Bar::blah;
+ char *blah(char *x) { return x; }
+};
+
+%}
+
diff --git a/Examples/test-suite/using_inherit.i b/Examples/test-suite/using_inherit.i
new file mode 100644
index 000000000..d4eca3707
--- /dev/null
+++ b/Examples/test-suite/using_inherit.i
@@ -0,0 +1,17 @@
+%module using_inherit
+
+%inline %{
+
+class Foo {
+public:
+ int test(int x) { return x; }
+ double test(double x) { return x; };
+};
+
+class Bar : public Foo {
+public:
+ using Foo::test;
+};
+
+%}
+
diff --git a/Examples/test-suite/using_namespace.i b/Examples/test-suite/using_namespace.i
new file mode 100644
index 000000000..886dd2a3e
--- /dev/null
+++ b/Examples/test-suite/using_namespace.i
@@ -0,0 +1,56 @@
+%module using_namespace
+
+%warnfilter(801) hi::hi0; /* Ruby, wrong class name */
+%warnfilter(801) hi::hi1; /* Ruby, wrong class name */
+
+%warnfilter(802, 813) Hi<hello::Hello, hi::hi0>; // Ruby, Java multiple inheritance
+
+%inline %{
+ namespace hello
+ {
+ struct Hello
+ {
+ };
+
+ template <class _T1, class _T2>
+ struct Hi : _T1, _T2
+ {
+ int value1() const
+ {
+ return 1;
+ }
+ };
+ }
+
+ namespace hi
+ {
+
+ struct hi0
+ {
+ };
+
+ }
+%}
+
+namespace hello
+{
+ %template(Hi_hi0) Hi<hello::Hello, hi::hi0>;
+}
+
+
+%inline %{
+ namespace hi
+ {
+ struct hi1 : private hello::Hi< hello::Hello, hi0 >
+ {
+ // This works
+ // using hello::Hi< hello::Hello, hi::hi0 >::value1;
+
+ // This doesn't
+ using hello::Hi< hello::Hello, hi0 >::value1;
+
+ };
+
+ }
+
+%}
diff --git a/Examples/test-suite/using_private.i b/Examples/test-suite/using_private.i
new file mode 100644
index 000000000..cd5a7974b
--- /dev/null
+++ b/Examples/test-suite/using_private.i
@@ -0,0 +1,17 @@
+%module using_private
+
+%inline %{
+class Foo {
+public:
+ int x;
+ int blah(int x) { return x; }
+};
+
+class FooBar : private Foo {
+public:
+ using Foo::blah;
+ using Foo::x;
+};
+
+%}
+
diff --git a/Examples/test-suite/using_protected.i b/Examples/test-suite/using_protected.i
new file mode 100644
index 000000000..93d48cb49
--- /dev/null
+++ b/Examples/test-suite/using_protected.i
@@ -0,0 +1,17 @@
+%module using_protected
+
+%inline %{
+class Foo {
+protected:
+ int x;
+ int blah(int x) { return x; }
+};
+
+class FooBar : public Foo {
+public:
+ using Foo::blah;
+ using Foo::x;
+};
+
+%}
+
diff --git a/Examples/test-suite/valuewrapper_base.i b/Examples/test-suite/valuewrapper_base.i
new file mode 100644
index 000000000..1698c3e03
--- /dev/null
+++ b/Examples/test-suite/valuewrapper_base.i
@@ -0,0 +1,28 @@
+%module valuewrapper_base
+%inline
+%{
+ namespace oss
+ {
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ struct Base
+ {
+ };
+
+ template <Polarization P>
+ struct Interface : Base
+ {
+ Interface(const Base& b) { };
+ };
+
+ template <class Result>
+ Result make() { return Result(*new Base()); }
+ }
+%}
+
+namespace oss
+{
+ // Interface
+ %template(Interface_BP) Interface<BinaryPolarization>;
+ %template(make_Interface_BP) make<Interface<BinaryPolarization> >;
+}
diff --git a/Examples/test-suite/virtual_destructor.i b/Examples/test-suite/virtual_destructor.i
new file mode 100644
index 000000000..da357c4a3
--- /dev/null
+++ b/Examples/test-suite/virtual_destructor.i
@@ -0,0 +1,16 @@
+/*
+This testcase checks that a virtual destructor with void as a parameter is
+correctly handled.
+*/
+
+%module virtual_destructor
+
+%inline %{
+
+class VirtualVoidDestructor {
+public:
+ VirtualVoidDestructor() {};
+ virtual ~VirtualVoidDestructor(void) { };
+};
+
+%}
diff --git a/Examples/test-suite/voidtest.i b/Examples/test-suite/voidtest.i
new file mode 100644
index 000000000..37d6d9fc5
--- /dev/null
+++ b/Examples/test-suite/voidtest.i
@@ -0,0 +1,16 @@
+%module voidtest
+
+%inline %{
+
+void globalfunc(void) {
+};
+
+class Foo {
+public:
+ Foo() { };
+ void memberfunc(void) { };
+ static void staticmemberfunc(void) { };
+};
+
+%}
+ \ No newline at end of file