summaryrefslogtreecommitdiff
path: root/trunk/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/Examples')
-rw-r--r--trunk/Examples/Makefile.in1143
-rw-r--r--trunk/Examples/README47
-rw-r--r--trunk/Examples/chicken/README12
-rw-r--r--trunk/Examples/chicken/check.list6
-rw-r--r--trunk/Examples/chicken/class/Makefile38
-rw-r--r--trunk/Examples/chicken/class/example.cxx28
-rw-r--r--trunk/Examples/chicken/class/example.h46
-rw-r--r--trunk/Examples/chicken/class/example.i10
-rw-r--r--trunk/Examples/chicken/class/test-lowlevel-class.scm76
-rw-r--r--trunk/Examples/chicken/class/test-tinyclos-class.scm76
-rw-r--r--trunk/Examples/chicken/constants/Makefile30
-rw-r--r--trunk/Examples/chicken/constants/example.i27
-rw-r--r--trunk/Examples/chicken/constants/test-constants.scm16
-rw-r--r--trunk/Examples/chicken/egg/Makefile39
-rw-r--r--trunk/Examples/chicken/egg/README19
-rw-r--r--trunk/Examples/chicken/egg/mod1.i8
-rw-r--r--trunk/Examples/chicken/egg/mod2.i17
-rw-r--r--trunk/Examples/chicken/egg/multi.setup2
-rw-r--r--trunk/Examples/chicken/egg/multi_init.scm2
-rw-r--r--trunk/Examples/chicken/egg/single.i8
-rw-r--r--trunk/Examples/chicken/egg/single.setup2
-rw-r--r--trunk/Examples/chicken/egg/test.scm18
-rw-r--r--trunk/Examples/chicken/multimap/Makefile30
-rw-r--r--trunk/Examples/chicken/multimap/example.c53
-rw-r--r--trunk/Examples/chicken/multimap/example.i96
-rw-r--r--trunk/Examples/chicken/multimap/test-multimap.scm59
-rw-r--r--trunk/Examples/chicken/overload/Makefile30
-rw-r--r--trunk/Examples/chicken/overload/README2
-rw-r--r--trunk/Examples/chicken/overload/example.cxx33
-rw-r--r--trunk/Examples/chicken/overload/example.h14
-rw-r--r--trunk/Examples/chicken/overload/example.i16
-rw-r--r--trunk/Examples/chicken/overload/test-overload.scm45
-rw-r--r--trunk/Examples/chicken/simple/Makefile30
-rw-r--r--trunk/Examples/chicken/simple/README1
-rw-r--r--trunk/Examples/chicken/simple/example.c24
-rw-r--r--trunk/Examples/chicken/simple/example.i16
-rw-r--r--trunk/Examples/chicken/simple/test-simple.scm28
-rw-r--r--trunk/Examples/contract/simple_c/example.c11
-rw-r--r--trunk/Examples/contract/simple_c/example.i19
-rw-r--r--trunk/Examples/contract/simple_c/runme1.py17
-rw-r--r--trunk/Examples/contract/simple_c/runme2.py20
-rw-r--r--trunk/Examples/contract/simple_cxx/example.cxx30
-rw-r--r--trunk/Examples/contract/simple_cxx/example.h34
-rw-r--r--trunk/Examples/contract/simple_cxx/example.i28
-rw-r--r--trunk/Examples/contract/simple_cxx/runme1.py33
-rw-r--r--trunk/Examples/contract/simple_cxx/runme2.py44
-rw-r--r--trunk/Examples/contract/simple_cxx/runme3.py57
-rw-r--r--trunk/Examples/csharp/arrays/Makefile20
-rw-r--r--trunk/Examples/csharp/arrays/example.c22
-rw-r--r--trunk/Examples/csharp/arrays/example.h4
-rw-r--r--trunk/Examples/csharp/arrays/example.i45
-rw-r--r--trunk/Examples/csharp/arrays/runme.cs43
-rw-r--r--trunk/Examples/csharp/callback/Makefile20
-rw-r--r--trunk/Examples/csharp/callback/example-cs.csproj99
-rw-r--r--trunk/Examples/csharp/callback/example-vc.vcproj158
-rw-r--r--trunk/Examples/csharp/callback/example.cxx4
-rw-r--r--trunk/Examples/csharp/callback/example.h24
-rw-r--r--trunk/Examples/csharp/callback/example.i13
-rw-r--r--trunk/Examples/csharp/callback/example.sln30
-rw-r--r--trunk/Examples/csharp/callback/runme.cs46
-rw-r--r--trunk/Examples/csharp/check.list11
-rw-r--r--trunk/Examples/csharp/class/Makefile20
-rw-r--r--trunk/Examples/csharp/class/example-cs.csproj104
-rw-r--r--trunk/Examples/csharp/class/example-vc.vcproj158
-rw-r--r--trunk/Examples/csharp/class/example.cxx28
-rw-r--r--trunk/Examples/csharp/class/example.h39
-rw-r--r--trunk/Examples/csharp/class/example.i10
-rw-r--r--trunk/Examples/csharp/class/example.sln30
-rw-r--r--trunk/Examples/csharp/class/runme.cs66
-rw-r--r--trunk/Examples/csharp/enum/Makefile20
-rw-r--r--trunk/Examples/csharp/enum/example-cs.csproj99
-rw-r--r--trunk/Examples/csharp/enum/example-vc.vcproj158
-rw-r--r--trunk/Examples/csharp/enum/example.cxx37
-rw-r--r--trunk/Examples/csharp/enum/example.h13
-rw-r--r--trunk/Examples/csharp/enum/example.i11
-rw-r--r--trunk/Examples/csharp/enum/example.sln30
-rw-r--r--trunk/Examples/csharp/enum/runme.cs31
-rw-r--r--trunk/Examples/csharp/extend/Makefile20
-rw-r--r--trunk/Examples/csharp/extend/example-cs.csproj104
-rw-r--r--trunk/Examples/csharp/extend/example-vc.vcproj158
-rw-r--r--trunk/Examples/csharp/extend/example.cxx4
-rw-r--r--trunk/Examples/csharp/extend/example.h56
-rw-r--r--trunk/Examples/csharp/extend/example.i15
-rw-r--r--trunk/Examples/csharp/extend/example.sln30
-rw-r--r--trunk/Examples/csharp/extend/runme.cs77
-rw-r--r--trunk/Examples/csharp/funcptr/Makefile20
-rw-r--r--trunk/Examples/csharp/funcptr/example-cs.csproj94
-rw-r--r--trunk/Examples/csharp/funcptr/example-vc.vcproj160
-rw-r--r--trunk/Examples/csharp/funcptr/example.c19
-rw-r--r--trunk/Examples/csharp/funcptr/example.h9
-rw-r--r--trunk/Examples/csharp/funcptr/example.i16
-rw-r--r--trunk/Examples/csharp/funcptr/example.sln30
-rw-r--r--trunk/Examples/csharp/funcptr/runme.cs27
-rw-r--r--trunk/Examples/csharp/reference/Makefile20
-rw-r--r--trunk/Examples/csharp/reference/example-cs.csproj99
-rw-r--r--trunk/Examples/csharp/reference/example-vc.vcproj158
-rw-r--r--trunk/Examples/csharp/reference/example.cxx46
-rw-r--r--trunk/Examples/csharp/reference/example.h26
-rw-r--r--trunk/Examples/csharp/reference/example.i46
-rw-r--r--trunk/Examples/csharp/reference/example.sln30
-rw-r--r--trunk/Examples/csharp/reference/runme.cs73
-rw-r--r--trunk/Examples/csharp/simple/Makefile20
-rw-r--r--trunk/Examples/csharp/simple/example-cs.csproj89
-rw-r--r--trunk/Examples/csharp/simple/example-vc.vcproj222
-rw-r--r--trunk/Examples/csharp/simple/example.c18
-rw-r--r--trunk/Examples/csharp/simple/example.i7
-rw-r--r--trunk/Examples/csharp/simple/example.sln26
-rw-r--r--trunk/Examples/csharp/simple/runme.cs25
-rw-r--r--trunk/Examples/csharp/template/Makefile20
-rw-r--r--trunk/Examples/csharp/template/example-cs.csproj109
-rw-r--r--trunk/Examples/csharp/template/example-vc.vcproj157
-rw-r--r--trunk/Examples/csharp/template/example.h32
-rw-r--r--trunk/Examples/csharp/template/example.i17
-rw-r--r--trunk/Examples/csharp/template/example.sln30
-rw-r--r--trunk/Examples/csharp/template/runme.cs39
-rw-r--r--trunk/Examples/csharp/variables/Makefile20
-rw-r--r--trunk/Examples/csharp/variables/example-cs.csproj99
-rw-r--r--trunk/Examples/csharp/variables/example-vc.vcproj157
-rw-r--r--trunk/Examples/csharp/variables/example.c91
-rw-r--r--trunk/Examples/csharp/variables/example.h6
-rw-r--r--trunk/Examples/csharp/variables/example.i49
-rw-r--r--trunk/Examples/csharp/variables/example.sln30
-rw-r--r--trunk/Examples/csharp/variables/runme.cs82
-rw-r--r--trunk/Examples/guile/Makefile.in40
-rw-r--r--trunk/Examples/guile/README14
-rw-r--r--trunk/Examples/guile/check.list6
-rw-r--r--trunk/Examples/guile/constants/Makefile17
-rw-r--r--trunk/Examples/guile/constants/constants.scm10
-rw-r--r--trunk/Examples/guile/constants/example.i27
-rw-r--r--trunk/Examples/guile/matrix/Makefile18
-rw-r--r--trunk/Examples/guile/matrix/README13
-rw-r--r--trunk/Examples/guile/matrix/main.c24
-rw-r--r--trunk/Examples/guile/matrix/matrix.c61
-rw-r--r--trunk/Examples/guile/matrix/matrix.i36
-rw-r--r--trunk/Examples/guile/matrix/matrix.scm210
-rw-r--r--trunk/Examples/guile/matrix/package.i20
-rw-r--r--trunk/Examples/guile/matrix/vector.c44
-rw-r--r--trunk/Examples/guile/matrix/vector.h10
-rw-r--r--trunk/Examples/guile/matrix/vector.i22
-rw-r--r--trunk/Examples/guile/multimap/Makefile18
-rw-r--r--trunk/Examples/guile/multimap/example.c53
-rw-r--r--trunk/Examples/guile/multimap/example.i87
-rw-r--r--trunk/Examples/guile/multimap/runme.scm30
-rw-r--r--trunk/Examples/guile/multivalue/Makefile18
-rw-r--r--trunk/Examples/guile/multivalue/example.c18
-rw-r--r--trunk/Examples/guile/multivalue/example.i32
-rw-r--r--trunk/Examples/guile/multivalue/runme.scm66
-rw-r--r--trunk/Examples/guile/port/Makefile18
-rw-r--r--trunk/Examples/guile/port/README2
-rw-r--r--trunk/Examples/guile/port/port.c18
-rw-r--r--trunk/Examples/guile/port/port.i15
-rw-r--r--trunk/Examples/guile/port/port.scm32
-rw-r--r--trunk/Examples/guile/simple/Makefile19
-rw-r--r--trunk/Examples/guile/simple/README9
-rw-r--r--trunk/Examples/guile/simple/example.c21
-rw-r--r--trunk/Examples/guile/simple/example.i14
-rw-r--r--trunk/Examples/guile/simple/example.scm28
-rw-r--r--trunk/Examples/guile/std_vector/Makefile18
-rw-r--r--trunk/Examples/guile/std_vector/example.h25
-rw-r--r--trunk/Examples/guile/std_vector/example.i17
-rw-r--r--trunk/Examples/guile/std_vector/runme.scm54
-rw-r--r--trunk/Examples/index.html52
-rw-r--r--trunk/Examples/java/callback/Makefile18
-rw-r--r--trunk/Examples/java/callback/example.cxx4
-rw-r--r--trunk/Examples/java/callback/example.h23
-rw-r--r--trunk/Examples/java/callback/example.i13
-rw-r--r--trunk/Examples/java/callback/index.html20
-rw-r--r--trunk/Examples/java/callback/runme.java56
-rw-r--r--trunk/Examples/java/check.list15
-rw-r--r--trunk/Examples/java/class/Makefile18
-rw-r--r--trunk/Examples/java/class/example.cxx28
-rw-r--r--trunk/Examples/java/class/example.dsp162
-rw-r--r--trunk/Examples/java/class/example.h39
-rw-r--r--trunk/Examples/java/class/example.i10
-rw-r--r--trunk/Examples/java/class/index.html197
-rw-r--r--trunk/Examples/java/class/runme.java70
-rw-r--r--trunk/Examples/java/constants/Makefile18
-rw-r--r--trunk/Examples/java/constants/example.i30
-rw-r--r--trunk/Examples/java/constants/index.html52
-rw-r--r--trunk/Examples/java/constants/runme.java44
-rw-r--r--trunk/Examples/java/enum/Makefile18
-rw-r--r--trunk/Examples/java/enum/example.cxx37
-rw-r--r--trunk/Examples/java/enum/example.h13
-rw-r--r--trunk/Examples/java/enum/example.i14
-rw-r--r--trunk/Examples/java/enum/index.html29
-rw-r--r--trunk/Examples/java/enum/runme.java38
-rw-r--r--trunk/Examples/java/extend/Makefile18
-rw-r--r--trunk/Examples/java/extend/example.cxx4
-rw-r--r--trunk/Examples/java/extend/example.h56
-rw-r--r--trunk/Examples/java/extend/example.i15
-rw-r--r--trunk/Examples/java/extend/index.html19
-rw-r--r--trunk/Examples/java/extend/runme.java88
-rw-r--r--trunk/Examples/java/funcptr/Makefile18
-rw-r--r--trunk/Examples/java/funcptr/example.c19
-rw-r--r--trunk/Examples/java/funcptr/example.h9
-rw-r--r--trunk/Examples/java/funcptr/example.i16
-rw-r--r--trunk/Examples/java/funcptr/index.html91
-rw-r--r--trunk/Examples/java/funcptr/runme.java33
-rw-r--r--trunk/Examples/java/index.html65
-rw-r--r--trunk/Examples/java/multimap/Makefile18
-rw-r--r--trunk/Examples/java/multimap/example.c53
-rw-r--r--trunk/Examples/java/multimap/example.dsp158
-rw-r--r--trunk/Examples/java/multimap/example.i109
-rw-r--r--trunk/Examples/java/multimap/runme.java40
-rw-r--r--trunk/Examples/java/native/Makefile18
-rw-r--r--trunk/Examples/java/native/example.i56
-rw-r--r--trunk/Examples/java/native/index.html33
-rw-r--r--trunk/Examples/java/native/runme.java19
-rw-r--r--trunk/Examples/java/pointer/Makefile18
-rw-r--r--trunk/Examples/java/pointer/example.c16
-rw-r--r--trunk/Examples/java/pointer/example.i30
-rw-r--r--trunk/Examples/java/pointer/index.html165
-rw-r--r--trunk/Examples/java/pointer/runme.java55
-rw-r--r--trunk/Examples/java/reference/Makefile18
-rw-r--r--trunk/Examples/java/reference/example.cxx46
-rw-r--r--trunk/Examples/java/reference/example.h26
-rw-r--r--trunk/Examples/java/reference/example.i46
-rw-r--r--trunk/Examples/java/reference/index.html147
-rw-r--r--trunk/Examples/java/reference/runme.java79
-rw-r--r--trunk/Examples/java/simple/Makefile18
-rw-r--r--trunk/Examples/java/simple/example.c18
-rw-r--r--trunk/Examples/java/simple/example.dsp158
-rw-r--r--trunk/Examples/java/simple/example.i7
-rw-r--r--trunk/Examples/java/simple/index.html108
-rw-r--r--trunk/Examples/java/simple/runme.java32
-rw-r--r--trunk/Examples/java/template/Makefile18
-rw-r--r--trunk/Examples/java/template/example.h32
-rw-r--r--trunk/Examples/java/template/example.i17
-rw-r--r--trunk/Examples/java/template/index.html102
-rw-r--r--trunk/Examples/java/template/runme.java45
-rw-r--r--trunk/Examples/java/typemap/Makefile18
-rw-r--r--trunk/Examples/java/typemap/example.i101
-rw-r--r--trunk/Examples/java/typemap/index.html32
-rw-r--r--trunk/Examples/java/typemap/runme.java26
-rw-r--r--trunk/Examples/java/variables/Makefile18
-rw-r--r--trunk/Examples/java/variables/example.c91
-rw-r--r--trunk/Examples/java/variables/example.h6
-rw-r--r--trunk/Examples/java/variables/example.i49
-rw-r--r--trunk/Examples/java/variables/index.html85
-rw-r--r--trunk/Examples/java/variables/runme.java97
-rw-r--r--trunk/Examples/lua/arrays/Makefile18
-rw-r--r--trunk/Examples/lua/arrays/example.c25
-rw-r--r--trunk/Examples/lua/arrays/example.i42
-rw-r--r--trunk/Examples/lua/arrays/runme.lua74
-rw-r--r--trunk/Examples/lua/check.list17
-rw-r--r--trunk/Examples/lua/class/Makefile19
-rw-r--r--trunk/Examples/lua/class/example.cxx28
-rw-r--r--trunk/Examples/lua/class/example.h39
-rw-r--r--trunk/Examples/lua/class/example.i10
-rw-r--r--trunk/Examples/lua/class/runme.lua62
-rw-r--r--trunk/Examples/lua/constants/Makefile19
-rw-r--r--trunk/Examples/lua/constants/example.i27
-rw-r--r--trunk/Examples/lua/constants/runme.lua35
-rw-r--r--trunk/Examples/lua/dual/Makefile21
-rw-r--r--trunk/Examples/lua/dual/dual.cpp109
-rw-r--r--trunk/Examples/lua/dual/example.i10
-rw-r--r--trunk/Examples/lua/dual/example2.i10
-rw-r--r--trunk/Examples/lua/embed/Makefile18
-rw-r--r--trunk/Examples/lua/embed/embed.c85
-rw-r--r--trunk/Examples/lua/embed/example.c22
-rw-r--r--trunk/Examples/lua/embed/example.i8
-rw-r--r--trunk/Examples/lua/embed/runme.lua40
-rw-r--r--trunk/Examples/lua/embed2/Makefile18
-rw-r--r--trunk/Examples/lua/embed2/embed2.c233
-rw-r--r--trunk/Examples/lua/embed2/example.c22
-rw-r--r--trunk/Examples/lua/embed2/example.i8
-rw-r--r--trunk/Examples/lua/embed2/runme.lua27
-rw-r--r--trunk/Examples/lua/embed3/Makefile20
-rw-r--r--trunk/Examples/lua/embed3/embed3.cpp146
-rw-r--r--trunk/Examples/lua/embed3/example.cpp25
-rw-r--r--trunk/Examples/lua/embed3/example.h24
-rw-r--r--trunk/Examples/lua/embed3/example.i8
-rw-r--r--trunk/Examples/lua/embed3/runme.lua35
-rw-r--r--trunk/Examples/lua/exception/Makefile19
-rw-r--r--trunk/Examples/lua/exception/example.h53
-rw-r--r--trunk/Examples/lua/exception/example.i17
-rw-r--r--trunk/Examples/lua/exception/runme.lua96
-rw-r--r--trunk/Examples/lua/funcptr3/Makefile19
-rw-r--r--trunk/Examples/lua/funcptr3/example.c19
-rw-r--r--trunk/Examples/lua/funcptr3/example.h9
-rw-r--r--trunk/Examples/lua/funcptr3/example.i69
-rw-r--r--trunk/Examples/lua/funcptr3/runme.lua54
-rw-r--r--trunk/Examples/lua/functest/Makefile19
-rw-r--r--trunk/Examples/lua/functest/example.c25
-rw-r--r--trunk/Examples/lua/functest/example.i13
-rw-r--r--trunk/Examples/lua/functest/runme.lua20
-rw-r--r--trunk/Examples/lua/functor/Makefile20
-rw-r--r--trunk/Examples/lua/functor/example.i29
-rw-r--r--trunk/Examples/lua/functor/runme.lua24
-rw-r--r--trunk/Examples/lua/import.lua42
-rw-r--r--trunk/Examples/lua/import/Makefile19
-rw-r--r--trunk/Examples/lua/import/README36
-rw-r--r--trunk/Examples/lua/import/bar.h21
-rw-r--r--trunk/Examples/lua/import/bar.i9
-rw-r--r--trunk/Examples/lua/import/base.h16
-rw-r--r--trunk/Examples/lua/import/base.i6
-rw-r--r--trunk/Examples/lua/import/foo.h21
-rw-r--r--trunk/Examples/lua/import/foo.i8
-rw-r--r--trunk/Examples/lua/import/runme.lua103
-rw-r--r--trunk/Examples/lua/import/spam.h24
-rw-r--r--trunk/Examples/lua/import/spam.i9
-rw-r--r--trunk/Examples/lua/lua.c438
-rw-r--r--trunk/Examples/lua/owner/Makefile19
-rw-r--r--trunk/Examples/lua/owner/example.cxx69
-rw-r--r--trunk/Examples/lua/owner/example.h54
-rw-r--r--trunk/Examples/lua/owner/example.i32
-rw-r--r--trunk/Examples/lua/owner/runme.lua104
-rw-r--r--trunk/Examples/lua/pointer/Makefile19
-rw-r--r--trunk/Examples/lua/pointer/example.c16
-rw-r--r--trunk/Examples/lua/pointer/example.i35
-rw-r--r--trunk/Examples/lua/pointer/runme.lua48
-rw-r--r--trunk/Examples/lua/simple/Makefile18
-rw-r--r--trunk/Examples/lua/simple/example.c18
-rw-r--r--trunk/Examples/lua/simple/example.i7
-rw-r--r--trunk/Examples/lua/simple/runme.lua35
-rw-r--r--trunk/Examples/lua/variables/Makefile18
-rw-r--r--trunk/Examples/lua/variables/example.c91
-rw-r--r--trunk/Examples/lua/variables/example.h6
-rw-r--r--trunk/Examples/lua/variables/example.i49
-rw-r--r--trunk/Examples/lua/variables/runme.lua81
-rw-r--r--trunk/Examples/modula3/check.list7
-rw-r--r--trunk/Examples/modula3/class/Makefile25
-rw-r--r--trunk/Examples/modula3/class/example.cxx28
-rw-r--r--trunk/Examples/modula3/class/example.h44
-rw-r--r--trunk/Examples/modula3/class/example.i32
-rw-r--r--trunk/Examples/modula3/class/swig.tmpl11
-rw-r--r--trunk/Examples/modula3/enum/Makefile26
-rw-r--r--trunk/Examples/modula3/enum/example.cxx32
-rw-r--r--trunk/Examples/modula3/enum/example.h83
-rw-r--r--trunk/Examples/modula3/enum/example.i72
-rw-r--r--trunk/Examples/modula3/exception/Makefile23
-rw-r--r--trunk/Examples/modula3/exception/example.h18
-rw-r--r--trunk/Examples/modula3/exception/example.i43
-rw-r--r--trunk/Examples/modula3/reference/Makefile21
-rw-r--r--trunk/Examples/modula3/reference/example.cxx46
-rw-r--r--trunk/Examples/modula3/reference/example.h22
-rw-r--r--trunk/Examples/modula3/reference/example.i32
-rw-r--r--trunk/Examples/modula3/simple/Makefile21
-rw-r--r--trunk/Examples/modula3/simple/example.c18
-rw-r--r--trunk/Examples/modula3/simple/example.i7
-rw-r--r--trunk/Examples/modula3/typemap/Makefile21
-rw-r--r--trunk/Examples/modula3/typemap/example.i90
-rw-r--r--trunk/Examples/mzscheme/check.list3
-rw-r--r--trunk/Examples/mzscheme/multimap/Makefile13
-rw-r--r--trunk/Examples/mzscheme/multimap/example.c53
-rw-r--r--trunk/Examples/mzscheme/multimap/example.i91
-rw-r--r--trunk/Examples/mzscheme/multimap/example.scm27
-rw-r--r--trunk/Examples/mzscheme/simple/Makefile13
-rw-r--r--trunk/Examples/mzscheme/simple/README1
-rw-r--r--trunk/Examples/mzscheme/simple/example.c24
-rw-r--r--trunk/Examples/mzscheme/simple/example.i16
-rw-r--r--trunk/Examples/mzscheme/simple/example.scm24
-rw-r--r--trunk/Examples/mzscheme/std_vector/Makefile19
-rw-r--r--trunk/Examples/mzscheme/std_vector/example.h25
-rw-r--r--trunk/Examples/mzscheme/std_vector/example.i17
-rw-r--r--trunk/Examples/mzscheme/std_vector/example.scm54
-rw-r--r--trunk/Examples/ocaml/argout_ref/Makefile27
-rw-r--r--trunk/Examples/ocaml/argout_ref/example.c19
-rw-r--r--trunk/Examples/ocaml/argout_ref/example.i4
-rw-r--r--trunk/Examples/ocaml/argout_ref/example_prog.ml26
-rw-r--r--trunk/Examples/ocaml/check.list10
-rw-r--r--trunk/Examples/ocaml/contract/Makefile33
-rw-r--r--trunk/Examples/ocaml/contract/example.i18
-rw-r--r--trunk/Examples/ocaml/contract/example_prog.ml7
-rw-r--r--trunk/Examples/ocaml/scoped_enum/Makefile33
-rw-r--r--trunk/Examples/ocaml/scoped_enum/README1
-rw-r--r--trunk/Examples/ocaml/scoped_enum/example.i7
-rw-r--r--trunk/Examples/ocaml/scoped_enum/example_prog.ml4
-rw-r--r--trunk/Examples/ocaml/scoped_enum/foo.h5
-rw-r--r--trunk/Examples/ocaml/shapes/Makefile34
-rw-r--r--trunk/Examples/ocaml/shapes/example.c48
-rw-r--r--trunk/Examples/ocaml/shapes/example.h18
-rw-r--r--trunk/Examples/ocaml/shapes/example.i10
-rw-r--r--trunk/Examples/ocaml/shapes/example_prog.ml76
-rw-r--r--trunk/Examples/ocaml/simple/Makefile33
-rw-r--r--trunk/Examples/ocaml/simple/example.c18
-rw-r--r--trunk/Examples/ocaml/simple/example.i7
-rw-r--r--trunk/Examples/ocaml/simple/example_prog.ml33
-rw-r--r--trunk/Examples/ocaml/simple/index.html97
-rw-r--r--trunk/Examples/ocaml/std_string/Makefile23
-rw-r--r--trunk/Examples/ocaml/std_string/README13
-rw-r--r--trunk/Examples/ocaml/std_string/example.h36
-rw-r--r--trunk/Examples/ocaml/std_string/example.i12
-rw-r--r--trunk/Examples/ocaml/std_string/runme.ml24
-rw-r--r--trunk/Examples/ocaml/std_vector/Makefile23
-rw-r--r--trunk/Examples/ocaml/std_vector/example.h25
-rw-r--r--trunk/Examples/ocaml/std_vector/example.i15
-rw-r--r--trunk/Examples/ocaml/std_vector/runme.ml35
-rw-r--r--trunk/Examples/ocaml/stl/Makefile33
-rw-r--r--trunk/Examples/ocaml/stl/example.h17
-rw-r--r--trunk/Examples/ocaml/stl/example.i12
-rw-r--r--trunk/Examples/ocaml/stl/runme.ml13
-rw-r--r--trunk/Examples/ocaml/string_from_ptr/Makefile34
-rw-r--r--trunk/Examples/ocaml/string_from_ptr/example_prog.ml23
-rw-r--r--trunk/Examples/ocaml/string_from_ptr/foolib.i16
-rw-r--r--trunk/Examples/ocaml/strings_test/Makefile28
-rw-r--r--trunk/Examples/ocaml/strings_test/example.h37
-rw-r--r--trunk/Examples/ocaml/strings_test/example.i14
-rw-r--r--trunk/Examples/ocaml/strings_test/runme.ml17
-rw-r--r--trunk/Examples/octave/callback/Makefile21
-rw-r--r--trunk/Examples/octave/callback/example.cxx4
-rw-r--r--trunk/Examples/octave/callback/example.h23
-rw-r--r--trunk/Examples/octave/callback/example.i13
-rw-r--r--trunk/Examples/octave/callback/runme.m63
-rw-r--r--trunk/Examples/octave/check.list16
-rw-r--r--trunk/Examples/octave/class/Makefile21
-rw-r--r--trunk/Examples/octave/class/example.cxx28
-rw-r--r--trunk/Examples/octave/class/example.h39
-rw-r--r--trunk/Examples/octave/class/example.i10
-rw-r--r--trunk/Examples/octave/class/runme.m52
-rw-r--r--trunk/Examples/octave/constants/Makefile21
-rw-r--r--trunk/Examples/octave/constants/example.i27
-rw-r--r--trunk/Examples/octave/constants/runme.m29
-rw-r--r--trunk/Examples/octave/contract/Makefile19
-rw-r--r--trunk/Examples/octave/contract/example.c23
-rw-r--r--trunk/Examples/octave/contract/example.i21
-rw-r--r--trunk/Examples/octave/contract/runme.m22
-rw-r--r--trunk/Examples/octave/enum/Makefile21
-rw-r--r--trunk/Examples/octave/enum/example.cxx37
-rw-r--r--trunk/Examples/octave/enum/example.h13
-rw-r--r--trunk/Examples/octave/enum/example.i11
-rw-r--r--trunk/Examples/octave/enum/runme.m32
-rw-r--r--trunk/Examples/octave/extend/Makefile21
-rw-r--r--trunk/Examples/octave/extend/example.cxx4
-rw-r--r--trunk/Examples/octave/extend/example.h56
-rw-r--r--trunk/Examples/octave/extend/example.i15
-rw-r--r--trunk/Examples/octave/extend/runme.m74
-rw-r--r--trunk/Examples/octave/funcptr/Makefile19
-rw-r--r--trunk/Examples/octave/funcptr/example.c19
-rw-r--r--trunk/Examples/octave/funcptr/example.h9
-rw-r--r--trunk/Examples/octave/funcptr/example.i16
-rw-r--r--trunk/Examples/octave/funcptr/runme.m21
-rw-r--r--trunk/Examples/octave/funcptr2/Makefile19
-rw-r--r--trunk/Examples/octave/funcptr2/example.c19
-rw-r--r--trunk/Examples/octave/funcptr2/example.h9
-rw-r--r--trunk/Examples/octave/funcptr2/example.i18
-rw-r--r--trunk/Examples/octave/funcptr2/runme.m24
-rw-r--r--trunk/Examples/octave/functor/Makefile21
-rw-r--r--trunk/Examples/octave/functor/example.i29
-rw-r--r--trunk/Examples/octave/functor/runme.m18
-rw-r--r--trunk/Examples/octave/operator/Makefile21
-rw-r--r--trunk/Examples/octave/operator/example.h36
-rw-r--r--trunk/Examples/octave/operator/example.i24
-rw-r--r--trunk/Examples/octave/operator/runme.m24
-rw-r--r--trunk/Examples/octave/pointer/Makefile19
-rw-r--r--trunk/Examples/octave/pointer/example.c16
-rw-r--r--trunk/Examples/octave/pointer/example.i30
-rw-r--r--trunk/Examples/octave/pointer/runme.m42
-rw-r--r--trunk/Examples/octave/reference/Makefile21
-rw-r--r--trunk/Examples/octave/reference/example.cxx46
-rw-r--r--trunk/Examples/octave/reference/example.h26
-rw-r--r--trunk/Examples/octave/reference/example.i48
-rw-r--r--trunk/Examples/octave/reference/runme.m63
-rw-r--r--trunk/Examples/octave/simple/Makefile19
-rw-r--r--trunk/Examples/octave/simple/example.c18
-rw-r--r--trunk/Examples/octave/simple/example.i7
-rw-r--r--trunk/Examples/octave/simple/runme.m22
-rw-r--r--trunk/Examples/octave/template/Makefile21
-rw-r--r--trunk/Examples/octave/template/example.h32
-rw-r--r--trunk/Examples/octave/template/example.i17
-rw-r--r--trunk/Examples/octave/template/runme.m37
-rw-r--r--trunk/Examples/octave/variables/Makefile19
-rw-r--r--trunk/Examples/octave/variables/example.c91
-rw-r--r--trunk/Examples/octave/variables/example.h6
-rw-r--r--trunk/Examples/octave/variables/example.i53
-rw-r--r--trunk/Examples/octave/variables/runme.m75
-rw-r--r--trunk/Examples/perl5/check.list14
-rw-r--r--trunk/Examples/perl5/class/Makefile19
-rw-r--r--trunk/Examples/perl5/class/example.cxx28
-rw-r--r--trunk/Examples/perl5/class/example.dsp152
-rw-r--r--trunk/Examples/perl5/class/example.h47
-rw-r--r--trunk/Examples/perl5/class/example.i11
-rw-r--r--trunk/Examples/perl5/class/index.html208
-rw-r--r--trunk/Examples/perl5/class/runme.pl60
-rw-r--r--trunk/Examples/perl5/constants/Makefile18
-rw-r--r--trunk/Examples/perl5/constants/example.i27
-rw-r--r--trunk/Examples/perl5/constants/index.html53
-rw-r--r--trunk/Examples/perl5/constants/runme.pl29
-rw-r--r--trunk/Examples/perl5/constants2/Makefile18
-rw-r--r--trunk/Examples/perl5/constants2/example.i27
-rw-r--r--trunk/Examples/perl5/constants2/runme.pl16
-rw-r--r--trunk/Examples/perl5/funcptr/Makefile18
-rw-r--r--trunk/Examples/perl5/funcptr/example.c19
-rw-r--r--trunk/Examples/perl5/funcptr/example.h9
-rw-r--r--trunk/Examples/perl5/funcptr/example.i16
-rw-r--r--trunk/Examples/perl5/funcptr/index.html90
-rw-r--r--trunk/Examples/perl5/funcptr/runme.pl21
-rw-r--r--trunk/Examples/perl5/import/Makefile20
-rw-r--r--trunk/Examples/perl5/import/README39
-rw-r--r--trunk/Examples/perl5/import/bar.dsp144
-rw-r--r--trunk/Examples/perl5/import/bar.h22
-rw-r--r--trunk/Examples/perl5/import/bar.i9
-rw-r--r--trunk/Examples/perl5/import/base.dsp144
-rw-r--r--trunk/Examples/perl5/import/base.h18
-rw-r--r--trunk/Examples/perl5/import/base.i6
-rw-r--r--trunk/Examples/perl5/import/example.dsw65
-rw-r--r--trunk/Examples/perl5/import/foo.dsp144
-rw-r--r--trunk/Examples/perl5/import/foo.h21
-rw-r--r--trunk/Examples/perl5/import/foo.i8
-rw-r--r--trunk/Examples/perl5/import/runme.pl116
-rw-r--r--trunk/Examples/perl5/import/spam.dsp144
-rw-r--r--trunk/Examples/perl5/import/spam.h24
-rw-r--r--trunk/Examples/perl5/import/spam.i9
-rw-r--r--trunk/Examples/perl5/index.html80
-rw-r--r--trunk/Examples/perl5/inline/Makefile7
-rw-r--r--trunk/Examples/perl5/inline/README2
-rw-r--r--trunk/Examples/perl5/inline/runme.pl34
-rw-r--r--trunk/Examples/perl5/java/Example.java29
-rw-r--r--trunk/Examples/perl5/java/Makefile26
-rw-r--r--trunk/Examples/perl5/java/example.i10
-rw-r--r--trunk/Examples/perl5/java/runme.pl29
-rw-r--r--trunk/Examples/perl5/multimap/Makefile18
-rw-r--r--trunk/Examples/perl5/multimap/example.c53
-rw-r--r--trunk/Examples/perl5/multimap/example.dsp148
-rw-r--r--trunk/Examples/perl5/multimap/example.i93
-rw-r--r--trunk/Examples/perl5/multimap/runme.pl28
-rw-r--r--trunk/Examples/perl5/multiple_inheritance/Makefile19
-rw-r--r--trunk/Examples/perl5/multiple_inheritance/example.h31
-rw-r--r--trunk/Examples/perl5/multiple_inheritance/example.i9
-rw-r--r--trunk/Examples/perl5/multiple_inheritance/runme.pl16
-rw-r--r--trunk/Examples/perl5/pointer/Makefile18
-rw-r--r--trunk/Examples/perl5/pointer/example.c16
-rw-r--r--trunk/Examples/perl5/pointer/example.i30
-rw-r--r--trunk/Examples/perl5/pointer/index.html171
-rw-r--r--trunk/Examples/perl5/pointer/runme.pl44
-rw-r--r--trunk/Examples/perl5/reference/Makefile20
-rw-r--r--trunk/Examples/perl5/reference/example.cxx46
-rw-r--r--trunk/Examples/perl5/reference/example.h26
-rw-r--r--trunk/Examples/perl5/reference/example.i46
-rw-r--r--trunk/Examples/perl5/reference/index.html146
-rw-r--r--trunk/Examples/perl5/reference/runme.pl74
-rw-r--r--trunk/Examples/perl5/simple/Makefile18
-rw-r--r--trunk/Examples/perl5/simple/example.c18
-rw-r--r--trunk/Examples/perl5/simple/example.dsp148
-rw-r--r--trunk/Examples/perl5/simple/example.i7
-rw-r--r--trunk/Examples/perl5/simple/index.html99
-rw-r--r--trunk/Examples/perl5/simple/runme.pl23
-rw-r--r--trunk/Examples/perl5/value/Makefile18
-rw-r--r--trunk/Examples/perl5/value/example.c15
-rw-r--r--trunk/Examples/perl5/value/example.h5
-rw-r--r--trunk/Examples/perl5/value/example.i32
-rw-r--r--trunk/Examples/perl5/value/index.html126
-rw-r--r--trunk/Examples/perl5/value/runme.pl38
-rw-r--r--trunk/Examples/perl5/variables/Makefile18
-rw-r--r--trunk/Examples/perl5/variables/example.c91
-rw-r--r--trunk/Examples/perl5/variables/example.h6
-rw-r--r--trunk/Examples/perl5/variables/example.i51
-rw-r--r--trunk/Examples/perl5/variables/index.html63
-rw-r--r--trunk/Examples/perl5/variables/runme.pl73
-rw-r--r--trunk/Examples/perl5/xmlstring/Makefile23
-rw-r--r--trunk/Examples/perl5/xmlstring/example.cxx1
-rw-r--r--trunk/Examples/perl5/xmlstring/example.h36
-rw-r--r--trunk/Examples/perl5/xmlstring/example.i10
-rw-r--r--trunk/Examples/perl5/xmlstring/runme.pl8
-rw-r--r--trunk/Examples/perl5/xmlstring/xmlstring.i111
-rw-r--r--trunk/Examples/php/callback/Makefile22
-rw-r--r--trunk/Examples/php/callback/example.cxx4
-rw-r--r--trunk/Examples/php/callback/example.h22
-rw-r--r--trunk/Examples/php/callback/example.i13
-rw-r--r--trunk/Examples/php/callback/index.html19
-rw-r--r--trunk/Examples/php/callback/runme.php47
-rw-r--r--trunk/Examples/php/check.list19
-rw-r--r--trunk/Examples/php/class/Makefile24
-rw-r--r--trunk/Examples/php/class/example.cxx39
-rw-r--r--trunk/Examples/php/class/example.h38
-rw-r--r--trunk/Examples/php/class/example.i10
-rw-r--r--trunk/Examples/php/class/runme.php60
-rw-r--r--trunk/Examples/php/constants/Makefile24
-rw-r--r--trunk/Examples/php/constants/example.i26
-rw-r--r--trunk/Examples/php/constants/runme.php28
-rw-r--r--trunk/Examples/php/cpointer/Makefile24
-rw-r--r--trunk/Examples/php/cpointer/example.c16
-rw-r--r--trunk/Examples/php/cpointer/example.i26
-rw-r--r--trunk/Examples/php/cpointer/runme.php45
-rw-r--r--trunk/Examples/php/disown/Makefile24
-rw-r--r--trunk/Examples/php/disown/example.cxx51
-rw-r--r--trunk/Examples/php/disown/example.h50
-rw-r--r--trunk/Examples/php/disown/example.i12
-rw-r--r--trunk/Examples/php/disown/runme.php49
-rw-r--r--trunk/Examples/php/enum/Makefile24
-rw-r--r--trunk/Examples/php/enum/example.cxx37
-rw-r--r--trunk/Examples/php/enum/example.h13
-rw-r--r--trunk/Examples/php/enum/example.i12
-rw-r--r--trunk/Examples/php/enum/runme.php32
-rw-r--r--trunk/Examples/php/extend/Makefile22
-rw-r--r--trunk/Examples/php/extend/example.cxx4
-rw-r--r--trunk/Examples/php/extend/example.h56
-rw-r--r--trunk/Examples/php/extend/example.i15
-rw-r--r--trunk/Examples/php/extend/index.html19
-rw-r--r--trunk/Examples/php/extend/runme.php76
-rw-r--r--trunk/Examples/php/funcptr/Makefile24
-rw-r--r--trunk/Examples/php/funcptr/example.c17
-rw-r--r--trunk/Examples/php/funcptr/example.h7
-rw-r--r--trunk/Examples/php/funcptr/example.i15
-rw-r--r--trunk/Examples/php/funcptr/runme.php24
-rw-r--r--trunk/Examples/php/overloading/Makefile24
-rw-r--r--trunk/Examples/php/overloading/example.cxx55
-rw-r--r--trunk/Examples/php/overloading/example.h46
-rw-r--r--trunk/Examples/php/overloading/example.i8
-rw-r--r--trunk/Examples/php/overloading/runme.php59
-rw-r--r--trunk/Examples/php/pointer/Makefile24
-rw-r--r--trunk/Examples/php/pointer/example.c16
-rw-r--r--trunk/Examples/php/pointer/example.i24
-rw-r--r--trunk/Examples/php/pointer/runme.php35
-rw-r--r--trunk/Examples/php/pragmas/Makefile24
-rw-r--r--trunk/Examples/php/pragmas/example.i31
-rw-r--r--trunk/Examples/php/pragmas/include.php7
-rwxr-xr-xtrunk/Examples/php/pragmas/runme.php5
-rw-r--r--trunk/Examples/php/proxy/Makefile24
-rw-r--r--trunk/Examples/php/proxy/example.cxx43
-rw-r--r--trunk/Examples/php/proxy/example.h43
-rw-r--r--trunk/Examples/php/proxy/example.i12
-rw-r--r--trunk/Examples/php/proxy/runme.php68
-rw-r--r--trunk/Examples/php/reference/Makefile24
-rw-r--r--trunk/Examples/php/reference/example.cxx49
-rw-r--r--trunk/Examples/php/reference/example.h26
-rw-r--r--trunk/Examples/php/reference/example.i47
-rw-r--r--trunk/Examples/php/reference/runme.php49
-rw-r--r--trunk/Examples/php/simple/Makefile24
-rw-r--r--trunk/Examples/php/simple/example.c23
-rw-r--r--trunk/Examples/php/simple/example.i10
-rwxr-xr-xtrunk/Examples/php/simple/runme.php25
-rw-r--r--trunk/Examples/php/sync/Makefile24
-rw-r--r--trunk/Examples/php/sync/example.cxx13
-rw-r--r--trunk/Examples/php/sync/example.h9
-rw-r--r--trunk/Examples/php/sync/example.i7
-rw-r--r--trunk/Examples/php/sync/runme.php15
-rw-r--r--trunk/Examples/php/value/Makefile24
-rw-r--r--trunk/Examples/php/value/example.c13
-rw-r--r--trunk/Examples/php/value/example.h8
-rw-r--r--trunk/Examples/php/value/example.i17
-rw-r--r--trunk/Examples/php/value/runme.php43
-rw-r--r--trunk/Examples/php/variables/Makefile24
-rw-r--r--trunk/Examples/php/variables/example.c95
-rw-r--r--trunk/Examples/php/variables/example.h34
-rw-r--r--trunk/Examples/php/variables/example.i44
-rw-r--r--trunk/Examples/php/variables/runme.php96
-rw-r--r--trunk/Examples/pike/check.list5
-rw-r--r--trunk/Examples/pike/class/Makefile19
-rw-r--r--trunk/Examples/pike/class/example.cxx46
-rw-r--r--trunk/Examples/pike/class/example.h35
-rw-r--r--trunk/Examples/pike/class/example.i10
-rwxr-xr-xtrunk/Examples/pike/class/runme.pike53
-rw-r--r--trunk/Examples/pike/constants/Makefile18
-rw-r--r--trunk/Examples/pike/constants/example.i27
-rwxr-xr-xtrunk/Examples/pike/constants/runme.pike24
-rw-r--r--trunk/Examples/pike/enum/Makefile19
-rw-r--r--trunk/Examples/pike/enum/README13
-rw-r--r--trunk/Examples/pike/enum/example.cxx37
-rw-r--r--trunk/Examples/pike/enum/example.h13
-rw-r--r--trunk/Examples/pike/enum/example.i11
-rw-r--r--trunk/Examples/pike/enum/runme.pike28
-rw-r--r--trunk/Examples/pike/overload/Makefile19
-rw-r--r--trunk/Examples/pike/overload/example.cxx115
-rw-r--r--trunk/Examples/pike/overload/example.h41
-rw-r--r--trunk/Examples/pike/overload/example.i28
-rw-r--r--trunk/Examples/pike/overload/runme.pike83
-rw-r--r--trunk/Examples/pike/simple/Makefile18
-rw-r--r--trunk/Examples/pike/simple/example.c18
-rw-r--r--trunk/Examples/pike/simple/example.i7
-rw-r--r--trunk/Examples/pike/simple/runme.pike20
-rw-r--r--trunk/Examples/pike/template/Makefile20
-rw-r--r--trunk/Examples/pike/template/example.h32
-rw-r--r--trunk/Examples/pike/template/example.i17
-rwxr-xr-xtrunk/Examples/pike/template/runme.pike33
-rw-r--r--trunk/Examples/python/callback/Makefile22
-rw-r--r--trunk/Examples/python/callback/example.cxx4
-rw-r--r--trunk/Examples/python/callback/example.h22
-rw-r--r--trunk/Examples/python/callback/example.i13
-rw-r--r--trunk/Examples/python/callback/index.html19
-rw-r--r--trunk/Examples/python/callback/runme.py56
-rw-r--r--trunk/Examples/python/check.list29
-rw-r--r--trunk/Examples/python/class/Makefile21
-rw-r--r--trunk/Examples/python/class/example.cxx28
-rw-r--r--trunk/Examples/python/class/example.dsp152
-rw-r--r--trunk/Examples/python/class/example.h39
-rw-r--r--trunk/Examples/python/class/example.i10
-rw-r--r--trunk/Examples/python/class/index.html216
-rw-r--r--trunk/Examples/python/class/runme.py51
-rw-r--r--trunk/Examples/python/constants/Makefile20
-rw-r--r--trunk/Examples/python/constants/example.i27
-rw-r--r--trunk/Examples/python/constants/index.html67
-rw-r--r--trunk/Examples/python/constants/runme.py27
-rw-r--r--trunk/Examples/python/contract/Makefile20
-rw-r--r--trunk/Examples/python/contract/example.c23
-rw-r--r--trunk/Examples/python/contract/example.dsp148
-rw-r--r--trunk/Examples/python/contract/example.i21
-rw-r--r--trunk/Examples/python/contract/runme.py30
-rw-r--r--trunk/Examples/python/docstrings/Makefile24
-rw-r--r--trunk/Examples/python/docstrings/example.cxx4
-rw-r--r--trunk/Examples/python/docstrings/example.h4
-rw-r--r--trunk/Examples/python/docstrings/example.i14
-rw-r--r--trunk/Examples/python/docstrings/runme.py6
-rw-r--r--trunk/Examples/python/enum/Makefile21
-rw-r--r--trunk/Examples/python/enum/example.cxx37
-rw-r--r--trunk/Examples/python/enum/example.h13
-rw-r--r--trunk/Examples/python/enum/example.i11
-rw-r--r--trunk/Examples/python/enum/index.html35
-rw-r--r--trunk/Examples/python/enum/runme.py31
-rw-r--r--trunk/Examples/python/exception/Makefile21
-rw-r--r--trunk/Examples/python/exception/example.h53
-rw-r--r--trunk/Examples/python/exception/example.i12
-rw-r--r--trunk/Examples/python/exception/runme.py36
-rw-r--r--trunk/Examples/python/exceptproxy/Makefile22
-rw-r--r--trunk/Examples/python/exceptproxy/example.h54
-rw-r--r--trunk/Examples/python/exceptproxy/example.i114
-rw-r--r--trunk/Examples/python/exceptproxy/runme.py45
-rw-r--r--trunk/Examples/python/extend/Makefile22
-rw-r--r--trunk/Examples/python/extend/example.cxx4
-rw-r--r--trunk/Examples/python/extend/example.h56
-rw-r--r--trunk/Examples/python/extend/example.i15
-rw-r--r--trunk/Examples/python/extend/index.html19
-rw-r--r--trunk/Examples/python/extend/runme.py81
-rw-r--r--trunk/Examples/python/funcptr/Makefile20
-rw-r--r--trunk/Examples/python/funcptr/example.c19
-rw-r--r--trunk/Examples/python/funcptr/example.h9
-rw-r--r--trunk/Examples/python/funcptr/example.i16
-rw-r--r--trunk/Examples/python/funcptr/index.html90
-rw-r--r--trunk/Examples/python/funcptr/runme.py20
-rw-r--r--trunk/Examples/python/funcptr2/Makefile20
-rw-r--r--trunk/Examples/python/funcptr2/example.c19
-rw-r--r--trunk/Examples/python/funcptr2/example.h9
-rw-r--r--trunk/Examples/python/funcptr2/example.i18
-rw-r--r--trunk/Examples/python/funcptr2/runme.py24
-rw-r--r--trunk/Examples/python/functor/Makefile22
-rw-r--r--trunk/Examples/python/functor/example.i29
-rw-r--r--trunk/Examples/python/functor/runme.py17
-rw-r--r--trunk/Examples/python/import/Makefile22
-rw-r--r--trunk/Examples/python/import/README39
-rw-r--r--trunk/Examples/python/import/bar.dsp144
-rw-r--r--trunk/Examples/python/import/bar.h22
-rw-r--r--trunk/Examples/python/import/bar.i9
-rw-r--r--trunk/Examples/python/import/base.dsp144
-rw-r--r--trunk/Examples/python/import/base.h18
-rw-r--r--trunk/Examples/python/import/base.i6
-rw-r--r--trunk/Examples/python/import/example.dsw65
-rw-r--r--trunk/Examples/python/import/foo.dsp144
-rw-r--r--trunk/Examples/python/import/foo.h21
-rw-r--r--trunk/Examples/python/import/foo.i8
-rw-r--r--trunk/Examples/python/import/runme.py111
-rw-r--r--trunk/Examples/python/import/spam.dsp144
-rw-r--r--trunk/Examples/python/import/spam.h24
-rw-r--r--trunk/Examples/python/import/spam.i9
-rw-r--r--trunk/Examples/python/import_template/Makefile22
-rw-r--r--trunk/Examples/python/import_template/README30
-rw-r--r--trunk/Examples/python/import_template/bar.h22
-rw-r--r--trunk/Examples/python/import_template/bar.i11
-rw-r--r--trunk/Examples/python/import_template/base.h18
-rw-r--r--trunk/Examples/python/import_template/base.i7
-rw-r--r--trunk/Examples/python/import_template/foo.h21
-rw-r--r--trunk/Examples/python/import_template/foo.i10
-rw-r--r--trunk/Examples/python/import_template/runme.py111
-rw-r--r--trunk/Examples/python/import_template/spam.h24
-rw-r--r--trunk/Examples/python/import_template/spam.i10
-rw-r--r--trunk/Examples/python/index.html112
-rw-r--r--trunk/Examples/python/java/Example.java29
-rw-r--r--trunk/Examples/python/java/Makefile25
-rw-r--r--trunk/Examples/python/java/example.i9
-rw-r--r--trunk/Examples/python/java/runme.py16
-rw-r--r--trunk/Examples/python/libffi/Makefile20
-rw-r--r--trunk/Examples/python/libffi/example.i176
-rw-r--r--trunk/Examples/python/multimap/Makefile20
-rw-r--r--trunk/Examples/python/multimap/example.c53
-rw-r--r--trunk/Examples/python/multimap/example.dsp148
-rw-r--r--trunk/Examples/python/multimap/example.i121
-rw-r--r--trunk/Examples/python/multimap/runme.py27
-rw-r--r--trunk/Examples/python/operator/Makefile22
-rw-r--r--trunk/Examples/python/operator/example.h36
-rw-r--r--trunk/Examples/python/operator/example.i28
-rw-r--r--trunk/Examples/python/operator/runme.py21
-rw-r--r--trunk/Examples/python/pointer/Makefile20
-rw-r--r--trunk/Examples/python/pointer/example.c16
-rw-r--r--trunk/Examples/python/pointer/example.i30
-rw-r--r--trunk/Examples/python/pointer/index.html171
-rw-r--r--trunk/Examples/python/pointer/runme.py44
-rw-r--r--trunk/Examples/python/reference/Makefile21
-rw-r--r--trunk/Examples/python/reference/example.cxx46
-rw-r--r--trunk/Examples/python/reference/example.h26
-rw-r--r--trunk/Examples/python/reference/example.i48
-rw-r--r--trunk/Examples/python/reference/index.html147
-rw-r--r--trunk/Examples/python/reference/runme.py63
-rw-r--r--trunk/Examples/python/simple/Makefile20
-rw-r--r--trunk/Examples/python/simple/example.c18
-rw-r--r--trunk/Examples/python/simple/example.dsp148
-rw-r--r--trunk/Examples/python/simple/example.i7
-rw-r--r--trunk/Examples/python/simple/index.html97
-rw-r--r--trunk/Examples/python/simple/runme.py30
-rw-r--r--trunk/Examples/python/smartptr/Makefile22
-rw-r--r--trunk/Examples/python/smartptr/example.cxx31
-rw-r--r--trunk/Examples/python/smartptr/example.h39
-rw-r--r--trunk/Examples/python/smartptr/example.i20
-rw-r--r--trunk/Examples/python/smartptr/runme.py55
-rw-r--r--trunk/Examples/python/smartptr/smartptr.h13
-rw-r--r--trunk/Examples/python/std_map/Makefile25
-rw-r--r--trunk/Examples/python/std_map/example.h17
-rw-r--r--trunk/Examples/python/std_map/example.i27
-rw-r--r--trunk/Examples/python/std_map/runme.py82
-rw-r--r--trunk/Examples/python/std_vector/Makefile22
-rw-r--r--trunk/Examples/python/std_vector/example.h25
-rw-r--r--trunk/Examples/python/std_vector/example.i17
-rw-r--r--trunk/Examples/python/std_vector/runme.py36
-rw-r--r--trunk/Examples/python/swigrun/Makefile25
-rw-r--r--trunk/Examples/python/swigrun/example.cxx20
-rw-r--r--trunk/Examples/python/swigrun/example.h58
-rw-r--r--trunk/Examples/python/swigrun/example.i15
-rw-r--r--trunk/Examples/python/swigrun/runme.py28
-rw-r--r--trunk/Examples/python/template/Makefile22
-rw-r--r--trunk/Examples/python/template/example.h32
-rw-r--r--trunk/Examples/python/template/example.i17
-rw-r--r--trunk/Examples/python/template/runme.py34
-rw-r--r--trunk/Examples/python/varargs/Makefile20
-rw-r--r--trunk/Examples/python/varargs/example.i65
-rw-r--r--trunk/Examples/python/varargs/runme.py34
-rw-r--r--trunk/Examples/python/variables/Makefile20
-rw-r--r--trunk/Examples/python/variables/example.c91
-rw-r--r--trunk/Examples/python/variables/example.h6
-rw-r--r--trunk/Examples/python/variables/example.i51
-rw-r--r--trunk/Examples/python/variables/index.html100
-rw-r--r--trunk/Examples/python/variables/runme.py75
-rw-r--r--trunk/Examples/r/check.list3
-rw-r--r--trunk/Examples/r/class/Makefile15
-rw-r--r--trunk/Examples/r/class/example.cxx28
-rw-r--r--trunk/Examples/r/class/example.dsp152
-rw-r--r--trunk/Examples/r/class/example.h39
-rw-r--r--trunk/Examples/r/class/example.i9
-rw-r--r--trunk/Examples/r/class/runme.R49
-rw-r--r--trunk/Examples/r/simple/Makefile15
-rw-r--r--trunk/Examples/r/simple/example.c18
-rw-r--r--trunk/Examples/r/simple/example.dsp148
-rw-r--r--trunk/Examples/r/simple/example.i7
-rw-r--r--trunk/Examples/r/simple/runme.R24
-rw-r--r--trunk/Examples/ruby/check.list23
-rw-r--r--trunk/Examples/ruby/class/Makefile19
-rw-r--r--trunk/Examples/ruby/class/example.cxx28
-rw-r--r--trunk/Examples/ruby/class/example.dsp154
-rw-r--r--trunk/Examples/ruby/class/example.h39
-rw-r--r--trunk/Examples/ruby/class/example.i10
-rw-r--r--trunk/Examples/ruby/class/index.html199
-rw-r--r--trunk/Examples/ruby/class/runme.rb49
-rw-r--r--trunk/Examples/ruby/constants/Makefile18
-rw-r--r--trunk/Examples/ruby/constants/example.i27
-rw-r--r--trunk/Examples/ruby/constants/index.html64
-rwxr-xr-xtrunk/Examples/ruby/constants/runme.rb25
-rw-r--r--trunk/Examples/ruby/enum/Makefile19
-rw-r--r--trunk/Examples/ruby/enum/example.cxx37
-rw-r--r--trunk/Examples/ruby/enum/example.h13
-rw-r--r--trunk/Examples/ruby/enum/example.i11
-rw-r--r--trunk/Examples/ruby/enum/index.html35
-rw-r--r--trunk/Examples/ruby/enum/runme.rb30
-rw-r--r--trunk/Examples/ruby/exception_class/Makefile19
-rw-r--r--trunk/Examples/ruby/exception_class/example.h51
-rw-r--r--trunk/Examples/ruby/exception_class/example.i46
-rw-r--r--trunk/Examples/ruby/exception_class/runme.rb45
-rw-r--r--trunk/Examples/ruby/free_function/Makefile19
-rw-r--r--trunk/Examples/ruby/free_function/example.cxx67
-rw-r--r--trunk/Examples/ruby/free_function/example.dsp154
-rw-r--r--trunk/Examples/ruby/free_function/example.h49
-rw-r--r--trunk/Examples/ruby/free_function/example.i41
-rw-r--r--trunk/Examples/ruby/free_function/runme.rb46
-rw-r--r--trunk/Examples/ruby/funcptr/Makefile18
-rw-r--r--trunk/Examples/ruby/funcptr/example.c17
-rw-r--r--trunk/Examples/ruby/funcptr/example.h9
-rw-r--r--trunk/Examples/ruby/funcptr/example.i15
-rw-r--r--trunk/Examples/ruby/funcptr/index.html90
-rw-r--r--trunk/Examples/ruby/funcptr/runme.rb21
-rw-r--r--trunk/Examples/ruby/funcptr2/Makefile18
-rw-r--r--trunk/Examples/ruby/funcptr2/example.c19
-rw-r--r--trunk/Examples/ruby/funcptr2/example.h9
-rw-r--r--trunk/Examples/ruby/funcptr2/example.i18
-rw-r--r--trunk/Examples/ruby/funcptr2/runme.rb22
-rw-r--r--trunk/Examples/ruby/functor/Makefile18
-rw-r--r--trunk/Examples/ruby/functor/example.i26
-rw-r--r--trunk/Examples/ruby/functor/runme.rb17
-rw-r--r--trunk/Examples/ruby/hashargs/Makefile20
-rw-r--r--trunk/Examples/ruby/hashargs/example.i36
-rwxr-xr-xtrunk/Examples/ruby/hashargs/runme.rb26
-rw-r--r--trunk/Examples/ruby/import/Makefile19
-rw-r--r--trunk/Examples/ruby/import/README39
-rw-r--r--trunk/Examples/ruby/import/bar.dsp146
-rw-r--r--trunk/Examples/ruby/import/bar.h21
-rw-r--r--trunk/Examples/ruby/import/bar.i9
-rw-r--r--trunk/Examples/ruby/import/base.dsp146
-rw-r--r--trunk/Examples/ruby/import/base.h16
-rw-r--r--trunk/Examples/ruby/import/base.i6
-rw-r--r--trunk/Examples/ruby/import/example.dsw65
-rw-r--r--trunk/Examples/ruby/import/foo.dsp146
-rw-r--r--trunk/Examples/ruby/import/foo.h21
-rw-r--r--trunk/Examples/ruby/import/foo.i8
-rw-r--r--trunk/Examples/ruby/import/runme.rb90
-rw-r--r--trunk/Examples/ruby/import/spam.dsp146
-rw-r--r--trunk/Examples/ruby/import/spam.h24
-rw-r--r--trunk/Examples/ruby/import/spam.i9
-rw-r--r--trunk/Examples/ruby/import_template/Makefile19
-rw-r--r--trunk/Examples/ruby/import_template/README30
-rw-r--r--trunk/Examples/ruby/import_template/bar.h22
-rw-r--r--trunk/Examples/ruby/import_template/bar.i11
-rw-r--r--trunk/Examples/ruby/import_template/base.h18
-rw-r--r--trunk/Examples/ruby/import_template/base.i7
-rw-r--r--trunk/Examples/ruby/import_template/foo.h21
-rw-r--r--trunk/Examples/ruby/import_template/foo.i10
-rw-r--r--trunk/Examples/ruby/import_template/runme.rb92
-rw-r--r--trunk/Examples/ruby/import_template/spam.h24
-rw-r--r--trunk/Examples/ruby/import_template/spam.i10
-rw-r--r--trunk/Examples/ruby/index.html94
-rw-r--r--trunk/Examples/ruby/java/Example.java29
-rw-r--r--trunk/Examples/ruby/java/Makefile26
-rw-r--r--trunk/Examples/ruby/java/example.i9
-rw-r--r--trunk/Examples/ruby/java/runme.rb18
-rw-r--r--trunk/Examples/ruby/mark_function/Makefile19
-rw-r--r--trunk/Examples/ruby/mark_function/example.cxx61
-rw-r--r--trunk/Examples/ruby/mark_function/example.dsp154
-rw-r--r--trunk/Examples/ruby/mark_function/example.h49
-rw-r--r--trunk/Examples/ruby/mark_function/example.i37
-rw-r--r--trunk/Examples/ruby/mark_function/runme.rb23
-rw-r--r--trunk/Examples/ruby/multimap/Makefile18
-rw-r--r--trunk/Examples/ruby/multimap/example.c53
-rw-r--r--trunk/Examples/ruby/multimap/example.dsp150
-rw-r--r--trunk/Examples/ruby/multimap/example.i92
-rwxr-xr-xtrunk/Examples/ruby/multimap/runme.rb22
-rw-r--r--trunk/Examples/ruby/operator/Makefile20
-rw-r--r--trunk/Examples/ruby/operator/example.h36
-rw-r--r--trunk/Examples/ruby/operator/example.i26
-rw-r--r--trunk/Examples/ruby/operator/runme.rb25
-rw-r--r--trunk/Examples/ruby/overloading/Makefile19
-rw-r--r--trunk/Examples/ruby/overloading/example.cxx125
-rw-r--r--trunk/Examples/ruby/overloading/example.h41
-rw-r--r--trunk/Examples/ruby/overloading/example.i24
-rw-r--r--trunk/Examples/ruby/overloading/runme.rb88
-rw-r--r--trunk/Examples/ruby/pointer/Makefile18
-rw-r--r--trunk/Examples/ruby/pointer/example.c16
-rw-r--r--trunk/Examples/ruby/pointer/example.i30
-rw-r--r--trunk/Examples/ruby/pointer/index.html171
-rw-r--r--trunk/Examples/ruby/pointer/runme.rb45
-rw-r--r--trunk/Examples/ruby/reference/Makefile19
-rw-r--r--trunk/Examples/ruby/reference/example.cxx46
-rw-r--r--trunk/Examples/ruby/reference/example.h26
-rw-r--r--trunk/Examples/ruby/reference/example.i46
-rw-r--r--trunk/Examples/ruby/reference/index.html147
-rw-r--r--trunk/Examples/ruby/reference/runme.rb60
-rw-r--r--trunk/Examples/ruby/simple/Makefile18
-rw-r--r--trunk/Examples/ruby/simple/example.c18
-rw-r--r--trunk/Examples/ruby/simple/example.dsp150
-rw-r--r--trunk/Examples/ruby/simple/example.i7
-rw-r--r--trunk/Examples/ruby/simple/index.html97
-rwxr-xr-xtrunk/Examples/ruby/simple/runme.rb21
-rw-r--r--trunk/Examples/ruby/std_vector/Makefile20
-rw-r--r--trunk/Examples/ruby/std_vector/example.h25
-rw-r--r--trunk/Examples/ruby/std_vector/example.i17
-rw-r--r--trunk/Examples/ruby/std_vector/runme.rb36
-rw-r--r--trunk/Examples/ruby/template/Makefile20
-rw-r--r--trunk/Examples/ruby/template/example.h32
-rw-r--r--trunk/Examples/ruby/template/example.i21
-rw-r--r--trunk/Examples/ruby/template/runme.rb25
-rw-r--r--trunk/Examples/ruby/value/Makefile18
-rw-r--r--trunk/Examples/ruby/value/example.c15
-rw-r--r--trunk/Examples/ruby/value/example.h5
-rw-r--r--trunk/Examples/ruby/value/example.i32
-rw-r--r--trunk/Examples/ruby/value/index.html114
-rw-r--r--trunk/Examples/ruby/value/runme.rb32
-rw-r--r--trunk/Examples/ruby/variables/Makefile18
-rw-r--r--trunk/Examples/ruby/variables/example.c91
-rw-r--r--trunk/Examples/ruby/variables/example.h6
-rw-r--r--trunk/Examples/ruby/variables/example.i50
-rw-r--r--trunk/Examples/ruby/variables/index.html94
-rw-r--r--trunk/Examples/ruby/variables/runme.rb77
-rw-r--r--trunk/Examples/s-exp/uffi.lisp389
-rw-r--r--trunk/Examples/tcl/check.list16
-rw-r--r--trunk/Examples/tcl/class/Makefile19
-rw-r--r--trunk/Examples/tcl/class/example.cxx28
-rw-r--r--trunk/Examples/tcl/class/example.dsp152
-rw-r--r--trunk/Examples/tcl/class/example.h39
-rw-r--r--trunk/Examples/tcl/class/example.i11
-rw-r--r--trunk/Examples/tcl/class/index.html274
-rw-r--r--trunk/Examples/tcl/class/runme.tcl50
-rw-r--r--trunk/Examples/tcl/class/runme2.tcl70
-rw-r--r--trunk/Examples/tcl/constants/Makefile19
-rw-r--r--trunk/Examples/tcl/constants/example.i27
-rw-r--r--trunk/Examples/tcl/constants/index.html61
-rw-r--r--trunk/Examples/tcl/constants/runme.tcl26
-rw-r--r--trunk/Examples/tcl/contract/Makefile20
-rw-r--r--trunk/Examples/tcl/contract/example.c23
-rw-r--r--trunk/Examples/tcl/contract/example.dsp148
-rw-r--r--trunk/Examples/tcl/contract/example.i21
-rw-r--r--trunk/Examples/tcl/contract/runme.tcl22
-rw-r--r--trunk/Examples/tcl/enum/Makefile19
-rw-r--r--trunk/Examples/tcl/enum/example.cxx37
-rw-r--r--trunk/Examples/tcl/enum/example.h13
-rw-r--r--trunk/Examples/tcl/enum/example.i11
-rw-r--r--trunk/Examples/tcl/enum/index.html35
-rw-r--r--trunk/Examples/tcl/enum/runme.tcl32
-rw-r--r--trunk/Examples/tcl/funcptr/Makefile19
-rw-r--r--trunk/Examples/tcl/funcptr/example.c19
-rw-r--r--trunk/Examples/tcl/funcptr/example.h9
-rw-r--r--trunk/Examples/tcl/funcptr/example.i16
-rw-r--r--trunk/Examples/tcl/funcptr/index.html90
-rw-r--r--trunk/Examples/tcl/funcptr/runme.tcl21
-rw-r--r--trunk/Examples/tcl/import/Makefile20
-rw-r--r--trunk/Examples/tcl/import/README37
-rw-r--r--trunk/Examples/tcl/import/bar.dsp144
-rw-r--r--trunk/Examples/tcl/import/bar.h22
-rw-r--r--trunk/Examples/tcl/import/bar.i9
-rw-r--r--trunk/Examples/tcl/import/base.dsp144
-rw-r--r--trunk/Examples/tcl/import/base.h18
-rw-r--r--trunk/Examples/tcl/import/base.i6
-rw-r--r--trunk/Examples/tcl/import/example.dsw65
-rw-r--r--trunk/Examples/tcl/import/foo.dsp144
-rw-r--r--trunk/Examples/tcl/import/foo.h21
-rw-r--r--trunk/Examples/tcl/import/foo.i8
-rw-r--r--trunk/Examples/tcl/import/runme.tcl114
-rw-r--r--trunk/Examples/tcl/import/spam.dsp144
-rw-r--r--trunk/Examples/tcl/import/spam.h24
-rw-r--r--trunk/Examples/tcl/import/spam.i9
-rw-r--r--trunk/Examples/tcl/index.html70
-rw-r--r--trunk/Examples/tcl/java/Example.java29
-rw-r--r--trunk/Examples/tcl/java/Makefile26
-rw-r--r--trunk/Examples/tcl/java/example.i8
-rw-r--r--trunk/Examples/tcl/java/runme.tcl15
-rw-r--r--trunk/Examples/tcl/multimap/Makefile19
-rw-r--r--trunk/Examples/tcl/multimap/example.c53
-rw-r--r--trunk/Examples/tcl/multimap/example.dsp148
-rw-r--r--trunk/Examples/tcl/multimap/example.i80
-rw-r--r--trunk/Examples/tcl/multimap/runme.tcl24
-rw-r--r--trunk/Examples/tcl/operator/Makefile19
-rw-r--r--trunk/Examples/tcl/operator/example.h36
-rw-r--r--trunk/Examples/tcl/operator/example.i28
-rw-r--r--trunk/Examples/tcl/operator/runme.tcl30
-rw-r--r--trunk/Examples/tcl/pointer/Makefile19
-rw-r--r--trunk/Examples/tcl/pointer/example.c16
-rw-r--r--trunk/Examples/tcl/pointer/example.i31
-rw-r--r--trunk/Examples/tcl/pointer/index.html171
-rw-r--r--trunk/Examples/tcl/pointer/runme.tcl47
-rw-r--r--trunk/Examples/tcl/reference/Makefile19
-rw-r--r--trunk/Examples/tcl/reference/example.cxx46
-rw-r--r--trunk/Examples/tcl/reference/example.h26
-rw-r--r--trunk/Examples/tcl/reference/example.i46
-rw-r--r--trunk/Examples/tcl/reference/index.html147
-rw-r--r--trunk/Examples/tcl/reference/runme.tcl76
-rw-r--r--trunk/Examples/tcl/simple/Makefile19
-rw-r--r--trunk/Examples/tcl/simple/example.c18
-rw-r--r--trunk/Examples/tcl/simple/example.dsp148
-rw-r--r--trunk/Examples/tcl/simple/example.i7
-rw-r--r--trunk/Examples/tcl/simple/index.html97
-rw-r--r--trunk/Examples/tcl/simple/runme.tcl22
-rw-r--r--trunk/Examples/tcl/std_vector/Makefile20
-rw-r--r--trunk/Examples/tcl/std_vector/example.h25
-rw-r--r--trunk/Examples/tcl/std_vector/example.i17
-rw-r--r--trunk/Examples/tcl/std_vector/runme.tcl40
-rw-r--r--trunk/Examples/tcl/value/Makefile19
-rw-r--r--trunk/Examples/tcl/value/example.c15
-rw-r--r--trunk/Examples/tcl/value/example.h5
-rw-r--r--trunk/Examples/tcl/value/example.i32
-rw-r--r--trunk/Examples/tcl/value/index.html122
-rw-r--r--trunk/Examples/tcl/value/runme.tcl39
-rw-r--r--trunk/Examples/tcl/variables/Makefile19
-rw-r--r--trunk/Examples/tcl/variables/example.c91
-rw-r--r--trunk/Examples/tcl/variables/example.h6
-rw-r--r--trunk/Examples/tcl/variables/example.i51
-rw-r--r--trunk/Examples/tcl/variables/index.html76
-rw-r--r--trunk/Examples/tcl/variables/runme.tcl76
-rw-r--r--trunk/Examples/test-suite/README42
-rw-r--r--trunk/Examples/test-suite/abstract_access.i36
-rw-r--r--trunk/Examples/test-suite/abstract_inherit.i62
-rw-r--r--trunk/Examples/test-suite/abstract_inherit_ok.i22
-rw-r--r--trunk/Examples/test-suite/abstract_signature.i26
-rw-r--r--trunk/Examples/test-suite/abstract_typedef.i56
-rw-r--r--trunk/Examples/test-suite/abstract_typedef2.i60
-rw-r--r--trunk/Examples/test-suite/abstract_virtual.i67
-rw-r--r--trunk/Examples/test-suite/access_change.i51
-rw-r--r--trunk/Examples/test-suite/add_link.i20
-rw-r--r--trunk/Examples/test-suite/aggregate.i37
-rw-r--r--trunk/Examples/test-suite/allegrocl/Makefile.in126
-rw-r--r--trunk/Examples/test-suite/allowexcept.i73
-rw-r--r--trunk/Examples/test-suite/allprotected.i78
-rw-r--r--trunk/Examples/test-suite/anonymous_bitfield.i17
-rw-r--r--trunk/Examples/test-suite/apply_signed_char.i37
-rw-r--r--trunk/Examples/test-suite/apply_strings.i78
-rw-r--r--trunk/Examples/test-suite/argcargvtest.i23
-rw-r--r--trunk/Examples/test-suite/argout.i37
-rw-r--r--trunk/Examples/test-suite/array_member.i74
-rw-r--r--trunk/Examples/test-suite/array_typedef_memberin.i12
-rw-r--r--trunk/Examples/test-suite/arrayref.i14
-rw-r--r--trunk/Examples/test-suite/arrays.i72
-rw-r--r--trunk/Examples/test-suite/arrays_dimensionless.i69
-rw-r--r--trunk/Examples/test-suite/arrays_global.i95
-rw-r--r--trunk/Examples/test-suite/arrays_global_twodim.i61
-rw-r--r--trunk/Examples/test-suite/arrays_scope.i19
-rw-r--r--trunk/Examples/test-suite/bloody_hell.i18
-rw-r--r--trunk/Examples/test-suite/bools.i64
-rw-r--r--trunk/Examples/test-suite/callback.i72
-rw-r--r--trunk/Examples/test-suite/cast_operator.i20
-rw-r--r--trunk/Examples/test-suite/casts.i21
-rw-r--r--trunk/Examples/test-suite/catches.i33
-rw-r--r--trunk/Examples/test-suite/cffi/Makefile.in51
-rw-r--r--trunk/Examples/test-suite/char_constant.i20
-rw-r--r--trunk/Examples/test-suite/char_strings.i195
-rw-r--r--trunk/Examples/test-suite/chicken/Makefile.in99
-rw-r--r--trunk/Examples/test-suite/chicken/README11
-rw-r--r--trunk/Examples/test-suite/chicken/casts_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/char_constant_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/chicken_ext_test_runme.ss5
-rw-r--r--trunk/Examples/test-suite/chicken/class_ignore_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/clientdata_prop_runme_proxy.ss95
-rw-r--r--trunk/Examples/test-suite/chicken/constover_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/contract_runme.ss3
-rw-r--r--trunk/Examples/test-suite/chicken/cpp_basic_runme_proxy.ss64
-rw-r--r--trunk/Examples/test-suite/chicken/cpp_enum_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/cpp_namespace_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/dynamic_cast_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/ext_test_external.cxx22
-rw-r--r--trunk/Examples/test-suite/chicken/global_vars_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/global_vars_runme_proxy.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/import_nomodule_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/imports_runme.ss3
-rw-r--r--trunk/Examples/test-suite/chicken/inherit_missing_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/li_std_string_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/li_std_string_runme_proxy.ss47
-rw-r--r--trunk/Examples/test-suite/chicken/li_typemaps_runme.ss12
-rw-r--r--trunk/Examples/test-suite/chicken/li_typemaps_runme_proxy.ss13
-rw-r--r--trunk/Examples/test-suite/chicken/list_vector_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/member_pointer_runme.ss28
-rw-r--r--trunk/Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/multivalue_runme.ss4
-rw-r--r--trunk/Examples/test-suite/chicken/name_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/newobject1_runme_proxy.ss30
-rw-r--r--trunk/Examples/test-suite/chicken/newobject2_runme.ss29
-rw-r--r--trunk/Examples/test-suite/chicken/newobject2_runme_proxy.ss29
-rw-r--r--trunk/Examples/test-suite/chicken/overload_complicated_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/overload_copy_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/overload_copy_runme_proxy.ss6
-rw-r--r--trunk/Examples/test-suite/chicken/overload_extend_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/overload_extend_runme_proxy.ss14
-rw-r--r--trunk/Examples/test-suite/chicken/overload_simple_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/overload_simple_runme_proxy.ss56
-rw-r--r--trunk/Examples/test-suite/chicken/overload_subtype_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/overload_subtype_runme_proxy.ss12
-rw-r--r--trunk/Examples/test-suite/chicken/pointer_in_out_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/reference_global_vars_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/testsuite.ss12
-rw-r--r--trunk/Examples/test-suite/chicken/throw_exception_runme.ss29
-rw-r--r--trunk/Examples/test-suite/chicken/typedef_inherit_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/typename_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/unions_runme.ss2
-rw-r--r--trunk/Examples/test-suite/chicken/unions_runme_proxy.ss2
-rw-r--r--trunk/Examples/test-suite/chicken_ext_test.i21
-rw-r--r--trunk/Examples/test-suite/class_ignore.i47
-rw-r--r--trunk/Examples/test-suite/class_scope_weird.i50
-rw-r--r--trunk/Examples/test-suite/clientdata_prop.list2
-rw-r--r--trunk/Examples/test-suite/clientdata_prop_a.h12
-rw-r--r--trunk/Examples/test-suite/clientdata_prop_a.i12
-rw-r--r--trunk/Examples/test-suite/clientdata_prop_b.h38
-rw-r--r--trunk/Examples/test-suite/clientdata_prop_b.i20
-rw-r--r--trunk/Examples/test-suite/clisp/Makefile.in51
-rw-r--r--trunk/Examples/test-suite/common.mk591
-rw-r--r--trunk/Examples/test-suite/compactdefaultargs.i38
-rw-r--r--trunk/Examples/test-suite/complextest.i61
-rw-r--r--trunk/Examples/test-suite/const_const.i13
-rw-r--r--trunk/Examples/test-suite/const_const_2.i21
-rw-r--r--trunk/Examples/test-suite/constant_expr.i11
-rw-r--r--trunk/Examples/test-suite/constant_pointers.i157
-rw-r--r--trunk/Examples/test-suite/constants.i16
-rw-r--r--trunk/Examples/test-suite/constover.i38
-rw-r--r--trunk/Examples/test-suite/constructor_copy.i158
-rw-r--r--trunk/Examples/test-suite/constructor_exception.i27
-rw-r--r--trunk/Examples/test-suite/constructor_explicit.i19
-rw-r--r--trunk/Examples/test-suite/constructor_ignore.i36
-rw-r--r--trunk/Examples/test-suite/constructor_rename.i12
-rw-r--r--trunk/Examples/test-suite/constructor_value.i15
-rw-r--r--trunk/Examples/test-suite/contract.i233
-rw-r--r--trunk/Examples/test-suite/conversion.i11
-rw-r--r--trunk/Examples/test-suite/conversion_namespace.i14
-rw-r--r--trunk/Examples/test-suite/conversion_ns_template.i76
-rw-r--r--trunk/Examples/test-suite/cplusplus_throw.i28
-rw-r--r--trunk/Examples/test-suite/cpp_basic.i107
-rw-r--r--trunk/Examples/test-suite/cpp_broken.i12
-rw-r--r--trunk/Examples/test-suite/cpp_enum.i54
-rw-r--r--trunk/Examples/test-suite/cpp_namespace.i105
-rw-r--r--trunk/Examples/test-suite/cpp_nodefault.i40
-rw-r--r--trunk/Examples/test-suite/cpp_static.i26
-rw-r--r--trunk/Examples/test-suite/cpp_typedef.i46
-rw-r--r--trunk/Examples/test-suite/csharp/Makefile.in88
-rw-r--r--trunk/Examples/test-suite/csharp/README42
-rw-r--r--trunk/Examples/test-suite/csharp/aggregate_runme.cs28
-rw-r--r--trunk/Examples/test-suite/csharp/allprotected_runme.cs71
-rw-r--r--trunk/Examples/test-suite/csharp/apply_strings_runme.cs16
-rw-r--r--trunk/Examples/test-suite/csharp/bools_runme.cs29
-rw-r--r--trunk/Examples/test-suite/csharp/catches_runme.cs66
-rw-r--r--trunk/Examples/test-suite/csharp/char_strings_runme.cs155
-rw-r--r--trunk/Examples/test-suite/csharp/constover_runme.cs34
-rw-r--r--trunk/Examples/test-suite/csharp/csharp_attributes_runme.cs266
-rw-r--r--trunk/Examples/test-suite/csharp/csharp_exceptions_runme.cs342
-rw-r--r--trunk/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs70
-rw-r--r--trunk/Examples/test-suite/csharp/csharp_prepost_runme.cs70
-rw-r--r--trunk/Examples/test-suite/csharp/csharp_typemaps_runme.cs113
-rw-r--r--trunk/Examples/test-suite/csharp/default_args_runme.cs143
-rw-r--r--trunk/Examples/test-suite/csharp/default_constructor_runme.cs24
-rw-r--r--trunk/Examples/test-suite/csharp/director_basic_runme.cs74
-rw-r--r--trunk/Examples/test-suite/csharp/director_classes_runme.cs180
-rw-r--r--trunk/Examples/test-suite/csharp/director_classic_runme.cs314
-rw-r--r--trunk/Examples/test-suite/csharp/director_ignore_runme.cs57
-rw-r--r--trunk/Examples/test-suite/csharp/director_primitives_runme.cs127
-rw-r--r--trunk/Examples/test-suite/csharp/director_protected_runme.cs72
-rw-r--r--trunk/Examples/test-suite/csharp/director_string_runme.cs53
-rw-r--r--trunk/Examples/test-suite/csharp/enum_thorough_runme.cs410
-rw-r--r--trunk/Examples/test-suite/csharp/enum_thorough_simple_runme.cs410
-rw-r--r--trunk/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs410
-rw-r--r--trunk/Examples/test-suite/csharp/exception_order_runme.cs48
-rw-r--r--trunk/Examples/test-suite/csharp/imports_runme.cs18
-rw-r--r--trunk/Examples/test-suite/csharp/inherit_target_language_runme.cs24
-rw-r--r--trunk/Examples/test-suite/csharp/intermediary_classname_runme.cs21
-rw-r--r--trunk/Examples/test-suite/csharp/li_attribute_runme.cs78
-rw-r--r--trunk/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs17
-rw-r--r--trunk/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs589
-rw-r--r--trunk/Examples/test-suite/csharp/li_std_combinations_runme.cs31
-rw-r--r--trunk/Examples/test-suite/csharp/li_std_except_runme.cs24
-rw-r--r--trunk/Examples/test-suite/csharp/li_std_map_runme.cs238
-rw-r--r--trunk/Examples/test-suite/csharp/li_std_string_runme.cs100
-rw-r--r--trunk/Examples/test-suite/csharp/li_std_vector_runme.cs638
-rw-r--r--trunk/Examples/test-suite/csharp/li_std_wstring_runme.cs76
-rw-r--r--trunk/Examples/test-suite/csharp/li_typemaps_runme.cs101
-rw-r--r--trunk/Examples/test-suite/csharp/long_long_runme.cs41
-rw-r--r--trunk/Examples/test-suite/csharp/member_pointer_runme.cs47
-rw-r--r--trunk/Examples/test-suite/csharp/nspace_extend_runme.cs39
-rw-r--r--trunk/Examples/test-suite/csharp/nspace_runme.cs76
-rw-r--r--trunk/Examples/test-suite/csharp/operator_overload_runme.cs46
-rw-r--r--trunk/Examples/test-suite/csharp/overload_complicated_runme.cs55
-rw-r--r--trunk/Examples/test-suite/csharp/overload_template_runme.cs152
-rw-r--r--trunk/Examples/test-suite/csharp/pointer_reference_runme.cs18
-rw-r--r--trunk/Examples/test-suite/csharp/preproc_constants_c_runme.cs70
-rw-r--r--trunk/Examples/test-suite/csharp/preproc_constants_runme.cs69
-rw-r--r--trunk/Examples/test-suite/csharp/sizet_runme.cs18
-rw-r--r--trunk/Examples/test-suite/csharp/sneaky1_runme.cs20
-rw-r--r--trunk/Examples/test-suite/csharp/special_variable_macros_runme.cs22
-rw-r--r--trunk/Examples/test-suite/csharp/threads_runme.cs61
-rw-r--r--trunk/Examples/test-suite/csharp/throw_exception_runme.cs24
-rw-r--r--trunk/Examples/test-suite/csharp/typemap_namespace_runme.cs16
-rw-r--r--trunk/Examples/test-suite/csharp/typemap_out_optimal_runme.cs13
-rw-r--r--trunk/Examples/test-suite/csharp/varargs_runme.cs20
-rw-r--r--trunk/Examples/test-suite/csharp/virtual_poly_runme.cs51
-rw-r--r--trunk/Examples/test-suite/csharp_attributes.i62
-rw-r--r--trunk/Examples/test-suite/csharp_exceptions.i241
-rw-r--r--trunk/Examples/test-suite/csharp_features.i24
-rw-r--r--trunk/Examples/test-suite/csharp_lib_arrays.i61
-rw-r--r--trunk/Examples/test-suite/csharp_prepost.i192
-rw-r--r--trunk/Examples/test-suite/csharp_typemaps.i112
-rw-r--r--trunk/Examples/test-suite/default_args.i243
-rw-r--r--trunk/Examples/test-suite/default_constructor.i170
-rw-r--r--trunk/Examples/test-suite/defvalue_constructor.i14
-rw-r--r--trunk/Examples/test-suite/derived_byvalue.i91
-rw-r--r--trunk/Examples/test-suite/derived_nested.i27
-rw-r--r--trunk/Examples/test-suite/destructor_reprotected.i41
-rw-r--r--trunk/Examples/test-suite/director_abstract.i200
-rw-r--r--trunk/Examples/test-suite/director_basic.i144
-rw-r--r--trunk/Examples/test-suite/director_classes.i104
-rw-r--r--trunk/Examples/test-suite/director_classic.i53
-rw-r--r--trunk/Examples/test-suite/director_constructor.i37
-rw-r--r--trunk/Examples/test-suite/director_default.i66
-rw-r--r--trunk/Examples/test-suite/director_detect.i72
-rw-r--r--trunk/Examples/test-suite/director_enum.i86
-rw-r--r--trunk/Examples/test-suite/director_exception.i112
-rw-r--r--trunk/Examples/test-suite/director_extend.i54
-rw-r--r--trunk/Examples/test-suite/director_finalizer.i42
-rw-r--r--trunk/Examples/test-suite/director_frob.i106
-rw-r--r--trunk/Examples/test-suite/director_ignore.i96
-rw-r--r--trunk/Examples/test-suite/director_namespace_clash.i21
-rw-r--r--trunk/Examples/test-suite/director_nested.i86
-rw-r--r--trunk/Examples/test-suite/director_overload.i47
-rw-r--r--trunk/Examples/test-suite/director_primitives.i88
-rw-r--r--trunk/Examples/test-suite/director_profile.i64
-rw-r--r--trunk/Examples/test-suite/director_protected.i148
-rw-r--r--trunk/Examples/test-suite/director_protected_overloaded.i21
-rw-r--r--trunk/Examples/test-suite/director_redefined.i50
-rw-r--r--trunk/Examples/test-suite/director_stl.i80
-rw-r--r--trunk/Examples/test-suite/director_string.i58
-rw-r--r--trunk/Examples/test-suite/director_thread.i102
-rw-r--r--trunk/Examples/test-suite/director_unroll.i40
-rw-r--r--trunk/Examples/test-suite/director_using.i67
-rw-r--r--trunk/Examples/test-suite/director_wombat.i49
-rw-r--r--trunk/Examples/test-suite/director_wstring.i60
-rw-r--r--trunk/Examples/test-suite/disown.i47
-rw-r--r--trunk/Examples/test-suite/dynamic_cast.i76
-rw-r--r--trunk/Examples/test-suite/empty.i1
-rw-r--r--trunk/Examples/test-suite/enum_plus.i12
-rw-r--r--trunk/Examples/test-suite/enum_scope_template.i20
-rw-r--r--trunk/Examples/test-suite/enum_template.i43
-rw-r--r--trunk/Examples/test-suite/enum_thorough.i553
-rw-r--r--trunk/Examples/test-suite/enum_thorough_proper.i7
-rw-r--r--trunk/Examples/test-suite/enum_thorough_simple.i7
-rw-r--r--trunk/Examples/test-suite/enum_thorough_typesafe.i9
-rw-r--r--trunk/Examples/test-suite/enum_thorough_typeunsafe.i7
-rw-r--r--trunk/Examples/test-suite/enum_var.i8
-rw-r--r--trunk/Examples/test-suite/enums.i97
-rw-r--r--trunk/Examples/test-suite/errors/c_bad_name.i4
-rw-r--r--trunk/Examples/test-suite/errors/c_bad_native.i5
-rw-r--r--trunk/Examples/test-suite/errors/c_class.i8
-rw-r--r--trunk/Examples/test-suite/errors/c_default_error.i4
-rw-r--r--trunk/Examples/test-suite/errors/c_deprecated.i8
-rw-r--r--trunk/Examples/test-suite/errors/c_empty_char.i4
-rw-r--r--trunk/Examples/test-suite/errors/c_enum_badvalue.i7
-rw-r--r--trunk/Examples/test-suite/errors/c_extra_rblock.i8
-rw-r--r--trunk/Examples/test-suite/errors/c_extra_rbrace.i7
-rw-r--r--trunk/Examples/test-suite/errors/c_extra_unsigned.i6
-rw-r--r--trunk/Examples/test-suite/errors/c_insert_missing.i3
-rw-r--r--trunk/Examples/test-suite/errors/c_long_short.i6
-rw-r--r--trunk/Examples/test-suite/errors/c_missing_rbrace.i10
-rw-r--r--trunk/Examples/test-suite/errors/c_missing_semi.i4
-rw-r--r--trunk/Examples/test-suite/errors/c_redefine.i20
-rw-r--r--trunk/Examples/test-suite/errors/c_varargs.i3
-rw-r--r--trunk/Examples/test-suite/errors/c_varargs_neg.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_bad_extern.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_extend_redefine.i23
-rw-r--r--trunk/Examples/test-suite/errors/cpp_extend_undefined.i6
-rw-r--r--trunk/Examples/test-suite/errors/cpp_inline_namespace.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_missing_rtemplate.i11
-rw-r--r--trunk/Examples/test-suite/errors/cpp_namespace_alias.i14
-rw-r--r--trunk/Examples/test-suite/errors/cpp_namespace_aliasnot.i4
-rw-r--r--trunk/Examples/test-suite/errors/cpp_namespace_aliasundef.i3
-rw-r--r--trunk/Examples/test-suite/errors/cpp_nested.i13
-rw-r--r--trunk/Examples/test-suite/errors/cpp_no_access.i4
-rw-r--r--trunk/Examples/test-suite/errors/cpp_nobase.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_overload.i15
-rw-r--r--trunk/Examples/test-suite/errors/cpp_private_defvalue.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_private_inherit.i11
-rw-r--r--trunk/Examples/test-suite/errors/cpp_template_argname.i8
-rw-r--r--trunk/Examples/test-suite/errors/cpp_template_nargs.i10
-rw-r--r--trunk/Examples/test-suite/errors/cpp_template_not.i9
-rw-r--r--trunk/Examples/test-suite/errors/cpp_template_partial.i4
-rw-r--r--trunk/Examples/test-suite/errors/cpp_template_repeat.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_template_undef.i7
-rw-r--r--trunk/Examples/test-suite/errors/cpp_using_not.i9
-rw-r--r--trunk/Examples/test-suite/errors/cpp_using_undef.i9
-rwxr-xr-xtrunk/Examples/test-suite/errors/make.sh103
-rw-r--r--trunk/Examples/test-suite/errors/nomodule.i2
-rw-r--r--trunk/Examples/test-suite/errors/pp_badeval.i11
-rw-r--r--trunk/Examples/test-suite/errors/pp_defined.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_macro_args.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_macro_badchar.i5
-rw-r--r--trunk/Examples/test-suite/errors/pp_macro_nargs.i16
-rw-r--r--trunk/Examples/test-suite/errors/pp_macro_redef.i8
-rw-r--r--trunk/Examples/test-suite/errors/pp_macro_rparen.i3
-rw-r--r--trunk/Examples/test-suite/errors/pp_macro_unterminated.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_misplaced_elif.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_misplaced_else.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_missing_enddef.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_missing_endif.i6
-rw-r--r--trunk/Examples/test-suite/errors/pp_missing_file.i3
-rw-r--r--trunk/Examples/test-suite/errors/pp_missing_rblock.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_unterm_char.i7
-rw-r--r--trunk/Examples/test-suite/errors/pp_unterm_comment.i6
-rw-r--r--trunk/Examples/test-suite/errors/pp_unterm_string.i6
-rw-r--r--trunk/Examples/test-suite/errors/swig_apply_nargs.i6
-rw-r--r--trunk/Examples/test-suite/errors/swig_identifier.i6
-rw-r--r--trunk/Examples/test-suite/errors/swig_insert_bad.i5
-rw-r--r--trunk/Examples/test-suite/errors/swig_typemap_copy.i3
-rw-r--r--trunk/Examples/test-suite/errors/swig_typemap_old.i6
-rw-r--r--trunk/Examples/test-suite/evil_diamond.i26
-rw-r--r--trunk/Examples/test-suite/evil_diamond_ns.i27
-rw-r--r--trunk/Examples/test-suite/evil_diamond_prop.i39
-rw-r--r--trunk/Examples/test-suite/exception_order.i111
-rw-r--r--trunk/Examples/test-suite/exception_partial_info.i51
-rw-r--r--trunk/Examples/test-suite/expressions.i10
-rw-r--r--trunk/Examples/test-suite/extend.i53
-rw-r--r--trunk/Examples/test-suite/extend_default.i133
-rw-r--r--trunk/Examples/test-suite/extend_placement.i107
-rw-r--r--trunk/Examples/test-suite/extend_template.i26
-rw-r--r--trunk/Examples/test-suite/extend_template_ns.i32
-rw-r--r--trunk/Examples/test-suite/extend_variable.i103
-rw-r--r--trunk/Examples/test-suite/extern_c.i16
-rw-r--r--trunk/Examples/test-suite/extern_declaration.i31
-rw-r--r--trunk/Examples/test-suite/extern_namespace.i23
-rw-r--r--trunk/Examples/test-suite/extern_throws.i18
-rw-r--r--trunk/Examples/test-suite/features.i181
-rw-r--r--trunk/Examples/test-suite/file_test.i21
-rw-r--r--trunk/Examples/test-suite/fragments.i36
-rw-r--r--trunk/Examples/test-suite/friends.i178
-rw-r--r--trunk/Examples/test-suite/funcptr.i60
-rw-r--r--trunk/Examples/test-suite/function_typedef.i20
-rw-r--r--trunk/Examples/test-suite/fvirtual.i21
-rw-r--r--trunk/Examples/test-suite/global_namespace.i60
-rw-r--r--trunk/Examples/test-suite/global_ns_arg.i15
-rw-r--r--trunk/Examples/test-suite/global_scope_types.i44
-rw-r--r--trunk/Examples/test-suite/global_vars.i31
-rw-r--r--trunk/Examples/test-suite/grouping.i31
-rw-r--r--trunk/Examples/test-suite/guile/Makefile.in56
-rw-r--r--trunk/Examples/test-suite/guile/README4
-rw-r--r--trunk/Examples/test-suite/guile/casts_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/char_constant_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/class_ignore_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/constover_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/contract_runme.scm6
-rw-r--r--trunk/Examples/test-suite/guile/cpp_enum_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/cpp_namespace_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/dynamic_cast_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/import_nomodule_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/imports_runme.scm11
-rw-r--r--trunk/Examples/test-suite/guile/inherit_missing_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/integers_runme.scm11
-rw-r--r--trunk/Examples/test-suite/guile/li_std_string_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/li_typemaps_runme.scm18
-rw-r--r--trunk/Examples/test-suite/guile/list_vector_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/multivalue_runme.scm7
-rw-r--r--trunk/Examples/test-suite/guile/name_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/overload_complicated_runme.scm21
-rw-r--r--trunk/Examples/test-suite/guile/overload_copy_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/overload_extend_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/overload_simple_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/overload_subtype_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/pointer_in_out_runme.scm5
-rw-r--r--trunk/Examples/test-suite/guile/reference_global_vars_runme.scm3
-rw-r--r--trunk/Examples/test-suite/guile/testsuite.scm37
-rw-r--r--trunk/Examples/test-suite/guile/throw_exception_runme.scm45
-rw-r--r--trunk/Examples/test-suite/guile/typedef_inherit_runme.scm2
-rw-r--r--trunk/Examples/test-suite/guile/typename_runme.scm3
-rw-r--r--trunk/Examples/test-suite/guile/unions_runme.scm8
-rw-r--r--trunk/Examples/test-suite/guilescm/Makefile.in49
-rw-r--r--trunk/Examples/test-suite/guilescm/ext_test_external.cxx24
-rw-r--r--trunk/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm19
-rw-r--r--trunk/Examples/test-suite/guilescm_ext_test.i19
-rw-r--r--trunk/Examples/test-suite/iadd.i58
-rw-r--r--trunk/Examples/test-suite/ignore_parameter.i42
-rw-r--r--trunk/Examples/test-suite/ignore_template_constructor.i45
-rw-r--r--trunk/Examples/test-suite/immutable.i20
-rw-r--r--trunk/Examples/test-suite/implicittest.i68
-rw-r--r--trunk/Examples/test-suite/import_nomodule.h2
-rw-r--r--trunk/Examples/test-suite/import_nomodule.i42
-rw-r--r--trunk/Examples/test-suite/imports.list2
-rw-r--r--trunk/Examples/test-suite/imports_a.h21
-rw-r--r--trunk/Examples/test-suite/imports_a.i15
-rw-r--r--trunk/Examples/test-suite/imports_b.h31
-rw-r--r--trunk/Examples/test-suite/imports_b.i47
-rw-r--r--trunk/Examples/test-suite/inctest.h2
-rw-r--r--trunk/Examples/test-suite/inctest.i35
-rw-r--r--trunk/Examples/test-suite/inherit.i19
-rw-r--r--trunk/Examples/test-suite/inherit_missing.i51
-rw-r--r--trunk/Examples/test-suite/inherit_same_name.i16
-rw-r--r--trunk/Examples/test-suite/inherit_target_language.i73
-rw-r--r--trunk/Examples/test-suite/inherit_void_arg.i18
-rw-r--r--trunk/Examples/test-suite/inline_initializer.i12
-rw-r--r--trunk/Examples/test-suite/inout.i48
-rw-r--r--trunk/Examples/test-suite/inplaceadd.i40
-rw-r--r--trunk/Examples/test-suite/input.i41
-rw-r--r--trunk/Examples/test-suite/insert_directive.i38
-rw-r--r--trunk/Examples/test-suite/integers.i20
-rw-r--r--trunk/Examples/test-suite/intermediary_classname.i82
-rw-r--r--trunk/Examples/test-suite/java/Makefile.in92
-rw-r--r--trunk/Examples/test-suite/java/README6
-rw-r--r--trunk/Examples/test-suite/java/aggregate_runme.java39
-rw-r--r--trunk/Examples/test-suite/java/allprotected_runme.java74
-rw-r--r--trunk/Examples/test-suite/java/apply_signed_char_runme.java36
-rw-r--r--trunk/Examples/test-suite/java/apply_strings_runme.java24
-rw-r--r--trunk/Examples/test-suite/java/array_member_runme.java35
-rw-r--r--trunk/Examples/test-suite/java/arrays_global_twodim_runme.java33
-rw-r--r--trunk/Examples/test-suite/java/char_strings_runme.java163
-rw-r--r--trunk/Examples/test-suite/java/cpp_typedef_runme.java34
-rw-r--r--trunk/Examples/test-suite/java/default_args_runme.java150
-rw-r--r--trunk/Examples/test-suite/java/default_constructor_runme.java32
-rw-r--r--trunk/Examples/test-suite/java/director_abstract_runme.java46
-rw-r--r--trunk/Examples/test-suite/java/director_basic_runme.java72
-rw-r--r--trunk/Examples/test-suite/java/director_classes_runme.java207
-rw-r--r--trunk/Examples/test-suite/java/director_classic_runme.java318
-rw-r--r--trunk/Examples/test-suite/java/director_default_runme.java51
-rw-r--r--trunk/Examples/test-suite/java/director_enum_runme.java54
-rw-r--r--trunk/Examples/test-suite/java/director_exception_runme.java34
-rw-r--r--trunk/Examples/test-suite/java/director_frob_runme.java39
-rw-r--r--trunk/Examples/test-suite/java/director_ignore_runme.java40
-rw-r--r--trunk/Examples/test-suite/java/director_primitives_runme.java138
-rw-r--r--trunk/Examples/test-suite/java/director_protected_runme.java85
-rw-r--r--trunk/Examples/test-suite/java/director_string_runme.java56
-rw-r--r--trunk/Examples/test-suite/java/director_thread_runme.java36
-rw-r--r--trunk/Examples/test-suite/java/director_unroll_runme.java34
-rw-r--r--trunk/Examples/test-suite/java/director_wombat_runme.java94
-rw-r--r--trunk/Examples/test-suite/java/dynamic_cast_runme.java29
-rw-r--r--trunk/Examples/test-suite/java/enum_thorough_proper_runme.java421
-rw-r--r--trunk/Examples/test-suite/java/enum_thorough_runme.java421
-rw-r--r--trunk/Examples/test-suite/java/enum_thorough_simple_runme.java421
-rw-r--r--trunk/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java421
-rw-r--r--trunk/Examples/test-suite/java/extend_default_runme.java226
-rw-r--r--trunk/Examples/test-suite/java/extern_declaration_runme.java21
-rw-r--r--trunk/Examples/test-suite/java/global_namespace_runme.java25
-rw-r--r--trunk/Examples/test-suite/java/ignore_parameter_runme.java36
-rw-r--r--trunk/Examples/test-suite/java/imports_runme.java24
-rw-r--r--trunk/Examples/test-suite/java/inctest_runme.java21
-rw-r--r--trunk/Examples/test-suite/java/inherit_target_language_runme.java35
-rw-r--r--trunk/Examples/test-suite/java/intermediary_classname_runme.java24
-rw-r--r--trunk/Examples/test-suite/java/java_constants_runme.java29
-rw-r--r--trunk/Examples/test-suite/java/java_director_runme.java92
-rw-r--r--trunk/Examples/test-suite/java/java_enums_runme.java54
-rw-r--r--trunk/Examples/test-suite/java/java_jnitypes_runme.java57
-rw-r--r--trunk/Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java62
-rw-r--r--trunk/Examples/test-suite/java/java_lib_arrays_runme.java165
-rw-r--r--trunk/Examples/test-suite/java/java_lib_various_runme.java83
-rw-r--r--trunk/Examples/test-suite/java/java_pgcpp_runme.java32
-rw-r--r--trunk/Examples/test-suite/java/java_pragmas_runme.java15
-rw-r--r--trunk/Examples/test-suite/java/java_prepost_runme.java28
-rw-r--r--trunk/Examples/test-suite/java/java_throws_runme.java123
-rw-r--r--trunk/Examples/test-suite/java/java_typemaps_proxy_runme.java81
-rw-r--r--trunk/Examples/test-suite/java/java_typemaps_typewrapper_runme.java45
-rw-r--r--trunk/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java701
-rw-r--r--trunk/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java24
-rw-r--r--trunk/Examples/test-suite/java/li_boost_shared_ptr_runme.java603
-rw-r--r--trunk/Examples/test-suite/java/li_carrays_runme.java88
-rw-r--r--trunk/Examples/test-suite/java/li_std_except_runme.java29
-rw-r--r--trunk/Examples/test-suite/java/li_std_string_runme.java108
-rw-r--r--trunk/Examples/test-suite/java/li_std_vector_runme.java36
-rw-r--r--trunk/Examples/test-suite/java/li_typemaps_runme.java125
-rw-r--r--trunk/Examples/test-suite/java/long_long_runme.java83
-rw-r--r--trunk/Examples/test-suite/java/member_pointer_runme.java58
-rw-r--r--trunk/Examples/test-suite/java/memberin_extend_runme.java26
-rw-r--r--trunk/Examples/test-suite/java/minherit2_runme.java32
-rw-r--r--trunk/Examples/test-suite/java/multiple_inheritance_runme.java32
-rw-r--r--trunk/Examples/test-suite/java/nested_class_runme.java72
-rw-r--r--trunk/Examples/test-suite/java/nested_structs_runme.java37
-rw-r--r--trunk/Examples/test-suite/java/nested_workaround_runme.java31
-rw-r--r--trunk/Examples/test-suite/java/nspace_extend_runme.java44
-rw-r--r--trunk/Examples/test-suite/java/nspace_runme.java80
-rw-r--r--trunk/Examples/test-suite/java/operator_overload_runme.java113
-rw-r--r--trunk/Examples/test-suite/java/overload_complicated_runme.java63
-rw-r--r--trunk/Examples/test-suite/java/overload_template_runme.java160
-rw-r--r--trunk/Examples/test-suite/java/pointer_reference_runme.java23
-rw-r--r--trunk/Examples/test-suite/java/primitive_ref_runme.java64
-rw-r--r--trunk/Examples/test-suite/java/profiletest_runme.java15
-rw-r--r--trunk/Examples/test-suite/java/rename1_runme.java75
-rw-r--r--trunk/Examples/test-suite/java/rename2_runme.java75
-rw-r--r--trunk/Examples/test-suite/java/rename3_runme.java75
-rw-r--r--trunk/Examples/test-suite/java/rename4_runme.java75
-rw-r--r--trunk/Examples/test-suite/java/ret_by_value_runme.java33
-rw-r--r--trunk/Examples/test-suite/java/rname_runme.java38
-rw-r--r--trunk/Examples/test-suite/java/sizet_runme.java24
-rw-r--r--trunk/Examples/test-suite/java/special_variable_macros_runme.java32
-rw-r--r--trunk/Examples/test-suite/java/special_variables_runme.java53
-rw-r--r--trunk/Examples/test-suite/java/template_classes_runme.java25
-rw-r--r--trunk/Examples/test-suite/java/template_default_arg_runme.java156
-rw-r--r--trunk/Examples/test-suite/java/template_default_class_parms_runme.java43
-rw-r--r--trunk/Examples/test-suite/java/template_methods_runme.java44
-rw-r--r--trunk/Examples/test-suite/java/template_nested_runme.java30
-rw-r--r--trunk/Examples/test-suite/java/template_nested_typemaps_runme.java39
-rw-r--r--trunk/Examples/test-suite/java/template_partial_specialization_runme.java59
-rw-r--r--trunk/Examples/test-suite/java/template_partial_specialization_typedef_runme.java59
-rw-r--r--trunk/Examples/test-suite/java/template_template_parameters_runme.java28
-rw-r--r--trunk/Examples/test-suite/java/typemap_namespace_runme.java21
-rw-r--r--trunk/Examples/test-suite/java/typemap_out_optimal_runme.java21
-rw-r--r--trunk/Examples/test-suite/java/unions_runme.java68
-rw-r--r--trunk/Examples/test-suite/java/using_pointers_runme.java32
-rw-r--r--trunk/Examples/test-suite/java/varargs_runme.java35
-rw-r--r--trunk/Examples/test-suite/java/virtual_poly_runme.java61
-rw-r--r--trunk/Examples/test-suite/java/wallkw_runme.java25
-rw-r--r--trunk/Examples/test-suite/java_constants.i35
-rw-r--r--trunk/Examples/test-suite/java_director.i132
-rw-r--r--trunk/Examples/test-suite/java_enums.i66
-rw-r--r--trunk/Examples/test-suite/java_jnitypes.i29
-rw-r--r--trunk/Examples/test-suite/java_lib_arrays.i56
-rw-r--r--trunk/Examples/test-suite/java_lib_arrays_dimensionless.i26
-rw-r--r--trunk/Examples/test-suite/java_lib_various.i51
-rw-r--r--trunk/Examples/test-suite/java_pgcpp.i56
-rw-r--r--trunk/Examples/test-suite/java_pragmas.i50
-rw-r--r--trunk/Examples/test-suite/java_prepost.i91
-rw-r--r--trunk/Examples/test-suite/java_throws.i187
-rw-r--r--trunk/Examples/test-suite/java_typemaps_proxy.i129
-rw-r--r--trunk/Examples/test-suite/java_typemaps_typewrapper.i72
-rw-r--r--trunk/Examples/test-suite/keyword_rename.i32
-rw-r--r--trunk/Examples/test-suite/kind.i34
-rw-r--r--trunk/Examples/test-suite/langobj.i41
-rw-r--r--trunk/Examples/test-suite/lextype.i54
-rw-r--r--trunk/Examples/test-suite/li_attribute.i139
-rw-r--r--trunk/Examples/test-suite/li_boost_intrusive_ptr.i491
-rw-r--r--trunk/Examples/test-suite/li_boost_shared_ptr.i409
-rw-r--r--trunk/Examples/test-suite/li_boost_shared_ptr_bits.i50
-rw-r--r--trunk/Examples/test-suite/li_carrays.i28
-rw-r--r--trunk/Examples/test-suite/li_cdata.i8
-rw-r--r--trunk/Examples/test-suite/li_cdata_carrays.i8
-rw-r--r--trunk/Examples/test-suite/li_cmalloc.i12
-rw-r--r--trunk/Examples/test-suite/li_constraints.i35
-rw-r--r--trunk/Examples/test-suite/li_cpointer.i10
-rw-r--r--trunk/Examples/test-suite/li_cstring.i98
-rw-r--r--trunk/Examples/test-suite/li_cwstring.i98
-rw-r--r--trunk/Examples/test-suite/li_factory.i49
-rw-r--r--trunk/Examples/test-suite/li_implicit.i23
-rw-r--r--trunk/Examples/test-suite/li_math.i7
-rw-r--r--trunk/Examples/test-suite/li_reference.i52
-rw-r--r--trunk/Examples/test-suite/li_std_carray.i8
-rw-r--r--trunk/Examples/test-suite/li_std_combinations.i23
-rw-r--r--trunk/Examples/test-suite/li_std_deque.i47
-rw-r--r--trunk/Examples/test-suite/li_std_except.i39
-rw-r--r--trunk/Examples/test-suite/li_std_functors.i18
-rw-r--r--trunk/Examples/test-suite/li_std_list.i46
-rw-r--r--trunk/Examples/test-suite/li_std_map.i111
-rw-r--r--trunk/Examples/test-suite/li_std_multimap.i25
-rw-r--r--trunk/Examples/test-suite/li_std_pair.i62
-rw-r--r--trunk/Examples/test-suite/li_std_pair_extra.i210
-rw-r--r--trunk/Examples/test-suite/li_std_pair_lang_object.i8
-rw-r--r--trunk/Examples/test-suite/li_std_queue.i7
-rw-r--r--trunk/Examples/test-suite/li_std_set.i34
-rw-r--r--trunk/Examples/test-suite/li_std_stack.i7
-rw-r--r--trunk/Examples/test-suite/li_std_stream.i59
-rw-r--r--trunk/Examples/test-suite/li_std_string.i149
-rw-r--r--trunk/Examples/test-suite/li_std_string_extra.i55
-rw-r--r--trunk/Examples/test-suite/li_std_vector.i109
-rw-r--r--trunk/Examples/test-suite/li_std_vector_extra.i148
-rw-r--r--trunk/Examples/test-suite/li_std_vector_ptr.i30
-rw-r--r--trunk/Examples/test-suite/li_std_vectora.i65
-rw-r--r--trunk/Examples/test-suite/li_std_wstream.i59
-rw-r--r--trunk/Examples/test-suite/li_std_wstring.i89
-rw-r--r--trunk/Examples/test-suite/li_stdint.i67
-rw-r--r--trunk/Examples/test-suite/li_typemaps.i109
-rw-r--r--trunk/Examples/test-suite/li_windows.i97
-rw-r--r--trunk/Examples/test-suite/list_vector.i153
-rw-r--r--trunk/Examples/test-suite/long_long.i40
-rw-r--r--trunk/Examples/test-suite/long_long_apply.i77
-rw-r--r--trunk/Examples/test-suite/lua/Makefile.in64
-rw-r--r--trunk/Examples/test-suite/lua/abstract_access_runme.lua17
-rw-r--r--trunk/Examples/test-suite/lua/char_strings_runme.lua12
-rw-r--r--trunk/Examples/test-suite/lua/cpp_basic_runme.lua64
-rw-r--r--trunk/Examples/test-suite/lua/disown_runme.lua12
-rw-r--r--trunk/Examples/test-suite/lua/dynamic_cast_runme.lua15
-rw-r--r--trunk/Examples/test-suite/lua/enums_runme.lua20
-rw-r--r--trunk/Examples/test-suite/lua/exception_order_runme.lua45
-rw-r--r--trunk/Examples/test-suite/lua/exception_partial_info_runme.lua12
-rw-r--r--trunk/Examples/test-suite/lua/import.lua28
-rw-r--r--trunk/Examples/test-suite/lua/import_nomodule_runme.lua14
-rw-r--r--trunk/Examples/test-suite/lua/imports_runme.lua28
-rw-r--r--trunk/Examples/test-suite/lua/li_carrays_runme.lua29
-rw-r--r--trunk/Examples/test-suite/lua/li_std_except_runme.lua16
-rw-r--r--trunk/Examples/test-suite/lua/li_std_pair_runme.lua34
-rw-r--r--trunk/Examples/test-suite/lua/li_std_string_runme.lua113
-rw-r--r--trunk/Examples/test-suite/lua/li_std_vector_runme.lua66
-rw-r--r--trunk/Examples/test-suite/lua/li_typemaps_runme.lua40
-rw-r--r--trunk/Examples/test-suite/lua/member_pointer_runme.lua43
-rw-r--r--trunk/Examples/test-suite/lua/multi_import_runme.lua16
-rw-r--r--trunk/Examples/test-suite/lua/newobject1_runme.lua16
-rw-r--r--trunk/Examples/test-suite/lua/newobject2_runme.lua16
-rw-r--r--trunk/Examples/test-suite/lua/operator_overload_runme.lua157
-rw-r--r--trunk/Examples/test-suite/lua/overload_simple_runme.lua55
-rw-r--r--trunk/Examples/test-suite/lua/overload_template_fast_runme.lua81
-rw-r--r--trunk/Examples/test-suite/lua/overload_template_runme.lua81
-rw-r--r--trunk/Examples/test-suite/lua/pointer_reference_runme.lua11
-rw-r--r--trunk/Examples/test-suite/lua/primitive_ref_runme.lua32
-rw-r--r--trunk/Examples/test-suite/lua/ret_by_value_runme.lua6
-rw-r--r--trunk/Examples/test-suite/lua/sizet_runme.lua9
-rw-r--r--trunk/Examples/test-suite/lua/smart_pointer_overload_runme.lua14
-rw-r--r--trunk/Examples/test-suite/lua/template_default_arg_runme.lua63
-rw-r--r--trunk/Examples/test-suite/lua/voidtest_runme.lua37
-rw-r--r--trunk/Examples/test-suite/member_pointer.i101
-rw-r--r--trunk/Examples/test-suite/member_template.i28
-rw-r--r--trunk/Examples/test-suite/memberin1.i63
-rw-r--r--trunk/Examples/test-suite/memberin_extend.i33
-rw-r--r--trunk/Examples/test-suite/memberin_extend_c.i38
-rw-r--r--trunk/Examples/test-suite/minherit.i82
-rw-r--r--trunk/Examples/test-suite/minherit2.i94
-rw-r--r--trunk/Examples/test-suite/mixed_types.i164
-rw-r--r--trunk/Examples/test-suite/mod.h34
-rw-r--r--trunk/Examples/test-suite/mod.list2
-rw-r--r--trunk/Examples/test-suite/mod_a.i24
-rw-r--r--trunk/Examples/test-suite/mod_b.i22
-rw-r--r--trunk/Examples/test-suite/multi_import.h17
-rw-r--r--trunk/Examples/test-suite/multi_import.list2
-rw-r--r--trunk/Examples/test-suite/multi_import_a.i15
-rw-r--r--trunk/Examples/test-suite/multi_import_b.i13
-rw-r--r--trunk/Examples/test-suite/multi_import_c.i5
-rw-r--r--trunk/Examples/test-suite/multiple_inheritance.i92
-rw-r--r--trunk/Examples/test-suite/multivalue.i52
-rw-r--r--trunk/Examples/test-suite/mzscheme/Makefile.in48
-rw-r--r--trunk/Examples/test-suite/mzscheme/README4
-rw-r--r--trunk/Examples/test-suite/mzscheme/casts_runme.scm7
-rw-r--r--trunk/Examples/test-suite/mzscheme/char_constant_runme.scm6
-rw-r--r--trunk/Examples/test-suite/mzscheme/imports_runme.scm16
-rw-r--r--trunk/Examples/test-suite/mzscheme/integers_runme.scm9
-rw-r--r--trunk/Examples/test-suite/mzscheme/name_runme.scm10
-rw-r--r--trunk/Examples/test-suite/mzscheme/unions_runme.scm38
-rw-r--r--trunk/Examples/test-suite/name.i28
-rw-r--r--trunk/Examples/test-suite/name_cxx.i31
-rw-r--r--trunk/Examples/test-suite/name_warnings.i71
-rw-r--r--trunk/Examples/test-suite/namespace_class.i303
-rw-r--r--trunk/Examples/test-suite/namespace_enum.i24
-rw-r--r--trunk/Examples/test-suite/namespace_extend.i34
-rw-r--r--trunk/Examples/test-suite/namespace_nested.i101
-rw-r--r--trunk/Examples/test-suite/namespace_spaces.i26
-rw-r--r--trunk/Examples/test-suite/namespace_template.i84
-rw-r--r--trunk/Examples/test-suite/namespace_typedef_class.i18
-rw-r--r--trunk/Examples/test-suite/namespace_typemap.i258
-rw-r--r--trunk/Examples/test-suite/namespace_union.i31
-rw-r--r--trunk/Examples/test-suite/namespace_virtual_method.i41
-rw-r--r--trunk/Examples/test-suite/naturalvar.i40
-rw-r--r--trunk/Examples/test-suite/nested.i54
-rw-r--r--trunk/Examples/test-suite/nested_class.i206
-rw-r--r--trunk/Examples/test-suite/nested_comment.i36
-rw-r--r--trunk/Examples/test-suite/nested_structs.i27
-rw-r--r--trunk/Examples/test-suite/nested_workaround.i38
-rw-r--r--trunk/Examples/test-suite/newobject1.i51
-rw-r--r--trunk/Examples/test-suite/newobject2.i47
-rw-r--r--trunk/Examples/test-suite/nspace.i103
-rw-r--r--trunk/Examples/test-suite/nspace_extend.i50
-rw-r--r--trunk/Examples/test-suite/null_pointer.i10
-rw-r--r--trunk/Examples/test-suite/ocaml/Makefile.in83
-rw-r--r--trunk/Examples/test-suite/ocaml/README2
-rw-r--r--trunk/Examples/test-suite/ocaml/class_ignore_runme.ml7
-rw-r--r--trunk/Examples/test-suite/ocaml/imports_runme.ml10
-rwxr-xr-xtrunk/Examples/test-suite/ocaml/makedebugtop21
-rw-r--r--trunk/Examples/test-suite/ocaml/minherit_runme.ml131
-rw-r--r--trunk/Examples/test-suite/ocaml/name_runme.ml9
-rw-r--r--trunk/Examples/test-suite/ocaml/newobject1_runme.ml26
-rw-r--r--trunk/Examples/test-suite/ocaml/overload_copy_runme.ml5
-rw-r--r--trunk/Examples/test-suite/ocaml/sneaky1_runme.ml9
-rw-r--r--trunk/Examples/test-suite/ocaml/throw_exception_runme.ml28
-rw-r--r--trunk/Examples/test-suite/ocaml/typedef_mptr_runme.ml16
-rw-r--r--trunk/Examples/test-suite/ocaml/typename_runme.ml12
-rw-r--r--trunk/Examples/test-suite/ocaml/unions_runme.ml28
-rw-r--r--trunk/Examples/test-suite/ocaml/using_protected_runme.ml8
-rw-r--r--trunk/Examples/test-suite/ocaml/varargs_runme.ml11
-rw-r--r--trunk/Examples/test-suite/ocaml/voidtest_runme.ml8
-rw-r--r--trunk/Examples/test-suite/octave/Makefile.in90
-rw-r--r--trunk/Examples/test-suite/octave/abstract_access_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/abstract_typedef2_runme.m8
-rw-r--r--trunk/Examples/test-suite/octave/abstract_typedef_runme.m12
-rw-r--r--trunk/Examples/test-suite/octave/abstract_virtual_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/argcargvtest_runme.m29
-rw-r--r--trunk/Examples/test-suite/octave/array_member_runme.m25
-rw-r--r--trunk/Examples/test-suite/octave/arrays_global_runme.m19
-rw-r--r--trunk/Examples/test-suite/octave/callback_runme.m40
-rw-r--r--trunk/Examples/test-suite/octave/class_ignore_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/class_scope_weird_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/compactdefaultargs_runme.m24
-rw-r--r--trunk/Examples/test-suite/octave/complextest_runme.m19
-rw-r--r--trunk/Examples/test-suite/octave/constover_runme.m34
-rw-r--r--trunk/Examples/test-suite/octave/constructor_copy_runme.m44
-rw-r--r--trunk/Examples/test-suite/octave/contract_runme.m135
-rw-r--r--trunk/Examples/test-suite/octave/cpp_enum_runme.m27
-rw-r--r--trunk/Examples/test-suite/octave/cpp_namespace_runme.m55
-rw-r--r--trunk/Examples/test-suite/octave/default_args_runme.m86
-rw-r--r--trunk/Examples/test-suite/octave/default_constructor_runme.m111
-rw-r--r--trunk/Examples/test-suite/octave/director_abstract_runme.m44
-rw-r--r--trunk/Examples/test-suite/octave/director_basic_runme.m110
-rw-r--r--trunk/Examples/test-suite/octave/director_classic_runme.m98
-rw-r--r--trunk/Examples/test-suite/octave/director_default_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/director_detect_runme.m36
-rw-r--r--trunk/Examples/test-suite/octave/director_enum_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/director_extend_runme.m12
-rw-r--r--trunk/Examples/test-suite/octave/director_frob_runme.m9
-rw-r--r--trunk/Examples/test-suite/octave/director_nested_runme.m39
-rw-r--r--trunk/Examples/test-suite/octave/director_stl_runme.m31
-rw-r--r--trunk/Examples/test-suite/octave/director_string_runme.m27
-rw-r--r--trunk/Examples/test-suite/octave/director_unroll_runme.m16
-rw-r--r--trunk/Examples/test-suite/octave/director_wstring_runme.m21
-rw-r--r--trunk/Examples/test-suite/octave/dynamic_cast_runme.m14
-rw-r--r--trunk/Examples/test-suite/octave/empty_runme.m2
-rw-r--r--trunk/Examples/test-suite/octave/enum_template_runme.m13
-rw-r--r--trunk/Examples/test-suite/octave/enums_runme.m23
-rw-r--r--trunk/Examples/test-suite/octave/exception_order_runme.m44
-rw-r--r--trunk/Examples/test-suite/octave/extend_placement_runme.m46
-rw-r--r--trunk/Examples/test-suite/octave/extend_template_ns_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/extend_template_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/extend_variable_runme.m6
-rw-r--r--trunk/Examples/test-suite/octave/file_test_runme.m9
-rw-r--r--trunk/Examples/test-suite/octave/friends_runme.m46
-rw-r--r--trunk/Examples/test-suite/octave/fvirtual_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/global_ns_arg_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/grouping_runme.m15
-rwxr-xr-xtrunk/Examples/test-suite/octave/iadd_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/import_nomodule_runme.m8
-rw-r--r--trunk/Examples/test-suite/octave/imports_runme.m19
-rw-r--r--trunk/Examples/test-suite/octave/inctest_runme.m24
-rw-r--r--trunk/Examples/test-suite/octave/inherit_missing_runme.m22
-rw-r--r--trunk/Examples/test-suite/octave/inout_runme.m27
-rw-r--r--trunk/Examples/test-suite/octave/inplaceadd_runme.m24
-rw-r--r--trunk/Examples/test-suite/octave/input_runme.m22
-rw-r--r--trunk/Examples/test-suite/octave/li_attribute_runme.m85
-rw-r--r--trunk/Examples/test-suite/octave/li_carrays_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/li_cmalloc_runme.m17
-rw-r--r--trunk/Examples/test-suite/octave/li_cpointer_runme.m12
-rw-r--r--trunk/Examples/test-suite/octave/li_cstring_runme.m39
-rw-r--r--trunk/Examples/test-suite/octave/li_cwstring_runme.m38
-rw-r--r--trunk/Examples/test-suite/octave/li_factory_runme.m13
-rw-r--r--trunk/Examples/test-suite/octave/li_implicit_runme.m20
-rw-r--r--trunk/Examples/test-suite/octave/li_std_carray_runme.m52
-rw-r--r--trunk/Examples/test-suite/octave/li_std_pair_extra_runme.m69
-rw-r--r--trunk/Examples/test-suite/octave/li_std_set_runme.m96
-rw-r--r--trunk/Examples/test-suite/octave/li_std_stream_runme.m13
-rw-r--r--trunk/Examples/test-suite/octave/li_std_string_extra_runme.m162
-rw-r--r--trunk/Examples/test-suite/octave/li_std_vector_runme.m11
-rw-r--r--trunk/Examples/test-suite/octave/li_std_wstream_runme.m14
-rw-r--r--trunk/Examples/test-suite/octave/li_std_wstring_runme.m90
-rw-r--r--trunk/Examples/test-suite/octave/member_pointer_runme.m45
-rw-r--r--trunk/Examples/test-suite/octave/minherit_runme.m86
-rw-r--r--trunk/Examples/test-suite/octave/mod_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/multi_import_runme.m24
-rw-r--r--trunk/Examples/test-suite/octave/namespace_class_runme.m39
-rw-r--r--trunk/Examples/test-suite/octave/namespace_typemap_runme.m106
-rw-r--r--trunk/Examples/test-suite/octave/namespace_virtual_method_runme.m4
-rw-r--r--trunk/Examples/test-suite/octave/naturalvar_runme.m14
-rw-r--r--trunk/Examples/test-suite/octave/nondynamic_runme.m36
-rw-r--r--trunk/Examples/test-suite/octave/null_pointer_runme.m3
-rw-r--r--trunk/Examples/test-suite/octave/octave_cell_deref_runme.m8
-rw-r--r--trunk/Examples/test-suite/octave/octave_empty.c1
-rwxr-xr-xtrunk/Examples/test-suite/octave/overload_complicated_runme.m58
-rw-r--r--trunk/Examples/test-suite/octave/overload_copy_runme.m3
-rw-r--r--trunk/Examples/test-suite/octave/overload_extend_runme.m19
-rw-r--r--trunk/Examples/test-suite/octave/overload_extendc_runme.m30
-rw-r--r--trunk/Examples/test-suite/octave/overload_rename_runme.m8
-rw-r--r--trunk/Examples/test-suite/octave/overload_simple_cast_runme.m229
-rw-r--r--trunk/Examples/test-suite/octave/overload_simple_runme.m125
-rw-r--r--trunk/Examples/test-suite/octave/overload_subtype_runme.m13
-rw-r--r--trunk/Examples/test-suite/octave/overload_template_fast_runme.m188
-rw-r--r--trunk/Examples/test-suite/octave/overload_template_runme.m184
-rw-r--r--trunk/Examples/test-suite/octave/preproc_runme.m18
-rw-r--r--trunk/Examples/test-suite/octave/primitive_ref_runme.m53
-rw-r--r--trunk/Examples/test-suite/octave/primitive_types_runme.m402
-rw-r--r--trunk/Examples/test-suite/octave/profiletest_runme.m32
-rw-r--r--trunk/Examples/test-suite/octave/refcount_runme.m15
-rw-r--r--trunk/Examples/test-suite/octave/reference_global_vars_runme.m91
-rw-r--r--trunk/Examples/test-suite/octave/rename_scope_runme.m15
-rw-r--r--trunk/Examples/test-suite/octave/ret_by_value_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/return_const_value_runme.m11
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_extend_runme.m41
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_member_runme.m39
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_multi_runme.m17
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m18
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_not_runme.m42
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_overload_runme.m27
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_rename_runme.m17
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_simple_runme.m15
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m19
-rw-r--r--trunk/Examples/test-suite/octave/smart_pointer_typedef_runme.m15
-rw-r--r--trunk/Examples/test-suite/octave/sneaky1_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/static_const_member_2_runme.m18
-rw-r--r--trunk/Examples/test-suite/octave/std_containers_runme.m135
-rw-r--r--trunk/Examples/test-suite/octave/struct_rename_runme.m4
-rw-r--r--trunk/Examples/test-suite/octave/struct_value_runme.m13
-rw-r--r--trunk/Examples/test-suite/octave/swigobject_runme.m28
-rw-r--r--trunk/Examples/test-suite/octave/template_construct_runme.m1
-rw-r--r--trunk/Examples/test-suite/octave/template_default_arg_runme.m117
-rw-r--r--trunk/Examples/test-suite/octave/template_extend1_runme.m12
-rw-r--r--trunk/Examples/test-suite/octave/template_extend2_runme.m12
-rw-r--r--trunk/Examples/test-suite/octave/template_inherit_runme.m68
-rw-r--r--trunk/Examples/test-suite/octave/template_matrix_runme.m6
-rw-r--r--trunk/Examples/test-suite/octave/template_ns4_runme.m6
-rw-r--r--trunk/Examples/test-suite/octave/template_ns_runme.m21
-rw-r--r--trunk/Examples/test-suite/octave/template_opaque_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/template_ref_type_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/template_rename_runme.m12
-rw-r--r--trunk/Examples/test-suite/octave/template_static_runme.m3
-rw-r--r--trunk/Examples/test-suite/octave/template_tbase_template_runme.m6
-rw-r--r--trunk/Examples/test-suite/octave/template_type_namespace_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/template_typedef_cplx2_runme.m103
-rw-r--r--trunk/Examples/test-suite/octave/template_typedef_cplx3_runme.m34
-rw-r--r--trunk/Examples/test-suite/octave/template_typedef_cplx4_runme.m33
-rw-r--r--trunk/Examples/test-suite/octave/template_typedef_cplx_runme.m92
-rw-r--r--trunk/Examples/test-suite/octave/template_typedef_import_runme.m34
-rw-r--r--trunk/Examples/test-suite/octave/template_typedef_runme.m51
-rw-r--r--trunk/Examples/test-suite/octave/typedef_class_runme.m7
-rw-r--r--trunk/Examples/test-suite/octave/typedef_inherit_runme.m27
-rw-r--r--trunk/Examples/test-suite/octave/typedef_scope_runme.m14
-rw-r--r--trunk/Examples/test-suite/octave/typemap_namespace_runme.m10
-rw-r--r--trunk/Examples/test-suite/octave/typemap_ns_using_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/typename_runme.m13
-rw-r--r--trunk/Examples/test-suite/octave/types_directive_runme.m15
-rw-r--r--trunk/Examples/test-suite/octave/unions_runme.m49
-rw-r--r--trunk/Examples/test-suite/octave/using1_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/using2_runme.m5
-rw-r--r--trunk/Examples/test-suite/octave/using_composition_runme.m43
-rw-r--r--trunk/Examples/test-suite/octave/using_extend_runme.m27
-rw-r--r--trunk/Examples/test-suite/octave/using_inherit_runme.m61
-rw-r--r--trunk/Examples/test-suite/octave/using_private_runme.m16
-rw-r--r--trunk/Examples/test-suite/octave/using_protected_runme.m8
-rw-r--r--trunk/Examples/test-suite/octave/varargs_runme.m23
-rw-r--r--trunk/Examples/test-suite/octave/virtual_derivation_runme.m9
-rw-r--r--trunk/Examples/test-suite/octave/virtual_poly_runme.m44
-rw-r--r--trunk/Examples/test-suite/octave/voidtest_runme.m38
-rw-r--r--trunk/Examples/test-suite/octave/wrapmacro_runme.m8
-rw-r--r--trunk/Examples/test-suite/octave_cell_deref.i15
-rw-r--r--trunk/Examples/test-suite/operator_overload.i360
-rw-r--r--trunk/Examples/test-suite/operator_overload_break.i63
-rw-r--r--trunk/Examples/test-suite/operbool.i12
-rw-r--r--trunk/Examples/test-suite/ordering.i30
-rw-r--r--trunk/Examples/test-suite/overload_complicated.i72
-rw-r--r--trunk/Examples/test-suite/overload_copy.i16
-rw-r--r--trunk/Examples/test-suite/overload_extend.i65
-rw-r--r--trunk/Examples/test-suite/overload_extendc.i21
-rw-r--r--trunk/Examples/test-suite/overload_rename.i28
-rw-r--r--trunk/Examples/test-suite/overload_simple.i205
-rw-r--r--trunk/Examples/test-suite/overload_subtype.i17
-rw-r--r--trunk/Examples/test-suite/overload_template.i210
-rw-r--r--trunk/Examples/test-suite/overload_template_fast.i5
-rw-r--r--trunk/Examples/test-suite/packageoption.h6
-rw-r--r--trunk/Examples/test-suite/packageoption.list3
-rw-r--r--trunk/Examples/test-suite/packageoption_a.i16
-rw-r--r--trunk/Examples/test-suite/packageoption_b.i10
-rw-r--r--trunk/Examples/test-suite/packageoption_c.i13
-rw-r--r--trunk/Examples/test-suite/perl5/Makefile.in61
-rw-r--r--trunk/Examples/test-suite/perl5/README32
-rw-r--r--trunk/Examples/test-suite/perl5/Test/Builder.pm1591
-rw-r--r--trunk/Examples/test-suite/perl5/Test/More.pm1448
-rw-r--r--trunk/Examples/test-suite/perl5/aggregate_runme.pl22
-rw-r--r--trunk/Examples/test-suite/perl5/apply_signed_char_runme.pl26
-rw-r--r--trunk/Examples/test-suite/perl5/apply_strings_runme.pl11
-rw-r--r--trunk/Examples/test-suite/perl5/array_member_runme.pl28
-rw-r--r--trunk/Examples/test-suite/perl5/char_strings_runme.pl15
-rwxr-xr-xtrunk/Examples/test-suite/perl5/class_ignore_runme.pl12
-rwxr-xr-xtrunk/Examples/test-suite/perl5/contract_runme.pl78
-rw-r--r--trunk/Examples/test-suite/perl5/default_args_runme.pl85
-rw-r--r--trunk/Examples/test-suite/perl5/default_constructor_runme.pl51
-rw-r--r--trunk/Examples/test-suite/perl5/disown_runme.pl10
-rw-r--r--trunk/Examples/test-suite/perl5/dynamic_cast_runme.pl13
-rwxr-xr-xtrunk/Examples/test-suite/perl5/enum_template_runme.pl12
-rw-r--r--trunk/Examples/test-suite/perl5/enum_thorough_runme.pl409
-rw-r--r--trunk/Examples/test-suite/perl5/exception_order_runme.pl25
-rw-r--r--trunk/Examples/test-suite/perl5/global_vars_runme.pl11
-rwxr-xr-xtrunk/Examples/test-suite/perl5/grouping_runme.pl17
-rwxr-xr-xtrunk/Examples/test-suite/perl5/ignore_parameter_runme.pl33
-rw-r--r--trunk/Examples/test-suite/perl5/import_nomodule_runme.pl13
-rw-r--r--trunk/Examples/test-suite/perl5/imports_runme.pl5
-rw-r--r--trunk/Examples/test-suite/perl5/inctest_runme.pl12
-rwxr-xr-xtrunk/Examples/test-suite/perl5/inherit_missing_runme.pl20
-rw-r--r--trunk/Examples/test-suite/perl5/inherit_runme.pl9
-rw-r--r--trunk/Examples/test-suite/perl5/li_carrays_runme.pl72
-rw-r--r--trunk/Examples/test-suite/perl5/li_cdata_carrays_runme.pl14
-rw-r--r--trunk/Examples/test-suite/perl5/li_reference_runme.pl36
-rwxr-xr-xtrunk/Examples/test-suite/perl5/li_std_except_runme.pl46
-rw-r--r--trunk/Examples/test-suite/perl5/li_std_string_runme.pl113
-rw-r--r--trunk/Examples/test-suite/perl5/li_typemaps_runme.pl82
-rw-r--r--trunk/Examples/test-suite/perl5/member_pointer_runme.pl51
-rwxr-xr-xtrunk/Examples/test-suite/perl5/minherit_runme.pl72
-rw-r--r--trunk/Examples/test-suite/perl5/multiple_inheritance_runme.pl12
-rwxr-xr-xtrunk/Examples/test-suite/perl5/naturalvar_runme.pl22
-rw-r--r--trunk/Examples/test-suite/perl5/operator_overload_break_runme.pl55
-rw-r--r--trunk/Examples/test-suite/perl5/operator_overload_runme.pl175
-rw-r--r--trunk/Examples/test-suite/perl5/overload_copy_runme.pl5
-rw-r--r--trunk/Examples/test-suite/perl5/overload_simple_runme.pl191
-rw-r--r--trunk/Examples/test-suite/perl5/packageoption_runme.pl24
-rwxr-xr-xtrunk/Examples/test-suite/perl5/preproc_runme.pl14
-rw-r--r--trunk/Examples/test-suite/perl5/primitive_ref_runme.pl18
-rwxr-xr-xtrunk/Examples/test-suite/perl5/primitive_types_runme.pl282
-rw-r--r--trunk/Examples/test-suite/perl5/profiletest_runme.pl8
-rwxr-xr-xtrunk/Examples/test-suite/perl5/reference_global_vars_runme.pl80
-rwxr-xr-xtrunk/Examples/test-suite/perl5/rename_scope_runme.pl15
-rw-r--r--trunk/Examples/test-suite/perl5/ret_by_value_runme.pl12
-rwxr-xr-xtrunk/Examples/test-suite/perl5/return_const_value_runme.pl13
-rwxr-xr-xtrunk/Examples/test-suite/perl5/run-perl-test.pl15
-rwxr-xr-xtrunk/Examples/test-suite/perl5/sizet_runme.pl18
-rwxr-xr-xtrunk/Examples/test-suite/perl5/sneaky1_runme.pl13
-rw-r--r--trunk/Examples/test-suite/perl5/template_default_arg_runme.pl111
-rw-r--r--trunk/Examples/test-suite/perl5/template_ref_type_runme.pl6
-rwxr-xr-xtrunk/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl53
-rw-r--r--trunk/Examples/test-suite/perl5/template_typedef_cplx3_runme.pl41
-rw-r--r--trunk/Examples/test-suite/perl5/template_typedef_cplx_runme.pl49
-rwxr-xr-xtrunk/Examples/test-suite/perl5/typedef_class_runme.pl16
-rw-r--r--trunk/Examples/test-suite/perl5/typemap_namespace_runme.pl9
-rwxr-xr-xtrunk/Examples/test-suite/perl5/typename_runme.pl17
-rw-r--r--trunk/Examples/test-suite/perl5/unions_runme.pl42
-rwxr-xr-xtrunk/Examples/test-suite/perl5/using1_runme.pl10
-rwxr-xr-xtrunk/Examples/test-suite/perl5/using2_runme.pl10
-rw-r--r--trunk/Examples/test-suite/perl5/varargs_runme.pl18
-rw-r--r--trunk/Examples/test-suite/perl5/virtual_poly_runme.pl36
-rw-r--r--trunk/Examples/test-suite/perl5/voidtest_runme.pl20
-rwxr-xr-xtrunk/Examples/test-suite/perl5/wrapmacro_runme.pl14
-rw-r--r--trunk/Examples/test-suite/php/Makefile.in70
-rw-r--r--trunk/Examples/test-suite/php/abstract_inherit_ok_runme.php12
-rw-r--r--trunk/Examples/test-suite/php/abstract_inherit_runme.php14
-rw-r--r--trunk/Examples/test-suite/php/add_link_runme.php22
-rw-r--r--trunk/Examples/test-suite/php/argout_runme.php37
-rw-r--r--trunk/Examples/test-suite/php/arrayptr_runme.php14
-rw-r--r--trunk/Examples/test-suite/php/arrays_global_runme.php19
-rw-r--r--trunk/Examples/test-suite/php/arrays_global_twodim_runme.php22
-rw-r--r--trunk/Examples/test-suite/php/arrays_runme.php17
-rw-r--r--trunk/Examples/test-suite/php/arrays_scope_runme.php16
-rw-r--r--trunk/Examples/test-suite/php/casts_runme.php18
-rw-r--r--trunk/Examples/test-suite/php/char_strings_runme.php43
-rw-r--r--trunk/Examples/test-suite/php/class_ignore_runme.php16
-rw-r--r--trunk/Examples/test-suite/php/conversion_namespace_runme.php13
-rw-r--r--trunk/Examples/test-suite/php/conversion_ns_template_runme.php10
-rw-r--r--trunk/Examples/test-suite/php/conversion_runme.php13
-rw-r--r--trunk/Examples/test-suite/php/cpp_static_runme.php14
-rw-r--r--trunk/Examples/test-suite/php/director_abstract_runme.php62
-rw-r--r--trunk/Examples/test-suite/php/director_basic_runme.php58
-rw-r--r--trunk/Examples/test-suite/php/director_classic_runme.php150
-rw-r--r--trunk/Examples/test-suite/php/director_default_runme.php20
-rw-r--r--trunk/Examples/test-suite/php/director_detect_runme.php55
-rw-r--r--trunk/Examples/test-suite/php/director_enum_runme.php25
-rw-r--r--trunk/Examples/test-suite/php/director_exception_runme.php78
-rw-r--r--trunk/Examples/test-suite/php/director_extend_runme.php24
-rw-r--r--trunk/Examples/test-suite/php/director_finalizer_runme.php61
-rw-r--r--trunk/Examples/test-suite/php/director_frob_runme.php19
-rw-r--r--trunk/Examples/test-suite/php/director_nested_runme.php74
-rw-r--r--trunk/Examples/test-suite/php/director_profile_runme.php53
-rw-r--r--trunk/Examples/test-suite/php/director_protected_runme.php54
-rw-r--r--trunk/Examples/test-suite/php/director_stl_runme.php60
-rw-r--r--trunk/Examples/test-suite/php/director_string_runme.php34
-rw-r--r--trunk/Examples/test-suite/php/director_thread_runme.php29
-rw-r--r--trunk/Examples/test-suite/php/director_unroll_runme.php29
-rw-r--r--trunk/Examples/test-suite/php/enum_scope_template_runme.php15
-rw-r--r--trunk/Examples/test-suite/php/evil_diamond_ns_runme.php18
-rw-r--r--trunk/Examples/test-suite/php/evil_diamond_prop_runme.php38
-rw-r--r--trunk/Examples/test-suite/php/evil_diamond_runme.php16
-rw-r--r--trunk/Examples/test-suite/php/exception_order_runme.php39
-rw-r--r--trunk/Examples/test-suite/php/extend_template_ns_runme.php12
-rw-r--r--trunk/Examples/test-suite/php/extend_template_runme.php12
-rw-r--r--trunk/Examples/test-suite/php/grouping_runme.php22
-rw-r--r--trunk/Examples/test-suite/php/ignore_parameter_runme.php38
-rw-r--r--trunk/Examples/test-suite/php/import_nomodule_runme.php20
-rw-r--r--trunk/Examples/test-suite/php/li_carrays_runme.php22
-rw-r--r--trunk/Examples/test-suite/php/li_factory_runme.php22
-rw-r--r--trunk/Examples/test-suite/php/li_std_string_runme.php31
-rw-r--r--trunk/Examples/test-suite/php/newobject1_runme.php19
-rw-r--r--trunk/Examples/test-suite/php/overload_rename_runme.php19
-rw-r--r--trunk/Examples/test-suite/php/pointer_reference_runme.php15
-rw-r--r--trunk/Examples/test-suite/php/prefix_runme.php18
-rw-r--r--trunk/Examples/test-suite/php/primitive_ref_runme.php34
-rw-r--r--trunk/Examples/test-suite/php/rename_scope_runme.php16
-rw-r--r--trunk/Examples/test-suite/php/skel.php15
-rw-r--r--trunk/Examples/test-suite/php/smart_pointer_rename_runme.php27
-rw-r--r--trunk/Examples/test-suite/php/sym_runme.php22
-rw-r--r--trunk/Examples/test-suite/php/template_arg_typename_runme.php18
-rw-r--r--trunk/Examples/test-suite/php/template_construct_runme.php11
-rw-r--r--trunk/Examples/test-suite/php/tests.php232
-rwxr-xr-xtrunk/Examples/test-suite/php/threads_exception_runme.php43
-rw-r--r--trunk/Examples/test-suite/php/typedef_reference_runme.php13
-rw-r--r--trunk/Examples/test-suite/php/typemap_ns_using_runme.php9
-rw-r--r--trunk/Examples/test-suite/php/using1_runme.php9
-rw-r--r--trunk/Examples/test-suite/php/using2_runme.php9
-rw-r--r--trunk/Examples/test-suite/php/valuewrapper_base_runme.php13
-rw-r--r--trunk/Examples/test-suite/php_namewarn_rename.i29
-rw-r--r--trunk/Examples/test-suite/pike/Makefile.in49
-rw-r--r--trunk/Examples/test-suite/pointer_in_out.i35
-rw-r--r--trunk/Examples/test-suite/pointer_reference.i44
-rw-r--r--trunk/Examples/test-suite/prefix.i14
-rw-r--r--trunk/Examples/test-suite/preproc.i344
-rw-r--r--trunk/Examples/test-suite/preproc_constants.i82
-rw-r--r--trunk/Examples/test-suite/preproc_constants_c.i6
-rw-r--r--trunk/Examples/test-suite/primitive_ref.i47
-rw-r--r--trunk/Examples/test-suite/primitive_types.i617
-rw-r--r--trunk/Examples/test-suite/private_assign.i71
-rw-r--r--trunk/Examples/test-suite/profiletest.i65
-rw-r--r--trunk/Examples/test-suite/protected_rename.i19
-rw-r--r--trunk/Examples/test-suite/pure_virtual.i82
-rw-r--r--trunk/Examples/test-suite/python/Makefile.in170
-rw-r--r--trunk/Examples/test-suite/python/README8
-rw-r--r--trunk/Examples/test-suite/python/abstract_access_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/abstract_typedef2_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/abstract_typedef_runme.py11
-rw-r--r--trunk/Examples/test-suite/python/abstract_virtual_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/argcargvtest_runme.py27
-rw-r--r--trunk/Examples/test-suite/python/array_member_runme.py21
-rw-r--r--trunk/Examples/test-suite/python/arrays_global_runme.py20
-rw-r--r--trunk/Examples/test-suite/python/callback_runme.py31
-rw-r--r--trunk/Examples/test-suite/python/class_ignore_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/class_scope_weird_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/compactdefaultargs_runme.py20
-rw-r--r--trunk/Examples/test-suite/python/complextest_runme.py17
-rw-r--r--trunk/Examples/test-suite/python/constover_runme.py38
-rw-r--r--trunk/Examples/test-suite/python/constructor_copy_runme.py38
-rw-r--r--trunk/Examples/test-suite/python/constructor_rename_runme.py3
-rw-r--r--trunk/Examples/test-suite/python/contract_runme.py143
-rw-r--r--trunk/Examples/test-suite/python/cpp_enum_runme.py23
-rw-r--r--trunk/Examples/test-suite/python/cpp_namespace_runme.py45
-rw-r--r--trunk/Examples/test-suite/python/cpp_static_runme.py7
-rw-r--r--trunk/Examples/test-suite/python/default_args_runme.py64
-rw-r--r--trunk/Examples/test-suite/python/default_constructor_runme.py111
-rw-r--r--trunk/Examples/test-suite/python/director_abstract_runme.py68
-rw-r--r--trunk/Examples/test-suite/python/director_basic_runme.py98
-rw-r--r--trunk/Examples/test-suite/python/director_classic_runme.py142
-rw-r--r--trunk/Examples/test-suite/python/director_default_runme.py9
-rw-r--r--trunk/Examples/test-suite/python/director_detect_runme.py36
-rw-r--r--trunk/Examples/test-suite/python/director_enum_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/director_exception_runme.py77
-rw-r--r--trunk/Examples/test-suite/python/director_extend_runme.py20
-rw-r--r--trunk/Examples/test-suite/python/director_finalizer_runme.py48
-rw-r--r--trunk/Examples/test-suite/python/director_frob_runme.py7
-rw-r--r--trunk/Examples/test-suite/python/director_nested_runme.py63
-rw-r--r--trunk/Examples/test-suite/python/director_profile_runme.py41
-rw-r--r--trunk/Examples/test-suite/python/director_protected_runme.py88
-rw-r--r--trunk/Examples/test-suite/python/director_stl_runme.py39
-rw-r--r--trunk/Examples/test-suite/python/director_string_runme.py29
-rw-r--r--trunk/Examples/test-suite/python/director_thread_runme.py18
-rw-r--r--trunk/Examples/test-suite/python/director_unroll_runme.py19
-rw-r--r--trunk/Examples/test-suite/python/director_wstring_runme.py28
-rw-r--r--trunk/Examples/test-suite/python/disown_runme.py25
-rw-r--r--trunk/Examples/test-suite/python/dynamic_cast_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/empty_runme.py1
-rw-r--r--trunk/Examples/test-suite/python/enum_template_runme.py7
-rw-r--r--trunk/Examples/test-suite/python/enums_runme.py19
-rw-r--r--trunk/Examples/test-suite/python/exception_order_runme.py41
-rw-r--r--trunk/Examples/test-suite/python/extend_placement_runme.py46
-rw-r--r--trunk/Examples/test-suite/python/extend_template_ns_runme.py7
-rw-r--r--trunk/Examples/test-suite/python/extend_template_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/extend_variable_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/extern_c_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/file_test_runme.py10
-rw-r--r--trunk/Examples/test-suite/python/friends_runme.py28
-rw-r--r--trunk/Examples/test-suite/python/fvirtual_runme.py9
-rw-r--r--trunk/Examples/test-suite/python/global_ns_arg_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/grouping_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/hugemod.pl55
-rwxr-xr-xtrunk/Examples/test-suite/python/iadd_runme.py9
-rw-r--r--trunk/Examples/test-suite/python/import_nomodule_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/imports_runme.py17
-rw-r--r--trunk/Examples/test-suite/python/inctest_runme.py32
-rw-r--r--trunk/Examples/test-suite/python/inherit_missing_runme.py19
-rw-r--r--trunk/Examples/test-suite/python/inout_runme.py22
-rw-r--r--trunk/Examples/test-suite/python/inplaceadd_runme.py20
-rw-r--r--trunk/Examples/test-suite/python/input_runme.py20
-rw-r--r--trunk/Examples/test-suite/python/keyword_rename_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/langobj_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/li_attribute_runme.py74
-rw-r--r--trunk/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py31
-rw-r--r--trunk/Examples/test-suite/python/li_boost_shared_ptr_runme.py544
-rw-r--r--trunk/Examples/test-suite/python/li_carrays_runme.py9
-rw-r--r--trunk/Examples/test-suite/python/li_cdata_runme.py10
-rw-r--r--trunk/Examples/test-suite/python/li_cmalloc_runme.py14
-rw-r--r--trunk/Examples/test-suite/python/li_cpointer_runme.py10
-rw-r--r--trunk/Examples/test-suite/python/li_cstring_runme.py32
-rw-r--r--trunk/Examples/test-suite/python/li_cwstring_runme.py29
-rw-r--r--trunk/Examples/test-suite/python/li_factory_runme.py11
-rw-r--r--trunk/Examples/test-suite/python/li_implicit_runme.py17
-rw-r--r--trunk/Examples/test-suite/python/li_std_carray_runme.py41
-rw-r--r--trunk/Examples/test-suite/python/li_std_map_runme.py58
-rw-r--r--trunk/Examples/test-suite/python/li_std_pair_extra_runme.py59
-rw-r--r--trunk/Examples/test-suite/python/li_std_set_runme.py96
-rw-r--r--trunk/Examples/test-suite/python/li_std_stream_runme.py14
-rw-r--r--trunk/Examples/test-suite/python/li_std_string_extra_runme.py132
-rw-r--r--trunk/Examples/test-suite/python/li_std_vector_extra_runme.py176
-rw-r--r--trunk/Examples/test-suite/python/li_std_vector_ptr_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/li_std_wstream_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/li_std_wstring_runme.py76
-rw-r--r--trunk/Examples/test-suite/python/member_pointer_runme.py43
-rw-r--r--trunk/Examples/test-suite/python/memberin_extend_c_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/minherit_runme.py71
-rw-r--r--trunk/Examples/test-suite/python/mod_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/multi_import_runme.py18
-rw-r--r--trunk/Examples/test-suite/python/namespace_class_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/namespace_typemap_runme.py82
-rw-r--r--trunk/Examples/test-suite/python/namespace_virtual_method_runme.py3
-rw-r--r--trunk/Examples/test-suite/python/naturalvar_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/nested_workaround_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/operbool_runme.py4
-rwxr-xr-xtrunk/Examples/test-suite/python/overload_complicated_runme.py47
-rw-r--r--trunk/Examples/test-suite/python/overload_copy_runme.py3
-rw-r--r--trunk/Examples/test-suite/python/overload_extend_runme.py14
-rw-r--r--trunk/Examples/test-suite/python/overload_extendc_runme.py22
-rw-r--r--trunk/Examples/test-suite/python/overload_rename_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/overload_simple_runme.py102
-rw-r--r--trunk/Examples/test-suite/python/overload_subtype_runme.py11
-rw-r--r--trunk/Examples/test-suite/python/overload_template_fast_runme.py145
-rw-r--r--trunk/Examples/test-suite/python/overload_template_runme.py145
-rw-r--r--trunk/Examples/test-suite/python/preproc_runme.py14
-rw-r--r--trunk/Examples/test-suite/python/primitive_ref_runme.py40
-rw-r--r--trunk/Examples/test-suite/python/primitive_types_runme.py353
-rw-r--r--trunk/Examples/test-suite/python/profiletest_runme.py32
-rw-r--r--trunk/Examples/test-suite/python/profiletestc_runme.py54
-rw-r--r--trunk/Examples/test-suite/python/python_abstractbase_runme3.py8
-rw-r--r--trunk/Examples/test-suite/python/python_append_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/python_kwargs_runme.py67
-rw-r--r--trunk/Examples/test-suite/python/python_nondynamic_runme.py39
-rw-r--r--trunk/Examples/test-suite/python/python_overload_simple_cast_runme.py192
-rw-r--r--trunk/Examples/test-suite/python/python_pybuf_runme3.py42
-rw-r--r--trunk/Examples/test-suite/python/pythonswig.supp463
-rw-r--r--trunk/Examples/test-suite/python/refcount_runme.py32
-rw-r--r--trunk/Examples/test-suite/python/reference_global_vars_runme.py74
-rw-r--r--trunk/Examples/test-suite/python/rename_scope_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/rename_strip_encoder_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/ret_by_value_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/return_const_value_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_extend_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_member_runme.py30
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_multi_runme.py15
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py15
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_not_runme.py42
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_overload_runme.py21
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_rename_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_simple_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_templatevariables_runme.py17
-rw-r--r--trunk/Examples/test-suite/python/smart_pointer_typedef_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/sneaky1_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/special_variable_macros_runme.py16
-rw-r--r--trunk/Examples/test-suite/python/static_const_member_2_runme.py16
-rw-r--r--trunk/Examples/test-suite/python/std_containers_runme.py119
-rw-r--r--trunk/Examples/test-suite/python/struct_initialization_runme.py20
-rw-r--r--trunk/Examples/test-suite/python/struct_rename_runme.py3
-rw-r--r--trunk/Examples/test-suite/python/struct_value_runme.py9
-rw-r--r--trunk/Examples/test-suite/python/swigobject_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/template_construct_runme.py1
-rw-r--r--trunk/Examples/test-suite/python/template_default_arg_runme.py98
-rw-r--r--trunk/Examples/test-suite/python/template_extend1_runme.py10
-rw-r--r--trunk/Examples/test-suite/python/template_extend2_runme.py10
-rw-r--r--trunk/Examples/test-suite/python/template_inherit_runme.py53
-rw-r--r--trunk/Examples/test-suite/python/template_matrix_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/template_ns4_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/template_ns_runme.py17
-rw-r--r--trunk/Examples/test-suite/python/template_opaque_runme.py6
-rw-r--r--trunk/Examples/test-suite/python/template_ref_type_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/template_rename_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/template_static_runme.py3
-rw-r--r--trunk/Examples/test-suite/python/template_tbase_template_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/template_type_namespace_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/template_typedef_cplx2_runme.py94
-rw-r--r--trunk/Examples/test-suite/python/template_typedef_cplx3_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/template_typedef_cplx4_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/template_typedef_cplx_runme.py87
-rw-r--r--trunk/Examples/test-suite/python/template_typedef_import_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/template_typedef_runme.py46
-rwxr-xr-xtrunk/Examples/test-suite/python/threads_exception_runme.py36
-rw-r--r--trunk/Examples/test-suite/python/typedef_class_runme.py7
-rw-r--r--trunk/Examples/test-suite/python/typedef_inherit_runme.py23
-rw-r--r--trunk/Examples/test-suite/python/typedef_scope_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/typemap_delete_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/typemap_namespace_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/typemap_ns_using_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/typemap_out_optimal_runme.py5
-rw-r--r--trunk/Examples/test-suite/python/typemap_qualifier_strip_runme.py54
-rw-r--r--trunk/Examples/test-suite/python/typename_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/types_directive_runme.py12
-rw-r--r--trunk/Examples/test-suite/python/unions_runme.py51
-rw-r--r--trunk/Examples/test-suite/python/using1_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/using2_runme.py4
-rw-r--r--trunk/Examples/test-suite/python/using_composition_runme.py34
-rw-r--r--trunk/Examples/test-suite/python/using_extend_runme.py21
-rw-r--r--trunk/Examples/test-suite/python/using_inherit_runme.py49
-rw-r--r--trunk/Examples/test-suite/python/using_private_runme.py13
-rw-r--r--trunk/Examples/test-suite/python/using_protected_runme.py7
-rw-r--r--trunk/Examples/test-suite/python/varargs_runme.py18
-rw-r--r--trunk/Examples/test-suite/python/virtual_derivation_runme.py8
-rw-r--r--trunk/Examples/test-suite/python/virtual_poly_runme.py38
-rw-r--r--trunk/Examples/test-suite/python/voidtest_runme.py29
-rw-r--r--trunk/Examples/test-suite/python/wrapmacro_runme.py7
-rw-r--r--trunk/Examples/test-suite/python_abstractbase.i18
-rw-r--r--trunk/Examples/test-suite/python_append.i32
-rw-r--r--trunk/Examples/test-suite/python_autodoc.i95
-rw-r--r--trunk/Examples/test-suite/python_kwargs.i112
-rw-r--r--trunk/Examples/test-suite/python_nondynamic.i58
-rw-r--r--trunk/Examples/test-suite/python_overload_simple_cast.i4
-rw-r--r--trunk/Examples/test-suite/python_pybuf.i64
-rw-r--r--trunk/Examples/test-suite/r/Makefile.in72
-rw-r--r--trunk/Examples/test-suite/r/arrays_dimensionless_runme.R20
-rw-r--r--trunk/Examples/test-suite/r/funcptr_runme.R7
-rw-r--r--trunk/Examples/test-suite/r/ignore_parameter_runme.R10
-rw-r--r--trunk/Examples/test-suite/r/integers_runme.R20
-rw-r--r--trunk/Examples/test-suite/r/r_copy_struct_runme.R58
-rw-r--r--trunk/Examples/test-suite/r/r_double_delete_runme.R9
-rw-r--r--trunk/Examples/test-suite/r/r_legacy_runme.R30
-rw-r--r--trunk/Examples/test-suite/r/simple_array_runme.R9
-rw-r--r--trunk/Examples/test-suite/r/unions_runme.R12
-rw-r--r--trunk/Examples/test-suite/r/unittest.R9
-rw-r--r--trunk/Examples/test-suite/r_copy_struct.i93
-rw-r--r--trunk/Examples/test-suite/r_double_delete.i14
-rw-r--r--trunk/Examples/test-suite/r_legacy.i98
-rw-r--r--trunk/Examples/test-suite/redefined.i107
-rw-r--r--trunk/Examples/test-suite/refcount.h198
-rw-r--r--trunk/Examples/test-suite/refcount.i104
-rw-r--r--trunk/Examples/test-suite/reference_global_vars.i65
-rw-r--r--trunk/Examples/test-suite/register_par.i6
-rw-r--r--trunk/Examples/test-suite/rename.h44
-rw-r--r--trunk/Examples/test-suite/rename1.i63
-rw-r--r--trunk/Examples/test-suite/rename2.i65
-rw-r--r--trunk/Examples/test-suite/rename3.i75
-rw-r--r--trunk/Examples/test-suite/rename4.i108
-rw-r--r--trunk/Examples/test-suite/rename_camel.i68
-rw-r--r--trunk/Examples/test-suite/rename_scope.i68
-rw-r--r--trunk/Examples/test-suite/rename_strip_encoder.i16
-rw-r--r--trunk/Examples/test-suite/restrict_cplusplus.i7
-rw-r--r--trunk/Examples/test-suite/ret_by_value.i19
-rw-r--r--trunk/Examples/test-suite/return_const_value.i45
-rw-r--r--trunk/Examples/test-suite/return_value_scope.i28
-rw-r--r--trunk/Examples/test-suite/rname.i57
-rw-r--r--trunk/Examples/test-suite/ruby/Makefile.in71
-rw-r--r--trunk/Examples/test-suite/ruby/README4
-rwxr-xr-xtrunk/Examples/test-suite/ruby/abstract_access_runme.rb34
-rw-r--r--trunk/Examples/test-suite/ruby/abstract_inherit_ok_runme.rb48
-rw-r--r--trunk/Examples/test-suite/ruby/abstract_inherit_runme.rb61
-rw-r--r--trunk/Examples/test-suite/ruby/abstract_signature_runme.rb62
-rw-r--r--trunk/Examples/test-suite/ruby/abstract_typedef2_runme.rb17
-rw-r--r--trunk/Examples/test-suite/ruby/abstract_typedef_runme.rb23
-rw-r--r--trunk/Examples/test-suite/ruby/abstract_virtual_runme.rb16
-rwxr-xr-xtrunk/Examples/test-suite/ruby/access_change_runme.rb46
-rwxr-xr-xtrunk/Examples/test-suite/ruby/add_link_runme.rb20
-rw-r--r--trunk/Examples/test-suite/ruby/aggregate_runme.rb37
-rwxr-xr-xtrunk/Examples/test-suite/ruby/anonymous_bitfield_runme.rb35
-rwxr-xr-xtrunk/Examples/test-suite/ruby/apply_signed_char_runme.rb45
-rwxr-xr-xtrunk/Examples/test-suite/ruby/apply_strings_runme.rb61
-rwxr-xr-xtrunk/Examples/test-suite/ruby/argout_runme.rb42
-rw-r--r--trunk/Examples/test-suite/ruby/array_member_runme.rb36
-rw-r--r--trunk/Examples/test-suite/ruby/arrays_global_runme.rb15
-rwxr-xr-xtrunk/Examples/test-suite/ruby/arrays_runme.rb25
-rw-r--r--trunk/Examples/test-suite/ruby/bools_runme.rb82
-rwxr-xr-xtrunk/Examples/test-suite/ruby/cast_operator_runme.rb17
-rwxr-xr-xtrunk/Examples/test-suite/ruby/casts_runme.rb23
-rw-r--r--trunk/Examples/test-suite/ruby/char_constant_runme.rb34
-rwxr-xr-xtrunk/Examples/test-suite/ruby/check_missing_tests.rb53
-rwxr-xr-xtrunk/Examples/test-suite/ruby/class_ignore_runme.rb21
-rwxr-xr-xtrunk/Examples/test-suite/ruby/const_const_runme.rb14
-rwxr-xr-xtrunk/Examples/test-suite/ruby/constover_runme.rb55
-rwxr-xr-xtrunk/Examples/test-suite/ruby/cpp_namespace_runme.rb62
-rwxr-xr-xtrunk/Examples/test-suite/ruby/default_constructor_runme.rb153
-rw-r--r--trunk/Examples/test-suite/ruby/director_abstract_runme.rb42
-rw-r--r--trunk/Examples/test-suite/ruby/director_basic_runme.rb36
-rw-r--r--trunk/Examples/test-suite/ruby/director_constructor_runme.rb37
-rw-r--r--trunk/Examples/test-suite/ruby/director_default_runme.rb30
-rw-r--r--trunk/Examples/test-suite/ruby/director_detect_runme.rb54
-rw-r--r--trunk/Examples/test-suite/ruby/director_exception_runme.rb70
-rw-r--r--trunk/Examples/test-suite/ruby/director_frob_runme.rb17
-rw-r--r--trunk/Examples/test-suite/ruby/director_nested_runme.rb54
-rw-r--r--trunk/Examples/test-suite/ruby/director_protected_runme.rb45
-rw-r--r--trunk/Examples/test-suite/ruby/director_string_runme.rb24
-rw-r--r--trunk/Examples/test-suite/ruby/director_unroll_runme.rb28
-rw-r--r--trunk/Examples/test-suite/ruby/director_wombat_runme.rb60
-rw-r--r--trunk/Examples/test-suite/ruby/disown_runme.rb20
-rwxr-xr-xtrunk/Examples/test-suite/ruby/dynamic_cast_runme.rb24
-rwxr-xr-xtrunk/Examples/test-suite/ruby/enum_thorough_runme.rb19
-rw-r--r--trunk/Examples/test-suite/ruby/enums_runme.rb34
-rw-r--r--trunk/Examples/test-suite/ruby/extend_template_ns_runme.rb23
-rw-r--r--trunk/Examples/test-suite/ruby/extend_template_runme.rb21
-rw-r--r--trunk/Examples/test-suite/ruby/friends_runme.rb19
-rwxr-xr-xtrunk/Examples/test-suite/ruby/function_typedef_runme.rb11
-rw-r--r--trunk/Examples/test-suite/ruby/grouping_runme.rb26
-rw-r--r--trunk/Examples/test-suite/ruby/ignore_parameter_runme.rb34
-rwxr-xr-xtrunk/Examples/test-suite/ruby/imports_runme.rb20
-rw-r--r--trunk/Examples/test-suite/ruby/inherit_missing_runme.rb31
-rwxr-xr-xtrunk/Examples/test-suite/ruby/integers_runme.rb21
-rw-r--r--trunk/Examples/test-suite/ruby/li_carrays_runme.rb36
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_cstring_runme.rb22
-rw-r--r--trunk/Examples/test-suite/ruby/li_factory_runme.rb38
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_math_runme.rb13
-rw-r--r--trunk/Examples/test-suite/ruby/li_std_deque_runme.rb55
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_functors_runme.rb70
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_map_runme.rb51
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_multimap_runme.rb27
-rw-r--r--trunk/Examples/test-suite/ruby/li_std_pair_lang_object_runme.rb19
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_pair_runme.rb57
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_queue_runme.rb32
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_set_runme.rb63
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_speed2_runme.rb67
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_stack_runme.rb30
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_stream_runme.rb22
-rw-r--r--trunk/Examples/test-suite/ruby/li_std_string_runme.rb144
-rwxr-xr-xtrunk/Examples/test-suite/ruby/li_std_vector_runme.rb122
-rw-r--r--trunk/Examples/test-suite/ruby/member_pointer_runme.rb54
-rw-r--r--trunk/Examples/test-suite/ruby/minherit_runme.rb89
-rwxr-xr-xtrunk/Examples/test-suite/ruby/namespace_typemap_runme.rb44
-rw-r--r--trunk/Examples/test-suite/ruby/newobject1_runme.rb33
-rw-r--r--trunk/Examples/test-suite/ruby/newobject2_runme.rb27
-rwxr-xr-xtrunk/Examples/test-suite/ruby/overload_copy_runme.rb17
-rwxr-xr-xtrunk/Examples/test-suite/ruby/overload_extend_runme.rb19
-rwxr-xr-xtrunk/Examples/test-suite/ruby/overload_extendc_runme.rb18
-rwxr-xr-xtrunk/Examples/test-suite/ruby/overload_simple_runme.rb130
-rw-r--r--trunk/Examples/test-suite/ruby/overload_subtype_runme.rb26
-rwxr-xr-xtrunk/Examples/test-suite/ruby/overload_template_runme.rb17
-rwxr-xr-xtrunk/Examples/test-suite/ruby/primitive_ref_runme.rb38
-rw-r--r--trunk/Examples/test-suite/ruby/primitive_types_runme.rb98
-rw-r--r--trunk/Examples/test-suite/ruby/profiletest_runme.rb20
-rw-r--r--trunk/Examples/test-suite/ruby/refcount_runme.rb21
-rw-r--r--trunk/Examples/test-suite/ruby/reference_global_vars_runme.rb104
-rw-r--r--trunk/Examples/test-suite/ruby/rename_scope_runme.rb21
-rw-r--r--trunk/Examples/test-suite/ruby/ruby_keywords_runme.rb159
-rwxr-xr-xtrunk/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb82
-rw-r--r--trunk/Examples/test-suite/ruby/ruby_naming_runme.rb115
-rw-r--r--trunk/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb39
-rw-r--r--trunk/Examples/test-suite/ruby/ruby_track_objects_runme.rb117
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_const_runme.rb24
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_multi_runme.rb26
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb25
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_not_runme.rb55
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_overload_runme.rb27
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_rename_runme.rb23
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_simple_runme.rb24
-rw-r--r--trunk/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb24
-rwxr-xr-xtrunk/Examples/test-suite/ruby/sneaky1_runme.rb17
-rw-r--r--trunk/Examples/test-suite/ruby/static_const_member_2_runme.rb23
-rwxr-xr-xtrunk/Examples/test-suite/ruby/std_containers_runme.rb119
-rwxr-xr-xtrunk/Examples/test-suite/ruby/stl_new_runme.rb117
-rw-r--r--trunk/Examples/test-suite/ruby/struct_value_runme.rb21
-rwxr-xr-xtrunk/Examples/test-suite/ruby/swig_assert.rb141
-rwxr-xr-xtrunk/Examples/test-suite/ruby/swig_gc.rb70
-rw-r--r--trunk/Examples/test-suite/ruby/template_construct_runme.rb13
-rw-r--r--trunk/Examples/test-suite/ruby/template_extend1_runme.rb19
-rw-r--r--trunk/Examples/test-suite/ruby/template_extend2_runme.rb19
-rwxr-xr-xtrunk/Examples/test-suite/ruby/template_inherit_runme.rb51
-rwxr-xr-xtrunk/Examples/test-suite/ruby/template_ns4_runme.rb15
-rwxr-xr-xtrunk/Examples/test-suite/ruby/template_ns_runme.rb26
-rwxr-xr-xtrunk/Examples/test-suite/ruby/template_rename_runme.rb23
-rw-r--r--trunk/Examples/test-suite/ruby/template_tbase_template_runme.rb18
-rw-r--r--trunk/Examples/test-suite/ruby/template_type_namespace_runme.rb18
-rw-r--r--trunk/Examples/test-suite/ruby/template_typedef_cplx2_runme.rb81
-rw-r--r--trunk/Examples/test-suite/ruby/template_typedef_cplx3_runme.rb46
-rw-r--r--trunk/Examples/test-suite/ruby/template_typedef_cplx4_runme.rb46
-rw-r--r--trunk/Examples/test-suite/ruby/template_typedef_cplx_runme.rb77
-rw-r--r--trunk/Examples/test-suite/ruby/throw_exception_runme.rb41
-rwxr-xr-xtrunk/Examples/test-suite/ruby/typedef_inherit_runme.rb38
-rwxr-xr-xtrunk/Examples/test-suite/ruby/typedef_scope_runme.rb24
-rwxr-xr-xtrunk/Examples/test-suite/ruby/typemap_namespace_runme.rb18
-rw-r--r--trunk/Examples/test-suite/ruby/typemap_ns_using_runme.rb15
-rwxr-xr-xtrunk/Examples/test-suite/ruby/typename_runme.rb25
-rw-r--r--trunk/Examples/test-suite/ruby/unions_runme.rb65
-rw-r--r--trunk/Examples/test-suite/ruby/using1_runme.rb15
-rw-r--r--trunk/Examples/test-suite/ruby/using2_runme.rb15
-rw-r--r--trunk/Examples/test-suite/ruby/using_composition_runme.rb56
-rw-r--r--trunk/Examples/test-suite/ruby/using_extend_runme.rb36
-rw-r--r--trunk/Examples/test-suite/ruby/using_inherit_runme.rb74
-rw-r--r--trunk/Examples/test-suite/ruby/using_private_runme.rb30
-rw-r--r--trunk/Examples/test-suite/ruby/using_protected_runme.rb22
-rw-r--r--trunk/Examples/test-suite/ruby/varargs_runme.rb26
-rw-r--r--trunk/Examples/test-suite/ruby/virtual_derivation_runme.rb18
-rw-r--r--trunk/Examples/test-suite/ruby/virtual_poly_runme.rb33
-rw-r--r--trunk/Examples/test-suite/ruby/voidtest_runme.rb24
-rw-r--r--trunk/Examples/test-suite/ruby_keywords.i65
-rw-r--r--trunk/Examples/test-suite/ruby_li_std_speed.i17
-rw-r--r--trunk/Examples/test-suite/ruby_naming.i107
-rw-r--r--trunk/Examples/test-suite/ruby_track_objects.i125
-rw-r--r--trunk/Examples/test-suite/ruby_track_objects_directors.i44
-rw-r--r--trunk/Examples/test-suite/samename.i22
-rw-r--r--trunk/Examples/test-suite/samename_runme.m1
-rw-r--r--trunk/Examples/test-suite/schemerunme/casts.scm8
-rw-r--r--trunk/Examples/test-suite/schemerunme/char_constant.scm4
-rw-r--r--trunk/Examples/test-suite/schemerunme/class_ignore.scm6
-rw-r--r--trunk/Examples/test-suite/schemerunme/constover.scm26
-rw-r--r--trunk/Examples/test-suite/schemerunme/contract.scm14
-rw-r--r--trunk/Examples/test-suite/schemerunme/cpp_enum.scm21
-rw-r--r--trunk/Examples/test-suite/schemerunme/cpp_namespace.scm42
-rw-r--r--trunk/Examples/test-suite/schemerunme/dynamic_cast.scm11
-rw-r--r--trunk/Examples/test-suite/schemerunme/global_vars.scm31
-rw-r--r--trunk/Examples/test-suite/schemerunme/global_vars_proxy.scm31
-rw-r--r--trunk/Examples/test-suite/schemerunme/import_nomodule.scm7
-rw-r--r--trunk/Examples/test-suite/schemerunme/imports.scm13
-rw-r--r--trunk/Examples/test-suite/schemerunme/inherit_missing.scm14
-rw-r--r--trunk/Examples/test-suite/schemerunme/integers.scm28
-rw-r--r--trunk/Examples/test-suite/schemerunme/li_std_string.scm46
-rw-r--r--trunk/Examples/test-suite/schemerunme/li_typemaps.scm45
-rw-r--r--trunk/Examples/test-suite/schemerunme/li_typemaps_proxy.scm45
-rw-r--r--trunk/Examples/test-suite/schemerunme/list_vector.scm26
-rw-r--r--trunk/Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm31
-rw-r--r--trunk/Examples/test-suite/schemerunme/multivalue.scm19
-rw-r--r--trunk/Examples/test-suite/schemerunme/name.scm5
-rw-r--r--trunk/Examples/test-suite/schemerunme/overload_complicated.scm16
-rw-r--r--trunk/Examples/test-suite/schemerunme/overload_copy.scm4
-rw-r--r--trunk/Examples/test-suite/schemerunme/overload_extend.scm12
-rw-r--r--trunk/Examples/test-suite/schemerunme/overload_simple.scm51
-rw-r--r--trunk/Examples/test-suite/schemerunme/overload_subtype.scm7
-rw-r--r--trunk/Examples/test-suite/schemerunme/pointer_in_out.scm13
-rw-r--r--trunk/Examples/test-suite/schemerunme/reference_global_vars.scm59
-rw-r--r--trunk/Examples/test-suite/schemerunme/typedef_inherit.scm19
-rw-r--r--trunk/Examples/test-suite/schemerunme/typename.scm12
-rw-r--r--trunk/Examples/test-suite/schemerunme/unions.scm36
-rw-r--r--trunk/Examples/test-suite/schemerunme/unions_proxy.scm37
-rw-r--r--trunk/Examples/test-suite/shared_ptr_wrapper.h100
-rw-r--r--trunk/Examples/test-suite/simple_array.i42
-rw-r--r--trunk/Examples/test-suite/simutry.i98
-rw-r--r--trunk/Examples/test-suite/sizeof_pointer.i19
-rw-r--r--trunk/Examples/test-suite/sizet.i52
-rw-r--r--trunk/Examples/test-suite/smart_pointer_const.i19
-rw-r--r--trunk/Examples/test-suite/smart_pointer_const2.i20
-rw-r--r--trunk/Examples/test-suite/smart_pointer_extend.i132
-rw-r--r--trunk/Examples/test-suite/smart_pointer_inherit.i76
-rw-r--r--trunk/Examples/test-suite/smart_pointer_member.i56
-rw-r--r--trunk/Examples/test-suite/smart_pointer_multi.i39
-rw-r--r--trunk/Examples/test-suite/smart_pointer_multi_typedef.i45
-rw-r--r--trunk/Examples/test-suite/smart_pointer_namespace.i78
-rw-r--r--trunk/Examples/test-suite/smart_pointer_namespace2.i80
-rw-r--r--trunk/Examples/test-suite/smart_pointer_not.i39
-rw-r--r--trunk/Examples/test-suite/smart_pointer_overload.i28
-rw-r--r--trunk/Examples/test-suite/smart_pointer_protected.i33
-rw-r--r--trunk/Examples/test-suite/smart_pointer_rename.i25
-rw-r--r--trunk/Examples/test-suite/smart_pointer_simple.i19
-rw-r--r--trunk/Examples/test-suite/smart_pointer_static.i24
-rw-r--r--trunk/Examples/test-suite/smart_pointer_templatemethods.i52
-rw-r--r--trunk/Examples/test-suite/smart_pointer_templatevariables.i39
-rw-r--r--trunk/Examples/test-suite/smart_pointer_typedef.i21
-rw-r--r--trunk/Examples/test-suite/sneaky1.i29
-rw-r--r--trunk/Examples/test-suite/special_variable_macros.i179
-rw-r--r--trunk/Examples/test-suite/special_variables.i90
-rw-r--r--trunk/Examples/test-suite/static_array_member.i12
-rw-r--r--trunk/Examples/test-suite/static_const_member.i26
-rw-r--r--trunk/Examples/test-suite/static_const_member_2.i76
-rw-r--r--trunk/Examples/test-suite/std_containers.i207
-rw-r--r--trunk/Examples/test-suite/stl_new.i29
-rw-r--r--trunk/Examples/test-suite/struct_initialization.i31
-rw-r--r--trunk/Examples/test-suite/struct_initialization_cpp.i5
-rw-r--r--trunk/Examples/test-suite/struct_rename.i11
-rw-r--r--trunk/Examples/test-suite/struct_value.i14
-rw-r--r--trunk/Examples/test-suite/swig_examples_lock.h70
-rw-r--r--trunk/Examples/test-suite/swigobject.i25
-rw-r--r--trunk/Examples/test-suite/sym.i24
-rw-r--r--trunk/Examples/test-suite/symbol_clash.i28
-rw-r--r--trunk/Examples/test-suite/tag_no_clash_with_variable.i33
-rw-r--r--trunk/Examples/test-suite/tcl/Makefile.in57
-rw-r--r--trunk/Examples/test-suite/tcl/README4
-rw-r--r--trunk/Examples/test-suite/tcl/bools_runme.tcl73
-rw-r--r--trunk/Examples/test-suite/tcl/clientdata_prop_runme.tcl88
-rw-r--r--trunk/Examples/test-suite/tcl/disown_runme.tcl16
-rw-r--r--trunk/Examples/test-suite/tcl/enum_thorough_runme.tcl9
-rw-r--r--trunk/Examples/test-suite/tcl/import_nomodule_runme.tcl4
-rw-r--r--trunk/Examples/test-suite/tcl/imports_runme.tcl19
-rw-r--r--trunk/Examples/test-suite/tcl/li_std_string_runme.tcl21
-rw-r--r--trunk/Examples/test-suite/tcl/member_pointer_runme.tcl46
-rw-r--r--trunk/Examples/test-suite/tcl/newobject1_runme.tcl28
-rw-r--r--trunk/Examples/test-suite/tcl/newobject2_runme.tcl27
-rw-r--r--trunk/Examples/test-suite/tcl/overload_copy_runme.tcl12
-rw-r--r--trunk/Examples/test-suite/tcl/overload_simple_runme.tcl166
-rw-r--r--trunk/Examples/test-suite/tcl/primitive_ref_runme.tcl19
-rw-r--r--trunk/Examples/test-suite/tcl/primitive_types_runme.tcl33
-rw-r--r--trunk/Examples/test-suite/tcl/profiletest_runme.tcl8
-rw-r--r--trunk/Examples/test-suite/tcl/reference_global_vars_runme.tcl108
-rw-r--r--trunk/Examples/test-suite/tcl/union_parameter_runme.tcl36
-rw-r--r--trunk/Examples/test-suite/tcl/unions_runme.tcl63
-rw-r--r--trunk/Examples/test-suite/template.i52
-rw-r--r--trunk/Examples/test-suite/template_arg_replace.i14
-rw-r--r--trunk/Examples/test-suite/template_arg_scope.i16
-rw-r--r--trunk/Examples/test-suite/template_arg_typename.i26
-rw-r--r--trunk/Examples/test-suite/template_array_numeric.i26
-rw-r--r--trunk/Examples/test-suite/template_base_template.i41
-rw-r--r--trunk/Examples/test-suite/template_classes.i40
-rw-r--r--trunk/Examples/test-suite/template_const_ref.i14
-rw-r--r--trunk/Examples/test-suite/template_construct.i15
-rw-r--r--trunk/Examples/test-suite/template_default.i216
-rw-r--r--trunk/Examples/test-suite/template_default2.i44
-rw-r--r--trunk/Examples/test-suite/template_default_arg.i126
-rw-r--r--trunk/Examples/test-suite/template_default_class_parms.i33
-rw-r--r--trunk/Examples/test-suite/template_default_inherit.i25
-rw-r--r--trunk/Examples/test-suite/template_default_pointer.i12
-rw-r--r--trunk/Examples/test-suite/template_default_qualify.i56
-rw-r--r--trunk/Examples/test-suite/template_default_vw.i24
-rw-r--r--trunk/Examples/test-suite/template_enum.i41
-rw-r--r--trunk/Examples/test-suite/template_enum_ns_inherit.i48
-rw-r--r--trunk/Examples/test-suite/template_enum_typedef.i39
-rw-r--r--trunk/Examples/test-suite/template_explicit.i60
-rw-r--r--trunk/Examples/test-suite/template_expr.i57
-rw-r--r--trunk/Examples/test-suite/template_extend1.i26
-rw-r--r--trunk/Examples/test-suite/template_extend2.i28
-rw-r--r--trunk/Examples/test-suite/template_extend_overload.i44
-rw-r--r--trunk/Examples/test-suite/template_extend_overload_2.i121
-rw-r--r--trunk/Examples/test-suite/template_forward.i71
-rw-r--r--trunk/Examples/test-suite/template_inherit.i41
-rw-r--r--trunk/Examples/test-suite/template_inherit_abstract.i67
-rw-r--r--trunk/Examples/test-suite/template_int_const.i50
-rw-r--r--trunk/Examples/test-suite/template_matrix.i71
-rw-r--r--trunk/Examples/test-suite/template_methods.i100
-rw-r--r--trunk/Examples/test-suite/template_nested.i116
-rw-r--r--trunk/Examples/test-suite/template_nested_typemaps.i47
-rw-r--r--trunk/Examples/test-suite/template_ns.i35
-rw-r--r--trunk/Examples/test-suite/template_ns2.i16
-rw-r--r--trunk/Examples/test-suite/template_ns3.i21
-rw-r--r--trunk/Examples/test-suite/template_ns4.i77
-rw-r--r--trunk/Examples/test-suite/template_ns_enum.i18
-rw-r--r--trunk/Examples/test-suite/template_ns_enum2.i38
-rw-r--r--trunk/Examples/test-suite/template_ns_inherit.i30
-rw-r--r--trunk/Examples/test-suite/template_ns_scope.i38
-rw-r--r--trunk/Examples/test-suite/template_opaque.i41
-rw-r--r--trunk/Examples/test-suite/template_partial_arg.i21
-rw-r--r--trunk/Examples/test-suite/template_partial_specialization.i150
-rw-r--r--trunk/Examples/test-suite/template_partial_specialization_typedef.i130
-rw-r--r--trunk/Examples/test-suite/template_qualifier.i15
-rw-r--r--trunk/Examples/test-suite/template_ref_type.i27
-rw-r--r--trunk/Examples/test-suite/template_rename.i49
-rw-r--r--trunk/Examples/test-suite/template_retvalue.i32
-rw-r--r--trunk/Examples/test-suite/template_specialization.i37
-rw-r--r--trunk/Examples/test-suite/template_specialization_defarg.i95
-rw-r--r--trunk/Examples/test-suite/template_specialization_enum.i63
-rw-r--r--trunk/Examples/test-suite/template_static.i33
-rw-r--r--trunk/Examples/test-suite/template_tbase_template.i49
-rw-r--r--trunk/Examples/test-suite/template_template_parameters.i39
-rw-r--r--trunk/Examples/test-suite/template_type_namespace.i14
-rw-r--r--trunk/Examples/test-suite/template_typedef.i179
-rw-r--r--trunk/Examples/test-suite/template_typedef_cplx.i178
-rw-r--r--trunk/Examples/test-suite/template_typedef_cplx2.h175
-rw-r--r--trunk/Examples/test-suite/template_typedef_cplx2.i7
-rw-r--r--trunk/Examples/test-suite/template_typedef_cplx3.i37
-rw-r--r--trunk/Examples/test-suite/template_typedef_cplx4.i44
-rw-r--r--trunk/Examples/test-suite/template_typedef_cplx5.i22
-rw-r--r--trunk/Examples/test-suite/template_typedef_fnc.i14
-rw-r--r--trunk/Examples/test-suite/template_typedef_funcptr.i53
-rw-r--r--trunk/Examples/test-suite/template_typedef_import.i37
-rw-r--r--trunk/Examples/test-suite/template_typedef_import.list2
-rw-r--r--trunk/Examples/test-suite/template_typedef_ns.i18
-rw-r--r--trunk/Examples/test-suite/template_typedef_ptr.i38
-rw-r--r--trunk/Examples/test-suite/template_typedef_rec.i113
-rw-r--r--trunk/Examples/test-suite/template_typemaps.i62
-rw-r--r--trunk/Examples/test-suite/template_using.i17
-rw-r--r--trunk/Examples/test-suite/template_virtual.i34
-rw-r--r--trunk/Examples/test-suite/template_whitespace.i22
-rw-r--r--trunk/Examples/test-suite/testdir/subdir1/hello.i24
-rw-r--r--trunk/Examples/test-suite/testdir/subdir1/imports.i6
-rw-r--r--trunk/Examples/test-suite/testdir/subdir1/subinc1.i5
-rw-r--r--trunk/Examples/test-suite/testdir/subdir2/hello.i24
-rw-r--r--trunk/Examples/test-suite/testdir/subdir2/imports.i6
-rw-r--r--trunk/Examples/test-suite/testdir/subdir2/subinc2.i3
-rw-r--r--trunk/Examples/test-suite/testdir/test.i4
-rw-r--r--trunk/Examples/test-suite/threads.i23
-rwxr-xr-xtrunk/Examples/test-suite/threads_exception.i54
-rw-r--r--trunk/Examples/test-suite/throw_exception.i79
-rw-r--r--trunk/Examples/test-suite/traits.i6
-rw-r--r--trunk/Examples/test-suite/typedef_array_member.i25
-rw-r--r--trunk/Examples/test-suite/typedef_class.i16
-rw-r--r--trunk/Examples/test-suite/typedef_funcptr.i27
-rw-r--r--trunk/Examples/test-suite/typedef_inherit.i49
-rw-r--r--trunk/Examples/test-suite/typedef_mptr.i34
-rw-r--r--trunk/Examples/test-suite/typedef_reference.i10
-rw-r--r--trunk/Examples/test-suite/typedef_scope.i37
-rw-r--r--trunk/Examples/test-suite/typedef_sizet.i6
-rw-r--r--trunk/Examples/test-suite/typedef_struct.i43
-rw-r--r--trunk/Examples/test-suite/typemap_delete.i16
-rw-r--r--trunk/Examples/test-suite/typemap_global_scope.i215
-rw-r--r--trunk/Examples/test-suite/typemap_namespace.i49
-rw-r--r--trunk/Examples/test-suite/typemap_ns_using.i21
-rw-r--r--trunk/Examples/test-suite/typemap_numinputs.i37
-rw-r--r--trunk/Examples/test-suite/typemap_out_optimal.i38
-rw-r--r--trunk/Examples/test-suite/typemap_qualifier_strip.i76
-rw-r--r--trunk/Examples/test-suite/typemap_self.i47
-rw-r--r--trunk/Examples/test-suite/typemap_subst.i73
-rw-r--r--trunk/Examples/test-suite/typemap_template.i34
-rw-r--r--trunk/Examples/test-suite/typemap_variables.i69
-rw-r--r--trunk/Examples/test-suite/typemap_various.i57
-rw-r--r--trunk/Examples/test-suite/typename.i34
-rw-r--r--trunk/Examples/test-suite/types_directive.i54
-rw-r--r--trunk/Examples/test-suite/uffi/Makefile.in51
-rw-r--r--trunk/Examples/test-suite/union_parameter.i41
-rw-r--r--trunk/Examples/test-suite/union_scope.i14
-rw-r--r--trunk/Examples/test-suite/unions.i42
-rw-r--r--trunk/Examples/test-suite/using1.i22
-rw-r--r--trunk/Examples/test-suite/using2.i27
-rw-r--r--trunk/Examples/test-suite/using_composition.i49
-rw-r--r--trunk/Examples/test-suite/using_extend.i51
-rw-r--r--trunk/Examples/test-suite/using_inherit.i54
-rw-r--r--trunk/Examples/test-suite/using_namespace.i87
-rw-r--r--trunk/Examples/test-suite/using_pointers.i36
-rw-r--r--trunk/Examples/test-suite/using_private.i25
-rw-r--r--trunk/Examples/test-suite/using_protected.i17
-rw-r--r--trunk/Examples/test-suite/valuewrapper.i17
-rw-r--r--trunk/Examples/test-suite/valuewrapper_base.i28
-rw-r--r--trunk/Examples/test-suite/valuewrapper_const.i36
-rw-r--r--trunk/Examples/test-suite/valuewrapper_opaque.i253
-rw-r--r--trunk/Examples/test-suite/varargs.i38
-rw-r--r--trunk/Examples/test-suite/virtual_derivation.i67
-rw-r--r--trunk/Examples/test-suite/virtual_destructor.i22
-rw-r--r--trunk/Examples/test-suite/virtual_poly.i204
-rw-r--r--trunk/Examples/test-suite/voidtest.i23
-rw-r--r--trunk/Examples/test-suite/wallkw.i16
-rw-r--r--trunk/Examples/test-suite/wrapmacro.i62
-rw-r--r--trunk/Examples/xml/Makefile.in54
-rw-r--r--trunk/Examples/xml/error.expected-xml24
-rw-r--r--trunk/Examples/xml/error.i2
-rw-r--r--trunk/Examples/xml/example.expected-xml23
-rw-r--r--trunk/Examples/xml/example.h3
-rw-r--r--trunk/Examples/xml/example.i8
-rw-r--r--trunk/Examples/xml/example_apply.expected-xml1486
-rw-r--r--trunk/Examples/xml/example_apply.i23
-rw-r--r--trunk/Examples/xml/example_const.expected-xml51
-rw-r--r--trunk/Examples/xml/example_const.i26
-rw-r--r--trunk/Examples/xml/example_gif.expected-xml2338
-rw-r--r--trunk/Examples/xml/example_inl.expected-xml104
-rw-r--r--trunk/Examples/xml/example_inl.h5
-rw-r--r--trunk/Examples/xml/example_inl.i30
-rw-r--r--trunk/Examples/xml/example_p5.expected-xml24
-rw-r--r--trunk/Examples/xml/example_p5.i11
-rw-r--r--trunk/Examples/xml/example_ro.expected-xml23
-rw-r--r--trunk/Examples/xml/example_ro.i6
-rw-r--r--trunk/Examples/xml/example_title_add.expected-xml119
-rw-r--r--trunk/Examples/xml/example_title_add.i47
-rw-r--r--trunk/Examples/xml/example_xml.expected-xml1624
-rw-r--r--trunk/Examples/xml/example_xml.h39
-rw-r--r--trunk/Examples/xml/example_xml.i69
-rw-r--r--trunk/Examples/xml/gnarly.expected-xml206
-rw-r--r--trunk/Examples/xml/gnarly.i63
2655 files changed, 128953 insertions, 0 deletions
diff --git a/trunk/Examples/Makefile.in b/trunk/Examples/Makefile.in
new file mode 100644
index 000000000..9dee0347f
--- /dev/null
+++ b/trunk/Examples/Makefile.in
@@ -0,0 +1,1143 @@
+# ------------------------------------------------------------
+# SWIG Examples Makefile
+#
+# This file is used by the examples to build modules. Assuming
+# you ran configure, this file will probably work. However,
+# it's not perfect so you might need to do some hand tweaking.
+#
+# Other notes:
+#
+# 1. Take a look at the prefixes below. Since SWIG works with
+# multiple target languages, you may need to find out where
+# certain packages have been installed. Set the prefixes
+# accordingly.
+#
+# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE,
+# INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a
+# $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \
+# INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \
+# INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method
+#
+# 'method' describes what is being built.
+#---------------------------------------------------------------
+
+TARGET =
+CC = @CC@
+CXX = @CXX@
+CFLAGS = @PLATFLAGS@
+prefix = @prefix@
+exec_prefix= @exec_prefix@
+SRCS =
+INCLUDES =
+LIBS =
+INTERFACE =
+INTERFACEDIR =
+INTERFACEPATH = $(INTERFACEDIR)$(INTERFACE)
+SWIGOPT =
+SWIG = swig
+
+LIBM = @LIBM@
+LIBC = @LIBC@
+LIBCRYPT = @LIBCRYPT@
+SYSLIBS = $(LIBM) $(LIBC) $(LIBCRYPT)
+LIBPREFIX =
+
+# RUNTOOL is for use with runtime tools, eg set it to valgrind
+RUNTOOL =
+# COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing
+COMPILETOOL=
+
+# X11 options
+
+XLIB = @XLIBSW@
+XINCLUDE = @XINCLUDES@
+
+IWRAP = $(INTERFACE:.i=_wrap.i)
+ISRCS = $(IWRAP:.i=.c)
+ICXXSRCS = $(IWRAP:.i=.cxx)
+IOBJS = $(IWRAP:.i=.@OBJEXT@)
+
+##################################################################
+# Dynamic loading for C++
+# If you are going to be building dynamic loadable modules in C++,
+# you may need to edit this line appropriately.
+#
+# This line works for g++, but I'm not sure what it might be
+# for other C++ compilers
+##################################################################
+
+CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
+ -L/usr/local/lib -lg++ -lstdc++ -lgcc
+
+# Solaris workshop 5.0
+# CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
+
+# Symbols used for using shared libraries
+SO= @SO@
+LDSHARED= @LDSHARED@
+CCSHARED= @CCSHARED@
+CXXSHARED= @CXXSHARED@
+
+# This is used for building shared libraries with a number of C++
+# compilers. If it doesn't work, comment it out.
+@TRYLINKINGWITHCXX@
+
+OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@)
+
+distclean:
+ rm -f Makefile
+ rm -f guile/Makefile
+ rm -f xml/Makefile
+
+##################################################################
+##### Tcl/Tk ######
+##################################################################
+
+# Set these to your local copy of Tcl/Tk.
+
+TCL_INCLUDE = @TCLINCLUDE@
+TCL_LIB = @TCLLIB@
+TCL_OPTS = @LIBS@
+TK_OPTS = -ltk -ltcl @LIBS@
+
+# Extra Tcl specific dynamic linking options
+TCL_DLNK = @TCLDYNAMICLINKING@
+TCL_SO = @TCL_SO@
+TCLLDSHARED = @TCLLDSHARED@
+TCLCXXSHARED = @TCLCXXSHARED@
+
+# -----------------------------------------------------------
+# Build a new version of the tclsh shell
+# -----------------------------------------------------------
+
+
+tclsh: $(SRCS)
+ $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \
+ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
+
+tclsh_cpp: $(SRCS)
+ $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
+ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
+
+# -----------------------------------------------------------
+# Build a new copy of wish
+# -----------------------------------------------------------
+
+wish: $(SRCS)
+ $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \
+ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET)
+
+
+wish_cpp: $(SRCS)
+ $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
+ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET)
+
+# -----------------------------------------------------------
+# Build a Tcl dynamic loadable module (you might need to tweak this)
+# -----------------------------------------------------------
+
+tcl: $(SRCS)
+ $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
+ $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
+
+# -----------------------------------------------------------
+# Build a Tcl7.5 dynamic loadable module for C++
+# -----------------------------------------------------------
+
+tcl_cpp: $(SRCS)
+ $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
+ $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
+
+# -----------------------------------------------------------------
+# Cleaning the Tcl examples
+# -----------------------------------------------------------------
+
+tcl_clean:
+ rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### PERL 5 ######
+##################################################################
+
+# You need to set this variable to the Perl5 directory containing the
+# files "perl.h", "EXTERN.h" and "XSUB.h". With Perl5.003, it's
+# usually something like /usr/local/lib/perl5/arch-osname/5.003/CORE.
+
+PERL5_INCLUDE= @PERL5EXT@
+
+# Extra Perl specific dynamic linking options
+PERL5_DLNK = @PERL5DYNAMICLINKING@
+PERL5_CCFLAGS = @PERL5CCFLAGS@
+
+# ----------------------------------------------------------------
+# Build a Perl5 dynamically loadable module (C)
+# ----------------------------------------------------------------
+
+perl5: $(SRCS)
+ $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a Perl5 dynamically loadable module (C++)
+# ----------------------------------------------------------------
+
+perl5_cpp: $(SRCS)
+ $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a module from existing XS C source code. (ie. from xsubpp).
+# ----------------------------------------------------------------
+perl5_xs: $(SRCS)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(LIBS) -o $(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a statically linked Perl5 executable
+# ----------------------------------------------------------------
+
+PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS)
+
+perl5_static: $(SRCS)
+ $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+
+perl5_static_cpp: $(SRCS)
+ $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+
+# -----------------------------------------------------------------
+# Cleaning the Perl5 examples
+# -----------------------------------------------------------------
+
+perl5_clean:
+ rm -f *_wrap* *~ .~* myperl@EXEEXT@ *.pm
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### PYTHON ######
+##################################################################
+
+# Make sure these locate your Python installation
+ifeq (,$(PY3))
+ PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@
+ PYTHON_LIB = @PYLIB@
+ PYTHON = @PYTHON@
+else
+ PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@
+ PYTHON_LIB = @PY3LIB@
+ PYTHON = @PYTHON3@
+endif
+
+# Extra Python specific linking options
+ifeq (,$(PY3))
+ PYTHON_DLNK = @PYTHONDYNAMICLINKING@
+ PYTHON_LINK = @PYLINK@
+else
+ PYTHON_DLNK = @PYTHON3DYNAMICLINKING@
+ PYTHON_LINK = @PY3LINK@
+endif
+PYTHON_SO = @PYTHON_SO@
+
+# SWIG option for Python
+ifeq (,$(PY3))
+ SWIGPYTHON = $(SWIG) -python
+else
+ SWIGPYTHON = $(SWIG) -python -py3
+endif
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# ----------------------------------------------------------------
+
+python: $(SRCS)
+ $(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
+
+# -----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# -----------------------------------------------------------------
+
+python_cpp: $(SRCS)
+ $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
+
+# -----------------------------------------------------------------
+# Build statically linked Python interpreter
+#
+# These should only be used in conjunction with the %include embed.i
+# library file
+# -----------------------------------------------------------------
+
+#TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11
+TKINTER =
+PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
+
+python_static: $(SRCS)
+ $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
+ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
+
+python_static_cpp: $(SRCS)
+ $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
+
+# -----------------------------------------------------------------
+# Running a Python example
+# -----------------------------------------------------------------
+
+ifeq (,$(PY3))
+ PYSCRIPT = runme.py
+else
+ PYSCRIPT = runme3.py
+endif
+
+PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
+
+python_run: $(PYSCRIPT)
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null
+
+runme3.py: runme.py
+ cp $< $@
+ $(PY2TO3) -w $@ >/dev/null 2>&1
+
+# -----------------------------------------------------------------
+# Cleaning the python examples
+# -----------------------------------------------------------------
+
+python_clean:
+ rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@
+ if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi
+
+
+##################################################################
+##### OCTAVE ######
+##################################################################
+
+# Make sure these locate your Octave installation
+OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@
+OCTAVE_LIB =
+
+# Extra Octave specific dynamic linking options
+OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@
+OCTAVE_SO = @OCTAVE_SO@
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# Note: Octave requires C++ compiler when compiling C wrappers
+# ----------------------------------------------------------------
+
+octave: $(SRCS)
+ $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
+ $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CSRCS) $(INCLUDES)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
+
+# -----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# -----------------------------------------------------------------
+
+octave_cpp: $(SRCS)
+ $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
+ $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
+
+# -----------------------------------------------------------------
+# Cleaning the octave examples
+# -----------------------------------------------------------------
+
+octave_clean:
+ rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@ *@OCTAVE_SO@
+
+##################################################################
+##### GUILE ######
+##################################################################
+
+# Make sure these locate your Guile installation
+GUILE_INCLUDE = @GUILEINCLUDE@
+GUILE_LIB = @GUILELIB@
+GUILE_SO = @GUILE_SO@
+GUILE_LIBPREFIX = lib
+
+#------------------------------------------------------------------
+# Build a dynamically loaded module with passive linkage and the scm interface
+#------------------------------------------------------------------
+guile: $(SRCS)
+ $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+
+guile_cpp: $(SRCS)
+ $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+
+guile_externalhdr:
+ $(SWIG) -guile -external-runtime $(TARGET)
+
+#------------------------------------------------------------------
+# Build a dynamically loaded module with passive linkage and the gh interface
+#------------------------------------------------------------------
+guile_gh: $(SRCS)
+ $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+
+guile_gh_cpp: $(SRCS)
+ $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+
+# -----------------------------------------------------------------
+# Build a dynamically loadable module with passive linkage
+# -----------------------------------------------------------------
+
+guile_passive: $(SRCS)
+ $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+
+guile_passive_cpp: $(SRCS)
+ $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+
+# -----------------------------------------------------------------
+# Build statically linked Guile interpreter
+# -----------------------------------------------------------------
+
+GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS)
+
+guile_static: $(SRCS)
+ $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \
+ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
+ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
+
+guile_static_cpp: $(SRCS)
+ $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
+ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
+
+guile_simple: $(SRCS)
+ $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \
+ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
+
+guile_simple_cpp: $(SRCS)
+ $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
+
+# -----------------------------------------------------------------
+# Cleaning the Guile examples
+# -----------------------------------------------------------------
+
+guile_clean:
+ rm -f *_wrap* *~ .~* my-guile@EXEEXT@ $(TARGET)@EXEEXT@
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@GUILE_SO@
+
+##################################################################
+##### JAVA ######
+##################################################################
+
+# You need to set this variable to the java directories containing the
+# files "jni.h" and "md.h"
+# usually something like /usr/java/include and /usr/java/include/<arch-osname>.
+JAVA_INCLUDE= @JAVAINC@
+
+# Extra Java specific dynamic linking options
+JAVA_DLNK = @JAVADYNAMICLINKING@
+JAVA_LIBPREFIX = @JAVALIBRARYPREFIX@
+JAVASO =@JAVASO@
+JAVALDSHARED = @JAVALDSHARED@
+JAVACXXSHARED = @JAVACXXSHARED@
+JAVACFLAGS = @JAVACFLAGS@
+
+# ----------------------------------------------------------------
+# Build a java dynamically loadable module (C)
+# ----------------------------------------------------------------
+
+java: $(SRCS)
+ $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
+ $(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
+
+# ----------------------------------------------------------------
+# Build a java dynamically loadable module (C++)
+# ----------------------------------------------------------------
+
+java_cpp: $(SRCS)
+ $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
+ $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
+
+# -----------------------------------------------------------------
+# Cleaning the java examples
+# -----------------------------------------------------------------
+
+java_clean:
+ rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java`
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@JAVASO@
+
+##################################################################
+##### MODULA3 ######
+##################################################################
+
+MODULA3_INCLUDE= @MODULA3INC@
+
+# ----------------------------------------------------------------
+# Build a modula3 dynamically loadable module (C)
+# ----------------------------------------------------------------
+
+modula3: $(SRCS)
+ $(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \
+# $(OBJS) $(IOBJS) $(LIBS)
+
+modula3_cpp: $(SRCS)
+ $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH)
+
+# -----------------------------------------------------------------
+# Cleaning the modula3 examples
+# -----------------------------------------------------------------
+
+modula3_clean:
+ rm -f *_wrap* *.i3 *.m3
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### MZSCHEME ######
+##################################################################
+
+MZC = @MZC@
+MZDYNOBJ = @MZDYNOBJ@
+MZSCHEME_SO = @MZSCHEME_SO@
+
+# ----------------------------------------------------------------
+# Build a C/C++ dynamically loadable module
+# ----------------------------------------------------------------
+
+mzscheme: $(SRCS)
+ $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH)
+ $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS)
+ $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
+
+mzscheme_cpp: $(SRCS)
+ $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
+
+# -----------------------------------------------------------------
+# Cleaning the mzscheme examples
+# -----------------------------------------------------------------
+
+mzscheme_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### Ocaml #####
+##################################################################
+
+OCC=@OCAMLC@
+OCAMLDLGEN=@OCAMLDLGEN@
+OCAMLFIND=@OCAMLFIND@
+OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
+NOLINK ?= false
+OCAMLPP= -pp "camlp4o ./swigp4.cmo"
+OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where`
+OCAMLCORE=\
+ rm -rf swig.mli swig.ml swigp4.ml && \
+ $(SWIG) -ocaml -co swig.mli 2>/dev/null && \
+ $(SWIG) -ocaml -co swig.ml 2>/dev/null && \
+ $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \
+ $(OCC) -c swig.mli && \
+ $(OCC) -c swig.ml && \
+ $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \
+ -c swigp4.ml
+
+ocaml_static: $(SRCS)
+ $(OCAMLCORE)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
+ $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
+ $(OCC) -g -c $(INTERFACE:%.i=%.mli)
+ $(OCC) -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) $(OCAMLPP) -c $(PROGFILE)
+ $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \
+ swig.cmo \
+ $(INTERFACE:%.i=%.cmo) \
+ $(PROGFILE:%.ml=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
+
+ocaml_dynamic: $(SRCS)
+ $(OCAMLCORE)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
+ $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
+ $(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS)
+ $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
+ $(INTERFACE:%.i=%_dynamic.ml)
+ mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml)
+ rm $(INTERFACE:%.i=%.mli)
+ $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) $(OCAMLPP) -c $(PROGFILE)
+ $(NOLINK) || $(OCAMLFIND) \
+ $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \
+ swig.cmo \
+ -package dl -linkpkg \
+ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
+
+ocaml_static_toplevel: $(SRCS)
+ $(OCAMLCORE)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
+ $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
+ $(OCC) -g -c $(INTERFACE:%.i=%.mli)
+ $(OCC) -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) $(OCAMLPP) -c $(PROGFILE)
+ $(NOLINK) || $(OCAMLMKTOP) \
+ swig.cmo \
+ -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
+ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
+ $(INTERFACE:%.i=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
+
+ocaml_static_cpp: $(SRCS)
+ $(OCAMLCORE)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
+ cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
+ $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
+ $(OCC) -g -c $(INTERFACE:%.i=%.mli)
+ $(OCC) -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) $(OCAMLPP) -c $(PROGFILE)
+ $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \
+ swig.cmo \
+ $(INTERFACE:%.i=%.cmo) \
+ $(PROGFILE:%.ml=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
+ -cclib "$(LIBS)" -cc '$(CXX)'
+
+ocaml_static_cpp_toplevel: $(SRCS)
+ $(OCAMLCORE)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
+ cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
+ $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
+ $(OCC) -g -c $(INTERFACE:%.i=%.mli)
+ $(OCC) -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) $(OCAMLPP) -c $(PROGFILE)
+ $(NOLINK) || $(OCAMLMKTOP) \
+ swig.cmo \
+ -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
+ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
+ $(INTERFACE:%.i=%.cmo) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
+ -cclib "$(LIBS)" -cc '$(CXX)'
+
+ocaml_dynamic_cpp: $(SRCS)
+ $(OCAMLCORE)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
+ cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
+ $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
+ $(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
+ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
+ $(CPP_DLLIBS) $(LIBS)
+ $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
+ $(INTERFACE:%.i=%_dynamic.ml)
+ mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml)
+ rm $(INTERFACE:%.i=%.mli)
+ $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
+ $(OCC) $(OCAMLPP) -c $(PROGFILE)
+ $(NOLINK) || $(OCAMLFIND) \
+ swig.cmo \
+ $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
+ -o $(TARGET) \
+ -package dl -linkpkg \
+ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
+
+ocaml_clean:
+ rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### RUBY ######
+##################################################################
+
+# Make sure these locate your Ruby installation
+RUBY_CFLAGS= @RUBYCCDLFLAGS@ $(DEFS)
+RUBY_INCLUDE= @RUBYINCLUDE@
+RUBY_LIB = @RUBYLIB@
+RUBY_DLNK = @RUBYDYNAMICLINKING@
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# ----------------------------------------------------------------
+
+ruby: $(SRCS)
+ $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# -----------------------------------------------------------------
+
+ruby_cpp: $(SRCS)
+ $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build statically linked Ruby interpreter
+#
+# These should only be used in conjunction with the %include embed.i
+# library file
+# -----------------------------------------------------------------
+
+RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS)
+
+ruby_static: $(SRCS)
+ $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
+ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
+
+ruby_cpp_static: $(SRCS)
+ $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
+
+
+# -----------------------------------------------------------------
+# Cleaning the Ruby examples
+# -----------------------------------------------------------------
+
+ruby_clean:
+ rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### PHP ######
+##################################################################
+
+# -------------------------------------------------------------------
+# Build a PHP dynamically loadable module (C)
+# -------------------------------------------------------------------
+
+PHP_INCLUDE = @PHPINC@
+PHP_SO = @PHP_SO@
+
+php: $(SRCS)
+ $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
+
+# --------------------------------------------------------------------
+# Build a PHP dynamically loadable module (C++)
+# --------------------------------------------------------------------
+
+php_cpp: $(SRCS)
+ $(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
+
+# -----------------------------------------------------------------
+# Running a PHP example
+# -----------------------------------------------------------------
+
+PHP=@PHP@
+PHPSCRIPT ?= runme.php
+
+php_run:
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
+
+# -----------------------------------------------------------------
+# Cleaning the PHP examples
+# -----------------------------------------------------------------
+
+php_clean:
+ rm -f *_wrap* *~ .~* example.php php_example.h
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### Pike ######
+##################################################################
+
+# Make sure these locate your Pike installation
+PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H
+PIKE_INCLUDE = @PIKEINCLUDE@
+PIKE_LIB = @PIKELIB@
+PIKE_DLNK = @PIKEDYNAMICLINKING@
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# ----------------------------------------------------------------
+
+pike: $(SRCS)
+ $(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# -----------------------------------------------------------------
+
+pike_cpp: $(SRCS)
+ $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build statically linked Pike interpreter
+#
+# These should only be used in conjunction with the %include embed.i
+# library file
+# -----------------------------------------------------------------
+
+PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS)
+
+pike_static: $(SRCS)
+ $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
+ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
+
+pike_cpp_static: $(SRCS)
+ $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
+
+# -----------------------------------------------------------------
+# Cleaning the Pike examples
+# -----------------------------------------------------------------
+
+pike_clean:
+ rm -f *_wrap* *~ .~* mypike@EXEEXT@
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+
+##################################################################
+##### Chicken ######
+##################################################################
+
+CHICKEN = @CHICKEN@
+CHICKEN_CSC = @CHICKEN_CSC@
+CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS)
+CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS)
+CHICKEN_CFLAGS = @CHICKENOPTS@
+CHICKENOPTS = -quiet
+CHICKEN_MAIN =
+
+# SWIG produces $(ISRCS) (the C wrapper file)
+# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file):
+CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm)
+CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c)
+CHICKEN_COMPILED_OBJECT = $(CHICKEN_COMPILED_SCHEME:.c=.@OBJEXT@)
+
+# flags for the main chicken sources (only used when compiling staticly)
+CHICKEN_COMPILED_MAIN = $(CHICKEN_MAIN:.scm=_chicken.c)
+CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@)
+
+# -----------------------------------------------------------------
+# Build a CHICKEN dynamically loadable module
+# -----------------------------------------------------------------
+
+# This is the old way to build chicken, but it does not work correctly with exceptions
+chicken_direct: $(SRCS)
+ $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
+ $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
+ -dynamic -feature chicken-compile-shared \
+ -output-file $(CHICKEN_COMPILED_SCHEME)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
+ $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCS) $(CHICKEN_COMPILED_SCHEME)
+ $(LDSHARED) $(CFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
+ $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
+ $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
+ $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
+ -dynamic -feature chicken-compile-shared \
+ -output-file $(CHICKEN_COMPILED_SCHEME)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
+ $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CHICKEN_COMPILED_SCHEME)
+ $(CXXSHARED) $(CFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
+ $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Build statically linked CHICKEN interpreter
+# -----------------------------------------------------------------
+
+# The following two targets are also used by the test suite
+chicken_static: $(SRCS) $(CHICKSRCS)
+ $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
+ $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
+ -output-file $(CHICKEN_COMPILED_SCHEME)
+ $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
+ -output-file $(CHICKEN_MAIN:.scm=_chicken.c)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
+ $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCS) \
+ $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
+ $(CC) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
+ $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
+
+chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
+ $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
+ $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
+ -output-file $(CHICKEN_COMPILED_SCHEME)
+ $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
+ -output-file $(CHICKEN_MAIN:.scm=_chicken.c)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
+ $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) \
+ $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
+ $(CXX) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
+ $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
+
+# ----------------------------------------------------------------
+# Build a shared library using csc
+# ----------------------------------------------------------------
+
+chicken:
+ $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
+ $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
+
+chicken_cpp:
+ $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
+ $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
+
+chicken_externalhdr:
+ $(SWIG) -chicken -external-runtime $(TARGET)
+
+chicken_clean:
+ rm -f *_wrap* *~ .~* *_chicken*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### CSHARP ######
+##################################################################
+
+# Extra CSharp specific dynamic linking options
+CSHARP_DLNK = @CSHARPDYNAMICLINKING@
+CSHARP_LIBPREFIX = @CSHARPLIBRARYPREFIX@
+CSHARPCOMPILER = @CSHARPCOMPILER@
+CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
+CSHARPCFLAGS = @CSHARPCFLAGS@
+CSHARPSO = @CSHARPSO@
+
+# ----------------------------------------------------------------
+# Build a CSharp dynamically loadable module (C)
+# ----------------------------------------------------------------
+
+csharp: $(SRCS)
+ $(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
+
+# ----------------------------------------------------------------
+# Build a CSharp dynamically loadable module (C++)
+# ----------------------------------------------------------------
+
+csharp_cpp: $(SRCS)
+ $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
+
+# ----------------------------------------------------------------
+# Compile CSharp files
+# ----------------------------------------------------------------
+
+csharp_compile: $(SRCS)
+ $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS)
+
+# -----------------------------------------------------------------
+# Cleaning the CSharp examples
+# -----------------------------------------------------------------
+
+csharp_clean:
+ rm -f *_wrap* *~ .~* runme runme.exe *.exe.mdb gc.log `find . -name \*.cs | grep -v runme.cs`
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@CSHARPSO@
+
+##################################################################
+##### LUA ######
+##################################################################
+
+# lua flags
+LUA_INCLUDE= @LUAFLAGS@
+LUA_LIB = @LUALINK@
+
+# Extra specific dynamic linking options
+LUA_DLNK = @LUADYNAMICLINKING@
+LUA_SO = @LUA_SO@
+
+# Extra code for lua static link
+LUA_INTERP = ../lua.c
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# ----------------------------------------------------------------
+
+lua: $(SRCS)
+ $(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
+
+# -----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# -----------------------------------------------------------------
+
+lua_cpp: $(SRCS)
+ $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
+
+# -----------------------------------------------------------------
+# Build statically linked Lua interpreter
+# -----------------------------------------------------------------
+
+lua_static: $(SRCS)
+ $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \
+ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET)
+
+lua_static_cpp: $(SRCS)
+ $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \
+ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET)
+
+# -----------------------------------------------------------------
+# Cleaning the lua examples
+# -----------------------------------------------------------------
+
+lua_clean:
+ rm -f *_wrap* *~ .~* mylua@EXEEXT@
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### ALLEGRO CL ######
+##################################################################
+
+allegrocl: $(SRCS)
+ $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+allegrocl_cpp: $(SRCS)
+ $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+allegrocl_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### CLISP ######
+##################################################################
+
+clisp: $(SRCS)
+ $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH)
+
+clisp_cpp: $(SRCS)
+ $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH)
+
+clisp_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### CFFI ######
+##################################################################
+
+cffi: $(SRCS)
+ $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+cffi_cpp: $(SRCS)
+ $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+cffi_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### UFFI ######
+##################################################################
+
+uffi: $(SRCS)
+ $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+uffi_cpp: $(SRCS)
+ $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
+# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+# $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+uffi_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+
+##################################################################
+##### R ######
+##################################################################
+
+R = R
+RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx
+RRSRC = $(INTERFACE:.i=.R)
+
+r: $(SRCS)
+ $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
+ +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(SRCS) )
+
+r_cpp: $(CXXSRCS)
+ $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
+ +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(SRCS) $(CXXSRCS))
+
+r_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@ NAMESPACE
+ rm -f $(RRSRC) runme.Rout .RData
+
diff --git a/trunk/Examples/README b/trunk/Examples/README
new file mode 100644
index 000000000..4dda3222d
--- /dev/null
+++ b/trunk/Examples/README
@@ -0,0 +1,47 @@
+SWIG Examples
+
+The "perl5", "python", "tcl", "guile", "java", "mzscheme", "ruby", and
+"chicken" directories contain a number of simple examples that are
+primarily used for testing.
+
+The file 'index.html' is the top of a hyperlinked document that
+contains information about all of the examples along with various
+notes related to each example.
+
+The Examples directory is currently quite incomplete because it
+is being reorganized. A more complete set of examples can be found
+in the SWIG1.1p5 distribution (most of which should still work with
+SWIG1.3).
+
+Note: All of the examples rely upon the Makefile in this directory.
+You may need to edit it to reflect the configuration of your machine
+in case the configure script guesses incorrect settings.
+
+
+*** Special note concering C++ ***
+
+The configure script is currently unable to handle all of the possible
+options for producing dynamically loadable C++ extensions. Here are
+the rules of thumb for making C++ work:
+
+ - Try using the C++ as the linker for the shared library. For example:
+
+ g++ -shared $(OBJS) -o module.so
+
+ - If that doesn't work, you may need to explicitly link against some
+ kind of C++ runtime library. For example:
+
+ ld -G $(OBJS) -L/opt/SUNWspro/lib -lCrun -o module.so
+
+ This can be set by modifying the setting of CPP_DLLIBS in the
+ Makefile.
+
+
+*** Special note for SWIG Maintainers ***
+
+When you add an example, consider arranging for the example to be also
+useful as part of the SWIG testing framework. To do this, include in
+the example makefile a target "check" ("check: all" is sufficient for a
+first pass), and add an invocation to ../Makefile.in under target
+"check-examples" (or whatever is appropriate). Later, we can add or
+expand the actions under target "check" to do more in-depth testing.
diff --git a/trunk/Examples/chicken/README b/trunk/Examples/chicken/README
new file mode 100644
index 000000000..d4f91baf6
--- /dev/null
+++ b/trunk/Examples/chicken/README
@@ -0,0 +1,12 @@
+This directory contains examples for CHICKEN.
+
+class -- illustrates the proxy class C++ interface
+constants -- handling #define and %constant literals
+egg -- examples of building chicken extension libraries
+multimap -- typemaps with multiple sub-types
+overload -- C++ function overloading
+simple -- the simple example from the user manual
+zlib -- a wrapping of the zlib compression library
+
+You should be able to run make in each of the examples. By default, a shared
+library will be built. Run make check to execute the test.
diff --git a/trunk/Examples/chicken/check.list b/trunk/Examples/chicken/check.list
new file mode 100644
index 000000000..9ea022bfb
--- /dev/null
+++ b/trunk/Examples/chicken/check.list
@@ -0,0 +1,6 @@
+# see top-level Makefile.in
+class
+constants
+multimap
+overload
+simple
diff --git a/trunk/Examples/chicken/class/Makefile b/trunk/Examples/chicken/class/Makefile
new file mode 100644
index 000000000..1261ec5ac
--- /dev/null
+++ b/trunk/Examples/chicken/class/Makefile
@@ -0,0 +1,38 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+INTERFACE = example.i
+SRCS =
+CXXSRCS = example.cxx
+TARGET = class
+INCLUDE =
+SWIGOPT =
+CFLAGS =
+VARIANT =
+
+# uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines)
+#CHICKEN_MAIN = test-lowlevel-class.scm
+#CHICKEN_MAIN = test-tinyclos-class.scm
+#VARIANT = _static
+
+all:: $(TARGET) $(TARGET)_proxy
+
+$(TARGET): $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
+
+$(TARGET)_proxy: $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile chicken_clean
+ rm -f example.scm
+ rm -f $(TARGET)
+
+check::
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm
diff --git a/trunk/Examples/chicken/class/example.cxx b/trunk/Examples/chicken/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/chicken/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/chicken/class/example.h b/trunk/Examples/chicken/class/example.h
new file mode 100644
index 000000000..210ba989f
--- /dev/null
+++ b/trunk/Examples/chicken/class/example.h
@@ -0,0 +1,46 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+
+ enum SomeEnum {
+ First = 0,
+ Second,
+ Third,
+ Last = 1000
+ };
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+
+
+
diff --git a/trunk/Examples/chicken/class/example.i b/trunk/Examples/chicken/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/chicken/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/chicken/class/test-lowlevel-class.scm b/trunk/Examples/chicken/class/test-lowlevel-class.scm
new file mode 100644
index 000000000..7c59c0aaa
--- /dev/null
+++ b/trunk/Examples/chicken/class/test-lowlevel-class.scm
@@ -0,0 +1,76 @@
+;; This file illustrates the low-level C++ interface generated
+;; by SWIG.
+
+(load-library 'example "class.so")
+(declare (uses example))
+
+;; ----- Object creation -----
+
+(display "Creating some objects:\n")
+(define c (new-Circle 10.0))
+(display " Created circle ")
+(display c)
+(display "\n")
+(define s (new-Square 10.0))
+(display " Created square ")
+(display s)
+(display "\n")
+
+;; ----- Access a static member -----
+
+(display "\nA total of ")
+(display (Shape-nshapes))
+(display " shapes were created\n")
+
+;; ----- Member data access -----
+
+;; Set the location of the object
+
+(Shape-x-set c 20.0)
+(Shape-y-set c 30.0)
+
+(Shape-x-set s -10.0)
+(Shape-y-set s 5.0)
+
+(display "\nHere is their current position:\n")
+(display " Circle = (")
+(display (Shape-x-get c))
+(display ", ")
+(display (Shape-y-get c))
+(display ")\n")
+(display " Square = (")
+(display (Shape-x-get s))
+(display ", ")
+(display (Shape-y-get s))
+(display ")\n")
+
+;; ----- Call some methods -----
+
+(display "\nHere are some properties of the shapes:\n")
+(let
+ ((disp (lambda (o)
+ (display " ")
+ (display o)
+ (display "\n")
+ (display " area = ")
+ (display (Shape-area o))
+ (display "\n")
+ (display " perimeter = ")
+ (display (Shape-perimeter o))
+ (display "\n"))))
+ (disp c)
+ (disp s))
+
+(display "\nGuess I'll clean up now\n")
+
+;; Note: this invokes the virtual destructor
+(set! c #f)
+(set! s #f)
+(gc #t)
+
+(set! s 3)
+(display (Shape-nshapes))
+(display " shapes remain\n")
+(display "Goodbye\n")
+
+(exit)
diff --git a/trunk/Examples/chicken/class/test-tinyclos-class.scm b/trunk/Examples/chicken/class/test-tinyclos-class.scm
new file mode 100644
index 000000000..5ba1d6adb
--- /dev/null
+++ b/trunk/Examples/chicken/class/test-tinyclos-class.scm
@@ -0,0 +1,76 @@
+;; This file illustrates the proxy C++ interface generated
+;; by SWIG.
+
+(load-library 'example "class_proxy.so")
+(declare (uses example))
+(declare (uses tinyclos))
+
+;; ----- Object creation -----
+
+(display "Creating some objects:\n")
+(define c (make <Circle> 10.0))
+(display " Created circle ")
+(display c)
+(display "\n")
+(define s (make <Square> 10.0))
+(display " Created square ")
+(display s)
+(display "\n")
+
+;; ----- Access a static member -----
+
+(display "\nA total of ")
+(display (Shape-nshapes))
+(display " shapes were created\n")
+
+;; ----- Member data access -----
+
+;; Set the location of the object
+
+(slot-set! c 'x 20.0)
+(slot-set! c 'y 30.0)
+
+(slot-set! s 'x -10.0)
+(slot-set! s 'y 5.0)
+
+(display "\nHere is their current position:\n")
+(display " Circle = (")
+(display (slot-ref c 'x))
+(display ", ")
+(display (slot-ref c 'y))
+(display ")\n")
+(display " Square = (")
+(display (slot-ref s 'x))
+(display ", ")
+(display (slot-ref s 'y))
+(display ")\n")
+
+;; ----- Call some methods -----
+
+(display "\nHere are some properties of the shapes:\n")
+(let
+ ((disp (lambda (o)
+ (display " ")
+ (display o)
+ (display "\n")
+ (display " area = ")
+ (display (area o))
+ (display "\n")
+ (display " perimeter = ")
+ (display (perimeter o))
+ (display "\n"))))
+ (disp c)
+ (disp s))
+
+(display "\nGuess I'll clean up now\n")
+
+;; Note: Invoke the virtual destructors by forcing garbage collection
+(set! c 77)
+(set! s 88)
+(gc #t)
+
+(display (Shape-nshapes))
+(display " shapes remain\n")
+(display "Goodbye\n")
+
+(exit)
diff --git a/trunk/Examples/chicken/constants/Makefile b/trunk/Examples/chicken/constants/Makefile
new file mode 100644
index 000000000..81308fcf3
--- /dev/null
+++ b/trunk/Examples/chicken/constants/Makefile
@@ -0,0 +1,30 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+INTERFACE = example.i
+SRCS =
+CXXSRCS =
+TARGET = constants
+INCLUDE =
+SWIGOPT =
+CFLAGS =
+VARIANT =
+
+# uncomment the following two lines to build a static exe
+#CHICKEN_MAIN = test-constants.scm
+#VARIANT = _static
+
+all:: $(TARGET)
+
+$(TARGET): $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile chicken_clean
+ rm -f example.scm
+ rm -f $(TARGET)
+
+check::
+ csi test-constants.scm
diff --git a/trunk/Examples/chicken/constants/example.i b/trunk/Examples/chicken/constants/example.i
new file mode 100644
index 000000000..0995c19b9
--- /dev/null
+++ b/trunk/Examples/chicken/constants/example.i
@@ -0,0 +1,27 @@
+/* File : example.i */
+%module example
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following directives also produce constants. Remember that
+ CHICKEN is normally case-insensitive, so don't rely on differing
+ case to differentiate variable names */
+
+%constant int iconstX = 37;
+%constant double fconstX = 3.14;
diff --git a/trunk/Examples/chicken/constants/test-constants.scm b/trunk/Examples/chicken/constants/test-constants.scm
new file mode 100644
index 000000000..1b10b2605
--- /dev/null
+++ b/trunk/Examples/chicken/constants/test-constants.scm
@@ -0,0 +1,16 @@
+;; feel free to uncomment and comment sections
+
+(load-library 'example "./constants.so")
+
+(display "starting test ... you will see 'finished' if successful.\n")
+(or (= (ICONST) 42) (exit 1))
+(or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1))
+(or (char=? (CCONST) #\x) (exit 1))
+(or (char=? (CCONST2) #\newline) (exit 1))
+(or (string=? (SCONST) "Hello World") (exit 1))
+(or (string=? (SCONST2) "\"Hello World\"") (exit 1))
+(or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1))
+(or (= (iconstX) 37) (exit 1))
+(or (< (abs (- (fconstX) 3.14)) 0.00001) (exit 1))
+(display "finished test.\n")
+(exit 0)
diff --git a/trunk/Examples/chicken/egg/Makefile b/trunk/Examples/chicken/egg/Makefile
new file mode 100644
index 000000000..bdf71b104
--- /dev/null
+++ b/trunk/Examples/chicken/egg/Makefile
@@ -0,0 +1,39 @@
+SWIG = ../../../preinst-swig
+
+all: single multi
+
+# This creates an egg which contains only the single module. Any additional implementation files
+# that implement the interface being wrapped should also be added to this egg
+single: single_wrap.cxx
+ mkdir -p eggs
+ tar czf eggs/single.egg single.setup single.scm single_wrap.cxx
+ rm -f single.scm single_wrap.cxx
+
+# complie the single module with -nounit
+single_wrap.cxx: single.i
+ $(SWIG) -chicken -c++ -proxy -nounit single.i
+
+# Now build both mod1 and mod2 into a single egg
+multi: mod1_wrap.cxx mod2_wrap.cxx
+ mkdir -p eggs
+ tar czf eggs/multi.egg multi.setup multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
+ rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
+
+mod1_wrap.cxx: mod1.i
+ $(SWIG) -chicken -c++ -proxy mod1.i
+
+mod2_wrap.cxx: mod2.i
+ $(SWIG) -chicken -c++ -proxy mod2.i
+
+clean:
+ rm -rf eggs
+
+# this part is for testing...
+setup:
+ cd eggs && \
+ mkdir -p install && \
+ chicken-setup -repository `pwd`/install single.egg && \
+ chicken-setup -repository `pwd`/install multi.egg
+
+check:
+ cd eggs/install && csi ../../test.scm
diff --git a/trunk/Examples/chicken/egg/README b/trunk/Examples/chicken/egg/README
new file mode 100644
index 000000000..b5df0e631
--- /dev/null
+++ b/trunk/Examples/chicken/egg/README
@@ -0,0 +1,19 @@
+These examples show how to build a chicken extension module in the form of an
+egg. There are two eggs that get built, single.egg which contains a single
+module which is built with -nounit and multi.egg, which contains two modules
+mod1 and mod2. These are built normally, and multi_init.scm loads them both.
+Read section "17.4.2 Building chicken extension libraries" in the manual
+for a description of these two techniques.
+
+To build:
+
+$ make
+$ make setup
+$ make run
+
+$ make clean
+
+The eggs are built into an eggs subdirectory, because chicken-setup has
+problems installing eggs when there are other files named similar in
+the same directory. The make setup step runs chicken-setup to install
+the eggs into the eggs/install directory.
diff --git a/trunk/Examples/chicken/egg/mod1.i b/trunk/Examples/chicken/egg/mod1.i
new file mode 100644
index 000000000..6a2940b89
--- /dev/null
+++ b/trunk/Examples/chicken/egg/mod1.i
@@ -0,0 +1,8 @@
+%module mod1
+
+%inline %{
+class Bar {
+ public:
+ int b;
+};
+%}
diff --git a/trunk/Examples/chicken/egg/mod2.i b/trunk/Examples/chicken/egg/mod2.i
new file mode 100644
index 000000000..e9ae4a6a8
--- /dev/null
+++ b/trunk/Examples/chicken/egg/mod2.i
@@ -0,0 +1,17 @@
+%module mod2
+
+%import "mod1.i"
+
+%{
+class Bar {
+ public:
+ int b;
+};
+%}
+
+%inline %{
+ class Bar2 : public Bar {
+ public:
+ int c;
+ };
+%}
diff --git a/trunk/Examples/chicken/egg/multi.setup b/trunk/Examples/chicken/egg/multi.setup
new file mode 100644
index 000000000..95aeb001c
--- /dev/null
+++ b/trunk/Examples/chicken/egg/multi.setup
@@ -0,0 +1,2 @@
+(run (csc -s -o multi.so multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx))
+(install-extension 'multi '("multi.so"))
diff --git a/trunk/Examples/chicken/egg/multi_init.scm b/trunk/Examples/chicken/egg/multi_init.scm
new file mode 100644
index 000000000..600491d5b
--- /dev/null
+++ b/trunk/Examples/chicken/egg/multi_init.scm
@@ -0,0 +1,2 @@
+(declare (uses mod1))
+(declare (uses mod2))
diff --git a/trunk/Examples/chicken/egg/single.i b/trunk/Examples/chicken/egg/single.i
new file mode 100644
index 000000000..46266b4bf
--- /dev/null
+++ b/trunk/Examples/chicken/egg/single.i
@@ -0,0 +1,8 @@
+%module single
+
+%inline %{
+class Foo {
+ public:
+ int a;
+};
+%}
diff --git a/trunk/Examples/chicken/egg/single.setup b/trunk/Examples/chicken/egg/single.setup
new file mode 100644
index 000000000..4b503ec21
--- /dev/null
+++ b/trunk/Examples/chicken/egg/single.setup
@@ -0,0 +1,2 @@
+(run (csc -s -o single.so single.scm single_wrap.cxx))
+(install-extension 'single '("single.so"))
diff --git a/trunk/Examples/chicken/egg/test.scm b/trunk/Examples/chicken/egg/test.scm
new file mode 100644
index 000000000..4ec94ed18
--- /dev/null
+++ b/trunk/Examples/chicken/egg/test.scm
@@ -0,0 +1,18 @@
+(require-extension single)
+(require-extension multi)
+
+(define f (make <Foo>))
+(slot-set! f 'a 3)
+(print (slot-ref f 'a))
+
+(define b (make <Bar>))
+(slot-set! b 'b 2)
+(print (slot-ref b 'b))
+
+(define b2 (make <Bar2>))
+(slot-set! b2 'b 4)
+(slot-set! b2 'c 6)
+(print (slot-ref b2 'b))
+(print (slot-ref b2 'c))
+
+(exit 0)
diff --git a/trunk/Examples/chicken/multimap/Makefile b/trunk/Examples/chicken/multimap/Makefile
new file mode 100644
index 000000000..dace61a1e
--- /dev/null
+++ b/trunk/Examples/chicken/multimap/Makefile
@@ -0,0 +1,30 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+INTERFACE = example.i
+SRCS = example.c
+CXXSRCS =
+TARGET = multimap
+INCLUDE =
+SWIGOPT =
+CFLAGS =
+VARIANT =
+
+# uncomment the following two lines to build a static exe
+#CHICKEN_MAIN = test-multimap.scm
+#VARIANT = _static
+
+all:: $(TARGET)
+
+$(TARGET): $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile chicken_clean
+ rm -f example.scm
+ rm -f $(TARGET)
+
+check::
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm
diff --git a/trunk/Examples/chicken/multimap/example.c b/trunk/Examples/chicken/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/Examples/chicken/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/chicken/multimap/example.i b/trunk/Examples/chicken/multimap/example.i
new file mode 100644
index 000000000..02567f48f
--- /dev/null
+++ b/trunk/Examples/chicken/multimap/example.i
@@ -0,0 +1,96 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in) (int argc, char *argv[]) {
+ int i;
+ if (!C_swig_is_vector ($input)) {
+ swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a vector");
+ }
+ $1 = C_header_size ($input);
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ C_word o = C_block_item ($input, i);
+ if (!C_swig_is_string (o)) {
+ char err[50];
+ free($2);
+ sprintf (err, "$input[%d] is not a string", i);
+ swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, err);
+ }
+ $2[i] = C_c_string (o);
+ }
+ $2[i] = 0;
+}
+
+%typemap(freearg) (int argc, char *argv[]) {
+ free($2);
+}
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+ if (!C_swig_is_string ($input)) {
+ swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
+ }
+ $1 = C_c_string ($input);
+ $2 = C_header_size ($input);
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len)
+%{ if (!C_swig_is_string ($input)) {
+ swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
+ }
+ $2 = C_header_size ($input);
+ $1 = (char *) malloc ($2+1);
+ memmove ($1, C_c_string ($input), $2);
+%}
+
+/* Return the mutated string as a new object. Notice the if MANY construct ... they must be at column 0. */
+
+%typemap(argout) (char *str, int len) (C_word *scmstr)
+%{ scmstr = C_alloc (C_SIZEOF_STRING ($2));
+ SWIG_APPEND_VALUE(C_string (&scmstr, $2, $1));
+ free ($1);
+%}
+
+extern void capitalize (char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception (SWIG_ValueError, "cx and cy must be in unit circle");
+ }
+}
+
+extern void circle (double cx, double cy);
+
+/* Test out multiple return values */
+
+extern int squareCubed (int n, int *OUTPUT);
+%{
+/* Returns n^3 and set n2 to n^2 */
+int squareCubed (int n, int *n2) {
+ *n2 = n * n;
+ return (*n2) * n;
+};
+%}
diff --git a/trunk/Examples/chicken/multimap/test-multimap.scm b/trunk/Examples/chicken/multimap/test-multimap.scm
new file mode 100644
index 000000000..3a6b46e2c
--- /dev/null
+++ b/trunk/Examples/chicken/multimap/test-multimap.scm
@@ -0,0 +1,59 @@
+;; run with './multimap test-multimap.scm'
+;; feel free to uncomment and comment sections
+
+(load-library 'example "multimap.so")
+
+(display "(gcd 90 12): ")
+(display (gcd 90 12))
+(display "\n")
+
+(display "(circle 0.5 0.5): ")
+(display (circle 0.5 0.5))
+(display "\n")
+
+(display "(circle 1.0 1.0): ")
+(handle-exceptions exvar
+ (if (= (car exvar) 9)
+ (display "success: exception thrown")
+ (display "an incorrect exception was thrown"))
+ (begin
+ (circle 1.0 1.0)
+ (display "an exception was not thrown when it should have been")))
+(display "\n")
+
+(display "(circle 1 1): ")
+(handle-exceptions exvar
+ (if (= (car exvar) 9)
+ (display "success: exception thrown")
+ (display "an incorrect exception was thrown"))
+ (begin
+ (circle 1 1)
+ (display "an exception was not thrown when it should have been")))
+(display "\n")
+
+(display "(capitalize \"will this be all capital letters?\"): ")
+(display (capitalize "will this be all capital letters?"))
+(display "\n")
+
+(display "(count \"jumpity little spider\" #\\t): ")
+(display (count "jumpity little spider" #\t))
+(display "\n")
+
+(display "(gcdmain '#(\"hi\" \"there\")): ")
+(display (gcdmain '#("hi" "there")))
+(display "\n")
+
+(display "(gcdmain '#(\"gcd\" \"9\" \"28\")): ")
+(gcdmain '#("gcd" "9" "28"))
+(display "\n")
+
+(display "(gcdmain '#(\"gcd\" \"12\" \"90\")): ")
+(gcdmain '#("gcd" "12" "90"))
+(display "\n")
+
+(display "squarecubed 3: ")
+(call-with-values (lambda() (squareCubed 3))
+ (lambda (a b) (printf "~A ~A" a b)))
+(display "\n")
+
+(exit)
diff --git a/trunk/Examples/chicken/overload/Makefile b/trunk/Examples/chicken/overload/Makefile
new file mode 100644
index 000000000..48ec43af4
--- /dev/null
+++ b/trunk/Examples/chicken/overload/Makefile
@@ -0,0 +1,30 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+INTERFACE = example.i
+SRCS =
+CXXSRCS = example.cxx
+TARGET = overload
+INCLUDE =
+SWIGOPT = -proxy -unhideprimitive
+CFLAGS =
+VARIANT =
+
+# uncomment the following lines to build a static exe
+#CHICKEN_MAIN = test-overload.scm
+#VARIANT = _static
+
+all:: $(TARGET)
+
+$(TARGET): $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile chicken_clean
+ rm -f example.scm
+ rm -f $(TARGET)
+
+check::
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm
diff --git a/trunk/Examples/chicken/overload/README b/trunk/Examples/chicken/overload/README
new file mode 100644
index 000000000..9487c3f3e
--- /dev/null
+++ b/trunk/Examples/chicken/overload/README
@@ -0,0 +1,2 @@
+Overloading example from Chapter 5.14 of SWIG Core Documentation for
+version 1.3.
diff --git a/trunk/Examples/chicken/overload/example.cxx b/trunk/Examples/chicken/overload/example.cxx
new file mode 100644
index 000000000..65e743941
--- /dev/null
+++ b/trunk/Examples/chicken/overload/example.cxx
@@ -0,0 +1,33 @@
+/* File : example.c */
+
+#include "example.h"
+#include <stdio.h>
+
+void foo(int x) {
+ printf("x is %d\n", x);
+}
+
+void foo(char *x) {
+ printf("x is '%s'\n", x);
+}
+
+Foo::Foo () {
+ myvar = 55;
+ printf ("Foo constructor called\n");
+}
+
+Foo::Foo (const Foo &) {
+ myvar = 66;
+ printf ("Foo copy constructor called\n");
+}
+
+void Foo::bar (int x) {
+ printf ("Foo::bar(x) method ... \n");
+ printf("x is %d\n", x);
+}
+
+void Foo::bar (char *s, int y) {
+ printf ("Foo::bar(s,y) method ... \n");
+ printf ("s is '%s'\n", s);
+ printf ("y is %d\n", y);
+}
diff --git a/trunk/Examples/chicken/overload/example.h b/trunk/Examples/chicken/overload/example.h
new file mode 100644
index 000000000..1c135d509
--- /dev/null
+++ b/trunk/Examples/chicken/overload/example.h
@@ -0,0 +1,14 @@
+/* File : example.h */
+
+extern void foo (int x);
+extern void foo (char *x);
+
+class Foo {
+ private:
+ int myvar;
+ public:
+ Foo();
+ Foo(const Foo &); // Copy constructor
+ void bar(int x);
+ void bar(char *s, int y);
+};
diff --git a/trunk/Examples/chicken/overload/example.i b/trunk/Examples/chicken/overload/example.i
new file mode 100644
index 000000000..23a29986e
--- /dev/null
+++ b/trunk/Examples/chicken/overload/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let "Foo" objects be converted back and forth from TinyCLOS into
+ low-level CHICKEN SWIG procedures */
+
+%typemap(clos_in) Foo * = SIMPLE_CLOS_OBJECT *;
+%typemap(clos_out) Foo * = SIMPLE_CLOS_OBJECT *;
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/chicken/overload/test-overload.scm b/trunk/Examples/chicken/overload/test-overload.scm
new file mode 100644
index 000000000..168490f76
--- /dev/null
+++ b/trunk/Examples/chicken/overload/test-overload.scm
@@ -0,0 +1,45 @@
+;; This file demonstrates the overloading capabilities of SWIG
+
+(load-library 'example "overload.so")
+
+;; Low level
+;; ---------
+
+(display "
+Trying low level code ...
+ (foo 1)
+ (foo \"some string\")
+ (define A-FOO (new-Foo))
+ (define ANOTHER-FOO (new-Foo A-FOO)) ;; copy constructor
+ (Foo-bar A-FOO 2)
+ (Foo-bar ANOTHER-FOO \"another string\" 3)
+")
+
+(primitive:foo 1)
+(primitive:foo "some string")
+(define A-FOO (slot-ref (primitive:new-Foo) 'swig-this))
+(define ANOTHER-FOO (slot-ref (primitive:new-Foo A-FOO) 'swig-this)) ;; copy constructor
+(primitive:Foo-bar A-FOO 2)
+(primitive:Foo-bar ANOTHER-FOO "another string" 3)
+
+;; TinyCLOS
+;; --------
+
+(display "
+Trying TinyCLOS code ...
+ (+foo+ 1)
+ (+foo+ \"some string\")
+ (define A-FOO (make <Foo>))
+ (define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
+ (-bar- A-FOO 2)
+ (-bar- ANOTHER-FOO \"another string\" 3)
+")
+
+(foo 1)
+(foo "some string")
+(define A-FOO (make <Foo>))
+(define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
+(bar A-FOO 2)
+(bar ANOTHER-FOO "another string" 3)
+
+(exit)
diff --git a/trunk/Examples/chicken/simple/Makefile b/trunk/Examples/chicken/simple/Makefile
new file mode 100644
index 000000000..bb7814260
--- /dev/null
+++ b/trunk/Examples/chicken/simple/Makefile
@@ -0,0 +1,30 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+INTERFACE = example.i
+SRCS = example.c
+CXXSRCS =
+TARGET = simple
+INCLUDE =
+SWIGOPT =
+CFLAGS =
+VARIANT =
+
+# uncomment the following two lines to build a static exe
+#CHICKEN_MAIN = test-simple.scm
+#VARIANT = _static
+
+all:: $(TARGET)
+
+$(TARGET): $(INTERFACE) $(SRCS)
+ $(MAKE) -f $(TOP)/Makefile \
+ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
+ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
+ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile chicken_clean
+ rm -f example.scm example-generic.scm example-clos.scm
+ rm -f $(TARGET)
+
+check::
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm
diff --git a/trunk/Examples/chicken/simple/README b/trunk/Examples/chicken/simple/README
new file mode 100644
index 000000000..07e8da069
--- /dev/null
+++ b/trunk/Examples/chicken/simple/README
@@ -0,0 +1 @@
+Simple example from users manual.
diff --git a/trunk/Examples/chicken/simple/example.c b/trunk/Examples/chicken/simple/example.c
new file mode 100644
index 000000000..f2b074781
--- /dev/null
+++ b/trunk/Examples/chicken/simple/example.c
@@ -0,0 +1,24 @@
+/* Simple example from documentation */
+/* File : example.c */
+
+#include <time.h>
+
+double My_variable = 3.0;
+
+/* Compute factorial of n */
+int fact(int n) {
+ if (n <= 1) return 1;
+ else return n*fact(n-1);
+}
+
+/* Compute n mod m */
+int my_mod(int n, int m) {
+ return (n % m);
+}
+
+
+char *get_time() {
+ long ltime;
+ time(&ltime);
+ return ctime(&ltime);
+}
diff --git a/trunk/Examples/chicken/simple/example.i b/trunk/Examples/chicken/simple/example.i
new file mode 100644
index 000000000..5b3e95580
--- /dev/null
+++ b/trunk/Examples/chicken/simple/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+%{
+/* Put headers and other declarations here */
+%}
+
+%include typemaps.i
+
+%rename(mod) my_mod;
+
+%inline %{
+extern double My_variable;
+extern int fact(int);
+extern int my_mod(int n, int m);
+extern char *get_time();
+%}
diff --git a/trunk/Examples/chicken/simple/test-simple.scm b/trunk/Examples/chicken/simple/test-simple.scm
new file mode 100644
index 000000000..05aa87081
--- /dev/null
+++ b/trunk/Examples/chicken/simple/test-simple.scm
@@ -0,0 +1,28 @@
+;; feel free to uncomment and comment sections
+(load-library 'example "simple.so")
+
+(display "(My-variable): ")
+(display (My-variable))
+(display "\n")
+
+(display "(My-variable 3.141259): ")
+(display (My-variable 3.141259))
+(display "\n")
+
+(display "(My-variable): ")
+(display (My-variable))
+(display "\n")
+
+(display "(fact 5): ")
+(display (fact 5))
+(display "\n")
+
+(display "(mod 75 7): ")
+(display (mod 75 7))
+(display "\n")
+
+(display "(get-time): ")
+(display (get-time))
+(display "\n")
+
+(exit)
diff --git a/trunk/Examples/contract/simple_c/example.c b/trunk/Examples/contract/simple_c/example.c
new file mode 100644
index 000000000..85a3e1417
--- /dev/null
+++ b/trunk/Examples/contract/simple_c/example.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int Circle (int x, int y, int radius) {
+ /* Draw Circle */
+ printf("Drawing the circle...\n");
+ /* Return -1 to test contract post assertion */
+ if (radius == 2)
+ return -1;
+ else
+ return 1;
+}
diff --git a/trunk/Examples/contract/simple_c/example.i b/trunk/Examples/contract/simple_c/example.i
new file mode 100644
index 000000000..49df09af6
--- /dev/null
+++ b/trunk/Examples/contract/simple_c/example.i
@@ -0,0 +1,19 @@
+/* File : example.i */
+
+/* Basic C example for swig contract */
+/* Tiger, University of Chicago, 2003 */
+
+%module example
+
+%contract Circle (int x, int y, int radius) {
+require:
+ x >= 0;
+ y >= 0;
+ radius > x;
+ensure:
+ Circle >= 0;
+}
+
+%inline %{
+extern int Circle (int x, int y, int radius);
+%}
diff --git a/trunk/Examples/contract/simple_c/runme1.py b/trunk/Examples/contract/simple_c/runme1.py
new file mode 100644
index 000000000..abd8df62f
--- /dev/null
+++ b/trunk/Examples/contract/simple_c/runme1.py
@@ -0,0 +1,17 @@
+import example
+# Call the Circle() function correctly
+
+x = 1;
+y = 1;
+r = 3;
+
+c = example.Circle(x, y, r)
+
+# test post-assertion
+x = 1;
+y = 1;
+r = 2;
+
+c = example.Circle(x, y, r)
+
+print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
diff --git a/trunk/Examples/contract/simple_c/runme2.py b/trunk/Examples/contract/simple_c/runme2.py
new file mode 100644
index 000000000..48d4a3f10
--- /dev/null
+++ b/trunk/Examples/contract/simple_c/runme2.py
@@ -0,0 +1,20 @@
+import example
+
+# Call the Circle() function correctly
+
+x = 1;
+y = 1;
+r = 3;
+
+c = example.Circle(x, y, r)
+
+print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
+
+# test pre-assertion
+x = 1;
+y = -1;
+r = 3;
+
+c = example.Circle(x, y, r)
+
+print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
diff --git a/trunk/Examples/contract/simple_cxx/example.cxx b/trunk/Examples/contract/simple_cxx/example.cxx
new file mode 100644
index 000000000..e3dd2ca7a
--- /dev/null
+++ b/trunk/Examples/contract/simple_cxx/example.cxx
@@ -0,0 +1,30 @@
+#include "example.h"
+
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ /* return -1 is to test post-assertion */
+ if (radius == 1)
+ return -1;
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/contract/simple_cxx/example.h b/trunk/Examples/contract/simple_cxx/example.h
new file mode 100644
index 000000000..64b7684fa
--- /dev/null
+++ b/trunk/Examples/contract/simple_cxx/example.h
@@ -0,0 +1,34 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
diff --git a/trunk/Examples/contract/simple_cxx/example.i b/trunk/Examples/contract/simple_cxx/example.i
new file mode 100644
index 000000000..9b47409d0
--- /dev/null
+++ b/trunk/Examples/contract/simple_cxx/example.i
@@ -0,0 +1,28 @@
+%module example
+
+%contract Circle::Circle(double radius) {
+require:
+ radius > 0;
+}
+
+%contract Circle::area(void) {
+ensure:
+ area > 0;
+}
+
+%contract Shape::move(double dx, double dy) {
+require:
+ dx > 0;
+}
+
+/* should be no effect, since there is no move() for class Circle */
+%contract Circle::move(double dx, double dy) {
+require:
+ dy > 1;
+}
+
+# include must be after contracts
+%{
+#include "example.h"
+%}
+%include "example.h"
diff --git a/trunk/Examples/contract/simple_cxx/runme1.py b/trunk/Examples/contract/simple_cxx/runme1.py
new file mode 100644
index 000000000..9028d02d9
--- /dev/null
+++ b/trunk/Examples/contract/simple_cxx/runme1.py
@@ -0,0 +1,33 @@
+import example
+
+# Create the Circle object
+
+r = 2;
+print " Creating circle (radium: %d) :" % r
+c = example.Circle(r)
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+print " Here is its current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+
+# ----- Call some methods -----
+
+print "\n Here are some properties of the Circle:"
+print " area = ", c.area()
+print " perimeter = ", c.perimeter()
+dx = 1;
+dy = 1;
+print " Moving with (%d, %d)..." % (dx, dy)
+c.move(dx, dy)
+
+del c
+
+print "==================================="
+
+# test construction */
+r = -1;
+print " Creating circle (radium: %d) :" % r
+c = example.Circle(r)
diff --git a/trunk/Examples/contract/simple_cxx/runme2.py b/trunk/Examples/contract/simple_cxx/runme2.py
new file mode 100644
index 000000000..5f9c0df5b
--- /dev/null
+++ b/trunk/Examples/contract/simple_cxx/runme2.py
@@ -0,0 +1,44 @@
+import example
+
+# Create the Circle object
+
+r = 2;
+print " Creating circle (radium: %d) :" % r
+c = example.Circle(r)
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+print " Here is its current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+
+# ----- Call some methods -----
+
+print "\n Here are some properties of the Circle:"
+print " area = ", c.area()
+print " perimeter = ", c.perimeter()
+dx = 1;
+dy = 1;
+print " Moving with (%d, %d)..." % (dx, dy)
+c.move(dx, dy)
+
+del c
+
+print "==================================="
+
+# test area function */
+r = 1;
+print " Creating circle (radium: %d) :" % r
+c = example.Circle(r)
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+print " Here is its current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+
+# ----- Call some methods -----
+
+print "\n Here are some properties of the Circle:"
+print " area = ", c.area()
diff --git a/trunk/Examples/contract/simple_cxx/runme3.py b/trunk/Examples/contract/simple_cxx/runme3.py
new file mode 100644
index 000000000..a663732b1
--- /dev/null
+++ b/trunk/Examples/contract/simple_cxx/runme3.py
@@ -0,0 +1,57 @@
+import example
+
+# Create the Circle object
+
+r = 2;
+print " Creating circle (radium: %d) :" % r
+c = example.Circle(r)
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+print " Here is its current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+
+# ----- Call some methods -----
+
+print "\n Here are some properties of the Circle:"
+print " area = ", c.area()
+print " perimeter = ", c.perimeter()
+dx = 1;
+dy = 1;
+print " Moving with (%d, %d)..." % (dx, dy)
+c.move(dx, dy)
+
+del c
+
+print "==================================="
+
+# test move function */
+r = 2;
+print " Creating circle (radium: %d) :" % r
+c = example.Circle(r)
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+print " Here is its current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+
+# ----- Call some methods -----
+
+print "\n Here are some properties of the Circle:"
+print " area = ", c.area()
+print " perimeter = ", c.perimeter()
+
+# no error for Circle's pre-assertion
+dx = 1;
+dy = -1;
+print " Moving with (%d, %d)..." % (dx, dy)
+c.move(dx, dy)
+
+# error with Shape's pre-assertion
+dx = -1;
+dy = 1;
+print " Moving with (%d, %d)..." % (dx, dy)
+c.move(dx, dy)
diff --git a/trunk/Examples/csharp/arrays/Makefile b/trunk/Examples/csharp/arrays/Makefile
new file mode 100644
index 000000000..b3446d895
--- /dev/null
+++ b/trunk/Examples/csharp/arrays/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -unsafe -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/arrays/example.c b/trunk/Examples/csharp/arrays/example.c
new file mode 100644
index 000000000..2498e1f4e
--- /dev/null
+++ b/trunk/Examples/csharp/arrays/example.c
@@ -0,0 +1,22 @@
+/* File : example.c */
+
+#include "example.h"
+
+/* copy the contents of the first array to the second */
+void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
+ int i;
+ for ( i = 0; i < nitems; i++ ) {
+ targetArray[ i ] = sourceArray[ i ];
+ }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwap( int* array1, int* array2, int nitems ) {
+ int i, temp;
+ for ( i = 0; i < nitems; i++ ) {
+ temp = array1[ i ];
+ array1[ i ] = array2[ i ];
+ array2[ i ] = temp;
+ }
+}
+
diff --git a/trunk/Examples/csharp/arrays/example.h b/trunk/Examples/csharp/arrays/example.h
new file mode 100644
index 000000000..113b92c1b
--- /dev/null
+++ b/trunk/Examples/csharp/arrays/example.h
@@ -0,0 +1,4 @@
+
+void myArrayCopy( int *sourceArray, int* targetArray, int nitems );
+void myArraySwap( int* array1, int* array2, int nitems );
+
diff --git a/trunk/Examples/csharp/arrays/example.i b/trunk/Examples/csharp/arrays/example.i
new file mode 100644
index 000000000..488565a74
--- /dev/null
+++ b/trunk/Examples/csharp/arrays/example.i
@@ -0,0 +1,45 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+%include "arrays_csharp.i"
+
+%apply int INPUT[] { int* sourceArray }
+%apply int OUTPUT[] { int* targetArray }
+
+%apply int INOUT[] { int* array1 }
+%apply int INOUT[] { int* array2 }
+
+%include "example.h"
+
+%clear int* sourceArray;
+%clear int* targetArray;
+
+%clear int* array1;
+%clear int* array2;
+
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers "public unsafe";
+
+%apply int FIXED[] { int* sourceArray }
+%apply int FIXED[] { int* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
+ myArrayCopy(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply int FIXED[] { int* array1 }
+%apply int FIXED[] { int* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
+ myArraySwap(array1, array2, nitems);
+}
+%}
+
+
diff --git a/trunk/Examples/csharp/arrays/runme.cs b/trunk/Examples/csharp/arrays/runme.cs
new file mode 100644
index 000000000..c2b8a6bdd
--- /dev/null
+++ b/trunk/Examples/csharp/arrays/runme.cs
@@ -0,0 +1,43 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ int[] source = { 1, 2, 3 };
+ int[] target = new int[ source.Length ];
+
+ example.myArrayCopy( source, target, target.Length );
+
+ Console.WriteLine( "Contents of copy target array using default marshaling" );
+ PrintArray( target );
+
+ target = new int[ source.Length ];
+
+ example.myArrayCopyUsingFixedArrays( source, target, target.Length );
+ Console.WriteLine( "Contents of copy target array using fixed arrays" );
+ PrintArray( target );
+
+ target = new int[] { 4, 5, 6 };
+ example.myArraySwap( source, target, target.Length );
+ Console.WriteLine( "Contents of arrays after swapping using default marshaling" );
+ PrintArray( source );
+ PrintArray( target );
+
+ source = new int[] { 1, 2, 3 };
+ target = new int[] { 4, 5, 6 };
+
+ example.myArraySwapUsingFixedArrays( source, target, target.Length );
+ Console.WriteLine( "Contents of arrays after swapping using fixed arrays" );
+ PrintArray( source );
+ PrintArray( target );
+ }
+
+ static void PrintArray( int[] a )
+ {
+ foreach ( int i in a )
+ Console.Write( "{0} ", i );
+ Console.WriteLine();
+ }
+}
+
diff --git a/trunk/Examples/csharp/callback/Makefile b/trunk/Examples/csharp/callback/Makefile
new file mode 100644
index 000000000..51b163b85
--- /dev/null
+++ b/trunk/Examples/csharp/callback/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -debug -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/callback/example-cs.csproj b/trunk/Examples/csharp/callback/example-cs.csproj
new file mode 100644
index 000000000..5fc34527f
--- /dev/null
+++ b/trunk/Examples/csharp/callback/example-cs.csproj
@@ -0,0 +1,99 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "Callback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Caller.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/callback/example-vc.vcproj b/trunk/Examples/csharp/callback/example-vc.vcproj
new file mode 100644
index 000000000..7c0b8ef13
--- /dev/null
+++ b/trunk/Examples/csharp/callback/example-vc.vcproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="example.cxx">
+ </File>
+ <File
+ RelativePath="example_wrap.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/callback/example.cxx b/trunk/Examples/csharp/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/csharp/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/csharp/callback/example.h b/trunk/Examples/csharp/callback/example.h
new file mode 100644
index 000000000..38d25a043
--- /dev/null
+++ b/trunk/Examples/csharp/callback/example.h
@@ -0,0 +1,24 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void resetCallback() { _callback = 0; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/trunk/Examples/csharp/callback/example.i b/trunk/Examples/csharp/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/trunk/Examples/csharp/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/trunk/Examples/csharp/callback/example.sln b/trunk/Examples/csharp/callback/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/callback/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/callback/runme.cs b/trunk/Examples/csharp/callback/runme.cs
new file mode 100644
index 000000000..a104b1a3e
--- /dev/null
+++ b/trunk/Examples/csharp/callback/runme.cs
@@ -0,0 +1,46 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ Console.WriteLine("Adding and calling a normal C++ callback");
+ Console.WriteLine("----------------------------------------");
+
+ Caller caller = new Caller();
+ using (Callback callback = new Callback())
+ {
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine("Adding and calling a C# callback");
+ Console.WriteLine("------------------------------------");
+
+ using (Callback callback = new CSharpCallback())
+ {
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine("C# exit");
+ }
+}
+
+public class CSharpCallback : Callback
+{
+ public CSharpCallback()
+ : base()
+ {
+ }
+
+ public override void run()
+ {
+ Console.WriteLine("CSharpCallback.run()");
+ }
+}
+
diff --git a/trunk/Examples/csharp/check.list b/trunk/Examples/csharp/check.list
new file mode 100644
index 000000000..5454d8531
--- /dev/null
+++ b/trunk/Examples/csharp/check.list
@@ -0,0 +1,11 @@
+# see top-level Makefile.in
+arrays
+callback
+class
+enum
+extend
+funcptr
+reference
+simple
+template
+variables
diff --git a/trunk/Examples/csharp/class/Makefile b/trunk/Examples/csharp/class/Makefile
new file mode 100644
index 000000000..20f0dd5bb
--- /dev/null
+++ b/trunk/Examples/csharp/class/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/class/example-cs.csproj b/trunk/Examples/csharp/class/example-cs.csproj
new file mode 100644
index 000000000..0b9ea2e05
--- /dev/null
+++ b/trunk/Examples/csharp/class/example-cs.csproj
@@ -0,0 +1,104 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "Circle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Shape.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Square.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/class/example-vc.vcproj b/trunk/Examples/csharp/class/example-vc.vcproj
new file mode 100644
index 000000000..7c0b8ef13
--- /dev/null
+++ b/trunk/Examples/csharp/class/example-vc.vcproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="example.cxx">
+ </File>
+ <File
+ RelativePath="example_wrap.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/class/example.cxx b/trunk/Examples/csharp/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/csharp/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/csharp/class/example.h b/trunk/Examples/csharp/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/csharp/class/example.h
@@ -0,0 +1,39 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+
+
+
diff --git a/trunk/Examples/csharp/class/example.i b/trunk/Examples/csharp/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/csharp/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/csharp/class/example.sln b/trunk/Examples/csharp/class/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/class/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/class/runme.cs b/trunk/Examples/csharp/class/runme.cs
new file mode 100644
index 000000000..9088031d6
--- /dev/null
+++ b/trunk/Examples/csharp/class/runme.cs
@@ -0,0 +1,66 @@
+// This example illustrates how C++ classes can be used from C# using SWIG.
+// The C# class gets mapped onto the C++ class and behaves as if it is a C# class.
+
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ // ----- Object creation -----
+
+ Console.WriteLine( "Creating some objects:" );
+
+ using (Square s = new Square(10))
+ using (Circle c = new Circle(10))
+ {
+ Console.WriteLine( " Created circle " + c );
+ Console.WriteLine( " Created square " + s );
+
+ // ----- Access a static member -----
+
+ Console.WriteLine( "\nA total of " + Shape.nshapes + " shapes were created" );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.x = 20;
+ c.y = 30;
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.x = -10;
+ shape.y = 5;
+
+ Console.WriteLine( "\nHere is their current position:" );
+ Console.WriteLine( " Circle = (" + c.x + " " + c.y + ")" );
+ Console.WriteLine( " Square = (" + s.x + " " + s.y + ")" );
+
+ // ----- Call some methods -----
+
+ Console.WriteLine( "\nHere are some properties of the shapes:" );
+ Shape[] shapes = {c,s};
+ // for (int i=0; i<shapes.Size; i++)
+ for (int i=0; i<2; i++)
+ {
+ Console.WriteLine( " " + shapes[i].ToString() );
+ Console.WriteLine( " area = " + shapes[i].area() );
+ Console.WriteLine( " perimeter = " + shapes[i].perimeter() );
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+
+ Console.WriteLine( "\nGuess I'll clean up now" );
+
+ }
+ // Note: when this using scope is exited the C# Dispose() methods
+ // are called which in turn call the C++ destructors
+
+ Console.WriteLine( Shape.nshapes + " shapes remain" );
+ Console.WriteLine( "Goodbye" );
+ }
+}
diff --git a/trunk/Examples/csharp/enum/Makefile b/trunk/Examples/csharp/enum/Makefile
new file mode 100644
index 000000000..20f0dd5bb
--- /dev/null
+++ b/trunk/Examples/csharp/enum/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/enum/example-cs.csproj b/trunk/Examples/csharp/enum/example-cs.csproj
new file mode 100644
index 000000000..9d37ce2b4
--- /dev/null
+++ b/trunk/Examples/csharp/enum/example-cs.csproj
@@ -0,0 +1,99 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "color.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Foo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/enum/example-vc.vcproj b/trunk/Examples/csharp/enum/example-vc.vcproj
new file mode 100644
index 000000000..7c0b8ef13
--- /dev/null
+++ b/trunk/Examples/csharp/enum/example-vc.vcproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="example.cxx">
+ </File>
+ <File
+ RelativePath="example_wrap.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/enum/example.cxx b/trunk/Examples/csharp/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/trunk/Examples/csharp/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/trunk/Examples/csharp/enum/example.h b/trunk/Examples/csharp/enum/example.h
new file mode 100644
index 000000000..9119cd9fc
--- /dev/null
+++ b/trunk/Examples/csharp/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/trunk/Examples/csharp/enum/example.i b/trunk/Examples/csharp/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/csharp/enum/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/trunk/Examples/csharp/enum/example.sln b/trunk/Examples/csharp/enum/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/enum/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/enum/runme.cs b/trunk/Examples/csharp/enum/runme.cs
new file mode 100644
index 000000000..42ba896a2
--- /dev/null
+++ b/trunk/Examples/csharp/enum/runme.cs
@@ -0,0 +1,31 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ // Print out the value of some enums
+ Console.WriteLine("*** color ***");
+ Console.WriteLine(" " + color.RED + " = " + (int)color.RED);
+ Console.WriteLine(" " + color.BLUE + " = " + (int)color.BLUE);
+ Console.WriteLine(" " + color.GREEN + " = " + (int)color.GREEN);
+
+ Console.WriteLine("\n*** Foo::speed ***");
+ Console.WriteLine(" Foo::" + Foo.speed.IMPULSE + " = " + (int)Foo.speed.IMPULSE);
+ Console.WriteLine(" Foo::" + Foo.speed.WARP + " = " + (int)Foo.speed.WARP);
+ Console.WriteLine(" Foo::" + Foo.speed.LUDICROUS + " = " + (int)Foo.speed.LUDICROUS);
+
+ Console.WriteLine("\nTesting use of enums with functions\n");
+
+ example.enum_test(color.RED, Foo.speed.IMPULSE);
+ example.enum_test(color.BLUE, Foo.speed.WARP);
+ example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
+
+ Console.WriteLine( "\nTesting use of enum with class method" );
+ Foo f = new Foo();
+
+ f.enum_test(Foo.speed.IMPULSE);
+ f.enum_test(Foo.speed.WARP);
+ f.enum_test(Foo.speed.LUDICROUS);
+ }
+}
diff --git a/trunk/Examples/csharp/extend/Makefile b/trunk/Examples/csharp/extend/Makefile
new file mode 100644
index 000000000..20f0dd5bb
--- /dev/null
+++ b/trunk/Examples/csharp/extend/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/extend/example-cs.csproj b/trunk/Examples/csharp/extend/example-cs.csproj
new file mode 100644
index 000000000..4e8874669
--- /dev/null
+++ b/trunk/Examples/csharp/extend/example-cs.csproj
@@ -0,0 +1,104 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "Employee.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "EmployeeList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Manager.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/extend/example-vc.vcproj b/trunk/Examples/csharp/extend/example-vc.vcproj
new file mode 100644
index 000000000..7c0b8ef13
--- /dev/null
+++ b/trunk/Examples/csharp/extend/example-vc.vcproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="example.cxx">
+ </File>
+ <File
+ RelativePath="example_wrap.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/extend/example.cxx b/trunk/Examples/csharp/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/csharp/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/csharp/extend/example.h b/trunk/Examples/csharp/extend/example.h
new file mode 100644
index 000000000..b27ab9711
--- /dev/null
+++ b/trunk/Examples/csharp/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/trunk/Examples/csharp/extend/example.i b/trunk/Examples/csharp/extend/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/trunk/Examples/csharp/extend/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/trunk/Examples/csharp/extend/example.sln b/trunk/Examples/csharp/extend/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/extend/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/extend/runme.cs b/trunk/Examples/csharp/extend/runme.cs
new file mode 100644
index 000000000..825dcdbca
--- /dev/null
+++ b/trunk/Examples/csharp/extend/runme.cs
@@ -0,0 +1,77 @@
+// This file illustrates the cross language polymorphism using directors.
+
+using System;
+
+// CEO class, which overrides Employee::getPosition().
+
+class CEO : Manager {
+ public CEO(String name) : base(name) {
+ }
+ public override String getPosition() {
+ return "CEO";
+ }
+ // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
+ public void disownMemory() {
+ swigCMemOwn = false;
+ }
+}
+
+
+public class runme
+{
+ static void Main()
+ {
+ // Create an instance of CEO, a class derived from the C# proxy of the
+ // underlying C++ class. The calls to getName() and getPosition() are standard,
+ // the call to getTitle() uses the director wrappers to call CEO.getPosition().
+
+ CEO e = new CEO("Alice");
+ Console.WriteLine( e.getName() + " is a " + e.getPosition() );
+ Console.WriteLine( "Just call her \"" + e.getTitle() + "\"" );
+ Console.WriteLine( "----------------------" );
+
+ // Create a new EmployeeList instance. This class does not have a C++
+ // director wrapper, but can be used freely with other classes that do.
+
+ using (EmployeeList list = new EmployeeList()) {
+
+ // EmployeeList owns its items, so we must surrender ownership of objects we add.
+ e.disownMemory();
+ list.addEmployee(e);
+ Console.WriteLine( "----------------------" );
+
+ // Now we access the first four items in list (three are C++ objects that
+ // EmployeeList's constructor adds, the last is our CEO). The virtual
+ // methods of all these instances are treated the same. For items 0, 1, and
+ // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
+ // getPosition which resolves in C#. The call to getPosition is
+ // slightly different, however, because of the overidden getPosition() call, since
+ // now the object reference has been "laundered" by passing through
+ // EmployeeList as an Employee*. Previously, C# resolved the call
+ // immediately in CEO, but now C# thinks the object is an instance of
+ // class Employee. So the call passes through the
+ // Employee proxy class and on to the C wrappers and C++ director,
+ // eventually ending up back at the C# CEO implementation of getPosition().
+ // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+ // method, which in turn calls getPosition(). This virtual method call
+ // passes down through the C++ director class to the C# implementation
+ // in CEO. All this routing takes place transparently.
+
+ Console.WriteLine( "(position, title) for items 0-3:" );
+
+ Console.WriteLine( " " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" );
+ Console.WriteLine( " " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" );
+ Console.WriteLine( " " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" );
+ Console.WriteLine( " " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" );
+ Console.WriteLine( "----------------------" );
+
+ // The using statement ensures the EmployeeList.Dispose() will be called, which will delete all the Employee*
+ // items it contains. The last item is our CEO, which gets destroyed as well.
+ }
+ Console.WriteLine( "----------------------" );
+
+ // All done.
+
+ Console.WriteLine( "C# exit" );
+ }
+}
diff --git a/trunk/Examples/csharp/funcptr/Makefile b/trunk/Examples/csharp/funcptr/Makefile
new file mode 100644
index 000000000..223300497
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/funcptr/example-cs.csproj b/trunk/Examples/csharp/funcptr/example-cs.csproj
new file mode 100644
index 000000000..5ff0d9da9
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/example-cs.csproj
@@ -0,0 +1,94 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "SWIGTYPE_p_f_int_int__int.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/funcptr/example-vc.vcproj b/trunk/Examples/csharp/funcptr/example-vc.vcproj
new file mode 100644
index 000000000..03047bfb0
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/example-vc.vcproj
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\example.c">
+ </File>
+ <File
+ RelativePath=".\example_wrap.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath=".\example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -csharp &quot;$(InputPath)&quot;
+@echo off
+"
+ Outputs="$(InputName)_wrap.c"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -csharp &quot;$(InputPath)&quot;
+@echo off
+"
+ Outputs="$(InputName)_wrap.c"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/funcptr/example.c b/trunk/Examples/csharp/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int sub(int a, int b) {
+ return a-b;
+}
+
+int mul(int a, int b) {
+ return a*b;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/trunk/Examples/csharp/funcptr/example.h b/trunk/Examples/csharp/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/csharp/funcptr/example.i b/trunk/Examples/csharp/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Wrap a function taking a pointer to a function */
+extern int do_op(int a, int b, int (*op)(int, int));
+
+/* Now install a bunch of "ops" as constants */
+%constant int (*ADD)(int,int) = add;
+%constant int (*SUB)(int,int) = sub;
+%constant int (*MUL)(int,int) = mul;
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/csharp/funcptr/example.sln b/trunk/Examples/csharp/funcptr/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/funcptr/runme.cs b/trunk/Examples/csharp/funcptr/runme.cs
new file mode 100644
index 000000000..ba2e228ea
--- /dev/null
+++ b/trunk/Examples/csharp/funcptr/runme.cs
@@ -0,0 +1,27 @@
+
+using System;
+using System.Reflection;
+
+public class runme {
+
+ public static void Main(String[] args) {
+
+
+ int a = 37;
+ int b = 42;
+
+ // Now call our C function with a bunch of callbacks
+
+ Console.WriteLine( "Trying some C callback functions" );
+ Console.WriteLine( " a = " + a );
+ Console.WriteLine( " b = " + b );
+ Console.WriteLine( " ADD(a,b) = " + example.do_op(a,b,example.ADD) );
+ Console.WriteLine( " SUB(a,b) = " + example.do_op(a,b,example.SUB) );
+ Console.WriteLine( " MUL(a,b) = " + example.do_op(a,b,example.MUL) );
+
+ Console.WriteLine( "Here is what the C callback function classes are called in C#" );
+ Console.WriteLine( " ADD = " + example.ADD.GetType() );
+ Console.WriteLine( " SUB = " + example.SUB.GetType() );
+ Console.WriteLine( " MUL = " + example.MUL.GetType() );
+ }
+}
diff --git a/trunk/Examples/csharp/reference/Makefile b/trunk/Examples/csharp/reference/Makefile
new file mode 100644
index 000000000..20f0dd5bb
--- /dev/null
+++ b/trunk/Examples/csharp/reference/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/reference/example-cs.csproj b/trunk/Examples/csharp/reference/example-cs.csproj
new file mode 100644
index 000000000..e55912bdc
--- /dev/null
+++ b/trunk/Examples/csharp/reference/example-cs.csproj
@@ -0,0 +1,99 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Vector.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "VectorArray.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/reference/example-vc.vcproj b/trunk/Examples/csharp/reference/example-vc.vcproj
new file mode 100644
index 000000000..7c0b8ef13
--- /dev/null
+++ b/trunk/Examples/csharp/reference/example-vc.vcproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="example.cxx">
+ </File>
+ <File
+ RelativePath="example_wrap.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/reference/example.cxx b/trunk/Examples/csharp/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/csharp/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/csharp/reference/example.h b/trunk/Examples/csharp/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/Examples/csharp/reference/example.h
@@ -0,0 +1,26 @@
+/* File : example.h */
+
+class Vector {
+private:
+ double x,y,z;
+public:
+ Vector() : x(0), y(0), z(0) { };
+ Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+ friend Vector operator+(const Vector &a, const Vector &b);
+ char *print();
+};
+
+class VectorArray {
+private:
+ Vector *items;
+ int maxsize;
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ Vector &operator[](int);
+ int size();
+};
+
+
+
+
diff --git a/trunk/Examples/csharp/reference/example.i b/trunk/Examples/csharp/reference/example.i
new file mode 100644
index 000000000..6daa3b1f4
--- /dev/null
+++ b/trunk/Examples/csharp/reference/example.i
@@ -0,0 +1,46 @@
+/* File : example.i */
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *print();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %extend {
+ Vector &get(int index) {
+ return (*$self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*$self)[index] = a;
+ }
+ }
+};
+
+
+
+
diff --git a/trunk/Examples/csharp/reference/example.sln b/trunk/Examples/csharp/reference/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/reference/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/reference/runme.cs b/trunk/Examples/csharp/reference/runme.cs
new file mode 100644
index 000000000..499ddea6a
--- /dev/null
+++ b/trunk/Examples/csharp/reference/runme.cs
@@ -0,0 +1,73 @@
+// This example illustrates the manipulation of C++ references in C#.
+
+using System;
+
+public class runme {
+
+ public static void Main()
+ {
+ Console.WriteLine( "Creating some objects:" );
+ Vector a = new Vector(3,4,5);
+ Vector b = new Vector(10,11,12);
+
+ Console.WriteLine( " Created " + a.print() );
+ Console.WriteLine( " Created " + b.print() );
+
+ // ----- Call an overloaded operator -----
+
+ // This calls the wrapper we placed around
+ //
+ // operator+(const Vector &a, const Vector &)
+ //
+ // It returns a new allocated object.
+
+ Console.WriteLine( "Adding a+b" );
+ Vector c = example.addv(a,b);
+ Console.WriteLine( " a+b = " + c.print() );
+
+ // Note: Unless we free the result, a memory leak will occur if the -noproxy commandline
+ // is used as the proxy classes define finalizers which call the Dispose() method. When
+ // -noproxy is not specified the memory management is controlled by the garbage collector.
+ // You can still call Dispose(). It will free the c++ memory immediately, but not the
+ // C# memory! You then must be careful not to call any member functions as it will
+ // use a NULL c pointer on the underlying c++ object. We set the C# object to null
+ // which will then throw a C# exception should we attempt to use it again.
+ c.Dispose();
+ c = null;
+
+ // ----- Create a vector array -----
+
+ Console.WriteLine( "Creating an array of vectors" );
+ VectorArray va = new VectorArray(10);
+ Console.WriteLine( " va = " + va.ToString() );
+
+ // ----- Set some values in the array -----
+
+ // These operators copy the value of Vector a and Vector b to the vector array
+ va.set(0,a);
+ va.set(1,b);
+
+ // This works, but it would cause a memory leak if -noproxy was used!
+
+ va.set(2,example.addv(a,b));
+
+
+ // Get some values from the array
+
+ Console.WriteLine( "Getting some array values" );
+ for (int i=0; i<5; i++)
+ Console.WriteLine( " va(" + i + ") = " + va.get(i).print() );
+
+ // Watch under resource meter to check on this
+ Console.WriteLine( "Making sure we don't leak memory." );
+ for (int i=0; i<1000000; i++)
+ c = va.get(i%10);
+
+ // ----- Clean up -----
+ // This could be omitted. The garbage collector would then clean up for us.
+ Console.WriteLine( "Cleaning up" );
+ va.Dispose();
+ a.Dispose();
+ b.Dispose();
+ }
+}
diff --git a/trunk/Examples/csharp/simple/Makefile b/trunk/Examples/csharp/simple/Makefile
new file mode 100644
index 000000000..223300497
--- /dev/null
+++ b/trunk/Examples/csharp/simple/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/simple/example-cs.csproj b/trunk/Examples/csharp/simple/example-cs.csproj
new file mode 100644
index 000000000..d801057d9
--- /dev/null
+++ b/trunk/Examples/csharp/simple/example-cs.csproj
@@ -0,0 +1,89 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/simple/example-vc.vcproj b/trunk/Examples/csharp/simple/example-vc.vcproj
new file mode 100644
index 000000000..14f50049b
--- /dev/null
+++ b/trunk/Examples/csharp/simple/example-vc.vcproj
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\example.c"
+ >
+ </File>
+ <File
+ RelativePath=".\example_wrap.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\example.i"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...&#x0D;&#x0A;echo on&#x0D;&#x0A;..\..\..\swig.exe -csharp &quot;$(InputPath)&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
+ Outputs="$(InputName)_wrap.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...&#x0D;&#x0A;echo on&#x0D;&#x0A;..\..\..\swig.exe -csharp &quot;$(InputPath)&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
+ Outputs="$(InputName)_wrap.c"
+ />
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/simple/example.c b/trunk/Examples/csharp/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/csharp/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/trunk/Examples/csharp/simple/example.i b/trunk/Examples/csharp/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/csharp/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/csharp/simple/example.sln b/trunk/Examples/csharp/simple/example.sln
new file mode 100644
index 000000000..9967f7e20
--- /dev/null
+++ b/trunk/Examples/csharp/simple/example.sln
@@ -0,0 +1,26 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|Any CPU
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/simple/runme.cs b/trunk/Examples/csharp/simple/runme.cs
new file mode 100644
index 000000000..26106c65f
--- /dev/null
+++ b/trunk/Examples/csharp/simple/runme.cs
@@ -0,0 +1,25 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ // Call our gcd() function
+
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x,y);
+ Console.WriteLine("The gcd of " + x + " and " + y + " is " + g);
+
+ // Manipulate the Foo global variable
+
+ // Output its current value
+ Console.WriteLine("Foo = " + example.Foo);
+
+ // Change its value
+ example.Foo = 3.1415926;
+
+ // See if the change took effect
+ Console.WriteLine("Foo = " + example.Foo);
+ }
+}
diff --git a/trunk/Examples/csharp/template/Makefile b/trunk/Examples/csharp/template/Makefile
new file mode 100644
index 000000000..3f3bbe6dd
--- /dev/null
+++ b/trunk/Examples/csharp/template/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/template/example-cs.csproj b/trunk/Examples/csharp/template/example-cs.csproj
new file mode 100644
index 000000000..b51122ba6
--- /dev/null
+++ b/trunk/Examples/csharp/template/example-cs.csproj
@@ -0,0 +1,109 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "SWIGTYPE_p_double.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "SWIGTYPE_p_int.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "vecdouble.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "vecint.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/template/example-vc.vcproj b/trunk/Examples/csharp/template/example-vc.vcproj
new file mode 100644
index 000000000..867e694c1
--- /dev/null
+++ b/trunk/Examples/csharp/template/example-vc.vcproj
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="example_wrap.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="example.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off
+"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -c++ -csharp &quot;$(InputPath)&quot;
+@echo off
+"
+ Outputs="$(InputName)_wrap.cxx"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/template/example.h b/trunk/Examples/csharp/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/trunk/Examples/csharp/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/trunk/Examples/csharp/template/example.i b/trunk/Examples/csharp/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/trunk/Examples/csharp/template/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
diff --git a/trunk/Examples/csharp/template/example.sln b/trunk/Examples/csharp/template/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/template/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/template/runme.cs b/trunk/Examples/csharp/template/runme.cs
new file mode 100644
index 000000000..b2a8e6a62
--- /dev/null
+++ b/trunk/Examples/csharp/template/runme.cs
@@ -0,0 +1,39 @@
+// This example illustrates how C++ templates can be used from C#.
+
+using System;
+
+public class runme {
+
+ public static void Main()
+ {
+ // Call some templated functions
+ Console.WriteLine(example.maxint(3,7));
+ Console.WriteLine(example.maxdouble(3.14,2.18));
+
+ // Create some class
+
+ vecint iv = new vecint(100);
+ vecdouble dv = new vecdouble(1000);
+
+ for (int i=0; i<100; i++)
+ iv.setitem(i,2*i);
+
+ for (int i=0; i<1000; i++)
+ dv.setitem(i, 1.0/(i+1));
+
+ {
+ int sum = 0;
+ for (int i=0; i<100; i++)
+ sum = sum + iv.getitem(i);
+
+ Console.WriteLine(sum);
+ }
+
+ {
+ double sum = 0.0;
+ for (int i=0; i<1000; i++)
+ sum = sum + dv.getitem(i);
+ Console.WriteLine(sum);
+ }
+ }
+}
diff --git a/trunk/Examples/csharp/variables/Makefile b/trunk/Examples/csharp/variables/Makefile
new file mode 100644
index 000000000..223300497
--- /dev/null
+++ b/trunk/Examples/csharp/variables/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/trunk/Examples/csharp/variables/example-cs.csproj b/trunk/Examples/csharp/variables/example-cs.csproj
new file mode 100644
index 000000000..f0e015929
--- /dev/null
+++ b/trunk/Examples/csharp/variables/example-cs.csproj
@@ -0,0 +1,99 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "runme"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "runme"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = ".\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References/>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "example.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "examplePINVOKE.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "runme.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "SWIGTYPE_p_int.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "SWIGTYPE_p_Point.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/trunk/Examples/csharp/variables/example-vc.vcproj b/trunk/Examples/csharp/variables/example-vc.vcproj
new file mode 100644
index 000000000..be0dfc742
--- /dev/null
+++ b/trunk/Examples/csharp/variables/example-vc.vcproj
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example-vc"
+ ProjectGUID="{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example-vc.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEVC_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/example-vc.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\example.c">
+ </File>
+ <File
+ RelativePath=".\example_wrap.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <File
+ RelativePath=".\example.i">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -csharp &quot;$(InputPath)&quot;
+@echo off
+"
+ Outputs="$(InputName)_wrap.c"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="echo Invoking SWIG...
+echo on
+..\..\..\swig.exe -csharp &quot;$(InputPath)&quot;
+@echo off
+"
+ Outputs="$(InputName)_wrap.c"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/trunk/Examples/csharp/variables/example.c b/trunk/Examples/csharp/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/csharp/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/csharp/variables/example.h b/trunk/Examples/csharp/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/csharp/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/csharp/variables/example.i b/trunk/Examples/csharp/variables/example.i
new file mode 100644
index 000000000..591b871ed
--- /dev/null
+++ b/trunk/Examples/csharp/variables/example.i
@@ -0,0 +1,49 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/csharp/variables/example.sln b/trunk/Examples/csharp/variables/example.sln
new file mode 100644
index 000000000..28b9851b0
--- /dev/null
+++ b/trunk/Examples/csharp/variables/example.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/trunk/Examples/csharp/variables/runme.cs b/trunk/Examples/csharp/variables/runme.cs
new file mode 100644
index 000000000..3d19b6aac
--- /dev/null
+++ b/trunk/Examples/csharp/variables/runme.cs
@@ -0,0 +1,82 @@
+// This example illustrates global variable access from C#.
+
+using System;
+using System.Reflection;
+
+public class runme {
+
+ public static void Main() {
+
+ // Try to set the values of some global variables
+
+ example.ivar = 42;
+ example.svar = -31000;
+ example.lvar = 65537;
+ example.uivar = 123456;
+ example.usvar = 61000;
+ example.ulvar = 654321;
+ example.scvar = -13;
+ example.ucvar = 251;
+ example.cvar = 'S';
+ example.fvar = (float)3.14159;
+ example.dvar = 2.1828;
+ example.strvar = "Hello World";
+ example.iptrvar= example.new_int(37);
+ example.ptptr = example.new_Point(37,42);
+ example.name = "Bill";
+
+ // Now print out the values of the variables
+
+ Console.WriteLine( "Variables (values printed from C#)" );
+
+ Console.WriteLine( "ivar =" + example.ivar );
+ Console.WriteLine( "svar =" + example.svar );
+ Console.WriteLine( "lvar =" + example.lvar );
+ Console.WriteLine( "uivar =" + example.uivar );
+ Console.WriteLine( "usvar =" + example.usvar );
+ Console.WriteLine( "ulvar =" + example.ulvar );
+ Console.WriteLine( "scvar =" + example.scvar );
+ Console.WriteLine( "ucvar =" + example.ucvar );
+ Console.WriteLine( "fvar =" + example.fvar );
+ Console.WriteLine( "dvar =" + example.dvar );
+ Console.WriteLine( "cvar =" + example.cvar );
+ Console.WriteLine( "strvar =" + example.strvar );
+ Console.WriteLine( "cstrvar =" + example.cstrvar );
+ Console.WriteLine( "iptrvar =" + example.iptrvar );
+ Console.WriteLine( "name =" + example.name );
+ Console.WriteLine( "ptptr =" + example.ptptr + example.Point_print(example.ptptr) );
+ Console.WriteLine( "pt =" + example.pt + example.Point_print(example.pt) );
+
+ Console.WriteLine( "\nVariables (values printed from C)" );
+
+ example.print_vars();
+
+ Console.WriteLine( "\nNow I'm going to try and modify some read only variables" );
+ Console.WriteLine( "\nChecking that the read only variables are readonly..." );
+
+ example ex = new example();
+ Type t = ex.GetType();
+
+ Console.WriteLine( " 'path'" );
+ PropertyInfo pi = t.GetProperty("path");
+ if (pi.CanWrite)
+ Console.WriteLine("Oh dear this variable is not read only\n");
+ else
+ Console.WriteLine("Good.");
+
+ Console.WriteLine( " 'status'" );
+ pi = t.GetProperty("status");
+ if (pi.CanWrite)
+ Console.WriteLine("Oh dear this variable is not read only");
+ else
+ Console.WriteLine("Good.");
+
+ Console.WriteLine( "\nI'm going to try and update a structure variable.\n" );
+
+ example.pt = example.ptptr;
+
+ Console.WriteLine( "The new value is" );
+ example.pt_print();
+ Console.WriteLine( "You should see the value" + example.Point_print(example.ptptr) );
+ }
+}
diff --git a/trunk/Examples/guile/Makefile.in b/trunk/Examples/guile/Makefile.in
new file mode 100644
index 000000000..a11095599
--- /dev/null
+++ b/trunk/Examples/guile/Makefile.in
@@ -0,0 +1,40 @@
+# Makefile for Guile. Used by all of the example programs.
+
+subdirs = simple matrix port constants multimap multivalue
+
+top_srcdir = @top_srcdir@
+SWIG = ../$(top_srcdir)/preinst-swig
+CC = @CC@
+CXX = @CXX@
+CFLAGS = @PLATFLAGS@
+GUILEINCLUDE = @GUILEINCLUDE@
+GUILELINK = @GUILELINK@
+SWIGOPT =
+
+WRAP = $(IFILE:.i=_wrap.c)
+CXXWRAP = $(IFILE:.i=_wrap.cxx)
+
+SO = @SO@
+
+all:
+ for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done
+
+clean::
+ for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done
+ rm -f *~ .~*
+
+guile_clean:
+ rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core my-guile $(TARGET)
+
+# This is meant to be used w/ "make -f ../Makefile" from subdirs.
+# Doesn't make sense to use it from here.
+
+sub-all::
+ $(SWIG) -guile $(SWIGOPT) $(IFILE)
+ $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK)
+
+sub-all-cxx::
+ $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE)
+ $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILEINCLUDE) $(GUILELINK)
+
+# Makefile ends here
diff --git a/trunk/Examples/guile/README b/trunk/Examples/guile/README
new file mode 100644
index 000000000..7d726619e
--- /dev/null
+++ b/trunk/Examples/guile/README
@@ -0,0 +1,14 @@
+This directory contains examples for Guile.
+
+constants -- handling #define and %constant literals
+matrix -- a very simple Matrix example
+multimap -- typemaps with multiple sub-types
+multivalue -- using the %values_as_list directive
+port -- scheme ports as temporary FILE streams
+simple -- the simple example from the user manual
+std_vector -- C++ STL vector<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.
+
diff --git a/trunk/Examples/guile/check.list b/trunk/Examples/guile/check.list
new file mode 100644
index 000000000..7ccd0730a
--- /dev/null
+++ b/trunk/Examples/guile/check.list
@@ -0,0 +1,6 @@
+# see top-level Makefile.in
+constants
+simple
+port
+multimap
+multivalue
diff --git a/trunk/Examples/guile/constants/Makefile b/trunk/Examples/guile/constants/Makefile
new file mode 100644
index 000000000..70243c75e
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/constants/constants.scm b/trunk/Examples/guile/constants/constants.scm
new file mode 100644
index 000000000..5220150f1
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/constants/example.i b/trunk/Examples/guile/constants/example.i
new file mode 100644
index 000000000..0b602e5ab
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/matrix/Makefile b/trunk/Examples/guile/matrix/Makefile
new file mode 100644
index 000000000..5df2c6515
--- /dev/null
+++ b/trunk/Examples/guile/matrix/Makefile
@@ -0,0 +1,18 @@
+SRCS = matrix.c vector.c
+TARGET = matrix
+IFILE = package.i
+MKDIR = ..
+
+
+all::
+ $(MAKE) -f $(MKDIR)/Makefile \
+ SRCS='$(SRCS)' \
+ TARGET=$(TARGET) \
+ IFILE=$(IFILE) \
+ MODULE=$(MODULE) \
+ sub-all
+
+clean::
+ $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
+
+check: all
diff --git a/trunk/Examples/guile/matrix/README b/trunk/Examples/guile/matrix/README
new file mode 100644
index 000000000..dc1957719
--- /dev/null
+++ b/trunk/Examples/guile/matrix/README
@@ -0,0 +1,13 @@
+Matrix example. To run the example, execute the program 'matrix' and
+type the following :
+
+ (load "matrix.scm")
+ (do-test 0)
+
+Alternatively, use the command-line:
+
+ ./matrix -e do-test -s matrix.scm
+
+Or, if your operating system is spiffy enough:
+
+ ./matrix.scm
diff --git a/trunk/Examples/guile/matrix/main.c b/trunk/Examples/guile/matrix/main.c
new file mode 100644
index 000000000..88209aea7
--- /dev/null
+++ b/trunk/Examples/guile/matrix/main.c
@@ -0,0 +1,24 @@
+#include <tcl.h>
+extern int matrix_init(Tcl_Interp *); /* Init function from matrix.i */
+
+int main() {
+
+ int code;
+ char input[1024];
+ Tcl_Interp *interp;
+
+ interp = Tcl_CreateInterp();
+
+ /* Initialize the wrappers */
+
+ if (matrix_init(interp) == TCL_ERROR)
+ exit(0);
+
+ fprintf(stdout,"matrix > ");
+ while(fgets(input, 1024, stdin) != NULL) {
+ code = Tcl_Eval(interp, input);
+ fprintf(stdout,"%s\n",interp->result);
+ fprintf(stdout,"matrix > ");
+ }
+}
+
diff --git a/trunk/Examples/guile/matrix/matrix.c b/trunk/Examples/guile/matrix/matrix.c
new file mode 100644
index 000000000..6ce10098b
--- /dev/null
+++ b/trunk/Examples/guile/matrix/matrix.c
@@ -0,0 +1,61 @@
+/* FILE : matrix.c : some simple 4x4 matrix operations */
+#include <stdlib.h>
+#include <stdio.h>
+
+double **new_matrix() {
+
+ int i;
+ double **M;
+
+ M = (double **) malloc(4*sizeof(double *));
+ M[0] = (double *) malloc(16*sizeof(double));
+
+ for (i = 0; i < 4; i++) {
+ M[i] = M[0] + 4*i;
+ }
+ return M;
+}
+
+void destroy_matrix(double **M) {
+
+ free(M[0]);
+ free(M);
+
+}
+
+void print_matrix(double **M) {
+
+ int i,j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ printf("%10g ", M[i][j]);
+ }
+ printf("\n");
+ }
+
+}
+
+void mat_mult(double **m1, double **m2, double **m3) {
+
+ int i,j,k;
+ double temp[4][4];
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++) {
+ temp[i][j] = 0;
+ for (k = 0; k < 4; k++)
+ temp[i][j] += m1[i][k]*m2[k][j];
+ }
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ m3[i][j] = temp[i][j];
+}
+
+
+
+
+
+
+
diff --git a/trunk/Examples/guile/matrix/matrix.i b/trunk/Examples/guile/matrix/matrix.i
new file mode 100644
index 000000000..d61f0dc55
--- /dev/null
+++ b/trunk/Examples/guile/matrix/matrix.i
@@ -0,0 +1,36 @@
+//
+// FILE : matrix.i
+
+%{
+
+void set_m(double **M, int i, int j, double val) {
+ M[i][j] = val;
+}
+
+double get_m(double **M, int i, int j) {
+ return M[i][j];
+}
+%}
+
+%inline {
+/*** Matrix Operations ***/
+
+extern double **new_matrix();
+/* Creates a new matrix and returns a pointer to it */
+
+extern void destroy_matrix(double **M);
+/* Destroys the matrix M */
+
+extern void print_matrix(double **M);
+/* Prints out the matrix M */
+
+extern void set_m(double **M, int i, int j, double val);
+/* Sets M[i][j] = val*/
+
+extern double get_m(double **M, int i, int j);
+/* Returns M[i][j] */
+
+extern void mat_mult(double **a, double **b, double **c);
+/* Multiplies matrix a by b and places the result in c*/
+
+}
diff --git a/trunk/Examples/guile/matrix/matrix.scm b/trunk/Examples/guile/matrix/matrix.scm
new file mode 100644
index 000000000..18e52842d
--- /dev/null
+++ b/trunk/Examples/guile/matrix/matrix.scm
@@ -0,0 +1,210 @@
+#!./matrix \
+-e do-test -s
+!#
+;;; Authors: David Beazley <beazley@cs.uchicago.edu>, 1999
+;;; Martin Froehlich <MartinFroehlich@ACM.org>, 2000
+;;;
+;;; PURPOSE OF THIS FILE: This file is an example for how to use the guile
+;;; scripting options with a little more than trivial script. Example
+;;; derived from David Beazley's matrix evaluation example. David
+;;; Beazley's annotation: >>Guile script for testing out matrix
+;;; operations. Disclaimer : I'm not a very good scheme
+;;; programmer<<. Martin Froehlich's annotation: >>I'm not a very good
+;;; scheme programmer, too<<.
+;;;
+;;; Explanation: The three lines at the beginning of this script are
+;;; telling the kernel to load the enhanced guile interpreter named
+;;; "matrix"; to execute the function "do-test" (-e option) after loading
+;;; this script (-s option). There are a lot more options wich allow for
+;;; even finer tuning. SEE ALSO: Section "Guile Scripts" in the "Guile
+;;; reference manual -- Part I: Preliminaries".
+;;;
+;;;
+;;; This program is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+;;; Create a zero matrix
+
+(define (zero M)
+ (define (zero-loop M i j)
+ (if (< i 4)
+ (if (< j 4) (begin
+ (set-m M i j 0.0)
+ (zero-loop M i (+ j 1)))
+ (zero-loop M (+ i 1) 0))))
+ (zero-loop M 0 0))
+
+;;; Create an identity matrix
+
+(define (identity M)
+ (define (iloop M i)
+ (if (< i 4) (begin
+ (set-m M i i 1.0)
+ (iloop M (+ i 1)))))
+ (zero M)
+ (iloop M 0))
+
+;;; Rotate around x axis
+
+(define (rotx M r)
+ (define temp (new-matrix))
+ (define rd (/ (* r 3.14159) 180.0))
+ (zero temp)
+ (set-m temp 0 0 1.0)
+ (set-m temp 1 1 (cos rd))
+ (set-m temp 1 2 (- 0 (sin rd)))
+ (set-m temp 2 1 (sin rd))
+ (set-m temp 2 2 (cos rd))
+ (set-m temp 3 3 1.0)
+ (mat-mult M temp M)
+ (destroy-matrix temp))
+
+;;; Rotate around y axis
+
+(define (roty M r)
+ (define temp (new-matrix))
+ (define rd (/ (* r 3.14159) 180.0))
+ (zero temp)
+ (set-m temp 1 1 1.0)
+ (set-m temp 0 0 (cos rd))
+ (set-m temp 0 2 (sin rd))
+ (set-m temp 2 0 (- 0 (sin rd)))
+ (set-m temp 2 2 (cos rd))
+ (set-m temp 3 3 1.0)
+ (mat-mult M temp M)
+ (destroy-matrix temp))
+
+;;; Rotate around z axis
+
+(define (rotz M r)
+ (define temp (new-matrix))
+ (define rd (/ (* r 3.14159) 180.0))
+ (zero temp)
+ (set-m temp 0 0 (cos rd))
+ (set-m temp 0 1 (- 0 (sin rd)))
+ (set-m temp 1 0 (sin rd))
+ (set-m temp 1 1 (cos rd))
+ (set-m temp 2 2 1.0)
+ (set-m temp 3 3 1.0)
+ (mat-mult M temp M)
+ (destroy-matrix temp))
+
+;;; Scale a matrix
+
+(define (scale M s)
+ (define temp (new-matrix))
+ (define (sloop m i s)
+ (if (< i 4) (begin
+ (set-m m i i s)
+ (sloop m (+ i 1) s))))
+ (zero temp)
+ (sloop temp 0 s)
+ (mat-mult M temp M)
+ (destroy-matrix temp))
+
+;;; Make a matrix with random elements
+
+(define (randmat M)
+ (define (rand-loop M i j)
+ (if (< i 4)
+ (if (< j 4)
+ (begin
+ (set-m M i j (drand48))
+ (rand-loop M i (+ j 1)))
+ (rand-loop M (+ i 1) 0))))
+ (rand-loop M 0 0))
+
+;;; stray definitions collected here
+
+(define (rot-test M v t i)
+ (if (< i 360) (begin
+ (rotx M 1)
+ (rotz M -0.5)
+ (transform M v t)
+ (rot-test M v t (+ i 1)))))
+
+(define (create-matrix) ; Create some matrices
+ (let loop ((i 0) (result '()))
+ (if (< i 200)
+ (loop (+ i 1) (cons (new-matrix) result))
+ result)))
+
+(define (add-mat M ML)
+ (define (add-two m1 m2 i j)
+ (if (< i 4)
+ (if (< j 4)
+ (begin
+ (set-m m1 i j (+ (get-m m1 i j) (get-m m2 i j)))
+ (add-two m1 m2 i (+ j 1)))
+ (add-two m1 m2 (+ i 1) 0))))
+ (if (null? ML) () (begin
+ (add-two M (car ML) 0 0)
+ (add-mat M (cdr ML)))))
+
+(define (cleanup ML)
+ (if (null? ML) () (begin
+ (destroy-matrix (car ML))
+ (cleanup (cdr ML)))))
+
+(define (make-random ML) ; Put random values in them
+ (if (null? ML) () (begin
+ (randmat (car ML))
+ (make-random (cdr ML)))))
+
+(define (mul-mat m ML)
+ (if (null? ML) () (begin
+ (mat-mult m (car ML) m)
+ (mul-mat m (cdr ML)))))
+
+;;; Now we'll hammer on things a little bit just to make
+;;; sure everything works.
+(define M1 (new-matrix)) ; a matrix
+(define v (createv 1 2 3 4)) ; a vector
+(define t (createv 0 0 0 0)) ; the zero-vector
+(define M-list (create-matrix)) ; get list of marices
+(define M (new-matrix)) ; yet another matrix
+
+(display "variables defined\n")
+(define (do-test x)
+ (display "Testing matrix program...\n")
+
+ (identity M1)
+ (print-matrix M1)
+ (display "Rotate-x 45 degrees\n")
+ (rotx M1 45)
+ (print-matrix M1)
+ (display "Rotate y 30 degrees\n")
+ (roty M1 30)
+ (print-matrix M1)
+ (display "Rotate z 15 degrees\n")
+ (rotz M1 15)
+ (print-matrix M1)
+ (display "Scale 0.5\n")
+ (scale M1 0.5)
+ (print-matrix M1)
+
+ ;; Rotating ...
+ (display "Rotating...\n")
+ (rot-test M1 v t 0)
+ (printv t)
+
+ (make-random M-list)
+
+ (zero M1)
+
+ (display "Adding them together (in Guile)\n")
+
+ (add-mat M1 M-list)
+ (print-matrix M1)
+
+ (display "Doing 200 multiplications (mostly in C)\n")
+ (randmat M)
+
+ (mul-mat M M-list)
+
+ (display "Cleaning up\n")
+
+ (cleanup M-list))
+
+;;; matrix.scm ends here
diff --git a/trunk/Examples/guile/matrix/package.i b/trunk/Examples/guile/matrix/package.i
new file mode 100644
index 000000000..aaa55511c
--- /dev/null
+++ b/trunk/Examples/guile/matrix/package.i
@@ -0,0 +1,20 @@
+// FILE : package.i
+// See the SWIG users manual
+
+/*** Matrix and vector package ***/
+
+%module Matrix
+%{
+#include <math.h>
+%}
+
+%include guilemain.i
+%include matrix.i
+%include vector.i
+
+// Include the math library so we can get some random numbers and
+// other stuff
+
+%include math.i
+
+extern double drand48();
diff --git a/trunk/Examples/guile/matrix/vector.c b/trunk/Examples/guile/matrix/vector.c
new file mode 100644
index 000000000..3012993f8
--- /dev/null
+++ b/trunk/Examples/guile/matrix/vector.c
@@ -0,0 +1,44 @@
+/* File : vector.c */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "vector.h"
+
+Vector *createv(double x, double y, double z, double w) {
+
+ Vector *n;
+ n = (Vector *) malloc(sizeof(Vector));
+ n->x = x;
+ n->y = y;
+ n->z = z;
+ n->w = w;
+ return n;
+
+}
+
+/* Destroy vector */
+
+void destroyv(Vector *v) {
+ free(v);
+}
+
+/* Print a vector */
+
+void printv(Vector *v) {
+
+ printf("x = %g, y = %g, z = %g, w = %g\n", v->x, v->y, v->z, v->w);
+
+}
+
+/* Do a transformation */
+void transform(double **m, Vector *v, Vector *r) {
+
+ r->x = m[0][0]*v->x + m[0][1]*v->y + m[0][2]*v->z + m[0][3]*v->w;
+ r->y = m[1][0]*v->x + m[1][1]*v->y + m[1][2]*v->z + m[1][3]*v->w;
+ r->z = m[2][0]*v->x + m[2][1]*v->y + m[2][2]*v->z + m[2][3]*v->w;
+ r->w = m[3][0]*v->x + m[3][1]*v->y + m[3][2]*v->z + m[3][3]*v->w;
+
+}
+
+
+
diff --git a/trunk/Examples/guile/matrix/vector.h b/trunk/Examples/guile/matrix/vector.h
new file mode 100644
index 000000000..a6b5f3574
--- /dev/null
+++ b/trunk/Examples/guile/matrix/vector.h
@@ -0,0 +1,10 @@
+
+#include <math.h>
+
+typedef struct {
+ double x;
+ double y;
+ double z;
+ double w;
+} Vector;
+
diff --git a/trunk/Examples/guile/matrix/vector.i b/trunk/Examples/guile/matrix/vector.i
new file mode 100644
index 000000000..b6c2ef975
--- /dev/null
+++ b/trunk/Examples/guile/matrix/vector.i
@@ -0,0 +1,22 @@
+//
+// FILE : vector.i
+
+%{
+#include "vector.h"
+%}
+
+%inline {
+
+extern Vector *createv(double x,double y,double z,double w);
+/* Creates a new vector v(x,y,z,w) */
+
+extern void destroyv(Vector *v);
+/* Destroys the vector v */
+
+extern void printv(Vector *v);
+/* Prints out the vector v */
+
+extern void transform(double **T, Vector *v, Vector *t);
+/* Transforms vector c to vector t by M*v --> t */
+
+}
diff --git a/trunk/Examples/guile/multimap/Makefile b/trunk/Examples/guile/multimap/Makefile
new file mode 100644
index 000000000..dc9c66d1f
--- /dev/null
+++ b/trunk/Examples/guile/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+
+check: all
diff --git a/trunk/Examples/guile/multimap/example.c b/trunk/Examples/guile/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/guile/multimap/example.i b/trunk/Examples/guile/multimap/example.i
new file mode 100644
index 000000000..7337d1e9e
--- /dev/null
+++ b/trunk/Examples/guile/multimap/example.i
@@ -0,0 +1,87 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in) (int argc, char *argv[]) {
+ int i;
+ SCM *v;
+ if (!(SCM_NIMP($input) && SCM_VECTORP($input))) {
+ SWIG_exception(SWIG_ValueError, "Expecting a vector");
+ return 0;
+ }
+ $1 = SCM_LENGTH($input);
+ if ($1 == 0) {
+ SWIG_exception(SWIG_ValueError, "Vector must contain at least 1 element");
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ v = SCM_VELTS($input);
+ for (i = 0; i < $1; i++) {
+ if (!(SCM_NIMP(v[i]) && SCM_STRINGP(v[i]))) {
+ free($2);
+ SWIG_exception(SWIG_ValueError, "Vector items must be strings");
+ return 0;
+ }
+ $2[i] = SCM_CHARS(v[i]);
+ }
+ $2[i] = 0;
+}
+
+%typemap(freearg) (int argc, char *argv[]) {
+ free($2);
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+ if (!(SCM_NIMP($input) && SCM_STRINGP($input))) {
+ SWIG_exception(SWIG_ValueError, "Expecting a string");
+ }
+ $1 = SCM_CHARS($input);
+ $2 = SCM_LENGTH($input);
+}
+
+extern int count(char *bytes, int len, char c);
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len) {
+ size_t temp;
+ $1 = gh_scm2newstr($input,&temp);
+ $2 = temp;
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(argout) (char *str, int len) {
+ SWIG_APPEND_VALUE(gh_str2scm($1,$2));
+ if ($1) scm_must_free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/trunk/Examples/guile/multimap/runme.scm b/trunk/Examples/guile/multimap/runme.scm
new file mode 100644
index 000000000..edc197259
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/multivalue/Makefile b/trunk/Examples/guile/multivalue/Makefile
new file mode 100644
index 000000000..dc9c66d1f
--- /dev/null
+++ b/trunk/Examples/guile/multivalue/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+
+check: all
diff --git a/trunk/Examples/guile/multivalue/example.c b/trunk/Examples/guile/multivalue/example.c
new file mode 100644
index 000000000..c9ebad1ae
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/multivalue/example.i b/trunk/Examples/guile/multivalue/example.i
new file mode 100644
index 000000000..135389487
--- /dev/null
+++ b/trunk/Examples/guile/multivalue/example.i
@@ -0,0 +1,32 @@
+/* -*- c -*- */
+
+%module example;
+
+%{
+void divide_l(int a, int b, int *quotient_p, int *remainder_p);
+void divide_v(int a, int b, int *quotient_p, int *remainder_p);
+void divide_mv(int a, int b, int *quotient_p, int *remainder_p);
+%}
+
+/* Multiple values as lists. By default, if more than one value is to
+be returned, a list of the values is created and returned; to switch
+back to this behavior, use: */
+%values_as_list;
+
+void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
+
+/* Multiple values as vectors. By issueing: */
+%values_as_vector;
+/* vectors instead of lists will be used. */
+
+void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
+
+/* Multiple values for multiple-value continuations.
+ (This is the most elegant way.) By issueing: */
+%multiple_values;
+/* multiple values are passed to the multiple-value
+ continuation, as created by `call-with-values' or the
+ convenience macro `receive'. (See the Scheme file.) */
+
+void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
+
diff --git a/trunk/Examples/guile/multivalue/runme.scm b/trunk/Examples/guile/multivalue/runme.scm
new file mode 100644
index 000000000..73eb5affa
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/port/Makefile b/trunk/Examples/guile/port/Makefile
new file mode 100644
index 000000000..824f3f823
--- /dev/null
+++ b/trunk/Examples/guile/port/Makefile
@@ -0,0 +1,18 @@
+SRCS = port.c
+TARGET = port
+IFILE = port.i
+MKDIR = ..
+
+
+all::
+ $(MAKE) -f $(MKDIR)/Makefile \
+ SRCS='$(SRCS)' \
+ TARGET=$(TARGET) \
+ IFILE=$(IFILE) \
+ MODULE=$(MODULE) \
+ sub-all
+
+clean::
+ $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
+
+check: all
diff --git a/trunk/Examples/guile/port/README b/trunk/Examples/guile/port/README
new file mode 100644
index 000000000..5ed0199e2
--- /dev/null
+++ b/trunk/Examples/guile/port/README
@@ -0,0 +1,2 @@
+This example illustrates the translation from Scheme file ports to
+temporary FILE streams. Read the source and run ./port -s port.scm
diff --git a/trunk/Examples/guile/port/port.c b/trunk/Examples/guile/port/port.c
new file mode 100644
index 000000000..95867b687
--- /dev/null
+++ b/trunk/Examples/guile/port/port.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <errno.h>
+
+void print_int(FILE *f, int i)
+{
+ if (fprintf(f, "%d\n", i)<0)
+ perror("print_int");
+}
+
+int read_int(FILE *f)
+{
+ int i;
+ if (fscanf(f, "%d", &i)!=1) {
+ fprintf(stderr, "read_int: error reading from file\n");
+ perror("read_int");
+ }
+ return i;
+}
diff --git a/trunk/Examples/guile/port/port.i b/trunk/Examples/guile/port/port.i
new file mode 100644
index 000000000..eb7539173
--- /dev/null
+++ b/trunk/Examples/guile/port/port.i
@@ -0,0 +1,15 @@
+%module port
+
+%include guilemain.i
+
+/* Include the required FILE * typemaps */
+%include ports.i
+
+%{
+#include <stdio.h>
+%}
+
+%inline %{
+void print_int(FILE *f, int i);
+int read_int(FILE *f);
+%}
diff --git a/trunk/Examples/guile/port/port.scm b/trunk/Examples/guile/port/port.scm
new file mode 100644
index 000000000..68e9b8e85
--- /dev/null
+++ b/trunk/Examples/guile/port/port.scm
@@ -0,0 +1,32 @@
+;; Call with standard output
+(print-int (current-output-port) 314159)
+
+;; Redirection to a file. Note that the port is automatically flushed
+;; (via force-output) before calling the C function, and that the C
+;; function gets a temporary "FILE" stream, which is closed after the
+;; call. So you can simply mix Scheme and C output.
+(with-output-to-file "test.out"
+ (lambda ()
+ (display 4711)
+ (newline)
+ (print-int (current-output-port) 314159)
+ (display 815)
+ (newline)))
+
+;; Redirection to a string or soft port won't work --
+;; we can only handle file ports.
+(catch #t
+ (lambda ()
+ (with-output-to-string
+ (lambda ()
+ (print-int (current-output-port) 314159))))
+ (lambda args
+ (write args) (newline)))
+
+;; Read from a file port. Note that it is a bad idea to mix Scheme and
+;; C input because of buffering.
+(with-input-from-file "test.out"
+ (lambda ()
+ (display (read-int (current-input-port)))
+ (newline)))
+
diff --git a/trunk/Examples/guile/simple/Makefile b/trunk/Examples/guile/simple/Makefile
new file mode 100644
index 000000000..702b5bb96
--- /dev/null
+++ b/trunk/Examples/guile/simple/Makefile
@@ -0,0 +1,19 @@
+SRCS = example.c
+TARGET = my-guile
+IFILE = example.i
+MKDIR = ..
+
+all: $(TARGET)
+
+$(TARGET):
+ $(MAKE) -f $(MKDIR)/Makefile \
+ SRCS='$(SRCS)' \
+ TARGET=$(TARGET) \
+ IFILE=$(IFILE) \
+ sub-all
+
+clean::
+ $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
+
+check: $(TARGET)
+ ./$(TARGET) -s example.scm > /dev/null
diff --git a/trunk/Examples/guile/simple/README b/trunk/Examples/guile/simple/README
new file mode 100644
index 000000000..982216eaa
--- /dev/null
+++ b/trunk/Examples/guile/simple/README
@@ -0,0 +1,9 @@
+A very simple example.
+
+To run it, start the program 'my-guile' and type:
+
+ (load "example.scm")
+
+Alternatively, you can use the shell command:
+
+ ./my-guile -s example.scm
diff --git a/trunk/Examples/guile/simple/example.c b/trunk/Examples/guile/simple/example.c
new file mode 100644
index 000000000..dcafc4dc4
--- /dev/null
+++ b/trunk/Examples/guile/simple/example.c
@@ -0,0 +1,21 @@
+/* Simple example from documentation */
+/* File : example.c */
+
+#include <time.h>
+
+double My_variable = 3.0;
+
+int fact(int n) {
+ if (n <= 1) return 1;
+ else return n*fact(n-1);
+}
+
+int mod(int n, int m) {
+ return (n % m);
+}
+
+char *get_time() {
+ long ltime;
+ time(&ltime);
+ return ctime(&ltime);
+}
diff --git a/trunk/Examples/guile/simple/example.i b/trunk/Examples/guile/simple/example.i
new file mode 100644
index 000000000..1a9930a14
--- /dev/null
+++ b/trunk/Examples/guile/simple/example.i
@@ -0,0 +1,14 @@
+/* File : example.i */
+%module Example
+%{
+/* Put headers and other declarations here */
+%}
+
+%inline %{
+extern double My_variable;
+extern int fact(int);
+extern int mod(int n, int m);
+extern char *get_time();
+%}
+
+%include guile/guilemain.i
diff --git a/trunk/Examples/guile/simple/example.scm b/trunk/Examples/guile/simple/example.scm
new file mode 100644
index 000000000..9408b1aa6
--- /dev/null
+++ b/trunk/Examples/guile/simple/example.scm
@@ -0,0 +1,28 @@
+;;; example.scm
+
+(define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'?
+ (for-each display args)
+ (newline))
+
+(mdisplay-newline (get-time) "My variable = " (My-variable))
+
+(do ((i 0 (1+ i)))
+ ((= 14 i))
+ (mdisplay-newline i " factorial is " (fact i)))
+
+(define (mods i imax j jmax)
+ (if (< i imax)
+ (if (< j jmax)
+ (begin
+ (My-variable (+ (My-variable) (mod i j)))
+ (mods i imax (+ j 1) jmax))
+ (mods (+ i 1) imax 1 jmax))))
+
+(mods 1 150 1 150)
+
+(mdisplay-newline "My-variable = " (My-variable))
+
+(exit (and (= 1932053504 (fact 13))
+ (= 745470.0 (My-variable))))
+
+;;; example.scm ends here
diff --git a/trunk/Examples/guile/std_vector/Makefile b/trunk/Examples/guile/std_vector/Makefile
new file mode 100644
index 000000000..2733fb017
--- /dev/null
+++ b/trunk/Examples/guile/std_vector/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+
+check: all
diff --git a/trunk/Examples/guile/std_vector/example.h b/trunk/Examples/guile/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/std_vector/example.i b/trunk/Examples/guile/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/trunk/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/trunk/Examples/guile/std_vector/runme.scm b/trunk/Examples/guile/std_vector/runme.scm
new file mode 100644
index 000000000..77443a156
--- /dev/null
+++ b/trunk/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/trunk/Examples/index.html b/trunk/Examples/index.html
new file mode 100644
index 000000000..66885b6a0
--- /dev/null
+++ b/trunk/Examples/index.html
@@ -0,0 +1,52 @@
+<html>
+<head>
+<title>SWIG Examples</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Examples</H1>
+
+<p>
+Welcome to the browsable SWIG Examples directory. This directory contains a
+collection of examples that illustrate various SWIG features for a variety
+of target languages. First, it is important to cover a few preliminaries:
+
+<ul>
+<li>All of the examples depend on the file <tt>Examples/Makefile</tt>
+found within the SWIG distribution. This file is created by
+'configure' and usually requires no modifications. However, if you
+have an usual installation of packages or experience compilation
+problems, you may need to make a few modifications.
+
+<p>
+<li>The examples directory is a work in progress and will probably remain
+somewhat incomplete. At this time, the Examples directory is somewhat sparse
+since it is being rewritten and reoganized.
+
+<p>
+<li>
+The SWIG user manual also contains a large variety of examples.
+</ul>
+
+
+<h2>Fundamentals</h2>
+
+Follow one of these links to see some simple examples for a specific target
+language:
+
+<ul>
+<li><a href="python/index.html">Python</a>
+<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/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.
+
+</body>
+</html>
+
+
diff --git a/trunk/Examples/java/callback/Makefile b/trunk/Examples/java/callback/Makefile
new file mode 100644
index 000000000..14c301703
--- /dev/null
+++ b/trunk/Examples/java/callback/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/callback/example.cxx b/trunk/Examples/java/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/java/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/java/callback/example.h b/trunk/Examples/java/callback/example.h
new file mode 100644
index 000000000..1a0e8c432
--- /dev/null
+++ b/trunk/Examples/java/callback/example.h
@@ -0,0 +1,23 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/trunk/Examples/java/callback/example.i b/trunk/Examples/java/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/trunk/Examples/java/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/trunk/Examples/java/callback/index.html b/trunk/Examples/java/callback/index.html
new file mode 100644
index 000000000..c25452018
--- /dev/null
+++ b/trunk/Examples/java/callback/index.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+<title>SWIG:Examples:java:callback</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/extend/</tt>
+<hr>
+
+<H2>Implementing C++ callbacks in Java</H2>
+
+<p>
+This example illustrates how to use directors to implement C++ callbacks in Java.
+</p>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/java/callback/runme.java b/trunk/Examples/java/callback/runme.java
new file mode 100644
index 000000000..4090f0ac3
--- /dev/null
+++ b/trunk/Examples/java/callback/runme.java
@@ -0,0 +1,56 @@
+public class runme
+{
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println("Adding and calling a normal C++ callback");
+ System.out.println("----------------------------------------");
+
+ Caller caller = new Caller();
+ Callback callback = new Callback();
+
+ caller.setCallback(callback);
+ caller.call();
+ caller.delCallback();
+
+ callback = new JavaCallback();
+
+ System.out.println();
+ System.out.println("Adding and calling a Java callback");
+ System.out.println("------------------------------------");
+
+ caller.setCallback(callback);
+ caller.call();
+ caller.delCallback();
+
+ // Test that a double delete does not occur as the object has already been deleted from the C++ layer.
+ // Note that the garbage collector can also call the delete() method via the finalizer (callback.finalize())
+ // at any point after here.
+ callback.delete();
+
+ System.out.println();
+ System.out.println("java exit");
+ }
+}
+
+class JavaCallback extends Callback
+{
+ public JavaCallback()
+ {
+ super();
+ }
+
+ public void run()
+ {
+ System.out.println("JavaCallback.run()");
+ }
+}
+
diff --git a/trunk/Examples/java/check.list b/trunk/Examples/java/check.list
new file mode 100644
index 000000000..9728342f2
--- /dev/null
+++ b/trunk/Examples/java/check.list
@@ -0,0 +1,15 @@
+# see top-level Makefile.in
+callback
+class
+constants
+enum
+extend
+funcptr
+multimap
+native
+pointer
+reference
+simple
+template
+typemap
+variables
diff --git a/trunk/Examples/java/class/Makefile b/trunk/Examples/java/class/Makefile
new file mode 100644
index 000000000..14c301703
--- /dev/null
+++ b/trunk/Examples/java/class/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/class/example.cxx b/trunk/Examples/java/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/class/example.dsp b/trunk/Examples/java/class/example.dsp
new file mode 100644
index 000000000..fbe87e7a4
--- /dev/null
+++ b/trunk/Examples/java/class/example.dsp
@@ -0,0 +1,162 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -c++ -java $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -c++ -java $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/java/class/example.h b/trunk/Examples/java/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/class/example.i b/trunk/Examples/java/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/class/index.html b/trunk/Examples/java/class/index.html
new file mode 100644
index 000000000..cf9130c62
--- /dev/null
+++ b/trunk/Examples/java/class/index.html
@@ -0,0 +1,197 @@
+<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>
+
+<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="runme.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 proxy classes is not the only way to handle C++ code.
+A low level interface using c functions to access member variables and member functions is the alternative SWIG
+approach. This entails passing around the c pointer or c++ 'this' pointer and as such it is not difficult to crash the JVM.
+The abstraction of the underlying pointer by the java proxy classes far better fits the java programming paradigm.
+
+<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/trunk/Examples/java/class/runme.java b/trunk/Examples/java/class/runme.java
new file mode 100644
index 000000000..e1ea0d71c
--- /dev/null
+++ b/trunk/Examples/java/class/runme.java
@@ -0,0 +1,70 @@
+// This example illustrates how C++ classes can be used from Java using SWIG.
+// The Java class gets mapped onto the C++ class and behaves as if it is a Java class.
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // ----- Object creation -----
+
+ System.out.println( "Creating some objects:" );
+ Circle c = new Circle(10);
+ System.out.println( " Created circle " + c );
+ Square s = new Square(10);
+ System.out.println( " Created square " + s );
+
+ // ----- Access a static member -----
+
+ System.out.println( "\nA total of " + Shape.getNshapes() + " shapes were created" );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.setX(20);
+ c.setY(30);
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.setX(-10);
+ shape.setY(5);
+
+ System.out.println( "\nHere is their current position:" );
+ System.out.println( " Circle = (" + c.getX() + " " + c.getY() + ")" );
+ System.out.println( " Square = (" + s.getX() + " " + s.getY() + ")" );
+
+ // ----- Call some methods -----
+
+ System.out.println( "\nHere are some properties of the shapes:" );
+ Shape[] shapes = {c,s};
+ for (int i=0; i<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/trunk/Examples/java/constants/Makefile b/trunk/Examples/java/constants/Makefile
new file mode 100644
index 000000000..2b3d35c6a
--- /dev/null
+++ b/trunk/Examples/java/constants/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/constants/example.i b/trunk/Examples/java/constants/example.i
new file mode 100644
index 000000000..76665fca0
--- /dev/null
+++ b/trunk/Examples/java/constants/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+/* Force the generated Java code to use the C constant values rather than making a JNI call */
+%javaconst(1);
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
+
+
diff --git a/trunk/Examples/java/constants/index.html b/trunk/Examples/java/constants/index.html
new file mode 100644
index 000000000..9f1e95a03
--- /dev/null
+++ b/trunk/Examples/java/constants/index.html
@@ -0,0 +1,52 @@
+<html>
+<head>
+<title>SWIG:Examples:java:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/java/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<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="../../../Doc/Manual/Java.html#constants">here</a> for the section on constants in the SWIG and Java documentation.
+<p>
+
+Click <a href="runme.java">here</a> to see a Java program that prints out the values
+of the constants contained in the above file.</p>
+<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/trunk/Examples/java/constants/runme.java b/trunk/Examples/java/constants/runme.java
new file mode 100644
index 000000000..2c67d86aa
--- /dev/null
+++ b/trunk/Examples/java/constants/runme.java
@@ -0,0 +1,44 @@
+import java.lang.reflect.*;
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ System.out.println("ICONST = " + example.ICONST + " (should be 42)");
+ System.out.println("FCONST = " + example.FCONST + " (should be 2.1828)");
+ System.out.println("CCONST = " + example.CCONST + " (should be 'x')");
+ System.out.println("CCONST2 = " + example.CCONST2 + " (this should be on a new line)");
+ System.out.println("SCONST = " + example.SCONST + " (should be 'Hello World')");
+ System.out.println("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')");
+ System.out.println("EXPR = " + example.EXPR + " (should be 48.5484)");
+ System.out.println("iconst = " + example.iconst + " (should be 37)");
+ System.out.println("fconst = " + example.fconst + " (should be 3.14)");
+
+// Use reflection to check if these variables are defined:
+ try
+ {
+ System.out.println("EXTERN = " + example.class.getField("EXTERN") + " (Arg! This shouldn't print anything)");
+ }
+ catch (NoSuchFieldException e)
+ {
+ System.out.println("EXTERN isn't defined (good)");
+ }
+
+ try
+ {
+ System.out.println("FOO = " + example.class.getField("FOO") + " (Arg! This shouldn't print anything)");
+ }
+ catch (NoSuchFieldException e)
+ {
+ System.out.println("FOO isn't defined (good)");
+ }
+ }
+}
diff --git a/trunk/Examples/java/enum/Makefile b/trunk/Examples/java/enum/Makefile
new file mode 100644
index 000000000..14c301703
--- /dev/null
+++ b/trunk/Examples/java/enum/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/enum/example.cxx b/trunk/Examples/java/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/enum/example.h b/trunk/Examples/java/enum/example.h
new file mode 100644
index 000000000..9119cd9fc
--- /dev/null
+++ b/trunk/Examples/java/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/trunk/Examples/java/enum/example.i b/trunk/Examples/java/enum/example.i
new file mode 100644
index 000000000..fb6568943
--- /dev/null
+++ b/trunk/Examples/java/enum/example.i
@@ -0,0 +1,14 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Force the generated Java code to use the C enum values rather than making a JNI call */
+%javaconst(1);
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/trunk/Examples/java/enum/index.html b/trunk/Examples/java/enum/index.html
new file mode 100644
index 000000000..20daf2691
--- /dev/null
+++ b/trunk/Examples/java/enum/index.html
@@ -0,0 +1,29 @@
+<html>
+<head>
+<title>SWIG:Examples:java:enum</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/enum/</tt>
+<hr>
+
+<H2>Wrapping enumerations</H2>
+
+<p>
+This example tests SWIG's ability to wrap enumerations.
+SWIG wraps enums in numerous different ways. The default approach is to wrap
+each enum with the typesafe enum pattern. Enums are handled as integers in the JNI layer.
+See the documentation for the other approaches for wrapping enums.
+
+
+<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="runme.java">runme.java</a>. Sample Java program.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/java/enum/runme.java b/trunk/Examples/java/enum/runme.java
new file mode 100644
index 000000000..56e49af91
--- /dev/null
+++ b/trunk/Examples/java/enum/runme.java
@@ -0,0 +1,38 @@
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // Print out the value of some enums
+ System.out.println("*** color ***");
+ System.out.println(" " + color.RED + " = " + color.RED.swigValue());
+ System.out.println(" " + color.BLUE + " = " + color.BLUE.swigValue());
+ System.out.println(" " + color.GREEN + " = " + color.GREEN.swigValue());
+
+ System.out.println("\n*** Foo::speed ***");
+ System.out.println(" Foo::" + Foo.speed.IMPULSE + " = " + Foo.speed.IMPULSE.swigValue());
+ System.out.println(" Foo::" + Foo.speed.WARP + " = " + Foo.speed.WARP.swigValue());
+ System.out.println(" Foo::" + Foo.speed.LUDICROUS + " = " + Foo.speed.LUDICROUS.swigValue());
+
+ System.out.println("\nTesting use of enums with functions\n");
+
+ example.enum_test(color.RED, Foo.speed.IMPULSE);
+ example.enum_test(color.BLUE, Foo.speed.WARP);
+ example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
+
+ System.out.println( "\nTesting use of enum with class method" );
+ Foo f = new Foo();
+
+ f.enum_test(Foo.speed.IMPULSE);
+ f.enum_test(Foo.speed.WARP);
+ f.enum_test(Foo.speed.LUDICROUS);
+ }
+}
diff --git a/trunk/Examples/java/extend/Makefile b/trunk/Examples/java/extend/Makefile
new file mode 100644
index 000000000..14c301703
--- /dev/null
+++ b/trunk/Examples/java/extend/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/extend/example.cxx b/trunk/Examples/java/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/java/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/java/extend/example.h b/trunk/Examples/java/extend/example.h
new file mode 100644
index 000000000..b27ab9711
--- /dev/null
+++ b/trunk/Examples/java/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/trunk/Examples/java/extend/example.i b/trunk/Examples/java/extend/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/trunk/Examples/java/extend/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/trunk/Examples/java/extend/index.html b/trunk/Examples/java/extend/index.html
new file mode 100644
index 000000000..c7c2c127d
--- /dev/null
+++ b/trunk/Examples/java/extend/index.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>SWIG:Examples:java:extend</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/extend/</tt>
+<hr>
+
+<H2>Extending a simple C++ class in Java</H2>
+
+<p>
+This example illustrates the extending of a C++ class with cross language polymorphism.
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/java/extend/runme.java b/trunk/Examples/java/extend/runme.java
new file mode 100644
index 000000000..629bb14a6
--- /dev/null
+++ b/trunk/Examples/java/extend/runme.java
@@ -0,0 +1,88 @@
+// This file illustrates the cross language polymorphism using directors.
+
+
+// CEO class, which overrides Employee::getPosition().
+
+class CEO extends Manager {
+ public CEO(String name) {
+ super(name);
+ }
+ public String getPosition() {
+ return "CEO";
+ }
+ // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
+ public void disownMemory() {
+ swigCMemOwn = false;
+ }
+}
+
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+
+ // Create an instance of CEO, a class derived from the Java proxy of the
+ // underlying C++ class. The calls to getName() and getPosition() are standard,
+ // the call to getTitle() uses the director wrappers to call CEO.getPosition().
+
+ CEO e = new CEO("Alice");
+ System.out.println( e.getName() + " is a " + e.getPosition() );
+ System.out.println( "Just call her \"" + e.getTitle() + "\"" );
+ System.out.println( "----------------------" );
+
+
+ // Create a new EmployeeList instance. This class does not have a C++
+ // director wrapper, but can be used freely with other classes that do.
+
+ EmployeeList list = new EmployeeList();
+
+ // EmployeeList owns its items, so we must surrender ownership of objects we add.
+ e.disownMemory();
+ list.addEmployee(e);
+ System.out.println( "----------------------" );
+
+ // Now we access the first four items in list (three are C++ objects that
+ // EmployeeList's constructor adds, the last is our CEO). The virtual
+ // methods of all these instances are treated the same. For items 0, 1, and
+ // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
+ // getPosition which resolves in Java. The call to getPosition is
+ // slightly different, however, because of the overidden getPosition() call, since
+ // now the object reference has been "laundered" by passing through
+ // EmployeeList as an Employee*. Previously, Java resolved the call
+ // immediately in CEO, but now Java thinks the object is an instance of
+ // class Employee. So the call passes through the
+ // Employee proxy class and on to the C wrappers and C++ director,
+ // eventually ending up back at the Java CEO implementation of getPosition().
+ // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+ // method, which in turn calls getPosition(). This virtual method call
+ // passes down through the C++ director class to the Java implementation
+ // in CEO. All this routing takes place transparently.
+
+ System.out.println( "(position, title) for items 0-3:" );
+
+ System.out.println( " " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" );
+ System.out.println( " " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" );
+ System.out.println( " " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" );
+ System.out.println( " " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" );
+ System.out.println( "----------------------" );
+
+ // Time to delete the EmployeeList, which will delete all the Employee*
+ // items it contains. The last item is our CEO, which gets destroyed as well.
+ list.delete();
+ System.out.println( "----------------------" );
+
+ // All done.
+
+ System.out.println( "java exit" );
+
+ }
+}
diff --git a/trunk/Examples/java/funcptr/Makefile b/trunk/Examples/java/funcptr/Makefile
new file mode 100644
index 000000000..968c92c6c
--- /dev/null
+++ b/trunk/Examples/java/funcptr/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/funcptr/example.c b/trunk/Examples/java/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/funcptr/example.h b/trunk/Examples/java/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/java/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/java/funcptr/example.i b/trunk/Examples/java/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/funcptr/index.html b/trunk/Examples/java/funcptr/index.html
new file mode 100644
index 000000000..56d3baa18
--- /dev/null
+++ b/trunk/Examples/java/funcptr/index.html
@@ -0,0 +1,91 @@
+<html>
+<head>
+<title>SWIG:Examples:java:funcptr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/funcptr/</tt>
+<hr>
+
+<H2>Pointers to Functions</H2>
+
+<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="runme.java">runme.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/trunk/Examples/java/funcptr/runme.java b/trunk/Examples/java/funcptr/runme.java
new file mode 100644
index 000000000..cd34c1b65
--- /dev/null
+++ b/trunk/Examples/java/funcptr/runme.java
@@ -0,0 +1,33 @@
+
+public class runme {
+
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+
+ int a = 37;
+ int b = 42;
+
+ // Now call our C function with a bunch of callbacks
+
+ System.out.println( "Trying some C callback functions" );
+ System.out.println( " a = " + a );
+ System.out.println( " b = " + b );
+ System.out.println( " ADD(a,b) = " + example.do_op(a,b,example.ADD) );
+ System.out.println( " SUB(a,b) = " + example.do_op(a,b,example.SUB) );
+ System.out.println( " MUL(a,b) = " + example.do_op(a,b,example.MUL) );
+
+ System.out.println( "Here is what the C callback function classes are called in Java" );
+ System.out.println( " ADD = " + example.ADD.getClass().getName() );
+ System.out.println( " SUB = " + example.SUB.getClass().getName() );
+ System.out.println( " MUL = " + example.MUL.getClass().getName() );
+ }
+}
diff --git a/trunk/Examples/java/index.html b/trunk/Examples/java/index.html
new file mode 100644
index 000000000..007e14dbc
--- /dev/null
+++ b/trunk/Examples/java/index.html
@@ -0,0 +1,65 @@
+<html>
+<head>
+<title>SWIG:Examples:java</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Java Examples</H1>
+
+<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.
+<li><a href="callback/index.html">callback</a>. C++ callbacks using directors.
+<li><a href="extend/index.html">extend</a>. Polymorphism using directors.
+</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 runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.
+<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 runme
+</pre>
+</blockquote>
+<p>
+
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Solaris
+<li>Linux
+<li>Cygwin
+<li>Windows
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
+</body>
+</html>
+
+
diff --git a/trunk/Examples/java/multimap/Makefile b/trunk/Examples/java/multimap/Makefile
new file mode 100644
index 000000000..968c92c6c
--- /dev/null
+++ b/trunk/Examples/java/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/multimap/example.c b/trunk/Examples/java/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/java/multimap/example.dsp b/trunk/Examples/java/multimap/example.dsp
new file mode 100644
index 000000000..8e1f8415e
--- /dev/null
+++ b/trunk/Examples/java/multimap/example.dsp
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -java $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -java $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/java/multimap/example.i b/trunk/Examples/java/multimap/example.i
new file mode 100644
index 000000000..8d67282a5
--- /dev/null
+++ b/trunk/Examples/java/multimap/example.i
@@ -0,0 +1,109 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+extern int gcd(int x, int y);
+
+%typemap(jni) (int argc, char *argv[]) "jobjectArray"
+%typemap(jtype) (int argc, char *argv[]) "String[]"
+%typemap(jstype) (int argc, char *argv[]) "String[]"
+
+%typemap(javain) (int argc, char *argv[]) "$javainput"
+
+%typemap(in) (int argc, char *argv[]) (jstring *jsarray) {
+int i;
+
+ $1 = (*jenv)->GetArrayLength(jenv, $input);
+ if ($1 == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return $null;
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ jsarray = (jstring *) malloc($1*sizeof(jstring));
+ for (i = 0; i < $1; i++) {
+ jsarray[i] = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, i);
+ $2[i] = (char *) (*jenv)->GetStringUTFChars(jenv, jsarray[i], 0);
+ }
+ $2[i] = 0;
+}
+
+%typemap(argout) (int argc, char *argv[]) "" /* override char *[] default */
+
+%typemap(freearg) (int argc, char *argv[]) {
+int i;
+ for (i = 0; i < $1; i++) {
+ (*jenv)->ReleaseStringUTFChars(jenv, jsarray$argnum[i], $2[i]);
+ }
+ free($2);
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(jni) (char *bytes, int len) "jstring"
+%typemap(jtype) (char *bytes, int len) "String"
+%typemap(jstype) (char *bytes, int len) "String"
+
+%typemap(javain) (char *bytes, int len) "$javainput"
+
+%typemap(in) (char *bytes, int len) {
+ $1 = ($1_type)(*jenv)->GetStringUTFChars(jenv, $input, 0);
+ $2 = (*jenv)->GetStringUTFLength(jenv, $input);
+}
+
+%typemap(freearg) (char *bytes, int len) %{
+ (*jenv)->ReleaseStringUTFChars(jenv, $input, $1);
+%}
+
+extern int count(char *bytes, int len, char c);
+
+/* This example shows how to wrap a function that mutates a c string. A one
+ * element Java string array is used so that the string can be returned modified.*/
+
+%typemap(jni) (char *str, int len) "jobjectArray"
+%typemap(jtype) (char *str, int len) "String[]"
+%typemap(jstype) (char *str, int len) "String[]"
+
+%typemap(javain) (char *str, int len) "$javainput"
+
+%typemap(in) (char *str, int len) (jstring js) {
+ int index = 0;
+ js = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, index);
+ $1 = (char *) (*jenv)->GetStringUTFChars(jenv, js, 0);
+ $2 = (*jenv)->GetStringUTFLength(jenv, js);
+}
+
+/* Return the mutated string as a modified element in the array. */
+%typemap(argout) (char *str, int len) {
+ jstring newstring = (*jenv)->NewStringUTF(jenv, $1);
+ (*jenv)->SetObjectArrayElement(jenv, $input, 0, newstring);
+}
+
+/* Release memory */
+%typemap(freearg) (char *str, int len) {
+ (*jenv)->ReleaseStringUTFChars(jenv, js$argnum, $1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "$1_name and $2_name must be in unit circle");
+ return;
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/trunk/Examples/java/multimap/runme.java b/trunk/Examples/java/multimap/runme.java
new file mode 100644
index 000000000..738330e77
--- /dev/null
+++ b/trunk/Examples/java/multimap/runme.java
@@ -0,0 +1,40 @@
+
+public class runme {
+
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // Call our gcd() function
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x,y);
+ System.out.println("The gcd of " + x + " and " + y + " is " + g);
+
+ // Call the gcdmain() function
+ String[] args = {"gcdmain","42","105"};
+ example.gcdmain(args);
+
+ // Call the count function
+ System.out.println(example.count("Hello World", 'l'));
+
+ // Call the capitalize function
+ String[] capitalizeMe = {"hello world"};
+ example.capitalize(capitalizeMe);
+ System.out.println(capitalizeMe[0]);
+ }
+}
+
+
+
+
+
+
+
diff --git a/trunk/Examples/java/native/Makefile b/trunk/Examples/java/native/Makefile
new file mode 100644
index 000000000..92afbd4d0
--- /dev/null
+++ b/trunk/Examples/java/native/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/native/example.i b/trunk/Examples/java/native/example.i
new file mode 100644
index 000000000..851b6fdc2
--- /dev/null
+++ b/trunk/Examples/java/native/example.i
@@ -0,0 +1,56 @@
+/* File : example.i */
+%module example
+
+%{
+#include <string.h>
+
+typedef struct point {
+ int x;
+ int y;
+} Point;
+
+
+Point *point_create(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+
+ return p;
+}
+
+static char *point_toString(char *format, Point *p) {
+ static char buf[80];
+
+ sprintf(buf, format, p->x, p->y);
+
+ return buf;
+}
+
+/* this function will be wrapped by SWIG */
+char *point_toString1(Point *p) {
+ return point_toString("(%d,%d)", p);
+}
+
+/* this one we wrapped manually*/
+JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) {
+ Point * p;
+ jstring result;
+
+ (void)jcls;
+
+ p = *(Point **)&jpoint;
+
+ result = (*jenv)->NewStringUTF(jenv, point_toString("[%d,%d]", p));
+
+ return result;
+}
+%}
+
+
+Point *point_create(int x, int y);
+char *point_toString1(Point *p);
+
+/* give access to free() for memory cleanup of the malloc'd Point */
+extern void free(void *memblock);
+
+%native(point_toString2) char *point_toString2(Point *p);
diff --git a/trunk/Examples/java/native/index.html b/trunk/Examples/java/native/index.html
new file mode 100644
index 000000000..1ca51c1e9
--- /dev/null
+++ b/trunk/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>
+
+Click <a href="../../../Doc/Manual/Java.html#using_own_jni_functions">here</a> for the relevant section in the SWIG and Java documentation.
+<p>
+This example compares wrapping a c global function using the manual way and the SWIG way.
+</p>
+
+<ul>
+<li><a href="example.i">example.i</a>. Interface file comparing code wrapped by SWIG and wrapped manually.
+<li><a href="runme.java">runme.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/trunk/Examples/java/native/runme.java b/trunk/Examples/java/native/runme.java
new file mode 100644
index 000000000..e9a18b21a
--- /dev/null
+++ b/trunk/Examples/java/native/runme.java
@@ -0,0 +1,19 @@
+
+public class runme {
+
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ SWIGTYPE_p_Point p = example.point_create(1, 2);
+ System.out.println("auto wrapped : " + example.point_toString1(p));
+ System.out.println("manual wrapped: " + example.point_toString2(p));
+ example.free(new SWIGTYPE_p_void(SWIGTYPE_p_Point.getCPtr(p), false)); //clean up c allocated memory
+ }
+}
diff --git a/trunk/Examples/java/pointer/Makefile b/trunk/Examples/java/pointer/Makefile
new file mode 100644
index 000000000..968c92c6c
--- /dev/null
+++ b/trunk/Examples/java/pointer/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/pointer/example.c b/trunk/Examples/java/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/pointer/example.i b/trunk/Examples/java/pointer/example.i
new file mode 100644
index 000000000..a8ac79499
--- /dev/null
+++ b/trunk/Examples/java/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/java/pointer/index.html b/trunk/Examples/java/pointer/index.html
new file mode 100644
index 000000000..5c93d4d58
--- /dev/null
+++ b/trunk/Examples/java/pointer/index.html
@@ -0,0 +1,165 @@
+<html>
+<head>
+<title>SWIG:Examples:java:pointer</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/java/pointer/</tt>
+<hr>
+
+<H2>Simple Pointer Handling</H2>
+
+<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="runme.java">runme.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/trunk/Examples/java/pointer/runme.java b/trunk/Examples/java/pointer/runme.java
new file mode 100644
index 000000000..f32f980f9
--- /dev/null
+++ b/trunk/Examples/java/pointer/runme.java
@@ -0,0 +1,55 @@
+
+public class runme {
+
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // First create some objects using the pointer library.
+ System.out.println("Testing the pointer library");
+ SWIGTYPE_p_int a = example.new_intp();
+ SWIGTYPE_p_int b = example.new_intp();
+ SWIGTYPE_p_int c = example.new_intp();
+ example.intp_assign(a,37);
+ example.intp_assign(b,42);
+
+ // Note that getCPtr() has package access by default
+ System.out.println(" a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a)));
+ System.out.println(" b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b)));
+ System.out.println(" c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c)));
+
+ // Call the add() function with some pointers
+ example.add(a,b,c);
+
+ // Now get the result
+ int res = example.intp_value(c);
+ System.out.println(" 37 + 42 =" + res);
+
+ // Clean up the pointers
+ example.delete_intp(a);
+ example.delete_intp(b);
+ example.delete_intp(c);
+
+ // Now try the typemap library
+ // Now it is no longer necessary to manufacture pointers.
+ // Instead we use a single element array which in Java is modifiable.
+
+ System.out.println("Trying the typemap library");
+ int[] r = {0};
+ example.sub(37,42,r);
+ System.out.println(" 37 - 42 = " + r[0]);
+
+ // Now try the version with return value
+
+ System.out.println("Testing return value");
+ int q = example.divide(42,37,r);
+ System.out.println(" 42/37 = " + q + " remainder " + r[0]);
+ }
+}
diff --git a/trunk/Examples/java/reference/Makefile b/trunk/Examples/java/reference/Makefile
new file mode 100644
index 000000000..14c301703
--- /dev/null
+++ b/trunk/Examples/java/reference/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/reference/example.cxx b/trunk/Examples/java/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/java/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/java/reference/example.h b/trunk/Examples/java/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/reference/example.i b/trunk/Examples/java/reference/example.i
new file mode 100644
index 000000000..6daa3b1f4
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/reference/index.html b/trunk/Examples/java/reference/index.html
new file mode 100644
index 000000000..33c80c50f
--- /dev/null
+++ b/trunk/Examples/java/reference/index.html
@@ -0,0 +1,147 @@
+<html>
+<head>
+<title>SWIG:Examples:java:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<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 &amp;a, const Vector &amp;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 &amp;a, const Vector &amp;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 &amp;operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &amp;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 &amp;result = self-&gt;get(index);
+ return &amp;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 &amp;get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &amp;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="runme.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/trunk/Examples/java/reference/runme.java b/trunk/Examples/java/reference/runme.java
new file mode 100644
index 000000000..6a2d9bf70
--- /dev/null
+++ b/trunk/Examples/java/reference/runme.java
@@ -0,0 +1,79 @@
+// This example illustrates the manipulation of C++ references in Java.
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ System.out.println( "Creating some objects:" );
+ Vector a = new Vector(3,4,5);
+ Vector b = new Vector(10,11,12);
+
+ System.out.println( " Created " + a.print() );
+ System.out.println( " Created " + b.print() );
+
+ // ----- Call an overloaded operator -----
+
+ // This calls the wrapper we placed around
+ //
+ // operator+(const Vector &a, const Vector &)
+ //
+ // It returns a new allocated object.
+
+ System.out.println( "Adding a+b" );
+ Vector c = example.addv(a,b);
+ System.out.println( " a+b = " + c.print() );
+
+ // Note: Unless we free the result, a memory leak will occur if the -noproxy commandline
+ // is used as the proxy classes define finalizers which call the delete() method. When
+ // -noproxy is not specified the memory management is controlled by the garbage collector.
+ // You can still call delete(). It will free the c++ memory immediately, but not the
+ // Java memory! You then must be careful not to call any member functions as it will
+ // use a NULL c pointer on the underlying c++ object. We set the Java object to null
+ // which will then throw a Java exception should we attempt to use it again.
+ c.delete();
+ c = null;
+
+ // ----- Create a vector array -----
+
+ System.out.println( "Creating an array of vectors" );
+ VectorArray va = new VectorArray(10);
+ System.out.println( " va = " + va.toString() );
+
+ // ----- Set some values in the array -----
+
+ // These operators copy the value of Vector a and Vector b to the vector array
+ va.set(0,a);
+ va.set(1,b);
+
+ // This works, but it would cause a memory leak if -noproxy was used!
+
+ va.set(2,example.addv(a,b));
+
+
+ // Get some values from the array
+
+ System.out.println( "Getting some array values" );
+ for (int i=0; i<5; i++)
+ System.out.println( " va(" + i + ") = " + va.get(i).print() );
+
+ // Watch under resource meter to check on this
+ System.out.println( "Making sure we don't leak memory." );
+ for (int i=0; i<1000000; i++)
+ c = va.get(i%10);
+
+ // ----- Clean up -----
+ // This could be omitted. The garbage collector would then clean up for us.
+ System.out.println( "Cleaning up" );
+ va.delete();
+ a.delete();
+ b.delete();
+ }
+}
diff --git a/trunk/Examples/java/simple/Makefile b/trunk/Examples/java/simple/Makefile
new file mode 100644
index 000000000..968c92c6c
--- /dev/null
+++ b/trunk/Examples/java/simple/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/simple/example.c b/trunk/Examples/java/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/java/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/trunk/Examples/java/simple/example.dsp b/trunk/Examples/java/simple/example.dsp
new file mode 100644
index 000000000..8e1f8415e
--- /dev/null
+++ b/trunk/Examples/java/simple/example.dsp
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -java $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -java $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/java/simple/example.i b/trunk/Examples/java/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/java/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/java/simple/index.html b/trunk/Examples/java/simple/index.html
new file mode 100644
index 000000000..9729e6dd8
--- /dev/null
+++ b/trunk/Examples/java/simple/index.html
@@ -0,0 +1,108 @@
+<html>
+<head>
+<title>SWIG:Examples:java:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/simple/</tt>
+<hr>
+
+<H2>Simple Java Example</H2>
+
+<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 &gt; 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="runme.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="runme.java">runme.java</a></tt>
+to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
+<blockquote>
+<pre>
+export LD_LIBRARY_PATH=. #ksh
+javac *.java
+java runme
+</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/trunk/Examples/java/simple/runme.java b/trunk/Examples/java/simple/runme.java
new file mode 100644
index 000000000..92880e8f9
--- /dev/null
+++ b/trunk/Examples/java/simple/runme.java
@@ -0,0 +1,32 @@
+
+public class runme {
+
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ // Call our gcd() function
+
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x,y);
+ System.out.println("The gcd of " + x + " and " + y + " is " + g);
+
+ // Manipulate the Foo global variable
+
+ // Output its current value
+ System.out.println("Foo = " + example.getFoo());
+
+ // Change its value
+ example.setFoo(3.1415926);
+
+ // See if the change took effect
+ System.out.println("Foo = " + example.getFoo());
+ }
+}
diff --git a/trunk/Examples/java/template/Makefile b/trunk/Examples/java/template/Makefile
new file mode 100644
index 000000000..2b3d35c6a
--- /dev/null
+++ b/trunk/Examples/java/template/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/template/example.h b/trunk/Examples/java/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/template/example.i b/trunk/Examples/java/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/trunk/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/trunk/Examples/java/template/index.html b/trunk/Examples/java/template/index.html
new file mode 100644
index 000000000..f4408e568
--- /dev/null
+++ b/trunk/Examples/java/template/index.html
@@ -0,0 +1,102 @@
+<html>
+<head>
+<title>SWIG:Examples:java:template</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/template/</tt>
+<hr>
+
+<H2>C++ template support</H2>
+
+<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 &amp;get(int index) {
+ return v[index];
+ }
+ void set(int index, T &amp;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="runme.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/trunk/Examples/java/template/runme.java b/trunk/Examples/java/template/runme.java
new file mode 100644
index 000000000..5d1097bba
--- /dev/null
+++ b/trunk/Examples/java/template/runme.java
@@ -0,0 +1,45 @@
+// This example illustrates how C++ templates can be used from Java.
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // Call some templated functions
+ System.out.println(example.maxint(3,7));
+ System.out.println(example.maxdouble(3.14,2.18));
+
+ // Create some class
+
+ vecint iv = new vecint(100);
+ vecdouble dv = new vecdouble(1000);
+
+ for (int i=0; i<100; i++)
+ iv.setitem(i,2*i);
+
+ for (int i=0; i<1000; i++)
+ dv.setitem(i, 1.0/(i+1));
+
+ {
+ int sum = 0;
+ for (int i=0; i<100; i++)
+ sum = sum + iv.getitem(i);
+
+ System.out.println(sum);
+ }
+
+ {
+ double sum = 0.0;
+ for (int i=0; i<1000; i++)
+ sum = sum + dv.getitem(i);
+ System.out.println(sum);
+ }
+ }
+}
diff --git a/trunk/Examples/java/typemap/Makefile b/trunk/Examples/java/typemap/Makefile
new file mode 100644
index 000000000..92afbd4d0
--- /dev/null
+++ b/trunk/Examples/java/typemap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/typemap/example.i b/trunk/Examples/java/typemap/example.i
new file mode 100644
index 000000000..7c97e6673
--- /dev/null
+++ b/trunk/Examples/java/typemap/example.i
@@ -0,0 +1,101 @@
+/* File : example.i */
+%module example
+%{
+/*
+ example of a function that returns a value in the char * argument
+ normally used like:
+
+ char buf[bigenough];
+ f1(buf);
+*/
+
+void f1(char *s) {
+ if(s != NULL) {
+ sprintf(s, "hello world");
+ }
+}
+
+void f2(char *s) {
+ f1(s);
+}
+
+void f3(char *s) {
+ f1(s);
+}
+
+%}
+
+/* default behaviour is that of input arg, Java cannot return a value in a
+ * string argument, so any changes made by f1(char*) will not be seen in the Java
+ * string passed to the f1 function.
+*/
+void f1(char *s);
+
+%include various.i
+
+/* use the BYTE argout typemap to get around this. Changes in the string by
+ * f2 can be seen in Java. */
+void f2(char *BYTE);
+
+
+
+/* Alternative approach uses a StringBuffer typemap for argout */
+
+/* Define the types to use in the generated JNI C code and Java code */
+%typemap(jni) char *SBUF "jobject"
+%typemap(jtype) char *SBUF "StringBuffer"
+%typemap(jstype) char *SBUF "StringBuffer"
+
+/* How to convert Java(JNI) type to requested C type */
+%typemap(in) char *SBUF {
+
+ $1 = NULL;
+ if($input != NULL) {
+ /* Get the String from the StringBuffer */
+ jmethodID setLengthID;
+ jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input);
+ jmethodID toStringID = (*jenv)->GetMethodID(jenv, sbufClass, "toString", "()Ljava/lang/String;");
+ jstring js = (jstring) (*jenv)->CallObjectMethod(jenv, $input, toStringID);
+
+ /* Convert the String to a C string */
+ const char *pCharStr = (*jenv)->GetStringUTFChars(jenv, js, 0);
+
+ /* Take a copy of the C string as the typemap is for a non const C string */
+ jmethodID capacityID = (*jenv)->GetMethodID(jenv, sbufClass, "capacity", "()I");
+ jint capacity = (*jenv)->CallIntMethod(jenv, $input, capacityID);
+ $1 = (char *) malloc(capacity+1);
+ strcpy($1, pCharStr);
+
+ /* Release the UTF string we obtained with GetStringUTFChars */
+ (*jenv)->ReleaseStringUTFChars(jenv, js, pCharStr);
+
+ /* Zero the original StringBuffer, so we can replace it with the result */
+ setLengthID = (*jenv)->GetMethodID(jenv, sbufClass, "setLength", "(I)V");
+ (*jenv)->CallVoidMethod(jenv, $input, setLengthID, (jint) 0);
+ }
+}
+
+/* How to convert the C type to the Java(JNI) type */
+%typemap(argout) char *SBUF {
+
+ if($1 != NULL) {
+ /* Append the result to the empty StringBuffer */
+ jstring newString = (*jenv)->NewStringUTF(jenv, $1);
+ jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input);
+ jmethodID appendStringID = (*jenv)->GetMethodID(jenv, sbufClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;");
+ (*jenv)->CallObjectMethod(jenv, $input, appendStringID, newString);
+
+ /* Clean up the string object, no longer needed */
+ free($1);
+ $1 = NULL;
+ }
+}
+/* Prevent the default freearg typemap from being used */
+%typemap(freearg) char *SBUF ""
+
+/* Convert the jstype to jtype typemap type */
+%typemap(javain) char *SBUF "$javainput"
+
+/* apply the new typemap to our function */
+void f3(char *SBUF);
+
diff --git a/trunk/Examples/java/typemap/index.html b/trunk/Examples/java/typemap/index.html
new file mode 100644
index 000000000..5dd591941
--- /dev/null
+++ b/trunk/Examples/java/typemap/index.html
@@ -0,0 +1,32 @@
+<html>
+<head>
+<title>SWIG:Examples:java:typemap</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/java/typemap/</tt>
+<hr>
+
+<H2>Typemaps in Java</H2>
+
+<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="runme.java">runme.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/trunk/Examples/java/typemap/runme.java b/trunk/Examples/java/typemap/runme.java
new file mode 100644
index 000000000..fcbcc3067
--- /dev/null
+++ b/trunk/Examples/java/typemap/runme.java
@@ -0,0 +1,26 @@
+
+public class runme {
+
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ String s = "brave new world";
+ example.f1(s);
+ System.out.println("f1(String): " + s);
+
+ byte b[] = new byte[25];
+ example.f2(b);
+ System.out.println("f2(byte[]): " + new String(b));
+
+ StringBuffer sb = new StringBuffer(20);
+ example.f3(sb);
+ System.out.println("f3(StringBuffer): " + sb);
+ }
+}
diff --git a/trunk/Examples/java/variables/Makefile b/trunk/Examples/java/variables/Makefile
new file mode 100644
index 000000000..968c92c6c
--- /dev/null
+++ b/trunk/Examples/java/variables/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all:: java
+
+java::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ javac *.java
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile java_clean
+
+check: all
diff --git a/trunk/Examples/java/variables/example.c b/trunk/Examples/java/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/java/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/java/variables/example.h b/trunk/Examples/java/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/java/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/java/variables/example.i b/trunk/Examples/java/variables/example.i
new file mode 100644
index 000000000..591b871ed
--- /dev/null
+++ b/trunk/Examples/java/variables/example.i
@@ -0,0 +1,49 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/java/variables/index.html b/trunk/Examples/java/variables/index.html
new file mode 100644
index 000000000..07b19d4e7
--- /dev/null
+++ b/trunk/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>
+
+<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.
+
+
+<p>Click <a href="../../../Doc/Manual/Java.html#global_variables">here</a> for the section on global variables in the SWIG and Java documentation.</p>
+<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="runme.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/trunk/Examples/java/variables/runme.java b/trunk/Examples/java/variables/runme.java
new file mode 100644
index 000000000..361a30fa6
--- /dev/null
+++ b/trunk/Examples/java/variables/runme.java
@@ -0,0 +1,97 @@
+// This example illustrates global variable access from Java.
+
+import java.lang.reflect.*;
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+// Try to set the values of some global variables
+
+ example.setIvar(42);
+ example.setSvar((short)-31000);
+ example.setLvar(65537);
+ example.setUivar(123456);
+ example.setUsvar(61000);
+ example.setUlvar(654321);
+ example.setScvar((byte)-13);
+ example.setUcvar((short)251);
+ example.setCvar('S');
+ example.setFvar((float)3.14159);
+ example.setDvar(2.1828);
+ example.setStrvar("Hello World");
+ example.setIptrvar(example.new_int(37));
+ example.setPtptr(example.new_Point(37,42));
+ example.setName("Bill");
+
+ // Now print out the values of the variables
+
+ System.out.println( "Variables (values printed from Java)" );
+
+ System.out.println( "ivar =" + example.getIvar() );
+ System.out.println( "svar =" + example.getSvar() );
+ System.out.println( "lvar =" + example.getLvar() );
+ System.out.println( "uivar =" + example.getUivar() );
+ System.out.println( "usvar =" + example.getUsvar() );
+ System.out.println( "ulvar =" + example.getUlvar() );
+ System.out.println( "scvar =" + example.getScvar() );
+ System.out.println( "ucvar =" + example.getUcvar() );
+ System.out.println( "fvar =" + example.getFvar() );
+ System.out.println( "dvar =" + example.getDvar() );
+ System.out.println( "cvar =" + (char)example.getCvar() );
+ System.out.println( "strvar =" + example.getStrvar() );
+ System.out.println( "cstrvar =" + example.getCstrvar() );
+ System.out.println( "iptrvar =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(example.getIptrvar())) );
+ System.out.println( "name =" + example.getName() );
+ System.out.println( "ptptr =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPtptr())) + example.Point_print(example.getPtptr()) );
+ System.out.println( "pt =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPt())) + example.Point_print(example.getPt()) );
+
+ System.out.println( "\nVariables (values printed from C)" );
+
+ example.print_vars();
+
+ System.out.println( "\nNow I'm going to try and modify some read only variables" );
+
+ System.out.println( " Trying to set 'path'" );
+ try {
+ Method m = example.class.getDeclaredMethod("setPath", new Class[] {String.class});
+ m.invoke(example.class, new Object[] {"Whoa!"} );
+ System.out.println( "Hey, what's going on?!?! This shouldn't work" );
+ }
+ catch (NoSuchMethodException e) {
+ System.out.println( "Good." );
+ }
+ catch (Throwable t) {
+ System.out.println( "You shouldn't see this!" );
+ }
+
+ System.out.println( " Trying to set 'status'" );
+ try {
+ Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class});
+ m.invoke(example.class, new Object[] {new Integer(0)} );
+ System.out.println( "Hey, what's going on?!?! This shouldn't work" );
+ }
+ catch (NoSuchMethodException e) {
+ System.out.println( "Good." );
+ }
+ catch (Throwable t) {
+ System.out.println( "You shouldn't see this!" );
+ }
+
+ System.out.println( "\nI'm going to try and update a structure variable.\n" );
+
+ example.setPt(example.getPtptr());
+
+ System.out.println( "The new value is" );
+ example.pt_print();
+ System.out.println( "You should see the value" + example.Point_print(example.getPtptr()) );
+ }
+}
diff --git a/trunk/Examples/lua/arrays/Makefile b/trunk/Examples/lua/arrays/Makefile
new file mode 100644
index 000000000..bb9cf0b3b
--- /dev/null
+++ b/trunk/Examples/lua/arrays/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/arrays/example.c b/trunk/Examples/lua/arrays/example.c
new file mode 100644
index 000000000..56c7b19d9
--- /dev/null
+++ b/trunk/Examples/lua/arrays/example.c
@@ -0,0 +1,25 @@
+/* File : example.c */
+
+#include <stdlib.h>
+
+/* we are using the qsort function, which needs a helper function to sort */
+int compare_int(const void * a, const void * b)
+{
+ return ( *(int*)a - *(int*)b );
+}
+
+void sort_int(int* arr, int len)
+{
+ qsort(arr, len, sizeof(int), compare_int);
+}
+
+// ditto doubles
+int compare_double(const void * a, const void * b)
+{
+ return (int)( *(double*)a - *(double*)b );
+}
+
+void sort_double(double* arr, int len)
+{
+ qsort(arr, len, sizeof(double), compare_double);
+}
diff --git a/trunk/Examples/lua/arrays/example.i b/trunk/Examples/lua/arrays/example.i
new file mode 100644
index 000000000..197a5a21b
--- /dev/null
+++ b/trunk/Examples/lua/arrays/example.i
@@ -0,0 +1,42 @@
+/* File : example.i */
+%module example
+
+/* in this file there are two sorting functions
+and three different ways to wrap them.
+
+See the lua code for how they are called
+*/
+
+%include <carrays.i> // array helpers
+
+// this declares a batch of function for manipulating C integer arrays
+%array_functions(int,int)
+
+// this adds some lua code directly into the module
+// warning: you need the example. prefix if you want it added into the module
+// addmittedly this code is a bit tedious, but its a one off effort
+%luacode {
+function example.sort_int2(t)
+ local len=table.maxn(t) -- the len
+ local arr=example.new_int(len)
+ for i=1,len do
+ example.int_setitem(arr,i-1,t[i]) -- note: C index is one less then lua indea
+ end
+ example.sort_int(arr,len) -- call the fn
+ -- copy back
+ for i=1,len do
+ t[i]=example.int_getitem(arr,i-1) -- note: C index is one less then lua indea
+ end
+ example.delete_int(arr) -- must delete it
+end
+}
+
+// this way uses the SWIG-Lua typemaps to do the conversion for us
+// the %apply command states to apply this wherever the argument signature matches
+%include <typemaps.i>
+%apply (double *INOUT,int) {(double* arr,int len)};
+
+%inline %{
+extern void sort_int(int* arr, int len);
+extern void sort_double(double* arr, int len);
+%} \ No newline at end of file
diff --git a/trunk/Examples/lua/arrays/runme.lua b/trunk/Examples/lua/arrays/runme.lua
new file mode 100644
index 000000000..b0f5cfc96
--- /dev/null
+++ b/trunk/Examples/lua/arrays/runme.lua
@@ -0,0 +1,74 @@
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+-- a helper to print a Lua table
+function print_table(t)
+ print(table.concat(t,","))
+end
+
+-- a helper to print a C array
+function print_array(arr,len)
+ for i=0,len-1 do
+ io.write(example.int_getitem(arr,i),",")
+ end
+ io.write("\n")
+end
+
+math.randomseed(0) -- init random
+
+
+--[[ version 1: passing a C array to the code
+lets test call sort_int()
+this requires a C array, so is the hardest to use]]
+ARRAY_SIZE=10
+arr=example.new_int(ARRAY_SIZE)
+for i=0,ARRAY_SIZE-1 do
+ example.int_setitem(arr,i,math.random(1000))
+end
+print "unsorted"
+print_array(arr,ARRAY_SIZE)
+example.sort_int(arr,ARRAY_SIZE)
+print "sorted"
+print_array(arr,ARRAY_SIZE)
+example.delete_int(arr) -- must delete it
+print ""
+
+--[[ version 2: using %luacode to write a helper
+a simpler way is to use a %luacode
+which is a lua function added into the module
+this can do the conversion for us
+so we can just add a lua table directly
+(what we do is move the lua code into the module instead)
+]]
+t={}
+for i=1,ARRAY_SIZE do
+ t[i]=math.random(1000)
+end
+print "unsorted"
+print_table(t)
+example.sort_int2(t) -- calls lua helper which then calls C
+print "sorted"
+print_table(t)
+print ""
+
+--[[ version 3: use a typemap
+this is the best way
+it uses the SWIG-Lua typemaps to do the work
+one item of note: the typemap creates a copy, rather than edit-in-place]]
+t={}
+for i=1,ARRAY_SIZE do
+ t[i]=math.random(1000)/10
+end
+print "unsorted"
+print_table(t)
+t=example.sort_double(t) -- replace t with the result
+print "sorted"
+print_table(t)
+
diff --git a/trunk/Examples/lua/check.list b/trunk/Examples/lua/check.list
new file mode 100644
index 000000000..6862e4478
--- /dev/null
+++ b/trunk/Examples/lua/check.list
@@ -0,0 +1,17 @@
+# see top-level Makefile.in
+arrays
+class
+constants
+dual
+embed
+embed2
+embed3
+exception
+funcptr3
+functest
+functor
+import
+owner
+pointer
+simple
+variables
diff --git a/trunk/Examples/lua/class/Makefile b/trunk/Examples/lua/class/Makefile
new file mode 100644
index 000000000..44888f66f
--- /dev/null
+++ b/trunk/Examples/lua/class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/class/example.cxx b/trunk/Examples/lua/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/lua/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/lua/class/example.h b/trunk/Examples/lua/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/lua/class/example.h
@@ -0,0 +1,39 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+
+
+
diff --git a/trunk/Examples/lua/class/example.i b/trunk/Examples/lua/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/lua/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/lua/class/runme.lua b/trunk/Examples/lua/class/runme.lua
new file mode 100644
index 000000000..2c3ad8ced
--- /dev/null
+++ b/trunk/Examples/lua/class/runme.lua
@@ -0,0 +1,62 @@
+-- file: runme.lua
+
+-- This file illustrates class C++ interface generated
+-- by SWIG.
+
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+----- Object creation -----
+
+print("Creating some objects:")
+c = example.Circle(10)
+print(" Created circle", c)
+s = example.Square(10)
+print(" Created square", s)
+
+----- Access a static member -----
+
+print("\nA total of",example.Shape_nshapes,"shapes were created")
+
+----- Member data access -----
+
+-- Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print("\nHere is their current position:")
+print(string.format(" Circle = (%f, %f)",c.x,c.y))
+print(string.format(" Square = (%f, %f)",s.x,s.y))
+
+----- Call some methods -----
+
+print("\nHere are some properties of the shapes:")
+for _,o in pairs({c,s}) do
+ print(" ", o)
+ print(" area = ", o:area())
+ print(" perimeter = ", o:perimeter())
+end
+
+print("\nGuess I'll clean up now")
+
+-- Note: this invokes the virtual destructor
+c=nil
+s=nil
+s = 3
+
+-- call gc to make sure they are collected
+collectgarbage()
+
+print(example.Shape_nshapes,"shapes remain")
+print "Goodbye"
diff --git a/trunk/Examples/lua/constants/Makefile b/trunk/Examples/lua/constants/Makefile
new file mode 100644
index 000000000..4204545b8
--- /dev/null
+++ b/trunk/Examples/lua/constants/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/constants/example.i b/trunk/Examples/lua/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/Examples/lua/constants/example.i
@@ -0,0 +1,27 @@
+/* File : example.i */
+%module example
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
+
+
diff --git a/trunk/Examples/lua/constants/runme.lua b/trunk/Examples/lua/constants/runme.lua
new file mode 100644
index 000000000..751e7d623
--- /dev/null
+++ b/trunk/Examples/lua/constants/runme.lua
@@ -0,0 +1,35 @@
+-- file: example.lua
+
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+print("ICONST = "..example.ICONST.." (should be 42)")
+print("FCONST = "..example.FCONST.." (should be 2.1828)")
+print("CCONST = "..example.CCONST.." (should be 'x')")
+print("CCONST2 = "..example.CCONST2.." (this should be on a new line)")
+print("SCONST = "..example.SCONST.." (should be 'Hello World')")
+print("SCONST2 = "..example.SCONST2.." (should be '\"Hello World\"')")
+print("EXPR = "..example.EXPR.." (should be 48.5484)")
+print("iconst = "..example.iconst.." (should be 37)")
+print("fconst = "..example.fconst.." (should be 3.14)")
+
+-- helper to check that a fn failed
+function checkfail(fn)
+ if pcall(fn)==true then
+ print("that shouldn't happen, it worked")
+ else
+ print("function failed as expected")
+ end
+end
+
+-- these should fail
+-- example.EXTERN is a nil value, so concatentatin will make it fail
+checkfail(function() print("EXTERN = "..example.EXTERN) end)
+checkfail(function() print("FOO = "..example.FOO) end)
diff --git a/trunk/Examples/lua/dual/Makefile b/trunk/Examples/lua/dual/Makefile
new file mode 100644
index 000000000..b4e28f331
--- /dev/null
+++ b/trunk/Examples/lua/dual/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = dual
+CXXSRCS = example2_wrap.cxx
+INTERFACE = dual.i
+LUA_INTERP = dual.cpp
+
+# This is a little different to normal as we need to static link two modules and a custom interpreter
+# We need the external runtime, then swig examples2, and build the module as normal
+all::
+ $(SWIG) -lua -external-runtime
+ $(SWIG) -c++ -lua $(SWIGOPT) example2.i
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+ rm -f swigluarun.h
+
+check: all
+
diff --git a/trunk/Examples/lua/dual/dual.cpp b/trunk/Examples/lua/dual/dual.cpp
new file mode 100644
index 000000000..d2a9ecaa9
--- /dev/null
+++ b/trunk/Examples/lua/dual/dual.cpp
@@ -0,0 +1,109 @@
+/*
+dual.cpp a test for multiple modules and multiple intrepreters staticly linked together.
+
+Earlier version of lua bindings for SWIG would fail if staticly linked.
+
+What is happening is as follows:
+example.i declares a type Foo
+examples2.i declares Bar
+
+The first lua state will load example.i
+and check to see if types Foo and Bar are registered with it
+(Foo should be & Bar should not)
+
+The second lua state will load example2.i
+and check to see if types Foo and Bar are registered with it
+(Bar should be & Foo should not)
+
+Note: Though both the modules exist and are loaded, they are not linked together,
+as they are connected to seperate lua interpreters.
+
+When the third lua state loads both example.i and example2.i,
+the two modules are now linked together, and all can now find
+both Foo and Bar.
+*/
+
+#include "swigluarun.h" // the swig runtimes
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// the 2 libraries which are wrappered via SWIG
+extern "C" int luaopen_example(lua_State*L);
+extern "C" int luaopen_example2(lua_State*L);
+
+#define DEBUG(X) {printf(X);fflush(stdout);}
+#define DEBUG2(X,Y) {printf(X,Y);fflush(stdout);}
+#define DEBUG3(X,Y,Z) {printf(X,Y,Z);fflush(stdout);}
+
+void testModule(lua_State *L)
+{
+ swig_type_info *pTypeInfo=0,*pTypeInfo2=0;
+ swig_module_info *pModule=0;
+ pModule=SWIG_GetModule(L);
+ DEBUG2(" SWIG_GetModule() returns %p\n",pModule)
+ if(pModule==0) return;
+ pTypeInfo = SWIG_TypeQuery(L,"Foo *");
+ DEBUG2(" Type (Foo*) is %s\n",pTypeInfo==0?"unknown":"known");
+ DEBUG3(" Module %p typeinfo(Foo*) %p\n",pModule,pTypeInfo);
+ pTypeInfo2 = SWIG_TypeQuery(L,"Bar *");
+ DEBUG2(" Type (Bar*) is %s\n",pTypeInfo2==0?"unknown":"known");
+ DEBUG3(" Module %p typeinfo(Bar*) %p\n",pModule,pTypeInfo2);
+}
+
+int main(int argc,char* argv[])
+{
+ lua_State *L1=0,*L2=0,*L3=0;
+
+ printf("This is a test of having two SWIG'ed modules and three lua states\n"
+ "statically linked together.\n"
+ "Its mainly to check that all the types are correctly managed\n\n");
+
+ DEBUG("creating lua states(L1,L2,L3)");
+ L1=lua_open();
+ L2=lua_open();
+ L3=lua_open();
+ DEBUG("ok\n\n");
+
+ DEBUG("luaopen_example(L1)..");
+ luaopen_example(L1);
+ DEBUG("ok\n");
+
+ DEBUG("Testing Module L1\n");
+ DEBUG("This module should know about Foo* but not Bar*\n");
+ testModule(L1);
+ DEBUG("End Testing Module L1\n\n");
+
+ DEBUG("luaopen_example2(L2)..");
+ luaopen_example2(L2);
+ DEBUG("ok\n");
+
+ DEBUG("Testing Module L2\n");
+ DEBUG("This module should know about Bar* but not Foo*\n");
+ testModule(L2);
+ DEBUG("End Testing Module L2\n\n");
+
+ DEBUG("luaopen_example(L3)..");
+ luaopen_example(L3);
+ DEBUG("ok\n");
+ DEBUG("luaopen_example2(L3)..");
+ luaopen_example2(L3);
+ DEBUG("ok\n");
+
+ DEBUG("Testing Module L3\n");
+ DEBUG("This module should know about Foo* and Bar*\n");
+ testModule(L3);
+ DEBUG("End Testing Module L3\n\n");
+
+ DEBUG("Testing Module L1 again\n");
+ DEBUG("It now should know about Foo* and Bar*\n");
+ testModule(L1);
+ DEBUG("End Testing Module L1 again\n\n");
+
+ DEBUG("close all..");
+ lua_close(L1);
+ lua_close(L2);
+ lua_close(L3);
+ DEBUG("ok, exiting\n");
+ return 0;
+}
diff --git a/trunk/Examples/lua/dual/example.i b/trunk/Examples/lua/dual/example.i
new file mode 100644
index 000000000..5e573ddb3
--- /dev/null
+++ b/trunk/Examples/lua/dual/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%inline %{
+
+struct Foo{
+ int i;
+};
+
+%}
diff --git a/trunk/Examples/lua/dual/example2.i b/trunk/Examples/lua/dual/example2.i
new file mode 100644
index 000000000..94496647f
--- /dev/null
+++ b/trunk/Examples/lua/dual/example2.i
@@ -0,0 +1,10 @@
+/* File : example2.i */
+%module example2
+
+%inline %{
+
+struct Bar{
+ int i;
+};
+
+%}
diff --git a/trunk/Examples/lua/embed/Makefile b/trunk/Examples/lua/embed/Makefile
new file mode 100644
index 000000000..51d0e6180
--- /dev/null
+++ b/trunk/Examples/lua/embed/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = embed
+SRCS = example.c
+INTERFACE = example.i
+LUA_INTERP = embed.c
+
+# this is a little different to normal as we have our own special interpreter
+# which we want to static link
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
+
diff --git a/trunk/Examples/lua/embed/embed.c b/trunk/Examples/lua/embed/embed.c
new file mode 100644
index 000000000..55ea099be
--- /dev/null
+++ b/trunk/Examples/lua/embed/embed.c
@@ -0,0 +1,85 @@
+/* embed.c a simple test for an embeded interpreter
+
+The idea is that we wrapper a few simple function (example.c)
+and write our own app to call it.
+
+What it will do is load the wrappered lib, load runme.lua and then call some functions.
+To make life easier, all the printf's have either [C] or [Lua] at the start
+so you can see where they are coming from.
+
+We will be using the luaL_dostring()/lua_dostring() function to call into lua
+
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+
+/* the SWIG wrappered library */
+extern int luaopen_example(lua_State*L);
+
+/* a really simple way of calling lua from C
+ just give it a lua state & a string to execute
+Unfortunately lua keeps changing its API's.
+In lua 5.0.X its lua_dostring()
+In lua 5.1.X its luaL_dostring()
+so we have a few extra compiles
+*/
+int dostring(lua_State *L, char* str) {
+ int ok;
+#if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
+
+ ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */
+#else
+
+ ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */
+#endif
+
+ if (ok!=0)
+ printf("[C] ERROR in dostring: %s\n",lua_tostring(L,-1));
+ return ok;
+}
+
+
+int main(int argc,char* argv[]) {
+ lua_State *L;
+ int ok;
+ printf("[C] Welcome to the simple embedded lua example\n");
+ printf("[C] We are in C\n");
+ printf("[C] opening a lua state & loading the libraries\n");
+ L=lua_open();
+ luaopen_base(L);
+ luaopen_string(L);
+ luaopen_math(L);
+ printf("[C] now loading the SWIG wrappered library\n");
+ luaopen_example(L);
+ printf("[C] all looks ok\n");
+ printf("\n");
+ printf("[C] lets load the file 'runme.lua'\n");
+ printf("[C] any lua code in this file will be executed\n");
+ if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
+ printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
+ exit(3);
+ }
+ printf("[C] We are now back in C, all looks ok\n");
+ printf("\n");
+ printf("[C] lets call the function 'do_tests()'\n");
+ ok=dostring(L,"do_tests()");
+ printf("[C] We are back in C, the dostring() function returned %d\n",ok);
+ printf("\n");
+ printf("[C] Lets call lua again, but create an error\n");
+ ok=dostring(L,"no_such_function()");
+ printf("[C] We are back in C, the dostring() function returned %d\n",ok);
+ printf("[C] it should also have returned 1 and printed an error message\n");
+ printf("\n");
+ printf("[C] Lets call lua again, calling the greeting function\n");
+ ok=dostring(L,"call_greeting()");
+ printf("[C] This was C=>Lua=>C (getting a bit complex)\n");
+ printf("\n");
+ printf("[C] all finished, closing the lua state\n");
+ lua_close(L);
+ return 0;
+}
diff --git a/trunk/Examples/lua/embed/example.c b/trunk/Examples/lua/embed/example.c
new file mode 100644
index 000000000..c6c6d7ba1
--- /dev/null
+++ b/trunk/Examples/lua/embed/example.c
@@ -0,0 +1,22 @@
+/* File : example.c */
+
+#include <stdio.h>
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+void greeting() {
+ printf("Hello from the C function 'greeting'\n");
+}
diff --git a/trunk/Examples/lua/embed/example.i b/trunk/Examples/lua/embed/example.i
new file mode 100644
index 000000000..7784b8e3c
--- /dev/null
+++ b/trunk/Examples/lua/embed/example.i
@@ -0,0 +1,8 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+extern void greeting();
+%} \ No newline at end of file
diff --git a/trunk/Examples/lua/embed/runme.lua b/trunk/Examples/lua/embed/runme.lua
new file mode 100644
index 000000000..e02fd1d55
--- /dev/null
+++ b/trunk/Examples/lua/embed/runme.lua
@@ -0,0 +1,40 @@
+print "[lua] This is runme.lua"
+-- test program for embeded lua
+-- we do not need to load the library, as it was already in the intrepreter
+-- but lets check anyway
+assert(type(example)=='table',"Don't appear to have loaded the example module")
+
+-- a test function to run the tests
+function do_tests()
+ print("[lua] We are now in Lua, inside the do_tests() function")
+ print("[lua] We will be calling example.gcd() and changing example.Foo")
+ -- Call our gcd() function
+ x = 42
+ y = 105
+ g = example.gcd(x,y)
+ print("[lua] The gcd of",x,"and",y,"is",g)
+
+ -- Manipulate the Foo global variable
+
+ -- Output its current value
+ print("[lua] Foo = ", example.Foo)
+
+ -- Change its value
+ example.Foo = 3.1415926
+
+ -- See if the change took effect
+ print("[lua] Foo = ", example.Foo)
+ print("[lua] ending the do_tests() function")
+end
+
+function call_greeting()
+ print("[lua] We are now in Lua, inside the call_greeting() function")
+ example.greeting()
+ print("[lua] ending the call_greeting() function")
+end
+
+
+
+
+
+
diff --git a/trunk/Examples/lua/embed2/Makefile b/trunk/Examples/lua/embed2/Makefile
new file mode 100644
index 000000000..5f267d94d
--- /dev/null
+++ b/trunk/Examples/lua/embed2/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = embed2
+SRCS = example.c
+INTERFACE = example.i
+LUA_INTERP = embed2.c
+
+# this is a little different to normal as we have our own special interpreter
+# which we want to static link
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
+
diff --git a/trunk/Examples/lua/embed2/embed2.c b/trunk/Examples/lua/embed2/embed2.c
new file mode 100644
index 000000000..dac527eb4
--- /dev/null
+++ b/trunk/Examples/lua/embed2/embed2.c
@@ -0,0 +1,233 @@
+/* embed2.c some more test for an embeded interpreter
+
+This will go a bit further as it will pass values to and from the lua code.
+It uses less of the SWIG code, and more of the raw lua API's
+
+What it will do is load the wrappered lib, load runme.lua and then call some functions.
+To make life easier, all the printf's have either [C] or [Lua] at the start
+so you can see where they are coming from.
+
+We will be using the luaL_dostring()/lua_dostring() function to call into lua
+
+*/
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+#include <stdarg.h>
+#include <string.h>
+
+
+/* the SWIG wrappered library */
+extern int luaopen_example(lua_State*L);
+
+/* This is an example of how to call the Lua function
+ int add(int,int)
+ its very tedious, but gives you an idea of the issues involded.
+ (look below for a better idea)
+*/
+int call_add(lua_State *L,int a,int b,int* res) {
+ int top;
+ /* ok, here we go:
+ push a, push b, call 'add' check & return res
+ */
+ top=lua_gettop(L); /* for later */
+ lua_pushstring(L, "add"); /* function name */
+ lua_gettable(L, LUA_GLOBALSINDEX); /* function to be called */
+ if (!lua_isfunction(L,-1)) {
+ printf("[C] error: cannot find function 'add'\n");
+ lua_settop(L,top); // reset
+ return 0;
+ }
+ lua_pushnumber(L,a);
+ lua_pushnumber(L,b);
+ if (lua_pcall(L, 2, 1, 0) != 0) /* call function with 2 arguments and 1 result */
+ {
+ printf("[C] error running function `add': %s\n",lua_tostring(L, -1));
+ lua_settop(L,top); // reset
+ return 0;
+ }
+ // check results
+ if (!lua_isnumber(L,-1)) {
+ printf("[C] error: returned value is not a number\n");
+ lua_settop(L,top); // reset
+ return 0;
+ }
+ *res=(int)lua_tonumber(L,-1);
+ lua_settop(L,top); /* reset stack */
+ return 1; // ok
+}
+
+/* This is a variargs call function for calling from C into Lua.
+Original Code from Programming in Lua (PIL) by Roberto Ierusalimschy
+ISBN 85-903798-1-7
+http://www.lua.org/pil/25.3.html
+This has been modified slightly to make it compile, and its still a bit rough.
+But it gives the idea of how to make it work.
+*/
+int call_va (lua_State *L,const char *func, const char *sig, ...) {
+ va_list vl;
+ int narg, nres; /* number of arguments and results */
+ int top;
+ top=lua_gettop(L); /* for later */
+
+ va_start(vl, sig);
+ lua_getglobal(L, func); /* get function */
+
+ /* push arguments */
+ narg = 0;
+ while (*sig) { /* push arguments */
+ switch (*sig++) {
+
+ case 'd': /* double argument */
+ lua_pushnumber(L, va_arg(vl, double));
+ break;
+
+ case 'i': /* int argument */
+ lua_pushnumber(L, va_arg(vl, int));
+ break;
+
+ case 's': /* string argument */
+ lua_pushstring(L, va_arg(vl, char *));
+ break;
+
+ case '>':
+ goto endwhile;
+
+ default:
+ printf("invalid option (%c)\n", *(sig - 1));
+ goto fail;
+ }
+ narg++;
+ /* do we need this?*/
+ /* luaL_checkstack(L, 1, "too many arguments"); */
+ }
+endwhile:
+
+ /* do the call */
+ nres = (int)strlen(sig); /* number of expected results */
+ if (lua_pcall(L, narg, nres, 0) != 0) /* do the call */
+ {
+ printf("error running function `%s': %s\n",func, lua_tostring(L, -1));
+ goto fail;
+ }
+
+ /* retrieve results */
+ nres = -nres; /* stack index of first result */
+ while (*sig) { /* get results */
+ switch (*sig++) {
+
+ case 'd': /* double result */
+ if (!lua_isnumber(L, nres)) {
+ printf("wrong result type\n");
+ goto fail;
+ }
+ *va_arg(vl, double *) = lua_tonumber(L, nres);
+ break;
+
+ case 'i': /* int result */
+ if (!lua_isnumber(L, nres)) {
+ printf("wrong result type\n");
+ goto fail;
+ }
+ *va_arg(vl, int *) = (int)lua_tonumber(L, nres);
+ break;
+
+ case 's': /* string result */
+ if (!lua_isstring(L, nres)) {
+ printf("wrong result type\n");
+ goto fail;
+ }
+ strcpy(va_arg(vl, char *),lua_tostring(L, nres));/* WARNING possible buffer overflow */
+ break;
+
+ default: {
+ printf("invalid option (%c)", *(sig - 1));
+ goto fail;
+ }
+ }
+ nres++;
+ }
+ va_end(vl);
+
+ lua_settop(L,top); /* reset stack */
+ return 1; /* ok */
+fail:
+ lua_settop(L,top); /* reset stack */
+ return 0; /* error */
+}
+
+int main(int argc,char* argv[]) {
+ lua_State *L;
+ int ok;
+ int res;
+ char str[80];
+ printf("[C] Welcome to the simple embedded Lua example v2\n");
+ printf("[C] We are in C\n");
+ printf("[C] opening a Lua state & loading the libraries\n");
+ L=lua_open();
+ luaopen_base(L);
+ luaopen_string(L);
+ luaopen_math(L);
+ printf("[C] now loading the SWIG wrappered library\n");
+ luaopen_example(L);
+ printf("[C] all looks ok\n");
+ printf("\n");
+ printf("[C] lets load the file 'runme.lua'\n");
+ printf("[C] any lua code in this file will be executed\n");
+ if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
+ printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
+ exit(3);
+ }
+ printf("[C] We are now back in C, all looks ok\n");
+ printf("\n");
+ printf("[C] lets call the Lua function 'add(1,1)'\n");
+ printf("[C] using the C function 'call_add'\n");
+ ok=call_add(L,1,1,&res);
+ printf("[C] the function returned %d with value %d\n",ok,res);
+ printf("\n");
+ printf("[C] lets do this rather easier\n");
+ printf("[C] we will call the same Lua function using a generic C function 'call_va'\n");
+ ok=call_va(L,"add","ii>i",1,1,&res);
+ printf("[C] the function returned %d with value %d\n",ok,res);
+ printf("\n");
+ printf("[C] we will now use the same generic C function to call 'append(\"cat\",\"dog\")'\n");
+ ok=call_va(L,"append","ss>s","cat","dog",str);
+ printf("[C] the function returned %d with value %s\n",ok,str);
+ printf("\n");
+ printf("[C] we can also make some bad calls to ensure the code doesn't fail\n");
+ printf("[C] calling adds(1,2)\n");
+ ok=call_va(L,"adds","ii>i",1,2,&res);
+ printf("[C] the function returned %d with value %d\n",ok,res);
+ printf("[C] calling add(1,'fred')\n");
+ ok=call_va(L,"add","is>i",1,"fred",&res);
+ printf("[C] the function returned %d with value %d\n",ok,res);
+ printf("\n");
+ printf("[C] Note: no protection if you mess up the va-args, this is C\n");
+ printf("\n");
+ printf("[C] Finally we will call the wrappered gcd function gdc(6,9):\n");
+ printf("[C] This will pass the values to Lua, then call the wrappered function\n");
+ printf(" Which will get the values from Lua, call the C code \n");
+ printf(" and return the value to Lua and eventually back to C\n");
+ printf("[C] Certainly not the best way to do it :-)\n");
+ ok=call_va(L,"gcd","ii>i",6,9,&res);
+ printf("[C] the function returned %d with value %d\n",ok,res);
+ printf("\n");
+ printf("[C] all finished, closing the lua state\n");
+ lua_close(L);
+ return 0;
+}
diff --git a/trunk/Examples/lua/embed2/example.c b/trunk/Examples/lua/embed2/example.c
new file mode 100644
index 000000000..c6c6d7ba1
--- /dev/null
+++ b/trunk/Examples/lua/embed2/example.c
@@ -0,0 +1,22 @@
+/* File : example.c */
+
+#include <stdio.h>
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+void greeting() {
+ printf("Hello from the C function 'greeting'\n");
+}
diff --git a/trunk/Examples/lua/embed2/example.i b/trunk/Examples/lua/embed2/example.i
new file mode 100644
index 000000000..7784b8e3c
--- /dev/null
+++ b/trunk/Examples/lua/embed2/example.i
@@ -0,0 +1,8 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+extern void greeting();
+%} \ No newline at end of file
diff --git a/trunk/Examples/lua/embed2/runme.lua b/trunk/Examples/lua/embed2/runme.lua
new file mode 100644
index 000000000..73af9c5f2
--- /dev/null
+++ b/trunk/Examples/lua/embed2/runme.lua
@@ -0,0 +1,27 @@
+print "[lua] This is runme.lua"
+-- test program for embeded lua
+-- we do not need to load the library, as it was already in the intrepreter
+-- but lets check anyway
+assert(type(example)=='table',"Don't appear to have loaded the example module")
+
+-- note: we will copy the functions from example table into global
+-- this will help us later
+for k,v in pairs(example) do _G[k]=v end
+
+-- our add function
+-- we will be calling this from C
+function add(a,b)
+ print("[lua] this is function add(",a,b,")")
+ c=a+b
+ print("[lua] returning",c)
+ return c
+end
+
+function append(a,b)
+ print("[lua] this is function append(",a,b,")")
+ c=a..b
+ print("[lua] returning",c)
+ return c
+end
+
+
diff --git a/trunk/Examples/lua/embed3/Makefile b/trunk/Examples/lua/embed3/Makefile
new file mode 100644
index 000000000..def3528a5
--- /dev/null
+++ b/trunk/Examples/lua/embed3/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = embed3
+SRCS = example.cpp
+INTERFACE = example.i
+LUA_INTERP = embed3.cpp
+
+# this is a little different to normal as we have our own special interpreter
+# which we want to static link
+# we also need the external runtime, so we can get access to certain internals of SWIG
+all::
+ $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
+
diff --git a/trunk/Examples/lua/embed3/embed3.cpp b/trunk/Examples/lua/embed3/embed3.cpp
new file mode 100644
index 000000000..e5e0e0a7d
--- /dev/null
+++ b/trunk/Examples/lua/embed3/embed3.cpp
@@ -0,0 +1,146 @@
+/* embed3.cpp A C++ embeded interpreter
+
+This will register a C++ class with Lua, and then call a Lua function
+passing C++ objects to this function.
+
+*/
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+extern "C" {
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+}
+
+/* The SWIG external runtime is generated by using.
+swig -lua -externalruntime swigluarun.h
+It contains useful function used by SWIG in its wrappering
+SWIG_TypeQuery() SWIG_NewPointerObj()
+*/
+#include "swigluarun.h" // the SWIG external runtime
+
+/* the SWIG wrappered library */
+extern "C" int luaopen_example(lua_State*L);
+
+// the code itself
+#include "example.h"
+
+// this code pushes a C++ pointer as well as the SWIG type onto the Lua stack
+bool push_pointer(lua_State*L, void* ptr, const char* type_name, int owned = 0) {
+ // task 1: get the object 'type' which is registered with SWIG
+ // you need to call SWIG_TypeQuery() with the class name
+ // (normally, just look in the wrapper file to get this)
+ swig_type_info * pTypeInfo = SWIG_TypeQuery(L, type_name);
+ if (pTypeInfo == 0)
+ return false; // error
+ // task 2: push the pointer to the Lua stack
+ // this requires a pointer & the type
+ // the last param specifies if Lua is responsible for deleting the object
+ SWIG_NewPointerObj(L, ptr, pTypeInfo, owned);
+ return true;
+}
+
+/* This is an example of how to call the Lua function
+ void onEvent(Event e)
+ its very tedious, but gives you an idea of the issues involed.
+*/
+int call_onEvent(lua_State *L, Event e) {
+ int top;
+ /* ok, here we go:
+ push a, push b, call 'add' check & return res
+ */
+ top = lua_gettop(L); /* for later */
+ lua_pushstring(L, "onEvent"); /* function name */
+ lua_gettable(L, LUA_GLOBALSINDEX); /* function to be called */
+ if (!lua_isfunction(L, -1)) {
+ printf("[C++] error: cannot find function 'OnEvent'\n");
+ lua_settop(L, top); // reset
+ return 0;
+ }
+ // push the event object
+ push_pointer(L, &e, "Event *", 0);
+ if (lua_pcall(L, 1, 0, 0) != 0) /* call function with 1 arguments and no result */
+ {
+ printf("[C++] error running function `OnEvent': %s\n", lua_tostring(L, -1));
+ lua_settop(L, top); // reset
+ return 0;
+ }
+ lua_settop(L, top); /* reset stack */
+ return 1; // ok
+}
+
+
+int main(int argc, char* argv[]) {
+ printf("[C++] Welcome to the simple embedded Lua example v3\n");
+ printf("[C++] We are in C++\n");
+ printf("[C++] opening a Lua state & loading the libraries\n");
+ lua_State *L = lua_open();
+ luaopen_base(L);
+ luaopen_string(L);
+ luaopen_math(L);
+ printf("[C++] now loading the SWIG wrappered library\n");
+ luaopen_example(L);
+ printf("[C++] all looks ok\n");
+ printf("\n");
+ printf("[C++] lets create an Engine and pass a pointer to Lua\n");
+ Engine engine;
+ /* this code will pass a pointer into lua, but C++ still owns the object
+ this is a little tedious, to do, but lets do it
+ we need to pass the pointer (obviously), the type name
+ and a flag which states if Lua should delete the pointer once its finished with it
+ The type name is a class name string which is registered with SWIG
+ (normally, just look in the wrapper file to get this)
+ in this case we don't want Lua to delete the pointer so the ownership flag is 0
+ */
+ push_pointer(L,&engine,"Engine *",0);
+ lua_setglobal(L, "pEngine"); // set as global variable
+
+ printf("[C++] now lets load the file 'runme.lua'\n");
+ printf("[C++] any lua code in this file will be executed\n");
+ if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
+ printf("[C++] ERROR: cannot run lua file: %s", lua_tostring(L, -1));
+ exit(3);
+ }
+ printf("[C++] We are now back in C++, all looks ok\n");
+ printf("\n");
+
+ printf("[C++] Lets call the Lua function onEvent(e)\n");
+ printf("[C++] We will give it different events, as we wish\n");
+ printf("[C++] Starting with STARTUP\n");
+ Event ev;
+ ev.mType = Event::STARTUP;
+ call_onEvent(L, ev);
+ printf("[C++] ok\n");
+ printf("[C++] now we will try MOUSEPRESS,KEYPRESS,MOUSEPRESS\n");
+ ev.mType = Event::MOUSEPRESS;
+ call_onEvent(L, ev);
+ ev.mType = Event::KEYPRESS;
+ call_onEvent(L, ev);
+ ev.mType = Event::MOUSEPRESS;
+ call_onEvent(L, ev);
+ printf("[C++] ok\n");
+ printf("[C++] Finally we will SHUTDOWN\n");
+ ev.mType = Event::SHUTDOWN;
+ call_onEvent(L, ev);
+ printf("[C++] ok\n");
+
+ printf("\n");
+ printf("[C++] all finished, closing the lua state\n");
+ lua_close(L);
+ return 0;
+}
diff --git a/trunk/Examples/lua/embed3/example.cpp b/trunk/Examples/lua/embed3/example.cpp
new file mode 100644
index 000000000..a8264f370
--- /dev/null
+++ b/trunk/Examples/lua/embed3/example.cpp
@@ -0,0 +1,25 @@
+/* File : example.cpp */
+
+#include <stdio.h>
+#include "example.h"
+
+void Engine::start()
+{
+ printf("[C++] Engine::start()\n");
+}
+
+void Engine::stop()
+{
+ printf("[C++] Engine::stop()\n");
+}
+
+void Engine::accelerate(float f)
+{
+ printf("[C++] Engine::accelerate(%f)\n",f);
+}
+
+void Engine::decelerate(float f)
+{
+ printf("[C++] Engine::decelerate(%f)\n",f);
+}
+
diff --git a/trunk/Examples/lua/embed3/example.h b/trunk/Examples/lua/embed3/example.h
new file mode 100644
index 000000000..41c13e9c1
--- /dev/null
+++ b/trunk/Examples/lua/embed3/example.h
@@ -0,0 +1,24 @@
+/* File : example.h */
+
+/* This is some kind of engine of some kind
+we will give it some dummy methods for Lua to call*/
+
+class Engine
+{
+public:
+ void start();
+ void stop();
+ void accelerate(float f);
+ void decelerate(float f);
+};
+
+
+/* We also want to pass some events to Lua, so lets have a few classes
+to do this.
+*/
+class Event
+{
+public:
+ enum {STARTUP,KEYPRESS,MOUSEPRESS,SHUTDOWN} mType;
+ // etc
+};
diff --git a/trunk/Examples/lua/embed3/example.i b/trunk/Examples/lua/embed3/example.i
new file mode 100644
index 000000000..032805c0e
--- /dev/null
+++ b/trunk/Examples/lua/embed3/example.i
@@ -0,0 +1,8 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
diff --git a/trunk/Examples/lua/embed3/runme.lua b/trunk/Examples/lua/embed3/runme.lua
new file mode 100644
index 000000000..3a44bd2fc
--- /dev/null
+++ b/trunk/Examples/lua/embed3/runme.lua
@@ -0,0 +1,35 @@
+print "[lua] This is runme.lua"
+-- test program for embeded lua
+-- we do not need to load the library, as it was already in the intrepreter
+-- but lets check anyway
+
+assert(type(example)=='table',"Don't appear to have loaded the example module. Do not run this file directly, run the embed3 executable")
+
+print "[lua] looking to see if we have a pointer to the engine"
+if type(pEngine)=="userdata" then
+ print "[lua] looks good"
+else
+ print "[lua] nope, no signs of it"
+end
+
+
+-- the embed program expects a function void onEvent(Event)
+-- this is it
+
+function onEvent(e)
+ print("[Lua] onEvent with event",e.mType)
+ -- lets do something with the Engine
+ -- nothing clever, but ...
+ if e.mType==example.Event_STARTUP then
+ pEngine:start()
+ elseif e.mType==example.Event_KEYPRESS then
+ pEngine:accelerate(0.4)
+ elseif e.mType==example.Event_MOUSEPRESS then
+ pEngine:decelerate(0.4)
+ elseif e.mType==example.Event_SHUTDOWN then
+ pEngine:stop()
+ else
+ error("unknown event type")
+ end
+ print("[Lua] ending onEvent")
+end \ No newline at end of file
diff --git a/trunk/Examples/lua/exception/Makefile b/trunk/Examples/lua/exception/Makefile
new file mode 100644
index 000000000..8657f1922
--- /dev/null
+++ b/trunk/Examples/lua/exception/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/exception/example.h b/trunk/Examples/lua/exception/example.h
new file mode 100644
index 000000000..5148a5962
--- /dev/null
+++ b/trunk/Examples/lua/exception/example.h
@@ -0,0 +1,53 @@
+/* File : example.h */
+
+#include <string>
+#ifndef SWIG
+struct A {
+};
+#endif
+
+class Exc {
+public:
+ Exc(int c, const char *m) {
+ code = c;
+ strncpy(msg,m,256);
+ }
+ int code;
+ char msg[256];
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+class Test {
+public:
+ int simple() throw(int&) {
+ throw(37);
+ return 1;
+ }
+ int message() throw(const char *) {
+ throw("I died.");
+ return 1;
+ }
+ int hosed() throw(Exc) {
+ throw(Exc(42,"Hosed"));
+ return 1;
+ }
+ int unknown() throw(A*) {
+ static A a;
+ throw &a;
+ return 1;
+ }
+ int multi(int x) throw(int, const char *, Exc) {
+ if (x == 1) throw(37);
+ if (x == 2) throw("Bleah!");
+ if (x == 3) throw(Exc(42,"No-go-diggy-die"));
+ return 1;
+ }
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
diff --git a/trunk/Examples/lua/exception/example.i b/trunk/Examples/lua/exception/example.i
new file mode 100644
index 000000000..09cd9e812
--- /dev/null
+++ b/trunk/Examples/lua/exception/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+// we want to return Exc objects to the interpreter
+// therefore we add this typemap
+// note: only works if Exc is copyable
+%apply SWIGTYPE EXCEPTION_BY_VAL {Exc};
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/lua/exception/runme.lua b/trunk/Examples/lua/exception/runme.lua
new file mode 100644
index 000000000..39b2d6da8
--- /dev/null
+++ b/trunk/Examples/lua/exception/runme.lua
@@ -0,0 +1,96 @@
+-- file: example.lua
+
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+-- throw a lot of exceptions:
+-- you must catch exceptions using pcall and then checking the result
+
+t = example.Test()
+
+print "calling t:unknown()"
+ok,res=pcall(function() t:unknown() end)
+if ok then
+ print " that worked! Funny"
+else
+ print(" call failed with error:",res)
+end
+
+print "calling t:simple()"
+ok,res=pcall(function() t:simple() end)
+if ok then
+ print " that worked! Funny"
+else
+ print(" call failed with error:",res)
+end
+
+print "calling t:message()"
+ok,res=pcall(function() t:message() end)
+if ok then
+ print " that worked! Funny"
+else
+ print(" call failed with error:",res)
+end
+
+print "calling t:hosed()"
+ok,res=pcall(function() t:hosed() end)
+if ok then
+ print " that worked! Funny"
+else
+ print(" call failed with error:",res.code,res.msg)
+end
+
+-- this is a rather strange way to perform the multiple catch of exceptions
+print "calling t:mutli()"
+for i=1,3 do
+ ok,res=pcall(function() t:multi(i) end)
+ if ok then
+ print " that worked! Funny"
+ else
+ if swig_type(res)=="Exc *" then
+ print(" call failed with Exc exception:",res.code,res.msg)
+ else
+ print(" call failed with error:",res)
+ end
+ end
+end
+
+-- this is a bit crazy, but it shows obtaining of the stacktrace
+function a()
+ b()
+end
+function b()
+ t:message()
+end
+print [[
+Now lets call function a()
+ which calls b()
+ which calls into C++
+ which will throw an exception!]]
+ok,res=pcall(a)
+if ok then
+ print " that worked! Funny"
+else
+ print(" call failed with error:",res)
+end
+print "Now lets do the same using xpcall(a,debug.traceback)"
+ok,res=xpcall(a,debug.traceback)
+if ok then
+ print " that worked! Funny"
+else
+ print(" call failed with error:",res)
+end
+print "As you can see, the xpcall gives a nice stacktrace to work with"
+
+
+ok,res=pcall(a)
+print(ok,res)
+ok,res=xpcall(a,debug.traceback)
+print(ok,res)
diff --git a/trunk/Examples/lua/funcptr3/Makefile b/trunk/Examples/lua/funcptr3/Makefile
new file mode 100644
index 000000000..ac0fff43e
--- /dev/null
+++ b/trunk/Examples/lua/funcptr3/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/funcptr3/example.c b/trunk/Examples/lua/funcptr3/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/lua/funcptr3/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int sub(int a, int b) {
+ return a-b;
+}
+
+int mul(int a, int b) {
+ return a*b;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/trunk/Examples/lua/funcptr3/example.h b/trunk/Examples/lua/funcptr3/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/lua/funcptr3/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/lua/funcptr3/example.i b/trunk/Examples/lua/funcptr3/example.i
new file mode 100644
index 000000000..319b2274c
--- /dev/null
+++ b/trunk/Examples/lua/funcptr3/example.i
@@ -0,0 +1,69 @@
+/* File : example.i */
+/*
+This demonstrates how to pass a lua function, into some C code and then call it.
+
+There are two examples, the first is as a parameter, the second as a global variable.
+
+*/
+%module example
+%{
+#include "example.h"
+%}
+/* the extra wrappers for lua functions, see SWIG/Lib/lua/lua_fnptr.i for more details */
+%include "lua_fnptr.i"
+
+/* these are a bunch of C functions which we want to be able to call from lua */
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+/* this function takes a lua function as a parameter and calls it.
+As this is takes a lua fn it needs lua code
+*/
+%inline %{
+
+int callback(int a, int b, SWIGLUA_FN fn)
+{
+ SWIGLUA_FN_GET(fn);
+ lua_pushnumber(fn.L,a);
+ lua_pushnumber(fn.L,b);
+ lua_call(fn.L,2,1); /* 2 in, 1 out */
+ return (int)luaL_checknumber(fn.L,-1);
+}
+%}
+
+/******************
+Second code uses a stored reference.
+*******************/
+
+%inline %{
+/* note: this is not so good to just have it as a raw ref
+ people could set anything to this
+ a better solution would to be to have a fn which wants a SWIGLUA_FN, then
+ checks the type & converts to a SWIGLUA_REF.
+*/
+SWIGLUA_REF the_func={0,0};
+
+void call_the_func(int a)
+{
+ int i;
+ if (the_func.L==0){
+ printf("the_func is zero\n");
+ return;
+ }
+ swiglua_ref_get(&the_func);
+ if (!lua_isfunction(the_func.L,-1))
+ {
+ printf("the_func is not a function\n");
+ return;
+ }
+ lua_pop(the_func.L,1); /* tidy stack */
+ for(i=0;i<a;i++)
+ {
+ swiglua_ref_get(&the_func);
+ lua_pushnumber(the_func.L,i);
+ lua_call(the_func.L,1,0); /* 1 in, 0 out */
+ }
+}
+
+%}
diff --git a/trunk/Examples/lua/funcptr3/runme.lua b/trunk/Examples/lua/funcptr3/runme.lua
new file mode 100644
index 000000000..b78c504ef
--- /dev/null
+++ b/trunk/Examples/lua/funcptr3/runme.lua
@@ -0,0 +1,54 @@
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+a = 37
+b = 42
+
+-- Now call our C function
+
+print("Trying some C functions")
+print(" a =", a)
+print(" b =", b)
+print(" add(a,b) =", example.add(a,b))
+print(" sub(a,b) =", example.sub(a,b))
+print(" mul(a,b) =", example.mul(a,b))
+
+print("Calling them using the my_func()")
+print(" add(a,b) =", example.callback(a,b,example.add))
+print(" sub(a,b) =", example.callback(a,b,example.sub))
+print(" mul(a,b) =", example.callback(a,b,example.mul))
+
+print("Now let us write our own function")
+function foo(a,b) return 101 end
+print(" foo(a,b) =", example.callback(a,b,foo))
+
+print("Now let us try something that will fail")
+local ok,c=pcall(example.callback,a,b,print)
+if ok==false then
+ print("this failed as expected, error:",c)
+else
+ print("oops, that worked! result:",c)
+end
+
+
+-- part2 stored function
+print("trying a stored fn")
+print("the_func=",example.the_func)
+print("setting to print")
+example.the_func=print
+print("the_func=",example.the_func)
+print("call_the_func(5)")
+example.call_the_func(5)
+
+function bar(i) print("bar",i) end
+print("setting to bar")
+example.the_func=bar
+print("call_the_func(5)")
+example.call_the_func(5)
diff --git a/trunk/Examples/lua/functest/Makefile b/trunk/Examples/lua/functest/Makefile
new file mode 100644
index 000000000..ac0fff43e
--- /dev/null
+++ b/trunk/Examples/lua/functest/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/functest/example.c b/trunk/Examples/lua/functest/example.c
new file mode 100644
index 000000000..8eb647f66
--- /dev/null
+++ b/trunk/Examples/lua/functest/example.c
@@ -0,0 +1,25 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+int add1(int x, int y)
+{
+ return x+y;
+}
+
+void add2(int x, int *y, int *z)
+{
+ *z = x+*y;
+}
+
+int add3(int x, int y, int *z)
+{
+ *z = x-y;
+ return x+y;
+}
+
+void add4(int x, int *y)
+{
+ *y += x;
+}
diff --git a/trunk/Examples/lua/functest/example.i b/trunk/Examples/lua/functest/example.i
new file mode 100644
index 000000000..631e0602d
--- /dev/null
+++ b/trunk/Examples/lua/functest/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module example
+
+%include "typemaps.i" // you must have this for the typemaps for ptrs
+// basic function testing
+//
+%inline %{
+extern int add1(int x, int y); // return x+y -- basic function test
+extern void add2(int x, int *INPUT, int *OUTPUT); // *z = x+*y -- argin and argout test
+extern int add3(int x, int y, int *OUTPUT); // return x+y, *z=x-y -- returning 2 values
+extern void add4(int x, int *INOUT); // *y += x -- INOUT dual purpose variable
+%}
+
diff --git a/trunk/Examples/lua/functest/runme.lua b/trunk/Examples/lua/functest/runme.lua
new file mode 100644
index 000000000..65b3cc215
--- /dev/null
+++ b/trunk/Examples/lua/functest/runme.lua
@@ -0,0 +1,20 @@
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+
+x,y = 42,105
+print("add1 - simple arg passing and single return value -- ")
+print(example.add1(x,y))
+print("add2 - pointer arg passing and single return value through pointer arg -- ")
+print(example.add2(x,y))
+print("add3 - simple arg passing and double return value through return and ptr arg -- ")
+print(example.add3(x,y))
+print("add4 - dual use arg and return value -- ")
+print(example.add4(x,y))
diff --git a/trunk/Examples/lua/functor/Makefile b/trunk/Examples/lua/functor/Makefile
new file mode 100644
index 000000000..432bfbef3
--- /dev/null
+++ b/trunk/Examples/lua/functor/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/functor/example.i b/trunk/Examples/lua/functor/example.i
new file mode 100644
index 000000000..cc7a67990
--- /dev/null
+++ b/trunk/Examples/lua/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.
+// Note: this is normally automatic, but if you had to do it yourself
+// you would use this directive:
+//
+// %rename(__call) *::operator(); // the fn call operator
+
+// Instantiate a few versions
+%template(intSum) Sum<int>;
+%template(doubleSum) Sum<double>;
+
+
+
+
diff --git a/trunk/Examples/lua/functor/runme.lua b/trunk/Examples/lua/functor/runme.lua
new file mode 100644
index 000000000..adf124ac6
--- /dev/null
+++ b/trunk/Examples/lua/functor/runme.lua
@@ -0,0 +1,24 @@
+-- Operator overloading example
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+a = example.intSum(0)
+b = example.doubleSum(100.0)
+
+-- Use the objects. They should be callable just like a normal
+-- lua function.
+
+for i=0,100 do
+ a(i) -- Note: function call
+ b(math.sqrt(i)) -- Note: function call
+end
+print("int sum 0..100 is",a:result(),"(expected 5050)")
+print("double sum 0..100 is",b:result(),"(expected ~771.46)")
+
diff --git a/trunk/Examples/lua/import.lua b/trunk/Examples/lua/import.lua
new file mode 100644
index 000000000..b2a40b017
--- /dev/null
+++ b/trunk/Examples/lua/import.lua
@@ -0,0 +1,42 @@
+-- import
+-- the lua 5.0 loading mechanism is rather poor & relies upon the loadlib() fn
+-- the lua 5.1 loading mechanism is simplicity itself
+-- for now we need a bridge which will use the correct verion
+
+function import_5_0(module)
+ -- imports the file into the program
+ -- for a module 'example'
+ -- this must load 'example.dll' or 'example.so'
+ -- and look for the fn 'Example_Init()' (note the capitalisation)
+ if rawget(_G,module)~=nil then return end -- module appears to be loaded
+
+ -- capitialising the first letter
+ local c=string.upper(string.sub(module,1,1))
+ local fnname=c..string.sub(module,2).."_Init"
+
+ local suffix,lib
+ -- note: as there seems to be no way in lua to determine the platform
+ -- we will try loading all possible names
+ -- providing one works, we can load
+ for _,suffix in pairs{".dll",".so"} do
+ lib=loadlib(module..suffix,fnname)
+ if lib then -- found
+ break
+ end
+ end
+ assert(lib,"error loading module:"..module)
+
+ lib() -- execute the function: initalising the lib
+ local m=rawget(_G,module) -- gets the module object
+ assert(m~=nil,"no module table found")
+end
+
+function import_5_1(module)
+ require(module)
+end
+
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ import=import_5_0
+else
+ import=import_5_1
+end \ No newline at end of file
diff --git a/trunk/Examples/lua/import/Makefile b/trunk/Examples/lua/import/Makefile
new file mode 100644
index 000000000..8f692d175
--- /dev/null
+++ b/trunk/Examples/lua/import/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/import/README b/trunk/Examples/lua/import/README
new file mode 100644
index 000000000..1a52e3c1e
--- /dev/null
+++ b/trunk/Examples/lua/import/README
@@ -0,0 +1,36 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'lua runme.lua' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
+Windows:
+--------
+Sorry, no files here.
+If you know how, you could copy the python or ruby example dsw & dsp and try editing that
+
+
diff --git a/trunk/Examples/lua/import/bar.h b/trunk/Examples/lua/import/bar.h
new file mode 100644
index 000000000..1c99f28e6
--- /dev/null
+++ b/trunk/Examples/lua/import/bar.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+class Bar : public Base {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual const char * A() const {
+ return "Bar::A";
+ }
+ const char * B() const {
+ return "Bar::B";
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Bar *fromBase(Base *b) {
+ return dynamic_cast<Bar *>(b);
+ }
+};
+
+
diff --git a/trunk/Examples/lua/import/bar.i b/trunk/Examples/lua/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/trunk/Examples/lua/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/trunk/Examples/lua/import/base.h b/trunk/Examples/lua/import/base.h
new file mode 100644
index 000000000..fec0f329c
--- /dev/null
+++ b/trunk/Examples/lua/import/base.h
@@ -0,0 +1,16 @@
+class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual const char * A() const {
+ return "Base::A";
+ }
+ const char * B() const {
+ return "Base::B";
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/trunk/Examples/lua/import/base.i b/trunk/Examples/lua/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/trunk/Examples/lua/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/trunk/Examples/lua/import/foo.h b/trunk/Examples/lua/import/foo.h
new file mode 100644
index 000000000..1abe2c0d8
--- /dev/null
+++ b/trunk/Examples/lua/import/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+class Foo : public Base {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual const char * A() const {
+ return "Foo::A";
+ }
+ const char * B() const {
+ return "Foo::B";
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Foo *fromBase(Base *b) {
+ return dynamic_cast<Foo *>(b);
+ }
+};
+
+
diff --git a/trunk/Examples/lua/import/foo.i b/trunk/Examples/lua/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/trunk/Examples/lua/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/trunk/Examples/lua/import/runme.lua b/trunk/Examples/lua/import/runme.lua
new file mode 100644
index 000000000..9cd7ae06c
--- /dev/null
+++ b/trunk/Examples/lua/import/runme.lua
@@ -0,0 +1,103 @@
+# Test various properties of classes defined in separate modules
+
+print("Testing the %import directive")
+
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ function loadit(a)
+ lib=loadlib(a..'.dll','luaopen_'..a) or loadlib(a..'.so','luaopen_'..a)
+ assert(lib)()
+ end
+ loadit('base')
+ loadit('foo')
+ loadit('bar')
+ loadit('spam')
+else
+ -- lua 5.1 does
+ require 'base'
+ require 'foo'
+ require 'bar'
+ require 'spam'
+end
+
+-- Create some objects
+
+print("Creating some objects")
+
+a = base.Base()
+b = foo.Foo()
+c = bar.Bar()
+d = spam.Spam()
+
+-- Try calling some methods
+print("Testing some methods")
+print("Should see 'Base::A' ---> ",a:A())
+print("Should see 'Base::B' ---> ",a:B())
+
+print("Should see 'Foo::A' ---> ",b:A())
+print("Should see 'Foo::B' ---> ",b:B())
+
+print("Should see 'Bar::A' ---> ",c:A())
+print("Should see 'Bar::B' ---> ",c:B())
+
+print("Should see 'Spam::A' ---> ",d:A())
+print("Should see 'Spam::B' ---> ",d:B())
+
+-- Try some casts
+
+print("\nTesting some casts")
+
+x = a:toBase()
+print("Should see 'Base::A' ---> ",x:A())
+print("Should see 'Base::B' ---> ",x:B())
+
+x = b:toBase()
+print("Should see 'Foo::A' ---> ",x:A())
+print("Should see 'Base::B' ---> ",x:B())
+
+x = c:toBase()
+print("Should see 'Bar::A' ---> ",x:A())
+print("Should see 'Base::B' ---> ",x:B())
+
+x = d:toBase()
+print("Should see 'Spam::A' ---> ",x:A())
+print("Should see 'Base::B' ---> ",x:B())
+
+x = d:toBar()
+print("Should see 'Bar::B' ---> ",x:B())
+
+
+print "\nTesting some dynamic casts\n"
+x = d:toBase()
+
+print " Spam -> Base -> Foo : "
+y = foo.Foo_fromBase(x)
+if y then
+ print "bad swig"
+else
+ print "good swig"
+end
+
+print " Spam -> Base -> Bar : "
+y = bar.Bar_fromBase(x)
+if y then
+ print "good swig"
+else
+ print "bad swig"
+end
+
+print " Spam -> Base -> Spam : "
+y = spam.Spam_fromBase(x)
+if y then
+ print "good swig"
+else
+ print "bad swig"
+end
+
+print " Foo -> Spam : "
+y = spam.Spam_fromBase(b)
+if y then
+ print "bad swig"
+else
+ print "good swig"
+end
diff --git a/trunk/Examples/lua/import/spam.h b/trunk/Examples/lua/import/spam.h
new file mode 100644
index 000000000..57db84563
--- /dev/null
+++ b/trunk/Examples/lua/import/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+class Spam : public Bar {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual const char * A() const {
+ return "Spam::A";
+ }
+ const char * B() const {
+ return "Spam::B";
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ virtual Bar *toBar() {
+ return static_cast<Bar *>(this);
+ }
+ static Spam *fromBase(Base *b) {
+ return dynamic_cast<Spam *>(b);
+ }
+};
+
+
diff --git a/trunk/Examples/lua/import/spam.i b/trunk/Examples/lua/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/trunk/Examples/lua/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/trunk/Examples/lua/lua.c b/trunk/Examples/lua/lua.c
new file mode 100644
index 000000000..8cffaa503
--- /dev/null
+++ b/trunk/Examples/lua/lua.c
@@ -0,0 +1,438 @@
+/*
+** Lua stand-alone interpreter
+** See Copyright Notice in lua.h
+*/
+
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define lua_c
+
+#include "lua.h"
+
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/*
+** generic extra include file
+*/
+#ifdef LUA_USERCONFIG
+#include LUA_USERCONFIG
+#endif
+
+
+/*
+** definition of `isatty'
+*/
+#ifdef _POSIX_C_SOURCE
+#include <unistd.h>
+#define stdin_is_tty() isatty(0)
+#else
+#define stdin_is_tty() 1 /* assume stdin is a tty */
+#endif
+
+
+
+#ifndef PROMPT
+#define PROMPT "> "
+#endif
+
+
+#ifndef PROMPT2
+#define PROMPT2 ">> "
+#endif
+
+#ifndef PROGNAME
+#define PROGNAME "lua"
+#endif
+
+#ifndef lua_userinit
+#define lua_userinit(L) openstdlibs(L)
+#endif
+
+
+#ifndef LUA_EXTRALIBS
+#define LUA_EXTRALIBS /* empty */
+#endif
+
+
+static lua_State *L = NULL;
+
+static const char *progname = PROGNAME;
+
+extern int Example_Init(lua_State* L);
+
+static const luaL_reg lualibs[] = {
+ {"base", luaopen_base},
+ {"table", luaopen_table},
+ {"io", luaopen_io},
+ {"string", luaopen_string},
+ {"math", luaopen_math},
+ {"debug", luaopen_debug},
+ {"loadlib", luaopen_loadlib},
+ /* add your libraries here */
+ {"example", Example_Init},
+ LUA_EXTRALIBS
+ {NULL, NULL}
+};
+
+
+
+static void lstop (lua_State *l, lua_Debug *ar) {
+ (void)ar; /* unused arg. */
+ lua_sethook(l, NULL, 0, 0);
+ luaL_error(l, "interrupted!");
+}
+
+
+static void laction (int i) {
+ signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
+ terminate process (default action) */
+ lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
+}
+
+
+static void print_usage (void) {
+ fprintf(stderr,
+ "usage: %s [options] [script [args]].\n"
+ "Available options are:\n"
+ " - execute stdin as a file\n"
+ " -e stat execute string `stat'\n"
+ " -i enter interactive mode after executing `script'\n"
+ " -l name load and run library `name'\n"
+ " -v show version information\n"
+ " -- stop handling options\n" ,
+ progname);
+}
+
+
+static void l_message (const char *pname, const char *msg) {
+ if (pname) fprintf(stderr, "%s: ", pname);
+ fprintf(stderr, "%s\n", msg);
+}
+
+
+static int report (int status) {
+ const char *msg;
+ if (status) {
+ msg = lua_tostring(L, -1);
+ if (msg == NULL) msg = "(error with no message)";
+ l_message(progname, msg);
+ lua_pop(L, 1);
+ }
+ return status;
+}
+
+
+static int lcall (int narg, int clear) {
+ int status;
+ int base = lua_gettop(L) - narg; /* function index */
+ lua_pushliteral(L, "_TRACEBACK");
+ lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */
+ lua_insert(L, base); /* put it under chunk and args */
+ signal(SIGINT, laction);
+ status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
+ signal(SIGINT, SIG_DFL);
+ lua_remove(L, base); /* remove traceback function */
+ return status;
+}
+
+
+static void print_version (void) {
+ l_message(NULL, LUA_VERSION " " LUA_COPYRIGHT);
+}
+
+
+static void getargs (char *argv[], int n) {
+ int i;
+ lua_newtable(L);
+ for (i=0; argv[i]; i++) {
+ lua_pushnumber(L, i - n);
+ lua_pushstring(L, argv[i]);
+ lua_rawset(L, -3);
+ }
+ /* arg.n = maximum index in table `arg' */
+ lua_pushliteral(L, "n");
+ lua_pushnumber(L, i-n-1);
+ lua_rawset(L, -3);
+}
+
+
+static int docall (int status) {
+ if (status == 0) status = lcall(0, 1);
+ return report(status);
+}
+
+
+static int file_input (const char *name) {
+ return docall(luaL_loadfile(L, name));
+}
+
+
+static int dostring (const char *s, const char *name) {
+ return docall(luaL_loadbuffer(L, s, strlen(s), name));
+}
+
+
+static int load_file (const char *name) {
+ lua_pushliteral(L, "require");
+ lua_rawget(L, LUA_GLOBALSINDEX);
+ if (!lua_isfunction(L, -1)) { /* no `require' defined? */
+ lua_pop(L, 1);
+ return file_input(name);
+ }
+ else {
+ lua_pushstring(L, name);
+ return report(lcall(1, 1));
+ }
+}
+
+
+/*
+** this macro can be used by some `history' system to save lines
+** read in manual input
+*/
+#ifndef lua_saveline
+#define lua_saveline(L,line) /* empty */
+#endif
+
+
+/*
+** this macro defines a function to show the prompt and reads the
+** next line for manual input
+*/
+#ifndef lua_readline
+#define lua_readline(L,prompt) readline(L,prompt)
+
+/* maximum length of an input line */
+#ifndef MAXINPUT
+#define MAXINPUT 512
+#endif
+
+
+static int readline (lua_State *l, const char *prompt) {
+ static char buffer[MAXINPUT];
+ if (prompt) {
+ fputs(prompt, stdout);
+ fflush(stdout);
+ }
+ if (fgets(buffer, sizeof(buffer), stdin) == NULL)
+ return 0; /* read fails */
+ else {
+ lua_pushstring(l, buffer);
+ return 1;
+ }
+}
+
+#endif
+
+
+static const char *get_prompt (int firstline) {
+ const char *p = NULL;
+ lua_pushstring(L, firstline ? "_PROMPT" : "_PROMPT2");
+ lua_rawget(L, LUA_GLOBALSINDEX);
+ p = lua_tostring(L, -1);
+ if (p == NULL) p = (firstline ? PROMPT : PROMPT2);
+ lua_pop(L, 1); /* remove global */
+ return p;
+}
+
+
+static int incomplete (int status) {
+ if (status == LUA_ERRSYNTAX &&
+ strstr(lua_tostring(L, -1), "near `<eof>'") != NULL) {
+ lua_pop(L, 1);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+
+static int load_string (void) {
+ int status;
+ lua_settop(L, 0);
+ if (lua_readline(L, get_prompt(1)) == 0) /* no input? */
+ return -1;
+ if (lua_tostring(L, -1)[0] == '=') { /* line starts with `=' ? */
+ lua_pushfstring(L, "return %s", lua_tostring(L, -1)+1);/* `=' -> `return' */
+ lua_remove(L, -2); /* remove original line */
+ }
+ for (;;) { /* repeat until gets a complete line */
+ status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
+ if (!incomplete(status)) break; /* cannot try to add lines? */
+ if (lua_readline(L, get_prompt(0)) == 0) /* no more input? */
+ return -1;
+ lua_concat(L, lua_gettop(L)); /* join lines */
+ }
+ lua_saveline(L, lua_tostring(L, 1));
+ lua_remove(L, 1); /* remove line */
+ return status;
+}
+
+
+static void manual_input (void) {
+ int status;
+ const char *oldprogname = progname;
+ progname = NULL;
+ while ((status = load_string()) != -1) {
+ if (status == 0) status = lcall(0, 0);
+ report(status);
+ if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
+ lua_getglobal(L, "print");
+ lua_insert(L, 1);
+ if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
+ l_message(progname, lua_pushfstring(L, "error calling `print' (%s)",
+ lua_tostring(L, -1)));
+ }
+ }
+ lua_settop(L, 0); /* clear stack */
+ fputs("\n", stdout);
+ progname = oldprogname;
+}
+
+
+static int handle_argv (char *argv[], int *interactive) {
+ if (argv[1] == NULL) { /* no more arguments? */
+ if (stdin_is_tty()) {
+ print_version();
+ manual_input();
+ }
+ else
+ file_input(NULL); /* executes stdin as a file */
+ }
+ else { /* other arguments; loop over them */
+ int i;
+ for (i = 1; argv[i] != NULL; i++) {
+ if (argv[i][0] != '-') break; /* not an option? */
+ switch (argv[i][1]) { /* option */
+ case '-': { /* `--' */
+ if (argv[i][2] != '\0') {
+ print_usage();
+ return 1;
+ }
+ i++; /* skip this argument */
+ goto endloop; /* stop handling arguments */
+ }
+ case '\0': {
+ file_input(NULL); /* executes stdin as a file */
+ break;
+ }
+ case 'i': {
+ *interactive = 1;
+ break;
+ }
+ case 'v': {
+ print_version();
+ break;
+ }
+ case 'e': {
+ const char *chunk = argv[i] + 2;
+ if (*chunk == '\0') chunk = argv[++i];
+ if (chunk == NULL) {
+ print_usage();
+ return 1;
+ }
+ if (dostring(chunk, "=<command line>") != 0)
+ return 1;
+ break;
+ }
+ case 'l': {
+ const char *filename = argv[i] + 2;
+ if (*filename == '\0') filename = argv[++i];
+ if (filename == NULL) {
+ print_usage();
+ return 1;
+ }
+ if (load_file(filename))
+ return 1; /* stop if file fails */
+ break;
+ }
+ case 'c': {
+ l_message(progname, "option `-c' is deprecated");
+ break;
+ }
+ case 's': {
+ l_message(progname, "option `-s' is deprecated");
+ break;
+ }
+ default: {
+ print_usage();
+ return 1;
+ }
+ }
+ } endloop:
+ if (argv[i] != NULL) {
+ const char *filename = argv[i];
+ getargs(argv, i); /* collect arguments */
+ lua_setglobal(L, "arg");
+ return file_input(filename); /* stop scanning arguments */
+ }
+ }
+ return 0;
+}
+
+
+static void openstdlibs (lua_State *l) {
+ const luaL_reg *lib = lualibs;
+ for (; lib->func; lib++) {
+ lib->func(l); /* open library */
+ lua_settop(l, 0); /* discard any results */
+ }
+}
+
+
+static int handle_luainit (void) {
+ const char *init = getenv("LUA_INIT");
+ if (init == NULL) return 0; /* status OK */
+ else if (init[0] == '@')
+ return file_input(init+1);
+ else
+ return dostring(init, "=LUA_INIT");
+}
+
+
+struct Smain {
+ int argc;
+ char **argv;
+ int status;
+};
+
+
+static int pmain (lua_State *l) {
+ struct Smain *s = (struct Smain *)lua_touserdata(l, 1);
+ int status;
+ int interactive = 0;
+ if (s->argv[0] && s->argv[0][0]) progname = s->argv[0];
+ L = l;
+ lua_userinit(l); /* open libraries */
+ status = handle_luainit();
+ if (status == 0) {
+ status = handle_argv(s->argv, &interactive);
+ if (status == 0 && interactive) manual_input();
+ }
+ s->status = status;
+ return 0;
+}
+
+
+int main (int argc, char *argv[]) {
+ int status;
+ struct Smain s;
+ lua_State *l = lua_open(); /* create state */
+ if (l == NULL) {
+ l_message(argv[0], "cannot create state: not enough memory");
+ return EXIT_FAILURE;
+ }
+ s.argc = argc;
+ s.argv = argv;
+ status = lua_cpcall(l, &pmain, &s);
+ report(status);
+ lua_close(l);
+ return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
diff --git a/trunk/Examples/lua/owner/Makefile b/trunk/Examples/lua/owner/Makefile
new file mode 100644
index 000000000..1fe68ec7f
--- /dev/null
+++ b/trunk/Examples/lua/owner/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/owner/example.cxx b/trunk/Examples/lua/owner/example.cxx
new file mode 100644
index 000000000..d6caeef15
--- /dev/null
+++ b/trunk/Examples/lua/owner/example.cxx
@@ -0,0 +1,69 @@
+/* File : example.c */
+
+#include "example.h"
+#include <stdio.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;
+}
+
+Circle* createCircle(double w)
+{
+ return new Circle(w);
+}
+
+Square* createSquare(double w)
+{
+ return new Square(w);
+}
+
+ShapeOwner::ShapeOwner() {printf(" ShapeOwner(%p)\n",this);}
+ShapeOwner::~ShapeOwner()
+{
+ printf(" ~ShapeOwner(%p)\n",this);
+ for(unsigned i=0;i<shapes.size();i++)
+ delete shapes[i];
+}
+
+void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object
+{
+ shapes.push_back(ptr);
+}
+
+Shape* ShapeOwner::get(int idx) // this pointer is still owned by the class (assessor)
+{
+ if (idx < 0 || idx >= static_cast<int>(shapes.size()))
+ return NULL;
+ return shapes[idx];
+}
+
+Shape* ShapeOwner::remove(int idx) // this method returns memory which must be deleted
+{
+ if (idx < 0 || idx >= static_cast<int>(shapes.size()))
+ return NULL;
+ Shape* ptr=shapes[idx];
+ shapes.erase(shapes.begin()+idx);
+ return ptr;
+}
diff --git a/trunk/Examples/lua/owner/example.h b/trunk/Examples/lua/owner/example.h
new file mode 100644
index 000000000..b00568025
--- /dev/null
+++ b/trunk/Examples/lua/owner/example.h
@@ -0,0 +1,54 @@
+/* File : example.h */
+#include <vector>
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+Circle* createCircle(double w); // this method creates a new object
+Square* createSquare(double w); // this method creates a new object
+
+class ShapeOwner {
+private:
+ std::vector<Shape*> shapes;
+ ShapeOwner(const ShapeOwner&); // no copying
+ ShapeOwner& operator=(const ShapeOwner&); // no copying
+public:
+ ShapeOwner();
+ ~ShapeOwner();
+ void add(Shape* ptr); // this method takes ownership of the object
+ Shape* get(int idx); // this pointer is still owned by the class (assessor)
+ Shape* remove(int idx); // this method returns memory which must be deleted
+};
+
+
diff --git a/trunk/Examples/lua/owner/example.i b/trunk/Examples/lua/owner/example.i
new file mode 100644
index 000000000..4e7c331bc
--- /dev/null
+++ b/trunk/Examples/lua/owner/example.i
@@ -0,0 +1,32 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+// before we grab the header file, we must warn SWIG about some of these functions.
+
+// these functions create data, so must be managed
+%newobject createCircle;
+%newobject createSquare;
+
+// this method returns as pointer which must be managed
+%newobject ShapeOwner::remove;
+
+// you cannot use %delobject on ShapeOwner::add()
+// as this disowns the ShapeOwner, not the Shape (oops)
+//%delobject ShapeOwner::add(Shape*); DO NOT USE
+
+// either you can use a new function (such as this)
+/*%delobject add_Shape;
+%inline %{
+void add_Shape(Shape* s,ShapeOwner* own){own->add(s);}
+%}*/
+
+// or a better solution is a typemap
+%apply SWIGTYPE *DISOWN {Shape* ptr};
+
+// now we can grab the header file
+%include "example.h"
+
diff --git a/trunk/Examples/lua/owner/runme.lua b/trunk/Examples/lua/owner/runme.lua
new file mode 100644
index 000000000..d2d8a9c6f
--- /dev/null
+++ b/trunk/Examples/lua/owner/runme.lua
@@ -0,0 +1,104 @@
+-- Operator overloading example
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+print "ok, lets test Lua's ownership of C++ objects"
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
+
+print "\nLets make a couple"
+a=example.Square(10)
+b=example.Circle(1)
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 2)")
+
+print "\nNote lets use the createX functions"
+c=example.createCircle(5)
+d=example.createSquare(3)
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
+
+print "\nWe will run the garbage collector & see if they are till here"
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
+
+print "\nLets get rid of them all, collect garbage & see if they are till here"
+a,b,c,d=nil,nil,nil,nil
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
+
+print "\nLets start putting stuff into the ShapeOwner"
+print "The ShapeOwner now owns the shapes, but Lua still has pointers to them"
+o=example.ShapeOwner()
+a=example.Square(10)
+b=example.Circle(1)
+o:add(a)
+o:add(b)
+o:add(example.createSquare(5))
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
+
+print "\nWe will nil our references,run the garbage collector & see if they are till here"
+print "they should be, as the ShapeOwner owns them"
+a,b=nil,nil
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
+
+print "\nWe will access them and check that they are still valid"
+a=o:get(0)
+b=o:get(1)
+print(" Area's are",a:area(),b:area(),o:get(2):area())
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
+
+print "\nWe will remove one from the C++ owner & pass its ownership to Lua,"
+print " then check that they are still unchanged"
+a,b=nil,nil
+a=o:remove(0) -- a now owns it
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
+
+print "\nDelete the ShapeOwner (this should destroy two shapes),"
+print " but we have one left in Lua"
+o=nil
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 1)")
+
+print "\nFinal tidy up "
+a=nil
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
+
+
+print "Final test, we will create some Shapes & pass them around like mad"
+print "If there is any memory leak, you will see it in the memory usage"
+io.flush()
+sh={}
+-- make some objects
+for i=0,10 do
+ a=example.Circle(i)
+ b=example.Square(i)
+ sh[a]=true
+ sh[b]=true
+end
+o=example.ShapeOwner()
+for i=0,10000 do
+ for k,_ in pairs(sh) do
+ o:add(k)
+ end
+ sh={} -- clear it
+ while true do
+ a=o:remove(0)
+ if a==nil then break end
+ sh[a]=true
+ end
+ if i%100==0 then collectgarbage() end
+end
+print "done"
+o,sh=nil,nil
+collectgarbage()
+print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
+print "thats all folks!" \ No newline at end of file
diff --git a/trunk/Examples/lua/pointer/Makefile b/trunk/Examples/lua/pointer/Makefile
new file mode 100644
index 000000000..ac0fff43e
--- /dev/null
+++ b/trunk/Examples/lua/pointer/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/pointer/example.c b/trunk/Examples/lua/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/trunk/Examples/lua/pointer/example.c
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(int *x, int *y, int *result) {
+ *result = *x + *y;
+}
+
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/trunk/Examples/lua/pointer/example.i b/trunk/Examples/lua/pointer/example.i
new file mode 100644
index 000000000..d49365ba1
--- /dev/null
+++ b/trunk/Examples/lua/pointer/example.i
@@ -0,0 +1,35 @@
+/* File : example.i */
+%module example
+
+%{
+ #include <stdlib.h>
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+%inline %{
+extern void add(int *x, int *y, int *result);
+%}
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+%{
+extern void sub(int *, int *, int *);
+%}
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+%inline %{
+extern int divide(int n, int d, int *r);
+%}
+
+
+
+
diff --git a/trunk/Examples/lua/pointer/runme.lua b/trunk/Examples/lua/pointer/runme.lua
new file mode 100644
index 000000000..8deee67e6
--- /dev/null
+++ b/trunk/Examples/lua/pointer/runme.lua
@@ -0,0 +1,48 @@
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+-- First create some objects using the pointer library.
+print("Testing the pointer library")
+a = example.new_intp()
+b = example.new_intp()
+c = example.new_intp()
+example.intp_assign(a,37)
+example.intp_assign(b,42)
+
+print(" a = "..tostring(a))
+print(" b = "..tostring(b))
+print(" c = "..tostring(c))
+
+-- Call the add() function with some pointers
+example.add(a,b,c)
+
+-- Now get the result
+r = example.intp_value(c)
+print(" 37 + 42 = "..r)
+
+-- Clean up the pointers
+-- since this is C-style pointers you must clean it up
+example.delete_intp(a)
+example.delete_intp(b)
+example.delete_intp(c)
+
+-- Now try the typemap library
+-- This should be much easier. Now how it is no longer
+-- necessary to manufacture pointers.
+
+print("Trying the typemap library")
+r = example.sub(37,42)
+print(" 37 - 42 = "..r)
+
+-- Now try the version with multiple return values
+
+print("Testing multiple return values")
+q,r = example.divide(42,37)
+print(" 42/37 = "..q.." remainder "..r)
diff --git a/trunk/Examples/lua/simple/Makefile b/trunk/Examples/lua/simple/Makefile
new file mode 100644
index 000000000..f181818a6
--- /dev/null
+++ b/trunk/Examples/lua/simple/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/simple/example.c b/trunk/Examples/lua/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/lua/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/trunk/Examples/lua/simple/example.i b/trunk/Examples/lua/simple/example.i
new file mode 100644
index 000000000..86ae9f361
--- /dev/null
+++ b/trunk/Examples/lua/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%} \ No newline at end of file
diff --git a/trunk/Examples/lua/simple/runme.lua b/trunk/Examples/lua/simple/runme.lua
new file mode 100644
index 000000000..1e5a139c8
--- /dev/null
+++ b/trunk/Examples/lua/simple/runme.lua
@@ -0,0 +1,35 @@
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+-- Call our gcd() function
+x = 42
+y = 105
+g = example.gcd(x,y)
+print("The gcd of",x,"and",y,"is",g)
+
+-- Manipulate the Foo global variable
+
+-- Output its current value
+print("Foo = ", example.Foo)
+
+-- Change its value
+example.Foo = 3.1415926
+
+-- See if the change took effect
+print("Foo = ", example.Foo)
+
+
+
+
+
+
+
+
+
diff --git a/trunk/Examples/lua/variables/Makefile b/trunk/Examples/lua/variables/Makefile
new file mode 100644
index 000000000..f181818a6
--- /dev/null
+++ b/trunk/Examples/lua/variables/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile lua_clean
+
+check: all
diff --git a/trunk/Examples/lua/variables/example.c b/trunk/Examples/lua/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/lua/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/lua/variables/example.h b/trunk/Examples/lua/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/lua/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/lua/variables/example.i b/trunk/Examples/lua/variables/example.i
new file mode 100644
index 000000000..591b871ed
--- /dev/null
+++ b/trunk/Examples/lua/variables/example.i
@@ -0,0 +1,49 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/lua/variables/runme.lua b/trunk/Examples/lua/variables/runme.lua
new file mode 100644
index 000000000..05b2d3fbf
--- /dev/null
+++ b/trunk/Examples/lua/variables/runme.lua
@@ -0,0 +1,81 @@
+---- importing ----
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ -- lua5.0 doesnt have a nice way to do this
+ lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
+ assert(lib)()
+else
+ -- lua 5.1 does
+ require('example')
+end
+
+-- Try to set the values of some global variables
+
+example.ivar = 42
+example.svar = -31000
+example.lvar = 65537
+example.uivar = 123456
+example.usvar = 61000
+example.ulvar = 654321
+example.scvar = -13
+example.ucvar = 251
+example.cvar = "S"
+example.fvar = 3.14159
+example.dvar = 2.1828
+example.strvar = "Hello World"
+example.iptrvar= example.new_int(37)
+example.ptptr = example.new_Point(37,42)
+example.name = "Bill"
+
+-- Now print out the values of the variables
+
+print("Variables (values printed from Lua)")
+
+print("ivar =", example.ivar)
+print("svar =", example.svar)
+print("lvar =", example.lvar)
+print("uivar =", example.uivar)
+print("usvar =", example.usvar)
+print("ulvar =", example.ulvar)
+print("scvar =", example.scvar)
+print("ucvar =", example.ucvar)
+print("fvar =", example.fvar)
+print("dvar =", example.dvar)
+print("cvar =", example.cvar)
+print("strvar =", example.strvar)
+print("cstrvar =", example.cstrvar)
+print("iptrvar =", example.iptrvar)
+print("name =", example.name)
+print("ptptr =", example.ptptr, example.Point_print(example.ptptr))
+print("pt =", example.pt, example.Point_print(example.pt))
+
+print("\nVariables (values printed from C)")
+
+example.print_vars()
+
+print "\nNow I'm going to try and modify some read only variables";
+
+print " Tring to set 'path' to 'Whoa!'";
+if pcall(function() example.path = "Whoa!" end)==true then
+ print " Thats funny, it didn't give an error!"
+else
+ print " It gave an error, as it should"
+end
+print(" Just checking the value: path =", example.path)
+
+print " Trying to set 'status' to '0'";
+if pcall(function() example.status = 0 end)==true then
+ print " Thats funny, it didn't give an error!"
+else
+ print " It gave an error, as it should"
+end
+print(" Just checking the value: status =", example.status)
+
+
+print "\nI'm going to try and update a structure variable.\n"
+
+example.pt = example.ptptr
+
+print "The new value is"
+example.pt_print()
+print("You should see the value", example.Point_print(example.ptptr))
+
diff --git a/trunk/Examples/modula3/check.list b/trunk/Examples/modula3/check.list
new file mode 100644
index 000000000..37ac8c105
--- /dev/null
+++ b/trunk/Examples/modula3/check.list
@@ -0,0 +1,7 @@
+# see top-level Makefile.in
+class
+enum
+exception
+reference
+simple
+typemap
diff --git a/trunk/Examples/modula3/class/Makefile b/trunk/Examples/modula3/class/Makefile
new file mode 100644
index 000000000..bf929a061
--- /dev/null
+++ b/trunk/Examples/modula3/class/Makefile
@@ -0,0 +1,25 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+PLATFORM = LINUXLIBC6
+INTERFACE = example.i
+SWIGOPT = -c++
+MODULA3SRCS = *.[im]3
+
+all:: modula3
+
+modula3::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
+ m3ppinplace $(MODULA3SRCS)
+# compilation of example_wrap.cxx is started by cm3
+# $(CXX) -c $(TARGET)_wrap.cxx
+ mv example_wrap.cxx m3makefile $(MODULA3SRCS) src/
+ ln -sf ../example.h src/example.h
+ cm3
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile modula3_clean
+
+check: all
diff --git a/trunk/Examples/modula3/class/example.cxx b/trunk/Examples/modula3/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/modula3/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/modula3/class/example.h b/trunk/Examples/modula3/class/example.h
new file mode 100644
index 000000000..9c1f47995
--- /dev/null
+++ b/trunk/Examples/modula3/class/example.h
@@ -0,0 +1,44 @@
+/* File : example.h */
+
+class Shape
+{
+public:
+ Shape ()
+ {
+ nshapes++;
+ }
+ virtual ~ Shape ()
+ {
+ nshapes--;
+ };
+ double x, y;
+ void move (double dx, double dy);
+ virtual double area (void) const = 0;
+ virtual double perimeter (void) const = 0;
+protected:
+ static int nshapes;
+};
+
+class Circle:public Shape
+{
+private:
+ double radius;
+public:
+ Circle (double r):radius (r)
+ {
+ };
+ virtual double area (void) const;
+ virtual double perimeter (void) const;
+};
+
+class Square:public Shape
+{
+private:
+ double width;
+public:
+ Square (double w):width (w)
+ {
+ };
+ virtual double area (void) const;
+ virtual double perimeter (void) const;
+};
diff --git a/trunk/Examples/modula3/class/example.i b/trunk/Examples/modula3/class/example.i
new file mode 100644
index 000000000..2fafadbd6
--- /dev/null
+++ b/trunk/Examples/modula3/class/example.i
@@ -0,0 +1,32 @@
+/* File : example.i */
+%module Example
+
+%{
+#include "example.h"
+%}
+
+%insert(m3makefile) %{template("../swig")
+cxx_source("example_wrap")%}
+
+%typemap(m3rawinmode) Shape *, Circle *, Square * ""
+%typemap(m3rawrettype) Shape *, Circle *, Square * "$1_basetype"
+
+%typemap(m3wrapinmode) Shape *, Circle *, Square * ""
+%typemap(m3wrapargraw) Shape *, Circle *, Square * "self.cxxObj"
+
+%typemap(m3wrapretvar) Circle *, Square * "cxxObj : ExampleRaw.$1_basetype;"
+%typemap(m3wrapretraw) Circle *, Square * "cxxObj"
+%typemap(m3wrapretconv) Circle *, Square * "NEW($1_basetype,cxxObj:=cxxObj)"
+%typemap(m3wraprettype) Circle *, Square * "$1_basetype"
+
+/* Should work with and without renaming
+%rename(M3Shape) Shape;
+%rename(M3Circle) Circle;
+%rename(M3Square) Square;
+%typemap(m3wrapintype) Shape *, Circle *, Square * "M3$1_basetype"
+%typemap(m3wraprettype) Shape *, Circle *, Square * "M3$1_basetype"
+%typemap(m3wrapretconv) Circle *, Square * "NEW(M3$1_basetype,cxxObj:=cxxObj)"
+*/
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/trunk/Examples/modula3/class/swig.tmpl b/trunk/Examples/modula3/class/swig.tmpl
new file mode 100644
index 000000000..e3e9bf178
--- /dev/null
+++ b/trunk/Examples/modula3/class/swig.tmpl
@@ -0,0 +1,11 @@
+
+readonly proc cxx_source (X) is
+ local cxxfile = X&".cxx"
+ local objfile = X&".o"
+ %exec("echo $PWD")
+ if stale(objfile,cxxfile)
+ exec("cd",path(),"; g++ -I.. -c -o",objfile,cxxfile)
+ end
+ import_obj(X)
+ %unlink_file(path()&SL&objfile)
+end
diff --git a/trunk/Examples/modula3/enum/Makefile b/trunk/Examples/modula3/enum/Makefile
new file mode 100644
index 000000000..b5bf8f672
--- /dev/null
+++ b/trunk/Examples/modula3/enum/Makefile
@@ -0,0 +1,26 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+CONSTNUMERIC = example_const
+SWIGOPT = -c++
+MODULA3SRCS = *.[im]3
+
+all:: modula3
+
+modula3::
+ $(SWIG) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h
+ $(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC)
+ $(CONSTNUMERIC) >$(CONSTNUMERIC).i
+
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
+ m3ppinplace $(MODULA3SRCS)
+ mv m3makefile $(MODULA3SRCS) src/
+ cm3
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile modula3_clean
+
+check: all
diff --git a/trunk/Examples/modula3/enum/example.cxx b/trunk/Examples/modula3/enum/example.cxx
new file mode 100644
index 000000000..bd808ff7c
--- /dev/null
+++ b/trunk/Examples/modula3/enum/example.cxx
@@ -0,0 +1,32 @@
+/* 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 if (s == HYPER) {
+ printf("HYPER speed\n");
+ } else {
+ printf("Unknown speed\n");
+ }
+}
+
+void enum_test(color c, Foo::speed s) {
+ if (c == RED) {
+ printf("color = RED, ");
+ } else if (c == BLUE) {
+ printf("color = BLUE, ");
+ } else if (c == GREEN) {
+ printf("color = GREEN, ");
+ } else {
+ printf("color = Unknown color!, ");
+ }
+ Foo obj;
+ obj.enum_test(s);
+}
diff --git a/trunk/Examples/modula3/enum/example.h b/trunk/Examples/modula3/enum/example.h
new file mode 100644
index 000000000..2f44a6ccf
--- /dev/null
+++ b/trunk/Examples/modula3/enum/example.h
@@ -0,0 +1,83 @@
+/* File : example.h */
+
+#define PI 3.141
+
+#define DAY_MONDAY 0
+#define DAY_TUESDAY 1
+#define DAY_WEDNESDAY 2
+#define DAY_THURSDAY 3
+#define DAY_FRIDAY 4
+#define DAY_SATURDAY 5
+#define DAY_SUNDAY 6
+
+enum color { BLUE, RED, GREEN };
+
+#define CLB_BLACK 0
+#define CLB_BLUE 1
+#define CLB_RED 2
+#define CLB_MAGENTA 3
+#define CLB_GREEN 4
+#define CLB_CYAN 5
+#define CLB_YELLOW 6
+#define CLB_WHITE 7
+
+/* Using this would be good style
+ which cannot be expected for general C header files.
+ Instead I want to demonstrate how to live without it.
+enum month {
+ MTHF_JANUARY,
+ MTHF_FEBRUARY,
+ MTHF_MARCH,
+ MTHF_APRIL,
+ MTHF_MAY,
+ MTHF_JUNE,
+ MTHF_JULY,
+ MTHF_AUGUST,
+ MTHF_SEPTEMBER,
+ MTHF_OCTOBER,
+ MTHF_NOVEMBER,
+ MTHF_DECEMBER,
+}
+*/
+
+/* Since there are no compile time constants in C / C++
+ it is a common abuse
+ to declare bit set (flag) constants
+ as enumerations. */
+enum calendar {
+ MTHB_JANUARY = 1 << 0, /* 1 << MTHF_JANUARY, */
+ MTHB_FEBRUARY = 1 << 1, /* 1 << MTHF_FEBRUARY, */
+ MTHB_MARCH = 1 << 2, /* 1 << MTHF_MARCH, */
+ MTHB_APRIL = 1 << 3, /* 1 << MTHF_APRIL, */
+ MTHB_MAY = 1 << 4, /* 1 << MTHF_MAY, */
+ MTHB_JUNE = 1 << 5, /* 1 << MTHF_JUNE, */
+ MTHB_JULY = 1 << 6, /* 1 << MTHF_JULY, */
+ MTHB_AUGUST = 1 << 7, /* 1 << MTHF_AUGUST, */
+ MTHB_SEPTEMBER = 1 << 8, /* 1 << MTHF_SEPTEMBER, */
+ MTHB_OCTOBER = 1 << 9, /* 1 << MTHF_OCTOBER, */
+ MTHB_NOVEMBER = 1 << 10, /* 1 << MTHF_NOVEMBER, */
+ MTHB_DECEMBER = 1 << 11, /* 1 << MTHF_DECEMBER, */
+
+ MTHB_SPRING = MTHB_MARCH | MTHB_APRIL | MTHB_MAY,
+ MTHB_SUMMER = MTHB_JUNE | MTHB_JULY | MTHB_AUGUST,
+ MTHB_AUTUMN = MTHB_SEPTEMBER | MTHB_OCTOBER | MTHB_NOVEMBER,
+ MTHB_WINTER = MTHB_DECEMBER | MTHB_JANUARY | MTHB_FEBRUARY,
+};
+
+
+namespace Answer {
+ enum {
+ UNIVERSE_AND_EVERYTHING = 42,
+ SEVENTEEN_AND_FOUR = 21,
+ TWOHUNDRED_PERCENT_OF_NOTHING = 0,
+ };
+
+ class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE = -2, WARP = 0, HYPER, LUDICROUS = 3};
+ void enum_test(speed s);
+ };
+};
+
+void enum_test(color c, Answer::Foo::speed s);
diff --git a/trunk/Examples/modula3/enum/example.i b/trunk/Examples/modula3/enum/example.i
new file mode 100644
index 000000000..f5947b3bc
--- /dev/null
+++ b/trunk/Examples/modula3/enum/example.i
@@ -0,0 +1,72 @@
+/* File : example.i */
+%module Example
+
+%{
+#include "example.h"
+%}
+
+%include "example_const.i"
+
+// such features are generated by the following pragmas
+#if 0
+%feature("modula3:enumitem:enum","Days") DAY_MONDAY;
+%feature("modula3:enumitem:name","monday") DAY_MONDAY;
+%feature("modula3:enumitem:conv","int:int") DAY_MONDAY;
+
+%feature("modula3:enumitem:enum","Month") MTHB_JANUARY;
+%feature("modula3:enumitem:name","january") MTHB_JANUARY;
+%feature("modula3:enumitem:conv","set:int") MTHB_JANUARY;
+//%feature("modula3:constset:type","MonthSet") MTHB_JANUARY; /*type in the constant definition*/
+%feature("modula3:constset:set", "MonthSet") MTHB_JANUARY; /*remarks that the 'type' is a set type*/
+%feature("modula3:constset:base","Month") MTHB_JANUARY;
+%feature("modula3:constset:name","monthsJanuary") MTHB_JANUARY;
+%feature("modula3:constset:conv","set:set") MTHB_JANUARY; /*conversion of the bit pattern: no change*/
+
+%feature("modula3:enumitem:enum","Color") BLUE;
+%feature("modula3:enumitem:name","blue") BLUE;
+%feature("modula3:enumitem:conv","int:int") BLUE;
+
+%feature("modula3:constint:type","INTEGER") Foo::IMPULSE;
+%feature("modula3:constint:name","impulse") Foo::IMPULSE;
+%feature("modula3:constint:conv","int:int") Foo::IMPULSE;
+#endif
+
+%rename(pi) PI;
+
+%pragma(modula3) enumitem="prefix=DAY_;int;srcstyle=underscore;Day";
+
+%pragma(modula3) enumitem="enum=color;int;srcstyle=underscore;Color";
+%pragma(modula3) makesetofenum="Color";
+%pragma(modula3) constset="prefix=CLB_;set;srcstyle=underscore,prefix=clb;ColorSet,Color";
+
+%pragma(modula3) enumitem="prefix=MTHB_,enum=calendar;set;srcstyle=underscore;Month";
+%pragma(modula3) makesetofenum="Month";
+%pragma(modula3) constset="prefix=MTHB_,enum=calendar;set;srcstyle=underscore,prefix=monthset;MonthSet,Month";
+
+%pragma(modula3) constint="prefix=Answer::Foo::,enum=Answer::Foo::speed;int;srcstyle=underscore,prefix=speed;INTEGER";
+
+%pragma(modula3) constint="prefix=Answer::,enum=Answer::;int;srcstyle=underscore,prefix=answer;CARDINAL";
+
+%rename(AnswerFoo) Answer::Foo;
+%typemap("m3rawrettype") Answer::Foo * %{AnswerFoo%}
+%typemap("m3rawintype") Answer::Foo * %{AnswerFoo%}
+%typemap("m3rawinmode") Answer::Foo * %{%}
+%typemap("m3wraprettype") Answer::Foo * %{AnswerFoo%}
+%typemap("m3wrapintype") Answer::Foo * %{AnswerFoo%}
+%typemap("m3wrapinmode") Answer::Foo * %{%}
+%typemap("m3wrapargraw") Answer::Foo * %{self.cxxObj%}
+
+%typemap("m3wrapretvar") Answer::Foo * %{cxxObj : ExampleRaw.AnswerFoo;%}
+%typemap("m3wrapretraw") Answer::Foo * %{cxxObj%}
+%typemap("m3wrapretconv") Answer::Foo * %{NEW(AnswerFoo,cxxObj:=cxxObj)%}
+
+
+%typemap("m3rawintype") Answer::Foo::speed %{C.int%};
+%typemap("m3rawintype:import") Answer::Foo::speed %{Ctypes AS C%};
+%typemap("m3wrapintype") Answer::Foo::speed %{[-2..3]%};
+
+%typemap("m3wrapintype") color %{Color%};
+%typemap("m3wrapargraw") color %{ORD($1_name)%};
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/trunk/Examples/modula3/exception/Makefile b/trunk/Examples/modula3/exception/Makefile
new file mode 100644
index 000000000..2518a2203
--- /dev/null
+++ b/trunk/Examples/modula3/exception/Makefile
@@ -0,0 +1,23 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+MODULA3SRCS = *.[im]3
+MODULA3FLAGS= -o runme
+
+all:: modula3
+
+modula3::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp
+# $(MAKE) -f $(TOP)/Makefile MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile
+ m3ppinplace $(MODULA3SRCS)
+ mv m3makefile $(MODULA3SRCS) src/
+ cm3
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile modula3_clean
+
+check: all
diff --git a/trunk/Examples/modula3/exception/example.h b/trunk/Examples/modula3/exception/example.h
new file mode 100644
index 000000000..0e9e0e81d
--- /dev/null
+++ b/trunk/Examples/modula3/exception/example.h
@@ -0,0 +1,18 @@
+/* File : example.h */
+
+enum error {OK, OVERFLOW, DIVISION_BY_ZERO, NEGATIVE_RADICAND, NEGATIVE_BASE};
+typedef error errorstate; /* just to separate the typemaps */
+
+error acc_add (double &x, double y);
+error acc_sub (double &x, double y);
+error acc_mul (double &x, double y);
+error acc_div (double &x, double y);
+
+double op_add (double x, double y, errorstate &err);
+double op_sub (double x, double y, errorstate &err);
+double op_mul (double x, double y, errorstate &err);
+double op_div (double x, double y, errorstate &err);
+double op_sqrt (double x, errorstate &err);
+double op_pow (double x, double y, errorstate &err);
+
+double op_noexc (double x, double y);
diff --git a/trunk/Examples/modula3/exception/example.i b/trunk/Examples/modula3/exception/example.i
new file mode 100644
index 000000000..92a716fae
--- /dev/null
+++ b/trunk/Examples/modula3/exception/example.i
@@ -0,0 +1,43 @@
+/* File : example.i */
+%module Example
+
+%{
+#include "example.h"
+%}
+
+%insert(m3wrapintf) %{
+EXCEPTION E(Error);
+%}
+%insert(m3wrapimpl) %{
+IMPORT Ctypes AS C;
+%}
+
+%pragma(modula3) enumitem="enum=error;int;srcstyle=underscore;Error";
+
+%typemap("m3rawintype") double & %{C.double%};
+%typemap("m3wrapintype") double & %{LONGREAL%};
+
+%typemap("m3wraprettype") error ""
+%typemap("m3wrapretvar") error "rawerr: C.int;"
+%typemap("m3wrapretraw") error "rawerr"
+%typemap("m3wrapretcheck:throws") error "E"
+%typemap("m3wrapretcheck") error
+%{VAR err := VAL(rawerr, Error);
+BEGIN
+IF err # Error.ok THEN
+RAISE E(err);
+END;
+END;%}
+
+%typemap("m3rawintype") errorstate & %{C.int%};
+%typemap("m3wrapintype",numinputs=0) errorstate & %{%};
+%typemap("m3wrapargvar") errorstate & %{err:C.int:=ORD(Error.ok);%};
+%typemap("m3wrapoutcheck:throws") errorstate & "E";
+%typemap("m3wrapoutcheck") errorstate &
+%{IF VAL(err,Error) # Error.ok THEN
+RAISE E(VAL(err,Error));
+END;%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
diff --git a/trunk/Examples/modula3/reference/Makefile b/trunk/Examples/modula3/reference/Makefile
new file mode 100644
index 000000000..b31577a58
--- /dev/null
+++ b/trunk/Examples/modula3/reference/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT = -c++
+MODULA3SRCS = *.[im]3
+
+all:: modula3
+
+modula3::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
+ m3ppinplace $(MODULA3SRCS)
+ mv m3makefile $(MODULA3SRCS) src/
+ cm3
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile modula3_clean
+
+check: all
diff --git a/trunk/Examples/modula3/reference/example.cxx b/trunk/Examples/modula3/reference/example.cxx
new file mode 100644
index 000000000..649b0169c
--- /dev/null
+++ b/trunk/Examples/modula3/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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)", (int)this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/modula3/reference/example.h b/trunk/Examples/modula3/reference/example.h
new file mode 100644
index 000000000..0a9cd447f
--- /dev/null
+++ b/trunk/Examples/modula3/reference/example.h
@@ -0,0 +1,22 @@
+/* File : example.h */
+
+struct Vector {
+private:
+ double x,y,z;
+public:
+ Vector() : x(0), y(0), z(0) { };
+ Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+ Vector operator+(const Vector &b) const;
+ char *print();
+};
+
+struct VectorArray {
+private:
+ Vector *items;
+ int maxsize;
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ Vector &operator[](int);
+ int size();
+};
diff --git a/trunk/Examples/modula3/reference/example.i b/trunk/Examples/modula3/reference/example.i
new file mode 100644
index 000000000..002090918
--- /dev/null
+++ b/trunk/Examples/modula3/reference/example.i
@@ -0,0 +1,32 @@
+/* File : example.i */
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module Example
+
+%{
+#include "example.h"
+%}
+
+%pragma(modula3) unsafe="1";
+
+%insert(m3wrapintf) %{FROM ExampleRaw IMPORT Vector, VectorArray;%}
+%insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Vector, VectorArray;%}
+
+%typemap(m3wrapretvar) Vector %{vec: UNTRACED REF Vector;%}
+%typemap(m3wrapretraw) Vector %{vec%}
+%typemap(m3wrapretconv) Vector %{vec^%}
+
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(const Vector &a, const Vector &b) {
+ return a+b;
+}
+%}
+
+%rename(Vector_Clear) Vector::Vector();
+%rename(Add) Vector::operator+;
+%rename(GetItem) VectorArray::operator[];
+
+%include "example.h"
diff --git a/trunk/Examples/modula3/simple/Makefile b/trunk/Examples/modula3/simple/Makefile
new file mode 100644
index 000000000..834521fa5
--- /dev/null
+++ b/trunk/Examples/modula3/simple/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+MODULA3SRCS = *.[im]3
+
+all:: modula3
+
+modula3::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
+ m3ppinplace $(MODULA3SRCS)
+ mv m3makefile $(MODULA3SRCS) src/
+ cm3
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile modula3_clean
+
+check: all
diff --git a/trunk/Examples/modula3/simple/example.c b/trunk/Examples/modula3/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/modula3/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/trunk/Examples/modula3/simple/example.i b/trunk/Examples/modula3/simple/example.i
new file mode 100644
index 000000000..1694e6dbe
--- /dev/null
+++ b/trunk/Examples/modula3/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module Example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/modula3/typemap/Makefile b/trunk/Examples/modula3/typemap/Makefile
new file mode 100644
index 000000000..834521fa5
--- /dev/null
+++ b/trunk/Examples/modula3/typemap/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+MODULA3SRCS = *.[im]3
+
+all:: modula3
+
+modula3::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
+ m3ppinplace $(MODULA3SRCS)
+ mv m3makefile $(MODULA3SRCS) src/
+ cm3
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile modula3_clean
+
+check: all
diff --git a/trunk/Examples/modula3/typemap/example.i b/trunk/Examples/modula3/typemap/example.i
new file mode 100644
index 000000000..2f454eff3
--- /dev/null
+++ b/trunk/Examples/modula3/typemap/example.i
@@ -0,0 +1,90 @@
+/* File : example.i */
+%module Example
+
+%pragma(modula3) unsafe="true";
+
+%insert(m3wrapintf) %{FROM ExampleRaw IMPORT Window, Point;
+%}
+%insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Window, Point;
+IMPORT M3toC;
+IMPORT Ctypes AS C;
+%}
+
+/* Typemap applied to patterns of multiple arguments */
+
+%typemap(m3rawinmode) (char *outstr) %{VAR%}
+%typemap(m3rawintype) (char *outstr) %{CHAR%}
+%typemap(m3wrapinmode) (char *outstr, int size) %{VAR%}
+%typemap(m3wrapintype) (char *outstr, int size) %{ARRAY OF CHAR%}
+%typemap(m3wrapargraw) (char *outstr, int size) %{$1_name[0], NUMBER($1_name)%}
+
+
+%typemap(m3rawinmode) (const struct Window *) %{READONLY%}
+%typemap(m3wrapinmode) (const struct Window *) %{READONLY%}
+%typemap(m3rawintype) ( struct Window *) %{Window%}
+%typemap(m3wrapintype) ( struct Window *) %{Window%}
+
+%typemap(m3rawinmode) (const char *str []) %{READONLY%}
+%typemap(m3wrapinmode) (const char *str []) %{READONLY%}
+%typemap(m3rawintype) (const char *str []) %{(*ARRAY OF*) C.char_star%}
+%typemap(m3wrapintype) (const char *str []) %{ARRAY OF TEXT%}
+%typemap(m3wrapargvar) (const char *str []) %{$1: REF ARRAY OF C.char_star;%}
+%typemap(m3wrapargraw) (const char *str []) %{$1[0]%}
+%typemap(m3wrapinconv) (const char *str []) %{$1:= NEW(REF ARRAY OF C.char_star,NUMBER($1_name));
+FOR i:=FIRST($1_name) TO LAST($1_name) DO
+$1[i]:=M3toC.SharedTtoS($1_name[i]);
+END;%}
+%typemap(m3wrapfreearg) (const char *str [])
+%{FOR i:=FIRST($1_name) TO LAST($1_name) DO
+M3toC.FreeSharedS($1_name[i],$1[i]);
+END;%}
+
+%typemap(m3wraprettype) char * %{TEXT%}
+%typemap(m3wrapretvar) char * %{result_string: C.char_star;%}
+%typemap(m3wrapretraw) char * %{result_string%}
+%typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result_string)%}
+
+struct Window {
+ char *label;
+ int left,top,width,height;
+};
+
+
+%typemap(m3wrapinname) (int x, int y) %{p%}
+%typemap(m3wrapinmode) (int x, int y) %{READONLY%}
+%typemap(m3wrapintype) (int x, int y) %{Point%}
+%typemap(m3wrapargraw) (int x, int y) %{p.$1_name, p.$2_name%}
+
+%typemap(m3wrapargraw) (int &x, int &y) %{p.$1_name, p.$2_name%}
+%typemap(m3wrapintype) (int &x, int &y) %{Point%}
+%typemap(m3wrapoutname) (int &x, int &y) %{p%}
+%typemap(m3wrapouttype) (int &x, int &y) %{Point%}
+%typemap(m3wrapargdir) (int &x, int &y) "out"
+
+
+%typemap(m3wrapargvar) int &left, int &top, int &width, int &height "$1:C.int;"
+%typemap(m3wrapargraw) int &left, int &top, int &width, int &height "$1"
+%typemap(m3wrapoutconv) int &left, int &top, int &width, int &height "$1"
+
+%typemap(m3wrapargdir) int &left, int &top "out"
+
+%typemap(m3wrapouttype) int &width, int &height "CARDINAL"
+%typemap(m3wrapargdir) int &width, int &height "out"
+
+struct Point {
+ int x,y;
+};
+
+%m3multiretval get_box;
+
+void set_label ( struct Window *win, const char *str, bool activate);
+void set_multi_label ( struct Window *win, const char *str []);
+void write_label (const struct Window *win, char *outstr, int size);
+int get_label (const struct Window *win, char *outstr, int size);
+char *get_label_ptr (const struct Window *win);
+void move(struct Window *win, int x, int y);
+int get_area(const struct Window *win);
+void get_box(const struct Window *win, int &left, int &top, int &width, int &height);
+void get_left(const struct Window *win, int &left);
+void get_mouse(const struct Window *win, int &x, int &y);
+int get_attached_data(const struct Window *win, const char *id);
diff --git a/trunk/Examples/mzscheme/check.list b/trunk/Examples/mzscheme/check.list
new file mode 100644
index 000000000..ae728ea43
--- /dev/null
+++ b/trunk/Examples/mzscheme/check.list
@@ -0,0 +1,3 @@
+# see top-level Makefile.in
+multimap
+simple
diff --git a/trunk/Examples/mzscheme/multimap/Makefile b/trunk/Examples/mzscheme/multimap/Makefile
new file mode 100644
index 000000000..a3cfb8f3c
--- /dev/null
+++ b/trunk/Examples/mzscheme/multimap/Makefile
@@ -0,0 +1,13 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
+clean::
+ $(MAKE) -f $(TOP)/Makefile mzscheme_clean
+
+check: all
diff --git a/trunk/Examples/mzscheme/multimap/example.c b/trunk/Examples/mzscheme/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/mzscheme/multimap/example.i b/trunk/Examples/mzscheme/multimap/example.i
new file mode 100644
index 000000000..515948abc
--- /dev/null
+++ b/trunk/Examples/mzscheme/multimap/example.i
@@ -0,0 +1,91 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in) (int argc, char *argv[]) {
+ int i;
+ Scheme_Object **elms;
+ if (!SCHEME_VECTORP($input)) {
+ scheme_wrong_type("$name","vector",$argnum,argc,argv);
+ }
+ $1 = SCHEME_VEC_SIZE($input);
+ elms = SCHEME_VEC_ELS($input);
+ if ($1 == 0) {
+ scheme_wrong_type("$name","vector",$argnum,argc,argv);
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ if (!SCHEME_STRINGP(elms[i])) {
+ free($2);
+ scheme_wrong_type("$name","vector",$argnum,argc,argv);
+ }
+ $2[i] = SCHEME_STR_VAL(elms[i]);
+ }
+ $2[i] = 0;
+}
+
+%typemap(freearg) (int argc, char *argv[]) {
+ free($2);
+}
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+ if (!SCHEME_STRINGP($input)) {
+ scheme_wrong_type("$name","string",1,argc,argv);
+ }
+ $1 = SCHEME_STR_VAL($input);
+ $2 = SCHEME_STRLEN_VAL($input);
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len) {
+ if (!SCHEME_STRINGP($input)) {
+ scheme_wrong_type("$name","string",1,argc,argv);
+ }
+ $2 = SCHEME_STRLEN_VAL($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,SCHEME_STR_VAL($input),$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(argout) (char *str, int len) {
+ Scheme_Object *s;
+ s = scheme_make_sized_string($1,$2,1);
+ SWIG_APPEND_VALUE(s);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ return NULL;
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/trunk/Examples/mzscheme/multimap/example.scm b/trunk/Examples/mzscheme/multimap/example.scm
new file mode 100644
index 000000000..ac9f64283
--- /dev/null
+++ b/trunk/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/trunk/Examples/mzscheme/simple/Makefile b/trunk/Examples/mzscheme/simple/Makefile
new file mode 100644
index 000000000..a3cfb8f3c
--- /dev/null
+++ b/trunk/Examples/mzscheme/simple/Makefile
@@ -0,0 +1,13 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
+clean::
+ $(MAKE) -f $(TOP)/Makefile mzscheme_clean
+
+check: all
diff --git a/trunk/Examples/mzscheme/simple/README b/trunk/Examples/mzscheme/simple/README
new file mode 100644
index 000000000..07e8da069
--- /dev/null
+++ b/trunk/Examples/mzscheme/simple/README
@@ -0,0 +1 @@
+Simple example from users manual.
diff --git a/trunk/Examples/mzscheme/simple/example.c b/trunk/Examples/mzscheme/simple/example.c
new file mode 100644
index 000000000..f2b074781
--- /dev/null
+++ b/trunk/Examples/mzscheme/simple/example.c
@@ -0,0 +1,24 @@
+/* Simple example from documentation */
+/* File : example.c */
+
+#include <time.h>
+
+double My_variable = 3.0;
+
+/* Compute factorial of n */
+int fact(int n) {
+ if (n <= 1) return 1;
+ else return n*fact(n-1);
+}
+
+/* Compute n mod m */
+int my_mod(int n, int m) {
+ return (n % m);
+}
+
+
+char *get_time() {
+ long ltime;
+ time(&ltime);
+ return ctime(&ltime);
+}
diff --git a/trunk/Examples/mzscheme/simple/example.i b/trunk/Examples/mzscheme/simple/example.i
new file mode 100644
index 000000000..5b3e95580
--- /dev/null
+++ b/trunk/Examples/mzscheme/simple/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+%{
+/* Put headers and other declarations here */
+%}
+
+%include typemaps.i
+
+%rename(mod) my_mod;
+
+%inline %{
+extern double My_variable;
+extern int fact(int);
+extern int my_mod(int n, int m);
+extern char *get_time();
+%}
diff --git a/trunk/Examples/mzscheme/simple/example.scm b/trunk/Examples/mzscheme/simple/example.scm
new file mode 100644
index 000000000..8e20345b2
--- /dev/null
+++ b/trunk/Examples/mzscheme/simple/example.scm
@@ -0,0 +1,24 @@
+;; run with mzscheme -r example.scm
+
+(load-extension "example.so")
+
+(display (get-time))
+
+(printf "My-variable = ~a~n" (my-variable))
+
+(let loop ((i 0))
+ (when (< i 14) (begin (display i)
+ (display " factorial is ")
+ (display (fact i))
+ (newline)
+ (loop (+ i 1)))))
+
+(let loop ((i 1))
+ (when (< i 250)
+ (begin
+ (let loopi ((j 1))
+ (when (< j 250) (begin (my-variable (+ (my-variable) (mod i j)))
+ (loopi (+ j 1)))))
+ (loop (+ i 1)))))
+
+(printf "My-variable = ~a~n" (my-variable))
diff --git a/trunk/Examples/mzscheme/std_vector/Makefile b/trunk/Examples/mzscheme/std_vector/Makefile
new file mode 100644
index 000000000..e18726981
--- /dev/null
+++ b/trunk/Examples/mzscheme/std_vector/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+GPP = `which g++`
+MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc
+
+all::
+ $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
+ $(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
+ $(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile mzscheme_clean
+
+check: all
diff --git a/trunk/Examples/mzscheme/std_vector/example.h b/trunk/Examples/mzscheme/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/trunk/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/trunk/Examples/mzscheme/std_vector/example.i b/trunk/Examples/mzscheme/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/trunk/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/trunk/Examples/mzscheme/std_vector/example.scm b/trunk/Examples/mzscheme/std_vector/example.scm
new file mode 100644
index 000000000..0e4ac3f97
--- /dev/null
+++ b/trunk/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/trunk/Examples/ocaml/argout_ref/Makefile b/trunk/Examples/ocaml/argout_ref/Makefile
new file mode 100644
index 000000000..8a260fe30
--- /dev/null
+++ b/trunk/Examples/ocaml/argout_ref/Makefile
@@ -0,0 +1,27 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+MLFILE = example.ml
+PROGFILE = example_prog.ml
+OBJS = example.o
+
+all:: static
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/argout_ref/example.c b/trunk/Examples/ocaml/argout_ref/example.c
new file mode 100644
index 000000000..6f095cddb
--- /dev/null
+++ b/trunk/Examples/ocaml/argout_ref/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+extern "C" void factor( int &x, int &y ) {
+ int gcd_xy = gcd( x,y );
+ x /= gcd_xy;
+ y /= gcd_xy;
+}
diff --git a/trunk/Examples/ocaml/argout_ref/example.i b/trunk/Examples/ocaml/argout_ref/example.i
new file mode 100644
index 000000000..a0be05f24
--- /dev/null
+++ b/trunk/Examples/ocaml/argout_ref/example.i
@@ -0,0 +1,4 @@
+/* File : example.i */
+%module example
+
+extern "C" void factor(int &x, int &y);
diff --git a/trunk/Examples/ocaml/argout_ref/example_prog.ml b/trunk/Examples/ocaml/argout_ref/example_prog.ml
new file mode 100644
index 000000000..c6de34597
--- /dev/null
+++ b/trunk/Examples/ocaml/argout_ref/example_prog.ml
@@ -0,0 +1,26 @@
+(* example_prog.ml *)
+
+open Swig
+open Example
+
+exception BadReturn
+
+let _ = if Array.length Sys.argv < 3 then
+ begin
+ print_endline
+ ("Usage: " ^ Sys.argv.(0) ^ " n1 n2\n" ^
+ " Displays the least factors of the numbers that have the same\n" ^
+ " relationship, 16 12 -> 4 3\n") ;
+ exit 0
+ end
+
+let x = int_of_string Sys.argv.(1)
+let y = int_of_string Sys.argv.(2)
+let (xf,yf) = match _factor '((x to int),(y to int)) with
+ C_list [ C_int a ; C_int b ] -> a,b
+ | _ -> raise BadReturn
+let _ = print_endline
+ ("Factorization of " ^ (string_of_int x) ^
+ " and " ^ (string_of_int y) ^
+ " is " ^ (string_of_int xf) ^
+ " and " ^ (string_of_int yf))
diff --git a/trunk/Examples/ocaml/check.list b/trunk/Examples/ocaml/check.list
new file mode 100644
index 000000000..cbdf270f0
--- /dev/null
+++ b/trunk/Examples/ocaml/check.list
@@ -0,0 +1,10 @@
+# see top-level Makefile.in
+simple
+std_string
+std_vector
+stl
+argout_ref
+shapes
+contract
+scoped_enum
+string_from_ptr
diff --git a/trunk/Examples/ocaml/contract/Makefile b/trunk/Examples/ocaml/contract/Makefile
new file mode 100644
index 000000000..8e0f2a4fd
--- /dev/null
+++ b/trunk/Examples/ocaml/contract/Makefile
@@ -0,0 +1,33 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+MLFILE = example.ml
+PROGFILE = example_prog.ml
+OBJS =
+
+all:: static
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static
+
+toplevel::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_toplevel
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/contract/example.i b/trunk/Examples/ocaml/contract/example.i
new file mode 100644
index 000000000..28d9dd7d6
--- /dev/null
+++ b/trunk/Examples/ocaml/contract/example.i
@@ -0,0 +1,18 @@
+%module example
+%{
+#include <math.h>
+%}
+
+/* File : example.i */
+%module example
+
+%contract cos(double d) {
+require:
+ d >= -3.14159265358979323845254338327950;
+ d < 3.14159265358979323846264338327950;
+ensure:
+ cos >= -1.0;
+ cos <= 1.0;
+}
+
+double cos(double d); \ No newline at end of file
diff --git a/trunk/Examples/ocaml/contract/example_prog.ml b/trunk/Examples/ocaml/contract/example_prog.ml
new file mode 100644
index 000000000..748109c2b
--- /dev/null
+++ b/trunk/Examples/ocaml/contract/example_prog.ml
@@ -0,0 +1,7 @@
+open Swig
+open Example
+
+let _ = print_endline "This won't throw."
+let _ = Printf.printf "Cos 1.0 is %f\n" (_cos '(1.0) as float)
+let _ = print_endline "This will throw."
+let _ = Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float)
diff --git a/trunk/Examples/ocaml/scoped_enum/Makefile b/trunk/Examples/ocaml/scoped_enum/Makefile
new file mode 100644
index 000000000..45c5edca4
--- /dev/null
+++ b/trunk/Examples/ocaml/scoped_enum/Makefile
@@ -0,0 +1,33 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+MLFILE = example.ml
+PROGFILE = example_prog.ml
+OBJS =
+
+all:: static
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+toplevel::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp_toplevel
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/scoped_enum/README b/trunk/Examples/ocaml/scoped_enum/README
new file mode 100644
index 000000000..88b6693fd
--- /dev/null
+++ b/trunk/Examples/ocaml/scoped_enum/README
@@ -0,0 +1 @@
+This tests our handling of scoped enums. Run with argument Tag1 or Tag2. \ No newline at end of file
diff --git a/trunk/Examples/ocaml/scoped_enum/example.i b/trunk/Examples/ocaml/scoped_enum/example.i
new file mode 100644
index 000000000..de553f851
--- /dev/null
+++ b/trunk/Examples/ocaml/scoped_enum/example.i
@@ -0,0 +1,7 @@
+%module example
+
+%{
+#include "foo.h"
+%}
+
+%include "foo.h" \ No newline at end of file
diff --git a/trunk/Examples/ocaml/scoped_enum/example_prog.ml b/trunk/Examples/ocaml/scoped_enum/example_prog.ml
new file mode 100644
index 000000000..e19bb3454
--- /dev/null
+++ b/trunk/Examples/ocaml/scoped_enum/example_prog.ml
@@ -0,0 +1,4 @@
+open Swig
+open Example
+
+let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2)
diff --git a/trunk/Examples/ocaml/scoped_enum/foo.h b/trunk/Examples/ocaml/scoped_enum/foo.h
new file mode 100644
index 000000000..8238cb66d
--- /dev/null
+++ b/trunk/Examples/ocaml/scoped_enum/foo.h
@@ -0,0 +1,5 @@
+namespace foo {
+ enum Bar { Tag1, Tag2 };
+ static void f( Bar b ) { printf( "b = %d\n", (int)b ); }
+}
+
diff --git a/trunk/Examples/ocaml/shapes/Makefile b/trunk/Examples/ocaml/shapes/Makefile
new file mode 100644
index 000000000..31f9934a7
--- /dev/null
+++ b/trunk/Examples/ocaml/shapes/Makefile
@@ -0,0 +1,34 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+MLFILE = example.ml
+PROGFILE = example_prog.ml
+OBJS = example.o
+
+all:: static static_top
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+static_top::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp_toplevel
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
+ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/shapes/example.c b/trunk/Examples/ocaml/shapes/example.c
new file mode 100644
index 000000000..bf0fff937
--- /dev/null
+++ b/trunk/Examples/ocaml/shapes/example.c
@@ -0,0 +1,48 @@
+/* File : example.c */
+#include <stdio.h>
+#include "example.h"
+
+shape::~shape() { }
+
+bool shape::cover( double x, double y ) { return false; }
+
+void draw_shape_coverage( shape *s, int div_x, int div_y ) {
+ double i,j;
+
+ for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) {
+ for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) {
+ if( s->cover( j,i ) ) putchar( 'x' ); else putchar( ' ' );
+ }
+ printf( "\n" );
+ }
+}
+
+void draw_depth_map( volume *v, int div_x, int div_y ) {
+ double i,j;
+ char depth_map_chars[] = "#*+o;:,. ";
+ double lowbound, highbound;
+ double current = 0.0;
+ bool bounds_set = false;
+
+ for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) {
+ for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) {
+ current = v->depth( j,i );
+ if( !bounds_set ) {
+ lowbound = current; highbound = current; bounds_set = true;
+ }
+ if( current < lowbound ) lowbound = current;
+ if( current > highbound ) highbound = current;
+ }
+ }
+
+ for( i = 0; i < 1.0; i += 1.0 / ((float)div_y) ) {
+ for( j = 0; j < 1.0; j += 1.0 / ((float)div_x) ) {
+ current = ((v->depth( j,i ) - lowbound) /
+ (highbound - lowbound)) * 8;
+ putchar(depth_map_chars[(int)current]);
+ }
+ putchar('\n');
+ }
+}
+
+double volume::depth( double x, double y ) { return 0.0; }
diff --git a/trunk/Examples/ocaml/shapes/example.h b/trunk/Examples/ocaml/shapes/example.h
new file mode 100644
index 000000000..4b1644494
--- /dev/null
+++ b/trunk/Examples/ocaml/shapes/example.h
@@ -0,0 +1,18 @@
+#ifndef EXAMPLE_H
+#define EXAMPLE_H
+
+class shape {
+public:
+ virtual ~shape();
+ virtual bool cover( double x, double y ); // does this shape cover this point?
+};
+
+class volume {
+public:
+ virtual double depth( double x, double y );
+};
+
+extern void draw_shape_coverage( shape *s, int div_x, int div_y );
+extern void draw_depth_map( volume *v, int div_x, int div_y );
+
+#endif//EXAMPLE_H
diff --git a/trunk/Examples/ocaml/shapes/example.i b/trunk/Examples/ocaml/shapes/example.i
new file mode 100644
index 000000000..ac0fa4a56
--- /dev/null
+++ b/trunk/Examples/ocaml/shapes/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module(directors="1") example
+#ifndef SWIGSEXP
+%{
+ #include "example.h"
+%}
+#endif
+
+%feature("director");
+%include "example.h"
diff --git a/trunk/Examples/ocaml/shapes/example_prog.ml b/trunk/Examples/ocaml/shapes/example_prog.ml
new file mode 100644
index 000000000..b9e35158a
--- /dev/null
+++ b/trunk/Examples/ocaml/shapes/example_prog.ml
@@ -0,0 +1,76 @@
+(* example_prog.ml *)
+
+open Swig ;;
+open Example ;;
+
+let side_length (ax,ay) (bx,by) =
+ sqrt (((bx -. ax) ** 2.0) +. ((by -. ay) ** 2.0)) ;;
+
+let triangle_area a_pt b_pt c_pt =
+ let a = (side_length a_pt b_pt)
+ and b = (side_length b_pt c_pt)
+ and c = (side_length c_pt a_pt) in
+ let s = (a +. b +. c) /. 2.0 in
+ sqrt (s *. (s -. a) *. (s -. b) *. (s -. c)) ;;
+
+let point_in_triangle (pta,ptb,ptc) x y =
+ let delta = 0.0000001 in (* Error *)
+ let ptx = (x,y) in
+ begin
+ let a_area = triangle_area pta ptb ptx
+ and b_area = triangle_area ptb ptc ptx
+ and c_area = triangle_area ptc pta ptx
+ and x_area = triangle_area pta ptb ptc in
+ let result = (abs_float (a_area +. b_area +. c_area -. x_area)) < delta
+ in
+ result
+ end ;;
+
+let triangle_class pts ob meth args =
+ match meth with
+ "cover" ->
+ (match args with
+ C_list [ x_arg ; y_arg ] ->
+ let xa = x_arg as float
+ and ya = y_arg as float in
+ (point_in_triangle pts xa ya) to bool
+ | _ -> raise (Failure "cover needs two double arguments."))
+ | _ -> (invoke ob) meth args ;;
+
+let dist (ax,ay) (bx,by) =
+ let dx = ax -. bx and dy = ay -. by in
+ sqrt ((dx *. dx) +. (dy *. dy))
+
+let waveplot_depth events distance pt =
+ (List.fold_left (+.) 0.0
+ (List.map
+ (fun (x,y,d) ->
+ let t = dist pt (x,y) in
+ ((sin t) /. t) *. d)
+ events)) +. distance
+
+let waveplot_class events distance ob meth args =
+ match meth with
+ "depth" ->
+ (match args with
+ C_list [ x_arg ; y_arg ] ->
+ let xa = x_arg as float
+ and ya = y_arg as float in
+ (waveplot_depth events distance (xa,ya)) to float
+ | _ -> raise (Failure "cover needs two double arguments."))
+ | _ -> (invoke ob) meth args ;;
+
+let triangle =
+ new_derived_object
+ new_shape
+ (triangle_class ((0.0,0.0),(0.5,1.0),(1.0,0.6)))
+ '() ;;
+
+let waveplot =
+ new_derived_object
+ new_volume
+ (waveplot_class [ 0.01,0.01,3.0 ; 1.01,-2.01,1.5 ] 5.0)
+ '() ;;
+
+let _ = _draw_shape_coverage '(triangle, 60, 20) ;;
+let _ = _draw_depth_map '(waveplot, 60, 20) ;;
diff --git a/trunk/Examples/ocaml/simple/Makefile b/trunk/Examples/ocaml/simple/Makefile
new file mode 100644
index 000000000..4b85bf33e
--- /dev/null
+++ b/trunk/Examples/ocaml/simple/Makefile
@@ -0,0 +1,33 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+MLFILE = example.ml
+PROGFILE = example_prog.ml
+OBJS = example.o
+
+all:: static
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static
+
+toplevel::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_toplevel
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/simple/example.c b/trunk/Examples/ocaml/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/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/trunk/Examples/ocaml/simple/example.i b/trunk/Examples/ocaml/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/ocaml/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/ocaml/simple/example_prog.ml b/trunk/Examples/ocaml/simple/example_prog.ml
new file mode 100644
index 000000000..cc3b973d8
--- /dev/null
+++ b/trunk/Examples/ocaml/simple/example_prog.ml
@@ -0,0 +1,33 @@
+(* example_prog.ml *)
+
+open Swig
+open Example
+
+(* Call our gcd() function *)
+
+exception NoReturn
+
+let x = 42 to int
+let y = 105 to int
+let g = _gcd '(x,y) as int
+let _ = Printf.printf "The gcd of %d and %d is %d\n" (x as int) (y as int) g
+
+(* Manipulate the Foo global variable *)
+
+(* Output its current value *)
+let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
+
+(* Change its value *)
+let _ = _Foo '(3.1415926)
+
+(* See if the change took effect *)
+let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
+
+
+
+
+
+
+
+
+
diff --git a/trunk/Examples/ocaml/simple/index.html b/trunk/Examples/ocaml/simple/index.html
new file mode 100644
index 000000000..dace471a3
--- /dev/null
+++ b/trunk/Examples/ocaml/simple/index.html
@@ -0,0 +1,97 @@
+<html>
+<head>
+<title>SWIG:Examples:python:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/simple/</tt>
+<hr>
+
+<H2>Simple Python Example</H2>
+
+<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 &gt; 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/trunk/Examples/ocaml/std_string/Makefile b/trunk/Examples/ocaml/std_string/Makefile
new file mode 100644
index 000000000..e5a8017ae
--- /dev/null
+++ b/trunk/Examples/ocaml/std_string/Makefile
@@ -0,0 +1,23 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+PROGFILE = runme.ml
+
+all default:: static
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_dynamic_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/std_string/README b/trunk/Examples/ocaml/std_string/README
new file mode 100644
index 000000000..566553083
--- /dev/null
+++ b/trunk/Examples/ocaml/std_string/README
@@ -0,0 +1,13 @@
+This example shows how to use both std::string and std::wstring in Ocaml,
+and also demonstrates that one might use this to make a locale-obedient
+Ocaml program.
+
+These are two sample runs; note that the output is different based on the
+locale chosen to perform the conversion to wchar_t.
+
+bash-2.05a$ ./example ja_JP.EUC-JP
+the original string contains 2
+the new string contains 1 : [ 29494; ]
+bash-2.05a$ ./example en_US
+the original string contains 2
+the new string contains 2 : [ 205; 177; ]
diff --git a/trunk/Examples/ocaml/std_string/example.h b/trunk/Examples/ocaml/std_string/example.h
new file mode 100644
index 000000000..60de9847c
--- /dev/null
+++ b/trunk/Examples/ocaml/std_string/example.h
@@ -0,0 +1,36 @@
+/* File : example.h -- stolen from the guile std_vector example */
+
+#include <string>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+#include <stdlib.h>
+#include <locale.h>
+
+std::string from_wstring_with_locale( const std::wstring source,
+ const std::string locale ) {
+ const char *current_locale = setlocale( LC_CTYPE, locale.c_str() );
+ int required_chars = wcstombs( NULL, source.c_str(), 0 );
+ std::string s;
+ char *temp_chars = new char[required_chars + 1];
+ temp_chars[0] = 0;
+ wcstombs( temp_chars, source.c_str(), required_chars + 1 );
+ s = temp_chars;
+ delete [] temp_chars;
+ setlocale( LC_CTYPE, current_locale );
+ return s;
+}
+
+std::wstring to_wstring_with_locale( const std::string source,
+ const std::string locale ) {
+ const char *current_locale = setlocale( LC_CTYPE, locale.c_str() );
+ int required_chars = mbstowcs( NULL, source.c_str(), 0 );
+ std::wstring s;
+ wchar_t *temp_chars = new wchar_t[required_chars + 1];
+ temp_chars[0] = 0;
+ mbstowcs( temp_chars, source.c_str(), required_chars + 1 );
+ s = temp_chars;
+ delete [] temp_chars;
+ setlocale( LC_CTYPE, current_locale );
+ return s;
+}
diff --git a/trunk/Examples/ocaml/std_string/example.i b/trunk/Examples/ocaml/std_string/example.i
new file mode 100644
index 000000000..7b144ea05
--- /dev/null
+++ b/trunk/Examples/ocaml/std_string/example.i
@@ -0,0 +1,12 @@
+/* -*- C++ -*- */
+/* File : example.i -- stolen from the guile std_vector example */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include stl.i
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/trunk/Examples/ocaml/std_string/runme.ml b/trunk/Examples/ocaml/std_string/runme.ml
new file mode 100644
index 000000000..199dbe56a
--- /dev/null
+++ b/trunk/Examples/ocaml/std_string/runme.ml
@@ -0,0 +1,24 @@
+(* This example was mostly lifted from the guile example directory *)
+
+open Swig
+open Example
+
+let y = "\205\177"
+let z = _to_wstring_with_locale '((y to string),(Sys.argv.(1) to string))
+
+let _ =
+ begin
+ print_string "the original string contains " ;
+ print_int (String.length y) ;
+ print_newline () ;
+
+ print_string "the new string contains " ;
+ print_int (z -> size () as int) ;
+ print_string " : [ " ;
+ for i = 0 to (pred ((z -> size ()) as int)) do
+ print_int ((z '[i to int]) as int) ;
+ print_string "; " ;
+ done ;
+ print_string "]" ;
+ print_newline () ;
+ end
diff --git a/trunk/Examples/ocaml/std_vector/Makefile b/trunk/Examples/ocaml/std_vector/Makefile
new file mode 100644
index 000000000..e5a8017ae
--- /dev/null
+++ b/trunk/Examples/ocaml/std_vector/Makefile
@@ -0,0 +1,23 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+PROGFILE = runme.ml
+
+all default:: static
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_dynamic_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/std_vector/example.h b/trunk/Examples/ocaml/std_vector/example.h
new file mode 100644
index 000000000..b75359243
--- /dev/null
+++ b/trunk/Examples/ocaml/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h -- stolen from the guile std_vector example */
+
+#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/trunk/Examples/ocaml/std_vector/example.i b/trunk/Examples/ocaml/std_vector/example.i
new file mode 100644
index 000000000..60285e529
--- /dev/null
+++ b/trunk/Examples/ocaml/std_vector/example.i
@@ -0,0 +1,15 @@
+/* -*- C++ -*- */
+/* File : example.i -- stolen from the guile std_vector example */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include stl.i
+/* instantiate the required template specializations */
+%template(IntVector) std::vector<int>;
+%template(DoubleVector) std::vector<double>;
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/trunk/Examples/ocaml/std_vector/runme.ml b/trunk/Examples/ocaml/std_vector/runme.ml
new file mode 100644
index 000000000..feb70dd5e
--- /dev/null
+++ b/trunk/Examples/ocaml/std_vector/runme.ml
@@ -0,0 +1,35 @@
+(* This example was mostly lifted from the guile example directory *)
+
+open Swig
+open Example
+
+let with_vector v f =
+ for i = 0 to ((v -> size()) as int) - 1 do
+ f v i
+ done
+
+let print_DoubleVector v =
+ begin
+ with_vector v
+ (fun v i ->
+ print_float ((v '[i to int]) as float) ;
+ print_string " ") ;
+ print_endline
+ end
+
+(* Call average with a Ocaml array... *)
+
+let v = new_DoubleVector '()
+let rec fill_dv v x =
+ if x < 0.0001 then v else
+ begin
+ v -> push_back ((x to float)) ;
+ fill_dv v (x *. x)
+ end
+let _ = fill_dv v 0.999
+let _ = print_DoubleVector v ; print_endline ""
+let u = new_IntVector '()
+let _ = for i = 1 to 4 do
+ u -> push_back ((i to int))
+done
+let _ = (print_float ((_average u) as float) ; print_newline ())
diff --git a/trunk/Examples/ocaml/stl/Makefile b/trunk/Examples/ocaml/stl/Makefile
new file mode 100644
index 000000000..fa4333ec0
--- /dev/null
+++ b/trunk/Examples/ocaml/stl/Makefile
@@ -0,0 +1,33 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+PROGFILE = runme.ml
+
+all default:: static
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp
+
+director::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp_director
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp
+
+toplevel::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp_toplevel
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/stl/example.h b/trunk/Examples/ocaml/stl/example.h
new file mode 100644
index 000000000..df5762bfc
--- /dev/null
+++ b/trunk/Examples/ocaml/stl/example.h
@@ -0,0 +1,17 @@
+/* File : example.h -- stolen from the guile std_vector example */
+
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+
+using std::string;
+
+double vec_write(std::vector<string> v) {
+ int n = 0;
+ for( std::vector<string>::iterator i = v.begin();
+ i != v.end();
+ i++ )
+ printf( "%04d: %s\n", ++n, i->c_str() );
+}
diff --git a/trunk/Examples/ocaml/stl/example.i b/trunk/Examples/ocaml/stl/example.i
new file mode 100644
index 000000000..19a80a605
--- /dev/null
+++ b/trunk/Examples/ocaml/stl/example.i
@@ -0,0 +1,12 @@
+%module example
+%{
+#include "example.h"
+%}
+
+#define ENABLE_CHARPTR_ARRAY
+#define ENABLE_STRING_VECTOR
+%include stl.i
+
+%feature("director");
+
+%include example.h
diff --git a/trunk/Examples/ocaml/stl/runme.ml b/trunk/Examples/ocaml/stl/runme.ml
new file mode 100644
index 000000000..2fa5d20b8
--- /dev/null
+++ b/trunk/Examples/ocaml/stl/runme.ml
@@ -0,0 +1,13 @@
+(* This example was mostly lifted from the guile example directory *)
+
+open Swig
+open Example
+
+let v = new_StringVector '()
+
+let _ =
+ for i = 0 to (Array.length Sys.argv) - 1 do
+ let str = (Sys.argv.(i)) to string in v -> push_back (str)
+ done
+
+let _ = _vec_write '(v)
diff --git a/trunk/Examples/ocaml/string_from_ptr/Makefile b/trunk/Examples/ocaml/string_from_ptr/Makefile
new file mode 100644
index 000000000..350d9734c
--- /dev/null
+++ b/trunk/Examples/ocaml/string_from_ptr/Makefile
@@ -0,0 +1,34 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT = -c++
+SRCS =
+TARGET = example
+INTERFACE = foolib.i
+MLFILE = foolib.ml
+PROGFILE = example_prog.ml
+OBJS =
+
+all:: static static_top
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+static_top::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp_toplevel
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
+ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/string_from_ptr/example_prog.ml b/trunk/Examples/ocaml/string_from_ptr/example_prog.ml
new file mode 100644
index 000000000..8069dc228
--- /dev/null
+++ b/trunk/Examples/ocaml/string_from_ptr/example_prog.ml
@@ -0,0 +1,23 @@
+(* foo_program.ml -- the program using foolib *)
+
+open Swig (* Give access to the swig library *)
+open Foolib (* This is the name of your swig output *)
+
+let results = _foo '() (* Function names are prefixed with _ in order to make
+ them lex as identifiers in ocaml. Consider that
+ uppercase identifiers are module names in ocaml.
+ NOTE: the '() syntax is part of swigp4. You can do:
+ let results = _foo C_void *)
+
+(* Since your function has a return value in addition to the string output,
+ you'll need to match them as a list *)
+
+let result_string =
+ match results with
+ C_list [ C_string result_string ; C_int 0 ] -> (* The return value is
+ last when out arguments appear, but this too can be customized.
+ We're also checking that the function succeeded. *)
+ result_string
+ | _ -> raise (Failure "Expected string, int reply from _foo")
+
+let _ = print_endline result_string
diff --git a/trunk/Examples/ocaml/string_from_ptr/foolib.i b/trunk/Examples/ocaml/string_from_ptr/foolib.i
new file mode 100644
index 000000000..86e0880eb
--- /dev/null
+++ b/trunk/Examples/ocaml/string_from_ptr/foolib.i
@@ -0,0 +1,16 @@
+%module foolib
+%{
+static int foo( char **buf ) {
+ *buf = "string from c";
+ return 0;
+}
+%}
+
+%typemap(in,numinputs=0) char **buf (char *temp) {
+ $1 = &temp;
+}
+%typemap(argout) char **buf {
+ swig_result = caml_list_append(swig_result,caml_val_string((char *)*$1));
+}
+
+int foo( char **buf );
diff --git a/trunk/Examples/ocaml/strings_test/Makefile b/trunk/Examples/ocaml/strings_test/Makefile
new file mode 100644
index 000000000..8d1f96edf
--- /dev/null
+++ b/trunk/Examples/ocaml/strings_test/Makefile
@@ -0,0 +1,28 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+PROGFILE = runme.ml
+
+all default:: static top
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp
+
+top::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_static_cpp_toplevel
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+
+check: all
diff --git a/trunk/Examples/ocaml/strings_test/example.h b/trunk/Examples/ocaml/strings_test/example.h
new file mode 100644
index 000000000..3417981f0
--- /dev/null
+++ b/trunk/Examples/ocaml/strings_test/example.h
@@ -0,0 +1,37 @@
+/* -*- mode: c++ -*- */
+/* File : example.h -- Tests all string typemaps */
+
+void takes_std_string( std::string in ) {
+ cout << "takes_std_string( \"" << in << "\" );" << endl;
+}
+
+std::string gives_std_string() {
+ time_t t;
+
+ return std::string( asctime( localtime( &t ) ) );
+}
+
+void takes_char_ptr( char *p ) {
+ cout << "takes_char_ptr( \"" << p << "\" );" << endl;
+}
+
+char *gives_char_ptr() {
+ return "foo";
+}
+
+void takes_and_gives_std_string( std::string &inout ) {
+ inout.insert( inout.begin(), '[' );
+ inout.insert( inout.end(), ']' );
+}
+
+void takes_and_gives_char_ptr( char *&ptr ) {
+ char *pout = strchr( ptr, '.' );
+ if( pout ) ptr = pout + 1;
+ else ptr = "foo";
+}
+
+/*
+ * Local-Variables:
+ * c-indentation-style: "stroustrup"
+ * End:
+ */
diff --git a/trunk/Examples/ocaml/strings_test/example.i b/trunk/Examples/ocaml/strings_test/example.i
new file mode 100644
index 000000000..be9eabfbc
--- /dev/null
+++ b/trunk/Examples/ocaml/strings_test/example.i
@@ -0,0 +1,14 @@
+%module example
+%{
+#include <iostream>
+#include <string>
+
+using std::cin;
+using std::cout;
+using std::endl;
+using std::string;
+
+#include "example.h"
+%}
+
+%include example.h
diff --git a/trunk/Examples/ocaml/strings_test/runme.ml b/trunk/Examples/ocaml/strings_test/runme.ml
new file mode 100644
index 000000000..0eb56379c
--- /dev/null
+++ b/trunk/Examples/ocaml/strings_test/runme.ml
@@ -0,0 +1,17 @@
+(* This example is meant to reach every case in cstring.i *)
+
+open Swig
+open Example
+
+let _ = _takes_std_string (C_string "foo")
+let _ = print_endline
+ ("_gives_std_string <<" ^ (get_string (_gives_std_string C_void)) ^ " >>")
+let _ = _takes_char_ptr (C_string "bar")
+let _ = print_endline
+ ("_gives_char_ptr << " ^ (get_string (_gives_char_ptr C_void)) ^ " >>")
+let _ = print_endline
+ ("_takes_and_gives_std_string << " ^
+ (get_string (_takes_and_gives_std_string (C_string "foo"))) ^ " >>")
+let _ = print_endline
+ ("_takes_and_gives_char_ptr << " ^
+ (get_string (_takes_and_gives_char_ptr (C_string "bar.bar"))) ^ " >>")
diff --git a/trunk/Examples/octave/callback/Makefile b/trunk/Examples/octave/callback/Makefile
new file mode 100644
index 000000000..2bce9df5d
--- /dev/null
+++ b/trunk/Examples/octave/callback/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/callback/example.cxx b/trunk/Examples/octave/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/octave/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/octave/callback/example.h b/trunk/Examples/octave/callback/example.h
new file mode 100644
index 000000000..1a0e8c432
--- /dev/null
+++ b/trunk/Examples/octave/callback/example.h
@@ -0,0 +1,23 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/trunk/Examples/octave/callback/example.i b/trunk/Examples/octave/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/trunk/Examples/octave/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/trunk/Examples/octave/callback/runme.m b/trunk/Examples/octave/callback/runme.m
new file mode 100644
index 000000000..b87925e3d
--- /dev/null
+++ b/trunk/Examples/octave/callback/runme.m
@@ -0,0 +1,63 @@
+# file: runme.m
+
+# This file illustrates the cross language polymorphism using directors.
+
+example
+
+OctCallback=@() subclass(example.Callback(), \
+ 'run',@(self) printf("OctCallback.run()\n"));
+
+# Create an Caller instance
+
+caller = example.Caller();
+
+# Add a simple C++ callback (caller owns the callback, so
+# we disown it first)
+
+printf("Adding and calling a normal C++ callback\n");
+printf("----------------------------------------\n");
+
+callback = example.Callback().__disown();
+caller.setCallback(callback);
+caller.call();
+caller.delCallback();
+
+printf("Adding and calling a Octave callback\n");
+printf("------------------------------------\n");
+
+# Add a Octave callback (caller owns the callback, so we
+# disown it first by calling __disown).
+
+caller.setCallback(OctCallback().__disown())
+caller.call();
+caller.delCallback();
+
+printf("Adding and calling another Octave callback\n");
+printf("------------------------------------------\n");
+
+# Let's do the same but use the weak reference this time.
+
+callback = OctCallback().__disown();
+caller.setCallback(callback);
+caller.call();
+caller.delCallback();
+
+# careful-- using callback here may cause problems; octave_swig_type still
+# exists, but is holding a destroyed object (the C++ example.Callback).
+# to manually drop the octave-side reference, you can use
+clear callback;
+
+# Let's call them directly now
+
+printf("Calling Octave and C++ callbacks directly\n");
+printf("------------------------------------------\n");
+
+a = OctCallback();
+a.run();
+a.Callback.run();
+
+
+# All done.
+
+printf("octave exit\n");
+
diff --git a/trunk/Examples/octave/check.list b/trunk/Examples/octave/check.list
new file mode 100644
index 000000000..1e6608151
--- /dev/null
+++ b/trunk/Examples/octave/check.list
@@ -0,0 +1,16 @@
+# see top-level Makefile.in
+callback
+class
+constants
+contract
+enum
+extend
+funcptr
+funcptr2
+functor
+operator
+pointer
+reference
+simple
+template
+variables
diff --git a/trunk/Examples/octave/class/Makefile b/trunk/Examples/octave/class/Makefile
new file mode 100644
index 000000000..2bce9df5d
--- /dev/null
+++ b/trunk/Examples/octave/class/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/class/example.cxx b/trunk/Examples/octave/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/octave/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/octave/class/example.h b/trunk/Examples/octave/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/octave/class/example.h
@@ -0,0 +1,39 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+
+
+
+
diff --git a/trunk/Examples/octave/class/example.i b/trunk/Examples/octave/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/octave/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/octave/class/runme.m b/trunk/Examples/octave/class/runme.m
new file mode 100644
index 000000000..c833a701b
--- /dev/null
+++ b/trunk/Examples/octave/class/runme.m
@@ -0,0 +1,52 @@
+# file: runme.m
+
+# This file illustrates the proxy class C++ interface generated
+# by SWIG.
+
+example
+
+# ----- Object creation -----
+
+printf("Creating some objects:\n");
+c = example.Circle(10)
+s = example.Square(10)
+
+# ----- Access a static member -----
+
+printf("\nA total of %i shapes were created\n", example.Shape.nshapes);
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+printf("\nHere is their current position:\n");
+printf(" Circle = (%f, %f)\n",c.x,c.y);
+printf(" Square = (%f, %f)\n",s.x,s.y);
+
+# ----- Call some methods -----
+
+printf("\nHere are some properties of the shapes:\n");
+function print_shape(o)
+ o
+ printf(" area = %f\n", o.area());
+ printf(" perimeter = %f\n", o.perimeter());
+end;
+print_shape(c);
+print_shape(s);
+
+printf("\nGuess I'll clean up now\n");
+
+# Note: this invokes the virtual destructor
+clear c
+clear s
+
+printf("%i shapes remain\n", example.Shape.nshapes);
+printf("Goodbye\n");
+
+
diff --git a/trunk/Examples/octave/constants/Makefile b/trunk/Examples/octave/constants/Makefile
new file mode 100644
index 000000000..4d80c6f19
--- /dev/null
+++ b/trunk/Examples/octave/constants/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/constants/example.i b/trunk/Examples/octave/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/Examples/octave/constants/example.i
@@ -0,0 +1,27 @@
+/* File : example.i */
+%module example
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
+
+
diff --git a/trunk/Examples/octave/constants/runme.m b/trunk/Examples/octave/constants/runme.m
new file mode 100644
index 000000000..322858734
--- /dev/null
+++ b/trunk/Examples/octave/constants/runme.m
@@ -0,0 +1,29 @@
+# file: runme.m
+
+example
+
+printf("ICONST = %i (should be 42)\n", example.ICONST);
+printf("FCONST = %f (should be 2.1828)\n", example.FCONST);
+printf("CCONST = %s (should be 'x')\n", example.CCONST);
+printf("CCONST2 = %s (this should be on a new line)\n", example.CCONST2);
+printf("SCONST = %s (should be 'Hello World')\n", example.SCONST);
+printf("SCONST2 = %s (should be '\"Hello World\"')\n", example.SCONST2);
+printf("EXPR = %f (should be 48.5484)\n", example.EXPR);
+printf("iconst = %i (should be 37)\n", example.iconst);
+printf("fconst = %f (should be 3.14)\n", example.fconst);
+
+try
+ printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", example.EXTERN);
+catch
+ printf("EXTERN isn't defined (good)\n");
+end_try_catch
+
+try
+ printf("FOO = %i (Arg! This shouldn't printf(anything)\n", example.FOO);
+catch
+ printf("FOO isn't defined (good)\n");
+end_try_catch
+
+
+
+
diff --git a/trunk/Examples/octave/contract/Makefile b/trunk/Examples/octave/contract/Makefile
new file mode 100644
index 000000000..627b0a977
--- /dev/null
+++ b/trunk/Examples/octave/contract/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/contract/example.c b/trunk/Examples/octave/contract/example.c
new file mode 100644
index 000000000..1a644543f
--- /dev/null
+++ b/trunk/Examples/octave/contract/example.c
@@ -0,0 +1,23 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+int fact(int n) {
+ if (n <= 0) return 1;
+ return n*fact(n-1);
+}
+
+
diff --git a/trunk/Examples/octave/contract/example.i b/trunk/Examples/octave/contract/example.i
new file mode 100644
index 000000000..8fd1a80af
--- /dev/null
+++ b/trunk/Examples/octave/contract/example.i
@@ -0,0 +1,21 @@
+/* File : example.i */
+%module example
+
+%contract gcd(int x, int y) {
+require:
+ x >= 0;
+ y >= 0;
+}
+
+%contract fact(int n) {
+require:
+ n >= 0;
+ensure:
+ fact >= 1;
+}
+
+%inline %{
+extern int gcd(int x, int y);
+extern int fact(int n);
+extern double Foo;
+%}
diff --git a/trunk/Examples/octave/contract/runme.m b/trunk/Examples/octave/contract/runme.m
new file mode 100644
index 000000000..62b72320b
--- /dev/null
+++ b/trunk/Examples/octave/contract/runme.m
@@ -0,0 +1,22 @@
+# file: runme.m
+
+example
+
+# Call our gcd() function
+
+x = 42;
+y = 105;
+g = example.gcd(x,y);
+printf("The gcd of %d and %d is %d\n",x,y,g);
+
+# Manipulate the Foo global variable
+
+# Output its current value
+printf("Foo = %f\n", example.cvar.Foo);
+
+# Change its value
+example.cvar.Foo = 3.1415926;
+
+# See if the change took effect
+printf("Foo = %f\n", example.cvar.Foo);
+
diff --git a/trunk/Examples/octave/enum/Makefile b/trunk/Examples/octave/enum/Makefile
new file mode 100644
index 000000000..2bce9df5d
--- /dev/null
+++ b/trunk/Examples/octave/enum/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/enum/example.cxx b/trunk/Examples/octave/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/trunk/Examples/octave/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/trunk/Examples/octave/enum/example.h b/trunk/Examples/octave/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/trunk/Examples/octave/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE, WARP, LUDICROUS };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/trunk/Examples/octave/enum/example.i b/trunk/Examples/octave/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/octave/enum/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/trunk/Examples/octave/enum/runme.m b/trunk/Examples/octave/enum/runme.m
new file mode 100644
index 000000000..a749e81db
--- /dev/null
+++ b/trunk/Examples/octave/enum/runme.m
@@ -0,0 +1,32 @@
+# file: runme.m
+
+example
+
+# ----- Object creation -----
+
+# Print out the value of some enums
+printf("*** color ***\n");
+printf(" RED = %i\n", example.RED);
+printf(" BLUE = %i\n", example.BLUE);
+printf(" GREEN = %i\n", example.GREEN);
+
+printf("\n*** Foo::speed ***\n");
+printf(" Foo_IMPULSE = %i\n", example.Foo_IMPULSE);
+printf(" Foo_WARP = %i\n", example.Foo_WARP);
+printf(" Foo_LUDICROUS = %i\n", example.Foo_LUDICROUS);
+
+printf("\nTesting use of enums with functions\n");
+
+example.enum_test(example.RED, example.Foo_IMPULSE);
+example.enum_test(example.BLUE, example.Foo_WARP);
+example.enum_test(example.GREEN, example.Foo_LUDICROUS);
+example.enum_test(1234,5678)
+
+printf("\nTesting use of enum with class method\n");
+f = example.Foo();
+
+f.enum_test(example.Foo_IMPULSE);
+f.enum_test(example.Foo_WARP);
+f.enum_test(example.Foo_LUDICROUS);
+
+
diff --git a/trunk/Examples/octave/extend/Makefile b/trunk/Examples/octave/extend/Makefile
new file mode 100644
index 000000000..2bce9df5d
--- /dev/null
+++ b/trunk/Examples/octave/extend/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/extend/example.cxx b/trunk/Examples/octave/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/octave/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/octave/extend/example.h b/trunk/Examples/octave/extend/example.h
new file mode 100644
index 000000000..b27ab9711
--- /dev/null
+++ b/trunk/Examples/octave/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/trunk/Examples/octave/extend/example.i b/trunk/Examples/octave/extend/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/trunk/Examples/octave/extend/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/trunk/Examples/octave/extend/runme.m b/trunk/Examples/octave/extend/runme.m
new file mode 100644
index 000000000..c64c082c4
--- /dev/null
+++ b/trunk/Examples/octave/extend/runme.m
@@ -0,0 +1,74 @@
+# file: runme.m
+
+# This file illustrates the cross language polymorphism using directors.
+
+example
+
+
+# CEO class, which overrides Employee::getPosition().
+
+CEO=@(name) subclass(example.Manager(name),'getPosition',@(self) "CEO");
+
+# Create an instance of our employee extension class, CEO. The calls to
+# getName() and getPosition() are standard, the call to getTitle() uses
+# the director wrappers to call CEO.getPosition. e = CEO("Alice")
+
+e = CEO("Alice");
+printf("%s is a %s\n",e.getName(),e.getPosition());
+printf("Just call her \"%s\"\n",e.getTitle());
+printf("----------------------\n");
+
+
+# Create a new EmployeeList instance. This class does not have a C++
+# director wrapper, but can be used freely with other classes that do.
+
+list = example.EmployeeList();
+
+# EmployeeList owns its items, so we must surrender ownership of objects
+# we add. This involves first calling the __disown__ method to tell the
+# C++ director to start reference counting. We reassign the resulting
+# weakref.proxy to e so that no hard references remain. This can also be
+# done when the object is constructed, as in: e =
+# CEO("Alice").__disown()
+
+e = e.__disown();
+list.addEmployee(e);
+printf("----------------------\n");
+
+# Now we access the first four items in list (three are C++ objects that
+# EmployeeList's constructor adds, the last is our CEO). The virtual
+# methods of all these instances are treated the same. For items 0, 1, and
+# 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls
+# getPosition which resolves in Octave. The call to getPosition is
+# slightly different, however, from the e.getPosition() call above, since
+# now the object reference has been "laundered" by passing through
+# EmployeeList as an Employee*. Previously, Octave resolved the call
+# immediately in CEO, but now Octave thinks the object is an instance of
+# class Employee (actually EmployeePtr). So the call passes through the
+# Employee proxy class and on to the C wrappers and C++ director,
+# eventually ending up back at the CEO implementation of getPosition().
+# The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+# method, which in turn calls getPosition(). This virtual method call
+# passes down through the C++ director class to the Octave implementation
+# in CEO. All this routing takes place transparently.
+
+printf("(position, title) for items 0-3:\n");
+for i=0:3,
+ printf(" %s, \"%s\"\n",list.get_item(i).getPosition(), list.get_item(i).getTitle());
+endfor
+printf("----------------------\n");
+
+# Time to delete the EmployeeList, which will delete all the Employee*
+# items it contains. The last item is our CEO, which gets destroyed as its
+# reference count goes to zero. The Octave destructor runs, and is still
+# able to call self.getName() since the underlying C++ object still
+# exists. After this destructor runs the remaining C++ destructors run as
+# usual to destroy the object.
+
+clear list;
+printf("----------------------\n");
+
+# All done.
+
+printf("octave exit\n");
+
diff --git a/trunk/Examples/octave/funcptr/Makefile b/trunk/Examples/octave/funcptr/Makefile
new file mode 100644
index 000000000..627b0a977
--- /dev/null
+++ b/trunk/Examples/octave/funcptr/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/funcptr/example.c b/trunk/Examples/octave/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/octave/funcptr/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int sub(int a, int b) {
+ return a-b;
+}
+
+int mul(int a, int b) {
+ return a*b;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/trunk/Examples/octave/funcptr/example.h b/trunk/Examples/octave/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/octave/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/octave/funcptr/example.i b/trunk/Examples/octave/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/trunk/Examples/octave/funcptr/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Wrap a function taking a pointer to a function */
+extern int do_op(int a, int b, int (*op)(int, int));
+
+/* Now install a bunch of "ops" as constants */
+%constant int (*ADD)(int,int) = add;
+%constant int (*SUB)(int,int) = sub;
+%constant int (*MUL)(int,int) = mul;
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/octave/funcptr/runme.m b/trunk/Examples/octave/funcptr/runme.m
new file mode 100644
index 000000000..455311c16
--- /dev/null
+++ b/trunk/Examples/octave/funcptr/runme.m
@@ -0,0 +1,21 @@
+# file: runme.m
+
+example
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+printf("Trying some C callback functions\n");
+printf(" a = %i\n", a);
+printf(" b = %i\n", b);
+printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD));
+printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB));
+printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL));
+
+printf("Here is what the C callback function objects look like in Octave\n");
+example.ADD
+example.SUB
+example.MUL
+
diff --git a/trunk/Examples/octave/funcptr2/Makefile b/trunk/Examples/octave/funcptr2/Makefile
new file mode 100644
index 000000000..627b0a977
--- /dev/null
+++ b/trunk/Examples/octave/funcptr2/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/funcptr2/example.c b/trunk/Examples/octave/funcptr2/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/octave/funcptr2/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int sub(int a, int b) {
+ return a-b;
+}
+
+int mul(int a, int b) {
+ return a*b;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/trunk/Examples/octave/funcptr2/example.h b/trunk/Examples/octave/funcptr2/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/octave/funcptr2/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/octave/funcptr2/example.i b/trunk/Examples/octave/funcptr2/example.i
new file mode 100644
index 000000000..681775a3e
--- /dev/null
+++ b/trunk/Examples/octave/funcptr2/example.i
@@ -0,0 +1,18 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Wrap a function taking a pointer to a function */
+extern int do_op(int a, int b, int (*op)(int, int));
+
+/* Now install a bunch of "ops" as constants */
+%callback("%(upper)s");
+int add(int, int);
+int sub(int, int);
+int mul(int, int);
+%nocallback;
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/octave/funcptr2/runme.m b/trunk/Examples/octave/funcptr2/runme.m
new file mode 100644
index 000000000..1d3d8f73a
--- /dev/null
+++ b/trunk/Examples/octave/funcptr2/runme.m
@@ -0,0 +1,24 @@
+# file: runme.m
+
+example
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+printf("Trying some C callback functions\n");
+printf(" a = %i\n", a);
+printf(" b = %i\n", b);
+printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD));
+printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB));
+printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL));
+
+printf("Here is what the C callback function objects look like in Octave\n");
+example.ADD
+example.SUB
+example.MUL
+
+printf("Call the functions directly...\n");
+printf(" add(a,b) = %i\n", example.add(a,b));
+printf(" sub(a,b) = %i\n", example.sub(a,b));
diff --git a/trunk/Examples/octave/functor/Makefile b/trunk/Examples/octave/functor/Makefile
new file mode 100644
index 000000000..d910de530
--- /dev/null
+++ b/trunk/Examples/octave/functor/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/functor/example.i b/trunk/Examples/octave/functor/example.i
new file mode 100644
index 000000000..2fd38176f
--- /dev/null
+++ b/trunk/Examples/octave/functor/example.i
@@ -0,0 +1,29 @@
+/* File : example.i */
+%module example
+
+
+%inline %{
+// From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514
+template<class 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/trunk/Examples/octave/functor/runme.m b/trunk/Examples/octave/functor/runme.m
new file mode 100644
index 000000000..65dabcc91
--- /dev/null
+++ b/trunk/Examples/octave/functor/runme.m
@@ -0,0 +1,18 @@
+# Operator overloading example
+example
+
+a = example.intSum(0);
+b = example.doubleSum(100.0);
+
+# Use the objects. They should be callable just like a normal
+# python function.
+
+for i=0:100-1,
+ a(i); # Note: function call
+ b(sqrt(i)); # Note: function call
+endfor
+
+a.result()
+b.result()
+
+
diff --git a/trunk/Examples/octave/operator/Makefile b/trunk/Examples/octave/operator/Makefile
new file mode 100644
index 000000000..6e625d538
--- /dev/null
+++ b/trunk/Examples/octave/operator/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).m
+
+check: all
diff --git a/trunk/Examples/octave/operator/example.h b/trunk/Examples/octave/operator/example.h
new file mode 100644
index 000000000..526f262b9
--- /dev/null
+++ b/trunk/Examples/octave/operator/example.h
@@ -0,0 +1,36 @@
+/* File : example.h */
+#include <math.h>
+
+class ComplexVal {
+private:
+ double rpart, ipart;
+public:
+ ComplexVal(double r = 0, double i = 0) : rpart(r), ipart(i) { }
+ ComplexVal(const ComplexVal &c) : rpart(c.rpart), ipart(c.ipart) { }
+ ComplexVal &operator=(const ComplexVal &c) {
+ rpart = c.rpart;
+ ipart = c.ipart;
+ return *this;
+ }
+ ComplexVal operator+(const ComplexVal &c) const {
+ return ComplexVal(rpart+c.rpart, ipart+c.ipart);
+ }
+ ComplexVal operator-(const ComplexVal &c) const {
+ return ComplexVal(rpart-c.rpart, ipart-c.ipart);
+ }
+ ComplexVal operator*(const ComplexVal &c) const {
+ return ComplexVal(rpart*c.rpart - ipart*c.ipart,
+ rpart*c.ipart + c.rpart*ipart);
+ }
+ ComplexVal operator-() const {
+ return ComplexVal(-rpart, -ipart);
+ }
+
+ double re() const { return rpart; }
+ double im() const { return ipart; }
+};
+
+
+
+
+
diff --git a/trunk/Examples/octave/operator/example.i b/trunk/Examples/octave/operator/example.i
new file mode 100644
index 000000000..d4bba5c53
--- /dev/null
+++ b/trunk/Examples/octave/operator/example.i
@@ -0,0 +1,24 @@
+/* File : example.i */
+%module example
+#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
+%{
+#include "example.h"
+%}
+
+/* Now grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend ComplexVal {
+ char *__str() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", $self->re(), $self->im());
+ return temp;
+ }
+
+ ComplexVal __paren(int j) {
+ return ComplexVal($self->re()*j,$self->im()*j);
+ }
+};
+
+
diff --git a/trunk/Examples/octave/operator/runme.m b/trunk/Examples/octave/operator/runme.m
new file mode 100644
index 000000000..e0f590694
--- /dev/null
+++ b/trunk/Examples/octave/operator/runme.m
@@ -0,0 +1,24 @@
+# Operator overloading example
+example
+
+a = example.ComplexVal(2,3);
+b = example.ComplexVal(-5,10);
+
+printf("a = %s\n",a);
+printf("b = %s\n",b);
+
+c = a + b;
+printf("c = %s\n",c);
+printf("a*b = %s\n",a*b);
+printf("a-c = %s\n",a-c);
+
+e = example.ComplexVal(a-c);
+printf("e = %s\n",e);
+
+# Big expression
+f = ((a+b)*(c+b*e)) + (-a);
+printf("f = %s\n",f);
+
+# paren overloading
+printf("a(3)= %s\n",a(3));
+
diff --git a/trunk/Examples/octave/pointer/Makefile b/trunk/Examples/octave/pointer/Makefile
new file mode 100644
index 000000000..627b0a977
--- /dev/null
+++ b/trunk/Examples/octave/pointer/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/pointer/example.c b/trunk/Examples/octave/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/trunk/Examples/octave/pointer/example.c
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(int *x, int *y, int *result) {
+ *result = *x + *y;
+}
+
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/trunk/Examples/octave/pointer/example.i b/trunk/Examples/octave/pointer/example.i
new file mode 100644
index 000000000..a8ac79499
--- /dev/null
+++ b/trunk/Examples/octave/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/octave/pointer/runme.m b/trunk/Examples/octave/pointer/runme.m
new file mode 100644
index 000000000..c36df7270
--- /dev/null
+++ b/trunk/Examples/octave/pointer/runme.m
@@ -0,0 +1,42 @@
+# file: runme.m
+
+example;
+
+# First create some objects using the pointer library.
+printf("Testing the pointer library\n");
+a = example.new_intp();
+b = example.new_intp();
+c = example.new_intp();
+example.intp_assign(a,37);
+example.intp_assign(b,42);
+
+a,b,c
+
+# Call the add() function with some pointers
+example.add(a,b,c);
+
+# Now get the result
+r = example.intp_value(c);
+printf(" 37 + 42 = %i\n",r);
+
+# Clean up the pointers
+example.delete_intp(a);
+example.delete_intp(b);
+example.delete_intp(c);
+
+# Now try the typemap library
+# This should be much easier. Now how it is no longer
+# necessary to manufacture pointers.
+
+printf("Trying the typemap library\n");
+r = example.sub(37,42);
+printf(" 37 - 42 = %i\n",r);
+
+# Now try the version with multiple return values
+
+printf("Testing multiple return values\n");
+[q,r] = example.divide(42,37);
+printf(" 42/37 = %d remainder %d\n",q,r);
+
+
+
diff --git a/trunk/Examples/octave/reference/Makefile b/trunk/Examples/octave/reference/Makefile
new file mode 100644
index 000000000..2bce9df5d
--- /dev/null
+++ b/trunk/Examples/octave/reference/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/reference/example.cxx b/trunk/Examples/octave/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/octave/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/octave/reference/example.h b/trunk/Examples/octave/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/Examples/octave/reference/example.h
@@ -0,0 +1,26 @@
+/* File : example.h */
+
+class Vector {
+private:
+ double x,y,z;
+public:
+ Vector() : x(0), y(0), z(0) { };
+ Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+ friend Vector operator+(const Vector &a, const Vector &b);
+ char *print();
+};
+
+class VectorArray {
+private:
+ Vector *items;
+ int maxsize;
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ Vector &operator[](int);
+ int size();
+};
+
+
+
+
diff --git a/trunk/Examples/octave/reference/example.i b/trunk/Examples/octave/reference/example.i
new file mode 100644
index 000000000..8c95b3213
--- /dev/null
+++ b/trunk/Examples/octave/reference/example.i
@@ -0,0 +1,48 @@
+/* File : example.i */
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+%rename(cprint) print;
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *print();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %extend {
+ Vector &get(int index) {
+ return (*$self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*$self)[index] = a;
+ }
+ }
+};
+
+
+
+
diff --git a/trunk/Examples/octave/reference/runme.m b/trunk/Examples/octave/reference/runme.m
new file mode 100644
index 000000000..f59c8eb7d
--- /dev/null
+++ b/trunk/Examples/octave/reference/runme.m
@@ -0,0 +1,63 @@
+# file: runme.m
+
+# This file illustrates the manipulation of C++ references in Octave
+
+example
+
+# ----- Object creation -----
+
+printf("Creating some objects:\n");
+a = example.Vector(3,4,5)
+b = example.Vector(10,11,12)
+
+printf(" Created %s\n",a.cprint());
+printf(" Created %s\n",b.cprint());
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+printf("Adding a+b\n");
+c = example.addv(a,b);
+printf(" a+b = %s\n", c.cprint());
+
+clear c
+
+# ----- Create a vector array -----
+
+# Note: Using the high-level interface here
+printf("Creating an array of vectors\n");
+va = example.VectorArray(10)
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of $a and $b to the vector array
+va.set(0,a);
+va.set(1,b);
+
+va.set(2,example.addv(a,b))
+
+# Get some values from the array
+
+printf("Getting some array values\n");
+for i=0:4,
+ printf(" va(%d) = %s\n",i,va.get(i).cprint());
+end;
+
+# Watch under resource meter to check on this
+printf("Making sure we don't leak memory.\n");
+for i=0:1000000-1,
+ c = va.get(mod(i,10));
+end
+
+# ----- Clean up -----
+printf("Cleaning up\n");
+
+clear va
+clear a
+clear b
+
diff --git a/trunk/Examples/octave/simple/Makefile b/trunk/Examples/octave/simple/Makefile
new file mode 100644
index 000000000..627b0a977
--- /dev/null
+++ b/trunk/Examples/octave/simple/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/simple/example.c b/trunk/Examples/octave/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/octave/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/trunk/Examples/octave/simple/example.i b/trunk/Examples/octave/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/octave/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/octave/simple/runme.m b/trunk/Examples/octave/simple/runme.m
new file mode 100644
index 000000000..8dc5eaa58
--- /dev/null
+++ b/trunk/Examples/octave/simple/runme.m
@@ -0,0 +1,22 @@
+# file: runme.m
+
+example
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = example.gcd(x,y)
+printf("The gcd of %d and %d is %d\n",x,y,g);
+
+# Manipulate the Foo global variable
+
+# Output its current value
+example.cvar.Foo
+
+# Change its value
+example.cvar.Foo = 3.1415926
+
+# See if the change took effect
+printf("Foo = %f\n", example.cvar.Foo);
+
diff --git a/trunk/Examples/octave/template/Makefile b/trunk/Examples/octave/template/Makefile
new file mode 100644
index 000000000..3d7445a66
--- /dev/null
+++ b/trunk/Examples/octave/template/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/template/example.h b/trunk/Examples/octave/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/trunk/Examples/octave/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/trunk/Examples/octave/template/example.i b/trunk/Examples/octave/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/trunk/Examples/octave/template/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
diff --git a/trunk/Examples/octave/template/runme.m b/trunk/Examples/octave/template/runme.m
new file mode 100644
index 000000000..a9891d459
--- /dev/null
+++ b/trunk/Examples/octave/template/runme.m
@@ -0,0 +1,37 @@
+# file: runme.m
+
+example
+
+# Call some templated functions
+example.maxint(3,7)
+example.maxdouble(3.14,2.18)
+
+# Create some class
+
+iv = example.vecint(100)
+dv = example.vecdouble(1000)
+
+for i=0:99,
+ iv.setitem(i,2*i);
+end
+
+for i=0:999,
+ dv.setitem(i, 1.0/(i+1));
+end;
+
+sum = 0;
+for i=0:99
+ sum = sum + iv.getitem(i);
+end
+sum
+
+sum = 0.0;
+for i=0:999,
+ sum = sum + dv.getitem(i);
+end
+sum
+
+clear iv
+clear dv
+
+
diff --git a/trunk/Examples/octave/variables/Makefile b/trunk/Examples/octave/variables/Makefile
new file mode 100644
index 000000000..627b0a977
--- /dev/null
+++ b/trunk/Examples/octave/variables/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).py
+
+check: all
diff --git a/trunk/Examples/octave/variables/example.c b/trunk/Examples/octave/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/octave/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/octave/variables/example.h b/trunk/Examples/octave/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/octave/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/octave/variables/example.i b/trunk/Examples/octave/variables/example.i
new file mode 100644
index 000000000..639b6c704
--- /dev/null
+++ b/trunk/Examples/octave/variables/example.i
@@ -0,0 +1,53 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+ extern "C" {
+ extern int ivar;
+ extern short svar;
+ extern long lvar;
+ extern unsigned int uivar;
+ extern unsigned short usvar;
+ extern unsigned long ulvar;
+ extern signed char scvar;
+ extern unsigned char ucvar;
+ extern char cvar;
+ extern float fvar;
+ extern double dvar;
+ extern char *strvar;
+ // extern const char cstrvar[];
+ extern int *iptrvar;
+ extern char name[256];
+
+ extern Point *ptptr;
+ extern Point pt;
+ }
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/octave/variables/runme.m b/trunk/Examples/octave/variables/runme.m
new file mode 100644
index 000000000..db88b18b0
--- /dev/null
+++ b/trunk/Examples/octave/variables/runme.m
@@ -0,0 +1,75 @@
+# file: runme.m
+
+example
+
+# Try to set the values of some global variables
+
+example.cvar.ivar = 42;
+example.cvar.svar = -31000;
+example.cvar.lvar = 65537;
+example.cvar.uivar = 123456;
+example.cvar.usvar = 61000;
+example.cvar.ulvar = 654321;
+example.cvar.scvar = -13;
+example.cvar.ucvar = 251;
+example.cvar.cvar = "S";
+example.cvar.fvar = 3.14159;
+example.cvar.dvar = 2.1828;
+example.cvar.strvar = "Hello World";
+example.cvar.iptrvar= example.new_int(37);
+example.cvar.ptptr = example.new_Point(37,42);
+example.cvar.name = "Bill";
+
+# Now print out the values of the variables
+
+printf("Variables (values printed from Octave)\n");
+
+printf("ivar = %i\n", example.cvar.ivar);
+printf("svar = %i\n", example.cvar.svar);
+printf("lvar = %i\n", example.cvar.lvar);
+printf("uivar = %i\n", example.cvar.uivar);
+printf("usvar = %i\n", example.cvar.usvar);
+printf("ulvar = %i\n", example.cvar.ulvar);
+printf("scvar = %i\n", example.cvar.scvar);
+printf("ucvar = %i\n", example.cvar.ucvar);
+printf("fvar = %i\n", example.cvar.fvar);
+printf("dvar = %i\n", example.cvar.dvar);
+printf("cvar = %s\n", example.cvar.cvar);
+printf("strvar = %s\n", example.cvar.strvar);
+#printf("cstrvar = %s\n", example.cvar.cstrvar);
+example.cvar.iptrvar
+printf("name = %i\n", example.cvar.name);
+printf("ptptr = %s\n", example.Point_print(example.cvar.ptptr));
+#printf("pt = %s\n", example.cvar.Point_print(example.cvar.pt));
+
+printf("\nVariables (values printed from C)\n");
+
+example.print_vars();
+
+printf("\nNow I'm going to try and modify some read only variables\n");
+
+printf(" Tring to set 'path'\n");
+try
+ example.cvar.path = "Whoa!";
+ printf("Hey, what's going on?!?! This shouldn't work\n");
+catch
+ printf("Good.\n");
+end_try_catch
+
+printf(" Trying to set 'status'\n");
+try
+ example.cvar.status = 0;
+ printf("Hey, what's going on?!?! This shouldn't work\n");
+catch
+ printf("Good.\n");
+end_try_catch
+
+
+printf("\nI'm going to try and update a structure variable.\n");
+
+example.cvar.pt = example.cvar.ptptr;
+
+printf("The new value is %s\n", example.Point_print(example.cvar.pt));
+
+
+
diff --git a/trunk/Examples/perl5/check.list b/trunk/Examples/perl5/check.list
new file mode 100644
index 000000000..e15f02e18
--- /dev/null
+++ b/trunk/Examples/perl5/check.list
@@ -0,0 +1,14 @@
+# see top-level Makefile.in
+class
+constants
+constants2
+funcptr
+import
+java
+multimap
+multiple_inheritance
+pointer
+reference
+simple
+value
+variables
diff --git a/trunk/Examples/perl5/class/Makefile b/trunk/Examples/perl5/class/Makefile
new file mode 100644
index 000000000..f53361730
--- /dev/null
+++ b/trunk/Examples/perl5/class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/trunk/Examples/perl5/class/example.cxx b/trunk/Examples/perl5/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/perl5/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/perl5/class/example.dsp b/trunk/Examples/perl5/class/example.dsp
new file mode 100644
index 000000000..b5ccd1928
--- /dev/null
+++ b/trunk/Examples/perl5/class/example.dsp
@@ -0,0 +1,152 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/class/example.h b/trunk/Examples/perl5/class/example.h
new file mode 100644
index 000000000..b0671d583
--- /dev/null
+++ b/trunk/Examples/perl5/class/example.h
@@ -0,0 +1,47 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+typedef Square TSquare;
+class CFoo
+{
+public:
+ static Square MakeSquare(void) {return Square(4.0);};
+ static TSquare MakeTSquare(void) {return Square(4.0);};
+};
+
+
+
+
+
diff --git a/trunk/Examples/perl5/class/example.i b/trunk/Examples/perl5/class/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/perl5/class/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/trunk/Examples/perl5/class/index.html b/trunk/Examples/perl5/class/index.html
new file mode 100644
index 000000000..58a50ad2e
--- /dev/null
+++ b/trunk/Examples/perl5/class/index.html
@@ -0,0 +1,208 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:class</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/perl5/class/</tt>
+<hr>
+
+<H2>Wrapping a simple C++ class</H2>
+
+<p>
+This example illustrates the most primitive form of C++ class wrapping performed
+by SWIG. In this case, C++ classes are simply transformed into a collection of
+C-style functions that provide access to class members.
+
+<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++ -python example.i
+</pre>
+</blockquote>
+
+<h2>A sample Perl script</h2>
+
+Click <a href="runme.pl">here</a> to see a script that calls the C++ functions from Perl.
+
+<h2>Key points</h2>
+
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+$c = example::new_Circle(10.0);
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, a pair of accessor functions are used.
+For example:
+
+<blockquote>
+<pre>
+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 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
+
+<blockquote>
+<pre>
+print "The area is ", example::Shape_area($c);
+</pre>
+</blockquote>
+
+<p>
+<li>Type checking knows about the inheritance structure of C++. For example:
+
+<blockquote>
+<pre>
+example::Shape_area($c); # Works (c is a Shape)
+example::Circle_area($c); # Works (c is a Circle)
+example::Square_area($c); # Fails (c is definitely not a Square)
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a destructor, simply do this
+
+<blockquote>
+<pre>
+example::delete_Shape($c); # Deletes a shape
+</pre>
+</blockquote>
+
+<p>
+<li>Static member variables are wrapped as C global variables. For example:
+
+<blockquote>
+<pre>
+$n = $example::Shape_nshapes; # Get a static data member
+$example::Shapes_nshapes = 13; # Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+
+<h2>General Comments</h2>
+
+<ul>
+<li>This low-level interface is not the only way to handle C++ code. Proxy 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.
+
+<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>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/perl5/class/runme.pl b/trunk/Examples/perl5/class/runme.pl
new file mode 100644
index 000000000..076e1437b
--- /dev/null
+++ b/trunk/Examples/perl5/class/runme.pl
@@ -0,0 +1,60 @@
+# file: runme.pl
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+use example;
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = new example::Circle(10);
+print " Created circle $c\n";
+$s = new example::Square(10);
+print " Created square $s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of $example::Shape::nshapes shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+$c->{x} = 20;
+$c->{y} = 30;
+$s->{x} = -10;
+$s->{y} = 5;
+
+print "\nHere is their current position:\n";
+print " Circle = (",$c->{x},",", $c->{y},")\n";
+print " Square = (",$s->{x},",", $s->{y},")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach $o ($c,$s) {
+ print " $o\n";
+ print " area = ", $o->area(), "\n";
+ print " perimeter = ", $o->perimeter(), "\n";
+ }
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+
+$c->DESTROY();
+$s->DESTROY();
+
+print $example::Shape::nshapes," shapes remain\n";
+
+$square = example::CFoo::MakeSquare();
+$tsquare = example::CFoo::MakeTSquare();
+print "Areas ", $square->area(), " ", $tsquare->area(),"\n";
+
+print "Goodbye\n";
diff --git a/trunk/Examples/perl5/constants/Makefile b/trunk/Examples/perl5/constants/Makefile
new file mode 100644
index 000000000..576d2a095
--- /dev/null
+++ b/trunk/Examples/perl5/constants/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+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/trunk/Examples/perl5/constants/example.i b/trunk/Examples/perl5/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/constants/index.html b/trunk/Examples/perl5/constants/index.html
new file mode 100644
index 000000000..f38338b63
--- /dev/null
+++ b/trunk/Examples/perl5/constants/index.html
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/perl5/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<p>
+When SWIG encounters C preprocessor macros and C declarations that look like constants,
+it creates Perl5 variables 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 Perl</h2>
+
+Click <a href="runme.pl">here</a> to see a script 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 Perl 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 Perl strings.
+<li>C string literals such as "Hello World" are converted into Perl 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 Perl constants.
+
+<p>
+<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/trunk/Examples/perl5/constants/runme.pl b/trunk/Examples/perl5/constants/runme.pl
new file mode 100644
index 000000000..6e8a6edf1
--- /dev/null
+++ b/trunk/Examples/perl5/constants/runme.pl
@@ -0,0 +1,29 @@
+# file: runme.pl
+
+use example;
+
+print "ICONST = ", $example::ICONST, " (should be 42)\n";
+print "FCONST = ", $example::FCONST, " (should be 2.1828)\n";
+print "CCONST = ", $example::CCONST, " (should be 'x')\n";
+print "CCONST2 = ", $example::CCONST2," (this should be on a new line)\n";
+print "SCONST = ", $example::SCONST, " (should be 'Hello World')\n";
+print "SCONST2 = ", $example::SCONST2, " (should be '\"Hello World\"')\n";
+print "EXPR = ", $example::EXPR, " (should be 48.5484)\n";
+print "iconst = ", $example::iconst, " (should be 37)\n";
+print "fconst = ", $example::fconst, " (should be 3.14)\n";
+
+
+if ($example::EXTERN) {
+ print "EXTERN = ", example.EXTERN, " (Arg! This shouldn't print anything)\n";
+} else {
+ print "EXTERN isn't defined (good)\n";
+}
+
+if ($example::FOO) {
+ print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)\n";
+} else {
+ print "FOO isn't defined (good)\n";
+}
+
+
+
diff --git a/trunk/Examples/perl5/constants2/Makefile b/trunk/Examples/perl5/constants2/Makefile
new file mode 100644
index 000000000..4ba4b2544
--- /dev/null
+++ b/trunk/Examples/perl5/constants2/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/perl5/constants2/example.i b/trunk/Examples/perl5/constants2/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/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/trunk/Examples/perl5/constants2/runme.pl b/trunk/Examples/perl5/constants2/runme.pl
new file mode 100644
index 000000000..d16f3b3fc
--- /dev/null
+++ b/trunk/Examples/perl5/constants2/runme.pl
@@ -0,0 +1,16 @@
+# file: runme.pl
+
+use example;
+
+print "ICONST = ", example::ICONST, " (should be 42)\n";
+print "FCONST = ", example::FCONST, " (should be 2.1828)\n";
+print "CCONST = ", example::CCONST, " (should be 'x')\n";
+print "CCONST2 = ", example::CCONST2," (this should be on a new line)\n";
+print "SCONST = ", example::SCONST, " (should be 'Hello World')\n";
+print "SCONST2 = ", example::SCONST2, " (should be '\"Hello World\"')\n";
+print "EXPR = ", example::EXPR, " (should be 48.5484)\n";
+print "iconst = ", example::iconst, " (should be 37)\n";
+print "fconst = ", example::fconst, " (should be 3.14)\n";
+
+
+
diff --git a/trunk/Examples/perl5/funcptr/Makefile b/trunk/Examples/perl5/funcptr/Makefile
new file mode 100644
index 000000000..ce2bbb5b9
--- /dev/null
+++ b/trunk/Examples/perl5/funcptr/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/perl5/funcptr/example.c b/trunk/Examples/perl5/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/funcptr/example.h b/trunk/Examples/perl5/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/perl5/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/perl5/funcptr/example.i b/trunk/Examples/perl5/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/funcptr/index.html b/trunk/Examples/perl5/funcptr/index.html
new file mode 100644
index 000000000..7333a39f2
--- /dev/null
+++ b/trunk/Examples/perl5/funcptr/index.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:funcptr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/perl5/funcptr/</tt>
+<hr>
+
+<H2>Pointers to Functions</H2>
+
+<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 script,
+you will need to pass some kind of C function pointer object. In C,
+this is easy, you just supply a function name as an argument like this:
+
+<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 script, you would do this:
+
+<blockquote>
+<pre>
+$r = do_op($x,$y, $ADD);
+</pre>
+</blockquote>
+
+<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="runme.pl">runme.pl</a> (Sample script)
+</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 Perl function object in as a substitute for a C
+function pointer.
+
+<p>
+<li>A perl function can be used as a C/C++ callback if you write some
+clever typemaps and are very careful about how you create your extension.
+This is an advanced topic not covered here.
+</ul>
+
+<hr>
+</body>
+</html>
+
+
+
+
diff --git a/trunk/Examples/perl5/funcptr/runme.pl b/trunk/Examples/perl5/funcptr/runme.pl
new file mode 100644
index 000000000..a73b53825
--- /dev/null
+++ b/trunk/Examples/perl5/funcptr/runme.pl
@@ -0,0 +1,21 @@
+# file: runme.pl
+
+use example;
+
+$a = 37;
+$b = 42;
+
+# Now call our C function with a bunch of callbacks
+
+print "Trying some C callback functions\n";
+print " a = $a\n";
+print " b = $b\n";
+print " ADD(a,b) = ", example::do_op($a,$b,$example::ADD),"\n";
+print " SUB(a,b) = ", example::do_op($a,$b,$example::SUB),"\n";
+print " MUL(a,b) = ", example::do_op($a,$b,$example::MUL),"\n";
+
+print "Here is what the C callback function objects look like in Perl\n";
+print " ADD = $example::ADD\n";
+print " SUB = $example::SUB\n";
+print " MUL = $example::MUL\n";
+
diff --git a/trunk/Examples/perl5/import/Makefile b/trunk/Examples/perl5/import/Makefile
new file mode 100644
index 000000000..60dfdfcee
--- /dev/null
+++ b/trunk/Examples/perl5/import/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/trunk/Examples/perl5/import/README b/trunk/Examples/perl5/import/README
new file mode 100644
index 000000000..030a33bc5
--- /dev/null
+++ b/trunk/Examples/perl5/import/README
@@ -0,0 +1,39 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'perl runme.pl' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
+Windows:
+--------
+- Use the Visual C++ 6 workspace file (example.dsw). Build the runtime
+ project DLL first followed by the other 4 DLLs as they all have a
+ dependency on the runtime DLL. The Batch build option in the Build menu
+ is usually the easiest way to do this. Only use the Release builds not
+ the Debug builds.
+- Run the test as described above
+
diff --git a/trunk/Examples/perl5/import/bar.dsp b/trunk/Examples/perl5/import/bar.dsp
new file mode 100644
index 000000000..64786b8f6
--- /dev/null
+++ b/trunk/Examples/perl5/import/bar.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=bar - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"bar.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "bar - Win32 Debug"
+# Name "bar - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\bar_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\bar.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\bar.i
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/import/bar.h b/trunk/Examples/perl5/import/bar.h
new file mode 100644
index 000000000..fa4185f1f
--- /dev/null
+++ b/trunk/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/trunk/Examples/perl5/import/bar.i b/trunk/Examples/perl5/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/trunk/Examples/perl5/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/trunk/Examples/perl5/import/base.dsp b/trunk/Examples/perl5/import/base.dsp
new file mode 100644
index 000000000..920891cbf
--- /dev/null
+++ b/trunk/Examples/perl5/import/base.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=base - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"baseclass.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"baseclass.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "base - Win32 Debug"
+# Name "base - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\base_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\base.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\base.i
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/import/base.h b/trunk/Examples/perl5/import/base.h
new file mode 100644
index 000000000..5a266f68c
--- /dev/null
+++ b/trunk/Examples/perl5/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/trunk/Examples/perl5/import/base.i b/trunk/Examples/perl5/import/base.i
new file mode 100644
index 000000000..dc99383a7
--- /dev/null
+++ b/trunk/Examples/perl5/import/base.i
@@ -0,0 +1,6 @@
+%module baseclass
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/trunk/Examples/perl5/import/example.dsw b/trunk/Examples/perl5/import/example.dsw
new file mode 100644
index 000000000..d395d464b
--- /dev/null
+++ b/trunk/Examples/perl5/import/example.dsw
@@ -0,0 +1,65 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "bar"=.\bar.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "base"=.\base.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "foo"=.\foo.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "spam"=.\spam.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/trunk/Examples/perl5/import/foo.dsp b/trunk/Examples/perl5/import/foo.dsp
new file mode 100644
index 000000000..d519a5316
--- /dev/null
+++ b/trunk/Examples/perl5/import/foo.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=foo - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"foo.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "foo - Win32 Debug"
+# Name "foo - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\foo_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\foo.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\foo.i
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/import/foo.h b/trunk/Examples/perl5/import/foo.h
new file mode 100644
index 000000000..dd5184031
--- /dev/null
+++ b/trunk/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/trunk/Examples/perl5/import/foo.i b/trunk/Examples/perl5/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/trunk/Examples/perl5/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/trunk/Examples/perl5/import/runme.pl b/trunk/Examples/perl5/import/runme.pl
new file mode 100644
index 000000000..1db080751
--- /dev/null
+++ b/trunk/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/trunk/Examples/perl5/import/spam.dsp b/trunk/Examples/perl5/import/spam.dsp
new file mode 100644
index 000000000..e5c8046eb
--- /dev/null
+++ b/trunk/Examples/perl5/import/spam.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=spam - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"spam.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "spam - Win32 Debug"
+# Name "spam - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\spam_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\spam.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\spam.i
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/import/spam.h b/trunk/Examples/perl5/import/spam.h
new file mode 100644
index 000000000..b4e7a2646
--- /dev/null
+++ b/trunk/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/trunk/Examples/perl5/import/spam.i b/trunk/Examples/perl5/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/trunk/Examples/perl5/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/trunk/Examples/perl5/index.html b/trunk/Examples/perl5/index.html
new file mode 100644
index 000000000..5648c587d
--- /dev/null
+++ b/trunk/Examples/perl5/index.html
@@ -0,0 +1,80 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Perl Examples</H1>
+
+<p>
+The following examples illustrate the use of SWIG with Perl.
+
+<ul>
+<li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
+be used to wrap a C function and a global variable.
+<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>. This example shows how to access C global variables from Perl.
+<li><a href="value/index.html">value</a>. How to pass and return structures by value.
+<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="funcptr/index.html">funcptr</a>. Pointers to functions.
+</ul>
+
+<h2>Compilation Issues</h2>
+
+<ul>
+<li>To create a Perl extension, SWIG is run with the following options:
+
+<blockquote>
+<pre>
+% swig -perl5 interface.i
+</pre>
+</blockquote>
+
+<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):
+
+<blockquote>
+<pre>
+% swig -perl5 interface.i
+% gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
+% gcc -shared interface_wrap.o $(OBJS) -o interface.so
+% perl
+use interface;
+...
+</pre>
+</blockquote>
+
+<li>The politically "correct" way to compile a Perl extension module is to use MakeMaker
+and related tools (especially if you are considering third-party distribution). Consult
+a book such as Advanced Perl Programming for details.
+
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<p>
+<ul>
+<li>Linux
+<li>Solaris
+</ul>
+
+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>
+
+<p>
+Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows,
+the code generated by SWIG is extremely messy. We have made every attempt to maintain compatibility with
+many Perl releases going as far back as 5.003 and as recent as 5.6. However, your mileage may vary.
+If you experience a problem, please let us know by
+contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
+Better yet, send us a patch.
+
+</body>
+</html>
+
+
diff --git a/trunk/Examples/perl5/inline/Makefile b/trunk/Examples/perl5/inline/Makefile
new file mode 100644
index 000000000..4ac085ec3
--- /dev/null
+++ b/trunk/Examples/perl5/inline/Makefile
@@ -0,0 +1,7 @@
+all:
+
+run:
+ perl runme.pl
+
+clean:
+ rm -fr _Inline *~
diff --git a/trunk/Examples/perl5/inline/README b/trunk/Examples/perl5/inline/README
new file mode 100644
index 000000000..33be94973
--- /dev/null
+++ b/trunk/Examples/perl5/inline/README
@@ -0,0 +1,2 @@
+This example requires the Inline::SWIG package.
+
diff --git a/trunk/Examples/perl5/inline/runme.pl b/trunk/Examples/perl5/inline/runme.pl
new file mode 100644
index 000000000..8b0f0898f
--- /dev/null
+++ b/trunk/Examples/perl5/inline/runme.pl
@@ -0,0 +1,34 @@
+use Inline SWIG => <<"END_CODE", SWIG_ARGS => '-c++ -proxy', CC => 'g++', LD=>'g++';
+ class Foo {
+ public:
+ int meaning() { return 42; };
+ };
+END_CODE
+
+my $o = new Foo();
+print $o->meaning(),"\n";
+
+use Inline SWIG => ' ', SWIG_INTERFACE => <<"END_CODE", SWIG_ARGS => '-c++', CC => "g++", LD => "g++";
+%include std_string.i
+%inline {
+ template <class Type>
+ class Bar {
+ Type _val;
+ public:
+ Bar(Type v) : _val(v) {}
+ Type meaning() { return _val; }
+ };
+}
+%template(Bar_i) Bar<int>;
+%template(Bar_d) Bar<double>;
+%template(Bar_s) Bar<std::string>;
+END_CODE
+
+my $o = new Bar_i(1);
+print $o->meaning(),"\n";
+
+my $o = new Bar_d(2);
+print $o->meaning(),"\n";
+
+my $o = new Bar_s("hello");
+print $o->meaning(),"\n";
diff --git a/trunk/Examples/perl5/java/Example.java b/trunk/Examples/perl5/java/Example.java
new file mode 100644
index 000000000..91ddb1ac5
--- /dev/null
+++ b/trunk/Examples/perl5/java/Example.java
@@ -0,0 +1,29 @@
+public class Example {
+ public int mPublicInt;
+
+ public Example() {
+ mPublicInt = 0;
+ }
+
+ public Example(int IntVal) {
+ mPublicInt = IntVal;
+ }
+
+
+ public int Add(int a, int b) {
+ return (a+b);
+ }
+
+ public float Add(float a, float b) {
+ return (a+b);
+ }
+
+ public String Add(String a, String b) {
+ return (a+b);
+ }
+
+ public Example Add(Example a, Example b) {
+ return new Example(a.mPublicInt + b.mPublicInt);
+ }
+}
+
diff --git a/trunk/Examples/perl5/java/Makefile b/trunk/Examples/perl5/java/Makefile
new file mode 100644
index 000000000..882eba70f
--- /dev/null
+++ b/trunk/Examples/perl5/java/Makefile
@@ -0,0 +1,26 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all:: Example.class
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+ rm -f *.class Example.h
+
+check: all
+
+run:
+ perl runme.pl
+
+Example.class: Example.java
+ gcj -fPIC -C -c -g Example.java
+ gcjh Example
+
diff --git a/trunk/Examples/perl5/java/example.i b/trunk/Examples/perl5/java/example.i
new file mode 100644
index 000000000..a82abb267
--- /dev/null
+++ b/trunk/Examples/perl5/java/example.i
@@ -0,0 +1,10 @@
+%module example
+
+%include <cni.i>
+
+%{
+#include "Example.h"
+%}
+
+
+%include Example.h
diff --git a/trunk/Examples/perl5/java/runme.pl b/trunk/Examples/perl5/java/runme.pl
new file mode 100644
index 000000000..56ad6e408
--- /dev/null
+++ b/trunk/Examples/perl5/java/runme.pl
@@ -0,0 +1,29 @@
+use example;
+
+example::JvCreateJavaVM(undef);
+example::JvAttachCurrentThread(undef, undef);
+
+$e1 = new example::Example(1);
+print $e1->{mPublicInt},"\n";
+
+$e2 = new example::Example(2);
+print $e2->{mPublicInt},"\n";
+
+$i = $e1->Add(1,2);
+print $i,"\n";
+
+$d = $e2->Add(1.0,2.0);
+print $d,"\n";
+
+$d = $e2->Add("1","2");
+print $d,"\n";
+
+$e3 = $e1->Add($e1,$e2);
+print $e3->{mPublicInt},"\n";
+
+
+$s = $e2->Add("a","b");
+print $s,"\n";
+
+
+example::JvDetachCurrentThread()
diff --git a/trunk/Examples/perl5/multimap/Makefile b/trunk/Examples/perl5/multimap/Makefile
new file mode 100644
index 000000000..ce2bbb5b9
--- /dev/null
+++ b/trunk/Examples/perl5/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/perl5/multimap/example.c b/trunk/Examples/perl5/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/perl5/multimap/example.dsp b/trunk/Examples/perl5/multimap/example.dsp
new file mode 100644
index 000000000..be8a0070e
--- /dev/null
+++ b/trunk/Examples/perl5/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 "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/multimap/example.i b/trunk/Examples/perl5/multimap/example.i
new file mode 100644
index 000000000..64eb6a7f7
--- /dev/null
+++ b/trunk/Examples/perl5/multimap/example.i
@@ -0,0 +1,93 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(arginit) (int argc, char *argv[]) "$2 = 0;";
+
+%typemap(in) (int argc, char *argv[]) {
+ AV *tempav;
+ SV **tv;
+ I32 len;
+ int i;
+ if (!SvROK($input)) {
+ SWIG_exception(SWIG_ValueError,"$input is not an array.");
+ }
+ if (SvTYPE(SvRV($input)) != SVt_PVAV) {
+ SWIG_exception(SWIG_ValueError,"$input is not an array.");
+ }
+ tempav = (AV*)SvRV($input);
+ len = av_len(tempav);
+ $1 = (int) len+1;
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ tv = av_fetch(tempav, i, 0);
+ $2[i] = (char *) SvPV(*tv,PL_na);
+ }
+ $2[i] = 0;
+}
+
+%typemap(freearg) (int argc, char *argv[]) {
+ free($2);
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+ STRLEN temp;
+ $1 = (char *) SvPV($input, temp);
+ $2 = (int) temp;
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len) {
+ STRLEN templen;
+ char *temp;
+ temp = (char *) SvPV($input,templen);
+ $2 = (int) templen;
+ $1 = (char *) malloc($2+1);
+ memmove($1,temp,$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(argout) (char *str, int len) {
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $result = sv_newmortal();
+ sv_setpvn((SV*)ST(argvi++),$1,$2);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/trunk/Examples/perl5/multimap/runme.pl b/trunk/Examples/perl5/multimap/runme.pl
new file mode 100644
index 000000000..416055f5b
--- /dev/null
+++ b/trunk/Examples/perl5/multimap/runme.pl
@@ -0,0 +1,28 @@
+# file: runme.pl
+
+use example;
+
+# Call our gcd() function
+
+$x = 42;
+$y = 105;
+$g = example::gcd($x,$y);
+print "The gcd of $x and $y is $g\n";
+
+# Call the gcdmain() function
+@a = ("gcdmain","42","105");
+example::gcdmain(\@a);
+
+# Call the count function
+print example::count("Hello World", "l"),"\n";
+
+# Call the capitize function
+
+print example::capitalize("hello world"),"\n";
+
+
+
+
+
+
+
diff --git a/trunk/Examples/perl5/multiple_inheritance/Makefile b/trunk/Examples/perl5/multiple_inheritance/Makefile
new file mode 100644
index 000000000..fcca38473
--- /dev/null
+++ b/trunk/Examples/perl5/multiple_inheritance/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/trunk/Examples/perl5/multiple_inheritance/example.h b/trunk/Examples/perl5/multiple_inheritance/example.h
new file mode 100644
index 000000000..a8f544898
--- /dev/null
+++ b/trunk/Examples/perl5/multiple_inheritance/example.h
@@ -0,0 +1,31 @@
+/* File : example.h */
+
+#include <iostream>
+
+using namespace std;
+
+class Bar
+{
+ public:
+ virtual void bar () {
+ cout << "bar" << endl;
+ }
+ virtual ~Bar() {}
+};
+
+class Foo
+{
+ public:
+ virtual void foo () {
+ cout << "foo" << endl;
+ }
+ virtual ~Foo() {}
+};
+
+class Foo_Bar : public Foo, public Bar
+{
+ public:
+ virtual void fooBar () {
+ cout << "foobar" << endl;
+ }
+};
diff --git a/trunk/Examples/perl5/multiple_inheritance/example.i b/trunk/Examples/perl5/multiple_inheritance/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/trunk/Examples/perl5/multiple_inheritance/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/trunk/Examples/perl5/multiple_inheritance/runme.pl b/trunk/Examples/perl5/multiple_inheritance/runme.pl
new file mode 100644
index 000000000..a1130c66e
--- /dev/null
+++ b/trunk/Examples/perl5/multiple_inheritance/runme.pl
@@ -0,0 +1,16 @@
+# file: runme.pl
+
+# This file test multiple inheritance
+
+use example;
+
+$foo_Bar = new example::Foo_Bar();
+
+print "must be foo: ";
+$foo_Bar->foo();
+
+print "must be bar: ";
+$foo_Bar->bar();
+
+print "must be foobar: ";
+$foo_Bar->fooBar();
diff --git a/trunk/Examples/perl5/pointer/Makefile b/trunk/Examples/perl5/pointer/Makefile
new file mode 100644
index 000000000..ce2bbb5b9
--- /dev/null
+++ b/trunk/Examples/perl5/pointer/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/perl5/pointer/example.c b/trunk/Examples/perl5/pointer/example.c
new file mode 100644
index 000000000..8762329fe
--- /dev/null
+++ b/trunk/Examples/perl5/pointer/example.c
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(int *x, int *y, int *result) {
+ *result = *x + *y;
+}
+
+void subtract(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/trunk/Examples/perl5/pointer/example.i b/trunk/Examples/perl5/pointer/example.i
new file mode 100644
index 000000000..38c67d7d2
--- /dev/null
+++ b/trunk/Examples/perl5/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void subtract(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void subtract(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/perl5/pointer/index.html b/trunk/Examples/perl5/pointer/index.html
new file mode 100644
index 000000000..94467bc36
--- /dev/null
+++ b/trunk/Examples/perl5/pointer/index.html
@@ -0,0 +1,171 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:pointer</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/perl5/pointer/</tt>
+<hr>
+
+<H2>Simple Pointer Handling</H2>
+
+<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. The only
+problem is how does one go about creating these objects from a script?
+
+<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>
+
+Now, in a script you would do this:
+
+<blockquote>
+<pre>
+$a = new_int(37);
+$b = new_int(42);
+$c = new_int(0):
+add($a,$b,$c);
+$r = get_int($c);
+print "Result = $r\n";
+delete_int($a);
+delete_int($b);
+delete_int($c);
+</pre>
+</blockquote>
+
+<p>
+<li>Use the SWIG pointer library. For example, in the interface file
+you would do this:
+
+<blockquote>
+<pre>
+%include "pointer.i"
+</pre>
+</blockquote?
+
+and in a script you would do this:
+
+<blockquote>
+<pre>
+$a = ptrcreate("int",37);
+$b = ptrcreate("int",42);
+$c = ptrcreate("int");
+add($a,$b,$c);
+$r = ptrvalue($c);
+print "Result = $r\n";
+ptrfree($a);
+ptrfree($b);
+ptrfree($c);
+</pre>
+</blockquote>
+
+The advantage to using the pointer library is that it unifies some of the helper
+functions behind a common set of names. For example, the same set of functions work
+with int, double, float, and other fundamental types.
+
+<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 script:
+
+<blockquote>
+<pre>
+$r = add(37,42);
+print "Result = $r\n";
+</pre>
+</blockquote>
+Needless to say, this is substantially easier.
+
+<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 subtract(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="runme.pl">runme.pl</a> (Perl Script)
+</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 pointer.i library files can be
+found in the SWIG user manual. The files also contain documentation.
+
+<p>
+<li>The pointer.i library is designed primarily for convenience. If you
+are concerned about performance, you probably want to use a different
+approach.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/perl5/pointer/runme.pl b/trunk/Examples/perl5/pointer/runme.pl
new file mode 100644
index 000000000..4f0a89e82
--- /dev/null
+++ b/trunk/Examples/perl5/pointer/runme.pl
@@ -0,0 +1,44 @@
+# file: runme.pl
+
+use example;
+
+# First create some objects using the pointer library.
+print "Testing the pointer library\n";
+$a = example::new_intp();
+$b = example::new_intp();
+$c = example::new_intp();
+example::intp_assign($a,37);
+example::intp_assign($b,42);
+
+print " a = $a\n";
+print " b = $b\n";
+print " c = $c\n";
+
+# Call the add() function with some pointers
+example::add($a,$b,$c);
+
+# Now get the result
+$r = example::intp_value($c);
+print " 37 + 42 = $r\n";
+
+# Clean up the pointers
+example::delete_intp($a);
+example::delete_intp($b);
+example::delete_intp($c);
+
+# Now try the typemap library
+# This should be much easier. Now how it is no longer
+# necessary to manufacture pointers.
+
+print "Trying the typemap library\n";
+$r = example::subtract(37,42);
+print " 37 - 42 = $r\n";
+
+# Now try the version with multiple return values
+
+print "Testing multiple return values\n";
+($q,$r) = example::divide(42,37);
+print " 42/37 = $q remainder $r\n";
+
+
+
diff --git a/trunk/Examples/perl5/reference/Makefile b/trunk/Examples/perl5/reference/Makefile
new file mode 100644
index 000000000..4a804258b
--- /dev/null
+++ b/trunk/Examples/perl5/reference/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
diff --git a/trunk/Examples/perl5/reference/example.cxx b/trunk/Examples/perl5/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/perl5/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/perl5/reference/example.h b/trunk/Examples/perl5/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/reference/example.i b/trunk/Examples/perl5/reference/example.i
new file mode 100644
index 000000000..6daa3b1f4
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/reference/index.html b/trunk/Examples/perl5/reference/index.html
new file mode 100644
index 000000000..70b4f3d34
--- /dev/null
+++ b/trunk/Examples/perl5/reference/index.html
@@ -0,0 +1,146 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/perl5/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<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 &amp;a, const Vector &amp;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 &amp;a, const Vector &amp;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 &amp;operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &amp;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 &amp;result = self-&gt;get(index);
+ return &amp;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 &amp;get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &amp;a) {
+ (*self)[index] = a;
+ }
+ }
+ ...
+}
+</pre>
+</blockquote>
+
+Click <a href="example.i">here</a> to see a SWIG interface file with these additions.
+
+<h2>Sample Perl script</h2>
+
+Click <a href="runme.pl">here</a> to see a script that manipulates some C++ references.
+
+<h2>Notes:</h2>
+
+<ul>
+<li>C++ references primarily provide notational convenience for C++
+source code. However, it doesn't much matter to Perl.
+
+<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/trunk/Examples/perl5/reference/runme.pl b/trunk/Examples/perl5/reference/runme.pl
new file mode 100644
index 000000000..41dc0b873
--- /dev/null
+++ b/trunk/Examples/perl5/reference/runme.pl
@@ -0,0 +1,74 @@
+# file: runme.pl
+
+# This file illustrates the manipulation of C++ references in Perl.
+# This uses the low-level interface. Proxy classes work differently.
+
+use example;
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$a = example::new_Vector(3,4,5);
+$b = example::new_Vector(10,11,12);
+
+print " Created",example::Vector_print($a),"\n";
+print " Created",example::Vector_print($b),"\n";
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+print "Adding a+b\n";
+$c = example::addv($a,$b);
+print " a+b =", example::Vector_print($c),"\n";
+
+# Note: Unless we free the result, a memory leak will occur
+example::delete_Vector($c);
+
+# ----- Create a vector array -----
+
+# Note: Using the high-level interface here
+print "Creating an array of vectors\n";
+$va = example::new_VectorArray(10);
+print " va = $va\n";
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of $a and $b to the vector array
+example::VectorArray_set($va,0,$a);
+example::VectorArray_set($va,1,$b);
+
+# This will work, but it will cause a memory leak!
+
+example::VectorArray_set($va,2,example::addv($a,$b));
+
+# The non-leaky way to do it
+
+$c = example::addv($a,$b);
+example::VectorArray_set($va,3,$c);
+example::delete_Vector($c);
+
+# Get some values from the array
+
+print "Getting some array values\n";
+for ($i = 0; $i < 5; $i++) {
+ print " va($i) = ", example::Vector_print(example::VectorArray_get($va,$i)), "\n";
+}
+
+# Watch under resource meter to check on this
+print "Making sure we don't leak memory.\n";
+for ($i = 0; $i < 1000000; $i++) {
+ $c = example::VectorArray_get($va,$i % 10);
+}
+
+# ----- Clean up -----
+print "Cleaning up\n";
+
+example::delete_VectorArray($va);
+example::delete_Vector($a);
+example::delete_Vector($b);
+
diff --git a/trunk/Examples/perl5/simple/Makefile b/trunk/Examples/perl5/simple/Makefile
new file mode 100644
index 000000000..ce2bbb5b9
--- /dev/null
+++ b/trunk/Examples/perl5/simple/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/perl5/simple/example.c b/trunk/Examples/perl5/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/simple/example.dsp b/trunk/Examples/perl5/simple/example.dsp
new file mode 100644
index 000000000..be8a0070e
--- /dev/null
+++ b/trunk/Examples/perl5/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 "$(PERL5_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PERL5_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PERL5_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -perl5 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PERL5_INCLUDE: %PERL5_INCLUDE%
+ echo PERL5_LIB: %PERL5_LIB%
+ echo on
+ ..\..\..\swig.exe -perl5 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/perl5/simple/example.i b/trunk/Examples/perl5/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/perl5/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/perl5/simple/index.html b/trunk/Examples/perl5/simple/index.html
new file mode 100644
index 000000000..7f230531d
--- /dev/null
+++ b/trunk/Examples/perl5/simple/index.html
@@ -0,0 +1,99 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/perl5/simple/</tt>
+<hr>
+
+<H2>Simple Perl5 Example</H2>
+
+<p>
+This example illustrates how you can hook Perl 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 &gt; 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 -perl5 <a href="example.i">example.i</a></tt>
+<p>
+<li>This produces two files: <tt><a href="example_wrap.c">example_wrap.c</a></tt> and <tt><a href="example.pm">example.pm</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>example.so</tt>.
+</ol>
+
+<h2>Using the extension</h2>
+
+Click <a href="runme.pl">here</a> to see a script that calls our C functions from Perl.
+
+<h2>Key points</h2>
+
+<ul>
+<li>Use the <tt>use</tt> statement to load your extension module from Perl. For example:
+<blockquote>
+<pre>
+use example;
+</pre>
+</blockquote>
+
+<li>C functions work just like Perl functions. For example:
+<blockquote>
+<pre>
+$g = example::gcd(42,105);
+</pre>
+</blockquote>
+
+<li>C global variables are accessed like ordinary Perl variables. For example:
+<blockquote>
+<pre>
+$a = $example::Foo;
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/perl5/simple/runme.pl b/trunk/Examples/perl5/simple/runme.pl
new file mode 100644
index 000000000..b8655be8a
--- /dev/null
+++ b/trunk/Examples/perl5/simple/runme.pl
@@ -0,0 +1,23 @@
+#
+# Perl5 script for testing simple example
+
+use example;
+
+# Call our gcd() function
+
+$x = 42;
+$y = 105;
+$g = example::gcd($x,$y);
+print "The gcd of $x and $y is $g\n";
+
+# Manipulate the Foo global variable
+
+# Output its current value
+print "Foo = $example::Foo\n";
+
+# Change its value
+$example::Foo = 3.1415926;
+
+# See if the change took effect
+print "Foo = $example::Foo\n";
+
diff --git a/trunk/Examples/perl5/value/Makefile b/trunk/Examples/perl5/value/Makefile
new file mode 100644
index 000000000..ce2bbb5b9
--- /dev/null
+++ b/trunk/Examples/perl5/value/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/perl5/value/example.c b/trunk/Examples/perl5/value/example.c
new file mode 100644
index 000000000..4ed2fe10a
--- /dev/null
+++ b/trunk/Examples/perl5/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/trunk/Examples/perl5/value/example.h b/trunk/Examples/perl5/value/example.h
new file mode 100644
index 000000000..212cf4bdb
--- /dev/null
+++ b/trunk/Examples/perl5/value/example.h
@@ -0,0 +1,5 @@
+/* File : example.h */
+
+typedef struct {
+ double x, y, z;
+} Vector;
diff --git a/trunk/Examples/perl5/value/example.i b/trunk/Examples/perl5/value/example.i
new file mode 100644
index 000000000..98fd60ed5
--- /dev/null
+++ b/trunk/Examples/perl5/value/example.i
@@ -0,0 +1,32 @@
+// Tests SWIG's handling of pass-by-value for complex datatypes
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Some functions that manipulate Vectors by value */
+%inline %{
+extern double dot_product(Vector a, Vector b);
+extern Vector vector_add(Vector a, Vector b);
+%}
+
+/* Include this because the vector_add() function will leak memory */
+void free(void *);
+
+/* Some helper functions for our interface */
+%inline %{
+
+Vector *new_Vector(double x, double y, double z) {
+ Vector *v = (Vector *) malloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+}
+
+void vector_print(Vector *v) {
+ printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+%}
+
diff --git a/trunk/Examples/perl5/value/index.html b/trunk/Examples/perl5/value/index.html
new file mode 100644
index 000000000..62c1a032f
--- /dev/null
+++ b/trunk/Examples/perl5/value/index.html
@@ -0,0 +1,126 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:value</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/perl5/value/</tt>
+<hr>
+
+<H2>Passing and Returning Structures by Value</H2>
+
+<p>
+Occasionally, a C program will manipulate structures by value such as shown in the
+following code:
+
+<blockquote>
+<pre>
+/* File : example.c */
+
+typedef struct Vector {
+ double x, y, z;
+} Vector;
+
+double dot_product(Vector a, Vector b) {
+ return (a.x*b.x + a.y*b.y + a.z*b.z);
+}
+
+Vector vector_add(Vector a, Vector b) {
+ Vector r;
+ r.x = a.x + b.x;
+ r.y = a.y + b.y;
+ r.z = a.z + b.z;
+ return r;
+}
+</pre>
+</blockquote>
+
+Since SWIG only knows how to manage pointers to structures (not their internal
+representation), the following translations are made when wrappers are
+created:
+
+<blockquote>
+<pre>
+double wrap_dot_product(Vector *a, Vector *b) {
+ return dot_product(*a,*b);
+}
+
+Vector *wrap_vector_add(Vector *a, Vector *b) {
+ Vector *r = (Vector *) malloc(sizeof(Vector));
+ *r = vector_add(*a,*b);
+ return r;
+}
+</pre>
+</blockquote>
+
+The functions are then called using pointers from the scripting language interface.
+It should also be noted that any function that returns a structure by value results
+in an implicit memory allocation. This will be a memory leak unless you take steps
+to free the result (see below).
+
+<h2>The SWIG interface</h2>
+
+Click <a href="example.i">here</a> to see a SWIG interface file that
+wraps these two functions. In this file, there are a few essential features:
+
+<ul>
+<li>A wrapper for the <tt>free()</tt> function is created so that we
+can clean up the return result created by <tt>vector_add()</tt>
+function.
+
+<p>
+<li>The %inline directive is used to create a few helper functions for creating new Vector
+objects and to print out the value (for debugging purposes).
+</ul>
+
+<h2>A Perl Script</h2>
+
+Click <a href="runme.pl">here</a> to see a script that uses these functions from Perl.
+
+<h2>Notes</h2>
+
+<ul>
+<li>When the '<tt>-c++</tt>' option is used, the resulting wrapper code for the return value
+changes to the following:
+
+<blockquote>
+<pre>
+Vector *wrap_vector_add(Vector *a, Vector *b) {
+ Vector *r = new Vector(vector_add(*a,*b));
+ return r;
+}
+</pre>
+</blockquote>
+
+Similarly, it would be a mistake to use the <tt>free()</tt> function from C++. A safer
+approach would be to write a helper function like this:
+
+<blockquote>
+<pre>
+%inline %{
+ void delete_Vector(Vector *v) {
+ delete v;
+ }
+%}
+</pre>
+</blockquote>
+
+<p>
+<li>If you use proxy classes and are careful, the SWIG generated wrappers can automatically
+clean up the result of return-by-reference when the scripting variable goes out of scope.
+
+<p>
+<li>Passing parameters by value like this really isn't the best C programming style.
+If possible, you might change your application to use pointers.
+
+<p>
+<li>Similar translations are made when C++ references are used.
+
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/perl5/value/runme.pl b/trunk/Examples/perl5/value/runme.pl
new file mode 100644
index 000000000..dc2660bf1
--- /dev/null
+++ b/trunk/Examples/perl5/value/runme.pl
@@ -0,0 +1,38 @@
+# file: runme.pl
+
+use example;
+
+# Create a couple of a vectors
+
+$v = example::new_Vector(1,2,3);
+$w = example::new_Vector(10,11,12);
+
+print "I just created the following vectors\n";
+example::vector_print($v);
+example::vector_print($w);
+
+# Now call some of our functions
+
+print "\nNow I'm going to compute the dot product\n";
+$d = example::dot_product($v,$w);
+print "dot product = $d (should be 68)\n";
+
+# Add the vectors together
+
+print "\nNow I'm going to add the vectors together\n";
+$r = example::vector_add($v,$w);
+example::vector_print($r);
+print "The value should be (11,13,15)\n";
+
+# Now I'd better clean up the return result r
+
+print "\nNow I'm going to clean up the return result\n";
+example::free($r);
+
+print "Good\n";
+
+
+
+
+
+
diff --git a/trunk/Examples/perl5/variables/Makefile b/trunk/Examples/perl5/variables/Makefile
new file mode 100644
index 000000000..ce2bbb5b9
--- /dev/null
+++ b/trunk/Examples/perl5/variables/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/perl5/variables/example.c b/trunk/Examples/perl5/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/perl5/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/perl5/variables/example.h b/trunk/Examples/perl5/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/perl5/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/perl5/variables/example.i b/trunk/Examples/perl5/variables/example.i
new file mode 100644
index 000000000..9d0101cb7
--- /dev/null
+++ b/trunk/Examples/perl5/variables/example.i
@@ -0,0 +1,51 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/perl5/variables/index.html b/trunk/Examples/perl5/variables/index.html
new file mode 100644
index 000000000..e4d426e2d
--- /dev/null
+++ b/trunk/Examples/perl5/variables/index.html
@@ -0,0 +1,63 @@
+<html>
+<head>
+<title>SWIG:Examples:perl5:variables</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/perl5/variables/</tt>
+<hr>
+
+<H2>Wrapping C Global Variables</H2>
+
+<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 Perl 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 Perl</h2>
+
+Accessing a C global variable from Perl is easy---just reference it like a normal Perl variable.
+Click <a href="runme.pl">here</a> to see a script that updates and prints some global variables.
+
+<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>Notes:</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 Perl, 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 Perl strings, but
+when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
+<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.
+<li>Variables are linked using Perl's magic mechanism. Take a look at the Advanced Perl Programming book to
+find out more about this feature.
+</ul>
+
+</body>
+</html>
+<hr>
diff --git a/trunk/Examples/perl5/variables/runme.pl b/trunk/Examples/perl5/variables/runme.pl
new file mode 100644
index 000000000..76e3dc8bc
--- /dev/null
+++ b/trunk/Examples/perl5/variables/runme.pl
@@ -0,0 +1,73 @@
+# file: runme.pl
+
+use example;
+
+# Try to set the values of some global variables
+
+$example::ivar = 42;
+$example::svar = -31000;
+$example::lvar = 65537;
+$example::uivar = 123456;
+$example::usvar = 61000;
+$example::ulvar = 654321;
+$example::scvar = -13;
+$example::ucvar = 251;
+$example::cvar = "S";
+$example::fvar = 3.14159;
+$example::dvar = 2.1828;
+$example::strvar = "Hello World";
+$example::iptrvar= example::new_int(37);
+$example::ptptr = example::new_Point(37,42);
+$example::name = "Bill";
+
+# Now print out the values of the variables
+
+print "Variables (values printed from Perl)\n";
+
+print "ivar = $example::ivar\n";
+print "svar = $example::svar\n";
+print "lvar = $example::lvar\n";
+print "uivar = $example::uivar\n";
+print "usvar = $example::usvar\n";
+print "ulvar = $example::ulvar\n";
+print "scvar = $example::scvar\n";
+print "ucvar = $example::ucvar\n";
+print "fvar = $example::fvar\n";
+print "dvar = $example::dvar\n";
+print "cvar = $example::cvar\n";
+print "strvar = $example::strvar\n";
+print "cstrvar = $example::cstrvar\n";
+print "iptrvar = $example::iptrvar\n";
+print "name = $example::name\n";
+print "ptptr = $example::ptptr", example::Point_print($example::ptptr), "\n";
+print "pt = $example::pt", example::Point_print($example::pt), "\n";
+
+print "\nVariables (values printed from C)\n";
+
+example::print_vars();
+
+print "\nI'm going to try and update a structure variable.\n";
+
+$example::pt = $example::ptptr;
+
+print "The new value is ";
+example::pt_print();
+print "You should see the value", example::Point_print($example::ptptr), "\n";
+
+
+print "\nNow I'm going to try and modify some read only variables\n";
+
+
+print " Trying to set 'status'\n";
+eval { $example::status = 0; };
+if (!$@) {
+ die("status");
+}
+print " get error for 'status'\n";
+
+print " Tring to set 'path'\n";
+eval { $example::path = "Whoa!";};
+if (!$@) {
+ die("path");
+}
+print " get error for 'path'\n";
diff --git a/trunk/Examples/perl5/xmlstring/Makefile b/trunk/Examples/perl5/xmlstring/Makefile
new file mode 100644
index 000000000..36143fc3a
--- /dev/null
+++ b/trunk/Examples/perl5/xmlstring/Makefile
@@ -0,0 +1,23 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lxerces-c -lxerces-depdom -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile perl5_clean
+
+check: all
+
+
+run:
+ perl runme.pl
diff --git a/trunk/Examples/perl5/xmlstring/example.cxx b/trunk/Examples/perl5/xmlstring/example.cxx
new file mode 100644
index 000000000..370dd9ea9
--- /dev/null
+++ b/trunk/Examples/perl5/xmlstring/example.cxx
@@ -0,0 +1 @@
+#include "example.h"
diff --git a/trunk/Examples/perl5/xmlstring/example.h b/trunk/Examples/perl5/xmlstring/example.h
new file mode 100644
index 000000000..a1ccf2185
--- /dev/null
+++ b/trunk/Examples/perl5/xmlstring/example.h
@@ -0,0 +1,36 @@
+#include <xercesc/util/XMLString.hpp>
+
+
+class XMLChTest
+{
+ XMLCh *_val;
+
+public:
+
+ XMLChTest() : _val(0)
+ {
+ }
+
+ void set(const XMLCh *v)
+ {
+ size_t len = XERCES_CPP_NAMESPACE::XMLString::stringLen(v);
+ delete[] _val;
+ _val = new XMLCh[len + 1];
+ for (int i = 0; i < len; ++i) {
+ _val[i] = v[i];
+ }
+ _val[len] = 0;
+ }
+
+ const XMLCh *get()
+ {
+ return _val;
+ }
+
+ XMLCh get_first()
+ {
+ return _val[0];
+ }
+
+};
+
diff --git a/trunk/Examples/perl5/xmlstring/example.i b/trunk/Examples/perl5/xmlstring/example.i
new file mode 100644
index 000000000..8a9e02e40
--- /dev/null
+++ b/trunk/Examples/perl5/xmlstring/example.i
@@ -0,0 +1,10 @@
+%module example
+
+%include <xmlstring.i>
+
+%{
+#include "example.h"
+%}
+
+
+%include example.h
diff --git a/trunk/Examples/perl5/xmlstring/runme.pl b/trunk/Examples/perl5/xmlstring/runme.pl
new file mode 100644
index 000000000..1b223d4ca
--- /dev/null
+++ b/trunk/Examples/perl5/xmlstring/runme.pl
@@ -0,0 +1,8 @@
+use example;
+
+
+$e1 = new example::XMLChTest();
+$e1->set("hello");
+print $e1->get(),"\n";
+print $e1->get_first(),"\n";
+
diff --git a/trunk/Examples/perl5/xmlstring/xmlstring.i b/trunk/Examples/perl5/xmlstring/xmlstring.i
new file mode 100644
index 000000000..3ef53169d
--- /dev/null
+++ b/trunk/Examples/perl5/xmlstring/xmlstring.i
@@ -0,0 +1,111 @@
+%include <perlstrings.swg>
+
+%fragment("<XMLCh.h>","header")
+%{
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/TransService.hpp>
+#include <xercesc/util/XMLUTF8Transcoder.hpp>
+%}
+
+%fragment("SWIG_UTF8Transcoder","header",fragment="<XMLCh.h>") {
+SWIGINTERN XERCES_CPP_NAMESPACE::XMLTranscoder*
+SWIG_UTF8Transcoder() {
+ using namespace XERCES_CPP_NAMESPACE;
+ static int init = 0;
+ static XMLTranscoder* UTF8_TRANSCODER = NULL;
+ static XMLCh* UTF8_ENCODING = NULL;
+ if (!init) {
+ XMLTransService::Codes failReason;
+ XMLPlatformUtils::Initialize(); // first we must create the transservice
+ UTF8_ENCODING = XMLString::transcode("UTF-8");
+ UTF8_TRANSCODER = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(UTF8_ENCODING,
+ failReason,
+ 1024);
+ init = 1;
+ }
+ return UTF8_TRANSCODER;
+}
+}
+
+%fragment("SWIG_AsXMLChPtrAndSize","header",fragment="SWIG_AsCharPtrAndSize",fragment="SWIG_UTF8Transcoder") {
+SWIGINTERN int
+SWIG_AsXMLChPtrAndSize(SV *obj, XMLCh **val, size_t* psize, int *alloc)
+{
+ if (!val) {
+ return SWIG_AsCharPtrAndSize(obj, 0, 0, 0);
+ } else {
+ size_t size;
+ char *cptr = 0;
+ int calloc = SWIG_OLDOBJ;
+ int res = SWIG_AsCharPtrAndSize(obj, &cptr, &size, &calloc);
+ if (SWIG_IsOK(res)) {
+ STRLEN length = size - 1;
+ if (SvUTF8(obj)) {
+ unsigned int charsEaten = 0;
+ unsigned char* sizes = %new_array(size, unsigned char);
+ *val = %new_array(size, XMLCh);
+ unsigned int chars_stored =
+ SWIG_UTF8Transcoder()->transcodeFrom((const XMLByte*) cptr,
+ (unsigned int) length,
+ (XMLCh*) *val,
+ (unsigned int) length,
+ charsEaten,
+ (unsigned char*)sizes
+ );
+ %delete_array(sizes);
+ // indicate the end of the string
+ (*val)[chars_stored] = '\0';
+ } else {
+ *val = XERCES_CPP_NAMESPACE::XMLString::transcode(cptr);
+ }
+ if (psize) *psize = size;
+ if (alloc) *alloc = SWIG_NEWOBJ;
+ if (calloc == SWIG_NEWOBJ) %delete_array(cptr);
+ return SWIG_NEWOBJ;
+ } else {
+ return res;
+ }
+ }
+}
+}
+
+%fragment("SWIG_FromXMLChPtrAndSize","header",fragment="SWIG_UTF8Transcoder") {
+SWIGINTERNINLINE SV *
+SWIG_FromXMLChPtrAndSize(const XMLCh* input, size_t size)
+{
+ SV *output = sv_newmortal();
+ unsigned int charsEaten = 0;
+ int length = size; // string length
+ XMLByte* res = %new_array(length * UTF8_MAXLEN, XMLByte); // output string
+ unsigned int total_chars =
+ SWIG_UTF8Transcoder()->transcodeTo((const XMLCh*) input,
+ (unsigned int) length,
+ (XMLByte*) res,
+ (unsigned int) length*UTF8_MAXLEN,
+ charsEaten,
+ XERCES_CPP_NAMESPACE::XMLTranscoder::UnRep_Throw
+ );
+ res[total_chars] = '\0';
+ sv_setpv((SV*)output, (char *)res );
+ SvUTF8_on((SV*)output);
+ %delete_array(res);
+ return output;
+}
+}
+
+%init {
+ if (!SWIG_UTF8Transcoder()) {
+ croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder");
+ }
+}
+
+
+%include <typemaps/strings.swg>
+%typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR),
+ XMLCh, XMLCh,
+ SWIG_AsXMLChPtrAndSize,
+ SWIG_FromXMLChPtrAndSize,
+ XERCES_CPP_NAMESPACE::XMLString::stringLen,
+ "<XMLCh.h>", INT_MIN, INT_MAX);
+
+
diff --git a/trunk/Examples/php/callback/Makefile b/trunk/Examples/php/callback/Makefile
new file mode 100644
index 000000000..42597202b
--- /dev/null
+++ b/trunk/Examples/php/callback/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/callback/example.cxx b/trunk/Examples/php/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/php/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/php/callback/example.h b/trunk/Examples/php/callback/example.h
new file mode 100644
index 000000000..2a0194999
--- /dev/null
+++ b/trunk/Examples/php/callback/example.h
@@ -0,0 +1,22 @@
+/* File : example.h */
+
+#include <iostream>
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/trunk/Examples/php/callback/example.i b/trunk/Examples/php/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/trunk/Examples/php/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/trunk/Examples/php/callback/index.html b/trunk/Examples/php/callback/index.html
new file mode 100644
index 000000000..2aa720e24
--- /dev/null
+++ b/trunk/Examples/php/callback/index.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>SWIG:Examples:php:callback</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/php/callback/</tt>
+<hr>
+
+<H2>Implementing C++ callbacks in PHP</H2>
+
+<p>
+This example illustrates how to use directors to implement C++ callbacks in PHP.
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/php/callback/runme.php b/trunk/Examples/php/callback/runme.php
new file mode 100644
index 000000000..2be71994f
--- /dev/null
+++ b/trunk/Examples/php/callback/runme.php
@@ -0,0 +1,47 @@
+<?php
+
+# This file illustrates the cross language polymorphism using directors.
+
+require("example.php");
+
+# Class, which overwrites Callback::run().
+
+class PhpCallback extends Callback {
+ function run() {
+ print "PhpCallback.run()\n";
+ }
+};
+
+# Create an Caller instance
+
+$caller = new Caller();
+
+# Add a simple C++ callback (caller owns the callback, so
+# we disown it first by clearing the .thisown flag).
+
+print "Adding and calling a normal C++ callback\n";
+print "----------------------------------------\n";
+
+$callback = new Callback();
+$callback->thisown = 0;
+$caller->setCallback($callback);
+$caller->call();
+$caller->delCallback();
+
+print "\n";
+print "Adding and calling a PHP callback\n";
+print "------------------------------------\n";
+
+# Add a PHP callback.
+
+$callback = new PhpCallback();
+$callback->thisown = 0;
+$caller->setCallback($callback);
+$caller->call();
+$caller->delCallback();
+
+# All done.
+
+print "php exit\n";
+
+?>
diff --git a/trunk/Examples/php/check.list b/trunk/Examples/php/check.list
new file mode 100644
index 000000000..28c7a619f
--- /dev/null
+++ b/trunk/Examples/php/check.list
@@ -0,0 +1,19 @@
+# see top-level Makefile.in
+# (see also top-level configure.in kludge)
+callback
+class
+constants
+cpointer
+disown
+enum
+extend
+funcptr
+overloading
+pointer
+pragmas
+proxy
+reference
+simple
+sync
+value
+variables
diff --git a/trunk/Examples/php/class/Makefile b/trunk/Examples/php/class/Makefile
new file mode 100644
index 000000000..1bc0beaab
--- /dev/null
+++ b/trunk/Examples/php/class/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/class/example.cxx b/trunk/Examples/php/class/example.cxx
new file mode 100644
index 000000000..f171f10e9
--- /dev/null
+++ b/trunk/Examples/php/class/example.cxx
@@ -0,0 +1,39 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+int Shape::get_nshapes() {
+ return nshapes;
+}
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+void Circle::set_radius( double r ) {
+ radius = r;
+}
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/trunk/Examples/php/class/example.h b/trunk/Examples/php/class/example.h
new file mode 100644
index 000000000..02eaf7232
--- /dev/null
+++ b/trunk/Examples/php/class/example.h
@@ -0,0 +1,38 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+ static int get_nshapes();
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { }
+ ~Circle() { }
+ void set_radius( double r );
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { }
+ ~Square() { }
+ virtual double area(void);
+ virtual double perimeter(void);
+};
diff --git a/trunk/Examples/php/class/example.i b/trunk/Examples/php/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/class/runme.php b/trunk/Examples/php/class/runme.php
new file mode 100644
index 000000000..12b686052
--- /dev/null
+++ b/trunk/Examples/php/class/runme.php
@@ -0,0 +1,60 @@
+<?php
+
+# This example illustrates how member variables are wrapped.
+
+require("example.php");
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = new Circle(10);
+print " Created circle\n";
+$s = new Square(10);
+print " Created square\n";
+
+# ----- Access a static member -----
+
+print "\nA total of " . Shape::get_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 -----
+
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+print "\nHere are some properties of the shapes:\n";
+foreach (array($c,$s) as $o) {
+ print " ". get_class($o) . "\n";
+ print " area = {$o->area()}\n";
+ print " perimeter = {$o->perimeter()}\n";
+}
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+$c = NULL;
+$s = NULL;
+
+# and don't forget the $o from the for loop above. It still refers to
+# the square.
+$o = NULL;
+
+print Shape::get_nshapes() . " shapes remain\n";
+print "Goodbye\n";
+
+?>
diff --git a/trunk/Examples/php/constants/Makefile b/trunk/Examples/php/constants/Makefile
new file mode 100644
index 000000000..23e2675d7
--- /dev/null
+++ b/trunk/Examples/php/constants/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/constants/example.i b/trunk/Examples/php/constants/example.i
new file mode 100644
index 000000000..0098a893a
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/constants/runme.php b/trunk/Examples/php/constants/runme.php
new file mode 100644
index 000000000..cea06485f
--- /dev/null
+++ b/trunk/Examples/php/constants/runme.php
@@ -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/trunk/Examples/php/cpointer/Makefile b/trunk/Examples/php/cpointer/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/trunk/Examples/php/cpointer/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/cpointer/example.c b/trunk/Examples/php/cpointer/example.c
new file mode 100644
index 000000000..3326dec3e
--- /dev/null
+++ b/trunk/Examples/php/cpointer/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/trunk/Examples/php/cpointer/example.i b/trunk/Examples/php/cpointer/example.i
new file mode 100644
index 000000000..52e6df190
--- /dev/null
+++ b/trunk/Examples/php/cpointer/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/trunk/Examples/php/cpointer/runme.php b/trunk/Examples/php/cpointer/runme.php
new file mode 100644
index 000000000..48f0ad631
--- /dev/null
+++ b/trunk/Examples/php/cpointer/runme.php
@@ -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/trunk/Examples/php/disown/Makefile b/trunk/Examples/php/disown/Makefile
new file mode 100644
index 000000000..1bc0beaab
--- /dev/null
+++ b/trunk/Examples/php/disown/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/disown/example.cxx b/trunk/Examples/php/disown/example.cxx
new file mode 100644
index 000000000..6393735e9
--- /dev/null
+++ b/trunk/Examples/php/disown/example.cxx
@@ -0,0 +1,51 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+int Shape::get_nshapes() {
+ return nshapes;
+}
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+void Circle::set_radius( double r ) {
+ radius = r;
+}
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
+
+ShapeContainer::~ShapeContainer() {
+ iterator i=shapes.begin();
+ for( iterator i = shapes.begin(); i != shapes.end(); ++i ) {
+ delete *i;
+ }
+}
+
+void
+ShapeContainer::addShape( Shape *s ) {
+ shapes.push_back( s );
+}
diff --git a/trunk/Examples/php/disown/example.h b/trunk/Examples/php/disown/example.h
new file mode 100644
index 000000000..985bc333d
--- /dev/null
+++ b/trunk/Examples/php/disown/example.h
@@ -0,0 +1,50 @@
+/* File : example.h */
+
+#include <vector>
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+ static int get_nshapes();
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ ~Circle() { };
+ void set_radius( double r );
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ ~Square() { }
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class ShapeContainer {
+private:
+ typedef std::vector<Shape*>::iterator iterator;
+ std::vector<Shape*> shapes;
+public:
+ ShapeContainer() : shapes() {};
+ ~ShapeContainer();
+ void addShape( Shape *s );
+};
diff --git a/trunk/Examples/php/disown/example.i b/trunk/Examples/php/disown/example.i
new file mode 100644
index 000000000..599f162c5
--- /dev/null
+++ b/trunk/Examples/php/disown/example.i
@@ -0,0 +1,12 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%apply SWIGTYPE *DISOWN {(Shape *s)};
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/php/disown/runme.php b/trunk/Examples/php/disown/runme.php
new file mode 100644
index 000000000..d90b03a9d
--- /dev/null
+++ b/trunk/Examples/php/disown/runme.php
@@ -0,0 +1,49 @@
+<?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";
+
+# ----- Create the ShapeContainer ----
+
+$container = new ShapeContainer();
+
+$container->addShape($c);
+$container->addShape($s);
+
+# ----- Access a static member -----
+
+print "\nA total of " . Shape::nshapes() . " shapes were created\n";
+
+# ----- Delete by the old references -----
+# This should not truely delete the shapes because they are now owned
+# by the ShapeContainer.
+
+print "Delete the old references.";
+
+# Note: this invokes the virtual destructor
+$c = NULL;
+$s = NULL;
+
+print "\nA total of " . Shape::nshapes() . " shapes remain\n";
+
+# ----- Delete by the container -----
+# This should truely delete the shapes
+
+print "Delete the container.";
+$container = NULL;
+print "\nA total of " . Shape::nshapes() . " shapes remain\n";
+
+print "Goodbye\n";
+
+?>
diff --git a/trunk/Examples/php/enum/Makefile b/trunk/Examples/php/enum/Makefile
new file mode 100644
index 000000000..252a72660
--- /dev/null
+++ b/trunk/Examples/php/enum/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/enum/example.cxx b/trunk/Examples/php/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/enum/example.h b/trunk/Examples/php/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/enum/example.i b/trunk/Examples/php/enum/example.i
new file mode 100644
index 000000000..abf254731
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/enum/runme.php b/trunk/Examples/php/enum/runme.php
new file mode 100644
index 000000000..55b0bc4c3
--- /dev/null
+++ b/trunk/Examples/php/enum/runme.php
@@ -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/trunk/Examples/php/extend/Makefile b/trunk/Examples/php/extend/Makefile
new file mode 100644
index 000000000..42597202b
--- /dev/null
+++ b/trunk/Examples/php/extend/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/extend/example.cxx b/trunk/Examples/php/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/php/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/php/extend/example.h b/trunk/Examples/php/extend/example.h
new file mode 100644
index 000000000..b27ab9711
--- /dev/null
+++ b/trunk/Examples/php/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/trunk/Examples/php/extend/example.i b/trunk/Examples/php/extend/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/trunk/Examples/php/extend/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/trunk/Examples/php/extend/index.html b/trunk/Examples/php/extend/index.html
new file mode 100644
index 000000000..32c6a4913
--- /dev/null
+++ b/trunk/Examples/php/extend/index.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>SWIG:Examples:php:extend</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/php/extend/</tt>
+<hr>
+
+<H2>Extending a simple C++ class in PHP</H2>
+
+<p>
+This example illustrates the extending of a C++ class with cross language polymorphism.
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/php/extend/runme.php b/trunk/Examples/php/extend/runme.php
new file mode 100644
index 000000000..158683142
--- /dev/null
+++ b/trunk/Examples/php/extend/runme.php
@@ -0,0 +1,76 @@
+<?php
+
+# This file illustrates the cross language polymorphism using directors.
+
+require("example.php");
+
+# CEO class, which overrides Employee::getPosition().
+
+class CEO extends Manager {
+ function getPosition() {
+ return "CEO";
+ }
+}
+
+# Create an instance of our employee extension class, CEO. The calls to
+# getName() and getPosition() are standard, the call to getTitle() uses
+# the director wrappers to call CEO.getPosition.
+
+$e = new CEO("Alice");
+print $e->getName() . " is a " . $e->getPosition() . "\n";
+printf("Just call her \"%s\"\n", $e->getTitle());
+print "----------------------\n";
+
+# Create a new EmployeeList instance. This class does not have a C++
+# director wrapper, but can be used freely with other classes that do.
+
+$list = new EmployeeList();
+
+# EmployeeList owns its items, so we must surrender ownership of objects
+# we add. This involves first clearing the ->disown member to tell the
+# C++ director to start reference counting.
+
+$e->thisown = 0;
+$list->addEmployee($e);
+print "----------------------\n";
+
+# Now we access the first four items in list (three are C++ objects that
+# EmployeeList's constructor adds, the last is our CEO). The virtual
+# methods of all these instances are treated the same. For items 0, 1, and
+# 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls
+# getPosition which resolves in PHP. The call to getPosition is
+# slightly different, however, from the e.getPosition() call above, since
+# now the object reference has been "laundered" by passing through
+# EmployeeList as an Employee*. Previously, PHP resolved the call
+# immediately in CEO, but now PHP thinks the object is an instance of
+# class Employee (actually EmployeePtr). So the call passes through the
+# Employee proxy class and on to the C wrappers and C++ director,
+# eventually ending up back at the CEO implementation of getPosition().
+# The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+# method, which in turn calls getPosition(). This virtual method call
+# passes down through the C++ director class to the PHP implementation
+# in CEO. All this routing takes place transparently.
+
+print "(position, title) for items 0-3:\n";
+
+printf(" %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle());
+printf(" %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle());
+printf(" %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle());
+printf(" %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle());
+print "----------------------\n";
+
+# Time to delete the EmployeeList, which will delete all the Employee*
+# items it contains. The last item is our CEO, which gets destroyed as its
+# reference count goes to zero. The PHP destructor runs, and is still
+# able to call the getName() method since the underlying C++ object still
+# exists. After this destructor runs the remaining C++ destructors run as
+# usual to destroy the object.
+
+unset($list);
+print "----------------------\n";
+
+# All done.
+
+print "php exit\n";
+
+?>
diff --git a/trunk/Examples/php/funcptr/Makefile b/trunk/Examples/php/funcptr/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/trunk/Examples/php/funcptr/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/funcptr/example.c b/trunk/Examples/php/funcptr/example.c
new file mode 100644
index 000000000..99583b72e
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/funcptr/example.h b/trunk/Examples/php/funcptr/example.h
new file mode 100644
index 000000000..58989db79
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/funcptr/example.i b/trunk/Examples/php/funcptr/example.i
new file mode 100644
index 000000000..39390da27
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/funcptr/runme.php b/trunk/Examples/php/funcptr/runme.php
new file mode 100644
index 000000000..712d4147c
--- /dev/null
+++ b/trunk/Examples/php/funcptr/runme.php
@@ -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/trunk/Examples/php/overloading/Makefile b/trunk/Examples/php/overloading/Makefile
new file mode 100644
index 000000000..1bc0beaab
--- /dev/null
+++ b/trunk/Examples/php/overloading/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/overloading/example.cxx b/trunk/Examples/php/overloading/example.cxx
new file mode 100644
index 000000000..2f684f05c
--- /dev/null
+++ b/trunk/Examples/php/overloading/example.cxx
@@ -0,0 +1,55 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+int Shape::get_nshapes() {
+ return nshapes;
+}
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
+
+const char *overloaded(int i) {
+ return "Overloaded with int";
+}
+
+const char *overloaded(double d) {
+ return "Overloaded with double";
+}
+
+const char *overloaded(const char * str) {
+ return "Overloaded with char *";
+}
+
+const char *overloaded( const Circle& ) {
+ return "Overloaded with Circle";
+}
+
+const char *overloaded( const Shape& ) {
+ return "Overloaded with Shape";
+}
diff --git a/trunk/Examples/php/overloading/example.h b/trunk/Examples/php/overloading/example.h
new file mode 100644
index 000000000..01d71dd70
--- /dev/null
+++ b/trunk/Examples/php/overloading/example.h
@@ -0,0 +1,46 @@
+/* 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;
+ static int get_nshapes();
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { }
+ ~Circle() { }
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { }
+ ~Square() { }
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+const char *overloaded( int i );
+const char *overloaded( double d );
+const char *overloaded( const char * str );
+const char *overloaded( const Circle& );
+const char *overloaded( const Shape& );
+
diff --git a/trunk/Examples/php/overloading/example.i b/trunk/Examples/php/overloading/example.i
new file mode 100644
index 000000000..950d2549d
--- /dev/null
+++ b/trunk/Examples/php/overloading/example.i
@@ -0,0 +1,8 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
diff --git a/trunk/Examples/php/overloading/runme.php b/trunk/Examples/php/overloading/runme.php
new file mode 100644
index 000000000..01044445f
--- /dev/null
+++ b/trunk/Examples/php/overloading/runme.php
@@ -0,0 +1,59 @@
+<?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(1, 2.1, "quick brown fox", $c, $s) as $o) {
+ print " ".get_class($o)." \$o\n";
+ print " overloaded = " . overloaded($o) . "\n";
+ }
+
+# Need to unset($o) or else we hang on to a reference to the Square object.
+unset($o);
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+unset($c);
+$s = 42;
+
+print Shape::nshapes() . " shapes remain\n";
+
+print "Goodbye\n";
+
+?>
diff --git a/trunk/Examples/php/pointer/Makefile b/trunk/Examples/php/pointer/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/trunk/Examples/php/pointer/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/pointer/example.c b/trunk/Examples/php/pointer/example.c
new file mode 100644
index 000000000..3326dec3e
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/pointer/example.i b/trunk/Examples/php/pointer/example.i
new file mode 100644
index 000000000..c14b94189
--- /dev/null
+++ b/trunk/Examples/php/pointer/example.i
@@ -0,0 +1,24 @@
+/* File : example.i */
+%module example
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+%include phppointers.i
+/* First we'll use the pointer library */
+extern void add(double *REF, double *REF, double *REF);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+//%apply int *OUTPUT { int *r };
+//extern int divide(int n, int d, int *r);
+
+
+
+
+
diff --git a/trunk/Examples/php/pointer/runme.php b/trunk/Examples/php/pointer/runme.php
new file mode 100644
index 000000000..5e86de6a2
--- /dev/null
+++ b/trunk/Examples/php/pointer/runme.php
@@ -0,0 +1,35 @@
+<?php
+
+ require "example.php";
+
+ # First create some objects using the pointer library.
+
+ print "Testing the pointer library\n";
+
+ $a = 37.145;
+ $b = 42.555;
+ $c = ""; // $c must be defined and not null.
+
+ print " a = $a\n";
+ print " b = $b\n";
+ print " c = $c\n";
+
+ # Call the add() function wuth some pointers
+ add(&$a,&$b,&$c);
+
+ print " $a + $b = $c\n";
+
+ # 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/trunk/Examples/php/pragmas/Makefile b/trunk/Examples/php/pragmas/Makefile
new file mode 100644
index 000000000..23e2675d7
--- /dev/null
+++ b/trunk/Examples/php/pragmas/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/pragmas/example.i b/trunk/Examples/php/pragmas/example.i
new file mode 100644
index 000000000..c7e8bf303
--- /dev/null
+++ b/trunk/Examples/php/pragmas/example.i
@@ -0,0 +1,31 @@
+/* File : example.i */
+%module example
+
+%init{
+ zend_printf("This was %%init\n");
+}
+
+%minit{
+ zend_printf("This was %%minit\n");
+}
+
+%mshutdown{
+ zend_printf("This was %%shutdown\n");
+}
+
+%rinit{
+ zend_printf("This was %%rinit\n");
+}
+
+%rshutdown{
+ zend_printf("This was %%rshutdown\n");
+}
+
+%pragma(php) include="include.php";
+
+%pragma(php) code="
+# This code is inserted into example.php
+echo \"this was php code\\n\";
+"
+
+%pragma(php) phpinfo="php_info_print_table_start();"
diff --git a/trunk/Examples/php/pragmas/include.php b/trunk/Examples/php/pragmas/include.php
new file mode 100644
index 000000000..e19880a06
--- /dev/null
+++ b/trunk/Examples/php/pragmas/include.php
@@ -0,0 +1,7 @@
+<?php
+
+# This code is inserted into example.php
+echo "this is include.php\n";
+
+
+?>
diff --git a/trunk/Examples/php/pragmas/runme.php b/trunk/Examples/php/pragmas/runme.php
new file mode 100755
index 000000000..538548b6f
--- /dev/null
+++ b/trunk/Examples/php/pragmas/runme.php
@@ -0,0 +1,5 @@
+<?php
+
+require "example.php";
+
+?>
diff --git a/trunk/Examples/php/proxy/Makefile b/trunk/Examples/php/proxy/Makefile
new file mode 100644
index 000000000..1bc0beaab
--- /dev/null
+++ b/trunk/Examples/php/proxy/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/proxy/example.cxx b/trunk/Examples/php/proxy/example.cxx
new file mode 100644
index 000000000..94e4a7888
--- /dev/null
+++ b/trunk/Examples/php/proxy/example.cxx
@@ -0,0 +1,43 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+int Shape::get_nshapes() {
+ return nshapes;
+}
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+void Circle::set_radius( double r ) {
+ radius = r;
+}
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
+
+Circle *CircleFactory( double r ) {
+ return new Circle(r);
+}
diff --git a/trunk/Examples/php/proxy/example.h b/trunk/Examples/php/proxy/example.h
new file mode 100644
index 000000000..361dff898
--- /dev/null
+++ b/trunk/Examples/php/proxy/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;
+ static int get_nshapes();
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ ~Circle() { };
+ void set_radius( double r );
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ ~Square() { }
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+Circle *CircleFactory( double r );
+
diff --git a/trunk/Examples/php/proxy/example.i b/trunk/Examples/php/proxy/example.i
new file mode 100644
index 000000000..ce73746d0
--- /dev/null
+++ b/trunk/Examples/php/proxy/example.i
@@ -0,0 +1,12 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%newobject CircleFactory;
+%include "example.h"
+
diff --git a/trunk/Examples/php/proxy/runme.php b/trunk/Examples/php/proxy/runme.php
new file mode 100644
index 000000000..e70ab229f
--- /dev/null
+++ b/trunk/Examples/php/proxy/runme.php
@@ -0,0 +1,68 @@
+<?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 = example::CircleFactory(10);
+print " Created circle \$c with area ". $c->area() ."\n";
+$s = new Square(10);
+print " Created square \$s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of " . Shape::nshapes() . " shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+$c->x = 20;
+$c->y = 30;
+$s->x = -10;
+$s->y = 5;
+
+print "\nHere is their current position:\n";
+print " Circle = (" . $c->x . "," . $c->y . ")\n";
+print " Square = (" . $s->x . "," . $s->y . ")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach (array($c,$s) as $o) {
+ print " ".get_class($o)." \$o\n";
+ print " x = " . $o->x . "\n";
+ print " y = " . $o->y . "\n";
+ print " area = " . $o->area() . "\n";
+ print " perimeter = " . $o->perimeter() . "\n";
+ }
+
+# Need to unset($o) or else we hang on to a reference to the Square object.
+unset($o);
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+unset($c);
+$s = 42;
+
+print Shape::nshapes() . " shapes remain\n";
+
+print "Manually setting nshapes\n";
+
+Shape::nshapes(42);
+
+print Shape::get_nshapes() ." == 42\n";
+
+print "Goodbye\n";
+
+?>
diff --git a/trunk/Examples/php/reference/Makefile b/trunk/Examples/php/reference/Makefile
new file mode 100644
index 000000000..1bc0beaab
--- /dev/null
+++ b/trunk/Examples/php/reference/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/reference/example.cxx b/trunk/Examples/php/reference/example.cxx
new file mode 100644
index 000000000..13e47eade
--- /dev/null
+++ b/trunk/Examples/php/reference/example.cxx
@@ -0,0 +1,49 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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::as_string() {
+ static char temp[512];
+ sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+ printf("VectorArray new: self=%p\n",this);
+}
+
+VectorArray::~VectorArray() {
+ printf("VectorArray delete: self=%p\n",this);
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ printf("VectorArray: read[%d] self=%p\n",index,this);
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ printf("VectorArray: size %d self=%p\n",maxsize,this);
+ return maxsize;
+}
diff --git a/trunk/Examples/php/reference/example.h b/trunk/Examples/php/reference/example.h
new file mode 100644
index 000000000..1b88cbf5c
--- /dev/null
+++ b/trunk/Examples/php/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 *as_string();
+};
+
+class VectorArray {
+private:
+ Vector *items;
+ int maxsize;
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ Vector &operator[](int);
+ int size();
+};
+
+
+
+
diff --git a/trunk/Examples/php/reference/example.i b/trunk/Examples/php/reference/example.i
new file mode 100644
index 000000000..d6122866b
--- /dev/null
+++ b/trunk/Examples/php/reference/example.i
@@ -0,0 +1,47 @@
+/* File : example.i */
+
+/* This example has nothing to do with references but the name is used by all
+ * the other languages so it's hard to rename to something more meaningful.
+ *
+ * Mostly it shows how to use %extend.
+ */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *as_string();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %extend {
+ Vector &get(int index) {
+ printf("VectorArray extended get: %p %d\n",$self,index);
+ return (*$self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*$self)[index] = a;
+ }
+ }
+};
diff --git a/trunk/Examples/php/reference/runme.php b/trunk/Examples/php/reference/runme.php
new file mode 100644
index 000000000..5d264ee43
--- /dev/null
+++ b/trunk/Examples/php/reference/runme.php
@@ -0,0 +1,49 @@
+<?php
+
+# This file illustrates the manipulation of C++ references in PHP.
+
+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->as_string()}\n";
+print " Created b: {$b->as_string()}\n";
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+print "Adding a+b\n";
+$c = example::addv($a, $b);
+print " a+b ={$c->as_string()}\n";
+
+# ----- Create a vector array -----
+
+print "Creating an array of vectors\n";
+$va = new VectorArray(10);
+
+print " va: size={$va->size()}\n";
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of $a and $b to the vector array
+$va->set(0, $a);
+$va->set(1, $b);
+$va->set(2, addv($a, $b));
+
+# Get some values from the array
+
+print "Getting some array values\n";
+for ($i = 0; $i < 5; $i++) {
+ print " va[$i] = {$va->get($i)->as_string()}\n";
+}
+
+?>
diff --git a/trunk/Examples/php/simple/Makefile b/trunk/Examples/php/simple/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/trunk/Examples/php/simple/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/simple/example.c b/trunk/Examples/php/simple/example.c
new file mode 100644
index 000000000..2fe275632
--- /dev/null
+++ b/trunk/Examples/php/simple/example.c
@@ -0,0 +1,23 @@
+/* File : example.c */
+#include <stdio.h>
+
+/* A global variable */
+double Foo = 3.0;
+
+void print_Foo() {
+ printf("In C, Foo = %f\n",Foo);
+}
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/trunk/Examples/php/simple/example.i b/trunk/Examples/php/simple/example.i
new file mode 100644
index 000000000..af4ff08a7
--- /dev/null
+++ b/trunk/Examples/php/simple/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+ extern double Foo;
+%}
+
+extern double Foo;
+void print_Foo();
+int gcd(int x, int y);
diff --git a/trunk/Examples/php/simple/runme.php b/trunk/Examples/php/simple/runme.php
new file mode 100755
index 000000000..0e96fe800
--- /dev/null
+++ b/trunk/Examples/php/simple/runme.php
@@ -0,0 +1,25 @@
+<?php
+
+require "example.php";
+
+# Call our gcd() function
+
+$x = "42 aaa";
+$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_get() . "\n";
+
+# Change its value
+Foo_set(3.1415926);
+
+# See if the change took effect ( this isn't a good example for php, see
+# manual for why. )
+print "Foo = " . Foo_get() . "\n";
+print_Foo();
+
+?>
diff --git a/trunk/Examples/php/sync/Makefile b/trunk/Examples/php/sync/Makefile
new file mode 100644
index 000000000..1bc0beaab
--- /dev/null
+++ b/trunk/Examples/php/sync/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/sync/example.cxx b/trunk/Examples/php/sync/example.cxx
new file mode 100644
index 000000000..31ed2021b
--- /dev/null
+++ b/trunk/Examples/php/sync/example.cxx
@@ -0,0 +1,13 @@
+#include "example.h"
+#include <stdio.h>
+
+int x = 42;
+char *s = (char *)"Test";
+
+void Sync::printer(void) {
+
+ printf("The value of global s is %s\n", s);
+ printf("The value of global x is %d\n", x);
+ printf("The value of class s is %s\n", s);
+ printf("The value of class x is %d\n", x);
+};
diff --git a/trunk/Examples/php/sync/example.h b/trunk/Examples/php/sync/example.h
new file mode 100644
index 000000000..d67ec21dc
--- /dev/null
+++ b/trunk/Examples/php/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/trunk/Examples/php/sync/example.i b/trunk/Examples/php/sync/example.i
new file mode 100644
index 000000000..17ff87cf3
--- /dev/null
+++ b/trunk/Examples/php/sync/example.i
@@ -0,0 +1,7 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
diff --git a/trunk/Examples/php/sync/runme.php b/trunk/Examples/php/sync/runme.php
new file mode 100644
index 000000000..a7c43474f
--- /dev/null
+++ b/trunk/Examples/php/sync/runme.php
@@ -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/trunk/Examples/php/value/Makefile b/trunk/Examples/php/value/Makefile
new file mode 100644
index 000000000..9e69d00a4
--- /dev/null
+++ b/trunk/Examples/php/value/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT = -noproxy
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/value/example.c b/trunk/Examples/php/value/example.c
new file mode 100644
index 000000000..3c402a214
--- /dev/null
+++ b/trunk/Examples/php/value/example.c
@@ -0,0 +1,13 @@
+/* File : example.c */
+
+#include "example.h"
+
+double dot_product(Vector a, Vector b) {
+ return (a.x*b.x + a.y*b.y + a.z*b.z);
+}
+
+void vector_add(Vector a, Vector b, Vector* result) {
+ result->x = a.x + b.x;
+ result->y = a.y + b.y;
+ result->z = a.z + b.z;
+}
diff --git a/trunk/Examples/php/value/example.h b/trunk/Examples/php/value/example.h
new file mode 100644
index 000000000..f55752a5f
--- /dev/null
+++ b/trunk/Examples/php/value/example.h
@@ -0,0 +1,8 @@
+/* File : example.h */
+
+typedef struct {
+ double x, y, z;
+} Vector;
+
+double dot_product(Vector a, Vector b);
+void vector_add(Vector a, Vector b, Vector* result);
diff --git a/trunk/Examples/php/value/example.i b/trunk/Examples/php/value/example.i
new file mode 100644
index 000000000..386fa3b84
--- /dev/null
+++ b/trunk/Examples/php/value/example.i
@@ -0,0 +1,17 @@
+// Tests SWIG's handling of pass-by-value for complex datatypes
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
+
+/* Some helper functions for our interface */
+%inline %{
+
+void vector_print(Vector *v) {
+ printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+%}
+
diff --git a/trunk/Examples/php/value/runme.php b/trunk/Examples/php/value/runme.php
new file mode 100644
index 000000000..49115376c
--- /dev/null
+++ b/trunk/Examples/php/value/runme.php
@@ -0,0 +1,43 @@
+<?php
+
+ require "example.php";
+
+
+ $v = new_vector();
+ vector_x_set($v,1.0);
+ vector_y_set($v,2.0);
+ vector_z_set($v,3.0);
+
+ $w = new_vector();
+ vector_x_set($w,10.0);
+ vector_y_set($w,11.0);
+ vector_z_set($w,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 = new_vector();
+ vector_add($v, $w, $r);
+
+ 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/trunk/Examples/php/variables/Makefile b/trunk/Examples/php/variables/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/trunk/Examples/php/variables/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/trunk/Examples/php/variables/example.c b/trunk/Examples/php/variables/example.c
new file mode 100644
index 000000000..3114c7c5f
--- /dev/null
+++ b/trunk/Examples/php/variables/example.c
@@ -0,0 +1,95 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[5] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
+ printf("ptptr = %p %s\n", ptptr, Point_print( ptptr ) );
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+int value_int(int *value) {
+ return *value;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/php/variables/example.h b/trunk/Examples/php/variables/example.h
new file mode 100644
index 000000000..3b3659ce5
--- /dev/null
+++ b/trunk/Examples/php/variables/example.h
@@ -0,0 +1,34 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
+/* Some global variable declarations */
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[5];
+
+extern Point *ptptr;
+extern Point pt;
+
+extern int status;
+extern char path[256];
+
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
diff --git a/trunk/Examples/php/variables/example.i b/trunk/Examples/php/variables/example.i
new file mode 100644
index 000000000..3edbb72d7
--- /dev/null
+++ b/trunk/Examples/php/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[5];
+
+extern Point *ptptr;
+extern Point pt;
+
+/* Some read-only variables */
+
+%immutable;
+extern int status;
+extern char path[256];
+%mutable;
+
+/* Some helper functions to make it easier to test */
+extern void print_vars();
+extern int *new_int(int value);
+
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+
+
+
+
diff --git a/trunk/Examples/php/variables/runme.php b/trunk/Examples/php/variables/runme.php
new file mode 100644
index 000000000..bbfeb610b
--- /dev/null
+++ b/trunk/Examples/php/variables/runme.php
@@ -0,0 +1,96 @@
+<?php
+
+ require "example.php";
+ echo "\nVariables (values printed from C)\n";
+
+ print_vars();
+
+ 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";
+
+ /* Try to set the values of some global variables */
+$a = "42.14";
+
+ ivar_set($a);
+echo "a = $a\n";
+ 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");
+ iptrvar_set(new_int(37));
+ ptptr_set(new_point(37,42));
+ name_set("B");
+
+ 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/trunk/Examples/pike/check.list b/trunk/Examples/pike/check.list
new file mode 100644
index 000000000..a8d348bf1
--- /dev/null
+++ b/trunk/Examples/pike/check.list
@@ -0,0 +1,5 @@
+# see top-level Makefile.in
+class
+constants
+enum
+simple
diff --git a/trunk/Examples/pike/class/Makefile b/trunk/Examples/pike/class/Makefile
new file mode 100644
index 000000000..981ccef6f
--- /dev/null
+++ b/trunk/Examples/pike/class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all:
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/pike/class/example.cxx b/trunk/Examples/pike/class/example.cxx
new file mode 100644
index 000000000..c7a3194a4
--- /dev/null
+++ b/trunk/Examples/pike/class/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.c */
+
+#include "example.h"
+
+#include <stdio.h>
+
+#define M_PI 3.14159265358979323846
+
+// Static member initializer
+int Shape::nshapes = 0;
+
+// Constructor
+Shape::Shape() {
+ nshapes++;
+}
+
+// Move the shape to a new location
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+// Destructor
+Shape::~Shape() {
+ nshapes--;
+}
+
+// Circle area
+double Circle::area() const {
+ return M_PI*radius*radius;
+}
+
+// Circle perimeter
+double Circle::perimeter() const {
+ return 2*M_PI*radius;
+}
+
+// Square area
+double Square::area() const {
+ return width*width;
+}
+
+// Square perimeter
+double Square::perimeter() const {
+ return 4*width;
+}
diff --git a/trunk/Examples/pike/class/example.h b/trunk/Examples/pike/class/example.h
new file mode 100644
index 000000000..f74a4fefc
--- /dev/null
+++ b/trunk/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() const = 0;
+ virtual double perimeter() const = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area() const;
+ virtual double perimeter() const;
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area() const;
+ virtual double perimeter() const;
+};
+
+
+
+
+
diff --git a/trunk/Examples/pike/class/example.i b/trunk/Examples/pike/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/class/runme.pike b/trunk/Examples/pike/class/runme.pike
new file mode 100755
index 000000000..a6377600e
--- /dev/null
+++ b/trunk/Examples/pike/class/runme.pike
@@ -0,0 +1,53 @@
+import .example;
+
+int main()
+{
+ // ----- Object creation -----
+
+ write("Creating some objects:\n");
+ Circle c = Circle(10.0);
+ write(" Created circle.\n");
+ Square s = Square(10.0);
+ write(" Created square.\n");
+
+ // ----- Access a static member -----
+
+ write("\nA total of " + Shape_nshapes_get() + " shapes were created\n");
+
+ // ----- Member data access -----
+
+ // Set the location of the object
+
+ c->x_set(20.0);
+ c->y_set(30.0);
+
+ s->x_set(-10.0);
+ s->y_set(5.0);
+
+ write("\nHere is their current position:\n");
+ write(" Circle = (%f, %f)\n", c->x_get(), c->y_get());
+ write(" Square = (%f, %f)\n", s->x_get(), s->y_get());
+
+ // ----- Call some methods -----
+
+ write("\nHere are some properties of the shapes:\n");
+ write(" The circle:\n");
+ write(" area = %f.\n", c->area());
+ write(" perimeter = %f.\n", c->perimeter());
+ write(" The square:\n");
+ write(" area = %f.\n", s->area());
+ write(" perimeter = %f.\n", s->perimeter());
+
+ write("\nGuess I'll clean up now\n");
+
+ /* See if we can force 's' to be garbage-collected */
+ s = 0;
+
+ /* Now we should be down to only 1 shape */
+ write("%d shapes remain\n", Shape_nshapes_get());
+
+ /* Done */
+ write("Goodbye\n");
+
+ return 0;
+}
diff --git a/trunk/Examples/pike/constants/Makefile b/trunk/Examples/pike/constants/Makefile
new file mode 100644
index 000000000..7fa493851
--- /dev/null
+++ b/trunk/Examples/pike/constants/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/pike/constants/example.i b/trunk/Examples/pike/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/constants/runme.pike b/trunk/Examples/pike/constants/runme.pike
new file mode 100755
index 000000000..a8d9f944f
--- /dev/null
+++ b/trunk/Examples/pike/constants/runme.pike
@@ -0,0 +1,24 @@
+int main()
+{
+ write("ICONST = %d (should be 42)\n", .example.ICONST);
+ write("FCONST = %f (should be 2.1828)\n", .example.FCONST);
+ write("CCONST = %c (should be 'x')\n", .example.CCONST);
+ write("CCONST2 = %c (this should be on a new line)\n", .example.CCONST2);
+ write("SCONST = %s (should be 'Hello World')\n", .example.SCONST);
+ write("SCONST2 = %s (should be '\"Hello World\"')\n", .example.SCONST2);
+ write("EXPR = %f (should be 48.5484)\n", .example.EXPR);
+ write("iconst = %d (should be 37)\n", .example.iconst);
+ write("fconst = %f (should be 3.14)\n", .example.fconst);
+
+ if (search(indices(.example), "EXTERN") == -1)
+ write("EXTERN isn't defined (good)\n");
+ else
+ write("EXTERN is defined (bad)\n");
+
+ if (search(indices(.example), "FOO") == -1)
+ write("FOO isn't defined (good)\n");
+ else
+ write("FOO is defined (bad)\n");
+
+ return 0;
+}
diff --git a/trunk/Examples/pike/enum/Makefile b/trunk/Examples/pike/enum/Makefile
new file mode 100644
index 000000000..0ae102156
--- /dev/null
+++ b/trunk/Examples/pike/enum/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/pike/enum/README b/trunk/Examples/pike/enum/README
new file mode 100644
index 000000000..055aa9fce
--- /dev/null
+++ b/trunk/Examples/pike/enum/README
@@ -0,0 +1,13 @@
+This example will not compile with Pike versions 7.4.20 unless you first
+patch the Pike sources. The problem is for line 91 of Pike's "stralloc.h"
+(usually installed as /usr/local/pike/7.4.10/include/pike/stralloc.h). That
+line reads:
+
+ tmp.ptr=ptr;
+
+but should be patched to read:
+
+ tmp.ptr=(p_wchar0 *) ptr;
+
+This bug has been reported to the Pike developers.
+
diff --git a/trunk/Examples/pike/enum/example.cxx b/trunk/Examples/pike/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/enum/example.h b/trunk/Examples/pike/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/enum/example.i b/trunk/Examples/pike/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/enum/runme.pike b/trunk/Examples/pike/enum/runme.pike
new file mode 100644
index 000000000..4846356b3
--- /dev/null
+++ b/trunk/Examples/pike/enum/runme.pike
@@ -0,0 +1,28 @@
+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);
+ .example.enum_test(1234, 5678);
+
+ write("\nTesting use of enum with class method\n");
+ .example.Foo f = .example.Foo();
+
+ f->enum_test(.example.Foo.IMPULSE);
+ f->enum_test(.example.Foo.WARP);
+ f->enum_test(.example.Foo.LUDICROUS);
+
+ return 0;
+}
diff --git a/trunk/Examples/pike/overload/Makefile b/trunk/Examples/pike/overload/Makefile
new file mode 100644
index 000000000..60af005b1
--- /dev/null
+++ b/trunk/Examples/pike/overload/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/pike/overload/example.cxx b/trunk/Examples/pike/overload/example.cxx
new file mode 100644
index 000000000..3760fdd49
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/overload/example.h b/trunk/Examples/pike/overload/example.h
new file mode 100644
index 000000000..e47a122ee
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/overload/example.i b/trunk/Examples/pike/overload/example.i
new file mode 100644
index 000000000..ddcd006be
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/overload/runme.pike b/trunk/Examples/pike/overload/runme.pike
new file mode 100644
index 000000000..d30e947b3
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/simple/Makefile b/trunk/Examples/pike/simple/Makefile
new file mode 100644
index 000000000..544c97b5d
--- /dev/null
+++ b/trunk/Examples/pike/simple/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all:
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/pike/simple/example.c b/trunk/Examples/pike/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/simple/example.i b/trunk/Examples/pike/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/pike/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/pike/simple/runme.pike b/trunk/Examples/pike/simple/runme.pike
new file mode 100644
index 000000000..a6a78e9e7
--- /dev/null
+++ b/trunk/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("The gcd of %d and %d is %d\n", x, y, g);
+
+ /* Manipulate the Foo global variable */
+ /* Output its current value */
+ write("Foo = %f\n", .example->Foo_get());
+
+ /* Change its value */
+ .example->Foo_set(3.1415926);
+
+ /* See if the change took effect */
+ write("Foo = %f\n", .example->Foo_get());
+
+ return 0;
+}
diff --git a/trunk/Examples/pike/template/Makefile b/trunk/Examples/pike/template/Makefile
new file mode 100644
index 000000000..b3f012927
--- /dev/null
+++ b/trunk/Examples/pike/template/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all:
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/pike/template/example.h b/trunk/Examples/pike/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/template/example.i b/trunk/Examples/pike/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/trunk/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/trunk/Examples/pike/template/runme.pike b/trunk/Examples/pike/template/runme.pike
new file mode 100755
index 000000000..36825c3e3
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/callback/Makefile b/trunk/Examples/python/callback/Makefile
new file mode 100644
index 000000000..a29276e58
--- /dev/null
+++ b/trunk/Examples/python/callback/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/callback/example.cxx b/trunk/Examples/python/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/python/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/python/callback/example.h b/trunk/Examples/python/callback/example.h
new file mode 100644
index 000000000..2a0194999
--- /dev/null
+++ b/trunk/Examples/python/callback/example.h
@@ -0,0 +1,22 @@
+/* File : example.h */
+
+#include <iostream>
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/trunk/Examples/python/callback/example.i b/trunk/Examples/python/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/trunk/Examples/python/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/trunk/Examples/python/callback/index.html b/trunk/Examples/python/callback/index.html
new file mode 100644
index 000000000..e2017eca3
--- /dev/null
+++ b/trunk/Examples/python/callback/index.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>SWIG:Examples:python:callback</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/extend/</tt>
+<hr>
+
+<H2>Implementing C++ callbacks in Python</H2>
+
+<p>
+This example illustrates how to use directors to implement C++ callbacks in Python.
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/python/callback/runme.py b/trunk/Examples/python/callback/runme.py
new file mode 100644
index 000000000..026e9520b
--- /dev/null
+++ b/trunk/Examples/python/callback/runme.py
@@ -0,0 +1,56 @@
+# file: runme.py
+
+# This file illustrates the cross language polymorphism using directors.
+
+import example
+
+
+class PyCallback(example.Callback):
+ def __init__(self):
+ example.Callback.__init__(self)
+ def run(self):
+ print "PyCallback.run()"
+
+# Create an Caller instance
+
+caller = example.Caller()
+
+# Add a simple C++ callback (caller owns the callback, so
+# we disown it first by clearing the .thisown flag).
+
+print "Adding and calling a normal C++ callback"
+print "----------------------------------------"
+
+callback = example.Callback()
+callback.thisown = 0
+caller.setCallback(callback)
+caller.call()
+caller.delCallback();
+
+print
+print "Adding and calling a Python callback"
+print "------------------------------------"
+
+# Add a Python callback (caller owns the callback, so we
+# disown it first by calling __disown__).
+
+caller.setCallback(PyCallback().__disown__())
+caller.call()
+caller.delCallback()
+
+print
+print "Adding and calling another Python callback"
+print "------------------------------------------"
+
+# Lets do the same but use the weak reference this time.
+
+callback = PyCallback().__disown__()
+caller.setCallback(callback)
+caller.call()
+caller.delCallback()
+
+# All done.
+
+print
+print "python exit"
+
diff --git a/trunk/Examples/python/check.list b/trunk/Examples/python/check.list
new file mode 100644
index 000000000..7cfe437f0
--- /dev/null
+++ b/trunk/Examples/python/check.list
@@ -0,0 +1,29 @@
+# see top-level Makefile.in
+callback
+class
+constants
+contract
+docstrings
+enum
+exception
+exceptproxy
+extend
+funcptr
+funcptr2
+functor
+import
+import_template
+java
+#libffi
+multimap
+operator
+pointer
+reference
+simple
+smartptr
+std_vector
+std_map
+swigrun
+template
+varargs
+variables
diff --git a/trunk/Examples/python/class/Makefile b/trunk/Examples/python/class/Makefile
new file mode 100644
index 000000000..74625b992
--- /dev/null
+++ b/trunk/Examples/python/class/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/class/example.cxx b/trunk/Examples/python/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/class/example.dsp b/trunk/Examples/python/class/example.dsp
new file mode 100644
index 000000000..fd7bf8c06
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/class/example.h b/trunk/Examples/python/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/class/example.i b/trunk/Examples/python/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/class/index.html b/trunk/Examples/python/class/index.html
new file mode 100644
index 000000000..12c5eded1
--- /dev/null
+++ b/trunk/Examples/python/class/index.html
@@ -0,0 +1,216 @@
+<html>
+<head>
+<title>SWIG:Examples:python:class</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/class/</tt>
+<hr>
+
+<H2>Wrapping a simple C++ class</H2>
+
+<p>
+This example illustrates the most primitive form of C++ class wrapping performed
+by SWIG. In this case, C++ classes are simply transformed into a collection of
+C-style functions that provide access to class members.
+
+<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++ -python example.i
+</pre>
+</blockquote>
+
+<h2>A sample Python script</h2>
+
+Click <a href="example.py">here</a> to see a script that calls the C++ functions from Python.
+
+<h2>Key points</h2>
+
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+c = example.new_Circle(10.0)
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, a pair of accessor functions are used.
+For example:
+
+<blockquote>
+<pre>
+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 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
+
+<blockquote>
+<pre>
+print "The area is ", example.Shape_area(c)
+</pre>
+</blockquote>
+
+<p>
+<li>Type checking knows about the inheritance structure of C++. For example:
+
+<blockquote>
+<pre>
+example.Shape_area(c) # Works (c is a Shape)
+example.Circle_area(c) # Works (c is a Circle)
+example.Square_area(c) # Fails (c is definitely not a Square)
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a destructor, simply do this
+
+<blockquote>
+<pre>
+example.delete_Shape(c) # Deletes a shape
+</pre>
+</blockquote>
+
+(Note: destructors are currently not inherited. This might change later).
+
+<p>
+<li>Static member variables are wrapped as C global variables. For example:
+
+<blockquote>
+<pre>
+n = example.cvar.Shape_nshapes # Get a static data member
+example.cvar.Shapes_nshapes = 13 # Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+
+<h2>General Comments</h2>
+
+<ul>
+<li>This low-level interface is not the only way to handle C++ code.
+Proxy 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.
+
+<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).
+
+<p>
+<li>Dave's snide remark: Like a large bottle of strong Tequilla, it's better to
+use C++ in moderation.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/python/class/runme.py b/trunk/Examples/python/class/runme.py
new file mode 100644
index 000000000..f1272ae81
--- /dev/null
+++ b/trunk/Examples/python/class/runme.py
@@ -0,0 +1,51 @@
+# file: runme.py
+
+# This file illustrates the proxy class C++ interface generated
+# by SWIG.
+
+import example
+
+# ----- Object creation -----
+
+print "Creating some objects:"
+c = example.Circle(10)
+print " Created circle", c
+s = example.Square(10)
+print " Created square", s
+
+# ----- Access a static member -----
+
+print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print "\nHere is their current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+print " Square = (%f, %f)" % (s.x,s.y)
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:"
+for o in [c,s]:
+ print " ", o
+ print " area = ", o.area()
+ print " perimeter = ", o.perimeter()
+
+print "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print example.cvar.Shape_nshapes,"shapes remain"
+print "Goodbye"
+
diff --git a/trunk/Examples/python/constants/Makefile b/trunk/Examples/python/constants/Makefile
new file mode 100644
index 000000000..1420b4e0b
--- /dev/null
+++ b/trunk/Examples/python/constants/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/constants/example.i b/trunk/Examples/python/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/constants/index.html b/trunk/Examples/python/constants/index.html
new file mode 100644
index 000000000..35cc0d7e6
--- /dev/null
+++ b/trunk/Examples/python/constants/index.html
@@ -0,0 +1,67 @@
+<html>
+<head>
+<title>SWIG:Examples:python:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/python/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<p>
+When SWIG encounters C preprocessor macros and C declarations that look like constants,
+it creates Python variables 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 Python</h2>
+
+Click <a href="example.py">here</a> to see a script 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 Python 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 Python strings.
+<li>C string literals such as "Hello World" are converted into Python 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 Python constants.
+<li>The Python variables that SWIG creates are not protected from modification. For example,
+even if you had this:
+<blockquote>
+<pre>
+#define FOO 73
+</pre>
+</blockquote>
+a user could come along in a script and type
+<blockquote>
+<pre>
+example.FOO = 13
+</pre>
+</blockquote>
+Unfortunately, there's no easy way to prevent this.
+
+<p>
+<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/trunk/Examples/python/constants/runme.py b/trunk/Examples/python/constants/runme.py
new file mode 100644
index 000000000..8d25b878b
--- /dev/null
+++ b/trunk/Examples/python/constants/runme.py
@@ -0,0 +1,27 @@
+# file: runme.py
+
+import example
+
+print "ICONST =", example.ICONST, "(should be 42)"
+print "FCONST =", example.FCONST, "(should be 2.1828)"
+print "CCONST =", example.CCONST, "(should be 'x')"
+print "CCONST2 =", example.CCONST2, "(this should be on a new line)"
+print "SCONST =", example.SCONST, "(should be 'Hello World')"
+print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')"
+print "EXPR =", example.EXPR, "(should be 48.5484)"
+print "iconst =", example.iconst, "(should be 37)"
+print "fconst =", example.fconst, "(should be 3.14)"
+
+try:
+ print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)"
+except AttributeError:
+ print "EXTERN isn't defined (good)"
+
+try:
+ print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
+except AttributeError:
+ print "FOO isn't defined (good)"
+
+
+
+
diff --git a/trunk/Examples/python/contract/Makefile b/trunk/Examples/python/contract/Makefile
new file mode 100644
index 000000000..77fe94b1a
--- /dev/null
+++ b/trunk/Examples/python/contract/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/contract/example.c b/trunk/Examples/python/contract/example.c
new file mode 100644
index 000000000..1a644543f
--- /dev/null
+++ b/trunk/Examples/python/contract/example.c
@@ -0,0 +1,23 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+int fact(int n) {
+ if (n <= 0) return 1;
+ return n*fact(n-1);
+}
+
+
diff --git a/trunk/Examples/python/contract/example.dsp b/trunk/Examples/python/contract/example.dsp
new file mode 100644
index 000000000..32845e0e8
--- /dev/null
+++ b/trunk/Examples/python/contract/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/contract/example.i b/trunk/Examples/python/contract/example.i
new file mode 100644
index 000000000..8fd1a80af
--- /dev/null
+++ b/trunk/Examples/python/contract/example.i
@@ -0,0 +1,21 @@
+/* File : example.i */
+%module example
+
+%contract gcd(int x, int y) {
+require:
+ x >= 0;
+ y >= 0;
+}
+
+%contract fact(int n) {
+require:
+ n >= 0;
+ensure:
+ fact >= 1;
+}
+
+%inline %{
+extern int gcd(int x, int y);
+extern int fact(int n);
+extern double Foo;
+%}
diff --git a/trunk/Examples/python/contract/runme.py b/trunk/Examples/python/contract/runme.py
new file mode 100644
index 000000000..d484ae916
--- /dev/null
+++ b/trunk/Examples/python/contract/runme.py
@@ -0,0 +1,30 @@
+# file: runme.py
+
+import example
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = example.gcd(x,y)
+print "The gcd of %d and %d is %d" % (x,y,g)
+
+# Manipulate the Foo global variable
+
+# Output its current value
+print "Foo = ", example.cvar.Foo
+
+# Change its value
+example.cvar.Foo = 3.1415926
+
+# See if the change took effect
+print "Foo = ", example.cvar.Foo
+
+
+
+
+
+
+
+
+
diff --git a/trunk/Examples/python/docstrings/Makefile b/trunk/Examples/python/docstrings/Makefile
new file mode 100644
index 000000000..f25450cac
--- /dev/null
+++ b/trunk/Examples/python/docstrings/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT = -O
+
+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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/docstrings/example.cxx b/trunk/Examples/python/docstrings/example.cxx
new file mode 100644
index 000000000..93e65421c
--- /dev/null
+++ b/trunk/Examples/python/docstrings/example.cxx
@@ -0,0 +1,4 @@
+#include "example.h"
+
+void Foo::bar() {}
+
diff --git a/trunk/Examples/python/docstrings/example.h b/trunk/Examples/python/docstrings/example.h
new file mode 100644
index 000000000..f44dbc4d3
--- /dev/null
+++ b/trunk/Examples/python/docstrings/example.h
@@ -0,0 +1,4 @@
+class Foo {
+ public:
+ void bar();
+};
diff --git a/trunk/Examples/python/docstrings/example.i b/trunk/Examples/python/docstrings/example.i
new file mode 100644
index 000000000..15e08e641
--- /dev/null
+++ b/trunk/Examples/python/docstrings/example.i
@@ -0,0 +1,14 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* %feature("docstring") has to come before the declaration of the method to
+ * SWIG. */
+%feature("docstring") Foo::bar "No comment"
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/trunk/Examples/python/docstrings/runme.py b/trunk/Examples/python/docstrings/runme.py
new file mode 100644
index 000000000..b6c95e613
--- /dev/null
+++ b/trunk/Examples/python/docstrings/runme.py
@@ -0,0 +1,6 @@
+# file: runme.py
+
+import example
+
+print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"
+
diff --git a/trunk/Examples/python/enum/Makefile b/trunk/Examples/python/enum/Makefile
new file mode 100644
index 000000000..74625b992
--- /dev/null
+++ b/trunk/Examples/python/enum/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/enum/example.cxx b/trunk/Examples/python/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/enum/example.h b/trunk/Examples/python/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/enum/example.i b/trunk/Examples/python/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/enum/index.html b/trunk/Examples/python/enum/index.html
new file mode 100644
index 000000000..776030ffa
--- /dev/null
+++ b/trunk/Examples/python/enum/index.html
@@ -0,0 +1,35 @@
+<html>
+<head>
+<title>SWIG:Examples:python:enum</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/enum/</tt>
+<hr>
+
+<H2>Wrapping enumerations</H2>
+
+<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="example.py">example.py</a>. Sample Python script.
+</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/trunk/Examples/python/enum/runme.py b/trunk/Examples/python/enum/runme.py
new file mode 100644
index 000000000..10c4a260d
--- /dev/null
+++ b/trunk/Examples/python/enum/runme.py
@@ -0,0 +1,31 @@
+# file: runme.py
+
+import example
+
+# ----- Object creation -----
+
+# Print out the value of some enums
+print "*** color ***"
+print " RED =", example.RED
+print " BLUE =", example.BLUE
+print " GREEN =", example.GREEN
+
+print "\n*** Foo::speed ***"
+print " Foo_IMPULSE =", example.Foo.IMPULSE
+print " Foo_WARP =", example.Foo.WARP
+print " Foo_LUDICROUS =", example.Foo.LUDICROUS
+
+print "\nTesting use of enums with functions\n"
+
+example.enum_test(example.RED, example.Foo.IMPULSE)
+example.enum_test(example.BLUE, example.Foo.WARP)
+example.enum_test(example.GREEN, example.Foo.LUDICROUS)
+example.enum_test(1234,5678)
+
+print "\nTesting use of enum with class method"
+f = example.Foo()
+
+f.enum_test(example.Foo.IMPULSE)
+f.enum_test(example.Foo.WARP)
+f.enum_test(example.Foo.LUDICROUS)
+
diff --git a/trunk/Examples/python/exception/Makefile b/trunk/Examples/python/exception/Makefile
new file mode 100644
index 000000000..7dbdde944
--- /dev/null
+++ b/trunk/Examples/python/exception/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/exception/example.h b/trunk/Examples/python/exception/example.h
new file mode 100644
index 000000000..8f9a977b0
--- /dev/null
+++ b/trunk/Examples/python/exception/example.h
@@ -0,0 +1,53 @@
+/* File : example.h */
+
+#include <string>
+#ifndef SWIG
+struct A {
+};
+#endif
+
+class Exc {
+public:
+ Exc(int c, const char *m) {
+ code = c;
+ strncpy(msg,m,256);
+ }
+ int code;
+ char msg[256];
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+class Test {
+public:
+ int simple() throw(int) {
+ throw(37);
+ return 1;
+ }
+ int message() throw(const char *) {
+ throw("I died.");
+ return 1;
+ }
+ int hosed() throw(Exc) {
+ throw(Exc(42,"Hosed"));
+ return 1;
+ }
+ int unknown() throw(A*) {
+ static A a;
+ throw &a;
+ return 1;
+ }
+ int multi(int x) throw(int, const char *, Exc) {
+ if (x == 1) throw(37);
+ if (x == 2) throw("Bleah!");
+ if (x == 3) throw(Exc(42,"No-go-diggy-die"));
+ return 1;
+ }
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
diff --git a/trunk/Examples/python/exception/example.i b/trunk/Examples/python/exception/example.i
new file mode 100644
index 000000000..08672c3a8
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/exception/runme.py b/trunk/Examples/python/exception/runme.py
new file mode 100644
index 000000000..718707861
--- /dev/null
+++ b/trunk/Examples/python/exception/runme.py
@@ -0,0 +1,36 @@
+# file: runme.py
+
+# Throw a lot of exceptions
+
+import example
+
+t = example.Test()
+try:
+ t.unknown()
+except RuntimeError,e:
+ print "incomplete type", e.args[0]
+
+try:
+ t.simple()
+except RuntimeError,e:
+ print e.args[0]
+
+try:
+ t.message()
+except RuntimeError,e:
+ print e.args[0]
+
+try:
+ t.hosed()
+except example.Exc,e:
+ print e.code, e.msg
+
+for i in range(1,4):
+ try:
+ t.multi(i)
+ except RuntimeError,e:
+ print e.args[0]
+ except example.Exc,e:
+ print e.code, e.msg
+
+
diff --git a/trunk/Examples/python/exceptproxy/Makefile b/trunk/Examples/python/exceptproxy/Makefile
new file mode 100644
index 000000000..ba5c79827
--- /dev/null
+++ b/trunk/Examples/python/exceptproxy/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/exceptproxy/example.h b/trunk/Examples/python/exceptproxy/example.h
new file mode 100644
index 000000000..ec7107a5e
--- /dev/null
+++ b/trunk/Examples/python/exceptproxy/example.h
@@ -0,0 +1,54 @@
+/* File : example.h */
+
+// A simple exception
+class EmptyError { };
+class FullError {
+ public:
+ int maxsize;
+ FullError(int m) : maxsize(m) { }
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+template<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() {
+ T x;
+ if (nitems == 0) throw EmptyError();
+ x = items[(last + maxsize - nitems) % maxsize];
+ nitems--;
+ return x;
+ }
+ int length() {
+ return nitems;
+ }
+};
+
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
diff --git a/trunk/Examples/python/exceptproxy/example.i b/trunk/Examples/python/exceptproxy/example.i
new file mode 100644
index 000000000..4a1e0bae9
--- /dev/null
+++ b/trunk/Examples/python/exceptproxy/example.i
@@ -0,0 +1,114 @@
+/* This is a rather sophisticated example that illustrates exception handling,
+ templates, and proxy classes.
+
+ (i) The %exception directive is used to attach exception handlers
+ to specific methods.
+
+ (ii) Exception classes are automatically converted to proxy class
+ objects.
+
+ (iii) The %template directive is used to expand the templates
+*/
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Define some exception handlers for specific methods. In
+ the header file, the enqueue method throws FullError and
+ the dequeue method throws EmptyError. Since we don't
+ want to define an exception handler for everything, we
+ simply write a handler each method individually.
+
+ Note: the *::enqueue syntax means that we simply define
+ the handler for any class with this method defined.
+*/
+
+/*
+ First we need to 'disable' the default swig throw mechanism for the
+ FullError class. We do this by rethrowing the exception.
+
+ Note that this is necessary since the class appears in a throw
+ declaration:
+
+
+ void enqueue(T x) throw(FullError);
+
+ hence, swig recognizes it as an exception class and it will generate
+ the necessary code to catch it and rethrow it to the python side.
+
+*/
+%typemap(throws) FullError "(void)$1; throw;";
+
+
+%exception *::enqueue {
+ try {
+ $action
+ } catch(FullError& e) {
+ FullError *ecopy = new FullError(e);
+ PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_FullError, 1);
+ PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_FullError), err);
+ SWIG_fail;
+ }
+}
+
+/* Some notes about the code above:
+
+ (0) $action gets replaced with the actual method call.
+
+ (1) We are going to return a copy of the exception object (FullError)
+ to pass back to the Python interpreter. This is why the copy
+ constructor is being called.
+
+ (2) The SWIG_NewPointerObj() call automatically wraps the exception object
+ into a proxy class. The SWIGTYPE_p_FullError is the type-descriptor
+ used for type checking. The "1" indicates that Python will have
+ ownership of the resulting object.
+
+ (3) The PyErr_SetObject call sets the Python exception. However,
+ the SWIGTYPE_p_FullError->clientdata reference may not be
+ obvious. This is actually the Python proxy class object
+ for FullError. Recall that in Python, exceptions are defined
+ as classes. Therefore, this works perfectly as the argument to
+ PyErr_SetObject()! A neat trick perhaps.
+*/
+
+/*
+ Now, the EmpytError doesn't appear in a throw declaration, and hence
+ we need to 'mark' it as an exception class. In python, classes that
+ are used as exception are 'special', and need to be wrapped as
+ 'classic' ones.
+
+ This is a python issue, and if you don't mark the class, you will
+ see 'interesting' behaviours at the python side.
+
+
+*/
+%exceptionclass EmptyError;
+%exceptionclass FullError;
+
+%exception *::dequeue {
+ try {
+ $action
+ } catch(EmptyError& e) {
+ EmptyError *ecopy = new EmptyError(e);
+ PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_EmptyError, 1);
+ PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_EmptyError), err);
+ SWIG_fail;
+ }
+}
+
+/* Grab the original header file */
+%include "example.h"
+
+/* Instantiate a few templates */
+
+%template(intQueue) Queue<int>;
+%template(doubleQueue) Queue<double>;
+
+
+
+
+
diff --git a/trunk/Examples/python/exceptproxy/runme.py b/trunk/Examples/python/exceptproxy/runme.py
new file mode 100644
index 000000000..a2ae55584
--- /dev/null
+++ b/trunk/Examples/python/exceptproxy/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/trunk/Examples/python/extend/Makefile b/trunk/Examples/python/extend/Makefile
new file mode 100644
index 000000000..a29276e58
--- /dev/null
+++ b/trunk/Examples/python/extend/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/extend/example.cxx b/trunk/Examples/python/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/trunk/Examples/python/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/trunk/Examples/python/extend/example.h b/trunk/Examples/python/extend/example.h
new file mode 100644
index 000000000..b27ab9711
--- /dev/null
+++ b/trunk/Examples/python/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/trunk/Examples/python/extend/example.i b/trunk/Examples/python/extend/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/trunk/Examples/python/extend/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/trunk/Examples/python/extend/index.html b/trunk/Examples/python/extend/index.html
new file mode 100644
index 000000000..959e8c63b
--- /dev/null
+++ b/trunk/Examples/python/extend/index.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>SWIG:Examples:python:extend</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/extend/</tt>
+<hr>
+
+<H2>Extending a simple C++ class in Python</H2>
+
+<p>
+This example illustrates the extending of a C++ class with cross language polymorphism.
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/python/extend/runme.py b/trunk/Examples/python/extend/runme.py
new file mode 100644
index 000000000..240b09894
--- /dev/null
+++ b/trunk/Examples/python/extend/runme.py
@@ -0,0 +1,81 @@
+# file: runme.py
+
+# This file illustrates the cross language polymorphism using directors.
+
+import example
+
+
+# CEO class, which overrides Employee::getPosition().
+
+class CEO(example.Manager):
+ def __init__(self, name):
+ example.Manager.__init__(self, name)
+ def getPosition(self):
+ return "CEO"
+
+
+# Create an instance of our employee extension class, CEO. The calls to
+# getName() and getPosition() are standard, the call to getTitle() uses
+# the director wrappers to call CEO.getPosition. e = CEO("Alice")
+
+e = CEO("Alice")
+print e.getName(), "is a", e.getPosition()
+print "Just call her \"%s\"" % e.getTitle()
+print "----------------------"
+
+
+# Create a new EmployeeList instance. This class does not have a C++
+# director wrapper, but can be used freely with other classes that do.
+
+list = example.EmployeeList()
+
+# EmployeeList owns its items, so we must surrender ownership of objects
+# we add. This involves first calling the __disown__ method to tell the
+# C++ director to start reference counting. We reassign the resulting
+# weakref.proxy to e so that no hard references remain. This can also be
+# done when the object is constructed, as in: e =
+# CEO("Alice").__disown__()
+
+e = e.__disown__()
+list.addEmployee(e)
+print "----------------------"
+
+# Now we access the first four items in list (three are C++ objects that
+# EmployeeList's constructor adds, the last is our CEO). The virtual
+# methods of all these instances are treated the same. For items 0, 1, and
+# 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls
+# getPosition which resolves in Python. The call to getPosition is
+# slightly different, however, from the e.getPosition() call above, since
+# now the object reference has been "laundered" by passing through
+# EmployeeList as an Employee*. Previously, Python resolved the call
+# immediately in CEO, but now Python thinks the object is an instance of
+# class Employee (actually EmployeePtr). So the call passes through the
+# Employee proxy class and on to the C wrappers and C++ director,
+# eventually ending up back at the CEO implementation of getPosition().
+# The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+# method, which in turn calls getPosition(). This virtual method call
+# passes down through the C++ director class to the Python implementation
+# in CEO. All this routing takes place transparently.
+
+print "(position, title) for items 0-3:"
+
+print " %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle())
+print " %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle())
+print " %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle())
+print " %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle())
+print "----------------------"
+
+# Time to delete the EmployeeList, which will delete all the Employee*
+# items it contains. The last item is our CEO, which gets destroyed as its
+# reference count goes to zero. The Python destructor runs, and is still
+# able to call self.getName() since the underlying C++ object still
+# exists. After this destructor runs the remaining C++ destructors run as
+# usual to destroy the object.
+
+del list
+print "----------------------"
+
+# All done.
+
+print "python exit"
+
diff --git a/trunk/Examples/python/funcptr/Makefile b/trunk/Examples/python/funcptr/Makefile
new file mode 100644
index 000000000..0f4a1e077
--- /dev/null
+++ b/trunk/Examples/python/funcptr/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/funcptr/example.c b/trunk/Examples/python/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/funcptr/example.h b/trunk/Examples/python/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/python/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/python/funcptr/example.i b/trunk/Examples/python/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/funcptr/index.html b/trunk/Examples/python/funcptr/index.html
new file mode 100644
index 000000000..e41e0db45
--- /dev/null
+++ b/trunk/Examples/python/funcptr/index.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<title>SWIG:Examples:python:funcptr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/funcptr/</tt>
+<hr>
+
+<H2>Pointers to Functions</H2>
+
+<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 script,
+you will need to pass some kind of C function pointer object. In C,
+this is easy, you just supply a function name as an argument like this:
+
+<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 script, you would do this:
+
+<blockquote>
+<pre>
+r = do_op(x,y, ADD)
+</pre>
+</blockquote>
+
+<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="example.py">example.py</a> (Sample script)
+</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 Python function object in as a substitute for a C
+function pointer.
+
+<p>
+<li>A python function can be used as a C/C++ callback if you write some
+clever typemaps and are very careful about how you create your extension.
+This is an advanced topic not covered here.
+</ul>
+
+<hr>
+</body>
+</html>
+
+
+
+
diff --git a/trunk/Examples/python/funcptr/runme.py b/trunk/Examples/python/funcptr/runme.py
new file mode 100644
index 000000000..bce065057
--- /dev/null
+++ b/trunk/Examples/python/funcptr/runme.py
@@ -0,0 +1,20 @@
+# file: runme.py
+
+import example
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+print "Trying some C callback functions"
+print " a =", a
+print " b =", b
+print " ADD(a,b) =", example.do_op(a,b,example.ADD)
+print " SUB(a,b) =", example.do_op(a,b,example.SUB)
+print " MUL(a,b) =", example.do_op(a,b,example.MUL)
+
+print "Here is what the C callback function objects look like in Python"
+print " ADD =", example.ADD
+print " SUB =", example.SUB
+print " MUL =", example.MUL
diff --git a/trunk/Examples/python/funcptr2/Makefile b/trunk/Examples/python/funcptr2/Makefile
new file mode 100644
index 000000000..0f4a1e077
--- /dev/null
+++ b/trunk/Examples/python/funcptr2/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/funcptr2/example.c b/trunk/Examples/python/funcptr2/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/funcptr2/example.h b/trunk/Examples/python/funcptr2/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/python/funcptr2/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/python/funcptr2/example.i b/trunk/Examples/python/funcptr2/example.i
new file mode 100644
index 000000000..681775a3e
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/funcptr2/runme.py b/trunk/Examples/python/funcptr2/runme.py
new file mode 100644
index 000000000..bd58fb620
--- /dev/null
+++ b/trunk/Examples/python/funcptr2/runme.py
@@ -0,0 +1,24 @@
+# file: runme.py
+
+import example
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+print "Trying some C callback functions"
+print " a =", a
+print " b =", b
+print " ADD(a,b) =", example.do_op(a,b,example.ADD)
+print " SUB(a,b) =", example.do_op(a,b,example.SUB)
+print " MUL(a,b) =", example.do_op(a,b,example.MUL)
+
+print "Here is what the C callback function objects look like in Python"
+print " ADD =", example.ADD
+print " SUB =", example.SUB
+print " MUL =", example.MUL
+
+print "Call the functions directly..."
+print " add(a,b) =", example.add(a,b)
+print " sub(a,b) =", example.sub(a,b)
diff --git a/trunk/Examples/python/functor/Makefile b/trunk/Examples/python/functor/Makefile
new file mode 100644
index 000000000..fe389757a
--- /dev/null
+++ b/trunk/Examples/python/functor/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/functor/example.i b/trunk/Examples/python/functor/example.i
new file mode 100644
index 000000000..2fd38176f
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/functor/runme.py b/trunk/Examples/python/functor/runme.py
new file mode 100644
index 000000000..8fc0f2ff2
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import/Makefile b/trunk/Examples/python/import/Makefile
new file mode 100644
index 000000000..74d4f88cf
--- /dev/null
+++ b/trunk/Examples/python/import/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ @rm -f foo.py bar.py spam.py base.py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/import/README b/trunk/Examples/python/import/README
new file mode 100644
index 000000000..5679dbb7f
--- /dev/null
+++ b/trunk/Examples/python/import/README
@@ -0,0 +1,39 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'python runme.py' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
+Windows:
+--------
+- Use the Visual C++ 6 workspace file (example.dsw). Build the runtime
+ project DLL first followed by the other 4 DLLs as they all have a
+ dependency on the runtime DLL. The Batch build option in the Build menu
+ is usually the easiest way to do this. Only use the Release builds not
+ the Debug builds.
+- Run the test as described above
+
diff --git a/trunk/Examples/python/import/bar.dsp b/trunk/Examples/python/import/bar.dsp
new file mode 100644
index 000000000..17b05cc39
--- /dev/null
+++ b/trunk/Examples/python/import/bar.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=bar - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_bar.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_bar.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "bar - Win32 Debug"
+# Name "bar - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\bar_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\bar.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\bar.i
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/import/bar.h b/trunk/Examples/python/import/bar.h
new file mode 100644
index 000000000..fa4185f1f
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import/bar.i b/trunk/Examples/python/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/trunk/Examples/python/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/trunk/Examples/python/import/base.dsp b/trunk/Examples/python/import/base.dsp
new file mode 100644
index 000000000..2bc9736d1
--- /dev/null
+++ b/trunk/Examples/python/import/base.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=base - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_base.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_base.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "base - Win32 Debug"
+# Name "base - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\base_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\base.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\base.i
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/import/base.h b/trunk/Examples/python/import/base.h
new file mode 100644
index 000000000..5a266f68c
--- /dev/null
+++ b/trunk/Examples/python/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/trunk/Examples/python/import/base.i b/trunk/Examples/python/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/trunk/Examples/python/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/trunk/Examples/python/import/example.dsw b/trunk/Examples/python/import/example.dsw
new file mode 100644
index 000000000..d395d464b
--- /dev/null
+++ b/trunk/Examples/python/import/example.dsw
@@ -0,0 +1,65 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "bar"=.\bar.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "base"=.\base.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "foo"=.\foo.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "spam"=.\spam.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/trunk/Examples/python/import/foo.dsp b/trunk/Examples/python/import/foo.dsp
new file mode 100644
index 000000000..9a92c4b85
--- /dev/null
+++ b/trunk/Examples/python/import/foo.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=foo - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_foo.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_foo.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "foo - Win32 Debug"
+# Name "foo - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\foo_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\foo.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\foo.i
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/import/foo.h b/trunk/Examples/python/import/foo.h
new file mode 100644
index 000000000..dd5184031
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import/foo.i b/trunk/Examples/python/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/trunk/Examples/python/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/trunk/Examples/python/import/runme.py b/trunk/Examples/python/import/runme.py
new file mode 100644
index 000000000..6b800ecb8
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import/spam.dsp b/trunk/Examples/python/import/spam.dsp
new file mode 100644
index 000000000..0a6595bfe
--- /dev/null
+++ b/trunk/Examples/python/import/spam.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=spam - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_spam.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_spam.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "spam - Win32 Debug"
+# Name "spam - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\spam_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\spam.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\spam.i
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/import/spam.h b/trunk/Examples/python/import/spam.h
new file mode 100644
index 000000000..b4e7a2646
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import/spam.i b/trunk/Examples/python/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/trunk/Examples/python/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/trunk/Examples/python/import_template/Makefile b/trunk/Examples/python/import_template/Makefile
new file mode 100644
index 000000000..ee47e994d
--- /dev/null
+++ b/trunk/Examples/python/import_template/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ @rm -f foo.py bar.py spam.py base.py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/import_template/README b/trunk/Examples/python/import_template/README
new file mode 100644
index 000000000..f8cf02dc7
--- /dev/null
+++ b/trunk/Examples/python/import_template/README
@@ -0,0 +1,30 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'python runme.py' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
diff --git a/trunk/Examples/python/import_template/bar.h b/trunk/Examples/python/import_template/bar.h
new file mode 100644
index 000000000..500b67a3c
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/bar.i b/trunk/Examples/python/import_template/bar.i
new file mode 100644
index 000000000..155c08d34
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/base.h b/trunk/Examples/python/import_template/base.h
new file mode 100644
index 000000000..c755a6f9d
--- /dev/null
+++ b/trunk/Examples/python/import_template/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+template<class T> class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base<T> *toBase() {
+ return static_cast<Base<T> *>(this);
+ }
+};
+
+
diff --git a/trunk/Examples/python/import_template/base.i b/trunk/Examples/python/import_template/base.i
new file mode 100644
index 000000000..a6da06339
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/foo.h b/trunk/Examples/python/import_template/foo.h
new file mode 100644
index 000000000..3df13d20d
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/foo.i b/trunk/Examples/python/import_template/foo.i
new file mode 100644
index 000000000..e271672cd
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/runme.py b/trunk/Examples/python/import_template/runme.py
new file mode 100644
index 000000000..0d5aded14
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/spam.h b/trunk/Examples/python/import_template/spam.h
new file mode 100644
index 000000000..c72f49a32
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/import_template/spam.i b/trunk/Examples/python/import_template/spam.i
new file mode 100644
index 000000000..dd94b0350
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/index.html b/trunk/Examples/python/index.html
new file mode 100644
index 000000000..8443a85e1
--- /dev/null
+++ b/trunk/Examples/python/index.html
@@ -0,0 +1,112 @@
+<html>
+<head>
+<title>SWIG:Examples:python</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Python Examples</H1>
+
+<p>
+The following examples illustrate the use of SWIG with Python.
+
+<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="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 from Python.
+<li><a href="value/index.html">value</a>. How to pass and return structures by value.
+<li><a href="class/index.html">class</a>. Wrapping 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="funcptr/index.html">funcptr</a>. Pointers to functions.
+</ul>
+
+<h2>Compilation Issues</h2>
+
+<ul>
+<li>To create a Python extension, SWIG is run with the following options:
+
+<blockquote>
+<pre>
+% swig -python interface.i
+</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>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):
+
+<blockquote>
+<pre>
+% swig -python interface.i
+% gcc -fpic -c interface_wrap.c -I/usr/local/include/python1.5
+% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so
+% python
+Python 1.5.2 (#3, Oct 9 1999, 22:09:34) [GCC 2.95.1 19990816 (release)] on linux2
+Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
+&gt;&gt;&gt; import interface
+&gt;&gt;&gt; interface.blah(...)
+...
+</pre>
+</blockquote>
+
+<li>The politically "correct" way to compile a Python extension is to follow the steps
+described at <a href="http://www.python.org/doc/current/ext/building-on-unix.html">www.python.org</a>
+or in the most excellent (and shamelessly plugged) <a href="http://islab.cs.uchicago.edu/python">Python Essential Reference</a>:
+
+<p>
+<ol>
+<li>Create a file called <tt>Setup</tt> that looks like the following where $(SRCS) is filled
+in with any other source files you need to build the extension:
+
+<blockquote>
+<pre>
+*shared*
+interface interface_wrap.c $(SRCS)
+</pre>
+</blockquote>
+<li>Copy the file <tt>Makefile.pre.in</tt> from the Python distribution. Usually it's located
+in the directory <tt>/usr/local/lib/python1.5/config</tt> on a Unix machine.
+
+<p>
+<li>Type the following to build the extension:
+
+<blockquote>
+<pre>
+% make -f Makefile.pre.in boot
+% make
+</pre>
+</blockquote>
+<li> And that's it. If you are preparing an extension for distribution, you may want
+to look at the <a href="http://www.python.org/sigs/distutils-sig/">distutils</a>.
+</ol>
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Linux
+<li>Solaris
+</ul>
+
+All of the examples were last tested with the following configuration (9/1/2000):
+
+<ul>
+<li>Sparc Solaris 2.8.
+<li>gcc-2.95.2
+<li>Python 1.6b1.
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
+</body>
+</html>
+
+
diff --git a/trunk/Examples/python/java/Example.java b/trunk/Examples/python/java/Example.java
new file mode 100644
index 000000000..91ddb1ac5
--- /dev/null
+++ b/trunk/Examples/python/java/Example.java
@@ -0,0 +1,29 @@
+public class Example {
+ public int mPublicInt;
+
+ public Example() {
+ mPublicInt = 0;
+ }
+
+ public Example(int IntVal) {
+ mPublicInt = IntVal;
+ }
+
+
+ public int Add(int a, int b) {
+ return (a+b);
+ }
+
+ public float Add(float a, float b) {
+ return (a+b);
+ }
+
+ public String Add(String a, String b) {
+ return (a+b);
+ }
+
+ public Example Add(Example a, Example b) {
+ return new Example(a.mPublicInt + b.mPublicInt);
+ }
+}
+
diff --git a/trunk/Examples/python/java/Makefile b/trunk/Examples/python/java/Makefile
new file mode 100644
index 000000000..326a4da94
--- /dev/null
+++ b/trunk/Examples/python/java/Makefile
@@ -0,0 +1,25 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all:: Example.class
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+ rm -f *.class Example.h
+
+check: all
+
+
+Example.class: Example.java
+ gcj -fPIC -C -c -g Example.java
+ gcjh Example
+
diff --git a/trunk/Examples/python/java/example.i b/trunk/Examples/python/java/example.i
new file mode 100644
index 000000000..13d5b5e70
--- /dev/null
+++ b/trunk/Examples/python/java/example.i
@@ -0,0 +1,9 @@
+%module example
+%include <cni.i>
+
+%{
+#include "Example.h"
+%}
+
+
+%include Example.h
diff --git a/trunk/Examples/python/java/runme.py b/trunk/Examples/python/java/runme.py
new file mode 100644
index 000000000..0cec8a7cb
--- /dev/null
+++ b/trunk/Examples/python/java/runme.py
@@ -0,0 +1,16 @@
+from example import *
+
+JvCreateJavaVM(None)
+JvAttachCurrentThread(None, None)
+
+e1 = Example(1)
+e2 = Example(2)
+
+print e1.Add(1,2)
+print e1.Add(1.0,2.0)
+e3 = e1.Add(e1,e2)
+print e3.mPublicInt
+
+print e1.Add("1","2")
+
+JvDetachCurrentThread()
diff --git a/trunk/Examples/python/libffi/Makefile b/trunk/Examples/python/libffi/Makefile
new file mode 100644
index 000000000..fafb7de09
--- /dev/null
+++ b/trunk/Examples/python/libffi/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/libffi/example.i b/trunk/Examples/python/libffi/example.i
new file mode 100644
index 000000000..9a29ec04e
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/multimap/Makefile b/trunk/Examples/python/multimap/Makefile
new file mode 100644
index 000000000..0f4a1e077
--- /dev/null
+++ b/trunk/Examples/python/multimap/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/multimap/example.c b/trunk/Examples/python/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/python/multimap/example.dsp b/trunk/Examples/python/multimap/example.dsp
new file mode 100644
index 000000000..32845e0e8
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/multimap/example.i b/trunk/Examples/python/multimap/example.i
new file mode 100644
index 000000000..f1c4d9990
--- /dev/null
+++ b/trunk/Examples/python/multimap/example.i
@@ -0,0 +1,121 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in,fragment="t_output_helper") (int argc, char *argv[]) {
+ int i;
+ if (!PyList_Check($input)) {
+ SWIG_exception(SWIG_ValueError, "Expecting a list");
+ }
+ $1 = PyList_Size($input);
+ if ($1 == 0) {
+ SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ PyObject *s = PyList_GetItem($input,i);
+%#if PY_VERSION_HEX >= 0x03000000
+ if (!PyUnicode_Check(s))
+%#else
+ if (!PyString_Check(s))
+%#endif
+ {
+ free($2);
+ SWIG_exception(SWIG_ValueError, "List items must be strings");
+ }
+%#if PY_VERSION_HEX >= 0x03000000
+ {
+ int l;
+ $2[i] = PyUnicode_AsStringAndSize(s, &l);
+ }
+%#else
+ $2[i] = PyString_AsString(s);
+%#endif
+
+ }
+ $2[i] = 0;
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+
+%#if PY_VERSION_HEX >= 0x03000000
+ if (!PyUnicode_Check($input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ $1 = PyUnicode_AsStringAndSize($input, &$2);
+%#else
+ if (!PyString_Check($input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ $1 = PyString_AsString($input);
+ $2 = PyString_Size($input);
+%#endif
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+/* Since str is modified, we make a copy of the Python object
+ so that we don't violate it's mutability */
+
+%typemap(in) (char *str, int len) {
+%#if PY_VERSION_HEX >= 0x03000000
+ $2 = PyUnicode_GetSize($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,PyUnicode_AsString($input),$2);
+%#else
+ $2 = PyString_Size($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,PyString_AsString($input),$2);
+%#endif
+}
+
+/* Return the mutated string as a new object. The t_output_helper
+ function takes an object and appends it to the output object
+ to create a tuple */
+
+%typemap(argout) (char *str, int len) {
+ PyObject *o;
+%#if PY_VERSION_HEX >= 0x03000000
+ o = PyUnicode_FromStringAndSize($1,$2);
+%#else
+ o = PyString_FromStringAndSize($1,$2);
+%#endif
+ $result = t_output_helper($result,o);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/trunk/Examples/python/multimap/runme.py b/trunk/Examples/python/multimap/runme.py
new file mode 100644
index 000000000..f996ab3ae
--- /dev/null
+++ b/trunk/Examples/python/multimap/runme.py
@@ -0,0 +1,27 @@
+# file: runme.py
+
+import example
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = example.gcd(x,y)
+print "The gcd of %d and %d is %d" % (x,y,g)
+
+# Call the gcdmain() function
+example.gcdmain(["gcdmain","42","105"])
+
+# Call the count function
+print example.count("Hello World", "l")
+
+# Call the capitalize function
+
+print example.capitalize("hello world")
+
+
+
+
+
+
+
diff --git a/trunk/Examples/python/operator/Makefile b/trunk/Examples/python/operator/Makefile
new file mode 100644
index 000000000..fe389757a
--- /dev/null
+++ b/trunk/Examples/python/operator/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/operator/example.h b/trunk/Examples/python/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/operator/example.i b/trunk/Examples/python/operator/example.i
new file mode 100644
index 000000000..e37e76b3e
--- /dev/null
+++ b/trunk/Examples/python/operator/example.i
@@ -0,0 +1,28 @@
+/* File : example.i */
+%module example
+#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
+%{
+#include "example.h"
+%}
+
+/* This header file is a little tough to handle because it has overloaded
+ operators and constructors. We're going to try and deal with that here */
+
+/* This turns the copy constructor in a function ComplexCopy() that can
+ be called */
+
+%rename(ComplexCopy) Complex::Complex(Complex const &);
+
+/* Now grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend Complex {
+ char *__str__() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", $self->re(), $self->im());
+ return temp;
+ }
+};
+
+
diff --git a/trunk/Examples/python/operator/runme.py b/trunk/Examples/python/operator/runme.py
new file mode 100644
index 000000000..3687a38de
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/pointer/Makefile b/trunk/Examples/python/pointer/Makefile
new file mode 100644
index 000000000..0f4a1e077
--- /dev/null
+++ b/trunk/Examples/python/pointer/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/pointer/example.c b/trunk/Examples/python/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/pointer/example.i b/trunk/Examples/python/pointer/example.i
new file mode 100644
index 000000000..a8ac79499
--- /dev/null
+++ b/trunk/Examples/python/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/python/pointer/index.html b/trunk/Examples/python/pointer/index.html
new file mode 100644
index 000000000..b99c8fe4c
--- /dev/null
+++ b/trunk/Examples/python/pointer/index.html
@@ -0,0 +1,171 @@
+<html>
+<head>
+<title>SWIG:Examples:python:pointer</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/python/pointer/</tt>
+<hr>
+
+<H2>Simple Pointer Handling</H2>
+
+<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. The only
+problem is how does one go about creating these objects from a script?
+
+<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>
+
+Now, in a script you would do this:
+
+<blockquote>
+<pre>
+a = new_int(37)
+b = new_int(42)
+c = new_int(0)
+add(a,b,c)
+r = get_int(c);
+print "Result =",r
+delete_int(a)
+delete_int(b)
+delete_int(c)
+</pre>
+</blockquote>
+
+<p>
+<li>Use the SWIG pointer library. For example, in the interface file
+you would do this:
+
+<blockquote>
+<pre>
+%include "pointer.i"
+</pre>
+</blockquote?
+
+and in a script you would do this:
+
+<blockquote>
+<pre>
+a = ptrcreate("int",37)
+b = ptrcreate("int",42)
+c = ptrcreate("int")
+add(a,b,c)
+r = ptrvalue(c)
+print "Result =",r
+ptrfree(a)
+ptrfree(b)
+ptrfree(c)
+</pre>
+</blockquote>
+
+The advantage to using the pointer library is that it unifies some of the helper
+functions behind a common set of names. For example, the same set of functions work
+with int, double, float, and other fundamental types.
+
+<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 script:
+
+<blockquote>
+<pre>
+r = add(37,42)
+print "Result =",r
+</pre>
+</blockquote>
+Needless to say, this is substantially easier.
+
+<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="example.py">example.py</a> (Python Script)
+</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 pointer.i library files can be
+found in the SWIG user manual. The files also contain documentation.
+
+<p>
+<li>The pointer.i library is designed primarily for convenience. If you
+are concerned about performance, you probably want to use a different
+approach.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/python/pointer/runme.py b/trunk/Examples/python/pointer/runme.py
new file mode 100644
index 000000000..e38a306c1
--- /dev/null
+++ b/trunk/Examples/python/pointer/runme.py
@@ -0,0 +1,44 @@
+# file: runme.py
+
+import example;
+
+# First create some objects using the pointer library.
+print "Testing the pointer library";
+a = example.new_intp();
+b = example.new_intp();
+c = example.new_intp();
+example.intp_assign(a,37);
+example.intp_assign(b,42);
+
+print " a =",a
+print " b =",b
+print " c =",c
+
+# Call the add() function with some pointers
+example.add(a,b,c)
+
+# Now get the result
+r = example.intp_value(c)
+print " 37 + 42 =",r
+
+# Clean up the pointers
+example.delete_intp(a)
+example.delete_intp(b)
+example.delete_intp(c)
+
+# Now try the typemap library
+# This should be much easier. Now how it is no longer
+# necessary to manufacture pointers.
+
+print "Trying the typemap library";
+r = example.sub(37,42)
+print " 37 - 42 =",r
+
+# Now try the version with multiple return values
+
+print "Testing multiple return values";
+q,r = example.divide(42,37)
+print " 42/37 = %d remainder %d" % (q,r)
+
+
+
diff --git a/trunk/Examples/python/reference/Makefile b/trunk/Examples/python/reference/Makefile
new file mode 100644
index 000000000..74625b992
--- /dev/null
+++ b/trunk/Examples/python/reference/Makefile
@@ -0,0 +1,21 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/reference/example.cxx b/trunk/Examples/python/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/python/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/python/reference/example.h b/trunk/Examples/python/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/reference/example.i b/trunk/Examples/python/reference/example.i
new file mode 100644
index 000000000..8c95b3213
--- /dev/null
+++ b/trunk/Examples/python/reference/example.i
@@ -0,0 +1,48 @@
+/* File : example.i */
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+%rename(cprint) print;
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *print();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %extend {
+ Vector &get(int index) {
+ return (*$self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*$self)[index] = a;
+ }
+ }
+};
+
+
+
+
diff --git a/trunk/Examples/python/reference/index.html b/trunk/Examples/python/reference/index.html
new file mode 100644
index 000000000..25d40299e
--- /dev/null
+++ b/trunk/Examples/python/reference/index.html
@@ -0,0 +1,147 @@
+<html>
+<head>
+<title>SWIG:Examples:python:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<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 &amp;a, const Vector &amp;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 &amp;a, const Vector &amp;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 &amp;operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &amp;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 &amp;result = self-&gt;get(index);
+ return &amp;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 &amp;get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &amp;a) {
+ (*self)[index] = a;
+ }
+ }
+ ...
+}
+</pre>
+</blockquote>
+
+Click <a href="example.i">here</a> to see a SWIG interface file with these additions.
+
+<h2>Sample Python script</h2>
+
+Click <a href="example.py">here</a> to see a script that manipulates some C++ references.
+
+<h2>Notes:</h2>
+
+<ul>
+<li>C++ references primarily provide notational convenience for C++
+source code. However, Python 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/trunk/Examples/python/reference/runme.py b/trunk/Examples/python/reference/runme.py
new file mode 100644
index 000000000..a1f53368e
--- /dev/null
+++ b/trunk/Examples/python/reference/runme.py
@@ -0,0 +1,63 @@
+# file: runme.py
+
+# This file illustrates the manipulation of C++ references in Python
+
+import example
+
+# ----- Object creation -----
+
+print "Creating some objects:"
+a = example.Vector(3,4,5)
+b = example.Vector(10,11,12)
+
+print " Created",a.cprint()
+print " Created",b.cprint()
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+print "Adding a+b"
+c = example.addv(a,b)
+print " a+b =", c.cprint()
+
+# Note: Unless we free the result, a memory leak will occur
+del c
+
+# ----- Create a vector array -----
+
+# Note: Using the high-level interface here
+print "Creating an array of vectors"
+va = example.VectorArray(10)
+print " va = ",va
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of $a and $b to the vector array
+va.set(0,a)
+va.set(1,b)
+
+va.set(2,example.addv(a,b))
+
+# Get some values from the array
+
+print "Getting some array values"
+for i in range(0,5):
+ print " va(%d) = %s" % (i, va.get(i).cprint())
+
+# Watch under resource meter to check on this
+print "Making sure we don't leak memory."
+for i in xrange(0,1000000):
+ c = va.get(i % 10)
+
+# ----- Clean up -----
+print "Cleaning up"
+
+del va
+del a
+del b
+
diff --git a/trunk/Examples/python/simple/Makefile b/trunk/Examples/python/simple/Makefile
new file mode 100644
index 000000000..0f4a1e077
--- /dev/null
+++ b/trunk/Examples/python/simple/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/simple/example.c b/trunk/Examples/python/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/python/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/trunk/Examples/python/simple/example.dsp b/trunk/Examples/python/simple/example.dsp
new file mode 100644
index 000000000..32845e0e8
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/python/simple/example.i b/trunk/Examples/python/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/python/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/python/simple/index.html b/trunk/Examples/python/simple/index.html
new file mode 100644
index 000000000..dace471a3
--- /dev/null
+++ b/trunk/Examples/python/simple/index.html
@@ -0,0 +1,97 @@
+<html>
+<head>
+<title>SWIG:Examples:python:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/python/simple/</tt>
+<hr>
+
+<H2>Simple Python Example</H2>
+
+<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 &gt; 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/trunk/Examples/python/simple/runme.py b/trunk/Examples/python/simple/runme.py
new file mode 100644
index 000000000..d484ae916
--- /dev/null
+++ b/trunk/Examples/python/simple/runme.py
@@ -0,0 +1,30 @@
+# file: runme.py
+
+import example
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = example.gcd(x,y)
+print "The gcd of %d and %d is %d" % (x,y,g)
+
+# Manipulate the Foo global variable
+
+# Output its current value
+print "Foo = ", example.cvar.Foo
+
+# Change its value
+example.cvar.Foo = 3.1415926
+
+# See if the change took effect
+print "Foo = ", example.cvar.Foo
+
+
+
+
+
+
+
+
+
diff --git a/trunk/Examples/python/smartptr/Makefile b/trunk/Examples/python/smartptr/Makefile
new file mode 100644
index 000000000..f73802a6b
--- /dev/null
+++ b/trunk/Examples/python/smartptr/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/smartptr/example.cxx b/trunk/Examples/python/smartptr/example.cxx
new file mode 100644
index 000000000..92a3add45
--- /dev/null
+++ b/trunk/Examples/python/smartptr/example.cxx
@@ -0,0 +1,31 @@
+/* File : example.c */
+
+#include "example.h"
+#include <math.h>
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/trunk/Examples/python/smartptr/example.h b/trunk/Examples/python/smartptr/example.h
new file mode 100644
index 000000000..c0f9b1d57
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/smartptr/example.i b/trunk/Examples/python/smartptr/example.i
new file mode 100644
index 000000000..83da4f144
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/smartptr/runme.py b/trunk/Examples/python/smartptr/runme.py
new file mode 100644
index 000000000..5ea1fb947
--- /dev/null
+++ b/trunk/Examples/python/smartptr/runme.py
@@ -0,0 +1,55 @@
+# file: runme.py
+
+# This file illustrates the proxy class C++ interface generated
+# by SWIG.
+
+import example
+
+# ----- Object creation -----
+
+print "Creating some objects:"
+cc = example.Circle(10)
+c = example.ShapePtr(cc)
+print " Created circle", c
+ss = example.Square(10)
+s = example.ShapePtr(ss)
+print " Created square", s
+
+# ----- Access a static member -----
+
+print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print "\nHere is their current position:"
+print " Circle = (%f, %f)" % (c.x,c.y)
+print " Square = (%f, %f)" % (s.x,s.y)
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:"
+for o in [c,s]:
+ print " ", o
+ print " area = ", o.area()
+ print " perimeter = ", o.perimeter()
+
+print "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+del c
+del s
+del cc
+del ss
+
+s = 3
+print example.cvar.Shape_nshapes,"shapes remain"
+print "Goodbye"
+
diff --git a/trunk/Examples/python/smartptr/smartptr.h b/trunk/Examples/python/smartptr/smartptr.h
new file mode 100644
index 000000000..2ffa1ca0e
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/std_map/Makefile b/trunk/Examples/python/std_map/Makefile
new file mode 100644
index 000000000..5d13da764
--- /dev/null
+++ b/trunk/Examples/python/std_map/Makefile
@@ -0,0 +1,25 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+
+run:
+ python runme.py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/std_map/example.h b/trunk/Examples/python/std_map/example.h
new file mode 100644
index 000000000..79ccc6478
--- /dev/null
+++ b/trunk/Examples/python/std_map/example.h
@@ -0,0 +1,17 @@
+/* File : example.h */
+
+#include <map>
+#include <string>
+
+template<class Key, class Value>
+std::map<Key,Value> half_map(const std::map<Key,Value>& v) {
+ typedef typename std::map<Key,Value>::const_iterator iter;
+ std::map<Key,Value> w;
+ for (iter i = v.begin(); i != v.end(); ++i) {
+ w[i->first] = (i->second)/2;
+ }
+ return w;
+}
+
+
+
diff --git a/trunk/Examples/python/std_map/example.i b/trunk/Examples/python/std_map/example.i
new file mode 100644
index 000000000..6a7af7108
--- /dev/null
+++ b/trunk/Examples/python/std_map/example.i
@@ -0,0 +1,27 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include std_string.i
+%include std_pair.i
+%include std_map.i
+
+/* instantiate the required template specializations */
+namespace std {
+ /* remember to instantiate the key,value pair! */
+ %template(DoubleMap) map<std::string,double>;
+ %template() map<std::string,int>;
+}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+%template(halfd) half_map<std::string,double>;
+%template(halfi) half_map<std::string,int>;
+
+
+%template() std::pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
+%template(pymap) std::map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
diff --git a/trunk/Examples/python/std_map/runme.py b/trunk/Examples/python/std_map/runme.py
new file mode 100644
index 000000000..b521c9c9c
--- /dev/null
+++ b/trunk/Examples/python/std_map/runme.py
@@ -0,0 +1,82 @@
+# file: runme.py
+
+import example
+
+pmap = example.pymap()
+pmap["hi"] = 1
+pmap["hello"] = 2
+
+
+
+
+dmap = {}
+dmap["hello"] = 1.0
+dmap["hi"] = 2.0
+
+print dmap.items()
+print dmap.keys()
+print dmap.values()
+
+print dmap
+hmap = example.halfd(dmap)
+dmap = hmap
+
+print dmap
+for i in dmap.iterkeys():
+ print "key", i
+
+for i in dmap.itervalues():
+ print "val", i
+
+for k,v in dmap.iteritems():
+ print "item", k,v
+
+dmap = example.DoubleMap()
+dmap["hello"] = 1.0
+dmap["hi"] = 2.0
+
+for i in dmap.iterkeys():
+ print "key", i
+
+for i in dmap.itervalues():
+ print "val", i
+
+for k,v in dmap.iteritems():
+ print "item", k,v
+
+
+print dmap.items()
+print dmap.keys()
+print dmap.values()
+
+hmap = example.halfd(dmap)
+print hmap.keys()
+print hmap.values()
+
+
+
+dmap = {}
+dmap["hello"] = 2
+dmap["hi"] = 4
+
+hmap = example.halfi(dmap)
+print hmap
+print hmap.keys()
+print hmap.values()
+
+
+dmap = hmap
+
+for i in dmap.iterkeys():
+ print "key", i
+
+for i in dmap.itervalues():
+ print "val", i
+
+for i in dmap.iteritems():
+ print "item", i
+
+for k,v in dmap.iteritems():
+ print "item", k,v
+
+print dmap
diff --git a/trunk/Examples/python/std_vector/Makefile b/trunk/Examples/python/std_vector/Makefile
new file mode 100644
index 000000000..ba5c79827
--- /dev/null
+++ b/trunk/Examples/python/std_vector/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/std_vector/example.h b/trunk/Examples/python/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/std_vector/example.i b/trunk/Examples/python/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/std_vector/runme.py b/trunk/Examples/python/std_vector/runme.py
new file mode 100644
index 000000000..d248ccbbb
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/swigrun/Makefile b/trunk/Examples/python/swigrun/Makefile
new file mode 100644
index 000000000..2142be5bb
--- /dev/null
+++ b/trunk/Examples/python/swigrun/Makefile
@@ -0,0 +1,25 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(SWIG) -python -external-runtime
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
+ rm -f swigpyrun.h
+
+check: all
+
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/swigrun/example.cxx b/trunk/Examples/python/swigrun/example.cxx
new file mode 100644
index 000000000..25906a559
--- /dev/null
+++ b/trunk/Examples/python/swigrun/example.cxx
@@ -0,0 +1,20 @@
+/* File : example.cxx */
+
+#include <Python.h>
+#include "swigpyrun.h"
+#include "example.h"
+
+
+Manager* convert_to_Manager(PyObject *py_obj)
+{
+ Manager* c_ptr;
+ swig_type_info *ty = SWIG_TypeQuery("Manager *");
+ printf("manager ty %p \n", ty);
+ if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) {
+ c_ptr = 0;
+ } else {
+ Py_XINCREF(py_obj);
+ }
+ return c_ptr;
+}
+
diff --git a/trunk/Examples/python/swigrun/example.h b/trunk/Examples/python/swigrun/example.h
new file mode 100644
index 000000000..69e6fe4de
--- /dev/null
+++ b/trunk/Examples/python/swigrun/example.h
@@ -0,0 +1,58 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
+Manager* convert_to_Manager(PyObject *obj);
+
diff --git a/trunk/Examples/python/swigrun/example.i b/trunk/Examples/python/swigrun/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/trunk/Examples/python/swigrun/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/trunk/Examples/python/swigrun/runme.py b/trunk/Examples/python/swigrun/runme.py
new file mode 100644
index 000000000..abcd96463
--- /dev/null
+++ b/trunk/Examples/python/swigrun/runme.py
@@ -0,0 +1,28 @@
+# file: runme.py
+
+# This file illustrates the cross language polymorphism using directors.
+
+import example
+
+
+# CEO class, which overrides Employee::getPosition().
+
+class CEO(example.Manager):
+ def __init__(self, name):
+ example.Manager.__init__(self, name)
+ def getPosition(self):
+ return "CEO"
+ def __del__(self):
+ print "CEO.__del__(),", self.getName()
+ # for proxy class extensions that are not "disowned" and
+ # define a __del__ method, it is very important to call the
+ # base class __del__. otherwise the c++ objects will never
+ # be deleted.
+ example.Manager.__del__(self)
+
+
+
+
+e = CEO("Alice")
+m = example.convert_to_Manager(e)
+print m
diff --git a/trunk/Examples/python/template/Makefile b/trunk/Examples/python/template/Makefile
new file mode 100644
index 000000000..ba5c79827
--- /dev/null
+++ b/trunk/Examples/python/template/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/template/example.h b/trunk/Examples/python/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/template/example.i b/trunk/Examples/python/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/template/runme.py b/trunk/Examples/python/template/runme.py
new file mode 100644
index 000000000..05940bc67
--- /dev/null
+++ b/trunk/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/trunk/Examples/python/varargs/Makefile b/trunk/Examples/python/varargs/Makefile
new file mode 100644
index 000000000..1420b4e0b
--- /dev/null
+++ b/trunk/Examples/python/varargs/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/varargs/example.i b/trunk/Examples/python/varargs/example.i
new file mode 100644
index 000000000..6cb88f5f4
--- /dev/null
+++ b/trunk/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(in,numinputs=0) const char *fmt {
+ $1 = "%s";
+}
+#else
+/* An alternative approach using typemaps */
+%typemap(in) (const char *fmt, ...) {
+ $1 = "%s";
+ $2 = (void *) PyString_AsString($input);
+}
+#endif
+
+/* 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/trunk/Examples/python/varargs/runme.py b/trunk/Examples/python/varargs/runme.py
new file mode 100644
index 000000000..a01cb6769
--- /dev/null
+++ b/trunk/Examples/python/varargs/runme.py
@@ -0,0 +1,34 @@
+# file: runme.py
+
+import sys
+import example
+
+# Call printf
+example.printf("Hello World. I'm printf\n")
+
+# Note: We call printf, but use *python* string formatting
+for i in range(0,10):
+ example.printf("i is %d\n" % i)
+
+# This will probably be garbled because %d is interpreted by C
+example.printf("The value is %d\n")
+
+# 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/trunk/Examples/python/variables/Makefile b/trunk/Examples/python/variables/Makefile
new file mode 100644
index 000000000..0f4a1e077
--- /dev/null
+++ b/trunk/Examples/python/variables/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/trunk/Examples/python/variables/example.c b/trunk/Examples/python/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/python/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/python/variables/example.h b/trunk/Examples/python/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/python/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/python/variables/example.i b/trunk/Examples/python/variables/example.i
new file mode 100644
index 000000000..9d0101cb7
--- /dev/null
+++ b/trunk/Examples/python/variables/example.i
@@ -0,0 +1,51 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/python/variables/index.html b/trunk/Examples/python/variables/index.html
new file mode 100644
index 000000000..2940d8a6b
--- /dev/null
+++ b/trunk/Examples/python/variables/index.html
@@ -0,0 +1,100 @@
+<html>
+<head>
+<title>SWIG:Examples:python:variables</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/python/variables/</tt>
+<hr>
+
+<H2>Wrapping C Global Variables</H2>
+
+<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 Python 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 Python</h2>
+
+Before going any further, it is important to understand some important
+differences between C and Python variables. In C, a variable is
+simply a name that refers to a specific location in memory. For
+example, when you declare a global variable '<tt>double a</tt>' you
+know that somewhere in memory, 8 bytes have been set aside to hold a
+<tt>double</tt> and that <tt>a</tt> is bound to this location for the
+life of the program. In Python, variable creation is nothing more
+than a naming operation. For example, when you say '<tt>a = 3</tt>',
+'a' becomes a name that refers to some object '3'. Later on, if you say
+'<tt>a = 7.5</tt>, the name 'a' is bound to an entirely different object
+containing the value '7.5' (the contents of the original object are not
+changed). The end result of this is that a variable in Python can refer
+to a virtually unlimited number of different objects (memory locations)
+over the lifetime of a program.
+
+<p>
+Because of Python's somewhat unusual variable assignment semantics, it is not
+possible to directly link a C global variable into an equivalent Python variable.
+Instead, all C global variables are accessed as attributes of a special object
+called 'cvar'. For example, if you had a global variable
+
+<blockquote>
+<pre>
+double foo;
+</pre>
+</blockquote>
+
+it will be accessed in the Python module as <tt>cvar.foo</tt>. Click
+<a href="example.py">here</a> to see a script 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 Python, 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 Python strings, but
+when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
+<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 scripting interface and resulting memory management
+is much trickier than simply creating a wrapper function.
+<p>
+<li>Because of the potential for a namespace conflict, you should not use
+the <tt>from module import *</tt> statement for a SWIG module with global
+variables. Doing so will cause a collision on the 'cvar' object should
+more than one module be loaded in this manner.
+</ul>
+
+</body>
+</html>
+<hr>
diff --git a/trunk/Examples/python/variables/runme.py b/trunk/Examples/python/variables/runme.py
new file mode 100644
index 000000000..b635b9859
--- /dev/null
+++ b/trunk/Examples/python/variables/runme.py
@@ -0,0 +1,75 @@
+# file: runme.py
+
+import example
+
+# Try to set the values of some global variables
+
+example.cvar.ivar = 42
+example.cvar.svar = -31000
+example.cvar.lvar = 65537
+example.cvar.uivar = 123456
+example.cvar.usvar = 61000
+example.cvar.ulvar = 654321
+example.cvar.scvar = -13
+example.cvar.ucvar = 251
+example.cvar.cvar = "S"
+example.cvar.fvar = 3.14159
+example.cvar.dvar = 2.1828
+example.cvar.strvar = "Hello World"
+example.cvar.iptrvar= example.new_int(37)
+example.cvar.ptptr = example.new_Point(37,42)
+example.cvar.name = "Bill"
+
+# Now print out the values of the variables
+
+print "Variables (values printed from Python)"
+
+print "ivar =", example.cvar.ivar
+print "svar =", example.cvar.svar
+print "lvar =", example.cvar.lvar
+print "uivar =", example.cvar.uivar
+print "usvar =", example.cvar.usvar
+print "ulvar =", example.cvar.ulvar
+print "scvar =", example.cvar.scvar
+print "ucvar =", example.cvar.ucvar
+print "fvar =", example.cvar.fvar
+print "dvar =", example.cvar.dvar
+print "cvar =", example.cvar.cvar
+print "strvar =", example.cvar.strvar
+print "cstrvar =", example.cvar.cstrvar
+print "iptrvar =", example.cvar.iptrvar
+print "name =", example.cvar.name
+print "ptptr =", example.cvar.ptptr, example.Point_print(example.cvar.ptptr)
+print "pt =", example.cvar.pt, example.Point_print(example.cvar.pt)
+
+print "\nVariables (values printed from C)"
+
+example.print_vars()
+
+print "\nNow I'm going to try and modify some read only variables";
+
+print " Tring to set 'path'";
+try:
+ example.cvar.path = "Whoa!"
+ print "Hey, what's going on?!?! This shouldn't work"
+except:
+ print "Good."
+
+print " Trying to set 'status'";
+try:
+ example.cvar.status = 0
+ print "Hey, what's going on?!?! This shouldn't work"
+except:
+ print "Good."
+
+
+print "\nI'm going to try and update a structure variable.\n"
+
+example.cvar.pt = example.cvar.ptptr
+
+print "The new value is"
+example.pt_print()
+print "You should see the value", example.Point_print(example.cvar.ptptr)
+
+
+
diff --git a/trunk/Examples/r/check.list b/trunk/Examples/r/check.list
new file mode 100644
index 000000000..69d56a4f6
--- /dev/null
+++ b/trunk/Examples/r/check.list
@@ -0,0 +1,3 @@
+# see top-level Makefile.in
+class
+simple
diff --git a/trunk/Examples/r/class/Makefile b/trunk/Examples/r/class/Makefile
new file mode 100644
index 000000000..0cd8ed3d3
--- /dev/null
+++ b/trunk/Examples/r/class/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean
+
+check: all
+ R CMD BATCH runme.R
diff --git a/trunk/Examples/r/class/example.cxx b/trunk/Examples/r/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/r/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/trunk/Examples/r/class/example.dsp b/trunk/Examples/r/class/example.dsp
new file mode 100644
index 000000000..b831989cc
--- /dev/null
+++ b/trunk/Examples/r/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 "$(R_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(R_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo R_INCLUDE: %R_INCLUDE%
+ echo R_LIB: %R_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo R_INCLUDE: %R_INCLUDE%
+ echo R_LIB: %R_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/r/class/example.h b/trunk/Examples/r/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/r/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/trunk/Examples/r/class/example.i b/trunk/Examples/r/class/example.i
new file mode 100644
index 000000000..4654d269f
--- /dev/null
+++ b/trunk/Examples/r/class/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%inline %{
+#include "example.h"
+%}
+%include "example.h"
+
+
diff --git a/trunk/Examples/r/class/runme.R b/trunk/Examples/r/class/runme.R
new file mode 100644
index 000000000..4a2028553
--- /dev/null
+++ b/trunk/Examples/r/class/runme.R
@@ -0,0 +1,49 @@
+# This file illustrates the proxy class C++ interface generated
+# by SWIG.
+
+dyn.load(paste("example", .Platform$dynlib.ext, sep=""))
+source("example.R")
+cacheMetaData(1)
+
+# ----- Object creation -----
+
+print("Creating some objects:")
+circle <- Circle(10)
+print (" Created circle")
+square <- Square(10)
+print (" Created square")
+
+# ----- Access a static member -----
+
+sprintf("A total of %d shapes were created", Shape_nshapes())
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+circle$x <- 20
+circle$y <- 30
+
+square$x <- -10
+square$y <- 5
+
+print("Here is their current position:")
+sprintf(" Circle = (%f, %f)", circle$x,circle$y)
+sprintf(" Square = (%f, %f)", square$x,square$y)
+
+# ----- Call some methods -----
+
+print ("Here are some properties of the shapes:")
+
+sapply(c(circle, square),
+ function(o) {
+sprintf(" area = %f perimeter = %f", o$area(), o$perimeter())
+})
+
+print("Guess I'll clean up now")
+delete(circle)
+delete(square)
+
+sprintf("%d shapes remain", Shape_nshapes())
+print ("Goodbye");
+
diff --git a/trunk/Examples/r/simple/Makefile b/trunk/Examples/r/simple/Makefile
new file mode 100644
index 000000000..5ef29565a
--- /dev/null
+++ b/trunk/Examples/r/simple/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean
+
+check: all
+ R CMD BATCH runme.R
diff --git a/trunk/Examples/r/simple/example.c b/trunk/Examples/r/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/r/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/trunk/Examples/r/simple/example.dsp b/trunk/Examples/r/simple/example.dsp
new file mode 100644
index 000000000..356815d19
--- /dev/null
+++ b/trunk/Examples/r/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 "$(R_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(R_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(R_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo R_INCLUDE: %R_INCLUDE%
+ echo R_LIB: %R_LIB%
+ echo on
+ ..\..\..\swig.exe -r $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo R_INCLUDE: %R_INCLUDE%
+ echo R_LIB: %R_LIB%
+ echo on
+ ..\..\..\swig.exe -r $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/r/simple/example.i b/trunk/Examples/r/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/r/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/r/simple/runme.R b/trunk/Examples/r/simple/runme.R
new file mode 100644
index 000000000..783093741
--- /dev/null
+++ b/trunk/Examples/r/simple/runme.R
@@ -0,0 +1,24 @@
+# file: runme.R
+
+dyn.load(paste("example", .Platform$dynlib.ext, sep=""))
+source("example.R")
+cacheMetaData(1)
+
+# Call our gcd() function
+
+x <- 42
+y <- 105
+g <- gcd(x,y)
+sprintf("The gcd of %d and %d is %d", x, y, g)
+
+# Manipulate the Foo global variable
+
+# Output its current value
+Foo()
+
+# Change its value
+Foo(3.1415926)
+
+# See if the change took effect
+Foo()
+
diff --git a/trunk/Examples/ruby/check.list b/trunk/Examples/ruby/check.list
new file mode 100644
index 000000000..131dcbb33
--- /dev/null
+++ b/trunk/Examples/ruby/check.list
@@ -0,0 +1,23 @@
+# see top-level Makefile.in
+class
+constants
+enum
+free_function
+funcptr
+funcptr2
+functor
+hashargs
+import
+import_template
+java
+mark_function
+multimap
+operator
+overloading
+pointer
+reference
+simple
+std_vector
+template
+value
+variables
diff --git a/trunk/Examples/ruby/class/Makefile b/trunk/Examples/ruby/class/Makefile
new file mode 100644
index 000000000..56c84c651
--- /dev/null
+++ b/trunk/Examples/ruby/class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/class/example.cxx b/trunk/Examples/ruby/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/class/example.dsp b/trunk/Examples/ruby/class/example.dsp
new file mode 100644
index 000000000..2adab787a
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/class/example.h b/trunk/Examples/ruby/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/class/example.i b/trunk/Examples/ruby/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/class/index.html b/trunk/Examples/ruby/class/index.html
new file mode 100644
index 000000000..67eeac9ad
--- /dev/null
+++ b/trunk/Examples/ruby/class/index.html
@@ -0,0 +1,199 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:class</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/ruby/class/</tt>
+<hr>
+
+<H2>Wrapping a simple C++ class</H2>
+
+<p>
+This example illustrates C++ class wrapping performed by SWIG.
+C++ classes are simply transformed into Ruby classes that provide methods to
+access 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++ -ruby example.i
+</pre>
+</blockquote>
+
+<h2>A sample Ruby script</h2>
+
+Click <a href="runme.rb">here</a> to see a script that calls the C++ functions from Ruby.
+
+<h2>Key points</h2>
+
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+c = Example::Circle.new(10)
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, a pair of accessor methods are used.
+For example:
+
+<blockquote>
+<pre>
+c.x = 15 # Set member data
+x = c.x # Get member data
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a member function, you simply do this
+
+<blockquote>
+<pre>
+print "The area is ", c.area, "\n"
+</pre>
+</blockquote>
+
+<p>
+<li>When a instance of Ruby level wrapper class is garbage collected by
+Ruby interpreter, the corresponding C++ destructor is automatically invoked.
+(Note: destructors are currently not inherited. This might change later.
+Until then, use <tt>-make_default</tt>).
+
+<p>
+<li>Static member variables are wrapped as Ruby class accessor methods.
+For example:
+
+<blockquote>
+<pre>
+n = Shape.nshapes # Get a static data member
+Shapes.nshapes = 13 # Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+
+<h2>General Comments</h2>
+
+<ul>
+<li>Ruby module of SWIG differs from other language modules in wrapping C++
+interfaces. They provides lower-level interfaces and optional higher-level
+interfaces know as proxy classes. Ruby module needs no such redundancy
+due to Ruby's sophisticated extension API.
+
+<p>
+<li>SWIG *does* know how to properly perform upcasting of objects in
+an inheritance hierarchy except for multiple inheritance.
+
+<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>
+<p>
+
+<li>Dave's snide remark: Like a large bottle of strong Tequilla, it's better to
+use C++ in moderation.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/ruby/class/runme.rb b/trunk/Examples/ruby/class/runme.rb
new file mode 100644
index 000000000..de73bcd46
--- /dev/null
+++ b/trunk/Examples/ruby/class/runme.rb
@@ -0,0 +1,49 @@
+# file: runme.rb
+
+# This file illustrates the C++ interface created by SWIG.
+# All of our C++ classes get converted into Ruby classes.
+
+require 'example'
+
+# ----- Object creation -----
+
+print "Creating some objects:\n"
+c = Example::Circle.new(10)
+print " Created circle #{c}\n"
+s = Example::Square.new(10)
+print " Created square #{s}\n"
+
+# ----- Access a static member -----
+
+print "\nA total of #{Example::Shape.nshapes} shapes were created\n"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+# Notice how we can do this using functions specific to
+# the 'Circle' class.
+c.x = 20
+c.y = 30
+
+# Now use the same functions in the base class
+s.x = -10
+s.y = 5
+
+print "\nHere is their current position:\n"
+print " Circle = (", c.x, ",", c.y, ")\n"
+print " Square = (", s.x, ",", s.y, ")\n"
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n"
+for o in [c, s]
+ print " #{o}\n"
+ print " area = ", o.area, "\n"
+ print " perimeter = ", o.perimeter, "\n"
+end
+# Notice how the Shape#area() and Shape#perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+print "\n", Example::Shape.nshapes," shapes remain\n"
+print "Goodbye\n"
diff --git a/trunk/Examples/ruby/constants/Makefile b/trunk/Examples/ruby/constants/Makefile
new file mode 100644
index 000000000..7dce3bee4
--- /dev/null
+++ b/trunk/Examples/ruby/constants/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/constants/example.i b/trunk/Examples/ruby/constants/example.i
new file mode 100644
index 000000000..14eb23cad
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/constants/index.html b/trunk/Examples/ruby/constants/index.html
new file mode 100644
index 000000000..3b63f3d3d
--- /dev/null
+++ b/trunk/Examples/ruby/constants/index.html
@@ -0,0 +1,64 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/ruby/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<p>
+When SWIG encounters C preprocessor macros and C declarations that look like constants,
+it creates Ruby constants 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 Ruby</h2>
+
+Click <a href="run.rb">here</a> to see a script 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 Ruby 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 Ruby strings.
+<li>C string literals such as "Hello World" are converted into Ruby 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 Ruby constants.
+
+<li>Constants that begin with lower case character are automatically capitalized.
+For example:
+<blockquote>
+<pre>
+const int iconst = 37;
+</pre>
+</blockquote>
+is capitalized as <tt>Example::Iconst</tt> because Ruby constants name must begin
+with upper case character.
+
+<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/trunk/Examples/ruby/constants/runme.rb b/trunk/Examples/ruby/constants/runme.rb
new file mode 100755
index 000000000..2a6b5f5e2
--- /dev/null
+++ b/trunk/Examples/ruby/constants/runme.rb
@@ -0,0 +1,25 @@
+# file: runme.rb
+
+require 'example'
+
+print "ICONST = ", Example::ICONST, " (should be 42)\n"
+print "FCONST = ", Example::FCONST, " (should be 2.1828)\n"
+print "CCONST = ", Example::CCONST, " (should be 'x')\n"
+print "CCONST2 = ", Example::CCONST2, " (this should be on a new line)\n"
+print "SCONST = ", Example::SCONST, " (should be 'Hello World')\n"
+print "SCONST2 = ", Example::SCONST2, " (should be '\"Hello World\"')\n"
+print "EXPR = ", Example::EXPR, " (should be 48.5484)\n"
+print "iconst = ", Example::Iconst, " (should be 37)\n"
+print "fconst = ", Example::Fconst, " (should be 3.14)\n"
+
+begin
+ print "EXTERN = ", Example::EXTERN, " (Arg! This shouldn't print anything)\n"
+rescue NameError
+ print "EXTERN isn't defined (good)\n"
+end
+
+begin
+ print "FOO = ", Example::FOO, " (Arg! This shouldn't print anything)\n"
+rescue NameError
+ print "FOO isn't defined (good)\n"
+end
diff --git a/trunk/Examples/ruby/enum/Makefile b/trunk/Examples/ruby/enum/Makefile
new file mode 100644
index 000000000..56c84c651
--- /dev/null
+++ b/trunk/Examples/ruby/enum/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/enum/example.cxx b/trunk/Examples/ruby/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/enum/example.h b/trunk/Examples/ruby/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/enum/example.i b/trunk/Examples/ruby/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/enum/index.html b/trunk/Examples/ruby/enum/index.html
new file mode 100644
index 000000000..d773d9c66
--- /dev/null
+++ b/trunk/Examples/ruby/enum/index.html
@@ -0,0 +1,35 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:enum</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/ruby/enum/</tt>
+<hr>
+
+<H2>Wrapping enumerations</H2>
+
+<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="runme.rb">runme.rb</a>. Sample Ruby script.
+</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/trunk/Examples/ruby/enum/runme.rb b/trunk/Examples/ruby/enum/runme.rb
new file mode 100644
index 000000000..cd6a76ff4
--- /dev/null
+++ b/trunk/Examples/ruby/enum/runme.rb
@@ -0,0 +1,30 @@
+# file: runme.rb
+
+require 'example'
+
+# ----- Object creation -----
+
+# Print out the value of some enums
+print "*** color ***\n"
+print " RED = #{Example::RED}\n"
+print " BLUE = #{Example::BLUE}\n"
+print " GREEN = #{Example::GREEN}\n"
+
+print "\n*** Foo::speed ***\n"
+print " Foo::IMPULSE = #{Example::Foo::IMPULSE}\n"
+print " Foo::WARP = #{Example::Foo::WARP}\n"
+print " Foo::LUDICROUS = #{Example::Foo::LUDICROUS}\n"
+
+print "\nTesting use of enums with functions\n\n"
+
+Example::enum_test(Example::RED, Example::Foo::IMPULSE)
+Example::enum_test(Example::BLUE, Example::Foo::WARP)
+Example::enum_test(Example::GREEN, Example::Foo::LUDICROUS)
+Example::enum_test(1234, 5678)
+
+print "\nTesting use of enum with class method\n"
+f = Example::Foo.new()
+
+f.enum_test(Example::Foo::IMPULSE)
+f.enum_test(Example::Foo::WARP)
+f.enum_test(Example::Foo::LUDICROUS)
diff --git a/trunk/Examples/ruby/exception_class/Makefile b/trunk/Examples/ruby/exception_class/Makefile
new file mode 100644
index 000000000..016a5ade0
--- /dev/null
+++ b/trunk/Examples/ruby/exception_class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/exception_class/example.h b/trunk/Examples/ruby/exception_class/example.h
new file mode 100644
index 000000000..9facde4bd
--- /dev/null
+++ b/trunk/Examples/ruby/exception_class/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() {
+ T x;
+ if (nitems == 0) throw EmptyError();
+ x = items[(last + maxsize - nitems) % maxsize];
+ nitems--;
+ return x;
+ }
+ int length() {
+ return nitems;
+ }
+};
+
+
+
+
+
+
+
diff --git a/trunk/Examples/ruby/exception_class/example.i b/trunk/Examples/ruby/exception_class/example.i
new file mode 100644
index 000000000..5094b7a60
--- /dev/null
+++ b/trunk/Examples/ruby/exception_class/example.i
@@ -0,0 +1,46 @@
+/* This example illustrates the use of the %exceptionclass feature. By
+ default, if a method has a throws specification then SWIG will generate
+ code to catch the exception and pass it on the scripting language.
+
+ If a method does not have a throws specification, but does throw
+ an exception, then the %exceptionclass feature can be used to tell
+ SWIG about the exception class so it can be properly added to Ruby.
+ This is done by making the exception class inherit from rb_eRuntimeError.*/
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+
+/* The EmpytError doesn't appear in a throw declaration, and hence
+ we need to tell SWIG that the dequeue method throws it. This can
+ now be done via the %catchs feature. */
+%catches(EmptyError) *::dequeue();
+
+
+/* What the catches clause is doing under the covers is this:
+
+%exceptionclass EmptyError;
+
+%exception *::dequeue {
+ try {
+ $action
+ } catch(EmptyError& e) {
+ // Create a new instance of the EmptyError, wrap it as a Ruby object that Ruby owns,
+ // and return it as the exception. For this to work EmtpyError must inherit from
+ // a standard Ruby exception class such as rb_eRuntimeError. SWIG automatically does
+ // this when the class is marked as %exceptionclass or is a throws specification.
+ %raise(SWIG_NewPointerObj(new EmptyError(e),SWIGTYPE_p_EmptyError, SWIG_POINTER_OWN),
+ "EmptyError", SWIGTYPE_p_EmptyError);
+ }
+}
+*/
+
+/* Grab the original header file */
+%include "example.h"
+
+/* Instantiate a few templates */
+%template(IntQueue) Queue<int>;
+%template(DoubleQueue) Queue<double>;
diff --git a/trunk/Examples/ruby/exception_class/runme.rb b/trunk/Examples/ruby/exception_class/runme.rb
new file mode 100644
index 000000000..c198c1406
--- /dev/null
+++ b/trunk/Examples/ruby/exception_class/runme.rb
@@ -0,0 +1,45 @@
+require 'example'
+
+q = Example::IntQueue.new(10)
+
+puts "Inserting items into intQueue"
+
+begin
+ 0.upto(100) do |i|
+ q.enqueue(i)
+ end
+rescue Example::FullError => e
+ puts "Maxsize is: #{e.maxsize}"
+end
+
+puts "Removing items"
+
+begin
+ loop do
+ q.dequeue()
+ end
+rescue Example::EmptyError => e
+ ## do nothing
+end
+
+q = Example::DoubleQueue.new(1000)
+
+puts "Inserting items into doubleQueue"
+
+begin
+ 0.upto(100) do |i|
+ q.enqueue(i*1.5)
+ end
+rescue Example::FullError => e
+ puts "Maxsize is: #{e.maxsize}"
+end
+
+puts "Removing items"
+
+begin
+ loop do
+ q.dequeue()
+ end
+rescue Example::EmptyError => e
+ # do nothing
+end
diff --git a/trunk/Examples/ruby/free_function/Makefile b/trunk/Examples/ruby/free_function/Makefile
new file mode 100644
index 000000000..56c84c651
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/free_function/example.cxx b/trunk/Examples/ruby/free_function/example.cxx
new file mode 100644
index 000000000..402a947e9
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/example.cxx
@@ -0,0 +1,67 @@
+#include "example.h"
+
+Animal::Animal(const char* name) : name_(name)
+{
+}
+
+Animal::~Animal()
+{
+}
+
+/* Return the animal's name */
+const char* Animal::get_name() const
+{
+ return name_.c_str();
+}
+
+Zoo::Zoo()
+{
+}
+
+Zoo::~Zoo()
+{
+ IterType iter = this->animals.begin();
+ IterType end = this->animals.end();
+
+ for(; iter != end; ++iter)
+ {
+ Animal* animal = *iter;
+ delete animal;
+ }
+}
+
+/* Create a new animal. */
+Animal* Zoo::create_animal(const char* name)
+{
+ return new Animal(name);
+}
+
+/* Add a new animal to the zoo. */
+void Zoo::add_animal(Animal* animal)
+{
+ animals.push_back(animal);
+}
+
+Animal* Zoo::remove_animal(size_t i)
+{
+ /* Note a production implementation should check
+ for out of range errors. */
+ Animal* result = this->animals[i];
+ IterType iter = this->animals.begin();
+ std::advance(iter, i);
+ this->animals.erase(iter);
+
+ return result;
+}
+
+/* Return the number of animals in the zoo. */
+size_t Zoo::get_num_animals() const
+{
+ return animals.size();
+}
+
+/* Return a pointer to the ith animal */
+Animal* Zoo::get_animal(size_t i) const
+{
+ return animals[i];
+}
diff --git a/trunk/Examples/ruby/free_function/example.dsp b/trunk/Examples/ruby/free_function/example.dsp
new file mode 100644
index 000000000..2adab787a
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/free_function/example.h b/trunk/Examples/ruby/free_function/example.h
new file mode 100644
index 000000000..933bb3645
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/example.h
@@ -0,0 +1,49 @@
+#ifndef _EXAMPLE_H_
+#define _EXAMPLE_H_
+
+#include <vector>
+#include <string>
+
+class Animal
+{
+protected:
+ std::string name_;
+public:
+ // Construct an animal with a name
+ Animal(const char* name);
+
+ // Destruct an animal
+ ~Animal();
+
+ // Return the animal's name
+ const char* get_name() const;
+};
+
+class Zoo
+{
+private:
+ typedef std::vector<Animal*> AnimalsType;
+ typedef AnimalsType::iterator IterType;
+protected:
+ AnimalsType animals;
+public:
+ Zoo();
+ ~Zoo();
+
+ /* Create a new animal */
+ static Animal* create_animal(const char* name);
+
+ /* Add a new animal to the zoo */
+ void add_animal(Animal* animal);
+
+ /* Remove an animal from the zoo */
+ Animal* remove_animal(size_t i);
+
+ /* Return the number of animals in the zoo */
+ size_t get_num_animals() const;
+
+ /* Return a pointer to the ith animal */
+ Animal* get_animal(size_t i) const;
+};
+
+#endif /*_EXAMPLE_H_*/
diff --git a/trunk/Examples/ruby/free_function/example.i b/trunk/Examples/ruby/free_function/example.i
new file mode 100644
index 000000000..a446b3f99
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/example.i
@@ -0,0 +1,41 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Specify that ownership is transferred to the zoo
+ when calling add_animal */
+%apply SWIGTYPE *DISOWN { Animal* animal };
+
+/* Track objects */
+%trackobjects;
+
+/* Specify the mark function */
+%freefunc Zoo "free_Zoo";
+
+%include "example.h"
+
+%header %{
+ static void free_Zoo(void* ptr) {
+ Zoo* zoo = (Zoo*) ptr;
+
+ /* Loop over each object and call SWIG_RubyRemoveTracking */
+ int count = zoo->get_num_animals();
+
+ for(int i = 0; i < count; ++i) {
+ /* Get an animal */
+ Animal* animal = zoo->get_animal(i);
+ /* Unlink the Ruby object from the C++ object */
+ SWIG_RubyUnlinkObjects(animal);
+ /* Now remove the tracking for this animal */
+ SWIG_RubyRemoveTracking(animal);
+ }
+
+ /* Now call SWIG_RubyRemoveTracking for the zoo */
+ SWIG_RubyRemoveTracking(ptr);
+
+ /* Now free the zoo which will free the animals it contains */
+ delete zoo;
+ }
+%}
diff --git a/trunk/Examples/ruby/free_function/runme.rb b/trunk/Examples/ruby/free_function/runme.rb
new file mode 100644
index 000000000..1d88b6f3e
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/runme.rb
@@ -0,0 +1,46 @@
+require 'example'
+
+begin
+ begin
+ # Create an animal and zoo
+ tiger1 = Example::Animal.new("tiger1")
+ zoo = Example::Zoo.new
+
+ # At the animal to the zoo - this will transfer ownership
+ # of the underlying C++ object to the C++ zoo object
+ zoo.add_animal(tiger1)
+
+ # get the id of the tiger
+ id1 = tiger1.object_id
+
+ # Unset the tiger
+ tiger1 = nil
+ end
+
+ # Force a gc
+ GC.start
+
+ # Get the tiger and its id
+ tiger2 = zoo.get_animal(0)
+ id2 = tiger2.object_id
+
+ # The ids should not be the same
+ if id1==id2
+ raise RuntimeError, "Id's should not be the same"
+ end
+
+ zoo = nil
+end
+
+GC.start
+
+# This method is no longer valid since the zoo freed the underlying
+# C++ object
+ok = false
+begin
+ puts tiger2.get_name
+rescue ObjectPreviouslyDeleted => error
+ ok = true
+end
+
+raise(RuntimeError, "Incorrect exception raised - should be ObjectPreviouslyDeleted") unless ok
diff --git a/trunk/Examples/ruby/funcptr/Makefile b/trunk/Examples/ruby/funcptr/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/funcptr/example.c b/trunk/Examples/ruby/funcptr/example.c
new file mode 100644
index 000000000..99583b72e
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/funcptr/example.h b/trunk/Examples/ruby/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/ruby/funcptr/example.i b/trunk/Examples/ruby/funcptr/example.i
new file mode 100644
index 000000000..39390da27
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/funcptr/index.html b/trunk/Examples/ruby/funcptr/index.html
new file mode 100644
index 000000000..980106c5e
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr/index.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:funcptr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/ruby/funcptr/</tt>
+<hr>
+
+<H2>Pointers to Functions</H2>
+
+<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 script,
+you will need to pass some kind of C function pointer object. In C,
+this is easy, you just supply a function name as an argument like this:
+
+<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 script, you would do this:
+
+<blockquote>
+<pre>
+r = do_op(x,y, ADD)
+</pre>
+</blockquote>
+
+<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="runme.rb">runme.rb</a> (Sample script)
+</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 Ruby proc object in as a substitute for a C
+function pointer.
+
+<p>
+<li>A ruby proc can be used as a C/C++ callback if you write some
+clever typemaps and are very careful about how you create your extension.
+This is an advanced topic not covered here.
+</ul>
+
+<hr>
+</body>
+</html>
+
+
+
+
diff --git a/trunk/Examples/ruby/funcptr/runme.rb b/trunk/Examples/ruby/funcptr/runme.rb
new file mode 100644
index 000000000..4a5b01411
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr/runme.rb
@@ -0,0 +1,21 @@
+# file: runme.rb
+
+require 'example'
+
+a = 37
+b = 42
+
+# Now call our C function with a bunch of callbacks
+
+print "Trying some C callback functions\n"
+print " a = #{a}\n"
+print " b = #{b}\n"
+print " ADD(a,b) = ", Example::do_op(a,b,Example::ADD),"\n"
+print " SUB(a,b) = ", Example::do_op(a,b,Example::SUB),"\n"
+print " MUL(a,b) = ", Example::do_op(a,b,Example::MUL),"\n"
+
+print "Here is what the C callback function objects look like in Ruby\n"
+print " ADD = #{Example::ADD}\n"
+print " SUB = #{Example::SUB}\n"
+print " MUL = #{Example::MUL}\n"
+
diff --git a/trunk/Examples/ruby/funcptr2/Makefile b/trunk/Examples/ruby/funcptr2/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr2/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/funcptr2/example.c b/trunk/Examples/ruby/funcptr2/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/funcptr2/example.h b/trunk/Examples/ruby/funcptr2/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr2/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/ruby/funcptr2/example.i b/trunk/Examples/ruby/funcptr2/example.i
new file mode 100644
index 000000000..681775a3e
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/funcptr2/runme.rb b/trunk/Examples/ruby/funcptr2/runme.rb
new file mode 100644
index 000000000..99b984260
--- /dev/null
+++ b/trunk/Examples/ruby/funcptr2/runme.rb
@@ -0,0 +1,22 @@
+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}"
+
+puts "Call the functions directly..."
+puts " add(a,b) = #{Example.add(a,b)}"
+puts " sub(a,b) = #{Example.sub(a,b)}"
diff --git a/trunk/Examples/ruby/functor/Makefile b/trunk/Examples/ruby/functor/Makefile
new file mode 100644
index 000000000..730698d35
--- /dev/null
+++ b/trunk/Examples/ruby/functor/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/ruby/functor/example.i b/trunk/Examples/ruby/functor/example.i
new file mode 100644
index 000000000..903c9786c
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/functor/runme.rb b/trunk/Examples/ruby/functor/runme.rb
new file mode 100644
index 000000000..3f78dcecc
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/hashargs/Makefile b/trunk/Examples/ruby/hashargs/Makefile
new file mode 100644
index 000000000..a2fbbd397
--- /dev/null
+++ b/trunk/Examples/ruby/hashargs/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/ruby/hashargs/example.i b/trunk/Examples/ruby/hashargs/example.i
new file mode 100644
index 000000000..159bbd32a
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/hashargs/runme.rb b/trunk/Examples/ruby/hashargs/runme.rb
new file mode 100755
index 000000000..0b06f6934
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import/Makefile b/trunk/Examples/ruby/import/Makefile
new file mode 100644
index 000000000..acae6e6bf
--- /dev/null
+++ b/trunk/Examples/ruby/import/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/trunk/Examples/ruby/import/README b/trunk/Examples/ruby/import/README
new file mode 100644
index 000000000..c529cd92c
--- /dev/null
+++ b/trunk/Examples/ruby/import/README
@@ -0,0 +1,39 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'ruby runme.rb' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
+Windows:
+--------
+- Use the Visual C++ 6 workspace file (example.dsw). Build the runtime
+ project DLL first followed by the other 4 DLLs as they all have a
+ dependency on the runtime DLL. The Batch build option in the Build menu
+ is usually the easiest way to do this. Only use the Release builds not
+ the Debug builds.
+- Run the test as described above
+
diff --git a/trunk/Examples/ruby/import/bar.dsp b/trunk/Examples/ruby/import/bar.dsp
new file mode 100644
index 000000000..29d9abf2f
--- /dev/null
+++ b/trunk/Examples/ruby/import/bar.dsp
@@ -0,0 +1,146 @@
+# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=bar - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"bar.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "bar - Win32 Debug"
+# Name "bar - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\bar_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\bar.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\bar.i
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/import/bar.h b/trunk/Examples/ruby/import/bar.h
new file mode 100644
index 000000000..1c99f28e6
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import/bar.i b/trunk/Examples/ruby/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/trunk/Examples/ruby/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/trunk/Examples/ruby/import/base.dsp b/trunk/Examples/ruby/import/base.dsp
new file mode 100644
index 000000000..174afef3e
--- /dev/null
+++ b/trunk/Examples/ruby/import/base.dsp
@@ -0,0 +1,146 @@
+# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=base - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"base.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"base.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "base - Win32 Debug"
+# Name "base - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\base_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\base.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\base.i
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/import/base.h b/trunk/Examples/ruby/import/base.h
new file mode 100644
index 000000000..fec0f329c
--- /dev/null
+++ b/trunk/Examples/ruby/import/base.h
@@ -0,0 +1,16 @@
+class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual const char * A() const {
+ return "Base::A";
+ }
+ const char * B() const {
+ return "Base::B";
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/trunk/Examples/ruby/import/base.i b/trunk/Examples/ruby/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/trunk/Examples/ruby/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/trunk/Examples/ruby/import/example.dsw b/trunk/Examples/ruby/import/example.dsw
new file mode 100644
index 000000000..d395d464b
--- /dev/null
+++ b/trunk/Examples/ruby/import/example.dsw
@@ -0,0 +1,65 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "bar"=.\bar.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "base"=.\base.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "foo"=.\foo.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "spam"=.\spam.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/trunk/Examples/ruby/import/foo.dsp b/trunk/Examples/ruby/import/foo.dsp
new file mode 100644
index 000000000..7f4754915
--- /dev/null
+++ b/trunk/Examples/ruby/import/foo.dsp
@@ -0,0 +1,146 @@
+# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=foo - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"foo.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "foo - Win32 Debug"
+# Name "foo - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\foo_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\foo.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\foo.i
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/import/foo.h b/trunk/Examples/ruby/import/foo.h
new file mode 100644
index 000000000..1abe2c0d8
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import/foo.i b/trunk/Examples/ruby/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/trunk/Examples/ruby/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/trunk/Examples/ruby/import/runme.rb b/trunk/Examples/ruby/import/runme.rb
new file mode 100644
index 000000000..32ca482d6
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import/spam.dsp b/trunk/Examples/ruby/import/spam.dsp
new file mode 100644
index 000000000..72729f290
--- /dev/null
+++ b/trunk/Examples/ruby/import/spam.dsp
@@ -0,0 +1,146 @@
+# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=spam - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(RUBY_INCLUDE)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"spam.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "spam - Win32 Debug"
+# Name "spam - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\spam_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\spam.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\spam.i
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/import/spam.h b/trunk/Examples/ruby/import/spam.h
new file mode 100644
index 000000000..57db84563
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import/spam.i b/trunk/Examples/ruby/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/trunk/Examples/ruby/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/trunk/Examples/ruby/import_template/Makefile b/trunk/Examples/ruby/import_template/Makefile
new file mode 100644
index 000000000..acae6e6bf
--- /dev/null
+++ b/trunk/Examples/ruby/import_template/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile ruby_clean
+
+check: all
diff --git a/trunk/Examples/ruby/import_template/README b/trunk/Examples/ruby/import_template/README
new file mode 100644
index 000000000..9170a7ae0
--- /dev/null
+++ b/trunk/Examples/ruby/import_template/README
@@ -0,0 +1,30 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'ruby runme.rb' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
diff --git a/trunk/Examples/ruby/import_template/bar.h b/trunk/Examples/ruby/import_template/bar.h
new file mode 100644
index 000000000..1aa907dfc
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/bar.i b/trunk/Examples/ruby/import_template/bar.i
new file mode 100644
index 000000000..357de0db9
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/base.h b/trunk/Examples/ruby/import_template/base.h
new file mode 100644
index 000000000..e88c440c0
--- /dev/null
+++ b/trunk/Examples/ruby/import_template/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+template<class T> class Base {
+ public:
+ Base() { };
+ virtual ~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/trunk/Examples/ruby/import_template/base.i b/trunk/Examples/ruby/import_template/base.i
new file mode 100644
index 000000000..bcf1a5f7d
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/foo.h b/trunk/Examples/ruby/import_template/foo.h
new file mode 100644
index 000000000..626257462
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/foo.i b/trunk/Examples/ruby/import_template/foo.i
new file mode 100644
index 000000000..37e655ea2
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/runme.rb b/trunk/Examples/ruby/import_template/runme.rb
new file mode 100644
index 000000000..b9ca19f77
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/spam.h b/trunk/Examples/ruby/import_template/spam.h
new file mode 100644
index 000000000..a27b08829
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/import_template/spam.i b/trunk/Examples/ruby/import_template/spam.i
new file mode 100644
index 000000000..ff0ca113e
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/index.html b/trunk/Examples/ruby/index.html
new file mode 100644
index 000000000..f04146e56
--- /dev/null
+++ b/trunk/Examples/ruby/index.html
@@ -0,0 +1,94 @@
+
+<head>
+<title>SWIG:Examples:ruby</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Ruby Examples</H1>
+
+<p>
+The following examples illustrate the use of SWIG with Ruby.
+
+<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="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 from Ruby.
+<li><a href="value/index.html">value</a>. How to pass and return structures by value.
+<li><a href="class/index.html">class</a>. Wrapping 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="funcptr/index.html">funcptr</a>. Pointers to functions.
+<li><a href="enum/index.html">enum</a>. Enumeration.
+</ul>
+
+<h2>Compilation Issues</h2>
+
+<ul>
+<li>To create a Ruby extension, SWIG is run with the following options:
+
+<blockquote>
+<pre>
+% swig -ruby interface.i
+</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>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):
+
+<blockquote>
+<pre>
+% swig -ruby interface.i
+% gcc -fpic -c interface_wrap.c -I/usr/local/lib/ruby/1.4/i686-linux
+% gcc -shared interface_wrap.o $(OBJS) -o interface.so
+% ruby
+require 'interface'
+Interface.blah(...)
+...
+</pre>
+</blockquote>
+
+<li>The politically "correct" way to compile a Ruby extension is to follow the steps
+described <tt>README.EXT</tt> in Ruby distribution:
+
+<p>
+<ol>
+<li>Create a file called <tt>extconf.rb</tt> that looks like the following:
+
+<blockquote>
+<pre>
+require 'mkmf'
+create_makefile('interface')
+</pre>
+</blockquote>
+<li>Type the following to build the extension:
+
+<blockquote>
+<pre>
+% ruby extconf.rb
+% make
+</pre>
+</blockquote>
+</ol>
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Linux
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
+</body>
+</html>
+
+
diff --git a/trunk/Examples/ruby/java/Example.java b/trunk/Examples/ruby/java/Example.java
new file mode 100644
index 000000000..91ddb1ac5
--- /dev/null
+++ b/trunk/Examples/ruby/java/Example.java
@@ -0,0 +1,29 @@
+public class Example {
+ public int mPublicInt;
+
+ public Example() {
+ mPublicInt = 0;
+ }
+
+ public Example(int IntVal) {
+ mPublicInt = IntVal;
+ }
+
+
+ public int Add(int a, int b) {
+ return (a+b);
+ }
+
+ public float Add(float a, float b) {
+ return (a+b);
+ }
+
+ public String Add(String a, String b) {
+ return (a+b);
+ }
+
+ public Example Add(Example a, Example b) {
+ return new Example(a.mPublicInt + b.mPublicInt);
+ }
+}
+
diff --git a/trunk/Examples/ruby/java/Makefile b/trunk/Examples/ruby/java/Makefile
new file mode 100644
index 000000000..e525d88f9
--- /dev/null
+++ b/trunk/Examples/ruby/java/Makefile
@@ -0,0 +1,26 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all:: Example.class
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f *.class Example.h
+
+check: all
+
+run:
+ ruby runme.rb
+
+Example.class: Example.java
+ gcj -fPIC -C -c -g Example.java
+ gcjh Example
+
diff --git a/trunk/Examples/ruby/java/example.i b/trunk/Examples/ruby/java/example.i
new file mode 100644
index 000000000..13d5b5e70
--- /dev/null
+++ b/trunk/Examples/ruby/java/example.i
@@ -0,0 +1,9 @@
+%module example
+%include <cni.i>
+
+%{
+#include "Example.h"
+%}
+
+
+%include Example.h
diff --git a/trunk/Examples/ruby/java/runme.rb b/trunk/Examples/ruby/java/runme.rb
new file mode 100644
index 000000000..fc018b70c
--- /dev/null
+++ b/trunk/Examples/ruby/java/runme.rb
@@ -0,0 +1,18 @@
+require 'example'
+
+Example.JvCreateJavaVM(nil)
+Example.JvAttachCurrentThread(nil, nil)
+
+e1 = Example::Example.new(1)
+e2 = Example::Example.new(2)
+
+print e1.Add(1,2),"\n"
+print e1.Add(1.0,2.0),"\n"
+e3 = e1.Add(e1,e2)
+print e3.mPublicInt,"\n"
+
+
+print e1.Add("1","2"),"\n"
+
+Example.JvDetachCurrentThread()
+
diff --git a/trunk/Examples/ruby/mark_function/Makefile b/trunk/Examples/ruby/mark_function/Makefile
new file mode 100644
index 000000000..56c84c651
--- /dev/null
+++ b/trunk/Examples/ruby/mark_function/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/mark_function/example.cxx b/trunk/Examples/ruby/mark_function/example.cxx
new file mode 100644
index 000000000..504e8fcbe
--- /dev/null
+++ b/trunk/Examples/ruby/mark_function/example.cxx
@@ -0,0 +1,61 @@
+#include "example.h"
+
+Animal::Animal(const char* name) : name_(name)
+{
+}
+
+Animal::~Animal()
+{
+ name_ = "Destroyed";
+}
+
+/* Return the animal's name */
+const char* Animal::get_name() const
+{
+ return name_.c_str();
+}
+
+Zoo::Zoo()
+{
+}
+
+Zoo::~Zoo()
+{
+ return;
+}
+
+/* Create a new animal. */
+Animal* Zoo::create_animal(const char* name)
+{
+ return new Animal(name);
+}
+
+/* Add a new animal to the zoo. */
+void Zoo::add_animal(Animal* animal)
+{
+ animals.push_back(animal);
+}
+
+Animal* Zoo::remove_animal(size_t i)
+{
+ /* Note a production implementation should check
+ for out of range errors. */
+ Animal* result = this->animals[i];
+ IterType iter = this->animals.begin();
+ std::advance(iter, i);
+ this->animals.erase(iter);
+
+ return result;
+}
+
+/* Return the number of animals in the zoo. */
+size_t Zoo::get_num_animals() const
+{
+ return animals.size();
+}
+
+/* Return a pointer to the ith animal */
+Animal* Zoo::get_animal(size_t i) const
+{
+ return animals[i];
+}
diff --git a/trunk/Examples/ruby/mark_function/example.dsp b/trunk/Examples/ruby/mark_function/example.dsp
new file mode 100644
index 000000000..2adab787a
--- /dev/null
+++ b/trunk/Examples/ruby/mark_function/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/mark_function/example.h b/trunk/Examples/ruby/mark_function/example.h
new file mode 100644
index 000000000..933bb3645
--- /dev/null
+++ b/trunk/Examples/ruby/mark_function/example.h
@@ -0,0 +1,49 @@
+#ifndef _EXAMPLE_H_
+#define _EXAMPLE_H_
+
+#include <vector>
+#include <string>
+
+class Animal
+{
+protected:
+ std::string name_;
+public:
+ // Construct an animal with a name
+ Animal(const char* name);
+
+ // Destruct an animal
+ ~Animal();
+
+ // Return the animal's name
+ const char* get_name() const;
+};
+
+class Zoo
+{
+private:
+ typedef std::vector<Animal*> AnimalsType;
+ typedef AnimalsType::iterator IterType;
+protected:
+ AnimalsType animals;
+public:
+ Zoo();
+ ~Zoo();
+
+ /* Create a new animal */
+ static Animal* create_animal(const char* name);
+
+ /* Add a new animal to the zoo */
+ void add_animal(Animal* animal);
+
+ /* Remove an animal from the zoo */
+ Animal* remove_animal(size_t i);
+
+ /* Return the number of animals in the zoo */
+ size_t get_num_animals() const;
+
+ /* Return a pointer to the ith animal */
+ Animal* get_animal(size_t i) const;
+};
+
+#endif /*_EXAMPLE_H_*/
diff --git a/trunk/Examples/ruby/mark_function/example.i b/trunk/Examples/ruby/mark_function/example.i
new file mode 100644
index 000000000..6380fa010
--- /dev/null
+++ b/trunk/Examples/ruby/mark_function/example.i
@@ -0,0 +1,37 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Tell SWIG that create_animal creates a new object */
+%newobject Zoo::create_animal;
+
+/* Keep track of mappings between C/C++ structs/classes
+ and Ruby objects so we can implement a mark function. */
+%trackobjects;
+
+
+/* Specify the mark function */
+%markfunc Zoo "mark_Zoo";
+
+%include "example.h"
+
+%header %{
+ static void mark_Zoo(void* ptr) {
+ Zoo* zoo = (Zoo*) ptr;
+
+ /* Loop over each object and tell the garbage collector
+ that we are holding a reference to them. */
+ int count = zoo->get_num_animals();
+
+ for(int i = 0; i < count; ++i) {
+ Animal* animal = zoo->get_animal(i);
+ VALUE object = SWIG_RubyInstanceFor(animal);
+
+ if (object != Qnil) {
+ rb_gc_mark(object);
+ }
+ }
+ }
+%}
diff --git a/trunk/Examples/ruby/mark_function/runme.rb b/trunk/Examples/ruby/mark_function/runme.rb
new file mode 100644
index 000000000..6d84ee88f
--- /dev/null
+++ b/trunk/Examples/ruby/mark_function/runme.rb
@@ -0,0 +1,23 @@
+require 'example'
+
+# create a zoo
+zoo = Example::Zoo.new
+
+begin
+ # Add in an couple of animals
+ tiger1 = Example::Animal.new("tiger1")
+ zoo.add_animal(tiger1)
+
+ # unset variables to force gc
+ tiger = nil
+end
+
+GC.start
+
+# Now get the tiger again
+tiger2 = zoo.get_animal(0)
+
+# Call a method to verify the animal is still valid and not gc'ed
+if tiger2.get_name != "tiger1"
+ raise RuntimeError, "Wrong animal name"
+end
diff --git a/trunk/Examples/ruby/multimap/Makefile b/trunk/Examples/ruby/multimap/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/multimap/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/multimap/example.c b/trunk/Examples/ruby/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/ruby/multimap/example.dsp b/trunk/Examples/ruby/multimap/example.dsp
new file mode 100644
index 000000000..4888299f5
--- /dev/null
+++ b/trunk/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 "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/multimap/example.i b/trunk/Examples/ruby/multimap/example.i
new file mode 100644
index 000000000..f68422a18
--- /dev/null
+++ b/trunk/Examples/ruby/multimap/example.i
@@ -0,0 +1,92 @@
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+%include typemaps.i
+
+extern int gcd(int x, int y);
+
+%typemap(in) (int argc, char *argv[]) {
+ int i;
+
+ if (TYPE($input) != T_ARRAY) {
+ SWIG_exception(SWIG_ValueError, "Expected an array");
+ }
+ $1 = RARRAY_LEN($input);
+ if ($1 == 0) {
+ SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ VALUE s = rb_ary_entry($input,i);
+ if (TYPE(s) != T_STRING) {
+ free($2);
+ SWIG_exception(SWIG_ValueError, "List items must be strings");
+ }
+ $2[i] = 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_LEN($input);
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len) {
+ char *temp;
+ if (TYPE($input) != T_STRING) {
+ SWIG_exception(SWIG_ValueError,"Expected a string");
+ }
+ temp = STR2CSTR($input);
+ $2 = RSTRING_LEN($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,temp,$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(argout, fragment="output_helper") (char *str, int len) {
+ VALUE o;
+ o = rb_str_new($1,$2);
+ $result = output_helper($result,o);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ }
+}
+
+extern void circle(double cx, double cy);
+
+
diff --git a/trunk/Examples/ruby/multimap/runme.rb b/trunk/Examples/ruby/multimap/runme.rb
new file mode 100755
index 000000000..dde835136
--- /dev/null
+++ b/trunk/Examples/ruby/multimap/runme.rb
@@ -0,0 +1,22 @@
+# file: runme.rb
+
+require 'example'
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = Example.gcd(x,y)
+printf "The gcd of %d and %d is %d\n",x,y,g
+
+# Call the gcdmain() function
+Example.gcdmain(["gcdmain","42","105"])
+
+# Call the count function
+
+printf "%d\n",Example.count("Hello World","l")
+
+# Call the capitalize function
+
+printf "%s\n",Example.capitalize("hello world")
+
diff --git a/trunk/Examples/ruby/operator/Makefile b/trunk/Examples/ruby/operator/Makefile
new file mode 100644
index 000000000..4c16edb5a
--- /dev/null
+++ b/trunk/Examples/ruby/operator/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/operator/example.h b/trunk/Examples/ruby/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/operator/example.i b/trunk/Examples/ruby/operator/example.i
new file mode 100644
index 000000000..b7e013ffd
--- /dev/null
+++ b/trunk/Examples/ruby/operator/example.i
@@ -0,0 +1,26 @@
+/* File : example.i */
+%module example
+
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ);
+
+
+%{
+#include "example.h"
+%}
+
+/* This header file is a little tough to handle because it has overloaded
+ operators and constructors. We're going to try and deal with that here */
+
+/* Grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend Complex {
+ char *__str__() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", $self->re(), $self->im());
+ return temp;
+ }
+};
+
+
diff --git a/trunk/Examples/ruby/operator/runme.rb b/trunk/Examples/ruby/operator/runme.rb
new file mode 100644
index 000000000..518d91e9e
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/overloading/Makefile b/trunk/Examples/ruby/overloading/Makefile
new file mode 100644
index 000000000..56c84c651
--- /dev/null
+++ b/trunk/Examples/ruby/overloading/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/overloading/example.cxx b/trunk/Examples/ruby/overloading/example.cxx
new file mode 100644
index 000000000..49d998d5a
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/overloading/example.h b/trunk/Examples/ruby/overloading/example.h
new file mode 100644
index 000000000..e47a122ee
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/overloading/example.i b/trunk/Examples/ruby/overloading/example.i
new file mode 100644
index 000000000..17ad66997
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/overloading/runme.rb b/trunk/Examples/ruby/overloading/runme.rb
new file mode 100644
index 000000000..9f1233347
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/pointer/Makefile b/trunk/Examples/ruby/pointer/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/pointer/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/pointer/example.c b/trunk/Examples/ruby/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/pointer/example.i b/trunk/Examples/ruby/pointer/example.i
new file mode 100644
index 000000000..a8ac79499
--- /dev/null
+++ b/trunk/Examples/ruby/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/ruby/pointer/index.html b/trunk/Examples/ruby/pointer/index.html
new file mode 100644
index 000000000..c9d5b9c32
--- /dev/null
+++ b/trunk/Examples/ruby/pointer/index.html
@@ -0,0 +1,171 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:pointer</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/ruby/pointer/</tt>
+<hr>
+
+<H2>Simple Pointer Handling</H2>
+
+<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. The only
+problem is how does one go about creating these objects from a script?
+
+<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>
+
+Now, in a script you would do this:
+
+<blockquote>
+<pre>
+a = new_int(37)
+b = new_int(42)
+c = new_int(0)
+add(a,b,c)
+r = get_int(c)
+print "Result = #{r}\n"
+delete_int(a)
+delete_int(b)
+delete_int(c)
+</pre>
+</blockquote>
+
+<p>
+<li>Use the SWIG pointer library. For example, in the interface file
+you would do this:
+
+<blockquote>
+<pre>
+%include "pointer.i"
+</pre>
+</blockquote>
+
+and in a script you would do this:
+
+<blockquote>
+<pre>
+a = ptrcreate("int",37)
+b = ptrcreate("int",42)
+c = ptrcreate("int")
+add(a,b,c)
+r = ptrvalue(c)
+print "Result = #{r}\n"
+ptrfree(a)
+ptrfree(b)
+ptrfree(c)
+</pre>
+</blockquote>
+
+The advantage to using the pointer library is that it unifies some of the helper
+functions behind a common set of names. For example, the same set of functions work
+with int, double, float, and other fundamental types.
+
+<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 script:
+
+<blockquote>
+<pre>
+r = add(37,42)
+print "Result = #{r}\n"
+</pre>
+</blockquote>
+Needless to say, this is substantially easier.
+
+<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="runme.rb">runme.rb</a> (Ruby Script)
+</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 pointer.i library files can be
+found in the SWIG user manual. The files also contain documentation.
+
+<p>
+<li>The pointer.i library is designed primarily for convenience. If you
+are concerned about performance, you probably want to use a different
+approach.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/ruby/pointer/runme.rb b/trunk/Examples/ruby/pointer/runme.rb
new file mode 100644
index 000000000..d696b026f
--- /dev/null
+++ b/trunk/Examples/ruby/pointer/runme.rb
@@ -0,0 +1,45 @@
+# file: runme.rb
+
+require 'example'
+
+# First create some objects using the pointer library.
+print "Testing the pointer library\n"
+a = Example::new_intp()
+b = Example::new_intp()
+c = Example::new_intp()
+
+Example::intp_assign(a,37)
+Example::intp_assign(b,42)
+
+print " a = #{a}\n"
+print " b = #{b}\n"
+print " c = #{c}\n"
+
+# Call the add() function with some pointers
+Example::add(a, b, c)
+
+# Now get the result
+r = Example::intp_value(c)
+print " 37 + 42 = #{r}\n"
+
+# Clean up the pointers
+Example::delete_intp(a)
+Example::delete_intp(b)
+Example::delete_intp(c)
+
+# Now try the typemap library
+# This should be much easier. Now how it is no longer
+# necessary to manufacture pointers.
+
+print "Trying the typemap library\n"
+r = Example::sub(37, 42)
+print " 37 - 42 = #{r}\n"
+
+# Now try the version with multiple return values
+
+print "Testing multiple return values\n"
+q, r = Example::divide(42, 37)
+print " 42/37 = #{q} remainder #{r}\n"
+
+
+
diff --git a/trunk/Examples/ruby/reference/Makefile b/trunk/Examples/ruby/reference/Makefile
new file mode 100644
index 000000000..56c84c651
--- /dev/null
+++ b/trunk/Examples/ruby/reference/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/reference/example.cxx b/trunk/Examples/ruby/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/ruby/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/ruby/reference/example.h b/trunk/Examples/ruby/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/reference/example.i b/trunk/Examples/ruby/reference/example.i
new file mode 100644
index 000000000..6daa3b1f4
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/reference/index.html b/trunk/Examples/ruby/reference/index.html
new file mode 100644
index 000000000..d45dbe3d9
--- /dev/null
+++ b/trunk/Examples/ruby/reference/index.html
@@ -0,0 +1,147 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/ruby/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<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 &amp;a, const Vector &amp;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 &amp;a, const Vector &amp;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 &amp;operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &amp;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 &amp;result = self-&gt;get(index);
+ return &amp;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 &amp;get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &amp;a) {
+ (*self)[index] = a;
+ }
+ }
+ ...
+}
+</pre>
+</blockquote>
+
+Click <a href="example.i">here</a> to see a SWIG interface file with these additions.
+
+<h2>Sample Ruby script</h2>
+
+Click <a href="runme.rb">here</a> to see a script that manipulates some C++ references.
+
+<h2>Notes:</h2>
+
+<ul>
+<li>C++ references primarily provide notational convenience for C++
+source code. However, Ruby 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/trunk/Examples/ruby/reference/runme.rb b/trunk/Examples/ruby/reference/runme.rb
new file mode 100644
index 000000000..67b76fc8a
--- /dev/null
+++ b/trunk/Examples/ruby/reference/runme.rb
@@ -0,0 +1,60 @@
+# file: runme.rb
+
+# This file illustrates the manipulation of C++ references in Ruby.
+
+require 'example'
+
+# ----- Object creation -----
+
+print "Creating some objects:\n"
+a = Example::Vector.new(3,4,5)
+b = Example::Vector.new(10,11,12)
+
+print " Created ", a.print, "\n"
+print " Created ", b.print, "\n"
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+print "Adding a+b\n"
+c = Example::addv(a, b)
+print " a+b = ", c.print, "\n"
+
+# ----- Create a vector array -----
+
+print "Creating an array of vectors\n"
+va = Example::VectorArray.new(10)
+print " va = #{va}\n"
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of a and b to the vector array
+va.set(0, a)
+va.set(1, b)
+
+va.set(2, Example::addv(a,b))
+
+c = Example::addv(a,b)
+va.set(3, c)
+
+=begin commented out due to GC issue
+
+# Get some values from the array
+
+print "Getting some array values\n"
+for i in 0...5
+ print " va(#{i}) = ", va.get(i).print, "\n"
+end
+
+# Watch under resource meter to check on this
+print "Making sure we don't leak memory.\n"
+for i in 0...1000000
+ c = va.get(i % 10)
+end
+
+=end
diff --git a/trunk/Examples/ruby/simple/Makefile b/trunk/Examples/ruby/simple/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/simple/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/simple/example.c b/trunk/Examples/ruby/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/simple/example.dsp b/trunk/Examples/ruby/simple/example.dsp
new file mode 100644
index 000000000..4888299f5
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(RUBY_INCLUDE)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /D NT=1 /D "IMPORT" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(RUBY_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -ruby $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo RUBY_INCLUDE: %RUBY_INCLUDE%
+ echo RUBY_LIB: %RUBY_LIB%
+ echo on
+ ..\..\..\swig.exe -ruby $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/ruby/simple/example.i b/trunk/Examples/ruby/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/ruby/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/ruby/simple/index.html b/trunk/Examples/ruby/simple/index.html
new file mode 100644
index 000000000..b2ab14ed1
--- /dev/null
+++ b/trunk/Examples/ruby/simple/index.html
@@ -0,0 +1,97 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/ruby/simple/</tt>
+<hr>
+
+<H2>Simple Ruby Example</H2>
+
+<p>
+This example illustrates how you can hook Ruby 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 &gt; 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 -ruby <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>example.so</tt>.
+</ol>
+
+<h2>Using the extension</h2>
+
+Click <a href="run.rb">here</a> to see a script that calls our C functions from Ruby.
+
+<h2>Key points</h2>
+
+<ul>
+<li>Use the <tt>require</tt> function to load your extension library from Ruby. For example:
+<blockquote>
+<pre>
+require 'example'
+</pre>
+</blockquote>
+
+<li>C functions work just like Ruby functions. For example:
+<blockquote>
+<pre>
+g = Example.gcd(42,105)
+</pre>
+</blockquote>
+
+<li>C global variables are accessed through module method. For example:
+<blockquote>
+<pre>
+a = Example.Foo
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/ruby/simple/runme.rb b/trunk/Examples/ruby/simple/runme.rb
new file mode 100755
index 000000000..9cc47b2df
--- /dev/null
+++ b/trunk/Examples/ruby/simple/runme.rb
@@ -0,0 +1,21 @@
+# file: runme.rb
+
+require 'example'
+
+# Call our gcd() function
+
+x = 42
+y = 105
+g = Example.gcd(x,y)
+printf "The gcd of %d and %d is %d\n",x,y,g
+
+# Manipulate the Foo global variable
+
+# Output its current value
+print "Foo = ", Example.Foo, "\n"
+
+# Change its value
+Example.Foo = 3.1415926
+
+# See if the change took effect
+print "Foo = ", Example.Foo, "\n"
diff --git a/trunk/Examples/ruby/std_vector/Makefile b/trunk/Examples/ruby/std_vector/Makefile
new file mode 100644
index 000000000..15c9d705f
--- /dev/null
+++ b/trunk/Examples/ruby/std_vector/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/std_vector/example.h b/trunk/Examples/ruby/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/std_vector/example.i b/trunk/Examples/ruby/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/std_vector/runme.rb b/trunk/Examples/ruby/std_vector/runme.rb
new file mode 100644
index 000000000..851190536
--- /dev/null
+++ b/trunk/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.size-1) { |i| v[i] = i+1 }
+puts Example::average(v)
+
+
+# half will return a Ruby array.
+# Call it with a Ruby array...
+
+w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0])
+0.upto(w.size-1) { |i| print w[i],"; " }
+puts
+
+# ... or a wrapped std::vector<double>
+
+v = Example::DoubleVector.new
+[1,2,3,4].each { |i| v.push(i) }
+w = Example::half(v)
+0.upto(w.size-1) { |i| print w[i],"; " }
+puts
+
+# now halve a wrapped std::vector<double> in place
+
+Example::halve_in_place(v)
+0.upto(v.size-1) { |i| print v[i],"; " }
+puts
+
diff --git a/trunk/Examples/ruby/template/Makefile b/trunk/Examples/ruby/template/Makefile
new file mode 100644
index 000000000..15c9d705f
--- /dev/null
+++ b/trunk/Examples/ruby/template/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/template/example.h b/trunk/Examples/ruby/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/template/example.i b/trunk/Examples/ruby/template/example.i
new file mode 100644
index 000000000..d5ddf7aaa
--- /dev/null
+++ b/trunk/Examples/ruby/template/example.i
@@ -0,0 +1,21 @@
+/* File : example.i */
+%module example
+
+%{
+#ifdef max
+#undef max
+#endif
+
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max<int>;
+%template(maxdouble) max<double>;
+%template(Vecint) vector<int>;
+%template(Vecdouble) vector<double>;
+
diff --git a/trunk/Examples/ruby/template/runme.rb b/trunk/Examples/ruby/template/runme.rb
new file mode 100644
index 000000000..6c9c4ebc2
--- /dev/null
+++ b/trunk/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/trunk/Examples/ruby/value/Makefile b/trunk/Examples/ruby/value/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/value/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/value/example.c b/trunk/Examples/ruby/value/example.c
new file mode 100644
index 000000000..4ed2fe10a
--- /dev/null
+++ b/trunk/Examples/ruby/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/trunk/Examples/ruby/value/example.h b/trunk/Examples/ruby/value/example.h
new file mode 100644
index 000000000..212cf4bdb
--- /dev/null
+++ b/trunk/Examples/ruby/value/example.h
@@ -0,0 +1,5 @@
+/* File : example.h */
+
+typedef struct {
+ double x, y, z;
+} Vector;
diff --git a/trunk/Examples/ruby/value/example.i b/trunk/Examples/ruby/value/example.i
new file mode 100644
index 000000000..98fd60ed5
--- /dev/null
+++ b/trunk/Examples/ruby/value/example.i
@@ -0,0 +1,32 @@
+// Tests SWIG's handling of pass-by-value for complex datatypes
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Some functions that manipulate Vectors by value */
+%inline %{
+extern double dot_product(Vector a, Vector b);
+extern Vector vector_add(Vector a, Vector b);
+%}
+
+/* Include this because the vector_add() function will leak memory */
+void free(void *);
+
+/* Some helper functions for our interface */
+%inline %{
+
+Vector *new_Vector(double x, double y, double z) {
+ Vector *v = (Vector *) malloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+}
+
+void vector_print(Vector *v) {
+ printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+%}
+
diff --git a/trunk/Examples/ruby/value/index.html b/trunk/Examples/ruby/value/index.html
new file mode 100644
index 000000000..cd99ba1e6
--- /dev/null
+++ b/trunk/Examples/ruby/value/index.html
@@ -0,0 +1,114 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:value</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/ruby/value/</tt>
+<hr>
+
+<H2>Passing and Returning Structures by Value</H2>
+
+<p>
+Occasionally, a C program will manipulate structures by value such as shown in the
+following code:
+
+<blockquote>
+<pre>
+/* File : example.c */
+
+typedef struct Vector {
+ double x, y, z;
+} Vector;
+
+double dot_product(Vector a, Vector b) {
+ return (a.x*b.x + a.y*b.y + a.z*b.z);
+}
+
+Vector vector_add(Vector a, Vector b) {
+ Vector r;
+ r.x = a.x + b.x;
+ r.y = a.y + b.y;
+ r.z = a.z + b.z;
+ return r;
+}
+</pre>
+</blockquote>
+
+Since SWIG only knows how to manage pointers to structures (not their internal
+representation), the following translations are made when wrappers are
+created:
+
+<blockquote>
+<pre>
+double wrap_dot_product(Vector *a, Vector *b) {
+ return dot_product(*a,*b);
+}
+
+Vector *wrap_vector_add(Vector *a, Vector *b) {
+ Vector *r = (Vector *) malloc(sizeof(Vector));
+ *r = vector_add(*a,*b);
+ return r;
+}
+</pre>
+</blockquote>
+
+The functions are then called using pointers from the scripting language interface.
+It should also be noted that any function that returns a structure by value results
+in an implicit memory allocation. This will be a memory leak unless you take steps
+to free the result (see below).
+
+<h2>The SWIG interface</h2>
+
+Click <a href="example.i">here</a> to see a SWIG interface file that
+wraps these two functions. In this file, there are a few essential features:
+
+<ul>
+<li>A wrapper for the <tt>free()</tt> function is created so that we
+can clean up the return result created by <tt>vector_add()</tt>
+function.
+
+<p>
+<li>The %inline directive is used to create a few helper functions for creating new Vector
+objects and to print out the value (for debugging purposes).
+</ul>
+
+<h2>A Ruby Script</h2>
+
+Click <a href="runme.rb">here</a> to see a script that uses these functions from Ruby.
+
+<h2>Notes</h2>
+
+<ul>
+<li>When the '<tt>-c++</tt>' option is used, the resulting wrapper code for the return value
+changes to the following:
+
+<blockquote>
+<pre>
+Vector *wrap_vector_add(Vector *a, Vector *b) {
+ Vector *r = new Vector(vector_add(*a,*b));
+ return r;
+}
+</pre>
+</blockquote>
+
+<p>
+<li>If you define C structure (or C++ class with '<tt>-c++</tt>' option)
+in the interface file, the SWIG generated wrappers can automaticallyclean
+up the result of return-by-reference by GC.
+
+<p>
+<li>Passing parameters by value like this really isn't the best C programming style.
+If possible, you might change your application to use pointers.
+
+<p>
+<li>Similar translations are made when C++ references are used.
+
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/ruby/value/runme.rb b/trunk/Examples/ruby/value/runme.rb
new file mode 100644
index 000000000..9372c03f4
--- /dev/null
+++ b/trunk/Examples/ruby/value/runme.rb
@@ -0,0 +1,32 @@
+# file: runme.rb
+
+require 'example'
+
+# Create a couple of a vectors
+
+v = Example::new_Vector(1, 2, 3)
+w = Example::new_Vector(10, 11, 12)
+
+print "I just created the following vectors\n"
+Example::vector_print(v)
+Example::vector_print(w)
+
+# Now call some of our functions
+
+print "\nNow I'm going to compute the dot product\n"
+d = Example::dot_product(v,w)
+print "dot product = #{d} (should be 68)\n"
+
+# Add the vectors together
+
+print "\nNow I'm going to add the vectors together\n"
+r = Example::vector_add(v,w)
+Example::vector_print(r)
+print "The value should be (11, 13, 15)\n"
+
+# Now I'd better clean up the return result r
+
+print "\nNow I'm going to clean up the return result\n"
+Example::free(r)
+
+print "Good\n"
diff --git a/trunk/Examples/ruby/variables/Makefile b/trunk/Examples/ruby/variables/Makefile
new file mode 100644
index 000000000..8c4fe1064
--- /dev/null
+++ b/trunk/Examples/ruby/variables/Makefile
@@ -0,0 +1,18 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/ruby/variables/example.c b/trunk/Examples/ruby/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/ruby/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/ruby/variables/example.h b/trunk/Examples/ruby/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/ruby/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/ruby/variables/example.i b/trunk/Examples/ruby/variables/example.i
new file mode 100644
index 000000000..84a150900
--- /dev/null
+++ b/trunk/Examples/ruby/variables/example.i
@@ -0,0 +1,50 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/ruby/variables/index.html b/trunk/Examples/ruby/variables/index.html
new file mode 100644
index 000000000..d83a87ce7
--- /dev/null
+++ b/trunk/Examples/ruby/variables/index.html
@@ -0,0 +1,94 @@
+<html>
+<head>
+<title>SWIG:Examples:ruby:variables</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/ruby/variables/</tt>
+<hr>
+
+<H2>Wrapping C Global Variables</H2>
+
+<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 Ruby variable (actually module method) 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 Ruby</h2>
+
+Before going any further, it is important to understand some important
+differences between C and Ruby variables. In C, a variable is
+simply a name that refers to a specific location in memory. For
+example, when you declare a global variable '<tt>double a</tt>' you
+know that somewhere in memory, 8 bytes have been set aside to hold a
+<tt>double</tt> and that <tt>a</tt> is bound to this location for the
+life of the program. In Ruby, variable creation is nothing more
+than a naming operation. For example, when you say '<tt>a = 3</tt>',
+'a' becomes a name that refers to some object '3'. Later on, if you say
+'<tt>a = 7.5</tt>, the name 'a' is bound to an entirely different object
+containing the value '7.5' (the contents of the original object are not
+changed). The end result of this is that a variable in Ruby can refer
+to a virtually unlimited number of different objects (memory locations)
+over the lifetime of a program.
+
+<p>
+Because of Ruby's somewhat unusual variable assignment semantics, it is not
+possible to directly link a C global variable into an equivalent Ruby variable.
+Instead, all C global variables are accessed as attributes of the module.
+For example, if you had a global variable
+
+<blockquote>
+<pre>
+double foo;
+</pre>
+</blockquote>
+
+it will be accessed in the Ruby module as <tt>Example.foo</tt>. Click
+<a href="runme.rb">here</a> to see a script 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 Ruby, the old
+value is destroyed using <tt>free()</tt>.
+<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 Ruby strings, but
+when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
+<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 scripting interface and resulting memory management
+is much trickier than simply creating a wrapper function.
+</ul>
+
+</body>
+</html>
+<hr>
diff --git a/trunk/Examples/ruby/variables/runme.rb b/trunk/Examples/ruby/variables/runme.rb
new file mode 100644
index 000000000..38531c833
--- /dev/null
+++ b/trunk/Examples/ruby/variables/runme.rb
@@ -0,0 +1,77 @@
+# file: runme.rb
+
+require 'example'
+
+# Try to set the values of some global variables
+
+Example.ivar = 42
+Example.svar = -31000
+Example.lvar = 65537
+Example.uivar = 123456
+Example.usvar = 61000
+Example.ulvar = 654321
+Example.scvar = -13
+Example.ucvar = 251
+Example.cvar = "S"
+Example.fvar = 3.14159
+Example.dvar = 2.1828
+Example.strvar = "Hello World"
+Example.iptrvar= Example.new_int(37)
+Example.ptptr = Example.new_Point(37,42)
+Example.name = "Bill"
+
+# Now print out the values of the variables
+
+puts "Variables (values printed from Ruby)"
+
+puts "ivar = #{Example.ivar}"
+puts "svar = #{Example.svar}"
+puts "lvar = #{Example.lvar}"
+puts "uivar = #{Example.uivar}"
+puts "usvar = #{Example.usvar}"
+puts "ulvar = #{Example.ulvar}"
+puts "scvar = #{Example.scvar}"
+puts "ucvar = #{Example.ucvar}"
+puts "fvar = #{Example.fvar}"
+puts "dvar = #{Example.dvar}"
+puts "cvar = #{Example.cvar}"
+puts "strvar = #{Example.strvar}"
+puts "cstrvar = #{Example.cstrvar}"
+puts "iptrvar = #{Example.iptrvar}"
+puts "name = #{Example.name}"
+puts "ptptr = #{Example.ptptr} (#{Example.Point_print(Example.ptptr)})"
+puts "pt = #{Example.pt} (#{Example.Point_print(Example.pt)})"
+
+puts "\nVariables (values printed from C)"
+
+Example.print_vars()
+
+puts "\nNow I'm going to try and modify some read only variables";
+
+puts " Tring to set 'path'";
+begin
+ Example.path = "Whoa!"
+ puts "Hey, what's going on?!?! This shouldn't work"
+rescue NameError
+ puts "Good."
+end
+
+puts " Trying to set 'status'";
+begin
+ Example.status = 0
+ puts "Hey, what's going on?!?! This shouldn't work"
+rescue NameError
+ puts "Good."
+end
+
+
+puts "\nI'm going to try and update a structure variable.\n"
+
+Example.pt = Example.ptptr
+
+puts "The new value is"
+Example.pt_print()
+puts "You should see the value #{Example.Point_print(Example.ptptr)}"
+
+
+
diff --git a/trunk/Examples/s-exp/uffi.lisp b/trunk/Examples/s-exp/uffi.lisp
new file mode 100644
index 000000000..253f85aba
--- /dev/null
+++ b/trunk/Examples/s-exp/uffi.lisp
@@ -0,0 +1,389 @@
+;;; 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>
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (require 'port) ; from CLOCC
+ (require 'uffi))
+
+(in-package :cl-user)
+
+;; Interaction with the SWIG binary
+
+(defvar *swig-source-directory* #p"/home/mkoeppe/s/swig1.3/")
+
+(defvar *swig-program* (merge-pathnames "preinst-swig" *swig-source-directory*))
+
+(defun run-swig (swig-interface-file-name &key directory-search-list module
+ ignore-errors c++)
+ (let ((temp-file-name "/tmp/swig.lsp"))
+ (let ((process
+ (port:run-prog (namestring *swig-program*)
+ :output t
+ :args `(,@(and c++ '("-c++"))
+ "-sexp"
+ ,@(mapcar (lambda (dir)
+ (concatenate 'string
+ "-I" (namestring dir)))
+ directory-search-list)
+ ,@(and module
+ `("-module" ,module))
+ "-o" ,temp-file-name
+ ,(namestring swig-interface-file-name)))))
+ #+cmu (unless (or (zerop (ext:process-exit-code process))
+ ignore-errors)
+ (error "Process swig exited abnormally"))
+ (with-open-file (s temp-file-name)
+ (read s)))))
+
+;; Type system
+
+(defun parse-swigtype (type-string &key start end junk-ok)
+ "Parse TYPE-STRING as SWIG's internal representation of C/C++
+types. Return two values: The type description (an improper list) and
+the terminating index into TYPE-STRING."
+ ;; SWIG's internal representation is described in Source/Swig/stype.c
+ (unless start
+ (setq start 0))
+ (unless end
+ (setq end (length type-string)))
+ (flet ((prefix-match (prefix)
+ (let ((position (mismatch prefix type-string :start2 start :end2 end)))
+ (or (not position)
+ (= position (length prefix)))))
+ (bad-type-error (reason)
+ (error "Bad SWIG type (~A): ~A" reason
+ (subseq type-string start end)))
+ (type-char (index)
+ (and (< index (length type-string))
+ (char type-string index)))
+ (cons-and-recurse (prefix start end)
+ (multiple-value-bind (type-description index)
+ (parse-swigtype type-string :start start :end end
+ :junk-ok junk-ok)
+ (values (cons prefix type-description)
+ index))))
+ (cond
+ ((prefix-match "p.") ; pointer
+ (cons-and-recurse '* (+ start 2) end))
+ ((prefix-match "r.") ; C++ reference
+ (cons-and-recurse '& (+ start 2) end))
+ ((prefix-match "a(") ; array
+ (let ((closing-paren (position #\) type-string
+ :start (+ start 2)
+ :end end)))
+ (unless closing-paren
+ (bad-type-error "missing right paren"))
+ (unless (eql (type-char (+ closing-paren 1)) #\.)
+ (bad-type-error "missing dot"))
+ (cons-and-recurse (list 'ARRAY (subseq type-string (+ start 2) closing-paren))
+ (+ closing-paren 2) end)))
+ ((prefix-match "q(") ; qualifier (const, volatile)
+ (let ((closing-paren (position #\) type-string
+ :start (+ start 2)
+ :end end)))
+ (unless closing-paren
+ (bad-type-error "missing right paren"))
+ (unless (eql (type-char (+ closing-paren 1)) #\.)
+ (bad-type-error "missing dot"))
+ (cons-and-recurse (list 'QUALIFIER (subseq type-string (+ start 2) closing-paren))
+ (+ closing-paren 2) end)))
+ ((prefix-match "m(") ; C++ member pointer
+ (multiple-value-bind (class-type class-end-index)
+ (parse-swigtype type-string :junk-ok t
+ :start (+ start 2) :end end)
+ (unless (eql (type-char class-end-index) #\))
+ (bad-type-error "missing right paren"))
+ (unless (eql (type-char (+ class-end-index 1)) #\.)
+ (bad-type-error "missing dot"))
+ (cons-and-recurse (list 'MEMBER-POINTER class-type)
+ (+ class-end-index 2) end)))
+ ((prefix-match "f(") ; function
+ (loop with index = (+ start 2)
+ until (eql (type-char index) #\))
+ collect (multiple-value-bind (arg-type arg-end-index)
+ (parse-swigtype type-string :junk-ok t
+ :start index :end end)
+ (case (type-char arg-end-index)
+ (#\, (setq index (+ arg-end-index 1)))
+ (#\) (setq index arg-end-index))
+ (otherwise (bad-type-error "comma or right paren expected")))
+ arg-type)
+ into arg-types
+ finally (unless (eql (type-char (+ index 1)) #\.)
+ (bad-type-error "missing dot"))
+ (return (cons-and-recurse (cons 'FUNCTION arg-types)
+ (+ index 2) end))))
+ ((prefix-match "v(") ;varargs
+ (let ((closing-paren (position #\) type-string
+ :start (+ start 2)
+ :end end)))
+ (unless closing-paren
+ (bad-type-error "missing right paren"))
+ (values (list 'VARARGS (subseq type-string (+ start 2) closing-paren))
+ (+ closing-paren 1))))
+ (t (let ((junk-position (position-if (lambda (char)
+ (member char '(#\, #\( #\) #\.)))
+ type-string
+ :start start :end end)))
+ (cond (junk-position ; found junk
+ (unless junk-ok
+ (bad-type-error "trailing junk"))
+ (values (subseq type-string start junk-position)
+ junk-position))
+ (t
+ (values (subseq type-string start end)
+ end))))))))
+
+(defun swigtype-function-p (swigtype)
+ "Check whether SWIGTYPE designates a function. If so, the second
+value is the list of argument types, and the third value is the return
+type."
+ (if (and (consp swigtype)
+ (consp (first swigtype))
+ (eql (first (first swigtype)) 'FUNCTION))
+ (values t (rest (first swigtype)) (rest swigtype))
+ (values nil nil nil)))
+
+
+;; UFFI
+
+(defvar *uffi-definitions* '())
+
+(defconstant *uffi-default-primitive-type-alist*
+ '(("char" . :char)
+ ("unsigned char" . :unsigned-byte)
+ ("signed char" . :byte)
+ ("short" . :short)
+ ("signed short" . :short)
+ ("unsigned short" . :unsigned-short)
+ ("int" . :int)
+ ("signed int" . :int)
+ ("unsigned int" . :unsigned-int)
+ ("long" . :long)
+ ("signed long" . :long)
+ ("unsigned long" . :unsigned-long)
+ ("float" . :float)
+ ("double" . :double)
+ ((* . "char") . :cstring)
+ ((* . "void") . :pointer-void)
+ ("void" . :void)))
+
+(defvar *uffi-primitive-type-alist* *uffi-default-primitive-type-alist*)
+
+(defun uffi-type-spec (type-list)
+ "Return the UFFI type spec equivalent to TYPE-LIST, or NIL if there
+is no representation."
+ (let ((primitive-type-pair
+ (assoc type-list *uffi-primitive-type-alist* :test 'equal)))
+ (cond
+ (primitive-type-pair
+ (cdr primitive-type-pair))
+ ((and (consp type-list)
+ (eql (first type-list) '*))
+ (let ((base-type-spec (uffi-type-spec (rest type-list))))
+ (cond
+ ((not base-type-spec)
+ :pointer-void)
+ (t
+ (list '* base-type-spec)))))
+ (t nil))))
+
+;; Parse tree
+
+(defvar *uffi-output* nil)
+
+(defun emit-uffi-definition (uffi-definition)
+ (format *uffi-output* "~&~S~%" uffi-definition)
+ (push uffi-definition *uffi-definitions*))
+
+(defun make-cl-symbol (c-identifier &key uninterned)
+ (let ((name (substitute #\- #\_ (string-upcase c-identifier))))
+ (if uninterned
+ (make-symbol name)
+ (intern name))))
+
+(defvar *class-scope* '() "A stack of names of nested C++ classes.")
+
+(defvar *struct-fields* '())
+
+(defvar *linkage* :C "NIL or :C")
+
+(defgeneric handle-node (node-type &key &allow-other-keys)
+ (:documentation "Handle a node of SWIG's parse tree of a C/C++ program"))
+
+(defmethod handle-node ((node-type t) &key &allow-other-keys)
+ ;; do nothing for unknown node types
+ nil)
+
+(defmethod handle-node ((node-type (eql 'cdecl)) &key name decl storage parms type &allow-other-keys)
+ (let ((swigtype (parse-swigtype (concatenate 'string decl type))))
+ (let ((*print-pretty* nil) ; or FUNCTION would be printed as #' by cmucl
+ (*print-circle* t))
+ (format *uffi-output* "~&;; C Declaration: ~A ~A ~A ~A~%;; with-parms ~W~%;; of-type ~W~%"
+ storage type name decl parms swigtype))
+ (multiple-value-bind (function-p arg-swigtype-list return-swigtype)
+ (swigtype-function-p swigtype)
+ (declare (ignore arg-swigtype-list))
+ (cond
+ ((and (null *class-scope*) function-p
+ (or (eql *linkage* :c)
+ (string= storage "externc")))
+ ;; ordinary top-level function with C linkage
+ (let ((argnum 0)
+ (argname-list '()))
+ (flet ((unique-argname (name)
+ ;; Sometimes the functions in SWIG interfaces
+ ;; do not have unique names. Make them unique
+ ;; by adding a suffix. Also avoid symbols
+ ;; that are specially bound.
+ (unless name
+ (setq name (format nil "arg~D" argnum)))
+ (let ((argname (make-cl-symbol name)))
+ (when (boundp argname) ;specially bound
+ (setq argname (make-cl-symbol name :uninterned t)))
+ (push argname argname-list)
+ argname)))
+ (let ((uffi-arg-list
+ (mapcan (lambda (param)
+ (incf argnum)
+ (destructuring-bind (&key name type &allow-other-keys) param
+ (let ((uffi-type (uffi-type-spec (parse-swigtype type))))
+ (cond
+ ((not uffi-type)
+ (format *uffi-output* "~&;; Warning: Cannot handle type ~S of argument `~A'~%"
+ type name)
+ (return-from handle-node))
+ ((eq uffi-type :void)
+ '())
+ (t
+ (let ((symbol (unique-argname name)))
+ (list `(,symbol ,uffi-type))))))))
+ parms))
+ (uffi-return-type
+ (uffi-type-spec return-swigtype)))
+ (unless uffi-return-type
+ (format *uffi-output* "~&;; Warning: Cannot handle return type `~S'~%"
+ return-swigtype)
+ (return-from handle-node))
+ (emit-uffi-definition `(UFFI:DEF-FUNCTION ,name ,uffi-arg-list :RETURNING ,uffi-return-type))))))
+ ((and (not (null *class-scope*)) (null (rest *class-scope*))
+ (not function-p)) ; class/struct member (no nested structs)
+ (let ((uffi-type (uffi-type-spec swigtype)))
+ (unless uffi-type
+ (format *uffi-output* "~&;; Warning: Cannot handle type ~S of struct field `~A'~%"
+ type name)
+ (return-from handle-node))
+ (push `(,(make-cl-symbol name) ,uffi-type) *struct-fields*)))))))
+
+(defmethod handle-node ((node-type (eql 'class)) &key name children kind &allow-other-keys)
+ (format *uffi-output* "~&;; Class ~A~%" name)
+ (let ((*class-scope* (cons name *class-scope*))
+ (*struct-fields* '()))
+ (dolist (child children)
+ (apply 'handle-node child))
+ (emit-uffi-definition `(,(if (string= kind "union")
+ 'UFFI:DEF-UNION
+ 'UFFI:DEF-STRUCT)
+ ,(make-cl-symbol name) ,@(nreverse *struct-fields*)))))
+
+(defmethod handle-node ((node-type (eql 'top)) &key children &allow-other-keys)
+ (dolist (child children)
+ (apply 'handle-node child)))
+
+(defmethod handle-node ((node-type (eql 'include)) &key name children &allow-other-keys)
+ (format *uffi-output* ";; INCLUDE ~A~%" name)
+ (dolist (child children)
+ (apply 'handle-node child)))
+
+(defmethod handle-node ((node-type (eql 'extern)) &key name children &allow-other-keys)
+ (format *uffi-output* ";; EXTERN \"C\" ~A~%" name)
+ (let ((*linkage* :c))
+ (dolist (child children)
+ (apply 'handle-node child))))
+
+;;(defun compute-uffi-definitions (swig-interface)
+;; (let ((*uffi-definitions* '()))
+;; (handle-node swig-interface)
+;; *uffi-definitions*))
+
+;; Test instances
+
+;;; Link to SWIG itself
+
+#||
+
+(defparameter *c++-compiler* "g++")
+
+(defun stdc++-library (&key env)
+ (let ((error-output (make-string-output-stream)))
+ (let ((name-output (make-string-output-stream)))
+ (let ((proc (ext:run-program
+ *c++-compiler*
+ '("-print-file-name=libstdc++.so")
+ :env env
+ :input nil
+ :output name-output
+ :error error-output)))
+ (unless proc
+ (error "Could not run ~A" *c++-compiler*))
+ (unless (zerop (ext:process-exit-code proc))
+ (system:serve-all-events 0)
+ (error "~A failed:~%~A" *c++-compiler*
+ (get-output-stream-string error-output))))
+ (string-right-trim '(#\Newline) (get-output-stream-string name-output)))))
+
+(defvar *swig-interface* nil)
+
+(defvar *swig-uffi-pathname* #p"/tmp/swig-uffi.lisp")
+
+(defun link-swig ()
+ (setq *swig-interface*
+ (run-swig (merge-pathnames "Source/swig.i" *swig-source-directory*)
+ :directory-search-list
+ (list (merge-pathnames "Source/" *swig-source-directory*))
+ :module "swig"
+ :ignore-errors t
+ :c++ t))
+ (with-open-file (f *swig-uffi-pathname* :direction :output)
+ (let ((*linkage* :c++)
+ (*uffi-definitions* '())
+ (*uffi-output* f)
+ (*uffi-primitive-type-alist* *uffi-default-primitive-type-alist*))
+ (apply 'handle-node *swig-interface*)))
+ (compile-file *swig-uffi-pathname*)
+ (alien:load-foreign (merge-pathnames "Source/libswig.a"
+ *swig-source-directory*)
+ :libraries (list (stdc++-library)))
+ ;; FIXME: UFFI stuffes a "-l" in front of the passed library names
+ ;; (uffi:load-foreign-library (merge-pathnames "Source/libswig.a"
+ ;; *swig-source-directory*)
+ ;; :supporting-libraries
+ ;; (list (stdc++-library)))
+ (load (compile-file-pathname *swig-uffi-pathname*)))
+
+||#
+
+;;;; TODO:
+
+;; * How to do type lookups? Is everything important that SWIG knows
+;; about the types written out? What to make of typemaps?
+;;
+;; * Wrapped functions should probably automatically COERCE their
+;; arguments (as of type DOUBLE-FLOAT), to make the functions more
+;; flexible?
+;;
+;; * Why are the functions created by FFI interpreted?
+;;
+;; * We can't deal with more complicated structs and C++ classes
+;; directly with the FFI; we have to emit SWIG wrappers that access
+;; those classes.
+;;
+;; * A CLOS layer where structure fields are mapped as slots. It
+;; looks like we need MOP functions to implement this.
+;;
+;; * Maybe modify SWIG so that key-value hashes are distinguished from
+;; value-value hashes.
diff --git a/trunk/Examples/tcl/check.list b/trunk/Examples/tcl/check.list
new file mode 100644
index 000000000..8e7a8a9d7
--- /dev/null
+++ b/trunk/Examples/tcl/check.list
@@ -0,0 +1,16 @@
+# see top-level Makefile.in
+class
+constants
+contract
+enum
+funcptr
+import
+java
+multimap
+operator
+pointer
+reference
+simple
+std_vector
+value
+variables
diff --git a/trunk/Examples/tcl/class/Makefile b/trunk/Examples/tcl/class/Makefile
new file mode 100644
index 000000000..c01283c20
--- /dev/null
+++ b/trunk/Examples/tcl/class/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/tcl/class/example.cxx b/trunk/Examples/tcl/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/class/example.dsp b/trunk/Examples/tcl/class/example.dsp
new file mode 100644
index 000000000..0ff54829f
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/class/example.h b/trunk/Examples/tcl/class/example.h
new file mode 100644
index 000000000..46d901361
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/class/example.i b/trunk/Examples/tcl/class/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/tcl/class/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/trunk/Examples/tcl/class/index.html b/trunk/Examples/tcl/class/index.html
new file mode 100644
index 000000000..fd8cfe502
--- /dev/null
+++ b/trunk/Examples/tcl/class/index.html
@@ -0,0 +1,274 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:class</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/tcl/class/</tt>
+<hr>
+
+<H2>Wrapping a simple C++ class</H2>
+
+<p>
+This example illustrates the most primitive form of C++ class wrapping performed
+by SWIG. In this case, C++ classes are simply transformed into a collection of
+C-style functions that provide access to class members.
+
+<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++ -tcl example.i
+</pre>
+</blockquote>
+
+<h2>Some sample Tcl scripts</h2>
+
+SWIG performs two forms of C++ wrapping-- a low level interface and a high level widget-like interface.
+<ul>
+<li>
+Click <a href="example1.tcl">here</a> to see a script that calls the C++ functions using the
+low-level interface.
+<li>
+Click <a href="example2.tcl">here</a> to see a the same script written with the high-level
+interface.
+</ul>
+
+<h2>Key points</h2>
+
+<ul>
+<li>The low-level C++ interface works like this:
+<p>
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+set c [new_Circle 10.0]
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, a pair of accessor functions are used.
+For example:
+
+<blockquote>
+<pre>
+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 must
+be used such as <tt>Shape_x_get</tt>
+
+<p>
+<li>To invoke a member function, you simply do this
+
+<blockquote>
+<pre>
+puts "The area is [Shape_area $c]"
+</pre>
+</blockquote>
+
+<p>
+<li>Type checking knows about the inheritance structure of C++. For example:
+
+<blockquote>
+<pre>
+Shape_area $c # Works (c is a Shape)
+Circle_area $c # Works (c is a Circle)
+Square_area $c # Fails (c is definitely not a Square)
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a destructor, simply do this
+
+<blockquote>
+<pre>
+delete_Shape $c # Deletes a shape
+</pre>
+</blockquote>
+
+<p>
+<li>Static member variables are wrapped as C global variables. For example:
+
+<blockquote>
+<pre>
+set n $Shape_nshapes # Get a static data member
+set Shapes_nshapes 13 # Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+
+<p>
+<li>The high-level interface works like a Tk widget
+
+<p>
+<ul>
+<li>To create a new object, you call a constructor like this:
+
+<blockquote>
+<pre>
+Circle c 10 # c becomes a name for the Circle object
+</pre>
+</blockquote>
+
+<p>
+<li>To access member data, use cget and configure methods.
+For example:
+
+<blockquote>
+<pre>
+c configure -x 15 ;# Set member data
+set x [c cget -x] ;# Get member data
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a member function, you simply do this
+
+<blockquote>
+<pre>
+puts "The area is [c area]"
+</pre>
+</blockquote>
+
+<p>
+<li>To invoke a destructor, simply destroy the object name like this:
+
+<blockquote>
+<pre>
+rename c "" # c goes away
+</pre>
+</blockquote>
+
+<p>
+<li>Static member variables are wrapped as C global variables. For example:
+
+<blockquote>
+<pre>
+set n $Shape_nshapes # Get a static data member
+set Shapes_nshapes 13 # Set a static data member
+</pre>
+</blockquote>
+
+</ul>
+</ul>
+
+<h2>General Comments</h2>
+
+<ul>
+<li>The low-level function interface is much faster than the high-level interface.
+In fact, all the higher level interface does is call functions in the low-level interface.
+
+<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.
+
+<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>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/tcl/class/runme.tcl b/trunk/Examples/tcl/class/runme.tcl
new file mode 100644
index 000000000..c7f472560
--- /dev/null
+++ b/trunk/Examples/tcl/class/runme.tcl
@@ -0,0 +1,50 @@
+# file: runme.tcl
+
+# This file illustrates the high level C++ interface.
+# In this case C++ classes work kind of like Tk widgets
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+Circle c 10
+puts " Created circle [c cget -this]"
+Square s 10
+puts " Created square [s cget -this]"
+
+# ----- Access a static member -----
+
+puts "\nA total of $Shape_nshapes shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c configure -x 20 -y 30
+s configure -x -10 -y 5
+
+puts "\nHere is their current position:"
+puts " Circle = ([c cget -x], [c cget -y])"
+puts " Square = ([s cget -x], [s cget -y])"
+
+# ----- Call some methods -----
+
+puts "\nHere are some properties of the shapes:"
+foreach o "c s" {
+ puts " [$o cget -this]"
+ puts " area = [$o area]"
+ puts " perimeter = [$o perimeter]"
+}
+
+# ----- Delete everything -----
+
+puts "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+rename c ""
+rename s ""
+
+puts "$Shape_nshapes shapes remain"
+puts "Goodbye"
+
diff --git a/trunk/Examples/tcl/class/runme2.tcl b/trunk/Examples/tcl/class/runme2.tcl
new file mode 100644
index 000000000..88ec2f678
--- /dev/null
+++ b/trunk/Examples/tcl/class/runme2.tcl
@@ -0,0 +1,70 @@
+# file: runme2.tcl
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+set c [new_Circle 10]
+puts " Created circle $c"
+set s [new_Square 10]
+puts " Created square $s"
+
+# ----- Access a static member -----
+
+puts "\nA total of $Shape_nshapes shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+# Note: the base class must be used since that's where x and y
+# were declared.
+
+Shape_x_set $c 20
+Shape_y_set $c 30
+Shape_x_set $s -10
+Shape_y_set $s 5
+
+puts "\nHere is their current position:"
+puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])"
+puts " Square = ([Shape_x_get $s], [Shape_y_get $s])"
+
+# ----- Call some methods -----
+
+puts "\nHere are some properties of the shapes:"
+foreach o "$c $s" {
+ puts " $o"
+ puts " area = [Shape_area $o]"
+ puts " perimeter = [Shape_perimeter $o]"
+}
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Try to cause a type error -----
+
+puts "\nI'm going to try and break the type system"
+
+if { [catch {
+ # Bad script!
+ Square_area $c # Try to invoke Square method on a Circle
+ puts " Bad bad SWIG!"
+
+}]} {
+ puts " Well, it didn't work. Good SWIG."
+}
+
+# ----- Delete everything -----
+
+puts "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+delete_Shape $c
+delete_Shape $s
+
+puts "$Shape_nshapes shapes remain"
+puts "Goodbye"
+
diff --git a/trunk/Examples/tcl/constants/Makefile b/trunk/Examples/tcl/constants/Makefile
new file mode 100644
index 000000000..ba28f47a4
--- /dev/null
+++ b/trunk/Examples/tcl/constants/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+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/trunk/Examples/tcl/constants/example.i b/trunk/Examples/tcl/constants/example.i
new file mode 100644
index 000000000..4f7b1a4d7
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/constants/index.html b/trunk/Examples/tcl/constants/index.html
new file mode 100644
index 000000000..fa332c64c
--- /dev/null
+++ b/trunk/Examples/tcl/constants/index.html
@@ -0,0 +1,61 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:constants</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/tcl/constants/</tt>
+<hr>
+
+<H2>Wrapping C Constants</H2>
+
+<p>
+When SWIG encounters C preprocessor macros and C declarations that look like constants,
+it creates Tcl variables 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 Tcl</h2>
+
+Click <a href="runme.tcl">here</a> to see a script 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 Tcl read-only variables.
+<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 strings.
+<li>C string literals such as "Hello World" are converted into 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 Tcl 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).
+<li>Since constants are turned into Tcl variables, you have to use the global
+statement when accessing from a procedure. For example:
+
+<blockquote>
+<pre>
+proc foo {} {
+ global ICONST # Some C constant
+ puts $ICONST
+}
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+
+</body>
+</html>
diff --git a/trunk/Examples/tcl/constants/runme.tcl b/trunk/Examples/tcl/constants/runme.tcl
new file mode 100644
index 000000000..b504ba852
--- /dev/null
+++ b/trunk/Examples/tcl/constants/runme.tcl
@@ -0,0 +1,26 @@
+# file: runme.tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+puts "ICONST = $ICONST (should be 42)"
+puts "FCONST = $FCONST (should be 2.1828)"
+puts "CCONS T = $CCONST (should be 'x')"
+puts "CCONST2 = $CCONST2 (this should be on a separate line)"
+puts "SCONST = $SCONST (should be 'Hello World')"
+puts "SCONST2 = $SCONST2 (should be '\"Hello World\"')"
+puts "EXPR = $EXPR (should be 48.5484)"
+puts "iconst = $iconst (should be 37)"
+puts "fconst = $fconst (should be 3.14)"
+
+if { [catch {
+ puts "EXTERN = $EXTERN (Arg! This shouldn't print anything)"
+}]} {
+ puts "EXTERN isn't defined (good)"
+}
+
+if { [catch {
+ puts "FOO = $FOO (Arg! This shouldn't print anything)"
+}]} {
+ puts "FOO isn't defined (good)"
+}
+
diff --git a/trunk/Examples/tcl/contract/Makefile b/trunk/Examples/tcl/contract/Makefile
new file mode 100644
index 000000000..91a139afb
--- /dev/null
+++ b/trunk/Examples/tcl/contract/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = my_tclsh
+DLTARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+
+check: all
diff --git a/trunk/Examples/tcl/contract/example.c b/trunk/Examples/tcl/contract/example.c
new file mode 100644
index 000000000..1a644543f
--- /dev/null
+++ b/trunk/Examples/tcl/contract/example.c
@@ -0,0 +1,23 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+int fact(int n) {
+ if (n <= 0) return 1;
+ return n*fact(n-1);
+}
+
+
diff --git a/trunk/Examples/tcl/contract/example.dsp b/trunk/Examples/tcl/contract/example.dsp
new file mode 100644
index 000000000..c1568f2c5
--- /dev/null
+++ b/trunk/Examples/tcl/contract/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/contract/example.i b/trunk/Examples/tcl/contract/example.i
new file mode 100644
index 000000000..8fd1a80af
--- /dev/null
+++ b/trunk/Examples/tcl/contract/example.i
@@ -0,0 +1,21 @@
+/* File : example.i */
+%module example
+
+%contract gcd(int x, int y) {
+require:
+ x >= 0;
+ y >= 0;
+}
+
+%contract fact(int n) {
+require:
+ n >= 0;
+ensure:
+ fact >= 1;
+}
+
+%inline %{
+extern int gcd(int x, int y);
+extern int fact(int n);
+extern double Foo;
+%}
diff --git a/trunk/Examples/tcl/contract/runme.tcl b/trunk/Examples/tcl/contract/runme.tcl
new file mode 100644
index 000000000..3a6ce10b5
--- /dev/null
+++ b/trunk/Examples/tcl/contract/runme.tcl
@@ -0,0 +1,22 @@
+# file: runme.tcl
+# Try to load as a dynamic module.
+
+catch { load ./example[info sharedlibextension] example}
+
+# Call our gcd() function
+set x 42
+set y 105
+set g [gcd $x $y]
+puts "The gcd of $x and $y is $g"
+
+# Manipulate the Foo global variable
+
+# Output its current value
+puts "Foo = $Foo"
+
+# Change its value
+set Foo 3.1415926
+
+# See if the change took effect
+puts "Foo = $Foo"
+
diff --git a/trunk/Examples/tcl/enum/Makefile b/trunk/Examples/tcl/enum/Makefile
new file mode 100644
index 000000000..c01283c20
--- /dev/null
+++ b/trunk/Examples/tcl/enum/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/tcl/enum/example.cxx b/trunk/Examples/tcl/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/enum/example.h b/trunk/Examples/tcl/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/enum/example.i b/trunk/Examples/tcl/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/enum/index.html b/trunk/Examples/tcl/enum/index.html
new file mode 100644
index 000000000..559f6a804
--- /dev/null
+++ b/trunk/Examples/tcl/enum/index.html
@@ -0,0 +1,35 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:enum</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/tcl/enum/</tt>
+<hr>
+
+<H2>Wrapping enumerations</H2>
+
+<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="runme.tcl">runme.tcl</a>. Sample Tcl script.
+</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/trunk/Examples/tcl/enum/runme.tcl b/trunk/Examples/tcl/enum/runme.tcl
new file mode 100644
index 000000000..3d4e52ac5
--- /dev/null
+++ b/trunk/Examples/tcl/enum/runme.tcl
@@ -0,0 +1,32 @@
+# file: runme.tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+# Print out the value of some enums
+puts "*** color ***"
+puts " RED = $RED"
+puts " BLUE = $BLUE"
+puts " GREEN = $GREEN"
+
+puts "\n*** Foo::speed ***"
+puts " Foo_IMPULSE = $Foo_IMPULSE"
+puts " Foo_WARP = $Foo_WARP"
+puts " Foo_LUDICROUS = $Foo_LUDICROUS"
+
+
+puts "\nTesting use of enums with functions\n"
+
+enum_test $RED $Foo_IMPULSE
+enum_test $BLUE $Foo_WARP
+enum_test $GREEN $Foo_LUDICROUS
+enum_test 1234 5678
+
+puts "\nTesting use of enum with class method"
+Foo f
+
+f enum_test $Foo_IMPULSE
+f enum_test $Foo_WARP
+f enum_test $Foo_LUDICROUS
+
diff --git a/trunk/Examples/tcl/funcptr/Makefile b/trunk/Examples/tcl/funcptr/Makefile
new file mode 100644
index 000000000..bed049a36
--- /dev/null
+++ b/trunk/Examples/tcl/funcptr/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/tcl/funcptr/example.c b/trunk/Examples/tcl/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/funcptr/example.h b/trunk/Examples/tcl/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/trunk/Examples/tcl/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/trunk/Examples/tcl/funcptr/example.i b/trunk/Examples/tcl/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/funcptr/index.html b/trunk/Examples/tcl/funcptr/index.html
new file mode 100644
index 000000000..b822962c7
--- /dev/null
+++ b/trunk/Examples/tcl/funcptr/index.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:funcptr</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/tcl/funcptr/</tt>
+<hr>
+
+<H2>Pointers to Functions</H2>
+
+<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 script,
+you will need to pass some kind of C function pointer object. In C,
+this is easy, you just supply a function name as an argument like this:
+
+<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 script, you would do this:
+
+<blockquote>
+<pre>
+set r [do_op $x $y $ADD]
+</pre>
+</blockquote>
+
+<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="runme.tcl">runme.tcl</a> (Sample script)
+</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 Tcl function object in as a substitute for a C
+function pointer.
+
+<p>
+<li>A Tcl function can be used as a C/C++ callback if you write some
+clever typemaps and are very careful about how you create your extension.
+This is an advanced topic not covered here.
+</ul>
+
+<hr>
+</body>
+</html>
+
+
+
+
diff --git a/trunk/Examples/tcl/funcptr/runme.tcl b/trunk/Examples/tcl/funcptr/runme.tcl
new file mode 100644
index 000000000..7e676c2ea
--- /dev/null
+++ b/trunk/Examples/tcl/funcptr/runme.tcl
@@ -0,0 +1,21 @@
+# file: runme.tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+set a 37
+set b 42
+
+# Now call our C function with a bunch of callbacks
+
+puts "Trying some C callback functions"
+puts " a = $a"
+puts " b = $b"
+puts " ADD(a,b) = [do_op $a $b $ADD]"
+puts " SUB(a,b) = [do_op $a $b $SUB]"
+puts " MUL(a,b) = [do_op $a $b $MUL]"
+
+puts "Here is what the C callback function objects look like in Tcl"
+puts " ADD = $ADD"
+puts " SUB = $SUB"
+puts " MUL = $MUL"
+
diff --git a/trunk/Examples/tcl/import/Makefile b/trunk/Examples/tcl/import/Makefile
new file mode 100644
index 000000000..6b257aa7c
--- /dev/null
+++ b/trunk/Examples/tcl/import/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' tcl_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' tcl_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+
+check: all
diff --git a/trunk/Examples/tcl/import/README b/trunk/Examples/tcl/import/README
new file mode 100644
index 000000000..b2a65f5ed
--- /dev/null
+++ b/trunk/Examples/tcl/import/README
@@ -0,0 +1,37 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'tclsh runme.tcl' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module used %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
+Windows:
+--------
+- Use the Visual C++ 6 workspace file (example.dsw). The Batch build option
+ in the Build menu is usually the easiest way to do this. Only use the Release
+ builds not the Debug builds.
+- Run the test as described above
+
diff --git a/trunk/Examples/tcl/import/bar.dsp b/trunk/Examples/tcl/import/bar.dsp
new file mode 100644
index 000000000..d22b6a6fa
--- /dev/null
+++ b/trunk/Examples/tcl/import/bar.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=bar - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"bar.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"bar.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "bar - Win32 Debug"
+# Name "bar - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\bar_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\bar.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\bar.i
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/import/bar.h b/trunk/Examples/tcl/import/bar.h
new file mode 100644
index 000000000..fa4185f1f
--- /dev/null
+++ b/trunk/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/trunk/Examples/tcl/import/bar.i b/trunk/Examples/tcl/import/bar.i
new file mode 100644
index 000000000..5816cbe17
--- /dev/null
+++ b/trunk/Examples/tcl/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/trunk/Examples/tcl/import/base.dsp b/trunk/Examples/tcl/import/base.dsp
new file mode 100644
index 000000000..b27bbfdb6
--- /dev/null
+++ b/trunk/Examples/tcl/import/base.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=base - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"base.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"base.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "base - Win32 Debug"
+# Name "base - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\base_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\base.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\base.i
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/import/base.h b/trunk/Examples/tcl/import/base.h
new file mode 100644
index 000000000..5a266f68c
--- /dev/null
+++ b/trunk/Examples/tcl/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/trunk/Examples/tcl/import/base.i b/trunk/Examples/tcl/import/base.i
new file mode 100644
index 000000000..f6e19efd8
--- /dev/null
+++ b/trunk/Examples/tcl/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/trunk/Examples/tcl/import/example.dsw b/trunk/Examples/tcl/import/example.dsw
new file mode 100644
index 000000000..d395d464b
--- /dev/null
+++ b/trunk/Examples/tcl/import/example.dsw
@@ -0,0 +1,65 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "bar"=.\bar.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "base"=.\base.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "foo"=.\foo.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "spam"=.\spam.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/trunk/Examples/tcl/import/foo.dsp b/trunk/Examples/tcl/import/foo.dsp
new file mode 100644
index 000000000..4d3765bd7
--- /dev/null
+++ b/trunk/Examples/tcl/import/foo.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=foo - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"foo.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"foo.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "foo - Win32 Debug"
+# Name "foo - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\foo_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\foo.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\foo.i
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/import/foo.h b/trunk/Examples/tcl/import/foo.h
new file mode 100644
index 000000000..dd5184031
--- /dev/null
+++ b/trunk/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/trunk/Examples/tcl/import/foo.i b/trunk/Examples/tcl/import/foo.i
new file mode 100644
index 000000000..27feb2e6a
--- /dev/null
+++ b/trunk/Examples/tcl/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/trunk/Examples/tcl/import/runme.tcl b/trunk/Examples/tcl/import/runme.tcl
new file mode 100644
index 000000000..1227d7b21
--- /dev/null
+++ b/trunk/Examples/tcl/import/runme.tcl
@@ -0,0 +1,114 @@
+# file: runme.tcl
+# Test various properties of classes defined in separate modules
+
+puts "Testing the %import directive"
+catch { load ./base[info sharedlibextension] base}
+catch { load ./foo[info sharedlibextension] foo}
+catch { load ./bar[info sharedlibextension] bar}
+catch { load ./spam[info sharedlibextension] spam}
+
+# Create some objects
+
+puts "Creating some objects"
+
+set a [Base]
+set b [Foo]
+set c [Bar]
+set d [Spam]
+
+# Try calling some methods
+puts "Testing some methods"
+puts "Should see 'Base::A' ---> "
+$a A
+puts "Should see 'Base::B' ---> "
+$a B
+
+puts "Should see 'Foo::A' ---> "
+$b A
+puts "Should see 'Foo::B' ---> "
+$b B
+
+puts "Should see 'Bar::A' ---> "
+$c A
+puts "Should see 'Bar::B' ---> "
+$c B
+
+puts "Should see 'Spam::A' ---> "
+$d A
+puts "Should see 'Spam::B' ---> "
+$d B
+
+# Try some casts
+
+puts "\nTesting some casts\n"
+
+Base x -this [$a toBase]
+puts "Should see 'Base::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Base x -this [$b toBase]
+puts "Should see 'Foo::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Base x -this [$c toBase]
+puts "Should see 'Bar::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Base x -this [$d toBase]
+puts "Should see 'Spam::A' ---> "
+x A
+puts "Should see 'Base::B' ---> "
+x B
+rename x ""
+
+Bar x -this [$d toBar]
+puts "Should see 'Bar::B' ---> "
+x B
+rename x ""
+
+puts "\nTesting some dynamic casts\n"
+Base x -this [$d toBase]
+
+puts "Spam -> Base -> Foo : "
+set y [Foo_fromBase [x cget -this]]
+if {$y != "NULL"} {
+ puts "bad swig"
+} {
+ puts "good swig"
+}
+
+puts "Spam -> Base -> Bar : "
+set y [Bar_fromBase [x cget -this]]
+if {$y != "NULL"} {
+ puts "good swig"
+} {
+ puts "bad swig"
+}
+
+puts "Spam -> Base -> Spam : "
+set y [Spam_fromBase [x cget -this]]
+if {$y != "NULL"} {
+ puts "good swig"
+} {
+ puts "bad swig"
+}
+
+puts "Foo -> Spam : "
+set y [Spam_fromBase $b]
+if {$y != "NULL"} {
+ puts "bad swig"
+} {
+ puts "good swig"
+}
+
+
+
diff --git a/trunk/Examples/tcl/import/spam.dsp b/trunk/Examples/tcl/import/spam.dsp
new file mode 100644
index 000000000..5674c4373
--- /dev/null
+++ b/trunk/Examples/tcl/import/spam.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=spam - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For spam:
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(TCL_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"spam.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"spam.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "spam - Win32 Debug"
+# Name "spam - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\spam_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\spam.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\spam.i
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/import/spam.h b/trunk/Examples/tcl/import/spam.h
new file mode 100644
index 000000000..b4e7a2646
--- /dev/null
+++ b/trunk/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/trunk/Examples/tcl/import/spam.i b/trunk/Examples/tcl/import/spam.i
new file mode 100644
index 000000000..d3d9121db
--- /dev/null
+++ b/trunk/Examples/tcl/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+
diff --git a/trunk/Examples/tcl/index.html b/trunk/Examples/tcl/index.html
new file mode 100644
index 000000000..b32726002
--- /dev/null
+++ b/trunk/Examples/tcl/index.html
@@ -0,0 +1,70 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Tcl Examples</H1>
+
+<p>
+The following examples illustrate the use of SWIG with Tcl.
+
+<ul>
+<li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
+be used to wrap a C function and a global variable.
+<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>. How SWIG can be used to wrap C global variables.
+<li><a href="value/index.html">value</a>. How to pass and return structures by value.
+<li><a href="class/index.html">class</a>. How 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="funcptr/index.html">funcptr</a>. Pointers to functions.
+</ul>
+
+<h2>Compilation Issues</h2>
+
+<ul>
+<li>To create a Tcl extension, SWIG is run with the following options:
+
+<blockquote>
+<pre>
+% swig -tcl interface.i
+</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):
+
+<blockquote>
+<pre>
+unix % swig -tcl interface.i
+unix % gcc -fpic -c interface_wrap.c -I/usr/local/include
+unix % gcc -shared interface_wrap.o $(OBJS) -o interface.so
+unix % tclsh8.3
+% load ./interface.so
+% blah ...
+</pre>
+</blockquote>
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Linux
+<li>Solaris
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
+</body>
+</html>
+
+
diff --git a/trunk/Examples/tcl/java/Example.java b/trunk/Examples/tcl/java/Example.java
new file mode 100644
index 000000000..91ddb1ac5
--- /dev/null
+++ b/trunk/Examples/tcl/java/Example.java
@@ -0,0 +1,29 @@
+public class Example {
+ public int mPublicInt;
+
+ public Example() {
+ mPublicInt = 0;
+ }
+
+ public Example(int IntVal) {
+ mPublicInt = IntVal;
+ }
+
+
+ public int Add(int a, int b) {
+ return (a+b);
+ }
+
+ public float Add(float a, float b) {
+ return (a+b);
+ }
+
+ public String Add(String a, String b) {
+ return (a+b);
+ }
+
+ public Example Add(Example a, Example b) {
+ return new Example(a.mPublicInt + b.mPublicInt);
+ }
+}
+
diff --git a/trunk/Examples/tcl/java/Makefile b/trunk/Examples/tcl/java/Makefile
new file mode 100644
index 000000000..1c6d4d027
--- /dev/null
+++ b/trunk/Examples/tcl/java/Makefile
@@ -0,0 +1,26 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all:: Example.class
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ TCL_CXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+ rm -f *.class Example.h
+
+check: all
+
+run:
+ tclsh runme.tcl
+
+Example.class: Example.java
+ gcj -fPIC -C -c -g Example.java
+ gcjh Example
+
diff --git a/trunk/Examples/tcl/java/example.i b/trunk/Examples/tcl/java/example.i
new file mode 100644
index 000000000..b69d83f8d
--- /dev/null
+++ b/trunk/Examples/tcl/java/example.i
@@ -0,0 +1,8 @@
+%module example
+%include <cni.i>
+
+%{
+#include "Example.h"
+%}
+
+%include Example.h
diff --git a/trunk/Examples/tcl/java/runme.tcl b/trunk/Examples/tcl/java/runme.tcl
new file mode 100644
index 000000000..6caf0079f
--- /dev/null
+++ b/trunk/Examples/tcl/java/runme.tcl
@@ -0,0 +1,15 @@
+catch { load ./example[info sharedlibextension] example}
+
+JvCreateJavaVM NULL
+JvAttachCurrentThread NULL NULL
+Example e1 1
+Example e2 2
+
+puts "[e1 cget -mPublicInt]"
+puts "[e2 cget -mPublicInt]"
+
+puts "[e2 Add 1 2]"
+puts "[e2 Add 1.0 2.0]"
+puts "[e2 Add '1' '2']"
+
+JvDetachCurrentThread
diff --git a/trunk/Examples/tcl/multimap/Makefile b/trunk/Examples/tcl/multimap/Makefile
new file mode 100644
index 000000000..bed049a36
--- /dev/null
+++ b/trunk/Examples/tcl/multimap/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/tcl/multimap/example.c b/trunk/Examples/tcl/multimap/example.c
new file mode 100644
index 000000000..b8360fa8a
--- /dev/null
+++ b/trunk/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] = (char)toupper(str[i]);
+ }
+}
+
+void circle(double x, double y) {
+ double a = x*x + y*y;
+ if (a > 1.0) {
+ printf("Bad points %g, %g\n", x,y);
+ } else {
+ printf("Good points %g, %g\n", x,y);
+ }
+}
diff --git a/trunk/Examples/tcl/multimap/example.dsp b/trunk/Examples/tcl/multimap/example.dsp
new file mode 100644
index 000000000..c1568f2c5
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/multimap/example.i b/trunk/Examples/tcl/multimap/example.i
new file mode 100644
index 000000000..9a141b65a
--- /dev/null
+++ b/trunk/Examples/tcl/multimap/example.i
@@ -0,0 +1,80 @@
+/* File : example.i */
+%module example
+
+%{
+extern int gcd(int x, int y);
+extern int gcdmain(int argc, char *argv[]);
+extern int count(char *bytes, int len, char c);
+extern void capitalize (char *str, int len);
+extern void circle (double cx, double cy);
+extern int squareCubed (int n, int *OUTPUT);
+%}
+
+%include exception.i
+
+extern int gcd(int x, int y);
+
+%typemap(arginit) (int argc, char *argv[]) "$2 = 0;";
+
+%typemap(in) (int argc, char *argv[]) {
+ Tcl_Obj **listobjv = 0;
+ int i;
+ if (Tcl_ListObjGetElements(interp,$input, &$1, &listobjv) == TCL_ERROR) {
+ SWIG_exception(SWIG_ValueError,"Expected a list");
+ return TCL_ERROR;
+ }
+ $2 = (char **) malloc(($1+1)*sizeof(char *));
+ for (i = 0; i < $1; i++) {
+ $2[i] = Tcl_GetStringFromObj(listobjv[i],0);
+ }
+ $2[i] = 0;
+}
+
+%typemap(freearg) char *argv[] {
+ if ($1) {
+ free($1);
+ }
+}
+
+extern int gcdmain(int argc, char *argv[]);
+
+%typemap(in) (char *bytes, int len) {
+ $1 = Tcl_GetStringFromObj($input,&$2);
+}
+
+extern int count(char *bytes, int len, char c);
+
+
+/* This example shows how to wrap a function that mutates a string */
+
+%typemap(in) (char *str, int len) {
+ char *temp;
+ temp = Tcl_GetStringFromObj($input,&$2);
+ $1 = (char *) malloc($2+1);
+ memmove($1,temp,$2);
+}
+
+/* Return the mutated string as a new object. */
+
+%typemap(argout) (char *str, int len) {
+ Tcl_Obj *o;
+ o = Tcl_NewStringObj($1,$2);
+ Tcl_ListObjAppendElement(interp,$result,o);
+ free($1);
+}
+
+extern void capitalize(char *str, int len);
+
+
+/* A multi-valued constraint. Force two arguments to lie
+ inside the unit circle */
+
+%typemap(check) (double cx, double cy) {
+ double a = $1*$1 + $2*$2;
+ if (a > 1.0) {
+ SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
+ return TCL_ERROR;
+ }
+}
+
+extern void circle(double cx, double cy);
diff --git a/trunk/Examples/tcl/multimap/runme.tcl b/trunk/Examples/tcl/multimap/runme.tcl
new file mode 100644
index 000000000..bafa281f8
--- /dev/null
+++ b/trunk/Examples/tcl/multimap/runme.tcl
@@ -0,0 +1,24 @@
+# file: runme.tcl
+# Try to load as a dynamic module.
+
+catch { load ./example[info sharedlibextension] example}
+
+# Call our gcd() function
+set x 42
+set y 105
+set g [gcd $x $y]
+puts "The gcd of $x and $y is $g"
+
+# call the gcdmain
+gcdmain "gcdmain 42 105"
+
+
+# call count
+set c [count "Hello World" l]
+puts $c
+
+# call capitalize
+
+set c [capitalize "helloworld"]
+puts $c
+
diff --git a/trunk/Examples/tcl/operator/Makefile b/trunk/Examples/tcl/operator/Makefile
new file mode 100644
index 000000000..caf2f79e2
--- /dev/null
+++ b/trunk/Examples/tcl/operator/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/tcl/operator/example.h b/trunk/Examples/tcl/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/trunk/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/trunk/Examples/tcl/operator/example.i b/trunk/Examples/tcl/operator/example.i
new file mode 100644
index 000000000..fa5bccd06
--- /dev/null
+++ b/trunk/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/trunk/Examples/tcl/operator/runme.tcl b/trunk/Examples/tcl/operator/runme.tcl
new file mode 100644
index 000000000..3b7c06838
--- /dev/null
+++ b/trunk/Examples/tcl/operator/runme.tcl
@@ -0,0 +1,30 @@
+# Operator overloading example
+
+catch { load ./example[info sharedlibextension] example}
+
+set a [Complex -args 2 3]
+set b [Complex -args -5 10]
+
+puts "a = $a [$a str]"
+puts "b = $b [$b str]"
+
+set c [$a + $b]
+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/trunk/Examples/tcl/pointer/Makefile b/trunk/Examples/tcl/pointer/Makefile
new file mode 100644
index 000000000..bed049a36
--- /dev/null
+++ b/trunk/Examples/tcl/pointer/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/tcl/pointer/example.c b/trunk/Examples/tcl/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/pointer/example.i b/trunk/Examples/tcl/pointer/example.i
new file mode 100644
index 000000000..4d5b523bf
--- /dev/null
+++ b/trunk/Examples/tcl/pointer/example.i
@@ -0,0 +1,31 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/tcl/pointer/index.html b/trunk/Examples/tcl/pointer/index.html
new file mode 100644
index 000000000..407380240
--- /dev/null
+++ b/trunk/Examples/tcl/pointer/index.html
@@ -0,0 +1,171 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:pointer</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/tcl/pointer/</tt>
+<hr>
+
+<H2>Simple Pointer Handling</H2>
+
+<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. The only
+problem is how does one go about creating these objects from a script?
+
+<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>
+
+Now, in a script you would do this:
+
+<blockquote>
+<pre>
+set a [new_int 37]
+set b [new_int 42]
+set c [new_int 0]
+add $a $b $c
+set r [get_int $c]
+puts "Result = $r"
+delete_int $a
+delete_int $b
+delete_int $c
+</pre>
+</blockquote>
+
+<p>
+<li>Use the SWIG pointer library. For example, in the interface file
+you would do this:
+
+<blockquote>
+<pre>
+%include "pointer.i"
+</pre>
+</blockquote?
+
+and in a script you would do this:
+
+<blockquote>
+<pre>
+set a [ptrcreate int 37]
+set b [ptrcreate int 42]
+set c [ptrcreate int]
+add $a $b $c
+set r [ptrvalue $c]
+puts "Result = $r"
+ptrfree $a
+ptrfree $b
+ptrfree $c
+</pre>
+</blockquote>
+
+The advantage to using the pointer library is that it unifies some of the helper
+functions behind a common set of names. For example, the same set of functions work
+with int, double, float, and other fundamental types.
+
+<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 script:
+
+<blockquote>
+<pre>
+set r [add 37 42]
+puts "Result = $r"
+</pre>
+</blockquote>
+Needless to say, this is substantially easier.
+
+<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="runme.tcl">runme.tcl</a> (Tcl Script)
+</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 pointer.i library files can be
+found in the SWIG user manual. The files also contain documentation.
+
+<p>
+<li>The pointer.i library is designed primarily for convenience. If you
+are concerned about performance, you probably want to use a different
+approach.
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/tcl/pointer/runme.tcl b/trunk/Examples/tcl/pointer/runme.tcl
new file mode 100644
index 000000000..efe9bb495
--- /dev/null
+++ b/trunk/Examples/tcl/pointer/runme.tcl
@@ -0,0 +1,47 @@
+# file: runme.tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+# First create some objects using the pointer library.
+puts "Testing the pointer library"
+set a [new_intp]
+set b [new_intp]
+set c [new_intp] ;# Memory for result
+
+intp_assign $a 37
+intp_assign $b 42
+
+puts " a = $a"
+puts " b = $b"
+puts " c = $c"
+
+# Call the add() function with some pointers
+add $a $b $c
+
+# Now get the result
+set r [intp_value $c]
+puts " 37 + 42 = $r"
+
+# Clean up the pointers
+delete_intp $a
+delete_intp $b
+delete_intp $c
+
+# Now try the typemap library
+# This should be much easier. Now how it is no longer
+# necessary to manufacture pointers.
+
+puts "Trying the typemap library"
+set r [sub 37 42]
+puts " 37 - 42 = $r"
+
+# Now try the version with multiple return values
+
+puts "Testing multiple return values"
+set qr [divide 42 37]
+set q [lindex $qr 0]
+set r [lindex $qr 1]
+puts " 42/37 = $q remainder $r"
+
+
+
diff --git a/trunk/Examples/tcl/reference/Makefile b/trunk/Examples/tcl/reference/Makefile
new file mode 100644
index 000000000..c01283c20
--- /dev/null
+++ b/trunk/Examples/tcl/reference/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' 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/trunk/Examples/tcl/reference/example.cxx b/trunk/Examples/tcl/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/trunk/Examples/tcl/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include <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 %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/trunk/Examples/tcl/reference/example.h b/trunk/Examples/tcl/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/reference/example.i b/trunk/Examples/tcl/reference/example.i
new file mode 100644
index 000000000..6daa3b1f4
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/reference/index.html b/trunk/Examples/tcl/reference/index.html
new file mode 100644
index 000000000..ef799fa90
--- /dev/null
+++ b/trunk/Examples/tcl/reference/index.html
@@ -0,0 +1,147 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:reference</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/tcl/reference/</tt>
+<hr>
+
+<H2>C++ Reference Handling</H2>
+
+<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 &amp;a, const Vector &amp;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 &amp;a, const Vector &amp;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 &amp;operator[](int index);
+</pre>
+</blockquote>
+
+or a method:
+
+<blockquote>
+<pre>
+Vector &amp;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 &amp;result = self-&gt;get(index);
+ return &amp;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 &amp;get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &amp;a) {
+ (*self)[index] = a;
+ }
+ }
+ ...
+}
+</pre>
+</blockquote>
+
+Click <a href="example.i">here</a> to see a SWIG interface file with these additions.
+
+<h2>Sample Tcl scripts</h2>
+
+Click <a href="runme.tcl">here</a> to see a script that manipulates some C++ references.
+
+<h2>Notes:</h2>
+
+<ul>
+<li>C++ references primarily provide notational convenience for C++
+source code. However, Tcl has neither the 'x.a' or 'x-&gt;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/trunk/Examples/tcl/reference/runme.tcl b/trunk/Examples/tcl/reference/runme.tcl
new file mode 100644
index 000000000..6560cf4cd
--- /dev/null
+++ b/trunk/Examples/tcl/reference/runme.tcl
@@ -0,0 +1,76 @@
+# file: runme.tcl
+
+# This file illustrates the manipulation of C++ references in Tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+set a [new_Vector 3 4 5]
+set b [new_Vector 10 11 12]
+
+puts " Created [Vector_print $a]"
+puts " Created [Vector_print $b]"
+
+# ----- Call an overloaded operator -----
+
+# This calls the wrapper we placed around
+#
+# operator+(const Vector &a, const Vector &)
+#
+# It returns a new allocated object.
+
+puts "Adding a+b"
+set c [addv $a $b]
+puts " a+b = [Vector_print $c]"
+
+# Note: Unless we free the result, a memory leak will occur
+delete_Vector $c
+
+# ----- Create a vector array -----
+
+# Note: Using the high-level interface here
+puts "Creating an array of vectors"
+VectorArray va 10
+puts " va = [va cget -this]"
+
+
+# ----- Set some values in the array -----
+
+# These operators copy the value of $a and $b to the vector array
+va set 0 $a
+va set 1 $b
+
+# This will work, but it will cause a memory leak!
+
+va set 2 [addv $a $b]
+
+# The non-leaky way to do it
+
+set c [addv $a $b]
+va set 3 $c
+delete_Vector $c
+
+# Get some values from the array
+
+puts "Getting some array values"
+for {set i 0} {$i < 5} {incr i 1} {
+ puts " va($i) = [Vector_print [va get $i]]"
+}
+
+# Watch under resource meter to check on this
+puts "Making sure we don't leak memory."
+for {set i 0} {$i < 1000000} {incr i 1} {
+ set c [va get [expr {$i % 10}]]
+}
+
+# ----- Clean up -----
+puts "Cleaning up"
+
+rename va ""
+
+delete_Vector $a
+delete_Vector $b
+
+
diff --git a/trunk/Examples/tcl/simple/Makefile b/trunk/Examples/tcl/simple/Makefile
new file mode 100644
index 000000000..bed049a36
--- /dev/null
+++ b/trunk/Examples/tcl/simple/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/tcl/simple/example.c b/trunk/Examples/tcl/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/simple/example.dsp b/trunk/Examples/tcl/simple/example.dsp
new file mode 100644
index 000000000..c1568f2c5
--- /dev/null
+++ b/trunk/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 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(TCL_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(TCL_LIB)" /nologo /dll /machine:I386 /out:"example.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo TCL_INCLUDE: %TCL_INCLUDE%
+ echo TCL_LIB: %TCL_LIB%
+ echo on
+ ..\..\..\swig.exe -tcl8 $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/trunk/Examples/tcl/simple/example.i b/trunk/Examples/tcl/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/trunk/Examples/tcl/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/trunk/Examples/tcl/simple/index.html b/trunk/Examples/tcl/simple/index.html
new file mode 100644
index 000000000..333d90593
--- /dev/null
+++ b/trunk/Examples/tcl/simple/index.html
@@ -0,0 +1,97 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:simple</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/tcl/simple/</tt>
+<hr>
+
+<H2>Simple Tcl Example</H2>
+
+<p>
+This example illustrates how you can hook Tcl 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 &gt; 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 -tcl <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>example.so</tt>.
+</ol>
+
+<h2>Using the extension</h2>
+
+Click <a href="runme.tcl">here</a> to see a script that calls our C functions from Tcl.
+
+<h2>Key points</h2>
+
+<ul>
+<li>Use the <tt>load</tt> statement to load your extension module into Tcl. For example:
+<blockquote>
+<pre>
+load ./example.so
+</pre>
+</blockquote>
+
+<li>C functions work just like Tcl functions. For example:
+<blockquote>
+<pre>
+set g [gcd 42 105]
+</pre>
+</blockquote>
+
+<li>C global variables are accessed as Tcl variables. For example:
+<blockquote>
+<pre>
+set a $Foo
+set Foo $newvalue
+</pre>
+</blockquote>
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/tcl/simple/runme.tcl b/trunk/Examples/tcl/simple/runme.tcl
new file mode 100644
index 000000000..3a6ce10b5
--- /dev/null
+++ b/trunk/Examples/tcl/simple/runme.tcl
@@ -0,0 +1,22 @@
+# file: runme.tcl
+# Try to load as a dynamic module.
+
+catch { load ./example[info sharedlibextension] example}
+
+# Call our gcd() function
+set x 42
+set y 105
+set g [gcd $x $y]
+puts "The gcd of $x and $y is $g"
+
+# Manipulate the Foo global variable
+
+# Output its current value
+puts "Foo = $Foo"
+
+# Change its value
+set Foo 3.1415926
+
+# See if the change took effect
+puts "Foo = $Foo"
+
diff --git a/trunk/Examples/tcl/std_vector/Makefile b/trunk/Examples/tcl/std_vector/Makefile
new file mode 100644
index 000000000..ce6a3c7ce
--- /dev/null
+++ b/trunk/Examples/tcl/std_vector/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = my_tclsh
+DLTARGET = example
+INTERFACE = example.i
+LIBS = -lm
+
+all::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile tcl_clean
+
+check: all
diff --git a/trunk/Examples/tcl/std_vector/example.h b/trunk/Examples/tcl/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/std_vector/example.i b/trunk/Examples/tcl/std_vector/example.i
new file mode 100644
index 000000000..aa58b66e0
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/std_vector/runme.tcl b/trunk/Examples/tcl/std_vector/runme.tcl
new file mode 100644
index 000000000..2cece9691
--- /dev/null
+++ b/trunk/Examples/tcl/std_vector/runme.tcl
@@ -0,0 +1,40 @@
+# file: runme.tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+# Exercise IntVector
+
+set iv [IntVector]
+$iv push 1
+$iv push 3
+$iv push 5
+
+puts "IntVector size: [$iv size] (should be 3)"
+puts "IntVector average: [average $iv] (should be 3.0)"
+puts "IntVector pop: [$iv pop] (should be 5)"
+puts "IntVector pop: [$iv pop] (should be 3)"
+puts "IntVector get 0: [$iv get 0] (should be 1)"
+puts ""
+
+# Exercise DoubleVector
+
+set dv [DoubleVector]
+$dv push 2
+$dv push 4
+$dv push 6
+
+puts "DoubleVector size: [$dv size] (should be 3)"
+puts "DoubleVector data: [$dv get 0] [$dv get 1] [$dv get 2] (should be 2.0 4.0 6.0)"
+halve_in_place $dv
+puts "DoubleVector halved: [$dv get 0] [$dv get 1] [$dv get 2] (should be 1.0 2.0 3.0)"
+puts ""
+
+# Complain if unknown is called
+rename unknown unknown_orig
+proc unknown {args} {
+ puts "ERROR: unknown called with: $args"
+ uplevel 1 unknown_orig $args
+}
+
+puts "average \"1 2 3\": [average [list 1 2 3]]"
+
diff --git a/trunk/Examples/tcl/value/Makefile b/trunk/Examples/tcl/value/Makefile
new file mode 100644
index 000000000..bed049a36
--- /dev/null
+++ b/trunk/Examples/tcl/value/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/tcl/value/example.c b/trunk/Examples/tcl/value/example.c
new file mode 100644
index 000000000..4ed2fe10a
--- /dev/null
+++ b/trunk/Examples/tcl/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/trunk/Examples/tcl/value/example.h b/trunk/Examples/tcl/value/example.h
new file mode 100644
index 000000000..212cf4bdb
--- /dev/null
+++ b/trunk/Examples/tcl/value/example.h
@@ -0,0 +1,5 @@
+/* File : example.h */
+
+typedef struct {
+ double x, y, z;
+} Vector;
diff --git a/trunk/Examples/tcl/value/example.i b/trunk/Examples/tcl/value/example.i
new file mode 100644
index 000000000..98fd60ed5
--- /dev/null
+++ b/trunk/Examples/tcl/value/example.i
@@ -0,0 +1,32 @@
+// Tests SWIG's handling of pass-by-value for complex datatypes
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Some functions that manipulate Vectors by value */
+%inline %{
+extern double dot_product(Vector a, Vector b);
+extern Vector vector_add(Vector a, Vector b);
+%}
+
+/* Include this because the vector_add() function will leak memory */
+void free(void *);
+
+/* Some helper functions for our interface */
+%inline %{
+
+Vector *new_Vector(double x, double y, double z) {
+ Vector *v = (Vector *) malloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+}
+
+void vector_print(Vector *v) {
+ printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+%}
+
diff --git a/trunk/Examples/tcl/value/index.html b/trunk/Examples/tcl/value/index.html
new file mode 100644
index 000000000..17a991ecf
--- /dev/null
+++ b/trunk/Examples/tcl/value/index.html
@@ -0,0 +1,122 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:value</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/tcl/value/</tt>
+<hr>
+
+<H2>Passing and Returning Structures by Value</H2>
+
+<p>
+Occasionally, a C program will manipulate structures by value such as shown in the
+following code:
+
+<blockquote>
+<pre>
+/* File : example.c */
+
+typedef struct Vector {
+ double x, y, z;
+} Vector;
+
+double dot_product(Vector a, Vector b) {
+ return (a.x*b.x + a.y*b.y + a.z*b.z);
+}
+
+Vector vector_add(Vector a, Vector b) {
+ Vector r;
+ r.x = a.x + b.x;
+ r.y = a.y + b.y;
+ r.z = a.z + b.z;
+ return r;
+}
+</pre>
+</blockquote>
+
+Since SWIG only knows how to manage pointers to structures (not their internal
+representation), the following translations are made when wrappers are
+created:
+
+<blockquote>
+<pre>
+double wrap_dot_product(Vector *a, Vector *b) {
+ return dot_product(*a,*b);
+}
+
+Vector *wrap_vector_add(Vector *a, Vector *b) {
+ Vector *r = (Vector *) malloc(sizeof(Vector));
+ *r = vector_add(*a,*b);
+ return r;
+}
+</pre>
+</blockquote>
+
+The functions are then called using pointers from the scripting language interface.
+It should also be noted that any function that returns a structure by value results
+in an implicit memory allocation. This will be a memory leak unless you take steps
+to free the result (see below).
+
+<h2>The SWIG interface</h2>
+
+Click <a href="example.i">here</a> to see a SWIG interface file that
+wraps these two functions. In this file, there are a few essential features:
+
+<ul>
+<li>A wrapper for the <tt>free()</tt> function is created so that we
+can clean up the return result created by <tt>vector_add()</tt>
+function.
+
+<p>
+<li>The %inline directive is used to create a few helper functions for creating new Vector
+objects and to print out the value (for debugging purposes).
+</ul>
+
+<h2>A Tcl Script</h2>
+
+Click <a href="runme.tcl">here</a> to see a script that uses these functions from Tcl.
+
+<h2>Notes</h2>
+
+<ul>
+<li>When the '<tt>-c++</tt>' option is used, the resulting wrapper code for the return value
+changes to the following:
+
+<blockquote>
+<pre>
+Vector *wrap_vector_add(Vector *a, Vector *b) {
+ Vector *r = new Vector(vector_add(*a,*b));
+ return r;
+}
+</pre>
+</blockquote>
+
+Similarly, it would be a mistake to use the <tt>free()</tt> function from C++. A safer
+approach would be to write a helper function like this:
+
+<blockquote>
+<pre>
+%inline %{
+ void delete_Vector(Vector *v) {
+ delete v;
+ }
+%}
+</pre>
+</blockquote>
+
+<p>
+<li>Passing parameters by value like this really isn't the best C programming style.
+If possible, you might change your application to use pointers.
+
+<p>
+<li>Similar translations are made when C++ references are used.
+
+
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/trunk/Examples/tcl/value/runme.tcl b/trunk/Examples/tcl/value/runme.tcl
new file mode 100644
index 000000000..1f6f4afa6
--- /dev/null
+++ b/trunk/Examples/tcl/value/runme.tcl
@@ -0,0 +1,39 @@
+# file: runme.tcl
+# Try to load as a dynamic module.
+
+catch { load ./example[info sharedlibextension] example}
+
+# Create a couple of a vectors
+
+set v [new_Vector 1 2 3]
+set w [new_Vector 10 11 12]
+
+puts "I just created the following vectors"
+vector_print $v
+vector_print $w
+
+# Now call some of our functions
+
+puts "\nNow I'm going to compute the dot product"
+set d [dot_product $v $w]
+puts "dot product = $d (should be 68)"
+
+# Add the vectors together
+
+puts "\nNow I'm going to add the vectors together"
+set r [vector_add $v $w]
+vector_print $r
+puts "The value should be (11,13,15)"
+
+# Now I'd better clean up the return result r
+
+puts "\nNow I'm going to clean up the return result"
+free $r
+
+puts "Good"
+
+
+
+
+
+
diff --git a/trunk/Examples/tcl/variables/Makefile b/trunk/Examples/tcl/variables/Makefile
new file mode 100644
index 000000000..bed049a36
--- /dev/null
+++ b/trunk/Examples/tcl/variables/Makefile
@@ -0,0 +1,19 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-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/trunk/Examples/tcl/variables/example.c b/trunk/Examples/tcl/variables/example.c
new file mode 100644
index 000000000..aa4ffe9b3
--- /dev/null
+++ b/trunk/Examples/tcl/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <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[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/trunk/Examples/tcl/variables/example.h b/trunk/Examples/tcl/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/trunk/Examples/tcl/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/trunk/Examples/tcl/variables/example.i b/trunk/Examples/tcl/variables/example.i
new file mode 100644
index 000000000..9d0101cb7
--- /dev/null
+++ b/trunk/Examples/tcl/variables/example.i
@@ -0,0 +1,51 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/trunk/Examples/tcl/variables/index.html b/trunk/Examples/tcl/variables/index.html
new file mode 100644
index 000000000..245a445d5
--- /dev/null
+++ b/trunk/Examples/tcl/variables/index.html
@@ -0,0 +1,76 @@
+<html>
+<head>
+<title>SWIG:Examples:tcl:variables</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/tcl/variables/</tt>
+<hr>
+
+<H2>Wrapping C Global Variables</H2>
+
+<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 Tcl
+variable that works exactly like you would expect in a Tcl script, but which magically
+retrieves or updates the value of the underlying C variable.
+Click <a href="example.i">here</a> to see a SWIG interface with some variable declarations in it.
+
+<h2>Manipulating Variables from Tcl</h2>
+
+Click <a href="runme.tcl">here</a> to see a script that updates and prints out the values of
+the variables defined in the above file. Notice how the C global variables work just
+like normal Tcl variables.
+
+<h2>Key points</h2>
+
+<ul>
+<li>The <tt>set</tt> statement changes the value of the corresponding C global variable.
+<li>Whenever you access the value of a variable such as <tt>$ivar</tt>, the value
+of the C global variable is read.
+<li>If a C program changes a global variable independently of Tcl, this change is
+automatically reflected in the Tcl variable (i.e., reads will always return the
+most up to date value of the variable).
+<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 Tcl, 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 Tcl strings, but
+when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
+<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 scripting interface and resulting memory management
+is much trickier than simply creating a wrapper function.
+<p>
+<li>You may be better off hiding global variables behind a function based
+interface.
+</ul>
+
+</body>
+</html>
+<hr>
diff --git a/trunk/Examples/tcl/variables/runme.tcl b/trunk/Examples/tcl/variables/runme.tcl
new file mode 100644
index 000000000..b9e2fd418
--- /dev/null
+++ b/trunk/Examples/tcl/variables/runme.tcl
@@ -0,0 +1,76 @@
+# file: runme.tcl
+
+catch { load ./example[info sharedlibextension] example}
+
+# Try to set the values of some global variables
+
+set ivar 42
+set svar -31000
+set lvar 65537
+set uivar 123456
+set usvar 61000
+set ulvar 654321
+set scvar -13
+set ucvar 251
+set cvar "S"
+set fvar 3.14159
+set dvar 2.1828
+set strvar "Hello World"
+set iptrvar [new_int 37]
+set ptptr [new_Point 37 42]
+set name "Bill"
+
+# Now print out the values of the variables
+
+puts "Variables (values printed from Tcl)"
+
+puts "ivar = $ivar"
+puts "svar = $svar"
+puts "lvar = $lvar"
+puts "uivar = $uivar"
+puts "usvar = $usvar"
+puts "ulvar = $ulvar"
+puts "scvar = $scvar"
+puts "ucvar = $ucvar"
+puts "fvar = $fvar"
+puts "dvar = $dvar"
+puts "cvar = $cvar"
+puts "strvar = $strvar"
+puts "cstrvar = $cstrvar"
+puts "iptrvar = $iptrvar"
+puts "name = $name"
+puts "ptptr = $ptptr [Point_print $ptptr]"
+puts "pt = $pt [Point_print $pt]"
+
+puts "\nVariables (values printed from C)"
+
+print_vars
+
+puts "\nNow I'm going to try and modify some read only variables";
+
+puts " Tring to set 'path'";
+if { [catch {
+ set path "Whoa!"
+ puts "Hey, what's going on?!?! This shouldn't work"
+}]} {
+ puts "Good."
+}
+
+puts " Trying to set 'status'";
+if { [catch {
+ set status 0
+ puts "Hey, what's going on?!?! This shouldn't work"
+}]} {
+ puts "Good."
+}
+
+puts "\nI'm going to try and update a structure variable.\n"
+
+set pt $ptptr
+
+puts "The new value is"
+pt_print
+puts "You should see the value [Point_print $ptptr]"
+
+
+
diff --git a/trunk/Examples/test-suite/README b/trunk/Examples/test-suite/README
new file mode 100644
index 000000000..96dea942c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/abstract_access.i b/trunk/Examples/test-suite/abstract_access.i
new file mode 100644
index 000000000..557f23154
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_access.i
@@ -0,0 +1,36 @@
+%module abstract_access
+
+%warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) A;
+
+%inline %{
+class A {
+public:
+ virtual ~A()
+ {
+ }
+
+private:
+ virtual int x() = 0;
+protected:
+ virtual int y() = 0;
+public:
+ virtual int z() = 0;
+ int do_x() { return x(); }
+};
+
+class B : public A {
+private:
+ virtual int x() { return y(); }
+};
+
+class C : public B {
+protected:
+ virtual int y() { return z(); }
+};
+
+class D : public C {
+private:
+ virtual int z() { return 1; }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/abstract_inherit.i b/trunk/Examples/test-suite/abstract_inherit.i
new file mode 100644
index 000000000..3fe1f67c0
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_inherit.i
@@ -0,0 +1,62 @@
+%module abstract_inherit
+
+%warnfilter(SWIGWARN_TYPE_ABSTRACT) Spam;
+%warnfilter(SWIGWARN_TYPE_ABSTRACT) Bar;
+
+%inline %{
+
+class Foo {
+public:
+ virtual ~Foo()
+ {
+ }
+
+ virtual int blah() = 0;
+};
+
+class Bar : public Foo { };
+
+class Spam: public Foo {
+public:
+ Spam() { }
+};
+
+
+template <class Type>
+class NRFilter {
+public:
+ virtual ~NRFilter()
+ {
+ }
+
+protected:
+ virtual void do_filter() = 0;
+};
+
+template <class Type>
+class NRRCFilter : public NRFilter<Type>
+{
+};
+
+
+template <class Type>
+class NRRCFilterpro : protected NRFilter<Type>
+{
+};
+
+
+template <class Type>
+class NRRCFilterpri : private NRFilter<Type>
+{
+};
+
+%}
+
+%template(NRFilter_i) NRFilter<int>;
+
+%template(NRRCFilter_i) NRRCFilter<int>;
+
+%template(NRRCFilterpro_i) NRRCFilterpro<int>;
+
+%template(NRRCFilterpri_i) NRRCFilterpri<int>;
+
diff --git a/trunk/Examples/test-suite/abstract_inherit_ok.i b/trunk/Examples/test-suite/abstract_inherit_ok.i
new file mode 100644
index 000000000..cb40fa436
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_inherit_ok.i
@@ -0,0 +1,22 @@
+%module abstract_inherit_ok
+
+%feature("notabstract") Spam;
+%warnfilter(SWIGWARN_TYPE_ABSTRACT) Spam;
+
+%inline %{
+
+class Foo {
+public:
+ virtual ~Foo() { }
+ virtual int blah() = 0;
+};
+
+class Spam: public Foo {
+public:
+ Spam() { }
+#ifndef SWIG
+ int blah() { return 0; }
+#endif
+};
+
+%}
diff --git a/trunk/Examples/test-suite/abstract_signature.i b/trunk/Examples/test-suite/abstract_signature.i
new file mode 100644
index 000000000..5d68fd0a9
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_signature.i
@@ -0,0 +1,26 @@
+%module abstract_signature
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) abstract_foo; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) abstract_bar; // Ruby, wrong class name
+
+%inline %{
+class abstract_foo
+{
+public:
+ abstract_foo() { };
+ virtual ~abstract_foo() { };
+ virtual int meth(int meth_param) = 0;
+};
+
+
+class abstract_bar : public abstract_foo
+{
+public:
+ abstract_bar() { };
+
+ virtual ~abstract_bar() { };
+ virtual int meth(int meth_param) = 0;
+ int meth(int meth_param_1, int meth_param_2) { return 0; }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/abstract_typedef.i b/trunk/Examples/test-suite/abstract_typedef.i
new file mode 100644
index 000000000..456cfc207
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_typedef.i
@@ -0,0 +1,56 @@
+%module abstract_typedef
+
+
+%inline %{
+ struct Engine
+ {
+ };
+
+ struct AbstractBaseClass
+ {
+ virtual ~AbstractBaseClass()
+ {
+ }
+
+ virtual bool write(Engine& archive) const = 0;
+ };
+
+ typedef Engine PersEngine;
+ typedef AbstractBaseClass PersClassBase;
+
+
+ class A : public PersClassBase
+ {
+ // This works always
+ // bool write(Engine& archive) const;
+
+ // This doesn't with Swig 1.3.17.
+ // But it works fine with 1.3.16
+ bool write(PersEngine& archive) const
+ {
+ return true;
+ }
+
+
+ };
+
+%}
+
+
+/*
+
+Problem related to the direct comparison of strings
+in the file allocate.cxx (line 55)
+
+ ......
+ String *local_decl = Getattr(dn,"decl");
+ if (local_decl && !Strcmp(local_decl, base_decl)) {
+ ......
+
+with the direct string comparison, no equivalent types
+are checked and the two 'write' functions appear to be
+different because
+
+ "q(const).f(r.bss::PersEngine)." != "q(const).f(r.bss::Engine)."
+
+*/
diff --git a/trunk/Examples/test-suite/abstract_typedef2.i b/trunk/Examples/test-suite/abstract_typedef2.i
new file mode 100644
index 000000000..450af391e
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_typedef2.i
@@ -0,0 +1,60 @@
+%module abstract_typedef2
+
+ /*
+ After the fix for abstract_typedef, this simpler
+ example got broken.
+ */
+
+%inline %{
+
+ enum FieldDim {
+ UnaryField,
+ BinaryField
+ };
+
+ template <FieldDim Dim>
+ struct Facet;
+
+
+ template <FieldDim Dim>
+ struct Base
+ {
+ virtual ~Base() {}
+
+ typedef unsigned int size_type;
+ typedef Facet<Dim>* facet_ptr;
+
+ // This works
+ // virtual Facet<Dim>* set(size_type) = 0;
+
+ // This doesn't
+ virtual facet_ptr set(size_type) = 0;
+ };
+
+
+ template <FieldDim Dim>
+ struct Facet
+ {
+ };
+
+
+ template <FieldDim Dim>
+ struct A : Base<Dim>
+ {
+ typedef Base<Dim> base;
+ typedef typename base::size_type size_type;
+
+ A(int a = 0)
+ {
+ }
+
+ Facet<Dim>* set(size_type)
+ {
+ return 0;
+ }
+ };
+%}
+
+
+%template(Base_UF) Base<UnaryField>;
+%template(A_UF) A<UnaryField>;
diff --git a/trunk/Examples/test-suite/abstract_virtual.i b/trunk/Examples/test-suite/abstract_virtual.i
new file mode 100644
index 000000000..2e4d105b1
--- /dev/null
+++ b/trunk/Examples/test-suite/abstract_virtual.i
@@ -0,0 +1,67 @@
+%module(ruby_minherit="1") abstract_virtual
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
+
+%inline %{
+#if defined(_MSC_VER)
+ #pragma warning( disable : 4250) // warning C4250: 'D' : inherits 'B::B::foo' via dominance
+#endif
+ struct A
+ {
+ virtual ~A()
+ {
+ }
+
+ virtual int foo() = 0;
+ };
+
+ struct B : virtual A
+ {
+ int foo()
+ {
+ return 0;
+ }
+ };
+
+ struct C: virtual A
+ {
+ protected:
+ C()
+ {
+ }
+ };
+
+ //
+ // This case works
+ //
+ struct D : B, C
+ {
+ D()
+ {
+ }
+ };
+
+ //
+ // This case doesn't work.
+ // It seems the is_abstract function doesn't
+ // navigate the entire set of base classes,
+ // and therefore, it doesn't detect B::foo()
+ //
+#ifdef SWIG
+ // Uncommenting this line, of course, make it works
+ // %feature("notabstract") E;
+#endif
+ //
+ struct E : C, B
+ {
+ E()
+ {
+ }
+ };
+%}
+
diff --git a/trunk/Examples/test-suite/access_change.i b/trunk/Examples/test-suite/access_change.i
new file mode 100644
index 000000000..aca5af36f
--- /dev/null
+++ b/trunk/Examples/test-suite/access_change.i
@@ -0,0 +1,51 @@
+%module access_change
+
+// test access changing from protected to public
+
+%inline %{
+
+template<typename T> class Base {
+public:
+ virtual ~Base() {}
+ virtual int *PublicProtectedPublic1() { return 0; }
+ int *PublicProtectedPublic2() { return 0; }
+ virtual int *PublicProtectedPublic3() { return 0; }
+ int *PublicProtectedPublic4() { return 0; }
+protected:
+ virtual int * WasProtected1() { return 0; }
+ int * WasProtected2() { return 0; }
+ virtual int * WasProtected3() { return 0; }
+ int * WasProtected4() { return 0; }
+};
+
+template<typename T> class Derived : public Base<T> {
+public:
+ int * WasProtected1() { return 0; }
+ int * WasProtected2() { return 0; }
+ using Base<T>::WasProtected3;
+ using Base<T>::WasProtected4;
+protected:
+ virtual int *PublicProtectedPublic1() { return 0; }
+ int *PublicProtectedPublic2() { return 0; }
+ using Base<T>::PublicProtectedPublic3;
+ using Base<T>::PublicProtectedPublic4;
+};
+
+template<typename T> class Bottom : public Derived<T> {
+public:
+ int * WasProtected1() { return 0; }
+ int * WasProtected2() { return 0; }
+ using Base<T>::WasProtected3;
+ using Base<T>::WasProtected4;
+ int *PublicProtectedPublic1() { return 0; }
+ int *PublicProtectedPublic2() { return 0; }
+ int *PublicProtectedPublic3() { return 0; }
+ int *PublicProtectedPublic4() { return 0; }
+};
+%}
+
+%template(BaseInt) Base<int>;
+%template(DerivedInt) Derived<int>;
+%template(BottomInt) Bottom<int>;
+
+
diff --git a/trunk/Examples/test-suite/add_link.i b/trunk/Examples/test-suite/add_link.i
new file mode 100644
index 000000000..dfd4b376d
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/aggregate.i b/trunk/Examples/test-suite/aggregate.i
new file mode 100644
index 000000000..dc00f0605
--- /dev/null
+++ b/trunk/Examples/test-suite/aggregate.i
@@ -0,0 +1,37 @@
+/* This file tests a few new contract features.
+ First it checks to make sure the constant aggregation macro
+ %aggregate_check() works. This is defined in swig.swg.
+
+ Next, it checks to make sure a simple contract works.
+ To support contracts, you need to add a macro to the runtime.
+ For Python, it looks like this:
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg #expr ); goto fail; } else
+
+ Note: It is used like this:
+ SWIG_contract_assert(x == 1, "Some kind of error message");
+
+ Note: Contracts are still experimental. The runtime interface may
+ change in future versions.
+ */
+
+%module aggregate
+
+%include <exception.i>
+%aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT)
+
+%contract move(int x) {
+require:
+ check_direction(x);
+}
+
+%inline %{
+#define UP 1
+#define DOWN 2
+#define LEFT 3
+#define RIGHT 4
+
+int move(int direction) {
+ return direction;
+}
+%}
diff --git a/trunk/Examples/test-suite/allegrocl/Makefile.in b/trunk/Examples/test-suite/allegrocl/Makefile.in
new file mode 100644
index 000000000..5f75bfc08
--- /dev/null
+++ b/trunk/Examples/test-suite/allegrocl/Makefile.in
@@ -0,0 +1,126 @@
+#######################################################################
+# Makefile for allegrocl test-suite
+#######################################################################
+
+LANGUAGE = allegrocl
+ALLEGROCL = @ALLEGROCLBIN@
+SCRIPTSUFFIX = _runme.lisp
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+
+# these cpp tests generate warnings/errors when compiling
+# the wrapper .cxx file.
+CPP_TEST_BROKEN_CXX =
+# the error is wrap:action code generated by swig. \
+# error: can't convert [std::string] 'b' to 'bool' \
+# might just need a bool overload op for std::string. \
+ global_vars \
+# same as w/ global_vars but with more errors in cxx file \
+ naturalvar \
+
+# these cpp tests aren't working. Fix 'em
+# need to further separate these into tests requiring
+# std libraries, or the $ldestructor problem.
+CPP_TEST_BROKEN_ACL = \
+ contract \
+ allprotected \
+# 'throws' typemap entries. \
+ cplusplus_throw \
+# 'throws' typemap entries. \
+ default_args \
+# missing typemaps. suspect module support needed \
+ dynamic_cast \
+ extend_variable \
+# cdata.i support needed \
+ li_cdata \
+# warning generated. otherwise all good. \
+ operator_overload \
+# std_common.i support \
+ sizet \
+# std_vector.i support. \
+ template_default \
+# *** line 31. can't copy typemap?? \
+ typemap_namespace \
+
+# these aren't working due to longlong support. (low hanging fruit)
+CPP_TEST_BROKEN_LONGLONG = \
+ arrays_dimensionless \
+ arrays_global \
+ arrays_global_twodim \
+ li_typemaps \
+ li_windows \
+ long_long_apply \
+ primitive_ref \
+ reference_global_vars \
+ template_default_arg
+
+# These are currently unsupported.
+CPP_TEST_CASES_ACL_UNSUPPORTED = \
+# contract support \
+ aggregate \
+# directors support \
+ apply_signed_char \
+# contract support \
+ contract \
+ director_exception \
+ director_protected \
+ exception_order \
+# 'throws' typemap support \
+ extern_throws \
+ throw_exception \
+ using_pointers \
+
+C_TEST_CASES_ACL_BROKEN = \
+# 'cdate.i' module support \
+ li_cdata \
+# adding an existing type defnition... \
+ typedef_struct \
+# swigrun.swg support. \
+ typemap_subst
+
+C_TEST_BROKEN_LONGLONG = \
+ long_long
+
+
+# std lib support hasn't been done yet.
+SKIP_CPP_STD_CASES = Yes
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# SWIGOPT += -debug-module 4
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.lisp appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+%.clean:
+ @rm -f $*.cl
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
+
diff --git a/trunk/Examples/test-suite/allowexcept.i b/trunk/Examples/test-suite/allowexcept.i
new file mode 100644
index 000000000..37b01cd75
--- /dev/null
+++ b/trunk/Examples/test-suite/allowexcept.i
@@ -0,0 +1,73 @@
+// Test allowexcept feature
+
+%module allowexcept
+
+// First make sure %exception is not used by default for variable wrappers
+
+%nodefaultctor;
+%nodefaultdtor;
+%exception {
+ This will not compile
+}
+
+%inline %{
+struct UVW {};
+UVW uvw_global_variable;
+struct Bar {
+ UVW member_variable;
+ static UVW static_member_variable;
+};
+UVW Bar::static_member_variable;
+%}
+
+
+// Now test the allowexcept feature by making the usual $action uncompileable and ensuring the %exception is picked up
+
+struct XYZ {
+};
+
+// The operator& trick doesn't work for SWIG/PHP because the generated code
+// takes the address of the variable in the code in the "vinit" section.
+#ifdef SWIGPHP
+%{
+struct XYZ {
+ void foo() {}
+private:
+ XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
+};
+%}
+#else
+%{
+struct XYZ {
+ void foo() {}
+private:
+ XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
+ XYZ* operator&(); // prevent dereferencing used in normally generated get method
+};
+%}
+#endif
+#if defined(SWIGUTL)
+%exception {
+ /*
+ $action
+ */
+ SWIG_fail;
+}
+#else
+%exception {
+ /*
+ $action
+ */
+}
+#endif
+%allowexception;
+
+%inline %{
+XYZ global_variable;
+struct Foo {
+ XYZ member_variable;
+ static XYZ static_member_variable;
+};
+XYZ Foo::static_member_variable;
+%}
+
diff --git a/trunk/Examples/test-suite/allprotected.i b/trunk/Examples/test-suite/allprotected.i
new file mode 100644
index 000000000..bd4dfe5c7
--- /dev/null
+++ b/trunk/Examples/test-suite/allprotected.i
@@ -0,0 +1,78 @@
+// Tests for the allprotected option
+
+%module(directors="1", allprotected="1") allprotected
+
+%{
+#include <string>
+%}
+
+%include "std_string.i"
+
+%feature("director") PublicBase;
+%feature("director") ProtectedBase;
+
+// protected types not supported (ProtectedEnum, IntegerType). Make sure they can be ignored.
+%ignore ProtectedBase::protectedenum;
+%ignore ProtectedBase::typedefs;
+
+%inline %{
+class Klass {
+ std::string name;
+public:
+ Klass(const std::string& n) : name(n) {}
+ std::string getName() { return name; }
+};
+
+class PublicBase {
+ std::string str;
+public:
+ enum AnEnum { EnumVal1, EnumVal2 };
+public:
+ PublicBase(const char* s): str(s), instanceMemberVariable(0), anEnum(EnumVal1), stringMember(0) {}
+ virtual ~PublicBase() { }
+ virtual std::string virtualMethod() const { return "PublicBase"; }
+ Klass instanceMethod(Klass k) const { return k; }
+ Klass *instanceOverloaded(Klass *k) const { return k; }
+ Klass *instanceOverloaded(Klass *k, std::string name) const { return new Klass(name); }
+ static Klass staticMethod(Klass k) { return k; }
+ static Klass *staticOverloaded(Klass *k) { return k; }
+ static Klass *staticOverloaded(Klass *k, std::string name) { return new Klass(name); }
+ int instanceMemberVariable;
+ static int staticMemberVariable;
+ static const int staticConstMemberVariable = 20;
+ AnEnum anEnum;
+ char *stringMember;
+};
+int PublicBase::staticMemberVariable = 10;
+
+class ProtectedBase {
+ std::string str;
+public:
+ enum AnEnum { EnumVal1, EnumVal2 };
+ std::string getName() { return str; }
+protected:
+ ProtectedBase(const char* s): str(s), instanceMemberVariable(0), anEnum(EnumVal1), stringMember(0), protectedenum(ProtEnumVal1) {}
+ virtual ~ProtectedBase() { }
+ virtual std::string virtualMethod() const { return "ProtectedBase"; }
+ Klass instanceMethod(Klass k) const { return k; }
+ Klass *instanceOverloaded(Klass *k) const { return k; }
+ Klass *instanceOverloaded(Klass *k, std::string name) const { return new Klass(name); }
+ static Klass staticMethod(Klass k) { return k; }
+ static Klass *staticOverloaded(Klass *k) { return k; }
+ static Klass *staticOverloaded(Klass *k, std::string name) { return new Klass(name); }
+ int instanceMemberVariable;
+ static int staticMemberVariable;
+ static const int staticConstMemberVariable = 20;
+ AnEnum anEnum;
+ char *stringMember;
+
+// unsupported: types defined with protected access and thus methods/variables which use them
+ enum ProtectedEnum { ProtEnumVal1, ProtEnumVal2 };
+ typedef int IntegerType;
+ ProtectedEnum protectedenum;
+ IntegerType typedefs(IntegerType it) { return it; }
+};
+int ProtectedBase::staticMemberVariable = 10;
+
+%}
+
diff --git a/trunk/Examples/test-suite/anonymous_bitfield.i b/trunk/Examples/test-suite/anonymous_bitfield.i
new file mode 100644
index 000000000..309f82caf
--- /dev/null
+++ b/trunk/Examples/test-suite/anonymous_bitfield.i
@@ -0,0 +1,17 @@
+%module anonymous_bitfield
+
+%inline %{
+
+struct Foo {
+ int x : 4;
+ int y : 4;
+ int : 2;
+ unsigned int f : 1;
+ unsigned int : 5;
+ int z : 15;
+ unsigned int : 8+6;
+ unsigned seq : (sizeof(unsigned)*8 - 6);
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/apply_signed_char.i b/trunk/Examples/test-suite/apply_signed_char.i
new file mode 100644
index 000000000..c0fa00cfe
--- /dev/null
+++ b/trunk/Examples/test-suite/apply_signed_char.i
@@ -0,0 +1,37 @@
+/* Test %apply for char */
+
+%module(directors="1") apply_signed_char
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest;
+
+%apply signed char {char, const char};
+%apply const signed char & {const char &};
+
+%inline %{
+ char CharValFunction(char number) { return number; }
+ const char CCharValFunction(const char number) { return number; }
+ const char & CCharRefFunction(const char & number) { return number; }
+ char globalchar = -109;
+ const char globalconstchar = -110;
+%}
+
+// Director test
+%feature("director");
+
+%inline %{
+ struct DirectorTest {
+
+ DirectorTest() : memberchar(-111), memberconstchar(-112) {}
+
+ virtual char CharValFunction(char number) { return number; }
+ virtual const char CCharValFunction(const char number) { return number; }
+ virtual const char & CCharRefFunction(const char & number) { return number; }
+
+ char memberchar;
+ const char memberconstchar;
+
+ virtual ~DirectorTest() {}
+ private:
+ DirectorTest& operator=(const DirectorTest &);
+ };
+%}
diff --git a/trunk/Examples/test-suite/apply_strings.i b/trunk/Examples/test-suite/apply_strings.i
new file mode 100644
index 000000000..54a91f83a
--- /dev/null
+++ b/trunk/Examples/test-suite/apply_strings.i
@@ -0,0 +1,78 @@
+/* Test %apply for char *, signed char *, unsigned char *
+ This won't work in all situations, so does not necessarily have to be implemented. See
+ http://groups.google.com.ai/group/comp.lang.c++.moderated/browse_thread/thread/ad5873ce25d49324/0ae94552452366be?lnk=raot */
+%module(directors="1") apply_strings
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest;
+%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) DigitsGlobalB;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) DigitsGlobalC;
+
+%apply char * {UCharPtr};
+%apply char * {SCharPtr};
+%apply const char * {CUCharPtr};
+%apply const char * {CSCharPtr};
+
+%inline %{
+ typedef unsigned char* UCharPtr;
+ typedef signed char* SCharPtr;
+ typedef const unsigned char* CUCharPtr;
+ typedef const signed char* CSCharPtr;
+
+ UCharPtr UCharFunction(UCharPtr str) { return str; }
+ SCharPtr SCharFunction(SCharPtr str) { return str; }
+ CUCharPtr CUCharFunction(CUCharPtr str) { return str; }
+ CSCharPtr CSCharFunction(CSCharPtr str) { return str; }
+%}
+
+%typemap(freearg) SWIGTYPE * ""
+%apply SWIGTYPE* {CharPtr};
+%apply SWIGTYPE* {CCharPtr};
+
+%inline %{
+ typedef char* CharPtr;
+ typedef const char* CCharPtr;
+
+ CharPtr CharFunction(CharPtr buffer) { return buffer; }
+ CCharPtr CCharFunction(CCharPtr buffer) { return buffer; }
+%}
+
+// unsigned char* as strings
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+
+/* Note: Chicken does not allow unsigned char * in strings */
+
+%apply char [ANY] {TAscii[ANY]}
+%apply char [] {TAscii []}
+%apply char * {TAscii *}
+
+#endif
+
+%inline %{
+typedef unsigned char TAscii;
+typedef struct {
+ TAscii DigitsMemberA[20];
+ TAscii *DigitsMemberB;
+} TNumber;
+
+TAscii DigitsGlobalA[20];
+TAscii DigitsGlobalB[] = {(unsigned char)'A', (unsigned char)'B', 0};
+TAscii *DigitsGlobalC;
+
+%}
+
+// Director test
+%feature("director");
+
+%inline %{
+ struct DirectorTest {
+ virtual UCharPtr UCharFunction(UCharPtr str) { return str; }
+ virtual SCharPtr SCharFunction(SCharPtr str) { return str; }
+ virtual CUCharPtr CUCharFunction(CUCharPtr str) { return str; }
+ virtual CSCharPtr CSCharFunction(CSCharPtr str) { return str; }
+ virtual CharPtr CharFunction(CharPtr buffer) { return buffer; }
+ virtual CCharPtr CCharFunction(CCharPtr buffer) { return buffer; }
+ virtual ~DirectorTest() {}
+ };
+%}
+
+
diff --git a/trunk/Examples/test-suite/argcargvtest.i b/trunk/Examples/test-suite/argcargvtest.i
new file mode 100644
index 000000000..ed5aa0985
--- /dev/null
+++ b/trunk/Examples/test-suite/argcargvtest.i
@@ -0,0 +1,23 @@
+%module argcargvtest
+
+%include <argcargv.i>
+
+%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
+
+%inline %{
+
+int mainc(size_t argc, const char **argv)
+{
+ return (int)argc;
+}
+
+const char* mainv(size_t argc, const char **argv, int idx)
+{
+ return argv[idx];
+}
+
+void initializeApp(size_t argc, const char **argv, bool setPGid = true, bool isMakeline = false)
+{
+}
+
+%}
diff --git a/trunk/Examples/test-suite/argout.i b/trunk/Examples/test-suite/argout.i
new file mode 100644
index 000000000..8f849a6bf
--- /dev/null
+++ b/trunk/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 separately; for the cases where
+ maybe multiple values are passed by reference and all want changing */
+
+%module argout
+
+%include cpointer.i
+%pointer_functions(int,intp);
+
+%inline %{
+// returns old value
+int incp(int *value) {
+ return (*value)++;
+}
+
+// returns old value
+int incr(int &value) {
+ return value++;
+}
+
+typedef int & IntRef;
+// returns old value
+int inctr(IntRef value) {
+ return value++;
+}
+
+// example of the old DB login type routines where you keep
+// a void* which it points to its opaque struct when you login
+// So login function takes a void**
+void voidhandle(void** handle) {
+ *handle=(void*)"Here it is";
+}
+char * handle(void* handle) {
+ return (char *)handle;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/array_member.i b/trunk/Examples/test-suite/array_member.i
new file mode 100644
index 000000000..d8e2f873c
--- /dev/null
+++ b/trunk/Examples/test-suite/array_member.i
@@ -0,0 +1,74 @@
+%module array_member
+
+%inline %{
+
+typedef struct Foo {
+ char text[8];
+ int data[8];
+} Foo;
+
+int global_data[8] = { 0,1,2,3,4,5,6,7 };
+
+void set_value(int *x, int i, int v) {
+ x[i] = v;
+}
+
+int get_value(int *x, int i) {
+ return x[i];
+}
+%}
+
+
+
+
+
+
+#ifdef __cplusplus
+%inline
+{
+
+ struct Material
+ {
+ };
+
+ class RayPacketData {
+ public:
+ enum {
+ Size = 32
+ };
+
+ const Material * chitMat[Size];
+ Material hitMat_val[Size];
+ Material *hitMat[Size];
+
+ const Material * chitMat2[Size][Size];
+ Material hitMat_val2[Size][Size];
+ Material *hitMat2[Size][Size];
+ };
+}
+
+#endif
+
+
+
+%inline %{
+#define BUFF_LEN 12
+
+typedef unsigned char BUFF[BUFF_LEN];
+
+typedef BUFF MY_BUFF;
+
+typedef struct _m {
+ int i;
+ MY_BUFF x;
+} MyBuff;
+
+
+typedef char SBUFF[BUFF_LEN];
+typedef SBUFF MY_SBUFF;
+typedef struct _sm {
+ int i;
+ MY_SBUFF x;
+} MySBuff;
+
+%}
diff --git a/trunk/Examples/test-suite/array_typedef_memberin.i b/trunk/Examples/test-suite/array_typedef_memberin.i
new file mode 100644
index 000000000..3a0cf2522
--- /dev/null
+++ b/trunk/Examples/test-suite/array_typedef_memberin.i
@@ -0,0 +1,12 @@
+%module array_typedef_memberin
+%inline %{
+typedef short arr_short8[8];
+namespace ArrayExample
+{
+ class ExampleDetail
+ {
+ public:
+ arr_short8 node_list;
+ };
+}
+%}
diff --git a/trunk/Examples/test-suite/arrayref.i b/trunk/Examples/test-suite/arrayref.i
new file mode 100644
index 000000000..f9c4df786
--- /dev/null
+++ b/trunk/Examples/test-suite/arrayref.i
@@ -0,0 +1,14 @@
+// A function that passes arrays by reference
+
+%module arrayref
+
+%inline %{
+
+void foo(const int (&x)[10]) {
+}
+
+void bar(int (&x)[10]) {
+}
+%}
+
+
diff --git a/trunk/Examples/test-suite/arrays.i b/trunk/Examples/test-suite/arrays.i
new file mode 100644
index 000000000..decce7415
--- /dev/null
+++ b/trunk/Examples/test-suite/arrays.i
@@ -0,0 +1,72 @@
+/*
+This test case tests that various types of arrays are working.
+*/
+
+%module arrays
+%{
+#include <stdlib.h>
+%}
+
+%inline %{
+#define ARRAY_LEN 2
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+typedef struct {
+ char array_c [ARRAY_LEN];
+ signed char array_sc[ARRAY_LEN];
+ unsigned char array_uc[ARRAY_LEN];
+ short array_s [ARRAY_LEN];
+ unsigned short array_us[ARRAY_LEN];
+ int array_i [ARRAY_LEN];
+ unsigned int array_ui[ARRAY_LEN];
+ long array_l [ARRAY_LEN];
+ unsigned long array_ul[ARRAY_LEN];
+ long long array_ll[ARRAY_LEN];
+ float array_f [ARRAY_LEN];
+ double array_d [ARRAY_LEN];
+ SimpleStruct array_struct[ARRAY_LEN];
+ SimpleStruct* array_structpointers[ARRAY_LEN];
+ int* array_ipointers [ARRAY_LEN];
+ finger array_enum[ARRAY_LEN];
+ finger* array_enumpointers[ARRAY_LEN];
+ const int array_const_i[ARRAY_LEN];
+} ArrayStruct;
+
+void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN]) {}
+
+/* Pointer helper functions used in the Java run test */
+int* newintpointer() {
+ return (int*)malloc(sizeof(int));
+}
+void setintfrompointer(int* intptr, int value) {
+ *intptr = value;
+}
+int getintfrompointer(int* intptr) {
+ return *intptr;
+}
+
+%}
+
+// This tests wrapping of function that involves pointer to array
+
+
+%inline %{
+void array_pointer_func(int (*x)[10]) {}
+%}
+
+
+%inline %{
+typedef float FLOAT;
+
+typedef FLOAT cartPosition_t[3];
+
+typedef struct {
+cartPosition_t p;
+} CartPoseData_t;
+
+%}
diff --git a/trunk/Examples/test-suite/arrays_dimensionless.i b/trunk/Examples/test-suite/arrays_dimensionless.i
new file mode 100644
index 000000000..11dc022f7
--- /dev/null
+++ b/trunk/Examples/test-suite/arrays_dimensionless.i
@@ -0,0 +1,69 @@
+
+%module arrays_dimensionless
+
+%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) globalints; /* Unable to set variable of type int [] */
+%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) ints; /* Unable to set variable of type int [] */
+
+%inline %{
+
+int globalints[] = {100, 200, 300};
+const int constglobalints[] = {400, 500, 600};
+
+struct Bar {
+ static int ints[];
+};
+int Bar::ints[] = {700, 800, 900};
+
+double arr_bool(bool array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]=!array[i]; } return sum; }
+double arr_char(char array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_schar(signed char array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_uchar(unsigned char array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_short(short array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_ushort(unsigned short array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_int(int array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_uint(unsigned int array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_long(long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_ulong(unsigned long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_ll(long long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_ull(unsigned long long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_float(float array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+double arr_double(double array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
+
+%}
+
+%apply SWIGTYPE[] {
+ bool *,
+ char *,
+ signed char *,
+ unsigned char *,
+ short *,
+ unsigned short *,
+ int *,
+ unsigned int *,
+ long *,
+ unsigned long *,
+ long *,
+ unsigned long long *,
+ float *,
+ double *
+}
+
+%inline %{
+
+double ptr_bool(bool *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_char(char *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_schar(signed char *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_uchar(unsigned char *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_short(short *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_ushort(unsigned short *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_int(int *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_uint(unsigned int *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_long(long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_ulong(unsigned long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_ll(long long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_ull(unsigned long long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_float(float *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+double ptr_double(double *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
+
+%}
+
diff --git a/trunk/Examples/test-suite/arrays_global.i b/trunk/Examples/test-suite/arrays_global.i
new file mode 100644
index 000000000..10d29b6dc
--- /dev/null
+++ b/trunk/Examples/test-suite/arrays_global.i
@@ -0,0 +1,95 @@
+/*
+This test case tests that various types of arrays are working.
+*/
+
+%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK,SWIGWARN_TYPEMAP_VARIN_UNDEF);
+
+%module arrays_global
+
+%inline %{
+#define ARRAY_LEN 2
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+char array_c [ARRAY_LEN];
+signed char array_sc[ARRAY_LEN];
+unsigned char array_uc[ARRAY_LEN];
+short array_s [ARRAY_LEN];
+unsigned short array_us[ARRAY_LEN];
+int array_i [ARRAY_LEN];
+unsigned int array_ui[ARRAY_LEN];
+long array_l [ARRAY_LEN];
+unsigned long array_ul[ARRAY_LEN];
+long long array_ll[ARRAY_LEN];
+float array_f [ARRAY_LEN];
+double array_d [ARRAY_LEN];
+SimpleStruct array_struct[ARRAY_LEN];
+SimpleStruct* array_structpointers[ARRAY_LEN];
+int* array_ipointers [ARRAY_LEN];
+finger array_enum[ARRAY_LEN];
+finger* array_enumpointers[ARRAY_LEN];
+const int array_const_i[ARRAY_LEN] = {10, 20};
+
+%}
+
+%inline %{
+
+const char BeginString_FIX44a[8] = "FIX.a.a";
+char BeginString_FIX44b[8] = "FIX.b.b";
+
+const char BeginString_FIX44c[] = "FIX.c.c";
+char BeginString_FIX44d[] = "FIX.d.d";
+
+const char* BeginString_FIX44e = "FIX.e.e";
+const char* const BeginString_FIX44f = "FIX.f.f";
+
+typedef char name[8];
+typedef char namea[];
+
+char* test_a(char hello[8],
+ char hi[],
+ const char chello[8],
+ const char chi[]) {
+ return hi;
+}
+
+char* test_b(name a, const namea b) {
+ return a;
+}
+
+#if 0
+int test_a(int a) {
+ return a;
+}
+
+int test_b(int a) {
+ return a;
+}
+
+#endif
+%}
+
+
+
+#ifdef __cplusplus
+%inline
+{
+
+ struct Material
+ {
+ };
+
+ enum {
+ Size = 32
+ };
+
+ const Material * chitMat[Size];
+ Material hitMat_val[Size];
+ Material *hitMat[Size];
+}
+
+#endif
diff --git a/trunk/Examples/test-suite/arrays_global_twodim.i b/trunk/Examples/test-suite/arrays_global_twodim.i
new file mode 100644
index 000000000..f6404b918
--- /dev/null
+++ b/trunk/Examples/test-suite/arrays_global_twodim.i
@@ -0,0 +1,61 @@
+/*
+Two dimension arrays
+*/
+
+%module arrays_global_twodim
+
+%inline %{
+#define ARRAY_LEN_X 2
+#define ARRAY_LEN_Y 4
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+char array_c [ARRAY_LEN_X][ARRAY_LEN_Y];
+signed char array_sc[ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned char array_uc[ARRAY_LEN_X][ARRAY_LEN_Y];
+short array_s [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y];
+int array_i [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned int array_ui[ARRAY_LEN_X][ARRAY_LEN_Y];
+long array_l [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned long array_ul[ARRAY_LEN_X][ARRAY_LEN_Y];
+long long array_ll[ARRAY_LEN_X][ARRAY_LEN_Y];
+float array_f [ARRAY_LEN_X][ARRAY_LEN_Y];
+double array_d [ARRAY_LEN_X][ARRAY_LEN_Y];
+SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y];
+SimpleStruct* array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
+int* array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y];
+finger array_enum[ARRAY_LEN_X][ARRAY_LEN_Y];
+finger* array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
+const int array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} };
+
+void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {}
+
+int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
+ return array[x][y];
+}
+%}
+
+#ifdef __cplusplus
+%inline
+{
+
+ struct Material
+ {
+ };
+
+ enum {
+ Size = 32
+ };
+
+ const Material * chitMat[Size][Size];
+ Material hitMat_val[Size][Size];
+ Material *hitMat[Size][Size];
+}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/arrays_scope.i b/trunk/Examples/test-suite/arrays_scope.i
new file mode 100644
index 000000000..efde11e59
--- /dev/null
+++ b/trunk/Examples/test-suite/arrays_scope.i
@@ -0,0 +1,19 @@
+%module arrays_scope
+
+%inline %{
+
+enum { ASIZE = 256 };
+namespace foo {
+ enum { BBSIZE = 512 };
+ class Bar {
+ public:
+ enum { CCSIZE = 768 };
+ int adata[ASIZE];
+ int bdata[BBSIZE];
+ int cdata[CCSIZE];
+ void blah(int x[ASIZE], int y[BBSIZE], int z[CCSIZE]) { };
+ };
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/bloody_hell.i b/trunk/Examples/test-suite/bloody_hell.i
new file mode 100644
index 000000000..e580f0dd4
--- /dev/null
+++ b/trunk/Examples/test-suite/bloody_hell.i
@@ -0,0 +1,18 @@
+%module bloody_hell
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) kMaxIOCTLSpaceParmsSize;
+
+#define kMaxIOCTLSpaceParmsSize 128
+
+%{
+#define kMaxIOCTLSpaceParmsSize 128
+ %}
+
+%inline %{
+typedef struct sm_channel_ix_dump_parms {
+ unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
+} SM_CHANNEL_IX_DUMP_PARMS;
+ %}
+
+
+
diff --git a/trunk/Examples/test-suite/bools.i b/trunk/Examples/test-suite/bools.i
new file mode 100644
index 000000000..7b94fcf88
--- /dev/null
+++ b/trunk/Examples/test-suite/bools.i
@@ -0,0 +1,64 @@
+// bool typemaps check
+%module bools
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool; /* Ruby, wrong class name */
+
+// bool constant
+%constant bool constbool=false;
+
+%inline %{
+
+// bool variables
+bool bool1 = true;
+bool bool2 = false;
+bool* pbool = &bool1;
+bool& rbool = bool2;
+const bool* const_pbool = pbool;
+const bool& const_rbool = rbool;
+
+static int eax()
+{
+ return 1024; // NOTE: any number > 255 should do
+}
+
+// bool functions
+bool bo(bool b) {
+ return b;
+}
+bool& rbo(bool& b) {
+ return b;
+}
+bool* pbo(bool* b) {
+ return b;
+}
+const bool& const_rbo(const bool& b) {
+ return b;
+}
+const bool* const_pbo(const bool* b) {
+ return b;
+}
+
+// helper function
+bool value(bool* b) {
+ return *b;
+}
+
+struct BoolStructure {
+ bool m_bool1;
+ bool m_bool2;
+ bool* m_pbool;
+ bool& m_rbool;
+ const bool* m_const_pbool;
+ const bool& m_const_rbool;
+ BoolStructure() :
+ m_bool1(true),
+ m_bool2(false),
+ m_pbool(&m_bool1),
+ m_rbool(m_bool2),
+ m_const_pbool(m_pbool),
+ m_const_rbool(m_rbool) {}
+private:
+ BoolStructure& operator=(const BoolStructure &);
+};
+%}
+
diff --git a/trunk/Examples/test-suite/callback.i b/trunk/Examples/test-suite/callback.i
new file mode 100644
index 000000000..c4d50d3fe
--- /dev/null
+++ b/trunk/Examples/test-suite/callback.i
@@ -0,0 +1,72 @@
+%module callback
+
+%callback(1) foo;
+%callback(1) foof;
+%callback(1) A::bar;
+%callback(1) A::foom;
+%callback("%s_Cb_Ptr") foo_T; // old style, still works.
+
+%inline %{
+
+ int foo(int a) {
+ return a;
+ }
+
+ int foof(int a) {
+ return 3*a;
+ }
+
+ struct A
+ {
+ static int bar(int a) {
+ return 2*a;
+ }
+
+ int foom(int a)
+ {
+ return -a;
+ }
+
+ //friend int foof(int a);
+ };
+
+
+ extern "C" int foobar(int a, int (*pf)(int a)) {
+ return pf(a);
+ }
+
+ extern "C" int foobarm(int a, A ap, int (A::*pf)(int a)) {
+ return (ap.*pf)(a);
+ }
+
+ template <class T>
+ T foo_T(T a)
+ {
+ return a;
+ }
+
+ template <class T>
+ T foo_T(T a, T b)
+ {
+ return a + b;
+ }
+
+
+ template <class T>
+ T foobar_T(T a, T (*pf)(T a)) {
+ return pf(a);
+ }
+
+ template <class T>
+ const T& ident(const T& x) {
+ return x;
+ }
+%}
+
+%template(foo_i) foo_T<int>;
+%template(foobar_i) foobar_T<int>;
+
+%template(foo_d) foo_T<double>;
+%template(foobar_d) foobar_T<double>;
+
+%template(ident_d) ident<double>;
diff --git a/trunk/Examples/test-suite/cast_operator.i b/trunk/Examples/test-suite/cast_operator.i
new file mode 100644
index 000000000..88964e3b8
--- /dev/null
+++ b/trunk/Examples/test-suite/cast_operator.i
@@ -0,0 +1,20 @@
+%module cast_operator
+
+%rename(tochar) A::operator char*() const;
+%inline %{
+#include <string.h>
+struct A
+{
+operator char*() const;
+};
+
+inline
+A::operator char*() const
+{
+ static char hi[16];
+ strcpy(hi, "hi");
+ return hi;
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/casts.i b/trunk/Examples/test-suite/casts.i
new file mode 100644
index 000000000..4893756f0
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/catches.i b/trunk/Examples/test-suite/catches.i
new file mode 100644
index 000000000..8f09ae24c
--- /dev/null
+++ b/trunk/Examples/test-suite/catches.i
@@ -0,0 +1,33 @@
+%module catches
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%include <exception.i> // for throws(...) typemap
+
+%catches(int, const char *, const ThreeException&) test_catches(int i);
+%catches(int, ...) test_exception_specification(int i); // override the exception specification
+%catches(...) test_catches_all(int i);
+
+%inline %{
+struct ThreeException {};
+void test_catches(int i) {
+ if (i == 1) {
+ throw int(1);
+ } else if (i == 2) {
+ throw (const char *)"two";
+ } else if (i == 3) {
+ throw ThreeException();
+ }
+}
+void test_exception_specification(int i) throw(int, const char *, const ThreeException&) {
+ test_catches(i);
+}
+void test_catches_all(int i) {
+ test_catches(i);
+}
+%}
+
diff --git a/trunk/Examples/test-suite/cffi/Makefile.in b/trunk/Examples/test-suite/cffi/Makefile.in
new file mode 100644
index 000000000..bf21b3552
--- /dev/null
+++ b/trunk/Examples/test-suite/cffi/Makefile.in
@@ -0,0 +1,51 @@
+#######################################################################
+# Makefile for cffi test-suite
+#######################################################################
+
+LANGUAGE = cffi
+CFFI = @CFFIBIN@
+SCRIPTSUFFIX = _runme.lisp
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# no C++ tests for now
+CPP_TEST_CASES =
+#C_TEST_CASES +=
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.lisp appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: (does nothing, we dont generate extra cffi code)
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile cffi_clean
+
diff --git a/trunk/Examples/test-suite/char_constant.i b/trunk/Examples/test-suite/char_constant.i
new file mode 100644
index 000000000..5235b0581
--- /dev/null
+++ b/trunk/Examples/test-suite/char_constant.i
@@ -0,0 +1,20 @@
+/* This interface file tests whether character constants are correctly
+ wrapped as procedures returning Scheme characters (rather than
+ Scheme strings).
+*/
+
+%module char_constant
+
+#define CHAR_CONSTANT 'x'
+
+#define STRING_CONSTANT "xyzzy"
+
+#define ESC_CONST '\1'
+#define NULL_CONST '\0'
+#define SPECIALCHAR 'á'
+
+%inline
+{
+ const int ia = (int)'a';
+ const int ib = 'b';
+}
diff --git a/trunk/Examples/test-suite/char_strings.i b/trunk/Examples/test-suite/char_strings.i
new file mode 100644
index 000000000..cc59815b2
--- /dev/null
+++ b/trunk/Examples/test-suite/char_strings.i
@@ -0,0 +1,195 @@
+/*
+A test case for testing char based strings. Useful for runtime testing,
+there were some runtime crashes and leaks in the C# module in some of the scenarios
+below.
+*/
+
+%module char_strings
+
+%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
+%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
+
+#ifdef SWIG_ALLEGRO_CL
+%{
+#include <stdio.h>
+%}
+#endif
+
+%{
+#define OTHERLAND_MSG "Little message from the safe world."
+#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
+static char *global_str = NULL;
+const int UINT_DIGITS = 10; // max unsigned int is 4294967295
+
+bool check(const char *const str, unsigned int number) {
+ static char expected[256];
+ sprintf(expected, "%s%d", OTHERLAND_MSG, number);
+ bool matches = (strcmp(str, expected) == 0);
+ if (!matches) printf("Failed: [%s][%s]\n", str, expected);
+ return matches;
+}
+
+%}
+
+%immutable global_const_char;
+
+%inline %{
+// get functions
+char *GetCharHeapString() {
+ global_str = new char[sizeof(CPLUSPLUS_MSG)+1];
+ strcpy(global_str, CPLUSPLUS_MSG);
+ return global_str;
+}
+
+const char *GetConstCharProgramCodeString() {
+ return CPLUSPLUS_MSG;
+}
+
+void DeleteCharHeapString() {
+ delete[] global_str;
+ global_str = NULL;
+}
+
+char *GetCharStaticString() {
+ static char str[sizeof(CPLUSPLUS_MSG)+1];
+ strcpy(str, CPLUSPLUS_MSG);
+ return str;
+}
+
+char *GetCharStaticStringFixed() {
+ static char str[] = CPLUSPLUS_MSG;
+ return str;
+}
+
+const char *GetConstCharStaticStringFixed() {
+ static const char str[] = CPLUSPLUS_MSG;
+ return str;
+}
+
+// set functions
+bool SetCharHeapString(char *str, unsigned int number) {
+ delete[] global_str;
+ global_str = new char[strlen(str)+UINT_DIGITS+1];
+ strcpy(global_str, str);
+ return check(global_str, number);
+}
+
+bool SetCharStaticString(char *str, unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+bool SetCharArrayStaticString(char str[], unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+bool SetConstCharHeapString(const char *str, unsigned int number) {
+ delete[] global_str;
+ global_str = new char[strlen(str)+UINT_DIGITS+1];
+ strcpy(global_str, str);
+ return check(global_str, number);
+}
+
+bool SetConstCharStaticString(const char *str, unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+bool SetConstCharArrayStaticString(const char str[], unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+bool SetCharConstStaticString(char *const str, unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+bool SetConstCharConstStaticString(const char *const str, unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+// get set function
+char *CharPingPong(char *str) {
+ return str;
+}
+char *CharArrayPingPong(char abcstr[]) {
+ return abcstr;
+}
+char *CharArrayDimsPingPong(char abcstr[16]) {
+ return abcstr;
+}
+
+// variables
+char *global_char = NULL;
+char global_char_array1[] = CPLUSPLUS_MSG;
+char global_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
+
+const char *global_const_char = CPLUSPLUS_MSG;
+const char global_const_char_array1[] = CPLUSPLUS_MSG;
+const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
+
+%}
+
+
+%typemap(newfree) char *GetNewCharString() { /* hello */ delete[] $1; }
+%newobject GetNewCharString();
+
+%inline {
+ char *GetNewCharString() {
+ char *nstr = new char[sizeof(CPLUSPLUS_MSG)+1];
+ strcpy(nstr, CPLUSPLUS_MSG);
+ return nstr;
+ }
+}
+
+%inline {
+ struct Formatpos;
+ struct OBFormat;
+
+ static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) {
+ return 0;
+ }
+
+
+
+}
+
+
+%inline %{
+
+// char *& tests
+char *&GetCharPointerRef() {
+ static char str[] = CPLUSPLUS_MSG;
+ static char *ptr = str;
+ return ptr;
+}
+
+bool SetCharPointerRef(char *&str, unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+const char *&GetConstCharPointerRef() {
+ static const char str[] = CPLUSPLUS_MSG;
+ static const char *ptr = str;
+ return ptr;
+}
+
+bool SetConstCharPointerRef(const char *&str, unsigned int number) {
+ static char static_str[] = CPLUSPLUS_MSG;
+ strcpy(static_str, str);
+ return check(static_str, number);
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/chicken/Makefile.in b/trunk/Examples/test-suite/chicken/Makefile.in
new file mode 100644
index 000000000..42fe6100a
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/Makefile.in
@@ -0,0 +1,99 @@
+#######################################################################
+# Makefile for chicken test-suite
+#######################################################################
+
+LANGUAGE = chicken
+VARIANT =
+SCRIPTSUFFIX = _runme.ss
+PROXYSUFFIX = _runme_proxy.ss
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+CHICKEN_CSI = @CHICKEN_CSI@ -quiet -batch -no-init
+SO = @SO@
+
+#C_TEST_CASES = long_long list_vector pointer_in_out multivalue
+
+# Skip the STD cases for now, except for li_std_string.i
+SKIP_CPP_STD_CASES = Yes
+
+CPP_TEST_CASES += li_std_string
+
+EXTRA_TEST_CASES += chicken_ext_test.externaltest
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+SWIGOPT += -nounit
+
+# Custom tests - tests with additional commandline options
+# If there exists a PROXYSUFFIX runme file, we also generate the wrapper
+# with the -proxy argument
+%.cppproxy: SWIGOPT += -proxy
+%.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
+
+%.cproxy: SWIGOPT += -proxy
+%.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
+
+%.multiproxy: SWIGOPT += -proxy -noclosuses
+%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
+ $(MAKE) $*.cppproxy; \
+ fi
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
+ $(MAKE) $*.cproxy; \
+ fi
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
+ $(MAKE) $*.multiproxy; \
+ fi
+
+%.externaltest:
+ $(setup)
+ +$(swig_and_compile_external)
+ $(run_testcase)
+
+%.cppproxy:
+ echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.cproxy:
+ echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multiproxy:
+ echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.scm appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile chicken_clean
+ rm -f *.scm
diff --git a/trunk/Examples/test-suite/chicken/README b/trunk/Examples/test-suite/chicken/README
new file mode 100644
index 000000000..ba32bb464
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/README
@@ -0,0 +1,11 @@
+See ../README for common README file.
+
+Any testcases which have _runme.ss appended after the testcase name will be detected and run.
+NOTE: I had to use _runme.ss becuase otherwise it would be hard to implement make clean
+Since when SWIG runs it generates an example.scm file for every test, to clean those files
+I needed to add a rm -f *.scm to make clean. But we don't want the runme scripts to
+dissappear as well!
+
+Any testcases which have _runme_proxy.ss appended after the testcase name will be detected
+and run with the -proxy argument passed to SWIG. SWIG will not be run with the -unhide-primitive
+option, so the _runme_proxy.ss file must use only the tinyclos exported interface.
diff --git a/trunk/Examples/test-suite/chicken/casts_runme.ss b/trunk/Examples/test-suite/chicken/casts_runme.ss
new file mode 100644
index 000000000..2eca46149
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/casts_runme.ss
@@ -0,0 +1,2 @@
+(load "casts.so")
+(include "../schemerunme/casts.scm")
diff --git a/trunk/Examples/test-suite/chicken/char_constant_runme.ss b/trunk/Examples/test-suite/chicken/char_constant_runme.ss
new file mode 100644
index 000000000..50dff3018
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/char_constant_runme.ss
@@ -0,0 +1,2 @@
+(load "char_constant.so")
+(include "../schemerunme/char_constant.scm")
diff --git a/trunk/Examples/test-suite/chicken/chicken_ext_test_runme.ss b/trunk/Examples/test-suite/chicken/chicken_ext_test_runme.ss
new file mode 100644
index 000000000..65fa4e085
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/chicken_ext_test_runme.ss
@@ -0,0 +1,5 @@
+(load "chicken_ext_test.so")
+
+(define a (test-create))
+
+(A-hello a)
diff --git a/trunk/Examples/test-suite/chicken/class_ignore_runme.ss b/trunk/Examples/test-suite/chicken/class_ignore_runme.ss
new file mode 100644
index 000000000..ba84810a3
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/class_ignore_runme.ss
@@ -0,0 +1,2 @@
+(load "class_ignore.so")
+(include "../schemerunme/class_ignore.scm")
diff --git a/trunk/Examples/test-suite/chicken/clientdata_prop_runme_proxy.ss b/trunk/Examples/test-suite/chicken/clientdata_prop_runme_proxy.ss
new file mode 100644
index 000000000..62f2c2053
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/clientdata_prop_runme_proxy.ss
@@ -0,0 +1,95 @@
+(require 'clientdata_prop_a)
+(require 'clientdata_prop_b)
+
+(define a (make <A>))
+(test-A a)
+(test-tA a)
+(test-t2A a)
+(test-t3A a)
+(fA a)
+
+(define b (make <B>))
+(test-A b)
+(test-tA b)
+(test-t2A b)
+(test-t3A b)
+(test-B b)
+(fA b)
+(fB b)
+
+(define c (make <C>))
+(test-A c)
+(test-tA c)
+(test-t2A c)
+(test-t3A c)
+(test-C c)
+(fA c)
+(fC c)
+
+(define d (make <D>))
+(test-A d)
+(test-tA d)
+(test-t2A d)
+(test-t3A d)
+(test-D d)
+(test-tD d)
+(test-t2D d)
+(fA d)
+(fD d)
+
+;; here are the real tests... if the clientdata is correctly
+;; propegated, new-tA, new-t2A, should all return wrapped proxy's
+;; of class <A>
+
+(define a2 (new-tA))
+(if (not (eq? (class-of a2) <A>))
+ (error "Error 1"))
+(test-A a2)
+(test-tA a2)
+(test-t2A a2)
+(test-t3A a2)
+(fA a2)
+
+(define a3 (new-t2A))
+(if (not (eq? (class-of a3) <A>))
+ (error "Error 2"))
+(test-A a3)
+(test-tA a3)
+(test-t2A a3)
+(test-t3A a3)
+(fA a3)
+
+(define a4 (new-t3A))
+(if (not (eq? (class-of a4) <A>))
+ (error "Error 3"))
+(test-A a4)
+(test-tA a4)
+(test-t2A a4)
+(test-t3A a4)
+(fA a4)
+
+(define d2 (new-tD))
+(if (not (eq? (class-of d2) <D>))
+ (error "Error 4"))
+(test-A d2)
+(test-tA d2)
+(test-t2A d2)
+(test-t3A d2)
+(test-D d2)
+(test-tD d2)
+(fA d2)
+(fD d2)
+
+(define d3 (new-t2D))
+(if (not (eq? (class-of d3) <D>))
+ (error "Error 5"))
+(test-A d3)
+(test-tA d3)
+(test-t2A d3)
+(test-t3A d3)
+(test-D d3)
+(test-tD d3)
+(fA d3)
+(fD d3)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/constover_runme.ss b/trunk/Examples/test-suite/chicken/constover_runme.ss
new file mode 100644
index 000000000..eb39c7ff0
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/constover_runme.ss
@@ -0,0 +1,2 @@
+(load "constover.so")
+(include "../schemerunme/constover.scm")
diff --git a/trunk/Examples/test-suite/chicken/contract_runme.ss b/trunk/Examples/test-suite/chicken/contract_runme.ss
new file mode 100644
index 000000000..006bcfdec
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/contract_runme.ss
@@ -0,0 +1,3 @@
+(load "contract.so")
+(include "testsuite.ss")
+(include "../schemerunme/contract.scm")
diff --git a/trunk/Examples/test-suite/chicken/cpp_basic_runme_proxy.ss b/trunk/Examples/test-suite/chicken/cpp_basic_runme_proxy.ss
new file mode 100644
index 000000000..7b0b6d722
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/cpp_basic_runme_proxy.ss
@@ -0,0 +1,64 @@
+(require 'cpp_basic)
+
+(define-macro (check test)
+ `(if (not ,test) (error "Error in test " ',test)))
+
+(define f (make <Foo> 4))
+(check (= (slot-ref f 'num) 4))
+(slot-set! f 'num -17)
+(check (= (slot-ref f 'num) -17))
+
+(define b (make <Bar>))
+
+(slot-set! b 'fptr f)
+(check (= (slot-ref (slot-ref b 'fptr) 'num) -17))
+(check (= (test b -3 (slot-ref b 'fptr)) -5))
+(slot-set! f 'num 12)
+(check (= (slot-ref (slot-ref b 'fptr) 'num) 12))
+
+(check (= (slot-ref (slot-ref b 'fref) 'num) -4))
+(check (= (test b 12 (slot-ref b 'fref)) 23))
+;; references don't take ownership, so if we didn't define this here it might get garbage collected
+(define f2 (make <Foo> 23))
+(slot-set! b 'fref f2)
+(check (= (slot-ref (slot-ref b 'fref) 'num) 23))
+(check (= (test b -3 (slot-ref b 'fref)) 35))
+
+(check (= (slot-ref (slot-ref b 'fval) 'num) 15))
+(check (= (test b 3 (slot-ref b 'fval)) 33))
+(slot-set! b 'fval (make <Foo> -15))
+(check (= (slot-ref (slot-ref b 'fval) 'num) -15))
+(check (= (test b 3 (slot-ref b 'fval)) -27))
+
+(define f3 (testFoo b 12 (slot-ref b 'fref)))
+(check (= (slot-ref f3 'num) 32))
+
+;; now test global
+(define f4 (make <Foo> 6))
+(Bar-global-fptr f4)
+(check (= (slot-ref (Bar-global-fptr) 'num) 6))
+(slot-set! f4 'num 8)
+(check (= (slot-ref (Bar-global-fptr) 'num) 8))
+
+(check (= (slot-ref (Bar-global-fref) 'num) 23))
+(Bar-global-fref (make <Foo> -7))
+(check (= (slot-ref (Bar-global-fref) 'num) -7))
+
+(check (= (slot-ref (Bar-global-fval) 'num) 3))
+(Bar-global-fval (make <Foo> -34))
+(check (= (slot-ref (Bar-global-fval) 'num) -34))
+
+;; Now test function pointers
+(define func1ptr (get-func1-ptr))
+(define func2ptr (get-func2-ptr))
+
+(slot-set! f 'num 4)
+(check (= (func1 f 2) 16))
+(check (= (func2 f 2) -8))
+
+(slot-set! f 'func-ptr func1ptr)
+(check (= (test-func-ptr f 2) 16))
+(slot-set! f 'func-ptr func2ptr)
+(check (= (test-func-ptr f 2) -8))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/cpp_enum_runme.ss b/trunk/Examples/test-suite/chicken/cpp_enum_runme.ss
new file mode 100644
index 000000000..4d4ec7623
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/cpp_enum_runme.ss
@@ -0,0 +1,2 @@
+(load "cpp_enum.so")
+(include "../schemerunme/cpp_enum.scm")
diff --git a/trunk/Examples/test-suite/chicken/cpp_namespace_runme.ss b/trunk/Examples/test-suite/chicken/cpp_namespace_runme.ss
new file mode 100644
index 000000000..800172ed8
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/cpp_namespace_runme.ss
@@ -0,0 +1,2 @@
+(load "cpp_namespace.so")
+(include "../schemerunme/cpp_namespace.scm")
diff --git a/trunk/Examples/test-suite/chicken/dynamic_cast_runme.ss b/trunk/Examples/test-suite/chicken/dynamic_cast_runme.ss
new file mode 100644
index 000000000..1e81d5555
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/dynamic_cast_runme.ss
@@ -0,0 +1,2 @@
+(load "dynamic_cast.so")
+(include "../schemerunme/dynamic_cast.scm")
diff --git a/trunk/Examples/test-suite/chicken/ext_test_external.cxx b/trunk/Examples/test-suite/chicken/ext_test_external.cxx
new file mode 100644
index 000000000..338151e88
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/ext_test_external.cxx
@@ -0,0 +1,22 @@
+#include <ext_test_wrap_hdr.h>
+#include <imports_a.h>
+
+void test_create(C_word,C_word,C_word) C_noret;
+void test_create(C_word argc, C_word closure, C_word continuation) {
+ C_word resultobj;
+ swig_type_info *type;
+ A *newobj;
+ C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
+
+ C_trace("test-create");
+ if (argc!=2) C_bad_argc(argc,2);
+
+
+ newobj = new A();
+
+ type = SWIG_TypeQuery("A *");
+ resultobj = SWIG_NewPointerObj(newobj, type, 1);
+
+ C_kontinue(continuation, resultobj);
+}
+
diff --git a/trunk/Examples/test-suite/chicken/global_vars_runme.ss b/trunk/Examples/test-suite/chicken/global_vars_runme.ss
new file mode 100644
index 000000000..802205b7c
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/global_vars_runme.ss
@@ -0,0 +1,2 @@
+(require 'global_vars)
+(load "../schemerunme/global_vars.scm")
diff --git a/trunk/Examples/test-suite/chicken/global_vars_runme_proxy.ss b/trunk/Examples/test-suite/chicken/global_vars_runme_proxy.ss
new file mode 100644
index 000000000..3c4500d6b
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/global_vars_runme_proxy.ss
@@ -0,0 +1,2 @@
+(require 'global_vars)
+(load "../schemerunme/global_vars_proxy.scm")
diff --git a/trunk/Examples/test-suite/chicken/import_nomodule_runme.ss b/trunk/Examples/test-suite/chicken/import_nomodule_runme.ss
new file mode 100644
index 000000000..7e64053bc
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/import_nomodule_runme.ss
@@ -0,0 +1,2 @@
+(load "import_nomodule.so")
+(include "../schemerunme/import_nomodule.scm")
diff --git a/trunk/Examples/test-suite/chicken/imports_runme.ss b/trunk/Examples/test-suite/chicken/imports_runme.ss
new file mode 100644
index 000000000..ac5fb9890
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/imports_runme.ss
@@ -0,0 +1,3 @@
+(load "imports_a.so")
+(load "imports_b.so")
+(include "../schemerunme/imports.scm")
diff --git a/trunk/Examples/test-suite/chicken/inherit_missing_runme.ss b/trunk/Examples/test-suite/chicken/inherit_missing_runme.ss
new file mode 100644
index 000000000..50a084a95
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/inherit_missing_runme.ss
@@ -0,0 +1,2 @@
+(load "inherit_missing.so")
+(include "../schemerunme/inherit_missing.scm")
diff --git a/trunk/Examples/test-suite/chicken/li_std_string_runme.ss b/trunk/Examples/test-suite/chicken/li_std_string_runme.ss
new file mode 100644
index 000000000..cc64287dd
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/li_std_string_runme.ss
@@ -0,0 +1,2 @@
+(load "li_std_string.so")
+(include "../schemerunme/li_std_string.scm")
diff --git a/trunk/Examples/test-suite/chicken/li_std_string_runme_proxy.ss b/trunk/Examples/test-suite/chicken/li_std_string_runme_proxy.ss
new file mode 100644
index 000000000..e1e240970
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/li_std_string_runme_proxy.ss
@@ -0,0 +1,47 @@
+(load "li_std_string.so")
+
+(define x "hello")
+
+(if (not (string=? (test-value x) x))
+ (begin (error "Error 1") (exit 1)))
+
+(if (not (string=? (test-const-reference x) x))
+ (begin (error "Error 2") (exit 1)))
+
+(define y (test-pointer-out))
+(test-pointer y)
+(define z (test-const-pointer-out))
+(test-const-pointer z)
+
+(define a (test-reference-out))
+(test-reference a)
+
+;; test global variables
+(GlobalString "whee")
+(if (not (string=? (GlobalString) "whee"))
+ (error "Error 3"))
+(if (not (string=? (GlobalString2) "global string 2"))
+ (error "Error 4"))
+
+(define struct (make <Structure>))
+
+;; MemberString should be a wrapped class
+(if (not (string=? (slot-ref struct 'MemberString) ""))
+ (error "Error 4.5"))
+;(slot-set! (slot-ref struct 'MemberString) "and how")
+;;(if (not (string=? (slot-ref struct 'MemberString) "and how"))
+;; (error "Error 5"))
+(if (not (string=? (slot-ref struct 'MemberString2) "member string 2"))
+ (error "Error 6"))
+(Structure-StaticMemberString "static str")
+(if (not (string=? (Structure-StaticMemberString) "static str"))
+ (error "Error 7"))
+(if (not (string=? (Structure-StaticMemberString2) "static member string 2"))
+ (error "Error 8"))
+
+;(if (not (string=? (Structure-ConstMemberString-get struct) "const member string"))
+; (error "Error 9"))
+(if (not (string=? (Structure-ConstStaticMemberString) "const static member string"))
+ (error "Error 10"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/li_typemaps_runme.ss b/trunk/Examples/test-suite/chicken/li_typemaps_runme.ss
new file mode 100644
index 000000000..1ad6e921e
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/li_typemaps_runme.ss
@@ -0,0 +1,12 @@
+(require 'li_typemaps)
+(load "../schemerunme/li_typemaps.scm")
+
+(call-with-values (lambda () (inoutr-int2 3 -2))
+ (lambda (a b)
+ (if (not (and (= a 3) (= b -2)))
+ (error "Error in inoutr-int2"))))
+(call-with-values (lambda () (out-foo 4))
+ (lambda (a b)
+ (if (not (and (= (Foo-a-get a) 4) (= b 8)))
+ (error "Error in out-foo"))))
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/li_typemaps_runme_proxy.ss b/trunk/Examples/test-suite/chicken/li_typemaps_runme_proxy.ss
new file mode 100644
index 000000000..52997c6fe
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/li_typemaps_runme_proxy.ss
@@ -0,0 +1,13 @@
+(require 'li_typemaps)
+(load "../schemerunme/li_typemaps_proxy.scm")
+
+(call-with-values (lambda () (inoutr-int2 3 -2))
+ (lambda (a b)
+ (if (not (and (= a 3) (= b -2)))
+ (error "Error in inoutr-int2"))))
+(call-with-values (lambda () (out-foo 4))
+ (lambda (a b)
+ (if (not (and (= (slot-ref a 'a) 4) (= b 8)))
+ (error "Error in out-foo"))))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/list_vector_runme.ss b/trunk/Examples/test-suite/chicken/list_vector_runme.ss
new file mode 100644
index 000000000..67d52f609
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/list_vector_runme.ss
@@ -0,0 +1,2 @@
+(load "list_vector.so")
+(include "../schemerunme/list_vector.scm")
diff --git a/trunk/Examples/test-suite/chicken/member_pointer_runme.ss b/trunk/Examples/test-suite/chicken/member_pointer_runme.ss
new file mode 100644
index 000000000..f2226b20a
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/member_pointer_runme.ss
@@ -0,0 +1,28 @@
+(require 'member_pointer)
+
+(define (check-eq? msg expected actual)
+ (if (not (= expected actual))
+ (error "Error " msg ": expected " expected " got " actual)))
+
+(define area-pt (areapt))
+(define perim-pt (perimeterpt))
+
+(define s (new-Square 10))
+
+(check-eq? "Square area" 100.0 (do-op s area-pt))
+(check-eq? "Square perim" 40.0 (do-op s perim-pt))
+
+(check-eq? "Square area" 100.0 (do-op s (areavar)))
+(check-eq? "Square perim" 40.0 (do-op s (perimetervar)))
+
+;; Set areavar to return value of function
+(areavar perim-pt)
+(check-eq? "Square perim" 40 (do-op s (areavar)))
+
+(check-eq? "Square area" 100.0 (do-op s (AREAPT)))
+(check-eq? "Square perim" 40.0 (do-op s (PERIMPT)))
+
+(define test (NULLPT))
+
+(perimetervar (AREAPT))
+(check-eq? "Square area" 100.0 (do-op s (perimetervar)))
diff --git a/trunk/Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss b/trunk/Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss
new file mode 100644
index 000000000..313157c70
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/multiple_inheritance_runme_proxy.ss
@@ -0,0 +1,2 @@
+(require 'multiple_inheritance)
+(load "../schemerunme/multiple_inheritance_proxy.scm")
diff --git a/trunk/Examples/test-suite/chicken/multivalue_runme.ss b/trunk/Examples/test-suite/chicken/multivalue_runme.ss
new file mode 100644
index 000000000..f5aafcbf4
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/multivalue_runme.ss
@@ -0,0 +1,4 @@
+;; this doesn't work yet :(
+(load "multivalue.so")
+(include "../schemerunme/multivalue.scm")
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/name_runme.ss b/trunk/Examples/test-suite/chicken/name_runme.ss
new file mode 100644
index 000000000..938915dcb
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/name_runme.ss
@@ -0,0 +1,2 @@
+(load "name.so")
+(include "../schemerunme/name.scm")
diff --git a/trunk/Examples/test-suite/chicken/newobject1_runme_proxy.ss b/trunk/Examples/test-suite/chicken/newobject1_runme_proxy.ss
new file mode 100644
index 000000000..7bc5a241a
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/newobject1_runme_proxy.ss
@@ -0,0 +1,30 @@
+(require 'newobject1)
+
+(define-macro (check-count val)
+ `(if (not (= (Foo-fooCount) ,val)) (error "Error checking val " ,val " != " ,(Foo-fooCount))))
+
+(define f (Foo-makeFoo))
+
+(check-count 1)
+
+(define f2 (makeMore f))
+
+(check-count 2)
+
+(set! f #f)
+(gc #t)
+
+(check-count 1)
+
+(define f3 (makeMore f2))
+
+(check-count 2)
+
+(set! f3 #f)
+(set! f2 #f)
+
+(gc #t)
+
+(check-count 0)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/newobject2_runme.ss b/trunk/Examples/test-suite/chicken/newobject2_runme.ss
new file mode 100644
index 000000000..cc445f477
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/newobject2_runme.ss
@@ -0,0 +1,29 @@
+(load "newobject2.so")
+
+(define f (new-Foo))
+
+(Foo-dummy-set f 14)
+(if (not (= (Foo-dummy-get f) 14))
+ (error "Bad dummy value"))
+
+(if (not (= (fooCount) 0))
+ (error "Bad foo count 1"))
+
+(define f2 (makeFoo))
+
+(if (not (= (fooCount) 1))
+ (error "Bad foo count 2"))
+
+(Foo-dummy-set f2 16)
+(if (not (= (Foo-dummy-get f2) 16))
+ (error "Bad dummy value for f2"))
+
+(set! f #f)
+(set! f2 #f)
+
+(gc #t)
+
+(if (not (= (fooCount) -1))
+ (error "Bad foo count 3"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/newobject2_runme_proxy.ss b/trunk/Examples/test-suite/chicken/newobject2_runme_proxy.ss
new file mode 100644
index 000000000..36b8cda7f
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/newobject2_runme_proxy.ss
@@ -0,0 +1,29 @@
+(load "newobject2.so")
+
+(define f (make <Foo>))
+
+(slot-set! f 'dummy 14)
+(if (not (= (slot-ref f 'dummy) 14))
+ (error "Bad dummy value"))
+
+(if (not (= (fooCount) 0))
+ (error "Bad foo count 1"))
+
+(define f2 (makeFoo))
+
+(if (not (= (fooCount) 1))
+ (error "Bad foo count 2"))
+
+(slot-set! f2 'dummy 16)
+(if (not (= (slot-ref f2 'dummy) 16))
+ (error "Bad dummy value for f2"))
+
+(set! f #f)
+(set! f2 #f)
+
+(gc #t)
+
+(if (not (= (fooCount) -1))
+ (error "Bad foo count 3"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/overload_complicated_runme.ss b/trunk/Examples/test-suite/chicken/overload_complicated_runme.ss
new file mode 100644
index 000000000..f89f70bde
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_complicated_runme.ss
@@ -0,0 +1,2 @@
+(load "overload_complicated.so")
+(include "../schemerunme/overload_complicated.scm")
diff --git a/trunk/Examples/test-suite/chicken/overload_copy_runme.ss b/trunk/Examples/test-suite/chicken/overload_copy_runme.ss
new file mode 100644
index 000000000..4ec542205
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_copy_runme.ss
@@ -0,0 +1,2 @@
+(load "overload_copy.so")
+(include "../schemerunme/overload_copy.scm")
diff --git a/trunk/Examples/test-suite/chicken/overload_copy_runme_proxy.ss b/trunk/Examples/test-suite/chicken/overload_copy_runme_proxy.ss
new file mode 100644
index 000000000..5f4808070
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_copy_runme_proxy.ss
@@ -0,0 +1,6 @@
+(load "./overload_copy.so")
+
+(define f (make <Foo>))
+(define g (make <Foo> f))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/overload_extend_runme.ss b/trunk/Examples/test-suite/chicken/overload_extend_runme.ss
new file mode 100644
index 000000000..a19cb29a9
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_extend_runme.ss
@@ -0,0 +1,2 @@
+(load "overload_extend.so")
+(include "../schemerunme/overload_extend.scm")
diff --git a/trunk/Examples/test-suite/chicken/overload_extend_runme_proxy.ss b/trunk/Examples/test-suite/chicken/overload_extend_runme_proxy.ss
new file mode 100644
index 000000000..2a6867e22
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_extend_runme_proxy.ss
@@ -0,0 +1,14 @@
+(load "./overload_extend.so")
+
+(define f (make <Foo>))
+
+(if (not (= (test f 3) 1))
+ (error "test integer bad"))
+
+(if (not (= (test f "hello") 2))
+ (error "test string bad"))
+
+(if (not (= (test f 3.5 2.5) 6.0))
+ (error "test reals bad"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/overload_simple_runme.ss b/trunk/Examples/test-suite/chicken/overload_simple_runme.ss
new file mode 100644
index 000000000..24fa67aec
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_simple_runme.ss
@@ -0,0 +1,2 @@
+(load "overload_simple.so")
+(include "../schemerunme/overload_simple.scm")
diff --git a/trunk/Examples/test-suite/chicken/overload_simple_runme_proxy.ss b/trunk/Examples/test-suite/chicken/overload_simple_runme_proxy.ss
new file mode 100644
index 000000000..0ae3e6215
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_simple_runme_proxy.ss
@@ -0,0 +1,56 @@
+(load "overload_simple.so")
+
+(define-macro (check test)
+ `(if (not ,test) (error ',test)))
+
+(check (string=? (foo) "foo:"))
+(check (string=? (foo 3) "foo:int"))
+(check (string=? (foo 3.01) "foo:double"))
+(check (string=? (foo "hey") "foo:char *"))
+
+(define f (make <Foo>))
+(define b (make <Bar>))
+(define b2 (make <Bar> 3))
+
+(check (= (slot-ref b 'num) 0))
+(check (= (slot-ref b2 'num) 3))
+
+(check (string=? (foo f) "foo:Foo *"))
+(check (string=? (foo b) "foo:Bar *"))
+(check (string=? (foo f 3) "foo:Foo *,int"))
+(check (string=? (foo 3.2 b) "foo:double,Bar *"))
+
+;; now check blah
+(check (string=? (blah 2.01) "blah:double"))
+(check (string=? (blah "hey") "blah:char *"))
+
+;; now check spam member functions
+(define s (make <Spam>))
+(define s2 (make <Spam> 3))
+(define s3 (make <Spam> 3.2))
+(define s4 (make <Spam> "whee"))
+(define s5 (make <Spam> f))
+(define s6 (make <Spam> b))
+
+(check (string=? (slot-ref s 'type) "none"))
+(check (string=? (slot-ref s2 'type) "int"))
+(check (string=? (slot-ref s3 'type) "double"))
+(check (string=? (slot-ref s4 'type) "char *"))
+(check (string=? (slot-ref s5 'type) "Foo *"))
+(check (string=? (slot-ref s6 'type) "Bar *"))
+
+;; now check Spam member functions
+(check (string=? (foo s 2) "foo:int"))
+(check (string=? (foo s 2.1) "foo:double"))
+(check (string=? (foo s "hey") "foo:char *"))
+(check (string=? (foo s f) "foo:Foo *"))
+(check (string=? (foo s b) "foo:Bar *"))
+
+;; check static member funcs
+(check (string=? (Spam-bar 3) "bar:int"))
+(check (string=? (Spam-bar 3.2) "bar:double"))
+(check (string=? (Spam-bar "hey") "bar:char *"))
+(check (string=? (Spam-bar f) "bar:Foo *"))
+(check (string=? (Spam-bar b) "bar:Bar *"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/overload_subtype_runme.ss b/trunk/Examples/test-suite/chicken/overload_subtype_runme.ss
new file mode 100644
index 000000000..b3663b719
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_subtype_runme.ss
@@ -0,0 +1,2 @@
+(load "overload_subtype.so")
+(include "../schemerunme/overload_subtype.scm")
diff --git a/trunk/Examples/test-suite/chicken/overload_subtype_runme_proxy.ss b/trunk/Examples/test-suite/chicken/overload_subtype_runme_proxy.ss
new file mode 100644
index 000000000..d83d59a11
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/overload_subtype_runme_proxy.ss
@@ -0,0 +1,12 @@
+(load "./overload_subtype.so")
+
+(define f (make <Foo>))
+(define b (make <Bar>))
+
+(if (not (= (spam f) 1))
+ (error "Error in foo"))
+
+(if (not (= (spam b) 2))
+ (error "Error in bar"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/pointer_in_out_runme.ss b/trunk/Examples/test-suite/chicken/pointer_in_out_runme.ss
new file mode 100644
index 000000000..807c4ebad
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/pointer_in_out_runme.ss
@@ -0,0 +1,2 @@
+(load "pointer_in_out.so")
+(include "../schemerunme/pointer_in_out.scm")
diff --git a/trunk/Examples/test-suite/chicken/reference_global_vars_runme.ss b/trunk/Examples/test-suite/chicken/reference_global_vars_runme.ss
new file mode 100644
index 000000000..1e1914be3
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/reference_global_vars_runme.ss
@@ -0,0 +1,2 @@
+(load "reference_global_vars.so")
+(include "../schemerunme/reference_global_vars.scm")
diff --git a/trunk/Examples/test-suite/chicken/testsuite.ss b/trunk/Examples/test-suite/chicken/testsuite.ss
new file mode 100644
index 000000000..e1152a6fe
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/testsuite.ss
@@ -0,0 +1,12 @@
+(define (lookup-ext-tag tag)
+ (cond
+ ((equal? tag '(quote swig-contract-assertion-failed))
+ '( ((exn type) #f)) )
+ (#t '())))
+
+(define-macro (expect-throw tag-form form)
+ `(if (condition-case (begin ,form #t)
+ ,@(lookup-ext-tag tag-form)
+ ((exn) (print "The form threw a different error than expected: " ',form) (exit 1))
+ (var () (print "The form did not error as expected: " ',form) (exit 1)))
+ (begin (print "The form returned normally when it was expected to throw an error: " ',form) (exit 1))))
diff --git a/trunk/Examples/test-suite/chicken/throw_exception_runme.ss b/trunk/Examples/test-suite/chicken/throw_exception_runme.ss
new file mode 100644
index 000000000..62bc7befb
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/throw_exception_runme.ss
@@ -0,0 +1,29 @@
+(load "throw_exception.so")
+
+(define-macro (check-throw expr check)
+ `(if (handle-exceptions exvar (if ,check #f (begin (print "Error executing: " ',expr " " exvar) (exit 1))) ,expr #t)
+ (print "Expression did not throw an error: " ',expr)))
+
+(define f (new-Foo))
+
+(check-throw (Foo-test-int f) (= exvar 37))
+(check-throw (Foo-test-msg f) (string=? exvar "Dead"))
+(check-throw (Foo-test-cls f) (test-is-Error exvar))
+(check-throw (Foo-test-cls-ptr f) (test-is-Error exvar))
+(check-throw (Foo-test-cls-ref f) (test-is-Error exvar))
+(check-throw (Foo-test-cls-td f) (test-is-Error exvar))
+(check-throw (Foo-test-cls-ptr-td f) (test-is-Error exvar))
+(check-throw (Foo-test-cls-ref-td f) (test-is-Error exvar))
+(check-throw (Foo-test-enum f) (= exvar (enum2)))
+
+; don't know how to test this... it is returning a SWIG wrapped int *
+;(check-throw (Foo-test-array f) (equal? exvar '(0 1 2 3 4 5 6 7 8 9)))
+
+(check-throw (Foo-test-multi f 1) (= exvar 37))
+(check-throw (Foo-test-multi f 2) (string=? exvar "Dead"))
+(check-throw (Foo-test-multi f 3) (test-is-Error exvar))
+
+(set! f #f)
+(gc #t)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/chicken/typedef_inherit_runme.ss b/trunk/Examples/test-suite/chicken/typedef_inherit_runme.ss
new file mode 100644
index 000000000..111296d60
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/typedef_inherit_runme.ss
@@ -0,0 +1,2 @@
+(load "typedef_inherit.so")
+(include "../schemerunme/typedef_inherit.scm")
diff --git a/trunk/Examples/test-suite/chicken/typename_runme.ss b/trunk/Examples/test-suite/chicken/typename_runme.ss
new file mode 100644
index 000000000..60fc3203b
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/typename_runme.ss
@@ -0,0 +1,2 @@
+(load "typename.so")
+(include "../schemerunme/typename.scm")
diff --git a/trunk/Examples/test-suite/chicken/unions_runme.ss b/trunk/Examples/test-suite/chicken/unions_runme.ss
new file mode 100644
index 000000000..465784a43
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/unions_runme.ss
@@ -0,0 +1,2 @@
+(load "unions.so")
+(include "../schemerunme/unions.scm")
diff --git a/trunk/Examples/test-suite/chicken/unions_runme_proxy.ss b/trunk/Examples/test-suite/chicken/unions_runme_proxy.ss
new file mode 100644
index 000000000..4dd14148d
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken/unions_runme_proxy.ss
@@ -0,0 +1,2 @@
+(load "unions.so")
+(include "../schemerunme/unions_proxy.scm")
diff --git a/trunk/Examples/test-suite/chicken_ext_test.i b/trunk/Examples/test-suite/chicken_ext_test.i
new file mode 100644
index 000000000..b4f726cc7
--- /dev/null
+++ b/trunk/Examples/test-suite/chicken_ext_test.i
@@ -0,0 +1,21 @@
+%module chicken_ext_test
+
+/* just use the imports_a.h header... for this test we only need a class */
+%{
+#include "imports_a.h"
+%}
+
+%include "imports_a.h"
+
+%{
+void test_create(C_word,C_word,C_word) C_noret;
+%}
+
+%init %{
+ {
+ C_word *space = C_alloc(2 + C_SIZEOF_INTERNED_SYMBOL(11));
+ sym = C_intern (&space, 11, "test-create");
+ C_mutate ((C_word*)sym+1, (*space=C_CLOSURE_TYPE|1, space[1]=(C_word)test_create, tmp=(C_word)space, space+=2, tmp));
+ }
+%}
+
diff --git a/trunk/Examples/test-suite/class_ignore.i b/trunk/Examples/test-suite/class_ignore.i
new file mode 100644
index 000000000..c0b954cd1
--- /dev/null
+++ b/trunk/Examples/test-suite/class_ignore.i
@@ -0,0 +1,47 @@
+%module class_ignore
+
+%ignore Foo;
+%ignore *::Bar::foo;
+%ignore Far::away() const;
+
+%inline %{
+ class Foo {
+ public:
+ virtual ~Foo() { }
+ virtual char *blah() = 0;
+ };
+
+ namespace hi
+ {
+ namespace hello
+ {
+ class Bar : public Foo {
+ public:
+ void foo(void) {};
+
+ virtual char *blah() { return (char *) "Bar::blah"; }
+ };
+
+ }
+ }
+
+ struct Boo {
+ virtual ~Boo() {}
+ virtual void away() const {}
+ };
+ struct Far : Boo {
+ virtual void away() const {}
+ };
+ struct Hoo : Far {
+ virtual void away() const {}
+ };
+
+ char *do_blah(Foo *f) {
+ return f->blah();
+ }
+
+ class ForwardClass;
+ template <class C> class ForwardClassT;
+ template<typename T1, typename T2> class PatchList;
+%}
+
diff --git a/trunk/Examples/test-suite/class_scope_weird.i b/trunk/Examples/test-suite/class_scope_weird.i
new file mode 100644
index 000000000..cc55dc880
--- /dev/null
+++ b/trunk/Examples/test-suite/class_scope_weird.i
@@ -0,0 +1,50 @@
+%module class_scope_weird
+
+// Use this version with extra qualifiers to test SWIG as some compilers accept this
+class Foo {
+public:
+ Foo::Foo(void) {}
+ Foo::Foo(int) {}
+ int Foo::bar(int x) {
+ return x;
+ }
+};
+
+// Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards)
+%{
+class Foo {
+public:
+ Foo(void) {}
+ Foo(int) {}
+ int bar(int x) {
+ return x;
+ }
+};
+%}
+
+%inline %{
+class Quat;
+class matrix4;
+class tacka3;
+%}
+
+// Use this version with extra qualifiers to test SWIG as some compilers accept this
+class Quat {
+public:
+ Quat::Quat(void){}
+ Quat::Quat(float in_w, float x, float y, float z){}
+ Quat::Quat(const tacka3& axis, float angle){}
+ Quat::Quat(const matrix4& m){}
+};
+
+// Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards)
+%{
+class Quat {
+public:
+ Quat(void){}
+ Quat(float in_w, float x, float y, float z){}
+ Quat(const tacka3& axis, float angle){}
+ Quat(const matrix4& m){}
+};
+%}
+
diff --git a/trunk/Examples/test-suite/clientdata_prop.list b/trunk/Examples/test-suite/clientdata_prop.list
new file mode 100644
index 000000000..5e41f6d0e
--- /dev/null
+++ b/trunk/Examples/test-suite/clientdata_prop.list
@@ -0,0 +1,2 @@
+clientdata_prop_a
+clientdata_prop_b
diff --git a/trunk/Examples/test-suite/clientdata_prop_a.h b/trunk/Examples/test-suite/clientdata_prop_a.h
new file mode 100644
index 000000000..5f82e98bc
--- /dev/null
+++ b/trunk/Examples/test-suite/clientdata_prop_a.h
@@ -0,0 +1,12 @@
+
+class A {
+ public:
+ void fA() {}
+};
+
+typedef A tA;
+
+void test_A(A *a) {}
+void test_tA(tA *a) {}
+
+tA *new_tA() { return new tA(); }
diff --git a/trunk/Examples/test-suite/clientdata_prop_a.i b/trunk/Examples/test-suite/clientdata_prop_a.i
new file mode 100644
index 000000000..626f2a1b8
--- /dev/null
+++ b/trunk/Examples/test-suite/clientdata_prop_a.i
@@ -0,0 +1,12 @@
+/* This file tests the clientdata propagation at swig wrapper
+ generation. It tests a bug in the TCL module where the
+ clientdata was not propagated correctly to all classes */
+
+%module clientdata_prop_a
+%{
+ #include "clientdata_prop_a.h"
+%}
+
+%include "clientdata_prop_a.h"
+
+%newobject new_tA;
diff --git a/trunk/Examples/test-suite/clientdata_prop_b.h b/trunk/Examples/test-suite/clientdata_prop_b.h
new file mode 100644
index 000000000..f8a709ec4
--- /dev/null
+++ b/trunk/Examples/test-suite/clientdata_prop_b.h
@@ -0,0 +1,38 @@
+#include "clientdata_prop_a.h"
+
+typedef tA t2A;
+typedef A t3A;
+
+class B : public A
+{
+ public:
+ void fB() {}
+};
+
+class C : public tA
+{
+ public:
+ void fC() {}
+};
+
+class D : public t2A
+{
+ public:
+ void fD() {}
+};
+
+typedef D tD;
+typedef tD t2D;
+
+void test_t2A(t2A *a) {}
+void test_t3A(t3A *a) {}
+void test_B(B *b) {}
+void test_C(C *c) {}
+void test_D(D *d) {}
+void test_tD(tD *d) {}
+void test_t2D(t2D *d) {}
+
+t2A *new_t2A() { return new t2A(); }
+t3A *new_t3A() { return new t3A(); }
+tD * new_tD () { return new tD (); }
+t2D *new_t2D() { return new t2D(); }
diff --git a/trunk/Examples/test-suite/clientdata_prop_b.i b/trunk/Examples/test-suite/clientdata_prop_b.i
new file mode 100644
index 000000000..709c1a28d
--- /dev/null
+++ b/trunk/Examples/test-suite/clientdata_prop_b.i
@@ -0,0 +1,20 @@
+/* This file tests the clientdata propagation at swig wrapper
+ generation. It tests a bug in the TCL module where the
+ clientdata was not propagated correctly to all classes */
+
+%module clientdata_prop_b
+
+%{
+#include "clientdata_prop_b.h"
+%}
+
+%import "clientdata_prop_a.i"
+
+%include "clientdata_prop_b.h"
+
+%types(tA *);
+
+%newobject new_t2A;
+%newobject new_t3A;
+%newobject new_tD;
+%newobject new_t2D;
diff --git a/trunk/Examples/test-suite/clisp/Makefile.in b/trunk/Examples/test-suite/clisp/Makefile.in
new file mode 100644
index 000000000..2ebaa6750
--- /dev/null
+++ b/trunk/Examples/test-suite/clisp/Makefile.in
@@ -0,0 +1,51 @@
+#######################################################################
+# Makefile for clisp test-suite
+#######################################################################
+
+LANGUAGE = clisp
+CLISP = @CLISPBIN@
+SCRIPTSUFFIX = _runme.lisp
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# no C++ tests for now
+CPP_TEST_CASES =
+#C_TEST_CASES +=
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.lisp appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: (does nothing, we dont generate extra clisp code)
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile clisp_clean
+
diff --git a/trunk/Examples/test-suite/common.mk b/trunk/Examples/test-suite/common.mk
new file mode 100644
index 000000000..97708be47
--- /dev/null
+++ b/trunk/Examples/test-suite/common.mk
@@ -0,0 +1,591 @@
+#######################################################################
+# SWIG test suite makefile.
+# The test suite comprises many different test cases, which have
+# typically produced bugs in the past. The aim is to have the test
+# cases compiling for every language modules. Some testcase have
+# a runtime test which is written in each of the module's language.
+#
+# This makefile runs SWIG on the testcases, compiles the c/c++ code
+# then builds the object code for use by the language.
+# To complete a test in a language follow these guidelines:
+# 1) Add testcases to CPP_TEST_CASES (c++) or C_TEST_CASES (c) or
+# MULTI_CPP_TEST_CASES (multi-module c++ tests)
+# 2) If not already done, create a makefile which:
+# a) Defines LANGUAGE matching a language rule in Examples/Makefile,
+# for example LANGUAGE = java
+# b) Define rules for %.ctest, %.cpptest, %.multicpptest and %.clean.
+# c) Define srcdir, top_srcdir and top_builddir (these are the
+# equivalent to configure's variables of the same name).
+# 3) One off special commandline options for a testcase can be added.
+# See custom tests below.
+#
+# The 'check' target runs the testcases including SWIG invocation,
+# C/C++ compilation, target language compilation (if any) and runtime
+# test (if there is an associated 'runme' test).
+# The 'partialcheck' target only invokes SWIG.
+# The 'all' target is the same as the 'check' target but also includes
+# known broken testcases.
+# The 'clean' target cleans up.
+#
+# Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used
+# for invoking tools for the runtime tests and target language
+# compiler (eg javac), and on SWIG respectively. For example, valgrind
+# can be used for memory checking of the runtime tests using:
+# make RUNTOOL="valgrind --leak-check=full"
+# and valgrind can be used when invoking SWIG using:
+# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
+# Note: trace-children needed because of preinst-swig shell wrapper
+# to the swig executable.
+#
+# An individual test run can be debugged easily:
+# make director_string.cpptest RUNTOOL="gdb --args"
+#
+# The variables below can be overridden after including this makefile
+#######################################################################
+
+#######################################################################
+# Variables
+#######################################################################
+
+ifneq (,$(USE_VALGRIND))
+VALGRIND_OPT = --leak-check=full
+RUNTOOL = valgrind $(VALGRIND_OPT)
+else
+RUNTOOL =
+endif
+COMPILETOOL=
+SWIGTOOL =
+
+SWIG = $(SWIGTOOL) $(top_builddir)/preinst-swig
+SWIG_LIB = $(top_srcdir)/Lib
+TEST_SUITE = test-suite
+EXAMPLES = Examples
+CXXSRCS =
+CSRCS =
+TARGETPREFIX =
+TARGETSUFFIX =
+SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+LIBS = -L.
+LIBPREFIX = lib
+ACTION = check
+INTERFACEDIR = ../
+
+#
+# Please keep test cases in alphabetical order.
+# Note that any whitespace after the last entry in each list will break make
+#
+
+# Broken C++ test cases. (Can be run individually using: make testcase.cpptest)
+CPP_TEST_BROKEN += \
+ constants \
+ cpp_broken \
+ exception_partial_info \
+ extend_variable \
+ li_std_vector_ptr \
+ overload_complicated \
+ template_default_pointer \
+ template_expr
+
+
+# Broken C test cases. (Can be run individually using: make testcase.ctest)
+C_TEST_BROKEN += \
+ tag_no_clash_with_variable
+
+
+# C++ test cases. (Can be run individually using: make testcase.cpptest)
+CPP_TEST_CASES += \
+ abstract_access \
+ abstract_inherit \
+ abstract_inherit_ok \
+ abstract_signature \
+ abstract_typedef \
+ abstract_typedef2 \
+ abstract_virtual \
+ access_change \
+ add_link \
+ aggregate \
+ allowexcept \
+ allprotected \
+ anonymous_bitfield \
+ apply_signed_char \
+ apply_strings \
+ argout \
+ array_member \
+ array_typedef_memberin \
+ arrayref \
+ arrays_dimensionless \
+ arrays_global \
+ arrays_global_twodim \
+ arrays_scope \
+ bloody_hell \
+ bools \
+ catches \
+ cast_operator \
+ casts \
+ char_strings \
+ class_ignore \
+ class_scope_weird \
+ compactdefaultargs \
+ const_const_2 \
+ constant_pointers \
+ constover \
+ constructor_copy \
+ constructor_exception \
+ constructor_explicit \
+ constructor_ignore \
+ constructor_rename \
+ constructor_value \
+ contract \
+ conversion \
+ conversion_namespace \
+ conversion_ns_template \
+ cplusplus_throw \
+ cpp_basic \
+ cpp_enum \
+ cpp_namespace \
+ cpp_nodefault \
+ cpp_static \
+ cpp_typedef \
+ default_args \
+ default_constructor \
+ defvalue_constructor \
+ derived_byvalue \
+ derived_nested \
+ destructor_reprotected \
+ director_abstract \
+ director_basic \
+ director_classes \
+ director_classic \
+ director_constructor \
+ director_default \
+ director_detect \
+ director_enum \
+ director_exception \
+ director_extend \
+ director_finalizer \
+ director_frob \
+ director_ignore \
+ director_namespace_clash \
+ director_nested \
+ director_overload \
+ director_primitives \
+ director_protected \
+ director_protected_overloaded \
+ director_redefined \
+ director_thread \
+ director_unroll \
+ director_using \
+ director_wombat \
+ disown \
+ dynamic_cast \
+ empty \
+ enum_scope_template \
+ enum_template \
+ enum_thorough \
+ enum_var \
+ evil_diamond \
+ evil_diamond_ns \
+ evil_diamond_prop \
+ exception_order \
+ extend \
+ extend_default \
+ extend_placement \
+ extend_template \
+ extend_template_ns \
+ extern_c \
+ extern_namespace \
+ extern_throws \
+ expressions \
+ features \
+ fragments \
+ friends \
+ fvirtual \
+ global_namespace \
+ global_ns_arg \
+ global_scope_types \
+ global_vars \
+ grouping \
+ ignore_parameter \
+ import_nomodule \
+ inherit \
+ inherit_missing \
+ inherit_same_name \
+ inherit_target_language \
+ inherit_void_arg \
+ inline_initializer \
+ insert_directive \
+ keyword_rename \
+ kind \
+ langobj \
+ li_attribute \
+ li_boost_shared_ptr \
+ li_boost_shared_ptr_bits \
+ li_carrays \
+ li_cdata \
+ li_cpointer \
+ li_stdint \
+ li_typemaps \
+ li_windows \
+ long_long_apply \
+ memberin_extend \
+ member_pointer \
+ member_template \
+ minherit \
+ minherit2 \
+ mixed_types \
+ multiple_inheritance \
+ name_cxx \
+ name_warnings \
+ namespace_class \
+ namespace_enum \
+ namespace_extend \
+ namespace_nested \
+ namespace_spaces \
+ namespace_template \
+ namespace_typedef_class \
+ namespace_typemap \
+ namespace_union \
+ namespace_virtual_method \
+ nspace \
+ nspace_extend \
+ naturalvar \
+ nested_class \
+ nested_comment \
+ nested_workaround \
+ newobject1 \
+ null_pointer \
+ operator_overload \
+ operator_overload_break \
+ operbool \
+ ordering \
+ overload_copy \
+ overload_extend \
+ overload_rename \
+ overload_simple \
+ overload_subtype \
+ overload_template \
+ overload_template_fast \
+ pointer_reference \
+ preproc_constants \
+ primitive_ref \
+ private_assign \
+ protected_rename \
+ pure_virtual \
+ redefined \
+ refcount \
+ reference_global_vars \
+ register_par \
+ rename1 \
+ rename2 \
+ rename3 \
+ rename4 \
+ rename_scope \
+ rename_strip_encoder \
+ restrict_cplusplus \
+ return_const_value \
+ return_value_scope \
+ rname \
+ samename \
+ sizet \
+ smart_pointer_const \
+ smart_pointer_const2 \
+ smart_pointer_extend \
+ smart_pointer_member \
+ smart_pointer_multi \
+ smart_pointer_multi_typedef \
+ smart_pointer_namespace \
+ smart_pointer_namespace2 \
+ smart_pointer_not \
+ smart_pointer_overload \
+ smart_pointer_protected \
+ smart_pointer_rename \
+ smart_pointer_simple \
+ smart_pointer_static \
+ smart_pointer_templatemethods \
+ smart_pointer_templatevariables \
+ smart_pointer_typedef \
+ special_variables \
+ special_variable_macros \
+ static_array_member \
+ static_const_member \
+ static_const_member_2 \
+ struct_initialization_cpp \
+ struct_value \
+ symbol_clash \
+ template \
+ template_arg_replace \
+ template_arg_scope \
+ template_arg_typename \
+ template_array_numeric \
+ template_base_template \
+ template_classes \
+ template_const_ref \
+ template_construct \
+ template_default \
+ template_default2 \
+ template_default_arg \
+ template_default_class_parms \
+ template_default_inherit \
+ template_default_qualify \
+ template_default_vw \
+ template_enum \
+ template_enum_ns_inherit \
+ template_enum_typedef \
+ template_explicit \
+ template_extend1 \
+ template_extend2 \
+ template_extend_overload \
+ template_extend_overload_2 \
+ template_forward \
+ template_inherit \
+ template_inherit_abstract \
+ template_int_const \
+ template_methods \
+ template_nested \
+ template_nested_typemaps \
+ template_ns \
+ template_ns2 \
+ template_ns3 \
+ template_ns4 \
+ template_ns_enum \
+ template_ns_enum2 \
+ template_ns_inherit \
+ template_ns_scope \
+ template_partial_arg \
+ template_partial_specialization \
+ template_partial_specialization_typedef \
+ template_qualifier \
+ template_qualifier \
+ template_ref_type \
+ template_rename \
+ template_retvalue \
+ template_specialization \
+ template_specialization_defarg \
+ template_specialization_enum \
+ template_static \
+ template_tbase_template \
+ template_template_parameters \
+ template_typedef \
+ template_typedef_cplx \
+ template_typedef_cplx2 \
+ template_typedef_cplx3 \
+ template_typedef_cplx4 \
+ template_typedef_cplx5 \
+ template_typedef_funcptr \
+ template_typedef_ns \
+ template_typedef_ptr \
+ template_typedef_rec \
+ template_using \
+ template_virtual \
+ template_whitespace \
+ threads \
+ threads_exception \
+ throw_exception \
+ typedef_array_member \
+ typedef_class \
+ typedef_funcptr \
+ typedef_inherit \
+ typedef_mptr \
+ typedef_reference \
+ typedef_scope \
+ typedef_sizet \
+ typedef_struct \
+ typemap_delete \
+ typemap_global_scope \
+ typemap_namespace \
+ typemap_ns_using \
+ typemap_numinputs \
+ typemap_template \
+ typemap_out_optimal \
+ typemap_qualifier_strip \
+ typemap_variables \
+ typemap_various \
+ typename \
+ types_directive \
+ union_scope \
+ using1 \
+ using2 \
+ using_composition \
+ using_extend \
+ using_inherit \
+ using_namespace \
+ using_pointers \
+ using_private \
+ using_protected \
+ valuewrapper \
+ valuewrapper_base \
+ valuewrapper_const \
+ valuewrapper_opaque \
+ varargs \
+ virtual_destructor \
+ virtual_poly \
+ voidtest \
+ wallkw \
+ wrapmacro
+
+#
+# Put all the heavy STD/STL cases here, where they can be skipped if needed
+#
+CPP_STD_TEST_CASES += \
+ director_string \
+ ignore_template_constructor \
+ li_std_combinations \
+ li_std_deque \
+ li_std_except \
+ li_std_map \
+ li_std_pair \
+ li_std_string \
+ li_std_vector \
+ naturalvar \
+ smart_pointer_inherit \
+ template_typedef_fnc \
+ template_type_namespace \
+ template_opaque
+# li_std_list
+
+
+ifndef SKIP_CPP_STD_CASES
+CPP_TEST_CASES += ${CPP_STD_TEST_CASES}
+endif
+
+
+# C test cases. (Can be run individually using: make testcase.ctest)
+C_TEST_CASES += \
+ arrays \
+ char_constant \
+ const_const \
+ constant_expr \
+ empty \
+ enums \
+ extern_declaration \
+ funcptr \
+ function_typedef \
+ immutable \
+ inctest \
+ integers \
+ keyword_rename \
+ lextype \
+ li_carrays \
+ li_cdata \
+ li_cmalloc \
+ li_constraints \
+ li_cpointer \
+ li_math \
+ long_long \
+ memberin_extend_c \
+ name \
+ nested \
+ nested_structs \
+ newobject2 \
+ overload_extend \
+ overload_extendc \
+ preproc \
+ preproc_constants_c \
+ ret_by_value \
+ simple_array \
+ sizeof_pointer \
+ sneaky1 \
+ struct_rename \
+ struct_initialization \
+ typedef_struct \
+ typemap_subst \
+ union_parameter \
+ unions
+
+
+# Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest)
+MULTI_CPP_TEST_CASES += \
+ clientdata_prop \
+ imports \
+ packageoption \
+ mod \
+ template_typedef_import \
+ multi_import
+
+# Custom tests - tests with additional commandline options
+wallkw.cpptest: SWIGOPT += -Wallkw
+
+
+NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
+ $(C_TEST_CASES:=.ctest) \
+ $(MULTI_CPP_TEST_CASES:=.multicpptest) \
+ $(EXTRA_TEST_CASES)
+
+BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \
+ $(C_TEST_BROKEN:=.ctest)
+
+ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \
+ $(C_TEST_CASES:=.clean) \
+ $(MULTI_CPP_TEST_CASES:=.clean) \
+ $(CPP_TEST_BROKEN:=.clean) \
+ $(C_TEST_BROKEN:=.clean)
+
+#######################################################################
+# The following applies for all module languages
+#######################################################################
+all: $(BROKEN_TEST_CASES) $(NOT_BROKEN_TEST_CASES)
+
+check: $(NOT_BROKEN_TEST_CASES)
+
+# partialcheck target runs SWIG only, ie no compilation or running of tests (for a subset of languages)
+partialcheck:
+ $(MAKE) check CC=true CXX=true LDSHARED=true CXXSHARED=true RUNTOOL=true COMPILETOOL=true
+
+broken: $(BROKEN_TEST_CASES)
+
+swig_and_compile_cpp = \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
+ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
+ $(LANGUAGE)$(VARIANT)_cpp
+
+swig_and_compile_c = \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
+ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
+ $(LANGUAGE)$(VARIANT)
+
+swig_and_compile_multi_cpp = \
+ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
+ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
+ $(LANGUAGE)$(VARIANT)_cpp; \
+ done
+
+swig_and_compile_external = \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ TARGET="$*_wrap_hdr.h" \
+ $(LANGUAGE)$(VARIANT)_externalhdr; \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
+ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
+ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
+ $(LANGUAGE)$(VARIANT)_cpp
+
+swig_and_compile_runtime = \
+
+setup = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi;
+
+
+
+#######################################################################
+# Clean
+#######################################################################
+clean: $(ALL_CLEAN)
+
+distclean: clean
+ @rm -f Makefile
+
+.PHONY: all check partialcheck broken clean distclean
+
diff --git a/trunk/Examples/test-suite/compactdefaultargs.i b/trunk/Examples/test-suite/compactdefaultargs.i
new file mode 100644
index 000000000..b2b07c5f8
--- /dev/null
+++ b/trunk/Examples/test-suite/compactdefaultargs.i
@@ -0,0 +1,38 @@
+%module compactdefaultargs
+
+// compactdefaultargs off by default
+
+// The following should compile with compactdefaultargs off
+%inline %{
+class Defaults1 {
+ static const int PRIVATE_DEFAULT = -1;
+public:
+ static const double PUBLIC_DEFAULT;
+ Defaults1(int a = PRIVATE_DEFAULT) {}
+ double ret(double d = PUBLIC_DEFAULT) { return d; }
+};
+%}
+
+%{
+const double Defaults1::PUBLIC_DEFAULT = -1.0;
+%}
+
+// compactdefaultargs now on by default
+%feature("compactdefaultargs");
+
+// Turn compactdefaultargs off for the constructor which can't work with this feature
+%feature("compactdefaultargs", "0") Defaults2(int a = PRIVATE_DEFAULT);
+
+%inline %{
+class Defaults2 {
+ static const int PRIVATE_DEFAULT = -1;
+public:
+ static const double PUBLIC_DEFAULT;
+ Defaults2(int a = PRIVATE_DEFAULT) {}
+ double ret(double d = PUBLIC_DEFAULT) { return d; }
+};
+%}
+
+%{
+const double Defaults2::PUBLIC_DEFAULT = -1.0;
+%}
diff --git a/trunk/Examples/test-suite/complextest.i b/trunk/Examples/test-suite/complextest.i
new file mode 100644
index 000000000..64c751a82
--- /dev/null
+++ b/trunk/Examples/test-suite/complextest.i
@@ -0,0 +1,61 @@
+%module complextest
+
+%include <complex.i>
+
+#ifdef __cplusplus
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+%include <std_vector.i>
+
+#if 1
+%template(VectorStdCplx) std::vector<std::complex<double> >;
+#endif
+
+%inline
+{
+ std::complex<double> Conj(const std::complex<double>& a)
+ {
+ return std::conj(a);
+ }
+
+ std::complex<float> Conjf(const std::complex<float>& a)
+ {
+ return std::conj(a);
+ }
+
+#if 1
+ std::vector<std::complex<double> > Copy_h(const std::vector<std::complex<double> >& a)
+ {
+ std::vector<std::complex<double> > b(a.size()/2);
+ std::copy(a.begin(), a.begin()+a.size()/2, b.begin());
+ return b;
+ }
+#endif
+}
+
+
+#else
+
+
+%{
+%}
+
+%inline
+{
+ complex Conj(complex a)
+ {
+ return conj(a);
+ }
+
+
+ complex float Conjf(float complex a)
+ {
+ return conj(a);
+ }
+}
+
+
+#endif
diff --git a/trunk/Examples/test-suite/const_const.i b/trunk/Examples/test-suite/const_const.i
new file mode 100644
index 000000000..7c1c92d22
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/const_const_2.i b/trunk/Examples/test-suite/const_const_2.i
new file mode 100644
index 000000000..9094262a6
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/constant_expr.i b/trunk/Examples/test-suite/constant_expr.i
new file mode 100644
index 000000000..8e5c8aee6
--- /dev/null
+++ b/trunk/Examples/test-suite/constant_expr.i
@@ -0,0 +1,11 @@
+%module constant_expr;
+/* Tests of constant expressions. */
+
+%inline %{
+
+/* % didn't work in SWIG 1.3.40 and earlier. */
+const int X = 123%7;
+#define FOO 12 % 9
+double d_array[12 % 9];
+
+%}
diff --git a/trunk/Examples/test-suite/constant_pointers.i b/trunk/Examples/test-suite/constant_pointers.i
new file mode 100644
index 000000000..277d3cc75
--- /dev/null
+++ b/trunk/Examples/test-suite/constant_pointers.i
@@ -0,0 +1,157 @@
+/*
+This testcase primarily test constant pointers, eg int* const. Only a getter is expected to be produced when wrapping constant pointer variables. A number of other const issues are also tested.
+*/
+
+%module constant_pointers
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
+
+%inline %{
+
+int GlobalInt;
+const int ConstInt=2;
+int* GlobalIntPtr=&GlobalInt;
+int* const GlobalConstIntPtr=&GlobalInt;
+#define ARRAY_SIZE 2
+
+class ParametersTest {
+public:
+ void param1(int* a) {}
+ void param2(const int* a) {}
+ void param3(int* const a) {}
+ void param4(int const a) {}
+ void param5(const int a) {}
+ void param6(int& a) {}
+ void param7(const int& a) {}
+ void param8(int const& a) {}
+ void param9(int*& a) {}
+ void param10(int* const& a) {}
+ void param11(const int* const a) {}
+
+ void param_array1(int* a[ARRAY_SIZE]) {}
+ void param_array2(const int* a[ARRAY_SIZE]) {}
+ void param_array3(int* const a[ARRAY_SIZE]) {}
+ void param_array4(int const a[ARRAY_SIZE]) {}
+ void param_array5(const int a[ARRAY_SIZE]) {}
+ void param_array6(const int* const a[ARRAY_SIZE]) {}
+};
+
+class MemberVariablesTest {
+public:
+ int* member1;
+ ParametersTest* member2;
+ int* const member3;
+ ParametersTest* const member4;
+
+ int* array_member1[ARRAY_SIZE];
+ ParametersTest* array_member2[ARRAY_SIZE];
+ MemberVariablesTest() : member3(NULL), member4(NULL) {}
+private:
+ MemberVariablesTest& operator=(const MemberVariablesTest&);
+};
+void foo(const int *const i) {}
+
+typedef int *typedef1, typedef2, *const typedef3;
+int int1, int2=2, *int3, *const int4 = &GlobalInt;
+
+int* const global_const_int_ptr_array[ARRAY_SIZE] = { &int1, &int2 };
+ParametersTest* const array_member4[ARRAY_SIZE] = { new ParametersTest(), new ParametersTest() };
+
+class ReturnValuesTest {
+public:
+ typedef1 td1;
+ typedef2 td2;
+ int int1, int2, *const int3, *int4, array1[ARRAY_SIZE];
+ int ret1() {return 5;}
+ const int ret2() {return 5;}
+ int ret3() {return 5;}
+ const int* ret4() {return &ConstInt;}
+ int* const ret5() {return &GlobalInt;}
+
+ void ret6(int*& a) {}
+ int*& ret7() {return GlobalIntPtr;}
+ void ret8(int*const& a) {}
+ int*const& ret9() {return GlobalIntPtr;}
+ ReturnValuesTest() : int3(NULL) {}
+private:
+ ReturnValuesTest& operator=(const ReturnValuesTest&);
+};
+
+const int* globalRet1() {return &GlobalInt;}
+int* const globalRet2() {return &GlobalInt;}
+
+%}
+
+
+%{
+ struct A
+ {
+ };
+%}
+
+
+%inline
+{
+ typedef const A* Acptr;
+
+ Acptr opaque(Acptr aptr) {
+ return aptr;
+ }
+
+ struct B
+ {
+ B() : ca() {}
+ const A ca;
+ A a;
+ A* ap;
+ const A* cap;
+ Acptr acptr;
+ private:
+ B& operator=(const B&);
+ };
+
+ const B* bar(const B* b) {
+ return b;
+ }
+
+ B *const& cbar(B *const& b) {
+ return b;
+ }
+}
+
+
+
+%{
+static int wxEVT_COMMAND_BUTTON_CLICKEDv;
+static int *wxEVT_COMMAND_BUTTON_CLICKEDp;
+static int **wxEVT_COMMAND_BUTTON_CLICKEDpp = &wxEVT_COMMAND_BUTTON_CLICKEDp;
+#if defined(SWIGR)
+#undef lang1 /* conflicts with symbol in R internals */
+#endif
+
+char lang1[16] = "Hello";
+char *langs[] ={ lang1 };
+
+
+%}
+
+
+%inline {
+#define EWXWEXPORT_VAR
+
+ const int* wxEVENT_COMMAND_BUTTON_CLICKEDr = (int*) &wxEVT_COMMAND_BUTTON_CLICKEDv;
+ const int* wxEVENT_COMMAND_BUTTON_CLICKEDp = (int*) *wxEVT_COMMAND_BUTTON_CLICKEDpp;
+ char **languages1 = &langs[0];
+ char **languages2 = (char **)&langs[0];
+}
+
+%inline %{
+struct Foo {
+ const int *icap;
+};
+const int* icap;
+const Foo *cap;
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/constants.i b/trunk/Examples/test-suite/constants.i
new file mode 100644
index 000000000..1ca1dc637
--- /dev/null
+++ b/trunk/Examples/test-suite/constants.i
@@ -0,0 +1,16 @@
+%module constants
+
+
+%inline %{
+
+ struct A {
+ A(double) { }
+
+ };
+
+ const A b123(3.0);
+
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/constover.i b/trunk/Examples/test-suite/constover.i
new file mode 100644
index 000000000..06f9ac7e2
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/constructor_copy.i b/trunk/Examples/test-suite/constructor_copy.i
new file mode 100644
index 000000000..f6bdcb240
--- /dev/null
+++ b/trunk/Examples/test-suite/constructor_copy.i
@@ -0,0 +1,158 @@
+%module constructor_copy
+
+%copyctor;
+%nocopyctor Foo8;
+%nocopyctor Bar<double>;
+
+%inline %{
+
+struct Foo1 {
+ int x;
+
+ Foo1(int _x = 2) : x(_x)
+ {
+ }
+};
+
+struct Foo2 {
+ Foo2() { }
+};
+
+struct Foo3 {
+ Foo3() { }
+ Foo3(const Foo3& ) { }
+};
+
+struct Foo4 {
+ Foo4() { }
+
+protected:
+ Foo4(const Foo4& ) { }
+};
+
+
+struct Foo4a {
+ Foo4a() { }
+
+private:
+ Foo4a(const Foo4a& ) { }
+};
+
+
+struct Foo5 : Foo4 {
+};
+
+struct Foo6 : Foo4 {
+ Foo6(const Foo6& f) : Foo4(f) { }
+};
+
+struct Foo7 : Foo5 {
+};
+
+struct Foo8 {
+};
+
+template <class T>
+class Bar
+{
+public:
+ int x;
+
+ Bar(int _x = 0) : x(_x)
+ {
+ }
+};
+%}
+
+%template(Bari) Bar<int>;
+%template(Bard) Bar<double>;
+
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGUTL)
+
+
+%include "std_vector.i"
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
+#define SWIG_GOOD_VECTOR
+%ignore std::vector<Space::Flow>::vector(size_type);
+%ignore std::vector<Space::Flow>::resize(size_type);
+#endif
+
+#if defined(SWIGTCL) || defined(SWIGPERL)
+#define SWIG_GOOD_VECTOR
+/* here, for languages with bad declaration */
+%ignore std::vector<Space::Flow>::vector(unsigned int);
+%ignore std::vector<Space::Flow>::resize(unsigned int);
+#endif
+
+%copyctor;
+
+%ignore FlowFlow::FlowFlow;
+
+%inline %{
+
+namespace Space {
+class Flow {
+public:
+ Flow(int i) {}
+};
+
+
+class FlowFlow {
+public:
+ FlowFlow(int i) {}
+};
+
+}
+
+%}
+
+%template (VectFlow) std::vector<Space::Flow>;
+
+#endif
+
+
+%rename(ABC_Libor_ModelUtils) ABC_Nam::ABC_Libor::ModelUtils;
+
+%copyctor;
+%inline %{
+ namespace ABC_Nam {
+ namespace ABC_Libor {
+ struct ModelUtils {};
+
+ template <class T>
+ struct ModelUtils_T {};
+
+ }
+ }
+%}
+
+%template(ModelUtils_i) ABC_Nam::ABC_Libor::ModelUtils_T<int>;
+
+
+%rename(Space1Space2_TotalReturnSwap) Space1::Space2::TotalReturnSwap;
+
+%copyctor;
+
+%inline %{
+namespace Space1 {
+ namespace Space2 {
+
+ class TotalReturnSwap {
+ public:
+ TotalReturnSwap() {}
+ };
+
+ template <class T>
+ class TotalReturnSwap_T {
+ public:
+ TotalReturnSwap_T() {}
+ };
+
+ }
+}
+%}
+
+%template(Total_i) Space1::Space2::TotalReturnSwap_T<int>;
+
diff --git a/trunk/Examples/test-suite/constructor_exception.i b/trunk/Examples/test-suite/constructor_exception.i
new file mode 100644
index 000000000..4c867c144
--- /dev/null
+++ b/trunk/Examples/test-suite/constructor_exception.i
@@ -0,0 +1,27 @@
+%module constructor_exception
+
+%inline %{
+class Error {
+};
+
+class SomeClass {
+public:
+ SomeClass(int x) {
+ if (x < 0) {
+ throw Error();
+ }
+ }
+};
+
+class Test {
+ SomeClass o;
+public:
+ Test(int x) try : o(x) { }
+ catch (Error &) {
+ }
+ catch (int) {
+ }
+ catch (...) {
+ }
+};
+%}
diff --git a/trunk/Examples/test-suite/constructor_explicit.i b/trunk/Examples/test-suite/constructor_explicit.i
new file mode 100644
index 000000000..5f4c83cc0
--- /dev/null
+++ b/trunk/Examples/test-suite/constructor_explicit.i
@@ -0,0 +1,19 @@
+/* Swig 1.3.6 fails to understand the "explicit" keyword.
+ SF Bug #445233, reported by Krzysztof Kozminski
+ <kozminski@users.sf.net>.
+*/
+
+%module constructor_explicit
+%inline %{
+
+class Foo {
+public:
+ explicit Foo() { }
+ explicit Foo(int) {};
+};
+
+Foo test(Foo x) {
+ return x;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/constructor_ignore.i b/trunk/Examples/test-suite/constructor_ignore.i
new file mode 100644
index 000000000..9af126be2
--- /dev/null
+++ b/trunk/Examples/test-suite/constructor_ignore.i
@@ -0,0 +1,36 @@
+%module constructor_ignore
+
+%ignore Space::Delta1::Delta1();
+%ignore Space::Delta2::Delta2(int i);
+%ignore Space::Delta3::Delta3;
+%ignore Space::Delta4::Delta4;
+
+%inline %{
+namespace Space {
+ struct Delta1 {
+ };
+ struct Delta2 {
+ Delta2(int i) {}
+ };
+ struct Delta3 {
+ Delta3(const Delta3&) {}
+ Delta3() {}
+ Delta3(int i) {}
+ };
+ struct Delta4 {
+ };
+}
+%}
+
+%copyctor;
+%ignore Space::Delta5::Delta5;
+%ignore Space::Delta6::Delta6(const Space::Delta6&);
+
+%inline %{
+namespace Space {
+ struct Delta5 {
+ };
+ struct Delta6 {
+ };
+}
+%}
diff --git a/trunk/Examples/test-suite/constructor_rename.i b/trunk/Examples/test-suite/constructor_rename.i
new file mode 100644
index 000000000..401b07d65
--- /dev/null
+++ b/trunk/Examples/test-suite/constructor_rename.i
@@ -0,0 +1,12 @@
+%module constructor_rename
+
+%{
+struct Foo {
+ Foo() {}
+};
+%}
+
+struct Foo {
+ %rename(RenamedConstructor) Foo();
+ Foo() {}
+};
diff --git a/trunk/Examples/test-suite/constructor_value.i b/trunk/Examples/test-suite/constructor_value.i
new file mode 100644
index 000000000..b5c56d031
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/contract.i b/trunk/Examples/test-suite/contract.i
new file mode 100644
index 000000000..b979ef19e
--- /dev/null
+++ b/trunk/Examples/test-suite/contract.i
@@ -0,0 +1,233 @@
+%module contract
+
+%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+ SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */
+
+#ifdef SWIGCSHARP
+%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
+#endif
+
+%contract test_preassert(int a, int b) {
+require:
+ a > 0;
+ b > 0;
+}
+
+%contract test_postassert(int a) {
+ensure:
+ test_postassert > 0;
+}
+
+%contract test_prepost(int a, int b) {
+require:
+ a > 0;
+ensure:
+ test_prepost > 0;
+}
+
+%inline %{
+
+int test_preassert(int x, int y) {
+ if ((x > 0) && (y > 0)) return 1;
+ return 0;
+}
+
+int test_postassert(int x) {
+ return x;
+}
+
+int test_prepost(int x, int y) {
+ return x+y;
+}
+%}
+
+/* Class tests */
+
+%contract Foo::test_preassert(int x, int y) {
+ require:
+ x > 0;
+ y > 0;
+}
+
+%contract Foo::test_postassert(int a) {
+ ensure:
+ test_postassert > 0;
+}
+
+%contract Foo::test_prepost(int a, int b) {
+ require:
+ a > 0;
+ ensure:
+ test_prepost > 0;
+}
+
+%contract Foo::stest_prepost(int a, int b) {
+ require:
+ a > 0;
+ ensure:
+ stest_prepost > 0;
+}
+
+%contract Bar::test_prepost(int c, int d) {
+ require:
+ d > 0;
+}
+
+%inline %{
+class Foo {
+public:
+ virtual ~Foo() { }
+
+ virtual int test_preassert(int x, int y) {
+ if ((x > 0) && (y > 0)) return 1;
+ return 0;
+ }
+ virtual int test_postassert(int x) {
+ return x;
+ }
+ virtual int test_prepost(int x, int y) {
+ return x+y;
+ }
+ static int stest_prepost(int x, int y) {
+ return x+y;
+ }
+ };
+
+class Bar : public Foo {
+public:
+ virtual int test_prepost(int x, int y) {
+ return x+y;
+ }
+};
+
+%}
+
+/* Multiple inheritance test */
+
+%contract A::foo(int i, int j, int k, int l, int m) {
+ require:
+ i > 0;
+ j > 0;
+ ensure:
+ foo > 0;
+}
+
+%contract B::bar(int x, int y, int z, int w, int v) {
+ require:
+ w > 0;
+ v > 0;
+ ensure:
+ bar > 0;
+}
+
+%contract C::foo(int a, int b, int c, int d, int e) {
+ require:
+ c > 0;
+ d > 0;
+ ensure:
+ foo > 0;
+}
+
+%contract D::foo(int, int, int, int, int x) {
+ require:
+ x > 0;
+}
+
+%contract D::bar(int a, int b, int c, int, int) {
+ require:
+ a > 0;
+ b > 0;
+ c > 0;
+}
+
+%inline %{
+ class A {
+ public:
+ virtual ~A() {}
+ virtual int foo(int a, int b, int c, int d, int e) {
+ if ((a > 0) && (b > 0) && (c > 0) && (d > 0) && (e > 0)) {
+ return 1;
+ }
+ return 0;
+ }
+ };
+
+ class B {
+ public:
+ virtual ~B() {}
+ virtual int bar(int a, int b, int c, int d, int e) {
+ if ((a > 0) && (b > 0) && (c > 0) && (d > 0) && (e > 0)) {
+ return 1;
+ }
+ return 0;
+ }
+ };
+
+ class C : public A, public B {
+ public:
+ virtual int foo(int a, int b, int c, int d, int e) {
+ return A::foo(a,b,c,d,e);
+ }
+ virtual int bar(int a, int b, int c, int d, int e) {
+ return B::bar(a,b,c,d,e);
+ }
+ };
+
+ class D : public C {
+ public:
+ virtual int foo(int a, int b, int c, int d, int e) {
+ return C::foo(a,b,c,d,e);
+ }
+ virtual int bar(int a, int b, int c, int d, int e) {
+ return C::bar(a,b,c,d,e);
+ }
+ };
+ %}
+
+%extend E {
+ %contract manipulate_i(int i) {
+ require:
+ i <= $self->m_i;
+ }
+}
+
+%inline %{
+struct E {
+ int m_i;
+ void manipulate_i(int i) {
+ }
+};
+%}
+
+
+// Namespace
+
+%{
+namespace myNames {
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+%}
+
+namespace myNames {
+
+%contract myClass::myClass( int i ) {
+require:
+ i > 0;
+}
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+
diff --git a/trunk/Examples/test-suite/conversion.i b/trunk/Examples/test-suite/conversion.i
new file mode 100644
index 000000000..bad6c147a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/conversion_namespace.i b/trunk/Examples/test-suite/conversion_namespace.i
new file mode 100644
index 000000000..e090025a3
--- /dev/null
+++ b/trunk/Examples/test-suite/conversion_namespace.i
@@ -0,0 +1,14 @@
+%module conversion_namespace
+%rename(toFoo) oss::Bar::operator Foo();
+
+%inline %{
+ namespace oss
+ {
+ struct Foo {
+ };
+ struct Bar {
+ operator Foo () { return Foo(); }
+ };
+ }
+%}
+
diff --git a/trunk/Examples/test-suite/conversion_ns_template.i b/trunk/Examples/test-suite/conversion_ns_template.i
new file mode 100644
index 000000000..0814f2a18
--- /dev/null
+++ b/trunk/Examples/test-suite/conversion_ns_template.i
@@ -0,0 +1,76 @@
+%module conversion_ns_template
+%{
+ namespace oss
+ {
+ struct Hi
+ {
+ Hi(){}
+ Hi(int){}
+ };
+
+ enum Test {One, Two};
+
+ template <Test>
+ struct Foo {
+ Foo(){}
+ };
+
+ template <Test T>
+ struct Bar {
+ Bar(){ }
+ Bar(int){ }
+
+ 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};
+
+ // these works
+ %ignore Hi::Hi();
+ %rename(create) Hi::Hi(int);
+
+ struct Hi
+ {
+ Hi();
+ Hi(int);
+ };
+
+ template <Test>
+ struct Foo {
+ Foo();
+ };
+
+ // these works
+ %rename(hello1) Bar<One>::operator int&();
+ %ignore Bar<One>::operator int();
+ %rename(hello2) Bar<One>::operator Foo<oss::One>&();
+ %ignore Bar<One>::operator Foo<oss::One>();
+
+ // these don't
+ %ignore Bar<One>::Bar();
+ %rename(Bar_create) Bar<One>::Bar(int);
+
+ template <Test T>
+ struct Bar {
+ Bar();
+ Bar(int);
+ 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/trunk/Examples/test-suite/cplusplus_throw.i b/trunk/Examples/test-suite/cplusplus_throw.i
new file mode 100644
index 000000000..3b11c48ca
--- /dev/null
+++ b/trunk/Examples/test-suite/cplusplus_throw.i
@@ -0,0 +1,28 @@
+/* This interface file checks whether the SWIG parses the throw
+ directive in combination with the const directive. Bug reported by
+ Scott B. Drummonds, 08 June 2001.
+*/
+
+%module cplusplus_throw
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%nodefaultctor;
+
+%inline %{
+
+class Foo { };
+
+class Bar {
+public:
+ void baz() const { };
+ void foo() throw (Foo) { };
+ void bazfoo() const throw (int) { };
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/cpp_basic.i b/trunk/Examples/test-suite/cpp_basic.i
new file mode 100644
index 000000000..a247dd268
--- /dev/null
+++ b/trunk/Examples/test-suite/cpp_basic.i
@@ -0,0 +1,107 @@
+/* This is a basic test of proxy classes, used by chicken */
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) global_cint; /* Ruby, wrong constant name */
+
+%module cpp_basic
+
+%newobject Bar::testFoo;
+
+%inline %{
+
+class Foo {
+ public:
+ Foo(int a) : num(a) {}
+ int num;
+
+ int func1(int a) {
+ return 2*a*num;
+ }
+
+ int func2(int a) {
+ return -a*num;
+ }
+
+ int (Foo::*func_ptr)(int);
+};
+
+%}
+
+%{
+static Foo init_ref = Foo(-4);
+%}
+
+%inline %{
+class Bar {
+ public:
+ Bar() : fptr(0), fref(init_ref), fval(15) , cint(3) {}
+
+ Foo *fptr;
+ Foo &fref;
+ Foo fval;
+
+ const int cint;
+ static const int global_cint = -4;
+
+ static Foo *global_fptr;
+ static Foo &global_fref;
+ static Foo global_fval;
+
+ int test(int a, Foo *f) {
+ return a + (f ? f->num : 0) + fval.num;
+ }
+
+ Foo *testFoo(int a, Foo *f) {
+ return new Foo(2 * a + (f ? f->num : 0) + fval.num);
+ }
+private:
+ Bar& operator=(const Bar&);
+};
+
+%}
+
+%{
+Foo *Bar::global_fptr = NULL;
+Foo &Bar::global_fref = init_ref;
+Foo Bar::global_fval = Foo(3);
+%}
+
+/* member function tests */
+%inline %{
+int (Foo::*get_func1_ptr())(int) {
+ return &Foo::func1;
+}
+
+int (Foo::*get_func2_ptr())(int) {
+ return &Foo::func2;
+}
+
+int test_func_ptr(Foo *f, int a) {
+ return (f->*(f->func_ptr))(a);
+}
+
+%}
+
+
+#ifdef __cplusplus
+%define MACRO_WINDOW_SHOW
+void show(void *count = 0, void *data = 0)
+{
+ return;
+}
+%enddef
+
+%inline %{
+ class Fl_Window {
+ public:
+ Fl_Window() {};
+ ~Fl_Window() {};
+ };
+%}
+
+%extend Fl_Window {
+ MACRO_WINDOW_SHOW
+}
+
+#endif
diff --git a/trunk/Examples/test-suite/cpp_broken.i b/trunk/Examples/test-suite/cpp_broken.i
new file mode 100644
index 000000000..84d6122e5
--- /dev/null
+++ b/trunk/Examples/test-suite/cpp_broken.i
@@ -0,0 +1,12 @@
+%module cpp_broken
+
+
+// bug #940318
+%inline %{
+typedef enum {
+eZero = 0
+#define ONE 1
+} EFoo;
+%}
+
+
diff --git a/trunk/Examples/test-suite/cpp_enum.i b/trunk/Examples/test-suite/cpp_enum.i
new file mode 100644
index 000000000..cb212615a
--- /dev/null
+++ b/trunk/Examples/test-suite/cpp_enum.i
@@ -0,0 +1,54 @@
+/*
+The primary purpose of this testcase is to ensure that enums used along with the 'enum' keyword compile under c++.
+*/
+
+%module cpp_enum
+
+%inline %{
+
+enum SOME_ENUM {ENUM_ONE, ENUM_TWO};
+
+struct StructWithEnums {
+ StructWithEnums() : some_enum(ENUM_ONE) {};
+ enum SOME_ENUM some_enum;
+ void enum_test1(enum SOME_ENUM param1, enum SOME_ENUM* param2, enum SOME_ENUM& param3) {};
+ void enum_test2(SOME_ENUM param1, SOME_ENUM* param2, SOME_ENUM& param3) {};
+
+ SOME_ENUM enum_test3() { return ENUM_ONE; };
+ enum SOME_ENUM enum_test4() { return ENUM_TWO; };
+
+ SOME_ENUM* enum_test5() { return &some_enum; };
+ enum SOME_ENUM* enum_test6() { return &some_enum; };
+
+ SOME_ENUM& enum_test7() { return some_enum; };
+ enum SOME_ENUM& enum_test8() { return some_enum; };
+};
+
+ struct Foo
+ {
+ enum {Hi, Hello } hola;
+
+ Foo()
+ : hola(Hello)
+ {
+ }
+ };
+
+extern "C"
+{
+ enum {Hi, Hello } hi;
+}
+
+%}
+
+// Using true and false in enums is legal in C++. Quoting the standard:
+// [dcl.enum]
+// ... The constant-expression shall be of integral or enumeration type.
+// [basic.fundamental]
+// ... Types bool, char, wchar_t, and the signed and unsigned integer
+// types are collectively called integral types.
+// So this shouldn't lead to a warning, at least in C++ mode.
+%inline %{
+typedef enum { PLAY = true, STOP = false } play_state;
+%}
+
diff --git a/trunk/Examples/test-suite/cpp_namespace.i b/trunk/Examples/test-suite/cpp_namespace.i
new file mode 100644
index 000000000..d7bf95e9f
--- /dev/null
+++ b/trunk/Examples/test-suite/cpp_namespace.i
@@ -0,0 +1,105 @@
+// 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 ~Test2() { }
+ 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/trunk/Examples/test-suite/cpp_nodefault.i b/trunk/Examples/test-suite/cpp_nodefault.i
new file mode 100644
index 000000000..30629ec9c
--- /dev/null
+++ b/trunk/Examples/test-suite/cpp_nodefault.i
@@ -0,0 +1,40 @@
+// This file tests SWIG pass/return by value for
+// a class with no default constructor
+
+%module cpp_nodefault
+
+%inline %{
+
+class Foo {
+public:
+ int a;
+ Foo(int x, int y) { }
+ ~Foo() {}
+};
+
+Foo create(int x, int y) {
+ return Foo(x,y);
+}
+
+typedef Foo Foo_t;
+
+void consume(Foo f, Foo_t g) {}
+
+class Bar {
+public:
+ void consume(Foo f, Foo_t g) {}
+ Foo create(int x, int y) {
+ return Foo(x,y);
+ }
+};
+
+
+%}
+
+%{
+Foo gvar = Foo(3,4);
+%}
+
+Foo gvar;
+
+
diff --git a/trunk/Examples/test-suite/cpp_static.i b/trunk/Examples/test-suite/cpp_static.i
new file mode 100644
index 000000000..c68e986eb
--- /dev/null
+++ b/trunk/Examples/test-suite/cpp_static.i
@@ -0,0 +1,26 @@
+/*
+Testcase to test c++ static member variables and static functions.
+Tests Sourceforge bug #444748.
+*/
+
+%module cpp_static
+
+%inline %{
+
+class StaticMemberTest {
+public:
+ static int static_int;
+};
+
+class StaticFunctionTest {
+public:
+ static void static_func() {};
+ static void static_func_2(int param_1) {};
+ static void static_func_3(int param_1, int param_2) {};
+};
+
+%}
+
+%{
+int StaticMemberTest::static_int;
+%}
diff --git a/trunk/Examples/test-suite/cpp_typedef.i b/trunk/Examples/test-suite/cpp_typedef.i
new file mode 100644
index 000000000..f869f4d9c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/csharp/Makefile.in b/trunk/Examples/test-suite/csharp/Makefile.in
new file mode 100644
index 000000000..afb29dfbf
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/Makefile.in
@@ -0,0 +1,88 @@
+#######################################################################
+# Makefile for C# test-suite
+#######################################################################
+
+LANGUAGE = csharp
+SCRIPTSUFFIX = _runme.cs
+INTERPRETER = @CSHARPCILINTERPRETER@
+CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
+CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@/..
+top_builddir = @top_builddir@/..
+
+CPP_TEST_CASES = \
+ csharp_attributes \
+ csharp_exceptions \
+ csharp_features \
+ csharp_lib_arrays \
+ csharp_prepost \
+ csharp_typemaps \
+ enum_thorough_simple \
+ enum_thorough_typesafe \
+ exception_partial_info \
+ intermediary_classname
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+SWIGOPT += -namespace $*Namespace
+INTERFACEDIR = ../../
+
+CSHARPFLAGSSPECIAL =
+
+# Custom tests - tests with additional commandline options
+intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
+csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
+
+# 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi; \
+ if [ ! -d $* ]; then \
+ mkdir $*; \
+ fi
+
+# Compiles C# files then runs the testcase. A testcase is only run if
+# a file is found which has _runme.cs appended after the testcase name.
+# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
+ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
+ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
+ else \
+ cd $* && \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
+ CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
+ fi
+
+# Clean: remove testcase directories
+%.clean:
+ @if [ -d $* ]; then \
+ rm -rf $*; \
+ fi
+
+clean:
+ @rm -f *.exe *.exe.mdb
diff --git a/trunk/Examples/test-suite/csharp/README b/trunk/Examples/test-suite/csharp/README
new file mode 100644
index 000000000..96dea942c
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/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/trunk/Examples/test-suite/csharp/aggregate_runme.cs b/trunk/Examples/test-suite/csharp/aggregate_runme.cs
new file mode 100644
index 000000000..ee6394b56
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/aggregate_runme.cs
@@ -0,0 +1,28 @@
+using System;
+using aggregateNamespace;
+
+public class runme {
+ static void Main() {
+
+ // Confirm that move() returns correct results under normal use
+ int result = aggregate.move(aggregate.UP);
+ if (result != aggregate.UP) throw new Exception("UP failed");
+
+ result = aggregate.move(aggregate.DOWN);
+ if (result != aggregate.DOWN) throw new Exception("DOWN failed");
+
+ result = aggregate.move(aggregate.LEFT);
+ if (result != aggregate.LEFT) throw new Exception("LEFT failed");
+
+ result = aggregate.move(aggregate.RIGHT);
+ if (result != aggregate.RIGHT) throw new Exception("RIGHT failed");
+
+ // Confirm that move() raises an exception when the contract is violated
+ try {
+ aggregate.move(0);
+ throw new Exception("0 test failed");
+ }
+ catch (ArgumentOutOfRangeException) {
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/allprotected_runme.cs b/trunk/Examples/test-suite/csharp/allprotected_runme.cs
new file mode 100644
index 000000000..99a791d58
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/allprotected_runme.cs
@@ -0,0 +1,71 @@
+using System;
+using allprotectedNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase");
+ mpb.accessProtected();
+ }
+}
+
+class MyProtectedBase : ProtectedBase
+{
+ public MyProtectedBase(string name) : base(name) {
+ }
+ public void accessProtected() {
+ string s = virtualMethod();
+ if (s != "ProtectedBase")
+ throw new Exception("Failed");
+
+ Klass k = instanceMethod(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = ProtectedBase.staticMethod(new Klass("abc"));
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = ProtectedBase.staticOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = ProtectedBase.staticOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ instanceMemberVariable = 30;
+ int i = instanceMemberVariable;
+ if (i != 30)
+ throw new Exception("Failed");
+
+ staticMemberVariable = 40;
+ i = staticMemberVariable;
+ if (i != 40)
+ throw new Exception("Failed");
+
+ i = staticConstMemberVariable;
+ if (i != 20)
+ throw new Exception("Failed");
+
+ anEnum = ProtectedBase.AnEnum.EnumVal1;
+ ProtectedBase.AnEnum ae = anEnum;
+ if (ae != ProtectedBase.AnEnum.EnumVal1)
+ throw new Exception("Failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/apply_strings_runme.cs b/trunk/Examples/test-suite/csharp/apply_strings_runme.cs
new file mode 100644
index 000000000..deaa5213b
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/apply_strings_runme.cs
@@ -0,0 +1,16 @@
+
+using System;
+using apply_stringsNamespace;
+
+public class apply_strings_runme {
+
+ private static string TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+ public static void Main() {
+ if (apply_strings.UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
+ if (apply_strings.SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
+ SWIGTYPE_p_char pChar = apply_strings.CharFunction(null);
+ if (pChar != null) throw new Exception("CharFunction failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/bools_runme.cs b/trunk/Examples/test-suite/csharp/bools_runme.cs
new file mode 100644
index 000000000..70620fcef
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/bools_runme.cs
@@ -0,0 +1,29 @@
+
+// This is the bool runtime testcase. It checks that the C++ bool type works.
+
+using System;
+using boolsNamespace;
+
+public class bools_runme {
+
+ public static void Main() {
+
+ bool t = true;
+ bool f = false;
+
+ check_bo(f);
+ check_bo(t);
+ }
+
+ public static void check_bo(bool input) {
+
+ for( int i=0; i<1000; i++ ) {
+ if( bools.bo(input) != input ) {
+ string ErrorMessage = "Runtime test check_bo failed.";
+ throw new Exception(ErrorMessage);
+ }
+ }
+
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/catches_runme.cs b/trunk/Examples/test-suite/csharp/catches_runme.cs
new file mode 100644
index 000000000..2b5290eac
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/catches_runme.cs
@@ -0,0 +1,66 @@
+using System;
+using catchesNamespace;
+
+public class runme {
+ static void Main() {
+ // test_catches()
+ try {
+ catches.test_catches(1);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ int exception thrown, value: 1")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ catches.test_catches(2);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "two")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ catches.test_catches(3);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ ThreeException const & exception thrown")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ // test_exception_specification()
+ try {
+ catches.test_exception_specification(1);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ int exception thrown, value: 1")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ catches.test_exception_specification(2);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "unknown exception")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ catches.test_exception_specification(3);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "unknown exception")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ // test_catches_all()
+ try {
+ catches.test_catches_all(1);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "unknown exception")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/char_strings_runme.cs b/trunk/Examples/test-suite/csharp/char_strings_runme.cs
new file mode 100644
index 000000000..414d32b7a
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/char_strings_runme.cs
@@ -0,0 +1,155 @@
+
+using System;
+using char_stringsNamespace;
+
+public class char_strings_runme {
+
+ private static string CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+ private static string OTHERLAND_MSG = "Little message from the safe world.";
+
+ public static void Main() {
+
+ uint count = 10000;
+ uint i = 0;
+
+ // get functions
+ for (i=0; i<count; i++) {
+ string str = char_strings.GetCharHeapString();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 1 failed, iteration " + i);
+ char_strings.DeleteCharHeapString();
+ }
+
+ for (i=0; i<count; i++) {
+ string str = char_strings.GetConstCharProgramCodeString();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 2 failed, iteration " + i);
+ char_strings.DeleteCharHeapString();
+ }
+
+ for (i=0; i<count; i++) {
+ string str = char_strings.GetCharStaticString();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 3 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ string str = char_strings.GetCharStaticStringFixed();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 4 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ string str = char_strings.GetConstCharStaticStringFixed();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 5 failed, iteration " + i);
+ }
+
+ // set functions
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharHeapString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 1 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharStaticString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 2 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharArrayStaticString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 3 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharHeapString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 4 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharStaticString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 5 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharArrayStaticString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 6 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharConstStaticString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 7 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharConstStaticString(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char set 8 failed, iteration " + i);
+ }
+
+ // get set function
+ for (i=0; i<count*10; i++) {
+ string ping = OTHERLAND_MSG + i;
+ string pong = char_strings.CharPingPong(ping);
+ if (ping != pong)
+ throw new Exception("Test PingPong 1 failed.\nExpected:" + ping + "\nReceived:" + pong);
+ }
+
+ // variables
+ for (i=0; i<count; i++) {
+ char_strings.global_char = OTHERLAND_MSG + i;
+ if (char_strings.global_char != OTHERLAND_MSG + i)
+ throw new Exception("Test variables 1 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ char_strings.global_char_array1 = OTHERLAND_MSG + i;
+ if (char_strings.global_char_array1 != OTHERLAND_MSG + i)
+ throw new Exception("Test variables 2 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ char_strings.global_char_array2 = OTHERLAND_MSG + i;
+ if (char_strings.global_char_array2 != OTHERLAND_MSG + i)
+ throw new Exception("Test variables 3 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (char_strings.global_const_char != CPLUSPLUS_MSG)
+ throw new Exception("Test variables 4 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (char_strings.global_const_char_array1 != CPLUSPLUS_MSG)
+ throw new Exception("Test variables 5 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (char_strings.global_const_char_array2 != CPLUSPLUS_MSG)
+ throw new Exception("Test variables 6 failed, iteration " + i);
+ }
+
+ // char *& tests
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetCharPointerRef();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char pointer ref get failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharPointerRef(OTHERLAND_MSG + i, i))
+ throw new Exception("Test char pointer ref set failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetConstCharPointerRef();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test const char pointer ref get failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
+ throw new Exception("Test const char pointer ref set failed, iteration " + i);
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/constover_runme.cs b/trunk/Examples/test-suite/csharp/constover_runme.cs
new file mode 100644
index 000000000..bae7b38a6
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/constover_runme.cs
@@ -0,0 +1,34 @@
+using System;
+using constoverNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ string p = constover.test("test");
+ if ( p != "test" )
+ throw new Exception( "test failed!" );
+
+ p = constover.test_pconst("test");
+ if ( p != "test_pconst" )
+ throw new Exception( "test_pconst failed!" );
+
+ Foo f = new Foo();
+ p = f.test("test");
+ if ( p != "test" )
+ throw new Exception( "member-test failed!" );
+
+ p = f.test_pconst("test");
+ if ( p != "test_pconst" )
+ throw new Exception( "member-test_pconst failed!" );
+
+ p = f.test_constm("test");
+ if ( p != "test_constmethod" )
+ throw new Exception( "member-test_constm failed!" );
+
+ p = f.test_pconstm("test");
+ if ( p != "test_pconstmethod" )
+ throw new Exception( "member-test_pconstm failed!" );
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/csharp_attributes_runme.cs b/trunk/Examples/test-suite/csharp/csharp_attributes_runme.cs
new file mode 100644
index 000000000..4cdced80d
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/csharp_attributes_runme.cs
@@ -0,0 +1,266 @@
+using System;
+using System.Reflection;
+using System.ComponentModel;
+using csharp_attributesNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // Custom attributes typemap tests
+ //
+ // cstype typemap attributechecks
+ //
+ // Global function cstype typemap attributes check
+ Type globaltype = typeof(csharp_attributes);
+ {
+ MethodInfo member = (MethodInfo)globaltype.GetMember("GlobalFunction")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
+ throw new Exception("No IntOut attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
+ if (parameter.Name != "myInt")
+ throw new Exception("Incorrect parameter name");
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntInAttribute))
+ throw new Exception("Expecting IntIn attribute");
+ }
+ // Constant - cstype typemap attributes check
+ {
+ MemberInfo member = (MemberInfo)globaltype.GetMember("TESTMACRO")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
+ throw new Exception("No IntOut attribute for " + member.Name);
+ }
+
+ // Non-static method cstype typemap attributes check
+ Type type = typeof(Stations);
+ {
+ MethodInfo member = (MethodInfo)type.GetMember("Reading")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
+ throw new Exception("No IntOut attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
+ if (parameter.Name != "myInt")
+ throw new Exception("Incorrect parameter name");
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntInAttribute))
+ throw new Exception("Expecting IntIn attribute");
+ }
+ // Static method cstype typemap attributes check
+ {
+ MethodInfo member = (MethodInfo)type.GetMember("Swindon")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
+ throw new Exception("No IntOut attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
+ if (parameter.Name != "myInt")
+ throw new Exception("Incorrect parameter name");
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntInAttribute))
+ throw new Exception("Expecting IntIn attribute");
+ }
+ // Constructor cstype typemap attributes check
+ {
+ ConstructorInfo member = (ConstructorInfo)type.GetConstructors()[0];
+ ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
+ if (parameter.Name != "myInt")
+ throw new Exception("Incorrect parameter name");
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntInAttribute))
+ throw new Exception("Expecting IntIn attribute");
+ }
+
+ //
+ // imtype typemap attributechecks
+ //
+ // Global function imtype typemap attributes check
+ Type imclasstype = typeof(csharp_attributesPINVOKE);
+ {
+ MethodInfo member = (MethodInfo)imclasstype.GetMember("GlobalFunction")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
+ throw new Exception("No IntegerOut attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntegerInAttribute))
+ throw new Exception("Expecting IntegerIn attribute");
+ }
+ // Constant - imtype typemap attributes check
+ {
+ MethodInfo member = (MethodInfo)imclasstype.GetMember("TESTMACRO_get")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
+ throw new Exception("No IntegerOut attribute for " + member.Name);
+ }
+ // Non-static method imtype typemap attributes check
+ {
+ MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Reading")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
+ throw new Exception("No IntegerOut attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[1]; // checking 2nd parameter
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntegerInAttribute))
+ throw new Exception("Expecting IntegerIn attribute");
+ }
+ // Static method imtype typemap attributes check
+ {
+ MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Swindon")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
+ throw new Exception("No IntegerOut attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(IntegerInAttribute))
+ throw new Exception("Expecting IntegerIn attribute");
+ }
+
+ //
+ // attributes feature
+ //
+ Type moretype = typeof(MoreStations);
+
+ // Constructor attributes feature check
+ {
+ ConstructorInfo member = (ConstructorInfo)moretype.GetConstructors()[0];
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity1Attribute)) == null)
+ throw new Exception("MoreStations::MoreStations attribute failed");
+ }
+ // Non-static method attributes feature check
+ {
+ MethodInfo member = (MethodInfo)moretype.GetMember("Chippenham")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity2Attribute)) == null)
+ throw new Exception("MoreStations::Chippenham attribute failed");
+ }
+ // Static method attributes feature check
+ {
+ MethodInfo member = (MethodInfo)moretype.GetMember("Bath")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity3Attribute)) == null)
+ throw new Exception("MoreStations::Bath attribute failed");
+ }
+ // Non-static member variable attributes feature check
+ {
+ PropertyInfo member = (PropertyInfo)moretype.GetProperty("Bristol");
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity4Attribute)) == null)
+ throw new Exception("MoreStations::Bristol attribute failed");
+ }
+ // Static member variable attributes feature check
+ {
+ PropertyInfo member = (PropertyInfo)moretype.GetProperty("WestonSuperMare");
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity5Attribute)) == null)
+ throw new Exception("MoreStations::Bristol attribute failed");
+ }
+ // Global function attributes feature check
+ {
+ MethodInfo member = (MethodInfo)globaltype.GetMember("Paddington")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity7Attribute)) == null)
+ throw new Exception("MoreStations::Paddington attribute failed");
+ }
+ // Global variables attributes feature check
+ {
+ PropertyInfo member = (PropertyInfo)globaltype.GetProperty("DidcotParkway");
+ if (Attribute.GetCustomAttribute(member, typeof(InterCity8Attribute)) == null)
+ throw new Exception("MoreStations::Paddington attribute failed");
+ }
+
+ //
+ // csattribute typemaps
+ //
+ // Class csattribute typemap
+ {
+ Object[] attribs = moretype.GetCustomAttributes(true);
+ Eurostar1Attribute tgv = (Eurostar1Attribute)attribs[0];
+ if (tgv == null)
+ throw new Exception("No attribute for MoreStations");
+ }
+ // Nested enum csattribute typemap
+ {
+ MemberInfo member = (MemberInfo)moretype.GetMember("Wales")[0];
+ if (Attribute.GetCustomAttribute(member, typeof(Eurostar2Attribute)) == null)
+ throw new Exception("No attribute for " + member.Name);
+ }
+ // Enum value attributes
+ Type walesType = typeof(MoreStations.Wales);
+ {
+ MemberInfo member = (MemberInfo)walesType.GetMember("Cardiff")[0];
+ DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
+ if (attribute == null)
+ throw new Exception("No attribute for " + member.Name);
+ if (attribute.Description != "Cardiff city station")
+ throw new Exception("Incorrect attribute value for " + member.Name);
+ }
+ {
+ MemberInfo member = (MemberInfo)walesType.GetMember("Swansea")[0];
+ DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
+ if (attribute == null)
+ throw new Exception("No attribute for " + member.Name);
+ if (attribute.Description != "Swansea city station")
+ throw new Exception("Incorrect attribute value for " + member.Name);
+ }
+ // Enum csattribute typemap
+ {
+ Type cymrutype = typeof(Cymru);
+ Object[] attribs = cymrutype.GetCustomAttributes(true);
+ Eurostar3Attribute tgv = (Eurostar3Attribute)attribs[0];
+ if (tgv == null)
+ throw new Exception("No attribute for Cymru");
+ }
+
+ // No runtime test for directorinattributes and directoroutattributes
+ }
+}
+
+// Custom attribute classes
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class IntInAttribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class IntOutAttribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class IntegerInAttribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class IntegerOutAttribute : Attribute {}
+
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity1Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity2Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity3Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity4Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity5Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity6Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity7Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class InterCity8Attribute : Attribute {}
+
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class Eurostar1Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class Eurostar2Attribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class Eurostar3Attribute : Attribute {}
+
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class ThreadSafeAttribute : Attribute {
+ public ThreadSafeAttribute(bool safe) {}
+ public ThreadSafeAttribute() {}
+}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class DirectorIntegerOutAttribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class DirectorIntegerInAttribute : Attribute {}
+
diff --git a/trunk/Examples/test-suite/csharp/csharp_exceptions_runme.cs b/trunk/Examples/test-suite/csharp/csharp_exceptions_runme.cs
new file mode 100644
index 000000000..43585b106
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/csharp_exceptions_runme.cs
@@ -0,0 +1,342 @@
+using System;
+using System.Threading;
+using csharp_exceptionsNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // %exception tests
+ try {
+ csharp_exceptions.ThrowByValue();
+ throw new Exception("ThrowByValue not working");
+ } catch (DivideByZeroException) {
+ }
+ try {
+ csharp_exceptions.ThrowByReference();
+ throw new Exception("ThrowByReference not working");
+ } catch (DivideByZeroException) {
+ }
+
+ // %csnothrowexception
+ csharp_exceptions.NoThrowException();
+ csharp_exceptions.NullReference(new Ex("should not throw"));
+
+ // exception specifications
+ bool testFailed = false;
+ try {
+ csharp_exceptions.ExceptionSpecificationValue();
+ testFailed = true;
+ } catch (ApplicationException) {
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationValue not working");
+ try {
+ csharp_exceptions.ExceptionSpecificationReference();
+ testFailed = true;
+ } catch (ApplicationException) {
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationReference not working");
+ try {
+ csharp_exceptions.ExceptionSpecificationString();
+ testFailed = true;
+ } catch (ApplicationException e) {
+ if (e.Message != "ExceptionSpecificationString") throw new Exception("ExceptionSpecificationString unexpected message: " + e.Message);
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationString not working");
+ try {
+ csharp_exceptions.ExceptionSpecificationInteger();
+ testFailed = true;
+ } catch (ApplicationException) {
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationInteger not working");
+
+ // null reference exceptions
+ try {
+ csharp_exceptions.NullReference(null);
+ throw new Exception("NullReference not working");
+ } catch (ArgumentNullException) {
+ }
+ try {
+ csharp_exceptions.NullValue(null);
+ throw new Exception("NullValue not working");
+ } catch (ArgumentNullException) {
+ }
+
+ // enums
+ try {
+ csharp_exceptions.ExceptionSpecificationEnumValue();
+ testFailed = true;
+ } catch (ApplicationException) {
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationEnumValue not working");
+ try {
+ csharp_exceptions.ExceptionSpecificationEnumReference();
+ testFailed = true;
+ } catch (ApplicationException) {
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationEnumReference not working");
+
+ // std::string
+ try {
+ csharp_exceptions.NullStdStringValue(null);
+ throw new Exception("NullStdStringValue not working");
+ } catch (ArgumentNullException) {
+ }
+ try {
+ csharp_exceptions.NullStdStringReference(null);
+ throw new Exception("NullStdStringReference not working");
+ } catch (ArgumentNullException) {
+ }
+ try {
+ csharp_exceptions.ExceptionSpecificationStdStringValue();
+ testFailed = true;
+ } catch (ApplicationException e) {
+ if (e.Message != "ExceptionSpecificationStdStringValue") throw new Exception("ExceptionSpecificationStdStringValue unexpected message: " + e.Message);
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationStdStringValue not working");
+ try {
+ csharp_exceptions.ExceptionSpecificationStdStringReference();
+ testFailed = true;
+ } catch (ApplicationException e) {
+ if (e.Message != "ExceptionSpecificationStdStringReference") throw new Exception("ExceptionSpecificationStdStringReference unexpected message: " + e.Message);
+ }
+ if (testFailed) throw new Exception("ExceptionSpecificationStdStringReference not working");
+
+ // Memory leak check (The C++ exception stack was never unwound in the original approach to throwing exceptions from unmanaged code)
+ try {
+ csharp_exceptions.MemoryLeakCheck();
+ throw new Exception("MemoryLeakCheck not working");
+ } catch (DivideByZeroException) {
+ }
+ if (Counter.count != 0) throw new Exception("Memory leaks when throwing exception. count: " + Counter.count);
+
+ // test exception pending in the csconstruct typemap
+ try {
+ new constructor(null);
+ throw new Exception("constructor 1 not working");
+ } catch (ArgumentNullException) {
+ }
+ try {
+ new constructor();
+ throw new Exception("constructor 2 not working");
+ } catch (ApplicationException) {
+ }
+
+ // test exception pending in the csout typemaps
+ try {
+ csharp_exceptions.ushorttest();
+ throw new Exception("csout not working");
+ } catch (IndexOutOfRangeException) {
+ }
+
+ // test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps (1) global variables
+ // 1) global variables
+ int numberout = 0;
+ try {
+ csharp_exceptions.numberin = -1;
+ throw new Exception("global csvarin not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ csharp_exceptions.numberin = 5;
+ if (csharp_exceptions.numberin != 5)
+ throw new Exception("global numberin not 5");
+ csharp_exceptions.numberout = 20;
+ try {
+ numberout += csharp_exceptions.numberout;
+ throw new Exception("global csvarout not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ // 2) static member variables
+ try {
+ InOutStruct.staticnumberin = -1;
+ throw new Exception("static csvarin not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ InOutStruct.staticnumberin = 5;
+ if (InOutStruct.staticnumberin != 5)
+ throw new Exception("static staticnumberin not 5");
+ InOutStruct.staticnumberout = 20;
+ try {
+ numberout += InOutStruct.staticnumberout;
+ throw new Exception("static csvarout not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ // 3) member variables
+ InOutStruct io = new InOutStruct();
+ try {
+ io.numberin = -1;
+ throw new Exception("member csvarin not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ io.numberin = 5;
+ if (io.numberin != 5)
+ throw new Exception("member numberin not 5");
+ io.numberout = 20;
+ try {
+ numberout += io.numberout;
+ throw new Exception("member csvarout not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ // test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code
+ try {
+ csharp_exceptions.exceptionmacrotest(-1);
+ throw new Exception("exception macro not working");
+ } catch (IndexOutOfRangeException) {
+ }
+ if (csharp_exceptions.exception_macro_run_flag)
+ throw new Exception("exceptionmacrotest was executed");
+
+ // test all the types of exceptions
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedApplicationException);
+ throw new Exception("ApplicationException not caught");
+ } catch (ApplicationException e) {
+ if (e.Message != "msg") throw new Exception("ApplicationException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArithmeticException);
+ throw new Exception("ArithmeticException not caught");
+ } catch (ArithmeticException e) {
+ if (e.Message != "msg") throw new Exception("ArithmeticException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedDivideByZeroException);
+ throw new Exception("DivideByZeroException not caught");
+ } catch (DivideByZeroException e) {
+ if (e.Message != "msg") throw new Exception("DivideByZeroException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedIndexOutOfRangeException);
+ throw new Exception("IndexOutOfRangeException not caught");
+ } catch (IndexOutOfRangeException e) {
+ if (e.Message != "msg") throw new Exception("IndexOutOfRangeException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedInvalidOperationException);
+ throw new Exception("InvalidOperationException not caught");
+ } catch (InvalidOperationException e) {
+ if (e.Message != "msg") throw new Exception("InvalidOperationException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedIOException);
+ throw new Exception("IOException not caught");
+ } catch (System.IO.IOException e) {
+ if (e.Message != "msg") throw new Exception("IOException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedNullReferenceException);
+ throw new Exception("NullReferenceException not caught");
+ } catch (NullReferenceException e) {
+ if (e.Message != "msg") throw new Exception("NullReferenceException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedOutOfMemoryException);
+ throw new Exception("OutOfMemoryException not caught");
+ } catch (OutOfMemoryException e) {
+ if (e.Message != "msg") throw new Exception("OutOfMemoryException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedOverflowException);
+ throw new Exception("OverflowException not caught");
+ } catch (OverflowException e) {
+ if (e.Message != "msg") throw new Exception("OverflowException msg incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedSystemException);
+ throw new Exception("SystemException not caught");
+ } catch (SystemException e) {
+ if (e.Message != "msg") throw new Exception("SystemException msg incorrect");
+ }
+
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentException);
+ throw new Exception("ArgumentException not caught");
+ } catch (ArgumentException e) {
+ if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentException msg incorrect");
+ if (e.ParamName != "parm") throw new Exception("ArgumentException parm incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentNullException);
+ throw new Exception("ArgumentNullException not caught");
+ } catch (ArgumentNullException e) {
+ if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentNullException msg incorrect");
+ if (e.ParamName != "parm") throw new Exception("ArgumentNullException parm incorrect");
+ }
+ try {
+ csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentOutOfRangeException);
+ throw new Exception("ArgumentOutOfRangeException not caught");
+ } catch (ArgumentOutOfRangeException e) {
+ if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentOutOfRangeException msg incorrect");
+ if (e.ParamName != "parm") throw new Exception("ArgumentOutOfRangeException parm incorrect");
+ }
+
+
+ // exceptions in multiple threads test
+ {
+ ThrowsClass throwsClass = new ThrowsClass(1234.5678);
+ const int NUM_THREADS = 8;
+ Thread[] threads = new Thread[NUM_THREADS];
+ TestThread[] testThreads = new TestThread[NUM_THREADS];
+ // invoke the threads
+ for (int i=0; i<NUM_THREADS; i++) {
+ testThreads[i] = new TestThread(throwsClass, i);
+ threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
+ threads[i].Start();
+ }
+ // wait for the threads to finish
+ for (int i=0; i<NUM_THREADS; i++) {
+ threads[i].Join();
+ }
+ for (int i=0; i<NUM_THREADS; i++) {
+ if (testThreads[i].Failed) throw new Exception("Test Failed");
+ }
+ }
+
+
+ // test inner exceptions
+ try {
+ csharp_exceptions.InnerExceptionTest();
+ throw new Exception("InnerExceptionTest exception not caught");
+ } catch (InvalidOperationException e) {
+ if (e.Message != "My OuterException message") throw new Exception("OuterException msg incorrect");
+ if (e.InnerException.Message != "My InnerException message") throw new Exception("InnerException msg incorrect");
+ }
+ }
+ public static string CRLF = "\r\n"; // Some CLR implementations use a CRLF instead of just CR
+}
+
+public class TestThread {
+ private int threadId;
+ private ThrowsClass throwsClass;
+ public bool Failed;
+ public TestThread(ThrowsClass t, int id) {
+ throwsClass = t;
+ threadId = id;
+ }
+ public void Run() {
+ Failed = false;
+ try {
+ for (int i=0; i<6000; i++) { // run test for about 10 seconds on a 1GHz machine (Mono)
+ try {
+ throwsClass.ThrowException(i);
+ throw new Exception("No exception thrown");
+ } catch (ArgumentOutOfRangeException e) {
+ String expectedMessage = "caught:" + i + "\n" + "Parameter name: input";
+ if (e.Message.Replace(runme.CRLF,"\n") != expectedMessage)
+ throw new Exception("Exception message incorrect. Expected:\n[" + expectedMessage + "]\n" + "Received:\n[" + e.Message + "]");
+ if (e.ParamName != "input")
+ throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]");
+ if (e.InnerException != null)
+ throw new Exception("Unexpected inner exception");
+ }
+ if (throwsClass.dub != 1234.5678) // simple check which attempts to catch memory corruption
+ throw new Exception("throwsException.dub = " + throwsClass.dub + " expected: 1234.5678");
+ }
+ } catch (Exception e) {
+ Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
+ Failed = true;
+ }
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/trunk/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs
new file mode 100644
index 000000000..9f3ea6b88
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs
@@ -0,0 +1,70 @@
+using System;
+using csharp_lib_arraysNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[ source.Length ];
+
+ csharp_lib_arrays.myArrayCopy( source, target, target.Length );
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[ source.Length ];
+
+ csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length );
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[] { 6, 7, 8, 9, 10 };
+
+ csharp_lib_arrays.myArraySwap( source, target, target.Length );
+
+ for (int i=0; i<target.Length; ++i)
+ target[i] += 5;
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[] { 6, 7, 8, 9, 10 };
+
+ csharp_lib_arrays.myArraySwapUsingFixedArrays( source, target, target.Length );
+
+ for (int i=0; i<target.Length; ++i)
+ target[i] += 5;
+ CompareArrays(source, target);
+ }
+ }
+
+ static void CompareArrays( int[] a, int[] b )
+ {
+ if (a.Length != b.Length)
+ throw new Exception("size mismatch");
+
+ for(int i=0; i<a.Length; ++i) {
+ if (a[i] != b[i]) {
+ Console.Error.WriteLine("a:");
+ PrintArray(a);
+ Console.Error.WriteLine("b:");
+ PrintArray(b);
+ throw new Exception("element mismatch");
+ }
+ }
+ }
+
+ static void PrintArray( int[] a )
+ {
+ foreach ( int i in a )
+ Console.Error.Write( "{0} ", i );
+ Console.Error.WriteLine();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/csharp_prepost_runme.cs b/trunk/Examples/test-suite/csharp/csharp_prepost_runme.cs
new file mode 100644
index 000000000..d0bacdaba
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/csharp_prepost_runme.cs
@@ -0,0 +1,70 @@
+
+using System;
+using System.Reflection;
+using csharp_prepostNamespace;
+
+public class csharp_prepost_runme {
+
+ public static void Main() {
+ {
+ double[] v;
+ csharp_prepost.globalfunction(out v);
+ Assert(v.Length, 3);
+ Assert(v[0], 0.0);
+ Assert(v[1], 1.1);
+ Assert(v[2], 2.2);
+ }
+ {
+ double[] v;
+ new PrePostTest(out v);
+ Assert(v.Length, 2);
+ Assert(v[0], 3.3);
+ Assert(v[1], 4.4);
+ }
+ {
+ double[] v;
+ PrePostTest p = new PrePostTest();
+ p.method(out v);
+ Assert(v.Length, 2);
+ Assert(v[0], 5.5);
+ Assert(v[1], 6.6);
+ }
+ {
+ double[] v;
+ PrePostTest.staticmethod(out v);
+ Assert(v.Length, 2);
+ Assert(v[0], 7.7);
+ Assert(v[1], 8.8);
+ }
+
+ // Check attributes are generated for the constructor helper function
+ {
+ CsinAttributes c = new CsinAttributes(5);
+ Assert(c.getVal(), 500);
+
+ Type type = typeof(CsinAttributes);
+ {
+ MethodInfo member = (MethodInfo)type.GetMember("SwigConstructCsinAttributes", BindingFlags.NonPublic | BindingFlags.Static)[0];
+ if (Attribute.GetCustomAttribute(member, typeof(CustomIntPtrAttribute)) == null)
+ throw new Exception("No CustomIntPtr attribute for " + member.Name);
+ ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
+ if (parameter.Name != "val")
+ throw new Exception("Incorrect parameter name");
+ Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
+ if (attribute.GetType() != typeof(CustomIntAttribute))
+ throw new Exception("Expecting CustomInt attribute");
+ }
+ }
+ }
+ private static void Assert(double d1, double d2) {
+ if (d1 != d2)
+ throw new Exception("assertion failure. " + d1 + " != " + d2);
+ }
+}
+
+// Custom attribute classes
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class CustomIntAttribute : Attribute {}
+
+[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+public class CustomIntPtrAttribute : Attribute {}
diff --git a/trunk/Examples/test-suite/csharp/csharp_typemaps_runme.cs b/trunk/Examples/test-suite/csharp/csharp_typemaps_runme.cs
new file mode 100644
index 000000000..846644f09
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/csharp_typemaps_runme.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Threading;
+using csharp_typemapsNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // Test the C# types customisation by modifying the default char * typemaps to return a single char
+ Things things = new Things();
+ System.Text.StringBuilder initialLetters = new System.Text.StringBuilder();
+ char myChar = things.start("boo");
+ initialLetters.Append(myChar);
+ myChar = Things.stop("hiss");
+ initialLetters.Append(myChar);
+ myChar = csharp_typemaps.partyon("off");
+ initialLetters.Append(myChar);
+ if (initialLetters.ToString() != "bho")
+ throw new Exception("initial letters failed");
+
+ // $csinput expansion
+ csharp_typemaps.myInt = 1;
+ try {
+ csharp_typemaps.myInt = -1;
+ throw new Exception("oops");
+ } catch (ApplicationException) {
+ }
+
+ // Eager garbage collector test
+ {
+ const int NUM_THREADS = 8;
+ Thread[] threads = new Thread[NUM_THREADS];
+ TestThread[] testThreads = new TestThread[NUM_THREADS];
+ // invoke the threads
+ for (int i=0; i<NUM_THREADS; i++) {
+ testThreads[i] = new TestThread(i);
+ threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
+ threads[i].Start();
+ }
+ // wait for the threads to finish
+ for (int i=0; i<NUM_THREADS; i++) {
+ threads[i].Join();
+ }
+ for (int i=0; i<NUM_THREADS; i++) {
+ if (testThreads[i].Failed) throw new Exception("Test Failed");
+ }
+ }
+
+ }
+}
+
+
+public class TestThread {
+ private int threadId;
+ public bool Failed;
+ public TestThread(int id) {
+ threadId = id;
+ }
+ public void Run() {
+ Failed = false;
+ try {
+ // Older versions of SWIG used IntPtr instead of HandleRef to hold the underlying
+ // C++ pointer, so this test would (usually) fail as the garbage collector would
+ // sometimes collect the Number class while it was being used in unmanaged code
+ for (int i=0; i<5000; i++) { // run test for a few seconds
+ {
+ Obj obj = new Obj();
+ Number n = new Number(i);
+ Number triple = obj.triple(n);
+ if (triple.Value != i*3)
+ throw new ApplicationException("triple failed: " + triple.Value);
+ }
+ {
+ Obj obj = new Obj();
+ Number n = new Number(i);
+ Number times6 = obj.times6(n);
+ if (times6.Value != i*6)
+ throw new ApplicationException("times6 failed: " + times6.Value);
+ }
+ {
+ Obj obj = new Obj();
+ Number n = new Number(i);
+ Number times9 = obj.times9(n);
+ if (times9.Value != i*9)
+ throw new ApplicationException("times9 failed: " + times9.Value);
+ }
+ {
+ Number n = new Number(i);
+ Number quadruple = csharp_typemaps.quadruple(n);
+ if (quadruple.Value != i*4)
+ throw new ApplicationException("quadruple failed: " + quadruple.Value);
+ }
+ {
+ Number n = new Number(i);
+ Number times8 = csharp_typemaps.times8(n);
+ if (times8.Value != i*8)
+ throw new ApplicationException("times8 failed: " + times8.Value);
+ }
+ {
+ Number n = new Number(i);
+ Number times12 = csharp_typemaps.times12(n);
+ if (times12.Value != i*12)
+ throw new ApplicationException("times12 failed: " + times12.Value);
+ }
+ }
+ } catch (Exception e) {
+ Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
+ Failed = true;
+ }
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/csharp/default_args_runme.cs b/trunk/Examples/test-suite/csharp/default_args_runme.cs
new file mode 100644
index 000000000..68ea0e854
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/default_args_runme.cs
@@ -0,0 +1,143 @@
+using System;
+using default_argsNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ if (default_args.anonymous() != 7771)
+ throw new Exception("anonymous (1) failed");
+ if (default_args.anonymous(1234) != 1234)
+ throw new Exception("anonymous (2) failed");
+
+ if (default_args.booltest() != true)
+ throw new Exception("booltest (1) failed");
+ if (default_args.booltest(true) != true)
+ throw new Exception("booltest (2) failed");
+ if (default_args.booltest(false) != false)
+ throw new Exception("booltest (3) failed");
+
+ EnumClass ec = new EnumClass();
+ if (ec.blah() != true)
+ throw new Exception("EnumClass failed");
+
+ if (default_args.casts1() != null)
+ throw new Exception("casts1 failed");
+
+ if (default_args.casts2() != "Hello")
+ throw new Exception("casts2 failed");
+
+ if (default_args.casts1("Ciao") != "Ciao")
+ throw new Exception("casts1 not default failed");
+
+ if (default_args.chartest1() != 'x')
+ throw new Exception("chartest1 failed");
+
+ if (default_args.chartest2() != '\0')
+ throw new Exception("chartest2 failed");
+
+ if (default_args.chartest1('y') != 'y')
+ throw new Exception("chartest1 not default failed");
+
+ if (default_args.chartest1('y') != 'y')
+ throw new Exception("chartest1 not default failed");
+
+ if (default_args.reftest1() != 42)
+ throw new Exception("reftest1 failed");
+
+ if (default_args.reftest1(400) != 400)
+ throw new Exception("reftest1 not default failed");
+
+ if (default_args.reftest2() != "hello")
+ throw new Exception("reftest2 failed");
+
+ // rename
+ Foo foo = new Foo();
+ foo.newname();
+ foo.newname(10);
+ foo.renamed3arg(10, 10.0);
+ foo.renamed2arg(10);
+ foo.renamed1arg();
+
+ // exception specifications
+ try {
+ default_args.exceptionspec();
+ throw new Exception("exceptionspec 1 failed");
+ } catch (Exception) {
+ }
+ try {
+ default_args.exceptionspec(-1);
+ throw new Exception("exceptionspec 2 failed");
+ } catch (Exception) {
+ }
+ try {
+ default_args.exceptionspec(100);
+ throw new Exception("exceptionspec 3 failed");
+ } catch (Exception) {
+ }
+ Except ex = new Except(false);
+ try {
+ ex.exspec();
+ throw new Exception("exspec 1 failed");
+ } catch (Exception) {
+ }
+ try {
+ ex.exspec(-1);
+ throw new Exception("exspec 2 failed");
+ } catch (Exception) {
+ }
+ try {
+ ex.exspec(100);
+ throw new Exception("exspec 3 failed");
+ } catch (Exception) {
+ }
+ try {
+ ex = new Except(true);
+ throw new Exception("Except constructor 1 failed");
+ } catch (Exception) {
+ }
+ try {
+ ex = new Except(true, -2);
+ throw new Exception("Except constructor 2 failed");
+ } catch (Exception) {
+ }
+
+ // Default parameters in static class methods
+ if (Statics.staticmethod() != 10+20+30)
+ throw new Exception("staticmethod 1 failed");
+ if (Statics.staticmethod(100) != 100+20+30)
+ throw new Exception("staticmethod 2 failed");
+ if (Statics.staticmethod(100,200,300) != 100+200+300)
+ throw new Exception("staticmethod 3 failed");
+
+
+ Tricky tricky = new Tricky();
+ if (tricky.privatedefault() != 200)
+ throw new Exception("privatedefault failed");
+ if (tricky.protectedint() != 2000)
+ throw new Exception("protectedint failed");
+ if (tricky.protecteddouble() != 987.654)
+ throw new Exception("protecteddouble failed");
+ if (tricky.functiondefault() != 500)
+ throw new Exception("functiondefault failed");
+ if (tricky.contrived() != 'X')
+ throw new Exception("contrived failed");
+
+ if (default_args.constructorcall().val != -1)
+ throw new Exception("constructorcall test 1 failed");
+
+ if (default_args.constructorcall(new Klass(2222)).val != 2222)
+ throw new Exception("constructorcall test 2 failed");
+
+ if (default_args.constructorcall(new Klass()).val != -1)
+ throw new Exception("constructorcall test 3 failed");
+
+ // const methods
+ ConstMethods cm = new ConstMethods();
+ if (cm.coo() != 20)
+ throw new Exception("coo test 1 failed");
+ if (cm.coo(1.0) != 20)
+ throw new Exception("coo test 2 failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/default_constructor_runme.cs b/trunk/Examples/test-suite/csharp/default_constructor_runme.cs
new file mode 100644
index 000000000..acd62dc3d
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/default_constructor_runme.cs
@@ -0,0 +1,24 @@
+using System;
+using default_constructorNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // calling protected destructor test
+ try {
+ using (G g = new G()) {
+ }
+ throw new Exception("Protected destructor exception should have been thrown");
+ } catch (MethodAccessException) {
+ }
+
+ // calling private destructor test
+ try {
+ using (FFF f = new FFF()) {
+ }
+ throw new Exception("Private destructor exception should have been thrown");
+ } catch (MethodAccessException) {
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/director_basic_runme.cs b/trunk/Examples/test-suite/csharp/director_basic_runme.cs
new file mode 100644
index 000000000..b9916108c
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_basic_runme.cs
@@ -0,0 +1,74 @@
+using System;
+
+namespace director_basicNamespace {
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ director_basic_MyFoo a = new director_basic_MyFoo();
+
+ if (a.ping() != "director_basic_MyFoo::ping()") {
+ throw new Exception ( "a.ping()" );
+ }
+
+ if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") {
+ throw new Exception ( "a.pong()" );
+ }
+
+ Foo b = new Foo();
+
+ if (b.ping() != "Foo::ping()") {
+ throw new Exception ( "b.ping()" );
+ }
+
+ if (b.pong() != "Foo::pong();Foo::ping()") {
+ throw new Exception ( "b.pong()" );
+ }
+
+ A1 a1 = new A1(1, false);
+ a1.Dispose();
+
+ {
+ MyOverriddenClass my = new MyOverriddenClass();
+
+ my.expectNull = true;
+ if (MyClass.call_pmethod(my, null) != null)
+ throw new Exception("null pointer marshalling problem");
+
+ Bar myBar = new Bar();
+ my.expectNull = false;
+ Bar myNewBar = MyClass.call_pmethod(my, myBar);
+ if (myNewBar == null)
+ throw new Exception("non-null pointer marshalling problem");
+ myNewBar.x = 10;
+ }
+ }
+}
+
+class director_basic_MyFoo : Foo {
+ public director_basic_MyFoo() : base() {
+ }
+
+ public override string ping() {
+ return "director_basic_MyFoo::ping()";
+ }
+}
+
+class MyOverriddenClass : MyClass {
+ public bool expectNull = false;
+ public bool nonNullReceived = false;
+ public override Bar pmethod(Bar b) {
+ if ( expectNull && (b != null) )
+ throw new Exception("null not received as expected");
+ return b;
+ }
+}
+
+}
diff --git a/trunk/Examples/test-suite/csharp/director_classes_runme.cs b/trunk/Examples/test-suite/csharp/director_classes_runme.cs
new file mode 100644
index 000000000..112561464
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_classes_runme.cs
@@ -0,0 +1,180 @@
+/*
+This test demonstrates director classes when the types are classes.
+Shown are virtual function calls which use classes passed by:
+ - Value
+ - Reference
+ - Pointer
+as both parameters and return values.
+The test also demonstrates directors used with:
+ - method overloading
+ - default parameters
+Note: Methods with default parameters that call up from C++ cannot call
+the overloaded C# methods, see DefaultParms method.
+
+Expected output if PrintDebug enabled:
+------------ Start ------------
+Base - Val(444.555)
+Base - Ref(444.555)
+Base - Ptr(444.555)
+Base - FullyOverloaded(int 10)
+Base - FullyOverloaded(bool 1)
+Base - SemiOverloaded(int -678)
+Base - SemiOverloaded(bool 1)
+Base - DefaultParms(10, 2.2)
+Base - DefaultParms(10, 1.1)
+--------------------------------
+Derived - Val(444.555)
+Derived - Ref(444.555)
+Derived - Ptr(444.555)
+Derived - FullyOverloaded(int 10)
+Derived - FullyOverloaded(bool 1)
+Derived - SemiOverloaded(int -678)
+Base - SemiOverloaded(bool 1)
+Derived - DefaultParms(10, 2.2)
+Derived - DefaultParms(10, 1.1)
+--------------------------------
+CSharpDerived - Val(444.555)
+CSharpDerived - Ref(444.555)
+CSharpDerived - Ptr(444.555)
+CSharpDerived - FullyOverloaded(int 10)
+CSharpDerived - FullyOverloaded(bool True)
+CSharpDerived - SemiOverloaded(-678)
+Base - SemiOverloaded(bool 1)
+CSharpDerived - DefaultParms(10, 2.2)
+CSharpDerived - DefaultParms(10, 1.1)
+------------ Finish ------------
+*/
+
+using System;
+
+namespace director_classesNamespace {
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("------------ Start ------------ ");
+
+ Caller myCaller = new Caller();
+
+ // test C++ base class
+ using (Base myBase = new Base(100.0))
+ {
+ makeCalls(myCaller, myBase);
+ }
+
+ if (director_classes.PrintDebug) Console.WriteLine("--------------------------------");
+
+ // test vanilla C++ wrapped derived class
+ using (Base myBase = new Derived(200.0))
+ {
+ makeCalls(myCaller, myBase);
+ }
+
+ if (director_classes.PrintDebug) Console.WriteLine("--------------------------------");
+
+ // test director / C# derived class
+ using (Base myBase = new CSharpDerived(300.0))
+ {
+ makeCalls(myCaller, myBase);
+ }
+
+ if (director_classes.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
+ }
+
+ void makeCalls(Caller myCaller, Base myBase)
+ {
+ string NAMESPACE = "director_classesNamespace.";
+ myCaller.set(myBase);
+
+ DoubleHolder dh = new DoubleHolder(444.555);
+
+ // Class pointer, reference and pass by value tests
+ if (myCaller.ValCall(dh).val != dh.val) throw new Exception("failed");
+ if (myCaller.RefCall(dh).val != dh.val) throw new Exception("failed");
+ if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("failed");
+
+ // Fully overloaded method test (all methods in base class are overloaded)
+ if (NAMESPACE + myCaller.FullyOverloadedCall(10) != myBase.GetType() + "::FullyOverloaded(int)") throw new Exception("failed");
+ if (NAMESPACE + myCaller.FullyOverloadedCall(true) != myBase.GetType() + "::FullyOverloaded(bool)") throw new Exception("failed");
+
+ // Semi overloaded method test (some methods in base class are overloaded)
+ if (NAMESPACE + myCaller.SemiOverloadedCall(-678) != myBase.GetType() + "::SemiOverloaded(int)") throw new Exception("failed");
+ if (myCaller.SemiOverloadedCall(true) != "Base" + "::SemiOverloaded(bool)") throw new Exception("failed");
+
+ // Default parameters methods test
+ if (NAMESPACE + myCaller.DefaultParmsCall(10, 2.2) != myBase.GetType() + "::DefaultParms(int, double)") throw new Exception("failed");
+ if (myBase.GetType() == typeof(CSharpDerived)) { // special handling for C# derived classes, there is no way to do this any other way
+ if (NAMESPACE + myCaller.DefaultParmsCall(10) != myBase.GetType() + "::DefaultParms(int, double)") throw new Exception("failed");
+ } else {
+ if (NAMESPACE + myCaller.DefaultParmsCall(10) != myBase.GetType() + "::DefaultParms(int)") throw new Exception("failed");
+ }
+
+ myCaller.reset();
+ }
+}
+
+public class CSharpDerived : Base
+{
+ public CSharpDerived(double dd)
+ : base(dd)
+ {
+ }
+
+ public override DoubleHolder Val(DoubleHolder x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Val({0})", x.val);
+ return x;
+ }
+ public override DoubleHolder Ref(DoubleHolder x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Ref({0})", x.val);
+ return x;
+ }
+ public override DoubleHolder Ptr(DoubleHolder x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Ptr({0})", x.val);
+ return x;
+ }
+ public override String FullyOverloaded(int x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - FullyOverloaded(int {0})", x);
+ return "CSharpDerived::FullyOverloaded(int)";
+ }
+ public override String FullyOverloaded(bool x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - FullyOverloaded(bool {0})", x);
+ return "CSharpDerived::FullyOverloaded(bool)";
+ }
+ // Note no SemiOverloaded(bool x) method
+ public override String SemiOverloaded(int x)
+ {
+ String ret = "CSharpDerived::SemiOverloaded(int)";
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - SemiOverloaded({0})", x);
+ return ret;
+ }
+ public override String DefaultParms(int x, double y)
+ {
+ String ret = "CSharpDerived::DefaultParms(int, double)";
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - DefaultParms({0}, {1})", x, y);
+ return ret;
+ }
+ // Note the following method can never be called from unmanaged code.
+ // It is here only for code that calls it directly from managed code.
+ // But should always be defined to ensure behaviour is consistent
+ // independent of where DefaultParsms is called from (managed or unmanaged code).
+ // Note this method can never be called from unmanaged code
+ public override String DefaultParms(int x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - DefaultParms({0})", x);
+ return DefaultParms(x, 1.1/*use C++ default here*/);
+ }
+}
+
+}
diff --git a/trunk/Examples/test-suite/csharp/director_classic_runme.cs b/trunk/Examples/test-suite/csharp/director_classic_runme.cs
new file mode 100644
index 000000000..7220437d5
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_classic_runme.cs
@@ -0,0 +1,314 @@
+using System;
+
+namespace director_classicNamespace {
+
+public class runme
+{
+ static void Main()
+ {
+ {
+ Person person = new Person();
+ check(person, "Person");
+ person.Dispose();
+ }
+ {
+ Person person = new Child();
+ check(person, "Child");
+ person.Dispose();
+ }
+ {
+ Person person = new GrandChild();
+ check(person, "GrandChild");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangPerson();
+ check(person, "TargetLangPerson");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangChild();
+ check(person, "TargetLangChild");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangGrandChild();
+ check(person, "TargetLangGrandChild");
+ person.Dispose();
+ }
+
+ // Semis - don't override id() in target language
+ {
+ Person person = new TargetLangSemiPerson();
+ check(person, "Person");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangSemiChild();
+ check(person, "Child");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangSemiGrandChild();
+ check(person, "GrandChild");
+ person.Dispose();
+ }
+
+ // Orphans - don't override id() in C++
+ {
+ Person person = new OrphanPerson();
+ check(person, "Person");
+ person.Dispose();
+ }
+ {
+ Person person = new OrphanChild();
+ check(person, "Child");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangOrphanPerson();
+ check(person, "TargetLangOrphanPerson");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangOrphanChild();
+ check(person, "TargetLangOrphanChild");
+ person.Dispose();
+ }
+
+ // Duals - id() makes an upcall to the base id()
+ {
+ Person person = new TargetLangDualPerson();
+ check(person, "TargetLangDualPerson + Person");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangDualChild();
+ check(person, "TargetLangDualChild + Child");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangDualGrandChild();
+ check(person, "TargetLangDualGrandChild + GrandChild");
+ person.Dispose();
+ }
+
+ // Mix Orphans and Duals
+ {
+ Person person = new TargetLangDualOrphanPerson();
+ check(person, "TargetLangDualOrphanPerson + Person");
+ person.Dispose();
+ }
+ {
+ Person person = new TargetLangDualOrphanChild();
+ check(person, "TargetLangDualOrphanChild + Child");
+ person.Dispose();
+ }
+ }
+
+ static void check(Person person, String expected) {
+ String ret;
+ // Normal target language polymorphic call
+ ret = person.id();
+ if (debug)
+ Console.WriteLine(ret);
+ if (ret != expected)
+ throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
+
+ // Polymorphic call from C++
+ Caller caller = new Caller();
+ caller.setCallback(person);
+ ret = caller.call();
+ if (debug)
+ Console.WriteLine(ret);
+ if (ret != expected)
+ throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
+
+ // Polymorphic call of object created in target language and passed to C++ and back again
+ Person baseclass = caller.baseClass();
+ ret = baseclass.id();
+ if (debug)
+ Console.WriteLine(ret);
+ if (ret != expected)
+ throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
+
+ caller.resetCallback();
+ if (debug)
+ Console.WriteLine("----------------------------------------");
+ }
+ static bool debug = false;
+}
+
+public class TargetLangPerson : Person
+{
+ public TargetLangPerson()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangPerson";
+ return identifier;
+ }
+}
+
+public class TargetLangChild : Child
+{
+ public TargetLangChild()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangChild";
+ return identifier;
+ }
+}
+
+public class TargetLangGrandChild : GrandChild
+{
+ public TargetLangGrandChild()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangGrandChild";
+ return identifier;
+ }
+}
+
+// Semis - don't override id() in target language
+public class TargetLangSemiPerson : Person
+{
+ public TargetLangSemiPerson()
+ : base()
+ {
+ }
+ // No id() override
+}
+
+public class TargetLangSemiChild : Child
+{
+ public TargetLangSemiChild()
+ : base()
+ {
+ }
+ // No id() override
+}
+
+public class TargetLangSemiGrandChild : GrandChild
+{
+ public TargetLangSemiGrandChild()
+ : base()
+ {
+ }
+ // No id() override
+}
+
+// Orphans - don't override id() in C++
+class TargetLangOrphanPerson : OrphanPerson
+{
+ public TargetLangOrphanPerson()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangOrphanPerson";
+ return identifier;
+ }
+}
+
+class TargetLangOrphanChild : OrphanChild
+{
+ public TargetLangOrphanChild()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangOrphanChild";
+ return identifier;
+ }
+}
+
+
+// Duals - id() makes an upcall to the base id()
+class TargetLangDualPerson : Person
+{
+ public TargetLangDualPerson()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangDualPerson + " + base.id();
+ return identifier;
+ }
+}
+
+class TargetLangDualChild : Child
+{
+ public TargetLangDualChild()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangDualChild + " + base.id();
+ return identifier;
+ }
+}
+
+class TargetLangDualGrandChild : GrandChild
+{
+ public TargetLangDualGrandChild()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangDualGrandChild + " + base.id();
+ return identifier;
+ }
+}
+
+// Mix Orphans and Duals
+class TargetLangDualOrphanPerson : OrphanPerson
+{
+ public TargetLangDualOrphanPerson()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangDualOrphanPerson + " + base.id();
+ return identifier;
+ }
+}
+
+class TargetLangDualOrphanChild : OrphanChild
+{
+ public TargetLangDualOrphanChild()
+ : base()
+ {
+ }
+
+ public override String id()
+ {
+ String identifier = "TargetLangDualOrphanChild + " + base.id();
+ return identifier;
+ }
+}
+
+}
diff --git a/trunk/Examples/test-suite/csharp/director_ignore_runme.cs b/trunk/Examples/test-suite/csharp/director_ignore_runme.cs
new file mode 100644
index 000000000..481b1f40a
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_ignore_runme.cs
@@ -0,0 +1,57 @@
+using System;
+
+namespace director_ignoreNamespace {
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ // Just check the classes can be instantiated and other methods work as expected
+ DIgnoresDerived a = new DIgnoresDerived();
+ if (a.Triple(5) != 15)
+ throw new Exception("Triple failed");
+ DAbstractIgnoresDerived b = new DAbstractIgnoresDerived();
+ if (b.Quadruple(5) != 20)
+ throw new Exception("Quadruple failed");
+ }
+}
+
+class DIgnoresDerived : DIgnores
+{
+ public DIgnoresDerived() : base()
+ {
+ }
+
+ // These will give a warning if the %ignore is not working
+ public virtual int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
+ public virtual int OverloadedMethod(int n, int xoffset) { return 0; }
+ public virtual int OverloadedMethod(int n) { return 0; }
+
+ public virtual int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
+ public virtual int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
+ public virtual int OverloadedProtectedMethod(int n) { return 0; }
+}
+
+class DAbstractIgnoresDerived : DAbstractIgnores
+{
+ public DAbstractIgnoresDerived() : base()
+ {
+ }
+
+ // These will give a warning if the %ignore is not working
+ public virtual int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
+ public virtual int OverloadedMethod(int n, int xoffset) { return 0; }
+ public virtual int OverloadedMethod(int n) { return 0; }
+
+ public virtual int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
+ public virtual int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
+ public virtual int OverloadedProtectedMethod(int n) { return 0; }
+}
+
+}
diff --git a/trunk/Examples/test-suite/csharp/director_primitives_runme.cs b/trunk/Examples/test-suite/csharp/director_primitives_runme.cs
new file mode 100644
index 000000000..0a8f705dc
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_primitives_runme.cs
@@ -0,0 +1,127 @@
+/*
+ This test program shows a C# class CSharpDerived inheriting from Base. Three types of classes are created
+ and the virtual methods called to demonstrate:
+ 1) Wide variety of primitive types
+ 2) Calling methods with zero, one or more parameters
+ 3) Director methods that are not overridden in C#
+ 4) Director classes that are not overridden at all in C#, ie non-director behaviour is as expected for director classes
+ 5) Inheritance hierarchy using director methods
+ 6) Return types working as well as parameters
+
+ The Caller class is a tester class, which calls the virtual functions from C++.
+*/
+
+using System;
+using director_primitivesNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("------------ Start ------------ ");
+
+ Caller myCaller = new Caller();
+
+ // test C++ base class
+ using (Base myBase = new Base(100.0))
+ {
+ makeCalls(myCaller, myBase);
+ }
+
+ if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");
+
+ // test vanilla C++ wrapped derived class
+ using (Base myBase = new Derived(200.0))
+ {
+ makeCalls(myCaller, myBase);
+ }
+
+ if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");
+
+ // test director / C# derived class
+ using (Base myBase = new CSharpDerived(300.0))
+ {
+ makeCalls(myCaller, myBase);
+ }
+
+ if (director_primitives.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
+ }
+
+ void makeCalls(Caller myCaller, Base myBase)
+ {
+ myCaller.set(myBase);
+
+ myCaller.NoParmsMethodCall();
+ if (myCaller.BoolMethodCall(true) != true) throw new Exception("failed");
+ if (myCaller.BoolMethodCall(false) != false) throw new Exception("failed");
+ if (myCaller.IntMethodCall(-123) != -123) throw new Exception("failed");
+ if (myCaller.UIntMethodCall(123) != 123) throw new Exception("failed");
+ if (myCaller.FloatMethodCall((float)-123.456) != (float)-123.456) throw new Exception("failed");
+ if (myCaller.CharPtrMethodCall("test string") != "test string") throw new Exception("failed");
+ if (myCaller.ConstCharPtrMethodCall("another string") != "another string") throw new Exception("failed");
+ if (myCaller.EnumMethodCall(HShadowMode.HShadowHard) != HShadowMode.HShadowHard) throw new Exception("failed");
+ myCaller.ManyParmsMethodCall(true, -123, 123, (float)123.456, "test string", "another string", HShadowMode.HShadowHard);
+ myCaller.NotOverriddenMethodCall();
+
+ myCaller.reset();
+ }
+}
+
+public class CSharpDerived : Base
+{
+ public CSharpDerived(double dd)
+ : base(dd)
+ {
+ }
+
+ public override void NoParmsMethod()
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - NoParmsMethod()");
+ }
+ public override bool BoolMethod(bool x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - BoolMethod({0})", x);
+ return x;
+ }
+ public override int IntMethod(int x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - IntMethod({0})", x);
+ return x;
+ }
+ public override uint UIntMethod(uint x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - UIntMethod({0})", x);
+ return x;
+ }
+ public override float FloatMethod(float x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - FloatMethod({0})", x);
+ return x;
+ }
+ public override string CharPtrMethod(string x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - CharPtrMethod({0})", x);
+ return x;
+ }
+ public override string ConstCharPtrMethod(string x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - ConstCharPtrMethod({0})", x);
+ return x;
+ }
+ public override HShadowMode EnumMethod(HShadowMode x)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - EnumMethod({0})", x);
+ return x;
+ }
+ public override void ManyParmsMethod(bool b, int i, uint u, float f, string c, string cc, HShadowMode h)
+ {
+ if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - ManyParmsMethod({0}, {1}, {2}, {3}, {4}, {5}, {6})", b, i, u, f, c, cc, h);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/director_protected_runme.cs b/trunk/Examples/test-suite/csharp/director_protected_runme.cs
new file mode 100644
index 000000000..ee4697b0e
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_protected_runme.cs
@@ -0,0 +1,72 @@
+using System;
+
+namespace director_protectedNamespace {
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ Bar b = new Bar();
+ Foo f = b.create();
+ FooBar fb = new FooBar();
+ FooBar2 fb2 = new FooBar2();
+
+ String s;
+ s = fb.used();
+ if ( s != ("Foo::pang();Bar::pong();Foo::pong();FooBar::ping();"))
+ throw new Exception("bad FooBar::used" + " - " + s);
+
+ s = fb2.used();
+ if ( s != ("FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();"))
+ throw new Exception("bad FooBar2::used");
+
+ s = b.pong();
+ if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
+ throw new Exception("bad Bar::pong");
+
+ s = f.pong();
+ if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
+ throw new Exception("bad Foo::pong");
+
+ s = fb.pong();
+ if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
+ throw new Exception("bad FooBar::pong");
+ }
+}
+
+class FooBar : Bar
+{
+ public FooBar() : base()
+ {
+ }
+
+ protected override String ping()
+ {
+ return "FooBar::ping();";
+ }
+}
+
+class FooBar2 : Bar
+{
+ public FooBar2() : base()
+ {
+ }
+
+ protected override String ping()
+ {
+ return "FooBar2::ping();";
+ }
+
+ protected override String pang()
+ {
+ return "FooBar2::pang();";
+ }
+}
+
+}
diff --git a/trunk/Examples/test-suite/csharp/director_string_runme.cs b/trunk/Examples/test-suite/csharp/director_string_runme.cs
new file mode 100644
index 000000000..0b1b04fa4
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/director_string_runme.cs
@@ -0,0 +1,53 @@
+using System;
+using director_stringNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ String s;
+
+ director_string_A c = new director_string_A("hi");
+ for (int i=0; i<3; i++) {
+ s = c.call_get(i);
+ Object ii = i;
+ if (s != ii.ToString()) throw new Exception("director_string_A.get(" + i + ") failed. Got:" + s);
+ }
+
+ director_string_B b = new director_string_B("hello");
+
+ s = b.call_get_first();
+ if (s != "director_string_B.get_first") throw new Exception("call_get_first() failed");
+
+ s = b.call_get(0);
+ if (s != "director_string_B.get: hello") throw new Exception("get(0) failed");
+ }
+}
+
+class director_string_B : A {
+ public director_string_B(String first) : base(first) {
+ }
+ public override String get_first() {
+ return "director_string_B.get_first";
+ }
+
+ public override String get(int n) {
+ return "director_string_B.get: " + base.get(n);
+ }
+}
+
+class director_string_A : A {
+ public director_string_A(String first) : base(first) {
+ }
+ public override String get(int n) {
+ Object nn = n;
+ return nn.ToString();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/enum_thorough_runme.cs b/trunk/Examples/test-suite/csharp/enum_thorough_runme.cs
new file mode 100644
index 000000000..144736f2b
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/enum_thorough_runme.cs
@@ -0,0 +1,410 @@
+using System;
+using enum_thoroughNamespace;
+
+public class runme {
+ static void Main() {
+ {
+ // Anonymous enums
+ int i = enum_thorough.AnonEnum1;
+ if (enum_thorough.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
+ i += enum_thorough.AnonSpaceEnum1;
+ i += AnonStruct.AnonStructEnum1;
+ }
+ {
+ colour red = colour.red;
+ enum_thorough.colourTest1(red);
+ enum_thorough.colourTest2(red);
+ enum_thorough.colourTest3(red);
+ enum_thorough.colourTest4(red);
+ enum_thorough.myColour = red;
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed speed = SpeedClass.speed.slow;
+ if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
+
+ if (enum_thorough.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
+ if (enum_thorough.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
+ if (enum_thorough.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
+ if (enum_thorough.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
+ if (enum_thorough.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed slow = SpeedClass.speed.slow;
+ SpeedClass.speed lightning = SpeedClass.speed.lightning;
+
+ if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
+ if ((int)s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed");
+
+ s.mySpeedtd1 = lightning;
+ if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
+ if ((int)s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed");
+ }
+ {
+ twonames val = twonames.TwoNames2;
+ if (enum_thorough.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (enum_thorough.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (enum_thorough.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ namedanonspace val = namedanonspace.NamedAnonSpace2;
+ if (enum_thorough.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
+ if (enum_thorough.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
+ if (enum_thorough.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
+ if (enum_thorough.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
+
+ if (enum_thorough.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
+ if (enum_thorough.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
+ if (enum_thorough.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
+ if (enum_thorough.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
+ if (enum_thorough.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
+ if (enum_thorough.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
+ if (enum_thorough.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
+ if (enum_thorough.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ TClassInt.scientists bell = TClassInt.scientists.bell;
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
+
+ if (enum_thorough.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
+ if (enum_thorough.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
+ if (enum_thorough.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
+ if (enum_thorough.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
+ if (enum_thorough.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
+ if (enum_thorough.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
+ if (enum_thorough.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ newname val = newname.argh;
+ if (enum_thorough.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
+ if (enum_thorough.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed");
+ if (enum_thorough.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed");
+ if (enum_thorough.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed");
+ if (enum_thorough.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed");
+ if (enum_thorough.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ TreesClass.trees pine = TreesClass.trees.pine;
+
+ if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
+
+ if (enum_thorough.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
+ if (enum_thorough.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
+ if (enum_thorough.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
+ if (enum_thorough.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
+ if (enum_thorough.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
+ if (enum_thorough.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
+ if (enum_thorough.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
+ if (enum_thorough.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
+ if (enum_thorough.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
+ if (enum_thorough.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
+ if (enum_thorough.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
+ if (enum_thorough.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
+ if (enum_thorough.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
+ if (enum_thorough.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
+ if (enum_thorough.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
+ if (enum_thorough.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
+ if (enum_thorough.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
+ if (enum_thorough.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
+ if (enum_thorough.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
+ if (enum_thorough.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
+ if (enum_thorough.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
+ if (enum_thorough.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
+// if (enum_thorough.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
+ if (enum_thorough.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
+ if (enum_thorough.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
+ if (enum_thorough.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
+ if (enum_thorough.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ HairStruct.hair ginger = HairStruct.hair.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
+
+ colour red = colour.red;
+ if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
+
+ TreesClass.trees fir = TreesClass.trees.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+ if (enum_thorough.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
+ if (enum_thorough.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
+ if (enum_thorough.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
+ if (enum_thorough.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
+ if (enum_thorough.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
+ if (enum_thorough.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
+ if (enum_thorough.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
+ if (enum_thorough.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
+ if (enum_thorough.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
+ if (enum_thorough.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
+ if (enum_thorough.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
+ if (enum_thorough.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
+
+ if (enum_thorough.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
+ if (enum_thorough.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
+ if (enum_thorough.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
+ if (enum_thorough.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
+ if (enum_thorough.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
+ if (enum_thorough.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
+ if (enum_thorough.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
+ if (enum_thorough.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
+ if (enum_thorough.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
+ if (enum_thorough.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
+ if (enum_thorough.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
+ if (enum_thorough.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
+
+ if (enum_thorough.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
+ if (enum_thorough.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
+ if (enum_thorough.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
+ if (enum_thorough.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
+ if (enum_thorough.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
+ if (enum_thorough.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
+ if (enum_thorough.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
+ if (enum_thorough.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
+ if (enum_thorough.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
+ if (enum_thorough.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
+ if (enum_thorough.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
+ if (enum_thorough.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
+
+ if (enum_thorough.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
+ if (enum_thorough.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
+ if (enum_thorough.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
+ if (enum_thorough.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
+ if (enum_thorough.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
+ if (enum_thorough.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
+ if (enum_thorough.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
+ if (enum_thorough.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
+ if (enum_thorough.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
+ if (enum_thorough.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
+ if (enum_thorough.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
+ if (enum_thorough.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
+ }
+ {
+ enum_thorough.GlobalInstance = enum_thorough.globalinstance2;
+ if (enum_thorough.GlobalInstance != enum_thorough.globalinstance2) throw new Exception("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.MemberInstance = Instances.memberinstance3;
+ if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
+ if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
+ if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
+ if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if ((int)enum_thorough.repeatTest(repeat.one) != 1) throw new Exception("repeatTest 1 failed");
+ if ((int)enum_thorough.repeatTest(repeat.initial) != 1) throw new Exception("repeatTest 2 failed");
+ if ((int)enum_thorough.repeatTest(repeat.two) != 2) throw new Exception("repeatTest 3 failed");
+ if ((int)enum_thorough.repeatTest(repeat.three) != 3) throw new Exception("repeatTest 4 failed");
+ if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
+ if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/trunk/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
new file mode 100644
index 000000000..d5bba1b7d
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
@@ -0,0 +1,410 @@
+using System;
+using enum_thorough_simpleNamespace;
+
+public class runme {
+ static void Main() {
+ {
+ // Anonymous enums
+ int i = enum_thorough_simple.AnonEnum1;
+ if (enum_thorough_simple.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
+ i += enum_thorough_simple.AnonSpaceEnum1;
+ i += AnonStruct.AnonStructEnum1;
+ }
+ {
+ int red = enum_thorough_simple.red;
+ enum_thorough_simple.colourTest1(red);
+ enum_thorough_simple.colourTest2(red);
+ enum_thorough_simple.colourTest3(red);
+ enum_thorough_simple.colourTest4(red);
+ enum_thorough_simple.myColour = red;
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ int speed = SpeedClass.slow;
+ if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
+
+ if (enum_thorough_simple.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
+ if (enum_thorough_simple.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
+ if (enum_thorough_simple.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
+ if (enum_thorough_simple.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
+ if (enum_thorough_simple.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ int slow = SpeedClass.slow;
+ int lightning = SpeedClass.lightning;
+
+ if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
+ if (s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed");
+
+ s.mySpeedtd1 = lightning;
+ if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
+ if (s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough_simple.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new Exception("namedanonTest 1 failed");
+ }
+ {
+ int val = enum_thorough_simple.TwoNames2;
+ if (enum_thorough_simple.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (enum_thorough_simple.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (enum_thorough_simple.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ int val = TwoNamesStruct.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ int val = enum_thorough_simple.NamedAnonSpace2;
+ if (enum_thorough_simple.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
+ if (enum_thorough_simple.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
+ if (enum_thorough_simple.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
+ if (enum_thorough_simple.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ int galileo = TemplateClassInt.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
+
+ if (enum_thorough_simple.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
+ if (enum_thorough_simple.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
+ if (enum_thorough_simple.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
+ if (enum_thorough_simple.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
+ if (enum_thorough_simple.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
+ if (enum_thorough_simple.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
+ if (enum_thorough_simple.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
+ if (enum_thorough_simple.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ int bell = TClassInt.bell;
+ int galileo = TemplateClassInt.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
+
+ if (enum_thorough_simple.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
+ if (enum_thorough_simple.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
+ if (enum_thorough_simple.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
+ if (enum_thorough_simple.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
+ if (enum_thorough_simple.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
+ if (enum_thorough_simple.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
+ if (enum_thorough_simple.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough_simple.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough_simple.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough_simple.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ int val = enum_thorough_simple.argh;
+ if (enum_thorough_simple.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
+ if (enum_thorough_simple.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simple1) != NewNameStruct.simple1) throw new Exception("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new Exception("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough_simple.renameTest3(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest Global 3 failed");
+ if (enum_thorough_simple.renameTest4(NewNameStruct.simple1) != NewNameStruct.simple1) throw new Exception("renameTest Global 4 failed");
+ if (enum_thorough_simple.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest Global 5 failed");
+ if (enum_thorough_simple.renameTest6(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest Global 6 failed");
+ if (enum_thorough_simple.renameTest7(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new Exception("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ int pine = TreesClass.pine;
+
+ if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
+
+ if (enum_thorough_simple.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
+ if (enum_thorough_simple.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
+ if (enum_thorough_simple.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
+ if (enum_thorough_simple.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
+ if (enum_thorough_simple.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
+ if (enum_thorough_simple.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
+ if (enum_thorough_simple.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
+ if (enum_thorough_simple.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
+ if (enum_thorough_simple.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
+ if (enum_thorough_simple.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
+ if (enum_thorough_simple.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
+ if (enum_thorough_simple.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
+ if (enum_thorough_simple.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
+ if (enum_thorough_simple.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
+ if (enum_thorough_simple.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
+ if (enum_thorough_simple.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
+ if (enum_thorough_simple.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
+ if (enum_thorough_simple.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
+ if (enum_thorough_simple.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
+ if (enum_thorough_simple.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
+ if (enum_thorough_simple.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
+ if (enum_thorough_simple.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
+// if (enum_thorough_simple.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
+ if (enum_thorough_simple.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
+ if (enum_thorough_simple.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
+ if (enum_thorough_simple.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
+ if (enum_thorough_simple.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ int ginger = HairStruct.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
+
+ int red = enum_thorough_simple.red;
+ if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(enum_thorough_simple.NamedAnonSpace2) != enum_thorough_simple.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
+
+ int fir = TreesClass.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ int blonde = HairStruct.blonde;
+ if (enum_thorough_simple.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
+ if (enum_thorough_simple.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
+ if (enum_thorough_simple.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
+ if (enum_thorough_simple.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
+ if (enum_thorough_simple.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
+ if (enum_thorough_simple.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
+ if (enum_thorough_simple.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
+ if (enum_thorough_simple.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
+ if (enum_thorough_simple.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
+ if (enum_thorough_simple.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
+ if (enum_thorough_simple.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
+ if (enum_thorough_simple.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
+
+ if (enum_thorough_simple.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
+ if (enum_thorough_simple.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
+ if (enum_thorough_simple.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
+ if (enum_thorough_simple.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
+ if (enum_thorough_simple.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
+ if (enum_thorough_simple.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
+ if (enum_thorough_simple.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
+ if (enum_thorough_simple.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
+ if (enum_thorough_simple.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
+ if (enum_thorough_simple.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
+ if (enum_thorough_simple.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
+ if (enum_thorough_simple.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
+
+ if (enum_thorough_simple.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
+ if (enum_thorough_simple.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
+ if (enum_thorough_simple.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
+ if (enum_thorough_simple.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
+ if (enum_thorough_simple.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
+ if (enum_thorough_simple.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
+ if (enum_thorough_simple.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
+ if (enum_thorough_simple.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
+ if (enum_thorough_simple.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
+ if (enum_thorough_simple.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
+ if (enum_thorough_simple.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
+ if (enum_thorough_simple.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
+
+ if (enum_thorough_simple.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
+ if (enum_thorough_simple.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
+ if (enum_thorough_simple.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
+ if (enum_thorough_simple.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
+ if (enum_thorough_simple.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
+ if (enum_thorough_simple.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
+ if (enum_thorough_simple.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
+ if (enum_thorough_simple.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
+ if (enum_thorough_simple.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
+ if (enum_thorough_simple.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
+ if (enum_thorough_simple.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
+ if (enum_thorough_simple.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ int blonde = HairStruct.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
+ }
+ {
+ enum_thorough_simple.GlobalInstance = enum_thorough_simple.globalinstance2;
+ if (enum_thorough_simple.GlobalInstance != enum_thorough_simple.globalinstance2) throw new Exception("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.MemberInstance = Instances.memberinstance3;
+ if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.one) != 1) throw new Exception("repeatTest 1 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.initial) != 1) throw new Exception("repeatTest 2 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.two) != 2) throw new Exception("repeatTest 3 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.three) != 3) throw new Exception("repeatTest 4 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/trunk/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
new file mode 100644
index 000000000..3606d1137
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
@@ -0,0 +1,410 @@
+using System;
+using enum_thorough_typesafeNamespace;
+
+public class runme {
+ static void Main() {
+ {
+ // Anonymous enums
+ int i = enum_thorough_typesafe.AnonEnum1;
+ if (enum_thorough_typesafe.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
+ i += enum_thorough_typesafe.AnonSpaceEnum1;
+ i += AnonStruct.AnonStructEnum1;
+ }
+ {
+ colour red = colour.red;
+ enum_thorough_typesafe.colourTest1(red);
+ enum_thorough_typesafe.colourTest2(red);
+ enum_thorough_typesafe.colourTest3(red);
+ enum_thorough_typesafe.colourTest4(red);
+ enum_thorough_typesafe.myColour = red;
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed speed = SpeedClass.speed.slow;
+ if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
+
+ if (enum_thorough_typesafe.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
+ if (enum_thorough_typesafe.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
+ if (enum_thorough_typesafe.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
+ if (enum_thorough_typesafe.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
+ if (enum_thorough_typesafe.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed slow = SpeedClass.speed.slow;
+ SpeedClass.speed lightning = SpeedClass.speed.lightning;
+
+ if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
+ if (s.mySpeedtd1.swigValue != 10) throw new Exception("mySpeedtd1 2 failed");
+
+ s.mySpeedtd1 = lightning;
+ if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
+ if (s.mySpeedtd1.swigValue != 31) throw new Exception("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough_typesafe.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed");
+ }
+ {
+ twonames val = twonames.TwoNames2;
+ if (enum_thorough_typesafe.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (enum_thorough_typesafe.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (enum_thorough_typesafe.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ namedanonspace val = namedanonspace.NamedAnonSpace2;
+ if (enum_thorough_typesafe.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
+ if (enum_thorough_typesafe.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
+ if (enum_thorough_typesafe.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
+ if (enum_thorough_typesafe.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
+
+ if (enum_thorough_typesafe.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
+ if (enum_thorough_typesafe.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
+ if (enum_thorough_typesafe.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
+ if (enum_thorough_typesafe.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
+ if (enum_thorough_typesafe.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
+ if (enum_thorough_typesafe.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
+ if (enum_thorough_typesafe.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
+ if (enum_thorough_typesafe.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ TClassInt.scientists bell = TClassInt.scientists.bell;
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
+
+ if (enum_thorough_typesafe.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
+ if (enum_thorough_typesafe.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
+ if (enum_thorough_typesafe.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
+ if (enum_thorough_typesafe.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
+ if (enum_thorough_typesafe.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
+ if (enum_thorough_typesafe.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
+ if (enum_thorough_typesafe.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough_typesafe.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough_typesafe.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough_typesafe.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough_typesafe.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ newname val = newname.argh;
+ if (enum_thorough_typesafe.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
+ if (enum_thorough_typesafe.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough_typesafe.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed");
+ if (enum_thorough_typesafe.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed");
+ if (enum_thorough_typesafe.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed");
+ if (enum_thorough_typesafe.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed");
+ if (enum_thorough_typesafe.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ TreesClass.trees pine = TreesClass.trees.pine;
+
+ if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
+
+ if (enum_thorough_typesafe.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
+ if (enum_thorough_typesafe.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
+ if (enum_thorough_typesafe.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
+ if (enum_thorough_typesafe.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
+ if (enum_thorough_typesafe.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
+ if (enum_thorough_typesafe.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
+ if (enum_thorough_typesafe.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
+ if (enum_thorough_typesafe.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
+ if (enum_thorough_typesafe.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
+ if (enum_thorough_typesafe.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
+ if (enum_thorough_typesafe.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
+ if (enum_thorough_typesafe.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
+ if (enum_thorough_typesafe.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
+ if (enum_thorough_typesafe.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
+ if (enum_thorough_typesafe.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
+ if (enum_thorough_typesafe.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
+ if (enum_thorough_typesafe.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
+ if (enum_thorough_typesafe.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
+ if (enum_thorough_typesafe.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
+ if (enum_thorough_typesafe.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
+ if (enum_thorough_typesafe.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
+ if (enum_thorough_typesafe.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
+// if (enum_thorough_typesafe.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
+ if (enum_thorough_typesafe.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
+ if (enum_thorough_typesafe.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
+ if (enum_thorough_typesafe.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
+ if (enum_thorough_typesafe.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ HairStruct.hair ginger = HairStruct.hair.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
+
+ colour red = colour.red;
+ if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
+
+ TreesClass.trees fir = TreesClass.trees.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+ if (enum_thorough_typesafe.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
+ if (enum_thorough_typesafe.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
+ if (enum_thorough_typesafe.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
+ if (enum_thorough_typesafe.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
+ if (enum_thorough_typesafe.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
+ if (enum_thorough_typesafe.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
+ if (enum_thorough_typesafe.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
+ if (enum_thorough_typesafe.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
+ if (enum_thorough_typesafe.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
+ if (enum_thorough_typesafe.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
+ if (enum_thorough_typesafe.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
+ if (enum_thorough_typesafe.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
+
+ if (enum_thorough_typesafe.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
+ if (enum_thorough_typesafe.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
+ if (enum_thorough_typesafe.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
+ if (enum_thorough_typesafe.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
+ if (enum_thorough_typesafe.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
+ if (enum_thorough_typesafe.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
+ if (enum_thorough_typesafe.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
+ if (enum_thorough_typesafe.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
+ if (enum_thorough_typesafe.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
+ if (enum_thorough_typesafe.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
+ if (enum_thorough_typesafe.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
+ if (enum_thorough_typesafe.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
+
+ if (enum_thorough_typesafe.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
+ if (enum_thorough_typesafe.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
+ if (enum_thorough_typesafe.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
+ if (enum_thorough_typesafe.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
+ if (enum_thorough_typesafe.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
+ if (enum_thorough_typesafe.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
+ if (enum_thorough_typesafe.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
+ if (enum_thorough_typesafe.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
+ if (enum_thorough_typesafe.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
+ if (enum_thorough_typesafe.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
+ if (enum_thorough_typesafe.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
+ if (enum_thorough_typesafe.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
+
+ if (enum_thorough_typesafe.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
+ if (enum_thorough_typesafe.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
+ if (enum_thorough_typesafe.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
+ if (enum_thorough_typesafe.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
+ if (enum_thorough_typesafe.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
+ if (enum_thorough_typesafe.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
+ if (enum_thorough_typesafe.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
+ if (enum_thorough_typesafe.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
+ if (enum_thorough_typesafe.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
+ if (enum_thorough_typesafe.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
+ if (enum_thorough_typesafe.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
+ if (enum_thorough_typesafe.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
+ }
+ {
+ enum_thorough_typesafe.GlobalInstance = enum_thorough_typesafe.globalinstance2;
+ if (enum_thorough_typesafe.GlobalInstance != enum_thorough_typesafe.globalinstance2) throw new Exception("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.MemberInstance = Instances.memberinstance3;
+ if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue != 0) throw new Exception("ignoreATest 0 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue != 3) throw new Exception("ignoreATest 3 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue != 10) throw new Exception("ignoreATest 10 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue != 11) throw new Exception("ignoreATest 11 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue != 13) throw new Exception("ignoreATest 13 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue != 14) throw new Exception("ignoreATest 14 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue != 20) throw new Exception("ignoreATest 20 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue != 30) throw new Exception("ignoreATest 30 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue != 32) throw new Exception("ignoreATest 32 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue != 11) throw new Exception("ignoreBTest 11 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue != 12) throw new Exception("ignoreBTest 12 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue != 31) throw new Exception("ignoreBTest 31 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue != 32) throw new Exception("ignoreBTest 32 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue != 41) throw new Exception("ignoreBTest 41 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue != 10) throw new Exception("ignoreCTest 10 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue != 12) throw new Exception("ignoreCTest 12 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue != 30) throw new Exception("ignoreCTest 30 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue != 32) throw new Exception("ignoreCTest 32 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue != 40) throw new Exception("ignoreCTest 40 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue != 21) throw new Exception("ignoreDTest 21 failed");
+ if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue != 0) throw new Exception("ignoreETest 0 failed");
+ if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue != 21) throw new Exception("ignoreETest 21 failed");
+ if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (enum_thorough_typesafe.repeatTest(repeat.one).swigValue != 1) throw new Exception("repeatTest 1 failed");
+ if (enum_thorough_typesafe.repeatTest(repeat.initial).swigValue != 1) throw new Exception("repeatTest 2 failed");
+ if (enum_thorough_typesafe.repeatTest(repeat.two).swigValue != 2) throw new Exception("repeatTest 3 failed");
+ if (enum_thorough_typesafe.repeatTest(repeat.three).swigValue != 3) throw new Exception("repeatTest 4 failed");
+ if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
+ if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/exception_order_runme.cs b/trunk/Examples/test-suite/csharp/exception_order_runme.cs
new file mode 100644
index 000000000..16b32983f
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/exception_order_runme.cs
@@ -0,0 +1,48 @@
+using System;
+using exception_orderNamespace;
+
+public class runme {
+ static void Main() {
+ A a = new A();
+
+ try {
+ a.foo();
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ E1 exception thrown")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ a.bar();
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ E2 exception thrown")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ a.foobar();
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "postcatch unknown")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ a.barfoo(1);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ E1 exception thrown")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+
+ try {
+ a.barfoo(2);
+ throw new Exception("missed exception");
+ } catch (ApplicationException e) {
+ if (e.Message != "C++ E2 * exception thrown")
+ throw new ApplicationException("bad exception order: " + e.Message);
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/imports_runme.cs b/trunk/Examples/test-suite/csharp/imports_runme.cs
new file mode 100644
index 000000000..579dc8afb
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/imports_runme.cs
@@ -0,0 +1,18 @@
+using System;
+using importsNamespace;
+
+public class runme
+{
+ static void Main() {
+ B b = new B();
+ b.hello(); //call member function in A which is in a different SWIG generated library.
+ b.bye();
+
+ if (b.member_virtual_test(A.MemberEnum.memberenum1) != A.MemberEnum.memberenum2)
+ throw new Exception("Test 1 failed");
+ if (b.global_virtual_test(GlobalEnum.globalenum1) != GlobalEnum.globalenum2)
+ throw new Exception("Test 2 failed");
+
+ imports_b.global_test(A.MemberEnum.memberenum1);
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/inherit_target_language_runme.cs b/trunk/Examples/test-suite/csharp/inherit_target_language_runme.cs
new file mode 100644
index 000000000..2f9e2a75d
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/inherit_target_language_runme.cs
@@ -0,0 +1,24 @@
+using System;
+using inherit_target_languageNamespace;
+
+public class inherit_target_language_runme {
+ public static void Main() {
+ new Derived1().targetLanguageBaseMethod();
+ new Derived2().targetLanguageBaseMethod();
+
+ new MultipleDerived1().targetLanguageBaseMethod();
+ new MultipleDerived2().targetLanguageBaseMethod();
+ new MultipleDerived3().f();
+ new MultipleDerived4().g();
+
+ BaseX baseX = new BaseX();
+ baseX.basex();
+ baseX.targetLanguageBase2Method();
+
+ DerivedX derivedX = new DerivedX();
+ derivedX.basex();
+ derivedX.derivedx();
+ derivedX.targetLanguageBase2Method();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/intermediary_classname_runme.cs b/trunk/Examples/test-suite/csharp/intermediary_classname_runme.cs
new file mode 100644
index 000000000..0ae8fba75
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/intermediary_classname_runme.cs
@@ -0,0 +1,21 @@
+
+/***********************************************************************************************
+ NOTE: This is a custom testcase and should be run using make intermediary_classname.customtest
+ ***********************************************************************************************/
+
+using System;
+using intermediary_classnameNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // test the renamed module class is correctly named
+ double d = intermediary_classnameModule.maxdouble(10.0, 20.0);
+ if (d!=20.0) throw new Exception("Test failed");
+
+ // test the renamed intermediary class is correctly named
+ IntPtr ptr = intermediary_classname.new_vecdouble(10);
+ intermediary_classname.delete_vecdouble(new System.Runtime.InteropServices.HandleRef(null,ptr));
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/li_attribute_runme.cs b/trunk/Examples/test-suite/csharp/li_attribute_runme.cs
new file mode 100644
index 000000000..46f982637
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_attribute_runme.cs
@@ -0,0 +1,78 @@
+// Ported from Python li_attribute_runme.py
+
+using System;
+using li_attributeNamespace;
+
+public class li_attribute_runme {
+
+ public static void Main() {
+ A aa = new A(1,2,3);
+
+ if (aa.a != 1)
+ throw new ApplicationException("error");
+ aa.a = 3;
+ if (aa.a != 3)
+ throw new ApplicationException("error");
+
+ if (aa.b != 2)
+ throw new ApplicationException("error");
+ aa.b = 5;
+ if (aa.b != 5)
+ throw new ApplicationException("error");
+
+ if (aa.d != aa.b)
+ throw new ApplicationException("error");
+
+ if (aa.c != 3)
+ throw new ApplicationException("error");
+ //aa.c = 5;
+ //if (aa.c != 3)
+ // throw new ApplicationException("error");
+
+ Param_i pi = new Param_i(7);
+ if (pi.value != 7)
+ throw new ApplicationException("error");
+
+ pi.value=3;
+ if (pi.value != 3)
+ throw new ApplicationException("error");
+
+ B b = new B(aa);
+
+ if (b.a.c != 3)
+ throw new ApplicationException("error");
+
+ // class/struct attribute with get/set methods using return/pass by reference
+ MyFoo myFoo = new MyFoo();
+ myFoo.x = 8;
+ MyClass myClass = new MyClass();
+ myClass.Foo = myFoo;
+ if (myClass.Foo.x != 8)
+ throw new ApplicationException("error");
+
+ // class/struct attribute with get/set methods using return/pass by value
+ MyClassVal myClassVal = new MyClassVal();
+ if (myClassVal.ReadWriteFoo.x != -1)
+ throw new ApplicationException("error");
+ if (myClassVal.ReadOnlyFoo.x != -1)
+ throw new ApplicationException("error");
+ myClassVal.ReadWriteFoo = myFoo;
+ if (myClassVal.ReadWriteFoo.x != 8)
+ throw new ApplicationException("error");
+ if (myClassVal.ReadOnlyFoo.x != 8)
+ throw new ApplicationException("error");
+
+ // string attribute with get/set methods using return/pass by value
+ MyStringyClass myStringClass = new MyStringyClass("initial string");
+ if (myStringClass.ReadWriteString != "initial string")
+ throw new ApplicationException("error");
+ if (myStringClass.ReadOnlyString != "initial string")
+ throw new ApplicationException("error");
+ myStringClass.ReadWriteString = "changed string";
+ if (myStringClass.ReadWriteString != "changed string")
+ throw new ApplicationException("error");
+ if (myStringClass.ReadOnlyString != "changed string")
+ throw new ApplicationException("error");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs b/trunk/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
new file mode 100644
index 000000000..2b8c84e1b
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
@@ -0,0 +1,17 @@
+using System;
+using li_boost_shared_ptr_bitsNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ VectorIntHolder v = new VectorIntHolder();
+ v.Add(new IntHolder(11));
+ v.Add(new IntHolder(22));
+ v.Add(new IntHolder(33));
+
+ int sum = li_boost_shared_ptr_bits.sum(v);
+ if (sum != 66)
+ throw new ApplicationException("sum is wrong");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs b/trunk/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs
new file mode 100644
index 000000000..6ded989b5
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs
@@ -0,0 +1,589 @@
+using System;
+using li_boost_shared_ptrNamespace;
+
+public class runme
+{
+ // Debugging flag
+ public static bool debug = false;
+
+ static void Main()
+ {
+ if (debug)
+ Console.WriteLine("Started");
+
+ li_boost_shared_ptr.debug_shared=debug;
+
+ // Change loop count to run for a long time to monitor memory
+ const int loopCount = 1; //50000;
+ for (int i=0; i<loopCount; i++) {
+ new runme().runtest();
+ System.GC.Collect();
+ System.GC.WaitForPendingFinalizers();
+ if (i%100 == 0) {
+ System.Threading.Thread.Sleep(1); // give some time to the lower priority finalizer thread
+ }
+ }
+
+ if (debug)
+ Console.WriteLine("Nearly finished");
+
+ int countdown = 100;
+ while (true) {
+ System.GC.Collect();
+ System.GC.WaitForPendingFinalizers();
+ System.Threading.Thread.Sleep(10);
+ if (--countdown == 0)
+ break;
+ if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
+ break;
+ };
+ if (Klass.getTotal_count() != 1)
+ throw new ApplicationException("Klass.total_count=" + Klass.getTotal_count());
+
+ int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
+ if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING)
+ if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
+ throw new ApplicationException("shared_ptr wrapper count=" + wrapper_count);
+
+ if (debug)
+ Console.WriteLine("Finished");
+ }
+
+ private void runtest() {
+ // simple shared_ptr usage - created in C++
+ {
+ Klass k = new Klass("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ Klass k = li_boost_shared_ptr.factorycreate();
+ String val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.constsmartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.constsmartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.constsmartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by value
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.pointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ // TODO: add in const versions too
+ if (li_boost_shared_ptr.smartpointertest(k) != null)
+ throw new ApplicationException("return was not null");
+
+ if (li_boost_shared_ptr.smartpointerpointertest(k) != null)
+ throw new ApplicationException("return was not null");
+
+ if (li_boost_shared_ptr.smartpointerreftest(k) != null)
+ throw new ApplicationException("return was not null");
+
+ if (li_boost_shared_ptr.smartpointerpointerreftest(k) != null)
+ throw new ApplicationException("return was not null");
+
+ if (li_boost_shared_ptr.nullsmartpointerpointertest(null) != "null pointer")
+ throw new ApplicationException("not null smartpointer pointer");
+
+ try { li_boost_shared_ptr.valuetest(k); throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
+
+ if (li_boost_shared_ptr.pointertest(k) != null)
+ throw new ApplicationException("return was not null");
+
+ try { li_boost_shared_ptr.reftest(k); throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
+ }
+
+ // $owner
+ {
+ Klass k = li_boost_shared_ptr.pointerownertest();
+ String val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ Klass k = li_boost_shared_ptr.smartpointerpointerownertest();
+ String val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived pass by shared_ptr
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val); // note slicing
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // 3rd derived class
+ {
+ Klass k = new Klass3rdDerived("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = li_boost_shared_ptr.test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member value");
+ m.SmartMemberValue = k;
+ String val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(2, k);
+
+ Klass kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ m.Dispose();
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ String val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+
+ m.Dispose();
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member reference");
+ m.SmartMemberReference = k;
+ String val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(2, k);
+
+ Klass kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ Klass kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(4, kmemberVal);
+ verifyCount(4, kmember);
+ verifyCount(4, k);
+
+ m.Dispose();
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+ }
+ // plain by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member value");
+ m.MemberValue = k;
+ String val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.Dispose();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member pointer");
+ m.MemberPointer = k;
+ String val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.Dispose();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member reference");
+ m.MemberReference = k;
+ String val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.Dispose();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+
+ // null member variables
+ {
+ MemberVariables m = new MemberVariables();
+
+ // shared_ptr by value
+ Klass k = m.SmartMemberValue;
+ if (k != null)
+ throw new ApplicationException("expected null");
+ m.SmartMemberValue = null;
+ k = m.SmartMemberValue;
+ if (k != null)
+ throw new ApplicationException("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.MemberValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
+ }
+
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ Klass kglobal = li_boost_shared_ptr.GlobalSmartValue;
+ if (kglobal != null)
+ throw new ApplicationException("expected null");
+
+ Klass k = new Klass("smart global value");
+ li_boost_shared_ptr.GlobalSmartValue = k;
+ verifyCount(2, k);
+
+ kglobal = li_boost_shared_ptr.GlobalSmartValue;
+ String val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyCount(3, kglobal);
+ verifyCount(3, k);
+ verifyValue("smart global value", li_boost_shared_ptr.GlobalSmartValue.getValue());
+ li_boost_shared_ptr.GlobalSmartValue = null;
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global value");
+ li_boost_shared_ptr.GlobalValue = k;
+ verifyCount(1, k);
+
+ kglobal = li_boost_shared_ptr.GlobalValue;
+ String val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", li_boost_shared_ptr.GlobalValue.getValue());
+
+ try { li_boost_shared_ptr.GlobalValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
+ }
+ // plain pointer
+ {
+ Klass kglobal = li_boost_shared_ptr.GlobalPointer;
+ if (kglobal != null)
+ throw new ApplicationException("expected null");
+
+ Klass k = new Klass("global pointer");
+ li_boost_shared_ptr.GlobalPointer = k;
+ verifyCount(1, k);
+
+ kglobal = li_boost_shared_ptr.GlobalPointer;
+ String val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ li_boost_shared_ptr.GlobalPointer = null;
+ }
+ // plain reference
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global reference");
+ li_boost_shared_ptr.GlobalReference = k;
+ verifyCount(1, k);
+
+ kglobal = li_boost_shared_ptr.GlobalReference;
+ String val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { li_boost_shared_ptr.GlobalReference = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4)
+ throw new ApplicationException("Base values wrong");
+ if (pid.val1 != 10 || pid.val2 != 20.2)
+ throw new ApplicationException("Derived Values wrong");
+ }
+ }
+ private void verifyValue(String expected, String got) {
+ if (expected != got)
+ throw new Exception("verify value failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, Klass k) {
+ int got = li_boost_shared_ptr.use_count(k);
+ if (expected != got)
+ throw new Exception("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/li_std_combinations_runme.cs b/trunk/Examples/test-suite/csharp/li_std_combinations_runme.cs
new file mode 100644
index 000000000..ced9d17a3
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_std_combinations_runme.cs
@@ -0,0 +1,31 @@
+using System;
+using li_std_combinationsNamespace;
+
+public class li_std_combinations_runme {
+ public static void Main() {
+ VectorPairIntString vpis = new VectorPairIntString();
+ vpis.Add(new PairIntString(123, "one hundred and twenty three"));
+
+ VectorString vs = new VectorString();
+ vs.Add("hi");
+ PairIntVectorString pivs = new PairIntVectorString(456, vs);
+ if (pivs.second[0] != "hi")
+ throw new ApplicationException("PairIntVectorString");
+
+ VectorVectorString vvs = new VectorVectorString();
+ vvs.Add(vs);
+
+ PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4"));
+ if (pipis.first != 12)
+ throw new ApplicationException("PairIntPairIntString");
+
+ PairDoubleString pds = new PairDoubleString(12.34, "okay");
+ VectorPairDoubleString vpds = new VectorPairDoubleString();
+ vpds.Add(pds);
+
+ // Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method
+ if (!vpds.Contains(pds))
+ throw new ApplicationException("VectorPairDoubleString");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/li_std_except_runme.cs b/trunk/Examples/test-suite/csharp/li_std_except_runme.cs
new file mode 100644
index 000000000..86ab44892
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_std_except_runme.cs
@@ -0,0 +1,24 @@
+// This test tests all the methods in the C# collection wrapper
+
+using System;
+using li_std_exceptNamespace;
+
+public class li_std_except_runme {
+
+ public static void Main() {
+ Test test = new Test();
+ try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
+ try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
+ try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}
+ try { test.throw_invalid_argument(); throw new Exception("throw_invalid_argument failed"); } catch (ArgumentException) {}
+ try { test.throw_length_error(); throw new Exception("throw_length_error failed"); } catch (IndexOutOfRangeException) {}
+ try { test.throw_logic_error(); throw new Exception("throw_logic_error failed"); } catch (ApplicationException) {}
+ try { test.throw_out_of_range(); throw new Exception("throw_out_of_range failed"); } catch (ArgumentOutOfRangeException) {}
+ try { test.throw_overflow_error(); throw new Exception("throw_overflow_error failed"); } catch (OverflowException) {}
+ try { test.throw_range_error(); throw new Exception("throw_range_error failed"); } catch (IndexOutOfRangeException) {}
+ try { test.throw_runtime_error(); throw new Exception("throw_runtime_error failed"); } catch (ApplicationException) {}
+ try { test.throw_underflow_error(); throw new Exception("throw_underflow_error failed"); } catch (OverflowException) {}
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/li_std_map_runme.cs b/trunk/Examples/test-suite/csharp/li_std_map_runme.cs
new file mode 100644
index 000000000..b0a5a78e4
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_std_map_runme.cs
@@ -0,0 +1,238 @@
+/* -----------------------------------------------------------------------------
+ * li_std_map_runme.cs
+ *
+ * SWIG C# tester for std_map.i
+ * This class tests all the functionality of the std_map.i wrapper.
+ * Upon successful testing, the main function doesn't print out anything.
+ * If any error is found - it will be printed on the screen.
+ * ----------------------------------------------------------------------------- */
+
+using System;
+using System.Collections.Generic;
+using li_std_mapNamespace;
+
+public class li_std_map_runme {
+
+ private static readonly int collectionSize = 20;
+ private static readonly int midCollection = collectionSize / 2;
+
+ public static void Main()
+ {
+ // Set up an int int map
+ StringIntMap simap = new StringIntMap();
+ for (int i = 0; i < collectionSize; i++)
+ {
+ int val = i * 18;
+ simap.Add(i.ToString(), val);
+ }
+
+ // Count property test
+ if (simap.Count != collectionSize)
+ throw new Exception("Count test failed");
+
+ // IsReadOnly property test
+ if (simap.IsReadOnly)
+ throw new Exception("IsReadOnly test failed");
+
+ // Item indexing test
+ simap["0"] = 200;
+ if (simap["0"] != 200)
+ throw new Exception("Item property test failed");
+ simap["0"] = 0 * 18;
+
+ // ContainsKey() test
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!simap.ContainsKey(i.ToString()))
+ throw new Exception("ContainsKey test " + i + " failed");
+ }
+
+ // ContainsKey() test
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!simap.Contains(new KeyValuePair<string, int>(i.ToString(), i * 18)))
+ throw new Exception("Contains test " + i + " failed");
+ }
+
+ // TryGetValue() test
+ int value;
+ bool rc = simap.TryGetValue("3", out value);
+ if (rc != true || value != (3 * 18))
+ throw new Exception("TryGetValue test 1 failed");
+
+ rc = simap.TryGetValue("-1", out value);
+ if (rc != false)
+ throw new Exception("TryGetValue test 2 failed");
+
+ // Keys and Values test
+ {
+ IList<string> keys = new List<string>(simap.Keys);
+ IList<int> values = new List<int>(simap.Values);
+ if (keys.Count != collectionSize)
+ throw new Exception("Keys count test failed");
+
+ if (values.Count != collectionSize)
+ throw new Exception("Values count test failed");
+
+ for (int i = 0; i < keys.Count; i++)
+ {
+ if (simap[keys[i]] != values[i])
+ throw new Exception("Keys and values test failed for index " + i);
+ }
+ }
+
+ // Add and Remove test
+ for (int i = 100; i < 103; i++)
+ {
+ simap.Add(i.ToString(), i * 18);
+ if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
+ throw new Exception("Add test failed for index " + i);
+
+ simap.Remove(i.ToString());
+ if (simap.ContainsKey(i.ToString()))
+ throw new Exception("Remove test failed for index " + i);
+ }
+
+ for (int i = 200; i < 203; i++)
+ {
+ simap.Add(new KeyValuePair<string, int>(i.ToString(), i * 18));
+ if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
+ throw new Exception("Add explicit test failed for index " + i);
+
+ simap.Remove(new KeyValuePair<string, int>(i.ToString(), i * 18));
+ if (simap.ContainsKey(i.ToString()))
+ throw new Exception("Remove explicit test failed for index " + i);
+ }
+
+ // Duplicate key test
+ try
+ {
+ simap.Add("3", 0);
+ throw new Exception("Adding duplicate key test failed");
+ }
+ catch (ArgumentException)
+ {
+ }
+
+ // CopyTo() test
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize];
+ simap.CopyTo(outputarray);
+ foreach (KeyValuePair<string, int> val in outputarray)
+ {
+ if (simap[val.Key] != val.Value)
+ throw new Exception("CopyTo (1) test failed, index:" + val.Key);
+ }
+ }
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[midCollection + collectionSize];
+ simap.CopyTo(outputarray, midCollection);
+ for (int i = midCollection; i < midCollection + collectionSize; i++)
+ {
+ KeyValuePair<string, int> val = outputarray[i];
+ if (simap[val.Key] != val.Value)
+ throw new Exception("CopyTo (2) test failed, index:" + val.Key);
+ }
+ }
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize - 1];
+ try
+ {
+ simap.CopyTo(outputarray);
+ throw new Exception("CopyTo (4) test failed");
+ }
+ catch (ArgumentException)
+ {
+ }
+ }
+
+ // Clear test
+ simap.Clear();
+ if (simap.Count != 0)
+ throw new Exception("Clear test failed");
+
+ // Test wrapped methods
+ for (int i = 1; i <= 5; i++)
+ {
+ simap[i.ToString()] = i;
+ }
+ double avg = li_std_map.valueAverage(simap);
+ if (avg != 3.0)
+ throw new Exception("Wrapped method valueAverage test failed. Got " + avg);
+
+ string keyStringified = li_std_map.stringifyKeys(simap);
+ if (keyStringified != " 1 2 3 4 5")
+ throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
+
+ // Test a map with a new complex type (Struct)
+ {
+ IntStructMap ismap = new IntStructMap();
+ for (int i = 0; i < 10; i++)
+ {
+ ismap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (ismap.Count != 10)
+ throw new Exception("Count test on complex type map failed");
+
+ foreach (KeyValuePair<int, Struct> p in ismap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on complex type map failed for index " + p.Key);
+ }
+ }
+
+ // Test a map of pointers
+ {
+ IntStructPtrMap ispmap = new IntStructPtrMap();
+ for (int i = 0; i < 10; i++)
+ {
+ ispmap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (ispmap.Count != 10)
+ throw new Exception("Count test on complex type pointer map failed");
+
+ foreach (KeyValuePair<int, Struct> p in ispmap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key);
+ }
+ }
+ {
+ IntStructConstPtrMap iscpmap = new IntStructConstPtrMap();
+ for (int i = 0; i < 10; i++)
+ {
+ iscpmap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (iscpmap.Count != 10)
+ throw new Exception("Count test on complex type const pointer map failed");
+
+ foreach (KeyValuePair<int, Struct> p in iscpmap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key);
+ }
+ }
+
+ // Test complex type as key (Struct)
+ {
+ StructIntMap limap = new StructIntMap();
+ Struct s7 = new Struct(7);
+ Struct s8 = new Struct(8);
+ limap[s7] = 8;
+ if (limap[s7] != 8)
+ throw new Exception("Assignment test on complex key map failed");
+
+ if (!limap.ContainsKey(s7))
+ throw new Exception("Key test (1) on complex key map failed");
+
+ if (limap.ContainsKey(s8))
+ throw new Exception("Key test (2) on complex key map failed");
+ }
+
+ // All done
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/li_std_string_runme.cs b/trunk/Examples/test-suite/csharp/li_std_string_runme.cs
new file mode 100644
index 000000000..4c9d71384
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_std_string_runme.cs
@@ -0,0 +1,100 @@
+using System;
+using li_std_stringNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // Checking expected use of %typemap(in) std::string {}
+ li_std_string.test_value("Fee");
+
+ // Checking expected result of %typemap(out) std::string {}
+ if (li_std_string.test_value("Fi") != "Fi")
+ throw new Exception("Test 1 failed");
+
+ // Verify type-checking for %typemap(in) std::string {}
+ try {
+ li_std_string.test_value(null);
+ throw new Exception("Test 2 failed");
+ } catch (ArgumentNullException) {
+ }
+
+ // Checking expected use of %typemap(in) const std::string & {}
+ li_std_string.test_const_reference("Fo");
+
+ // Checking expected result of %typemap(out) const std::string& {}
+ if (li_std_string.test_const_reference("Fum") != "Fum")
+ throw new Exception("Test 3 failed");
+
+ // Verify type-checking for %typemap(in) const std::string & {}
+ try {
+ li_std_string.test_const_reference(null);
+ throw new Exception("Test 4 failed");
+ } catch (ArgumentNullException) {
+ }
+
+ //
+ // Input and output typemaps for pointers and non-const references to
+ // std::string are *not* supported; the following tests confirm
+ // that none of these cases are slipping through.
+ //
+
+ SWIGTYPE_p_std__string stringPtr = null;
+
+ stringPtr = li_std_string.test_pointer_out();
+
+ li_std_string.test_pointer(stringPtr);
+
+ stringPtr = li_std_string.test_const_pointer_out();
+
+ li_std_string.test_const_pointer(stringPtr);
+
+ stringPtr = li_std_string.test_reference_out();
+
+ li_std_string.test_reference(stringPtr);
+
+ // Check throw exception specification
+ try {
+ li_std_string.test_throw();
+ throw new Exception("Test 5 failed");
+ } catch (ApplicationException e) {
+ if (e.Message != "test_throw message")
+ throw new Exception("Test 5 string check: " + e.Message);
+ }
+ try {
+ li_std_string.test_const_reference_throw();
+ throw new Exception("Test 6 failed");
+ } catch (ApplicationException e) {
+ if (e.Message != "test_const_reference_throw message")
+ throw new Exception("Test 6 string check: " + e.Message);
+ }
+
+ // Global variables
+ const string s = "initial string";
+ if (li_std_string.GlobalString2 != "global string 2")
+ throw new Exception("GlobalString2 test 1");
+ li_std_string.GlobalString2 = s;
+ if (li_std_string.GlobalString2 != s)
+ throw new Exception("GlobalString2 test 2");
+ if (li_std_string.ConstGlobalString != "const global string")
+ throw new Exception("ConstGlobalString test");
+
+ // Member variables
+ Structure myStructure = new Structure();
+ if (myStructure.MemberString2 != "member string 2")
+ throw new Exception("MemberString2 test 1");
+ myStructure.MemberString2 = s;
+ if (myStructure.MemberString2 != s)
+ throw new Exception("MemberString2 test 2");
+ if (myStructure.ConstMemberString != "const member string")
+ throw new Exception("ConstMemberString test");
+
+ if (Structure.StaticMemberString2 != "static member string 2")
+ throw new Exception("StaticMemberString2 test 1");
+ Structure.StaticMemberString2 = s;
+ if (Structure.StaticMemberString2 != s)
+ throw new Exception("StaticMemberString2 test 2");
+ if (Structure.ConstStaticMemberString != "const static member string")
+ throw new Exception("ConstStaticMemberString test");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/li_std_vector_runme.cs b/trunk/Examples/test-suite/csharp/li_std_vector_runme.cs
new file mode 100644
index 000000000..617116d5a
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_std_vector_runme.cs
@@ -0,0 +1,638 @@
+// This test tests all the methods in the C# collection wrapper
+
+using System;
+using li_std_vectorNamespace;
+
+public class li_std_vector_runme {
+
+ private static readonly int collectionSize = 20;
+ private static readonly int midCollection = collectionSize/2;
+
+ public static DoubleVector myDoubleVector;
+ public static RealVector myRealVector;
+
+ public static void Main() {
+ // Setup collection
+ DoubleVector vect = new DoubleVector();
+ for (int i=0; i<collectionSize; i++) {
+ double num = i*10.1;
+ vect.Add(num);
+ }
+
+ // Count property test
+ if (vect.Count != collectionSize)
+ throw new Exception("Count test failed");
+
+ // IsFixedSize property test
+ if (vect.IsFixedSize)
+ throw new Exception("IsFixedSize test failed");
+
+ // IsReadOnly property test
+ if (vect.IsReadOnly)
+ throw new Exception("IsReadOnly test failed");
+
+ // Item indexing
+ vect[0] = 200.1;
+ if (vect[0] != 200.1)
+ throw new Exception("Item property test failed");
+ vect[0] = 0*10.1;
+ try {
+ vect[-1] = 777.1;
+ throw new Exception("Item out of range (1) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect[vect.Count] = 777.1;
+ throw new Exception("Item out of range (2) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+
+ // CopyTo() test
+ {
+ double[] outputarray = new double[collectionSize];
+ vect.CopyTo(outputarray);
+ int index = 0;
+ foreach(double val in outputarray) {
+ if (vect[index] != val)
+ throw new Exception("CopyTo (1) test failed, index:" + index);
+ index++;
+ }
+ }
+ {
+ double[] outputarray = new double[midCollection+collectionSize];
+ vect.CopyTo(outputarray, midCollection);
+ int index = midCollection;
+ foreach(double val in vect) {
+ if (outputarray[index] != val)
+ throw new Exception("CopyTo (2) test failed, index:" + index);
+ index++;
+ }
+ }
+ {
+ double[] outputarray = new double[3];
+ vect.CopyTo(10, outputarray, 1, 2);
+ if (outputarray[0] != 0.0 || outputarray[1] != vect[10] || outputarray[2] != vect[11])
+ throw new Exception("CopyTo (3) test failed");
+ }
+ {
+ double[] outputarray = new double[collectionSize-1];
+ try {
+ vect.CopyTo(outputarray);
+ throw new Exception("CopyTo (4) test failed");
+ } catch (ArgumentException) {
+ }
+ }
+#if SWIG_DOTNET_1
+ {
+ // runtime check that 2D arrays fail
+ double[,] outputarray = new double[collectionSize,collectionSize];
+ try {
+ vect.CopyTo(outputarray);
+ throw new Exception("CopyTo (5a) test failed");
+ } catch (ArgumentException) {
+ }
+ }
+#endif
+ {
+ StructVector inputvector = new StructVector();
+ int arrayLen = 10;
+ for (int i=0; i<arrayLen; i++) {
+ inputvector.Add(new Struct(i/10.0));
+ }
+ Struct[] outputarray = new Struct[arrayLen];
+ inputvector.CopyTo(outputarray);
+ for(int i=0; i<arrayLen; i++) {
+ if (outputarray[i].num != inputvector[i].num)
+ throw new Exception("CopyTo (6) test failed, i:" + i);
+ }
+ foreach (Struct s in inputvector) {
+ s.num += 20.0;
+ }
+ for(int i=0; i<arrayLen; i++) {
+ if (outputarray[i].num + 20.0 != inputvector[i].num )
+ throw new Exception("CopyTo (7) test failed (only a shallow copy was made), i:" + i);
+ }
+ }
+ {
+ try {
+ vect.CopyTo(null);
+ throw new Exception("CopyTo (8) test failed");
+ } catch (ArgumentNullException) {
+ }
+ }
+
+ // Contains() test
+ if (!vect.Contains(0*10.1))
+ throw new Exception("Contains test 1 failed");
+ if (!vect.Contains(10*10.1))
+ throw new Exception("Contains test 2 failed");
+ if (!vect.Contains(19*10.1))
+ throw new Exception("Contains test 3 failed");
+ if (vect.Contains(20*10.1))
+ throw new Exception("Contains test 4 failed");
+
+ {
+ // ICollection constructor
+ double[] doubleArray = new double[] { 0.0, 11.1, 22.2, 33.3, 44.4, 55.5, 33.3 };
+ DoubleVector dv = new DoubleVector(doubleArray);
+ if (doubleArray.Length != dv.Count)
+ throw new Exception("ICollection constructor length check failed: " + doubleArray.Length + "-" + dv.Count);
+ for (int i=0; i<doubleArray.Length; i++) {
+ if (doubleArray[i] != dv[i])
+ throw new Exception("ICollection constructor failed, index:" + i);
+ }
+ {
+ Struct[] structArray = new Struct[] { new Struct(0.0), new Struct(11.1), new Struct(22.2), new Struct(33.3) };
+ StructVector sv = new StructVector(structArray);
+ for (int i=0; i<structArray.Length; i++) {
+ structArray[i].num += 200.0;
+ }
+ for (int i=0; i<structArray.Length; i++) {
+ if (structArray[i].num != sv[i].num + 200.0)
+ throw new Exception("ICollection constructor not a deep copy, index:" + i);
+ }
+ }
+ try {
+ new DoubleVector((System.Collections.ICollection)null);
+ throw new Exception("ICollection constructor null test failed");
+ } catch (ArgumentNullException) {
+ }
+ {
+ // Collection initializer test, requires C# 3.0
+// myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
+ }
+
+ // IndexOf() test
+ for (int i=0; i<collectionSize; i++) {
+ if (vect.IndexOf(i*10.1) != i)
+ throw new Exception("IndexOf test " + i + " failed");
+ }
+ if (vect.IndexOf(200.1) != -1)
+ throw new Exception("IndexOf non-existent test failed");
+ if (dv.IndexOf(33.3) != 3)
+ throw new Exception("IndexOf position test failed");
+
+ // LastIndexOf() test
+ for (int i=0; i<collectionSize; i++) {
+ if (vect.LastIndexOf(i*10.1) != i)
+ throw new Exception("LastIndexOf test " + i + " failed");
+ }
+ if (vect.LastIndexOf(200.1) != -1)
+ throw new Exception("LastIndexOf non-existent test failed");
+ if (dv.LastIndexOf(33.3) != 6)
+ throw new Exception("LastIndexOf position test failed");
+
+ // Copy constructor test
+ DoubleVector dvCopy = new DoubleVector(dv);
+ for (int i=0; i<doubleArray.Length; i++) {
+ if (doubleArray[i] != dvCopy[i])
+ throw new Exception("Copy constructor failed, index:" + i);
+ }
+ }
+ {
+ // Repeat() test
+ try {
+ myDoubleVector = DoubleVector.Repeat(77.7, -1);
+ throw new Exception("Repeat negative count test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ DoubleVector dv = DoubleVector.Repeat(77.7, 5);
+ if (dv.Count != 5)
+ throw new Exception("Repeat count test failed");
+
+ // Also tests enumerator
+ {
+ System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
+ while ( myEnumerator.MoveNext() ) {
+ if ((double)myEnumerator.Current != 77.7)
+ throw new Exception("Repeat (1) test failed");
+ }
+ }
+#if !SWIG_DOTNET_1
+ {
+ System.Collections.Generic.IEnumerator<double> myEnumerator = dv.GetEnumerator();
+ while ( myEnumerator.MoveNext() ) {
+ if (myEnumerator.Current != 77.7)
+ throw new Exception("Repeat (2) test failed");
+ }
+ }
+#endif
+ }
+
+ {
+ // InsertRange() test
+ DoubleVector dvect = new DoubleVector();
+ for (int i=0; i<5; i++) {
+ dvect.Add(1000.0*i);
+ }
+ vect.InsertRange(midCollection, dvect);
+ if (vect.Count != collectionSize+dvect.Count)
+ throw new Exception("InsertRange test size failed");
+
+ for (int i=0; i<midCollection; i++) {
+ if (vect.IndexOf(i*10.1) != i)
+ throw new Exception("InsertRange (1) test " + i + " failed");
+ }
+ for (int i=0; i<dvect.Count; i++) {
+ if (vect[i+midCollection] != dvect[i])
+ throw new Exception("InsertRange (2) test " + i + " failed");
+ }
+ for (int i=midCollection; i<collectionSize; i++) {
+ if (vect.IndexOf(i*10.1) != i+dvect.Count)
+ throw new Exception("InsertRange (3) test " + i + " failed");
+ }
+ try {
+ vect.InsertRange(0, null);
+ throw new Exception("InsertRange (4) test failed");
+ } catch (ArgumentNullException) {
+ }
+
+ // RemoveRange() test
+ vect.RemoveRange(0, 0);
+ vect.RemoveRange(midCollection, dvect.Count);
+ if (vect.Count != collectionSize)
+ throw new Exception("RemoveRange test size failed");
+ for (int i=0; i<collectionSize; i++) {
+ if (vect.IndexOf(i*10.1) != i)
+ throw new Exception("RemoveRange test " + i + " failed");
+ }
+ try {
+ vect.RemoveRange(-1, 0);
+ throw new Exception("RemoveRange index out of range (1) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect.RemoveRange(0, -1);
+ throw new Exception("RemoveRange count out of range (2) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect.RemoveRange(collectionSize+1, 0);
+ throw new Exception("RemoveRange index and count out of range (1) test failed");
+ } catch (ArgumentException) {
+ }
+ try {
+ vect.RemoveRange(0, collectionSize+1);
+ throw new Exception("RemoveRange index and count out of range (2) test failed");
+ } catch (ArgumentException) {
+ }
+
+ // AddRange() test
+ vect.AddRange(dvect);
+ if (vect.Count != collectionSize+dvect.Count)
+ throw new Exception("AddRange test size failed");
+ for (int i=0; i<collectionSize; i++) {
+ if (vect.IndexOf(i*10.1) != i)
+ throw new Exception("AddRange (1) test " + i + " failed");
+ }
+ for (int i=0; i<dvect.Count; i++) {
+ if (vect[i+collectionSize] != dvect[i])
+ throw new Exception("AddRange (2) test " + i + " failed");
+ }
+ try {
+ vect.AddRange(null);
+ throw new Exception("AddRange (3) test failed");
+ } catch (ArgumentNullException) {
+ }
+ vect.RemoveRange(collectionSize, dvect.Count);
+
+ // GetRange() test
+ int rangeSize = 5;
+ DoubleVector returnedVec = vect.GetRange(0, 0);
+ returnedVec = vect.GetRange(midCollection, rangeSize);
+ if (returnedVec.Count != rangeSize)
+ throw new Exception("GetRange test size failed");
+ for (int i=0; i<rangeSize; i++) {
+ if (returnedVec.IndexOf((i+midCollection)*10.1) != i)
+ throw new Exception("GetRange test " + i + " failed");
+ }
+ try {
+ vect.GetRange(-1, 0);
+ throw new Exception("GetRange index out of range (1) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect.GetRange(0, -1);
+ throw new Exception("GetRange count out of range (2) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect.GetRange(collectionSize+1, 0);
+ throw new Exception("GetRange index and count out of range (1) test failed");
+ } catch (ArgumentException) {
+ }
+ try {
+ vect.GetRange(0, collectionSize+1);
+ throw new Exception("GetRange index and count out of range (2) test failed");
+ } catch (ArgumentException) {
+ }
+ {
+ StructVector inputvector = new StructVector();
+ int arrayLen = 10;
+ for (int i=0; i<arrayLen; i++) {
+ inputvector.Add(new Struct(i/10.0));
+ }
+ StructVector outputvector = inputvector.GetRange(0,arrayLen);
+ for(int i=0; i<arrayLen; i++) {
+ if (outputvector[i].num != inputvector[i].num)
+ throw new Exception("GetRange (1) test failed, i:" + i);
+ }
+ foreach (Struct s in inputvector) {
+ s.num += 20.0;
+ }
+ for(int i=0; i<arrayLen; i++) {
+ if (outputvector[i].num + 20.0 != inputvector[i].num )
+ throw new Exception("GetRange (2) test failed (only a shallow copy was made), i:" + i);
+ }
+ }
+ }
+
+ // Insert() test
+ int pos = 0;
+ int count = vect.Count;
+ vect.Insert(pos, -5.1);
+ count++;
+ if (vect.Count != count || vect[pos] != -5.1)
+ throw new Exception("Insert at beginning test failed");
+
+ pos = midCollection;
+ vect.Insert(pos, 85.1);
+ count++;
+ if (vect.Count != count || vect[pos] != 85.1)
+ throw new Exception("Insert at " + pos + " test failed");
+
+ pos = vect.Count;
+ vect.Insert(pos, 195.1);
+ count++;
+ if (vect.Count != count || vect[pos] != 195.1)
+ throw new Exception("Insert at end test failed");
+
+ pos = vect.Count+1;
+ try {
+ vect.Insert(pos, 222.1); // should throw
+ throw new Exception("Insert after end (1) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ if (vect.Count != count)
+ throw new Exception("Insert after end (2) test failed");
+
+ pos = -1;
+ try {
+ vect.Insert(pos, 333.1); // should throw
+ throw new Exception("Insert before start (1) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ if (vect.Count != count)
+ throw new Exception("Insert before start (2) test failed");
+
+ // Remove() test
+ vect.Remove(195.1);
+ count--;
+ vect.Remove(-5.1);
+ count--;
+ vect.Remove(85.1);
+ count--;
+ vect.Remove(9999.1); // element does not exist, should quietly do nothing
+ if (vect.Count != count)
+ throw new Exception("Remove count check test failed");
+ for (int i=0; i<collectionSize; i++) {
+ if (vect[i] != i*10.1)
+ throw new Exception("Remove test failed, index:" + i);
+ }
+
+ // RemoveAt() test
+ vect.Insert(0, -4.1);
+ vect.Insert(midCollection, 84.1);
+ vect.Insert(vect.Count, 194.1);
+ vect.RemoveAt(vect.Count-1);
+ vect.RemoveAt(midCollection);
+ vect.RemoveAt(0);
+ try {
+ vect.RemoveAt(-1);
+ throw new Exception("RemoveAt test (1) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect.RemoveAt(vect.Count);
+ throw new Exception("RemoveAt test (2) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ for (int i=0; i<collectionSize; i++) {
+ if (vect[i] != i*10.1)
+ throw new Exception("RemoveAt test (3) failed, index:" + i);
+ }
+
+ {
+ // Capacity test
+ try {
+ myDoubleVector = new DoubleVector(-1);
+ throw new Exception("constructor setting capacity (1) test failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+
+ DoubleVector dv = new DoubleVector(10);
+ if (dv.Capacity != 10 || dv.Count != 0)
+ throw new Exception("constructor setting capacity (2) test failed");
+ dv.Capacity = 20;
+ if (dv.Capacity != 20)
+ throw new Exception("capacity test (1) failed");
+ dv.Add(1.11);
+ try {
+ dv.Capacity = dv.Count-1;
+ throw new Exception("capacity test (2) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+
+ // SetRange() test
+ for (int i=dv.Count; i<collectionSize; i++) {
+ dv.Add(0.0);
+ }
+ dv.SetRange(0, vect);
+ if (dv.Count != collectionSize)
+ throw new Exception("SetRange count check test failed");
+ for (int i=0; i<collectionSize; i++) {
+ if (vect[i] != dv[i])
+ throw new Exception("SetRange test (1) failed, index:" + i);
+ }
+ try {
+ dv.SetRange(-1, vect);
+ throw new Exception("SetRange test (2) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ dv.SetRange(1, vect);
+ throw new Exception("SetRange test (3) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ vect.SetRange(0, null);
+ throw new Exception("SetRange (4) test failed");
+ } catch (ArgumentNullException) {
+ }
+
+ // Reverse() test
+ dv.Reverse();
+ for (int i=0; i<collectionSize; i++) {
+ if (vect[i] != dv[collectionSize-i-1])
+ throw new Exception("Reverse test (1) failed, index:" + i);
+ }
+ dv.Reverse(0, collectionSize);
+ for (int i=0; i<collectionSize; i++) {
+ if (vect[i] != dv[i])
+ throw new Exception("Reverse test (2) failed, index:" + i);
+ }
+ dv.Reverse(0, 0); // should do nothing!
+ for (int i=0; i<collectionSize; i++) {
+ if (vect[i] != dv[i])
+ throw new Exception("Reverse test (3) failed, index:" + i);
+ }
+ try {
+ dv.Reverse(-1, 0);
+ throw new Exception("Reverse test (4) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ dv.Reverse(0, -1);
+ throw new Exception("Reverse test (5) failed");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ try {
+ dv.Reverse(collectionSize+1, 0);
+ throw new Exception("Reverse test (6) failed");
+ } catch (ArgumentException) {
+ }
+ try {
+ dv.Reverse(0, collectionSize+1);
+ throw new Exception("Reverse test (7) failed");
+ } catch (ArgumentException) {
+ }
+ }
+
+ // foreach test
+ {
+ int index=0;
+ foreach (double s in vect) {
+ if (s != index*10.1)
+ throw new Exception("foreach test failed, index:" + index);
+ index++;
+ }
+ }
+
+ // Clear() test
+ vect.Clear();
+ if (vect.Count != 0)
+ throw new Exception("Clear failed");
+
+ // Finally test the methods being wrapped
+ {
+ IntVector iv = new IntVector();
+ for (int i=0; i<4; i++) {
+ iv.Add(i);
+ }
+
+ double x = li_std_vector.average(iv);
+ x += li_std_vector.average( new IntVector( new int[] {1, 2, 3, 4} ) );
+ myRealVector = li_std_vector.half( new RealVector( new float[] {10F, 10.5F, 11F, 11.5F} ) );
+
+ DoubleVector dvec = new DoubleVector();
+ for (int i=0; i<10; i++) {
+ dvec.Add(i/2.0);
+ }
+ li_std_vector.halve_in_place(dvec);
+ }
+
+ // Dispose()
+ {
+ using (StructVector vs = new StructVector( new Struct[] { new Struct(0.0), new Struct(11.1) } ) )
+ using (DoubleVector vd = new DoubleVector( new double[] { 0.0, 11.1 } ) ) {
+ }
+ }
+
+ // More wrapped methods
+ {
+ RealVector v0 = li_std_vector.vecreal(new RealVector());
+ float flo = 123.456f;
+ v0.Add(flo);
+ flo = v0[0];
+
+ IntVector v1 = li_std_vector.vecintptr(new IntVector());
+ IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector());
+ IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector());
+
+ v1.Add(123);
+ v2.Clear();
+ v3.Clear();
+
+ StructVector v4 = li_std_vector.vecstruct(new StructVector());
+ StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector());
+ StructConstPtrVector v6 = li_std_vector.vecstructconstptr(new StructConstPtrVector());
+
+ v4.Add(new Struct(123));
+ v5.Add(new Struct(123));
+ v6.Add(new Struct(123));
+ }
+
+ // Test vectors of pointers
+ {
+ StructPtrVector inputvector = new StructPtrVector();
+ int arrayLen = 10;
+ for (int i=0; i<arrayLen; i++) {
+ inputvector.Add(new Struct(i/10.0));
+ }
+ Struct[] outputarray = new Struct[arrayLen];
+ inputvector.CopyTo(outputarray);
+ for(int i=0; i<arrayLen; i++) {
+ if (outputarray[i].num != inputvector[i].num)
+ throw new Exception("StructPtrVector test (1) failed, i:" + i);
+ }
+ foreach (Struct s in inputvector) {
+ s.num += 20.0;
+ }
+ for(int i=0; i<arrayLen; i++) {
+ if (outputarray[i].num != 20.0 + i/10.0)
+ throw new Exception("StructPtrVector test (2) failed (a deep copy was incorrectly made), i:" + i);
+ }
+
+ int rangeSize = 5;
+ int mid = arrayLen/2;
+ StructPtrVector returnedVec = inputvector.GetRange(mid, rangeSize);
+ for (int i=0; i<rangeSize; i++) {
+ if (inputvector[i+mid].num != returnedVec[i].num)
+ throw new Exception("StructPtrVector test (3) failed, i:" + i);
+ }
+ }
+
+ // Test vectors of const pointers
+ {
+ StructConstPtrVector inputvector = new StructConstPtrVector();
+ int arrayLen = 10;
+ for (int i=0; i<arrayLen; i++) {
+ inputvector.Add(new Struct(i/10.0));
+ }
+ Struct[] outputarray = new Struct[arrayLen];
+ inputvector.CopyTo(outputarray);
+ for(int i=0; i<arrayLen; i++) {
+ if (outputarray[i].num != inputvector[i].num)
+ throw new Exception("StructConstPtrVector test (1) failed, i:" + i);
+ }
+ foreach (Struct s in inputvector) {
+ s.num += 20.0;
+ }
+ for(int i=0; i<arrayLen; i++) {
+ if (outputarray[i].num != 20.0 + i/10.0)
+ throw new Exception("StructConstPtrVector test (2) failed (a deep copy was incorrectly made), i:" + i);
+ }
+
+ int rangeSize = 5;
+ int mid = arrayLen/2;
+ StructConstPtrVector returnedVec = inputvector.GetRange(mid, rangeSize);
+ for (int i=0; i<rangeSize; i++) {
+ if (inputvector[i+mid].num != returnedVec[i].num)
+ throw new Exception("StructConstPtrVector test (3) failed, i:" + i);
+ }
+ }
+
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/li_std_wstring_runme.cs b/trunk/Examples/test-suite/csharp/li_std_wstring_runme.cs
new file mode 100644
index 000000000..fe663a3e0
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_std_wstring_runme.cs
@@ -0,0 +1,76 @@
+using System;
+using li_std_wstringNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ char y='h';
+
+ if (li_std_wstring.test_wcvalue(y) != y)
+ throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue(y));
+
+ if (li_std_wstring.test_wcvalue_w() != 'W')
+ throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue_w());
+
+ string x="hello";
+
+ if (li_std_wstring.test_ccvalue(x) != x)
+ throw new Exception("bad string mapping");
+
+ if (li_std_wstring.test_cvalue(x) != x)
+ throw new Exception("bad string mapping");
+
+
+ if (li_std_wstring.test_value(x) != x)
+ throw new Exception("bad string mapping: " + x + li_std_wstring.test_value(x));
+
+ if (li_std_wstring.test_const_reference(x) != x)
+ throw new Exception("bad string mapping");
+
+
+ string s = "he";
+ s = s + "llo";
+
+ if (s != x)
+ throw new Exception("bad string mapping: " + s + x);
+
+ if (li_std_wstring.test_value(s) != x)
+ throw new Exception("bad string mapping");
+
+ if (li_std_wstring.test_const_reference(s) != x)
+ throw new Exception("bad string mapping");
+
+ string a = s;
+
+ if (li_std_wstring.test_value(a) != x)
+ throw new Exception("bad string mapping");
+
+ if (li_std_wstring.test_const_reference(a) != x)
+ throw new Exception("bad string mapping");
+
+ string b = " world";
+
+ if (a + b != "hello world")
+ throw new Exception("bad string mapping");
+
+ if (a + " world" != "hello world")
+ throw new Exception("bad string mapping");
+
+ if ("hello" + b != "hello world")
+ throw new Exception("bad string mapping");
+
+ s = "hello world";
+
+ B myB = new B("hi");
+
+ myB.name = "hello";
+ if (myB.name != "hello")
+ throw new Exception("bad string mapping");
+
+ myB.a = "hello";
+ if (myB.a != "hello")
+ throw new Exception("bad string mapping");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/li_typemaps_runme.cs b/trunk/Examples/test-suite/csharp/li_typemaps_runme.cs
new file mode 100644
index 000000000..fde6e8b9f
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/li_typemaps_runme.cs
@@ -0,0 +1,101 @@
+
+// Check a few of the INPUT, OUTPUT and INOUT typemaps.
+
+using System;
+using li_typemapsNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ // Check double INPUT typemaps
+ if (li_typemaps.in_double(22.22) != 22.22) exit_test("in_double");
+ if (li_typemaps.inr_double(22.22) != 22.22) exit_test("inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double var = 44.44;
+ li_typemaps.out_double(22.22, out var);
+ if (var != 22.22) exit_test("out_double");
+ }
+ {
+ double var = 44.44;
+ li_typemaps.outr_double(22.22, out var);
+ if (var != 22.22) exit_test("outr_double");
+ }
+
+ // Check double INOUT typemaps
+ {
+ double var = 44.44;
+ li_typemaps.inout_double(ref var);
+ if (var != 44.44) exit_test("inout_double");
+ }
+ {
+ double var = 44.44;
+ li_typemaps.inoutr_double(ref var);
+ if (var != 44.44) exit_test("inoutr_double");
+ }
+
+ // Check unsigned long long INPUT typemaps
+ if (li_typemaps.in_ulonglong(20) != 20) exit_test("in_ulonglong");
+ if (li_typemaps.inr_ulonglong(20) != 20) exit_test("inr_ulonglong");
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ ulong var = 40;
+ li_typemaps.out_ulonglong(20, out var);
+ if (var != 20) exit_test("out_ulonglong");
+ }
+ {
+ ulong var = 40;
+ li_typemaps.outr_ulonglong(20, out var);
+ if (var != 20) exit_test("outr_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ ulong var = 40;
+ li_typemaps.inout_ulonglong(ref var);
+ if (var != 40) exit_test("inout_ulonglong");
+ }
+ {
+ ulong var = 40;
+ li_typemaps.inoutr_ulonglong(ref var);
+ if (var != 40) exit_test("inoutr_ulonglong");
+ }
+
+ // Check unsigned bool INPUT typemaps
+ if (li_typemaps.in_bool(false) != false) exit_test("in_bool");
+ if (li_typemaps.inr_bool(false) != false) exit_test("inr_bool");
+
+ // Check unsigned bool OUTPUT typemaps
+ {
+ bool var = false;
+ li_typemaps.out_bool(true, out var);
+ if (var != true) exit_test("out_bool");
+ }
+ {
+ bool var = false;
+ li_typemaps.outr_bool(true, out var);
+ if (var != true) exit_test("outr_bool");
+ }
+
+ // Check unsigned bool INOUT typemaps
+ {
+ bool var = false;
+ li_typemaps.inout_bool(ref var);
+ if (var != false) exit_test("inout_bool");
+ }
+ {
+ bool var = false;
+ li_typemaps.inoutr_bool(ref var);
+ if (var != false) exit_test("inoutr_bool");
+ }
+ }
+
+ private static void exit_test(String funcName) {
+ throw new Exception("Test FAILED in function " + funcName);
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/long_long_runme.cs b/trunk/Examples/test-suite/csharp/long_long_runme.cs
new file mode 100644
index 000000000..51d91e205
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/long_long_runme.cs
@@ -0,0 +1,41 @@
+
+// This is the long_long runtime testcase. It checks that the long long and
+// unsigned long long types work.
+
+using System;
+using long_longNamespace;
+
+public class long_long_runme {
+
+ public static void Main() {
+
+ check_ll(0L);
+ check_ll(0x7FFFFFFFFFFFFFFFL);
+ check_ll(-10);
+
+ check_ull(0);
+ check_ull(127);
+ check_ull(128);
+ check_ull(9223372036854775807); //0x7FFFFFFFFFFFFFFFL
+ check_ull(18446744073709551615); //0xFFFFFFFFFFFFFFFFL
+ }
+
+ public static void check_ll(long ll) {
+ long_long.ll = ll;
+ long ll_check = long_long.ll;
+ if (ll != ll_check) {
+ string ErrorMessage = "Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check;
+ throw new Exception(ErrorMessage);
+ }
+ }
+
+ public static void check_ull(ulong ull) {
+ long_long.ull = ull;
+ ulong ull_check = long_long.ull;
+ if (ull != ull_check) {
+ string ErrorMessage = "Runtime test using unsigned long long failed. ull=" + ull + " ull_check=" + ull_check;
+ throw new Exception(ErrorMessage);
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/member_pointer_runme.cs b/trunk/Examples/test-suite/csharp/member_pointer_runme.cs
new file mode 100644
index 000000000..ad324d474
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/member_pointer_runme.cs
@@ -0,0 +1,47 @@
+using System;
+using member_pointerNamespace;
+
+public class runme {
+ public static SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+ static void Main() {
+ // Get the pointers
+
+ SWIGTYPE_m_Shape__f_void__double area_pt = member_pointer.areapt();
+ SWIGTYPE_m_Shape__f_void__double perim_pt = member_pointer.perimeterpt();
+
+ // Create some objects
+
+ Square s = new Square(10);
+
+ // Do some calculations
+
+ check( "Square area ", 100.0, member_pointer.do_op(s,area_pt) );
+ check( "Square perim", 40.0, member_pointer.do_op(s,perim_pt) );
+
+ memberPtr = member_pointer.areavar;
+ memberPtr = member_pointer.perimetervar;
+
+ // Try the variables
+ check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.areavar) );
+ check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.perimetervar) );
+
+ // Modify one of the variables
+ member_pointer.areavar = perim_pt;
+
+ check( "Square perimeter", 40.0, member_pointer.do_op(s,member_pointer.areavar) );
+
+ // Try the constants
+
+ memberPtr = member_pointer.AREAPT;
+ memberPtr = member_pointer.PERIMPT;
+ memberPtr = member_pointer.NULLPT;
+
+ check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.AREAPT) );
+ check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.PERIMPT) );
+
+ }
+ private static void check(string what, double expected, double actual) {
+ if (expected != actual)
+ throw new ApplicationException("Failed: " + what + " Expected: " + expected + " Actual: " + actual);
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/nspace_extend_runme.cs b/trunk/Examples/test-suite/csharp/nspace_extend_runme.cs
new file mode 100644
index 000000000..addee7fe5
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/nspace_extend_runme.cs
@@ -0,0 +1,39 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ {
+ // constructors and destructors
+ nspace_extendNamespace.Outer.Inner1.Color color1 = new nspace_extendNamespace.Outer.Inner1.Color();
+ nspace_extendNamespace.Outer.Inner1.Color color = new nspace_extendNamespace.Outer.Inner1.Color(color1);
+ color1.Dispose();
+ color1 = null;
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ nspace_extendNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
+ nspace_extendNamespace.Outer.Inner1.Color created = nspace_extendNamespace.Outer.Inner1.Color.create();
+ created.Dispose();
+ }
+ {
+ // constructors and destructors
+ nspace_extendNamespace.Outer.Inner2.Color color2 = new nspace_extendNamespace.Outer.Inner2.Color();
+ nspace_extendNamespace.Outer.Inner2.Color color = new nspace_extendNamespace.Outer.Inner2.Color(color2);
+ color2.Dispose();
+ color2 = null;
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ nspace_extendNamespace.Outer.Inner2.Color.colorStaticMethod(20.0);
+ nspace_extendNamespace.Outer.Inner2.Color created = nspace_extendNamespace.Outer.Inner2.Color.create();
+ created.Dispose();
+
+ // Same class different namespaces
+ nspace_extendNamespace.Outer.Inner1.Color col1 = new nspace_extendNamespace.Outer.Inner1.Color();
+ nspace_extendNamespace.Outer.Inner2.Color col2 = nspace_extendNamespace.Outer.Inner2.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/nspace_runme.cs b/trunk/Examples/test-suite/csharp/nspace_runme.cs
new file mode 100644
index 000000000..9cf593857
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/nspace_runme.cs
@@ -0,0 +1,76 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ // constructors and destructors
+ nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
+ nspaceNamespace.Outer.Inner1.Color color = new nspaceNamespace.Outer.Inner1.Color(color1);
+ color1.Dispose();
+ color1 = null;
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ nspaceNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
+ nspaceNamespace.Outer.Inner1.Color created = nspaceNamespace.Outer.Inner1.Color.create();
+ created.Dispose();
+
+ // class enums
+ nspaceNamespace.Outer.SomeClass someClass = new nspaceNamespace.Outer.SomeClass();
+ nspaceNamespace.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
+ if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
+ throw new ApplicationException("Transmission wrong");
+
+ // class anonymous enums
+ int val1 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal1;
+ int val2 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal2;
+ if (val1 != 0 || val2 != 0x22)
+ throw new ApplicationException("ColorEnumVal wrong");
+
+ // instance member variables
+ color.instanceMemberVariable = 123;
+ if (color.instanceMemberVariable != 123)
+ throw new ApplicationException("instance member variable failed");
+
+ // static member variables
+ nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
+ if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
+ throw new ApplicationException("static member variable failed");
+ if (nspaceNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222)
+ throw new ApplicationException("static const member variable failed");
+ if (nspaceNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
+ throw new ApplicationException("static const enum member variable failed");
+
+ // check globals in a namespace don't get mangled with the nspaceNamespace option
+ nspaceNamespace.nspace.namespaceFunction(color);
+ nspaceNamespace.nspace.namespaceVar = 111;
+ if (nspaceNamespace.nspace.namespaceVar != 111)
+ throw new ApplicationException("global var failed");
+
+ // Same class different namespaces
+ nspaceNamespace.Outer.Inner1.Color col1 = new nspaceNamespace.Outer.Inner1.Color();
+ nspaceNamespace.Outer.Inner2.Color col2 = nspaceNamespace.Outer.Inner2.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+
+ // global enums
+ nspaceNamespace.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
+ if (outerChannel1 != nspaceNamespace.Outer.Inner1.Channel.Transmission1)
+ throw new ApplicationException("Transmission1 wrong");
+ nspaceNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
+ if (outerChannel2 != nspaceNamespace.Outer.Inner2.Channel.Transmission2)
+ throw new ApplicationException("Transmission2 wrong");
+
+ // turn feature off / ignoring
+ nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
+ ns.Dispose();
+ nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
+ nons.Dispose();
+
+ // Derived class
+ nspaceNamespace.Outer.Inner3.Blue blue3 = new nspaceNamespace.Outer.Inner3.Blue();
+ blue3.blueInstanceMethod();
+ nspaceNamespace.Outer.Inner4.Blue blue4 = new nspaceNamespace.Outer.Inner4.Blue();
+ blue4.blueInstanceMethod();
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/operator_overload_runme.cs b/trunk/Examples/test-suite/csharp/operator_overload_runme.cs
new file mode 100644
index 000000000..294bb7e77
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/operator_overload_runme.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Threading;
+using operator_overloadNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ Op.sanity_check();
+ {
+ Op op = new Op(100);
+ Op opNew = op++;
+ if (op.i != 101) throw new Exception("operator++ postfix failed (op)");
+ if (opNew.i != 100) throw new Exception("operator++ postfix failed (opNew)");
+ }
+ {
+ Op op = new Op(100);
+ Op opNew = op--;
+ if (op.i != 99) throw new Exception("operator-- postfix failed (op)");
+ if (opNew.i != 100) throw new Exception("operator-- postfix failed (opNew)");
+ }
+ {
+ Op op = new Op(100);
+ Op opNew = ++op;
+ if (op.i != 101) throw new Exception("operator++ prefix failed (op)");
+ if (opNew.i != 101) throw new Exception("operator++ prefix failed (opNew)");
+ }
+ {
+ Op op = new Op(100);
+ Op opNew = --op;
+ if (op.i != 99) throw new Exception("operator-- prefix failed (op)");
+ if (opNew.i != 99) throw new Exception("operator-- prefix failed (opNew)");
+ }
+
+ // overloaded operator class
+ Op k = new OpDerived(3);
+ int check_k = k.IntCast();
+ Assert(check_k == 6);
+ }
+
+ public static void Assert(bool b) {
+ if (!b)
+ throw new Exception("Assertion failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/overload_complicated_runme.cs b/trunk/Examples/test-suite/csharp/overload_complicated_runme.cs
new file mode 100644
index 000000000..13741827e
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/overload_complicated_runme.cs
@@ -0,0 +1,55 @@
+using System;
+using overload_complicatedNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ SWIGTYPE_p_int pInt = null;
+
+ // Check the correct constructors are available
+ Pop p = new Pop(pInt);
+
+ p = new Pop(pInt, false);
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ if (p.hip(false) != 701)
+ throw new Exception("Test 1 failed");
+
+ if (p.hip(pInt) != 702)
+ throw new Exception("Test 2 failed");
+
+ // Reverse the order for the above
+ if (p.hop(pInt) != 805)
+ throw new Exception("Test 3 failed");
+
+ if (p.hop(false) != 801)
+ throw new Exception("Test 4 failed");
+
+ // Few more variations and order shuffled
+ if (p.pop(false) != 901)
+ throw new Exception("Test 5 failed");
+
+ if (p.pop(pInt) != 902)
+ throw new Exception("Test 6 failed");
+
+ if (p.pop() != 905)
+ throw new Exception("Test 7 failed");
+
+ // Overload on const only
+ if (p.bop(pInt) != 1001)
+ throw new Exception("Test 8 failed");
+
+ if (p.bip(pInt) != 2001)
+ throw new Exception("Test 9 failed");
+
+ // Globals
+ if (overload_complicated.muzak(false) != 3001)
+ throw new Exception("Test 10 failed");
+
+ if (overload_complicated.muzak(pInt) != 3002)
+ throw new Exception("Test 11 failed");
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/csharp/overload_template_runme.cs b/trunk/Examples/test-suite/csharp/overload_template_runme.cs
new file mode 100644
index 000000000..e25420169
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/overload_template_runme.cs
@@ -0,0 +1,152 @@
+using System;
+using overload_templateNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ int f = overload_template.foo();
+
+ f += overload_template.maximum(3,4);
+ double b = overload_template.maximum(3.4,5.2);
+ b++; // warning suppression
+
+ // mix 1
+ if (overload_template.mix1("hi") != 101)
+ throw new Exception ("mix1(const char*)");
+
+ if (overload_template.mix1(1.0, 1.0) != 102)
+ throw new Exception ("mix1(double, const double &)");
+
+ if (overload_template.mix1(1.0) != 103)
+ throw new Exception ("mix1(double)");
+
+ // mix 2
+ if (overload_template.mix2("hi") != 101)
+ throw new Exception ("mix2(const char*)");
+
+ if (overload_template.mix2(1.0, 1.0) != 102)
+ throw new Exception ("mix2(double, const double &)");
+
+ if (overload_template.mix2(1.0) != 103)
+ throw new Exception ("mix2(double)");
+
+ // mix 3
+ if (overload_template.mix3("hi") != 101)
+ throw new Exception ("mix3(const char*)");
+
+ if (overload_template.mix3(1.0, 1.0) != 102)
+ throw new Exception ("mix3(double, const double &)");
+
+ if (overload_template.mix3(1.0) != 103)
+ throw new Exception ("mix3(double)");
+
+ // Combination 1
+ if (overload_template.overtparams1(100) != 10)
+ throw new Exception ("overtparams1(int)");
+
+ if (overload_template.overtparams1(100.0, 100) != 20)
+ throw new Exception ("overtparams1(double, int)");
+
+ // Combination 2
+ if (overload_template.overtparams2(100.0, 100) != 40)
+ throw new Exception ("overtparams2(double, int)");
+
+ // Combination 3
+ if (overload_template.overloaded() != 60)
+ throw new Exception ("overloaded()");
+
+ if (overload_template.overloaded(100.0, 100) != 70)
+ throw new Exception ("overloaded(double, int)");
+
+ // Combination 4
+ if (overload_template.overloadedagain("hello") != 80)
+ throw new Exception ("overloadedagain(const char *)");
+
+ if (overload_template.overloadedagain() != 90)
+ throw new Exception ("overloadedagain(double)");
+
+ // specializations
+ if (overload_template.specialization(10) != 202)
+ throw new Exception ("specialization(int)");
+
+ if (overload_template.specialization(10.0) != 203)
+ throw new Exception ("specialization(double)");
+
+ if (overload_template.specialization(10, 10) != 204)
+ throw new Exception ("specialization(int, int)");
+
+ if (overload_template.specialization(10.0, 10.0) != 205)
+ throw new Exception ("specialization(double, double)");
+
+ if (overload_template.specialization("hi", "hi") != 201)
+ throw new Exception ("specialization(const char *, const char *)");
+
+
+ // simple specialization
+ overload_template.xyz();
+ overload_template.xyz_int();
+ overload_template.xyz_double();
+
+
+ // a bit of everything
+ if (overload_template.overload("hi") != 0)
+ throw new Exception ("overload()");
+
+ if (overload_template.overload(1) != 10)
+ throw new Exception ("overload(int t)");
+
+ if (overload_template.overload(1, 1) != 20)
+ throw new Exception ("overload(int t, const int &)");
+
+ if (overload_template.overload(1, "hello") != 30)
+ throw new Exception ("overload(int t, const char *)");
+
+ Klass k = new Klass();
+ if (overload_template.overload(k) != 10)
+ throw new Exception ("overload(Klass t)");
+
+ if (overload_template.overload(k, k) != 20)
+ throw new Exception ("overload(Klass t, const Klass &)");
+
+ if (overload_template.overload(k, "hello") != 30)
+ throw new Exception ("overload(Klass t, const char *)");
+
+ if (overload_template.overload(10.0, "hi") != 40)
+ throw new Exception ("overload(double t, const char *)");
+
+ if (overload_template.overload() != 50)
+ throw new Exception ("overload(const char *)");
+
+
+ // everything put in a namespace
+ if (overload_template.nsoverload("hi") != 1000)
+ throw new Exception ("nsoverload()");
+
+ if (overload_template.nsoverload(1) != 1010)
+ throw new Exception ("nsoverload(int t)");
+
+ if (overload_template.nsoverload(1, 1) != 1020)
+ throw new Exception ("nsoverload(int t, const int &)");
+
+ if (overload_template.nsoverload(1, "hello") != 1030)
+ throw new Exception ("nsoverload(int t, const char *)");
+
+ if (overload_template.nsoverload(k) != 1010)
+ throw new Exception ("nsoverload(Klass t)");
+
+ if (overload_template.nsoverload(k, k) != 1020)
+ throw new Exception ("nsoverload(Klass t, const Klass &)");
+
+ if (overload_template.nsoverload(k, "hello") != 1030)
+ throw new Exception ("nsoverload(Klass t, const char *)");
+
+ if (overload_template.nsoverload(10.0, "hi") != 1040)
+ throw new Exception ("nsoverload(double t, const char *)");
+
+ if (overload_template.nsoverload() != 1050)
+ throw new Exception ("nsoverload(const char *)");
+
+ }
+}
+
diff --git a/trunk/Examples/test-suite/csharp/pointer_reference_runme.cs b/trunk/Examples/test-suite/csharp/pointer_reference_runme.cs
new file mode 100644
index 000000000..d00555199
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/pointer_reference_runme.cs
@@ -0,0 +1,18 @@
+// This test tests all the methods in the C# collection wrapper
+
+using System;
+using pointer_referenceNamespace;
+
+public class pointer_reference_runme {
+
+ public static void Main() {
+ Struct s = pointer_reference.get();
+ if (s.value != 10) throw new Exception("get test failed");
+
+ Struct ss = new Struct(20);
+ pointer_reference.set(ss);
+ if (Struct.instance.value != 20) throw new Exception("set test failed");
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/preproc_constants_c_runme.cs b/trunk/Examples/test-suite/csharp/preproc_constants_c_runme.cs
new file mode 100644
index 000000000..76c684d85
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/preproc_constants_c_runme.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Reflection;
+using preproc_constants_cNamespace;
+
+// Same as preproc_constants_c.i testcase, but bool types are int instead
+public class runme {
+ static void Main() {
+ assert( typeof(int) == preproc_constants_c.CONST_INT1.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_INT2.GetType() );
+ assert( typeof(uint) == preproc_constants_c.CONST_UINT1.GetType() );
+ assert( typeof(uint) == preproc_constants_c.CONST_UINT2.GetType() );
+ assert( typeof(uint) == preproc_constants_c.CONST_UINT3.GetType() );
+ assert( typeof(uint) == preproc_constants_c.CONST_UINT4.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_LONG1.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_LONG2.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_LONG3.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_LONG4.GetType() );
+ assert( typeof(long) == preproc_constants_c.CONST_LLONG1.GetType() );
+ assert( typeof(long) == preproc_constants_c.CONST_LLONG2.GetType() );
+ assert( typeof(long) == preproc_constants_c.CONST_LLONG3.GetType() );
+ assert( typeof(long) == preproc_constants_c.CONST_LLONG4.GetType() );
+ assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG1.GetType() );
+ assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG2.GetType() );
+ assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG3.GetType() );
+ assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG4.GetType() );
+ assert( typeof(double) == preproc_constants_c.CONST_DOUBLE1.GetType() );
+ assert( typeof(double) == preproc_constants_c.CONST_DOUBLE2.GetType() );
+ assert( typeof(double) == preproc_constants_c.CONST_DOUBLE3.GetType() );
+ assert( typeof(double) == preproc_constants_c.CONST_DOUBLE4.GetType() );
+ assert( typeof(double) == preproc_constants_c.CONST_DOUBLE5.GetType() );
+ assert( typeof(double) == preproc_constants_c.CONST_DOUBLE6.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_BOOL1.GetType() );
+ assert( typeof(int) == preproc_constants_c.CONST_BOOL2.GetType() );
+ assert( typeof(char) == preproc_constants_c.CONST_CHAR.GetType() );
+ assert( typeof(string) == preproc_constants_c.CONST_STRING1.GetType() );
+ assert( typeof(string) == preproc_constants_c.CONST_STRING2.GetType() );
+
+ assert( typeof(int) == preproc_constants_c.INT_AND_BOOL.GetType() );
+// assert( typeof(int) == preproc_constants_c.INT_AND_CHAR.GetType() );
+ assert( typeof(int) == preproc_constants_c.INT_AND_INT.GetType() );
+ assert( typeof(uint) == preproc_constants_c.INT_AND_UINT.GetType() );
+ assert( typeof(int) == preproc_constants_c.INT_AND_LONG.GetType() );
+ assert( typeof(uint) == preproc_constants_c.INT_AND_ULONG.GetType() );
+ assert( typeof(long) == preproc_constants_c.INT_AND_LLONG.GetType() );
+ assert( typeof(ulong) == preproc_constants_c.INT_AND_ULLONG.GetType() );
+ assert( typeof(int ) == preproc_constants_c.BOOL_AND_BOOL.GetType() );
+
+ assert( typeof(int) == preproc_constants_c.EXPR_MULTIPLY.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_DIVIDE.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_PLUS.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_MINUS.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_LSHIFT.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_RSHIFT.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_LTE.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_GTE.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_INEQUALITY.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_EQUALITY.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_AND.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_XOR.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_OR.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_LAND.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_LOR.GetType() );
+ assert( typeof(double) == preproc_constants_c.EXPR_CONDITIONAL.GetType() );
+
+ }
+ static void assert(bool assertion) {
+ if (!assertion)
+ throw new ApplicationException("test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/preproc_constants_runme.cs b/trunk/Examples/test-suite/csharp/preproc_constants_runme.cs
new file mode 100644
index 000000000..9fae5914a
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/preproc_constants_runme.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Reflection;
+using preproc_constantsNamespace;
+
+public class runme {
+ static void Main() {
+ assert( typeof(int) == preproc_constants.CONST_INT1.GetType() );
+ assert( typeof(int) == preproc_constants.CONST_INT2.GetType() );
+ assert( typeof(uint) == preproc_constants.CONST_UINT1.GetType() );
+ assert( typeof(uint) == preproc_constants.CONST_UINT2.GetType() );
+ assert( typeof(uint) == preproc_constants.CONST_UINT3.GetType() );
+ assert( typeof(uint) == preproc_constants.CONST_UINT4.GetType() );
+ assert( typeof(int) == preproc_constants.CONST_LONG1.GetType() );
+ assert( typeof(int) == preproc_constants.CONST_LONG2.GetType() );
+ assert( typeof(int) == preproc_constants.CONST_LONG3.GetType() );
+ assert( typeof(int) == preproc_constants.CONST_LONG4.GetType() );
+ assert( typeof(long) == preproc_constants.CONST_LLONG1.GetType() );
+ assert( typeof(long) == preproc_constants.CONST_LLONG2.GetType() );
+ assert( typeof(long) == preproc_constants.CONST_LLONG3.GetType() );
+ assert( typeof(long) == preproc_constants.CONST_LLONG4.GetType() );
+ assert( typeof(ulong) == preproc_constants.CONST_ULLONG1.GetType() );
+ assert( typeof(ulong) == preproc_constants.CONST_ULLONG2.GetType() );
+ assert( typeof(ulong) == preproc_constants.CONST_ULLONG3.GetType() );
+ assert( typeof(ulong) == preproc_constants.CONST_ULLONG4.GetType() );
+ assert( typeof(double) == preproc_constants.CONST_DOUBLE1.GetType() );
+ assert( typeof(double) == preproc_constants.CONST_DOUBLE2.GetType() );
+ assert( typeof(double) == preproc_constants.CONST_DOUBLE3.GetType() );
+ assert( typeof(double) == preproc_constants.CONST_DOUBLE4.GetType() );
+ assert( typeof(double) == preproc_constants.CONST_DOUBLE5.GetType() );
+ assert( typeof(double) == preproc_constants.CONST_DOUBLE6.GetType() );
+ assert( typeof(bool) == preproc_constants.CONST_BOOL1.GetType() );
+ assert( typeof(bool) == preproc_constants.CONST_BOOL2.GetType() );
+ assert( typeof(char) == preproc_constants.CONST_CHAR.GetType() );
+ assert( typeof(string) == preproc_constants.CONST_STRING1.GetType() );
+ assert( typeof(string) == preproc_constants.CONST_STRING2.GetType() );
+
+ assert( typeof(int) == preproc_constants.INT_AND_BOOL.GetType() );
+// assert( typeof(int) == preproc_constants.INT_AND_CHAR.GetType() );
+ assert( typeof(int) == preproc_constants.INT_AND_INT.GetType() );
+ assert( typeof(uint) == preproc_constants.INT_AND_UINT.GetType() );
+ assert( typeof(int) == preproc_constants.INT_AND_LONG.GetType() );
+ assert( typeof(uint) == preproc_constants.INT_AND_ULONG.GetType() );
+ assert( typeof(long) == preproc_constants.INT_AND_LLONG.GetType() );
+ assert( typeof(ulong) == preproc_constants.INT_AND_ULLONG.GetType() );
+ assert( typeof(int ) == preproc_constants.BOOL_AND_BOOL.GetType() );
+
+ assert( typeof(int) == preproc_constants.EXPR_MULTIPLY.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_DIVIDE.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_PLUS.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_MINUS.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_LSHIFT.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_RSHIFT.GetType() );
+ assert( typeof(bool) == preproc_constants.EXPR_LTE.GetType() );
+ assert( typeof(bool) == preproc_constants.EXPR_GTE.GetType() );
+ assert( typeof(bool) == preproc_constants.EXPR_INEQUALITY.GetType() );
+ assert( typeof(bool) == preproc_constants.EXPR_EQUALITY.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_AND.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_XOR.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_OR.GetType() );
+ assert( typeof(bool) == preproc_constants.EXPR_LAND.GetType() );
+ assert( typeof(bool) == preproc_constants.EXPR_LOR.GetType() );
+ assert( typeof(double) == preproc_constants.EXPR_CONDITIONAL.GetType() );
+
+ }
+ static void assert(bool assertion) {
+ if (!assertion)
+ throw new ApplicationException("test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/sizet_runme.cs b/trunk/Examples/test-suite/csharp/sizet_runme.cs
new file mode 100644
index 000000000..4852441ab
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/sizet_runme.cs
@@ -0,0 +1,18 @@
+
+using System;
+using sizetNamespace;
+
+public class sizet_runme {
+
+ public static void Main() {
+ uint s = 2000;
+ s = sizet.test1(s+1);
+ s = sizet.test2(s+1);
+ s = sizet.test3(s+1);
+ s = sizet.test4(s+1);
+ if (s != 2004)
+ throw new Exception("failed");
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/sneaky1_runme.cs b/trunk/Examples/test-suite/csharp/sneaky1_runme.cs
new file mode 100644
index 000000000..07e25700d
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/sneaky1_runme.cs
@@ -0,0 +1,20 @@
+using System;
+using sneaky1Namespace;
+
+public class runme
+{
+ static void Main()
+ {
+ if (sneaky1.add(30, 2) != 32)
+ throw new Exception("add test failed");
+
+ if (sneaky1.subtract(20, 2) != 18)
+ throw new Exception("subtract test failed");
+
+ if (sneaky1.mul(20, 2) != 40)
+ throw new Exception("mul test failed");
+
+ if (sneaky1.divide(20, 2) != 10)
+ throw new Exception("div test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/special_variable_macros_runme.cs b/trunk/Examples/test-suite/csharp/special_variable_macros_runme.cs
new file mode 100644
index 000000000..bd6fd4b04
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/special_variable_macros_runme.cs
@@ -0,0 +1,22 @@
+using System;
+using special_variable_macrosNamespace;
+
+public class runme {
+ static void Main() {
+ Name name = new Name();
+ if (special_variable_macros.testFred(name) != "none")
+ throw new Exception("test failed");
+ if (special_variable_macros.testJack(name) != "$specialname")
+ throw new Exception("test failed");
+ if (special_variable_macros.testJill(name) != "jilly")
+ throw new Exception("test failed");
+ if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap")
+ throw new Exception("test failed");
+ if (special_variable_macros.testJim(name) != "multiname num")
+ throw new Exception("test failed");
+ if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
+ throw new Exception("test failed");
+ NewName newName = NewName.factory("factoryname");
+ name = newName.getStoredName();
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/threads_runme.cs b/trunk/Examples/test-suite/csharp/threads_runme.cs
new file mode 100644
index 000000000..fa901990c
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/threads_runme.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Threading;
+using threadsNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ Kerfuffle kerf = new Kerfuffle();
+ const int NUM_THREADS = 8;
+ Thread[] threads = new Thread[NUM_THREADS];
+ TestThread[] testThreads = new TestThread[NUM_THREADS];
+ // invoke the threads
+ for (int i=0; i<NUM_THREADS; i++) {
+ testThreads[i] = new TestThread(kerf, i);
+ threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
+ threads[i].Start();
+ }
+ // wait for the threads to finish
+ for (int i=0; i<NUM_THREADS; i++) {
+ threads[i].Join();
+ }
+ for (int i=0; i<NUM_THREADS; i++) {
+ if (testThreads[i].Failed) throw new Exception("Test Failed");
+ }
+ }
+}
+
+public class TestThread {
+ private int threadId;
+ private Kerfuffle kerf;
+ public bool Failed;
+ public TestThread(Kerfuffle t, int id) {
+ kerf = t;
+ threadId = id;
+ }
+ public void Run() {
+ Failed = false;
+ try {
+ for (int i=0; i<30000; i++) { // run test for a few seconds on a 1GHz machine
+ string given = "This is the test string that should come back. A number: " + i;
+ string received = kerf.StdString(given);
+ if (received != given) {
+ throw new ApplicationException("StdString string does not match. Received:\n[" + received + "].\nExpected:\n{" + given + "}");
+ }
+ }
+ for (int i=0; i<30000; i++) { // run test for a few seconds on a 1GHz machine
+ string given = "This is the test string that should come back. A number: " + i;
+ string received = kerf.CharString(given);
+ if (received != given) {
+ throw new ApplicationException("StdString string does not match. Received:\n[" + received + "].\nExpected:\n{" + given + "}");
+ }
+ }
+ } catch (Exception e) {
+ Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
+ Failed = true;
+ }
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/csharp/throw_exception_runme.cs b/trunk/Examples/test-suite/csharp/throw_exception_runme.cs
new file mode 100644
index 000000000..e2e520086
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/throw_exception_runme.cs
@@ -0,0 +1,24 @@
+using System;
+using throw_exceptionNamespace;
+
+public class runme
+{
+ static void Main() {
+ Foo f = new Foo();
+ try {
+ f.test_int();
+ throw new Exception("Integer exception should have been thrown");
+ } catch (System.Exception) {
+ }
+ try {
+ f.test_msg();
+ throw new Exception("String exception should have been thrown");
+ } catch (System.Exception) {
+ }
+ try {
+ f.test_cls();
+ throw new Exception("Class exception should have been thrown");
+ } catch (System.Exception) {
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/typemap_namespace_runme.cs b/trunk/Examples/test-suite/csharp/typemap_namespace_runme.cs
new file mode 100644
index 000000000..39f1c6548
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/typemap_namespace_runme.cs
@@ -0,0 +1,16 @@
+// This test tests all the methods in the C# collection wrapper
+
+using System;
+using typemap_namespaceNamespace;
+
+public class typemap_namespace_runme {
+
+ public static void Main() {
+ if (typemap_namespace.test1("hello") != "hello")
+ throw new Exception("test1 failed");
+ if (typemap_namespace.test2("hello") != "hello")
+ throw new Exception("test2 failed");
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/trunk/Examples/test-suite/csharp/typemap_out_optimal_runme.cs
new file mode 100644
index 000000000..5bc1d14be
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/typemap_out_optimal_runme.cs
@@ -0,0 +1,13 @@
+using System;
+using typemap_out_optimalNamespace;
+
+public class typemap_out_optimal_runme {
+
+ public static XX x = null;
+ public static void Main() {
+ XX.debug = false;
+ x = XX.create();
+ }
+
+}
+
diff --git a/trunk/Examples/test-suite/csharp/varargs_runme.cs b/trunk/Examples/test-suite/csharp/varargs_runme.cs
new file mode 100644
index 000000000..b9fca3294
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/varargs_runme.cs
@@ -0,0 +1,20 @@
+// varargs test
+
+using System;
+using varargsNamespace;
+
+public class varargs_runme {
+
+ public static void Main() {
+
+ if (varargs.test("Hello") != "Hello")
+ throw new Exception("Failed");
+
+ Foo f = new Foo("Greetings");
+ if (f.str != "Greetings")
+ throw new Exception("Failed");
+
+ if (f.test("Hello") != "Hello")
+ throw new Exception("Failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp/virtual_poly_runme.cs b/trunk/Examples/test-suite/csharp/virtual_poly_runme.cs
new file mode 100644
index 000000000..9c1f79613
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp/virtual_poly_runme.cs
@@ -0,0 +1,51 @@
+using System;
+using virtual_polyNamespace;
+
+public class runme {
+ static void Main() {
+
+ NDouble d = new NDouble(3.5);
+ NInt i = new NInt(2);
+
+ //
+ // These two natural 'copy' forms fail because no covariant (polymorphic) return types
+ // are supported in C#.
+ //
+ // NDouble dc = d.copy();
+ // NInt ic = i.copy();
+
+ //
+ // Unlike C++, we have to downcast instead.
+ //
+ NDouble dc = (NDouble)d.copy();
+ NInt ic = (NInt)i.copy();
+
+ NDouble ddc = NDouble.narrow(dc);
+ NInt dic = NInt.narrow(ic);
+ dc = ddc; ic = dic; // warning suppression
+
+ virtual_poly.incr(ic);
+ if ( (i.get() + 1) != ic.get() )
+ throw new Exception("incr test failed");
+
+ //
+ // Checking a pure user downcast
+ //
+ NNumber n1 = d.copy();
+ NNumber n2 = d.nnumber();
+ NDouble dn1 = NDouble.narrow(n1);
+ NDouble dn2 = NDouble.narrow(n2);
+
+ if ( (dn1.get()) != dn2.get() )
+ throw new Exception("copy/narrow test failed");
+
+ //
+ // Checking the ref polymorphic case
+ //
+ NNumber nr = d.ref_this();
+ NDouble dr1 = NDouble.narrow(nr);
+ NDouble dr2 = (NDouble)d.ref_this();
+ if ( dr1.get() != dr2.get() )
+ throw new Exception("copy/narrow test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/csharp_attributes.i b/trunk/Examples/test-suite/csharp_attributes.i
new file mode 100644
index 000000000..bca595d9a
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp_attributes.i
@@ -0,0 +1,62 @@
+%module(directors="1") csharp_attributes
+
+// Test the inattributes and outattributes typemaps
+%typemap(cstype, outattributes="[IntOut]", inattributes="[IntIn]") int "int"
+%typemap(imtype, outattributes="[IntegerOut]", inattributes="[IntegerIn]") int "int"
+
+%inline %{
+class Stations {
+public:
+ Stations(int myInt) { }
+ int Reading(int myInt) { return myInt; }
+ static int Swindon(int myInt) { return myInt; }
+};
+#define TESTMACRO 10
+int GlobalFunction(int myInt) { return myInt; }
+%}
+
+//%include "enumsimple.swg"
+//%include "enumtypesafe.swg"
+
+// Test the attributes feature
+%csattributes MoreStations::MoreStations() "[InterCity1]"
+%csattributes MoreStations::Chippenham() "[InterCity2]"
+%csattributes MoreStations::Bath() "[InterCity3]"
+%csattributes Bristol "[InterCity4]"
+%csattributes WestonSuperMare "[InterCity5]"
+%csattributes Wales "[InterCity6]"
+%csattributes Paddington() "[InterCity7]"
+%csattributes DidcotParkway "[InterCity8]"
+%csattributes MoreStations::Cardiff "[System.ComponentModel.Description(\"Cardiff city station\")]"
+%csattributes Swansea "[System.ComponentModel.Description(\"Swansea city station\")]"
+
+%typemap(csattributes) MoreStations "[Eurostar1]"
+%typemap(csattributes) MoreStations::Wales "[Eurostar2]"
+%typemap(csattributes) Cymru "[Eurostar3]"
+
+%inline %{
+struct MoreStations {
+ MoreStations() : Bristol(0) {}
+ void Chippenham() {}
+ static void Bath() {}
+ int Bristol;
+ static double WestonSuperMare;
+ enum Wales { Cardiff = 1, Swansea };
+};
+void Paddington() {}
+float DidcotParkway;
+enum Cymru { Llanelli };
+
+double MoreStations::WestonSuperMare = 0.0;
+%}
+
+// Test directorinattributes and directoroutattributes
+%typemap(imtype, directoroutattributes="[DirectorIntegerOut]", directorinattributes="[DirectorIntegerIn]") int "int"
+%feature("director") YetMoreStations;
+
+%inline %{
+struct YetMoreStations {
+ virtual int Slough(int x) {}
+ virtual ~YetMoreStations() {}
+};
+%}
diff --git a/trunk/Examples/test-suite/csharp_exceptions.i b/trunk/Examples/test-suite/csharp_exceptions.i
new file mode 100644
index 000000000..0f11e7d69
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp_exceptions.i
@@ -0,0 +1,241 @@
+%module csharp_exceptions
+
+%include <exception.i>
+
+%inline %{
+ class Ex {
+ const char *message;
+ public:
+ Ex(const char *msg) : message(msg) {}
+ const char *what() { return message; }
+ };
+%}
+
+%exception ThrowByValue() {
+ try {
+ $action
+ } catch(Ex e) {
+ SWIG_exception(SWIG_DivisionByZero, e.what());
+ }
+}
+
+%exception ThrowByReference() {
+ try {
+ $action
+ } catch(Ex &e) {
+ SWIG_exception(SWIG_DivisionByZero, e.what());
+ }
+}
+
+%csnothrowexception NoThrowException() {
+ try {
+ $action
+ } catch(Ex) {
+ // swallowed
+ }
+}
+
+%inline %{
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+// %exception tests
+void ThrowByValue() { throw Ex("ThrowByValue"); }
+void ThrowByReference() { throw Ex("ThrowByReference"); }
+// %csnothrowexception
+void NoThrowException() { throw Ex("NoThrowException"); }
+// exception specifications
+void ExceptionSpecificationValue() throw(Ex) { throw Ex("ExceptionSpecificationValue"); }
+void ExceptionSpecificationReference() throw(Ex&) { throw Ex("ExceptionSpecificationReference"); }
+void ExceptionSpecificationString() throw(const char *) { throw "ExceptionSpecificationString"; }
+void ExceptionSpecificationInteger() throw(int) { throw 20; }
+%}
+
+// test exceptions in the default typemaps
+
+// null reference exceptions
+%inline %{
+void NullReference(Ex& e) {}
+void NullValue(Ex e) {}
+%}
+
+// enums
+%inline %{
+enum TestEnum {TestEnumItem};
+void ExceptionSpecificationEnumValue() throw(TestEnum) { throw TestEnumItem; }
+void ExceptionSpecificationEnumReference() throw(TestEnum&) { throw TestEnumItem; }
+%}
+
+// std::string
+%include <std_string.i>
+%inline %{
+void ExceptionSpecificationStdStringValue() throw(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); }
+void ExceptionSpecificationStdStringReference() throw(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); }
+void NullStdStringValue(std::string s) {}
+void NullStdStringReference(std::string &s) {}
+%}
+
+// Memory leak check (The C++ exception stack was never unwound in the original approach to throwing exceptions from unmanaged code)
+%exception MemoryLeakCheck() {
+ Counter destructor_should_be_called;
+ try {
+ $action
+ } catch(Ex e) {
+ SWIG_exception(SWIG_DivisionByZero, e.what());
+ }
+}
+
+%inline %{
+struct Counter {
+ static int count;
+ Counter() { count++; }
+ ~Counter() { count--; }
+};
+int Counter::count = 0;
+
+void MemoryLeakCheck() {
+ throw Ex("testing memory leaks when throwing exceptions");
+}
+%}
+
+// test exception pending in the csconstruct typemap
+%inline %{
+struct constructor {
+ constructor(std::string s) {}
+ constructor() throw(int) { throw 10; }
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+// test exception pending in the csout typemaps
+%typemap(out, canthrow=1) unsigned short ushorttest %{
+ $result = $1;
+ if ($result == 100) {
+ SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "don't like 100");
+ return $null;
+ }
+%}
+%inline %{
+unsigned short ushorttest() { return 100; }
+%}
+
+// test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps
+%typemap(check, canthrow=1) int numberin, int InOutStruct::staticnumberin %{
+ if ($1 < 0) {
+ SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "too small");
+ return $null;
+ }
+%}
+%typemap(out, canthrow=1) int numberout, int InOutStruct::staticnumberout %{
+ $result = $1;
+ if ($result > 10) {
+ SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "too big");
+ return $null;
+ }
+%}
+%inline %{
+ int numberin;
+ int numberout;
+ struct InOutStruct {
+ int numberin;
+ int numberout;
+ static int staticnumberin;
+ static int staticnumberout;
+ };
+ int InOutStruct::staticnumberin;
+ int InOutStruct::staticnumberout;
+%}
+
+// test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code
+%typemap(check, canthrow=1) int macrotest {
+ if ($1 < 0) {
+ SWIG_exception(SWIG_IndexError, "testing SWIG_exception macro");
+ }
+}
+%inline %{
+ bool exception_macro_run_flag = false;
+ void exceptionmacrotest(int macrotest) {
+ exception_macro_run_flag = true;
+ }
+%}
+
+// test all the types of exceptions
+%typemap(check, canthrow=1) UnmanagedExceptions {
+ switch($1) {
+ case UnmanagedApplicationException: SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "msg"); return $null; break;
+ case UnmanagedArithmeticException: SWIG_CSharpSetPendingException(SWIG_CSharpArithmeticException, "msg"); return $null; break;
+ case UnmanagedDivideByZeroException: SWIG_CSharpSetPendingException(SWIG_CSharpDivideByZeroException, "msg"); return $null; break;
+ case UnmanagedIndexOutOfRangeException: SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, "msg"); return $null; break;
+ case UnmanagedInvalidCastException: SWIG_CSharpSetPendingException(SWIG_CSharpInvalidCastException, "msg"); return $null; break;
+ case UnmanagedInvalidOperationException: SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, "msg"); return $null; break;
+ case UnmanagedIOException: SWIG_CSharpSetPendingException(SWIG_CSharpIOException, "msg"); return $null; break;
+ case UnmanagedNullReferenceException: SWIG_CSharpSetPendingException(SWIG_CSharpNullReferenceException, "msg"); return $null; break;
+ case UnmanagedOutOfMemoryException: SWIG_CSharpSetPendingException(SWIG_CSharpOutOfMemoryException, "msg"); return $null; break;
+ case UnmanagedOverflowException: SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, "msg"); return $null; break;
+ case UnmanagedSystemException: SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "msg"); return $null; break;
+ case UnmanagedArgumentException: SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, "msg", "parm"); return $null; break;
+ case UnmanagedArgumentNullException: SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "msg", "parm"); return $null; break;
+ case UnmanagedArgumentOutOfRangeException: SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, "msg", "parm"); return $null; break;
+ }
+}
+%inline %{
+enum UnmanagedExceptions {
+ UnmanagedApplicationException,
+ UnmanagedArithmeticException,
+ UnmanagedDivideByZeroException,
+ UnmanagedIndexOutOfRangeException,
+ UnmanagedInvalidCastException,
+ UnmanagedInvalidOperationException,
+ UnmanagedIOException,
+ UnmanagedNullReferenceException,
+ UnmanagedOutOfMemoryException,
+ UnmanagedOverflowException,
+ UnmanagedSystemException,
+ UnmanagedArgumentException,
+ UnmanagedArgumentNullException,
+ UnmanagedArgumentOutOfRangeException,
+};
+
+void check_exception(UnmanagedExceptions e) {
+}
+%}
+
+// exceptions in multiple threads test
+%exception ThrowsClass::ThrowException(long long input) {
+ try {
+ $action
+ } catch (long long d) {
+ char message[64];
+ sprintf(message, "caught:%lld", d);
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, message, "input");
+ }
+}
+%inline %{
+struct ThrowsClass {
+ double dub;
+ ThrowsClass(double d) : dub(d) {}
+ long long ThrowException(long long input) {
+ throw input;
+ return input;
+ }
+};
+%}
+
+// test inner exceptions
+%exception InnerExceptionTest() {
+ try {
+ $action
+ } catch(Ex &e) {
+ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what());
+ SWIG_CSharpSetPendingException(SWIG_CSharpInvalidOperationException, "My OuterException message");
+ }
+}
+
+%inline %{
+void InnerExceptionTest() { throw Ex("My InnerException message"); }
+%}
diff --git a/trunk/Examples/test-suite/csharp_features.i b/trunk/Examples/test-suite/csharp_features.i
new file mode 100644
index 000000000..578a56a10
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp_features.i
@@ -0,0 +1,24 @@
+%module csharp_features
+
+// SWIG gets the method modifiers wrong occasionally, like with private inheritance, %csmethodmodifiers can fix this
+%csmethodmodifiers Derived::VirtualMethod() "public virtual"
+%csmethodmodifiers MoreDerived::variable "public new"
+
+%inline %{
+class Base {
+public:
+ virtual ~Base() {}
+ virtual void VirtualMethod() {}
+};
+class Derived : private Base {
+public:
+ virtual ~Derived() {}
+ virtual void VirtualMethod() {}
+ int variable;
+};
+class MoreDerived : public Derived {
+public:
+ int variable;
+};
+%}
+
diff --git a/trunk/Examples/test-suite/csharp_lib_arrays.i b/trunk/Examples/test-suite/csharp_lib_arrays.i
new file mode 100644
index 000000000..d07d43737
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp_lib_arrays.i
@@ -0,0 +1,61 @@
+%module csharp_lib_arrays
+
+%include "arrays_csharp.i"
+
+%apply int INPUT[] { int* sourceArray }
+%apply int OUTPUT[] { int* targetArray }
+
+%apply int INOUT[] { int* array1 }
+%apply int INOUT[] { int* array2 }
+
+%inline %{
+/* copy the contents of the first array to the second */
+void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
+ int i;
+ for ( i = 0; i < nitems; i++ ) {
+ targetArray[ i ] = sourceArray[ i ];
+ }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwap( int* array1, int* array2, int nitems ) {
+ int i, temp;
+ for ( i = 0; i < nitems; i++ ) {
+ temp = array1[ i ];
+ array1[ i ] = array2[ i ];
+ array2[ i ] = temp;
+ }
+}
+%}
+
+
+%clear int* sourceArray;
+%clear int* targetArray;
+
+%clear int* array1;
+%clear int* array2;
+
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe";
+%csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe";
+
+%apply int FIXED[] { int* sourceArray }
+%apply int FIXED[] { int* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
+ myArrayCopy(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply int FIXED[] { int* array1 }
+%apply int FIXED[] { int* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
+ myArraySwap(array1, array2, nitems);
+}
+%}
+
+
diff --git a/trunk/Examples/test-suite/csharp_prepost.i b/trunk/Examples/test-suite/csharp_prepost.i
new file mode 100644
index 000000000..817f5b9b9
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp_prepost.i
@@ -0,0 +1,192 @@
+%module csharp_prepost
+
+// Test the pre, post, terminate and cshin attributes for csin typemaps
+
+%include "std_vector.i"
+
+%define VECTOR_DOUBLE_CSIN_POST
+" int count$csinput = d$csinput.Count;
+ $csinput = new double[count$csinput];
+ for (int i=0; i<count$csinput; ++i) {
+ $csinput[i] = d$csinput[i];
+ }"
+%enddef
+
+// pre and post in csin typemaps
+%typemap(cstype) std::vector<double> &v "out double[]"
+%typemap(csin, pre=" DoubleVector d$csinput = new DoubleVector();", post=VECTOR_DOUBLE_CSIN_POST, cshin="out $csinput") std::vector<double> &v
+ "$csclassname.getCPtr(d$csinput)"
+
+%apply std::vector<double> & v { std::vector<double> & v2 }
+
+// pre only in csin typemap
+%typemap(cstype) std::vector<double> &vpre "ref double[]"
+%typemap(csin, pre=" DoubleVector d$csinput = new DoubleVector();\n foreach (double d in $csinput) {\n d$csinput.Add(d);\n }", cshin="ref $csinput") std::vector<double> &vpre
+ "$csclassname.getCPtr(d$csinput)"
+
+// post only in csin typemap
+%typemap(csin, post=" int size = $csinput.Count;\n"
+ " for (int i=0; i<size; ++i) {\n"
+ " $csinput[i] /= 100;\n"
+ " }") std::vector<double> &vpost
+ "$csclassname.getCPtr($csinput)"
+
+%inline %{
+bool globalfunction(std::vector<double> & v) {
+ v.push_back(0.0);
+ v.push_back(1.1);
+ v.push_back(2.2);
+ return true;
+}
+struct PrePostTest {
+ PrePostTest() {
+ }
+ PrePostTest(std::vector<double> & v) {
+ v.push_back(3.3);
+ v.push_back(4.4);
+ }
+ bool method(std::vector<double> & v) {
+ v.push_back(5.5);
+ v.push_back(6.6);
+ return true;
+ }
+ static bool staticmethod(std::vector<double> & v) {
+ v.push_back(7.7);
+ v.push_back(8.8);
+ return true;
+ }
+};
+
+// Check pre and post only typemaps and that they coexist okay and that the generated code line spacing looks okay
+bool globalfunction2(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ return true;
+}
+struct PrePost2 {
+ PrePost2() {
+ }
+ PrePost2(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ }
+ bool method(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ return true;
+ }
+ static bool staticmethod(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ return true;
+ }
+};
+%}
+
+%template(DoubleVector) std::vector<double>;
+
+// Check attributes in the typemaps
+%typemap(cstype, inattributes="[CustomInt]") int val "int"
+%typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int "tmp_$csinput"
+%typemap(imtype, out="IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "HandleRef/*overridden*/"
+
+%inline %{
+class CsinAttributes {
+ int m_val;
+public:
+ CsinAttributes(int val) : m_val(val) {}
+ int getVal() { return m_val; }
+};
+%}
+
+
+
+// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html)
+%typemap(cstype) const CDate& "System.DateTime"
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
+ ) const CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+%typemap(cstype) CDate& "out System.DateTime"
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate();",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ cshin="out $csinput"
+ ) CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+
+%inline %{
+class CDate {
+public:
+ CDate();
+ CDate(int year, int month, int day);
+ int getYear();
+ int getMonth();
+ int getDay();
+private:
+ int m_year;
+ int m_month;
+ int m_day;
+};
+struct Action {
+ int doSomething(const CDate &dateIn, CDate &dateOut);
+ Action(const CDate &dateIn, CDate& dateOut);
+};
+%}
+
+%{
+Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;}
+int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; }
+CDate::CDate() : m_year(0), m_month(0), m_day(0) {}
+CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {}
+int CDate::getYear() { return m_year; }
+int CDate::getMonth() { return m_month; }
+int CDate::getDay() { return m_day; }
+%}
+
+%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"
+
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+%inline %{
+void addYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay());
+}
+%}
+
+%typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+%inline %{
+void subtractYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
+}
+%}
+
+%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
+ /* csvarin typemap code */
+ set {
+ CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);
+ $imcall;$excode
+ } %}
+
+%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
+ /* csvarout typemap code */
+ get {
+ IntPtr cPtr = $imcall;
+ CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
+ return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
+ 0, 0, 0);
+ } %}
+
+%inline %{
+CDate ImportantDate = CDate(1999, 12, 31);
+%}
+
diff --git a/trunk/Examples/test-suite/csharp_typemaps.i b/trunk/Examples/test-suite/csharp_typemaps.i
new file mode 100644
index 000000000..b940f25a3
--- /dev/null
+++ b/trunk/Examples/test-suite/csharp_typemaps.i
@@ -0,0 +1,112 @@
+%module csharp_typemaps
+
+// Test the C# types customisation by modifying the default char * typemaps to return a single char
+
+%typemap(ctype, out="char /*ctype out override*/") char * "char *"
+%typemap(imtype, out="char /*imtype out override*/") char * "string"
+%typemap(cstype, out="char /*cstype out override*/") char * "string"
+
+%typemap(out) char * %{
+ // return the 0th element rather than the whole string
+ $result = SWIG_csharp_string_callback($1)[0];
+%}
+
+%typemap(csout, excode=SWIGEXCODE) char * {
+ char ret = $imcall;$excode
+ return ret;
+ }
+
+%typemap(csvarout, excode=SWIGEXCODE2) char * %{
+ get {
+ char ret = $imcall;$excode
+ return ret;
+ } %}
+
+%inline %{
+namespace Space {
+ class Things {
+ public:
+ char* start(char *val) { return val; }
+ static char* stop(char *val) { return val; }
+ };
+ char* partyon(char *val) { return val; }
+}
+%}
+
+
+// Test variables when ref is used in the cstype typemap - the variable name should come from the out attribute if specified
+%typemap(cstype) MKVector, const MKVector& "MKVector"
+%typemap(cstype, out="MKVector") MKVector &, MKVector * "ref MKVector"
+
+%inline %{
+struct MKVector {
+};
+struct MKRenderGameVector {
+ MKVector memberValue;
+ static MKVector staticValue;
+};
+MKVector MKRenderGameVector::staticValue;
+MKVector globalValue;
+%}
+
+
+// Number and Obj are for the eager garbage collector runtime test
+%inline %{
+struct Number {
+ Number(double value) : Value(value) {}
+ double Value;
+};
+
+class Obj {
+public:
+ Number triple(Number n) {
+ n.Value *= 3;
+ return n;
+ }
+ Number times6(const Number& num) {
+ Number n(num);
+ n.Value *= 6;
+ return n;
+ }
+ Number times9(const Number* num) {
+ Number n(*num);
+ n.Value *= 9;
+ return n;
+ }
+};
+Number quadruple(Number n) {
+ n.Value *= 4;
+ return n;
+};
+Number times8(const Number& num) {
+ Number n(num);
+ n.Value *= 8;
+ return n;
+};
+Number times12(const Number* num) {
+ Number n(*num);
+ n.Value *= 12;
+ return n;
+};
+%}
+
+// Test $csinput expansion
+%typemap(csvarin, excode=SWIGEXCODE2) int %{
+ set {
+ if ($csinput < 0)
+ throw new ApplicationException("number too small!");
+ $imcall;$excode
+ } %}
+
+%inline %{
+int myInt = 0;
+%}
+
+
+// Illegal special variable crash
+%typemap(cstype) WasCrashing "$csclassname /*cstype $*csclassname*/" // $*csclassname was causing crash
+%inline %{
+struct WasCrashing {};
+void hoop(WasCrashing was) {}
+%}
+
diff --git a/trunk/Examples/test-suite/default_args.i b/trunk/Examples/test-suite/default_args.i
new file mode 100644
index 000000000..839d28e3e
--- /dev/null
+++ b/trunk/Examples/test-suite/default_args.i
@@ -0,0 +1,243 @@
+// Lots of tests for methods with default parameters / default arguments
+
+%module default_args
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%include <std_string.i>
+
+%inline %{
+ #include <string>
+
+ // Anonymous arguments
+ int anonymous(int = 7771);
+ int anonymous(int x) { return x; }
+
+ // Bug [548272] Default arguments
+ bool booltest(bool x = true) { return x; }
+
+ // scoped enums
+ enum flavor { BITTER, SWEET };
+ class EnumClass {
+ public:
+ enum speed { FAST, SLOW };
+ // Note: default values should be EnumClass::FAST and SWEET
+ bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
+ };
+
+ // casts
+ const char * casts1(const char *m = (const char *) NULL) {
+ char *ret = NULL;
+ if (m) {
+ ret = new char[strlen(m)+1];
+ strcpy(ret, m);
+ }
+ return ret;
+ }
+ const char * casts2(const char *m = (const char *) "Hello") {
+ char *ret = NULL;
+ if (m) {
+ ret = new char[strlen(m)+1];
+ strcpy(ret, m);
+ }
+ return ret;
+ }
+
+ // char
+ char chartest1(char c = 'x') { return c; }
+ char chartest2(char c = '\0') { return c; }
+
+ // namespaces
+ namespace AType {
+ enum AType { NoType };
+ }
+ void dummy(AType::AType aType = AType::NoType) {}
+ namespace A {
+ namespace B {
+ int CONST_NUM = 10;
+ }
+ int afunction(int i = B::CONST_NUM) { return i; }
+ }
+
+ // references
+ int reftest1(const int &x = 42) { return x; }
+ std::string reftest2(const std::string &x = "hello") { return x; }
+
+ // enum scope
+ class Tree {
+ public:
+ enum types {Oak, Fir, Cedar};
+ void chops(enum types type) {}
+ void test(int x = Oak + Fir + Cedar) {}
+ };
+ enum Tree::types chops(enum Tree::types type) { return type; }
+
+%}
+
+// Rename a class member
+%rename(bar2) Foo::bar;
+%rename(newname) Foo::oldname(int x = 1234);
+%ignore Foo::Foo(int x, int y = 0, int z = 0);
+%ignore Foo::meth(int x, int y = 0, int z = 0);
+%rename(renamed3arg) Foo::renameme(int x, double d) const;
+%rename(renamed2arg) Foo::renameme(int x) const;
+%rename(renamed1arg) Foo::renameme() const;
+
+%inline %{
+
+ // Define a class
+ class Foo {
+ public:
+ static int bar;
+ static int spam;
+
+ Foo(){}
+
+ Foo(int x, int y = 0, int z = 0){}
+
+ void meth(int x, int y = 0, int z = 0){}
+
+ // Use a renamed member as a default argument. SWIG has to resolve
+ // bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong.
+ // (Different default parameter wrapping in SWIG-1.3.23 ensures SWIG doesn't have to resolve these symbols).
+ void method1(int x = bar) {}
+
+ // Use unrenamed member as default
+ void method2(int x = spam) {}
+
+ // test the method itself being renamed
+ void oldname(int x = 1234) {}
+ void renameme(int x = 1234, double d=123.4) const {}
+ };
+ int Foo::bar = 1;
+ int Foo::spam = 2;
+%}
+
+
+// tests valuewrapper
+%feature("compactdefaultargs") MyClass2::set;
+%inline %{
+ enum MyType { Val1, Val2 };
+
+ class MyClass1
+ {
+ public:
+ MyClass1(MyType myType) {}
+ };
+
+ class MyClass2
+ {
+ public :
+ void set(MyClass1 cl1 = Val1) {}
+ // This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
+ // But it works in C++ since there is a "conversion" constructor in MyClass1.
+ void set2(MyClass1 cl1 = Val1) {}
+ };
+%}
+
+
+// Default parameters with exception specifications
+%inline %{
+void exceptionspec(int a = -1) throw (int, const char*) {
+ if (a == -1)
+ throw "ciao";
+ else
+ throw a;
+}
+struct Except {
+ Except(bool throwException, int a = -1) throw (int) {
+ if (throwException)
+ throw a;
+ }
+ void exspec(int a = 0) throw (int, const char*) {
+ ::exceptionspec(a);
+ }
+};
+%}
+
+// Default parameters in static class methods
+#ifdef SWIGPYTHON
+%rename(staticMethod) staticmethod;
+#endif
+
+%inline %{
+namespace SpaceName {
+ struct Statics {
+ static int staticmethod(int a=10, int b=20, int c=30) { return a+b+c; }
+ };
+}
+%}
+
+
+// Tests which could never be wrapped prior to changes in default argument wrapping implemented in SWIG-1.3.23:
+%inline %{
+class Tricky {
+ static int getDefault() { return 500; }
+ enum { privatevalue = 200 };
+ static const char charvalue;
+public:
+ int privatedefault(int val = privatevalue) { return val; }
+ int protectedint(int val = intvalue) { return val; }
+ double protecteddouble(double val = doublevalue) { return val; }
+ int functiondefault(int val = Tricky::getDefault()) { return val; }
+ char contrived(const char *c = &charvalue) { return *c; }
+protected:
+ static const int intvalue = 2000;
+ static const double doublevalue;
+};
+const char Tricky::charvalue = 'X';
+const double Tricky::doublevalue = 987.654;
+
+
+// tests default argument which is a constructor call within namespace
+// also tests default constructor (from defaulted parameter)
+namespace Space {
+struct Klass {
+ int val;
+ Klass(int val = -1) : val(val) {}
+};
+Klass constructorcall(const Klass& k = Klass()) { return k; }
+
+}
+%}
+
+%{
+struct ConstMethods {
+ int coo(double d = 0.0) { return 10; }
+ int coo(double d = 0.0) const { return 20; }
+};
+%}
+
+// const methods
+// runtime test needed to check that the const method is called
+struct ConstMethods {
+ int coo(double d = 0.0) const;
+};
+
+
+
+// Default args with C linkage
+%inline
+%{
+ extern "C" double cfunc1(double x,double p = 1) {
+ return(x+p);
+ }
+
+ extern "C" {
+ double cfunc2(double x,double p = 2) {
+ return(x+p);
+ }
+
+ double cfunc3(double x,double p = 3) {
+ return(x+p);
+ }
+
+ typedef struct Pointf {
+ double x,y;
+ } Pointf;
+ }
+%}
diff --git a/trunk/Examples/test-suite/default_constructor.i b/trunk/Examples/test-suite/default_constructor.i
new file mode 100644
index 000000000..ff22c7834
--- /dev/null
+++ b/trunk/Examples/test-suite/default_constructor.i
@@ -0,0 +1,170 @@
+// This module tests default constructor generation under a
+// number of different conditions
+
+%module(ruby_minherit="1") default_constructor
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */
+
+%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
+
+%delobject F::destroy;
+%delobject G::destroy;
+
+%inline %{
+
+/* A class with a public default constructor */
+class A {
+public:
+ A() { };
+};
+
+/* This class should get default constructor/destructors */
+class AA : public A {
+};
+
+/* A class with a public constructor, but not default */
+
+class B {
+private:
+ B() { }
+public:
+ B(int x, int y) { }
+};
+
+/* This class should get no default constructor, but a destructor */
+class BB : public B {
+};
+
+/* A class with a protected constructor */
+class C {
+protected:
+ C() { };
+public:
+};
+
+/* This class does get a default constructor/destructor */
+class CC : public C {
+};
+
+
+/* A class with a private constructor */
+class D {
+private:
+ D() { };
+public:
+ void foo() { };
+};
+
+/* This class does not get a default constructor */
+class DD: public D {
+
+};
+
+/* No default constructor. A is okay, but D is not */
+class AD: public A, public D {
+
+};
+
+/* This class has a default constructor because of optional arguments */
+class E {
+public:
+ E(int x = 0, int y = 0) { }
+};
+
+/* This should get a default constructor */
+class EE : public E {
+};
+
+/* This class should not get a default constructor. B doesn't have one */
+
+class EB : public E, public B {
+
+};
+
+/* A class with a private destructor */
+
+class F {
+private:
+ ~F() { }
+public:
+ void foo(int, int) { }
+ friend void bar(F *);
+ void destroy() { delete this; }
+
+};
+
+void bar(F *) { }
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible
+#endif
+class FFF : public F {
+};
+#if defined(_MSC_VER)
+ #pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible
+#endif
+
+/* A class with a protected destructor */
+class G {
+protected:
+ ~G() { }
+
+public:
+ static void destroy(G *g) { delete g; }
+};
+
+class GG : public G {
+};
+
+template <class T>
+class HH_T
+{
+
+
+public:
+
+ HH_T(int i,int j)
+ {
+ }
+
+
+protected:
+ HH_T();
+
+};
+
+
+%}
+
+
+%template(HH) HH_T<int>;
+
+
+%{
+ class OSRSpatialReferenceShadow {
+ private:
+ OSRSpatialReferenceShadow();
+ public:
+ };
+%}
+
+typedef void OSRSpatialReferenceShadow;
+
+class OSRSpatialReferenceShadow {
+private:
+public:
+ %extend {
+ OSRSpatialReferenceShadow( char const * wkt = "" ) {
+ return 0;
+ }
+ }
+};
+
+
+
diff --git a/trunk/Examples/test-suite/defvalue_constructor.i b/trunk/Examples/test-suite/defvalue_constructor.i
new file mode 100644
index 000000000..e4aabaf50
--- /dev/null
+++ b/trunk/Examples/test-suite/defvalue_constructor.i
@@ -0,0 +1,14 @@
+%module defvalue_constructor
+%inline %{
+
+namespace Foo {
+
+ class Bar {};
+
+ class Baz {
+ public:
+ Baz(Bar b = Bar()) {}
+ };
+}
+
+%}
diff --git a/trunk/Examples/test-suite/derived_byvalue.i b/trunk/Examples/test-suite/derived_byvalue.i
new file mode 100644
index 000000000..a251a8fc6
--- /dev/null
+++ b/trunk/Examples/test-suite/derived_byvalue.i
@@ -0,0 +1,91 @@
+%module derived_byvalue
+
+%inline %{
+
+struct Foo {
+ int x;
+
+ // this works
+ int rmethod(const Foo& f) { return f.x; }
+
+ // this doesn't when DerFoo (below) is introduced
+ int method(Foo f) { return f.x; }
+};
+
+struct Bar {
+ Foo a;
+ struct Foo b;
+};
+
+/*
+ When the next derived class is declared, the
+ following bad method is generated
+
+ static void *_DerFooTo_Foo(void *x) { // **** bad ****
+ return (void *)((Foo) ((DerFoo) x));
+ }
+
+ static void *_p_DerFooTo_p_Foo(void *x) { // *** good ***
+ return (void *)((Foo *) ((DerFoo *) x));
+ }
+
+ if the derived class is deleted, it works again
+
+ if the previous Foo::method is deleted, it works again
+
+ */
+struct DerFoo : Foo {
+};
+
+/*
+ The problem is caused by accidentally remembering a object value type
+ instead of an object pointer type.
+ During the course of SWIGing a file, several calls to SwigType_remember()
+ or SwigType_remember_clientdata() will be made.
+ When the SwigType_emit_type_table() function is called it emits all the
+ type conversion functions.
+
+ If a object type exists in the SwigType table, you get this error.
+
+ You can view the SwigType table, with a #define DEBUG at the top of
+ Source/Swig/typesys.c
+
+ When run you get an output like this:
+
+---r_mangled---
+Hash {
+ '_p_Bar' : Hash {
+ 'p.Bar' : _p_Bar,
+ }
+,
+ '_p_DerFoo' : Hash {
+ 'p.DerFoo' : _p_DerFoo,
+ }
+,
+ '_p_Foo' : Hash {
+ 'r.Foo' : _p_Foo,
+ 'p.Foo' : _p_Foo,
+ }
+,
+ '_Foo' : Hash {
+ 'Foo' : _Foo,
+ }
+,
+}
+....
+
+ The last field ('_Foo') is an object type and caused the error.
+ It can be fixed either by checking all the calls to SwigType_remember()
+ and by checking the typemaps.
+ The typemap code also calls SwigType_remember(), if your typemaps
+ defined an object type, it will be added into the SwigType table.
+ its normally a
+ SWIG_ConvertPtr(....$descriptor...)
+ when it should have been a $&descriptor or $*descriptor
+
+ Commenting out all your object typemaps (and typecheck fns) may help
+ isolate it.
+
+*/
+#
+%}
diff --git a/trunk/Examples/test-suite/derived_nested.i b/trunk/Examples/test-suite/derived_nested.i
new file mode 100644
index 000000000..29114d5a0
--- /dev/null
+++ b/trunk/Examples/test-suite/derived_nested.i
@@ -0,0 +1,27 @@
+/* This testcase tests nested derived classes.
+This was reported in bug #909389 */
+
+%module derived_nested
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::CC;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::DD;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::EE;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::FF;
+
+%inline %{
+
+class A { int x; };
+class B {
+ class C { int y; }; //generates a warning
+ class D : public A { int z; }; //ok
+};
+
+struct BB {
+ class CC { int y; };
+ class DD : public A { int z; };
+ struct EE : public A { int z; };
+ struct FF : public A { int z; } ff_instance; // Bug 1960977
+ void useEE(const EE& e) {}
+};
+%}
+
diff --git a/trunk/Examples/test-suite/destructor_reprotected.i b/trunk/Examples/test-suite/destructor_reprotected.i
new file mode 100644
index 000000000..67328f3a0
--- /dev/null
+++ b/trunk/Examples/test-suite/destructor_reprotected.i
@@ -0,0 +1,41 @@
+%module destructor_reprotected
+
+
+%inline {
+
+ struct A
+ {
+ A()
+ {
+ }
+
+ virtual ~A()
+ {
+ }
+
+ };
+
+ struct B : A
+ {
+ protected:
+ B()
+ {
+ }
+
+ ~B()
+ {
+ }
+
+ };
+
+ struct C : B
+ {
+ C()
+ {
+ }
+
+ ~C()
+ {
+ }
+ };
+}
diff --git a/trunk/Examples/test-suite/director_abstract.i b/trunk/Examples/test-suite/director_abstract.i
new file mode 100644
index 000000000..cc9dca55a
--- /dev/null
+++ b/trunk/Examples/test-suite/director_abstract.i
@@ -0,0 +1,200 @@
+%module(directors="1") director_abstract
+%{
+#include <string>
+
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual std::string ping() = 0;
+ virtual std::string pong() { return "Foo::pong();" + ping(); }
+};
+
+%}
+
+%include <std_string.i>
+
+%feature("director") Foo;
+
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual std::string ping() = 0;
+ virtual std::string pong() { return "Foo::pong();" + ping(); }
+};
+
+
+
+%feature("director");
+
+%inline %{
+class Example0
+{
+protected:
+ int xsize, ysize;
+
+public:
+
+ Example0(int x, int y)
+ : xsize(x), ysize(y) { }
+
+ Example0() { }
+
+public:
+ virtual ~Example0() {}
+
+ int GetXSize() const { return xsize; }
+
+ // pure virtual methods that must be overridden
+ virtual int Color(unsigned char r, unsigned char g, unsigned char b)
+ {
+ return 0;
+ }
+
+
+ static int get_color(Example0 *ptr, unsigned char r,
+ unsigned char g, unsigned char b) {
+ return ptr->Color(r, g, b);
+ }
+};
+
+class Example1
+{
+protected:
+ int xsize, ysize;
+
+protected:
+ /* this shouldn't be emitted, unless 'dirprot' is used, since they
+ is already a public constructor */
+
+ Example1(int x, int y)
+ : xsize(x), ysize(y) { }
+
+public:
+ Example1() { }
+
+public:
+ virtual ~Example1() {}
+
+ int GetXSize() const { return xsize; }
+
+ // pure virtual methods that must be overridden
+ virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
+
+ static int get_color(Example1 *ptr, unsigned char r,
+ unsigned char g, unsigned char b) {
+ return ptr->Color(r, g, b);
+ }
+
+
+};
+
+
+class Example2
+{
+protected:
+ int xsize, ysize;
+
+protected:
+ /* there is no default constructor, hence, all protected constructors
+ should be emitted */
+
+ Example2(int x)
+ {
+ }
+
+ Example2(int x, int y)
+ : xsize(x), ysize(y) { }
+
+public:
+
+ virtual ~Example2() {}
+
+ int GetXSize() const { return xsize; }
+
+ // pure virtual methods that must be overridden
+ virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
+
+ static int get_color(Example2 *ptr, unsigned char r,
+ unsigned char g, unsigned char b) {
+ return ptr->Color(r, g, b);
+ }
+};
+
+class Example4
+{
+protected:
+ int xsize, ysize;
+
+protected:
+
+ Example4()
+ {
+ }
+
+ /* this is not emitted, unless dirprot is used */
+ Example4(int x, int y)
+ : xsize(x), ysize(y) { }
+
+public:
+
+ virtual ~Example4() {}
+
+ int GetXSize() const { return xsize; }
+
+ // pure virtual methods that must be overridden
+ virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
+
+ static int get_color(Example4 *ptr, unsigned char r,
+ unsigned char g, unsigned char b) {
+ return ptr->Color(r, g, b);
+ }
+};
+
+namespace ns
+{
+ template <class T>
+ class Example3
+ {
+ protected:
+ /* the default constructor is always emitter, even when protected,
+ having another public constructor, and 'dirprot' is not used.
+ This is just for Java compatibility */
+ Example3()
+ {
+ }
+
+ /* this is no emitted, unless dirprot mode is used */
+ Example3(int x) { }
+
+ public:
+
+ Example3(int x, int y) { }
+
+ virtual ~Example3() {}
+
+ // pure virtual methods that must be overridden
+ virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
+
+ static int get_color(Example3 *ptr, unsigned char r,
+ unsigned char g, unsigned char b) {
+ return ptr->Color(r, g, b);
+ }
+ };
+}
+%}
+
+%template(Example3_i) ns::Example3<int>;
+
+
+%inline %{
+ struct A{
+ virtual ~A() {}
+ friend int g(A* obj);
+ protected:
+ A(const A&){}
+ virtual int f() = 0;
+ };
+
+ int g(A* obj) {return 1;}
+
+%}
diff --git a/trunk/Examples/test-suite/director_basic.i b/trunk/Examples/test-suite/director_basic.i
new file mode 100644
index 000000000..12cb0db65
--- /dev/null
+++ b/trunk/Examples/test-suite/director_basic.i
@@ -0,0 +1,144 @@
+ %module(directors="1") director_basic
+ #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+ %{
+ #include <string>
+
+ class Foo {
+ public:
+ virtual ~Foo() {}
+ virtual std::string ping() { return "Foo::ping()"; }
+ virtual std::string pong() { return "Foo::pong();" + ping(); }
+
+ static Foo* get_self(Foo *self) {return self;}
+
+ };
+
+ %}
+
+ %include <std_string.i>
+
+ %feature("director") Foo;
+
+
+ class Foo {
+ public:
+ virtual ~Foo();
+ virtual std::string ping();
+ virtual std::string pong();
+
+ static Foo* get_self(Foo *self);
+
+ };
+
+ %{
+ #include <complex>
+ %}
+ %feature("director") A;
+
+ // basic renaming
+ %rename(rg) A::gg;
+ %feature("nodirector") hi::A1::gg;
+
+ %inline %{
+
+ struct A{
+ A(std::complex<int> i, double d=0.0) {}
+ A(int i, bool j=false) {}
+ virtual ~A() {}
+
+ virtual int f(int i=0) {return i;}
+ virtual int gg(int i=0) {return i;}
+ };
+
+ namespace hi {
+
+ struct A1 : public A {
+ A1(std::complex<int> i, double d=0.0) : A(i, d) {}
+ A1(int i, bool j=false) : A(i, j) {}
+
+ virtual int ff(int i = 0) {return i;}
+ };
+ }
+
+
+ %}
+
+
+ %feature("director") MyClass;
+
+ %inline %{
+
+ typedef void VoidType;
+
+ struct Bar
+ {
+ int x;
+ Bar(int _x = 0) : x(_x)
+ {
+ }
+ };
+
+
+
+class MyClass {
+public:
+ MyClass(int a = 0)
+ {
+ }
+
+ virtual void method(VoidType *)
+ {
+ }
+
+ virtual ~MyClass()
+ {
+ }
+
+ virtual Bar vmethod(Bar b)
+ {
+ b.x += 13;
+ return b;
+ }
+
+ virtual Bar* pmethod(Bar *b)
+ {
+ b->x += 12;
+ return b;
+ }
+
+ Bar cmethod(const Bar &b)
+ {
+ return vmethod(b);
+ }
+
+ static MyClass *get_self(MyClass *c)
+ {
+ return c;
+ }
+
+ static Bar * call_pmethod(MyClass *myclass, Bar *b) {
+ return myclass->pmethod(b);
+ }
+};
+
+template<class T>
+class MyClassT {
+public:
+ MyClassT(int a = 0)
+ {
+ }
+
+ virtual void method(VoidType *)
+ {
+ }
+
+ virtual ~MyClassT()
+ {
+ }
+
+};
+
+%}
+
+%template(MyClassT_i) MyClassT<int>;
diff --git a/trunk/Examples/test-suite/director_classes.i b/trunk/Examples/test-suite/director_classes.i
new file mode 100644
index 000000000..5d0a67d00
--- /dev/null
+++ b/trunk/Examples/test-suite/director_classes.i
@@ -0,0 +1,104 @@
+// Tests classes passed by value, pointer and reference
+// Note: C# module has a large runtime test
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%module(directors="1") director_classes
+
+%feature("director") Base;
+%feature("director") Derived;
+
+%include "std_string.i"
+
+%inline %{
+#include <cstdio>
+#include <iostream>
+
+
+// Use for debugging
+bool PrintDebug = false;
+
+
+struct DoubleHolder
+{
+ DoubleHolder(double v = 0.0) : val(v) {}
+ double val;
+};
+
+class Base {
+protected:
+ double m_dd;
+public:
+
+ Base(double dd) : m_dd(dd) {}
+ virtual ~Base() {}
+
+ virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Base - Val(" << x.val << ")" << std::endl; return x; }
+ virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Base - Ref(" << x.val << ")" << std::endl; return x; }
+ virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Base - Ptr(" << x->val << ")" << std::endl; return x; }
+
+ virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(int " << x << ")" << std::endl; return "Base::FullyOverloaded(int)"; }
+ virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(bool " << x << ")" << std::endl; return "Base::FullyOverloaded(bool)"; }
+
+ virtual std::string SemiOverloaded(int x) { if (PrintDebug) std::cout << "Base - SemiOverloaded(int " << x << ")" << std::endl; return "Base::SemiOverloaded(int)"; }
+ virtual std::string SemiOverloaded(bool x) { if (PrintDebug) std::cout << "Base - SemiOverloaded(bool " << x << ")" << std::endl; return "Base::SemiOverloaded(bool)"; }
+
+ virtual std::string DefaultParms(int x, double y = 1.1) {
+ if (PrintDebug) std::cout << "Base - DefaultParms(" << x << ", " << y << ")" << std::endl;
+ std::string ret("Base::DefaultParms(int");
+ if (y!=1.1)
+ ret = ret + std::string(", double");
+ ret = ret + std::string(")");
+ return ret;
+ }
+};
+
+class Derived : public Base {
+public:
+ Derived(double dd) : Base(dd) {}
+ virtual ~Derived() {}
+
+ virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Derived - Val(" << x.val << ")" << std::endl; return x; }
+ virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Derived - Ref(" << x.val << ")" << std::endl; return x; }
+ virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Derived - Ptr(" << x->val << ")" << std::endl; return x; }
+
+ virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(int " << x << ")" << std::endl; return "Derived::FullyOverloaded(int)"; }
+ virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(bool " << x << ")" << std::endl; return "Derived::FullyOverloaded(bool)"; }
+
+ virtual std::string SemiOverloaded(int x) { if (PrintDebug) std::cout << "Derived - SemiOverloaded(int " << x << ")" << std::endl; return "Derived::SemiOverloaded(int)"; }
+ // No SemiOverloaded(bool x)
+
+ virtual std::string DefaultParms(int x, double y = 1.1) {
+ if (PrintDebug) std::cout << "Derived - DefaultParms(" << x << ", " << y << ")" << std::endl;
+ std::string ret("Derived::DefaultParms(int");
+ if (y!=1.1)
+ ret = ret + std::string(", double");
+ ret = ret + std::string(")");
+ return ret;
+ }
+};
+
+
+class Caller {
+private:
+ Base *m_base;
+ void delBase() { delete m_base; m_base = 0; }
+public:
+ Caller(): m_base(0) {}
+ ~Caller() { delBase(); }
+ void set(Base *b) { delBase(); m_base = b; }
+ void reset() { m_base = 0; }
+
+ DoubleHolder ValCall(DoubleHolder x) { return m_base->Val(x); }
+ DoubleHolder& RefCall(DoubleHolder& x) { return m_base->Ref(x); }
+ DoubleHolder* PtrCall(DoubleHolder* x) { return m_base->Ptr(x); }
+ std::string FullyOverloadedCall(int x) { return m_base->FullyOverloaded(x); }
+ std::string FullyOverloadedCall(bool x) { return m_base->FullyOverloaded(x); }
+ std::string SemiOverloadedCall(int x) { return m_base->SemiOverloaded(x); }
+ std::string SemiOverloadedCall(bool x) { return m_base->SemiOverloaded(x); }
+ std::string DefaultParmsCall(int x) { return m_base->DefaultParms(x); }
+ std::string DefaultParmsCall(int x, double y) { return m_base->DefaultParms(x, y); }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/director_classic.i b/trunk/Examples/test-suite/director_classic.i
new file mode 100644
index 000000000..f22de4c98
--- /dev/null
+++ b/trunk/Examples/test-suite/director_classic.i
@@ -0,0 +1,53 @@
+%module(directors="1") director_classic
+
+%include "std_string.i"
+
+%feature("director");
+
+%inline %{
+
+#include <cstdio>
+#include <iostream>
+#include <string>
+
+struct Being {
+ virtual std::string id() { return "Being"; }
+ virtual ~Being() {}
+};
+
+struct Person : Being {
+ virtual std::string id() { return "Person"; }
+};
+
+struct Child : Person {
+ virtual std::string id() { return "Child"; }
+};
+
+struct GrandChild : Child {
+ virtual std::string id() { return "GrandChild"; }
+};
+
+// Orphans - don't override id() in C++
+struct OrphanPerson : Person {
+ // no overridden id()
+};
+
+struct OrphanChild : Child {
+ // no overridden id()
+};
+
+class Caller {
+private:
+ Person *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Person *cb) { delCallback(); _callback = cb; }
+ void resetCallback() { _callback = 0; }
+ std::string call() { if (_callback) return _callback->id(); else return "oops"; }
+ Person* baseClass() { return _callback; }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/director_constructor.i b/trunk/Examples/test-suite/director_constructor.i
new file mode 100644
index 000000000..b3505f9f5
--- /dev/null
+++ b/trunk/Examples/test-suite/director_constructor.i
@@ -0,0 +1,37 @@
+%module(directors="1") director_constructor
+
+%feature("director") Foo;
+
+%inline %{
+class Foo
+{
+public:
+ int a;
+
+ Foo(int i)
+ {
+ a=i;
+ }
+
+ virtual ~Foo() { }
+
+ int do_test() {
+ return test();
+ }
+
+ virtual int getit()
+ {
+ return a;
+ }
+
+ virtual void doubleit()
+ {
+ a = a * 2;
+ }
+
+ virtual int test() = 0;
+};
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/director_default.i b/trunk/Examples/test-suite/director_default.i
new file mode 100644
index 000000000..8eb2ce370
--- /dev/null
+++ b/trunk/Examples/test-suite/director_default.i
@@ -0,0 +1,66 @@
+%module(directors="1") director_default
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DefaultsBase;
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DefaultsDerived;
+
+%{
+#include <string>
+
+class Foo {
+public:
+ Foo(int i = -1) {}
+ virtual ~Foo() {}
+ virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
+
+ std::string GetMsg() { return Msg(); }
+ std::string GetMsg(std::string msg) { return Msg(msg); }
+};
+
+%}
+
+%include <std_string.i>
+
+%feature("director") Foo;
+
+class Foo {
+public:
+ Foo(int i = -1) {}
+ virtual ~Foo() {}
+ virtual std::string Msg(std::string msg = "default") { return msg; }
+
+ std::string GetMsg() { return Msg(); }
+ std::string GetMsg(std::string msg) { return Msg(msg); }
+};
+
+
+%inline %{
+class Bar {
+public:
+ Bar() {}
+ Bar(int i) {}
+ virtual ~Bar() {}
+ virtual std::string Msg(std::string msg = "default") { return "Bar-" + msg; }
+
+ std::string GetMsg() { return Msg(); }
+ std::string GetMsg(std::string msg) { return Msg(msg); }
+};
+
+%}
+
+%feature("director") DefaultsBase;
+%feature("director") DefaultsDerived;
+
+%inline %{
+typedef int* IntegerPtr;
+typedef double Double;
+
+struct DefaultsBase {
+ virtual IntegerPtr defaultargs(double d, int * a = 0) = 0;
+ virtual ~DefaultsBase() {}
+};
+
+struct DefaultsDerived : DefaultsBase {
+ int * defaultargs(Double d, IntegerPtr a = 0) { return 0; }
+};
+%}
+
diff --git a/trunk/Examples/test-suite/director_detect.i b/trunk/Examples/test-suite/director_detect.i
new file mode 100644
index 000000000..fcb01b3e9
--- /dev/null
+++ b/trunk/Examples/test-suite/director_detect.i
@@ -0,0 +1,72 @@
+%module(directors="1") director_detect
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET,
+ SWIGWARN_CSHARP_COVARIANT_RET) cloner; /* Java, C# covariant return types */
+
+%{
+#include <string>
+#include <iostream>
+%}
+
+%include <std_string.i>
+
+%feature("director") Bar;
+%feature("director") Foo;
+
+%newobject Foo::cloner();
+%newobject Foo::get_class();
+%newobject Bar::cloner();
+%newobject Bar::get_class();
+
+
+%inline {
+ namespace foo { typedef int Int; }
+
+ struct A
+ {
+ };
+
+ typedef A B;
+
+ struct Foo {
+ virtual ~Foo() {}
+ virtual Foo* cloner() = 0;
+ virtual int get_value() = 0;
+ virtual A* get_class() = 0;
+
+ virtual void just_do_it() = 0;
+ };
+
+ class Bar : public Foo
+ {
+ public:
+ Foo* baseclass()
+ {
+ return this;
+ }
+
+ Bar* cloner()
+ {
+ return new Bar();
+ }
+
+
+ foo::Int get_value()
+ {
+ return 1;
+ }
+
+ B* get_class()
+ {
+ return new B();
+ }
+
+ void just_do_it()
+ {
+ }
+ };
+}
+
+
+
diff --git a/trunk/Examples/test-suite/director_enum.i b/trunk/Examples/test-suite/director_enum.i
new file mode 100644
index 000000000..e57734e74
--- /dev/null
+++ b/trunk/Examples/test-suite/director_enum.i
@@ -0,0 +1,86 @@
+%module(directors="1") director_enum
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::hi; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::hello; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::yo; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::awright; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::Foo::ciao; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::Foo::aufwiedersehen; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) EnumDirector::Foo::adios; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,
+ SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) EnumDirector::Foo; /* Thread/reentrant unsafe wrapping, consider returning by value instead. */
+
+
+
+%feature("director") Foo;
+
+%rename(Hallo) EnumDirector::Hello;
+
+%inline %{
+namespace EnumDirector {
+ struct A;
+
+ enum Hello {
+ hi, hello, yo, awright = 10
+ };
+
+ class Foo {
+ public:
+ enum Bye {
+ ciao, aufwiedersehen = 100, adios
+ };
+ virtual ~Foo() {}
+ virtual Hello say_hi(Hello h){ return h;}
+ virtual Hello say_hello(Hello){ return hello;}
+ virtual Hello say_hi(A *a){ return hi;}
+ virtual Bye say_bye(Bye b){ return b;}
+ virtual const Hello & say_hi_ref(const Hello & h){ return h;}
+
+ Hello ping(Hello h){ return say_hi(h);}
+ const Hello & ping_ref(const Hello &h){ return say_hi_ref(h);}
+ Bye ping_member_enum(Bye b){ return say_bye(b);}
+
+ };
+}
+%}
+
+%feature("director");
+
+%inline %{
+namespace EnumDirector {
+enum FType{ SA = -1, NA_=0, EA=1};
+
+struct A{
+ A(const double a, const double b, const FType c)
+ {}
+
+ virtual ~A() {}
+
+ virtual int f(int i=0) {return i;}
+};
+
+struct B : public A{
+ B(const double a, const double b, const FType c)
+ : A(a, b, c)
+ {}
+};
+}
+%}
+
+
+%inline %{
+namespace EnumDirector {
+struct A2{
+ A2(const FType c = NA_) {}
+
+ virtual ~A2() {}
+
+ virtual int f(int i=0) {return i;}
+};
+
+struct B2 : public A2{
+ B2(const FType c) : A2(c) {}
+};
+}
+
+%}
diff --git a/trunk/Examples/test-suite/director_exception.i b/trunk/Examples/test-suite/director_exception.i
new file mode 100644
index 000000000..de0ef3343
--- /dev/null
+++ b/trunk/Examples/test-suite/director_exception.i
@@ -0,0 +1,112 @@
+%module(directors="1") director_exception
+
+%{
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+#include <string>
+
+
+// define dummy director exception classes to prevent spurious errors
+// in target languages that do not support directors.
+
+#ifndef SWIG_DIRECTORS
+namespace Swig {
+class DirectorException {};
+class DirectorMethodException: public Swig::DirectorException {};
+}
+ #ifndef SWIG_fail
+ #define SWIG_fail
+ #endif
+#endif /* !SWIG_DIRECTORS */
+
+%}
+
+%include "std_string.i"
+
+#ifdef SWIGPYTHON
+
+%feature("director:except") {
+ if ($error != NULL) {
+ throw Swig::DirectorMethodException();
+ }
+}
+
+%exception {
+ try { $action }
+ catch (Swig::DirectorException &) { SWIG_fail; }
+}
+
+#endif
+
+#ifdef SWIGRUBY
+
+%feature("director:except") {
+ throw Swig::DirectorMethodException($error);
+}
+
+%exception {
+ try { $action }
+ catch (Swig::DirectorException &e) { rb_exc_raise(e.getError()); }
+}
+
+#endif
+
+%feature("director") Foo;
+
+%inline {
+
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual std::string ping() { return "Foo::ping()"; }
+ virtual std::string pong(int val=3) { return "Foo::pong();" + ping(); }
+};
+
+Foo *launder(Foo *f) {
+ return f;
+}
+
+}
+
+
+%{
+ struct Unknown1
+ {
+ };
+
+ struct Unknown2
+ {
+ };
+%}
+
+%feature("director") Bar;
+
+
+%inline %{
+ struct Exception1
+ {
+ };
+
+ struct Exception2
+ {
+ };
+
+ class Base
+ {
+ public:
+ virtual ~Base() throw () {}
+ };
+
+
+ class Bar : public Base
+ {
+ public:
+ virtual std::string ping() throw (Exception1, Exception2&) { return "Bar::ping()"; }
+ virtual std::string pong() throw (Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); }
+ virtual std::string pang() throw () { return "Bar::pang()"; }
+ };
+
+%}
diff --git a/trunk/Examples/test-suite/director_extend.i b/trunk/Examples/test-suite/director_extend.i
new file mode 100644
index 000000000..515866ac6
--- /dev/null
+++ b/trunk/Examples/test-suite/director_extend.i
@@ -0,0 +1,54 @@
+
+%module(directors="1") director_extend
+
+%extend SpObject
+{
+ virtual int dummy() // Had to remove virtual to work
+ {
+ return $self->getFooBar();
+ }
+};
+
+%inline %{
+#ifndef SWIG_DIRECTORS
+// dummy definition for non-director languages
+namespace Swig {
+ typedef int Director;
+}
+#endif
+%}
+
+%extend SpObject
+{
+ size_t ExceptionMethod()
+ {
+// Check positioning of director code in wrapper file
+// Below is what we really want to test, but director exceptions vary too much across across all languages
+// throw Swig::DirectorException("DirectorException was not in scope!!");
+// Instead check definition of Director class as that is defined in the same place as DirectorException (director.swg)
+ size_t size = sizeof(Swig::Director);
+ return size;
+ }
+};
+
+
+%inline %{
+class SpObject
+{
+public:
+ SpObject() {}
+ virtual ~SpObject() {}
+
+ int getFooBar() const {
+ return 666;
+ }
+
+private:
+ // Do NOT define the assignment operator
+ SpObject& operator=(const SpObject& rhs);
+
+ // This class can not be copied. Do NOT define the copy Constructor.
+ SpObject (const SpObject& rhs);
+};
+%}
+
diff --git a/trunk/Examples/test-suite/director_finalizer.i b/trunk/Examples/test-suite/director_finalizer.i
new file mode 100644
index 000000000..52cdb1f52
--- /dev/null
+++ b/trunk/Examples/test-suite/director_finalizer.i
@@ -0,0 +1,42 @@
+%module(directors="1") director_finalizer
+%{
+
+int status = 0;
+
+class Foo {
+public:
+ virtual ~Foo() { orStatus(1); }
+ virtual void orStatus(int x) { status |= x; }
+};
+
+void deleteFoo(Foo *f) {
+ delete f;
+}
+
+Foo *launder(Foo *f) {
+ return f;
+}
+
+int getStatus() {
+ return status;
+}
+
+void resetStatus() {
+ status = 0;
+}
+
+%}
+
+%feature("director") Foo;
+
+class Foo {
+public:
+ virtual ~Foo();
+ virtual void orStatus(int x);
+};
+
+void deleteFoo(Foo *f);
+int getStatus();
+Foo *launder(Foo *f);
+void resetStatus();
+
diff --git a/trunk/Examples/test-suite/director_frob.i b/trunk/Examples/test-suite/director_frob.i
new file mode 100644
index 000000000..cf555eb66
--- /dev/null
+++ b/trunk/Examples/test-suite/director_frob.i
@@ -0,0 +1,106 @@
+%module(directors="1") director_frob;
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%header %{
+#include <iostream>
+%}
+
+%feature("director");
+%feature("nodirector") Bravo::abs_method(); // ok
+%feature("director") Charlie::abs_method(); // ok
+%feature("nodirector") Delta::abs_method(); // ok
+
+%inline %{
+
+ struct Alpha
+ {
+ virtual ~Alpha() { };
+ virtual const char* abs_method() = 0;
+ };
+
+ struct Bravo : Alpha
+ {
+ const char* abs_method()
+ {
+ return "Bravo::abs_method()";
+ }
+ };
+
+ struct Charlie : Bravo
+ {
+ const char* abs_method()
+ {
+ return "Charlie::abs_method()";
+ }
+ };
+
+ struct Delta : Charlie
+ {
+ };
+%}
+
+%rename(OpInt) operator int();
+%rename(OpIntStarStarConst) operator int **() const;
+%rename(OpIntAmp) operator int &();
+%rename(OpIntStar) operator void *();
+%rename(OpConstIntIntStar) operator const int *();
+
+%inline %{
+ class Ops {
+ public:
+ Ops() : num(0) {}
+ virtual ~Ops() {}
+ virtual operator int() { return 0; }
+ virtual operator int **() const {
+ return (int **) 0;
+ }
+ virtual operator int &() {
+ return num;
+ }
+ virtual operator void *() {
+ return (void *) this;
+ }
+ virtual operator const int *() {
+ return &num;
+ }
+ private:
+ int num;
+ };
+
+ struct Prims {
+ virtual ~Prims() {}
+ virtual unsigned long long ull(unsigned long long i, unsigned long long j) { return i + j; }
+ unsigned long long callull(int i, int j) { return ull(i, j); }
+ };
+%}
+
+
+// The similarity of the director class name and other symbol names were causing a problem in the code generation
+%feature("director") coreCallbacks;
+
+%inline %{
+class corePoint3d {};
+
+struct coreCallbacks_On3dEngineRedrawnData
+{
+ corePoint3d _eye;
+ corePoint3d _at;
+};
+
+struct coreCallbacksOn3dEngineRedrawnData
+{
+ corePoint3d _eye;
+ corePoint3d _at;
+};
+
+class coreCallbacks
+{
+public:
+ coreCallbacks(void) {}
+ virtual ~coreCallbacks(void) {}
+
+ virtual void On3dEngineRedrawn(const coreCallbacks_On3dEngineRedrawnData& data){}
+ virtual void On3dEngineRedrawn2(const coreCallbacksOn3dEngineRedrawnData& data){}
+};
+%}
+
diff --git a/trunk/Examples/test-suite/director_ignore.i b/trunk/Examples/test-suite/director_ignore.i
new file mode 100644
index 000000000..51317fbe0
--- /dev/null
+++ b/trunk/Examples/test-suite/director_ignore.i
@@ -0,0 +1,96 @@
+%module(directors="1") director_ignore
+
+%warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) DIgnoreOnlyConstructor;
+
+%include "std_string.i"
+
+%feature("director");
+
+%ignore OverloadedMethod(int n, int xoffset = 0, int yoffset = 0);
+%ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0);
+%ignore DIgnoreConstructor(bool b);
+%ignore DIgnoreOnlyConstructor(bool b);
+%ignore Pointers;
+%ignore References;
+%ignore PublicMethod1;
+%ignore PublicMethod2;
+%ignore PublicPureVirtualMethod1;
+%ignore PublicPureVirtualMethod2;
+%ignore ProtectedMethod1;
+%ignore ProtectedMethod2;
+%ignore ProtectedPureVirtualMethod1;
+%ignore ProtectedPureVirtualMethod2;
+
+%inline %{
+
+#include <string>
+class DIgnores
+{
+ public:
+ virtual ~DIgnores() {}
+ virtual void OverloadedMethod(int n, int xoffset = 0, int yoffset = 0) {}
+ virtual void OverloadedMethod(bool b) {}
+ virtual int Triple(int n) { return n*3; }
+ virtual int& References(int& n) { static int nn; nn=n; return nn; }
+ virtual int* Pointers(int* n) { static int nn; nn=*n; return &nn; }
+ virtual double PublicMethod1() { return 0.0; }
+ virtual double PublicPureVirtualMethod1() = 0;
+ virtual void PublicMethod2() {}
+ virtual void PublicPureVirtualMethod2() = 0;
+ virtual void TempMethod() = 0;
+ protected:
+ virtual void OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0) {}
+ virtual void OverloadedProtectedMethod() {}
+ virtual double ProtectedMethod1() { return 0.0; }
+ virtual double ProtectedPureVirtualMethod1() = 0;
+ virtual void ProtectedMethod2() {}
+ virtual void ProtectedPureVirtualMethod2() = 0;
+};
+
+class DAbstractIgnores
+{
+ public:
+ virtual ~DAbstractIgnores() {}
+ virtual double OverloadedMethod(int n, int xoffset = 0, int yoffset = 0) = 0;
+ virtual double OverloadedMethod(bool b) = 0;
+ virtual int Quadruple(int n) { return n*4; }
+ virtual int& References(int& n) { static int nn; nn=n; return nn; }
+ virtual int* Pointers(int* n) { static int nn; nn=*n; return &nn; }
+ protected:
+ virtual double OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0) = 0;
+ virtual double OverloadedProtectedMethod() = 0;
+};
+
+class DIgnoreConstructor
+{
+ public:
+ virtual ~DIgnoreConstructor() {}
+ DIgnoreConstructor(std::string s, int i) {}
+ DIgnoreConstructor(bool b) {}
+};
+
+class DIgnoreOnlyConstructor
+{
+ public:
+ virtual ~DIgnoreOnlyConstructor() {}
+ DIgnoreOnlyConstructor(bool b) {}
+};
+
+template <typename T> class DTemplateAbstractIgnores
+{
+ T t;
+ public:
+ virtual ~DTemplateAbstractIgnores() {}
+ virtual double OverloadedMethod(int n, int xoffset = 0, int yoffset = 0) = 0;
+ virtual double OverloadedMethod(bool b) = 0;
+ virtual int Quadruple(int n) { return n*4; }
+ virtual int& References(int& n) { static int nn; nn=n; return nn; }
+ virtual int* Pointers(int* n) { static int nn; nn=*n; return &nn; }
+ protected:
+ virtual double OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0) = 0;
+ virtual double OverloadedProtectedMethod() = 0;
+};
+%}
+
+%template(DTemplateAbstractIgnoresInt) DTemplateAbstractIgnores<int>;
+
diff --git a/trunk/Examples/test-suite/director_namespace_clash.i b/trunk/Examples/test-suite/director_namespace_clash.i
new file mode 100644
index 000000000..5525159ba
--- /dev/null
+++ b/trunk/Examples/test-suite/director_namespace_clash.i
@@ -0,0 +1,21 @@
+%module(directors="1") director_namespace_clash
+
+%rename(GreatOne) One::Great;
+
+%feature("director");
+
+%inline %{
+namespace One {
+ struct Great {
+ virtual void superb(int a) {}
+ virtual ~Great() {}
+ };
+}
+namespace Two {
+ struct Great {
+ virtual void excellent() {}
+ virtual ~Great() {}
+ };
+}
+%}
+
diff --git a/trunk/Examples/test-suite/director_nested.i b/trunk/Examples/test-suite/director_nested.i
new file mode 100644
index 000000000..c1b4d2986
--- /dev/null
+++ b/trunk/Examples/test-suite/director_nested.i
@@ -0,0 +1,86 @@
+%module(directors="1",dirprot="1") director_nested
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%{
+#include <string>
+#include <iostream>
+%}
+
+%include "std_string.i"
+
+%feature("director") Bar;
+%feature("director") Foo<int>;
+%feature("director") FooBar<int>;
+
+%newobject *::create();
+
+%inline {
+ template <class C>
+ class Foo {
+ public:
+ virtual ~Foo() {}
+
+ std::string advance()
+ {
+ return "Foo::advance;" + do_advance();
+ }
+
+ protected:
+ virtual std::string do_advance() = 0;
+ };
+}
+
+%template(Foo_int) Foo<int>;
+
+%inline {
+
+ class Bar : public Foo<int>
+ {
+ public:
+
+ std::string step()
+ {
+ return "Bar::step;" + advance();
+ }
+
+ protected:
+ std::string do_advance()
+ {
+ return "Bar::do_advance;" + do_step();
+ }
+
+
+#if defined(SWIGPYTHON) || defined(SWIGRUBY) || \
+ defined(SWIGJAVA) || defined(SWIGOCAML) || defined(SWIGCSHARP)
+ virtual std::string do_step() const = 0;
+#else
+ virtual std::string do_step() const {return "";};
+#endif
+ };
+
+ template <class C>
+ class FooBar : public Bar
+ {
+ public:
+ virtual C get_value() const = 0;
+
+ virtual const char * get_name()
+ {
+ return "FooBar::get_name";
+ }
+
+ const char *name()
+ {
+ return get_name();
+ }
+
+ static FooBar *get_self(FooBar *a)
+ {
+ return a;
+ }
+
+ };
+}
+
+%template(FooBar_int) FooBar<int>;
+
diff --git a/trunk/Examples/test-suite/director_overload.i b/trunk/Examples/test-suite/director_overload.i
new file mode 100644
index 000000000..55bdf2caa
--- /dev/null
+++ b/trunk/Examples/test-suite/director_overload.i
@@ -0,0 +1,47 @@
+%module(directors="1") director_overload
+
+%feature("director");
+
+#ifdef SWIGPYTHON
+%feature("director:except") {
+ if ($error != NULL) {
+ throw Swig::DirectorMethodException();
+ }
+}
+#endif
+
+#ifdef SWIGRUBY
+// Catch ruby exceptions in directors
+%feature("director:except") {
+ throw Swig::DirectorMethodException($error);
+}
+#endif
+
+%inline %{
+
+class OverloadedClass
+{
+public:
+ virtual ~OverloadedClass() {}
+ virtual void method1() const {}
+ virtual void method2() const {}
+ virtual void method3() const {}
+ // test overloaded method, but not directly after the first method
+ virtual void method2(bool b) const {}
+};
+
+class OverloadedPointers
+{
+public:
+ virtual ~OverloadedPointers() {}
+ virtual void method(int *p) const {}
+ virtual void method(double *p) const {}
+ virtual void method(bool &r) const {}
+ virtual void method(short &r) const {}
+ virtual void method(OverloadedClass *p) const {}
+ virtual void method(OverloadedPointers *p) const {}
+ virtual void notover(int *p) const {}
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/director_primitives.i b/trunk/Examples/test-suite/director_primitives.i
new file mode 100644
index 000000000..0842bd200
--- /dev/null
+++ b/trunk/Examples/test-suite/director_primitives.i
@@ -0,0 +1,88 @@
+// Tests primitives
+// Note: C# module has a large runtime test
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%module(directors="1") director_primitives
+
+%feature("director") Base;
+%feature("director") Derived;
+
+%include "std_string.i"
+
+%inline %{
+#include <cstdio>
+#include <iostream>
+
+
+// Use for debugging
+bool PrintDebug = false;
+
+enum HShadowMode
+{
+ HShadowNone = 1,
+ HShadowSoft = 2,
+ HShadowHard = 3
+};
+
+class Base {
+protected:
+ double m_dd;
+public:
+
+ Base(double dd) : m_dd(dd) {}
+ virtual ~Base() {}
+
+ virtual void NoParmsMethod() { if (PrintDebug) std::cout << "Base - NoParmsMethod()" << std::endl; }
+ virtual bool BoolMethod(bool x) { if (PrintDebug) std::cout << "Base - BoolMethod(" << x << ")" << std::endl; return x; }
+ virtual int IntMethod(int x) { if (PrintDebug) std::cout << "Base - IntMethod(" << x << ")" << std::endl; return x; }
+ virtual unsigned int UIntMethod(unsigned int x) { if (PrintDebug) std::cout << "Base - UIntMethod(" << x << ")" << std::endl; return x; }
+ virtual float FloatMethod(float x) { if (PrintDebug) std::cout << "Base - FloatMethod(" << x << ")" << std::endl; return x; }
+ virtual char * CharPtrMethod(char * x) { if (PrintDebug) std::cout << "Base - CharPtrMethod(" << x << ")" << std::endl; return x; }
+ virtual const char * ConstCharPtrMethod(const char * x) { if (PrintDebug) std::cout << "Base - ConstCharPtrMethod(" << x << ")" << std::endl; return x; }
+ virtual HShadowMode EnumMethod(HShadowMode x) { if (PrintDebug) std::cout << "Base - EnumMethod(" << x << ")" << std::endl; return x; }
+ virtual void ManyParmsMethod(bool b, int i, unsigned int u, float f, char * c, const char * cc, HShadowMode h) { if (PrintDebug) std::cout << "Base - ManyParmsMethod(" << b << ", " << i << ", " << u << ", " << f << ", " << c << ", " << cc << ", " << h << ")" << std::endl; }
+ virtual void NotOverriddenMethod() { if (PrintDebug) std::cout << "Base - NotOverriddenMethod()" << std::endl; }
+};
+
+class Derived : public Base {
+public:
+ Derived(double dd) : Base(dd) {}
+ virtual ~Derived() {}
+
+ virtual void NoParmsMethod() { if (PrintDebug) std::cout << "Derived - NoParmsMethod()" << std::endl; }
+ virtual bool BoolMethod(bool x) { if (PrintDebug) std::cout << "Derived - BoolMethod(" << x << ")" << std::endl; return x; }
+ virtual int IntMethod(int x) { if (PrintDebug) std::cout << "Derived - IntMethod(" << x << ")" << std::endl; return x; }
+ virtual unsigned int UIntMethod(unsigned int x) { if (PrintDebug) std::cout << "Derived - UIntMethod(" << x << ")" << std::endl; return x; }
+ virtual float FloatMethod(float x) { if (PrintDebug) std::cout << "Derived - FloatMethod(" << x << ")" << std::endl; return x; }
+ virtual char * CharPtrMethod(char * x) { if (PrintDebug) std::cout << "Derived - CharPtrMethod(" << x << ")" << std::endl; return x; }
+ virtual const char * ConstCharPtrMethod(const char * x) { if (PrintDebug) std::cout << "Derived - ConstCharPtrMethod(" << x << ")" << std::endl; return x; }
+ virtual HShadowMode EnumMethod(HShadowMode x) { if (PrintDebug) std::cout << "Derived - EnumMethod(" << x << ")" << std::endl; return x; }
+ virtual void ManyParmsMethod(bool b, int i, unsigned int u, float f, char * c, const char * cc, HShadowMode h) { if (PrintDebug) std::cout << "Derived - ManyParmsMethod(" << b << ", " << i << ", " << u << ", " << f << ", " << c << ", " << cc << ", " << h << ")" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Base *m_base;
+ void delBase() { delete m_base; m_base = 0; }
+public:
+ Caller(): m_base(0) {}
+ virtual ~Caller() { delBase(); }
+ void set(Base *b) { delBase(); m_base = b; }
+ void reset() { m_base = 0; }
+
+ void NoParmsMethodCall() { m_base->NoParmsMethod(); }
+ bool BoolMethodCall(bool x) { return m_base->BoolMethod(x); }
+ int IntMethodCall(int x) { return m_base->IntMethod(x); }
+ unsigned int UIntMethodCall(unsigned int x) { return m_base->UIntMethod(x); }
+ float FloatMethodCall(float x) { return m_base->FloatMethod(x); }
+ char * CharPtrMethodCall(char * x) { return m_base->CharPtrMethod(x); }
+ const char * ConstCharPtrMethodCall(const char * x) { return m_base->ConstCharPtrMethod(x); }
+ HShadowMode EnumMethodCall(HShadowMode x) { return m_base->EnumMethod(x); }
+ virtual void ManyParmsMethodCall(bool b, int i, unsigned int u, float f, char * c, const char * cc, HShadowMode h) { return m_base->ManyParmsMethod(b, i, u, f, c, cc, h); }
+ virtual void NotOverriddenMethodCall() { m_base->NotOverriddenMethod(); }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/director_profile.i b/trunk/Examples/test-suite/director_profile.i
new file mode 100644
index 000000000..25ed895b5
--- /dev/null
+++ b/trunk/Examples/test-suite/director_profile.i
@@ -0,0 +1,64 @@
+%module(directors="1") director_profile
+
+%include std_string.i
+
+%feature("director") B;
+
+
+%inline %{
+
+ class A {
+ public:
+ A() {}
+ };
+
+ class B
+ {
+ A aa;
+ public:
+ B() {}
+
+ virtual A fn(const A* a) {
+ return *a;
+ }
+
+ virtual int vfi(int a) {
+ return a + 1;
+ }
+
+ int fi(int a) {
+ return vfi(a);
+ }
+
+ int fj(const A* a) {
+ return 10;
+ }
+
+ B* fk(int i) {
+ return this;
+ }
+
+ const char* fl(int i) {
+ return "hello";
+ }
+
+ virtual ~B()
+ {
+ }
+
+ static B* get_self(B *b)
+ {
+ return b;
+ }
+
+ virtual std::string vfs(const std::string& a) {
+ return a;
+ }
+
+ std::string fs(const std::string& a) {
+ return vfs(a);
+ }
+
+ };
+
+%}
diff --git a/trunk/Examples/test-suite/director_protected.i b/trunk/Examples/test-suite/director_protected.i
new file mode 100644
index 000000000..fee45b4a6
--- /dev/null
+++ b/trunk/Examples/test-suite/director_protected.i
@@ -0,0 +1,148 @@
+%module(directors="1",dirprot="1") director_protected
+%{
+#include <string>
+#include <iostream>
+%}
+
+%include "std_string.i"
+
+%feature("director") Foo;
+%feature("director") Bar;
+
+%newobject *::create();
+
+#ifdef SWIGPHP
+// TODO: Currently we do not track the dynamic type of returned objects
+// in PHP, so we need the factory helper.
+%include factory.i
+%factory(Foo *Bar::create, Bar);
+#endif
+
+%rename(a) Bar::hello;
+%rename(s) Foo::p;
+%rename(q) Foo::r;
+
+%inline {
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual std::string pong() {
+ return "Foo::pong();" + ping();
+ }
+
+ int p(){ return 1;}
+ int r(){ return 1;}
+
+
+protected:
+
+ typedef int q();
+ static int s();
+
+ Foo() {}
+
+ virtual std::string ping() = 0;
+
+ virtual std::string pang()
+ {
+ return "Foo::pang();";
+ }
+
+ void hellom() {}
+
+ virtual std::string used() {
+ return pang() + pong();
+ }
+};
+
+class Bar : public Foo
+{
+public:
+ Foo* create()
+ {
+ return new Bar();
+ }
+
+ std::string pong() {
+ return "Bar::pong();" + Foo::pong();
+ }
+
+ int hello;
+
+ using Foo::used;
+
+protected:
+ std::string ping() {
+ return "Bar::ping();";
+ };
+
+ enum Hello {hola, chao};
+
+ static int a;
+ static const int b;
+
+ int hi;
+ void him() {}
+
+private:
+ int c;
+
+};
+
+
+class PrivateFoo : private Foo
+{
+};
+
+}
+
+
+%director A;
+%director B;
+
+%inline %{
+ class A {
+ public:
+ A() {};
+ virtual ~A() {};
+ protected:
+ virtual void draw() {};
+ };
+
+ class B : public A {
+ public:
+ B() {};
+ virtual ~B() {};
+ protected:
+ void draw() {};
+ void draw(int arg1) {};
+ };
+
+%}
+
+
+%cleardirector;
+
+%inline %{
+ class AA {
+ public:
+ AA() {};
+ virtual ~AA() {};
+ protected:
+ virtual void draw() {};
+ virtual void plot() {};
+ };
+
+ class BB : public AA {
+ public:
+ BB() {};
+ virtual ~BB() {};
+ protected:
+ void draw() {};
+ void draw(int arg1) {};
+
+ void plot(int arg1) {};
+ void plot() {};
+ };
+%}
+
diff --git a/trunk/Examples/test-suite/director_protected_overloaded.i b/trunk/Examples/test-suite/director_protected_overloaded.i
new file mode 100644
index 000000000..a9f786fc7
--- /dev/null
+++ b/trunk/Examples/test-suite/director_protected_overloaded.i
@@ -0,0 +1,21 @@
+%module(directors="1",dirprot="1") director_protected_overloaded
+
+%director IDataObserver;
+%director DerivedDataObserver;
+
+// protected overloaded methods
+%inline %{
+ class IDataObserver
+ {
+ public:
+ virtual ~IDataObserver(){}
+
+ protected:
+ virtual void notoverloaded() = 0;
+ virtual void isoverloaded() = 0;
+ virtual void isoverloaded(int i) = 0;
+ virtual void isoverloaded(int i, double d) = 0;
+ };
+ class DerivedDataObserver : public IDataObserver {
+ };
+%}
diff --git a/trunk/Examples/test-suite/director_redefined.i b/trunk/Examples/test-suite/director_redefined.i
new file mode 100644
index 000000000..60da4a132
--- /dev/null
+++ b/trunk/Examples/test-suite/director_redefined.i
@@ -0,0 +1,50 @@
+%module(directors="1") director_redefined
+
+ /*
+ This example generates two 'get_val' virtual members in the
+ director, and since they are equivalent, the compilation fails.
+ */
+
+%feature("director") B;
+
+%inline
+{
+ typedef int Int;
+
+ struct A
+ {
+ virtual ~A()
+ {
+ }
+
+ virtual int get_val(Int a)
+ {
+ return 0;
+ }
+
+ virtual int get_rval(const Int& a)
+ {
+ return 0;
+ }
+
+ };
+
+ struct B : A
+ {
+ int get_val(int a)
+ {
+ return 1;
+ }
+
+ int get_rval(const int& a)
+ {
+ return 1;
+ }
+
+ const int& get_rrval(const int& a)
+ {
+ return a;
+ }
+ };
+}
+
diff --git a/trunk/Examples/test-suite/director_stl.i b/trunk/Examples/test-suite/director_stl.i
new file mode 100644
index 000000000..46946e513
--- /dev/null
+++ b/trunk/Examples/test-suite/director_stl.i
@@ -0,0 +1,80 @@
+%module(directors="1") director_stl
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%include "std_string.i"
+%include "std_pair.i"
+%include "std_vector.i"
+
+#ifndef SWIG_STD_DEFAULT_INSTANTIATION
+%template() std::vector<double>;
+%template() std::vector<int>;
+%template() std::vector<std::string>;
+%template() std::pair<std::string, int>;
+%template() std::pair<int,double>;
+%template() std::pair<double,int>;
+#endif
+
+%feature("director") Foo;
+
+%feature("director:except") {
+#ifndef SWIGPHP
+ if ($error != NULL) {
+#else
+ if ($error == FAILURE) {
+#endif
+ throw Swig::DirectorMethodException();
+ }
+}
+
+%exception {
+ try { $action }
+ catch (...) { SWIG_fail; }
+}
+
+%inline
+{
+class Foo {
+public:
+ virtual ~Foo() {}
+
+ virtual std::string& bar(std::string& s)
+ {
+ return s;
+ }
+
+
+ virtual std::string ping(std::string s) = 0;
+ virtual std::string pong(const std::string& s)
+ { return std::string("Foo::pong:") + s + ":" + ping(s); }
+
+ std::string tping(std::string s) { return ping(s); }
+ std::string tpong(const std::string& s) { return pong(s); }
+
+ virtual std::pair<double, int>
+ pident(const std::pair<double, int>& p) { return p; }
+
+ virtual std::vector<int>
+ vident(const std::vector<int>& p) { return p; }
+
+ virtual std::vector<int>
+ vsecond(const std::vector<int>& p, const std::vector<int>& s) { return s; }
+
+ std::pair<double, int>
+ tpident(const std::pair<double, int>& p) { return pident(p); }
+
+ std::vector<int>
+ tvident(const std::vector<int>& p) { return vident(p); }
+
+ virtual std::vector<int>
+ tvsecond(const std::vector<int>& p, const std::vector<int>& s) { return vsecond(p,s); }
+
+
+ virtual std::vector<std::string>
+ vidents(const std::vector<std::string>& p) { return p; }
+
+ std::vector<std::string>
+ tvidents(const std::vector<std::string>& p) { return vidents(p); }
+
+};
+
+}
diff --git a/trunk/Examples/test-suite/director_string.i b/trunk/Examples/test-suite/director_string.i
new file mode 100644
index 000000000..8dfbe03c1
--- /dev/null
+++ b/trunk/Examples/test-suite/director_string.i
@@ -0,0 +1,58 @@
+%module(directors="1") director_string;
+%include <stl.i>
+
+#ifndef SWIG_STL_UNIMPL
+
+%include std_vector.i
+%include std_string.i
+
+// Using thread unsafe wrapping
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) A;
+
+%{
+#include <vector>
+#include <string>
+%}
+
+%feature("director") A;
+%inline %{
+
+struct A
+{
+ A(const std::string& first)
+ : m_strings(1, first)
+ {}
+
+ virtual ~A() {}
+
+ virtual const std::string& get_first() const
+ { return get(0); }
+
+ virtual const std::string& get(int n) const
+ { return m_strings[n]; }
+
+ virtual const std::string& call_get_first() const
+ { return get_first(); }
+
+ virtual const std::string& call_get(int n) const
+ { return get(n); }
+
+ virtual int string_length(const std::string & s) const
+ { return (int)s.size(); }
+
+ std::vector<std::string> m_strings;
+
+
+ virtual void process_text(const char *text)
+ {
+ }
+
+ void call_process_func() { process_text("hello"); }
+ };
+
+ %}
+
+%template(StringVector) std::vector<std::string>;
+
+
+#endif
diff --git a/trunk/Examples/test-suite/director_thread.i b/trunk/Examples/test-suite/director_thread.i
new file mode 100644
index 000000000..2732eb907
--- /dev/null
+++ b/trunk/Examples/test-suite/director_thread.i
@@ -0,0 +1,102 @@
+// This testcase was in the python subdirectory
+
+#if defined(SWIGPYTHON)
+// Is "threads" really needed for Python? It seems to work without it.
+%module(directors="1",threads="1") director_thread
+#else
+%module(directors="1") director_thread
+#endif
+
+%{
+#ifdef _WIN32
+#include <windows.h>
+#include <process.h>
+#else
+#include <pthread.h>
+#include <signal.h>
+#include <unistd.h>
+#endif
+
+#include <iostream>
+
+class Foo;
+extern "C" {
+#ifdef _WIN32
+ unsigned int __stdcall working(void* t);
+ unsigned int thread_id(0);
+#else
+ void* working(void* t);
+ pthread_t thread;
+#endif
+ static int thread_terminate = 0;
+
+}
+%}
+
+%director Foo;
+
+%inline {
+ static void MilliSecondSleep(int milliseconds) {
+ %#ifdef _WIN32
+ Sleep(milliseconds);
+ %#else
+ usleep(milliseconds*1000);
+ %#endif
+ }
+
+ class Foo {
+ public:
+ int val;
+
+ Foo() : val(0) {
+ }
+
+ virtual ~Foo() {
+ }
+
+ void stop() {
+ thread_terminate = 1;
+ %#ifdef _WIN32
+ /*TODO(bhy) what to do for win32? */
+ %#else
+ pthread_join(thread, NULL);
+ %#endif
+ }
+
+ void run() {
+%#ifdef _WIN32
+ _beginthreadex(NULL,0,working,this,0,&thread_id);
+%#else
+ pthread_create(&thread,NULL,working,this);
+%#endif
+ MilliSecondSleep(500);
+ }
+
+ virtual void do_foo() {
+ val += 1;
+ }
+ };
+}
+
+%{
+extern "C" {
+#ifdef _WIN32
+ unsigned int __stdcall working(void* t)
+#else
+ void* working(void* t)
+#endif
+ {
+ Foo* f = static_cast<Foo*>(t);
+ while ( ! thread_terminate ) {
+ MilliSecondSleep(50);
+ f->do_foo();
+ }
+#ifdef _WIN32
+ /* TODO(bhy) what's the corresponding of pthread_exit in win32? */
+#else
+ pthread_exit(0);
+#endif
+ return 0;
+ }
+}
+%}
diff --git a/trunk/Examples/test-suite/director_unroll.i b/trunk/Examples/test-suite/director_unroll.i
new file mode 100644
index 000000000..6a11c3a90
--- /dev/null
+++ b/trunk/Examples/test-suite/director_unroll.i
@@ -0,0 +1,40 @@
+%module(directors="1") director_unroll
+%{
+#include <string>
+
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual std::string ping() { return "Foo::ping()"; }
+ virtual std::string pong() { return "Foo::pong();" + ping(); }
+};
+
+class Bar {
+private:
+ Foo *foo;
+public:
+ void set(Foo *x) { foo = x; }
+ Foo *get() { return foo; }
+};
+
+%}
+
+%include "std_string.i"
+
+%feature("director") Foo;
+
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual std::string ping() { return "Foo::ping()"; }
+ virtual std::string pong() { return "Foo::pong();" + ping(); }
+};
+
+class Bar {
+private:
+ Foo *foo;
+public:
+ void set(Foo *x) { foo = x; }
+ Foo *get() { return foo; }
+};
+
diff --git a/trunk/Examples/test-suite/director_using.i b/trunk/Examples/test-suite/director_using.i
new file mode 100644
index 000000000..9001ffbb9
--- /dev/null
+++ b/trunk/Examples/test-suite/director_using.i
@@ -0,0 +1,67 @@
+%module(directors="1",dirprot="1") director_using
+
+%warnfilter(SWIGWARN_PHP_PUBLIC_BASE) FooBar;
+
+%{
+#include <string>
+#include <iostream>
+%}
+
+%include "std_string.i"
+
+%feature("director");
+
+%newobject *::create();
+
+%inline {
+ template <class C>
+ class Foo {
+ public:
+ virtual ~Foo() {}
+
+ std::string advance()
+ {
+ return "Foo::advance;" + do_advance();
+ }
+
+ protected:
+ virtual std::string do_advance() = 0;
+ virtual std::string do_step() const = 0;
+ };
+}
+
+%template(Foo_int) Foo<int>;
+
+%inline {
+
+ class Bar : public Foo<int>
+ {
+ public:
+
+ std::string step()
+ {
+ return "Bar::step;" + advance();
+ }
+
+
+ using Foo<int>::do_step;
+ protected:
+ std::string do_advance()
+ {
+ return "Bar::do_advance;" + do_step();
+ }
+
+ };
+
+ template <class C>
+ class FooBar : public Bar
+ {
+ public:
+ virtual C get_value() const = 0;
+ using Bar::do_advance;
+
+ };
+}
+
+%template(FooBar_int) FooBar<int>;
+
diff --git a/trunk/Examples/test-suite/director_wombat.i b/trunk/Examples/test-suite/director_wombat.i
new file mode 100644
index 000000000..ab798ba09
--- /dev/null
+++ b/trunk/Examples/test-suite/director_wombat.i
@@ -0,0 +1,49 @@
+%module(directors="1") director_wombat
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+
+%feature(director) Bar;
+%feature(director) Foo<int>;
+
+%inline %{
+template<typename T> class Foo
+{
+public:
+ Foo()
+ { /* NOP */ }
+ virtual ~Foo()
+ { /* NOP */ }
+ virtual int meth(T param)
+ { return param; }
+};
+
+typedef Foo<int> Foo_int;
+
+class Bar
+{
+public:
+ virtual ~Bar();
+ virtual Foo_int *meth();
+ virtual void foo_meth_ref(Foo_int &, int);
+ virtual void foo_meth_ptr(Foo_int *, int);
+ virtual void foo_meth_val(Foo_int, int);
+ virtual void foo_meth_cref(const Foo_int &, int);
+ virtual void foo_meth_cptr(const Foo_int *, int);
+};
+
+Bar::~Bar()
+{ /* NOP */ }
+
+Foo_int *
+Bar::meth()
+{
+ return new Foo_int();
+}
+
+void Bar::foo_meth_ref(Foo_int &arg, int param) { }
+void Bar::foo_meth_ptr(Foo_int *arg, int param) { }
+void Bar::foo_meth_val(Foo_int arg, int param) { }
+void Bar::foo_meth_cref(const Foo_int &arg, int param) { }
+void Bar::foo_meth_cptr(const Foo_int *arg, int param) { }
+%}
+
+%template(Foo_integers) Foo<int>;
diff --git a/trunk/Examples/test-suite/director_wstring.i b/trunk/Examples/test-suite/director_wstring.i
new file mode 100644
index 000000000..17761ea59
--- /dev/null
+++ b/trunk/Examples/test-suite/director_wstring.i
@@ -0,0 +1,60 @@
+%module(directors="1") director_wstring;
+%include <stl.i>
+
+#ifndef SWIG_STL_UNIMPL
+
+%include std_vector.i
+%include std_wstring.i
+
+// Using thread unsafe wrapping
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) A;
+
+%{
+#include <vector>
+#include <string>
+%}
+
+%feature("director") A;
+%inline %{
+
+struct A
+{
+ A(const std::wstring& first)
+ : m_strings(1, first)
+ {}
+
+ virtual ~A() {}
+
+ virtual const std::wstring& get_first() const
+ { return get(0); }
+
+ virtual const std::wstring& get(int n) const
+ { return m_strings[n]; }
+
+ virtual const std::wstring& call_get_first() const
+ { return get_first(); }
+
+ virtual const std::wstring& call_get(int n) const
+ { return get(n); }
+
+ std::vector<std::wstring> m_strings;
+
+
+ virtual void process_text(const wchar_t *text)
+ {
+ }
+
+ virtual std::wstring multiple_params_val(const std::wstring& p1, const std::wstring& p2, std::wstring p3, std::wstring p4) const
+ { return get_first(); }
+
+ virtual const std::wstring& multiple_params_ref(const std::wstring& p1, const std::wstring& p2, std::wstring p3, std::wstring p4) const
+ { return get_first(); }
+
+ void call_process_func() { process_text(L"hello"); }
+ };
+
+ %}
+
+%template(StringVector) std::vector<std::wstring>;
+
+#endif
diff --git a/trunk/Examples/test-suite/disown.i b/trunk/Examples/test-suite/disown.i
new file mode 100644
index 000000000..8b3aeb0ec
--- /dev/null
+++ b/trunk/Examples/test-suite/disown.i
@@ -0,0 +1,47 @@
+%module disown
+
+%{
+#include <iostream>
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_APPLY_UNDEF
+
+%apply SWIGTYPE *DISOWN { A *disown };
+
+%inline {
+ struct A
+ {
+ ~A()
+ {
+ // std::cout <<"delete A" << std::endl;
+ }
+
+
+ };
+
+ class B
+ {
+ A *_a;
+ public:
+ B() : _a(0)
+ {
+ }
+
+ ~B()
+ {
+ if (_a) {
+ // std::cout <<"delete A from B" << std::endl;
+ delete _a;
+ }
+ // std::cout <<"delete B" << std::endl;
+ }
+
+ int acquire(A *disown)
+ {
+ // std::cout <<"acquire A" << std::endl;
+ _a = disown;
+ return 5;
+ }
+
+ };
+}
diff --git a/trunk/Examples/test-suite/dynamic_cast.i b/trunk/Examples/test-suite/dynamic_cast.i
new file mode 100644
index 000000000..5d4fbb0b6
--- /dev/null
+++ b/trunk/Examples/test-suite/dynamic_cast.i
@@ -0,0 +1,76 @@
+/* File : example.i */
+%module dynamic_cast
+
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
+%apply SWIGTYPE *DYNAMIC { Foo * };
+#endif
+
+%inline %{
+
+class Foo {
+public:
+ virtual ~Foo() { }
+
+ virtual Foo *blah() {
+ return this;
+ }
+};
+%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%typemap(out) Foo *blah {
+ Bar *downcast = dynamic_cast<Bar *>($1);
+ *(Bar **)&$result = downcast;
+}
+#endif
+
+#if defined(SWIGJAVA)
+%typemap(javaout) Foo * {
+ return new Bar($jnicall, $owner);
+ }
+#endif
+
+#if defined(SWIGCSHARP)
+%typemap(csout, excode=SWIGEXCODE) Foo * {
+ Bar ret = new Bar($imcall, $owner);$excode
+ return ret;
+ }
+#endif
+
+%inline %{
+
+class Bar : public Foo {
+public:
+ virtual Foo *blah() {
+ return (Foo *) this;
+ }
+ virtual char * test() {
+ return (char *) "Bar::test";
+ }
+};
+
+char *do_test(Bar *b) {
+ return b->test();
+}
+%}
+
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
+// 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/trunk/Examples/test-suite/empty.i b/trunk/Examples/test-suite/empty.i
new file mode 100644
index 000000000..a5040985a
--- /dev/null
+++ b/trunk/Examples/test-suite/empty.i
@@ -0,0 +1 @@
+%module empty
diff --git a/trunk/Examples/test-suite/enum_plus.i b/trunk/Examples/test-suite/enum_plus.i
new file mode 100644
index 000000000..74cc7fa27
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_plus.i
@@ -0,0 +1,12 @@
+%module enum_plus
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) iFoo; /* Ruby, wrong constant name */
+
+%inline %{
+struct iFoo
+{
+ enum {
+ Phoo = +50
+ };
+};
+%}
diff --git a/trunk/Examples/test-suite/enum_scope_template.i b/trunk/Examples/test-suite/enum_scope_template.i
new file mode 100644
index 000000000..b6b156bd7
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/enum_template.i b/trunk/Examples/test-suite/enum_template.i
new file mode 100644
index 000000000..953a4252c
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_template.i
@@ -0,0 +1,43 @@
+%module enum_template
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) eTest0; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) eTest1; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) eTest2; /* Ruby, wrong class name */
+
+/*
+From bug report 992329:
+
+In Python I see
+
+>>> import enum_template
+>>> enum_template.MakeETest()
+'_60561408_p_ETest'
+>>> enum_template.TakeETest(0)
+Traceback (most recent call last):
+File "<stdin>", line 1, in ?
+TypeError: Expected a pointer
+
+Without the %template, things work fine: the first
+function call returns an integer, and the second
+succeeds.
+*/
+
+%inline %{
+
+enum ETest
+{
+eTest0,
+eTest1,
+eTest2
+};
+
+void TakeETest(ETest test) {}
+ETest MakeETest(void) {return eTest1;}
+
+template<class T> class CTempl
+{
+};
+
+%}
+
+%template(CTempl_ETest) CTempl<ETest>;
diff --git a/trunk/Examples/test-suite/enum_thorough.i b/trunk/Examples/test-suite/enum_thorough.i
new file mode 100644
index 000000000..974227a01
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_thorough.i
@@ -0,0 +1,553 @@
+%module "enum_thorough"
+
+// Suppress warning messages from the Ruby module for all of the
+// following...
+
+#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) red;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) blue;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) green;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::slow;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::medium;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::fast;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) SpeedClass::lightning;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) TemplateClass::einstein;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) TemplateClass::galileo;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Name::TClass::faraday;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Name::TClass::bell;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) argh;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) eek;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::whizz;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::kerboom;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::pop;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::simple1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::singlename1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) OldNameStruct::doublename1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) TreesClass::oak;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) TreesClass::fir;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) TreesClass::pine;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) curly::greasy::HairStruct::blonde;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) curly::greasy::HairStruct::ginger;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::one;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::onetrail;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::two;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::twoagain;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::twotrail;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Obscure::twotrailagain;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance2;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance3;
+
+%inline %{
+
+enum { AnonEnum1, AnonEnum2 = 100 };
+enum { ReallyAnInteger = 200 };
+//enum { AnonEnum3, AnonEnum4 } instance;
+namespace AnonSpace {
+ enum { AnonSpaceEnum1, AnonSpaceEnum2 = 300 };
+ struct AnonStruct {
+ enum { AnonStructEnum1, AnonStructEnum2 = 400 };
+ };
+}
+
+
+enum colour { red=-1, blue, green = 10 };
+colour colourTest1(colour e) { return e; }
+enum colour colourTest2(enum colour e) { return e; }
+const colour colourTest3(const colour e) { return e; }
+const enum colour colourTest4(const enum colour e) { return e; }
+
+colour myColour;
+
+struct SpeedClass {
+ enum speed { slow=10, medium=20, fast=30, lightning };
+ typedef enum speed speedtd1;
+
+ int speedTest0(int s) { return s; }
+ speed speedTest1(speed s) { return s; }
+ enum speed speedTest2(enum speed s) { return s; }
+ const speed speedTest3(const speed s) { return s; }
+ const enum speed speedTest4(const enum speed s) { return s; }
+ speedtd1 speedTest5(speedtd1 s) { return s; }
+ const speedtd1 speedTest6(const speedtd1 s) { return s; }
+ const speed & speedTest7(const speed &s) { return s; }
+ const enum speed & speedTest8(const enum speed &s) { return s; }
+
+ const colour myColour2;
+ speedtd1 mySpeedtd1;
+ SpeedClass() : myColour2(red), mySpeedtd1(slow) { }
+private:
+ SpeedClass& operator=(const SpeedClass&);
+};
+
+int speedTest0(int s) { return s; }
+SpeedClass::speed speedTest1(SpeedClass::speed s) { return s; }
+enum SpeedClass::speed speedTest2(enum SpeedClass::speed s) { return s; }
+const SpeedClass::speed speedTest3(const SpeedClass::speed s) { return s; }
+const enum SpeedClass::speed speedTest4(const enum SpeedClass::speed s) { return s; }
+const SpeedClass::speed & speedTest5(const SpeedClass::speed &s) { return s; }
+
+
+typedef enum { NamedAnon1, NamedAnon2 } namedanon;
+
+namedanon namedanonTest1(namedanon e) { return e; }
+
+typedef enum twonamestag { TwoNames1, TwoNames2, TwoNames3 = 33 } twonames;
+
+twonames twonamesTest1(twonames e) { return e; }
+twonamestag twonamesTest2(twonamestag e) { return e; }
+enum twonamestag twonamesTest3(enum twonamestag e) { return e; }
+
+struct TwoNamesStruct {
+ typedef enum twonamestag { TwoNamesStruct1, TwoNamesStruct2 } twonames;
+ twonames twonamesTest1(twonames e) { return e; }
+ twonamestag twonamesTest2(twonamestag e) { return e; }
+ enum twonamestag twonamesTest3(enum twonamestag e) { return e; }
+};
+
+namespace AnonSpace{
+ typedef enum { NamedAnonSpace1, NamedAnonSpace2 } namedanonspace;
+ namedanonspace namedanonspaceTest1(namedanonspace e) { return e; }
+ AnonSpace::namedanonspace namedanonspaceTest2(AnonSpace::namedanonspace e) { return e; }
+}
+AnonSpace::namedanonspace namedanonspaceTest3(AnonSpace::namedanonspace e) { return e; }
+using namespace AnonSpace;
+namedanonspace namedanonspaceTest4(namedanonspace e) { return e; }
+
+
+template<typename T> struct TemplateClass {
+ enum scientists { einstein, galileo = 10 };
+ typedef enum scientists scientiststd1;
+ typedef scientists scientiststd2;
+ typedef scientiststd1 scientiststd3;
+ scientists scientistsTest1(scientists e) { return e; }
+ enum scientists scientistsTest2(enum scientists e) { return e; }
+ const scientists scientistsTest3(const scientists e) { return e; }
+ const enum scientists scientistsTest4(const enum scientists e) { return e; }
+ typename TemplateClass<T>::scientists scientistsTest5(typename TemplateClass<T>::scientists e) { return e; }
+ const typename TemplateClass<T>::scientists scientistsTest6(const typename TemplateClass<T>::scientists e) { return e; }
+ enum TemplateClass<T>::scientists scientistsTest7(enum TemplateClass<T>::scientists e) { return e; }
+ const enum TemplateClass<T>::scientists scientistsTest8(const enum TemplateClass<T>::scientists e) { return e; }
+ typename TemplateClass::scientists scientistsTest9(typename TemplateClass::scientists e) { return e; }
+// enum TemplateClass::scientists scientistsTestA(enum TemplateClass::scientists e) { return e; }
+ const typename TemplateClass::scientists scientistsTestB(const typename TemplateClass::scientists e) { return e; }
+// const enum TemplateClass::scientists scientistsTestC(const enum TemplateClass::scientists e) { return e; }
+ scientiststd1 scientistsTestD(scientiststd1 e) { return e; }
+ scientiststd2 scientistsTestE(scientiststd2 e) { return e; }
+ scientiststd3 scientistsTestF(scientiststd3 e) { return e; }
+ typename TemplateClass<T>::scientiststd1 scientistsTestG(typename TemplateClass<T>::scientiststd1 e) { return e; }
+ typename TemplateClass<T>::scientiststd2 scientistsTestH(typename TemplateClass<T>::scientiststd2 e) { return e; }
+ typename TemplateClass<T>::scientiststd3 scientistsTestI(typename TemplateClass<T>::scientiststd3 e) { return e; }
+ const scientists & scientistsTestJ(const scientists &e) { return e; }
+};
+
+TemplateClass<int>::scientists scientistsTest1(TemplateClass<int>::scientists e) { return e; }
+const TemplateClass<int>::scientists scientistsTest2(const TemplateClass<int>::scientists e) { return e; }
+enum TemplateClass<int>::scientists scientistsTest3(enum TemplateClass<int>::scientists e) { return e; }
+const enum TemplateClass<int>::scientists scientistsTest4(const enum TemplateClass<int>::scientists e) { return e; }
+TemplateClass<int>::scientiststd1 scientistsTest5(TemplateClass<int>::scientiststd1 e) { return e; }
+TemplateClass<int>::scientiststd2 scientistsTest6(TemplateClass<int>::scientiststd2 e) { return e; }
+TemplateClass<int>::scientiststd3 scientistsTest7(TemplateClass<int>::scientiststd3 e) { return e; }
+const TemplateClass<int>::scientiststd3 & scientistsTest8(const TemplateClass<int>::scientiststd3 &e) { return e; }
+
+
+namespace Name {
+template<typename T> struct TClass {
+ enum scientists { faraday, bell = 20 };
+ typedef enum scientists scientiststd1;
+ typedef scientists scientiststd2;
+ typedef scientiststd1 scientiststd3;
+ scientists scientistsNameTest1(scientists e) { return e; }
+ enum scientists scientistsNameTest2(enum scientists e) { return e; }
+ const scientists scientistsNameTest3(const scientists e) { return e; }
+ const enum scientists scientistsNameTest4(const enum scientists e) { return e; }
+ typename TClass<T>::scientists scientistsNameTest5(typename TClass<T>::scientists e) { return e; }
+ const typename TClass<T>::scientists scientistsNameTest6(const typename TClass<T>::scientists e) { return e; }
+ enum TClass<T>::scientists scientistsNameTest7(enum TClass<T>::scientists e) { return e; }
+ const enum TClass<T>::scientists scientistsNameTest8(const enum TClass<T>::scientists e) { return e; }
+ typename TClass::scientists scientistsNameTest9(typename TClass::scientists e) { return e; }
+// enum TClass::scientists scientistsNameTestA(enum TClass::scientists e) { return e; }
+ const typename TClass::scientists scientistsNameTestB(const typename TClass::scientists e) { return e; }
+// const enum TClass::scientists scientistsNameTestC(const enum TClass::scientists e) { return e; }
+ scientiststd1 scientistsNameTestD(scientiststd1 e) { return e; }
+ scientiststd2 scientistsNameTestE(scientiststd2 e) { return e; }
+ scientiststd3 scientistsNameTestF(scientiststd3 e) { return e; }
+ typename TClass<T>::scientiststd1 scientistsNameTestG(typename TClass<T>::scientiststd1 e) { return e; }
+ typename TClass<T>::scientiststd2 scientistsNameTestH(typename TClass<T>::scientiststd2 e) { return e; }
+ typename TClass<T>::scientiststd3 scientistsNameTestI(typename TClass<T>::scientiststd3 e) { return e; }
+
+ typename Name::TClass<T>::scientists scientistsNameSpaceTest1(typename Name::TClass<T>::scientists e) { return e; }
+ const typename Name::TClass<T>::scientists scientistsNameSpaceTest2(const typename Name::TClass<T>::scientists e) { return e; }
+ enum Name::TClass<T>::scientists scientistsNameSpaceTest3(enum Name::TClass<T>::scientists e) { return e; }
+ const enum Name::TClass<T>::scientists scientistsNameSpaceTest4(const enum Name::TClass<T>::scientists e) { return e; }
+ typename Name::TClass<T>::scientiststd1 scientistsNameSpaceTest5(typename Name::TClass<T>::scientiststd1 e) { return e; }
+ typename Name::TClass<T>::scientiststd2 scientistsNameSpaceTest6(typename Name::TClass<T>::scientiststd2 e) { return e; }
+ typename Name::TClass<T>::scientiststd3 scientistsNameSpaceTest7(typename Name::TClass<T>::scientiststd3 e) { return e; }
+
+ // Test TemplateClass::scientists rather then TClass::scientists
+ ::TemplateClass<int>::scientists scientistsOtherTest1(::TemplateClass<int>::scientists e) { return e; }
+ const ::TemplateClass<int>::scientists scientistsOtherTest2(const ::TemplateClass<int>::scientists e) { return e; }
+ enum ::TemplateClass<int>::scientists scientistsOtherTest3(enum ::TemplateClass<int>::scientists e) { return e; }
+ const enum ::TemplateClass<int>::scientists scientistsOtherTest4(const enum ::TemplateClass<int>::scientists e) { return e; }
+ ::TemplateClass<int>::scientiststd1 scientistsOtherTest5(::TemplateClass<int>::scientiststd1 e) { return e; }
+ ::TemplateClass<int>::scientiststd2 scientistsOtherTest6(::TemplateClass<int>::scientiststd2 e) { return e; }
+ ::TemplateClass<int>::scientiststd3 scientistsOtherTest7(::TemplateClass<int>::scientiststd3 e) { return e; }
+};
+
+TClass<int>::scientists scientistsNameTest1(TClass<int>::scientists e) { return e; }
+const TClass<int>::scientists scientistsNameTest2(const TClass<int>::scientists e) { return e; }
+enum TClass<int>::scientists scientistsNameTest3(enum TClass<int>::scientists e) { return e; }
+const enum TClass<int>::scientists scientistsNameTest4(const enum TClass<int>::scientists e) { return e; }
+TClass<int>::scientiststd1 scientistsNameTest5(TClass<int>::scientiststd1 e) { return e; }
+TClass<int>::scientiststd2 scientistsNameTest6(TClass<int>::scientiststd2 e) { return e; }
+TClass<int>::scientiststd3 scientistsNameTest7(TClass<int>::scientiststd3 e) { return e; }
+
+Name::TClass<int>::scientists scientistsNameSpaceTest1(Name::TClass<int>::scientists e) { return e; }
+const Name::TClass<int>::scientists scientistsNameSpaceTest2(const Name::TClass<int>::scientists e) { return e; }
+enum Name::TClass<int>::scientists scientistsNameSpaceTest3(enum Name::TClass<int>::scientists e) { return e; }
+const enum Name::TClass<int>::scientists scientistsNameSpaceTest4(const enum Name::TClass<int>::scientists e) { return e; }
+Name::TClass<int>::scientiststd1 scientistsNameSpaceTest5(Name::TClass<int>::scientiststd1 e) { return e; }
+Name::TClass<int>::scientiststd2 scientistsNameSpaceTest6(Name::TClass<int>::scientiststd2 e) { return e; }
+Name::TClass<int>::scientiststd3 scientistsNameSpaceTest7(Name::TClass<int>::scientiststd3 e) { return e; }
+}
+
+Name::TClass<int>::scientists scientistsNameSpaceTest8(Name::TClass<int>::scientists e) { return e; }
+const Name::TClass<int>::scientists scientistsNameSpaceTest9(const Name::TClass<int>::scientists e) { return e; }
+enum Name::TClass<int>::scientists scientistsNameSpaceTestA(enum Name::TClass<int>::scientists e) { return e; }
+const enum Name::TClass<int>::scientists scientistsNameSpaceTestB(const enum Name::TClass<int>::scientists e) { return e; }
+Name::TClass<int>::scientiststd1 scientistsNameSpaceTestC(Name::TClass<int>::scientiststd1 e) { return e; }
+Name::TClass<int>::scientiststd2 scientistsNameSpaceTestD(Name::TClass<int>::scientiststd2 e) { return e; }
+Name::TClass<int>::scientiststd3 scientistsNameSpaceTestE(Name::TClass<int>::scientiststd3 e) { return e; }
+
+using namespace Name;
+TClass<int>::scientists scientistsNameSpaceTestF(TClass<int>::scientists e) { return e; }
+const TClass<int>::scientists scientistsNameSpaceTestG(const TClass<int>::scientists e) { return e; }
+enum TClass<int>::scientists scientistsNameSpaceTestH(enum TClass<int>::scientists e) { return e; }
+const enum TClass<int>::scientists scientistsNameSpaceTestI(const enum TClass<int>::scientists e) { return e; }
+TClass<int>::scientiststd1 scientistsNameSpaceTestJ(TClass<int>::scientiststd1 e) { return e; }
+TClass<int>::scientiststd2 scientistsNameSpaceTestK(TClass<int>::scientiststd2 e) { return e; }
+TClass<int>::scientiststd3 scientistsNameSpaceTestL(TClass<int>::scientiststd3 e) { return e; }
+
+%}
+
+%template(TemplateClassInt) TemplateClass<int>;
+%template(TClassInt) Name::TClass<int>;
+
+
+// %rename tests
+%rename(NewNameStruct) OldNameStruct;
+%rename(newname) old_name;
+%rename(doublenamerenamed) doublename;
+%rename(simplerenamed) simple;
+%rename(singlenamerenamed) singlename;
+%rename(bang) OldNameStruct::kerboom;
+
+%inline %{
+enum old_name { argh, eek = -1 };
+typedef old_name old_nametd;
+old_name renameTest1(old_name e) { return e; }
+old_nametd renameTest2(old_nametd e) { return e; }
+
+struct OldNameStruct {
+ enum enumeration {whizz, kerboom, pop};
+ enumeration renameTest1(enumeration e) { return e; }
+ OldNameStruct::enumeration renameTest2(OldNameStruct::enumeration e) { return e; }
+
+ enum simple {simple1};
+ typedef enum doublenametag {doublename1} doublename;
+ typedef enum {singlename1} singlename;
+
+ simple renameTest3(simple e) { return e; }
+ doublename renameTest4(doublename e) { return e; }
+ doublenametag renameTest5(doublenametag e) { return e; }
+ singlename renameTest6(singlename e) { return e; }
+};
+
+OldNameStruct::enumeration renameTest3(OldNameStruct::enumeration e) { return e; }
+OldNameStruct::simple renameTest4(OldNameStruct::simple e) { return e; }
+OldNameStruct::doublename renameTest5(OldNameStruct::doublename e) { return e; }
+OldNameStruct::doublenametag renameTest6(OldNameStruct::doublenametag e) { return e; }
+OldNameStruct::singlename renameTest7(OldNameStruct::singlename e) { return e; }
+%}
+
+%inline %{
+struct TreesClass {
+ enum trees {oak, fir, pine };
+ typedef enum trees treestd1;
+ typedef trees treestd2;
+ typedef treestd1 treestd3;
+ typedef TreesClass::trees treestd4;
+ typedef treestd1 treestd5;
+
+ trees treesTest1(trees e) { return e; }
+ treestd1 treesTest2(treestd1 e) { return e; }
+ treestd2 treesTest3(treestd2 e) { return e; }
+ treestd3 treesTest4(treestd3 e) { return e; }
+ treestd4 treesTest5(treestd4 e) { return e; }
+ treestd5 treesTest6(treestd5 e) { return e; }
+ const trees treesTest7(const trees e) { return e; }
+ const treestd1 treesTest8(const treestd1 e) { return e; }
+ const treestd2 treesTest9(const treestd2 e) { return e; }
+ const treestd3 treesTestA(const treestd3 e) { return e; }
+ const treestd4 treesTestB(const treestd4 e) { return e; }
+ const treestd5 treesTestC(const treestd5 e) { return e; }
+ TreesClass::trees treesTestD(TreesClass::trees e) { return e; }
+ TreesClass::treestd1 treesTestE(TreesClass::treestd1 e) { return e; }
+ TreesClass::treestd2 treesTestF(TreesClass::treestd2 e) { return e; }
+ TreesClass::treestd3 treesTestG(TreesClass::treestd3 e) { return e; }
+ TreesClass::treestd4 treesTestH(TreesClass::treestd4 e) { return e; }
+ TreesClass::treestd5 treesTestI(TreesClass::treestd5 e) { return e; }
+ const TreesClass::trees treesTestJ(const TreesClass::trees e) { return e; }
+ const TreesClass::treestd1 treesTestK(const TreesClass::treestd1 e) { return e; }
+ const TreesClass::treestd2 treesTestL(const TreesClass::treestd2 e) { return e; }
+ const TreesClass::treestd3 treesTestM(const TreesClass::treestd3 e) { return e; }
+ const TreesClass::treestd4 treesTestN(const TreesClass::treestd4 e) { return e; }
+ const TreesClass::treestd5 treesTestO(const TreesClass::treestd5 e) { return e; }
+};
+
+TreesClass::trees treesTest1(TreesClass::trees e) { return e; }
+TreesClass::treestd1 treesTest2(TreesClass::treestd1 e) { return e; }
+TreesClass::treestd2 treesTest3(TreesClass::treestd2 e) { return e; }
+TreesClass::treestd3 treesTest4(TreesClass::treestd3 e) { return e; }
+TreesClass::treestd4 treesTest5(TreesClass::treestd4 e) { return e; }
+TreesClass::treestd5 treesTest6(TreesClass::treestd5 e) { return e; }
+const TreesClass::trees treesTest7(const TreesClass::trees e) { return e; }
+const TreesClass::treestd1 treesTest8(const TreesClass::treestd1 e) { return e; }
+const TreesClass::treestd2 treesTest9(const TreesClass::treestd2 e) { return e; }
+const TreesClass::treestd3 treesTestA(const TreesClass::treestd3 e) { return e; }
+const TreesClass::treestd4 treesTestB(const TreesClass::treestd4 e) { return e; }
+const TreesClass::treestd5 treesTestC(const TreesClass::treestd5 e) { return e; }
+
+typedef enum TreesClass::trees treesglobaltd1;
+typedef TreesClass::trees treesglobaltd2;
+typedef TreesClass::treestd1 treesglobaltd3;
+typedef TreesClass::treestd2 treesglobaltd4;
+typedef treesglobaltd4 treesglobaltd5;
+
+treesglobaltd1 treesTestD(treesglobaltd1 e) { return e; }
+treesglobaltd2 treesTestE(treesglobaltd2 e) { return e; }
+treesglobaltd3 treesTestF(treesglobaltd3 e) { return e; }
+treesglobaltd4 treesTestG(treesglobaltd4 e) { return e; }
+treesglobaltd5 treesTestH(treesglobaltd5 e) { return e; }
+const treesglobaltd1 treesTestI(const treesglobaltd1 e) { return e; }
+const treesglobaltd2 treesTestJ(const treesglobaltd2 e) { return e; }
+const treesglobaltd3 treesTestK(const treesglobaltd3 e) { return e; }
+const treesglobaltd4 treesTestL(const treesglobaltd4 e) { return e; }
+const treesglobaltd5 treesTestM(const treesglobaltd5 e) { return e; }
+
+typedef const enum TreesClass::trees treesglobaltd6;
+typedef const TreesClass::trees treesglobaltd7;
+typedef const TreesClass::treestd1 treesglobaltd8;
+typedef const TreesClass::treestd2 treesglobaltd9;
+typedef const treesglobaltd4 treesglobaltdA;
+
+//treesglobaltd6 treesTestN(treesglobaltd6 e) { return e; } // casting using an int instead of treesglobaltd6
+treesglobaltd7 treesTestO(treesglobaltd7 e) { return e; }
+treesglobaltd8 treesTestP(treesglobaltd8 e) { return e; }
+treesglobaltd9 treesTestQ(treesglobaltd9 e) { return e; }
+treesglobaltdA treesTestR(treesglobaltdA e) { return e; }
+
+namespace curly {
+ namespace greasy {
+ struct HairStruct {
+ enum hair { blonde=0xFF0, ginger };
+ typedef hair hairtd1;
+ typedef HairStruct::hair hairtd2;
+ typedef greasy::HairStruct::hair hairtd3;
+ typedef curly::greasy::HairStruct::hair hairtd4;
+ typedef ::curly::greasy::HairStruct::hair hairtd5;
+ typedef hairtd1 hairtd6;
+ typedef HairStruct::hairtd1 hairtd7;
+ typedef greasy::HairStruct::hairtd1 hairtd8;
+ typedef curly::greasy::HairStruct::hairtd1 hairtd9;
+ typedef ::curly::greasy::HairStruct::hairtd1 hairtdA;
+ hair hairTest1(hair e) { return e; }
+ hairtd1 hairTest2(hairtd1 e) { return e; }
+ hairtd2 hairTest3(hairtd2 e) { return e; }
+ hairtd3 hairTest4(hairtd3 e) { return e; }
+ hairtd4 hairTest5(hairtd4 e) { return e; }
+ hairtd5 hairTest6(hairtd5 e) { return e; }
+ hairtd6 hairTest7(hairtd6 e) { return e; }
+ hairtd7 hairTest8(hairtd7 e) { return e; }
+ hairtd8 hairTest9(hairtd8 e) { return e; }
+ hairtd9 hairTestA(hairtd9 e) { return e; }
+ hairtdA hairTestB(hairtdA e) { return e; }
+
+ ::colour colourTest1(::colour e) { return e; }
+ enum colour colourTest2(enum colour e) { return e; }
+ namedanon namedanonTest1(namedanon e) { return e; }
+ AnonSpace::namedanonspace namedanonspaceTest1(AnonSpace::namedanonspace e) { return e; }
+
+ treesglobaltd1 treesGlobalTest1(treesglobaltd1 e) { return e; }
+ treesglobaltd2 treesGlobalTest2(treesglobaltd2 e) { return e; }
+ treesglobaltd3 treesGlobalTest3(treesglobaltd3 e) { return e; }
+ treesglobaltd4 treesGlobalTest4(treesglobaltd4 e) { return e; }
+ treesglobaltd5 treesGlobalTest5(treesglobaltd5 e) { return e; }
+
+ };
+ HairStruct::hair hairTest1(HairStruct::hair e) { return e; }
+ HairStruct::hairtd1 hairTest2(HairStruct::hairtd1 e) { return e; }
+ HairStruct::hairtd2 hairTest3(HairStruct::hairtd2 e) { return e; }
+ HairStruct::hairtd3 hairTest4(HairStruct::hairtd3 e) { return e; }
+ HairStruct::hairtd4 hairTest5(HairStruct::hairtd4 e) { return e; }
+ HairStruct::hairtd5 hairTest6(HairStruct::hairtd5 e) { return e; }
+ HairStruct::hairtd6 hairTest7(HairStruct::hairtd6 e) { return e; }
+ HairStruct::hairtd7 hairTest8(HairStruct::hairtd7 e) { return e; }
+ HairStruct::hairtd8 hairTest9(HairStruct::hairtd8 e) { return e; }
+ HairStruct::hairtd9 hairTestA(HairStruct::hairtd9 e) { return e; }
+ HairStruct::hairtdA hairTestB(HairStruct::hairtdA e) { return e; }
+ const HairStruct::hair & hairTestC(const HairStruct::hair &e) { return e; }
+ }
+ greasy::HairStruct::hair hairTestA1(greasy::HairStruct::hair e) { return e; }
+ greasy::HairStruct::hairtd1 hairTestA2(greasy::HairStruct::hairtd1 e) { return e; }
+ greasy::HairStruct::hairtd2 hairTestA3(greasy::HairStruct::hairtd2 e) { return e; }
+ greasy::HairStruct::hairtd3 hairTestA4(greasy::HairStruct::hairtd3 e) { return e; }
+ greasy::HairStruct::hairtd4 hairTestA5(greasy::HairStruct::hairtd4 e) { return e; }
+ greasy::HairStruct::hairtd5 hairTestA6(greasy::HairStruct::hairtd5 e) { return e; }
+ greasy::HairStruct::hairtd6 hairTestA7(greasy::HairStruct::hairtd6 e) { return e; }
+ greasy::HairStruct::hairtd7 hairTestA8(greasy::HairStruct::hairtd7 e) { return e; }
+ greasy::HairStruct::hairtd8 hairTestA9(greasy::HairStruct::hairtd8 e) { return e; }
+ greasy::HairStruct::hairtd9 hairTestAA(greasy::HairStruct::hairtd9 e) { return e; }
+ greasy::HairStruct::hairtdA hairTestAB(greasy::HairStruct::hairtdA e) { return e; }
+ const greasy::HairStruct::hairtdA & hairTestAC(const greasy::HairStruct::hairtdA &e) { return e; }
+}
+curly::greasy::HairStruct::hair hairTestB1(curly::greasy::HairStruct::hair e) { return e; }
+curly::greasy::HairStruct::hairtd1 hairTestB2(curly::greasy::HairStruct::hairtd1 e) { return e; }
+curly::greasy::HairStruct::hairtd2 hairTestB3(curly::greasy::HairStruct::hairtd2 e) { return e; }
+curly::greasy::HairStruct::hairtd3 hairTestB4(curly::greasy::HairStruct::hairtd3 e) { return e; }
+curly::greasy::HairStruct::hairtd4 hairTestB5(curly::greasy::HairStruct::hairtd4 e) { return e; }
+curly::greasy::HairStruct::hairtd5 hairTestB6(curly::greasy::HairStruct::hairtd5 e) { return e; }
+curly::greasy::HairStruct::hairtd6 hairTestB7(curly::greasy::HairStruct::hairtd6 e) { return e; }
+curly::greasy::HairStruct::hairtd7 hairTestB8(curly::greasy::HairStruct::hairtd7 e) { return e; }
+curly::greasy::HairStruct::hairtd8 hairTestB9(curly::greasy::HairStruct::hairtd8 e) { return e; }
+curly::greasy::HairStruct::hairtd9 hairTestBA(curly::greasy::HairStruct::hairtd9 e) { return e; }
+curly::greasy::HairStruct::hairtdA hairTestBB(curly::greasy::HairStruct::hairtdA e) { return e; }
+const curly::greasy::HairStruct::hairtdA & hairTestBC(const curly::greasy::HairStruct::hairtdA &e) { return e; }
+
+using curly::greasy::HairStruct;
+HairStruct::hair hairTestC1(HairStruct::hair e) { return e; }
+HairStruct::hairtd1 hairTestC2(HairStruct::hairtd1 e) { return e; }
+HairStruct::hairtd2 hairTestC3(HairStruct::hairtd2 e) { return e; }
+HairStruct::hairtd3 hairTestC4(HairStruct::hairtd3 e) { return e; }
+HairStruct::hairtd4 hairTestC5(HairStruct::hairtd4 e) { return e; }
+HairStruct::hairtd5 hairTestC6(HairStruct::hairtd5 e) { return e; }
+HairStruct::hairtd6 hairTestC7(HairStruct::hairtd6 e) { return e; }
+HairStruct::hairtd7 hairTestC8(HairStruct::hairtd7 e) { return e; }
+HairStruct::hairtd8 hairTestC9(HairStruct::hairtd8 e) { return e; }
+HairStruct::hairtd9 hairTestCA(HairStruct::hairtd9 e) { return e; }
+HairStruct::hairtdA hairTestCB(HairStruct::hairtdA e) { return e; }
+const HairStruct::hairtdA & hairTestCC(const HairStruct::hairtdA &e) { return e; }
+
+namespace curly {
+ namespace greasy {
+ struct FirStruct : HairStruct {
+ hair hairTestFir1(hair e) { return e; }
+ hairtd1 hairTestFir2(hairtd1 e) { return e; }
+ hairtd2 hairTestFir3(hairtd2 e) { return e; }
+ hairtd3 hairTestFir4(hairtd3 e) { return e; }
+ hairtd4 hairTestFir5(hairtd4 e) { return e; }
+ hairtd5 hairTestFir6(hairtd5 e) { return e; }
+ hairtd6 hairTestFir7(hairtd6 e) { return e; }
+ hairtd7 hairTestFir8(hairtd7 e) { return e; }
+ hairtd8 hairTestFir9(hairtd8 e) { return e; }
+ hairtd9 hairTestFirA(hairtd9 e) { return e; }
+ hairtdA hairTestFirB(hairtdA e) { return e; }
+ };
+ }
+}
+
+struct Obscure {
+ enum Zero {};
+ enum One {one};
+ enum Two {two, twoagain};
+#if defined(SWIG)
+ // g++-4.3 warns about this
+ typedef enum Empty {};
+#endif
+ typedef enum {} AlsoEmpty;
+};
+
+// Unnamed enum instance
+extern "C" {
+enum { globalinstance1, globalinstance2, globalinstance3 = 30 } GlobalInstance;
+}
+
+struct Instances {
+ enum { memberinstance1, memberinstance2, memberinstance3 = 300 } MemberInstance;
+ Instances() : MemberInstance(memberinstance3) {}
+};
+
+%}
+
+// Repeated values
+#if defined(SWIGJAVA)
+%javaconst(1);
+// needed for typesafe and proper enums only
+%javaconst(0) ignoreA_three;
+%javaconst(0) ignoreA_thirteen;
+#elif defined(SWIGCSHARP)
+// needed for typesafe enums only
+#ifdef SWIG_TEST_NOCSCONST
+ %csconst(0) ignoreA_three;
+ %csconst(0) ignoreA_thirteen;
+#endif
+%csconst(1);
+#endif
+
+%ignore ignoreA_one;
+%ignore ignoreA_two;
+%ignore ignoreA_twelve;
+%ignore ignoreA_thirty_one;
+
+%ignore ignoreB_ten;
+%ignore ignoreB_twenty;
+%ignore ignoreB_thirty;
+%ignore ignoreB_forty;
+
+%ignore ignoreC_eleven;
+%ignore ignoreC_thirty_one;
+%ignore ignoreC_forty_one;
+
+%ignore ignoreD_ten;
+%ignore ignoreD_twenty;
+
+%ignore ignoreE_twenty;
+
+%inline %{
+struct IgnoreTest {
+ enum IgnoreA { ignoreA_zero, ignoreA_one, ignoreA_two, ignoreA_three, ignoreA_ten=10, ignoreA_eleven, ignoreA_twelve, ignoreA_thirteen, ignoreA_fourteen, ignoreA_twenty=20, ignoreA_thirty=30, ignoreA_thirty_one, ignoreA_thirty_two, ignoreA_thirty_three };
+ enum IgnoreB { ignoreB_ten=10, ignoreB_eleven, ignoreB_twelve, ignoreB_twenty=20, ignoreB_thirty=30, ignoreB_thirty_one, ignoreB_thirty_two, ignoreB_forty=40, ignoreB_forty_one, ignoreB_forty_two };
+ enum IgnoreC { ignoreC_ten=10, ignoreC_eleven, ignoreC_twelve, ignoreC_twenty=20, ignoreC_thirty=30, ignoreC_thirty_one, ignoreC_thirty_two, ignoreC_forty=40, ignoreC_forty_one, ignoreC_forty_two };
+ enum IgnoreD { ignoreD_ten=10, ignoreD_twenty=20, ignoreD_twenty_one, ignoreD_twenty_two };
+ enum IgnoreE { ignoreE_zero, ignoreE_twenty=20, ignoreE_twenty_one, ignoreE_twenty_two };
+};
+
+IgnoreTest::IgnoreA ignoreATest(IgnoreTest::IgnoreA n) { return n; }
+IgnoreTest::IgnoreB ignoreBTest(IgnoreTest::IgnoreB n) { return n; }
+IgnoreTest::IgnoreC ignoreCTest(IgnoreTest::IgnoreC n) { return n; }
+IgnoreTest::IgnoreD ignoreDTest(IgnoreTest::IgnoreD n) { return n; }
+IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; }
+%}
+
+%inline %{
+
+namespace RepeatSpace {
+typedef enum
+{
+ one = 1,
+ initial = one,
+ two,
+ three,
+ llast = three,
+ end = llast
+} repeat;
+repeat repeatTest(repeat e) { return e; }
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/enum_thorough_proper.i b/trunk/Examples/test-suite/enum_thorough_proper.i
new file mode 100644
index 000000000..dcddd25c9
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_thorough_proper.i
@@ -0,0 +1,7 @@
+%module "enum_thorough_proper"
+
+// Test enum wrapping using the proper enums in the target language
+%include "enums.swg"
+
+%include "enum_thorough.i"
+
diff --git a/trunk/Examples/test-suite/enum_thorough_simple.i b/trunk/Examples/test-suite/enum_thorough_simple.i
new file mode 100644
index 000000000..2e1f84ca8
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_thorough_simple.i
@@ -0,0 +1,7 @@
+%module "enum_thorough_simple"
+
+// Test enum wrapping using simple constants (SWIG-1.3.21 and earlier default enum wrapping for C# and Java)
+%include "enumsimple.swg"
+
+%include "enum_thorough.i"
+
diff --git a/trunk/Examples/test-suite/enum_thorough_typesafe.i b/trunk/Examples/test-suite/enum_thorough_typesafe.i
new file mode 100644
index 000000000..e205e8ad1
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_thorough_typesafe.i
@@ -0,0 +1,9 @@
+%module "enum_thorough_typesafe"
+
+// Test enum wrapping using the typesafe enum pattern in the target language
+%include "enumtypesafe.swg"
+
+#define SWIG_TEST_NOCSCONST // For C# typesafe enums
+
+%include "enum_thorough.i"
+
diff --git a/trunk/Examples/test-suite/enum_thorough_typeunsafe.i b/trunk/Examples/test-suite/enum_thorough_typeunsafe.i
new file mode 100644
index 000000000..1e41250ca
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_thorough_typeunsafe.i
@@ -0,0 +1,7 @@
+%module "enum_thorough_typeunsafe"
+
+// Test enum wrapping using a type unsafe enum pattern (constant integers in a class for the enum type)
+%include "enumtypeunsafe.swg"
+
+%include "enum_thorough.i"
+
diff --git a/trunk/Examples/test-suite/enum_var.i b/trunk/Examples/test-suite/enum_var.i
new file mode 100644
index 000000000..c8626d803
--- /dev/null
+++ b/trunk/Examples/test-suite/enum_var.i
@@ -0,0 +1,8 @@
+%module enum_var
+
+%inline %{
+
+enum Fruit { APPLE, PEAR };
+Fruit test;
+
+%}
diff --git a/trunk/Examples/test-suite/enums.i b/trunk/Examples/test-suite/enums.i
new file mode 100644
index 000000000..5632b5e97
--- /dev/null
+++ b/trunk/Examples/test-suite/enums.i
@@ -0,0 +1,97 @@
+/* Test whether varios enums in C. */
+
+%module "enums"
+
+/* Suppress warning messages from the Ruby module for all of the following.. */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) boo;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hoo;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+
+%inline %{
+
+typedef enum {
+ CSP_ITERATION_FWD,
+ CSP_ITERATION_BWD = 11
+} foo1;
+
+typedef enum foo2 {
+ ABCDE = 0,
+ FGHJI = 1
+} foo3;
+
+void
+bar1(foo1 x) {}
+
+void
+bar2(enum foo2 x) {}
+
+void
+bar3(foo3 x) {}
+
+enum sad { boo, hoo = 5 };
+
+#ifdef __cplusplus /* For Octave and g++ which compiles C test code as C++ */
+extern "C" {
+#endif
+/* Unnamed enum instance */
+enum { globalinstance1, globalinstance2, globalinstance3 = 30 } GlobalInstance;
+#ifdef __cplusplus
+}
+#endif
+
+/* Anonymous enum */
+enum { AnonEnum1, AnonEnum2 = 100 };
+
+%}
+
+%inline %{
+
+typedef struct _Foo {
+ enum { BAR1, BAR2 } e;
+} Foo;
+
+%}
+
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) _iFoo;
+
+#ifndef __cplusplus
+%inline %{
+typedef struct _iFoo
+{
+ enum {
+ Phoo = +50,
+ Char = 'a'
+ } e;
+} iFoo;
+%}
+#else
+%inline %{
+struct iFoo
+{
+ enum {
+ Phoo = +50,
+ Char = 'a'
+ };
+};
+%}
+#endif
+
+// enum declaration and initialization
+%inline %{
+enum Exclamation {
+ goodness,
+ gracious,
+ me
+} enumInstance = me;
+
+enum ContainYourself {
+ slap = 10,
+ mine,
+ thigh
+} Slap = slap, Mine = mine, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, mine, thigh};
+%}
+
diff --git a/trunk/Examples/test-suite/errors/c_bad_name.i b/trunk/Examples/test-suite/errors/c_bad_name.i
new file mode 100644
index 000000000..43ccb4d18
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_bad_name.i
@@ -0,0 +1,4 @@
+%module xxx
+
+%name() int foo;
+
diff --git a/trunk/Examples/test-suite/errors/c_bad_native.i b/trunk/Examples/test-suite/errors/c_bad_native.i
new file mode 100644
index 000000000..4d09e04b0
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_bad_native.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%native(foo) int foo;
+
+
diff --git a/trunk/Examples/test-suite/errors/c_class.i b/trunk/Examples/test-suite/errors/c_class.i
new file mode 100644
index 000000000..cd168f67b
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_class.i
@@ -0,0 +1,8 @@
+%module xxx
+
+int class(int x);
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/c_default_error.i b/trunk/Examples/test-suite/errors/c_default_error.i
new file mode 100644
index 000000000..f6220e11d
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_default_error.i
@@ -0,0 +1,4 @@
+%module xxx
+
+int foo(int x = 42 || 3);
+
diff --git a/trunk/Examples/test-suite/errors/c_deprecated.i b/trunk/Examples/test-suite/errors/c_deprecated.i
new file mode 100644
index 000000000..27e74397f
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_deprecated.i
@@ -0,0 +1,8 @@
+%module xxx
+
+int foo(%val int *x, %out int *y);
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/c_empty_char.i b/trunk/Examples/test-suite/errors/c_empty_char.i
new file mode 100644
index 000000000..0a669af86
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_empty_char.i
@@ -0,0 +1,4 @@
+%module xxx
+
+int foo(int x = '');
+
diff --git a/trunk/Examples/test-suite/errors/c_enum_badvalue.i b/trunk/Examples/test-suite/errors/c_enum_badvalue.i
new file mode 100644
index 000000000..8649c03e0
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_enum_badvalue.i
@@ -0,0 +1,7 @@
+%module xxx
+
+enum stuff {
+ FOO = 'x',
+ BAR = 3.14159
+};
+
diff --git a/trunk/Examples/test-suite/errors/c_extra_rblock.i b/trunk/Examples/test-suite/errors/c_extra_rblock.i
new file mode 100644
index 000000000..3e8e86a19
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_extra_rblock.i
@@ -0,0 +1,8 @@
+%module xxx
+
+int foo(int x);
+
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/errors/c_extra_rbrace.i b/trunk/Examples/test-suite/errors/c_extra_rbrace.i
new file mode 100644
index 000000000..0228f9b1d
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_extra_rbrace.i
@@ -0,0 +1,7 @@
+%module xxx
+
+int foo(int);
+
+}
+
+
diff --git a/trunk/Examples/test-suite/errors/c_extra_unsigned.i b/trunk/Examples/test-suite/errors/c_extra_unsigned.i
new file mode 100644
index 000000000..f5728cf0c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/c_insert_missing.i b/trunk/Examples/test-suite/errors/c_insert_missing.i
new file mode 100644
index 000000000..35755ccd8
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_insert_missing.i
@@ -0,0 +1,3 @@
+%module xxx
+
+%insert("header") "missing_file.i";
diff --git a/trunk/Examples/test-suite/errors/c_long_short.i b/trunk/Examples/test-suite/errors/c_long_short.i
new file mode 100644
index 000000000..f05831a8f
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/c_missing_rbrace.i b/trunk/Examples/test-suite/errors/c_missing_rbrace.i
new file mode 100644
index 000000000..381d5008d
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_missing_rbrace.i
@@ -0,0 +1,10 @@
+%module xxx
+
+int foo(int x) {
+ int y;
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/c_missing_semi.i b/trunk/Examples/test-suite/errors/c_missing_semi.i
new file mode 100644
index 000000000..fc20e1db1
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_missing_semi.i
@@ -0,0 +1,4 @@
+%module xxx
+int foo(int)
+int bar(int,int);
+
diff --git a/trunk/Examples/test-suite/errors/c_redefine.i b/trunk/Examples/test-suite/errors/c_redefine.i
new file mode 100644
index 000000000..818d70722
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/c_varargs.i b/trunk/Examples/test-suite/errors/c_varargs.i
new file mode 100644
index 000000000..88f9c2e7d
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/c_varargs.i
@@ -0,0 +1,3 @@
+%module xxx
+
+int foo(int x, ...);
diff --git a/trunk/Examples/test-suite/errors/c_varargs_neg.i b/trunk/Examples/test-suite/errors/c_varargs_neg.i
new file mode 100644
index 000000000..a88d8b712
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_bad_extern.i b/trunk/Examples/test-suite/errors/cpp_bad_extern.i
new file mode 100644
index 000000000..b6895a536
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_extend_redefine.i b/trunk/Examples/test-suite/errors/cpp_extend_redefine.i
new file mode 100644
index 000000000..dfe8fe48a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_extend_undefined.i b/trunk/Examples/test-suite/errors/cpp_extend_undefined.i
new file mode 100644
index 000000000..808a74878
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_extend_undefined.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%extend foo {
+ int bar() {
+ }
+};
diff --git a/trunk/Examples/test-suite/errors/cpp_inline_namespace.i b/trunk/Examples/test-suite/errors/cpp_inline_namespace.i
new file mode 100644
index 000000000..d92746ae0
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_inline_namespace.i
@@ -0,0 +1,7 @@
+%module xxx
+
+namespace foo {
+%inline %{
+int bar(int x) { }
+%}
+}
diff --git a/trunk/Examples/test-suite/errors/cpp_missing_rtemplate.i b/trunk/Examples/test-suite/errors/cpp_missing_rtemplate.i
new file mode 100644
index 000000000..2d87eecf1
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_missing_rtemplate.i
@@ -0,0 +1,11 @@
+%module xxx
+
+
+int foo(vector<int);
+
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/cpp_namespace_alias.i b/trunk/Examples/test-suite/errors/cpp_namespace_alias.i
new file mode 100644
index 000000000..1e45972e6
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_namespace_alias.i
@@ -0,0 +1,14 @@
+%module xxx
+
+namespace blah {
+}
+
+namespace B = blah;
+
+namespace B {
+}
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/cpp_namespace_aliasnot.i b/trunk/Examples/test-suite/errors/cpp_namespace_aliasnot.i
new file mode 100644
index 000000000..c52f8c1f9
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_namespace_aliasnot.i
@@ -0,0 +1,4 @@
+%module xxx
+
+int blah;
+namespace B = blah;
diff --git a/trunk/Examples/test-suite/errors/cpp_namespace_aliasundef.i b/trunk/Examples/test-suite/errors/cpp_namespace_aliasundef.i
new file mode 100644
index 000000000..25b5b7f57
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_namespace_aliasundef.i
@@ -0,0 +1,3 @@
+%module xxx
+
+namespace B = blah;
diff --git a/trunk/Examples/test-suite/errors/cpp_nested.i b/trunk/Examples/test-suite/errors/cpp_nested.i
new file mode 100644
index 000000000..625812e7d
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_no_access.i b/trunk/Examples/test-suite/errors/cpp_no_access.i
new file mode 100644
index 000000000..e04ad9d55
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_no_access.i
@@ -0,0 +1,4 @@
+%module xxx
+
+class Bar : foo {
+};
diff --git a/trunk/Examples/test-suite/errors/cpp_nobase.i b/trunk/Examples/test-suite/errors/cpp_nobase.i
new file mode 100644
index 000000000..70e6d684c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_overload.i b/trunk/Examples/test-suite/errors/cpp_overload.i
new file mode 100644
index 000000000..34fa3cc25
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_private_defvalue.i b/trunk/Examples/test-suite/errors/cpp_private_defvalue.i
new file mode 100644
index 000000000..15542c7bc
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_private_inherit.i b/trunk/Examples/test-suite/errors/cpp_private_inherit.i
new file mode 100644
index 000000000..e8267e98f
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_template_argname.i b/trunk/Examples/test-suite/errors/cpp_template_argname.i
new file mode 100644
index 000000000..b87c115c1
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_template_argname.i
@@ -0,0 +1,8 @@
+%module xxx
+
+template<T> T blah(T x);
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/cpp_template_nargs.i b/trunk/Examples/test-suite/errors/cpp_template_nargs.i
new file mode 100644
index 000000000..1a4fbdc20
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_template_not.i b/trunk/Examples/test-suite/errors/cpp_template_not.i
new file mode 100644
index 000000000..c8df700b5
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_template_not.i
@@ -0,0 +1,9 @@
+%module xxx
+
+int blah;
+
+%template(blahi) blah<int>;
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/cpp_template_partial.i b/trunk/Examples/test-suite/errors/cpp_template_partial.i
new file mode 100644
index 000000000..04ae9055e
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_template_partial.i
@@ -0,0 +1,4 @@
+%module xxx
+
+template<class T> class vector<T *> {
+};
diff --git a/trunk/Examples/test-suite/errors/cpp_template_repeat.i b/trunk/Examples/test-suite/errors/cpp_template_repeat.i
new file mode 100644
index 000000000..e63ffe8d9
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/cpp_template_undef.i b/trunk/Examples/test-suite/errors/cpp_template_undef.i
new file mode 100644
index 000000000..2c0afbecc
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_template_undef.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%template(blahi) blah<int>;
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/cpp_using_not.i b/trunk/Examples/test-suite/errors/cpp_using_not.i
new file mode 100644
index 000000000..2d5b6bf61
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_using_not.i
@@ -0,0 +1,9 @@
+%module xxx
+
+int blah;
+using namespace blah;
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/cpp_using_undef.i b/trunk/Examples/test-suite/errors/cpp_using_undef.i
new file mode 100644
index 000000000..bc0c8c797
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/cpp_using_undef.i
@@ -0,0 +1,9 @@
+%module xxx
+
+using foo::bar;
+using namespace foo;
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/make.sh b/trunk/Examples/test-suite/errors/make.sh
new file mode 100755
index 000000000..ae38ca879
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/make.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+echo "---------------------------------------"
+echo "Testing SWIG error and warning messages"
+echo "---------------------------------------"
+
+SWIG='../../../preinst-swig'
+
+# Files run in C mode
+CFILES='
+c_bad_name
+c_bad_native
+c_class
+c_default_error
+c_deprecated
+c_empty_char
+c_enum_badvalue
+c_extra_rblock
+c_extra_rbrace
+c_extra_unsigned
+c_insert_missing
+c_long_short
+c_missing_rbrace
+c_missing_semi
+c_redefine
+c_varargs
+c_varargs_neg
+nomodule
+pp_badeval
+pp_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/trunk/Examples/test-suite/errors/nomodule.i b/trunk/Examples/test-suite/errors/nomodule.i
new file mode 100644
index 000000000..6341be3fd
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/nomodule.i
@@ -0,0 +1,2 @@
+/* No module name */
+int foo(int);
diff --git a/trunk/Examples/test-suite/errors/pp_badeval.i b/trunk/Examples/test-suite/errors/pp_badeval.i
new file mode 100644
index 000000000..aca397c7c
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_badeval.i
@@ -0,0 +1,11 @@
+%module xxx
+
+#if FOO==4
+#elif FOO==4+
+#endif
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/errors/pp_defined.i b/trunk/Examples/test-suite/errors/pp_defined.i
new file mode 100644
index 000000000..e2f343079
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_defined.i
@@ -0,0 +1,7 @@
+%module xxx
+
+#if defined()
+#endif
+
+#if defined
+#endif
diff --git a/trunk/Examples/test-suite/errors/pp_macro_args.i b/trunk/Examples/test-suite/errors/pp_macro_args.i
new file mode 100644
index 000000000..8bbbfb104
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/pp_macro_badchar.i b/trunk/Examples/test-suite/errors/pp_macro_badchar.i
new file mode 100644
index 000000000..276011559
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/pp_macro_nargs.i b/trunk/Examples/test-suite/errors/pp_macro_nargs.i
new file mode 100644
index 000000000..15e434877
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/pp_macro_redef.i b/trunk/Examples/test-suite/errors/pp_macro_redef.i
new file mode 100644
index 000000000..e0910e60e
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/pp_macro_rparen.i b/trunk/Examples/test-suite/errors/pp_macro_rparen.i
new file mode 100644
index 000000000..cbb04fb87
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_macro_rparen.i
@@ -0,0 +1,3 @@
+%module xxx
+
+#define foo(a,x 3
diff --git a/trunk/Examples/test-suite/errors/pp_macro_unterminated.i b/trunk/Examples/test-suite/errors/pp_macro_unterminated.i
new file mode 100644
index 000000000..d0e32d726
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/pp_misplaced_elif.i b/trunk/Examples/test-suite/errors/pp_misplaced_elif.i
new file mode 100644
index 000000000..5e656f020
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_misplaced_elif.i
@@ -0,0 +1,7 @@
+%module xxx
+
+
+#elif foo == 3
+int x;
+#endif
+
diff --git a/trunk/Examples/test-suite/errors/pp_misplaced_else.i b/trunk/Examples/test-suite/errors/pp_misplaced_else.i
new file mode 100644
index 000000000..ad299466f
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_misplaced_else.i
@@ -0,0 +1,7 @@
+%module xxx
+
+
+#else
+int x;
+#endif
+
diff --git a/trunk/Examples/test-suite/errors/pp_missing_enddef.i b/trunk/Examples/test-suite/errors/pp_missing_enddef.i
new file mode 100644
index 000000000..e13deef27
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_missing_enddef.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%define FOO
+int x;
+
+
+
diff --git a/trunk/Examples/test-suite/errors/pp_missing_endif.i b/trunk/Examples/test-suite/errors/pp_missing_endif.i
new file mode 100644
index 000000000..e83496fb2
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_missing_endif.i
@@ -0,0 +1,6 @@
+%module xxx
+
+#ifdef FOO
+int x;
+
+
diff --git a/trunk/Examples/test-suite/errors/pp_missing_file.i b/trunk/Examples/test-suite/errors/pp_missing_file.i
new file mode 100644
index 000000000..5e3f0ea27
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_missing_file.i
@@ -0,0 +1,3 @@
+%module test
+
+%include "missing_filename.i"
diff --git a/trunk/Examples/test-suite/errors/pp_missing_rblock.i b/trunk/Examples/test-suite/errors/pp_missing_rblock.i
new file mode 100644
index 000000000..55c3cc808
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_missing_rblock.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%{
+int x;
+
+
+
diff --git a/trunk/Examples/test-suite/errors/pp_unterm_char.i b/trunk/Examples/test-suite/errors/pp_unterm_char.i
new file mode 100644
index 000000000..9b028fd3d
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_unterm_char.i
@@ -0,0 +1,7 @@
+%module xxx
+
+
+const char x = 'H
+
+
+
diff --git a/trunk/Examples/test-suite/errors/pp_unterm_comment.i b/trunk/Examples/test-suite/errors/pp_unterm_comment.i
new file mode 100644
index 000000000..f9cdb8257
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_unterm_comment.i
@@ -0,0 +1,6 @@
+%module xxx
+
+/* Hello
+
+
+
diff --git a/trunk/Examples/test-suite/errors/pp_unterm_string.i b/trunk/Examples/test-suite/errors/pp_unterm_string.i
new file mode 100644
index 000000000..31ed8d4bb
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/pp_unterm_string.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+const char *x = "Hello
+
+
diff --git a/trunk/Examples/test-suite/errors/swig_apply_nargs.i b/trunk/Examples/test-suite/errors/swig_apply_nargs.i
new file mode 100644
index 000000000..bb1519c1e
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/errors/swig_identifier.i b/trunk/Examples/test-suite/errors/swig_identifier.i
new file mode 100644
index 000000000..3ad07362d
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/swig_identifier.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%rename("foo bar") foobar;
+
+int foobar(int);
+
diff --git a/trunk/Examples/test-suite/errors/swig_insert_bad.i b/trunk/Examples/test-suite/errors/swig_insert_bad.i
new file mode 100644
index 000000000..e2dd8a93e
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/swig_insert_bad.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%insert("foobar") %{
+some code
+%}
diff --git a/trunk/Examples/test-suite/errors/swig_typemap_copy.i b/trunk/Examples/test-suite/errors/swig_typemap_copy.i
new file mode 100644
index 000000000..17607f2fb
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/swig_typemap_copy.i
@@ -0,0 +1,3 @@
+%module xxx
+
+%typemap(in) int = blah;
diff --git a/trunk/Examples/test-suite/errors/swig_typemap_old.i b/trunk/Examples/test-suite/errors/swig_typemap_old.i
new file mode 100644
index 000000000..c27ff5533
--- /dev/null
+++ b/trunk/Examples/test-suite/errors/swig_typemap_old.i
@@ -0,0 +1,6 @@
+%module xxx
+
+%typemap(in) int x {
+ $source;
+ $target;
+}
diff --git a/trunk/Examples/test-suite/evil_diamond.i b/trunk/Examples/test-suite/evil_diamond.i
new file mode 100644
index 000000000..7b2e9152f
--- /dev/null
+++ b/trunk/Examples/test-suite/evil_diamond.i
@@ -0,0 +1,26 @@
+%module(ruby_minherit="1") evil_diamond
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) baz; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
+ SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+
+%inline %{
+
+class foo { };
+
+class bar : public foo {
+};
+
+class baz : public foo {
+};
+
+class spam : public bar, public baz {
+};
+
+foo *test(foo *f) { return f; }
+%}
+
diff --git a/trunk/Examples/test-suite/evil_diamond_ns.i b/trunk/Examples/test-suite/evil_diamond_ns.i
new file mode 100644
index 000000000..515044007
--- /dev/null
+++ b/trunk/Examples/test-suite/evil_diamond_ns.i
@@ -0,0 +1,27 @@
+%module(ruby_minherit="1") evil_diamond_ns
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Blah::foo; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Blah::bar; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Blah::baz; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
+ SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+
+%inline %{
+namespace Blah {
+class foo { };
+
+class bar : public foo {
+};
+
+class baz : public foo {
+};
+
+class spam : public bar, public baz {
+};
+
+foo *test(foo *f) { return f; }
+}
+%}
+
diff --git a/trunk/Examples/test-suite/evil_diamond_prop.i b/trunk/Examples/test-suite/evil_diamond_prop.i
new file mode 100644
index 000000000..804ea66b4
--- /dev/null
+++ b/trunk/Examples/test-suite/evil_diamond_prop.i
@@ -0,0 +1,39 @@
+%module(ruby_minherit="1") evil_diamond_prop
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) baz; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
+ SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+
+%inline %{
+
+class foo {
+ public:
+ int _foo;
+ foo() : _foo(1) {}
+};
+
+class bar : public foo {
+ public:
+ int _bar;
+ bar() : _bar(2) {}
+};
+
+class baz : public foo {
+ public:
+ int _baz;
+ baz() : _baz(3) {}
+};
+
+class spam : public bar, public baz {
+ public:
+ int _spam;
+ spam() : _spam(4) {}
+};
+
+foo *test(foo *f) { return f; }
+%}
+
diff --git a/trunk/Examples/test-suite/exception_order.i b/trunk/Examples/test-suite/exception_order.i
new file mode 100644
index 000000000..45a87e0c5
--- /dev/null
+++ b/trunk/Examples/test-suite/exception_order.i
@@ -0,0 +1,111 @@
+%module exception_order
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+
+%include "exception.i"
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+/*
+ last resource, catch everything but don't override
+ user's throw declarations.
+*/
+
+#if defined(SWIGUTL)
+%exception {
+ try {
+ $action
+ } catch(...) {
+ SWIG_exception_fail(SWIG_RuntimeError,"postcatch unknown");
+ }
+}
+#else
+%exception {
+ try {
+ $action
+ } catch(...) {
+ SWIG_exception(SWIG_RuntimeError,"postcatch unknown");
+ }
+}
+#endif
+
+%catches(E1,E2*,ET<int>,ET<double>,...) A::barfoo(int i);
+
+
+%allowexception efoovar;
+%allowexception A::efoovar;
+
+%inline %{
+ int efoovar;
+ int foovar;
+ const int cfoovar = 1;
+
+ struct E1
+ {
+ };
+
+ struct E2
+ {
+ };
+
+ struct E3
+ {
+ };
+
+ template <class T>
+ struct ET
+ {
+ };
+
+ struct A
+ {
+ static int sfoovar;
+ static const int CSFOOVAR = 1;
+ int foovar;
+ int efoovar;
+
+ /* caught by the user's throw definition */
+ int foo() throw(E1)
+ {
+ throw E1();
+ return 0;
+ }
+
+ int bar() throw(E2)
+ {
+ throw E2();
+ return 0;
+ }
+
+ /* caught by %postexception */
+ int foobar()
+ {
+ throw E3();
+ return 0;
+ }
+
+
+ int barfoo(int i)
+ {
+ if (i == 1) {
+ throw E1();
+ } else if (i == 2) {
+ static E2 *ep = new E2();
+ throw ep;
+ } else if (i == 3) {
+ throw ET<int>();
+ } else {
+ throw ET<double>();
+ }
+ return 0;
+ }
+ };
+ int A::sfoovar = 1;
+%}
+
+%template(ET_i) ET<int>;
+%template(ET_d) ET<double>;
diff --git a/trunk/Examples/test-suite/exception_partial_info.i b/trunk/Examples/test-suite/exception_partial_info.i
new file mode 100644
index 000000000..37b87ef50
--- /dev/null
+++ b/trunk/Examples/test-suite/exception_partial_info.i
@@ -0,0 +1,51 @@
+%module exception_partial_info
+
+// This produced compileable code for Tcl, Python in 1.3.27, fails in 1.3.29
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%{
+class myException
+{
+ public:
+ virtual const char *name() = 0;
+};
+
+class ex1 : public myException
+{
+ public:
+ virtual const char *name() { return "ex1"; }
+};
+
+class ex2 : public myException
+{
+ public:
+ virtual const char *name() { return "ex2"; }
+};
+%}
+
+#if !defined(SWIGUTL)
+
+#if !defined(SWIGCHICKEN)
+
+%inline %{
+class Impl
+{
+ public:
+ void f1() throw (myException) { ex1 e; throw e; }
+ void f2() throw (myException) { ex2 e; throw e; }
+};
+%}
+
+#else
+#warning "Chicken needs fixing for partial exception information"
+#endif
+
+#else
+#warning "UTL needs fixing for partial exception information"
+#endif
+
diff --git a/trunk/Examples/test-suite/expressions.i b/trunk/Examples/test-suite/expressions.i
new file mode 100644
index 000000000..7b907ec3b
--- /dev/null
+++ b/trunk/Examples/test-suite/expressions.i
@@ -0,0 +1,10 @@
+%module expressions
+
+%inline %{
+struct A
+{
+ A() : k( 20/(5-1) ) {}
+ A(int i) : k( 20/(5-1)*i /* comment */ ) {}
+ int k;
+};
+%}
diff --git a/trunk/Examples/test-suite/extend.i b/trunk/Examples/test-suite/extend.i
new file mode 100644
index 000000000..2a2a472ea
--- /dev/null
+++ b/trunk/Examples/test-suite/extend.i
@@ -0,0 +1,53 @@
+%module extend
+
+%extend Base {
+ ~Base() {
+ delete $self;
+ }
+ static int zeroVal() {
+ return 0;
+ }
+ virtual int currentValue() {
+ return $self->value;
+ }
+ int extendmethod(int v) {
+ int ret = $self->method(v);
+ return ret * 2;
+ }
+};
+
+%inline %{
+struct Base {
+ Base(int v = 0) : value(v) {}
+ int value;
+ virtual int method(int v) {
+ return v;
+ }
+};
+struct Derived : Base {
+ double actualval;
+};
+%}
+
+%{
+ double extendval = 0;
+ double Derived_extendval_get(Derived *self) {
+ return self->actualval * 100;
+ }
+ void Derived_extendval_set(Derived *self, double d) {
+ self->actualval = d/100;
+ }
+%}
+
+%extend Derived {
+ Derived(int v) {
+ Derived *$self = new Derived();
+ $self->value = v*2;
+ return $self;
+ }
+ virtual int method(int v) {
+ int ret = $self->Base::method(v);
+ return ret * 2;
+ }
+ double extendval;
+}
diff --git a/trunk/Examples/test-suite/extend_default.i b/trunk/Examples/test-suite/extend_default.i
new file mode 100644
index 000000000..097b5332e
--- /dev/null
+++ b/trunk/Examples/test-suite/extend_default.i
@@ -0,0 +1,133 @@
+// Tests %extend with default arguments as well as %extend with default arguments with overloading
+
+%module extend_default
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Override::over;
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Override::overload;
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Override::ride;
+
+// %extend before the class definition
+%extend Before {
+ Before(int i = -1, double d = -1.0) {
+ Before *self = new Before();
+ self->i = i;
+ self->d = d;
+ return self;
+ }
+ static double AddedStaticMethod(int i = -1, double d = -1) { return i+d; }
+ double AddedMethod(int i = -1, double d = -1.0) { return i+d; }
+}
+
+%inline %{
+struct Before {
+ double d;
+ int i;
+};
+%}
+
+// %extend after the class definition
+%inline %{
+struct After {
+ double d;
+ int i;
+};
+%}
+
+%extend After {
+ After(int i = -1, double d = -1.0) {
+ After *self = new After();
+ self->i = i;
+ self->d = d;
+ return self;
+ }
+ static double AddedStaticMethod(int i = -1, double d = -1) { return i+d; }
+ double AddedMethod(int i = -1, double d = -1.0) { return i+d; }
+}
+
+
+// %extend before the class definition - with overloading and default args
+%extend OverBefore {
+ OverBefore(int i = -1, double d = -1.0) {
+ OverBefore *self = new OverBefore("boo");
+ self->i = i;
+ self->d = d;
+ return self;
+ }
+ static double AddedStaticMethod(int i = -1, double d = -1) { return i+d; }
+ double AddedMethod(int i = -1, double d = -1.0) { return i+d; }
+}
+
+%inline %{
+struct OverBefore {
+ OverBefore(const char *str, int ii = -2, double dd = -2.0) : d(dd), i(ii) { str=0; }
+ static double AddedStaticMethod(const char*, int ii = -1, double dd = -1) { return ii+dd; }
+ double AddedMethod(const char*, int ii = -1, double dd = -1.0) { return ii+dd; }
+ double d;
+ int i;
+};
+%}
+
+// %extend after the class definition - with overloading and default args
+%extend OverAfter {
+ OverAfter(int i = -1, double d = -1.0) {
+ OverAfter *self = new OverAfter("boo");
+ self->i = i;
+ self->d = d;
+ return self;
+ }
+ static double AddedStaticMethod(int i = -1, double d = -1) { return i+d; }
+ double AddedMethod(int i = -1, double d = -1.0) { return i+d; }
+}
+
+%inline %{
+struct OverAfter {
+ OverAfter(const char *str, int ii = -2, double dd = -2.0) : d(dd), i(ii) { str=0; }
+ static double AddedStaticMethod(const char*, int ii = -1, double dd = -1) { return ii+dd; }
+ double AddedMethod(const char*, int ii = -1, double dd = -1.0) { return ii+dd; }
+ double d;
+ int i;
+};
+%}
+
+
+// %extend overrides the class definition
+%extend Override {
+ int over(int a) { return a*a; } // SWIG should give a warning then choose this one over the real one
+ int overload(int a) { return a*a; } // Similarly, but this one generated uncompileable code in SWIG-1.3.22
+}
+%inline %{
+struct Override {
+ int over(int a = -1) { return a; }
+ int ride(int a = -1) { return a; }
+ int overload(int a) { return a; }
+ int overload() { return -10; }
+};
+%}
+%extend Override {
+ int ride(int a) { return a+a; } // SWIG should give a warning then ignore this one
+}
+
+
+// %extend in class hierarchy
+%extend Base {
+virtual int * virtualmethod(int a = 0) { return 0; }
+int * nonvirtual(int a = 0) { return 0; }
+static int * static_method(int a = 0) { return 0; }
+}
+%extend Derived {
+int * virtualmethod(int a = 0) { return 0; }
+int * nonvirtual(int a = 0) { return 0; }
+static int * static_method(int a = 0) { return 0; }
+int * realvirtual(int a = 0) { return 0; }
+}
+
+
+%inline %{
+struct Base {
+ virtual ~Base() {}
+ virtual int * realvirtual(int a = 0) { return 0; }
+};
+struct Derived : Base {
+};
+%}
+
diff --git a/trunk/Examples/test-suite/extend_placement.i b/trunk/Examples/test-suite/extend_placement.i
new file mode 100644
index 000000000..b95e82145
--- /dev/null
+++ b/trunk/Examples/test-suite/extend_placement.i
@@ -0,0 +1,107 @@
+%module extend_placement
+
+// Tests placement of %extend directives
+
+// Before the class
+
+%extend Foo {
+ Foo(int a) { return new Foo(); }
+ ~Foo() { delete $self;}
+ int spam(int x) { return x; }
+ int spam(int x, int y) { return x + y ; }
+ int spam(int x, int y,int z) { return x + y ; }
+ int spam(Foo f, double d = 10.0) { return 0; }
+};
+
+%inline %{
+class Foo {
+public:
+ Foo(){}
+
+#ifdef SWIG
+%extend { Foo(int a, int b) { return new Foo(); } }
+#endif
+
+ int spam() { return 1; }
+ int spam(const char* c) { return 2; }
+};
+%}
+
+// After the class
+
+%inline %{
+class Bar {
+public:
+ Bar() { }
+ int spam() { return 1; }
+ int spam(const char* c) { return 2; }
+};
+%}
+
+
+%extend Bar {
+ Bar(int a) { return new Bar(); }
+ ~Bar() { delete $self;}
+ int spam() { return 1}
+ int spam(int x) { return x; }
+ int spam(int x, int y) { return x + y ; }
+ int spam(int x, int y,int z) { return x + y ; }
+ int spam(Bar b, double d = 10.0) { return 0; }
+};
+
+
+// testing templates
+
+// Before the class
+
+%extend FooT {
+ FooT(int a) { return new FooT<T>(); }
+ ~FooT() { delete $self;}
+ int spam(int x) { return x; }
+ int spam(int x, int y) { return x + y ; }
+ int spam(int x, int y,int z) { return x + y ; }
+ int spam(Foo f, double d = 10.0) { return 0; }
+};
+
+%inline %{
+template<class T>
+class FooT {
+public:
+ FooT(){}
+
+#ifdef SWIG
+%extend { FooT(int a, int b) { return new FooT<T>(); } }
+#endif
+
+ int spam() { return 1; }
+ int spam(const char* c) { return 2; }
+};
+%}
+
+%template(FooTi) FooT<int>;
+
+
+// After the class
+
+%inline %{
+template<class T>
+class BarT {
+public:
+ BarT() { }
+ int spam() { return 1; }
+ int spam(const char* c) { return 2; }
+};
+%}
+
+
+%extend BarT {
+ BarT(int a) { return new BarT<T>(); }
+ ~BarT() { delete $self;}
+ int spam() { return 1}
+ int spam(int x) { return x; }
+ int spam(int x, int y) { return x + y ; }
+ int spam(int x, int y,int z) { return x + y ; }
+ int spam(Bar b, double d = 10.0) { return 0; }
+};
+
+%template(BarTi) BarT<int>;
diff --git a/trunk/Examples/test-suite/extend_template.i b/trunk/Examples/test-suite/extend_template.i
new file mode 100644
index 000000000..265c87675
--- /dev/null
+++ b/trunk/Examples/test-suite/extend_template.i
@@ -0,0 +1,26 @@
+%module extend_template
+%module xxx // should be ignored
+namespace oss { // this doesn't
+ %extend Foo<0> {
+ int test1(int x) { return x; }
+ }
+}
+
+%extend oss::Foo<0> { // this doesn't
+ int test2(int x) { return x; }
+};
+
+
+%inline %{
+ namespace oss
+ {
+ template <int>
+ struct Foo {
+ };
+ }
+%}
+
+namespace oss
+{
+ %template(Foo_0) Foo<0>;
+}
diff --git a/trunk/Examples/test-suite/extend_template_ns.i b/trunk/Examples/test-suite/extend_template_ns.i
new file mode 100644
index 000000000..3712f2c8f
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/extend_variable.i b/trunk/Examples/test-suite/extend_variable.i
new file mode 100644
index 000000000..7cb6e868a
--- /dev/null
+++ b/trunk/Examples/test-suite/extend_variable.i
@@ -0,0 +1,103 @@
+%module extend_variable
+
+// Tests %extend for variables
+
+%inline %{
+class ExtendMe {
+ double var;
+public:
+ ExtendMe() : var(0.0) {}
+ bool get(double &d) {
+ d = var;
+ return true;
+ }
+ bool set(const double &d) {
+ var = d;
+ return true;
+ }
+};
+%}
+
+%extend ExtendMe {
+ double ExtendVar;
+};
+
+%{
+// If possible, all language modules should use this naming format for consistency
+void ExtendMe_ExtendVar_set(ExtendMe *thisptr, double value) {
+ thisptr->set(value);
+}
+double ExtendMe_ExtendVar_get(ExtendMe *thisptr) {
+ double value = 0;
+ thisptr->get(value);
+ return value;
+}
+%}
+
+
+%{
+ class Foo
+ {
+ };
+%}
+
+#if SWIGJAVA
+%javaconst(1) AllBarOne;
+#elif SWIGCSHARP
+%csconst(1) AllBarOne;
+#endif
+
+
+class Foo {
+ public:
+ %extend {
+ static const int Bar = 42;
+ static const int AllBarOne = 4422;
+ static const int StaticConstInt;
+ static int StaticInt;
+ }
+};
+
+%{
+ int globalVariable = 1111;
+
+ void Foo_StaticInt_set(int value) {
+ globalVariable = value;
+ }
+
+ int Foo_StaticInt_get() {
+ return globalVariable;
+ }
+
+ int Foo_StaticConstInt_get() {
+ static int var = 2222;
+ return var;
+ }
+%}
+
+%inline {
+ namespace ns1
+ {
+ struct Bar
+ {
+ }
+ ;
+ }
+}
+
+%{
+ int ns1_Bar_x_get(ns1::Bar *self) {
+ return 1;
+ }
+
+ void ns1_Bar_x_set(ns1::Bar *self, int x) {
+ }
+%}
+
+%extend ns1::Bar
+{
+ int x;
+}
+
+
+
diff --git a/trunk/Examples/test-suite/extern_c.i b/trunk/Examples/test-suite/extern_c.i
new file mode 100644
index 000000000..9c17d18fb
--- /dev/null
+++ b/trunk/Examples/test-suite/extern_c.i
@@ -0,0 +1,16 @@
+%module extern_c
+
+%inline %{
+extern "C" {
+void RealFunction(int value);
+typedef void Function1(int value); // Fails
+typedef int Integer1;
+}
+typedef void Function2(int value); // Works
+typedef int Integer2;
+%}
+
+%{
+void RealFunction(int value) {}
+%}
+
diff --git a/trunk/Examples/test-suite/extern_declaration.i b/trunk/Examples/test-suite/extern_declaration.i
new file mode 100644
index 000000000..eca97b5b4
--- /dev/null
+++ b/trunk/Examples/test-suite/extern_declaration.i
@@ -0,0 +1,31 @@
+%module extern_declaration
+
+// Test different calling conventions on Windows. Old versions of SWIG generated
+// an incorrect extern declaration that wouldn't compile with Windows compilers.
+#define SWIGEXPORT
+#define SWIGSTDCALL
+#define MYDLLIMPORT
+
+%{
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define MYDLLIMPORT __declspec(dllimport)
+#else
+# define MYDLLIMPORT
+#endif
+%}
+
+MYDLLIMPORT extern int externimport(int i);
+SWIGEXPORT extern int externexport(int);
+extern int SWIGSTDCALL externstdcall(int);
+
+%{
+/*
+ externimport ought to be using MYDLLIMPORT and compiled into another dll, but that is
+ a bit tricky to do in the test framework
+*/
+SWIGEXPORT extern int externimport(int i) { return i; }
+SWIGEXPORT extern int externexport(int i) { return i; }
+extern int SWIGSTDCALL externstdcall(int i) { return i; }
+%}
+
+
diff --git a/trunk/Examples/test-suite/extern_namespace.i b/trunk/Examples/test-suite/extern_namespace.i
new file mode 100644
index 000000000..e7f952f3d
--- /dev/null
+++ b/trunk/Examples/test-suite/extern_namespace.i
@@ -0,0 +1,23 @@
+%module extern_namespace
+%inline %{
+
+ namespace foo {
+
+ extern int bar(int blah = 1);
+
+ }
+
+ extern "C" int foobar(int i) {
+ return i;
+ }
+
+%}
+
+
+
+%{
+ int foo::bar(int blah) {
+ return blah;
+ }
+%}
+
diff --git a/trunk/Examples/test-suite/extern_throws.i b/trunk/Examples/test-suite/extern_throws.i
new file mode 100644
index 000000000..eab26244e
--- /dev/null
+++ b/trunk/Examples/test-suite/extern_throws.i
@@ -0,0 +1,18 @@
+%module extern_throws
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%inline %{
+#include <exception>
+extern int get() throw(std::exception);
+
+%}
+
+%{
+int get() throw(std::exception) { return 0; }
+%}
+
diff --git a/trunk/Examples/test-suite/features.i b/trunk/Examples/test-suite/features.i
new file mode 100644
index 000000000..2ccbe725a
--- /dev/null
+++ b/trunk/Examples/test-suite/features.i
@@ -0,0 +1,181 @@
+%module features
+
+%warnfilter(SWIGWARN_LANG_IDENTIFIER,SWIGWARN_IGNORE_OPERATOR_PLUSEQ);
+
+// This testcase checks that %feature is working for templates and non user supplied constructors/destructors and is just generally working
+
+// If the default %exception is used it will not compile. It shouldn't get used.
+%exception "this_will_not_compile";
+
+// Test 1: Test for no user supplied constructors and destructor
+%exception Simple::Simple(const Simple&) "$action /*Simple::Simple*/";
+%exception Simple::Simple() "$action /*Simple::Simple*/";
+%exception Simple::~Simple() "$action /*Simple::~Simple*/";
+
+%inline %{
+class Simple {};
+%}
+
+
+%exception NS::SimpleNS::SimpleNS(const NS::SimpleNS&) "$action /*NS::SimpleNS::SimpleNS*/";
+%exception NS::SimpleNS::SimpleNS() "$action /*NS::SimpleNS::SimpleNS*/";
+%exception NS::SimpleNS::~SimpleNS() "$action /*NS::SimpleNS::~SimpleNS*/";
+// method tests
+%exception NS::SimpleNS::method() "_failed_ /*NS::Simple::method() const*/";
+%exception NS::SimpleNS::method() const "$action /*NS::Simple::method() const*/";
+%exception NS::SimpleNS::afunction() "$action /*NS::Simple::afunction()*/";
+
+%inline %{
+ namespace NS
+ {
+
+ class SimpleNS {
+ public:
+ void method() const {}
+ void afunction() {}
+ };
+ }
+
+%}
+
+// Test 2: Test templated functions
+%exception foobar "caca";
+%exception foobar<int>(int) "$action /*foobar<int>*/";
+
+%inline %{
+template<class T> void foobar(T t) {}
+%}
+
+%template(FooBarInt) foobar<int>;
+
+// Test 3: Test templates with no user supplied constructors and destructor
+%exception SimpleTemplate<int>::SimpleTemplate(const SimpleTemplate<int>&) "$action /*SimpleTemplate<int>::SimpleTemplate<int>*/";
+%exception SimpleTemplate<int>::SimpleTemplate() "$action /*SimpleTemplate<int>::SimpleTemplate<int>*/";
+%exception SimpleTemplate<int>::~SimpleTemplate() "$action /*SimpleTemplate<int>::~SimpleTemplate*/";
+
+%inline %{
+template<class T> class SimpleTemplate {
+ public:
+};
+
+%}
+
+%template(SimpleInt) SimpleTemplate<int>;
+
+// Test 4: Test templates with user supplied constructors and destructor
+%exception Template<int>::Template() "$action /*Template<int>::Template<int>*/";
+%exception Template<int>::Template(const Template&) "$action /*Template<int>::Template<int>(const Template&)*/";
+%exception Template<int>::~Template() "$action /*Template<int>::~Template*/";
+// method tests
+%exception Template<int>::foo "$action /*Template<int>::foo*/";
+%exception Template::get "$action /*Template<int>::get*/";
+%exception Template<int>::set(const int &t) "$action /*Template<int>::set(const int &t)*/";
+%exception Template<int>::bar(const int &t) "_failed_ /*Template<int>::bar(const int &t) const*/";
+%exception Template<int>::bar(const int &t) const "$action /*Template<int>::bar(const int &t) const*/";
+
+%inline %{
+template<class T> class Template {
+public:
+ Template(){}
+
+ Template(const Template&){}
+ ~Template(){}
+ void foo(){}
+ void bar(const int &t) const {}
+#ifdef SWIG
+ %extend {
+ T& get(int i) const {
+ throw 1;
+ }
+ void set(const T &t) {}
+ }
+#endif
+};
+%}
+
+%template(TemplateInt) Template<int>;
+
+// Test 5: wildcards
+%exception Space::WildCards::WildCards(const Space::WildCards&) "$action /* Space::WildCards::WildCards() */";
+%exception Space::WildCards::WildCards() "$action /* Space::WildCards::WildCards() */";
+%exception Space::WildCards::~WildCards() "$action /* Space::WildCards::WildCards() */";
+%exception *::incy "_failure_ /* *::incy */";
+%exception *::incy(int a) "_failure_ /* *::incy(int a) */";
+%exception *::incy(int a) const "$action /* *::incy(int a) const */";
+%exception *::wincy(int a) "$action /* *::wincy(int a) */";
+%exception *::spider "$action /* *::spider */";
+%exception *::spider(int a) "_failure_ /* *::spider(int a) */";
+
+%inline %{
+namespace Space {
+ struct WildCards {
+ virtual ~WildCards() {}
+ virtual WildCards* incy(int a) const { return 0; }
+ virtual WildCards* wincy(int a) { return 0; }
+ virtual WildCards* spider(int a) const { return 0; }
+ };
+}
+%}
+
+// Test 6: default arguments
+%exception Space::Animals::Animals(const Space::Animals&) "$action /* Space::Animals::Animals(int a = 0, double d = 0.0) */";
+%exception Space::Animals::Animals(int a = 0, double d = 0.0) "$action /* Space::Animals::Animals(int a = 0, double d = 0.0) */";
+%exception Space::Animals::~Animals() "$action /* Space::Animals::~Animals() */";
+%exception Space::Animals::lions(int a = 0, double d = 0.0) const "$action /* Space::Animals::lions(int a = 0, double d = 0.0) const */";
+%exception Space::Animals::leopards(int a = 0, double d = 0.0) "$action /* Space::Animals::leopards(int a = 0, double d = 0.0) */";
+%exception *::cheetahs(int a = 0, double d = 0.0) const "$action /* *::cheetahs(int a = 0, double d = 0.0) const */";
+%exception *::jackal(int a = 0, double d = 0.0) "$action /* *::jackal(int a = 0, double d = 0.0) */";
+%inline %{
+namespace Space {
+ struct Animals {
+ Animals(int a = 0, double d = 0.0) {}
+ void* lions(int a = 0, double d = 0.0) const { return 0; }
+ void* leopards(int a = 0, double d = 0.0) { return 0; }
+ int cheetahs(int a = 0, double d = 0.0) const { return 0; }
+ int jackal(int a = 0, double d = 0.0) { return 0; }
+ };
+}
+%}
+
+// Test 7: inheritance
+%exception Space::Base::Base(const Space::Base&) "$action /* Space::Base::Base() */";
+%exception Space::Base::Base() "$action /* Space::Base::Base() */";
+%exception Space::Base::~Base() "$action /* Space::Base::~Base() */";
+%exception Space::Derived::Derived(const Space::Derived&) "$action /* Space::Derived::Derived() */";
+%exception Space::Derived::Derived() "$action /* Space::Derived::Derived() */";
+%exception Space::Derived::~Derived() "$action /* Space::Derived::~Derived() */";
+// The following should apply to both Base and Derived
+%exception Space::Base::virtualmethod(int a) const "$action /* Space::Base::virtualmethod(int a) const */";
+
+%exception Space::Base::operator+=(int) "$action /* Space::Base::Base() */";
+
+%inline %{
+namespace Space {
+ struct Base {
+ int operator+=(int) { return 0; }
+ virtual const char** virtualmethod(int a) const { return 0; }
+ virtual ~Base() {}
+ };
+ struct Derived : Base {
+ virtual const char** virtualmethod(int a) const { return 0; }
+ };
+}
+%}
+
+// Test 8 conversion operators
+%rename(opbool) operator bool;
+%rename(opuint) operator unsigned int;
+
+%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */";
+%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */";
+%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */";
+%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/";
+
+%inline %{
+ class ConversionOperators {
+ public:
+ operator bool() { return false; }
+ operator unsigned int() { return 0; }
+ };
+%}
+
diff --git a/trunk/Examples/test-suite/file_test.i b/trunk/Examples/test-suite/file_test.i
new file mode 100644
index 000000000..f4d98a8b3
--- /dev/null
+++ b/trunk/Examples/test-suite/file_test.i
@@ -0,0 +1,21 @@
+%module file_test
+
+%include file.i
+
+
+%inline
+%{
+ int nfile(FILE *file) {
+ return 0;
+ }
+
+ int nfile_name(const char *filename) {
+ return 0;
+ }
+
+ FILE* GetStdOut() {
+ return stdout;
+ }
+
+%}
+
diff --git a/trunk/Examples/test-suite/fragments.i b/trunk/Examples/test-suite/fragments.i
new file mode 100644
index 000000000..4bf399a21
--- /dev/null
+++ b/trunk/Examples/test-suite/fragments.i
@@ -0,0 +1,36 @@
+%module fragments
+
+
+%fragment("Hello","header") %{
+/* hello!!! */
+int foobar(int a)
+{
+ return a;
+}
+%}
+
+/*
+ this fragment include the previous fragment if needed.
+*/
+
+%fragment("Hi","header",fragment="Hello") %{
+/* hi!!! */
+int bar(int a)
+{
+ return foobar(a);
+}
+%}
+
+%typemap(in,fragment="Hi") int hola "$1 = 123;";
+
+
+%inline %{
+
+int bar(int a);
+
+int foo(int hola)
+{
+ return bar(hola);
+}
+
+%}
diff --git a/trunk/Examples/test-suite/friends.i b/trunk/Examples/test-suite/friends.i
new file mode 100644
index 000000000..2dfee6f3b
--- /dev/null
+++ b/trunk/Examples/test-suite/friends.i
@@ -0,0 +1,178 @@
+%module friends
+%{
+#include <iostream>
+%}
+
+%warnfilter(SWIGWARN_LANG_IDENTIFIER);
+
+
+%inline
+{
+
+ void globalscope(); // forward declaration needed for some compilers
+
+ struct A;
+ struct B
+ {
+ B(int i) : v(i)
+ {
+ }
+
+ friend void ::globalscope();
+ friend int mix(A* a, B *b);
+ virtual ~B()
+ {
+ }
+
+ private:
+ int v;
+
+ };
+
+ void globalscope() { B b(0); b.v=10; }
+
+ struct A
+ {
+ A(int v) : val(v)
+ {
+ }
+
+ friend int get_val1(const A& a)
+ {
+ return a.val;
+ }
+
+ /* simple overloading */
+ friend int get_val1(const A& a, int o)
+ {
+ return a.val + o;
+ }
+
+ /*
+ note that operators << and >> are ignored, as they
+ should, since no rename is performed.
+ */
+ friend std::istream& operator>>(std::istream& in, A& a);
+
+ /* already declare at B */
+ friend int mix(A* a, B *b);
+
+ protected:
+ friend int get_val2(const A& a)
+ {
+ return a.val*2;
+ }
+
+ private:
+ friend int get_val3(const A& a);
+
+ /* this should be ignored */
+ friend std::ostream& operator<<(std::ostream& out, const A& a)
+ {
+ out << a.val;
+ return out;
+ }
+
+ int val;
+ };
+
+ /*
+ 'mix' is an interesting case, this is the third declaration
+ swig is getting (two friends + one inline).
+ */
+ inline int mix(A* a, B *b) {
+ return a->val + b->v;
+ }
+
+ /* this should be ignored */
+ inline std::istream& operator>>(std::istream& in, A& a) {
+ int v;
+ in >> v;
+ a = A(v);
+ return in;
+ }
+
+ inline int get_val3(const A& a) {
+ return a.val*3;
+ }
+
+ /* another overloading */
+ inline int get_val1(int i, int a, int b) {
+ return i;
+ }
+
+
+ /*
+ sit and watch how well this case works, is just incredible!!,
+
+ also note that there is no special code added to manage friends
+ and templates (or overloading), this is just old swig magic
+ working at its best.
+ */
+
+ template <class C>
+ struct D
+ {
+ D(C v) : val(v) {}
+
+ /* note that here we are overloading the already super
+ overloaded 'get_val1' */
+ friend C get_val1(D& b)
+ {
+ return b.val;
+ }
+
+ /* here set will be 'auto' overloaded, depending of the
+ %template instantiations. */
+ friend void set(D& b, C v)
+ {
+ b.val = v;
+ }
+
+ private:
+ C val;
+ };
+
+ namespace ns1 {
+
+ void bas() {}
+
+ void baz() {}
+ }
+}
+
+// Use this version with extra qualifiers to test SWIG as some compilers accept this
+ namespace ns1 {
+ namespace ns2 {
+ class Foo {
+ public:
+ Foo::Foo() {};
+ friend void bar();
+ friend void ns1::baz();
+ void Foo::member() { }
+
+ };
+ void bar() {}
+ }
+ }
+
+// Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards)
+%{
+ namespace ns1 {
+ namespace ns2 {
+ class Foo {
+ public:
+ Foo() {};
+ friend void bar();
+ friend void ns1::baz();
+ void member() { }
+
+ };
+ void bar() {}
+ }
+ }
+%}
+
+
+%template(D_i) D<int>;
+%template(D_d) D<double>;
diff --git a/trunk/Examples/test-suite/funcptr.i b/trunk/Examples/test-suite/funcptr.i
new file mode 100644
index 000000000..dae1ec577
--- /dev/null
+++ b/trunk/Examples/test-suite/funcptr.i
@@ -0,0 +1,60 @@
+%module funcptr
+
+/*
+ Complicated one that should defeat just reading , to find
+ the number of arguments expected in the function pointer.
+extern void do(int (*op)(int (*i)(double, double), int j));
+*/
+
+%inline %{
+typedef double (*DistFun)(double* data, int r, int c, int i, int j, void *xdata);
+
+void distance(double *data, int *dim, DistFun fun, double *output) {
+}
+
+typedef int (*Operator)(int i,int j);
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int subtract(int a, int b) {
+ return a-b;
+}
+
+int multiply(int a, int b) {
+ return a*b;
+}
+
+int *nowt() {
+ return 0;
+}
+
+int *nowt2(void) {
+ return 0;
+}
+
+struct MyStruct { int i; };
+typedef struct MyStruct * MyStructPtr;
+
+MyStructPtr mystructptr() {
+ return 0;
+}
+
+typedef int * Integer;
+
+int (*funcvar)(int,int) = add;
+int * (*funcvar2)() = nowt;
+int * (*funcvar3)(void) = nowt2;
+Integer (*funcvar4)() = nowt;
+MyStructPtr (*funcvar5)() = mystructptr;
+
+void (*pfunc0)();
+int (*pfuncA)();
+void (*pfunc1)(int);
+void (*pfunc2)(int, double);
+%}
diff --git a/trunk/Examples/test-suite/function_typedef.i b/trunk/Examples/test-suite/function_typedef.i
new file mode 100644
index 000000000..718af9c2f
--- /dev/null
+++ b/trunk/Examples/test-suite/function_typedef.i
@@ -0,0 +1,20 @@
+%module function_typedef
+
+%inline %{
+
+typedef int binop_t(int, int);
+
+int do_binop1(binop_t f, int x, int y) {
+ return f(x,y);
+}
+
+int do_binop2(binop_t *f, int x, int y) {
+ return (*f)(x,y);
+}
+
+int do_binop3(int f(int,int), int x, int y) {
+ return f(x,y);
+}
+%}
+
+
diff --git a/trunk/Examples/test-suite/fvirtual.i b/trunk/Examples/test-suite/fvirtual.i
new file mode 100644
index 000000000..af189ed1f
--- /dev/null
+++ b/trunk/Examples/test-suite/fvirtual.i
@@ -0,0 +1,21 @@
+// This testcase tests corner cases for the -fvirtual optimisation flag.
+// Note that the test-suite does not actually run with -fvirtual at any point, but this can be tested using the SWIG_FEATURES=-fvirtual env variable.
+%module fvirtual
+
+// Test overloaded methods #1508327 (requires a scripting language runtime test)
+%inline %{
+ class Node {
+ public:
+ virtual int addChild( Node *child ) { return 1; }
+ virtual ~Node() {}
+ };
+
+ class NodeSwitch : public Node {
+ public :
+ virtual int addChild( Node *child ) { return 2; } // This was hidden with -fvirtual
+ virtual int addChild( Node *child, bool value ) { return 3; }
+ virtual ~NodeSwitch() {}
+ };
+%}
+
+
diff --git a/trunk/Examples/test-suite/global_namespace.i b/trunk/Examples/test-suite/global_namespace.i
new file mode 100644
index 000000000..7b575614f
--- /dev/null
+++ b/trunk/Examples/test-suite/global_namespace.i
@@ -0,0 +1,60 @@
+%module global_namespace
+
+// classes
+%inline %{
+class Klass1 {};
+class Klass2 {};
+class Klass3 {};
+class Klass4 {};
+class Klass5 {};
+class Klass6 {};
+class Klass7 {};
+
+struct KlassMethods {
+ static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*const& pr) {}
+ static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*const& pr) {}
+};
+%}
+
+%inline %{
+namespace Space {
+class XYZ1 {};
+class XYZ2 {};
+class XYZ3 {};
+class XYZ4 {};
+class XYZ5 {};
+class XYZ6 {};
+class XYZ7 {};
+}
+
+struct XYZMethods {
+ static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*const& pr) {}
+ static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*const& pr) {}
+};
+%}
+
+//enums
+%inline %{
+enum AnEnum1 { anenum1 };
+enum AnEnum2 { anenum2 };
+enum AnEnum3 { anenum3 };
+
+struct AnEnumMethods {
+ static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {}
+ static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {}
+};
+%}
+
+%inline %{
+namespace Space {
+enum TheEnum1 { theenum1 };
+enum TheEnum2 { theenum2 };
+enum TheEnum3 { theenum3 };
+
+struct TheEnumMethods {
+ static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {}
+ static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {}
+};
+}
+%}
+
diff --git a/trunk/Examples/test-suite/global_ns_arg.i b/trunk/Examples/test-suite/global_ns_arg.i
new file mode 100644
index 000000000..3554fd814
--- /dev/null
+++ b/trunk/Examples/test-suite/global_ns_arg.i
@@ -0,0 +1,15 @@
+%module global_ns_arg
+
+%inline %{
+
+typedef int Integer;
+
+::Integer foo(::Integer x) {
+ return x;
+}
+
+::Integer bar() {
+ return 1;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/global_scope_types.i b/trunk/Examples/test-suite/global_scope_types.i
new file mode 100644
index 000000000..05aa43b77
--- /dev/null
+++ b/trunk/Examples/test-suite/global_scope_types.i
@@ -0,0 +1,44 @@
+%module global_scope_types
+
+// no constructor/destructor wrappers as they do not use global scope operator which we are trying to test here
+%nodefaultctor Dingaling;
+%nodefaultdtor Dingaling;
+
+%inline %{
+struct Dingaling {};
+typedef Dingaling DINGALING;
+template <typename T> struct MyTemplate {
+ T tt(T t) { return t; }
+ T& ttr(T& t) { return t; }
+};
+
+#ifndef SWIG
+// This is added so that the code will not compile, if the global scope operator on Dingaling is omitted in the generated code
+namespace Spac {
+ class Dingaling {
+ Dingaling();
+ Dingaling(const Dingaling& t);
+ Dingaling& operator=(const Dingaling t);
+ };
+}
+using namespace Spac;
+#endif
+
+namespace Spac {
+
+ struct Ting {};
+ typedef Ting TING;
+
+ class Test {
+ public:
+ void something(::Dingaling t, ::Dingaling* pt, ::Dingaling& rt, const ::Dingaling& crt) {}
+ void tsomething(MyTemplate< ::Dingaling > t1, MyTemplate< const ::Dingaling* > t2) {}
+// void usomething(::MyTemplate< ::DINGALING > t3, ::MyTemplate< ::DINGALING *> t4) {} // needs fixing
+ void nothing(::Spac::Ting*, ::Spac::TING&) {}
+ };
+
+}
+
+extern "C" void funcptrtest( void (*)(::Dingaling) ) {}
+%}
+
diff --git a/trunk/Examples/test-suite/global_vars.i b/trunk/Examples/test-suite/global_vars.i
new file mode 100644
index 000000000..8c18bbd34
--- /dev/null
+++ b/trunk/Examples/test-suite/global_vars.i
@@ -0,0 +1,31 @@
+%module global_vars
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
+
+%include std_string.i
+
+%inline %{
+
+ struct A
+ {
+ int x;
+ };
+
+ std::string b;
+ A a;
+ A *ap;
+ const A *cap;
+ A &ar = a;
+
+ int x;
+ int *xp;
+ int& c_member = x;
+
+ void *vp;
+
+ enum Hello { Hi, Hola };
+
+ Hello h;
+ Hello *hp;
+ Hello &hr = h;
+%}
diff --git a/trunk/Examples/test-suite/grouping.i b/trunk/Examples/test-suite/grouping.i
new file mode 100644
index 000000000..5632231d0
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/guile/Makefile.in b/trunk/Examples/test-suite/guile/Makefile.in
new file mode 100644
index 000000000..c6be92c32
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/Makefile.in
@@ -0,0 +1,56 @@
+#######################################################################
+# Makefile for guile test-suite
+#######################################################################
+
+LANGUAGE = guile
+VARIANT = _gh
+SCRIPTSUFFIX = _runme.scm
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+GUILE = @GUILE@
+GUILE_RUNTIME=-runtime
+
+C_TEST_CASES = long_long \
+ list_vector \
+ multivalue \
+ pointer_in_out
+
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+%.multicpptest: SWIGOPT += $(GUILE_RUNTIME)
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.scm appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean
+%.clean:
+ @rm -f $*-guile
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile guile_clean
diff --git a/trunk/Examples/test-suite/guile/README b/trunk/Examples/test-suite/guile/README
new file mode 100644
index 000000000..37432ea4b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/guile/casts_runme.scm b/trunk/Examples/test-suite/guile/casts_runme.scm
new file mode 100644
index 000000000..7a0a0420b
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/casts_runme.scm
@@ -0,0 +1,5 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts.so"))
+(load "../schemerunme/casts.scm")
diff --git a/trunk/Examples/test-suite/guile/char_constant_runme.scm b/trunk/Examples/test-suite/guile/char_constant_runme.scm
new file mode 100644
index 000000000..d183b35e5
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/char_constant_runme.scm
@@ -0,0 +1,5 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant.so"))
+(load "../schemerunme/char_constant.scm")
diff --git a/trunk/Examples/test-suite/guile/class_ignore_runme.scm b/trunk/Examples/test-suite/guile/class_ignore_runme.scm
new file mode 100644
index 000000000..b3229f85c
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/class_ignore_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore.so"))
+(load "../schemerunme/class_ignore.scm")
diff --git a/trunk/Examples/test-suite/guile/constover_runme.scm b/trunk/Examples/test-suite/guile/constover_runme.scm
new file mode 100644
index 000000000..1ab42d349
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/constover_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover.so"))
+(load "../schemerunme/constover.scm")
diff --git a/trunk/Examples/test-suite/guile/contract_runme.scm b/trunk/Examples/test-suite/guile/contract_runme.scm
new file mode 100644
index 000000000..ea80e321c
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/contract_runme.scm
@@ -0,0 +1,6 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract.so"))
+(load "testsuite.scm")
+(load "../schemerunme/contract.scm")
diff --git a/trunk/Examples/test-suite/guile/cpp_enum_runme.scm b/trunk/Examples/test-suite/guile/cpp_enum_runme.scm
new file mode 100644
index 000000000..5a2d9f048
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/cpp_enum_runme.scm
@@ -0,0 +1,5 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum.so"))
+(load "../schemerunme/cpp_enum.scm")
diff --git a/trunk/Examples/test-suite/guile/cpp_namespace_runme.scm b/trunk/Examples/test-suite/guile/cpp_namespace_runme.scm
new file mode 100644
index 000000000..2a871de24
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/cpp_namespace_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace.so"))
+(load "../schemerunme/cpp_namespace.scm")
diff --git a/trunk/Examples/test-suite/guile/dynamic_cast_runme.scm b/trunk/Examples/test-suite/guile/dynamic_cast_runme.scm
new file mode 100644
index 000000000..7b70001d0
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/dynamic_cast_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast.so"))
+(load "../schemerunme/dynamic_cast.scm")
diff --git a/trunk/Examples/test-suite/guile/import_nomodule_runme.scm b/trunk/Examples/test-suite/guile/import_nomodule_runme.scm
new file mode 100644
index 000000000..ffb2474fc
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/import_nomodule_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule.so"))
+(load "../schemerunme/import_nomodule.scm")
diff --git a/trunk/Examples/test-suite/guile/imports_runme.scm b/trunk/Examples/test-suite/guile/imports_runme.scm
new file mode 100644
index 000000000..2fda017ce
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/imports_runme.scm
@@ -0,0 +1,11 @@
+;;; 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"))
+(load "../schemerunme/imports.scm")
diff --git a/trunk/Examples/test-suite/guile/inherit_missing_runme.scm b/trunk/Examples/test-suite/guile/inherit_missing_runme.scm
new file mode 100644
index 000000000..97e950cb2
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/inherit_missing_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing.so"))
+(load "../schemerunme/inherit_missing.scm")
diff --git a/trunk/Examples/test-suite/guile/integers_runme.scm b/trunk/Examples/test-suite/guile/integers_runme.scm
new file mode 100644
index 000000000..14ec8b0fe
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/integers_runme.scm
@@ -0,0 +1,11 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers.so"))
+
+(define-macro (throws-exception? form)
+ `(catch #t
+ (lambda () ,form #f)
+ (lambda args #t)))
+
+(load "../schemerunme/integers.scm")
diff --git a/trunk/Examples/test-suite/guile/li_std_string_runme.scm b/trunk/Examples/test-suite/guile/li_std_string_runme.scm
new file mode 100644
index 000000000..05b74cd65
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/li_std_string_runme.scm
@@ -0,0 +1,5 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so"))
+(load "../schemerunme/li_std_string.scm")
diff --git a/trunk/Examples/test-suite/guile/li_typemaps_runme.scm b/trunk/Examples/test-suite/guile/li_typemaps_runme.scm
new file mode 100644
index 000000000..9824fc98e
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/li_typemaps_runme.scm
@@ -0,0 +1,18 @@
+;;; This is the union runtime testcase. It ensures that values within a
+;;; union embedded within a struct can be set and read correctly.
+
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so"))
+(load "../schemerunme/li_typemaps.scm")
+
+(let ((lst (inoutr-int2 3 -2)))
+ (if (not (and (= (car lst) 3) (= (cadr lst) -2)))
+ (error "Error in inoutr-int2")))
+
+(let ((lst (out-foo 4)))
+ (if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8)))
+ (error "Error in out-foo")))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/guile/list_vector_runme.scm b/trunk/Examples/test-suite/guile/list_vector_runme.scm
new file mode 100644
index 000000000..546d8a1ba
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/list_vector_runme.scm
@@ -0,0 +1,5 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector.so"))
+(load "../schemerunme/list_vector.scm")
diff --git a/trunk/Examples/test-suite/guile/multivalue_runme.scm b/trunk/Examples/test-suite/guile/multivalue_runme.scm
new file mode 100644
index 000000000..d1d7fbfe7
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/multivalue_runme.scm
@@ -0,0 +1,7 @@
+;;;; Automatic test of multiple return values
+
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue.so"))
+(load "../schemerunme/multivalue.scm")
diff --git a/trunk/Examples/test-suite/guile/name_runme.scm b/trunk/Examples/test-suite/guile/name_runme.scm
new file mode 100644
index 000000000..831c20610
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/name_runme.scm
@@ -0,0 +1,5 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_name_module" (dynamic-link "./libname.so"))
+(load "../schemerunme/name.scm")
diff --git a/trunk/Examples/test-suite/guile/overload_complicated_runme.scm b/trunk/Examples/test-suite/guile/overload_complicated_runme.scm
new file mode 100644
index 000000000..3c2b80dbf
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/overload_complicated_runme.scm
@@ -0,0 +1,21 @@
+;; 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)))
+
+(define (=~ a b)
+ (< (abs (- a b)) 1e-8))
+
+;; Check first method
+(check (=~ (foo 1 2 "bar" 4) 15))
+
+;; Check second method
+(check (=~ (foo 1 2) 4811.4))
+(check (=~ (foo 1 2 3.2) 4797.2))
+(check (=~ (foo 1 2 3.2 #\Q) 4798.2))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/guile/overload_copy_runme.scm b/trunk/Examples/test-suite/guile/overload_copy_runme.scm
new file mode 100644
index 000000000..9b93aeb8a
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/overload_copy_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy.so"))
+(load "../schemerunme/overload_copy.scm")
diff --git a/trunk/Examples/test-suite/guile/overload_extend_runme.scm b/trunk/Examples/test-suite/guile/overload_extend_runme.scm
new file mode 100644
index 000000000..cb0223dea
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/overload_extend_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend.so"))
+(load "../schemerunme/overload_extend.scm")
diff --git a/trunk/Examples/test-suite/guile/overload_simple_runme.scm b/trunk/Examples/test-suite/guile/overload_simple_runme.scm
new file mode 100644
index 000000000..993a5f30f
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/overload_simple_runme.scm
@@ -0,0 +1,5 @@
+;; 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"))
+(load "../schemerunme/overload_simple.scm")
diff --git a/trunk/Examples/test-suite/guile/overload_subtype_runme.scm b/trunk/Examples/test-suite/guile/overload_subtype_runme.scm
new file mode 100644
index 000000000..7dfa2c16c
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/overload_subtype_runme.scm
@@ -0,0 +1,5 @@
+;; 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"))
+(load "../schemerunme/overload_subtype.scm")
diff --git a/trunk/Examples/test-suite/guile/pointer_in_out_runme.scm b/trunk/Examples/test-suite/guile/pointer_in_out_runme.scm
new file mode 100644
index 000000000..de3522749
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/pointer_in_out_runme.scm
@@ -0,0 +1,5 @@
+;; 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"))
+(load "../schemerunme/pointer_in_out.scm")
diff --git a/trunk/Examples/test-suite/guile/reference_global_vars_runme.scm b/trunk/Examples/test-suite/guile/reference_global_vars_runme.scm
new file mode 100644
index 000000000..8cd31c3e8
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/reference_global_vars_runme.scm
@@ -0,0 +1,3 @@
+; copied from python runme_.py
+(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars.so"))
+(load "../schemerunme/reference_global_vars.scm")
diff --git a/trunk/Examples/test-suite/guile/testsuite.scm b/trunk/Examples/test-suite/guile/testsuite.scm
new file mode 100644
index 000000000..7f5fd71b0
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/testsuite.scm
@@ -0,0 +1,37 @@
+;; Little helper functions and macros for the run tests
+
+(use-modules (ice-9 format))
+
+(define (test-error error-format . args)
+ (display "Runtime check failed. ")
+ (apply format #t error-format args)
+ (newline)
+ (exit 1))
+
+(define-macro (expect-true form)
+ `(if (not ,form)
+ (test-error "Expected true value of ~A" ',form)))
+
+(define-macro (expect-false form)
+ `(if ,form
+ (test-error "Expected false value of ~A" ',form)))
+
+(define-macro (expect-result expected-result-form equal? form)
+ `(let ((expected-result ,expected-result-form)
+ (result ,form))
+ (if (not (,equal? result expected-result))
+ (test-error "The result of ~A was ~A, expected ~A, which is not ~A"
+ ',form result expected-result ',equal?))))
+
+(define-macro (expect-throw tag-form form)
+ `(let ((tag ,tag-form))
+ (if (catch #t
+ (lambda ()
+ ,form
+ #t)
+ (lambda (key . args)
+ (if (eq? key ,tag-form)
+ #f
+ (test-error "The form ~A threw to ~A (expected a throw to ~A)"
+ ',form key tag))))
+ (test-error "The form ~A returned normally (expected a throw to ~A)"))))
diff --git a/trunk/Examples/test-suite/guile/throw_exception_runme.scm b/trunk/Examples/test-suite/guile/throw_exception_runme.scm
new file mode 100644
index 000000000..377506276
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/throw_exception_runme.scm
@@ -0,0 +1,45 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so"))
+
+(define-macro (check-throw form)
+ `(catch 'swig-exception
+ (lambda ()
+ ,form
+ (error "Check failed (returned normally): " ',form))
+ (lambda (key result)
+ result)))
+
+(define-macro (check-throw-error form)
+ `(let ((result (check-throw ,form)))
+ (test-is-Error result)))
+
+(let ((foo (new-Foo)))
+ (let ((result (check-throw (Foo-test-int foo))))
+ (if (not (eqv? result 37))
+ (error "Foo-test-int failed, returned " result)))
+ (let ((result (check-throw (Foo-test-multi foo 1))))
+ (if (not (eqv? result 37))
+ (error "Foo-test-multi 1 failed, returned " result)))
+ (let ((result (check-throw (Foo-test-msg foo))))
+ (if (not (and (string? result)
+ (string=? result "Dead")))
+ (error "Foo-test-msg failed, returned " result)))
+ (let ((result (check-throw (Foo-test-multi foo 2))))
+ (if (not (and (string? result)
+ (string=? result "Dead")))
+ (error "Foo-test-multi 2 failed, returned " result)))
+ (check-throw-error (Foo-test-cls foo))
+ (check-throw-error (Foo-test-multi foo 3))
+ (check-throw-error (Foo-test-cls-ptr foo))
+ (check-throw-error (Foo-test-cls-ref foo))
+ ;; Namespace stuff
+ (let ((result (check-throw (Foo-test-enum foo))))
+ (if (not (eqv? result (enum2)))
+ (error "Foo-test-enum failed, returned " result)))
+ (check-throw-error (Foo-test-cls-td foo))
+ (check-throw-error (Foo-test-cls-ptr-td foo))
+ (check-throw-error (Foo-test-cls-ref-td foo)))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/guile/typedef_inherit_runme.scm b/trunk/Examples/test-suite/guile/typedef_inherit_runme.scm
new file mode 100644
index 000000000..d75d421d5
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/typedef_inherit_runme.scm
@@ -0,0 +1,2 @@
+(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit.so"))
+(load "../schemerunme/typedef_inherit.scm")
diff --git a/trunk/Examples/test-suite/guile/typename_runme.scm b/trunk/Examples/test-suite/guile/typename_runme.scm
new file mode 100644
index 000000000..4243f6974
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/typename_runme.scm
@@ -0,0 +1,3 @@
+(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename.so"))
+;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes.so"))
+(load "../schemerunme/typename.scm")
diff --git a/trunk/Examples/test-suite/guile/unions_runme.scm b/trunk/Examples/test-suite/guile/unions_runme.scm
new file mode 100644
index 000000000..867e8a3c3
--- /dev/null
+++ b/trunk/Examples/test-suite/guile/unions_runme.scm
@@ -0,0 +1,8 @@
+;;; 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"))
+(load "../schemerunme/unions.scm")
diff --git a/trunk/Examples/test-suite/guilescm/Makefile.in b/trunk/Examples/test-suite/guilescm/Makefile.in
new file mode 100644
index 000000000..ba1cba440
--- /dev/null
+++ b/trunk/Examples/test-suite/guilescm/Makefile.in
@@ -0,0 +1,49 @@
+#######################################################################
+# Makefile for guile test-suite (with SCM API)
+#######################################################################
+
+EXTRA_TEST_CASES += guilescm_ext_test.externaltest
+
+include ../guile/Makefile
+
+# Overridden variables here
+INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm
+VARIANT =
+# Refer to the guile directory for the run scripts
+SCRIPTPREFIX = ../guile/
+GUILE_RUNTIME=
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.scm appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+setup = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
+ fi
+
+%.externaltest:
+ $(local_setup)
+ +$(swig_and_compile_external)
+ $(local_run_testcase)
+
+# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory)
+local_setup = \
+ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
+ fi
+
+local_run_testcase = \
+ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \
+ fi
diff --git a/trunk/Examples/test-suite/guilescm/ext_test_external.cxx b/trunk/Examples/test-suite/guilescm/ext_test_external.cxx
new file mode 100644
index 000000000..4b65f4953
--- /dev/null
+++ b/trunk/Examples/test-suite/guilescm/ext_test_external.cxx
@@ -0,0 +1,24 @@
+#include <ext_test_wrap_hdr.h>
+#include <imports_a.h>
+
+SCM test_create()
+{
+#define FUNC_NAME "test-create"
+ SCM result;
+ A *newobj;
+ swig_type_info *type;
+
+ newobj = new A();
+ type = SWIG_TypeQuery("A *");
+ result = SWIG_NewPointerObj(result, type, 1);
+
+ return result;
+#undef FUNC_NAME
+}
+
+SCM test_is_pointer(SCM val)
+{
+#define FUNC_NAME "test-is-pointer"
+ return SCM_BOOL(SWIG_IsPointer(val));
+#undef FUNC_NAME
+}
diff --git a/trunk/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm b/trunk/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
new file mode 100644
index 000000000..ff3df064b
--- /dev/null
+++ b/trunk/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
@@ -0,0 +1,19 @@
+(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so"))
+
+; This is a test for SF Bug 1573892
+; If IsPointer is called before TypeQuery, the test-is-pointer will fail
+; (i.e if the bottom two lines were moved to the top, the old code would succeed)
+; only a problem when is-pointer is called first
+
+(define a (new-A))
+
+(if (not (test-is-pointer a))
+ (error "test-is-pointer failed!"))
+
+(if (test-is-pointer 5)
+ (error "test-is-pointer thinks 5 is a pointer!"))
+
+(define b (test-create))
+(A-hello b)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/guilescm_ext_test.i b/trunk/Examples/test-suite/guilescm_ext_test.i
new file mode 100644
index 000000000..fd5655d4f
--- /dev/null
+++ b/trunk/Examples/test-suite/guilescm_ext_test.i
@@ -0,0 +1,19 @@
+%module guilescm_ext_test
+
+/* just use the imports_a.h header... for this test we only need a class */
+%{
+#include "imports_a.h"
+%}
+
+%include "imports_a.h"
+
+%{
+SCM test_create();
+SCM test_is_pointer(SCM val);
+%}
+
+%init %{
+ scm_c_define_gsubr("test-create", 0, 0, 0, (swig_guile_proc) test_create);
+ scm_c_define_gsubr("test-is-pointer", 1, 0, 0, (swig_guile_proc) test_is_pointer);
+%}
+
diff --git a/trunk/Examples/test-suite/iadd.i b/trunk/Examples/test-suite/iadd.i
new file mode 100644
index 000000000..514bd3e4f
--- /dev/null
+++ b/trunk/Examples/test-suite/iadd.i
@@ -0,0 +1,58 @@
+%module iadd
+
+%include attribute.i
+class Foo;
+%attribute_ref(test::Foo, test::A& , AsA);
+%attribute_ref(test::Foo, long, AsLong);
+
+
+%inline %{
+struct B {
+ int x;
+ B(const int x) : x(x) {}
+
+ B& get_me()
+ {
+ return *this;
+ }
+
+ B& operator+=(const B& a) {
+ x += a.x;
+ return *this;
+ }
+};
+
+
+
+namespace test {
+
+struct A {
+ int x;
+ A(const int x) : x(x) {}
+
+ A& get_me()
+ {
+ return *this;
+ }
+
+ A operator+=(const A& a) {
+ x += a.x;
+ return *this;
+ }
+};
+
+
+class Foo {
+public:
+ Foo(): _a(new A(5)), _n(new long) {}
+ ~Foo() { delete _a; delete _n; _a = NULL; _n = NULL; }
+
+ A & AsA() const { return *_a; }
+ long& AsLong() const { return *_n; }
+private:
+ A *_a;
+ long *_n;
+};
+}
+
+%}
diff --git a/trunk/Examples/test-suite/ignore_parameter.i b/trunk/Examples/test-suite/ignore_parameter.i
new file mode 100644
index 000000000..bc0892c3a
--- /dev/null
+++ b/trunk/Examples/test-suite/ignore_parameter.i
@@ -0,0 +1,42 @@
+// Test for %typemap(ignore)
+
+%module ignore_parameter
+
+%typemap(in,numinputs=0) char* a "static const char* hi = \"hello\"; $1 = const_cast<char *>(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/trunk/Examples/test-suite/ignore_template_constructor.i b/trunk/Examples/test-suite/ignore_template_constructor.i
new file mode 100644
index 000000000..ffd541986
--- /dev/null
+++ b/trunk/Examples/test-suite/ignore_template_constructor.i
@@ -0,0 +1,45 @@
+%module ignore_template_constructor
+%include std_vector.i
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGPERL) || defined(SWIGRUBY)
+#define SWIG_GOOD_VECTOR
+%ignore std::vector<Flow>::vector(size_type);
+%ignore std::vector<Flow>::resize(size_type);
+#endif
+
+#if defined(SWIGTCL) || defined(SWIGPERL)
+#define SWIG_GOOD_VECTOR
+/* here, for languages with bad declaration */
+%ignore std::vector<Flow>::vector(unsigned int);
+%ignore std::vector<Flow>::resize(unsigned int);
+#endif
+
+#if defined(SWIG_GOOD_VECTOR)
+%inline %{
+class Flow {
+ Flow() {}
+public:
+ Flow(double d) {}
+};
+%}
+
+#else
+/* here, for languages with bad typemaps */
+
+%inline %{
+class Flow {
+public:
+ Flow() {}
+ Flow(double d) {}
+};
+%}
+
+#endif
+
+%template(VectFlow) std::vector<Flow>;
+
+%inline %{
+std::vector<Flow> inandout(std::vector<Flow> v) {
+ return v;
+}
+%}
diff --git a/trunk/Examples/test-suite/immutable.i b/trunk/Examples/test-suite/immutable.i
new file mode 100644
index 000000000..ff5081e9c
--- /dev/null
+++ b/trunk/Examples/test-suite/immutable.i
@@ -0,0 +1,20 @@
+// test to make sure setters are not generated for constants
+
+%module immutable
+
+
+%immutable;
+%mutable;
+
+%inline %{
+#define ABC -11
+enum count {Zero, One, Two}; %}
+
+
+%clearimmutable;
+
+%inline %{
+#define XYZ -22
+enum backwards {Tre=3, Duo=2, Uno=1};
+%}
+
diff --git a/trunk/Examples/test-suite/implicittest.i b/trunk/Examples/test-suite/implicittest.i
new file mode 100644
index 000000000..91205aafa
--- /dev/null
+++ b/trunk/Examples/test-suite/implicittest.i
@@ -0,0 +1,68 @@
+%module(naturalvar="1") implicittest
+
+%implicitconv;
+
+%inline
+{
+ struct B { };
+}
+
+%inline
+{
+ struct A
+ {
+ int ii;
+ A(int i) { ii = 1; }
+ A(double d) { ii = 2; }
+ A(const B& b) { ii = 3; }
+ explicit A(char *s) { ii = 4; }
+
+ int get() const { return ii; }
+
+ };
+
+ int get(const A& a) { return a.ii; }
+
+ template <class T>
+ struct A_T
+ {
+ int ii;
+ A_T(int i) { ii = 1; }
+ A_T(double d) { ii = 2; }
+ A_T(const B& b) { ii = 3; }
+ explicit A_T(char *s) { ii = 4; }
+
+ int get() const { return ii; }
+
+ };
+}
+
+%inline
+{
+ struct Foo
+ {
+ int ii;
+ Foo(){ ii = 0;}
+ Foo(int){ ii = 1;}
+ Foo(double){ ii = 2;}
+ explicit Foo(char *s){ii = 3;}
+ Foo(const Foo& f){ ii = f.ii;}
+
+ };
+
+ struct Bar
+ {
+ int ii;
+ Foo f;
+ Bar() {ii = -1;}
+ Bar(const Foo& ff){ ii = ff.ii;}
+ };
+
+
+ int get_b(const Bar&b) { return b.ii; }
+
+ Foo foo;
+
+}
+
+%template(A_int) A_T<int>;
diff --git a/trunk/Examples/test-suite/import_nomodule.h b/trunk/Examples/test-suite/import_nomodule.h
new file mode 100644
index 000000000..2e80e72bb
--- /dev/null
+++ b/trunk/Examples/test-suite/import_nomodule.h
@@ -0,0 +1,2 @@
+class Foo { };
+typedef int Integer;
diff --git a/trunk/Examples/test-suite/import_nomodule.i b/trunk/Examples/test-suite/import_nomodule.i
new file mode 100644
index 000000000..a1ba9ad7a
--- /dev/null
+++ b/trunk/Examples/test-suite/import_nomodule.i
@@ -0,0 +1,42 @@
+%module import_nomodule
+%{
+#include "import_nomodule.h"
+%}
+
+// For Python
+%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive.
+
+%import "import_nomodule.h"
+
+#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP)
+
+/**
+ * The proxy class does not have Bar derived from Foo, yet an instance of Bar
+ * can successfully be passed to a proxy function taking a Foo pointer (for some
+ * language modules).
+ *
+ * This violation of the type system is not possible in Java and C# due to static
+ * type checking. It's also not (currently) possible in Ruby, but this may be
+ * fixable (needs more investigation).
+ */
+
+%newobject create_Foo;
+%delobject delete_Foo;
+
+%inline %{
+Foo *create_Foo() {
+ return new Foo();
+}
+
+void delete_Foo(Foo *f) {
+ delete f;
+}
+
+void test1(Foo *f, Integer x) { }
+
+class Bar : public Foo { };
+
+%}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/imports.list b/trunk/Examples/test-suite/imports.list
new file mode 100644
index 000000000..36c0802fb
--- /dev/null
+++ b/trunk/Examples/test-suite/imports.list
@@ -0,0 +1,2 @@
+imports_a
+imports_b
diff --git a/trunk/Examples/test-suite/imports_a.h b/trunk/Examples/test-suite/imports_a.h
new file mode 100644
index 000000000..f761ea38c
--- /dev/null
+++ b/trunk/Examples/test-suite/imports_a.h
@@ -0,0 +1,21 @@
+#ifndef a_h
+#define a_h
+enum GlobalEnum { globalenum1=1, globalenum2 };
+
+/* This function should be static as it will be emitted into the code for
+ * every module. All _static targets would fail here with a multiple
+ * definition if this is not static. */
+static GlobalEnum global_test(GlobalEnum e) { return e; }
+
+class A {
+ public:
+ A() {}
+ virtual ~A() {}
+
+ void hello() {}
+
+ enum MemberEnum { memberenum1=10, memberenum2 };
+ virtual MemberEnum member_virtual_test(MemberEnum e) { return e; }
+ virtual GlobalEnum global_virtual_test(GlobalEnum e) { return global_test(e); }
+};
+#endif
diff --git a/trunk/Examples/test-suite/imports_a.i b/trunk/Examples/test-suite/imports_a.i
new file mode 100644
index 000000000..562a14888
--- /dev/null
+++ b/trunk/Examples/test-suite/imports_a.i
@@ -0,0 +1,15 @@
+/* This file is part of a test for SF bug #231619.
+ It shows that the %import directive does not work properly in SWIG
+ 1.3a5: Type information is not properly generated if a base class
+ comes from an %import-ed file. */
+
+%module imports_a
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) A::MemberEnum; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) GlobalEnum; /* Ruby, wrong constant name */
+
+%{
+ #include "imports_a.h"
+%}
+
+%include "imports_a.h"
diff --git a/trunk/Examples/test-suite/imports_b.h b/trunk/Examples/test-suite/imports_b.h
new file mode 100644
index 000000000..f50cee576
--- /dev/null
+++ b/trunk/Examples/test-suite/imports_b.h
@@ -0,0 +1,31 @@
+#include "imports_a.h"
+
+class B : public A
+{
+ public:
+ B() {};
+
+ void bye() {} ;
+
+ virtual MemberEnum member_virtual_test(MemberEnum e) { return memberenum2; }
+ virtual GlobalEnum global_virtual_test(GlobalEnum e) { return globalenum2; }
+};
+
+A::MemberEnum global_test(A::MemberEnum e) { return e; }
+
+struct C : A
+{
+ typedef A a_type;
+
+ A* get_a(A* a)
+ {
+ return a;
+ }
+
+ a_type* get_a_type(a_type* a)
+ {
+ return a;
+ }
+
+};
+
diff --git a/trunk/Examples/test-suite/imports_b.i b/trunk/Examples/test-suite/imports_b.i
new file mode 100644
index 000000000..81e84cddd
--- /dev/null
+++ b/trunk/Examples/test-suite/imports_b.i
@@ -0,0 +1,47 @@
+/* This file is part of a test for SF bug #231619.
+ It shows that the %import directive does not work properly in SWIG
+ 1.3a5: Type information is not properly generated if a base class
+ comes from an %import-ed file.
+
+ Extra tests added for enums to test languages that have enum types.
+*/
+
+%module imports_b
+
+%{
+#include "imports_b.h"
+%}
+
+
+/*
+ To import, you can use either
+
+ %import "imports_a.i"
+
+ or
+
+ %import(module="imports_a") "imports_a.h"
+
+
+ In the first case, imports_a.i should declare the module name using
+ the %module directive.
+
+ In the second case, the file could be either a .h file, where no
+ %module directive will be found, or a swig interface file, where
+ the module option will take priority over any %module directive
+ inside the imported file.
+
+*/
+
+#if 0
+ %import "imports_a.i"
+#else
+# if 0
+ // Test Warning 401 (Python only)
+ %import "imports_a.h"
+# else
+ %import(module="imports_a") "imports_a.h"
+# endif
+#endif
+
+%include "imports_b.h"
diff --git a/trunk/Examples/test-suite/inctest.h b/trunk/Examples/test-suite/inctest.h
new file mode 100644
index 000000000..e63d833fc
--- /dev/null
+++ b/trunk/Examples/test-suite/inctest.h
@@ -0,0 +1,2 @@
+int IntegerMember;
+double DoubleMember;
diff --git a/trunk/Examples/test-suite/inctest.i b/trunk/Examples/test-suite/inctest.i
new file mode 100644
index 000000000..f33304284
--- /dev/null
+++ b/trunk/Examples/test-suite/inctest.i
@@ -0,0 +1,35 @@
+%module inctest
+
+ //
+ // This test fails if swig is not able to include
+ // the following two files:
+ //
+ // 'testdir/subdir1/hello.i'
+ // 'testdir/subdir2/hello.i'
+ //
+ // since they have the same basename 'hello', swig is only
+ // including one. This is not right, it must include both,
+ // as the well known compilers do.
+ //
+ // Also repeats the test for the import directive in subdirectories
+
+%include "testdir/test.i"
+
+
+// Bug #1162194
+%inline %{
+typedef struct {
+#include "inctest.h"
+} MY_TYPES;
+
+%}
+
+%{
+typedef struct {
+#include "inctest.h"
+} MY_THINGS;
+%}
+
+typedef struct {
+%include "inctest.h"
+} MY_THINGS;
diff --git a/trunk/Examples/test-suite/inherit.i b/trunk/Examples/test-suite/inherit.i
new file mode 100644
index 000000000..e4eee23b1
--- /dev/null
+++ b/trunk/Examples/test-suite/inherit.i
@@ -0,0 +1,19 @@
+// Test that was failing for Perl - the non-member Foo was being called when the member version was intended
+%module inherit
+
+%inline %{
+
+const char* Foo(void) {
+ return "Non-member Foo";
+}
+
+class CBase {
+public:
+ const char* Foo(void) {
+ return "CBase::Foo";
+ }
+};
+
+class CDerived : public CBase {};
+
+%}
diff --git a/trunk/Examples/test-suite/inherit_missing.i b/trunk/Examples/test-suite/inherit_missing.i
new file mode 100644
index 000000000..5ef50c50d
--- /dev/null
+++ b/trunk/Examples/test-suite/inherit_missing.i
@@ -0,0 +1,51 @@
+// Tests handling of inheritance when a base class isn't provided to SWIG
+%module inherit_missing
+
+%warnfilter(402);
+
+%{
+/* Define the class internally, but don't tell SWIG about it */
+class Foo {
+public:
+ virtual ~Foo() {}
+ virtual char *blah() {
+ return (char *) "Foo::blah";
+ }
+};
+%}
+
+/* Forward declaration. Says that Foo is a class, but doesn't provide a definition */
+
+class Foo;
+
+%newobject new_Foo;
+%delobject delete_Foo;
+%inline %{
+
+class Bar : public Foo {
+ public:
+ virtual ~Bar() {}
+ virtual char *blah() {
+ return (char *) "Bar::blah";
+ };
+};
+
+class Spam : public Bar {
+ public:
+ virtual char *blah() {
+ return (char *) "Spam::blah";
+ };
+};
+
+Foo *new_Foo() {
+ return new Foo();
+}
+
+void delete_Foo(Foo *f) {
+ delete f;
+}
+
+char *do_blah(Foo *f) {
+ return f->blah();
+}
+%}
diff --git a/trunk/Examples/test-suite/inherit_same_name.i b/trunk/Examples/test-suite/inherit_same_name.i
new file mode 100644
index 000000000..e50d064ad
--- /dev/null
+++ b/trunk/Examples/test-suite/inherit_same_name.i
@@ -0,0 +1,16 @@
+%module inherit_same_name
+
+%inline %{
+ struct Base {
+ Base() : MethodOrVariable(0) {}
+ virtual ~Base() {}
+ protected:
+ int MethodOrVariable;
+ };
+ struct Derived : Base {
+ virtual void MethodOrVariable() { Base::MethodOrVariable = 10; }
+ };
+ struct Bottom : Derived {
+ void MethodOrVariable() {}
+ };
+%}
diff --git a/trunk/Examples/test-suite/inherit_target_language.i b/trunk/Examples/test-suite/inherit_target_language.i
new file mode 100644
index 000000000..20fb93fda
--- /dev/null
+++ b/trunk/Examples/test-suite/inherit_target_language.i
@@ -0,0 +1,73 @@
+// Test using a target language specified base class, primarily for Java/C# and possibly other single inheritance languages
+
+// Note the multiple inheritance warnings don't appear because of the two techniques used in here: typemaps and %ignore
+
+%module inherit_target_language
+
+#if defined(SWIGJAVA)
+# define csbase javabase
+#endif
+
+%pragma(csharp) moduleimports=%{
+using System;
+using System.Runtime.InteropServices;
+public class TargetLanguageBase { public virtual void targetLanguageBaseMethod() {} };
+public class TargetLanguageBase2 { public virtual void targetLanguageBase2Method() {} };
+%}
+
+%pragma(java) moduleimports=%{
+class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
+class TargetLanguageBase2 { public void targetLanguageBase2Method() {} };
+%}
+
+
+%typemap(csbase) SWIGTYPE "TargetLanguageBase"
+
+// Two ways to replace a C++ base with a completely different target language base
+%ignore Base1; // another way to use the target language base
+%typemap(csbase, replace="1") Derived2 "TargetLanguageBase"
+
+%inline %{
+struct Base1 { virtual ~Base1() {} };
+struct Base2 { virtual ~Base2() {} };
+struct Derived1 : Base1 {};
+struct Derived2 : Base2 {};
+%}
+
+// Multiple inheritance
+%ignore MBase1a;
+%ignore MBase1b;
+%typemap(csbase, replace="1") MultipleDerived2 "TargetLanguageBase"
+
+%inline %{
+struct MBase1a { virtual ~MBase1a() {} virtual void a() {} };
+struct MBase1b { virtual ~MBase1b() {} virtual void b() {} };
+struct MBase2a { virtual ~MBase2a() {} virtual void c() {} };
+struct MBase2b { virtual ~MBase2b() {} virtual void d() {} };
+struct MultipleDerived1 : MBase1a, MBase1b {};
+struct MultipleDerived2 : MBase1a, MBase2b {};
+%}
+
+
+%ignore MBase3a;
+%ignore MBase4b;
+%typemap(csbase) MultipleDerived3 ""
+%typemap(csbase) MultipleDerived4 ""
+
+%inline %{
+struct MBase3a { virtual ~MBase3a() {} virtual void e() {} };
+struct MBase3b { virtual ~MBase3b() {} virtual void f() {} };
+struct MBase4a { virtual ~MBase4a() {} virtual void g() {} };
+struct MBase4b { virtual ~MBase4b() {} virtual void h() {} };
+struct MultipleDerived3 : MBase3a, MBase3b {};
+struct MultipleDerived4 : MBase4a, MBase4b {};
+%}
+
+// Replace a C++ base, but only classes that do not have a C++ base
+%typemap(csbase, notderived="1") SWIGTYPE "TargetLanguageBase2"
+
+%inline %{
+struct BaseX { virtual ~BaseX() {}; void basex() {} };
+struct DerivedX : BaseX { void derivedx() {} };
+%}
+
diff --git a/trunk/Examples/test-suite/inherit_void_arg.i b/trunk/Examples/test-suite/inherit_void_arg.i
new file mode 100644
index 000000000..9b04038f1
--- /dev/null
+++ b/trunk/Examples/test-suite/inherit_void_arg.i
@@ -0,0 +1,18 @@
+%module inherit_void_arg
+
+%inline %{
+
+class A {
+public:
+ virtual ~A() { }
+
+ virtual void f(void) = 0;
+};
+
+class B : public A {
+public:
+ void f() { }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/inline_initializer.i b/trunk/Examples/test-suite/inline_initializer.i
new file mode 100644
index 000000000..35da6daea
--- /dev/null
+++ b/trunk/Examples/test-suite/inline_initializer.i
@@ -0,0 +1,12 @@
+%module inline_initializer
+
+%inline %{
+class Foo {
+ int x;
+public:
+ Foo(int a);
+};
+
+Foo::Foo(int a) : x(a) { }
+
+%}
diff --git a/trunk/Examples/test-suite/inout.i b/trunk/Examples/test-suite/inout.i
new file mode 100644
index 000000000..dc6db0ecb
--- /dev/null
+++ b/trunk/Examples/test-suite/inout.i
@@ -0,0 +1,48 @@
+%module inout
+
+%include "typemaps.i"
+%include "std_pair.i"
+
+%{
+ inline void AddOne3(double* a, double* b, double* c) {
+ *a += 1;
+ *b += 1;
+ *c += 1;
+ }
+
+ inline void AddOne1(double* a) {
+ *a += 1;
+ }
+
+ inline void AddOne1p(std::pair<double, double>* p) {
+ p->first += 1;
+ p->second += 1;
+ }
+
+ inline void AddOne2p(std::pair<double, double>* p,double* a) {
+ *a += 1;
+ p->first += 1;
+ p->second += 1;
+ }
+
+ inline void AddOne3p(double* a, std::pair<double, double>* p,double* b) {
+ *a += 1;
+ *b += 1;
+ p->first += 1;
+ p->second += 1;
+ }
+
+ inline void AddOne1r(double& a) {
+ a += 1;
+ }
+
+%}
+
+%template() std::pair<double, double>;
+
+void AddOne1(double* INOUT);
+void AddOne3(double* INOUT, double* INOUT, double* INOUT);
+void AddOne1p(std::pair<double, double>* INOUT);
+void AddOne2p(std::pair<double, double>* INOUT, double* INOUT);
+void AddOne3p(double* INOUT, std::pair<double, double>* INOUT, double* INOUT);
+void AddOne1r(double& INOUT);
diff --git a/trunk/Examples/test-suite/inplaceadd.i b/trunk/Examples/test-suite/inplaceadd.i
new file mode 100644
index 000000000..91ef84bd2
--- /dev/null
+++ b/trunk/Examples/test-suite/inplaceadd.i
@@ -0,0 +1,40 @@
+%module inplaceadd
+%{
+#include <iostream>
+%}
+
+
+%inline %{
+ struct A
+ {
+ int val;
+
+ A(int v): val(v)
+ {
+ }
+
+ A& operator+=(int v)
+ {
+ val += v;
+ return *this;
+ }
+
+ A& operator+=(const A& a)
+ {
+ val += a.val;
+ return *this;
+ }
+
+ A& operator-=(int v)
+ {
+ val -= v;
+ return *this;
+ }
+
+ A& operator*=(int v)
+ {
+ val *= v;
+ return *this;
+ }
+ };
+%}
diff --git a/trunk/Examples/test-suite/input.i b/trunk/Examples/test-suite/input.i
new file mode 100644
index 000000000..6cef3f9f5
--- /dev/null
+++ b/trunk/Examples/test-suite/input.i
@@ -0,0 +1,41 @@
+%module input
+
+%apply int *INPUT {int *bar};
+
+%typemap(out, fragment=SWIG_From_frag(int)) int *foo {
+ if ($1) {
+ $result = SWIG_From(int)(*$1);
+ } else {
+ $result = SWIG_Py_Void();
+ }
+}
+
+%inline
+{
+ struct Foo {
+ int *foo(int *bar = 0) {
+ if (bar) {
+ *bar *= 2;
+ }
+ return (bar) ? bar : 0;
+ }
+ };
+}
+
+%include std_string.i
+%apply std::string *INPUT {std::string *bar};
+
+%typemap(out, fragment=SWIG_From_frag(std::string)) std::string *sfoo {
+ if ($1) {
+ $result = SWIG_From(std::string)(*$1);
+ } else {
+ $result = SWIG_Py_Void();
+ }
+}
+
+%inline %{
+ std::string *sfoo(std::string *bar = 0) {
+ if (bar) *bar += " world";
+ return (bar) ? bar : 0;
+ }
+%}
diff --git a/trunk/Examples/test-suite/insert_directive.i b/trunk/Examples/test-suite/insert_directive.i
new file mode 100644
index 000000000..8ad966a99
--- /dev/null
+++ b/trunk/Examples/test-suite/insert_directive.i
@@ -0,0 +1,38 @@
+%module insert_directive
+
+// check %insert and the order of each insert section is correct
+
+%begin %{
+// %inserted code %begin
+int inserted_begin(int i) { return i; }
+%}
+
+%runtime %{
+// %inserted code %runtime
+int inserted_runtime(int i) { return inserted_begin(i); }
+%}
+
+%{
+// %inserted code %header
+int inserted_header1(int i) { return inserted_runtime(i); }
+%}
+
+%header %{
+// %inserted code %header
+int inserted_header2(int i) { return inserted_header1(i); }
+%}
+
+%{
+// %inserted code %header
+int inserted_header3(int i) { return inserted_header2(i); }
+%}
+
+%wrapper %{
+// %inserted code %wrapper
+int inserted_wrapper(int i) { return inserted_header3(i); }
+%}
+
+%init %{
+// %inserted code %init
+int inserted_init_value = inserted_wrapper(0);
+%}
diff --git a/trunk/Examples/test-suite/integers.i b/trunk/Examples/test-suite/integers.i
new file mode 100644
index 000000000..7f78a2a18
--- /dev/null
+++ b/trunk/Examples/test-suite/integers.i
@@ -0,0 +1,20 @@
+/* This test case is meant to be used with run tests that check that
+ -- the whole range of the integer types is supported;
+ -- errors are signalled when out-of-range values are passed.
+*/
+
+%module integers;
+
+%inline %{
+ signed char signed_char_identity(signed char x) { return x; }
+ unsigned char unsigned_char_identity(unsigned char x) { return x; }
+ signed short signed_short_identity(signed short x) { return x; }
+ unsigned short unsigned_short_identity(unsigned short x) { return x; }
+ signed int signed_int_identity(signed int x) { return x; }
+ unsigned int unsigned_int_identity(unsigned int x) { return x; }
+ signed long signed_long_identity(signed long x) { return x; }
+ unsigned long unsigned_long_identity(unsigned long x) { return x; }
+ signed long long signed_long_long_identity(signed long long x) { return x; }
+ unsigned long long unsigned_long_long_identity(unsigned long long x) { return x; }
+%}
+
diff --git a/trunk/Examples/test-suite/intermediary_classname.i b/trunk/Examples/test-suite/intermediary_classname.i
new file mode 100644
index 000000000..94858a5fb
--- /dev/null
+++ b/trunk/Examples/test-suite/intermediary_classname.i
@@ -0,0 +1,82 @@
+
+// This test is to check the intermediary class name can be changed (C# and Java only use intermediary classes at time of writing)
+%module(directors="1", jniclassname="intermediary_classname", imclassname="intermediary_classname") "intermediary_classname"
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR);
+
+// change the access to the intermediary class for testing purposes
+%pragma(java) jniclassclassmodifiers="public class";
+%pragma(csharp) imclassclassmodifiers="public class";
+
+%feature("director") Base;
+%feature("director") Derived;
+
+// Test the throws attribute in these typemaps
+%typemap(javadirectorout, throws="InstantiationException/*javadirectorout Base&*/") Base&
+ "$javaclassname.getCPtr($javacall)/* XYZ& typemap directorout*/"
+%typemap(javadirectorin, throws="ClassNotFoundException/*javadirectorin Base&*/") Base&
+ "new $javaclassname($jniinput, false)/*javadirectorin*/"
+%typemap(out, throws="IllegalAccessException/*out Base&*/") Base& {
+ // XYZ& typemap out
+ $result = 0; // remove unused variable warning
+}
+%inline %{
+
+template<class T> T maximum(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;
+ }
+ void testconst(const T x) { }
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+class Base {
+public:
+ Base() : mVectInt(0) {}
+ Base(Base *b) : mVectInt(0) {}
+ virtual ~Base() {}
+ virtual Base& m1(Base &b) { return b; }
+ virtual Base& m1out() { static Base b; return b; }
+ virtual Base* m2(Base *b) { return b; }
+// virtual Base m3(Base b) { return b; }
+ vector<int> mVectInt;
+ int mInt;
+ enum en { en1, en2 };
+ en enummethod(en e) { return e; }
+};
+class Derived : public Base {
+public:
+ Derived(Base *b) : Base(b) {}
+ virtual Base& m1(Base &b) { return b; }
+ virtual Base* m2(Base *b) { return b; }
+// virtual Base m3(Base b) { return b; }
+ void throwspec() throw (int, Base) {}
+};
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%template(maxint) maximum<int>;
+%template(maxdouble) maximum<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+%template(maxintp) maximum<int (*)[10]>;
+%template(vecintp) vector<int (*)[10]>;
+
+
diff --git a/trunk/Examples/test-suite/java/Makefile.in b/trunk/Examples/test-suite/java/Makefile.in
new file mode 100644
index 000000000..3cb7c0c53
--- /dev/null
+++ b/trunk/Examples/test-suite/java/Makefile.in
@@ -0,0 +1,92 @@
+#######################################################################
+# Makefile for java test-suite
+#######################################################################
+
+LANGUAGE = java
+JAVA = java
+JAVAC = javac
+SCRIPTSUFFIX = _runme.java
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@/..
+top_builddir = @top_builddir@/..
+
+C_TEST_CASES = \
+ java_lib_arrays \
+ java_lib_various
+
+CPP_TEST_CASES = \
+ enum_thorough_proper \
+ enum_thorough_simple \
+ enum_thorough_typeunsafe \
+ exception_partial_info \
+ intermediary_classname \
+ java_constants \
+ java_director \
+ java_enums \
+ java_lib_arrays_dimensionless \
+ java_lib_various \
+ java_jnitypes \
+ java_pgcpp \
+ java_pragmas \
+ java_prepost \
+ java_throws \
+ java_typemaps_proxy \
+ java_typemaps_typewrapper
+# li_boost_intrusive_ptr
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+JAVA_PACKAGE = $*
+SWIGOPT += -package $(JAVA_PACKAGE)
+INTERFACEDIR = ../../
+
+# Custom tests - tests with additional commandline options
+nspace.%: JAVA_PACKAGE = $*Package
+nspace_extend.%: JAVA_PACKAGE = $*Package
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +(cd $(JAVA_PACKAGE) && $(swig_and_compile_cpp))
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +(cd $(JAVA_PACKAGE) && $(swig_and_compile_c))
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +(cd $(JAVA_PACKAGE) && $(swig_and_compile_multi_cpp))
+ $(run_testcase)
+
+# Makes a directory for the testcase if it does not exist
+setup = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi; \
+ if [ ! -d $(JAVA_PACKAGE) ]; then \
+ mkdir $(JAVA_PACKAGE); \
+ 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, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X.
+run_testcase = \
+ cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
+ env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \
+ fi
+
+# Clean: remove testcase directories
+%.clean:
+ @if [ -d $(JAVA_PACKAGE) ]; then \
+ rm -rf $(JAVA_PACKAGE); \
+ fi
+
+clean:
+ @rm -f *.class hs_err*.log
diff --git a/trunk/Examples/test-suite/java/README b/trunk/Examples/test-suite/java/README
new file mode 100644
index 000000000..b8b7416d9
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/aggregate_runme.java b/trunk/Examples/test-suite/java/aggregate_runme.java
new file mode 100644
index 000000000..f25728bf2
--- /dev/null
+++ b/trunk/Examples/test-suite/java/aggregate_runme.java
@@ -0,0 +1,39 @@
+
+import aggregate.*;
+
+public class aggregate_runme {
+
+ static {
+ try {
+ System.loadLibrary("aggregate");
+ } 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[]) {
+
+ // Confirm that move() returns correct results under normal use
+ int result = aggregate.move(aggregate.UP);
+ if (result != aggregate.UP) throw new RuntimeException("UP failed");
+
+ result = aggregate.move(aggregate.DOWN);
+ if (result != aggregate.DOWN) throw new RuntimeException("DOWN failed");
+
+ result = aggregate.move(aggregate.LEFT);
+ if (result != aggregate.LEFT) throw new RuntimeException("LEFT failed");
+
+ result = aggregate.move(aggregate.RIGHT);
+ if (result != aggregate.RIGHT) throw new RuntimeException("RIGHT failed");
+
+ // Confirm that move() raises an exception when the contract is violated
+ try {
+ aggregate.move(0);
+ throw new RuntimeException("0 test failed");
+ }
+ catch (IllegalArgumentException e) {
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/allprotected_runme.java b/trunk/Examples/test-suite/java/allprotected_runme.java
new file mode 100644
index 000000000..aa5413a95
--- /dev/null
+++ b/trunk/Examples/test-suite/java/allprotected_runme.java
@@ -0,0 +1,74 @@
+import allprotected.*;
+
+public class allprotected_runme {
+ static {
+ try {
+ System.loadLibrary("allprotected");
+ } 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[])
+ {
+ MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase");
+ mpb.accessProtected();
+ }
+}
+
+class MyProtectedBase extends ProtectedBase
+{
+ MyProtectedBase(String name) {
+ super(name);
+ }
+ void accessProtected() {
+ String s = virtualMethod();
+ if (!s.equals("ProtectedBase"))
+ throw new RuntimeException("Failed");
+
+ Klass k = instanceMethod(new Klass("xyz"));
+ if (!k.getName().equals("xyz"))
+ throw new RuntimeException("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"));
+ if (!k.getName().equals("xyz"))
+ throw new RuntimeException("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"), "abc");
+ if (!k.getName().equals("abc"))
+ throw new RuntimeException("Failed");
+
+ k = ProtectedBase.staticMethod(new Klass("abc"));
+ if (!k.getName().equals("abc"))
+ throw new RuntimeException("Failed");
+
+ k = ProtectedBase.staticOverloaded(new Klass("xyz"));
+ if (!k.getName().equals("xyz"))
+ throw new RuntimeException("Failed");
+
+ k = ProtectedBase.staticOverloaded(new Klass("xyz"), "abc");
+ if (!k.getName().equals("abc"))
+ throw new RuntimeException("Failed");
+
+ setInstanceMemberVariable(30);
+ int i = getInstanceMemberVariable();
+ if (i != 30)
+ throw new RuntimeException("Failed");
+
+ setStaticMemberVariable(40);
+ i = getStaticMemberVariable();
+ if (i != 40)
+ throw new RuntimeException("Failed");
+
+ i = staticConstMemberVariable;
+ if (i != 20)
+ throw new RuntimeException("Failed");
+
+ setAnEnum(ProtectedBase.AnEnum.EnumVal1);
+ ProtectedBase.AnEnum ae = getAnEnum();
+ if (ae != ProtectedBase.AnEnum.EnumVal1)
+ throw new RuntimeException("Failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/apply_signed_char_runme.java b/trunk/Examples/test-suite/java/apply_signed_char_runme.java
new file mode 100644
index 000000000..531558e00
--- /dev/null
+++ b/trunk/Examples/test-suite/java/apply_signed_char_runme.java
@@ -0,0 +1,36 @@
+import apply_signed_char.*;
+
+public class apply_signed_char_runme {
+
+ static {
+ try {
+ System.loadLibrary("apply_signed_char");
+ } 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[]) {
+ byte smallnum = -127;
+ if (apply_signed_char.CharValFunction(smallnum) != smallnum) throw new RuntimeException("failed");
+ if (apply_signed_char.CCharValFunction(smallnum) != smallnum) throw new RuntimeException("failed");
+ if (apply_signed_char.CCharRefFunction(smallnum) != smallnum) throw new RuntimeException("failed");
+
+ apply_signed_char.setGlobalchar(smallnum);
+ if (apply_signed_char.getGlobalchar() != smallnum) throw new RuntimeException("failed");
+ if (apply_signed_char.getGlobalconstchar() != -110) throw new RuntimeException("failed");
+
+ DirectorTest d = new DirectorTest();
+ if (d.CharValFunction(smallnum) != smallnum) throw new RuntimeException("failed");
+ if (d.CCharValFunction(smallnum) != smallnum) throw new RuntimeException("failed");
+ if (d.CCharRefFunction(smallnum) != smallnum) throw new RuntimeException("failed");
+
+ d.setMemberchar(smallnum);
+ if (d.getMemberchar() != smallnum) throw new RuntimeException("failed");
+ if (d.getMemberconstchar() != -112) throw new RuntimeException("failed");
+
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/java/apply_strings_runme.java b/trunk/Examples/test-suite/java/apply_strings_runme.java
new file mode 100644
index 000000000..0b9f78085
--- /dev/null
+++ b/trunk/Examples/test-suite/java/apply_strings_runme.java
@@ -0,0 +1,24 @@
+import apply_strings.*;
+
+public class apply_strings_runme {
+
+ static {
+ try {
+ System.loadLibrary("apply_strings");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ private static String TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+ public static void main(String argv[]) {
+ if (!apply_strings.UCharFunction(TEST_MESSAGE).equals(TEST_MESSAGE)) throw new RuntimeException("UCharFunction failed");
+ if (!apply_strings.SCharFunction(TEST_MESSAGE).equals(TEST_MESSAGE)) throw new RuntimeException("SCharFunction failed");
+ SWIGTYPE_p_char pChar = apply_strings.CharFunction(null);
+ if (pChar != null) throw new RuntimeException("CharFunction failed");
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/java/array_member_runme.java b/trunk/Examples/test-suite/java/array_member_runme.java
new file mode 100644
index 000000000..2f17bb0c2
--- /dev/null
+++ b/trunk/Examples/test-suite/java/array_member_runme.java
@@ -0,0 +1,35 @@
+import array_member.*;
+
+public class array_member_runme {
+ static {
+ try {
+ System.loadLibrary("array_member");
+ } 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();
+ f.setData(array_member.getGlobal_data());
+
+ for (int i=0; i<8; i++) {
+ if (array_member.get_value(f.getData(),i) != array_member.get_value(array_member.getGlobal_data(),i))
+ throw new RuntimeException("Bad array assignment");
+ }
+
+ for (int i=0; i<8; i++) {
+ array_member.set_value(f.getData(),i,-i);
+ }
+
+ array_member.setGlobal_data(f.getData());
+
+ for (int i=0; i<8; i++) {
+ if (array_member.get_value(f.getData(),i) != array_member.get_value(array_member.getGlobal_data(),i))
+ throw new RuntimeException("Bad array assignment");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/arrays_global_twodim_runme.java b/trunk/Examples/test-suite/java/arrays_global_twodim_runme.java
new file mode 100644
index 000000000..2cbc0138a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/char_strings_runme.java b/trunk/Examples/test-suite/java/char_strings_runme.java
new file mode 100644
index 000000000..d06e7204a
--- /dev/null
+++ b/trunk/Examples/test-suite/java/char_strings_runme.java
@@ -0,0 +1,163 @@
+import char_strings.*;
+
+public class char_strings_runme {
+
+ static {
+ try {
+ System.loadLibrary("char_strings");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ private static String CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+ private static String OTHERLAND_MSG = "Little message from the safe world.";
+
+ public static void main(String argv[]) {
+
+ long count = 10000;
+ long i = 0;
+
+ // get functions
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetCharHeapString();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test char get 1 failed, iteration " + i);
+ char_strings.DeleteCharHeapString();
+ }
+
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetConstCharProgramCodeString();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test char get 2 failed, iteration " + i);
+ char_strings.DeleteCharHeapString();
+ }
+
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetCharStaticString();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test char get 3 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetCharStaticStringFixed();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test char get 4 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetConstCharStaticStringFixed();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test char get 5 failed, iteration " + i);
+ }
+
+ // set functions
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharHeapString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 1 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharStaticString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 2 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharArrayStaticString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 3 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharHeapString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 4 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharStaticString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 5 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharArrayStaticString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 6 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharConstStaticString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 7 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharConstStaticString(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char set 8 failed, iteration " + i);
+ }
+
+ // get set function
+ for (i=0; i<count; i++) {
+ String ping = OTHERLAND_MSG + i;
+ String pong = char_strings.CharPingPong(ping);
+ if (!ping.equals(pong))
+ throw new RuntimeException("Test PingPong 1 failed.\nExpected:" + ping + "\nReceived:" + pong);
+ }
+
+ // variables
+ for (i=0; i<count; i++) {
+ char_strings.setGlobal_char(OTHERLAND_MSG + i);
+ if (!char_strings.getGlobal_char().equals(OTHERLAND_MSG + i))
+ throw new RuntimeException("Test variables 1 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ char_strings.setGlobal_char_array1(OTHERLAND_MSG + i);
+ if (!char_strings.getGlobal_char_array1().equals(OTHERLAND_MSG + i))
+ throw new RuntimeException("Test variables 2 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ char_strings.setGlobal_char_array2(OTHERLAND_MSG + i);
+ if (!char_strings.getGlobal_char_array2().equals(OTHERLAND_MSG + i))
+ throw new RuntimeException("Test variables 3 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.getGlobal_const_char().equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test variables 4 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.getGlobal_const_char_array1().equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test variables 5 failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.getGlobal_const_char_array2().equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test variables 6 failed, iteration " + i);
+ }
+
+ // char *& tests
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetCharPointerRef();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test char pointer ref get failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetCharPointerRef(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test char pointer ref set failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ String str = char_strings.GetConstCharPointerRef();
+ if (!str.equals(CPLUSPLUS_MSG))
+ throw new RuntimeException("Test const char pointer ref get failed, iteration " + i);
+ }
+
+ for (i=0; i<count; i++) {
+ if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
+ throw new RuntimeException("Test const char pointer ref set failed, iteration " + i);
+ }
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/java/cpp_typedef_runme.java b/trunk/Examples/test-suite/java/cpp_typedef_runme.java
new file mode 100644
index 000000000..75bb47447
--- /dev/null
+++ b/trunk/Examples/test-suite/java/cpp_typedef_runme.java
@@ -0,0 +1,34 @@
+
+// This is the cpp_typedef runtime testcase. It checks that proxy 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[]) {
+
+ Foo f = new Foo();
+ SWIGTYPE_p_Bar pbar = f.bar();
+ pbar = Foo.sbar();
+
+ 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/trunk/Examples/test-suite/java/default_args_runme.java b/trunk/Examples/test-suite/java/default_args_runme.java
new file mode 100644
index 000000000..20a7949e4
--- /dev/null
+++ b/trunk/Examples/test-suite/java/default_args_runme.java
@@ -0,0 +1,150 @@
+
+import default_args.*;
+
+public class default_args_runme {
+ static {
+ try {
+ System.loadLibrary("default_args");
+ } 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 (default_args.anonymous() != 7771)
+ throw new RuntimeException("anonymous (1) failed");
+ if (default_args.anonymous(1234) != 1234)
+ throw new RuntimeException("anonymous (2) failed");
+
+ if (default_args.booltest() != true)
+ throw new RuntimeException("booltest (1) failed");
+ if (default_args.booltest(true) != true)
+ throw new RuntimeException("booltest (2) failed");
+ if (default_args.booltest(false) != false)
+ throw new RuntimeException("booltest (3) failed");
+
+ EnumClass ec = new EnumClass();
+ if (ec.blah() != true)
+ throw new RuntimeException("EnumClass failed");
+
+ if (default_args.casts1() != null)
+ throw new RuntimeException("casts1 failed");
+
+ if (!default_args.casts2().equals("Hello"))
+ throw new RuntimeException("casts2 failed");
+
+ if (!default_args.casts1("Ciao").equals("Ciao"))
+ throw new RuntimeException("casts1 not default failed");
+
+ if (default_args.chartest1() != 'x')
+ throw new RuntimeException("chartest1 failed");
+
+ if (default_args.chartest2() != '\0')
+ throw new RuntimeException("chartest2 failed");
+
+ if (default_args.chartest1('y') != 'y')
+ throw new RuntimeException("chartest1 not default failed");
+
+ if (default_args.chartest1('y') != 'y')
+ throw new RuntimeException("chartest1 not default failed");
+
+ if (default_args.reftest1() != 42)
+ throw new RuntimeException("reftest1 failed");
+
+ if (default_args.reftest1(400) != 400)
+ throw new RuntimeException("reftest1 not default failed");
+
+ if (!default_args.reftest2().equals("hello"))
+ throw new RuntimeException("reftest2 failed");
+
+ // rename
+ Foo foo = new Foo();
+ foo.newname();
+ foo.newname(10);
+ foo.renamed3arg(10, 10.0);
+ foo.renamed2arg(10);
+ foo.renamed1arg();
+
+ // exception specifications
+ try {
+ default_args.exceptionspec();
+ throw new RuntimeException("exceptionspec 1 failed");
+ } catch (RuntimeException e) {
+ }
+ try {
+ default_args.exceptionspec(-1);
+ throw new RuntimeException("exceptionspec 2 failed");
+ } catch (RuntimeException e) {
+ }
+ try {
+ default_args.exceptionspec(100);
+ throw new RuntimeException("exceptionspec 3 failed");
+ } catch (RuntimeException e) {
+ }
+ Except ex = new Except(false);
+ try {
+ ex.exspec();
+ throw new RuntimeException("exspec 1 failed");
+ } catch (RuntimeException e) {
+ }
+ try {
+ ex.exspec(-1);
+ throw new RuntimeException("exspec 2 failed");
+ } catch (RuntimeException e) {
+ }
+ try {
+ ex.exspec(100);
+ throw new RuntimeException("exspec 3 failed");
+ } catch (RuntimeException e) {
+ }
+ try {
+ ex = new Except(true);
+ throw new RuntimeException("Except constructor 1 failed");
+ } catch (RuntimeException e) {
+ }
+ try {
+ ex = new Except(true, -2);
+ throw new RuntimeException("Except constructor 2 failed");
+ } catch (RuntimeException e) {
+ }
+
+ // Default parameters in static class methods
+ if (Statics.staticmethod() != 10+20+30)
+ throw new RuntimeException("staticmethod 1 failed");
+ if (Statics.staticmethod(100) != 100+20+30)
+ throw new RuntimeException("staticmethod 2 failed");
+ if (Statics.staticmethod(100,200,300) != 100+200+300)
+ throw new RuntimeException("staticmethod 3 failed");
+
+
+ Tricky tricky = new Tricky();
+ if (tricky.privatedefault() != 200)
+ throw new RuntimeException("privatedefault failed");
+ if (tricky.protectedint() != 2000)
+ throw new RuntimeException("protectedint failed");
+ if (tricky.protecteddouble() != 987.654)
+ throw new RuntimeException("protecteddouble failed");
+ if (tricky.functiondefault() != 500)
+ throw new RuntimeException("functiondefault failed");
+ if (tricky.contrived() != 'X')
+ throw new RuntimeException("contrived failed");
+
+ if (default_args.constructorcall().getVal() != -1)
+ throw new RuntimeException("constructorcall test 1 failed");
+
+ if (default_args.constructorcall(new Klass(2222)).getVal() != 2222)
+ throw new RuntimeException("constructorcall test 2 failed");
+
+ if (default_args.constructorcall(new Klass()).getVal() != -1)
+ throw new RuntimeException("constructorcall test 3 failed");
+
+ // const methods
+ ConstMethods cm = new ConstMethods();
+ if (cm.coo() != 20)
+ throw new RuntimeException("coo test 1 failed");
+ if (cm.coo(1.0) != 20)
+ throw new RuntimeException("coo test 2 failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/default_constructor_runme.java b/trunk/Examples/test-suite/java/default_constructor_runme.java
new file mode 100644
index 000000000..6473c4099
--- /dev/null
+++ b/trunk/Examples/test-suite/java/default_constructor_runme.java
@@ -0,0 +1,32 @@
+
+import default_constructor.*;
+
+public class default_constructor_runme {
+ static {
+ try {
+ System.loadLibrary("default_constructor");
+ } 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[])
+ {
+ // calling protected destructor test
+ try {
+ G g = new G();
+ g.delete();
+ throw new RuntimeException("Protected destructor exception should have been thrown");
+ } catch (UnsupportedOperationException e) {
+ }
+
+ // calling private destructor test
+ try {
+ FFF f = new FFF();
+ f.delete();
+ throw new RuntimeException("Private destructor exception should have been thrown");
+ } catch (UnsupportedOperationException e) {
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/director_abstract_runme.java b/trunk/Examples/test-suite/java/director_abstract_runme.java
new file mode 100644
index 000000000..0453fb7f0
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_abstract_runme.java
@@ -0,0 +1,46 @@
+
+import director_abstract.*;
+
+public class director_abstract_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_abstract");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ director_abstract_MyFoo a = new director_abstract_MyFoo();
+
+ if (!a.ping().equals("director_abstract_MyFoo::ping()")) {
+ throw new RuntimeException ( "a.ping()" );
+ }
+
+ if (!a.pong().equals("Foo::pong();director_abstract_MyFoo::ping()")) {
+ throw new RuntimeException ( "a.pong()" );
+ }
+
+ director_abstract_BadFoo b = new director_abstract_BadFoo();
+ try {
+ b.ping();
+ System.out.println( "Test failed. An attempt to call a pure virtual method should throw an exception" );
+ System.exit(1);
+ }
+ catch (RuntimeException e) {
+ }
+ }
+}
+
+class director_abstract_MyFoo extends Foo {
+ public String ping() {
+ return "director_abstract_MyFoo::ping()";
+ }
+}
+
+class director_abstract_BadFoo extends Foo {
+}
+
diff --git a/trunk/Examples/test-suite/java/director_basic_runme.java b/trunk/Examples/test-suite/java/director_basic_runme.java
new file mode 100644
index 000000000..16a46aa35
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_basic_runme.java
@@ -0,0 +1,72 @@
+
+import director_basic.*;
+
+public class director_basic_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_basic");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ director_basic_MyFoo a = new director_basic_MyFoo();
+
+ if (!a.ping().equals("director_basic_MyFoo::ping()")) {
+ throw new RuntimeException ( "a.ping()" );
+ }
+
+ if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) {
+ throw new RuntimeException ( "a.pong()" );
+ }
+
+ Foo b = new Foo();
+
+ if (!b.ping().equals("Foo::ping()")) {
+ throw new RuntimeException ( "b.ping()" );
+ }
+
+ if (!b.pong().equals("Foo::pong();Foo::ping()")) {
+ throw new RuntimeException ( "b.pong()" );
+ }
+
+ A1 a1 = new A1(1, false);
+ a1.delete();
+
+ {
+ MyOverriddenClass my = new MyOverriddenClass();
+
+ my.expectNull = true;
+ if (MyClass.call_pmethod(my, null) != null)
+ throw new RuntimeException("null pointer marshalling problem");
+
+ Bar myBar = new Bar();
+ my.expectNull = false;
+ Bar myNewBar = MyClass.call_pmethod(my, myBar);
+ if (myNewBar == null)
+ throw new RuntimeException("non-null pointer marshalling problem");
+ myNewBar.setX(10);
+ }
+ }
+}
+
+class director_basic_MyFoo extends Foo {
+ public String ping() {
+ return "director_basic_MyFoo::ping()";
+ }
+}
+
+class MyOverriddenClass extends MyClass {
+ public boolean expectNull = false;
+ public boolean nonNullReceived = false;
+ public Bar pmethod(Bar b) {
+ if ( expectNull && (b != null) )
+ throw new RuntimeException("null not received as expected");
+ return b;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_classes_runme.java b/trunk/Examples/test-suite/java/director_classes_runme.java
new file mode 100644
index 000000000..013bdc75b
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_classes_runme.java
@@ -0,0 +1,207 @@
+/*
+This test demonstrates director classes when the types are classes.
+Shown are virtual function calls which use classes passed by:
+ - Value
+ - Reference
+ - Pointer
+as both parameters and return values.
+The test also demonstrates directors used with:
+ - method overloading
+ - default parameters
+Note: Methods with default parameters that call up from C++ cannot call
+the overloaded Java methods, see DefaultParms method.
+
+Expected output if PrintDebug enabled:
+------------ Start ------------
+Base - Val(444.555)
+Base - Ref(444.555)
+Base - Ptr(444.555)
+Base - FullyOverloaded(int 10)
+Base - FullyOverloaded(bool 1)
+Base - SemiOverloaded(int -678)
+Base - SemiOverloaded(bool 1)
+Base - DefaultParms(10, 2.2)
+Base - DefaultParms(10, 1.1)
+--------------------------------
+Derived - Val(444.555)
+Derived - Ref(444.555)
+Derived - Ptr(444.555)
+Derived - FullyOverloaded(int 10)
+Derived - FullyOverloaded(bool 1)
+Derived - SemiOverloaded(int -678)
+Base - SemiOverloaded(bool 1)
+Derived - DefaultParms(10, 2.2)
+Derived - DefaultParms(10, 1.1)
+--------------------------------
+JavaDerived - Val(444.555)
+JavaDerived - Ref(444.555)
+JavaDerived - Ptr(444.555)
+JavaDerived - FullyOverloaded(int 10)
+JavaDerived - FullyOverloaded(bool True)
+JavaDerived - SemiOverloaded(-678)
+Base - SemiOverloaded(bool 1)
+JavaDerived - DefaultParms(10, 2.2)
+JavaDerived - DefaultParms(10, 1.1)
+------------ Finish ------------
+*/
+
+
+import director_classes.*;
+
+public class director_classes_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_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[]) throws Throwable
+ {
+ director_classes_runme r = new director_classes_runme();
+ r.run();
+ }
+
+ void run()
+ {
+ if (director_classes.getPrintDebug()) System.out.println("------------ Start ------------ ");
+
+ Caller myCaller = new Caller();
+
+ // test C++ base class
+ {
+ Base myBase = new Base(100.0);
+ makeCalls(myCaller, myBase);
+ myBase.delete();
+ }
+
+ if (director_classes.getPrintDebug()) System.out.println("--------------------------------");
+
+ // test vanilla C++ wrapped derived class
+ {
+ Base myBase = new Derived(200.0);
+ makeCalls(myCaller, myBase);
+ myBase.delete();
+ }
+
+ if (director_classes.getPrintDebug()) System.out.println("--------------------------------");
+
+ // test director / Java derived class
+ {
+ Base myBase = new JavaDerived(300.0);
+ makeCalls(myCaller, myBase);
+ myBase.delete();
+ }
+
+ if (director_classes.getPrintDebug()) System.out.println("------------ Finish ------------ ");
+ }
+
+ void makeCalls(Caller myCaller, Base myBase)
+ {
+ String baseSimpleName = getSimpleName(myBase.getClass());
+
+ myCaller.set(myBase);
+
+ DoubleHolder dh = new DoubleHolder(444.555);
+
+ // Class pointer, reference and pass by value tests
+ if (myCaller.ValCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
+ if (myCaller.RefCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
+ if (myCaller.PtrCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
+
+ // Fully overloaded method test (all methods in base class are overloaded)
+ if (!myCaller.FullyOverloadedCall(10).equals(baseSimpleName + "::FullyOverloaded(int)")) {
+ System.out.println(myCaller.FullyOverloadedCall(10) + "----" + (baseSimpleName + "::FullyOverloaded(int)"));
+ throw new RuntimeException("failed");
+ }
+ if (!myCaller.FullyOverloadedCall(true).equals(baseSimpleName + "::FullyOverloaded(bool)")) throw new RuntimeException("failed");
+
+ // Semi overloaded method test (some methods in base class are overloaded)
+ if (!myCaller.SemiOverloadedCall(-678).equals(baseSimpleName + "::SemiOverloaded(int)")) throw new RuntimeException("failed");
+ if (!myCaller.SemiOverloadedCall(true).equals("Base" + "::SemiOverloaded(bool)")) throw new RuntimeException("failed");
+
+ // Default parameters methods test
+ if (!(myCaller.DefaultParmsCall(10, 2.2)).equals(baseSimpleName + "::DefaultParms(int, double)")) throw new RuntimeException("failed");
+ if (myBase instanceof JavaDerived) { // special handling for Java derived classes, there is no way to do this any other way
+ if (!myCaller.DefaultParmsCall(10).equals(baseSimpleName + "::DefaultParms(int, double)")) throw new RuntimeException("failed");
+ } else {
+ if (!myCaller.DefaultParmsCall(10).equals(baseSimpleName + "::DefaultParms(int)")) throw new RuntimeException("failed");
+ }
+
+ myCaller.reset();
+ }
+
+ // Same as Class.getSimpleName() which is not present in all jdks
+ static String getSimpleName(Class klass) {
+ String fullName = klass.getName();
+ Package packag = klass.getPackage();
+ String simpleName = null;
+ if (packag != null)
+ simpleName = fullName.replaceAll(packag.getName() + ".", "");
+ else
+ simpleName = fullName;
+ return simpleName;
+ }
+}
+
+
+class JavaDerived extends Base
+{
+ public JavaDerived(double dd)
+ {
+ super(dd);
+ }
+
+ public DoubleHolder Val(DoubleHolder x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - Val(" + x.getVal() + ")");
+ return x;
+ }
+ public DoubleHolder Ref(DoubleHolder x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - Ref(" + x.getVal() + ")");
+ return x;
+ }
+ public DoubleHolder Ptr(DoubleHolder x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - Ptr(" + x.getVal() + ")");
+ return x;
+ }
+ public String FullyOverloaded(int x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - FullyOverloaded(int " + x + ")");
+ return "JavaDerived::FullyOverloaded(int)";
+ }
+ public String FullyOverloaded(boolean x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - FullyOverloaded(bool " + x + ")");
+ return "JavaDerived::FullyOverloaded(bool)";
+ }
+ // Note no SemiOverloaded(bool x) method
+ public String SemiOverloaded(int x)
+ {
+ String ret = "JavaDerived::SemiOverloaded(int)";
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - SemiOverloaded(" + x + ")");
+ return ret;
+ }
+ public String DefaultParms(int x, double y)
+ {
+ String ret = "JavaDerived::DefaultParms(int, double)";
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - DefaultParms(" + x + ", " + y + ")");
+ return ret;
+ }
+ // Note the following method can never be called from unmanaged code.
+ // It is here only for code that calls it directly from managed code.
+ // But should always be defined to ensure behaviour is consistent
+ // independent of where DefaultParsms is called from (managed or unmanaged code).
+ // Note this method can never be called from unmanaged code
+ public String DefaultParms(int x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - DefaultParms(" + x + ")");
+ return DefaultParms(x, 1.1/*use C++ default here*/);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_classic_runme.java b/trunk/Examples/test-suite/java/director_classic_runme.java
new file mode 100644
index 000000000..50ea2b8d3
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_classic_runme.java
@@ -0,0 +1,318 @@
+import director_classic.*;
+
+public class director_classic_runme {
+ static {
+ try {
+ System.loadLibrary("director_classic");
+ } 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[])
+ {
+ {
+ Person person = new Person();
+ check(person, "Person");
+ person.delete();
+ }
+ {
+ Person person = new Child();
+ check(person, "Child");
+ person.delete();
+ }
+ {
+ Person person = new GrandChild();
+ check(person, "GrandChild");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangPerson();
+ check(person, "TargetLangPerson");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangChild();
+ check(person, "TargetLangChild");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangGrandChild();
+ check(person, "TargetLangGrandChild");
+ person.delete();
+ }
+
+ // Semis - don't override id() in target language
+ {
+ Person person = new TargetLangSemiPerson();
+ check(person, "Person");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangSemiChild();
+ check(person, "Child");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangSemiGrandChild();
+ check(person, "GrandChild");
+ person.delete();
+ }
+
+ // Orphans - don't override id() in C++
+ {
+ Person person = new OrphanPerson();
+ check(person, "Person");
+ person.delete();
+ }
+ {
+ Person person = new OrphanChild();
+ check(person, "Child");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangOrphanPerson();
+ check(person, "TargetLangOrphanPerson");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangOrphanChild();
+ check(person, "TargetLangOrphanChild");
+ person.delete();
+ }
+
+ // Duals - id() makes an upcall to the base id()
+ {
+ Person person = new TargetLangDualPerson();
+ check(person, "TargetLangDualPerson + Person");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangDualChild();
+ check(person, "TargetLangDualChild + Child");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangDualGrandChild();
+ check(person, "TargetLangDualGrandChild + GrandChild");
+ person.delete();
+ }
+
+ // Mix Orphans and Duals
+ {
+ Person person = new TargetLangDualOrphanPerson();
+ check(person, "TargetLangDualOrphanPerson + Person");
+ person.delete();
+ }
+ {
+ Person person = new TargetLangDualOrphanChild();
+ check(person, "TargetLangDualOrphanChild + Child");
+ person.delete();
+ }
+ }
+
+ static void check(Person person, String expected) {
+ String ret;
+ // Normal target language polymorphic call
+ ret = person.id();
+ if (debug)
+ System.out.println(ret);
+ if (!ret.equals(expected))
+ throw new RuntimeException("Failed. Received: " + ret + " Expected: " + expected);
+
+ // Polymorphic call from C++
+ Caller caller = new Caller();
+ caller.setCallback(person);
+ ret = caller.call();
+ if (debug)
+ System.out.println(ret);
+ if (!ret.equals(expected))
+ throw new RuntimeException("Failed. Received: " + ret + " Expected: " + expected);
+
+ // Polymorphic call of object created in target language and passed to C++ and back again
+ Person baseclass = caller.baseClass();
+ ret = baseclass.id();
+ if (debug)
+ System.out.println(ret);
+ if (!ret.equals(expected))
+ throw new RuntimeException("Failed. Received: " + ret + " Expected: " + expected);
+
+ caller.resetCallback();
+ if (debug)
+ System.out.println("----------------------------------------");
+ }
+ static boolean debug = false;
+}
+
+class TargetLangPerson extends Person
+{
+ public TargetLangPerson()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangPerson";
+ return identifier;
+ }
+}
+
+class TargetLangChild extends Child
+{
+ public TargetLangChild()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangChild";
+ return identifier;
+ }
+}
+
+class TargetLangGrandChild extends GrandChild
+{
+ public TargetLangGrandChild()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangGrandChild";
+ return identifier;
+ }
+}
+
+// Semis - don't override id() in target language
+class TargetLangSemiPerson extends Person
+{
+ public TargetLangSemiPerson()
+ {
+ super();
+ }
+ // No id() override
+}
+
+class TargetLangSemiChild extends Child
+{
+ public TargetLangSemiChild()
+ {
+ super();
+ }
+ // No id() override
+}
+
+class TargetLangSemiGrandChild extends GrandChild
+{
+ public TargetLangSemiGrandChild()
+ {
+ super();
+ }
+ // No id() override
+}
+
+// Orphans - don't override id() in C++
+class TargetLangOrphanPerson extends OrphanPerson
+{
+ public TargetLangOrphanPerson()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangOrphanPerson";
+ return identifier;
+ }
+}
+
+class TargetLangOrphanChild extends OrphanChild
+{
+ public TargetLangOrphanChild()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangOrphanChild";
+ return identifier;
+ }
+}
+
+// Duals - id() makes an upcall to the base id()
+class TargetLangDualPerson extends Person
+{
+ public TargetLangDualPerson()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangDualPerson + " + super.id();
+ return identifier;
+ }
+}
+
+class TargetLangDualChild extends Child
+{
+ public TargetLangDualChild()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangDualChild + " + super.id();
+ return identifier;
+ }
+}
+
+class TargetLangDualGrandChild extends GrandChild
+{
+ public TargetLangDualGrandChild()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangDualGrandChild + " + super.id();
+ return identifier;
+ }
+}
+
+// Mix Orphans and Duals
+class TargetLangDualOrphanPerson extends OrphanPerson
+{
+ public TargetLangDualOrphanPerson()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangDualOrphanPerson + " + super.id();
+ return identifier;
+ }
+}
+
+class TargetLangDualOrphanChild extends OrphanChild
+{
+ public TargetLangDualOrphanChild()
+ {
+ super();
+ }
+
+ public String id()
+ {
+ String identifier = "TargetLangDualOrphanChild + " + super.id();
+ return identifier;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_default_runme.java b/trunk/Examples/test-suite/java/director_default_runme.java
new file mode 100644
index 000000000..b71e45e25
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_default_runme.java
@@ -0,0 +1,51 @@
+
+import director_default.*;
+
+public class director_default_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_default");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ {
+ director_default_MyFoo a = new director_default_MyFoo();
+ a = new director_default_MyFoo(10);
+ }
+
+ director_default_MyFoo a = new director_default_MyFoo();
+ if (!a.GetMsg().equals("director_default_MyFoo-default")) {
+ throw new RuntimeException ( "Test 1 failed" );
+ }
+ if (!a.GetMsg("boo").equals("director_default_MyFoo-boo")) {
+ throw new RuntimeException ( "Test 2 failed" );
+ }
+
+ Foo b = new Foo();
+ if (!b.GetMsg().equals("Foo-default")) {
+ throw new RuntimeException ( "Test 1 failed" );
+ }
+ if (!b.GetMsg("boo").equals("Foo-boo")) {
+ throw new RuntimeException ( "Test 2 failed" );
+ }
+
+ }
+}
+
+class director_default_MyFoo extends Foo {
+ public director_default_MyFoo() {
+ super();
+ }
+ public director_default_MyFoo(int i) {
+ super(i);
+ }
+ public String Msg(String msg) {
+ return "director_default_MyFoo-" + msg;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_enum_runme.java b/trunk/Examples/test-suite/java/director_enum_runme.java
new file mode 100644
index 000000000..9abfa3174
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_enum_runme.java
@@ -0,0 +1,54 @@
+
+import director_enum.*;
+
+public class director_enum_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_enum");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ director_enum_MyFoo a = new director_enum_MyFoo();
+
+ if (a.ping(Hallo.awright) != Hallo.yo) {
+ throw new RuntimeException ( "a.ping()" );
+ }
+ if (a.ping_ref(Hallo.awright) != Hallo.hello) {
+ throw new RuntimeException ( "a.ping_ref()" );
+ }
+ if (a.ping_member_enum(Foo.Bye.adios) != Foo.Bye.aufwiedersehen) {
+ throw new RuntimeException ( "a.ping_member_enum()" );
+ }
+
+ Foo b = new Foo();
+
+ if (b.ping(Hallo.awright) != Hallo.awright) {
+ throw new RuntimeException ( "b.ping()" );
+ }
+ if (b.ping_ref(Hallo.awright) != Hallo.awright) {
+ throw new RuntimeException ( "b.ping_ref()" );
+ }
+ if (b.ping_member_enum(Foo.Bye.adios) != Foo.Bye.adios) {
+ throw new RuntimeException ( "b.ping_member_enum()" );
+ }
+ }
+}
+
+class director_enum_MyFoo extends Foo {
+ public Hallo say_hi(Hallo h) {
+ return Hallo.yo;
+ }
+ public Hallo say_hi_ref(Hallo h) {
+ return Hallo.hello;
+ }
+ public Foo.Bye say_bye(Foo.Bye b) {
+ return Foo.Bye.aufwiedersehen;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_exception_runme.java b/trunk/Examples/test-suite/java/director_exception_runme.java
new file mode 100644
index 000000000..3d2958abb
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_exception_runme.java
@@ -0,0 +1,34 @@
+
+import director_exception.*;
+
+public class director_exception_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_exception");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ director_exception_MyFoo a = new director_exception_MyFoo();
+ Foo b = director_exception.launder(a);
+
+ try {
+ a.pong();
+ throw new RuntimeException ( "Failed to catch exception" );
+ }
+ catch (UnsupportedOperationException e) {
+ }
+ }
+}
+
+class director_exception_MyFoo extends Foo {
+ public String ping() {
+ throw new UnsupportedOperationException("Foo::ping not implemented");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_frob_runme.java b/trunk/Examples/test-suite/java/director_frob_runme.java
new file mode 100644
index 000000000..ac1c4eb95
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_frob_runme.java
@@ -0,0 +1,39 @@
+
+import director_frob.*;
+import java.lang.reflect.*;
+
+public class director_frob_runme
+{
+ static {
+ try {
+ System.loadLibrary("director_frob");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String args[])
+ {
+ Bravo foo = new Bravo();
+
+ String s = foo.abs_method();
+ if (!s.equals("Bravo::abs_method()"))
+ throw new RuntimeException( "error" );
+
+ Prims prims = new PrimsDerived();
+ java.math.BigInteger bi = prims.callull(200, 50);
+ java.math.BigInteger biCheck = new java.math.BigInteger("150");
+ if (bi.compareTo(biCheck) != 0)
+ throw new RuntimeException( "failed got:" + bi);
+ }
+}
+
+class PrimsDerived extends Prims {
+ PrimsDerived() {
+ super();
+ }
+ public java.math.BigInteger ull(java.math.BigInteger i, java.math.BigInteger j) {
+ return i.subtract(j);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/director_ignore_runme.java b/trunk/Examples/test-suite/java/director_ignore_runme.java
new file mode 100644
index 000000000..9b98ee4cf
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_ignore_runme.java
@@ -0,0 +1,40 @@
+import director_ignore.*;
+
+public class director_ignore_runme {
+ static {
+ try {
+ System.loadLibrary("director_ignore");
+ } 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[])
+ {
+ // Just check the classes can be instantiated and other methods work as expected
+ DIgnoresDerived a = new DIgnoresDerived();
+ if (a.Triple(5) != 15)
+ throw new RuntimeException("Triple failed");
+ DAbstractIgnoresDerived b = new DAbstractIgnoresDerived();
+ if (b.Quadruple(5) != 20)
+ throw new RuntimeException("Quadruple failed");
+ }
+}
+
+class DIgnoresDerived extends DIgnores
+{
+ public DIgnoresDerived()
+ {
+ super();
+ }
+}
+
+class DAbstractIgnoresDerived extends DAbstractIgnores
+{
+ public DAbstractIgnoresDerived()
+ {
+ super();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_primitives_runme.java b/trunk/Examples/test-suite/java/director_primitives_runme.java
new file mode 100644
index 000000000..8dedfff05
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_primitives_runme.java
@@ -0,0 +1,138 @@
+/*
+ This test program shows a C# class JavaDerived inheriting from Base. Three types of classes are created
+ and the virtual methods called to demonstrate:
+ 1) Wide variety of primitive types
+ 2) Calling methods with zero, one or more parameters
+ 3) Director methods that are not overridden in C#
+ 4) Director classes that are not overridden at all in C#, ie non-director behaviour is as expected for director classes
+ 5) Inheritance hierarchy using director methods
+ 6) Return types working as well as parameters
+
+ The Caller class is a tester class, which calls the virtual functions from C++.
+*/
+
+import director_primitives.*;
+
+public class director_primitives_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_primitives");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ director_primitives_runme r = new director_primitives_runme();
+ r.run();
+ }
+
+ void run()
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("------------ Start ------------ ");
+
+ Caller myCaller = new Caller();
+
+ // test C++ base class
+ {
+ Base myBase = new Base(100.0);
+ makeCalls(myCaller, myBase);
+ myBase.delete();
+ }
+
+ if (director_primitives.getPrintDebug()) System.out.println("--------------------------------");
+
+ // test vanilla C++ wrapped derived class
+ {
+ Base myBase = new Derived(200.0);
+ makeCalls(myCaller, myBase);
+ myBase.delete();
+ }
+
+ if (director_primitives.getPrintDebug()) System.out.println("--------------------------------");
+
+ // test director / C# derived class
+ {
+ Base myBase = new JavaDerived(300.0);
+ makeCalls(myCaller, myBase);
+ myBase.delete();
+ }
+
+ if (director_primitives.getPrintDebug()) System.out.println("------------ Finish ------------ ");
+ }
+
+ void makeCalls(Caller myCaller, Base myBase)
+ {
+ myCaller.set(myBase);
+
+ myCaller.NoParmsMethodCall();
+ if (myCaller.BoolMethodCall(true) != true) throw new RuntimeException("failed");
+ if (myCaller.BoolMethodCall(false) != false) throw new RuntimeException("failed");
+ if (myCaller.IntMethodCall(-123) != -123) throw new RuntimeException("failed");
+ if (myCaller.UIntMethodCall(123) != 123) throw new RuntimeException("failed");
+ if (myCaller.FloatMethodCall((float)-123.456) != (float)-123.456) throw new RuntimeException("failed");
+ if (!myCaller.CharPtrMethodCall("test string").equals("test string")) throw new RuntimeException("failed");
+ if (!myCaller.ConstCharPtrMethodCall("another string").equals("another string")) throw new RuntimeException("failed");
+ if (myCaller.EnumMethodCall(HShadowMode.HShadowHard) != HShadowMode.HShadowHard) throw new RuntimeException("failed");
+ myCaller.ManyParmsMethodCall(true, -123, 123, (float)123.456, "test string", "another string", HShadowMode.HShadowHard);
+ myCaller.NotOverriddenMethodCall();
+
+ myCaller.reset();
+ }
+}
+
+class JavaDerived extends Base
+{
+ public JavaDerived(double dd)
+ {
+ super(dd);
+ }
+
+ public void NoParmsMethod()
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - NoParmsMethod()");
+ }
+ public boolean BoolMethod(boolean x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - BoolMethod(" + x + ")");
+ return x;
+ }
+ public int IntMethod(int x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - IntMethod(" + x + ")");
+ return x;
+ }
+ public long UIntMethod(long x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - UIntMethod(" + x + ")");
+ return x;
+ }
+ public float FloatMethod(float x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - FloatMethod(" + x + ")");
+ return x;
+ }
+ public String CharPtrMethod(String x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - CharPtrMethod(" + x + ")");
+ return x;
+ }
+ public String ConstCharPtrMethod(String x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - ConstCharPtrMethod(" + x + ")");
+ return x;
+ }
+ public HShadowMode EnumMethod(HShadowMode x)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - EnumMethod(" + x + ")");
+ return x;
+ }
+ public void ManyParmsMethod(boolean b, int i, long u, float f, String c, String cc, HShadowMode h)
+ {
+ if (director_primitives.getPrintDebug()) System.out.println("JavaDerived - ManyParmsMethod(" + b + ", " + i + ", " + u + ", " + f + ", " + c + ", " + cc + ", " + h);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_protected_runme.java b/trunk/Examples/test-suite/java/director_protected_runme.java
new file mode 100644
index 000000000..464b4d4d9
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_protected_runme.java
@@ -0,0 +1,85 @@
+
+import director_protected.*;
+import java.lang.reflect.*;
+
+public class director_protected_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_protected");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ Bar b = new Bar();
+ Foo f = b.create();
+ director_protected_FooBar fb = new director_protected_FooBar();
+ director_protected_FooBar2 fb2 = new director_protected_FooBar2();
+
+ {
+ String s = fb.used();
+ if (!s.equals("Foo::pang();Bar::pong();Foo::pong();director_protected_FooBar::ping();"))
+ throw new RuntimeException( "bad director_protected_FooBar::used" );
+ }
+
+ {
+ String s = fb2.used();
+ if (!s.equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
+ throw new RuntimeException( "bad director_protected_FooBar2::used" );
+ }
+
+ {
+ String s = b.pong();
+ if (!s.equals("Bar::pong();Foo::pong();Bar::ping();"))
+ throw new RuntimeException( "bad Bar::pong" );
+ }
+
+ {
+ String s = f.pong();
+ if (!s.equals("Bar::pong();Foo::pong();Bar::ping();"))
+ throw new RuntimeException(" bad Foo::pong" );
+ }
+
+ {
+ String s3 = fb.pong();
+ if (!s3.equals("Bar::pong();Foo::pong();director_protected_FooBar::ping();"))
+ throw new RuntimeException(" bad director_protected_FooBar::pong" );
+ }
+
+ try {
+
+ Method method = b.getClass().getDeclaredMethod("ping", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Bar::ping should be protected" );
+
+ method = f.getClass().getDeclaredMethod("ping", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Foo::ping should be protected" );
+
+ } catch (NoSuchMethodException n) {
+ throw new RuntimeException("NoSuchmethodException caught. Test failed.");
+ } catch (SecurityException s) {
+ throw new RuntimeException("SecurityException caught. Test failed.");
+ }
+ }
+}
+
+class director_protected_FooBar extends Bar {
+ public String ping() {
+ return "director_protected_FooBar::ping();";
+ }
+}
+
+class director_protected_FooBar2 extends Bar {
+ public String ping() {
+ return "director_protected_FooBar2::ping();";
+ }
+ public String pang() {
+ return "director_protected_FooBar2::pang();";
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_string_runme.java b/trunk/Examples/test-suite/java/director_string_runme.java
new file mode 100644
index 000000000..a6ed67100
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_string_runme.java
@@ -0,0 +1,56 @@
+
+import director_string.*;
+
+public class director_string_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_string");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ String s;
+
+ director_string_A c = new director_string_A("hi");
+ for (int i=0; i<3; i++) {
+ s = c.call_get(i);
+ if (!s.equals(new Integer(i).toString())) throw new RuntimeException("director_string_A.get(" + i + ") failed. Got:" + s);
+ }
+
+ director_string_B b = new director_string_B("hello");
+
+ s = b.call_get_first();
+ if (!s.equals("director_string_B.get_first")) throw new RuntimeException("call_get_first() failed");
+
+ s = b.call_get(0);
+ if (!s.equals("director_string_B.get: hello")) throw new RuntimeException("get(0) failed");
+ }
+}
+
+class director_string_B extends A {
+ public director_string_B(String first) {
+ super(first);
+ }
+ public String get_first() {
+ return "director_string_B.get_first";
+ }
+
+ public String get(int n) {
+ return "director_string_B.get: " + super.get(n);
+ }
+}
+
+class director_string_A extends A {
+ public director_string_A(String first) {
+ super(first);
+ }
+ public String get(int n) {
+ return new Integer(n).toString();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_thread_runme.java b/trunk/Examples/test-suite/java/director_thread_runme.java
new file mode 100644
index 000000000..c67d4104f
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_thread_runme.java
@@ -0,0 +1,36 @@
+
+import director_thread.*;
+import java.lang.reflect.*;
+
+public class director_thread_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_thread");
+ } 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[]) {
+ // This test used to hang the process. The solution is to call DetachCurrentThread in ~JNIEnvWrapper, however it causes seg faults in other JNI calls on older JDKs on Solaris. See SWIG_JAVA_NO_DETACH_CURRENT_THREAD in director.swg.
+ director_thread_Derived d = new director_thread_Derived();
+ d.run();
+
+ if (d.getVal() >= 0) {
+ throw new RuntimeException("Failed. Val: " + d.getVal());
+ }
+ }
+}
+
+class director_thread_Derived extends Foo {
+ director_thread_Derived() {
+ super();
+ }
+
+ public void do_foo() {
+ setVal(getVal() - 1);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_unroll_runme.java b/trunk/Examples/test-suite/java/director_unroll_runme.java
new file mode 100644
index 000000000..9ae7edd62
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_unroll_runme.java
@@ -0,0 +1,34 @@
+
+import director_unroll.*;
+
+public class director_unroll_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_unroll");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ director_unroll_MyFoo a = new director_unroll_MyFoo();
+
+ Bar b = new Bar();
+
+ b.set(a);
+ Foo c = b.get();
+
+ if (!c.ping().equals("director_unroll_MyFoo::ping()"))
+ throw new RuntimeException ( "c.ping()" );
+ }
+}
+
+class director_unroll_MyFoo extends Foo {
+ public String ping() {
+ return "director_unroll_MyFoo::ping()";
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/director_wombat_runme.java b/trunk/Examples/test-suite/java/director_wombat_runme.java
new file mode 100644
index 000000000..575d8d7f1
--- /dev/null
+++ b/trunk/Examples/test-suite/java/director_wombat_runme.java
@@ -0,0 +1,94 @@
+import director_wombat.*;
+
+public class director_wombat_runme
+{
+ static {
+ try {
+ System.loadLibrary("director_wombat");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ Bar b = new Bar();
+ Foo_integers a;
+ int retval;
+
+ a = b.meth();
+ if ((retval = a.meth(49)) != 49) {
+ throw new RuntimeException ("Test failed: retval = " + retval + ", expected 49");
+ }
+
+ a.delete();
+
+ a = new director_wombat_Foo_integers_derived();
+ if ((retval = a.meth(62)) != 62 + 2) {
+ throw new RuntimeException ("Test failed: retval = " + retval + ", expected 62 + 2");
+ }
+
+ a.delete();
+
+ a = new director_wombat_Foo_integers_derived_2();
+ if ((retval = a.meth(37)) != 37) {
+ throw new RuntimeException ("Test failed: retval = " + retval + ", expected 37");
+ }
+
+ b.delete();
+
+ b = new director_wombat_Bar_derived_1();
+ b.foo_meth_ref(a, 0);
+ b.foo_meth_ptr(a, 1);
+ b.foo_meth_val(a, 2);
+ }
+}
+
+class director_wombat_Foo_integers_derived extends Foo_integers
+{
+ public director_wombat_Foo_integers_derived()
+ {
+ super();
+ }
+
+ public int meth(int param)
+ {
+ return param + 2;
+ }
+}
+
+class director_wombat_Foo_integers_derived_2 extends Foo_integers
+{
+ public director_wombat_Foo_integers_derived_2()
+ {
+ super();
+ }
+}
+
+class director_wombat_Bar_derived_1 extends Bar
+{
+ public director_wombat_Bar_derived_1()
+ {
+ super();
+ }
+
+ public void foo_meth_ref(Foo_integers foo_obj, int param)
+ {
+ if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
+ throw new RuntimeException ("Test failed: foo_obj in foo_meth_ref is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
+ }
+ }
+ public void foo_meth_ptr(Foo_integers foo_obj, int param)
+ {
+ if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
+ throw new RuntimeException ("Test failed: foo_obj in foo_meth_ptr is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
+ }
+ }
+ public void foo_meth_val(Foo_integers foo_obj, int param)
+ {
+ if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
+ throw new RuntimeException ("Test failed: foo_obj in foo_meth_val is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/dynamic_cast_runme.java b/trunk/Examples/test-suite/java/dynamic_cast_runme.java
new file mode 100644
index 000000000..be1f97b35
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/enum_thorough_proper_runme.java b/trunk/Examples/test-suite/java/enum_thorough_proper_runme.java
new file mode 100644
index 000000000..66968060d
--- /dev/null
+++ b/trunk/Examples/test-suite/java/enum_thorough_proper_runme.java
@@ -0,0 +1,421 @@
+
+import enum_thorough_proper.*;
+
+public class enum_thorough_proper_runme {
+
+ static {
+ try {
+ System.loadLibrary("enum_thorough_proper");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ {
+ // Anonymous enums
+ int i = enum_thorough_proper.AnonEnum1;
+ if (enum_thorough_proper.ReallyAnInteger != 200) throw new RuntimeException("Test Anon 1 failed");
+ int j = enum_thorough_proper.AnonSpaceEnum1;
+ int k = AnonStruct.AnonStructEnum1;
+ }
+ {
+ colour red = colour.red;
+ enum_thorough_proper.colourTest1(red);
+ enum_thorough_proper.colourTest2(red);
+ enum_thorough_proper.colourTest3(red);
+ enum_thorough_proper.colourTest4(red);
+ enum_thorough_proper.setMyColour(red);
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed speed = SpeedClass.speed.slow;
+ if (s.speedTest1(speed) != speed) throw new RuntimeException("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new RuntimeException("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new RuntimeException("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new RuntimeException("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new RuntimeException("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new RuntimeException("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new RuntimeException("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new RuntimeException("speedTest 8 failed");
+
+ if (enum_thorough_proper.speedTest1(speed) != speed) throw new RuntimeException("speedTest Global 1 failed");
+ if (enum_thorough_proper.speedTest2(speed) != speed) throw new RuntimeException("speedTest Global 2 failed");
+ if (enum_thorough_proper.speedTest3(speed) != speed) throw new RuntimeException("speedTest Global 3 failed");
+ if (enum_thorough_proper.speedTest4(speed) != speed) throw new RuntimeException("speedTest Global 4 failed");
+ if (enum_thorough_proper.speedTest5(speed) != speed) throw new RuntimeException("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed slow = SpeedClass.speed.slow;
+ SpeedClass.speed lightning = SpeedClass.speed.lightning;
+
+ if (s.getMySpeedtd1() != slow) throw new RuntimeException("mySpeedtd1 1 failed");
+ if (s.getMySpeedtd1().swigValue() != 10) throw new RuntimeException("mySpeedtd1 2 failed");
+
+ s.setMySpeedtd1(lightning);
+ if (s.getMySpeedtd1() != lightning) throw new RuntimeException("mySpeedtd1 3 failed");
+ if (s.getMySpeedtd1().swigValue() != 31) throw new RuntimeException("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough_proper.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest 1 failed");
+ }
+ {
+ twonames val = twonames.TwoNames2;
+ if (enum_thorough_proper.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (enum_thorough_proper.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (enum_thorough_proper.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ namedanonspace val = namedanonspace.NamedAnonSpace2;
+ if (enum_thorough_proper.namedanonspaceTest1(val) != val) throw new RuntimeException("namedanonspaceTest 1 failed");
+ if (enum_thorough_proper.namedanonspaceTest2(val) != val) throw new RuntimeException("namedanonspaceTest 2 failed");
+ if (enum_thorough_proper.namedanonspaceTest3(val) != val) throw new RuntimeException("namedanonspaceTest 3 failed");
+ if (enum_thorough_proper.namedanonspaceTest4(val) != val) throw new RuntimeException("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new RuntimeException("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new RuntimeException("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new RuntimeException("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new RuntimeException("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new RuntimeException("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new RuntimeException("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new RuntimeException("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new RuntimeException("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new RuntimeException("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new RuntimeException("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new RuntimeException("scientistsTest J failed");
+
+ if (enum_thorough_proper.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest Global 1 failed");
+ if (enum_thorough_proper.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest Global 2 failed");
+ if (enum_thorough_proper.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest Global 3 failed");
+ if (enum_thorough_proper.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest Global 4 failed");
+ if (enum_thorough_proper.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest Global 5 failed");
+ if (enum_thorough_proper.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest Global 6 failed");
+ if (enum_thorough_proper.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest Global 7 failed");
+ if (enum_thorough_proper.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ TClassInt.scientists bell = TClassInt.scientists.bell;
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new RuntimeException("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new RuntimeException("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new RuntimeException("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new RuntimeException("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new RuntimeException("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new RuntimeException("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new RuntimeException("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new RuntimeException("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new RuntimeException("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new RuntimeException("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new RuntimeException("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 7 failed");
+
+ if (enum_thorough_proper.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest Global 1 failed");
+ if (enum_thorough_proper.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest Global 2 failed");
+ if (enum_thorough_proper.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest Global 3 failed");
+ if (enum_thorough_proper.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest Global 4 failed");
+ if (enum_thorough_proper.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest Global 5 failed");
+ if (enum_thorough_proper.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest Global 6 failed");
+ if (enum_thorough_proper.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough_proper.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough_proper.scientistsNameSpaceTest8(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTest9(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestA(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestB(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestC(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestD(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestE(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough_proper.scientistsNameSpaceTestF(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestG(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestH(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestI(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestJ(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestK(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough_proper.scientistsNameSpaceTestL(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ newname val = newname.argh;
+ if (enum_thorough_proper.renameTest1(val) != val) throw new RuntimeException("renameTest Global 1 failed");
+ if (enum_thorough_proper.renameTest2(val) != val) throw new RuntimeException("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough_proper.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest Global 3 failed");
+ if (enum_thorough_proper.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest Global 4 failed");
+ if (enum_thorough_proper.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 5 failed");
+ if (enum_thorough_proper.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 6 failed");
+ if (enum_thorough_proper.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ TreesClass.trees pine = TreesClass.trees.pine;
+
+ if (t.treesTest1(pine) != pine) throw new RuntimeException("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new RuntimeException("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new RuntimeException("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new RuntimeException("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new RuntimeException("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new RuntimeException("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new RuntimeException("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new RuntimeException("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new RuntimeException("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new RuntimeException("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new RuntimeException("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new RuntimeException("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new RuntimeException("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new RuntimeException("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new RuntimeException("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new RuntimeException("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new RuntimeException("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new RuntimeException("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new RuntimeException("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new RuntimeException("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new RuntimeException("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new RuntimeException("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new RuntimeException("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new RuntimeException("treesTest O failed");
+
+ if (enum_thorough_proper.treesTest1(pine) != pine) throw new RuntimeException("treesTest Global 1 failed");
+ if (enum_thorough_proper.treesTest2(pine) != pine) throw new RuntimeException("treesTest Global 2 failed");
+ if (enum_thorough_proper.treesTest3(pine) != pine) throw new RuntimeException("treesTest Global 3 failed");
+ if (enum_thorough_proper.treesTest4(pine) != pine) throw new RuntimeException("treesTest Global 4 failed");
+ if (enum_thorough_proper.treesTest5(pine) != pine) throw new RuntimeException("treesTest Global 5 failed");
+ if (enum_thorough_proper.treesTest6(pine) != pine) throw new RuntimeException("treesTest Global 6 failed");
+ if (enum_thorough_proper.treesTest7(pine) != pine) throw new RuntimeException("treesTest Global 7 failed");
+ if (enum_thorough_proper.treesTest8(pine) != pine) throw new RuntimeException("treesTest Global 8 failed");
+ if (enum_thorough_proper.treesTest9(pine) != pine) throw new RuntimeException("treesTest Global 9 failed");
+ if (enum_thorough_proper.treesTestA(pine) != pine) throw new RuntimeException("treesTest Global A failed");
+ if (enum_thorough_proper.treesTestB(pine) != pine) throw new RuntimeException("treesTest Global B failed");
+ if (enum_thorough_proper.treesTestC(pine) != pine) throw new RuntimeException("treesTest Global C failed");
+ if (enum_thorough_proper.treesTestD(pine) != pine) throw new RuntimeException("treesTest Global D failed");
+ if (enum_thorough_proper.treesTestE(pine) != pine) throw new RuntimeException("treesTest Global E failed");
+ if (enum_thorough_proper.treesTestF(pine) != pine) throw new RuntimeException("treesTest Global F failed");
+ if (enum_thorough_proper.treesTestG(pine) != pine) throw new RuntimeException("treesTest Global G failed");
+ if (enum_thorough_proper.treesTestH(pine) != pine) throw new RuntimeException("treesTest Global H failed");
+ if (enum_thorough_proper.treesTestI(pine) != pine) throw new RuntimeException("treesTest Global I failed");
+ if (enum_thorough_proper.treesTestJ(pine) != pine) throw new RuntimeException("treesTest Global J failed");
+ if (enum_thorough_proper.treesTestK(pine) != pine) throw new RuntimeException("treesTest Global K failed");
+ if (enum_thorough_proper.treesTestL(pine) != pine) throw new RuntimeException("treesTest Global L failed");
+ if (enum_thorough_proper.treesTestM(pine) != pine) throw new RuntimeException("treesTest Global M failed");
+// if (enum_thorough_proper.treesTestN(pine) != pine) throw new RuntimeException("treesTest Global N failed");
+ if (enum_thorough_proper.treesTestO(pine) != pine) throw new RuntimeException("treesTest Global O failed");
+ if (enum_thorough_proper.treesTestP(pine) != pine) throw new RuntimeException("treesTest Global P failed");
+ if (enum_thorough_proper.treesTestQ(pine) != pine) throw new RuntimeException("treesTest Global Q failed");
+ if (enum_thorough_proper.treesTestR(pine) != pine) throw new RuntimeException("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ HairStruct.hair ginger = HairStruct.hair.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new RuntimeException("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new RuntimeException("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new RuntimeException("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new RuntimeException("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new RuntimeException("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new RuntimeException("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new RuntimeException("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new RuntimeException("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new RuntimeException("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new RuntimeException("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new RuntimeException("hairTest B failed");
+
+ colour red = colour.red;
+ if (h.colourTest1(red) != red) throw new RuntimeException("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new RuntimeException("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new RuntimeException("namedanonspaceTest HairStruct 1 failed");
+
+ TreesClass.trees fir = TreesClass.trees.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+ if (enum_thorough_proper.hairTest1(blonde) != blonde) throw new RuntimeException("hairTest Global 1 failed");
+ if (enum_thorough_proper.hairTest2(blonde) != blonde) throw new RuntimeException("hairTest Global 2 failed");
+ if (enum_thorough_proper.hairTest3(blonde) != blonde) throw new RuntimeException("hairTest Global 3 failed");
+ if (enum_thorough_proper.hairTest4(blonde) != blonde) throw new RuntimeException("hairTest Global 4 failed");
+ if (enum_thorough_proper.hairTest5(blonde) != blonde) throw new RuntimeException("hairTest Global 5 failed");
+ if (enum_thorough_proper.hairTest6(blonde) != blonde) throw new RuntimeException("hairTest Global 6 failed");
+ if (enum_thorough_proper.hairTest7(blonde) != blonde) throw new RuntimeException("hairTest Global 7 failed");
+ if (enum_thorough_proper.hairTest8(blonde) != blonde) throw new RuntimeException("hairTest Global 8 failed");
+ if (enum_thorough_proper.hairTest9(blonde) != blonde) throw new RuntimeException("hairTest Global 9 failed");
+ if (enum_thorough_proper.hairTestA(blonde) != blonde) throw new RuntimeException("hairTest Global A failed");
+ if (enum_thorough_proper.hairTestB(blonde) != blonde) throw new RuntimeException("hairTest Global B failed");
+ if (enum_thorough_proper.hairTestC(blonde) != blonde) throw new RuntimeException("hairTest Global C failed");
+
+ if (enum_thorough_proper.hairTestA1(blonde) != blonde) throw new RuntimeException("hairTest Global A1 failed");
+ if (enum_thorough_proper.hairTestA2(blonde) != blonde) throw new RuntimeException("hairTest Global A2 failed");
+ if (enum_thorough_proper.hairTestA3(blonde) != blonde) throw new RuntimeException("hairTest Global A3 failed");
+ if (enum_thorough_proper.hairTestA4(blonde) != blonde) throw new RuntimeException("hairTest Global A4 failed");
+ if (enum_thorough_proper.hairTestA5(blonde) != blonde) throw new RuntimeException("hairTest Global A5 failed");
+ if (enum_thorough_proper.hairTestA6(blonde) != blonde) throw new RuntimeException("hairTest Global A6 failed");
+ if (enum_thorough_proper.hairTestA7(blonde) != blonde) throw new RuntimeException("hairTest Global A7 failed");
+ if (enum_thorough_proper.hairTestA8(blonde) != blonde) throw new RuntimeException("hairTest Global A8 failed");
+ if (enum_thorough_proper.hairTestA9(blonde) != blonde) throw new RuntimeException("hairTest Global A9 failed");
+ if (enum_thorough_proper.hairTestAA(blonde) != blonde) throw new RuntimeException("hairTest Global AA failed");
+ if (enum_thorough_proper.hairTestAB(blonde) != blonde) throw new RuntimeException("hairTest Global AB failed");
+ if (enum_thorough_proper.hairTestAC(blonde) != blonde) throw new RuntimeException("hairTest Global AC failed");
+
+ if (enum_thorough_proper.hairTestB1(blonde) != blonde) throw new RuntimeException("hairTest Global B1 failed");
+ if (enum_thorough_proper.hairTestB2(blonde) != blonde) throw new RuntimeException("hairTest Global B2 failed");
+ if (enum_thorough_proper.hairTestB3(blonde) != blonde) throw new RuntimeException("hairTest Global B3 failed");
+ if (enum_thorough_proper.hairTestB4(blonde) != blonde) throw new RuntimeException("hairTest Global B4 failed");
+ if (enum_thorough_proper.hairTestB5(blonde) != blonde) throw new RuntimeException("hairTest Global B5 failed");
+ if (enum_thorough_proper.hairTestB6(blonde) != blonde) throw new RuntimeException("hairTest Global B6 failed");
+ if (enum_thorough_proper.hairTestB7(blonde) != blonde) throw new RuntimeException("hairTest Global B7 failed");
+ if (enum_thorough_proper.hairTestB8(blonde) != blonde) throw new RuntimeException("hairTest Global B8 failed");
+ if (enum_thorough_proper.hairTestB9(blonde) != blonde) throw new RuntimeException("hairTest Global B9 failed");
+ if (enum_thorough_proper.hairTestBA(blonde) != blonde) throw new RuntimeException("hairTest Global BA failed");
+ if (enum_thorough_proper.hairTestBB(blonde) != blonde) throw new RuntimeException("hairTest Global BB failed");
+ if (enum_thorough_proper.hairTestBC(blonde) != blonde) throw new RuntimeException("hairTest Global BC failed");
+
+ if (enum_thorough_proper.hairTestC1(blonde) != blonde) throw new RuntimeException("hairTest Global C1 failed");
+ if (enum_thorough_proper.hairTestC2(blonde) != blonde) throw new RuntimeException("hairTest Global C2 failed");
+ if (enum_thorough_proper.hairTestC3(blonde) != blonde) throw new RuntimeException("hairTest Global C3 failed");
+ if (enum_thorough_proper.hairTestC4(blonde) != blonde) throw new RuntimeException("hairTest Global C4 failed");
+ if (enum_thorough_proper.hairTestC5(blonde) != blonde) throw new RuntimeException("hairTest Global C5 failed");
+ if (enum_thorough_proper.hairTestC6(blonde) != blonde) throw new RuntimeException("hairTest Global C6 failed");
+ if (enum_thorough_proper.hairTestC7(blonde) != blonde) throw new RuntimeException("hairTest Global C7 failed");
+ if (enum_thorough_proper.hairTestC8(blonde) != blonde) throw new RuntimeException("hairTest Global C8 failed");
+ if (enum_thorough_proper.hairTestC9(blonde) != blonde) throw new RuntimeException("hairTest Global C9 failed");
+ if (enum_thorough_proper.hairTestCA(blonde) != blonde) throw new RuntimeException("hairTest Global CA failed");
+ if (enum_thorough_proper.hairTestCB(blonde) != blonde) throw new RuntimeException("hairTest Global CB failed");
+ if (enum_thorough_proper.hairTestCC(blonde) != blonde) throw new RuntimeException("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new RuntimeException("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new RuntimeException("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new RuntimeException("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new RuntimeException("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new RuntimeException("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new RuntimeException("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new RuntimeException("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new RuntimeException("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new RuntimeException("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new RuntimeException("hairTestFir A failed");
+ }
+ {
+ enum_thorough_proper.setGlobalInstance(enum_thorough_proper.globalinstance2);
+ if (enum_thorough_proper.getGlobalInstance() != enum_thorough_proper.globalinstance2) throw new RuntimeException("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.setMemberInstance(Instances.memberinstance3);
+ if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue() != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue() != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue() != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue() != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue() != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue() != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue() != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue() != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue() != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue() != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue() != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue() != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue() != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue() != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue() != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue() != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue() != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue() != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue() != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough_proper.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue() != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (enum_thorough_proper.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed");
+ if (enum_thorough_proper.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed");
+ if (enum_thorough_proper.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed");
+ if (enum_thorough_proper.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed");
+ if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/enum_thorough_runme.java b/trunk/Examples/test-suite/java/enum_thorough_runme.java
new file mode 100644
index 000000000..79c902ccf
--- /dev/null
+++ b/trunk/Examples/test-suite/java/enum_thorough_runme.java
@@ -0,0 +1,421 @@
+
+import enum_thorough.*;
+
+public class enum_thorough_runme {
+
+ static {
+ try {
+ System.loadLibrary("enum_thorough");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ {
+ // Anonymous enums
+ int i = enum_thorough.AnonEnum1;
+ if (enum_thorough.ReallyAnInteger != 200) throw new RuntimeException("Test Anon 1 failed");
+ int j = enum_thorough.AnonSpaceEnum1;
+ int k = AnonStruct.AnonStructEnum1;
+ }
+ {
+ colour red = colour.red;
+ enum_thorough.colourTest1(red);
+ enum_thorough.colourTest2(red);
+ enum_thorough.colourTest3(red);
+ enum_thorough.colourTest4(red);
+ enum_thorough.setMyColour(red);
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed speed = SpeedClass.speed.slow;
+ if (s.speedTest1(speed) != speed) throw new RuntimeException("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new RuntimeException("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new RuntimeException("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new RuntimeException("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new RuntimeException("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new RuntimeException("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new RuntimeException("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new RuntimeException("speedTest 8 failed");
+
+ if (enum_thorough.speedTest1(speed) != speed) throw new RuntimeException("speedTest Global 1 failed");
+ if (enum_thorough.speedTest2(speed) != speed) throw new RuntimeException("speedTest Global 2 failed");
+ if (enum_thorough.speedTest3(speed) != speed) throw new RuntimeException("speedTest Global 3 failed");
+ if (enum_thorough.speedTest4(speed) != speed) throw new RuntimeException("speedTest Global 4 failed");
+ if (enum_thorough.speedTest5(speed) != speed) throw new RuntimeException("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ SpeedClass.speed slow = SpeedClass.speed.slow;
+ SpeedClass.speed lightning = SpeedClass.speed.lightning;
+
+ if (s.getMySpeedtd1() != slow) throw new RuntimeException("mySpeedtd1 1 failed");
+ if (s.getMySpeedtd1().swigValue() != 10) throw new RuntimeException("mySpeedtd1 2 failed");
+
+ s.setMySpeedtd1(lightning);
+ if (s.getMySpeedtd1() != lightning) throw new RuntimeException("mySpeedtd1 3 failed");
+ if (s.getMySpeedtd1().swigValue() != 31) throw new RuntimeException("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest 1 failed");
+ }
+ {
+ twonames val = twonames.TwoNames2;
+ if (enum_thorough.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (enum_thorough.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (enum_thorough.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ namedanonspace val = namedanonspace.NamedAnonSpace2;
+ if (enum_thorough.namedanonspaceTest1(val) != val) throw new RuntimeException("namedanonspaceTest 1 failed");
+ if (enum_thorough.namedanonspaceTest2(val) != val) throw new RuntimeException("namedanonspaceTest 2 failed");
+ if (enum_thorough.namedanonspaceTest3(val) != val) throw new RuntimeException("namedanonspaceTest 3 failed");
+ if (enum_thorough.namedanonspaceTest4(val) != val) throw new RuntimeException("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new RuntimeException("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new RuntimeException("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new RuntimeException("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new RuntimeException("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new RuntimeException("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new RuntimeException("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new RuntimeException("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new RuntimeException("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new RuntimeException("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new RuntimeException("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new RuntimeException("scientistsTest J failed");
+
+ if (enum_thorough.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest Global 1 failed");
+ if (enum_thorough.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest Global 2 failed");
+ if (enum_thorough.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest Global 3 failed");
+ if (enum_thorough.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest Global 4 failed");
+ if (enum_thorough.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest Global 5 failed");
+ if (enum_thorough.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest Global 6 failed");
+ if (enum_thorough.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest Global 7 failed");
+ if (enum_thorough.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ TClassInt.scientists bell = TClassInt.scientists.bell;
+ TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new RuntimeException("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new RuntimeException("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new RuntimeException("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new RuntimeException("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new RuntimeException("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new RuntimeException("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new RuntimeException("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new RuntimeException("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new RuntimeException("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new RuntimeException("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new RuntimeException("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 7 failed");
+
+ if (enum_thorough.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest Global 1 failed");
+ if (enum_thorough.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest Global 2 failed");
+ if (enum_thorough.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest Global 3 failed");
+ if (enum_thorough.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest Global 4 failed");
+ if (enum_thorough.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest Global 5 failed");
+ if (enum_thorough.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest Global 6 failed");
+ if (enum_thorough.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough.scientistsNameSpaceTest8(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough.scientistsNameSpaceTest9(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough.scientistsNameSpaceTestA(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough.scientistsNameSpaceTestB(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough.scientistsNameSpaceTestC(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough.scientistsNameSpaceTestD(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough.scientistsNameSpaceTestE(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough.scientistsNameSpaceTestF(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough.scientistsNameSpaceTestG(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough.scientistsNameSpaceTestH(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough.scientistsNameSpaceTestI(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough.scientistsNameSpaceTestJ(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough.scientistsNameSpaceTestK(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough.scientistsNameSpaceTestL(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ newname val = newname.argh;
+ if (enum_thorough.renameTest1(val) != val) throw new RuntimeException("renameTest Global 1 failed");
+ if (enum_thorough.renameTest2(val) != val) throw new RuntimeException("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest Global 3 failed");
+ if (enum_thorough.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest Global 4 failed");
+ if (enum_thorough.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 5 failed");
+ if (enum_thorough.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 6 failed");
+ if (enum_thorough.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ TreesClass.trees pine = TreesClass.trees.pine;
+
+ if (t.treesTest1(pine) != pine) throw new RuntimeException("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new RuntimeException("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new RuntimeException("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new RuntimeException("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new RuntimeException("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new RuntimeException("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new RuntimeException("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new RuntimeException("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new RuntimeException("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new RuntimeException("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new RuntimeException("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new RuntimeException("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new RuntimeException("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new RuntimeException("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new RuntimeException("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new RuntimeException("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new RuntimeException("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new RuntimeException("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new RuntimeException("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new RuntimeException("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new RuntimeException("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new RuntimeException("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new RuntimeException("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new RuntimeException("treesTest O failed");
+
+ if (enum_thorough.treesTest1(pine) != pine) throw new RuntimeException("treesTest Global 1 failed");
+ if (enum_thorough.treesTest2(pine) != pine) throw new RuntimeException("treesTest Global 2 failed");
+ if (enum_thorough.treesTest3(pine) != pine) throw new RuntimeException("treesTest Global 3 failed");
+ if (enum_thorough.treesTest4(pine) != pine) throw new RuntimeException("treesTest Global 4 failed");
+ if (enum_thorough.treesTest5(pine) != pine) throw new RuntimeException("treesTest Global 5 failed");
+ if (enum_thorough.treesTest6(pine) != pine) throw new RuntimeException("treesTest Global 6 failed");
+ if (enum_thorough.treesTest7(pine) != pine) throw new RuntimeException("treesTest Global 7 failed");
+ if (enum_thorough.treesTest8(pine) != pine) throw new RuntimeException("treesTest Global 8 failed");
+ if (enum_thorough.treesTest9(pine) != pine) throw new RuntimeException("treesTest Global 9 failed");
+ if (enum_thorough.treesTestA(pine) != pine) throw new RuntimeException("treesTest Global A failed");
+ if (enum_thorough.treesTestB(pine) != pine) throw new RuntimeException("treesTest Global B failed");
+ if (enum_thorough.treesTestC(pine) != pine) throw new RuntimeException("treesTest Global C failed");
+ if (enum_thorough.treesTestD(pine) != pine) throw new RuntimeException("treesTest Global D failed");
+ if (enum_thorough.treesTestE(pine) != pine) throw new RuntimeException("treesTest Global E failed");
+ if (enum_thorough.treesTestF(pine) != pine) throw new RuntimeException("treesTest Global F failed");
+ if (enum_thorough.treesTestG(pine) != pine) throw new RuntimeException("treesTest Global G failed");
+ if (enum_thorough.treesTestH(pine) != pine) throw new RuntimeException("treesTest Global H failed");
+ if (enum_thorough.treesTestI(pine) != pine) throw new RuntimeException("treesTest Global I failed");
+ if (enum_thorough.treesTestJ(pine) != pine) throw new RuntimeException("treesTest Global J failed");
+ if (enum_thorough.treesTestK(pine) != pine) throw new RuntimeException("treesTest Global K failed");
+ if (enum_thorough.treesTestL(pine) != pine) throw new RuntimeException("treesTest Global L failed");
+ if (enum_thorough.treesTestM(pine) != pine) throw new RuntimeException("treesTest Global M failed");
+// if (enum_thorough.treesTestN(pine) != pine) throw new RuntimeException("treesTest Global N failed");
+ if (enum_thorough.treesTestO(pine) != pine) throw new RuntimeException("treesTest Global O failed");
+ if (enum_thorough.treesTestP(pine) != pine) throw new RuntimeException("treesTest Global P failed");
+ if (enum_thorough.treesTestQ(pine) != pine) throw new RuntimeException("treesTest Global Q failed");
+ if (enum_thorough.treesTestR(pine) != pine) throw new RuntimeException("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ HairStruct.hair ginger = HairStruct.hair.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new RuntimeException("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new RuntimeException("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new RuntimeException("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new RuntimeException("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new RuntimeException("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new RuntimeException("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new RuntimeException("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new RuntimeException("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new RuntimeException("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new RuntimeException("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new RuntimeException("hairTest B failed");
+
+ colour red = colour.red;
+ if (h.colourTest1(red) != red) throw new RuntimeException("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new RuntimeException("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new RuntimeException("namedanonspaceTest HairStruct 1 failed");
+
+ TreesClass.trees fir = TreesClass.trees.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+ if (enum_thorough.hairTest1(blonde) != blonde) throw new RuntimeException("hairTest Global 1 failed");
+ if (enum_thorough.hairTest2(blonde) != blonde) throw new RuntimeException("hairTest Global 2 failed");
+ if (enum_thorough.hairTest3(blonde) != blonde) throw new RuntimeException("hairTest Global 3 failed");
+ if (enum_thorough.hairTest4(blonde) != blonde) throw new RuntimeException("hairTest Global 4 failed");
+ if (enum_thorough.hairTest5(blonde) != blonde) throw new RuntimeException("hairTest Global 5 failed");
+ if (enum_thorough.hairTest6(blonde) != blonde) throw new RuntimeException("hairTest Global 6 failed");
+ if (enum_thorough.hairTest7(blonde) != blonde) throw new RuntimeException("hairTest Global 7 failed");
+ if (enum_thorough.hairTest8(blonde) != blonde) throw new RuntimeException("hairTest Global 8 failed");
+ if (enum_thorough.hairTest9(blonde) != blonde) throw new RuntimeException("hairTest Global 9 failed");
+ if (enum_thorough.hairTestA(blonde) != blonde) throw new RuntimeException("hairTest Global A failed");
+ if (enum_thorough.hairTestB(blonde) != blonde) throw new RuntimeException("hairTest Global B failed");
+ if (enum_thorough.hairTestC(blonde) != blonde) throw new RuntimeException("hairTest Global C failed");
+
+ if (enum_thorough.hairTestA1(blonde) != blonde) throw new RuntimeException("hairTest Global A1 failed");
+ if (enum_thorough.hairTestA2(blonde) != blonde) throw new RuntimeException("hairTest Global A2 failed");
+ if (enum_thorough.hairTestA3(blonde) != blonde) throw new RuntimeException("hairTest Global A3 failed");
+ if (enum_thorough.hairTestA4(blonde) != blonde) throw new RuntimeException("hairTest Global A4 failed");
+ if (enum_thorough.hairTestA5(blonde) != blonde) throw new RuntimeException("hairTest Global A5 failed");
+ if (enum_thorough.hairTestA6(blonde) != blonde) throw new RuntimeException("hairTest Global A6 failed");
+ if (enum_thorough.hairTestA7(blonde) != blonde) throw new RuntimeException("hairTest Global A7 failed");
+ if (enum_thorough.hairTestA8(blonde) != blonde) throw new RuntimeException("hairTest Global A8 failed");
+ if (enum_thorough.hairTestA9(blonde) != blonde) throw new RuntimeException("hairTest Global A9 failed");
+ if (enum_thorough.hairTestAA(blonde) != blonde) throw new RuntimeException("hairTest Global AA failed");
+ if (enum_thorough.hairTestAB(blonde) != blonde) throw new RuntimeException("hairTest Global AB failed");
+ if (enum_thorough.hairTestAC(blonde) != blonde) throw new RuntimeException("hairTest Global AC failed");
+
+ if (enum_thorough.hairTestB1(blonde) != blonde) throw new RuntimeException("hairTest Global B1 failed");
+ if (enum_thorough.hairTestB2(blonde) != blonde) throw new RuntimeException("hairTest Global B2 failed");
+ if (enum_thorough.hairTestB3(blonde) != blonde) throw new RuntimeException("hairTest Global B3 failed");
+ if (enum_thorough.hairTestB4(blonde) != blonde) throw new RuntimeException("hairTest Global B4 failed");
+ if (enum_thorough.hairTestB5(blonde) != blonde) throw new RuntimeException("hairTest Global B5 failed");
+ if (enum_thorough.hairTestB6(blonde) != blonde) throw new RuntimeException("hairTest Global B6 failed");
+ if (enum_thorough.hairTestB7(blonde) != blonde) throw new RuntimeException("hairTest Global B7 failed");
+ if (enum_thorough.hairTestB8(blonde) != blonde) throw new RuntimeException("hairTest Global B8 failed");
+ if (enum_thorough.hairTestB9(blonde) != blonde) throw new RuntimeException("hairTest Global B9 failed");
+ if (enum_thorough.hairTestBA(blonde) != blonde) throw new RuntimeException("hairTest Global BA failed");
+ if (enum_thorough.hairTestBB(blonde) != blonde) throw new RuntimeException("hairTest Global BB failed");
+ if (enum_thorough.hairTestBC(blonde) != blonde) throw new RuntimeException("hairTest Global BC failed");
+
+ if (enum_thorough.hairTestC1(blonde) != blonde) throw new RuntimeException("hairTest Global C1 failed");
+ if (enum_thorough.hairTestC2(blonde) != blonde) throw new RuntimeException("hairTest Global C2 failed");
+ if (enum_thorough.hairTestC3(blonde) != blonde) throw new RuntimeException("hairTest Global C3 failed");
+ if (enum_thorough.hairTestC4(blonde) != blonde) throw new RuntimeException("hairTest Global C4 failed");
+ if (enum_thorough.hairTestC5(blonde) != blonde) throw new RuntimeException("hairTest Global C5 failed");
+ if (enum_thorough.hairTestC6(blonde) != blonde) throw new RuntimeException("hairTest Global C6 failed");
+ if (enum_thorough.hairTestC7(blonde) != blonde) throw new RuntimeException("hairTest Global C7 failed");
+ if (enum_thorough.hairTestC8(blonde) != blonde) throw new RuntimeException("hairTest Global C8 failed");
+ if (enum_thorough.hairTestC9(blonde) != blonde) throw new RuntimeException("hairTest Global C9 failed");
+ if (enum_thorough.hairTestCA(blonde) != blonde) throw new RuntimeException("hairTest Global CA failed");
+ if (enum_thorough.hairTestCB(blonde) != blonde) throw new RuntimeException("hairTest Global CB failed");
+ if (enum_thorough.hairTestCC(blonde) != blonde) throw new RuntimeException("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ HairStruct.hair blonde = HairStruct.hair.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new RuntimeException("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new RuntimeException("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new RuntimeException("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new RuntimeException("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new RuntimeException("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new RuntimeException("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new RuntimeException("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new RuntimeException("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new RuntimeException("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new RuntimeException("hairTestFir A failed");
+ }
+ {
+ enum_thorough.setGlobalInstance(enum_thorough.globalinstance2);
+ if (enum_thorough.getGlobalInstance() != enum_thorough.globalinstance2) throw new RuntimeException("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.setMemberInstance(Instances.memberinstance3);
+ if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue() != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue() != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue() != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue() != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue() != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue() != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue() != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue() != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue() != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue() != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue() != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue() != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue() != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue() != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue() != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue() != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue() != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue() != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue() != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue() != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (enum_thorough.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed");
+ if (enum_thorough.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed");
+ if (enum_thorough.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed");
+ if (enum_thorough.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed");
+ if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/enum_thorough_simple_runme.java b/trunk/Examples/test-suite/java/enum_thorough_simple_runme.java
new file mode 100644
index 000000000..e54acda70
--- /dev/null
+++ b/trunk/Examples/test-suite/java/enum_thorough_simple_runme.java
@@ -0,0 +1,421 @@
+
+import enum_thorough_simple.*;
+
+public class enum_thorough_simple_runme {
+
+ static {
+ try {
+ System.loadLibrary("enum_thorough_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[])
+ {
+ {
+ // Anonymous enums
+ int i = enum_thorough_simple.AnonEnum1;
+ if (enum_thorough_simple.ReallyAnInteger != 200) throw new RuntimeException("Test Anon 1 failed");
+ int j = enum_thorough_simple.AnonSpaceEnum1;
+ int k = AnonStruct.AnonStructEnum1;
+ }
+ {
+ int red = enum_thorough_simple.red;
+ enum_thorough_simple.colourTest1(red);
+ enum_thorough_simple.colourTest2(red);
+ enum_thorough_simple.colourTest3(red);
+ enum_thorough_simple.colourTest4(red);
+ enum_thorough_simple.setMyColour(red);
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ int speed = SpeedClass.slow;
+ if (s.speedTest1(speed) != speed) throw new RuntimeException("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new RuntimeException("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new RuntimeException("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new RuntimeException("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new RuntimeException("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new RuntimeException("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new RuntimeException("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new RuntimeException("speedTest 8 failed");
+
+ if (enum_thorough_simple.speedTest1(speed) != speed) throw new RuntimeException("speedTest Global 1 failed");
+ if (enum_thorough_simple.speedTest2(speed) != speed) throw new RuntimeException("speedTest Global 2 failed");
+ if (enum_thorough_simple.speedTest3(speed) != speed) throw new RuntimeException("speedTest Global 3 failed");
+ if (enum_thorough_simple.speedTest4(speed) != speed) throw new RuntimeException("speedTest Global 4 failed");
+ if (enum_thorough_simple.speedTest5(speed) != speed) throw new RuntimeException("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ int slow = SpeedClass.slow;
+ int lightning = SpeedClass.lightning;
+
+ if (s.getMySpeedtd1() != slow) throw new RuntimeException("mySpeedtd1 1 failed");
+ if (s.getMySpeedtd1() != 10) throw new RuntimeException("mySpeedtd1 2 failed");
+
+ s.setMySpeedtd1(lightning);
+ if (s.getMySpeedtd1() != lightning) throw new RuntimeException("mySpeedtd1 3 failed");
+ if (s.getMySpeedtd1() != 31) throw new RuntimeException("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough_simple.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new RuntimeException("namedanonTest 1 failed");
+ }
+ {
+ int val = enum_thorough_simple.TwoNames2;
+ if (enum_thorough_simple.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (enum_thorough_simple.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (enum_thorough_simple.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ int val = TwoNamesStruct.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ int val = enum_thorough_simple.NamedAnonSpace2;
+ if (enum_thorough_simple.namedanonspaceTest1(val) != val) throw new RuntimeException("namedanonspaceTest 1 failed");
+ if (enum_thorough_simple.namedanonspaceTest2(val) != val) throw new RuntimeException("namedanonspaceTest 2 failed");
+ if (enum_thorough_simple.namedanonspaceTest3(val) != val) throw new RuntimeException("namedanonspaceTest 3 failed");
+ if (enum_thorough_simple.namedanonspaceTest4(val) != val) throw new RuntimeException("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ int galileo = TemplateClassInt.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new RuntimeException("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new RuntimeException("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new RuntimeException("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new RuntimeException("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new RuntimeException("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new RuntimeException("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new RuntimeException("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new RuntimeException("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new RuntimeException("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new RuntimeException("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new RuntimeException("scientistsTest J failed");
+
+ if (enum_thorough_simple.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest Global 1 failed");
+ if (enum_thorough_simple.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest Global 2 failed");
+ if (enum_thorough_simple.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest Global 3 failed");
+ if (enum_thorough_simple.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest Global 4 failed");
+ if (enum_thorough_simple.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest Global 5 failed");
+ if (enum_thorough_simple.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest Global 6 failed");
+ if (enum_thorough_simple.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest Global 7 failed");
+ if (enum_thorough_simple.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ int bell = TClassInt.bell;
+ int galileo = TemplateClassInt.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new RuntimeException("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new RuntimeException("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new RuntimeException("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new RuntimeException("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new RuntimeException("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new RuntimeException("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new RuntimeException("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new RuntimeException("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new RuntimeException("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new RuntimeException("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new RuntimeException("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 7 failed");
+
+ if (enum_thorough_simple.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest Global 1 failed");
+ if (enum_thorough_simple.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest Global 2 failed");
+ if (enum_thorough_simple.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest Global 3 failed");
+ if (enum_thorough_simple.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest Global 4 failed");
+ if (enum_thorough_simple.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest Global 5 failed");
+ if (enum_thorough_simple.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest Global 6 failed");
+ if (enum_thorough_simple.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough_simple.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough_simple.scientistsNameSpaceTest8(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTest9(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestA(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestB(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestC(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestD(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestE(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough_simple.scientistsNameSpaceTestF(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestG(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestH(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestI(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestJ(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestK(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough_simple.scientistsNameSpaceTestL(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ int val = enum_thorough_simple.argh;
+ if (enum_thorough_simple.renameTest1(val) != val) throw new RuntimeException("renameTest Global 1 failed");
+ if (enum_thorough_simple.renameTest2(val) != val) throw new RuntimeException("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.bang) != NewNameStruct.bang) throw new RuntimeException("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.bang) != NewNameStruct.bang) throw new RuntimeException("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simple1) != NewNameStruct.simple1) throw new RuntimeException("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new RuntimeException("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new RuntimeException("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new RuntimeException("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough_simple.renameTest3(NewNameStruct.bang) != NewNameStruct.bang) throw new RuntimeException("renameTest Global 3 failed");
+ if (enum_thorough_simple.renameTest4(NewNameStruct.simple1) != NewNameStruct.simple1) throw new RuntimeException("renameTest Global 4 failed");
+ if (enum_thorough_simple.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new RuntimeException("renameTest Global 5 failed");
+ if (enum_thorough_simple.renameTest6(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new RuntimeException("renameTest Global 6 failed");
+ if (enum_thorough_simple.renameTest7(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new RuntimeException("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ int pine = TreesClass.pine;
+
+ if (t.treesTest1(pine) != pine) throw new RuntimeException("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new RuntimeException("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new RuntimeException("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new RuntimeException("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new RuntimeException("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new RuntimeException("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new RuntimeException("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new RuntimeException("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new RuntimeException("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new RuntimeException("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new RuntimeException("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new RuntimeException("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new RuntimeException("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new RuntimeException("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new RuntimeException("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new RuntimeException("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new RuntimeException("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new RuntimeException("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new RuntimeException("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new RuntimeException("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new RuntimeException("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new RuntimeException("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new RuntimeException("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new RuntimeException("treesTest O failed");
+
+ if (enum_thorough_simple.treesTest1(pine) != pine) throw new RuntimeException("treesTest Global 1 failed");
+ if (enum_thorough_simple.treesTest2(pine) != pine) throw new RuntimeException("treesTest Global 2 failed");
+ if (enum_thorough_simple.treesTest3(pine) != pine) throw new RuntimeException("treesTest Global 3 failed");
+ if (enum_thorough_simple.treesTest4(pine) != pine) throw new RuntimeException("treesTest Global 4 failed");
+ if (enum_thorough_simple.treesTest5(pine) != pine) throw new RuntimeException("treesTest Global 5 failed");
+ if (enum_thorough_simple.treesTest6(pine) != pine) throw new RuntimeException("treesTest Global 6 failed");
+ if (enum_thorough_simple.treesTest7(pine) != pine) throw new RuntimeException("treesTest Global 7 failed");
+ if (enum_thorough_simple.treesTest8(pine) != pine) throw new RuntimeException("treesTest Global 8 failed");
+ if (enum_thorough_simple.treesTest9(pine) != pine) throw new RuntimeException("treesTest Global 9 failed");
+ if (enum_thorough_simple.treesTestA(pine) != pine) throw new RuntimeException("treesTest Global A failed");
+ if (enum_thorough_simple.treesTestB(pine) != pine) throw new RuntimeException("treesTest Global B failed");
+ if (enum_thorough_simple.treesTestC(pine) != pine) throw new RuntimeException("treesTest Global C failed");
+ if (enum_thorough_simple.treesTestD(pine) != pine) throw new RuntimeException("treesTest Global D failed");
+ if (enum_thorough_simple.treesTestE(pine) != pine) throw new RuntimeException("treesTest Global E failed");
+ if (enum_thorough_simple.treesTestF(pine) != pine) throw new RuntimeException("treesTest Global F failed");
+ if (enum_thorough_simple.treesTestG(pine) != pine) throw new RuntimeException("treesTest Global G failed");
+ if (enum_thorough_simple.treesTestH(pine) != pine) throw new RuntimeException("treesTest Global H failed");
+ if (enum_thorough_simple.treesTestI(pine) != pine) throw new RuntimeException("treesTest Global I failed");
+ if (enum_thorough_simple.treesTestJ(pine) != pine) throw new RuntimeException("treesTest Global J failed");
+ if (enum_thorough_simple.treesTestK(pine) != pine) throw new RuntimeException("treesTest Global K failed");
+ if (enum_thorough_simple.treesTestL(pine) != pine) throw new RuntimeException("treesTest Global L failed");
+ if (enum_thorough_simple.treesTestM(pine) != pine) throw new RuntimeException("treesTest Global M failed");
+// if (enum_thorough_simple.treesTestN(pine) != pine) throw new RuntimeException("treesTest Global N failed");
+ if (enum_thorough_simple.treesTestO(pine) != pine) throw new RuntimeException("treesTest Global O failed");
+ if (enum_thorough_simple.treesTestP(pine) != pine) throw new RuntimeException("treesTest Global P failed");
+ if (enum_thorough_simple.treesTestQ(pine) != pine) throw new RuntimeException("treesTest Global Q failed");
+ if (enum_thorough_simple.treesTestR(pine) != pine) throw new RuntimeException("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ int ginger = HairStruct.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new RuntimeException("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new RuntimeException("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new RuntimeException("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new RuntimeException("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new RuntimeException("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new RuntimeException("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new RuntimeException("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new RuntimeException("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new RuntimeException("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new RuntimeException("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new RuntimeException("hairTest B failed");
+
+ int red = enum_thorough_simple.red;
+ if (h.colourTest1(red) != red) throw new RuntimeException("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new RuntimeException("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new RuntimeException("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(enum_thorough_simple.NamedAnonSpace2) != enum_thorough_simple.NamedAnonSpace2) throw new RuntimeException("namedanonspaceTest HairStruct 1 failed");
+
+ int fir = TreesClass.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ int blonde = HairStruct.blonde;
+ if (enum_thorough_simple.hairTest1(blonde) != blonde) throw new RuntimeException("hairTest Global 1 failed");
+ if (enum_thorough_simple.hairTest2(blonde) != blonde) throw new RuntimeException("hairTest Global 2 failed");
+ if (enum_thorough_simple.hairTest3(blonde) != blonde) throw new RuntimeException("hairTest Global 3 failed");
+ if (enum_thorough_simple.hairTest4(blonde) != blonde) throw new RuntimeException("hairTest Global 4 failed");
+ if (enum_thorough_simple.hairTest5(blonde) != blonde) throw new RuntimeException("hairTest Global 5 failed");
+ if (enum_thorough_simple.hairTest6(blonde) != blonde) throw new RuntimeException("hairTest Global 6 failed");
+ if (enum_thorough_simple.hairTest7(blonde) != blonde) throw new RuntimeException("hairTest Global 7 failed");
+ if (enum_thorough_simple.hairTest8(blonde) != blonde) throw new RuntimeException("hairTest Global 8 failed");
+ if (enum_thorough_simple.hairTest9(blonde) != blonde) throw new RuntimeException("hairTest Global 9 failed");
+ if (enum_thorough_simple.hairTestA(blonde) != blonde) throw new RuntimeException("hairTest Global A failed");
+ if (enum_thorough_simple.hairTestB(blonde) != blonde) throw new RuntimeException("hairTest Global B failed");
+ if (enum_thorough_simple.hairTestC(blonde) != blonde) throw new RuntimeException("hairTest Global C failed");
+
+ if (enum_thorough_simple.hairTestA1(blonde) != blonde) throw new RuntimeException("hairTest Global A1 failed");
+ if (enum_thorough_simple.hairTestA2(blonde) != blonde) throw new RuntimeException("hairTest Global A2 failed");
+ if (enum_thorough_simple.hairTestA3(blonde) != blonde) throw new RuntimeException("hairTest Global A3 failed");
+ if (enum_thorough_simple.hairTestA4(blonde) != blonde) throw new RuntimeException("hairTest Global A4 failed");
+ if (enum_thorough_simple.hairTestA5(blonde) != blonde) throw new RuntimeException("hairTest Global A5 failed");
+ if (enum_thorough_simple.hairTestA6(blonde) != blonde) throw new RuntimeException("hairTest Global A6 failed");
+ if (enum_thorough_simple.hairTestA7(blonde) != blonde) throw new RuntimeException("hairTest Global A7 failed");
+ if (enum_thorough_simple.hairTestA8(blonde) != blonde) throw new RuntimeException("hairTest Global A8 failed");
+ if (enum_thorough_simple.hairTestA9(blonde) != blonde) throw new RuntimeException("hairTest Global A9 failed");
+ if (enum_thorough_simple.hairTestAA(blonde) != blonde) throw new RuntimeException("hairTest Global AA failed");
+ if (enum_thorough_simple.hairTestAB(blonde) != blonde) throw new RuntimeException("hairTest Global AB failed");
+ if (enum_thorough_simple.hairTestAC(blonde) != blonde) throw new RuntimeException("hairTest Global AC failed");
+
+ if (enum_thorough_simple.hairTestB1(blonde) != blonde) throw new RuntimeException("hairTest Global B1 failed");
+ if (enum_thorough_simple.hairTestB2(blonde) != blonde) throw new RuntimeException("hairTest Global B2 failed");
+ if (enum_thorough_simple.hairTestB3(blonde) != blonde) throw new RuntimeException("hairTest Global B3 failed");
+ if (enum_thorough_simple.hairTestB4(blonde) != blonde) throw new RuntimeException("hairTest Global B4 failed");
+ if (enum_thorough_simple.hairTestB5(blonde) != blonde) throw new RuntimeException("hairTest Global B5 failed");
+ if (enum_thorough_simple.hairTestB6(blonde) != blonde) throw new RuntimeException("hairTest Global B6 failed");
+ if (enum_thorough_simple.hairTestB7(blonde) != blonde) throw new RuntimeException("hairTest Global B7 failed");
+ if (enum_thorough_simple.hairTestB8(blonde) != blonde) throw new RuntimeException("hairTest Global B8 failed");
+ if (enum_thorough_simple.hairTestB9(blonde) != blonde) throw new RuntimeException("hairTest Global B9 failed");
+ if (enum_thorough_simple.hairTestBA(blonde) != blonde) throw new RuntimeException("hairTest Global BA failed");
+ if (enum_thorough_simple.hairTestBB(blonde) != blonde) throw new RuntimeException("hairTest Global BB failed");
+ if (enum_thorough_simple.hairTestBC(blonde) != blonde) throw new RuntimeException("hairTest Global BC failed");
+
+ if (enum_thorough_simple.hairTestC1(blonde) != blonde) throw new RuntimeException("hairTest Global C1 failed");
+ if (enum_thorough_simple.hairTestC2(blonde) != blonde) throw new RuntimeException("hairTest Global C2 failed");
+ if (enum_thorough_simple.hairTestC3(blonde) != blonde) throw new RuntimeException("hairTest Global C3 failed");
+ if (enum_thorough_simple.hairTestC4(blonde) != blonde) throw new RuntimeException("hairTest Global C4 failed");
+ if (enum_thorough_simple.hairTestC5(blonde) != blonde) throw new RuntimeException("hairTest Global C5 failed");
+ if (enum_thorough_simple.hairTestC6(blonde) != blonde) throw new RuntimeException("hairTest Global C6 failed");
+ if (enum_thorough_simple.hairTestC7(blonde) != blonde) throw new RuntimeException("hairTest Global C7 failed");
+ if (enum_thorough_simple.hairTestC8(blonde) != blonde) throw new RuntimeException("hairTest Global C8 failed");
+ if (enum_thorough_simple.hairTestC9(blonde) != blonde) throw new RuntimeException("hairTest Global C9 failed");
+ if (enum_thorough_simple.hairTestCA(blonde) != blonde) throw new RuntimeException("hairTest Global CA failed");
+ if (enum_thorough_simple.hairTestCB(blonde) != blonde) throw new RuntimeException("hairTest Global CB failed");
+ if (enum_thorough_simple.hairTestCC(blonde) != blonde) throw new RuntimeException("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ int blonde = HairStruct.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new RuntimeException("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new RuntimeException("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new RuntimeException("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new RuntimeException("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new RuntimeException("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new RuntimeException("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new RuntimeException("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new RuntimeException("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new RuntimeException("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new RuntimeException("hairTestFir A failed");
+ }
+ {
+ enum_thorough_simple.setGlobalInstance(enum_thorough_simple.globalinstance2);
+ if (enum_thorough_simple.getGlobalInstance() != enum_thorough_simple.globalinstance2) throw new RuntimeException("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.setMemberInstance(Instances.memberinstance3);
+ if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.one) != 1) throw new RuntimeException("repeatTest 1 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.initial) != 1) throw new RuntimeException("repeatTest 2 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.two) != 2) throw new RuntimeException("repeatTest 3 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.three) != 3) throw new RuntimeException("repeatTest 4 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/trunk/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
new file mode 100644
index 000000000..b00788911
--- /dev/null
+++ b/trunk/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
@@ -0,0 +1,421 @@
+
+import enum_thorough_typeunsafe.*;
+
+public class enum_thorough_typeunsafe_runme {
+
+ static {
+ try {
+ System.loadLibrary("enum_thorough_typeunsafe");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ {
+ // Anonymous enums
+ int i = enum_thorough_typeunsafe.AnonEnum1;
+ if (enum_thorough_typeunsafe.ReallyAnInteger != 200) throw new RuntimeException("Test Anon 1 failed");
+ int j = enum_thorough_typeunsafe.AnonSpaceEnum1;
+ int k = AnonStruct.AnonStructEnum1;
+ }
+ {
+ int red = colour.red;
+ enum_thorough_typeunsafe.colourTest1(red);
+ enum_thorough_typeunsafe.colourTest2(red);
+ enum_thorough_typeunsafe.colourTest3(red);
+ enum_thorough_typeunsafe.colourTest4(red);
+ enum_thorough_typeunsafe.setMyColour(red);
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ int speed = SpeedClass.speed.slow;
+ if (s.speedTest1(speed) != speed) throw new RuntimeException("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new RuntimeException("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new RuntimeException("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new RuntimeException("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new RuntimeException("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new RuntimeException("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new RuntimeException("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new RuntimeException("speedTest 8 failed");
+
+ if (enum_thorough_typeunsafe.speedTest1(speed) != speed) throw new RuntimeException("speedTest Global 1 failed");
+ if (enum_thorough_typeunsafe.speedTest2(speed) != speed) throw new RuntimeException("speedTest Global 2 failed");
+ if (enum_thorough_typeunsafe.speedTest3(speed) != speed) throw new RuntimeException("speedTest Global 3 failed");
+ if (enum_thorough_typeunsafe.speedTest4(speed) != speed) throw new RuntimeException("speedTest Global 4 failed");
+ if (enum_thorough_typeunsafe.speedTest5(speed) != speed) throw new RuntimeException("speedTest Global 5 failed");
+ }
+ {
+ SpeedClass s = new SpeedClass();
+ int slow = SpeedClass.speed.slow;
+ int lightning = SpeedClass.speed.lightning;
+
+ if (s.getMySpeedtd1() != slow) throw new RuntimeException("mySpeedtd1 1 failed");
+ if (s.getMySpeedtd1() != 10) throw new RuntimeException("mySpeedtd1 2 failed");
+
+ s.setMySpeedtd1(lightning);
+ if (s.getMySpeedtd1() != lightning) throw new RuntimeException("mySpeedtd1 3 failed");
+ if (s.getMySpeedtd1() != 31) throw new RuntimeException("mySpeedtd1 4 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest 1 failed");
+ }
+ {
+ int val = twonames.TwoNames2;
+ if (enum_thorough_typeunsafe.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (enum_thorough_typeunsafe.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (enum_thorough_typeunsafe.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ TwoNamesStruct t = new TwoNamesStruct();
+ int val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new RuntimeException("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new RuntimeException("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new RuntimeException("twonamesTest 3 failed");
+ }
+ {
+ int val = namedanonspace.NamedAnonSpace2;
+ if (enum_thorough_typeunsafe.namedanonspaceTest1(val) != val) throw new RuntimeException("namedanonspaceTest 1 failed");
+ if (enum_thorough_typeunsafe.namedanonspaceTest2(val) != val) throw new RuntimeException("namedanonspaceTest 2 failed");
+ if (enum_thorough_typeunsafe.namedanonspaceTest3(val) != val) throw new RuntimeException("namedanonspaceTest 3 failed");
+ if (enum_thorough_typeunsafe.namedanonspaceTest4(val) != val) throw new RuntimeException("namedanonspaceTest 4 failed");
+ }
+ {
+ TemplateClassInt t = new TemplateClassInt();
+ int galileo = TemplateClassInt.scientists.galileo;
+
+ if (t.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new RuntimeException("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new RuntimeException("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new RuntimeException("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new RuntimeException("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new RuntimeException("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new RuntimeException("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new RuntimeException("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new RuntimeException("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new RuntimeException("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new RuntimeException("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new RuntimeException("scientistsTest J failed");
+
+ if (enum_thorough_typeunsafe.scientistsTest1(galileo) != galileo) throw new RuntimeException("scientistsTest Global 1 failed");
+ if (enum_thorough_typeunsafe.scientistsTest2(galileo) != galileo) throw new RuntimeException("scientistsTest Global 2 failed");
+ if (enum_thorough_typeunsafe.scientistsTest3(galileo) != galileo) throw new RuntimeException("scientistsTest Global 3 failed");
+ if (enum_thorough_typeunsafe.scientistsTest4(galileo) != galileo) throw new RuntimeException("scientistsTest Global 4 failed");
+ if (enum_thorough_typeunsafe.scientistsTest5(galileo) != galileo) throw new RuntimeException("scientistsTest Global 5 failed");
+ if (enum_thorough_typeunsafe.scientistsTest6(galileo) != galileo) throw new RuntimeException("scientistsTest Global 6 failed");
+ if (enum_thorough_typeunsafe.scientistsTest7(galileo) != galileo) throw new RuntimeException("scientistsTest Global 7 failed");
+ if (enum_thorough_typeunsafe.scientistsTest8(galileo) != galileo) throw new RuntimeException("scientistsTest Global 8 failed");
+ }
+ {
+ TClassInt t = new TClassInt();
+ int bell = TClassInt.scientists.bell;
+ int galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new RuntimeException("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new RuntimeException("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new RuntimeException("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new RuntimeException("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new RuntimeException("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new RuntimeException("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new RuntimeException("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new RuntimeException("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new RuntimeException("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new RuntimeException("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new RuntimeException("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new RuntimeException("scientistsOtherTest 7 failed");
+
+ if (enum_thorough_typeunsafe.scientistsNameTest1(bell) != bell) throw new RuntimeException("scientistsNameTest Global 1 failed");
+ if (enum_thorough_typeunsafe.scientistsNameTest2(bell) != bell) throw new RuntimeException("scientistsNameTest Global 2 failed");
+ if (enum_thorough_typeunsafe.scientistsNameTest3(bell) != bell) throw new RuntimeException("scientistsNameTest Global 3 failed");
+ if (enum_thorough_typeunsafe.scientistsNameTest4(bell) != bell) throw new RuntimeException("scientistsNameTest Global 4 failed");
+ if (enum_thorough_typeunsafe.scientistsNameTest5(bell) != bell) throw new RuntimeException("scientistsNameTest Global 5 failed");
+ if (enum_thorough_typeunsafe.scientistsNameTest6(bell) != bell) throw new RuntimeException("scientistsNameTest Global 6 failed");
+ if (enum_thorough_typeunsafe.scientistsNameTest7(bell) != bell) throw new RuntimeException("scientistsNameTest Global 7 failed");
+
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest1(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 1 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest2(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 2 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest3(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 3 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest4(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 4 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest5(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 5 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest6(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 6 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest7(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 7 failed");
+
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest8(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 8 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTest9(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global 9 failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestA(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global A failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestB(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global B failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestC(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global C failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestD(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global D failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestE(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global E failed");
+
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestF(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global F failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestG(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global G failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestH(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global H failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestI(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global I failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestJ(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global J failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestK(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global K failed");
+ if (enum_thorough_typeunsafe.scientistsNameSpaceTestL(bell) != bell) throw new RuntimeException("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ int val = newname.argh;
+ if (enum_thorough_typeunsafe.renameTest1(val) != val) throw new RuntimeException("renameTest Global 1 failed");
+ if (enum_thorough_typeunsafe.renameTest2(val) != val) throw new RuntimeException("renameTest Global 2 failed");
+ }
+ {
+ NewNameStruct n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest 6 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new RuntimeException("renameTest Global 3 failed");
+ if (enum_thorough_typeunsafe.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new RuntimeException("renameTest Global 4 failed");
+ if (enum_thorough_typeunsafe.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 5 failed");
+ if (enum_thorough_typeunsafe.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new RuntimeException("renameTest Global 6 failed");
+ if (enum_thorough_typeunsafe.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new RuntimeException("renameTest Global 7 failed");
+ }
+ {
+ TreesClass t = new TreesClass();
+ int pine = TreesClass.trees.pine;
+
+ if (t.treesTest1(pine) != pine) throw new RuntimeException("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new RuntimeException("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new RuntimeException("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new RuntimeException("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new RuntimeException("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new RuntimeException("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new RuntimeException("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new RuntimeException("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new RuntimeException("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new RuntimeException("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new RuntimeException("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new RuntimeException("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new RuntimeException("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new RuntimeException("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new RuntimeException("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new RuntimeException("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new RuntimeException("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new RuntimeException("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new RuntimeException("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new RuntimeException("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new RuntimeException("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new RuntimeException("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new RuntimeException("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new RuntimeException("treesTest O failed");
+
+ if (enum_thorough_typeunsafe.treesTest1(pine) != pine) throw new RuntimeException("treesTest Global 1 failed");
+ if (enum_thorough_typeunsafe.treesTest2(pine) != pine) throw new RuntimeException("treesTest Global 2 failed");
+ if (enum_thorough_typeunsafe.treesTest3(pine) != pine) throw new RuntimeException("treesTest Global 3 failed");
+ if (enum_thorough_typeunsafe.treesTest4(pine) != pine) throw new RuntimeException("treesTest Global 4 failed");
+ if (enum_thorough_typeunsafe.treesTest5(pine) != pine) throw new RuntimeException("treesTest Global 5 failed");
+ if (enum_thorough_typeunsafe.treesTest6(pine) != pine) throw new RuntimeException("treesTest Global 6 failed");
+ if (enum_thorough_typeunsafe.treesTest7(pine) != pine) throw new RuntimeException("treesTest Global 7 failed");
+ if (enum_thorough_typeunsafe.treesTest8(pine) != pine) throw new RuntimeException("treesTest Global 8 failed");
+ if (enum_thorough_typeunsafe.treesTest9(pine) != pine) throw new RuntimeException("treesTest Global 9 failed");
+ if (enum_thorough_typeunsafe.treesTestA(pine) != pine) throw new RuntimeException("treesTest Global A failed");
+ if (enum_thorough_typeunsafe.treesTestB(pine) != pine) throw new RuntimeException("treesTest Global B failed");
+ if (enum_thorough_typeunsafe.treesTestC(pine) != pine) throw new RuntimeException("treesTest Global C failed");
+ if (enum_thorough_typeunsafe.treesTestD(pine) != pine) throw new RuntimeException("treesTest Global D failed");
+ if (enum_thorough_typeunsafe.treesTestE(pine) != pine) throw new RuntimeException("treesTest Global E failed");
+ if (enum_thorough_typeunsafe.treesTestF(pine) != pine) throw new RuntimeException("treesTest Global F failed");
+ if (enum_thorough_typeunsafe.treesTestG(pine) != pine) throw new RuntimeException("treesTest Global G failed");
+ if (enum_thorough_typeunsafe.treesTestH(pine) != pine) throw new RuntimeException("treesTest Global H failed");
+ if (enum_thorough_typeunsafe.treesTestI(pine) != pine) throw new RuntimeException("treesTest Global I failed");
+ if (enum_thorough_typeunsafe.treesTestJ(pine) != pine) throw new RuntimeException("treesTest Global J failed");
+ if (enum_thorough_typeunsafe.treesTestK(pine) != pine) throw new RuntimeException("treesTest Global K failed");
+ if (enum_thorough_typeunsafe.treesTestL(pine) != pine) throw new RuntimeException("treesTest Global L failed");
+ if (enum_thorough_typeunsafe.treesTestM(pine) != pine) throw new RuntimeException("treesTest Global M failed");
+// if (enum_thorough_typeunsafe.treesTestN(pine) != pine) throw new RuntimeException("treesTest Global N failed");
+ if (enum_thorough_typeunsafe.treesTestO(pine) != pine) throw new RuntimeException("treesTest Global O failed");
+ if (enum_thorough_typeunsafe.treesTestP(pine) != pine) throw new RuntimeException("treesTest Global P failed");
+ if (enum_thorough_typeunsafe.treesTestQ(pine) != pine) throw new RuntimeException("treesTest Global Q failed");
+ if (enum_thorough_typeunsafe.treesTestR(pine) != pine) throw new RuntimeException("treesTest Global R failed");
+ }
+ {
+ HairStruct h = new HairStruct();
+ int ginger = HairStruct.hair.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new RuntimeException("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new RuntimeException("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new RuntimeException("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new RuntimeException("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new RuntimeException("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new RuntimeException("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new RuntimeException("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new RuntimeException("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new RuntimeException("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new RuntimeException("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new RuntimeException("hairTest B failed");
+
+ int red = colour.red;
+ if (h.colourTest1(red) != red) throw new RuntimeException("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new RuntimeException("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new RuntimeException("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new RuntimeException("namedanonspaceTest HairStruct 1 failed");
+
+ int fir = TreesClass.trees.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new RuntimeException("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ int blonde = HairStruct.hair.blonde;
+ if (enum_thorough_typeunsafe.hairTest1(blonde) != blonde) throw new RuntimeException("hairTest Global 1 failed");
+ if (enum_thorough_typeunsafe.hairTest2(blonde) != blonde) throw new RuntimeException("hairTest Global 2 failed");
+ if (enum_thorough_typeunsafe.hairTest3(blonde) != blonde) throw new RuntimeException("hairTest Global 3 failed");
+ if (enum_thorough_typeunsafe.hairTest4(blonde) != blonde) throw new RuntimeException("hairTest Global 4 failed");
+ if (enum_thorough_typeunsafe.hairTest5(blonde) != blonde) throw new RuntimeException("hairTest Global 5 failed");
+ if (enum_thorough_typeunsafe.hairTest6(blonde) != blonde) throw new RuntimeException("hairTest Global 6 failed");
+ if (enum_thorough_typeunsafe.hairTest7(blonde) != blonde) throw new RuntimeException("hairTest Global 7 failed");
+ if (enum_thorough_typeunsafe.hairTest8(blonde) != blonde) throw new RuntimeException("hairTest Global 8 failed");
+ if (enum_thorough_typeunsafe.hairTest9(blonde) != blonde) throw new RuntimeException("hairTest Global 9 failed");
+ if (enum_thorough_typeunsafe.hairTestA(blonde) != blonde) throw new RuntimeException("hairTest Global A failed");
+ if (enum_thorough_typeunsafe.hairTestB(blonde) != blonde) throw new RuntimeException("hairTest Global B failed");
+ if (enum_thorough_typeunsafe.hairTestC(blonde) != blonde) throw new RuntimeException("hairTest Global C failed");
+
+ if (enum_thorough_typeunsafe.hairTestA1(blonde) != blonde) throw new RuntimeException("hairTest Global A1 failed");
+ if (enum_thorough_typeunsafe.hairTestA2(blonde) != blonde) throw new RuntimeException("hairTest Global A2 failed");
+ if (enum_thorough_typeunsafe.hairTestA3(blonde) != blonde) throw new RuntimeException("hairTest Global A3 failed");
+ if (enum_thorough_typeunsafe.hairTestA4(blonde) != blonde) throw new RuntimeException("hairTest Global A4 failed");
+ if (enum_thorough_typeunsafe.hairTestA5(blonde) != blonde) throw new RuntimeException("hairTest Global A5 failed");
+ if (enum_thorough_typeunsafe.hairTestA6(blonde) != blonde) throw new RuntimeException("hairTest Global A6 failed");
+ if (enum_thorough_typeunsafe.hairTestA7(blonde) != blonde) throw new RuntimeException("hairTest Global A7 failed");
+ if (enum_thorough_typeunsafe.hairTestA8(blonde) != blonde) throw new RuntimeException("hairTest Global A8 failed");
+ if (enum_thorough_typeunsafe.hairTestA9(blonde) != blonde) throw new RuntimeException("hairTest Global A9 failed");
+ if (enum_thorough_typeunsafe.hairTestAA(blonde) != blonde) throw new RuntimeException("hairTest Global AA failed");
+ if (enum_thorough_typeunsafe.hairTestAB(blonde) != blonde) throw new RuntimeException("hairTest Global AB failed");
+ if (enum_thorough_typeunsafe.hairTestAC(blonde) != blonde) throw new RuntimeException("hairTest Global AC failed");
+
+ if (enum_thorough_typeunsafe.hairTestB1(blonde) != blonde) throw new RuntimeException("hairTest Global B1 failed");
+ if (enum_thorough_typeunsafe.hairTestB2(blonde) != blonde) throw new RuntimeException("hairTest Global B2 failed");
+ if (enum_thorough_typeunsafe.hairTestB3(blonde) != blonde) throw new RuntimeException("hairTest Global B3 failed");
+ if (enum_thorough_typeunsafe.hairTestB4(blonde) != blonde) throw new RuntimeException("hairTest Global B4 failed");
+ if (enum_thorough_typeunsafe.hairTestB5(blonde) != blonde) throw new RuntimeException("hairTest Global B5 failed");
+ if (enum_thorough_typeunsafe.hairTestB6(blonde) != blonde) throw new RuntimeException("hairTest Global B6 failed");
+ if (enum_thorough_typeunsafe.hairTestB7(blonde) != blonde) throw new RuntimeException("hairTest Global B7 failed");
+ if (enum_thorough_typeunsafe.hairTestB8(blonde) != blonde) throw new RuntimeException("hairTest Global B8 failed");
+ if (enum_thorough_typeunsafe.hairTestB9(blonde) != blonde) throw new RuntimeException("hairTest Global B9 failed");
+ if (enum_thorough_typeunsafe.hairTestBA(blonde) != blonde) throw new RuntimeException("hairTest Global BA failed");
+ if (enum_thorough_typeunsafe.hairTestBB(blonde) != blonde) throw new RuntimeException("hairTest Global BB failed");
+ if (enum_thorough_typeunsafe.hairTestBC(blonde) != blonde) throw new RuntimeException("hairTest Global BC failed");
+
+ if (enum_thorough_typeunsafe.hairTestC1(blonde) != blonde) throw new RuntimeException("hairTest Global C1 failed");
+ if (enum_thorough_typeunsafe.hairTestC2(blonde) != blonde) throw new RuntimeException("hairTest Global C2 failed");
+ if (enum_thorough_typeunsafe.hairTestC3(blonde) != blonde) throw new RuntimeException("hairTest Global C3 failed");
+ if (enum_thorough_typeunsafe.hairTestC4(blonde) != blonde) throw new RuntimeException("hairTest Global C4 failed");
+ if (enum_thorough_typeunsafe.hairTestC5(blonde) != blonde) throw new RuntimeException("hairTest Global C5 failed");
+ if (enum_thorough_typeunsafe.hairTestC6(blonde) != blonde) throw new RuntimeException("hairTest Global C6 failed");
+ if (enum_thorough_typeunsafe.hairTestC7(blonde) != blonde) throw new RuntimeException("hairTest Global C7 failed");
+ if (enum_thorough_typeunsafe.hairTestC8(blonde) != blonde) throw new RuntimeException("hairTest Global C8 failed");
+ if (enum_thorough_typeunsafe.hairTestC9(blonde) != blonde) throw new RuntimeException("hairTest Global C9 failed");
+ if (enum_thorough_typeunsafe.hairTestCA(blonde) != blonde) throw new RuntimeException("hairTest Global CA failed");
+ if (enum_thorough_typeunsafe.hairTestCB(blonde) != blonde) throw new RuntimeException("hairTest Global CB failed");
+ if (enum_thorough_typeunsafe.hairTestCC(blonde) != blonde) throw new RuntimeException("hairTest Global CC failed");
+ }
+ {
+ FirStruct f = new FirStruct();
+ int blonde = HairStruct.hair.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new RuntimeException("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new RuntimeException("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new RuntimeException("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new RuntimeException("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new RuntimeException("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new RuntimeException("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new RuntimeException("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new RuntimeException("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new RuntimeException("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new RuntimeException("hairTestFir A failed");
+ }
+ {
+ enum_thorough_typeunsafe.setGlobalInstance(enum_thorough_typeunsafe.globalinstance2);
+ if (enum_thorough_typeunsafe.getGlobalInstance() != enum_thorough_typeunsafe.globalinstance2) throw new RuntimeException("GlobalInstance 1 failed");
+
+ Instances i = new Instances();
+ i.setMemberInstance(Instances.memberinstance3);
+ if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (enum_thorough_typeunsafe.repeatTest(repeat.one) != 1) throw new RuntimeException("repeatTest 1 failed");
+ if (enum_thorough_typeunsafe.repeatTest(repeat.initial) != 1) throw new RuntimeException("repeatTest 2 failed");
+ if (enum_thorough_typeunsafe.repeatTest(repeat.two) != 2) throw new RuntimeException("repeatTest 3 failed");
+ if (enum_thorough_typeunsafe.repeatTest(repeat.three) != 3) throw new RuntimeException("repeatTest 4 failed");
+ if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/extend_default_runme.java b/trunk/Examples/test-suite/java/extend_default_runme.java
new file mode 100644
index 000000000..49c52f4f9
--- /dev/null
+++ b/trunk/Examples/test-suite/java/extend_default_runme.java
@@ -0,0 +1,226 @@
+
+import extend_default.Override;
+import extend_default.*;
+
+public class extend_default_runme {
+ static {
+ try {
+ System.loadLibrary("extend_default");
+ } 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[])
+ {
+ // %extend before the class definition
+ {
+ Before ex = new Before();
+ if (ex.getI() != -1.0 && ex.getD() != -1.0)
+ throw new RuntimeException("Before constructor 1 failed");
+
+ ex = new Before(10);
+ if (ex.getI() != 10.0 && ex.getD() != -1.0)
+ throw new RuntimeException("Before constructor 2 failed");
+
+ ex = new Before(20, 30.0);
+ if (ex.getI() != 20 && ex.getD() != 30.0)
+ throw new RuntimeException("Before constructor 3 failed");
+ }
+ {
+ Before ex = new Before();
+ if (ex.AddedMethod() != -2.0)
+ throw new RuntimeException("Before AddedMethod 1 failed");
+ if (ex.AddedMethod(-2) != -3.0)
+ throw new RuntimeException("Before AddedMethod 2 failed");
+ if (ex.AddedMethod(-10, -10.0) != -20)
+ throw new RuntimeException("Before AddedMethod 3 failed");
+ }
+ {
+ if (Before.AddedStaticMethod() != -2.0)
+ throw new RuntimeException("Before AddedStaticMethod 1 failed");
+ if (Before.AddedStaticMethod(-2) != -3.0)
+ throw new RuntimeException("Before AddedStaticMethod 2 failed");
+ if (Before.AddedStaticMethod(-10, -10.0) != -20)
+ throw new RuntimeException("Before AddedStaticMethod 3 failed");
+ }
+
+ // %extend after the class definition
+ {
+ After ex = new After();
+ if (ex.getI() != -1.0 && ex.getD() != -1.0)
+ throw new RuntimeException("After constructor 1 failed");
+
+ ex = new After(10);
+ if (ex.getI() != 10.0 && ex.getD() != -1.0)
+ throw new RuntimeException("After constructor 2 failed");
+
+ ex = new After(20, 30.0);
+ if (ex.getI() != 20 && ex.getD() != 30.0)
+ throw new RuntimeException("After constructor 3 failed");
+ }
+ {
+ After ex = new After();
+ if (ex.AddedMethod() != -2.0)
+ throw new RuntimeException("After AddedMethod 1 failed");
+ if (ex.AddedMethod(-2) != -3.0)
+ throw new RuntimeException("After AddedMethod 2 failed");
+ if (ex.AddedMethod(-10, -10.0) != -20)
+ throw new RuntimeException("After AddedMethod 3 failed");
+ }
+ {
+ if (After.AddedStaticMethod() != -2.0)
+ throw new RuntimeException("After AddedStaticMethod 1 failed");
+ if (After.AddedStaticMethod(-2) != -3.0)
+ throw new RuntimeException("After AddedStaticMethod 2 failed");
+ if (After.AddedStaticMethod(-10, -10.0) != -20)
+ throw new RuntimeException("After AddedStaticMethod 3 failed");
+ }
+
+ // %extend before the class definition - with overloading and default args
+ {
+ OverBefore ex = new OverBefore();
+ if (ex.getI() != -1.0 && ex.getD() != -1.0)
+ throw new RuntimeException("OverBefore constructor 1 failed");
+
+ ex = new OverBefore(10);
+ if (ex.getI() != 10.0 && ex.getD() != -1.0)
+ throw new RuntimeException("OverBefore constructor 2 failed");
+
+ ex = new OverBefore(20, 30.0);
+ if (ex.getI() != 20 && ex.getD() != 30.0)
+ throw new RuntimeException("OverBefore constructor 3 failed");
+ }
+ {
+ OverBefore ex = new OverBefore();
+ if (ex.AddedMethod() != -2.0)
+ throw new RuntimeException("OverBefore AddedMethod 1 failed");
+ if (ex.AddedMethod(-2) != -3.0)
+ throw new RuntimeException("OverBefore AddedMethod 2 failed");
+ if (ex.AddedMethod(-10, -10.0) != -20)
+ throw new RuntimeException("OverBefore AddedMethod 3 failed");
+ }
+ {
+ if (OverBefore.AddedStaticMethod() != -2.0)
+ throw new RuntimeException("OverBefore AddedStaticMethod 1 failed");
+ if (OverBefore.AddedStaticMethod(-2) != -3.0)
+ throw new RuntimeException("OverBefore AddedStaticMethod 2 failed");
+ if (OverBefore.AddedStaticMethod(-10, -10.0) != -20)
+ throw new RuntimeException("OverBefore AddedStaticMethod 3 failed");
+ }
+ {
+ OverBefore ex = new OverBefore("hello");
+ if (ex.getI() != -2.0 && ex.getD() != -2.0)
+ throw new RuntimeException("OverBefore overload constructor 1 failed");
+
+ ex = new OverBefore("hello", 10);
+ if (ex.getI() != 10.0 && ex.getD() != -1.0)
+ throw new RuntimeException("OverBefore overload constructor 2 failed");
+
+ ex = new OverBefore("hello", 20, 30.0);
+ if (ex.getI() != 20 && ex.getD() != 30.0)
+ throw new RuntimeException("OverBefore overload constructor 3 failed");
+ }
+ {
+ OverBefore ex = new OverBefore("hello");
+ if (ex.AddedMethod("hello") != -2.0)
+ throw new RuntimeException("OverBefore overload AddedMethod 1 failed");
+ if (ex.AddedMethod("hello", -2) != -3.0)
+ throw new RuntimeException("OverBefore overload AddedMethod 2 failed");
+ if (ex.AddedMethod("hello", -10, -10.0) != -20)
+ throw new RuntimeException("OverBefore overload AddedMethod 3 failed");
+ }
+ {
+ if (OverBefore.AddedStaticMethod("hello") != -2.0)
+ throw new RuntimeException("OverBefore overload AddedStaticMethod 1 failed");
+ if (OverBefore.AddedStaticMethod("hello", -2) != -3.0)
+ throw new RuntimeException("OverBefore overload AddedStaticMethod 2 failed");
+ if (OverBefore.AddedStaticMethod("hello", -10, -10.0) != -20)
+ throw new RuntimeException("OverBefore overload AddedStaticMethod 3 failed");
+ }
+
+ // %extend after the class definition - with overloading and default args
+ {
+ OverAfter ex = new OverAfter();
+ if (ex.getI() != -1.0 && ex.getD() != -1.0)
+ throw new RuntimeException("OverAfter constructor 1 failed");
+
+ ex = new OverAfter(10);
+ if (ex.getI() != 10.0 && ex.getD() != -1.0)
+ throw new RuntimeException("OverAfter constructor 2 failed");
+
+ ex = new OverAfter(20, 30.0);
+ if (ex.getI() != 20 && ex.getD() != 30.0)
+ throw new RuntimeException("OverAfter constructor 3 failed");
+ }
+ {
+ OverAfter ex = new OverAfter();
+ if (ex.AddedMethod() != -2.0)
+ throw new RuntimeException("OverAfter AddedMethod 1 failed");
+ if (ex.AddedMethod(-2) != -3.0)
+ throw new RuntimeException("OverAfter AddedMethod 2 failed");
+ if (ex.AddedMethod(-10, -10.0) != -20)
+ throw new RuntimeException("OverAfter AddedMethod 3 failed");
+ }
+ {
+ if (OverAfter.AddedStaticMethod() != -2.0)
+ throw new RuntimeException("OverAfter AddedStaticMethod 1 failed");
+ if (OverAfter.AddedStaticMethod(-2) != -3.0)
+ throw new RuntimeException("OverAfter AddedStaticMethod 2 failed");
+ if (OverAfter.AddedStaticMethod(-10, -10.0) != -20)
+ throw new RuntimeException("OverAfter AddedStaticMethod 3 failed");
+ }
+ {
+ OverAfter ex = new OverAfter("hello");
+ if (ex.getI() != -2.0 && ex.getD() != -2.0)
+ throw new RuntimeException("OverAfter overload constructor 1 failed");
+
+ ex = new OverAfter("hello", 10);
+ if (ex.getI() != 10.0 && ex.getD() != -1.0)
+ throw new RuntimeException("OverAfter overload constructor 2 failed");
+
+ ex = new OverAfter("hello", 20, 30.0);
+ if (ex.getI() != 20 && ex.getD() != 30.0)
+ throw new RuntimeException("OverAfter overload constructor 3 failed");
+ }
+ {
+ OverAfter ex = new OverAfter("hello");
+ if (ex.AddedMethod("hello") != -2.0)
+ throw new RuntimeException("OverAfter overload AddedMethod 1 failed");
+ if (ex.AddedMethod("hello", -2) != -3.0)
+ throw new RuntimeException("OverAfter overload AddedMethod 2 failed");
+ if (ex.AddedMethod("hello", -10, -10.0) != -20)
+ throw new RuntimeException("OverAfter overload AddedMethod 3 failed");
+ }
+ {
+ if (OverAfter.AddedStaticMethod("hello") != -2.0)
+ throw new RuntimeException("OverAfter overload AddedStaticMethod 1 failed");
+ if (OverAfter.AddedStaticMethod("hello", -2) != -3.0)
+ throw new RuntimeException("OverAfter overload AddedStaticMethod 2 failed");
+ if (OverAfter.AddedStaticMethod("hello", -10, -10.0) != -20)
+ throw new RuntimeException("OverAfter overload AddedStaticMethod 3 failed");
+ }
+
+ // Override
+ {
+ Override o = new Override();
+
+ if (o.over() != -1)
+ throw new RuntimeException("override test 1 failed");
+ if (o.over(10) != 10*10)
+ throw new RuntimeException("override test 2 failed");
+
+ if (o.ride() != -1)
+ throw new RuntimeException("override test 3 failed");
+ if (o.ride(10) != 10)
+ throw new RuntimeException("override test 4 failed");
+
+ if (o.overload() != -10)
+ throw new RuntimeException("override test 5 failed");
+ if (o.overload(10) != 10*10)
+ throw new RuntimeException("override test 6 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/extern_declaration_runme.java b/trunk/Examples/test-suite/java/extern_declaration_runme.java
new file mode 100644
index 000000000..e1d7eb180
--- /dev/null
+++ b/trunk/Examples/test-suite/java/extern_declaration_runme.java
@@ -0,0 +1,21 @@
+
+import extern_declaration.*;
+
+public class extern_declaration_runme {
+ static {
+ try {
+ System.loadLibrary("extern_declaration");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ if (extern_declaration.externimport(100) != 100) throw new RuntimeException("externimport failed");
+ if (extern_declaration.externexport(200) != 200) throw new RuntimeException("externexport failed");
+ if (extern_declaration.externstdcall(300) != 300) throw new RuntimeException("externstdcall failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/global_namespace_runme.java b/trunk/Examples/test-suite/java/global_namespace_runme.java
new file mode 100644
index 000000000..faab7d4ba
--- /dev/null
+++ b/trunk/Examples/test-suite/java/global_namespace_runme.java
@@ -0,0 +1,25 @@
+import global_namespace.*;
+
+public class global_namespace_runme {
+
+ static {
+ try {
+ System.loadLibrary("global_namespace");
+ } 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[]) {
+
+ KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+ KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+
+ XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
+ XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
+
+ TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
+ TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/ignore_parameter_runme.java b/trunk/Examples/test-suite/java/ignore_parameter_runme.java
new file mode 100644
index 000000000..7dbcb06db
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/imports_runme.java b/trunk/Examples/test-suite/java/imports_runme.java
new file mode 100644
index 000000000..b82862b67
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/inctest_runme.java b/trunk/Examples/test-suite/java/inctest_runme.java
new file mode 100644
index 000000000..4c298ad20
--- /dev/null
+++ b/trunk/Examples/test-suite/java/inctest_runme.java
@@ -0,0 +1,21 @@
+
+import inctest.*;
+
+public class inctest_runme {
+ static {
+ try {
+ System.loadLibrary("inctest");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ MY_THINGS things = new MY_THINGS();
+ int i=0;
+ things.setIntegerMember(i);
+ double d = things.getDoubleMember();
+ }
+}
diff --git a/trunk/Examples/test-suite/java/inherit_target_language_runme.java b/trunk/Examples/test-suite/java/inherit_target_language_runme.java
new file mode 100644
index 000000000..184272fe2
--- /dev/null
+++ b/trunk/Examples/test-suite/java/inherit_target_language_runme.java
@@ -0,0 +1,35 @@
+
+import inherit_target_language.*;
+
+
+public class inherit_target_language_runme {
+
+ static {
+ try {
+ System.loadLibrary("inherit_target_language");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ new Derived1().targetLanguageBaseMethod();
+ new Derived2().targetLanguageBaseMethod();
+
+ new MultipleDerived1().targetLanguageBaseMethod();
+ new MultipleDerived2().targetLanguageBaseMethod();
+ new MultipleDerived3().f();
+ new MultipleDerived4().g();
+
+ BaseX baseX = new BaseX();
+ baseX.basex();
+ baseX.targetLanguageBase2Method();
+
+ DerivedX derivedX = new DerivedX();
+ derivedX.basex();
+ derivedX.derivedx();
+ derivedX.targetLanguageBase2Method();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/intermediary_classname_runme.java b/trunk/Examples/test-suite/java/intermediary_classname_runme.java
new file mode 100644
index 000000000..03efc030c
--- /dev/null
+++ b/trunk/Examples/test-suite/java/intermediary_classname_runme.java
@@ -0,0 +1,24 @@
+
+import intermediary_classname.*;
+
+public class intermediary_classname_runme {
+ static {
+ try {
+ System.loadLibrary("intermediary_classname");
+ } 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 the renamed module class is correctly named
+ double d = intermediary_classnameModule.maxdouble(10.0, 20.0);
+ if (d!=20.0) throw new RuntimeException("Test failed");
+
+ // test the renamed intermediary class is correctly named
+ long ptr = intermediary_classname.new_vecdouble(10);
+ intermediary_classname.delete_vecdouble(ptr);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/java_constants_runme.java b/trunk/Examples/test-suite/java/java_constants_runme.java
new file mode 100644
index 000000000..be2ece08a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/java_director_runme.java b/trunk/Examples/test-suite/java/java_director_runme.java
new file mode 100644
index 000000000..86c92d49a
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_director_runme.java
@@ -0,0 +1,92 @@
+// Mainly tests that directors are finalized correctly
+
+import java_director.*;
+
+public class java_director_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_director");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ QuuxContainer qc = createContainer();
+
+ int instances = Quux.instances();
+ if (instances != 4)
+ throw new RuntimeException("Quux instances should be 4, actually " + instances);
+
+ for (int i = 0; i < qc.size(); ++i) {
+ Quux q = qc.get(i);
+
+ if (!q.director_method().equals(qc.invoke(i))) {
+ throw new RuntimeException ( "q.director_method()/qv.invoke(" + i + ")");
+ }
+ }
+
+ qc = null;
+ /* Watch qc get reaped, which causes the C++ object to delete
+ objects from the internal vector */
+ System.gc();
+ System.runFinalization();
+
+ // Give the finalizers a chance to run
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+
+ /* Watch the Quux objects formerly in the QuuxContainer object
+ get reaped */
+ System.gc();
+ System.runFinalization();
+
+ instances = Quux.instances();
+ if (instances != 0)
+ throw new RuntimeException("Quux instances should be 0, actually " + instances);
+
+ /* Test Quux1's director disconnect method rename */
+ Quux1 quux1 = new Quux1("quux1");
+ if (quux1.disconnectMethodCalled)
+ throw new RuntimeException("Oops");
+ quux1.delete();
+ if (!quux1.disconnectMethodCalled)
+ throw new RuntimeException("disconnect method not called");
+ }
+
+ public static QuuxContainer createContainer() {
+ QuuxContainer qc = new QuuxContainer();
+
+ qc.push(new Quux("element 1"));
+ qc.push(new java_director_MyQuux("element 2"));
+ qc.push(new java_director_MyQuux("element 3"));
+ qc.push(new Quux("element 4"));
+
+ return qc;
+ }
+}
+
+class java_director_MyQuux extends Quux {
+ public java_director_MyQuux(String arg) {
+ super(arg);
+ }
+
+ public String director_method() {
+ return "java_director_MyQuux:" + member();
+ }
+}
+
+class java_director_JavaExceptionTest extends JavaExceptionTest {
+ public java_director_JavaExceptionTest() {
+ super();
+ }
+
+ public void etest() throws Exception {
+ super.etest();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/java_enums_runme.java b/trunk/Examples/test-suite/java/java_enums_runme.java
new file mode 100644
index 000000000..bc7d41636
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_enums_runme.java
@@ -0,0 +1,54 @@
+
+import java_enums.*;
+
+public class java_enums_runme implements stuff {
+ static {
+ try {
+ System.loadLibrary("java_enums");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ int number = 200;
+
+ // Switch statement will only compile if these enums are initialised
+ // from a constant Java value, that is not from a function call
+ switch(number) {
+ case stuff.FIDDLE:
+ break;
+ case stuff.STICKS:
+ break;
+ case stuff.BONGO:
+ break;
+ case stuff.DRUMS:
+ break;
+ default:
+ break;
+ }
+ if (stuff.DRUMS != 15)
+ throw new RuntimeException("Incorrect value for DRUMS");
+
+ // check typemaps use short for this enum
+ short poppycock = nonsense.POPPYCOCK;
+ short tst1 = java_enums.test1(poppycock);
+ short tst2 = java_enums.test2(poppycock);
+
+ // Check that stuff is an interface and not a class - we can drop the stuff keyword as this class implements the stuff interface
+ switch(number) {
+ case FIDDLE:
+ break;
+ case STICKS:
+ break;
+ case BONGO:
+ break;
+ case DRUMS:
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/java_jnitypes_runme.java b/trunk/Examples/test-suite/java/java_jnitypes_runme.java
new file mode 100644
index 000000000..3e9d9e4c5
--- /dev/null
+++ b/trunk/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[] {'A', 'B'};
+ byte byteArray[] = new byte[] {10, 20};
+ 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_bool(true) != true) testFailed("jboolean");
+ if (java_jnitypes.jnifunc('A') != 'A') testFailed("jchar");
+ if (java_jnitypes.jnifunc((byte)100) != (byte)100) testFailed("jbyte");
+ if (java_jnitypes.jnifunc((short)100) != (short)100) testFailed("jshort");
+ if (java_jnitypes.jnifunc(100) != 100) testFailed("jint");
+ if (java_jnitypes.jnifunc((long)100) != (long)100) testFailed("jlong");
+ if (java_jnitypes.jnifunc((float)100) != (float)100) testFailed("jfloat");
+ if (java_jnitypes.jnifunc(100.0) != 100.0) 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] != 'B') testFailed("jcharArray");
+ if (java_jnitypes.jnifunc(byteArray)[1] != 20) 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/trunk/Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java b/trunk/Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java
new file mode 100644
index 000000000..cd9f7da08
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_lib_arrays_dimensionless_runme.java
@@ -0,0 +1,62 @@
+
+import java_lib_arrays_dimensionless.*;
+
+public class java_lib_arrays_dimensionless_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_lib_arrays_dimensionless");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ boolean bools[] = {true, false, true, false, true};
+ byte schars[] = {5, 10, 15, 20, 25};
+ short uchars[] = {5, 10, 15, 20, 25};
+ short shorts[] = {5, 10, 15, 20, 25};
+ int ushorts[] = {5, 10, 15, 20, 25};
+ int ints[] = {5, 10, 15, 20, 25};
+ long uints[] = {5, 10, 15, 20, 25};
+ int longs[] = {5, 10, 15, 20, 25};
+ long ulongs[] = {5, 10, 15, 20, 25};
+ long lls[] = {5, 10, 15, 20, 25};
+ //java.math.BigInteger ulls[] = {5, 10, 15, 20, 25};
+ float floats[] = {5, 10, 15, 20, 25};
+ double doubles[] = {5, 10, 15, 20, 25};
+
+ if (java_lib_arrays_dimensionless.arr_bool(bools, bools.length) != 3) throw new RuntimeException("test bools 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_bool(bools, bools.length) != 2) throw new RuntimeException("test bools 2 failed");
+// if (java_lib_arrays_dimensionless.arr_char(chars, chars.length) != 75) throw new RuntimeException("test chars 1 failed");
+// if (java_lib_arrays_dimensionless.ptr_char(chars, chars.length) != 150) throw new RuntimeException("test chars 2 failed");
+ if (java_lib_arrays_dimensionless.arr_schar(schars, schars.length) != 75) throw new RuntimeException("test schars 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_schar(schars, schars.length) != 150) throw new RuntimeException("test schars 2 failed");
+ if (java_lib_arrays_dimensionless.arr_uchar(uchars, uchars.length) != 75) throw new RuntimeException("test uchars 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_uchar(uchars, uchars.length) != 150) throw new RuntimeException("test uchars 2 failed");
+ if (java_lib_arrays_dimensionless.arr_short(shorts, shorts.length) != 75) throw new RuntimeException("test shorts 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_short(shorts, shorts.length) != 150) throw new RuntimeException("test shorts 2 failed");
+ if (java_lib_arrays_dimensionless.arr_ushort(ushorts, ushorts.length) != 75) throw new RuntimeException("test ushorts 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_ushort(ushorts, ushorts.length) != 150) throw new RuntimeException("test ushorts 2 failed");
+ if (java_lib_arrays_dimensionless.arr_int(ints, ints.length) != 75) throw new RuntimeException("test ints 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_int(ints, ints.length) != 150) throw new RuntimeException("test ints 2 failed");
+ if (java_lib_arrays_dimensionless.arr_uint(uints, uints.length) != 75) throw new RuntimeException("test uints 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_uint(uints, uints.length) != 150) throw new RuntimeException("test uints 2 failed");
+ if (java_lib_arrays_dimensionless.arr_long(longs, longs.length) != 75) throw new RuntimeException("test longs 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_long(longs, longs.length) != 150) throw new RuntimeException("test longs 2 failed");
+ if (java_lib_arrays_dimensionless.arr_ulong(ulongs, ulongs.length) != 75) throw new RuntimeException("test ulongs 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_ulong(ulongs, ulongs.length) != 150) throw new RuntimeException("test ulongs 2 failed");
+// if (java_lib_arrays_dimensionless.arr_ll(lls, lls.length) != 75) throw new RuntimeException("test lls 1 failed");
+// if (java_lib_arrays_dimensionless.ptr_ll(lls, lls.length) != 150) throw new RuntimeException("test lls 2 failed");
+// if (java_lib_arrays_dimensionless.arr_ull(ulls, ulls.length) != 75) throw new RuntimeException("test ulls 1 failed");
+// if (java_lib_arrays_dimensionless.ptr_ull(ulls, ulls.length) != 150) throw new RuntimeException("test ulls 2 failed");
+ if (java_lib_arrays_dimensionless.arr_float(floats, floats.length) != 75) throw new RuntimeException("test floats 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_float(floats, floats.length) != 150) throw new RuntimeException("test floats 2 failed");
+ if (java_lib_arrays_dimensionless.arr_double(doubles, doubles.length) != 75) throw new RuntimeException("test doubles 1 failed");
+ if (java_lib_arrays_dimensionless.ptr_double(doubles, doubles.length) != 150) throw new RuntimeException("test doubles 2 failed");
+
+ }
+
+}
diff --git a/trunk/Examples/test-suite/java/java_lib_arrays_runme.java b/trunk/Examples/test-suite/java/java_lib_arrays_runme.java
new file mode 100644
index 000000000..9ee36210a
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_lib_arrays_runme.java
@@ -0,0 +1,165 @@
+
+// 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_finger = {finger.Three, finger.Four};
+ int[] array_toe = {toe.Big, toe.Little};
+
+ SimpleStruct[] array_struct={new SimpleStruct(), new SimpleStruct()};
+ array_struct[0].setDouble_field(222.333);
+ array_struct[1].setDouble_field(444.555);
+
+ AnotherStruct[] array_another_struct={new AnotherStruct(), new AnotherStruct()};
+ array_another_struct[0].setSimple(array_struct[0]);
+ array_another_struct[1].setSimple(array_struct[1]);
+
+ YetAnotherStruct[] array_yet_another_struct={new YetAnotherStruct(), new YetAnotherStruct()};
+ array_yet_another_struct[0].setSimple(array_struct[0]);
+ array_yet_another_struct[1].setSimple(array_struct[1]);
+
+ if (array_another_struct[0].getSimple().getDouble_field() != 222.333) throw new RuntimeException("AnotherStruct[0] failed");
+ if (array_another_struct[1].getSimple().getDouble_field() != 444.555) throw new RuntimeException("AnotherStruct[1] failed");
+
+ if (java_lib_arrays.extract_ptr(array_yet_another_struct, 0) != 222.333) throw new RuntimeException("extract_ptr 0 failed");
+ if (java_lib_arrays.extract_ptr(array_yet_another_struct, 1) != 444.555) throw new RuntimeException("extract_ptr 1 failed");
+
+ java_lib_arrays.modifyYAS(array_yet_another_struct, array_yet_another_struct.length);
+ for (int i=0; i<2; ++i) {
+ if (array_yet_another_struct[i].getSimple().getDouble_field() != array_struct[i].getDouble_field() * 10.0)
+ throw new RuntimeException("modifyYAS failed ");
+ }
+
+ java_lib_arrays.toestest(array_toe, array_toe, array_toe);
+
+ // 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_finger);
+ check_int_array(array_finger, 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)) {
+ throw new RuntimeException("Runtime test failed. checking = [" + checking + "]");
+ }
+ }
+ public static void check_byte_array(byte[] original, byte[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ }
+ }
+ }
+ public static void check_short_array(short[] original, short[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ }
+ }
+ }
+ public static void check_int_array(int[] original, int[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ }
+ }
+ }
+ public static void check_long_array(long[] original, long[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ }
+ }
+ }
+ public static void check_float_array(float[] original, float[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ }
+ }
+ }
+ public static void check_double_array(double[] original, double[] checking) {
+ for (int i=0; i<original.length; i++) {
+ if (checking[i] != original[i]) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "]=" + checking[i]);
+ }
+ }
+ }
+ 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()) {
+ throw new RuntimeException("Runtime test failed. checking[" + i + "].double_field=" + checking[i].getDouble_field());
+ }
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/java_lib_various_runme.java b/trunk/Examples/test-suite/java/java_lib_various_runme.java
new file mode 100644
index 000000000..ab54aced8
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_lib_various_runme.java
@@ -0,0 +1,83 @@
+
+// Test case to check typemaps in various.i
+
+import java_lib_various.*;
+
+public class java_lib_various_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_lib_various");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // STRING_ARRAY typemap parameter
+ String animals[] = {"Cat","Dog","Cow","Goat"};
+ if (java_lib_various.check_animals(animals) != 1)
+ throw new RuntimeException("check_animals failed");
+
+ // STRING_ARRAY typemap return value
+ String expected[] = { "Dave", "Mike", "Susan", "John", "Michelle" };
+ String got[] = java_lib_various.get_names();
+ for (int i=0; i<got.length; i++)
+ if ( !got[i].equals(expected[i]) )
+ throw new RuntimeException("Name failed " + i + " " + got[i] + "|" + expected[i]);
+
+ // STRING_ARRAY variable getter
+ String langscheck[] = { "Hungarian", "Afrikaans", "Norwegian" };
+ String langs[] = java_lib_various.getLanguages();
+ for (int i=0; i<langs.length; i++)
+ if ( !langs[i].equals(langscheck[i]) )
+ throw new RuntimeException("Languages read failed " + i + " " + langs[i] + "|" + langscheck[i]);
+
+ // STRING_ARRAY variable setter
+ String newLangs[] = { "French", "Italian", "Spanish" };
+ java_lib_various.setLanguages(newLangs);
+
+ // STRING_ARRAY variable getter
+ langs = java_lib_various.getLanguages();
+ for (int i=0; i<langs.length; i++)
+ if ( !langs[i].equals(newLangs[i]) )
+ throw new RuntimeException("Languages verify failed " + i + " " + langs[i] + "|" + newLangs[i]);
+
+ // STRING_RET test
+ {
+ String stringOutArray[] = { "" };
+ java_lib_various.char_ptr_ptr_out(stringOutArray);
+ if (!stringOutArray[0].equals("returned string"))
+ throw new RuntimeException("Test failed: expected: returned string. got: " + stringOutArray[0]);
+ }
+
+ // STRING_RET null array test. Check that exception is thrown.
+ try {
+ String stringOutArray[] = null;
+ java_lib_various.char_ptr_ptr_out(stringOutArray);
+ throw new RuntimeException("Test failed: null array");
+ } catch (NullPointerException e) {
+ }
+
+ // STRING_RET empty array test. Check that exception is thrown.
+ try {
+ String stringOutArray[] = {};
+ java_lib_various.char_ptr_ptr_out(stringOutArray);
+ throw new RuntimeException("Test failed: empty array");
+ } catch (IndexOutOfBoundsException e) {
+ }
+
+ // BYTE typemap check
+ byte b[] = new byte[20];
+ java_lib_various.charout(b);
+ String byjovestring = new String("by jove");
+ byte byjove[] = byjovestring.getBytes();
+ for (int i=0; i<byjovestring.length(); i++) {
+ if (byjove[i] != b[i])
+ throw new RuntimeException("By jove, it failed: [" + new String(b) + "]");
+ }
+ }
+
+}
diff --git a/trunk/Examples/test-suite/java/java_pgcpp_runme.java b/trunk/Examples/test-suite/java/java_pgcpp_runme.java
new file mode 100644
index 000000000..624100cb1
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_pgcpp_runme.java
@@ -0,0 +1,32 @@
+
+import java_pgcpp.*;
+
+
+public class java_pgcpp_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_pgcpp");
+ } 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[]) {
+ Classic object = new Classic();
+ long ptr = object.getCPtrValue();
+
+ java_pgcppJNI.new_Classic__SWIG_1(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
+ java_pgcppJNI.new_Classic__SWIG_2(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object, false);
+
+ java_pgcppJNI.Classic_method(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
+ java_pgcppJNI.Classic_methodconst(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
+
+ java_pgcppJNI.function(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
+ java_pgcppJNI.functionconst(ptr, object, ptr, object, ptr, object, ptr, object, ptr, object);
+
+ java_pgcppJNI.comment_in_typemaps(ptr, object, ptr, object, ptr, object);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/java_pragmas_runme.java b/trunk/Examples/test-suite/java/java_pragmas_runme.java
new file mode 100644
index 000000000..311141159
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/java_prepost_runme.java b/trunk/Examples/test-suite/java/java_prepost_runme.java
new file mode 100644
index 000000000..6eeb60393
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_prepost_runme.java
@@ -0,0 +1,28 @@
+
+import java_prepost.*;
+
+public class java_prepost_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_prepost");
+ } 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[])
+ {
+ // ensure checked exception is generated
+ try {
+ PrePostThrows ppt = new PrePostThrows(null);
+ } catch (InstantiationException e) {
+ }
+ }
+
+ private static void Assert(double d1, double d2) {
+ if (d1 != d2)
+ throw new RuntimeException("assertion failure. " + d1 + " != " + d2);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/java_throws_runme.java b/trunk/Examples/test-suite/java/java_throws_runme.java
new file mode 100644
index 000000000..0365b69ed
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_throws_runme.java
@@ -0,0 +1,123 @@
+
+import java_throws.*;
+
+public class java_throws_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_throws");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ // Check the exception classes in the main typemaps
+ boolean pass = false;
+
+ // This won't compile unless all of these exceptions are in the throw clause
+ try {
+ short s = java_throws.full_of_exceptions(10);
+ }
+ catch (ClassNotFoundException e) {}
+ catch (NoSuchFieldException e) { pass = true; }
+ catch (InstantiationException e) {}
+ catch (CloneNotSupportedException e) {}
+ catch (IllegalAccessException e) {}
+
+ if (!pass)
+ throw new RuntimeException("Test 1 failed");
+
+ // Check the exception class in the throw typemap
+ pass = false;
+ try {
+ java_throws.throw_spec_function(100);
+ }
+ catch (IllegalAccessException e) { pass = true; }
+
+ if (!pass)
+ throw new RuntimeException("Test 2 failed");
+
+ // Check the exception class is used with %catches
+ pass = false;
+ try {
+ java_throws.catches_function(100);
+ }
+ catch (IllegalAccessException e) { pass = true; }
+
+ if (!pass)
+ throw new RuntimeException("Test 3 failed");
+
+ // Check newfree typemap throws attribute
+ try {
+ TestClass tc = java_throws.makeTestClass();
+ }
+ catch (NoSuchMethodException e) {}
+
+ // Check javaout typemap throws attribute
+ pass = false;
+ try {
+ int myInt = java_throws.ioTest();
+ }
+ catch (java.io.IOException e) { pass = true; }
+
+ if (!pass)
+ throw new RuntimeException("Test 4 failed");
+
+ // Check except feature throws attribute...
+ // Static method
+ pass = false;
+ try {
+ FeatureTest.staticMethod();
+ }
+ catch (MyException e) { pass = true; }
+
+ if (!pass)
+ throw new RuntimeException("Test 5 failed");
+
+ FeatureTest f = null;
+ try {
+ f = new FeatureTest();
+ }
+ catch (MyException e) {}
+
+ // Instance method
+ pass = false;
+ try {
+ f.method();
+ }
+ catch (MyException e) { pass = true; }
+
+ if (!pass)
+ throw new RuntimeException("Test 6 failed");
+
+ // Global function
+ pass = false;
+ try {
+ java_throws.globalFunction(10);
+ }
+ catch (MyException e) { pass = true; }
+ catch (ClassNotFoundException e) {}
+ catch (NoSuchFieldException e) {}
+
+ if (!pass)
+ throw new RuntimeException("Test 7 failed");
+
+ // Test %nojavaexception
+ NoExceptTest net = new NoExceptTest();
+
+ pass = false;
+ try {
+ net.exceptionPlease();
+ pass = true;
+ }
+ catch (MyException e) {}
+
+ if (!pass)
+ throw new RuntimeException("Test 8 failed");
+
+ net.noExceptionPlease();
+ }
+}
diff --git a/trunk/Examples/test-suite/java/java_typemaps_proxy_runme.java b/trunk/Examples/test-suite/java/java_typemaps_proxy_runme.java
new file mode 100644
index 000000000..67a083114
--- /dev/null
+++ b/trunk/Examples/test-suite/java/java_typemaps_proxy_runme.java
@@ -0,0 +1,81 @@
+
+// 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.*;
+import java.lang.reflect.*;
+
+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);
+
+ // Test typemaps are being found for templated classes
+ AdieuIntPtrPtr.adieu();
+
+ // Check the %javamethodmodifiers feature
+ try {
+ Method methodmodifiertest = nullFarewell.getClass().getDeclaredMethod("methodmodifiertest", (java.lang.Class[])null);
+ if ( !Modifier.isPrivate(methodmodifiertest.getModifiers()) )
+ throw new RuntimeException("NS::Farewell::methodmodifiertest not private" );
+
+ } catch (NoSuchMethodException n) {
+ throw new RuntimeException("NoSuchmethodException caught. Test failed.");
+ } catch (SecurityException s) {
+ throw new RuntimeException("SecurityException caught. Test failed.");
+ }
+
+ // Check the premature garbage collection prevention parameter
+ // Check it is normally present
+ long nullPtr = 0;
+ With with = new With(null);
+ java_typemaps_proxyJNI.new_With(nullPtr, with);
+ java_typemaps_proxyJNI.With_static_method(nullPtr, with);
+ java_typemaps_proxyJNI.With_member_method(nullPtr, with, nullPtr, with);
+ java_typemaps_proxyJNI.delete_With(nullPtr);
+ java_typemaps_proxyJNI.global_method_with(nullPtr, with);
+
+ // Check that it can be turned off
+ java_typemaps_proxyJNI.new_Without(nullPtr);
+ java_typemaps_proxyJNI.Without_static_method(nullPtr);
+ java_typemaps_proxyJNI.Without_member_method(nullPtr, nullPtr);
+ java_typemaps_proxyJNI.delete_Without(nullPtr);
+ java_typemaps_proxyJNI.global_method_without(nullPtr);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/java_typemaps_typewrapper_runme.java b/trunk/Examples/test-suite/java/java_typemaps_typewrapper_runme.java
new file mode 100644
index 000000000..f6769fe20
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/trunk/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
new file mode 100644
index 000000000..f40c28e9e
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
@@ -0,0 +1,701 @@
+import li_boost_intrusive_ptr.*;
+
+public class li_boost_intrusive_ptr_runme {
+ static {
+ try {
+ System.loadLibrary("li_boost_intrusive_ptr");
+ } 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);
+ }
+ }
+
+ // Debugging flag
+ public final static boolean debug = false;
+
+ public static void main(String argv[])
+ {
+ if (debug)
+ System.out.println("Started");
+
+ li_boost_intrusive_ptr.setDebug_shared(debug);
+
+ // Change loop count to run for a long time to monitor memory
+ final int loopCount = 5000; //5000;
+ for (int i=0; i<loopCount; i++) {
+ new li_boost_intrusive_ptr_runme().runtest();
+ System.gc();
+ System.runFinalization();
+ try {
+ if (i%100 == 0) {
+ java.lang.Thread.sleep(1); // give some time to the lower priority finalizer thread
+ }
+ } catch (java.lang.InterruptedException e) {
+ }
+ }
+
+ if (debug)
+ System.out.println("Nearly finished");
+
+ int countdown = 50;
+ while (true) {
+ System.gc();
+ System.runFinalization();
+ try {
+ java.lang.Thread.sleep(100);
+ } catch (java.lang.InterruptedException e) {
+ }
+ if (--countdown == 0)
+ break;
+ if (Klass.getTotal_count() == 1 && KlassWithoutRefCount.getTotal_count() == 0 &&
+ li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() == 0 &&
+ KlassDerived.getTotal_count() == 0 && KlassDerivedDerived.getTotal_count() == 1)
+ // Expect 1 Klass instance - the one global variable (GlobalValue)
+ break;
+ };
+ if (Klass.getTotal_count() != 1)
+ throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
+ if (KlassWithoutRefCount.getTotal_count() != 0)
+ throw new RuntimeException("KlassWithoutRefCount.total_count=" + KlassWithoutRefCount.getTotal_count());
+ if (li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() != 0)
+ throw new RuntimeException("IgnoredRefCountingBase.total_count=" + li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count());
+ if (KlassDerived.getTotal_count() != 0)
+ throw new RuntimeException("KlassDerived.total_count=" + KlassDerived.getTotal_count());
+ if (KlassDerivedDerived.getTotal_count() != 0)
+ throw new RuntimeException("KlassDerivedDerived.total_count=" + KlassDerivedDerived.getTotal_count());
+
+ int wrapper_count = li_boost_intrusive_ptr.intrusive_ptr_wrapper_count();
+ if (wrapper_count != li_boost_intrusive_ptr.getNOT_COUNTING())
+ if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
+ throw new RuntimeException("shared_ptr wrapper count=" + wrapper_count);
+
+ if (debug)
+ System.out.println("Finished");
+ }
+
+ private void runtest() {
+ // simple shared_ptr usage - created in C++
+ {
+ Klass k = new Klass("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ Klass k = li_boost_intrusive_ptr.factorycreate();
+ String val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by value
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.pointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ if (li_boost_intrusive_ptr.smartpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (!li_boost_intrusive_ptr.nullsmartpointerpointertest(null).equals("null pointer"))
+ throw new RuntimeException("not null smartpointer pointer");
+
+ try { li_boost_intrusive_ptr.valuetest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+
+ if (li_boost_intrusive_ptr.pointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ try { li_boost_intrusive_ptr.reftest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ // $owner
+ {
+ Klass k = li_boost_intrusive_ptr.pointerownertest();
+ String val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ Klass k = li_boost_intrusive_ptr.smartpointerpointerownertest();
+ String val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived access to base class which cannot be wrapped in an intrusive_ptr
+ {
+ KlassWithoutRefCount k = new KlassDerived("me oh my");
+ verifyValue("this class cannot be wrapped by intrusive_ptrs but we can still use it", k.getSpecialValueFromUnwrappableClass());
+ }
+ // derived pass by shared_ptr
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // derived pass by shared_ptr pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
+ verifyCount(2, kret);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
+ verifyCount(2, kret);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedvaluetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedvaluetest-Derived", val); // note slicing
+ verifyIntrusiveCount(1, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-DerivedDerived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-DerivedDerived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member value");
+ m.setSmartMemberValue(k);
+ String val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ verifyCount(1, kmember);
+
+ m.delete();
+ verifyIntrusiveCount(2, kmember);
+ verifyIntrusiveCount(2, k);
+ }
+
+ // smart pointer by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member pointer");
+ m.setSmartMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+
+ Klass kmember = m.getSmartMemberPointer();
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyIntrusiveCount(2, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+ }
+ // smart pointer by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member reference");
+ m.setSmartMemberReference(k);
+ String val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberReference();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ m.setSmartMemberValue(k);
+ Klass kmemberVal = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(5, kmemberVal);
+ verifyCount(1, kmemberVal);
+ verifyIntrusiveCount(5, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(5, k);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyIntrusiveCount(3, kmemberVal);
+ verifyCount(1, kmemberVal);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ }
+
+ //plain by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member value");
+ m.setMemberValue(k);
+ String val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberValue();
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //plain by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member pointer");
+ m.setMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberPointer();
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //plain by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member reference");
+ m.setMemberReference(k);
+ String val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberReference();
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //null member variables
+ {
+ MemberVariables m = new MemberVariables();
+
+ // shared_ptr by value
+ Klass k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ m.setSmartMemberValue(null);
+ k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+}
+private void toIgnore() {
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ Klass kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("smart global value");
+ li_boost_intrusive_ptr.setGlobalSmartValue(k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
+ String val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyIntrusiveCount(3, kglobal);
+ verifyCount(1, kglobal);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ verifyValue("smart global value", li_boost_intrusive_ptr.getGlobalSmartValue().getValue());
+ li_boost_intrusive_ptr.setGlobalSmartValue(null);
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global value");
+ li_boost_intrusive_ptr.setGlobalValue(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalValue();
+ String val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", li_boost_intrusive_ptr.getGlobalValue().getValue());
+
+ try { li_boost_intrusive_ptr.setGlobalValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+ //plain pointer
+ {
+ Klass kglobal = li_boost_intrusive_ptr.getGlobalPointer();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("global pointer");
+ li_boost_intrusive_ptr.setGlobalPointer(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalPointer();
+ String val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ li_boost_intrusive_ptr.setGlobalPointer(null);
+ }
+
+ // plain reference
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global reference");
+ li_boost_intrusive_ptr.setGlobalReference(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalReference();
+ String val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { li_boost_intrusive_ptr.setGlobalReference(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
+ throw new RuntimeException("Base values wrong");
+ if (pid.getVal1() != 10 || pid.getVal2() != 20.2)
+ throw new RuntimeException("Derived Values wrong");
+ }
+ }
+ private void verifyValue(String expected, String got) {
+ if (!expected.equals(got))
+ throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, Klass k) {
+ int got = li_boost_intrusive_ptr.use_count(k);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, KlassDerived kd) {
+ int got = li_boost_intrusive_ptr.use_count(kd);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, KlassDerivedDerived kdd) {
+ int got = li_boost_intrusive_ptr.use_count(kdd);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, Klass k) {
+ int got = k.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, KlassDerived kd) {
+ int got = kd.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, KlassDerivedDerived kdd) {
+ int got = kdd.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java b/trunk/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java
new file mode 100644
index 000000000..ffa0c5e64
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java
@@ -0,0 +1,24 @@
+import li_boost_shared_ptr_bits.*;
+
+public class li_boost_shared_ptr_bits_runme {
+ static {
+ try {
+ System.loadLibrary("li_boost_shared_ptr_bits");
+ } 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[])
+ {
+ VectorIntHolder v = new VectorIntHolder();
+ v.add(new IntHolder(11));
+ v.add(new IntHolder(22));
+ v.add(new IntHolder(33));
+
+ int sum = li_boost_shared_ptr_bits.sum(v);
+ if (sum != 66)
+ throw new RuntimeException("sum is wrong");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/trunk/Examples/test-suite/java/li_boost_shared_ptr_runme.java
new file mode 100644
index 000000000..02d6d6502
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_boost_shared_ptr_runme.java
@@ -0,0 +1,603 @@
+import li_boost_shared_ptr.*;
+
+public class li_boost_shared_ptr_runme {
+ static {
+ try {
+ System.loadLibrary("li_boost_shared_ptr");
+ } 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);
+ }
+ }
+
+ // Debugging flag
+ public final static boolean debug = false;
+
+ public static void main(String argv[])
+ {
+ if (debug)
+ System.out.println("Started");
+
+ li_boost_shared_ptr.setDebug_shared(debug);
+
+ // Change loop count to run for a long time to monitor memory
+ final int loopCount = 1; //5000;
+ for (int i=0; i<loopCount; i++) {
+ new li_boost_shared_ptr_runme().runtest();
+ System.gc();
+ System.runFinalization();
+ try {
+ if (i%100 == 0) {
+ java.lang.Thread.sleep(1); // give some time to the lower priority finalizer thread
+ }
+ } catch (java.lang.InterruptedException e) {
+ }
+ }
+
+ if (debug)
+ System.out.println("Nearly finished");
+
+ int countdown = 100;
+ while (true) {
+ System.gc();
+ System.runFinalization();
+ try {
+ java.lang.Thread.sleep(10);
+ } catch (java.lang.InterruptedException e) {
+ }
+ if (--countdown == 0)
+ break;
+ if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
+ break;
+ };
+ if (Klass.getTotal_count() != 1)
+ throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
+
+ int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
+ if (wrapper_count != li_boost_shared_ptr.getNOT_COUNTING())
+ if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
+ throw new RuntimeException("shared_ptr wrapper count=" + wrapper_count);
+
+ if (debug)
+ System.out.println("Finished");
+ }
+
+ private void runtest() {
+ // simple shared_ptr usage - created in C++
+ {
+ Klass k = new Klass("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ Klass k = li_boost_shared_ptr.factorycreate();
+ String val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.constsmartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.constsmartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.constsmartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by value
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_shared_ptr.pointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ if (li_boost_shared_ptr.smartpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_shared_ptr.smartpointerpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_shared_ptr.smartpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_shared_ptr.smartpointerpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (!li_boost_shared_ptr.nullsmartpointerpointertest(null).equals("null pointer"))
+ throw new RuntimeException("not null smartpointer pointer");
+
+ try { li_boost_shared_ptr.valuetest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+
+ if (li_boost_shared_ptr.pointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ try { li_boost_shared_ptr.reftest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ // $owner
+ {
+ Klass k = li_boost_shared_ptr.pointerownertest();
+ String val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ Klass k = li_boost_shared_ptr.smartpointerpointerownertest();
+ String val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived pass by shared_ptr
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_shared_ptr.derivedreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val); // note slicing
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ Klass k = new KlassDerived("me oh my");
+ Klass kret = li_boost_shared_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // 3rd derived class
+ {
+ Klass k = new Klass3rdDerived("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = li_boost_shared_ptr.test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member value");
+ m.setSmartMemberValue(k);
+ String val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(2, k);
+
+ Klass kmember = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ m.delete();
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member pointer");
+ m.setSmartMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberPointer();
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+
+ m.delete();
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member reference");
+ m.setSmartMemberReference(k);
+ String val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(2, k);
+
+ Klass kmember = m.getSmartMemberReference();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ Klass kmemberVal = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(4, kmemberVal);
+ verifyCount(4, kmember);
+ verifyCount(4, k);
+
+ m.delete();
+ verifyCount(3, kmemberVal);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+ }
+ // plain by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member value");
+ m.setMemberValue(k);
+ String val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberValue();
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member pointer");
+ m.setMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberPointer();
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member reference");
+ m.setMemberReference(k);
+ String val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberReference();
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+
+ // null member variables
+ {
+ MemberVariables m = new MemberVariables();
+
+ // shared_ptr by value
+ Klass k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ m.setSmartMemberValue(null);
+ k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ Klass kglobal = li_boost_shared_ptr.getGlobalSmartValue();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("smart global value");
+ li_boost_shared_ptr.setGlobalSmartValue(k);
+ verifyCount(2, k);
+
+ kglobal = li_boost_shared_ptr.getGlobalSmartValue();
+ String val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyCount(3, kglobal);
+ verifyCount(3, k);
+ verifyValue("smart global value", li_boost_shared_ptr.getGlobalSmartValue().getValue());
+ li_boost_shared_ptr.setGlobalSmartValue(null);
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global value");
+ li_boost_shared_ptr.setGlobalValue(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_shared_ptr.getGlobalValue();
+ String val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", li_boost_shared_ptr.getGlobalValue().getValue());
+
+ try { li_boost_shared_ptr.setGlobalValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+ // plain pointer
+ {
+ Klass kglobal = li_boost_shared_ptr.getGlobalPointer();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("global pointer");
+ li_boost_shared_ptr.setGlobalPointer(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_shared_ptr.getGlobalPointer();
+ String val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ li_boost_shared_ptr.setGlobalPointer(null);
+ }
+
+ // plain reference
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global reference");
+ li_boost_shared_ptr.setGlobalReference(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_shared_ptr.getGlobalReference();
+ String val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { li_boost_shared_ptr.setGlobalReference(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
+ throw new RuntimeException("Base values wrong");
+ if (pid.getVal1() != 10 || pid.getVal2() != 20.2)
+ throw new RuntimeException("Derived Values wrong");
+ }
+ }
+ private void verifyValue(String expected, String got) {
+ if (!expected.equals(got))
+ throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, Klass k) {
+ int got = li_boost_shared_ptr.use_count(k);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_carrays_runme.java b/trunk/Examples/test-suite/java/li_carrays_runme.java
new file mode 100644
index 000000000..f576eab84
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_carrays_runme.java
@@ -0,0 +1,88 @@
+import li_carrays.*;
+
+public class li_carrays_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_carrays");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ // array_class
+ {
+ int length = 5;
+ XYArray xyArray = new XYArray(length);
+ for (int i=0; i<length; i++) {
+ XY xy = xyArray.getitem(i);
+ xy.setX(i*10);
+ xy.setY(i*100);
+ xyArray.setitem(i, xy);
+ }
+ for (int i=0; i<length; i++) {
+ Assert(xyArray.getitem(i).getX(), i*10);
+ Assert(xyArray.getitem(i).getY(), i*100);
+ }
+ }
+
+ {
+ // global array variable
+ int length = 5;
+ XY xyArrayPointer = li_carrays.getGlobalXYArray();
+ XYArray xyArray = XYArray.frompointer(xyArrayPointer);
+ for (int i=0; i<length; i++) {
+ XY xy = xyArray.getitem(i);
+ xy.setX(i*10);
+ xy.setY(i*100);
+ xyArray.setitem(i, xy);
+ }
+ for (int i=0; i<length; i++) {
+ Assert(xyArray.getitem(i).getX(), i*10);
+ Assert(xyArray.getitem(i).getY(), i*100);
+ }
+ }
+
+ // array_functions
+ {
+ int length = 5;
+ AB abArray = li_carrays.new_ABArray(length);
+ for (int i=0; i<length; i++) {
+ AB ab = li_carrays.ABArray_getitem(abArray, i);
+ ab.setA(i*10);
+ ab.setB(i*100);
+ li_carrays.ABArray_setitem(abArray, i, ab);
+ }
+ for (int i=0; i<length; i++) {
+ Assert(li_carrays.ABArray_getitem(abArray, i).getA(), i*10);
+ Assert(li_carrays.ABArray_getitem(abArray, i).getB(), i*100);
+ }
+ li_carrays.delete_ABArray(abArray);
+ }
+
+ {
+ // global array variable
+ int length = 3;
+ AB abArray = li_carrays.getGlobalABArray();
+ for (int i=0; i<length; i++) {
+ AB ab = li_carrays.ABArray_getitem(abArray, i);
+ ab.setA(i*10);
+ ab.setB(i*100);
+ li_carrays.ABArray_setitem(abArray, i, ab);
+ }
+ for (int i=0; i<length; i++) {
+ Assert(li_carrays.ABArray_getitem(abArray, i).getA(), i*10);
+ Assert(li_carrays.ABArray_getitem(abArray, i).getB(), i*100);
+ }
+ }
+ }
+
+ private static void Assert(int val1, int val2) {
+// System.out.println("val1=" + val1 + " val2=" + val2);
+ if (val1 != val2)
+ throw new RuntimeException("Mismatch. val1=" + val1 + " val2=" + val2);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_std_except_runme.java b/trunk/Examples/test-suite/java/li_std_except_runme.java
new file mode 100644
index 000000000..6fe6ba5d8
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_std_except_runme.java
@@ -0,0 +1,29 @@
+import li_std_except.*;
+
+public class li_std_except_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_std_except");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ Test test = new Test();
+ try { test.throw_bad_exception(); throw new RuntimeException("throw_bad_exception failed"); } catch (RuntimeException e) {}
+ try { test.throw_domain_error(); throw new RuntimeException("throw_domain_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_exception(); throw new RuntimeException("throw_exception failed"); } catch (RuntimeException e) {}
+ try { test.throw_invalid_argument(); throw new RuntimeException("throw_invalid_argument failed"); } catch (IllegalArgumentException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_length_error(); throw new RuntimeException("throw_length_error failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_logic_error(); throw new RuntimeException("throw_logic_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_out_of_range(); throw new RuntimeException("throw_out_of_range failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_overflow_error(); throw new RuntimeException("throw_overflow_error failed"); } catch (ArithmeticException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_range_error(); throw new RuntimeException("throw_range_error failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_runtime_error(); throw new RuntimeException("throw_runtime_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ try { test.throw_underflow_error(); throw new RuntimeException("throw_underflow_error failed"); } catch (ArithmeticException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_std_string_runme.java b/trunk/Examples/test-suite/java/li_std_string_runme.java
new file mode 100644
index 000000000..1ee2a23c5
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_std_string_runme.java
@@ -0,0 +1,108 @@
+import li_std_string.*;
+
+public class li_std_string_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_std_string");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ // Checking expected use of %typemap(in) std::string {}
+ li_std_string.test_value("Fee");
+
+ // Checking expected result of %typemap(out) std::string {}
+ if (!li_std_string.test_value("Fi").equals("Fi"))
+ throw new RuntimeException("Test 1 failed");
+
+ // Verify type-checking for %typemap(in) std::string {}
+ try {
+ li_std_string.test_value(null);
+ throw new RuntimeException("Test 2 failed");
+ } catch (NullPointerException e) {
+ }
+
+ // Checking expected use of %typemap(in) const std::string & {}
+ li_std_string.test_const_reference("Fo");
+
+ // Checking expected result of %typemap(out) const std::string& {}
+ if (!li_std_string.test_const_reference("Fum").equals("Fum"))
+ throw new RuntimeException("Test 3 failed");
+
+ // Verify type-checking for %typemap(in) const std::string & {}
+ try {
+ li_std_string.test_const_reference(null);
+ throw new RuntimeException("Test 4 failed");
+ } catch (NullPointerException e) {
+ }
+
+ //
+ // Input and output typemaps for pointers and non-const references to
+ // std::string are *not* supported; the following tests confirm
+ // that none of these cases are slipping through.
+ //
+
+ SWIGTYPE_p_std__string stringPtr = null;
+
+ stringPtr = li_std_string.test_pointer_out();
+
+ li_std_string.test_pointer(stringPtr);
+
+ stringPtr = li_std_string.test_const_pointer_out();
+
+ li_std_string.test_const_pointer(stringPtr);
+
+ stringPtr = li_std_string.test_reference_out();
+
+ li_std_string.test_reference(stringPtr);
+
+ // Check throw exception specification
+ try {
+ li_std_string.test_throw();
+ throw new Throwable("Test 5 failed");
+ } catch (RuntimeException e) {
+ if (!e.getMessage().equals("test_throw message"))
+ throw new Exception("Test 5 string check: " + e.getMessage());
+ }
+ try {
+ li_std_string.test_const_reference_throw();
+ throw new Throwable("Test 6 failed");
+ } catch (RuntimeException e) {
+ if (!e.getMessage().equals("test_const_reference_throw message"))
+ throw new Exception("Test 6 string check: " + e.getMessage());
+ }
+
+ // Global variables
+ String s = "initial string";
+ if (!li_std_string.getGlobalString2().equals("global string 2"))
+ throw new Exception("GlobalString2 test 1");
+ li_std_string.setGlobalString2(s);
+ if (!li_std_string.getGlobalString2().equals(s))
+ throw new Exception("GlobalString2 test 2");
+ if (!li_std_string.getConstGlobalString().equals("const global string"))
+ throw new Exception("ConstGlobalString test");
+
+ // Member variables
+ Structure myStructure = new Structure();
+ if (!myStructure.getMemberString2().equals("member string 2"))
+ throw new Exception("MemberString2 test 1");
+ myStructure.setMemberString2(s);
+ if (!myStructure.getMemberString2().equals(s))
+ throw new Exception("MemberString2 test 2");
+ if (!myStructure.getConstMemberString().equals("const member string"))
+ throw new Exception("ConstMemberString test");
+
+ if (!Structure.getStaticMemberString2().equals("static member string 2"))
+ throw new Exception("StaticMemberString2 test 1");
+ Structure.setStaticMemberString2(s);
+ if (!Structure.getStaticMemberString2().equals(s))
+ throw new Exception("StaticMemberString2 test 2");
+ if (!Structure.getConstStaticMemberString().equals("const static member string"))
+ throw new Exception("ConstStaticMemberString test");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_std_vector_runme.java b/trunk/Examples/test-suite/java/li_std_vector_runme.java
new file mode 100644
index 000000000..b422655a4
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_std_vector_runme.java
@@ -0,0 +1,36 @@
+import li_std_vector.*;
+
+public class li_std_vector_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_std_vector");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ IntVector v1 = li_std_vector.vecintptr(new IntVector());
+ IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector());
+ IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector());
+
+ v1.add(123);
+ if (v1.get(0) != 123) throw new RuntimeException("v1 test failed");
+
+ StructVector v4 = li_std_vector.vecstruct(new StructVector());
+ StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector());
+ StructConstPtrVector v6 = li_std_vector.vecstructconstptr(new StructConstPtrVector());
+
+ v4.add(new Struct(12));
+ v5.add(new Struct(34));
+ v6.add(new Struct(56));
+
+ Struct s = null;
+ if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed");
+ if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed");
+ if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/li_typemaps_runme.java b/trunk/Examples/test-suite/java/li_typemaps_runme.java
new file mode 100644
index 000000000..327b188c2
--- /dev/null
+++ b/trunk/Examples/test-suite/java/li_typemaps_runme.java
@@ -0,0 +1,125 @@
+
+// Check a few of the INPUT, OUTPUT and INOUT typemaps.
+
+import li_typemaps.*;
+import java.math.*;
+
+public class li_typemaps_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_typemaps");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ // Check double INPUT typemaps
+ if (li_typemaps.in_double(22.22) != 22.22) exit_test("in_double");
+ if (li_typemaps.inr_double(22.22) != 22.22) exit_test("inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double[] var = {44.44};
+ li_typemaps.out_double(22.22, var);
+ if (var[0] != 22.22) exit_test("out_double");
+ }
+ {
+ double[] var = {44.44};
+ li_typemaps.outr_double(22.22, var);
+ if (var[0] != 22.22) exit_test("outr_double");
+ }
+ try {
+ double[] var = null;
+ li_typemaps.out_double(22.22, var);
+ exit_test("null out_double");
+ } catch (NullPointerException e) {
+ }
+
+ // Check double INOUT typemaps
+ {
+ double[] var = {44.44};
+ li_typemaps.inout_double(var);
+ if (var[0] != 44.44) exit_test("inout_double");
+ }
+ {
+ double[] var = {44.44};
+ li_typemaps.inoutr_double(var);
+ if (var[0] != 44.44) exit_test("inoutr_double");
+ }
+ try {
+ double[] var = null;
+ li_typemaps.inout_double(var);
+ exit_test("null inout_double");
+ } catch (NullPointerException e) {
+ }
+
+ // Check unsigned long long INPUT typemaps
+ BigInteger forty = new BigInteger("40");
+ BigInteger twenty = new BigInteger("20");
+ if (!li_typemaps.in_ulonglong(twenty).equals(twenty)) exit_test("in_ulonglong");
+ if (!li_typemaps.inr_ulonglong(twenty).equals(twenty)) exit_test("inr_ulonglong");
+
+ try {
+ li_typemaps.in_ulonglong(null);
+ exit_test("null in_ulonglong");
+ } catch (NullPointerException e) {
+ }
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ li_typemaps.out_ulonglong(twenty, var);
+ if (!var[0].equals(twenty)) exit_test("out_ulonglong");
+ }
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ li_typemaps.outr_ulonglong(twenty, var);
+ if (!var[0].equals(twenty)) exit_test("outr_ulonglong");
+ }
+ try {
+ BigInteger[] var = null;
+ li_typemaps.out_ulonglong(twenty, var);
+ exit_test("null out_ulonglong");
+ } catch (NullPointerException e) {
+ }
+ {
+ BigInteger[] var = { null };
+ li_typemaps.out_ulonglong(twenty, var);
+ if (!var[0].equals(twenty)) exit_test("null element out_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ li_typemaps.inout_ulonglong(var);
+ if (!var[0].equals(forty)) exit_test("inout_ulonglong");
+ }
+ {
+ BigInteger[] var = {new BigInteger("40")};
+ li_typemaps.inoutr_ulonglong(var);
+ if (!var[0].equals(forty)) exit_test("inoutr_ulonglong");
+ }
+ try {
+ BigInteger[] var = null;
+ li_typemaps.inout_ulonglong(var);
+ exit_test("null inout_ulonglong");
+ } catch (NullPointerException e) {
+ }
+ try {
+ BigInteger[] var = { null };
+ li_typemaps.inout_ulonglong(var);
+ exit_test("null element inout_ulonglong");
+ } catch (NullPointerException e) {
+ }
+
+ }
+
+ private static void exit_test(String funcName) {
+ throw new RuntimeException("Test FAILED in function " + funcName);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/long_long_runme.java b/trunk/Examples/test-suite/java/long_long_runme.java
new file mode 100644
index 000000000..d3092b326
--- /dev/null
+++ b/trunk/Examples/test-suite/java/long_long_runme.java
@@ -0,0 +1,83 @@
+
+// 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);
+
+ BigInteger testNumber = new BigInteger("0");
+ final int COUNT = 1025;
+
+ for (long i=0; i<COUNT; i++) {
+ check_ull(testNumber);
+ testNumber = testNumber.add(BigInteger.ONE);
+ }
+
+ testNumber = new BigInteger(Long.toString(256*256/2-COUNT));
+ for (long i=0; i<COUNT*2; i++) {
+ check_ull(testNumber);
+ testNumber = testNumber.add(BigInteger.ONE);
+ }
+
+ testNumber = new BigInteger(Long.toString(256*256-COUNT));
+ for (long i=0; i<COUNT*2; i++) {
+ check_ull(testNumber);
+ testNumber = testNumber.add(BigInteger.ONE);
+ }
+
+ testNumber = new BigInteger(Long.toString(0x7FFFFFFFFFFFFFFFL-COUNT));
+ for (long i=0; i<COUNT*2; i++) {
+ check_ull(testNumber);
+ testNumber = testNumber.add(BigInteger.ONE);
+ }
+
+ testNumber = new BigInteger("18446744073709551615"); //0xFFFFFFFFFFFFFFFFL
+ testNumber = testNumber.add(BigInteger.valueOf(1-COUNT));
+ for (long i=0; i<COUNT; i++) {
+ check_ull(testNumber);
+ testNumber = testNumber.add(BigInteger.ONE);
+ }
+
+ try {
+ long_long.setUll(null);
+ throw new RuntimeException("null check failed");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ 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/trunk/Examples/test-suite/java/member_pointer_runme.java b/trunk/Examples/test-suite/java/member_pointer_runme.java
new file mode 100644
index 000000000..f8dcfbcb8
--- /dev/null
+++ b/trunk/Examples/test-suite/java/member_pointer_runme.java
@@ -0,0 +1,58 @@
+import member_pointer.*;
+
+public class member_pointer_runme {
+
+ static {
+ try {
+ System.loadLibrary("member_pointer");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+
+ public static void main(String argv[]) {
+ // Get the pointers
+
+ SWIGTYPE_m_Shape__f_void__double area_pt = member_pointer.areapt();
+ SWIGTYPE_m_Shape__f_void__double perim_pt = member_pointer.perimeterpt();
+
+ // Create some objects
+
+ Square s = new Square(10);
+
+ // Do some calculations
+
+ check( "Square area ", 100.0, member_pointer.do_op(s,area_pt) );
+ check( "Square perim", 40.0, member_pointer.do_op(s,perim_pt) );
+
+ memberPtr = member_pointer.getAreavar();
+ memberPtr = member_pointer.getPerimetervar();
+
+ // Try the variables
+ check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.getAreavar()) );
+ check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.getPerimetervar()) );
+
+ // Modify one of the variables
+ member_pointer.setAreavar(perim_pt);
+
+ check( "Square perimeter", 40.0, member_pointer.do_op(s,member_pointer.getAreavar()) );
+
+ // Try the constants
+
+ memberPtr = member_pointer.AREAPT;
+ memberPtr = member_pointer.PERIMPT;
+ memberPtr = member_pointer.NULLPT;
+
+ check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.AREAPT) );
+ check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.PERIMPT) );
+
+ }
+
+ private static void check(String what, double expected, double actual) {
+ if (expected != actual)
+ throw new RuntimeException("Failed: " + what + " Expected: " + expected + " Actual: " + actual);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/memberin_extend_runme.java b/trunk/Examples/test-suite/java/memberin_extend_runme.java
new file mode 100644
index 000000000..c3fa29d8d
--- /dev/null
+++ b/trunk/Examples/test-suite/java/memberin_extend_runme.java
@@ -0,0 +1,26 @@
+
+import memberin_extend.*;
+
+public class memberin_extend_runme {
+ static {
+ try {
+ System.loadLibrary("memberin_extend");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ ExtendMe em1 = new ExtendMe();
+ ExtendMe em2 = new ExtendMe();
+ em1.setThing("em1thing");
+ em2.setThing("em2thing");
+ if (!em1.getThing().equals("em1thing"))
+ throw new RuntimeException("wrong: " + em1.getThing());
+ if (!em2.getThing().equals("em2thing"))
+ throw new RuntimeException("wrong: " + em2.getThing());
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/minherit2_runme.java b/trunk/Examples/test-suite/java/minherit2_runme.java
new file mode 100644
index 000000000..ea8102a42
--- /dev/null
+++ b/trunk/Examples/test-suite/java/minherit2_runme.java
@@ -0,0 +1,32 @@
+
+import minherit2.*;
+import java.lang.reflect.*;
+
+public class minherit2_runme {
+
+ static {
+ try {
+ System.loadLibrary("minherit2");
+ } 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 {
+
+ Method method = IRemoteAsyncIO.class.getDeclaredMethod("asyncmethod", (java.lang.Class[])null);
+ if ( !Modifier.isAbstract(method.getModifiers()) )
+ throw new RuntimeException("asyncmethod should be abstract" );
+
+ method = IRemoteSyncIO.class.getDeclaredMethod("syncmethod", (java.lang.Class[])null);
+ if ( !Modifier.isAbstract(method.getModifiers()) )
+ throw new RuntimeException("syncmethod should be abstract" );
+
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/multiple_inheritance_runme.java b/trunk/Examples/test-suite/java/multiple_inheritance_runme.java
new file mode 100644
index 000000000..dbfd79858
--- /dev/null
+++ b/trunk/Examples/test-suite/java/multiple_inheritance_runme.java
@@ -0,0 +1,32 @@
+
+import multiple_inheritance.*;
+
+public class multiple_inheritance_runme {
+
+ static {
+ try {
+ System.loadLibrary("multiple_inheritance");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ FooBar fooBar = new FooBar();
+ fooBar.foo();
+
+ IgnoreDerived1 ignoreDerived1 = new IgnoreDerived1();
+ ignoreDerived1.bar();
+
+ IgnoreDerived2 ignoreDerived2 = new IgnoreDerived2();
+ ignoreDerived2.bar();
+
+ IgnoreDerived3 ignoreDerived3 = new IgnoreDerived3();
+ ignoreDerived3.bar();
+
+ IgnoreDerived4 ignoreDerived4 = new IgnoreDerived4();
+ ignoreDerived4.bar();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/nested_class_runme.java b/trunk/Examples/test-suite/java/nested_class_runme.java
new file mode 100644
index 000000000..f1c67a0af
--- /dev/null
+++ b/trunk/Examples/test-suite/java/nested_class_runme.java
@@ -0,0 +1,72 @@
+
+import nested_class.*;
+
+public class nested_class_runme {
+
+ static {
+ try {
+ System.loadLibrary("nested_class");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ Outer outer = new Outer();
+ SWIGTYPE_p_Outer__InnerStruct1 is1 = outer.makeInnerStruct1();
+ SWIGTYPE_p_Outer__InnerClass1 ic1 = outer.makeInnerClass1();
+ SWIGTYPE_p_Outer__InnerUnion1 iu1 = outer.makeInnerUnion1();
+
+ SWIGTYPE_p_Outer__InnerStruct2 is2 = outer.makeInnerStruct2();
+ SWIGTYPE_p_Outer__InnerClass2 ic2 = outer.makeInnerClass2();
+ SWIGTYPE_p_Outer__InnerUnion2 iu2 = outer.makeInnerUnion2();
+
+ SWIGTYPE_p_Outer__InnerClass4Typedef ic4 = outer.makeInnerClass4Typedef();
+ SWIGTYPE_p_Outer__InnerStruct4Typedef is4 = outer.makeInnerStruct4Typedef();
+ SWIGTYPE_p_Outer__InnerUnion4Typedef iu4 = outer.makeInnerUnion4Typedef();
+
+ SWIGTYPE_p_Outer__InnerClass5 ic5 = outer.makeInnerClass5();
+ SWIGTYPE_p_Outer__InnerStruct5 is5 = outer.makeInnerStruct5();
+ SWIGTYPE_p_Outer__InnerUnion5 iu5 = outer.makeInnerUnion5();
+
+ ic5 = outer.makeInnerClass5Typedef();
+ is5 = outer.makeInnerStruct5Typedef();
+ iu5 = outer.makeInnerUnion5Typedef();
+
+ {
+ SWIGTYPE_p_Outer__InnerMultiple im1 = outer.getMultipleInstance1();
+ SWIGTYPE_p_Outer__InnerMultiple im2 = outer.getMultipleInstance2();
+ SWIGTYPE_p_Outer__InnerMultiple im3 = outer.getMultipleInstance3();
+ SWIGTYPE_p_Outer__InnerMultiple im4 = outer.getMultipleInstance4();
+ }
+
+ {
+ SWIGTYPE_p_Outer__InnerMultipleDerived im1 = outer.getMultipleDerivedInstance1();
+ SWIGTYPE_p_Outer__InnerMultipleDerived im2 = outer.getMultipleDerivedInstance2();
+ SWIGTYPE_p_Outer__InnerMultipleDerived im3 = outer.getMultipleDerivedInstance3();
+ SWIGTYPE_p_Outer__InnerMultipleDerived im4 = outer.getMultipleDerivedInstance4();
+ }
+
+ {
+ SWIGTYPE_p_Outer__InnerMultipleDerived im1 = outer.getMultipleDerivedInstance1();
+ SWIGTYPE_p_Outer__InnerMultipleDerived im2 = outer.getMultipleDerivedInstance2();
+ SWIGTYPE_p_Outer__InnerMultipleDerived im3 = outer.getMultipleDerivedInstance3();
+ SWIGTYPE_p_Outer__InnerMultipleDerived im4 = outer.getMultipleDerivedInstance4();
+ }
+
+ {
+ SWIGTYPE_p_Outer__InnerMultipleAnonTypedef1 mat1 = outer.makeInnerMultipleAnonTypedef1();
+ SWIGTYPE_p_Outer__InnerMultipleAnonTypedef2 mat2 = outer.makeInnerMultipleAnonTypedef2();
+ SWIGTYPE_p_Outer__InnerMultipleAnonTypedef3 mat3 = outer.makeInnerMultipleAnonTypedef3();
+
+ SWIGTYPE_p_Outer__InnerMultipleNamedTypedef mnt = outer.makeInnerMultipleNamedTypedef();
+ SWIGTYPE_p_Outer__InnerMultipleNamedTypedef mnt1 = outer.makeInnerMultipleNamedTypedef1();
+ SWIGTYPE_p_Outer__InnerMultipleNamedTypedef mnt2 = outer.makeInnerMultipleNamedTypedef2();
+ SWIGTYPE_p_p_Outer__InnerMultipleNamedTypedef mnt3 = outer.makeInnerMultipleNamedTypedef3();
+ }
+ {
+ SWIGTYPE_p_Outer__InnerSameName isn = outer.makeInnerSameName();
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/nested_structs_runme.java b/trunk/Examples/test-suite/java/nested_structs_runme.java
new file mode 100644
index 000000000..6e103cd12
--- /dev/null
+++ b/trunk/Examples/test-suite/java/nested_structs_runme.java
@@ -0,0 +1,37 @@
+
+import nested_structs.*;
+
+public class nested_structs_runme {
+
+ static {
+ try {
+ System.loadLibrary("nested_structs");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ Outer outer = new Outer();
+ nested_structs.setValues(outer, 10);
+
+ Outer_inner1 inner1 = outer.getInner1();
+ Outer_inner2 inner2 = outer.getInner2();
+ Outer_inner3 inner3 = outer.getInner3();
+ Outer_inner4 inner4 = outer.getInner4();
+ if (inner1.getVal() != 10) throw new RuntimeException("failed inner1");
+ if (inner2.getVal() != 20) throw new RuntimeException("failed inner2");
+ if (inner3.getVal() != 20) throw new RuntimeException("failed inner3");
+ if (inner4.getVal() != 40) throw new RuntimeException("failed inner4");
+
+ Outer_inside1 inside1 = outer.getInside1();
+ Outer_inside2 inside2 = outer.getInside2();
+ Outer_inside3 inside3 = outer.getInside3();
+ Outer_inside4 inside4 = outer.getInside4();
+ if (inside1.getVal() != 100) throw new RuntimeException("failed inside1");
+ if (inside2.getVal() != 200) throw new RuntimeException("failed inside2");
+ if (inside3.getVal() != 200) throw new RuntimeException("failed inside3");
+ if (inside4.getVal() != 400) throw new RuntimeException("failed inside4");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/nested_workaround_runme.java b/trunk/Examples/test-suite/java/nested_workaround_runme.java
new file mode 100644
index 000000000..761a2da8e
--- /dev/null
+++ b/trunk/Examples/test-suite/java/nested_workaround_runme.java
@@ -0,0 +1,31 @@
+import nested_workaround.*;
+
+public class nested_workaround_runme {
+
+ static {
+ try {
+ System.loadLibrary("nested_workaround");
+ } 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[]) {
+ {
+ Inner inner = new Inner(5);
+ Outer outer = new Outer();
+ Inner newInner = outer.doubleInnerValue(inner);
+ if (newInner.getValue() != 10)
+ throw new RuntimeException("inner failed");
+ }
+
+ {
+ Outer outer = new Outer();
+ Inner inner = outer.createInner(3);
+ Inner newInner = outer.doubleInnerValue(inner);
+ if (outer.getInnerValue(newInner) != 6)
+ throw new RuntimeException("inner failed");
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/nspace_extend_runme.java b/trunk/Examples/test-suite/java/nspace_extend_runme.java
new file mode 100644
index 000000000..3e44673d1
--- /dev/null
+++ b/trunk/Examples/test-suite/java/nspace_extend_runme.java
@@ -0,0 +1,44 @@
+// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name
+public class nspace_extend_runme {
+
+ static {
+ try {
+ System.loadLibrary("nspace_extend");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ {
+ // constructors and destructors
+ nspace_extendPackage.Outer.Inner1.Color color1 = new nspace_extendPackage.Outer.Inner1.Color();
+ nspace_extendPackage.Outer.Inner1.Color color = new nspace_extendPackage.Outer.Inner1.Color(color1);
+ color1.delete();
+ color1 = null;
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ nspace_extendPackage.Outer.Inner1.Color.colorStaticMethod(20.0);
+ nspace_extendPackage.Outer.Inner1.Color created = nspace_extendPackage.Outer.Inner1.Color.create();
+ }
+ {
+ // constructors and destructors
+ nspace_extendPackage.Outer.Inner2.Color color2 = new nspace_extendPackage.Outer.Inner2.Color();
+ nspace_extendPackage.Outer.Inner2.Color color = new nspace_extendPackage.Outer.Inner2.Color(color2);
+ color2.delete();
+ color2 = null;
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ nspace_extendPackage.Outer.Inner2.Color.colorStaticMethod(20.0);
+ nspace_extendPackage.Outer.Inner2.Color created = nspace_extendPackage.Outer.Inner2.Color.create();
+
+ // Same class different namespaces
+ nspace_extendPackage.Outer.Inner1.Color col1 = new nspace_extendPackage.Outer.Inner1.Color();
+ nspace_extendPackage.Outer.Inner2.Color col2 = nspace_extendPackage.Outer.Inner2.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/nspace_runme.java b/trunk/Examples/test-suite/java/nspace_runme.java
new file mode 100644
index 000000000..9800e79cd
--- /dev/null
+++ b/trunk/Examples/test-suite/java/nspace_runme.java
@@ -0,0 +1,80 @@
+// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name
+public class nspace_runme {
+
+ static {
+ try {
+ System.loadLibrary("nspace");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ // constructors and destructors
+ nspacePackage.Outer.Inner1.Color color1 = new nspacePackage.Outer.Inner1.Color();
+ nspacePackage.Outer.Inner1.Color color = new nspacePackage.Outer.Inner1.Color(color1);
+ color1.delete();
+ color1 = null;
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ nspacePackage.Outer.Inner1.Color.colorStaticMethod(20.0);
+ nspacePackage.Outer.Inner1.Color created = nspacePackage.Outer.Inner1.Color.create();
+
+ // class enums
+ nspacePackage.Outer.SomeClass someClass = new nspacePackage.Outer.SomeClass();
+ nspacePackage.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
+ if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
+ throw new RuntimeException("Transmission wrong");
+
+ // class anonymous enums
+ int val1 = nspacePackage.Outer.Inner1.Color.ColorEnumVal1;
+ int val2 = nspacePackage.Outer.Inner1.Color.ColorEnumVal2;
+ if (val1 != 0 || val2 != 0x22)
+ throw new RuntimeException("ColorEnumVal wrong");
+
+ // instance member variables
+ color.setInstanceMemberVariable(123);
+ if (color.getInstanceMemberVariable() != 123)
+ throw new RuntimeException("instance member variable failed");
+
+ // static member variables
+ nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789);
+ if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789)
+ throw new RuntimeException("static member variable failed");
+ if (nspacePackage.Outer.Inner1.Color.staticConstMemberVariable != 222)
+ throw new RuntimeException("static const member variable failed");
+ if (nspacePackage.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
+ throw new RuntimeException("static const enum member variable failed");
+
+ // Same class different namespaces
+ nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color();
+ nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+
+ // check globals in a namespace don't get mangled with the nspacePackage option
+ nspacePackage.nspace.namespaceFunction(color);
+ nspacePackage.nspace.setNamespaceVar(111);
+ if (nspacePackage.nspace.getNamespaceVar() != 111)
+ throw new RuntimeException("global var failed");
+
+ // global enums
+ nspacePackage.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
+ if (outerChannel1 != nspacePackage.Outer.Inner1.Channel.Transmission1)
+ throw new RuntimeException("Transmission1 wrong");
+ nspacePackage.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
+ if (outerChannel2 != nspacePackage.Outer.Inner2.Channel.Transmission2)
+ throw new RuntimeException("Transmission2 wrong");
+
+ // turn feature off / ignoring
+ nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace();
+ nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease();
+
+ // Derived class
+ nspacePackage.Outer.Inner3.Blue blue3 = new nspacePackage.Outer.Inner3.Blue();
+ blue3.blueInstanceMethod();
+ nspacePackage.Outer.Inner4.Blue blue4 = new nspacePackage.Outer.Inner4.Blue();
+ blue4.blueInstanceMethod();
+ }
+}
diff --git a/trunk/Examples/test-suite/java/operator_overload_runme.java b/trunk/Examples/test-suite/java/operator_overload_runme.java
new file mode 100644
index 000000000..8a9dddf6b
--- /dev/null
+++ b/trunk/Examples/test-suite/java/operator_overload_runme.java
@@ -0,0 +1,113 @@
+import operator_overload.*;
+
+public class operator_overload_runme {
+
+ static {
+ System.loadLibrary("operator_overload");
+ }
+
+ public static void main(String argv[]) {
+
+ // Java does not support operators, so we just check that these can be called as methods.
+
+ Op.sanity_check();
+
+ //test routine:
+ Op a = new Op();
+ Op b = new Op(5);
+ Op c = new Op(b); // copy constructor
+ Op d = new Op(2);
+ Op dd = d.Equal(d); // assignment operator
+
+ // test equality
+ Assert(a.NotEqual(b));
+ Assert(b.EqualEqual(c));
+ Assert(a.NotEqual(d));
+ Assert(d.EqualEqual(dd));
+
+ // test <
+ Assert(a.LessThan(b));
+ Assert(a.LessThanEqual(b));
+ Assert(b.LessThanEqual(c));
+ Assert(b.GreaterThanEqual(c));
+ Assert(b.GreaterThan(d));
+ Assert(b.GreaterThanEqual(d));
+
+ // test +=
+ Op e = new Op(3);
+ e.PlusEqual(d);
+ Assert(e.EqualEqual(b));
+ e.MinusEqual(c);
+ Assert(e.EqualEqual(a));
+ e = new Op(1);
+ e.MultiplyEqual(b);
+ Assert(e.EqualEqual(c));
+ e.DivideEqual(d);
+ Assert(e.EqualEqual(d));
+ e.PercentEqual(c);
+ Assert(e.EqualEqual(d));
+
+ // test +
+ Op f = new Op(1);
+ Op g = new Op(1);
+ Assert(f.Plus(g).EqualEqual(new Op(2)));
+ Assert(f.Minus(g).EqualEqual(new Op(0)));
+ Assert(f.Multiply(g).EqualEqual(new Op(1)));
+ Assert(f.Divide(g).EqualEqual(new Op(1)));
+ Assert(f.Percent(g).EqualEqual(new Op(0)));
+
+ // test unary operators
+ Assert((a.Not() == true));
+ Assert((b.Not() == false));
+ Assert(a.Minus().EqualEqual(a));
+ Assert(b.Minus().EqualEqual( new Op(-5)));
+
+ // test []
+ Op h = new Op(3);
+ Assert(h.__getitem__(0) == 3);
+ Assert(h.__getitem__(1) == 0);
+ h.__setitem__(0,2); // set
+ Assert(h.__getitem__(0) == 2);
+ h.__setitem__(1,2); // ignored
+ Assert(h.IndexIntoConst(0) == 2);
+ Assert(h.IndexIntoConst(1) == 0);
+
+ // test ()
+ Op i = new Op(3);
+ Assert(i.Functor()==3);
+ Assert(i.Functor(1)==4);
+ Assert(i.Functor(1,2)==6);
+
+ // test ++ --
+ Op j = new Op(10);
+ j.PlusPlusPrefix();
+ j.PlusPlusPostfix(0);
+ Assert(j.getI() == 12);
+ j.MinusMinusPrefix();
+ j.MinusMinusPostfix(0);
+ Assert(j.getI() == 10);
+ {
+ Op op = j.PlusPlusPostfix(0);
+ Assert(j.getI() == op.getI()+1);
+ }
+ {
+ Op op = j.MinusMinusPostfix(0);
+ Assert(j.getI() == op.getI()-1);
+ }
+
+ // cast operators
+ Op k = new Op(3);
+ int check_k = k.IntCast();
+ Assert(check_k == 3);
+
+ Op l = new Op(4);
+ double check_l = l.DoubleCast();
+ Assert(check_l == 4);
+
+ }
+
+ public static void Assert(boolean b) {
+ if (!b)
+ throw new RuntimeException("Assertion failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/overload_complicated_runme.java b/trunk/Examples/test-suite/java/overload_complicated_runme.java
new file mode 100644
index 000000000..ac8523d75
--- /dev/null
+++ b/trunk/Examples/test-suite/java/overload_complicated_runme.java
@@ -0,0 +1,63 @@
+
+import overload_complicated.*;
+
+public class overload_complicated_runme {
+
+ static {
+ try {
+ System.loadLibrary("overload_complicated");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ SWIGTYPE_p_int pInt = null;
+
+ // Check the correct constructors are available
+ Pop p = new Pop(pInt);
+
+ p = new Pop(pInt, false);
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ if (p.hip(false) != 701)
+ throw new RuntimeException("Test 1 failed");
+
+ if (p.hip(pInt) != 702)
+ throw new RuntimeException("Test 2 failed");
+
+ // Reverse the order for the above
+ if (p.hop(pInt) != 805)
+ throw new RuntimeException("Test 3 failed");
+
+ if (p.hop(false) != 801)
+ throw new RuntimeException("Test 4 failed");
+
+ // Few more variations and order shuffled
+ if (p.pop(false) != 901)
+ throw new RuntimeException("Test 5 failed");
+
+ if (p.pop(pInt) != 902)
+ throw new RuntimeException("Test 6 failed");
+
+ if (p.pop() != 905)
+ throw new RuntimeException("Test 7 failed");
+
+ // Overload on const only
+ if (p.bop(pInt) != 1001)
+ throw new RuntimeException("Test 8 failed");
+
+ if (p.bip(pInt) != 2001)
+ throw new RuntimeException("Test 9 failed");
+
+ // Globals
+ if (overload_complicated.muzak(false) != 3001)
+ throw new RuntimeException("Test 10 failed");
+
+ if (overload_complicated.muzak(pInt) != 3002)
+ throw new RuntimeException("Test 11 failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/overload_template_runme.java b/trunk/Examples/test-suite/java/overload_template_runme.java
new file mode 100644
index 000000000..bda1853be
--- /dev/null
+++ b/trunk/Examples/test-suite/java/overload_template_runme.java
@@ -0,0 +1,160 @@
+
+
+import overload_template.*;
+
+public class overload_template_runme {
+
+ static {
+ try {
+ System.loadLibrary("overload_template");
+ } 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 f = overload_template.foo();
+
+ int a = overload_template.maximum(3,4);
+ double b = overload_template.maximum(3.4,5.2);
+
+ // mix 1
+ if (overload_template.mix1("hi") != 101)
+ throw new RuntimeException ("mix1(const char*)");
+
+ if (overload_template.mix1(1.0, 1.0) != 102)
+ throw new RuntimeException ("mix1(double, const double &)");
+
+ if (overload_template.mix1(1.0) != 103)
+ throw new RuntimeException ("mix1(double)");
+
+ // mix 2
+ if (overload_template.mix2("hi") != 101)
+ throw new RuntimeException ("mix2(const char*)");
+
+ if (overload_template.mix2(1.0, 1.0) != 102)
+ throw new RuntimeException ("mix2(double, const double &)");
+
+ if (overload_template.mix2(1.0) != 103)
+ throw new RuntimeException ("mix2(double)");
+
+ // mix 3
+ if (overload_template.mix3("hi") != 101)
+ throw new RuntimeException ("mix3(const char*)");
+
+ if (overload_template.mix3(1.0, 1.0) != 102)
+ throw new RuntimeException ("mix3(double, const double &)");
+
+ if (overload_template.mix3(1.0) != 103)
+ throw new RuntimeException ("mix3(double)");
+
+ // Combination 1
+ if (overload_template.overtparams1(100) != 10)
+ throw new RuntimeException ("overtparams1(int)");
+
+ if (overload_template.overtparams1(100.0, 100) != 20)
+ throw new RuntimeException ("overtparams1(double, int)");
+
+ // Combination 2
+ if (overload_template.overtparams2(100.0, 100) != 40)
+ throw new RuntimeException ("overtparams2(double, int)");
+
+ // Combination 3
+ if (overload_template.overloaded() != 60)
+ throw new RuntimeException ("overloaded()");
+
+ if (overload_template.overloaded(100.0, 100) != 70)
+ throw new RuntimeException ("overloaded(double, int)");
+
+ // Combination 4
+ if (overload_template.overloadedagain("hello") != 80)
+ throw new RuntimeException ("overloadedagain(const char *)");
+
+ if (overload_template.overloadedagain() != 90)
+ throw new RuntimeException ("overloadedagain(double)");
+
+ // specializations
+ if (overload_template.specialization(10) != 202)
+ throw new RuntimeException ("specialization(int)");
+
+ if (overload_template.specialization(10.0) != 203)
+ throw new RuntimeException ("specialization(double)");
+
+ if (overload_template.specialization(10, 10) != 204)
+ throw new RuntimeException ("specialization(int, int)");
+
+ if (overload_template.specialization(10.0, 10.0) != 205)
+ throw new RuntimeException ("specialization(double, double)");
+
+ if (overload_template.specialization("hi", "hi") != 201)
+ throw new RuntimeException ("specialization(const char *, const char *)");
+
+
+ // simple specialization
+ overload_template.xyz();
+ overload_template.xyz_int();
+ overload_template.xyz_double();
+
+
+ // a bit of everything
+ if (overload_template.overload("hi") != 0)
+ throw new RuntimeException ("overload()");
+
+ if (overload_template.overload(1) != 10)
+ throw new RuntimeException ("overload(int t)");
+
+ if (overload_template.overload(1, 1) != 20)
+ throw new RuntimeException ("overload(int t, const int &)");
+
+ if (overload_template.overload(1, "hello") != 30)
+ throw new RuntimeException ("overload(int t, const char *)");
+
+ Klass k = new Klass();
+ if (overload_template.overload(k) != 10)
+ throw new RuntimeException ("overload(Klass t)");
+
+ if (overload_template.overload(k, k) != 20)
+ throw new RuntimeException ("overload(Klass t, const Klass &)");
+
+ if (overload_template.overload(k, "hello") != 30)
+ throw new RuntimeException ("overload(Klass t, const char *)");
+
+ if (overload_template.overload(10.0, "hi") != 40)
+ throw new RuntimeException ("overload(double t, const char *)");
+
+ if (overload_template.overload() != 50)
+ throw new RuntimeException ("overload(const char *)");
+
+
+ // everything put in a namespace
+ if (overload_template.nsoverload("hi") != 1000)
+ throw new RuntimeException ("nsoverload()");
+
+ if (overload_template.nsoverload(1) != 1010)
+ throw new RuntimeException ("nsoverload(int t)");
+
+ if (overload_template.nsoverload(1, 1) != 1020)
+ throw new RuntimeException ("nsoverload(int t, const int &)");
+
+ if (overload_template.nsoverload(1, "hello") != 1030)
+ throw new RuntimeException ("nsoverload(int t, const char *)");
+
+ if (overload_template.nsoverload(k) != 1010)
+ throw new RuntimeException ("nsoverload(Klass t)");
+
+ if (overload_template.nsoverload(k, k) != 1020)
+ throw new RuntimeException ("nsoverload(Klass t, const Klass &)");
+
+ if (overload_template.nsoverload(k, "hello") != 1030)
+ throw new RuntimeException ("nsoverload(Klass t, const char *)");
+
+ if (overload_template.nsoverload(10.0, "hi") != 1040)
+ throw new RuntimeException ("nsoverload(double t, const char *)");
+
+ if (overload_template.nsoverload() != 1050)
+ throw new RuntimeException ("nsoverload(const char *)");
+
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/pointer_reference_runme.java b/trunk/Examples/test-suite/java/pointer_reference_runme.java
new file mode 100644
index 000000000..e8bd6800e
--- /dev/null
+++ b/trunk/Examples/test-suite/java/pointer_reference_runme.java
@@ -0,0 +1,23 @@
+import pointer_reference.*;
+
+public class pointer_reference_runme {
+
+ static {
+ try {
+ System.loadLibrary("pointer_reference");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ Struct s = pointer_reference.get();
+ if (s.getValue() != 10) throw new RuntimeException("get test failed");
+
+ Struct ss = new Struct(20);
+ pointer_reference.set(ss);
+ if (Struct.getInstance().getValue() != 20) throw new RuntimeException("set test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/primitive_ref_runme.java b/trunk/Examples/test-suite/java/primitive_ref_runme.java
new file mode 100644
index 000000000..2955004db
--- /dev/null
+++ b/trunk/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(0x123456789ABCDEF0L) != 0x123456789ABCDEF0L) {
+ 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/trunk/Examples/test-suite/java/profiletest_runme.java b/trunk/Examples/test-suite/java/profiletest_runme.java
new file mode 100644
index 000000000..f55001369
--- /dev/null
+++ b/trunk/Examples/test-suite/java/profiletest_runme.java
@@ -0,0 +1,15 @@
+import profiletest.*;
+
+public class profiletest_runme {
+
+ System.loadLibrary("profiletest");
+
+ public static void main(String argv[]) {
+
+ long a = profiletest.new_A();
+ long b = profiletest.new_B();
+ for (int i=0; i<1000000; i++) {
+ a = profiletest.B_fn(b, a);
+ }
+ }
+}
diff --git a/trunk/Examples/test-suite/java/rename1_runme.java b/trunk/Examples/test-suite/java/rename1_runme.java
new file mode 100644
index 000000000..058de41fd
--- /dev/null
+++ b/trunk/Examples/test-suite/java/rename1_runme.java
@@ -0,0 +1,75 @@
+
+import rename1.*;
+
+public class rename1_runme {
+
+ static {
+ try {
+ System.loadLibrary("rename1");
+ } 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);
+ }
+ }
+
+ // The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
+ public static void main(String argv[]) {
+ {
+ XYZInt xyz = new XYZInt();
+ NotXYZInt notxyz = new NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+ }
+ {
+ XYZDouble xyz = new XYZDouble();
+ NotXYZDouble notxyz = new NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+ }
+ {
+ XYZKlass xyz = new XYZKlass();
+ NotXYZKlass notxyz = new NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+ }
+ {
+ XYZEnu xyz = new XYZEnu();
+ NotXYZEnu notxyz = new NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(Enu.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+ }
+ {
+ ABC abc = new ABC();
+ abc.methodABC(abc);
+ Klass k = new Klass();
+ abc.methodKlass(k);
+ ABC a = abc.opABC();
+ k = abc.opKlass();
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/rename2_runme.java b/trunk/Examples/test-suite/java/rename2_runme.java
new file mode 100644
index 000000000..b6a62dd1e
--- /dev/null
+++ b/trunk/Examples/test-suite/java/rename2_runme.java
@@ -0,0 +1,75 @@
+
+import rename2.*;
+
+public class rename2_runme {
+
+ static {
+ try {
+ System.loadLibrary("rename2");
+ } 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);
+ }
+ }
+
+ // The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
+ public static void main(String argv[]) {
+ {
+ XYZInt xyz = new XYZInt();
+ NotXYZInt notxyz = new NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+ }
+ {
+ XYZDouble xyz = new XYZDouble();
+ NotXYZDouble notxyz = new NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+ }
+ {
+ XYZKlass xyz = new XYZKlass();
+ NotXYZKlass notxyz = new NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+ }
+ {
+ XYZEnu xyz = new XYZEnu();
+ NotXYZEnu notxyz = new NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(Enu.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+ }
+ {
+ ABC abc = new ABC();
+ abc.methodABC(abc);
+ Klass k = new Klass();
+ abc.methodKlass(k);
+ ABC a = abc.opABC();
+ k = abc.opKlass();
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/rename3_runme.java b/trunk/Examples/test-suite/java/rename3_runme.java
new file mode 100644
index 000000000..e1b090af8
--- /dev/null
+++ b/trunk/Examples/test-suite/java/rename3_runme.java
@@ -0,0 +1,75 @@
+
+import rename3.*;
+
+public class rename3_runme {
+
+ static {
+ try {
+ System.loadLibrary("rename3");
+ } 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);
+ }
+ }
+
+ // The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
+ public static void main(String argv[]) {
+ {
+ XYZInt xyz = new XYZInt();
+ NotXYZInt notxyz = new NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+ }
+ {
+ XYZDouble xyz = new XYZDouble();
+ NotXYZDouble notxyz = new NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+ }
+ {
+ XYZKlass xyz = new XYZKlass();
+ NotXYZKlass notxyz = new NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+ }
+ {
+ XYZEnu xyz = new XYZEnu();
+ NotXYZEnu notxyz = new NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(Enu.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+ }
+ {
+ ABC abc = new ABC();
+ abc.methodABC(abc);
+ Klass k = new Klass();
+ abc.methodKlass(k);
+ ABC a = abc.opABC();
+ k = abc.opKlass();
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/rename4_runme.java b/trunk/Examples/test-suite/java/rename4_runme.java
new file mode 100644
index 000000000..69f909e9e
--- /dev/null
+++ b/trunk/Examples/test-suite/java/rename4_runme.java
@@ -0,0 +1,75 @@
+
+import rename4.*;
+
+public class rename4_runme {
+
+ static {
+ try {
+ System.loadLibrary("rename4");
+ } 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);
+ }
+ }
+
+ // The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
+ public static void main(String argv[]) {
+ {
+ XYZInt xyz = new XYZInt();
+ NotXYZInt notxyz = new NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+ }
+ {
+ XYZDouble xyz = new XYZDouble();
+ NotXYZDouble notxyz = new NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+ }
+ {
+ XYZKlass xyz = new XYZKlass();
+ NotXYZKlass notxyz = new NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+ }
+ {
+ XYZEnu xyz = new XYZEnu();
+ NotXYZEnu notxyz = new NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(Enu.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+ }
+ {
+ ABC abc = new ABC();
+ abc.methodABC(abc);
+ Klass k = new Klass();
+ abc.methodKlass(k);
+ ABC a = abc.opABC();
+ k = abc.opKlass();
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/ret_by_value_runme.java b/trunk/Examples/test-suite/java/ret_by_value_runme.java
new file mode 100644
index 000000000..44bb69796
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/rname_runme.java b/trunk/Examples/test-suite/java/rname_runme.java
new file mode 100644
index 000000000..7f2ab2f75
--- /dev/null
+++ b/trunk/Examples/test-suite/java/rname_runme.java
@@ -0,0 +1,38 @@
+
+import rname.*;
+
+public class rname_runme {
+
+ static {
+ try {
+ System.loadLibrary("rname");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ rname.foo_i(10);
+ rname.foo_d(10.0);
+ rname.foo_s((short)10);
+ rname.foo((long)10);
+
+ Bar bar = new Bar();
+ bar.foo_i(10);
+ bar.foo_d(10.0);
+ bar.foo((short)10);
+ bar.foo_u((long)10);
+
+ RenamedBase base = new RenamedBase();
+ base.fn(base, base, base);
+ if (!base.newname(10.0).equals("Base"))
+ throw new RuntimeException("base.newname");
+
+ RenamedDerived derived = new RenamedDerived();
+ derived.func(base, base, base);
+ if (!derived.newname(10.0).equals("Derived"))
+ throw new RuntimeException("derived.newname");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/sizet_runme.java b/trunk/Examples/test-suite/java/sizet_runme.java
new file mode 100644
index 000000000..20ab047dc
--- /dev/null
+++ b/trunk/Examples/test-suite/java/sizet_runme.java
@@ -0,0 +1,24 @@
+import sizet.*;
+
+public class sizet_runme {
+
+ static {
+ try {
+ System.loadLibrary("sizet");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ long s = 2000;
+ s = sizet.test1(s+1);
+ s = sizet.test2(s+1);
+ s = sizet.test3(s+1);
+ s = sizet.test4(s+1);
+ if (s != 2004)
+ throw new RuntimeException("failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/special_variable_macros_runme.java b/trunk/Examples/test-suite/java/special_variable_macros_runme.java
new file mode 100644
index 000000000..d7f8070b3
--- /dev/null
+++ b/trunk/Examples/test-suite/java/special_variable_macros_runme.java
@@ -0,0 +1,32 @@
+
+import special_variable_macros.*;
+
+public class special_variable_macros_runme {
+
+ static {
+ try {
+ System.loadLibrary("special_variable_macros");
+ } 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[]) {
+ Name name = new Name();
+ if (!special_variable_macros.testFred(name).equals("none"))
+ throw new RuntimeException("test failed");
+ if (!special_variable_macros.testJack(name).equals("$specialname"))
+ throw new RuntimeException("test failed");
+ if (!special_variable_macros.testJill(name).equals("jilly"))
+ throw new RuntimeException("test failed");
+ if (!special_variable_macros.testMary(name).equals("SWIGTYPE_p_NameWrap"))
+ throw new RuntimeException("test failed");
+ if (!special_variable_macros.testJim(name).equals("multiname num"))
+ throw new RuntimeException("test failed");
+ if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
+ throw new RuntimeException("test failed");
+ NewName newName = NewName.factory("factoryname");
+ name = newName.getStoredName();
+ }
+}
diff --git a/trunk/Examples/test-suite/java/special_variables_runme.java b/trunk/Examples/test-suite/java/special_variables_runme.java
new file mode 100644
index 000000000..eb9f093bd
--- /dev/null
+++ b/trunk/Examples/test-suite/java/special_variables_runme.java
@@ -0,0 +1,53 @@
+
+import special_variables.*;
+
+public class special_variables_runme {
+
+ static {
+ try {
+ System.loadLibrary("special_variables");
+ } 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[])
+ {
+ verify(special_variables.ExceptionVars(1.0, 2.0),
+ "result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars Java_special_1variables_special_1variablesJNI_ExceptionVars");
+
+ verify(special_variables.overloadedmethod(),
+ "result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_11");
+
+ verify(special_variables.overloadedmethod(10.0),
+ "result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_10");
+
+ ABC a = new ABC(0, 0.0);
+ verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)");
+ a = new ABC();
+ verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::ABC() SpaceNamespace::ABC::ABC()");
+ a.instancemethod(1);
+ verify(special_variables.getDeclaration(), "short * SpaceNamespace::ABC::instancemethod(int) SpaceNamespace::ABC::instancemethod(int)");
+ a.instancemethod(1, false);
+ verify(special_variables.getDeclaration(), "short * SpaceNamespace::ABC::instancemethod(int,bool) SpaceNamespace::ABC::instancemethod(int,bool)");
+ a.constmethod(1);
+ verify(special_variables.getDeclaration(), "short * SpaceNamespace::ABC::constmethod(int) const SpaceNamespace::ABC::constmethod(int) const");
+ ABC.staticmethod(0, false);
+ verify(special_variables.getDeclaration(), "short * SpaceNamespace::ABC::staticmethod(int,bool) SpaceNamespace::ABC::staticmethod(int,bool)");
+ a.delete();
+ verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::~ABC() SpaceNamespace::ABC::~ABC()");
+ TemplateABC abc = new TemplateABC();
+ verify(special_variables.getDeclaration(), "SpaceNamespace::Template< SpaceNamespace::ABC >::Template() SpaceNamespace::Template< SpaceNamespace::ABC >::Template()");
+ abc.tmethod(new ABC());
+ verify(special_variables.getDeclaration(), "std::string SpaceNamespace::Template< SpaceNamespace::ABC >::tmethod(SpaceNamespace::ABC) SpaceNamespace::Template< SpaceNamespace::ABC >::tmethod(SpaceNamespace::ABC)");
+ abc.delete();
+ verify(special_variables.getDeclaration(), "SpaceNamespace::Template< SpaceNamespace::ABC >::~Template() SpaceNamespace::Template< SpaceNamespace::ABC >::~Template()");
+ special_variables.globtemplate(new TemplateABC());
+ verify(special_variables.getDeclaration(), "void SpaceNamespace::globtemplate(SpaceNamespace::Template< SpaceNamespace::ABC >) SpaceNamespace::globtemplate(SpaceNamespace::Template< SpaceNamespace::ABC >)");
+ }
+ static void verify(String received, String expected) {
+ if (!received.equals(expected))
+ throw new RuntimeException("Incorrect, received: " + received);
+ }
+}
diff --git a/trunk/Examples/test-suite/java/template_classes_runme.java b/trunk/Examples/test-suite/java/template_classes_runme.java
new file mode 100644
index 000000000..48f12cb7a
--- /dev/null
+++ b/trunk/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 proxy 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/trunk/Examples/test-suite/java/template_default_arg_runme.java b/trunk/Examples/test-suite/java/template_default_arg_runme.java
new file mode 100644
index 000000000..b274935da
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_default_arg_runme.java
@@ -0,0 +1,156 @@
+
+
+import template_default_arg.*;
+
+public class template_default_arg_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_default_arg");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ {
+ Hello_int helloInt = new Hello_int();
+ helloInt.foo(Hello_int.Hi.hi);
+ }
+ {
+ X_int x = new X_int();
+ if (x.meth(20.0, 200) != 200)
+ throw new RuntimeException("X_int test 1 failed");
+ if (x.meth(20) != 20)
+ throw new RuntimeException("X_int test 2 failed");
+ if (x.meth() != 0)
+ throw new RuntimeException("X_int test 3 failed");
+ }
+
+ {
+ Y_unsigned y = new Y_unsigned();
+ if (y.meth(20.0, 200) != 200)
+ throw new RuntimeException("Y_unsigned test 1 failed");
+ if (y.meth(20) != 20)
+ throw new RuntimeException("Y_unsigned test 2 failed");
+ if (y.meth() != 0)
+ throw new RuntimeException("Y_unsigned test 3 failed");
+ }
+
+ {
+ X_longlong x = new X_longlong();
+ x = new X_longlong(20.0);
+ x = new X_longlong(20.0, 200L);
+ }
+ {
+ X_int x = new X_int();
+ x = new X_int(20.0);
+ x = new X_int(20.0, 200);
+ }
+ {
+ X_hello_unsigned x = new X_hello_unsigned();
+ x = new X_hello_unsigned(20.0);
+ x = new X_hello_unsigned(20.0, new Hello_int());
+ }
+ {
+ Y_hello_unsigned y = new Y_hello_unsigned();
+ y.meth(20.0, new Hello_int());
+ y.meth(new Hello_int());
+ y.meth();
+ }
+
+ {
+ Foo_Z_8 fz = new Foo_Z_8();
+ X_Foo_Z_8 x = new X_Foo_Z_8();
+ Foo_Z_8 fzc = x.meth(fz);
+ }
+
+ // Templated functions
+ {
+ // plain function: int ott(Foo<int>)
+ if (template_default_arg.ott(new Foo_int()) != 30)
+ throw new RuntimeException("ott test 1 failed");
+
+ // %template(ott) ott<int, int>;
+ if (template_default_arg.ott() != 10)
+ throw new RuntimeException("ott test 2 failed");
+ if (template_default_arg.ott(1) != 10)
+ throw new RuntimeException("ott test 3 failed");
+ if (template_default_arg.ott(1, 1) != 10)
+ throw new RuntimeException("ott test 4 failed");
+
+ if (template_default_arg.ott("hi") != 20)
+ throw new RuntimeException("ott test 5 failed");
+ if (template_default_arg.ott("hi", 1) != 20)
+ throw new RuntimeException("ott test 6 failed");
+ if (template_default_arg.ott("hi", 1, 1) != 20)
+ throw new RuntimeException("ott test 7 failed");
+
+ // %template(ott) ott<const char *>;
+ if (template_default_arg.ottstring(new Hello_int(), "hi") != 40)
+ throw new RuntimeException("ott test 8 failed");
+
+ if (template_default_arg.ottstring(new Hello_int()) != 40)
+ throw new RuntimeException("ott test 9 failed");
+
+ // %template(ott) ott<int>;
+ if (template_default_arg.ottint(new Hello_int(), 1) != 50)
+ throw new RuntimeException("ott test 10 failed");
+
+ if (template_default_arg.ottint(new Hello_int()) != 50)
+ throw new RuntimeException("ott test 11 failed");
+
+ // %template(ott) ott<double>;
+ if (template_default_arg.ott(new Hello_int(), 1.0) != 60)
+ throw new RuntimeException("ott test 12 failed");
+
+ if (template_default_arg.ott(new Hello_int()) != 60)
+ throw new RuntimeException("ott test 13 failed");
+ }
+
+ // Above test in namespaces
+ {
+ // plain function: int nsott(Foo<int>)
+ if (template_default_arg.nsott(new Foo_int()) != 130)
+ throw new RuntimeException("nsott test 1 failed");
+
+ // %template(nsott) nsott<int, int>;
+ if (template_default_arg.nsott() != 110)
+ throw new RuntimeException("nsott test 2 failed");
+ if (template_default_arg.nsott(1) != 110)
+ throw new RuntimeException("nsott test 3 failed");
+ if (template_default_arg.nsott(1, 1) != 110)
+ throw new RuntimeException("nsott test 4 failed");
+
+ if (template_default_arg.nsott("hi") != 120)
+ throw new RuntimeException("nsott test 5 failed");
+ if (template_default_arg.nsott("hi", 1) != 120)
+ throw new RuntimeException("nsott test 6 failed");
+ if (template_default_arg.nsott("hi", 1, 1) != 120)
+ throw new RuntimeException("nsott test 7 failed");
+
+ // %template(nsott) nsott<const char *>;
+ if (template_default_arg.nsottstring(new Hello_int(), "hi") != 140)
+ throw new RuntimeException("nsott test 8 failed");
+
+ if (template_default_arg.nsottstring(new Hello_int()) != 140)
+ throw new RuntimeException("nsott test 9 failed");
+
+ // %template(nsott) nsott<int>;
+ if (template_default_arg.nsottint(new Hello_int(), 1) != 150)
+ throw new RuntimeException("nsott test 10 failed");
+
+ if (template_default_arg.nsottint(new Hello_int()) != 150)
+ throw new RuntimeException("nsott test 11 failed");
+
+ // %template(nsott) nsott<double>;
+ if (template_default_arg.nsott(new Hello_int(), 1.0) != 160)
+ throw new RuntimeException("nsott test 12 failed");
+
+ if (template_default_arg.nsott(new Hello_int()) != 160)
+ throw new RuntimeException("nsott test 13 failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_default_class_parms_runme.java b/trunk/Examples/test-suite/java/template_default_class_parms_runme.java
new file mode 100644
index 000000000..4c8010745
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_default_class_parms_runme.java
@@ -0,0 +1,43 @@
+
+
+import template_default_class_parms.*;
+
+public class template_default_class_parms_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_default_class_parms");
+ } 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[]) {
+ {
+ DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
+ double d = bar.getCType();
+ SomeType s = bar.getDType();
+ int i = bar.getEType();
+ d = bar.method(d, s, i);
+ }
+ {
+ DefaultFoo foo = new DefaultFoo(new SomeType());
+ SomeType s = foo.getTType();
+ s = foo.method(s);
+ }
+ {
+ BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
+ AnotherType a = bar.getCType();
+ boolean b = bar.getDType();
+ int i = bar.getEType();
+ a = bar.method(a, b, i);
+ }
+ {
+ FooAnotherType foo = new FooAnotherType(new AnotherType());
+ AnotherType a = foo.getTType();
+ a = foo.method(a);
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_methods_runme.java b/trunk/Examples/test-suite/java/template_methods_runme.java
new file mode 100644
index 000000000..14256b6be
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_methods_runme.java
@@ -0,0 +1,44 @@
+
+import template_methods.*;
+
+public class template_methods_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_methods");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ float num = (float)1.1;
+
+ // Global templated functions
+ int i = template_methods.convolve1Bool();
+ template_methods.convolve1Bool(true);
+ i = template_methods.convolve2Float();
+ template_methods.convolve3FloatRenamed(num);
+ i = template_methods.convolve4Float();
+ template_methods.convolve4FloatRenamed(num);
+ i = template_methods.convolve5FloatRenamed();
+ template_methods.convolve5FloatRenamed(num);
+
+
+ // Static templated methods
+ Klass k = new Klass();
+ boolean b = k.KlassTMethodBoolRenamed(true);
+ k.KlassTMethodBool();
+ b = Klass.KlassStaticTMethodBoolRenamed(true);
+ Klass.KlassStaticTMethodBool();
+
+
+ //
+ ComponentProperties cp = new ComponentProperties();
+ cp.adda("key1", "val1", "key2", 22.2);
+ cp.adda("key1", "val1", "key2", "val2", "key3", "val3");
+ cp.adda("key1", 1, "key2", 2, "key3", 3);
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_nested_runme.java b/trunk/Examples/test-suite/java/template_nested_runme.java
new file mode 100644
index 000000000..407821674
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_nested_runme.java
@@ -0,0 +1,30 @@
+
+import template_nested.*;
+
+public class template_nested_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_nested");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ new T_NormalTemplateNormalClass().tmethod(new NormalClass());
+ new OuterClass().T_OuterTMethodNormalClass(new NormalClass());
+
+ TemplateFuncs tf = new TemplateFuncs();
+ if (tf.T_TemplateFuncs1Int(-10) != -10)
+ throw new RuntimeException("it failed");
+ if (tf.T_TemplateFuncs2Double(-12.3) != -12.3)
+ throw new RuntimeException("it failed");
+
+ T_NestedOuterTemplateDouble tn = new T_NestedOuterTemplateDouble();
+ if (tn.hohum(-12.3) != -12.3)
+ throw new RuntimeException("it failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_nested_typemaps_runme.java b/trunk/Examples/test-suite/java/template_nested_typemaps_runme.java
new file mode 100644
index 000000000..443faca4f
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_nested_typemaps_runme.java
@@ -0,0 +1,39 @@
+import template_nested_typemaps.*;
+
+public class template_nested_typemaps_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_nested_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[]) {
+ BreezeString b = new BreezeString();
+ {
+ int v = 88;
+ short vTypemap = -99;
+ if (b.methodInt1(v) != v) throw new RuntimeException("failed");
+ if (b.methodInt2(v) != vTypemap) throw new RuntimeException("failed");
+
+ if (template_nested_typemaps.globalInt1(v) != v) throw new RuntimeException("failed");
+ if (template_nested_typemaps.globalInt2(v) != v) throw new RuntimeException("failed");
+ if (template_nested_typemaps.globalInt3(v) != vTypemap) throw new RuntimeException("failed");
+ }
+
+ {
+ short v = 88;
+ short vTypemap = -77;
+ if (b.methodShort1(v) != v) throw new RuntimeException("failed");
+ if (b.methodShort2(v) != vTypemap) throw new RuntimeException("failed");
+
+ if (template_nested_typemaps.globalShort1(v) != v) throw new RuntimeException("failed");
+ if (template_nested_typemaps.globalShort2(v) != v) throw new RuntimeException("failed");
+ if (template_nested_typemaps.globalShort3(v) != vTypemap) throw new RuntimeException("failed");
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_partial_specialization_runme.java b/trunk/Examples/test-suite/java/template_partial_specialization_runme.java
new file mode 100644
index 000000000..ef8c4e80e
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_partial_specialization_runme.java
@@ -0,0 +1,59 @@
+import template_partial_specialization.*;
+
+public class template_partial_specialization_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_partial_specialization");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ // One parameter tests
+ new A().a();
+ new B().b();
+ new C().c();
+ new D().d();
+ new E().e();
+
+ new F().f();
+ new G().g();
+ new H().h();
+
+ new I().i();
+ new J().j();
+ new K().k();
+ new L().l();
+
+ new BB().b();
+ new BBB().b();
+ new BBBB().b();
+ new BBBBB().b();
+
+ new B1().b();
+ new B2().b();
+ new B3().b();
+ new B4().b();
+
+ // Two parameter tests
+ new A_().a();
+ new B_().b();
+ new C_().c();
+ new D_().d();
+ new E_().e();
+ new F_().f();
+ new G_().g();
+
+ new C1_().c();
+ new C2_().c();
+ new C3_().c();
+ new C4_().c();
+ new B1_().b();
+ new E1_().e();
+ new E2_().e();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_partial_specialization_typedef_runme.java b/trunk/Examples/test-suite/java/template_partial_specialization_typedef_runme.java
new file mode 100644
index 000000000..6ae95eb6a
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_partial_specialization_typedef_runme.java
@@ -0,0 +1,59 @@
+import template_partial_specialization_typedef.*;
+
+public class template_partial_specialization_typedef_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_partial_specialization_typedef");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ // One parameter tests
+ new A().a();
+ new B().b();
+ new C().c();
+ new D().d();
+ new E().e();
+
+ new F().f();
+ new G().g();
+ new H().h();
+
+ new I().i();
+ new J().j();
+ new K().k();
+ new L().l();
+
+ new BB().b();
+ new BBB().b();
+ new BBBB().b();
+ new BBBBB().b();
+
+ new B1().b();
+ new B2().b();
+ new B3().b();
+ new B4().b();
+
+ // Two parameter tests
+ new A_().a();
+ new B_().b();
+ new C_().c();
+ new D_().d();
+ new E_().e();
+ new F_().f();
+ new G_().g();
+
+ new C1_().c();
+ new C2_().c();
+ new C3_().c();
+ new C4_().c();
+ new B1_().b();
+ new E1_().e();
+ new E2_().e();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/template_template_parameters_runme.java b/trunk/Examples/test-suite/java/template_template_parameters_runme.java
new file mode 100644
index 000000000..42135b982
--- /dev/null
+++ b/trunk/Examples/test-suite/java/template_template_parameters_runme.java
@@ -0,0 +1,28 @@
+
+
+import template_template_parameters.*;
+
+public class template_template_parameters_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_template_parameters");
+ } 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[]) {
+ ListFastBool listBool = new ListFastBool();
+ listBool.setItem(true);
+ if (listBool.getItem() != true)
+ throw new RuntimeException("Failed");
+
+ ListDefaultDouble listDouble = new ListDefaultDouble();
+ listDouble.setItem(10.2);
+ if (listDouble.getItem() != 10.2)
+ throw new RuntimeException("Failed");
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/typemap_namespace_runme.java b/trunk/Examples/test-suite/java/typemap_namespace_runme.java
new file mode 100644
index 000000000..eddb896cf
--- /dev/null
+++ b/trunk/Examples/test-suite/java/typemap_namespace_runme.java
@@ -0,0 +1,21 @@
+import typemap_namespace.*;
+
+public class typemap_namespace_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_namespace");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ if (!typemap_namespace.test1("hello").equals("hello"))
+ throw new RuntimeException("test1 failed");
+ if (!typemap_namespace.test2("hello").equals("hello"))
+ throw new RuntimeException("test2 failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/typemap_out_optimal_runme.java b/trunk/Examples/test-suite/java/typemap_out_optimal_runme.java
new file mode 100644
index 000000000..8a87f0c4b
--- /dev/null
+++ b/trunk/Examples/test-suite/java/typemap_out_optimal_runme.java
@@ -0,0 +1,21 @@
+
+import typemap_out_optimal.*;
+
+public class typemap_out_optimal_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_out_optimal");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static XX x = null;
+ public static void main(String argv[]) {
+ XX.setDebug(false);
+ x = XX.create();
+ }
+}
+
diff --git a/trunk/Examples/test-suite/java/unions_runme.java b/trunk/Examples/test-suite/java/unions_runme.java
new file mode 100644
index 000000000..16a5b3b87
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/java/using_pointers_runme.java b/trunk/Examples/test-suite/java/using_pointers_runme.java
new file mode 100644
index 000000000..deab4e6e4
--- /dev/null
+++ b/trunk/Examples/test-suite/java/using_pointers_runme.java
@@ -0,0 +1,32 @@
+
+import using_pointers.*;
+
+public class using_pointers_runme {
+
+ static {
+ try {
+ System.loadLibrary("using_pointers");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[])
+ {
+ FooBar f = new FooBar();
+ boolean pass = true;
+ try {
+ f.exception_spec(1);
+ pass = false;
+ } catch (RuntimeException e) {
+ }
+ if (!pass) throw new RuntimeException("Missed exception 1");
+ try {
+ f.exception_spec(2);
+ pass = false;
+ } catch (RuntimeException e) {
+ }
+ if (!pass) throw new RuntimeException("Missed exception 2");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/varargs_runme.java b/trunk/Examples/test-suite/java/varargs_runme.java
new file mode 100644
index 000000000..e8b485db9
--- /dev/null
+++ b/trunk/Examples/test-suite/java/varargs_runme.java
@@ -0,0 +1,35 @@
+// varargs test
+
+import varargs.*;
+
+public class varargs_runme {
+
+ static {
+ try {
+ System.loadLibrary("varargs");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ if (!varargs.test("Hello").equals("Hello"))
+ throw new RuntimeException("Failed");
+
+ Foo f = new Foo("BuonGiorno", 1);
+ if (!f.getStr().equals("BuonGiorno"))
+ throw new RuntimeException("Failed");
+
+ f = new Foo("Greetings");
+ if (!f.getStr().equals("Greetings"))
+ throw new RuntimeException("Failed");
+
+ if (!f.test("Hello").equals("Hello"))
+ throw new RuntimeException("Failed");
+
+ if (!Foo.statictest("Grussen", 1).equals("Grussen"))
+ throw new RuntimeException("Failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/virtual_poly_runme.java b/trunk/Examples/test-suite/java/virtual_poly_runme.java
new file mode 100644
index 000000000..81e2f398a
--- /dev/null
+++ b/trunk/Examples/test-suite/java/virtual_poly_runme.java
@@ -0,0 +1,61 @@
+// virtual_poly test
+
+import virtual_poly.*;
+
+public class virtual_poly_runme {
+
+ static {
+ try {
+ System.loadLibrary("virtual_poly");
+ } 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[]) {
+
+ NDouble d = new NDouble(3.5);
+ NInt i = new NInt(2);
+
+ //
+ // These two natural 'copy' forms fail because no covariant (polymorphic) return types
+ // are supported in Java.
+ //
+ // NDouble dc = d.copy();
+ // NInt ic = i.copy();
+
+ //
+ // Unlike C++, we have to downcast instead.
+ //
+ NDouble dc = (NDouble)d.copy();
+ NInt ic = (NInt)i.copy();
+
+ NDouble ddc = NDouble.narrow(dc);
+ NInt dic = NInt.narrow(ic);
+
+ virtual_poly.incr(ic);
+ if ( (i.get() + 1) != ic.get() )
+ throw new RuntimeException("incr test failed");
+
+ //
+ // Checking a pure user downcast
+ //
+ NNumber n1 = d.copy();
+ NNumber n2 = d.nnumber();
+ NDouble dn1 = NDouble.narrow(n1);
+ NDouble dn2 = NDouble.narrow(n2);
+
+ if ( (dn1.get()) != dn2.get() )
+ throw new RuntimeException("copy/narrow test failed");
+
+ //
+ // Checking the ref polymorphic case
+ //
+ NNumber nr = d.ref_this();
+ NDouble dr1 = NDouble.narrow(nr);
+ NDouble dr2 = (NDouble)d.ref_this();
+ if ( dr1.get() != dr2.get() )
+ throw new RuntimeException("copy/narrow test failed");
+ }
+}
diff --git a/trunk/Examples/test-suite/java/wallkw_runme.java b/trunk/Examples/test-suite/java/wallkw_runme.java
new file mode 100644
index 000000000..028c2a32f
--- /dev/null
+++ b/trunk/Examples/test-suite/java/wallkw_runme.java
@@ -0,0 +1,25 @@
+
+import wallkw.*;
+
+public class wallkw_runme {
+
+ static {
+ try {
+ System.loadLibrary("wallkw");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ if (!wallkw.c_clone().equals("clone"))
+ throw new RuntimeException("clone_c keyword fail");
+ if (!wallkw._delegate().equals("delegate"))
+ throw new RuntimeException("delegate keyword fail");
+ if (!wallkw._pass().equals("pass"))
+ throw new RuntimeException("pass keyword fail");
+ if (!wallkw.C_alias().equals("alias"))
+ throw new RuntimeException("alias keyword fail");
+ }
+}
diff --git a/trunk/Examples/test-suite/java_constants.i b/trunk/Examples/test-suite/java_constants.i
new file mode 100644
index 000000000..220485361
--- /dev/null
+++ b/trunk/Examples/test-suite/java_constants.i
@@ -0,0 +1,35 @@
+
+// This testcase uses the %javaconst directive to control how constants are initialised
+
+%module java_constants
+
+
+%constant short DIPSTICK=100;
+
+// Set default Java const code generation
+%javaconst(1);
+
+// Modify the code generation to use JNI function call initialisation for some difficult cases
+%javaconst(0) TOM;
+%javaconst(0) ORCHESTRA_STALLS;
+%javaconst(0) PORKY;
+
+%inline %{
+#define CHINA 2*100
+#define TOM 300ULL
+#define ORCHESTRA_STALLS 400LL
+#define JAM_JAR "500"
+#define OXO '6'
+#define PORKY !7
+%}
+
+%constant int BRISTOLS=800;
+
+%javaconstvalue(100L) APPLES;
+%inline %{
+#define APPLES 100LL
+%}
+
+%javaconst(0);
+%constant long long ROSY=900LL;
+
diff --git a/trunk/Examples/test-suite/java_director.i b/trunk/Examples/test-suite/java_director.i
new file mode 100644
index 000000000..03d733d6a
--- /dev/null
+++ b/trunk/Examples/test-suite/java_director.i
@@ -0,0 +1,132 @@
+/*
+ * Test Java director typemaps and features
+ */
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR); /* Thread/reentrant unsafe wrapping, consider returning by value instead. */
+
+%module(directors="1") java_director
+
+%typemap(javafinalize) SWIGTYPE %{
+ protected void finalize() {
+// System.out.println("Finalizing " + this);
+ delete();
+ }
+%}
+
+
+%{
+#include <string>
+#include <vector>
+
+class Quux {
+public:
+ Quux() : memb_("default Quux ctor arg") {instances_++; }
+ Quux(const std::string &arg) : memb_(arg) {instances_++;}
+ Quux(const Quux &src) : memb_(src.memb_) {instances_++;}
+ virtual ~Quux() {instances_--;}
+ virtual const std::string &director_method() { return memb_; }
+ const std::string &member() { return memb_; }
+ static int instances() { return instances_; }
+private:
+ static int instances_;
+ std::string memb_;
+};
+
+int Quux::instances_ = 0;
+
+class QuuxContainer {
+protected:
+ typedef std::vector<Quux *> quuxvec_t;
+public:
+ QuuxContainer() : quuxen_()
+ { }
+ ~QuuxContainer() {
+ for (quuxvec_t::iterator iter = quuxen_.begin(); iter != quuxen_.end(); ++iter) {
+ delete *iter;
+ }
+ quuxen_.clear();
+ }
+ void push(Quux *elem) {
+ quuxen_.push_back(elem);
+ }
+ Quux *get(int idx) {
+ return quuxen_[idx];
+ }
+ const std::string &invoke(int idx) {
+ return quuxen_[idx]->director_method();
+ }
+ size_t size() {
+ return quuxen_.size();
+ }
+private:
+ quuxvec_t quuxen_;
+};
+%}
+
+%include "std_string.i"
+
+%feature("director") Quux;
+SWIG_DIRECTOR_OWNED(Quux)
+
+class Quux {
+public:
+ Quux();
+ Quux(const std::string &arg);
+ Quux(const Quux &src);
+ virtual ~Quux();
+ virtual const std::string &director_method();
+ const std::string &member();
+ static int instances();
+};
+
+class QuuxContainer {
+public:
+ QuuxContainer();
+ ~QuuxContainer();
+ void push(Quux *elem);
+ Quux *get(int idx);
+ const std::string &invoke(int idx);
+ size_t size();
+};
+
+
+%feature("director");
+
+%typemap(javacode) hi::Quux1 %{
+ public boolean disconnectMethodCalled = false;
+%}
+
+%typemap(directordisconnect, methodname="disconnect_director") hi::Quux1 %{
+ public void $methodname() {
+ swigCMemOwn = false;
+ $jnicall;
+ // add in a flag to check this method is really called
+ disconnectMethodCalled = true;
+ }
+%}
+
+%inline %{
+
+namespace hi {
+ struct Quux1 : public Quux {
+ Quux1(const std::string& arg) : Quux(arg) {}
+ virtual int ff(int i = 0) {return i;}
+ };
+}
+
+struct JObjectTest {
+ virtual ~JObjectTest() {}
+ // Test special Java JNI type jobject
+ virtual jobject foo(jobject x) { return x; }
+};
+
+%}
+
+%javaexception("Exception") etest "$action"
+%inline %{
+struct JavaExceptionTest {
+ virtual ~JavaExceptionTest() {}
+ virtual void etest() {}
+};
+%}
+
diff --git a/trunk/Examples/test-suite/java_enums.i b/trunk/Examples/test-suite/java_enums.i
new file mode 100644
index 000000000..855913d06
--- /dev/null
+++ b/trunk/Examples/test-suite/java_enums.i
@@ -0,0 +1,66 @@
+
+// This testcase uses the %javaconst directive to control how enums are initialised
+
+%module java_enums
+
+%include "enumtypeunsafe.swg"
+
+// Some pragmas to add in an interface to the module class
+%pragma(java) moduleinterfaces="Serializable"
+%pragma(java) moduleimports=%{
+import java.io.*; // For Serializable
+%}
+%pragma(java) modulecode=%{
+ public static final long serialVersionUID = 0x52151001; // Suppress ecj warning
+%}
+
+
+// Set default Java const code generation
+%javaconst(1);
+
+// Change the default generation so that these enums are generated into an interface instead of a class
+%typemap(javaclassmodifiers) enum stuff "public interface"
+
+%inline %{
+enum stuff { FIDDLE = 2*100, STICKS = 5+8, BONGO, DRUMS };
+%}
+
+// Check that the enum typemaps are working by using a short for the enums instead of int
+%javaconst(0); // will create compile errors in runme file if short typemaps not used
+
+namespace Space {
+%typemap(jtype) enum nonsense "short"
+%typemap(jstype) enum nonsense "short"
+%typemap(javain) enum nonsense "$javainput"
+%typemap(in) enum nonsense %{ $1 = (enum Space::nonsense)$input; %}
+%typemap(out) enum nonsense %{ $result = (jshort)$1; %}
+%typemap(jni) enum nonsense "jshort"
+%typemap(javaout) enum nonsense {
+ return $jnicall;
+ }
+}
+
+%inline %{
+namespace Space {
+enum nonsense { POPPYCOCK, JUNK };
+nonsense test1(nonsense n) { return n; }
+enum nonsense test2(enum nonsense n) { return n; }
+}
+%}
+
+// Test the %javaconstvalue directive for enums
+%{
+static const int FOUR = 4;
+%}
+
+%javaconst(1);
+%javaconstvalue(4) Quattro;
+%inline %{
+enum Numero { Quattro = FOUR };
+%}
+
+// Test boolean enums
+%inline %{
+typedef enum { PLAY = true, STOP = false } play_state;
+%}
+
diff --git a/trunk/Examples/test-suite/java_jnitypes.i b/trunk/Examples/test-suite/java_jnitypes.i
new file mode 100644
index 000000000..90970d1b2
--- /dev/null
+++ b/trunk/Examples/test-suite/java_jnitypes.i
@@ -0,0 +1,29 @@
+
+// This testcase tests the JNI types
+
+%module java_jnitypes
+
+%inline %{
+
+jboolean jnifunc_bool(jboolean in) { return in; } /* some JVM implementations won't allow overloading of the jboolean type with some of the others on the c++ level */
+jchar jnifunc(jchar in) { return in; }
+jbyte jnifunc(jbyte in) { return in; }
+jshort jnifunc(jshort in) { return in; }
+jint jnifunc(jint in) { return in; }
+jlong jnifunc(jlong in) { return in; }
+jfloat jnifunc(jfloat in) { return in; }
+jdouble jnifunc(jdouble in) { return in; }
+jstring jnifunc(jstring in) { return in; }
+jobject jnifunc(jobject in) { return in; }
+jbooleanArray jnifunc(jbooleanArray in) { return in; }
+jcharArray jnifunc(jcharArray in) { return in; }
+jbyteArray jnifunc(jbyteArray in) { return in; }
+jshortArray jnifunc(jshortArray in) { return in; }
+jintArray jnifunc(jintArray in) { return in; }
+jlongArray jnifunc(jlongArray in) { return in; }
+jfloatArray jnifunc(jfloatArray in) { return in; }
+jdoubleArray jnifunc(jdoubleArray in) { return in; }
+jobjectArray jnifunc(jobjectArray in) { return in; }
+
+%}
+
diff --git a/trunk/Examples/test-suite/java_lib_arrays.i b/trunk/Examples/test-suite/java_lib_arrays.i
new file mode 100644
index 000000000..0551cd100
--- /dev/null
+++ b/trunk/Examples/test-suite/java_lib_arrays.i
@@ -0,0 +1,56 @@
+/* Testcase for the Java array typemaps which are not used by default. */
+%module java_lib_arrays
+
+%include "enumtypeunsafe.swg"
+
+/* Use the Java library typemaps */
+%include "arrays_java.i"
+
+JAVA_ARRAYSOFCLASSES(SimpleStruct)
+%apply ARRAYSOFENUMS[ANY] { finger[ANY] }
+
+%include "arrays.i"
+
+// This will test the %typemap(javacode) in the JAVA_ARRAYSOFCLASSES works with C structs amongst other things
+JAVA_ARRAYSOFCLASSES(struct AnotherStruct)
+%inline %{
+struct AnotherStruct {
+ SimpleStruct simple;
+};
+double extract(struct AnotherStruct as[], int index) {
+ return as[index].simple.double_field;
+}
+double extract2(struct AnotherStruct as[5], int index) {
+ return as[index].simple.double_field;
+}
+%}
+
+// Test %apply to pointers
+JAVA_ARRAYSOFCLASSES(struct YetAnotherStruct)
+%apply struct YetAnotherStruct[] { struct YetAnotherStruct *yas }
+//%apply struct YetAnotherStruct[] { struct YetAnotherStruct * } // Note: Does not work unless this is put after the YetAnotherStruct definition
+%inline %{
+struct YetAnotherStruct {
+ SimpleStruct simple;
+};
+double extract_ptr(struct YetAnotherStruct *yas, int index) {
+ return yas[index].simple.double_field;
+}
+void modifyYAS(struct YetAnotherStruct yas[], int size) {
+ int i;
+ for (i=0; i<size; ++i) {
+ SimpleStruct ss;
+ ss.double_field = yas[i].simple.double_field * 10.0;
+ yas[i].simple = ss;
+ }
+}
+%}
+
+%apply ARRAYSOFENUMS[ANY] { toe[ANY] }
+%apply ARRAYSOFENUMS[] { toe[] }
+%apply ARRAYSOFENUMS[] { toe* }
+%inline %{
+typedef enum { Big, Little } toe;
+void toestest(toe *t, toe tt[], toe ttt[2]) {}
+%}
+
diff --git a/trunk/Examples/test-suite/java_lib_arrays_dimensionless.i b/trunk/Examples/test-suite/java_lib_arrays_dimensionless.i
new file mode 100644
index 000000000..ec2676fdb
--- /dev/null
+++ b/trunk/Examples/test-suite/java_lib_arrays_dimensionless.i
@@ -0,0 +1,26 @@
+%module java_lib_arrays_dimensionless
+
+%include "arrays_java.i"
+
+// Can't wrap dimensionless arrays, so we use the old pointer approach
+%apply SWIGTYPE* { int globalints[], int constglobalints[], int Bar::ints[] }
+
+// Test %apply for arrays in arrays_java.i library file
+%apply bool [] { bool *array }
+%apply char [] { char *array }
+%apply signed char [] { signed char *array }
+%apply unsigned char [] { unsigned char *array }
+%apply short [] { short *array }
+%apply unsigned short [] { unsigned short *array }
+%apply int [] { int *array }
+%apply unsigned int [] { unsigned int *array }
+%apply long [] { long *array }
+%apply unsigned long [] { unsigned long *array }
+%apply long [] { long *array }
+%apply unsigned long long [] { unsigned long long *array }
+%apply float [] { float *array }
+%apply double [] { double *array }
+
+%include "arrays_dimensionless.i"
+
+
diff --git a/trunk/Examples/test-suite/java_lib_various.i b/trunk/Examples/test-suite/java_lib_various.i
new file mode 100644
index 000000000..716ae9139
--- /dev/null
+++ b/trunk/Examples/test-suite/java_lib_various.i
@@ -0,0 +1,51 @@
+/* Java various.i library tests */
+%module java_lib_various
+
+%include "various.i"
+
+%apply char **STRING_ARRAY { char **received };
+%apply char **STRING_ARRAY { char **get_names };
+%apply char **STRING_ARRAY { char **languages };
+%apply char *BYTE { char *chars };
+%apply char **STRING_OUT { char **string_ptr };
+%typemap(freearg) char **languages "" // don't delete memory when setting global variable
+
+%{
+char *langs[] = { (char *)"Hungarian", (char *)"Afrikaans", (char *)"Norwegian", NULL };
+%}
+
+%inline %{
+char **languages = &langs[0];
+%}
+
+%inline %{
+
+int check_animals(char **received) {
+ const char *expected[] = {"Cat","Dog","Cow","Goat", 0};
+ int strings_match = 1;
+ int i=0;
+ while (expected[i]) {
+ if (strcmp(received[i], expected[i]) != 0)
+ strings_match = 0;
+ i++;
+ }
+ return strings_match;
+}
+
+char **get_names() {
+ static char *values[] = { (char *)"Dave", (char *)"Mike", (char *)"Susan", (char *)"John", (char *)"Michelle", NULL};
+ return &values[0];
+}
+
+void charout(char *chars) {
+ if(chars != NULL)
+ sprintf(chars, "by jove");
+}
+
+void char_ptr_ptr_out(char **string_ptr) {
+ static char ret[] = "returned string";
+ *string_ptr = ret;
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/java_pgcpp.i b/trunk/Examples/test-suite/java_pgcpp.i
new file mode 100644
index 000000000..6bfef9316
--- /dev/null
+++ b/trunk/Examples/test-suite/java_pgcpp.i
@@ -0,0 +1,56 @@
+// Test the premature garbage collection prevention parameter (pgcpp) for the different ways of passing objects
+
+%module java_pgcpp
+
+%pragma(java) jniclassclassmodifiers="public class"
+
+%typemap(javacode) Space::Classic %{
+ public long getCPtrValue() {
+ return this.swigCPtr;
+ }
+%}
+
+// Default pointer to pointer typemaps do not use proxy class, so make sure that the pgcpp is generated for these typemaps
+%typemap(jni) Space::Classic ** "jlong"
+%typemap(jtype) Space::Classic ** "long"
+%typemap(jstype) Space::Classic ** " Classic "
+%typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)"
+
+// Default typemaps for pass by value, ref, pointer and pointer const reference should use pgcpp
+
+%inline %{
+namespace Space {
+ struct Classic {
+ Classic() {}
+ Classic(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
+ Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5, bool b) {}
+
+ void method(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
+ void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {}
+ };
+
+ void function(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
+ void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {}
+}
+%}
+
+
+%typemap(jtype) Klassic *k1 "/*a*/ long /*b*/ /*c*/"
+%typemap(jstype) Klassic *k1 "/*a*/ Classic/*b*/ /*c*/"
+
+%typemap(jtype) Klassic *k2 "/*d*/ long"
+%typemap(jstype) Klassic *k2 "/*d*/ Classic"
+
+%typemap(jtype) Klassic *k3 "long/*e*/ "
+%typemap(jstype) Klassic *k3 "Classic/*e*/ "
+
+%typemap(javain) Klassic * "Classic.getCPtr($javainput)"
+
+%{
+typedef Space::Classic Klassic;
+%}
+
+%inline %{
+ void comment_in_typemaps(Klassic *k1, Klassic *k2, Klassic *k3) {}
+%}
+
diff --git a/trunk/Examples/test-suite/java_pragmas.i b/trunk/Examples/test-suite/java_pragmas.i
new file mode 100644
index 000000000..b1fab2700
--- /dev/null
+++ b/trunk/Examples/test-suite/java_pragmas.i
@@ -0,0 +1,50 @@
+
+// Test case uses all the Java pragmas which are for tailoring the generated JNI class and Java module class.
+
+%module java_pragmas
+
+%pragma(java) jniclassimports=%{
+import java.lang.*; // For Exception
+%}
+
+%pragma(java) jniclassclassmodifiers="public class"
+%pragma(java) jniclassbase="Exception"
+%pragma(java) jniclassinterfaces="Cloneable"
+
+%pragma(java) jniclasscode=%{
+ // jniclasscode pragma code: Static block so that the JNI class loads the C++ DLL/shared object when the class is loaded
+ static {
+ try {
+ System.loadLibrary("java_pragmas");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+ public static final long serialVersionUID = 0x52151000; // Suppress ecj warning
+%}
+
+
+%pragma(java) moduleimports=%{
+import java.io.*; // For Serializable
+%}
+
+%pragma(java) moduleclassmodifiers="public final class"
+%pragma(java) modulebase="Object"
+%pragma(java) moduleinterfaces="Serializable"
+
+%pragma(java) modulecode=%{
+ public static final long serialVersionUID = 0x52151001; // Suppress ecj warning
+ public static void added_function(String s) {
+ // Added function
+ }
+%}
+
+
+%inline %{
+int *get_int_pointer() {
+ static int number = 10;
+ return &number;
+}
+%}
+
diff --git a/trunk/Examples/test-suite/java_prepost.i b/trunk/Examples/test-suite/java_prepost.i
new file mode 100644
index 000000000..3e3839248
--- /dev/null
+++ b/trunk/Examples/test-suite/java_prepost.i
@@ -0,0 +1,91 @@
+%module java_prepost
+
+// Test the pre, post attributes for javain typemaps
+
+%include "std_vector.i"
+
+%define VECTOR_DOUBLE_JAVAIN_POST
+" int count$javainput = (int)d$javainput.size();
+ $javainput = new double[count$javainput];
+ for (int i=0; i<count$javainput; ++i) {
+ $javainput[i] = d$javainput.get(i);
+ }"
+%enddef
+
+// pre and post in javain typemaps
+//%typemap(jtype, nopgcpp=1) std::vector<double> &v "long" // could suppress pgcpp instead of using pgcppname, but not recommended
+%typemap(jstype) std::vector<double> &v "double[]"
+%typemap(javain, pre=" DoubleVector d$javainput = new DoubleVector();", post=VECTOR_DOUBLE_JAVAIN_POST, pgcppname="d$javainput") std::vector<double> &v
+ "$javaclassname.getCPtr(d$javainput)"
+
+%apply std::vector<double> & v { std::vector<double> & v2 }
+
+// pre only in javain typemap
+//%typemap(jtype, nopgcpp=1) std::vector<double> &vpre "long" // could suppress pgcpp instead of using pgcppname, but not recommended
+%typemap(jstype) std::vector<double> &vpre "double[]"
+%typemap(javain, pre=" DoubleVector d$javainput = new DoubleVector();\n for (int i=0; i<$javainput.length; ++i) {\n double d = $javainput[i];\n d$javainput.add(d);\n }", pgcppname="d$javainput") std::vector<double> &vpre
+ "$javaclassname.getCPtr(d$javainput)"
+
+// post only in javain typemap
+%typemap(javain, post=" int size = (int)$javainput.size();\n for (int i=0; i<size; ++i) {\n $javainput.set(i, $javainput.get(i)/100);\n }") std::vector<double> &vpost
+ "$javaclassname.getCPtr($javainput)"
+
+%inline %{
+bool globalfunction(std::vector<double> & v) {
+ v.push_back(0.0);
+ v.push_back(1.1);
+ v.push_back(2.2);
+ return true;
+}
+struct PrePostTest {
+ PrePostTest() {
+ }
+ PrePostTest(std::vector<double> & v) {
+ v.push_back(3.3);
+ v.push_back(4.4);
+ }
+ bool method(std::vector<double> & v) {
+ v.push_back(5.5);
+ v.push_back(6.6);
+ return true;
+ }
+ static bool staticmethod(std::vector<double> & v) {
+ v.push_back(7.7);
+ v.push_back(8.8);
+ return true;
+ }
+};
+
+// Check pre and post only typemaps and that they coexist okay and that the generated code line spacing looks okay
+bool globalfunction2(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ return true;
+}
+struct PrePost2 {
+ PrePost2() {
+ }
+ PrePost2(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ }
+ bool method(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ return true;
+ }
+ static bool staticmethod(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
+ return true;
+ }
+};
+%}
+
+%template(DoubleVector) std::vector<double>;
+
+
+// Check pre post constructor helper deals with checked exceptions, InstantiationException is just a random checked exception
+%typemap(javain, pre=" if ($javainput == null)\n throw new InstantiationException(\"empty value!!\");", throws="InstantiationException") PrePostTest *
+ "$javaclassname.getCPtr($javainput)"
+
+%inline %{
+struct PrePostThrows {
+ PrePostThrows(PrePostTest *ppt) {
+ }
+};
+%}
+
+
diff --git a/trunk/Examples/test-suite/java_throws.i b/trunk/Examples/test-suite/java_throws.i
new file mode 100644
index 000000000..48a0eeabc
--- /dev/null
+++ b/trunk/Examples/test-suite/java_throws.i
@@ -0,0 +1,187 @@
+// Test to check the exception classes in the throws attribute of the typemaps and except feature is working
+
+%module java_throws
+
+// Exceptions are chosen at random but are ones which have to have a try catch block to compile
+%typemap(in, throws=" ClassNotFoundException") int num {
+ $1 = (int)$input;
+}
+%typemap(freearg, throws="InstantiationException ") int num "/*not written*/"
+%typemap(argout, throws="CloneNotSupportedException ") int num "/*not written*/"
+%typemap(check, throws="NoSuchFieldException") int num {
+ if ($input == 10) {
+ jenv->ExceptionClear();
+ jclass excep = jenv->FindClass("java/lang/NoSuchFieldException");
+ if (excep)
+ jenv->ThrowNew(excep, "Value of 10 not acceptable");
+ return $null;
+ }
+}
+
+// Duplicate exceptions should be removed from the generated throws clause
+%typemap(out, throws="IllegalAccessException, NoSuchFieldException, CloneNotSupportedException ") short {
+ $result = (jshort)$1;
+}
+
+%inline %{
+short full_of_exceptions(int num) {
+ return 0;
+}
+%}
+
+
+%typemap(throws, throws="IllegalAccessException") int {
+ (void)$1;
+ jclass excep = jenv->FindClass("java/lang/IllegalAccessException");
+ if (excep) {
+ jenv->ThrowNew(excep, "Test exception");
+ }
+ return $null;
+}
+%inline %{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+bool throw_spec_function(int value) throw (int) { throw (int)0; }
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%catches(int) catches_function(int value);
+%inline %{
+bool catches_function(int value) { throw (int)0; }
+%}
+
+// Check newfree typemap throws attribute
+%newobject makeTestClass;
+%typemap(newfree, throws="NoSuchMethodException") TestClass* "/*not written*/"
+%inline %{
+class TestClass {
+ int x;
+public:
+ TestClass(int xx) : x(xx) {}
+};
+TestClass* makeTestClass() { return new TestClass(1000); }
+%}
+
+
+// javain typemap throws attribute
+// Will only compile if the fileFunction has a java.io.IOException throws clause as getCanonicalPath() throws this exception
+%typemap(jstype) char* someFileArgument "java.io.File"
+%typemap(javain, throws="java.io.IOException") char* someFileArgument "$javainput.getCanonicalPath()"
+
+%inline %{
+void fileFunction(char* someFileArgument) {}
+%}
+
+
+// javout typemap throws attribute
+%typemap(javaout, throws="java.io.IOException") int {
+ int returnValue=$jnicall;
+ if (returnValue==0) throw new java.io.IOException("some IOException");
+ return returnValue;
+ }
+
+%inline %{
+int ioTest() { return 0; }
+%}
+
+// except feature (%javaexception) specifying a checked exception class for the throws clause
+%typemap(javabase) MyException "Throwable";
+%typemap(javacode) MyException %{
+ public static final long serialVersionUID = 0x52151000; // Suppress ecj warning
+%}
+%inline %{
+ struct MyException {
+ MyException(const char *msg) {}
+ };
+%}
+
+%define JAVAEXCEPTION(METHOD)
+%javaexception("MyException") METHOD %{
+try {
+ $action
+} catch (MyException) {
+ jclass excep = jenv->FindClass("java_throws/MyException");
+ if (excep)
+ jenv->ThrowNew(excep, "exception message");
+ return $null;
+}
+%}
+%enddef
+
+JAVAEXCEPTION(FeatureTest::FeatureTest)
+JAVAEXCEPTION(FeatureTest::method)
+JAVAEXCEPTION(FeatureTest::staticMethod)
+
+%inline %{
+ struct FeatureTest {
+ static void staticMethod() {
+ throw MyException("no message");
+ }
+ void method() {
+ throw MyException("no message");
+ }
+ };
+%}
+
+// Mixing except feature and typemaps when both generate a class for the throws clause
+%typemap(in, throws="ClassNotFoundException") int both {
+ $1 = (int)$input;
+}
+%javaexception("MyException , NoSuchFieldException") globalFunction %{
+try {
+ $action
+} catch (MyException) {
+ jclass excep = jenv->FindClass("java_throws/MyException");
+ if (excep)
+ jenv->ThrowNew(excep, "exception message");
+ return $null;
+}
+%}
+
+%inline %{
+ void globalFunction(int both) {
+ throw MyException("no message");
+ }
+%}
+
+// Test %nojavaexception
+%javaexception("MyException") %{
+/* global exception handler */
+try {
+ $action
+} catch (MyException) {
+ jclass excep = jenv->FindClass("java_throws/MyException");
+ if (excep)
+ jenv->ThrowNew(excep, "exception message");
+ return $null;
+}
+%}
+
+%nojavaexception *::noExceptionPlease();
+%nojavaexception NoExceptTest::NoExceptTest();
+
+// Need to handle the checked exception in NoExceptTest.delete()
+%typemap(javafinalize) SWIGTYPE %{
+ protected void finalize() {
+ try {
+ delete();
+ } catch (MyException e) {
+ throw new RuntimeException(e);
+ }
+ }
+%}
+
+%inline %{
+struct NoExceptTest {
+ unsigned int noExceptionPlease() { return 123; }
+ unsigned int exceptionPlease() { return 456; }
+ ~NoExceptTest() {}
+};
+%}
+
+// Turn global exceptions off (for the implicit destructors/constructors)
+%nojavaexception;
+
diff --git a/trunk/Examples/test-suite/java_typemaps_proxy.i b/trunk/Examples/test-suite/java_typemaps_proxy.i
new file mode 100644
index 000000000..e315a36b5
--- /dev/null
+++ b/trunk/Examples/test-suite/java_typemaps_proxy.i
@@ -0,0 +1,129 @@
+/* Tests the Java specific directives */
+
+%module java_typemaps_proxy
+
+
+%typemap(javaimports) SWIGTYPE "import java.math.*;";
+%typemap(javacode) NS::Farewell %{
+ public void saybye(BigDecimal num_times) {
+ // BigDecimal requires the java.math library
+ }
+%}
+%typemap(javaclassmodifiers) NS::Farewell "public final class";
+
+%typemap(javaimports) NS::Greeting %{
+import java.util.*; // for EventListener
+import java.lang.*; // for Exception
+%};
+
+%typemap(javabase) NS::Greeting "Exception";
+%typemap(javainterfaces) NS::Greeting "EventListener";
+%typemap(javacode) NS::Greeting %{
+ public static final long serialVersionUID = 0x52151000; // Suppress ecj warning
+ // 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 and is public
+%typemap(javabody) NS::Greeting %{
+ private long swigCPtr;
+ protected boolean swigCMemOwn;
+
+ protected $javaclassname(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ public static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+// Make the pointer constructor public
+%typemap(javabody) NS::Farewell %{
+ private long swigCPtr;
+ protected boolean swigCMemOwn;
+
+ public $javaclassname(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+// get rid of the finalize method for NS::Farewell
+%typemap(javafinalize) NS::Farewell "";
+
+// Test typemaps are being found for templated classes
+%typemap(javacode) NS::Adieu<int**> %{
+ public static void adieu() {
+ }
+%}
+
+// Check the %javamethodmodifiers feature
+%javamethodmodifiers NS::Farewell::methodmodifiertest() "private";
+
+%inline %{
+namespace NS {
+ class Greeting {
+ public:
+ void hello() {}
+ static void ciao(Greeting* g) {}
+ };
+ class Farewell {
+ public:
+ void methodmodifiertest() {}
+ };
+ template<class T> class Adieu {};
+}
+%}
+
+%template(AdieuIntPtrPtr) NS::Adieu<int**>;
+
+// Check the premature garbage collection prevention parameter can be turned off
+%typemap(jtype, nopgcpp="1") Without * "long";
+%pragma(java) jniclassclassmodifiers="public class"
+
+%inline %{
+struct Without {
+ Without(Without *p) : var(0) {}
+ static void static_method(Without *p) {}
+ void member_method(Without *p) {}
+ Without *var;
+};
+Without *global_without = 0;
+void global_method_without(Without *p) {}
+struct With {
+ With(With *p) {}
+ static void static_method(With *p) {}
+ void member_method(With *p) {}
+};
+void global_method_with(With *p) {}
+%}
+
+%typemap(jtype, nopgcpp="1") const ConstWithout * "long";
+%inline %{
+class ConstWithout {
+public:
+ ConstWithout(const ConstWithout *p) : const_var(0), var_const(0) {}
+ static void static_method(const ConstWithout *p) {}
+ void member_method(const ConstWithout *p) {}
+ void const_member_method(const ConstWithout *p) const {}
+ const ConstWithout * const_var;
+ const ConstWithout * const var_const;
+private:
+ ConstWithout& operator=(const ConstWithout &);
+};
+const ConstWithout * global_constwithout = 0;
+void global_method_constwithout(const ConstWithout *p) {}
+%}
+
+
diff --git a/trunk/Examples/test-suite/java_typemaps_typewrapper.i b/trunk/Examples/test-suite/java_typemaps_typewrapper.i
new file mode 100644
index 000000000..a99ca7b65
--- /dev/null
+++ b/trunk/Examples/test-suite/java_typemaps_typewrapper.i
@@ -0,0 +1,72 @@
+/* Contrived example to test the Java specific directives on the type wrapper classes */
+
+%module java_typemaps_typewrapper
+
+
+%typemap(javaimports) SWIGTYPE * "import java.math.*;";
+%typemap(javacode) Farewell * %{
+ public static $javaclassname CreateNullPointer() {
+ return new $javaclassname();
+ }
+ public void saybye(BigDecimal num_times) {
+ // BigDecimal requires the java.math library
+ }
+%}
+%typemap(javaclassmodifiers) Farewell * "public final class";
+
+%typemap(javaimports) Greeting * %{
+import java.util.*; // for EventListener
+import java.lang.*; // for Exception
+%};
+
+%typemap(javabase) Greeting * "Exception";
+%typemap(javainterfaces) Greeting * "EventListener";
+%typemap(javacode) Greeting * %{
+ public static final long serialVersionUID = 0x52151000; // Suppress ecj warning
+ // Pure Java code generated using %typemap(javacode)
+ public static $javaclassname CreateNullPointer() {
+ return new $javaclassname();
+ }
+
+ public void sayhello() {
+ $javaclassname.cheerio(new $javaclassname());
+ }
+
+ public static void cheerio(EventListener e) {
+ }
+%}
+
+// Create a new getCPtr() function which takes Java null and is public
+// Make the pointer constructor public
+%typemap(javabody) Farewell * %{
+ private long swigCPtr;
+
+ public $javaclassname(long cPtr, boolean bFutureUse) {
+ swigCPtr = cPtr;
+ }
+
+ protected $javaclassname() {
+ swigCPtr = 0;
+ }
+
+ public static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+%{
+class Greeting {};
+class Farewell {};
+%}
+
+%inline %{
+ Greeting* solong(Farewell* f) { return NULL; }
+%}
+
+// Illegal special variable crash
+%typemap(jstype) WasCrashing "$javaclassname /*jstype $*javaclassname*/" // $*javaclassname was causing crash
+%inline %{
+struct WasCrashing {};
+void hoop(WasCrashing was) {}
+%}
+
diff --git a/trunk/Examples/test-suite/keyword_rename.i b/trunk/Examples/test-suite/keyword_rename.i
new file mode 100644
index 000000000..da9328868
--- /dev/null
+++ b/trunk/Examples/test-suite/keyword_rename.i
@@ -0,0 +1,32 @@
+/*
+ * Test reserved keyword renaming
+ */
+
+%module keyword_rename
+
+#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD
+
+%inline %{
+
+#define KW(x, y) int x (int y) { return y; }
+
+/* Python keywords */
+KW(in, except)
+KW(except, in)
+KW(pass, in)
+
+/* Perl keywords */
+KW(tie, die)
+KW(use, next)
+
+/* Java keywords */
+KW(implements, native)
+KW(synchronized, final)
+
+/* C# Keywords */
+KW(string, out)
+struct sealed {int i;};
+
+%}
+
+
diff --git a/trunk/Examples/test-suite/kind.i b/trunk/Examples/test-suite/kind.i
new file mode 100644
index 000000000..15727fdeb
--- /dev/null
+++ b/trunk/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 proxy classes.
+*/
+
+%module kind
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) uni; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test; /* Ruby, wrong class name */
+
+%inline %{
+
+class foo {};
+struct bar {};
+union uni {};
+
+struct test {
+ void foofn(class foo myfoo1, foo myfoo2, class foo* myfoo3, foo* myfoo4, class foo& myfoo5, foo& myfoo6) {}
+ void barfn(struct bar mybar1, bar mybar2, struct bar* mybar3, bar* mybar4, struct bar& mybar5, bar& mybar6) {}
+ void unifn(union uni myuni1, uni myuni2, union uni* myuni3, uni* myuni4, union myuni& myuni5, myuni& myuni6) {}
+
+ class foo myFooMember;
+ struct bar myBarMember;
+ union uni myUniMember;
+
+ class foo* mypFooMember;
+ struct bar* mypBarMember;
+ union uni* mypUniMember;
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/langobj.i b/trunk/Examples/test-suite/langobj.i
new file mode 100644
index 000000000..9afd2d465
--- /dev/null
+++ b/trunk/Examples/test-suite/langobj.i
@@ -0,0 +1,41 @@
+%module langobj
+
+
+#ifndef SWIG_Object
+#define SWIG_Object void *
+#endif
+
+
+%inline %{
+
+#ifdef SWIGTCL
+#define SWIG_Object Tcl_Obj *
+#endif
+
+#ifdef SWIGPYTHON
+#define SWIG_Object PyObject *
+#endif
+
+#ifdef SWIGRUBY
+#define SWIG_Object VALUE
+#endif
+
+#ifndef SWIG_Object
+#define SWIG_Object void *
+#endif
+
+%}
+
+
+%inline {
+
+ SWIG_Object identity(SWIG_Object x) {
+#ifdef SWIGPYTHON
+ Py_XINCREF(x);
+#endif
+ return x;
+ }
+
+}
+
+
diff --git a/trunk/Examples/test-suite/lextype.i b/trunk/Examples/test-suite/lextype.i
new file mode 100644
index 000000000..083fb589d
--- /dev/null
+++ b/trunk/Examples/test-suite/lextype.i
@@ -0,0 +1,54 @@
+/*
+This module tests whether SWIG sets the '$lextype' variable
+correctly. This variable maintains the literal base name of the
+type in the wrapper code - it's therefore usually the same
+as '$basetype', but NOT ALWAYS.
+
+In the example below, the typemap definitions are written
+for any type of 'Animal', but are parameterized through
+preprocessor definitions. So when wrapping functions which
+explicitly reference Giraffes, the wrapper code can
+behave appropriately for that particular species.
+
+For this to work correctly however, it is critical that
+there is a variable which strictly preserves the name
+of the type. '$basetype' doesn't currently do this -
+it sometimes contains 'Giraffe' and sometimes (specifically
+the case of arrays) contains 'Animal'. Since existing
+code may rely on that behaviour, we create a new variable
+'$lextype' which does what we need.
+
+There is no need for any runtime test here, since if the
+code is not functioning properly it will fail to compile.
+*/
+
+%module lextype
+%{
+#include <stdlib.h>
+%}
+
+%typemap(in) Animal ()
+{
+ void *space_needed = malloc(HEIGHT_$1_lextype * WIDTH_$1_lextype);
+ $1 = ($1_ltype)space_needed;
+}
+
+%typemap(in) Animal[2] ()
+{
+ void *space_needed = malloc(2 * HEIGHT_$1_lextype * WIDTH_$1_lextype);
+ $1 = ($1_ltype)space_needed;
+}
+
+%inline %{
+
+#define HEIGHT_Giraffe 100
+#define WIDTH_Giraffe 5
+
+typedef void * Animal;
+typedef Animal Giraffe;
+
+void eat(Giraffe g) {}
+void drink(Giraffe *g) {}
+Giraffe mate(Giraffe g[2]) { return g[0]; }
+
+%}
diff --git a/trunk/Examples/test-suite/li_attribute.i b/trunk/Examples/test-suite/li_attribute.i
new file mode 100644
index 000000000..4f9497afb
--- /dev/null
+++ b/trunk/Examples/test-suite/li_attribute.i
@@ -0,0 +1,139 @@
+%module li_attribute
+
+%include <exception.i>
+
+//#define SWIG_ATTRIBUTE_TEMPLATE
+%include <attribute.i>
+
+%{
+// forward reference needed if using SWIG_ATTRIBUTE_TEMPLATE
+struct A;
+struct MyFoo; // %attribute2 does not work with templates
+%}
+
+%attribute(A, int, a, get_a, set_a);
+%attributeref(A, int, b);
+
+%attributeref(Param<int>, int, value);
+
+
+%attribute(A, int, c, get_c); /* read-only */
+%attributeref(A, int, d, b); /* renames accessor method 'b' to attribute name 'd' */
+
+%attributeref(B, A*, a)
+
+%inline
+{
+ struct A
+ {
+ A(int a, int b, int c) : _a(a), _b(b), _c(c)
+ {
+ }
+
+ int get_a() const
+ {
+ return _a;
+ }
+
+ void set_a(int aa)
+ {
+ _a = aa;
+ }
+
+ /* only one ref method */
+ int& b()
+ {
+ return _b;
+ }
+
+ int get_c() const
+ {
+ return _c;
+ }
+ private:
+ int _a;
+ int _b;
+ int _c;
+ };
+
+ template <class C>
+ struct Param
+ {
+ Param(C v) : _v(v)
+ {
+ }
+
+ const int& value() const
+ {
+ return _v;
+ }
+
+ int& value()
+ {
+ return _v;
+ }
+ private:
+ C _v;
+ };
+
+
+ struct B {
+ B(A *a) : mA(a)
+ {
+ }
+
+ A*& a() { return mA; }
+
+ protected:
+ A* mA;
+ };
+
+}
+
+%template(Param_i) Param<int>;
+
+
+// class/struct attribute with get/set methods using return/pass by reference
+%attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo);
+%inline %{
+ struct MyFoo {
+ MyFoo() : x(-1) {}
+ int x;
+ };
+ class MyClass {
+ MyFoo foo;
+ public:
+ MyFoo& GetFoo() { return foo; }
+ void SetFoo(const MyFoo& other) { foo = other; }
+ };
+%}
+
+
+// class/struct attribute with get/set methods using return/pass by value
+%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo);
+%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo);
+%inline %{
+ class MyClassVal {
+ MyFoo foo;
+ public:
+ MyFoo GetFoo() { return foo; }
+ void SetFoo(MyFoo other) { foo = other; }
+ };
+%}
+
+
+// string attribute with get/set methods using return/pass by value
+%include <std_string.i>
+%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString);
+%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString);
+%inline %{
+ class MyStringyClass {
+ std::string str;
+ public:
+ MyStringyClass(const std::string &val) : str(val) {}
+ std::string GetString() { return str; }
+ void SetString(std::string other) { str = other; }
+ };
+%}
+
+
diff --git a/trunk/Examples/test-suite/li_boost_intrusive_ptr.i b/trunk/Examples/test-suite/li_boost_intrusive_ptr.i
new file mode 100644
index 000000000..a84af4d45
--- /dev/null
+++ b/trunk/Examples/test-suite/li_boost_intrusive_ptr.i
@@ -0,0 +1,491 @@
+// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
+// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
+// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
+// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
+//
+// Also note the debug_shared flag which can be set from the target language.
+
+%module li_boost_intrusive_ptr
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+
+%inline %{
+#include "boost/shared_ptr.hpp"
+#include "boost/intrusive_ptr.hpp"
+#include <boost/detail/atomic_count.hpp>
+
+// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
+//#define INTRUSIVE_PTR_WRAPPER
+
+#ifdef INTRUSIVE_PTR_WRAPPER
+# include "intrusive_ptr_wrapper.h"
+# include "shared_ptr_wrapper.h"
+#endif
+%}
+
+%{
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SwigBoost boost
+#endif
+%}
+
+%include "std_string.i"
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
+# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+%include <boost_intrusive_ptr.i>
+%intrusive_ptr(Space::Klass)
+%intrusive_ptr_no_wrap(Space::KlassWithoutRefCount)
+%intrusive_ptr(Space::KlassDerived)
+%intrusive_ptr(Space::KlassDerivedDerived)
+
+//For the use_count shared_ptr functions
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
+
+#endif
+
+// TODO:
+// const intrusive_ptr
+// std::vector
+// Add in generic %extend for the Upcast function for derived classes
+// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
+
+%exception {
+ if (debug_shared) {
+ cout << "++++++" << endl << flush;
+ cout << "calling $name" << endl << flush;
+ }
+ $action
+ if (debug_shared) {
+ cout << "------" << endl << flush;
+ }
+}
+
+%ignore IgnoredRefCountingBase;
+%ignore *::operator=;
+%ignore intrusive_ptr_add_ref;
+%ignore intrusive_ptr_release;
+%newobject pointerownertest();
+%newobject smartpointerpointerownertest();
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+static bool debug_shared = false;
+
+namespace Space {
+
+struct Klass {
+ Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
+
+ Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
+
+ Klass &operator=(const Klass &other) { value = other.value; return *this; }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+ mutable boost::detail::atomic_count count;
+};
+
+struct KlassWithoutRefCount {
+ KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
+
+ KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
+ std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
+ KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+};
+
+struct IgnoredRefCountingBase {
+ IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
+ return *this;
+ }
+
+ virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ double d;
+ double e;
+ mutable boost::detail::atomic_count count;
+};
+
+long getTotal_IgnoredRefCountingBase_count() {
+ return IgnoredRefCountingBase::getTotal_count();
+}
+
+// For most compilers, this use of multiple inheritance results in different derived and base class
+// pointer values ... for some more challenging tests :)
+struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
+ KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
+ KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
+ int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+struct KlassDerivedDerived : KlassDerived {
+ KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
+ KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+KlassDerived* derivedpointertest(KlassDerived* kd) {
+ if (kd)
+ kd->append(" derivedpointertest");
+ return kd;
+}
+KlassDerived derivedvaluetest(KlassDerived kd) {
+ kd.append(" derivedvaluetest");
+ return kd;
+}
+KlassDerived& derivedreftest(KlassDerived& kd) {
+ kd.append(" derivedreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::intrusive_ptr<KlassDerived> kd) {
+ if (kd)
+ kd->append(" derivedsmartptrtest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointertest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr<KlassDerived>*& kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointerreftest");
+ return kd;
+}
+
+SwigBoost::intrusive_ptr<Klass> factorycreate() {
+ return SwigBoost::intrusive_ptr<Klass>(new Klass("factorycreate"));
+}
+// smart pointer
+SwigBoost::intrusive_ptr<Klass> smartpointertest(SwigBoost::intrusive_ptr<Klass> k) {
+ if (k)
+ k->append(" smartpointertest");
+ return SwigBoost::intrusive_ptr<Klass>(k);
+}
+SwigBoost::intrusive_ptr<Klass>* smartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointertest");
+ return k;
+}
+SwigBoost::intrusive_ptr<Klass>& smartpointerreftest(SwigBoost::intrusive_ptr<Klass>& k) {
+ if (k)
+ k->append(" smartpointerreftest");
+ return k;
+}
+SwigBoost::intrusive_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::intrusive_ptr<Klass>*& k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointerreftest");
+ return k;
+}
+// const
+SwigBoost::intrusive_ptr<const Klass> constsmartpointertest(SwigBoost::intrusive_ptr<const Klass> k) {
+ return SwigBoost::intrusive_ptr<const Klass>(k);
+}
+SwigBoost::intrusive_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::intrusive_ptr<const Klass>* k) {
+ return k;
+}
+SwigBoost::intrusive_ptr<const Klass>& constsmartpointerreftest(SwigBoost::intrusive_ptr<const Klass>& k) {
+ return k;
+}
+// plain pointer
+Klass valuetest(Klass k) {
+ k.append(" valuetest");
+ return k;
+}
+Klass *pointertest(Klass *k) {
+ if (k)
+ k->append(" pointertest");
+ return k;
+}
+Klass& reftest(Klass& k) {
+ k.append(" reftest");
+ return k;
+}
+Klass *const& pointerreftest(Klass *const& k) {
+ k->append(" pointerreftest");
+ return k;
+}
+// null
+std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
+ if (k && *k)
+ return "not null";
+ else if (!k)
+ return "null smartpointer pointer";
+ else if (!*k)
+ return "null pointer";
+ else
+ return "also not null";
+}
+// $owner
+Klass *pointerownertest() {
+ return new Klass("pointerownertest");
+}
+SwigBoost::intrusive_ptr<Klass>* smartpointerpointerownertest() {
+ return new SwigBoost::intrusive_ptr<Klass>(new Klass("smartpointerpointerownertest"));
+}
+
+const SwigBoost::intrusive_ptr<Klass>& ref_1() {
+ static SwigBoost::intrusive_ptr<Klass> sptr;
+ return sptr;
+}
+
+// overloading tests
+std::string overload_rawbyval(int i) { return "int"; }
+std::string overload_rawbyval(Klass k) { return "rawbyval"; }
+
+std::string overload_rawbyref(int i) { return "int"; }
+std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
+
+std::string overload_rawbyptr(int i) { return "int"; }
+std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
+
+std::string overload_rawbyptrref(int i) { return "int"; }
+std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
+
+
+
+std::string overload_smartbyval(int i) { return "int"; }
+std::string overload_smartbyval(SwigBoost::intrusive_ptr<Klass> k) { return "smartbyval"; }
+
+std::string overload_smartbyref(int i) { return "int"; }
+std::string overload_smartbyref(SwigBoost::intrusive_ptr<Klass> &k) { return "smartbyref"; }
+
+std::string overload_smartbyptr(int i) { return "int"; }
+std::string overload_smartbyptr(SwigBoost::intrusive_ptr<Klass> *k) { return "smartbyptr"; }
+
+std::string overload_smartbyptrref(int i) { return "int"; }
+std::string overload_smartbyptrref(SwigBoost::intrusive_ptr<Klass> *&k) { return "smartbyptrref"; }
+
+} // namespace Space
+
+%}
+%{
+ boost::detail::atomic_count Space::Klass::total_count(0);
+ boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
+ boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
+ boost::detail::atomic_count Space::KlassDerived::total_count(0);
+ boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
+%}
+
+// Member variables
+
+%inline %{
+struct MemberVariables {
+ MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr<Space::Klass>()), SmartMemberReference(*(new SwigBoost::intrusive_ptr<Space::Klass>())), MemberPointer(0), MemberReference(MemberValue) {}
+ virtual ~MemberVariables() {
+ delete SmartMemberPointer;
+ delete &SmartMemberReference;
+ }
+ SwigBoost::intrusive_ptr<Space::Klass> SmartMemberValue;
+ SwigBoost::intrusive_ptr<Space::Klass> * SmartMemberPointer;
+ SwigBoost::intrusive_ptr<Space::Klass> & SmartMemberReference;
+ Space::Klass MemberValue;
+ Space::Klass * MemberPointer;
+ Space::Klass & MemberReference;
+};
+
+// Global variables
+SwigBoost::intrusive_ptr<Space::Klass> GlobalSmartValue;
+Space::Klass GlobalValue;
+Space::Klass * GlobalPointer = 0;
+Space::Klass & GlobalReference = GlobalValue;
+
+%}
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+// Note: %template after the intrusive_ptr typemaps
+%intrusive_ptr(Base<int, double>)
+%intrusive_ptr(Pair<int, double>)
+
+#endif
+
+// Templates
+%inline %{
+template <class T1, class T2> struct Base {
+ Space::Klass klassBase;
+ T1 baseVal1;
+ T2 baseVal2;
+ Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
+ virtual std::string getValue() const { return "Base<>"; };
+ mutable int count;
+ void addref(void) const { count++; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+};
+%}
+
+%template(BaseIntDouble) Base<int, double>;
+
+%inline %{
+template <class T1, class T2> struct Pair : Base<T1, T2> {
+ Space::Klass klassPair;
+ T1 val1;
+ T2 val2;
+ Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
+ virtual std::string getValue() const { return "Pair<>"; };
+};
+
+Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
+SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
+
+template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
+
+template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
+
+long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Space::KlassDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Space::KlassDerivedDerived>& sptr) {
+ return sptr.use_count();
+}
+%}
+
+%template(PairIntDouble) Pair<int, double>;
+
+// For counting the instances of intrusive_ptr (all of which are created on the heap)
+// intrusive_ptr_wrapper_count() gives overall count
+%inline %{
+namespace SwigBoost {
+ const int NOT_COUNTING = -123456;
+ int intrusive_ptr_wrapper_count() {
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ return SwigBoost::IntrusivePtrWrapper::getTotalCount();
+ #else
+ return NOT_COUNTING;
+ #endif
+ }
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ template<> std::string show_message(boost::intrusive_ptr<Space::Klass >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<const Space::Klass >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<Space::KlassDerived >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<const Space::KlassDerived >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ #endif
+}
+%}
+
diff --git a/trunk/Examples/test-suite/li_boost_shared_ptr.i b/trunk/Examples/test-suite/li_boost_shared_ptr.i
new file mode 100644
index 000000000..f92df23a9
--- /dev/null
+++ b/trunk/Examples/test-suite/li_boost_shared_ptr.i
@@ -0,0 +1,409 @@
+// This tests shared_ptr is working okay. It also checks that there are no memory leaks in the
+// class that shared_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
+// In order to test that there are no leaks of the shared_ptr class itself (as it is created on the heap)
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// like 'top'. There is a wrapper for shared_ptr in shared_ptr_wrapper.h which enables one to
+// count the instances of shared_ptr. Uncomment the SHARED_PTR_WRAPPER macro to turn this on.
+//
+// Also note the debug_shared flag which can be set from the target language.
+
+%module li_boost_shared_ptr
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+
+%inline %{
+#include "boost/shared_ptr.hpp"
+#include "swig_examples_lock.h"
+
+// Uncomment macro below to turn on shared_ptr memory leak checking as described above
+//#define SHARED_PTR_WRAPPER
+
+#ifdef SHARED_PTR_WRAPPER
+# include "shared_ptr_wrapper.h"
+#endif
+%}
+
+%{
+#ifndef SHARED_PTR_WRAPPER
+# define SwigBoost boost
+#endif
+%}
+
+%include "std_string.i"
+#ifndef SHARED_PTR_WRAPPER
+# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#define SHARED_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+%include <boost_shared_ptr.i>
+%shared_ptr(Space::Klass)
+%shared_ptr(Space::KlassDerived)
+%shared_ptr(Space::Klass2ndDerived)
+%shared_ptr(Space::Klass3rdDerived)
+
+#endif
+
+// TODO:
+// const shared_ptr
+// std::vector
+// Add in generic %extend for the Upcast function for derived classes
+// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
+
+%exception {
+ if (debug_shared) {
+ cout << "++++++" << endl;
+ cout << "calling $name" << endl;
+ }
+ $action
+ if (debug_shared) {
+ cout << "------" << endl;
+ }
+}
+
+%ignore IgnoredMultipleInheritBase;
+%ignore Space::Klass::operator=;
+%newobject pointerownertest();
+%newobject smartpointerpointerownertest();
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+static bool debug_shared = false;
+
+namespace Space {
+
+struct Klass {
+ Klass() : value("EMPTY") { if (debug_shared) cout << "Klass() [" << value << "]" << endl; increment(); }
+
+ Klass(const std::string &val) : value(val) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl; increment(); }
+
+ virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ Klass(const Klass &other) : value(other.value) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl; increment(); }
+
+ Klass &operator=(const Klass &other) { value = other.value; return *this; }
+ static int getTotal_count() { return total_count; }
+
+private:
+ // lock increment and decrement as a destructor could be called at the same time as a
+ // new object is being created - C# / Java, at least, have finalizers run in a separate thread
+ static SwigExamples::CriticalSection critical_section;
+ static void increment() { SwigExamples::Lock lock(critical_section); total_count++; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
+ static void decrement() { SwigExamples::Lock lock(critical_section); total_count--; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
+ static int total_count;
+ std::string value;
+ int array[1024];
+};
+SwigExamples::CriticalSection Space::Klass::critical_section;
+
+struct IgnoredMultipleInheritBase {
+ IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
+ virtual ~IgnoredMultipleInheritBase() {}
+ double d;
+ double e;
+ virtual void AVirtualMethod() {}
+};
+
+// For most compilers, this use of multiple inheritance results in different derived and base class
+// pointer values ... for some more challenging tests :)
+struct KlassDerived : IgnoredMultipleInheritBase, Klass {
+ KlassDerived() : Klass() {}
+ KlassDerived(const std::string &val) : Klass(val) {}
+ KlassDerived(const KlassDerived &other) : Klass(other) {}
+ virtual ~KlassDerived() {}
+ virtual std::string getValue() const { return Klass::getValue() + "-Derived"; }
+};
+KlassDerived* derivedpointertest(KlassDerived* kd) {
+ if (kd)
+ kd->append(" derivedpointertest");
+ return kd;
+}
+KlassDerived& derivedreftest(KlassDerived& kd) {
+ kd.append(" derivedreftest");
+ return kd;
+}
+SwigBoost::shared_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::shared_ptr<KlassDerived> kd) {
+ if (kd)
+ kd->append(" derivedsmartptrtest");
+ return kd;
+}
+SwigBoost::shared_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::shared_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointertest");
+ return kd;
+}
+SwigBoost::shared_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::shared_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrreftest");
+ return kd;
+}
+SwigBoost::shared_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::shared_ptr<KlassDerived>*& kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointerreftest");
+ return kd;
+}
+
+// 3 classes in inheritance chain test
+struct Klass2ndDerived : Klass {
+ Klass2ndDerived() : Klass() {}
+ Klass2ndDerived(const std::string &val) : Klass(val) {}
+};
+struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived {
+ Klass3rdDerived() : Klass2ndDerived() {}
+ Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {}
+ virtual ~Klass3rdDerived() {}
+ virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; }
+};
+
+std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) {
+ return k->getValue();
+}
+
+
+
+SwigBoost::shared_ptr<Klass> factorycreate() {
+ return SwigBoost::shared_ptr<Klass>(new Klass("factorycreate"));
+}
+// smart pointer
+SwigBoost::shared_ptr<Klass> smartpointertest(SwigBoost::shared_ptr<Klass> k) {
+ if (k)
+ k->append(" smartpointertest");
+ return SwigBoost::shared_ptr<Klass>(k);
+}
+SwigBoost::shared_ptr<Klass>* smartpointerpointertest(SwigBoost::shared_ptr<Klass>* k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointertest");
+ return k;
+}
+SwigBoost::shared_ptr<Klass>& smartpointerreftest(SwigBoost::shared_ptr<Klass>& k) {
+ if (k)
+ k->append(" smartpointerreftest");
+ return k;
+}
+SwigBoost::shared_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::shared_ptr<Klass>*& k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointerreftest");
+ return k;
+}
+// const
+SwigBoost::shared_ptr<const Klass> constsmartpointertest(SwigBoost::shared_ptr<const Klass> k) {
+ return SwigBoost::shared_ptr<const Klass>(k);
+}
+SwigBoost::shared_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::shared_ptr<const Klass>* k) {
+ return k;
+}
+SwigBoost::shared_ptr<const Klass>& constsmartpointerreftest(SwigBoost::shared_ptr<const Klass>& k) {
+ return k;
+}
+// plain pointer
+Klass valuetest(Klass k) {
+ k.append(" valuetest");
+ return k;
+}
+Klass *pointertest(Klass *k) {
+ if (k)
+ k->append(" pointertest");
+ return k;
+}
+Klass& reftest(Klass& k) {
+ k.append(" reftest");
+ return k;
+}
+Klass *const& pointerreftest(Klass *const& k) {
+ k->append(" pointerreftest");
+ return k;
+}
+// null
+std::string nullsmartpointerpointertest(SwigBoost::shared_ptr<Klass>* k) {
+ if (k && *k)
+ return "not null";
+ else if (!k)
+ return "null smartpointer pointer";
+ else if (!*k)
+ return "null pointer";
+ else
+ return "also not null";
+}
+// $owner
+Klass *pointerownertest() {
+ return new Klass("pointerownertest");
+}
+SwigBoost::shared_ptr<Klass>* smartpointerpointerownertest() {
+ return new SwigBoost::shared_ptr<Klass>(new Klass("smartpointerpointerownertest"));
+}
+
+// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in
+// the marshalling if an upcast to a base class is required.
+long use_count(const SwigBoost::shared_ptr<Klass3rdDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Klass2ndDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Klass>& sptr) {
+ return sptr.use_count();
+}
+const SwigBoost::shared_ptr<Klass>& ref_1() {
+ static SwigBoost::shared_ptr<Klass> sptr;
+ return sptr;
+}
+
+// overloading tests
+std::string overload_rawbyval(int i) { return "int"; }
+std::string overload_rawbyval(Klass k) { return "rawbyval"; }
+
+std::string overload_rawbyref(int i) { return "int"; }
+std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
+
+std::string overload_rawbyptr(int i) { return "int"; }
+std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
+
+std::string overload_rawbyptrref(int i) { return "int"; }
+std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
+
+
+
+std::string overload_smartbyval(int i) { return "int"; }
+std::string overload_smartbyval(SwigBoost::shared_ptr<Klass> k) { return "smartbyval"; }
+
+std::string overload_smartbyref(int i) { return "int"; }
+std::string overload_smartbyref(SwigBoost::shared_ptr<Klass> &k) { return "smartbyref"; }
+
+std::string overload_smartbyptr(int i) { return "int"; }
+std::string overload_smartbyptr(SwigBoost::shared_ptr<Klass> *k) { return "smartbyptr"; }
+
+std::string overload_smartbyptrref(int i) { return "int"; }
+std::string overload_smartbyptrref(SwigBoost::shared_ptr<Klass> *&k) { return "smartbyptrref"; }
+
+} // namespace Space
+
+%}
+%{
+ int Space::Klass::total_count = 0;
+%}
+
+
+// Member variables
+
+%inline %{
+struct MemberVariables {
+ MemberVariables() : SmartMemberPointer(&SmartMemberValue), SmartMemberReference(SmartMemberValue), MemberPointer(0), MemberReference(MemberValue) {}
+ SwigBoost::shared_ptr<Space::Klass> SmartMemberValue;
+ SwigBoost::shared_ptr<Space::Klass> * SmartMemberPointer;
+ SwigBoost::shared_ptr<Space::Klass> & SmartMemberReference;
+ Space::Klass MemberValue;
+ Space::Klass * MemberPointer;
+ Space::Klass & MemberReference;
+};
+
+// Global variables
+SwigBoost::shared_ptr<Space::Klass> GlobalSmartValue;
+Space::Klass GlobalValue;
+Space::Klass * GlobalPointer = 0;
+Space::Klass & GlobalReference = GlobalValue;
+
+%}
+
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+// Note: %template after the shared_ptr typemaps
+%shared_ptr(Base<int, double>)
+%shared_ptr(Pair<int, double>)
+
+#endif
+
+// Templates
+%inline %{
+template <class T1, class T2> struct Base {
+ Space::Klass klassBase;
+ T1 baseVal1;
+ T2 baseVal2;
+ Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
+ virtual std::string getValue() const { return "Base<>"; };
+};
+%}
+
+%template(BaseIntDouble) Base<int, double>;
+
+%inline %{
+template <class T1, class T2> struct Pair : Base<T1, T2> {
+ Space::Klass klassPair;
+ T1 val1;
+ T2 val2;
+ Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
+ virtual std::string getValue() const { return "Pair<>"; };
+};
+Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
+SwigBoost::shared_ptr< Pair<int, double> > pair_id1(SwigBoost::shared_ptr< Pair<int, double> > p) { return p; }
+%}
+
+%template(PairIntDouble) Pair<int, double>;
+
+
+// For counting the instances of shared_ptr (all of which are created on the heap)
+// shared_ptr_wrapper_count() gives overall count
+%inline %{
+namespace SwigBoost {
+ const int NOT_COUNTING = -123456;
+ int shared_ptr_wrapper_count() {
+ #ifdef SHARED_PTR_WRAPPER
+ return SwigBoost::SharedPtrWrapper::getTotalCount();
+ #else
+ return NOT_COUNTING;
+ #endif
+ }
+ #ifdef SHARED_PTR_WRAPPER
+ template<> std::string show_message(boost::shared_ptr<Space::Klass >*t) {
+ if (!t)
+ return "null shared_ptr!!!";
+ if (boost::get_deleter<SWIG_null_deleter>(*t))
+ return "Klass NULL DELETER"; // pointer may be dangling so cannot use it
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::shared_ptr<const Space::Klass >*t) {
+ if (!t)
+ return "null shared_ptr!!!";
+ if (boost::get_deleter<SWIG_null_deleter>(*t))
+ return "Klass NULL DELETER"; // pointer may be dangling so cannot use it
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::shared_ptr<Space::KlassDerived >*t) {
+ if (!t)
+ return "null shared_ptr!!!";
+ if (boost::get_deleter<SWIG_null_deleter>(*t))
+ return "KlassDerived NULL DELETER"; // pointer may be dangling so cannot use it
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ template<> std::string show_message(boost::shared_ptr<const Space::KlassDerived >*t) {
+ if (!t)
+ return "null shared_ptr!!!";
+ if (boost::get_deleter<SWIG_null_deleter>(*t))
+ return "KlassDerived NULL DELETER"; // pointer may be dangling so cannot use it
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ #endif
+}
+%}
+
diff --git a/trunk/Examples/test-suite/li_boost_shared_ptr_bits.i b/trunk/Examples/test-suite/li_boost_shared_ptr_bits.i
new file mode 100644
index 000000000..b43e1b137
--- /dev/null
+++ b/trunk/Examples/test-suite/li_boost_shared_ptr_bits.i
@@ -0,0 +1,50 @@
+%module li_boost_shared_ptr_bits
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#define SHARED_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+%include <boost_shared_ptr.i>
+%shared_ptr(NonDynamic)
+
+#endif
+
+#if defined(SWIGPYTHON)
+%pythonnondynamic NonDynamic;
+#endif
+
+%inline %{
+#include <boost/shared_ptr.hpp>
+struct NonDynamic {
+ int i;
+};
+boost::shared_ptr<NonDynamic> boing(boost::shared_ptr<NonDynamic> b) { return b; }
+%}
+
+// vector of shared_ptr
+%include "std_vector.i"
+
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+%shared_ptr(IntHolder);
+
+#endif
+
+%inline %{
+#include "boost/shared_ptr.hpp"
+struct IntHolder {
+ int val;
+ IntHolder(int a) : val(a) {}
+};
+int sum(std::vector< boost::shared_ptr<IntHolder> > v) {
+ int sum = 0;
+ for (size_t i=0; i<v.size(); ++i)
+ sum += v[i]->val;
+ return sum;
+}
+%}
+
+%template(VectorIntHolder) std::vector< boost::shared_ptr<IntHolder> >;
+
diff --git a/trunk/Examples/test-suite/li_carrays.i b/trunk/Examples/test-suite/li_carrays.i
new file mode 100644
index 000000000..45c6537d5
--- /dev/null
+++ b/trunk/Examples/test-suite/li_carrays.i
@@ -0,0 +1,28 @@
+%module li_carrays
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) doubleArray; /* Ruby, wrong class name */
+
+%include <carrays.i>
+
+%array_functions(int,intArray);
+%array_class(double, doubleArray);
+
+%inline %{
+typedef struct {
+ int x;
+ int y;
+} XY;
+XY globalXYArray[3];
+
+typedef struct {
+ int a;
+ int b;
+} AB;
+
+AB globalABArray[3];
+%}
+
+// Note that struct XY { ... }; gives compiler error for C when using %array_class or %array_functions, but is okay in C++
+%array_class(XY, XYArray)
+%array_functions(AB, ABArray)
+
diff --git a/trunk/Examples/test-suite/li_cdata.i b/trunk/Examples/test-suite/li_cdata.i
new file mode 100644
index 000000000..2180af96e
--- /dev/null
+++ b/trunk/Examples/test-suite/li_cdata.i
@@ -0,0 +1,8 @@
+%module li_cdata
+
+%include <cdata.i>
+
+%cdata(int);
+%cdata(double);
+
+void *malloc(size_t size);
diff --git a/trunk/Examples/test-suite/li_cdata_carrays.i b/trunk/Examples/test-suite/li_cdata_carrays.i
new file mode 100644
index 000000000..7b000c1d1
--- /dev/null
+++ b/trunk/Examples/test-suite/li_cdata_carrays.i
@@ -0,0 +1,8 @@
+%module li_cdata_carrays
+
+%include <carrays.i>
+%array_class(int, intArray);
+
+%include <cdata.i>
+
+%cdata(int);
diff --git a/trunk/Examples/test-suite/li_cmalloc.i b/trunk/Examples/test-suite/li_cmalloc.i
new file mode 100644
index 000000000..364351d5a
--- /dev/null
+++ b/trunk/Examples/test-suite/li_cmalloc.i
@@ -0,0 +1,12 @@
+%module li_cmalloc
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) sizeof_int; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) sizeof_double; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) sizeof_intp; /* Ruby, wrong constant name */
+
+%include <cmalloc.i>
+
+%allocators(int);
+%allocators(double);
+%allocators(void);
+%allocators(int *, intp);
diff --git a/trunk/Examples/test-suite/li_constraints.i b/trunk/Examples/test-suite/li_constraints.i
new file mode 100644
index 000000000..1bbecf180
--- /dev/null
+++ b/trunk/Examples/test-suite/li_constraints.i
@@ -0,0 +1,35 @@
+%module li_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) {
+}
+
+/* These generated non-portable code and there isn't an obvious fix
+
+void test_align8(void *ALIGN8) {
+}
+
+void test_align4(void *ALIGN4) {
+}
+
+void test_align2(void *ALIGN2) {
+}
+*/
+%}
+
diff --git a/trunk/Examples/test-suite/li_cpointer.i b/trunk/Examples/test-suite/li_cpointer.i
new file mode 100644
index 000000000..c5584ce5a
--- /dev/null
+++ b/trunk/Examples/test-suite/li_cpointer.i
@@ -0,0 +1,10 @@
+%module li_cpointer
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) doublep; /* Ruby, wrong class name */
+
+%include "cpointer.i"
+
+%pointer_functions(int,intp);
+%pointer_class(double,doublep);
+%pointer_cast(int, unsigned int, int_to_uint);
+
diff --git a/trunk/Examples/test-suite/li_cstring.i b/trunk/Examples/test-suite/li_cstring.i
new file mode 100644
index 000000000..28e8049e8
--- /dev/null
+++ b/trunk/Examples/test-suite/li_cstring.i
@@ -0,0 +1,98 @@
+%module li_cstring
+
+%include "cstring.i"
+
+#ifndef SWIG_CSTRING_UNIMPL
+
+%cstring_input_binary(char *str_in, int n);
+%cstring_bounded_output(char *out1, 512);
+%cstring_chunk_output(char *out2, 64);
+%cstring_bounded_mutable(char *out3, 512);
+%cstring_mutable(char *out4, 32);
+%cstring_output_maxsize(char *out5, int max);
+%cstring_output_withsize(char *out6, int *size);
+
+#ifdef __cplusplus
+%cstring_output_allocate(char **out7, delete [] *$1);
+%cstring_output_allocate_size(char **out8, int *size, delete [] *$1);
+#else
+%cstring_output_allocate(char **out7, free(*$1));
+%cstring_output_allocate_size(char **out8, int *size, free(*$1));
+#endif
+
+%inline %{
+
+int count(char *str_in, int n, char c) {
+ int r = 0;
+ while (n > 0) {
+ if (*str_in == c) {
+ r++;
+ }
+ str_in++;
+ --n;
+ }
+ return r;
+}
+
+void test1(char *out1) {
+ strcpy(out1,"Hello World");
+}
+
+void test2(char *out2) {
+ int i;
+ for (i = 0; i < 64; i++) {
+ *out2 = (char) i + 32;
+ out2++;
+ }
+}
+
+void test3(char *out3) {
+ strcat(out3,"-suffix");
+}
+
+void test4(char *out4) {
+ strcat(out4,"-suffix");
+}
+
+void test5(char *out5, int max) {
+ int i;
+ for (i = 0; i < max; i++) {
+ out5[i] = 'x';
+ }
+ out5[max]='\0';
+}
+
+void test6(char *out6, int *size) {
+ int i;
+ for (i = 0; i < (*size/2); i++) {
+ out6[i] = 'x';
+ }
+ *size = (*size/2);
+}
+
+void test7(char **out7) {
+#ifdef __cplusplus
+ *out7 = new char[64];
+#else
+ *out7 = malloc(64);
+#endif
+ (*out7)[0] = 0;
+ strcat(*out7,"Hello world!");
+}
+
+void test8(char **out8, int *size) {
+ int i;
+#ifdef __cplusplus
+ *out8 = new char[64];
+#else
+ *out8 = malloc(64);
+#endif
+ for (i = 0; i < 64; i++) {
+ (*out8)[i] = (char) i+32;
+ }
+ *size = 64;
+}
+
+%}
+
+#endif
diff --git a/trunk/Examples/test-suite/li_cwstring.i b/trunk/Examples/test-suite/li_cwstring.i
new file mode 100644
index 000000000..769dcce12
--- /dev/null
+++ b/trunk/Examples/test-suite/li_cwstring.i
@@ -0,0 +1,98 @@
+%module li_cwstring
+
+%include "cwstring.i"
+
+#ifndef SWIG_CWSTRING_UNIMPL
+
+%cwstring_input_binary(wchar_t *str_in, int n);
+%cwstring_bounded_output(wchar_t *out1, 512);
+%cwstring_chunk_output(wchar_t *out2, 64);
+%cwstring_bounded_mutable(wchar_t *out3, 512);
+%cwstring_mutable(wchar_t *out4, 32);
+%cwstring_output_maxsize(wchar_t *out5, int max);
+%cwstring_output_withsize(wchar_t *out6, int *size);
+
+#ifdef __cplusplus
+%cwstring_output_allocate(wchar_t **out7, delete [] *$1);
+%cwstring_output_allocate_size(wchar_t **out8, int *size, delete [] *$1);
+#else
+%cwstring_output_allocate(wchar_t **out7, free(*$1));
+%cwstring_output_allocate_size(wchar_t **out8, int *size, free(*$1));
+#endif
+
+%inline %{
+
+int count(wchar_t *str_in, int n, wchar_t c) {
+ int r = 0;
+ while (n > 0) {
+ if (*str_in == c) {
+ r++;
+ }
+ str_in++;
+ --n;
+ }
+ return r;
+}
+
+void test1(wchar_t *out1) {
+ wcscpy(out1,L"Hello World");
+}
+
+void test2(wchar_t *out2) {
+ int i;
+ for (i = 0; i < 64; i++) {
+ *out2 = (wchar_t) i + 32;
+ out2++;
+ }
+}
+
+void test3(wchar_t *out3) {
+ wcscat(out3,L"-suffix");
+}
+
+void test4(wchar_t *out4) {
+ wcscat(out4,L"-suffix");
+}
+
+void test5(wchar_t *out5, int max) {
+ int i;
+ for (i = 0; i < max; i++) {
+ out5[i] = 'x';
+ }
+ out5[max]='\0';
+}
+
+void test6(wchar_t *out6, int *size) {
+ int i;
+ for (i = 0; i < (*size/2); i++) {
+ out6[i] = 'x';
+ }
+ *size = (*size/2);
+}
+
+void test7(wchar_t **out7) {
+#ifdef __cplusplus
+ *out7 = new wchar_t[64];
+#else
+ *out7 = malloc(64*sizeof(wchar_t));
+#endif
+ (*out7)[0] = 0;
+ wcscat(*out7,L"Hello world!");
+}
+
+void test8(wchar_t **out8, int *size) {
+ int i;
+#ifdef __cplusplus
+ *out8 = new wchar_t[64];
+#else
+ *out8 = malloc(64*sizeof(wchar_t));
+#endif
+ for (i = 0; i < 64; i++) {
+ (*out8)[i] = (wchar_t) i + 32;
+ }
+ *size = 64;
+}
+
+%}
+
+#endif
diff --git a/trunk/Examples/test-suite/li_factory.i b/trunk/Examples/test-suite/li_factory.i
new file mode 100644
index 000000000..7c59d53b2
--- /dev/null
+++ b/trunk/Examples/test-suite/li_factory.i
@@ -0,0 +1,49 @@
+%module li_factory
+%include factory.i
+
+%newobject Geometry::create;
+
+%newobject Geometry::clone;
+%factory(Geometry *Geometry::create, Point, Circle);
+%factory(Geometry *Geometry::clone, Point, Circle);
+#ifdef SWIGPHP
+%rename(clone_) clone;
+#endif
+%factory(Geometry *Point::clone, Point, Circle);
+%factory(Geometry *Circle::clone, Point, Circle);
+
+%inline {
+ struct Geometry {
+ enum GeomType{
+ POINT,
+ CIRCLE
+ };
+
+ virtual ~Geometry() {}
+ virtual int draw() = 0;
+ static Geometry *create(GeomType i);
+ virtual Geometry *clone() = 0;
+ };
+
+ struct Point : Geometry {
+ int draw() { return 1; }
+ double width() { return 1.0; }
+ Geometry *clone() { return new Point(); }
+ };
+
+ struct Circle : Geometry {
+ int draw() { return 2; }
+ double radius() { return 1.5; }
+ Geometry *clone() { return new Circle(); }
+ };
+
+ Geometry *Geometry::create(GeomType type) {
+ switch (type) {
+ case POINT: return new Point();
+ case CIRCLE: return new Circle();
+ default: return 0;
+ }
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/li_implicit.i b/trunk/Examples/test-suite/li_implicit.i
new file mode 100644
index 000000000..0ce10dd6e
--- /dev/null
+++ b/trunk/Examples/test-suite/li_implicit.i
@@ -0,0 +1,23 @@
+%module("nocastmode") li_implicit
+#pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING
+%include implicit.i
+
+%inline
+{
+ struct B { };
+}
+
+%implicit(A, int, double, B);
+
+%inline
+{
+ struct A
+ {
+ int ii;
+ A(int i) { ii = 1; }
+ A(double d) { ii = 2; }
+ A(const B& b) { ii = 3; }
+ };
+
+ int get(const A& a) { return a.ii; }
+}
diff --git a/trunk/Examples/test-suite/li_math.i b/trunk/Examples/test-suite/li_math.i
new file mode 100644
index 000000000..3aa3db303
--- /dev/null
+++ b/trunk/Examples/test-suite/li_math.i
@@ -0,0 +1,7 @@
+%module li_math
+#ifdef SWIGPHP
+// PHP already provides these functions with the same names, so just kill that
+// warning.
+%warnfilter(SWIGWARN_PARSE_KEYWORD);
+#endif
+%include math.i
diff --git a/trunk/Examples/test-suite/li_reference.i b/trunk/Examples/test-suite/li_reference.i
new file mode 100644
index 000000000..f16fdbeaa
--- /dev/null
+++ b/trunk/Examples/test-suite/li_reference.i
@@ -0,0 +1,52 @@
+%module li_reference
+
+%include "reference.i"
+
+%inline %{
+ double FrVal;
+ double ToVal;
+ void PDouble(double *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RDouble(double &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PFloat(float *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (float)(FrVal + t); }
+ void RFloat(float &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (float)(FrVal + t); }
+ void PInt(int *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (int)(FrVal + t); }
+ void RInt(int &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (int)(FrVal + t); }
+ void PShort(short *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (short)(FrVal + t); }
+ void RShort(short &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (short)(FrVal + t); }
+ void PLong(long *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (long)(FrVal + t); }
+ void RLong(long &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (long)(FrVal + t); }
+ void PUInt(unsigned int *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (unsigned int)(FrVal + t); }
+ void RUInt(unsigned int &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (unsigned int)(FrVal + t); }
+ void PUShort(unsigned short *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (unsigned short)(FrVal + t); }
+ void RUShort(unsigned short &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (unsigned short)(FrVal + t); }
+ void PULong(unsigned long *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (unsigned long)(FrVal + t); }
+ void RULong(unsigned long &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (unsigned long)(FrVal + t); }
+ void PUChar(unsigned char *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (unsigned char)(FrVal + t); }
+ void RUChar(unsigned char &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (unsigned char)(FrVal + t); }
+ void PChar(signed char *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (signed char)(FrVal + t); }
+ void RChar(signed char &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (signed char)(FrVal + t); }
+ void PBool(bool *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = (FrVal + t) ? true : false; }
+ void RBool(bool &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = (FrVal + t) ? true : false; }
+%}
diff --git a/trunk/Examples/test-suite/li_std_carray.i b/trunk/Examples/test-suite/li_std_carray.i
new file mode 100644
index 000000000..b38e0e441
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_carray.i
@@ -0,0 +1,8 @@
+%module li_std_carray
+
+%include <std_carray.i>
+
+%template(Vector3) std::carray<double, 3>;
+
+%template(Matrix3) std::carray<std::carray<double, 3>, 3>;
+
diff --git a/trunk/Examples/test-suite/li_std_combinations.i b/trunk/Examples/test-suite/li_std_combinations.i
new file mode 100644
index 000000000..9acc8f23d
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_combinations.i
@@ -0,0 +1,23 @@
+%module li_std_combinations
+
+%include <std_vector.i>
+%include <std_string.i>
+%include <std_pair.i>
+
+%template(VectorInt) std::vector<int>;
+%template(VectorString) std::vector<std::string>;
+%template(PairIntString) std::pair<int, std::string>;
+
+%template(VectorPairIntString) std::vector< std::pair<int, std::string> >;
+%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
+
+%template(VectorVectorString) std::vector< std::vector<std::string> >;
+%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;
+
+#if defined(SWIGCSHARP)
+// Checks macro containing a type with a comma
+SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
+#endif
+%template(PairDoubleString) std::pair< double, std::string >;
+%template(VectorPairDoubleString) std::vector< std::pair<double, std::string> >;
+
diff --git a/trunk/Examples/test-suite/li_std_deque.i b/trunk/Examples/test-suite/li_std_deque.i
new file mode 100644
index 000000000..152bc86c1
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_deque.i
@@ -0,0 +1,47 @@
+%module li_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/trunk/Examples/test-suite/li_std_except.i b/trunk/Examples/test-suite/li_std_except.i
new file mode 100644
index 000000000..fc886dca7
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_except.i
@@ -0,0 +1,39 @@
+%module li_std_except
+
+%include <std_except.i>
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+
+%inline %{
+ struct E1 : public std::exception
+ {
+ };
+
+ struct E2
+ {
+ };
+
+ struct Test {
+ int foo1() throw(std::bad_exception) { return 0; }
+ int foo2() throw(std::logic_error) { return 0; }
+ int foo3() throw(E1) { return 0; }
+ int foo4() throw(E2) { return 0; }
+ // all the STL exceptions...
+ void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
+ void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
+ void throw_exception() throw(std::exception) { throw std::exception(); }
+ void throw_invalid_argument() throw(std::invalid_argument) { throw std::invalid_argument("oops"); }
+ void throw_length_error() throw(std::length_error) { throw std::length_error("oops"); }
+ void throw_logic_error() throw(std::logic_error) { throw std::logic_error("oops"); }
+ void throw_out_of_range() throw(std::out_of_range) { throw std::out_of_range("oops"); }
+ void throw_overflow_error() throw(std::overflow_error) { throw std::overflow_error("oops"); }
+ void throw_range_error() throw(std::range_error) { throw std::range_error("oops"); }
+ void throw_runtime_error() throw(std::runtime_error) { throw std::runtime_error("oops"); }
+ void throw_underflow_error() throw(std::underflow_error) { throw std::underflow_error("oops"); }
+ };
+%}
diff --git a/trunk/Examples/test-suite/li_std_functors.i b/trunk/Examples/test-suite/li_std_functors.i
new file mode 100644
index 000000000..067bb1002
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_functors.i
@@ -0,0 +1,18 @@
+%module li_std_functors
+
+%include <std_vector.i>
+%include <std_deque.i>
+%include <std_list.i>
+%include <std_set.i>
+%include <std_map.i>
+%include <std_functors.i>
+
+%template(Vector ) std::vector <swig::LANGUAGE_OBJ>;
+%template(Deque ) std::deque <swig::LANGUAGE_OBJ>;
+%template(List ) std::list <swig::LANGUAGE_OBJ>;
+
+%template(Set ) std::set <swig::LANGUAGE_OBJ,
+ swig::BinaryPredicate<> >;
+%template(Map ) std::map <swig::LANGUAGE_OBJ,swig::LANGUAGE_OBJ,
+ swig::BinaryPredicate<> >;
+
diff --git a/trunk/Examples/test-suite/li_std_list.i b/trunk/Examples/test-suite/li_std_list.i
new file mode 100644
index 000000000..bae475eea
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_list.i
@@ -0,0 +1,46 @@
+%module li_std_list
+
+%include "std_list.i"
+
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+
+namespace std {
+ %template(IntList) list<int>;
+}
+
+%template(DoubleList) std::list<double>;
+
+%inline %{
+typedef float Real;
+%}
+
+namespace std {
+ %template(RealList) list<Real>;
+}
+
+%inline %{
+
+double average(std::list<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+
+void halve_in_place(std::list<double>& v) {
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+struct Struct {
+ double num;
+ Struct() : num(0.0) {}
+ Struct(double d) : num(d) {}
+// bool operator==(const Struct &other) { return (num == other.num); }
+};
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/li_std_map.i b/trunk/Examples/test-suite/li_std_map.i
new file mode 100644
index 000000000..d5929d786
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_map.i
@@ -0,0 +1,111 @@
+%module("templatereduce") li_std_map
+%feature("trackobjects");
+
+%include "std_pair.i"
+%include "std_map.i"
+%include "std_string.i"
+
+// Declare some maps to play around with
+%template(IntIntMap) std::map<int, int>;
+%template(StringIntMap) std::map<std::string, int>;
+
+%ignore Struct::operator<;
+%ignore Struct::operator==;
+
+// Add an inline function to test
+%inline %{
+
+double valueAverage(std::map<std::string, int> m) {
+ if (m.size() == 0) {
+ return 0.0;
+ }
+
+ double a = 0.0;
+ for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) {
+ a += i->second;
+ }
+
+ return a / m.size();
+}
+
+std::string stringifyKeys(std::map<std::string, int> m) {
+ std::string a;
+ for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) {
+ a += " " + i->first;
+ }
+ return a;
+}
+
+struct Struct {
+ double num;
+ Struct() : num(0.0) {}
+ Struct(double d) : num(d) {}
+ bool operator<(const Struct &other) const { return num < other.num; }
+ bool operator==(const Struct &other) const { return num == other.num; }
+};
+
+%}
+
+//#if !defined(SWIGR)
+
+// Test out some maps with pointer types
+%template(IntIntPtrMap) std::map<int, int *>;
+%template(IntConstIntPtrMap) std::map<int, const int *>;
+
+//#endif
+
+
+// Test out some maps with non-basic types and non-basic pointer types
+%template(IntStructMap) std::map<int, Struct>;
+%template(IntStructPtrMap) std::map<int, Struct *>;
+%template(IntStructConstPtrMap) std::map<int, const Struct *>;
+%template(StructPtrIntMap) std::map<Struct *, int>;
+
+// Test out a non-specialized map
+%template(StructIntMap) std::map<Struct, int>;
+
+// Additional map definitions for Ruby, Python and Octave tests
+%inline %{
+ struct A{
+ int val;
+
+ A(int v = 0): val(v) {
+ }
+ };
+%}
+
+namespace std {
+ %template(pairii) pair<int, int>;
+ %template(pairAA) pair<int, A>;
+ %template(pairA) pair<int, A*>;
+ %template(mapA) map<int, A*>;
+
+ %template(paircA1) pair<const int, A*>;
+ %template(paircA2) pair<const int, const A*>;
+ %template(pairiiA) pair<int,pair<int, A*> >;
+ %template(pairiiAc) pair<int,const pair<int, A*> >;
+
+
+#ifdef SWIGRUBY
+ %template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
+ %template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
+#endif
+
+#ifdef SWIGPYTHON
+ %template() pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
+ %template(pymap) map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
+#endif
+
+}
+
+%inline {
+ std::pair<int, A*> p_identa(std::pair<int, A*> p) {
+ return p;
+ }
+
+ std::map<int, A*> m_identa(const std::map<int,A*>& v) {
+ return v;
+ }
+}
+
+
diff --git a/trunk/Examples/test-suite/li_std_multimap.i b/trunk/Examples/test-suite/li_std_multimap.i
new file mode 100644
index 000000000..a29417919
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_multimap.i
@@ -0,0 +1,25 @@
+%module("templatereduce") li_std_multimap
+
+%feature("trackobjects");
+
+%include std_pair.i
+%include std_map.i
+%include std_multimap.i
+
+%inline %{
+struct A{
+ int val;
+
+ A(int v = 0): val(v)
+ {
+ }
+
+};
+%}
+
+namespace std
+{
+ %template(pairA) pair<int, A*>;
+ %template(mapA) map<int, A*>;
+ %template(multimapA) multimap<int, A*>;
+}
diff --git a/trunk/Examples/test-suite/li_std_pair.i b/trunk/Examples/test-suite/li_std_pair.i
new file mode 100644
index 000000000..9dea1d814
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_pair.i
@@ -0,0 +1,62 @@
+%module li_std_pair
+
+%include "std_pair.i"
+
+namespace std {
+ %template(IntPair) pair<int, int>;
+}
+
+%inline %{
+
+/* Test the "out" typemap for pair<T, U> */
+std::pair<int, int> makeIntPair(int a, int b) {
+ return std::make_pair(a, b);
+}
+
+/**
+ * There is no "out" typemap for a pointer to a pair, so
+ * this should return a wrapped instance of a std::pair
+ * instead of the native "array" type for the target language.
+ */
+std::pair<int, int> * makeIntPairPtr(int a, int b) {
+ static std::pair<int, int> p = std::make_pair(a, b);
+ return &p;
+}
+
+/**
+ * There is no "out" typemap for a non-const reference to a pair, so
+ * this should return a wrapped instance of a std::pair instead of
+ * the native "array" type for the target language.
+ */
+std::pair<int, int>& makeIntPairRef(int a, int b) {
+ static std::pair<int, int> p = std::make_pair(a, b);
+ return p;
+}
+
+/**
+ * There is no "out" typemap for a const reference to a pair, so
+ * this should return a wrapped instance of a std::pair
+ * instead of the native "array" type for the target language.
+ */
+const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
+ static std::pair<int, int> p = std::make_pair(a, b);
+ return p;
+}
+
+/* Test the "in" typemap for pair<T, U> */
+int product1(std::pair<int, int> p) {
+ return p.first*p.second;
+}
+
+/* Test the "in" typemap for const pair<T, U>& */
+int product2(const std::pair<int, int>& p) {
+ return p.first*p.second;
+}
+
+/* Test the "in" typemap for const pair<T, U>* */
+int product3(const std::pair<int, int> *p) {
+ return p->first*p->second;
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/li_std_pair_extra.i b/trunk/Examples/test-suite/li_std_pair_extra.i
new file mode 100644
index 000000000..4e3b3a571
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_pair_extra.i
@@ -0,0 +1,210 @@
+%module li_std_pair_extra
+
+//
+// activate the automatic comparison methods generation (==,!=,...)
+//
+
+%{
+#include <algorithm> // for std::swap
+%}
+
+
+%include std_pair.i
+%include std_string.i
+%include std_complex.i
+
+%inline
+%{
+ struct A
+ {
+ int val;
+
+ A(int v = 0): val(v)
+ {
+ }
+
+ };
+ struct B
+ {
+ };
+%}
+
+%std_comp_methods(std::pair<std::string, int>);
+
+namespace std {
+ %template(CIntPair) pair<const int, const int>;
+ %template() pair<double, double>;
+ %template(ShortPair) pair<short, short>;
+
+ %template(IntPair) pair<int, int>;
+ %extend pair<int, int>
+ {
+ %template(pair) pair<short,short>;
+ }
+
+
+
+ %template(SIPair) pair<std::string, int>;
+ %template(CIPair) pair<std::complex<double>, int>;
+ %template(SIIPair) pair<std::pair<std::string, int>, int>;
+ %template(AIntPair) pair<A, int>;
+
+ %template(CCIntPair) pair<const A, const pair<int, int> >;
+
+ %template(ABPair) pair<A, B>;
+ %template(IntAPair) pair<int, A>;
+
+ %template(pairP1) pair<int, A*>;
+ %template(pairP2) pair<A*, int>;
+ %template(pairP3) pair<A*, A*>;
+ %template(pairP4) pair<int, int*>;
+ %template(pairP5) pair<int*, int>;
+ %template(pairP6) pair<int*, int*>;
+
+}
+%std_comp_methods(std::pair<std::pair<std::string, int>, int>);
+
+%apply std::pair<int,int> *INOUT {std::pair<int,int> *INOUT2};
+
+%inline %{
+
+/* Test the "out" typemap for pair<T, U> */
+std::pair<int, int> makeIntPair(int a, int b) {
+ return std::make_pair(a, b);
+}
+
+/**
+ * There is no "out" typemap for a pointer to a pair, so
+ * this should return a wrapped instance of a std::pair
+ * instead of the native "array" type for the target language.
+ */
+std::pair<int, int> * makeIntPairPtr(int a, int b) {
+ static std::pair<int, int> p = std::make_pair(a, b);
+ return &p;
+}
+
+/**
+ * There is no "out" typemap for a non-const reference to a pair, so
+ * this should return a wrapped instance of a std::pair instead of
+ * the native "array" type for the target language.
+ */
+std::pair<int, int>& makeIntPairRef(int a, int b) {
+ static std::pair<int, int> p = std::make_pair(a, b);
+ return p;
+}
+
+/**
+ * There is no "out" typemap for a const reference to a pair, so
+ * this should return a wrapped instance of a std::pair
+ * instead of the native "array" type for the target language.
+ */
+const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
+ static std::pair<int, int> p = std::make_pair(a, b);
+ return p;
+}
+
+/* Test the "in" typemap for pair<T, U> */
+int product1(std::pair<int, int> p) {
+ return p.first*p.second;
+}
+
+/* Test the "in" typemap for const pair<T, U>& */
+int product2(const std::pair<int, int>& p) {
+ return p.first*p.second;
+}
+
+std::pair<int, int>
+ p_ident(std::pair<int, int> p, const std::pair<int, int>& q) {
+ return p;
+}
+
+
+std::pair<int, A*>
+p_identa(const std::pair<int, A*>& p) {
+ return p;
+}
+
+void
+d_inout(double *INOUT) {
+ *INOUT += *INOUT;
+}
+
+void
+d_inout(int *INOUT) {
+ *INOUT += *INOUT;
+}
+
+int
+d_inout2(double *INOUT) {
+ *INOUT += *INOUT;
+ return 1;
+}
+
+void
+p_inout(std::pair<int, int> *INOUT) {
+ std::swap(INOUT->first, INOUT->second);
+}
+
+int
+p_inout2(std::pair<int, int> *INOUT) {
+ std::swap(INOUT->first, INOUT->second);
+ return 1;
+}
+
+void
+ p_inout3(std::pair<int,int> *INOUT, std::pair<int,int> *INOUT2) {
+ std::swap(*INOUT, *INOUT2);
+}
+
+void
+p_inoutd(std::pair<double, double> *INOUT) {
+ std::swap(INOUT->first, INOUT->second);
+}
+
+std::string
+ s_ident(const std::string& s) {
+ return s;
+}
+
+#if 0
+std::pair<char, char>
+ p_ident(std::pair<char, char> p, const std::pair<char, char>& q) {
+ return p;
+}
+
+/* Test the "in" typemap for const pair<T, U>* */
+std::pair<A, B>
+ p_ident(std::pair<A, B> p, const std::pair<A, B>& q) {
+ return q;
+}
+
+/* Test the "in" typemap for const pair<T, U>* */
+std::pair<int, A>
+ p_ident(std::pair<int, A> p, const std::pair<int, A>& q) {
+ return p;
+}
+
+
+std::pair<int, int>
+ p_ident(std::pair<int, int> p, const std::pair<A, int>& q) {
+ return p;
+}
+
+std::pair<int, int>
+ p_ident(std::pair<int, int> p, const std::pair<A, B>& q) {
+ return p;
+}
+
+
+
+#endif
+%}
+
+
+namespace std
+{
+ %template(paircA1) pair<const int, A*>;
+ %template(paircA2) pair<const int, const A*>;
+ %template(pairiiA) pair<int,pair<int, A*> >;
+}
+
diff --git a/trunk/Examples/test-suite/li_std_pair_lang_object.i b/trunk/Examples/test-suite/li_std_pair_lang_object.i
new file mode 100644
index 000000000..a830af728
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_pair_lang_object.i
@@ -0,0 +1,8 @@
+%module li_std_pair_lang_object
+
+%include <std_pair.i>
+
+namespace std {
+ %template(ValuePair) pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
+}
+
diff --git a/trunk/Examples/test-suite/li_std_queue.i b/trunk/Examples/test-suite/li_std_queue.i
new file mode 100644
index 000000000..6bf71afca
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_queue.i
@@ -0,0 +1,7 @@
+// test of std::queue
+%module li_std_queue
+
+%include std_queue.i
+
+
+%template( IntQueue ) std::queue< int >;
diff --git a/trunk/Examples/test-suite/li_std_set.i b/trunk/Examples/test-suite/li_std_set.i
new file mode 100644
index 000000000..2dcc2f17c
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_set.i
@@ -0,0 +1,34 @@
+/*
+ * a test of set containers.
+ * Languages should define swig::LANGUAGE_OBJ to be
+ * an entity of their native pointer type which can be
+ * included in a STL container.
+ *
+ * For example:
+ * swig::LANGUAGE_OBJ is GC_VALUE in Ruby
+ * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python
+ */
+
+%module li_std_set
+
+%include <std_string.i>
+%include <std_set.i>
+%include <std_multiset.i>
+%include <std_vector.i>
+
+%template(set_string) std::set<std::string>;
+%template(set_int) std::multiset<int>;
+
+
+%template(v_int) std::vector<int>;
+
+
+
+
+#if defined(SWIGRUBY)
+%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
+#endif
+
+#if defined(SWIGPYTHON)
+%template(pyset) std::set<swig::SwigPtr_PyObject>;
+#endif
diff --git a/trunk/Examples/test-suite/li_std_stack.i b/trunk/Examples/test-suite/li_std_stack.i
new file mode 100644
index 000000000..19b45d46f
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_stack.i
@@ -0,0 +1,7 @@
+// test of std::stack
+%module li_std_stack
+
+%include std_stack.i
+
+
+%template( IntStack ) std::stack< int >;
diff --git a/trunk/Examples/test-suite/li_std_stream.i b/trunk/Examples/test-suite/li_std_stream.i
new file mode 100644
index 000000000..0a999ddbf
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_stream.i
@@ -0,0 +1,59 @@
+%module li_std_stream
+
+%inline %{
+ struct A;
+%}
+
+%include <std_iostream.i>
+%include <std_sstream.i>
+
+
+
+%callback(1) A::bar;
+
+%inline %{
+
+ struct B {
+ virtual ~B()
+ {
+ }
+
+ };
+
+ struct A : B
+ {
+ void __add__(int a)
+ {
+ }
+
+ void __add__(double a)
+ {
+ }
+
+ static int bar(int a){
+ return a;
+ }
+
+ static int foo(int a, int (*pf)(int a))
+ {
+ return pf(a);
+ }
+
+
+ std::ostream& __rlshift__(std::ostream& out)
+ {
+ out << "A class";
+ return out;
+ }
+ };
+%}
+
+%extend std::basic_ostream<char>{
+ std::basic_ostream<char>&
+ operator<<(const A& a)
+ {
+ *self << "A class";
+ return *self;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/li_std_string.i b/trunk/Examples/test-suite/li_std_string.i
new file mode 100644
index 000000000..2d0b7503d
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_string.i
@@ -0,0 +1,149 @@
+%module li_std_string
+%include <std_string.i>
+
+#if defined(SWIGUTL)
+%apply std::string& INPUT { std::string &input }
+%apply std::string& INOUT { std::string &inout }
+#endif
+
+
+%inline %{
+
+std::string test_value(std::string x) {
+ return x;
+}
+
+const std::string& test_const_reference(const std::string &x) {
+ return x;
+}
+
+void test_pointer(std::string *x) {
+}
+
+std::string *test_pointer_out() {
+ static std::string x = "x";
+ return &x;
+}
+
+void test_const_pointer(const std::string *x) {
+}
+
+const std::string *test_const_pointer_out() {
+ static std::string x = "x";
+ return &x;
+}
+
+void test_reference(std::string &x) {
+}
+
+std::string& test_reference_out() {
+ static std::string x = "test_reference_out message";
+ return x;
+}
+
+std::string test_reference_input(std::string &input) {
+ return input;
+}
+
+void test_reference_inout(std::string &inout) {
+ inout += inout;
+}
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+void test_throw() throw(std::string){
+ static std::string x = "test_throw message";
+ throw x;
+}
+
+void test_const_reference_throw() throw(const std::string &){
+ static std::string x = "test_const_reference_throw message";
+ throw x;
+}
+
+void test_pointer_throw() throw(std::string *) {
+ throw new std::string("foo");
+}
+
+void test_const_pointer_throw() throw(const std::string *) {
+ throw new std::string("foo");
+}
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+%}
+
+/* Old way, now std::string is a %naturalvar by default
+%apply const std::string& { std::string *GlobalString2,
+ std::string *MemberString2,
+ std::string *Structure::StaticMemberString2 };
+*/
+
+%inline %{
+std::string GlobalString;
+std::string GlobalString2 = "global string 2";
+const std::string ConstGlobalString = "const global string";
+
+struct Structure {
+ std::string MemberString;
+ std::string MemberString2;
+ static std::string StaticMemberString;
+ static std::string StaticMemberString2;
+
+ const std::string ConstMemberString;
+ static const std::string ConstStaticMemberString;
+
+ Structure() : MemberString2("member string 2"), ConstMemberString("const member string") {}
+};
+%}
+
+%{
+ std::string Structure::StaticMemberString = "static member string";
+ std::string Structure::StaticMemberString2 = "static member string 2";
+ const std::string Structure::ConstStaticMemberString = "const static member string";
+%}
+
+
+%inline %{
+class Foo {
+public:
+ unsigned long long test(unsigned long long l)
+ {
+ return l + 1;
+ }
+ std::string test(std::string l)
+ {
+ return l + "1";
+ }
+
+ unsigned long long testl(unsigned long long l)
+ {
+ return l + 1;
+ }
+
+};
+%}
+
+%inline %{
+ std::string stdstring_empty() {
+ return std::string();
+ }
+
+ char *c_empty() {
+ return (char *)"";
+ }
+
+ char *c_null() {
+ return 0;
+ }
+
+ const char *get_null(const char *a) {
+ return a == 0 ? a : "non-null";
+ }
+
+
+%}
diff --git a/trunk/Examples/test-suite/li_std_string_extra.i b/trunk/Examples/test-suite/li_std_string_extra.i
new file mode 100644
index 000000000..aa758532a
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_string_extra.i
@@ -0,0 +1,55 @@
+%module li_std_string_extra
+
+%naturalvar A;
+
+
+%include <std_basic_string.i>
+%include <std_string.i>
+
+
+%inline %{
+
+struct A : std::string
+{
+ A(const std::string& s) : std::string(s)
+ {
+ }
+};
+
+struct B
+{
+ B(const std::string& s) : cname(0), name(s), a(s)
+ {
+ }
+
+ char *cname;
+ std::string name;
+ A a;
+
+};
+
+
+const char* test_ccvalue(const char* x) {
+ return x;
+}
+
+char* test_cvalue(char* x) {
+ return x;
+}
+
+std::basic_string<char> test_value_basic1(std::basic_string<char> x) {
+ return x;
+}
+
+std::basic_string<char,std::char_traits<char> > test_value_basic2(std::basic_string<char,std::char_traits<char> > x) {
+ return x;
+}
+
+std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic3(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) {
+ return x;
+}
+
+%}
+
+%include "li_std_string.i"
+
diff --git a/trunk/Examples/test-suite/li_std_vector.i b/trunk/Examples/test-suite/li_std_vector.i
new file mode 100644
index 000000000..a58f97ff1
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_vector.i
@@ -0,0 +1,109 @@
+%module li_std_vector
+
+%include "std_vector.i"
+%include "std_string.i"
+
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+
+namespace std {
+ %template(IntVector) vector<int>;
+}
+
+%template(BoolVector) std::vector<bool>;
+%template(CharVector) std::vector<char>;
+%template(ShortVector) std::vector<short>;
+%template(LongVector) std::vector<long>;
+%template(UCharVector) std::vector<unsigned char>;
+%template(UIntVector) std::vector<unsigned int>;
+%template(UShortVector) std::vector<unsigned short>;
+%template(ULongVector) std::vector<unsigned long>;
+%template(DoubleVector) std::vector<double>;
+%template(StringVector) std::vector<std::string>;
+
+
+%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<Real> half(const std::vector<Real>& v) {
+ std::vector<Real> w(v);
+ for (std::vector<Real>::size_type 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));
+}
+
+struct Struct {
+ double num;
+ Struct() : num(0.0) {}
+ Struct(double d) : num(d) {}
+};
+
+struct Structure {
+ double num;
+ Structure() : num(0.0) {}
+ Structure(double d) : num(d) {}
+};
+
+const std::vector<Real> & vecreal(const std::vector<Real> & vec) { return vec; }
+
+const std::vector<int> & vecintptr(const std::vector<int> & vec) { return vec; }
+const std::vector<int *> & vecintptr(const std::vector<int *> & vec) { return vec; }
+const std::vector<const int *> & vecintconstptr(const std::vector<const int *> & vec) { return vec; }
+
+const std::vector<Struct> & vecstruct(const std::vector<Struct> & vec) { return vec; }
+const std::vector<Struct *> & vecstructptr(const std::vector<Struct *> & vec) { return vec; }
+const std::vector<const Struct *> & vecstructconstptr(const std::vector<const Struct *> & vec) { return vec; }
+%}
+
+#if !defined(SWIGR)
+%template(IntPtrVector) std::vector<int *>;
+%template(IntConstPtrVector) std::vector<const int *>;
+#endif
+%template(StructVector) std::vector<Struct>;
+%template(StructPtrVector) std::vector<Struct *>;
+%template(StructConstPtrVector) std::vector<const Struct *>;
+
+%inline {
+ struct MyClass {};
+ typedef MyClass *MyClassPtr;
+ typedef std::vector<MyClassPtr> MyClassVector;
+}
+%template(MyClassPtrVector) std::vector<MyClassPtr>;
+
+%inline {
+ class RetsMetadata
+ {
+ public:
+ MyClassVector GetAllResources(size_t n) const
+ {
+ return MyClassVector(n, 0);
+ }
+ };
+}
+
+#if defined(SWIGRUBY)
+%template(LanguageVector) std::vector< swig::LANGUAGE_OBJ >;
+
+%inline {
+ std::vector< swig::LANGUAGE_OBJ > LanguageVector;
+}
+#endif
diff --git a/trunk/Examples/test-suite/li_std_vector_extra.i b/trunk/Examples/test-suite/li_std_vector_extra.i
new file mode 100644
index 000000000..114de3f11
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_vector_extra.i
@@ -0,0 +1,148 @@
+%module li_std_vector_extra
+
+%warnfilter(509) overloaded1;
+%warnfilter(509) overloaded2;
+
+%include "std_string.i"
+%include "std_vector.i"
+%include "cpointer.i"
+%include "carrays.i"
+
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+
+namespace std {
+ %template() vector<short>;
+ %template(IntVector) vector<int>;
+ %template(BoolVector) vector<bool>;
+ %template() vector<string>;
+}
+
+%template(DoubleVector) std::vector<double>;
+
+
+%template(sizeVector) std::vector<size_t>;
+%{
+ template <class T>
+ struct Param
+ {
+ T val;
+
+ Param(T v = 0): val(v) {
+ }
+
+ operator T() const { return val; }
+ };
+%}
+specialize_std_vector(Param<int>,PyInt_Check,PyInt_AsLong,PyInt_FromLong);
+%template(PIntVector) std::vector<Param<int> >;
+
+%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<Real> half(const std::vector<Real>& v) {
+ std::vector<Real> w(v);
+ for (std::vector<Real>::size_type 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));
+}
+
+%}
+
+%template(IntPtrVector) std::vector<int *>;
+
+
+
+//
+//
+%{
+#include <iostream>
+%}
+
+%inline %{
+
+namespace Test {
+struct A {
+ virtual ~A() {}
+ virtual int f(const int i) const = 0;
+};
+
+struct B : public A {
+ int val;
+
+ B(int i = 0) : val(i)
+ {
+ }
+
+ int f(const int i) const { return i + val; }
+};
+
+
+int vecAptr(const std::vector<A*>& v) {
+ return v[0]->f(1);
+}
+
+}
+
+std::vector<short> halfs(const std::vector<short>& v) {
+ std::vector<short> w(v);
+ for (std::vector<short>::size_type i=0; i<w.size(); i++)
+ w[i] /= 2;
+ return w;
+}
+
+
+std::vector<std::string> vecStr(std::vector<std::string> v) {
+ v[0] += v[1];
+ return v;
+}
+
+%}
+%template(VecB) std::vector<Test::B>;
+%template(VecA) std::vector<Test::A*>;
+
+%pointer_class(int,PtrInt)
+%array_functions(int,ArrInt)
+
+%inline %{
+ int *makeIntPtr(int v) { return new int(v); }
+ const short *makeConstShortPtr(int v) { return new short(v); }
+ double *makeDoublePtr(double v) { return new double(v); }
+ int extractInt(int *p) { return *p; }
+ short extractConstShort(const short *p) { return *p; }
+%}
+
+%template(pyvector) std::vector<swig::SwigPtr_PyObject>;
+
+namespace std {
+ %template(ConstShortPtrVector) vector<const short *>;
+}
+
+%inline %{
+std::string overloaded1(std::vector<double> vi) { return "vector<double>"; }
+std::string overloaded1(std::vector<int> vi) { return "vector<int>"; }
+std::string overloaded2(std::vector<int> vi) { return "vector<int>"; }
+std::string overloaded2(std::vector<double> vi) { return "vector<double>"; }
+std::string overloaded3(std::vector<int> *vi) { return "vector<int> *"; }
+std::string overloaded3(int i) { return "int"; }
+%}
+
diff --git a/trunk/Examples/test-suite/li_std_vector_ptr.i b/trunk/Examples/test-suite/li_std_vector_ptr.i
new file mode 100644
index 000000000..292c9d700
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_vector_ptr.i
@@ -0,0 +1,30 @@
+// Bug 2359417
+%module li_std_vector_ptr
+
+%include "std_vector.i"
+
+%template(IntPtrVector) std::vector<int *>;
+
+%inline %{
+#include <iostream>
+using namespace std;
+int* makeIntPtr(int v) {
+ return new int(v);
+}
+double* makeDoublePtr(double v) {
+ return new double(v);
+}
+
+#if 1
+int** makeIntPtrPtr(int* v) {
+ return new int*(v);
+}
+#endif
+
+void displayVector(std::vector<int *> vpi) {
+ cout << "displayVector..." << endl;
+ for (int i=0; i<vpi.size(); ++i)
+ cout << *vpi[i] << endl;
+}
+%}
+
diff --git a/trunk/Examples/test-suite/li_std_vectora.i b/trunk/Examples/test-suite/li_std_vectora.i
new file mode 100644
index 000000000..d95fdf648
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_vectora.i
@@ -0,0 +1,65 @@
+%module li_std_vectora
+
+%include std_vectora.i
+
+
+%{
+#include <algorithm>
+#include <functional>
+#include <numeric>
+%}
+
+
+%template(vector_i) std::vector<int, std::allocator<int> >;
+
+%template(matrix_i) std::vector<std::vector<int,std::allocator<int> >,std::allocator<std::vector<int,std::allocator<int> > > >;
+
+%inline
+{
+ typedef
+ std::vector<std::vector<int,std::allocator<int> >,
+ std::allocator<std::vector<int,std::allocator<int> > > >
+ imatrix;
+
+ std::vector<int> vident(const std::vector<int,std::allocator<int> >& v)
+ {
+ return v;
+ }
+
+ imatrix mident(const imatrix& v)
+ {
+ return v;
+ }
+}
+
+
+%template(DoubleVector) std::vector<double, std::allocator<double> >;
+
+%inline %{
+typedef float Real;
+%}
+
+namespace std {
+ %template(RealVector) vector<Real, std::allocator<Real> >;
+}
+
+%inline %{
+
+double average(std::vector<int, std::allocator<int> > v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<Real,std::allocator<Real> >
+half(const std::vector<Real,std::allocator<Real> >& v) {
+ std::vector<Real> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+%}
+
+%template(IntPtrVector) std::vector<int *,std::allocator<int *> >;
+
+
+
diff --git a/trunk/Examples/test-suite/li_std_wstream.i b/trunk/Examples/test-suite/li_std_wstream.i
new file mode 100644
index 000000000..e4d725f10
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_wstream.i
@@ -0,0 +1,59 @@
+%module li_std_wstream
+
+%inline %{
+ struct A;
+%}
+
+%include <std_wiostream.i>
+%include <std_wsstream.i>
+
+
+
+%callback(1) A::bar;
+
+%inline %{
+
+ struct B {
+ virtual ~B()
+ {
+ }
+
+ };
+
+ struct A : B
+ {
+ void __add__(int a)
+ {
+ }
+
+ void __add__(double a)
+ {
+ }
+
+ static int bar(int a){
+ return a;
+ }
+
+ static int foo(int a, int (*pf)(int a))
+ {
+ return pf(a);
+ }
+
+
+ std::wostream& __rlshift__(std::wostream& out)
+ {
+ out << "A class";
+ return out;
+ }
+ };
+%}
+
+%extend std::basic_ostream<wchar_t>{
+ std::basic_ostream<wchar_t>&
+ operator<<(const A& a)
+ {
+ *self << "A class";
+ return *self;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/li_std_wstring.i b/trunk/Examples/test-suite/li_std_wstring.i
new file mode 100644
index 000000000..c809e11ec
--- /dev/null
+++ b/trunk/Examples/test-suite/li_std_wstring.i
@@ -0,0 +1,89 @@
+%module li_std_wstring
+%include <std_basic_string.i>
+%include <std_wstring.i>
+
+
+%inline %{
+
+struct A : std::wstring
+{
+ A(const std::wstring& s) : std::wstring(s)
+ {
+ }
+};
+
+struct B
+{
+ B(const std::wstring& s) : cname(0), name(s), a(s)
+ {
+ }
+
+ char *cname;
+ std::wstring name;
+ A a;
+
+};
+
+
+wchar_t test_wcvalue(wchar_t x) {
+ return x;
+}
+
+const wchar_t* test_ccvalue(const wchar_t* x) {
+ return x;
+}
+
+wchar_t* test_cvalue(wchar_t* x) {
+ return x;
+}
+
+
+std::wstring test_value(std::wstring x) {
+ return x;
+}
+
+const std::wstring& test_const_reference(const std::wstring &x) {
+ return x;
+}
+
+void test_pointer(std::wstring *x) {
+}
+
+std::wstring *test_pointer_out() {
+ static std::wstring x = L"x";
+ return &x;
+}
+
+void test_const_pointer(const std::wstring *x) {
+}
+
+const std::wstring *test_const_pointer_out() {
+ static std::wstring x = L"x";
+ return &x;
+}
+
+void test_reference(std::wstring &x) {
+}
+
+std::wstring& test_reference_out() {
+ static std::wstring x = L"x";
+ return x;
+}
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+void test_throw() throw(std::wstring){
+ static std::wstring x = L"x";
+
+ throw x;
+}
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+%}
+
+
diff --git a/trunk/Examples/test-suite/li_stdint.i b/trunk/Examples/test-suite/li_stdint.i
new file mode 100644
index 000000000..518679934
--- /dev/null
+++ b/trunk/Examples/test-suite/li_stdint.i
@@ -0,0 +1,67 @@
+%module li_stdint
+
+%include <stdint.i>
+
+%inline %{
+ struct StdInts {
+ int8_t int8_member;
+ int16_t int16_member;
+ int32_t int32_member;
+ int64_t int64_member;
+ uint8_t uint8_member;
+ uint16_t uint16_member;
+ uint32_t uint32_member;
+ uint64_t uint64_member;
+ };
+
+ int8_t int8_td (int8_t i) { return i; }
+ int16_t int16_td(int16_t i) { return i; }
+ int32_t int32_td(int32_t i) { return i; }
+ int64_t int64_td(int64_t i) { return i; }
+ uint8_t uint8_td (int8_t i) { return i; }
+ uint16_t uint16_td(int16_t i) { return i; }
+ uint32_t uint32_td(int32_t i) { return i; }
+ uint64_t uint64_td(int64_t i) { return i; }
+
+ struct StdIntFasts {
+ int_fast8_t int_fast8_member;
+ int_fast16_t int_fast16_member;
+ int_fast32_t int_fast32_member;
+ int_fast64_t int_fast64_member;
+ uint_fast8_t uint_fast8_member;
+ uint_fast16_t uint_fast16_member;
+ uint_fast32_t uint_fast32_member;
+ uint_fast64_t uint_fast64_member;
+ };
+
+ int_fast8_t int_fast8_td (int_fast8_t i) { return i; }
+ int_fast16_t int_fast16_td(int_fast16_t i) { return i; }
+ int_fast32_t int_fast32_td(int_fast32_t i) { return i; }
+ int_fast64_t int_fast64_td(int_fast64_t i) { return i; }
+ uint_fast8_t uint_fast8_td (int_fast8_t i) { return i; }
+ uint_fast16_t uint_fast16_td(int_fast16_t i) { return i; }
+ uint_fast32_t uint_fast32_td(int_fast32_t i) { return i; }
+ uint_fast64_t uint_fast64_td(int_fast64_t i) { return i; }
+
+ struct StdIntLeasts {
+ int_least8_t int_least8_member;
+ int_least16_t int_least16_member;
+ int_least32_t int_least32_member;
+ int_least64_t int_least64_member;
+ uint_least8_t uint_least8_member;
+ uint_least16_t uint_least16_member;
+ uint_least32_t uint_least32_member;
+ uint_least64_t uint_least64_member;
+ };
+
+ int_least8_t int_least8_td (int_least8_t i) { return i; }
+ int_least16_t int_least16_td(int_least16_t i) { return i; }
+ int_least32_t int_least32_td(int_least32_t i) { return i; }
+ int_least64_t int_least64_td(int_least64_t i) { return i; }
+ uint_least8_t uint_least8_td (int_least8_t i) { return i; }
+ uint_least16_t uint_least16_td(int_least16_t i) { return i; }
+ uint_least32_t uint_least32_td(int_least32_t i) { return i; }
+ uint_least64_t uint_least64_td(int_least64_t i) { return i; }
+
+%}
+
diff --git a/trunk/Examples/test-suite/li_typemaps.i b/trunk/Examples/test-suite/li_typemaps.i
new file mode 100644
index 000000000..a53c1c74a
--- /dev/null
+++ b/trunk/Examples/test-suite/li_typemaps.i
@@ -0,0 +1,109 @@
+%module li_typemaps
+
+%include "typemaps.i"
+
+%apply int &INOUT { int &INOUT2 };
+%newobject out_foo;
+%inline %{
+
+struct Foo { int a; };
+
+bool in_bool(bool *INPUT) { return *INPUT; }
+int in_int(int *INPUT) { return *INPUT; }
+long in_long(long *INPUT) { return *INPUT; }
+short in_short(short *INPUT) { return *INPUT; }
+unsigned int in_uint(unsigned int *INPUT) { return *INPUT; }
+unsigned short in_ushort(unsigned short *INPUT) { return *INPUT; }
+unsigned long in_ulong(unsigned long *INPUT) { return *INPUT; }
+unsigned char in_uchar(unsigned char *INPUT) { return *INPUT; }
+signed char in_schar(signed char *INPUT) { return *INPUT; }
+float in_float(float *INPUT) { return *INPUT; }
+double in_double(double *INPUT) { return *INPUT; }
+long long in_longlong(long long *INPUT) { return *INPUT; }
+unsigned long long in_ulonglong(unsigned long long *INPUT) { return *INPUT; }
+
+bool inr_bool(bool &INPUT) { return INPUT; }
+int inr_int(int &INPUT) { return INPUT; }
+long inr_long(long &INPUT) { return INPUT; }
+short inr_short(short &INPUT) { return INPUT; }
+unsigned int inr_uint(unsigned int &INPUT) { return INPUT; }
+unsigned short inr_ushort(unsigned short &INPUT) { return INPUT; }
+unsigned long inr_ulong(unsigned long &INPUT) { return INPUT; }
+unsigned char inr_uchar(unsigned char &INPUT) { return INPUT; }
+signed char inr_schar(signed char &INPUT) { return INPUT; }
+float inr_float(float &INPUT) { return INPUT; }
+double inr_double(double &INPUT) { return INPUT; }
+long long inr_longlong(long long &INPUT) { return INPUT; }
+unsigned long long inr_ulonglong(unsigned long long &INPUT) { return INPUT; }
+
+void out_bool(bool x, bool *OUTPUT) { *OUTPUT = x; }
+void out_int(int x, int *OUTPUT) { *OUTPUT = x; }
+void out_short(short x, short *OUTPUT) { *OUTPUT = x; }
+void out_long(long x, long *OUTPUT) { *OUTPUT = x; }
+void out_uint(unsigned int x, unsigned int *OUTPUT) { *OUTPUT = x; }
+void out_ushort(unsigned short x, unsigned short *OUTPUT) { *OUTPUT = x; }
+void out_ulong(unsigned long x, unsigned long *OUTPUT) { *OUTPUT = x; }
+void out_uchar(unsigned char x, unsigned char *OUTPUT) { *OUTPUT = x; }
+void out_schar(signed char x, signed char *OUTPUT) { *OUTPUT = x; }
+void out_float(float x, float *OUTPUT) { *OUTPUT = x; }
+void out_double(double x, double *OUTPUT) { *OUTPUT = x; }
+void out_longlong(long long x, long long *OUTPUT) { *OUTPUT = x; }
+void out_ulonglong(unsigned long long x, unsigned long long *OUTPUT) { *OUTPUT = x; }
+
+/* Tests a returning a wrapped pointer and an output argument */
+struct Foo *out_foo(int a, int *OUTPUT) {
+ struct Foo *f = new struct Foo();
+ f->a = a;
+ *OUTPUT = a * 2;
+ return f;
+}
+
+void outr_bool(bool x, bool &OUTPUT) { OUTPUT = x; }
+void outr_int(int x, int &OUTPUT) { OUTPUT = x; }
+void outr_short(short x, short &OUTPUT) { OUTPUT = x; }
+void outr_long(long x, long &OUTPUT) { OUTPUT = x; }
+void outr_uint(unsigned int x, unsigned int &OUTPUT) { OUTPUT = x; }
+void outr_ushort(unsigned short x, unsigned short &OUTPUT) { OUTPUT = x; }
+void outr_ulong(unsigned long x, unsigned long &OUTPUT) { OUTPUT = x; }
+void outr_uchar(unsigned char x, unsigned char &OUTPUT) { OUTPUT = x; }
+void outr_schar(signed char x, signed char &OUTPUT) { OUTPUT = x; }
+void outr_float(float x, float &OUTPUT) { OUTPUT = x; }
+void outr_double(double x, double &OUTPUT) { OUTPUT = x; }
+void outr_longlong(long long x, long long &OUTPUT) { OUTPUT = x; }
+void outr_ulonglong(unsigned long long x, unsigned long long &OUTPUT) { OUTPUT = x; }
+
+void inout_bool(bool *INOUT) { *INOUT = *INOUT; }
+void inout_int(int *INOUT) { *INOUT = *INOUT; }
+void inout_short(short *INOUT) { *INOUT = *INOUT; }
+void inout_long(long *INOUT) { *INOUT = *INOUT; }
+void inout_uint(unsigned int *INOUT) { *INOUT = *INOUT; }
+void inout_ushort(unsigned short *INOUT) { *INOUT = *INOUT; }
+void inout_ulong(unsigned long *INOUT) { *INOUT = *INOUT; }
+void inout_uchar(unsigned char *INOUT) { *INOUT = *INOUT; }
+void inout_schar(signed char *INOUT) { *INOUT = *INOUT; }
+void inout_float(float *INOUT) { *INOUT = *INOUT; }
+void inout_double(double *INOUT) { *INOUT = *INOUT; }
+void inout_longlong(long long *INOUT) { *INOUT = *INOUT; }
+void inout_ulonglong(unsigned long long *INOUT) { *INOUT = *INOUT; }
+
+void inoutr_bool(bool &INOUT) { INOUT = INOUT; }
+void inoutr_int(int &INOUT) { INOUT = INOUT; }
+void inoutr_short(short &INOUT) { INOUT = INOUT; }
+void inoutr_long(long &INOUT) { INOUT = INOUT; }
+void inoutr_uint(unsigned int &INOUT) { INOUT = INOUT; }
+void inoutr_ushort(unsigned short &INOUT) { INOUT = INOUT; }
+void inoutr_ulong(unsigned long &INOUT) { INOUT = INOUT; }
+void inoutr_uchar(unsigned char &INOUT) { INOUT = INOUT; }
+void inoutr_schar(signed char &INOUT) { INOUT = INOUT; }
+void inoutr_float(float &INOUT) { INOUT = INOUT; }
+void inoutr_double(double &INOUT) { INOUT = INOUT; }
+void inoutr_longlong(long long &INOUT) { INOUT = INOUT; }
+void inoutr_ulonglong(unsigned long long &INOUT) { INOUT = INOUT; }
+
+void inoutr_int2(int &INOUT, int &INOUT2) { INOUT = INOUT; INOUT2 = INOUT2;}
+
+%}
+
+
+
+
diff --git a/trunk/Examples/test-suite/li_windows.i b/trunk/Examples/test-suite/li_windows.i
new file mode 100644
index 000000000..26f96cc3b
--- /dev/null
+++ b/trunk/Examples/test-suite/li_windows.i
@@ -0,0 +1,97 @@
+%module li_windows
+
+%include "windows.i"
+
+%{
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+ #include <windows.h>
+#else
+ // Use equivalent types for non-windows systems
+ #define __int8 char
+ #define __int16 short
+ #define __int32 int
+ #define __int64 long long
+#endif
+%}
+
+%inline %{
+// Non ISO integral types
+ __int8 int8_val ( __int8 i) { return i; }
+ __int16 int16_val( __int16 i) { return i; }
+ __int32 int32_val( __int32 i) { return i; }
+ __int64 int64_val( __int64 i) { return i; }
+unsigned __int8 uint8_val (unsigned __int8 i) { return i; }
+unsigned __int16 uint16_val(unsigned __int16 i) { return i; }
+unsigned __int32 uint32_val(unsigned __int32 i) { return i; }
+unsigned __int64 uint64_val(unsigned __int64 i) { return i; }
+
+const __int8& int8_ref (const __int8& i) { return i; }
+const __int16& int16_ref(const __int16& i) { return i; }
+const __int32& int32_ref(const __int32& i) { return i; }
+const __int64& int64_ref(const __int64& i) { return i; }
+const unsigned __int8& uint8_ref (const unsigned __int8& i) { return i; }
+const unsigned __int16& uint16_ref(const unsigned __int16& i) { return i; }
+const unsigned __int32& uint32_ref(const unsigned __int32& i) { return i; }
+const unsigned __int64& uint64_ref(const unsigned __int64& i) { return i; }
+
+ __int8 int8_global;
+ __int16 int16_global;
+ __int32 int32_global;
+ __int64 int64_global;
+unsigned __int8 uint8_global;
+unsigned __int16 uint16_global;
+unsigned __int32 uint32_global;
+unsigned __int64 uint64_global;
+
+struct WindowsInts {
+ __int8 int8_member;
+ __int16 int16_member;
+ __int32 int32_member;
+ __int64 int64_member;
+ unsigned __int8 uint8_member;
+ unsigned __int16 uint16_member;
+ unsigned __int32 uint32_member;
+ unsigned __int64 uint64_member;
+};
+
+// Typedef for non ISO integral types
+typedef __int8 int8;
+typedef __int16 int16;
+typedef __int32 int32;
+typedef __int64 int64;
+
+typedef unsigned __int8 uint8;
+typedef unsigned __int16 uint16;
+typedef unsigned __int32 uint32;
+typedef unsigned __int64 uint64;
+
+ int8 int8_td (int8 i) { return i; }
+ int16 int16_td(int16 i) { return i; }
+ int32 int32_td(int32 i) { return i; }
+ int64 int64_td(int64 i) { return i; }
+uint8 uint8_td (int8 i) { return i; }
+uint16 uint16_td(int16 i) { return i; }
+uint32 uint32_td(int32 i) { return i; }
+uint64 uint64_td(int64 i) { return i; }
+
+%}
+
+// Windows calling conventions and some types in windows.h
+%inline %{
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#else
+
+#define __stdcall
+#define __declspec(WINDOWS_EXTENDED_ATTRIBUTE)
+#define DWORD unsigned int
+#define PSZ char *
+
+#endif
+
+// Windows calling conventions
+__declspec(dllexport) int __stdcall declspecstdcall(int i) { return i; }
+
+DWORD mefod(DWORD d) { return d; }
+PSZ funktion(PSZ d) { return d; }
+%}
+
diff --git a/trunk/Examples/test-suite/list_vector.i b/trunk/Examples/test-suite/list_vector.i
new file mode 100644
index 000000000..7f907d4f5
--- /dev/null
+++ b/trunk/Examples/test-suite/list_vector.i
@@ -0,0 +1,153 @@
+/* -*- c -*- */
+
+%module list_vector
+
+%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 = 0.0;
+ 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 = 0.0;
+ 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/trunk/Examples/test-suite/long_long.i b/trunk/Examples/test-suite/long_long.i
new file mode 100644
index 000000000..74dd87a15
--- /dev/null
+++ b/trunk/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(SWIGWARN_RUBY_WRONG_NAME) lconst1; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst2; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst3; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst4; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst5; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) lconst6; /* Ruby, wrong constant name */
+
+%inline %{
+void foo1(long long x) {}
+void foo2(long long int x) {}
+void foo3(signed long long int x) {}
+void foo4(unsigned long long int x) {}
+void foo5(signed long long x) {}
+void foo6(unsigned long long x) {}
+
+long long bar1() {return 0;}
+long long int bar2() {return 0;}
+signed long long int bar3() {return 0;}
+unsigned long long int bar4() {return 0;}
+signed long long bar5() {return 0;}
+unsigned long long bar6() {return 0;}
+
+long long ll;
+unsigned long long ull;
+%}
+
+%constant long long lconst1 = 1234567890LL;
+%constant unsigned long long lconst2 = 1234567890ULL;
+
+%constant lconst3 = 1234567LL;
+%constant lconst4 = 1234567ULL;
+
+#define lconst5 987654321LL
+#define lconst6 987654321ULL
diff --git a/trunk/Examples/test-suite/long_long_apply.i b/trunk/Examples/test-suite/long_long_apply.i
new file mode 100644
index 000000000..0280994d2
--- /dev/null
+++ b/trunk/Examples/test-suite/long_long_apply.i
@@ -0,0 +1,77 @@
+/* This interface file tests whether SWIG handles the Microsoft __int64 type through the use of
+applying the long long typemaps. The generated code should not have any instances of long long. */
+
+%module long_long_apply
+
+%{
+#ifdef _MSC_VER /* Visual C++ */
+ typedef __int64 LongLong;
+ typedef unsigned __int64 UnsignedLongLong;
+#else
+ typedef long long LongLong;
+ typedef unsigned long long UnsignedLongLong;
+#endif
+%}
+
+%apply long long { LongLong };
+%apply unsigned long long { UnsignedLongLong };
+
+%apply const long long & { const LongLong & };
+%apply const unsigned long long & { const UnsignedLongLong & };
+
+%inline %{
+// pass by value
+LongLong value1(LongLong x) { return x; }
+UnsignedLongLong value2(UnsignedLongLong x) { return x; }
+
+// pass by reference
+const LongLong &ref1(const LongLong &x) { return x; }
+const UnsignedLongLong &ref2(const UnsignedLongLong &x) { return x; }
+
+// global variables
+LongLong global1;
+UnsignedLongLong global2;
+
+// global reference variables
+const LongLong& global_ref1 = global1;
+const UnsignedLongLong& global_ref2 = global2;
+%}
+
+
+// typemaps library
+%include "typemaps.i"
+%apply long long *INPUT { LongLong *INPUT };
+%apply unsigned long long *INPUT { UnsignedLongLong *INPUT };
+
+%apply long long *OUTPUT { LongLong *OUTPUT };
+%apply unsigned long long *OUTPUT { UnsignedLongLong *OUTPUT };
+
+%apply long long *INOUT { LongLong *INOUT };
+%apply unsigned long long *INOUT { UnsignedLongLong *INOUT };
+
+%apply long long &INPUT { LongLong &INPUT };
+%apply unsigned long long &INPUT { UnsignedLongLong &INPUT };
+
+%apply long long &OUTPUT { LongLong &OUTPUT };
+%apply unsigned long long &OUTPUT { UnsignedLongLong &OUTPUT };
+
+%apply long long &INOUT { LongLong &INOUT };
+%apply unsigned long long &INOUT { UnsignedLongLong &INOUT };
+
+%inline %{
+LongLong in_longlong(LongLong *INPUT) { return *INPUT; }
+UnsignedLongLong in_ulonglong(UnsignedLongLong *INPUT) { return *INPUT; }
+LongLong inr_longlong(LongLong &INPUT) { return INPUT; }
+UnsignedLongLong inr_ulonglong(UnsignedLongLong &INPUT) { return INPUT; }
+
+void out_longlong(LongLong x, LongLong *OUTPUT) { *OUTPUT = x; }
+void out_ulonglong(UnsignedLongLong x, UnsignedLongLong *OUTPUT) { *OUTPUT = x; }
+void outr_longlong(LongLong x, LongLong &OUTPUT) { OUTPUT = x; }
+void outr_ulonglong(UnsignedLongLong x, UnsignedLongLong &OUTPUT) { OUTPUT = x; }
+
+void inout_longlong(LongLong *INOUT) { *INOUT = *INOUT; }
+void inout_ulonglong(UnsignedLongLong *INOUT) { *INOUT = *INOUT; }
+void inoutr_longlong(LongLong &INOUT) { INOUT = INOUT; }
+void inoutr_ulonglong(UnsignedLongLong &INOUT) { INOUT = INOUT; }
+%}
+
diff --git a/trunk/Examples/test-suite/lua/Makefile.in b/trunk/Examples/test-suite/lua/Makefile.in
new file mode 100644
index 000000000..0ddc86a7d
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/Makefile.in
@@ -0,0 +1,64 @@
+#######################################################################
+# Makefile for lua test-suite
+#######################################################################
+
+LANGUAGE = lua
+LUA = @LUABIN@
+SCRIPTSUFFIX = _runme.lua
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+# sorry, currently very few test cases work/have been written
+
+#CPP_TEST_CASES += \
+# cnum
+
+#C_TEST_CASES += \
+# file_test \
+# nondynamic
+
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+LIBS = -L.
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.lua appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: (does nothing, we dont generate extra lua code)
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile lua_clean
+
+cvsignore:
+ @echo '*wrap* *.so *.dll *.exp *.lib'
+ @echo Makefile
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done
diff --git a/trunk/Examples/test-suite/lua/abstract_access_runme.lua b/trunk/Examples/test-suite/lua/abstract_access_runme.lua
new file mode 100644
index 000000000..b9f44cf5a
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/abstract_access_runme.lua
@@ -0,0 +1,17 @@
+require("import") -- the import fn
+import("abstract_access") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- trying to instantiate pure virual classes
+-- should fail
+assert(pcall(abstract_access.A)==false)
+assert(pcall(abstract_access.B)==false)
+assert(pcall(abstract_access.C)==false)
+
+-- instantiate object
+d=abstract_access.D()
+
+--call fn
+assert(d:do_x()==1)
diff --git a/trunk/Examples/test-suite/lua/char_strings_runme.lua b/trunk/Examples/test-suite/lua/char_strings_runme.lua
new file mode 100644
index 000000000..64ae6ec1c
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/char_strings_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("char_strings") -- import code
+
+assert (char_strings.CharPingPong("hi there") == "hi there")
+assert (char_strings.CharPingPong(nil) == nil)
+
+assert (char_strings.CharArrayPingPong("hi there") == "hi there")
+assert (char_strings.CharArrayPingPong(nil) == nil)
+
+assert (char_strings.CharArrayDimsPingPong("hi there") == "hi there")
+assert (char_strings.CharArrayDimsPingPong(nil) == nil)
+
diff --git a/trunk/Examples/test-suite/lua/cpp_basic_runme.lua b/trunk/Examples/test-suite/lua/cpp_basic_runme.lua
new file mode 100644
index 000000000..b63b89cdc
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/cpp_basic_runme.lua
@@ -0,0 +1,64 @@
+require("import") -- the import fn
+import("cpp_basic") -- import code
+cb=cpp_basic -- renaming import
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+f=cb.Foo(4)
+assert(f.num==4)
+f.num=-17
+assert(f.num==-17)
+
+b=cb.Bar()
+
+b.fptr=f
+assert(b.fptr.num==-17)
+assert(b:test(-3,b.fptr)==-5)
+f.num=12
+assert(b.fptr.num==12)
+
+assert(b.fref.num==-4)
+assert(b:test(12,b.fref)==23)
+
+-- references don't take ownership, so if we didn't define this here it might get garbage collected
+f2=cb.Foo(23)
+b.fref=f2
+assert(b.fref.num==23)
+assert(b:test(-3,b.fref)==35)
+
+assert(b.fval.num==15)
+assert(b:test(3,b.fval)==33)
+b.fval=cb.Foo(-15) -- this is safe as it is copied into the C++
+assert(b.fval.num==-15)
+assert(b:test(3,b.fval)==-27)
+
+f3=b:testFoo(12,b.fref)
+assert(f3.num==32)
+
+-- now test global
+f4=cb.Foo(6)
+cb.Bar_global_fptr=f4
+assert(cb.Bar_global_fptr.num==6)
+f4.num=8
+assert(cb.Bar_global_fptr.num==8)
+
+assert(cb.Bar_global_fref.num==23)
+cb.Bar_global_fref=cb.Foo(-7) -- this will set the value
+assert(cb.Bar_global_fref.num==-7)
+
+assert(cb.Bar_global_fval.num==3)
+cb.Bar_global_fval=cb.Foo(-34)
+assert(cb.Bar_global_fval.num==-34)
+
+-- Now test member function pointers
+func1_ptr=cb.get_func1_ptr()
+func2_ptr=cb.get_func2_ptr()
+f.num=4
+assert(f:func1(2)==16)
+assert(f:func2(2)==-8)
+
+f.func_ptr=func1_ptr
+assert(cb.test_func_ptr(f,2)==16)
+f.func_ptr=func2_ptr
+assert(cb.test_func_ptr(f,2)==-8)
diff --git a/trunk/Examples/test-suite/lua/disown_runme.lua b/trunk/Examples/test-suite/lua/disown_runme.lua
new file mode 100644
index 000000000..270758990
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/disown_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("disown") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+for x=0,100 do
+ a=disown.A()
+ b=disown.B()
+ b:acquire(a)
+end
+collectgarbage() -- this will double delete unless the memory is managed properly
diff --git a/trunk/Examples/test-suite/lua/dynamic_cast_runme.lua b/trunk/Examples/test-suite/lua/dynamic_cast_runme.lua
new file mode 100644
index 000000000..6e0a1d226
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/dynamic_cast_runme.lua
@@ -0,0 +1,15 @@
+require("import") -- the import fn
+import("dynamic_cast") -- import code
+
+f = dynamic_cast.Foo()
+b = dynamic_cast.Bar()
+
+x = f:blah()
+y = b:blah()
+
+-- swig_type is a swiglua specific function which gets the swig_type_info's name
+assert(swig_type(f)==swig_type(x))
+assert(swig_type(b)==swig_type(y))
+
+-- the real test: is y a Foo* or a Bar*?
+assert(dynamic_cast.do_test(y)=="Bar::test")
diff --git a/trunk/Examples/test-suite/lua/enums_runme.lua b/trunk/Examples/test-suite/lua/enums_runme.lua
new file mode 100644
index 000000000..f96331c9d
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/enums_runme.lua
@@ -0,0 +1,20 @@
+require("import") -- the import fn
+import("enums") -- import lib
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- check values
+assert(enums.CSP_ITERATION_FWD==0)
+assert(enums.CSP_ITERATION_BWD==11)
+assert(enums.ABCDE==0)
+assert(enums.FGHJI==1)
+assert(enums.boo==0)
+assert(enums.hoo==5)
+assert(enums.globalinstance1==0)
+assert(enums.globalinstance2==1)
+assert(enums.globalinstance3==30)
+assert(enums.AnonEnum1==0)
+assert(enums.AnonEnum2==100)
+
+-- no point in checking fns, C will allow any value
diff --git a/trunk/Examples/test-suite/lua/exception_order_runme.lua b/trunk/Examples/test-suite/lua/exception_order_runme.lua
new file mode 100644
index 000000000..e5caa838d
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/exception_order_runme.lua
@@ -0,0 +1,45 @@
+-- demo of lua swig capacilities (operator overloading)
+require("import") -- the import fn
+import("exception_order") -- import lib into global
+eo=exception_order --alias
+
+-- catching undefined variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+a = eo.A()
+
+function try1()
+ a:foo()
+end
+
+function try2()
+ a:bar()
+end
+
+function try3()
+ a:foobar()
+end
+
+-- the following code used to work
+-- but now no longer works, as the lua bindings don't throw objects any more
+-- all objects are converted to string & thrown
+-- it could be made to work, if E1 & E2 were thrown by value (see lua.swg)
+--[[
+ok,ex=pcall(try1)
+print(ok,ex)
+assert(ok==false and swig_type(ex)==swig_type(eo.E1()))
+
+ok,ex=pcall(try2)
+assert(ok==false and swig_type(ex)==swig_type(eo.E2()))
+]]
+-- this new code does work, but has to look at the string
+ok,ex=pcall(try1)
+assert(ok==false and ex=="object exception:E1")
+
+ok,ex=pcall(try2)
+assert(ok==false and ex=="object exception:E2")
+
+-- the SWIG_exception is just an error string
+ok,ex=pcall(try3)
+assert(ok==false and type(ex)=="string")
+
diff --git a/trunk/Examples/test-suite/lua/exception_partial_info_runme.lua b/trunk/Examples/test-suite/lua/exception_partial_info_runme.lua
new file mode 100644
index 000000000..fb0e5146e
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/exception_partial_info_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("exception_partial_info") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+imp=exception_partial_info.Impl()
+
+-- trying to call throwing methods
+-- should fail
+assert(pcall(function() imp:f1() end)==false)
+assert(pcall(function() imp:f2() end)==false)
diff --git a/trunk/Examples/test-suite/lua/import.lua b/trunk/Examples/test-suite/lua/import.lua
new file mode 100644
index 000000000..eaab3b400
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/import.lua
@@ -0,0 +1,28 @@
+-- import
+-- the lua 5.0 loading mechanism is rather poor & relies upon the loadlib() fn
+-- the lua 5.1 loading mechanism is simplicity itself
+-- for now we need a bridge which will use the correct verion
+
+function import_5_0(name)
+ -- imports the file into the program
+ -- for a module 'example'
+ -- this must load 'example.dll' or 'example.so'
+ -- and look for the fn 'luaopen_example()'
+ if rawget(_G,name)~=nil then return end -- module appears to be loaded
+
+ local lib=loadlib(name..'.dll','luaopen_'..name) or loadlib(name..'.so','luaopen_'..name)
+ assert(lib,"error loading module:"..name)
+
+ lib() -- execute the function: initalising the lib
+ assert(rawget(_G,name)~=nil,"no module table found")
+end
+
+function import_5_1(name)
+ require(name)
+end
+
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ import=import_5_0
+else
+ import=import_5_1
+end \ No newline at end of file
diff --git a/trunk/Examples/test-suite/lua/import_nomodule_runme.lua b/trunk/Examples/test-suite/lua/import_nomodule_runme.lua
new file mode 100644
index 000000000..947acebf5
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/import_nomodule_runme.lua
@@ -0,0 +1,14 @@
+require("import") -- the import fn
+import("import_nomodule") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+f = import_nomodule.create_Foo()
+import_nomodule.test1(f,42)
+import_nomodule.delete_Foo(f)
+
+b = import_nomodule.Bar()
+import_nomodule.test1(b,37)
+
+collectgarbage() \ No newline at end of file
diff --git a/trunk/Examples/test-suite/lua/imports_runme.lua b/trunk/Examples/test-suite/lua/imports_runme.lua
new file mode 100644
index 000000000..1509e1769
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/imports_runme.lua
@@ -0,0 +1,28 @@
+require("import") -- the import fn
+-- need to load two modules
+import("imports_a") -- import code
+import("imports_b") -- import code
+
+b=imports_b.B()
+b:hello() -- call member function in A which is in a different SWIG generated library.
+b:bye()
+
+assert (b:member_virtual_test(imports_a.A_memberenum1) == imports_a.A_memberenum2)
+assert (b:global_virtual_test(imports_a.globalenum1) == imports_a.globalenum2)
+
+imports_b.global_test(imports_a.A_memberenum1)
+
+--[[ B b = new B();
+ b.hello(); //call member function in A which is in a different SWIG generated library.
+
+ B b = new B();
+ b.hello(); //call member function in A which is in a different SWIG generated library.
+ b.bye();
+
+ if (b.member_virtual_test(A.MemberEnum.memberenum1) != A.MemberEnum.memberenum2)
+ throw new Exception("Test 1 failed");
+ if (b.global_virtual_test(GlobalEnum.globalenum1) != GlobalEnum.globalenum2)
+ throw new Exception("Test 2 failed");
+
+ imports_b.global_test(A.MemberEnum.memberenum1);
+]]
diff --git a/trunk/Examples/test-suite/lua/li_carrays_runme.lua b/trunk/Examples/test-suite/lua/li_carrays_runme.lua
new file mode 100644
index 000000000..c54e36acc
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/li_carrays_runme.lua
@@ -0,0 +1,29 @@
+require("import") -- the import fn
+import("li_carrays") -- import code
+
+-- moving to global
+for k,v in pairs(li_carrays) do _G[k]=v end
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- Testing for %array_functions(int,intArray)
+ary = new_intArray(2)
+intArray_setitem(ary, 0, 0)
+intArray_setitem(ary, 1, 1)
+assert(intArray_getitem(ary, 0)==0)
+assert(intArray_getitem(ary, 1)==1)
+delete_intArray(ary)
+
+-- Testing for %array_class(double, doubleArray)
+d = doubleArray(10)
+d[0] = 7
+d[5] = d[0] + 3
+assert(d[5] + d[0] == 17)
+--print(d[5] + d[0])
+
+ptr = d:cast() -- to ptr
+d2 = doubleArray_frompointer(ptr) -- and back to array
+assert(d2[5] + d2[0] == 17)
+--print(d2[5] + d2[0])
+
diff --git a/trunk/Examples/test-suite/lua/li_std_except_runme.lua b/trunk/Examples/test-suite/lua/li_std_except_runme.lua
new file mode 100644
index 000000000..014368fc5
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/li_std_except_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("li_std_except") -- import code
+
+test = li_std_except.Test()
+-- under lua, all the std::exceptions are just turned to strings, so we are only checking that is fails
+assert(pcall(function() test:throw_bad_exception() end)==false)
+assert(pcall(function() test:throw_domain_error() end)==false)
+assert(pcall(function() test:throw_exception() end)==false)
+assert(pcall(function() test:throw_invalid_argument() end)==false)
+assert(pcall(function() test:throw_length_error() end)==false)
+assert(pcall(function() test:throw_logic_error() end)==false)
+assert(pcall(function() test:throw_out_of_range() end)==false)
+assert(pcall(function() test:throw_overflow_error() end)==false)
+assert(pcall(function() test:throw_range_error() end)==false)
+assert(pcall(function() test:throw_runtime_error() end)==false)
+assert(pcall(function() test:throw_underflow_error() end)==false)
diff --git a/trunk/Examples/test-suite/lua/li_std_pair_runme.lua b/trunk/Examples/test-suite/lua/li_std_pair_runme.lua
new file mode 100644
index 000000000..793eaa8c0
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/li_std_pair_runme.lua
@@ -0,0 +1,34 @@
+require("import") -- the import fn
+import("li_std_pair") -- import code
+
+for k,v in pairs(li_std_pair) do _G[k]=v end -- move to global
+
+intPair = makeIntPair(7, 6)
+assert(intPair.first==7 and intPair.second==6)
+
+intPairPtr = makeIntPairPtr(7, 6)
+assert(intPairPtr.first==7 and intPairPtr.second==6)
+
+intPairRef = makeIntPairRef(7, 6)
+assert(intPairRef.first == 7 and intPairRef.second == 6)
+
+intPairConstRef = makeIntPairConstRef(7, 6)
+assert(intPairConstRef.first == 7 and intPairConstRef.second == 6)
+
+-- call fns
+assert(product1(intPair) == 42)
+assert(product2(intPair) == 42)
+assert(product3(intPair) == 42)
+
+-- also use the pointer version
+assert(product1(intPairPtr) == 42)
+assert(product2(intPairPtr) == 42)
+assert(product3(intPairPtr) == 42)
+
+-- or the other types
+assert(product1(intPairRef) == 42)
+assert(product2(intPairRef) == 42)
+assert(product3(intPairRef) == 42)
+assert(product1(intPairConstRef) == 42)
+assert(product2(intPairConstRef) == 42)
+assert(product3(intPairConstRef) == 42)
diff --git a/trunk/Examples/test-suite/lua/li_std_string_runme.lua b/trunk/Examples/test-suite/lua/li_std_string_runme.lua
new file mode 100644
index 000000000..70461f7d1
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/li_std_string_runme.lua
@@ -0,0 +1,113 @@
+require("import") -- the import fn
+import("li_std_string") -- import lib
+
+for k,v in pairs(li_std_string) do _G[k]=v end -- move to global
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- helper to check type
+function is_std_string(s)
+ return type(s)=='userdata' and swig_type(s)=='std::string *'
+end
+
+-- std::string by value is just a Lua string
+s=test_value("foo")
+assert(type(s)=="string" and s=="foo")
+
+-- std::string by const ref is also just a Lua string
+s=test_const_reference("foo")
+assert(type(s)=="string" and s=="foo")
+
+-- std:string* is an object
+obj=test_pointer_out()
+assert(is_std_string(obj) and obj:c_str()=="x") -- check type & value
+
+test_pointer(obj) -- this wants an object
+
+cobj=test_const_pointer_out()
+assert(is_std_string(cobj) and cobj:c_str()=="x") -- check type & value
+
+test_const_pointer(cobj)
+
+-- this shouldnt work, but it does
+-- swig doesnt appear to diff between const object ptrs & object ptrs very well
+test_pointer(cobj) -- this wants an non const object (give it a const one!)
+
+-- refs are also wrappered as ptrs (unless the correct typemaps are applied)
+robj=test_reference_out()
+assert(is_std_string(robj) and robj:c_str()=="test_reference_out message") -- check type & value
+
+test_reference(robj)
+test_reference(obj) -- object ptr is ok
+test_reference(cobj) -- obj const ptr is also ok
+
+-- throwing string
+ok,ex=pcall(test_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw string
+
+ok,ex=pcall(test_const_reference_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw string
+
+-- const ptrs are now converted to lua strings
+-- they used to be std::string*
+ok,ex=pcall(test_const_pointer_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw object
+
+-- ditto non const ptrs
+ok,ex=pcall(test_pointer_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw object
+
+-- testing std::string variables
+-- Global variables
+s = "initial string"
+assert (li_std_string.GlobalString2 == "global string 2")
+li_std_string.GlobalString2 = s
+assert (li_std_string.GlobalString2 == s)
+assert (li_std_string.ConstGlobalString == "const global string")
+
+-- Member variables
+myStructure = Structure()
+assert(myStructure.MemberString2 == "member string 2")
+myStructure.MemberString2 = s
+assert (myStructure.MemberString2 == s)
+assert (myStructure.ConstMemberString == "const member string")
+
+assert (li_std_string.Structure_StaticMemberString2 == "static member string 2")
+li_std_string.Structure_StaticMemberString2 = s
+assert (li_std_string.Structure_StaticMemberString2 == s)
+assert (li_std_string.Structure_ConstStaticMemberString == "const static member string")
+
+
+-- testing the structure (these are some old tests which predated the std::string variable tests above)
+struc=Structure()
+
+assert(type(struc.MemberString2)=="string") -- typemaps make this a string
+assert(type(struc.ConstMemberString)=="string")
+
+-- set a const (should fail with error)
+assert(pcall(function () struc.ConstMemberString="c" end)==false)
+--print(struc.MemberString:data(),struc.MemberString2,struc.ConstMemberString:data())
+
+--check type again
+assert(type(struc.MemberString2)=="string") -- typemaps make this a string
+assert(type(struc.ConstMemberString)=="string")
+
+-- for static types: they are really variables,
+-- so we must still use the module name
+
+-- check static type
+assert(type(li_std_string.Structure_StaticMemberString2)=="string")
+assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
+
+-- try setting (should fail with error)
+--li_std_string.Structure_StaticMemberString2='e'
+assert(pcall(function () li_std_string.Structure_ConstStaticMemberString='f' end)==false)
+--[[print(li_std_string.Structure_StaticMemberString:data(),
+ li_std_string.Structure_StaticMemberString2,
+ li_std_string.Structure_ConstStaticMemberString:data())]]
+
+-- check static type again
+assert(type(li_std_string.Structure_StaticMemberString)=="string")
+assert(type(li_std_string.Structure_StaticMemberString2)=="string")
+assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
diff --git a/trunk/Examples/test-suite/lua/li_std_vector_runme.lua b/trunk/Examples/test-suite/lua/li_std_vector_runme.lua
new file mode 100644
index 000000000..81994b92f
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/li_std_vector_runme.lua
@@ -0,0 +1,66 @@
+require("import") -- the import fn
+import("li_std_vector") -- import code
+
+for k,v in pairs(li_std_vector) do _G[k]=v end -- move to global
+
+iv = IntVector(4)
+for i=0,3 do
+ iv[i] = i
+end
+
+for i=0,3 do assert(iv[i]==i) end
+
+x = average(iv)
+
+function near(x,y) return math.abs(x-y)<0.001 end
+
+assert(near(x,1.5))
+
+rv = RealVector()
+rv:push_back(10)
+rv:push_back(10.5)
+rv:push_back(11)
+rv:push_back(11.5)
+
+a=half(rv)
+for i=0,rv:size()-1 do
+ assert(near(a[i],rv[i]/2))
+end
+
+dv = DoubleVector(10)
+for i=0,9 do dv[i] = i/2.0 end
+
+halve_in_place(dv)
+
+for i=0,9 do
+ assert(near(dv[i],i/4))
+end
+
+sv=StructVector(4)
+
+for i=0,3 do
+ sv[i]=Struct(i)
+end
+
+for i=0,3 do
+ assert( swig_type(sv[i]) =='Struct *' and sv[i].num==i)
+end
+
+-- range checking
+idx=0
+function test_set() iv[idx]=0 end
+function test_get() iv[idx]=0 end
+
+idx=0 --ok
+assert(pcall(test_get)==true)
+assert(pcall(test_set)==true)
+idx=-1 --should error
+assert(pcall(test_get)==false)
+assert(pcall(test_set)==false)
+idx=3 --ok
+assert(pcall(test_get)==true)
+assert(pcall(test_set)==true)
+idx=4 --should error
+assert(pcall(test_get)==false)
+assert(pcall(test_set)==false)
+
diff --git a/trunk/Examples/test-suite/lua/li_typemaps_runme.lua b/trunk/Examples/test-suite/lua/li_typemaps_runme.lua
new file mode 100644
index 000000000..77aeb54e4
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/li_typemaps_runme.lua
@@ -0,0 +1,40 @@
+require("import") -- the import fn
+import("li_typemaps") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- Check double INPUT typemaps
+assert(li_typemaps.in_double(22.22) == 22.22)
+assert(li_typemaps.inr_double(22.22) == 22.22)
+
+-- Check double OUTPUT typemaps
+assert(li_typemaps.out_double(22.22) == 22.22)
+assert(li_typemaps.outr_double(22.22) == 22.22)
+
+-- Check double INOUT typemaps
+assert(li_typemaps.inout_double(22.22) == 22.22)
+assert(li_typemaps.inoutr_double(22.22) == 22.22)
+
+-- check long long
+assert(li_typemaps.in_ulonglong(20)==20)
+assert(li_typemaps.inr_ulonglong(20)==20)
+assert(li_typemaps.out_ulonglong(20)==20)
+assert(li_typemaps.outr_ulonglong(20)==20)
+assert(li_typemaps.inout_ulonglong(20)==20)
+assert(li_typemaps.inoutr_ulonglong(20)==20)
+
+-- check bools
+assert(li_typemaps.in_bool(true)==true)
+assert(li_typemaps.inr_bool(false)==false)
+assert(li_typemaps.out_bool(true)==true)
+assert(li_typemaps.outr_bool(false)==false)
+assert(li_typemaps.inout_bool(true)==true)
+assert(li_typemaps.inoutr_bool(false)==false)
+
+-- the others
+a,b=li_typemaps.inoutr_int2(1,2)
+assert(a==1 and b==2)
+
+f,i=li_typemaps.out_foo(10)
+assert(f.a==10 and i==20)
diff --git a/trunk/Examples/test-suite/lua/member_pointer_runme.lua b/trunk/Examples/test-suite/lua/member_pointer_runme.lua
new file mode 100644
index 000000000..8dddab295
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/member_pointer_runme.lua
@@ -0,0 +1,43 @@
+--Example using pointers to member functions
+
+require("import") -- the import fn
+import("member_pointer") -- import code
+
+for k,v in pairs(member_pointer) do _G[k]=v end
+
+function check(what, expected, actual)
+ assert(expected == actual,"Failed: "..what.." Expected: "..expected.." Actual: "..actual)
+end
+
+-- Get the pointers
+area_pt = areapt()
+perim_pt = perimeterpt()
+
+-- Create some objects
+s = Square(10)
+
+-- Do some calculations
+check ("Square area ", 100.0, do_op(s,area_pt))
+check ("Square perim", 40.0, do_op(s,perim_pt))
+
+-- Try the variables
+-- these have to still be part of the 'member_pointer' table
+memberPtr = member_pointer.areavar
+memberPtr = member_pointer.perimetervar
+
+check ("Square area ", 100.0, do_op(s,member_pointer.areavar))
+check ("Square perim", 40.0, do_op(s,member_pointer.perimetervar))
+
+-- Modify one of the variables
+member_pointer.areavar = perim_pt
+
+check ("Square perimeter", 40.0, do_op(s,member_pointer.areavar))
+
+-- Try the constants
+memberPtr = AREAPT
+memberPtr = PERIMPT
+memberPtr = NULLPT
+
+check ("Square area ", 100.0, do_op(s,AREAPT))
+check ("Square perim", 40.0, do_op(s,PERIMPT))
+
diff --git a/trunk/Examples/test-suite/lua/multi_import_runme.lua b/trunk/Examples/test-suite/lua/multi_import_runme.lua
new file mode 100644
index 000000000..5d4c1360c
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/multi_import_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+-- note: need to import the base class module before the derived class
+-- this is because if the derived class is imported first it doesn't get the base class methods
+import("multi_import_b") -- import code
+import("multi_import_a") -- import code
+
+x = multi_import_b.XXX()
+assert(x:testx() == 0)
+
+y = multi_import_b.YYY()
+assert(y:testx() == 0)
+assert(y:testy() == 1)
+
+z = multi_import_a.ZZZ()
+assert(z:testx() == 0)
+assert(z:testz() == 2)
diff --git a/trunk/Examples/test-suite/lua/newobject1_runme.lua b/trunk/Examples/test-suite/lua/newobject1_runme.lua
new file mode 100644
index 000000000..5de8276db
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/newobject1_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("newobject1") -- import code
+
+foo1 = newobject1.Foo_makeFoo() -- lua doesnt yet support static fns properly
+assert(newobject1.Foo_fooCount() == 1) -- lua doesnt yet support static fns properly
+
+foo2 = foo1:makeMore()
+assert(newobject1.Foo_fooCount() == 2)
+
+foo1 = nil
+collectgarbage()
+assert(newobject1.Foo_fooCount() == 1)
+
+foo2 = nil
+collectgarbage()
+assert(newobject1.Foo_fooCount() == 0)
diff --git a/trunk/Examples/test-suite/lua/newobject2_runme.lua b/trunk/Examples/test-suite/lua/newobject2_runme.lua
new file mode 100644
index 000000000..cf6c87ae7
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/newobject2_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("newobject2",true) -- import code
+
+foo1 = newobject2.makeFoo() -- lua doesnt yet support static fns properly
+assert(newobject2.fooCount() == 1) -- lua doesnt yet support static fns properly
+
+foo2 = newobject2.makeFoo()
+assert(newobject2.fooCount() == 2)
+
+foo1 = nil
+collectgarbage()
+assert(newobject2.fooCount() == 1)
+
+foo2 = nil
+collectgarbage()
+assert(newobject2.fooCount() == 0)
diff --git a/trunk/Examples/test-suite/lua/operator_overload_runme.lua b/trunk/Examples/test-suite/lua/operator_overload_runme.lua
new file mode 100644
index 000000000..1610c1705
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/operator_overload_runme.lua
@@ -0,0 +1,157 @@
+-- demo of lua swig capacilities (operator overloading)
+require("import") -- the import fn
+import("operator_overload") -- import lib
+
+for k,v in pairs(operator_overload) do _G[k]=v end -- move to global
+
+-- first check all the operators are implemented correctly from pure C++ code
+Op_sanity_check()
+
+-- catching undefined variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- test routine:
+a=Op()
+b=Op(5)
+c=Op(b) -- copy construct
+d=Op(2)
+dd=d; -- assignment operator
+
+-- test equality
+assert(a~=b)
+assert(b==c)
+assert(a~=d)
+assert(d==dd)
+
+-- test <
+assert(a<b)
+assert(a<=b)
+assert(b<=c)
+assert(b>=c)
+assert(b>d)
+assert(b>=d)
+
+-- lua does not support += operators: skiping
+
+-- test +
+f=Op(1)
+g=Op(1)
+assert(f+g==Op(2))
+assert(f-g==Op(0))
+assert(f*g==Op(1))
+assert(f/g==Op(1))
+--assert(f%g==Op(0)) -- lua does not support %
+
+-- test unary operators
+--assert((not a)==true) -- lua does not allow overloading for not operator
+--assert((not b)==false) -- lua does not allow overloading for not operator
+
+--lua 5.0.2 defines that unary - is __unm(self,nil)
+--lua 5.1.2 defines that unary - is __unm(self,self)
+--C++ expectes unary - as operator-()
+--however the latest version of SWIG strictly checks the number of args
+--and will complain if too many args are provided
+--therefore disabling these tests for now
+-- (solution will to be not to check args for this test case)
+assert(-a==a)
+assert(-b==Op(-5))
+
+-- test []
+h=Op(3)
+assert(h[0]==3)
+assert(h[1]==0)
+h[0]=2 -- set
+assert(h[0]==2)
+h[1]=2 -- ignored
+assert(h[0]==2)
+assert(h[1]==0)
+
+-- test ()
+i=Op(3)
+assert(i()==3)
+assert(i(1)==4)
+assert(i(1,2)==6)
+
+-- plus add some code to check the __str__ fn
+assert(tostring(Op(1))=="Op(1)")
+assert(tostring(Op(-3))=="Op(-3)")
+
+--[[
+/* Sample test code in C++
+
+#include <assert.h>
+#include <stdio.h>
+
+int main(int argc,char** argv)
+{
+ // test routine:
+ Op a;
+ Op b=5;
+ Op c=b; // copy construct
+ Op d=2;
+
+ // test equality
+ assert(a!=b);
+ assert(b==c);
+ assert(a!=d);
+
+ // test <
+ assert(a<b);
+ assert(a<=b);
+ assert(b<=c);
+ assert(b>=c);
+ assert(b>d);
+ assert(b>=d);
+
+ // test +=
+ Op e=3;
+ e+=d;
+ assert(e==b);
+ e-=c;
+ assert(e==a);
+ e=Op(1);
+ e*=b;
+ assert(e==c);
+ e/=d;
+ assert(e==d);
+ e%=c;
+ assert(e==d);
+
+ // test +
+ Op f(1),g(1);
+ assert(f+g==Op(2));
+ assert(f-g==Op(0));
+ assert(f*g==Op(1));
+ assert(f/g==Op(1));
+ assert(f%g==Op(0));
+
+ // test unary operators
+ assert(!a==true);
+ assert(!b==false);
+ assert(-a==a);
+ assert(-b==Op(-5));
+
+ // test []
+ Op h=3;
+ assert(h[0]==3);
+ assert(h[1]==0);
+ h[0]=2; // set
+ assert(h[0]==2);
+ h[1]=2; // ignored
+ assert(h[0]==2);
+ assert(h[1]==0);
+
+ // test ()
+ Op i=3;
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // plus add some code to check the __str__ fn
+ //assert(str(Op(1))=="Op(1)");
+ //assert(str(Op(-3))=="Op(-3)");
+
+ printf("ok\n");
+}
+*/
+]]
diff --git a/trunk/Examples/test-suite/lua/overload_simple_runme.lua b/trunk/Examples/test-suite/lua/overload_simple_runme.lua
new file mode 100644
index 000000000..97b1876b6
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/overload_simple_runme.lua
@@ -0,0 +1,55 @@
+require("import") -- the import fn
+import("overload_simple") -- import code
+for k,v in pairs(overload_simple) do _G[k]=v end -- move to global
+
+-- lua has only one numeric type, foo(int) and foo(double) are the same
+-- whichever one was wrapper first will be used
+
+assert(foo(3)=="foo:int" or foo(3)=="foo:double") -- could be either
+assert(foo("hello")=="foo:char *")
+
+f=Foo()
+b=Bar()
+
+assert(foo(f)=="foo:Foo *")
+assert(foo(b)=="foo:Bar *")
+
+v = malloc_void(32)
+
+assert(foo(v) == "foo:void *")
+
+s = Spam()
+
+assert(s:foo(3) == "foo:int" or s:foo(3.0) == "foo:double") -- could be either
+assert(s:foo("hello") == "foo:char *")
+assert(s:foo(f) == "foo:Foo *")
+assert(s:foo(b) == "foo:Bar *")
+assert(s:foo(v) == "foo:void *")
+
+assert(Spam_bar(3) == "bar:int" or Spam_bar(3.0) == "bar:double")
+assert(Spam_bar("hello") == "bar:char *")
+assert(Spam_bar(f) == "bar:Foo *")
+assert(Spam_bar(b) == "bar:Bar *")
+assert(Spam_bar(v) == "bar:void *")
+
+-- Test constructors
+
+s = Spam()
+assert(s.type == "none")
+
+s = Spam(3)
+assert(s.type == "int" or s.type == "double")
+
+s = Spam("hello")
+assert(s.type == "char *")
+
+s = Spam(f)
+assert(s.type == "Foo *")
+
+s = Spam(b)
+assert(s.type == "Bar *")
+
+s = Spam(v)
+assert(s.type == "void *")
+
+free_void(v)
diff --git a/trunk/Examples/test-suite/lua/overload_template_fast_runme.lua b/trunk/Examples/test-suite/lua/overload_template_fast_runme.lua
new file mode 100644
index 000000000..6663cb0b5
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/overload_template_fast_runme.lua
@@ -0,0 +1,81 @@
+require("import") -- the import fn
+import("overload_template_fast") -- import code
+for k,v in pairs(overload_template_fast) do _G[k]=v end -- move to global
+
+-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
+-- whichever one was wrapper first will be used (which is int)
+
+f = foo()
+
+a = maximum(3,4)
+
+-- mix 1
+assert(mix1("hi") == 101)
+assert(mix1(1.0, 1.0) == 102)
+assert(mix1(1.0) == 103)
+
+-- mix 2
+assert(mix2("hi") == 101)
+assert(mix2(1.0, 1.0) == 102)
+assert(mix2(1.0) == 103)
+
+-- mix 3
+assert(mix3("hi") == 101)
+assert(mix3(1.0, 1.0) == 102)
+assert(mix3(1.0) == 103)
+
+-- Combination 1
+assert(overtparams1(100) == 10)
+assert(overtparams1(100.0, 100) == 20)
+
+-- Combination 2
+assert(overtparams2(100.0, 100) == 40)
+
+-- Combination 3
+assert(overloaded() == 60)
+assert(overloaded(100.0, 100) == 70)
+
+-- Combination 4
+assert(overloadedagain("hello") == 80)
+assert(overloadedagain() == 90)
+
+-- specializations
+assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works
+assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto
+assert(specialization("hi", "hi") == 201)
+
+-- simple specialization
+xyz()
+xyz_int()
+xyz_double()
+
+-- a bit of everything
+assert(overload("hi") == 0)
+assert(overload(1) == 10)
+assert(overload(1, 1) == 20)
+assert(overload(1, "hello") == 30)
+
+k = Klass()
+assert(overload(k) == 10)
+assert(overload(k, k) == 20)
+assert(overload(k, "hello") == 30)
+-- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c)
+--print(overload(10.0, "hi"))
+--assert(overload(10.0, "hi") == 40)
+assert(overload() == 50)
+
+-- everything put in a namespace
+assert(nsoverload("hi") == 1000,"nsoverload()")
+assert(nsoverload(1) == 1010,"nsoverload(int t)")
+assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)")
+assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)")
+assert(nsoverload(k) == 1010,"nsoverload(Klass t)")
+assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)")
+assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)")
+-- again this one fails
+--assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)")
+assert(nsoverload() == 1050,"nsoverload(const char *)")
+
+A_foo(1)
+b = B()
+b:foo(1)
diff --git a/trunk/Examples/test-suite/lua/overload_template_runme.lua b/trunk/Examples/test-suite/lua/overload_template_runme.lua
new file mode 100644
index 000000000..19cc7e9dd
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/overload_template_runme.lua
@@ -0,0 +1,81 @@
+require("import") -- the import fn
+import("overload_template") -- import code
+for k,v in pairs(overload_template) do _G[k]=v end -- move to global
+
+-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
+-- whichever one was wrapper first will be used (which is int)
+
+f = foo()
+
+a = maximum(3,4)
+
+-- mix 1
+assert(mix1("hi") == 101)
+assert(mix1(1.0, 1.0) == 102)
+assert(mix1(1.0) == 103)
+
+-- mix 2
+assert(mix2("hi") == 101)
+assert(mix2(1.0, 1.0) == 102)
+assert(mix2(1.0) == 103)
+
+-- mix 3
+assert(mix3("hi") == 101)
+assert(mix3(1.0, 1.0) == 102)
+assert(mix3(1.0) == 103)
+
+-- Combination 1
+assert(overtparams1(100) == 10)
+assert(overtparams1(100.0, 100) == 20)
+
+-- Combination 2
+assert(overtparams2(100.0, 100) == 40)
+
+-- Combination 3
+assert(overloaded() == 60)
+assert(overloaded(100.0, 100) == 70)
+
+-- Combination 4
+assert(overloadedagain("hello") == 80)
+assert(overloadedagain() == 90)
+
+-- specializations
+assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works
+assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto
+assert(specialization("hi", "hi") == 201)
+
+-- simple specialization
+xyz()
+xyz_int()
+xyz_double()
+
+-- a bit of everything
+assert(overload("hi") == 0)
+assert(overload(1) == 10)
+assert(overload(1, 1) == 20)
+assert(overload(1, "hello") == 30)
+
+k = Klass()
+assert(overload(k) == 10)
+assert(overload(k, k) == 20)
+assert(overload(k, "hello") == 30)
+-- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c)
+--print(overload(10.0, "hi"))
+--assert(overload(10.0, "hi") == 40)
+assert(overload() == 50)
+
+-- everything put in a namespace
+assert(nsoverload("hi") == 1000,"nsoverload()")
+assert(nsoverload(1) == 1010,"nsoverload(int t)")
+assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)")
+assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)")
+assert(nsoverload(k) == 1010,"nsoverload(Klass t)")
+assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)")
+assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)")
+-- again this one fails
+--assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)")
+assert(nsoverload() == 1050,"nsoverload(const char *)")
+
+A_foo(1)
+b = B()
+b:foo(1)
diff --git a/trunk/Examples/test-suite/lua/pointer_reference_runme.lua b/trunk/Examples/test-suite/lua/pointer_reference_runme.lua
new file mode 100644
index 000000000..959d5a2a3
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/pointer_reference_runme.lua
@@ -0,0 +1,11 @@
+require("import") -- the import fn
+import("pointer_reference",true) -- import code
+
+
+s=pointer_reference.get()
+assert(s.value == 10)
+
+ss = pointer_reference.Struct(20);
+pointer_reference.set(ss);
+assert(pointer_reference.Struct_instance.value == 20)
+
diff --git a/trunk/Examples/test-suite/lua/primitive_ref_runme.lua b/trunk/Examples/test-suite/lua/primitive_ref_runme.lua
new file mode 100644
index 000000000..d3da5dc49
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/primitive_ref_runme.lua
@@ -0,0 +1,32 @@
+require("import") -- the import fn
+import("primitive_ref") -- import code
+pr=primitive_ref --alias
+
+assert(pr.ref_int(3)==3)
+
+assert(pr.ref_uint(3) == 3)
+
+assert(pr.ref_short(3) == 3)
+
+assert(pr.ref_ushort(3) == 3)
+
+assert(pr.ref_long(3) == 3)
+
+assert(pr.ref_ulong(3) == 3)
+
+assert(pr.ref_schar(3) == 3)
+
+assert(pr.ref_uchar(3) == 3)
+
+assert(pr.ref_float(3.5) == 3.5)
+
+assert(pr.ref_double(3.5) == 3.5)
+
+assert(pr.ref_bool(true) == true)
+
+assert(pr.ref_char('x') == 'x')
+
+assert(pr.ref_over(0) == 0)
+
+a=pr.A(12)
+assert(pr.ref_over(a)==12)
diff --git a/trunk/Examples/test-suite/lua/ret_by_value_runme.lua b/trunk/Examples/test-suite/lua/ret_by_value_runme.lua
new file mode 100644
index 000000000..f1f5c6ce2
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/ret_by_value_runme.lua
@@ -0,0 +1,6 @@
+require("import") -- the import fn
+import("ret_by_value") -- import code
+
+a = ret_by_value.get_test()
+assert(a.myInt == 100)
+assert(a.myShort == 200)
diff --git a/trunk/Examples/test-suite/lua/sizet_runme.lua b/trunk/Examples/test-suite/lua/sizet_runme.lua
new file mode 100644
index 000000000..fbaea6a04
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/sizet_runme.lua
@@ -0,0 +1,9 @@
+require("import") -- the import fn
+import("sizet") -- import code
+
+s = 2000
+s = sizet.test1(s+1)
+s = sizet.test2(s+1)
+s = sizet.test3(s+1)
+s = sizet.test4(s+1)
+assert(s == 2004)
diff --git a/trunk/Examples/test-suite/lua/smart_pointer_overload_runme.lua b/trunk/Examples/test-suite/lua/smart_pointer_overload_runme.lua
new file mode 100644
index 000000000..b83bedee2
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/smart_pointer_overload_runme.lua
@@ -0,0 +1,14 @@
+require("import") -- the import fn
+import("smart_pointer_overload") -- import code
+for k,v in pairs(smart_pointer_overload) do _G[k]=v end -- move to global
+
+f = Foo()
+b = Bar(f)
+
+assert(f:test(3) == 1)
+--assert(f:test(3.5) == 2) -- won't work due to being unable to overloads
+assert(f:test("hello") == 3)
+
+assert(b:test(3) == 1)
+--assert(b:test(3.5) == 2) -- won't work due to being unable to overloads
+assert(b:test("hello") == 3)
diff --git a/trunk/Examples/test-suite/lua/template_default_arg_runme.lua b/trunk/Examples/test-suite/lua/template_default_arg_runme.lua
new file mode 100644
index 000000000..ebb22ed63
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/template_default_arg_runme.lua
@@ -0,0 +1,63 @@
+require("import") -- the import fn
+import("template_default_arg") -- import code
+--for k,v in pairs(template_default_arg) do _G[k]=v end -- move to global
+
+helloInt = template_default_arg.Hello_int()
+helloInt:foo(template_default_arg.Hello_int_hi)
+
+x = template_default_arg.X_int()
+assert(x:meth(20.0, 200) == 200,"X_int test 1 failed")
+assert(x:meth(20) == 20,"X_int test 2 failed")
+assert(x:meth() == 0,"X_int test 3 failed")
+
+y = template_default_arg.Y_unsigned()
+assert(y:meth(20.0, 200) == 200,"Y_unsigned test 1 failed")
+assert(y:meth(20) == 20,"Y_unsigned test 2 failed")
+assert(y:meth() == 0,"Y_unsigned test 3 failed")
+
+x = template_default_arg.X_longlong()
+x = template_default_arg.X_longlong(20.0)
+x = template_default_arg.X_longlong(20.0, 200) -- note: long longs just treated as another number
+
+x = template_default_arg.X_int()
+x = template_default_arg.X_int(20.0)
+x = template_default_arg.X_int(20.0, 200)
+
+x = template_default_arg.X_hello_unsigned()
+x = template_default_arg.X_hello_unsigned(20.0)
+x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int())
+
+y = template_default_arg.Y_hello_unsigned()
+y:meth(20.0, template_default_arg.Hello_int())
+y:meth(template_default_arg.Hello_int())
+y:meth()
+
+fz = template_default_arg.Foo_Z_8()
+x = template_default_arg.X_Foo_Z_8()
+fzc = x:meth(fz)
+
+-- Templated functions
+
+-- plain function: int ott(Foo<int>)
+assert(template_default_arg.ott(template_default_arg.Foo_int()) == 30,"ott test 1 failed")
+
+-- %template(ott) ott<int, int>
+assert(template_default_arg.ott() == 10,"ott test 2 failed")
+assert(template_default_arg.ott(1) == 10,"ott test 3 failed")
+assert(template_default_arg.ott(1, 1) == 10,"ott test 4 failed")
+
+assert(template_default_arg.ott("hi") == 20,"ott test 5 failed")
+assert(template_default_arg.ott("hi", 1) == 20,"ott test 6 failed")
+assert(template_default_arg.ott("hi", 1, 1) == 20,"ott test 7 failed")
+
+-- %template(ott) ott<const char *>
+assert(template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") == 40,"ott test 8 failed")
+assert(template_default_arg.ottstring(template_default_arg.Hello_int()) == 40,"ott test 9 failed")
+
+-- %template(ott) ott<int>
+assert(template_default_arg.ottint(template_default_arg.Hello_int(), 1) == 50,"ott test 10 failed")
+assert(template_default_arg.ottint(template_default_arg.Hello_int()) == 50,"ott test 11 failed")
+
+-- %template(ott) ott<double>
+assert(template_default_arg.ott(template_default_arg.Hello_int(), 1.0) == 60,"ott test 12 failed")
+assert(template_default_arg.ott(template_default_arg.Hello_int()) == 60,"ott test 13 failed")
diff --git a/trunk/Examples/test-suite/lua/voidtest_runme.lua b/trunk/Examples/test-suite/lua/voidtest_runme.lua
new file mode 100644
index 000000000..e185dbd1f
--- /dev/null
+++ b/trunk/Examples/test-suite/lua/voidtest_runme.lua
@@ -0,0 +1,37 @@
+-- demo of lua swig
+require("import") -- the import fn
+import("voidtest") -- import lib
+
+-- test calling functions
+voidtest.globalfunc()
+f = voidtest.Foo()
+f:memberfunc() -- member fns must have : not a .
+
+voidtest.Foo_staticmemberfunc() -- static member fns are still a little messy
+
+v1 = voidtest.vfunc1(f)
+v2 = voidtest.vfunc2(f)
+
+assert(swig_equals(v1,v2)) -- a raw equals will not work, we look at the raw pointers
+
+v3 = voidtest.vfunc3(v1)
+assert(swig_equals(v3,f))
+
+v4 = voidtest.vfunc1(f)
+assert(swig_equals(v4,v1))
+
+v3:memberfunc()
+
+-- also testing nil's support
+-- nil, are acceptable anywhere a pointer is
+n1 = voidtest.vfunc1(nil)
+n2 = voidtest.vfunc2(nil)
+
+assert(n1==nil)
+assert(n2==nil)
+
+n3 = voidtest.vfunc3(n1)
+n4 = voidtest.vfunc1(nil)
+
+assert(n3==nil)
+assert(n4==nil)
diff --git a/trunk/Examples/test-suite/member_pointer.i b/trunk/Examples/test-suite/member_pointer.i
new file mode 100644
index 000000000..f03528cd5
--- /dev/null
+++ b/trunk/Examples/test-suite/member_pointer.i
@@ -0,0 +1,101 @@
+%module member_pointer
+
+%inline %{
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+extern double do_op(Shape *s, double (Shape::*m)(void));
+
+/* Functions that return member pointers */
+
+extern double (Shape::*areapt())(void);
+extern double (Shape::*perimeterpt())(void);
+
+/* Global variables that are member pointers */
+extern double (Shape::*areavar)(void);
+extern double (Shape::*perimetervar)(void);
+
+%}
+
+%{
+# define SWIG_M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return SWIG_M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*SWIG_M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
+
+double do_op(Shape *s, double (Shape::*m)(void)) {
+ return (s->*m)();
+}
+
+double (Shape::*areapt())(void) {
+ return &Shape::area;
+}
+
+double (Shape::*perimeterpt())(void) {
+ return &Shape::perimeter;
+}
+
+/* Member pointer variables */
+double (Shape::*areavar)(void) = &Shape::area;
+double (Shape::*perimetervar)(void) = &Shape::perimeter;
+%}
+
+
+/* Some constants */
+%constant double (Shape::*AREAPT)(void) = &Shape::area;
+%constant double (Shape::*PERIMPT)(void) = &Shape::perimeter;
+%constant double (Shape::*NULLPT)(void) = 0;
+
diff --git a/trunk/Examples/test-suite/member_template.i b/trunk/Examples/test-suite/member_template.i
new file mode 100644
index 000000000..6a1cb3363
--- /dev/null
+++ b/trunk/Examples/test-suite/member_template.i
@@ -0,0 +1,28 @@
+%module member_template
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+
+
+%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/trunk/Examples/test-suite/memberin1.i b/trunk/Examples/test-suite/memberin1.i
new file mode 100644
index 000000000..920323044
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/memberin_extend.i b/trunk/Examples/test-suite/memberin_extend.i
new file mode 100644
index 000000000..c6eb10526
--- /dev/null
+++ b/trunk/Examples/test-suite/memberin_extend.i
@@ -0,0 +1,33 @@
+%module memberin_extend
+
+// Tests memberin typemap is not used for %extend.
+// The test extends the struct with a pseudo member variable
+
+%inline %{
+#include <string>
+struct ExtendMe {
+};
+%}
+
+%{
+#include <map>
+std::map<ExtendMe*, char *> ExtendMeStringMap;
+void ExtendMe_thing_set(ExtendMe *self, const char *val) {
+ char *old_val = ExtendMeStringMap[self];
+ delete [] old_val;
+ if (val) {
+ ExtendMeStringMap[self] = new char[strlen(val)+1];
+ strcpy(ExtendMeStringMap[self], val);
+ } else {
+ ExtendMeStringMap[self] = 0;
+ }
+}
+char * ExtendMe_thing_get(ExtendMe *self) {
+ return ExtendMeStringMap[self];
+}
+%}
+
+%extend ExtendMe {
+ char *thing;
+}
+
diff --git a/trunk/Examples/test-suite/memberin_extend_c.i b/trunk/Examples/test-suite/memberin_extend_c.i
new file mode 100644
index 000000000..0599e65a0
--- /dev/null
+++ b/trunk/Examples/test-suite/memberin_extend_c.i
@@ -0,0 +1,38 @@
+%module memberin_extend_c
+
+/* Example from the Manual, section 5.5.6: "Adding member functions to C structures" */
+
+%{
+typedef struct {
+ char name[50];
+} Person;
+%}
+
+typedef struct {
+ %extend {
+ char name[50];
+ }
+} Person;
+
+%{
+#include <ctype.h>
+#include <string.h>
+
+void make_upper(char *name) {
+ char *c;
+ for (c = name; *c; ++c)
+ *c = (char)toupper((int)*c);
+}
+
+/* Specific implementation of set/get functions forcing capitalization */
+
+char *Person_name_get(Person *p) {
+ make_upper(p->name);
+ return p->name;
+}
+
+void Person_name_set(Person *p, char *val) {
+ strncpy(p->name,val,50);
+ make_upper(p->name);
+}
+%}
diff --git a/trunk/Examples/test-suite/minherit.i b/trunk/Examples/test-suite/minherit.i
new file mode 100644
index 000000000..fed8b029c
--- /dev/null
+++ b/trunk/Examples/test-suite/minherit.i
@@ -0,0 +1,82 @@
+// This module tests multiple inheritance, typedef handling, and some
+// truly horrible parts of the SWIG type system. This is only tested
+// for Python since not all language modules support multiple-inheritance.
+// However, if it works for Python, things should be working for other
+// modules.
+
+%module(ruby_minherit="1") minherit
+
+#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL)
+
+%inline %{
+
+class Foo {
+private:
+ int x;
+public:
+ Foo() { x = 1; }
+ virtual ~Foo() {}
+ virtual int xget() { return x; };
+};
+typedef Foo *FooPtr;
+
+FooPtr toFooPtr(Foo *f) { return f; }
+
+class Bar {
+private:
+ int y;
+public:
+ Bar() { y = 2; }
+ virtual ~Bar() {}
+ virtual int yget() { return y; }
+};
+
+typedef Bar *BarPtr;
+BarPtr toBarPtr(Bar *f) { return f; }
+
+class FooBar : public Foo, public Bar {
+private:
+ int z;
+public:
+ FooBar() { z = 3; }
+ virtual int zget() { return z; }
+};
+
+typedef FooBar *FooBarPtr;
+FooBarPtr toFooBarPtr(FooBar *f) { return f; }
+
+class Spam: public FooBar {
+private:
+ int w;
+public:
+ Spam() { w = 4; }
+ virtual int wget() { return w; }
+};
+
+typedef Spam *SpamPtr;
+SpamPtr toSpamPtr(Spam *f) { return f; }
+
+int xget(FooPtr f) {
+ return f->xget();
+}
+
+int yget(BarPtr f) {
+ return f->yget();
+}
+
+int zget(FooBarPtr f) {
+ return f->zget();
+}
+
+int wget(SpamPtr f) {
+ return f->wget();
+}
+%}
+
+#endif
+
+
+// Was causing runtime error in Ruby
+%include <std_vector.i>
+%template(IntVector) std::vector<int>;
+
diff --git a/trunk/Examples/test-suite/minherit2.i b/trunk/Examples/test-suite/minherit2.i
new file mode 100644
index 000000000..1bca4fc48
--- /dev/null
+++ b/trunk/Examples/test-suite/minherit2.i
@@ -0,0 +1,94 @@
+%module minherit2
+
+// A multiple inheritance example, mainly for Java and C#.
+// The example shows how it is possible to turn C++ abstract base classes into Java/C# interface.
+// In the future, all this trouble might be more automated.
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe;
+
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+
+#if defined(SWIGCSHARP)
+#define javaclassmodifiers csclassmodifiers
+#define javabody csbody
+#define javafinalize csfinalize
+#define javadestruct csdestruct
+#define javaout csout
+#define javainterfaces csinterfaces
+#define javabase csbase
+#endif
+
+// Modify multiple inherited base classes into inheriting interfaces
+%typemap(javainterfaces) RemoteMpe "IRemoteSyncIO, IRemoteAsyncIO";
+%typemap(javabase, replace="1") RemoteMpe "";
+
+// Turn the proxy class into an interface
+%typemap(javaclassmodifiers) IRemoteSyncIO "public interface";
+%typemap(javaclassmodifiers) IRemoteAsyncIO "public interface";
+%typemap(javabody) IRemoteSyncIO "";
+%typemap(javabody) IRemoteAsyncIO "";
+%typemap(javafinalize) IRemoteSyncIO "";
+%typemap(javafinalize) IRemoteAsyncIO "";
+%typemap(javadestruct) IRemoteSyncIO "";
+%typemap(javadestruct) IRemoteAsyncIO "";
+
+// Turn the methods into abstract methods
+%typemap(javaout) void IRemoteSyncIO::syncmethod ";"
+%typemap(javaout) void IRemoteAsyncIO::asyncmethod ";"
+#if defined(SWIGJAVA)
+%javamethodmodifiers IRemoteSyncIO::syncmethod "abstract public";
+%javamethodmodifiers IRemoteAsyncIO::asyncmethod "abstract public";
+// Features are inherited by derived classes, so override this
+%javamethodmodifiers RemoteMpe::syncmethod "public"
+%javamethodmodifiers RemoteMpe::asyncmethod "public"
+#elif defined(SWIGCSHARP)
+%csmethodmodifiers IRemoteSyncIO::syncmethod "";
+%csmethodmodifiers IRemoteAsyncIO::asyncmethod "";
+// Features are inherited by derived classes, so override this
+%csmethodmodifiers RemoteMpe::syncmethod "public"
+%csmethodmodifiers RemoteMpe::asyncmethod "public"
+#endif
+
+#endif
+
+
+%inline %{
+class IRemoteSyncIO
+{
+public:
+ virtual ~IRemoteSyncIO () {}
+ virtual void syncmethod() = 0;
+protected:
+ IRemoteSyncIO () {}
+
+private:
+ IRemoteSyncIO (const IRemoteSyncIO&);
+ IRemoteSyncIO& operator= (const IRemoteSyncIO&);
+};
+
+class IRemoteAsyncIO
+{
+public:
+ virtual ~IRemoteAsyncIO () {}
+ virtual void asyncmethod() = 0;
+protected:
+ IRemoteAsyncIO () {}
+
+private:
+ IRemoteAsyncIO (const IRemoteAsyncIO&);
+ IRemoteAsyncIO& operator= (const IRemoteAsyncIO&);
+};
+
+class RemoteMpe : public IRemoteSyncIO, public IRemoteAsyncIO
+{
+public:
+ virtual void syncmethod() {}
+ virtual void asyncmethod() {}
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/mixed_types.i b/trunk/Examples/test-suite/mixed_types.i
new file mode 100644
index 000000000..274cfcf7f
--- /dev/null
+++ b/trunk/Examples/test-suite/mixed_types.i
@@ -0,0 +1,164 @@
+%module mixed_types
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hello; /* Ruby, wrong constant name */
+
+%inline
+{
+ const void* ref_pointer(const void*& a) {
+ return a;
+ }
+
+ struct A
+ {
+ };
+
+ const A* ref_pointer(A* const& a) {
+ return a;
+ }
+
+ const A** ref_pointer_1(const A**& a) {
+ return a;
+ }
+
+ A* pointer_1(A* a) {
+ return a;
+ }
+
+ const A& ref_const(const A& a) {
+ return a;
+ }
+
+ enum Hello { hi,hello };
+
+ int sint(int a) {
+ return a;
+ }
+
+ const int& ref_int(const int& a) {
+ return a;
+ }
+
+ Hello senum(Hello a) {
+ return a;
+ }
+
+ const Hello& ref_enum(const Hello& a) {
+ return a;
+ }
+
+ typedef A *Aptr;
+ const Aptr& rptr_const(const Aptr& a) {
+ return a;
+ }
+
+ const Aptr& rptr_const2(const Aptr& a) {
+ return a;
+ }
+
+ const void*& rptr_void(const void*& a) {
+ return a;
+ }
+
+ const A& cref_a(const A& a) {
+ return a;
+ }
+
+ A& ref_a(A& a) {
+ return a;
+ }
+
+
+ template <class T> struct NameT {
+ };
+
+
+ typedef char name[8];
+ typedef char namea[];
+
+ typedef NameT<char> name_t[8];
+
+ char* test_a(char hello[8],
+ char hi[],
+ const char chello[8],
+ const char chi[]) {
+ return hi;
+ }
+
+ int test_b(name n2) {
+ return 1;
+ }
+
+/* gcc doesn't like this one. Removing until reason resolved.*/
+ int test_c(const name& n1) {
+ return 1;
+ }
+
+ int test_d(name* n1) {
+ return 1;
+ }
+
+ int test_e(const name_t& n1) {
+ return 1;
+ }
+
+ int test_f(name_t n1) {
+ return 1;
+ }
+
+ int test_g(name_t* n1) {
+ return 1;
+ }
+
+ struct Foo
+ {
+ int foo(const Aptr&a);
+ int foon(const char (&a)[8]);
+ };
+
+ inline int Foo::foo(A* const& a) { return 1; }
+
+}
+
+%{
+ inline int Foo::foon(const name& a) { return a[0]; }
+%}
+
+
+
+%inline %{
+#define ARRAY_LEN_X 2
+#define ARRAY_LEN_Y 4
+
+typedef enum {One, Two, Three, Four, Five} finger;
+
+typedef struct {
+ double double_field;
+} SimpleStruct;
+
+char array_c [ARRAY_LEN_X][ARRAY_LEN_Y];
+signed char array_sc[ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned char array_uc[ARRAY_LEN_X][ARRAY_LEN_Y];
+short array_s [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y];
+int array_i [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned int array_ui[ARRAY_LEN_X][ARRAY_LEN_Y];
+long array_l [ARRAY_LEN_X][ARRAY_LEN_Y];
+unsigned long array_ul[ARRAY_LEN_X][ARRAY_LEN_Y];
+long long array_ll[ARRAY_LEN_X][ARRAY_LEN_Y];
+float array_f [ARRAY_LEN_X][ARRAY_LEN_Y];
+double array_d [ARRAY_LEN_X][ARRAY_LEN_Y];
+SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y];
+SimpleStruct* array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
+int* array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y];
+finger array_enum[ARRAY_LEN_X][ARRAY_LEN_Y];
+finger* array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
+const int array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} };
+
+void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {}
+
+int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
+ return array[x][y];
+}
+%}
+
diff --git a/trunk/Examples/test-suite/mod.h b/trunk/Examples/test-suite/mod.h
new file mode 100644
index 000000000..aae629850
--- /dev/null
+++ b/trunk/Examples/test-suite/mod.h
@@ -0,0 +1,34 @@
+
+
+class C;
+
+class A
+{
+public:
+ A() {}
+ C* GetC() { return NULL; }
+
+ void DoSomething(A* a) {}
+};
+
+
+class B : public A
+{
+public:
+ B() {}
+
+};
+
+
+class C : public B
+{
+public:
+ C() {}
+};
+
+
+class D : public C
+{
+public:
+ D() {}
+};
diff --git a/trunk/Examples/test-suite/mod.list b/trunk/Examples/test-suite/mod.list
new file mode 100644
index 000000000..41350aefa
--- /dev/null
+++ b/trunk/Examples/test-suite/mod.list
@@ -0,0 +1,2 @@
+mod_a
+mod_b
diff --git a/trunk/Examples/test-suite/mod_a.i b/trunk/Examples/test-suite/mod_a.i
new file mode 100644
index 000000000..bc8c163f4
--- /dev/null
+++ b/trunk/Examples/test-suite/mod_a.i
@@ -0,0 +1,24 @@
+%module mod_a
+
+%{
+#include "mod.h"
+%}
+
+
+class C;
+
+class A
+{
+public:
+ A() {}
+ C* GetC() { return NULL; }
+
+ void DoSomething(A* a) {}
+};
+
+
+class B : public A
+{
+public:
+ B();
+};
diff --git a/trunk/Examples/test-suite/mod_b.i b/trunk/Examples/test-suite/mod_b.i
new file mode 100644
index 000000000..3bb8c8bf3
--- /dev/null
+++ b/trunk/Examples/test-suite/mod_b.i
@@ -0,0 +1,22 @@
+%module mod_b
+
+%{
+#include "mod.h"
+%}
+
+
+%import mod_a.i
+
+
+class C : public B
+{
+public:
+ C() {}
+};
+
+
+class D : public C
+{
+public:
+ D() {}
+};
diff --git a/trunk/Examples/test-suite/multi_import.h b/trunk/Examples/test-suite/multi_import.h
new file mode 100644
index 000000000..fa7a460e9
--- /dev/null
+++ b/trunk/Examples/test-suite/multi_import.h
@@ -0,0 +1,17 @@
+class XXX
+{
+ public:
+ int testx() { return 0;}
+};
+
+class YYY : public XXX
+{
+ public:
+ int testy() { return 1;}
+};
+
+class ZZZ : public XXX
+{
+ public:
+ int testz() { return 2;}
+};
diff --git a/trunk/Examples/test-suite/multi_import.list b/trunk/Examples/test-suite/multi_import.list
new file mode 100644
index 000000000..6f7f98cae
--- /dev/null
+++ b/trunk/Examples/test-suite/multi_import.list
@@ -0,0 +1,2 @@
+multi_import_a
+multi_import_b
diff --git a/trunk/Examples/test-suite/multi_import_a.i b/trunk/Examples/test-suite/multi_import_a.i
new file mode 100644
index 000000000..62d7cc0b8
--- /dev/null
+++ b/trunk/Examples/test-suite/multi_import_a.i
@@ -0,0 +1,15 @@
+/* This was reported in Bug #1735931 */
+
+%module multi_import_a
+
+%import multi_import_b.i
+
+%{
+#include "multi_import.h"
+%}
+
+class ZZZ : public XXX
+{
+public:
+ int testz();
+};
diff --git a/trunk/Examples/test-suite/multi_import_b.i b/trunk/Examples/test-suite/multi_import_b.i
new file mode 100644
index 000000000..a2be27055
--- /dev/null
+++ b/trunk/Examples/test-suite/multi_import_b.i
@@ -0,0 +1,13 @@
+%module multi_import_b
+
+%include multi_import_c.i
+
+%{
+#include "multi_import.h"
+%}
+
+class YYY : public XXX
+{
+public:
+ int testy();
+};
diff --git a/trunk/Examples/test-suite/multi_import_c.i b/trunk/Examples/test-suite/multi_import_c.i
new file mode 100644
index 000000000..854e6b136
--- /dev/null
+++ b/trunk/Examples/test-suite/multi_import_c.i
@@ -0,0 +1,5 @@
+class XXX
+{
+public:
+ int testx();
+};
diff --git a/trunk/Examples/test-suite/multiple_inheritance.i b/trunk/Examples/test-suite/multiple_inheritance.i
new file mode 100644
index 000000000..1fc68eef9
--- /dev/null
+++ b/trunk/Examples/test-suite/multiple_inheritance.i
@@ -0,0 +1,92 @@
+/* This was broken in the perl module. See bug 962115
+It tests basic multiple inheritance */
+
+%module(ruby_minherit="1") multiple_inheritance
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */
+
+
+%inline %{
+
+class Bar {
+public:
+ virtual ~Bar()
+ {
+ }
+
+ virtual int bar() { return 1; }
+};
+
+class Foo {
+public:
+ virtual ~Foo()
+ {
+ }
+
+ virtual int foo() { return 2; }
+};
+
+template<class T> class Spam {
+public:
+ virtual ~Spam()
+ {
+ }
+
+ virtual int spam(const T& t) { return 100; }
+};
+%}
+
+%template(SpamInt) Spam<int>;
+
+%inline %{
+class FooBar : public Foo, public Bar {
+public:
+ virtual int fooBar() { return 3; }
+};
+
+class FooBarSpam : public Foo, public Bar, public Spam<int> {
+public:
+ virtual int fooBarSpam() { return 4; }
+};
+
+%}
+
+// Languages that don't support multiple inheritance should inherit from one of the non-ignored classes
+%ignore IgnoreMe;
+%ignore IgnoreMeToo;
+
+%inline %{
+class IgnoreMe {
+public:
+ virtual int ignoreme() { return 5; }
+ virtual ~IgnoreMe() {}
+};
+class IgnoreMeToo {
+public:
+ virtual int ignoremetoo() { return 6; }
+ virtual ~IgnoreMeToo() {}
+};
+class IgnoreDerived1 : public IgnoreMe, public Bar {
+public:
+ virtual int ignorederived1() { return 7; }
+};
+class IgnoreDerived2 : public IgnoreMe, public IgnoreMeToo, public Bar {
+public:
+ virtual int ignorederived2() { return 8; }
+};
+class IgnoreDerived3 : public IgnoreMe, public Bar, public IgnoreMeToo {
+public:
+ virtual int ignorederived3() { return 9; }
+};
+class IgnoreDerived4 : public Bar, public IgnoreMe, public IgnoreMeToo {
+public:
+ virtual int ignorederived4() { return 10; }
+};
+%}
+
diff --git a/trunk/Examples/test-suite/multivalue.i b/trunk/Examples/test-suite/multivalue.i
new file mode 100644
index 000000000..59f3d7643
--- /dev/null
+++ b/trunk/Examples/test-suite/multivalue.i
@@ -0,0 +1,52 @@
+/* -*- c -*- */
+
+%module multivalue
+
+#ifdef SWIGGUILE
+
+/* Multiple values as lists. By default, if more than one value is to
+be returned, a list of the values is created and returned; to switch
+back to this behavior, use: */
+%values_as_list;
+
+void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
+
+/* Multiple values as vectors. By issueing: */
+%values_as_vector;
+/* vectors instead of lists will be used. */
+
+void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
+
+/* Multiple values for multiple-value continuations.
+ (This is the most elegant way.) By issueing: */
+%multiple_values;
+/* multiple values are passed to the multiple-value
+ continuation, as created by `call-with-values' or the
+ convenience macro `receive'. (See the Scheme file.) */
+
+void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
+
+#endif
+
+%{
+
+void divide_l(int a, int b, int *quotient_p, int *remainder_p)
+{
+ *quotient_p = a/b;
+ *remainder_p = a%b;
+}
+
+void divide_v(int a, int b, int *quotient_p, int *remainder_p)
+{
+ *quotient_p = a/b;
+ *remainder_p = a%b;
+}
+
+void divide_mv(int a, int b, int *quotient_p, int *remainder_p)
+{
+ *quotient_p = a/b;
+ *remainder_p = a%b;
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/mzscheme/Makefile.in b/trunk/Examples/test-suite/mzscheme/Makefile.in
new file mode 100644
index 000000000..fcaf33a48
--- /dev/null
+++ b/trunk/Examples/test-suite/mzscheme/Makefile.in
@@ -0,0 +1,48 @@
+#######################################################################
+# Makefile for mzscheme test-suite
+#######################################################################
+
+LANGUAGE = mzscheme
+MZSCHEME = mzscheme
+SCRIPTSUFFIX = _runme.scm
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.scm appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile mzscheme_clean
diff --git a/trunk/Examples/test-suite/mzscheme/README b/trunk/Examples/test-suite/mzscheme/README
new file mode 100644
index 000000000..37432ea4b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/mzscheme/casts_runme.scm b/trunk/Examples/test-suite/mzscheme/casts_runme.scm
new file mode 100644
index 000000000..3aaa62dc6
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/mzscheme/char_constant_runme.scm b/trunk/Examples/test-suite/mzscheme/char_constant_runme.scm
new file mode 100644
index 000000000..4e3ed47ca
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/mzscheme/imports_runme.scm b/trunk/Examples/test-suite/mzscheme/imports_runme.scm
new file mode 100644
index 000000000..ae636aaa7
--- /dev/null
+++ b/trunk/Examples/test-suite/mzscheme/imports_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 "imports_a.so")
+(load-extension "imports_b.so")
+
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG runtime code does not know
+;; that x (an instance of class B) can be passed to methods of class A.
+
+(A-hello x)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/mzscheme/integers_runme.scm b/trunk/Examples/test-suite/mzscheme/integers_runme.scm
new file mode 100644
index 000000000..03c802166
--- /dev/null
+++ b/trunk/Examples/test-suite/mzscheme/integers_runme.scm
@@ -0,0 +1,9 @@
+(load-extension "integers.so")
+(require (lib "defmacro.ss"))
+
+(define-macro (throws-exception? form)
+ `(with-handlers ((not-break-exn? (lambda (exn) #t)))
+ ,form
+ #f))
+
+(load "../schemerunme/integers.scm")
diff --git a/trunk/Examples/test-suite/mzscheme/name_runme.scm b/trunk/Examples/test-suite/mzscheme/name_runme.scm
new file mode 100644
index 000000000..1782c6481
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/mzscheme/unions_runme.scm b/trunk/Examples/test-suite/mzscheme/unions_runme.scm
new file mode 100644
index 000000000..c44847cfc
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/name.i b/trunk/Examples/test-suite/name.i
new file mode 100644
index 000000000..70e80dcd3
--- /dev/null
+++ b/trunk/Examples/test-suite/name.i
@@ -0,0 +1,28 @@
+/* This interface file tests whether SWIG/Guile handle the %rename and
+ %name directives, which was not the case in 1.3a5.
+*/
+
+%module name
+
+#pragma SWIG nowarn=SWIGWARN_DEPRECATED_NAME // %name is deprecated. Use %rename instead.
+
+#ifdef SWIGGUILE
+%rename foo_1 "foo-2";
+#else
+%rename foo_1 "foo_2";
+#endif
+%inline %{
+void foo_1() {}
+%}
+
+#ifdef SWIGGUILE
+%name("bar-2")
+#else
+%name("bar_2")
+#endif
+%inline %{
+int bar_1 = 17;
+%}
+
+%name("Baz_2")
+%constant int Baz_1 = 47;
diff --git a/trunk/Examples/test-suite/name_cxx.i b/trunk/Examples/test-suite/name_cxx.i
new file mode 100644
index 000000000..64d79c308
--- /dev/null
+++ b/trunk/Examples/test-suite/name_cxx.i
@@ -0,0 +1,31 @@
+/* This interface files tests whether SWIG handles overloaded
+ renamed functions.
+*/
+
+%module name_cxx
+
+#pragma SWIG nowarn=SWIGWARN_DEPRECATED_NAME // %name is deprecated. Use %rename instead.
+
+%name("bar_int")
+%inline %{
+void bar(int i) {}
+%}
+
+%name("bar_double")
+%inline %{
+void bar(double i) {}
+%}
+
+// %name inheritance test
+%{
+class A {
+};
+
+class B : public A {
+};
+
+%}
+
+%name(AA) class A { };
+class B : public A { };
+
diff --git a/trunk/Examples/test-suite/name_warnings.i b/trunk/Examples/test-suite/name_warnings.i
new file mode 100644
index 000000000..4032f20e1
--- /dev/null
+++ b/trunk/Examples/test-suite/name_warnings.i
@@ -0,0 +1,71 @@
+%module name_warnings
+/*
+ This test should produce no warnings at all.
+
+ It just show the cases where swig was showing unintended warnings
+ before.
+
+ Right now the test includes some cases for python, java and csharp.
+
+*/
+
+/* activate all the name warnings */
+%warnfilter(+SWIGWARN_PARSE_KEYWORD,+SWIGWARN_PARSE_BUILTIN_NAME,-SWIGWARN_TYPE_ABSTRACT);
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+class string; // csharp keyword
+namespace std
+{
+ template <class T>
+ class complex;
+}
+
+%inline
+{
+ class complex; // python built-in
+
+ typedef complex None; // python built-in
+
+ struct A
+ {
+ typedef complex None;
+
+#ifndef SWIGPHP // clone() *is* an invalid method name in PHP.
+ A* clone(int) { return NULL; }
+#endif
+
+ virtual ~A() {}
+ virtual int func() = 0;
+ private:
+ typedef complex False;
+ };
+
+ template <class T>
+ T max (T a, T b) { // python 'max' built-in
+ return a > b ? a : b;
+ }
+
+ struct B : A
+ {
+ B() {}
+ };
+
+
+}
+
+%template(max_i) max<int>;
+
+%inline {
+ /* silently rename the parameter names in csharp/java */
+#ifdef SWIGR
+ double foo(double inparam, double out) { return 1.0; }
+#else
+ double foo(double abstract, double out) { return 1.0; }
+#endif
+ double bar(double native, bool boolean) { return 1.0; }
+}
diff --git a/trunk/Examples/test-suite/namespace_class.i b/trunk/Examples/test-suite/namespace_class.i
new file mode 100644
index 000000000..7dc9139cd
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_class.i
@@ -0,0 +1,303 @@
+%module namespace_class
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola;
+
+%inline %{
+ template<class T> void foobar(T t) {}
+ namespace test {
+ template<class T> void barfoo(T t) {}
+ }
+%}
+
+%template(FooBarInt) ::foobar<int>;
+%template(BarFooInt) test::barfoo<int>;
+
+
+%inline %{
+ template <class C>
+ struct Bar_T
+ {
+ };
+
+
+
+ namespace test {
+ enum Hello {
+ Hi
+ };
+
+ struct Test;
+
+ struct Bar {
+ Hello foo(Hello h) {
+ return h;
+ }
+ };
+
+ namespace hola {
+ struct Bor;
+ struct Foo;
+ struct Foobar;
+ template <class T> struct BarT {
+ };
+
+ template <class T> class FooT;
+ }
+
+ template <class T>
+ class hola::FooT {
+ public:
+ Hello foo(Hello h) {
+ return h;
+ }
+
+ T bar(T h) {
+ return h;
+ }
+ };
+
+ namespace hola {
+ template <> class FooT<double>;
+ template <> class FooT<int>;
+ }
+
+ template <>
+ class hola::FooT<double> {
+ public:
+ double moo(double h) {
+ return h;
+ }
+ };
+
+ int a;
+
+ struct hola::Foo : Bar {
+ Hello bar(Hello h) {
+ return h;
+ }
+ };
+ }
+
+ struct test::Test {
+ Hello foo(Hello h) {
+ return h;
+ }
+ };
+
+ struct test::hola::Bor {
+ Hello foo(Hello h) {
+ return h;
+ }
+ };
+
+ namespace test {
+ struct hola::Foobar : Bar {
+ Hello bar(Hello h) {
+ return h;
+ }
+ };
+ }
+
+ template <>
+ class test::hola::FooT<int> {
+ public:
+ int quack(int h) {
+ return h;
+ }
+ };
+
+%}
+
+
+namespace test
+{
+ namespace hola {
+ %template(FooT_i) FooT<int>;
+ }
+
+ %template(FooT_H) hola::FooT<Hello>;
+}
+
+%template(FooT_d) ::test::hola::FooT<double>;
+%template(BarT_H) test::hola::BarT<test::Hello>;
+
+%inline %{
+
+ namespace hi {
+ namespace hello {
+ template <class T> struct PooT;
+ }
+
+ namespace hello {
+ template <class T> struct PooT
+ {
+ };
+ }
+ }
+%}
+
+%template(Poo_i) hi::hello::PooT<int>;
+
+%inline %{
+
+ template <class T> struct BooT {
+ };
+
+ namespace test {
+
+ typedef ::BooT<Hello> BooT_H;
+ }
+
+%}
+
+namespace test {
+
+ %template(BooT_H) ::BooT<Hello>;
+}
+%template(BooT_i) ::BooT<int>;
+
+
+%inline %{
+
+namespace jafar {
+ namespace jmath {
+ class EulerT3D {
+ public:
+ static void hello(){}
+
+ template<class VecFrame, class Vec, class VecRes>
+ static void toFrame(const VecFrame& frame_, const Vec&v_,const VecRes& vRes){}
+
+ template<class T>
+ void operator ()(T& x){}
+
+ template<class T>
+ void operator < (T& x){}
+
+ template<class T>
+ operator Bar_T<T> () {}
+
+ };
+ }
+}
+%}
+
+%template(toFrame) jafar::jmath::EulerT3D::toFrame<int,int,int>;
+%template(callint) jafar::jmath::EulerT3D::operator()<int>;
+%template(lessint) jafar::jmath::EulerT3D::operator < <int>;
+%template(callfooi) jafar::jmath::EulerT3D::operator() <test::hola::FooT<int> >;
+%template(lessfooi) jafar::jmath::EulerT3D::operator < < test::hola::FooT<int> >;
+
+
+%inline %{
+
+namespace {
+ /* the unnamed namespace is 'private', so, the following
+ declarations shouldn't be wrapped */
+ class Private1
+ {
+ };
+
+}
+
+namespace a
+{
+ namespace
+ {
+ class Private2
+ {
+ };
+ }
+}
+
+%}
+
+// %copyctor doesn't work with nested class workaround
+%nocopyctor;
+
+%inline %{
+ class Ala {
+ public :
+ Ala() {}
+ class Ola {
+ public:
+ Ola() {}
+ void eek() {}
+ };
+
+ template <class T>
+ static void hi()
+ {
+ }
+ };
+%}
+
+%rename(Ala__Ola) Ala::Ola;
+class Ala::Ola {
+public:
+ Ola() {}
+ void eek() {}
+};
+
+%template(hi) Ala::hi<int>;
+
+%extend jafar::jmath::EulerT3D
+{
+
+}
+
+%rename(FLACFile) TagLib::FLAC::File;
+
+%inline {
+namespace TagLib
+{
+ class File {
+ public:
+ File() {}
+ };
+
+ class AudioProperties {
+ };
+
+ class AudioPropertiesFile {
+ public:
+ typedef TagLib::File File;
+ };
+
+ namespace FLAC
+ {
+ class File;
+ class Properties : public AudioProperties {
+ public:
+ Properties(File *) {}
+ };
+
+ class PropertiesFile : public AudioPropertiesFile {
+ public:
+ PropertiesFile(File * = 0) {}
+ };
+
+ namespace bar {
+ class PropertiesFree : public AudioProperties {
+ public:
+ PropertiesFree(File *) {}
+ };
+ }
+
+ class FooFilePrivate : private PropertiesFile {
+ public:
+ FooFilePrivate(File *) {}
+ };
+
+ class FooFile : public PropertiesFile {
+ public:
+ FooFile(File *) {}
+ };
+
+ class File {
+ public:
+ File() {}
+ };
+ }
+}
+}
diff --git a/trunk/Examples/test-suite/namespace_enum.i b/trunk/Examples/test-suite/namespace_enum.i
new file mode 100644
index 000000000..82a97c630
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/namespace_extend.i b/trunk/Examples/test-suite/namespace_extend.i
new file mode 100644
index 000000000..3c414d1af
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_extend.i
@@ -0,0 +1,34 @@
+%module namespace_extend
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) bar; /* Ruby, wrong class name */
+
+%{
+namespace foo {
+ class bar {
+ public:
+ };
+}
+foo::bar *new_foo_bar() {
+ return new foo::bar;
+}
+void delete_foo_bar(foo::bar *self) {
+ delete self;
+}
+int foo_bar_blah(foo::bar *self, int x) {
+ return x;
+}
+%}
+
+namespace foo {
+ class bar {
+ public:
+ %extend {
+ bar();
+ ~bar();
+ int blah(int x);
+ };
+ };
+}
+
+
+
diff --git a/trunk/Examples/test-suite/namespace_nested.i b/trunk/Examples/test-suite/namespace_nested.i
new file mode 100644
index 000000000..63d871f3c
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_nested.i
@@ -0,0 +1,101 @@
+%module namespace_nested
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hello::hi::hi0; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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 T1>
+ struct hi1 : T1
+ {
+ };
+
+ typedef hello::Hi<hello::hi::hi0> h0;
+ }
+
+%}
+
+namespace oss
+{
+ %template(hi1_hi0) hi1<hello::Hi0 >;
+}
+
+
+%rename(MyFoo) geos::algorithm::Foo;
+
+%inline
+{
+ namespace geos {
+ namespace algorithm {
+ class Foo
+ {
+ };
+ }
+
+ namespace planargraph { // geos.planargraph
+ namespace algorithm { // geos.planargraph.algorithm
+ class Bar {
+ };
+ }
+ namespace algorithm { // geos.planargraph.algorithm
+
+ class Foo {
+ public:
+ typedef int size_type;
+ };
+ }
+ namespace algorithm { // geos.planargraph.algorithm
+
+ class ConnectedSubgraphFinder : public Foo {
+ public:
+ ConnectedSubgraphFinder(size_type)
+ {
+ }
+
+ };
+ }
+ }
+ }
+}
+
diff --git a/trunk/Examples/test-suite/namespace_spaces.i b/trunk/Examples/test-suite/namespace_spaces.i
new file mode 100644
index 000000000..981916142
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_spaces.i
@@ -0,0 +1,26 @@
+%module namespace_spaces
+%inline %{
+
+class Foo {
+public:
+ Foo();
+ ~Foo();
+ typedef int Integer;
+ int blah(int x);
+ int spam(int x);
+ Integer bar(Integer x);
+ void (Foo:: *func_ptr) (int);
+};
+
+inline Foo :: Foo () {}
+
+inline Foo :: ~Foo () {}
+
+inline int Foo
+::blah(int x) { return 2*x; }
+
+inline int Foo :: spam(int x) { return -x; }
+
+inline Foo :: Integer Foo :: bar(Foo :: Integer x) { return x; }
+
+%}
diff --git a/trunk/Examples/test-suite/namespace_template.i b/trunk/Examples/test-suite/namespace_template.i
new file mode 100644
index 000000000..a36abb19b
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_template.i
@@ -0,0 +1,84 @@
+/* Tests the use of %template with namespaces */
+
+%module namespace_template
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test2::vector<short>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test3::vector<long>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<test4::Integer>; /* Ruby, wrong class name */
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+%{
+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/trunk/Examples/test-suite/namespace_typedef_class.i b/trunk/Examples/test-suite/namespace_typedef_class.i
new file mode 100644
index 000000000..6e3729a22
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_typedef_class.i
@@ -0,0 +1,18 @@
+%module namespace_typedef_class
+
+%inline %{
+namespace ns {
+
+ struct S1
+ {
+ int n;
+ };
+
+ typedef struct
+ {
+ int n;
+ } S2;
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/namespace_typemap.i b/trunk/Examples/test-suite/namespace_typemap.i
new file mode 100644
index 000000000..984b93a6f
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_typemap.i
@@ -0,0 +1,258 @@
+// This tests SWIG's handling of typemaps and namespaces
+%module namespace_typemap
+
+%{
+namespace test {
+ /* A minimalistic string class */
+ class string_class {
+ char *data;
+ public:
+ string_class() {
+ data = 0;
+ }
+ string_class(const char *s) {
+ data = new char[strlen(s)+1];
+ strcpy(data,s);
+ }
+ ~string_class() {
+ if (data) delete [] data;
+ }
+ char *c_str() {
+ return data;
+ }
+ };
+
+ /* A minimalistic test_complex class */
+ class test_complex {
+ double re;
+ double im;
+ public:
+ test_complex(double r = 0, double i = 0) {
+ re = r;
+ im = i;
+ }
+ double real() {
+ return re;
+ }
+ double imag() {
+ return im;
+ }
+ };
+}
+ %}
+
+/* SWIG interface tests */
+
+#ifdef SWIGPYTHON
+%typemap(in) test::test_complex * {
+ if (PyComplex_Check($input)) {
+ $1 = new test_complex(PyComplex_RealAsDouble($input),
+ PyComplex_ImagAsDouble($input));
+ } else {
+ PyErr_SetString(PyExc_TypeError,"Expected test_complex.\n");
+ return NULL;
+ }
+}
+%typemap(freearg) test::test_complex * {
+ delete $1;
+}
+#endif
+#ifdef SWIGOCTAVE
+%typemap(in) test::test_complex * {
+ if ($input.is_complex_scalar()) {
+ $1 = new test_complex($input.complex_value().real(),
+ $input.complex_value().imag());
+ } else {
+ error("Expected test_complex.");
+ }
+}
+%typemap(freearg) test::test_complex * {
+ delete $1;
+}
+#endif
+
+namespace test {
+ class string_class;
+#ifdef SWIGPYTHON
+ %typemap(in) string_class * {
+ $1 = new string_class(SWIG_Python_str_AsChar($input));
+ }
+ %typemap(freearg) string_class * {
+ delete $1;
+ }
+#endif
+#ifdef SWIGOCTAVE
+ %typemap(in) string_class * {
+ $1 = new string_class($input.string_value().c_str());
+ }
+ %typemap(freearg) string_class * {
+ delete $1;
+ }
+#endif
+#ifdef SWIGRUBY
+ %typemap(in) string_class * {
+ $1 = new string_class(STR2CSTR($input));
+ }
+ %typemap(freearg) string_class * {
+ delete $1;
+ }
+#endif
+}
+
+%inline %{
+ namespace test {
+ class string_class;
+ class test_complex;
+
+ /* Functions in the namespace itself */
+ char *stest1(string_class *s) {
+ return s->c_str();
+ }
+ double ctest1(test_complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test2 {
+ using test::string_class;
+ using test::test_complex;
+
+ /* Functions in another namespace */
+ char *stest2(string_class *s) {
+ return s->c_str();
+ }
+ double ctest2(test_complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test3 {
+ using namespace test;
+
+ char *stest3(string_class *s) {
+ return s->c_str();
+ }
+ double ctest3(test_complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test4 {
+ using namespace test2;
+
+ char *stest4(string_class *s) {
+ return s->c_str();
+ }
+ double ctest4(test_complex *c) {
+ return c->real();
+ }
+ }
+
+ namespace test5 {
+ using namespace test3;
+
+ char *stest5(string_class *s) {
+ return s->c_str();
+ }
+ double ctest5(test_complex *c) {
+ return c->real();
+ }
+ }
+
+ char *stest6(test::string_class *s) {
+ return s->c_str();
+ }
+ double ctest6(test::test_complex *c) {
+ return c->real();
+ }
+
+ char *stest7(test2::string_class *s) {
+ return s->c_str();
+ }
+ double ctest7(test2::test_complex *c) {
+ return c->real();
+ }
+
+ char *stest8(test3::string_class *s) {
+ return s->c_str();
+ }
+ double ctest8(test3::test_complex *c) {
+ return c->real();
+ }
+
+ char *stest9(test4::string_class *s) {
+ return s->c_str();
+ }
+ double ctest9(test4::test_complex *c) {
+ return c->real();
+ }
+
+ char *stest10(test5::string_class *s) {
+ return s->c_str();
+ }
+ double ctest10(test5::test_complex *c) {
+ return c->real();
+ }
+
+ namespace test11 = test;
+
+ char *stest11(test11::string_class *s) {
+ return s->c_str();
+ }
+ double ctest11(test11::test_complex *c) {
+ return c->real();
+ }
+
+ using namespace test2;
+ using test::test_complex;
+
+ char *stest12(string_class *s) {
+ return s->c_str();
+ }
+ double ctest12(test_complex *c) {
+ return c->real();
+ }
+%}
+
+namespace Split {
+#ifdef SWIGPYTHON
+ %typemap(in) PosInteger {
+ $1 = PyInt_AsLong($input);
+ if ($1 < 0) {
+ PyErr_SetString(PyExc_ValueError,"domain error\n");
+ return NULL;
+ }
+ }
+#endif
+#ifdef SWIGOCTAVE
+ %typemap(in) PosInteger {
+ $1 = $input.long_value();
+ if ($1 < 0) {
+ error("domain error");
+ }
+ }
+#endif
+#ifdef SWIGRUBY
+ %typemap(in) PosInteger {
+ $1 = NUM2INT($input);
+ if ($1 < 0) {
+ rb_raise(rb_eRangeError, "domain error");
+ }
+ }
+#endif
+}
+
+%inline %{
+ namespace Split {
+ typedef int PosInteger;
+ PosInteger ttest1(PosInteger x) {
+ return x;
+ }
+ }
+%}
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/namespace_union.i b/trunk/Examples/test-suite/namespace_union.i
new file mode 100644
index 000000000..85885f399
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_union.i
@@ -0,0 +1,31 @@
+%module namespace_union
+
+#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
+
+%inline %{
+namespace SpatialIndex
+{
+ class Variant
+ {
+ public:
+ Variant() { };
+ int varType;
+ union
+ {
+ long lVal; // VT_LONG
+ short iVal; // VT_SHORT
+ float fltVal; // VT_FLOAT
+ double dblVal; // VT_DOUBLE
+ char cVal; // VT_CHAR
+ unsigned short uiVal; // VT_USHORT
+ unsigned long ulVal; // VT_ULONG
+ int intVal; // VT_INT
+ unsigned int uintVal; // VT_UINT
+ bool blVal; // VT_BOOL
+ char* pcVal; // VT_PCHAR
+ void* pvVal; // VT_PVOID
+ } val;
+ }; // Variant
+}
+%}
+
diff --git a/trunk/Examples/test-suite/namespace_virtual_method.i b/trunk/Examples/test-suite/namespace_virtual_method.i
new file mode 100644
index 000000000..05c8f9795
--- /dev/null
+++ b/trunk/Examples/test-suite/namespace_virtual_method.i
@@ -0,0 +1,41 @@
+%module namespace_virtual_method
+
+%warnfilter(515);
+
+
+%inline %{
+
+namespace A {
+ namespace B {
+ class Foo;
+ }
+ namespace C {
+ class Foo {
+ public:
+ Foo() { };
+ virtual ~Foo() { };
+ virtual int bar(const A::B::Foo &x) = 0;
+ };
+ }
+}
+
+namespace A {
+ namespace C {
+ class Spam : public Foo {
+ public:
+ Spam() { }
+ virtual ~Spam() { }
+ virtual int bar(const B::Foo &x) { return 1; }
+ };
+ }
+}
+
+%}
+
+%{
+namespace A {
+ namespace B {
+ class Foo { };
+ }
+}
+%}
diff --git a/trunk/Examples/test-suite/naturalvar.i b/trunk/Examples/test-suite/naturalvar.i
new file mode 100644
index 000000000..af1362031
--- /dev/null
+++ b/trunk/Examples/test-suite/naturalvar.i
@@ -0,0 +1,40 @@
+%module(naturalvar) naturalvar
+
+#ifdef __cplusplus
+%include std_string.i
+%inline
+{
+ struct Foo
+ {
+ };
+
+
+ Foo f;
+ std::string s;
+ struct Bar
+ {
+ int i;
+ Foo f;
+ std::string s;
+ };
+}
+#else
+%inline
+{
+ typedef struct _foo
+ {
+ }Foo;
+
+
+ Foo f;
+ char *s;
+ typedef struct _bar
+ {
+ int i;
+ Foo f;
+ char *s;
+ } Bar;
+}
+#endif
+
+
diff --git a/trunk/Examples/test-suite/nested.i b/trunk/Examples/test-suite/nested.i
new file mode 100644
index 000000000..004cb4814
--- /dev/null
+++ b/trunk/Examples/test-suite/nested.i
@@ -0,0 +1,54 @@
+/*
+This testcase tests that nested structs/unions work. Named structs/unions declared within
+a struct produced redefinition errors in SWIG 1.3.6 as reported by SF bug #447488.
+Also tests reported error when a #define placed in a deeply embedded struct/union.
+*/
+
+%module nested
+
+%inline %{
+
+struct TestStruct {
+ int a;
+};
+
+struct OuterStructNamed {
+ struct InnerStructNamed {
+ double dd;
+ } inner_struct_named;
+ union InnerUnionNamed {
+ double ee;
+ int ff;
+ } inner_union_named;
+};
+
+struct OuterStructUnnamed {
+ struct {
+ double xx;
+ } inner_struct_unnamed;
+ union {
+ double yy;
+ int zz;
+ } inner_union_unnamed;
+};
+
+
+typedef struct OuterStruct {
+ union {
+
+ struct outer_nested_struct {
+ union inner_nested_union {
+#define BAD_STYLE 1
+ int red;
+ struct TestStruct green;
+ } InnerNestedUnion;
+
+ struct inner_nested_struct {
+ int blue;
+ } InnerNestedStruct;
+ } OuterNestedStruct;
+
+ } EmbeddedUnion;
+} OuterStruct;
+
+%}
diff --git a/trunk/Examples/test-suite/nested_class.i b/trunk/Examples/test-suite/nested_class.i
new file mode 100644
index 000000000..71d91f022
--- /dev/null
+++ b/trunk/Examples/test-suite/nested_class.i
@@ -0,0 +1,206 @@
+%module nested_class
+
+#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass2;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct2;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion2;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass4Typedef;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct4Typedef;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion4Typedef;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass5;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct5;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion5;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultiple;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleDerived;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleAnonTypedef1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleNamedTypedef;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerSameName;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer2::IgnoreMe;
+
+%inline %{
+struct Outer {
+ typedef int Integer;
+ ///////////////////////////////////////////
+ struct InnerStruct1 {
+ Integer x;
+ };
+
+ class InnerClass1 {
+ public:
+ Integer x;
+ };
+
+ union InnerUnion1 {
+ Integer x;
+ double y;
+ };
+
+ ///////////////////////////////////////////
+ class {
+ public:
+ Integer a;
+ };
+
+ struct {
+ Integer b;
+ };
+
+ union {
+ Integer c;
+ double d;
+ };
+
+ ///////////////////////////////////////////
+ class InnerClass2 {
+ public:
+ Integer x;
+ } InnerClass2Instance;
+
+ struct InnerStruct2 {
+ Integer x;
+ } InnerStruct2Instance;
+
+ union InnerUnion2 {
+ Integer x;
+ double y;
+ } InnerUnion2Instance;
+
+ ///////////////////////////////////////////
+ class {
+ public:
+ Integer x;
+ } InnerClass3Instance;
+
+ struct {
+ Integer x;
+ } InnerStruct3Instance;
+
+ union {
+ Integer x;
+ double y;
+ } InnerUnion3Instance;
+
+ ///////////////////////////////////////////
+ typedef class {
+ public:
+ Integer x;
+ } InnerClass4Typedef;
+
+ typedef struct {
+ Integer x;
+ } InnerStruct4Typedef;
+
+ typedef union {
+ Integer x;
+ double y;
+ } InnerUnion4Typedef;
+
+ ///////////////////////////////////////////
+ typedef class InnerClass5 {
+ public:
+ Integer x;
+ } InnerClass5Typedef;
+
+ typedef struct InnerStruct5 {
+ Integer x;
+ } InnerStruct5Typedef;
+
+ typedef union InnerUnion5 {
+ Integer x;
+ double y;
+ } InnerUnion5Typedef;
+
+ // bug #909387 - inner declared types are treated as forward declarations
+ InnerStruct1* makeInnerStruct1() { return 0; }
+ InnerClass1* makeInnerClass1() { return 0; }
+ InnerUnion1* makeInnerUnion1() { return 0; }
+
+ InnerStruct2* makeInnerStruct2() { return 0; }
+ InnerClass2* makeInnerClass2() { return 0; }
+ InnerUnion2* makeInnerUnion2() { return 0; }
+
+ InnerStruct4Typedef* makeInnerStruct4Typedef() { return 0; }
+ InnerClass4Typedef* makeInnerClass4Typedef() { return 0; }
+ InnerUnion4Typedef* makeInnerUnion4Typedef() { return 0; }
+
+ InnerStruct5* makeInnerStruct5() { return 0; }
+ InnerClass5* makeInnerClass5() { return 0; }
+ InnerUnion5* makeInnerUnion5() { return 0; }
+
+ InnerStruct5Typedef* makeInnerStruct5Typedef() { return 0; }
+ InnerClass5Typedef* makeInnerClass5Typedef() { return 0; }
+ InnerUnion5Typedef* makeInnerUnion5Typedef() { return 0; }
+
+ ///////////////////////////////////////////
+ struct InnerMultiple {
+ Integer x;
+ } MultipleInstance1, MultipleInstance2, *MultipleInstance3, MultipleInstance4[2];
+
+ struct InnerMultipleDerived : public InnerMultiple {
+ Integer xx;
+ } MultipleDerivedInstance1, MultipleDerivedInstance2, *MultipleDerivedInstance3, MultipleDerivedInstance4[2];
+
+ struct {
+ Integer x;
+ } MultipleInstanceAnon1, MultipleInstanceAnon2, *MultipleInstanceAnon3, MultipleInstanceAnon4[2];
+
+ struct : public InnerMultiple {
+ Integer xx;
+ } MultipleInstanceAnonDerived1, MultipleInstanceAnonDerived2, *MultipleInstanceAnonDerived3, MultipleInstanceAnonDerived4[2];
+
+ struct : public InnerMultiple {
+ Integer xx;
+ };
+
+ class : public InnerMultiple {
+ public:
+ Integer yy;
+ };
+
+ ///////////////////////////////////////////
+ typedef struct {
+ Integer x;
+ } InnerMultipleAnonTypedef1, InnerMultipleAnonTypedef2, *InnerMultipleAnonTypedef3;
+
+ InnerMultipleAnonTypedef1* makeInnerMultipleAnonTypedef1() { return 0; }
+ InnerMultipleAnonTypedef2* makeInnerMultipleAnonTypedef2() { return 0; }
+ InnerMultipleAnonTypedef3* makeInnerMultipleAnonTypedef3() { return 0; }
+
+ typedef struct InnerMultipleNamedTypedef {
+ Integer x;
+ } InnerMultipleNamedTypedef1, InnerMultipleNamedTypedef2, *InnerMultipleNamedTypedef3;
+
+ InnerMultipleNamedTypedef* makeInnerMultipleNamedTypedef() { return 0; }
+ InnerMultipleNamedTypedef1* makeInnerMultipleNamedTypedef1() { return 0; }
+ InnerMultipleNamedTypedef2* makeInnerMultipleNamedTypedef2() { return 0; }
+ InnerMultipleNamedTypedef3* makeInnerMultipleNamedTypedef3() { return 0; }
+
+ ///////////////////////////////////////////
+ typedef struct InnerSameName {
+ Integer x;
+ } InnerSameName;
+
+ InnerSameName* makeInnerSameName() { return 0; }
+};
+%}
+
+// Ignore nested struct instance
+%ignore Outer2::IgnoreMeInstance;
+%{
+struct Outer2 {
+ struct IgnoreMe {
+ int xx;
+ };
+};
+%}
+
+struct Outer2 {
+ struct IgnoreMe {
+ int xx;
+ } IgnoreMeInstance;
+};
+
+
diff --git a/trunk/Examples/test-suite/nested_comment.i b/trunk/Examples/test-suite/nested_comment.i
new file mode 100644
index 000000000..99d0ffb43
--- /dev/null
+++ b/trunk/Examples/test-suite/nested_comment.i
@@ -0,0 +1,36 @@
+%module nested_comment
+
+#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
+
+// this example shows a problem with 'dump_nested' (parser.y).
+
+// bug #949654
+%inline %{
+ typedef struct s1 {
+ union {
+ int fsc; /* genie structure hiding - Conductor
+ */
+ int fso; /* genie structure hiding - FSOptions
+ */
+ struct {
+ double *vals;
+ int size;
+ } vector_val; /* matrix values are mainly used
+ in rlgc models */
+ char *name;
+ } n ;
+ } s2;
+%}
+
+// comment in nested struct
+%inline %{
+struct a
+{
+ struct {
+ /*struct*/
+ struct {
+ int b; /**< v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */
+ } c;
+ } d;
+};
+%}
diff --git a/trunk/Examples/test-suite/nested_structs.i b/trunk/Examples/test-suite/nested_structs.i
new file mode 100644
index 000000000..60e34a638
--- /dev/null
+++ b/trunk/Examples/test-suite/nested_structs.i
@@ -0,0 +1,27 @@
+%module nested_structs
+
+// bug #491476
+%inline %{
+struct Outer {
+ struct {
+ int val;
+ } inner1, inner2, *inner3, inner4[1];
+ struct Named {
+ int val;
+ } inside1, inside2, *inside3, inside4[1];
+} outer;
+
+void setValues(struct Outer *outer, int val) {
+ outer->inner1.val = val;
+ outer->inner2.val = val * 2;
+ outer->inner3 = &outer->inner2;
+ outer->inner4[0].val = val * 4;
+
+ val = val * 10;
+ outer->inside1.val = val;
+ outer->inside2.val = val * 2;
+ outer->inside3 = &outer->inside2;
+ outer->inside4[0].val = val * 4;
+}
+%}
+
diff --git a/trunk/Examples/test-suite/nested_workaround.i b/trunk/Examples/test-suite/nested_workaround.i
new file mode 100644
index 000000000..9727dacee
--- /dev/null
+++ b/trunk/Examples/test-suite/nested_workaround.i
@@ -0,0 +1,38 @@
+%module nested_workaround
+// Similar to "Nested classes" documentation example.
+
+class Inner {
+ int val;
+ public:
+ Inner(int v = 0) : val(v) {}
+ void setValue(int v) { val = v; }
+ int getValue() const { return val; }
+};
+%nestedworkaround Outer::Inner;
+
+%inline %{
+class Outer {
+public:
+ class Inner {
+ int val;
+ public:
+ Inner(int v = 0) : val(v) {}
+ void setValue(int v) { val = v; }
+ int getValue() const { return val; }
+ };
+ Inner createInner(int v) const { return Inner(v); }
+ int getInnerValue(const Inner& i) const { return i.getValue(); }
+ Inner doubleInnerValue(Inner inner) {
+ inner.setValue(inner.getValue() * 2);
+ return inner;
+ }
+};
+%}
+
+// We've fooled SWIG into thinking that Inner is a global class, so now we need
+// to trick the C++ compiler into understanding this apparent global type.
+%{
+typedef Outer::Inner Inner;
+%}
+
+
diff --git a/trunk/Examples/test-suite/newobject1.i b/trunk/Examples/test-suite/newobject1.i
new file mode 100644
index 000000000..b5b018b2f
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/newobject2.i b/trunk/Examples/test-suite/newobject2.i
new file mode 100644
index 000000000..bc7394d4a
--- /dev/null
+++ b/trunk/Examples/test-suite/newobject2.i
@@ -0,0 +1,47 @@
+/**
+ * The purpose of this test is to confirm that a language module
+ * correctly handles the case when a C function has been tagged with the
+ * %newobject directive.
+ */
+
+%module newobject2
+
+%{
+#include <stdlib.h>
+%}
+
+%{
+/* Global initialization (not wrapped) */
+int g_fooCount = 0;
+%}
+
+%newobject makeFoo();
+
+%inline %{
+/* Struct definition */
+typedef struct {
+ int dummy;
+} Foo;
+
+/* Make one */
+Foo *makeFoo() {
+ Foo *foo = (Foo *) malloc(sizeof(Foo));
+ g_fooCount++;
+ return foo;
+}
+
+/* Return the number of instances */
+int fooCount() {
+ return g_fooCount;
+}
+
+void do_stuff(Foo *f) {
+}
+%}
+
+%extend Foo {
+ ~Foo() {
+ free((void *) $self);
+ g_fooCount--;
+ }
+}
diff --git a/trunk/Examples/test-suite/nspace.i b/trunk/Examples/test-suite/nspace.i
new file mode 100644
index 000000000..4e4e461c0
--- /dev/null
+++ b/trunk/Examples/test-suite/nspace.i
@@ -0,0 +1,103 @@
+// Test the nspace feature
+%module nspace
+
+// nspace feature only supported by these languages
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+
+%nspace;
+%nonspace Outer::Inner2::NoNSpacePlease;
+
+%copyctor;
+%ignore Outer::Inner2::Color::Color();
+
+#define CONSTANT100 100
+
+%inline %{
+
+namespace Outer {
+ class nspace {
+ };
+ namespace Inner1 {
+ enum Channel { Diffuse, Specular = 0x10, Transmission1 };
+ enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 };
+
+ struct Color {
+ static Color* create() { return new Color(); }
+
+ enum Channel { Diffuse, Specular = 0x20, Transmission };
+ enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 };
+
+ int instanceMemberVariable;
+ static int staticMemberVariable;
+ static const int staticConstMemberVariable = 222;
+ static const Channel staticConstEnumMemberVariable = Transmission;
+ void colorInstanceMethod(double d) {}
+ static void colorStaticMethod(double d) {}
+ }; // Color
+ int Color::staticMemberVariable = 0;
+
+ Color namespaceFunction(Color k) { return k; }
+ int namespaceVar = 0;
+ } // Inner1
+
+ namespace Inner2 {
+ enum Channel { Diffuse, Specular = 0x30, Transmission2 };
+
+ struct Color {
+ Color() : instanceMemberVariable(0) {}
+ static Color* create() { return new Color(); }
+
+ enum Channel { Diffuse, Specular = 0x40, Transmission };
+ enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 };
+
+ int instanceMemberVariable;
+ static int staticMemberVariable;
+ static const int staticConstMemberVariable = 333;
+ static const Channel staticConstEnumMemberVariable = Transmission;
+ void colorInstanceMethod(double d) {}
+ static void colorStaticMethod(double d) {}
+ void colors(const Inner1::Color& col1a,
+ const Outer::Inner1::Color& col1b,
+ const Color &col2a,
+ const Inner2::Color& col2b,
+ const Outer::Inner2::Color& col2c) {}
+ }; // Color
+ int Color::staticMemberVariable = 0;
+ class NoNSpacePlease {};
+ } // Inner2
+
+ // Derived class
+ namespace Inner3 {
+ struct Blue : Inner2::Color {
+ void blueInstanceMethod() {}
+ };
+ }
+ namespace Inner4 {
+ struct Blue : Inner2::Color {
+ void blueInstanceMethod() {}
+ };
+ }
+
+ class SomeClass {
+ public:
+ Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; }
+ Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; }
+ Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; }
+ Inner2::Channel GetInner2Channel() { return Inner2::Transmission2; }
+ }; // SomeClass
+
+} // Outer
+
+namespace Outer {
+ struct MyWorldPart2 {};
+}
+
+struct GlobalClass {
+ void gmethod() {}
+};
+
+void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
+%}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/nspace_extend.i b/trunk/Examples/test-suite/nspace_extend.i
new file mode 100644
index 000000000..88f40bc69
--- /dev/null
+++ b/trunk/Examples/test-suite/nspace_extend.i
@@ -0,0 +1,50 @@
+// Test the nspace feature and %extend
+%module nspace_extend
+
+// nspace feature only supported by these languages
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+
+%nspace;
+
+%extend Outer::Inner1::Color {
+ Color() { return new Outer::Inner1::Color(); }
+ virtual ~Color() { delete $self; }
+ static Color* create() { return new Outer::Inner1::Color(); }
+ Color(const Color& other) { return new Outer::Inner1::Color(other); }
+
+ void colorInstanceMethod(double d) {}
+ static void colorStaticMethod(double d) {}
+}
+
+%inline %{
+
+namespace Outer {
+ namespace Inner1 {
+ struct Color {
+ };
+ }
+
+ namespace Inner2 {
+ struct Color {
+ };
+ }
+}
+%}
+
+%extend Outer::Inner2::Color {
+ Color() { return new Outer::Inner2::Color(); }
+ ~Color() { delete $self; }
+ static Color* create() { return new Outer::Inner2::Color(); }
+ Color(const Color& other) { return new Outer::Inner2::Color(other); }
+
+ void colorInstanceMethod(double d) {}
+ static void colorStaticMethod(double d) {}
+ void colors(const Inner1::Color& col1a,
+ const Outer::Inner1::Color& col1b,
+ const Color &col2a,
+ const Inner2::Color& col2b,
+ const Outer::Inner2::Color& col2c) {}
+}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/null_pointer.i b/trunk/Examples/test-suite/null_pointer.i
new file mode 100644
index 000000000..59d554c2b
--- /dev/null
+++ b/trunk/Examples/test-suite/null_pointer.i
@@ -0,0 +1,10 @@
+%module null_pointer
+
+%inline {
+ struct A {};
+
+ bool func(A* a) {
+ return !a;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/ocaml/Makefile.in b/trunk/Examples/test-suite/ocaml/Makefile.in
new file mode 100644
index 000000000..f16c3da95
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/Makefile.in
@@ -0,0 +1,83 @@
+#######################################################################
+# Makefile for ocaml test-suite
+#######################################################################
+
+LANGUAGE = ocaml
+OCAMLC = ocamlc
+VARIANT = _static
+SCRIPTSUFFIX = _runme.ml
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+C_TEST_CASES =
+
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
+ -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \
+ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme; \
+ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
+ $(RUNTOOL) ./runme; \
+ fi ;
+
+check_quant:
+ cat /dev/null > testing
+ cat /dev/null > success
+ cat /dev/null > results
+ $(MAKE) check
+ echo "Failed:" >> results
+ for element in `cat testing` ; do \
+ if grep $$element success >/dev/null 2>/dev/null ; then \
+ : ; \
+ else \
+ echo $$element >> results ; \
+ fi ; \
+ done
+ echo "Success:" >> results
+ cat success >> results
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ echo $@ >> testing
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+ if [ -f $(@:%.cpptest=%_wrap.o) ] ; then \
+ echo $@ >> success ; \
+ fi
+
+%.ctest:
+ echo $@ >> testing
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+ if [ -f $(@:%.ctest=%_wrap.o) ] ; then \
+ echo $@ >> success ; \
+ fi
+
+%.multicpptest:
+ echo $@ >> testing
+ +$(swig_and_compile_multi_cpp)
+ $(setup)
+ $(run_testcase)
+ if [ -f $(@:%.multicpptest=%_runtime_wrap.o) ] ; then \
+ echo $@ >> success ; \
+ fi
+
+# Clean
+%.clean:
+ @rm -f $*.ml $*.mli;
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ocaml_clean
diff --git a/trunk/Examples/test-suite/ocaml/README b/trunk/Examples/test-suite/ocaml/README
new file mode 100644
index 000000000..3fdea6252
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/ocaml/class_ignore_runme.ml b/trunk/Examples/test-suite/ocaml/class_ignore_runme.ml
new file mode 100644
index 000000000..518930527
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/class_ignore_runme.ml
@@ -0,0 +1,7 @@
+open Swig
+open Class_ignore
+
+let a = new_Bar C_void
+let _ = (if _do_blah a <> C_string "Bar::blah" then
+ raise (Failure "We didn't really get a bar object."))
+
diff --git a/trunk/Examples/test-suite/ocaml/imports_runme.ml b/trunk/Examples/test-suite/ocaml/imports_runme.ml
new file mode 100644
index 000000000..33d631406
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/imports_runme.ml
@@ -0,0 +1,10 @@
+(* purpose: to receive the hello A method from Imports_a exposed through
+ * a B object derived from A *)
+
+open Swig
+open Imports_a
+open Imports_b
+let x = new_B C_void
+(* Tests conversion of x to a generic value *)
+let a = swig_val `unknown x
+let _ = (invoke x) "hello" C_void
diff --git a/trunk/Examples/test-suite/ocaml/makedebugtop b/trunk/Examples/test-suite/ocaml/makedebugtop
new file mode 100755
index 000000000..d51439a75
--- /dev/null
+++ b/trunk/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 swig.cmo ${thetest}_wrap.o ${thetest}.cmo -o ${thetest}_top -cclib -lstdc++
diff --git a/trunk/Examples/test-suite/ocaml/minherit_runme.ml b/trunk/Examples/test-suite/ocaml/minherit_runme.ml
new file mode 100644
index 000000000..29a37f43a
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/minherit_runme.ml
@@ -0,0 +1,131 @@
+(* Stolen from the python tests *)
+open Swig
+open Minherit
+
+let a = new_Foo C_void
+let b = new_Bar C_void
+let c = new_FooBar C_void
+let d = new_Spam C_void
+
+let soci x = (string_of_int (get_int x))
+
+let _ =
+ if (invoke a) "xget" C_void <> (C_int 1) then
+ raise (Failure "Bad attribute value (a.xget)")
+
+let _ =
+ if (invoke b) "yget" C_void <> (C_int 2) then
+ raise (Failure "Bad attribute value (b.yget)")
+
+let _ =
+ if (invoke c) "xget" C_void <> (C_int 1)
+ || (invoke c) "yget" C_void <> (C_int 2)
+ || (invoke c) "zget" C_void <> (C_int 3) then
+ raise (Failure "Bad attribute value c")
+
+let _ =
+ if (invoke d) "xget" C_void <> (C_int 1)
+ || (invoke d) "yget" C_void <> (C_int 2)
+ || (invoke d) "zget" C_void <> (C_int 3)
+ || (invoke d) "wget" C_void <> (C_int 4) then
+ raise (Failure "Bad attribute value d")
+
+let xga = _xget a
+let _ =
+ if xga <> (C_int 1) then
+ raise (Failure ("Bad attribute value (xget a): " ^ (soci xga)))
+
+let ygb = _yget b
+let _ =
+ if ygb <> (C_int 2) then
+ raise (Failure ("Bad attribute value (yget b): " ^
+ (string_of_int (get_int ygb))))
+
+let xgc = _xget c and ygc = _yget c and zgc = _zget c
+let _ =
+ if xgc <> (C_int 1) || ygc <> (C_int 2) || zgc <> (C_int 3) then
+ raise (Failure ("Bad attribute value (xgc=" ^ (soci xgc) ^
+ " (sb 1) ygc=" ^ (soci ygc) ^
+ " (sb 2) zgc=" ^ (soci zgc) ^
+ " (sb 3))"))
+
+let xgd = _xget d and ygd = _yget d and zgd = _zget d and wgd = _wget d
+let _ =
+ if xgd <> (C_int 1) || ygd <> (C_int 2)
+ || zgd <> (C_int 3) || wgd <> (C_int 4) then
+ raise (Failure ("Bad attribute value (xgd=" ^ (soci xgd) ^
+ " (sb 1) ygd=" ^ (soci ygd) ^
+ " (sb 2) zgd=" ^ (soci zgd) ^
+ " (sb 3)"))
+
+(* Cleanse all of the pointers and see what happens *)
+
+let aa = _toFooPtr a
+let bb = _toBarPtr b
+let cc = _toFooBarPtr c
+let dd = _toSpamPtr d
+
+let xgaa = (invoke aa) "xget" C_void
+let _ =
+ if xgaa <> (C_int 1) then
+ raise (Failure ("Bad attribute value xgaa " ^ (soci xgaa)))
+
+let ygbb = (invoke bb) "yget" C_void
+let _ =
+ if ygbb <> (C_int 2) then
+ raise (Failure ("Bad attribute value ygbb " ^ (soci ygbb)))
+
+let xgcc = (invoke cc) "xget" C_void
+and ygcc = (invoke cc) "yget" C_void
+and zgcc = (invoke cc) "zget" C_void
+
+let _ =
+ if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then
+ raise (Failure ("Bad attribute value (" ^
+ (soci xgcc) ^ " (sb 1) " ^
+ (soci ygcc) ^ " (sb 2) " ^
+ (soci zgcc) ^ " (sb 3))"))
+
+let xgdd = (invoke dd) "xget" C_void
+and ygdd = (invoke dd) "yget" C_void
+and zgdd = (invoke dd) "zget" C_void
+and wgdd = (invoke dd) "wget" C_void
+
+let _ =
+ if xgdd <> (C_int 1) || ygdd <> (C_int 2)
+ || zgdd <> (C_int 3) || wgdd <> (C_int 4) then
+ raise (Failure ("Bad value: " ^
+ "xgdd=" ^ (soci xgdd) ^
+ "ygdd=" ^ (soci ygdd) ^
+ "zgdd=" ^ (soci zgdd) ^
+ "wgdd=" ^ (soci wgdd)))
+
+let xgaa = _xget aa
+and ygbb = _yget bb
+and xgcc = _xget cc
+and ygcc = _yget cc
+and zgcc = _zget cc
+and xgdd = _xget dd
+and ygdd = _yget dd
+and zgdd = _zget dd
+and wgdd = _wget dd
+
+let _ =
+ if xgaa <> (C_int 1) then
+ raise (Failure ("Fn xget: xgaa=" ^ (soci xgaa)))
+
+let _ =
+ if ygbb <> (C_int 2) then
+ raise (Failure ("Fn yget: ygbb=" ^ (soci ygbb)))
+
+let _ =
+ if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then
+ raise (Failure ("CC with fns: (" ^
+ (soci xgcc) ^ " " ^ (soci ygcc) ^ " " ^ (soci zgcc)))
+
+let _ =
+ if xgdd <> (C_int 1) || ygdd <> (C_int 2)
+ || zgdd <> (C_int 3) || wgdd <> (C_int 4) then
+ raise (Failure ("CC with fns: (" ^
+ (soci xgdd) ^ " " ^ (soci ygdd) ^ " " ^
+ (soci zgdd) ^ " " ^ (soci wgdd) ^ ")"))
diff --git a/trunk/Examples/test-suite/ocaml/name_runme.ml b/trunk/Examples/test-suite/ocaml/name_runme.ml
new file mode 100644
index 000000000..1e4e62c2b
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/name_runme.ml
@@ -0,0 +1,9 @@
+open Swig
+open Name
+
+let _ = if (get_int (_Baz_2 C_void)) - (get_int (_bar_2 C_void)) == 30
+then
+ exit 0
+else
+ exit 1
+
diff --git a/trunk/Examples/test-suite/ocaml/newobject1_runme.ml b/trunk/Examples/test-suite/ocaml/newobject1_runme.ml
new file mode 100644
index 000000000..c7d66c148
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/newobject1_runme.ml
@@ -0,0 +1,26 @@
+open Swig
+open Newobject1
+
+exception RuntimeError of string * int
+
+let foo1 = ref (_Foo_makeFoo C_void)
+let _ = if get_int (_Foo_fooCount C_void) != 1 then
+ raise (RuntimeError ("(1) Foo.fooCount != 1",
+ get_int (_Foo_fooCount C_void)))
+
+let foo2 = ref ((invoke !foo1) "makeMore" C_void)
+let _ = if get_int (_Foo_fooCount C_void) != 2 then
+ raise (RuntimeError ("(2) Foo.fooCount != 2",
+ get_int (_Foo_fooCount C_void)))
+
+let _ = begin
+ foo1 := C_void ; Gc.full_major () ;
+ (if get_int (_Foo_fooCount C_void) != 1 then
+ raise (RuntimeError ("(3) Foo.fooCount != 1",
+ get_int (_Foo_fooCount C_void)))) ;
+
+ foo2 := C_void ; Gc.full_major () ;
+ (if get_int (_Foo_fooCount C_void) != 0 then
+ raise (RuntimeError ("(4) Foo.fooCount != 0",
+ get_int (_Foo_fooCount C_void)))) ;
+end
diff --git a/trunk/Examples/test-suite/ocaml/overload_copy_runme.ml b/trunk/Examples/test-suite/ocaml/overload_copy_runme.ml
new file mode 100644
index 000000000..c7839aeea
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/overload_copy_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Overload_copy
+
+let f = new_Foo C_void
+let g = new_Foo f
diff --git a/trunk/Examples/test-suite/ocaml/sneaky1_runme.ml b/trunk/Examples/test-suite/ocaml/sneaky1_runme.ml
new file mode 100644
index 000000000..81b69f372
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/sneaky1_runme.ml
@@ -0,0 +1,9 @@
+(* Stolen from ruby test cases *)
+
+open Swig
+open Sneaky1
+
+let x = Sneaky1._add (C_list [ C_int 3; C_int 4 ])
+let y = Sneaky1._subtract (C_list [ C_int 3; C_int 4 ])
+let z = Sneaky1._mul (C_list [ C_int 3; C_int 4 ])
+let w = Sneaky1._divide (C_list [ C_int 3; C_int 4 ])
diff --git a/trunk/Examples/test-suite/ocaml/throw_exception_runme.ml b/trunk/Examples/test-suite/ocaml/throw_exception_runme.ml
new file mode 100644
index 000000000..8781926b6
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/throw_exception_runme.ml
@@ -0,0 +1,28 @@
+(* Throw exception test *)
+
+open Swig
+open Throw_exception
+
+let x = new_Foo C_void ;;
+let _ =
+ try
+ (invoke x) "test_int" C_void
+ with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
+ try
+ (invoke x) "test_msg" C_void
+ with (Failure "Exception(0): Dead\n") ->
+ try
+ (invoke x) "test_cls" C_void
+ with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
+ try
+ (invoke x) "test_multi" (C_int 1)
+ with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
+ try
+ (invoke x) "test_multi" (C_int 2)
+ with (Failure "Exception(0): Dead\n") ->
+ try
+ (invoke x) "test_multi" (C_int 3)
+ with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
+ exit 0
+
+let _ = exit 1
diff --git a/trunk/Examples/test-suite/ocaml/typedef_mptr_runme.ml b/trunk/Examples/test-suite/ocaml/typedef_mptr_runme.ml
new file mode 100644
index 000000000..3bdaac4ba
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/typedef_mptr_runme.ml
@@ -0,0 +1,16 @@
+open Swig
+open Typedef_mptr
+
+let soci x = (string_of_int (get_int x))
+
+let x = new_Foo C_void
+let add_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _add ])
+and sub_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _sub ])
+let _ =
+ if add_res <> (C_int 3) || sub_res <> (C_int 1) then
+ raise (Failure ("Bad result:" ^
+ " (add " ^ (soci add_res) ^ ") " ^
+ " (sub " ^ (soci sub_res) ^ ")"))
+let _ = Printf.printf "2 + 1 = %d, 2 - 1 = %d\n"
+ (get_int add_res)
+ (get_int sub_res)
diff --git a/trunk/Examples/test-suite/ocaml/typename_runme.ml b/trunk/Examples/test-suite/ocaml/typename_runme.ml
new file mode 100644
index 000000000..01f49de72
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/typename_runme.ml
@@ -0,0 +1,12 @@
+(* Fun with type names -- stolen from the ruby runme *)
+
+open Swig
+open Typename
+
+let f = new_Foo C_void
+let b = new_Bar C_void
+
+let x = _twoFoo f
+let _ = match x with C_double f -> () | _ -> raise (Failure "not a float")
+let y = _twoBar b
+let _ = match y with C_int i -> () | _ -> raise (Failure "not an int")
diff --git a/trunk/Examples/test-suite/ocaml/unions_runme.ml b/trunk/Examples/test-suite/ocaml/unions_runme.ml
new file mode 100644
index 000000000..cbf1628ac
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/unions_runme.ml
@@ -0,0 +1,28 @@
+(* Test the unions example... *)
+
+open Swig
+open Unions
+
+let a = new_SmallStruct C_void
+let b = new_BigStruct C_void
+let c = new_UnionTest C_void
+let d = new_EmbeddedUnionTest C_void
+
+let _ = (invoke a) "jill" (C_short 3)
+let _ = (invoke b) "jack" (C_char 'a') (* Int conversion *)
+let _ = (invoke b) "smallstruct" a (* Put a in b *)
+let _ = (invoke c) "bs" b
+
+let _ = if get_int ((invoke a) "jill" C_void) != 3 then
+ raise (Failure "jill value is not preserved")
+let _ = if get_int ((invoke b) "jack" C_void) != (int_of_char 'a') then
+ raise (Failure "jack value is not preserved")
+let _ = if get_int ((invoke ((invoke b) "smallstruct" C_void))
+ "jill" C_void) != 3 then
+ raise (Failure "jill value is not embedded in bigstruct")
+let _ = if get_int ((invoke ((invoke c) "bs" C_void))
+ "jack" C_void) != (int_of_char 'a') then
+ raise (Failure "union set of bigstruct did not take")
+let _ = if get_int ((invoke ((invoke c) "ss" C_void))
+ "jill" C_void) != (int_of_char 'a') then
+ raise (Failure "corresponding union values are not the same")
diff --git a/trunk/Examples/test-suite/ocaml/using_protected_runme.ml b/trunk/Examples/test-suite/ocaml/using_protected_runme.ml
new file mode 100644
index 000000000..4dc4fe1c9
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/using_protected_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Using_protected
+
+let f = new_FooBar C_void
+let _ = (invoke f) "x" (C_int 3)
+
+let _ = if (invoke f) "blah" (C_int 4) <> (C_int 4) then
+ raise (Failure "blah(int)")
diff --git a/trunk/Examples/test-suite/ocaml/varargs_runme.ml b/trunk/Examples/test-suite/ocaml/varargs_runme.ml
new file mode 100644
index 000000000..52962d927
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/varargs_runme.ml
@@ -0,0 +1,11 @@
+(* Test case stolen from the python directory *)
+
+open Swig
+open Varargs
+
+let _ = if _test (C_string "Hello") <> (C_string "Hello") then
+ raise (Failure "1")
+
+let f = new_Foo C_void
+let _ = if (invoke f) "test" (C_string "Hello") <> (C_string "Hello") then
+ raise (Failure "2")
diff --git a/trunk/Examples/test-suite/ocaml/voidtest_runme.ml b/trunk/Examples/test-suite/ocaml/voidtest_runme.ml
new file mode 100644
index 000000000..542ec3508
--- /dev/null
+++ b/trunk/Examples/test-suite/ocaml/voidtest_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Voidtest
+
+let _ = _globalfunc C_void
+let f = new_Foo C_void
+let _ = (invoke f) "memberfunc" C_void
+
+let _ = _Foo_staticmemberfunc C_void
diff --git a/trunk/Examples/test-suite/octave/Makefile.in b/trunk/Examples/test-suite/octave/Makefile.in
new file mode 100644
index 000000000..0dbb6a1e5
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/Makefile.in
@@ -0,0 +1,90 @@
+#######################################################################
+# Makefile for octave test-suite
+#######################################################################
+
+LANGUAGE = octave
+OCTAVE = @OCTAVE@ -q
+SCRIPTSUFFIX = _runme.m
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+CPP_TEST_CASES += \
+ li_std_pair_extra \
+ li_std_string_extra \
+ octave_cell_deref
+
+CPP_TEST_BROKEN += \
+ implicittest \
+ li_implicit \
+ li_std_set \
+ li_std_stream
+
+#C_TEST_CASES +=
+
+#
+# This test only works with modern C compilers
+#
+#C_TEST_CASES += \
+# complextest
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+LIBS = -L.
+CSRCS = octave_empty.c
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.m appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):OCTAVEPATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: remove the generated .m file
+%.clean:
+ @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
+ @rm -f $*.m;
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile octave_clean
+
+cvsignore:
+ @echo '*wrap* *.mc *.so *.dll *.exp *.lib'
+ @echo Makefile
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done
+ @echo clientdata_prop_a.m
+ @echo clientdata_prop_b.m
+ @echo imports_a.m
+ @echo imports_b.m
+ @echo mod_a.m mod_b.m
+ @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
+ @echo template_typedef_import.m
+
+
+hugemod:
+ perl hugemod.pl
+ $(MAKE) hugemod_a.cpptest
+ $(MAKE) hugemod_b.cpptest
+ time $(OCTAVE) hugemod_runme.m
+ time $(OCTAVE) hugemod_runme.m
diff --git a/trunk/Examples/test-suite/octave/abstract_access_runme.m b/trunk/Examples/test-suite/octave/abstract_access_runme.m
new file mode 100644
index 000000000..e49343a92
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/abstract_access_runme.m
@@ -0,0 +1,7 @@
+abstract_access
+
+d = abstract_access.D();
+if (d.do_x() != 1)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/abstract_typedef2_runme.m b/trunk/Examples/test-suite/octave/abstract_typedef2_runme.m
new file mode 100644
index 000000000..7f364db4e
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/abstract_typedef2_runme.m
@@ -0,0 +1,8 @@
+abstract_typedef2
+
+a = A_UF();
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/abstract_typedef_runme.m b/trunk/Examples/test-suite/octave/abstract_typedef_runme.m
new file mode 100644
index 000000000..f28cf3c8b
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/abstract_typedef_runme.m
@@ -0,0 +1,12 @@
+abstract_typedef
+e = Engine();
+
+a = A();
+
+
+if (a.write(e) != 1)
+ error
+endif
+
+
+
diff --git a/trunk/Examples/test-suite/octave/abstract_virtual_runme.m b/trunk/Examples/test-suite/octave/abstract_virtual_runme.m
new file mode 100644
index 000000000..9845a5885
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/abstract_virtual_runme.m
@@ -0,0 +1,7 @@
+abstract_virtual
+
+
+d = D();
+
+e = E();
+
diff --git a/trunk/Examples/test-suite/octave/argcargvtest_runme.m b/trunk/Examples/test-suite/octave/argcargvtest_runme.m
new file mode 100644
index 000000000..f246dd9db
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/argcargvtest_runme.m
@@ -0,0 +1,29 @@
+argcargvtest
+
+largs={'hi','hola','hello'};
+if (mainc(largs) != 3)
+ error("bad main typemap");
+endif
+
+targs={'hi','hola'};
+if (mainv(targs,1) != 'hola')
+ error("bad main typemap");
+endif
+
+targs={'hi', 'hola'};
+if (mainv(targs,1) != 'hola')
+ error("bad main typemap");
+endif
+
+try
+ error_flag = 0;
+ mainv('hello',1);
+ error_flag = 1;
+catch
+end_try_catch
+if (error_flag)
+ error("bad main typemap")
+endif
+
+
+initializeApp(largs);
diff --git a/trunk/Examples/test-suite/octave/array_member_runme.m b/trunk/Examples/test-suite/octave/array_member_runme.m
new file mode 100644
index 000000000..56b7968c5
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/array_member_runme.m
@@ -0,0 +1,25 @@
+array_member
+
+f = Foo();
+f.data = cvar.global_data;
+
+for i=0:7,
+ if (get_value(f.data,i) != get_value(cvar.global_data,i))
+ error("Bad array assignment");
+ endif
+endfor
+
+for i=0:7,
+ set_value(f.data,i,-i);
+endfor
+
+cvar.global_data = f.data;
+
+for i=0:7,
+ if (get_value(f.data,i) != get_value(cvar.global_data,i))
+ error("Bad array assignment")
+ endif
+endfor
+
+
+
diff --git a/trunk/Examples/test-suite/octave/arrays_global_runme.m b/trunk/Examples/test-suite/octave/arrays_global_runme.m
new file mode 100644
index 000000000..619d381b0
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/arrays_global_runme.m
@@ -0,0 +1,19 @@
+arrays_global
+
+arrays_global.cvar.array_i = arrays_global.cvar.array_const_i;
+
+cvar.BeginString_FIX44a;
+cvar.BeginString_FIX44b;
+cvar.BeginString_FIX44c;
+cvar.BeginString_FIX44d;
+cvar.BeginString_FIX44d;
+cvar.BeginString_FIX44b = strcat("12","\0","45");
+cvar.BeginString_FIX44b;
+cvar.BeginString_FIX44d;
+cvar.BeginString_FIX44e;
+cvar.BeginString_FIX44f;
+
+test_a("hello","hi","chello","chi");
+
+test_b("1234567","hi");
+
diff --git a/trunk/Examples/test-suite/octave/callback_runme.m b/trunk/Examples/test-suite/octave/callback_runme.m
new file mode 100644
index 000000000..db9f7888d
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/callback_runme.m
@@ -0,0 +1,40 @@
+_callback
+callback
+
+if (foo(2) != 2)
+ error
+endif
+
+if (A_bar(2) != 4)
+ error
+endif
+
+if (foobar(3, _callback.foo) != foo(3))
+ error
+endif
+
+if (foobar(3, foo) != foo(3))
+ error
+endif
+
+if (foobar(3, A_bar) != A_bar(3))
+ error
+endif
+
+if (foobar(3, foof) != foof(3))
+ error
+endif
+
+if (foobar_i(3, foo_i) != foo_i(3))
+ error
+endif
+
+
+if (foobar_d(3.5, foo_d) != foo_d(3.5))
+ error
+endif
+
+a = A();
+if (foobarm(3, a, A.foom_cb_ptr) != a.foom(3))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/class_ignore_runme.m b/trunk/Examples/test-suite/octave/class_ignore_runme.m
new file mode 100644
index 000000000..76bbcd3f0
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/class_ignore_runme.m
@@ -0,0 +1,7 @@
+class_ignore
+
+a = class_ignore.Bar();
+
+if (!strcmp(class_ignore.do_blah(a),"Bar::blah"))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/class_scope_weird_runme.m b/trunk/Examples/test-suite/octave/class_scope_weird_runme.m
new file mode 100644
index 000000000..2fc857808
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/class_scope_weird_runme.m
@@ -0,0 +1,7 @@
+class_scope_weird
+
+f = class_scope_weird.Foo();
+g = class_scope_weird.Foo(3);
+if (f.bar(3) != 3)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/compactdefaultargs_runme.m b/trunk/Examples/test-suite/octave/compactdefaultargs_runme.m
new file mode 100644
index 000000000..08e872724
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/compactdefaultargs_runme.m
@@ -0,0 +1,24 @@
+compactdefaultargs
+
+defaults1 = Defaults1(1000);
+defaults1 = Defaults1();
+
+if (defaults1.ret(10.0) != 10.0)
+ error
+endif
+
+if (defaults1.ret() != -1.0)
+ error
+endif
+
+defaults2 = Defaults2(1000);
+defaults2 = Defaults2();
+
+if (defaults2.ret(10.0) != 10.0)
+ error
+endif
+
+if (defaults2.ret() != -1.0)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/complextest_runme.m b/trunk/Examples/test-suite/octave/complextest_runme.m
new file mode 100644
index 000000000..cd0f9f4e2
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/complextest_runme.m
@@ -0,0 +1,19 @@
+complextest
+
+a = complex(-1,2);
+
+if (complextest.Conj(a) != a.conjugate())
+ error("bad complex mapping")
+endif
+
+if (complextest.Conjf(a) != a.conjugate())
+ error("bad complex mapping")
+endif
+
+
+v = (complex(1,2), complex(2,3), complex(4,3), 1);
+
+try
+ complextest.Copy_h(v);
+catch
+end_try_catch
diff --git a/trunk/Examples/test-suite/octave/constover_runme.m b/trunk/Examples/test-suite/octave/constover_runme.m
new file mode 100644
index 000000000..febcdae69
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/constover_runme.m
@@ -0,0 +1,34 @@
+constover
+
+p = constover.test("test");
+if (!strcmp(p,"test"))
+ error("test failed!")
+endif
+
+p = constover.test_pconst("test");
+if (!strcmp(p,"test_pconst"))
+ error("test_pconst failed!")
+endif
+
+f = constover.Foo();
+p = f.test("test");
+if (!strcmp(p,"test"))
+ error("member-test failed!")
+endif
+
+p = f.test_pconst("test");
+if (!strcmp(p,"test_pconst"))
+ error("member-test_pconst failed!")
+endif
+
+p = f.test_constm("test");
+if (!strcmp(p,"test_constmethod"))
+ error("member-test_constm failed!")
+endif
+
+p = f.test_pconstm("test");
+if (!strcmp(p,"test_pconstmethod"))
+ error("member-test_pconstm failed!")
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/constructor_copy_runme.m b/trunk/Examples/test-suite/octave/constructor_copy_runme.m
new file mode 100644
index 000000000..5d52ab525
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/constructor_copy_runme.m
@@ -0,0 +1,44 @@
+constructor_copy
+
+f1 = Foo1(3);
+f11 = Foo1(f1);
+
+
+if (f1.x != f11.x)
+ error
+endif
+
+
+f8 = Foo8();
+try
+ f81 = Foo8(f8);
+ good = 0;
+catch
+ good = 1;
+end_try_catch
+
+if (!good)
+ error
+endif
+
+
+bi = Bari(5);
+bc = Bari(bi);
+
+if (bi.x != bc.x)
+ error
+endif
+
+
+bd = Bard(5);
+try
+ bc = Bard(bd);
+ good = 0;
+catch
+ good = 1;
+end_try_catch
+
+if (!good)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/contract_runme.m b/trunk/Examples/test-suite/octave/contract_runme.m
new file mode 100644
index 000000000..9170e77f2
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/contract_runme.m
@@ -0,0 +1,135 @@
+contract
+
+contract.test_preassert(1,2);
+try
+ contract.test_preassert(-1,0)
+ error("Failed! Preassertions are broken")
+catch
+end_try_catch
+
+contract.test_postassert(3);
+try
+ contract.test_postassert(-3);
+ error("Failed! Postassertions are broken")
+catch
+end_try_catch
+
+contract.test_prepost(2,3);
+contract.test_prepost(5,-4);
+try
+ contract.test_prepost(-3,4);
+ error("Failed! Preassertions are broken")
+catch
+end_try_catch
+
+try
+ contract.test_prepost(4,-10);
+ error("Failed! Postassertions are broken")
+
+catch
+end_try_catch
+
+f = contract.Foo();
+f.test_preassert(4,5);
+try
+ f.test_preassert(-2,3);
+ error("Failed! Method preassertion.")
+catch
+end_try_catch
+
+f.test_postassert(4);
+try
+ f.test_postassert(-4);
+ error("Failed! Method postassertion")
+catch
+end_try_catch
+
+f.test_prepost(3,4);
+f.test_prepost(4,-3);
+try
+ f.test_prepost(-4,2);
+ error("Failed! Method preassertion.")
+catch
+end_try_catch
+
+try
+ f.test_prepost(4,-10);
+ error("Failed! Method postassertion.")
+catch
+end_try_catch
+
+contract.Foo_stest_prepost(4,0);
+try
+ contract.Foo_stest_prepost(-4,2);
+ error("Failed! Static method preassertion")
+catch
+end_try_catch
+
+try
+ contract.Foo_stest_prepost(4,-10);
+ error("Failed! Static method posteassertion")
+catch
+end_try_catch
+
+b = contract.Bar();
+try
+ b.test_prepost(2,-4);
+ error("Failed! Inherited preassertion.")
+catch
+end_try_catch
+
+
+d = contract.D();
+try
+ d.foo(-1,1,1,1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.foo(1,-1,1,1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.foo(1,1,-1,1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.foo(1,1,1,-1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.foo(1,1,1,1,-1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+
+
+try
+ d.bar(-1,1,1,1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.bar(1,-1,1,1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.bar(1,1,-1,1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.bar(1,1,1,-1,1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+try
+ d.bar(1,1,1,1,-1);
+ error("Failed! Inherited preassertion (D).")
+catch
+end_try_catch
+
diff --git a/trunk/Examples/test-suite/octave/cpp_enum_runme.m b/trunk/Examples/test-suite/octave/cpp_enum_runme.m
new file mode 100644
index 000000000..fe5f3b183
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/cpp_enum_runme.m
@@ -0,0 +1,27 @@
+cpp_enum
+
+f = cpp_enum.Foo();
+
+if (f.hola != cpp_enum.Foo_Hello)
+ error(f.hola);
+ error;
+endif
+
+f.hola = cpp_enum.Foo_Hi;
+if (f.hola != cpp_enum.Foo_Hi)
+ error(f.hola);
+ error;
+endif
+
+f.hola = cpp_enum.Foo_Hello;
+
+if (f.hola != cpp_enum.Foo_Hello)
+ error(f.hola);
+ error;
+endif
+
+cpp_enum.hi = cpp_enum.Hello;
+if (cpp_enum.hi != cpp_enum.Hello)
+ error(cpp_enum.hi);
+ error;
+endif
diff --git a/trunk/Examples/test-suite/octave/cpp_namespace_runme.m b/trunk/Examples/test-suite/octave/cpp_namespace_runme.m
new file mode 100644
index 000000000..ac6c663fa
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/cpp_namespace_runme.m
@@ -0,0 +1,55 @@
+# Note: This example assumes that namespaces are flattened
+cpp_namespace
+
+n = cpp_namespace.fact(4);
+if (n != 24)
+ error("Bad return value!")
+endif
+
+if (cpp_namespace.cvar.Foo != 42)
+ error("Bad variable value!")
+endif
+
+t = cpp_namespace.Test();
+if (!strcmp(t.method(),"Test::method"))
+ error("Bad method return value!")
+endif
+
+if (!strcmp(cpp_namespace.do_method(t),"Test::method"))
+ error("Bad return value!")
+endif
+
+if (!strcmp(cpp_namespace.do_method2(t),"Test::method"))
+ error("Bad return value!")
+endif
+
+cpp_namespace.weird("hello", 4);
+
+clear t;
+
+t2 = cpp_namespace.Test2();
+t3 = cpp_namespace.Test3();
+t4 = cpp_namespace.Test4();
+t5 = cpp_namespace.Test5();
+
+if (cpp_namespace.foo3(42) != 42)
+ error("Bad return value!")
+endif
+
+if (!strcmp(cpp_namespace.do_method3(t2,40),"Test2::method"))
+ error("Bad return value!")
+endif
+
+if (!strcmp(cpp_namespace.do_method3(t3,40),"Test3::method"))
+ error("Bad return value!")
+endif
+
+if (!strcmp(cpp_namespace.do_method3(t4,40),"Test4::method"))
+ error("Bad return value!")
+endif
+
+if (!strcmp(cpp_namespace.do_method3(t5,40),"Test5::method"))
+ error("Bad return value!")
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/default_args_runme.m b/trunk/Examples/test-suite/octave/default_args_runme.m
new file mode 100644
index 000000000..f8a656003
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/default_args_runme.m
@@ -0,0 +1,86 @@
+default_args
+
+
+if (default_args.Statics.staticmethod() != 60)
+ error
+endif
+
+if (default_args.cfunc1(1) != 2)
+ error
+endif
+
+if (default_args.cfunc2(1) != 3)
+ error
+endif
+
+if (default_args.cfunc3(1) != 4)
+ error
+endif
+
+
+f = default_args.Foo();
+
+f.newname();
+f.newname(1);
+
+
+try
+ f = default_args.Foo(1);
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+if (ok)
+ error("Foo::Foo ignore is not working")
+endif
+
+try
+ f = default_args.Foo(1,2);
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+if (ok)
+ error("Foo::Foo ignore is not working")
+endif
+
+try
+ f = default_args.Foo(1,2,3);
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+if (ok)
+ error("Foo::Foo ignore is not working")
+endif
+
+try
+ m = f.meth(1);
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+if (ok)
+ error("Foo::meth ignore is not working")
+endif
+
+try
+ m = f.meth(1,2);
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+if (ok)
+ error("Foo::meth ignore is not working")
+endif
+
+try
+ m = f.meth(1,2,3);
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+if (ok)
+ error("Foo::meth ignore is not working")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/default_constructor_runme.m b/trunk/Examples/test-suite/octave/default_constructor_runme.m
new file mode 100644
index 000000000..41d0f3f1e
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/default_constructor_runme.m
@@ -0,0 +1,111 @@
+default_constructor
+
+dc = default_constructor;
+
+a = dc.new_A();
+dc.delete_A(a);
+
+aa = dc.new_AA();
+dc.delete_AA(aa);
+
+try
+ b = dc.new_B();
+ error("Whoa. new_BB created.")
+catch
+end_try_catch
+
+del_b = dc.delete_B;
+
+try
+ bb = dc.new_BB();
+ error("Whoa. new_BB created.")
+catch
+end_try_catch
+
+del_bb = dc.delete_BB;
+
+try
+ c = dc.new_C();
+ error("Whoa. new_C created.")
+catch
+end_try_catch
+
+del_c = dc.delete_C;
+
+cc = dc.new_CC();
+dc.delete_CC(cc);
+
+try
+ d = dc.new_D();
+ error("Whoa. new_D created")
+catch
+end_try_catch
+
+del_d = dc.delete_D;
+
+try
+ dd = dc.new_DD();
+ error("Whoa. new_DD created")
+catch
+end_try_catch
+
+dd = dc.delete_DD;
+
+try
+ ad = dc.new_AD();
+ error("Whoa. new_AD created")
+catch
+end_try_catch
+
+del_ad = dc.delete_AD;
+
+e = dc.new_E();
+dc.delete_E(e);
+
+ee = dc.new_EE();
+dc.delete_EE(ee);
+
+try
+ eb = dc.new_EB();
+ error("Whoa. new_EB created")
+catch
+end_try_catch
+
+del_eb = dc.delete_EB;
+
+f = dc.new_F();
+
+try
+ del_f = dc.delete_F;
+ error("Whoa. delete_F created")
+catch
+end_try_catch
+
+dc.F_destroy(f);
+
+ff = dc.new_FFF();
+try
+ del_ff = dc.delete_FFF;
+ error("Whoa. delete_FFF created")
+catch
+end_try_catch
+
+dc.F_destroy(ff);
+
+g = dc.new_G();
+
+try
+ del_g = dc.delete_G;
+ error("Whoa. delete_G created")
+catch
+end_try_catch
+
+dc.G_destroy(g);
+
+gg = dc.new_GG();
+dc.delete_GG(gg);
+
+
+hh = default_constructor.HH(1,1);
+
+
diff --git a/trunk/Examples/test-suite/octave/director_abstract_runme.m b/trunk/Examples/test-suite/octave/director_abstract_runme.m
new file mode 100644
index 000000000..00fb676f5
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_abstract_runme.m
@@ -0,0 +1,44 @@
+director_abstract
+
+MyFoo=@() subclass(director_abstract.Foo(),@ping);
+function out=ping(self)
+ out="MyFoo::ping()";
+end
+
+
+a = MyFoo();
+
+if (!strcmp(a.ping(),"MyFoo::ping()"))
+ error(a.ping())
+endif
+
+if (!strcmp(a.pong(),"Foo::pong();MyFoo::ping()"))
+ error(a.pong())
+endif
+
+
+MyExample1=@() subclass(director_abstract.Example1(),'Color',@(self,r,g,b) r);
+MyExample2=@(a,b) subclass(director_abstract.Example2(a,b),'Color',@(self,r,g,b) g);
+MyExample3=@() subclass(director_abstract.Example3_i(),'Color',@(self,r,g,b) b);
+
+me1 = MyExample1();
+if (director_abstract.Example1.get_color(me1, 1,2,3) != 1)
+ error
+endif
+
+me2 = MyExample2(1,2);
+if (me2.get_color(me2, 1,2,3) != 2)
+ error
+endif
+
+me3 = MyExample3();
+if (me3.get_color(me3, 1,2,3) != 3)
+ error
+endif
+
+
+# don't check that we cannot construct abstract bases, since we have no
+# way of disambiguating that with the normal construction case using
+# subclass. furthermore, calling a pure virtual method will still generate
+# an error.
+
diff --git a/trunk/Examples/test-suite/octave/director_basic_runme.m b/trunk/Examples/test-suite/octave/director_basic_runme.m
new file mode 100644
index 000000000..9de54a385
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_basic_runme.m
@@ -0,0 +1,110 @@
+director_basic
+
+
+function self=OctFoo()
+ global director_basic;
+ self=subclass(director_basic.Foo());
+ self.ping=@OctFoo_ping;
+end
+function string=OctFoo_ping(self)
+ string="OctFoo::ping()";
+end
+
+a = OctFoo();
+
+if (!strcmp(a.ping(),"OctFoo::ping()"))
+ error(a.ping())
+endif
+
+if (!strcmp(a.pong(),"Foo::pong();OctFoo::ping()"))
+ error(a.pong())
+endif
+
+b = director_basic.Foo();
+
+if (!strcmp(b.ping(),"Foo::ping()"))
+ error(b.ping())
+endif
+
+if (!strcmp(b.pong(),"Foo::pong();Foo::ping()"))
+ error(b.pong())
+endif
+
+a = director_basic.A1(1);
+
+if (a.rg(2) != 2)
+ error
+endif
+
+function self=OctClass()
+ global director_basic;
+ self=subclass(director_basic.MyClass());
+ self.method=@OctClass_method;
+ self.vmethod=@OctClass_vmethod;
+end
+function OctClass_method(self,vptr)
+ self.cmethod = 7;
+end
+function out=OctClass_vmethod(self,b)
+ b.x = b.x + 31;
+ out=b;
+end
+
+b = director_basic.Bar(3);
+d = director_basic.MyClass();
+c = OctClass();
+
+cc = director_basic.MyClass_get_self(c);
+dd = director_basic.MyClass_get_self(d);
+
+bc = cc.cmethod(b);
+bd = dd.cmethod(b);
+
+cc.method(b);
+if (c.cmethod != 7)
+ error
+endif
+
+if (bc.x != 34)
+ error
+endif
+
+
+if (bd.x != 16)
+ error
+endif
+
+
+function self=OctMulti()
+ global director_basic;
+ self=subclass(director_basic.Foo(),director_basic.MyClass());
+ self.vmethod=@OctMulti_vmethod;
+ self.ping=@OctMulti_ping;
+end
+function out=OctMulti_vmethod(self,b)
+ b.x = b.x + 31;
+ out=b;
+end
+function out=OctMulti_ping(self)
+ out="OctFoo::ping()";
+end
+
+a = 0;
+for i=0:100,
+ octmult = OctMulti();
+ octmult.pong();
+ clear octmult
+endfor
+
+
+octmult = OctMulti();
+
+
+p1 = director_basic.Foo_get_self(octmult);
+p2 = director_basic.MyClass_get_self(octmult);
+
+p1.ping();
+p2.vmethod(bc);
+
+
+
diff --git a/trunk/Examples/test-suite/octave/director_classic_runme.m b/trunk/Examples/test-suite/octave/director_classic_runme.m
new file mode 100644
index 000000000..c1f8e95d4
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_classic_runme.m
@@ -0,0 +1,98 @@
+director_classic
+
+TargetLangPerson=@() subclass(Person(),'id',@(self) "TargetLangPerson");
+TargetLangChild=@() subclass(Child(),'id',@(self) "TargetLangChild");
+TargetLangGrandChild=@() subclass(GrandChild(),'id',@(self) "TargetLangGrandChild");
+
+# Semis - don't override id() in target language
+TargetLangSemiPerson=@() subclass(Person());
+TargetLangSemiChild=@() subclass(Child());
+TargetLangSemiGrandChild=@() subclass(GrandChild());
+
+# Orphans - don't override id() in C++
+TargetLangOrphanPerson=@() subclass(OrphanPerson(),'id',@(self) "TargetLangOrphanPerson");
+TargetLangOrphanChild=@() subclass(OrphanChild(),'id',@(self) "TargetLangOrphanChild");
+
+
+function check(person,expected)
+ global Caller;
+
+ # Normal target language polymorphic call
+ ret = person.id();
+ if (ret != expected)
+ raise ("Failed. Received: " + ret + " Expected: " + expected);
+ endif
+
+ # Polymorphic call from C++
+ caller = Caller();
+ caller.setCallback(person);
+ ret = caller.call();
+ if (ret != expected)
+ error ("Failed. Received: " + ret + " Expected: " + expected);
+ endif
+
+ # Polymorphic call of object created in target language and passed to C++ and back again
+ baseclass = caller.baseClass();
+ ret = baseclass.id();
+ if (ret != expected)
+ error ("Failed. Received: " + ret + " Expected: " + expected);
+ endif
+
+ caller.resetCallback();
+end
+
+
+person = Person();
+check(person, "Person");
+clear person;
+
+person = Child();
+check(person, "Child");
+clear person;
+
+person = GrandChild();
+check(person, "GrandChild");
+clear person;
+
+person = TargetLangPerson();
+check(person, "TargetLangPerson");
+clear person;
+
+person = TargetLangChild();
+check(person, "TargetLangChild");
+clear person;
+
+person = TargetLangGrandChild();
+check(person, "TargetLangGrandChild");
+clear person;
+
+# Semis - don't override id() in target language
+person = TargetLangSemiPerson();
+check(person, "Person");
+clear person;
+
+person = TargetLangSemiChild();
+check(person, "Child");
+clear person;
+
+person = TargetLangSemiGrandChild();
+check(person, "GrandChild");
+clear person;
+
+# Orphans - don't override id() in C++
+person = OrphanPerson();
+check(person, "Person");
+clear person;
+
+person = OrphanChild();
+check(person, "Child");
+clear person;
+
+person = TargetLangOrphanPerson();
+check(person, "TargetLangOrphanPerson");
+clear person;
+
+person = TargetLangOrphanChild();
+check(person, "TargetLangOrphanChild");
+clear person;
+
diff --git a/trunk/Examples/test-suite/octave/director_default_runme.m b/trunk/Examples/test-suite/octave/director_default_runme.m
new file mode 100644
index 000000000..c0b479d2a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_default_runme.m
@@ -0,0 +1,10 @@
+director_default
+
+
+f = Foo();
+f = Foo(1);
+
+
+f = Bar();
+f = Bar(1);
+
diff --git a/trunk/Examples/test-suite/octave/director_detect_runme.m b/trunk/Examples/test-suite/octave/director_detect_runme.m
new file mode 100644
index 000000000..f2d8c8dd2
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_detect_runme.m
@@ -0,0 +1,36 @@
+director_detect
+
+global MyBar=@(val=2) \
+ subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone);
+function val=get_value(self)
+ self.val = self.val + 1;
+ val = self.val;
+end
+function ptr=get_class(self)
+ global director_detect;
+ self.val = self.val + 1;
+ ptr=director_detect.A();
+end
+function just_do_it(self)
+ self.val = self.val + 1;
+end
+function ptr=clone(self)
+ global MyBar;
+ ptr=MyBar(self.val);
+end
+
+b = MyBar();
+
+f = b.baseclass();
+
+v = f.get_value();
+a = f.get_class();
+f.just_do_it();
+
+c = b.clone();
+vc = c.get_value();
+
+if ((v != 3) || (b.val != 5) || (vc != 6))
+ error("Bad virtual detection")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/director_enum_runme.m b/trunk/Examples/test-suite/octave/director_enum_runme.m
new file mode 100644
index 000000000..96f158d39
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_enum_runme.m
@@ -0,0 +1,10 @@
+director_enum
+
+MyFoo=@() subclass(director_enum.Foo(),'say_hi',@(self,val) val);
+
+b = director_enum.Foo();
+a = MyFoo();
+
+if (a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/director_extend_runme.m b/trunk/Examples/test-suite/octave/director_extend_runme.m
new file mode 100644
index 000000000..1cbeac8e2
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_extend_runme.m
@@ -0,0 +1,12 @@
+director_extend
+
+MyObject=@() subclass(SpObject(),'getFoo',@(self) 123);
+
+m = MyObject();
+if (m.dummy() != 666)
+ error("1st call")
+endif
+if (m.dummy() != 666)
+ error("2nd call")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/director_frob_runme.m b/trunk/Examples/test-suite/octave/director_frob_runme.m
new file mode 100644
index 000000000..16585cc9e
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_frob_runme.m
@@ -0,0 +1,9 @@
+director_frob
+
+foo = Bravo();
+s = foo.abs_method();
+
+if (!strcmp(s,"Bravo::abs_method()"))
+ error(s)
+endif
+
diff --git a/trunk/Examples/test-suite/octave/director_nested_runme.m b/trunk/Examples/test-suite/octave/director_nested_runme.m
new file mode 100644
index 000000000..6e1d0ded9
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_nested_runme.m
@@ -0,0 +1,39 @@
+director_nested
+
+A=@() subclass(FooBar_int(),
+ 'do_step',@(self) "A::do_step;",
+ 'get_value',@(self) "A::get_value");
+
+a = A();
+if (!strcmp(a.step(),"Bar::step;Foo::advance;Bar::do_advance;A::do_step;"))
+ error("Bad A virtual resolution")
+endif
+
+B=@() subclass(FooBar_int(),
+ 'do_advance',@(self) strcat("B::do_advance;",self.do_step()),
+ 'do_step',@(self) "B::do_step;",
+ 'get_value',@(self) 1);
+
+b = B();
+
+if (!strcmp(b.step(),"Bar::step;Foo::advance;B::do_advance;B::do_step;"))
+ error("Bad B virtual resolution")
+endif
+
+C=@() subclass(FooBar_int(),
+ 'do_advance',@(self) strcat("C::do_advance;",self.FooBar_int.do_advance()),
+ 'do_step',@(self) "C::do_step;",
+ 'get_value',@(self) 2,
+ 'get_name',@(self) strcat(self.FooBar_int.get_name()," hello"));
+
+cc = C();
+c = FooBar_int_get_self(cc);
+c.advance();
+
+if (!strcmp(c.get_name(),"FooBar::get_name hello"))
+ error
+endif
+
+if (!strcmp(c.name(),"FooBar::get_name hello"))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/director_stl_runme.m b/trunk/Examples/test-suite/octave/director_stl_runme.m
new file mode 100644
index 000000000..e8f4c5e34
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_stl_runme.m
@@ -0,0 +1,31 @@
+director_stl
+
+MyFoo=@() subclass(director_stl.Foo(),\
+ 'ping',@(self,s) "MyFoo::ping():" + s,\
+ 'pident',@(self,arg) arg,\
+ 'vident',@(self,v) v,\
+ 'vidents',@(self,v) v,\
+ 'vsecond',@(self,v1,v2) v2,\
+);
+
+a = MyFoo();
+
+a.tping("hello");
+a.tpong("hello");
+
+p = {1,2}
+a.pident(p);
+v = {3,4}
+a.vident(v);
+
+a.tpident(p);
+a.tvident(v);
+
+v1 = {3,4};
+v2 = {5,6};
+a.tvsecond(v1,v2);
+
+vs=("hi", "hello");
+vs;
+a.tvidents(vs);
+
diff --git a/trunk/Examples/test-suite/octave/director_string_runme.m b/trunk/Examples/test-suite/octave/director_string_runme.m
new file mode 100644
index 000000000..c2d4e9ce7
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_string_runme.m
@@ -0,0 +1,27 @@
+director_string
+
+
+function out=get_first(self)
+ out = strcat(self.A.get_first()," world!");
+end
+function process_text(self,string)
+ self.A.process_text(string);
+ self.smem = "hello";
+end
+B=@(string) subclass(A(string),'get_first',@get_first,'process_text',@process_text);
+
+
+b = B("hello");
+
+b.get(0);
+if (!strcmp(b.get_first(),"hello world!"))
+ error(b.get_first())
+endif
+
+b.call_process_func();
+
+if (!strcmp(b.smem,"hello"))
+ error(b.smem)
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/director_unroll_runme.m b/trunk/Examples/test-suite/octave/director_unroll_runme.m
new file mode 100644
index 000000000..6ca213c4c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_unroll_runme.m
@@ -0,0 +1,16 @@
+director_unroll
+
+MyFoo=@() subclass(director_unroll.Foo(),'ping',@(self) "MyFoo::ping()");
+
+a = MyFoo();
+
+b = director_unroll.Bar();
+
+b.set(a);
+c = b.get();
+
+if (swig_this(a) != swig_this(c))
+ a,c
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/director_wstring_runme.m b/trunk/Examples/test-suite/octave/director_wstring_runme.m
new file mode 100644
index 000000000..b59ff6efa
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/director_wstring_runme.m
@@ -0,0 +1,21 @@
+director_wstring
+
+
+B=@(string) subclass(A(string),\
+ 'get_first',A.get_first(self) + " world!",\
+ 'process_text',@(self) self.smem = u"hello"\
+ );
+
+b = B("hello");
+
+b.get(0);
+if (!strcmp(b.get_first(),"hello world!"))
+ error(b.get_first())
+endif
+
+b.call_process_func();
+
+if (!strcmp(b.smem,"hello"))
+ error(smem)
+endif
+
diff --git a/trunk/Examples/test-suite/octave/dynamic_cast_runme.m b/trunk/Examples/test-suite/octave/dynamic_cast_runme.m
new file mode 100644
index 000000000..dad0ba25c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/dynamic_cast_runme.m
@@ -0,0 +1,14 @@
+dynamic_cast
+
+f = dynamic_cast.Foo();
+b = dynamic_cast.Bar();
+
+x = f.blah();
+y = b.blah();
+
+a = dynamic_cast.do_test(y);
+if (!strcmp(a,"Bar::test"))
+ error("Failed!!")
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/empty_runme.m b/trunk/Examples/test-suite/octave/empty_runme.m
new file mode 100644
index 000000000..e7b64f1cd
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/empty_runme.m
@@ -0,0 +1,2 @@
+empty
+
diff --git a/trunk/Examples/test-suite/octave/enum_template_runme.m b/trunk/Examples/test-suite/octave/enum_template_runme.m
new file mode 100644
index 000000000..ca10f1f37
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/enum_template_runme.m
@@ -0,0 +1,13 @@
+enum_template
+
+if (enum_template.MakeETest() != 1)
+ error
+endif
+
+enum_template.TakeETest(0);
+try
+ a=enum_template.TakeETest(0);
+ error
+catch
+end_try_catch
+
diff --git a/trunk/Examples/test-suite/octave/enums_runme.m b/trunk/Examples/test-suite/octave/enums_runme.m
new file mode 100644
index 000000000..b654d9d04
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/enums_runme.m
@@ -0,0 +1,23 @@
+
+enums
+
+enums.bar2(1)
+enums.bar3(1)
+enums.bar1(1)
+
+if (enums.cvar.enumInstance != 2)
+ error
+endif
+
+if (enums.cvar.Slap != 10)
+ error
+endif
+
+if (enums.cvar.Mine != 11)
+ error
+endif
+
+if (enums.cvar.Thigh != 12)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/exception_order_runme.m b/trunk/Examples/test-suite/octave/exception_order_runme.m
new file mode 100644
index 000000000..3fb2b9a50
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/exception_order_runme.m
@@ -0,0 +1,44 @@
+exception_order
+
+
+a = A();
+
+try
+ a.foo()
+catch
+ if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
+ error("bad exception order")
+ endif
+end_try_catch
+
+try
+ a.bar()
+catch
+ if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2\n"))
+ error("bad exception order")
+ endif
+end_try_catch
+
+try
+ a.foobar()
+catch
+ if (!strcmp(lasterror.message, "error: postcatch unknown (SWIG_RuntimeError)\n"))
+ error("bad exception order")
+ endif
+end_try_catch
+
+try
+ a.barfoo(1)
+catch
+ if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
+ error("bad exception order")
+ endif
+end_try_catch
+
+try
+ a.barfoo(2)
+catch
+ if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2 *\n"))
+ error("bad exception order")
+ endif
+end_try_catch
diff --git a/trunk/Examples/test-suite/octave/extend_placement_runme.m b/trunk/Examples/test-suite/octave/extend_placement_runme.m
new file mode 100644
index 000000000..b7a8e783d
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/extend_placement_runme.m
@@ -0,0 +1,46 @@
+extend_placement
+
+foo = extend_placement.Foo();
+foo = extend_placement.Foo(1);
+foo = extend_placement.Foo(1,1);
+foo.spam();
+foo.spam("hello");
+foo.spam(1);
+foo.spam(1,1);
+foo.spam(1,1,1);
+foo.spam(extend_placement.Foo());
+foo.spam(extend_placement.Foo(), 1.0);
+
+
+bar = extend_placement.Bar();
+bar = extend_placement.Bar(1);
+bar.spam();
+bar.spam("hello");
+bar.spam(1);
+bar.spam(1,1);
+bar.spam(1,1,1);
+bar.spam(extend_placement.Bar());
+bar.spam(extend_placement.Bar(), 1.0);
+
+
+foo = extend_placement.FooTi();
+foo = extend_placement.FooTi(1);
+foo = extend_placement.FooTi(1,1);
+foo.spam();
+foo.spam("hello");
+foo.spam(1);
+foo.spam(1,1);
+foo.spam(1,1,1);
+foo.spam(extend_placement.Foo());
+foo.spam(extend_placement.Foo(), 1.0);
+
+
+bar = extend_placement.BarTi();
+bar = extend_placement.BarTi(1);
+bar.spam();
+bar.spam("hello");
+bar.spam(1);
+bar.spam(1,1);
+bar.spam(1,1,1);
+bar.spam(extend_placement.Bar());
+bar.spam(extend_placement.Bar(), 1.0);
diff --git a/trunk/Examples/test-suite/octave/extend_template_ns_runme.m b/trunk/Examples/test-suite/octave/extend_template_ns_runme.m
new file mode 100644
index 000000000..401ea6327
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/extend_template_ns_runme.m
@@ -0,0 +1,10 @@
+extend_template_ns
+
+f = Foo_One();
+if (f.test1(37) != 37)
+ error
+endif
+
+if (f.test2(42) != 42)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/extend_template_runme.m b/trunk/Examples/test-suite/octave/extend_template_runme.m
new file mode 100644
index 000000000..1cad7bfc9
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/extend_template_runme.m
@@ -0,0 +1,10 @@
+extend_template
+
+f = extend_template.Foo_0();
+if (f.test1(37) != 37)
+ error
+endif
+
+if (f.test2(42) != 42)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/extend_variable_runme.m b/trunk/Examples/test-suite/octave/extend_variable_runme.m
new file mode 100644
index 000000000..c55b6c55c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/extend_variable_runme.m
@@ -0,0 +1,6 @@
+extend_variable
+
+if (Foo.Bar != 42)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/file_test_runme.m b/trunk/Examples/test-suite/octave/file_test_runme.m
new file mode 100644
index 000000000..4c22a307c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/file_test_runme.m
@@ -0,0 +1,9 @@
+file_test
+
+file_test.nfile("stdout");
+
+cstdout = file_test.GetStdOut();
+
+file_test.nfile(cstdout);
+file_test.nfile_name("test.dat");
+
diff --git a/trunk/Examples/test-suite/octave/friends_runme.m b/trunk/Examples/test-suite/octave/friends_runme.m
new file mode 100644
index 000000000..e18f47a24
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/friends_runme.m
@@ -0,0 +1,46 @@
+friends
+
+a = friends.A(2);
+
+if (friends.get_val1(a) != 2)
+ error
+endif
+if (friends.get_val2(a) != 4)
+ error
+endif
+if (friends.get_val3(a) != 6)
+ error
+endif
+
+ # nice overload working fine
+if (friends.get_val1(1,2,3) != 1)
+ error
+endif
+
+b = friends.B(3);
+
+ # David's case
+if (friends.mix(a,b) != 5)
+ error
+endif
+
+di = friends.D_d(2);
+dd = friends.D_d(3.3);
+
+ # incredible template overloading working just fine
+if (friends.get_val1(di) != 2)
+ error
+endif
+if (friends.get_val1(dd) != 3.3)
+ error
+endif
+
+friends.set(di, 4);
+friends.set(dd, 1.3);
+
+if (friends.get_val1(di) != 4)
+ error
+endif
+if (friends.get_val1(dd) != 1.3)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/fvirtual_runme.m b/trunk/Examples/test-suite/octave/fvirtual_runme.m
new file mode 100644
index 000000000..e755a559a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/fvirtual_runme.m
@@ -0,0 +1,10 @@
+fvirtual
+
+sw = NodeSwitch();
+n = Node();
+i = sw.addChild(n);
+
+if (i != 2)
+ error("addChild")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/global_ns_arg_runme.m b/trunk/Examples/test-suite/octave/global_ns_arg_runme.m
new file mode 100644
index 000000000..fa3625ef1
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/global_ns_arg_runme.m
@@ -0,0 +1,5 @@
+global_ns_arg
+
+a = foo(1);
+b = bar();
+
diff --git a/trunk/Examples/test-suite/octave/grouping_runme.m b/trunk/Examples/test-suite/octave/grouping_runme.m
new file mode 100644
index 000000000..26b896c2b
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/grouping_runme.m
@@ -0,0 +1,15 @@
+grouping
+
+x = grouping.test1(42);
+if (x != 42)
+ error
+endif
+
+grouping.test2(42);
+
+x = (grouping.do_unary(37, grouping.NEGATE));
+if (x != -37)
+ error
+endif
+
+grouping.cvar.test3 = 42;
diff --git a/trunk/Examples/test-suite/octave/iadd_runme.m b/trunk/Examples/test-suite/octave/iadd_runme.m
new file mode 100755
index 000000000..c386c669e
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/iadd_runme.m
@@ -0,0 +1,10 @@
+iadd
+
+f = iadd.Foo();
+
+f.AsA.x = 3;
+f.AsA += f.AsA;
+
+if (f.AsA.x != 6)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/import_nomodule_runme.m b/trunk/Examples/test-suite/octave/import_nomodule_runme.m
new file mode 100644
index 000000000..a70b46885
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/import_nomodule_runme.m
@@ -0,0 +1,8 @@
+import_nomodule
+
+f = create_Foo();
+test1(f,42);
+delete_Foo(f);
+
+b = Bar();
+test1(b,37);
diff --git a/trunk/Examples/test-suite/octave/imports_runme.m b/trunk/Examples/test-suite/octave/imports_runme.m
new file mode 100644
index 000000000..be9db5919
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/imports_runme.m
@@ -0,0 +1,19 @@
+# This is the import runtime testcase.
+
+imports_b;
+imports_a;
+
+x = imports_b.B();
+x.hello();
+
+a = imports_a.A();
+
+c = imports_b.C();
+a1 = c.get_a(c);
+a2 = c.get_a_type(c);
+
+a1.hello();
+a2.hello();
+assert(swig_this(a1)==swig_this(a2));
+assert(strcmp(swig_type(a1),swig_type(a2)));
+
diff --git a/trunk/Examples/test-suite/octave/inctest_runme.m b/trunk/Examples/test-suite/octave/inctest_runme.m
new file mode 100644
index 000000000..ab0cb64ef
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/inctest_runme.m
@@ -0,0 +1,24 @@
+inctest
+
+try
+ a = inctest.A();
+catch
+ error("didn't find A\ntherefore, I didn't include \
+ 'testdir/subdir1/hello.i'")
+end_try_catch
+
+try
+ b = inctest.B();
+catch
+ error("didn't find B\ntherefore, I didn't include 'testdir/subdir2/hello.i'")
+end_try_catch
+
+# Check the import in subdirectory worked
+if (inctest.importtest1(5) != 15)
+ error("import test 1 failed")
+endif
+
+if (!strcmp(inctest.importtest2("black"),"white"))
+ error("import test 2 failed")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/inherit_missing_runme.m b/trunk/Examples/test-suite/octave/inherit_missing_runme.m
new file mode 100644
index 000000000..8517e2d89
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/inherit_missing_runme.m
@@ -0,0 +1,22 @@
+inherit_missing
+
+a = inherit_missing.new_Foo();
+b = inherit_missing.Bar();
+c = inherit_missing.Spam();
+
+x = inherit_missing.do_blah(a);
+if (!strcmp(x, "Foo::blah"))
+ error("Whoa! Bad return %s", x)
+endif
+
+x = inherit_missing.do_blah(b);
+if (!strcmp(x, "Bar::blah"))
+ error("Whoa! Bad return %s", x)
+endif
+
+x = inherit_missing.do_blah(c);
+if (!strcmp(x, "Spam::blah"))
+ error("Whoa! Bad return %s", x)
+endif
+
+inherit_missing.delete_Foo(a);
diff --git a/trunk/Examples/test-suite/octave/inout_runme.m b/trunk/Examples/test-suite/octave/inout_runme.m
new file mode 100644
index 000000000..74caaff46
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/inout_runme.m
@@ -0,0 +1,27 @@
+inout
+
+a = inout.AddOne1(1);
+if (a != 2)
+ error
+endif
+
+a = inout.AddOne3(1,1,1);
+if (a != [2,2,2])
+ error
+endif
+
+a = inout.AddOne1p((1,1));
+if (a != (2,2))
+ error
+endif
+
+a = inout.AddOne2p((1,1),1);
+if (a != [(2,2),2])
+ error
+endif
+
+a = inout.AddOne3p(1,(1,1),1);
+if (a != [2,(2,2),2])
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/inplaceadd_runme.m b/trunk/Examples/test-suite/octave/inplaceadd_runme.m
new file mode 100644
index 000000000..2bc193793
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/inplaceadd_runme.m
@@ -0,0 +1,24 @@
+inplaceadd
+a = inplaceadd.A(7);
+
+a += 5;
+if (a.val != 12)
+ error
+endif
+
+a -= 5;
+if a.val != 7:
+ error
+endif
+
+a *= 2;
+
+if (a.val != 14)
+ error
+endif
+
+a += a;
+if (a.val != 28)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/input_runme.m b/trunk/Examples/test-suite/octave/input_runme.m
new file mode 100644
index 000000000..757862179
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/input_runme.m
@@ -0,0 +1,22 @@
+input
+
+f = Foo();
+if (f.foo(2) != 4)
+ error
+endif
+
+try
+ a=f.foo();
+ error
+catch
+end_try_catch
+
+if (!strcmp(sfoo("Hello"),"Hello world"))
+ error
+endif
+
+try
+ a=sfoo();
+ error
+catch
+end_try_catch
diff --git a/trunk/Examples/test-suite/octave/li_attribute_runme.m b/trunk/Examples/test-suite/octave/li_attribute_runme.m
new file mode 100644
index 000000000..548e733ed
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_attribute_runme.m
@@ -0,0 +1,85 @@
+li_attribute
+
+aa = li_attribute.A(1,2,3);
+
+if (aa.a != 1)
+ error
+endif
+aa.a = 3;
+if (aa.a != 3)
+ error("aa.a = %i",aa.a)
+endif
+
+if (aa.b != 2)
+ error(aa.b)
+endif
+aa.b = 5;
+if (aa.b != 5)
+ error
+endif
+
+if (aa.d != aa.b)
+ error
+endif
+
+if (aa.c != 3)
+ error
+endif
+
+pi = li_attribute.Param_i(7);
+if (pi.value != 7)
+ error
+endif
+
+pi.value=3;
+if (pi.value != 3)
+ error
+endif
+
+b = li_attribute.B(aa);
+
+if (b.a.c != 3)
+ error
+endif
+
+# class/struct attribute with get/set methods using return/pass by reference
+myFoo = li_attribute.MyFoo();
+myFoo.x = 8;
+myClass = li_attribute.MyClass();
+myClass.Foo = myFoo;
+if (myClass.Foo.x != 8)
+ error
+endif
+
+# class/struct attribute with get/set methods using return/pass by value
+myClassVal = li_attribute.MyClassVal();
+if (myClassVal.ReadWriteFoo.x != -1)
+ error
+endif
+if (myClassVal.ReadOnlyFoo.x != -1)
+ error
+endif
+myClassVal.ReadWriteFoo = myFoo;
+if (myClassVal.ReadWriteFoo.x != 8)
+ error
+endif
+if (myClassVal.ReadOnlyFoo.x != 8)
+ error
+endif
+
+# string attribute with get/set methods using return/pass by value
+myStringyClass = li_attribute.MyStringyClass("initial string");
+if (myStringyClass.ReadWriteString != "initial string")
+ error
+endif
+if (myStringyClass.ReadOnlyString != "initial string")
+ error
+endif
+myStringyClass.ReadWriteString = "changed string";
+if (myStringyClass.ReadWriteString != "changed string")
+ error
+endif
+if (myStringyClass.ReadOnlyString != "changed string")
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_carrays_runme.m b/trunk/Examples/test-suite/octave/li_carrays_runme.m
new file mode 100644
index 000000000..8ec7e5911
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_carrays_runme.m
@@ -0,0 +1,10 @@
+li_carrays
+
+d = doubleArray(10);
+
+d(0) = 7;
+d(5) = d(0) + 3;
+
+if (d(5) + d(0) != 17)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/li_cmalloc_runme.m b/trunk/Examples/test-suite/octave/li_cmalloc_runme.m
new file mode 100644
index 000000000..45faf7381
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_cmalloc_runme.m
@@ -0,0 +1,17 @@
+li_cmalloc
+
+p = malloc_int();
+free_int(p);
+
+ok = 0;
+try
+ p = calloc_int(-1);
+ free_int(p);
+catch
+ ok = 1;
+end_try_catch
+
+if (ok != 1)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_cpointer_runme.m b/trunk/Examples/test-suite/octave/li_cpointer_runme.m
new file mode 100644
index 000000000..bf660a647
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_cpointer_runme.m
@@ -0,0 +1,12 @@
+li_cpointer
+
+
+p = new_intp();
+intp_assign(p,3);
+
+if (intp_value(p) != 3)
+ error
+endif
+
+delete_intp(p);
+
diff --git a/trunk/Examples/test-suite/octave/li_cstring_runme.m b/trunk/Examples/test-suite/octave/li_cstring_runme.m
new file mode 100644
index 000000000..0d2bdb73d
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_cstring_runme.m
@@ -0,0 +1,39 @@
+li_cstring
+
+
+if (count("ab\0ab\0ab\0", 0) != 3)
+ error
+endif
+
+if (!strcmp(test1(),"Hello World"))
+ error
+endif
+
+if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
+ error
+endif
+
+if (!strcmp(test3("hello"),"hello-suffix"))
+ error(test3("hello"))
+endif
+
+if (!strcmp(test4("hello"),"hello-suffix"))
+ error(test4("hello"))
+endif
+
+if (!strcmp(test5(4),'xxxx'))
+ error
+endif
+
+if (!strcmp(test6(10),'xxxxx'))
+ error
+endif
+
+if (!strcmp(test7(),"Hello world!"))
+ error
+endif
+
+if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_cwstring_runme.m b/trunk/Examples/test-suite/octave/li_cwstring_runme.m
new file mode 100644
index 000000000..4cfef7fb5
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_cwstring_runme.m
@@ -0,0 +1,38 @@
+li_cwstring
+
+if (count("ab\0ab\0ab\0", 0) != 3)
+ error
+endif
+
+if (!strcmp(test1(),"Hello World"))
+ error
+endif
+
+if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
+ error
+endif
+
+if (!strcmp(test3("hello"),"hello-suffix"))
+ error
+endif
+
+if (!strcmp(test4("hello"),"hello-suffix"))
+ error
+endif
+
+if (!strcmp(test5(4),'xxxx'))
+ error
+endif
+
+if (!strcmp(test6(10),'xxxxx'))
+ error
+endif
+
+if (!strcmp(test7(),"Hello world!"))
+ error
+endif
+
+if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_factory_runme.m b/trunk/Examples/test-suite/octave/li_factory_runme.m
new file mode 100644
index 000000000..d87920da6
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_factory_runme.m
@@ -0,0 +1,13 @@
+li_factory
+
+circle = Geometry_create(Geometry.CIRCLE);
+r = circle.radius();
+if (r != 1.5)
+ error
+endif
+
+point = Geometry_create(Geometry.POINT);
+w = point.width();
+if (w != 1.0)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/li_implicit_runme.m b/trunk/Examples/test-suite/octave/li_implicit_runme.m
new file mode 100644
index 000000000..2ca8b59bf
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_implicit_runme.m
@@ -0,0 +1,20 @@
+li_implicit
+b = B();
+ai = A(1);
+ad = A(2.0);
+ab = A(b);
+
+ai, get(ai);
+ad, get(ad);
+ab, get(ab);
+
+if (get(ai) != get(1))
+ error("bad implicit type")
+endif
+if (get(ad) != get(2.0))
+ error("bad implicit type")
+endif
+if (get(ab) != get(b))
+ error("bad implicit type")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_std_carray_runme.m b/trunk/Examples/test-suite/octave/li_std_carray_runme.m
new file mode 100644
index 000000000..4943fa8a2
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_carray_runme.m
@@ -0,0 +1,52 @@
+li_std_carray
+
+
+v3 = Vector3();
+for i=0:len(v3),
+ v3(i) = i;
+endfor
+
+i = 0;
+for d in v3,
+ if (d != i)
+ error
+ endif
+ i = i + 1;
+endfor
+
+
+m3 = Matrix3();
+
+for i=0:len(m3),
+ v3 = m3(i);
+ for j=0:len(v3),
+ v3(j) = i + j;
+ endfor
+endfor
+
+i = 0;
+for v3 in m3,
+ j = 0;
+ for d in v3,
+ if (d != i + j)
+ error
+ endif
+ j = j + 1;
+ endfor
+ i = i + 1
+endfor
+
+for i=0:len(m3),
+ for j=0:len(m3),
+ if (m3(i,j) != i + j)
+ error
+ endif
+ endfor
+endfor
+
+da = Vector3([1,2,3]);
+ma = Matrix3({[1,2,3],[4,5,6],[7,8,9]});
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/li_std_pair_extra_runme.m b/trunk/Examples/test-suite/octave/li_std_pair_extra_runme.m
new file mode 100644
index 000000000..0f9e9a23d
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_pair_extra_runme.m
@@ -0,0 +1,69 @@
+li_std_pair_extra
+
+p = {1,2};
+p1 = li_std_pair_extra.p_inout(p);
+assert(all(cell2mat(p1)==[2,1]));
+p2 = li_std_pair_extra.p_inoutd(p1);
+assert(all(cell2mat(p2)==[1,2]));
+
+d1 = li_std_pair_extra.d_inout(2);
+assert(d1==4);
+
+[i,d2] = li_std_pair_extra.d_inout2(2);
+assert(all([i,d2]==[1,4]));
+
+[i,p] = li_std_pair_extra.p_inout2(p);
+assert(i==1&&all([cell2mat(p)]==[2,1]));
+[p3,p4] = li_std_pair_extra.p_inout3(p1,p1);
+assert(all(cell2mat(p3)==[2,1]));
+assert(all(cell2mat(p4)==[2,1]));
+
+psi = li_std_pair_extra.SIPair("hello",1);
+assert(psi=={"hello",1});
+pci = li_std_pair_extra.CIPair(complex(1,2),1);
+assert(pci.first==complex(1,2)&&pci.second==1);
+
+
+psi = li_std_pair_extra.SIPair("hi",1);
+assert(psi.first=="hi"&&psi.second==1);
+
+psii = li_std_pair_extra.SIIPair(psi,1);
+assert(psii.first.first=="hi");
+assert(psii.first.second==1);
+assert(psii.second==1);
+
+a = li_std_pair_extra.A();
+b = li_std_pair_extra.B();
+
+pab = li_std_pair_extra.ABPair(a,b);
+
+pab.first = a;
+pab.first.val = 2;
+
+assert(pab.first.val == 2);
+
+pci = li_std_pair_extra.CIntPair(1,0);
+assert(pci.first==1&&pci.second==0);
+
+a = li_std_pair_extra.A(5);
+p1 = li_std_pair_extra.pairP1(1,a);
+p2 = li_std_pair_extra.pairP2(a,1);
+p3 = li_std_pair_extra.pairP3(a,a);
+
+assert(a.val == li_std_pair_extra.p_identa(p1){2}.val);
+
+p = li_std_pair_extra.IntPair(1,10);
+assert(p.first==1&&p.second==10);
+p.first = 1;
+assert(p.first==1);
+
+p = li_std_pair_extra.paircA1(1,a);
+assert(p.first==1);
+assert(swig_this(p.second)==swig_this(a));
+
+p = li_std_pair_extra.paircA2(1,a);
+assert(p.first==1);
+assert(swig_this(p.second)==swig_this(a));
+#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2
+pp = li_std_pair_extra.pairiiA(1,{1,A()});
+
diff --git a/trunk/Examples/test-suite/octave/li_std_set_runme.m b/trunk/Examples/test-suite/octave/li_std_set_runme.m
new file mode 100644
index 000000000..9bd4f152c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_set_runme.m
@@ -0,0 +1,96 @@
+li_std_set
+
+s = set_string()
+
+s.append("a")
+s.append("b")
+s.append("c")
+
+sum = ""
+for i in s:
+ sum = sum + i
+
+if (sum != "abc")
+ error
+
+i = s.__iter__()
+if i.next() != "a":
+ error
+if i.next() != "b":
+ error
+if i.next() != "c":
+ error
+
+
+b = s.begin()
+e = s.end()
+sum = ""
+while (b != e):
+ sum = sum + b.next()
+if sum != "abc":
+ error
+
+b = s.rbegin()
+e = s.rend()
+sum = ""
+while (b != e):
+ sum = sum + b.next()
+
+if sum != "cba":
+ error
+
+
+
+si = set_int()
+
+si.append(1)
+si.append(2)
+si.append(3)
+i = si.__iter__()
+
+if i.next() != 1:
+ error
+if i.next() != 2:
+ error
+if i.next() != 3:
+ error
+
+
+
+
+i = s.begin()
+i.next()
+s.erase(i)
+
+b = s.begin()
+e = s.end()
+sum = ""
+while (b != e):
+ sum = sum + b.next()
+if sum != "ac":
+ error
+
+
+b = s.begin()
+e = s.end()
+if e - b != 2:
+ error
+
+m = b + 1
+if m.value() != "c":
+ error
+
+
+
+s = pyset()
+s.insert((1,2))
+s.insert(1)
+s.insert("hello")
+
+
+sum = ()
+for i in s:
+ sum = sum + (i,)
+
+if sum != (1, 'hello', (1, 2)):
+ error
diff --git a/trunk/Examples/test-suite/octave/li_std_stream_runme.m b/trunk/Examples/test-suite/octave/li_std_stream_runme.m
new file mode 100644
index 000000000..bf9402e16
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_stream_runme.m
@@ -0,0 +1,13 @@
+li_std_stream
+
+a = A();
+
+o = ostringstream();
+
+o << a << " " << 2345 << " " << 1.435;
+
+
+if (o.str() != "A class 2345 1.435")
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_std_string_extra_runme.m b/trunk/Examples/test-suite/octave/li_std_string_extra_runme.m
new file mode 100644
index 000000000..8d506af8a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_string_extra_runme.m
@@ -0,0 +1,162 @@
+li_std_string_extra
+
+x="hello";
+
+
+
+if (li_std_string_extra.test_ccvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_cvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_value(x) != x)
+ error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
+endif
+
+if (li_std_string_extra.test_const_reference(x) != x)
+ error("bad string mapping")
+endif
+
+
+s = li_std_string_extra.string("he");
+#s += "ll"
+#s.append("ll")
+s = s + "llo";
+
+if (s != x)
+ error("bad string mapping: %s, %s", s, x);
+endif
+
+#if (s(1:4) != x(1:4))
+# error("bad string mapping")
+#endif
+
+if (li_std_string_extra.test_value(s) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_const_reference(s) != x)
+ error("bad string mapping")
+endif
+
+a = li_std_string_extra.A(s);
+
+if (li_std_string_extra.test_value(a) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_const_reference(a) != x)
+ error("bad string mapping")
+endif
+
+b = li_std_string_extra.string(" world");
+
+s = a + b;
+if (a + b != "hello world")
+ error("bad string mapping: %s", a + b)
+endif
+
+if (a + " world" != "hello world")
+ error("bad string mapping")
+endif
+
+#if ("hello" + b != "hello world")
+# error("bad string mapping")
+#endif
+
+c = (li_std_string_extra.string("hello") + b);
+if (c.find_last_of("l") != 9)
+ error("bad string mapping")
+endif
+
+s = "hello world";
+
+b = li_std_string_extra.B("hi");
+
+b.name = li_std_string_extra.string("hello");
+if (b.name != "hello")
+ error("bad string mapping")
+endif
+
+
+b.a = li_std_string_extra.A("hello");
+if (b.a != "hello")
+ error("bad string mapping")
+endif
+
+
+if (li_std_string_extra.test_value_basic1(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_value_basic2(x) != x)
+ error("bad string mapping")
+endif
+
+
+if (li_std_string_extra.test_value_basic3(x) != x)
+ error("bad string mapping")
+endif
+
+# Global variables
+s = "initial string";
+if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
+ error("GlobalString2 test 1")
+endif
+li_std_string_extra.cvar.GlobalString2 = s;
+if (li_std_string_extra.cvar.GlobalString2 != s)
+ error("GlobalString2 test 2")
+endif
+if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
+ error("ConstGlobalString test")
+endif
+
+# Member variables
+myStructure = li_std_string_extra.Structure();
+if (myStructure.MemberString2 != "member string 2")
+ error("MemberString2 test 1")
+endif
+myStructure.MemberString2 = s;
+if (myStructure.MemberString2 != s)
+ error("MemberString2 test 2")
+endif
+if (myStructure.ConstMemberString != "const member string")
+ error("ConstMemberString test")
+endif
+
+if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
+ error("StaticMemberString2 test 1")
+endif
+li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
+if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
+ error("StaticMemberString2 test 2")
+endif
+if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
+ error("ConstStaticMemberString test")
+endif
+
+
+if (li_std_string_extra.test_reference_input("hello") != "hello")
+ error
+endif
+s = li_std_string_extra.test_reference_inout("hello");
+if (s != "hellohello")
+ error
+endif
+
+
+if (li_std_string_extra.stdstring_empty() != "")
+ error
+endif
+
+
+if (li_std_string_extra.c_empty() != "")
+ error
+endif
+
+#if (li_std_string_extra.c_null() != None)
+# error
+#endif
diff --git a/trunk/Examples/test-suite/octave/li_std_vector_runme.m b/trunk/Examples/test-suite/octave/li_std_vector_runme.m
new file mode 100644
index 000000000..83d1f2cb0
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_vector_runme.m
@@ -0,0 +1,11 @@
+li_std_vector
+
+iv = IntVector(4);
+for i=0:3,
+ iv(i) = i;
+endfor
+x = average(iv);
+
+if (x != 1.5)
+ error("average failed");
+endif
diff --git a/trunk/Examples/test-suite/octave/li_std_wstream_runme.m b/trunk/Examples/test-suite/octave/li_std_wstream_runme.m
new file mode 100644
index 000000000..a017e8acd
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_wstream_runme.m
@@ -0,0 +1,14 @@
+li_std_wstream
+
+
+
+a = A();
+
+o = wostringstream();
+
+o << a << u" " << 2345 << u" " << 1.435 << wends;
+
+if (o.str() != "A class 2345 1.435\0")
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/li_std_wstring_runme.m b/trunk/Examples/test-suite/octave/li_std_wstring_runme.m
new file mode 100644
index 000000000..e46c1f219
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/li_std_wstring_runme.m
@@ -0,0 +1,90 @@
+li_std_wstring
+
+x="h";
+
+if (li_std_wstring.test_wcvalue(x) != x)
+ error("bad string mapping")
+endif
+
+x="hello";
+if (li_std_wstring.test_ccvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_wstring.test_cvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_wstring.test_value(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_wstring.test_const_reference(x) != x)
+ error("bad string mapping")
+endif
+
+
+s = li_std_wstring.wstring("he");
+s = s + "llo";
+
+if (s != x)
+ error("bad string mapping")
+endif
+
+if (s(1:4) != x(1:4))
+ error("bad string mapping")
+endif
+
+if (li_std_wstring.test_value(s) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_wstring.test_const_reference(s) != x)
+ error("bad string mapping")
+endif
+
+a = li_std_wstring.A(s);
+
+if (li_std_wstring.test_value(a) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_wstring.test_const_reference(a) != x)
+ error("bad string mapping")
+endif
+
+b = li_std_wstring.wstring(" world");
+
+if (a + b != "hello world")
+ error("bad string mapping")
+endif
+
+if (a + " world" != "hello world")
+ error("bad string mapping")
+endif
+
+if ("hello" + b != "hello world")
+ error("bad string mapping")
+endif
+
+c = "hello" + b;
+if (c.find_last_of("l") != 9)
+ error("bad string mapping")
+endif
+
+s = "hello world";
+
+b = li_std_wstring.B("hi");
+
+b.name = li_std_wstring.wstring("hello");
+if (b.name != "hello")
+ error("bad string mapping")
+endif
+
+
+b.a = li_std_wstring.A("hello");
+if (b.a != "hello")
+ error("bad string mapping")
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/member_pointer_runme.m b/trunk/Examples/test-suite/octave/member_pointer_runme.m
new file mode 100644
index 000000000..c13350bd0
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/member_pointer_runme.m
@@ -0,0 +1,45 @@
+# Example using pointers to member functions
+
+member_pointer
+
+function check(what,expected,actual)
+ if (expected != actual)
+ error ("Failed: %s, Expected: %f, Actual: %f",what,expected,actual);
+ endif
+end
+
+# Get the pointers
+
+area_pt = areapt;
+perim_pt = perimeterpt;
+
+# Create some objects
+
+s = Square(10);
+
+# Do some calculations
+
+check ("Square area ", 100.0, do_op(s,area_pt));
+check ("Square perim", 40.0, do_op(s,perim_pt));
+
+memberPtr = cvar.areavar;
+memberPtr = cvar.perimetervar;
+
+# Try the variables
+check ("Square area ", 100.0, do_op(s,cvar.areavar));
+check ("Square perim", 40.0, do_op(s,cvar.perimetervar));
+
+# Modify one of the variables
+cvar.areavar = perim_pt;
+
+check ("Square perimeter", 40.0, do_op(s,cvar.areavar));
+
+# Try the constants
+
+memberPtr = AREAPT;
+memberPtr = PERIMPT;
+memberPtr = NULLPT;
+
+check ("Square area ", 100.0, do_op(s,AREAPT));
+check ("Square perim", 40.0, do_op(s,PERIMPT));
+
diff --git a/trunk/Examples/test-suite/octave/minherit_runme.m b/trunk/Examples/test-suite/octave/minherit_runme.m
new file mode 100644
index 000000000..24d2091be
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/minherit_runme.m
@@ -0,0 +1,86 @@
+minherit
+
+a = minherit.Foo();
+b = minherit.Bar();
+c = minherit.FooBar();
+d = minherit.Spam();
+
+if (a.xget() != 1)
+ error("Bad attribute value")
+endif
+
+if (b.yget() != 2)
+ error("Bad attribute value")
+endif
+
+if (c.xget() != 1 || c.yget() != 2 || c.zget() != 3)
+ error("Bad attribute value")
+endif
+
+if (d.xget() != 1 || d.yget() != 2 || d.zget() != 3 || d.wget() != 4)
+ error("Bad attribute value")
+endif
+
+
+if (minherit.xget(a) != 1)
+ error("Bad attribute value %d",minherit.xget(a))
+endif
+
+if (minherit.yget(b) != 2)
+ error("Bad attribute value %d",minherit.yget(b))
+endif
+
+if (minherit.xget(c) != 1 || minherit.yget(c) != 2 || minherit.zget(c) != 3)
+ error("Bad attribute value %d %d %d",minherit.xget(c),minherit.yget(c),minherit.zget(c))
+endif
+
+if (minherit.xget(d) != 1 || minherit.yget(d) != 2 || minherit.zget(d) != 3 || minherit.wget(d) != 4)
+ error("Bad attribute value %d %d %d %d",minherit.xget(d),minherit.yget(d),minherit.zget(d),minherit.wget(d))
+endif
+
+# Cleanse all of the pointers and see what happens
+
+aa = minherit.toFooPtr(a);
+bb = minherit.toBarPtr(b);
+cc = minherit.toFooBarPtr(c);
+dd = minherit.toSpamPtr(d);
+
+if (aa.xget() != 1)
+ error("Bad attribute value");
+endif
+
+if (bb.yget() != 2)
+ error("Bad attribute value");
+endif
+
+if (cc.xget() != 1 || cc.yget() != 2 || cc.zget() != 3)
+ error("Bad attribute value")
+endif
+
+if (dd.xget() != 1 || dd.yget() != 2 || dd.zget() != 3 || dd.wget() != 4)
+ error("Bad attribute value")
+endif
+
+if (minherit.xget(aa) != 1)
+ error("Bad attribute value %d",minherit.xget(aa));
+endif
+
+if (minherit.yget(bb) != 2)
+ error("Bad attribute value %d",minherit.yget(bb));
+endif
+
+if (minherit.xget(cc) != 1 || minherit.yget(cc) != 2 || minherit.zget(cc) != 3)
+ error("Bad attribute value %d %d %d",minherit.xget(cc),minherit.yget(cc),minherit.zget(cc));
+endif
+
+if (minherit.xget(dd) != 1 || minherit.yget(dd) != 2 || minherit.zget(dd) != 3 || minherit.wget(dd) != 4)
+ error("Bad attribute value %d %d %d %d",minherit.xget(dd),minherit.yget(dd),minherit.zget(dd),minherit.wget(dd))
+endif
+
+
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/mod_runme.m b/trunk/Examples/test-suite/octave/mod_runme.m
new file mode 100644
index 000000000..faebf70e3
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/mod_runme.m
@@ -0,0 +1,7 @@
+mod_a
+mod_b
+
+c = mod_b.C();
+d = mod_b.D();
+d.DoSomething(c);
+
diff --git a/trunk/Examples/test-suite/octave/multi_import_runme.m b/trunk/Examples/test-suite/octave/multi_import_runme.m
new file mode 100644
index 000000000..08149aae4
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/multi_import_runme.m
@@ -0,0 +1,24 @@
+multi_import_a;
+multi_import_b;
+
+x = multi_import_b.XXX();
+if (x.testx() != 0)
+ error
+endif
+
+y = multi_import_b.YYY();
+if (y.testx() != 0)
+ error
+endif
+if (y.testy() != 1)
+ error
+endif
+
+z = multi_import_a.ZZZ();
+if (z.testx() != 0)
+ error
+endif
+if (z.testz() != 2)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/namespace_class_runme.m b/trunk/Examples/test-suite/octave/namespace_class_runme.m
new file mode 100644
index 000000000..564cf87da
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/namespace_class_runme.m
@@ -0,0 +1,39 @@
+namespace_class
+
+try
+ p = Private1();
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+
+if (ok)
+ error("Private1 is private")
+endif
+
+try
+ p = Private2();
+ ok = 1;
+catch
+ ok = 0;
+end_try_catch
+
+if (ok)
+ error("Private2 is private")
+endif
+
+EulerT3D.toFrame(1,1,1);
+
+b = BooT_i();
+b = BooT_H();
+
+
+f = FooT_i();
+f.quack(1);
+
+f = FooT_d();
+f.moo(1);
+
+f = FooT_H();
+f.foo(Hi);
+
diff --git a/trunk/Examples/test-suite/octave/namespace_typemap_runme.m b/trunk/Examples/test-suite/octave/namespace_typemap_runme.m
new file mode 100644
index 000000000..ca3730773
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/namespace_typemap_runme.m
@@ -0,0 +1,106 @@
+namespace_typemap
+
+if (!strcmp(stest1("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest2("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest3("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest4("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest5("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest6("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest7("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest8("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest9("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest10("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest11("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(stest12("hello"),"hello"))
+ error
+endif
+
+c = complex(2,3);
+r = real(c);
+
+if (ctest1(c) != r)
+ error
+endif
+
+if (ctest2(c) != r)
+ error
+endif
+
+if (ctest3(c) != r)
+ error
+endif
+
+if (ctest4(c) != r)
+ error
+endif
+
+if (ctest5(c) != r)
+ error
+endif
+
+if (ctest6(c) != r)
+ error
+endif
+
+if (ctest7(c) != r)
+ error
+endif
+
+if (ctest8(c) != r)
+ error
+endif
+
+if (ctest9(c) != r)
+ error
+endif
+
+if (ctest10(c) != r)
+ error
+endif
+
+if (ctest11(c) != r)
+ error
+endif
+
+if (ctest12(c) != r)
+ error
+endif
+
+try
+ ttest1(-14)
+ error
+catch
+end_try_catch
diff --git a/trunk/Examples/test-suite/octave/namespace_virtual_method_runme.m b/trunk/Examples/test-suite/octave/namespace_virtual_method_runme.m
new file mode 100644
index 000000000..b78e9128c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/namespace_virtual_method_runme.m
@@ -0,0 +1,4 @@
+namespace_virtual_method
+
+x = namespace_virtual_method.Spam();
+
diff --git a/trunk/Examples/test-suite/octave/naturalvar_runme.m b/trunk/Examples/test-suite/octave/naturalvar_runme.m
new file mode 100644
index 000000000..889563f35
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/naturalvar_runme.m
@@ -0,0 +1,14 @@
+naturalvar
+
+f = Foo();
+b = Bar();
+
+b.f = f;
+
+cvar.s = "hello";
+b.s = "hello";
+
+if (b.s != cvar.s)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/nondynamic_runme.m b/trunk/Examples/test-suite/octave/nondynamic_runme.m
new file mode 100644
index 000000000..7b3b44125
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/nondynamic_runme.m
@@ -0,0 +1,36 @@
+nondynamic
+
+aa = nondynamic.A();
+
+aa.a = 1;
+aa.b = 2;
+try
+ aa.c = 2;
+ err = 0;
+catch
+ err = 1;
+end_try_catch
+
+if (!err)
+ error("A is not static")
+endif
+
+
+B=@() subclass(nondynamic.A(),'c',4);
+
+bb = B();
+bb.c = 3;
+try
+ bb.d = 2
+ err = 0
+catch
+ err = 1
+end_try_catch
+
+if (!err)
+ error("B is not static")
+endif
+
+cc = nondynamic.C();
+cc.d = 3;
+
diff --git a/trunk/Examples/test-suite/octave/null_pointer_runme.m b/trunk/Examples/test-suite/octave/null_pointer_runme.m
new file mode 100644
index 000000000..51b6eaf91
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/null_pointer_runme.m
@@ -0,0 +1,3 @@
+null_pointer;
+
+assert(func([]));
diff --git a/trunk/Examples/test-suite/octave/octave_cell_deref_runme.m b/trunk/Examples/test-suite/octave/octave_cell_deref_runme.m
new file mode 100644
index 000000000..5a98c0a3b
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/octave_cell_deref_runme.m
@@ -0,0 +1,8 @@
+octave_cell_deref;
+
+assert(func("hello"));
+assert(func({"hello"}));
+
+c = func2();
+assert(strcmp(c{1}, "hello"));
+assert(c{2} == 4);
diff --git a/trunk/Examples/test-suite/octave/octave_empty.c b/trunk/Examples/test-suite/octave/octave_empty.c
new file mode 100644
index 000000000..9bb690bbd
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/octave_empty.c
@@ -0,0 +1 @@
+/* empty C file for the Octave test-suite C tests is needed - build system workaround as the generated files for Octave are C++ files */
diff --git a/trunk/Examples/test-suite/octave/overload_complicated_runme.m b/trunk/Examples/test-suite/octave/overload_complicated_runme.m
new file mode 100755
index 000000000..0313be954
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_complicated_runme.m
@@ -0,0 +1,58 @@
+overload_complicated
+
+pInt = None;
+
+# Check the correct constructors are available
+p = Pop(pInt);
+
+p = Pop(pInt, 0);
+
+# Check overloaded in const only and pointers/references which target languages cannot disambiguate
+if (p.hip(0) != 701)
+ error("Test 1 failed")
+endif
+
+if (p.hip(pInt) != 702)
+ error("Test 2 failed")
+endif
+
+# Reverse the order for the above
+if (p.hop(pInt) != 805)
+ error("Test 3 failed")
+endif
+
+if (p.hop(0) != 801)
+ error("Test 4 failed")
+endif
+
+# Few more variations and order shuffled
+if (p.pop(0) != 901)
+ error("Test 5 failed")
+endif
+
+if (p.pop(pInt) != 902)
+ error("Test 6 failed")
+endif
+
+if (p.pop() != 905)
+ error("Test 7 failed")
+endif
+
+# Overload on const only
+if (p.bop(pInt) != 1001)
+ error("Test 8 failed")
+endif
+
+if (p.bip(pInt) != 2001)
+ error("Test 9 failed")
+endif
+
+# Globals
+if (muzak(0) != 3001)
+ error("Test 10 failed")
+endif
+
+if (muzak(pInt) != 3002)
+ error("Test 11 failed")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/overload_copy_runme.m b/trunk/Examples/test-suite/octave/overload_copy_runme.m
new file mode 100644
index 000000000..b303ba618
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_copy_runme.m
@@ -0,0 +1,3 @@
+overload_copy
+f = Foo();
+g = Foo(f);
diff --git a/trunk/Examples/test-suite/octave/overload_extend_runme.m b/trunk/Examples/test-suite/octave/overload_extend_runme.m
new file mode 100644
index 000000000..42c79388f
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_extend_runme.m
@@ -0,0 +1,19 @@
+overload_extend
+
+f = overload_extend.Foo();
+if (f.test() != 0)
+ error
+endif
+if (f.test(3) != 1)
+ error
+endif
+if (f.test("hello") != 2)
+ error
+endif
+if (f.test(3,2) != 5)
+ error
+endif
+if (f.test(3.1)-.1 != 1003) # :)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/overload_extendc_runme.m b/trunk/Examples/test-suite/octave/overload_extendc_runme.m
new file mode 100644
index 000000000..fec586d4f
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_extendc_runme.m
@@ -0,0 +1,30 @@
+overload_extendc
+
+f = overload_extendc.Foo();
+if (f.test(3) != 1)
+ error
+endif
+if (f.test("hello") != 2)
+ error
+endif
+if (f.test(3.5,2.5) != 3)
+ error
+endif
+if (f.test("hello",20) != 1020)
+ error
+endif
+if (f.test("hello",20,100) != 120)
+ error
+endif
+
+# C default args
+if (f.test(f) != 30)
+ error
+endif
+if (f.test(f,100) != 120)
+ error
+endif
+if (f.test(f,100,200) != 300)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/overload_rename_runme.m b/trunk/Examples/test-suite/octave/overload_rename_runme.m
new file mode 100644
index 000000000..4a416cfbc
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_rename_runme.m
@@ -0,0 +1,8 @@
+overload_rename
+
+
+f = overload_rename.Foo(1);
+f = overload_rename.Foo(1,1);
+f = overload_rename.new_Foo_int(1,1);
+f = overload_rename.new_Foo_int(1,1,1);
+
diff --git a/trunk/Examples/test-suite/octave/overload_simple_cast_runme.m b/trunk/Examples/test-suite/octave/overload_simple_cast_runme.m
new file mode 100644
index 000000000..65bc4229a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_simple_cast_runme.m
@@ -0,0 +1,229 @@
+overload_simple_cast
+
+Ai=@(x) subclass('x',x,'__int',@(self) self.x);
+Ad=@(x) subclass('x',x,'__float',@(self) self.x);
+
+ai = Ai(4);
+
+ad = Ad(5.0);
+add = Ad(5.5);
+
+try
+ fint(add);
+ good = 0;
+catch
+ good = 1;
+end_try_catch
+
+if (!good)
+ error("fint(int)")
+endif
+
+
+if (!strcmp(fint(ad),"fint:int"))
+ error("fint(int)")
+endif
+
+if (!strcmp(fdouble(ad),"fdouble:double"))
+ error("fdouble(double)")
+endif
+
+if (!strcmp(fint(ai),"fint:int"))
+ error("fint(int)")
+endif
+
+if (!strcmp(fint(5.0),"fint:int"))
+ error("fint(int)")
+endif
+
+if (!strcmp(fint(3),"fint:int"))
+ error("fint(int)")
+endif
+if (!strcmp(fint(3.0),"fint:int"))
+ error("fint(int)")
+endif
+
+if (!strcmp(fdouble(ad),"fdouble:double"))
+ error("fdouble(double)")
+endif
+if (!strcmp(fdouble(3),f"fdouble:double"))
+ error("fdouble(double)")
+endif
+if (!strcmp(fdouble(3.0),"fdouble:double"))
+ error("fdouble(double)")
+endif
+
+if (!strcmp(fid(3,3.0),"fid:intdouble"))
+ error("fid:intdouble")
+endif
+
+if (!strcmp(fid(3.0,3),"fid:doubleint"))
+ error("fid:doubleint")
+endif
+
+if (!strcmp(fid(ad,ai),"fid:doubleint"))
+ error("fid:doubleint")
+endif
+
+if (!strcmp(fid(ai,ad),"fid:intdouble"))
+ error("fid:intdouble")
+endif
+
+
+
+if (!strcmp(foo(3),"foo:int"))
+ error("foo(int)")
+endif
+
+if (!strcmp(foo(3.0),"foo:double"))
+ error("foo(double)")
+endif
+
+if (!strcmp(foo("hello"),"foo:char *"))
+ error("foo(char *)")
+endif
+
+f = Foo();
+b = Bar();
+
+if (!strcmp(foo(f),"foo:Foo *"))
+ error("foo(Foo *)")
+endif
+
+if (!strcmp(foo(b),"foo:Bar *"))
+ error("foo(Bar *)")
+endif
+
+v = malloc_void(32);
+
+if (!strcmp(foo(v),"foo:void *"))
+ error("foo(void *)")
+endif
+
+s = Spam();
+
+if (!strcmp(s.foo(3),"foo:int"))
+ error("Spam::foo(int)")
+endif
+
+if (!strcmp(s.foo(3.0),"foo:double"))
+ error("Spam::foo(double)")
+endif
+
+if (!strcmp(s.foo("hello"),"foo:char *"))
+ error("Spam::foo(char *)")
+endif
+
+if (!strcmp(s.foo(f),"foo:Foo *"))
+ error("Spam::foo(Foo *)")
+endif
+
+if (!strcmp(s.foo(b),"foo:Bar *"))
+ error("Spam::foo(Bar *)")
+endif
+
+if (!strcmp(s.foo(v),"foo:void *"))
+ error("Spam::foo(void *)")
+endif
+
+if (!strcmp(Spam_bar(3),"bar:int"))
+ error("Spam::bar(int)")
+endif
+
+if (!strcmp(Spam_bar(3.0),"bar:double"))
+ error("Spam::bar(double)")
+endif
+
+if (!strcmp(Spam_bar("hello"),"bar:char *"))
+ error("Spam::bar(char *)")
+endif
+
+if (!strcmp(Spam_bar(f),"bar:Foo *"))
+ error("Spam::bar(Foo *)")
+endif
+
+if (!strcmp(Spam_bar(b),"bar:Bar *"))
+ error("Spam::bar(Bar *)")
+endif
+
+if (!strcmp(Spam_bar(v),"bar:void *"))
+ error("Spam::bar(void *)")
+endif
+
+# Test constructors
+
+s = Spam();
+if (!strcmp(s.type,"none"))
+ error("Spam()")
+endif
+
+s = Spam(3);
+if (!strcmp(s.type,"int"))
+ error("Spam(int)")
+endif
+
+s = Spam(3.4);
+if (!strcmp(s.type,"double"))
+ error("Spam(double)")
+endif
+
+s = Spam("hello");
+if (!strcmp(s.type,"char *"))
+ error("Spam(char *)")
+endif
+
+s = Spam(f);
+if (!strcmp(s.type,"Foo *"))
+ error("Spam(Foo *)")
+endif
+
+s = Spam(b);
+if (!strcmp(s.type,"Bar *"))
+ error("Spam(Bar *)")
+endif
+
+s = Spam(v);
+if (!strcmp(s.type,"void *"))
+ error("Spam(void *)")
+endif
+
+
+# unsigned long long
+ullmax = 9223372036854775807; #0xffffffffffffffff
+ullmaxd = 9007199254740992.0;
+ullmin = 0;
+ullmind = 0.0;
+if (ull(ullmin) != ullmin)
+ error("ull(ullmin)")
+endif
+if (ull(ullmax) != ullmax)
+ error("ull(ullmax)")
+endif
+if (ull(ullmind) != ullmind)
+ error("ull(ullmind)")
+endif
+if (ull(ullmaxd) != ullmaxd)
+ error("ull(ullmaxd)")
+endif
+
+# long long
+llmax = 9223372036854775807; #0x7fffffffffffffff
+llmin = -9223372036854775808;
+# these are near the largest floats we can still convert into long long
+llmaxd = 9007199254740992.0;
+llmind = -9007199254740992.0;
+if (ll(llmin) != llmin)
+ error("ll(llmin)")
+endif
+if (ll(llmax) != llmax)
+ error("ll(llmax)")
+endif
+if (ll(llmind) != llmind)
+ error("ll(llmind)")
+endif
+if (ll(llmaxd) != llmaxd)
+ error("ll(llmaxd)")
+endif
+
+free_void(v);
+
diff --git a/trunk/Examples/test-suite/octave/overload_simple_runme.m b/trunk/Examples/test-suite/octave/overload_simple_runme.m
new file mode 100644
index 000000000..e980610da
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_simple_runme.m
@@ -0,0 +1,125 @@
+overload_simple
+
+# unless explicitly casted via {{u}int{8,16,32,64},double,single},
+# octave will take numeric literals as doubles.
+
+if (!strcmp(foo(3),"foo:int"))
+ error("foo(int)")
+endif
+
+if (!strcmp(foo(3.1),"foo:double"))
+ error("foo(double)")
+endif
+
+if (!strcmp(foo("hello"),"foo:char *"))
+ error("foo(char *)")
+endif
+
+f = Foo();
+b = Bar();
+
+if (!strcmp(foo(f),"foo:Foo *"))
+ error("foo(Foo *)")
+endif
+
+if (!strcmp(foo(b),"foo:Bar *"))
+ error("foo(Bar *)")
+endif
+
+v = malloc_void(32);
+
+if (!strcmp(foo(v),"foo:void *"))
+ error("foo(void *)")
+endif
+
+s = Spam();
+
+if (!strcmp(s.foo(3),"foo:int"))
+ error("Spam::foo(int)")
+endif
+
+if (!strcmp(s.foo(3.1),"foo:double"))
+ error("Spam::foo(double)")
+endif
+
+if (!strcmp(s.foo("hello"),"foo:char *"))
+ error("Spam::foo(char *)")
+endif
+
+if (!strcmp(s.foo(f),"foo:Foo *"))
+ error("Spam::foo(Foo *)")
+endif
+
+if (!strcmp(s.foo(b),"foo:Bar *"))
+ error("Spam::foo(Bar *)")
+endif
+
+if (!strcmp(s.foo(v),"foo:void *"))
+ error("Spam::foo(void *)")
+endif
+
+if (!strcmp(Spam_bar(3),"bar:int"))
+ error("Spam::bar(int)")
+endif
+
+if (!strcmp(Spam_bar(3.1),"bar:double"))
+ error("Spam::bar(double)")
+endif
+
+if (!strcmp(Spam_bar("hello"),"bar:char *"))
+ error("Spam::bar(char *)")
+endif
+
+if (!strcmp(Spam_bar(f),"bar:Foo *"))
+ error("Spam::bar(Foo *)")
+endif
+
+if (!strcmp(Spam_bar(b),"bar:Bar *"))
+ error("Spam::bar(Bar *)")
+endif
+
+if (!strcmp(Spam_bar(v),"bar:void *"))
+ error("Spam::bar(void *)")
+endif
+
+# Test constructors
+
+s = Spam();
+if (!strcmp(s.type,"none"))
+ error("Spam()")
+endif
+
+s = Spam(3);
+if (!strcmp(s.type,"int"))
+ error("Spam(int)")
+endif
+
+s = Spam(3.4);
+if (!strcmp(s.type,"double"))
+ error("Spam(double)")
+endif
+
+s = Spam("hello");
+if (!strcmp(s.type,"char *"))
+ error("Spam(char *)")
+endif
+
+s = Spam(f);
+if (!strcmp(s.type,"Foo *"))
+ error("Spam(Foo *)")
+endif
+
+s = Spam(b);
+if (!strcmp(s.type,"Bar *"))
+ error("Spam(Bar *)")
+endif
+
+s = Spam(v);
+if (!strcmp(s.type,"void *"))
+ error("Spam(void *)")
+endif
+
+free_void(v);
+
+a = ClassA();
+b = a.method1(1);
diff --git a/trunk/Examples/test-suite/octave/overload_subtype_runme.m b/trunk/Examples/test-suite/octave/overload_subtype_runme.m
new file mode 100644
index 000000000..b34be9734
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_subtype_runme.m
@@ -0,0 +1,13 @@
+overload_subtype
+
+f = Foo();
+b = Bar();
+
+if (spam(f) != 1)
+ error("foo")
+endif
+
+if (spam(b) != 2)
+ error("bar")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/overload_template_fast_runme.m b/trunk/Examples/test-suite/octave/overload_template_fast_runme.m
new file mode 100644
index 000000000..f99ce8642
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_template_fast_runme.m
@@ -0,0 +1,188 @@
+overload_template_fast
+
+# unless explicitly casted via {{u}int{8,16,32,64},double,single},
+# octave will take numeric literals as doubles.
+
+f = foo();
+
+a = maximum(3,4);
+b = maximum(3.4,5.2);
+
+# mix 1
+if (mix1("hi") != 101)
+ error("mix1(const char*)")
+endif
+
+if (mix1(1.1, 1.1) != 102)
+ error("mix1(double, const double &)")
+endif
+
+if (mix1(1.1) != 103)
+ error("mix1(double)")
+endif
+
+# mix 2
+if (mix2("hi") != 101)
+ error("mix2(const char*)")
+endif
+
+if (mix2(1.1, 1.1) != 102)
+ error("mix2(double, const double &)")
+endif
+
+if (mix2(1.1) != 103)
+ error("mix2(double)")
+endif
+
+# mix 3
+if (mix3("hi") != 101)
+ error("mix3(const char*)")
+endif
+
+if (mix3(1.1, 1.1) != 102)
+ error("mix3(double, const double &)")
+endif
+
+if (mix3(1.1) != 103)
+ error("mix3(double)")
+endif
+
+# Combination 1
+if (overtparams1(100) != 10)
+ error("overtparams1(int)")
+endif
+
+if (overtparams1(100.1, 100) != 20)
+ error("overtparams1(double, int)")
+endif
+
+# Combination 2
+if (overtparams2(100.1, 100) != 40)
+ error("overtparams2(double, int)")
+endif
+
+# Combination 3
+if (overloaded() != 60)
+ error("overloaded()")
+endif
+
+if (overloaded(100.1, 100) != 70)
+ error("overloaded(double, int)")
+endif
+
+# Combination 4
+if (overloadedagain("hello") != 80)
+ error("overloadedagain(const char *)")
+endif
+
+if (overloadedagain() != 90)
+ error("overloadedagain(double)")
+endif
+
+# specializations
+if (specialization(10) != 202)
+ error("specialization(int)")
+endif
+
+if (specialization(10.1) != 203)
+ error("specialization(double)")
+endif
+
+if (specialization(10, 10) != 204)
+ error("specialization(int, int)")
+endif
+
+if (specialization(10.1, 10.1) != 205)
+ error("specialization(double, double)")
+endif
+
+if (specialization("hi", "hi") != 201)
+ error("specialization(const char *, const char *)")
+endif
+
+
+# simple specialization
+xyz();
+xyz_int();
+xyz_double();
+
+# a bit of everything
+if (overload("hi") != 0)
+ error("overload()")
+endif
+
+if (overload(1) != 10)
+ error("overload(int t)")
+endif
+
+if (overload(1, 1) != 20)
+ error("overload(int t, const int &)")
+endif
+
+if (overload(1, "hello") != 30)
+ error("overload(int t, const char *)")
+endif
+
+k = Klass();
+if (overload(k) != 10)
+ error("overload(Klass t)")
+endif
+
+if (overload(k, k) != 20)
+ error("overload(Klass t, const Klass &)")
+endif
+
+if (overload(k, "hello") != 30)
+ error("overload(Klass t, const char *)")
+endif
+
+if (overload(10.1, "hi") != 40)
+ error("overload(double t, const char *)")
+endif
+
+if (overload() != 50)
+ error("overload(const char *)")
+endif
+
+
+# everything put in a namespace
+if (nsoverload("hi") != 1000)
+ error("nsoverload()")
+endif
+
+if (nsoverload(1) != 1010)
+ error("nsoverload(int t)")
+endif
+
+if (nsoverload(1, 1) != 1020)
+ error("nsoverload(int t, const int &)")
+endif
+
+if (nsoverload(1, "hello") != 1030)
+ error("nsoverload(int t, const char *)")
+endif
+
+if (nsoverload(k) != 1010)
+ error("nsoverload(Klass t)")
+endif
+
+if (nsoverload(k, k) != 1020)
+ error("nsoverload(Klass t, const Klass &)")
+endif
+
+if (nsoverload(k, "hello") != 1030)
+ error("nsoverload(Klass t, const char *)")
+endif
+
+if (nsoverload(10.1, "hi") != 1040)
+ error("nsoverload(double t, const char *)")
+endif
+
+if (nsoverload() != 1050)
+ error("nsoverload(const char *)")
+endif
+
+
+A.foo(1);
+b = B();
+b.foo(1);
diff --git a/trunk/Examples/test-suite/octave/overload_template_runme.m b/trunk/Examples/test-suite/octave/overload_template_runme.m
new file mode 100644
index 000000000..d7b1cbb65
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/overload_template_runme.m
@@ -0,0 +1,184 @@
+overload_template
+f = foo();
+
+a = maximum(3,4);
+b = maximum(3.4,5.2);
+
+# mix 1
+if (mix1("hi") != 101)
+ error("mix1(const char*)")
+endif
+
+if (mix1(1.0, 1.0) != 102)
+ error("mix1(double, const double &)")
+endif
+
+if (mix1(1.0) != 103)
+ error("mix1(double)")
+endif
+
+# mix 2
+if (mix2("hi") != 101)
+ error("mix2(const char*)")
+endif
+
+if (mix2(1.0, 1.0) != 102)
+ error("mix2(double, const double &)")
+endif
+
+if (mix2(1.0) != 103)
+ error("mix2(double)")
+endif
+
+# mix 3
+if (mix3("hi") != 101)
+ error("mix3(const char*)")
+endif
+
+if (mix3(1.0, 1.0) != 102)
+ error("mix3(double, const double &)")
+endif
+
+if (mix3(1.0) != 103)
+ error("mix3(double)")
+endif
+
+# Combination 1
+if (overtparams1(100) != 10)
+ error("overtparams1(int)")
+endif
+
+if (overtparams1(100.0, 100) != 20)
+ error("overtparams1(double, int)")
+endif
+
+# Combination 2
+if (overtparams2(100.0, 100) != 40)
+ error("overtparams2(double, int)")
+endif
+
+# Combination 3
+if (overloaded() != 60)
+ error("overloaded()")
+endif
+
+if (overloaded(100.0, 100) != 70)
+ error("overloaded(double, int)")
+endif
+
+# Combination 4
+if (overloadedagain("hello") != 80)
+ error("overloadedagain(const char *)")
+endif
+
+if (overloadedagain() != 90)
+ error("overloadedagain(double)")
+endif
+
+# specializations
+if (specialization(10) != 202)
+ error("specialization(int)")
+endif
+
+if (specialization(10.1) != 203)
+ error("specialization(double)")
+endif
+
+if (specialization(10, 10) != 204)
+ error("specialization(int, int)")
+endif
+
+if (specialization(10.0, 10.1) != 205)
+ error("specialization(double, double)")
+endif
+
+if (specialization("hi", "hi") != 201)
+ error("specialization(const char *, const char *)")
+endif
+
+
+# simple specialization
+xyz();
+xyz_int();
+xyz_double();
+
+# a bit of everything
+if (overload("hi") != 0)
+ error("overload()")
+endif
+
+if (overload(1) != 10)
+ error("overload(int t)")
+endif
+
+if (overload(1, 1) != 20)
+ error("overload(int t, const int &)")
+endif
+
+if (overload(1, "hello") != 30)
+ error("overload(int t, const char *)")
+endif
+
+k = Klass();
+if (overload(k) != 10)
+ error("overload(Klass t)")
+endif
+
+if (overload(k, k) != 20)
+ error("overload(Klass t, const Klass &)")
+endif
+
+if (overload(k, "hello") != 30)
+ error("overload(Klass t, const char *)")
+endif
+
+if (overload(10.1, "hi") != 40)
+ error("overload(double t, const char *)")
+endif
+
+if (overload() != 50)
+ error("overload(const char *)")
+endif
+
+
+# everything put in a namespace
+if (nsoverload("hi") != 1000)
+ error("nsoverload()")
+endif
+
+if (nsoverload(1) != 1010)
+ error("nsoverload(int t)")
+endif
+
+if (nsoverload(1, 1) != 1020)
+ error("nsoverload(int t, const int &)")
+endif
+
+if (nsoverload(1, "hello") != 1030)
+ error("nsoverload(int t, const char *)")
+endif
+
+if (nsoverload(k) != 1010)
+ error("nsoverload(Klass t)")
+endif
+
+if (nsoverload(k, k) != 1020)
+ error("nsoverload(Klass t, const Klass &)")
+endif
+
+if (nsoverload(k, "hello") != 1030)
+ error("nsoverload(Klass t, const char *)")
+endif
+
+if (nsoverload(10.1, "hi") != 1040)
+ error("nsoverload(double t, const char *)")
+endif
+
+if (nsoverload() != 1050)
+ error("nsoverload(const char *)")
+endif
+
+
+A_foo(1);
+b = B();
+b.foo(1);
diff --git a/trunk/Examples/test-suite/octave/preproc_runme.m b/trunk/Examples/test-suite/octave/preproc_runme.m
new file mode 100644
index 000000000..791b38bf4
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/preproc_runme.m
@@ -0,0 +1,18 @@
+preproc
+
+if (preproc.cvar.endif != 1)
+ error
+endif
+
+if (preproc.cvar.define != 1)
+ error
+endif
+
+if (preproc.cvar.defined != 1)
+ error
+endif
+
+if (2*preproc.one != preproc.two)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/primitive_ref_runme.m b/trunk/Examples/test-suite/octave/primitive_ref_runme.m
new file mode 100644
index 000000000..68a5750c3
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/primitive_ref_runme.m
@@ -0,0 +1,53 @@
+primitive_ref
+
+if (ref_int(3) != 3)
+ error
+endif
+
+if (ref_uint(3) != 3)
+ error
+endif
+
+if (ref_short(3) != 3)
+ error
+endif
+
+if (ref_ushort(3) != 3)
+ error
+endif
+
+if (ref_long(3) != 3)
+ error
+endif
+
+if (ref_ulong(3) != 3)
+ error
+endif
+
+if (ref_schar(3) != 3)
+ error
+endif
+
+if (ref_uchar(3) != 3)
+ error
+endif
+
+if (ref_float(3.5) != 3.5)
+ error
+endif
+
+if (ref_double(3.5) != 3.5)
+ error
+endif
+
+if (ref_bool(true) != true)
+ error
+endif
+
+if (!strcmp(ref_char('x'),'x'))
+ error
+endif
+
+if (ref_over(0) != 0)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/primitive_types_runme.m b/trunk/Examples/test-suite/octave/primitive_types_runme.m
new file mode 100644
index 000000000..568e3511e
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/primitive_types_runme.m
@@ -0,0 +1,402 @@
+primitive_types
+
+var_init();
+
+# assigning globals calls
+cvar.var_bool = sct_bool;
+cvar.var_schar = sct_schar;
+cvar.var_uchar = sct_uchar;
+cvar.var_int = sct_int;
+cvar.var_uint = sct_uint;
+cvar.var_short = sct_short;
+cvar.var_ushort = sct_ushort;
+cvar.var_long = sct_long;
+cvar.var_ulong = sct_ulong;
+cvar.var_llong = sct_llong;
+cvar.var_ullong = sct_ullong;
+cvar.var_char = sct_char;
+cvar.var_pchar = sct_pchar;
+cvar.var_pcharc = sct_pcharc;
+cvar.var_pint = sct_pint;
+cvar.var_sizet = sct_sizet;
+cvar.var_hello = sct_hello;
+cvar.var_myint = sct_myint;
+cvar.var_namet = def_namet;
+cvar.var_parami = sct_parami;
+cvar.var_paramd = sct_paramd;
+cvar.var_paramc = sct_paramc;
+
+v_check();
+
+function octerror(name, val, cte)
+ name, val, cte
+ error
+endfunction
+
+if cvar.var_bool != cct_bool:
+octerror("bool", cvar.var_bool, cct_bool)
+endif
+if cvar.var_schar != cct_schar:
+octerror("schar", cvar.var_schar, cct_schar)
+endif
+if cvar.var_uchar != cct_uchar:
+ octerror("uchar", cvar.var_uchar, cct_uchar)
+endif
+if cvar.var_int != cct_int:
+ octerror("int", cvar.var_int, cct_int)
+endif
+if cvar.var_uint != cct_uint:
+ octerror("uint", cvar.var_uint, cct_uint)
+endif
+if cvar.var_short != cct_short:
+ octerror("short", cvar.var_short, cct_short)
+endif
+if cvar.var_ushort != cct_ushort:
+ octerror("ushort", cvar.var_ushort, cct_ushort)
+endif
+if cvar.var_long != cct_long:
+ octerror("long", cvar.var_long, cct_long)
+endif
+if cvar.var_ulong != cct_ulong:
+ octerror("ulong", cvar.var_ulong, cct_ulong)
+endif
+if cvar.var_llong != cct_llong:
+ octerror("llong", cvar.var_llong, cct_llong)
+endif
+if cvar.var_ullong != cct_ullong:
+ octerror("ullong", cvar.var_ullong, cct_ullong)
+endif
+if cvar.var_char != cct_char:
+ octerror("char", cvar.var_char, cct_char)
+endif
+if cvar.var_pchar != cct_pchar:
+ octerror("pchar", cvar.var_pchar, cct_pchar)
+endif
+if cvar.var_pcharc != cct_pcharc:
+ octerror("pchar", cvar.var_pcharc, cct_pcharc)
+endif
+if cvar.var_pint != cct_pint:
+ octerror("pint", cvar.var_pint, cct_pint)
+endif
+if cvar.var_sizet != cct_sizet:
+ octerror("sizet", cvar.var_sizet, cct_sizet)
+endif
+if cvar.var_hello != cct_hello:
+ octerror("hello", cvar.var_hello, cct_hello)
+endif
+if cvar.var_myint != cct_myint:
+ octerror("myint", cvar.var_myint, cct_myint)
+endif
+if cvar.var_namet != def_namet:
+ octerror("name", cvar.var_namet, def_namet)
+endif
+
+
+function OctTest()
+ self=subclass(TestDirector);
+ self.ident=@(self,x) x;
+
+ self.vval_bool=@(self, x) self.ident(x);
+ self.vval_schar=@(self, x) self.ident(x);
+ self.vval_uchar=@(self, x) self.ident(x);
+ self.vval_int=@(self, x) self.ident(x);
+ self.vval_uint=@(self, x) self.ident(x);
+ self.vval_short=@(self, x) self.ident(x);
+ self.vval_ushort=@(self, x) self.ident(x);
+ self.vval_long=@(self, x) self.ident(x);
+ self.vval_ulong=@(self, x) self.ident(x);
+ self.vval_llong=@(self, x) self.ident(x);
+ self.vval_ullong=@(self, x) self.ident(x);
+ self.vval_float=@(self, x) self.ident(x);
+ self.vval_double=@(self, x) self.ident(x);
+ self.vval_char=@(self, x) self.ident(x);
+ self.vval_pchar=@(self, x) self.ident(x);
+ self.vval_pcharc=@(self, x) self.ident(x);
+ self.vval_pint=@(self, x) self.ident(x);
+ self.vval_sizet=@(self, x) self.ident(x);
+ self.vval_hello=@(self, x) self.ident(x);
+ self.vval_myint=@(self, x) self.ident(x);
+
+ self.vref_bool=@(self, x) self.ident(x);
+ self.vref_schar=@(self, x) self.ident(x);
+ self.vref_uchar=@(self, x) self.ident(x);
+ self.vref_int=@(self, x) self.ident(x);
+ self.vref_uint=@(self, x) self.ident(x);
+ self.vref_short=@(self, x) self.ident(x);
+ self.vref_ushort=@(self, x) self.ident(x);
+ self.vref_long=@(self, x) self.ident(x);
+ self.vref_ulong=@(self, x) self.ident(x);
+ self.vref_llong=@(self, x) self.ident(x);
+ self.vref_ullong=@(self, x) self.ident(x);
+ self.vref_float=@(self, x) self.ident(x);
+ self.vref_double=@(self, x) self.ident(x);
+ self.vref_char=@(self, x) self.ident(x);
+ self.vref_pchar=@(self, x) self.ident(x);
+ self.vref_pcharc=@(self, x) self.ident(x);
+ self.vref_pint=@(self, x) self.ident(x);
+ self.vref_sizet=@(self, x) self.ident(x);
+ self.vref_hello=@(self, x) self.ident(x);
+ self.vref_myint=@(self, x) self.ident(x);
+endfunction
+
+
+t = Test();
+p = OctTest();
+
+
+# internal call check
+if (t.c_check() != p.c_check())
+ error, "bad director"
+endif
+
+p.var_bool = p.stc_bool;
+p.var_schar = p.stc_schar;
+p.var_uchar = p.stc_uchar;
+p.var_int = p.stc_int;
+p.var_uint = p.stc_uint;
+p.var_short = p.stc_short;
+p.var_ushort = p.stc_ushort;
+p.var_long = p.stc_long;
+p.var_ulong = p.stc_ulong;
+p.var_llong = p.stc_llong;
+p.var_ullong = p.stc_ullong;
+p.var_char = p.stc_char;
+p.var_pchar = sct_pchar;
+p.var_pcharc = sct_pcharc;
+p.var_pint = sct_pint;
+p.var_sizet = sct_sizet;
+p.var_hello = sct_hello;
+p.var_myint = sct_myint;
+p.var_namet = def_namet;
+p.var_parami = sct_parami;
+p.var_paramd = sct_paramd;
+p.var_paramc = sct_paramc;
+
+p.v_check();
+
+t.var_bool = t.stc_bool;
+t.var_schar = t.stc_schar;
+t.var_uchar = t.stc_uchar;
+t.var_int = t.stc_int;
+t.var_uint = t.stc_uint;
+t.var_short = t.stc_short;
+t.var_ushort = t.stc_ushort;
+t.var_long = t.stc_long;
+t.var_ulong = t.stc_ulong;
+t.var_llong = t.stc_llong;
+t.var_ullong = t.stc_ullong;
+t.var_char = t.stc_char;
+t.var_pchar = sct_pchar;
+t.var_pcharc = sct_pcharc;
+t.var_pint = sct_pint;
+t.var_sizet = sct_sizet;
+t.var_hello = sct_hello;
+t.var_myint = sct_myint;
+t.var_namet = def_namet;
+t.var_parami = sct_parami;
+t.var_paramd = sct_paramd;
+t.var_paramc = sct_paramc;
+
+t.v_check();
+
+# this value contains a '0' char!
+if (def_namet != 'ho\0la')
+ error
+endif
+
+t.var_namet = def_namet;
+if (t.var_namet != def_namet)
+ error
+endif
+
+t.var_namet = 'holac';
+
+if (t.var_namet != 'holac')
+ error
+endif
+
+t.var_namet = 'hol';
+
+if (t.var_namet != 'hol')
+ error
+endif
+
+if (t.strlen('hile') != 4)
+ error
+endif
+
+if (t.strlen('hil\0') != 4)
+ error
+endif
+
+cvar.var_char = '\0';
+if (cvar.var_char != '\0')
+ error
+endif
+
+cvar.var_char = 0;
+if (cvar.var_char != '\0')
+ error
+endif
+
+cvar.var_namet = '\0';
+if (cvar.var_namet != '')
+ error
+endif
+
+cvar.var_namet = '';
+if (cvar.var_namet != '')
+ error, "bad char empty case"
+endif
+
+cvar.var_pchar = None;
+if (cvar.var_pchar != None)
+ error, "bad None case"
+endif
+
+cvar.var_pchar = '';
+if (cvar.var_pchar != '')
+ error
+endif
+
+cvar.var_pcharc = None;
+if (cvar.var_pcharc != None)
+ error
+endif
+
+cvar.var_pcharc = '';
+if (cvar.var_pcharc != '')
+ error
+endif
+
+#
+# creating a raw char*
+#
+pc = new_pchar(5);
+pchar_setitem(pc, 0, 'h');
+pchar_setitem(pc, 1, 'o');
+pchar_setitem(pc, 2, 'l');
+pchar_setitem(pc, 3, 'a');
+pchar_setitem(pc, 4, 0);
+
+
+if (t.strlen(pc) != 4)
+ error
+endif
+
+cvar.var_pchar = pc;
+if (cvar.var_pchar != "hola")
+ error
+endif
+
+cvar.var_namet = pc;
+if (cvar.var_namet != "hola")
+ error
+endif
+
+delete_pchar(pc);
+
+#
+# Now when things should fail
+#
+
+try
+ error = 0;
+ a = t.var_uchar;
+ t.var_uchar = 10000;
+ err = 1;
+catch
+ if (a != t.var_uchar)
+ err = 1;
+ endif
+end_try_catch
+
+if (err)
+ error
+endif
+
+try
+ err = 0;
+ a = t.var_char;
+ t.var_char = '23';
+ err = 1;
+catch
+ if (a != t.var_char)
+ error = 1
+ endif
+end_try_catch
+if (err)
+ error
+endif
+
+try
+ err = 0
+ a = t.var_uint
+ t.var_uint = -1
+ err = 1;
+catch
+ if a != t.var_uint:
+ err = 1;
+ endif
+end_try_catch
+if (err)
+ error
+endif
+
+#
+#
+try
+ err = 0;
+ a = t.var_namet;
+ t.var_namet = '123456';
+ err = 1;
+catch
+ if (a != t.var_namet)
+ err = 1;
+ endif
+end_try_catch
+if (err)
+ error
+endif
+
+#
+#
+#
+t2 = p.vtest(t);
+if (t.var_namet != t2.var_namet)
+ error
+endif
+
+
+if (cvar.fixsize != 'ho\0la\0\0\0')
+ error
+endif
+
+cvar.fixsize = 'ho';
+if (cvar.fixsize != 'ho\0\0\0\0\0\0')
+ error
+endif
+
+
+f = Foo(3);
+f1 = fptr_val(f);
+f2 = fptr_ref(f);
+if (f1._a != f2._a)
+ error
+endif
+
+v = char_foo(1,3);
+if (v !=3)
+ error
+endif
+
+s = char_foo(1,"hello");
+if (s !="hello")
+ error
+endif
+
+
+v = SetPos(1,3);
+if (v !=4)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/profiletest_runme.m b/trunk/Examples/test-suite/octave/profiletest_runme.m
new file mode 100644
index 000000000..d4f07dc11
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/profiletest_runme.m
@@ -0,0 +1,32 @@
+import _profiletest
+import profiletest
+
+a = profiletest.A()
+print a
+print a.this
+
+b = profiletest.B()
+fn = b.fn
+i = 50000
+while i:
+ a = fn(a) #1
+ a = fn(a) #2
+ a = fn(a) #3
+ a = fn(a) #4
+ a = fn(a) #5
+ a = fn(a) #6
+ a = fn(a) #7
+ a = fn(a) #8
+ a = fn(a) #9
+ a = fn(a) #10
+ a = fn(a) #1
+ a = fn(a) #2
+ a = fn(a) #3
+ a = fn(a) #4
+ a = fn(a) #5
+ a = fn(a) #6
+ a = fn(a) #7
+ a = fn(a) #8
+ a = fn(a) #9
+ a = fn(a) #20
+ i -= 1
diff --git a/trunk/Examples/test-suite/octave/refcount_runme.m b/trunk/Examples/test-suite/octave/refcount_runme.m
new file mode 100644
index 000000000..3ce5bcda2
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/refcount_runme.m
@@ -0,0 +1,15 @@
+refcount
+#
+# very innocent example
+#
+
+a = A3();
+b1 = B(a);
+b2 = B.create(a);
+
+
+if (a.ref_count() != 3)
+ error("This program will crash... now")
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/reference_global_vars_runme.m b/trunk/Examples/test-suite/octave/reference_global_vars_runme.m
new file mode 100644
index 000000000..67ad9c514
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/reference_global_vars_runme.m
@@ -0,0 +1,91 @@
+reference_global_vars
+
+# const class reference variable
+if (getconstTC().num != 33)
+ error
+endif
+
+# primitive reference variables
+cvar.var_bool = createref_bool(false);
+if (value_bool(cvar.var_bool) != 0)
+ error
+endif
+
+cvar.var_bool = createref_bool(true);
+if (value_bool(cvar.var_bool) != 1)
+ error
+endif
+
+cvar.var_char = createref_char('w');
+if (!strcmp(value_char(cvar.var_char),'w'))
+ error
+endif
+
+cvar.var_unsigned_char = createref_unsigned_char(10);
+if (value_unsigned_char(cvar.var_unsigned_char) != 10)
+ error
+endif
+
+cvar.var_signed_char = createref_signed_char(10);
+if (value_signed_char(cvar.var_signed_char) != 10)
+ error
+endif
+
+cvar.var_short = createref_short(10);
+if (value_short(cvar.var_short) != 10)
+ error
+endif
+
+cvar.var_unsigned_short = createref_unsigned_short(10);
+if (value_unsigned_short(cvar.var_unsigned_short) != 10)
+ error
+endif
+
+cvar.var_int = createref_int(10);
+if (value_int(cvar.var_int) != 10)
+ error
+endif
+
+cvar.var_unsigned_int = createref_unsigned_int(10);
+if (value_unsigned_int(cvar.var_unsigned_int) != 10)
+ error
+endif
+
+cvar.var_long = createref_long(10);
+if (value_long(cvar.var_long) != 10)
+ error
+endif
+
+cvar.var_unsigned_long = createref_unsigned_long(10);
+if (value_unsigned_long(cvar.var_unsigned_long) != 10)
+ error
+endif
+
+cvar.var_long_long = createref_long_long(int64(0x6FFFFFFFFFFFFFF8));
+if (value_long_long(cvar.var_long_long) != int64(0x6FFFFFFFFFFFFFF8))
+ error
+endif
+
+#ull = abs(0xFFFFFFF2FFFFFFF0)
+ull = uint64(55834574864);
+cvar.var_unsigned_long_long = createref_unsigned_long_long(ull);
+if (value_unsigned_long_long(cvar.var_unsigned_long_long) != ull)
+ error
+endif
+
+cvar.var_float = createref_float(10.5);
+if (value_float(cvar.var_float) != 10.5)
+ error
+endif
+
+cvar.var_double = createref_double(10.5);
+if (value_double(cvar.var_double) != 10.5)
+ error
+endif
+
+# class reference variable
+cvar.var_TestClass = createref_TestClass(TestClass(20));
+if (value_TestClass(cvar.var_TestClass).num != 20)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/rename_scope_runme.m b/trunk/Examples/test-suite/octave/rename_scope_runme.m
new file mode 100644
index 000000000..154f99dfe
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/rename_scope_runme.m
@@ -0,0 +1,15 @@
+rename_scope
+
+a = Natural_UP();
+b = Natural_BP();
+
+if (a.rtest() != 1)
+ error
+endif
+
+if (b.rtest() != 1)
+ error
+endif
+
+f = @equals;
+
diff --git a/trunk/Examples/test-suite/octave/ret_by_value_runme.m b/trunk/Examples/test-suite/octave/ret_by_value_runme.m
new file mode 100644
index 000000000..d17c9f233
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/ret_by_value_runme.m
@@ -0,0 +1,10 @@
+ret_by_value
+
+a = ret_by_value.get_test();
+if (a.myInt != 100)
+ error
+endif
+
+if (a.myShort != 200)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/return_const_value_runme.m b/trunk/Examples/test-suite/octave/return_const_value_runme.m
new file mode 100644
index 000000000..1219c9293
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/return_const_value_runme.m
@@ -0,0 +1,11 @@
+return_const_value
+
+p = return_const_value.Foo_ptr.getPtr();
+if (p.getVal() != 17)
+ error("Runtime test1 faild. p.getVal()=", p.getVal())
+endif
+
+p = return_const_value.Foo_ptr.getConstPtr();
+if (p.getVal() != 17)
+ error("Runtime test2 faild. p.getVal()=", p.getVal())
+endif
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_extend_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_extend_runme.m
new file mode 100644
index 000000000..c30cd9ff8
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_extend_runme.m
@@ -0,0 +1,41 @@
+smart_pointer_extend
+
+f = Foo();
+b = Bar(f);
+
+if (b.extension() != f.extension())
+ error
+endif
+
+
+b = CBase();
+d = CDerived();
+p = CPtr();
+
+if (b.bar() != p.bar())
+ error
+endif
+
+if (d.foo() != p.foo())
+ error
+endif
+
+if (b.hello() != p.hello())
+ error
+endif
+
+
+
+d = DFoo();
+
+dp = DPtrFoo(d);
+
+if (d.SExt(1) != dp.SExt(1))
+ error
+endif
+
+if (d.Ext(1) != dp.Ext(1))
+ error
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_member_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_member_runme.m
new file mode 100644
index 000000000..30251c3a8
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_member_runme.m
@@ -0,0 +1,39 @@
+smart_pointer_member
+
+f = Foo();
+f.y = 1;
+
+if (f.y != 1)
+ error
+endif
+
+b = Bar(f);
+b.y = 2;
+
+if (f.y != 2)
+ error("f.y = %i, b.y = %i",f.y,b.y)
+endif
+
+if (swig_this(b.x) != swig_this(f.x))
+ error
+endif
+
+if (b.z != f.z)
+ error
+endif
+
+try
+ if (Foo.z == Bar.z)
+ error
+ endif
+ error
+catch
+end_try_catch
+
+
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_multi_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_multi_runme.m
new file mode 100644
index 000000000..71ef9109a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_multi_runme.m
@@ -0,0 +1,17 @@
+smart_pointer_multi
+
+f = Foo();
+b = Bar(f);
+s = Spam(b);
+g = Grok(b);
+
+s.x = 3;
+if (s.getx() != 3)
+ error
+endif
+
+g.x = 4;
+if (g.getx() != 4)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m
new file mode 100644
index 000000000..4b77e0eea
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m
@@ -0,0 +1,18 @@
+smart_pointer_multi_typedef
+
+f = Foo();
+b = Bar(f);
+s = Spam(b);
+g = Grok(b);
+
+s.x = 3;
+if (s.getx() != 3)
+ error
+endif
+
+g.x = 4;
+if (g.getx() != 4)
+ error
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_not_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_not_runme.m
new file mode 100644
index 000000000..8b3fea8c7
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_not_runme.m
@@ -0,0 +1,42 @@
+smart_pointer_not
+
+f = Foo();
+b = Bar(f);
+s = Spam(f);
+g = Grok(f);
+
+try
+ x = b.x;
+ error("Error! b.x")
+catch
+end_try_catch
+
+try
+ x = s.x;
+ error("Error! s.x")
+catch
+end_try_catch
+
+try
+ x = g.x;
+ error("Error! g.x")
+catch
+end_try_catch
+
+try
+ x = b.getx();
+ error("Error! b.getx()")
+catch
+end_try_catch
+
+try
+ x = s.getx();
+ error("Error! s.getx()")
+catch
+end_try_catch
+
+try
+ x = g.getx();
+ error("Error! g.getx()")
+catch
+end_try_catch
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_overload_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_overload_runme.m
new file mode 100644
index 000000000..214437d66
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_overload_runme.m
@@ -0,0 +1,27 @@
+smart_pointer_overload
+
+f = Foo();
+b = Bar(f);
+
+
+if (f.test(3) != 1)
+ error
+endif
+if (f.test(3.5) != 2)
+ error
+endif
+if (f.test("hello") != 3)
+ error
+endif
+
+if (b.test(3) != 1)
+ error
+endif
+if (b.test(3.5) != 2)
+ error
+endif
+if (b.test("hello") != 3)
+ error
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_rename_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_rename_runme.m
new file mode 100644
index 000000000..260ee3e4c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_rename_runme.m
@@ -0,0 +1,17 @@
+smart_pointer_rename
+
+f = Foo();
+b = Bar(f);
+
+if (b.test() != 3)
+ error
+endif
+
+if (b.ftest1(1) != 1)
+ error
+endif
+
+if (b.ftest2(2,3) != 2)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_simple_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_simple_runme.m
new file mode 100644
index 000000000..26f32e04f
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_simple_runme.m
@@ -0,0 +1,15 @@
+smart_pointer_simple
+
+f = Foo();
+b = Bar(f);
+
+b.x = 3;
+if (b.getx() != 3)
+ error
+endif
+
+fp = b.__deref__();
+fp.x = 4;
+if (fp.getx() != 4)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m
new file mode 100644
index 000000000..4884fa24b
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m
@@ -0,0 +1,19 @@
+smart_pointer_templatevariables
+
+d = DiffImContainerPtr_D(create(1234, 5678));
+
+if (d.id != 1234)
+ error
+endif
+#if (d.xyz != 5678):
+# error
+
+d.id = 4321;
+#d.xyz = 8765
+
+if (d.id != 4321)
+ error
+endif
+#if (d.xyz != 8765):
+# error
+
diff --git a/trunk/Examples/test-suite/octave/smart_pointer_typedef_runme.m b/trunk/Examples/test-suite/octave/smart_pointer_typedef_runme.m
new file mode 100644
index 000000000..8fa6ca26a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/smart_pointer_typedef_runme.m
@@ -0,0 +1,15 @@
+smart_pointer_typedef
+
+f = Foo();
+b = Bar(f);
+
+b.x = 3;
+if (b.getx() != 3)
+ error
+endif
+
+fp = b.__deref__();
+fp.x = 4;
+if (fp.getx() != 4)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/sneaky1_runme.m b/trunk/Examples/test-suite/octave/sneaky1_runme.m
new file mode 100644
index 000000000..e044370ea
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/sneaky1_runme.m
@@ -0,0 +1,5 @@
+sneaky1
+x = sneaky1.add(3,4);
+y = sneaky1.subtract(3,4);
+z = sneaky1.mul(3,4);
+w = sneaky1.divide(3,4);
diff --git a/trunk/Examples/test-suite/octave/static_const_member_2_runme.m b/trunk/Examples/test-suite/octave/static_const_member_2_runme.m
new file mode 100644
index 000000000..b242bfcd1
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/static_const_member_2_runme.m
@@ -0,0 +1,18 @@
+static_const_member_2
+
+c = Test_int();
+try
+ a = c.forward_field;
+ a = c.current_profile;
+ a = c.RightIndex;
+ a = Test_int.backward_field;
+ a = Test_int.LeftIndex;
+ a = Test_int.cavity_flags;
+catch
+end_try_catch
+
+
+if (Foo.BAZ.val != 2*Foo.BAR.val)
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/std_containers_runme.m b/trunk/Examples/test-suite/octave/std_containers_runme.m
new file mode 100644
index 000000000..074f0fd58
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/std_containers_runme.m
@@ -0,0 +1,135 @@
+std_containers
+
+
+cube = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
+
+icube = std_containers.cident(cube);
+for i=len(cube),
+ if (cube{i} != icube{i})
+ error("bad cident")
+ endif
+endfor
+
+
+p = {1,2};
+if (p != std_containers.pident(p))
+ error("bad pident")
+endif
+
+v = {1,2,3,4,5,6};
+iv = std_containers.vident(v);
+for i=0:len(v),
+ if (v{i} != iv{i})
+ error("bad vident")
+ endif
+endfor
+
+
+iv = std_containers.videntu(v);
+for i=0:len(v),
+ if (v{i} != iv{i})
+ error("bad videntu")
+ endif
+endfor
+
+
+vu = std_containers.vector_ui(v);
+if (vu{2} != std_containers.videntu(vu){2})
+ error("bad videntu")
+endif
+
+
+if (v(0:3)(1) != vu(0:3)(1))
+ error("bad getslice")
+endif
+
+
+m = {[1,2,3],[2,3],[3,4]};
+im = std_containers.midenti(m);
+
+for i=0:len(m),
+ for j=0:len(m(i)),
+ if (m(i)(j) != im(i)(j))
+ error("bad getslice")
+ endif
+ endfor
+endfor
+
+m = {[1,0,1],[1,1],[1,1]};
+im = std_containers.midentb(m);
+for i=0:len(m),
+ for j in range(0,len(m[i])):
+ if (m(i)(j) != im(i)(j))
+ error("bad getslice")
+ endif
+ endfor
+endfor
+
+
+mi = std_containers.imatrix(m);
+mc = std_containers.cmatrix(m);
+if (mi(0)(1) != mc(0)(1))
+ error("bad matrix")
+endif
+
+
+map ={};
+map{'hello'} = 1;
+map{'hi'} = 2;
+map{'3'} = 2;
+
+imap = std_containers.mapident(map);
+for k in map,
+ if (map(k) != imap(k))
+ error("bad map")
+ endif
+endfor
+
+
+mapc ={};
+c1 = std_containers.C();
+c2 = std_containers.C();
+mapc(1) = swig_this(c1);
+mapc(2) = c2;
+
+std_containers.mapidentc(mapc);
+
+
+vi = std_containers.vector_i([2,2,3,4]);
+
+
+v = [1,2];
+v1 = std_containers.v_inout(vi);
+vi(1), v1(1);
+
+[v1,v2] = std_containers.v_inout2(v1,v2);
+
+a1 = std_containers.A(1);
+a2 = std_containers.A(2);
+
+p1 = {1,a1};
+p2 = {2,a2};
+v = (p1,p2);
+v2= std_containers.pia_vident(v);
+
+v2(0)(1).a;
+v2(1)(1).a;
+
+v3 = std_containers.vector_piA(v2);
+
+v3(0)(1).a;
+v3(1)(1).a;
+
+s = std_containers.set_i();
+s.append(1);
+s.append(2);
+s.append(3);
+j=1;
+for i in s,
+ if (i != j)
+ error
+ endif
+ j = j + 1;
+endfor
+
+
diff --git a/trunk/Examples/test-suite/octave/struct_rename_runme.m b/trunk/Examples/test-suite/octave/struct_rename_runme.m
new file mode 100644
index 000000000..1b57d8f66
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/struct_rename_runme.m
@@ -0,0 +1,4 @@
+struct_rename
+
+b = struct_rename.Bar();
+
diff --git a/trunk/Examples/test-suite/octave/struct_value_runme.m b/trunk/Examples/test-suite/octave/struct_value_runme.m
new file mode 100644
index 000000000..7340a36ec
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/struct_value_runme.m
@@ -0,0 +1,13 @@
+struct_value
+
+b = struct_value.Bar();
+
+b.a.x = 3;
+if (b.a.x != 3)
+ error
+endif
+
+b.b.x = 3;
+if (b.b.x != 3)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/swigobject_runme.m b/trunk/Examples/test-suite/octave/swigobject_runme.m
new file mode 100644
index 000000000..614e2a44a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/swigobject_runme.m
@@ -0,0 +1,28 @@
+swigobject
+
+a = A();
+
+a1 = a_ptr(a);
+a2 = a_ptr(a);
+
+if (swig_this(a1) != swig_this(a2))
+ error
+endif
+
+
+lthis = uint64(swig_this(a.this));
+xstr1 = printf("0x%x",lthis);
+xstr2 = pointer_str(a);
+
+if (xstr1 != xstr2)
+ error
+endif
+
+s = str(a.this);
+r = repr(a.this);
+
+v1 = v_ptr(a);
+v2 = v_ptr(a);
+if (uint64(v1) != uint64(v2))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/template_construct_runme.m b/trunk/Examples/test-suite/octave/template_construct_runme.m
new file mode 100644
index 000000000..2ed066409
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_construct_runme.m
@@ -0,0 +1 @@
+template_construct
diff --git a/trunk/Examples/test-suite/octave/template_default_arg_runme.m b/trunk/Examples/test-suite/octave/template_default_arg_runme.m
new file mode 100644
index 000000000..e50066248
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_default_arg_runme.m
@@ -0,0 +1,117 @@
+template_default_arg
+
+
+helloInt = template_default_arg.Hello_int();
+helloInt.foo(template_default_arg.Hello_int_hi);
+
+
+x = template_default_arg.X_int();
+if (x.meth(20.0, 200) != 200)
+ error("X_int test 1 failed")
+endif
+if (x.meth(20) != 20)
+ error("X_int test 2 failed")
+endif
+if (x.meth() != 0)
+ error("X_int test 3 failed")
+endif
+
+
+
+y = template_default_arg.Y_unsigned();
+if (y.meth(20.0, 200) != 200)
+ error("Y_unsigned test 1 failed")
+endif
+if (y.meth(20) != 20)
+ error("Y_unsigned test 2 failed")
+endif
+if (y.meth() != 0)
+ error("Y_unsigned test 3 failed")
+endif
+
+
+
+x = template_default_arg.X_longlong();
+x = template_default_arg.X_longlong(20.0);
+x = template_default_arg.X_longlong(20.0, 200);
+
+
+x = template_default_arg.X_int();
+x = template_default_arg.X_int(20.0);
+x = template_default_arg.X_int(20.0, 200);
+
+
+x = template_default_arg.X_hello_unsigned();
+x = template_default_arg.X_hello_unsigned(20.0);
+x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int());
+
+
+y = template_default_arg.Y_hello_unsigned();
+y.meth(20.0, template_default_arg.Hello_int());
+y.meth(template_default_arg.Hello_int());
+y.meth();
+
+
+
+fz = template_default_arg.Foo_Z_8();
+x = template_default_arg.X_Foo_Z_8();
+fzc = x.meth(fz);
+
+
+# Templated functions
+
+# plain function: int ott(Foo<int>)
+if (template_default_arg.ott(template_default_arg.Foo_int()) != 30)
+ error("ott test 1 failed")
+endif
+
+# %template(ott) ott<int, int>
+if (template_default_arg.ott() != 10)
+ error("ott test 2 failed")
+endif
+if (template_default_arg.ott(1) != 10)
+ error("ott test 3 failed")
+endif
+if (template_default_arg.ott(1, 1) != 10)
+ error("ott test 4 failed")
+endif
+
+if (template_default_arg.ott("hi") != 20)
+ error("ott test 5 failed")
+endif
+if (template_default_arg.ott("hi", 1) != 20)
+ error("ott test 6 failed")
+endif
+if (template_default_arg.ott("hi", 1, 1) != 20)
+ error("ott test 7 failed")
+endif
+
+# %template(ott) ott<const char *>
+if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40)
+ error("ott test 8 failed")
+endif
+
+if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40)
+ error("ott test 9 failed")
+endif
+
+# %template(ott) ott<int>
+if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50)
+ error("ott test 10 failed")
+endif
+
+if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50)
+ error("ott test 11 failed")
+endif
+
+# %template(ott) ott<double>
+if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60)
+ error("ott test 12 failed")
+endif
+
+if (template_default_arg.ott(template_default_arg.Hello_int()) != 60)
+ error("ott test 13 failed")
+endif
+
+
+
diff --git a/trunk/Examples/test-suite/octave/template_extend1_runme.m b/trunk/Examples/test-suite/octave/template_extend1_runme.m
new file mode 100644
index 000000000..e672da783
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_extend1_runme.m
@@ -0,0 +1,12 @@
+template_extend1
+
+a = template_extend1.lBaz();
+b = template_extend1.dBaz();
+
+if (!strcmp(a.foo(),"lBaz::foo"))
+ error
+endif
+
+if (!strcmp(b.foo(),"dBaz::foo"))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/template_extend2_runme.m b/trunk/Examples/test-suite/octave/template_extend2_runme.m
new file mode 100644
index 000000000..93c44d7de
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_extend2_runme.m
@@ -0,0 +1,12 @@
+template_extend2
+
+a = template_extend2.lBaz();
+b = template_extend2.dBaz();
+
+if (!strcmp(a.foo(),"lBaz::foo"))
+ error
+endif
+
+if (!strcmp(b.foo(),"dBaz::foo"))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/template_inherit_runme.m b/trunk/Examples/test-suite/octave/template_inherit_runme.m
new file mode 100644
index 000000000..ce7931e1c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_inherit_runme.m
@@ -0,0 +1,68 @@
+template_inherit
+a = FooInt();
+b = FooDouble();
+c = BarInt();
+d = BarDouble();
+e = FooUInt();
+f = BarUInt();
+
+if (!strcmp(a.blah(),"Foo"))
+ error
+endif
+
+if (!strcmp(b.blah(),"Foo"))
+ error
+endif
+
+if (!strcmp(e.blah(),"Foo"))
+ error
+endif
+
+if (!strcmp(c.blah(),"Bar"))
+ error
+endif
+
+if (!strcmp(d.blah(),"Bar"))
+ error
+endif
+
+if (!strcmp(f.blah(),"Bar"))
+ error
+endif
+
+if (!strcmp(c.foomethod(),"foomethod"))
+ error
+endif
+
+if (!strcmp(d.foomethod(),"foomethod"))
+ error
+endif
+
+if (!strcmp(f.foomethod(),"foomethod"))
+ error
+endif
+
+if (!strcmp(invoke_blah_int(a),"Foo"))
+ error
+endif
+
+if (!strcmp(invoke_blah_int(c),"Bar"))
+ error
+endif
+
+if (!strcmp(invoke_blah_double(b),"Foo"))
+ error
+endif
+
+if (!strcmp(invoke_blah_double(d),"Bar"))
+ error
+endif
+
+if (!strcmp(invoke_blah_uint(e),"Foo"))
+ error
+endif
+
+if (!strcmp(invoke_blah_uint(f),"Bar"))
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/template_matrix_runme.m b/trunk/Examples/test-suite/octave/template_matrix_runme.m
new file mode 100644
index 000000000..b8fb3d3dc
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_matrix_runme.m
@@ -0,0 +1,6 @@
+template_matrix
+passVector([1,2,3]);
+passMatrix({[1,2],[1,2,3]});
+passCube({{[1,2],[1,2,3]},{[1,2],[1,2,3]}});
+
+
diff --git a/trunk/Examples/test-suite/octave/template_ns4_runme.m b/trunk/Examples/test-suite/octave/template_ns4_runme.m
new file mode 100644
index 000000000..58ced7ca4
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_ns4_runme.m
@@ -0,0 +1,6 @@
+template_ns4
+
+d = make_Class_DD();
+if (!strcmp(d.test(),"test"))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/template_ns_runme.m b/trunk/Examples/test-suite/octave/template_ns_runme.m
new file mode 100644
index 000000000..29a2f53f6
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_ns_runme.m
@@ -0,0 +1,21 @@
+template_ns
+p1 = pairii(2,3);
+p2 = pairii(p1);
+
+if (p2.first != 2)
+ error
+endif
+if (p2.second != 3)
+ error
+endif
+
+p3 = pairdd(3.5,2.5);
+p4 = pairdd(p3);
+
+if (p4.first != 3.5)
+ error
+endif
+
+if (p4.second != 2.5)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/template_opaque_runme.m b/trunk/Examples/test-suite/octave/template_opaque_runme.m
new file mode 100644
index 000000000..1c123b334
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_opaque_runme.m
@@ -0,0 +1,7 @@
+template_opaque
+
+v = template_opaque.OpaqueVectorType(10);
+
+template_opaque.FillVector(v);
+
+
diff --git a/trunk/Examples/test-suite/octave/template_ref_type_runme.m b/trunk/Examples/test-suite/octave/template_ref_type_runme.m
new file mode 100644
index 000000000..ef77e06d9
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_ref_type_runme.m
@@ -0,0 +1,5 @@
+template_ref_type
+
+xr = template_ref_type.XC();
+y = template_ref_type.Y();
+y.find(xr);
diff --git a/trunk/Examples/test-suite/octave/template_rename_runme.m b/trunk/Examples/test-suite/octave/template_rename_runme.m
new file mode 100644
index 000000000..7cb54938c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_rename_runme.m
@@ -0,0 +1,12 @@
+template_rename
+
+i = template_rename.iFoo();
+d = template_rename.dFoo();
+
+a = i.blah_test(4);
+b = i.spam_test(5);
+c = i.groki_test(6);
+
+x = d.blah_test(7);
+y = d.spam(8);
+z = d.grok_test(9);
diff --git a/trunk/Examples/test-suite/octave/template_static_runme.m b/trunk/Examples/test-suite/octave/template_static_runme.m
new file mode 100644
index 000000000..c54139ae5
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_static_runme.m
@@ -0,0 +1,3 @@
+template_static
+
+Foo_bar_double(1);
diff --git a/trunk/Examples/test-suite/octave/template_tbase_template_runme.m b/trunk/Examples/test-suite/octave/template_tbase_template_runme.m
new file mode 100644
index 000000000..da8ec4c69
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_tbase_template_runme.m
@@ -0,0 +1,6 @@
+template_tbase_template
+
+a = make_Class_dd();
+if (!strcmp(a.test(),"test"))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/template_type_namespace_runme.m b/trunk/Examples/test-suite/octave/template_type_namespace_runme.m
new file mode 100644
index 000000000..bbdcdef5e
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_type_namespace_runme.m
@@ -0,0 +1,5 @@
+template_type_namespace
+
+assert(strcmp(foo()(1),"foo"));
+
+
diff --git a/trunk/Examples/test-suite/octave/template_typedef_cplx2_runme.m b/trunk/Examples/test-suite/octave/template_typedef_cplx2_runme.m
new file mode 100644
index 000000000..94d3beb79
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_typedef_cplx2_runme.m
@@ -0,0 +1,103 @@
+template_typedef_cplx2
+
+#
+# double case
+#
+
+try
+ d = make_Identity_double();
+ a = swig_this(d);
+catch
+ d
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(d)) != 1)
+ d
+ error("is not an ArithUnaryFunction")
+ error
+endif
+
+try
+ e = make_Multiplies_double_double_double_double(d, d);
+ a = swig_this(e);
+catch
+ e
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(e)) != 1)
+ e
+ error("is not an ArithUnaryFunction")
+endif
+
+
+#
+# complex case
+#
+
+try
+ c = make_Identity_complex();
+ a = swig_this(c);
+catch
+ c
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(c)) != 1)
+ c
+ error("is not an ArithUnaryFunction")
+endif
+
+try
+ f = make_Multiplies_complex_complex_complex_complex(c, c);
+ a = swig_this(f);
+catch
+ f
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(f)) != 1)
+ f
+ error("is not an ArithUnaryFunction")
+endif
+
+#
+# Mix case
+#
+
+try
+ g = make_Multiplies_double_double_complex_complex(d, c);
+ a = swig_this(g);
+catch
+ g
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(g)) != 1)
+ g
+ error("is not an ArithUnaryFunction")
+ error
+endif
+
+
+try
+ h = make_Multiplies_complex_complex_double_double(c, d);
+ a = swig_this(h);
+catch
+ h
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(h)) == -1)
+ h
+ error("is not an ArithUnaryFunction")
+endif
+
+try
+ a = g.get_value();
+catch
+ error(g, "has not get_value() method")
+ error
+end_try_catch
+
diff --git a/trunk/Examples/test-suite/octave/template_typedef_cplx3_runme.m b/trunk/Examples/test-suite/octave/template_typedef_cplx3_runme.m
new file mode 100644
index 000000000..d21f27990
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_typedef_cplx3_runme.m
@@ -0,0 +1,34 @@
+template_typedef_cplx3
+
+#
+# this is OK
+#
+
+
+s = Sin();
+s.get_base_value();
+s.get_value();
+s.get_arith_value();
+my_func_r(s);
+make_Multiplies_double_double_double_double(s,s);
+
+z = CSin();
+z.get_base_value();
+z.get_value();
+z.get_arith_value();
+my_func_c(z);
+make_Multiplies_complex_complex_complex_complex(z,z);
+
+#
+# Here we fail
+#
+d = make_Identity_double();
+my_func_r(d);
+
+c = make_Identity_complex();
+my_func_c(c);
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/template_typedef_cplx4_runme.m b/trunk/Examples/test-suite/octave/template_typedef_cplx4_runme.m
new file mode 100644
index 000000000..4db276de4
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_typedef_cplx4_runme.m
@@ -0,0 +1,33 @@
+template_typedef_cplx4
+
+#
+# this is OK
+#
+
+
+s = Sin();
+s.get_base_value();
+s.get_value();
+s.get_arith_value();
+my_func_r(s);
+make_Multiplies_double_double_double_double(s,s);
+
+z = CSin();
+z.get_base_value();
+z.get_value();
+z.get_arith_value();
+my_func_c(z);
+make_Multiplies_complex_complex_complex_complex(z,z);
+
+#
+# Here we fail
+#
+d = make_Identity_double();
+my_func_r(d);
+
+c = make_Identity_complex();
+my_func_c(c);
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/template_typedef_cplx_runme.m b/trunk/Examples/test-suite/octave/template_typedef_cplx_runme.m
new file mode 100644
index 000000000..d00981cec
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_typedef_cplx_runme.m
@@ -0,0 +1,92 @@
+template_typedef_cplx
+
+#
+# double case
+#
+
+try
+ d = make_Identity_double();
+ a = swig_this(d);
+catch
+ d
+ error("is not an instance")
+end_try_catch
+
+if (findstr("ArithUnaryFunction",swig_type(d)) != 1)
+ d
+ error("is not an ArithUnaryFunction")
+endif
+
+try
+ e = make_Multiplies_double_double_double_double(d, d);
+ a = swig_this(e);
+catch
+ error(e, "is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(e)) != 1);
+ c
+ error("is not an ArithUnaryFunction")
+endif
+
+
+#
+# complex case
+#
+
+try
+ c = make_Identity_complex();
+ a = swig_this(c);
+catch
+ c
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(c)) != 1)
+ c
+ error("is not an ArithUnaryFunction")
+endif
+
+try
+ f = make_Multiplies_complex_complex_complex_complex(c, c);
+ a = swig_this(f);
+catch
+ f
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(f)) != 1)
+ f
+ error("is not an ArithUnaryFunction")
+endif
+
+#
+# Mix case
+#
+
+try
+ g = make_Multiplies_double_double_complex_complex(d, c);
+ a = swig_this(g);
+catch
+ g
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(g)) != 1)
+ g
+ error("is not an ArithUnaryFunction")
+endif
+
+
+try
+ h = make_Multiplies_complex_complex_double_double(c, d);
+ a = swig_this(h);
+catch
+ h
+ error("is not an instance")
+end_try_catch
+
+if (findstr('ArithUnaryFunction',swig_type(h)) != 1)
+ h
+ error("is not an ArithUnaryFunction")
+endif
diff --git a/trunk/Examples/test-suite/octave/template_typedef_import_runme.m b/trunk/Examples/test-suite/octave/template_typedef_import_runme.m
new file mode 100644
index 000000000..0574ab1fc
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_typedef_import_runme.m
@@ -0,0 +1,34 @@
+template_typedef_cplx2
+template_typedef_import
+
+#
+# this is OK
+#
+
+
+s = Sin();
+s.get_base_value();
+s.get_value();
+s.get_arith_value();
+my_func_r(s);
+make_Multiplies_double_double_double_double(s,s);
+
+z = CSin();
+z.get_base_value();
+z.get_value();
+z.get_arith_value();
+my_func_c(z);
+make_Multiplies_complex_complex_complex_complex(z,z);
+
+#
+# Here we fail
+#
+d = make_Identity_double();
+my_func_r(d);
+
+c = make_Identity_complex();
+my_func_c(c);
+
+
+
+
diff --git a/trunk/Examples/test-suite/octave/template_typedef_runme.m b/trunk/Examples/test-suite/octave/template_typedef_runme.m
new file mode 100644
index 000000000..8d8af795b
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/template_typedef_runme.m
@@ -0,0 +1,51 @@
+template_typedef
+
+d = make_Identity_float();
+c = make_Identity_reald();
+
+
+try
+ a = swig_this(d);
+ a = swig_this(c);
+catch
+ error
+end_try_catch
+
+try
+ e = make_Multiplies_float_float_float_float(d, d);
+ a = swig_this(e);
+catch
+ e
+ error("is not an instance")
+end_try_catch
+
+try
+ f = make_Multiplies_reald_reald_reald_reald(c, c);
+ a = swig_this(f);
+catch
+ f
+ error("is not an instance");
+end_try_catch
+
+try
+ g = make_Multiplies_float_float_reald_reald(d, c);
+ a = swig_this(g);
+catch
+ error(g, "is not an instance")
+end_try_catch
+
+
+# the old large format
+if (strcmp("<unknown>",swig_typequery("vfncs::ArithUnaryFunction<vfncs::arith_traits<float,double>::argument_type,vfncs::arith_traits<float,double >::result_type > *")))
+ error
+endif
+
+# the reduced format
+if (strcmp("<unknown>",swig_typequery("vfncs::ArithUnaryFunction<double,double> *")))
+ error
+endif
+
+# this is a bad name
+if (!strcmp("<unknown>",swig_typequery("vfncs::ArithUnaryFunction<double,doublex> *")))
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/typedef_class_runme.m b/trunk/Examples/test-suite/octave/typedef_class_runme.m
new file mode 100644
index 000000000..97d2aed6a
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/typedef_class_runme.m
@@ -0,0 +1,7 @@
+typedef_class
+
+a = typedef_class.RealA();
+a.a = 3;
+
+b = typedef_class.B();
+b.testA(a);
diff --git a/trunk/Examples/test-suite/octave/typedef_inherit_runme.m b/trunk/Examples/test-suite/octave/typedef_inherit_runme.m
new file mode 100644
index 000000000..6c4c47a43
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/typedef_inherit_runme.m
@@ -0,0 +1,27 @@
+typedef_inherit
+
+a = typedef_inherit.Foo();
+b = typedef_inherit.Bar();
+
+x = typedef_inherit.do_blah(a);
+if (!strcmp(x,"Foo::blah"))
+ error("Whoa! Bad return", x)
+endif
+
+x = typedef_inherit.do_blah(b);
+if (!strcmp(x,"Bar::blah"))
+ error("Whoa! Bad return", x)
+endif
+
+c = typedef_inherit.Spam();
+d = typedef_inherit.Grok();
+
+x = typedef_inherit.do_blah2(c);
+if (!strcmp(x,"Spam::blah"))
+ error("Whoa! Bad return", x)
+endif
+
+x = typedef_inherit.do_blah2(d);
+if (!strcmp(x,"Grok::blah"))
+ error("Whoa! Bad return", x)
+endif
diff --git a/trunk/Examples/test-suite/octave/typedef_scope_runme.m b/trunk/Examples/test-suite/octave/typedef_scope_runme.m
new file mode 100644
index 000000000..9e6d1013c
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/typedef_scope_runme.m
@@ -0,0 +1,14 @@
+typedef_scope
+
+b = typedef_scope.Bar();
+x = b.test1(42,"hello");
+if (x != 42)
+ error("Failed!!")
+endif
+
+x = b.test2(42,"hello");
+if (!strcmp(x,"hello"))
+ error("Failed!!")
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/typemap_namespace_runme.m b/trunk/Examples/test-suite/octave/typemap_namespace_runme.m
new file mode 100644
index 000000000..ec62a3910
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/typemap_namespace_runme.m
@@ -0,0 +1,10 @@
+typemap_namespace
+
+if (!strcmp(test1("hello"),"hello"))
+ error
+endif
+
+if (!strcmp(test2("hello"),"hello"))
+ error
+endif
+
diff --git a/trunk/Examples/test-suite/octave/typemap_ns_using_runme.m b/trunk/Examples/test-suite/octave/typemap_ns_using_runme.m
new file mode 100644
index 000000000..dd3f657f0
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/typemap_ns_using_runme.m
@@ -0,0 +1,5 @@
+typemap_ns_using
+
+if (typemap_ns_using.spam(37) != 37)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/typename_runme.m b/trunk/Examples/test-suite/octave/typename_runme.m
new file mode 100644
index 000000000..c47f817a7
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/typename_runme.m
@@ -0,0 +1,13 @@
+typename
+f = typename.Foo();
+b = typename.Bar();
+
+x = typename.twoFoo(f);
+if (x == floor(x))
+ error("Wrong return type!")
+endif
+y = typename.twoBar(b);
+if (y != floor(y))
+ error("Wrong return type!")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/types_directive_runme.m b/trunk/Examples/test-suite/octave/types_directive_runme.m
new file mode 100644
index 000000000..0757c6c39
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/types_directive_runme.m
@@ -0,0 +1,15 @@
+types_directive
+
+d1 = Time1(2001, 2, 3, 60);
+newDate = add(d1, 7); # check that a Time1 instance is accepted where Date is expected
+if (newDate.day != 10)
+ error
+endif
+
+d2 = Time2(1999, 8, 7, 60);
+newDate = add(d2, 7); # check that a Time2 instance is accepted where Date is expected
+if (newDate.day != 14)
+ error
+endif
+
+
diff --git a/trunk/Examples/test-suite/octave/unions_runme.m b/trunk/Examples/test-suite/octave/unions_runme.m
new file mode 100644
index 000000000..05ac25240
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/unions_runme.m
@@ -0,0 +1,49 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+unions
+
+# Create new instances of SmallStruct and BigStruct for later use
+small = unions.SmallStruct();
+small.jill = 200;
+
+big = unions.BigStruct();
+big.smallstruct = small;
+big.jack = 300;
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+eut = unions.EmbeddedUnionTest();
+
+# First check the SmallStruct in EmbeddedUnionTest
+eut.number = 1;
+eut.uni.small = small;
+Jill1 = eut.uni.small.jill;
+if (Jill1 != 200)
+ error("Runtime test1 failed. eut.uni.small.jill=%i" , Jill1)
+endif
+
+Num1 = eut.number;
+if (Num1 != 1)
+ error("Runtime test2 failed. eut.number=%i" , Num1)
+endif
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+eut.number = 2;
+eut.uni.big = big;
+Jack1 = eut.uni.big.jack;
+if (Jack1 != 300)
+ error("Runtime test3 failed. eut.uni.big.jack=%i" , Jack1)
+endif
+
+Jill2 = eut.uni.big.smallstruct.jill;
+if (Jill2 != 200)
+ error("Runtime test4 failed. eut.uni.big.smallstruct.jill=%i" , Jill2)
+endif
+
+Num2 = eut.number;
+if (Num2 != 2)
+ error("Runtime test5 failed. eut.number=%i" , Num2)
+endif
+
diff --git a/trunk/Examples/test-suite/octave/using1_runme.m b/trunk/Examples/test-suite/octave/using1_runme.m
new file mode 100644
index 000000000..0c37daf7f
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using1_runme.m
@@ -0,0 +1,5 @@
+using1
+
+if (using1.spam(37) != 37)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/using2_runme.m b/trunk/Examples/test-suite/octave/using2_runme.m
new file mode 100644
index 000000000..205c6d7ad
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using2_runme.m
@@ -0,0 +1,5 @@
+using2
+
+if (using2.spam(37) != 37)
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/using_composition_runme.m b/trunk/Examples/test-suite/octave/using_composition_runme.m
new file mode 100644
index 000000000..9b58d6d54
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using_composition_runme.m
@@ -0,0 +1,43 @@
+using_composition
+
+f = FooBar();
+if (f.blah(3) != 3)
+ error("FooBar::blah(int)")
+endif
+
+if (f.blah(3.5) != 3.5)
+ error("FooBar::blah(double)")
+endif
+
+if (!strcmp(f.blah("hello"),"hello"))
+ error("FooBar::blah(char *)")
+endif
+
+
+f = FooBar2();
+if (f.blah(3) != 3)
+ error("FooBar2::blah(int)")
+endif
+
+if (f.blah(3.5) != 3.5)
+ error("FooBar2::blah(double)")
+endif
+
+if (!strcmp(f.blah("hello"),"hello"))
+ error("FooBar2::blah(char *)")
+endif
+
+
+f = FooBar3();
+if (f.blah(3) != 3)
+ error("FooBar3::blah(int)")
+endif
+
+if (f.blah(3.5) != 3.5)
+ error("FooBar3::blah(double)")
+endif
+
+if (!strcmp(f.blah("hello"),"hello"))
+ error("FooBar3::blah(char *)")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/using_extend_runme.m b/trunk/Examples/test-suite/octave/using_extend_runme.m
new file mode 100644
index 000000000..b9c13fa68
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using_extend_runme.m
@@ -0,0 +1,27 @@
+using_extend
+
+f = FooBar();
+if (f.blah(3) != 3)
+ error("blah(int)")
+endif
+
+if (f.blah(3.5) != 3.5)
+ error("blah(double)")
+endif
+
+if (!strcmp(f.blah("hello"),"hello"))
+ error("blah(char *)")
+endif
+
+if (f.blah(3,4) != 7)
+ error("blah(int,int)")
+endif
+
+if (f.blah(3.5,7.5) != (3.5+7.5))
+ error("blah(double,double)")
+endif
+
+
+if (f.duh(3) != 3)
+ error("duh(int)")
+endif
diff --git a/trunk/Examples/test-suite/octave/using_inherit_runme.m b/trunk/Examples/test-suite/octave/using_inherit_runme.m
new file mode 100644
index 000000000..effd0e2a0
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using_inherit_runme.m
@@ -0,0 +1,61 @@
+using_inherit
+
+b = Bar();
+if (b.test(3) != 3)
+ error("Bar::test(int)")
+endif
+
+if (b.test(3.5) != 3.5)
+ error("Bar::test(double)")
+endif
+
+
+b = Bar2();
+if (b.test(3) != 6)
+ error("Bar2::test(int)")
+endif
+
+if (b.test(3.5) != 7.0)
+ error("Bar2::test(double)")
+endif
+
+
+b = Bar3();
+if (b.test(3) != 6)
+ error("Bar3::test(int)")
+endif
+
+if (b.test(3.5) != 7.0)
+ error("Bar3::test(double)")
+endif
+
+
+b = Bar4();
+if (b.test(3) != 6)
+ error("Bar4::test(int)")
+endif
+
+if (b.test(3.5) != 7.0)
+ error("Bar4::test(double)")
+endif
+
+
+b = Fred1();
+if (b.test(3) != 3)
+ error("Fred1::test(int)")
+endif
+
+if (b.test(3.5) != 7.0)
+ error("Fred1::test(double)")
+endif
+
+
+b = Fred2();
+if (b.test(3) != 3)
+ error("Fred2::test(int)")
+endif
+
+if (b.test(3.5) != 7.0)
+ error("Fred2::test(double)")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/using_private_runme.m b/trunk/Examples/test-suite/octave/using_private_runme.m
new file mode 100644
index 000000000..3ac71dbf9
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using_private_runme.m
@@ -0,0 +1,16 @@
+using_private
+
+f = FooBar();
+f.x = 3;
+
+if (f.blah(4) != 4)
+ error, "blah(int)"
+endif
+
+if (f.defaulted() != -1)
+ error, "defaulted()"
+endif
+
+if (f.defaulted(222) != 222)
+ error, "defaulted(222)"
+endif
diff --git a/trunk/Examples/test-suite/octave/using_protected_runme.m b/trunk/Examples/test-suite/octave/using_protected_runme.m
new file mode 100644
index 000000000..ed4b1c32b
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/using_protected_runme.m
@@ -0,0 +1,8 @@
+using_protected
+
+f = FooBar();
+f.x = 3;
+
+if (f.blah(4) != 4)
+ error("blah(int)")
+endif
diff --git a/trunk/Examples/test-suite/octave/varargs_runme.m b/trunk/Examples/test-suite/octave/varargs_runme.m
new file mode 100644
index 000000000..dcdcb2491
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/varargs_runme.m
@@ -0,0 +1,23 @@
+varargs
+
+if (!strcmp(varargs.test("Hello"),"Hello"))
+ error("Failed")
+endif
+
+f = varargs.Foo("Greetings");
+if (!strcmp(f.str,"Greetings"))
+ error("Failed")
+endif
+
+if (!strcmp(f.test("Hello"),"Hello"))
+ error("Failed")
+endif
+
+
+if (!strcmp(varargs.test_def("Hello",1),"Hello"))
+ error("Failed")
+endif
+
+if (!strcmp(varargs.test_def("Hello"),"Hello"))
+ error("Failed")
+endif
diff --git a/trunk/Examples/test-suite/octave/virtual_derivation_runme.m b/trunk/Examples/test-suite/octave/virtual_derivation_runme.m
new file mode 100644
index 000000000..8ce8503ad
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/virtual_derivation_runme.m
@@ -0,0 +1,9 @@
+virtual_derivation
+#
+# very innocent example
+#
+b = B(3);
+if (b.get_a() != b.get_b())
+ error("something is really wrong")
+endif
+
diff --git a/trunk/Examples/test-suite/octave/virtual_poly_runme.m b/trunk/Examples/test-suite/octave/virtual_poly_runme.m
new file mode 100644
index 000000000..0c7c95153
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/virtual_poly_runme.m
@@ -0,0 +1,44 @@
+virtual_poly
+
+d = virtual_poly.NDouble(3.5);
+i = virtual_poly.NInt(2);
+
+#
+# the copy methods return the right polymorphic types
+#
+dc = d.copy();
+ic = i.copy();
+
+if (d.get() != dc.get())
+ error
+endif
+
+if (i.get() != ic.get())
+ error
+endif
+
+virtual_poly.incr(ic);
+
+if ((i.get() + 1) != ic.get())
+ error
+endif
+
+
+dr = d.ref_this();
+if (d.get() != dr.get())
+ error
+endif
+
+
+#
+# 'narrowing' also works
+#
+ddc = virtual_poly.NDouble_narrow(d.nnumber());
+if (d.get() != ddc.get())
+ error
+endif
+
+dic = virtual_poly.NInt_narrow(i.nnumber());
+if (i.get() != dic.get())
+ error
+endif
diff --git a/trunk/Examples/test-suite/octave/voidtest_runme.m b/trunk/Examples/test-suite/octave/voidtest_runme.m
new file mode 100644
index 000000000..e62f8a57f
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/voidtest_runme.m
@@ -0,0 +1,38 @@
+voidtest
+
+voidtest.globalfunc();
+f = voidtest.Foo();
+f.memberfunc();
+
+voidtest.Foo_staticmemberfunc();
+
+function fvoid()
+end
+
+try
+ a = f.memberfunc();
+catch
+end_try_catch
+try
+ a = fvoid();
+catch
+end_try_catch
+
+
+v1 = voidtest.vfunc1(f);
+v2 = voidtest.vfunc2(f);
+if (swig_this(v1) != swig_this(v2))
+ error
+endif
+
+v3 = voidtest.vfunc3(v1);
+if (swig_this(v3) != swig_this(f))
+ error
+endif
+v4 = voidtest.vfunc1(f);
+if (swig_this(v4) != swig_this(v1))
+ error
+endif
+
+
+v3.memberfunc();
diff --git a/trunk/Examples/test-suite/octave/wrapmacro_runme.m b/trunk/Examples/test-suite/octave/wrapmacro_runme.m
new file mode 100644
index 000000000..5069f2cca
--- /dev/null
+++ b/trunk/Examples/test-suite/octave/wrapmacro_runme.m
@@ -0,0 +1,8 @@
+wrapmacro
+
+a = 2;
+b = -1;
+wrapmacro.maximum(a,b);
+wrapmacro.maximum(a/7.0, -b*256);
+wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1);
+
diff --git a/trunk/Examples/test-suite/octave_cell_deref.i b/trunk/Examples/test-suite/octave_cell_deref.i
new file mode 100644
index 000000000..2e92ec4de
--- /dev/null
+++ b/trunk/Examples/test-suite/octave_cell_deref.i
@@ -0,0 +1,15 @@
+%module octave_cell_deref
+
+%inline {
+ bool func(const char* s) {
+ return !strcmp("hello",s);
+ }
+
+ Cell func2() {
+ Cell c(1,2);
+ c(0) = "hello";
+ c(1) = 4;
+ return c;
+ }
+}
+
diff --git a/trunk/Examples/test-suite/operator_overload.i b/trunk/Examples/test-suite/operator_overload.i
new file mode 100644
index 000000000..80facff76
--- /dev/null
+++ b/trunk/Examples/test-suite/operator_overload.i
@@ -0,0 +1,360 @@
+/* File : operator_overload.i */
+/*
+This is a test of all the possible operator overloads
+
+see bottom for a set of possible tests
+*/
+%module operator_overload
+
+#if defined(SWIGPYTHON)
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ,
+ SWIGWARN_IGNORE_OPERATOR_INDEX,
+ SWIGWARN_IGNORE_OPERATOR_PLUSPLUS,
+ SWIGWARN_IGNORE_OPERATOR_MINUSMINUS,
+ SWIGWARN_IGNORE_OPERATOR_LAND,
+ SWIGWARN_IGNORE_OPERATOR_LOR);
+#endif
+
+#if !defined(SWIGLUA) && !defined(SWIGR)
+%rename(Equal) operator =;
+%rename(PlusEqual) operator +=;
+%rename(MinusEqual) operator -=;
+%rename(MultiplyEqual) operator *=;
+%rename(DivideEqual) operator /=;
+%rename(PercentEqual) operator %=;
+%rename(Plus) operator +;
+%rename(Minus) operator -;
+%rename(Multiply) operator *;
+%rename(Divide) operator /;
+%rename(Percent) operator %;
+%rename(Not) operator !;
+%rename(IndexIntoConst) operator[](unsigned idx) const;
+%rename(IndexInto) operator[](unsigned idx);
+%rename(Functor) operator ();
+%rename(EqualEqual) operator ==;
+%rename(NotEqual) operator !=;
+%rename(LessThan) operator <;
+%rename(LessThanEqual) operator <=;
+%rename(GreaterThan) operator >;
+%rename(GreaterThanEqual) operator >=;
+%rename(And) operator &&;
+%rename(Or) operator ||;
+%rename(PlusPlusPrefix) operator++();
+%rename(PlusPlusPostfix) operator++(int);
+%rename(MinusMinusPrefix) operator--();
+%rename(MinusMinusPostfix) operator--(int);
+#endif
+
+%rename(IndexInto) *::operator[](unsigned idx); // some languages have a %rename *::operator[] already in place, which seems to takes precedence over the above %rename operator[].
+
+#ifdef SWIGCSHARP
+%csmethodmodifiers operator++() "protected";
+%csmethodmodifiers operator++(int) "private";
+%csmethodmodifiers operator--() "private";
+%csmethodmodifiers operator--(int) "protected";
+%typemap(cscode) Op %{
+ public static Op operator++(Op op) {
+ // Unlike C++, operator++ must not modify the parameter and both prefix and postfix operations call this method
+ Op newOp = new Op(op.i);
+ newOp.PlusPlusPostfix(0);
+ return newOp;
+ }
+ public static Op operator--(Op op) {
+ // Unlike C++, operator-- must not modify the parameter and both prefix and postfix operations call this method
+ Op newOp = new Op(op.i);
+ newOp.MinusMinusPrefix();
+ return newOp;
+ }
+%}
+#endif
+
+#ifdef SWIGPHP
+%rename(AndOperator) operator &&;
+%rename(OrOperator) operator ||;
+#endif
+
+#ifdef SWIG_ALLEGRO_CL
+%{
+#include <stdio.h>
+%}
+#endif
+
+%rename(IntCast) operator int();
+%rename(DoubleCast) operator double();
+
+%inline %{
+
+#if defined(_MSC_VER)
+ #include <iso646.h> /* for named logical operator, eg 'operator or' */
+#endif
+
+#include <assert.h>
+
+class Op {
+public:
+ int i;
+ Op(int a=0) : i(a)
+ {}
+ Op(const Op& o) : i(o.i)
+ {}
+ virtual ~Op()
+ {}
+
+ friend Op operator &&(const Op& a,const Op& b){return Op(a.i&&b.i);}
+ friend Op operator or(const Op& a,const Op& b){return Op(a.i||b.i);}
+
+ Op &operator=(const Op& o) {
+ i=o.i;
+ return *this;
+ }
+ // +=,-=... are member fns
+ void operator+=(const Op& o){ i+=o.i;}
+ void operator-=(const Op& o){ i-=o.i;}
+ void operator*=(const Op& o){ i*=o.i;}
+ void operator/=(const Op& o){ i/=o.i;}
+ void operator%=(const Op& o){ i%=o.i;}
+ // the +,-,*,... are friends
+ // (just to make life harder)
+ friend Op operator+(const Op& a,const Op& b){return Op(a.i+b.i);}
+ friend Op operator-(const Op& a,const Op& b);
+ friend Op operator*(const Op& a,const Op& b){return Op(a.i*b.i);}
+ friend Op operator/(const Op& a,const Op& b){return Op(a.i/b.i);}
+ friend Op operator%(const Op& a,const Op& b){return Op(a.i%b.i);}
+
+ // unary operators
+ Op operator-() const {return Op(-i);}
+ bool operator !() const {return !(i);}
+
+ // overloading the [] operator
+ // need 2 versions: get & set
+ // note: C++ can be a little mixed up upon which version it calls
+ // most of the time it calls the second version
+ int operator[](unsigned idx)const
+ { if (idx==0) return i; return 0;}
+ int& operator[](unsigned idx)
+ { if (idx==0) return i; static int j;j=0; return j;}
+
+ // overloading the () operator
+ // this can have many parameters so we will test this
+ int operator()(int a=0){return i+a;}
+ int operator()(int a,int b){return i+a+b;}
+
+ // increment/decrement operators
+ Op& operator++() {++i; return *this;} // prefix ++
+ Op operator++(int) {Op o = *this; ++(*this); return o;} // postfix ++
+ Op& operator--() {--i; return *this;} // prefix --
+ Op operator--(int) {Op o = *this; --(*this); return o;} // postfix --
+
+ // TODO: <<,<<=
+
+ // cast operators
+ operator double() { return i; }
+ virtual operator int() { return i; }
+
+ // This method just checks that the operators are implemented correctly
+ static void sanity_check();
+};
+
+// just to complicate matters
+// we have a couple of non class operators
+inline bool operator==(const Op& a,const Op& b){return a.i==b.i;}
+inline bool operator!=(const Op& a,const Op& b){return a.i!=b.i;}
+inline bool operator< (const Op& a,const Op& b){return a.i<b.i;}
+inline bool operator<=(const Op& a,const Op& b){return a.i<=b.i;}
+inline bool operator> (const Op& a,const Op& b){return a.i>b.i;}
+inline bool operator>=(const Op& a,const Op& b){return a.i>=b.i;}
+
+%}
+
+%{
+ // This one is not declared inline as VC++7.1 gets mixed up with the unary operator-
+ Op operator-(const Op& a,const Op& b){return Op(a.i-b.i);}
+%}
+
+// in order to wrapper this correctly
+// we need to extend the class
+// to make the friends & non members part of the class
+%extend Op{
+ Op operator &&(const Op& b){return Op($self->i&&b.i);}
+ Op operator or(const Op& b){return Op($self->i||b.i);}
+
+ Op operator+(const Op& b){return Op($self->i+b.i);}
+ Op operator-(const Op& b){return Op($self->i-b.i);}
+ Op operator*(const Op& b){return Op($self->i*b.i);}
+ Op operator/(const Op& b){return Op($self->i/b.i);}
+ Op operator%(const Op& b){return Op($self->i%b.i);}
+
+ bool operator==(const Op& b){return $self->i==b.i;}
+ bool operator!=(const Op& b){return $self->i!=b.i;}
+ bool operator< (const Op& b){return $self->i<b.i;}
+ bool operator<=(const Op& b){return $self->i<=b.i;}
+ bool operator> (const Op& b){return $self->i>b.i;}
+ bool operator>=(const Op& b){return $self->i>=b.i;}
+
+ // subtraction with reversed arguments
+ Op __rsub__(const int b){return Op(b - $self->i);}
+
+ // we also add the __str__() fn to the class
+ // this allows it to be converted to a string (so it can be printed)
+ const char* __str__()
+ {
+ static char buffer[255];
+ sprintf(buffer,"Op(%d)",$self->i);
+ return buffer;
+ }
+ // to get the [] operator working correctly we need to extend with two function
+ // __getitem__ & __setitem__
+ int __getitem__(unsigned i)
+ { return (*$self)[i]; }
+ void __setitem__(unsigned i,int v)
+ { (*$self)[i]=v; }
+}
+
+/*
+Suggested list of operator overloads (mainly from python)
+
+Operators overloaded with their C++ equivalent
+__add__,__sub__,__mul__,__div__,__mod__ +,-,*,/,%
+__iadd__,__isub__,__imul__,__idiv__,__imod__ +=,-=,*=,/=,%=
+
+__eq__,__ne__,__lt__,__le__,__gt__,__ge__ ==,!=,<,<=,>,>=
+__not__,__neg__ unary !, unary -
+__and__,__or__,__xor__ logical and,logical or,logical xor
+__rshift__,__lshift__ >>,<<
+
+__getitem__,__setitem__ for operator[]
+
+Operators overloaded without C++ equivilents
+__pow__ for power operator
+__str__ converts object to a string (should return a const char*)
+__concat__ for contatenation (if language supports)
+
+*/
+
+%inline %{
+class OpDerived : public Op {
+public:
+ OpDerived(int a=0) : Op(a)
+ {}
+
+ // overloaded
+ virtual operator int() { return i*2; }
+};
+%}
+
+
+%{
+
+#include <assert.h>
+
+void Op::sanity_check()
+{
+ // test routine:
+ Op a;
+ Op b=5;
+ Op c=b; // copy construct
+ Op d=2;
+ Op dd=d; // assignment operator
+
+ // test equality
+ assert(a!=b);
+ assert(b==c);
+ assert(a!=d);
+ assert(d==dd);
+
+ // test <
+ assert(a<b);
+ assert(a<=b);
+ assert(b<=c);
+ assert(b>=c);
+ assert(b>d);
+ assert(b>=d);
+
+ // test +=
+ Op e=3;
+ e+=d;
+ assert(e==b);
+ e-=c;
+ assert(e==a);
+ e=Op(1);
+ e*=b;
+ assert(e==c);
+ e/=d;
+ assert(e==d);
+ e%=c;
+ assert(e==d);
+
+ // test +
+ Op f(1),g(1);
+ assert(f+g==Op(2));
+ assert(f-g==Op(0));
+ assert(f*g==Op(1));
+ assert(f/g==Op(1));
+ assert(f%g==Op(0));
+
+ // test unary operators
+ assert(!a==true);
+ assert(!b==false);
+ assert(-a==a);
+ assert(-b==Op(-5));
+
+ // test []
+ Op h=3;
+ assert(h[0]==3);
+ assert(h[1]==0);
+ h[0]=2; // set
+ assert(h[0]==2);
+ h[1]=2; // ignored
+ assert(h[0]==2);
+ assert(h[1]==0);
+
+ // test ()
+ Op i=3;
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // plus add some code to check the __str__ fn
+ //assert(str(Op(1))=="Op(1)");
+ //assert(str(Op(-3))=="Op(-3)");
+
+ // test ++ and --
+ Op j(100);
+ int original = j.i;
+ {
+ Op newOp = j++;
+ int newInt = original++;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = j--;
+ int newInt = original--;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = ++j;
+ int newInt = ++original;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = --j;
+ int newInt = --original;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+
+ // cast operators
+ Op k=3;
+ int check_k = k;
+ assert (check_k == 3);
+
+ Op l=4;
+ double check_l = l;
+ assert (check_l == 4);
+}
+
+%}
+
diff --git a/trunk/Examples/test-suite/operator_overload_break.i b/trunk/Examples/test-suite/operator_overload_break.i
new file mode 100644
index 000000000..9c6927bb0
--- /dev/null
+++ b/trunk/Examples/test-suite/operator_overload_break.i
@@ -0,0 +1,63 @@
+%module operator_overload_break
+
+#if defined(SWIGPYTHON)
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_PLUSPLUS);
+#endif
+
+#if !defined(SWIGLUA) && !defined(SWIGR) && !defined(SWIGPERL)
+%rename(Plus) operator +;
+%rename(Minus) operator -;
+%rename(EqualEqual) operator ==;
+%rename(PlusPlusPrefix) operator++();
+%rename(PlusPlusPostfix) operator++(int);
+#endif
+
+%{
+#include <iostream>
+using namespace std;
+%}
+
+%inline %{
+
+class Op
+{
+public:
+ Op(int n) {k = n;}
+ Op(const Op& other) {
+ std::cerr << "COPY: "<< other.k << std::endl;
+ k = other.k;
+ }
+
+ bool operator==(const Op& rhs) {
+ std::cerr << "Op: " << k << std::endl;
+ std::cerr << "obj: " << rhs.k << std::endl;
+ return (k == rhs.k);
+ }
+ bool operator==(int i) {
+ std::cerr << "Op: " << k << std::endl;
+ std::cerr << "other: " << i << std::endl;
+ return (k == i);
+ }
+
+ Op operator+(const Op& rhs) {return Op(k + rhs.k);}
+ Op operator+(int rhs) {return Op(k + rhs);}
+
+ Op operator-(const Op& rhs) {return Op(k - rhs.k);}
+ Op operator-(int rhs) {
+ std::cerr << "sub: " << rhs << std::endl;
+ return Op(k - rhs);
+ }
+
+ Op __rsub__(int lhs) {
+ std::cerr << "sub: " << lhs << std::endl;
+ return Op(lhs - k);
+ }
+
+ Op& operator++() {k++; return *this;}
+
+ void PrintK() {std::cerr << k << std::endl;}
+
+ int k;
+};
+
+%}
diff --git a/trunk/Examples/test-suite/operbool.i b/trunk/Examples/test-suite/operbool.i
new file mode 100644
index 000000000..793c0174e
--- /dev/null
+++ b/trunk/Examples/test-suite/operbool.i
@@ -0,0 +1,12 @@
+%module operbool
+
+%rename(operbool) operator bool();
+
+%inline %{
+ class Test {
+ public:
+ operator bool() {
+ return false;
+ }
+ };
+%}
diff --git a/trunk/Examples/test-suite/ordering.i b/trunk/Examples/test-suite/ordering.i
new file mode 100644
index 000000000..258e7b1ff
--- /dev/null
+++ b/trunk/Examples/test-suite/ordering.i
@@ -0,0 +1,30 @@
+%module ordering
+
+// Ruby used to fail on the ordering of the two Class declarations below
+
+struct Klass {
+ int variable;
+};
+
+%{
+struct Klass {
+ int variable;
+};
+%}
+
+
+// Testing the order of various code block sections
+
+%runtime %{
+ class RuntimeSection {};
+%}
+
+%header %{
+ class HeaderSection {};
+ void HeaderMethod(RuntimeSection rs) {}
+%}
+
+%wrapper %{
+ void WrapperMethod(HeaderSection hs, RuntimeSection rs) {}
+%}
+
diff --git a/trunk/Examples/test-suite/overload_complicated.i b/trunk/Examples/test-suite/overload_complicated.i
new file mode 100644
index 000000000..63ed32b3a
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_complicated.i
@@ -0,0 +1,72 @@
+// A complicated test of overloaded functions
+%module overload_complicated
+
+#ifndef SWIG_NO_OVERLOAD
+
+// Different warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#).
+%warnfilter(509, 516) Pop::Pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
+%warnfilter(509, 516) Pop::hip; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
+%warnfilter(509, 516) Pop::hop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
+%warnfilter(509, 516) Pop::pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
+%warnfilter(516) Pop::bop; // Overloaded method xxxx ignored. Method at xxx:y used.
+%warnfilter(516) Pop::bip; // Overloaded method xxxx ignored. Method at xxx:y used.
+%warnfilter(509, 516) ::muzak; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
+
+%typemap(in, numinputs=0) int l { $1 = 4711; }
+
+%inline %{
+
+double foo(int, int, char *, int) {
+ return 15;
+}
+
+double foo(int i, int j, double k = 17.4, int l = 18, char m = 'P') {
+ return i + j + k + l + (int) m;
+}
+
+struct Pop {
+ Pop(int* i) {}
+ Pop(int& i) {}
+ Pop(const int* i, bool b) {}
+ Pop(const int* i) {}
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ int hip(bool b) { return 701; }
+ int hip(int* i) { return 702; }
+ int hip(int& i) { return 703; }
+ int hip(int* i) const { return 704; }
+ int hip(const int* i) { return 705; }
+
+ // Reverse the order for the above
+ int hop(const int* i) { return 805; }
+ int hop(int* i) const { return 804; }
+ int hop(int& i) { return 803; }
+ int hop(int* i) { return 802; }
+ int hop(bool b) { return 801; }
+
+ // Few more variations and order shuffled
+ int pop(bool b) { return 901; }
+ int pop(int* i) const { return 902; }
+ int pop(int& i) { return 903; }
+ int pop(int* i) { return 904; }
+ int pop() { return 905; }
+ int pop(const int* i) { return 906; }
+
+ // Overload on const only
+ int bop(int* i) { return 1001; }
+ int bop(int* i) const { return 1002; }
+
+ int bip(int* i) const { return 2001; }
+ int bip(int* i) { return 2002; }
+};
+
+// Globals
+int muzak(bool b) { return 3001; }
+int muzak(int* i) { return 3002; }
+int muzak(int& i) { return 3003; }
+int muzak(const int* i) { return 3004; }
+
+%}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/overload_copy.i b/trunk/Examples/test-suite/overload_copy.i
new file mode 100644
index 000000000..a685f76e2
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/overload_extend.i b/trunk/Examples/test-suite/overload_extend.i
new file mode 100644
index 000000000..c32a07f57
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_extend.i
@@ -0,0 +1,65 @@
+%module overload_extend
+
+#ifndef __cplusplus
+%{
+#include <stdlib.h>
+%}
+
+%typemap(default) double y "$1=1000;";
+#endif
+
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
+#endif
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test;
+
+
+
+%extend Foo {
+ int test() { return 0; }
+ int test(int x) { x = 0; return 1; }
+ int test(char *s) { s = 0; return 2; }
+#ifdef __cplusplus
+ double test(double x, double y = 1000) { return x + y; }
+#else
+ double test(double x, double y) { return x + y; }
+#endif
+};
+
+
+%inline %{
+struct Foo {
+ int variable;
+#ifdef __cplusplus
+ int test() { return -1; }
+#endif
+};
+%}
+
+
+%extend Bar {
+#ifdef __cplusplus
+ Bar() {
+ return new Bar();
+ }
+ ~Bar() {
+ delete $self;
+ }
+#else
+ Bar() {
+ return (Bar *) malloc(sizeof(Bar));
+ }
+ ~Bar() {
+ free($self);
+ }
+#endif
+}
+
+%inline %{
+typedef struct {
+ int variable;
+} Bar;
+%}
+
+
diff --git a/trunk/Examples/test-suite/overload_extendc.i b/trunk/Examples/test-suite/overload_extendc.i
new file mode 100644
index 000000000..1c1dd00b6
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_extendc.i
@@ -0,0 +1,21 @@
+%module overload_extendc
+
+%typemap(default) int int2 "$1=1000;";
+
+%inline %{
+typedef struct Foo {
+ int dummy;
+} Foo;
+%}
+
+%extend Foo {
+ int test(int x) { x = 0; return 1; }
+ int test(char *s) { s = 0; return 2; }
+ int test(double x, double y) { x = 0; y = 0; return 3; }
+ int test(char *s, int int1, int int2) { s = 0; return int1+int2; }
+
+ /* C default arguments */
+ int test(Foo* f, int i=10, int j=20) { return i+j; }
+};
+
+
diff --git a/trunk/Examples/test-suite/overload_rename.i b/trunk/Examples/test-suite/overload_rename.i
new file mode 100644
index 000000000..cdb64514a
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_rename.i
@@ -0,0 +1,28 @@
+%module overload_rename
+
+
+%{
+
+class Foo {
+public:
+ Foo(float a, float b=1.0)
+ {
+ }
+
+ Foo(float a, int c, float b=1.0)
+ {
+ }
+
+};
+
+%}
+
+%rename(Foo_int) Foo::Foo(float a, int c, float b=1.0);
+
+class Foo {
+public:
+ Foo(float a, float b=1.0);
+ Foo(float a, int c, float b=1.0);
+};
+
+
diff --git a/trunk/Examples/test-suite/overload_simple.i b/trunk/Examples/test-suite/overload_simple.i
new file mode 100644
index 000000000..be7602083
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_simple.i
@@ -0,0 +1,205 @@
+// Simple tests of overloaded functions
+%module overload_simple
+
+#ifdef SWIGCHICKEN
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fbool;
+#endif
+
+#ifdef SWIGLUA
+// lua only has one numeric type, so most of the overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) bar;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Spam;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) num;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fid;
+#endif
+
+#ifndef SWIG_NO_OVERLOAD
+%immutable Spam::type;
+
+%inline %{
+
+struct Foo {
+};
+
+class Bar {
+public:
+ Bar(int i = 0) { num = i; }
+
+ static int foo(int a=0, int b=0) {return 0;}
+
+ int num;
+};
+
+char *foo() {
+ return (char *) "foo:";
+}
+char *foo(int) {
+ return (char*) "foo:int";
+}
+
+char *foo(double) {
+ return (char*) "foo:double";
+}
+
+char *foo(char *) {
+ return (char*) "foo:char *";
+}
+
+char *foo(Foo *) {
+ return (char*) "foo:Foo *";
+}
+char *foo(Bar *) {
+ return (char *) "foo:Bar *";
+}
+char *foo(void *) {
+ return (char *) "foo:void *";
+}
+char *foo(Foo *, int) {
+ return (char *) "foo:Foo *,int";
+}
+char *foo(double, Bar *) {
+ return (char *) "foo:double,Bar *";
+}
+
+char *blah(double) {
+ return (char *) "blah:double";
+}
+
+char *blah(char *) {
+ return (char *) "blah:char *";
+}
+
+class Spam {
+public:
+ Spam() { type = "none"; }
+ Spam(int) { type = "int"; }
+ Spam(double) { type = "double"; }
+ Spam(char *) { type = "char *"; }
+ Spam(Foo *) { type = "Foo *"; }
+ Spam(Bar *) { type = "Bar *"; }
+ Spam(void *) { type = "void *"; }
+ const char *type;
+
+char *foo(int) {
+ return (char*) "foo:int";
+}
+char *foo(double) {
+ return (char*) "foo:double";
+}
+char *foo(char *) {
+ return (char*) "foo:char *";
+}
+char *foo(Foo *) {
+ return (char*) "foo:Foo *";
+}
+char *foo(Bar *) {
+ return (char *) "foo:Bar *";
+}
+char *foo(void *) {
+ return (char *) "foo:void *";
+}
+
+static char *bar(int) {
+ return (char*) "bar:int";
+}
+static char *bar(double) {
+ return (char*) "bar:double";
+}
+static char *bar(char *) {
+ return (char*) "bar:char *";
+}
+static char *bar(Foo *) {
+ return (char*) "bar:Foo *";
+}
+static char *bar(Bar *) {
+ return (char *) "bar:Bar *";
+}
+static char *bar(void *) {
+ return (char *) "bar:void *";
+}
+};
+
+
+bool fbool(bool b) {
+ return b;
+}
+
+int fbool(int b) {
+ return b;
+}
+
+char *fint(int) {
+ return (char*) "fint:int";
+}
+
+char *fdouble(double) {
+ return (char*) "fdouble:double";
+}
+
+char *num(int) {
+ return (char*) "num:int";
+}
+char *num(double) {
+ return (char*) "num:double";
+}
+
+char *fid(int, int) {
+ return (char*) "fid:intint";
+}
+char *fid(int, double) {
+ return (char*) "fid:intdouble";
+}
+
+char *fid(double, int) {
+ return (char*) "fid:doubleint";
+}
+
+char *fid(double, double) {
+ return (char*) "fid:doubledouble";
+}
+
+%}
+
+%inline %{
+unsigned long long ull() { return 0ULL; }
+unsigned long long ull(unsigned long long ull) { return ull; }
+long long ll() { return 0LL; }
+long long ll(long long ull) { return ull; }
+%}
+
+%include cmalloc.i
+%malloc(void);
+%free(void);
+
+#endif
+
+
+%inline {
+ class ClassA
+ {
+ public:
+ ClassA() {}
+ int method1( ) {return 0;}
+ int method1( int arg1 ) {return arg1;}
+ protected:
+ int method1( int arg1, int arg2 ) {return arg1 + arg2;}
+
+ };
+}
+
+#ifdef SWIGPYTHON
+%inline
+{
+ class Graph {
+ public:
+ int val;
+ Graph(int i) : val(i) {};
+ };
+}
+
+%extend Graph {
+ Graph(PyObject* p) { return new Graph(123);}
+}
+
+#endif
diff --git a/trunk/Examples/test-suite/overload_subtype.i b/trunk/Examples/test-suite/overload_subtype.i
new file mode 100644
index 000000000..3d9645d7b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/overload_template.i b/trunk/Examples/test-suite/overload_template.i
new file mode 100644
index 000000000..dee6ab91e
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_template.i
@@ -0,0 +1,210 @@
+%module overload_template
+
+#ifdef SWIGLUA
+// lua only has one numeric type, so most of the overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) maximum;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) specialization;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) overload;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) space::nsoverload;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fooT;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) barT;
+#endif
+
+%inline %{
+
+int foo() {
+ return 3;
+}
+
+template <class T>
+ int foo(T x) {
+ return (int)x;
+ }
+
+template<class T>
+ T maximum(T a, T b) { return (a > b) ? a : b; }
+%}
+
+
+%template(foo) foo<int>;
+%template(foo) foo<double>;
+
+%template(maximum) maximum<int>;
+%template(maximum) maximum<double>;
+
+// Mix template overloading with plain function overload
+// Mix 1
+%inline %{
+ int mix1(const char* msg) { return 101; }
+ template<typename T> int mix1(T t, const T& tt) { return 102; }
+ template<typename T> int mix1(T t) { return 103; }
+%}
+%template(mix1) mix1<double>;
+
+// Mix 2
+%inline %{
+ template<typename T> int mix2(T t, const T& tt) { return 102; }
+ int mix2(const char* msg) { return 101; }
+ template<typename T> int mix2(T t) { return 103; }
+%}
+%template(mix2) mix2<double>;
+
+// Mix 3
+%inline %{
+ template<typename T> int mix3(T t, const T& tt) { return 102; }
+ template<typename T> int mix3(T t) { return 103; }
+ int mix3(const char* msg) { return 101; }
+%}
+%template(mix3) mix3<double>;
+
+
+// overloaded by number of templated parameters
+// Combination 1
+%inline %{
+template<typename T> int overtparams1(T t) { return 10; }
+template<typename T, typename U> int overtparams1(T t, U u) { return 20; }
+%}
+
+%template(overtparams1) overtparams1<int>;
+%template(overtparams1) overtparams1<double, int>;
+
+
+// Combination 2
+%inline %{
+template<typename T> int overtparams2(T t) { return 30; }
+template<typename T, typename U> int overtparams2(T t, U u) { return 40; }
+%}
+
+%template(overtparams2) overtparams2<double, int>;
+
+
+// Combination 3
+%inline %{
+template<typename T> int overloaded(T t) { return 50; }
+int overloaded() { return 60; }
+template<typename T, typename U> int overloaded(T t, U u) { return 70; }
+%}
+
+%template(overloaded) overloaded<double, int>;
+
+// Combination 4
+%inline %{
+int overloadedagain(const char* msg) { return 80; }
+template<typename T> int overloadedagain() { return 90; }
+template<typename T, typename U> int overloadedagain(T t, U u) { return 100; }
+%}
+
+%template(overloadedagain) overloadedagain<double>;
+
+// simple specialization
+%inline %{
+template<typename T> void xyz() {}
+template<> void xyz<double>() {}
+void xyz() {}
+%}
+
+// We can have xyz(); xyz<double>(); xyz<int>(); in C++, but can't have this type of overloading in target language, so we need to do some renaming
+%template(xyz_double) xyz<double>;
+%template(xyz_int) xyz<int>;
+
+
+// specializations
+%inline %{
+template<typename T> int specialization(T t) { return 200; }
+template<typename T, typename U> int specialization(T t, U u) { return 201; }
+template<> int specialization(int t) { return 202; }
+template<> int specialization<double>(double t) { return 203; }
+template<> int specialization(int t, int u) { return 204; }
+template<> int specialization<double,double>(double t, double u) { return 205; }
+%}
+
+%template(specialization) specialization<int>;
+%template(specialization) specialization<double>;
+%template(specialization) specialization<int, int>;
+%template(specialization) specialization<double, double>;
+%template(specialization) specialization<const char *, const char *>;
+
+
+// a bit of everything
+%inline %{
+int overload(const char *c) { return 0; }
+template<typename T> int overload(T t) { return 10; }
+template<typename T> int overload(T t, const T &tref) { return 20; }
+template<typename T> int overload(T t, const char *c) { return 30; }
+template<> int overload<double>(double t, const char *c) { return 40; }
+int overload() { return 50; }
+
+class Klass {};
+%}
+
+%template(overload) overload<int>;
+%template(overload) overload<Klass>;
+%template(overload) overload<double>;
+
+
+// everything put in a namespace
+%inline %{
+namespace space {
+ int nsoverload(const char *c) { return 1000; }
+ template<typename T> int nsoverload(T t) { return 1010; }
+ template<typename T> int nsoverload(T t, const T &tref) { return 1020; }
+ template<typename T> int nsoverload(T t, const char *c) { return 1030; }
+ template<> int nsoverload<double>(double t, const char *c) { return 1040; }
+ int nsoverload() { return 1050; }
+}
+%}
+
+%template(nsoverload) space::nsoverload<int>;
+%template(nsoverload) space::nsoverload<Klass>;
+%template(nsoverload) space::nsoverload<double>;
+
+
+%inline %{
+ namespace space
+ {
+ template <class T>
+ struct Foo
+ {
+ void bar(T t1) { }
+ void bar(T t1, T t2) { }
+ void bar(int a, int b, int c) { }
+ };
+ struct A
+ {
+ template <class Y>
+ static void fooT(Y y) { }
+
+ };
+
+ }
+ template <class T>
+ struct Bar
+ {
+ void foo(T t1) { }
+ void foo(T t1, T t2) { }
+ void foo(int a, int b, int c) { }
+ template <class Y>
+ void fooT(Y y) { }
+ };
+
+
+ struct B
+ {
+ template <class Y>
+ void barT(Y y) { }
+
+ };
+
+%}
+
+
+%template(Bar_d) Bar<double>;
+%template(Foo_d) space::Foo<double>;
+%template(foo) space::A::fooT<double>;
+%template(foo) space::A::fooT<int>;
+%template(foo) space::A::fooT<char>;
+
+%template(foo) B::barT<double>;
+%template(foo) B::barT<int>;
+%template(foo) B::barT<char>;
diff --git a/trunk/Examples/test-suite/overload_template_fast.i b/trunk/Examples/test-suite/overload_template_fast.i
new file mode 100644
index 000000000..83d5accaf
--- /dev/null
+++ b/trunk/Examples/test-suite/overload_template_fast.i
@@ -0,0 +1,5 @@
+%module overload_template_fast
+
+%fastdispatch;
+
+%include overload_template.i
diff --git a/trunk/Examples/test-suite/packageoption.h b/trunk/Examples/test-suite/packageoption.h
new file mode 100644
index 000000000..82f29d1c7
--- /dev/null
+++ b/trunk/Examples/test-suite/packageoption.h
@@ -0,0 +1,6 @@
+struct Base {
+ virtual int vmethod() { return 1; }
+ int basemethod() { return 1; }
+ virtual ~Base() {}
+};
+
diff --git a/trunk/Examples/test-suite/packageoption.list b/trunk/Examples/test-suite/packageoption.list
new file mode 100644
index 000000000..da125c2a3
--- /dev/null
+++ b/trunk/Examples/test-suite/packageoption.list
@@ -0,0 +1,3 @@
+packageoption_a
+packageoption_b
+packageoption_c
diff --git a/trunk/Examples/test-suite/packageoption_a.i b/trunk/Examples/test-suite/packageoption_a.i
new file mode 100644
index 000000000..b28278282
--- /dev/null
+++ b/trunk/Examples/test-suite/packageoption_a.i
@@ -0,0 +1,16 @@
+%module(package="CommonPackage") "packageoption_a";
+
+%inline %{
+class A
+{
+ public:
+ int testInt() { return 2;}
+};
+%}
+
+%{
+#include "packageoption.h"
+%}
+
+%include "packageoption.h"
+
diff --git a/trunk/Examples/test-suite/packageoption_b.i b/trunk/Examples/test-suite/packageoption_b.i
new file mode 100644
index 000000000..40a44be14
--- /dev/null
+++ b/trunk/Examples/test-suite/packageoption_b.i
@@ -0,0 +1,10 @@
+%module(package="CommonPackage") "packageoption_b";
+
+%inline %{
+class B
+{
+ public:
+ int testInt() { return 4; }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/packageoption_c.i b/trunk/Examples/test-suite/packageoption_c.i
new file mode 100644
index 000000000..f43e47002
--- /dev/null
+++ b/trunk/Examples/test-suite/packageoption_c.i
@@ -0,0 +1,13 @@
+%module(package="PackageC") "packageoption_c";
+
+%import "packageoption_a.i"
+
+%inline %{
+#include "packageoption.h"
+
+struct Derived : Base {
+ virtual int vmethod() { return 2; }
+ virtual ~Derived() {}
+};
+
+%}
diff --git a/trunk/Examples/test-suite/perl5/Makefile.in b/trunk/Examples/test-suite/perl5/Makefile.in
new file mode 100644
index 000000000..67eaf5c9a
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/Makefile.in
@@ -0,0 +1,61 @@
+#######################################################################
+# Makefile for perl5 test-suite
+#######################################################################
+
+LANGUAGE = perl5
+PERL = @PERL@
+SCRIPTSUFFIX = _runme.pl
+TEST_RUNNER = run-perl-test.pl
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+CPP_TEST_CASES += \
+ primitive_types \
+ li_cdata \
+ li_cstring \
+ li_cdata_carrays \
+ li_reference \
+
+C_TEST_CASES += \
+ li_cdata \
+ li_cstring \
+ li_cdata_carrays \
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.pl appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: remove the generated .pm file
+%.clean:
+ @rm -f $*.pm;
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile perl5_clean
diff --git a/trunk/Examples/test-suite/perl5/README b/trunk/Examples/test-suite/perl5/README
new file mode 100644
index 000000000..14eb5277e
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/README
@@ -0,0 +1,32 @@
+See ../README for common README file.
+
+Any testcases which have _runme.pl appended after the testcase name will be detected and run.
+
+Test::More Support
+==
+
+Test::More and Test::Harness are two of the standard perl test harness
+tools. Support has been added for these modules as of 1.3.28. If
+adding a new test to this suite, please use Test::More.
+
+Currently converted test cases include:
+
+* operator_overload
+* operator_overload_break
+* package
+* overload_simple
+* apply_strings
+* char_strings
+* default_args
+* enum_thorough
+* global_vars
+* import_nomodule
+* inherit
+* li_cdata_carrays
+* li_std_string
+* member_pointer
+* multiple_inheritance
+* primitive_ref
+* template_default_arg
+* unions
+* voidtest
diff --git a/trunk/Examples/test-suite/perl5/Test/Builder.pm b/trunk/Examples/test-suite/perl5/Test/Builder.pm
new file mode 100644
index 000000000..9f6a3a43d
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/Test/Builder.pm
@@ -0,0 +1,1591 @@
+package Test::Builder;
+
+use 5.004;
+
+# $^C was only introduced in 5.005-ish. We do this to prevent
+# use of uninitialized value warnings in older perls.
+$^C ||= 0;
+
+use strict;
+use vars qw($VERSION);
+$VERSION = '0.22';
+$VERSION = eval $VERSION; # make the alpha version come out as a number
+
+# Make Test::Builder thread-safe for ithreads.
+BEGIN {
+ use Config;
+ # Load threads::shared when threads are turned on
+ if( $] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) {
+ require threads::shared;
+
+ # Hack around YET ANOTHER threads::shared bug. It would
+ # occassionally forget the contents of the variable when sharing it.
+ # So we first copy the data, then share, then put our copy back.
+ *share = sub (\[$@%]) {
+ my $type = ref $_[0];
+ my $data;
+
+ if( $type eq 'HASH' ) {
+ %$data = %{$_[0]};
+ }
+ elsif( $type eq 'ARRAY' ) {
+ @$data = @{$_[0]};
+ }
+ elsif( $type eq 'SCALAR' ) {
+ $$data = ${$_[0]};
+ }
+ else {
+ die "Unknown type: ".$type;
+ }
+
+ $_[0] = &threads::shared::share($_[0]);
+
+ if( $type eq 'HASH' ) {
+ %{$_[0]} = %$data;
+ }
+ elsif( $type eq 'ARRAY' ) {
+ @{$_[0]} = @$data;
+ }
+ elsif( $type eq 'SCALAR' ) {
+ ${$_[0]} = $$data;
+ }
+ else {
+ die "Unknown type: ".$type;
+ }
+
+ return $_[0];
+ };
+ }
+ # 5.8.0's threads::shared is busted when threads are off.
+ # We emulate it here.
+ else {
+ *share = sub { return $_[0] };
+ *lock = sub { 0 };
+ }
+}
+
+
+=head1 NAME
+
+Test::Builder - Backend for building test libraries
+
+=head1 SYNOPSIS
+
+ package My::Test::Module;
+ use Test::Builder;
+ require Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(ok);
+
+ my $Test = Test::Builder->new;
+ $Test->output('my_logfile');
+
+ sub import {
+ my($self) = shift;
+ my $pack = caller;
+
+ $Test->exported_to($pack);
+ $Test->plan(@_);
+
+ $self->export_to_level(1, $self, 'ok');
+ }
+
+ sub ok {
+ my($test, $name) = @_;
+
+ $Test->ok($test, $name);
+ }
+
+
+=head1 DESCRIPTION
+
+Test::Simple and Test::More have proven to be popular testing modules,
+but they're not always flexible enough. Test::Builder provides the a
+building block upon which to write your own test libraries I<which can
+work together>.
+
+=head2 Construction
+
+=over 4
+
+=item B<new>
+
+ my $Test = Test::Builder->new;
+
+Returns a Test::Builder object representing the current state of the
+test.
+
+Since you only run one test per program, there is B<one and only one>
+Test::Builder object. No matter how many times you call new(), you're
+getting the same object. (This is called a singleton).
+
+=cut
+
+my $Test = Test::Builder->new;
+sub new {
+ my($class) = shift;
+ $Test ||= bless ['Move along, nothing to see here'], $class;
+ return $Test;
+}
+
+=item B<reset>
+
+ $Test->reset;
+
+Reinitializes the Test::Builder singleton to its original state.
+Mostly useful for tests run in persistent environments where the same
+test might be run multiple times in the same process.
+
+=cut
+
+my $Test_Died;
+my $Have_Plan;
+my $No_Plan;
+my $Curr_Test; share($Curr_Test);
+use vars qw($Level);
+my $Original_Pid;
+my @Test_Results; share(@Test_Results);
+
+my $Exported_To;
+my $Expected_Tests;
+
+my $Skip_All;
+
+my $Use_Nums;
+
+my($No_Header, $No_Ending);
+
+$Test->reset;
+
+sub reset {
+ my ($self) = @_;
+
+ $Test_Died = 0;
+ $Have_Plan = 0;
+ $No_Plan = 0;
+ $Curr_Test = 0;
+ $Level = 1;
+ $Original_Pid = $$;
+ @Test_Results = ();
+
+ $Exported_To = undef;
+ $Expected_Tests = 0;
+
+ $Skip_All = 0;
+
+ $Use_Nums = 1;
+
+ ($No_Header, $No_Ending) = (0,0);
+
+ $self->_dup_stdhandles unless $^C;
+
+ return undef;
+}
+
+=back
+
+=head2 Setting up tests
+
+These methods are for setting up tests and declaring how many there
+are. You usually only want to call one of these methods.
+
+=over 4
+
+=item B<exported_to>
+
+ my $pack = $Test->exported_to;
+ $Test->exported_to($pack);
+
+Tells Test::Builder what package you exported your functions to.
+This is important for getting TODO tests right.
+
+=cut
+
+sub exported_to {
+ my($self, $pack) = @_;
+
+ if( defined $pack ) {
+ $Exported_To = $pack;
+ }
+ return $Exported_To;
+}
+
+=item B<plan>
+
+ $Test->plan('no_plan');
+ $Test->plan( skip_all => $reason );
+ $Test->plan( tests => $num_tests );
+
+A convenient way to set up your tests. Call this and Test::Builder
+will print the appropriate headers and take the appropriate actions.
+
+If you call plan(), don't call any of the other methods below.
+
+=cut
+
+sub plan {
+ my($self, $cmd, $arg) = @_;
+
+ return unless $cmd;
+
+ if( $Have_Plan ) {
+ die sprintf "You tried to plan twice! Second plan at %s line %d\n",
+ ($self->caller)[1,2];
+ }
+
+ if( $cmd eq 'no_plan' ) {
+ $self->no_plan;
+ }
+ elsif( $cmd eq 'skip_all' ) {
+ return $self->skip_all($arg);
+ }
+ elsif( $cmd eq 'tests' ) {
+ if( $arg ) {
+ return $self->expected_tests($arg);
+ }
+ elsif( !defined $arg ) {
+ die "Got an undefined number of tests. Looks like you tried to ".
+ "say how many tests you plan to run but made a mistake.\n";
+ }
+ elsif( !$arg ) {
+ die "You said to run 0 tests! You've got to run something.\n";
+ }
+ }
+ else {
+ require Carp;
+ my @args = grep { defined } ($cmd, $arg);
+ Carp::croak("plan() doesn't understand @args");
+ }
+
+ return 1;
+}
+
+=item B<expected_tests>
+
+ my $max = $Test->expected_tests;
+ $Test->expected_tests($max);
+
+Gets/sets the # of tests we expect this test to run and prints out
+the appropriate headers.
+
+=cut
+
+sub expected_tests {
+ my $self = shift;
+ my($max) = @_;
+
+ if( @_ ) {
+ die "Number of tests must be a postive integer. You gave it '$max'.\n"
+ unless $max =~ /^\+?\d+$/ and $max > 0;
+
+ $Expected_Tests = $max;
+ $Have_Plan = 1;
+
+ $self->_print("1..$max\n") unless $self->no_header;
+ }
+ return $Expected_Tests;
+}
+
+
+=item B<no_plan>
+
+ $Test->no_plan;
+
+Declares that this test will run an indeterminate # of tests.
+
+=cut
+
+sub no_plan {
+ $No_Plan = 1;
+ $Have_Plan = 1;
+}
+
+=item B<has_plan>
+
+ $plan = $Test->has_plan
+
+Find out whether a plan has been defined. $plan is either C<undef> (no plan has been set), C<no_plan> (indeterminate # of tests) or an integer (the number of expected tests).
+
+=cut
+
+sub has_plan {
+ return($Expected_Tests) if $Expected_Tests;
+ return('no_plan') if $No_Plan;
+ return(undef);
+};
+
+
+=item B<skip_all>
+
+ $Test->skip_all;
+ $Test->skip_all($reason);
+
+Skips all the tests, using the given $reason. Exits immediately with 0.
+
+=cut
+
+sub skip_all {
+ my($self, $reason) = @_;
+
+ my $out = "1..0";
+ $out .= " # Skip $reason" if $reason;
+ $out .= "\n";
+
+ $Skip_All = 1;
+
+ $self->_print($out) unless $self->no_header;
+ exit(0);
+}
+
+=back
+
+=head2 Running tests
+
+These actually run the tests, analogous to the functions in
+Test::More.
+
+$name is always optional.
+
+=over 4
+
+=item B<ok>
+
+ $Test->ok($test, $name);
+
+Your basic test. Pass if $test is true, fail if $test is false. Just
+like Test::Simple's ok().
+
+=cut
+
+sub ok {
+ my($self, $test, $name) = @_;
+
+ # $test might contain an object which we don't want to accidentally
+ # store, so we turn it into a boolean.
+ $test = $test ? 1 : 0;
+
+ unless( $Have_Plan ) {
+ require Carp;
+ Carp::croak("You tried to run a test without a plan! Gotta have a plan.");
+ }
+
+ lock $Curr_Test;
+ $Curr_Test++;
+
+ # In case $name is a string overloaded object, force it to stringify.
+ $self->_unoverload(\$name);
+
+ $self->diag(<<ERR) if defined $name and $name =~ /^[\d\s]+$/;
+ You named your test '$name'. You shouldn't use numbers for your test names.
+ Very confusing.
+ERR
+
+ my($pack, $file, $line) = $self->caller;
+
+ my $todo = $self->todo($pack);
+ $self->_unoverload(\$todo);
+
+ my $out;
+ my $result = &share({});
+
+ unless( $test ) {
+ $out .= "not ";
+ @$result{ 'ok', 'actual_ok' } = ( ( $todo ? 1 : 0 ), 0 );
+ }
+ else {
+ @$result{ 'ok', 'actual_ok' } = ( 1, $test );
+ }
+
+ $out .= "ok";
+ $out .= " $Curr_Test" if $self->use_numbers;
+
+ if( defined $name ) {
+ $name =~ s|#|\\#|g; # # in a name can confuse Test::Harness.
+ $out .= " - $name";
+ $result->{name} = $name;
+ }
+ else {
+ $result->{name} = '';
+ }
+
+ if( $todo ) {
+ $out .= " # TODO $todo";
+ $result->{reason} = $todo;
+ $result->{type} = 'todo';
+ }
+ else {
+ $result->{reason} = '';
+ $result->{type} = '';
+ }
+
+ $Test_Results[$Curr_Test-1] = $result;
+ $out .= "\n";
+
+ $self->_print($out);
+
+ unless( $test ) {
+ my $msg = $todo ? "Failed (TODO)" : "Failed";
+ $self->_print_diag("\n") if $ENV{HARNESS_ACTIVE};
+ $self->diag(" $msg test ($file at line $line)\n");
+ }
+
+ return $test ? 1 : 0;
+}
+
+
+sub _unoverload {
+ my $self = shift;
+
+ local($@,$!);
+
+ eval { require overload } || return;
+
+ foreach my $thing (@_) {
+ eval {
+ if( defined $$thing ) {
+ if( my $string_meth = overload::Method($$thing, '""') ) {
+ $$thing = $$thing->$string_meth();
+ }
+ }
+ };
+ }
+}
+
+
+=item B<is_eq>
+
+ $Test->is_eq($got, $expected, $name);
+
+Like Test::More's is(). Checks if $got eq $expected. This is the
+string version.
+
+=item B<is_num>
+
+ $Test->is_num($got, $expected, $name);
+
+Like Test::More's is(). Checks if $got == $expected. This is the
+numeric version.
+
+=cut
+
+sub is_eq {
+ my($self, $got, $expect, $name) = @_;
+ local $Level = $Level + 1;
+
+ if( !defined $got || !defined $expect ) {
+ # undef only matches undef and nothing else
+ my $test = !defined $got && !defined $expect;
+
+ $self->ok($test, $name);
+ $self->_is_diag($got, 'eq', $expect) unless $test;
+ return $test;
+ }
+
+ return $self->cmp_ok($got, 'eq', $expect, $name);
+}
+
+sub is_num {
+ my($self, $got, $expect, $name) = @_;
+ local $Level = $Level + 1;
+
+ if( !defined $got || !defined $expect ) {
+ # undef only matches undef and nothing else
+ my $test = !defined $got && !defined $expect;
+
+ $self->ok($test, $name);
+ $self->_is_diag($got, '==', $expect) unless $test;
+ return $test;
+ }
+
+ return $self->cmp_ok($got, '==', $expect, $name);
+}
+
+sub _is_diag {
+ my($self, $got, $type, $expect) = @_;
+
+ foreach my $val (\$got, \$expect) {
+ if( defined $$val ) {
+ if( $type eq 'eq' ) {
+ # quote and force string context
+ $$val = "'$$val'"
+ }
+ else {
+ # force numeric context
+ $$val = $$val+0;
+ }
+ }
+ else {
+ $$val = 'undef';
+ }
+ }
+
+ return $self->diag(sprintf <<DIAGNOSTIC, $got, $expect);
+ got: %s
+ expected: %s
+DIAGNOSTIC
+
+}
+
+=item B<isnt_eq>
+
+ $Test->isnt_eq($got, $dont_expect, $name);
+
+Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
+the string version.
+
+=item B<isnt_num>
+
+ $Test->is_num($got, $dont_expect, $name);
+
+Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
+the numeric version.
+
+=cut
+
+sub isnt_eq {
+ my($self, $got, $dont_expect, $name) = @_;
+ local $Level = $Level + 1;
+
+ if( !defined $got || !defined $dont_expect ) {
+ # undef only matches undef and nothing else
+ my $test = defined $got || defined $dont_expect;
+
+ $self->ok($test, $name);
+ $self->_cmp_diag($got, 'ne', $dont_expect) unless $test;
+ return $test;
+ }
+
+ return $self->cmp_ok($got, 'ne', $dont_expect, $name);
+}
+
+sub isnt_num {
+ my($self, $got, $dont_expect, $name) = @_;
+ local $Level = $Level + 1;
+
+ if( !defined $got || !defined $dont_expect ) {
+ # undef only matches undef and nothing else
+ my $test = defined $got || defined $dont_expect;
+
+ $self->ok($test, $name);
+ $self->_cmp_diag($got, '!=', $dont_expect) unless $test;
+ return $test;
+ }
+
+ return $self->cmp_ok($got, '!=', $dont_expect, $name);
+}
+
+
+=item B<like>
+
+ $Test->like($this, qr/$regex/, $name);
+ $Test->like($this, '/$regex/', $name);
+
+Like Test::More's like(). Checks if $this matches the given $regex.
+
+You'll want to avoid qr// if you want your tests to work before 5.005.
+
+=item B<unlike>
+
+ $Test->unlike($this, qr/$regex/, $name);
+ $Test->unlike($this, '/$regex/', $name);
+
+Like Test::More's unlike(). Checks if $this B<does not match> the
+given $regex.
+
+=cut
+
+sub like {
+ my($self, $this, $regex, $name) = @_;
+
+ local $Level = $Level + 1;
+ $self->_regex_ok($this, $regex, '=~', $name);
+}
+
+sub unlike {
+ my($self, $this, $regex, $name) = @_;
+
+ local $Level = $Level + 1;
+ $self->_regex_ok($this, $regex, '!~', $name);
+}
+
+=item B<maybe_regex>
+
+ $Test->maybe_regex(qr/$regex/);
+ $Test->maybe_regex('/$regex/');
+
+Convenience method for building testing functions that take regular
+expressions as arguments, but need to work before perl 5.005.
+
+Takes a quoted regular expression produced by qr//, or a string
+representing a regular expression.
+
+Returns a Perl value which may be used instead of the corresponding
+regular expression, or undef if it's argument is not recognised.
+
+For example, a version of like(), sans the useful diagnostic messages,
+could be written as:
+
+ sub laconic_like {
+ my ($self, $this, $regex, $name) = @_;
+ my $usable_regex = $self->maybe_regex($regex);
+ die "expecting regex, found '$regex'\n"
+ unless $usable_regex;
+ $self->ok($this =~ m/$usable_regex/, $name);
+ }
+
+=cut
+
+
+sub maybe_regex {
+ my ($self, $regex) = @_;
+ my $usable_regex = undef;
+
+ return $usable_regex unless defined $regex;
+
+ my($re, $opts);
+
+ # Check for qr/foo/
+ if( ref $regex eq 'Regexp' ) {
+ $usable_regex = $regex;
+ }
+ # Check for '/foo/' or 'm,foo,'
+ elsif( ($re, $opts) = $regex =~ m{^ /(.*)/ (\w*) $ }sx or
+ (undef, $re, $opts) = $regex =~ m,^ m([^\w\s]) (.+) \1 (\w*) $,sx
+ )
+ {
+ $usable_regex = length $opts ? "(?$opts)$re" : $re;
+ }
+
+ return $usable_regex;
+};
+
+sub _regex_ok {
+ my($self, $this, $regex, $cmp, $name) = @_;
+
+ local $Level = $Level + 1;
+
+ my $ok = 0;
+ my $usable_regex = $self->maybe_regex($regex);
+ unless (defined $usable_regex) {
+ $ok = $self->ok( 0, $name );
+ $self->diag(" '$regex' doesn't look much like a regex to me.");
+ return $ok;
+ }
+
+ {
+ local $^W = 0;
+ my $test = $this =~ /$usable_regex/ ? 1 : 0;
+ $test = !$test if $cmp eq '!~';
+ $ok = $self->ok( $test, $name );
+ }
+
+ unless( $ok ) {
+ $this = defined $this ? "'$this'" : 'undef';
+ my $match = $cmp eq '=~' ? "doesn't match" : "matches";
+ $self->diag(sprintf <<DIAGNOSTIC, $this, $match, $regex);
+ %s
+ %13s '%s'
+DIAGNOSTIC
+
+ }
+
+ return $ok;
+}
+
+=item B<cmp_ok>
+
+ $Test->cmp_ok($this, $type, $that, $name);
+
+Works just like Test::More's cmp_ok().
+
+ $Test->cmp_ok($big_num, '!=', $other_big_num);
+
+=cut
+
+sub cmp_ok {
+ my($self, $got, $type, $expect, $name) = @_;
+
+ my $test;
+ {
+ local $^W = 0;
+ local($@,$!); # don't interfere with $@
+ # eval() sometimes resets $!
+ $test = eval "\$got $type \$expect";
+ }
+ local $Level = $Level + 1;
+ my $ok = $self->ok($test, $name);
+
+ unless( $ok ) {
+ if( $type =~ /^(eq|==)$/ ) {
+ $self->_is_diag($got, $type, $expect);
+ }
+ else {
+ $self->_cmp_diag($got, $type, $expect);
+ }
+ }
+ return $ok;
+}
+
+sub _cmp_diag {
+ my($self, $got, $type, $expect) = @_;
+
+ $got = defined $got ? "'$got'" : 'undef';
+ $expect = defined $expect ? "'$expect'" : 'undef';
+ return $self->diag(sprintf <<DIAGNOSTIC, $got, $type, $expect);
+ %s
+ %s
+ %s
+DIAGNOSTIC
+}
+
+=item B<BAILOUT>
+
+ $Test->BAILOUT($reason);
+
+Indicates to the Test::Harness that things are going so badly all
+testing should terminate. This includes running any additional test
+scripts.
+
+It will exit with 255.
+
+=cut
+
+sub BAILOUT {
+ my($self, $reason) = @_;
+
+ $self->_print("Bail out! $reason");
+ exit 255;
+}
+
+=item B<skip>
+
+ $Test->skip;
+ $Test->skip($why);
+
+Skips the current test, reporting $why.
+
+=cut
+
+sub skip {
+ my($self, $why) = @_;
+ $why ||= '';
+ $self->_unoverload(\$why);
+
+ unless( $Have_Plan ) {
+ require Carp;
+ Carp::croak("You tried to run tests without a plan! Gotta have a plan.");
+ }
+
+ lock($Curr_Test);
+ $Curr_Test++;
+
+ $Test_Results[$Curr_Test-1] = &share({
+ 'ok' => 1,
+ actual_ok => 1,
+ name => '',
+ type => 'skip',
+ reason => $why,
+ });
+
+ my $out = "ok";
+ $out .= " $Curr_Test" if $self->use_numbers;
+ $out .= " # skip";
+ $out .= " $why" if length $why;
+ $out .= "\n";
+
+ $Test->_print($out);
+
+ return 1;
+}
+
+
+=item B<todo_skip>
+
+ $Test->todo_skip;
+ $Test->todo_skip($why);
+
+Like skip(), only it will declare the test as failing and TODO. Similar
+to
+
+ print "not ok $tnum # TODO $why\n";
+
+=cut
+
+sub todo_skip {
+ my($self, $why) = @_;
+ $why ||= '';
+
+ unless( $Have_Plan ) {
+ require Carp;
+ Carp::croak("You tried to run tests without a plan! Gotta have a plan.");
+ }
+
+ lock($Curr_Test);
+ $Curr_Test++;
+
+ $Test_Results[$Curr_Test-1] = &share({
+ 'ok' => 1,
+ actual_ok => 0,
+ name => '',
+ type => 'todo_skip',
+ reason => $why,
+ });
+
+ my $out = "not ok";
+ $out .= " $Curr_Test" if $self->use_numbers;
+ $out .= " # TODO & SKIP $why\n";
+
+ $Test->_print($out);
+
+ return 1;
+}
+
+
+=begin _unimplemented
+
+=item B<skip_rest>
+
+ $Test->skip_rest;
+ $Test->skip_rest($reason);
+
+Like skip(), only it skips all the rest of the tests you plan to run
+and terminates the test.
+
+If you're running under no_plan, it skips once and terminates the
+test.
+
+=end _unimplemented
+
+=back
+
+
+=head2 Test style
+
+=over 4
+
+=item B<level>
+
+ $Test->level($how_high);
+
+How far up the call stack should $Test look when reporting where the
+test failed.
+
+Defaults to 1.
+
+Setting $Test::Builder::Level overrides. This is typically useful
+localized:
+
+ {
+ local $Test::Builder::Level = 2;
+ $Test->ok($test);
+ }
+
+=cut
+
+sub level {
+ my($self, $level) = @_;
+
+ if( defined $level ) {
+ $Level = $level;
+ }
+ return $Level;
+}
+
+
+=item B<use_numbers>
+
+ $Test->use_numbers($on_or_off);
+
+Whether or not the test should output numbers. That is, this if true:
+
+ ok 1
+ ok 2
+ ok 3
+
+or this if false
+
+ ok
+ ok
+ ok
+
+Most useful when you can't depend on the test output order, such as
+when threads or forking is involved.
+
+Test::Harness will accept either, but avoid mixing the two styles.
+
+Defaults to on.
+
+=cut
+
+sub use_numbers {
+ my($self, $use_nums) = @_;
+
+ if( defined $use_nums ) {
+ $Use_Nums = $use_nums;
+ }
+ return $Use_Nums;
+}
+
+=item B<no_header>
+
+ $Test->no_header($no_header);
+
+If set to true, no "1..N" header will be printed.
+
+=item B<no_ending>
+
+ $Test->no_ending($no_ending);
+
+Normally, Test::Builder does some extra diagnostics when the test
+ends. It also changes the exit code as described below.
+
+If this is true, none of that will be done.
+
+=cut
+
+sub no_header {
+ my($self, $no_header) = @_;
+
+ if( defined $no_header ) {
+ $No_Header = $no_header;
+ }
+ return $No_Header;
+}
+
+sub no_ending {
+ my($self, $no_ending) = @_;
+
+ if( defined $no_ending ) {
+ $No_Ending = $no_ending;
+ }
+ return $No_Ending;
+}
+
+
+=back
+
+=head2 Output
+
+Controlling where the test output goes.
+
+It's ok for your test to change where STDOUT and STDERR point to,
+Test::Builder's default output settings will not be affected.
+
+=over 4
+
+=item B<diag>
+
+ $Test->diag(@msgs);
+
+Prints out the given @msgs. Like C<print>, arguments are simply
+appended together.
+
+Normally, it uses the failure_output() handle, but if this is for a
+TODO test, the todo_output() handle is used.
+
+Output will be indented and marked with a # so as not to interfere
+with test output. A newline will be put on the end if there isn't one
+already.
+
+We encourage using this rather than calling print directly.
+
+Returns false. Why? Because diag() is often used in conjunction with
+a failing test (C<ok() || diag()>) it "passes through" the failure.
+
+ return ok(...) || diag(...);
+
+=for blame transfer
+Mark Fowler <mark@twoshortplanks.com>
+
+=cut
+
+sub diag {
+ my($self, @msgs) = @_;
+ return unless @msgs;
+
+ # Prevent printing headers when compiling (i.e. -c)
+ return if $^C;
+
+ # Smash args together like print does.
+ # Convert undef to 'undef' so its readable.
+ my $msg = join '', map { defined($_) ? $_ : 'undef' } @msgs;
+
+ # Escape each line with a #.
+ $msg =~ s/^/# /gm;
+
+ # Stick a newline on the end if it needs it.
+ $msg .= "\n" unless $msg =~ /\n\Z/;
+
+ local $Level = $Level + 1;
+ $self->_print_diag($msg);
+
+ return 0;
+}
+
+=begin _private
+
+=item B<_print>
+
+ $Test->_print(@msgs);
+
+Prints to the output() filehandle.
+
+=end _private
+
+=cut
+
+sub _print {
+ my($self, @msgs) = @_;
+
+ # Prevent printing headers when only compiling. Mostly for when
+ # tests are deparsed with B::Deparse
+ return if $^C;
+
+ my $msg = join '', @msgs;
+
+ local($\, $", $,) = (undef, ' ', '');
+ my $fh = $self->output;
+
+ # Escape each line after the first with a # so we don't
+ # confuse Test::Harness.
+ $msg =~ s/\n(.)/\n# $1/sg;
+
+ # Stick a newline on the end if it needs it.
+ $msg .= "\n" unless $msg =~ /\n\Z/;
+
+ print $fh $msg;
+}
+
+
+=item B<_print_diag>
+
+ $Test->_print_diag(@msg);
+
+Like _print, but prints to the current diagnostic filehandle.
+
+=cut
+
+sub _print_diag {
+ my $self = shift;
+
+ local($\, $", $,) = (undef, ' ', '');
+ my $fh = $self->todo ? $self->todo_output : $self->failure_output;
+ print $fh @_;
+}
+
+=item B<output>
+
+ $Test->output($fh);
+ $Test->output($file);
+
+Where normal "ok/not ok" test output should go.
+
+Defaults to STDOUT.
+
+=item B<failure_output>
+
+ $Test->failure_output($fh);
+ $Test->failure_output($file);
+
+Where diagnostic output on test failures and diag() should go.
+
+Defaults to STDERR.
+
+=item B<todo_output>
+
+ $Test->todo_output($fh);
+ $Test->todo_output($file);
+
+Where diagnostics about todo test failures and diag() should go.
+
+Defaults to STDOUT.
+
+=cut
+
+my($Out_FH, $Fail_FH, $Todo_FH);
+sub output {
+ my($self, $fh) = @_;
+
+ if( defined $fh ) {
+ $Out_FH = _new_fh($fh);
+ }
+ return $Out_FH;
+}
+
+sub failure_output {
+ my($self, $fh) = @_;
+
+ if( defined $fh ) {
+ $Fail_FH = _new_fh($fh);
+ }
+ return $Fail_FH;
+}
+
+sub todo_output {
+ my($self, $fh) = @_;
+
+ if( defined $fh ) {
+ $Todo_FH = _new_fh($fh);
+ }
+ return $Todo_FH;
+}
+
+
+sub _new_fh {
+ my($file_or_fh) = shift;
+
+ my $fh;
+ if( _is_fh($file_or_fh) ) {
+ $fh = $file_or_fh;
+ }
+ else {
+ $fh = do { local *FH };
+ open $fh, ">$file_or_fh" or
+ die "Can't open test output log $file_or_fh: $!";
+ }
+
+ return $fh;
+}
+
+
+sub _is_fh {
+ my $maybe_fh = shift;
+
+ return 1 if ref \$maybe_fh eq 'GLOB'; # its a glob
+
+ return UNIVERSAL::isa($maybe_fh, 'GLOB') ||
+ UNIVERSAL::isa($maybe_fh, 'IO::Handle') ||
+
+ # 5.5.4's tied() and can() doesn't like getting undef
+ UNIVERSAL::can((tied($maybe_fh) || ''), 'TIEHANDLE');
+}
+
+
+sub _autoflush {
+ my($fh) = shift;
+ my $old_fh = select $fh;
+ $| = 1;
+ select $old_fh;
+}
+
+
+my $Opened_Testhandles = 0;
+sub _dup_stdhandles {
+ my $self = shift;
+
+ $self->_open_testhandles unless $Opened_Testhandles;
+
+ # Set everything to unbuffered else plain prints to STDOUT will
+ # come out in the wrong order from our own prints.
+ _autoflush(\*TESTOUT);
+ _autoflush(\*STDOUT);
+ _autoflush(\*TESTERR);
+ _autoflush(\*STDERR);
+
+ $Test->output(\*TESTOUT);
+ $Test->failure_output(\*TESTERR);
+ $Test->todo_output(\*TESTOUT);
+}
+
+sub _open_testhandles {
+ # We dup STDOUT and STDERR so people can change them in their
+ # test suites while still getting normal test output.
+ open(TESTOUT, ">&STDOUT") or die "Can't dup STDOUT: $!";
+ open(TESTERR, ">&STDERR") or die "Can't dup STDERR: $!";
+ $Opened_Testhandles = 1;
+}
+
+
+=back
+
+
+=head2 Test Status and Info
+
+=over 4
+
+=item B<current_test>
+
+ my $curr_test = $Test->current_test;
+ $Test->current_test($num);
+
+Gets/sets the current test number we're on. You usually shouldn't
+have to set this.
+
+If set forward, the details of the missing tests are filled in as 'unknown'.
+if set backward, the details of the intervening tests are deleted. You
+can erase history if you really want to.
+
+=cut
+
+sub current_test {
+ my($self, $num) = @_;
+
+ lock($Curr_Test);
+ if( defined $num ) {
+ unless( $Have_Plan ) {
+ require Carp;
+ Carp::croak("Can't change the current test number without a plan!");
+ }
+
+ $Curr_Test = $num;
+
+ # If the test counter is being pushed forward fill in the details.
+ if( $num > @Test_Results ) {
+ my $start = @Test_Results ? $#Test_Results + 1 : 0;
+ for ($start..$num-1) {
+ $Test_Results[$_] = &share({
+ 'ok' => 1,
+ actual_ok => undef,
+ reason => 'incrementing test number',
+ type => 'unknown',
+ name => undef
+ });
+ }
+ }
+ # If backward, wipe history. Its their funeral.
+ elsif( $num < @Test_Results ) {
+ $#Test_Results = $num - 1;
+ }
+ }
+ return $Curr_Test;
+}
+
+
+=item B<summary>
+
+ my @tests = $Test->summary;
+
+A simple summary of the tests so far. True for pass, false for fail.
+This is a logical pass/fail, so todos are passes.
+
+Of course, test #1 is $tests[0], etc...
+
+=cut
+
+sub summary {
+ my($self) = shift;
+
+ return map { $_->{'ok'} } @Test_Results;
+}
+
+=item B<details>
+
+ my @tests = $Test->details;
+
+Like summary(), but with a lot more detail.
+
+ $tests[$test_num - 1] =
+ { 'ok' => is the test considered a pass?
+ actual_ok => did it literally say 'ok'?
+ name => name of the test (if any)
+ type => type of test (if any, see below).
+ reason => reason for the above (if any)
+ };
+
+'ok' is true if Test::Harness will consider the test to be a pass.
+
+'actual_ok' is a reflection of whether or not the test literally
+printed 'ok' or 'not ok'. This is for examining the result of 'todo'
+tests.
+
+'name' is the name of the test.
+
+'type' indicates if it was a special test. Normal tests have a type
+of ''. Type can be one of the following:
+
+ skip see skip()
+ todo see todo()
+ todo_skip see todo_skip()
+ unknown see below
+
+Sometimes the Test::Builder test counter is incremented without it
+printing any test output, for example, when current_test() is changed.
+In these cases, Test::Builder doesn't know the result of the test, so
+it's type is 'unkown'. These details for these tests are filled in.
+They are considered ok, but the name and actual_ok is left undef.
+
+For example "not ok 23 - hole count # TODO insufficient donuts" would
+result in this structure:
+
+ $tests[22] = # 23 - 1, since arrays start from 0.
+ { ok => 1, # logically, the test passed since it's todo
+ actual_ok => 0, # in absolute terms, it failed
+ name => 'hole count',
+ type => 'todo',
+ reason => 'insufficient donuts'
+ };
+
+=cut
+
+sub details {
+ return @Test_Results;
+}
+
+=item B<todo>
+
+ my $todo_reason = $Test->todo;
+ my $todo_reason = $Test->todo($pack);
+
+todo() looks for a $TODO variable in your tests. If set, all tests
+will be considered 'todo' (see Test::More and Test::Harness for
+details). Returns the reason (ie. the value of $TODO) if running as
+todo tests, false otherwise.
+
+todo() is pretty part about finding the right package to look for
+$TODO in. It uses the exported_to() package to find it. If that's
+not set, it's pretty good at guessing the right package to look at.
+
+Sometimes there is some confusion about where todo() should be looking
+for the $TODO variable. If you want to be sure, tell it explicitly
+what $pack to use.
+
+=cut
+
+sub todo {
+ my($self, $pack) = @_;
+
+ $pack = $pack || $self->exported_to || $self->caller(1);
+
+ no strict 'refs';
+ return defined ${$pack.'::TODO'} ? ${$pack.'::TODO'}
+ : 0;
+}
+
+=item B<caller>
+
+ my $package = $Test->caller;
+ my($pack, $file, $line) = $Test->caller;
+ my($pack, $file, $line) = $Test->caller($height);
+
+Like the normal caller(), except it reports according to your level().
+
+=cut
+
+sub caller {
+ my($self, $height) = @_;
+ $height ||= 0;
+
+ my @caller = CORE::caller($self->level + $height + 1);
+ return wantarray ? @caller : $caller[0];
+}
+
+=back
+
+=cut
+
+=begin _private
+
+=over 4
+
+=item B<_sanity_check>
+
+ _sanity_check();
+
+Runs a bunch of end of test sanity checks to make sure reality came
+through ok. If anything is wrong it will die with a fairly friendly
+error message.
+
+=cut
+
+#'#
+sub _sanity_check {
+ _whoa($Curr_Test < 0, 'Says here you ran a negative number of tests!');
+ _whoa(!$Have_Plan and $Curr_Test,
+ 'Somehow your tests ran without a plan!');
+ _whoa($Curr_Test != @Test_Results,
+ 'Somehow you got a different number of results than tests ran!');
+}
+
+=item B<_whoa>
+
+ _whoa($check, $description);
+
+A sanity check, similar to assert(). If the $check is true, something
+has gone horribly wrong. It will die with the given $description and
+a note to contact the author.
+
+=cut
+
+sub _whoa {
+ my($check, $desc) = @_;
+ if( $check ) {
+ die <<WHOA;
+WHOA! $desc
+This should never happen! Please contact the author immediately!
+WHOA
+ }
+}
+
+=item B<_my_exit>
+
+ _my_exit($exit_num);
+
+Perl seems to have some trouble with exiting inside an END block. 5.005_03
+and 5.6.1 both seem to do odd things. Instead, this function edits $?
+directly. It should ONLY be called from inside an END block. It
+doesn't actually exit, that's your job.
+
+=cut
+
+sub _my_exit {
+ $? = $_[0];
+
+ return 1;
+}
+
+
+=back
+
+=end _private
+
+=cut
+
+$SIG{__DIE__} = sub {
+ # We don't want to muck with death in an eval, but $^S isn't
+ # totally reliable. 5.005_03 and 5.6.1 both do the wrong thing
+ # with it. Instead, we use caller. This also means it runs under
+ # 5.004!
+ my $in_eval = 0;
+ for( my $stack = 1; my $sub = (CORE::caller($stack))[3]; $stack++ ) {
+ $in_eval = 1 if $sub =~ /^\(eval\)/;
+ }
+ $Test_Died = 1 unless $in_eval;
+};
+
+sub _ending {
+ my $self = shift;
+
+ _sanity_check();
+
+ # Don't bother with an ending if this is a forked copy. Only the parent
+ # should do the ending.
+ do{ _my_exit($?) && return } if $Original_Pid != $$;
+
+ # Bailout if plan() was never called. This is so
+ # "require Test::Simple" doesn't puke.
+ do{ _my_exit(0) && return } if !$Have_Plan && !$Test_Died;
+
+ # Figure out if we passed or failed and print helpful messages.
+ if( @Test_Results ) {
+ # The plan? We have no plan.
+ if( $No_Plan ) {
+ $self->_print("1..$Curr_Test\n") unless $self->no_header;
+ $Expected_Tests = $Curr_Test;
+ }
+
+ # Auto-extended arrays and elements which aren't explicitly
+ # filled in with a shared reference will puke under 5.8.0
+ # ithreads. So we have to fill them in by hand. :(
+ my $empty_result = &share({});
+ for my $idx ( 0..$Expected_Tests-1 ) {
+ $Test_Results[$idx] = $empty_result
+ unless defined $Test_Results[$idx];
+ }
+
+ my $num_failed = grep !$_->{'ok'}, @Test_Results[0..$Expected_Tests-1];
+ $num_failed += abs($Expected_Tests - @Test_Results);
+
+ if( $Curr_Test < $Expected_Tests ) {
+ my $s = $Expected_Tests == 1 ? '' : 's';
+ $self->diag(<<"FAIL");
+Looks like you planned $Expected_Tests test$s but only ran $Curr_Test.
+FAIL
+ }
+ elsif( $Curr_Test > $Expected_Tests ) {
+ my $num_extra = $Curr_Test - $Expected_Tests;
+ my $s = $Expected_Tests == 1 ? '' : 's';
+ $self->diag(<<"FAIL");
+Looks like you planned $Expected_Tests test$s but ran $num_extra extra.
+FAIL
+ }
+ elsif ( $num_failed ) {
+ my $s = $num_failed == 1 ? '' : 's';
+ $self->diag(<<"FAIL");
+Looks like you failed $num_failed test$s of $Expected_Tests.
+FAIL
+ }
+
+ if( $Test_Died ) {
+ $self->diag(<<"FAIL");
+Looks like your test died just after $Curr_Test.
+FAIL
+
+ _my_exit( 255 ) && return;
+ }
+
+ _my_exit( $num_failed <= 254 ? $num_failed : 254 ) && return;
+ }
+ elsif ( $Skip_All ) {
+ _my_exit( 0 ) && return;
+ }
+ elsif ( $Test_Died ) {
+ $self->diag(<<'FAIL');
+Looks like your test died before it could output anything.
+FAIL
+ _my_exit( 255 ) && return;
+ }
+ else {
+ $self->diag("No tests run!\n");
+ _my_exit( 255 ) && return;
+ }
+}
+
+END {
+ $Test->_ending if defined $Test and !$Test->no_ending;
+}
+
+=head1 EXIT CODES
+
+If all your tests passed, Test::Builder will exit with zero (which is
+normal). If anything failed it will exit with how many failed. If
+you run less (or more) tests than you planned, the missing (or extras)
+will be considered failures. If no tests were ever run Test::Builder
+will throw a warning and exit with 255. If the test died, even after
+having successfully completed all its tests, it will still be
+considered a failure and will exit with 255.
+
+So the exit codes are...
+
+ 0 all tests successful
+ 255 test died
+ any other number how many failed (including missing or extras)
+
+If you fail more than 254 tests, it will be reported as 254.
+
+
+=head1 THREADS
+
+In perl 5.8.0 and later, Test::Builder is thread-safe. The test
+number is shared amongst all threads. This means if one thread sets
+the test number using current_test() they will all be effected.
+
+Test::Builder is only thread-aware if threads.pm is loaded I<before>
+Test::Builder.
+
+=head1 EXAMPLES
+
+CPAN can provide the best examples. Test::Simple, Test::More,
+Test::Exception and Test::Differences all use Test::Builder.
+
+=head1 SEE ALSO
+
+Test::Simple, Test::More, Test::Harness
+
+=head1 AUTHORS
+
+Original code by chromatic, maintained by Michael G Schwern
+E<lt>schwern@pobox.comE<gt>
+
+=head1 COPYRIGHT
+
+Copyright 2002, 2004 by chromatic E<lt>chromatic@wgz.orgE<gt> and
+ Michael G Schwern E<lt>schwern@pobox.comE<gt>.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See F<http://www.perl.com/perl/misc/Artistic.html>
+
+=cut
+
+1;
diff --git a/trunk/Examples/test-suite/perl5/Test/More.pm b/trunk/Examples/test-suite/perl5/Test/More.pm
new file mode 100644
index 000000000..aa0280851
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/Test/More.pm
@@ -0,0 +1,1448 @@
+package Test::More;
+
+use 5.004;
+
+use strict;
+use Test::Builder;
+
+
+# Can't use Carp because it might cause use_ok() to accidentally succeed
+# even though the module being used forgot to use Carp. Yes, this
+# actually happened.
+sub _carp {
+ my($file, $line) = (caller(1))[1,2];
+ warn @_, " at $file line $line\n";
+}
+
+
+
+require Exporter;
+use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);
+$VERSION = '0.54';
+$VERSION = eval $VERSION; # make the alpha version come out as a number
+
+@ISA = qw(Exporter);
+@EXPORT = qw(ok use_ok require_ok
+ is isnt like unlike is_deeply
+ cmp_ok
+ skip todo todo_skip
+ pass fail
+ eq_array eq_hash eq_set
+ $TODO
+ plan
+ can_ok isa_ok
+ diag
+ );
+
+my $Test = Test::Builder->new;
+my $Show_Diag = 1;
+
+
+# 5.004's Exporter doesn't have export_to_level.
+sub _export_to_level
+{
+ my $pkg = shift;
+ my $level = shift;
+ (undef) = shift; # redundant arg
+ my $callpkg = caller($level);
+ $pkg->export($callpkg, @_);
+}
+
+
+=head1 NAME
+
+Test::More - yet another framework for writing test scripts
+
+=head1 SYNOPSIS
+
+ use Test::More tests => $Num_Tests;
+ # or
+ use Test::More qw(no_plan);
+ # or
+ use Test::More skip_all => $reason;
+
+ BEGIN { use_ok( 'Some::Module' ); }
+ require_ok( 'Some::Module' );
+
+ # Various ways to say "ok"
+ ok($this eq $that, $test_name);
+
+ is ($this, $that, $test_name);
+ isnt($this, $that, $test_name);
+
+ # Rather than print STDERR "# here's what went wrong\n"
+ diag("here's what went wrong");
+
+ like ($this, qr/that/, $test_name);
+ unlike($this, qr/that/, $test_name);
+
+ cmp_ok($this, '==', $that, $test_name);
+
+ is_deeply($complex_structure1, $complex_structure2, $test_name);
+
+ SKIP: {
+ skip $why, $how_many unless $have_some_feature;
+
+ ok( foo(), $test_name );
+ is( foo(42), 23, $test_name );
+ };
+
+ TODO: {
+ local $TODO = $why;
+
+ ok( foo(), $test_name );
+ is( foo(42), 23, $test_name );
+ };
+
+ can_ok($module, @methods);
+ isa_ok($object, $class);
+
+ pass($test_name);
+ fail($test_name);
+
+ # Utility comparison functions.
+ eq_array(\@this, \@that);
+ eq_hash(\%this, \%that);
+ eq_set(\@this, \@that);
+
+ # UNIMPLEMENTED!!!
+ my @status = Test::More::status;
+
+ # UNIMPLEMENTED!!!
+ BAIL_OUT($why);
+
+
+=head1 DESCRIPTION
+
+B<STOP!> If you're just getting started writing tests, have a look at
+Test::Simple first. This is a drop in replacement for Test::Simple
+which you can switch to once you get the hang of basic testing.
+
+The purpose of this module is to provide a wide range of testing
+utilities. Various ways to say "ok" with better diagnostics,
+facilities to skip tests, test future features and compare complicated
+data structures. While you can do almost anything with a simple
+C<ok()> function, it doesn't provide good diagnostic output.
+
+
+=head2 I love it when a plan comes together
+
+Before anything else, you need a testing plan. This basically declares
+how many tests your script is going to run to protect against premature
+failure.
+
+The preferred way to do this is to declare a plan when you C<use Test::More>.
+
+ use Test::More tests => $Num_Tests;
+
+There are rare cases when you will not know beforehand how many tests
+your script is going to run. In this case, you can declare that you
+have no plan. (Try to avoid using this as it weakens your test.)
+
+ use Test::More qw(no_plan);
+
+B<NOTE>: using no_plan requires a Test::Harness upgrade else it will
+think everything has failed. See L<BUGS and CAVEATS>)
+
+In some cases, you'll want to completely skip an entire testing script.
+
+ use Test::More skip_all => $skip_reason;
+
+Your script will declare a skip with the reason why you skipped and
+exit immediately with a zero (success). See L<Test::Harness> for
+details.
+
+If you want to control what functions Test::More will export, you
+have to use the 'import' option. For example, to import everything
+but 'fail', you'd do:
+
+ use Test::More tests => 23, import => ['!fail'];
+
+Alternatively, you can use the plan() function. Useful for when you
+have to calculate the number of tests.
+
+ use Test::More;
+ plan tests => keys %Stuff * 3;
+
+or for deciding between running the tests at all:
+
+ use Test::More;
+ if( $^O eq 'MacOS' ) {
+ plan skip_all => 'Test irrelevant on MacOS';
+ }
+ else {
+ plan tests => 42;
+ }
+
+=cut
+
+sub plan {
+ my(@plan) = @_;
+
+ my $idx = 0;
+ my @cleaned_plan;
+ while( $idx <= $#plan ) {
+ my $item = $plan[$idx];
+
+ if( $item eq 'no_diag' ) {
+ $Show_Diag = 0;
+ }
+ else {
+ push @cleaned_plan, $item;
+ }
+
+ $idx++;
+ }
+
+ $Test->plan(@cleaned_plan);
+}
+
+sub import {
+ my($class) = shift;
+
+ my $caller = caller;
+
+ $Test->exported_to($caller);
+
+ my $idx = 0;
+ my @plan;
+ my @imports;
+ while( $idx <= $#_ ) {
+ my $item = $_[$idx];
+
+ if( $item eq 'import' ) {
+ push @imports, @{$_[$idx+1]};
+ $idx++;
+ }
+ else {
+ push @plan, $item;
+ }
+
+ $idx++;
+ }
+
+ plan(@plan);
+
+ __PACKAGE__->_export_to_level(1, __PACKAGE__, @imports);
+}
+
+
+=head2 Test names
+
+By convention, each test is assigned a number in order. This is
+largely done automatically for you. However, it's often very useful to
+assign a name to each test. Which would you rather see:
+
+ ok 4
+ not ok 5
+ ok 6
+
+or
+
+ ok 4 - basic multi-variable
+ not ok 5 - simple exponential
+ ok 6 - force == mass * acceleration
+
+The later gives you some idea of what failed. It also makes it easier
+to find the test in your script, simply search for "simple
+exponential".
+
+All test functions take a name argument. It's optional, but highly
+suggested that you use it.
+
+
+=head2 I'm ok, you're not ok.
+
+The basic purpose of this module is to print out either "ok #" or "not
+ok #" depending on if a given test succeeded or failed. Everything
+else is just gravy.
+
+All of the following print "ok" or "not ok" depending on if the test
+succeeded or failed. They all also return true or false,
+respectively.
+
+=over 4
+
+=item B<ok>
+
+ ok($this eq $that, $test_name);
+
+This simply evaluates any expression (C<$this eq $that> is just a
+simple example) and uses that to determine if the test succeeded or
+failed. A true expression passes, a false one fails. Very simple.
+
+For example:
+
+ ok( $exp{9} == 81, 'simple exponential' );
+ ok( Film->can('db_Main'), 'set_db()' );
+ ok( $p->tests == 4, 'saw tests' );
+ ok( !grep !defined $_, @items, 'items populated' );
+
+(Mnemonic: "This is ok.")
+
+$test_name is a very short description of the test that will be printed
+out. It makes it very easy to find a test in your script when it fails
+and gives others an idea of your intentions. $test_name is optional,
+but we B<very> strongly encourage its use.
+
+Should an ok() fail, it will produce some diagnostics:
+
+ not ok 18 - sufficient mucus
+ # Failed test 18 (foo.t at line 42)
+
+This is actually Test::Simple's ok() routine.
+
+=cut
+
+sub ok ($;$) {
+ my($test, $name) = @_;
+ $Test->ok($test, $name);
+}
+
+=item B<is>
+
+=item B<isnt>
+
+ is ( $this, $that, $test_name );
+ isnt( $this, $that, $test_name );
+
+Similar to ok(), is() and isnt() compare their two arguments
+with C<eq> and C<ne> respectively and use the result of that to
+determine if the test succeeded or failed. So these:
+
+ # Is the ultimate answer 42?
+ is( ultimate_answer(), 42, "Meaning of Life" );
+
+ # $foo isn't empty
+ isnt( $foo, '', "Got some foo" );
+
+are similar to these:
+
+ ok( ultimate_answer() eq 42, "Meaning of Life" );
+ ok( $foo ne '', "Got some foo" );
+
+(Mnemonic: "This is that." "This isn't that.")
+
+So why use these? They produce better diagnostics on failure. ok()
+cannot know what you are testing for (beyond the name), but is() and
+isnt() know what the test was and why it failed. For example this
+test:
+
+ my $foo = 'waffle'; my $bar = 'yarblokos';
+ is( $foo, $bar, 'Is foo the same as bar?' );
+
+Will produce something like this:
+
+ not ok 17 - Is foo the same as bar?
+ # Failed test (foo.t at line 139)
+ # got: 'waffle'
+ # expected: 'yarblokos'
+
+So you can figure out what went wrong without rerunning the test.
+
+You are encouraged to use is() and isnt() over ok() where possible,
+however do not be tempted to use them to find out if something is
+true or false!
+
+ # XXX BAD!
+ is( exists $brooklyn{tree}, 1, 'A tree grows in Brooklyn' );
+
+This does not check if C<exists $brooklyn{tree}> is true, it checks if
+it returns 1. Very different. Similar caveats exist for false and 0.
+In these cases, use ok().
+
+ ok( exists $brooklyn{tree}, 'A tree grows in Brooklyn' );
+
+For those grammatical pedants out there, there's an C<isn't()>
+function which is an alias of isnt().
+
+=cut
+
+sub is ($$;$) {
+ $Test->is_eq(@_);
+}
+
+sub isnt ($$;$) {
+ $Test->isnt_eq(@_);
+}
+
+*isn't = \&isnt;
+
+
+=item B<like>
+
+ like( $this, qr/that/, $test_name );
+
+Similar to ok(), like() matches $this against the regex C<qr/that/>.
+
+So this:
+
+ like($this, qr/that/, 'this is like that');
+
+is similar to:
+
+ ok( $this =~ /that/, 'this is like that');
+
+(Mnemonic "This is like that".)
+
+The second argument is a regular expression. It may be given as a
+regex reference (i.e. C<qr//>) or (for better compatibility with older
+perls) as a string that looks like a regex (alternative delimiters are
+currently not supported):
+
+ like( $this, '/that/', 'this is like that' );
+
+Regex options may be placed on the end (C<'/that/i'>).
+
+Its advantages over ok() are similar to that of is() and isnt(). Better
+diagnostics on failure.
+
+=cut
+
+sub like ($$;$) {
+ $Test->like(@_);
+}
+
+
+=item B<unlike>
+
+ unlike( $this, qr/that/, $test_name );
+
+Works exactly as like(), only it checks if $this B<does not> match the
+given pattern.
+
+=cut
+
+sub unlike ($$;$) {
+ $Test->unlike(@_);
+}
+
+
+=item B<cmp_ok>
+
+ cmp_ok( $this, $op, $that, $test_name );
+
+Halfway between ok() and is() lies cmp_ok(). This allows you to
+compare two arguments using any binary perl operator.
+
+ # ok( $this eq $that );
+ cmp_ok( $this, 'eq', $that, 'this eq that' );
+
+ # ok( $this == $that );
+ cmp_ok( $this, '==', $that, 'this == that' );
+
+ # ok( $this && $that );
+ cmp_ok( $this, '&&', $that, 'this && that' );
+ ...etc...
+
+Its advantage over ok() is when the test fails you'll know what $this
+and $that were:
+
+ not ok 1
+ # Failed test (foo.t at line 12)
+ # '23'
+ # &&
+ # undef
+
+It's also useful in those cases where you are comparing numbers and
+is()'s use of C<eq> will interfere:
+
+ cmp_ok( $big_hairy_number, '==', $another_big_hairy_number );
+
+=cut
+
+sub cmp_ok($$$;$) {
+ $Test->cmp_ok(@_);
+}
+
+
+=item B<can_ok>
+
+ can_ok($module, @methods);
+ can_ok($object, @methods);
+
+Checks to make sure the $module or $object can do these @methods
+(works with functions, too).
+
+ can_ok('Foo', qw(this that whatever));
+
+is almost exactly like saying:
+
+ ok( Foo->can('this') &&
+ Foo->can('that') &&
+ Foo->can('whatever')
+ );
+
+only without all the typing and with a better interface. Handy for
+quickly testing an interface.
+
+No matter how many @methods you check, a single can_ok() call counts
+as one test. If you desire otherwise, use:
+
+ foreach my $meth (@methods) {
+ can_ok('Foo', $meth);
+ }
+
+=cut
+
+sub can_ok ($@) {
+ my($proto, @methods) = @_;
+ my $class = ref $proto || $proto;
+
+ unless( @methods ) {
+ my $ok = $Test->ok( 0, "$class->can(...)" );
+ $Test->diag(' can_ok() called with no methods');
+ return $ok;
+ }
+
+ my @nok = ();
+ foreach my $method (@methods) {
+ local($!, $@); # don't interfere with caller's $@
+ # eval sometimes resets $!
+ eval { $proto->can($method) } || push @nok, $method;
+ }
+
+ my $name;
+ $name = @methods == 1 ? "$class->can('$methods[0]')"
+ : "$class->can(...)";
+
+ my $ok = $Test->ok( !@nok, $name );
+
+ $Test->diag(map " $class->can('$_') failed\n", @nok);
+
+ return $ok;
+}
+
+=item B<isa_ok>
+
+ isa_ok($object, $class, $object_name);
+ isa_ok($ref, $type, $ref_name);
+
+Checks to see if the given C<< $object->isa($class) >>. Also checks to make
+sure the object was defined in the first place. Handy for this sort
+of thing:
+
+ my $obj = Some::Module->new;
+ isa_ok( $obj, 'Some::Module' );
+
+where you'd otherwise have to write
+
+ my $obj = Some::Module->new;
+ ok( defined $obj && $obj->isa('Some::Module') );
+
+to safeguard against your test script blowing up.
+
+It works on references, too:
+
+ isa_ok( $array_ref, 'ARRAY' );
+
+The diagnostics of this test normally just refer to 'the object'. If
+you'd like them to be more specific, you can supply an $object_name
+(for example 'Test customer').
+
+=cut
+
+sub isa_ok ($$;$) {
+ my($object, $class, $obj_name) = @_;
+
+ my $diag;
+ $obj_name = 'The object' unless defined $obj_name;
+ my $name = "$obj_name isa $class";
+ if( !defined $object ) {
+ $diag = "$obj_name isn't defined";
+ }
+ elsif( !ref $object ) {
+ $diag = "$obj_name isn't a reference";
+ }
+ else {
+ # We can't use UNIVERSAL::isa because we want to honor isa() overrides
+ local($@, $!); # eval sometimes resets $!
+ my $rslt = eval { $object->isa($class) };
+ if( $@ ) {
+ if( $@ =~ /^Can't call method "isa" on unblessed reference/ ) {
+ if( !UNIVERSAL::isa($object, $class) ) {
+ my $ref = ref $object;
+ $diag = "$obj_name isn't a '$class' it's a '$ref'";
+ }
+ } else {
+ die <<WHOA;
+WHOA! I tried to call ->isa on your object and got some weird error.
+This should never happen. Please contact the author immediately.
+Here's the error.
+$@
+WHOA
+ }
+ }
+ elsif( !$rslt ) {
+ my $ref = ref $object;
+ $diag = "$obj_name isn't a '$class' it's a '$ref'";
+ }
+ }
+
+
+
+ my $ok;
+ if( $diag ) {
+ $ok = $Test->ok( 0, $name );
+ $Test->diag(" $diag\n");
+ }
+ else {
+ $ok = $Test->ok( 1, $name );
+ }
+
+ return $ok;
+}
+
+
+=item B<pass>
+
+=item B<fail>
+
+ pass($test_name);
+ fail($test_name);
+
+Sometimes you just want to say that the tests have passed. Usually
+the case is you've got some complicated condition that is difficult to
+wedge into an ok(). In this case, you can simply use pass() (to
+declare the test ok) or fail (for not ok). They are synonyms for
+ok(1) and ok(0).
+
+Use these very, very, very sparingly.
+
+=cut
+
+sub pass (;$) {
+ $Test->ok(1, @_);
+}
+
+sub fail (;$) {
+ $Test->ok(0, @_);
+}
+
+=back
+
+=head2 Diagnostics
+
+If you pick the right test function, you'll usually get a good idea of
+what went wrong when it failed. But sometimes it doesn't work out
+that way. So here we have ways for you to write your own diagnostic
+messages which are safer than just C<print STDERR>.
+
+=over 4
+
+=item B<diag>
+
+ diag(@diagnostic_message);
+
+Prints a diagnostic message which is guaranteed not to interfere with
+test output. Like C<print> @diagnostic_message is simply concatinated
+together.
+
+Handy for this sort of thing:
+
+ ok( grep(/foo/, @users), "There's a foo user" ) or
+ diag("Since there's no foo, check that /etc/bar is set up right");
+
+which would produce:
+
+ not ok 42 - There's a foo user
+ # Failed test (foo.t at line 52)
+ # Since there's no foo, check that /etc/bar is set up right.
+
+You might remember C<ok() or diag()> with the mnemonic C<open() or
+die()>.
+
+All diag()s can be made silent by passing the "no_diag" option to
+Test::More. C<use Test::More tests => 1, 'no_diag'>. This is useful
+if you have diagnostics for personal testing but then wish to make
+them silent for release without commenting out each individual
+statement.
+
+B<NOTE> The exact formatting of the diagnostic output is still
+changing, but it is guaranteed that whatever you throw at it it won't
+interfere with the test.
+
+=cut
+
+sub diag {
+ return unless $Show_Diag;
+ $Test->diag(@_);
+}
+
+
+=back
+
+=head2 Module tests
+
+You usually want to test if the module you're testing loads ok, rather
+than just vomiting if its load fails. For such purposes we have
+C<use_ok> and C<require_ok>.
+
+=over 4
+
+=item B<use_ok>
+
+ BEGIN { use_ok($module); }
+ BEGIN { use_ok($module, @imports); }
+
+These simply use the given $module and test to make sure the load
+happened ok. It's recommended that you run use_ok() inside a BEGIN
+block so its functions are exported at compile-time and prototypes are
+properly honored.
+
+If @imports are given, they are passed through to the use. So this:
+
+ BEGIN { use_ok('Some::Module', qw(foo bar)) }
+
+is like doing this:
+
+ use Some::Module qw(foo bar);
+
+Version numbers can be checked like so:
+
+ # Just like "use Some::Module 1.02"
+ BEGIN { use_ok('Some::Module', 1.02) }
+
+Don't try to do this:
+
+ BEGIN {
+ use_ok('Some::Module');
+
+ ...some code that depends on the use...
+ ...happening at compile time...
+ }
+
+because the notion of "compile-time" is relative. Instead, you want:
+
+ BEGIN { use_ok('Some::Module') }
+ BEGIN { ...some code that depends on the use... }
+
+
+=cut
+
+sub use_ok ($;@) {
+ my($module, @imports) = @_;
+ @imports = () unless @imports;
+
+ my($pack,$filename,$line) = caller;
+
+ local($@,$!); # eval sometimes interferes with $!
+
+ if( @imports == 1 and $imports[0] =~ /^\d+(?:\.\d+)?$/ ) {
+ # probably a version check. Perl needs to see the bare number
+ # for it to work with non-Exporter based modules.
+ eval <<USE;
+package $pack;
+use $module $imports[0];
+USE
+ }
+ else {
+ eval <<USE;
+package $pack;
+use $module \@imports;
+USE
+ }
+
+ my $ok = $Test->ok( !$@, "use $module;" );
+
+ unless( $ok ) {
+ chomp $@;
+ $@ =~ s{^BEGIN failed--compilation aborted at .*$}
+ {BEGIN failed--compilation aborted at $filename line $line.}m;
+ $Test->diag(<<DIAGNOSTIC);
+ Tried to use '$module'.
+ Error: $@
+DIAGNOSTIC
+
+ }
+
+ return $ok;
+}
+
+=item B<require_ok>
+
+ require_ok($module);
+ require_ok($file);
+
+Like use_ok(), except it requires the $module or $file.
+
+=cut
+
+sub require_ok ($) {
+ my($module) = shift;
+
+ my $pack = caller;
+
+ # Try to deterine if we've been given a module name or file.
+ # Module names must be barewords, files not.
+ $module = qq['$module'] unless _is_module_name($module);
+
+ local($!, $@); # eval sometimes interferes with $!
+ eval <<REQUIRE;
+package $pack;
+require $module;
+REQUIRE
+
+ my $ok = $Test->ok( !$@, "require $module;" );
+
+ unless( $ok ) {
+ chomp $@;
+ $Test->diag(<<DIAGNOSTIC);
+ Tried to require '$module'.
+ Error: $@
+DIAGNOSTIC
+
+ }
+
+ return $ok;
+}
+
+
+sub _is_module_name {
+ my $module = shift;
+
+ # Module names start with a letter.
+ # End with an alphanumeric.
+ # The rest is an alphanumeric or ::
+ $module =~ s/\b::\b//g;
+ $module =~ /^[a-zA-Z]\w+$/;
+}
+
+=back
+
+=head2 Conditional tests
+
+Sometimes running a test under certain conditions will cause the
+test script to die. A certain function or method isn't implemented
+(such as fork() on MacOS), some resource isn't available (like a
+net connection) or a module isn't available. In these cases it's
+necessary to skip tests, or declare that they are supposed to fail
+but will work in the future (a todo test).
+
+For more details on the mechanics of skip and todo tests see
+L<Test::Harness>.
+
+The way Test::More handles this is with a named block. Basically, a
+block of tests which can be skipped over or made todo. It's best if I
+just show you...
+
+=over 4
+
+=item B<SKIP: BLOCK>
+
+ SKIP: {
+ skip $why, $how_many if $condition;
+
+ ...normal testing code goes here...
+ }
+
+This declares a block of tests that might be skipped, $how_many tests
+there are, $why and under what $condition to skip them. An example is
+the easiest way to illustrate:
+
+ SKIP: {
+ eval { require HTML::Lint };
+
+ skip "HTML::Lint not installed", 2 if $@;
+
+ my $lint = new HTML::Lint;
+ isa_ok( $lint, "HTML::Lint" );
+
+ $lint->parse( $html );
+ is( $lint->errors, 0, "No errors found in HTML" );
+ }
+
+If the user does not have HTML::Lint installed, the whole block of
+code I<won't be run at all>. Test::More will output special ok's
+which Test::Harness interprets as skipped, but passing, tests.
+
+It's important that $how_many accurately reflects the number of tests
+in the SKIP block so the # of tests run will match up with your plan.
+If your plan is C<no_plan> $how_many is optional and will default to 1.
+
+It's perfectly safe to nest SKIP blocks. Each SKIP block must have
+the label C<SKIP>, or Test::More can't work its magic.
+
+You don't skip tests which are failing because there's a bug in your
+program, or for which you don't yet have code written. For that you
+use TODO. Read on.
+
+=cut
+
+#'#
+sub skip {
+ my($why, $how_many) = @_;
+
+ unless( defined $how_many ) {
+ # $how_many can only be avoided when no_plan is in use.
+ _carp "skip() needs to know \$how_many tests are in the block"
+ unless $Test->has_plan eq 'no_plan';
+ $how_many = 1;
+ }
+
+ for( 1..$how_many ) {
+ $Test->skip($why);
+ }
+
+ local $^W = 0;
+ last SKIP;
+}
+
+
+=item B<TODO: BLOCK>
+
+ TODO: {
+ local $TODO = $why if $condition;
+
+ ...normal testing code goes here...
+ }
+
+Declares a block of tests you expect to fail and $why. Perhaps it's
+because you haven't fixed a bug or haven't finished a new feature:
+
+ TODO: {
+ local $TODO = "URI::Geller not finished";
+
+ my $card = "Eight of clubs";
+ is( URI::Geller->your_card, $card, 'Is THIS your card?' );
+
+ my $spoon;
+ URI::Geller->bend_spoon;
+ is( $spoon, 'bent', "Spoon bending, that's original" );
+ }
+
+With a todo block, the tests inside are expected to fail. Test::More
+will run the tests normally, but print out special flags indicating
+they are "todo". Test::Harness will interpret failures as being ok.
+Should anything succeed, it will report it as an unexpected success.
+You then know the thing you had todo is done and can remove the
+TODO flag.
+
+The nice part about todo tests, as opposed to simply commenting out a
+block of tests, is it's like having a programmatic todo list. You know
+how much work is left to be done, you're aware of what bugs there are,
+and you'll know immediately when they're fixed.
+
+Once a todo test starts succeeding, simply move it outside the block.
+When the block is empty, delete it.
+
+B<NOTE>: TODO tests require a Test::Harness upgrade else it will
+treat it as a normal failure. See L<BUGS and CAVEATS>)
+
+
+=item B<todo_skip>
+
+ TODO: {
+ todo_skip $why, $how_many if $condition;
+
+ ...normal testing code...
+ }
+
+With todo tests, it's best to have the tests actually run. That way
+you'll know when they start passing. Sometimes this isn't possible.
+Often a failing test will cause the whole program to die or hang, even
+inside an C<eval BLOCK> with and using C<alarm>. In these extreme
+cases you have no choice but to skip over the broken tests entirely.
+
+The syntax and behavior is similar to a C<SKIP: BLOCK> except the
+tests will be marked as failing but todo. Test::Harness will
+interpret them as passing.
+
+=cut
+
+sub todo_skip {
+ my($why, $how_many) = @_;
+
+ unless( defined $how_many ) {
+ # $how_many can only be avoided when no_plan is in use.
+ _carp "todo_skip() needs to know \$how_many tests are in the block"
+ unless $Test->has_plan eq 'no_plan';
+ $how_many = 1;
+ }
+
+ for( 1..$how_many ) {
+ $Test->todo_skip($why);
+ }
+
+ local $^W = 0;
+ last TODO;
+}
+
+=item When do I use SKIP vs. TODO?
+
+B<If it's something the user might not be able to do>, use SKIP.
+This includes optional modules that aren't installed, running under
+an OS that doesn't have some feature (like fork() or symlinks), or maybe
+you need an Internet connection and one isn't available.
+
+B<If it's something the programmer hasn't done yet>, use TODO. This
+is for any code you haven't written yet, or bugs you have yet to fix,
+but want to put tests in your testing script (always a good idea).
+
+
+=back
+
+=head2 Comparison functions
+
+Not everything is a simple eq check or regex. There are times you
+need to see if two arrays are equivalent, for instance. For these
+instances, Test::More provides a handful of useful functions.
+
+B<NOTE> I'm not quite sure what will happen with filehandles.
+
+=over 4
+
+=item B<is_deeply>
+
+ is_deeply( $this, $that, $test_name );
+
+Similar to is(), except that if $this and $that are hash or array
+references, it does a deep comparison walking each data structure to
+see if they are equivalent. If the two structures are different, it
+will display the place where they start differing.
+
+Test::Differences and Test::Deep provide more in-depth functionality
+along these lines.
+
+=cut
+
+use vars qw(@Data_Stack %Refs_Seen);
+my $DNE = bless [], 'Does::Not::Exist';
+sub is_deeply {
+ unless( @_ == 2 or @_ == 3 ) {
+ my $msg = <<WARNING;
+is_deeply() takes two or three args, you gave %d.
+This usually means you passed an array or hash instead
+of a reference to it
+WARNING
+ chop $msg; # clip off newline so carp() will put in line/file
+
+ _carp sprintf $msg, scalar @_;
+ }
+
+ my($this, $that, $name) = @_;
+
+ my $ok;
+ if( !ref $this xor !ref $that ) { # one's a reference, one isn't
+ $ok = 0;
+ }
+ if( !ref $this and !ref $that ) {
+ $ok = $Test->is_eq($this, $that, $name);
+ }
+ else {
+ local @Data_Stack = ();
+ local %Refs_Seen = ();
+ if( _deep_check($this, $that) ) {
+ $ok = $Test->ok(1, $name);
+ }
+ else {
+ $ok = $Test->ok(0, $name);
+ $ok = $Test->diag(_format_stack(@Data_Stack));
+ }
+ }
+
+ return $ok;
+}
+
+sub _format_stack {
+ my(@Stack) = @_;
+
+ my $var = '$FOO';
+ my $did_arrow = 0;
+ foreach my $entry (@Stack) {
+ my $type = $entry->{type} || '';
+ my $idx = $entry->{'idx'};
+ if( $type eq 'HASH' ) {
+ $var .= "->" unless $did_arrow++;
+ $var .= "{$idx}";
+ }
+ elsif( $type eq 'ARRAY' ) {
+ $var .= "->" unless $did_arrow++;
+ $var .= "[$idx]";
+ }
+ elsif( $type eq 'REF' ) {
+ $var = "\${$var}";
+ }
+ }
+
+ my @vals = @{$Stack[-1]{vals}}[0,1];
+ my @vars = ();
+ ($vars[0] = $var) =~ s/\$FOO/ \$got/;
+ ($vars[1] = $var) =~ s/\$FOO/\$expected/;
+
+ my $out = "Structures begin differing at:\n";
+ foreach my $idx (0..$#vals) {
+ my $val = $vals[$idx];
+ $vals[$idx] = !defined $val ? 'undef' :
+ $val eq $DNE ? "Does not exist"
+ : "'$val'";
+ }
+
+ $out .= "$vars[0] = $vals[0]\n";
+ $out .= "$vars[1] = $vals[1]\n";
+
+ $out =~ s/^/ /msg;
+ return $out;
+}
+
+
+sub _type {
+ my $thing = shift;
+
+ return '' if !ref $thing;
+
+ for my $type (qw(ARRAY HASH REF SCALAR GLOB Regexp)) {
+ return $type if UNIVERSAL::isa($thing, $type);
+ }
+
+ return '';
+}
+
+
+=item B<eq_array>
+
+ eq_array(\@this, \@that);
+
+Checks if two arrays are equivalent. This is a deep check, so
+multi-level structures are handled correctly.
+
+=cut
+
+#'#
+sub eq_array {
+ local @Data_Stack;
+ local %Refs_Seen;
+ _eq_array(@_);
+}
+
+sub _eq_array {
+ my($a1, $a2) = @_;
+
+ if( grep !_type($_) eq 'ARRAY', $a1, $a2 ) {
+ warn "eq_array passed a non-array ref";
+ return 0;
+ }
+
+ return 1 if $a1 eq $a2;
+
+ if($Refs_Seen{$a1}) {
+ return $Refs_Seen{$a1} eq $a2;
+ }
+ else {
+ $Refs_Seen{$a1} = "$a2";
+ }
+
+ my $ok = 1;
+ my $max = $#$a1 > $#$a2 ? $#$a1 : $#$a2;
+ for (0..$max) {
+ my $e1 = $_ > $#$a1 ? $DNE : $a1->[$_];
+ my $e2 = $_ > $#$a2 ? $DNE : $a2->[$_];
+
+ push @Data_Stack, { type => 'ARRAY', idx => $_, vals => [$e1, $e2] };
+ $ok = _deep_check($e1,$e2);
+ pop @Data_Stack if $ok;
+
+ last unless $ok;
+ }
+
+ return $ok;
+}
+
+sub _deep_check {
+ my($e1, $e2) = @_;
+ my $ok = 0;
+
+ {
+ # Quiet uninitialized value warnings when comparing undefs.
+ local $^W = 0;
+
+ $Test->_unoverload(\$e1, \$e2);
+
+ # Either they're both references or both not.
+ my $same_ref = !(!ref $e1 xor !ref $e2);
+
+ if( defined $e1 xor defined $e2 ) {
+ $ok = 0;
+ }
+ elsif ( $e1 == $DNE xor $e2 == $DNE ) {
+ $ok = 0;
+ }
+ elsif ( $same_ref and ($e1 eq $e2) ) {
+ $ok = 1;
+ }
+ else {
+ my $type = _type($e1);
+ $type = '' unless _type($e2) eq $type;
+
+ if( !$type ) {
+ push @Data_Stack, { vals => [$e1, $e2] };
+ $ok = 0;
+ }
+ elsif( $type eq 'ARRAY' ) {
+ $ok = _eq_array($e1, $e2);
+ }
+ elsif( $type eq 'HASH' ) {
+ $ok = _eq_hash($e1, $e2);
+ }
+ elsif( $type eq 'REF' ) {
+ push @Data_Stack, { type => 'REF', vals => [$e1, $e2] };
+ $ok = _deep_check($$e1, $$e2);
+ pop @Data_Stack if $ok;
+ }
+ elsif( $type eq 'SCALAR' ) {
+ push @Data_Stack, { type => 'REF', vals => [$e1, $e2] };
+ $ok = _deep_check($$e1, $$e2);
+ pop @Data_Stack if $ok;
+ }
+ }
+ }
+
+ return $ok;
+}
+
+
+=item B<eq_hash>
+
+ eq_hash(\%this, \%that);
+
+Determines if the two hashes contain the same keys and values. This
+is a deep check.
+
+=cut
+
+sub eq_hash {
+ local @Data_Stack;
+ local %Refs_Seen;
+ return _eq_hash(@_);
+}
+
+sub _eq_hash {
+ my($a1, $a2) = @_;
+
+ if( grep !_type($_) eq 'HASH', $a1, $a2 ) {
+ warn "eq_hash passed a non-hash ref";
+ return 0;
+ }
+
+ return 1 if $a1 eq $a2;
+
+ if( $Refs_Seen{$a1} ) {
+ return $Refs_Seen{$a1} eq $a2;
+ }
+ else {
+ $Refs_Seen{$a1} = "$a2";
+ }
+
+ my $ok = 1;
+ my $bigger = keys %$a1 > keys %$a2 ? $a1 : $a2;
+ foreach my $k (keys %$bigger) {
+ my $e1 = exists $a1->{$k} ? $a1->{$k} : $DNE;
+ my $e2 = exists $a2->{$k} ? $a2->{$k} : $DNE;
+
+ push @Data_Stack, { type => 'HASH', idx => $k, vals => [$e1, $e2] };
+ $ok = _deep_check($e1, $e2);
+ pop @Data_Stack if $ok;
+
+ last unless $ok;
+ }
+
+ return $ok;
+}
+
+=item B<eq_set>
+
+ eq_set(\@this, \@that);
+
+Similar to eq_array(), except the order of the elements is B<not>
+important. This is a deep check, but the irrelevancy of order only
+applies to the top level.
+
+B<NOTE> By historical accident, this is not a true set comparision.
+While the order of elements does not matter, duplicate elements do.
+
+=cut
+
+sub eq_set {
+ my($a1, $a2) = @_;
+ return 0 unless @$a1 == @$a2;
+
+ # There's faster ways to do this, but this is easiest.
+ local $^W = 0;
+
+ # We must make sure that references are treated neutrally. It really
+ # doesn't matter how we sort them, as long as both arrays are sorted
+ # with the same algorithm.
+ # Have to inline the sort routine due to a threading/sort bug.
+ # See [rt.cpan.org 6782]
+ return eq_array(
+ [sort { ref $a ? -1 : ref $b ? 1 : $a cmp $b } @$a1],
+ [sort { ref $a ? -1 : ref $b ? 1 : $a cmp $b } @$a2]
+ );
+}
+
+=back
+
+
+=head2 Extending and Embedding Test::More
+
+Sometimes the Test::More interface isn't quite enough. Fortunately,
+Test::More is built on top of Test::Builder which provides a single,
+unified backend for any test library to use. This means two test
+libraries which both use Test::Builder B<can be used together in the
+same program>.
+
+If you simply want to do a little tweaking of how the tests behave,
+you can access the underlying Test::Builder object like so:
+
+=over 4
+
+=item B<builder>
+
+ my $test_builder = Test::More->builder;
+
+Returns the Test::Builder object underlying Test::More for you to play
+with.
+
+=cut
+
+sub builder {
+ return Test::Builder->new;
+}
+
+=back
+
+
+=head1 EXIT CODES
+
+If all your tests passed, Test::Builder will exit with zero (which is
+normal). If anything failed it will exit with how many failed. If
+you run less (or more) tests than you planned, the missing (or extras)
+will be considered failures. If no tests were ever run Test::Builder
+will throw a warning and exit with 255. If the test died, even after
+having successfully completed all its tests, it will still be
+considered a failure and will exit with 255.
+
+So the exit codes are...
+
+ 0 all tests successful
+ 255 test died
+ any other number how many failed (including missing or extras)
+
+If you fail more than 254 tests, it will be reported as 254.
+
+
+=head1 CAVEATS and NOTES
+
+=over 4
+
+=item Backwards compatibility
+
+Test::More works with Perls as old as 5.004_05.
+
+
+=item Overloaded objects
+
+String overloaded objects are compared B<as strings>. This prevents
+Test::More from piercing an object's interface allowing better blackbox
+testing. So if a function starts returning overloaded objects instead of
+bare strings your tests won't notice the difference. This is good.
+
+However, it does mean that functions like is_deeply() cannot be used to
+test the internals of string overloaded objects. In this case I would
+suggest Test::Deep which contains more flexible testing functions for
+complex data structures.
+
+
+=item Threads
+
+Test::More will only be aware of threads if "use threads" has been done
+I<before> Test::More is loaded. This is ok:
+
+ use threads;
+ use Test::More;
+
+This may cause problems:
+
+ use Test::More
+ use threads;
+
+
+=item Test::Harness upgrade
+
+no_plan and todo depend on new Test::Harness features and fixes. If
+you're going to distribute tests that use no_plan or todo your
+end-users will have to upgrade Test::Harness to the latest one on
+CPAN. If you avoid no_plan and TODO tests, the stock Test::Harness
+will work fine.
+
+Installing Test::More should also upgrade Test::Harness.
+
+=back
+
+
+=head1 HISTORY
+
+This is a case of convergent evolution with Joshua Pritikin's Test
+module. I was largely unaware of its existence when I'd first
+written my own ok() routines. This module exists because I can't
+figure out how to easily wedge test names into Test's interface (along
+with a few other problems).
+
+The goal here is to have a testing utility that's simple to learn,
+quick to use and difficult to trip yourself up with while still
+providing more flexibility than the existing Test.pm. As such, the
+names of the most common routines are kept tiny, special cases and
+magic side-effects are kept to a minimum. WYSIWYG.
+
+
+=head1 SEE ALSO
+
+L<Test::Simple> if all this confuses you and you just want to write
+some tests. You can upgrade to Test::More later (it's forward
+compatible).
+
+L<Test> is the old testing module. Its main benefit is that it has
+been distributed with Perl since 5.004_05.
+
+L<Test::Harness> for details on how your test results are interpreted
+by Perl.
+
+L<Test::Differences> for more ways to test complex data structures.
+And it plays well with Test::More.
+
+L<Test::Class> is like XUnit but more perlish.
+
+L<Test::Deep> gives you more powerful complex data structure testing.
+
+L<Test::Unit> is XUnit style testing.
+
+L<Test::Inline> shows the idea of embedded testing.
+
+L<Bundle::Test> installs a whole bunch of useful test modules.
+
+
+=head1 AUTHORS
+
+Michael G Schwern E<lt>schwern@pobox.comE<gt> with much inspiration
+from Joshua Pritikin's Test module and lots of help from Barrie
+Slaymaker, Tony Bowden, blackstar.co.uk, chromatic, Fergal Daly and
+the perl-qa gang.
+
+
+=head1 BUGS
+
+See F<http://rt.cpan.org> to report and view bugs.
+
+
+=head1 COPYRIGHT
+
+Copyright 2001, 2002, 2004 by Michael G Schwern E<lt>schwern@pobox.comE<gt>.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See F<http://www.perl.com/perl/misc/Artistic.html>
+
+=cut
+
+1;
diff --git a/trunk/Examples/test-suite/perl5/aggregate_runme.pl b/trunk/Examples/test-suite/perl5/aggregate_runme.pl
new file mode 100644
index 000000000..148ec94a8
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/aggregate_runme.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('aggregate') }
+require_ok('aggregate');
+
+# adapted from ../java/aggregate_runme.java
+
+# Confirm that move() returns correct results under normal use
+is(aggregate::move($aggregate::UP), $aggregate::UP, "UP");
+
+is(aggregate::move($aggregate::DOWN), $aggregate::DOWN, "DOWN");
+
+is(aggregate::move($aggregate::LEFT), $aggregate::LEFT, "LEFT");
+
+is(aggregate::move($aggregate::RIGHT), $aggregate::RIGHT, "RIGHT");
+
+# Confirm that move() raises an exception when the contract is violated
+eval { aggregate::move(0) };
+like($@, qr/\bRuntimeError\b/);
+
diff --git a/trunk/Examples/test-suite/perl5/apply_signed_char_runme.pl b/trunk/Examples/test-suite/perl5/apply_signed_char_runme.pl
new file mode 100644
index 000000000..d39e4c329
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/apply_signed_char_runme.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 12;
+BEGIN { use_ok('apply_signed_char') }
+require_ok('apply_signed_char');
+
+# adapted from ../java/apply_signed_char_runme.java
+
+my $smallnum = -127;
+is(apply_signed_char::CharValFunction($smallnum), $smallnum);
+is(apply_signed_char::CCharValFunction($smallnum), $smallnum);
+is(apply_signed_char::CCharRefFunction($smallnum), $smallnum);
+
+$apply_signed_char::globalchar = $smallnum;
+is($apply_signed_char::globalchar, $smallnum);
+is($apply_signed_char::globalconstchar, -110);
+
+my $d = new apply_signed_char::DirectorTest();
+is($d->CharValFunction($smallnum), $smallnum);
+is($d->CCharValFunction($smallnum), $smallnum);
+is($d->CCharRefFunction($smallnum), $smallnum);
+
+$d->{memberchar} = $smallnum;
+is($d->{memberchar}, $smallnum);
+is($d->{memberconstchar}, -112);
diff --git a/trunk/Examples/test-suite/perl5/apply_strings_runme.pl b/trunk/Examples/test-suite/perl5/apply_strings_runme.pl
new file mode 100644
index 000000000..2cb54d16b
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/apply_strings_runme.pl
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('apply_strings') }
+require_ok('apply_strings');
+
+my $TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+is(apply_strings::UCharFunction($TEST_MESSAGE), $TEST_MESSAGE, "UCharFunction");
+
+is(apply_strings::SCharFunction($TEST_MESSAGE), $TEST_MESSAGE, "SCharFunction");
diff --git a/trunk/Examples/test-suite/perl5/array_member_runme.pl b/trunk/Examples/test-suite/perl5/array_member_runme.pl
new file mode 100644
index 000000000..77d28fe9d
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/array_member_runme.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 18;
+BEGIN { use_ok('array_member') }
+require_ok('array_member');
+
+my $f = array_member::Foo->new();
+$f->{data} = $array_member::global_data;
+
+for(my $i=0; $i<8; $i++) {
+ is( array_member::get_value($f->{data},$i),
+ array_member::get_value($array_member::global_data,$i),
+ "array assignment");
+}
+
+for(my $i=0; $i<8; $i++) {
+ array_member::set_value($f->{data},$i,-$i);
+}
+
+$array_member::global_data = $f->{data};
+
+for(my $i=0; $i<8; $i++) {
+ is(array_member::get_value($f->{data},$i),
+ array_member::get_value($array_member::global_data,$i),
+ "array assignment");
+}
+
diff --git a/trunk/Examples/test-suite/perl5/char_strings_runme.pl b/trunk/Examples/test-suite/perl5/char_strings_runme.pl
new file mode 100644
index 000000000..c4573737e
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/char_strings_runme.pl
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('char_strings') }
+require_ok('char_strings');
+
+my $val1 = "100";
+is(char_strings::CharPingPong($val1), "100", 'cstr1');
+
+my $val2 = "greetings";
+is(char_strings::CharPingPong($val2), "greetings", 'cstr2');
+
+# SF#2564192
+"this is a test" =~ /(\w+)$/;
+is(char_strings::CharPingPong($1), "test", "handles Magical");
diff --git a/trunk/Examples/test-suite/perl5/class_ignore_runme.pl b/trunk/Examples/test-suite/perl5/class_ignore_runme.pl
new file mode 100755
index 000000000..989150c3f
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/class_ignore_runme.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('class_ignore') }
+require_ok('class_ignore');
+
+# adapted from ../python/class_ignore_runme.py
+
+my $a = class_ignore::Bar->new();
+
+is(class_ignore::do_blah($a), "Bar::blah");
diff --git a/trunk/Examples/test-suite/perl5/contract_runme.pl b/trunk/Examples/test-suite/perl5/contract_runme.pl
new file mode 100755
index 000000000..fb162e691
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/contract_runme.pl
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 32;
+BEGIN { use_ok('contract') }
+require_ok('contract');
+
+# adapted from ../python/contract_runme.py
+{
+ ok(contract::test_preassert(1,2), "good preassertion");
+ eval { contract::test_preassert(-1) };
+ like($@, qr/\bRuntimeError\b/, "bad preassertion");
+
+ ok(contract::test_postassert(3), "good postassertion");
+ eval { contract::test_postassert(-3) };
+ like($@, qr/\bRuntimeError\b/, "bad postassertion");
+
+ ok(contract::test_prepost(2,3), "good prepost");
+ ok(contract::test_prepost(5,-4), "good prepost");
+ eval { contract::test_prepost(-3,4); };
+ like($@, qr/\bRuntimeError\b/, "bad preassertion");
+ eval { contract::test_prepost(4,-10) };
+ like($@, qr/\bRuntimeError\b/, "bad postassertion");
+}
+{
+ my $f = contract::Foo->new();
+ ok($f->test_preassert(4,5), "method pre");
+ eval { $f->test_preassert(-2,3) };
+ like($@, qr/\bRuntimeError\b/, "method pre bad");
+
+ ok($f->test_postassert(4), "method post");
+ eval { $f->test_postassert(-4) };
+ like($@, qr/\bRuntimeError\b/, "method post bad");
+
+ ok($f->test_prepost(3,4), "method prepost");
+ ok($f->test_prepost(4,-3), "method prepost");
+ eval { $f->test_prepost(-4,2) };
+ like($@, qr/\bRuntimeError\b/, "method pre bad");
+ eval { $f->test_prepost(4,-10) };
+ like($@, qr/\bRuntimeError\b/, "method post bad");
+}
+{
+ ok(contract::Foo::stest_prepost(4,0), "static method prepost");
+ eval { contract::Foo::stest_prepost(-4,2) };
+ like($@, qr/\bRuntimeError\b/, "static method pre bad");
+ eval { contract::Foo::stest_prepost(4,-10) };
+ like($@, qr/\bRuntimeError\b/, "static method post bad");
+}
+{
+ my $b = contract::Bar->new();
+ eval { $b->test_prepost(2,-4) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre bad");
+}
+{
+ my $d = contract::D->new();
+ eval { $d->foo(-1,1,1,1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->foo(1,-1,1,1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->foo(1,1,-1,1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->foo(1,1,1,-1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->foo(1,1,1,1,-1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+
+ eval { $d->bar(-1,1,1,1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->bar(1,-1,1,1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->bar(1,1,-1,1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->bar(1,1,1,-1,1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+ eval { $d->bar(1,1,1,1,-1) };
+ like($@, qr/\bRuntimeError\b/, "inherit pre D");
+}
+
diff --git a/trunk/Examples/test-suite/perl5/default_args_runme.pl b/trunk/Examples/test-suite/perl5/default_args_runme.pl
new file mode 100644
index 000000000..8d0d2689b
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/default_args_runme.pl
@@ -0,0 +1,85 @@
+use strict;
+use warnings;
+use Test::More tests => 40;
+BEGIN { use_ok('default_args') }
+require_ok('default_args');
+
+my $true = 1;
+my $false = '';
+
+is(default_args::anonymous(), 7771, "anonymous (1)");
+is(default_args::anonymous(1234), 1234, "anonymous (2)");
+
+is(default_args::booltest(), $true, "booltest (1)");
+is(default_args::booltest($true), $true, "booltest (2)");
+is(default_args::booltest($false), $false, "booltest (3)");
+
+my $ec = new default_args::EnumClass();
+is($ec->blah(), $true, "EnumClass");
+
+is(default_args::casts1(), undef, "casts1");
+is(default_args::casts2(), "Hello", "casts2");
+is(default_args::casts1("Ciao"), "Ciao", "casts1 not default");
+is(default_args::chartest1(), 'x', "chartest1");
+is(default_args::chartest2(), "\0", "chartest2");
+is(default_args::chartest1('y'), 'y', "chartest1 not default");
+is(default_args::reftest1(), 42, "reftest1");
+is(default_args::reftest1(400), 400, "reftest1 not default");
+is(default_args::reftest2(), "hello", "reftest2");
+
+# rename
+my $foo = new default_args::Foo();
+can_ok($foo, qw(newname renamed3arg renamed2arg renamed1arg));
+eval {
+ $foo->newname();
+ $foo->newname(10);
+ $foo->renamed3arg(10, 10.0);
+ $foo->renamed2arg(10);
+ $foo->renamed1arg();
+};
+ok(not($@), '%rename handling');
+
+# exception specifications
+eval { default_args::exceptionspec() };
+is($@, "ciao", "exceptionspec 1");
+eval { default_args::exceptionspec(-1) };
+is($@, "ciao", "exceptionspec 2");
+eval { default_args::exceptionspec(100) };
+is($@, '100', "exceptionspec 3");
+
+my $ex = new default_args::Except($false);
+
+my $hit = 0;
+eval { $ex->exspec(); $hit = 1; };
+# a zero was thrown, an exception occured, but $@ is false
+is($hit, 0, "exspec 1");
+eval { $ex->exspec(-1) };
+is($@, "ciao", "exspec 2");
+eval { $ex->exspec(100) };
+is($@, 100, "exspec 3");
+eval { $ex = default_args::Except->new($true) };
+is($@, -1, "Except constructor 1");
+eval { $ex = default_args::Except->new($true, -2) };
+is($@, -2, "Except constructor 2");
+
+#Default parameters in static class methods
+is(default_args::Statics::staticmethod(), 60, "staticmethod 1");
+is(default_args::Statics::staticmethod(100), 150, "staticmethod 2");
+is(default_args::Statics::staticmethod(100,200,300), 600, "staticmethod 3");
+
+my $tricky = new default_args::Tricky();
+is($tricky->privatedefault(), 200, "privatedefault");
+is($tricky->protectedint(), 2000, "protectedint");
+is($tricky->protecteddouble(), 987.654, "protecteddouble");
+is($tricky->functiondefault(), 500, "functiondefault");
+is($tricky->contrived(), 'X', "contrived");
+is(default_args::constructorcall()->{val}, -1, "constructorcall test 1");
+is(default_args::constructorcall(new default_args::Klass(2222))->{val},
+ 2222, "constructorcall test 2");
+is(default_args::constructorcall(new default_args::Klass())->{val},
+ -1, "constructorcall test 3");
+
+# const methods
+my $cm = new default_args::ConstMethods();
+is($cm->coo(), 20, "coo test 1");
+is($cm->coo(1.0), 20, "coo test 2");
diff --git a/trunk/Examples/test-suite/perl5/default_constructor_runme.pl b/trunk/Examples/test-suite/perl5/default_constructor_runme.pl
new file mode 100644
index 000000000..b43df9e0b
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/default_constructor_runme.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 20;
+BEGIN { use_ok('default_constructor') }
+require_ok('default_constructor');
+
+isa_ok(eval { default_constructor::A->new() }, "default_constructor::A");
+isa_ok(eval { default_constructor::AA->new() }, "default_constructor::AA");
+is( eval { default_constructor::B->new() }, undef, "private default constructor");
+isa_ok(eval { default_constructor::B->new(0, 0) }, "default_constructor::B");
+is( eval { default_constructor::BB->new() }, undef, "inherited private default constructor");
+is( eval { default_constructor::C->new() }, undef, "protected default constructor");
+isa_ok(eval { default_constructor::CC->new() }, "default_constructor::CC");
+is( eval { default_constructor::D->new() }, undef, "private constructor");
+is( eval { default_constructor::DD->new() }, undef, "inherited private constructor");
+{ local $TODO = "default_constructor.i disagrees with our result";
+is( eval { default_constructor::AD->new() }, undef, "MI on A, D");
+}
+isa_ok(eval { default_constructor::E->new() }, "default_constructor::E");
+isa_ok(eval { default_constructor::EE->new() }, "default_constructor::EE");
+{ local $TODO = "default_constructor.i disagrees with our result";
+is( eval { default_constructor::EB->new() }, undef, "MI on E, B");
+}
+{ local $TODO = "destructor hiding seems off";
+my $hit = 0;
+eval {
+ my $F = default_constructor::F->new();
+ undef $F;
+ $hit = 1;
+};
+ok(not($hit), "private destructor");
+$hit = 0;
+eval {
+ my $G = default_constructor::G->new();
+ undef $G;
+ $hit = 1;
+};
+ok(not($hit), "protected destructor");
+$hit = 0;
+eval {
+ my $G = default_constructor::GG->new();
+ undef $G;
+ $hit = 1;
+};
+ok(not($hit), "inherited protected destructor");
+}
+isa_ok(eval { default_constructor::HH->new(0, 0) }, "default_constructor::HH");
+is( eval { default_constructor::HH->new() }, undef, "templated protected constructor");
+
+# TODO: sort out what needs to be tested from OSRSpatialReferenceShadow
diff --git a/trunk/Examples/test-suite/perl5/disown_runme.pl b/trunk/Examples/test-suite/perl5/disown_runme.pl
new file mode 100644
index 000000000..0e8f8cb6b
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/disown_runme.pl
@@ -0,0 +1,10 @@
+use disown;
+
+if (1) {
+ $a = new disown::A();
+ $b = new disown::B();
+ $c = $b->acquire($a);
+}
+
+
+
diff --git a/trunk/Examples/test-suite/perl5/dynamic_cast_runme.pl b/trunk/Examples/test-suite/perl5/dynamic_cast_runme.pl
new file mode 100644
index 000000000..39406690e
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/dynamic_cast_runme.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('dynamic_cast') }
+require_ok('dynamic_cast');
+
+my $f = dynamic_cast::Foo->new();
+my $b = dynamic_cast::Bar->new();
+my $x = $f->blah();
+my $y = $b->blah();
+my $a = dynamic_cast::do_test($y);
+is($a, "Bar::test");
diff --git a/trunk/Examples/test-suite/perl5/enum_template_runme.pl b/trunk/Examples/test-suite/perl5/enum_template_runme.pl
new file mode 100755
index 000000000..bdaaa8534
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/enum_template_runme.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('enum_template') }
+require_ok('enum_template');
+
+# adapted from ../python/enum_template_runme.py
+
+is(enum_template::MakeETest(), 1);
+
+is(enum_template::TakeETest(0), undef);
diff --git a/trunk/Examples/test-suite/perl5/enum_thorough_runme.pl b/trunk/Examples/test-suite/perl5/enum_thorough_runme.pl
new file mode 100644
index 000000000..66e719275
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/enum_thorough_runme.pl
@@ -0,0 +1,409 @@
+# an adaptation of ../java/enum_thorough_runme.java
+use strict;
+use warnings;
+use Test::More tests => 298;
+BEGIN { use_ok('enum_thorough') }
+require_ok('enum_thorough');
+
+is($enum_thorough::ReallyAnInteger, 200, "Test Anon 1");
+
+{
+ my $red = $enum_thorough::red;
+ is(enum_thorough::colourTest1($red), $red, "colourTest1");
+ is(enum_thorough::colourTest2($red), $red, "colourTest2");
+ is(enum_thorough::colourTest3($red), $red, "colourTest3");
+ is(enum_thorough::colourTest4($red), $red, "colourTest4");
+ isnt($enum_thorough::myColour, $red, "colour global get");
+ $enum_thorough::myColour = $red;
+ is($enum_thorough::myColour, $red, "colour global set");
+}
+{
+ my $s = enum_thorough::SpeedClass->new();
+ my $speed = $enum_thorough::SpeedClass::slow;
+ ok(defined($speed), "SpeedClass.slow");
+ is($s->speedTest1($speed), $speed, "speedTest 1");
+ is($s->speedTest2($speed), $speed, "speedTest 2");
+ is($s->speedTest3($speed), $speed, "speedTest 3");
+ is($s->speedTest4($speed), $speed, "speedTest 4");
+ is($s->speedTest5($speed), $speed, "speedTest 5");
+ is($s->speedTest6($speed), $speed, "speedTest 6");
+ is($s->speedTest7($speed), $speed, "speedTest 7");
+ is($s->speedTest8($speed), $speed, "speedTest 8");
+ is(enum_thorough::speedTest1($speed), $speed, "speedTest Global 1");
+ is(enum_thorough::speedTest2($speed), $speed, "speedTest Global 2");
+ is(enum_thorough::speedTest3($speed), $speed, "speedTest Global 3");
+ is(enum_thorough::speedTest4($speed), $speed, "speedTest Global 4");
+ is(enum_thorough::speedTest5($speed), $speed, "speedTest Global 5");
+}
+{
+ my $s = enum_thorough::SpeedClass->new();
+ my $slow = $enum_thorough::SpeedClass::slow;
+ my $lightning = $enum_thorough::SpeedClass::lightning;
+ is($s->{mySpeedtd1}, $slow, "mySpeedtd1 1");
+ is($s->{mySpeedtd1}, 10, "mySpeedtd1 2");
+ $s->{mySpeedtd1} = $lightning;
+ is($s->{mySpeedtd1}, $lightning, "mySpeedtd1 3");
+ is($s->{mySpeedtd1}, 31, "mySpeedtd1 4");
+}
+is(enum_thorough::namedanonTest1($enum_thorough::NamedAnon2),
+ $enum_thorough::NamedAnon2, "namedanonTest1");
+{
+ my $val = $enum_thorough::TwoNames2;
+ is(enum_thorough::twonamesTest1($val), $val, "twonamesTest 1");
+ is(enum_thorough::twonamesTest2($val), $val, "twonamesTest 2");
+ is(enum_thorough::twonamesTest3($val), $val, "twonamesTest 3");
+}
+{ local $TODO = "shouldn't namespaces drop into a package?";
+ my $val = $enum_thorough::AnonSpace::NamedAnonSpace2;
+ ok(defined($val), "found enum value");
+SKIP: {
+ skip "enum value not in expected package", 3 unless defined $val;
+ is(enum_thorough::namedanonspaceTest1($val), $val, "namedanonspaceTest 1");
+ is(enum_thorough::namedanonspaceTest2($val), $val, "namedanonspaceTest 2");
+ is(enum_thorough::namedanonspaceTest3($val), $val, "namedanonspaceTest 3");
+}}
+{
+ my $t = enum_thorough::TemplateClassInt->new();
+ my $galileo = $enum_thorough::TemplateClassInt::galileo;
+ is($t->scientistsTest1($galileo), $galileo, "scientistsTest 1");
+ is($t->scientistsTest2($galileo), $galileo, "scientistsTest 2");
+ is($t->scientistsTest3($galileo), $galileo, "scientistsTest 3");
+ is($t->scientistsTest4($galileo), $galileo, "scientistsTest 4");
+ is($t->scientistsTest5($galileo), $galileo, "scientistsTest 5");
+ is($t->scientistsTest6($galileo), $galileo, "scientistsTest 6");
+ is($t->scientistsTest7($galileo), $galileo, "scientistsTest 7");
+ is($t->scientistsTest8($galileo), $galileo, "scientistsTest 8");
+ is($t->scientistsTest9($galileo), $galileo, "scientistsTest 9");
+ is($t->scientistsTestB($galileo), $galileo, "scientistsTest B");
+ is($t->scientistsTestD($galileo), $galileo, "scientistsTest D");
+ is($t->scientistsTestE($galileo), $galileo, "scientistsTest E");
+ is($t->scientistsTestF($galileo), $galileo, "scientistsTest F");
+ is($t->scientistsTestG($galileo), $galileo, "scientistsTest G");
+ is($t->scientistsTestH($galileo), $galileo, "scientistsTest H");
+ is($t->scientistsTestI($galileo), $galileo, "scientistsTest I");
+ is($t->scientistsTestJ($galileo), $galileo, "scientistsTest J");
+
+ is(enum_thorough::scientistsTest1($galileo), $galileo, "scientistsTest Global 1");
+ is(enum_thorough::scientistsTest2($galileo), $galileo, "scientistsTest Global 2");
+ is(enum_thorough::scientistsTest3($galileo), $galileo, "scientistsTest Global 3");
+ is(enum_thorough::scientistsTest4($galileo), $galileo, "scientistsTest Global 4");
+ is(enum_thorough::scientistsTest5($galileo), $galileo, "scientistsTest Global 5");
+ is(enum_thorough::scientistsTest6($galileo), $galileo, "scientistsTest Global 6");
+ is(enum_thorough::scientistsTest7($galileo), $galileo, "scientistsTest Global 7");
+ is(enum_thorough::scientistsTest8($galileo), $galileo, "scientistsTest Global 8");
+}
+{
+ my $t = enum_thorough::TClassInt->new();
+ my $bell = $enum_thorough::TClassInt::bell;
+ my $galileo = $enum_thorough::TemplateClassInt::galileo;
+ is($t->scientistsNameTest1($bell), $bell, "scientistsNameTest 1");
+ is($t->scientistsNameTest2($bell), $bell, "scientistsNameTest 2");
+ is($t->scientistsNameTest3($bell), $bell, "scientistsNameTest 3");
+ is($t->scientistsNameTest4($bell), $bell, "scientistsNameTest 4");
+ is($t->scientistsNameTest5($bell), $bell, "scientistsNameTest 5");
+ is($t->scientistsNameTest6($bell), $bell, "scientistsNameTest 6");
+ is($t->scientistsNameTest7($bell), $bell, "scientistsNameTest 7");
+ is($t->scientistsNameTest8($bell), $bell, "scientistsNameTest 8");
+ is($t->scientistsNameTest9($bell), $bell, "scientistsNameTest 9");
+ is($t->scientistsNameTestB($bell), $bell, "scientistsNameTest B");
+ is($t->scientistsNameTestD($bell), $bell, "scientistsNameTest D");
+ is($t->scientistsNameTestE($bell), $bell, "scientistsNameTest E");
+ is($t->scientistsNameTestF($bell), $bell, "scientistsNameTest F");
+ is($t->scientistsNameTestG($bell), $bell, "scientistsNameTest G");
+ is($t->scientistsNameTestH($bell), $bell, "scientistsNameTest H");
+ is($t->scientistsNameTestI($bell), $bell, "scientistsNameTest I");
+
+ is($t->scientistsNameSpaceTest1($bell), $bell, "scientistsNameSpaceTest 1");
+ is($t->scientistsNameSpaceTest2($bell), $bell, "scientistsNameSpaceTest 2");
+ is($t->scientistsNameSpaceTest3($bell), $bell, "scientistsNameSpaceTest 3");
+ is($t->scientistsNameSpaceTest4($bell), $bell, "scientistsNameSpaceTest 4");
+ is($t->scientistsNameSpaceTest5($bell), $bell, "scientistsNameSpaceTest 5");
+ is($t->scientistsNameSpaceTest6($bell), $bell, "scientistsNameSpaceTest 6");
+ is($t->scientistsNameSpaceTest7($bell), $bell, "scientistsNameSpaceTest 7");
+
+ is($t->scientistsOtherTest1($galileo), $galileo, "scientistsOtherTest 1");
+ is($t->scientistsOtherTest2($galileo), $galileo, "scientistsOtherTest 2");
+ is($t->scientistsOtherTest3($galileo), $galileo, "scientistsOtherTest 3");
+ is($t->scientistsOtherTest4($galileo), $galileo, "scientistsOtherTest 4");
+ is($t->scientistsOtherTest5($galileo), $galileo, "scientistsOtherTest 5");
+ is($t->scientistsOtherTest6($galileo), $galileo, "scientistsOtherTest 6");
+ is($t->scientistsOtherTest7($galileo), $galileo, "scientistsOtherTest 7");
+
+ is(enum_thorough::scientistsNameTest1($bell), $bell, "scientistsNameTest Global 1");
+ is(enum_thorough::scientistsNameTest2($bell), $bell, "scientistsNameTest Global 2");
+ is(enum_thorough::scientistsNameTest3($bell), $bell, "scientistsNameTest Global 3");
+ is(enum_thorough::scientistsNameTest4($bell), $bell, "scientistsNameTest Global 4");
+ is(enum_thorough::scientistsNameTest5($bell), $bell, "scientistsNameTest Global 5");
+ is(enum_thorough::scientistsNameTest6($bell), $bell, "scientistsNameTest Global 6");
+ is(enum_thorough::scientistsNameTest7($bell), $bell, "scientistsNameTest Global 7");
+
+ is(enum_thorough::scientistsNameSpaceTest1($bell), $bell, "scientistsNameSpaceTest Global 1");
+ is(enum_thorough::scientistsNameSpaceTest2($bell), $bell, "scientistsNameSpaceTest Global 2");
+ is(enum_thorough::scientistsNameSpaceTest3($bell), $bell, "scientistsNameSpaceTest Global 3");
+ is(enum_thorough::scientistsNameSpaceTest4($bell), $bell, "scientistsNameSpaceTest Global 4");
+ is(enum_thorough::scientistsNameSpaceTest5($bell), $bell, "scientistsNameSpaceTest Global 5");
+ is(enum_thorough::scientistsNameSpaceTest6($bell), $bell, "scientistsNameSpaceTest Global 6");
+ is(enum_thorough::scientistsNameSpaceTest7($bell), $bell, "scientistsNameSpaceTest Global 7");
+
+ is(enum_thorough::scientistsNameSpaceTest8($bell), $bell, "scientistsNameSpaceTest Global 8");
+ is(enum_thorough::scientistsNameSpaceTest9($bell), $bell, "scientistsNameSpaceTest Global 9");
+ is(enum_thorough::scientistsNameSpaceTestA($bell), $bell, "scientistsNameSpaceTest Global A");
+ is(enum_thorough::scientistsNameSpaceTestB($bell), $bell, "scientistsNameSpaceTest Global B");
+ is(enum_thorough::scientistsNameSpaceTestC($bell), $bell, "scientistsNameSpaceTest Global C");
+ is(enum_thorough::scientistsNameSpaceTestD($bell), $bell, "scientistsNameSpaceTest Global D");
+ is(enum_thorough::scientistsNameSpaceTestE($bell), $bell, "scientistsNameSpaceTest Global E");
+
+ is(enum_thorough::scientistsNameSpaceTestF($bell), $bell, "scientistsNameSpaceTest Global F");
+ is(enum_thorough::scientistsNameSpaceTestG($bell), $bell, "scientistsNameSpaceTest Global G");
+ is(enum_thorough::scientistsNameSpaceTestH($bell), $bell, "scientistsNameSpaceTest Global H");
+ is(enum_thorough::scientistsNameSpaceTestI($bell), $bell, "scientistsNameSpaceTest Global I");
+ is(enum_thorough::scientistsNameSpaceTestJ($bell), $bell, "scientistsNameSpaceTest Global J");
+ is(enum_thorough::scientistsNameSpaceTestK($bell), $bell, "scientistsNameSpaceTest Global K");
+ is(enum_thorough::scientistsNameSpaceTestL($bell), $bell, "scientistsNameSpaceTest Global L");
+}
+{
+ my $val = $enum_thorough::argh;
+ is(enum_thorough::renameTest1($val), $val, "renameTest Global 1");
+ is(enum_thorough::renameTest2($val), $val, "renameTest Global 2");
+}
+{
+ my $n = enum_thorough::NewNameStruct->new();
+ is($n->renameTest1($enum_thorough::NewNameStruct::bang), $enum_thorough::NewNameStruct::bang, "renameTest 1");
+ is($n->renameTest2($enum_thorough::NewNameStruct::bang), $enum_thorough::NewNameStruct::bang, "renameTest 2");
+ is($n->renameTest3($enum_thorough::NewNameStruct::simple1), $enum_thorough::NewNameStruct::simple1, "renameTest 3");
+ is($n->renameTest4($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest 4");
+ is($n->renameTest5($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest 5");
+ is($n->renameTest6($enum_thorough::NewNameStruct::singlename1), $enum_thorough::NewNameStruct::singlename1, "renameTest 6");
+}
+{
+ is(enum_thorough::renameTest3($enum_thorough::NewNameStruct::bang), $enum_thorough::NewNameStruct::bang, "renameTest Global 3");
+ is(enum_thorough::renameTest4($enum_thorough::NewNameStruct::simple1), $enum_thorough::NewNameStruct::simple1, "renameTest Global 4");
+ is(enum_thorough::renameTest5($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest Global 5");
+ is(enum_thorough::renameTest6($enum_thorough::NewNameStruct::doublename1), $enum_thorough::NewNameStruct::doublename1, "renameTest Global 6");
+ is(enum_thorough::renameTest7($enum_thorough::NewNameStruct::singlename1), $enum_thorough::NewNameStruct::singlename1, "renameTest Global 7");
+}
+{
+ my $t = enum_thorough::TreesClass->new();
+ my $pine = $enum_thorough::TreesClass::pine;
+ is($t->treesTest1($pine), $pine, "treesTest 1");
+ is($t->treesTest2($pine), $pine, "treesTest 2");
+ is($t->treesTest3($pine), $pine, "treesTest 3");
+ is($t->treesTest4($pine), $pine, "treesTest 4");
+ is($t->treesTest5($pine), $pine, "treesTest 5");
+ is($t->treesTest6($pine), $pine, "treesTest 6");
+ is($t->treesTest7($pine), $pine, "treesTest 7");
+ is($t->treesTest8($pine), $pine, "treesTest 8");
+ is($t->treesTest9($pine), $pine, "treesTest 9");
+ is($t->treesTestA($pine), $pine, "treesTest A");
+ is($t->treesTestB($pine), $pine, "treesTest B");
+ is($t->treesTestC($pine), $pine, "treesTest C");
+ is($t->treesTestD($pine), $pine, "treesTest D");
+ is($t->treesTestE($pine), $pine, "treesTest E");
+ is($t->treesTestF($pine), $pine, "treesTest F");
+ is($t->treesTestG($pine), $pine, "treesTest G");
+ is($t->treesTestH($pine), $pine, "treesTest H");
+ is($t->treesTestI($pine), $pine, "treesTest I");
+ is($t->treesTestJ($pine), $pine, "treesTest J");
+ is($t->treesTestK($pine), $pine, "treesTest K");
+ is($t->treesTestL($pine), $pine, "treesTest L");
+ is($t->treesTestM($pine), $pine, "treesTest M");
+ is($t->treesTestN($pine), $pine, "treesTest N");
+ is($t->treesTestO($pine), $pine, "treesTest O");
+
+ is(enum_thorough::treesTest1($pine), $pine, "treesTest Global 1");
+ is(enum_thorough::treesTest2($pine), $pine, "treesTest Global 2");
+ is(enum_thorough::treesTest3($pine), $pine, "treesTest Global 3");
+ is(enum_thorough::treesTest4($pine), $pine, "treesTest Global 4");
+ is(enum_thorough::treesTest5($pine), $pine, "treesTest Global 5");
+ is(enum_thorough::treesTest6($pine), $pine, "treesTest Global 6");
+ is(enum_thorough::treesTest7($pine), $pine, "treesTest Global 7");
+ is(enum_thorough::treesTest8($pine), $pine, "treesTest Global 8");
+ is(enum_thorough::treesTest9($pine), $pine, "treesTest Global 9");
+ is(enum_thorough::treesTestA($pine), $pine, "treesTest Global A");
+ is(enum_thorough::treesTestB($pine), $pine, "treesTest Global B");
+ is(enum_thorough::treesTestC($pine), $pine, "treesTest Global C");
+ is(enum_thorough::treesTestD($pine), $pine, "treesTest Global D");
+ is(enum_thorough::treesTestE($pine), $pine, "treesTest Global E");
+ is(enum_thorough::treesTestF($pine), $pine, "treesTest Global F");
+ is(enum_thorough::treesTestG($pine), $pine, "treesTest Global G");
+ is(enum_thorough::treesTestH($pine), $pine, "treesTest Global H");
+ is(enum_thorough::treesTestI($pine), $pine, "treesTest Global I");
+ is(enum_thorough::treesTestJ($pine), $pine, "treesTest Global J");
+ is(enum_thorough::treesTestK($pine), $pine, "treesTest Global K");
+ is(enum_thorough::treesTestL($pine), $pine, "treesTest Global L");
+ is(enum_thorough::treesTestM($pine), $pine, "treesTest Global M");
+ is(enum_thorough::treesTestO($pine), $pine, "treesTest Global O");
+ is(enum_thorough::treesTestP($pine), $pine, "treesTest Global P");
+ is(enum_thorough::treesTestQ($pine), $pine, "treesTest Global Q");
+ is(enum_thorough::treesTestR($pine), $pine, "treesTest Global R");
+}
+{
+ my $h = enum_thorough::HairStruct->new();
+ my $ginger = $enum_thorough::HairStruct::ginger;
+
+ is($h->hairTest1($ginger), $ginger, "hairTest 1");
+ is($h->hairTest2($ginger), $ginger, "hairTest 2");
+ is($h->hairTest3($ginger), $ginger, "hairTest 3");
+ is($h->hairTest4($ginger), $ginger, "hairTest 4");
+ is($h->hairTest5($ginger), $ginger, "hairTest 5");
+ is($h->hairTest6($ginger), $ginger, "hairTest 6");
+ is($h->hairTest7($ginger), $ginger, "hairTest 7");
+ is($h->hairTest8($ginger), $ginger, "hairTest 8");
+ is($h->hairTest9($ginger), $ginger, "hairTest 9");
+ is($h->hairTestA($ginger), $ginger, "hairTest A");
+ is($h->hairTestB($ginger), $ginger, "hairTest B");
+
+ my $red = $enum_thorough::red;
+ is($h->colourTest1($red), $red, "colourTest HairStruct 1");
+ is($h->colourTest2($red), $red, "colourTest HairStruct 2");
+ is($h->namedanonTest1($enum_thorough::NamedAnon2), $enum_thorough::NamedAnon2, "namedanonTest HairStruct 1");
+{ local $TODO = "shouldn't namespaces drop into a package?";
+ ok(defined($enum_thorough::AnonSpace::NamedAnonSpace2), "found enum value");
+SKIP: {
+ skip "enum value not in expected package", 1 unless defined $enum_thorough::AnonSpace::NamedAnonSpace2;
+ is($h->namedanonspaceTest1($enum_thorough::AnonSpace::NamedAnonSpace2), $enum_thorough::AnonSpace::NamedAnonSpace2, "namedanonspaceTest HairStruct 1");
+}}
+
+
+ my $fir = $enum_thorough::TreesClass::fir;
+ is($h->treesGlobalTest1($fir), $fir, "treesGlobalTest1 HairStruct 1");
+ is($h->treesGlobalTest2($fir), $fir, "treesGlobalTest1 HairStruct 2");
+ is($h->treesGlobalTest3($fir), $fir, "treesGlobalTest1 HairStruct 3");
+ is($h->treesGlobalTest4($fir), $fir, "treesGlobalTest1 HairStruct 4");
+}
+{
+ my $blonde = $enum_thorough::HairStruct::blonde;
+ is(enum_thorough::hairTest1($blonde), $blonde, "hairTest Global 1");
+ is(enum_thorough::hairTest2($blonde), $blonde, "hairTest Global 2");
+ is(enum_thorough::hairTest3($blonde), $blonde, "hairTest Global 3");
+ is(enum_thorough::hairTest4($blonde), $blonde, "hairTest Global 4");
+ is(enum_thorough::hairTest5($blonde), $blonde, "hairTest Global 5");
+ is(enum_thorough::hairTest6($blonde), $blonde, "hairTest Global 6");
+ is(enum_thorough::hairTest7($blonde), $blonde, "hairTest Global 7");
+ is(enum_thorough::hairTest8($blonde), $blonde, "hairTest Global 8");
+ is(enum_thorough::hairTest9($blonde), $blonde, "hairTest Global 9");
+ is(enum_thorough::hairTestA($blonde), $blonde, "hairTest Global A");
+ is(enum_thorough::hairTestB($blonde), $blonde, "hairTest Global B");
+ is(enum_thorough::hairTestC($blonde), $blonde, "hairTest Global C");
+
+ is(enum_thorough::hairTestA1($blonde), $blonde, "hairTest Global A1");
+ is(enum_thorough::hairTestA2($blonde), $blonde, "hairTest Global A2");
+ is(enum_thorough::hairTestA3($blonde), $blonde, "hairTest Global A3");
+ is(enum_thorough::hairTestA4($blonde), $blonde, "hairTest Global A4");
+ is(enum_thorough::hairTestA5($blonde), $blonde, "hairTest Global A5");
+ is(enum_thorough::hairTestA6($blonde), $blonde, "hairTest Global A6");
+ is(enum_thorough::hairTestA7($blonde), $blonde, "hairTest Global A7");
+ is(enum_thorough::hairTestA8($blonde), $blonde, "hairTest Global A8");
+ is(enum_thorough::hairTestA9($blonde), $blonde, "hairTest Global A9");
+ is(enum_thorough::hairTestAA($blonde), $blonde, "hairTest Global AA");
+ is(enum_thorough::hairTestAB($blonde), $blonde, "hairTest Global AB");
+ is(enum_thorough::hairTestAC($blonde), $blonde, "hairTest Global AC");
+
+ is(enum_thorough::hairTestB1($blonde), $blonde, "hairTest Global B1");
+ is(enum_thorough::hairTestB2($blonde), $blonde, "hairTest Global B2");
+ is(enum_thorough::hairTestB3($blonde), $blonde, "hairTest Global B3");
+ is(enum_thorough::hairTestB4($blonde), $blonde, "hairTest Global B4");
+ is(enum_thorough::hairTestB5($blonde), $blonde, "hairTest Global B5");
+ is(enum_thorough::hairTestB6($blonde), $blonde, "hairTest Global B6");
+ is(enum_thorough::hairTestB7($blonde), $blonde, "hairTest Global B7");
+ is(enum_thorough::hairTestB8($blonde), $blonde, "hairTest Global B8");
+ is(enum_thorough::hairTestB9($blonde), $blonde, "hairTest Global B9");
+ is(enum_thorough::hairTestBA($blonde), $blonde, "hairTest Global BA");
+ is(enum_thorough::hairTestBB($blonde), $blonde, "hairTest Global BB");
+ is(enum_thorough::hairTestBC($blonde), $blonde, "hairTest Global BC");
+
+ is(enum_thorough::hairTestC1($blonde), $blonde, "hairTest Global C1");
+ is(enum_thorough::hairTestC2($blonde), $blonde, "hairTest Global C2");
+ is(enum_thorough::hairTestC3($blonde), $blonde, "hairTest Global C3");
+ is(enum_thorough::hairTestC4($blonde), $blonde, "hairTest Global C4");
+ is(enum_thorough::hairTestC5($blonde), $blonde, "hairTest Global C5");
+ is(enum_thorough::hairTestC6($blonde), $blonde, "hairTest Global C6");
+ is(enum_thorough::hairTestC7($blonde), $blonde, "hairTest Global C7");
+ is(enum_thorough::hairTestC8($blonde), $blonde, "hairTest Global C8");
+ is(enum_thorough::hairTestC9($blonde), $blonde, "hairTest Global C9");
+ is(enum_thorough::hairTestCA($blonde), $blonde, "hairTest Global CA");
+ is(enum_thorough::hairTestCB($blonde), $blonde, "hairTest Global CB");
+ is(enum_thorough::hairTestCC($blonde), $blonde, "hairTest Global CC");
+}
+{
+ my $f = enum_thorough::FirStruct->new();
+ my $blonde = $enum_thorough::HairStruct::blonde;
+
+ is($f->hairTestFir1($blonde), $blonde, "hairTestFir 1");
+ is($f->hairTestFir2($blonde), $blonde, "hairTestFir 2");
+ is($f->hairTestFir3($blonde), $blonde, "hairTestFir 3");
+ is($f->hairTestFir4($blonde), $blonde, "hairTestFir 4");
+ is($f->hairTestFir5($blonde), $blonde, "hairTestFir 5");
+ is($f->hairTestFir6($blonde), $blonde, "hairTestFir 6");
+ is($f->hairTestFir7($blonde), $blonde, "hairTestFir 7");
+ is($f->hairTestFir8($blonde), $blonde, "hairTestFir 8");
+ is($f->hairTestFir9($blonde), $blonde, "hairTestFir 9");
+ is($f->hairTestFirA($blonde), $blonde, "hairTestFir A");
+}
+{
+ $enum_thorough::GlobalInstance = $enum_thorough::globalinstance2;
+ is($enum_thorough::GlobalInstance, $enum_thorough::globalinstance2, "GlobalInstance 1");
+
+ my $i = enum_thorough::Instances->new();
+ $i->{MemberInstance} = $enum_thorough::Instances::memberinstance3;
+ is($i->{MemberInstance}, $enum_thorough::Instances::memberinstance3, "MemberInstance 1");
+}
+# ignore enum item tests start
+{
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_zero), 0, "ignoreATest 0");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_three), 3, "ignoreATest 3");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_ten), 10, "ignoreATest 10");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_eleven), 11, "ignoreATest 11");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirteen), 13, "ignoreATest 13");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_fourteen), 14, "ignoreATest 14");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_twenty), 20, "ignoreATest 20");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty), 30, "ignoreATest 30");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_two), 32, "ignoreATest 32");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_three), 33, "ignoreATest 33");
+}
+{
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_eleven), 11, "ignoreBTest 11");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_twelve), 12, "ignoreBTest 12");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_one), 31, "ignoreBTest 31");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_two), 32, "ignoreBTest 32");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_one), 41, "ignoreBTest 41");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_two), 42, "ignoreBTest 42");
+}
+{
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_ten), 10, "ignoreCTest 10");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_twelve), 12, "ignoreCTest 12");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty), 30, "ignoreCTest 30");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty_two), 32, "ignoreCTest 32");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty), 40, "ignoreCTest 40");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty_two), 42, "ignoreCTest 42");
+}
+{
+ is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_one), 21, "ignoreDTest 21");
+ is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_two), 22, "ignoreDTest 22");
+}
+{
+ is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_zero), 0, "ignoreETest 0");
+ is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_one), 21, "ignoreETest 21");
+ is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_two), 22, "ignoreETest 22");
+}
+# ignore enum item tests end
+{
+ is(enum_thorough::repeatTest($enum_thorough::one), 1, "repeatTest 1");
+ is(enum_thorough::repeatTest($enum_thorough::initial), 1, "repeatTest 2");
+ is(enum_thorough::repeatTest($enum_thorough::two), 2, "repeatTest 3");
+ is(enum_thorough::repeatTest($enum_thorough::three), 3, "repeatTest 4");
+ is(enum_thorough::repeatTest($enum_thorough::llast), 3, "repeatTest 5");
+ is(enum_thorough::repeatTest($enum_thorough::end), 3, "repeatTest 6");
+}
+
+# these were the preexisting Perl testcases before the port.
+
+# Just test an in and out typemap for enum SWIGTYPE and const enum SWIGTYPE & typemaps
+is(enum_thorough::speedTest4($enum_thorough::SpeedClass::slow),
+ $enum_thorough::SpeedClass::slow, "speedTest Global 4");
+is(enum_thorough::speedTest5($enum_thorough::SpeedClass::slow),
+ $enum_thorough::SpeedClass::slow, "speedTest Global 5");
+is(enum_thorough::speedTest4($enum_thorough::SpeedClass::fast),
+ $enum_thorough::SpeedClass::fast, "speedTest Global 4");
+is(enum_thorough::speedTest5($enum_thorough::SpeedClass::fast),
+ $enum_thorough::SpeedClass::fast, "speedTest Global 5");
diff --git a/trunk/Examples/test-suite/perl5/exception_order_runme.pl b/trunk/Examples/test-suite/perl5/exception_order_runme.pl
new file mode 100644
index 000000000..79b1b9dfa
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/exception_order_runme.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('exception_order') }
+require_ok('exception_order');
+
+# adapted from ../python/exception_order_runme.py
+
+my $a = exception_order::A->new();
+
+eval { $a->foo() };
+isa_ok($@, "exception_order::E1");
+
+eval { $a->bar() };
+isa_ok($@, "exception_order::E2");
+
+eval { $a->foobar() };
+like($@, qr/\bpostcatch unknown\b/);
+
+eval { $a->barfoo(1) };
+isa_ok($@, "exception_order::E1");
+
+eval { $a->barfoo(2) };
+isa_ok($@, "exception_order::E2");
diff --git a/trunk/Examples/test-suite/perl5/global_vars_runme.pl b/trunk/Examples/test-suite/perl5/global_vars_runme.pl
new file mode 100644
index 000000000..b645f7bac
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/global_vars_runme.pl
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('global_vars') }
+require_ok('global_vars');
+
+my $an = new global_vars::A();
+isa_ok($an, 'global_vars::A');
+$global_vars::ap = $an;
+is($global_vars::ap, $an, "global var assignment");
+
diff --git a/trunk/Examples/test-suite/perl5/grouping_runme.pl b/trunk/Examples/test-suite/perl5/grouping_runme.pl
new file mode 100755
index 000000000..2009cce73
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/grouping_runme.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 6;
+BEGIN { use_ok('grouping') }
+require_ok('grouping');
+
+# adapted from ../python/grouping_runme.py
+
+is(grouping::test1(42), 42);
+
+isnt(eval { grouping::test2(42) }, undef);
+
+is(grouping::do_unary(37, $grouping::NEGATE), -37);
+
+$grouping::test3 = 42;
+is($grouping::test3, 42);
diff --git a/trunk/Examples/test-suite/perl5/ignore_parameter_runme.pl b/trunk/Examples/test-suite/perl5/ignore_parameter_runme.pl
new file mode 100755
index 000000000..8e75e0b0e
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/ignore_parameter_runme.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 14;
+BEGIN { use_ok('ignore_parameter') }
+require_ok('ignore_parameter');
+
+# adapted from ../java/ignore_parameter_runme.java
+
+# Runtime test checking the %typemap(ignore) macro
+
+# Compilation will ensure the number of arguments and type are correct.
+# Then check the return value is the same as the value given to the ignored parameter.
+is(ignore_parameter::jaguar(200, 0.0), "hello", "jaguar()");
+is(ignore_parameter::lotus("fast", 0.0), 101, "lotus()");
+is(ignore_parameter::tvr("fast", 200), 8.8, "tvr()");
+is(ignore_parameter::ferrari(), 101, "ferrari()");
+
+my $sc = new ignore_parameter::SportsCars();
+is($sc->daimler(200, 0.0), "hello", "daimler()");
+is($sc->astonmartin("fast", 0.0), 101, "astonmartin()");
+is($sc->bugatti("fast", 200), 8.8, "bugatti()");
+is($sc->lamborghini(), 101, "lamborghini()");
+
+# Check constructors are also generated correctly
+my $mc = eval { new ignore_parameter::MiniCooper(200, 0.0) };
+isa_ok($mc, 'ignore_parameter::MiniCooper');
+my $mm = eval { new ignore_parameter::MorrisMinor("slow", 0.0) };
+isa_ok($mm, 'ignore_parameter::MorrisMinor');
+my $fa = eval { new ignore_parameter::FordAnglia("slow", 200) };
+isa_ok($fa, 'ignore_parameter::FordAnglia');
+my $aa = eval { new ignore_parameter::AustinAllegro() };
+isa_ok($aa, 'ignore_parameter::AustinAllegro');
diff --git a/trunk/Examples/test-suite/perl5/import_nomodule_runme.pl b/trunk/Examples/test-suite/perl5/import_nomodule_runme.pl
new file mode 100644
index 000000000..f2136c1bf
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/import_nomodule_runme.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('import_nomodule') }
+require_ok('import_nomodule');
+
+my $f = import_nomodule::create_Foo();
+import_nomodule::test1($f,42);
+ok(1, "basecase");
+
+my $b = new import_nomodule::Bar();
+import_nomodule::test1($b,37);
+ok(1, "testcase");
diff --git a/trunk/Examples/test-suite/perl5/imports_runme.pl b/trunk/Examples/test-suite/perl5/imports_runme.pl
new file mode 100644
index 000000000..fd730fedf
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/perl5/inctest_runme.pl b/trunk/Examples/test-suite/perl5/inctest_runme.pl
new file mode 100644
index 000000000..db78c6615
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/inctest_runme.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('inctest') }
+require_ok('inctest');
+
+my $things = inctest::MY_THINGS->new();
+my $i = 0;
+$things->{IntegerMember} = $i;
+my $d = $things->{DoubleMember};
+ok(1);
diff --git a/trunk/Examples/test-suite/perl5/inherit_missing_runme.pl b/trunk/Examples/test-suite/perl5/inherit_missing_runme.pl
new file mode 100755
index 000000000..bc2260215
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/inherit_missing_runme.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('inherit_missing') }
+require_ok('inherit_missing');
+
+# adapted from ../python/inherit_missing_runme.py
+
+my $a = inherit_missing::new_Foo();
+my $b = inherit_missing::Bar->new();
+my $c = inherit_missing::Spam->new();
+
+is(inherit_missing::do_blah($a), "Foo::blah");
+
+is(inherit_missing::do_blah($b), "Bar::blah");
+
+is(inherit_missing::do_blah($c), "Spam::blah");
+
+inherit_missing::delete_Foo($a);
diff --git a/trunk/Examples/test-suite/perl5/inherit_runme.pl b/trunk/Examples/test-suite/perl5/inherit_runme.pl
new file mode 100644
index 000000000..3add80dea
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/inherit_runme.pl
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('inherit') }
+require_ok('inherit');
+
+my $der = new inherit::CDerived();
+is($der->Foo(), "CBase::Foo", "inherit test");
+
diff --git a/trunk/Examples/test-suite/perl5/li_carrays_runme.pl b/trunk/Examples/test-suite/perl5/li_carrays_runme.pl
new file mode 100644
index 000000000..00d12cd1b
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/li_carrays_runme.pl
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 38;
+BEGIN { use_ok('li_carrays') }
+require_ok('li_carrays');
+
+# array_class
+{
+ my $length = 5;
+ my $xyArray = new li_carrays::XYArray($length);
+ for (my $i=0; $i<$length; $i++) {
+ my $xy = $xyArray->getitem($i);
+ $xy->{x} = $i*10;
+ $xy->{y} = $i*100;
+ $xyArray->setitem($i, $xy);
+ }
+ for (my $i=0; $i<$length; $i++) {
+ is($xyArray->getitem($i)->{x}, $i*10);
+ is($xyArray->getitem($i)->{y}, $i*100);
+ }
+}
+
+{
+ # global array variable
+ my $length = 5;
+ my $xyArrayPointer = $li_carrays::globalXYArray;
+ my $xyArray = li_carrays::XYArray::frompointer($xyArrayPointer);
+ for (my $i=0; $i<$length; $i++) {
+ my $xy = $xyArray->getitem($i);
+ $xy->{x} = $i*10;
+ $xy->{y} = $i*100;
+ $xyArray->setitem($i, $xy);
+ }
+ for (my $i=0; $i<$length; $i++) {
+ is($xyArray->getitem($i)->{x}, $i*10);
+ is($xyArray->getitem($i)->{y}, $i*100);
+ }
+}
+
+# array_functions
+{
+ my $length = 5;
+ my $abArray = li_carrays::new_ABArray($length);
+ for (my $i=0; $i<$length; $i++) {
+ my $ab = li_carrays::ABArray_getitem($abArray, $i);
+ $ab->{a} = $i*10;
+ $ab->{b} = $i*100;
+ li_carrays::ABArray_setitem($abArray, $i, $ab);
+ }
+ for (my $i=0; $i<$length; $i++) {
+ is(li_carrays::ABArray_getitem($abArray, $i)->{a}, $i*10);
+ is(li_carrays::ABArray_getitem($abArray, $i)->{b}, $i*100);
+ }
+ li_carrays::delete_ABArray($abArray);
+}
+
+{
+ # global array variable
+ my $length = 3;
+ my $abArray = $li_carrays::globalABArray;
+ for (my $i=0; $i<$length; $i++) {
+ my $ab = li_carrays::ABArray_getitem($abArray, $i);
+ $ab->{a} = $i*10;
+ $ab->{b} = $i*100;
+ li_carrays::ABArray_setitem($abArray, $i, $ab);
+ }
+ for (my $i=0; $i<$length; $i++) {
+ is(li_carrays::ABArray_getitem($abArray, $i)->{a}, $i*10);
+ is(li_carrays::ABArray_getitem($abArray, $i)->{b}, $i*100);
+ }
+}
diff --git a/trunk/Examples/test-suite/perl5/li_cdata_carrays_runme.pl b/trunk/Examples/test-suite/perl5/li_cdata_carrays_runme.pl
new file mode 100644
index 000000000..133006e06
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/li_cdata_carrays_runme.pl
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('li_cdata_carrays') }
+require_ok('li_cdata_carrays');
+
+my $ia = li_cdata_carrays::intArray->new(5);
+for (0..4) {
+ $ia->setitem($_, $_**2);
+}
+ok(1, "setitems");
+my $x = pack q{I5}, map $_**2, (0..4);
+my $y = li_cdata_carrays::cdata_int($ia->cast, 5);
+is($x, $y, "carrays");
diff --git a/trunk/Examples/test-suite/perl5/li_reference_runme.pl b/trunk/Examples/test-suite/perl5/li_reference_runme.pl
new file mode 100644
index 000000000..afbd9e088
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/li_reference_runme.pl
@@ -0,0 +1,36 @@
+use strict;
+use warnings;
+use Test::More tests => 68;
+BEGIN { use_ok('li_reference') }
+require_ok('li_reference');
+
+sub chk { my($type, $call, $v1, $v2) = @_;
+ $li_reference::FrVal = $v1;
+ my $v = $v2;
+ eval { $call->(\$v) };
+ is($@, '', "$type check");
+ is($li_reference::ToVal, $v2, "$type out");
+ is($v, $v1, "$type in");
+}
+chk("double*", \&li_reference::PDouble, 12.2, 18.6);
+chk("double&", \&li_reference::RDouble, 32.5, 64.8);
+chk("float*", \&li_reference::PFloat, 64.5, 96.0);
+chk("float&", \&li_reference::RFloat, 98.5, 6.25);
+chk("int*", \&li_reference::PInt, 1887, 3356);
+chk("int&", \&li_reference::RInt, 2622, 9867);
+chk("short*", \&li_reference::PShort, 4752, 3254);
+chk("short&", \&li_reference::RShort, 1898, 5757);
+chk("long*", \&li_reference::PLong, 6687, 7132);
+chk("long&", \&li_reference::RLong, 8346, 4398);
+chk("uint*", \&li_reference::PUInt, 6853, 5529);
+chk("uint&", \&li_reference::RUInt, 5483, 7135);
+chk("ushort*", \&li_reference::PUShort, 9960, 9930);
+chk("ushort&", \&li_reference::RUShort, 1193, 4178);
+chk("ulong*", \&li_reference::PULong, 7960, 4788);
+chk("ulong&", \&li_reference::RULong, 8829, 1603);
+chk("uchar*", \&li_reference::PUChar, 110, 239);
+chk("uchar&", \&li_reference::RUChar, 15, 97);
+chk("char*", \&li_reference::PChar, -7, 118);
+chk("char&", \&li_reference::RChar, -3, -107);
+chk("bool*", \&li_reference::PBool, 0, 1);
+chk("bool&", \&li_reference::RBool, 1, 0);
diff --git a/trunk/Examples/test-suite/perl5/li_std_except_runme.pl b/trunk/Examples/test-suite/perl5/li_std_except_runme.pl
new file mode 100755
index 000000000..59d3126ea
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/li_std_except_runme.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 22;
+BEGIN { use_ok('li_std_except') }
+require_ok('li_std_except');
+
+# adapted from ../java/li_std_except_runme.java
+
+# these are not prescriptive tests, they just match the error classes I
+# found are currently being issued, we may want to provide a more
+# granular error api later, so don't let these tests stop code
+# improvements.
+
+my $test = new li_std_except::Test();
+eval { $test->throw_bad_exception() };
+like($@, qr/\bSystemError\b/, "throw_bad_exception");
+eval { $test->throw_domain_error() };
+like($@, qr/\bValueError\b/, "throw_domain_error");
+like($@, qr/\boops\b/, "throw_domain_error message");
+eval { $test->throw_exception() };
+like($@, qr/\bSystemError\b/, "throw_exception");
+eval { $test->throw_invalid_argument() };
+like($@, qr/\bValueError\b/, "throw_invalid_argument");
+like($@, qr/\boops\b/, "throw_invalid_argument message");
+eval { $test->throw_length_error() };
+like($@, qr/\bIndexError\b/, "throw_length_error");
+like($@, qr/\boops\b/, "throw_length_error message");
+eval { $test->throw_logic_error() };
+like($@, qr/\bRuntimeError\b/, "throw_logic_error");
+like($@, qr/\boops\b/, "throw_logic_error message");
+eval { $test->throw_out_of_range() };
+like($@, qr/\bIndexError\b/, "throw_out_of_range");
+like($@, qr/\boops\b/, "throw_out_of_range message");
+eval { $test->throw_overflow_error() };
+like($@, qr/\bOverflowError\b/, "throw_overflow_error");
+like($@, qr/\boops\b/, "throw_overflow_error message");
+eval { $test->throw_range_error() };
+like($@, qr/\bOverflowError\b/, "throw_range_error");
+like($@, qr/\boops\b/, "throw_range_error message");
+eval { $test->throw_runtime_error() };
+like($@, qr/\bRuntimeError\b/, "throw_runtime_error");
+like($@, qr/\boops\b/, "throw_runtime_error message");
+eval { $test->throw_underflow_error() };
+like($@, qr/\bOverflowError\b/, "throw_underflow_error");
+like($@, qr/\boops\b/, "throw_underflow_error message");
diff --git a/trunk/Examples/test-suite/perl5/li_std_string_runme.pl b/trunk/Examples/test-suite/perl5/li_std_string_runme.pl
new file mode 100644
index 000000000..9ec7dd08c
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/li_std_string_runme.pl
@@ -0,0 +1,113 @@
+use strict;
+use warnings;
+use Test::More tests => 30;
+BEGIN { use_ok('li_std_string') }
+require_ok('li_std_string');
+
+use Devel::Peek;
+# Checking expected use of %typemap(in) std::string {}
+li_std_string::test_value("Fee");
+
+# Checking expected result of %typemap(out) std::string {}
+is(li_std_string::test_value("Fi"), "Fi", "Test 1");
+
+
+# Verify type-checking for %typemap(in) std::string {}
+eval { li_std_string::test_value(undef) };
+like($@, qr/\bTypeError\b/, "Test 2");
+
+# Checking expected use of %typemap(in) const std::string & {}
+li_std_string::test_const_reference("Fo");
+
+# Checking expected result of %typemap(out) const std::string& {}
+is(li_std_string::test_const_reference("Fum"), "Fum", "Test 3");
+
+# Verify type-checking for %typemap(in) const std::string & {}
+eval { li_std_string::test_const_reference(undef) };
+like($@, qr/\bValueError\b/, "Test 4");
+
+#
+# Input and output typemaps for pointers and non-const references to
+# std::string are *not* supported; the following tests confirm
+# that none of these cases are slipping through.
+#
+
+my $stringPtr = undef;
+
+$stringPtr = li_std_string::test_pointer_out();
+
+li_std_string::test_pointer($stringPtr);
+
+$stringPtr = li_std_string::test_const_pointer_out();
+
+li_std_string::test_const_pointer($stringPtr);
+
+$stringPtr = li_std_string::test_reference_out();
+
+li_std_string::test_reference($stringPtr);
+
+# Check throw exception specification
+eval { li_std_string::test_throw() };
+is($@, "test_throw message", "Test 5");
+{ local $TODO = "why is the error not a Perl string?";
+eval { li_std_string::test_const_reference_throw() };
+is($@, "<some kind of string>", "Test 6");
+}
+
+# Global variables
+my $s = "initial string";
+is($li_std_string::GlobalString2, "global string 2", "GlobalString2 test 1");
+$li_std_string::GlobalString2 = $s;
+is($li_std_string::GlobalString2, $s, "GlobalString2 test 2");
+is($li_std_string::ConstGlobalString, "const global string", "ConstGlobalString test");
+
+# Member variables
+my $myStructure = new li_std_string::Structure();
+is($myStructure->{MemberString2}, "member string 2", "MemberString2 test 1");
+$myStructure->{MemberString2} = $s;
+is($myStructure->{MemberString2}, $s, "MemberString2 test 2");
+is($myStructure->{ConstMemberString}, "const member string", "ConstMemberString test");
+
+is($li_std_string::Structure::StaticMemberString2, "static member string 2", "StaticMemberString2 test 1");
+$li_std_string::Structure::StaticMemberString2 = $s;
+is($li_std_string::Structure::StaticMemberString2, $s, "StaticMemberString2 test 2");
+is($li_std_string::Structure::ConstStaticMemberString, "const static member string", "ConstStaticMemberString test");
+
+is(li_std_string::test_reference_input("hello"), "hello", "reference_input");
+
+is(li_std_string::test_reference_inout("hello"), "hellohello", "reference_inout");
+
+
+no strict;
+my $gen1 = new li_std_string::Foo();
+is($gen1->test(1), 2, "ulonglong");
+is($gen1->test("1"), "11", "ulonglong");
+is($gen1->testl(12345), 12346, "ulonglong small number");
+# Note: 32 bit builds of perl will fail this test as the number is stored internally in scientific notation
+# (USE_64_BIT_ALL probably needs defining when building Perl in order to avoid this)
+SKIP: {
+ skip "this Perl does not seem to do 64 bit ints", 1
+ if 9234567890121111114 - 9234567890121111113 != 1;
+ local $TODO;
+ use Config;
+ $TODO = "if we're lucky this might work" unless $Config{use64bitall};
+ is(eval { $gen1->testl(9234567890121111113) }, 9234567890121111114, "ulonglong big number");
+ # TODO: I suspect we can get by with "use64bitint", but I'll have to
+ # work that out later. -talby
+}
+is($gen1->testl("9234567890121111113"), "9234567890121111114", "ulonglong big number");
+
+
+is(li_std_string::stdstring_empty(), "", "stdstring_empty");
+
+is(li_std_string::c_empty(), "", "c_empty");
+
+
+is(li_std_string::c_null(), undef, "c_empty");
+
+
+is(li_std_string::get_null(li_std_string::c_null()), undef, "c_empty");
+
+is(li_std_string::get_null(li_std_string::c_empty()), "non-null", "c_empty");
+
+is(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "stdstring_empty");
diff --git a/trunk/Examples/test-suite/perl5/li_typemaps_runme.pl b/trunk/Examples/test-suite/perl5/li_typemaps_runme.pl
new file mode 100644
index 000000000..c182cdbb1
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/li_typemaps_runme.pl
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 415;
+BEGIN { use_ok('li_typemaps') }
+require_ok('li_typemaps');
+
+sub batch { my($type, @values) = @_;
+ # this is a little ugly because I'm trying to be clever and save my
+ # wrists from hammering out all these tests.
+ for my $val (@values) {
+ for my $tst (qw(
+ in inr
+ out outr
+ inout inoutr
+ )) {
+ my $func = $tst . '_' . $type;
+ is(eval { li_typemaps->can($func)->($val) }, $val, "$func $val");
+ if($@) {
+ my $err = $@;
+ $err =~ s/^/#\$\@# /mg;
+ print $err;
+ }
+ }
+ }
+}
+
+batch('bool', '', 1);
+# let's assume we're at least on a 32 bit machine
+batch('int', -0x80000000, -1, 0, 1, 12, 0x7fffffff);
+# long could be bigger, but it's at least this big
+batch('long', -0x80000000, -1, 0, 1, 12, 0x7fffffff);
+batch('short', -0x8000, -1, 0, 1, 12, 0x7fff);
+batch('uint', 0, 1, 12, 0xffffffff);
+batch('ushort', 0, 1, 12, 0xffff);
+batch('ulong', 0, 1, 12, 0xffffffff);
+batch('uchar', 0, 1, 12, 0xff);
+batch('schar', -0x80, 0, 1, 12, 0x7f);
+
+{
+ use Math::BigInt qw();
+ # the pack dance is to get plain old NVs out of the
+ # Math::BigInt objects.
+ my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
+ my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
+ batch('float',
+ -(2 - 2 ** -23) * 2 ** 127,
+ -1, -2 ** -149, 0, 2 ** -149, 1,
+ (2 - 2 ** -23) * 2 ** 127,
+ $nan);
+ { local $TODO = "float typemaps don't pass infinity";
+ # it seems as though SWIG is unwilling to pass infinity around
+ # because that value always fails bounds checking. I think that
+ # is a bug.
+ batch('float', $inf);
+ }
+ batch('double',
+ -(2 - 2 ** -53) ** 1023,
+ -1, -2 ** -1074, 0, 2 ** 1074,
+ (2 - 2 ** -53) ** 1023,
+ $nan, $inf);
+}
+batch('longlong', -1, 0, 1, 12);
+batch('ulonglong', 0, 1, 12);
+SKIP: {
+ my $a = "8000000000000000";
+ my $b = "7fffffffffffffff";
+ my $c = "ffffffffffffffff";
+ skip "not a 64bit Perl", 18 unless eval { pack 'q', 1 };
+ batch('longlong', -hex($a), hex($b));
+ batch('ulonglong', hex($c));
+}
+
+my($foo, $int) = li_typemaps::out_foo(10);
+isa_ok($foo, 'li_typemaps::Foo');
+is($foo->{a}, 10);
+is($int, 20);
+
+my($a, $b) = li_typemaps::inoutr_int2(13, 31);
+is($a, 13);
+is($b, 31);
+
diff --git a/trunk/Examples/test-suite/perl5/member_pointer_runme.pl b/trunk/Examples/test-suite/perl5/member_pointer_runme.pl
new file mode 100644
index 000000000..ff2cee7d1
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/member_pointer_runme.pl
@@ -0,0 +1,51 @@
+use strict;
+use warnings;
+use Test::More tests => 9;
+# member_pointer using pointers to member functions
+
+BEGIN { use_ok('member_pointer') }
+require_ok('member_pointer');
+
+sub check($;$;$) {
+ my($what, $expected, $actual) = @_;
+ if ($expected != $actual) {
+ die ("Failed: $what Expected: $expected Actual: $actual");
+ }
+}
+
+# Get the pointers
+
+my $area_pt = member_pointer::areapt();
+my $perim_pt = member_pointer::perimeterpt();
+
+# Create some objects
+
+my $s = new member_pointer::Square(10);
+
+# Do some calculations
+
+is(100.0, member_pointer::do_op($s,$area_pt), "Square area");
+is(40.0, member_pointer::do_op($s,$perim_pt), "Square perim");
+no strict;
+
+my $memberPtr = $member_pointer::areavar;
+$memberPtr = $member_pointer::perimetervar;
+
+# Try the variables
+is(100.0, member_pointer::do_op($s,$member_pointer::areavar), "Square area");
+is(40.0, member_pointer::do_op($s,$member_pointer::perimetervar), "Square perim");
+
+# Modify one of the variables
+$member_pointer::areavar = $perim_pt;
+
+is(40.0, member_pointer::do_op($s,$member_pointer::areavar), "Square perimeter");
+
+# Try the constants
+
+$memberPtr = $member_pointer::AREAPT;
+$memberPtr = $member_pointer::PERIMPT;
+$memberPtr = $member_pointer::NULLPT;
+
+is(100.0, member_pointer::do_op($s,$member_pointer::AREAPT), "Square area");
+is(40.0, member_pointer::do_op($s,$member_pointer::PERIMPT), "Square perim");
+
diff --git a/trunk/Examples/test-suite/perl5/minherit_runme.pl b/trunk/Examples/test-suite/perl5/minherit_runme.pl
new file mode 100755
index 000000000..1f3afadd2
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/minherit_runme.pl
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 38;
+BEGIN { use_ok('minherit') }
+require_ok('minherit');
+
+# adapted from ../python/minherit_runme.py
+
+my $a = minherit::Foo->new();
+my $b = minherit::Bar->new();
+my $c = minherit::FooBar->new();
+my $d = minherit::Spam->new();
+
+is($a->xget(), 1);
+
+is($b->yget(), 2);
+
+is($c->xget(), 1);
+is($c->yget(), 2);
+is($c->zget(), 3);
+
+is($d->xget(), 1);
+is($d->yget(), 2);
+is($d->zget(), 3);
+is($d->wget(), 4);
+
+is(minherit::xget($a), 1);
+
+is(minherit::yget($b), 2);
+
+is(minherit::xget($c), 1);
+is(minherit::yget($c), 2);
+is(minherit::zget($c), 3);
+
+is(minherit::xget($d), 1);
+is(minherit::yget($d), 2);
+is(minherit::zget($d), 3);
+is(minherit::wget($d), 4);
+
+# Cleanse all of the pointers and see what happens
+
+my $aa = minherit::toFooPtr($a);
+my $bb = minherit::toBarPtr($b);
+my $cc = minherit::toFooBarPtr($c);
+my $dd = minherit::toSpamPtr($d);
+
+is($aa->xget, 1);
+
+is($bb->yget(), 2);
+
+is($cc->xget(), 1);
+is($cc->yget(), 2);
+is($cc->zget(), 3);
+
+is($dd->xget(), 1);
+is($dd->yget(), 2);
+is($dd->zget(), 3);
+is($dd->wget(), 4);
+
+is(minherit::xget($aa), 1);
+
+is(minherit::yget($bb), 2);
+
+is(minherit::xget($cc), 1);
+is(minherit::yget($cc), 2);
+is(minherit::zget($cc), 3);
+
+is(minherit::xget($dd), 1);
+is(minherit::yget($dd), 2);
+is(minherit::zget($dd), 3);
+is(minherit::wget($dd), 4);
diff --git a/trunk/Examples/test-suite/perl5/multiple_inheritance_runme.pl b/trunk/Examples/test-suite/perl5/multiple_inheritance_runme.pl
new file mode 100644
index 000000000..1d913ffef
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/multiple_inheritance_runme.pl
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('multiple_inheritance') }
+require_ok('multiple_inheritance');
+
+my $fooBar = new multiple_inheritance::FooBar();
+is($fooBar->foo(), 2, "Runtime test1");
+
+is($fooBar->bar(), 1, "Runtime test2");
+
+is($fooBar->fooBar(), 3, "Runtime test3 ");
diff --git a/trunk/Examples/test-suite/perl5/naturalvar_runme.pl b/trunk/Examples/test-suite/perl5/naturalvar_runme.pl
new file mode 100755
index 000000000..c0f972d68
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/naturalvar_runme.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('naturalvar') }
+require_ok('naturalvar');
+
+# adapted from ../python/naturalvar_runme.py
+
+my $f = naturalvar::Foo->new();
+isa_ok($f, 'naturalvar::Foo');
+my $b = naturalvar::Bar->new();
+isa_ok($b, 'naturalvar::Bar');
+
+$b->{f} = $f;
+
+$naturalvar::s = "hello";
+
+$b->{s} = "hello";
+
+is($naturalvar::s, $b->{s});
+
diff --git a/trunk/Examples/test-suite/perl5/operator_overload_break_runme.pl b/trunk/Examples/test-suite/perl5/operator_overload_break_runme.pl
new file mode 100644
index 000000000..fd3fe3303
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/operator_overload_break_runme.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 9;
+
+use operator_overload_break;
+
+# Workaround for
+# ok( not (expression) , "test description" );
+# does not working in older versions of Perl, eg 5.004_04
+sub ok_not ($;$) {
+ my($test, $name) = @_;
+ $test = not $test;
+ ok($test, $name);
+}
+
+pass("loaded");
+
+my $op = operator_overload_break::Op->new(5);
+
+isa_ok($op, "operator_overload_break::Op");
+
+ok((2 == $op - 3),
+ "subtraction");
+
+$op->{k} = 37;
+
+ok((40 == $op + 3),
+ "addition");
+
+$op->{k} = 22;
+
+ok((10 == (32 - $op)),
+ "reversed subtraction");
+
+ok_not((3 == $op),
+ 'not equal');
+
+$op->{k} = 3;
+
+++$op;
+
+ok(($op == 4),
+ "pre-increment operator");
+
+$op++;
+
+ok(($op == 5),
+ "post-increment operator");
+
+my $op2 = ++$op;
+
+$op2 = $op++;
+
+ok(($op == 7) and ($op2 == 7),
+ "multiple post-increments");
diff --git a/trunk/Examples/test-suite/perl5/operator_overload_runme.pl b/trunk/Examples/test-suite/perl5/operator_overload_runme.pl
new file mode 100644
index 000000000..ba3f33a64
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/operator_overload_runme.pl
@@ -0,0 +1,175 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 39;
+
+use operator_overload;
+
+# Workaround for
+# ok( not (expression) , "test description" );
+# does not working in older versions of Perl, eg 5.004_04
+sub ok_not ($;$) {
+ my($test, $name) = @_;
+ $test = not $test;
+ ok($test, $name);
+}
+
+pass("loaded");
+
+# first check all the operators are implemented correctly from pure C++ code
+operator_overloadc::Op_sanity_check();
+
+my $op = operator_overload::Op->new();
+
+isa_ok($op, "operator_overload::Op");
+
+my $op2 = operator_overload::Op->new();
+
+isa_ok($op2, "operator_overload::Op");
+
+# operator equal
+$op->{i} = 5;
+$op2->{i} = 3;
+
+ok_not(($op == $op2), "operator equal: not equal");
+
+$op->{i} = 3;
+ok(($op == $op2), "operator equal: equal");
+
+# operator not equal
+$op->{i} = 5;
+$op2->{i} = 3;
+
+ok(($op != $op2), "operator not equal: not equal");
+
+$op->{i} = 3;
+ok_not(($op != $op2), "operator not equal: equal");
+
+# stringify operator
+$op->{i} = 3;
+is("Op(3)", "$op", "operator stringify");
+
+# addition operator
+$op->{i} = 3;
+$op2->{i} = 3;
+my $op3 = $op + $op2;
+is($op3->{i}, 6, "operator addition");
+
+# addition assignment operator
+$op->{i} = 3;
+$op2->{i} = 3;
+$op += $op2;
+is($op->{i}, 6, "operator additive assignment");
+
+# subtraction operator
+$op3->{i} = 6;
+$op2->{i} = 3;
+$op = $op3 - $op2;
+is($op->{i}, 3, "operator subtraction");
+
+# reversed subtraction operator (with int)
+$op3->{i} = 3;
+$op = 6 - $op3;
+is($op->{i}, 3, "reversed operator subtraction (with int)");
+
+# subtractive assignment operator
+$op->{i} = 6;
+$op2->{i} = 3;
+$op -= $op2;
+is($op->{i}, 3, "operator subtractive assignment");
+
+# multiplication operator
+$op->{i} = 3;
+$op2->{i} = 3;
+$op3 = $op * $op2;
+is($op3->{i}, 9, "operator multiplication");
+
+# division operator
+$op->{i} = 9;
+$op2->{i} = 3;
+$op3 = $op / $op2;
+is($op3->{i}, 3, "operator division");
+
+# modulus operator
+$op->{i} = 8;
+$op2->{i} = 3;
+$op3 = $op % $op2;
+is($op3->{i}, 2, "operator modulus");
+
+# greater than operator
+$op->{i} = 8;
+$op2->{i} = 3;
+ok($op > $op2, "operator greater than");
+ok_not(($op2 > $op), "operator greater than");
+$op->{i} = 3;
+ok_not(($op2 > $op), "operator greater than");
+ok_not(($op > $op2), "operator greater than");
+
+# greater than or equal operator
+$op->{i} = 8;
+$op2->{i} = 3;
+ok($op >= $op2, "operator greater than or equal");
+ok_not(($op2 >= $op), "operator greater than or equal");
+$op->{i} = 3;
+ok(($op2 >= $op), "operator greater than or equal");
+ok(($op >= $op2), "operator greater than or equal");
+
+# lesser than operator
+$op2->{i} = 8;
+$op->{i} = 3;
+ok($op < $op2, "operator lesser than");
+ok_not(($op2 < $op), "operator lesser than");
+$op2->{i} = 3;
+ok_not(($op2 < $op), "operator lesser than");
+ok_not(($op < $op2), "operator lesser than");
+
+# less than or equal operator
+$op2->{i} = 8;
+$op->{i} = 3;
+ok($op <= $op2, "operator lesser than or equal");
+ok_not(($op2 <= $op), "operator lesser than or equal");
+$op2->{i} = 3;
+ok(($op2 <= $op), "operator less than or equal");
+ok(($op <= $op2), "operator less than or equal");
+
+# post-increment operator
+$op->{i} = 7;
+$op++;
+is($op->{i}, 8, "operator post-increment");
+
+# pre-increment operator
+$op->{i} = 7;
+++$op;
+is($op->{i}, 8, "operator pre-increment");
+
+# post-decrement operator
+$op->{i} = 7;
+$op--;
+is($op->{i}, 6, "operator post-decrement");
+
+# pre-decrement operator
+$op->{i} = 7;
+--$op;
+is($op->{i}, 6, "operator pre-decrement");
+
+# neg operator
+$op->{i} = 3;
+$op2 = -$op;
+is($op2->{i}, -3, "operator neg");
+
+# not operator
+$op->{i} = 0;
+is(!$op, !0, "operator not");
+
+$op->{i} = 1;
+is(!$op, !1, "operator not");
+
+### # and operator
+### $op->{i} = 4;
+### $op2->{i} = 2;
+###
+### is($op & $op2, 4 & 2, "operator and");
+###
+### isnt(($op & $op2), (10 & 2), "operator and - false");
+
+# fail("testing failed condition");
+
diff --git a/trunk/Examples/test-suite/perl5/overload_copy_runme.pl b/trunk/Examples/test-suite/perl5/overload_copy_runme.pl
new file mode 100644
index 000000000..06d03f5e6
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/perl5/overload_simple_runme.pl b/trunk/Examples/test-suite/perl5/overload_simple_runme.pl
new file mode 100644
index 000000000..27719aa00
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/overload_simple_runme.pl
@@ -0,0 +1,191 @@
+#!/usr/bin/perl -w
+use overload_simple;
+use vars qw/$DOWARN/;
+use strict;
+use Test::More tests => 71;
+
+pass("loaded");
+
+my $f = new overload_simple::Foo();
+isa_ok($f, "overload_simple::Foo");
+my $b = new overload_simple::Bar();
+isa_ok($b, "overload_simple::Bar");
+my $v = overload_simple::malloc_void(32);
+isa_ok($v, "_p_void");
+
+
+#
+# Silence warnings about bad types
+#
+BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } }
+#
+#these tests should 'fail'
+#
+eval { overload_simple::fint("l") };
+ok($@, "fint(int) - int");
+
+eval { overload_simple::fint("3.5") };
+ok($@, "fint(int) - double");
+
+eval { overload_simple::fdouble("l") };
+ok($@, "fint(double) - int");
+
+eval { overload_simple::fdouble("1.5/2.0") };
+ok($@, "fint(double) - double");
+
+#
+#enable the warnings again
+#
+$DOWARN =1;
+
+#
+# 'simple' dispatch (no overload) of int and double arguments
+#
+
+is(overload_simple::fint(3), "fint:int", "fint(int) - int");
+
+is(overload_simple::fint("1"), "fint:int", "fint(int) - string int");
+
+is(overload_simple::fint(3.0), "fint:int", "fint(int) - double");
+
+is(overload_simple::fint("3.0"), "fint:int", "fint(int) - string double");
+
+# old bad case that now works
+my $n = 3;
+$n = $n + 1;
+is(overload_simple::fint($n), "fint:int", "fint(int) - int var");
+
+is(overload_simple::fint(4/2), "fint:int", "fint(int) - divide int denom");
+
+is(overload_simple::fint(4/2.0), "fint:int", "fint(int) - divide double denom");
+
+is(overload_simple::fdouble(3), "fdouble:double", "fdouble(double) - int");
+
+is(overload_simple::fdouble("3"), "fdouble:double", "fdouble(double) - string int");
+
+is(overload_simple::fdouble(3.0), "fdouble:double", "fdouble(double) - double");
+
+is(overload_simple::fdouble("3.0"), "fdouble:double", "fdouble(double) - string doubl");
+
+#
+# Overload between int and double
+#
+is(overload_simple::num(3), "num:int", "num(int) - int");
+
+is(overload_simple::num("3"), "num:int", "num(int) - string int");
+
+is(overload_simple::num(3.0), "num:double", "num(int) - double");
+
+is(overload_simple::num("3.0"), "num:double", "num(int) - string double");
+
+#
+# Overload between int, double, char * and many types.
+#
+is(overload_simple::foo(3), "foo:int", "foo:int - int");
+
+is(overload_simple::foo(3.0), "foo:double", "foo:double - double");
+
+is(overload_simple::foo("3"), "foo:char *", "foo:char * - string int");
+
+is(overload_simple::foo("3.0"), "foo:char *", "foo:char * - string double");
+
+is(overload_simple::foo("hello"), "foo:char *", "foo:char * string");
+
+is(overload_simple::foo($f), "foo:Foo *", "foo:Foo *");
+
+is(overload_simple::foo($b), "foo:Bar *", "foo:Bar *");
+
+is(overload_simple::foo($v), "foo:void *", "foo:void *");
+
+is(overload_simple::blah(3), "blah:double", "blah:double");
+
+is(overload_simple::blah("hello"), "blah:char *", "blah:char *");
+
+my $s = new overload_simple::Spam();
+
+is($s->foo(3), "foo:int", "Spam::foo:int");
+
+is($s->foo(3.0), "foo:double", "Spam::foo(double)");
+
+is($s->foo("hello"), "foo:char *", "Spam::foo:char *");
+
+is($s->foo($f), "foo:Foo *", "Spam::foo(Foo *)");
+
+is($s->foo($b), "foo:Bar *", "Spam::foo(Bar *)");
+
+is($s->foo($v), "foo:void *", "Spam::foo(void *)");
+
+is(overload_simple::Spam::bar(3), "bar:int", "Spam::bar(int)");
+
+is(overload_simple::Spam::bar(3.0), "bar:double", "Spam::bar(double)");
+
+is(overload_simple::Spam::bar("hello"), "bar:char *", "Spam::bar(char *)");
+
+is(overload_simple::Spam::bar($f), "bar:Foo *", "Spam::bar(Foo *)");
+
+is(overload_simple::Spam::bar($b), "bar:Bar *", "Spam::bar(Bar *)");
+
+is(overload_simple::Spam::bar($v), "bar:void *", "Spam::bar(void *)");
+
+# Test constructors
+
+$s = new overload_simple::Spam();
+isa_ok($s, "overload_simple::Spam");
+
+is($s->{type}, "none", "Spam()");
+
+$s = new overload_simple::Spam(3);
+isa_ok($s, "overload_simple::Spam");
+
+is($s->{type}, "int", "Spam(int)");
+
+$s = new overload_simple::Spam(3.0);
+isa_ok($s, "overload_simple::Spam");
+is($s->{type}, "double", "Spam(double)");
+
+$s = new overload_simple::Spam("hello");
+isa_ok($s, "overload_simple::Spam");
+is($s->{type}, "char *", "Spam(char *)");
+
+$s = new overload_simple::Spam($f);
+isa_ok($s, "overload_simple::Spam");
+is($s->{type}, "Foo *", "Spam(Foo *)");
+
+$s = new overload_simple::Spam($b);
+isa_ok($s, "overload_simple::Spam");
+is($s->{type}, "Bar *", "Spam(Bar *)");
+
+$s = new overload_simple::Spam($v);
+isa_ok($s, "overload_simple::Spam");
+is($s->{type}, "void *", "Spam(void *)");
+
+#
+# Combine dispatch
+#
+
+
+is(overload_simple::fid(3, 3.0), "fid:intdouble", "fid(int,double)");
+
+is(overload_simple::fid(3.0, 3), "fid:doubleint", "fid(double,int)");
+
+is(overload_simple::fid(3.0, 3.0), "fid:doubledouble", "fid(double,double)");
+
+is(overload_simple::fid(3, 3), "fid:intint", "fid(int,int)");
+
+# with strings now
+
+is(overload_simple::fid(3, "3.0"), "fid:intdouble", "fid(int,double)");
+
+is(overload_simple::fid("3", 3.0), "fid:intdouble", "fid(int,double)");
+
+is(overload_simple::fid("3", "3.0"), "fid:intdouble", "fid(int,double)");
+
+is(overload_simple::fid(3.0, "3"), "fid:doubleint", "fid(double,int)");
+
+is(overload_simple::fid("3.0", "3.0"), "fid:doubledouble", "fid:doubledouble");
+
+is(overload_simple::fid("3", 3), "fid:intint", "fid:fid(int,int)");
+
+isnt(overload_simple::fbool(0), overload_simple::fbool(1), "fbool(bool)");
+
+is(2, overload_simple::fbool(2), "fbool(int)");
diff --git a/trunk/Examples/test-suite/perl5/packageoption_runme.pl b/trunk/Examples/test-suite/perl5/packageoption_runme.pl
new file mode 100644
index 000000000..d94a7a1fd
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/packageoption_runme.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 4;
+
+BEGIN { use_ok('packageoption_a'); }
+BEGIN { use_ok('packageoption_b'); }
+
+# Workaround for
+# ok( not (expression) , "test description" );
+# does not working in older versions of Perl, eg 5.004_04
+sub ok_not ($;$) {
+ my($test, $name) = @_;
+ $test = not $test;
+ ok($test, $name);
+}
+
+my $a = CommonPackage::A->new();
+
+isa_ok($a, 'CommonPackage::A');
+
+my $b = CommonPackage::B->new();
+
+isa_ok($b, 'CommonPackage::B');
+
diff --git a/trunk/Examples/test-suite/perl5/preproc_runme.pl b/trunk/Examples/test-suite/perl5/preproc_runme.pl
new file mode 100755
index 000000000..89e25f896
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/preproc_runme.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 6;
+BEGIN { use_ok('preproc') }
+require_ok('preproc');
+
+# adapted from ../python/preproc_runme.py
+
+is($preproc::endif, 1);
+is($preproc::define, 1);
+is($preproc::defined, 1);
+is($preproc::one * 2, $preproc::two);
+
diff --git a/trunk/Examples/test-suite/perl5/primitive_ref_runme.pl b/trunk/Examples/test-suite/perl5/primitive_ref_runme.pl
new file mode 100644
index 000000000..20d37a79a
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/primitive_ref_runme.pl
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More tests => 14;
+BEGIN { use_ok('primitive_ref') }
+require_ok('primitive_ref');
+
+is(primitive_ref::ref_int(3), 3, "ref_int");
+is(primitive_ref::ref_uint(3), 3, "ref_uint");
+is(primitive_ref::ref_short(3), 3, "ref_short");
+is(primitive_ref::ref_ushort(3), 3, "ref_ushort");
+is(primitive_ref::ref_long(3), 3, "ref_long");
+is(primitive_ref::ref_ulong(3), 3, "ref_ulong");
+is(primitive_ref::ref_schar(3), 3, "ref_schar");
+is(primitive_ref::ref_uchar(3), 3, "ref_uchar");
+is(primitive_ref::ref_bool(1), 1, "ref_bool");
+is(primitive_ref::ref_float(3.5), 3.5, "ref_float");
+is(primitive_ref::ref_double(3.5), 3.5, "ref_double");
+is(primitive_ref::ref_char('x'), 'x', "ref_char");
diff --git a/trunk/Examples/test-suite/perl5/primitive_types_runme.pl b/trunk/Examples/test-suite/perl5/primitive_types_runme.pl
new file mode 100755
index 000000000..6d7b05d8d
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/primitive_types_runme.pl
@@ -0,0 +1,282 @@
+use strict;
+use warnings;
+use Test::More tests => 54;
+BEGIN { use_ok('primitive_types') }
+require_ok('primitive_types');
+
+primitive_types::var_init();
+
+# assigning globals calls
+$primitive_types::var_bool = $primitive_types::sct_bool;
+$primitive_types::var_schar = $primitive_types::sct_schar;
+$primitive_types::var_uchar = $primitive_types::sct_uchar;
+$primitive_types::var_int = $primitive_types::sct_int;
+$primitive_types::var_uint = $primitive_types::sct_uint;
+$primitive_types::var_short = $primitive_types::sct_short;
+$primitive_types::var_ushort = $primitive_types::sct_ushort;
+$primitive_types::var_long = $primitive_types::sct_long;
+$primitive_types::var_ulong = $primitive_types::sct_ulong;
+$primitive_types::var_llong = $primitive_types::sct_llong;
+$primitive_types::var_ullong = $primitive_types::sct_ullong;
+$primitive_types::var_char = $primitive_types::sct_char;
+$primitive_types::var_pchar = $primitive_types::sct_pchar;
+$primitive_types::var_pcharc = $primitive_types::sct_pcharc;
+$primitive_types::var_pint = $primitive_types::sct_pint;
+$primitive_types::var_sizet = $primitive_types::sct_sizet;
+$primitive_types::var_hello = $primitive_types::sct_hello;
+$primitive_types::var_myint = $primitive_types::sct_myint;
+$primitive_types::var_namet = $primitive_types::def_namet;
+$primitive_types::var_parami = $primitive_types::sct_parami;
+$primitive_types::var_paramd = $primitive_types::sct_paramd;
+$primitive_types::var_paramc = $primitive_types::sct_paramc;
+
+ok(primitive_types::v_check(), "v_check");
+
+#def pyerror(name, val, cte):
+# print "bad val/cte", name, val, cte
+# raise RuntimeError
+# pass
+
+is($primitive_types::var_bool, $primitive_types::cct_bool, "bool");
+is($primitive_types::var_schar, $primitive_types::cct_schar, "schar");
+is($primitive_types::var_uchar, $primitive_types::cct_uchar, "uchar");
+is($primitive_types::var_int, $primitive_types::cct_int, "int");
+is($primitive_types::var_uint, $primitive_types::cct_uint, "uint");
+is($primitive_types::var_short, $primitive_types::cct_short, "short");
+is($primitive_types::var_ushort, $primitive_types::cct_ushort, "ushort");
+is($primitive_types::var_long, $primitive_types::cct_long, "long");
+is($primitive_types::var_ulong, $primitive_types::cct_ulong, "ulong");
+is($primitive_types::var_llong, $primitive_types::cct_llong, "llong");
+is($primitive_types::var_ullong, $primitive_types::cct_ullong, "ullong");
+is($primitive_types::var_char, $primitive_types::cct_char, "char");
+is($primitive_types::var_pchar, $primitive_types::cct_pchar, "pchar");
+is($primitive_types::var_pcharc, $primitive_types::cct_pcharc, "pchar");
+is($primitive_types::var_pint, $primitive_types::cct_pint, "pint");
+is($primitive_types::var_sizet, $primitive_types::cct_sizet, "sizet");
+is($primitive_types::var_hello, $primitive_types::cct_hello, "hello");
+is($primitive_types::var_myint, $primitive_types::cct_myint, "myint");
+is($primitive_types::var_namet, $primitive_types::def_namet, "name");
+
+#class PyTest (TestDirector):
+# def __init__(self):
+# TestDirector.__init__(self)
+# pass
+# def ident(self, x):
+# return x
+#
+# def vval_bool(self, x): return self.ident(x)
+# def vval_schar(self, x): return self.ident(x)
+# def vval_uchar(self, x): return self.ident(x)
+# def vval_int(self, x): return self.ident(x)
+# def vval_uint(self, x): return self.ident(x)
+# def vval_short(self, x): return self.ident(x)
+# def vval_ushort(self, x): return self.ident(x)
+# def vval_long(self, x): return self.ident(x)
+# def vval_ulong(self, x): return self.ident(x)
+# def vval_llong(self, x): return self.ident(x)
+# def vval_ullong(self, x): return self.ident(x)
+# def vval_float(self, x): return self.ident(x)
+# def vval_double(self, x): return self.ident(x)
+# def vval_char(self, x): return self.ident(x)
+# def vval_pchar(self, x): return self.ident(x)
+# def vval_pcharc(self, x): return self.ident(x)
+# def vval_pint(self, x): return self.ident(x)
+# def vval_sizet(self, x): return self.ident(x)
+# def vval_hello(self, x): return self.ident(x)
+# def vval_myint(self, x): return self.ident(x)
+#
+# def vref_bool(self, x): return self.ident(x)
+# def vref_schar(self, x): return self.ident(x)
+# def vref_uchar(self, x): return self.ident(x)
+# def vref_int(self, x): return self.ident(x)
+# def vref_uint(self, x): return self.ident(x)
+# def vref_short(self, x): return self.ident(x)
+# def vref_ushort(self, x): return self.ident(x)
+# def vref_long(self, x): return self.ident(x)
+# def vref_ulong(self, x): return self.ident(x)
+# def vref_llong(self, x): return self.ident(x)
+# def vref_ullong(self, x): return self.ident(x)
+# def vref_float(self, x): return self.ident(x)
+# def vref_double(self, x): return self.ident(x)
+# def vref_char(self, x): return self.ident(x)
+# def vref_pchar(self, x): return self.ident(x)
+# def vref_pcharc(self, x): return self.ident(x)
+# def vref_pint(self, x): return self.ident(x)
+# def vref_sizet(self, x): return self.ident(x)
+# def vref_hello(self, x): return self.ident(x)
+# def vref_myint(self, x): return self.ident(x)
+#
+# pass
+
+
+my $t = primitive_types::Test->new();
+#p = PyTest()
+#
+#
+# internal call check
+#if t.c_check() != p.c_check():
+# raise RuntimeError, "bad director"
+#
+#p.var_bool = p.stc_bool
+#p.var_schar = p.stc_schar
+#p.var_uchar = p.stc_uchar
+#p.var_int = p.stc_int
+#p.var_uint = p.stc_uint
+#p.var_short = p.stc_short
+#p.var_ushort = p.stc_ushort
+#p.var_long = p.stc_long
+#p.var_ulong = p.stc_ulong
+#p.var_llong = p.stc_llong
+#p.var_ullong = p.stc_ullong
+#p.var_char = p.stc_char
+#p.var_pchar = sct_pchar
+#p.var_pcharc = sct_pcharc
+#p.var_pint = sct_pint
+#p.var_sizet = sct_sizet
+#p.var_hello = sct_hello
+#p.var_myint = sct_myint
+#p.var_namet = def_namet
+#p.var_parami = sct_parami
+#p.var_paramd = sct_paramd
+#p.var_paramc = sct_paramc
+#
+#p.v_check()
+
+$t->{var_bool} = $primitive_types::Test::stc_bool;
+$t->{var_schar} = $primitive_types::Test::stc_schar;
+$t->{var_uchar} = $primitive_types::Test::stc_uchar;
+$t->{var_int} = $primitive_types::Test::stc_int;
+$t->{var_uint} = $primitive_types::Test::stc_uint;
+$t->{var_short} = $primitive_types::Test::stc_short;
+$t->{var_ushort} = $primitive_types::Test::stc_ushort;
+$t->{var_long} = $primitive_types::Test::stc_long;
+$t->{var_ulong} = $primitive_types::Test::stc_ulong;
+$t->{var_llong} = $primitive_types::Test::stc_llong;
+$t->{var_ullong} = $primitive_types::Test::stc_ullong;
+$t->{var_char} = $primitive_types::Test::stc_char;
+$t->{var_pchar} = $primitive_types::sct_pchar;
+$t->{var_pcharc} = $primitive_types::sct_pcharc;
+$t->{var_pint} = $primitive_types::sct_pint;
+$t->{var_sizet} = $primitive_types::sct_sizet;
+$t->{var_hello} = $primitive_types::sct_hello;
+$t->{var_myint} = $primitive_types::sct_myint;
+$t->{var_namet} = $primitive_types::def_namet;
+$t->{var_parami} = $primitive_types::sct_parami;
+$t->{var_paramd} = $primitive_types::sct_paramd;
+$t->{var_paramc} = $primitive_types::sct_paramc;
+ok($t->v_check(), 'v_check');
+
+is($primitive_types::def_namet, "ho\0la", "namet");
+$t->{var_namet} = $primitive_types::def_namet;
+is($t->{var_namet}, $primitive_types::def_namet, "namet");
+
+$t->{var_namet} = 'holac';
+
+is($t->{var_namet}, 'holac', "namet");
+
+$t->{var_namet} = 'hol';
+
+is($t->{var_namet}, 'hol', "namet");
+
+
+is($t->strlen('hile'), 4, "string typemap");
+
+is($t->strlen("hil\0"), 4, "string typemap");
+
+
+$primitive_types::var_char = "\0";
+is($primitive_types::var_char, "\0", "char '0' case");
+
+$primitive_types::var_char = 0;
+is($primitive_types::var_char, "\0", "char '0' case");
+
+$primitive_types::var_namet = "\0";
+is($primitive_types::var_namet, '', "char '\\0' case");
+
+$primitive_types::var_namet = '';
+is($primitive_types::var_namet, '', "char empty case");
+
+$primitive_types::var_pchar = undef;
+is($primitive_types::var_pchar, undef, "undef case");
+
+$primitive_types::var_pchar = '';
+is($primitive_types::var_pchar, '', "char empty case");
+
+$primitive_types::var_pcharc = undef;
+is($primitive_types::var_pcharc, undef, "undef case");
+
+$primitive_types::var_pcharc = '';
+is($primitive_types::var_pcharc, '', "char empty case");
+
+
+#
+# creating a raw char*
+#
+my $pc = primitive_types::new_pchar(5);
+primitive_types::pchar_setitem($pc, 0, 'h');
+primitive_types::pchar_setitem($pc, 1, 'o');
+primitive_types::pchar_setitem($pc, 2, 'l');
+primitive_types::pchar_setitem($pc, 3, 'a');
+primitive_types::pchar_setitem($pc, 4, 0);
+
+
+is($t->strlen($pc), 4, "string typemap");
+
+$primitive_types::var_pchar = $pc;
+is($primitive_types::var_pchar, "hola", "pointer case");
+
+$primitive_types::var_namet = $pc;
+is($primitive_types::var_namet, "hola", "pointer case");
+
+primitive_types::delete_pchar($pc);
+
+#
+# Now when things should fail
+#
+
+{
+ my $orig = $t->{var_uchar};
+ eval { $t->{var_uchar} = 10000 };
+ like($@, qr/\bOverflowError\b/, "uchar typemap");
+ is($orig, $t->{var_uchar}, "uchar typemap");
+}
+{
+ my $orig = $t->{var_char};
+ #eval { $t->{var_char} = "23" }; Perl will gladly make a number out of that
+ eval { $t->{var_char} = "twenty-three" };
+ like($@, qr/\bTypeError\b/, "char typemap");
+ is($orig, $t->{var_char}, "char typemap");
+}
+{
+ my $orig = $t->{var_uint};
+ eval { $t->{var_uint} = -1 };
+ like($@, qr/\bOverflowError\b/, "uint typemap");
+ is($orig, $t->{var_uint}, "uint typemap");
+}
+{
+ my $orig = $t->{var_namet};
+ eval { $t->{var_namet} = '123456' };
+ like($@, qr/\bTypeError\b/, "namet typemap");
+ is($orig, $t->{var_namet}, "namet typemap");
+}
+#t2 = p.vtest(t)
+#if t.var_namet != t2.var_namet:
+# raise RuntimeError, "bad SWIGTYPE* typemap"
+
+is($primitive_types::fixsize, "ho\0la\0\0\0", "FIXSIZE typemap");
+
+$primitive_types::fixsize = 'ho';
+is($primitive_types::fixsize, "ho\0\0\0\0\0\0", "FIXSIZE typemap");
+
+
+my $f = primitive_types::Foo->new(3);
+my $f1 = primitive_types::fptr_val($f);
+my $f2 = primitive_types::fptr_ref($f);
+is($f1->{_a}, $f2->{_a}, "const ptr& typemap");
+
+
+is(primitive_types::char_foo(1,3), 3, "int typemap");
+
+is(primitive_types::char_foo(1,"hello"), "hello", "char* typemap");
+
+is(primitive_types::SetPos(1,3), 4, "int typemap");
diff --git a/trunk/Examples/test-suite/perl5/profiletest_runme.pl b/trunk/Examples/test-suite/perl5/profiletest_runme.pl
new file mode 100644
index 000000000..fcf5c6a53
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/profiletest_runme.pl
@@ -0,0 +1,8 @@
+use profiletest;
+$a = profiletestc::new_A();
+$b = profiletestc::new_B();
+
+for ($i = 0; $i < 100000; $i++) {
+ $a = profiletestc::B_fn($b, $a);
+}
+
diff --git a/trunk/Examples/test-suite/perl5/reference_global_vars_runme.pl b/trunk/Examples/test-suite/perl5/reference_global_vars_runme.pl
new file mode 100755
index 000000000..dfbcf15bb
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/reference_global_vars_runme.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 19;
+BEGIN { use_ok('reference_global_vars') }
+require_ok('reference_global_vars');
+
+# adapted from ../python/reference_global_vars_runme.py
+
+my $cvar;
+{
+ # don't try this at home kids... sneaking an import of all symbols
+ # from reference_global_vars to main because my fingers are getting
+ # sore from qualifying all these names. ;)
+ my $cvar = *reference_global_vars::;
+ map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar};
+}
+
+is(getconstTC()->{num}, 33);
+
+# primitive reference variables
+$cvar->{var_bool} = createref_bool(0);
+is(value_bool($cvar->{var_bool}), '');
+
+$cvar->{var_bool} = createref_bool(1);
+is(value_bool($cvar->{var_bool}), 1);
+
+$cvar->{var_char} = createref_char('w');
+is(value_char($cvar->{var_char}), 'w');
+
+$cvar->{var_unsigned_char} = createref_unsigned_char(10);
+is(value_unsigned_char($cvar->{var_unsigned_char}), 10);
+
+$cvar->{var_signed_char} = createref_signed_char(10);
+is(value_signed_char($cvar->{var_signed_char}), 10);
+
+$cvar->{var_short} = createref_short(10);
+is(value_short($cvar->{var_short}), 10);
+
+$cvar->{var_unsigned_short} = createref_unsigned_short(10);
+is(value_unsigned_short($cvar->{var_unsigned_short}), 10);
+
+$cvar->{var_int} = createref_int(10);
+is(value_int($cvar->{var_int}), 10);
+
+$cvar->{var_unsigned_int} = createref_unsigned_int(10);
+is(value_unsigned_int($cvar->{var_unsigned_int}), 10);
+
+$cvar->{var_long} = createref_long(10);
+is(value_long($cvar->{var_long}), 10);
+
+$cvar->{var_unsigned_long} = createref_unsigned_long(10);
+is(value_unsigned_long($cvar->{var_unsigned_long}), 10);
+
+SKIP: {
+ my $a = "6FFFFFFFFFFFFFF8";
+ skip "64 bit int support", 1 unless eval { pack 'q', 1 };
+ # using hex() here instead of a literal because non 64bit Perls will
+ # be noisy about big constants.
+ $cvar->{var_long_long} = createref_long_long(hex $a);
+ is(value_long_long($cvar->{var_long_long}), hex $a);
+}
+
+#ull = abs(0xFFFFFFF2FFFFFFF0)
+my $ull = 55834574864;
+$cvar->{var_unsigned_long_long} = createref_unsigned_long_long($ull);
+is(value_unsigned_long_long($cvar->{var_unsigned_long_long}), $ull);
+
+$cvar->{var_float} = createref_float(10.5);
+is(value_float($cvar->{var_float}), 10.5);
+
+$cvar->{var_double} = createref_double(10.5);
+is(value_double($cvar->{var_double}), 10.5);
+
+# class reference variable
+$cvar->{var_TestClass} = createref_TestClass(
+ TestClass->new(20)
+);
+is(value_TestClass($cvar->{var_TestClass})->{num}, 20);
+
diff --git a/trunk/Examples/test-suite/perl5/rename_scope_runme.pl b/trunk/Examples/test-suite/perl5/rename_scope_runme.pl
new file mode 100755
index 000000000..71c0cfc6f
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/rename_scope_runme.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('rename_scope') }
+require_ok('rename_scope');
+
+# adapted from ../python/rename_scope_runme.py
+
+my $a = rename_scope::Natural_UP->new();
+is($a->rtest(), 1);
+my $b = rename_scope::Natural_BP->new();
+is($b->rtest(), 1);
+
+isa_ok(rename_scope->can('equals'), 'CODE');
diff --git a/trunk/Examples/test-suite/perl5/ret_by_value_runme.pl b/trunk/Examples/test-suite/perl5/ret_by_value_runme.pl
new file mode 100644
index 000000000..61266279d
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/ret_by_value_runme.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('ret_by_value') }
+require_ok('ret_by_value');
+
+my $tst = ret_by_value::get_test();
+isa_ok($tst, 'ret_by_value::test');
+is($tst->{myInt}, 100);
+is($tst->{myShort}, 200);
+
diff --git a/trunk/Examples/test-suite/perl5/return_const_value_runme.pl b/trunk/Examples/test-suite/perl5/return_const_value_runme.pl
new file mode 100755
index 000000000..4b31c0b26
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/return_const_value_runme.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('return_const_value') }
+require_ok('return_const_value');
+
+# adapted from ../python/return_const_value_runme.py
+
+is(return_const_value::Foo_ptr::getPtr()->getVal(), 17);
+
+is(return_const_value::Foo_ptr::getConstPtr()->getVal(), 17);
+
diff --git a/trunk/Examples/test-suite/perl5/run-perl-test.pl b/trunk/Examples/test-suite/perl5/run-perl-test.pl
new file mode 100755
index 000000000..106bf002b
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/run-perl-test.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+ eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+#!/usr/bin/perl -w
+
+use strict;
+
+my $command = shift @ARGV;
+
+my $output = `$^X $command 2>&1`;
+
+die "SWIG Perl test failed: \n\n$output\n"
+ if $?;
+
+exit(0);
diff --git a/trunk/Examples/test-suite/perl5/sizet_runme.pl b/trunk/Examples/test-suite/perl5/sizet_runme.pl
new file mode 100755
index 000000000..5f29773b3
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/sizet_runme.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 6;
+BEGIN { use_ok('sizet') }
+require_ok('sizet');
+
+# adapted from ../java/sizet_runme.java
+
+my $s = 2000;
+$s = sizet::test1($s + 1);
+is($s, 2001, 'test1');
+$s = sizet::test1($s + 1);
+is($s, 2002, 'test2');
+$s = sizet::test1($s + 1);
+is($s, 2003, 'test3');
+$s = sizet::test1($s + 1);
+is($s, 2004, 'test4');
diff --git a/trunk/Examples/test-suite/perl5/sneaky1_runme.pl b/trunk/Examples/test-suite/perl5/sneaky1_runme.pl
new file mode 100755
index 000000000..097d44678
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/sneaky1_runme.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More 'no_plan';
+BEGIN { use_ok('sneaky1') }
+require_ok('sneaky1');
+
+# adapted from ../python/sneaky1_runme.py
+
+is(sneaky1::add(3,4), 7);
+is(sneaky1::subtract(3,4), -1);
+is(sneaky1::mul(3,4), 12);
+is(sneaky1::divide(3,4), 0);
diff --git a/trunk/Examples/test-suite/perl5/template_default_arg_runme.pl b/trunk/Examples/test-suite/perl5/template_default_arg_runme.pl
new file mode 100644
index 000000000..791f5085c
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/template_default_arg_runme.pl
@@ -0,0 +1,111 @@
+use strict;
+use warnings;
+use Test::More tests => 34;
+BEGIN { use_ok('template_default_arg') }
+require_ok('template_default_arg');
+
+{
+ my $helloInt = new template_default_arg::Hello_int();
+ $helloInt->foo(0);
+}
+{
+ my $x = new template_default_arg::X_int();
+ is($x->meth(20.0, 200), 200, "X_int test 1");
+ is($x->meth(20), 20, "X_int test 2");
+ is($x->meth(), 0, "X_int test 3");
+}
+
+{
+ my $y = new template_default_arg::Y_unsigned();
+ is($y->meth(20.0, 200), 200, "Y_unsigned test 1");
+ is($y->meth(20), 20, "Y_unsigned test 2");
+ is($y->meth(), 0, "Y_unsigned test 3");
+}
+
+{
+ my $x = new template_default_arg::X_longlong();
+ $x = new template_default_arg::X_longlong(20.0);
+ $x = new template_default_arg::X_longlong(20.0, 200);
+}
+{
+ my $x = new template_default_arg::X_int();
+ $x = new template_default_arg::X_int(20.0);
+ $x = new template_default_arg::X_int(20.0, 200);
+}
+{
+ my $x = new template_default_arg::X_hello_unsigned();
+ $x = new template_default_arg::X_hello_unsigned(20.0);
+ $x = new template_default_arg::X_hello_unsigned(20.0, new template_default_arg::Hello_int());
+}
+{
+ my $y = new template_default_arg::Y_hello_unsigned();
+ $y->meth(20.0, new template_default_arg::Hello_int());
+ $y->meth(new template_default_arg::Hello_int());
+ $y->meth();
+}
+
+{
+ my $fz = new template_default_arg::Foo_Z_8();
+ my $x = new template_default_arg::X_Foo_Z_8();
+ my $fzc = $x->meth($fz);
+}
+
+# Templated functions
+{
+ # plain function: int ott(Foo<int>)
+ is(template_default_arg::ott(new template_default_arg::Foo_int()), 30, "ott test 1");
+
+ # %template(ott) ott<int, int>;
+ is(template_default_arg::ott(), 10, "ott test 2");
+ is(template_default_arg::ott(1), 10, "ott test 3");
+ is(template_default_arg::ott(1, 1), 10, "ott test 4");
+
+ is(template_default_arg::ott("hi"), 20, "ott test 5");
+ is(template_default_arg::ott("hi", 1), 20, "ott test 6");
+ is(template_default_arg::ott("hi", 1, 1), 20,"ott test 7");
+
+ # %template(ott) ott<const char *>;
+ is(template_default_arg::ottstring(new template_default_arg::Hello_int(), "hi"), 40, "ott test 8");
+
+ is(template_default_arg::ottstring(new template_default_arg::Hello_int()), 40, "ott test 9");
+
+ # %template(ott) ott<int>;
+ is(template_default_arg::ottint(new template_default_arg::Hello_int(), 1), 50, "ott test 10");
+
+ is(template_default_arg::ottint(new template_default_arg::Hello_int()), 50, "ott test 11");
+
+ # %template(ott) ott<double>;
+ is(template_default_arg::ott(new template_default_arg::Hello_int(), 1.0), 60, "ott test 12");
+
+ is(template_default_arg::ott(new template_default_arg::Hello_int()), 60, "ott test 13");
+}
+
+# Above test in namespaces
+{
+ # plain function: int nsott(Foo<int>)
+ is(template_default_arg::nsott(new template_default_arg::Foo_int()), 130, "nsott test 1");
+
+ # %template(nsott) nsott<int, int>;
+ is(template_default_arg::nsott(), 110, "nsott test 2");
+ is(template_default_arg::nsott(1), 110, "nsott test 3");
+ is(template_default_arg::nsott(1, 1), 110, "nsott test 4");
+
+ is(template_default_arg::nsott("hi"), 120, "nsott test 5");
+ is(template_default_arg::nsott("hi", 1), 120, "nsott test 6");
+ is(template_default_arg::nsott("hi", 1, 1), 120, "nsott test 7");
+
+ # %template(nsott) nsott<const char *>;
+ is(template_default_arg::nsottstring(new template_default_arg::Hello_int(), "hi"), 140, "nsott test 8");
+
+ is(template_default_arg::nsottstring(new template_default_arg::Hello_int()), 140, "nsott test 9");
+
+ # %template(nsott) nsott<int>;
+ is(template_default_arg::nsottint(new template_default_arg::Hello_int(), 1), 150, "nsott test 10");
+
+ is(template_default_arg::nsottint(new template_default_arg::Hello_int()), 150, "nsott test 11");
+
+ # %template(nsott) nsott<double>;
+ is(template_default_arg::nsott(new template_default_arg::Hello_int(), 1.0), 160, "nsott test 12");
+
+ is(template_default_arg::nsott(new template_default_arg::Hello_int()), 160, "nsott test 13");
+}
diff --git a/trunk/Examples/test-suite/perl5/template_ref_type_runme.pl b/trunk/Examples/test-suite/perl5/template_ref_type_runme.pl
new file mode 100644
index 000000000..ba6e2b901
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/template_ref_type_runme.pl
@@ -0,0 +1,6 @@
+use template_ref_type;
+
+my $xr = template_ref_type::XC->new();
+my $y = template_ref_type::Y->new();
+
+$y->find($xr);
diff --git a/trunk/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl b/trunk/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl
new file mode 100755
index 000000000..e0a3003d2
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 16;
+BEGIN { use_ok('template_typedef_cplx2') }
+require_ok('template_typedef_cplx2');
+
+# adapted from ../python/template_typedef_cplx2_runme.py
+
+{ # kids, don't try this at home (glob hijinks)
+ my $cvar = *template_typedef_cplx2::;
+ map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar};
+}
+
+#
+# double case
+#
+
+my $d = eval { make_Identity_double() };
+ok(ref($d), 'is an object');
+like(ref($d), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+my $e = eval { make_Multiplies_double_double_double_double($d, $d) };
+ok(ref($e), 'is an object');
+like(ref($e), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+#
+# complex case
+#
+
+my $c = eval { make_Identity_complex() };
+ok(ref($c), 'is an object');
+like(ref($c), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+my $f = eval { make_Multiplies_complex_complex_complex_complex($c, $c) };
+ok(ref($f), 'is an object');
+like(ref($f), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+#
+# Mix case
+#
+
+my $g = eval { make_Multiplies_double_double_complex_complex($d, $c) };
+ok(ref($g), 'is an object');
+like(ref($g), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+my $h = eval { make_Multiplies_complex_complex_double_double($c, $d) };
+ok(ref($h), 'is an object');
+like(ref($h), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+can_ok($g, 'get_value');
+ok(eval { $g->get_value() }, 'get_value');
+
diff --git a/trunk/Examples/test-suite/perl5/template_typedef_cplx3_runme.pl b/trunk/Examples/test-suite/perl5/template_typedef_cplx3_runme.pl
new file mode 100644
index 000000000..fe411f6f7
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/template_typedef_cplx3_runme.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 16;
+BEGIN { use_ok('template_typedef_cplx3') }
+require_ok('template_typedef_cplx3');
+
+# adapted from ../python/template_typedef_cplx3_runme.py
+
+{ # kids, don't try this at home (glob hijinks)
+ my $cvar = *template_typedef_cplx3::;
+ map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar};
+}
+
+my $s = Sin->new();
+is($s->get_base_value(), 0);
+is($s->get_value(), 1);
+is($s->get_arith_value(), 2);
+is(my_func_r($s), 0);
+isa_ok(make_Multiplies_double_double_double_double($s,$s),
+ "template_typedef_cplx3::ArithUnaryFunction_double_double");
+
+my $z = CSin->new();
+is($z->get_base_value(), 0);
+is($z->get_value(), 1);
+is($z->get_arith_value(), 2);
+is(my_func_c($z), 1);
+isa_ok(make_Multiplies_complex_complex_complex_complex($z,$z),
+ "template_typedef_cplx3::ArithUnaryFunction_complex_complex");
+
+my $d = eval { make_Identity_double() };
+isa_ok($d, "template_typedef_cplx3::ArithUnaryFunction_double_double");
+is(my_func_r($d), 0);
+
+my $c = eval { make_Identity_complex() };
+isa_ok($d, "template_typedef_cplx3::ArithUnaryFunction_double_double");
+is(my_func_c($c), 1);
+
+
+
+
diff --git a/trunk/Examples/test-suite/perl5/template_typedef_cplx_runme.pl b/trunk/Examples/test-suite/perl5/template_typedef_cplx_runme.pl
new file mode 100644
index 000000000..47cc67216
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/template_typedef_cplx_runme.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 14;
+BEGIN { use_ok('template_typedef_cplx') }
+require_ok('template_typedef_cplx');
+
+# adapted from ../python/template_typedef_cplx_runme.py
+
+{ # kids, don't try this at home (glob hijinks)
+ my $cvar = *template_typedef_cplx::;
+ map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar};
+}
+
+#
+# double case
+#
+
+my $d = eval { make_Identity_double() };
+ok(ref($d), 'is an object');
+like(ref($d), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+my $e = eval { make_Multiplies_double_double_double_double($d, $d) };
+ok(ref($e), 'is an object');
+like(ref($e), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+#
+# complex case
+#
+
+my $c = eval { make_Identity_complex() };
+ok(ref($c), 'is an object');
+like(ref($c), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+my $f = eval { make_Multiplies_complex_complex_complex_complex($c, $c) };
+ok(ref($f), 'is an object');
+like(ref($f), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+#
+# Mix case
+#
+
+my $g = eval { make_Multiplies_double_double_complex_complex($d, $c) };
+ok(ref($f), 'is an object');
+like(ref($f), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
+
+my $h = eval { make_Multiplies_complex_complex_double_double($c, $d) };
+ok(ref($h), 'is an object');
+like(ref($h), qr/ArithUnaryFunction/, "is an ArithUnaryFunction");
diff --git a/trunk/Examples/test-suite/perl5/typedef_class_runme.pl b/trunk/Examples/test-suite/perl5/typedef_class_runme.pl
new file mode 100755
index 000000000..a7b88a771
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/typedef_class_runme.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 6;
+BEGIN { use_ok('typedef_class') }
+require_ok('typedef_class');
+
+# adapted from ../python/typedef_class_runme.py
+
+my $a = typedef_class::RealA->new();
+isa_ok($a, 'typedef_class::RealA');
+$a->{a} = 3;
+is($a->{a}, 3);
+my $b = typedef_class::B->new();
+isa_ok($b, 'typedef_class::B');
+is($b->testA($a), 3);
diff --git a/trunk/Examples/test-suite/perl5/typemap_namespace_runme.pl b/trunk/Examples/test-suite/perl5/typemap_namespace_runme.pl
new file mode 100644
index 000000000..f2fdd6f82
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/typemap_namespace_runme.pl
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('typemap_namespace') }
+require_ok('typemap_namespace');
+
+is(typemap_namespace::test1("hello"), "hello", "test 1");
+is(typemap_namespace::test2("hello"), "hello", "test 1");
diff --git a/trunk/Examples/test-suite/perl5/typename_runme.pl b/trunk/Examples/test-suite/perl5/typename_runme.pl
new file mode 100755
index 000000000..543080d8c
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/typename_runme.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 4;
+BEGIN { use_ok('typename') }
+require_ok('typename');
+
+# adapted from ../python/typename_runme.py
+
+my $f = typename::Foo->new();
+my $b = typename::Bar->new();
+my $x = typename::twoFoo($f);
+is($x, 4.3656);
+my $y = typename::twoBar($b);
+is($y, 84);
+# I would like this test better if I could pass in a float to the
+# integer test and see it lose precision.
diff --git a/trunk/Examples/test-suite/perl5/unions_runme.pl b/trunk/Examples/test-suite/perl5/unions_runme.pl
new file mode 100644
index 000000000..7a62295c3
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/unions_runme.pl
@@ -0,0 +1,42 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+BEGIN { use_ok('unions') }
+require_ok('unions');
+
+# Create new instances of SmallStruct and BigStruct for later use
+my $small = new unions::SmallStruct();
+$small->{jill} = 200;
+
+my $big = new unions::BigStruct();
+$big->{smallstruct} = $small;
+$big->{jack} = 300;
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+my $eut = new unions::EmbeddedUnionTest();
+
+# First check the SmallStruct in EmbeddedUnionTest
+$eut->{number} = 1;
+$eut->{uni}->{small} = $small;
+my $Jill1 = $eut->{uni}->{small}->{jill};
+is($Jill1, 200, "eut.uni.small.jill");
+
+my $Num1 = $eut->{number};
+is($Num1, 1, "test2 eut.number");
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+$eut->{number} = 2;
+$eut->{uni}->{big} = $big;
+my $Jack1 = $eut->{uni}->{big}->{jack};
+is($Jack1, 300, "test3 eut.uni.big.jack");
+
+my $Jill2 = $eut->{uni}->{big}->{smallstruct}->{jill};
+is($Jill2, 200, "test4 eut.uni.big.smallstruct.jill");
+
+my $Num2 = $eut->{number};
+is($Num2, 2, "test5 eut.number");
+
diff --git a/trunk/Examples/test-suite/perl5/using1_runme.pl b/trunk/Examples/test-suite/perl5/using1_runme.pl
new file mode 100755
index 000000000..8551b6fc6
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/using1_runme.pl
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('using1') }
+require_ok('using1');
+
+# adapted from ../python/using1_runme.py
+
+is(using1::spam(37), 37);
diff --git a/trunk/Examples/test-suite/perl5/using2_runme.pl b/trunk/Examples/test-suite/perl5/using2_runme.pl
new file mode 100755
index 000000000..3a31bb364
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/using2_runme.pl
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('using2') }
+require_ok('using2');
+
+# adapted from ../python/using2_runme.py
+
+is(using2::spam(37), 37);
diff --git a/trunk/Examples/test-suite/perl5/varargs_runme.pl b/trunk/Examples/test-suite/perl5/varargs_runme.pl
new file mode 100644
index 000000000..4d8a831d3
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/varargs_runme.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('varargs') }
+require_ok('varargs');
+
+is(varargs::test("Hello"), "Hello");
+
+my $f = new varargs::Foo("BuonGiorno", 1);
+is($f->{str}, "BuonGiorno");
+
+$f = new varargs::Foo("Greetings");
+is($f->{str}, "Greetings");
+
+is($f->test("Hello"), "Hello");
+
+is(varargs::Foo::statictest("Grussen", 1), "Grussen");
diff --git a/trunk/Examples/test-suite/perl5/virtual_poly_runme.pl b/trunk/Examples/test-suite/perl5/virtual_poly_runme.pl
new file mode 100644
index 000000000..a56a64eda
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/virtual_poly_runme.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 8;
+BEGIN { use_ok('virtual_poly') }
+require_ok('virtual_poly');
+
+my $d = virtual_poly::NDouble->new(3.5);
+my $i = virtual_poly::NInt->new(2);
+
+#
+# the copy methods return the right polymorphic types
+#
+my $dc = $d->copy();
+my $ic = $i->copy();
+
+is($d->get(), $dc->get());
+
+is($i->get(), $ic->get());
+
+virtual_poly::incr($ic);
+
+is($i->get() + 1, $ic->get());
+
+my $dr = $d->ref_this();
+is($d->get(), $dr->get());
+
+
+#
+# 'narrowing' also works
+#
+my $ddc = virtual_poly::NDouble::narrow($d->nnumber());
+is($d->get, $ddc->get());
+
+my $dic = virtual_poly::NInt::narrow($i->nnumber());
+is($i->get(), $dic->get());
diff --git a/trunk/Examples/test-suite/perl5/voidtest_runme.pl b/trunk/Examples/test-suite/perl5/voidtest_runme.pl
new file mode 100644
index 000000000..405f8fd11
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/voidtest_runme.pl
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('voidtest') }
+require_ok('voidtest');
+
+# adapted from ../python/voidtest_runme.py
+voidtest::globalfunc();
+my $f = voidtest::Foo->new();
+is($f->memberfunc(), undef);
+{ local $TODO = "opaque pointers hidden behind layer of indirection";
+my $v1 = voidtest::vfunc1($f);
+my $v2 = voidtest::vfunc2($f);
+is($v1, $v2);
+my $v3 = voidtest::vfunc3($v1);
+is($v3->this, $f->this);
+my $v4 = voidtest::vfunc4($f);
+is($v1, $v4);
+}
+ok(1, "done");
diff --git a/trunk/Examples/test-suite/perl5/wrapmacro_runme.pl b/trunk/Examples/test-suite/perl5/wrapmacro_runme.pl
new file mode 100755
index 000000000..8e0154057
--- /dev/null
+++ b/trunk/Examples/test-suite/perl5/wrapmacro_runme.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+BEGIN { use_ok('wrapmacro') }
+require_ok('wrapmacro');
+
+# adapted from ../python/wrapmacro_runme.py
+
+my $a = 2;
+my $b = -1;
+is(wrapmacro::maximum($a,$b), 2);
+is(wrapmacro::maximum($a/7.0, -$b*256), 256);
+is(wrapmacro::GUINT16_SWAP_LE_BE_CONSTANT(1), 256);
diff --git a/trunk/Examples/test-suite/php/Makefile.in b/trunk/Examples/test-suite/php/Makefile.in
new file mode 100644
index 000000000..5340751e7
--- /dev/null
+++ b/trunk/Examples/test-suite/php/Makefile.in
@@ -0,0 +1,70 @@
+#######################################################################
+# Makefile for php test-suite
+#######################################################################
+
+LANGUAGE = php
+SCRIPTSUFFIX = _runme.php
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+CPP_TEST_CASES += \
+ php_namewarn_rename \
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+TARGETPREFIX =# Should be php_ for Windows, empty otherwise
+
+# Custom tests - tests with additional commandline options
+prefix.cpptest: SWIGOPT += -prefix Project
+
+# write out tests without a _runme.php
+missingcpptests:
+ for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
+
+missingctests:
+ for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
+
+missingtests: missingcpptests missingctests
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ +$(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ +$(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ +$(run_testcase)
+
+# Smart target
+%.test:
+ @echo ' $(C_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
+ $(MAKE) $*.ctest
+ @echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
+ $(MAKE) $*.cpptest
+ @echo ' $(MULTICPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
+ $(MAKE) $*.multicpptest
+
+# Runs the testcase. Tries to run testcase_runme.php, and if that's not
+# found, runs testcase.php, except for multicpptests.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \
+ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \
+ fi
+
+# Clean: remove the generated .php file
+%.clean:
+ @rm -f $*.php;
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean
diff --git a/trunk/Examples/test-suite/php/abstract_inherit_ok_runme.php b/trunk/Examples/test-suite/php/abstract_inherit_ok_runme.php
new file mode 100644
index 000000000..c2d86499b
--- /dev/null
+++ b/trunk/Examples/test-suite/php/abstract_inherit_ok_runme.php
@@ -0,0 +1,12 @@
+<?php
+
+require "tests.php";
+require "abstract_inherit_ok.php";
+
+check::classes(array(Foo,Spam));
+$spam=new Spam();
+
+check::equal(0,$spam->blah(),"spam object method");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/abstract_inherit_runme.php b/trunk/Examples/test-suite/php/abstract_inherit_runme.php
new file mode 100644
index 000000000..3554e6fd8
--- /dev/null
+++ b/trunk/Examples/test-suite/php/abstract_inherit_runme.php
@@ -0,0 +1,14 @@
+<?php
+
+require "tests.php";
+require "abstract_inherit.php";
+
+check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));
+// 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/trunk/Examples/test-suite/php/add_link_runme.php b/trunk/Examples/test-suite/php/add_link_runme.php
new file mode 100644
index 000000000..7523bd604
--- /dev/null
+++ b/trunk/Examples/test-suite/php/add_link_runme.php
@@ -0,0 +1,22 @@
+<?php
+
+require "tests.php";
+require "add_link.php";
+
+// No new functions, except the flat functions
+check::functions(array(new_foo,foo_blah));
+
+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/trunk/Examples/test-suite/php/argout_runme.php b/trunk/Examples/test-suite/php/argout_runme.php
new file mode 100644
index 000000000..1c9026b6c
--- /dev/null
+++ b/trunk/Examples/test-suite/php/argout_runme.php
@@ -0,0 +1,37 @@
+<?php
+
+require "tests.php";
+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=copy_intp(2);
+check::equal(2,incp($p),"2==incp($p)");
+check::equal(3,intp_value($p),"3==$p");
+
+$r=copy_intp(7);
+check::equal(7,incr($r),"7==incr($r)");
+check::equal(8,intp_value($r),"8==$r");
+
+$tr=copy_intp(4);
+check::equal(4,inctr($tr),"4==incr($tr)");
+check::equal(5,intp_value($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/trunk/Examples/test-suite/php/arrayptr_runme.php b/trunk/Examples/test-suite/php/arrayptr_runme.php
new file mode 100644
index 000000000..3b9baed05
--- /dev/null
+++ b/trunk/Examples/test-suite/php/arrayptr_runme.php
@@ -0,0 +1,14 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/arrays_global_runme.php b/trunk/Examples/test-suite/php/arrays_global_runme.php
new file mode 100644
index 000000000..12a7806c9
--- /dev/null
+++ b/trunk/Examples/test-suite/php/arrays_global_runme.php
@@ -0,0 +1,19 @@
+<?php
+
+require "tests.php";
+require "arrays_global.php";
+
+check::functions(array(test_a,test_b,new_simplestruct,new_material));
+check::classes(array(arrays_global,SimpleStruct,Material));
+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,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat,simplestruct_double_field));
+// The size of array_c is 2, but the last byte is \0, so we can only store a
+// single byte string in it.
+check::set(array_c,"Z");
+check::equal("Z",check::get(array_c),"set array_c");
+check::set(array_c,"xy");
+check::equal("x",check::get(array_c),"set array_c");
+check::set(array_c,"h");
+check::equal("h",check::get(array_c),"set array_c");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/arrays_global_twodim_runme.php b/trunk/Examples/test-suite/php/arrays_global_twodim_runme.php
new file mode 100644
index 000000000..40ecf1719
--- /dev/null
+++ b/trunk/Examples/test-suite/php/arrays_global_twodim_runme.php
@@ -0,0 +1,22 @@
+<?php
+
+require "tests.php";
+require "arrays_global_twodim.php";
+
+check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
+check::classes(array(arrays_global_twodim,SimpleStruct,Material));
+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,chitmat,hitmat_val,hitmat,simplestruct_double_field));
+$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/trunk/Examples/test-suite/php/arrays_runme.php b/trunk/Examples/test-suite/php/arrays_runme.php
new file mode 100644
index 000000000..23490e61e
--- /dev/null
+++ b/trunk/Examples/test-suite/php/arrays_runme.php
@@ -0,0 +1,17 @@
+<?php
+require "tests.php";
+require "arrays.php";
+
+check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));
+check::classes(array(arrays,SimpleStruct,ArrayStruct,CartPoseData_t));
+check::globals(array(simplestruct_double_field,arraystruct_array_c,arraystruct_array_sc,arraystruct_array_uc,arraystruct_array_s,arraystruct_array_us,arraystruct_array_i,arraystruct_array_ui,arraystruct_array_l,arraystruct_array_ul,arraystruct_array_ll,arraystruct_array_f,arraystruct_array_d,arraystruct_array_struct,arraystruct_array_structpointers,arraystruct_array_ipointers,arraystruct_array_enum,arraystruct_array_enumpointers,arraystruct_array_const_i,cartposedata_t_p));
+
+$ss=new simplestruct();
+check::classname(simplestruct,$ss);
+
+$as=new arraystruct();
+$as->array_c="abc";
+check::equal($as->array_c,"a",'$as->array_c=="a"');
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/arrays_scope_runme.php b/trunk/Examples/test-suite/php/arrays_scope_runme.php
new file mode 100644
index 000000000..c208b7518
--- /dev/null
+++ b/trunk/Examples/test-suite/php/arrays_scope_runme.php
@@ -0,0 +1,16 @@
+<?php
+
+require "tests.php";
+require "arrays_scope.php";
+
+// New functions
+check::functions(array(new_bar,bar_blah));
+// New classes
+check::classes(array(arrays_scope,Bar));
+// New vars
+check::globals(array(bar_adata,bar_bdata,bar_cdata));
+
+$bar=new bar();
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/casts_runme.php b/trunk/Examples/test-suite/php/casts_runme.php
new file mode 100644
index 000000000..10522dca4
--- /dev/null
+++ b/trunk/Examples/test-suite/php/casts_runme.php
@@ -0,0 +1,18 @@
+<?php
+
+require "tests.php";
+require "casts.php";
+
+// No new functions
+check::functions(array(new_a,a_hello,new_b));
+// 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/trunk/Examples/test-suite/php/char_strings_runme.php b/trunk/Examples/test-suite/php/char_strings_runme.php
new file mode 100644
index 000000000..e06ee9d2b
--- /dev/null
+++ b/trunk/Examples/test-suite/php/char_strings_runme.php
@@ -0,0 +1,43 @@
+<?php
+
+require "tests.php";
+require "char_strings.php";
+
+$CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+$OTHERLAND_MSG_10 = "Little message from the safe world.10";
+
+check::equal(GetCharHeapString(), $CPLUSPLUS_MSG, "failed GetCharHeapString");
+check::equal(GetConstCharProgramCodeString(), $CPLUSPLUS_MSG, "failed GetConstCharProgramCodeString");
+check::equal(GetCharStaticString(), $CPLUSPLUS_MSG, "failed GetCharStaticString");
+check::equal(GetCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetCharStaticStringFixed");
+check::equal(GetConstCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetConstCharStaticStringFixed");
+
+check::equal(SetCharHeapString($OTHERLAND_MSG_10, 10), true, "failed GetConstCharStaticStringFixed");
+check::equal(SetCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharStaticString");
+check::equal(SetCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharArrayStaticString");
+check::equal(SetConstCharHeapString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharHeapString");
+check::equal(SetConstCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharStaticString");
+check::equal(SetConstCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharArrayStaticString");
+
+check::equal(CharPingPong($OTHERLAND_MSG_10), $OTHERLAND_MSG_10, "failed CharPingPong");
+
+Global_char_set($OTHERLAND_MSG_10);
+check::equal(Global_char_get(), $OTHERLAND_MSG_10, "failed Global_char_get");
+
+Global_char_array1_set($OTHERLAND_MSG_10);
+check::equal(Global_char_array1_get(), $OTHERLAND_MSG_10, "failed Global_char_array1_get");
+
+Global_char_array2_set($OTHERLAND_MSG_10);
+check::equal(Global_char_array2_get(), $OTHERLAND_MSG_10, "failed Global_char_array2_get");
+
+check::equal(Global_const_char_get(), $CPLUSPLUS_MSG, "failed Global_const_char");
+check::equal(Global_const_char_array1_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array1");
+check::equal(Global_const_char_array2_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array2");
+
+check::equal(GetCharPointerRef(), $CPLUSPLUS_MSG, "failed GetCharPointerRef");
+check::equal(SetCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetCharPointerRef");
+check::equal(GetConstCharPointerRef(), $CPLUSPLUS_MSG, "failed GetConstCharPointerRef");
+check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetConstCharPointerRef");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/class_ignore_runme.php b/trunk/Examples/test-suite/php/class_ignore_runme.php
new file mode 100644
index 000000000..d5ce36217
--- /dev/null
+++ b/trunk/Examples/test-suite/php/class_ignore_runme.php
@@ -0,0 +1,16 @@
+<?php
+
+require "tests.php";
+require "class_ignore.php";
+
+check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));
+check::classes(array(class_ignore,Bar,Boo,Far,Hoo));
+// No new vars
+check::globals(array());
+
+$bar=new bar();
+do_blah($bar);
+check::classparent($bar,"");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/conversion_namespace_runme.php b/trunk/Examples/test-suite/php/conversion_namespace_runme.php
new file mode 100644
index 000000000..e21ff7438
--- /dev/null
+++ b/trunk/Examples/test-suite/php/conversion_namespace_runme.php
@@ -0,0 +1,13 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/conversion_ns_template_runme.php b/trunk/Examples/test-suite/php/conversion_ns_template_runme.php
new file mode 100644
index 000000000..9702eedb7
--- /dev/null
+++ b/trunk/Examples/test-suite/php/conversion_ns_template_runme.php
@@ -0,0 +1,10 @@
+<?php
+
+require "tests.php";
+require "conversion_ns_template.php";
+
+check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi"));
+// this is too hard, I'm not sure what to test for,
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/conversion_runme.php b/trunk/Examples/test-suite/php/conversion_runme.php
new file mode 100644
index 000000000..1a10ff4f4
--- /dev/null
+++ b/trunk/Examples/test-suite/php/conversion_runme.php
@@ -0,0 +1,13 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/cpp_static_runme.php b/trunk/Examples/test-suite/php/cpp_static_runme.php
new file mode 100644
index 000000000..e1cc3e733
--- /dev/null
+++ b/trunk/Examples/test-suite/php/cpp_static_runme.php
@@ -0,0 +1,14 @@
+<?php
+
+require "tests.php";
+require "cpp_static.php";
+
+// New functions
+check::functions(array(staticfunctiontest_static_func,staticfunctiontest_static_func_2,staticfunctiontest_static_func_3));
+// New classes
+check::classes(array(StaticMemberTest,StaticFunctionTest));
+// New vars
+check::globals(array(staticmembertest_static_int));
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_abstract_runme.php b/trunk/Examples/test-suite/php/director_abstract_runme.php
new file mode 100644
index 000000000..ca3d676da
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_abstract_runme.php
@@ -0,0 +1,62 @@
+<?php
+
+require "tests.php";
+require "director_abstract.php";
+
+// No new functions
+check::functions(array(foo_ping,foo_pong,example0_getxsize,example0_color,example0_get_color,example1_getxsize,example1_color,example1_get_color,example2_getxsize,example2_color,example2_get_color,example4_getxsize,example4_color,example4_get_color,example3_i_color,example3_i_get_color,g,a_f));
+// No new classes
+check::classes(array(director_abstract,Foo,Example0,Example1,Example2,Example4,Example3_i,A));
+// now new vars
+check::globals(array());
+
+class MyFoo extends Foo {
+ function ping() {
+ return "MyFoo::ping()";
+ }
+}
+
+$a = new MyFoo();
+
+check::equal($a->ping(), "MyFoo::ping()", "MyFoo::ping failed");
+
+check::equal($a->pong(), "Foo::pong();MyFoo::ping()", "MyFoo::pong failed");
+
+class MyExample1 extends Example1 {
+ function Color($r, $g, $b) {
+ return $r;
+ }
+}
+
+class MyExample2 extends Example1 {
+ function Color($r, $g, $b) {
+ return $g;
+ }
+}
+
+class MyExample3 extends Example1 {
+ function Color($r, $g, $b) {
+ return $b;
+ }
+}
+
+$me1 = new MyExample1();
+check::equal($me1->Color(1, 2, 3), 1, "Example1_get_color failed");
+
+$me2 = new MyExample2(1, 2);
+check::equal($me2->Color(1, 2, 3), 2, "Example2_get_color failed");
+
+$me3 = new MyExample3();
+check::equal($me3->Color(1, 2, 3), 3, "Example3_get_color failed");
+
+$class = new ReflectionClass('Example1');
+check::equal($class->isAbstract(), true, "Example1 abstractness failed");
+
+$class = new ReflectionClass('Example2');
+check::equal($class->isAbstract(), true, "Example2 abstractness failed");
+
+$class = new ReflectionClass('Example3_i');
+check::equal($class->isAbstract(), true, "Example3_i abstractness failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_basic_runme.php b/trunk/Examples/test-suite/php/director_basic_runme.php
new file mode 100644
index 000000000..de6b50502
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_basic_runme.php
@@ -0,0 +1,58 @@
+<?php
+
+require "tests.php";
+require "director_basic.php";
+
+// No new functions
+check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method));
+// No new classes
+check::classes(array(Foo,A,A1,Bar,MyClass,MyClassT_i));
+// now new vars
+check::globals(array(bar_x));
+
+class PhpFoo extends Foo {
+ function ping() {
+ return "PhpFoo::ping()";
+ }
+}
+
+$a = new PhpFoo();
+
+check::equal($a->ping(), "PhpFoo::ping()", "ping failed");
+
+check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed");
+
+$b = new Foo();
+
+check::equal($b->ping(), "Foo::ping()", "ping failed");
+
+check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed");
+
+$a = new A1(1);
+
+check::equal($a->rg(2), 2, "rg failed");
+
+class PhpClass extends MyClass {
+ function vmethod($b) {
+ $b->x = $b->x + 31;
+ return $b;
+ }
+}
+
+$b = new Bar(3);
+$d = new MyClass();
+$c = new PhpClass();
+
+$cc = MyClass::get_self($c);
+$dd = MyClass::get_self($d);
+
+$bc = $cc->cmethod($b);
+$bd = $dd->cmethod($b);
+
+$cc->method($b);
+
+check::equal($bc->x, 34, "bc failed");
+check::equal($bd->x, 16, "bd failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_classic_runme.php b/trunk/Examples/test-suite/php/director_classic_runme.php
new file mode 100644
index 000000000..d2da1b1ba
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_classic_runme.php
@@ -0,0 +1,150 @@
+<?php
+
+require "tests.php";
+require "director_classic.php";
+
+// No new functions
+check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
+// No new classes
+check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
+// now new vars
+check::globals(array());
+
+class TargetLangPerson extends Person {
+ function id() {
+ $identifier = "TargetLangPerson";
+ return $identifier;
+ }
+}
+
+class TargetLangChild extends Child {
+ function id() {
+ $identifier = "TargetLangChild";
+ return $identifier;
+ }
+}
+
+class TargetLangGrandChild extends GrandChild {
+ function id() {
+ $identifier = "TargetLangGrandChild";
+ return $identifier;
+ }
+}
+
+# Semis - don't override id() in target language
+class TargetLangSemiPerson extends Person {
+ # No id() override
+}
+
+class TargetLangSemiChild extends Child {
+ # No id() override
+}
+
+class TargetLangSemiGrandChild extends GrandChild {
+ # No id() override
+}
+
+# Orphans - don't override id() in C++
+class TargetLangOrphanPerson extends OrphanPerson {
+ function id() {
+ $identifier = "TargetLangOrphanPerson";
+ return $identifier;
+ }
+}
+
+class TargetLangOrphanChild extends OrphanChild {
+ function id() {
+ $identifier = "TargetLangOrphanChild";
+ return $identifier;
+ }
+}
+
+function mycheck($person, $expected) {
+ $debug = 0;
+ # Normal target language polymorphic call
+ $ret = $person->id();
+ if ($debug)
+ print $ret . "\n";
+ check::equal($ret, $expected, "#1 failed");
+
+ # Polymorphic call from C++
+ $caller = new Caller();
+ $caller->setCallback($person);
+ $ret = $caller->call();
+ if ($debug)
+ print $ret . "\n";
+ check::equal($ret, $expected, "#2 failed");
+
+ # Polymorphic call of object created in target language and passed to
+ # C++ and back again
+ $baseclass = $caller->baseClass();
+ $ret = $baseclass->id();
+ if ($debug)
+ print $ret . "\n";
+ # TODO: Currently we do not track the dynamic type of returned
+ # objects, so in case it's possible that the dynamic type is not equal
+ # to the static type, we skip this check.
+ if (get_parent_class($person) === false)
+ check::equal($ret, $expected, "#3 failed");
+
+ $caller->resetCallback();
+ if ($debug)
+ print "----------------------------------------\n";
+}
+
+$person = new Person();
+mycheck($person, "Person");
+unset($person);
+
+$person = new Child();
+mycheck($person, "Child");
+unset($person);
+
+$person = new GrandChild();
+mycheck($person, "GrandChild");
+unset($person);
+
+$person = new TargetLangPerson();
+mycheck($person, "TargetLangPerson");
+unset($person);
+
+$person = new TargetLangChild();
+mycheck($person, "TargetLangChild");
+unset($person);
+
+$person = new TargetLangGrandChild();
+mycheck($person, "TargetLangGrandChild");
+unset($person);
+
+# Semis - don't override id() in target language
+$person = new TargetLangSemiPerson();
+mycheck($person, "Person");
+unset($person);
+
+$person = new TargetLangSemiChild();
+mycheck($person, "Child");
+unset($person);
+
+$person = new TargetLangSemiGrandChild();
+mycheck($person, "GrandChild");
+unset($person);
+
+# Orphans - don't override id() in C++
+$person = new OrphanPerson();
+mycheck($person, "Person");
+unset($person);
+
+$person = new OrphanChild();
+mycheck($person, "Child");
+unset($person);
+
+$person = new TargetLangOrphanPerson();
+mycheck($person, "TargetLangOrphanPerson");
+unset($person);
+
+$person = new TargetLangOrphanChild();
+mycheck($person, "TargetLangOrphanChild");
+unset($person);
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_default_runme.php b/trunk/Examples/test-suite/php/director_default_runme.php
new file mode 100644
index 000000000..f97fc7425
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_default_runme.php
@@ -0,0 +1,20 @@
+<?php
+
+require "tests.php";
+require "director_default.php";
+
+// No new functions
+check::functions(array(foo_msg,foo_getmsg,bar_msg,bar_getmsg,defaultsbase_defaultargs,defaultsderived_defaultargs));
+// No new classes
+check::classes(array(Foo,Bar,DefaultsBase,DefaultsDerived));
+// now new vars
+check::globals(array());
+
+$f = new Foo();
+$f = new Foo(1);
+
+$f = new Bar();
+$f = new Bar(1);
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_detect_runme.php b/trunk/Examples/test-suite/php/director_detect_runme.php
new file mode 100644
index 000000000..cc19c0302
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_detect_runme.php
@@ -0,0 +1,55 @@
+<?php
+
+require "tests.php";
+require "director_detect.php";
+
+// No new functions
+check::functions(array(foo_cloner,foo_get_value,foo_get_class,foo_just_do_it,bar_baseclass,bar_cloner,bar_get_value,bar_get_class,bar_just_do_it));
+// No new classes
+check::classes(array(A,Foo,Bar));
+// now new vars
+check::globals(array());
+
+class MyBar extends Bar {
+ function __construct($val = 2) {
+ parent::__construct();
+ $this->val = $val;
+ }
+
+ function get_value() {
+ $this->val = $this->val + 1;
+ return $this->val;
+ }
+
+ function get_class() {
+ $this->val = $this->val + 1;
+ return new A();
+ }
+
+ function just_do_it() {
+ $this->val = $this->val + 1;
+ }
+
+ /* clone is a reserved keyword */
+ function clone_() {
+ return new MyBar($this->val);
+ }
+}
+
+$b = new MyBar();
+
+$f = $b->baseclass();
+
+$v = $f->get_value();
+$a = $f->get_class();
+$f->just_do_it();
+
+$c = $b->clone_();
+$vc = $c->get_value();
+
+check::equal($v, 3, "f: Bad virtual detection");
+check::equal($b->val, 5, "b: Bad virtual detection");
+check::equal($vc, 6, "c: Bad virtual detection");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_enum_runme.php b/trunk/Examples/test-suite/php/director_enum_runme.php
new file mode 100644
index 000000000..8f6487a28
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_enum_runme.php
@@ -0,0 +1,25 @@
+<?php
+
+require "tests.php";
+require "director_enum.php";
+
+// No new functions
+check::functions(array(foo_say_hello,foo_say_hi,foo_say_bye,foo_say_hi_ref,foo_ping,foo_ping_ref,foo_ping_member_enum,a_f,a2_f));
+// No new classes
+check::classes(array(director_enum,Foo,A,B,A2,B2));
+// now new vars
+check::globals(array());
+
+class MyFoo extends Foo {
+ function say_hi($val) {
+ return $val;
+ }
+}
+
+$b = new Foo();
+$a = new MyFoo();
+
+check::equal($a->say_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_exception_runme.php b/trunk/Examples/test-suite/php/director_exception_runme.php
new file mode 100644
index 000000000..33e6e9b52
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_exception_runme.php
@@ -0,0 +1,78 @@
+<?php
+
+require "tests.php";
+require "director_exception.php";
+
+// No new functions
+check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang));
+// No new classes
+check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar));
+// now new vars
+check::globals(array());
+
+class MyException extends Exception {
+ function __construct($a, $b) {
+ $this->msg = $a . $b;
+ }
+}
+
+class MyFoo extends Foo {
+ function ping() {
+ throw new Exception("MyFoo::ping() EXCEPTION");
+ }
+}
+
+class MyFoo2 extends Foo {
+ function ping() {
+ return true;
+ }
+}
+
+class MyFoo3 extends Foo {
+ function ping() {
+ throw new MyException("foo", "bar");
+ }
+}
+
+# Check that the Exception raised by MyFoo.ping() is returned by
+# MyFoo.pong().
+$ok = 0;
+$a = new MyFoo();
+# TODO: Currently we do not track the dynamic type of returned
+# objects, so we skip the launder() call.
+#$b = director_exception::launder($a);
+$b = $a;
+try {
+ $b->pong();
+} catch (Exception $e) {
+ $ok = 1;
+ check::equal($e->getMessage(), "MyFoo::ping() EXCEPTION", "Unexpected error message #1");
+}
+check::equal($ok, 1, "Got no exception while expected one #1");
+
+# Check that the director can return an exception which requires two
+# arguments to the constructor, without mangling it.
+$ok = 0;
+$a = new MyFoo3();
+#$b = director_exception::launder($a);
+$b = $a;
+try {
+ $b->pong();
+} catch (Exception $e) {
+ $ok = 1;
+ check::equal($e->msg, "foobar", "Unexpected error message #2");
+}
+check::equal($ok, 1, "Got no exception while expected one #2");
+
+try {
+ throw new Exception2();
+} catch (Exception2 $e2) {
+}
+
+try {
+ throw new Exception1();
+} catch (Exception1 $e1) {
+}
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_extend_runme.php b/trunk/Examples/test-suite/php/director_extend_runme.php
new file mode 100644
index 000000000..f283aefbe
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_extend_runme.php
@@ -0,0 +1,24 @@
+<?php
+
+require "tests.php";
+require "director_extend.php";
+
+// No new functions
+check::functions(array(spobject_getfoobar,spobject_dummy,spobject_exceptionmethod));
+// No new classes
+check::classes(array(SpObject));
+// now new vars
+check::globals(array());
+
+class MyObject extends SpObject{
+ function getFoo() {
+ return 123;
+ }
+}
+
+$m = new MyObject();
+check::equal($m->dummy(), 666, "1st call");
+check::equal($m->dummy(), 666, "2st call"); // Locked system
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_finalizer_runme.php b/trunk/Examples/test-suite/php/director_finalizer_runme.php
new file mode 100644
index 000000000..0fcddfd8b
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_finalizer_runme.php
@@ -0,0 +1,61 @@
+<?php
+
+require "tests.php";
+require "director_finalizer.php";
+
+// No new functions
+check::functions(array(foo_orstatus,deletefoo,getstatus,launder,resetstatus));
+// No new classes
+check::classes(array(director_finalizer,Foo));
+// now new vars
+check::globals(array());
+
+class MyFoo extends Foo {
+ function __destruct() {
+ $this->orStatus(2);
+ if (method_exists(parent, "__destruct")) {
+ parent::__destruct();
+ }
+ }
+}
+
+resetStatus();
+
+$a = new MyFoo();
+unset($a);
+
+check::equal(getStatus(), 3, "getStatus() failed #1");
+
+resetStatus();
+
+$a = new MyFoo();
+launder($a);
+
+check::equal(getStatus(), 0, "getStatus() failed #2");
+
+unset($a);
+
+check::equal(getStatus(), 3, "getStatus() failed #3");
+
+resetStatus();
+
+$a = new MyFoo();
+$a->thisown = 0;
+deleteFoo($a);
+unset($a);
+
+check::equal(getStatus(), 3, "getStatus() failed #4");
+
+resetStatus();
+
+$a = new MyFoo();
+$a->thisown = 0;
+deleteFoo(launder($a));
+unset($a);
+
+check::equal(getStatus(), 3, "getStatus() failed #5");
+
+resetStatus();
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_frob_runme.php b/trunk/Examples/test-suite/php/director_frob_runme.php
new file mode 100644
index 000000000..548b0b804
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_frob_runme.php
@@ -0,0 +1,19 @@
+<?php
+
+require "tests.php";
+require "director_frob.php";
+
+// No new functions
+check::functions(array(alpha_abs_method,bravo_abs_method,charlie_abs_method,ops_opint,ops_opintstarstarconst,ops_opintamp,ops_opintstar,ops_opconstintintstar,prims_ull,prims_callull,corecallbacks_on3dengineredrawn,corecallbacks_on3dengineredrawn2));
+// No new classes
+check::classes(array(Alpha,Bravo,Charlie,Delta,Ops,Prims,corePoint3d,coreCallbacks_On3dEngineRedrawnData,coreCallbacksOn3dEngineRedrawnData,coreCallbacks));
+// now new vars
+check::globals(array(corecallbacks_on3dengineredrawndata__eye,corecallbacks_on3dengineredrawndata__at,corecallbackson3dengineredrawndata__eye,corecallbackson3dengineredrawndata__at));
+
+$foo = new Bravo();
+$s = $foo->abs_method();
+
+check::equal($s, "Bravo::abs_method()", "s failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_nested_runme.php b/trunk/Examples/test-suite/php/director_nested_runme.php
new file mode 100644
index 000000000..4965e94f7
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_nested_runme.php
@@ -0,0 +1,74 @@
+<?php
+
+require "tests.php";
+require "director_nested.php";
+
+// No new functions
+check::functions(array(foo_int_advance,foo_int_do_advance,bar_step,bar_do_advance,bar_do_step,foobar_int_get_value,foobar_int_get_name,foobar_int_name,foobar_int_get_self,foobar_int_do_advance,foobar_int_do_step));
+// No new classes
+check::classes(array(Foo_int,Bar,FooBar_int));
+// now new vars
+check::globals(array());
+
+class A extends FooBar_int {
+ function do_step() {
+ return "A::do_step;";
+ }
+
+ function get_value() {
+ return "A::get_value";
+ }
+}
+
+$a = new A();
+check::equal($a->step(), "Bar::step;Foo::advance;Bar::do_advance;A::do_step;", "Bad A virtual resolution");
+
+class B extends FooBar_int {
+ function do_advance() {
+ return "B::do_advance;" . $this->do_step();
+ }
+
+ function do_step() {
+ return "B::do_step;";
+ }
+
+ function get_value() {
+ return 1;
+ }
+}
+
+$b = new B();
+
+check::equal($b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", "Bad B virtual resolution");
+
+class C extends FooBar_int {
+ function do_advance() {
+ return "C::do_advance;" . parent::do_advance();
+ }
+
+ function do_step() {
+ return "C::do_step;";
+ }
+
+ function get_value() {
+ return 2;
+ }
+
+ function get_name() {
+ return parent::get_name() . " hello";
+ }
+}
+
+$cc = new C();
+# TODO: Currently we do not track the dynamic type of returned
+# objects, so we skip the get_self() call.
+#$c = Foobar_int::get_self($cc);
+$c = $cc;
+$c->advance();
+
+check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed");
+
+check::equal($c->name(), "FooBar::get_name hello", "name failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_profile_runme.php b/trunk/Examples/test-suite/php/director_profile_runme.php
new file mode 100644
index 000000000..c72421341
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_profile_runme.php
@@ -0,0 +1,53 @@
+<?php
+
+require "tests.php";
+require "director_profile.php";
+
+// No new functions
+check::functions(array(b_fn,b_vfi,b_fi,b_fj,b_fk,b_fl,b_get_self,b_vfs,b_fs));
+// No new classes
+check::classes(array(A,B));
+// now new vars
+check::globals(array());
+
+class MyB extends B {
+ function vfi($a) {
+ return $a+3;
+ }
+}
+
+$a = new A();
+$myb = new MyB();
+$b = B::get_self($myb);
+
+$i = 50000;
+$a = 1;
+
+while ($i) {
+ $a = $b->fi($a); #1
+ $a = $b->fi($a); #2
+ $a = $b->fi($a); #3
+ $a = $b->fi($a); #4
+ $a = $b->fi($a); #5
+ $a = $b->fi($a); #6
+ $a = $b->fi($a); #7
+ $a = $b->fi($a); #8
+ $a = $b->fi($a); #9
+ $a = $b->fi($a); #10
+ $a = $b->fi($a); #1
+ $a = $b->fi($a); #2
+ $a = $b->fi($a); #3
+ $a = $b->fi($a); #4
+ $a = $b->fi($a); #5
+ $a = $b->fi($a); #6
+ $a = $b->fi($a); #7
+ $a = $b->fi($a); #8
+ $a = $b->fi($a); #9
+ $a = $b->fi($a); #20
+ $i -= 1;
+}
+
+print $a . "\n";
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_protected_runme.php b/trunk/Examples/test-suite/php/director_protected_runme.php
new file mode 100644
index 000000000..73bcba1fd
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_protected_runme.php
@@ -0,0 +1,54 @@
+<?php
+
+require "tests.php";
+require "director_protected.php";
+
+// No new functions
+check::functions(array(foo_pong,foo_s,foo_q,foo_ping,foo_pang,foo_used,bar_create,bar_pong,bar_used,bar_ping,bar_pang,a_draw,b_draw));
+// No new classes
+check::classes(array(Foo,Bar,PrivateFoo,A,B,AA,BB));
+// now new vars
+check::globals(array(bar_a));
+
+class FooBar extends Bar {
+ protected function ping() {
+ return "FooBar::ping();";
+ }
+}
+
+class FooBar2 extends Bar {
+ function ping() {
+ return "FooBar2::ping();";
+ }
+
+ function pang() {
+ return "FooBar2::pang();";
+ }
+}
+
+$b = new Bar();
+$f = $b->create();
+$fb = new FooBar();
+$fb2 = new FooBar2();
+
+check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
+
+check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
+
+check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
+
+check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
+
+check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
+
+$method = new ReflectionMethod('Bar', 'ping');
+check::equal($method->isProtected(), true, "Boo::ping should be protected");
+
+$method = new ReflectionMethod('Foo', 'ping');
+check::equal($method->isProtected(), true, "Foo::ping should be protected");
+
+$method = new ReflectionMethod('FooBar', 'pang');
+check::equal($method->isProtected(), true, "FooBar::pang should be protected");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_stl_runme.php b/trunk/Examples/test-suite/php/director_stl_runme.php
new file mode 100644
index 000000000..29addd261
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_stl_runme.php
@@ -0,0 +1,60 @@
+<?php
+
+require "tests.php";
+require "director_stl.php";
+
+// No new functions
+check::functions(array(foo_bar,foo_ping,foo_pong,foo_tping,foo_tpong,foo_pident,foo_vident,foo_vsecond,foo_tpident,foo_tvident,foo_tvsecond,foo_vidents,foo_tvidents));
+// No new classes
+check::classes(array(Foo));
+// now new vars
+check::globals(array());
+
+class MyFoo extends Foo {
+ function ping($s) {
+ return "MyFoo::ping():" . $s;
+ }
+
+ function pident($arg) {
+ return $arg;
+ }
+
+ function vident($v) {
+ return $v;
+ }
+
+ function vidents($v) {
+ return $v;
+ }
+
+ function vsecond($v1, $v2) {
+ return $v2;
+ }
+}
+
+$a = new MyFoo();
+
+$a->tping("hello");
+$a->tpong("hello");
+
+# TODO: automatic conversion between PHP arrays and std::pair or
+# std::vector is not yet implemented.
+/*$p = array(1, 2);
+$a->pident($p);
+$v = array(3, 4);
+$a->vident($v);
+
+$a->tpident($p);
+$a->tvident($v);
+
+$v1 = array(3, 4);
+$v2 = array(5, 6);
+
+$a->tvsecond($v1, $v2);
+
+$vs = array("hi", "hello");
+$vs;
+$a->tvidents($vs);*/
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_string_runme.php b/trunk/Examples/test-suite/php/director_string_runme.php
new file mode 100644
index 000000000..5ac583f78
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_string_runme.php
@@ -0,0 +1,34 @@
+<?php
+
+require "tests.php";
+require "director_string.php";
+
+// No new functions
+check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop,stringvector_capacity,stringvector_reserve));
+// No new classes
+check::classes(array(A,StringVector));
+// now new vars
+check::globals(array(a,a_call,a_m_strings,stringvector));
+
+class B extends A {
+ function get_first() {
+ return parent::get_first() . " world!";
+ }
+
+ function process_text($string) {
+ parent::process_text($string);
+ $this->smem = "hello";
+ }
+}
+
+$b = new B("hello");
+
+$b->get(0);
+check::equal($b->get_first(),"hello world!", "get_first failed");
+
+$b->call_process_func();
+
+check::equal($b->smem, "hello", "smem failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_thread_runme.php b/trunk/Examples/test-suite/php/director_thread_runme.php
new file mode 100644
index 000000000..8df25d969
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_thread_runme.php
@@ -0,0 +1,29 @@
+<?php
+
+require "tests.php";
+require "director_thread.php";
+
+// No new functions
+check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
+// No new classes
+check::classes(array(director_thread,Foo));
+// now new vars
+check::globals(array(foo_val));
+
+class Derived extends Foo {
+ function do_foo() {
+ $this->val = $this->val - 1;
+ }
+}
+
+$d = new Derived();
+$d->run();
+
+if ($d->val >= 0) {
+ check::fail($d->val);
+}
+
+$d->stop();
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/director_unroll_runme.php b/trunk/Examples/test-suite/php/director_unroll_runme.php
new file mode 100644
index 000000000..626b1f07d
--- /dev/null
+++ b/trunk/Examples/test-suite/php/director_unroll_runme.php
@@ -0,0 +1,29 @@
+<?php
+
+require "tests.php";
+require "director_unroll.php";
+
+// No new functions
+check::functions(array(foo_ping,foo_pong));
+// No new classes
+check::classes(array(Foo,Bar));
+// now new vars
+check::globals(array(bar));
+
+class MyFoo extends Foo {
+ function ping() {
+ return "MyFoo::ping()";
+ }
+}
+
+$a = new MyFoo();
+
+$b = new Bar();
+
+$b->set($a);
+$c = $b->get();
+
+check::equal($a->this, $c->this, "this failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/enum_scope_template_runme.php b/trunk/Examples/test-suite/php/enum_scope_template_runme.php
new file mode 100644
index 000000000..85ba467b7
--- /dev/null
+++ b/trunk/Examples/test-suite/php/enum_scope_template_runme.php
@@ -0,0 +1,15 @@
+<?php
+require "tests.php";
+require "enum_scope_template.php";
+
+check::classes(array("enum_scope_template", "TreeInt"));
+check::functions(array("chops","treeint_chops"));
+check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
+check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
+check::equal(2,TreeInt_Cedar,"2==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/trunk/Examples/test-suite/php/evil_diamond_ns_runme.php b/trunk/Examples/test-suite/php/evil_diamond_ns_runme.php
new file mode 100644
index 000000000..fcce0f767
--- /dev/null
+++ b/trunk/Examples/test-suite/php/evil_diamond_ns_runme.php
@@ -0,0 +1,18 @@
+<?php
+
+require "tests.php";
+require "evil_diamond_ns.php";
+
+check::classes(array("evil_diamond_ns","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/trunk/Examples/test-suite/php/evil_diamond_prop_runme.php b/trunk/Examples/test-suite/php/evil_diamond_prop_runme.php
new file mode 100644
index 000000000..02d9944d6
--- /dev/null
+++ b/trunk/Examples/test-suite/php/evil_diamond_prop_runme.php
@@ -0,0 +1,38 @@
+<?php
+
+require "tests.php";
+require "evil_diamond_prop.php";
+
+check::classes(array("evil_diamond_prop","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");
+// multiple inheritance not supported in PHP
+check::equal(null,$spam->_baz,"null==spam->_baz");
+check::equal(4,$spam->_spam,"4==spam->_spam");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/evil_diamond_runme.php b/trunk/Examples/test-suite/php/evil_diamond_runme.php
new file mode 100644
index 000000000..a587ca359
--- /dev/null
+++ b/trunk/Examples/test-suite/php/evil_diamond_runme.php
@@ -0,0 +1,16 @@
+<?php
+
+require "tests.php";
+require "evil_diamond.php";
+
+check::classes(array("evil_diamond","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/trunk/Examples/test-suite/php/exception_order_runme.php b/trunk/Examples/test-suite/php/exception_order_runme.php
new file mode 100644
index 000000000..a83598170
--- /dev/null
+++ b/trunk/Examples/test-suite/php/exception_order_runme.php
@@ -0,0 +1,39 @@
+<?
+require "tests.php";
+require "exception_order.php";
+
+check::functions(array(a_foo,a_bar,a_foobar,a_barfoo));
+check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
+check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
+
+$a = new A();
+try {
+ $a->foo();
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
+}
+
+try {
+ $a->bar();
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'C++ E2 exception thrown', '');
+}
+
+try {
+ $a->foobar();
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'postcatch unknown', '');
+}
+
+try {
+ $a->barfoo(1);
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
+}
+
+try {
+ $a->barfoo(2);
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'C++ E2 * exception thrown', '');
+}
+?>
diff --git a/trunk/Examples/test-suite/php/extend_template_ns_runme.php b/trunk/Examples/test-suite/php/extend_template_ns_runme.php
new file mode 100644
index 000000000..e6d3e9f73
--- /dev/null
+++ b/trunk/Examples/test-suite/php/extend_template_ns_runme.php
@@ -0,0 +1,12 @@
+<?php
+
+require "tests.php";
+require "extend_template_ns.php";
+
+check::classes(array("extend_template_ns","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/trunk/Examples/test-suite/php/extend_template_runme.php b/trunk/Examples/test-suite/php/extend_template_runme.php
new file mode 100644
index 000000000..41bde4458
--- /dev/null
+++ b/trunk/Examples/test-suite/php/extend_template_runme.php
@@ -0,0 +1,12 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/grouping_runme.php b/trunk/Examples/test-suite/php/grouping_runme.php
new file mode 100644
index 000000000..51446f473
--- /dev/null
+++ b/trunk/Examples/test-suite/php/grouping_runme.php
@@ -0,0 +1,22 @@
+<?php
+
+require "tests.php";
+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::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/ignore_parameter_runme.php b/trunk/Examples/test-suite/php/ignore_parameter_runme.php
new file mode 100644
index 000000000..1c8c76ad4
--- /dev/null
+++ b/trunk/Examples/test-suite/php/ignore_parameter_runme.php
@@ -0,0 +1,38 @@
+<?php
+
+require "tests.php";
+require "ignore_parameter.php";
+
+// New functions
+check::functions(array(jaguar,lotus,tvr,ferrari,sportscars_daimler,sportscars_astonmartin,sportscars_bugatti,sportscars_lamborghini));
+// New classes
+check::classes(array(ignore_parameter,SportsCars,MiniCooper,MorrisMinor,FordAnglia,AustinAllegro));
+// No 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/trunk/Examples/test-suite/php/import_nomodule_runme.php b/trunk/Examples/test-suite/php/import_nomodule_runme.php
new file mode 100644
index 000000000..84191fba9
--- /dev/null
+++ b/trunk/Examples/test-suite/php/import_nomodule_runme.php
@@ -0,0 +1,20 @@
+<?php
+require "tests.php";
+require "import_nomodule.php";
+
+// No new functions
+check::functions(array(create_foo,delete_foo,test1));
+// No new classes
+check::classes(array(import_nomodule,Bar));
+// now new vars
+check::globals(array());
+
+$f = import_nomodule::create_Foo();
+import_nomodule::test1($f,42);
+import_nomodule::delete_Foo($f);
+
+$b = new Bar();
+import_nomodule::test1($b,37);
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/li_carrays_runme.php b/trunk/Examples/test-suite/php/li_carrays_runme.php
new file mode 100644
index 000000000..fbe5cc793
--- /dev/null
+++ b/trunk/Examples/test-suite/php/li_carrays_runme.php
@@ -0,0 +1,22 @@
+<?php
+require "tests.php";
+require "li_carrays.php";
+
+// Check functions.
+check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem));
+
+// Check classes.
+// NB An "li_carrays" class is created as a mock namespace.
+check::classes(array(li_carrays,doubleArray,AB,XY,XYArray));
+
+// Check global variables.
+check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
+
+$d = new doubleArray(10);
+
+$d->setitem(0, 7);
+$d->setitem(5, $d->getitem(0) + 3);
+check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/li_factory_runme.php b/trunk/Examples/test-suite/php/li_factory_runme.php
new file mode 100644
index 000000000..6623e2a8c
--- /dev/null
+++ b/trunk/Examples/test-suite/php/li_factory_runme.php
@@ -0,0 +1,22 @@
+<?php
+
+require "tests.php";
+require "li_factory.php";
+
+// No new functions
+check::functions(array(geometry_draw,geometry_create,geometry_clone_,point_draw,point_width,point_clone_,circle_draw,circle_radius,circle_clone_));
+// No new classes
+check::classes(array(Geometry,Point,Circle));
+// now new vars
+check::globals(array());
+
+$circle = Geometry::create(Geometry::CIRCLE);
+$r = $circle->radius();
+check::equal($r, 1.5, "r failed");
+
+$point = Geometry::create(Geometry::POINT);
+$w = $point->width();
+check::equal($w, 1.0, "w failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/li_std_string_runme.php b/trunk/Examples/test-suite/php/li_std_string_runme.php
new file mode 100644
index 000000000..ad62247e1
--- /dev/null
+++ b/trunk/Examples/test-suite/php/li_std_string_runme.php
@@ -0,0 +1,31 @@
+<?php
+
+require "tests.php";
+require "li_std_string.php";
+
+// Global variables
+//$s="initial string";
+//check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
+
+// Global variables
+$s = "initial string";
+check::equal(GlobalString2_get(), "global string 2", "GlobalString2 test 1");
+GlobalString2_set($s);
+check::equal(GlobalString2_get(), $s, "GlobalString2 test 2");
+check::equal(ConstGlobalString_get(), "const global string", "ConstGlobalString test");
+
+// Member variables
+$myStructure = new Structure();
+check::equal($myStructure->MemberString2, "member string 2", "MemberString2 test 1");
+$myStructure->MemberString2 = $s;
+check::equal($myStructure->MemberString2, $s, "MemberString2 test 2");
+check::equal($myStructure->ConstMemberString, "const member string", "ConstMemberString test");
+
+check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1");
+Structure::StaticMemberString2($s);
+check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2");
+// below broken ?
+//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/newobject1_runme.php b/trunk/Examples/test-suite/php/newobject1_runme.php
new file mode 100644
index 000000000..5853a72c0
--- /dev/null
+++ b/trunk/Examples/test-suite/php/newobject1_runme.php
@@ -0,0 +1,19 @@
+<?php
+
+require "tests.php";
+require "newobject1.php";
+
+// No new functions
+check::functions(array(foo_makefoo,foo_makemore,foo_foocount));
+// No new classes
+check::classes(array(Foo));
+// now new vars
+check::globals(array());
+
+$foo = Foo::makeFoo();
+check::equal(get_class($foo), "Foo", "static failed");
+$bar = $foo->makeMore();
+check::equal(get_class($bar), "Foo", "regular failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/overload_rename_runme.php b/trunk/Examples/test-suite/php/overload_rename_runme.php
new file mode 100644
index 000000000..dce4c6cb3
--- /dev/null
+++ b/trunk/Examples/test-suite/php/overload_rename_runme.php
@@ -0,0 +1,19 @@
+<?php
+
+require "tests.php";
+require "overload_rename.php";
+
+// No new functions
+check::functions(array());
+// No new classes
+check::classes(array(Foo));
+// now new vars
+check::globals(array());
+
+$f = new Foo(1.0);
+$f = new Foo(1.0,1.0);
+$f = Foo::Foo_int(1.0,1);
+$f = Foo::Foo_int(1.0,1,1.0);
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/pointer_reference_runme.php b/trunk/Examples/test-suite/php/pointer_reference_runme.php
new file mode 100644
index 000000000..782760a37
--- /dev/null
+++ b/trunk/Examples/test-suite/php/pointer_reference_runme.php
@@ -0,0 +1,15 @@
+<?php
+
+require "tests.php";
+require "pointer_reference.php";
+
+$s = pointer_reference::get();
+check::equal($s->value, 10, "pointer_reference::get() failed");
+
+$ss = new Struct(20);
+pointer_reference::set($ss);
+$i = Struct::instance();
+check::equal($i->value, 20, "pointer_reference::set() failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/prefix_runme.php b/trunk/Examples/test-suite/php/prefix_runme.php
new file mode 100644
index 000000000..ead064f5b
--- /dev/null
+++ b/trunk/Examples/test-suite/php/prefix_runme.php
@@ -0,0 +1,18 @@
+<?php
+
+require "tests.php";
+require "prefix.php";
+
+// No new functions
+check::functions(array(foo_get_self));
+// No new classes
+check::classes(array(ProjectFoo));
+// now new vars
+check::globals(array());
+
+$f = new ProjectFoo();
+// This resulted in "Fatal error: Class 'Foo' not found"
+$f->get_self();
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/primitive_ref_runme.php b/trunk/Examples/test-suite/php/primitive_ref_runme.php
new file mode 100644
index 000000000..263a28074
--- /dev/null
+++ b/trunk/Examples/test-suite/php/primitive_ref_runme.php
@@ -0,0 +1,34 @@
+<?php
+
+require "tests.php";
+require "primitive_ref.php";
+
+# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
+# The conversion to double can lose precision so this isn't an exact comparison.
+function long_long_equal($a,$b,$message) {
+ if (! ($a===$b))
+ if (! ((double)$a===$b))
+ return check::fail($message . ": '$a'!=='$b'");
+ return TRUE;
+}
+
+
+check::equal(ref_over(3), 3, "ref_over failed");
+
+check::equal(ref_int(3), 3, "ref_int failed");
+check::equal(ref_uint(3), 3, "ref_uint failed");
+check::equal(ref_short(3), 3, "ref_short failed");
+check::equal(ref_ushort(3), 3, "ref_ushort failed");
+check::equal(ref_long(3), 3, "ref_long failed");
+check::equal(ref_ulong(3), 3, "ref_ulong failed");
+check::equal(ref_schar(3), 3, "ref_schar failed");
+check::equal(ref_uchar(3), 3, "ref_uchar failed");
+check::equal(ref_bool(true), true, "ref_bool failed");
+check::equal(ref_float(3.5), 3.5, "ref_float failed");
+check::equal(ref_double(3.5), 3.5, "ref_double failed");
+check::equal(ref_char('x'), 'x', "ref_char failed");
+long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
+long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/rename_scope_runme.php b/trunk/Examples/test-suite/php/rename_scope_runme.php
new file mode 100644
index 000000000..df620d796
--- /dev/null
+++ b/trunk/Examples/test-suite/php/rename_scope_runme.php
@@ -0,0 +1,16 @@
+<?php
+
+require "tests.php";
+require "rename_scope.php";
+
+check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));
+
+check::classmethods("Interface_UP",array("__construct","__set","__isset","__get"));
+check::classmethods("Interface_BP",array("__construct","__set","__isset","__get"));
+check::classmethods("Natural_UP",array("__construct","__set","__isset","__get","rtest"));
+check::classmethods("Natural_BP",array("__construct","__set","__isset","__get","rtest"));
+check::classparent("Natural_UP","Interface_UP");
+check::classparent("Natural_BP","Interface_BP");
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php/skel.php b/trunk/Examples/test-suite/php/skel.php
new file mode 100644
index 000000000..780a999ed
--- /dev/null
+++ b/trunk/Examples/test-suite/php/skel.php
@@ -0,0 +1,15 @@
+<?php
+// Sample test file
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/smart_pointer_rename_runme.php b/trunk/Examples/test-suite/php/smart_pointer_rename_runme.php
new file mode 100644
index 000000000..26692dde5
--- /dev/null
+++ b/trunk/Examples/test-suite/php/smart_pointer_rename_runme.php
@@ -0,0 +1,27 @@
+<?php
+
+require "tests.php";
+require "smart_pointer_rename.php";
+
+check::classes(array("Foo","Bar"));
+check::classmethods("foo",array("ftest1","ftest2","__set","__isset","__get","__construct"));
+check::classmethods("bar",array("__deref__","test","ftest1","ftest2","__set","__isset","__get","__construct"));
+$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/trunk/Examples/test-suite/php/sym_runme.php b/trunk/Examples/test-suite/php/sym_runme.php
new file mode 100644
index 000000000..483aaa980
--- /dev/null
+++ b/trunk/Examples/test-suite/php/sym_runme.php
@@ -0,0 +1,22 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/template_arg_typename_runme.php b/trunk/Examples/test-suite/php/template_arg_typename_runme.php
new file mode 100644
index 000000000..87d07de03
--- /dev/null
+++ b/trunk/Examples/test-suite/php/template_arg_typename_runme.php
@@ -0,0 +1,18 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/template_construct_runme.php b/trunk/Examples/test-suite/php/template_construct_runme.php
new file mode 100644
index 000000000..3a3986f7e
--- /dev/null
+++ b/trunk/Examples/test-suite/php/template_construct_runme.php
@@ -0,0 +1,11 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/tests.php b/trunk/Examples/test-suite/php/tests.php
new file mode 100644
index 000000000..57c5c4788
--- /dev/null
+++ b/trunk/Examples/test-suite/php/tests.php
@@ -0,0 +1,232 @@
+<?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)) || ereg('^new_', $func)
+ || ereg('_(alter|get)_newobject$', $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 (!is_object($object))
+ return check::fail("The second argument is a " . gettype($object) . ", not an object.");
+ if (strtolower($string)!=strtolower($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 ($message) {
+ return check::fail("Class %s %s\nFull class list:\n %s\n",$classname,join("\nbut ",$message),join("\n ",get_class_methods($classname)));
+ }
+ if ($extra) $message[]="Class ".$classname." has these extra methods:\n ".join(",",$extra);
+ if ($message) return check::warn(join("\n ",$message));
+ 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 ($message) return check::fail(join("\n ",$message));
+ if ($extra) $message[]=sprintf("These extra classes are defined: %s",join(",",array_keys($extra)));
+ if ($message) return check::warn(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 ($message) return check::fail(join("\n ",$message));
+ if ($extra) $message[]=sprintf("These extra functions are defined: %s",join(",",array_keys($extra)));
+ if ($message) return check::warn(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 ($message) return check::fail(join("\n ",$message));
+ if ($extra) $message[]=sprintf("These extra globals are defined: %s",join(",",array_keys($extra)));
+ if ($message) return check::warn(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 . ": '$a'!=='$b'");
+ 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 warn($pattern) {
+ $args=func_get_args();
+ print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
+ return FALSE;
+ }
+
+ function done() {
+# print $_SERVER[argv][0]." ok\n";
+ }
+}
+?>
diff --git a/trunk/Examples/test-suite/php/threads_exception_runme.php b/trunk/Examples/test-suite/php/threads_exception_runme.php
new file mode 100755
index 000000000..31148a1e1
--- /dev/null
+++ b/trunk/Examples/test-suite/php/threads_exception_runme.php
@@ -0,0 +1,43 @@
+<?php
+
+require "tests.php";
+require "threads_exception.php";
+
+// Check functions
+check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi));
+// Check classes.
+check::classes(array(Exc,Test));
+// Chek globals.
+check::globals(array(exc_code,exc_msg));
+
+$t = new Test();
+try {
+ $t->unknown();
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'C++ A * exception thrown', '');
+}
+
+try {
+ $t->simple();
+} catch (Exception $e) {
+ check::equal($e->getCode(), 37, '');
+}
+
+try {
+ $t->message();
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'I died.', '');
+}
+
+try {
+ $t->hosed();
+} catch (Exception $e) {
+ check::equal($e->getMessage(), 'C++ Exc exception thrown', '');
+}
+
+foreach (Array(1,2,3,4) as $i) {
+ try {
+ $t->multi($i);
+ } catch (Exception $e) {
+ }
+}
diff --git a/trunk/Examples/test-suite/php/typedef_reference_runme.php b/trunk/Examples/test-suite/php/typedef_reference_runme.php
new file mode 100644
index 000000000..88a70f8d3
--- /dev/null
+++ b/trunk/Examples/test-suite/php/typedef_reference_runme.php
@@ -0,0 +1,13 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/typemap_ns_using_runme.php b/trunk/Examples/test-suite/php/typemap_ns_using_runme.php
new file mode 100644
index 000000000..6a599f008
--- /dev/null
+++ b/trunk/Examples/test-suite/php/typemap_ns_using_runme.php
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/using1_runme.php b/trunk/Examples/test-suite/php/using1_runme.php
new file mode 100644
index 000000000..51841bc78
--- /dev/null
+++ b/trunk/Examples/test-suite/php/using1_runme.php
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/using2_runme.php b/trunk/Examples/test-suite/php/using2_runme.php
new file mode 100644
index 000000000..391a98f52
--- /dev/null
+++ b/trunk/Examples/test-suite/php/using2_runme.php
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php";
+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/trunk/Examples/test-suite/php/valuewrapper_base_runme.php b/trunk/Examples/test-suite/php/valuewrapper_base_runme.php
new file mode 100644
index 000000000..6a1abdbd2
--- /dev/null
+++ b/trunk/Examples/test-suite/php/valuewrapper_base_runme.php
@@ -0,0 +1,13 @@
+<?php
+
+require "tests.php";
+require "valuewrapper_base.php";
+
+check::classes(array("valuewrapper_base","Base","Interface_BP"));
+check::functions("make_interface_bp");
+
+$ibp=valuewrapper_base::make_interface_bp();
+check::classname("interface_bp",$ibp);
+
+check::done();
+?>
diff --git a/trunk/Examples/test-suite/php_namewarn_rename.i b/trunk/Examples/test-suite/php_namewarn_rename.i
new file mode 100644
index 000000000..e3447a9c4
--- /dev/null
+++ b/trunk/Examples/test-suite/php_namewarn_rename.i
@@ -0,0 +1,29 @@
+%module php_namewarn_rename
+
+#ifdef SWIGPHP
+%warnfilter(SWIGWARN_PARSE_KEYWORD) Empty();
+%warnfilter(SWIGWARN_PARSE_KEYWORD) stdClass;
+%warnfilter(SWIGWARN_PARSE_KEYWORD) directory;
+%warnfilter(SWIGWARN_PARSE_KEYWORD) Hello::empty();
+#endif
+
+%inline %{
+
+ int Exception() { return 13; }
+
+ void Empty() {}
+
+ class stdClass
+ {
+ };
+
+ class directory
+ {
+ };
+
+ struct Hello
+ {
+ void empty() {}
+ };
+
+%}
diff --git a/trunk/Examples/test-suite/pike/Makefile.in b/trunk/Examples/test-suite/pike/Makefile.in
new file mode 100644
index 000000000..389dc74f8
--- /dev/null
+++ b/trunk/Examples/test-suite/pike/Makefile.in
@@ -0,0 +1,49 @@
+#######################################################################
+# Makefile for Pike test-suite
+#######################################################################
+
+LANGUAGE = pike
+PIKE = pike
+SCRIPTSUFFIX = _runme.pike
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.pike appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: remove the generated .pike file
+%.clean:
+ @rm -f $*.pike;
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile pike_clean
+
diff --git a/trunk/Examples/test-suite/pointer_in_out.i b/trunk/Examples/test-suite/pointer_in_out.i
new file mode 100644
index 000000000..f4b1ed440
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/pointer_reference.i b/trunk/Examples/test-suite/pointer_reference.i
new file mode 100644
index 000000000..c57a32374
--- /dev/null
+++ b/trunk/Examples/test-suite/pointer_reference.i
@@ -0,0 +1,44 @@
+/* This interface file tests whether SWIG handles pointer-reference
+ (*&) arguments.
+
+ SWIG 1.3a5 signals a syntax error.
+*/
+
+%module pointer_reference
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
+
+#ifdef SWIGGUILE
+/* A silly testing typemap for feeding a doubly indirect integer */
+%typemap(in) int *&XYZZY (int temp1, int *temp2) {
+ temp1 = gh_scm2int($input); temp2 = &temp1; $1 = &temp2;
+};
+#endif
+
+%inline %{
+void foo(int *&XYZZY) {}
+%}
+
+
+// Test pointer reference typemaps shipped with SWIG (add in SWIG 1.3.28 for many languages)
+%inline %{
+struct Struct {
+ int value;
+ Struct(int v) : value(v) {}
+ static Struct instance;
+ static Struct *pInstance;
+};
+
+void set(Struct *const& s) {
+ Struct::instance = *s;
+}
+Struct *const& get() {
+ return Struct::pInstance;
+}
+%}
+
+%{
+Struct Struct::instance = Struct(10);
+Struct *Struct::pInstance = &Struct::instance;
+%}
+
diff --git a/trunk/Examples/test-suite/prefix.i b/trunk/Examples/test-suite/prefix.i
new file mode 100644
index 000000000..b0cb31205
--- /dev/null
+++ b/trunk/Examples/test-suite/prefix.i
@@ -0,0 +1,14 @@
+// Test that was failing for PHP - the value of the -prefix option was
+// ignored
+%module prefix
+
+%inline %{
+
+class Foo {
+public:
+ Foo *get_self() {
+ return this;
+ }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/preproc.i b/trunk/Examples/test-suite/preproc.i
new file mode 100644
index 000000000..b9f357b90
--- /dev/null
+++ b/trunk/Examples/test-suite/preproc.i
@@ -0,0 +1,344 @@
+%module preproc
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) one; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) two; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) three; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_CONST; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
+
+/* check __cplusplus case */
+%header
+%{
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+ /* C code */
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+%}
+
+
+/* This interface file tests whether SWIG's extended C
+ preprocessor is working right.
+
+ In this example, SWIG 1.3.6 chokes on "//" in a #define with a
+ syntax error.
+*/
+
+#define SLASHSLASH "//"
+
+/* This SWIG -*- c -*- interface is to test for some strange
+ preprocessor bug.
+
+ I get syntax errors unless I remove the apostrophe in the comment
+ or the sharp-sign substitution. (The apostrophe seems to disable
+ sharp-sign substitution.)
+*/
+
+
+%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(SCM_TYPE)
+
+ /* Don't check for NULL pointers (override checks). */
+
+ %typemap(argout, doc="($arg <vector of <" #SCM_TYPE ">>)")
+ int *VECTORLENOUTPUT
+ {
+ }
+
+%enddef
+
+TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(boolean)
+
+// preproc_3
+
+#define Sum( A, B, \
+ C) \
+ A + B + C
+
+
+// preproc_4
+%{
+ int hello0()
+ {
+ return 0;
+ }
+
+ int hello1()
+ {
+ return 1;
+ }
+
+ int hello2()
+ {
+ return 2;
+ }
+ int f(int min) { return min; }
+%}
+
+#define ARITH_RTYPE(A1, A2) A2
+
+#define HELLO_TYPE(A, B) ARITH_RTYPE(A, ARITH_RTYPE(A,B))
+
+//
+// These two work fine
+//
+int hello0();
+ARITH_RTYPE(double,int) hello1();
+
+
+//
+// This doesn't work with 1.3.17+ ( but it was ok in 1.3.16 )
+// it gets expanded as (using -E)
+//
+// ARITH_RTYPE(double,int) hello2();
+//
+HELLO_TYPE(double,int) hello2();
+
+#define min(x,y) ((x) < (y)) ? (x) : (y)
+int f(int min);
+
+// preproc_5
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) A5; // Ruby, wrong constant name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) a5; // Ruby, wrong constant name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) b5; // Ruby, wrong constant name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) c5; // Ruby, wrong constant name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) d5; // Ruby, wrong constant name
+
+// Various preprocessor bits of nastiness.
+
+
+/* Test argument name substitution */
+#define foo(x,xx) #x #xx
+#define bar(x,xx) x + xx
+
+%constant char *a5 = foo(hello,world);
+%constant int b5 = bar(3,4);
+
+// Wrap your brain around this one ;-)
+
+%{
+#define cat(x,y) x ## y
+%}
+
+#define cat(x,y) x ## y
+
+/* This should expand to cat(1,2);
+ See K&R, p. 231 */
+
+%constant int c5 = cat(cat(1,2),;)
+
+#define xcat(x,y) cat(x,y)
+
+/* This expands to 123. See K&R, p. 231 */
+%constant int d5 = xcat(xcat(1,2),3);
+
+
+#define C1\
+"hello"
+
+#define C2
+#define C3 C2
+
+#define ALONG_\
+NAME 42
+
+#define C4"Hello"
+
+// preproc_6
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) A6; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) a6; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) b6; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) c6; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) d6; /* Ruby, wrong constant name */
+
+#define add(a, b) (a + b)
+#define times(a, b) (a * b)
+#define op(x) x(1, 5)
+
+/* expand to (1 + 5) */
+%constant int a6 = op(add);
+/* expand to (1 * 5) */
+%constant int b6 = op(times);
+/* expand to ((1 + 5) * 5) */
+%constant int c6 = times(add(1, 5), 5);
+/* expand to ((1 + 5) * 5) */
+%constant int d6 = times(op(add), 5);
+
+/* This interface file tests whether SWIG's extended C
+ preprocessor is working right.
+
+ In this example, SWIG 1.3a5 reports missing macro arguments, which
+ is bogus.
+*/
+
+%define MACRO1(C_TYPE, GETLENGTH)
+ /* nothing */
+%enddef
+
+%define MACRO2(XYZZY)
+ MACRO1(XYZZY, 1)
+%enddef
+
+MACRO2(int)
+
+// cpp_macro_noarg. Tests to make sure macros with no arguments work right.
+#define MACROWITHARG(x) something(x)
+
+typedef int MACROWITHARG;
+
+/*
+This testcase tests for embedded defines and embedded %constants
+*/
+
+%inline %{
+
+typedef struct EmbeddedDefines {
+ int dummy;
+#define EMBEDDED_DEFINE 44
+#ifdef SWIG
+%constant EMBEDDED_SWIG_CONSTANT = 55;
+#endif
+} EmbeddedDefines;
+
+%}
+
+/*
+This testcase tests operators for defines
+*/
+
+#define A1 1 + 2
+#define A2 3 - 4
+#define A3 5 * 6
+#define A4 7 / 8
+#define A5 9 >> 10
+#define A6 11 << 12
+#define A7 13 & 14
+#define A8 15 | 16
+#define A9 17 ^ 18
+#define A10 19 && 20
+#define A11 21 || 21
+#define A12 ~22
+#define A13 !23
+
+
+
+#ifdef __cplusplus
+
+#define %mangle_macro(...) #@__VA_ARGS__
+#define %mangle_macro_str(...) ##@__VA_ARGS__
+
+%define my_func(...)
+inline const char* mangle_macro ## #@__VA_ARGS__ () {
+ return %mangle_macro_str(__VA_ARGS__);
+}
+%enddef
+
+%inline {
+ my_func(class Int) ;
+ my_func(std::pair<double, std::complex< double > >*) ;
+}
+
+#endif
+
+
+#if defined (__cplusplus) \
+|| defined (_AIX) \
+|| defined (__DECC) \
+|| (defined (__mips) && defined (_SYSTYPE_SVR4)) \
+|| defined (_MSC_VER) \
+|| defined (_WIN32)
+#define __GMP_HAVE_CONST 1
+#define __GMP_HAVE_PROTOTYPES 1
+#define __GMP_HAVE_TOKEN_PASTE 1
+#else
+#define __GMP_HAVE_CONST 0
+#define __GMP_HAVE_PROTOTYPES 0
+#define __GMP_HAVE_TOKEN_PASTE 0
+#endif
+
+
+/* empty TWO() macro is broken */
+#define ONE 1
+#define TWO() 2
+#define THREE(FOO) 3
+
+#define one ONE
+#define two TWO()
+#define three THREE(42)
+
+
+#if defined(one)
+/* hello */
+#else
+/* chiao */
+#endif;
+
+#ifdef SWIGCHICKEN
+/* define is a scheme keyword (and thus an invalid variable name), so SWIG warns about it */
+%warnfilter(SWIGWARN_PARSE_KEYWORD) define;
+#endif
+
+#ifdef SWIGRUBY
+%rename(ddefined) defined;
+#endif
+#ifdef SWIGPHP
+%rename(endif_) endif;
+#endif
+%inline %{
+const int endif = 1;
+const int define = 1;
+const int defined = 1;
+int test(int defined)
+{
+ return defined;
+}
+
+%}
+
+#pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING
+#warning "Some warning"
+
+/* check that #error can be turned into a warning, but suppress the warning message for the test-suite! */
+#pragma SWIG nowarn=SWIGWARN_PP_CPP_ERROR
+#pragma SWIG cpperraswarn=1
+#error "Some error"
+
+
+#define MASK(shift, size) (((1 << (size)) - 1) <<(shift))
+#define SOME_MASK_DEF (80*MASK(8, 10))
+
+/* some constants */
+#define BOLTZMANN (1.380658e-23)
+#define AVOGADRO (6.0221367e23)
+#define RGAS (BOLTZMANN*AVOGADRO)
+#define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN)
+
+%{
+#define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \
+struct TypeNameTraits { \
+ int val; \
+} \
+
+%}
+
+
+#define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \
+struct TypeNameTraits { \
+ int val; \
+} \
+
+%inline %{
+TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(int);
+%}
+
+%inline %{
+int method(struct TypeNameTraits tnt) {
+ return tnt.val;
+}
+%}
diff --git a/trunk/Examples/test-suite/preproc_constants.i b/trunk/Examples/test-suite/preproc_constants.i
new file mode 100644
index 000000000..771f3db1b
--- /dev/null
+++ b/trunk/Examples/test-suite/preproc_constants.i
@@ -0,0 +1,82 @@
+%module preproc_constants
+
+// Note: C types are slightly different to C++ types as (a && b) is int in C and bool in C++
+
+// Simple constants
+#define CONST_INT1 10
+#define CONST_INT2 0xFF
+
+#define CONST_UINT1 10u
+#define CONST_UINT2 10U
+#define CONST_UINT3 0xFFu
+#define CONST_UINT4 0xFFU
+
+#define CONST_LONG1 10l
+#define CONST_LONG2 10L
+#define CONST_LONG3 0xFFl
+#define CONST_LONG4 0xFFL
+
+#define CONST_LLONG1 10LL
+#define CONST_LLONG2 10ll
+#define CONST_LLONG3 0xFFll
+#define CONST_LLONG4 0xFFLL
+
+#define CONST_ULLONG1 10ull
+#define CONST_ULLONG2 10ULL
+#define CONST_ULLONG3 0xFFull
+#define CONST_ULLONG4 0xFFULL
+
+#define CONST_DOUBLE1 10e1
+#define CONST_DOUBLE2 10E1
+#define CONST_DOUBLE3 12.3
+#define CONST_DOUBLE4 12.
+#define CONST_DOUBLE5 12.3f
+#define CONST_DOUBLE6 12.3F
+
+#define CONST_BOOL1 true
+#define CONST_BOOL2 false
+
+#define CONST_CHAR 'x'
+#define CONST_STRING1 "const string"
+#define CONST_STRING2 "const" " string"
+
+// Expressions - runtime tests check the type for any necessary type promotions of the expressions
+
+#define INT_AND_BOOL 0xFF & true
+//#define INT_AND_CHAR 0xFF & 'A' /* FIXME compile error */
+#define INT_AND_INT 0xFF & 2
+#define INT_AND_UINT 0xFF & 2u
+#define INT_AND_LONG 0xFF & 2l
+#define INT_AND_ULONG 0xFF & 2ul
+#define INT_AND_LLONG 0xFF & 2ll
+#define INT_AND_ULLONG 0xFF & 2ull
+
+#define BOOL_AND_BOOL true & true // Note integral promotion to type int
+//#define CHAR_AND_CHAR 'A' & 'B' // Note integral promotion to type int
+/* FIXME ABOVE */
+
+
+#define EXPR_MULTIPLY 0xFF * 2
+#define EXPR_DIVIDE 0xFF / 2
+//FIXME #define EXPR_MOD 0xFF % 2
+
+#define EXPR_PLUS 0xFF + 2
+#define EXPR_MINUS 0xFF + 2
+
+#define EXPR_LSHIFT 0xFF << 2
+#define EXPR_RSHIFT 0xFF >> 2
+/* FIXME
+#define EXPR_LT 0xFF < 255
+#define EXPR_GT 0xFF > 255
+*/
+#define EXPR_LTE 0xFF <= 255
+#define EXPR_GTE 0xFF >= 255
+#define EXPR_INEQUALITY 0xFF != 255
+#define EXPR_EQUALITY 0xFF == 255
+#define EXPR_AND 0xFF & 1
+#define EXPR_XOR 0xFF ^ 1
+#define EXPR_OR 0xFF | 1
+#define EXPR_LAND 0xFF && 1
+#define EXPR_LOR 0xFF || 1
+#define EXPR_CONDITIONAL true ? 2 : 2.2
+
diff --git a/trunk/Examples/test-suite/preproc_constants_c.i b/trunk/Examples/test-suite/preproc_constants_c.i
new file mode 100644
index 000000000..e27d1f508
--- /dev/null
+++ b/trunk/Examples/test-suite/preproc_constants_c.i
@@ -0,0 +1,6 @@
+%module preproc_constants_c
+
+%define true 1 %enddef
+%define false 0 %enddef
+
+%include "preproc_constants.i"
diff --git a/trunk/Examples/test-suite/primitive_ref.i b/trunk/Examples/test-suite/primitive_ref.i
new file mode 100644
index 000000000..1e228f238
--- /dev/null
+++ b/trunk/Examples/test-suite/primitive_ref.i
@@ -0,0 +1,47 @@
+// Tests passing of references to primitive datatypes
+%module primitive_ref
+
+%define ref(type,name)
+%inline %{
+const type &ref_##name(const type &x) {
+ static type y = x;
+ return y;
+}
+%}
+%enddef
+
+ref(int,int);
+ref(unsigned int, uint);
+ref(short, short);
+ref(unsigned short, ushort);
+ref(long,long);
+ref(unsigned long, ulong);
+ref(signed char, schar);
+ref(unsigned char, uchar);
+ref(char, char);
+ref(float, float);
+ref(double, double);
+ref(bool, bool);
+ref(long long, longlong);
+ref(unsigned long long, ulonglong);
+
+
+%inline %{
+
+int ref_over(int a)
+{
+ return a;
+}
+
+ struct A
+ {
+ int v;
+ A(int V) :v(V) {}
+ };
+
+int ref_over(const A& a)
+{
+ return a.v;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/primitive_types.i b/trunk/Examples/test-suite/primitive_types.i
new file mode 100644
index 000000000..e00108b93
--- /dev/null
+++ b/trunk/Examples/test-suite/primitive_types.i
@@ -0,0 +1,617 @@
+// Massive primitive datatype test.
+%module(directors="1") primitive_types
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+// Ruby constant names
+#pragma SWIG nowarn=SWIGWARN_RUBY_WRONG_NAME
+
+// Using thread unsafe wrapping
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+ /*
+
+ if your language has problems with MyInt* and/or Hello*,
+ you need to change the constant reference typemaps from something
+ like:
+
+ %typemap(in) const char & (char temp),
+ const signed char & (signed char temp),
+ const unsigned char & (unsigned char temp),
+ const short & (short temp),
+ const unsigned short & (unsigned short temp),
+ const int & (int temp),
+ const unsigned int & (unsigned int temp),
+ const long & (long temp),
+ const unsigned long & (unsigned long temp),
+ const long long & ($*1_ltype temp),
+ const float & (float temp),
+ const double & (double temp)
+ %{ temp = ($*1_ltype)$input; $1 = &temp; %}
+
+ to the following:
+
+ %typemap(in) const char & ($basetype temp),
+ const signed char & ($basetype temp),
+ const unsigned char & ($basetype temp),
+ const short & ($basetype temp),
+ const unsigned short & ($basetype temp),
+ const int & ($basetype temp),
+ const unsigned int & ($basetype temp),
+ const long & ($basetype temp),
+ const unsigned long & ($basetype temp),
+ const long long & ($basetype temp),
+ const float & ($basetype temp),
+ const double & ($basetype temp)
+ %{ temp = ($basetype)$input; $1 = &temp; %}
+
+ the other tipical change is to add the enum SWIGTYPE to the
+ integer throws typemaps:
+
+ %typemap(throws) int,
+ long,
+ short,
+ unsigned int,
+ unsigned long,
+ unsigned short,
+ enum SWIGTYPE {
+ Tcl_SetObjResult(interp, Tcl_NewIntObj((long) $1));
+ SWIG_fail;
+ }
+
+ or just add the %apply directive after all the typemaps declaration
+
+ %apply int { enum SWIGTYPE };
+
+
+ Also note that this test should not only compile, if you run the
+ program
+
+ grep 'resultobj = SWIG_NewPointerObj' primitive_types_wrap.cxx
+
+ you should get only two calls:
+
+ resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Test, 1);
+ resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_TestDirector, 1);
+
+ if you get a lot more, some typemap could be not defined.
+
+ The same with
+
+ grep SWIG_ConvertPtr primitive_types_wrap.cxx| egrep -v 'Test'
+
+ you should only get
+
+ #define SWIG_ConvertPtr(obj, pp, type, flags)
+
+ */
+
+//
+// Try your language module with and without
+// these nowarn flags.
+//
+%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+
+%{
+#include <stddef.h>
+#include <iostream>
+#include <sstream>
+%}
+
+%feature("director") TestDirector;
+
+%{
+ // Integer class, only visible in C++
+ struct MyInt
+ {
+ char name[5];
+ int val;
+
+ MyInt(int v = 0): val(v) {
+ }
+
+ operator int() const { return val; }
+ };
+
+ // Template primitive type, only visible in C++
+ template <class T>
+ struct Param
+ {
+ char name[5];
+ T val;
+
+ Param(T v = 0): val(v) {
+ name[0] = 0;
+ name[1] = 0;
+ name[2] = 0;
+ name[3] = 0;
+ name[4] = 0;
+ }
+
+ operator T() const { return val; }
+ };
+
+ typedef char namet[5];
+ extern namet gbl_namet;
+ namet gbl_namet;
+
+%}
+
+
+//
+// adding applies for incomplete swig type MyInt
+//
+%apply int { MyInt };
+%apply const int& { const MyInt& };
+%apply int { Param<int> };
+%apply char { Param<char> };
+%apply float { Param<float> };
+%apply double { Param<double> };
+%apply const int& { const Param<int>& };
+%apply const char& { const Param<char>& };
+%apply const float& { const Param<float>& };
+%apply const double& { const Param<double>& };
+
+
+
+//
+// These applies shouldn't be needed ....!!
+//
+//%apply const int& { const Hello& };
+
+%apply void* { pint };
+%apply void* const& { const pint& };
+
+
+//
+// Some simple types
+%apply char FIXSIZE[ANY] {char fixsize[8]};
+
+
+
+%inline %{
+ enum Hello {
+ Hi, Hola
+ };
+
+ typedef char namet[5];
+ typedef char* pchar;
+ typedef const char* pcharc;
+ typedef char* pint;
+
+ char* const def_pchar = (char *const)"hello";
+ const char* const def_pcharc = "hija";
+
+ const namet def_namet = {'h','o',0, 'l','a'};
+
+ extern namet gbl_namet;
+
+ char fixsize[8] = {'h','o',0, 'l','a', 0, 0, 0};
+%}
+
+
+/* all the primitive types */
+#define def_bool 1
+#define def_schar 1
+#define def_uchar 1
+#define def_int 1
+#define def_uint 1
+#define def_short 1
+#define def_ushort 1
+#define def_long 1
+#define def_ulong 1
+#define def_llong 1
+#define def_ullong 1
+#define def_float 1
+#define def_double 1
+#define def_char 'H'
+#define def_pint 0
+#define def_sizet 1
+#define def_hello Hola
+#define def_myint 1
+#define def_parami 1
+#define def_paramd 1
+#define def_paramc 'c'
+
+/* types that can be declared as static const class members */
+%define %test_prim_types_stc(macro, pfx)
+macro(bool, pfx, bool)
+macro(signed char, pfx, schar)
+macro(unsigned char, pfx, uchar)
+macro(int, pfx, int)
+macro(unsigned int, pfx, uint)
+macro(short, pfx, short)
+macro(unsigned short, pfx, ushort)
+macro(long, pfx, long)
+macro(unsigned long, pfx, ulong)
+macro(long long, pfx, llong)
+macro(unsigned long long, pfx, ullong)
+macro(char, pfx, char)
+%enddef
+
+
+/* types that can be used to test overloading */
+%define %test_prim_types_ovr(macro, pfx)
+%test_prim_types_stc(macro, pfx)
+macro(pchar, pfx, pchar)
+%enddef
+
+/* all the types */
+%define %test_prim_types(macro, pfx)
+%test_prim_types_ovr(macro, pfx)
+macro(pcharc, pfx, pcharc)
+macro(pint, pfx, pint)
+/* these ones should behave like primitive types too */
+macro(Hello, pfx, hello)
+macro(MyInt, pfx, myint)
+macro(Param<int>, pfx, parami)
+macro(Param<double>, pfx, paramd)
+macro(Param<char>, pfx, paramc)
+macro(size_t, pfx, sizet)
+%enddef
+
+
+/* function passing by value */
+%define val_decl(type, pfx, name)
+ type pfx##_##name(type x) throw (type) { return x; }
+%enddef
+/* function passing by ref */
+%define ref_decl(type, pfx, name)
+ const type& pfx##_##name(const type& x) throw (type) { return x; }
+%enddef
+
+/* C++ constant declaration */
+%define cct_decl(type, pfx, name)
+ const type pfx##_##name = def##_##name;
+%enddef
+
+/* C++ static constant declaration */
+%define stc_decl(type, pfx, name)
+ static const type pfx##_##name = def##_##name;
+%enddef
+
+/* Swig constant declaration */
+%define sct_decl(type, pfx, name)
+ %constant type pfx##_##name = def##_##name;
+%enddef
+
+/* variable delaration */
+%define var_decl(type, pfx, name)
+ type pfx##_##name;
+%enddef
+
+/* virtual function passing by value */
+%define vval_decl(type, pfx, name)
+ virtual val_decl(type, pfx, name)
+%enddef
+/* virtual function passing by ref */
+%define vref_decl(type, pfx, name)
+ virtual ref_decl(type, pfx, name)
+%enddef
+
+
+%test_prim_types(sct_decl, sct)
+
+%inline {
+ %test_prim_types(val_decl, val)
+ %test_prim_types(ref_decl, ref)
+ %test_prim_types(cct_decl, cct)
+ %test_prim_types(var_decl, var)
+
+ var_decl(namet, var, namet)
+
+ void var_init()
+ {
+ var_pchar = 0;
+ var_pcharc = 0;
+ var_pint = 0;
+ var_namet[0] = 'h';
+ }
+
+}
+
+/* check variables */
+%define var_check(type, pfx, name)
+ if (pfx##_##name != def_##name) {
+ std::ostringstream a; std::ostringstream b;
+ a << pfx##_##name;
+ b << def_##name;
+ if (a.str() != b.str()) {
+ std::cout << "failing in pfx""_""name : "
+ << a.str() << " : " << b.str() << std::endl;
+ // return 0;
+ }
+ }
+%enddef
+
+/* check a function call */
+%define call_check(type, pfx, name)
+ type pfx##_##tmp##name = def_##name;
+ if (pfx##_##name(pfx##_##tmp##name) != def_##name) {
+ std::ostringstream a; std::ostringstream b;
+ a << pfx##_##name(pfx##_##tmp##name);
+ b << def_##name;
+ if (a.str() != b.str()) {
+ std::cout << "failing in pfx""_""name : "
+ << a.str() << " : " << b.str() << std::endl;
+ // return 0;
+ }
+ }
+%enddef
+
+%define wrp_decl(type, pfx, name)
+ type wrp##_##pfx##_##name(type x) {
+ return pfx##_##name(x);
+ }
+%enddef
+
+/* function passing by value */
+%define ovr_decl(type, pfx, name)
+ virtual int pfx##_##val(type x) { return 1; }
+ virtual int pfx##_##ref(const type& x) { return 1; }
+%enddef
+
+
+%apply (char *STRING, int LENGTH) { (const char *str, size_t len) }
+
+%inline {
+ struct Foo
+ {
+ int _a;
+
+ Foo (int a) : _a(a)
+ {
+ }
+
+ Foo(const Foo&)
+ {
+ }
+
+ Foo copy(Foo x)
+ {
+ return x;
+ }
+
+ const Foo copy_c(const Foo x)
+ {
+ return x;
+ }
+
+ const Foo& copy_r(const Foo& x)
+ {
+ return x;
+ }
+
+ Foo* this_p()
+ {
+ return this;
+ }
+
+ Foo& this_r()
+ {
+ return *this;
+ }
+
+ };
+
+ typedef Foo* foo_ptr;
+
+ foo_ptr fptr_val(foo_ptr a) {
+ return a;
+ }
+
+ const foo_ptr& fptr_ref(const foo_ptr& a) {
+ return a;
+ }
+
+
+ struct Test
+ {
+ Test()
+ : var_pchar(0), var_pcharc(0), var_pint(0)
+ {
+ }
+
+ virtual ~Test()
+ {
+ }
+
+ %test_prim_types_stc(stc_decl, stc)
+ %test_prim_types(var_decl, var)
+ var_decl(namet, var, namet)
+
+
+ const char* val_namet(namet x) throw(namet)
+ {
+ return x;
+ }
+
+ const char* val_cnamet(const namet x) throw(namet)
+ {
+ return x;
+ }
+
+#if 0
+ /* I have no idea how to define a typemap for
+ const namet&, where namet is a char[ANY] array */
+ const namet& ref_namet(const namet& x) throw(namet)
+ {
+ return x;
+ }
+#endif
+
+
+ %test_prim_types(val_decl, val)
+ %test_prim_types(ref_decl, ref)
+
+ int c_check()
+ {
+ %test_prim_types(call_check, val)
+ %test_prim_types(call_check, ref)
+ return 1;
+ }
+
+ int v_check()
+ {
+ %test_prim_types_stc(var_check, stc)
+ %test_prim_types(var_check, var)
+ var_check(namet, var, namet);
+ return 1;
+ }
+
+ %test_prim_types_ovr(ovr_decl, ovr)
+
+ size_t strlen(const char *str, size_t len)
+ {
+ return len;
+ }
+
+ static const double stc_double;
+ static const double stc_float;
+
+
+ };
+
+ struct TestDirector
+ {
+ TestDirector()
+ : var_pchar(0), var_pcharc(0), var_pint(0)
+ {
+ }
+
+
+ virtual ~TestDirector()
+ {
+ var_namet[0]='h';
+ }
+
+ virtual const char* vval_namet(namet x) throw(namet)
+ {
+ return x;
+ }
+
+ virtual const char* vval_cnamet(const namet x) throw(namet)
+ {
+ return x;
+ }
+
+#if 0
+ /* I have no idea how to define a typemap for
+ const namet&, where namet is a char[ANY] array */
+ virtual const namet& vref_namet(const namet& x) throw(namet)
+ {
+ return x;
+ }
+#endif
+
+
+ %test_prim_types_stc(stc_decl, stc)
+ %test_prim_types(var_decl, var)
+ var_decl(namet, var, namet)
+
+ %test_prim_types(val_decl, val)
+ %test_prim_types(ref_decl, ref)
+
+ %test_prim_types(vval_decl, vval)
+ %test_prim_types(vref_decl, vref)
+
+ %test_prim_types(wrp_decl, vref)
+ %test_prim_types(wrp_decl, vval)
+
+ int c_check()
+ {
+ %test_prim_types(call_check, vval)
+ %test_prim_types(call_check, vref)
+ return 1;
+ }
+
+ int v_check()
+ {
+ %test_prim_types_stc(var_check, stc)
+ %test_prim_types(var_check, var)
+ return 1;
+ }
+
+ %test_prim_types_ovr(ovr_decl, ovr)
+
+
+ virtual Test* vtest(Test* t) const throw (Test)
+ {
+ return t;
+ }
+
+ };
+
+ int v_check()
+ {
+ %test_prim_types(var_check, cct)
+ %test_prim_types(var_check, var)
+ var_check(namet, var, namet);
+ return 1;
+ }
+
+}
+
+%inline %{
+
+ const char* char_foo(float f, const char *s) {
+ return s;
+ }
+
+ int char_foo(double d, int i) {
+ return i;
+ }
+
+%}
+
+%{
+ const double Test::stc_double = 1;
+ const double Test::stc_float = 1;
+%}
+
+
+%inline
+%{
+ namespace DCTypes
+ {
+ typedef const unsigned int cuint;
+ }
+
+ namespace DCSystem
+ {
+ using namespace DCTypes;
+ unsigned int SetPos(cuint& x, cuint& y) {return x + y;}
+ }
+
+ double val_double_2(double x, const double& y = 3.0) {
+ return x + y;
+ }
+
+ double val_double(double x) {
+ return x;
+ }
+
+ float val_float_2(float x, const float& y = 3.0) {
+ return x + y;
+ }
+
+ // Regression test for bug1699646 - we weren't handling
+ // + or - after e for float constants.
+ float regression_test_for_bug1699646(float f = 1e-02f) {
+ return f;
+ }
+
+ float val_float(float x) {
+ return x;
+ }
+%}
+
+
+%apply SWIGTYPE* { char *};
+
+%include "carrays.i"
+%array_functions(char,pchar);
+
diff --git a/trunk/Examples/test-suite/private_assign.i b/trunk/Examples/test-suite/private_assign.i
new file mode 100644
index 000000000..acc4d0bc9
--- /dev/null
+++ b/trunk/Examples/test-suite/private_assign.i
@@ -0,0 +1,71 @@
+// A class with a private assignment operator.
+// This is rare, but sometimes used with singletons and
+// objects that have complicated state.
+
+%module private_assign
+%{
+#include <stdlib.h>
+%}
+
+%inline %{
+ class Foo {
+ private:
+ Foo &operator=(const Foo &f) {
+ return *this;
+ }
+ public:
+ void bar() { }
+ };
+
+ Foo blah() {
+ return Foo();
+ }
+
+ class Bar : protected Foo
+ {
+ };
+
+%}
+
+#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_NEW // operator new
+
+%inline %{
+ class TROOT {
+ protected:
+ void *operator new(size_t l) { return malloc(sizeof(TROOT)); }
+
+ int prot_meth()
+ {
+ return 1;
+ }
+
+ public:
+ TROOT()
+ {
+ }
+
+ TROOT(const char *name, const char *title, void *initfunc = 0)
+ {
+ }
+ };
+
+ class A : protected TROOT
+ {
+ };
+
+%}
+
+#ifdef SWIGPYTHON
+
+// This case only works in python
+%inline %{
+ struct FooBar : Foo
+ {
+ };
+
+ FooBar bar;
+
+%}
+
+
+#endif
diff --git a/trunk/Examples/test-suite/profiletest.i b/trunk/Examples/test-suite/profiletest.i
new file mode 100644
index 000000000..e75f8fc14
--- /dev/null
+++ b/trunk/Examples/test-suite/profiletest.i
@@ -0,0 +1,65 @@
+%module profiletest
+
+%inline %{
+
+ class A {
+ public:
+ A() {}
+ };
+
+ class B
+ {
+ A aa;
+ public:
+ B() {}
+ A fn(const A* a) {
+ return *a;
+ }
+
+ int fi(int a) {
+ return a;
+ }
+
+ int fj(const A* a) {
+ return 10;
+ }
+
+ B* fk(int i) {
+ return this;
+ }
+
+ const char* fl(int i) {
+ return "hello";
+ }
+
+ const char* fs(const char *s) {
+ return s;
+ }
+
+ int fi(int a, int) {
+ return a;
+ }
+
+ int fi(char *) {
+ return 1;
+ }
+
+ int fi(double) {
+ return 2;
+ }
+
+ int fi(A *a) {
+ return 3;
+ }
+
+ int fi(int a, int, int) {
+ return a;
+ }
+
+ int fi(int a, int, int, int) {
+ return a;
+ }
+
+ };
+
+%}
diff --git a/trunk/Examples/test-suite/protected_rename.i b/trunk/Examples/test-suite/protected_rename.i
new file mode 100644
index 000000000..41f7ac4ae
--- /dev/null
+++ b/trunk/Examples/test-suite/protected_rename.i
@@ -0,0 +1,19 @@
+%module protected_rename
+
+/**
+ * We should be able to rename Foo::y() to 'x' since the protected
+ * member variable of the same name is not wrapped. Thus this test
+ * case shouldn't generate any warnings.
+ */
+
+%rename(x) Foo::y();
+
+%inline %{
+class Foo {
+protected:
+ int x;
+public:
+ void y() {}
+};
+
+%}
diff --git a/trunk/Examples/test-suite/pure_virtual.i b/trunk/Examples/test-suite/pure_virtual.i
new file mode 100644
index 000000000..5bda283cf
--- /dev/null
+++ b/trunk/Examples/test-suite/pure_virtual.i
@@ -0,0 +1,82 @@
+/* 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(ruby_minherit="1") pure_virtual
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
+
+%nodefaultctor C;
+%nodefaultdtor C;
+%nodefaultctor E;
+%nodefaultdtor E;
+
+%inline %{
+
+class A {
+ public:
+ A() { };
+ virtual ~A() = 0;
+ virtual void something() = 0;
+ virtual void method() = 0;
+};
+
+class B : public A {
+public:
+ B() {};
+ virtual ~B() { };
+ virtual void something() { };
+ virtual void method() { };
+};
+
+/* class C is abstract because it doesn't define all methods in A */
+class C : public A {
+ public:
+ virtual ~C() { };
+ virtual void method() { };
+}
+;
+
+/* class D is not abstract, it defines everything */
+class D : public C {
+ public:
+ virtual ~D() { };
+ virtual void something() { };
+}
+;
+
+/* Another abstract class */
+class AA {
+ public:
+ virtual ~AA() { }
+ virtual void method2() = 0;
+};
+
+/* Multiple inheritance between two abstract classes */
+class E : public C, public AA {
+public:
+ virtual void something() { };
+};
+%}
+
+/* Fill in method from AA. This class should be constructable */
+#ifdef SWIGCSHARP
+%ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored.
+#endif
+
+%inline %{
+class F : public E {
+ public:
+ virtual void method2() { }
+};
+%}
+
+%{
+A::~A() {}
+%}
+
diff --git a/trunk/Examples/test-suite/python/Makefile.in b/trunk/Examples/test-suite/python/Makefile.in
new file mode 100644
index 000000000..4938ddc27
--- /dev/null
+++ b/trunk/Examples/test-suite/python/Makefile.in
@@ -0,0 +1,170 @@
+#######################################################################
+# Makefile for python test-suite
+#######################################################################
+
+ifeq (,$(PY3))
+ PYBIN = @PYTHON@
+else
+ PYBIN = @PYTHON3@
+endif
+
+LANGUAGE = python
+PYTHON = $(PYBIN)
+
+#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
+PY2SCRIPTSUFFIX = _runme.py
+PY3SCRIPTSUFFIX = _runme3.py
+
+ifeq (,$(PY3))
+ SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
+else
+ SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
+endif
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+
+PY2TO3 = 2to3 -x import
+
+
+CPP_TEST_CASES += \
+ argcargvtest \
+ python_autodoc \
+ python_append \
+ callback \
+ complextest \
+ director_stl \
+ director_wstring \
+ file_test \
+ iadd \
+ inout \
+ input \
+ inplaceadd \
+ implicittest \
+ li_cstring \
+ li_cwstring \
+ li_factory \
+ li_implicit \
+ li_std_vectora \
+ li_std_vector_extra \
+ li_std_multimap \
+ li_std_pair_extra \
+ li_std_set \
+ li_std_stream \
+ li_std_string_extra \
+ li_std_wstream \
+ li_std_wstring \
+ primitive_types \
+ python_abstractbase \
+ python_kwargs \
+ python_nondynamic \
+ python_overload_simple_cast \
+ std_containers \
+ swigobject \
+ template_matrix \
+ simutry
+
+# li_std_carray
+# director_profile
+# python_pybuf
+
+C_TEST_CASES += \
+ file_test \
+ li_cstring \
+ li_cwstring \
+ python_nondynamic
+
+#
+# This test only works with modern C compilers
+#
+#C_TEST_CASES += \
+# complextest
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+LIBS = -L.
+VALGRIND_OPT += --suppressions=pythonswig.supp
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+
+# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file
+%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX)
+ cp $< $@
+ $(PY2TO3) -w $@ >/dev/null 2>&1
+
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
+
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+
+py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
+py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
+
+ifeq (,$(PY3))
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ $(run_python);\
+ fi
+else
+run_testcase = \
+ if [ -f $(py2_runme) ]; then \
+ $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \
+ elif [ -f $(py3_runme) ]; then \
+ $(run_python); \
+ fi
+endif
+
+# Clean: remove the generated .py file
+%.clean:
+ @rm -f $*.py;
+ @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
+ @if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
+ rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
+
+cvsignore:
+ @echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
+ @echo Makefile
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
+ @echo clientdata_prop_a.py
+ @echo clientdata_prop_b.py
+ @echo imports_a.py
+ @echo imports_b.py
+ @echo mod_a.py mod_b.py
+ @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
+ @echo template_typedef_import.py
+
+hugemod_runme = hugemod$(SCRIPTPREFIX)
+
+hugemod:
+ perl hugemod.pl $(hugemod_runme)
+ $(MAKE) hugemod_a.cpptest
+ $(MAKE) hugemod_b.cpptest
+ sh -c "time $(PYTHON) $(hugemod_runme)"
+ sh -c "time $(PYTHON) $(hugemod_runme)"
+
diff --git a/trunk/Examples/test-suite/python/README b/trunk/Examples/test-suite/python/README
new file mode 100644
index 000000000..71db759b5
--- /dev/null
+++ b/trunk/Examples/test-suite/python/README
@@ -0,0 +1,8 @@
+See ../README for common README file.
+
+Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run.
+
+If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test.
+
+You can run make with PY3=y to run test case with Python 3.x, eg.
+ $ make voidtest.cpptest PY3=y
diff --git a/trunk/Examples/test-suite/python/abstract_access_runme.py b/trunk/Examples/test-suite/python/abstract_access_runme.py
new file mode 100644
index 000000000..55638e40e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/abstract_access_runme.py
@@ -0,0 +1,6 @@
+import abstract_access
+
+d = abstract_access.D()
+if d.do_x() != 1:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/abstract_typedef2_runme.py b/trunk/Examples/test-suite/python/abstract_typedef2_runme.py
new file mode 100644
index 000000000..2a11d1944
--- /dev/null
+++ b/trunk/Examples/test-suite/python/abstract_typedef2_runme.py
@@ -0,0 +1,8 @@
+from abstract_typedef2 import *
+
+a = A_UF()
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/python/abstract_typedef_runme.py b/trunk/Examples/test-suite/python/abstract_typedef_runme.py
new file mode 100644
index 000000000..15d70aa42
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/abstract_virtual_runme.py b/trunk/Examples/test-suite/python/abstract_virtual_runme.py
new file mode 100644
index 000000000..9cd0b7c44
--- /dev/null
+++ b/trunk/Examples/test-suite/python/abstract_virtual_runme.py
@@ -0,0 +1,6 @@
+from abstract_virtual import *
+
+
+d = D()
+
+e = E()
diff --git a/trunk/Examples/test-suite/python/argcargvtest_runme.py b/trunk/Examples/test-suite/python/argcargvtest_runme.py
new file mode 100644
index 000000000..584a19f6e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/argcargvtest_runme.py
@@ -0,0 +1,27 @@
+from argcargvtest import *
+
+largs=['hi','hola','hello']
+if mainc(largs) != 3:
+ raise RuntimeError, "bad main typemap"
+
+targs=('hi','hola')
+if mainv(targs,1) != 'hola':
+ print mainv(targs,1)
+ raise RuntimeError, "bad main typemap"
+
+targs=('hi', 'hola')
+if mainv(targs,1) != 'hola':
+ raise RuntimeError, "bad main typemap"
+
+try:
+ error = 0
+ mainv('hello',1)
+ error = 1
+except TypeError:
+ pass
+if error:
+ raise RuntimeError, "bad main typemap"
+
+
+
+initializeApp(largs)
diff --git a/trunk/Examples/test-suite/python/array_member_runme.py b/trunk/Examples/test-suite/python/array_member_runme.py
new file mode 100644
index 000000000..95cf03b44
--- /dev/null
+++ b/trunk/Examples/test-suite/python/array_member_runme.py
@@ -0,0 +1,21 @@
+from array_member import *
+
+f = Foo()
+f.data = cvar.global_data
+
+for i in range(0,8):
+ if get_value(f.data,i) != get_value(cvar.global_data,i):
+ raise RuntimeError, "Bad array assignment"
+
+
+for i in range(0,8):
+ set_value(f.data,i,-i)
+
+cvar.global_data = f.data
+
+for i in range(0,8):
+ if get_value(f.data,i) != get_value(cvar.global_data,i):
+ raise RuntimeError, "Bad array assignment"
+
+
+
diff --git a/trunk/Examples/test-suite/python/arrays_global_runme.py b/trunk/Examples/test-suite/python/arrays_global_runme.py
new file mode 100644
index 000000000..ab7fd6a41
--- /dev/null
+++ b/trunk/Examples/test-suite/python/arrays_global_runme.py
@@ -0,0 +1,20 @@
+import arrays_global
+
+arrays_global.cvar.array_i = arrays_global.cvar.array_const_i
+
+from arrays_global import *
+
+BeginString_FIX44a
+cvar.BeginString_FIX44b
+BeginString_FIX44c
+cvar.BeginString_FIX44d
+cvar.BeginString_FIX44d
+cvar.BeginString_FIX44b ="12"'\0'"45"
+cvar.BeginString_FIX44b
+cvar.BeginString_FIX44d
+cvar.BeginString_FIX44e
+BeginString_FIX44f
+
+test_a("hello","hi","chello","chi")
+
+test_b("1234567","hi")
diff --git a/trunk/Examples/test-suite/python/callback_runme.py b/trunk/Examples/test-suite/python/callback_runme.py
new file mode 100644
index 000000000..b2bbb2d0f
--- /dev/null
+++ b/trunk/Examples/test-suite/python/callback_runme.py
@@ -0,0 +1,31 @@
+import _callback
+from callback import *
+
+if foo(2) != 2:
+ raise RuntimeError
+
+if A_bar(2) != 4:
+ raise RuntimeError
+
+if foobar(3, _callback.foo) != foo(3):
+ raise RuntimeError
+
+if foobar(3, foo) != foo(3):
+ raise RuntimeError
+
+if foobar(3, A_bar) != A_bar(3):
+ raise RuntimeError
+
+if foobar(3, foof) != foof(3):
+ raise RuntimeError
+
+if foobar_i(3, foo_i) != foo_i(3):
+ raise RuntimeError
+
+
+if foobar_d(3.5, foo_d) != foo_d(3.5):
+ raise RuntimeError
+
+a = A()
+if foobarm(3, a, A.foom_cb_ptr) != a.foom(3):
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/class_ignore_runme.py b/trunk/Examples/test-suite/python/class_ignore_runme.py
new file mode 100644
index 000000000..782fc07e1
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/class_scope_weird_runme.py b/trunk/Examples/test-suite/python/class_scope_weird_runme.py
new file mode 100644
index 000000000..5c91d441f
--- /dev/null
+++ b/trunk/Examples/test-suite/python/class_scope_weird_runme.py
@@ -0,0 +1,6 @@
+import class_scope_weird
+
+f = class_scope_weird.Foo()
+g = class_scope_weird.Foo(3)
+if f.bar(3) != 3:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/compactdefaultargs_runme.py b/trunk/Examples/test-suite/python/compactdefaultargs_runme.py
new file mode 100644
index 000000000..ff865714c
--- /dev/null
+++ b/trunk/Examples/test-suite/python/compactdefaultargs_runme.py
@@ -0,0 +1,20 @@
+from compactdefaultargs import *
+
+defaults1 = Defaults1(1000)
+defaults1 = Defaults1()
+
+if defaults1.ret(10.0) != 10.0:
+ raise RuntimeError
+
+if defaults1.ret() != -1.0:
+ raise RuntimeError
+
+defaults2 = Defaults2(1000)
+defaults2 = Defaults2()
+
+if defaults2.ret(10.0) != 10.0:
+ raise RuntimeError
+
+if defaults2.ret() != -1.0:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/complextest_runme.py b/trunk/Examples/test-suite/python/complextest_runme.py
new file mode 100644
index 000000000..cc2463a39
--- /dev/null
+++ b/trunk/Examples/test-suite/python/complextest_runme.py
@@ -0,0 +1,17 @@
+import complextest
+
+a = complex(-1,2)
+
+if complextest.Conj(a) != a.conjugate():
+ raise RuntimeError, "bad complex mapping"
+
+if complextest.Conjf(a) != a.conjugate():
+ raise RuntimeError, "bad complex mapping"
+
+
+v = (complex(1,2), complex(2,3), complex(4,3), 1)
+
+try:
+ complextest.Copy_h(v)
+except:
+ pass
diff --git a/trunk/Examples/test-suite/python/constover_runme.py b/trunk/Examples/test-suite/python/constover_runme.py
new file mode 100644
index 000000000..5c5419706
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/constructor_copy_runme.py b/trunk/Examples/test-suite/python/constructor_copy_runme.py
new file mode 100644
index 000000000..431d3232f
--- /dev/null
+++ b/trunk/Examples/test-suite/python/constructor_copy_runme.py
@@ -0,0 +1,38 @@
+from constructor_copy import *
+
+f1 = Foo1(3);
+f11 = Foo1(f1);
+
+
+if f1.x != f11.x:
+ raise RuntimeError
+
+
+f8 = Foo8()
+try:
+ f81 = Foo8(f8)
+ good = 0
+except:
+ good = 1
+
+if not good:
+ raise RuntimeError
+
+
+bi = Bari(5)
+bc = Bari(bi)
+
+if (bi.x != bc.x):
+ raise RuntimeError
+
+
+bd = Bard(5)
+try:
+ bc = Bard(bd)
+ good = 0
+except:
+ good = 1
+
+if not good:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/constructor_rename_runme.py b/trunk/Examples/test-suite/python/constructor_rename_runme.py
new file mode 100644
index 000000000..cf3f88b81
--- /dev/null
+++ b/trunk/Examples/test-suite/python/constructor_rename_runme.py
@@ -0,0 +1,3 @@
+from constructor_rename import *
+
+x = RenamedConstructor()
diff --git a/trunk/Examples/test-suite/python/contract_runme.py b/trunk/Examples/test-suite/python/contract_runme.py
new file mode 100644
index 000000000..905bf1196
--- /dev/null
+++ b/trunk/Examples/test-suite/python/contract_runme.py
@@ -0,0 +1,143 @@
+import contract
+
+contract.test_preassert(1,2)
+try:
+ contract.test_preassert(-1)
+ print "Failed! Preassertions are broken"
+except:
+ pass
+
+contract.test_postassert(3)
+try:
+ contract.test_postassert(-3)
+ print "Failed! Postassertions are broken"
+except:
+ pass
+
+contract.test_prepost(2,3)
+contract.test_prepost(5,-4)
+try:
+ contract.test_prepost(-3,4)
+ print "Failed! Preassertions are broken"
+except:
+ pass
+
+try:
+ contract.test_prepost(4,-10)
+ print "Failed! Postassertions are broken"
+
+except:
+ pass
+
+f = contract.Foo()
+f.test_preassert(4,5)
+try:
+ f.test_preassert(-2,3)
+ print "Failed! Method preassertion."
+except:
+ pass
+
+f.test_postassert(4)
+try:
+ f.test_postassert(-4)
+ print "Failed! Method postassertion"
+except:
+ pass
+
+f.test_prepost(3,4)
+f.test_prepost(4,-3)
+try:
+ f.test_prepost(-4,2)
+ print "Failed! Method preassertion."
+except:
+ pass
+
+try:
+ f.test_prepost(4,-10)
+ print "Failed! Method postassertion."
+except:
+ pass
+
+contract.Foo_stest_prepost(4,0)
+try:
+ contract.Foo_stest_prepost(-4,2)
+ print "Failed! Static method preassertion"
+except:
+ pass
+
+try:
+ contract.Foo_stest_prepost(4,-10)
+ print "Failed! Static method posteassertion"
+except:
+ pass
+
+b = contract.Bar()
+try:
+ b.test_prepost(2,-4)
+ print "Failed! Inherited preassertion."
+except:
+ pass
+
+
+d = contract.D()
+try:
+ d.foo(-1,1,1,1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.foo(1,-1,1,1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.foo(1,1,-1,1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.foo(1,1,1,-1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.foo(1,1,1,1,-1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+
+
+try:
+ d.bar(-1,1,1,1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.bar(1,-1,1,1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.bar(1,1,-1,1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.bar(1,1,1,-1,1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+try:
+ d.bar(1,1,1,1,-1)
+ print "Failed! Inherited preassertion (D)."
+except:
+ pass
+
+#Namespace
+my = contract.myClass(1)
+try:
+ my = contract.myClass(0)
+ print "Failed! constructor preassertion"
+except:
+ pass
+
diff --git a/trunk/Examples/test-suite/python/cpp_enum_runme.py b/trunk/Examples/test-suite/python/cpp_enum_runme.py
new file mode 100644
index 000000000..0054ae281
--- /dev/null
+++ b/trunk/Examples/test-suite/python/cpp_enum_runme.py
@@ -0,0 +1,23 @@
+import cpp_enum
+
+f = cpp_enum.Foo()
+
+if f.hola != f.Hello:
+ print f.hola
+ raise RuntimeError
+
+f.hola = f.Hi
+if f.hola != f.Hi:
+ print f.hola
+ raise RuntimeError
+
+f.hola = f.Hello
+
+if f.hola != f.Hello:
+ print f.hola
+ raise RuntimeError
+
+cpp_enum.cvar.hi = cpp_enum.Hello
+if cpp_enum.cvar.hi != cpp_enum.Hello:
+ print cpp_enum.cvar.hi
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/cpp_namespace_runme.py b/trunk/Examples/test-suite/python/cpp_namespace_runme.py
new file mode 100644
index 000000000..a454774f5
--- /dev/null
+++ b/trunk/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 RuntimeError("Bad return value!")
+
+if cpp_namespace.cvar.Foo != 42:
+ raise RuntimeError("Bad variable value!")
+
+t = cpp_namespace.Test()
+if t.method() != "Test::method":
+ raise RuntimeError("Bad method return value!")
+
+if cpp_namespace.do_method(t) != "Test::method":
+ raise RuntimeError("Bad return value!")
+
+if cpp_namespace.do_method2(t) != "Test::method":
+ raise RuntimeError("Bad return value!")
+
+cpp_namespace.weird("hello", 4)
+
+del t
+
+t2 = cpp_namespace.Test2()
+t3 = cpp_namespace.Test3()
+t4 = cpp_namespace.Test4()
+t5 = cpp_namespace.Test5()
+
+if cpp_namespace.foo3(42) != 42:
+ raise RuntimeError("Bad return value!")
+
+if cpp_namespace.do_method3(t2,40) != "Test2::method":
+ raise RuntimeError("Bad return value!")
+
+if cpp_namespace.do_method3(t3,40) != "Test3::method":
+ raise RuntimeError("Bad return value!")
+
+if cpp_namespace.do_method3(t4,40) != "Test4::method":
+ raise RuntimeError("Bad return value!")
+
+if cpp_namespace.do_method3(t5,40) != "Test5::method":
+ raise RuntimeError("Bad return value!")
+
+
diff --git a/trunk/Examples/test-suite/python/cpp_static_runme.py b/trunk/Examples/test-suite/python/cpp_static_runme.py
new file mode 100644
index 000000000..ef8623359
--- /dev/null
+++ b/trunk/Examples/test-suite/python/cpp_static_runme.py
@@ -0,0 +1,7 @@
+#!/usr/bin/evn python
+from cpp_static import *
+StaticFunctionTest.static_func()
+StaticFunctionTest.static_func_2(1)
+StaticFunctionTest.static_func_3(1,2)
+StaticMemberTest.static_int = 10
+assert StaticMemberTest.static_int == 10
diff --git a/trunk/Examples/test-suite/python/default_args_runme.py b/trunk/Examples/test-suite/python/default_args_runme.py
new file mode 100644
index 000000000..091a92376
--- /dev/null
+++ b/trunk/Examples/test-suite/python/default_args_runme.py
@@ -0,0 +1,64 @@
+import default_args
+
+
+if default_args.Statics_staticMethod() != 60:
+ raise RuntimeError
+
+if default_args.cfunc1(1) != 2:
+ raise RuntimeError
+
+if default_args.cfunc2(1) != 3:
+ raise RuntimeError
+
+if default_args.cfunc3(1) != 4:
+ raise RuntimeError
+
+
+f = default_args.Foo()
+
+f.newname()
+f.newname(1)
+
+
+try:
+ f = default_args.Foo(1)
+ error = 1
+except:
+ error = 0
+if error: raise RuntimeError,"Foo::Foo ignore is not working"
+
+try:
+ f = default_args.Foo(1,2)
+ error = 1
+except:
+ error = 0
+if error: raise RuntimeError,"Foo::Foo ignore is not working"
+
+try:
+ f = default_args.Foo(1,2,3)
+ error = 1
+except:
+ error = 0
+if error: raise RuntimeError,"Foo::Foo ignore is not working"
+
+try:
+ m = f.meth(1)
+ error = 1
+except:
+ error = 0
+if error: raise RuntimeError,"Foo::meth ignore is not working"
+
+try:
+ m = f.meth(1,2)
+ error = 1
+except:
+ error = 0
+if error: raise RuntimeError,"Foo::meth ignore is not working"
+
+try:
+ m = f.meth(1,2,3)
+ error = 1
+except:
+ error = 0
+if error: raise RuntimeError,"Foo::meth ignore is not working"
+
diff --git a/trunk/Examples/test-suite/python/default_constructor_runme.py b/trunk/Examples/test-suite/python/default_constructor_runme.py
new file mode 100644
index 000000000..334eaa8af
--- /dev/null
+++ b/trunk/Examples/test-suite/python/default_constructor_runme.py
@@ -0,0 +1,111 @@
+import _default_constructor
+
+dc = _default_constructor
+
+a = dc.new_A()
+dc.delete_A(a)
+
+aa = dc.new_AA()
+dc.delete_AA(aa)
+
+try:
+ b = dc.new_B()
+ print "Whoa. new_BB created."
+except:
+ pass
+
+del_b = dc.delete_B
+
+try:
+ bb = dc.new_BB();
+ print "Whoa. new_BB created."
+except:
+ pass
+
+del_bb = dc.delete_BB
+
+try:
+ c = dc.new_C()
+ print "Whoa. new_C created."
+except:
+ pass
+
+del_c = dc.delete_C
+
+cc = dc.new_CC()
+dc.delete_CC(cc)
+
+try:
+ d = dc.new_D();
+ print "Whoa. new_D created"
+except:
+ pass
+
+del_d = dc.delete_D
+
+try:
+ dd = dc.new_DD()
+ print "Whoa. new_DD created"
+except:
+ pass
+
+dd = dc.delete_DD
+
+try:
+ ad = dc.new_AD()
+ print "Whoa. new_AD created"
+except:
+ pass
+
+del_ad = dc.delete_AD
+
+e = dc.new_E()
+dc.delete_E(e)
+
+ee = dc.new_EE()
+dc.delete_EE(ee)
+
+try:
+ eb = dc.new_EB()
+ print "Whoa. new_EB created"
+except:
+ pass
+
+del_eb = dc.delete_EB
+
+f = dc.new_F()
+
+try:
+ del_f = dc.delete_F
+ print "Whoa. delete_F created"
+except AttributeError:
+ pass
+
+dc.F_destroy(f)
+
+ff = dc.new_FFF()
+try:
+ del_ff = dc.delete_FFF
+ print "Whoa. delete_FFF created"
+except AttributeError:
+ pass
+
+dc.F_destroy(ff)
+
+g = dc.new_G()
+
+try:
+ del_g = dc.delete_G
+ print "Whoa. delete_G created"
+except AttributeError:
+ pass
+
+dc.G_destroy(g)
+
+gg = dc.new_GG()
+dc.delete_GG(gg)
+
+
+import default_constructor
+hh = default_constructor.HH(1,1)
+
diff --git a/trunk/Examples/test-suite/python/director_abstract_runme.py b/trunk/Examples/test-suite/python/director_abstract_runme.py
new file mode 100644
index 000000000..7d92d10ff
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_abstract_runme.py
@@ -0,0 +1,68 @@
+import director_abstract
+
+class MyFoo(director_abstract.Foo):
+ def __init__(self):
+ director_abstract.Foo.__init__(self)
+ def ping(self):
+ return "MyFoo::ping()"
+
+
+a = MyFoo()
+
+if a.ping() != "MyFoo::ping()":
+ raise RuntimeError, a.ping()
+
+if a.pong() != "Foo::pong();MyFoo::ping()":
+ raise RuntimeError, a.pong()
+
+
+class MyExample1(director_abstract.Example1):
+ def Color(self, r, g, b):
+ return r
+
+class MyExample2(director_abstract.Example2):
+ def Color(self, r, g, b):
+ return g
+
+class MyExample3(director_abstract.Example3_i):
+ def Color(self, r, g, b):
+ return b
+
+me1 = MyExample1()
+if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
+ raise RuntimeError
+
+me2 = MyExample2(1,2)
+if MyExample2.get_color(me2, 1,2,3) != 2:
+ raise RuntimeError
+
+me3 = MyExample3()
+if MyExample3.get_color(me3, 1,2,3) != 3:
+ raise RuntimeError
+
+error = 1
+try:
+ me1 = director_abstract.Example1()
+except:
+ error = 0
+if (error): raise RuntimeError
+
+error = 1
+try:
+ me2 = director_abstract.Example2()
+except:
+ error = 0
+if (error): raise RuntimeError
+
+error = 1
+try:
+ me3 = director_abstract.Example3_i()
+except:
+ error = 0
+if (error): raise RuntimeError
+
+
+try:
+ f = director_abstract.A.f
+except:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/director_basic_runme.py b/trunk/Examples/test-suite/python/director_basic_runme.py
new file mode 100644
index 000000000..541139814
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_basic_runme.py
@@ -0,0 +1,98 @@
+import director_basic
+
+class PyFoo(director_basic.Foo):
+ def ping(self):
+ return "PyFoo::ping()"
+
+
+a = PyFoo()
+
+if a.ping() != "PyFoo::ping()":
+ raise RuntimeError, a.ping()
+
+if a.pong() != "Foo::pong();PyFoo::ping()":
+ raise RuntimeError, a.pong()
+
+b = director_basic.Foo()
+
+if b.ping() != "Foo::ping()":
+ raise RuntimeError, b.ping()
+
+if b.pong() != "Foo::pong();Foo::ping()":
+ raise RuntimeError, b.pong()
+
+a = director_basic.A1(1)
+
+if a.rg(2) != 2:
+ raise RuntimeError
+
+
+
+class PyClass(director_basic.MyClass):
+ def method(self, vptr):
+ self.cmethod = 7
+ pass
+
+ def vmethod(self, b):
+ b.x = b.x + 31
+ return b
+
+
+b = director_basic.Bar(3)
+d = director_basic.MyClass()
+c = PyClass()
+
+cc = director_basic.MyClass_get_self(c)
+dd = director_basic.MyClass_get_self(d)
+
+bc = cc.cmethod(b)
+bd = dd.cmethod(b)
+
+cc.method(b)
+if c.cmethod != 7:
+ raise RuntimeError
+
+if bc.x != 34:
+ raise RuntimeError
+
+
+if bd.x != 16:
+ raise RuntimeError
+
+
+
+class PyMulti(director_basic.Foo, director_basic.MyClass):
+ def __init__(self):
+ director_basic.Foo.__init__(self)
+ director_basic.MyClass.__init__(self)
+ pass
+
+
+ def vmethod(self, b):
+ b.x = b.x + 31
+ return b
+
+
+ def ping(self):
+ return "PyFoo::ping()"
+
+a = 0
+for i in range(0,100):
+ pymult = PyMulti()
+ pymult.pong()
+ del pymult
+
+
+
+pymult = PyMulti()
+
+
+
+
+p1 = director_basic.Foo_get_self(pymult)
+p2 = director_basic.MyClass_get_self(pymult)
+
+p1.ping()
+p2.vmethod(bc)
+
+
diff --git a/trunk/Examples/test-suite/python/director_classic_runme.py b/trunk/Examples/test-suite/python/director_classic_runme.py
new file mode 100644
index 000000000..7e18a9a61
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_classic_runme.py
@@ -0,0 +1,142 @@
+from director_classic import *
+
+class TargetLangPerson(Person):
+ def __init__(self):
+ Person.__init__(self)
+ def id(self):
+ identifier = "TargetLangPerson"
+ return identifier
+
+class TargetLangChild(Child):
+ def __init__(self):
+ Child.__init__(self)
+ def id(self):
+ identifier = "TargetLangChild"
+ return identifier
+
+class TargetLangGrandChild(GrandChild):
+ def __init__(self):
+ GrandChild.__init__(self)
+ def id(self):
+ identifier = "TargetLangGrandChild"
+ return identifier
+
+# Semis - don't override id() in target language
+class TargetLangSemiPerson(Person):
+ def __init__(self):
+ Person.__init__(self)
+ # No id() override
+
+class TargetLangSemiChild(Child):
+ def __init__(self):
+ Child.__init__(self)
+ # No id() override
+
+class TargetLangSemiGrandChild(GrandChild):
+ def __init__(self):
+ GrandChild.__init__(self)
+ # No id() override
+
+# Orphans - don't override id() in C++
+class TargetLangOrphanPerson(OrphanPerson):
+ def __init__(self):
+ OrphanPerson.__init__(self)
+ def id(self):
+ identifier = "TargetLangOrphanPerson"
+ return identifier
+
+class TargetLangOrphanChild(OrphanChild):
+ def __init__(self):
+ Child.__init__(self)
+ def id(self):
+ identifier = "TargetLangOrphanChild"
+ return identifier
+
+
+def check(person, expected):
+
+ debug = 0
+ # Normal target language polymorphic call
+ ret = person.id()
+ if (debug):
+ print(ret)
+ if (ret != expected):
+ raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
+
+ # Polymorphic call from C++
+ caller = Caller()
+ caller.setCallback(person)
+ ret = caller.call()
+ if (debug):
+ print(ret)
+ if (ret != expected):
+ raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
+
+ # Polymorphic call of object created in target language and passed to C++ and back again
+ baseclass = caller.baseClass()
+ ret = baseclass.id()
+ if (debug):
+ print(ret)
+ if (ret != expected):
+ raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected)
+
+ caller.resetCallback()
+ if (debug):
+ print("----------------------------------------")
+
+
+
+person = Person();
+check(person, "Person");
+del person
+
+person = Child();
+check(person, "Child");
+del person
+
+person = GrandChild();
+check(person, "GrandChild");
+del person
+
+person = TargetLangPerson();
+check(person, "TargetLangPerson");
+del person
+
+person = TargetLangChild();
+check(person, "TargetLangChild");
+del person
+
+person = TargetLangGrandChild();
+check(person, "TargetLangGrandChild");
+del person
+
+# Semis - don't override id() in target language
+person = TargetLangSemiPerson();
+check(person, "Person");
+del person
+
+person = TargetLangSemiChild();
+check(person, "Child");
+del person
+
+person = TargetLangSemiGrandChild();
+check(person, "GrandChild");
+del person
+
+# Orphans - don't override id() in C++
+person = OrphanPerson();
+check(person, "Person");
+del person
+
+person = OrphanChild();
+check(person, "Child");
+del person
+
+person = TargetLangOrphanPerson();
+check(person, "TargetLangOrphanPerson");
+del person
+
+person = TargetLangOrphanChild();
+check(person, "TargetLangOrphanChild");
+del person
+
diff --git a/trunk/Examples/test-suite/python/director_default_runme.py b/trunk/Examples/test-suite/python/director_default_runme.py
new file mode 100644
index 000000000..f3ac14972
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_default_runme.py
@@ -0,0 +1,9 @@
+from director_default import *
+
+
+f = Foo()
+f = Foo(1)
+
+
+f = Bar()
+f = Bar(1)
diff --git a/trunk/Examples/test-suite/python/director_detect_runme.py b/trunk/Examples/test-suite/python/director_detect_runme.py
new file mode 100644
index 000000000..a90cfe8b4
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_detect_runme.py
@@ -0,0 +1,36 @@
+import director_detect
+
+class MyBar(director_detect.Bar):
+ def __init__(self, val = 2):
+ director_detect.Bar.__init__(self)
+ self.val = val
+
+ def get_value(self):
+ self.val = self.val + 1
+ return self.val
+
+ def get_class(self):
+ self.val = self.val + 1
+ return director_detect.A()
+
+ def just_do_it(self):
+ self.val = self.val + 1
+
+ def clone(self):
+ return MyBar(self.val)
+ pass
+
+
+b = MyBar()
+
+f = b.baseclass()
+
+v = f.get_value()
+a = f.get_class()
+f.just_do_it()
+
+c = b.clone()
+vc = c.get_value()
+
+if (v != 3) or (b.val != 5) or (vc != 6):
+ raise RuntimeError,"Bad virtual detection"
diff --git a/trunk/Examples/test-suite/python/director_enum_runme.py b/trunk/Examples/test-suite/python/director_enum_runme.py
new file mode 100644
index 000000000..5692c88b8
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_enum_runme.py
@@ -0,0 +1,12 @@
+import director_enum
+
+class MyFoo(director_enum.Foo):
+ def say_hi(self, val):
+ return val
+
+
+b = director_enum.Foo()
+a = MyFoo()
+
+if a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi):
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/director_exception_runme.py b/trunk/Examples/test-suite/python/director_exception_runme.py
new file mode 100644
index 000000000..82be1289b
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_exception_runme.py
@@ -0,0 +1,77 @@
+from director_exception import *
+
+class MyException(Exception):
+ def __init__(self, a, b):
+ self.msg = a + b
+
+class MyFoo(Foo):
+ def ping(self):
+ raise NotImplementedError, "MyFoo::ping() EXCEPTION"
+
+class MyFoo2(Foo):
+ def ping(self):
+ return True
+ pass # error: should return a string
+
+class MyFoo3(Foo):
+ def ping(self):
+ raise MyException("foo", "bar")
+
+# Check that the NotImplementedError raised by MyFoo.ping() is returned by
+# MyFoo.pong().
+ok = 0
+a = MyFoo()
+b = launder(a)
+try:
+ b.pong()
+except NotImplementedError, e:
+ if str(e) == "MyFoo::ping() EXCEPTION":
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
+except:
+ pass
+if not ok:
+ raise RuntimeError
+
+
+# Check that the director returns the appropriate TypeError if the return type
+# is wrong.
+ok = 0
+a = MyFoo2()
+b = launder(a)
+try:
+ b.pong()
+except TypeError, e:
+ if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
+if not ok:
+ raise RuntimeError
+
+
+# Check that the director can return an exception which requires two arguments
+# to the constructor, without mangling it.
+ok = 0
+a = MyFoo3()
+b = launder(a)
+try:
+ b.pong()
+except MyException, e:
+ if e.msg == 'foobar':
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
+if not ok:
+ raise RuntimeError
+
+try:
+ raise Exception2()
+except Exception2:
+ pass
+
+try:
+ raise Exception1()
+except Exception1:
+ pass
diff --git a/trunk/Examples/test-suite/python/director_extend_runme.py b/trunk/Examples/test-suite/python/director_extend_runme.py
new file mode 100644
index 000000000..1ab58676a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_extend_runme.py
@@ -0,0 +1,20 @@
+# Test case from bug #1506850
+#"When threading is enabled, the interpreter will infinitely wait on a mutex the second
+#time this type of extended method is called. Attached is an example
+#program that waits on the mutex to be unlocked."
+
+from director_extend import *
+
+class MyObject(SpObject):
+ def __init__(self):
+ SpObject.__init__(self)
+ return
+
+ def getFoo(self):
+ return 123
+
+m = MyObject()
+if m.dummy() != 666:
+ raise RuntimeError, "1st call"
+if m.dummy() != 666: # Locked system
+ raise RuntimeError, "2nd call"
diff --git a/trunk/Examples/test-suite/python/director_finalizer_runme.py b/trunk/Examples/test-suite/python/director_finalizer_runme.py
new file mode 100644
index 000000000..4cd1f573e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_finalizer_runme.py
@@ -0,0 +1,48 @@
+from director_finalizer import *
+
+class MyFoo(Foo):
+ def __del__(self):
+ self.orStatus(2)
+ try: Foo.__del__(self)
+ except: pass
+
+
+resetStatus()
+
+a = MyFoo()
+del a
+
+if getStatus() != 3:
+ raise RuntimeError
+
+resetStatus()
+
+a = MyFoo()
+launder(a)
+
+if getStatus() != 0:
+ raise RuntimeError
+
+del a
+
+if getStatus() != 3:
+ raise RuntimeError
+
+resetStatus()
+
+a = MyFoo().__disown__()
+deleteFoo(a)
+
+if getStatus() != 3:
+ raise RuntimeError
+
+resetStatus()
+
+a = MyFoo().__disown__()
+deleteFoo(launder(a))
+
+if getStatus() != 3:
+ raise RuntimeError
+
+resetStatus()
+
diff --git a/trunk/Examples/test-suite/python/director_frob_runme.py b/trunk/Examples/test-suite/python/director_frob_runme.py
new file mode 100644
index 000000000..c2dd734cf
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_frob_runme.py
@@ -0,0 +1,7 @@
+from director_frob import *
+
+foo = Bravo();
+s = foo.abs_method();
+
+if s != "Bravo::abs_method()":
+ raise RuntimeError, s
diff --git a/trunk/Examples/test-suite/python/director_nested_runme.py b/trunk/Examples/test-suite/python/director_nested_runme.py
new file mode 100644
index 000000000..cff82f55b
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_nested_runme.py
@@ -0,0 +1,63 @@
+from director_nested import *
+
+
+class A(FooBar_int):
+ def do_step(self):
+ return "A::do_step;"
+
+ def get_value(self):
+ return "A::get_value"
+
+ pass
+
+
+a = A()
+if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;":
+ raise RuntimeError,"Bad A virtual resolution"
+
+
+class B(FooBar_int):
+ def do_advance(self):
+ return "B::do_advance;" + self.do_step()
+
+ def do_step(self):
+ return "B::do_step;"
+
+ def get_value(self):
+ return 1
+
+ pass
+
+
+b = B()
+
+if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;":
+ raise RuntimeError,"Bad B virtual resolution"
+
+
+
+class C(FooBar_int):
+ def do_advance(self):
+ return "C::do_advance;" + FooBar_int.do_advance(self)
+
+ def do_step(self):
+ return "C::do_step;"
+
+ def get_value(self):
+ return 2
+
+ def get_name(self):
+ return FooBar_int.get_name(self) + " hello"
+
+
+ pass
+
+cc = C()
+c = FooBar_int_get_self(cc)
+c.advance()
+
+if c.get_name() != "FooBar::get_name hello":
+ raise RuntimeError
+
+if c.name() != "FooBar::get_name hello":
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/director_profile_runme.py b/trunk/Examples/test-suite/python/director_profile_runme.py
new file mode 100644
index 000000000..2f67481f5
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_profile_runme.py
@@ -0,0 +1,41 @@
+import director_profile
+
+class MyB(director_profile.B):
+ def vfi(self, a):
+ return a+3
+
+
+
+a = director_profile.A()
+myb = MyB()
+b = director_profile.B.get_self(myb)
+
+
+fi = b.fi
+i = 50000
+a = 1
+while i:
+ a = fi(a) #1
+ a = fi(a) #2
+ a = fi(a) #3
+ a = fi(a) #4
+ a = fi(a) #5
+ a = fi(a) #6
+ a = fi(a) #7
+ a = fi(a) #8
+ a = fi(a) #9
+ a = fi(a) #10
+ a = fi(a) #1
+ a = fi(a) #2
+ a = fi(a) #3
+ a = fi(a) #4
+ a = fi(a) #5
+ a = fi(a) #6
+ a = fi(a) #7
+ a = fi(a) #8
+ a = fi(a) #9
+ a = fi(a) #20
+ i -= 1
+
+print a
+
diff --git a/trunk/Examples/test-suite/python/director_protected_runme.py b/trunk/Examples/test-suite/python/director_protected_runme.py
new file mode 100644
index 000000000..9d565a1b4
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_protected_runme.py
@@ -0,0 +1,88 @@
+from director_protected import *
+
+
+
+class FooBar(Bar):
+ def ping(self):
+ return "FooBar::ping();"
+
+class FooBar2(Bar):
+ def ping(self):
+ return "FooBar2::ping();"
+ def pang(self):
+ return "FooBar2::pang();"
+
+
+b = Bar()
+f = b.create()
+fb = FooBar()
+fb2 = FooBar2()
+
+
+try:
+ s = fb.used()
+ if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();":
+ raise RuntimeError
+ pass
+except:
+ raise RuntimeError, "bad FooBar::used"
+
+try:
+ s = fb2.used()
+ if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
+ raise RuntimeError
+ pass
+except:
+ raise RuntimeError, "bad FooBar2::used"
+
+try:
+ s = b.pong()
+ if s != "Bar::pong();Foo::pong();Bar::ping();":
+ raise RuntimeError
+ pass
+except:
+ raise RuntimeError, "bad Bar::pong"
+
+try:
+ s = f.pong()
+ if s != "Bar::pong();Foo::pong();Bar::ping();":
+ raise RuntimeError
+ pass
+except:
+ raise RuntimeError," bad Foo::pong"
+
+try:
+ s = fb.pong()
+ if s != "Bar::pong();Foo::pong();FooBar::ping();":
+ raise RuntimeError
+ pass
+except:
+ raise RuntimeError," bad FooBar::pong"
+
+protected=1
+try:
+ b.ping()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Boo::ping is protected"
+
+protected=1
+try:
+ f.ping()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Foo::ping is protected"
+
+
+protected=1
+try:
+ f.pang()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"FooBar::pang is protected"
diff --git a/trunk/Examples/test-suite/python/director_stl_runme.py b/trunk/Examples/test-suite/python/director_stl_runme.py
new file mode 100644
index 000000000..aaea0362a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_stl_runme.py
@@ -0,0 +1,39 @@
+import director_stl
+
+class MyFoo(director_stl.Foo):
+ def ping(self, s):
+ return "MyFoo::ping():" + s
+
+ def pident(self, arg):
+ return arg
+
+ def vident(self,v):
+ return v
+
+ def vidents(self,v):
+ return v
+
+ def vsecond(self,v1,v2):
+ return v2
+
+
+a = MyFoo()
+
+a.tping("hello")
+a.tpong("hello")
+
+p = (1,2)
+a.pident(p)
+v = (3,4)
+a.vident(v)
+
+a.tpident(p)
+a.tvident(v)
+
+v1 = (3,4)
+v2 = (5,6)
+a.tvsecond(v1,v2)
+
+vs=("hi", "hello")
+vs
+a.tvidents(vs)
diff --git a/trunk/Examples/test-suite/python/director_string_runme.py b/trunk/Examples/test-suite/python/director_string_runme.py
new file mode 100644
index 000000000..f2db416ca
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_string_runme.py
@@ -0,0 +1,29 @@
+from director_string import *
+
+class B(A):
+ def __init__(self,string):
+ A.__init__(self,string)
+
+ def get_first(self):
+ return A.get_first(self) + " world!"
+
+ def process_text(self, string):
+ A.process_text(self, string)
+ self.smem = "hello"
+
+
+
+b = B("hello")
+
+b.get(0)
+if b.get_first() != "hello world!":
+ print b.get_first()
+ raise RuntimeError
+
+
+b.call_process_func()
+
+if b.smem != "hello":
+ print smem
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/director_thread_runme.py b/trunk/Examples/test-suite/python/director_thread_runme.py
new file mode 100644
index 000000000..15a12ab80
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_thread_runme.py
@@ -0,0 +1,18 @@
+from director_thread import Foo
+
+class Derived(Foo) :
+ def __init__(self):
+ Foo.__init__(self)
+
+ def do_foo(self):
+ self.val = self.val - 1
+
+
+d = Derived()
+d.run()
+
+if d.val >= 0:
+ print d.val
+ raise RuntimeError
+
+d.stop()
diff --git a/trunk/Examples/test-suite/python/director_unroll_runme.py b/trunk/Examples/test-suite/python/director_unroll_runme.py
new file mode 100644
index 000000000..e2bc93779
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_unroll_runme.py
@@ -0,0 +1,19 @@
+import director_unroll
+
+class MyFoo(director_unroll.Foo):
+ def ping(self):
+ return "MyFoo::ping()"
+
+
+a = MyFoo()
+
+b = director_unroll.Bar()
+
+b.set(a)
+c = b.get()
+
+
+if not (a.this == c.this):
+ print a, c
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/director_wstring_runme.py b/trunk/Examples/test-suite/python/director_wstring_runme.py
new file mode 100644
index 000000000..f3f29de5e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/director_wstring_runme.py
@@ -0,0 +1,28 @@
+from director_wstring import *
+
+class B(A):
+ def __init__(self,string):
+ A.__init__(self,string)
+
+ def get_first(self):
+ return A.get_first(self) + u" world!"
+
+ def process_text(self, string):
+ self.smem = u"hello"
+
+
+
+b = B(u"hello")
+
+b.get(0)
+if b.get_first() != u"hello world!":
+ print b.get_first()
+ raise RuntimeError
+
+
+b.call_process_func()
+
+if b.smem != u"hello":
+ print smem
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/disown_runme.py b/trunk/Examples/test-suite/python/disown_runme.py
new file mode 100644
index 000000000..b8cae077a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/disown_runme.py
@@ -0,0 +1,25 @@
+from disown import *
+
+a = A()
+
+tmp = a.thisown
+
+a.thisown = 0
+if a.thisown:
+ raise RuntimeError
+
+a.thisown = 1
+if (not a.thisown):
+ raise RuntimeError
+
+a.thisown = tmp
+if (a.thisown != tmp):
+ raise RuntimeError
+
+
+b = B()
+
+b.acquire(a)
+
+if a.thisown:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/dynamic_cast_runme.py b/trunk/Examples/test-suite/python/dynamic_cast_runme.py
new file mode 100644
index 000000000..68b06db50
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/empty_runme.py b/trunk/Examples/test-suite/python/empty_runme.py
new file mode 100644
index 000000000..7de5d15e5
--- /dev/null
+++ b/trunk/Examples/test-suite/python/empty_runme.py
@@ -0,0 +1 @@
+import empty
diff --git a/trunk/Examples/test-suite/python/enum_template_runme.py b/trunk/Examples/test-suite/python/enum_template_runme.py
new file mode 100644
index 000000000..6ad0a8060
--- /dev/null
+++ b/trunk/Examples/test-suite/python/enum_template_runme.py
@@ -0,0 +1,7 @@
+import enum_template
+if enum_template.MakeETest() != 1:
+ raise RuntimeError
+
+if enum_template.TakeETest(0) != None:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/enums_runme.py b/trunk/Examples/test-suite/python/enums_runme.py
new file mode 100644
index 000000000..8d491baf4
--- /dev/null
+++ b/trunk/Examples/test-suite/python/enums_runme.py
@@ -0,0 +1,19 @@
+
+import _enums
+
+_enums.bar2(1)
+_enums.bar3(1)
+_enums.bar1(1)
+
+if _enums.cvar.enumInstance != 2:
+ raise RuntimeError
+
+if _enums.cvar.Slap != 10:
+ raise RuntimeError
+
+if _enums.cvar.Mine != 11:
+ raise RuntimeError
+
+if _enums.cvar.Thigh != 12:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/exception_order_runme.py b/trunk/Examples/test-suite/python/exception_order_runme.py
new file mode 100644
index 000000000..0b0b1c08d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/exception_order_runme.py
@@ -0,0 +1,41 @@
+from exception_order import *
+
+
+a = A()
+
+try:
+ a.foo()
+except E1,e:
+ pass
+except:
+ raise RuntimeError, "bad exception order"
+
+try:
+ a.bar()
+except E2,e:
+ pass
+except:
+ raise RuntimeError, "bad exception order"
+
+try:
+ a.foobar()
+except RuntimeError,e:
+ if e.args[0] != "postcatch unknown":
+ print "bad exception order",
+ raise RuntimeError, e.args
+
+
+
+try:
+ a.barfoo(1)
+except E1,e:
+ pass
+except:
+ raise RuntimeError, "bad exception order"
+
+try:
+ a.barfoo(2)
+except E2,e:
+ pass
+except:
+ raise RuntimeError, "bad exception order"
diff --git a/trunk/Examples/test-suite/python/extend_placement_runme.py b/trunk/Examples/test-suite/python/extend_placement_runme.py
new file mode 100644
index 000000000..97b7b1654
--- /dev/null
+++ b/trunk/Examples/test-suite/python/extend_placement_runme.py
@@ -0,0 +1,46 @@
+import extend_placement
+
+foo = extend_placement.Foo()
+foo = extend_placement.Foo(1)
+foo = extend_placement.Foo(1,1)
+foo.spam()
+foo.spam("hello")
+foo.spam(1)
+foo.spam(1,1)
+foo.spam(1,1,1)
+foo.spam(extend_placement.Foo())
+foo.spam(extend_placement.Foo(), 1.0)
+
+
+bar = extend_placement.Bar()
+bar = extend_placement.Bar(1)
+bar.spam()
+bar.spam("hello")
+bar.spam(1)
+bar.spam(1,1)
+bar.spam(1,1,1)
+bar.spam(extend_placement.Bar())
+bar.spam(extend_placement.Bar(), 1.0)
+
+
+foo = extend_placement.FooTi()
+foo = extend_placement.FooTi(1)
+foo = extend_placement.FooTi(1,1)
+foo.spam()
+foo.spam("hello")
+foo.spam(1)
+foo.spam(1,1)
+foo.spam(1,1,1)
+foo.spam(extend_placement.Foo())
+foo.spam(extend_placement.Foo(), 1.0)
+
+
+bar = extend_placement.BarTi()
+bar = extend_placement.BarTi(1)
+bar.spam()
+bar.spam("hello")
+bar.spam(1)
+bar.spam(1,1)
+bar.spam(1,1,1)
+bar.spam(extend_placement.Bar())
+bar.spam(extend_placement.Bar(), 1.0)
diff --git a/trunk/Examples/test-suite/python/extend_template_ns_runme.py b/trunk/Examples/test-suite/python/extend_template_ns_runme.py
new file mode 100644
index 000000000..5c5feac66
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/extend_template_runme.py b/trunk/Examples/test-suite/python/extend_template_runme.py
new file mode 100644
index 000000000..be6e2fc98
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/extend_variable_runme.py b/trunk/Examples/test-suite/python/extend_variable_runme.py
new file mode 100644
index 000000000..6a6628cac
--- /dev/null
+++ b/trunk/Examples/test-suite/python/extend_variable_runme.py
@@ -0,0 +1,4 @@
+from extend_variable import *
+
+if Foo.Bar != 42:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/extern_c_runme.py b/trunk/Examples/test-suite/python/extern_c_runme.py
new file mode 100644
index 000000000..1a6d2aa12
--- /dev/null
+++ b/trunk/Examples/test-suite/python/extern_c_runme.py
@@ -0,0 +1,4 @@
+import extern_c
+
+extern_c.RealFunction(2)
+
diff --git a/trunk/Examples/test-suite/python/file_test_runme.py b/trunk/Examples/test-suite/python/file_test_runme.py
new file mode 100644
index 000000000..de4e2669e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/file_test_runme.py
@@ -0,0 +1,10 @@
+import sys
+import file_test
+
+if sys.version_info < (3,0):
+ file_test.nfile(sys.stdout)
+
+cstdout = file_test.GetStdOut()
+
+file_test.nfile(cstdout)
+file_test.nfile_name("test.dat")
diff --git a/trunk/Examples/test-suite/python/friends_runme.py b/trunk/Examples/test-suite/python/friends_runme.py
new file mode 100644
index 000000000..04897655a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/friends_runme.py
@@ -0,0 +1,28 @@
+import friends
+
+a = friends.A(2)
+
+if friends.get_val1(a) != 2: raise RuntimeError
+if friends.get_val2(a) != 4: raise RuntimeError
+if friends.get_val3(a) != 6: raise RuntimeError
+
+# nice overload working fine
+if friends.get_val1(1,2,3) != 1: raise RuntimeError
+
+b = friends.B(3)
+
+# David's case
+if friends.mix(a,b) != 5: raise RuntimeError
+
+di = friends.D_d(2)
+dd = friends.D_d(3.3)
+
+# incredible template overloading working just fine
+if friends.get_val1(di) != 2: raise RuntimeError
+if friends.get_val1(dd) != 3.3: raise RuntimeError
+
+friends.set(di, 4)
+friends.set(dd, 1.3)
+
+if friends.get_val1(di) != 4: raise RuntimeError
+if friends.get_val1(dd) != 1.3: raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/fvirtual_runme.py b/trunk/Examples/test-suite/python/fvirtual_runme.py
new file mode 100644
index 000000000..ada3313de
--- /dev/null
+++ b/trunk/Examples/test-suite/python/fvirtual_runme.py
@@ -0,0 +1,9 @@
+from fvirtual import *
+
+sw = NodeSwitch()
+n = Node()
+i = sw.addChild(n);
+
+if i != 2:
+ raise RuntimeError, "addChild"
+
diff --git a/trunk/Examples/test-suite/python/global_ns_arg_runme.py b/trunk/Examples/test-suite/python/global_ns_arg_runme.py
new file mode 100644
index 000000000..e597db5f8
--- /dev/null
+++ b/trunk/Examples/test-suite/python/global_ns_arg_runme.py
@@ -0,0 +1,5 @@
+from global_ns_arg import *
+
+a = foo(1)
+b = bar()
+
diff --git a/trunk/Examples/test-suite/python/grouping_runme.py b/trunk/Examples/test-suite/python/grouping_runme.py
new file mode 100644
index 000000000..13f8c8c92
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/hugemod.pl b/trunk/Examples/test-suite/python/hugemod.pl
new file mode 100644
index 000000000..5420926e4
--- /dev/null
+++ b/trunk/Examples/test-suite/python/hugemod.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod
+
+my $runme = shift @ARGV;
+
+open HEADER, ">hugemod.h" or die "error";
+open TEST, ">$runme" or die "error";
+open I1, ">hugemod_a.i" or die "error";
+open I2, ">hugemod_b.i" or die "error";
+
+print TEST "import hugemod_a\n";
+print TEST "import hugemod_b\n";
+
+print I1 "\%module hugemod_a;\n";
+print I1 "\%include \"hugemod.h\";\n";
+print I1 "\%{ #include \"hugemod.h\" \%}\n";
+
+print I2 "\%module hugemod_b;\n";
+print I2 "\%import \"hugemod.h\";\n";
+print I2 "\%{ #include \"hugemod.h\" \%}\n";
+print I2 "\%inline \%{\n";
+
+my $i;
+
+for ($i = 0; $i < $modsize; $i++) {
+ my $t = $i * 4;
+ print HEADER "class type$i { public: int a; };\n";
+ print I2 "class dtype$i : public type$i { public: int b; };\n";
+
+ print TEST "c = hugemod_a.type$i()\n";
+ print TEST "c.a = $t\n";
+ print TEST "if c.a != $t:\n";
+ print TEST " raise RuntimeError\n";
+
+ print TEST "c = hugemod_b.dtype$i()\n";
+ print TEST "c.a = $t\n";
+ print TEST "if c.a != $t:\n";
+ print TEST " raise RuntimeError\n";
+
+ $t = -$t;
+
+ print TEST "c.b = $t\n";
+ print TEST "if c.b != $t:\n";
+ print TEST " raise RuntimeError\n\n";
+}
+
+print I2 "\%}\n";
+
+close HEADER;
+close TEST;
+close I1;
+close I2;
diff --git a/trunk/Examples/test-suite/python/iadd_runme.py b/trunk/Examples/test-suite/python/iadd_runme.py
new file mode 100755
index 000000000..fbeb0ec3e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/iadd_runme.py
@@ -0,0 +1,9 @@
+import iadd
+
+f = iadd.Foo()
+
+f.AsA.x = 3
+f.AsA += f.AsA
+
+if f.AsA.x != 6:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/import_nomodule_runme.py b/trunk/Examples/test-suite/python/import_nomodule_runme.py
new file mode 100644
index 000000000..ba0abfd9a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/import_nomodule_runme.py
@@ -0,0 +1,8 @@
+from import_nomodule import *
+
+f = create_Foo()
+test1(f,42)
+delete_Foo(f)
+
+b = Bar()
+test1(b,37)
diff --git a/trunk/Examples/test-suite/python/imports_runme.py b/trunk/Examples/test-suite/python/imports_runme.py
new file mode 100644
index 000000000..50a3ab59f
--- /dev/null
+++ b/trunk/Examples/test-suite/python/imports_runme.py
@@ -0,0 +1,17 @@
+# This is the import runtime testcase.
+
+import imports_b
+import imports_a
+import sys
+
+x = imports_b.B()
+imports_a.A.hello(x)
+
+a = imports_a.A()
+
+c = imports_b.C()
+a1 = c.get_a(c)
+a2 = c.get_a_type(c)
+
+if a1.hello() != a2.hello():
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/inctest_runme.py b/trunk/Examples/test-suite/python/inctest_runme.py
new file mode 100644
index 000000000..e10f4544c
--- /dev/null
+++ b/trunk/Examples/test-suite/python/inctest_runme.py
@@ -0,0 +1,32 @@
+import inctest
+
+error = 0
+try:
+ a = inctest.A()
+except:
+ print "didn't find A"
+ print "therefore, I didn't include 'testdir/subdir1/hello.i'"
+ error = 1
+pass
+
+
+try:
+ b = inctest.B()
+except:
+ print "didn't find B"
+ print "therefore, I didn't include 'testdir/subdir2/hello.i'"
+ error = 1
+pass
+
+if error == 1:
+ raise RuntimeError
+
+# Check the import in subdirectory worked
+if inctest.importtest1(5) != 15:
+ print "import test 1 failed"
+ raise RuntimeError
+
+if inctest.importtest2("black") != "white":
+ print "import test 2 failed"
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/inherit_missing_runme.py b/trunk/Examples/test-suite/python/inherit_missing_runme.py
new file mode 100644
index 000000000..044c166fb
--- /dev/null
+++ b/trunk/Examples/test-suite/python/inherit_missing_runme.py
@@ -0,0 +1,19 @@
+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
+
+inherit_missing.delete_Foo(a)
diff --git a/trunk/Examples/test-suite/python/inout_runme.py b/trunk/Examples/test-suite/python/inout_runme.py
new file mode 100644
index 000000000..fb290f62f
--- /dev/null
+++ b/trunk/Examples/test-suite/python/inout_runme.py
@@ -0,0 +1,22 @@
+import inout
+
+a = inout.AddOne1(1)
+if a != 2:
+ raise RuntimeError
+
+a = inout.AddOne3(1,1,1)
+if a != [2,2,2]:
+ raise RuntimeError
+
+a = inout.AddOne1p((1,1))
+if a != (2,2):
+ raise RuntimeError
+
+a = inout.AddOne2p((1,1),1)
+if a != [(2,2),2]:
+ raise RuntimeError
+
+a = inout.AddOne3p(1,(1,1),1)
+if a != [2,(2,2),2]:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/inplaceadd_runme.py b/trunk/Examples/test-suite/python/inplaceadd_runme.py
new file mode 100644
index 000000000..b703c56c7
--- /dev/null
+++ b/trunk/Examples/test-suite/python/inplaceadd_runme.py
@@ -0,0 +1,20 @@
+import inplaceadd
+a = inplaceadd.A(7)
+
+a += 5
+if a.val != 12:
+ print a.val
+ raise RuntimeError
+
+a -= 5
+if a.val != 7:
+ raise RuntimeError
+
+a *= 2
+
+if a.val != 14:
+ raise RuntimeError
+
+a += a
+if a.val != 28:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/input_runme.py b/trunk/Examples/test-suite/python/input_runme.py
new file mode 100644
index 000000000..f5ef6dc8b
--- /dev/null
+++ b/trunk/Examples/test-suite/python/input_runme.py
@@ -0,0 +1,20 @@
+from input import *
+
+f = Foo()
+if f.foo(2) != 4:
+ raise RuntimeError
+
+if f.foo(None)!= None:
+ raise RuntimeError
+
+if f.foo()!= None:
+ raise RuntimeError
+
+if sfoo("Hello") != "Hello world":
+ raise RuntimeError
+
+if sfoo(None) != None:
+ raise RuntimeError
+
+if sfoo() != None:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/keyword_rename_runme.py b/trunk/Examples/test-suite/python/keyword_rename_runme.py
new file mode 100644
index 000000000..5646ce7d6
--- /dev/null
+++ b/trunk/Examples/test-suite/python/keyword_rename_runme.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+import keyword_rename
+keyword_rename._in(1)
+keyword_rename._except(1)
diff --git a/trunk/Examples/test-suite/python/langobj_runme.py b/trunk/Examples/test-suite/python/langobj_runme.py
new file mode 100644
index 000000000..c10e19303
--- /dev/null
+++ b/trunk/Examples/test-suite/python/langobj_runme.py
@@ -0,0 +1,13 @@
+import sys
+from langobj import *
+
+
+x ="hello"
+rx = sys.getrefcount(x)
+v = identity(x)
+rv = sys.getrefcount(v)
+if v != x:
+ raise RuntimeError
+
+if rv - rx != 1:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_attribute_runme.py b/trunk/Examples/test-suite/python/li_attribute_runme.py
new file mode 100644
index 000000000..db40b9b2a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_attribute_runme.py
@@ -0,0 +1,74 @@
+# Ported to C# li_attribute_runme.cs
+
+import li_attribute
+
+aa = li_attribute.A(1,2,3)
+
+if aa.a != 1:
+ raise RuntimeError
+aa.a = 3
+if aa.a != 3:
+ print aa.a
+ raise RuntimeError
+
+if aa.b != 2:
+ print aa.b
+ raise RuntimeError
+aa.b = 5
+if aa.b != 5:
+ raise RuntimeError
+
+if aa.d != aa.b:
+ raise RuntimeError
+
+if aa.c != 3:
+ raise RuntimeError
+#aa.c = 5
+#if aa.c != 3:
+# raise RuntimeError
+
+pi = li_attribute.Param_i(7)
+if pi.value != 7:
+ raise RuntimeError
+
+pi.value=3
+if pi.value != 3:
+ raise RuntimeError
+
+b = li_attribute.B(aa)
+
+if b.a.c != 3:
+ raise RuntimeError
+
+# class/struct attribute with get/set methods using return/pass by reference
+myFoo = li_attribute.MyFoo()
+myFoo.x = 8
+myClass = li_attribute.MyClass()
+myClass.Foo = myFoo
+if myClass.Foo.x != 8:
+ raise RuntimeError
+
+# class/struct attribute with get/set methods using return/pass by value
+myClassVal = li_attribute.MyClassVal()
+if myClassVal.ReadWriteFoo.x != -1:
+ raise RuntimeError
+if myClassVal.ReadOnlyFoo.x != -1:
+ raise RuntimeError
+myClassVal.ReadWriteFoo = myFoo
+if myClassVal.ReadWriteFoo.x != 8:
+ raise RuntimeError
+if myClassVal.ReadOnlyFoo.x != 8:
+ raise RuntimeError
+
+# string attribute with get/set methods using return/pass by value
+myStringyClass = li_attribute.MyStringyClass("initial string")
+if myStringyClass.ReadWriteString != "initial string":
+ raise RuntimeError
+if myStringyClass.ReadOnlyString != "initial string":
+ raise RuntimeError
+myStringyClass.ReadWriteString = "changed string"
+if myStringyClass.ReadWriteString != "changed string":
+ raise RuntimeError
+if myStringyClass.ReadOnlyString != "changed string":
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/trunk/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
new file mode 100644
index 000000000..9e5668e57
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
@@ -0,0 +1,31 @@
+from li_boost_shared_ptr_bits import *
+
+def check(nd):
+ nd.i = 200
+ i = nd.i
+
+ try:
+ nd.notexist = 100
+ passed = 0
+ except:
+ passed = 1
+
+ if not passed:
+ raise "Test failed"
+
+nd = NonDynamic()
+check(nd)
+b = boing(nd)
+check(b)
+
+################################
+
+v = VectorIntHolder()
+v.push_back(IntHolder(11))
+v.push_back(IntHolder(22))
+v.push_back(IntHolder(33))
+
+sum = sum(v)
+if sum != 66:
+ raise "sum is wrong"
+
diff --git a/trunk/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/trunk/Examples/test-suite/python/li_boost_shared_ptr_runme.py
new file mode 100644
index 000000000..f967def14
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_boost_shared_ptr_runme.py
@@ -0,0 +1,544 @@
+import li_boost_shared_ptr
+import gc
+
+debug = False
+
+# simple shared_ptr usage - created in C++
+class li_boost_shared_ptr_runme:
+ def main(self):
+ if (debug):
+ print "Started"
+
+ li_boost_shared_ptr.cvar.debug_shared = debug
+
+ # Change loop count to run for a long time to monitor memory
+ loopCount = 1 #5000
+ for i in range (0,loopCount):
+ self.runtest()
+
+ # Expect 1 instance - the one global variable (GlobalValue)
+ if (li_boost_shared_ptr.Klass.getTotal_count() != 1):
+ raise RuntimeError("Klass.total_count=%s" % li_boost_shared_ptr.Klass.getTotal_count())
+
+ wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count()
+ if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING):
+ # Expect 1 instance - the one global variable (GlobalSmartValue)
+ if (wrapper_count != 1):
+ raise RuntimeError("shared_ptr wrapper count=%s" % wrapper_count)
+
+ if (debug):
+ print "Finished"
+
+ def runtest(self):
+ # simple shared_ptr usage - created in C++
+ k = li_boost_shared_ptr.Klass("me oh my")
+ val = k.getValue()
+ self.verifyValue("me oh my", val)
+ self.verifyCount(1, k)
+
+ # simple shared_ptr usage - not created in C++
+ k = li_boost_shared_ptr.factorycreate()
+ val = k.getValue()
+ self.verifyValue("factorycreate", val)
+ self.verifyCount(1, k)
+
+ # pass by shared_ptr
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.smartpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointertest", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by shared_ptr pointer
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.smartpointerpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointerpointertest", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by shared_ptr reference
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.smartpointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointerreftest", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by shared_ptr pointer reference
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.smartpointerpointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointerpointerreftest", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # const pass by shared_ptr
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.constsmartpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # const pass by shared_ptr pointer
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.constsmartpointerpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # const pass by shared_ptr reference
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.constsmartpointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by value
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.valuetest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my valuetest", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # pass by pointer
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.pointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my pointertest", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # pass by reference
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.reftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my reftest", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # pass by pointer reference
+ k = li_boost_shared_ptr.Klass("me oh my")
+ kret = li_boost_shared_ptr.pointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my pointerreftest", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # null tests
+ k = None
+
+ if (li_boost_shared_ptr.smartpointertest(k) != None):
+ raise RuntimeError("return was not null")
+
+ if (li_boost_shared_ptr.smartpointerpointertest(k) != None):
+ raise RuntimeError("return was not null")
+
+ if (li_boost_shared_ptr.smartpointerreftest(k) != None):
+ raise RuntimeError("return was not null")
+
+ if (li_boost_shared_ptr.smartpointerpointerreftest(k) != None):
+ raise RuntimeError("return was not null")
+
+ if (li_boost_shared_ptr.nullsmartpointerpointertest(None) != "null pointer"):
+ raise RuntimeError("not null smartpointer pointer")
+
+ try:
+ li_boost_shared_ptr.valuetest(k)
+ raise RuntimeError("Failed to catch null pointer")
+ except ValueError:
+ pass
+
+ if (li_boost_shared_ptr.pointertest(k) != None):
+ raise RuntimeError("return was not null")
+
+ try:
+ li_boost_shared_ptr.reftest(k)
+ raise RuntimeError("Failed to catch null pointer")
+ except ValueError:
+ pass
+
+ # $owner
+ k = li_boost_shared_ptr.pointerownertest()
+ val = k.getValue()
+ self.verifyValue("pointerownertest", val)
+ self.verifyCount(1, k)
+ k = li_boost_shared_ptr.smartpointerpointerownertest()
+ val = k.getValue()
+ self.verifyValue("smartpointerpointerownertest", val)
+ self.verifyCount(1, k)
+
+ # //////////////////////////////// Derived class ////////////////////////////////////////
+ # derived pass by shared_ptr
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.derivedsmartptrtest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my derivedsmartptrtest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # derived pass by shared_ptr pointer
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.derivedsmartptrpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my derivedsmartptrpointertest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # derived pass by shared_ptr ref
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.derivedsmartptrreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my derivedsmartptrreftest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # derived pass by shared_ptr pointer ref
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # derived pass by pointer
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.derivedpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my derivedpointertest-Derived", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # derived pass by ref
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.derivedreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my derivedreftest-Derived", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # //////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ # pass by shared_ptr (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.smartpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointertest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by shared_ptr pointer (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.smartpointerpointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointerpointertest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by shared_ptr reference (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.smartpointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointerreftest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by shared_ptr pointer reference (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.smartpointerpointerreftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my smartpointerpointerreftest-Derived", val)
+ self.verifyCount(2, k)
+ self.verifyCount(2, kret)
+
+ # pass by value (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.valuetest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my valuetest", val) # note slicing
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # pass by pointer (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.pointertest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my pointertest-Derived", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # pass by ref (mixed)
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ kret = li_boost_shared_ptr.reftest(k)
+ val = kret.getValue()
+ self.verifyValue("me oh my reftest-Derived", val)
+ self.verifyCount(1, k)
+ self.verifyCount(1, kret)
+
+ # //////////////////////////////// Overloading tests ////////////////////////////////////////
+ # Base class
+ k = li_boost_shared_ptr.Klass("me oh my")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref")
+
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval")
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref")
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr")
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref")
+
+ # Derived class
+ k = li_boost_shared_ptr.KlassDerived("me oh my")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr")
+ self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref")
+
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval")
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref")
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr")
+ self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref")
+
+ # 3rd derived class
+ k = li_boost_shared_ptr.Klass3rdDerived("me oh my")
+ val = k.getValue()
+ self.verifyValue("me oh my-3rdDerived", val)
+ self.verifyCount(1, k)
+ val = li_boost_shared_ptr.test3rdupcast(k)
+ self.verifyValue("me oh my-3rdDerived", val)
+ self.verifyCount(1, k)
+
+ # //////////////////////////////// Member variables ////////////////////////////////////////
+ # smart pointer by value
+ m = li_boost_shared_ptr.MemberVariables()
+ k = li_boost_shared_ptr.Klass("smart member value")
+ m.SmartMemberValue = k
+ val = k.getValue()
+ self.verifyValue("smart member value", val)
+ self.verifyCount(2, k)
+
+ kmember = m.SmartMemberValue
+ val = kmember.getValue()
+ self.verifyValue("smart member value", val)
+ self.verifyCount(3, kmember)
+ self.verifyCount(3, k)
+
+ del m
+ self.verifyCount(2, kmember)
+ self.verifyCount(2, k)
+
+ # smart pointer by pointer
+ m = li_boost_shared_ptr.MemberVariables()
+ k = li_boost_shared_ptr.Klass("smart member pointer")
+ m.SmartMemberPointer = k
+ val = k.getValue()
+ self.verifyValue("smart member pointer", val)
+ self.verifyCount(1, k)
+
+ kmember = m.SmartMemberPointer
+ val = kmember.getValue()
+ self.verifyValue("smart member pointer", val)
+ self.verifyCount(2, kmember)
+ self.verifyCount(2, k)
+
+ del m
+ self.verifyCount(2, kmember)
+ self.verifyCount(2, k)
+
+ # smart pointer by reference
+ m = li_boost_shared_ptr.MemberVariables()
+ k = li_boost_shared_ptr.Klass("smart member reference")
+ m.SmartMemberReference = k
+ val = k.getValue()
+ self.verifyValue("smart member reference", val)
+ self.verifyCount(2, k)
+
+ kmember = m.SmartMemberReference
+ val = kmember.getValue()
+ self.verifyValue("smart member reference", val)
+ self.verifyCount(3, kmember)
+ self.verifyCount(3, k)
+
+ # The C++ reference refers to SmartMemberValue...
+ kmemberVal = m.SmartMemberValue
+ val = kmember.getValue()
+ self.verifyValue("smart member reference", val)
+ self.verifyCount(4, kmemberVal)
+ self.verifyCount(4, kmember)
+ self.verifyCount(4, k)
+
+ del m
+ self.verifyCount(3, kmemberVal)
+ self.verifyCount(3, kmember)
+ self.verifyCount(3, k)
+
+ # plain by value
+ m = li_boost_shared_ptr.MemberVariables()
+ k = li_boost_shared_ptr.Klass("plain member value")
+ m.MemberValue = k
+ val = k.getValue()
+ self.verifyValue("plain member value", val)
+ self.verifyCount(1, k)
+
+ kmember = m.MemberValue
+ val = kmember.getValue()
+ self.verifyValue("plain member value", val)
+ self.verifyCount(1, kmember)
+ self.verifyCount(1, k)
+
+ del m
+ self.verifyCount(1, kmember)
+ self.verifyCount(1, k)
+
+ # plain by pointer
+ m = li_boost_shared_ptr.MemberVariables()
+ k = li_boost_shared_ptr.Klass("plain member pointer")
+ m.MemberPointer = k
+ val = k.getValue()
+ self.verifyValue("plain member pointer", val)
+ self.verifyCount(1, k)
+
+ kmember = m.MemberPointer
+ val = kmember.getValue()
+ self.verifyValue("plain member pointer", val)
+ self.verifyCount(1, kmember)
+ self.verifyCount(1, k)
+
+ del m
+ self.verifyCount(1, kmember)
+ self.verifyCount(1, k)
+
+ # plain by reference
+ m = li_boost_shared_ptr.MemberVariables()
+ k = li_boost_shared_ptr.Klass("plain member reference")
+ m.MemberReference = k
+ val = k.getValue()
+ self.verifyValue("plain member reference", val)
+ self.verifyCount(1, k)
+
+ kmember = m.MemberReference
+ val = kmember.getValue()
+ self.verifyValue("plain member reference", val)
+ self.verifyCount(1, kmember)
+ self.verifyCount(1, k)
+
+ del m
+ self.verifyCount(1, kmember)
+ self.verifyCount(1, k)
+
+ # null member variables
+ m = li_boost_shared_ptr.MemberVariables()
+
+ # shared_ptr by value
+ k = m.SmartMemberValue
+ if (k != None):
+ raise RuntimeError("expected null")
+ m.SmartMemberValue = None
+ k = m.SmartMemberValue
+ if (k != None):
+ raise RuntimeError("expected null")
+ self.verifyCount(0, k)
+
+ # plain by value
+ try:
+ m.MemberValue = None
+ raise RuntimeError("Failed to catch null pointer")
+ except ValueError:
+ pass
+
+ # ////////////////////////////////// Global variables ////////////////////////////////////////
+ # smart pointer
+ kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue
+ if (kglobal != None):
+ raise RuntimeError("expected null")
+
+ k = li_boost_shared_ptr.Klass("smart global value")
+ li_boost_shared_ptr.cvar.GlobalSmartValue = k
+ self.verifyCount(2, k)
+
+ kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue
+ val = kglobal.getValue()
+ self.verifyValue("smart global value", val)
+ self.verifyCount(3, kglobal)
+ self.verifyCount(3, k)
+ self.verifyValue("smart global value", li_boost_shared_ptr.cvar.GlobalSmartValue.getValue())
+ li_boost_shared_ptr.cvar.GlobalSmartValue = None
+
+ # plain value
+ k = li_boost_shared_ptr.Klass("global value")
+ li_boost_shared_ptr.cvar.GlobalValue = k
+ self.verifyCount(1, k)
+
+ kglobal = li_boost_shared_ptr.cvar.GlobalValue
+ val = kglobal.getValue()
+ self.verifyValue("global value", val)
+ self.verifyCount(1, kglobal)
+ self.verifyCount(1, k)
+ self.verifyValue("global value", li_boost_shared_ptr.cvar.GlobalValue.getValue())
+
+ try:
+ li_boost_shared_ptr.cvar.GlobalValue = None
+ raise RuntimeError("Failed to catch null pointer")
+ except ValueError:
+ pass
+
+ # plain pointer
+ kglobal = li_boost_shared_ptr.cvar.GlobalPointer
+ if (kglobal != None):
+ raise RuntimeError("expected null")
+
+ k = li_boost_shared_ptr.Klass("global pointer")
+ li_boost_shared_ptr.cvar.GlobalPointer = k
+ self.verifyCount(1, k)
+
+ kglobal = li_boost_shared_ptr.cvar.GlobalPointer
+ val = kglobal.getValue()
+ self.verifyValue("global pointer", val)
+ self.verifyCount(1, kglobal)
+ self.verifyCount(1, k)
+ li_boost_shared_ptr.cvar.GlobalPointer = None
+
+ # plain reference
+ kglobal
+
+ k = li_boost_shared_ptr.Klass("global reference")
+ li_boost_shared_ptr.cvar.GlobalReference = k
+ self.verifyCount(1, k)
+
+ kglobal = li_boost_shared_ptr.cvar.GlobalReference
+ val = kglobal.getValue()
+ self.verifyValue("global reference", val)
+ self.verifyCount(1, kglobal)
+ self.verifyCount(1, k)
+
+ try:
+ li_boost_shared_ptr.cvar.GlobalReference = None
+ raise RuntimeError("Failed to catch null pointer")
+ except ValueError:
+ pass
+
+ # ////////////////////////////////// Templates ////////////////////////////////////////
+ pid = li_boost_shared_ptr.PairIntDouble(10, 20.2)
+ if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4):
+ raise RuntimeError("Base values wrong")
+ if (pid.val1 != 10 or pid.val2 != 20.2):
+ raise RuntimeError("Derived Values wrong")
+
+ def verifyValue(self, expected, got):
+ if (expected != got):
+ raise RuntimeError("verify value failed. Expected: ", expected, " Got: ", got)
+
+ def verifyCount(self, expected, k):
+ got = li_boost_shared_ptr.use_count(k)
+ if (expected != got):
+ raise RuntimeError("verify use_count failed. Expected: ", expected, " Got: ", got)
+
+
+runme = li_boost_shared_ptr_runme()
+runme.main()
+
diff --git a/trunk/Examples/test-suite/python/li_carrays_runme.py b/trunk/Examples/test-suite/python/li_carrays_runme.py
new file mode 100644
index 000000000..ad48eab61
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_carrays_runme.py
@@ -0,0 +1,9 @@
+from li_carrays import *
+
+d = doubleArray(10)
+
+d[0] = 7
+d[5] = d[0] + 3
+
+if d[5] + d[0] != 17:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_cdata_runme.py b/trunk/Examples/test-suite/python/li_cdata_runme.py
new file mode 100644
index 000000000..061ca6f68
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_cdata_runme.py
@@ -0,0 +1,10 @@
+
+from li_cdata import *
+
+s = "ABC abc"
+m = malloc(256)
+memmove(m, s)
+ss = cdata(m, 7)
+if ss != "ABC abc":
+ raise "failed"
+
diff --git a/trunk/Examples/test-suite/python/li_cmalloc_runme.py b/trunk/Examples/test-suite/python/li_cmalloc_runme.py
new file mode 100644
index 000000000..9e698aee2
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_cmalloc_runme.py
@@ -0,0 +1,14 @@
+from li_cmalloc import *
+
+p = malloc_int()
+free_int(p)
+
+ok = 0
+try:
+ p = calloc_int(-1)
+ free_int(p)
+except:
+ ok = 1
+
+if ok != 1:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_cpointer_runme.py b/trunk/Examples/test-suite/python/li_cpointer_runme.py
new file mode 100644
index 000000000..ac95ff4b9
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_cpointer_runme.py
@@ -0,0 +1,10 @@
+from li_cpointer import *
+
+
+p = new_intp()
+intp_assign(p,3)
+
+if intp_value(p) != 3:
+ raise RuntimeError
+
+delete_intp(p)
diff --git a/trunk/Examples/test-suite/python/li_cstring_runme.py b/trunk/Examples/test-suite/python/li_cstring_runme.py
new file mode 100644
index 000000000..6503744bd
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_cstring_runme.py
@@ -0,0 +1,32 @@
+from li_cstring import *
+
+
+if count("ab\0ab\0ab\0", 0) != 3:
+ raise RuntimeError
+
+if test1() != "Hello World":
+ raise RuntimeError
+
+if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+ raise RuntimeError
+
+if test3("hello") != "hello-suffix":
+ print test3("hello")
+ raise RuntimeError
+
+if test4("hello") != "hello-suffix":
+ print test4("hello")
+ raise RuntimeError
+
+if test5(4) != 'xxxx':
+ raise RuntimeError
+
+if test6(10) != 'xxxxx':
+ raise RuntimeError
+
+if test7() !="Hello world!":
+ raise RuntimeError
+
+if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/li_cwstring_runme.py b/trunk/Examples/test-suite/python/li_cwstring_runme.py
new file mode 100644
index 000000000..4ab590882
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_cwstring_runme.py
@@ -0,0 +1,29 @@
+from li_cwstring import *
+
+if count(u"ab\0ab\0ab\0", 0) != 3:
+ raise RuntimeError
+
+if test1() != u"Hello World":
+ raise RuntimeError
+
+if test2() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+ raise RuntimeError
+
+if test3("hello") != u"hello-suffix":
+ raise RuntimeError
+
+if test4("hello") != u"hello-suffix":
+ raise RuntimeError
+
+if test5(4) != u'xxxx':
+ raise RuntimeError
+
+if test6(10) != u'xxxxx':
+ raise RuntimeError
+
+if test7() != u"Hello world!":
+ raise RuntimeError
+
+if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/li_factory_runme.py b/trunk/Examples/test-suite/python/li_factory_runme.py
new file mode 100644
index 000000000..fb2c81e45
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_factory_runme.py
@@ -0,0 +1,11 @@
+from li_factory import *
+
+circle = Geometry_create(Geometry.CIRCLE)
+r = circle.radius()
+if (r != 1.5):
+ raise RuntimeError
+
+point = Geometry_create(Geometry.POINT)
+w = point.width()
+if (w != 1.0):
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_implicit_runme.py b/trunk/Examples/test-suite/python/li_implicit_runme.py
new file mode 100644
index 000000000..a0672e016
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_implicit_runme.py
@@ -0,0 +1,17 @@
+from li_implicit import *
+b = B()
+ai = A(1)
+ad = A(2.0)
+ab = A(b)
+
+ai, get(ai)
+ad, get(ad)
+ab, get(ab)
+
+if get(ai) != get(1):
+ raise RuntimeError,"bad implicit type"
+if get(ad) != get(2.0):
+ raise RuntimeError,"bad implicit type"
+if get(ab) != get(b):
+ raise RuntimeError,"bad implicit type"
+
diff --git a/trunk/Examples/test-suite/python/li_std_carray_runme.py b/trunk/Examples/test-suite/python/li_std_carray_runme.py
new file mode 100644
index 000000000..803bc96c5
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_carray_runme.py
@@ -0,0 +1,41 @@
+from li_std_carray import *
+
+
+v3 = Vector3()
+for i in range(0,len(v3)):
+ v3[i] = i
+
+i = 0
+for d in v3:
+ if d != i:
+ raise RuntimeError
+ i = i + 1
+
+
+m3 = Matrix3()
+
+for i in range(0,len(m3)):
+ v3 = m3[i]
+ for j in range(0,len(v3)):
+ v3[j] = i + j
+
+i = 0
+for v3 in m3:
+ j = 0
+ for d in v3:
+ if d != i + j:
+ raise RuntimeError
+ j = j + 1
+ pass
+ i = i + 1
+ pass
+
+for i in range(0,len(m3)):
+ for j in range(0,len(m3)):
+ if m3[i][j] != i + j:
+ raise RuntimeError
+
+da = Vector3((1,2,3))
+ma = Matrix3(((1,2,3),(4,5,6),(7,8,9)))
+
+
diff --git a/trunk/Examples/test-suite/python/li_std_map_runme.py b/trunk/Examples/test-suite/python/li_std_map_runme.py
new file mode 100644
index 000000000..ae75bdda0
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_map_runme.py
@@ -0,0 +1,58 @@
+import li_std_map
+
+a1 = li_std_map.A(3)
+a2 = li_std_map.A(7)
+
+
+p0 = li_std_map.pairii(1,2)
+p1 = li_std_map.pairA(1,a1.this)
+m = {}
+m[1] = a1
+m[2] = a2
+
+pp1 = li_std_map.p_identa(p1)
+mm = li_std_map.m_identa(m)
+
+
+
+m = li_std_map.mapA()
+m[1] = a1
+m[2] = a2
+
+
+pm ={}
+for k in m:
+ pm[k] = m[k]
+
+for k in m:
+ if pm[k].this != m[k].this:
+ print pm[k], m[k]
+ raise RuntimeError
+
+
+
+
+
+m = {}
+m[1] = (1,2)
+m["foo"] = "hello"
+
+pm = li_std_map.pymap()
+
+for k in m:
+ pm[k] = m[k]
+
+for k in pm:
+ if (pm[k] != m[k]):
+ raise RuntimeError
+
+
+
+mii = li_std_map.IntIntMap()
+
+mii[1] = 1
+mii[1] = 2
+
+if mii[1] != 2:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/li_std_pair_extra_runme.py b/trunk/Examples/test-suite/python/li_std_pair_extra_runme.py
new file mode 100644
index 000000000..dc6e31b76
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_pair_extra_runme.py
@@ -0,0 +1,59 @@
+import li_std_pair_extra
+
+p = (1,2)
+p1 = li_std_pair_extra.p_inout(p)
+p2 = li_std_pair_extra.p_inoutd(p1)
+
+d1 = li_std_pair_extra.d_inout(2)
+
+i,d2 = li_std_pair_extra.d_inout2(2)
+
+i,p = li_std_pair_extra.p_inout2(p)
+p3,p4 = li_std_pair_extra.p_inout3(p1,p1)
+
+psi = li_std_pair_extra.SIPair("hello",1)
+pci = li_std_pair_extra.CIPair(1,1)
+
+
+#psi.first = "hi"
+
+
+psi = li_std_pair_extra.SIPair("hi",1)
+if psi != ("hi",1):
+ raise RuntimeError
+
+psii = li_std_pair_extra.SIIPair(psi,1)
+
+a = li_std_pair_extra.A()
+b = li_std_pair_extra.B()
+
+pab = li_std_pair_extra.ABPair(a,b);
+
+pab.first = a
+pab.first.val = 2
+
+if pab.first.val != 2:
+ raise RuntimeError
+
+
+pci = li_std_pair_extra.CIntPair(1,0)
+
+a = li_std_pair_extra.A(5)
+p1 = li_std_pair_extra.pairP1(1,a.this)
+p2 = li_std_pair_extra.pairP2(a,1)
+p3 = li_std_pair_extra.pairP3(a,a)
+
+
+if a.val != li_std_pair_extra.p_identa(p1.this)[1].val:
+ raise RuntimeError
+
+p = li_std_pair_extra.IntPair(1,10)
+p.first = 1
+
+p = li_std_pair_extra.paircA1(1,a)
+p.first
+p.second
+
+p = li_std_pair_extra.paircA2(1,a)
+pp = li_std_pair_extra.pairiiA(1,p)
+
diff --git a/trunk/Examples/test-suite/python/li_std_set_runme.py b/trunk/Examples/test-suite/python/li_std_set_runme.py
new file mode 100644
index 000000000..6d8963138
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_set_runme.py
@@ -0,0 +1,96 @@
+from li_std_set import *
+
+s = set_string()
+
+s.append("a")
+s.append("b")
+s.append("c")
+
+sum = ""
+for i in s:
+ sum = sum + i
+
+if sum != "abc":
+ raise RuntimeError
+
+i = s.__iter__()
+if i.next() != "a":
+ raise RuntimeError
+if i.next() != "b":
+ raise RuntimeError
+if i.next() != "c":
+ raise RuntimeError
+
+
+b = s.begin()
+e = s.end()
+sum = ""
+while (b != e):
+ sum = sum + b.next()
+if sum != "abc":
+ raise RuntimeError
+
+b = s.rbegin()
+e = s.rend()
+sum = ""
+while (b != e):
+ sum = sum + b.next()
+
+if sum != "cba":
+ raise RuntimeError
+
+
+
+si = set_int()
+
+si.append(1)
+si.append(2)
+si.append(3)
+i = si.__iter__()
+
+if i.next() != 1:
+ raise RuntimeError
+if i.next() != 2:
+ raise RuntimeError
+if i.next() != 3:
+ raise RuntimeError
+
+
+
+
+i = s.begin()
+i.next()
+s.erase(i)
+
+b = s.begin()
+e = s.end()
+sum = ""
+while (b != e):
+ sum = sum + b.next()
+if sum != "ac":
+ raise RuntimeError
+
+
+b = s.begin()
+e = s.end()
+if e - b != 2:
+ raise RuntimeError
+
+m = b + 1
+if m.value() != "c":
+ raise RuntimeError
+
+
+
+s = pyset()
+s.insert((1,2))
+s.insert(1)
+s.insert("hello")
+
+
+sum = ()
+for i in s:
+ sum = sum + (i,)
+
+if sum != (1, 'hello', (1, 2)):
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_std_stream_runme.py b/trunk/Examples/test-suite/python/li_std_stream_runme.py
new file mode 100644
index 000000000..d41e41f4a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_stream_runme.py
@@ -0,0 +1,14 @@
+from li_std_stream import *
+
+
+
+a = A()
+
+o = ostringstream()
+
+o << a << " " << 2345 << " " << 1.435
+
+
+if o.str() != "A class 2345 1.435":
+ print "\"%s\"" % (o.str(),)
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_std_string_extra_runme.py b/trunk/Examples/test-suite/python/li_std_string_extra_runme.py
new file mode 100644
index 000000000..cef5921b0
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -0,0 +1,132 @@
+import li_std_string_extra
+
+x="hello"
+
+
+
+if li_std_string_extra.test_ccvalue(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_cvalue(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_value(x) != x:
+ print x, li_std_string_extra.test_value(x)
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_const_reference(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+
+s = li_std_string_extra.string("he")
+#s += "ll"
+#s.append('o')
+s = s + "llo"
+
+if s != x:
+ print s, x
+ raise RuntimeError, "bad string mapping"
+
+if s[1:4] != x[1:4]:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_value(s) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_const_reference(s) != x:
+ raise RuntimeError, "bad string mapping"
+
+a = li_std_string_extra.A(s)
+
+if li_std_string_extra.test_value(a) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_const_reference(a) != x:
+ raise RuntimeError, "bad string mapping"
+
+b = li_std_string_extra.string(" world")
+
+s = a + b
+if a + b != "hello world":
+ print a + b
+ raise RuntimeError, "bad string mapping"
+
+if a + " world" != "hello world":
+ raise RuntimeError, "bad string mapping"
+
+if "hello" + b != "hello world":
+ raise RuntimeError, "bad string mapping"
+
+c = "hello" + b
+if c.find_last_of("l") != 9:
+ raise RuntimeError, "bad string mapping"
+
+s = "hello world"
+
+b = li_std_string_extra.B("hi")
+
+b.name = li_std_string_extra.string("hello")
+if b.name != "hello":
+ raise RuntimeError, "bad string mapping"
+
+
+b.a = li_std_string_extra.A("hello")
+if b.a != "hello":
+ raise RuntimeError, "bad string mapping"
+
+
+if li_std_string_extra.test_value_basic1(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_string_extra.test_value_basic2(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+
+if li_std_string_extra.test_value_basic3(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+# Global variables
+s = "initial string"
+if li_std_string_extra.cvar.GlobalString2 != "global string 2":
+ raise RuntimeError, "GlobalString2 test 1"
+li_std_string_extra.cvar.GlobalString2 = s
+if li_std_string_extra.cvar.GlobalString2 != s:
+ raise RuntimeError, "GlobalString2 test 2"
+if li_std_string_extra.cvar.ConstGlobalString != "const global string":
+ raise RuntimeError, "ConstGlobalString test"
+
+# Member variables
+myStructure = li_std_string_extra.Structure()
+if myStructure.MemberString2 != "member string 2":
+ raise RuntimeError, "MemberString2 test 1"
+myStructure.MemberString2 = s
+if myStructure.MemberString2 != s:
+ raise RuntimeError, "MemberString2 test 2"
+if myStructure.ConstMemberString != "const member string":
+ raise RuntimeError, "ConstMemberString test"
+
+if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2":
+ raise RuntimeError, "StaticMemberString2 test 1"
+li_std_string_extra.cvar.Structure_StaticMemberString2 = s
+if li_std_string_extra.cvar.Structure_StaticMemberString2 != s:
+ raise RuntimeError, "StaticMemberString2 test 2"
+if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string":
+ raise RuntimeError, "ConstStaticMemberString test"
+
+
+if li_std_string_extra.test_reference_input("hello") != "hello":
+ raise RuntimeError
+s = li_std_string_extra.test_reference_inout("hello")
+if s != "hellohello":
+ raise RuntimeError
+
+
+if li_std_string_extra.stdstring_empty() != "":
+ raise RuntimeError
+
+
+if li_std_string_extra.c_empty() != "":
+ raise RuntimeError
+
+if li_std_string_extra.c_null() != None:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_std_vector_extra_runme.py b/trunk/Examples/test-suite/python/li_std_vector_extra_runme.py
new file mode 100644
index 000000000..8900d7298
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_vector_extra_runme.py
@@ -0,0 +1,176 @@
+from li_std_vector_extra import *
+
+iv = IntVector(4)
+for i in range(0,4):
+ iv[i] = i
+
+x = average(iv)
+y = average([1,2,3,4])
+
+a = half([10,10.5,11,11.5])
+
+dv = DoubleVector(10)
+for i in range(0,10):
+ dv[i] = i/2.0
+
+halve_in_place(dv)
+
+
+bv = BoolVector(4)
+bv[0]= 1
+bv[1]= 0
+bv[2]= 4
+bv[3]= 0
+
+if bv[0] != bv[2]:
+ raise RuntimeError,"bad std::vector<bool> mapping"
+
+b = B(5)
+va = VecA([b,None,b,b])
+
+if va[0].f(1) != 6:
+ raise RuntimeError,"bad std::vector<A*> mapping"
+
+if vecAptr(va) != 6:
+ raise RuntimeError,"bad std::vector<A*> mapping"
+
+b.val = 7
+if va[3].f(1) != 8:
+ raise RuntimeError,"bad std::vector<A*> mapping"
+
+
+ip = PtrInt()
+ap = new_ArrInt(10)
+
+ArrInt_setitem(ip,0,123)
+ArrInt_setitem(ap,2,123)
+
+vi = IntPtrVector((ip,ap,None))
+if ArrInt_getitem(vi[0],0) != ArrInt_getitem(vi[1],2):
+ raise RuntimeError,"bad std::vector<int*> mapping"
+
+delete_ArrInt(ap)
+
+
+a = halfs([10,8,4,3])
+
+v = IntVector()
+v[0:2] = [1,2]
+if v[0] != 1 or v[1] != 2:
+ raise RuntimeError,"bad setslice"
+
+if v[0:-1][0] != 1:
+ raise RuntimeError,"bad getslice"
+
+if v[0:-2].size() != 0:
+ raise RuntimeError,"bad getslice"
+
+v[0:1] = [2]
+if v[0] != 2:
+ raise RuntimeError,"bad setslice"
+
+v[1:] = [3]
+if v[1] != 3:
+ raise RuntimeError,"bad setslice"
+
+v[2:] = [3]
+if v[2] != 3:
+ raise RuntimeError,"bad setslice"
+
+if v[0:][0] != v[0]:
+ raise RuntimeError,"bad getslice"
+
+
+del v[:]
+if v.size() != 0:
+ raise RuntimeError,"bad getslice"
+
+del v[:]
+if v.size() != 0:
+ raise RuntimeError,"bad getslice"
+
+
+
+v = vecStr(["hello ", "world"])
+if v[0] != 'hello world':
+ raise RuntimeError,"bad std::string+std::vector"
+
+
+
+pv = pyvector([1, "hello", (1,2)])
+
+if pv[1] != "hello":
+ raise RuntimeError
+
+
+iv = IntVector(5)
+for i in range(0,5):
+ iv[i] = i
+
+iv[1:3] = []
+if iv[1] != 3:
+ raise RuntimeError
+
+# Overloading checks
+if overloaded1(iv) != "vector<int>":
+ raise RuntimeError
+
+if overloaded1(dv) != "vector<double>":
+ raise RuntimeError
+
+if overloaded2(iv) != "vector<int>":
+ raise RuntimeError
+
+if overloaded2(dv) != "vector<double>":
+ raise RuntimeError
+
+if overloaded3(iv) != "vector<int> *":
+ raise RuntimeError
+
+if overloaded3(None) != "vector<int> *":
+ raise RuntimeError
+
+if overloaded3(100) != "int":
+ raise RuntimeError
+
+
+# vector pointer checks
+ip = makeIntPtr(11)
+dp = makeDoublePtr(33.3)
+error = 0
+try:
+ vi = IntPtrVector((ip, dp)) # check vector<int *> does not accept double * element
+ error = 1
+except:
+ pass
+
+if error:
+ raise RuntimeError
+
+vi = IntPtrVector((ip, makeIntPtr(22)))
+if extractInt(vi[0]) != 11:
+ raise RuntimeError
+
+if extractInt(vi[1]) != 22:
+ raise RuntimeError
+
+# vector const pointer checks
+csp = makeConstShortPtr(111)
+
+error = 0
+try:
+ vcs = ConstShortPtrVector((csp, dp)) # check vector<const unsigned short *> does not accept double * element
+ error = 1
+except:
+ pass
+
+if error:
+ raise RuntimeError
+
+vcs = ConstShortPtrVector((csp, makeConstShortPtr(222)))
+if extractConstShort(vcs[0]) != 111:
+ raise RuntimeError
+
+if extractConstShort(vcs[1]) != 222:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/li_std_vector_ptr_runme.py b/trunk/Examples/test-suite/python/li_std_vector_ptr_runme.py
new file mode 100644
index 000000000..c5f72fde4
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_vector_ptr_runme.py
@@ -0,0 +1,8 @@
+from li_std_vector_ptr import *
+
+ip1 = makeIntPtr(11)
+ip2 = makeIntPtr(22)
+
+vi = IntPtrVector((ip1, ip2))
+displayVector(vi)
+
diff --git a/trunk/Examples/test-suite/python/li_std_wstream_runme.py b/trunk/Examples/test-suite/python/li_std_wstream_runme.py
new file mode 100644
index 000000000..f7379bdf8
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_wstream_runme.py
@@ -0,0 +1,13 @@
+from li_std_wstream import *
+
+
+
+a = A()
+
+o = wostringstream()
+
+o << a << u" " << 2345 << u" " << 1.435 << wends
+
+if o.str() != "A class 2345 1.435\0":
+ print "\"%s\"" % (o.str(),)
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/li_std_wstring_runme.py b/trunk/Examples/test-suite/python/li_std_wstring_runme.py
new file mode 100644
index 000000000..a4b9d3ee2
--- /dev/null
+++ b/trunk/Examples/test-suite/python/li_std_wstring_runme.py
@@ -0,0 +1,76 @@
+import li_std_wstring
+
+x=u"h"
+
+if li_std_wstring.test_wcvalue(x) != x:
+ print li_std_wstring.test_wcvalue(x)
+ raise RuntimeError, "bad string mapping"
+
+x=u"hello"
+if li_std_wstring.test_ccvalue(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_wstring.test_cvalue(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_wstring.test_value(x) != x:
+ print x, li_std_wstring.test_value(x)
+ raise RuntimeError, "bad string mapping"
+
+if li_std_wstring.test_const_reference(x) != x:
+ raise RuntimeError, "bad string mapping"
+
+
+s = li_std_wstring.wstring(u"he")
+s = s + u"llo"
+
+if s != x:
+ print s, x
+ raise RuntimeError, "bad string mapping"
+
+if s[1:4] != x[1:4]:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_wstring.test_value(s) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_wstring.test_const_reference(s) != x:
+ raise RuntimeError, "bad string mapping"
+
+a = li_std_wstring.A(s)
+
+if li_std_wstring.test_value(a) != x:
+ raise RuntimeError, "bad string mapping"
+
+if li_std_wstring.test_const_reference(a) != x:
+ raise RuntimeError, "bad string mapping"
+
+b = li_std_wstring.wstring(" world")
+
+if a + b != "hello world":
+ raise RuntimeError, "bad string mapping"
+
+if a + " world" != "hello world":
+ raise RuntimeError, "bad string mapping"
+
+if "hello" + b != "hello world":
+ raise RuntimeError, "bad string mapping"
+
+c = "hello" + b
+if c.find_last_of("l") != 9:
+ raise RuntimeError, "bad string mapping"
+
+s = "hello world"
+
+b = li_std_wstring.B("hi")
+
+b.name = li_std_wstring.wstring(u"hello")
+if b.name != "hello":
+ raise RuntimeError, "bad string mapping"
+
+
+b.a = li_std_wstring.A("hello")
+if b.a != u"hello":
+ raise RuntimeError, "bad string mapping"
+
+
diff --git a/trunk/Examples/test-suite/python/member_pointer_runme.py b/trunk/Examples/test-suite/python/member_pointer_runme.py
new file mode 100644
index 000000000..27e7a483d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/member_pointer_runme.py
@@ -0,0 +1,43 @@
+# Example using pointers to member functions
+
+from member_pointer import *
+
+def check(what, expected, actual):
+ if expected != actual:
+ raise RuntimeError ("Failed: " , what , " Expected: " , expected , " Actual: " , actual)
+
+# Get the pointers
+
+area_pt = areapt()
+perim_pt = perimeterpt()
+
+# Create some objects
+
+s = Square(10)
+
+# Do some calculations
+
+check ("Square area ", 100.0, do_op(s,area_pt))
+check ("Square perim", 40.0, do_op(s,perim_pt))
+
+memberPtr = cvar.areavar
+memberPtr = cvar.perimetervar
+
+# Try the variables
+check ("Square area ", 100.0, do_op(s,cvar.areavar))
+check ("Square perim", 40.0, do_op(s,cvar.perimetervar))
+
+# Modify one of the variables
+cvar.areavar = perim_pt
+
+check ("Square perimeter", 40.0, do_op(s,cvar.areavar))
+
+# Try the constants
+
+memberPtr = AREAPT
+memberPtr = PERIMPT
+memberPtr = NULLPT
+
+check ("Square area ", 100.0, do_op(s,AREAPT))
+check ("Square perim", 40.0, do_op(s,PERIMPT))
+
diff --git a/trunk/Examples/test-suite/python/memberin_extend_c_runme.py b/trunk/Examples/test-suite/python/memberin_extend_c_runme.py
new file mode 100644
index 000000000..314761f89
--- /dev/null
+++ b/trunk/Examples/test-suite/python/memberin_extend_c_runme.py
@@ -0,0 +1,6 @@
+import memberin_extend_c
+
+t = memberin_extend_c.Person()
+t.name = "Fred Bloggs"
+if t.name != "FRED BLOGGS":
+ raise RuntimeError("name wrong")
diff --git a/trunk/Examples/test-suite/python/minherit_runme.py b/trunk/Examples/test-suite/python/minherit_runme.py
new file mode 100644
index 000000000..d7ad0b36b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/mod_runme.py b/trunk/Examples/test-suite/python/mod_runme.py
new file mode 100644
index 000000000..d92611991
--- /dev/null
+++ b/trunk/Examples/test-suite/python/mod_runme.py
@@ -0,0 +1,6 @@
+import mod_a
+import mod_b
+
+c = mod_b.C()
+d = mod_b.D()
+d.DoSomething(c)
diff --git a/trunk/Examples/test-suite/python/multi_import_runme.py b/trunk/Examples/test-suite/python/multi_import_runme.py
new file mode 100644
index 000000000..f8a2f19c7
--- /dev/null
+++ b/trunk/Examples/test-suite/python/multi_import_runme.py
@@ -0,0 +1,18 @@
+import multi_import_a
+import multi_import_b
+
+x = multi_import_b.XXX()
+if x.testx() != 0:
+ raise RuntimeError
+
+y = multi_import_b.YYY()
+if y.testx() != 0:
+ raise RuntimeError
+if y.testy() != 1:
+ raise RuntimeError
+
+z = multi_import_a.ZZZ()
+if z.testx() != 0:
+ raise RuntimeError
+if z.testz() != 2:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/namespace_class_runme.py b/trunk/Examples/test-suite/python/namespace_class_runme.py
new file mode 100644
index 000000000..84d3b00ed
--- /dev/null
+++ b/trunk/Examples/test-suite/python/namespace_class_runme.py
@@ -0,0 +1,34 @@
+from namespace_class import *
+
+try:
+ p = Private1()
+ error = 1
+except:
+ error = 0
+
+if (error):
+ raise RuntimeError, "Private1 is private"
+
+try:
+ p = Private2()
+ error = 1
+except:
+ error = 0
+
+if (error):
+ raise RuntimeError, "Private2 is private"
+
+EulerT3D.toFrame(1,1,1)
+
+b = BooT_i()
+b = BooT_H()
+
+
+f = FooT_i()
+f.quack(1)
+
+f = FooT_d()
+f.moo(1)
+
+f = FooT_H()
+f.foo(Hi)
diff --git a/trunk/Examples/test-suite/python/namespace_typemap_runme.py b/trunk/Examples/test-suite/python/namespace_typemap_runme.py
new file mode 100644
index 000000000..682ad3bb1
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/namespace_virtual_method_runme.py b/trunk/Examples/test-suite/python/namespace_virtual_method_runme.py
new file mode 100644
index 000000000..c3580fbc5
--- /dev/null
+++ b/trunk/Examples/test-suite/python/namespace_virtual_method_runme.py
@@ -0,0 +1,3 @@
+import namespace_virtual_method
+
+x = namespace_virtual_method.Spam()
diff --git a/trunk/Examples/test-suite/python/naturalvar_runme.py b/trunk/Examples/test-suite/python/naturalvar_runme.py
new file mode 100644
index 000000000..a0481ec60
--- /dev/null
+++ b/trunk/Examples/test-suite/python/naturalvar_runme.py
@@ -0,0 +1,12 @@
+from naturalvar import *
+
+f = Foo()
+b = Bar()
+
+b.f = f
+
+cvar.s = "hello"
+b.s = "hello"
+
+if b.s != cvar.s:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/nested_workaround_runme.py b/trunk/Examples/test-suite/python/nested_workaround_runme.py
new file mode 100644
index 000000000..a8a75d370
--- /dev/null
+++ b/trunk/Examples/test-suite/python/nested_workaround_runme.py
@@ -0,0 +1,13 @@
+from nested_workaround import *
+
+inner = Inner(5)
+outer = Outer()
+newInner = outer.doubleInnerValue(inner)
+if newInner.getValue() != 10:
+ raise RuntimeError
+
+outer = Outer()
+inner = outer.createInner(3)
+newInner = outer.doubleInnerValue(inner)
+if outer.getInnerValue(newInner) != 6:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/operbool_runme.py b/trunk/Examples/test-suite/python/operbool_runme.py
new file mode 100644
index 000000000..4218b5dd4
--- /dev/null
+++ b/trunk/Examples/test-suite/python/operbool_runme.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+import operbool
+assert not operbool.Test()
+
diff --git a/trunk/Examples/test-suite/python/overload_complicated_runme.py b/trunk/Examples/test-suite/python/overload_complicated_runme.py
new file mode 100755
index 000000000..2b7467d4d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_complicated_runme.py
@@ -0,0 +1,47 @@
+from overload_complicated import *
+
+pInt = None
+
+# Check the correct constructors are available
+p = Pop(pInt)
+
+p = Pop(pInt, 0)
+
+# Check overloaded in const only and pointers/references which target languages cannot disambiguate
+if p.hip(0) != 701:
+ raise RuntimeError,"Test 1 failed"
+
+if p.hip(pInt) != 702:
+ raise RuntimeError,"Test 2 failed"
+
+# Reverse the order for the above
+if p.hop(pInt) != 805:
+ raise RuntimeError,"Test 3 failed"
+
+if p.hop(0) != 801:
+ raise RuntimeError,"Test 4 failed"
+
+# Few more variations and order shuffled
+if p.pop(0) != 901:
+ raise RuntimeError,"Test 5 failed"
+
+if p.pop(pInt) != 902:
+ raise RuntimeError,"Test 6 failed"
+
+if p.pop() != 905:
+ raise RuntimeError,"Test 7 failed"
+
+# Overload on const only
+if p.bop(pInt) != 1001:
+ raise RuntimeError,"Test 8 failed"
+
+if p.bip(pInt) != 2001:
+ raise RuntimeError,"Test 9 failed"
+
+# Globals
+if muzak(0) != 3001:
+ raise RuntimeError,"Test 10 failed"
+
+if muzak(pInt) != 3002:
+ raise RuntimeError,"Test 11 failed"
+
diff --git a/trunk/Examples/test-suite/python/overload_copy_runme.py b/trunk/Examples/test-suite/python/overload_copy_runme.py
new file mode 100644
index 000000000..6ccf4013e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_copy_runme.py
@@ -0,0 +1,3 @@
+from overload_copy import *
+f = Foo()
+g = Foo(f)
diff --git a/trunk/Examples/test-suite/python/overload_extend_runme.py b/trunk/Examples/test-suite/python/overload_extend_runme.py
new file mode 100644
index 000000000..7d08d482b
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_extend_runme.py
@@ -0,0 +1,14 @@
+import overload_extend
+
+f = overload_extend.Foo()
+if f.test() != 0:
+ raise RuntimeError
+if f.test(3) != 1:
+ raise RuntimeError
+if f.test("hello") != 2:
+ raise RuntimeError
+if f.test(3,2) != 5:
+ raise RuntimeError
+if f.test(3.0) != 1003:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/overload_extendc_runme.py b/trunk/Examples/test-suite/python/overload_extendc_runme.py
new file mode 100644
index 000000000..cea3ea618
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_extendc_runme.py
@@ -0,0 +1,22 @@
+import overload_extendc
+
+f = overload_extendc.Foo()
+if f.test(3) != 1:
+ raise RuntimeError
+if f.test("hello") != 2:
+ raise RuntimeError
+if f.test(3.5,2.5) != 3:
+ raise RuntimeError
+if f.test("hello",20) != 1020:
+ raise RuntimeError
+if f.test("hello",20,100) != 120:
+ raise RuntimeError
+
+# C default args
+if f.test(f) != 30:
+ raise RuntimeError
+if f.test(f,100) != 120:
+ raise RuntimeError
+if f.test(f,100,200) != 300:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/overload_rename_runme.py b/trunk/Examples/test-suite/python/overload_rename_runme.py
new file mode 100644
index 000000000..b192f7d5d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_rename_runme.py
@@ -0,0 +1,8 @@
+import overload_rename
+
+
+f = overload_rename.Foo(1)
+f = overload_rename.Foo(1,1)
+f = overload_rename.Foo_int(1,1)
+f = overload_rename.Foo_int(1,1,1)
+
diff --git a/trunk/Examples/test-suite/python/overload_simple_runme.py b/trunk/Examples/test-suite/python/overload_simple_runme.py
new file mode 100644
index 000000000..a78f3720a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_simple_runme.py
@@ -0,0 +1,102 @@
+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 *)"
+
+
+
+
+
+free_void(v)
+
+
+a = ClassA()
+b = a.method1(1)
diff --git a/trunk/Examples/test-suite/python/overload_subtype_runme.py b/trunk/Examples/test-suite/python/overload_subtype_runme.py
new file mode 100644
index 000000000..6bf77dc59
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/overload_template_fast_runme.py b/trunk/Examples/test-suite/python/overload_template_fast_runme.py
new file mode 100644
index 000000000..d47f7d14d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_template_fast_runme.py
@@ -0,0 +1,145 @@
+from overload_template_fast import *
+f = foo()
+
+a = maximum(3,4)
+b = maximum(3.4,5.2)
+
+# mix 1
+if (mix1("hi") != 101):
+ raise RuntimeError, ("mix1(const char*)")
+
+if (mix1(1.0, 1.0) != 102):
+ raise RuntimeError, ("mix1(double, const double &)")
+
+if (mix1(1.0) != 103):
+ raise RuntimeError, ("mix1(double)")
+
+# mix 2
+if (mix2("hi") != 101):
+ raise RuntimeError, ("mix2(const char*)")
+
+if (mix2(1.0, 1.0) != 102):
+ raise RuntimeError, ("mix2(double, const double &)")
+
+if (mix2(1.0) != 103):
+ raise RuntimeError, ("mix2(double)")
+
+# mix 3
+if (mix3("hi") != 101):
+ raise RuntimeError, ("mix3(const char*)")
+
+if (mix3(1.0, 1.0) != 102):
+ raise RuntimeError, ("mix3(double, const double &)")
+
+if (mix3(1.0) != 103):
+ raise RuntimeError, ("mix3(double)")
+
+# Combination 1
+if (overtparams1(100) != 10):
+ raise RuntimeError, ("overtparams1(int)")
+
+if (overtparams1(100.0, 100) != 20):
+ raise RuntimeError, ("overtparams1(double, int)")
+
+# Combination 2
+if (overtparams2(100.0, 100) != 40):
+ raise RuntimeError, ("overtparams2(double, int)")
+
+# Combination 3
+if (overloaded() != 60):
+ raise RuntimeError, ("overloaded()")
+
+if (overloaded(100.0, 100) != 70):
+ raise RuntimeError, ("overloaded(double, int)")
+
+# Combination 4
+if (overloadedagain("hello") != 80):
+ raise RuntimeError, ("overloadedagain(const char *)")
+
+if (overloadedagain() != 90):
+ raise RuntimeError, ("overloadedagain(double)")
+
+# specializations
+if (specialization(10) != 202):
+ raise RuntimeError, ("specialization(int)")
+
+if (specialization(10.0) != 203):
+ raise RuntimeError, ("specialization(double)")
+
+if (specialization(10, 10) != 204):
+ raise RuntimeError, ("specialization(int, int)")
+
+if (specialization(10.0, 10.0) != 205):
+ raise RuntimeError, ("specialization(double, double)")
+
+if (specialization("hi", "hi") != 201):
+ raise RuntimeError, ("specialization(const char *, const char *)")
+
+
+# simple specialization
+xyz()
+xyz_int()
+xyz_double()
+
+# a bit of everything
+if (overload("hi") != 0):
+ raise RuntimeError, ("overload()")
+
+if (overload(1) != 10):
+ raise RuntimeError, ("overload(int t)")
+
+if (overload(1, 1) != 20):
+ raise RuntimeError, ("overload(int t, const int &)")
+
+if (overload(1, "hello") != 30):
+ raise RuntimeError, ("overload(int t, const char *)")
+
+k = Klass()
+if (overload(k) != 10):
+ raise RuntimeError, ("overload(Klass t)")
+
+if (overload(k, k) != 20):
+ raise RuntimeError, ("overload(Klass t, const Klass &)")
+
+if (overload(k, "hello") != 30):
+ raise RuntimeError, ("overload(Klass t, const char *)")
+
+if (overload(10.0, "hi") != 40):
+ raise RuntimeError, ("overload(double t, const char *)")
+
+if (overload() != 50):
+ raise RuntimeError, ("overload(const char *)")
+
+
+# everything put in a namespace
+if (nsoverload("hi") != 1000):
+ raise RuntimeError, ("nsoverload()")
+
+if (nsoverload(1) != 1010):
+ raise RuntimeError, ("nsoverload(int t)")
+
+if (nsoverload(1, 1) != 1020):
+ raise RuntimeError, ("nsoverload(int t, const int &)")
+
+if (nsoverload(1, "hello") != 1030):
+ raise RuntimeError, ("nsoverload(int t, const char *)")
+
+if (nsoverload(k) != 1010):
+ raise RuntimeError, ("nsoverload(Klass t)")
+
+if (nsoverload(k, k) != 1020):
+ raise RuntimeError, ("nsoverload(Klass t, const Klass &)")
+
+if (nsoverload(k, "hello") != 1030):
+ raise RuntimeError, ("nsoverload(Klass t, const char *)")
+
+if (nsoverload(10.0, "hi") != 1040):
+ raise RuntimeError, ("nsoverload(double t, const char *)")
+
+if (nsoverload() != 1050):
+ raise RuntimeError, ("nsoverload(const char *)")
+
+
+A.foo(1)
+b = B()
+b.foo(1)
diff --git a/trunk/Examples/test-suite/python/overload_template_runme.py b/trunk/Examples/test-suite/python/overload_template_runme.py
new file mode 100644
index 000000000..c1337ba6a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/overload_template_runme.py
@@ -0,0 +1,145 @@
+from overload_template import *
+f = foo()
+
+a = maximum(3,4)
+b = maximum(3.4,5.2)
+
+# mix 1
+if (mix1("hi") != 101):
+ raise RuntimeError, ("mix1(const char*)")
+
+if (mix1(1.0, 1.0) != 102):
+ raise RuntimeError, ("mix1(double, const double &)")
+
+if (mix1(1.0) != 103):
+ raise RuntimeError, ("mix1(double)")
+
+# mix 2
+if (mix2("hi") != 101):
+ raise RuntimeError, ("mix2(const char*)")
+
+if (mix2(1.0, 1.0) != 102):
+ raise RuntimeError, ("mix2(double, const double &)")
+
+if (mix2(1.0) != 103):
+ raise RuntimeError, ("mix2(double)")
+
+# mix 3
+if (mix3("hi") != 101):
+ raise RuntimeError, ("mix3(const char*)")
+
+if (mix3(1.0, 1.0) != 102):
+ raise RuntimeError, ("mix3(double, const double &)")
+
+if (mix3(1.0) != 103):
+ raise RuntimeError, ("mix3(double)")
+
+# Combination 1
+if (overtparams1(100) != 10):
+ raise RuntimeError, ("overtparams1(int)")
+
+if (overtparams1(100.0, 100) != 20):
+ raise RuntimeError, ("overtparams1(double, int)")
+
+# Combination 2
+if (overtparams2(100.0, 100) != 40):
+ raise RuntimeError, ("overtparams2(double, int)")
+
+# Combination 3
+if (overloaded() != 60):
+ raise RuntimeError, ("overloaded()")
+
+if (overloaded(100.0, 100) != 70):
+ raise RuntimeError, ("overloaded(double, int)")
+
+# Combination 4
+if (overloadedagain("hello") != 80):
+ raise RuntimeError, ("overloadedagain(const char *)")
+
+if (overloadedagain() != 90):
+ raise RuntimeError, ("overloadedagain(double)")
+
+# specializations
+if (specialization(10) != 202):
+ raise RuntimeError, ("specialization(int)")
+
+if (specialization(10.0) != 203):
+ raise RuntimeError, ("specialization(double)")
+
+if (specialization(10, 10) != 204):
+ raise RuntimeError, ("specialization(int, int)")
+
+if (specialization(10.0, 10.0) != 205):
+ raise RuntimeError, ("specialization(double, double)")
+
+if (specialization("hi", "hi") != 201):
+ raise RuntimeError, ("specialization(const char *, const char *)")
+
+
+# simple specialization
+xyz()
+xyz_int()
+xyz_double()
+
+# a bit of everything
+if (overload("hi") != 0):
+ raise RuntimeError, ("overload()")
+
+if (overload(1) != 10):
+ raise RuntimeError, ("overload(int t)")
+
+if (overload(1, 1) != 20):
+ raise RuntimeError, ("overload(int t, const int &)")
+
+if (overload(1, "hello") != 30):
+ raise RuntimeError, ("overload(int t, const char *)")
+
+k = Klass()
+if (overload(k) != 10):
+ raise RuntimeError, ("overload(Klass t)")
+
+if (overload(k, k) != 20):
+ raise RuntimeError, ("overload(Klass t, const Klass &)")
+
+if (overload(k, "hello") != 30):
+ raise RuntimeError, ("overload(Klass t, const char *)")
+
+if (overload(10.0, "hi") != 40):
+ raise RuntimeError, ("overload(double t, const char *)")
+
+if (overload() != 50):
+ raise RuntimeError, ("overload(const char *)")
+
+
+# everything put in a namespace
+if (nsoverload("hi") != 1000):
+ raise RuntimeError, ("nsoverload()")
+
+if (nsoverload(1) != 1010):
+ raise RuntimeError, ("nsoverload(int t)")
+
+if (nsoverload(1, 1) != 1020):
+ raise RuntimeError, ("nsoverload(int t, const int &)")
+
+if (nsoverload(1, "hello") != 1030):
+ raise RuntimeError, ("nsoverload(int t, const char *)")
+
+if (nsoverload(k) != 1010):
+ raise RuntimeError, ("nsoverload(Klass t)")
+
+if (nsoverload(k, k) != 1020):
+ raise RuntimeError, ("nsoverload(Klass t, const Klass &)")
+
+if (nsoverload(k, "hello") != 1030):
+ raise RuntimeError, ("nsoverload(Klass t, const char *)")
+
+if (nsoverload(10.0, "hi") != 1040):
+ raise RuntimeError, ("nsoverload(double t, const char *)")
+
+if (nsoverload() != 1050):
+ raise RuntimeError, ("nsoverload(const char *)")
+
+
+A_foo(1)
+b = B()
+b.foo(1)
diff --git a/trunk/Examples/test-suite/python/preproc_runme.py b/trunk/Examples/test-suite/python/preproc_runme.py
new file mode 100644
index 000000000..c989294b6
--- /dev/null
+++ b/trunk/Examples/test-suite/python/preproc_runme.py
@@ -0,0 +1,14 @@
+import preproc
+
+if preproc.endif != 1:
+ raise RuntimeError
+
+if preproc.define != 1:
+ raise RuntimeError
+
+if preproc.defined != 1:
+ raise RuntimeError
+
+if 2*preproc.one != preproc.two:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/primitive_ref_runme.py b/trunk/Examples/test-suite/python/primitive_ref_runme.py
new file mode 100644
index 000000000..7ce872a62
--- /dev/null
+++ b/trunk/Examples/test-suite/python/primitive_ref_runme.py
@@ -0,0 +1,40 @@
+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
+
+if ref_over(0) != 0:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/primitive_types_runme.py b/trunk/Examples/test-suite/python/primitive_types_runme.py
new file mode 100644
index 000000000..02cc21763
--- /dev/null
+++ b/trunk/Examples/test-suite/python/primitive_types_runme.py
@@ -0,0 +1,353 @@
+from primitive_types import *
+
+var_init()
+
+# assigning globals calls
+cvar.var_bool = sct_bool
+cvar.var_schar = sct_schar
+cvar.var_uchar = sct_uchar
+cvar.var_int = sct_int
+cvar.var_uint = sct_uint
+cvar.var_short = sct_short
+cvar.var_ushort = sct_ushort
+cvar.var_long = sct_long
+cvar.var_ulong = sct_ulong
+cvar.var_llong = sct_llong
+cvar.var_ullong = sct_ullong
+cvar.var_char = sct_char
+cvar.var_pchar = sct_pchar
+cvar.var_pcharc = sct_pcharc
+cvar.var_pint = sct_pint
+cvar.var_sizet = sct_sizet
+cvar.var_hello = sct_hello
+cvar.var_myint = sct_myint
+cvar.var_namet = def_namet
+cvar.var_parami = sct_parami
+cvar.var_paramd = sct_paramd
+cvar.var_paramc = sct_paramc
+
+v_check()
+
+def pyerror(name, val, cte):
+ print "bad val/cte", name, val, cte
+ raise RuntimeError
+ pass
+
+if cvar.var_bool != cct_bool: pyerror("bool", cvar.var_bool, cct_bool)
+if cvar.var_schar != cct_schar: pyerror("schar", cvar.var_schar, cct_schar)
+if cvar.var_uchar != cct_uchar: pyerror("uchar", cvar.var_uchar, cct_uchar)
+if cvar.var_int != cct_int: pyerror("int", cvar.var_int, cct_int)
+if cvar.var_uint != cct_uint: pyerror("uint", cvar.var_uint, cct_uint)
+if cvar.var_short != cct_short: pyerror("short", cvar.var_short, cct_short)
+if cvar.var_ushort != cct_ushort: pyerror("ushort", cvar.var_ushort, cct_ushort)
+if cvar.var_long != cct_long: pyerror("long", cvar.var_long, cct_long)
+if cvar.var_ulong != cct_ulong: pyerror("ulong", cvar.var_ulong, cct_ulong)
+if cvar.var_llong != cct_llong: pyerror("llong", cvar.var_llong, cct_llong)
+if cvar.var_ullong != cct_ullong: pyerror("ullong", cvar.var_ullong, cct_ullong)
+if cvar.var_char != cct_char: pyerror("char", cvar.var_char, cct_char)
+if cvar.var_pchar != cct_pchar: pyerror("pchar", cvar.var_pchar, cct_pchar)
+if cvar.var_pcharc != cct_pcharc: pyerror("pchar", cvar.var_pcharc, cct_pcharc)
+if cvar.var_pint != cct_pint: pyerror("pint", cvar.var_pint, cct_pint)
+if cvar.var_sizet != cct_sizet: pyerror("sizet", cvar.var_sizet, cct_sizet)
+if cvar.var_hello != cct_hello: pyerror("hello", cvar.var_hello, cct_hello)
+if cvar.var_myint != cct_myint: pyerror("myint", cvar.var_myint, cct_myint)
+if cvar.var_namet != def_namet: pyerror("name", cvar.var_namet, def_namet)
+
+class PyTest (TestDirector):
+ def __init__(self):
+ TestDirector.__init__(self)
+ pass
+ def ident(self, x):
+ return x
+
+ def vval_bool(self, x): return self.ident(x)
+ def vval_schar(self, x): return self.ident(x)
+ def vval_uchar(self, x): return self.ident(x)
+ def vval_int(self, x): return self.ident(x)
+ def vval_uint(self, x): return self.ident(x)
+ def vval_short(self, x): return self.ident(x)
+ def vval_ushort(self, x): return self.ident(x)
+ def vval_long(self, x): return self.ident(x)
+ def vval_ulong(self, x): return self.ident(x)
+ def vval_llong(self, x): return self.ident(x)
+ def vval_ullong(self, x): return self.ident(x)
+ def vval_float(self, x): return self.ident(x)
+ def vval_double(self, x): return self.ident(x)
+ def vval_char(self, x): return self.ident(x)
+ def vval_pchar(self, x): return self.ident(x)
+ def vval_pcharc(self, x): return self.ident(x)
+ def vval_pint(self, x): return self.ident(x)
+ def vval_sizet(self, x): return self.ident(x)
+ def vval_hello(self, x): return self.ident(x)
+ def vval_myint(self, x): return self.ident(x)
+
+ def vref_bool(self, x): return self.ident(x)
+ def vref_schar(self, x): return self.ident(x)
+ def vref_uchar(self, x): return self.ident(x)
+ def vref_int(self, x): return self.ident(x)
+ def vref_uint(self, x): return self.ident(x)
+ def vref_short(self, x): return self.ident(x)
+ def vref_ushort(self, x): return self.ident(x)
+ def vref_long(self, x): return self.ident(x)
+ def vref_ulong(self, x): return self.ident(x)
+ def vref_llong(self, x): return self.ident(x)
+ def vref_ullong(self, x): return self.ident(x)
+ def vref_float(self, x): return self.ident(x)
+ def vref_double(self, x): return self.ident(x)
+ def vref_char(self, x): return self.ident(x)
+ def vref_pchar(self, x): return self.ident(x)
+ def vref_pcharc(self, x): return self.ident(x)
+ def vref_pint(self, x): return self.ident(x)
+ def vref_sizet(self, x): return self.ident(x)
+ def vref_hello(self, x): return self.ident(x)
+ def vref_myint(self, x): return self.ident(x)
+
+ pass
+
+
+t = Test()
+p = PyTest()
+
+
+# internal call check
+if t.c_check() != p.c_check():
+ raise RuntimeError, "bad director"
+
+p.var_bool = p.stc_bool
+p.var_schar = p.stc_schar
+p.var_uchar = p.stc_uchar
+p.var_int = p.stc_int
+p.var_uint = p.stc_uint
+p.var_short = p.stc_short
+p.var_ushort = p.stc_ushort
+p.var_long = p.stc_long
+p.var_ulong = p.stc_ulong
+p.var_llong = p.stc_llong
+p.var_ullong = p.stc_ullong
+p.var_char = p.stc_char
+p.var_pchar = sct_pchar
+p.var_pcharc = sct_pcharc
+p.var_pint = sct_pint
+p.var_sizet = sct_sizet
+p.var_hello = sct_hello
+p.var_myint = sct_myint
+p.var_namet = def_namet
+p.var_parami = sct_parami
+p.var_paramd = sct_paramd
+p.var_paramc = sct_paramc
+
+p.v_check()
+
+
+t.var_bool = t.stc_bool
+t.var_schar = t.stc_schar
+t.var_uchar = t.stc_uchar
+t.var_int = t.stc_int
+t.var_uint = t.stc_uint
+t.var_short = t.stc_short
+t.var_ushort = t.stc_ushort
+t.var_long = t.stc_long
+t.var_ulong = t.stc_ulong
+t.var_llong = t.stc_llong
+t.var_ullong = t.stc_ullong
+t.var_char = t.stc_char
+t.var_pchar = sct_pchar
+t.var_pcharc = sct_pcharc
+t.var_pint = sct_pint
+t.var_sizet = sct_sizet
+t.var_hello = sct_hello
+t.var_myint = sct_myint
+t.var_namet = def_namet
+t.var_parami = sct_parami
+t.var_paramd = sct_paramd
+t.var_paramc = sct_paramc
+
+t.v_check()
+
+# this value contains a '0' char!
+if def_namet != 'ho\0la':
+ print "bad namet", def_namet
+ raise RuntimeError
+
+t.var_namet = def_namet
+if t.var_namet != def_namet:
+ print "bad namet", t.var_namet, def_namet
+ raise RuntimeError
+
+t.var_namet = 'holac'
+
+if t.var_namet != 'holac':
+ print "bad namet", t.var_namet
+ raise RuntimeError
+
+t.var_namet = 'hol'
+
+if t.var_namet != 'hol':
+#if t.var_namet != 'hol\0\0':
+ print "bad namet", t.var_namet
+ raise RuntimeError
+
+
+if t.strlen('hile') != 4:
+ print t.strlen('hile')
+ raise RuntimeError, "bad string typemap"
+
+if t.strlen('hil\0') != 4:
+ raise RuntimeError, "bad string typemap"
+
+
+cvar.var_char = '\0'
+if cvar.var_char != '\0':
+ raise RuntimeError, "bad char '0' case"
+
+cvar.var_char = 0
+if cvar.var_char != '\0':
+ raise RuntimeError, "bad char '0' case"
+
+cvar.var_namet = '\0'
+#if cvar.var_namet != '\0\0\0\0\0':
+if cvar.var_namet != '':
+ print 'hola', '', cvar.var_namet
+ raise RuntimeError, "bad char '\0' case"
+
+cvar.var_namet = ''
+#if cvar.var_namet != '\0\0\0\0\0':
+if cvar.var_namet != '':
+ raise RuntimeError, "bad char empty case"
+
+cvar.var_pchar = None
+if cvar.var_pchar != None:
+ raise RuntimeError, "bad None case"
+
+cvar.var_pchar = ''
+if cvar.var_pchar != '':
+ print '%c' % (cvar.var_pchar[0],)
+ raise RuntimeError, "bad char empty case"
+
+cvar.var_pcharc = None
+if cvar.var_pcharc != None:
+ raise RuntimeError, "bad None case"
+
+cvar.var_pcharc = ''
+if cvar.var_pcharc != '':
+ raise RuntimeError, "bad char empty case"
+
+
+#
+# creating a raw char*
+#
+pc = new_pchar(5)
+pchar_setitem(pc, 0, 'h')
+pchar_setitem(pc, 1, 'o')
+pchar_setitem(pc, 2, 'l')
+pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 4, 0)
+
+
+if t.strlen(pc) != 4:
+ raise RuntimeError, "bad string typemap"
+
+cvar.var_pchar = pc
+if cvar.var_pchar != "hola":
+ print cvar.var_pchar
+ raise RuntimeError, "bad pointer case"
+
+cvar.var_namet = pc
+#if cvar.var_namet != "hola\0":
+if cvar.var_namet != "hola":
+ raise RuntimeError, "bad pointer case"
+
+delete_pchar(pc)
+
+#
+# Now when things should fail
+#
+
+
+try:
+ error = 0
+ a = t.var_uchar
+ t.var_uchar = 10000
+ error = 1
+except OverflowError:
+ if a != t.var_uchar:
+ error = 1
+ pass
+if error:
+ raise RuntimeError, "bad uchar typemap"
+
+
+
+try:
+ error = 0
+ a = t.var_char
+ t.var_char = '23'
+ error = 1
+except TypeError:
+ if a != t.var_char:
+ error = 1
+ pass
+if error:
+ raise RuntimeError, "bad char typemap"
+
+try:
+ error = 0
+ a = t.var_uint
+ t.var_uint = -1
+ error = 1
+except OverflowError:
+ if a != t.var_uint:
+ error = 1
+ pass
+if error:
+ raise RuntimeError, "bad uint typemap"
+
+#
+#
+try:
+ error = 0
+ a = t.var_namet
+ t.var_namet = '123456'
+ error = 1
+except TypeError:
+ if a != t.var_namet:
+ error = 1
+ pass
+if error:
+ raise RuntimeError, "bad namet typemap"
+
+#
+#
+#
+t2 = p.vtest(t)
+if t.var_namet != t2.var_namet:
+ raise RuntimeError, "bad SWIGTYPE* typemap"
+
+
+if cvar.fixsize != 'ho\0la\0\0\0':
+ raise RuntimeError, "bad FIXSIZE typemap"
+
+cvar.fixsize = 'ho'
+if cvar.fixsize != 'ho\0\0\0\0\0\0':
+ raise RuntimeError, "bad FIXSIZE typemap"
+
+
+f = Foo(3)
+f1 = fptr_val(f)
+f2 = fptr_ref(f)
+if f1._a != f2._a:
+ raise RuntimeError, "bad const ptr& typemap"
+
+
+v = char_foo(1,3)
+if v !=3:
+ raise RuntimeError, "bad int typemap"
+
+s = char_foo(1,"hello")
+if s !="hello":
+ raise RuntimeError, "bad char* typemap"
+
+
+v = SetPos(1,3)
+if v !=4:
+ raise RuntimeError, "bad int typemap"
diff --git a/trunk/Examples/test-suite/python/profiletest_runme.py b/trunk/Examples/test-suite/python/profiletest_runme.py
new file mode 100644
index 000000000..d4f07dc11
--- /dev/null
+++ b/trunk/Examples/test-suite/python/profiletest_runme.py
@@ -0,0 +1,32 @@
+import _profiletest
+import profiletest
+
+a = profiletest.A()
+print a
+print a.this
+
+b = profiletest.B()
+fn = b.fn
+i = 50000
+while i:
+ a = fn(a) #1
+ a = fn(a) #2
+ a = fn(a) #3
+ a = fn(a) #4
+ a = fn(a) #5
+ a = fn(a) #6
+ a = fn(a) #7
+ a = fn(a) #8
+ a = fn(a) #9
+ a = fn(a) #10
+ a = fn(a) #1
+ a = fn(a) #2
+ a = fn(a) #3
+ a = fn(a) #4
+ a = fn(a) #5
+ a = fn(a) #6
+ a = fn(a) #7
+ a = fn(a) #8
+ a = fn(a) #9
+ a = fn(a) #20
+ i -= 1
diff --git a/trunk/Examples/test-suite/python/profiletestc_runme.py b/trunk/Examples/test-suite/python/profiletestc_runme.py
new file mode 100644
index 000000000..33461e484
--- /dev/null
+++ b/trunk/Examples/test-suite/python/profiletestc_runme.py
@@ -0,0 +1,54 @@
+import _profiletest
+#import profiletest
+
+pa = _profiletest.new_A()
+pb = _profiletest.new_B()
+fn = _profiletest.B_fn
+destroy = _profiletest.delete_A
+i = 50000
+a = pa
+while i:
+ a = fn(pb,a) #1
+ destroy(a)
+ a = fn(pb,a) #2
+ destroy(a)
+ a = fn(pb,a) #3
+ destroy(a)
+ a = fn(pb,a) #4
+ destroy(a)
+ a = fn(pb,a) #5
+ destroy(a)
+ a = fn(pb,a) #6
+ destroy(a)
+ a = fn(pb,a) #7
+ destroy(a)
+ a = fn(pb,a) #8
+ destroy(a)
+ a = fn(pb,a) #9
+ destroy(a)
+ a = fn(pb,a) #10
+ destroy(a)
+ a = fn(pb,a) #1
+ destroy(a)
+ a = fn(pb,a) #2
+ destroy(a)
+ a = fn(pb,a) #3
+ destroy(a)
+ a = fn(pb,a) #4
+ destroy(a)
+ a = fn(pb,a) #5
+ destroy(a)
+ a = fn(pb,a) #6
+ destroy(a)
+ a = fn(pb,a) #7
+ destroy(a)
+ a = fn(pb,a) #8
+ destroy(a)
+ a = fn(pb,a) #9
+ destroy(a)
+ a = fn(pb,a) #20
+ destroy(a)
+ i -= 1
+
+_profiletest.delete_A(pa)
+_profiletest.delete_B(pb)
diff --git a/trunk/Examples/test-suite/python/python_abstractbase_runme3.py b/trunk/Examples/test-suite/python/python_abstractbase_runme3.py
new file mode 100644
index 000000000..e34777558
--- /dev/null
+++ b/trunk/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -0,0 +1,8 @@
+from python_abstractbase import *
+from collections import *
+assert issubclass(Mapii, MutableMapping)
+assert issubclass(Multimapii, MutableMapping)
+assert issubclass(IntSet, MutableSet)
+assert issubclass(IntMultiset, MutableSet)
+assert issubclass(IntVector, MutableSequence)
+assert issubclass(IntList, MutableSequence)
diff --git a/trunk/Examples/test-suite/python/python_append_runme.py b/trunk/Examples/test-suite/python/python_append_runme.py
new file mode 100644
index 000000000..c8e6b2640
--- /dev/null
+++ b/trunk/Examples/test-suite/python/python_append_runme.py
@@ -0,0 +1,4 @@
+from python_append import *
+t=Test()
+t.func()
+t.static_func()
diff --git a/trunk/Examples/test-suite/python/python_kwargs_runme.py b/trunk/Examples/test-suite/python/python_kwargs_runme.py
new file mode 100644
index 000000000..fb6e191dd
--- /dev/null
+++ b/trunk/Examples/test-suite/python/python_kwargs_runme.py
@@ -0,0 +1,67 @@
+from python_kwargs import *
+
+class MyFoo(Foo):
+ def __init__(self, a , b = 0):
+ Foo.__init__(self, a, b)
+
+
+
+# Simple class
+f1 = MyFoo(2)
+
+f = Foo(b=2,a=1)
+
+if f.foo(b=1,a=2) != 3:
+ raise RuntimeError
+
+if Foo_statfoo(b=2) != 3:
+ raise RuntimeError
+
+if f.efoo(b=2) != 3:
+ raise RuntimeError
+
+if Foo_sfoo(b=2) != 3:
+ raise RuntimeError
+
+
+# Templated class
+b = BarInt(b=2,a=1)
+
+if b.bar(b=1,a=2) != 3:
+ raise RuntimeError
+
+if BarInt_statbar(b=2) != 3:
+ raise RuntimeError
+
+if b.ebar(b=2) != 3:
+ raise RuntimeError
+
+if BarInt_sbar(b=2) != 3:
+ raise RuntimeError
+
+
+# Functions
+if templatedfunction(b=2) != 3:
+ raise RuntimeError
+
+if foo(a=1,b=2) != 3:
+ raise RuntimeError
+
+if foo(b=2) != 3:
+ raise RuntimeError
+
+
+#Funtions with keywords
+
+if foo_kw(_from=2) != 4:
+ raise RuntimeError
+
+if foo_nu(_from=2, arg2=3) != 2:
+ raise RuntimeError
+
+if foo_mm(min=2) != 4:
+ raise RuntimeError
+
+if foo_mm(max=3) != 4:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/python_nondynamic_runme.py b/trunk/Examples/test-suite/python/python_nondynamic_runme.py
new file mode 100644
index 000000000..27755db9c
--- /dev/null
+++ b/trunk/Examples/test-suite/python/python_nondynamic_runme.py
@@ -0,0 +1,39 @@
+import python_nondynamic
+
+aa = python_nondynamic.A()
+
+aa.a = 1
+aa.b = 2
+try:
+ aa.c = 2
+ err = 0
+except:
+ err = 1
+
+if not err:
+ raise RuntimeError, "A is not static"
+
+
+class B(python_nondynamic.A):
+ c = 4
+ def __init__(self):
+ python_nondynamic.A.__init__(self)
+ pass
+ pass
+
+
+
+bb = B()
+bb.c = 3
+try:
+ bb.d = 2
+ err = 0
+except:
+ err = 1
+
+if not err:
+ raise RuntimeError, "B is not static"
+
+
+cc = python_nondynamic.C()
+cc.d = 3
diff --git a/trunk/Examples/test-suite/python/python_overload_simple_cast_runme.py b/trunk/Examples/test-suite/python/python_overload_simple_cast_runme.py
new file mode 100644
index 000000000..1b3a5482c
--- /dev/null
+++ b/trunk/Examples/test-suite/python/python_overload_simple_cast_runme.py
@@ -0,0 +1,192 @@
+from python_overload_simple_cast import *
+
+class Ai:
+ def __init__(self,x):
+ self.x = x
+
+ def __int__(self):
+ return self.x
+
+class Ad:
+ def __init__(self,x):
+ self.x = x
+
+ def __float__(self):
+ return self.x
+
+ai = Ai(4)
+
+ad = Ad(5.0)
+add = Ad(5.5)
+
+try:
+ fint(add)
+ good = 0
+except:
+ good = 1
+
+if not good:
+ raise RuntimeError, "fint(int)"
+
+
+if fint(ad) != "fint:int":
+ raise RuntimeError, "fint(int)"
+
+if fdouble(ad) != "fdouble:double":
+ raise RuntimeError, "fdouble(double)"
+
+if fint(ai) != "fint:int":
+ raise RuntimeError, "fint(int)"
+
+if fint(5.0) != "fint:int":
+ raise RuntimeError, "fint(int)"
+
+if fint(3) != "fint:int":
+ raise RuntimeError, "fint(int)"
+if fint(3.0) != "fint:int":
+ raise RuntimeError, "fint(int)"
+
+if fdouble(ad) != "fdouble:double":
+ raise RuntimeError, "fdouble(double)"
+if fdouble(3) != "fdouble:double":
+ raise RuntimeError, "fdouble(double)"
+if fdouble(3.0) != "fdouble:double":
+ raise RuntimeError, "fdouble(double)"
+
+if fid(3,3.0) != "fid:intdouble":
+ raise RuntimeError, "fid:intdouble"
+
+if fid(3.0,3) != "fid:doubleint":
+ raise RuntimeError, "fid:doubleint"
+
+if fid(ad,ai) != "fid:doubleint":
+ raise RuntimeError, "fid:doubleint"
+
+if fid(ai,ad) != "fid:intdouble":
+ raise RuntimeError, "fid:intdouble"
+
+
+
+if foo(3) != "foo:int":
+ raise RuntimeError, "foo(int)"
+
+if foo(3.0) != "foo:double":
+ raise RuntimeError, "foo(double)"
+
+if foo("hello") != "foo:char *":
+ raise RuntimeError, "foo(char *)"
+
+f = Foo()
+b = Bar()
+
+if foo(f) != "foo:Foo *":
+ raise RuntimeError, "foo(Foo *)"
+
+if foo(b) != "foo:Bar *":
+ raise RuntimeError, "foo(Bar *)"
+
+v = malloc_void(32)
+
+if foo(v) != "foo:void *":
+ raise RuntimeError, "foo(void *)"
+
+s = Spam()
+
+if s.foo(3) != "foo:int":
+ raise RuntimeError, "Spam::foo(int)"
+
+if s.foo(3.0) != "foo:double":
+ raise RuntimeError, "Spam::foo(double)"
+
+if s.foo("hello") != "foo:char *":
+ raise RuntimeError, "Spam::foo(char *)"
+
+if s.foo(f) != "foo:Foo *":
+ raise RuntimeError, "Spam::foo(Foo *)"
+
+if s.foo(b) != "foo:Bar *":
+ raise RuntimeError, "Spam::foo(Bar *)"
+
+if s.foo(v) != "foo:void *":
+ raise RuntimeError, "Spam::foo(void *)"
+
+if Spam_bar(3) != "bar:int":
+ raise RuntimeError, "Spam::bar(int)"
+
+if Spam_bar(3.0) != "bar:double":
+ raise RuntimeError, "Spam::bar(double)"
+
+if Spam_bar("hello") != "bar:char *":
+ raise RuntimeError, "Spam::bar(char *)"
+
+if Spam_bar(f) != "bar:Foo *":
+ raise RuntimeError, "Spam::bar(Foo *)"
+
+if Spam_bar(b) != "bar:Bar *":
+ raise RuntimeError, "Spam::bar(Bar *)"
+
+if Spam_bar(v) != "bar:void *":
+ raise RuntimeError, "Spam::bar(void *)"
+
+# Test constructors
+
+s = Spam()
+if s.type != "none":
+ raise RuntimeError, "Spam()"
+
+s = Spam(3)
+if s.type != "int":
+ raise RuntimeError, "Spam(int)"
+
+s = Spam(3.4)
+if s.type != "double":
+ raise RuntimeError, "Spam(double)"
+
+s = Spam("hello")
+if s.type != "char *":
+ raise RuntimeError, "Spam(char *)"
+
+s = Spam(f)
+if s.type != "Foo *":
+ raise RuntimeError, "Spam(Foo *)"
+
+s = Spam(b)
+if s.type != "Bar *":
+ raise RuntimeError, "Spam(Bar *)"
+
+s = Spam(v)
+if s.type != "void *":
+ raise RuntimeError, "Spam(void *)"
+
+
+# unsigned long long
+ullmax = 9223372036854775807 #0xffffffffffffffff
+ullmaxd = 9007199254740992.0
+ullmin = 0
+ullmind = 0.0
+if ull(ullmin) != ullmin:
+ raise runtimeerror, "ull(ullmin)"
+if ull(ullmax) != ullmax:
+ raise runtimeerror, "ull(ullmax)"
+if ull(ullmind) != ullmind:
+ raise RuntimeError, "ull(ullmind)"
+if ull(ullmaxd) != ullmaxd:
+ raise RuntimeError, "ull(ullmaxd)"
+
+# long long
+llmax = 9223372036854775807 #0x7fffffffffffffff
+llmin = -9223372036854775808
+# these are near the largest floats we can still convert into long long
+llmaxd = 9007199254740992.0
+llmind = -9007199254740992.0
+if ll(llmin) != llmin:
+ raise runtimeerror, "ll(llmin)"
+if ll(llmax) != llmax:
+ raise runtimeerror, "ll(llmax)"
+if ll(llmind) != llmind:
+ raise RuntimeError, "ll(llmind)"
+if ll(llmaxd) != llmaxd:
+ raise RuntimeError, "ll(llmaxd)"
+
+
+free_void(v)
diff --git a/trunk/Examples/test-suite/python/python_pybuf_runme3.py b/trunk/Examples/test-suite/python/python_pybuf_runme3.py
new file mode 100644
index 000000000..152aecdc0
--- /dev/null
+++ b/trunk/Examples/test-suite/python/python_pybuf_runme3.py
@@ -0,0 +1,42 @@
+#run:
+# python python_pybuf_runme3.py benchmark
+#for the benchmark, other wise the test case will be run
+import python_pybuf
+import sys
+if len(sys.argv)>=2 and sys.argv[1]=="benchmark":
+ #run the benchmark
+ import time
+ k=1000000 #number of times to excute the functions
+
+ t=time.time()
+ a = bytearray(b'hello world')
+ for i in range(k):
+ pybuf.title1(a)
+ print("Time used by bytearray:",time.time()-t)
+
+ t=time.time()
+ b = 'hello world'
+ for i in range(k):
+ pybuf.title2(b)
+ print("Time used by string:",time.time()-t)
+else:
+ #run the test case
+ buf1 = bytearray(10)
+ buf2 = bytearray(50)
+
+ pybuf.func1(buf1)
+ assert buf1 == b'a'*10
+
+ pybuf.func2(buf2)
+ assert buf2.startswith(b"Hello world!\x00")
+
+ count = pybuf.func3(buf2)
+ assert count==10 #number of alpha and number in 'Hello world!'
+
+ length = pybuf.func4(buf2)
+ assert length==12
+
+ buf3 = bytearray(b"hello")
+ pybuf.title1(buf3)
+ assert buf3==b'Hello'
+
diff --git a/trunk/Examples/test-suite/python/pythonswig.supp b/trunk/Examples/test-suite/python/pythonswig.supp
new file mode 100644
index 000000000..a9b03afc9
--- /dev/null
+++ b/trunk/Examples/test-suite/python/pythonswig.supp
@@ -0,0 +1,463 @@
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:_Z21SWIG_AsCharPtrAndSizeP7_objectPPcPmPi
+ fun:var_pcharc_set
+ fun:swig_varlink_setattr
+ fun:PyObject_SetAttr
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:var_pchar_set
+ fun:swig_varlink_setattr
+ fun:PyObject_SetAttr
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:_wrap_Test_var_pcharc_set
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:function_call
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+ fun:instance_setattr
+ fun:PyObject_SetAttr
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:_wrap_TestDirector_var_pcharc_set
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:function_call
+ fun:PyObject_Call
+ fun:instancemethod_call
+ fun:PyObject_Call
+ fun:call_method
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:_Z21SWIG_AsCharPtrAndSizeP7_objectPPcPmPi
+ fun:var_pcharc_set
+ fun:swig_varlink_setattr
+ fun:PyObject_SetAttr
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:_wrap_Test_var_pchar_set
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:function_call
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+ fun:instance_setattr
+ fun:PyObject_SetAttr
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znam
+ fun:_wrap_TestDirector_var_pchar_set
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:function_call
+ fun:PyObject_Call
+ fun:instancemethod_call
+ fun:PyObject_Call
+ fun:call_method
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:SWIG_Python_newvarlink
+ fun:SWIG_globals
+ fun:init_primitive_types
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:SWIG_Python_addvarlink
+ fun:init_primitive_types
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:PyFloat_FromDouble
+ fun:init_primitive_types
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:SWIG_Python_addvarlink
+ fun:init_primitive_types
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:realloc
+ fun:_PyString_Resize
+ fun:jcompile
+ fun:com_funcdef
+ fun:com_node
+ fun:com_node
+ fun:compile_node
+ fun:jcompile
+ fun:com_classdef
+ fun:com_node
+ fun:compile_node
+ fun:jcompile
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:_PyObject_GC_New
+ fun:PyDict_New
+ fun:PyModule_New
+ fun:PyImport_AddModule
+ fun:Py_InitModule4
+ fun:_PyExc_Init
+ fun:Py_InitializeEx
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z21createref_signed_chara
+ fun:_wrap_createref_signed_char
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z23createref_unsigned_charh
+ fun:_wrap_createref_unsigned_char
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z14createref_charc
+ fun:_wrap_createref_char
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z24createref_unsigned_shortt
+ fun:_wrap_createref_unsigned_short
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z15createref_shorts
+ fun:_wrap_createref_short
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z14createref_boolb
+ fun:_wrap_createref_bool
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z19createref_TestClass9TestClass
+ fun:_wrap_createref_TestClass
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z15createref_floatf
+ fun:_wrap_createref_float
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z22createref_unsigned_intj
+ fun:_wrap_createref_unsigned_int
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z13createref_inti
+ fun:_wrap_createref_int
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z16createref_doubled
+ fun:_wrap_createref_double
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z28createref_unsigned_long_longy
+ fun:_wrap_createref_unsigned_long_long
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z19createref_long_longx
+ fun:_wrap_createref_long_long
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z23createref_unsigned_longm
+ fun:_wrap_createref_unsigned_long
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_Z14createref_longl
+ fun:_wrap_createref_long
+ fun:PyEval_EvalFrame
+ fun:PyEval_EvalCodeEx
+ fun:PyEval_EvalCode
+ fun:PyRun_FileExFlags
+ fun:PyRun_SimpleFileExFlags
+ fun:Py_Main
+ fun:__libc_start_main
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:SWIG_Python_newvarlink
+ fun:SWIG_globals
+ fun:init_reference_global_vars
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:SWIG_Python_addvarlink
+ fun:init_reference_global_vars
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc
+ fun:SWIG_Python_addvarlink
+ fun:init_reference_global_vars
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+ fun:builtin___import__
+ fun:PyObject_Call
+ fun:PyEval_CallObjectWithKeywords
+}
diff --git a/trunk/Examples/test-suite/python/refcount_runme.py b/trunk/Examples/test-suite/python/refcount_runme.py
new file mode 100644
index 000000000..b429404e7
--- /dev/null
+++ b/trunk/Examples/test-suite/python/refcount_runme.py
@@ -0,0 +1,32 @@
+from refcount import *
+#
+# very innocent example
+#
+
+a = A3()
+b1 = B(a)
+b2 = B.create(a)
+
+
+
+if a.ref_count() != 3:
+ print "This program will crash... now"
+
+
+rca = b2.get_rca()
+b3 = B.create(rca)
+
+if a.ref_count() != 5:
+ print "This program will crash... now"
+
+
+v = vector_A(2)
+v[0] = a
+v[1] = a
+
+x = v[0]
+del v
+
+
+
+
diff --git a/trunk/Examples/test-suite/python/reference_global_vars_runme.py b/trunk/Examples/test-suite/python/reference_global_vars_runme.py
new file mode 100644
index 000000000..aa42ff50b
--- /dev/null
+++ b/trunk/Examples/test-suite/python/reference_global_vars_runme.py
@@ -0,0 +1,74 @@
+from reference_global_vars import *
+
+# const class reference variable
+if getconstTC().num != 33:
+ raise RuntimeError
+
+# primitive reference variables
+cvar.var_bool = createref_bool(0)
+if value_bool(cvar.var_bool) != 0:
+ raise RuntimeError
+
+cvar.var_bool = createref_bool(1)
+if value_bool(cvar.var_bool) != 1:
+ raise RuntimeError
+
+cvar.var_char = createref_char('w')
+if value_char(cvar.var_char) != 'w':
+ raise RuntimeError
+
+cvar.var_unsigned_char = createref_unsigned_char(10)
+if value_unsigned_char(cvar.var_unsigned_char) != 10:
+ raise RuntimeError
+
+cvar.var_signed_char = createref_signed_char(10)
+if value_signed_char(cvar.var_signed_char) != 10:
+ raise RuntimeError
+
+cvar.var_short = createref_short(10)
+if value_short(cvar.var_short) != 10:
+ raise RuntimeError
+
+cvar.var_unsigned_short = createref_unsigned_short(10)
+if value_unsigned_short(cvar.var_unsigned_short) != 10:
+ raise RuntimeError
+
+cvar.var_int = createref_int(10)
+if value_int(cvar.var_int) != 10:
+ raise RuntimeError
+
+cvar.var_unsigned_int = createref_unsigned_int(10)
+if value_unsigned_int(cvar.var_unsigned_int) != 10:
+ raise RuntimeError
+
+cvar.var_long = createref_long(10)
+if value_long(cvar.var_long) != 10:
+ raise RuntimeError
+
+cvar.var_unsigned_long = createref_unsigned_long(10)
+if value_unsigned_long(cvar.var_unsigned_long) != 10:
+ raise RuntimeError
+
+cvar.var_long_long = createref_long_long(0x6FFFFFFFFFFFFFF8)
+if value_long_long(cvar.var_long_long) != 0x6FFFFFFFFFFFFFF8:
+ raise RuntimeError
+
+#ull = abs(0xFFFFFFF2FFFFFFF0)
+ull = 55834574864
+cvar.var_unsigned_long_long = createref_unsigned_long_long(ull)
+if value_unsigned_long_long(cvar.var_unsigned_long_long) != ull:
+ raise RuntimeError
+
+cvar.var_float = createref_float(10.5)
+if value_float(cvar.var_float) != 10.5:
+ raise RuntimeError
+
+cvar.var_double = createref_double(10.5)
+if value_double(cvar.var_double) != 10.5:
+ raise RuntimeError
+
+# class reference variable
+cvar.var_TestClass = createref_TestClass(TestClass(20))
+if value_TestClass(cvar.var_TestClass).num != 20:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/rename_scope_runme.py b/trunk/Examples/test-suite/python/rename_scope_runme.py
new file mode 100644
index 000000000..faea6a84d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/rename_scope_runme.py
@@ -0,0 +1,12 @@
+from rename_scope import *
+
+a = Natural_UP()
+b = Natural_BP()
+
+if a.rtest() != 1:
+ raise RuntimeError
+
+if b.rtest() != 1:
+ raise RuntimeError
+
+f = equals
diff --git a/trunk/Examples/test-suite/python/rename_strip_encoder_runme.py b/trunk/Examples/test-suite/python/rename_strip_encoder_runme.py
new file mode 100644
index 000000000..64be611d6
--- /dev/null
+++ b/trunk/Examples/test-suite/python/rename_strip_encoder_runme.py
@@ -0,0 +1,6 @@
+from rename_strip_encoder import *
+
+s = SomeWidget()
+a = AnotherWidget()
+a.DoSomething()
+
diff --git a/trunk/Examples/test-suite/python/ret_by_value_runme.py b/trunk/Examples/test-suite/python/ret_by_value_runme.py
new file mode 100644
index 000000000..0b2d7fd86
--- /dev/null
+++ b/trunk/Examples/test-suite/python/ret_by_value_runme.py
@@ -0,0 +1,8 @@
+import ret_by_value
+
+a = ret_by_value.get_test()
+if a.myInt != 100:
+ raise RuntimeError
+
+if a.myShort != 200:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/return_const_value_runme.py b/trunk/Examples/test-suite/python/return_const_value_runme.py
new file mode 100644
index 000000000..516e9f5d9
--- /dev/null
+++ b/trunk/Examples/test-suite/python/return_const_value_runme.py
@@ -0,0 +1,12 @@
+import return_const_value
+import sys
+
+p = return_const_value.Foo_ptr.getPtr()
+if (p.getVal() != 17):
+ print "Runtime test1 faild. p.getVal()=", p.getVal()
+ sys.exit(1)
+
+p = return_const_value.Foo_ptr.getConstPtr()
+if (p.getVal() != 17):
+ print "Runtime test2 faild. p.getVal()=", p.getVal()
+ sys.exit(1)
diff --git a/trunk/Examples/test-suite/python/smart_pointer_extend_runme.py b/trunk/Examples/test-suite/python/smart_pointer_extend_runme.py
new file mode 100644
index 000000000..969757b4c
--- /dev/null
+++ b/trunk/Examples/test-suite/python/smart_pointer_extend_runme.py
@@ -0,0 +1,34 @@
+from smart_pointer_extend import *
+
+f = Foo()
+b = Bar(f)
+
+if b.extension() != f.extension():
+ raise RuntimeError
+
+
+b = CBase()
+d = CDerived()
+p = CPtr()
+
+if b.bar() != p.bar():
+ raise RuntimeError
+
+if d.foo() != p.foo():
+ raise RuntimeError
+
+if b.hello() != p.hello():
+ raise RuntimeError
+
+
+
+d = DFoo()
+
+dp = DPtrFoo(d)
+
+if d.SExt(1) != dp.SExt(1):
+ raise RuntimeError
+
+if d.Ext(1) != dp.Ext(1):
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/smart_pointer_member_runme.py b/trunk/Examples/test-suite/python/smart_pointer_member_runme.py
new file mode 100644
index 000000000..70e655652
--- /dev/null
+++ b/trunk/Examples/test-suite/python/smart_pointer_member_runme.py
@@ -0,0 +1,30 @@
+from smart_pointer_member import *
+
+f = Foo()
+f.y = 1
+
+if f.y != 1:
+ raise RuntimeError
+
+b = Bar(f)
+b.y = 2
+
+if f.y != 2:
+ print f.y
+ print b.y
+ raise RuntimeError
+
+if b.x != f.x:
+ raise RuntimeError
+
+if b.z != f.z:
+ raise RuntimeError
+
+if Foo.z == Bar.z:
+ raise RuntimeError
+
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/python/smart_pointer_multi_runme.py b/trunk/Examples/test-suite/python/smart_pointer_multi_runme.py
new file mode 100644
index 000000000..c17053055
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py b/trunk/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py
new file mode 100644
index 000000000..ebf4c9b09
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/smart_pointer_not_runme.py b/trunk/Examples/test-suite/python/smart_pointer_not_runme.py
new file mode 100644
index 000000000..4c90b376b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/smart_pointer_overload_runme.py b/trunk/Examples/test-suite/python/smart_pointer_overload_runme.py
new file mode 100644
index 000000000..c9fd3a5b0
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/smart_pointer_rename_runme.py b/trunk/Examples/test-suite/python/smart_pointer_rename_runme.py
new file mode 100644
index 000000000..c6d22273c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/smart_pointer_simple_runme.py b/trunk/Examples/test-suite/python/smart_pointer_simple_runme.py
new file mode 100644
index 000000000..95b678aae
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/smart_pointer_templatevariables_runme.py b/trunk/Examples/test-suite/python/smart_pointer_templatevariables_runme.py
new file mode 100644
index 000000000..367dcf3b2
--- /dev/null
+++ b/trunk/Examples/test-suite/python/smart_pointer_templatevariables_runme.py
@@ -0,0 +1,17 @@
+from smart_pointer_templatevariables import *
+
+d = DiffImContainerPtr_D(create(1234, 5678))
+
+if (d.id != 1234):
+ raise RuntimeError
+#if (d.xyz != 5678):
+# raise RuntimeError
+
+d.id = 4321
+#d.xyz = 8765
+
+if (d.id != 4321):
+ raise RuntimeError
+#if (d.xyz != 8765):
+# raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/smart_pointer_typedef_runme.py b/trunk/Examples/test-suite/python/smart_pointer_typedef_runme.py
new file mode 100644
index 000000000..eee0537f4
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/sneaky1_runme.py b/trunk/Examples/test-suite/python/sneaky1_runme.py
new file mode 100644
index 000000000..9c2c32f85
--- /dev/null
+++ b/trunk/Examples/test-suite/python/sneaky1_runme.py
@@ -0,0 +1,5 @@
+import sneaky1
+x = sneaky1.add(3,4)
+y = sneaky1.subtract(3,4)
+z = sneaky1.mul(3,4)
+w = sneaky1.divide(3,4)
diff --git a/trunk/Examples/test-suite/python/special_variable_macros_runme.py b/trunk/Examples/test-suite/python/special_variable_macros_runme.py
new file mode 100644
index 000000000..07e60dfa2
--- /dev/null
+++ b/trunk/Examples/test-suite/python/special_variable_macros_runme.py
@@ -0,0 +1,16 @@
+import special_variable_macros
+
+name = special_variable_macros.Name()
+if special_variable_macros.testFred(name) != "none":
+ raise "test failed"
+if special_variable_macros.testJack(name) != "$specialname":
+ raise "test failed"
+if special_variable_macros.testJill(name) != "jilly":
+ raise "test failed"
+if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
+ raise "test failed"
+if special_variable_macros.testJim(name) != "multiname num":
+ raise "test failed"
+if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123:
+ raise "test failed"
+
diff --git a/trunk/Examples/test-suite/python/static_const_member_2_runme.py b/trunk/Examples/test-suite/python/static_const_member_2_runme.py
new file mode 100644
index 000000000..081726361
--- /dev/null
+++ b/trunk/Examples/test-suite/python/static_const_member_2_runme.py
@@ -0,0 +1,16 @@
+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:
+ raise RuntimeError
+
+
+if Foo.BAZ.val != 2*Foo.BAR.val:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/std_containers_runme.py b/trunk/Examples/test-suite/python/std_containers_runme.py
new file mode 100644
index 000000000..bed59bb29
--- /dev/null
+++ b/trunk/Examples/test-suite/python/std_containers_runme.py
@@ -0,0 +1,119 @@
+import sys
+import std_containers
+
+
+cube = (((1, 2), (3, 4)), ((5, 6), (7, 8)))
+
+icube = std_containers.cident(cube)
+for i in range(0,len(cube)):
+ if cube[i] != icube[i]:
+ raise RuntimeError, "bad cident"
+
+
+p = (1,2)
+if p != std_containers.pident(p):
+ raise RuntimeError, "bad pident"
+
+v = (1,2,3,4,5,6)
+iv = std_containers.vident(v)
+for i in range(0,len(v)):
+ if v[i] != iv[i]:
+ raise RuntimeError, "bad vident"
+
+
+
+iv = std_containers.videntu(v)
+for i in range(0,len(v)):
+ if v[i] != iv[i]:
+ raise RuntimeError, "bad videntu"
+
+
+vu = std_containers.vector_ui(v)
+if vu[2] != std_containers.videntu(vu)[2]:
+ raise RuntimeError, "bad videntu"
+
+
+if v[0:3][1] != vu[0:3][1]:
+ print v[0:3][1], vu[0:3][1]
+ raise RuntimeError, "bad getslice"
+
+
+m = ((1,2,3),(2,3),(3,4))
+im = std_containers.midenti(m)
+
+for i in range(0,len(m)):
+ for j in range(0,len(m[i])):
+ if m[i][j] != im[i][j]:
+ raise RuntimeError, "bad getslice"
+
+m = ((1,0,1),(1,1),(1,1))
+im = std_containers.midentb(m)
+for i in range(0,len(m)):
+ for j in range(0,len(m[i])):
+ if m[i][j] != im[i][j]:
+ raise RuntimeError, "bad getslice"
+
+
+mi = std_containers.imatrix(m)
+mc = std_containers.cmatrix(m)
+if mi[0][1] != mc[0][1]:
+ raise RuntimeError, "bad matrix"
+
+
+map ={}
+map['hello'] = 1
+map['hi'] = 2
+map['3'] = 2
+
+imap = std_containers.mapident(map)
+for k in map:
+ if map[k] != imap[k]:
+ raise RuntimeError, "bad map"
+
+
+mapc ={}
+c1 = std_containers.C()
+c2 = std_containers.C()
+mapc[1] = c1.this
+mapc[2] = c2
+
+std_containers.mapidentc(mapc)
+
+
+vi = std_containers.vector_i((2,2,3,4))
+
+
+v = (1,2)
+v1 = std_containers.v_inout(vi)
+vi[1], v1[1]
+
+v1,v2 = ((1,2),(3,4))
+v1,v2 = std_containers.v_inout2(v1,v2)
+
+a1 = std_containers.A(1)
+a2 = std_containers.A(2)
+
+p1 = (1,a1)
+p2 = (2,a2)
+v = (p1,p2)
+v2= std_containers.pia_vident(v)
+
+v2[0][1].a
+v2[1][1].a
+
+v3 = std_containers.vector_piA(v2)
+
+v3[0][1].a
+v3[1][1].a
+
+s = std_containers.set_i()
+s.append(1)
+s.append(2)
+s.append(3)
+j=1
+for i in s:
+ if i != j:
+ raise RuntimeError
+ j = j + 1
+
+
diff --git a/trunk/Examples/test-suite/python/struct_initialization_runme.py b/trunk/Examples/test-suite/python/struct_initialization_runme.py
new file mode 100644
index 000000000..fbed6a5e9
--- /dev/null
+++ b/trunk/Examples/test-suite/python/struct_initialization_runme.py
@@ -0,0 +1,20 @@
+from struct_initialization import *
+
+if cvar.instanceC1.x != 10:
+ raise RuntimeError
+
+if cvar.instanceD1.x != 10:
+ raise RuntimeError
+
+if cvar.instanceD2.x != 20:
+ raise RuntimeError
+
+if cvar.instanceD3.x != 30:
+ raise RuntimeError
+
+if cvar.instanceE1.x != 1:
+ raise RuntimeError
+
+if cvar.instanceF1.x != 1:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/struct_rename_runme.py b/trunk/Examples/test-suite/python/struct_rename_runme.py
new file mode 100644
index 000000000..880c41639
--- /dev/null
+++ b/trunk/Examples/test-suite/python/struct_rename_runme.py
@@ -0,0 +1,3 @@
+import struct_rename
+
+b = struct_rename.Bar()
diff --git a/trunk/Examples/test-suite/python/struct_value_runme.py b/trunk/Examples/test-suite/python/struct_value_runme.py
new file mode 100644
index 000000000..727996f53
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/swigobject_runme.py b/trunk/Examples/test-suite/python/swigobject_runme.py
new file mode 100644
index 000000000..a906108e3
--- /dev/null
+++ b/trunk/Examples/test-suite/python/swigobject_runme.py
@@ -0,0 +1,34 @@
+
+from swigobject import *
+
+a = A()
+
+
+a1 = a_ptr(a)
+a2 = a_ptr(a)
+
+if a1.this != a2.this:
+ raise RuntimeError
+
+
+lthis = long(a.this)
+# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p
+xstr1 = "%016X" % (lthis,)
+xstr1 = str.lstrip(xstr1, '0')
+xstr2 = pointer_str(a)
+xstr2 = str.replace(xstr2, "0x", "")
+xstr2 = str.replace(xstr2, "0X", "")
+xstr2 = str.lstrip(xstr2, '0')
+xstr2 = str.upper(xstr2)
+
+if xstr1 != xstr2:
+ print xstr1, xstr2
+ raise RuntimeError
+
+s = str(a.this)
+r = repr(a.this)
+
+v1 = v_ptr(a)
+v2 = v_ptr(a)
+if long(v1) != long(v2):
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/template_construct_runme.py b/trunk/Examples/test-suite/python/template_construct_runme.py
new file mode 100644
index 000000000..3409fdd62
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_construct_runme.py
@@ -0,0 +1 @@
+import template_construct
diff --git a/trunk/Examples/test-suite/python/template_default_arg_runme.py b/trunk/Examples/test-suite/python/template_default_arg_runme.py
new file mode 100644
index 000000000..235a2313a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_default_arg_runme.py
@@ -0,0 +1,98 @@
+import template_default_arg
+
+
+helloInt = template_default_arg.Hello_int()
+helloInt.foo(template_default_arg.Hello_int.hi)
+
+
+x = template_default_arg.X_int()
+if (x.meth(20.0, 200) != 200):
+ raise RuntimeError, ("X_int test 1 failed")
+if (x.meth(20) != 20):
+ raise RuntimeError, ("X_int test 2 failed")
+if (x.meth() != 0):
+ raise RuntimeError, ("X_int test 3 failed")
+
+
+
+y = template_default_arg.Y_unsigned()
+if (y.meth(20.0, 200) != 200):
+ raise RuntimeError, ("Y_unsigned test 1 failed")
+if (y.meth(20) != 20):
+ raise RuntimeError, ("Y_unsigned test 2 failed")
+if (y.meth() != 0):
+ raise RuntimeError, ("Y_unsigned test 3 failed")
+
+
+
+x = template_default_arg.X_longlong()
+x = template_default_arg.X_longlong(20.0)
+x = template_default_arg.X_longlong(20.0, 200L)
+
+
+x = template_default_arg.X_int()
+x = template_default_arg.X_int(20.0)
+x = template_default_arg.X_int(20.0, 200)
+
+
+x = template_default_arg.X_hello_unsigned()
+x = template_default_arg.X_hello_unsigned(20.0)
+x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int())
+
+
+y = template_default_arg.Y_hello_unsigned()
+y.meth(20.0, template_default_arg.Hello_int())
+y.meth(template_default_arg.Hello_int())
+y.meth()
+
+
+
+fz = template_default_arg.Foo_Z_8()
+x = template_default_arg.X_Foo_Z_8()
+fzc = x.meth(fz)
+
+
+# Templated functions
+
+# plain function: int ott(Foo<int>)
+if (template_default_arg.ott(template_default_arg.Foo_int()) != 30):
+ raise RuntimeError, ("ott test 1 failed")
+
+# %template(ott) ott<int, int>
+if (template_default_arg.ott() != 10):
+ raise RuntimeError, ("ott test 2 failed")
+if (template_default_arg.ott(1) != 10):
+ raise RuntimeError, ("ott test 3 failed")
+if (template_default_arg.ott(1, 1) != 10):
+ raise RuntimeError, ("ott test 4 failed")
+
+if (template_default_arg.ott("hi") != 20):
+ raise RuntimeError, ("ott test 5 failed")
+if (template_default_arg.ott("hi", 1) != 20):
+ raise RuntimeError, ("ott test 6 failed")
+if (template_default_arg.ott("hi", 1, 1) != 20):
+ raise RuntimeError, ("ott test 7 failed")
+
+# %template(ott) ott<const char *>
+if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40):
+ raise RuntimeError, ("ott test 8 failed")
+
+if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40):
+ raise RuntimeError, ("ott test 9 failed")
+
+# %template(ott) ott<int>
+if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50):
+ raise RuntimeError, ("ott test 10 failed")
+
+if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50):
+ raise RuntimeError, ("ott test 11 failed")
+
+# %template(ott) ott<double>
+if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60):
+ raise RuntimeError, ("ott test 12 failed")
+
+if (template_default_arg.ott(template_default_arg.Hello_int()) != 60):
+ raise RuntimeError, ("ott test 13 failed")
+
+
+
diff --git a/trunk/Examples/test-suite/python/template_extend1_runme.py b/trunk/Examples/test-suite/python/template_extend1_runme.py
new file mode 100644
index 000000000..b4679513a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_extend1_runme.py
@@ -0,0 +1,10 @@
+import template_extend1
+
+a = template_extend1.lBaz()
+b = template_extend1.dBaz()
+
+if a.foo() != "lBaz::foo":
+ raise RuntimeError
+
+if b.foo() != "dBaz::foo":
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/template_extend2_runme.py b/trunk/Examples/test-suite/python/template_extend2_runme.py
new file mode 100644
index 000000000..a5f222fb6
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_extend2_runme.py
@@ -0,0 +1,10 @@
+import template_extend2
+
+a = template_extend2.lBaz()
+b = template_extend2.dBaz()
+
+if a.foo() != "lBaz::foo":
+ raise RuntimeError
+
+if b.foo() != "dBaz::foo":
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/template_inherit_runme.py b/trunk/Examples/test-suite/python/template_inherit_runme.py
new file mode 100644
index 000000000..bb1465a2b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_matrix_runme.py b/trunk/Examples/test-suite/python/template_matrix_runme.py
new file mode 100644
index 000000000..95815a068
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_matrix_runme.py
@@ -0,0 +1,6 @@
+from template_matrix import *
+passVector([1,2,3])
+passMatrix([[1,2],[1,2,3]])
+passCube([[[1,2],[1,2,3]],[[1,2],[1,2,3]]])
+
+
diff --git a/trunk/Examples/test-suite/python/template_ns4_runme.py b/trunk/Examples/test-suite/python/template_ns4_runme.py
new file mode 100644
index 000000000..81107b493
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_ns_runme.py b/trunk/Examples/test-suite/python/template_ns_runme.py
new file mode 100644
index 000000000..20cc9b99c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_opaque_runme.py b/trunk/Examples/test-suite/python/template_opaque_runme.py
new file mode 100644
index 000000000..f3aeb39d1
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_opaque_runme.py
@@ -0,0 +1,6 @@
+import template_opaque
+
+v = template_opaque.OpaqueVectorType(10)
+
+template_opaque.FillVector(v)
+
diff --git a/trunk/Examples/test-suite/python/template_ref_type_runme.py b/trunk/Examples/test-suite/python/template_ref_type_runme.py
new file mode 100644
index 000000000..0b3e4dd26
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_ref_type_runme.py
@@ -0,0 +1,5 @@
+import template_ref_type
+
+xr = template_ref_type.XC()
+y = template_ref_type.Y()
+y.find(xr)
diff --git a/trunk/Examples/test-suite/python/template_rename_runme.py b/trunk/Examples/test-suite/python/template_rename_runme.py
new file mode 100644
index 000000000..4f0e7e83e
--- /dev/null
+++ b/trunk/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.groki_test(6)
+
+x = d.blah_test(7)
+y = d.spam(8)
+z = d.grok_test(9)
diff --git a/trunk/Examples/test-suite/python/template_static_runme.py b/trunk/Examples/test-suite/python/template_static_runme.py
new file mode 100644
index 000000000..9171d93b5
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_static_runme.py
@@ -0,0 +1,3 @@
+from template_static import *
+
+Foo_bar_double(1)
diff --git a/trunk/Examples/test-suite/python/template_tbase_template_runme.py b/trunk/Examples/test-suite/python/template_tbase_template_runme.py
new file mode 100644
index 000000000..d13c5f2c2
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_type_namespace_runme.py b/trunk/Examples/test-suite/python/template_type_namespace_runme.py
new file mode 100644
index 000000000..19ea5f5ce
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_typedef_cplx2_runme.py b/trunk/Examples/test-suite/python/template_typedef_cplx2_runme.py
new file mode 100644
index 000000000..04c599329
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_typedef_cplx2_runme.py
@@ -0,0 +1,94 @@
+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 = '%s' % d
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print d, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ e = make_Multiplies_double_double_double_double(d, d)
+ a = e.this
+except:
+ print e, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % e
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print e, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+#
+# complex case
+#
+
+try:
+ c = make_Identity_complex()
+ a = c.this
+except:
+ print c, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % c
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print c, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ f = make_Multiplies_complex_complex_complex_complex(c, c)
+ a = f.this
+except:
+ print f, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % f
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print f, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+#
+# Mix case
+#
+
+try:
+ g = make_Multiplies_double_double_complex_complex(d, c)
+ a = g.this
+except:
+ print g, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % g
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print g, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+try:
+ h = make_Multiplies_complex_complex_double_double(c, d)
+ a = h.this
+except:
+ print h, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % h
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print h, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ a = g.get_value()
+except:
+ print g, "has not get_value() method"
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/template_typedef_cplx3_runme.py b/trunk/Examples/test-suite/python/template_typedef_cplx3_runme.py
new file mode 100644
index 000000000..b8ac1b6ef
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_typedef_cplx4_runme.py b/trunk/Examples/test-suite/python/template_typedef_cplx4_runme.py
new file mode 100644
index 000000000..faeca219f
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/template_typedef_cplx_runme.py b/trunk/Examples/test-suite/python/template_typedef_cplx_runme.py
new file mode 100644
index 000000000..2cd9c8348
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_typedef_cplx_runme.py
@@ -0,0 +1,87 @@
+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 = '%s' % d
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print d, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ e = make_Multiplies_double_double_double_double(d, d)
+ a = e.this
+except:
+ print e, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % e
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print e, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+#
+# complex case
+#
+
+try:
+ c = make_Identity_complex()
+ a = c.this
+except:
+ print c, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % c
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print c, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+try:
+ f = make_Multiplies_complex_complex_complex_complex(c, c)
+ a = f.this
+except:
+ print f, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % f
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print f, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+#
+# Mix case
+#
+
+try:
+ g = make_Multiplies_double_double_complex_complex(d, c)
+ a = g.this
+except:
+ print g, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % g
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print g, "is not an ArithUnaryFunction"
+ raise RuntimeError
+
+
+try:
+ h = make_Multiplies_complex_complex_double_double(c, d)
+ a = h.this
+except:
+ print h, "is not an instance"
+ raise RuntimeError
+
+s = '%s' % h
+if str.find(s, 'ArithUnaryFunction') == -1:
+ print h, "is not an ArithUnaryFunction"
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/template_typedef_import_runme.py b/trunk/Examples/test-suite/python/template_typedef_import_runme.py
new file mode 100644
index 000000000..5c0b0b936
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_typedef_import_runme.py
@@ -0,0 +1,34 @@
+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/trunk/Examples/test-suite/python/template_typedef_runme.py b/trunk/Examples/test-suite/python/template_typedef_runme.py
new file mode 100644
index 000000000..4b3970593
--- /dev/null
+++ b/trunk/Examples/test-suite/python/template_typedef_runme.py
@@ -0,0 +1,46 @@
+from template_typedef import *
+
+d = make_Identity_float()
+c = make_Identity_reald()
+
+
+try:
+ a = d.this
+ a = c.this
+except:
+ raise RuntimeError
+
+try:
+ e = make_Multiplies_float_float_float_float(d, d)
+ a = e.this
+except:
+ print e, "is not an instance"
+ raise RuntimeError
+
+try:
+ f = make_Multiplies_reald_reald_reald_reald(c, c)
+ a = f.this
+except:
+ print f, "is not an instance"
+ raise RuntimeError
+
+try:
+ g = make_Multiplies_float_float_reald_reald(d, c)
+ a = g.this
+except:
+ print g, "is not an instance"
+ raise RuntimeError
+
+
+# the old large format
+if not SWIG_TypeQuery("vfncs::ArithUnaryFunction<vfncs::arith_traits<float,double>::argument_type,vfncs::arith_traits<float,double >::result_type > *"):
+ raise RuntimeError
+
+
+# the reduced format
+if not SWIG_TypeQuery("vfncs::ArithUnaryFunction<double,double> *"):
+ raise RuntimeError
+
+# this is a bad name
+if SWIG_TypeQuery("vfncs::ArithUnaryFunction<double,doublex> *"):
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/threads_exception_runme.py b/trunk/Examples/test-suite/python/threads_exception_runme.py
new file mode 100755
index 000000000..9fbc6a9b2
--- /dev/null
+++ b/trunk/Examples/test-suite/python/threads_exception_runme.py
@@ -0,0 +1,36 @@
+import threads_exception
+
+t = threads_exception.Test()
+try:
+ t.unknown()
+except RuntimeError,e:
+ pass
+
+try:
+ t.simple()
+except RuntimeError,e:
+ if e.args[0] != 37:
+ raise RuntimeError
+
+try:
+ t.message()
+except RuntimeError,e:
+ if e.args[0] != "I died.":
+ raise RuntimeError
+
+try:
+ t.hosed()
+except threads_exception.Exc,e:
+ if e.code != 42:
+ raise RuntimeError
+ if e.msg != "Hosed":
+ raise RuntimeError
+
+for i in range(1,4):
+ try:
+ t.multi(i)
+ except RuntimeError,e:
+ pass
+ except threads_exception.Exc,e:
+ pass
+
diff --git a/trunk/Examples/test-suite/python/typedef_class_runme.py b/trunk/Examples/test-suite/python/typedef_class_runme.py
new file mode 100644
index 000000000..71436b399
--- /dev/null
+++ b/trunk/Examples/test-suite/python/typedef_class_runme.py
@@ -0,0 +1,7 @@
+import typedef_class
+
+a = typedef_class.RealA()
+a.a = 3
+
+b = typedef_class.B()
+b.testA(a)
diff --git a/trunk/Examples/test-suite/python/typedef_inherit_runme.py b/trunk/Examples/test-suite/python/typedef_inherit_runme.py
new file mode 100644
index 000000000..6b7f2d872
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/typedef_scope_runme.py b/trunk/Examples/test-suite/python/typedef_scope_runme.py
new file mode 100644
index 000000000..37bfc97b1
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/typemap_delete_runme.py b/trunk/Examples/test-suite/python/typemap_delete_runme.py
new file mode 100644
index 000000000..582a2167c
--- /dev/null
+++ b/trunk/Examples/test-suite/python/typemap_delete_runme.py
@@ -0,0 +1,5 @@
+import typemap_delete
+
+r = typemap_delete.Rect(123)
+if r.val != 123:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/typemap_namespace_runme.py b/trunk/Examples/test-suite/python/typemap_namespace_runme.py
new file mode 100644
index 000000000..581a0f437
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/typemap_ns_using_runme.py b/trunk/Examples/test-suite/python/typemap_ns_using_runme.py
new file mode 100644
index 000000000..802ea7f56
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/typemap_out_optimal_runme.py b/trunk/Examples/test-suite/python/typemap_out_optimal_runme.py
new file mode 100644
index 000000000..b148f2d06
--- /dev/null
+++ b/trunk/Examples/test-suite/python/typemap_out_optimal_runme.py
@@ -0,0 +1,5 @@
+from typemap_out_optimal import *
+
+cvar.XX_debug = False
+x = XX.create()
+
diff --git a/trunk/Examples/test-suite/python/typemap_qualifier_strip_runme.py b/trunk/Examples/test-suite/python/typemap_qualifier_strip_runme.py
new file mode 100644
index 000000000..5e466cf69
--- /dev/null
+++ b/trunk/Examples/test-suite/python/typemap_qualifier_strip_runme.py
@@ -0,0 +1,54 @@
+import typemap_qualifier_strip
+
+val = typemap_qualifier_strip.create_int(111)
+if typemap_qualifier_strip.testA1(val) != 1234:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testA2(val) != 1234:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testA3(val) != 1234:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testA4(val) != 1234:
+ raise RuntimeError
+
+
+if typemap_qualifier_strip.testB1(val) != 111:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testB2(val) != 111:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testB3(val) != 111:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testB4(val) != 111:
+ raise RuntimeError
+
+
+if typemap_qualifier_strip.testC1(val) != 5678:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testC2(val) != 111:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testC3(val) != 5678:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testC4(val) != 111:
+ raise RuntimeError
+
+
+if typemap_qualifier_strip.testD1(val) != 111:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testD2(val) != 3456:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testD3(val) != 111:
+ raise RuntimeError
+
+if typemap_qualifier_strip.testD4(val) != 111:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/typename_runme.py b/trunk/Examples/test-suite/python/typename_runme.py
new file mode 100644
index 000000000..59a0f1f76
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/types_directive_runme.py b/trunk/Examples/test-suite/python/types_directive_runme.py
new file mode 100644
index 000000000..c28453e84
--- /dev/null
+++ b/trunk/Examples/test-suite/python/types_directive_runme.py
@@ -0,0 +1,12 @@
+from types_directive import *
+
+d1 = Time1(2001, 2, 3, 60)
+newDate = add(d1, 7) # check that a Time1 instance is accepted where Date is expected
+if newDate.day != 10:
+ raise RuntimeError
+
+d2 = Time2(1999, 8, 7, 60)
+newDate = add(d2, 7) # check that a Time2 instance is accepted where Date is expected
+if newDate.day != 14:
+ raise RuntimeError
+
diff --git a/trunk/Examples/test-suite/python/unions_runme.py b/trunk/Examples/test-suite/python/unions_runme.py
new file mode 100644
index 000000000..d59e2429e
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/using1_runme.py b/trunk/Examples/test-suite/python/using1_runme.py
new file mode 100644
index 000000000..5556c1b6a
--- /dev/null
+++ b/trunk/Examples/test-suite/python/using1_runme.py
@@ -0,0 +1,4 @@
+import using1
+
+if using1.spam(37) != 37:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/using2_runme.py b/trunk/Examples/test-suite/python/using2_runme.py
new file mode 100644
index 000000000..cf657d734
--- /dev/null
+++ b/trunk/Examples/test-suite/python/using2_runme.py
@@ -0,0 +1,4 @@
+import using2
+
+if using2.spam(37) != 37:
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/using_composition_runme.py b/trunk/Examples/test-suite/python/using_composition_runme.py
new file mode 100644
index 000000000..6baa16d13
--- /dev/null
+++ b/trunk/Examples/test-suite/python/using_composition_runme.py
@@ -0,0 +1,34 @@
+from using_composition import *
+
+f = FooBar()
+if f.blah(3) != 3:
+ raise RuntimeError,"FooBar::blah(int)"
+
+if f.blah(3.5) != 3.5:
+ raise RuntimeError,"FooBar::blah(double)"
+
+if f.blah("hello") != "hello":
+ raise RuntimeError,"FooBar::blah(char *)"
+
+
+f = FooBar2()
+if f.blah(3) != 3:
+ raise RuntimeError,"FooBar2::blah(int)"
+
+if f.blah(3.5) != 3.5:
+ raise RuntimeError,"FooBar2::blah(double)"
+
+if f.blah("hello") != "hello":
+ raise RuntimeError,"FooBar2::blah(char *)"
+
+
+f = FooBar3()
+if f.blah(3) != 3:
+ raise RuntimeError,"FooBar3::blah(int)"
+
+if f.blah(3.5) != 3.5:
+ raise RuntimeError,"FooBar3::blah(double)"
+
+if f.blah("hello") != "hello":
+ raise RuntimeError,"FooBar3::blah(char *)"
+
diff --git a/trunk/Examples/test-suite/python/using_extend_runme.py b/trunk/Examples/test-suite/python/using_extend_runme.py
new file mode 100644
index 000000000..14615a05e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/using_extend_runme.py
@@ -0,0 +1,21 @@
+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)"
+
+
+if f.duh(3) != 3:
+ raise RuntimeError,"duh(int)"
diff --git a/trunk/Examples/test-suite/python/using_inherit_runme.py b/trunk/Examples/test-suite/python/using_inherit_runme.py
new file mode 100644
index 000000000..b00e66ec3
--- /dev/null
+++ b/trunk/Examples/test-suite/python/using_inherit_runme.py
@@ -0,0 +1,49 @@
+from using_inherit import *
+
+b = Bar()
+if b.test(3) != 3:
+ raise RuntimeError,"Bar::test(int)"
+
+if b.test(3.5) != 3.5:
+ raise RuntimeError, "Bar::test(double)"
+
+
+b = Bar2()
+if b.test(3) != 6:
+ raise RuntimeError,"Bar2::test(int)"
+
+if b.test(3.5) != 7.0:
+ raise RuntimeError, "Bar2::test(double)"
+
+
+b = Bar3()
+if b.test(3) != 6:
+ raise RuntimeError,"Bar3::test(int)"
+
+if b.test(3.5) != 7.0:
+ raise RuntimeError, "Bar3::test(double)"
+
+
+b = Bar4()
+if b.test(3) != 6:
+ raise RuntimeError,"Bar4::test(int)"
+
+if b.test(3.5) != 7.0:
+ raise RuntimeError, "Bar4::test(double)"
+
+
+b = Fred1()
+if b.test(3) != 3:
+ raise RuntimeError,"Fred1::test(int)"
+
+if b.test(3.5) != 7.0:
+ raise RuntimeError, "Fred1::test(double)"
+
+
+b = Fred2()
+if b.test(3) != 3:
+ raise RuntimeError,"Fred2::test(int)"
+
+if b.test(3.5) != 7.0:
+ raise RuntimeError, "Fred2::test(double)"
+
diff --git a/trunk/Examples/test-suite/python/using_private_runme.py b/trunk/Examples/test-suite/python/using_private_runme.py
new file mode 100644
index 000000000..00c9a8d25
--- /dev/null
+++ b/trunk/Examples/test-suite/python/using_private_runme.py
@@ -0,0 +1,13 @@
+from using_private import *
+
+f = FooBar()
+f.x = 3
+
+if f.blah(4) != 4:
+ raise RuntimeError, "blah(int)"
+
+if f.defaulted() != -1:
+ raise RuntimeError, "defaulted()"
+
+if f.defaulted(222) != 222:
+ raise RuntimeError, "defaulted(222)"
diff --git a/trunk/Examples/test-suite/python/using_protected_runme.py b/trunk/Examples/test-suite/python/using_protected_runme.py
new file mode 100644
index 000000000..525a1cde4
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/python/varargs_runme.py b/trunk/Examples/test-suite/python/varargs_runme.py
new file mode 100644
index 000000000..301de78a7
--- /dev/null
+++ b/trunk/Examples/test-suite/python/varargs_runme.py
@@ -0,0 +1,18 @@
+import varargs
+
+if varargs.test("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+f = varargs.Foo("Greetings")
+if f.str != "Greetings":
+ raise RuntimeError, "Failed"
+
+if f.test("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+
+if varargs.test_def("Hello",1) != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs.test_def("Hello") != "Hello":
+ raise RuntimeError, "Failed"
diff --git a/trunk/Examples/test-suite/python/virtual_derivation_runme.py b/trunk/Examples/test-suite/python/virtual_derivation_runme.py
new file mode 100644
index 000000000..8a6e743af
--- /dev/null
+++ b/trunk/Examples/test-suite/python/virtual_derivation_runme.py
@@ -0,0 +1,8 @@
+from virtual_derivation import *
+#
+# very innocent example
+#
+b = B(3)
+if b.get_a() != b.get_b():
+ raise RuntimeError, "something is really wrong"
+
diff --git a/trunk/Examples/test-suite/python/virtual_poly_runme.py b/trunk/Examples/test-suite/python/virtual_poly_runme.py
new file mode 100644
index 000000000..7e202f9cf
--- /dev/null
+++ b/trunk/Examples/test-suite/python/virtual_poly_runme.py
@@ -0,0 +1,38 @@
+import virtual_poly
+
+d = virtual_poly.NDouble(3.5)
+i = virtual_poly.NInt(2)
+
+#
+# the copy methods return the right polymorphic types
+#
+dc = d.copy()
+ic = i.copy()
+
+if d.get() != dc.get():
+ raise RuntimeError
+
+if i.get() != ic.get():
+ raise RuntimeError
+
+virtual_poly.incr(ic)
+
+if (i.get() + 1) != ic.get():
+ raise RuntimeError
+
+
+dr = d.ref_this()
+if d.get() != dr.get():
+ raise RuntimeError
+
+
+#
+# 'narrowing' also works
+#
+ddc = virtual_poly.NDouble_narrow(d.nnumber())
+if d.get() != ddc.get():
+ raise RuntimeError
+
+dic = virtual_poly.NInt_narrow(i.nnumber())
+if i.get() != dic.get():
+ raise RuntimeError
diff --git a/trunk/Examples/test-suite/python/voidtest_runme.py b/trunk/Examples/test-suite/python/voidtest_runme.py
new file mode 100644
index 000000000..a7b421d6e
--- /dev/null
+++ b/trunk/Examples/test-suite/python/voidtest_runme.py
@@ -0,0 +1,29 @@
+import voidtest
+
+voidtest.globalfunc()
+f = voidtest.Foo()
+f.memberfunc()
+
+voidtest.Foo_staticmemberfunc()
+
+def fvoid():
+ pass
+
+if f.memberfunc() != fvoid():
+ raise RuntimeError
+
+
+v1 = voidtest.vfunc1(f)
+v2 = voidtest.vfunc2(f)
+if v1 != v2:
+ raise RuntimeError
+
+v3 = voidtest.vfunc3(v1)
+if v3.this != f.this:
+ raise RuntimeError
+v4 = voidtest.vfunc1(f)
+if v4 != v1:
+ raise RuntimeError
+
+
+v3.memberfunc()
diff --git a/trunk/Examples/test-suite/python/wrapmacro_runme.py b/trunk/Examples/test-suite/python/wrapmacro_runme.py
new file mode 100644
index 000000000..0272afd5d
--- /dev/null
+++ b/trunk/Examples/test-suite/python/wrapmacro_runme.py
@@ -0,0 +1,7 @@
+import wrapmacro
+
+a = 2
+b = -1
+wrapmacro.maximum(a,b)
+wrapmacro.maximum(a/7.0, -b*256)
+wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1)
diff --git a/trunk/Examples/test-suite/python_abstractbase.i b/trunk/Examples/test-suite/python_abstractbase.i
new file mode 100644
index 000000000..f72688237
--- /dev/null
+++ b/trunk/Examples/test-suite/python_abstractbase.i
@@ -0,0 +1,18 @@
+%module python_abstractbase
+%include <pyabc.i>
+%include <std_map.i>
+%include <std_multimap.i>
+%include <std_set.i>
+%include <std_multiset.i>
+%include <std_list.i>
+%include <std_vector.i>
+
+namespace std
+{
+ %template(Mapii) map<int, int>;
+ %template(Multimapii) multimap<int, int>;
+ %template(IntSet) set<int>;
+ %template(IntMultiset) multiset<int>;
+ %template(IntVector) vector<int>;
+ %template(IntList) list<int>;
+}
diff --git a/trunk/Examples/test-suite/python_append.i b/trunk/Examples/test-suite/python_append.i
new file mode 100644
index 000000000..2dc9cb970
--- /dev/null
+++ b/trunk/Examples/test-suite/python_append.i
@@ -0,0 +1,32 @@
+/*
+Testcase to test %pythonprepend and %pythonappend
+*/
+
+%module python_append
+
+%pythonappend Test::func %{
+ pass
+%}
+
+%pythonprepend Test::func %{
+ pass
+%}
+
+%pythonappend Test::static_func %{
+pass
+%}
+
+%pythonprepend Test::static_func {
+ pass
+}
+
+%inline %{
+
+class Test {
+public:
+ static void static_func() {};
+ void func() {};
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/python_autodoc.i b/trunk/Examples/test-suite/python_autodoc.i
new file mode 100644
index 000000000..c363e4384
--- /dev/null
+++ b/trunk/Examples/test-suite/python_autodoc.i
@@ -0,0 +1,95 @@
+%module(docstring="hello") python_autodoc
+
+%feature("autodoc");
+
+// especial typemap and its docs
+%typemap(in) (int c, int d) "$1 =0; $2 = 0;";
+%typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
+
+// testing for different documentation levels
+%feature("autodoc","0") A::func0; // names
+%feature("autodoc","1") A::func1; // names + types
+%feature("autodoc","2") A::func2; // extended
+%feature("autodoc","3") A::func3; // extended + types
+
+%feature("autodoc","just a string") A::func; // names
+
+%inline {
+
+ enum Hola {
+ hi, hello
+ };
+
+ struct A
+ {
+ A(int a, short b, Hola h)
+ {
+ }
+
+ int func(int a)
+ {
+ return a;
+ }
+
+ int func0(int c, int d)
+ {
+ return c;
+ }
+
+ int func1(int c, int d)
+ {
+ return c;
+ }
+
+ int func2(A* c, double d = 2)
+ {
+ return 2;
+ }
+
+ int func3(A* c, double d = 2)
+ {
+ return 2;
+ }
+ };
+}
+
+
+// deleting typemaps and docs
+%typemap(in) (int c, int d) ;
+%typemap(doc) (int c, int d);
+
+// docs for some parameters
+%typemap(doc) int a "a: special comment for parameter a";
+%typemap(doc) int b "b: another special comment for parameter b";
+
+%callback(1) func_cb;
+
+%inline {
+
+ struct B
+ {
+ B(int a, int b, Hola h)
+ {
+ }
+
+
+ int func(int c, int d)
+ {
+ return c;
+ }
+
+ };
+
+ int func(int c, int d) {
+ return c;
+ }
+
+ int funcio(int *INOUT) {
+ return 1;
+ }
+
+ int func_cb(int c, int d) {
+ return c;
+ }
+
+}
diff --git a/trunk/Examples/test-suite/python_kwargs.i b/trunk/Examples/test-suite/python_kwargs.i
new file mode 100644
index 000000000..28089bbf1
--- /dev/null
+++ b/trunk/Examples/test-suite/python_kwargs.i
@@ -0,0 +1,112 @@
+%module python_kwargs
+
+%nocopyctor;
+%kwargs;
+
+%rename(myDel) del;
+%inline
+{
+ struct s { int del; };
+}
+
+
+// Simple class
+%extend Foo
+{
+ int efoo(int a = 1, int b = 0) {return a + b; }
+ static int sfoo(int a = 1, int b = 0) { return a + b; }
+}
+
+%newobject Foo::create;
+
+%inline %{
+
+ struct Foo
+ {
+ Foo(int a, int b = 0) {}
+
+ virtual int foo(int a = 1, int b = 0) {return a + b; }
+ static int statfoo(int a = 1, int b = 0) {return a + b; }
+
+ static Foo *create(int a = 1, int b = 0)
+ {
+ return new Foo(a, b);
+ }
+
+ virtual ~Foo() {
+ }
+
+ };
+
+%}
+
+
+// Templated class
+%extend Bar
+{
+ T ebar(T a = 1, T b = 0) {return a + b; }
+ static T sbar(T a = 1, T b = 0) { return a + b; }
+}
+
+%inline %{
+ template <typename T> struct Bar
+ {
+ Bar(T a, T b = 0){}
+
+ T bar(T a = 1, T b = 0) {return a + b; }
+ static T statbar(T a = 1, T b = 0) {return a + b; }
+ };
+
+%}
+
+%template(BarInt) Bar<int>;
+
+
+// Functions
+%inline %{
+ int foo(int a = 1, int b = 0) {return a + b; }
+
+
+ template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
+%}
+
+%template(templatedfunction) templatedfunction<int>;
+
+
+// Deafult args with references
+%inline
+%{
+
+ typedef int size_type;
+
+ struct Hello
+ {
+ static const size_type hello = 3;
+ };
+
+
+
+ int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
+ {
+ return x;
+ }
+
+%}
+%{
+ const int Hello::hello;
+%}
+
+
+// Functions with keywords
+%warnfilter(SWIGWARN_PARSE_KEYWORD);
+%inline %{
+ /* silently rename the parameter names in python */
+
+ int foo_kw(int from = 1, int except = 2) {return from + except; }
+
+
+ int foo_nu(int from = 1, int = 0) {return from; }
+
+ int foo_mm(int min = 1, int max = 2) {return min + max; }
+
+%}
diff --git a/trunk/Examples/test-suite/python_nondynamic.i b/trunk/Examples/test-suite/python_nondynamic.i
new file mode 100644
index 000000000..26c69644d
--- /dev/null
+++ b/trunk/Examples/test-suite/python_nondynamic.i
@@ -0,0 +1,58 @@
+%module python_nondynamic
+
+/*
+ Use the %pythonnondynamic directuve to make the wrapped class a
+ nondynamic one, ie, a python class that doesn't dynamically add new
+ attributes. Hence, for the class
+
+ %pythonnondynamic A;
+ struct A
+ {
+ int a;
+ int b;
+ };
+
+ you will get:
+
+ aa = A()
+ aa.a = 1 # Ok
+ aa.b = 1 # Ok
+ aa.c = 3 # error
+
+ Since "nondynamic" is a feature, if you use
+
+ %pythonnondynamic;
+
+ it will make all the wrapped class nondynamic ones.
+
+ The implementation is based on the recipe:
+
+ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
+
+ and works for modern (-modern) and plain python.
+
+*/
+
+
+
+%pythonnondynamic A;
+%pythondynamic C;
+
+
+%inline %{
+
+ struct A
+ {
+ int a;
+ int b;
+ };
+
+
+ struct C
+ {
+ int a;
+ int b;
+ };
+
+%}
+
diff --git a/trunk/Examples/test-suite/python_overload_simple_cast.i b/trunk/Examples/test-suite/python_overload_simple_cast.i
new file mode 100644
index 000000000..e7f58d788
--- /dev/null
+++ b/trunk/Examples/test-suite/python_overload_simple_cast.i
@@ -0,0 +1,4 @@
+// Simple tests of overloaded functions
+%module("castmode") python_overload_simple_cast
+
+%include overload_simple.i
diff --git a/trunk/Examples/test-suite/python_pybuf.i b/trunk/Examples/test-suite/python_pybuf.i
new file mode 100644
index 000000000..8e1302582
--- /dev/null
+++ b/trunk/Examples/test-suite/python_pybuf.i
@@ -0,0 +1,64 @@
+%module python_pybuf
+%include<pybuffer.i>
+%include<cstring.i>
+/*functions for the test case*/
+%pybuffer_mutable_binary(char *buf1, int len);
+%pybuffer_mutable_string(char *buf2);
+%pybuffer_binary(const char *buf3, int len);
+%pybuffer_string(const char *buf4);
+
+%inline %{
+ void func1(char *buf1, int len)
+ {
+ int i;
+ for (i=0; i<len; ++i)
+ buf1[i] = 'a';
+ return;
+ }
+ void func2(char *buf2)
+ {
+ strcpy(buf2, "Hello world!");
+ }
+ int func3(const char *buf3, int len)
+ {
+ int count = 0;
+ int i;
+ for(i=0; i<len; ++i)
+ if (isalnum(buf3[i]))
+ ++count;
+ return count;
+ }
+ int func4(const char *buf4)
+ {
+ return strlen(buf4);
+ }
+%}
+
+/*functions for the benchmark*/
+%pybuffer_mutable_string(char *str1);
+%cstring_mutable(char *str2);
+
+%inline %{
+void title(char *str) {
+ int outword = 1;
+ while(*str) {
+ if (isalnum(*str)) {
+ if (outword) {
+ outword = 0;
+ *str = toupper(*str);
+ }
+ }
+ else {
+ outword = 0;
+ }
+ str++;
+ }
+}
+
+void title1(char *str1) {
+ title(str1);
+}
+void title2(char *str2) {
+ title(str2);
+}
+%}
diff --git a/trunk/Examples/test-suite/r/Makefile.in b/trunk/Examples/test-suite/r/Makefile.in
new file mode 100644
index 000000000..32d046679
--- /dev/null
+++ b/trunk/Examples/test-suite/r/Makefile.in
@@ -0,0 +1,72 @@
+#######################################################################
+# Makefile for r test-suite
+#######################################################################
+
+LANGUAGE = r
+SCRIPTSUFFIX = _runme.R
+WRAPSUFFIX = .R
+RUNR = R CMD BATCH --no-save --no-restore
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+C_TEST_CASES = r_copy_struct r_legacy
+CPP_TEST_CASES = r_double_delete
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_multitestcase)
+
+# Runs the testcase.
+#
+# Run the runme if it exists. If not just load the R wrapper to
+# check for syntactic correctness
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ else \
+ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \
+ fi
+
+run_multitestcase = \
+ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
+ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
+ else \
+ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
+ fi; \
+ done
+# Clean
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile r_clean
+
+%.clean:
+ @rm -f $*.R $*_wrap.so $*_wrap.cpp $*_wrap.c $*_wrap.o $*_runme.Rout $*.Rout
+ @if [ -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
+ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
+ rm -f $${f}.R $${f}.Rout ; \
+ done \
+ fi
+
+
diff --git a/trunk/Examples/test-suite/r/arrays_dimensionless_runme.R b/trunk/Examples/test-suite/r/arrays_dimensionless_runme.R
new file mode 100644
index 000000000..9b97de2d8
--- /dev/null
+++ b/trunk/Examples/test-suite/r/arrays_dimensionless_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep=""))
+source("arrays_dimensionless.R")
+cacheMetaData(1)
+
+unittest(arr_short(1:4, 3), 6)
+unittest(arr_ushort(1:4, 3), 6)
+unittest(arr_int(1:4, 3), 6)
+unittest(arr_uint(1:4, 3), 6)
+unittest(arr_long(1:4, 3), 6)
+unittest(arr_ulong(1:4, 3), 6)
+unittest(arr_ll(1:4, 3), 6)
+unittest(arr_ull(1:4, 3), 6)
+unittest(arr_float(as.numeric(1:4), 3), 6)
+unittest(arr_double(as.numeric(1:4), 3), 6)
+
+q(save="no")
+
+
+
diff --git a/trunk/Examples/test-suite/r/funcptr_runme.R b/trunk/Examples/test-suite/r/funcptr_runme.R
new file mode 100644
index 000000000..3d5281bfa
--- /dev/null
+++ b/trunk/Examples/test-suite/r/funcptr_runme.R
@@ -0,0 +1,7 @@
+source("unittest.R")
+dyn.load(paste("funcptr", .Platform$dynlib.ext, sep=""))
+source("funcptr.R")
+cacheMetaData(1)
+unittest(do_op(1, 3, add), 4)
+unittest(do_op(2, 3, multiply), 6)
+unittest(do_op(2, 3, funcvar()), 5)
diff --git a/trunk/Examples/test-suite/r/ignore_parameter_runme.R b/trunk/Examples/test-suite/r/ignore_parameter_runme.R
new file mode 100644
index 000000000..89e461d71
--- /dev/null
+++ b/trunk/Examples/test-suite/r/ignore_parameter_runme.R
@@ -0,0 +1,10 @@
+source("unittest.R")
+dyn.load(paste("ignore_parameter", .Platform$dynlib.ext, sep=""))
+source("ignore_parameter.R")
+cacheMetaData(1)
+
+unittest(jaguar(1, 1.0), "hello")
+q(save="no")
+
+
+
diff --git a/trunk/Examples/test-suite/r/integers_runme.R b/trunk/Examples/test-suite/r/integers_runme.R
new file mode 100644
index 000000000..e31099a3b
--- /dev/null
+++ b/trunk/Examples/test-suite/r/integers_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("integers", .Platform$dynlib.ext, sep=""))
+source("integers.R")
+cacheMetaData(1)
+
+unittest(signed_char_identity(1), 1)
+unittest(unsigned_char_identity(1), 1)
+unittest(signed_short_identity(1), 1)
+unittest(unsigned_short_identity(1), 1)
+unittest(signed_int_identity(1), 1)
+unittest(unsigned_int_identity(1), 1)
+unittest(signed_long_identity(1), 1)
+unittest(unsigned_long_identity(1), 1)
+unittest(signed_long_long_identity(1), 1)
+unittest(unsigned_long_long_identity(1), 1)
+
+q(save="no")
+
+
+
diff --git a/trunk/Examples/test-suite/r/r_copy_struct_runme.R b/trunk/Examples/test-suite/r/r_copy_struct_runme.R
new file mode 100644
index 000000000..21bd93b64
--- /dev/null
+++ b/trunk/Examples/test-suite/r/r_copy_struct_runme.R
@@ -0,0 +1,58 @@
+source("unittest.R")
+dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep=""))
+source("r_copy_struct.R")
+cacheMetaData(1)
+
+a <- getA()
+
+r = getARef()
+
+unittest(A_d_get(r), 42)
+unittest(r$d, 42)
+unittest(r$i, 20)
+
+# An error in trying to access a field that doesn't exist.
+try(r$foo)
+
+r$d <- pi
+unittesttol(r$d, 3.141593, 0.0001)
+r$i <- -100
+
+r$ui
+r$ui <- 10
+
+ # An error since i is unsigned and so must be positive.
+try(r$ui <- -10)
+
+
+a = A()
+unittest(a$i,0)
+unittest(a$d,0)
+unittest(a$ui,0)
+a$ui <- 100
+unittest(a$ui,100)
+a$d = 1
+unittest(a$d,1)
+
+d <- bar()
+unittest(class(d), "_p_D")
+unittest(d$x, 1)
+unittest(d$u, 0)
+
+
+la <- new("A");
+la@ui <- as.integer(5)
+# Removing the next line makes this fail in R 2.4
+la@str <- ""
+
+other = A()
+foo <- copyToC(la, other)
+
+aa = A()
+aa$i = as.integer(201)
+aa$d = pi
+aa$str = "foo"
+aa$ui = as.integer(0)
+copyToR(aa)
+
+
diff --git a/trunk/Examples/test-suite/r/r_double_delete_runme.R b/trunk/Examples/test-suite/r/r_double_delete_runme.R
new file mode 100644
index 000000000..7b6fdb77f
--- /dev/null
+++ b/trunk/Examples/test-suite/r/r_double_delete_runme.R
@@ -0,0 +1,9 @@
+dyn.load(paste("r_double_delete", .Platform$dynlib.ext, sep=""))
+source("r_double_delete.R")
+cacheMetaData(1)
+
+# ----- Object creation -----
+
+f <- Foo(2.0)
+delete(f);
+delete(f);
diff --git a/trunk/Examples/test-suite/r/r_legacy_runme.R b/trunk/Examples/test-suite/r/r_legacy_runme.R
new file mode 100644
index 000000000..7e5ade87f
--- /dev/null
+++ b/trunk/Examples/test-suite/r/r_legacy_runme.R
@@ -0,0 +1,30 @@
+source("unittest.R")
+dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep=""))
+source("r_legacy.R")
+cacheMetaData(1)
+
+obj <- getObject(1,3)
+unittest(class(obj), "_p_Obj")
+unittest(obj$i, 1)
+unittesttol(obj$d, 3, 0.001)
+unittest(obj$str, "a test string")
+obj$i <- 2
+unittest(obj$i, 2)
+obj$d <- 4
+unittesttol(obj$d, 4, 0.001)
+obj$str <- "a new string"
+unittest(obj$str, "a new string")
+
+unittest(getInt(), 42)
+unittesttol(getDouble(),3.14159, 0.001)
+unittesttol(getFloat(),3.14159/2.0, 0.001)
+unittest(getLong(), -321313)
+unittest(getUnsignedLong(), 23123)
+unittest(getChar(), "A")
+
+q(save="no")
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/r/simple_array_runme.R b/trunk/Examples/test-suite/r/simple_array_runme.R
new file mode 100644
index 000000000..a6758dedd
--- /dev/null
+++ b/trunk/Examples/test-suite/r/simple_array_runme.R
@@ -0,0 +1,9 @@
+source("unittest.R")
+dyn.load(paste("simple_array", .Platform$dynlib.ext, sep=""))
+source("simple_array.R")
+cacheMetaData(1)
+initArray()
+
+q(save="no")
+
+
diff --git a/trunk/Examples/test-suite/r/unions_runme.R b/trunk/Examples/test-suite/r/unions_runme.R
new file mode 100644
index 000000000..76870d10c
--- /dev/null
+++ b/trunk/Examples/test-suite/r/unions_runme.R
@@ -0,0 +1,12 @@
+source("unittest.R")
+dyn.load(paste("unions", .Platform$dynlib.ext, sep=""))
+source("unions.R")
+cacheMetaData(1)
+
+ss <- SmallStruct()
+
+bstruct <- BigStruct()
+
+q(save="no")
+
+
diff --git a/trunk/Examples/test-suite/r/unittest.R b/trunk/Examples/test-suite/r/unittest.R
new file mode 100644
index 000000000..81c590a3f
--- /dev/null
+++ b/trunk/Examples/test-suite/r/unittest.R
@@ -0,0 +1,9 @@
+unittest <- function (x,y) {
+if (x==y) print("PASS")
+else print("FAIL")
+}
+
+unittesttol <- function(x,y,z) {
+if (abs(x-y) < z) print("PASS")
+else print("FAIL")
+} \ No newline at end of file
diff --git a/trunk/Examples/test-suite/r_copy_struct.i b/trunk/Examples/test-suite/r_copy_struct.i
new file mode 100644
index 000000000..fda321afb
--- /dev/null
+++ b/trunk/Examples/test-suite/r_copy_struct.i
@@ -0,0 +1,93 @@
+%module r_copy_struct
+
+%feature("opaque", "yes") B;
+%feature("opaque", "yes") C;
+
+%inline %{
+struct A {
+ int i;
+ unsigned int ui;
+ double d;
+ char* str;
+ int **tmp;
+};
+
+struct A getA();
+struct A* getARef();
+
+typedef struct {
+ int invisible;
+} B;
+
+struct C {
+ int invisible;
+ double blind;
+};
+
+typedef B C;
+
+B* getBRef();
+struct C* getCRef();
+
+C* getCCRef();
+
+typedef struct
+{
+ int x;
+ double u;
+} D;
+
+struct A
+getA()
+{
+ struct A a;
+
+ a.i = 10;
+ a.d = 3.1415;
+
+ return a;
+}
+
+static struct A fixed = {20, 3, 42.0};
+
+struct A *
+getARef()
+{
+ return(&fixed);
+}
+
+
+static B bb = {101};
+
+B*
+getBRef()
+{
+ return(&bb);
+}
+
+struct C cc = {201, 3.14159};
+struct C *
+getCRef()
+{
+ return(&cc);
+}
+
+
+C*
+getCCRef()
+{
+ return(&bb);
+}
+
+D
+bar()
+{ D a;
+ a.x = 1;
+ a.u = 0;
+ return(a);
+}
+
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/r_double_delete.i b/trunk/Examples/test-suite/r_double_delete.i
new file mode 100644
index 000000000..9743d0454
--- /dev/null
+++ b/trunk/Examples/test-suite/r_double_delete.i
@@ -0,0 +1,14 @@
+%module r_double_delete
+
+%inline %{
+
+class Foo {
+private:
+ double r;
+public:
+ Foo(double rin) : r(rin) {};
+};
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/r_legacy.i b/trunk/Examples/test-suite/r_legacy.i
new file mode 100644
index 000000000..c89263082
--- /dev/null
+++ b/trunk/Examples/test-suite/r_legacy.i
@@ -0,0 +1,98 @@
+%module r_legacy
+%inline %{
+typedef char *String;
+
+typedef struct {
+ int i;
+ double d;
+ char *str;
+ String s;
+} Obj;
+
+Obj *getObject(int i, double d);
+
+#include <string.h>
+
+Obj *
+getObject(int i, double d)
+{
+
+ const char *test_string = "a test string";
+ Obj *obj;
+ obj = (Obj *) calloc(1, sizeof(Obj));
+
+ obj->i = i;
+ obj->d = d;
+ /* allocate one extra byte for the null */
+ obj->str = (char *)malloc(strlen(test_string) + 1);
+ strcpy(obj->str, test_string);
+
+ return(obj);
+}
+%}
+
+char *getString();
+int getInt();
+double getDouble();
+float getFloat();
+long getLong();
+unsigned long getUnsignedLong();
+char getChar();
+
+extern unsigned long MyULong;
+
+extern const double PiSquared;
+
+#if 0
+extern float *MyFloatRef;
+#endif
+
+%inline %{
+#define PI 3.14159265358979
+unsigned long MyULong = 20;
+
+static float MyFloat = 1.05f;
+float *MyFloatRef = &MyFloat;
+
+const double PiSquared = PI * PI;
+
+char *getString()
+{
+ return "This is a literal string";
+}
+
+int
+getInt()
+{
+ return 42;
+}
+
+double
+getDouble()
+{
+ return PI;
+}
+
+float
+getFloat()
+{
+ return (float)PI/2;
+}
+
+long getLong()
+{
+ return -321313L;
+}
+
+unsigned long
+getUnsignedLong()
+{
+ return 23123L;
+}
+
+char
+getChar()
+{
+ return('A');
+}
+%}
diff --git a/trunk/Examples/test-suite/redefined.i b/trunk/Examples/test-suite/redefined.i
new file mode 100644
index 000000000..3022ee9cc
--- /dev/null
+++ b/trunk/Examples/test-suite/redefined.i
@@ -0,0 +1,107 @@
+%module redefined
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) agua;
+
+/* no redundant warnings */
+%warnfilter(SWIGWARN_PARSE_REDUNDANT);
+
+#if 1
+ //
+ // All these repeated declarations are not redefinitions,
+ // and they are valid C++ code, therefore, we skip
+ // swig redefined warnings.
+ //
+%define uja
+ aju;
+%enddef
+
+%define uja
+ aju;
+%enddef
+
+%constant int agua = 0;
+%constant int agua = 0;
+
+%inline %{
+
+#define REDUNDANT 1
+#define REDUNDANT 1
+
+#define MACROREP(x) x
+#define MACROREP(x) x
+
+ class Hello;
+ class Hello;
+
+ typedef int Int;
+ typedef int Int;
+
+ inline int hello(int);
+ int hello(int) { return 0; }
+
+ struct B;
+
+ struct A
+ {
+ typedef int Int;
+ friend int foo(A*, B*);
+ };
+
+ struct B
+ {
+ typedef int Int;
+ friend int foo(A*, B*);
+ };
+
+ inline int foo(A*, B*) { return 0; }
+
+%}
+
+
+#else
+
+//
+// the %extend and %rename directive ALWAYS emit redefined warnings,
+// since they are not C/C++/CPP standard.
+//
+%extend Hello {
+ int hi(int) { return 0; }
+}
+
+%rename(chao) hi(int);
+
+//
+// All these repeated declarations are really redefinitions,
+// therefore, swig must produce a redefined warning
+//
+
+%constant int agua = 0;
+%constant int agua = 1;
+
+
+%inline %{
+
+#define REDEFINED 1
+#define REDEFINED 2
+
+#define MACROREP(x) x
+#define MACROREP(x) x*2
+
+ typedef int Int;
+ typedef double Int;
+
+ int hi(int);
+ int chao(int);
+ int hello(int);
+ inline double hello(int) { return 0; }
+
+ struct Hello
+ {
+ typedef int Int;
+ typedef double Int;
+ friend short hello(int);
+ int hi(int) { return 0; }
+ };
+
+%}
+#endif
diff --git a/trunk/Examples/test-suite/refcount.h b/trunk/Examples/test-suite/refcount.h
new file mode 100644
index 000000000..7d07e7242
--- /dev/null
+++ b/trunk/Examples/test-suite/refcount.h
@@ -0,0 +1,198 @@
+#ifndef TEST_SUITE_REFCOUNT_H__
+#define TEST_SUITE_REFCOUNT_H__
+
+struct RCObjBase {
+ /*!
+ Return the numbers of active references.
+
+ \return The internal \c refCount value.
+ */
+ int ref_count() const
+ {
+ return refCount;
+ }
+
+ /*!
+ Add one reference.
+
+ \return The reference counter value.
+ */
+ int addref() const
+ {
+ return add_ref();
+ }
+
+ /*!
+ Delete one reference. If the refCount is zero, the
+ object is deleted.
+
+ \return The reference counter value, which can be zero after
+ deletion.
+ */
+ int delref() const
+ {
+ if (ref_count() == 0 || del_ref() == 0 )
+ {
+ delete this;
+ return 0;
+ }
+ return ref_count();
+ }
+
+protected:
+ RCObjBase();
+ RCObjBase(const RCObjBase& );
+ virtual ~RCObjBase() = 0;
+
+private:
+
+ RCObjBase& operator=(const RCObjBase& );
+
+ friend struct RCObj;
+
+ int add_ref() const
+ {
+ return ++refCount;
+ }
+
+ int del_ref() const
+ {
+ return --refCount;
+ }
+
+ mutable int refCount;
+};
+
+struct RCObj : virtual RCObjBase {
+protected:
+ RCObj()
+ {
+ }
+};
+
+/*! Reference an RCObj object
+ \return The input pointer \a r
+*/
+template <class T>
+inline
+T* addref(T* r)
+{
+ return (r && r->addref() ) ? r : 0;
+}
+
+/*! Unreference an RCObj object.
+ \return The input pointer \a r or nil if the object was deleted.
+*/
+template <class T>
+inline
+T* delref(T* r)
+{
+ return ( r && r->delref() ) ? r : 0;
+}
+
+
+
+RCObjBase::RCObjBase()
+ : refCount(0)
+{
+}
+
+
+RCObjBase::~RCObjBase()
+{
+}
+
+RCObjBase::RCObjBase(const RCObjBase&)
+ : refCount(0)
+{
+}
+
+
+RCObjBase& RCObjBase::operator=(const RCObjBase&)
+{
+ return *this;
+}
+
+
+template <class T>
+struct RCPtr {
+ typedef T* pointer_type;
+ typedef T& refernce_type;
+ typedef T value_type;
+
+ RCPtr();
+ RCPtr(T* realPtr);
+ RCPtr(const RCPtr& rhs);
+
+ ~RCPtr();
+
+ RCPtr& operator=(const RCPtr& rhs);
+
+ RCPtr& operator=(T* realPtr);
+
+ T* operator->() { return pointee; }
+ T& operator*() { return *pointee; }
+
+ const T* operator->() const { return pointee; }
+ const T& operator*() const { return *pointee; }
+
+ operator T*() { return pointee; }
+ operator T&() { return *pointee; }
+
+ operator const T*() const { return pointee; }
+ operator const T&() const { return *pointee; }
+
+ T* get() { return pointee; }
+ T* get() const { return pointee; }
+
+
+private:
+ T* pointee;
+};
+
+
+template <class T>
+inline
+RCPtr<T>::RCPtr()
+ : pointee(0)
+{
+}
+
+template <class T>
+inline
+RCPtr<T>::RCPtr(T* realPtr)
+ : pointee(realPtr)
+{
+ addref(pointee);
+}
+
+template <class T>
+inline
+RCPtr<T>::RCPtr(const RCPtr& rhs)
+ : pointee(rhs.pointee)
+{
+ addref(pointee);
+}
+
+template <class T>
+inline
+RCPtr<T>::~RCPtr()
+{
+ delref(pointee);
+}
+
+template <class T>
+inline
+RCPtr<T>& RCPtr<T>::operator=(const RCPtr& rhs)
+{
+ if (pointee != rhs.pointee) {
+ delref(pointee);
+ pointee = rhs.pointee;
+ addref(pointee);
+ }
+ return *this;
+}
+
+
+
+#endif //TEST_SUITE_REFCOUNT_H__
diff --git a/trunk/Examples/test-suite/refcount.i b/trunk/Examples/test-suite/refcount.i
new file mode 100644
index 000000000..8352b508a
--- /dev/null
+++ b/trunk/Examples/test-suite/refcount.i
@@ -0,0 +1,104 @@
+%module refcount
+
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ,SWIGWARN_LANG_IDENTIFIER);
+
+%{
+#include <iostream>
+#include "refcount.h"
+%}
+
+//
+// using the %refobject/%unrefobject directives you can active the
+// ref. counting for RCObj and all its descendents at once
+//
+
+%refobject RCObj "$this->addref();"
+%unrefobject RCObj "$this->delref();"
+
+%include "refcount.h"
+
+%newobject B::create(A* a);
+%newobject B::cloner();
+
+
+
+%inline %{
+
+ struct A : RCObj
+ {
+ A() {}
+
+ ~A()
+ {
+ // std::cout << "deleting a" << std::endl;
+ }
+
+#ifdef SWIGRUBY
+ // fix strange ruby + virtual derivation problem
+ using RCObjBase::ref_count;
+#endif
+ };
+
+ struct A1 : A
+ {
+ protected:
+ A1() {}
+ };
+
+ struct A2 : A
+ {
+ };
+
+ struct A3 : A1, private A2
+ {
+ };
+
+%}
+
+#if defined(SWIGPYTHON)
+%extend_smart_pointer(RCPtr<A>);
+%template(RCPtr_A) RCPtr<A>;
+#endif
+
+%inline %{
+
+ struct B : RCObj
+ {
+ B(A* a) : _a(a) {}
+
+ A* get_a()
+ {
+ return _a;
+ }
+
+ static B* create(A* a)
+ {
+ return new B(a);
+ }
+
+ B* cloner()
+ {
+ return new B(_a);
+ }
+
+ ~B()
+ {
+ // std::cout << "deleting b" << std::endl;
+ }
+
+ RCPtr<A> get_rca() {
+ return _a;
+ }
+
+ private:
+ RCPtr<A> _a;
+ };
+
+%}
+
+#if defined(SWIGPYTHON) || defined(SWIGOCTAVE)
+
+%include <std_vector.i>
+%template(vector_A) std::vector<RCPtr<A> >;
+
+#endif
diff --git a/trunk/Examples/test-suite/reference_global_vars.i b/trunk/Examples/test-suite/reference_global_vars.i
new file mode 100644
index 000000000..8c806599b
--- /dev/null
+++ b/trunk/Examples/test-suite/reference_global_vars.i
@@ -0,0 +1,65 @@
+// Tests global reference variables:
+// - all non const primitives
+// - const and non const class
+
+%module reference_global_vars
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
+
+%inline %{
+class TestClass {
+public:
+ int num;
+ TestClass(int n = 0) : num(n) {}
+};
+%}
+
+// const class reference variable
+%{
+const TestClass& global_constTestClass = TestClass(33);
+%}
+%inline %{
+TestClass getconstTC() {
+ return global_constTestClass;
+}
+%}
+
+// Macro to help define similar functions
+%define ref(type,name)
+%{
+static type initial_value_##name;
+%}
+%inline %{
+static type &var_##name = initial_value_##name;
+type setref_##name(type &x) {
+ var_##name = x;
+ return var_##name;
+}
+type& createref_##name(type x) {
+ return *new type(x);
+}
+type value_##name(type &x) {
+ return x;
+}
+%}
+%enddef
+
+// primitive reference variables
+ref(bool, bool);
+ref(char, char);
+ref(unsigned char, unsigned_char);
+ref(signed char, signed_char);
+ref(short, short);
+ref(unsigned short, unsigned_short);
+ref(int, int);
+ref(unsigned int, unsigned_int);
+ref(long, long);
+ref(unsigned long, unsigned_long);
+ref(float, float);
+ref(double, double);
+ref(long long, long_long);
+ref(unsigned long long, unsigned_long_long);
+
+// class reference variable
+ref(TestClass, TestClass);
+
diff --git a/trunk/Examples/test-suite/register_par.i b/trunk/Examples/test-suite/register_par.i
new file mode 100644
index 000000000..030be4556
--- /dev/null
+++ b/trunk/Examples/test-suite/register_par.i
@@ -0,0 +1,6 @@
+%module register_par
+
+// bug # 924413
+%inline {
+ void clear_tree_flags(register struct tree *tp, register int i) {}
+}
diff --git a/trunk/Examples/test-suite/rename.h b/trunk/Examples/test-suite/rename.h
new file mode 100644
index 000000000..4750337a9
--- /dev/null
+++ b/trunk/Examples/test-suite/rename.h
@@ -0,0 +1,44 @@
+
+namespace Space {
+struct Klass {
+ Klass(int i) {}
+ Klass() {}
+};
+}
+
+namespace AnotherSpace {
+ class Another {};
+}
+
+namespace Space {
+ using namespace AnotherSpace;
+ enum Enu { En1, En2, En3 };
+ template<typename T> struct NotXYZ {};
+ template<typename T> class XYZ {
+ NotXYZ<int> *m_int;
+ T m_t;
+ NotXYZ<T> m_notxyz;
+ public:
+ operator NotXYZ<int>*() const { return m_int; }
+ operator XYZ<int>*() const { return 0; }
+ operator Another() const { Another an; return an; }
+ void templateT(T i) {}
+ void templateNotXYZ(NotXYZ<T> i) {}
+ void templateXYZ(XYZ<T> i) {}
+ operator T() { return m_t; }
+ operator NotXYZ<T>() const { return m_notxyz; }
+ operator XYZ<T>() const { XYZ<T> xyz = XYZ<T>(); return xyz; }
+ };
+}
+
+namespace Space {
+// non-templated class using itself in method and operator
+class ABC {
+ public:
+ void method(ABC a) const {}
+ void method(Klass k) const {}
+ operator ABC() const { ABC a; return a; }
+ operator Klass() const { Klass k; return k; }
+};
+}
+
diff --git a/trunk/Examples/test-suite/rename1.i b/trunk/Examples/test-suite/rename1.i
new file mode 100644
index 000000000..38af2b3bd
--- /dev/null
+++ b/trunk/Examples/test-suite/rename1.i
@@ -0,0 +1,63 @@
+// Test %rename directive in global namespace by fully qualifying types
+%module rename1
+
+// Note: Space:: qualifier
+%rename(opIntPtrA) Space::XYZ::operator NotXYZ<int>*() const;
+%rename(opIntPtrB) Space::XYZ::operator XYZ<int>*() const;
+
+%rename(opAnother1) Space::XYZ::operator Another() const;
+%rename(opAnother2) Space::XYZ<int>::operator Another() const;
+%rename(opAnother3) Space::XYZ<Space::Klass>::operator Another() const;
+%rename(opAnother4) Space::XYZ<Space::Enu>::operator Another() const;
+
+%rename(tMethod1) Space::XYZ::templateT(T i);
+%rename(tMethod2) Space::XYZ<int>::templateT(int i);
+%rename(tMethod3) Space::XYZ<Space::Klass>::templateT(Space::Klass i);
+%rename(tMethod4) Space::XYZ<Space::Enu>::templateT(Space::Enu i);
+
+%rename(tMethodNotXYZ1) Space::XYZ::templateNotXYZ(NotXYZ<T>);
+%rename(tMethodNotXYZ2) Space::XYZ<int>::templateNotXYZ(NotXYZ<int>);
+%rename(tMethodNotXYZ3) Space::XYZ<Space::Klass>::templateNotXYZ(NotXYZ<Space::Klass>);
+%rename(tMethodNotXYZ4) Space::XYZ<Space::Enu>::templateNotXYZ(NotXYZ<Space::Enu>);
+
+%rename(tMethodXYZ1) Space::XYZ::templateXYZ(XYZ<T>);
+%rename(tMethodXYZ2) Space::XYZ<int>::templateXYZ(XYZ<int>);
+%rename(tMethodXYZ3) Space::XYZ<Space::Klass>::templateXYZ(XYZ<Space::Klass>);
+%rename(tMethodXYZ4) Space::XYZ<Space::Enu>::templateXYZ(XYZ<Space::Enu>);
+
+%rename(opT1) Space::XYZ::operator T();
+%rename(opT2) Space::XYZ<int>::operator int();
+%rename(opT3) Space::XYZ<Space::Klass>::operator Space::Klass();
+%rename(opT4) Space::XYZ<Space::Enu>::operator Space::Enu();
+
+%rename(opNotXYZ1) Space::XYZ::operator NotXYZ<T>() const;
+%rename(opNotXYZ2) Space::XYZ<int>::operator NotXYZ<int>() const;
+%rename(opNotXYZ3) Space::XYZ<Space::Klass>::operator NotXYZ<Space::Klass>() const;
+%rename(opNotXYZ4) Space::XYZ<Space::Enu>::operator NotXYZ<Space::Enu>() const;
+
+%rename(opXYZ1) Space::XYZ::operator XYZ<T>() const;
+%rename(opXYZ2) Space::XYZ<int>::operator XYZ<int>() const;
+%rename(opXYZ3) Space::XYZ<Space::Klass>::operator XYZ<Space::Klass>() const;
+%rename(opXYZ4) Space::XYZ<Space::Enu>::operator XYZ<Space::Enu>() const;
+
+
+%rename(methodABC) Space::ABC::method(ABC a) const;
+%rename(opABC) Space::ABC::operator ABC() const;
+%rename(methodKlass) Space::ABC::method(Klass k) const;
+%rename(opKlass) Space::ABC::operator Klass() const;
+
+%{
+#include "rename.h"
+%}
+%include "rename.h"
+
+%template(XYZInt) Space::XYZ<int>;
+%template(XYZDouble) Space::XYZ<double>;
+%template(XYZKlass) Space::XYZ<Space::Klass>;
+%template(XYZEnu) Space::XYZ<Space::Enu>;
+
+%template(NotXYZInt) Space::NotXYZ<int>;
+%template(NotXYZDouble) Space::NotXYZ<double>;
+%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
+%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
+
diff --git a/trunk/Examples/test-suite/rename2.i b/trunk/Examples/test-suite/rename2.i
new file mode 100644
index 000000000..6a9c22ecf
--- /dev/null
+++ b/trunk/Examples/test-suite/rename2.i
@@ -0,0 +1,65 @@
+// Test %rename directive in the Space namespace
+%module rename2
+
+namespace Space {
+// Note: no Space:: qualifier
+%rename(opIntPtrA) XYZ::operator NotXYZ<int>*() const;
+%rename(opIntPtrB) XYZ::operator XYZ<int>*() const;
+
+%rename(opAnother1) XYZ::operator Another() const;
+%rename(opAnother2) XYZ<int>::operator Another() const;
+%rename(opAnother3) XYZ<Space::Klass>::operator Another() const;
+%rename(opAnother4) XYZ<Space::Enu>::operator Another() const;
+
+%rename(tMethod1) XYZ::templateT(T i);
+%rename(tMethod2) XYZ<int>::templateT(int i);
+%rename(tMethod3) XYZ<Space::Klass>::templateT(Space::Klass i);
+%rename(tMethod4) XYZ<Space::Enu>::templateT(Space::Enu i);
+
+%rename(tMethodNotXYZ1) XYZ::templateNotXYZ(NotXYZ<T>);
+%rename(tMethodNotXYZ2) XYZ<int>::templateNotXYZ(NotXYZ<int>);
+%rename(tMethodNotXYZ3) XYZ<Space::Klass>::templateNotXYZ(NotXYZ<Space::Klass>);
+%rename(tMethodNotXYZ4) XYZ<Space::Enu>::templateNotXYZ(NotXYZ<Space::Enu>);
+
+%rename(tMethodXYZ1) XYZ::templateXYZ(XYZ<T>);
+%rename(tMethodXYZ2) XYZ<int>::templateXYZ(XYZ<int>);
+%rename(tMethodXYZ3) XYZ<Space::Klass>::templateXYZ(XYZ<Space::Klass>);
+%rename(tMethodXYZ4) XYZ<Space::Enu>::templateXYZ(XYZ<Space::Enu>);
+
+%rename(opT1) XYZ::operator T();
+%rename(opT2) XYZ<int>::operator int();
+%rename(opT3) XYZ<Space::Klass>::operator Space::Klass();
+%rename(opT4) XYZ<Space::Enu>::operator Space::Enu();
+
+%rename(opNotXYZ1) XYZ::operator NotXYZ<T>() const;
+%rename(opNotXYZ2) XYZ<int>::operator NotXYZ<int>() const;
+%rename(opNotXYZ3) XYZ<Space::Klass>::operator NotXYZ<Space::Klass>() const;
+%rename(opNotXYZ4) XYZ<Space::Enu>::operator NotXYZ<Space::Enu>() const;
+
+%rename(opXYZ1) XYZ::operator XYZ<T>() const;
+%rename(opXYZ2) XYZ<int>::operator XYZ<int>() const;
+%rename(opXYZ3) XYZ<Space::Klass>::operator XYZ<Space::Klass>() const;
+%rename(opXYZ4) XYZ<Space::Enu>::operator XYZ<Space::Enu>() const;
+
+
+%rename(methodABC) ABC::method(ABC a) const;
+%rename(opABC) ABC::operator ABC() const;
+%rename(methodKlass) ABC::method(Klass k) const;
+%rename(opKlass) ABC::operator Klass() const;
+}
+
+%{
+#include "rename.h"
+%}
+%include "rename.h"
+
+%template(XYZInt) Space::XYZ<int>;
+%template(XYZDouble) Space::XYZ<double>;
+%template(XYZKlass) Space::XYZ<Space::Klass>;
+%template(XYZEnu) Space::XYZ<Space::Enu>;
+
+%template(NotXYZInt) Space::NotXYZ<int>;
+%template(NotXYZDouble) Space::NotXYZ<double>;
+%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
+%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
+
diff --git a/trunk/Examples/test-suite/rename3.i b/trunk/Examples/test-suite/rename3.i
new file mode 100644
index 000000000..b39979fdd
--- /dev/null
+++ b/trunk/Examples/test-suite/rename3.i
@@ -0,0 +1,75 @@
+// Test %rename directive within %extend
+%module rename3
+
+namespace Space {
+ // Note no namespace nor class qualification
+ %extend XYZ {
+ %rename(opIntPtrA) operator NotXYZ<int>*() const;
+ %rename(opIntPtrB) operator XYZ<int>*() const;
+ }
+
+ %extend XYZ {
+ // Note use of type T
+ %rename(opAnother1) operator Another() const;
+ %rename(tMethod1) templateT(T i);
+ %rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ<T>);
+ %rename(tMethodXYZ1) templateXYZ(XYZ<T>);
+ %rename(opT1) operator T();
+ %rename(opNotXYZ1) operator NotXYZ<T>() const;
+ %rename(opXYZ1) operator XYZ<T>() const;
+ }
+
+ %extend XYZ<int> {
+ %rename(opAnother2) operator Another() const;
+ %rename(tMethod2) templateT(int i);
+ %rename(tMethodNotXYZ2) templateNotXYZ(NotXYZ<int>);
+ %rename(tMethodXYZ2) templateXYZ(XYZ<int>);
+ %rename(opT2) operator int();
+ %rename(opNotXYZ2) operator NotXYZ<int>() const;
+ %rename(opXYZ2) operator XYZ<int>() const;
+ }
+
+ %extend XYZ<Space::Klass> {
+ %rename(opAnother3) operator Another() const;
+ %rename(tMethod3) templateT(Space::Klass i);
+ %rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ<Space::Klass>);
+ %rename(tMethodXYZ3) templateXYZ(XYZ<Space::Klass>);
+ %rename(opT3) operator Space::Klass();
+ %rename(opNotXYZ3) operator NotXYZ<Space::Klass>() const;
+ %rename(opXYZ3) operator XYZ<Space::Klass>() const;
+ }
+
+ %extend XYZ<Space::Enu> {
+ %rename(opAnother4 )operator Another() const;
+ %rename(tMethod4) templateT(Space::Enu i);
+ %rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ<Space::Enu>);
+ %rename(tMethodXYZ4) templateXYZ(XYZ<Space::Enu>);
+ %rename(opT4) operator Space::Enu();
+ %rename(opNotXYZ4) operator NotXYZ<Space::Enu>() const;
+ %rename(opXYZ4) operator XYZ<Space::Enu>() const;
+ }
+
+
+ %extend ABC {
+ %rename(methodABC) method(ABC a) const;
+ %rename(opABC) operator ABC() const;
+ %rename(methodKlass) method(Klass k) const;
+ %rename(opKlass) operator Klass() const;
+ }
+}
+
+%{
+#include "rename.h"
+%}
+%include "rename.h"
+
+%template(XYZInt) Space::XYZ<int>;
+%template(XYZDouble) Space::XYZ<double>;
+%template(XYZKlass) Space::XYZ<Space::Klass>;
+%template(XYZEnu) Space::XYZ<Space::Enu>;
+
+%template(NotXYZInt) Space::NotXYZ<int>;
+%template(NotXYZDouble) Space::NotXYZ<double>;
+%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
+%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
+
diff --git a/trunk/Examples/test-suite/rename4.i b/trunk/Examples/test-suite/rename4.i
new file mode 100644
index 000000000..3f61e0c69
--- /dev/null
+++ b/trunk/Examples/test-suite/rename4.i
@@ -0,0 +1,108 @@
+// Test %rename directive with the 'using' keyword and within the class definition
+%module rename4
+
+%{
+#include "rename.h"
+%}
+
+namespace Space {
+struct Klass {
+ Klass(int i) {}
+ Klass() {}
+};
+}
+
+namespace AnotherSpace {
+ class Another {};
+}
+
+namespace Space {
+ %rename(opAnother1) XYZ::operator Another() const;
+ %rename(opAnother2) XYZ<int>::operator Another() const;
+ %rename(opAnother3) XYZ<Space::Klass>::operator Another() const;
+ %rename(opAnother4) XYZ<Space::Enu>::operator Another() const;
+}
+
+// Test %rename - no namespace, but specific templated type in the parameter, is used over the generic type T
+%rename(tMethod2) templateT(int i);
+%rename(tMethodNotXYZ2) templateNotXYZ(NotXYZ<int>);
+%rename(tMethodXYZ2) templateXYZ(XYZ<int>);
+%rename(opT2) operator int();
+%rename(opNotXYZ2) operator NotXYZ<int>() const;
+%rename(opXYZ2) operator XYZ<int>() const;
+
+%rename(tMethod3) templateT(Space::Klass i);
+%rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ<Space::Klass>);
+%rename(tMethodXYZ3) templateXYZ(XYZ<Space::Klass>);
+%rename(opT3) operator Space::Klass();
+%rename(opNotXYZ3) operator NotXYZ<Space::Klass>() const;
+%rename(opXYZ3) operator XYZ<Space::Klass>() const;
+
+%rename(tMethod4) templateT(Space::Enu i);
+%rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ<Space::Enu>);
+%rename(tMethodXYZ4) templateXYZ(XYZ<Space::Enu>);
+%rename(opT4) operator Space::Enu();
+%rename(opNotXYZ4) operator NotXYZ<Space::Enu>() const;
+%rename(opXYZ4) operator XYZ<Space::Enu>() const;
+
+namespace Space {
+ using namespace AnotherSpace;
+ enum Enu { En1, En2, En3 };
+ template<typename T> struct NotXYZ {};
+ template<typename T> class XYZ {
+
+ // Test %rename within the class
+ %rename(opIntPtrA) operator NotXYZ<int>*() const;
+ %rename(opIntPtrB) operator XYZ<int>*() const;
+
+ %rename(tMethod1) templateT(T i);
+ %rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ<T>);
+ %rename(tMethodXYZ1) templateXYZ(XYZ<T>);
+ %rename(opT1) operator T();
+ %rename(opNotXYZ1) operator NotXYZ<T>() const;
+ %rename(opXYZ1) operator XYZ<T>() const;
+
+ NotXYZ<int> *m_int;
+ T m_t;
+ NotXYZ<T> m_notxyz;
+ public:
+ operator NotXYZ<int>*() const { return m_int; }
+ operator XYZ<int>*() const { return 0; }
+ operator Another() const { Another an; return an; }
+ void templateT(T i) {}
+ void templateNotXYZ(NotXYZ<T> i) {}
+ void templateXYZ(XYZ<T> i) {}
+ operator T() { return m_t; }
+ operator NotXYZ<T>() const { return m_notxyz; }
+ operator XYZ<T>() const { XYZ<T> xyz; return xyz; }
+ };
+}
+
+namespace Space {
+// non-templated class using itself in method and operator
+class ABC {
+ public:
+
+ %rename(methodABC) method(ABC a) const;
+ %rename(opABC) operator ABC() const;
+ %rename(methodKlass) method(Klass k) const;
+ %rename(opKlass) operator Klass() const;
+
+ void method(ABC a) const {}
+ void method(Klass k) const {}
+ operator ABC() const { ABC a; return a; }
+ operator Klass() const { Klass k; return k; }
+};
+}
+
+
+%template(XYZInt) Space::XYZ<int>;
+%template(XYZDouble) Space::XYZ<double>;
+%template(XYZKlass) Space::XYZ<Space::Klass>;
+%template(XYZEnu) Space::XYZ<Space::Enu>;
+
+%template(NotXYZInt) Space::NotXYZ<int>;
+%template(NotXYZDouble) Space::NotXYZ<double>;
+%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
+%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
+
diff --git a/trunk/Examples/test-suite/rename_camel.i b/trunk/Examples/test-suite/rename_camel.i
new file mode 100644
index 000000000..54f06f967
--- /dev/null
+++ b/trunk/Examples/test-suite/rename_camel.i
@@ -0,0 +1,68 @@
+%module rename_camel
+
+%rename("%(utitle)s",%$isfunction,%$ismember) "";
+%rename("%(ctitle)s",%$isvariable,%$ismember) "";
+
+%inline {
+ struct GeometryFactory
+ {
+ void createPointFromInternalCoord(int);
+ void BIG_METHOD(int);
+ };
+
+ class ByteOrderValues {
+
+ public:
+ void readHEX();
+ static int ENDIAN_BIG;
+ };
+
+}
+
+
+%define SedCmd "%(command:sed -e 's/\([a-z]\)/\U\\1/' -e 's/\(_\)\([a-z]\)/\U\\2/g' <<<)s" %enddef
+
+%rename(CamelCase1) camel_case_1;
+%rename(SedCmd) camel_case_2;
+%rename("%(ctitle)s") camel_case_3;
+
+
+%rename("%(utitle)s") CamelCase_5;
+
+%define awk_cmd "%(command:awk '/^i/{print toupper($1)}' <<<)s" %enddef
+
+%rename(awk_cmd) "";
+
+%rename("%(title)s",rxsmatch$parentNode$type="enum .*") "";
+
+%inline
+{
+ int camel_case_1(int);
+ int camel_case_2(int);
+ int camel_case_3(int);
+ int camel_case_4(int);
+ int camel_case(int);
+ int CamelCase_5(int);
+ int also_works_here(int);
+
+ enum HelloEnum {
+ hello, hi_there
+ };
+
+
+ enum ChaoEnum {
+ bye, see_you
+ };
+
+ int import(int);
+ int foo(int);
+
+}
+
+%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) "";
+%inline {
+ void GSL_Hello() {}
+}
+
+
+
diff --git a/trunk/Examples/test-suite/rename_scope.i b/trunk/Examples/test-suite/rename_scope.i
new file mode 100644
index 000000000..9a09949c4
--- /dev/null
+++ b/trunk/Examples/test-suite/rename_scope.i
@@ -0,0 +1,68 @@
+%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>;
+ }
+}
+
+%rename("equals") operator==;
+
+%inline %{
+
+ namespace Utilities {
+ class Bucket
+ {
+ public:
+ Bucket() : m_left(0) {}
+ friend bool operator==(const Bucket& lhs, const Bucket& rhs){
+ return ( rhs.m_left == lhs.m_left );
+ }
+ private:
+ int m_left;
+ };
+ }
+
+%}
diff --git a/trunk/Examples/test-suite/rename_strip_encoder.i b/trunk/Examples/test-suite/rename_strip_encoder.i
new file mode 100644
index 000000000..691173b02
--- /dev/null
+++ b/trunk/Examples/test-suite/rename_strip_encoder.i
@@ -0,0 +1,16 @@
+%module rename_strip_encoder
+
+// strip the wx prefix from all identifiers
+%rename("%(strip:[wx])s") "";
+
+%inline %{
+
+class wxSomeWidget {
+};
+
+struct wxAnotherWidget {
+ void wxDoSomething() {}
+};
+
+
+%}
diff --git a/trunk/Examples/test-suite/restrict_cplusplus.i b/trunk/Examples/test-suite/restrict_cplusplus.i
new file mode 100644
index 000000000..4e4bfc277
--- /dev/null
+++ b/trunk/Examples/test-suite/restrict_cplusplus.i
@@ -0,0 +1,7 @@
+%module restrict_cplusplus
+
+%inline %{
+struct Foo {
+ int restrict;
+};
+%}
diff --git a/trunk/Examples/test-suite/ret_by_value.i b/trunk/Examples/test-suite/ret_by_value.i
new file mode 100644
index 000000000..c69ade3d6
--- /dev/null
+++ b/trunk/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(SWIGWARN_RUBY_WRONG_NAME) test; /* Ruby, wrong class name */
+
+%inline %{
+
+typedef struct {
+ int myInt;
+ short myShort;
+} test;
+
+test get_test() {
+ test myTest = {100, 200};
+ return myTest;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/return_const_value.i b/trunk/Examples/test-suite/return_const_value.i
new file mode 100644
index 000000000..1d688d175
--- /dev/null
+++ b/trunk/Examples/test-suite/return_const_value.i
@@ -0,0 +1,45 @@
+/* This test a return by value constant SWIGTYPE.
+It was reported in bug 899332 by Jermey Brown (jhbrown94) */
+
+%module return_const_value
+
+
+%inline %{
+
+class Foo {
+public:
+ int _val;
+ Foo(int x): _val(x) {}
+ int getVal() const {
+ return _val;
+ }
+};
+
+class Foo_ptr {
+ Foo *_ptr;
+ mutable bool _own;
+
+public:
+ Foo_ptr(Foo *p, bool own = false): _ptr(p), _own(own) {}
+ static Foo_ptr getPtr() {
+ return Foo_ptr(new Foo(17), true);
+ }
+ static const Foo_ptr getConstPtr() {
+ return Foo_ptr(new Foo(17), true);
+ }
+ const Foo *operator->() {
+ return _ptr;
+ }
+
+ Foo_ptr(const Foo_ptr& f) : _ptr(f._ptr), _own(f._own)
+ {
+ f._own = 0;
+ }
+
+
+ ~Foo_ptr() {
+ if(_own) delete _ptr;
+ }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/return_value_scope.i b/trunk/Examples/test-suite/return_value_scope.i
new file mode 100644
index 000000000..d7d97a10a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/rname.i b/trunk/Examples/test-suite/rname.i
new file mode 100644
index 000000000..dde71f203
--- /dev/null
+++ b/trunk/Examples/test-suite/rname.i
@@ -0,0 +1,57 @@
+// 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;
+
+/* Rename base class method applies to derived classes too */#
+%rename (newname) Base::oldname(double d) const;
+
+/* Rename derived class method only */
+%rename (func) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
+
+%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(){};
+ void fn(Base baseValue, Base* basePtr, Base& baseRef){}
+ virtual const char * oldname(double d) const { return (char*) "Base"; }
+};
+class Derived : public Base {
+public:
+ Derived(){}
+ ~Derived(){}
+ void fn(Base baseValue, Base* basePtr, Base& baseRef){}
+ virtual const char * oldname(double d) const { return (char*) "Derived"; }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/ruby/Makefile.in b/trunk/Examples/test-suite/ruby/Makefile.in
new file mode 100644
index 000000000..27996616e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/Makefile.in
@@ -0,0 +1,71 @@
+#######################################################################
+# Makefile for ruby test-suite
+#######################################################################
+
+LANGUAGE = ruby
+RUBY = @RUBY@
+SCRIPTSUFFIX = _runme.rb
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+CPP_TEST_CASES = \
+ li_cdata \
+ li_cstring \
+ li_factory \
+ li_std_functors \
+ li_std_multimap \
+ li_std_pair_lang_object \
+ li_std_queue \
+ li_std_set \
+ li_std_stack \
+ primitive_types \
+ ruby_keywords \
+ ruby_naming \
+ ruby_track_objects \
+ ruby_track_objects_directors \
+ std_containers
+# ruby_li_std_speed
+# stl_new
+
+C_TEST_CASES += \
+ li_cdata \
+ li_cstring
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+SWIGOPT += -w801 -noautorename -features autodoc=4
+
+# Custom tests - tests with additional commandline options
+ruby_naming.cpptest: SWIGOPT += -autorename
+
+# 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ruby_clean
diff --git a/trunk/Examples/test-suite/ruby/README b/trunk/Examples/test-suite/ruby/README
new file mode 100644
index 000000000..c4ace93e6
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/ruby/abstract_access_runme.rb b/trunk/Examples/test-suite/ruby/abstract_access_runme.rb
new file mode 100755
index 000000000..6f91702c9
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_access_runme.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'abstract_access'
+
+include Abstract_access
+
+begin
+ a = A.new
+rescue TypeError
+ swig_assert(true, binding, 'A.new')
+end
+
+begin
+ b = B.new
+rescue TypeError
+ swig_assert(true, binding, 'B.new')
+end
+
+begin
+ c = C.new
+rescue TypeError
+ swig_assert(true, binding, 'C.new')
+end
+
+swig_assert( 'D.new' )
+
diff --git a/trunk/Examples/test-suite/ruby/abstract_inherit_ok_runme.rb b/trunk/Examples/test-suite/ruby/abstract_inherit_ok_runme.rb
new file mode 100644
index 000000000..1d6899317
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_inherit_ok_runme.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'abstract_inherit_ok'
+
+include Abstract_inherit_ok
+
+#
+# Shouldn't be able to instantiate Foo, because it declares
+# a pure virtual function.
+#
+
+exceptionRaised = false
+begin
+ Foo.new
+rescue NameError
+ exceptionRaised = true
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Abstract_inherit_ok::Foo
+ exceptionRaised = true
+ensure
+ swig_assert( "exceptionRaised", binding )
+end
+
+#
+# This one's OK since we cleared it with a %feature("notabstract")
+# declaration in the interface file.
+#
+
+exceptionRaised = false
+begin
+ spam = Spam.new
+ raise RuntimeError unless spam.blah == 0
+rescue NameError
+ exceptionRaised = true
+ensure
+ swig_assert( "!exceptionRaised", binding )
+end
+
diff --git a/trunk/Examples/test-suite/ruby/abstract_inherit_runme.rb b/trunk/Examples/test-suite/ruby/abstract_inherit_runme.rb
new file mode 100644
index 000000000..c9cef7d5b
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_inherit_runme.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'abstract_inherit'
+
+include Abstract_inherit
+
+#
+# Shouldn't be able to instantiate any of these classes
+# since none of them implements the pure virtual function
+# declared in the base class (Foo).
+#
+
+exceptionRaised = false
+begin
+ Foo.new
+rescue NameError
+ exceptionRaised = true
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Abstract_inherit::Foo
+ exceptionRaised = true
+ensure
+ swig_assert( "exceptionRaised", binding )
+end
+
+exceptionRaised = false
+begin
+ Bar.new
+rescue NameError
+ exceptionRaised = true
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Abstract_inherit::Bar
+ exceptionRaised = true
+ensure
+ swig_assert( "exceptionRaised", binding )
+end
+
+exceptionRaised = false
+begin
+ Spam.new
+rescue NameError
+ exceptionRaised = true
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Abstract_inherit::Spam
+ exceptionRaised = true
+ensure
+ swig_assert( "exceptionRaised", binding )
+end
+
+
diff --git a/trunk/Examples/test-suite/ruby/abstract_signature_runme.rb b/trunk/Examples/test-suite/ruby/abstract_signature_runme.rb
new file mode 100644
index 000000000..8c090a70d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_signature_runme.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'abstract_signature'
+
+include Abstract_signature
+
+#
+# Shouldn't be able to instantiate Abstract_foo, because it declares
+# a pure virtual function.
+#
+
+exceptionRaised = false
+begin
+ foo = Abstract_foo.new
+ begin
+ foo.meth(1)
+ rescue RuntimeError
+ # here we are using directors
+ exceptionRaised = true
+ end
+rescue NameError
+ exceptionRaised = true
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Abstract_signature::Abstract_foo
+ exceptionRaised = true
+ensure
+ swig_assert( "exceptionRaised", binding)
+end
+
+#
+# Shouldn't be able to instantiate an Abstract_bar either, because it doesn't
+# implement the pure virtual function with the correct signature.
+#
+
+exceptionRaised = false
+begin
+ bar = Abstract_bar.new
+ begin
+ bar.meth(1)
+ rescue RuntimeError
+ # here we are using directors
+ exceptionRaised = true
+ end
+rescue NameError
+ exceptionRaised = true
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Abstract_signature::Abstract_bar
+ exceptionRaised = true
+ensure
+ swig_assert( "exceptionRaised", binding)
+end
+
diff --git a/trunk/Examples/test-suite/ruby/abstract_typedef2_runme.rb b/trunk/Examples/test-suite/ruby/abstract_typedef2_runme.rb
new file mode 100644
index 000000000..8c7d43f7a
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_typedef2_runme.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'abstract_typedef2'
+
+include Abstract_typedef2
+
+swig_assert( 'a = A_UF.new' )
+
+
diff --git a/trunk/Examples/test-suite/ruby/abstract_typedef_runme.rb b/trunk/Examples/test-suite/ruby/abstract_typedef_runme.rb
new file mode 100644
index 000000000..100f089d1
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_typedef_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'abstract_typedef'
+
+include Abstract_typedef
+
+swig_assert_each_line(<<'EOF', binding)
+
+e = Engine.new
+a = A.new
+a.write(e)
+
+EOF
+
diff --git a/trunk/Examples/test-suite/ruby/abstract_virtual_runme.rb b/trunk/Examples/test-suite/ruby/abstract_virtual_runme.rb
new file mode 100644
index 000000000..08fb43b66
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/abstract_virtual_runme.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'abstract_virtual'
+
+include Abstract_virtual
+
+swig_assert('d = D.new')
+swig_assert('e = E.new')
diff --git a/trunk/Examples/test-suite/ruby/access_change_runme.rb b/trunk/Examples/test-suite/ruby/access_change_runme.rb
new file mode 100755
index 000000000..5b3e99c58
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/access_change_runme.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'access_change'
+
+
+#
+# this test will currently fail, as it exposes functions that were
+# made protected from public. swig limitation for now.
+#
+exit(0)
+
+include Access_change
+
+klass = BaseInt.new
+public = ['PublicProtectedPublic1', 'PublicProtectedPublic2',
+ 'PublicProtectedPublic3', 'PublicProtectedPublic4']
+methods = (klass.public_methods - Object.methods).sort
+pmethods = (klass.protected_methods - Object.methods).sort
+swig_assert( methods == public,
+ " incorrect public methods for BaseInt\n" +
+ "#{methods.inspect} !=\n#{public.inspect}" )
+
+klass = DerivedInt.new
+public = ['PublicProtectedPublic3', 'PublicProtectedPublic4',
+ 'WasProtected1', 'WasProtected2', 'WasProtected3', 'WasProtected4']
+methods = (klass.public_methods - Object.methods).sort
+swig_assert( methods == public,
+ " incorrect public methods for DerivedInt\n" +
+ "#{methods.inspect} !=\n#{public.inspect}" )
+
+klass = BottomInt.new
+public = ['PublicProtectedPublic1', 'PublicProtectedPublic2',
+ 'PublicProtectedPublic3', 'PublicProtectedPublic4',
+ 'WasProtected1', 'WasProtected2']
+methods = (klass.public_methods - Object.methods).sort
+swig_assert( methods == public,
+ " incorrect public methods for BottomInt\n" +
+ "#{methods.inspect} !=\n#{public.inspect}" )
diff --git a/trunk/Examples/test-suite/ruby/add_link_runme.rb b/trunk/Examples/test-suite/ruby/add_link_runme.rb
new file mode 100755
index 000000000..8f726d27a
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/add_link_runme.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'add_link'
+include Add_link
+
+#
+# This test currently fails due to swig
+#
+exit(0)
+
+swig_assert( 'Foo.new' )
+swig_assert( 'Foo.blah' )
diff --git a/trunk/Examples/test-suite/ruby/aggregate_runme.rb b/trunk/Examples/test-suite/ruby/aggregate_runme.rb
new file mode 100644
index 000000000..4849fd185
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/aggregate_runme.rb
@@ -0,0 +1,37 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'aggregate'
+
+include Aggregate
+
+# Confirm that move() returns correct results under normal use
+result = move(UP)
+raise RuntimeError unless (result == UP)
+
+result = move(DOWN)
+raise RuntimeError unless (result == DOWN)
+
+result = move(LEFT)
+raise RuntimeError unless (result == LEFT)
+
+result = move(RIGHT)
+raise RuntimeError unless (result == RIGHT)
+
+# Confirm that it raises an exception when the contract is violated
+failed = false
+begin
+ move(0)
+rescue RuntimeError
+ failed = true
+end
+raise RuntimeError unless failed
+
diff --git a/trunk/Examples/test-suite/ruby/anonymous_bitfield_runme.rb b/trunk/Examples/test-suite/ruby/anonymous_bitfield_runme.rb
new file mode 100755
index 000000000..6949a3f28
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/anonymous_bitfield_runme.rb
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'anonymous_bitfield'
+
+include Anonymous_bitfield
+
+foo = Foo.new
+
+{'x' => 4,
+ 'y' => 3,
+ 'f' => 1,
+ 'z' => 8,
+ 'seq' => 3 }.each do |m, v|
+ foo.send("#{m}=", v)
+ val = foo.send(m)
+ swig_assert("val == v", binding)
+end
+
+{'x' => (1 << 4),
+ 'y' => (1 << 4),
+ 'f' => (1 << 1),
+ 'z' => (1 << 16),
+ 'seq' => (1 << (4*8-6)) }.each do |m, v|
+ foo.send("#{m}=", v)
+ val = foo.send(m)
+ swig_assert("val != v", binding)
+end
diff --git a/trunk/Examples/test-suite/ruby/apply_signed_char_runme.rb b/trunk/Examples/test-suite/ruby/apply_signed_char_runme.rb
new file mode 100755
index 000000000..3256e1f02
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/apply_signed_char_runme.rb
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'apply_signed_char'
+
+include Apply_signed_char
+
+
+['CharValFunction', 'CCharValFunction', 'CCharRefFunction'].each do |m|
+ [ 3, -3 ].each do |v|
+ val = send( m, v )
+ swig_assert( "v == val", binding, "for #{m}")
+ end
+end
+
+{ 'globalchar' => -109,
+ 'globalconstchar' => -110,
+}.each do |k,v|
+ val = Apply_signed_char.send( k )
+ swig_assert( "v == val", binding, "for #{k}")
+end
+
+
+a = DirectorTest.new
+
+['CharValFunction', 'CCharValFunction', 'CCharRefFunction'].each do |m|
+ [ 3, -3 ].each do |v|
+ val = a.send( m, v )
+ swig_assert( "v == val", binding, "for DirectorTest.#{m}")
+ end
+end
+
+{ 'memberchar' => -111,
+ 'memberconstchar' => -112,
+}.each do |k,v|
+ val = a.send( k )
+ swig_assert( "v == val", binding, "for #{k}")
+end
diff --git a/trunk/Examples/test-suite/ruby/apply_strings_runme.rb b/trunk/Examples/test-suite/ruby/apply_strings_runme.rb
new file mode 100755
index 000000000..299b96bb6
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/apply_strings_runme.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'apply_strings'
+
+include Apply_strings
+
+begin
+ x = UcharPtr.new
+ swig_assert( fail, "UcharPtr should not be defined")
+rescue NameError
+end
+
+ptr = 'a'
+['UCharFunction', 'SCharFunction', 'CUCharFunction',
+ 'CSCharFunction'].each do |m|
+ val = Apply_strings.send(m, ptr)
+ swig_assert( "val == ptr", binding )
+end
+
+
+['CharFunction', 'CCharFunction'].each do |m|
+ begin
+ val = Apply_strings.send(m, ptr)
+ swig_assert( false, nil, "Apply_strings.#{m} should raise TypeError" )
+ rescue TypeError
+ end
+end
+
+ptr = 'a'
+foo = DirectorTest.new
+['UCharFunction', 'SCharFunction', 'CUCharFunction',
+ 'CSCharFunction'].each do |m|
+ val = foo.send(m, ptr)
+ swig_assert( "val == ptr", binding, "DirectorTest.#{m}" )
+end
+
+
+['CharFunction', 'CCharFunction'].each do |m|
+ begin
+ val = foo.send(m, ptr)
+ swig_assert( false, nil, "DirectorTest.#{m} should raise TypeError" )
+ rescue TypeError
+ end
+end
+
+
+# ary = Apply_strings.DigitsGlobalB
+# { 0 => 'A',
+# 1 => 'B',
+# 2 => 'B' }.each do |k,v|
+# val = ary[k]
+# swig_assert( val == v, "Apply_strings.DigitsGlobalB[#{k}] #{val} != #{v}")
+# end
diff --git a/trunk/Examples/test-suite/ruby/argout_runme.rb b/trunk/Examples/test-suite/ruby/argout_runme.rb
new file mode 100755
index 000000000..54cb8f30f
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/argout_runme.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'argout'
+
+include Argout
+
+swig_assert_each_line(<<'EOF', binding)
+
+t = new_intp
+intp_assign(t, 5)
+v = incp(t)
+val = intp_value(t)
+val == 6
+
+t = new_intp
+intp_assign(t, 5)
+v = incr(t)
+v == 5
+val = intp_value(t)
+val == 6
+
+t = new_intp
+intp_assign(t, 5)
+v = inctr(t)
+v == 5
+val = intp_value(t)
+val == 6
+
+EOF
+
+#
+# @todo: how to use voidhandle and handle?
+#
+
diff --git a/trunk/Examples/test-suite/ruby/array_member_runme.rb b/trunk/Examples/test-suite/ruby/array_member_runme.rb
new file mode 100644
index 000000000..686f5a3c6
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/array_member_runme.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'array_member'
+
+include Array_member
+
+f = Foo.new
+f.data = Array_member.global_data
+
+0.upto(7) { |i|
+ unless get_value(f.data, i) == get_value(Array_member.global_data, i)
+ raise RuntimeError, "Bad array assignment"
+ end
+}
+
+0.upto(7) { |i|
+ set_value(f.data, i, -i)
+}
+
+Array_member.global_data = f.data
+
+0.upto(7) { |i|
+ unless get_value(f.data, i) == get_value(Array_member.global_data, i)
+ raise RuntimeError, "Bad array assignment"
+ end
+}
+
diff --git a/trunk/Examples/test-suite/ruby/arrays_global_runme.rb b/trunk/Examples/test-suite/ruby/arrays_global_runme.rb
new file mode 100644
index 000000000..9835f2a1d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/arrays_global_runme.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'arrays_global'
+
+Arrays_global.array_i = Arrays_global.array_const_i
+
diff --git a/trunk/Examples/test-suite/ruby/arrays_runme.rb b/trunk/Examples/test-suite/ruby/arrays_runme.rb
new file mode 100755
index 000000000..749d81758
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/arrays_runme.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+#
+# Test run of arrays.i
+#
+#
+
+require 'swig_assert'
+require 'arrays'
+
+include Arrays
+
+a = SimpleStruct.new
+a.double_field = 2.0
+
+b = SimpleStruct.new
+b.double_field = 1.0
+
+# @bug: this is broken
+#
+# c = [a,b]
+# fn_taking_arrays(c)
+#
+# a = ArrayStruct.new
+# a.array_i[0] = 0
+#
diff --git a/trunk/Examples/test-suite/ruby/bools_runme.rb b/trunk/Examples/test-suite/ruby/bools_runme.rb
new file mode 100644
index 000000000..373477c7e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/bools_runme.rb
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+
+require 'bools'
+
+# bool constant check
+if (Bools::Constbool != false)
+ print "Runtime test 1 failed\n"
+ exit 1
+end
+
+# bool variables check
+if (Bools.bool1 != true)
+ print "Runtime test 2 failed\n"
+ exit 1
+end
+
+if (Bools.bool2 != false)
+ print "Runtime test 3 failed\n"
+ exit 1
+end
+
+if (Bools.value(Bools.pbool) != Bools.bool1)
+ print "Runtime test 4 failed\n"
+ exit 1
+end
+
+if (Bools.value(Bools.rbool) != Bools.bool2)
+ print "Runtime test 5 failed\n"
+ exit 1
+end
+
+if (Bools.value(Bools.const_pbool) != Bools.bool1)
+ print "Runtime test 6 failed\n"
+ exit 1
+end
+
+if (Bools.const_rbool != Bools.bool2)
+ print "Runtime test 7 failed\n"
+ exit 1
+end
+
+# bool functions check
+if (Bools.bo(false) != false)
+ print "Runtime test 8 failed\n"
+ exit 1
+end
+
+if (Bools.bo(true) != true)
+ print "Runtime test 9 failed\n"
+ exit 1
+end
+
+if (Bools.value(Bools.rbo(Bools.rbool)) != Bools.value(Bools.rbool))
+ print "Runtime test 10 failed\n"
+ exit 1
+end
+
+if (Bools.value(Bools.pbo(Bools.pbool)) != Bools.value(Bools.pbool))
+ print "Runtime test 11 failed\n"
+ exit 1
+end
+
+if (Bools.const_rbo(Bools.const_rbool) != Bools.const_rbool)
+ print "Runtime test 12 failed\n"
+ exit 1
+end
+
+if (Bools.value(Bools.const_pbo(Bools.const_pbool)) != Bools.value(Bools.const_pbool))
+ print "Runtime test 13 failed\n"
+ exit 1
+end
+
diff --git a/trunk/Examples/test-suite/ruby/cast_operator_runme.rb b/trunk/Examples/test-suite/ruby/cast_operator_runme.rb
new file mode 100755
index 000000000..4879befbf
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/cast_operator_runme.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'cast_operator'
+include Cast_operator
+
+a = A.new
+t = a.tochar
+
+swig_assert( t == 'hi' )
diff --git a/trunk/Examples/test-suite/ruby/casts_runme.rb b/trunk/Examples/test-suite/ruby/casts_runme.rb
new file mode 100755
index 000000000..d1f536d75
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/casts_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'casts'
+
+include Casts
+
+swig_assert( B.ancestors.include?(A), 'B.ancestors.include? A' )
+
+a = A.new
+a.hello
+
+b = B.new
+b.hello
+
+swig_assert( b.kind_of?( A ), ' B.kind_of? A' )
diff --git a/trunk/Examples/test-suite/ruby/char_constant_runme.rb b/trunk/Examples/test-suite/ruby/char_constant_runme.rb
new file mode 100644
index 000000000..4e9d9d59c
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/char_constant_runme.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'char_constant'
+
+
+if Char_constant::CHAR_CONSTANT != 'x'
+ raise RuntimeError, "Invalid value for CHAR_CONSTANT."
+end
+
+if Char_constant::STRING_CONSTANT != 'xyzzy'
+ raise RuntimeError, "Invalid value for STRING_CONSTANT."
+end
+
+if Char_constant::ESC_CONST != "\001"
+ raise RuntimeError, "Invalid value for ESC_CONST."
+end
+
+if Char_constant::NULL_CONST != "\000"
+ raise RuntimeError, "Invalid value for NULL_CONST."
+end
+
+if Char_constant::SPECIALCHAR != "\341" #'á'
+ raise RuntimeError, "Invalid value for SPECIALCHAR."
+end
+
diff --git a/trunk/Examples/test-suite/ruby/check_missing_tests.rb b/trunk/Examples/test-suite/ruby/check_missing_tests.rb
new file mode 100755
index 000000000..97e197e3a
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/check_missing_tests.rb
@@ -0,0 +1,53 @@
+#!/usr/bin/env ruby
+#
+# This script allows you to compare the tests in the current directory
+# (Ruby) against the tests of other languages to see which ones are missing
+#
+#
+#
+#
+#
+
+
+ignore = ['ruby','std','typemaps']
+
+curr = Dir.pwd.sub(/.*\//, '')
+
+langs = Dir.glob('../*').select { |x| File.directory?("../#{x}") }
+langs.map! { |x| x.sub(/^\.\.\/*/, '') }
+langs -= ignore
+
+# Add generic test directory, too
+langs << ''
+
+testsB = Dir.glob("*runme*").map { |x| x.sub(/\.\w+$/, '') }
+
+
+all_tests = []
+
+langs.each do |lang|
+ testsA = Dir.glob("../#{lang}/*runme*")
+ testsA.map! { |x| x.sub(/.*\/(\w+)\.\w+$/, '\1') }
+ testsA.delete_if { |x| x =~ /~$/ } # ignore emacs backups
+
+ diff = testsA - testsB
+
+ unless diff.empty?
+ puts '-'*70
+ title = !lang.empty? ? "#{lang[0,1].upcase}#{lang[1..-1]}" : 'Generic'
+ title = "Missing #{title} tests"
+ puts title
+ puts '='*title.size
+ puts diff.join(', ')
+ all_tests += diff
+ end
+
+end
+
+
+all_tests.uniq!
+
+puts '-'*70
+puts 'All missing tests'
+puts '================='
+puts all_tests.join(', ')
diff --git a/trunk/Examples/test-suite/ruby/class_ignore_runme.rb b/trunk/Examples/test-suite/ruby/class_ignore_runme.rb
new file mode 100755
index 000000000..28e432486
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/class_ignore_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/const_const_runme.rb b/trunk/Examples/test-suite/ruby/const_const_runme.rb
new file mode 100755
index 000000000..cadc73a94
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/const_const_runme.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+#
+#
+
+require 'swig_assert'
+
+require 'const_const'
+include Const_const
+
+swig_assert_each_line <<EOF
+foo(1) # 1 is unused
+EOF
+
+
diff --git a/trunk/Examples/test-suite/ruby/constover_runme.rb b/trunk/Examples/test-suite/ruby/constover_runme.rb
new file mode 100755
index 000000000..49c0c81e8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/constover_runme.rb
@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/cpp_namespace_runme.rb b/trunk/Examples/test-suite/ruby/cpp_namespace_runme.rb
new file mode 100755
index 000000000..53649faf5
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/cpp_namespace_runme.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+# 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/trunk/Examples/test-suite/ruby/default_constructor_runme.rb b/trunk/Examples/test-suite/ruby/default_constructor_runme.rb
new file mode 100755
index 000000000..2706f67ca
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/default_constructor_runme.rb
@@ -0,0 +1,153 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::BB
+ exceptionRaised = true
+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
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::BB
+ exceptionRaised = true
+end
+
+# C's constructor is protected, so this should raise an exception
+begin
+ c = C.new
+ print "Whoa. new C created."
+rescue NoConstructorError
+ # pass
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::C
+ # pass
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::C
+ # 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
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::D
+ # 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
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::DD
+ # pass
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::D
+ # pass
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::DD
+ # 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
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::AD
+ # pass
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::AD
+ # 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
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::EB
+ # pass
+rescue TypeError
+ # In Ruby 1.8 the exception raised is:
+ # TypeError: allocator undefined for Default_constructor::EB
+ # 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/trunk/Examples/test-suite/ruby/director_abstract_runme.rb b/trunk/Examples/test-suite/ruby/director_abstract_runme.rb
new file mode 100644
index 000000000..685ede1e9
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_abstract_runme.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_abstract'
+
+class MyFoo < Director_abstract::Foo
+ def ping
+ "MyFoo::ping()"
+ end
+end
+
+
+a = MyFoo.new
+
+if a.ping != "MyFoo::ping()"
+ raise RuntimeError, a.ping
+end
+
+if a.pong != "Foo::pong();MyFoo::ping()"
+ raise RuntimeError, a.pong
+end
+
+
+class MyExample1 < Director_abstract::Example1
+ def color(r,g,b)
+ r
+ end
+end
+
+#m1 = MyExample1.new
+#
+#if m1.color(1,2,3) != 1
+# raise RuntimeError, m1.color
+#end
diff --git a/trunk/Examples/test-suite/ruby/director_basic_runme.rb b/trunk/Examples/test-suite/ruby/director_basic_runme.rb
new file mode 100644
index 000000000..a9019b68d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_basic_runme.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_basic'
+
+class MyFoo < Director_basic::Foo
+ def ping
+ "MyFoo::ping()"
+ end
+end
+
+a = MyFoo.new
+
+raise RuntimeError if a.ping != "MyFoo::ping()"
+raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()"
+
+b = Director_basic::Foo.new
+
+raise RuntimeError if b.ping != "Foo::ping()"
+raise RuntimeError if b.pong != "Foo::pong();Foo::ping()"
+
+
+a = Director_basic::MyClass.new
+a = Director_basic::MyClassT_i.new
+
+
+a = Director_basic::MyClass.new 1
+a = Director_basic::MyClassT_i.new 1
diff --git a/trunk/Examples/test-suite/ruby/director_constructor_runme.rb b/trunk/Examples/test-suite/ruby/director_constructor_runme.rb
new file mode 100644
index 000000000..f83f23ec0
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_constructor_runme.rb
@@ -0,0 +1,37 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_constructor'
+
+include Director_constructor
+
+class Test < Foo
+ def initialize(i)
+ super(i)
+ end
+
+ def doubleit()
+ self.a = (self.a * 2)
+ end
+
+ def test
+ 3
+ end
+end
+
+a = Test.new(5) #dies here
+
+raise RuntimeError if a.getit != 5
+raise RuntimeError if a.do_test != 3
+
+a.doubleit
+raise RuntimeError if a.getit != 10
+
diff --git a/trunk/Examples/test-suite/ruby/director_default_runme.rb b/trunk/Examples/test-suite/ruby/director_default_runme.rb
new file mode 100644
index 000000000..355f3c779
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_default_runme.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_default'
+
+
+
+a = Director_default::Foo.new 1
+a = Director_default::Foo.new
+
+a.Msg
+a.Msg "hello"
+a.GetMsg
+a.GetMsg "hello"
+
+a = Director_default::Bar.new 1
+a = Director_default::Bar.new
+
+a.Msg
+a.Msg "hello"
+a.GetMsg
+a.GetMsg "hello"
diff --git a/trunk/Examples/test-suite/ruby/director_detect_runme.rb b/trunk/Examples/test-suite/ruby/director_detect_runme.rb
new file mode 100644
index 000000000..c1bd8adf8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_detect_runme.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_detect'
+
+class MyBar < Director_detect::Bar
+ def initialize(v)
+ @val = v
+ end
+
+ def get_value
+ @val = @val + 1
+ end
+
+ def get_class
+ @val = @val + 1
+ Director_detect::A
+ end
+
+ def just_do_it
+ @val = @val + 1
+ end
+
+ def clone
+ MyBar.new(@val)
+ end
+
+ def val
+ @val
+ end
+end
+
+
+b = MyBar.new(2)
+
+f = b
+
+v = f.get_value
+a = f.get_class
+f.just_do_it
+
+c = b.clone
+vc = c.get_value
+
+raise RuntimeError if (v != 3) || (b.val != 5) || (vc != 6)
+
diff --git a/trunk/Examples/test-suite/ruby/director_exception_runme.rb b/trunk/Examples/test-suite/ruby/director_exception_runme.rb
new file mode 100644
index 000000000..d31cd712e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_exception_runme.rb
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_exception'
+
+include Director_exception
+
+class MyFoo < Foo
+ def ping
+ raise NotImplementedError, "MyFoo::ping() EXCEPTION"
+ end
+end
+
+class MyFoo2 < Foo
+ def ping
+ nil # error: should return a string
+ end
+end
+
+class MyFoo3 < Foo
+ def ping
+ 5 # error: should return a string
+ end
+end
+
+ok = false
+
+a = MyFoo.new
+b = launder(a)
+
+begin
+ b.pong
+rescue NotImplementedError
+ ok = true
+end
+
+raise RuntimeError unless ok
+
+ok = false
+
+a = MyFoo2.new
+b = launder(a)
+
+begin
+ b.pong
+rescue TypeError
+ ok = true
+end
+
+
+a = MyFoo3.new
+b = launder(a)
+
+begin
+ b.pong
+rescue TypeError
+ ok = true
+end
+
+
+raise RuntimeError unless ok
+
diff --git a/trunk/Examples/test-suite/ruby/director_frob_runme.rb b/trunk/Examples/test-suite/ruby/director_frob_runme.rb
new file mode 100644
index 000000000..edd861c20
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_frob_runme.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_frob'
+
+foo = Director_frob::Bravo.new;
+s = foo.abs_method;
+
+raise RuntimeError if s != "Bravo::abs_method()"
diff --git a/trunk/Examples/test-suite/ruby/director_nested_runme.rb b/trunk/Examples/test-suite/ruby/director_nested_runme.rb
new file mode 100644
index 000000000..a376b0d38
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_nested_runme.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_nested'
+
+NoProtectedError = Kernel.const_defined?("NoMethodError") ? NoMethodError : NameError
+
+class A < Director_nested::FooBar_int
+ protected
+ def do_step
+ "A::do_step;"
+ end
+
+ def get_value
+ "A::get_value"
+ end
+end
+
+a = A.new
+
+begin
+ a.do_advance
+rescue NoProtectedError
+end
+
+raise RuntimeError if a.step != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;"
+
+
+class B < Director_nested::FooBar_int
+ protected
+ def do_advance
+ "B::do_advance;" + do_step
+ end
+
+ def do_step
+ "B::do_step;"
+ end
+
+ def get_value
+ "B::get_value"
+ end
+end
+
+
+b = B.new
+raise RuntimeError if b.step != "Bar::step;Foo::advance;B::do_advance;B::do_step;"
diff --git a/trunk/Examples/test-suite/ruby/director_protected_runme.rb b/trunk/Examples/test-suite/ruby/director_protected_runme.rb
new file mode 100644
index 000000000..3bee9ac77
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_protected_runme.rb
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_protected'
+
+NoProtectedError = Kernel.const_defined?("NoMethodError") ? NoMethodError : NameError
+
+class FooBar < Director_protected::Bar
+ protected
+ def ping
+ "FooBar::ping();"
+ end
+end
+
+class Hello < FooBar
+ public
+ def pang
+ ping
+ end
+end
+
+b = Director_protected::Bar.new
+fb = FooBar.new
+
+p = 0
+begin
+ b.ping
+ p = 1
+rescue NoProtectedError
+end
+
+h = Hello.new
+
+raise RuntimeError if p == 1
+raise RuntimeError if b.pong != "Bar::pong();Foo::pong();Bar::ping();"
+raise RuntimeError if fb.pong != "Bar::pong();Foo::pong();FooBar::ping();"
+raise RuntimeError if h.pang != "FooBar::ping();"
diff --git a/trunk/Examples/test-suite/ruby/director_string_runme.rb b/trunk/Examples/test-suite/ruby/director_string_runme.rb
new file mode 100644
index 000000000..a18feac3d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_string_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_string'
+
+class B < Director_string::A
+
+ def initialize(some_string)
+ super(some_string)
+ end
+end
+
+
+b = B.new("hello")
+b.get_first
+b.get(0)
diff --git a/trunk/Examples/test-suite/ruby/director_unroll_runme.rb b/trunk/Examples/test-suite/ruby/director_unroll_runme.rb
new file mode 100644
index 000000000..0545671cb
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_unroll_runme.rb
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_unroll'
+
+class MyFoo < Director_unroll::Foo
+ def ping
+ "MyFoo::ping()"
+ end
+end
+
+a = MyFoo.new
+
+b = Director_unroll::Bar.new
+
+b.set(a)
+c = b.get()
+
+raise RuntimeError if a != c
+
diff --git a/trunk/Examples/test-suite/ruby/director_wombat_runme.rb b/trunk/Examples/test-suite/ruby/director_wombat_runme.rb
new file mode 100644
index 000000000..39f4a9e61
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/director_wombat_runme.rb
@@ -0,0 +1,60 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'director_wombat'
+
+include Director_wombat
+
+# Test base class functionality
+barObj = Bar.new
+
+# Bar#meth should return a Foo_integers instance
+fooIntsObj = barObj.meth
+raise RuntimeError unless fooIntsObj.instance_of?(Foo_integers)
+
+# Foo_integers#meth(n) should return n
+raise RuntimeError if fooIntsObj.meth(42) != 42
+
+#
+# Now subclass Foo_integers, but override its virtual method
+# meth(n) so that it returns the number plus one.
+#
+class MyFooInts < Foo_integers
+ def meth(n)
+ n + 1
+ end
+end
+
+#
+# Subclass Bar and override its virtual method meth()
+# so that it returns a new MyFooInts instance instead of
+# a Foo_integers instance.
+#
+class MyBar < Bar
+ def meth
+ MyFooInts.new
+ end
+end
+
+#
+# Now repeat previous tests:
+#
+# Create a MyBar instance...
+#
+barObj = MyBar.new
+
+# MyBar#meth should return a MyFooInts instance
+fooIntsObj = barObj.meth
+raise RuntimeError unless fooIntsObj.instance_of?(MyFooInts)
+
+# MyFooInts#meth(n) should return n+1
+raise RuntimeError if fooIntsObj.meth(42) != 43
+
diff --git a/trunk/Examples/test-suite/ruby/disown_runme.rb b/trunk/Examples/test-suite/ruby/disown_runme.rb
new file mode 100644
index 000000000..60b742163
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/disown_runme.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'disown'
+
+include Disown
+
+
+a = A.new
+b = B.new
+b.acquire(a)
+
diff --git a/trunk/Examples/test-suite/ruby/dynamic_cast_runme.rb b/trunk/Examples/test-suite/ruby/dynamic_cast_runme.rb
new file mode 100755
index 000000000..8239051b1
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/dynamic_cast_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/enum_thorough_runme.rb b/trunk/Examples/test-suite/ruby/enum_thorough_runme.rb
new file mode 100755
index 000000000..e4a1ec719
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/enum_thorough_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'enum_thorough'
+
+include Enum_thorough
+
+# Just test an in and out typemap for enum SWIGTYPE and const enum SWIGTYPE & typemaps
+raise RuntimeError if speedTest4(SpeedClass::Slow) != SpeedClass::Slow
+raise RuntimeError if speedTest5(SpeedClass::Slow) != SpeedClass::Slow
+
diff --git a/trunk/Examples/test-suite/ruby/enums_runme.rb b/trunk/Examples/test-suite/ruby/enums_runme.rb
new file mode 100644
index 000000000..cafac25fa
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/enums_runme.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+#
+# Runtime tests for enums.i
+#
+
+require 'swig_assert'
+require 'enums'
+
+swig_assert_each_line( <<EOF )
+Enums::CSP_ITERATION_FWD == 0
+Enums::CSP_ITERATION_BWD == 11
+Enums::ABCDE == 0
+Enums::FGHJI == 1
+Enums.bar1(1)
+Enums.bar2(1)
+Enums.bar3(1)
+Enums::Boo == 0
+Enums::Hoo == 5
+Enums::Globalinstance1 == 0
+Enums::Globalinstance2 == 1
+Enums::Globalinstance3 == 30
+Enums::AnonEnum1 == 0
+Enums::AnonEnum2 == 100
+Enums::BAR1 == 0
+Enums::BAR2 == 1
+EOF
+
+#
+# @bug:
+#
+# swig_assert_each_line( <<EOF )
+# Enums::IFoo::Phoo == 50
+# Enums::IFoo::Char == 'a'[0]
+# EOF
diff --git a/trunk/Examples/test-suite/ruby/extend_template_ns_runme.rb b/trunk/Examples/test-suite/ruby/extend_template_ns_runme.rb
new file mode 100644
index 000000000..d0ccee328
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/extend_template_ns_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/extend_template_runme.rb b/trunk/Examples/test-suite/ruby/extend_template_runme.rb
new file mode 100644
index 000000000..62f22bc17
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/extend_template_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/friends_runme.rb b/trunk/Examples/test-suite/ruby/friends_runme.rb
new file mode 100644
index 000000000..c5c1caa01
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/friends_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'friends'
+
+
+a = Friends::A.new(2)
+
+raise RuntimeError if Friends::get_val1(a) != 2
+raise RuntimeError if Friends::get_val2(a) != 4
+raise RuntimeError if Friends::get_val3(a) != 6
diff --git a/trunk/Examples/test-suite/ruby/function_typedef_runme.rb b/trunk/Examples/test-suite/ruby/function_typedef_runme.rb
new file mode 100755
index 000000000..c17f44d19
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/function_typedef_runme.rb
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+#
+# Tests for function_typedef.i
+#
+#
+
+require 'swig_assert'
+require 'function_typedef'
+include Function_typedef
+
+# Hmm... not sure how to test this.
diff --git a/trunk/Examples/test-suite/ruby/grouping_runme.rb b/trunk/Examples/test-suite/ruby/grouping_runme.rb
new file mode 100644
index 000000000..ad60eec2e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/grouping_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/ignore_parameter_runme.rb b/trunk/Examples/test-suite/ruby/ignore_parameter_runme.rb
new file mode 100644
index 000000000..c5466a2a6
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/ignore_parameter_runme.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'ignore_parameter'
+
+include Ignore_parameter
+
+# Global function tests
+raise RuntimeError unless jaguar(0, 1.0) == "hello"
+raise RuntimeError unless lotus("foo", 1.0) == 101
+raise RuntimeError unless tvr("foo", 0) == 8.8
+raise RuntimeError unless ferrari() == 101
+
+# Member function tests
+sc = SportsCars.new
+raise RuntimeError unless sc.daimler(0, 1.0) == "hello"
+raise RuntimeError unless sc.astonmartin("foo", 1.0) == 101
+raise RuntimeError unless sc.bugatti("foo", 0) == 8.8
+raise RuntimeError unless sc.lamborghini() == 101
+
+# Constructor tests
+MiniCooper.new(0, 1.0)
+MorrisMinor.new("foo", 1.0)
+FordAnglia.new("foo", 0)
+AustinAllegro.new()
+
diff --git a/trunk/Examples/test-suite/ruby/imports_runme.rb b/trunk/Examples/test-suite/ruby/imports_runme.rb
new file mode 100755
index 000000000..8bd242e86
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/imports_runme.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+# This is the import runtime testcase.
+
+require 'imports_a'
+require 'imports_b'
+
+x = Imports_b::B.new
+
+x.hello
+
diff --git a/trunk/Examples/test-suite/ruby/inherit_missing_runme.rb b/trunk/Examples/test-suite/ruby/inherit_missing_runme.rb
new file mode 100644
index 000000000..aeaec2485
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/inherit_missing_runme.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/integers_runme.rb b/trunk/Examples/test-suite/ruby/integers_runme.rb
new file mode 100755
index 000000000..b6ca45891
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/integers_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+
+require 'swig_assert'
+require 'integers'
+include Integers
+
+swig_assert_each_line <<EOF
+signed_char_identity(-3) == -3
+unsigned_char_identity(5) == 5
+signed_short_identity(-3) == -3
+unsigned_short_identity(5) == 5
+signed_int_identity(-3) == -3
+unsigned_int_identity(5) == 5
+signed_long_identity(-3) == -3
+unsigned_long_identity(5) == 5
+signed_long_long_identity(-3) == -3
+unsigned_long_long_identity(5) == 5
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_carrays_runme.rb b/trunk/Examples/test-suite/ruby/li_carrays_runme.rb
new file mode 100644
index 000000000..97241a0f1
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_carrays_runme.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_carrays'
+
+include Li_carrays
+
+#
+# Testing for %array_functions(int,intArray)
+#
+ary = new_intArray(2)
+intArray_setitem(ary, 0, 0)
+intArray_setitem(ary, 1, 1)
+intArray_getitem(ary, 0)
+intArray_getitem(ary, 1)
+delete_intArray(ary)
+
+#
+# Testing for %array_class(double, doubleArray)
+#
+ary = DoubleArray.new(2)
+ary[0] = 0.0
+ary[1] = 1.0
+ary[0]
+ary[1]
+ptr = ary.cast
+ary2 = DoubleArray.frompointer(ptr)
+
diff --git a/trunk/Examples/test-suite/ruby/li_cstring_runme.rb b/trunk/Examples/test-suite/ruby/li_cstring_runme.rb
new file mode 100755
index 000000000..a4ffcad02
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_cstring_runme.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+#
+# Test for li_cstring.i
+#
+
+require 'swig_assert'
+require 'li_cstring'
+
+include Li_cstring
+
+swig_assert_each_line <<EOF
+count("hello", 'l'[0]) == 2
+test1 == 'Hello World'
+test2
+test3('hello') == 'hello-suffix'
+test4('hello') == 'hello-suffix'
+test5(5) == 'xxxxx'
+test6(6) == 'xxx'
+test7 == 'Hello world!'
+test8 == (32..32+63).map {|x| x.chr }.join
+EOF
+
diff --git a/trunk/Examples/test-suite/ruby/li_factory_runme.rb b/trunk/Examples/test-suite/ruby/li_factory_runme.rb
new file mode 100644
index 000000000..a638b6f49
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_factory_runme.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_factory'
+
+circle = Li_factory::Geometry.create(Li_factory::Geometry::CIRCLE)
+r = circle.radius()
+if (r != 1.5)
+ raise RuntimeError, "Invalid value for r"
+end
+
+new_circle = circle.clone()
+r = new_circle.radius()
+if (r != 1.5)
+ raise RuntimeError, "Invalid value for r"
+end
+
+point = Li_factory::Geometry.create(Li_factory::Geometry::POINT)
+w = point.width()
+
+if (w != 1.0)
+ raise RuntimeError, "Invalid value for w"
+end
+
+new_point = point.clone()
+w = new_point.width()
+
+if (w != 1.0)
+ raise RuntimeError, "Invalid value for w"
+end
diff --git a/trunk/Examples/test-suite/ruby/li_math_runme.rb b/trunk/Examples/test-suite/ruby/li_math_runme.rb
new file mode 100755
index 000000000..038278315
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_math_runme.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+#
+# li_math.i tests
+#
+#
+
+require 'swig_assert'
+require 'li_math'
+
+swig_assert_each_line <<EOF
+Li_math.cos(-5) == Math.cos(-5)
+Li_math.sin(-5) == Math.sin(-5)
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_std_deque_runme.rb b/trunk/Examples/test-suite/ruby/li_std_deque_runme.rb
new file mode 100644
index 000000000..1c1c6a8f7
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_deque_runme.rb
@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_deque'
+
+include Li_std_deque
+
+# Test constructors for std::deque<int>
+intDeque = IntDeque.new
+intDeque2 = IntDeque.new(3)
+intDeque3 = IntDeque.new(4, 42)
+intDeque4 = IntDeque.new(intDeque3)
+
+# Test constructors for std::deque<double>
+doubleDeque = DoubleDeque.new
+doubleDeque2 = DoubleDeque.new(3)
+doubleDeque3 = DoubleDeque.new(4, 42.0)
+doubleDeque4 = DoubleDeque.new(doubleDeque3)
+
+# Test constructors for std::deque<Real>
+realDeque = RealDeque.new
+realDeque2 = RealDeque.new(3)
+realDeque3 = RealDeque.new(4, 42.0)
+realDeque4 = RealDeque.new(realDeque3)
+
+# average() should return the average of all values in a std::deque<int>
+intDeque << 2
+intDeque << 4
+intDeque << 6
+avg = average(intDeque)
+raise RuntimeError if avg != 4.0
+
+#
+# half() should return a std::deque<float>, where each element is half
+# the value of the corresponding element in the input deque<float>.
+# The original deque's contents are unchanged.
+#
+realDeque.clear
+realDeque << 2.0
+halfDeque = half(realDeque)
+raise RuntimeError unless halfDeque[0] == 1.0
+
+#
+# halve_in_place() should...
+#
+halve_in_place(doubleDeque)
+
diff --git a/trunk/Examples/test-suite/ruby/li_std_functors_runme.rb b/trunk/Examples/test-suite/ruby/li_std_functors_runme.rb
new file mode 100755
index 000000000..d31735c45
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_functors_runme.rb
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby
+#
+# This is a test of STL containers using proc
+# objects to change the sorting function used in them. Same as a
+# std::binary_predicate in C++.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'li_std_functors'
+
+
+def _set(container)
+ swig_assert_each_line(<<EOF, binding)
+ cont = #{container}.new
+ [9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
+ i0 = cont.begin()
+ cont.to_a == [1,2,3,4,5,6,7,8,9]
+ cont = #{container}.new( proc { |a,b| b < a } )
+ [9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
+ cont.to_a == [9, 8, 7, 6, 5, 4, 3, 2, 1]
+ cont = #{container}.new( proc { |a,b| b > a } )
+ [9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
+ cont.to_a == [1, 2, 3, 4, 5, 6, 7, 8, 9]
+ cont = #{container}.new(proc { |a,b| b < a } )
+ cont.insert(1)
+ cont.to_a == [1]
+ i0 = cont.begin()
+ cont.erase(i0) # don't use i0 anymore, it is invalid now
+ cont.to_a == []
+EOF
+end
+
+def _map(container)
+ swig_assert_each_line(<<EOF, binding)
+ cont = #{container}.new
+ cont['z'] = 9
+ cont['y'] = 1
+ cont['x'] = 8
+ cont['w'] = 2
+ cont.to_a == [['w',2],['x',8],['y',1],['z',9]]
+
+ cont = #{container}.new(proc { |a,b| b < a } )
+ cont['z'] = 9
+ cont['y'] = 1
+ cont['x'] = 8
+ cont['w'] = 2
+ cont.to_a == [['z',9],['y',1],['x',8],['w',2]]
+EOF
+end
+
+def test
+ yield method(:_set), Li_std_functors::Set
+ yield method(:_map), Li_std_functors::Map
+end
+
+# these should fail and not segfault
+begin
+ Li_std_functors::Set.new('sd')
+rescue
+end
+
+test do |proc, container|
+ proc.call(container)
+end
+
+
diff --git a/trunk/Examples/test-suite/ruby/li_std_map_runme.rb b/trunk/Examples/test-suite/ruby/li_std_map_runme.rb
new file mode 100755
index 000000000..0ec8cac84
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_map_runme.rb
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+#
+# Tests for std::map
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'li_std_map'
+
+swig_assert_each_line(<<'EOF', binding)
+
+a1 = Li_std_map::A.new(3)
+a2 = Li_std_map::A.new(7)
+
+p0 = Li_std_map::Pairii.new(1,2)
+p1 = Li_std_map::PairA.new(1,a1)
+m = {}
+m[1] = a1
+m[2] = a2
+
+pp1 = Li_std_map::p_identa(p1)
+mm = Li_std_map::m_identa(m)
+
+m = Li_std_map::MapA.new
+m[1] = a1
+m[2] = a2
+m.respond_to?(:each_key) == true
+m.respond_to?(:each_value) == true
+
+pm ={}
+m.each_key { |k| pm[k] = m[k] }
+m.each_key { |k| swig_assert_equal("pm[k].object_id", "m[k].object_id", binding, 'only true if %trackings is on') }
+
+m = {}
+m[1] = [1,2]
+m["foo"] = "hello"
+
+pm = Li_std_map::LanguageMap.new
+m.each_key { |k| pm[k] = m[k] }
+m.each_key { |k| swig_assert_equal("pm[#{k.inspect}]", "m[#{k.inspect}]", binding) }
+EOF
+
+mii = Li_std_map::IntIntMap.new
+
+mii[1] = 1
+mii[1] = 2
+
+swig_assert( "mii[1] == 2", binding )
diff --git a/trunk/Examples/test-suite/ruby/li_std_multimap_runme.rb b/trunk/Examples/test-suite/ruby/li_std_multimap_runme.rb
new file mode 100755
index 000000000..b0c2bb359
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_multimap_runme.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+#
+# Tests for std::multimap
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'li_std_multimap'
+
+swig_assert_each_line(<<'EOF', binding)
+
+a1 = Li_std_multimap::A.new(3)
+a2 = Li_std_multimap::A.new(7)
+
+m = Li_std_multimap::MultimapA.new
+m[0] = a1
+m[0] = a2
+m[0].size == 2
+m.respond_to?(:each) == true
+m.respond_to?(:each_key) == true
+m.respond_to?(:each_value) == true
+m.values_at(0)[0] == m[0]
+EOF
+
diff --git a/trunk/Examples/test-suite/ruby/li_std_pair_lang_object_runme.rb b/trunk/Examples/test-suite/ruby/li_std_pair_lang_object_runme.rb
new file mode 100644
index 000000000..3ce2bd3f5
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_pair_lang_object_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_pair_lang_object'
+include Li_std_pair_lang_object
+
+swig_assert_each_line(<<'EOF', binding)
+val = ValuePair.new
+val.first = 'sd'
+val.second = [5,4,3]
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_std_pair_runme.rb b/trunk/Examples/test-suite/ruby/li_std_pair_runme.rb
new file mode 100755
index 000000000..685046fd2
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_pair_runme.rb
@@ -0,0 +1,57 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_pair'
+include Li_std_pair
+
+swig_assert_each_line(<<'EOF', binding)
+#
+# Because of template specializations for pair<int, int>, these should return
+# an Array of size 2, where both elements are Fixnums.
+#
+intPair = makeIntPair(7, 6)
+intPair.instance_of?(Array)
+intPair.size == 2
+intPair[0] == 7 && intPair[1] == 6
+
+intPairConstRef = makeIntPairConstRef(7, 6)
+intPairConstRef.instance_of?(Array)
+intPairConstRef[0] == 7 && intPairConstRef[1] == 6
+
+#
+# Each of these should return a reference to a wrapped
+# std::pair<int, int> object (i.e. an IntPair instance).
+#
+intPairPtr = makeIntPairPtr(7, 6)
+intPairPtr.instance_of?(IntPair)
+intPairPtr[0] == 7 && intPairPtr[1] == 6
+
+intPairRef = makeIntPairRef(7, 6)
+intPairRef.instance_of?(IntPair)
+intPairRef[0] == 7 && intPairRef[1] == 6
+#
+# Now test various input typemaps. Each of the wrapped C++ functions
+# (product1, product2 and product3) is expecting an argument of a
+# different type (see li_std_pair.i). Typemaps should be in place to
+# convert this Array into the expected argument type.
+#
+product1(intPair) == 42
+product2(intPair) == 42
+product3(intPair) == 42
+
+#
+# Similarly, each of the input typemaps should know what to do
+# with an IntPair instance.
+#
+product1(intPairPtr) == 42
+product2(intPairPtr) == 42
+product3(intPairPtr) == 42
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_std_queue_runme.rb b/trunk/Examples/test-suite/ruby/li_std_queue_runme.rb
new file mode 100755
index 000000000..63101ed6e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_queue_runme.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+#
+# A simple std::queue test
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_queue'
+include Li_std_queue
+
+swig_assert_each_line(<<'EOF', binding)
+a = IntQueue.new
+a << 1
+a << 2
+a << 3
+a.back == 3
+a.front == 1
+a.pop
+a.back == 3
+a.front == 2
+a.pop
+a.back == 3
+a.front == 3
+a.pop
+a.size == 0
+a.empty? == true
+
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_std_set_runme.rb b/trunk/Examples/test-suite/ruby/li_std_set_runme.rb
new file mode 100755
index 000000000..65354be58
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_set_runme.rb
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_set'
+include Li_std_set
+
+swig_assert_each_line(<<'EOF', binding)
+s = Set_string.new
+
+s.push("a")
+s.push("b")
+s << "c"
+
+sum = ''
+s.each { |x| sum << x }
+sum == 'abc'
+
+b = s.begin # only if swig iterators are on
+e = s.end
+sum = ''
+while b != e; sum << b.value; b.next; end
+sum == 'abc'
+
+b = s.rbegin # only if swig iterators are on
+e = s.rend
+sum = ''
+while b != e; sum << b.value; b.next; end
+sum == 'cba'
+
+
+si = Set_int.new
+si << 1
+si.push(2)
+si.push(3)
+
+i = s.begin()
+i.next()
+s.erase(i)
+s.to_s == 'ac'
+
+b = s.begin
+e = s.end
+e - b == 2
+
+m = b + 1
+m.value == 'c'
+
+s = LanguageSet.new
+s.insert([1,2])
+s.insert(1)
+s.insert("hello")
+s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash}
+
+EOF
+
diff --git a/trunk/Examples/test-suite/ruby/li_std_speed2_runme.rb b/trunk/Examples/test-suite/ruby/li_std_speed2_runme.rb
new file mode 100755
index 000000000..1c4e15f2d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_speed2_runme.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+
+require 'benchmark'
+require 'li_std_speed'
+include Li_std_speed
+
+def benchmark(f, phigh, sequences)
+ print f.class
+ puts '%10s ' % 'n' + sequences.inject('') { |a,s| a << '%10s' % s.class }
+ 0.upto(phigh-1) do |p|
+ n = 2**p
+ print "%10d"%n
+ $stdout.flush
+ for s in sequences
+ cont = s.new((0..n).to_a)
+ Benchmark.benchmark { f.call(cont) }
+ end
+ end
+end
+
+def iterate(cont)
+ # expected: O(n)
+ # got: O(n**2) for set/list (vector/deque fine)
+ it = cont.begin
+ last = cont.end
+ while it != last
+ it.next
+ end
+end
+
+
+def erase(cont)
+ # expected: O(n)
+ # got: O(n**2) for vector/deque and O(n**3) for set/list
+ it = cont.end
+ # can't reuse begin since it might get invalidated
+ while it != cont.begin
+ it.previous
+ # set returns None, so need to reobtain end
+ it = cont.erase(it) or cont.end
+ end
+end
+
+def insert(cont)
+ it = cont.end
+ size = cont.size
+ if cont.kind_of? RbSet
+ # swig stl missing hint version of insert for set
+ # expected would be O(n) with iterator hint version
+ # expected: O(n*log(n))
+ # got: O(n**3*log(n))
+ size.upto(size<<1) { |x| cont.insert(x) }
+ else
+ # expected: O(n)
+ # got: O(n**3) for list (vector/deque fine)
+ size.upto(size<<1) { |x| cont.push(x) }
+ end
+end
+
+if $0 == __FILE__
+ sequences = [RbVector,RbDeque,RbSet,RbList]
+ for f,phigh in [[method(:iterate),15], [method(:insert),15],
+ [method(:erase),11]]
+ benchmark(f, phigh, sequences)
+ end
+end
+
diff --git a/trunk/Examples/test-suite/ruby/li_std_stack_runme.rb b/trunk/Examples/test-suite/ruby/li_std_stack_runme.rb
new file mode 100755
index 000000000..806bba029
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_stack_runme.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+#
+# A simple std::stack test
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_stack'
+include Li_std_stack
+
+swig_assert_each_line(<<'EOF', binding)
+a = IntStack.new
+a << 1
+a << 2
+a << 3
+a.top == 3
+a.pop
+a.top == 2
+a.pop
+a.top == 1
+a.pop
+a.size == 0
+a.empty? == true
+# a.top == Qnil
+
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_std_stream_runme.rb b/trunk/Examples/test-suite/ruby/li_std_stream_runme.rb
new file mode 100755
index 000000000..80c5166f3
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_stream_runme.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+#
+# Simple test of std::ostringstream.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_stream'
+include Li_std_stream
+
+swig_assert_each_line(<<'EOF', binding)
+
+a = A.new
+o = Ostringstream.new
+o << a << " " << 2345 << " " << 1.435
+o.str == "A class 2345 1.435"
+
+EOF
diff --git a/trunk/Examples/test-suite/ruby/li_std_string_runme.rb b/trunk/Examples/test-suite/ruby/li_std_string_runme.rb
new file mode 100644
index 000000000..dc85b5dab
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_string_runme.rb
@@ -0,0 +1,144 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_string'
+
+include Li_std_string
+
+# Checking expected use of %typemap(in) std::string {}
+test_value("Fee")
+
+# Checking expected result of %typemap(out) std::string {}
+raise RuntimeError unless test_value("Fi") == "Fi"
+
+# Verify type-checking for %typemap(in) std::string {}
+exceptionRaised = false
+begin
+ test_value(0)
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+# Checking expected use of %typemap(in) const std::string & {}
+test_const_reference("Fo")
+
+# Checking expected result of %typemap(out) const std::string& {}
+raise RuntimeError unless test_const_reference("Fum") == "Fum"
+
+# Verify type-checking for %typemap(in) const std::string & {}
+exceptionRaised = false
+begin
+ test_const_reference(0)
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+#
+# Input and output typemaps for pointers and non-const references to
+# std::string are *not* supported; the following tests confirm
+# that none of these cases are slipping through.
+#
+
+exceptionRaised = false
+begin
+ test_pointer("foo")
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+result = test_pointer_out()
+raise RuntimeError if result.is_a? String
+
+exceptionRaised = false
+begin
+ test_const_pointer("bar")
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+result = test_const_pointer_out()
+raise RuntimeError if result.is_a? String
+
+exceptionRaised = false
+begin
+ test_reference("foo")
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+result = test_reference_out()
+raise RuntimeError if result.is_a? String
+
+
+# Member Strings
+myStructure = Structure.new
+if (myStructure.MemberString2 != "member string 2")
+ raise RuntimeError
+end
+s = "Hello"
+myStructure.MemberString2 = s
+if (myStructure.MemberString2 != s)
+ raise RuntimeError
+end
+if (myStructure.ConstMemberString != "const member string")
+ raise RuntimeError
+end
+
+
+if (Structure.StaticMemberString2 != "static member string 2")
+ raise RuntimeError
+end
+Structure.StaticMemberString2 = s
+if (Structure.StaticMemberString2 != s)
+ raise RuntimeError
+end
+if (Structure.ConstStaticMemberString != "const static member string")
+ raise RuntimeError
+end
+
+
+if (test_reference_input("hello") != "hello")
+ raise RuntimeError
+end
+s = test_reference_inout("hello")
+if (s != "hellohello")
+ raise RuntimeError
+end
+
+
+if (stdstring_empty() != "")
+ raise RuntimeError
+end
+
+if (c_empty() != "")
+ raise RuntimeError
+end
+
+
+if (c_null() != nil)
+ raise RuntimeError
+end
+
+
+if (get_null(c_null()) != nil)
+ raise RuntimeError
+end
+
diff --git a/trunk/Examples/test-suite/ruby/li_std_vector_runme.rb b/trunk/Examples/test-suite/ruby/li_std_vector_runme.rb
new file mode 100755
index 000000000..8bcad2d19
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/li_std_vector_runme.rb
@@ -0,0 +1,122 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_vector'
+
+include Li_std_vector
+
+iv = IntVector.new(4)
+
+swig_assert( "iv.respond_to? :each", binding )
+
+begin
+ iv.each
+ swig_assert( false, nil, "iv.each worked with no block!")
+rescue ArgumentError
+end
+
+swig_assert_each_line(<<'EOF', binding)
+iv.respond_to?(:each) == true
+iv.respond_to?(:each_with_index) == true
+EOF
+
+iv.each_with_index { |e,i|
+ swig_assert("#{e} == 0", binding, "for iv[#{i}] == 0")
+}
+
+0.upto(3) { |i| iv[i] = i }
+
+{ "iv[-1]" => 3,
+ "iv.slice(0,2).to_s" => "01",
+ "iv.slice(1,2).to_s" => "12",
+ "iv[0,-2]" => nil,
+ "iv[0,3].to_s" => "012",
+ "iv[0,10].to_s" => "012",
+ "iv[1..2].to_s" => '12',
+ "iv[1..3].to_s" => '123',
+ "iv[1..4].to_s" => '123',
+ "iv[1..-2].to_s" => '12',
+ "iv[2..-3]" => nil,
+}.each do |k,v|
+ swig_assert( "#{k} == #{v.inspect}", binding )
+end
+
+swig_assert_each_line(<<'EOF', binding)
+iv << 5
+iv.push 5
+iv.pop == 5
+iv.unshift(7)
+iv.shift == 7
+iv.unshift(7, 3)
+iv.insert(1,5)
+iv.insert(0, 3)
+iv.unshift(2,3,4)
+x = average(iv)
+y = average([1, 2, 3, 4])
+half([10, 10.5, 11, 11.5])
+EOF
+
+dv = DoubleVector.new(10)
+
+swig_assert( "dv.respond_to? :each_with_index", binding )
+
+dv.each_with_index { |e,i| swig_assert_equal("dv[#{i}]", 0.0, binding) }
+
+0.upto(9) { |i| dv[i] = i/2.0 }
+
+{ "dv[-1]" => 4.5,
+ "dv.slice(0,2).to_s" => "0.00.5",
+ "dv[0,-2]" => nil,
+ "dv[0,3].to_s" => "0.00.51.0",
+ "dv[3,3].to_s" => "1.52.02.5",
+}.each do |k,v|
+ swig_assert_equal( k, v.inspect, binding )
+end
+
+swig_assert_each_line(<<'EOF', binding)
+dv.delete_at(2)
+dv.delete_if { |x| x == 2.0 }
+dv.include? 3.0
+dv.find {|x| x == 3.0 }
+dv.kind_of? DoubleVector
+halved = []
+halved = dv.map { |x| x / 2 }
+halve_in_place(dv)
+halved.to_a == dv.to_a
+sv = StructVector.new
+sv << Li_std_vector::Struct.new
+sv[0].class == Li_std_vector::Struct
+sv[1] = Li_std_vector::Struct.new
+
+EOF
+
+bv = BoolVector.new(2)
+[true, false, true, true].each { |i| bv.push(i) }
+0.upto(bv.size-1) { |i| bv[i] = !bv[i] }
+bv_check = [true, true, false, true, false, false]
+for i in 0..bv.size-1 do
+ swig_assert(bv_check[i] == bv[i], binding, "bv[#{i}]")
+end
+
+swig_assert_each_line(<<'EOF', binding)
+lv = LanguageVector.new
+lv << 1
+lv << [1,2]
+lv << 'asd'
+lv[0], lv[1] = lv[1], lv[0]
+EOF
+
+
+# this should assert
+begin
+ lv = LanguageVector.new('crapola')
+rescue
+end
diff --git a/trunk/Examples/test-suite/ruby/member_pointer_runme.rb b/trunk/Examples/test-suite/ruby/member_pointer_runme.rb
new file mode 100644
index 000000000..eca6f0df8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/member_pointer_runme.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+#
+# Example using pointers to member functions
+#
+#
+#
+
+require 'swig_assert'
+
+require 'member_pointer'
+
+include Member_pointer
+
+def check(what, expected, actual)
+ if not expected == actual
+ raise RuntimeError, "Failed: #{what} Expected: #{expected} Actual: #{actual}"
+ end
+end
+
+# Get the pointers
+
+area_pt = Member_pointer::areapt
+perim_pt = Member_pointer::perimeterpt
+
+# Create some objects
+
+s = Member_pointer::Square.new(10)
+
+# Do some calculations
+
+check "Square area ", 100.0, Member_pointer::do_op(s, area_pt)
+check "Square perim", 40.0, Member_pointer::do_op(s, perim_pt)
+
+memberPtr = Member_pointer::areavar
+memberPtr = Member_pointer::perimetervar
+
+# Try the variables
+check "Square area ", 100.0, Member_pointer::do_op(s, Member_pointer::areavar)
+check "Square perim", 40.0, Member_pointer::do_op(s, Member_pointer::perimetervar)
+
+# Modify one of the variables
+Member_pointer::areavar = perim_pt
+
+check "Square perimeter", 40.0, Member_pointer::do_op(s, Member_pointer::areavar)
+
+# Try the constants
+
+memberPtr = Member_pointer::AREAPT
+memberPtr = Member_pointer::PERIMPT
+memberPtr = Member_pointer::NULLPT
+
+check "Square area ", 100.0, Member_pointer::do_op(s, Member_pointer::AREAPT)
+check "Square perim", 40.0, Member_pointer::do_op(s, Member_pointer::PERIMPT)
+
diff --git a/trunk/Examples/test-suite/ruby/minherit_runme.rb b/trunk/Examples/test-suite/ruby/minherit_runme.rb
new file mode 100644
index 000000000..ba41ab6fa
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/minherit_runme.rb
@@ -0,0 +1,89 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'minherit'
+
+a = Minherit::Foo.new
+b = Minherit::Bar.new
+c = Minherit::FooBar.new
+d = Minherit::Spam.new
+
+if a.xget() != 1
+ raise RuntimeError, "Bad attribute value"
+end
+
+if b.yget() != 2
+ raise RuntimeError, "Bad attribute value"
+end
+
+if c.xget() != 1 or c.yget() != 2 or c.zget() != 3
+ raise RuntimeError, "Bad attribute value"
+end
+
+if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4
+ raise RuntimeError, "Bad attribute value"
+end
+
+if Minherit.xget(a) != 1
+ raise RuntimeError, "Bad attribute value #{Minherit.xget(a)}"
+end
+
+if Minherit.yget(b) != 2
+ raise RuntimeError, "Bad attribute value #{Minherit.yget(b)}"
+end
+
+if Minherit.xget(c) != 1 or Minherit.yget(c) != 2 or Minherit.zget(c) != 3
+ raise RuntimeError, "Bad attribute value #{Minherit.xget(c)} #{Minherit.yget(c)} #{Minherit.zget(c)}"
+end
+
+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 #{Minherit.xget(d)} #{Minherit.yget(d)} #{Minherit.zget(d)} #{Minherit.wget(d)}"
+end
+
+# 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"
+end
+
+if bb.yget() != 2
+ raise RuntimeError, "Bad attribute value"
+end
+
+if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3
+ raise RuntimeError, "Bad attribute value"
+end
+
+if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4
+ raise RuntimeError, "Bad attribute value"
+end
+
+if Minherit.xget(aa) != 1
+ raise RuntimeError, "Bad attribute value #{Minherit.xget(aa)}"
+end
+
+if Minherit.yget(bb) != 2
+ raise RuntimeError, "Bad attribute value #{Minherit.yget(bb)}"
+end
+
+if Minherit.xget(cc) != 1 or Minherit.yget(cc) != 2 or Minherit.zget(cc) != 3
+ raise RuntimeError, "Bad attribute value #{Minherit.xget(cc)} #{Minherit.yget(cc)} #{Minherit.zget(cc)}"
+end
+
+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 #{Minherit.xget(dd)} #{Minherit.yget(dd)} #{Minherit.zget(dd)} #{Minherit.wget(dd)}"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/namespace_typemap_runme.rb b/trunk/Examples/test-suite/ruby/namespace_typemap_runme.rb
new file mode 100755
index 000000000..42a5e23a7
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/namespace_typemap_runme.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/newobject1_runme.rb b/trunk/Examples/test-suite/ruby/newobject1_runme.rb
new file mode 100644
index 000000000..f5dc12fb5
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/newobject1_runme.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+#
+# Simple test of %newobject
+# * 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.
+#
+# Ruby's GC is somewhat broken in that it will mark some more stack space
+# leading to the collection of local objects to be delayed.
+# Thus, upon invokation, it sometimes you can wait up to several
+# instructions to kick in.
+# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'swig_gc'
+require 'newobject1'
+
+include Newobject1
+
+GC.track_class = Foo
+GC.start
+100.times { foo1 = Foo.makeFoo; foo2 = foo1.makeMore }
+GC.stats if $VERBOSE
+swig_assert( 'Foo.fooCount == 200', binding, "but is #{Foo.fooCount}" )
+GC.start
+swig_assert( 'Foo.fooCount <= 2', binding, "but is #{Foo.fooCount}" )
+
diff --git a/trunk/Examples/test-suite/ruby/newobject2_runme.rb b/trunk/Examples/test-suite/ruby/newobject2_runme.rb
new file mode 100644
index 000000000..99bc24374
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/newobject2_runme.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+#
+# Ruby's GC is somewhat broken in that it will mark some more stack space
+# leading to the collection of local objects to be delayed.
+# Thus, upon invokation, it sometimes you can wait up to several
+# instructions to kick in.
+# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'swig_gc'
+require 'newobject2'
+
+include Newobject2
+
+GC.track_class = Foo
+GC.stats if $VERBOSE
+100.times { foo1 = makeFoo }
+GC.stats if $VERBOSE
+swig_assert( 'fooCount == 100', nil, "but is #{fooCount}" )
+GC.start
+swig_assert( 'fooCount <= 1', nil, "but is #{fooCount}" )
+
diff --git a/trunk/Examples/test-suite/ruby/overload_copy_runme.rb b/trunk/Examples/test-suite/ruby/overload_copy_runme.rb
new file mode 100755
index 000000000..eb184b83c
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/overload_copy_runme.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'overload_copy'
+
+include Overload_copy
+
+f = Foo.new
+g = Foo.new(f)
diff --git a/trunk/Examples/test-suite/ruby/overload_extend_runme.rb b/trunk/Examples/test-suite/ruby/overload_extend_runme.rb
new file mode 100755
index 000000000..255793fb4
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/overload_extend_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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) != 6
+
diff --git a/trunk/Examples/test-suite/ruby/overload_extendc_runme.rb b/trunk/Examples/test-suite/ruby/overload_extendc_runme.rb
new file mode 100755
index 000000000..a2682bf42
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/overload_extendc_runme.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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) != 6
diff --git a/trunk/Examples/test-suite/ruby/overload_simple_runme.rb b/trunk/Examples/test-suite/ruby/overload_simple_runme.rb
new file mode 100755
index 000000000..88cee4411
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/overload_simple_runme.rb
@@ -0,0 +1,130 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/overload_subtype_runme.rb b/trunk/Examples/test-suite/ruby/overload_subtype_runme.rb
new file mode 100644
index 000000000..991a2e4ad
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/overload_subtype_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/overload_template_runme.rb b/trunk/Examples/test-suite/ruby/overload_template_runme.rb
new file mode 100755
index 000000000..b099fd3ea
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/overload_template_runme.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'overload_template'
+
+f = Overload_template.foo()
+
+a = Overload_template.maximum(3,4)
+b = Overload_template.maximum(3.4,5.2)
diff --git a/trunk/Examples/test-suite/ruby/primitive_ref_runme.rb b/trunk/Examples/test-suite/ruby/primitive_ref_runme.rb
new file mode 100755
index 000000000..5e97c7a6c
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/primitive_ref_runme.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/primitive_types_runme.rb b/trunk/Examples/test-suite/ruby/primitive_types_runme.rb
new file mode 100644
index 000000000..0024c9696
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/primitive_types_runme.rb
@@ -0,0 +1,98 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'primitive_types'
+
+include Primitive_types
+
+
+raise RuntimeError if val_uchar(255) != 255
+
+fail = 0
+begin
+ val_uchar(-1)
+rescue RangeError
+ fail = 1
+end
+
+fail = 0
+begin
+ val_uchar(256)
+rescue RangeError
+ fail = 1
+end
+
+raise RuntimeError if fail != 1
+
+fail = 0
+begin
+ val_uchar(256.0)
+rescue TypeError
+ fail = 1
+end
+
+raise RuntimeError if fail != 1
+
+fail = 0
+begin
+ val_uchar("caca")
+rescue TypeError
+ fail = 1
+end
+
+raise RuntimeError if fail != 1
+
+# Test a number which won't fit in a 32 bit integer and is represented
+# as a FIXNUM by Ruby.
+raise RuntimeError if val_double(51767811298) != 51767811298
+
+raise RuntimeError if val_double_2(1.0) != 4.0
+raise RuntimeError if val_double_2(1) != 4
+raise RuntimeError if val_double_2(1,1) != 2
+
+fail = 0
+begin
+ val_double_2("1.0",1.0)
+rescue
+ fail = 1
+end
+raise RuntimeError if fail != 1
+
+
+fail = 0
+begin
+ val_double_2(1.0,"1.0")
+rescue
+ fail = 1
+end
+raise RuntimeError if fail != 1
+
+
+raise RuntimeError if val_float_2(1.0) != 4.0
+raise RuntimeError if val_float_2(1) != 4
+raise RuntimeError if val_float_2(1,1) != 2
+
+fail = 0
+begin
+ val_float_2("1.0",1.0)
+rescue
+ fail = 1
+end
+raise RuntimeError if fail != 1
+
+
+fail = 0
+begin
+ val_float_2(1.0,"1.0")
+rescue
+ fail = 1
+end
+raise RuntimeError if fail != 1
diff --git a/trunk/Examples/test-suite/ruby/profiletest_runme.rb b/trunk/Examples/test-suite/ruby/profiletest_runme.rb
new file mode 100644
index 000000000..0f6ddc7f9
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/profiletest_runme.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'profiletest'
+
+a = Profiletest::A.new()
+b = Profiletest::B.new()
+
+for i in 0...1000000
+ a = b.fn(a)
+end
+
diff --git a/trunk/Examples/test-suite/ruby/refcount_runme.rb b/trunk/Examples/test-suite/ruby/refcount_runme.rb
new file mode 100644
index 000000000..7ef3c846e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/refcount_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'refcount'
+
+
+a = Refcount::A3.new;
+b1 = Refcount::B.new a;
+b2 = Refcount::B.new a;
+
+if a.ref_count() != 3
+ print "This program will crash... now\n"
+end
diff --git a/trunk/Examples/test-suite/ruby/reference_global_vars_runme.rb b/trunk/Examples/test-suite/ruby/reference_global_vars_runme.rb
new file mode 100644
index 000000000..49fbf4dfa
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/reference_global_vars_runme.rb
@@ -0,0 +1,104 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'reference_global_vars'
+
+# primitive reference variables
+Reference_global_vars.var_bool = Reference_global_vars.createref_bool(true)
+if (Reference_global_vars.value_bool(Reference_global_vars.var_bool) != true)
+ print "Runtime error test 1\n"
+ exit 1
+end
+
+Reference_global_vars.var_bool = Reference_global_vars.createref_bool(false)
+if (Reference_global_vars.value_bool(Reference_global_vars.var_bool) != false)
+ print "Runtime error test 2 \n"
+ exit 1
+end
+
+Reference_global_vars.var_char = Reference_global_vars.createref_char('w')
+if (Reference_global_vars.value_char(Reference_global_vars.var_char) != 'w')
+ print "Runtime error test 3 \n"
+ exit 1
+end
+
+Reference_global_vars.var_unsigned_char = Reference_global_vars.createref_unsigned_char(10)
+if (Reference_global_vars.value_unsigned_char(Reference_global_vars.var_unsigned_char) != 10)
+ print "Runtime error test 4 \n"
+ exit 1
+end
+
+Reference_global_vars.var_signed_char = Reference_global_vars.createref_signed_char(10)
+if (Reference_global_vars.value_signed_char(Reference_global_vars.var_signed_char) != 10)
+ print "Runtime error test 5 \n"
+ exit 1
+end
+
+Reference_global_vars.var_short = Reference_global_vars.createref_short(10)
+if (Reference_global_vars.value_short(Reference_global_vars.var_short) != 10)
+ print "Runtime error test 6 \n"
+ exit 1
+end
+
+Reference_global_vars.var_unsigned_short = Reference_global_vars.createref_unsigned_short(10)
+if (Reference_global_vars.value_unsigned_short(Reference_global_vars.var_unsigned_short) != 10)
+ print "Runtime error test 7 \n"
+ exit 1
+end
+
+Reference_global_vars.var_int = Reference_global_vars.createref_int(10)
+if (Reference_global_vars.value_int(Reference_global_vars.var_int) != 10)
+ print "Runtime error test 8 \n"
+ exit 1
+end
+
+Reference_global_vars.var_unsigned_int = Reference_global_vars.createref_unsigned_int(10)
+if (Reference_global_vars.value_unsigned_int(Reference_global_vars.var_unsigned_int) != 10)
+ print "Runtime error test 9 \n"
+ exit 1
+end
+
+Reference_global_vars.var_long = Reference_global_vars.createref_long(10)
+if (Reference_global_vars.value_long(Reference_global_vars.var_long) != 10)
+ print "Runtime error test 10 \n"
+ exit 1
+end
+
+Reference_global_vars.var_unsigned_long = Reference_global_vars.createref_unsigned_long(10)
+if (Reference_global_vars.value_unsigned_long(Reference_global_vars.var_unsigned_long) != 10)
+ print "Runtime error test 11 \n"
+ exit 1
+end
+
+Reference_global_vars.var_long_long = Reference_global_vars.createref_long_long(10)
+if (Reference_global_vars.value_long_long(Reference_global_vars.var_long_long) != 10)
+ print "Runtime error test 12 \n"
+ exit 1
+end
+
+Reference_global_vars.var_unsigned_long_long = Reference_global_vars.createref_unsigned_long_long(10)
+if (Reference_global_vars.value_unsigned_long_long(Reference_global_vars.var_unsigned_long_long) != 10)
+ print "Runtime error test 13 \n"
+ exit 1
+end
+
+Reference_global_vars.var_float = Reference_global_vars.createref_float(10.5)
+if (Reference_global_vars.value_float(Reference_global_vars.var_float) != 10.5)
+ print "Runtime error test 14 \n"
+ exit 1
+end
+
+Reference_global_vars.var_double = Reference_global_vars.createref_double(10.5)
+if (Reference_global_vars.value_double(Reference_global_vars.var_double) != 10.5)
+ print "Runtime error test 15 \n"
+ exit 1
+end
+
diff --git a/trunk/Examples/test-suite/ruby/rename_scope_runme.rb b/trunk/Examples/test-suite/ruby/rename_scope_runme.rb
new file mode 100644
index 000000000..76a14871d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/rename_scope_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/ruby_keywords_runme.rb b/trunk/Examples/test-suite/ruby/ruby_keywords_runme.rb
new file mode 100644
index 000000000..9b06ecf1d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/ruby_keywords_runme.rb
@@ -0,0 +1,159 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'ruby_keywords'
+
+kw = Ruby_keywords::Keywords.new
+
+if kw.alias != 'alias' then
+ raise RuntimeError, 'Keyword method did not work: alias'
+end
+
+if kw.and != 'and' then
+ raise RuntimeError, 'Keyword method did not work: and'
+end
+
+if kw.begin != 'begin' then
+ raise RuntimeError, 'Keyword method did not work: begin'
+end
+
+if kw.break != 'break' then
+ raise RuntimeError, 'Keyword method did not work: break'
+end
+
+if kw.case != 'case' then
+ raise RuntimeError, 'Keyword method did not work: case'
+end
+
+if kw.class != 'class' then
+ raise RuntimeError, 'Keyword method did not work: class'
+end
+
+if kw.def != 'def' then
+ raise RuntimeError, 'Keyword method did not work: def'
+end
+
+if kw.defined? != 'defined?' then
+ raise RuntimeError, 'Keyword method did not work: defined?'
+end
+
+if kw.do != 'do' then
+ raise RuntimeError, 'Keyword method did not work: do'
+end
+
+if kw.else != 'else' then
+ raise RuntimeError, 'Keyword method did not work: else'
+end
+
+if kw.elsif != 'elsif' then
+ raise RuntimeError, 'Keyword method did not work: elsif'
+end
+
+if kw.end != 'end' then
+ raise RuntimeError, 'Keyword method did not work: end'
+end
+
+if kw.ensure != 'ensure' then
+ raise RuntimeError, 'Keyword method did not work: ensure'
+end
+
+if kw.false != 'false' then
+ raise RuntimeError, 'Keyword method did not work: false'
+end
+
+if kw.for != 'for' then
+ raise RuntimeError, 'Keyword method did not work: for'
+end
+
+if kw.if != 'if' then
+ raise RuntimeError, 'Keyword method did not work: if'
+end
+
+if kw.in != 'in' then
+ raise RuntimeError, 'Keyword method did not work: in'
+end
+
+if kw.module != 'module' then
+ raise RuntimeError, 'Keyword method did not work: module'
+end
+
+if kw.next != 'next' then
+ raise RuntimeError, 'Keyword method did not work: next'
+end
+
+if kw.nil != 'nil' then
+ raise RuntimeError, 'Keyword method did not work: nil'
+end
+
+if kw.not != 'not' then
+ raise RuntimeError, 'Keyword method did not work: not'
+end
+
+if kw.or != 'or' then
+ raise RuntimeError, 'Keyword method did not work: or'
+end
+
+if kw.redo != 'redo' then
+ raise RuntimeError, 'Keyword method did not work: redo'
+end
+
+if kw.rescue != 'rescue' then
+ raise RuntimeError, 'Keyword method did not work: rescue'
+end
+
+if kw.retry != 'retry' then
+ raise RuntimeError, 'Keyword method did not work: retry'
+end
+
+if kw.return != 'return' then
+ raise RuntimeError, 'Keyword method did not work: return'
+end
+
+if kw.self != 'self' then
+ raise RuntimeError, 'Keyword method did not work: self'
+end
+
+if kw.super != 'super' then
+ raise RuntimeError, 'Keyword method did not work: super'
+end
+
+if kw.then != 'then' then
+ raise RuntimeError, 'Keyword method did not work: then'
+end
+
+if kw.true != 'true' then
+ raise RuntimeError, 'Keyword method did not work: true'
+end
+
+if kw.under != 'under' then
+ raise RuntimeError, 'Keyword method did not work: under'
+end
+
+if kw.unless != 'unless' then
+ raise RuntimeError, 'Keyword method did not work: unless'
+end
+
+if kw.until != 'until' then
+ raise RuntimeError, 'Keyword method did not work: until'
+end
+
+if kw.when != 'when' then
+ raise RuntimeError, 'Keyword method did not work: when'
+end
+
+if kw.while != 'while' then
+ raise RuntimeError, 'Keyword method did not work: while'
+end
+
+if kw.yield != 'yield' then
+ raise RuntimeError, 'Keyword method did not work: yield'
+end
+
diff --git a/trunk/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb b/trunk/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb
new file mode 100755
index 000000000..e79cb46a8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+#
+# This is a simple speed benchmark suite for std containers,
+# to verify their O(n) performance.
+# It is not part of the standard tests.
+
+
+require 'benchmark'
+require 'mathn'
+require 'ruby_li_std_speed'
+include Ruby_li_std_speed
+
+
+def benchmark(f, phigh, sequences)
+ puts f
+ print '%10s' % 'n'
+ maxlen = sequences.max { |a,b| a.to_s.size <=> b.to_s.size }
+ maxlen = maxlen.to_s.size - 12
+ sequences.each { |s| print "%#{maxlen}s" % "#{s.to_s.sub(/.*::/,'')}" }
+ puts
+ o_perf = Array.new(sequences.size, 0)
+ last_t = Array.new(sequences.size, nil)
+ 1.upto(phigh) do |p|
+ n = 2**(p-1)
+ print "%10d" % n
+ sequences.each_with_index do |s, i|
+ cont = s.new((0..n).to_a)
+ Benchmark.benchmark('',0,"%#{maxlen-2}.6r") { |x|
+ t = x.report { f.call(cont) }
+ o_perf[i] += last_t[i] ? (t.real / last_t[i]) : t.real
+ last_t[i] = t.real
+ }
+ end
+ puts
+ end
+
+ print " avg. O(n)"
+ base = 1.0 / Math.log(2.0)
+ sequences.each_with_index do |s, i|
+ o_perf[i] /= phigh
+ # o_perf[i] = 1 if o_perf[i] < 1
+ o_perf[i] = Math.log(o_perf[i]) * base
+ print "%#{maxlen-1}.2f " % o_perf[i]
+ end
+ puts
+end
+
+def iterate(cont)
+ it = cont.begin
+ last = cont.end
+ while it != last
+ it.next
+ end
+end
+
+
+def erase(cont)
+ it = cont.end
+ # can't reuse begin since it might get invalidated
+ while it != cont.begin
+ it.previous
+ # set returns None, so need to reobtain end
+ it = cont.erase(it) || cont.end
+ end
+end
+
+def insert(cont)
+ size = cont.size
+ size.upto((size<<1) - 1) { |x| cont.push(x) }
+end
+
+if $0 == __FILE__
+ GC.disable
+ sequences = [RbVector,RbDeque,RbSet,RbList,
+ RbFloatVector,RbFloatDeque,RbFloatSet,RbFloatList]
+ n = 17
+ for f,phigh in [[method(:iterate),n], [method(:insert),n],
+ [method(:erase),n-4]]
+ benchmark(f, phigh, sequences)
+ end
+end
+
diff --git a/trunk/Examples/test-suite/ruby/ruby_naming_runme.rb b/trunk/Examples/test-suite/ruby/ruby_naming_runme.rb
new file mode 100644
index 000000000..8ea5f13d3
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/ruby_naming_runme.rb
@@ -0,0 +1,115 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'ruby_naming'
+
+# Check class names
+if not Ruby_naming
+ raise RuntimeError, 'Invalid module name for Ruby_naming'
+end
+
+if not Ruby_naming::MyClass
+ raise RuntimeError, 'Invalid class name for MyClass'
+end
+
+
+# Check constant names / values
+if Ruby_naming::CONSTANT1 != 1
+ raise RuntimeError, "Incorrect value for CONSTANT1"
+end
+
+if Ruby_naming::CONSTANT2 != 2
+ raise RuntimeError, "Incorrect value for CONSTANT2"
+end
+
+# Check constant names / values
+if Ruby_naming::CONSTANT3 != 3
+ raise RuntimeError, "Incorrect value for CONSTANT3"
+end
+
+if not Ruby_naming::methods.include?("constant4")
+ raise RuntimeError, "Incorrect mapping for constant4"
+end
+
+if not Ruby_naming::methods.include?("constant5")
+ raise RuntimeError, "Incorrect mapping for constant5"
+end
+
+if not Ruby_naming::methods.include?("constant6")
+ raise RuntimeError, "Incorrect mapping for constant6"
+end
+
+if not Ruby_naming::TestConstants.instance_methods.include?("constant7")
+ raise RuntimeError, "Incorrect mapping for constant7"
+end
+
+if not Ruby_naming::TestConstants.methods.include?("constant8")
+ raise RuntimeError, "Incorrect mapping for constant8"
+end
+
+# There is no constant9 because it is illegal C++
+#if not Ruby_naming::TestConstants.instance_methods.include?("constant9")
+# raise RuntimeError, "Incorrect mapping for constant9"
+#end
+
+if Ruby_naming::TestConstants::CONSTANT10 != 10
+ raise RuntimeError, "Incorrect value for CONSTANT10"
+end
+
+if not Ruby_naming::methods.include?("constant11")
+ raise RuntimeError, "Incorrect mapping for constant11"
+end
+
+
+# Check enums
+if Ruby_naming::constants.include?("Color")
+ raise RuntimeError, "Color enum should not be exposed to Ruby"
+end
+
+if Ruby_naming::Red != 0
+ raise RuntimeError, "Incorrect value for enum RED"
+end
+
+if Ruby_naming::Green != 1
+ raise RuntimeError, "Incorrect value for enum GREEN"
+end
+
+if Ruby_naming::Blue != 2
+ raise RuntimeError, "Incorrect value for enum BLUE"
+end
+
+
+# Check method names
+my_class = Ruby_naming::MyClass.new()
+
+if my_class.method_one != 1
+ raise RuntimeError, "Incorrect value for method_one"
+end
+
+if my_class.method_two != 2
+ raise RuntimeError, "Incorrect value for method_two"
+end
+
+if my_class.method_three != 3
+ raise RuntimeError, "Incorrect value for method_three"
+end
+
+if my_class.method_44_4 != 4
+ raise RuntimeError, "Incorrect value for method_44_4"
+end
+
+if my_class.predicate_method? != true
+ raise RuntimeError, "Incorrect value for predicate_method?"
+end
+
+if my_class.bang_method! != true
+ raise RuntimeError, "Incorrect value for bang_method!"
+end
diff --git a/trunk/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb b/trunk/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb
new file mode 100644
index 000000000..fb55323a8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'ruby_track_objects_directors'
+
+class MyFoo < Ruby_track_objects_directors::Foo
+ def ping
+ "MyFoo::ping()"
+ end
+end
+
+a = MyFoo.new
+
+raise RuntimeError if a.ping != "MyFoo::ping()"
+raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()"
+
+b = Ruby_track_objects_directors::Foo.new
+
+raise RuntimeError if b.ping != "Foo::ping()"
+raise RuntimeError if b.pong != "Foo::pong();Foo::ping()"
+
+container = Ruby_track_objects_directors::Container.new
+foo = MyFoo.new
+container.set_foo(foo)
+
+myFoo1 = container.get_foo
+myFoo2 = container.get_foo
+
+if not myFoo1.equal?(myFoo2)
+ raise RuntimeError, "MyFoo's should be the same"
+end
diff --git a/trunk/Examples/test-suite/ruby/ruby_track_objects_runme.rb b/trunk/Examples/test-suite/ruby/ruby_track_objects_runme.rb
new file mode 100644
index 000000000..7bc67a478
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/ruby_track_objects_runme.rb
@@ -0,0 +1,117 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'ruby_track_objects'
+
+def test_same_ruby_object(foo1, foo2)
+ if not foo1.equal?(foo2)
+ raise "Ruby objects should be the same."
+ end
+end
+
+def test_same_cpp_object(foo1, foo2)
+ if not foo1.cpp_equal(foo2)
+ raise "C++ objects should be the same"
+ end
+end
+
+bar = Ruby_track_objects::Bar.new
+foo1 = Ruby_track_objects::Foo.new()
+bar.set_unowned_foo(foo1)
+
+# test_simple_identity
+foo2 = Ruby_track_objects::Foo.new()
+foo3 = foo2
+
+test_same_ruby_object(foo2, foo3)
+test_same_cpp_object(foo2, foo3)
+
+# test_unowned_foo_identity
+foo4 = bar.get_unowned_foo()
+
+test_same_ruby_object(foo1, foo4)
+test_same_cpp_object(foo1, foo4)
+
+# test_owned_foo_identity
+foo5 = bar.get_owned_foo()
+foo6 = bar.get_owned_foo()
+
+test_same_ruby_object(foo5, foo6)
+test_same_cpp_object(foo5, foo6)
+
+# test_new_foo_identity
+foo7 = Ruby_track_objects::Bar.get_new_foo()
+foo8 = Ruby_track_objects::Bar.get_new_foo()
+
+if foo7.equal?(foo8)
+ raise "Ruby objects should be different."
+end
+
+if foo7.cpp_equal(foo8)
+ raise "C++ objects should be different."
+end
+
+# test_set_owned_identity
+foo9 = Ruby_track_objects::Foo.new
+bar.set_owned_foo(foo9)
+foo10 = bar.get_owned_foo()
+
+test_same_ruby_object(foo9, foo10)
+test_same_cpp_object(foo9, foo10)
+
+# test_set_owned_identity2
+begin
+ foo11 = Ruby_track_objects::Foo.new
+ bar.set_owned_foo(foo11)
+ foo11 = nil
+end
+
+GC.start
+
+foo12 = bar.get_owned_foo()
+
+if not (foo12.say_hello == "Hello")
+ raise "Invalid C++ object returned."
+end
+
+# test_set_owned_identity3
+foo13 = bar.get_owned_foo_by_argument()
+foo14 = bar.get_owned_foo_by_argument()
+
+test_same_ruby_object(foo13, foo14)
+test_same_cpp_object(foo13, foo14)
+
+# Now create the factory
+factory = Ruby_track_objects::Factory.new
+
+# Create itemA which is really an itemB
+itemA = factory.createItem
+
+# Check class
+if itemA.class != Ruby_track_objects::ItemA
+ raise RuntimeError, 'Item should have an ItemA class'
+end
+
+# Now downcast
+itemB = Ruby_track_objects.downcast(itemA)
+
+if itemB.class != Ruby_track_objects::ItemB
+ raise RuntimeError, 'Item should have an ItemB class'
+end
+
+if itemA.eql?(itemB)
+ raise RuntimeError, 'Items should be different'
+end
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/ruby/smart_pointer_const_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_const_runme.rb
new file mode 100644
index 000000000..b6565ad76
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_const_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_multi_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_multi_runme.rb
new file mode 100644
index 000000000..a899ae758
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_multi_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb
new file mode 100644
index 000000000..d07da0d2e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_multi_typedef_runme.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_not_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_not_runme.rb
new file mode 100644
index 000000000..4324908f0
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_not_runme.rb
@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_overload_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_overload_runme.rb
new file mode 100644
index 000000000..24c343ac7
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_overload_runme.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_rename_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_rename_runme.rb
new file mode 100644
index 000000000..167e55444
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_rename_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_simple_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_simple_runme.rb
new file mode 100644
index 000000000..bdfbf9cd8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_simple_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb b/trunk/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb
new file mode 100644
index 000000000..168471234
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/sneaky1_runme.rb b/trunk/Examples/test-suite/ruby/sneaky1_runme.rb
new file mode 100755
index 000000000..c30fdaf2a
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/sneaky1_runme.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'sneaky1'
+
+x = Sneaky1.add(3, 4)
+y = Sneaky1.subtract(3, 4)
+z = Sneaky1.mul(3, 4)
+w = Sneaky1.divide(3, 4)
diff --git a/trunk/Examples/test-suite/ruby/static_const_member_2_runme.rb b/trunk/Examples/test-suite/ruby/static_const_member_2_runme.rb
new file mode 100644
index 000000000..0ba970ed8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/static_const_member_2_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'static_const_member_2'
+
+include Static_const_member_2
+
+c = Test_int.new
+a = Test_int::Forward_field # should be available as a class constant
+a = Test_int::Current_profile # should be available as a class constant
+a = Test_int::RightIndex # should be available as a class constant
+a = Test_int::Backward_field # should be available as a class constant
+a = Test_int::LeftIndex # should be available as a class constant
+a = Test_int.cavity_flags
+
diff --git a/trunk/Examples/test-suite/ruby/std_containers_runme.rb b/trunk/Examples/test-suite/ruby/std_containers_runme.rb
new file mode 100755
index 000000000..73d443218
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/std_containers_runme.rb
@@ -0,0 +1,119 @@
+#!/usr/bin/env ruby
+#
+# Standard containers test suite. Tests:
+# std::complex, std::vector, std::set and std::map,
+# and IN/OUT functions for them.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'std_containers'
+include Std_containers
+
+swig_assert_each_line(<<'EOF', binding)
+
+cube = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
+
+icube = cident(cube)
+icube.each_index { |i| swig_assert_equal("cube[#{i}]","icube[#{i}]", binding, 'cident') }
+
+
+p = [1,2]
+p == pident(p)
+
+v = [1,2,3,4,5,6]
+iv = vident(v)
+iv.each_index { |i| swig_assert_equal("iv[#{i}]","v[#{i}]", binding, 'vident') }
+
+
+
+iv = videntu(v)
+iv.each_index { |i| swig_assert_equal("iv[#{i}]","v[#{i}]", binding, 'videntu') }
+
+
+vu = Vector_ui.new(v)
+vu[2] == videntu(vu)[2]
+
+v[0,3][1] == vu[0,3][1]
+
+m = [[1,2,3],[2,3],[3,4]]
+im = midenti(m)
+
+0.upto(m.size-1){ |i| 0.upto(m[i].size-1) { |j| swig_assert_equal("m[#{i}][#{j}]","im[#{i}][#{j}]", binding, 'getslice') } }
+
+
+m = [[1,0,1],[1,1],[1,1]]
+im = midentb(m)
+
+0.upto(m.size-1){ |i| 0.upto(m[i].size-1) { |j| swig_assert_equal("(m[#{i}][#{j}]==1)","im[#{i}][#{j}]", binding, 'getslice') } }
+
+mi = Imatrix.new(m)
+mc = Cmatrix.new(m)
+mi[0][0] == mc[0][0] # or bad matrix
+
+map ={}
+map['hello'] = 1
+map['hi'] = 2
+map['3'] = 2
+
+imap = Std_containers.mapident(map)
+map.each_key { |k| swig_assert_equal("map['#{k}']", "imap['#{k}']", binding) }
+
+mapc ={}
+c1 = C.new
+c2 = C.new
+mapc[1] = c1
+mapc[2] = c2
+
+mapidentc(mapc)
+
+vi = Vector_i.new([2,2,3,4])
+v1 = vi.dup
+v1.class == vi.class
+v1 != vi
+v1.object_id != vi.object_id
+
+v = [1,2]
+v1 = v_inout(vi)
+vi[1] == v1[1]
+# vi.class == v1.class # only if SWIG_RUBY_EXTRA_NATIVE_CONTAINERS was set
+
+v1,v2 = [[1,2],[3,4]]
+v1,v2 = v_inout2(v1,v2)
+v2 == [1,2]
+v1 == [3,4]
+
+a1 = A.new(1)
+a2 = A.new(2)
+
+p1 = [1,a1]
+p2 = [2,a2]
+v = [p1,p2]
+v2 = pia_vident(v)
+
+
+
+# v2[0][1].a
+# v2[1][1].a
+
+# v3 = Std_containers.vector_piA(v2)
+
+# v3[0][1].a
+# v3[1][1].a
+
+
+
+
+s = Set_i.new
+s.push(1)
+s.push(2)
+s.push(3)
+j = 1
+s.each { |i| swig_assert_equal("#{i}","#{j}", binding, "for s[#{i}]"); j += 1 }
+
+
+EOF
+
diff --git a/trunk/Examples/test-suite/ruby/stl_new_runme.rb b/trunk/Examples/test-suite/ruby/stl_new_runme.rb
new file mode 100755
index 000000000..80d4ceab3
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/stl_new_runme.rb
@@ -0,0 +1,117 @@
+#!/usr/bin/env ruby
+#
+# This is a test of STL containers, iterators and using proc
+# objects to change the sorting function used in them. Same as a
+# std::binary_predicate in C++.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'stl_new'
+
+
+def _sequence(container)
+ swig_assert_each_line(<<'EOF', binding)
+cont = container.new([9,1,8,2,7,3,6,4,5])
+cont.to_a == [9,1,8,2,7,3,6,4,5]
+cont.size == 9
+i = cont.begin
+i.class == Stl_new::Iterator
+cont.end - cont.begin == cont.size
+cont.begin.value == 9
+(cont.end-1).value == 5
+cont[0],cont[1] = cont[1],cont[0]
+cont.to_a == [1,9,8,2,7,3,6,4,5]
+i0 = cont.begin
+i1 = i0+1
+tmp = i0.value # tmp = 1
+tmp == 1
+i0.value = i1.value # elem[0] = 9
+i1.value = tmp # elem[1] = 1
+cont.to_a == [9,1,8,2,7,3,6,4,5]
+i0 += 8
+prev = i0.value
+i0 -= 8
+cur = i0.value
+i0.value = prev
+prev = cur
+i0 += 8
+cur = i0.value
+i0.value = prev
+cont.to_a == [5,1,8,2,7,3,6,4,9]
+i0 == cont.end-1
+i0 != cont.end
+EOF
+end
+
+def _random_iterator(container)
+ swig_assert_each_line(<<EOF, binding)
+ cont = #{container}.new([9,1,8,2,7,3,6,4,5])
+ Stl_new.nth_element(cont.begin,cont.begin+cont.size/2,cont.end)
+ cont.to_a == [3, 1, 2, 4, 5, 6, 7, 8, 9]
+ Stl_new.nth_element(cont.begin,cont.begin+1,cont.end, proc { |a,b| b<a } )
+ cont.to_a == [9, 8, 7, 6, 5, 4, 2, 1, 3]
+EOF
+end
+
+def _set(container)
+ swig_assert_each_line(<<EOF, binding)
+ cont = #{container}.new
+ [9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
+ i0 = cont.begin()
+ cont.to_a == [1,2,3,4,5,6,7,8,9]
+ cont = #{container}.new( proc { |a,b| b < a } )
+ [9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
+ cont.to_a == [9, 8, 7, 6, 5, 4, 3, 2, 1]
+ cont = #{container}.new( proc { |a,b| b > a } )
+ [9,1,8,2,7,3,6,4,5].each { |x| cont.insert(x) }
+ cont.to_a == [1, 2, 3, 4, 5, 6, 7, 8, 9]
+ cont = #{container}.new(proc { |a,b| b < a } )
+ cont.insert(1)
+ cont.to_a == [1]
+ i0 = cont.begin()
+ cont.erase(i0) # don't use i0 anymore, it is invalid now
+ cont.to_a == []
+EOF
+end
+
+def _map(container)
+ swig_assert_each_line(<<EOF, binding)
+ cont = #{container}.new
+ cont['z'] = 9
+ cont['y'] = 1
+ cont['x'] = 8
+ cont['w'] = 2
+ cont.to_a == [['w',2],['x',8],['y',1],['z',9]]
+
+ cont = #{container}.new(proc { |a,b| b < a } )
+ cont['z'] = 9
+ cont['y'] = 1
+ cont['x'] = 8
+ cont['w'] = 2
+ cont.to_a == [['z',9],['y',1],['x',8],['w',2]]
+
+ #cont.iterator.to_a == [['w',2],['x',8],['y',1],['z',9]]
+EOF
+end
+
+def test
+ for container in [Stl_new::Vector, Stl_new::Deque, Stl_new::List]
+ yield method(:_sequence), container
+ end
+ yield method(:_set), Stl_new::Set
+ yield method(:_map), Stl_new::Map
+# for container in [Stl_new::Vector, Stl_new::Deque]
+# yield method(:_random_iterator), container
+# end
+end
+
+
+test do |proc, container|
+ proc.call(container)
+end
+
+
diff --git a/trunk/Examples/test-suite/ruby/struct_value_runme.rb b/trunk/Examples/test-suite/ruby/struct_value_runme.rb
new file mode 100644
index 000000000..afed41803
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/struct_value_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'struct_value'
+
+b = Struct_value::Bar.new
+
+b.a.x = 3
+raise RuntimeError if b.a.x != 3
+
+b.b.x = 3
+raise RuntimeError if b.b.x != 3
+
diff --git a/trunk/Examples/test-suite/ruby/swig_assert.rb b/trunk/Examples/test-suite/ruby/swig_assert.rb
new file mode 100755
index 000000000..200b08384
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/swig_assert.rb
@@ -0,0 +1,141 @@
+#!/usr/bin/env ruby
+#
+# A simple function to create useful asserts
+#
+#
+#
+#
+#
+
+
+#
+# Exception raised when some swig binding test fails
+#
+class SwigRubyError < RuntimeError
+end
+
+
+#
+# Asserts whether a and b are equal.
+#
+# scope - optional Binding where to run the code
+# msg - optional additional message to print
+#
+def swig_assert_equal( a, b, scope = nil, msg = nil )
+ begin
+ check = "#{a} == #{b}"
+ if scope.kind_of? Binding
+ ok = eval(check.to_s, scope)
+ else
+ ok = eval(check.to_s)
+ if !msg
+ msg = scope
+ scope = nil
+ end
+ end
+ rescue => e
+ raise
+ end
+
+ unless ok
+ valA = eval(a, scope)
+ valB = eval(b, scope)
+ raise SwigRubyError.new("FAILED EQUALITY: #{check} was #{valA} not #{valB}")
+ end
+
+ if $VERBOSE
+ $stdout.puts "\tPASSED EQUALITY #{check} #{msg}"
+ end
+
+ return ok
+rescue => e
+ trace = e.backtrace[1..-1]
+ $stderr.puts "#{trace[0,1]}: #{e}"
+ if trace.size > 1
+ $stderr.puts "\tfrom #{trace[1..-1].join("\n\t ")}"
+ end
+ exit(1)
+end
+
+
+#
+# Asserts whether an expression runs properly and is true
+#
+# scope - optional Binding where to run the code
+# msg - optional additional message to print
+#
+def swig_assert( expr, scope = nil, msg = nil )
+ begin
+ if scope.kind_of? Binding
+ ok = eval(expr.to_s, scope)
+ else
+ ok = eval(expr.to_s)
+ msg = scope if !msg
+ end
+ rescue
+ raise
+ end
+
+ raise SwigRubyError.new("FAILED: #{expr.to_s} - #{msg}") unless ok
+
+ if $VERBOSE
+ $stdout.puts "\tPASSED #{expr} #{msg}"
+ end
+rescue => e
+ trace = e.backtrace[1..-1]
+ $stderr.puts "#{trace[0,1]}: #{e}"
+ if trace.size > 1
+ $stderr.puts "\tfrom #{trace[1..-1].join("\n\t ")}"
+ end
+ exit(1)
+end
+
+#
+# Asserts whether an expression runs properly
+#
+# scope - optional Binding where to run the code
+# msg - optional additional message to print
+#
+def swig_eval( expr, scope = nil, msg = nil )
+ begin
+ if scope.kind_of? Binding
+ eval(expr.to_s, scope)
+ else
+ eval(expr.to_s)
+ msg = scope if !msg
+ end
+ rescue => e
+ raise SwigRubyError.new("Wrong assert: #{expr.to_s} - #{e}")
+ end
+ if $VERBOSE
+ $stdout.puts "\tPASSED #{expr} #{msg}"
+ end
+rescue => e
+ trace = e.backtrace[1..-1]
+ $stderr.puts "#{trace[0,1]}: #{e}"
+ if trace.size > 1
+ $stderr.puts "\tfrom #{trace[1..-1].join("\n\t ")}"
+ end
+ exit(1)
+end
+
+
+#
+# Given a set of lines as text, runs each of them, asserting them.
+# Lines that are of the form:
+# a == b are run with swig_assert_equal
+# others are run with swig_eval.
+#
+# scope - optional Binding where to run the code
+# msg - optional additional message to print
+#
+def swig_assert_each_line( lines, scope = nil, msg = nil )
+ lines.split("\n").each do |line|
+ next if line.empty? or line =~ /^\s*#.*/
+ if line =~ /^\s*([^\s]*)\s*==\s*(.*)\s*$/
+ swig_assert_equal($1, $2, scope, msg)
+ else
+ swig_eval(line, scope, msg)
+ end
+ end
+end
diff --git a/trunk/Examples/test-suite/ruby/swig_gc.rb b/trunk/Examples/test-suite/ruby/swig_gc.rb
new file mode 100755
index 000000000..30f6dfa42
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/swig_gc.rb
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby
+#
+#
+# VERY nice function from Robert Klemme to check memory leaks
+# and check on what GC has collected since last call.
+#
+# Usage can be:
+#
+# require 'swig_gc'
+#
+# GC.stats
+# # do some stuff..
+# GC.start # collect and report stats
+# # do some more...
+# GC.stats # just report stats
+#
+# or:
+#
+# require 'swig_gc'
+#
+# GC.track_class = String # track just String classes
+# GC.stats
+# # do some stuff..
+# GC.start # collect and report stats
+# # do some more...
+# GC.stats # just report stats
+#
+#
+#
+#
+#
+
+module GC
+
+ class << self
+
+ attr :last_stat
+ attr_accessor :track_class
+
+ alias :_start :start
+
+ def start
+ _start
+ stats if $VERBOSE
+ end
+
+ def stats
+ stats = Hash.new(0)
+ ObjectSpace.each_object {|o| stats[o.class] += 1}
+
+ if track_class
+ v = stats[track_class]
+ printf "\t%-30s %10d", track_class.to_s, v
+ if last_stat
+ printf " | delta %10d", (v - last_stat[track_class])
+ end
+ puts
+ else
+ stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v|
+ printf "\t%-30s %10d", k, v
+ printf " | delta %10d", (v - last_stat[k]) if last_stat
+ puts
+ end
+ end
+
+ last_stat = stats
+ end
+ end
+
+end
diff --git a/trunk/Examples/test-suite/ruby/template_construct_runme.rb b/trunk/Examples/test-suite/ruby/template_construct_runme.rb
new file mode 100644
index 000000000..4acebfe29
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_construct_runme.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_construct'
+
diff --git a/trunk/Examples/test-suite/ruby/template_extend1_runme.rb b/trunk/Examples/test-suite/ruby/template_extend1_runme.rb
new file mode 100644
index 000000000..999b181ba
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_extend1_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_extend1'
+
+a = Template_extend1::LBaz.new
+b = Template_extend1::DBaz.new
+
+raise RuntimeError unless a.foo() == "lBaz::foo"
+raise RuntimeError unless b.foo() == "dBaz::foo"
+
diff --git a/trunk/Examples/test-suite/ruby/template_extend2_runme.rb b/trunk/Examples/test-suite/ruby/template_extend2_runme.rb
new file mode 100644
index 000000000..89082b97c
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_extend2_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_extend2'
+
+a = Template_extend2::LBaz.new
+b = Template_extend2::DBaz.new
+
+raise RuntimeError unless a.foo() == "lBaz::foo"
+raise RuntimeError unless b.foo() == "dBaz::foo"
+
diff --git a/trunk/Examples/test-suite/ruby/template_inherit_runme.rb b/trunk/Examples/test-suite/ruby/template_inherit_runme.rb
new file mode 100755
index 000000000..609508891
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_inherit_runme.rb
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/template_ns4_runme.rb b/trunk/Examples/test-suite/ruby/template_ns4_runme.rb
new file mode 100755
index 000000000..bf2c5f566
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_ns4_runme.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_ns4'
+
+d = Template_ns4.make_Class_DD()
+raise RuntimeError if d.test() != "test"
diff --git a/trunk/Examples/test-suite/ruby/template_ns_runme.rb b/trunk/Examples/test-suite/ruby/template_ns_runme.rb
new file mode 100755
index 000000000..6446127cd
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_ns_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/template_rename_runme.rb b/trunk/Examples/test-suite/ruby/template_rename_runme.rb
new file mode 100755
index 000000000..18cfd4caa
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_rename_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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.groki_test(6)
+
+x = d.blah_test(7)
+y = d.spam(8)
+z = d.grok_test(9)
diff --git a/trunk/Examples/test-suite/ruby/template_tbase_template_runme.rb b/trunk/Examples/test-suite/ruby/template_tbase_template_runme.rb
new file mode 100644
index 000000000..43f055532
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_tbase_template_runme.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_tbase_template'
+
+include Template_tbase_template
+
+a = make_Class_dd()
+raise RuntimeError unless a.test() == "test"
+
diff --git a/trunk/Examples/test-suite/ruby/template_type_namespace_runme.rb b/trunk/Examples/test-suite/ruby/template_type_namespace_runme.rb
new file mode 100644
index 000000000..6db2fc424
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_type_namespace_runme.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_type_namespace'
+
+include Template_type_namespace
+
+result = foo()
+raise RuntimeError unless result[0].is_a? String
+
diff --git a/trunk/Examples/test-suite/ruby/template_typedef_cplx2_runme.rb b/trunk/Examples/test-suite/ruby/template_typedef_cplx2_runme.rb
new file mode 100644
index 000000000..a6eb04943
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_typedef_cplx2_runme.rb
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_typedef_cplx2'
+
+include Template_typedef_cplx2
+
+#
+# double case
+#
+
+
+d = make_Identity_double()
+raise RuntimeError, "#{d} is not an instance" if d.is_a? SWIG::Pointer
+
+classname = d.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{d} is not an ArithUnaryFunction"
+end
+
+e = make_Multiplies_double_double_double_double(d, d)
+raise RuntimeError, "#{e} is not an instance" if e.is_a? SWIG::Pointer
+
+classname = e.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{e} is not an ArithUnaryFunction"
+end
+
+
+#
+# complex case
+#
+
+c = make_Identity_complex()
+raise RuntimeError, "#{c}is not an instance" if c.is_a? SWIG::Pointer
+
+classname = c.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{c} is not an ArithUnaryFunction"
+end
+
+f = make_Multiplies_complex_complex_complex_complex(c, c)
+raise RuntimeError, "{f} is not an instance" if f.is_a? SWIG::Pointer
+
+classname = f.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{f} is not an ArithUnaryFunction"
+end
+
+#
+# Mix case
+#
+
+g = make_Multiplies_double_double_complex_complex(d, c)
+raise RuntimeError, "#{g} is not an instance" if g.is_a? SWIG::Pointer
+
+classname = g.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{g} is not an ArithUnaryFunction"
+end
+
+# This should raise NoMethodError if it fails
+g.get_value()
+
+h = make_Multiplies_complex_complex_double_double(c, d)
+raise RuntimeError, "#{h} is not an instance" if h.is_a? SWIG::Pointer
+
+classname = h.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{h} is not an ArithUnaryFunction"
+end
+
+
diff --git a/trunk/Examples/test-suite/ruby/template_typedef_cplx3_runme.rb b/trunk/Examples/test-suite/ruby/template_typedef_cplx3_runme.rb
new file mode 100644
index 000000000..98a880326
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_typedef_cplx3_runme.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_typedef_cplx3'
+
+include Template_typedef_cplx3
+
+#
+# this is OK
+#
+
+
+s = Sin.new
+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.new
+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/trunk/Examples/test-suite/ruby/template_typedef_cplx4_runme.rb b/trunk/Examples/test-suite/ruby/template_typedef_cplx4_runme.rb
new file mode 100644
index 000000000..d67e3cd3e
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_typedef_cplx4_runme.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_typedef_cplx4'
+
+include Template_typedef_cplx4
+
+#
+# this is OK
+#
+
+
+s = Sin.new
+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.new
+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/trunk/Examples/test-suite/ruby/template_typedef_cplx_runme.rb b/trunk/Examples/test-suite/ruby/template_typedef_cplx_runme.rb
new file mode 100644
index 000000000..eac337a2f
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/template_typedef_cplx_runme.rb
@@ -0,0 +1,77 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'template_typedef_cplx'
+
+include Template_typedef_cplx
+
+#
+# double case
+#
+
+
+d = make_Identity_double()
+raise RuntimeError, "#{d} is not an instance" if d.is_a? SWIG::Pointer
+
+classname = d.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{d} is not an ArithUnaryFunction"
+end
+
+e = make_Multiplies_double_double_double_double(d, d)
+raise RuntimeError, "#{e} is not an instance" if e.is_a? SWIG::Pointer
+
+classname = e.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{e} is not an ArithUnaryFunction"
+end
+
+
+#
+# complex case
+#
+
+c = make_Identity_complex()
+raise RuntimeError, "#{c}is not an instance" if c.is_a? SWIG::Pointer
+
+classname = c.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{c} is not an ArithUnaryFunction"
+end
+
+f = make_Multiplies_complex_complex_complex_complex(c, c)
+raise RuntimeError, "{f} is not an instance" if f.is_a? SWIG::Pointer
+
+classname = f.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{f} is not an ArithUnaryFunction"
+end
+
+#
+# Mix case
+#
+
+g = make_Multiplies_double_double_complex_complex(d, c)
+raise RuntimeError, "#{g} is not an instance" if g.is_a? SWIG::Pointer
+
+classname = g.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{g} is not an ArithUnaryFunction"
+end
+
+h = make_Multiplies_complex_complex_double_double(c, d)
+raise RuntimeError, "#{h} is not an instance" if h.is_a? SWIG::Pointer
+
+classname = h.class.name.split(/::/).last
+unless classname =~ /ArithUnaryFunction/
+ raise RuntimeError, "#{h} is not an ArithUnaryFunction"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/throw_exception_runme.rb b/trunk/Examples/test-suite/ruby/throw_exception_runme.rb
new file mode 100644
index 000000000..f21ff9484
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/throw_exception_runme.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'throw_exception'
+
+include Throw_exception
+
+foo = Foo.new
+
+begin
+ foo.test_int
+rescue => ex
+ raise RuntimeError if ex.message != "37"
+end
+
+begin
+ foo.test_msg
+rescue => ex
+ raise RuntimeError if ex.message != "Dead"
+end
+
+begin
+ foo.test_multi(1)
+rescue => ex
+ raise RuntimeError if ex.message != "37"
+end
+
+begin
+ foo.test_multi(2)
+rescue => ex
+ raise RuntimeError if ex.message != "Dead"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/typedef_inherit_runme.rb b/trunk/Examples/test-suite/ruby/typedef_inherit_runme.rb
new file mode 100755
index 000000000..029b80c70
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/typedef_inherit_runme.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/typedef_scope_runme.rb b/trunk/Examples/test-suite/ruby/typedef_scope_runme.rb
new file mode 100755
index 000000000..4858a2ef6
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/typedef_scope_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/typemap_namespace_runme.rb b/trunk/Examples/test-suite/ruby/typemap_namespace_runme.rb
new file mode 100755
index 000000000..09eb57e39
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/typemap_namespace_runme.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'typemap_namespace'
+
+include Typemap_namespace
+
+raise RuntimeError if test1("hello") != "hello"
+
+raise RuntimeError if test2("hello") != "hello"
diff --git a/trunk/Examples/test-suite/ruby/typemap_ns_using_runme.rb b/trunk/Examples/test-suite/ruby/typemap_ns_using_runme.rb
new file mode 100644
index 000000000..80f38c322
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/typemap_ns_using_runme.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'typemap_ns_using'
+
+raise RuntimeError unless Typemap_ns_using.spam(37) == 37
+
diff --git a/trunk/Examples/test-suite/ruby/typename_runme.rb b/trunk/Examples/test-suite/ruby/typename_runme.rb
new file mode 100755
index 000000000..65de7334d
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/typename_runme.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+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/trunk/Examples/test-suite/ruby/unions_runme.rb b/trunk/Examples/test-suite/ruby/unions_runme.rb
new file mode 100644
index 000000000..00a8703f9
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/unions_runme.rb
@@ -0,0 +1,65 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+
+# 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/trunk/Examples/test-suite/ruby/using1_runme.rb b/trunk/Examples/test-suite/ruby/using1_runme.rb
new file mode 100644
index 000000000..44fcf129b
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using1_runme.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using1'
+
+raise RuntimeError unless Using1.spam(37) == 37
+
diff --git a/trunk/Examples/test-suite/ruby/using2_runme.rb b/trunk/Examples/test-suite/ruby/using2_runme.rb
new file mode 100644
index 000000000..1eb72c16f
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using2_runme.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using2'
+
+raise RuntimeError unless Using2.spam(37) == 37
+
diff --git a/trunk/Examples/test-suite/ruby/using_composition_runme.rb b/trunk/Examples/test-suite/ruby/using_composition_runme.rb
new file mode 100644
index 000000000..b9500cb27
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using_composition_runme.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using_composition'
+
+include Using_composition
+
+f = FooBar.new
+if f.blah(3) != 3
+ raise RuntimeError,"FooBar::blah(int)"
+end
+
+if f.blah(3.5) != 3.5
+ raise RuntimeError,"FooBar::blah(double)"
+end
+
+if f.blah("hello") != "hello"
+ raise RuntimeError,"FooBar::blah(char *)"
+end
+
+
+f = FooBar2.new
+if f.blah(3) != 3
+ raise RuntimeError,"FooBar2::blah(int)"
+end
+
+if f.blah(3.5) != 3.5
+ raise RuntimeError,"FooBar2::blah(double)"
+end
+
+if f.blah("hello") != "hello"
+ raise RuntimeError,"FooBar2::blah(char *)"
+end
+
+
+f = FooBar3.new
+if f.blah(3) != 3
+ raise RuntimeError,"FooBar3::blah(int)"
+end
+
+if f.blah(3.5) != 3.5
+ raise RuntimeError,"FooBar3::blah(double)"
+end
+
+if f.blah("hello") != "hello"
+ raise RuntimeError,"FooBar3::blah(char *)"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/using_extend_runme.rb b/trunk/Examples/test-suite/ruby/using_extend_runme.rb
new file mode 100644
index 000000000..4caaa5bb6
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using_extend_runme.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using_extend'
+
+include Using_extend
+
+f = FooBar.new
+if f.blah(3) != 3
+ raise RuntimeError,"blah(int)"
+end
+
+if f.blah(3.5) != 3.5
+ raise RuntimeError,"blah(double)"
+end
+
+if f.blah("hello") != "hello"
+ raise RuntimeError,"blah(char *)"
+end
+
+if f.blah(3,4) != 7
+ raise RuntimeError,"blah(int,int)"
+end
+
+if f.blah(3.5,7.5) != (3.5+7.5)
+ raise RuntimeError,"blah(double,double)"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/using_inherit_runme.rb b/trunk/Examples/test-suite/ruby/using_inherit_runme.rb
new file mode 100644
index 000000000..1b7e4043a
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using_inherit_runme.rb
@@ -0,0 +1,74 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using_inherit'
+
+include Using_inherit
+
+b = Bar.new
+if b.test(3) != 3
+ raise RuntimeError,"Bar::test(int)"
+end
+
+if b.test(3.5) != 3.5
+ raise RuntimeError, "Bar::test(double)"
+end
+
+b = Bar2.new
+if b.test(3) != 6
+ raise RuntimeError,"Bar2::test(int)"
+end
+
+if b.test(3.5) != 7.0
+ raise RuntimeError, "Bar2::test(double)"
+end
+
+
+b = Bar3.new
+if b.test(3) != 6
+ raise RuntimeError,"Bar3::test(int)"
+end
+
+if b.test(3.5) != 7.0
+ raise RuntimeError, "Bar3::test(double)"
+end
+
+
+b = Bar4.new
+if b.test(3) != 6
+ raise RuntimeError,"Bar4::test(int)"
+end
+
+if b.test(3.5) != 7.0
+ raise RuntimeError, "Bar4::test(double)"
+end
+
+
+b = Fred1.new
+if b.test(3) != 3
+ raise RuntimeError,"Fred1::test(int)"
+end
+
+if b.test(3.5) != 7.0
+ raise RuntimeError, "Fred1::test(double)"
+end
+
+
+b = Fred2.new
+if b.test(3) != 3
+ raise RuntimeError,"Fred2::test(int)"
+end
+
+if b.test(3.5) != 7.0
+ raise RuntimeError, "Fred2::test(double)"
+end
+
+
diff --git a/trunk/Examples/test-suite/ruby/using_private_runme.rb b/trunk/Examples/test-suite/ruby/using_private_runme.rb
new file mode 100644
index 000000000..cf6928ce8
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using_private_runme.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using_private'
+
+include Using_private
+
+f = FooBar.new
+f.x = 3
+
+if f.blah(4) != 4
+ raise RuntimeError, "blah(int)"
+end
+
+if f.defaulted() != -1
+ raise RuntimeError, "defaulted()"
+end
+
+if f.defaulted(222) != 222
+ raise RuntimeError, "defaulted(hi)"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/using_protected_runme.rb b/trunk/Examples/test-suite/ruby/using_protected_runme.rb
new file mode 100644
index 000000000..3b4f88b55
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/using_protected_runme.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'using_protected'
+
+include Using_protected
+
+f = FooBar.new
+f.x = 3
+
+if f.blah(4) != 4
+ raise RuntimeError, "blah(int)"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/varargs_runme.rb b/trunk/Examples/test-suite/ruby/varargs_runme.rb
new file mode 100644
index 000000000..9825c2511
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/varargs_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'varargs'
+
+if Varargs.test("Hello") != "Hello"
+ raise RuntimeError, "Failed"
+end
+
+f = Varargs::Foo.new("Greetings")
+if f.str != "Greetings"
+ raise RuntimeError, "Failed"
+end
+
+if f.test("Hello") != "Hello"
+ raise RuntimeError, "Failed"
+end
+
diff --git a/trunk/Examples/test-suite/ruby/virtual_derivation_runme.rb b/trunk/Examples/test-suite/ruby/virtual_derivation_runme.rb
new file mode 100644
index 000000000..a739ddfe2
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/virtual_derivation_runme.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'virtual_derivation'
+
+b = Virtual_derivation::B.new 3
+
+if b.get_a() != b.get_b()
+ print "something is still wrong ", b.get_a(), b.get_b(), "\n"
+end
diff --git a/trunk/Examples/test-suite/ruby/virtual_poly_runme.rb b/trunk/Examples/test-suite/ruby/virtual_poly_runme.rb
new file mode 100644
index 000000000..38752cc3f
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/virtual_poly_runme.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'virtual_poly'
+
+d = Virtual_poly::NDouble.new(3.5)
+i = Virtual_poly::NInt.new(2)
+
+#
+# polymorphic return type working
+#
+dc = d.copy
+ic = i.copy
+
+raise RuntimeError if d.get != dc.get
+raise RuntimeError if i.get != ic.get
+
+#
+# 'narrowing' working ('nnumber' returns a NNumber)
+#
+ddc = Virtual_poly::NDouble.narrow(dc.nnumber)
+raise RuntimeError if d.get != ddc.get
+
+dic = Virtual_poly::NInt.narrow(ic.nnumber)
+raise RuntimeError if i.get != dic.get
diff --git a/trunk/Examples/test-suite/ruby/voidtest_runme.rb b/trunk/Examples/test-suite/ruby/voidtest_runme.rb
new file mode 100644
index 000000000..33cffe6f7
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby/voidtest_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'voidtest'
+
+Voidtest.globalfunc()
+f = Voidtest::Foo.new
+f.memberfunc()
+
+Voidtest::Foo.staticmemberfunc()
+
+v1 = Voidtest::vfunc1(f)
+v3 = Voidtest::vfunc3(v1)
+
+v3.memberfunc()
+
diff --git a/trunk/Examples/test-suite/ruby_keywords.i b/trunk/Examples/test-suite/ruby_keywords.i
new file mode 100644
index 000000000..c87efab33
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby_keywords.i
@@ -0,0 +1,65 @@
+%module ruby_keywords
+
+// fix up conflicts with C++ keywords
+%rename("and") Keywords::and_;
+%rename("break") Keywords::break_;
+%rename("case") Keywords::case_;
+%rename("class") Keywords::class_;
+%rename("defined?") Keywords::defined_;
+%rename("do") Keywords::do_;
+%rename("else") Keywords::else_;
+%rename("false") Keywords::false_;
+%rename("for") Keywords::for_;
+%rename("if") Keywords::if_;
+%rename("not") Keywords::not_;
+%rename("return") Keywords::return_;
+%rename("or") Keywords::or_;
+%rename("true") Keywords::true_;
+%rename("while") Keywords::while_;
+
+
+%inline %{
+
+class Keywords {
+public:
+ Keywords() {}
+
+ const char* alias() { return "alias"; }
+ const char* and_() { return "and"; }
+ const char* begin() { return "begin"; }
+ const char* break_() { return "break"; }
+ const char* case_() { return "case"; }
+ const char* class_() { return "class"; }
+ const char* def() { return "def"; }
+ const char* defined_() { return "defined?"; }
+ const char* do_() { return "do"; }
+ const char* else_() { return "else"; }
+ const char* elsif() { return "elsif"; }
+ const char* end() { return "end"; }
+ const char* ensure() { return "ensure"; }
+ const char* false_() { return "false"; }
+ const char* for_() { return "for"; }
+ const char* if_() { return "if"; }
+ const char* in() { return "in"; }
+ const char* module() { return "module"; }
+ const char* next() { return "next"; }
+ const char* nil() { return "nil"; }
+ const char* not_() { return "not"; }
+ const char* or_() { return "or"; }
+ const char* redo() { return "redo"; }
+ const char* rescue() { return "rescue"; }
+ const char* retry() { return "retry"; }
+ const char* return_() { return "return"; }
+ const char* self() { return "self"; }
+ const char* super() { return "super"; }
+ const char* then() { return "then"; }
+ const char* true_() { return "true"; }
+ const char* undef() { return "undef"; }
+ const char* under() { return "under"; }
+ const char* unless() { return "unless"; }
+ const char* until() { return "until"; }
+ const char* when() { return "when"; }
+ const char* while_() { return "while"; }
+ const char* yield() { return "yield"; }
+};
+%}
diff --git a/trunk/Examples/test-suite/ruby_li_std_speed.i b/trunk/Examples/test-suite/ruby_li_std_speed.i
new file mode 100644
index 000000000..bfb0b2776
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby_li_std_speed.i
@@ -0,0 +1,17 @@
+// A speed test of the ruby stl
+%module ruby_li_std_speed
+
+%include <std_list.i>
+%include <std_vector.i>
+%include <std_deque.i>
+%include <std_set.i>
+
+%template(RbList) std::list<swig::GC_VALUE>;
+%template(RbVector) std::vector<swig::GC_VALUE>;
+%template(RbDeque) std::deque<swig::GC_VALUE>;
+%template(RbSet) std::set<swig::GC_VALUE>;
+
+%template(RbFloatList) std::list<float>;
+%template(RbFloatVector) std::vector<float>;
+%template(RbFloatDeque) std::deque<float>;
+%template(RbFloatSet) std::set<float>;
diff --git a/trunk/Examples/test-suite/ruby_naming.i b/trunk/Examples/test-suite/ruby_naming.i
new file mode 100644
index 000000000..d8ef50ad3
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby_naming.i
@@ -0,0 +1,107 @@
+%module ruby_naming
+
+%predicate predicateMethod();
+%bang bangMethod();
+
+/* This gets mapped to a constant */
+%constant int constant1 = 1;
+
+/* This gets mapped to a constant */
+#define constant2 2
+
+%immutable TestConstants::constant8;
+
+%inline %{
+
+/* ============ Test Constants Names ============== */
+
+/* This gets mapped to a constant */
+#define constant3 3
+
+/* These are all singleton methods */
+const int constant4[2] = {10, 20};
+const int constant5 = 5;
+static const int constant6 = 6;
+
+
+class TestConstants {
+public:
+ TestConstants() : constant7(7) {}
+
+ /* This gets mapped to a method */
+ const int constant7;
+
+ /* This gets mapped to a singleton method, but this is not legal C++ */
+ static const int constant8;
+
+ /* This gets mapped to a method, but this it not legal C++ */
+ /*const int constant9 = 9;*/
+
+ /* This gets mapped to a constant */
+ static const int constant10 = 10;
+};
+
+const int TestConstants::constant8 = 8;
+
+const TestConstants * constant11[5];
+
+
+/* ============ Test Enum ============== */
+typedef enum {Red, Green, Blue} Colors;
+
+
+/* ============ Test Method Names ============== */
+class my_class {
+public:
+ int methodOne()
+ {
+ return 1;
+ }
+
+ int MethodTwo()
+ {
+ return 2;
+ }
+
+ int Method_THREE()
+ {
+ return 3;
+ }
+
+ int Method44_4()
+ {
+ return 4;
+ }
+
+ bool predicateMethod()
+ {
+ return true;
+ }
+
+ bool bangMethod()
+ {
+ return true;
+ }
+ int begin()
+ {
+ return 1;
+ }
+
+ int end()
+ {
+ return 1;
+ }
+
+};
+
+%}
+
+%inline
+{
+ template <class _Type>
+ struct A
+ {
+ };
+}
+
+%template(A_i) A<int>;
diff --git a/trunk/Examples/test-suite/ruby_track_objects.i b/trunk/Examples/test-suite/ruby_track_objects.i
new file mode 100644
index 000000000..f4bbb37e7
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby_track_objects.i
@@ -0,0 +1,125 @@
+%module ruby_track_objects
+
+%include typemaps.i
+
+%trackobjects Foo;
+
+%newobject Bar::get_new_foo;
+
+%typemap(in, numinputs=0) Foo** foo (Foo *temp) {
+ /* %typemap(in, numinputs=0) Foo** foo */
+ $1 = &temp;
+}
+
+%typemap(argout) Foo** foo {
+ /* %typemap(argout) Foo** foo */
+ $result = SWIG_NewPointerObj((void *) *$1, $*1_descriptor, 0);
+}
+
+%apply SWIGTYPE *DISOWN {Foo* ownedFoo};
+
+
+%trackobjects ItemA;
+%trackobjects ItemB;
+
+%inline %{
+
+class Foo
+{
+public:
+ Foo() {}
+ ~Foo() {}
+
+ /* Helper method that can be called from Ruby that checks
+ that two Ruby objects are pointing to the same underlying
+ C++ object */
+ bool cpp_equal(const Foo* other)
+ {
+ return (this == other);
+ }
+
+ /* Just a simple method to call on Foo*/
+ const char* say_hello()
+ {
+ return "Hello";
+ }
+};
+
+
+class Bar
+{
+private:
+ Foo* owned_;
+ Foo* unowned_;
+public:
+ Bar(): owned_(new Foo), unowned_(0)
+ {
+ }
+
+ ~Bar()
+ {
+ delete owned_;
+ }
+
+ /* Test that track objects works with %newobject */
+ static Foo* get_new_foo()
+ {
+ return new Foo;
+ }
+
+ /* Test the same foo Ruby object is created each time */
+ Foo* get_owned_foo()
+ {
+ return owned_;
+ }
+
+ /* Test that track objects works with argout parameters.*/
+ void get_owned_foo_by_argument(Foo** foo)
+ {
+ *foo = owned_;
+ }
+
+ /* Test that track objects works with the DISOWN typemap.*/
+ void set_owned_foo(Foo* ownedFoo)
+ {
+ delete owned_;
+ owned_ = ownedFoo;
+ }
+
+ Foo* get_unowned_foo()
+ {
+ return unowned_;
+ }
+
+ void set_unowned_foo(Foo* foo)
+ {
+ unowned_ = foo;
+ }
+};
+
+class ItemA
+{
+};
+
+class ItemB: public ItemA
+{
+public:
+};
+
+ItemB* downcast(ItemA* item)
+{
+ return static_cast<ItemB*>(item);
+}
+
+class Factory
+{
+public:
+ Factory() {}
+
+ ItemA* createItem()
+ {
+ return new ItemB;
+ }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/ruby_track_objects_directors.i b/trunk/Examples/test-suite/ruby_track_objects_directors.i
new file mode 100644
index 000000000..131209828
--- /dev/null
+++ b/trunk/Examples/test-suite/ruby_track_objects_directors.i
@@ -0,0 +1,44 @@
+%module(directors="1") ruby_track_objects_directors
+
+%{
+#include <string>
+%}
+
+%include "std_string.i";
+%feature("director") Foo;
+
+%trackobjects;
+
+%inline %{
+
+class Foo {
+public:
+ Foo() {}
+ virtual ~Foo() {}
+ virtual std::string ping()
+ {
+ return "Foo::ping()";
+ }
+
+ virtual std::string pong()
+ {
+ return "Foo::pong();" + ping();
+ }
+};
+
+
+class Container {
+ Foo* foo_;
+public:
+ Foo* get_foo()
+ {
+ return foo_;
+ }
+
+ void set_foo(Foo *foo)
+ {
+ foo_ = foo;
+ }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/samename.i b/trunk/Examples/test-suite/samename.i
new file mode 100644
index 000000000..819cb4abd
--- /dev/null
+++ b/trunk/Examples/test-suite/samename.i
@@ -0,0 +1,22 @@
+%module samename
+
+#if !(defined(SWIGCSHARP) || defined(SWIGJAVA))
+class samename {
+ public:
+ void do_something() {
+ // ...
+ }
+};
+#endif
+
+%{
+
+class samename {
+ public:
+ void do_something() {
+ // ...
+ }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/samename_runme.m b/trunk/Examples/test-suite/samename_runme.m
new file mode 100644
index 000000000..a3864cfc8
--- /dev/null
+++ b/trunk/Examples/test-suite/samename_runme.m
@@ -0,0 +1 @@
+samename
diff --git a/trunk/Examples/test-suite/schemerunme/casts.scm b/trunk/Examples/test-suite/schemerunme/casts.scm
new file mode 100644
index 000000000..8a566ec3c
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/casts.scm
@@ -0,0 +1,8 @@
+(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/trunk/Examples/test-suite/schemerunme/char_constant.scm b/trunk/Examples/test-suite/schemerunme/char_constant.scm
new file mode 100644
index 000000000..81ee7da35
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/char_constant.scm
@@ -0,0 +1,4 @@
+(if (and (char? (CHAR-CONSTANT))
+ (string? (STRING-CONSTANT)))
+ (exit 0)
+ (exit 1))
diff --git a/trunk/Examples/test-suite/schemerunme/class_ignore.scm b/trunk/Examples/test-suite/schemerunme/class_ignore.scm
new file mode 100644
index 000000000..2a62e7b66
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/class_ignore.scm
@@ -0,0 +1,6 @@
+(define a (new-Bar))
+
+(if (not (string=? (Bar-blah a) "Bar::blah"))
+ (error "Wrong string"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/constover.scm b/trunk/Examples/test-suite/schemerunme/constover.scm
new file mode 100644
index 000000000..38c30cb70
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/constover.scm
@@ -0,0 +1,26 @@
+(define p (test "test"))
+(if (not (string=? p "test"))
+ (error "test failed!"))
+
+(set! p (test-pconst "test"))
+(if (not (string=? p "test_pconst"))
+ (error "test_pconst failed!"))
+
+(define f (new-Foo))
+(set! p (Foo-test f "test"))
+(if (not (string=? p "test"))
+ (error "member-test failed!"))
+
+(set! p (Foo-test-pconst f "test"))
+(if (not (string=? p "test_pconst"))
+ (error "member-test_pconst failed!"))
+
+(set! p (Foo-test-constm f "test"))
+(if (not (string=? p "test_constmethod"))
+ (error "member-test_constm failed!"))
+
+(set! p (Foo-test-pconstm f "test"))
+(if (not (string=? p "test_pconstmethod"))
+ (error "member-test_pconstm failed!"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/contract.scm b/trunk/Examples/test-suite/schemerunme/contract.scm
new file mode 100644
index 000000000..16dd069dd
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/contract.scm
@@ -0,0 +1,14 @@
+(test-preassert 1 2)
+(expect-throw 'swig-contract-assertion-failed
+ (test-preassert -1 2))
+(test-postassert 3)
+(expect-throw 'swig-contract-assertion-failed
+ (test-postassert -3))
+(test-prepost 2 3)
+(test-prepost 5 -4)
+(expect-throw 'swig-contract-assertion-failed
+ (test-prepost -3 4))
+(expect-throw 'swig-contract-assertion-failed
+ (test-prepost 4 -10))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/cpp_enum.scm b/trunk/Examples/test-suite/schemerunme/cpp_enum.scm
new file mode 100644
index 000000000..101c0dabe
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/cpp_enum.scm
@@ -0,0 +1,21 @@
+(define f (new-Foo))
+
+(if (not (= (Foo-hola-get f) (Foo-Hello)))
+ (error "Error 1"))
+
+(Foo-hola-set f (Foo-Hi))
+
+(if (not (= (Foo-hola-get f) (Foo-Hi)))
+ (error "Error 2"))
+
+(Foo-hola-set f (Foo-Hello))
+
+(if (not (= (Foo-hola-get f) (Foo-Hello)))
+ (error "Error 3"))
+
+(hi (Hello))
+
+(if (not (= (hi) (Hello)))
+ (error "Error 4"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/cpp_namespace.scm b/trunk/Examples/test-suite/schemerunme/cpp_namespace.scm
new file mode 100644
index 000000000..ecfdab540
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/cpp_namespace.scm
@@ -0,0 +1,42 @@
+(define n (fact 4))
+(if (not (= n 24))
+ (error "Bad return value!"))
+
+(if (not (= (Foo) 42))
+ (error "bad variable value!"))
+
+(define t (new-Test))
+(if (not (string=? (Test-method t) "Test::method"))
+ (error "Bad method return value!"))
+
+(if (not (string=? (do-method t) "Test::method"))
+ (error "Bad return value!"))
+
+(if (not (string=? (do-method2 t) "Test::method"))
+ (error "Bad return value!"))
+
+(weird "hello" 4)
+
+;; (delete-Test t)
+
+(define t2 (new-Test2))
+(define t3 (new-Test3))
+(define t4 (new-Test4))
+(define t5 (new-Test5))
+
+(if (not (= (foo3 42) 42))
+ (error "Bad return value!"))
+
+(if (not (string=? (do-method3 t2 40) "Test2::method"))
+ (error "bad return value!"))
+
+(if (not (string=? (do-method3 t3 40) "Test3::method"))
+ (error "bad return value"))
+
+(if (not (string=? (do-method3 t4 40) "Test4::method"))
+ (error "bad return value"))
+
+(if (not (string=? (do-method3 t5 40) "Test5::method"))
+ (error "bad return value"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/dynamic_cast.scm b/trunk/Examples/test-suite/schemerunme/dynamic_cast.scm
new file mode 100644
index 000000000..ebb44de69
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/dynamic_cast.scm
@@ -0,0 +1,11 @@
+(define f (new-Foo))
+(define b (new-Bar))
+
+(define x (Foo-blah f))
+(define y (Bar-blah b))
+
+(define a (do-test y))
+(if (not (string=? a "Bar::test"))
+ (error "Failed!"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/global_vars.scm b/trunk/Examples/test-suite/schemerunme/global_vars.scm
new file mode 100644
index 000000000..a3e021952
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/global_vars.scm
@@ -0,0 +1,31 @@
+(define-macro (check test)
+ `(if (not ,test) (error "Error in test" ',test)))
+
+(b "hello")
+(check (string=? (b) "hello"))
+
+(define sa (new-A))
+(A-x-set sa 5)
+(a sa)
+(check (= (A-x-get (a)) 5))
+
+(ap sa)
+(check (= (A-x-get (ap)) 5))
+(A-x-set sa 10)
+(check (= (A-x-get (ap)) 10))
+
+(define sa2 (new-A))
+(A-x-set sa2 -4)
+(cap sa2)
+(check (= (A-x-get (cap)) -4))
+(A-x-set sa2 -7)
+(check (= (A-x-get (cap)) -7))
+
+(check (= (A-x-get (ar)) 5))
+(ar sa2)
+(check (= (A-x-get (ar)) -7))
+
+(x 4)
+(check (= (x) 4))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/global_vars_proxy.scm b/trunk/Examples/test-suite/schemerunme/global_vars_proxy.scm
new file mode 100644
index 000000000..41d73379b
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/global_vars_proxy.scm
@@ -0,0 +1,31 @@
+(define-macro (check test)
+ `(if (not ,test) (error "Error in test" ',test)))
+
+(b "hello")
+(check (string=? (b) "hello"))
+
+(define sa (make <A>))
+(slot-set! sa 'x 5)
+(a sa)
+(check (= (slot-ref (a) 'x) 5))
+
+(ap sa)
+(check (= (slot-ref (ap) 'x) 5))
+(slot-set! sa 'x 10)
+(check (= (slot-ref (ap) 'x) 10))
+
+(define sa2 (make <A>))
+(slot-set! sa2 'x -4)
+(cap sa2)
+(check (= (slot-ref (cap) 'x) -4))
+(slot-set! sa2 'x -7)
+(check (= (slot-ref (cap) 'x) -7))
+
+(check (= (slot-ref (ar) 'x) 5))
+(ar sa2)
+(check (= (slot-ref (ar) 'x) -7))
+
+(x 4)
+(check (= (x) 4))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/import_nomodule.scm b/trunk/Examples/test-suite/schemerunme/import_nomodule.scm
new file mode 100644
index 000000000..4598a8b4f
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/import_nomodule.scm
@@ -0,0 +1,7 @@
+(define f (create-Foo))
+(test1 f 42)
+
+(define b (new-Bar))
+(test1 b 37)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/imports.scm b/trunk/Examples/test-suite/schemerunme/imports.scm
new file mode 100644
index 000000000..663cc8bc0
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/imports.scm
@@ -0,0 +1,13 @@
+;;; This file is part of a test for SF bug #231619.
+;;; It shows that the %import directive does not work properly in SWIG
+;;; 1.3a5: Type information is not properly generated if a base class
+;;; comes from an %import-ed file.
+
+(define x (new-B))
+
+;; This fails in 1.3a5 because the SWIG runtime code does not know
+;; that x (an instance of class B) can be passed to methods of class A.
+
+(A-hello x)
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/inherit_missing.scm b/trunk/Examples/test-suite/schemerunme/inherit_missing.scm
new file mode 100644
index 000000000..1b9bd0ef0
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/inherit_missing.scm
@@ -0,0 +1,14 @@
+(define a (new-Foo))
+(define b (new-Bar))
+(define c (new-Spam))
+
+(if (not (string=? (do-blah a) "Foo::blah"))
+ (error "Bad return"))
+
+(if (not (string=? (do-blah b) "Bar::blah"))
+ (error "Bad return"))
+
+(if (not (string=? (do-blah c) "Spam::blah"))
+ (error "bad return"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/integers.scm b/trunk/Examples/test-suite/schemerunme/integers.scm
new file mode 100644
index 000000000..0bbf36ea8
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/integers.scm
@@ -0,0 +1,28 @@
+(define-macro (check-equality form1 form2)
+ `(let ((result1 ,form1)
+ (result2 ,form2))
+ (if (not (equal? result1 result2))
+ (error "Check failed:"
+ (list 'equal? ',form1 ',form2)
+ result1 result2))))
+
+(define-macro (check-range function from to)
+ `(begin (check-equality (,function ,from) ,from)
+ (check-equality (,function ,to) ,to)
+ (check-equality (throws-exception? (,function (- ,from 1))) #t)
+ (check-equality (throws-exception? (,function (+ ,to 1))) #t)))
+
+;;; signed char, unsigned char typemaps deal with characters, not integers.
+;; (check-range signed-char-identity (- (expt 2 7)) (- (expt 2 7) 1))
+;; (check-range unsigned-char-identity 0 (- (expt 2 8) 1))
+(check-range signed-short-identity (- (expt 2 15)) (- (expt 2 15) 1))
+(check-range unsigned-short-identity 0 (- (expt 2 16) 1))
+(check-range signed-int-identity (- (expt 2 31)) (- (expt 2 31) 1))
+(check-range unsigned-int-identity 0 (- (expt 2 32) 1))
+(check-range signed-long-identity (- (expt 2 31)) (- (expt 2 31) 1))
+(check-range unsigned-long-identity 0 (- (expt 2 32) 1))
+;;; long long not implemented in Guile and MzScheme.
+;; (check-range signed-long-long-identity (- (expt 2 63)) (- (expt 2 63) 1))
+;; (check-range unsigned-long-long-identity 0 (- (expt 2 64) 1))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/li_std_string.scm b/trunk/Examples/test-suite/schemerunme/li_std_string.scm
new file mode 100644
index 000000000..e77c32870
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/li_std_string.scm
@@ -0,0 +1,46 @@
+(define x "hello")
+
+(if (not (string=? (test-value x) x))
+ (begin (error "Error 1") (exit 1)))
+
+(if (not (string=? (test-const-reference x) x))
+ (begin (error "Error 2") (exit 1)))
+
+(define y (test-pointer-out))
+(test-pointer y)
+(define z (test-const-pointer-out))
+(test-const-pointer z)
+
+(define a (test-reference-out))
+(test-reference a)
+
+;; test global variables
+(GlobalString "whee")
+(if (not (string=? (GlobalString) "whee"))
+ (error "Error 3"))
+(if (not (string=? (GlobalString2) "global string 2"))
+ (error "Error 4"))
+
+(define struct (new-Structure))
+
+;; MemberString should be a wrapped class
+(define scl (Structure-MemberString-get struct))
+(if (not (string=? scl ""))
+ (error "Error 4.5"))
+(Structure-MemberString-set struct "and how")
+(if (not (string=? (Structure-MemberString-get struct) "and how"))
+ (error "Error 5"))
+(if (not (string=? (Structure-MemberString2-get struct) "member string 2"))
+ (error "Error 6"))
+(Structure-StaticMemberString "static str")
+(if (not (string=? (Structure-StaticMemberString) "static str"))
+ (error "Error 7"))
+(if (not (string=? (Structure-StaticMemberString2) "static member string 2"))
+ (error "Error 8"))
+
+;(if (not (string=? (Structure-ConstMemberString-get struct) "const member string"))
+; (error "Error 9"))
+(if (not (string=? (Structure-ConstStaticMemberString) "const static member string"))
+ (error "Error 10"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/li_typemaps.scm b/trunk/Examples/test-suite/schemerunme/li_typemaps.scm
new file mode 100644
index 000000000..161e803bb
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/li_typemaps.scm
@@ -0,0 +1,45 @@
+(define-macro (check func val test)
+ (cons 'begin
+ (map
+ (lambda (x)
+ `(if (not (,test (,(string->symbol (string-append x func)) ,val) ,val))
+ (error ,(string-append "Error in test " x func))))
+ (list "in-" "inr-" "out-" "outr-" "inout-" "inoutr-"))))
+
+(define (=~ a b)
+ (< (abs (- a b)) 1e-5))
+
+(check "bool" #t and)
+(check "int" -2 =)
+(check "long" -32 =)
+(check "short" -15 =)
+(check "uint" 75 =)
+(check "ushort" 123 =)
+(check "ulong" 462 =)
+;(check "uchar" 16 =)
+;(check "schar" -53 =)
+(check "float" 4.3 =~)
+(check "double" -175.42 =~)
+;(check "longlong" 1634 =)
+;(check "ulonglong" 6432 =)
+
+;; The checking of inoutr-int2 and out-foo is done in the individual
+;; language runme scripts, since chicken returns multiple values
+;; and must be checked with call-with-values, while guile just returns a list
+
+;(call-with-values (lambda () (inoutr-int2 3 -2))
+; (lambda (a b)
+; (if (not (and (= a 3) (= b -2)))
+; (error "Error in inoutr-int2"))))
+;(call-with-values (lambda () (out-foo 4))
+; (lambda (a b)
+; (if (not (and (= (Foo-a-get a) 4) (= b 8)))
+; (error "Error in out-foo"))))
+
+;(let ((lst (inoutr-int2 3 -2)))
+; (if (not (and (= (car lst) 3) (= (cadr lst) -2)))
+; (error "Error in inoutr-int2")))
+
+;(let ((lst (out-foo 4)))
+; (if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8)))
+; (error "Error in out-foo")))
diff --git a/trunk/Examples/test-suite/schemerunme/li_typemaps_proxy.scm b/trunk/Examples/test-suite/schemerunme/li_typemaps_proxy.scm
new file mode 100644
index 000000000..f61d4fee5
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/li_typemaps_proxy.scm
@@ -0,0 +1,45 @@
+(define-macro (check func val test)
+ (cons 'begin
+ (map
+ (lambda (x)
+ `(if (not (,test (,(string->symbol (string-append x func)) ,val) ,val))
+ (error ,(string-append "Error in test " x func))))
+ (list "in-" "inr-" "out-" "outr-" "inout-" "inoutr-"))))
+
+(define (=~ a b)
+ (< (abs (- a b)) 1e-5))
+
+(check "bool" #t and)
+(check "int" -2 =)
+(check "long" -32 =)
+(check "short" -15 =)
+(check "uint" 75 =)
+(check "ushort" 123 =)
+(check "ulong" 462 =)
+;(check "uchar" 16 =)
+;(check "schar" -53 =)
+(check "float" 4.3 =~)
+(check "double" -175.42 =~)
+(check "longlong" 1634 =)
+(check "ulonglong" 6432 =)
+
+;; The checking of inoutr-int2 and out-foo is done in the individual
+;; language runme scripts, since chicken returns multiple values
+;; and must be checked with call-with-values, while guile just returns a list
+
+;(call-with-values (lambda () (inoutr-int2 3 -2))
+; (lambda (a b)
+; (if (not (and (= a 3) (= b -2)))
+; (error "Error in inoutr-int2"))))
+;(call-with-values (lambda () (out-foo 4))
+; (lambda (a b)
+; (if (not (and (= (slot-ref a 'a) 4) (= b 8)))
+; (error "Error in out-foo"))))
+
+;(let ((lst (inoutr-int2 3 -2)))
+; (if (not (and (= (car lst) 3) (= (cadr lst) -2)))
+; (error "Error in inoutr-int2")))
+
+;(let ((lst (out-foo 4)))
+; (if (not (and (= (slot-ref (car lst) 'a) 4) (= (cadr lst) 8)))
+; (error "Error in out-foo")))
diff --git a/trunk/Examples/test-suite/schemerunme/list_vector.scm b/trunk/Examples/test-suite/schemerunme/list_vector.scm
new file mode 100644
index 000000000..e3dfa6a30
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/list_vector.scm
@@ -0,0 +1,26 @@
+(define-macro (check-equality form1 form2)
+ `(let ((result1 ,form1)
+ (result2 ,form2))
+ (if (not (equal? result1 result2))
+ (error "Check failed:"
+ (list 'equal? ',form1 ',form2)
+ result1 result2))))
+
+(check-equality (sum-list '(1 3 4 6 7)) 21.0)
+(check-equality (sum-vector #(2 4 6 7 9)) 28.0)
+(check-equality (one-to-seven-list) '(1 2 3 4 5 6 7))
+(check-equality (one-to-seven-vector) #(1 2 3 4 5 6 7))
+
+(check-equality (sum-list2 '(1 3 4 6 7)) 21.0)
+(check-equality (sum-vector2 #(2 4 6 7 9)) 28.0)
+(check-equality (one-to-seven-list2) '(1 2 3 4 5 6 7))
+(check-equality (one-to-seven-vector2) #(1 2 3 4 5 6 7))
+
+(check-equality (sum-lists '(1 2 3) '(4 5 6) '(7 8 9)) 45.0)
+(check-equality (sum-lists2 '(1 2 3) '(4 5 6) '(7 8 9)) 45.0)
+(check-equality (call-with-values produce-lists list)
+ '(#(0 1 2 3 4)
+ #(0 1 4 9 16)
+ #(0.0 1.5 3.0 4.5 6.0)))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm b/trunk/Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm
new file mode 100644
index 000000000..ab48f8a0c
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/multiple_inheritance_proxy.scm
@@ -0,0 +1,31 @@
+(define-macro (check test)
+ `(if (not ,test) (error "Error in test" ',test)))
+
+(define b (make <Bar>))
+(check (= (bar b) 1))
+
+(define f (make <Foo>))
+(check (= (foo f) 2))
+
+(define fb (make <FooBar>))
+(check (= (bar fb) 1))
+(check (= (foo fb) 2))
+(check (= (fooBar fb) 3))
+
+(define id1 (make <IgnoreDerived1>))
+(check (= (bar id1) 1))
+(check (= (ignorederived1 id1) 7))
+
+(define id2 (make <IgnoreDerived2>))
+(check (= (bar id2) 1))
+(check (= (ignorederived2 id2) 8))
+
+(define id3 (make <IgnoreDerived3>))
+(check (= (bar id3) 1))
+(check (= (ignorederived3 id3) 9))
+
+(define id4 (make <IgnoreDerived4>))
+(check (= (bar id4) 1))
+(check (= (ignorederived4 id4) 10))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/multivalue.scm b/trunk/Examples/test-suite/schemerunme/multivalue.scm
new file mode 100644
index 000000000..780ba3892
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/multivalue.scm
@@ -0,0 +1,19 @@
+;;;; Automatic test of multiple return values
+
+(let ((quotient/remainder (divide-l 37 5)))
+ (if (not (equal? quotient/remainder '(7 2)))
+ (exit 1)))
+
+(let ((quotient-remainder-vector (divide-v 41 7)))
+ (if (not (equal? quotient-remainder-vector #(5 6)))
+ (exit 1)))
+
+(call-with-values (lambda ()
+ (divide-mv 91 13))
+ (lambda (quotient remainder)
+ (if (not (and (= quotient 7)
+ (= remainder 0)))
+ (exit 1))))
+
+(exit 0)
+
diff --git a/trunk/Examples/test-suite/schemerunme/name.scm b/trunk/Examples/test-suite/schemerunme/name.scm
new file mode 100644
index 000000000..6fbaf7cb2
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/name.scm
@@ -0,0 +1,5 @@
+(foo-2)
+bar-2
+Baz-2
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/overload_complicated.scm b/trunk/Examples/test-suite/schemerunme/overload_complicated.scm
new file mode 100644
index 000000000..4320c82ab
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/overload_complicated.scm
@@ -0,0 +1,16 @@
+(define-macro (check form)
+ `(if (not ,form)
+ (error "Check failed: " ',form)))
+
+(define (=~ a b)
+ (< (abs (- a b)) 1e-8))
+
+;; Check first method
+(check (=~ (foo 1 2 "bar" 4) 15))
+
+;; Check second method
+(check (=~ (foo 1 2) 4811.4))
+(check (=~ (foo 1 2 3.2) 4797.2))
+(check (=~ (foo 1 2 3.2 #\Q) 4798.2))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/overload_copy.scm b/trunk/Examples/test-suite/schemerunme/overload_copy.scm
new file mode 100644
index 000000000..b6e89c7dd
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/overload_copy.scm
@@ -0,0 +1,4 @@
+(define f (new-Foo))
+(define g (new-Foo f))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/overload_extend.scm b/trunk/Examples/test-suite/schemerunme/overload_extend.scm
new file mode 100644
index 000000000..0b03b285a
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/overload_extend.scm
@@ -0,0 +1,12 @@
+(define f (new-Foo))
+
+(if (not (= (Foo-test f 3) 1))
+ (error "test integer bad"))
+
+(if (not (= (Foo-test f "hello") 2))
+ (error "test string bad"))
+
+(if (not (= (Foo-test f 3.5 2.5) 6.0))
+ (error "test reals bad"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/overload_simple.scm b/trunk/Examples/test-suite/schemerunme/overload_simple.scm
new file mode 100644
index 000000000..fc60ff1e9
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/overload_simple.scm
@@ -0,0 +1,51 @@
+(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/trunk/Examples/test-suite/schemerunme/overload_subtype.scm b/trunk/Examples/test-suite/schemerunme/overload_subtype.scm
new file mode 100644
index 000000000..bcc927604
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/overload_subtype.scm
@@ -0,0 +1,7 @@
+(if (not (= (spam (new-Foo)) 1))
+ (error "foo"))
+
+(if (not (= (spam (new-Bar)) 2))
+ (error "bar"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/pointer_in_out.scm b/trunk/Examples/test-suite/schemerunme/pointer_in_out.scm
new file mode 100644
index 000000000..cabf6c195
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/pointer_in_out.scm
@@ -0,0 +1,13 @@
+(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/trunk/Examples/test-suite/schemerunme/reference_global_vars.scm b/trunk/Examples/test-suite/schemerunme/reference_global_vars.scm
new file mode 100644
index 000000000..4b3370cfc
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/reference_global_vars.scm
@@ -0,0 +1,59 @@
+(define (!= a b) (not (= a b)))
+
+; const class reference variable
+(if (!= (TestClass-num-get (getconstTC)) 33)
+ (begin (display "Runtime test 1 failed.\n") (exit 1)))
+
+; primitive reference variables
+(var-bool (createref-bool #f))
+(if (value-bool (var-bool))
+ (begin (display "Runtime test 2 failed.\n") (exit 1)))
+
+(var-char (createref-char #\w))
+(if (not (char=? (value-char (var-char)) #\w))
+ (begin (display "Runtime test 3 failed.\n") (exit 1)))
+
+(var-unsigned-char (createref-unsigned-char #\newline))
+(if (not (char=? (value-unsigned-char (var-unsigned-char)) #\newline))
+ (begin (display "Runtime test 4 failed.\n") (exit 1)))
+
+(var-signed-char (createref-signed-char #\newline))
+(if (not (char=? (value-signed-char (var-signed-char)) #\newline))
+ (begin (display "Runtime test 5 failed.\n") (exit 1)))
+
+(var-unsigned-short (createref-unsigned-short 10))
+(if (!= (value-unsigned-short (var-unsigned-short)) 10)
+ (begin (display "Runtime test 6 failed.\n") (exit 1)))
+
+(var-int (createref-int 10))
+(if (!= (value-int (var-int)) 10)
+ (begin (display "Runtime test 7 failed.\n") (exit 1)))
+
+(var-unsigned-int (createref-unsigned-int 10))
+(if (!= (value-unsigned-int (var-unsigned-int)) 10)
+ (begin (display "Runtime test 8 failed.\n") (exit 1)))
+
+(var-long (createref-long 10))
+(if (!= (value-long (var-long)) 10)
+ (begin (display "Runtime test 9 failed.\n") (exit 1)))
+
+(var-unsigned-long (createref-unsigned-long 10))
+(if (!= (value-unsigned-long (var-unsigned-long)) 10)
+ (begin (display "Runtime test 10 failed.\n") (exit 1)))
+
+;skip long long and unsigned long long
+
+(var-float (createref-float 10.5))
+(if (!= (value-float (var-float)) 10.5)
+ (begin (display "Runtime test 11 failed.\n") (exit 1)))
+
+(var-double (createref-double 10.55))
+(if (!= (value-double (var-double)) 10.55)
+ (begin (display "Runtime test 12 failed.\n") (exit 1)))
+
+;class reference
+(var-TestClass (createref-TestClass (new-TestClass 20)))
+(if (!= (TestClass-num-get (value-TestClass (var-TestClass))) 20)
+ (begin (display "Runtime test 13 failed.\n") (exit 1)))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/typedef_inherit.scm b/trunk/Examples/test-suite/schemerunme/typedef_inherit.scm
new file mode 100644
index 000000000..e1a8925cb
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/typedef_inherit.scm
@@ -0,0 +1,19 @@
+(define a (new-Foo))
+(define b (new-Bar))
+
+(if (not (string=? (do-blah a) "Foo::blah"))
+ (error "bad return"))
+
+(if (not (string=? (do-blah b) "Bar::blah"))
+ (error "bad return"))
+
+(define c (new-Spam))
+(define d (new-Grok))
+
+(if (not (string=? (do-blah2 c) "Spam::blah"))
+ (error "bad return"))
+
+(if (not (string=? (do-blah2 d) "Grok::blah"))
+ (error "bad return"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/typename.scm b/trunk/Examples/test-suite/schemerunme/typename.scm
new file mode 100644
index 000000000..1e897ddc6
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/typename.scm
@@ -0,0 +1,12 @@
+(define f (new-Foo))
+(define b (new-Bar))
+
+(define x (twoFoo f))
+;;(if (not (isinstance x (types-FloatType)))
+;; (error "wrong return type"))
+
+(define y (twoBar b))
+;;(if (not (isinstance y (types-IntType)))
+;; (error "wrong return type"))
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/unions.scm b/trunk/Examples/test-suite/schemerunme/unions.scm
new file mode 100644
index 000000000..0ab2cc7c7
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/unions.scm
@@ -0,0 +1,36 @@
+;;; This is the union runtime testcase. It ensures that values within a
+;;; union embedded within a struct can be set and read correctly.
+
+;; Create new instances of SmallStruct and BigStruct for later use
+(define small (new-SmallStruct))
+(SmallStruct-jill-set small 200)
+
+(define big (new-BigStruct))
+(BigStruct-smallstruct-set big small)
+(BigStruct-jack-set big 300)
+
+;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+;; Ensure values in EmbeddedUnionTest are set correctly for each.
+(define eut (new-EmbeddedUnionTest))
+
+;; First check the SmallStruct in EmbeddedUnionTest
+(EmbeddedUnionTest-number-set eut 1)
+(EmbeddedUnionTest-uni-small-set (EmbeddedUnionTest-uni-get eut)
+ small)
+(let ((Jill1 (SmallStruct-jill-get
+ (EmbeddedUnionTest-uni-small-get
+ (EmbeddedUnionTest-uni-get eut)))))
+ (if (not (= Jill1 200))
+ (begin
+ (display "Runtime test 1 failed.")
+ (exit 1))))
+
+(let ((Num1 (EmbeddedUnionTest-number-get eut)))
+ (if (not (= Num1 1))
+ (begin
+ (display "Runtime test 2 failed.")
+ (exit 1))))
+
+;; that should do
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/schemerunme/unions_proxy.scm b/trunk/Examples/test-suite/schemerunme/unions_proxy.scm
new file mode 100644
index 000000000..43cb83611
--- /dev/null
+++ b/trunk/Examples/test-suite/schemerunme/unions_proxy.scm
@@ -0,0 +1,37 @@
+;;; This is the union runtime testcase. It ensures that values within a
+;;; union embedded within a struct can be set and read correctly.
+
+;; Create new instances of SmallStruct and BigStruct for later use
+(define small (make <SmallStruct>))
+(slot-set! small 'jill 200)
+
+(define big (make <BigStruct>))
+(slot-set! big 'smallstruct small)
+(slot-set! big 'jack 300)
+
+;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+;; Ensure values in EmbeddedUnionTest are set correctly for each.
+(define eut (make <EmbeddedUnionTest>))
+
+;; First check the SmallStruct in EmbeddedUnionTest
+(slot-set! eut 'number 1)
+(slot-set! (slot-ref eut 'uni) 'small small)
+(let ((Jill1 (slot-ref
+ (slot-ref
+ (slot-ref eut 'uni)
+ 'small)
+ 'jill)))
+ (if (not (= Jill1 200))
+ (begin
+ (display "Runtime test 1 failed.")
+ (exit 1))))
+
+(let ((Num1 (slot-ref eut 'number)))
+ (if (not (= Num1 1))
+ (begin
+ (display "Runtime test 2 failed.")
+ (exit 1))))
+
+;; that should do
+
+(exit 0)
diff --git a/trunk/Examples/test-suite/shared_ptr_wrapper.h b/trunk/Examples/test-suite/shared_ptr_wrapper.h
new file mode 100644
index 000000000..ef7b261b2
--- /dev/null
+++ b/trunk/Examples/test-suite/shared_ptr_wrapper.h
@@ -0,0 +1,100 @@
+// defines SwigBoost::shared_ptr, a wrapper around boost::shared_ptr
+// Use this shared_ptr wrapper for testing memory leaks of shared_ptr.
+// getTotalCount() should return zero at end of test
+
+#include <iostream>
+
+struct SWIG_null_deleter; // forward reference, definition is in shared_ptr.i
+namespace SwigBoost {
+// This template can be specialized for better debugging information
+template <typename T> std::string show_message(boost::shared_ptr<T>*t) {
+ if (!t)
+ return "null shared_ptr!!!";
+ if (boost::get_deleter<SWIG_null_deleter>(*t))
+ return std::string(typeid(t).name()) + " NULL DELETER";
+ if (*t)
+ return std::string(typeid(t).name()) + " object";
+ else
+ return std::string(typeid(t).name()) + " NULL";
+}
+
+namespace SharedPtrWrapper {
+ static SwigExamples::CriticalSection critical_section;
+ static int total_count = 0;
+
+ template<typename T> void increment(boost::shared_ptr<T>* ptr) {
+ SwigExamples::Lock lock(critical_section);
+ std::cout << "====SharedPtrWrapper==== + " << ptr << " " << show_message(ptr) << " " << std::endl << std::flush;
+ total_count++;
+ }
+ template<typename T> void decrement(boost::shared_ptr<T>* ptr) {
+ SwigExamples::Lock lock(critical_section);
+ std::cout << "====SharedPtrWrapper==== - " << ptr << " " << show_message(ptr) << " " << std::endl << std::flush;
+ total_count--;
+ }
+ static int getTotalCount() { return total_count; }
+}
+
+template<typename T> class shared_ptr {
+private:
+ typedef shared_ptr<T> this_type;
+public:
+ typedef typename boost::detail::shared_ptr_traits<T>::reference reference;
+
+ shared_ptr() : m_shared_ptr() {
+ SharedPtrWrapper::increment(&m_shared_ptr);
+ }
+ template<typename Y> explicit shared_ptr(Y* p) : m_shared_ptr(p) {
+ SharedPtrWrapper::increment(&m_shared_ptr);
+ }
+ template<typename Y, typename D> explicit shared_ptr(Y* p, D d) : m_shared_ptr(p, d) {
+ SharedPtrWrapper::increment(&m_shared_ptr);
+ }
+
+ shared_ptr(shared_ptr const & other)
+ : m_shared_ptr(other.m_shared_ptr)
+ {
+ SharedPtrWrapper::increment(&m_shared_ptr);
+ }
+
+ template<typename Y> shared_ptr(shared_ptr<Y> const & other)
+ : m_shared_ptr(other.m_shared_ptr)
+ {
+ SharedPtrWrapper::increment(&m_shared_ptr);
+ }
+
+ reference operator*() const {
+ return m_shared_ptr.operator*();
+ }
+ T* operator->() const {
+ return m_shared_ptr.operator->();
+ }
+ T* get() const {
+ return m_shared_ptr.get();
+ }
+ operator bool() const {
+ return m_shared_ptr.get() == 0 ? false : true;
+ }
+ bool unique() const {
+ return m_shared_ptr.unique();
+ }
+ long use_count() const {
+ return m_shared_ptr.use_count();
+ }
+ void swap(shared_ptr<T>& other) {
+ std::swap(m_shared_ptr, other.m_shared_ptr);
+ }
+ template<class Y> bool _internal_less(shared_ptr<Y> const & rhs) const {
+ return m_shared_ptr < rhs.m_shared_ptr;
+ }
+ ~shared_ptr() {
+ SharedPtrWrapper::decrement(&m_shared_ptr);
+ }
+
+private:
+ template<class Y> friend class shared_ptr;
+
+ boost::shared_ptr<T> m_shared_ptr;
+};
+}
+
diff --git a/trunk/Examples/test-suite/simple_array.i b/trunk/Examples/test-suite/simple_array.i
new file mode 100644
index 000000000..6ddc43678
--- /dev/null
+++ b/trunk/Examples/test-suite/simple_array.i
@@ -0,0 +1,42 @@
+%module simple_array
+
+extern int x[10];
+extern double y[7];
+
+
+%inline %{
+
+struct BarArray {
+ int i;
+ double d;
+};
+
+extern struct BarArray bars[2];
+
+int x[10];
+double y[7];
+struct BarArray bars[2];
+
+void
+initArray()
+{
+ int i, n;
+
+ n = sizeof(x)/sizeof(x[0]);
+ for(i = 0; i < n; i++)
+ x[i] = i;
+
+ n = sizeof(y)/sizeof(y[0]);
+ for(i = 0; i < n; i++)
+ y[i] = ((double) i)/ ((double) n);
+
+ n = sizeof(bars)/sizeof(bars[0]);
+ for(i = 0; i < n; i++) {
+ bars[i].i = x[i+2];
+ bars[i].d = y[i+2];
+ }
+
+ return;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/simutry.i b/trunk/Examples/test-suite/simutry.i
new file mode 100644
index 000000000..addea14db
--- /dev/null
+++ b/trunk/Examples/test-suite/simutry.i
@@ -0,0 +1,98 @@
+%module simutry
+
+%include "std_vector.i"
+
+%inline {
+
+namespace simuPOP
+{
+ // some simple pop class
+ template <class Type>
+ struct Population {
+ int m_a;
+ Population(int a):m_a(a){}
+ };
+
+ // base operator, output pop.m_a
+ template<class Pop>
+ struct Operator
+ {
+ Pop m_pop;
+ Operator(int a):m_pop(a){}
+ virtual ~Operator()
+ {
+ }
+
+ virtual int func() const
+ { return m_pop.m_a; }
+ };
+
+ // derived operator, output double of pop.m_a
+ template<class Pop>
+ struct DerivedOperator: public Operator<Pop>
+ {
+ DerivedOperator(int a):Operator<Pop>(a){}
+ virtual int func() const
+ { return 2*this->m_pop.m_a; }
+ };
+
+}
+
+}
+
+#if 1
+namespace simuPOP
+{
+ %template(population) Population< std::pair<unsigned long,unsigned long> >;
+}
+
+%inline
+{
+ namespace simuPOP
+ {
+ typedef Population< std::pair<unsigned long,unsigned long> > pop;
+ }
+}
+#else
+%inline
+{
+ namespace simuPOP
+ {
+ // %template(population) Population< std::pair<unsigned long,unsigned long> >;
+
+ struct pop {
+ int m_a;
+ pop(int a):m_a(a){}
+ };
+ }
+}
+#endif
+
+
+namespace simuPOP
+{
+ %template(baseOperator) Operator< pop >;
+ %template(derivedOperator) DerivedOperator< pop >;
+}
+
+
+
+namespace std
+{
+ %template(vectorop) vector< simuPOP::Operator<simuPOP::pop> * >;
+}
+
+%inline
+{
+namespace simuPOP
+{
+ // test function, use of a vector of Operator*
+ void test( const std::vector< Operator<pop>*>& para)
+ {
+ for( size_t i =0; i < para.size(); ++i)
+ para[i]->func();
+ }
+}
+}
+
+
diff --git a/trunk/Examples/test-suite/sizeof_pointer.i b/trunk/Examples/test-suite/sizeof_pointer.i
new file mode 100644
index 000000000..993ba4de5
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/sizet.i b/trunk/Examples/test-suite/sizet.i
new file mode 100644
index 000000000..537914155
--- /dev/null
+++ b/trunk/Examples/test-suite/sizet.i
@@ -0,0 +1,52 @@
+%module sizet
+%{
+#include <vector>
+%}
+
+#ifndef SWIGCHICKEN
+%include "std_common.i"
+#endif
+
+%inline
+{
+ size_t test1(size_t s)
+ {
+ return s;
+ }
+
+ std::size_t test2(std::size_t s)
+ {
+ return s;
+ }
+
+ const std::size_t& test3(const std::size_t& s)
+ {
+ return s;
+ }
+
+ const size_t& test4(const size_t& s)
+ {
+ return s;
+ }
+
+}
+
+#ifdef SWIGPYTHON
+%include "std_vector.i"
+
+%template(vectors) std::vector<unsigned long>;
+
+%inline
+{
+ std::vector<std::size_t> testv1(std::vector<std::size_t> s)
+ {
+ return s;
+ }
+
+ const std::vector<std::size_t>& testv2(const std::vector<std::size_t>& s)
+ {
+ return s;
+ }
+
+}
+#endif
diff --git a/trunk/Examples/test-suite/smart_pointer_const.i b/trunk/Examples/test-suite/smart_pointer_const.i
new file mode 100644
index 000000000..3100a021e
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/smart_pointer_const2.i b/trunk/Examples/test-suite/smart_pointer_const2.i
new file mode 100644
index 000000000..aa0d4abe2
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_const2.i
@@ -0,0 +1,20 @@
+%module smart_pointer_const2
+
+%inline %{
+struct Foo {
+ int x;
+ int getx() const { return x; }
+ int test() { return x; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ const Foo *operator->() {
+ return f;
+ }
+};
+%}
+
+
diff --git a/trunk/Examples/test-suite/smart_pointer_extend.i b/trunk/Examples/test-suite/smart_pointer_extend.i
new file mode 100644
index 000000000..d972f6725
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_extend.i
@@ -0,0 +1,132 @@
+%module smart_pointer_extend
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::CBase::z; /* Ruby, wrong const name */
+
+%inline %{
+ namespace hi
+ {
+ struct CBase
+ {
+ static int hello()
+ {
+ return 1;
+ }
+ int x;
+ static const int z = 1;
+ };
+
+ class CDerived : public CBase
+ {
+ };
+
+ class CPtr
+ {
+ public:
+ CDerived* operator->(void) {return 0;}
+ };
+
+ int get_hello(CPtr ptr)
+ {
+ return ptr->hello();
+ }
+
+ class CPtrConst
+ {
+ public:
+ const CDerived* operator->() const {return 0;};
+ };
+
+ }
+
+%}
+
+%extend hi::CBase {
+ int foo(void) {return 1;};
+ int bar(void) {return 2;};
+ int boo(int i) {return i;};
+}
+
+%extend hi::CDerived {
+ int foo(void) {return 1;};
+}
+
+
+
+%extend Foo
+{
+ int extension(int i, int j) { return i; }
+ int extension(int i) { return i; }
+ int extension() { return 1; }
+}
+
+%inline %{
+ struct Foo {
+ };
+
+ class Bar {
+ Foo *f;
+ public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+ };
+%}
+
+
+
+%extend CFoo
+{
+public:
+ static void StatFun() {};
+ static void StatFun(int i) {};
+
+ static void HoHoHo(int i, int j) {};
+}
+
+%inline %{
+
+class CFoo
+{
+};
+
+class CPtrFoo
+{
+public:
+ CFoo* operator->(void) {return 0;};
+};
+
+%}
+
+
+
+%inline %{
+ namespace foo {
+
+ class DFoo;
+
+ class DPtrFoo
+ {
+ DFoo *p;
+ public:
+ DPtrFoo(DFoo *ptr) : p(ptr)
+ {
+ }
+
+ DFoo* operator->(void) {return p;};
+ };
+
+ class DFoo
+ {
+ public:
+ void F(void) {};
+ };
+ }
+%}
+
+
+
+%extend foo::DFoo {
+ static int SExt(int i = 1) {return i;};
+ int Ext(int i = 2) {return i;};
+}
diff --git a/trunk/Examples/test-suite/smart_pointer_inherit.i b/trunk/Examples/test-suite/smart_pointer_inherit.i
new file mode 100644
index 000000000..a81d72268
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_inherit.i
@@ -0,0 +1,76 @@
+%module smart_pointer_inherit
+
+#ifdef SWIGCSHARP
+// Test that the override is removed in the smart pointer for custom method modifiers
+%csmethodmodifiers hi::Derived::value3 "/*csmethodmodifiers*/ public override";
+#endif
+
+%inline %{
+
+ namespace hi
+ {
+ struct Base
+ {
+ Base(int i) : val(i) {}
+ virtual ~Base() { }
+ virtual int value() = 0;
+ virtual int value2() { return val; }
+ virtual int value3() { return val; }
+ int valuehide() { return val; }
+ int val;
+ };
+
+ struct Derived : Base
+ {
+ Derived(int i) : Base(i) {}
+ virtual int value() { return val; }
+ virtual int value3() { return Base::value3(); }
+ int valuehide() { return -1; }
+ };
+
+ template <typename T> struct SmartPtr
+ {
+ SmartPtr(T *t) : ptr(t) {}
+ T * operator->() const { return ptr; }
+ private:
+ T *ptr;
+ };
+ }
+%}
+
+%template(SmartBase) hi::SmartPtr<hi::Base>;
+%template(SmartDerived) hi::SmartPtr<hi::Derived>;
+
+
+
+%include std_vector.i
+
+%inline %{
+class ItkLevelSetNodeUS2 {
+};
+%}
+
+#ifdef SWIGCSHARP
+// Get rid of C# compiler warnings.
+// Really the itkVectorContainerUILSNUS2_Pointer class should be manually modified to contain the same %extend methods that are in std_vector.i
+%csmethodmodifiers std::vector<ItkLevelSetNodeUS2>::getitemcopy "protected"
+%csmethodmodifiers std::vector<ItkLevelSetNodeUS2>::getitem "protected"
+%csmethodmodifiers std::vector<ItkLevelSetNodeUS2>::setitem "protected"
+%csmethodmodifiers std::vector<ItkLevelSetNodeUS2>::size "protected"
+%csmethodmodifiers std::vector<ItkLevelSetNodeUS2>::capacity "protected"
+%csmethodmodifiers std::vector<ItkLevelSetNodeUS2>::reserve "protected"
+#endif
+
+%template(VectorLevelSetNodeUS2) std::vector< ItkLevelSetNodeUS2 >;
+
+%inline %{
+class ItkVectorContainerUILSNUS2 : public std::vector< ItkLevelSetNodeUS2 > {
+};
+
+class ItkVectorContainerUILSNUS2_Pointer {
+ public:
+ ItkVectorContainerUILSNUS2 * operator->() const { return 0; }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/smart_pointer_member.i b/trunk/Examples/test-suite/smart_pointer_member.i
new file mode 100644
index 000000000..7a776261a
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_member.i
@@ -0,0 +1,56 @@
+%module smart_pointer_member
+
+
+
+%inline %{
+
+ class Foo {
+ public:
+ int x[4];
+ int y;
+ static const int z;
+ static const int ZZ = 3;
+ static int zx;
+
+ static int boo() { return 0;}
+
+ friend int foo(Foo* foo) { return 0;}
+ };
+
+ class Bar {
+ Foo *f;
+ public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+
+ static int bua() { return 0;}
+ };
+
+ class CBar {
+ Foo *f;
+ public:
+ CBar(Foo *f) : f(f) { }
+ const Foo *operator->() {
+ return f;
+ }
+ };
+
+
+ int get_y(Bar *b)
+ {
+ return (*b)->y;
+ }
+
+ int get_z(Bar *b)
+ {
+ return (*b)->z;
+ }
+%}
+
+
+%{
+ const int Foo::z = 3;
+ int Foo::zx;
+%}
diff --git a/trunk/Examples/test-suite/smart_pointer_multi.i b/trunk/Examples/test-suite/smart_pointer_multi.i
new file mode 100644
index 000000000..4b0aa0e4b
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/smart_pointer_multi_typedef.i b/trunk/Examples/test-suite/smart_pointer_multi_typedef.i
new file mode 100644
index 000000000..ed32b703a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/smart_pointer_namespace.i b/trunk/Examples/test-suite/smart_pointer_namespace.i
new file mode 100644
index 000000000..651da5ced
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_namespace.i
@@ -0,0 +1,78 @@
+
+%module smart_pointer_namespace
+%{
+namespace one
+{
+ template <typename T>
+ class Ptr
+ {
+ T* p;
+ public:
+ Ptr(T *tp) : p(tp) {}
+ ~Ptr() { };
+ T* operator->() { return p; }
+ };
+}
+namespace one
+{
+ class Obj1
+ {
+ public:
+ Obj1() {}
+ void donothing() {}
+ };
+ typedef one::Ptr<Obj1> Obj1_ptr;
+}
+
+namespace two
+{
+ class Obj2
+ {
+ public:
+ Obj2() {}
+ void donothing() {}
+ };
+ typedef one::Ptr<Obj2> Obj2_ptr;
+}
+%}
+
+namespace one
+{
+ template <typename T>
+ class Ptr
+ {
+ T* p;
+ public:
+ Ptr(T *tp) : p(tp) {}
+ ~Ptr() { };
+ T* operator->() { return p; }
+ };
+}
+
+namespace one
+{
+ class Obj1
+ {
+ public:
+ Obj1() {}
+ void donothing() {}
+ };
+
+ typedef one::Ptr<Obj1> Obj1;
+}
+
+%template(Obj1_ptr) one::Ptr<one::Obj1>;
+
+namespace two
+{
+ class Obj2
+ {
+ public:
+ Obj2() {}
+ void donothing() {}
+ };
+ typedef one::Ptr<Obj2> Obj2;
+}
+
+%template(Obj2_ptr) one::Ptr<two::Obj2>;
+
diff --git a/trunk/Examples/test-suite/smart_pointer_namespace2.i b/trunk/Examples/test-suite/smart_pointer_namespace2.i
new file mode 100644
index 000000000..882799862
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_namespace2.i
@@ -0,0 +1,80 @@
+
+%module smart_pointer_namespace2
+%{
+namespace one
+{
+ template <typename T>
+ class Ptr
+ {
+ T* p;
+ public:
+ Ptr(T *tp) : p(tp) {}
+ ~Ptr() { };
+ T* operator->() { return p; }
+ };
+}
+namespace one
+{
+ class Obj1
+ {
+ public:
+ Obj1() {}
+ void donothing() {}
+ };
+ typedef one::Ptr<Obj1> Obj1_ptr;
+}
+
+namespace two
+{
+ class Obj2
+ {
+ public:
+ Obj2() {}
+ void donothing() {}
+ };
+ typedef one::Ptr<Obj2> Obj2_ptr;
+}
+%}
+
+namespace one
+{
+ template <typename T>
+ class Ptr
+ {
+ T* p;
+ public:
+ Ptr(T *tp) : p(tp) {}
+ ~Ptr() { };
+ T* operator->() { return p; }
+ };
+}
+
+%define PTR_DEF(o)
+typedef one::Ptr<o> o ## _ptr;
+%template(o ## _ptr) one::Ptr<o>;
+%enddef
+
+namespace one
+{
+ class Obj1
+ {
+ public:
+ Obj1() {}
+ void donothing() {}
+ };
+
+ PTR_DEF(Obj1)
+}
+
+namespace two
+{
+ class Obj2
+ {
+ public:
+ Obj2() {}
+ void donothing() {}
+ };
+
+ PTR_DEF(Obj2)
+}
+
diff --git a/trunk/Examples/test-suite/smart_pointer_not.i b/trunk/Examples/test-suite/smart_pointer_not.i
new file mode 100644
index 000000000..712aa48fb
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/smart_pointer_overload.i b/trunk/Examples/test-suite/smart_pointer_overload.i
new file mode 100644
index 000000000..0d2cc595d
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_overload.i
@@ -0,0 +1,28 @@
+%module smart_pointer_overload
+
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
+#endif
+
+#ifndef SWIG_NO_OVERLOAD
+
+%inline %{
+struct Foo {
+ int x;
+ int test(int y) { y = 0; return 1; }
+ int test(double y) { y = 0; return 2; }
+ int test(char *s) { s = 0; return 3; }
+};
+
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ Foo *operator->() {
+ return f;
+ }
+};
+%}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/smart_pointer_protected.i b/trunk/Examples/test-suite/smart_pointer_protected.i
new file mode 100644
index 000000000..c9b2a768d
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_protected.i
@@ -0,0 +1,33 @@
+%module smart_pointer_protected
+
+%inline %{
+
+ namespace hi
+ {
+ struct A
+ {
+ virtual ~A() { }
+ virtual int value(A*) = 0;
+ int index;
+ };
+
+ struct B : A
+ {
+ protected:
+ int value(A*)
+ {
+ return 1;
+ }
+ };
+
+ struct C
+ {
+ hi::B* operator->() const { return new hi::B(); }
+ private:
+ int index;
+ };
+ }
+
+
+%}
+
diff --git a/trunk/Examples/test-suite/smart_pointer_rename.i b/trunk/Examples/test-suite/smart_pointer_rename.i
new file mode 100644
index 000000000..b137ffe71
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/smart_pointer_simple.i b/trunk/Examples/test-suite/smart_pointer_simple.i
new file mode 100644
index 000000000..ceb499c41
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/smart_pointer_static.i b/trunk/Examples/test-suite/smart_pointer_static.i
new file mode 100644
index 000000000..a9574f737
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_static.i
@@ -0,0 +1,24 @@
+%module smart_pointer_static
+%inline %{
+class Foo2;
+
+class MyHandle_Foo2 {
+ public:
+ Foo2 * operator -> ();
+};
+
+class Foo2 {
+ public:
+ virtual ~Foo2() {}
+ virtual int sum(int i, int j) { return i+j; }
+ static int sum(int i, int j, int k);
+};
+
+%}
+
+%{
+int Foo2::sum(int i, int j, int k) {
+ return i+j+k;
+}
+Foo2 * MyHandle_Foo2::operator -> () { return new Foo2(); }
+%}
diff --git a/trunk/Examples/test-suite/smart_pointer_templatemethods.i b/trunk/Examples/test-suite/smart_pointer_templatemethods.i
new file mode 100644
index 000000000..7baa6386a
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_templatemethods.i
@@ -0,0 +1,52 @@
+
+%module smart_pointer_templatemethods
+
+%inline %{
+namespace ns {
+
+template <typename T>
+class Ptr
+{
+public:
+ Ptr () {}
+ T *operator -> () { return 0; }
+};
+
+typedef unsigned short uint16_t;
+class InterfaceId
+{
+public:
+ InterfaceId (uint16_t iid) {}
+ InterfaceId() {}
+};
+
+template <typename K> class Objekt
+{
+public:
+ Objekt () {}
+ virtual ~Objekt () {}
+ Ptr<K> QueryInterface (InterfaceId iid) const { return Ptr<K>(); }
+ void DisposeObjekt (void) {}
+};
+
+class Object
+{
+public:
+ Object () {}
+ virtual ~Object () {}
+ template <typename T> Ptr<T> QueryInterface (InterfaceId iid) const { return Ptr<T>(); }
+ void DisposeObject (void) {}
+};
+
+#ifdef SWIG
+%template(PtrObject) Ptr<Object>;
+%template(PtrInt) Ptr<int>;
+%template(ObjektInt) Objekt<int>;
+%template(PtrObjektInt) Ptr<Objekt<int> >;
+%template(QueryInterfaceObject) Object::QueryInterface<Object>;
+#endif
+
+}; // namespace
+
+%}
+
diff --git a/trunk/Examples/test-suite/smart_pointer_templatevariables.i b/trunk/Examples/test-suite/smart_pointer_templatevariables.i
new file mode 100644
index 000000000..fd705eb28
--- /dev/null
+++ b/trunk/Examples/test-suite/smart_pointer_templatevariables.i
@@ -0,0 +1,39 @@
+%module smart_pointer_templatevariables
+
+%inline %{
+template <class _CharT>
+struct basic_string {
+ int npos;
+};
+
+template<class T>
+struct Ptr {
+ Ptr(T *p = 0) : ptr(p) {}
+ ~Ptr() { delete ptr; }
+ T *operator->() const { return ptr; }
+private:
+ T *ptr;
+};
+
+template <typename KernelPixelT>
+struct DiffImContainer {
+ int id;
+// static members seem to be can of worms. Note that SWIG wraps them as non-static members. Why?
+// Note CHANGES entry 10/14/2003. Static const variables are not wrapped as constants but as a read only variable. Why?
+// static short xyz;
+// static const short constvar = 555;
+};
+//template<typename KernelPixelT> short DiffImContainer<KernelPixelT>::xyz = 0;
+
+DiffImContainer<double>* create(int id, short xyz) {
+ DiffImContainer<double> *d = new DiffImContainer<double>();
+ d->id = id;
+// DiffImContainer<double>::xyz = xyz;
+ return d;
+}
+%}
+
+%template(BasicString) basic_string<char>;
+%template(DiffImContainer_D) DiffImContainer<double>;
+%template(DiffImContainerPtr_D) Ptr<DiffImContainer<double> >;
+
diff --git a/trunk/Examples/test-suite/smart_pointer_typedef.i b/trunk/Examples/test-suite/smart_pointer_typedef.i
new file mode 100644
index 000000000..d4e874f5c
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/sneaky1.i b/trunk/Examples/test-suite/sneaky1.i
new file mode 100644
index 000000000..2d915e102
--- /dev/null
+++ b/trunk/Examples/test-suite/sneaky1.i
@@ -0,0 +1,29 @@
+%module sneaky1
+
+%{
+int add(int x, int y) {
+ return x+y;
+}
+
+int subtract(int x, int y) {
+ return x-y;
+}
+int mul(int x, int y) {
+ return x*y;
+}
+
+int divide(int x, int y) {
+ return x/y;
+}
+%}
+
+%inline %{
+typedef int binop(int,int);
+%}
+
+binop add,subtract,mul,divide;
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/special_variable_macros.i b/trunk/Examples/test-suite/special_variable_macros.i
new file mode 100644
index 000000000..f27bbd619
--- /dev/null
+++ b/trunk/Examples/test-suite/special_variable_macros.i
@@ -0,0 +1,179 @@
+%module special_variable_macros
+
+// test $typemap() special variable function
+// these tests are not typical of how $typemap() should be used, but it checks that it is mostly working
+
+%inline %{
+struct Name {
+ Name(const char *n="none") : name(n) {}
+ const char *getName() const { return name; };
+ Name *getNamePtr() { return this; };
+private:
+ const char *name;
+};
+struct NameWrap {
+ NameWrap(const char *n="casternone") : name(n) {}
+ Name *getNamePtr() { return &name; };
+private:
+ Name name;
+};
+%}
+
+// check $1 and $input get expanded properly when used from $typemap()
+%typemap(in) Name *GENERIC ($*1_type temp)
+%{
+ /*%typemap(in) Name *GENERIC start */
+ temp = Name("$specialname");
+ (void)$input;
+ $1 = ($1_ltype) &temp;
+ /*%typemap(in) Name *GENERIC end */
+%}
+
+// This would never be done in real code, it is just a test of what madness can be done.
+// Note that the special variable substitutions $*1_type, $descriptor etc are for NameWrap
+// even when used within the Name typemap via $typemap. I can't think of any useful use cases
+// for this behaviour in the C/C++ typemaps, but it is possible.
+%typemap(in) NameWrap *NAMEWRAP ($*1_type temp)
+%{
+ /*%typemap(in) NameWrap *NAMEWRAP start */
+ temp = $*1_ltype("$descriptor");
+ (void)$input;
+ $1 = temp.getNamePtr();
+ /*%typemap(in) NameWrap *NAMEWRAP end */
+%}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+// This should use Name *GENERIC typemap which ignores passed in Name * and instead uses a newly a newly constructed Name
+// held in a typemap variable with name="$specialname"
+%typemap(in) Name *jack {
+// %typemap(in) Name *jack start
+$typemap(in, Name *GENERIC)
+// %typemap(in) Name *jack end
+}
+
+// as above, but also perform variable substitution
+%typemap(in) Name *jill {
+// %typemap(in) Name *jill start
+$typemap(in, Name *GENERIC, specialname=jilly)
+// %typemap(in) Name *jill end
+}
+
+%typemap(in) Name *mary {
+// %typemap(in) Name *mary start
+$typemap(in, NameWrap *NAMEWRAP)
+// %typemap(in) Name *mary end
+}
+
+%inline %{
+const char * testFred(Name *fred) {
+ return fred->getName();
+}
+const char * testJack(Name *jack) {
+ return jack->getName();
+}
+const char * testJill(Name *jill) {
+ return jill->getName();
+}
+const char * testMary(Name *mary) {
+ return mary->getName();
+}
+%}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Multi-arg typemap lookup
+// One would never do something like this in reality, it just checks $typemap with multi-arg typemaps
+%typemap(in) (Name *multiname, int num)($*1_type temp_name, $2_ltype temp_count)
+%{
+ /*%typemap(in) (Name *multiname, int num) start */
+ temp_name = $*1_ltype("multiname num");
+ temp_count = (int)strlen(temp_name.getNamePtr()->getName());
+ (void)$input;
+ $1 = temp_name.getNamePtr();
+ $2 = temp_count + 100;
+ /*%typemap(in) (Name *multiname, int num) end */
+%}
+
+%typemap(in) (Name *jim, int count) {
+// %typemap(in) Name *jim start
+$typemap(in, (Name *multiname, int num))
+// %typemap(in) Name *jim end
+}
+
+%inline %{
+const char * testJim(Name *jim, int count) {
+ if (count != (int)strlen(jim->getNamePtr()->getName()) + 100)
+ return "size check failed";
+ else
+ return jim->getName();
+}
+%}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Template types with more than one template parameter
+
+// check $1 and $input get expanded properly when used from $typemap()
+%typemap(in) Space::Pair<int, bool> PAIR_INT_BOOL ($1_type temp)
+%{
+ /*%typemap(in) Name *GENERIC start */
+ temp = Space::Pair<int, bool>(123, true);
+ (void)$input;
+ $1 = ($1_ltype)temp;
+ /*%typemap(in) Name *GENERIC end */
+%}
+
+%typemap(in) Space::Pair<int, bool> john {
+// %typemap(in) Name *john start
+$typemap(in, Space::Pair<int, bool> PAIR_INT_BOOL)
+// %typemap(in) Name *john end
+}
+
+%inline %{
+namespace Space {
+ template <typename T1, typename T2> struct Pair {
+ Pair(T1 f, T2 s) : first(f), second(s) {}
+ Pair() {}
+ T1 first;
+ T2 second;
+ };
+ int testJohn(Space::Pair<int, bool> john) {
+ return john.first;
+ }
+}
+%}
+%template(PairIntBool) Space::Pair<int, bool>;
+
+//////////////////////////////////////////////////////////////////////////////////////
+// A real use case for $typemap
+
+#if defined(SWIGCSHARP)
+%typemap(cscode) Space::RenameMe %{
+ public static NewName factory(String s) {
+ //below should expand to:
+ //return new NewName( new Name(s) );
+ return new $typemap(cstype, Space::RenameMe)( new $typemap(cstype, Name)(s) );
+ }
+%}
+#elif defined(SWIGJAVA)
+%typemap(javacode) Space::RenameMe %{
+ public static NewName factory(String s) {
+ //below should expand to:
+ //return new NewName( new Name(s) );
+ return new $typemap(jstype, Space::RenameMe)( new $typemap(jstype, Name)(s) );
+ }
+%}
+#endif
+
+%rename(NewName) Space::RenameMe;
+%inline %{
+namespace Space {
+ struct RenameMe {
+ RenameMe(Name n) : storedName(n) {}
+ Name getStoredName() { return storedName; }
+ private:
+ Name storedName;
+ };
+}
+%}
+
diff --git a/trunk/Examples/test-suite/special_variables.i b/trunk/Examples/test-suite/special_variables.i
new file mode 100644
index 000000000..e8853cec2
--- /dev/null
+++ b/trunk/Examples/test-suite/special_variables.i
@@ -0,0 +1,90 @@
+%module special_variables
+
+%include <std_string.i>
+
+// will fail to compile if $symname is not expanded
+%typemap(argout) int i {
+ $symname(99);
+}
+
+%{
+#define KKK_testmethod testmethod
+#define KKK_teststaticmethod KKK::teststaticmethod
+%}
+
+%inline %{
+void testmethod(int i) {}
+struct KKK {
+ void testmethod(int i) {}
+ static void teststaticmethod(int i) {}
+};
+%}
+
+%{
+std::string ExceptionVars(double i, double j) {
+ return "a1";
+}
+%}
+
+%rename(ExceptionVars) Space::exceptionvars;
+%exception Space::exceptionvars %{
+ $action
+ result = $symname(1.0,2.0); // Should expand to ExceptionVars
+ result = $name(3.0,4.0); // Should expand to Space::exceptionvars
+ // above will not compile if the variables are not expanded properly
+ result = "$action $name $symname $overname $wrapname";
+%}
+%inline %{
+namespace Space {
+std::string exceptionvars(double i, double j) {
+ return "b2";
+}
+}
+%}
+
+
+%exception Space::overloadedmethod %{
+ $action
+ result = Space::$symname(1.0);
+ result = $name();
+ result = $name(2.0);
+ // above will not compile if the variables are not expanded properly
+ result = "$action $name $symname $overname $wrapname";
+ // $decl
+%}
+
+%inline %{
+namespace Space {
+ std::string overloadedmethod(double j) {
+ return "c3";
+ }
+ std::string overloadedmethod() {
+ return "d4";
+ }
+}
+std::string declaration;
+%}
+
+%exception {
+ $action
+ declaration = "$fulldecl $decl";
+}
+
+%inline %{
+namespace SpaceNamespace {
+ struct ABC {
+ ABC(int a, double b) {}
+ ABC() {}
+ static short * staticmethod(int x, bool b) { return 0; }
+ short * instancemethod(int x, bool b = false) { return 0; }
+ short * constmethod(int x) const { return 0; }
+ };
+ template<typename T> struct Template {
+ std::string tmethod(T t) { return ""; }
+ };
+ void globtemplate(Template<ABC> t) {}
+}
+%}
+
+%template(TemplateABC) SpaceNamespace::Template<SpaceNamespace::ABC>;
+
diff --git a/trunk/Examples/test-suite/static_array_member.i b/trunk/Examples/test-suite/static_array_member.i
new file mode 100644
index 000000000..3bd8cf9f8
--- /dev/null
+++ b/trunk/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
+
+%inline %{
+class RB {
+ static char *rberror[];
+};
+%}
diff --git a/trunk/Examples/test-suite/static_const_member.i b/trunk/Examples/test-suite/static_const_member.i
new file mode 100644
index 000000000..3db60b4c2
--- /dev/null
+++ b/trunk/Examples/test-suite/static_const_member.i
@@ -0,0 +1,26 @@
+/* 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
+
+#if SWIGJAVA
+%javaconst(1) EN;
+%javaconst(1) CHARTEST;
+#elif SWIGCSHARP
+%csconst(1) EN;
+%csconst(1) CHARTEST;
+#endif
+
+%inline %{
+
+class X {
+public:
+ static const int PN = 0;
+ static const int CN = 1;
+ static const int EN = 2;
+ static const char CHARTEST = 'A';
+};
+
+%}
diff --git a/trunk/Examples/test-suite/static_const_member_2.i b/trunk/Examples/test-suite/static_const_member_2.i
new file mode 100644
index 000000000..0b6d38d21
--- /dev/null
+++ b/trunk/Examples/test-suite/static_const_member_2.i
@@ -0,0 +1,76 @@
+%module static_const_member_2
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::CavityPackFlags::forward_field;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::CavityPackFlags::backward_field;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::Test::current_profile;
+
+%inline %{
+ namespace oss
+ {
+ namespace modules
+ {
+ struct CavityPackFlags
+ {
+ typedef unsigned int viewflags;
+ static const viewflags forward_field = 1 << 0;
+ static const viewflags backward_field = 1 << 1;
+ static const viewflags cavity_flags;
+ static viewflags flags;
+ static const int &reftest;
+ };
+
+ template <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>;
+
+
+
+
+%inline %{
+
+class Foo
+{
+public:
+ int val;
+
+ Foo(int v) : val(v)
+ {
+ }
+
+ static const Foo BAR;
+ static const Foo BAZ;
+};
+
+%}
+%{
+ const Foo Foo::BAR = Foo(1);
+ const Foo Foo::BAZ = Foo(2);
+%}
diff --git a/trunk/Examples/test-suite/std_containers.i b/trunk/Examples/test-suite/std_containers.i
new file mode 100644
index 000000000..0955226ad
--- /dev/null
+++ b/trunk/Examples/test-suite/std_containers.i
@@ -0,0 +1,207 @@
+%module std_containers
+
+//
+// STL containers test suite.
+// Tests:
+// std::complex, std::string, std::vector, std::set, std::deque,
+// std::pair, std::map, std::multiset, std::multimap and IN/OUT functions
+// for them, with C++ types.
+//
+
+%{
+#include <set>
+%}
+%include std_vector.i
+%include std_string.i
+%include std_deque.i
+%include std_list.i
+%include std_set.i
+%include std_multiset.i
+%include std_pair.i
+%include std_map.i
+%include std_multimap.i
+%include std_complex.i
+
+%template() std::vector<double>;
+%template() std::pair<std::string, int>;
+%template() std::pair<int,double>;
+
+%template() std::vector< std::vector<double > > ;
+%template(ccube) std::vector< std::vector< std::vector<double > > >;
+
+%inline
+{
+ typedef
+ std::vector<std::vector<std::vector<double > > >
+ ccube;
+
+ ccube cident(const ccube& c)
+ {
+ return c;
+ }
+
+ struct C
+ {
+ };
+}
+
+
+%template(map_si) std::map<std::string, int>;
+%template(pair_iC) std::pair<int, C*>;
+%template(map_iC) std::map<int, C*>;
+%template(mmap_si) std::multimap<std::string, int>;
+%template(set_i) std::set<int>;
+%template(multiset_i) std::multiset<int>;
+%template(list_i) std::list<int>;
+%template(deque_i) std::deque<int>;
+
+%template(vector_b) std::vector<bool>;
+%template(vector_i) std::vector<int>;
+%template(vector_c) std::vector<std::complex<double> >;
+%template(vector_ui) std::vector<unsigned int>;
+
+%template(bmatrix) std::vector<std::vector<bool> >;
+%template(imatrix) std::vector<std::vector<int> >;
+%template(cmatrix) std::vector<std::vector<std::complex<double> > >;
+
+%apply std::vector<int> *INOUT {std::vector<int> *INOUT2};
+
+%inline
+{
+ typedef std::vector<std::vector<int> > imatrix;
+ imatrix midenti(const imatrix& v)
+ {
+ return v;
+ }
+
+ typedef std::vector<std::vector<bool> > bmatrix;
+ bmatrix midentb(const bmatrix& v)
+ {
+ return v;
+ }
+
+ std::map<int,C*> mapidentc(const std::map<int,C*>& v)
+ {
+ return v;
+ }
+
+ std::map<int,int> mapidenti(const std::map<int,int>& v)
+ {
+ return v;
+ }
+
+ std::map<std::string,int> mapident(const std::map<std::string,int>& v)
+ {
+ return v;
+ }
+
+ std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v)
+ {
+ return v;
+ }
+
+ std::vector<int> vident(const std::vector<int>& v)
+ {
+ return v;
+ }
+
+ std::set<int> sident(const std::set<int>& v)
+ {
+ return v;
+ }
+
+ std::vector<unsigned int> videntu(const std::vector<unsigned int>& v)
+ {
+ return v;
+ }
+
+
+ int get_elem(const std::vector<int>& v, int index)
+ {
+ return v[index];
+ }
+
+ std::pair<int,double> pident(const std::pair<int,double>& p)
+ {
+ return p;
+ }
+
+ void
+ v_inout(std::vector<int> *INOUT) {
+ *INOUT = *INOUT;
+ }
+
+ void
+ v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) {
+ std::swap(*INOUT, *INOUT2);
+ }
+
+}
+
+
+%{
+
+ template <class C> struct Param
+ {
+ };
+%}
+
+
+template <class C> struct Param
+{
+};
+
+
+%template(Param_c) Param<std::complex<double> >;
+%inline
+{
+ int hello(Param<std::complex<double> > c)
+ {
+ return 0;
+ }
+}
+
+%inline
+{
+ struct A
+ {
+ A(int aa = 0) : a(aa)
+ {
+ }
+ int a;
+ };
+}
+
+%template() std::pair<A,int>;
+%template(pair_iA) std::pair<int,A>;
+%template(vector_piA) std::vector<std::pair<int,A> >;
+
+
+%inline {
+ std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b)
+ {
+ return std::pair<A,int>();
+ }
+
+
+ std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a )
+ {
+ return a;
+ }
+
+ struct Foo
+ {
+ Foo(int i) {
+ }
+ };
+
+}
+
+
+%std_nodefconst_type(Foo);
+
+%template(vector_Foo) std::vector<Foo>;
+%template(deque_Foo) std::deque<Foo>;
+%template(list_Foo) std::list<Foo>;
+
+
diff --git a/trunk/Examples/test-suite/stl_new.i b/trunk/Examples/test-suite/stl_new.i
new file mode 100644
index 000000000..690a1672b
--- /dev/null
+++ b/trunk/Examples/test-suite/stl_new.i
@@ -0,0 +1,29 @@
+%module stl_new
+
+%include <std_vector.i>
+%include <std_deque.i>
+%include <std_list.i>
+%include <std_set.i>
+%include <std_map.i>
+
+%template(Vector ) std::vector <swig::LANGUAGE_OBJ>;
+%template(Deque ) std::deque <swig::LANGUAGE_OBJ>;
+%template(List ) std::list <swig::LANGUAGE_OBJ>;
+
+%template(Set ) std::set <swig::LANGUAGE_OBJ,
+ swig::BinaryPredicate<> >;
+%template(Map ) std::map <swig::LANGUAGE_OBJ,swig::LANGUAGE_OBJ,
+ swig::BinaryPredicate<> >;
+
+
+// %inline %{
+// namespace swig {
+// void nth_element(swig::Iterator_T< _Iter>& first,
+// swig::Iterator_T< _Iter>& nth,
+// swig::Iterator_T< _Iter>& last,
+// const swig::BinaryPredicate<>& comp = swig::BinaryPredicate<>())
+// {
+// std::nth_element( first, nth, last, comp);
+// }
+// }
+// %}
diff --git a/trunk/Examples/test-suite/struct_initialization.i b/trunk/Examples/test-suite/struct_initialization.i
new file mode 100644
index 000000000..c378ba31d
--- /dev/null
+++ b/trunk/Examples/test-suite/struct_initialization.i
@@ -0,0 +1,31 @@
+// Test declaration and initialization of structs (C code)
+%module struct_initialization
+
+%inline %{
+
+// Named types
+struct StructA {
+ int x;
+} instanceA1;
+
+struct StructB {
+ int x;
+} instanceB1, instanceB2, instanceB3;
+
+struct StructC {
+ int x;
+} instanceC1 = { 10 };
+
+struct StructD {
+ int x;
+} instanceD1 = { 10 }, instanceD2 = { 20 }, instanceD3 = { 30 };
+
+struct StructE {
+ int x;
+} instanceE1[3] = { { 1 }, { 2 }, { 3} };
+
+struct StructF {
+ int x;
+} instanceF1[3] = { { 1 }, { 2 } }, instanceF2[2] = { { -1 }, { -2 } }, instanceF3[2] = { { 11 }, { 22 } };
+
+%}
diff --git a/trunk/Examples/test-suite/struct_initialization_cpp.i b/trunk/Examples/test-suite/struct_initialization_cpp.i
new file mode 100644
index 000000000..dc47077b5
--- /dev/null
+++ b/trunk/Examples/test-suite/struct_initialization_cpp.i
@@ -0,0 +1,5 @@
+// Test declaration and initialization of structs (C++ code)
+%module struct_initialization_cpp
+
+%include "struct_initialization.i" // C code
+
diff --git a/trunk/Examples/test-suite/struct_rename.i b/trunk/Examples/test-suite/struct_rename.i
new file mode 100644
index 000000000..7acd7060a
--- /dev/null
+++ b/trunk/Examples/test-suite/struct_rename.i
@@ -0,0 +1,11 @@
+%module struct_rename
+
+%rename(Bar) Foo;
+
+%inline %{
+typedef struct {
+ int x;
+} Foo;
+
+%}
+
diff --git a/trunk/Examples/test-suite/struct_value.i b/trunk/Examples/test-suite/struct_value.i
new file mode 100644
index 000000000..bf944e2c5
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/swig_examples_lock.h b/trunk/Examples/test-suite/swig_examples_lock.h
new file mode 100644
index 000000000..feef26d0f
--- /dev/null
+++ b/trunk/Examples/test-suite/swig_examples_lock.h
@@ -0,0 +1,70 @@
+
+# if defined(_WIN32) || defined(__WIN32__)
+
+#include <windows.h>
+
+namespace SwigExamples {
+
+class CriticalSection {
+public:
+ CriticalSection() {
+ InitializeCriticalSection(&mutex_);
+ }
+ ~CriticalSection() {
+ DeleteCriticalSection(&mutex_);
+ }
+ CRITICAL_SECTION mutex_;
+};
+
+struct Lock {
+ Lock(CriticalSection &cs) : critical_section(cs) {
+ EnterCriticalSection(&critical_section.mutex_);
+ }
+ ~Lock() {
+ LeaveCriticalSection(&critical_section.mutex_);
+ }
+private:
+ CriticalSection &critical_section;
+};
+
+}
+
+#else
+
+#include <pthread.h>
+#ifndef PTHREAD_MUTEX_RECURSIVE_NP
+ // For Cygwin and possibly other OSs: _NP is "non-portable"
+ #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
+#endif
+
+namespace SwigExamples {
+
+class CriticalSection {
+public:
+ CriticalSection() {
+ pthread_mutexattr_t mutexattr;
+ pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP);
+ pthread_mutex_init(&mutex_, &mutexattr);
+ pthread_mutexattr_destroy(&mutexattr);
+ }
+ ~CriticalSection() {
+ pthread_mutex_destroy (&mutex_);
+ }
+ pthread_mutex_t mutex_;
+};
+
+struct Lock {
+ Lock(CriticalSection &cs) : critical_section(cs) {
+ pthread_mutex_lock (&critical_section.mutex_);
+ }
+ ~Lock() {
+ pthread_mutex_unlock (&critical_section.mutex_);
+ }
+private:
+ CriticalSection &critical_section;
+};
+
+}
+
+#endif
+
diff --git a/trunk/Examples/test-suite/swigobject.i b/trunk/Examples/test-suite/swigobject.i
new file mode 100644
index 000000000..2ec064509
--- /dev/null
+++ b/trunk/Examples/test-suite/swigobject.i
@@ -0,0 +1,25 @@
+%module swigobject
+
+
+
+%inline
+{
+ struct A {
+ char name[4];
+ };
+
+ const char* pointer_str(A *a){
+ static char result[1024];
+ sprintf(result,"%p", a);
+ return result;
+ }
+
+ A *a_ptr(A *a){
+ return a;
+ }
+
+
+ void *v_ptr(void *a){
+ return a;
+ }
+}
diff --git a/trunk/Examples/test-suite/sym.i b/trunk/Examples/test-suite/sym.i
new file mode 100644
index 000000000..83226cbaa
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/symbol_clash.i b/trunk/Examples/test-suite/symbol_clash.i
new file mode 100644
index 000000000..f0aef1398
--- /dev/null
+++ b/trunk/Examples/test-suite/symbol_clash.i
@@ -0,0 +1,28 @@
+%module symbol_clash
+
+// ::Vector and ::Text::Vector were incorrectly clashing in the target language symbol tables
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+
+#if defined(SWIGJAVA)
+%include "enumtypeunsafe.swg"
+#elif defined(SWIGCSHARP)
+%include "enumsimple.swg"
+#endif
+
+%inline %{
+class Vector
+{
+};
+
+namespace Text
+{
+ enum Preference
+ {
+ Raster,
+ Vector
+ };
+}
+%}
+
+#endif
diff --git a/trunk/Examples/test-suite/tag_no_clash_with_variable.i b/trunk/Examples/test-suite/tag_no_clash_with_variable.i
new file mode 100644
index 000000000..5d6342314
--- /dev/null
+++ b/trunk/Examples/test-suite/tag_no_clash_with_variable.i
@@ -0,0 +1,33 @@
+/* This is a test case for -*- C -*- mode. */
+%module tag_no_clash_with_variable
+
+%inline %{
+
+/* error_action is only a tag, not a type... */
+enum error_action {
+ ERRACT_ABORT,
+ ERRACT_EXIT,
+ ERRACT_THROW
+};
+
+/* ... thus it does not clash with a variable of the same name. */
+enum error_action error_action;
+
+/* Likewise for structs: */
+
+struct buffalo {
+ int foo;
+};
+
+struct buffalo buffalo;
+
+/* And for union */
+
+union onion {
+ int cheese;
+};
+
+union onion onion;
+
+%}
+
diff --git a/trunk/Examples/test-suite/tcl/Makefile.in b/trunk/Examples/test-suite/tcl/Makefile.in
new file mode 100644
index 000000000..49d2a7826
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/Makefile.in
@@ -0,0 +1,57 @@
+#######################################################################
+# Makefile for tcl test-suite
+#######################################################################
+
+LANGUAGE = tcl
+TCLSH = tclsh
+SCRIPTSUFFIX = _runme.tcl
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+CPP_TEST_CASES += \
+ primitive_types \
+ li_cstring \
+ li_cwstring
+
+C_TEST_CASES += \
+ li_cstring \
+ li_cwstring
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# none!
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.tcl appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile tcl_clean
diff --git a/trunk/Examples/test-suite/tcl/README b/trunk/Examples/test-suite/tcl/README
new file mode 100644
index 000000000..c36c3aa9a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/tcl/bools_runme.tcl b/trunk/Examples/test-suite/tcl/bools_runme.tcl
new file mode 100644
index 000000000..582b8121f
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/bools_runme.tcl
@@ -0,0 +1,73 @@
+
+if [ catch { load ./bools[info sharedlibextension] bools} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+# bool constant check
+if {$constbool != 0} {
+ puts stderr "Runtime test 1 failed"
+ exit 1
+}
+
+# bool variables check
+if {$bool1 != 1} {
+ puts stderr "Runtime test 2 failed"
+ exit 1
+}
+
+if {$bool2 != 0} {
+ puts stderr "Runtime test 3 failed"
+ exit 1
+}
+
+if { [ value $pbool ] != $bool1} {
+ puts stderr "Runtime test 4 failed"
+ exit 1
+}
+
+if { [ value $rbool ] != $bool2} {
+ puts stderr "Runtime test 5 failed"
+ exit 1
+}
+
+if { [ value $const_pbool ] != $bool1} {
+ puts stderr "Runtime test 6 failed"
+ exit 1
+}
+
+if { $const_rbool != $bool2} {
+ puts stderr "Runtime test 7 failed"
+ exit 1
+}
+
+# bool functions check
+if { [ bo 0 ] != 0} {
+ puts stderr "Runtime test 8 failed"
+ exit 1
+}
+
+if { [ bo 1 ] != 1} {
+ puts stderr "Runtime test 9 failed"
+ exit 1
+}
+
+if { [ value [ rbo $rbool ] ] != [ value $rbool ]} {
+ puts stderr "Runtime test 10 failed"
+ exit 1
+}
+
+if { [ value [ pbo $pbool ] ] != [ value $pbool ]} {
+ puts stderr "Runtime test 11 failed"
+ exit 1
+}
+
+if { [ const_rbo $const_rbool ] != $const_rbool } {
+ puts stderr "Runtime test 12 failed"
+ exit 1
+}
+
+if { [ value [ const_pbo $const_pbool ] ] != [ value $const_pbool ]} {
+ puts stderr "Runtime test 13 failed"
+ exit 1
+}
+
diff --git a/trunk/Examples/test-suite/tcl/clientdata_prop_runme.tcl b/trunk/Examples/test-suite/tcl/clientdata_prop_runme.tcl
new file mode 100644
index 000000000..2ac993fad
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/clientdata_prop_runme.tcl
@@ -0,0 +1,88 @@
+
+if [ catch { load ./clientdata_prop_b[info sharedlibextension] clientdata_prop_b} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+}
+if [ catch { load ./clientdata_prop_a[info sharedlibextension] clientdata_prop_a} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+}
+
+A a
+test_A a
+test_tA a
+test_t2A a
+test_t3A a
+a fA
+
+B b
+test_A b
+test_tA b
+test_t2A b
+test_t3A b
+test_B b
+b fA
+b fB
+
+C c
+test_A c
+test_tA c
+test_t2A c
+test_t3A c
+test_C c
+c fA
+c fC
+
+D d
+test_A d
+test_tA d
+test_t2A d
+test_t3A d
+test_D d
+test_tD d
+test_t2D d
+d fA
+d fD
+
+set a2 [new_tA]
+test_A $a2
+test_tA $a2
+test_t2A $a2
+test_t3A $a2
+$a2 fA
+
+set a3 [new_t2A]
+test_A $a3
+test_tA $a3
+test_t2A $a3
+test_t3A $a3
+$a3 fA
+
+set a4 [new_t3A]
+test_A $a4
+test_tA $a4
+test_t2A $a4
+test_t3A $a4
+$a4 fA
+
+set d2 [new_tD]
+test_A $d2
+test_tA $d2
+test_t2A $d2
+test_t3A $d2
+test_D $d2
+test_tD $d2
+test_t2D $d2
+$d2 fA
+$d2 fD
+
+set d3 [new_t2D]
+test_A $d3
+test_tA $d3
+test_t2A $d3
+test_t3A $d3
+test_D $d3
+test_tD $d3
+test_t2D $d3
+$d3 fA
+$d3 fD
diff --git a/trunk/Examples/test-suite/tcl/disown_runme.tcl b/trunk/Examples/test-suite/tcl/disown_runme.tcl
new file mode 100644
index 000000000..d6647c037
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/disown_runme.tcl
@@ -0,0 +1,16 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+if [ catch { load ./disown[info sharedlibextension] disown} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+set x 0
+while {$x<100} {
+ set a [new_A]
+ B b
+ b acquire $a
+ incr x
+}
+
diff --git a/trunk/Examples/test-suite/tcl/enum_thorough_runme.tcl b/trunk/Examples/test-suite/tcl/enum_thorough_runme.tcl
new file mode 100644
index 000000000..d4cc1995a
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/enum_thorough_runme.tcl
@@ -0,0 +1,9 @@
+
+if [ catch { load ./enum_thorough[info sharedlibextension] enum_thorough} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+if { [speedTest0 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest0 failed" }
+if { [speedTest4 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest4 failed" }
+if { [speedTest5 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest5 failed" }
+
diff --git a/trunk/Examples/test-suite/tcl/import_nomodule_runme.tcl b/trunk/Examples/test-suite/tcl/import_nomodule_runme.tcl
new file mode 100644
index 000000000..ead6c3fbe
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/import_nomodule_runme.tcl
@@ -0,0 +1,4 @@
+
+if [ catch { load ./import_nomodule[info sharedlibextension] import_nomodule} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
diff --git a/trunk/Examples/test-suite/tcl/imports_runme.tcl b/trunk/Examples/test-suite/tcl/imports_runme.tcl
new file mode 100644
index 000000000..85abe49ed
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/imports_runme.tcl
@@ -0,0 +1,19 @@
+
+# This is the imports runtime testcase.
+
+if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+}
+if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+exit 1
+}
+
+set x [new_B]
+A_hello $x
+if [ catch { $x nonexistant } ] {
+} else {
+ puts stderr "nonexistant method did not throw exception\n"
+ exit 1
+}
diff --git a/trunk/Examples/test-suite/tcl/li_std_string_runme.tcl b/trunk/Examples/test-suite/tcl/li_std_string_runme.tcl
new file mode 100644
index 000000000..333c1f1be
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/li_std_string_runme.tcl
@@ -0,0 +1,21 @@
+
+if [ catch { load ./li_std_string[info sharedlibextension] li_std_string} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+
+Structure s
+if {"[s cget -MemberString2]" != "member string 2"} { error "bad string map"}
+s configure -MemberString2 "hello"
+if {"[s cget -MemberString2]" != "hello"} { error "bad string map"}
+
+if {"[s cget -ConstMemberString]" != "const member string"} { error "bad string map"}
+
+if {"$GlobalString2" != "global string 2"} { error "bad string map"}
+if {"$Structure_StaticMemberString2" != "static member string 2"} { error "bad string map"}
+
+set GlobalString2 "hello"
+if {"$GlobalString2" != "hello"} { error "bad string map"}
+
+set Structure_StaticMemberString2 "hello"
+if {"$Structure_StaticMemberString2" != "hello"} { error "bad string map"}
diff --git a/trunk/Examples/test-suite/tcl/member_pointer_runme.tcl b/trunk/Examples/test-suite/tcl/member_pointer_runme.tcl
new file mode 100644
index 000000000..e4d099163
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/member_pointer_runme.tcl
@@ -0,0 +1,46 @@
+# Example using pointers to member functions
+
+if [ catch { load ./member_pointer[info sharedlibextension] member_pointer} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+proc check {what expected actual} {
+ if {$expected != $actual } {
+ error "Failed: $what , Expected: $expected , Actual: $actual"
+ }
+}
+# Get the pointers
+
+set area_pt [ areapt ]
+set perim_pt [ perimeterpt ]
+
+# Create some objects
+
+set s [Square -args 10]
+
+# Do some calculations
+
+check "Square area " 100.0 [do_op $s $area_pt]
+check "Square perim" 40.0 [do_op $s $perim_pt]
+
+set memberPtr $areavar
+set memberPtr $perimetervar
+
+# Try the variables
+check "Square area " 100.0 [do_op $s $areavar]
+check "Square perim" 40.0 [do_op $s $perimetervar]
+
+# Modify one of the variables
+set areavar $perim_pt
+
+check "Square perimeter" 40.0 [do_op $s $areavar]
+
+# Try the constants
+
+set memberPtr $AREAPT
+set memberPtr $PERIMPT
+set memberPtr $NULLPT
+
+check "Square area " 100.0 [do_op $s $AREAPT]
+check "Square perim" 40.0 [do_op $s $PERIMPT]
+
diff --git a/trunk/Examples/test-suite/tcl/newobject1_runme.tcl b/trunk/Examples/test-suite/tcl/newobject1_runme.tcl
new file mode 100644
index 000000000..da6ff6679
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/newobject1_runme.tcl
@@ -0,0 +1,28 @@
+if [ catch { load ./newobject1[info sharedlibextension] newobject1} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+set foo1 [Foo_makeFoo]
+if {[Foo_fooCount] != 1} {
+ puts stderr "newobject1 test 1 failed"
+ exit 1
+}
+
+set foo2 [$foo1 makeMore]
+if {[Foo_fooCount] != 2} {
+ puts stderr "newobject1 test 2 failed"
+ exit 1
+}
+
+# Disable test while we solve the problem of premature object deletion
+#$foo1 -delete
+#if {[Foo_fooCount] != 1} {
+# puts stderr "newobject1 test 3 failed"
+# exit 1
+#}
+#
+#$foo2 -delete
+#if {[Foo_fooCount] != 0} {
+# puts stderr "newobject1 test 4 failed"
+# exit 1
+#}
diff --git a/trunk/Examples/test-suite/tcl/newobject2_runme.tcl b/trunk/Examples/test-suite/tcl/newobject2_runme.tcl
new file mode 100644
index 000000000..18d23af33
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/newobject2_runme.tcl
@@ -0,0 +1,27 @@
+if [ catch { load ./newobject2[info sharedlibextension] newobject2} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+set foo1 [makeFoo]
+if {[fooCount] != 1} {
+ puts stderr "newobject2 test 1 failed"
+ exit 1
+}
+
+set foo2 [makeFoo]
+if {[fooCount] != 2} {
+ puts stderr "newobject2 test 2 failed"
+ exit 1
+}
+
+#$foo1 -delete
+#if {[fooCount] != 1} {
+# puts stderr "newobject2 test 3 failed"
+# exit 1
+#}
+
+#$foo2 -delete
+#if {[fooCount] != 0} {
+# puts stderr "newobject2 test 4 failed"
+# exit 1
+#}
diff --git a/trunk/Examples/test-suite/tcl/overload_copy_runme.tcl b/trunk/Examples/test-suite/tcl/overload_copy_runme.tcl
new file mode 100644
index 000000000..46d7058d5
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/overload_copy_runme.tcl
@@ -0,0 +1,12 @@
+
+if [ catch { load ./overload_copy[info sharedlibextension] overload_copy} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+Foo f
+Foo g [f cget -this]
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/tcl/overload_simple_runme.tcl b/trunk/Examples/test-suite/tcl/overload_simple_runme.tcl
new file mode 100644
index 000000000..6b65ccc90
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/overload_simple_runme.tcl
@@ -0,0 +1,166 @@
+
+if [ catch { load ./overload_simple[info sharedlibextension] overload_simple} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+set f [new_Foo]
+set b [new_Bar]
+set v [malloc_void 32]
+
+set x [foo 3]
+if {$x != "foo:int"} {
+ puts stderr "foo(int) test failed $x"
+ exit 1
+}
+
+set x [foo 3.4]
+if {$x != "foo:double"} {
+ puts stderr "foo(double) test failed"
+ exit 1
+}
+
+set x [foo hello]
+if {$x != "foo:char *"} {
+ puts stderr "foo(char *) test failed"
+ exit 1
+}
+
+set x [foo $f]
+if {$x != "foo:Foo *"} {
+ puts stderr "foo(Foo *) test failed"
+ exit 1
+}
+
+set x [foo $b]
+if {$x != "foo:Bar *"} {
+ puts stderr "foo(Bar *) test failed"
+ exit 1
+}
+
+set x [foo $v]
+if {$x != "foo:void *"} {
+ puts stderr "foo(void *) test failed"
+ exit 1
+}
+
+Spam s
+
+set x [s foo 3]
+if {$x != "foo:int"} {
+ puts stderr "Spam::foo(int) test failed"
+ exit 1
+}
+
+set x [s foo 3.4]
+if {$x != "foo:double"} {
+ puts stderr "Spam::foo(double) test failed"
+ exit 1
+}
+
+set x [s foo hello]
+if {$x != "foo:char *"} {
+ puts stderr "Spam::foo(char *) test failed"
+ exit 1
+}
+
+set x [s foo $f]
+if {$x != "foo:Foo *"} {
+ puts stderr "Spam::foo(Foo *) test failed"
+ exit 1
+}
+
+set x [s foo $b]
+if {$x != "foo:Bar *"} {
+ puts stderr "Spam::foo(Bar *) test failed"
+ exit 1
+}
+
+set x [s foo $v]
+if {$x != "foo:void *"} {
+ puts stderr "Spam::foo(void *) test failed"
+ exit 1
+}
+
+
+set x [Spam_bar 3]
+if {$x != "bar:int"} {
+ puts stderr "Spam::bar(int) test failed"
+ exit 1
+}
+
+set x [Spam_bar 3.4]
+if {$x != "bar:double"} {
+ puts stderr "Spam::bar(double) test failed"
+ exit 1
+}
+
+set x [Spam_bar hello]
+if {$x != "bar:char *"} {
+ puts stderr "Spam::bar(char *) test failed"
+ exit 1
+}
+
+set x [Spam_bar $f]
+if {$x != "bar:Foo *"} {
+ puts stderr "Spam::bar(Foo *) test failed"
+ exit 1
+}
+
+set x [Spam_bar $b]
+if {$x != "bar:Bar *"} {
+ puts stderr "Spam::bar(Bar *) test failed"
+ exit 1
+}
+
+set x [Spam_bar $v]
+if {$x != "bar:void *"} {
+ puts stderr "Spam::bar(void *) test failed"
+ exit 1
+}
+
+Spam s
+set x [s cget -type]
+if {$x != "none"} {
+ puts stderr "Spam() test failed"
+}
+
+Spam s 3
+set x [s cget -type]
+if {$x != "int"} {
+ puts stderr "Spam(int) test failed"
+}
+
+Spam s 3.4
+set x [s cget -type]
+if {$x != "double"} {
+ puts stderr "Spam(double) test failed"
+}
+
+Spam s hello
+set x [s cget -type]
+if {$x != "char *"} {
+ puts stderr "Spam(char *) test failed"
+}
+
+Spam s $f
+set x [s cget -type]
+if {$x != "Foo *"} {
+ puts stderr "Spam(Foo *) test failed"
+}
+
+Spam s $b
+set x [s cget -type]
+if {$x != "Bar *"} {
+ puts stderr "Spam(Bar *) test failed"
+}
+
+Spam s $v
+set x [s cget -type]
+if {$x != "void *"} {
+ puts stderr "Spam(void *) test failed"
+}
+
+free_void $v
+
+
+
diff --git a/trunk/Examples/test-suite/tcl/primitive_ref_runme.tcl b/trunk/Examples/test-suite/tcl/primitive_ref_runme.tcl
new file mode 100644
index 000000000..ab4e444d2
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/primitive_ref_runme.tcl
@@ -0,0 +1,19 @@
+# Primitive ref testcase. Tests to make sure references to
+# primitive types are passed by value
+
+if [ catch { load ./primitive_ref[info sharedlibextension] primitive_ref} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+if { [ref_int 3] != 3 } { puts stderr "ref_int failed" }
+if { [ref_uint 3] != 3 } { puts stderr "ref_uint failed" }
+if { [ref_short 3] != 3 } { puts stderr "ref_short failed" }
+if { [ref_ushort 3] != 3 } { puts stderr "ref_ushort failed" }
+if { [ref_long 3] != 3 } { puts stderr "ref_long failed" }
+if { [ref_ulong 3] != 3 } { puts stderr "ref_ulong failed" }
+if { [ref_schar 3] != 3 } { puts stderr "ref_schar failed" }
+if { [ref_uchar 3] != 3 } { puts stderr "ref_uchar failed" }
+if { [ref_float 3.5] != 3.5 } { puts stderr "ref_float failed" }
+if { [ref_double 3.5] != 3.5 } { puts stderr "ref_double failed" }
+if { [ref_char x] != "x" } { puts stderr "ref_char failed" }
+
diff --git a/trunk/Examples/test-suite/tcl/primitive_types_runme.tcl b/trunk/Examples/test-suite/tcl/primitive_types_runme.tcl
new file mode 100644
index 000000000..fa4c46ba5
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/primitive_types_runme.tcl
@@ -0,0 +1,33 @@
+
+if [ catch { load ./primitive_types[info sharedlibextension] primitive_types} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+
+if {[val_int 10] != 10 } { error "bad int map" }
+if {[val_schar 10] != 10 } { error "bad char map" }
+if {[val_short 10] != 10 } { error "bad schar map" }
+
+
+if [catch { val_schar 10000 } ] {} else { error "bad schar map" }
+if [catch { val_uint -100 } ] {} else { error "bad uint map" }
+if [catch { val_uchar -100 } ] {} else { error "bad uchar map" }
+
+if {[val_uint 10] != 10 } { error "bad uint map" }
+if {[val_uchar 10] != 10 } { error "bad uchar map" }
+if {[val_ushort 10] != 10 } { error "bad ushort map" }
+
+
+if {[val_double 10] != 10 } { error "bad double map" }
+if {[val_float 10] != 10 } { error "bad double map" }
+
+
+
+if [catch { val_float hello } ] {} else { error "bad double map" }
+
+if {[val_char c] != "c" } { error "bad char map" }
+if {[val_char "c"] != "c" } { error "bad char map" }
+if {[val_char 101] != "e" } { error "bad char map" }
+
+
+
diff --git a/trunk/Examples/test-suite/tcl/profiletest_runme.tcl b/trunk/Examples/test-suite/tcl/profiletest_runme.tcl
new file mode 100644
index 000000000..087eea463
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/profiletest_runme.tcl
@@ -0,0 +1,8 @@
+catch { load ./profiletest[info sharedlibextension] profiletest}
+
+set a [new_A]
+set b [new_B]
+
+for {set i 0} {$i < 1000000} {incr i 1} {
+ set a [B_fn $b $a]
+}
diff --git a/trunk/Examples/test-suite/tcl/reference_global_vars_runme.tcl b/trunk/Examples/test-suite/tcl/reference_global_vars_runme.tcl
new file mode 100644
index 000000000..bfd31a949
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/reference_global_vars_runme.tcl
@@ -0,0 +1,108 @@
+if [ catch { load ./reference_global_vars[info sharedlibextension] reference_global_vars} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+# const class reference variable
+if {[ [getconstTC ] cget -num] != 33 } {
+ puts stderr "test 1 failed"
+ exit 1
+}
+
+# primitive reference variables
+set var_bool [createref_bool 0]
+if {[value_bool $var_bool] != 0} {
+ puts stderr "test 2 failed"
+ exit 1
+}
+
+set var_bool [createref_bool 1]
+if {[value_bool $var_bool] != 1} {
+ puts stderr "test 3 failed"
+ exit 1
+}
+
+set var_char [createref_char "w"]
+if {[value_char $var_char] != "w"} {
+ puts stderr "test 4 failed"
+ exit 1
+}
+
+set var_unsigned_char [createref_unsigned_char 10]
+if {[value_unsigned_char $var_unsigned_char] != 10} {
+ puts stderr "test 5 failed"
+ exit 1
+}
+
+set var_signed_char [createref_signed_char 10]
+if {[value_signed_char $var_signed_char] != 10} {
+ puts stderr "test 6 failed"
+ exit 1
+}
+
+set var_short [createref_short 10]
+if {[value_short $var_short] != 10} {
+ puts stderr "test 7 failed"
+ exit 1
+}
+
+set var_unsigned_short [createref_unsigned_short 10]
+if {[value_unsigned_short $var_unsigned_short] != 10} {
+ puts stderr "test 8 failed"
+ exit 1
+}
+
+set var_int [createref_int 10]
+if {[value_int $var_int] != 10} {
+ puts stderr "test 9 failed"
+ exit 1
+}
+
+set var_unsigned_int [createref_unsigned_int 10]
+if {[value_unsigned_int $var_unsigned_int] != 10} {
+ puts stderr "test 10 failed"
+ exit 1
+}
+
+set var_long [createref_long 10]
+if {[value_long $var_long] != 10} {
+ puts stderr "test 11 failed"
+ exit 1
+}
+
+set var_unsigned_long [createref_unsigned_long 10]
+if {[value_unsigned_long $var_unsigned_long] != 10} {
+ puts stderr "test 12 failed"
+ exit 1
+}
+
+set var_long_long [createref_long_long 10]
+if {[value_long_long $var_long_long] != 10} {
+ puts stderr "test 13 failed"
+ exit 1
+}
+
+set var_unsigned_long_long [createref_unsigned_long_long 10]
+if {[value_unsigned_long_long $var_unsigned_long_long] != 10} {
+ puts stderr "test 14 failed"
+ exit 1
+}
+
+set var_float [createref_float 10.5]
+if {[value_float $var_float] != 10.5} {
+ puts stderr "test 15 failed"
+ exit 1
+}
+
+set var_double [createref_double 10.5]
+if {[value_double $var_double] != 10.5} {
+ puts stderr "test 16 failed"
+ exit 1
+}
+
+# class reference variable
+set var_TestClass [createref_TestClass [TestClass tc 20] ]
+if {[ [value_TestClass $var_TestClass] cget -num] != 20} {
+ puts stderr "test 17 failed"
+ exit 1
+}
+
diff --git a/trunk/Examples/test-suite/tcl/union_parameter_runme.tcl b/trunk/Examples/test-suite/tcl/union_parameter_runme.tcl
new file mode 100644
index 000000000..fb3e092b8
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/union_parameter_runme.tcl
@@ -0,0 +1,36 @@
+if [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+set event [SDL_Event]
+
+for { set i 0 } { $i < 2 } { incr i } {
+# puts -nonewline "Loop $i: "
+ set evAvailable [SDL_PollEvent $event]
+ set evType [$event cget -type]
+# puts "evType = $evType"
+
+ if { $evType == 1 } {
+ set specEvent [$event cget -active]
+# puts "specEvent = $specEvent"
+ set type [$specEvent cget -type]
+ if { $type != $evType } {
+ error "Type $type should be $evType"
+ }
+ set gain [$specEvent cget -gain]
+ set state [$specEvent cget -state]
+# puts "gain=$gain state=$state"
+ }
+ if { $evType == 2 } {
+ set specEvent [$event cget -key]
+# puts "specEvent = $specEvent"
+ set type [$specEvent cget -type]
+ if { $type != $evType } {
+ error "Type $type should be $evType"
+ }
+ set which [$specEvent cget -which]
+ set state [$specEvent cget -state]
+# puts "which=$which state=$state"
+ }
+# puts ""
+}
diff --git a/trunk/Examples/test-suite/tcl/unions_runme.tcl b/trunk/Examples/test-suite/tcl/unions_runme.tcl
new file mode 100644
index 000000000..8c310950f
--- /dev/null
+++ b/trunk/Examples/test-suite/tcl/unions_runme.tcl
@@ -0,0 +1,63 @@
+
+# This is the union runtime testcase. It ensures that values within a
+# union embedded within a struct can be set and read correctly.
+
+if [ catch { load ./unions[info sharedlibextension] unions} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+# Create new instances of SmallStruct and BigStruct for later use
+SmallStruct small
+small configure -jill 200
+
+BigStruct big
+big configure -smallstruct [small cget -this]
+big configure -jack 300
+
+# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
+# Ensure values in EmbeddedUnionTest are set correctly for each.
+EmbeddedUnionTest eut
+
+# First check the SmallStruct in EmbeddedUnionTest
+eut configure -number 1
+
+#eut.uni.small = small
+EmbeddedUnionTest_uni_small_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [small cget -this]
+
+#Jill1 = eut.uni.small.jill
+set Jill1 [SmallStruct_jill_get [EmbeddedUnionTest_uni_small_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
+if {$Jill1 != 200} {
+ puts stderr "Runtime test1 failed. eut.uni.small.jill=$Jill1"
+ exit 1
+}
+
+set Num1 [eut cget -number]
+if {$Num1 != 1} {
+ puts stderr "Runtime test2 failed. eut.number=$Num1"
+ exit 1
+}
+
+# Secondly check the BigStruct in EmbeddedUnionTest
+eut configure -number 2
+#eut.uni.big = big
+EmbeddedUnionTest_uni_big_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [big cget -this]
+#Jack1 = eut.uni.big.jack
+set Jack1 [BigStruct_jack_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
+if {$Jack1 != 300} {
+ puts stderr "Runtime test3 failed. eut.uni.big.jack=$Jack1"
+ exit 1
+}
+
+#Jill2 = eut.uni.big.smallstruct.jill
+set Jill2 [SmallStruct_jill_get [BigStruct_smallstruct_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] ]
+if {$Jill2 != 200} {
+ puts stderr "Runtime test4 failed. eut.uni.big.smallstruct.jill=$Jill2"
+ exit 1
+}
+
+set Num2 [eut cget -number]
+if {$Num2 != 2} {
+ puts stderr "Runtime test5 failed. eut.number=$Num2"
+ exit 1
+}
+
diff --git a/trunk/Examples/test-suite/template.i b/trunk/Examples/test-suite/template.i
new file mode 100644
index 000000000..d2c7a91ed
--- /dev/null
+++ b/trunk/Examples/test-suite/template.i
@@ -0,0 +1,52 @@
+/* File : example.i */
+%module "template"
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<double>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int (*)[10]>; /* Ruby, wrong class name */
+
+/* Let's just grab the original header file here */
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+%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/trunk/Examples/test-suite/template_arg_replace.i b/trunk/Examples/test-suite/template_arg_replace.i
new file mode 100644
index 000000000..25274c9ab
--- /dev/null
+++ b/trunk/Examples/test-suite/template_arg_replace.i
@@ -0,0 +1,14 @@
+%module template_arg_replace
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test_Matrix<float, 3, 3>; /* Ruby, wrong class name */
+
+%inline %{
+
+template <typename T, int r, int c> class test_Matrix {
+public:
+ void Func(const test_Matrix<T,r,c> &m) { };
+};
+%}
+
+%template (matrix33f) test_Matrix<float,3, 3>;
+
diff --git a/trunk/Examples/test-suite/template_arg_scope.i b/trunk/Examples/test-suite/template_arg_scope.i
new file mode 100644
index 000000000..36b593c3d
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_arg_typename.i b/trunk/Examples/test-suite/template_arg_typename.i
new file mode 100644
index 000000000..0f4c88793
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_array_numeric.i b/trunk/Examples/test-suite/template_array_numeric.i
new file mode 100644
index 000000000..463b04ac1
--- /dev/null
+++ b/trunk/Examples/test-suite/template_array_numeric.i
@@ -0,0 +1,26 @@
+%module template_array_numeric
+
+%inline %{
+
+template <int Len>
+class Arrayf
+{
+ float a[Len];
+ public:
+ Arrayf() {}
+ Arrayf(const float l[Len]) { };
+};
+
+template <int Len>
+Arrayf<Len> make_arrayf(const float l[Len])
+{
+ Arrayf<Len> a(l);
+ return a;
+}
+
+typedef Arrayf<4> Array4f;
+
+%}
+
+%template(Array4f) Arrayf<4>;
+%template(make_array4f) make_arrayf<4>;
diff --git a/trunk/Examples/test-suite/template_base_template.i b/trunk/Examples/test-suite/template_base_template.i
new file mode 100644
index 000000000..130dc390e
--- /dev/null
+++ b/trunk/Examples/test-suite/template_base_template.i
@@ -0,0 +1,41 @@
+%module template_base_template
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) traits<double, double>; /* Ruby, wrong class name */
+
+%warnfilter(SWIGWARN_PARSE_EXPLICIT_TEMPLATE);
+
+%inline %{
+ template <class ArgType, class ResType>
+ struct traits
+ {
+ typedef ArgType arg_type;
+ typedef ResType res_type;
+ };
+
+ template <class ArgType, class ResType>
+ struct Funktion
+ {
+ };
+
+ // Egad!
+ template <class AF, class AG>
+ struct Klass
+ : Funktion<typename traits<AF, AG>::arg_type,
+ typename traits<AF, AG>::res_type>
+ {
+ };
+%}
+
+%{
+ template struct Funktion <double, double>;
+ template struct Klass <double, double>;
+%}
+
+%template(traits_dd) traits <double, double>;
+%template(Funktion_dd) Funktion <double, double>;
+%template(Klass_dd) Klass <double, double>;
+
+
+
+
+
diff --git a/trunk/Examples/test-suite/template_classes.i b/trunk/Examples/test-suite/template_classes.i
new file mode 100644
index 000000000..ebe13bd9f
--- /dev/null
+++ b/trunk/Examples/test-suite/template_classes.i
@@ -0,0 +1,40 @@
+/* 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 RectangleTest {
+public:
+ Point<T>& getPoint() {return point;}
+ void setPoint(Point<T>& value) {point = value;}
+private:
+ Point<T> point;
+
+ template <class Data>
+ struct pair2nd_eq
+ {
+ };
+
+ struct Foo : Point<int>
+ {
+ };
+
+ Foo foo;
+};
+
+%}
+
+%template(PointInt) Point<int>;
+%template(RectangleInt) RectangleTest<int>;
+
diff --git a/trunk/Examples/test-suite/template_const_ref.i b/trunk/Examples/test-suite/template_const_ref.i
new file mode 100644
index 000000000..196ca9005
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_construct.i b/trunk/Examples/test-suite/template_construct.i
new file mode 100644
index 000000000..a6e8c3c33
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_default.i b/trunk/Examples/test-suite/template_default.i
new file mode 100644
index 000000000..d771ef09e
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default.i
@@ -0,0 +1,216 @@
+%module template_default
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) ns1::Traits::c; /* Ruby, wrong constant name */
+
+namespace ns1 {
+ namespace ns2 {
+
+ %feature("hello") A<int>;
+ %feature("hello") A<double,double>;
+ %feature("hi") A<int,int>;
+ %feature("hi") A<double>;
+
+ %extend A<int>
+ {
+ int foo() { return 1; }
+ }
+
+ %extend A<double,double>
+ {
+ int foo() { return 1; }
+ }
+
+ %extend A<int,int>
+ {
+ int bar() { return 1; }
+ }
+
+ %extend A<double>
+ {
+ int bar() { return 1; }
+ }
+
+ %extend N<double>
+ {
+ int bar() { return 1; }
+ }
+ }
+}
+
+%inline %{
+
+ namespace ns1 {
+ namespace ns2 {
+
+ struct Parm
+ {
+ };
+
+ template <class T1, class T2 = T1>
+ class A
+ {
+
+#ifdef SWIG
+ %typemap(in) A * { /* in A */ }
+ #ifdef SWIGCSHARP
+ %typemap(out) A * { /* out A */ $result=0; }
+ #else
+ %typemap(out) A * { /* out A */ }
+ #endif
+#endif
+ };
+
+ typedef unsigned int category;
+
+ const category one = 1;
+ const category two = 1;
+
+
+ template <class T1, category C = one, class T2 = Parm>
+ class N
+ {
+
+#ifdef SWIG
+ %typemap(in) N * { /* in N */ }
+ #ifdef SWIGCSHARP
+ %typemap(out) N * { /* out N */ $result=0; }
+ #else
+ %typemap(out) N * { /* out N */ }
+ #endif
+#endif
+ };
+ }
+ }
+%}
+
+
+
+
+%template(A_p) ns1::ns2::A<double,ns1::ns2::Parm>;
+%template(N_1p) ns1::ns2::N<int>;
+
+
+namespace ns1 {
+ namespace ns2 {
+ %template(A_ii) A<int, int>;
+ %template(A_d) A<double>;
+ %template(N_d) N<double>;
+
+ }
+}
+
+
+%inline %{
+ namespace ns1 {
+ namespace ns2 {
+ namespace ns3 {
+
+ struct B : A<int>
+ {
+ };
+
+ struct C : N<double,ns1::ns2::one>
+ {
+ };
+
+
+ A<int> *get_a1(A<int> *a) {
+ return a;
+ }
+
+ A<int,int> *get_a2(A<int,int> *a) {
+ return a;
+ }
+
+ }
+ }
+ }
+%}
+
+%inline %{
+ namespace ns1 {
+ struct Traits
+ {
+ static const ns2::category c = ns2::one;
+ };
+ namespace ns4 {
+
+ template <class T>
+ struct D : ns2::N<double,T::c>
+ {
+ D()
+ {
+ }
+
+ };
+
+ template <class T1, class T2 = D<T1> >
+ struct Base : T2
+ {
+ };
+ }
+ }
+%}
+
+
+%template(Doo) ns1::ns4::D<ns1::Traits>;
+%template(Boo) ns1::ns4::Base<ns1::Traits, ns1::ns4::D<ns1::Traits> >;
+
+
+
+%inline %{
+ namespace ns1 {
+ namespace ns5 {
+
+ struct Der : ns4::Base<Traits>
+ {
+ };
+ }
+ }
+
+%}
+
+
+%inline %{
+
+ namespace hi
+ {
+ class CFoo
+ {
+ };
+
+ template<class T1, class T2 = T1> class CTemplate
+ {
+ };
+
+ typedef CTemplate<CFoo> TBla; // OK
+ typedef void (*TFunc1)(CFoo arg); // OK
+ typedef void (*TFunc2)(CTemplate<CFoo> arg); // OK
+ typedef void (*TFunc3)(CTemplate<CFoo>* arg); // OK
+
+ int foo(TFunc1 a, TFunc2 b, TFunc3 c)
+ {
+ return 0;
+ }
+ }
+%}
+
+
+#ifndef SWIGCHICKEN
+%include std_vector.i
+
+%{
+#include <vector>
+%}
+
+%inline %{
+void g(std::vector<double>* s = 0) {}
+void q(double = 0) {}
+%}
+
+
+%constant void (*Bf)(std::vector<double> *p = 0) = g;
+%constant void (*Cf)(double = 0) = q;
+
+
+#endif
diff --git a/trunk/Examples/test-suite/template_default2.i b/trunk/Examples/test-suite/template_default2.i
new file mode 100644
index 000000000..9ba0455f1
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default2.i
@@ -0,0 +1,44 @@
+%module template_default2
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::traits; // Ruby, wrong class name
+
+%inline %{
+ namespace oss
+ {
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+
+ template <Polarization P>
+ struct Interface_tpl
+ {
+ };
+
+ struct traits
+ {
+ static const Polarization pmode = UnaryPolarization;
+ };
+
+ template <class C,
+ Polarization P = C::pmode,
+ class Base = Interface_tpl<P> > // **** problem here *****
+ struct Module : Base
+ {
+ };
+
+ }
+%}
+
+namespace oss
+{
+ %template(Interface_UP) Interface_tpl<UnaryPolarization>;
+
+ // This works
+ %template(Module_UP1) Module<traits,
+ UnaryPolarization,
+ Interface_tpl<UnaryPolarization> >;
+
+ // These don't
+ %template(Module_UP2) Module<traits, UnaryPolarization>;
+ %template(Module_UP3) Module<traits>;
+}
+
+
diff --git a/trunk/Examples/test-suite/template_default_arg.i b/trunk/Examples/test-suite/template_default_arg.i
new file mode 100644
index 000000000..faa0f686b
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default_arg.i
@@ -0,0 +1,126 @@
+%module template_default_arg
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hello; /* Ruby, wrong class name */
+#ifdef SWIGLUA
+// lua only has one numeric type, so most of the overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) X;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Z;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) meth;
+#endif
+
+%inline %{
+ template <class T>
+ struct Foo
+ {
+ typedef unsigned int size_type;
+ Foo(size_type n = size_type(0) ) { }
+ };
+
+ int foob(Foo<int> h = Foo<int>()) {return 1; }
+
+ 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) ) { }
+
+ enum Hi { hi, hello };
+
+ void foo(Hi h = hi) { }
+ };
+
+ template <typename T> struct X {
+ X(const T& t = T()) {}
+ X(double a, const T& t = T(0)) {}
+ T meth(double a, const T& t = T(0)) { return t; }
+ const T& meth(const T& t = T(0)) { return t; }
+ };
+
+ template <typename TT> class Y : private X<TT> {
+ public:
+ // test using on templated class with default args in the method
+ using X<TT>::meth;
+ };
+
+ template <int V> struct Z
+ {
+ Z(int t = V) {}
+ // and also:
+ Z(double a, int t = V){}
+ };
+
+
+%}
+
+%template(Foo_int) Foo<int>;
+%template(Hello_int) Hello<int>;
+%template(X_int) X<int>;
+%template(X_longlong) X<long long>;
+%template(X_unsigned) X<unsigned>;
+%template(Y_unsigned) Y<unsigned>;
+
+%template(X_hello_unsigned) X<Hello<int> >;
+%template(Y_hello_unsigned) Y<Hello<int> >;
+%template(X_Foo_Foo_int) X<Foo<Foo<int> > >;
+%template(Z_8) Z<8>;
+%template(Foo_Z_8) Foo<Z<8> >;
+%template(X_Foo_Z_8) X<Foo<Z<8> > >;
+
+%inline %{
+
+ struct Bar : Hello<int>
+ {
+ Bar(size_type n) : Hello<int>(n)
+ {
+ }
+
+ };
+%}
+
+
+// Templated functions
+%inline %{
+ // Templated methods which are overloaded and have default args, and %template which
+ // uses the same name as the C++ functions and overload on the template parameters and
+ // specialization thrown in too. Wow, SWIG can handle this insane stuff!
+ template<typename T, typename U> int ott(T t = 0, const U& u = U()) { return 10; }
+ template<typename T, typename U> int ott(const char *msg, T t = 0, const U& u = U()) { return 20; }
+ int ott(Foo<int>) { return 30; }
+ template<typename T> int ott(Hello<int> h, T t = 0) { return 40; }
+ template<> int ott<int>(Hello<int> h, int t) { return 50; }
+ template<> int ott(Hello<int> h, double t) { return 60; }
+%}
+
+%template(ott) ott<int, int>;
+%template(ott) ott<double>;
+%template(ottint) ott<int>; // default arg requires a rename
+%template(ottstring) ott<const char *>; // default arg requires a rename
+
+
+// Above test in namespaces
+%inline %{
+namespace OuterSpace {
+ namespace InnerSpace {
+ // Templated methods which are overloaded and have default args, and %template which
+ // uses the same name as the C++ functions and overload on the template parameters and
+ // specialization thrown in too. Wow, SWIG can handle this insane stuff!
+ template<typename T, typename U> int nsott(T t = 0, const U& u = U()) { return 110; }
+ template<typename T, typename U> int nsott(const char *msg, T t = 0, const U& u = U()) { return 120; }
+ int nsott(Foo<int>) { return 130; }
+ template<typename T> int nsott(Hello<int> h, T t = 0) { return 140; }
+ template<> int nsott<int>(Hello<int> h, int t) { return 150; }
+ template<> int nsott(Hello<int> h, double t) { return 160; }
+ }
+}
+%}
+
+%template(nsott) OuterSpace::InnerSpace::nsott<int, int>;
+%template(nsott) OuterSpace::InnerSpace::nsott<double>;
+%template(nsottint) OuterSpace::InnerSpace::nsott<int>; // default arg requires a rename
+%template(nsottstring) OuterSpace::InnerSpace::nsott<const char *>; // default arg requires a rename
+
diff --git a/trunk/Examples/test-suite/template_default_class_parms.i b/trunk/Examples/test-suite/template_default_class_parms.i
new file mode 100644
index 000000000..cd37269d3
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default_class_parms.i
@@ -0,0 +1,33 @@
+%module template_default_class_parms
+
+%inline %{
+namespace Space {
+ struct SomeType {};
+ struct AnotherType {};
+ template<typename C, typename D = SomeType, typename E = int> class Bar {
+ public:
+ C CType;
+ D DType;
+ E EType;
+ Bar(C c, D d, E e) {}
+ C method(C c, D d, E e) { return c; }
+ };
+ template<typename T = SomeType> class Foo {
+ public:
+ T TType;
+ Foo(T t) {}
+ T method(T t) { return t; }
+ };
+ template<typename T = int> class ATemplate {};
+}
+%}
+
+// Use defaults
+%template(DefaultBar) Space::Bar<double>;
+%template(DefaultFoo) Space::Foo<>;
+
+// Don't use all defaults
+%template(BarAnotherTypeBool) Space::Bar<Space::AnotherType, bool>;
+%template(FooAnotherType) Space::Foo<Space::AnotherType>;
+
+%template() Space::ATemplate<>;
diff --git a/trunk/Examples/test-suite/template_default_inherit.i b/trunk/Examples/test-suite/template_default_inherit.i
new file mode 100644
index 000000000..d8d34d858
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default_inherit.i
@@ -0,0 +1,25 @@
+%module template_default_inherit
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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 = A<C>::nindex) {}
+ };
+
+%}
+
+%template(A_int) A<int>;
+%template(B_int) B<int>;
+
diff --git a/trunk/Examples/test-suite/template_default_pointer.i b/trunk/Examples/test-suite/template_default_pointer.i
new file mode 100644
index 000000000..9582ef461
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default_pointer.i
@@ -0,0 +1,12 @@
+%module template_default_pointer
+
+%inline %{
+
+template <class T1, class T2 = T1*>
+class B
+{
+};
+
+%}
+
+%template(B_d) B<double>;
diff --git a/trunk/Examples/test-suite/template_default_qualify.i b/trunk/Examples/test-suite/template_default_qualify.i
new file mode 100644
index 000000000..640011b2c
--- /dev/null
+++ b/trunk/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(SWIGWARN_RUBY_WRONG_NAME) 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/trunk/Examples/test-suite/template_default_vw.i b/trunk/Examples/test-suite/template_default_vw.i
new file mode 100644
index 000000000..429ed301e
--- /dev/null
+++ b/trunk/Examples/test-suite/template_default_vw.i
@@ -0,0 +1,24 @@
+%module template_default_vw
+
+%inline %{
+class SomeClass{ };
+
+template<class T>
+class Handle {
+public:
+ Handle( T* t=0 ) { };
+ // ...
+};
+
+typedef Handle<SomeClass> hSomeClass;
+class AnotherClass {
+public:
+ void someFunc( hSomeClass a = hSomeClass() ) { };
+};
+
+%}
+
+%template() Handle<SomeClass>;
+
+
+
diff --git a/trunk/Examples/test-suite/template_enum.i b/trunk/Examples/test-suite/template_enum.i
new file mode 100644
index 000000000..0d6fbf5b9
--- /dev/null
+++ b/trunk/Examples/test-suite/template_enum.i
@@ -0,0 +1,41 @@
+%module template_enum
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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>;
+
+
+%inline {
+
+namespace Manta {
+ template<typename Traits> class ColorSpace {
+ public:
+ typedef typename Traits::ComponentType ComponentType;
+ enum { NumComponents = Traits::NumComponents};
+
+ ComponentType data[NumComponents];
+ };
+}
+
+namespace Manta {
+ class RGBTraits {
+ public:
+ typedef float ComponentType;
+ enum {NumComponents = 3};
+ };
+}
+}
+
+
+namespace Manta {
+ %template(Color) ColorSpace<RGBTraits>;
+};
diff --git a/trunk/Examples/test-suite/template_enum_ns_inherit.i b/trunk/Examples/test-suite/template_enum_ns_inherit.i
new file mode 100644
index 000000000..c617b5716
--- /dev/null
+++ b/trunk/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> > {
+ };
+
+ }
+ }
+%}
diff --git a/trunk/Examples/test-suite/template_enum_typedef.i b/trunk/Examples/test-suite/template_enum_typedef.i
new file mode 100644
index 000000000..38444594e
--- /dev/null
+++ b/trunk/Examples/test-suite/template_enum_typedef.i
@@ -0,0 +1,39 @@
+%module template_enum_typedef
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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/trunk/Examples/test-suite/template_explicit.i b/trunk/Examples/test-suite/template_explicit.i
new file mode 100644
index 000000000..ede854a27
--- /dev/null
+++ b/trunk/Examples/test-suite/template_explicit.i
@@ -0,0 +1,60 @@
+/* File : example.i */
+%module "template_explicit"
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<double>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int (*)[10]>; /* Ruby, wrong class name */
+
+// #pragma is used for warnings that are not associated to
+// specific nodes.
+#pragma SWIG nowarn=-SWIGWARN_PARSE_EXPLICIT_TEMPLATE
+
+
+/* Let's just grab the original header file here */
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+%inline %{
+
+template<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) { }
+};
+
+/* Explicit instantiation. SWIG should ignore */
+template class vector<int>;
+template class vector<double>;
+template class vector<int *>;
+%}
+
+/* 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/trunk/Examples/test-suite/template_expr.i b/trunk/Examples/test-suite/template_expr.i
new file mode 100644
index 000000000..a1bb7ef09
--- /dev/null
+++ b/trunk/Examples/test-suite/template_expr.i
@@ -0,0 +1,57 @@
+%module template_expr
+
+// bug #925555
+%inline %{
+
+ template<int __stride, class __elementTypeSequence,
+ class __dataPtrType, class __elementType>
+ inline const ThisType &
+ ConcatenationOf(const vctFixedLengthConstSequenceBase<_size - 1,
+ __stride, __elementTypeSequence, __dataPtrType> & other,
+ __elementType last);
+%}
+
+// bug #956282
+%inline %{
+
+
+template<int q>
+class X {};
+
+
+%}
+
+%template(X_1) X<1>;
+%template(X_m1) X<-1>;
+%template(X_1plus2) X<1+2>;
+%template(X_1024div8) X<1024/8>;
+
+
+// bug #646275
+
+%inline %{
+ template<typename Type, short Rank>
+ typedef typename CondRetType< Rank!=1,
+ Test<Type,Rank-1>, Type>::TestRm1 TestRm1;
+%}
+
+
+// bug #994301
+
+
+%inline %{
+ template<int foo> class X994301 {};
+%}
+
+%template(X994301_ternary) X<(7 >= 4) ? 1 + 1 : 1>;
+%template(X994301_ternary2) X<(7 <= 4) ? 1 + 1 : 1>;
+
+
+// bug #1338527 (still broken)
+
+
+%inline %{
+
+ template<typename, typename> class PatchList;
+
+%}
diff --git a/trunk/Examples/test-suite/template_extend1.i b/trunk/Examples/test-suite/template_extend1.i
new file mode 100644
index 000000000..34e4f5cec
--- /dev/null
+++ b/trunk/Examples/test-suite/template_extend1.i
@@ -0,0 +1,26 @@
+// One of Luigi's evil tests
+
+%module template_extend1
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Baz<long>; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Baz<double>; // Ruby, wrong class name
+
+%{
+namespace Quux {
+ template <class T> class Baz {};
+}
+%}
+
+namespace Quux {
+template <class T> class Baz {};
+
+%template (lBaz) Baz<long>;
+%extend Baz<long> {
+ char *foo(void) { return (char *) "lBaz::foo"; }
+}
+
+%template (dBaz) Baz<double>;
+%extend Baz<double> {
+ char *foo(void) { return (char *) "dBaz::foo"; }
+}
+}
diff --git a/trunk/Examples/test-suite/template_extend2.i b/trunk/Examples/test-suite/template_extend2.i
new file mode 100644
index 000000000..b0ac6c902
--- /dev/null
+++ b/trunk/Examples/test-suite/template_extend2.i
@@ -0,0 +1,28 @@
+// Another evil Luigi test
+%module template_extend2
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Baz<long>; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Baz<double>; // Ruby, wrong class name
+
+%{
+namespace Quux {
+template <class T> class Baz {};
+}
+%}
+
+namespace Quux {
+template <class T> class Baz {};
+
+%extend Baz<long> {
+ char *foo(void) { return (char *) "lBaz::foo"; }
+}
+%template (lBaz) Baz<long>;
+
+%extend Baz<double> {
+ char *foo(void) { return (char *) "dBaz::foo"; }
+}
+
+%template (dBaz) Baz<double>;
+}
+
+
diff --git a/trunk/Examples/test-suite/template_extend_overload.i b/trunk/Examples/test-suite/template_extend_overload.i
new file mode 100644
index 000000000..343d7f733
--- /dev/null
+++ b/trunk/Examples/test-suite/template_extend_overload.i
@@ -0,0 +1,44 @@
+%module template_extend_overload
+
+
+%inline %{
+ template <class T>
+ struct A
+ {
+ };
+
+ template <class Arg, class Res>
+ struct B
+ {
+ };
+%}
+
+
+%define __compose_unary(Class, ArgType, ResType)
+ Class<ResType> compose(const B<ArgType, ResType>& f)
+ {
+ return Class<ResType>();
+ }
+%enddef
+
+%define __compose_unary_3(Class, Type)
+%extend Class<Type>
+{
+ __compose_unary(Class, Type, bool);
+ __compose_unary(Class, Type, double);
+ __compose_unary(Class, Type, int);
+}
+%enddef
+
+%define compose_unary(Class)
+ __compose_unary_3(Class, bool)
+ __compose_unary_3(Class, double)
+ __compose_unary_3(Class, int)
+%enddef
+
+compose_unary(A);
+
+%template(A_double) A<double>;
+%template(A_int) A<int>;
+%template(A_bool) A<bool>;
+
diff --git a/trunk/Examples/test-suite/template_extend_overload_2.i b/trunk/Examples/test-suite/template_extend_overload_2.i
new file mode 100644
index 000000000..712189624
--- /dev/null
+++ b/trunk/Examples/test-suite/template_extend_overload_2.i
@@ -0,0 +1,121 @@
+%module template_extend_overload_2
+
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) A;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) AT;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) BT;
+#endif
+
+%inline %{
+
+ struct A
+ {
+ A()
+ {
+ }
+
+ A(int)
+ {
+ }
+
+ int hi()
+ {
+ return 0;
+ }
+ };
+
+ template <class T>
+ struct AT
+ {
+ AT()
+ {
+ }
+
+ AT(int)
+ {
+ }
+
+ int hi()
+ {
+ return 0;
+ }
+ };
+
+ template <class T>
+ struct BT
+ {
+ BT()
+ {
+ }
+
+ BT(int)
+ {
+ }
+
+ int hi()
+ {
+ return 0;
+ }
+ };
+
+%}
+
+
+%extend A
+{
+ //
+ // this works
+ //
+
+ int hi(int)
+ {
+ return 0;
+ }
+
+ A(double i)
+ {
+ A* a = new A();
+ return a;
+ }
+}
+
+
+%template(AT_double) AT<double>;
+%extend AT<double>
+{
+ //
+ // this doesn't work
+ //
+
+ int hi(int)
+ {
+ return 1;
+ }
+
+ AT<double>(double i)
+ {
+ AT<double>* a = new AT<double>();
+ return a;
+ }
+}
+
+
+%extend BT<double>
+{
+ //
+ // this doesn't work either
+ //
+
+ int hi(int)
+ {
+ return 1;
+ }
+
+ BT<double>(double i)
+ {
+ BT<double>* a = new BT<double>();
+ return a;
+ }
+}
+%template(BT_double) BT<double>;
+
diff --git a/trunk/Examples/test-suite/template_forward.i b/trunk/Examples/test-suite/template_forward.i
new file mode 100644
index 000000000..5a7d44c6d
--- /dev/null
+++ b/trunk/Examples/test-suite/template_forward.i
@@ -0,0 +1,71 @@
+%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>();
+ }
+}
+%}
+
+
+
+%inline {
+ // Forward declarations
+ template<class RangeScalar, class DomainScalar = RangeScalar> class LinearOpBase;
+ template<class Scalar> class VectorBase;
+}
+
+
+%inline {
+ // Class Describable
+ class Describable {
+ public:
+ void describe() {}
+ };
+
+ // Class LinearOpBase
+ template<class RangeScalar, class DomainScalar>
+ class LinearOpBase : virtual public Describable {
+ public:
+
+ }; // end class LinearOpBase<RangeScalar,DomainScalar>
+
+ // Class VectorBase
+ template<class Scalar>
+ class VectorBase : virtual public LinearOpBase<Scalar>
+ {
+ public:
+ using LinearOpBase<Scalar>::describe;
+ }; // end class VectorBase<Scalar>
+
+}
+
+
+%template (LinearOpBase_double) LinearOpBase<double>;
+%template (VectorBase_double) VectorBase<double>;
+%template (LinearOpBase_int) LinearOpBase<int,int>;
+%template (VectorBase_int) VectorBase<int>;
+
+// Template forward class declarations mixing class and typename without always naming the templated parameter name
+%inline %{
+template <class> class TClass1;
+template <typename> class TClass2;
+template <class, typename> class TClass3;
+template <class, class, class> class TClass4;
+template <typename, typename> class TClass5;
+template <typename, class K = double> class TClass6;
+template<typename, class K, class C = K> class TClass7;
+%}
+
diff --git a/trunk/Examples/test-suite/template_inherit.i b/trunk/Examples/test-suite/template_inherit.i
new file mode 100644
index 000000000..9a5c948ea
--- /dev/null
+++ b/trunk/Examples/test-suite/template_inherit.i
@@ -0,0 +1,41 @@
+/* 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 ~Foo() { }
+ 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/trunk/Examples/test-suite/template_inherit_abstract.i b/trunk/Examples/test-suite/template_inherit_abstract.i
new file mode 100644
index 000000000..2f83433a5
--- /dev/null
+++ b/trunk/Examples/test-suite/template_inherit_abstract.i
@@ -0,0 +1,67 @@
+%module(ruby_minherit="1") template_inherit_abstract
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::test; /* Ruby, wrong class name */
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, PHP 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
+ {
+ virtual ~Module() {}
+
+ 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
+ {
+#if defined(SWIG) && defined(SWIGCSHARP)
+%ignore HModule<B>::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored.
+#endif
+ struct test : HModule<B>
+ {
+ virtual int get() {return 0;} // declaration here breaks swig
+ };
+ }
+%}
diff --git a/trunk/Examples/test-suite/template_int_const.i b/trunk/Examples/test-suite/template_int_const.i
new file mode 100644
index 000000000..e69a53c4f
--- /dev/null
+++ b/trunk/Examples/test-suite/template_int_const.i
@@ -0,0 +1,50 @@
+%module template_int_const
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) interface_traits; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) module_traits; /* Ruby, wrong class name */
+
+%inline %{
+ enum Polarization { UnaryPolarization, BinaryPolarization };
+ struct interface_traits
+ {
+ static const Polarization polarization = UnaryPolarization;
+ };
+ template <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/trunk/Examples/test-suite/template_matrix.i b/trunk/Examples/test-suite/template_matrix.i
new file mode 100644
index 000000000..27696542a
--- /dev/null
+++ b/trunk/Examples/test-suite/template_matrix.i
@@ -0,0 +1,71 @@
+%module template_matrix
+%{
+#include <vector>
+
+ struct pop
+ {
+ };
+
+%}
+
+%include "std_vector.i"
+
+
+%inline {
+namespace simuPOP
+{
+ struct POP
+ {
+ };
+
+ template<class _POP1, class _POP2 = POP>
+ class Operator
+ {
+ };
+}
+
+}
+
+%template(vectorop) std::vector< simuPOP::Operator<pop> >;
+
+
+
+namespace simuPOP
+{
+ %template(baseOperator) Operator<pop>;
+}
+
+
+#if 1
+
+namespace std
+{
+%template(vectori) vector<int>;
+%template(matrixi) vector< vector<int> >;
+%template(cubei) vector< vector< vector<int> > >;
+}
+
+
+
+%inline %{
+std::vector<int>
+passVector(const std::vector<int>& a)
+{
+ return a;
+}
+
+std::vector< std::vector<int> >
+passMatrix(const std::vector< std::vector<int> >& a)
+{
+ return a;
+}
+
+std::vector< std::vector< std::vector<int> > >
+passCube(const std::vector< std::vector< std::vector<int> > >& a)
+{
+ return a;
+}
+
+%}
+
+#endif
diff --git a/trunk/Examples/test-suite/template_methods.i b/trunk/Examples/test-suite/template_methods.i
new file mode 100644
index 000000000..8524d5b44
--- /dev/null
+++ b/trunk/Examples/test-suite/template_methods.i
@@ -0,0 +1,100 @@
+// Test %ignore and %rename for templated methods
+
+%module template_methods
+
+%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve1<float>();
+%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve3<float>();
+
+%include <std_string.i>
+
+///////////////////
+%ignore convolve1<float>(float a);
+
+%inline %{
+template <typename ImageT> int convolve1() { return 0; }
+template <typename ImageT> void convolve1(ImageT a) { ImageT t = a; }
+%}
+
+%template() convolve1<float>;
+%template(convolve1Bool) convolve1<bool>;
+
+
+///////////////////
+%ignore convolve2<float>(float a);
+
+%inline %{
+template <typename ImageT> int convolve2() { return 0; }
+template <typename ImageT> void convolve2(ImageT a) { ImageT t = a; }
+%}
+
+%template(convolve2Float) convolve2<float>;
+
+///////////////////
+%rename(convolve3FloatRenamed) convolve3<float>(float a);
+
+%inline %{
+template <typename ImageT> int convolve3() { return 0; }
+template <typename ImageT> void convolve3(ImageT a) { ImageT t = a; }
+%}
+
+%template() convolve3<float>;
+
+///////////////////
+%rename(convolve4FloatRenamed) convolve4<float>(float a);
+
+%inline %{
+template <typename ImageT> int convolve4() { return 0; }
+template <typename ImageT> void convolve4(ImageT a) { ImageT t = a; }
+%}
+
+%template(convolve4Float) convolve4<float>;
+
+
+///////////////////
+%rename(convolve5FloatRenamed) convolve5<float>;
+%ignore convolve5<bool>;
+
+%inline %{
+template <typename ImageT> int convolve5() { return 0; }
+template <typename ImageT> void convolve5(ImageT a) { ImageT t = a; }
+%}
+
+%template() convolve5<float>;
+%template() convolve5<bool>;
+
+
+////////////////////////////////////////////////////////////////////////////
+%rename(KlassTMethodBoolRenamed) Klass::tmethod(bool);
+%rename(KlassStaticTMethodBoolRenamed) Klass::statictmethod(bool);
+
+%inline %{
+struct Klass {
+ template<typename X> X tmethod(X x) { return x; }
+ template<typename X> void tmethod() {}
+ template<typename X> static X statictmethod(X x) { return x; }
+ template<typename X> static void statictmethod() {}
+};
+%}
+%template(KlassTMethodBool) Klass::tmethod<bool>;
+%template(KlassStaticTMethodBool) Klass::statictmethod<bool>;
+
+////////////////////////////////////////////////////////////////////////////
+
+%inline %{
+ class ComponentProperties{
+ public:
+ ComponentProperties() {}
+ ~ComponentProperties() {}
+
+ template <typename T1> void adda(std::string key, T1 val) {}
+ template <typename T1, typename T2> void adda(std::string key1, T1 val1, std::string key2, T2 val2) {}
+ template <typename T1, typename T2, typename T3> void adda(std::string key1, T1 val1, std::string key2, T2 val2, std::string key3, T3 val3) {}
+ };
+%}
+
+%extend ComponentProperties {
+ %template(adda) adda<std::string, double>;
+ %template(adda) adda<std::string, std::string, std::string>; // ERROR OCCURS HERE
+ %template(adda) adda<int, int, int>;
+}
+
diff --git a/trunk/Examples/test-suite/template_nested.i b/trunk/Examples/test-suite/template_nested.i
new file mode 100644
index 000000000..1bb1c686a
--- /dev/null
+++ b/trunk/Examples/test-suite/template_nested.i
@@ -0,0 +1,116 @@
+%module template_nested
+
+// Test nested templates - that is template classes and template methods within a class.
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterClass::Inner1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterClass::Inner2;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate2;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate3;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedStruct;
+
+namespace ns {
+template <class T> struct ForwardTemplate;
+}
+%{
+namespace ns {
+ template <class T> struct ForwardTemplate {
+ void tmethod(T t) {}
+ };
+}
+%}
+
+%inline %{
+
+namespace ns {
+
+ class NormalClass {
+ public:
+ NormalClass() {}
+ ~NormalClass() {}
+ };
+
+ template <class T> struct NormalTemplate {
+ void tmethod(T t) {}
+ };
+
+ class OuterClass {
+ public:
+ template <class T> struct Inner1 {
+ template <class U> struct SuperInner1 {
+ void method1(U t) {}
+ };
+ template <class V> struct SuperInner2 {
+ void method1(V t) {}
+ };
+ template <class W> void tmethod(W w) {}
+ template <class X> void tmethodAgain(X x) {}
+ template <class Y> struct SuperBase : public SuperInner1<Y> {
+ void method1(Y y) {}
+ };
+ };
+ Inner1<int> useInner1(const Inner1<int>& inner) { return inner; }
+
+ template <class Z> void InnerTMethod(Z z) {}
+
+ template <class T> class Inner2 : public NormalTemplate<T> {
+ public:
+ template <class U> class SuperInner1 {
+ public:
+ SuperInner1() {}
+ void method1(U t) {}
+ };
+ template <class V> struct SuperInner2 {
+ void method1(V t) {}
+ };
+ int embeddedVar;
+ template <class X> void tmethod(X x) {}
+ template <class Y> struct SuperBase : public SuperInner1<Y> {
+ void method1(Y y) {}
+ };
+ };
+ Inner2<int> useInner2(const Inner2<int>& inner) { return inner; }
+ int iii;
+ };
+ struct ABC {
+ ABC() {}
+ ~ABC() {}
+ };
+
+ struct TemplateFuncs {
+ template <class X> X templateMethod1(X x) { return x; }
+ template <class X> X templateMethod2(X x) { return x; }
+ };
+
+ template <typename UU> struct OuterTemplate {
+ template <typename VV> struct NestedInnerTemplate1 {
+ template <typename Z> void NestedInnerInnerTMethod(Z z) {}
+ void hohum() {}
+ };
+ template <typename W> void NestedInnerTMethod(UU u, W w) {}
+ template <typename VV> struct NestedInnerTemplate2 {
+ void hohum() {}
+ };
+ UU hohum(UU u) { return u; }
+ template <typename VV> struct NestedInnerTemplate3 : public NestedInnerTemplate2<VV> {
+ void hohum() {}
+ };
+ struct NestedStruct {
+ NestedStruct() {}
+ void hohum() {}
+ };
+ NestedInnerTemplate1<short> useNestedInnerTemplate1(const NestedInnerTemplate1<short>& inner) { return inner; }
+ NestedInnerTemplate2<short> useNestedInnerTemplate2(const NestedInnerTemplate2<short>& inner) { return inner; }
+ NestedInnerTemplate3<short> useNestedInnerTemplate3(const NestedInnerTemplate3<short>& inner) { return inner; }
+ NestedStruct useNestedStruct(const NestedStruct& inner) { return inner; }
+ };
+}
+
+%}
+
+%template(T_NormalTemplateNormalClass) ns::NormalTemplate<ns::NormalClass>;
+%template(T_OuterTMethodNormalClass) ns::OuterClass::InnerTMethod<ns::NormalClass>;
+%template(T_TemplateFuncs1Int) ns::TemplateFuncs::templateMethod1<int>;
+%template(T_TemplateFuncs2Double) ns::TemplateFuncs::templateMethod2<double>;
+%template(T_NestedOuterTemplateDouble) ns::OuterTemplate<double>;
+
diff --git a/trunk/Examples/test-suite/template_nested_typemaps.i b/trunk/Examples/test-suite/template_nested_typemaps.i
new file mode 100644
index 000000000..54f5bc503
--- /dev/null
+++ b/trunk/Examples/test-suite/template_nested_typemaps.i
@@ -0,0 +1,47 @@
+#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE
+
+%module template_nested_typemaps
+
+// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
+
+template <typename T> struct Typemap {
+ %typemap(in) T {
+ $1 = -99;
+ }
+};
+template <> struct Typemap<short> { // Note explicit specialization
+ %typemap(in) short {
+ $1 = -77;
+ }
+};
+
+%inline %{
+int globalInt1(int s) { return s; }
+short globalShort1(short s) { return s; }
+
+template <typename T> struct Breeze {
+ int methodInt1(int s) { return s; }
+#if defined(SWIG)
+ %template() Typemap<int>;
+#endif
+ int methodInt2(int s) { return s; } // should pick up the typemap within Typemap<int>
+ void takeIt(T t) {}
+
+ short methodShort1(short s) { return s; }
+#if defined(SWIG)
+ %template(TypemapShort) Typemap<short>; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE
+#endif
+ short methodShort2(short s) { return s; } // should pick up the typemap within Typemap<short>
+};
+
+int globalInt2(int s) { return s; }
+short globalShort2(short s) { return s; }
+%}
+
+%template(BreezeString) Breeze<const char *>;
+
+%inline %{
+int globalInt3(int s) { return s; } // should pick up the typemap within Typemap<int>
+short globalShort3(short s) { return s; } // should pick up the typemap within Typemap<short>
+%}
+
diff --git a/trunk/Examples/test-suite/template_ns.i b/trunk/Examples/test-suite/template_ns.i
new file mode 100644
index 000000000..77dfcd194
--- /dev/null
+++ b/trunk/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(SWIGWARN_RUBY_WRONG_NAME) std::my_pair<int, int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) std::my_pair<double, double>; /* Ruby, wrong class name */
+
+%ignore std::my_pair::my_pair();
+
+%inline %{
+namespace std
+{
+template <class _T1, class _T2>
+struct my_pair {
+ typedef _T1 first_type;
+ typedef _T2 second_type;
+
+ _T1 first;
+ _T2 second;
+ my_pair() : first(_T1()), second(_T2()) {}
+ my_pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
+ template <class _U1, class _U2>
+ my_pair(const my_pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
+};
+}
+%}
+
+// Add copy constructor
+%extend std::my_pair {
+ %template(pair) my_pair<_T1,_T2>;
+};
+
+%template(pairii) std::my_pair<int,int>;
+%template(pairdd) std::my_pair<double,double>;
diff --git a/trunk/Examples/test-suite/template_ns2.i b/trunk/Examples/test-suite/template_ns2.i
new file mode 100644
index 000000000..f35d32654
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_ns3.i b/trunk/Examples/test-suite/template_ns3.i
new file mode 100644
index 000000000..8df02806d
--- /dev/null
+++ b/trunk/Examples/test-suite/template_ns3.i
@@ -0,0 +1,21 @@
+%module template_ns3
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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/trunk/Examples/test-suite/template_ns4.i b/trunk/Examples/test-suite/template_ns4.i
new file mode 100644
index 000000000..f5c134852
--- /dev/null
+++ b/trunk/Examples/test-suite/template_ns4.i
@@ -0,0 +1,77 @@
+%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 {
+ template struct Function_ <Double, Double>;
+ template struct ArithFunction <Double, Double>;
+ template class Class_ <Double, Double>;
+ }
+%}
+
+ 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/trunk/Examples/test-suite/template_ns_enum.i b/trunk/Examples/test-suite/template_ns_enum.i
new file mode 100644
index 000000000..4c73e5067
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_ns_enum2.i b/trunk/Examples/test-suite/template_ns_enum2.i
new file mode 100644
index 000000000..b646b3a4e
--- /dev/null
+++ b/trunk/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&
+ evaluate(const traits<Hola>::value_type& e) const;
+
+ };
+ const traits<Hola>::value_type&
+ B::evaluate(const traits<Hola>::value_type& e) const {
+ return e;
+ }
+ }
+
+%}
diff --git a/trunk/Examples/test-suite/template_ns_inherit.i b/trunk/Examples/test-suite/template_ns_inherit.i
new file mode 100644
index 000000000..fb336541a
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_ns_scope.i b/trunk/Examples/test-suite/template_ns_scope.i
new file mode 100644
index 000000000..928f628d2
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_opaque.i b/trunk/Examples/test-suite/template_opaque.i
new file mode 100644
index 000000000..5918fe069
--- /dev/null
+++ b/trunk/Examples/test-suite/template_opaque.i
@@ -0,0 +1,41 @@
+%module template_opaque
+%include "std_vector.i"
+
+%{
+ namespace A
+ {
+ struct OpaqueStruct
+ {
+ };
+ }
+
+ enum Hello { hi, hello };
+
+%}
+
+
+%inline {
+namespace A {
+ struct OpaqueStruct;
+ typedef struct OpaqueStruct OpaqueType;
+ typedef enum Hello Hi;
+ typedef std::vector<OpaqueType> OpaqueVectorType;
+ typedef std::vector<Hi> OpaqueVectorEnum;
+
+ void FillVector(OpaqueVectorType& v)
+ {
+ for (size_t i = 0; i < v.size(); ++i) {
+ v[i] = OpaqueStruct();
+ }
+ }
+
+ void FillVector(const OpaqueVectorEnum& v)
+ {
+ }
+}
+}
+
+#ifndef SWIGCSHARP
+// C# vector typemaps only ready for simple cases right now
+%template(OpaqueVectorType) std::vector<A::OpaqueType>;
+#endif
diff --git a/trunk/Examples/test-suite/template_partial_arg.i b/trunk/Examples/test-suite/template_partial_arg.i
new file mode 100644
index 000000000..539f76f8e
--- /dev/null
+++ b/trunk/Examples/test-suite/template_partial_arg.i
@@ -0,0 +1,21 @@
+%module template_partial_arg
+
+%inline %{
+ template <class T> class Foo {
+ public:
+ T bar() { return T(); }
+ T* baz() { return 0; }
+ };
+
+ template <class T> class Foo<T*> {
+ public:
+ T bar() { return T(); }
+ T* baz() { return 0; }
+ };
+
+ class Bar {};
+%}
+
+%template(Foo1) Foo<Bar>;
+%template(Foo2) Foo<Bar*>;
+
diff --git a/trunk/Examples/test-suite/template_partial_specialization.i b/trunk/Examples/test-suite/template_partial_specialization.i
new file mode 100644
index 000000000..8781fbbda
--- /dev/null
+++ b/trunk/Examples/test-suite/template_partial_specialization.i
@@ -0,0 +1,150 @@
+%module template_partial_specialization
+
+%inline %{
+namespace One {
+ template <typename T> struct OneParm { void a() {} };
+ template <typename T> struct OneParm<T *> { void b() {} };
+ template <typename T> struct OneParm<T &> { void c() {} };
+ template <typename T> struct OneParm<T const &> { void d() {} };
+ template <typename T> struct OneParm<T * const &> { void e() {} };
+
+ template <> struct OneParm<int> { void f() {} };
+ template <> struct OneParm<int * const &> { void g() {} };
+ template <> struct OneParm<int **> { void h() {} };
+
+ template <> struct OneParm<float> { void i() {} };
+ template <> struct OneParm<float *> { void j() {} };
+ template <> struct OneParm<float **> { void k() {} };
+ template <> struct OneParm<float ***> { void l() {} };
+}
+%}
+
+// partial specializations
+%template(A) One::OneParm<double>;
+%template(B) One::OneParm<double *>;
+%template(C) One::OneParm<double &>;
+%template(D) One::OneParm<const double &>;
+%template(E) One::OneParm<double * const &>;
+
+// explicit specializations
+%template(F) One::OneParm<int>;
+%template(G) One::OneParm<int * const &>;
+%template(H) One::OneParm<int **>;
+
+// %template scope explicit specializations
+namespace ONE {
+ %template(I) One::OneParm<float>;
+ %template(J) ::One::OneParm<float *>;
+}
+%template(K) ::One::OneParm<float **>;
+namespace One {
+ %template(L) OneParm<float ***>;
+}
+
+// %template scope partial specializations
+namespace ONE {
+ %template(BB) One::OneParm<bool *>;
+ %template(BBB) ::One::OneParm<char *>;
+}
+%template(BBBB) ::One::OneParm<short *>;
+namespace One {
+ %template(BBBBB) OneParm<long *>;
+}
+
+// non-exact match
+%template(B1) One::OneParm<unsigned int **>;
+%template(B2) One::OneParm<unsigned int ***>;
+%template(B3) One::OneParm<const unsigned int *>;
+%template(B4) One::OneParm<const unsigned int **>;
+
+
+// Two parameter specialization tests
+%inline %{
+struct Concrete {};
+namespace Two {
+ template <typename T1, typename T2> struct TwoParm { void a() {} };
+ template <typename T1, typename T2> struct TwoParm<T1 *, T2 *> { void b() {} };
+ template <typename T1, typename T2> struct TwoParm<T1 *, const T2 *> { void c() {} };
+ template <typename T1, typename T2> struct TwoParm<const T1 *, const T2 *> { void d() {} };
+ template <typename T1> struct TwoParm<T1 *, int *> { void e() {} };
+ template <typename T1> struct TwoParm<T1, int> { void f() {} };
+ template <> struct TwoParm<int *, const int *> { void g() {} };
+ template <> struct TwoParm<Concrete, Concrete *> { void h() {} };
+}
+%}
+
+namespace Two {
+ %template(A_) TwoParm<double, double>;
+ %template(B_) TwoParm<double *, double *>;
+ %template(C_) TwoParm<double *, const double *>;
+ %template(D_) TwoParm<const int *, const int *>;
+ %template(E_) TwoParm<int *, int *>;
+ %template(F_) TwoParm<int *, int>;
+ %template(G_) TwoParm<int *, const int *>;
+
+ %template(C1_) TwoParm<Concrete *, const Concrete *>;
+ %template(C2_) TwoParm<int *, const ::Concrete *>;
+}
+
+%template(C3_) Two::TwoParm<double *, const ::Concrete *>;
+%template(C4_) ::Two::TwoParm<void *, const ::Concrete *>;
+%template(B1_) ::Two::TwoParm<char *, ::Concrete *>;
+%template(E1_) Two::TwoParm<const int *, int *>;
+%template(E2_) Two::TwoParm<int **, int *>;
+%template(H_) Two::TwoParm< ::Concrete, ::Concrete * >;
+
+
+// Many template parameters
+%inline %{
+template <typename T1, typename T2, typename T3, typename T4, typename T5> struct FiveParm { void a() {} };
+template <typename T1> struct FiveParm<T1, int, int, double, short> { void b() {} };
+%}
+
+%template(FiveParm1) FiveParm<bool, int, int, double, short>;
+
+%inline %{
+template <typename T, int N = 0, int M = 0> struct ThreeParm;
+template <typename T, int N, int M> struct ThreeParm { void a1() {} };
+template <typename T> struct ThreeParm<T, 0, 0> { void a2() {} };
+template <typename T, int N> struct ThreeParm<T, N, N> { void a3() {} };
+%}
+
+%template(ThreeParmInt) ThreeParm<int, 0, 0>;
+
+#if 0
+// TODO fix:
+%inline %{
+//namespace S {
+ template<typename T> struct X { void a() {} };
+ template<typename T> struct X<T *> { void b() {} };
+// template<> struct X<int *> { void c() {} };
+//}
+%}
+
+namespace AA { // thinks X is in AA namespace
+ %template(X2) X<int *>;
+};
+#endif
+
+#if 0
+namespace Space {
+}
+template<typename T> struct Vector {
+#ifdef SWIG
+ %template() Space::VectorHelper<T>;
+#endif
+ void gook(T i) {}
+ void geeko(double d) {}
+ void geeky(int d) {}
+};
+/*
+template<typename T> struct Vector<T *> {
+};
+*/
+//}
+%}
+
+%template(VectorIntPtr) Space::Vector<int *>; // should fail as Vector is in global namespace
+// is this a regression - no fails in 1.3.40 too
+// Note problem is removed by removing empty Space namespace!!
+#endif
diff --git a/trunk/Examples/test-suite/template_partial_specialization_typedef.i b/trunk/Examples/test-suite/template_partial_specialization_typedef.i
new file mode 100644
index 000000000..6fdbf99aa
--- /dev/null
+++ b/trunk/Examples/test-suite/template_partial_specialization_typedef.i
@@ -0,0 +1,130 @@
+// This testcase is almost identical to template_partial_specialization but uses typedefs for %template
+
+%module template_partial_specialization_typedef
+
+%inline %{
+namespace TypeDef {
+ typedef double Double;
+ typedef int * IntPtr;
+ typedef double * DoublePtr;
+ typedef double & DoubleRef;
+ typedef const double & ConstDoubleRef;
+ typedef double * const & DoublePtrConstRef;
+
+ typedef int Int;
+ typedef int * const & IntPtrConstRef;
+ typedef int ** IntPtrPtr;
+ typedef float Float;
+ typedef float * FloatPtr;
+ typedef float ** FloatPtrPtr;
+ typedef float *** FloatPtrPtrPtr;
+
+ typedef bool * BoolPtr;
+ typedef char * CharPtr;
+ typedef short * ShortPtr;
+ typedef long * LongPtr;
+ typedef unsigned int ** UnsignedIntPtrPtr;
+ typedef unsigned int *** UnsignedIntPtrPtrPtr;
+ typedef const unsigned int ** ConstUnsignedIntPtr;
+ typedef const unsigned int *** ConstUnsignedIntPtrPtr;
+}
+namespace One {
+ template <typename T> struct OneParm { void a() {} };
+ template <typename T> struct OneParm<T *> { void b() {} };
+ template <typename T> struct OneParm<T &> { void c() {} };
+ template <typename T> struct OneParm<T const &> { void d() {} };
+ template <typename T> struct OneParm<T * const &> { void e() {} };
+
+ template <> struct OneParm<int> { void f() {} };
+ template <> struct OneParm<int * const &> { void g() {} };
+ template <> struct OneParm<int **> { void h() {} };
+
+ template <> struct OneParm<float> { void i() {} };
+ template <> struct OneParm<float *> { void j() {} };
+ template <> struct OneParm<float **> { void k() {} };
+ template <> struct OneParm<float ***> { void l() {} };
+}
+%}
+
+// partial specializations
+%template(A) One::OneParm<TypeDef::Double>;
+%template(B) One::OneParm<TypeDef::DoublePtr>;
+%template(C) One::OneParm<TypeDef::DoubleRef>;
+%template(D) One::OneParm<TypeDef::ConstDoubleRef>;
+%template(E) One::OneParm<TypeDef::DoublePtrConstRef>;
+
+// explicit specializations
+%template(F) One::OneParm<TypeDef::Int>;
+%template(G) One::OneParm<TypeDef::IntPtrConstRef>;
+%template(H) One::OneParm<TypeDef::IntPtrPtr>;
+
+// %template scope explicit specializations
+namespace ONE {
+ %template(I) One::OneParm<TypeDef::Float>;
+ %template(J) ::One::OneParm<TypeDef::FloatPtr>;
+}
+%template(K) ::One::OneParm<TypeDef::FloatPtrPtr>;
+namespace One {
+ %template(L) OneParm<TypeDef::FloatPtrPtrPtr>;
+}
+
+// %template scope partial specializations
+namespace ONE {
+ %template(BB) One::OneParm<TypeDef::BoolPtr>;
+ %template(BBB) ::One::OneParm<TypeDef::CharPtr>;
+}
+%template(BBBB) ::One::OneParm<TypeDef::ShortPtr>;
+namespace One {
+ %template(BBBBB) OneParm<TypeDef::LongPtr>;
+}
+
+// non-exact match
+%template(B1) One::OneParm<TypeDef::UnsignedIntPtrPtr>;
+%template(B2) One::OneParm<TypeDef::UnsignedIntPtrPtrPtr>;
+%template(B3) One::OneParm<TypeDef::ConstUnsignedIntPtr>;
+%template(B4) One::OneParm<TypeDef::ConstUnsignedIntPtrPtr>;
+
+
+// Two parameter specialization tests
+%inline %{
+struct Concrete {};
+namespace Two {
+ template <typename T1, typename T2> struct TwoParm { void a() {} };
+ template <typename T1, typename T2> struct TwoParm<T1 *, T2 *> { void b() {} };
+ template <typename T1, typename T2> struct TwoParm<T1 *, const T2 *> { void c() {} };
+ template <typename T1, typename T2> struct TwoParm<const T1 *, const T2 *> { void d() {} };
+ template <typename T1> struct TwoParm<T1 *, int *> { void e() {} };
+ template <typename T1> struct TwoParm<T1, int> { void f() {} };
+ template <> struct TwoParm<int *, const int *> { void g() {} };
+}
+%}
+
+%inline %{
+namespace TypeDef {
+ typedef const double * ConstDoublePtr;
+ typedef const int * ConstIntPtr;
+ typedef int * IntPtr;
+ typedef Concrete * ConcretePtr;
+ typedef const Concrete * ConstConcretePtr;
+ typedef void * VoidPtr;
+}
+%}
+namespace Two {
+ %template(A_) TwoParm<TypeDef::Double, TypeDef::Double>;
+ %template(B_) TwoParm<TypeDef::DoublePtr, TypeDef::DoublePtr>;
+ %template(C_) TwoParm<TypeDef::DoublePtr, TypeDef::ConstDoublePtr>;
+ %template(D_) TwoParm<TypeDef::ConstIntPtr, TypeDef::ConstIntPtr>;
+ %template(E_) TwoParm<TypeDef::IntPtr, TypeDef::IntPtr>;
+ %template(F_) TwoParm<TypeDef::IntPtr, TypeDef::Int>;
+ %template(G_) TwoParm<TypeDef::IntPtr, TypeDef::ConstIntPtr>;
+
+ %template(C1_) TwoParm<TypeDef::ConcretePtr, TypeDef::ConstConcretePtr>;
+ %template(C2_) TwoParm<TypeDef::IntPtr, TypeDef::ConstConcretePtr>;
+}
+
+%template(C3_) Two::TwoParm<TypeDef::DoublePtr, TypeDef::ConstConcretePtr>;
+%template(C4_) ::Two::TwoParm<TypeDef::VoidPtr, TypeDef::ConstConcretePtr>;
+%template(B1_) ::Two::TwoParm<TypeDef::CharPtr, TypeDef::ConcretePtr>;
+%template(E1_) Two::TwoParm<TypeDef::ConstIntPtr, TypeDef::IntPtr>;
+%template(E2_) Two::TwoParm<TypeDef::IntPtrPtr, TypeDef::IntPtr>;
+
diff --git a/trunk/Examples/test-suite/template_qualifier.i b/trunk/Examples/test-suite/template_qualifier.i
new file mode 100644
index 000000000..1c3b46fbc
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_ref_type.i b/trunk/Examples/test-suite/template_ref_type.i
new file mode 100644
index 000000000..a41d006ef
--- /dev/null
+++ b/trunk/Examples/test-suite/template_ref_type.i
@@ -0,0 +1,27 @@
+%module template_ref_type
+
+%inline %{
+class X {
+public:
+ unsigned _i;
+};
+
+template <class T> class Container {
+public:
+ Container () {}
+ bool reset () { return false ;}
+};
+
+typedef Container<X> XC;
+%}
+
+%template(XC) Container<X>;
+
+%inline %{
+class Y {
+public:
+ Y () {};
+ bool find (XC &) { return false; }
+};
+%}
+
diff --git a/trunk/Examples/test-suite/template_rename.i b/trunk/Examples/test-suite/template_rename.i
new file mode 100644
index 000000000..b34e260a0
--- /dev/null
+++ b/trunk/Examples/test-suite/template_rename.i
@@ -0,0 +1,49 @@
+%module template_rename
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Foo<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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>;
+
+
+// Testing ignore
+
+%ignore std::tvector<Flow>::tvector(size_type);
+
+%inline %{
+
+namespace std {
+
+ template<class T> class tvector {
+ public:
+ typedef size_t size_type;
+ tvector() {}
+ tvector(size_type n) { T t = T(); }
+ };
+}
+
+class Flow {
+ Flow() {}
+public:
+ Flow(double d) {}
+};
+%}
+
+%template(VectFlow) std::tvector<Flow>;
diff --git a/trunk/Examples/test-suite/template_retvalue.i b/trunk/Examples/test-suite/template_retvalue.i
new file mode 100644
index 000000000..9c15fea65
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_specialization.i b/trunk/Examples/test-suite/template_specialization.i
new file mode 100644
index 000000000..00a0cf8ce
--- /dev/null
+++ b/trunk/Examples/test-suite/template_specialization.i
@@ -0,0 +1,37 @@
+%module template_specialization
+
+%rename(not1) *::operator!() const;
+%rename(negate) *::operator-() const;
+
+%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/trunk/Examples/test-suite/template_specialization_defarg.i b/trunk/Examples/test-suite/template_specialization_defarg.i
new file mode 100644
index 000000000..2f664c6f2
--- /dev/null
+++ b/trunk/Examples/test-suite/template_specialization_defarg.i
@@ -0,0 +1,95 @@
+%module template_specialization_defarg
+
+%inline %{
+
+ template <class A, class B = double>
+ struct C
+ {
+ };
+
+
+ template <class BB>
+ struct C<int , BB>
+ {
+ int hi()
+ {
+ return 0;
+ }
+
+ C(int a)
+ {
+ }
+
+ };
+
+
+ template <class BB>
+ struct C<double , BB>
+ {
+ int hello()
+ {
+ return 0;
+ }
+
+ C(double a)
+ {
+ }
+
+ };
+
+ template <class T>
+ struct Alloc
+ {
+ };
+
+
+ template <class T, class A = double >
+ struct D
+ {
+ D(int){}
+ };
+
+
+ template <>
+ struct D<double>
+ {
+ D(){}
+ int foo() { return 0; }
+ };
+
+
+
+ template <class T, class A = Alloc<T> >
+ struct Vector
+ {
+ Vector(int){}
+ };
+
+
+ template <>
+ struct Vector<double>
+ {
+ Vector(){}
+ int foo() { return 0; }
+ };
+
+
+%}
+
+
+//
+// This works fine
+//
+%template(C_i) C<int, double>;
+
+//
+// This one fails
+//
+%template(C_dd) C<double,double>;
+%template(C_d) C<double>;
+
+%template(D_i) D<int>;
+%template(D_d) D<double>;
+
+%template(Vector_i) Vector<int>;
+%template(Vector_d) Vector<double, Alloc<double> >;
diff --git a/trunk/Examples/test-suite/template_specialization_enum.i b/trunk/Examples/test-suite/template_specialization_enum.i
new file mode 100644
index 000000000..5fc51fbe0
--- /dev/null
+++ b/trunk/Examples/test-suite/template_specialization_enum.i
@@ -0,0 +1,63 @@
+%module template_specialization_enum
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hello; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hi; /* Ruby, wrong class name */
+
+
+%inline %{
+
+ enum Hello
+ {
+ hi, hello
+ };
+
+
+ template <Hello, class A>
+ struct C
+ {
+ };
+
+
+ template <Hello, class BB>
+ struct Base
+ {
+ };
+
+
+ template <class A>
+ struct C<hello , A> : Base<hello, A>
+ {
+ int fhello()
+ {
+ return hello;
+ }
+
+ protected:
+ C()
+ {
+ }
+ };
+
+
+ template <class A>
+ struct C<hi , A> : Base<hi, A>
+ {
+ int fhi()
+ {
+ return hi;
+ }
+
+ protected:
+ C()
+ {
+ }
+ };
+
+
+%}
+
+%template(Base_dd) Base<hi, int>;
+%template(Base_ii) Base<hello, int>;
+
+%template(C_i) C<hi, int>;
+%template(C_d) C<hello, int>;
diff --git a/trunk/Examples/test-suite/template_static.i b/trunk/Examples/test-suite/template_static.i
new file mode 100644
index 000000000..bbca99490
--- /dev/null
+++ b/trunk/Examples/test-suite/template_static.i
@@ -0,0 +1,33 @@
+%module template_static
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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>;
+
+
+%inline %{
+namespace toto {
+ class Foo {
+ public:
+ template<class T>
+ static double bar(int i) {
+ return 1.0;
+ }
+
+ private:
+ int i;
+ };
+}
+%}
+
+%template(bar_double) toto::Foo::bar<double>;
diff --git a/trunk/Examples/test-suite/template_tbase_template.i b/trunk/Examples/test-suite/template_tbase_template.i
new file mode 100644
index 000000000..678a85d74
--- /dev/null
+++ b/trunk/Examples/test-suite/template_tbase_template.i
@@ -0,0 +1,49 @@
+%module template_tbase_template
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) traits<Double, Double>; /* Ruby, wrong class name */
+
+%warnfilter(SWIGWARN_PARSE_EXPLICIT_TEMPLATE);
+
+%inline %{
+ typedef double Double;
+
+
+ template <class ArgType, class ResType>
+ struct Funktion
+ {
+ char *test() { return (char *) "test"; }
+ };
+
+ template <class ArgType, class ResType>
+ struct traits
+ {
+ typedef ArgType arg_type;
+ typedef ResType res_type;
+ typedef Funktion<ArgType, double> base;
+ };
+
+ // Egad!
+ template <class AF, class AG>
+ struct Class_
+ : Funktion<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 struct Funktion <Double, Double>;
+ template struct Class_ <Double, Double>;
+%}
+
+%template(traits_dd) traits <Double, Double>;
+%template(Funktion_dd) Funktion <Double, Double>;
+%template(Class_dd) Class_ <Double, Double>;
+%template(make_Class_dd) make_Class<Double,Double>;
diff --git a/trunk/Examples/test-suite/template_template_parameters.i b/trunk/Examples/test-suite/template_template_parameters.i
new file mode 100644
index 000000000..0c3989603
--- /dev/null
+++ b/trunk/Examples/test-suite/template_template_parameters.i
@@ -0,0 +1,39 @@
+%module template_template_parameters
+
+
+%inline %{
+ namespace pfc {
+ template<typename t_item, template <typename> class t_alloc> class array_t {};
+ template<typename t_item> class alloc_fast {
+ public:
+ typedef t_item alloc_type;
+ };
+ }
+
+ template<typename t_item, typename t2> class list_impl_t {};
+
+ template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
+ class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > {
+ public:
+ t_item item;
+// typename t_alloc<t_item>::alloc_type allotype; // SWIG can't handle this yet
+ void xx() {
+ typename t_alloc<t_item>::alloc_type atype; // this type is the same as t_item type
+ atype = true;
+ }
+ };
+
+void TestInstantiations() {
+ pfc::array_t<int, pfc::alloc_fast> myArrayInt;
+ list_impl_t<int, pfc::array_t<int, pfc::alloc_fast> > myListImplInt;
+ (void) myArrayInt;
+ (void) myListImplInt;
+}
+%}
+
+%template(ListImplFastBool) list_impl_t<bool, pfc::array_t<bool, pfc::alloc_fast> >;
+%template(ListFastBool) list_t<bool, pfc::alloc_fast>;
+
+%template(ListImplFastDouble) list_impl_t<double, pfc::array_t<double, pfc::alloc_fast> >;
+%template(ListDefaultDouble) list_t<double>;
+
diff --git a/trunk/Examples/test-suite/template_type_namespace.i b/trunk/Examples/test-suite/template_type_namespace.i
new file mode 100644
index 000000000..ec94cd04d
--- /dev/null
+++ b/trunk/Examples/test-suite/template_type_namespace.i
@@ -0,0 +1,14 @@
+%module template_type_namespace
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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/trunk/Examples/test-suite/template_typedef.i b/trunk/Examples/test-suite/template_typedef.i
new file mode 100644
index 000000000..b6128e1fa
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef.i
@@ -0,0 +1,179 @@
+#ifdef SWIGPYTHON
+%module("templatereduce") template_typedef
+#else
+%module template_typedef
+#endif
+//
+// Change this to #if 1 to test the 'test'
+//
+#if 0
+
+#define reald double
+%{
+#define reald double
+%}
+
+#else
+
+%inline %{
+ typedef double reald;
+%}
+
+#endif
+
+
+%inline %{
+
+ // typedef double reald;
+
+ namespace vfncs {
+
+ struct UnaryFunctionBase
+ {
+ };
+
+ template <class ArgType, class ResType>
+ struct UnaryFunction;
+
+ template <class ArgType, class ResType>
+ struct 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;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< reald, reald >
+ {
+
+ typedef reald argument_type;
+ typedef reald result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< reald, float >
+ {
+ typedef float argument_type;
+ typedef reald result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< float, reald >
+ {
+ typedef float argument_type;
+ typedef reald result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template <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>();
+ }
+
+#ifndef SWIG
+
+ // Initialize these static class members
+
+ const char* const arith_traits< float, float >::arg_type = "float";
+ const char* const arith_traits< float, float >::res_type = "float";
+
+ const char* const arith_traits< reald, reald >::arg_type = "reald";
+ const char* const arith_traits< reald, reald >::res_type = "reald";
+
+ const char* const arith_traits< reald, float >::arg_type = "float";
+ const char* const arith_traits< reald, float >::res_type = "reald";
+
+ const char* const arith_traits< float, reald >::arg_type = "float";
+ const char* const arith_traits< float, reald >::res_type = "reald";
+
+#endif
+
+ }
+%}
+
+namespace vfncs {
+ %template(UnaryFunction_float_float) UnaryFunction<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_reald_reald) UnaryFunction<reald, reald >;
+ %template(ArithUnaryFunction_reald_reald) ArithUnaryFunction<reald, reald >;
+
+ %template() unary_func_traits<reald, reald >;
+ %template() arith_traits<reald, reald >;
+ %template(make_Identity_reald) make_Identity<reald >;
+
+ /* [beazley] Added this part */
+ %template() unary_func_traits<float,reald>;
+ %template(UnaryFunction_float_reald) UnaryFunction<float,reald>;
+ %template(ArithUnaryFunction_float_reald) ArithUnaryFunction<float,reald>;
+
+ /* */
+
+ %template() arith_traits<reald, float >;
+ %template() arith_traits<float, reald >;
+ %template() arith_traits<float, float >;
+
+ %template(make_Multiplies_float_float_reald_reald)
+ make_Multiplies<float, float, reald, reald>;
+
+ %template(make_Multiplies_float_float_float_float)
+ make_Multiplies<float, float, float, float>;
+
+ %template(make_Multiplies_reald_reald_reald_reald)
+ make_Multiplies<reald, reald, reald, reald>;
+
+}
+
+#ifdef SWIGPYTHON
+swig_type_info *SWIG_TypeQuery(const char* name);
+#endif
diff --git a/trunk/Examples/test-suite/template_typedef_cplx.i b/trunk/Examples/test-suite/template_typedef_cplx.i
new file mode 100644
index 000000000..dcf311a07
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_cplx.i
@@ -0,0 +1,178 @@
+%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>
+ struct UnaryFunction;
+
+ template <class ArgType, class ResType>
+ struct 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;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< Complex, Complex >
+ {
+
+ typedef Complex argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< Complex, double >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< double, Complex >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template <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>();
+ }
+
+#ifndef SWIG
+
+ // Initialize these static class members
+
+ const char* const arith_traits< double, double >::arg_type = "double";
+ const char* const arith_traits< double, double >::res_type = "double";
+
+ const char* const arith_traits< Complex, Complex >::arg_type = "complex";
+ const char* const arith_traits< Complex, Complex >::res_type = "complex";
+
+ const char* const arith_traits< Complex, double>::arg_type = "double";
+ const char* const arith_traits< Complex, double >::res_type = "complex";
+
+ const char* const arith_traits< double, Complex >::arg_type = "double";
+ const char* const arith_traits< double, Complex >::res_type = "complex";
+
+#endif
+
+ }
+%}
+
+namespace vfncs {
+ %template(UnaryFunction_double_double) UnaryFunction<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/trunk/Examples/test-suite/template_typedef_cplx2.h b/trunk/Examples/test-suite/template_typedef_cplx2.h
new file mode 100644
index 000000000..17d065252
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_cplx2.h
@@ -0,0 +1,175 @@
+#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>
+ struct UnaryFunction;
+
+ template <class ArgType, class ResType>
+ struct 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;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< Complex, Complex >
+ {
+
+ typedef Complex argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< Complex, double >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template<>
+ struct arith_traits< double, Complex >
+ {
+ typedef double argument_type;
+ typedef Complex result_type;
+ static const char* const arg_type;
+ static const char* const res_type;
+ };
+
+ template <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>();
+ }
+
+#ifndef SWIG
+
+// Initialize these static class members
+
+const char* const arith_traits< double, double >::arg_type = "double";
+const char* const arith_traits< double, double >::res_type = "double";
+
+const char* const arith_traits< Complex, Complex >::arg_type = "complex";
+const char* const arith_traits< Complex, Complex >::res_type = "complex";
+
+const char* const arith_traits< Complex, double >::arg_type = "double";
+const char* const arith_traits< Complex, double >::res_type = "complex";
+
+const char* const arith_traits< double, Complex >::arg_type = "double";
+const char* const arith_traits< double, Complex >::res_type = "complex";
+
+#endif
+
+} // end namespace vfncs
+
+#ifdef SWIG
+
+namespace vfncs {
+ %template(UnaryFunction_double_double) UnaryFunction<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/trunk/Examples/test-suite/template_typedef_cplx2.i b/trunk/Examples/test-suite/template_typedef_cplx2.i
new file mode 100644
index 000000000..6f99e8996
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_typedef_cplx3.i b/trunk/Examples/test-suite/template_typedef_cplx3.i
new file mode 100644
index 000000000..71fcf5e3e
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_typedef_cplx4.i b/trunk/Examples/test-suite/template_typedef_cplx4.i
new file mode 100644
index 000000000..a2457acdf
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_typedef_cplx5.i b/trunk/Examples/test-suite/template_typedef_cplx5.i
new file mode 100644
index 000000000..84b09fd78
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_cplx5.i
@@ -0,0 +1,22 @@
+%module template_typedef_cplx5
+
+%{
+#include <complex>
+%}
+
+
+%inline %{
+
+ // This typedef triggers an inifinite recursion
+ // in the next test1() nd test2() function declarations
+
+ typedef std::complex<double> complex;
+
+ struct A
+ {
+ complex test1() { complex r; return r; }
+ std::complex<double> test2() { std::complex<double> r; return r; }
+ };
+
+%}
+
diff --git a/trunk/Examples/test-suite/template_typedef_fnc.i b/trunk/Examples/test-suite/template_typedef_fnc.i
new file mode 100644
index 000000000..d0444d117
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_fnc.i
@@ -0,0 +1,14 @@
+%module template_typedef_fnc
+
+%include "std_vector.i"
+namespace std {
+ %template(IntVector) vector<int>;
+};
+
+%inline
+{
+ typedef void (*RtMidiCallback)(std::vector<int> *message);
+
+ void setCallback( RtMidiCallback callback) {
+ }
+}
diff --git a/trunk/Examples/test-suite/template_typedef_funcptr.i b/trunk/Examples/test-suite/template_typedef_funcptr.i
new file mode 100644
index 000000000..cec43e7c8
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_funcptr.i
@@ -0,0 +1,53 @@
+%module template_typedef_funcptr
+
+//Bug #1832613
+
+#if !defined(SWIGR)
+// R Swig fails on this test. Because it tries to return a nil SEXP in
+// an error
+
+%include <std_string.i>
+
+%inline %{
+
+#include <string>
+
+template<typename T> class Ptr {};
+
+class MCContract {};
+typedef Ptr<MCContract> MCContractPtr;
+%}
+
+%template() Ptr<MCContract>;
+
+%inline %{
+template <class Contract, typename ContractID, typename CallbackType>
+class ContractFactory
+{
+ public:
+ static ContractFactory<Contract,ContractID,CallbackType> &getInstance() {
+ static ContractFactory<Contract, ContractID, CallbackType> instance;
+ return instance;
+ }
+};
+/**
+ * CreateXXContractCallback is a pointer to a function taking no arguments and
+ * returning a pointer to an XXContract.
+ */
+typedef MCContractPtr (*CreateMCContractCallback)();
+%}
+
+
+//Get around it by changing this:
+%template(MCContractFactory) ContractFactory<MCContract, std::string, CreateMCContractCallback>;
+
+//to a form which expands the typedef:
+//%template(MCContractFactory) ContractFactory<MCContract, std::string, Ptr<MCContract>(*)()>;
+
+%inline %{
+typedef MCContractPtr* ContractPtrPtr;
+%}
+// Plain pointers were also causing problems...
+%template(MCContractFactory2) ContractFactory<MCContract, std::string, ContractPtrPtr>;
+
+#endif
diff --git a/trunk/Examples/test-suite/template_typedef_import.i b/trunk/Examples/test-suite/template_typedef_import.i
new file mode 100644
index 000000000..10bc61763
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/template_typedef_import.list b/trunk/Examples/test-suite/template_typedef_import.list
new file mode 100644
index 000000000..c7622b4da
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_import.list
@@ -0,0 +1,2 @@
+template_typedef_cplx2
+template_typedef_import
diff --git a/trunk/Examples/test-suite/template_typedef_ns.i b/trunk/Examples/test-suite/template_typedef_ns.i
new file mode 100644
index 000000000..a386284ab
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_ns.i
@@ -0,0 +1,18 @@
+%module("templatereduce") template_typedef_ns
+
+%inline {
+ namespace Alpha {
+ typedef int Integer;
+ }
+
+ namespace Beta {
+ template <typename Value>
+ struct Alpha {
+ Value x;
+ };
+ }
+}
+
+
+%template(AlphaInt) Beta::Alpha<Alpha::Integer>;
+
diff --git a/trunk/Examples/test-suite/template_typedef_ptr.i b/trunk/Examples/test-suite/template_typedef_ptr.i
new file mode 100644
index 000000000..9f9a29a55
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_ptr.i
@@ -0,0 +1,38 @@
+%module("templatereduce") template_typedef_ptr
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Test<int, C*>; /* Ruby, wrong constant name */
+
+ /*
+ Use the "templatereduce" feature to force swig to reduce the template
+ typedef as much as possible.
+
+ This fixes cases like this one, but it can prevent some
+ typemaps from working.
+ */
+
+%inline %{
+ struct C{};
+ typedef C* pC;
+
+ template <class A, class B>
+ struct Test
+ {
+ Test (A a, B b)
+ {
+ }
+
+ };
+
+
+ template <class A, class B>
+ struct Test<A, B*>
+ {
+ Test (B* a)
+ {
+ }
+
+ };
+%}
+
+
+%template(test_pC) Test<int, pC>;
diff --git a/trunk/Examples/test-suite/template_typedef_rec.i b/trunk/Examples/test-suite/template_typedef_rec.i
new file mode 100644
index 000000000..abdf11382
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typedef_rec.i
@@ -0,0 +1,113 @@
+%module template_typedef_rec
+
+%inline %{
+// --- includes required to compile the wrapper code ---
+typedef size_t MY_sizeT;
+typedef long MY_intT;
+typedef double MY_floatT;
+
+class test_Array
+{
+public:
+ typedef MY_intT intT;
+ typedef MY_sizeT sizeT;
+};
+
+
+
+template <typename T>
+class ArrayIterator_
+{
+ public:
+ typedef test_Array::intT intT;
+};
+
+
+template <typename T>
+class ArrayReverseIterator
+{
+ public:
+ typedef test_Array::intT intT;
+};
+
+
+template <typename T>
+class ArrayPrimitiveT
+ : public test_Array
+{
+public:
+ typedef T ValueT;
+ typedef T valueT;
+ typedef ArrayIterator_<T> Iterator;
+ typedef ArrayIterator_<const T> ConstIterator;
+ typedef ArrayReverseIterator<T> ReverseIterator;
+ typedef ArrayReverseIterator<const T> ConstReverseIterator;
+};
+
+
+template <class T>
+class TreeNode
+{
+public:
+ typedef T ValueT;
+ typedef T valueT;
+ typedef MY_intT intT;
+ typedef MY_sizeT sizeT;
+};
+
+template <class T>
+struct ArrayPointerT
+{
+};
+
+template <class T>
+class TreeIterator
+{
+public:
+ typedef MY_intT intT;
+ typedef MY_sizeT sizeT;
+ typedef ArrayPointerT< T* > NodeArrayT;
+
+};
+
+
+template <class T>
+class Tree
+{
+public:
+ typedef T ValueT;
+ typedef T valueT;
+ typedef MY_intT intT;
+ typedef MY_sizeT sizeT;
+ typedef TreeNode<T> NodeT;
+ typedef ArrayPointerT< NodeT* > NodeArrayT;
+ typedef TreeIterator<NodeT> Iterator;
+ typedef TreeIterator<NodeT> ConstIterator;
+
+
+};
+
+
+class ModelNode
+{
+ typedef MY_intT intT;
+ typedef MY_floatT floatT;
+ typedef MY_sizeT sizeT;
+
+
+};
+
+class Model
+{
+ typedef MY_intT intT;
+ typedef MY_sizeT sizeT;
+ typedef Tree<ModelNode> TreeT;
+ typedef TreeT::NodeT TreeNodeT;
+ typedef TreeT::Iterator TreeIteratorT;
+
+};
+%}
+
+
+// --- define ANSI C/C++ declarations to be interfaced ---
+%template(ModelTree) Tree<ModelNode>;
diff --git a/trunk/Examples/test-suite/template_typemaps.i b/trunk/Examples/test-suite/template_typemaps.i
new file mode 100644
index 000000000..92968e56f
--- /dev/null
+++ b/trunk/Examples/test-suite/template_typemaps.i
@@ -0,0 +1,62 @@
+%module template_typemap
+
+
+%typemap(in) Integer1
+{
+ /* do nothing */
+}
+
+%typemap(out) Integer1
+{
+ /* do nothing */
+}
+
+%typemap(in) Integer2
+{
+ /* do nothing */
+}
+
+%typemap(out) Integer2
+{
+ /* do nothing */
+}
+
+%{
+ typedef int Integer1;
+%}
+
+
+%inline %{
+ typedef int Integer2;
+
+ template <class T>
+ struct Foo
+ {
+ T val;
+
+ T get_val() const
+ {
+ return val;
+ }
+
+ void set_val(T v)
+ {
+ val = v;
+ }
+
+#ifdef SWIG
+ %typemap(in) Foo* "/* in typemap for Foo, with type T */"
+#endif
+ };
+%}
+
+%template(Foo_I1) Foo<Integer1>;
+%template(Foo_I2) Foo<Integer2>;
+
+%inline %{
+ int bar(Foo<Integer1> *foo) {
+ return 0;
+ }
+%}
+
+
diff --git a/trunk/Examples/test-suite/template_using.i b/trunk/Examples/test-suite/template_using.i
new file mode 100644
index 000000000..cb98dda10
--- /dev/null
+++ b/trunk/Examples/test-suite/template_using.i
@@ -0,0 +1,17 @@
+%module template_using
+
+%inline
+{
+
+namespace foo {
+ template<typename T> class Foo { };
+ template<typename T> T maxk(T a, T b) { return a > b ? a : b; }
+}
+using foo::maxk;
+
+}
+
+%template(maxint) foo::maxk<int>;
+%template(Foofloat) foo::Foo<float>;
+%template(maxfloat) maxk<float>;
+
diff --git a/trunk/Examples/test-suite/template_virtual.i b/trunk/Examples/test-suite/template_virtual.i
new file mode 100644
index 000000000..8c844f946
--- /dev/null
+++ b/trunk/Examples/test-suite/template_virtual.i
@@ -0,0 +1,34 @@
+%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 ~A() { }
+
+ virtual void say_hi() = 0; // only fails with pure virtual methods
+
+ virtual void say_hello() {} // this works fine
+
+ protected:
+ A() { } // defined protected as swig generates constructor by default
+ };
+
+ template <class 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/trunk/Examples/test-suite/template_whitespace.i b/trunk/Examples/test-suite/template_whitespace.i
new file mode 100644
index 000000000..f00b9e857
--- /dev/null
+++ b/trunk/Examples/test-suite/template_whitespace.i
@@ -0,0 +1,22 @@
+/* This interface file tests whether whitespace in angle brackets
+ affects the SWIG types. SF Bug #221917, reported by
+ burchanb@cs.tamu.edu. */
+
+%module template_whitespace
+
+%{
+template<class 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 bar(vector<unsigned int> v) {}
+void baz(map < int , int > p) {}
+%}
diff --git a/trunk/Examples/test-suite/testdir/subdir1/hello.i b/trunk/Examples/test-suite/testdir/subdir1/hello.i
new file mode 100644
index 000000000..75d0ec479
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/subdir1/hello.i
@@ -0,0 +1,24 @@
+#ifndef subdir1_hello_i_
+#define subdir1_hello_i_
+
+%{
+typedef int Integer;
+%}
+
+%inline %{
+
+ struct A
+ {
+ int aa;
+ };
+
+ Integer importtest1(Integer i) {
+ return i + 10;
+ }
+
+%}
+
+
+
+
+#endif //subdir1_hello_i_
diff --git a/trunk/Examples/test-suite/testdir/subdir1/imports.i b/trunk/Examples/test-suite/testdir/subdir1/imports.i
new file mode 100644
index 000000000..4c359914d
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/subdir1/imports.i
@@ -0,0 +1,6 @@
+#ifndef subdir1_imports_i_
+#define subdir1_imports_i_
+
+typedef int Integer;
+
+#endif //subdir1_imports_i_
diff --git a/trunk/Examples/test-suite/testdir/subdir1/subinc1.i b/trunk/Examples/test-suite/testdir/subdir1/subinc1.i
new file mode 100644
index 000000000..e023b4c2e
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/subdir1/subinc1.i
@@ -0,0 +1,5 @@
+// %include twice to check include header guards
+%include "hello.i"
+%include "hello.i"
+%import "imports.i"
+%import "imports.i"
diff --git a/trunk/Examples/test-suite/testdir/subdir2/hello.i b/trunk/Examples/test-suite/testdir/subdir2/hello.i
new file mode 100644
index 000000000..ed172b1fd
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/subdir2/hello.i
@@ -0,0 +1,24 @@
+#ifndef subdir2_hello_i_
+#define subdir2_hello_i_
+
+%{
+typedef char * TypedefString;
+%}
+
+
+%inline %{
+
+ struct B
+ {
+ int bb;
+ };
+
+ TypedefString importtest2(TypedefString str) {
+ strcpy(str, "white");
+ return str;
+ }
+
+%}
+
+
+#endif //subdir2_hello_i_
diff --git a/trunk/Examples/test-suite/testdir/subdir2/imports.i b/trunk/Examples/test-suite/testdir/subdir2/imports.i
new file mode 100644
index 000000000..6a5a1066c
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/subdir2/imports.i
@@ -0,0 +1,6 @@
+#ifndef subdir2_imports_i_
+#define subdir2_imports_i_
+
+typedef char * TypedefString;
+
+#endif //subdir2_imports_i_
diff --git a/trunk/Examples/test-suite/testdir/subdir2/subinc2.i b/trunk/Examples/test-suite/testdir/subdir2/subinc2.i
new file mode 100644
index 000000000..1218f41fe
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/subdir2/subinc2.i
@@ -0,0 +1,3 @@
+%include "hello.i"
+%import "imports.i"
+
diff --git a/trunk/Examples/test-suite/testdir/test.i b/trunk/Examples/test-suite/testdir/test.i
new file mode 100644
index 000000000..96a949e48
--- /dev/null
+++ b/trunk/Examples/test-suite/testdir/test.i
@@ -0,0 +1,4 @@
+
+%include "subdir1/subinc1.i"
+%include "subdir2/subinc2.i"
+
diff --git a/trunk/Examples/test-suite/threads.i b/trunk/Examples/test-suite/threads.i
new file mode 100644
index 000000000..7c6b09be0
--- /dev/null
+++ b/trunk/Examples/test-suite/threads.i
@@ -0,0 +1,23 @@
+// This test is designed for testing wrappers in the target language in a multi-threaded environment.
+// The most common cause for this test failing is incorrect compiler settings for a multi-threaded environment.
+
+%module threads
+
+%include "std_string.i"
+
+%newobject Kerfuffle::CharString;
+
+%inline %{
+ #include <string>
+ struct Kerfuffle {
+ std::string StdString(std::string str) {
+ return str;
+ }
+ char * CharString(const char *str) {
+ char * retstr = new char[256];
+ strcpy(retstr, str);
+ return retstr;
+ }
+ };
+%}
+
diff --git a/trunk/Examples/test-suite/threads_exception.i b/trunk/Examples/test-suite/threads_exception.i
new file mode 100755
index 000000000..9f275bd6a
--- /dev/null
+++ b/trunk/Examples/test-suite/threads_exception.i
@@ -0,0 +1,54 @@
+// Throw a lot of exceptions
+
+// The Python runtime tests were previously failing with the -threads option on Windows due to SWIG_PYTHON_THREAD_BEGIN_ALLOW not being within the try block.
+
+%module(threads="1") threads_exception
+
+%{
+struct A {};
+%}
+
+%inline %{
+#include <string>
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+class Exc {
+public:
+ Exc(int c, const char *m) {
+ code = c;
+ strncpy(msg,m,255);
+ }
+ int code;
+ char msg[256];
+};
+
+class Test {
+public:
+ int simple() throw(int) {
+ throw(37);
+ return 1;
+ }
+ int message() throw(const char *) {
+ throw("I died.");
+ return 1;
+ }
+ int hosed() throw(Exc) {
+ throw(Exc(42,"Hosed"));
+ return 1;
+ }
+ int unknown() throw(A*) {
+ static A a;
+ throw &a;
+ return 1;
+ }
+ int multi(int x) throw(int, const char *, Exc) {
+ if (x == 1) throw(37);
+ if (x == 2) throw("Bleah!");
+ if (x == 3) throw(Exc(42,"No-go-diggy-die"));
+ return 1;
+ }
+};
+%}
diff --git a/trunk/Examples/test-suite/throw_exception.i b/trunk/Examples/test-suite/throw_exception.i
new file mode 100644
index 000000000..c1ad945fb
--- /dev/null
+++ b/trunk/Examples/test-suite/throw_exception.i
@@ -0,0 +1,79 @@
+%module throw_exception
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1;
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum2;
+#ifdef SWIGPHP
+%warnfilter(SWIGWARN_PARSE_KEYWORD) Namespace;
+#endif
+
+// Tests SWIG's automatic exception mechanism
+
+%inline %{
+
+class Error {
+};
+
+void test_is_Error(Error *r) {}
+
+namespace Namespace {
+ typedef Error ErrorTypedef;
+ typedef const Error& ErrorRef;
+ typedef const Error* ErrorPtr;
+ typedef int IntArray[10];
+ enum EnumTest { enum1, enum2 };
+}
+class Foo {
+public:
+ void test_int() throw(int) {
+ throw 37;
+ }
+ void test_msg() throw(const char *) {
+ throw "Dead";
+ }
+ void test_cls() throw(Error) {
+ throw Error();
+ }
+ void test_cls_ptr() throw(Error *) {
+ static Error StaticError;
+ throw &StaticError;
+ }
+ void test_cls_ref() throw(Error &) {
+ static Error StaticError;
+ throw StaticError;
+ }
+ void test_cls_td() throw(Namespace::ErrorTypedef) {
+ throw Error();
+ }
+ void test_cls_ptr_td() throw(Namespace::ErrorPtr) {
+ static Error StaticError;
+ throw &StaticError;
+ }
+ void test_cls_ref_td() throw(Namespace::ErrorRef) {
+ static Error StaticError;
+ throw StaticError;
+ }
+ void test_array() throw(Namespace::IntArray) {
+ static Namespace::IntArray array;
+ for (int i=0; i<10; i++) {
+ array[i] = i;
+ }
+ throw array;
+ }
+ void test_enum() throw(Namespace::EnumTest) {
+ throw Namespace::enum2;
+ }
+ void test_multi(int x) throw(int, const char *, Error) {
+ if (x == 1) throw 37;
+ if (x == 2) throw "Dead";
+ if (x == 3) throw Error();
+ }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/traits.i b/trunk/Examples/test-suite/traits.i
new file mode 100644
index 000000000..0d25a60d9
--- /dev/null
+++ b/trunk/Examples/test-suite/traits.i
@@ -0,0 +1,6 @@
+%module traits
+
+%include typemaps/traits.swg
+
+
+%fragment("Traits");
diff --git a/trunk/Examples/test-suite/typedef_array_member.i b/trunk/Examples/test-suite/typedef_array_member.i
new file mode 100644
index 000000000..bb66efd77
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_array_member.i
@@ -0,0 +1,25 @@
+%module typedef_array_member
+%inline %{
+
+typedef char amember[20];
+
+struct Foo {
+ amember x;
+};
+
+%}
+
+
+%ignore jbuf_tag;
+%inline %{
+
+ typedef struct jbuf_tag
+ {
+ int mask;
+ } jbuf[1];
+
+ struct Ast_channel {
+ jbuf jmp[32];
+ };
+
+%}
diff --git a/trunk/Examples/test-suite/typedef_class.i b/trunk/Examples/test-suite/typedef_class.i
new file mode 100644
index 000000000..5a75305c9
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_class.i
@@ -0,0 +1,16 @@
+%module typedef_class
+
+%inline %{
+class RealA
+{
+ public:
+ int a;
+};
+
+class B
+{
+ public:
+ typedef RealA A2;
+ int testA (const A2& a) {return a.a;}
+};
+%}
diff --git a/trunk/Examples/test-suite/typedef_funcptr.i b/trunk/Examples/test-suite/typedef_funcptr.i
new file mode 100644
index 000000000..f8cdd14b3
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_funcptr.i
@@ -0,0 +1,27 @@
+// Tests typedef through function pointers
+
+%module typedef_funcptr
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) addf; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) subf; /* Ruby, wrong constant name */
+
+%{
+int addf(int x, int y) {
+ return x+y;
+}
+int subf(int x, int y) {
+ return x-y;
+}
+%}
+
+%inline %{
+typedef int Integer;
+
+extern "C"
+Integer do_op(Integer x, Integer y, Integer (*op)(Integer, Integer)) {
+ return (*op)(x,y);
+}
+%}
+
+%constant int addf(int x, int y);
+%constant Integer subf(Integer x, Integer y);
diff --git a/trunk/Examples/test-suite/typedef_inherit.i b/trunk/Examples/test-suite/typedef_inherit.i
new file mode 100644
index 000000000..48821a146
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_inherit.i
@@ -0,0 +1,49 @@
+// Inheritance through a typedef name
+%module typedef_inherit
+
+
+%inline %{
+class Foo {
+public:
+ virtual ~Foo () { }
+
+ virtual char *blah() {
+ return (char *) "Foo::blah";
+ }
+};
+
+typedef Foo FooObj;
+
+class Bar : public FooObj {
+ public:
+ virtual char *blah() {
+ return (char *) "Bar::blah";
+ };
+};
+
+char *do_blah(FooObj *f) {
+ return f->blah();
+}
+
+typedef struct spam {
+ virtual ~spam()
+ {
+ }
+
+ virtual char *blah() {
+ return (char *) "Spam::blah";
+ }
+} Spam;
+
+struct Grok : public Spam {
+ virtual ~Grok() { }
+ virtual char *blah() {
+ return (char *) "Grok::blah";
+ }
+};
+
+static char * do_blah2(Spam *s) {
+ return s->blah();
+}
+%}
+
diff --git a/trunk/Examples/test-suite/typedef_mptr.i b/trunk/Examples/test-suite/typedef_mptr.i
new file mode 100644
index 000000000..de0cde12a
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_mptr.i
@@ -0,0 +1,34 @@
+// Tests typedef through member pointers
+
+%module typedef_mptr
+
+#if defined(SWIGPYTHON) || defined(SWIGOCAML)
+
+%inline %{
+
+class Foo {
+public:
+ int add(int x, int y) {
+ return x+y;
+ }
+ int sub(int x, int y) {
+ return x-y;
+ }
+ int do_op(int x, int y, int (Foo::*op)(int, int)) {
+ return (this->*op)(x,y);
+ }
+};
+
+typedef Foo FooObj;
+typedef int Integer;
+
+Integer do_op(Foo *f, Integer x, Integer y, Integer (FooObj::*op)(Integer, Integer)) {
+ return f->do_op(x,y,op);
+}
+%}
+#endif
+
+#if defined(SWIGPYTHON) || defined(SWIGOCAML)
+%constant int (Foo::*add)(int,int) = &Foo::add;
+%constant Integer (FooObj::*sub)(Integer,Integer) = &FooObj::sub;
+#endif
diff --git a/trunk/Examples/test-suite/typedef_reference.i b/trunk/Examples/test-suite/typedef_reference.i
new file mode 100644
index 000000000..5146317a1
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/typedef_scope.i b/trunk/Examples/test-suite/typedef_scope.i
new file mode 100644
index 000000000..5c04d6c5a
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_scope.i
@@ -0,0 +1,37 @@
+// Tests some subtle issues of typedef scoping in C++
+
+%module typedef_scope
+
+%inline %{
+
+typedef char * FooType;
+class Bar {
+public:
+ typedef int FooType;
+ FooType test1(FooType n, ::FooType data) {
+ return n;
+ }
+ ::FooType test2(FooType n, ::FooType data) {
+ return data;
+ }
+};
+
+
+
+class Foo
+{
+};
+
+typedef Foo FooBar;
+
+class CBaz
+{
+public:
+ typedef FooBar Foo;
+};
+
+
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/typedef_sizet.i b/trunk/Examples/test-suite/typedef_sizet.i
new file mode 100644
index 000000000..0dc7d9e6d
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_sizet.i
@@ -0,0 +1,6 @@
+%module typedef_sizet
+
+typedef unsigned long long size_t;
+%inline %{
+size_t size(size_t x) {return x; }
+%}
diff --git a/trunk/Examples/test-suite/typedef_struct.i b/trunk/Examples/test-suite/typedef_struct.i
new file mode 100644
index 000000000..800d93b27
--- /dev/null
+++ b/trunk/Examples/test-suite/typedef_struct.i
@@ -0,0 +1,43 @@
+%module typedef_struct
+
+%inline %{
+ typedef struct {
+ int numpoints;
+ } LineObj;
+
+ typedef LineObj MultipointObj;
+
+ typedef struct {
+#ifdef SWIG
+ %immutable;
+#endif
+ char *filename;
+ int numfonts;
+#ifdef SWIG
+ %mutable;
+#endif
+ int* fonts;
+#ifndef SWIG
+ void* map;
+#endif
+ } FontSetObj;
+
+#define MS_NOOVERRIDE -1111
+
+%}
+
+
+%inline %{
+typedef struct {
+ int a;
+ int b;
+} A_t, *B_t;
+
+A_t* make_a() {
+ return (A_t*)malloc(sizeof(A_t));
+}
+
+B_t make_b() {
+ return make_a();
+}
+%}
diff --git a/trunk/Examples/test-suite/typemap_delete.i b/trunk/Examples/test-suite/typemap_delete.i
new file mode 100644
index 000000000..eb6abe73c
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_delete.i
@@ -0,0 +1,16 @@
+%module typemap_delete
+
+%typemap(in) Rect* (Rect temp) {
+ $1 = 0;
+ will_not_compile
+}
+
+%typemap(in) Rect*;
+
+%inline %{
+struct Rect
+{
+ int val;
+ Rect(int v) : val(v) {}
+};
+%}
diff --git a/trunk/Examples/test-suite/typemap_global_scope.i b/trunk/Examples/test-suite/typemap_global_scope.i
new file mode 100644
index 000000000..421ed9dd0
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_global_scope.i
@@ -0,0 +1,215 @@
+%module typemap_global_scope
+
+// Test global scope operator :: for typemaps. Previously SWIG would not use a typemap that did not specify the global scope
+// operator for a type that did have it, and vice-versa.
+
+%typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_ \"$type\""
+%typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_ \"$type\""
+%typemap(in) enum SWIGTYPE "_this_will_not_compile_enum_SWIGTYPE_ \"$type\""
+%typemap(in) const enum SWIGTYPE & "_this_will_not_compile_const_enum_SWIGTYPE_REF_ \"$type\""
+
+/////////////////////////////////////////////////////////////////////
+// Structs
+/////////////////////////////////////////////////////////////////////
+
+%typemap(in) Test1, ::Test2, Space::Test3, ::Space::Test4 "$1 = $type(); /*in typemap for $type*/"
+%typemap(in) const Test1 &, const ::Test2 &, const Space::Test3 &, const ::Space::Test4 & "/*in typemap for $type*/"
+%inline %{
+struct Test1 {};
+struct Test2 {};
+namespace Space {
+ struct Test3 {};
+ struct Test4 {};
+}
+%}
+
+%inline %{
+void test1a(Test1 t, const Test1 &tt) {}
+void test1b(::Test1 t, const ::Test1 &tt) {}
+
+void test2a(Test2 t, const Test2 &tt) {}
+void test2b(::Test2 t, const ::Test2 &tt) {}
+
+void test3a(Space::Test3 t, const Space::Test3 &tt) {}
+void test3b(::Space::Test3 t, const ::Space::Test3 &tt) {}
+namespace Space {
+ void test3c(Space::Test3 t, const Space::Test3 &tt) {}
+ void test3d(::Space::Test3 t, const ::Space::Test3 &tt) {}
+ void test3e(Test3 t, const Test3 &tt) {}
+}
+
+void test4a(Space::Test4 t, const Space::Test4 &tt) {}
+void test4b(::Space::Test4 t, const ::Space::Test4 &tt) {}
+namespace Space {
+ void test4c(Space::Test4 t, const Space::Test4 &tt) {}
+ void test4d(::Space::Test4 t, const ::Space::Test4 &tt) {}
+ void test4e(Test4 t, const Test4 &tt) {}
+}
+%}
+
+/////////////////////////////////////////////////////////////////////
+// Templates
+/////////////////////////////////////////////////////////////////////
+
+%inline %{
+struct XX {};
+%}
+
+%typemap(in) TemplateTest1< ::XX >, ::TemplateTest2< ::XX >, Space::TemplateTest3< ::XX >, ::Space::TemplateTest4< ::XX > "$1 = $type(); /* in typemap for $type */"
+%typemap(in) const TemplateTest1< XX > &, const ::TemplateTest2< XX > &, const Space::TemplateTest3< XX > &, const ::Space::TemplateTest4< XX > & "/* in typemap for $type */"
+%inline %{
+template<typename T> struct TemplateTest1 { T m_t; };
+template<typename T> struct TemplateTest2 { T m_t; };
+namespace Space {
+ template<typename T> struct TemplateTest3 { T m_t; };
+ template<typename T> struct TemplateTest4 { T m_t; };
+}
+%}
+
+%template(TemplateTest1XX) TemplateTest1< ::XX >;
+%template(TemplateTest2XX) TemplateTest2< ::XX >;
+%template(TemplateTest3XX) Space::TemplateTest3< ::XX >;
+%template(TemplateTest4XX) Space::TemplateTest4< ::XX >;
+
+%inline %{
+void test_template_1a(TemplateTest1< ::XX > t, const TemplateTest1< ::XX > &tt) {}
+void test_template_1b(::TemplateTest1< ::XX > t, const ::TemplateTest1< ::XX > &tt) {}
+
+void test_template_2a(TemplateTest2< ::XX > t, const TemplateTest2< ::XX > &tt) {}
+void test_template_2b(::TemplateTest2< ::XX > t, const ::TemplateTest2< ::XX > &tt) {}
+
+void test_template_3a(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {}
+void test_template_3b(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {}
+namespace Space {
+ void test_template_3c(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {}
+ void test_template_3d(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {}
+ void test_template_3e(TemplateTest3< ::XX > t, const TemplateTest3< ::XX > &tt) {}
+}
+
+void test_template_4a(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {}
+void test_template_4b(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {}
+namespace Space {
+ void test_template_4c(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {}
+ void test_template_4d(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {}
+ void test_template_4e(TemplateTest4< ::XX > t, const TemplateTest4< ::XX > &tt) {}
+}
+%}
+
+/////////////////////////////////////////////////////////////////////
+// Enums
+/////////////////////////////////////////////////////////////////////
+
+%typemap(in) Enum1, ::Enum2, Space::Enum3, ::Space::Enum4 "$1 = $1_type(); /*in typemap for $type*/"
+%typemap(in) const Enum1 &, const ::Enum2 &, const Space::Enum3 &, const ::Space::Enum4 & "/*in typemap for $type*/"
+%inline %{
+enum Enum1 { enum_1 };
+enum Enum2 { enum_2 };
+namespace Space {
+ enum Enum3 { enum_3 };
+ enum Enum4 { enum_4 };
+}
+%}
+
+%inline %{
+void test_enum_1a(Enum1 t, const Enum1 &tt) {}
+void test_enum_1b(::Enum1 t, const ::Enum1 &tt) {}
+
+void test_enum_2a(Enum2 t, const Enum2 &tt) {}
+void test_enum_2b(::Enum2 t, const ::Enum2 &tt) {}
+
+void test_enum_3a(Space::Enum3 t, const Space::Enum3 &tt) {}
+void test_enum_3b(::Space::Enum3 t, const ::Space::Enum3 &tt) {}
+namespace Space {
+ void test_enum_3c(Space::Enum3 t, const Space::Enum3 &tt) {}
+ void test_enum_3d(::Space::Enum3 t, const ::Space::Enum3 &tt) {}
+ void test_enum_3e(Enum3 t, const Enum3 &tt) {}
+}
+
+void test_enum_4a(Space::Enum4 t, const Space::Enum4 &tt) {}
+void test_enum_4b(::Space::Enum4 t, const ::Space::Enum4 &tt) {}
+namespace Space {
+ void test_enum_4c(Space::Enum4 t, const Space::Enum4 &tt) {}
+ void test_enum_4d(::Space::Enum4 t, const ::Space::Enum4 &tt) {}
+ void test_enum_4e(Enum4 t, const Enum4 &tt) {}
+}
+%}
+
+#if 0
+/////////////////////////////////////////////////////////////////////
+// Enums with enum specified in typemap
+/////////////////////////////////////////////////////////////////////
+
+%typemap(in) enum Mune1, enum ::Mune2, enum Space::Mune3, enum ::Space::Mune4 "/*in typemap for $type*/"
+%typemap(in) const enum Mune1 &, const enum ::Mune2 &, const enum Space::Mune3 &, const enum ::Space::Mune4 & "/*in typemap for $type*/"
+%inline %{
+enum Mune1 { mune_1 };
+enum Mune2 { mune_2 };
+namespace Space {
+ enum Mune3 { mune_3 };
+ enum Mune4 { mune_4 };
+}
+%}
+
+%inline %{
+void test_mune_1a(Mune1 t, const Mune1 &tt) {}
+void test_mune_1b(::Mune1 t, const ::Mune1 &tt) {}
+
+void test_mune_2a(Mune2 t, const Mune2 &tt) {}
+void test_mune_2b(::Mune2 t, const ::Mune2 &tt) {}
+
+void test_mune_3a(Space::Mune3 t, const Space::Mune3 &tt) {}
+void test_mune_3b(::Space::Mune3 t, const ::Space::Mune3 &tt) {}
+namespace Space {
+ void test_mune_3c(Space::Mune3 t, const Space::Mune3 &tt) {}
+ void test_mune_3d(::Space::Mune3 t, const ::Space::Mune3 &tt) {}
+ void test_mune_3e(Mune3 t, const Mune3 &tt) {}
+}
+
+void test_mune_4a(Space::Mune4 t, const Space::Mune4 &tt) {}
+void test_mune_4b(::Space::Mune4 t, const ::Space::Mune4 &tt) {}
+namespace Space {
+ void test_mune_4c(Space::Mune4 t, const Space::Mune4 &tt) {}
+ void test_mune_4d(::Space::Mune4 t, const ::Space::Mune4 &tt) {}
+ void test_mune_4e(Mune4 t, const Mune4 &tt) {}
+}
+%}
+
+/////////////////////////////////////////////////////////////////////
+// Enums with enum specified in type
+/////////////////////////////////////////////////////////////////////
+
+%typemap(in) Nemu1, ::Nemu2, Space::Nemu3, ::Space::Nemu4 "/*in typemap for $type*/"
+%typemap(in) const Nemu1 &, const ::Nemu2 &, const Space::Nemu3 &, const ::Space::Nemu4 & "/*in typemap for $type*/"
+%inline %{
+enum Nemu1 { nemu_1 };
+enum Nemu2 { nemu_2 };
+namespace Space {
+ enum Nemu3 { nemu_3 };
+ enum Nemu4 { nemu_4 };
+}
+%}
+
+%inline %{
+void test_nemu_1a(enum Nemu1 t, const enum Nemu1 &tt) {}
+void test_nemu_1b(enum ::Nemu1 t, const enum ::Nemu1 &tt) {}
+
+void test_nemu_2a(enum Nemu2 t, const enum Nemu2 &tt) {}
+void test_nemu_2b(enum ::Nemu2 t, const enum ::Nemu2 &tt) {}
+
+void test_nemu_3a(enum Space::Nemu3 t, const enum Space::Nemu3 &tt) {}
+void test_nemu_3b(enum ::Space::Nemu3 t, const enum ::Space::Nemu3 &tt) {}
+namespace Space {
+ void test_nemu_3c(enum Space::Nemu3 t, const enum Space::Nemu3 &tt) {}
+ void test_nemu_3d(enum ::Space::Nemu3 t, const enum ::Space::Nemu3 &tt) {}
+ void test_nemu_3e(enum Nemu3 t, const enum Nemu3 &tt) {}
+}
+
+void test_nemu_4a(enum Space::Nemu4 t, const enum Space::Nemu4 &tt) {}
+void test_nemu_4b(enum ::Space::Nemu4 t, const enum ::Space::Nemu4 &tt) {}
+namespace Space {
+ void test_nemu_4c(enum Space::Nemu4 t, const enum Space::Nemu4 &tt) {}
+ void test_nemu_4d(enum ::Space::Nemu4 t, const enum ::Space::Nemu4 &tt) {}
+ void test_nemu_4e(enum Nemu4 t, const enum Nemu4 &tt) {}
+}
+%}
+#endif
diff --git a/trunk/Examples/test-suite/typemap_namespace.i b/trunk/Examples/test-suite/typemap_namespace.i
new file mode 100644
index 000000000..b3fa1a733
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_namespace.i
@@ -0,0 +1,49 @@
+%module typemap_namespace
+
+/* Secret typedefs */
+%{
+namespace Foo {
+ typedef char Str1;
+ typedef char Str2;
+}
+%}
+
+namespace Foo {
+ struct Str1;
+ struct Str2;
+
+#ifdef SWIGCSHARP
+ %typemap(ctype) Str1 * = char *;
+ %typemap(imtype) Str1 * = char *;
+ %typemap(cstype) Str1 * = char *;
+ %typemap(csin) Str1 * = char *;
+ %typemap(csout) Str1 * = char *;
+#endif
+#ifdef SWIGJAVA
+ %typemap(jni) Str1 * = char *;
+ %typemap(jtype) Str1 * = char *;
+ %typemap(jstype) Str1 * = char *;
+ %typemap(javain) Str1 * = char *;
+ %typemap(javaout) Str1 * = char *;
+#endif
+ %typemap(in) Str1 * = char *;
+#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML))
+ %typemap(freearg) Str1 * = char *;
+#endif
+ %typemap(typecheck) Str1 * = char *;
+ %apply char * { Str2 * };
+}
+
+%inline %{
+namespace Foo {
+ char *test1(Str1 *s) {
+ return s;
+ }
+ char *test2(Str2 *s) {
+ return s;
+ }
+}
+%}
+
+
+
diff --git a/trunk/Examples/test-suite/typemap_ns_using.i b/trunk/Examples/test-suite/typemap_ns_using.i
new file mode 100644
index 000000000..72f5c1981
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_ns_using.i
@@ -0,0 +1,21 @@
+%module typemap_ns_using
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) X::_FooImpl; /* Ruby, wrong class name */
+
+%inline %{
+namespace X {
+ typedef int Integer;
+
+ class _FooImpl {
+ public:
+ typedef Integer value_type;
+ };
+ typedef _FooImpl Foo;
+}
+
+using X::Foo;
+
+int spam(Foo::value_type x) { return x; }
+
+%}
+
diff --git a/trunk/Examples/test-suite/typemap_numinputs.i b/trunk/Examples/test-suite/typemap_numinputs.i
new file mode 100644
index 000000000..24e8f3ae0
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_numinputs.i
@@ -0,0 +1,37 @@
+%module typemap_numinputs
+
+
+%typemap(in, numinputs=1) (char *STR, int LEN)(int temp = 0)
+{
+ temp = 1;
+ $2 = 0;
+ $1 = 0;
+}
+
+%typemap(in) (int *OUTPUT) (int temp = 0)
+{
+ temp = 2;
+ $1 = &temp;
+}
+
+%typemap(argout) (int *OUTPUT)
+{
+ ++temp$argnum;
+}
+
+%typemap(argout, numinputs=1) (char *STR, int LEN)
+{
+ ++temp$argnum;
+}
+
+%typemap(in) int hello
+{
+ $1 = 0;
+}
+
+%inline %{
+ int this_breaks(int hello, char *STR, int LEN, int *OUTPUT)
+ {
+ return LEN;
+ }
+%}
diff --git a/trunk/Examples/test-suite/typemap_out_optimal.i b/trunk/Examples/test-suite/typemap_out_optimal.i
new file mode 100644
index 000000000..23cd2ad3f
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_out_optimal.i
@@ -0,0 +1,38 @@
+// Test the optimal attribute in the out typemap
+%module typemap_out_optimal
+
+// Just the following languages tested
+#if defined (SWIGCSHARP)
+%typemap(out, optimal="1") SWIGTYPE %{
+ $result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGJAVA)
+%typemap(out, optimal="1") SWIGTYPE %{
+ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGUTL)
+%typemap(out,noblock="1", optimal="1") SWIGTYPE {
+ %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
+}
+#endif
+
+%ignore XX::operator=;
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+struct XX {
+ XX() { if (debug) cout << "XX()" << endl; }
+ XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; }
+ XX(const XX &other) { if (debug) cout << "XX(const XX &)" << endl; }
+ XX& operator =(const XX &other) { if (debug) cout << "operator=(const XX &)" << endl; return *this; }
+ ~XX() { if (debug) cout << "~XX()" << endl; }
+ static XX create() {
+ return XX(123);
+ }
+ static bool debug;
+};
+bool XX::debug = true;
+%}
+
diff --git a/trunk/Examples/test-suite/typemap_qualifier_strip.i b/trunk/Examples/test-suite/typemap_qualifier_strip.i
new file mode 100644
index 000000000..d91a7b109
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_qualifier_strip.i
@@ -0,0 +1,76 @@
+%module typemap_qualifier_strip
+
+%typemap(in) int *ptr {
+ int temp = 1234;
+ $1 = &temp;
+}
+
+%typemap(in) int *const ptrConst {
+ int temp = 5678;
+ $1 = &temp;
+}
+
+%typemap(in) int const* constPtr {
+ int temp = 3456;
+ $1 = &temp;
+}
+
+%inline %{
+int *create_int(int newval) {
+ static int val = 0;
+ val = newval;
+ return &val;
+}
+int testA1(int const*const ptr) {
+ return *ptr;
+}
+int testA2(int const* ptr) {
+ return *ptr;
+}
+int testA3(int *const ptr) {
+ return *ptr;
+}
+int testA4(int * ptr) {
+ return *ptr;
+}
+
+int testB1(int const*const p) {
+ return *p;
+}
+int testB2(int const* p) {
+ return *p;
+}
+int testB3(int *const p) {
+ return *p;
+}
+int testB4(int * p) {
+ return *p;
+}
+
+int testC1(int const*const ptrConst) {
+ return *ptrConst;
+}
+int testC2(int const* ptrConst) {
+ return *ptrConst;
+}
+int testC3(int *const ptrConst) {
+ return *ptrConst;
+}
+int testC4(int * ptrConst) {
+ return *ptrConst;
+}
+
+int testD1(int const*const constPtr) {
+ return *constPtr;
+}
+int testD2(int const* constPtr) {
+ return *constPtr;
+}
+int testD3(int *const constPtr) {
+ return *constPtr;
+}
+int testD4(int * constPtr) {
+ return *constPtr;
+}
+%}
+
diff --git a/trunk/Examples/test-suite/typemap_self.i b/trunk/Examples/test-suite/typemap_self.i
new file mode 100644
index 000000000..3630688c6
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_self.i
@@ -0,0 +1,47 @@
+%module typemap_self
+
+// This typemap should be ignored for self?
+%typemap(in) A* (A* ptr) {
+ if (SWIG_ConvertPtr($input, (void**) &ptr, $1_descriptor, 0) != -1) {
+ $1 = ptr;
+ } else {
+ $1 = new A();
+ }
+ }
+
+// Simple but unsecure current fix
+//%apply SWIGTYPE* {A* self}
+
+
+%inline %{
+ class A;
+
+ int foo(A* self)
+ {
+ return 0;
+ }
+
+ struct A
+ {
+ static int bar(int, A* self)
+ {
+ return 1;
+ }
+
+ int val;
+
+
+ int foo(A* self, A* b)
+ {
+ return 1;
+ }
+ };
+
+ struct B
+ {
+ B(A*)
+ {
+ }
+ };
+
+%}
diff --git a/trunk/Examples/test-suite/typemap_subst.i b/trunk/Examples/test-suite/typemap_subst.i
new file mode 100644
index 000000000..d5a8416db
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_subst.i
@@ -0,0 +1,73 @@
+/* This interface file tests for type-related typemap substitutions.
+ */
+
+%module typemap_subst
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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;
+ (void)a;
+ (void)b;
+ (void)c;
+ (void)d;
+ (void)e;
+ }
+ { /* Test locals */
+ basetemp.member = 0;
+ startemp = &basetemp;
+ temp = &startemp;
+ amptemp = &temp;
+ }
+ { /* Test descriptors */
+ void *desc = $descriptor;
+ void *stardesc = $*descriptor;
+ void *ampdesc = $&descriptor;
+ (void)desc;
+ (void)stardesc;
+ (void)ampdesc;
+ }
+ { /* Test mangled names */
+ void *desc = SWIGTYPE$mangle;
+ void *stardesc = SWIGTYPE$*mangle;
+ void *ampdesc = SWIGTYPE$&mangle;
+ (void)desc;
+ (void)stardesc;
+ (void)ampdesc;
+ }
+ { /* Test descriptor macro */
+ void *desc = $descriptor(const struct xyzzy **);
+ void *stardesc = $descriptor(const struct xyzzy *);
+ void *ampdesc = $descriptor(const struct xyzzy ***);
+ (void)desc;
+ (void)stardesc;
+ (void)ampdesc;
+ }
+ $1 = ($ltype) temp;
+}
+
+/* Java and C# modules don't use SWIG's runtime type system */
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
+%inline %{
+ void foo(const struct xyzzy **TEST) {}
+%}
+#endif
+
+
+
+
diff --git a/trunk/Examples/test-suite/typemap_template.i b/trunk/Examples/test-suite/typemap_template.i
new file mode 100644
index 000000000..ad35371cc
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_template.i
@@ -0,0 +1,34 @@
+%module typemap_template
+
+/* Test bug in 1.3.40 where the presence of a generic/unspecialized typemap caused the incorrect specialized typemap to be used */
+
+%typemap(in) SWIGTYPE "/*_this_will_not_compile_SWIGTYPE_ \"$type\" */ "
+%typemap(in) const SWIGTYPE & "/*_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" */ "
+
+%typemap(in) const TemplateTest1 & {$1 = (TemplateTest1<YY> *)0; /* in typemap generic for $type */}
+%typemap(in) const TemplateTest1< ZZ > & {$1 = (TemplateTest1<ZZ> *)0; /* in typemap ZZ for $type */}
+%typemap(in) const TemplateTest1< int > & {$1 = (TemplateTest1<int> *)0; /* in typemap int for $type */}
+
+%inline %{
+template<typename T> struct TemplateTest1 {
+ void setT(const TemplateTest1& t) {}
+};
+%}
+
+%inline %{
+ struct YY {};
+ struct ZZ {};
+%}
+
+
+%template(TTYY) TemplateTest1< YY >;
+%template(TTZZ) TemplateTest1< ZZ >;
+%template(TTint) TemplateTest1< int >;
+
+%inline %{
+ void extratest(const TemplateTest1< YY > &t,
+ const TemplateTest1< ZZ > &tt,
+ const TemplateTest1< int > &ttt)
+ {}
+%}
+
diff --git a/trunk/Examples/test-suite/typemap_variables.i b/trunk/Examples/test-suite/typemap_variables.i
new file mode 100644
index 000000000..142e35060
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_variables.i
@@ -0,0 +1,69 @@
+%module typemap_variables
+
+// Check typemap name matching rules for variables
+// Some of these are using qualified names, which is not right... the test will be adjusted as these get fixed
+
+#if defined(SWIGUTL)
+%{
+#define TYPEMAP_VARIABLES_FAIL SWIG_fail;
+%}
+#else
+%{
+#define TYPEMAP_VARIABLES_FAIL
+%}
+#endif
+
+// Scripting languages use varin/varout for variables (except non-static member variables where in/out are used ???)
+%typemap(varin) int "this_will_not_compile_varin "
+%typemap(varout) int "this_will_not_compile_varout"
+%typemap(varin) int globul "/*int globul varin */ TYPEMAP_VARIABLES_FAIL"
+%typemap(varout) int globul "/*int globul varout*/ $result=0;"
+%typemap(varin) int Space::nspace "/*int nspace varin */ TYPEMAP_VARIABLES_FAIL"
+%typemap(varout) int Space::nspace "/*int nspace varout*/ $result=0;"
+//%typemap(varin) int member "/*int member varin */"
+//%typemap(varout) int member "/*int member varout*/ $result=0;"
+%typemap(varin) int Space::Struct::smember "/*int smember varin */ TYPEMAP_VARIABLES_FAIL"
+%typemap(varout) int Space::Struct::smember "/*int smember varout*/ $result=0;"
+
+// Statically typed languages use in/out for variables
+%typemap(in) int "this_will_not_compile_in "
+%typemap(out) int "this_will_not_compile_out"
+%typemap(in) int globul "/*int globul in */ $1=0;"
+%typemap(out) int globul "/*int globul out*/ $result=0;"
+%typemap(in) int Space::nspace "/*int nspace in */ $1=0;"
+%typemap(out) int Space::nspace "/*int nspace out*/ $result=0;"
+%typemap(in) int member "/*int member in */ $1=0;"
+#ifdef SWIGTCL
+%typemap(out) int member "/*int member out*/"
+#else
+%typemap(out) int member "/*int member out*/ $result=0;"
+#endif
+%typemap(in) int Space::Struct::smember "/*int smember in */ $1=0;"
+%typemap(out) int Space::Struct::smember "/*int smember out*/ $result=0;"
+
+%typemap(javain) int "this_will_not_compile_javain "
+%typemap(javaout) int "this_will_not_compile_javaout"
+%typemap(javain) int globul "/*int globul in */ $javainput"
+%typemap(javaout) int globul "/*int globul out*/ { return $jnicall; }"
+%typemap(javain) int Space::nspace "/*int nspace in */ $javainput"
+%typemap(javaout) int Space::nspace "/*int nspace out*/ { return $jnicall; }"
+%typemap(javain) int member "/*int member in */ $javainput"
+%typemap(javaout) int member "/*int member out*/ { return $jnicall; }"
+%typemap(javain) int Space::Struct::smember "/*int smember in */ $javainput"
+%typemap(javaout) int Space::Struct::smember "/*int smember out*/ { return $jnicall; }"
+
+%inline %{
+
+int globul;
+
+namespace Space {
+ int nspace;
+ struct Struct {
+ int member;
+ static int smember;
+// static short memberfunction() { return 0; } //javaout and jstype typemaps don't use fully qualified name, but other typemaps do
+ };
+ int Struct::smember = 0;
+}
+%}
+
diff --git a/trunk/Examples/test-suite/typemap_various.i b/trunk/Examples/test-suite/typemap_various.i
new file mode 100644
index 000000000..0b7035ecf
--- /dev/null
+++ b/trunk/Examples/test-suite/typemap_various.i
@@ -0,0 +1,57 @@
+%module typemap_various
+
+// %copyctor need to be disables since 'const SWIGTYPE &' is intended to generate errors
+%nocopyctor;
+
+%typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_"
+%typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_"
+
+%inline %{
+template <class T> struct Foo {
+ Foo() {}
+#ifdef SWIG
+ // These typemaps should be used by foo1 and foo2
+ %typemap(in) Foo<T> "/*in typemap for Foo<T> */"
+ %typemap(in) const Foo & "/*in typemap for const Foo&, with type T*/"
+#endif
+};
+%}
+
+%template(FooInt) Foo<int>;
+%template() Foo<short>; // previously Foo<short> typemaps were being picked up for Python only
+
+%inline %{
+void foo1(Foo<int> f, const Foo<int>& ff) {}
+void foo2(Foo<short> f, const Foo<short>& ff) {}
+%}
+
+#ifdef SWIGUTL
+%typemap(ret) int Bar1::foo() { /* hello1 */ };
+%typemap(ret) int Bar2::foo() { /* hello2 */ };
+%typemap(ret) int foo() {/* hello3 */ };
+#endif
+
+%inline %{
+ struct Bar1 {
+ int foo() { return 1;}
+ };
+
+ struct Bar2 {
+ int foo() { return 1;}
+ };
+%}
+
+
+
+%newobject FFoo::Bar(bool) const ;
+%typemap(newfree) char* Bar(bool) {
+ /* hello */ delete[] result;
+}
+
+%inline {
+ class FFoo {
+ public:
+ char * Bar(bool b) const { return (char *)"x"; }
+ };
+}
+
diff --git a/trunk/Examples/test-suite/typename.i b/trunk/Examples/test-suite/typename.i
new file mode 100644
index 000000000..4253e0846
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/types_directive.i b/trunk/Examples/test-suite/types_directive.i
new file mode 100644
index 000000000..26cb6aeeb
--- /dev/null
+++ b/trunk/Examples/test-suite/types_directive.i
@@ -0,0 +1,54 @@
+%module types_directive
+
+#if defined(SWIGR)
+// Avoid conflict with Date class in R
+#define Date DateSwig
+%inline %{
+#define Date DateSwig
+%}
+#endif
+
+%ignore Time2::operator Date *;
+
+%inline %{
+struct Date {
+ Date(unsigned int year, unsigned int month, unsigned int day) : year(year), month(month), day(day) {}
+ unsigned int year;
+ unsigned int month;
+ unsigned int day;
+};
+
+struct Time1 {
+ Time1(unsigned int year, unsigned int month, unsigned int day, unsigned int seconds) : date(year, month, day), seconds(seconds) {}
+ Date &dateFromTime() {
+ return date;
+ }
+ Date date;
+ unsigned int seconds;
+};
+
+struct Time2 {
+ Time2(unsigned int year, unsigned int month, unsigned int day, unsigned int seconds) : date(year, month, day), seconds(seconds) {}
+ operator Date *() {
+ return &date;
+ }
+ Date date;
+ unsigned int seconds;
+};
+Date add(const Date &date, unsigned int days) {
+ Date newDate = date;
+ newDate.day += days;
+ return newDate;
+}
+%}
+
+// allow conversion from Date -> Time1 using the following code
+%types(Time1 = Date) %{
+ Time1 *t = (Time1 *)$from;
+ Date &d = t->dateFromTime();
+ return (void *) &d;
+%}
+
+// allow conversion from Date -> Time2 using conversion operator (cast) in Time2
+%types(Time2 = Date);
+
diff --git a/trunk/Examples/test-suite/uffi/Makefile.in b/trunk/Examples/test-suite/uffi/Makefile.in
new file mode 100644
index 000000000..d6b948b5d
--- /dev/null
+++ b/trunk/Examples/test-suite/uffi/Makefile.in
@@ -0,0 +1,51 @@
+#######################################################################
+# Makefile for uffi test-suite
+#######################################################################
+
+LANGUAGE = uffi
+UFFI = @UFFIBIN@
+SCRIPTSUFFIX = _runme.lisp
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+# no C++ tests for now
+CPP_TEST_CASES =
+#C_TEST_CASES +=
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.lisp appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: (does nothing, we dont generate extra uffi code)
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile uffi_clean
+
diff --git a/trunk/Examples/test-suite/union_parameter.i b/trunk/Examples/test-suite/union_parameter.i
new file mode 100644
index 000000000..bb010d3fa
--- /dev/null
+++ b/trunk/Examples/test-suite/union_parameter.i
@@ -0,0 +1,41 @@
+%module union_parameter
+
+%inline %{
+
+typedef unsigned char Uint8;
+
+typedef struct SDL_ActiveEvent {
+ Uint8 type; /* SDL_ACTIVEEVENT */
+ Uint8 gain; /* Whether given states were gained or lost (1/0) */
+ Uint8 state; /* A mask of the focus states */
+} SDL_ActiveEvent;
+
+/* Keyboard event structure */
+typedef struct SDL_KeyboardEvent {
+ Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
+ int which; /* The keyboard device index */
+ int state; /* SDL_PRESSED or SDL_RELEASED */
+} SDL_KeyboardEvent;
+
+typedef union {
+ Uint8 type;
+ SDL_ActiveEvent active;
+ SDL_KeyboardEvent key;
+} SDL_Event;
+
+int SDL_PollEvent (SDL_Event *ev) {
+ static int toggle = 0;
+ if (toggle == 0) {
+ ev->type = 1;
+ ev->active.gain = 20;
+ ev->active.state = 30;
+ } else {
+ ev->type = 2;
+ ev->key.which = 2000;
+ ev->key.state = 3000;
+ }
+ toggle = 1 - toggle;
+ return 1;
+}
+
+%}
diff --git a/trunk/Examples/test-suite/union_scope.i b/trunk/Examples/test-suite/union_scope.i
new file mode 100644
index 000000000..b7307cb29
--- /dev/null
+++ b/trunk/Examples/test-suite/union_scope.i
@@ -0,0 +1,14 @@
+%module union_scope
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState; // Ruby, wrong class name
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState_rstate; // Ruby, wrong class name
+#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
+
+%inline %{
+class nRState {
+public:
+ union {
+ int i;
+ } rstate;
+};
+%}
diff --git a/trunk/Examples/test-suite/unions.i b/trunk/Examples/test-suite/unions.i
new file mode 100644
index 000000000..49bb85de4
--- /dev/null
+++ b/trunk/Examples/test-suite/unions.i
@@ -0,0 +1,42 @@
+/*
+This testcase checks that unions can be set and read.
+*/
+
+%module unions
+
+%{
+/* Must undefine small to work on Windows. small is defined as a
+char in rpcndr.h */
+#ifdef small
+#undef small
+#endif
+%}
+
+%inline %{
+
+typedef struct SmallStruct {
+ short jill;
+} SmallStruct;
+
+typedef struct BigStruct {
+ int jack;
+ SmallStruct smallstruct;
+} BigStruct;
+
+/* This union is just to check the parser */
+typedef union {
+ BigStruct bs;
+ SmallStruct ss;
+} UnionTest;
+
+/* This union checks the parser and will be used in a runtime test */
+typedef struct {
+ union
+ {
+ BigStruct big;
+ SmallStruct small;
+ } uni;
+ int number;
+} EmbeddedUnionTest;
+
+%}
diff --git a/trunk/Examples/test-suite/using1.i b/trunk/Examples/test-suite/using1.i
new file mode 100644
index 000000000..2e336faab
--- /dev/null
+++ b/trunk/Examples/test-suite/using1.i
@@ -0,0 +1,22 @@
+%module using1
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) X::_FooImpl; /* Ruby, wrong class name */
+
+%inline %{
+
+namespace X {
+ typedef int Integer;
+
+ class _FooImpl {
+ public:
+ typedef Integer value_type;
+ };
+ typedef _FooImpl Foo;
+}
+
+namespace Y = X;
+using namespace Y;
+
+int spam(Foo::value_type x) { return x; }
+
+%}
diff --git a/trunk/Examples/test-suite/using2.i b/trunk/Examples/test-suite/using2.i
new file mode 100644
index 000000000..1f3dc46f5
--- /dev/null
+++ b/trunk/Examples/test-suite/using2.i
@@ -0,0 +1,27 @@
+%module using2
+
+%warnfilter(SWIGWARN_PARSE_USING_UNDEF);
+
+using ::baz;
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) X::_FooImpl; /* Ruby, wrong class name */
+
+%inline %{
+
+namespace X {
+ typedef int Integer;
+
+ class _FooImpl {
+ public:
+ typedef Integer value_type;
+ };
+ typedef _FooImpl Foo;
+}
+
+namespace Y = X;
+using Y::Foo;
+
+int spam(Foo::value_type x) { return x; }
+
+
+%}
diff --git a/trunk/Examples/test-suite/using_composition.i b/trunk/Examples/test-suite/using_composition.i
new file mode 100644
index 000000000..bd0f712b5
--- /dev/null
+++ b/trunk/Examples/test-suite/using_composition.i
@@ -0,0 +1,49 @@
+%module(ruby_minherit="1") using_composition
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, PHP multiple inheritance
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, PHP multiple inheritance
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah;
+#endif
+
+%inline %{
+class Foo {
+public:
+ int blah(int x) { return x; }
+ char *blah(char *x) { return x; }
+};
+
+class Bar {
+public:
+ double blah(double x) { return x; }
+};
+
+class FooBar : public Foo, public Bar {
+public:
+ using Foo::blah;
+ using Bar::blah;
+ char *blah(char *x) { return x; }
+};
+
+class FooBar2 : public Foo, public Bar {
+public:
+ char *blah(char *x) { return x; }
+ using Foo::blah;
+ using Bar::blah;
+};
+
+class FooBar3 : public Foo, public Bar {
+public:
+ using Foo::blah;
+ char *blah(char *x) { return x; }
+ using Bar::blah;
+};
+
+%}
diff --git a/trunk/Examples/test-suite/using_extend.i b/trunk/Examples/test-suite/using_extend.i
new file mode 100644
index 000000000..e14cc28e8
--- /dev/null
+++ b/trunk/Examples/test-suite/using_extend.i
@@ -0,0 +1,51 @@
+%module(ruby_minherit="1") using_extend
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah;
+#endif
+
+%extend Foo {
+ int blah(int x, int y) {
+ return x+y;
+ }
+};
+
+%extend Bar {
+ double blah(double x, double y) {
+ return x+y;
+ }
+};
+
+%inline %{
+class Foo {
+public:
+ int blah(int x) { return x; }
+ char *blah(char *x) { return x; }
+};
+
+class Bar {
+public:
+ int duh1() { return 1; }
+ int duh(int x) { return x; }
+ double blah(double x) { return x; }
+};
+
+class FooBar : public Foo, public Bar {
+public:
+ using Foo::blah;
+ using Bar::blah;
+ char *blah(char *x) { return x; }
+};
+
+%}
+
+%extend FooBar
+{
+ using Bar::duh1;
+ using Bar::duh;
+}
+
+
diff --git a/trunk/Examples/test-suite/using_inherit.i b/trunk/Examples/test-suite/using_inherit.i
new file mode 100644
index 000000000..b4fe9664a
--- /dev/null
+++ b/trunk/Examples/test-suite/using_inherit.i
@@ -0,0 +1,54 @@
+%module using_inherit
+
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test;
+#endif
+
+%inline %{
+
+class Foo {
+public:
+ int test(int x) { return x; }
+ double test(double x) { return x; };
+};
+
+class Bar : public Foo {
+public:
+ using Foo::test;
+};
+
+class Bar2 : public Foo {
+public:
+ int test(int x) { return x*2; }
+ double test(double x) { return x*2; };
+ using Foo::test;
+};
+
+class Bar3 : public Foo {
+public:
+ int test(int x) { return x*2; }
+ double test(double x) { return x*2; };
+ using Foo::test;
+};
+
+class Bar4 : public Foo {
+public:
+ int test(int x) { return x*2; }
+ using Foo::test;
+ double test(double x) { return x*2; };
+};
+
+class Fred1 : public Foo {
+public:
+ using Foo::test;
+ double test(double x) { return x*2; };
+};
+
+class Fred2 : public Foo {
+public:
+ double test(double x) { return x*2; };
+ using Foo::test;
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/using_namespace.i b/trunk/Examples/test-suite/using_namespace.i
new file mode 100644
index 000000000..ce02e9a87
--- /dev/null
+++ b/trunk/Examples/test-suite/using_namespace.i
@@ -0,0 +1,87 @@
+%module(ruby_minherit="1") using_namespace
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::hi0; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::hi1; /* Ruby, wrong class name */
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi<hello::Hello, hi::hi0>; // C#, Java, PHP multiple inheritance
+
+%inline %{
+ namespace hello
+ {
+ struct Hello
+ {
+ };
+
+ template <class _T1, class _T2>
+ struct Hi : _T1, _T2
+ {
+ int value1() const
+ {
+ return 1;
+ }
+
+ int value2() const
+ {
+ return 2;
+ }
+ };
+ }
+
+ 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 >
+ {
+ using hello::Hi< hello::Hello, hi::hi0 >::value1;
+ using hello::Hi< hello::Hello, hi0 >::value2;
+ };
+
+ }
+
+%}
+
+
+%inline {
+namespace foo {
+ typedef double mytype;
+}
+
+// global namespace
+typedef float mytype;
+
+using namespace foo;
+
+struct X {
+ ::mytype d;
+};
+
+}
+
+%inline %{
+namespace SpaceMan {
+ typedef double SpaceManDouble;
+}
+using namespace ::SpaceMan; // global namespace prefix
+
+SpaceManDouble useSpaceMan(SpaceManDouble s) { return s; }
+
+%}
+
diff --git a/trunk/Examples/test-suite/using_pointers.i b/trunk/Examples/test-suite/using_pointers.i
new file mode 100644
index 000000000..b2d6abe4d
--- /dev/null
+++ b/trunk/Examples/test-suite/using_pointers.i
@@ -0,0 +1,36 @@
+%module using_pointers
+
+#ifdef SWIGCSHARP
+%csmethodmodifiers x "public new"
+#endif
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%inline %{
+ class Foo {
+ public:
+ int x;
+ virtual ~Foo() { }
+ virtual Foo* blah() { return this; }
+ virtual Foo* exception_spec(int what_to_throw) throw (int, const char *) {
+ int num = 10;
+ const char *str = "exception message";
+ if (what_to_throw == 1) throw num;
+ else if (what_to_throw == 2) throw str;
+ return 0;
+ }
+ };
+
+ class FooBar : public Foo {
+ public:
+ using Foo::blah;
+ using Foo::x;
+ using Foo::exception_spec;
+ };
+
+%}
+
diff --git a/trunk/Examples/test-suite/using_private.i b/trunk/Examples/test-suite/using_private.i
new file mode 100644
index 000000000..be57ef787
--- /dev/null
+++ b/trunk/Examples/test-suite/using_private.i
@@ -0,0 +1,25 @@
+%module using_private
+
+%inline %{
+class Foo {
+public:
+ virtual ~Foo() { }
+ int x;
+ int blah(int xx) { return xx; }
+ int defaulted(int i = -1) { return i; }
+ virtual void virtualmethod() {}
+ virtual void anothervirtual() {}
+};
+
+class FooBar : private Foo {
+public:
+ using Foo::blah;
+ using Foo::x;
+ using Foo::defaulted;
+ using Foo::virtualmethod;
+ virtual void anothervirtual() {}
+ virtual ~FooBar() {}
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/using_protected.i b/trunk/Examples/test-suite/using_protected.i
new file mode 100644
index 000000000..23adfdbba
--- /dev/null
+++ b/trunk/Examples/test-suite/using_protected.i
@@ -0,0 +1,17 @@
+%module using_protected
+
+%inline %{
+class Foo {
+protected:
+ int x;
+ int blah(int xx) { return xx; }
+};
+
+class FooBar : public Foo {
+public:
+ using Foo::blah;
+ using Foo::x;
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/valuewrapper.i b/trunk/Examples/test-suite/valuewrapper.i
new file mode 100644
index 000000000..289f882de
--- /dev/null
+++ b/trunk/Examples/test-suite/valuewrapper.i
@@ -0,0 +1,17 @@
+// valuewrapper.i
+%module valuewrapper
+
+%inline %{
+template <typename T> struct X {
+ X(int) {}
+};
+
+template <typename T> struct Y {
+ Y() {}
+ int spam(T t = T(0)) { return 0; }
+};
+%}
+
+%template(Xi) X<int>;
+%template(YXi) Y< X<int> >;
+
diff --git a/trunk/Examples/test-suite/valuewrapper_base.i b/trunk/Examples/test-suite/valuewrapper_base.i
new file mode 100644
index 000000000..63471bbc8
--- /dev/null
+++ b/trunk/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/trunk/Examples/test-suite/valuewrapper_const.i b/trunk/Examples/test-suite/valuewrapper_const.i
new file mode 100644
index 000000000..3091df30e
--- /dev/null
+++ b/trunk/Examples/test-suite/valuewrapper_const.i
@@ -0,0 +1,36 @@
+%module valuewrapper_const
+
+%inline %{
+// B requires swig to use the SwigValueWrapper
+class B
+{
+private:
+ B() { }
+public:
+ B(const B&){ }
+};
+
+// A returns a B and a const B
+class A
+{
+ B b;
+public:
+ A(const B& b) : b(b) { }
+ // this one works SwigValueWrapper< B > result;
+ B GetB() {
+ return b;
+ }
+ // this one is incorrect B result;
+ const B GetBconst() const {
+ return b;
+ }
+ ::B GetBGlobalQualifier() {
+ return b;
+ }
+ const ::B GetBconstGlobalGlobalQualifier() const {
+ return b;
+ }
+};
+
+%}
+
diff --git a/trunk/Examples/test-suite/valuewrapper_opaque.i b/trunk/Examples/test-suite/valuewrapper_opaque.i
new file mode 100644
index 000000000..52da89391
--- /dev/null
+++ b/trunk/Examples/test-suite/valuewrapper_opaque.i
@@ -0,0 +1,253 @@
+%module valuewrapper_opaque
+
+/*
+ * Opaque types
+ */
+
+%feature("valuewrapper") C;
+class C;
+
+%{
+template<typename T> class TemplateClass {
+public:
+TemplateClass<T>(T a) {}
+};
+
+struct B
+{
+};
+
+class C
+{
+public:
+ C(int){}
+};
+%}
+
+
+/*
+ * Hint swig that the Opaque type B don't need the value wrapper.
+ * This hint is only necessary in very very special cases.
+ */
+%feature("novaluewrapper") B;
+class B;
+
+/*
+ * Force swig to use the value wrapper, even when the class
+ * has a default constructor, in case you want to save a
+ * instance construction.
+ *
+ */
+%feature("valuewrapper") D;
+class D;
+
+
+%feature("valuewrapper") A;
+class A;
+
+%feature("valuewrapper") TemplateClass<A>;
+%feature("valuewrapper") TemplateClass<C>;
+template<class T> class TemplateClass;
+
+%feature("valuewrapper") BB;
+class BB;
+
+
+%inline %{
+
+struct A
+{
+ A(int){}
+};
+
+class D {};
+
+class Klass {};
+
+
+TemplateClass<Klass> getKlass(Klass k) {
+ TemplateClass<Klass> t(k);
+ return t;
+}
+
+
+TemplateClass<A> getA(A a) {
+ TemplateClass<A> t(a);
+ return t;
+}
+
+
+TemplateClass<B> getA(B b) {
+ TemplateClass<B> t(b);
+ return t;
+}
+
+
+TemplateClass<C> getC(C a) {
+ TemplateClass<C> t(a);
+ return t;
+}
+
+
+TemplateClass<int> getInt(int a) {
+ TemplateClass<int> t(a);
+ return t;
+}
+
+A sgetA(A a) {
+ return a;
+}
+
+Klass sgetKlass(Klass a) {
+ return a;
+}
+
+template <class T>
+struct auto_ptr
+{
+ auto_ptr(T a){}
+};
+
+auto_ptr<A> getPtrA(auto_ptr<A> a) {
+ return a;
+}
+
+B getB(B a) {
+ return a;
+}
+
+D getD(D a) {
+ return a;
+}
+
+%}
+
+%template() auto_ptr<A>;
+
+
+/***** Another strange case, member var + opaque, bug #901706 ******/
+%{
+class BB {
+friend class AA;
+
+protected:
+ BB(int aa) { this->a = aa; };
+ BB() {};
+
+ int a;
+};
+%}
+
+%inline %{
+
+class AA {
+public:
+ AA(){}
+
+ BB innerObj;
+};
+
+%}
+
+%{
+class Foobar
+{
+public:
+ Foobar()
+ {
+ }
+
+ char *foo_method()
+ {
+ return 0;
+ }
+
+};
+
+class Quux
+{
+public:
+ Quux()
+ {
+ }
+
+ Foobar method()
+ {
+ return Foobar();
+ }
+
+};
+%}
+
+%feature("novaluewrapper") Foobar;
+class Foobar;
+
+
+class Quux {
+public:
+ Quux();
+
+ Foobar method();
+
+
+};
+
+
+#if defined(SWIGPYTHON)
+
+/*
+ This case can't be fixed by using the valuewrapper feature and the
+ old mechanismbut it works fine with the new mechanism
+*/
+
+%{
+
+ // Template primitive type, only visible in C++
+ template <class T>
+ struct Param
+ {
+ T val;
+
+ // This case is disabled by now
+ // Param(T v): val(v) {}
+
+ Param(T v = T()): val(v) {}
+
+ operator T() const { return val; }
+ };
+
+%}
+
+/*
+ Several languages have 'not 100% safe' typemaps,
+ where the following %applies don't work.
+*/
+%apply int { Param<int> };
+%apply const int& { const Param<int>& };
+
+%apply double { Param<double> };
+%apply const double& { const Param<double>& };
+
+%inline %{
+
+ template <class T>
+ T getv(const Param<T>& p)
+ {
+ return p.val;
+ }
+
+ template <class T>
+ Param<T> getp(const T& v)
+ {
+ return Param<T>(v);
+ }
+
+%}
+
+%template(getv_i) getv<int>;
+%template(getp_i) getp<int>;
+
+%template(getv_d) getv<double>;
+%template(getp_d) getp<double>;
+
+#endif
diff --git a/trunk/Examples/test-suite/varargs.i b/trunk/Examples/test-suite/varargs.i
new file mode 100644
index 000000000..41e4903f0
--- /dev/null
+++ b/trunk/Examples/test-suite/varargs.i
@@ -0,0 +1,38 @@
+// Tests SWIG's *default* handling of varargs. The default behavior is to simply ignore the varargs.
+%module varargs
+
+%varargs(int mode = 0) test_def;
+%varargs(int mode = 0) Foo::Foo;
+%varargs(int mode = 0) Foo::statictest(const char*fmt, ...);
+
+%inline %{
+char *test(const char *fmt, ...) {
+ return (char *) fmt;
+}
+
+const char *test_def(const char *fmt, ...) {
+ return fmt;
+}
+
+class Foo {
+public:
+ char *str;
+ Foo() {
+ str = NULL;
+ }
+ Foo(const char *fmt, ...) {
+ str = new char[strlen(fmt) + 1];
+ strcpy(str, fmt);
+ }
+ ~Foo() {
+ delete [] str;
+ }
+ char *test(const char *fmt, ...) {
+ return (char *) fmt;
+ }
+ static char *statictest(const char *fmt, ...) {
+ return (char *) fmt;
+ }
+};
+
+%}
diff --git a/trunk/Examples/test-suite/virtual_derivation.i b/trunk/Examples/test-suite/virtual_derivation.i
new file mode 100644
index 000000000..a199646d4
--- /dev/null
+++ b/trunk/Examples/test-suite/virtual_derivation.i
@@ -0,0 +1,67 @@
+%module virtual_derivation
+
+ /*
+
+ Try to add to your favorite language a runtime test like
+ this:
+
+ b = B(3)
+ if (b.get_a() != b.get_b()):
+ print "something is wrong"
+
+
+ The test runs fine with python, but not with ruby.
+
+ */
+
+%inline %{
+
+ struct A
+ {
+ ~A()
+ {
+ }
+
+ int m_a;
+
+ A(int a) :m_a(a)
+ {
+ }
+
+ int get_a()
+ {
+ return m_a;
+ }
+
+ };
+
+ struct B : virtual A
+ {
+ B(int a): A(a)
+ {
+ }
+
+ int get_b()
+ {
+ return get_a();
+ }
+
+ // in ruby, get_a() returns trash if called from b, unless is
+ // wrapped with the previous get_b or using the 'using'
+ // declaration:
+ // using A::get_a;
+ };
+
+
+
+
+ class IndexReader{
+ public:
+ virtual void norms() = 0;
+ };
+
+ class MultiReader : public IndexReader {
+ protected:
+ MultiReader();
+ };
+%}
diff --git a/trunk/Examples/test-suite/virtual_destructor.i b/trunk/Examples/test-suite/virtual_destructor.i
new file mode 100644
index 000000000..f45fccc53
--- /dev/null
+++ b/trunk/Examples/test-suite/virtual_destructor.i
@@ -0,0 +1,22 @@
+/*
+This testcase checks that a virtual destructor with void as a parameter is
+correctly handled.
+Also tests a class with protected destructor derived from a class with a
+public destructor.
+*/
+
+%module virtual_destructor
+
+%inline %{
+
+class VirtualVoidDestructor {
+public:
+ VirtualVoidDestructor() {};
+ virtual ~VirtualVoidDestructor(void) { };
+};
+
+class Derived : public VirtualVoidDestructor {
+protected:
+ virtual ~Derived() {};
+};
+%}
diff --git a/trunk/Examples/test-suite/virtual_poly.i b/trunk/Examples/test-suite/virtual_poly.i
new file mode 100644
index 000000000..d8051ae15
--- /dev/null
+++ b/trunk/Examples/test-suite/virtual_poly.i
@@ -0,0 +1,204 @@
+%module(directors="1") virtual_poly
+
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) copy; /* Java, C# covariant return types */
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) ref_this; /* Java, C# covariant return types */
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant; /* Java, C# covariant return types */
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant2; /* Java, C# covariant return types */
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant3; /* Java, C# covariant return types */
+%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant4; /* Java, C# covariant return types */
+
+//
+// Check this example with directors wherever possible.
+//
+//%feature("director");
+
+// This shouldn't get used.
+// %newobject *::copy();
+
+%newobject *::copy() const;
+
+
+%inline %{
+ struct NNumber
+ {
+ virtual ~NNumber() {};
+ virtual NNumber* copy() const = 0;
+ virtual NNumber& ref_this()
+ {
+ return *this;
+ }
+
+
+ NNumber* nnumber()
+ {
+ return this;
+ }
+
+
+ };
+
+ /*
+ NInt and NDouble are both NNumber derived classes, but they
+ have more different than common attributes.
+
+ In particular the function 'get', that is type dependent, can't
+ be included in the NNumber abstract interface.
+
+ For this reason, the virtual 'copy' method has a polymorphic (covariant)
+ return type, since in most of the cases we don't want to lose the
+ original object type, which is very very important.
+
+ Using the polymorphic return type reduced greatly the need of
+ using 'dynamic_cast' at the C++ side, and at the target languages
+ that support it.
+ */
+ struct NInt : NNumber
+ {
+ NInt(int v) : val(v)
+ {
+ }
+
+ int get() const
+ {
+ return val;
+ }
+
+ virtual NInt* copy() const
+ {
+ return new NInt(val);
+ }
+
+ virtual NInt& ref_this()
+ {
+ return *this;
+ }
+
+ /* See below */
+ static NInt* narrow(NNumber* nn);
+
+
+ private:
+ int val;
+ };
+
+ inline NInt& incr(NInt& i) {
+ i = i.get() + 1;
+ return i;
+ }
+
+ struct NDouble : NNumber
+ {
+ NDouble(double v) : val(v)
+ {
+ }
+
+ double get() const
+ {
+ return val;
+ }
+
+ virtual NDouble* copy() const
+ {
+ return new NDouble(val);
+ }
+
+ virtual NDouble& ref_this()
+ {
+ return *this;
+ }
+
+ /* See below */
+ static NDouble* narrow(NNumber* nn);
+
+ private:
+ double val;
+ };
+
+ /*
+ Java and C# do not support the polymorphic (covariant) return types used
+ in the copy method. So, they just emit 'plain' copy functions as if this is
+ being wrapped instead:
+
+ NNumber* NNumber::copy() const;
+ NNumber* NInt::copy() const;
+ NNumber* NDouble::copy() const;
+
+ However, since the objects provide their own downcasting
+ mechanism, the narrow methods similar to the CORBA mechanism,
+ could be used, otherwise use the Java/C# downcasts.
+ */
+ inline NInt* NInt::narrow(NNumber* n) {
+ // this is just a plain C++ dynamic_cast, but in theory the user
+ // could use whatever he wants.
+ return dynamic_cast<NInt*>(n);
+ }
+
+ inline NDouble* NDouble::narrow(NNumber* n) {
+ return dynamic_cast<NDouble*>(n);
+ }
+%}
+
+%inline %{
+
+// These three classes test covariant return types and whether swig accurately matches
+// polymorphic methods (mainly for C# override keyword). Also tests methods which hide
+// the base class' method (for C#, new keyword required on method declaration).
+
+typedef int* IntegerPtr;
+typedef double Double;
+
+template<typename T> struct Base {
+ T t;
+ virtual IntegerPtr method() const = 0;
+ virtual IntegerPtr foxy() const = 0;
+ virtual IntegerPtr foxy(int a) const = 0;
+ virtual int * foxy(int*& a) { return 0; }
+ virtual double afunction() = 0;
+ virtual IntegerPtr defaultargs(double d, int * a = 0) = 0;
+ static void StaticHidden() {}
+ void AmIAmINotVirtual() {}
+ IntegerPtr NotVirtual(IntegerPtr i) { return 0; }
+ virtual Base * covariant(int a = 0, int * i = 0) { return 0; }
+ typedef Base * BasePtr;
+ virtual BasePtr covariant2() { return 0; }
+ virtual BasePtr covariant3() { return 0; }
+ virtual ~Base() {}
+};
+
+template<typename T> struct Derived : Base<T> {
+ int * method() const { return 0; }
+ IntegerPtr foxy() const { return 0; }
+ int * foxy(int a) const { return 0; }
+ virtual int * foxy(int*& a) { return 0; }
+ Double afunction() { return 0; }
+ int * defaultargs(Double d, IntegerPtr a = 0) { return 0; }
+ void AmIAmINotVirtual() {}
+ int * NotVirtual(int *i) { return 0; }
+ typedef Derived * DerivedPtr;
+ DerivedPtr covariant(int a = 0, IntegerPtr i = 0) { return 0; }
+ DerivedPtr covariant2() { return 0; }
+ Derived<T> * covariant3() { return 0; }
+ virtual Derived<T> * covariant4(double d) { return 0; }
+ virtual int IsVirtual() { return 0; }
+};
+
+template<typename T> struct Bottom : Derived<T> {
+ int * method() const { return 0; }
+ static void StaticHidden() {}
+ void AmIAmINotVirtual() {}
+ IntegerPtr NotVirtual(IntegerPtr i) { return 0; }
+ void (*funcptr)(int a, bool b);
+ Bottom<T> * covariant(int a = 0, IntegerPtr i = 0) { return 0; }
+ Derived<T> * covariant2() { return 0; }
+ Bottom<T> * covariant3() { return 0; }
+ Bottom<T> * covariant4(double d) { return 0; }
+ int IsVirtual() { return 0; }
+};
+%}
+
+
+%template(BaseInt) Base<int>;
+%template(DerivedInt) Derived<int>;
+%template(BottomInt) Bottom<int>;
+
+
diff --git a/trunk/Examples/test-suite/voidtest.i b/trunk/Examples/test-suite/voidtest.i
new file mode 100644
index 000000000..90779e227
--- /dev/null
+++ b/trunk/Examples/test-suite/voidtest.i
@@ -0,0 +1,23 @@
+%module voidtest
+
+%inline %{
+
+void globalfunc(void) {
+}
+
+class Foo {
+public:
+ Foo(void) { }
+ void memberfunc(void) { }
+ static void staticmemberfunc(void) { }
+};
+
+
+void *vfunc1(void *f) { return f; }
+void *vfunc2(Foo *f) { return f; }
+Foo *vfunc3(void *f) { return (Foo *) f; }
+Foo *vfunc4(Foo *f) { return f; }
+
+
+%}
+
diff --git a/trunk/Examples/test-suite/wallkw.i b/trunk/Examples/test-suite/wallkw.i
new file mode 100644
index 000000000..0ac383bcd
--- /dev/null
+++ b/trunk/Examples/test-suite/wallkw.i
@@ -0,0 +1,16 @@
+%module wallkw
+
+// test the -Wallkw option
+
+%warnfilter(SWIGWARN_PARSE_KEYWORD) clone; // 'clone' is a php keyword, renamed as 'c_clone'
+%warnfilter(SWIGWARN_PARSE_KEYWORD) delegate; // 'delegate' is a C# keyword, renaming to '_delegate'
+%warnfilter(SWIGWARN_PARSE_KEYWORD) pass; // 'pass' is a python keyword, renaming to '_pass'
+%warnfilter(SWIGWARN_PARSE_KEYWORD) alias; // 'alias' is a ruby keyword, renaming to 'C_alias'
+
+%inline %{
+const char * clone() { return "clone"; }
+const char * delegate() { return "delegate"; }
+const char * pass() { return "pass"; }
+const char * alias() { return "alias"; }
+%}
+
diff --git a/trunk/Examples/test-suite/wrapmacro.i b/trunk/Examples/test-suite/wrapmacro.i
new file mode 100644
index 000000000..bd5e48b15
--- /dev/null
+++ b/trunk/Examples/test-suite/wrapmacro.i
@@ -0,0 +1,62 @@
+%module wrapmacro
+
+#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_max;
+#endif
+
+/* Testing technique for wrapping macros */
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+/* Here, some macros to wrap */
+%inline %{
+
+typedef unsigned short guint16;
+
+#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \
+ (guint16) ((guint16) (val) >> 8) | \
+ (guint16) ((guint16) (val) << 8)))
+
+/* Don't use max(), it's a builtin function for PHP. */
+#define maximum(a,b) ((a) > (b) ? (a) : (b))
+
+%}
+
+
+/* Here, the auxiliary macro to wrap a macro */
+%define %wrapmacro(type, name, lparams, lnames)
+%rename(name) SWIGMACRO_##name;
+%inline %{
+type SWIGMACRO_##name(lparams) {
+ return name(lnames);
+}
+%}
+%enddef
+#define PLIST(...) __VA_ARGS__
+
+
+
+/* Here, wrapping the macros */
+%wrapmacro(guint16, GUINT16_SWAP_LE_BE_CONSTANT, guint16 val, val);
+%wrapmacro(size_t, maximum, PLIST(size_t a, const size_t& b), PLIST(a, b));
+%wrapmacro(double, maximum, PLIST(double a, double b), PLIST(a, b));
+
+
+/* Maybe in the future, a swig directive will make this easier:
+
+#define max(a,b) ((a) > (b) ? (a) : (b))
+
+%wrapmacro double max(long a, double b); // target name is 'max'
+%wrapmacro(max_i) int max(int a, int b); // changes target name to 'max_i'.
+
+*/
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
diff --git a/trunk/Examples/xml/Makefile.in b/trunk/Examples/xml/Makefile.in
new file mode 100644
index 000000000..dfda4a646
--- /dev/null
+++ b/trunk/Examples/xml/Makefile.in
@@ -0,0 +1,54 @@
+# Examples/xml/Makefile
+
+top_srcdir = @top_srcdir@
+
+cleanup = tail +2 \
+ | sed -e 's/ident="ID[0-9A-F]*"//g' \
+ -e 's,name="/[^"]*/\([^/]*\.swg\)",name="\1",g'
+
+all-dot-i-files = \
+ error.i \
+ example.i \
+ example_apply.i \
+ example_const.i \
+ example_gif.i \
+ example_inl.i \
+ example_p5.i \
+ example_ro.i \
+ example_title_add.i \
+ example_xml.i \
+ gnarly.i
+
+all: check
+
+chk-swiglib = $(top_srcdir)/Lib
+
+check:
+ for f in $(all-dot-i-files) ; do \
+ base=`basename $$f .i` ; \
+ xml=$$base.xml ; \
+ SWIG_LIB=$(chk-swiglib) $(top_srcdir)/swig -xml $$xml $$f ; \
+ cat $$xml | $(cleanup) | diff -c $$base.expected-xml - ; \
+ done
+
+clean:
+ rm -f *.xml
+
+distclean: clean
+ rm -f Makefile
+
+# from here on, non-developers beware!
+
+%.expected-xml : %.i
+ SWIG_LIB=$(top_srcdir)/Lib $(top_srcdir)/swig -xml tmp-file $^
+ cat tmp-file | $(cleanup) > $@
+ rm -f tmp-file
+
+all-expected-xml:
+ for f in $(all-dot-i-files) ; do \
+ make `basename $$f .i`.expected-xml ; done
+
+all-expected-xml-clean:
+ rm -f *.expected-xml
+
+# Examples/xml/Makefile ends here
diff --git a/trunk/Examples/xml/error.expected-xml b/trunk/Examples/xml/error.expected-xml
new file mode 100644
index 000000000..6b1a31614
--- /dev/null
+++ b/trunk/Examples/xml/error.expected-xml
@@ -0,0 +1,24 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="error.i" >
+ <swigxml:child >
+ <swig:module name="error" />
+ <c:enum >
+ <swigxml:child >
+ <c:enumvalue name="RED" >
+ <swigxml:value string="RED" />
+ </c:enumvalue>
+ <c:enumvalue name="GREEN" />
+ <c:enumvalue name="BLUE" />
+ </swigxml:child>
+ </c:enum>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/error.i b/trunk/Examples/xml/error.i
new file mode 100644
index 000000000..7ea59a0c6
--- /dev/null
+++ b/trunk/Examples/xml/error.i
@@ -0,0 +1,2 @@
+%module error
+enum { RED=10, GREEN, BLUE }; \ No newline at end of file
diff --git a/trunk/Examples/xml/example.expected-xml b/trunk/Examples/xml/example.expected-xml
new file mode 100644
index 000000000..28231365e
--- /dev/null
+++ b/trunk/Examples/xml/example.expected-xml
@@ -0,0 +1,23 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example.i" >
+ <swigxml:child >
+ <swig:module name="example" />
+ <swig:apply name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:none name="r" >
+ <swigxml:type string="p.int" />
+ </swigxml:none>
+ </swigxml:parms>
+ <swigxml:type string="p.int" />
+ </swig:apply>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example.h b/trunk/Examples/xml/example.h
new file mode 100644
index 000000000..7f31fce92
--- /dev/null
+++ b/trunk/Examples/xml/example.h
@@ -0,0 +1,3 @@
+// i add this file because it's referenced by other files.
+// someone should replace these comments w/ proper content.
+// --ttn, 2001/01/16 17:44:19
diff --git a/trunk/Examples/xml/example.i b/trunk/Examples/xml/example.i
new file mode 100644
index 000000000..77d571ed8
--- /dev/null
+++ b/trunk/Examples/xml/example.i
@@ -0,0 +1,8 @@
+/* File : example.i */
+%module example
+
+%apply int *OUTPUT { int *r };
+
+
+
+
diff --git a/trunk/Examples/xml/example_apply.expected-xml b/trunk/Examples/xml/example_apply.expected-xml
new file mode 100644
index 000000000..50a6509ee
--- /dev/null
+++ b/trunk/Examples/xml/example_apply.expected-xml
@@ -0,0 +1,1486 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_apply.i" >
+ <swigxml:child >
+ <swig:module name="example" />
+ <c:function name="add" >
+ <swigxml:parms >
+ <swigxml:parm name="x" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="result" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:file name="../../Lib/pointer.i" >
+ <swigxml:child >
+ <swig:module name="pointer" />
+ <swig:insert >
+ <swigxml:code >
+
+%include pointer.i
+
+The pointer.i library provides run-time support for managing and
+manipulating a variety of C/C++ pointer values. In particular,
+you can create various kinds of objects and dereference common
+pointer types. This is done through a common set of functions:
+
+ ptrvalue - Dereferences a pointer
+ ptrset - Set the value of an object referenced by
+ a pointer.
+ ptrcreate - Create a new object and return a pointer.
+ ptrfree - Free the memory allocated by ptrcreate.
+ ptradd - Increment/decrement a pointer value.
+
+When creating, dereferencing, or setting the value of pointer
+variable, only the common C datatypes of int, short, long, float,
+double, char, and char * are currently supported. Other
+datatypes may generate an error.
+
+One of the more interesting aspects of this library is that
+it operates with a wide range of datatypes. For example,
+the "ptrvalue" function can dereference "double *", "int *",
+"long *", "char *", and other datatypes. Since SWIG encodes
+pointers with type information, this can be done transparently
+and in most cases, you can dereference a pointer without
+ever knowing what type it actually is.
+
+This library is primarily designed for utility, not high
+performance (the dynamic determination of pointer types takes
+more work than most normal wrapper functions). As a result,
+you may achieve better performance by writing customized
+"helper" functions if you're making lots of calls to these
+functions in inner loops or other intensive operations.
+ </swigxml:code>
+ <swigxml:section string="doc" />
+ </swig:insert>
+ <swig:types >
+ <swigxml:parms >
+ <swigxml:parm >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.short" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.long" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.float" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.double" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.p.char" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.void" />
+ </swigxml:parm>
+ </swigxml:parms>
+ </swig:types>
+ <swig:file name="../../Lib/xml/ptrlang.i" >
+ <swigxml:child >
+ <swig:insert >
+ <swigxml:code >
+
+#include &amp;lt;ctype.h>
+
+/* Types used by the library */
+static swig_type_info *SWIG_POINTER_int_p = 0;
+static swig_type_info *SWIG_POINTER_short_p =0;
+static swig_type_info *SWIG_POINTER_long_p = 0;
+static swig_type_info *SWIG_POINTER_float_p = 0;
+static swig_type_info *SWIG_POINTER_double_p = 0;
+static swig_type_info *SWIG_POINTER_char_p = 0;
+static swig_type_info *SWIG_POINTER_char_pp = 0;
+static swig_type_info *SWIG_POINTER_void_p = 0;
+ </swigxml:code>
+ </swig:insert>
+ <swig:insert >
+ <swigxml:code >
+
+ SWIG_POINTER_int_p = SWIG_TypeQuery("int *");
+ SWIG_POINTER_short_p = SWIG_TypeQuery("short *");
+ SWIG_POINTER_long_p = SWIG_TypeQuery("long *");
+ SWIG_POINTER_float_p = SWIG_TypeQuery("float *");
+ SWIG_POINTER_double_p = SWIG_TypeQuery("double *");
+ SWIG_POINTER_char_p = SWIG_TypeQuery("char *");
+ SWIG_POINTER_char_pp = SWIG_TypeQuery("char **");
+ SWIG_POINTER_void_p = SWIG_TypeQuery("void *");
+ </swigxml:code>
+ <swigxml:section string="init" />
+ </swig:insert>
+ <swig:insert >
+ <swigxml:code >
+
+
+/* #ifdef WIN32
+#undef isspace
+#define isspace(c) (c == ' ')
+#endif
+*/
+
+/*------------------------------------------------------------------
+ ptrvalue(ptr,type = 0)
+
+ Attempts to dereference a pointer value. If type is given, it
+ will try to use that type. Otherwise, this function will attempt
+ to "guess" the proper datatype by checking against all of the
+ builtin C datatypes.
+ ------------------------------------------------------------------ */
+
+#ifdef PERL_OBJECT
+static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, char *type) {
+#define ptrvalue(a,b,c) _ptrvalue(pPerl,a,b,c)
+#else
+static SV *_ptrvalue(SV *_PTRVALUE, int index, char *type) {
+#define ptrvalue(a,b,c) _ptrvalue(a,b,c)
+#endif
+
+ void *ptr;
+ SV *obj = 0;
+
+ if (SWIG_ConvertPtr(_PTRVALUE, &amp;ptr, 0) &amp;lt; 0) {
+ croak("Type error it ptrvalue. Argument is not a valid pointer value.");
+ } else {
+ /* If no datatype was passed, try a few common datatypes first */
+ if (!type) {
+
+ /* No datatype was passed. Type to figure out if it's a common one */
+
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_int_p) >= 0) {
+ type = "int";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_double_p) >= 0) {
+ type = "double";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_short_p) >= 0) {
+ type = "short";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_long_p) >= 0) {
+ type = "long";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_float_p) >= 0) {
+ type = "float";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_p) >= 0) {
+ type = "char";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_pp) >= 0) {
+ type = "char *";
+ } else {
+ type = "unknown";
+ }
+ }
+
+ if (!ptr) {
+ croak("Unable to dereference NULL pointer.");
+ return 0;
+ }
+
+ /* Now we have a datatype. Try to figure out what to do about it */
+ if (strcmp(type,"int") == 0) {
+ obj = sv_newmortal();
+ sv_setiv(obj,(IV) *(((int *) ptr) + index));
+ } else if (strcmp(type,"double") == 0) {
+ obj = sv_newmortal();
+ sv_setnv(obj,(double) *(((double *) ptr)+index));
+ } else if (strcmp(type,"short") == 0) {
+ obj = sv_newmortal();
+ sv_setiv(obj,(IV) *(((short *) ptr) + index));
+ } else if (strcmp(type,"long") == 0) {
+ obj = sv_newmortal();
+ sv_setiv(obj,(IV) *(((long *) ptr) + index));
+ } else if (strcmp(type,"float") == 0) {
+ obj = sv_newmortal();
+ sv_setnv(obj,(double) *(((float *) ptr)+index));
+ } else if (strcmp(type,"char") == 0) {
+ obj = sv_newmortal();
+ sv_setpv(obj,((char *) ptr)+index);
+ } else if (strcmp(type,"char *") == 0) {
+ char *c = *(((char **) ptr)+index);
+ obj = sv_newmortal();
+ if (c)
+ sv_setpv(obj,c);
+ else
+ sv_setpv(obj,"NULL");
+ } else {
+ croak("Unable to dereference unsupported datatype.");
+ obj = 0;
+ }
+ }
+ return obj;
+}
+
+/*------------------------------------------------------------------
+ ptrcreate(type,value = 0,numelements = 1)
+
+ Attempts to create a new object of given type. Type must be
+ a basic C datatype. Will not create complex objects.
+ ------------------------------------------------------------------ */
+#ifdef PERL_OBJECT
+static SV *_ptrcreate(CPerlObj *pPerl, char *type, SV *value, int numelements) {
+#define ptrcreate(a,b,c) _ptrcreate(pPerl,a,b,c)
+#else
+static SV *_ptrcreate(char *type, SV *value, int numelements) {
+#define ptrcreate(a,b,c) _ptrcreate(a,b,c)
+#endif
+
+ void *ptr;
+ SV *obj;
+ int sz;
+ swig_type_info *cast = 0;
+
+ /* Check the type string against a variety of possibilities */
+
+ if (strcmp(type,"int") == 0) {
+ sz = sizeof(int)*numelements;
+ cast = SWIG_POINTER_int_p;
+ } else if (strcmp(type,"short") == 0) {
+ sz = sizeof(short)*numelements;
+ cast = SWIG_POINTER_short_p;
+ } else if (strcmp(type,"long") == 0) {
+ sz = sizeof(long)*numelements;
+ cast = SWIG_POINTER_long_p;
+ } else if (strcmp(type,"double") == 0) {
+ sz = sizeof(double)*numelements;
+ cast = SWIG_POINTER_double_p;
+ } else if (strcmp(type,"float") == 0) {
+ sz = sizeof(float)*numelements;
+ cast = SWIG_POINTER_float_p;
+ } else if (strcmp(type,"char") == 0) {
+ sz = sizeof(char)*numelements;
+ cast = SWIG_POINTER_char_p;
+ } else if (strcmp(type,"char *") == 0) {
+ sz = sizeof(char *)*(numelements+1);
+ cast = SWIG_POINTER_char_pp;
+ } else if (strcmp(type,"void") == 0) {
+ sz = numelements;
+ cast = SWIG_POINTER_void_p;
+ } else {
+ croak("Unable to create unknown datatype.");
+ return 0;
+ }
+
+ /* Create the new object */
+
+ ptr = (void *) malloc(sz);
+ if (!ptr) {
+ croak("Out of memory in ptrcreate.");
+ return 0;
+ }
+
+ /* Now try to set its default value */
+
+ if (value) {
+ if (strcmp(type,"int") == 0) {
+ int *ip,i,ivalue;
+ ivalue = (int) SvIV(value);
+ ip = (int *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"short") == 0) {
+ short *ip,ivalue;
+ int i;
+ ivalue = (short) SvIV(value);
+ ip = (short *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"long") == 0) {
+ long *ip,ivalue;
+ int i;
+ ivalue = (long) SvIV(value);
+ ip = (long *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"double") == 0) {
+ double *ip,ivalue;
+ int i;
+ ivalue = (double) SvNV(value);
+ ip = (double *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"float") == 0) {
+ float *ip,ivalue;
+ int i;
+ ivalue = (float) SvNV(value);
+ ip = (float *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"char") == 0) {
+ char *ip,*ivalue;
+ ivalue = (char *) SvPV(value,PL_na);
+ ip = (char *) ptr;
+ strncpy(ip,ivalue,numelements-1);
+ } else if (strcmp(type,"char *") == 0) {
+ char **ip, *ivalue;
+ int i;
+ ivalue = (char *) SvPV(value,PL_na);
+ ip = (char **) ptr;
+ for (i = 0; i &amp;lt; numelements; i++) {
+ if (ivalue) {
+ ip[i] = (char *) malloc(strlen(ivalue)+1);
+ strcpy(ip[i],ivalue);
+ } else {
+ ip[i] = 0;
+ }
+ }
+ ip[numelements] = 0;
+ }
+ }
+ /* Create the pointer value */
+
+
+ obj = sv_newmortal();
+ SWIG_MakePtr(obj,ptr,cast);
+ return obj;
+}
+
+/*------------------------------------------------------------------
+ ptrset(ptr,value,index = 0,type = 0)
+
+ Attempts to set the value of a pointer variable. If type is
+ given, we will use that type. Otherwise, we'll guess the datatype.
+ ------------------------------------------------------------------ */
+
+#ifdef PERL_OBJECT
+static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, char *type) {
+#define ptrset(a,b,c,d) _ptrset(pPerl,a,b,c,d)
+#else
+static void _ptrset(SV *_PTRVALUE, SV *value, int index, char *type) {
+#define ptrset(a,b,c,d) _ptrset(a,b,c,d)
+#endif
+ void *ptr;
+ SV *obj;
+
+
+ if (SWIG_ConvertPtr(_PTRVALUE, &amp;ptr, 0) &amp;lt; 0) {
+ croak("Type error it ptrvalue. Argument is not a valid pointer value.");
+ } else {
+ /* If no datatype was passed, try a few common datatypes first */
+ if (!type) {
+ /* No datatype was passed. Type to figure out if it's a common one */
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_int_p) >= 0) {
+ type = "int";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_double_p) >= 0) {
+ type = "double";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_short_p) >= 0) {
+ type = "short";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_long_p) >= 0) {
+ type = "long";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_float_p) >= 0) {
+ type = "float";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_p) >= 0) {
+ type = "char";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_pp) >= 0) {
+ type = "char *";
+ } else {
+ type = "unknown";
+ }
+ }
+ }
+ if (!ptr) {
+ croak("Unable to set NULL pointer.");
+ return;
+ }
+
+ /* Now we have a datatype. Try to figure out what to do about it */
+ if (strcmp(type,"int") == 0) {
+ *(((int *) ptr)+index) = (int) SvIV(value);
+ } else if (strcmp(type,"double") == 0) {
+ *(((double *) ptr)+index) = (double) SvNV(value);
+ } else if (strcmp(type,"short") == 0) {
+ *(((short *) ptr)+index) = (short) SvIV(value);
+ } else if (strcmp(type,"long") == 0) {
+ *(((long *) ptr)+index) = (long) SvIV(value);
+ } else if (strcmp(type,"float") == 0) {
+ *(((float *) ptr)+index) = (float) SvNV(value);
+ } else if (strcmp(type,"char") == 0) {
+ char *c = SvPV(value,PL_na);
+ strcpy(((char *) ptr)+index, c);
+ } else if (strcmp(type,"char *") == 0) {
+ char *c = SvPV(value,PL_na);
+ char **ca = (char **) ptr;
+ if (ca[index]) free(ca[index]);
+ if (strcmp(c,"NULL") == 0) {
+ ca[index] = 0;
+ } else {
+ ca[index] = (char *) malloc(strlen(c)+1);
+ strcpy(ca[index],c);
+ }
+ } else {
+ croak("Unable to set unsupported datatype.");
+ return;
+ }
+}
+
+/*------------------------------------------------------------------
+ ptradd(ptr,offset)
+
+ Adds a value to an existing pointer value. Will do a type-dependent
+ add for basic datatypes. For other datatypes, will do a byte-add.
+ ------------------------------------------------------------------ */
+
+#ifdef PERL_OBJECT
+static SV *_ptradd(CPerlObj *pPerl, SV *_PTRVALUE, int offset) {
+#define ptradd(a,b) _ptradd(pPerl,a,b)
+#else
+static SV *_ptradd(SV *_PTRVALUE, int offset) {
+#define ptradd(a,b) _ptradd(a,b)
+#endif
+
+ void *ptr,*junk;
+ SV *obj;
+ swig_type_info *type;
+ char *tname;
+
+ /* Try to handle a few common datatypes first */
+
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_int_p) >= 0) {
+ ptr = (void *) (((int *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_double_p) >= 0) {
+ ptr = (void *) (((double *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_short_p) >= 0) {
+ ptr = (void *) (((short *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_long_p) >= 0) {
+ ptr = (void *) (((long *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_float_p) >= 0) {
+ ptr = (void *) (((float *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_p) >= 0) {
+ ptr = (void *) (((char *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,0) >= 0) {
+ ptr = (void *) (((char *) ptr) + offset);
+ } else {
+ croak("Type error in ptradd. Argument is not a valid pointer value.");
+ return 0;
+ }
+ printf("ptradd = %x\n", ptr);
+ tname = HvNAME(SvSTASH(SvRV(_PTRVALUE)));
+ obj = sv_newmortal();
+ sv_setref_pv(obj,tname,ptr);
+ return obj;
+}
+
+/*------------------------------------------------------------------
+ ptrfree(ptr)
+
+ Destroys a pointer value
+ ------------------------------------------------------------------ */
+#ifdef PERL_OBJECT
+void _ptrfree(CPerlObj *pPerl, SV *_PTRVALUE) {
+#define ptrfree(a) _ptrfree(pPerl, a)
+#else
+void _ptrfree(SV *_PTRVALUE) {
+#define ptrfree(a) _ptrfree(a)
+#endif
+
+ void *ptr, *junk;
+
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,0) &amp;lt; 0) {
+ croak("Type error in ptrfree. Argument is not a valid pointer value.");
+ return;
+ }
+
+ /* Check to see if this pointer is a char ** */
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;junk,SWIG_POINTER_char_pp) >= 0) {
+ char **c = (char **) ptr;
+ if (c) {
+ int i = 0;
+ while (c[i]) {
+ free(c[i]);
+ i++;
+ }
+ }
+ }
+ if (ptr)
+ free((char *) ptr);
+}
+
+ </swigxml:code>
+ </swig:insert>
+ <swig:typemap name="ptr" >
+ <swigxml:code >
+{
+ $target = $source;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="value" >
+ <swigxml:code >
+{
+ $target = $source;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrcast" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrvalue" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrcreate" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptradd" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrset" >
+ <swigxml:code >
+{
+ if ($source == -1) return NULL;
+} </swigxml:code>
+ <swigxml:method string="ret" />
+ <swigxml:type string="int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <c:function name="ptrvalue" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:value string="0" />
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="type" >
+ <swigxml:value string="0" />
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="p.SV" />
+ </c:function>
+ <c:function name="ptrset" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="value" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:value string="0" />
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="type" >
+ <swigxml:value string="0" />
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ptrcreate" >
+ <swigxml:parms >
+ <swigxml:parm name="type" >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ <swigxml:parm name="value" >
+ <swigxml:value string="0" />
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="nitems" >
+ <swigxml:value string="1" />
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="p.SV" />
+ </c:function>
+ <c:function name="ptrfree" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ptradd" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="offset" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="p.SV" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="../../Lib/xml/typemaps.i" >
+ <swigxml:child >
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (double) SvNV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="float" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (float) SvNV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (int) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (short) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (long) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned int) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned short) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned long) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned char) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="float" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setnv($target,(double) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setnv($target,(double) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.int" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.short" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.long" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned short" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned long" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned char" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.float" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.double" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.int" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.short" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.long" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned short" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned long" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned char" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.float" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.double" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if ((!SvNOK(tempsv)) &amp;&amp; (!SvIOK(tempsv))) {
+ printf("Received %d\n", SvTYPE(tempsv));
+ croak("Expected a double reference.");
+ }
+ dvalue = SvNV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="float" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if ((!SvNOK(tempsv)) &amp;&amp; (!SvIOK(tempsv))) {
+ croak("expected a double reference");
+ }
+ dvalue = (float) SvNV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (short) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (long) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (unsigned int) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="unsigned short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (unsigned short) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="unsigned long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (unsigned long) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setnv(tempsv, (double) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setnv(tempsv, (double) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ <c:function name="sub" >
+ <swigxml:parms >
+ <swigxml:parm name="INPUT" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="INPUT" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="OUTPUT" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:apply name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:none name="r" >
+ <swigxml:type string="p.int" />
+ </swigxml:none>
+ </swigxml:parms>
+ <swigxml:type string="p.int" />
+ </swig:apply>
+ <c:function name="divide" >
+ <swigxml:parms >
+ <swigxml:parm name="n" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="d" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_apply.i b/trunk/Examples/xml/example_apply.i
new file mode 100644
index 000000000..2ed2b5bbf
--- /dev/null
+++ b/trunk/Examples/xml/example_apply.i
@@ -0,0 +1,23 @@
+/* File : example.i */
+%module example
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include pointer.i
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/trunk/Examples/xml/example_const.expected-xml b/trunk/Examples/xml/example_const.expected-xml
new file mode 100644
index 000000000..eee768cde
--- /dev/null
+++ b/trunk/Examples/xml/example_const.expected-xml
@@ -0,0 +1,51 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_const.i" >
+ <swigxml:child >
+ <swig:module name="example" />
+ <swig:constant name="ICONST" >
+ <swigxml:value string="42" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="FCONST" >
+ <swigxml:value string="2.1828" />
+ <swigxml:type string="double" />
+ </swig:constant>
+ <swig:constant name="CCONST" >
+ <swigxml:value string="x" />
+ <swigxml:type string="char" />
+ </swig:constant>
+ <swig:constant name="CCONST2" >
+ <swigxml:value string="\n" />
+ <swigxml:type string="char" />
+ </swig:constant>
+ <swig:constant name="SCONST" >
+ <swigxml:value string="Hello World" />
+ <swigxml:type string="p.char" />
+ </swig:constant>
+ <swig:constant name="SCONST2" >
+ <swigxml:value string="\&quot;Hello World\&quot;" />
+ <swigxml:type string="p.char" />
+ </swig:constant>
+ <swig:constant name="EXPR" >
+ <swigxml:value string="42+3*(2.1828)" />
+ <swigxml:type string="double" />
+ </swig:constant>
+ <c:variable name="iconst" >
+ <swigxml:value string="37" />
+ <swigxml:type string="q(const).int" />
+ </c:variable>
+ <c:variable name="fconst" >
+ <swigxml:value string="3.14" />
+ <swigxml:type string="q(const).double" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_const.i b/trunk/Examples/xml/example_const.i
new file mode 100644
index 000000000..29a1a7f11
--- /dev/null
+++ b/trunk/Examples/xml/example_const.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 */
+const int iconst = 37;
+const double fconst = 3.14;
+
+
diff --git a/trunk/Examples/xml/example_gif.expected-xml b/trunk/Examples/xml/example_gif.expected-xml
new file mode 100644
index 000000000..3b21b8e01
--- /dev/null
+++ b/trunk/Examples/xml/example_gif.expected-xml
@@ -0,0 +1,2338 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_gif.i" >
+ <swigxml:child >
+ <c:typedef name="Pixel" >
+ <swigxml:type string="unsigned char" />
+ </c:typedef>
+ <c:typedef name="Zvalue" >
+ <swigxml:type string="float" />
+ </c:typedef>
+ <c:class name="ColorMap" >
+ <swigxml:child >
+ <c:variable name="cmap" >
+ <swigxml:type string="p.unsigned char" />
+ </c:variable>
+ <c:variable name="name" >
+ <swigxml:type string="p.char" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="ColorMap" />
+ <swigxml:altname string="ColorMap" />
+ </c:class>
+ <c:typedef name="ColorMap" >
+ <swigxml:type string="ColorMap" />
+ </c:typedef>
+ <c:function name="new_ColorMap" >
+ <swigxml:parms >
+ <swigxml:parm name="filename" >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.ColorMap" />
+ </c:function>
+ <c:function name="delete_ColorMap" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ColorMap_default" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ColorMap_assign" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="g" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="b" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ColorMap_getitem" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:function>
+ <c:function name="ColorMap_setitem" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="value" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ColorMap_write" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ <swigxml:parm name="filename" >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:function>
+ <swig:constant name="BLACK" >
+ <swigxml:value string="0" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="WHITE" >
+ <swigxml:value string="1" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="RED" >
+ <swigxml:value string="2" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="GREEN" >
+ <swigxml:value string="3" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="BLUE" >
+ <swigxml:value string="4" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="YELLOW" >
+ <swigxml:value string="5" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="CYAN" >
+ <swigxml:value string="6" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="MAGENTA" >
+ <swigxml:value string="7" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <c:class name="FrameBuffer" >
+ <swigxml:child >
+ <c:variable name="pixels" >
+ <swigxml:type string="p.p.Pixel" />
+ </c:variable>
+ <c:variable name="zbuffer" >
+ <swigxml:type string="p.p.Zvalue" />
+ </c:variable>
+ <c:variable name="height" >
+ <swigxml:type string="unsigned int" />
+ </c:variable>
+ <c:variable name="width" >
+ <swigxml:type string="unsigned int" />
+ </c:variable>
+ <c:variable name="xmin" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="ymin" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="xmax" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="ymax" >
+ <swigxml:type string="int" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="FrameBuffer" />
+ <swigxml:altname string="FrameBuffer" />
+ </c:class>
+ <c:typedef name="FrameBuffer" >
+ <swigxml:type string="FrameBuffer" />
+ </c:typedef>
+ <swig:constant name="ZMIN" >
+ <swigxml:value string="1e+36" />
+ <swigxml:type string="double" />
+ </swig:constant>
+ <c:function name="new_FrameBuffer" >
+ <swigxml:parms >
+ <swigxml:parm name="width" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ <swigxml:parm name="height" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.FrameBuffer" />
+ </c:function>
+ <c:function name="delete_FrameBuffer" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_resize" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="width" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="height" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:function>
+ <c:function name="FrameBuffer_clear" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_plot" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_horizontal" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="xmin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="xmax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_horizontalinterp" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="xmin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="xmax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_vertical" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="ymin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="ymax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_box" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_solidbox" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_interpbox" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c3" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c4" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_circle" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="radius" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_solidcircle" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="radius" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_line" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_setclip" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="xmin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="ymin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="xmax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="ymax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_noclip" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_makeGIF" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="cmap" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ <swigxml:parm name="buffer" >
+ <swigxml:type string="p.void" />
+ </swigxml:parm>
+ <swigxml:parm name="maxsize" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:function>
+ <c:function name="FrameBuffer_writeGIF" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="p.ColorMap" />
+ </swigxml:parm>
+ <swigxml:parm name="filename" >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:function>
+ <c:function name="FrameBuffer_zresize" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="width" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="height" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_zclear" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_solidtriangle" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_interptriangle" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="tx1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="ty1" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="tx2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="ty2" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="tx3" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="ty3" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c3" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:constant name="HORIZONTAL" >
+ <swigxml:value string="1" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="VERTICAL" >
+ <swigxml:value string="2" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <c:function name="FrameBuffer_drawchar" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="fgcolor" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="bgcolor" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="chr" >
+ <swigxml:type string="char" />
+ </swigxml:parm>
+ <swigxml:parm name="orientation" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_drawstring" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="fgcolor" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="bgcolor" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="text" >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ <swigxml:parm name="orientation" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:class name="PixMap" >
+ <swigxml:child >
+ <c:variable name="width" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="height" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="centerx" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="centery" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="map" >
+ <swigxml:type string="p.int" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="PixMap" />
+ <swigxml:altname string="PixMap" />
+ </c:class>
+ <c:typedef name="PixMap" >
+ <swigxml:type string="PixMap" />
+ </c:typedef>
+ <c:function name="new_PixMap" >
+ <swigxml:parms >
+ <swigxml:parm name="width" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="height" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="centerx" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="centery" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.PixMap" />
+ </c:function>
+ <c:function name="delete_PixMap" >
+ <swigxml:parms >
+ <swigxml:parm name="pm" >
+ <swigxml:type string="p.PixMap" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="PixMap_set" >
+ <swigxml:parms >
+ <swigxml:parm name="pm" >
+ <swigxml:type string="p.PixMap" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="pix" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="FrameBuffer_drawpixmap" >
+ <swigxml:parms >
+ <swigxml:parm name="f" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="pm" >
+ <swigxml:type string="p.PixMap" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="fgcolor" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="bgcolor" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:constant name="TRANSPARENT" >
+ <swigxml:value string="0" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="FOREGROUND" >
+ <swigxml:value string="1" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="BACKGROUND" >
+ <swigxml:value string="2" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <c:class name="Plot2D" >
+ <swigxml:child >
+ <c:variable name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </c:variable>
+ <c:variable name="view_xmin" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="view_ymin" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="view_xmax" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="view_ymax" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="xmin" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ymin" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="xmax" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ymax" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="xscale" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="yscale" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="dx" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="dy" >
+ <swigxml:type string="double" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="Plot2D" />
+ <swigxml:altname string="Plot2D" />
+ </c:class>
+ <c:typedef name="Plot2D" >
+ <swigxml:type string="Plot2D" />
+ </c:typedef>
+ <c:function name="new_Plot2D" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="xmin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ymin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="xmax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ymax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.Plot2D" />
+ </c:function>
+ <c:function name="delete_Plot2D" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_copy" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.Plot2D" />
+ </c:function>
+ <c:function name="Plot2D_clear" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_setview" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="vxmin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="vymin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="vxmax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="vymax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_setrange" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="xmin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ymin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="xmax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ymax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_setscale" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="xscale" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="yscale" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_plot" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_box" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_solidbox" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_interpbox" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c3" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="c4" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_circle" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="radius" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_solidcircle" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="radius" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_line" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_start" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_drawpixmap" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="pm" >
+ <swigxml:type string="p.PixMap" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="bgcolor" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_xaxis" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="xtick" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ticklength" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_yaxis" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ytick" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ticklength" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_triangle" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_solidtriangle" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot2D_interptriangle" >
+ <swigxml:parms >
+ <swigxml:parm name="p2" >
+ <swigxml:type string="p.Plot2D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c3" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:constant name="LINEAR" >
+ <swigxml:value string="10" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <swig:constant name="LOG" >
+ <swigxml:value string="11" />
+ <swigxml:type string="int" />
+ </swig:constant>
+ <c:typedef name="Matrix" >
+ <swigxml:type string="p.double" />
+ </c:typedef>
+ <c:class name="GL_Vector" >
+ <swigxml:child >
+ <c:variable name="x" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="y" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="z" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="w" >
+ <swigxml:type string="double" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="GL_Vector" />
+ <swigxml:altname string="GL_Vector" />
+ </c:class>
+ <c:typedef name="GL_Vector" >
+ <swigxml:type string="GL_Vector" />
+ </c:typedef>
+ <c:function name="new_Matrix" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="Matrix" />
+ </c:function>
+ <c:function name="delete_Matrix" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_copy" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="Matrix" />
+ </c:function>
+ <c:function name="Matrix_multiply" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="b" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_identity" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_zero" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_transpose" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="result" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_invert" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="inva" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_transform" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="p.GL_Vector" />
+ </swigxml:parm>
+ <swigxml:parm name="t" >
+ <swigxml:type string="p.GL_Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_transform4" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="rx" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ry" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="rz" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="rw" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="t" >
+ <swigxml:type string="p.GL_Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_print" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_translate" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="tx" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ty" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="tz" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_rotatex" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_rotatey" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Matrix_rotatez" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Matrix" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:class name="Plot3D" >
+ <swigxml:child >
+ <c:variable name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </c:variable>
+ <c:variable name="view_xmin" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="view_ymin" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="view_xmax" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="view_ymax" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="xmin" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ymin" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="zmin" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="xmax" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ymax" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="zmax" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="xcenter" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ycenter" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="zcenter" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="fovy" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="aspect" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="znear" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="zfar" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="center_mat" >
+ <swigxml:type string="Matrix" />
+ </c:variable>
+ <c:variable name="model_mat" >
+ <swigxml:type string="Matrix" />
+ </c:variable>
+ <c:variable name="view_mat" >
+ <swigxml:type string="Matrix" />
+ </c:variable>
+ <c:variable name="fullmodel_mat" >
+ <swigxml:type string="Matrix" />
+ </c:variable>
+ <c:variable name="trans_mat" >
+ <swigxml:type string="Matrix" />
+ </c:variable>
+ <c:variable name="lookatz" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="xshift" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="yshift" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="zoom" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="width" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="height" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="pers_mode" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="ortho_left" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ortho_right" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ortho_bottom" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="ortho_top" >
+ <swigxml:type string="double" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="Plot3D" />
+ <swigxml:altname string="Plot3D" />
+ </c:class>
+ <c:typedef name="Plot3D" >
+ <swigxml:type string="Plot3D" />
+ </c:typedef>
+ <c:function name="new_Plot3D" >
+ <swigxml:parms >
+ <swigxml:parm name="frame" >
+ <swigxml:type string="p.FrameBuffer" />
+ </swigxml:parm>
+ <swigxml:parm name="xmin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ymin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="zmin" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="xmax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="ymax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="zmax" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.Plot3D" />
+ </c:function>
+ <c:function name="delete_Plot3D" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_copy" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.Plot3D" />
+ </c:function>
+ <c:function name="Plot3D_clear" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="Color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_perspective" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="fovy" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="znear" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="zfar" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_ortho" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="left" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="right" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="top" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="bottom" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_lookat" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="z" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_autoperspective" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="fovy" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_autoortho" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotx" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_roty" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotz" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotl" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotr" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotd" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotu" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_rotc" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="deg" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_zoom" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="percent" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_left" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="percent" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_right" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="percent" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_down" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="percent" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_up" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="percent" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_center" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="cx" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="cy" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_plot" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="Color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_setview" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="vxmin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="vymin" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="vxmax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="vymax" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_start" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_line" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_triangle" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_solidtriangle" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_interptriangle" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c3" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_quad" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_solidquad" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="x4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="color" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_interpquad" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z1" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c1" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z2" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c2" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z3" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c3" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="x4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z4" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c4" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_solidsphere" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="radius" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="Plot3D_outlinesphere" >
+ <swigxml:parms >
+ <swigxml:parm name="p3" >
+ <swigxml:type string="p.Plot3D" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="radius" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="c" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ <swigxml:parm name="bc" >
+ <swigxml:type string="Pixel" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="void" />
+ </c:function>
+ <c:variable name="PixMap_SQUARE" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="PixMap" />
+ </c:variable>
+ <c:variable name="PixMap_TRIANGLE" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="PixMap" />
+ </c:variable>
+ <c:variable name="PixMap_CROSS" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="PixMap" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_inl.expected-xml b/trunk/Examples/xml/example_inl.expected-xml
new file mode 100644
index 000000000..6f83cfd7a
--- /dev/null
+++ b/trunk/Examples/xml/example_inl.expected-xml
@@ -0,0 +1,104 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_inl.i" >
+ <swigxml:child >
+ <swig:module name="example" />
+ <swig:insert >
+ <swigxml:code >
+
+#include "example.h"
+ </swigxml:code>
+ </swig:insert>
+ <c:function name="dot_product" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Vector" />
+ </swigxml:parm>
+ <swigxml:parm name="b" >
+ <swigxml:type string="Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="double" />
+ </c:function>
+ <c:function name="vector_add" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="Vector" />
+ </swigxml:parm>
+ <swigxml:parm name="b" >
+ <swigxml:type string="Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="Vector" />
+ </c:function>
+ <c:function name="free" >
+ <swigxml:parms >
+ <swigxml:parm >
+ <swigxml:type string="p.void" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:insert >
+ <swigxml:code >
+
+
+Vector *new_Vector(double x, double y, double z) {
+ Vector *v = (Vector *) malloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+}
+
+void vector_print(Vector *v) {
+ printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+ </swigxml:code>
+ </swig:insert>
+ <c:function name="new_Vector" >
+ <swigxml:parms >
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ Vector *v = (Vector *) malloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+} </swigxml:code>
+ <swigxml:type string="p.Vector" />
+ </c:function>
+ <c:function name="vector_print" >
+ <swigxml:parms >
+ <swigxml:parm name="v" >
+ <swigxml:type string="p.Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+} </swigxml:code>
+ <swigxml:type string="void" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_inl.h b/trunk/Examples/xml/example_inl.h
new file mode 100644
index 000000000..212cf4bdb
--- /dev/null
+++ b/trunk/Examples/xml/example_inl.h
@@ -0,0 +1,5 @@
+/* File : example.h */
+
+typedef struct {
+ double x, y, z;
+} Vector;
diff --git a/trunk/Examples/xml/example_inl.i b/trunk/Examples/xml/example_inl.i
new file mode 100644
index 000000000..39e4905d5
--- /dev/null
+++ b/trunk/Examples/xml/example_inl.i
@@ -0,0 +1,30 @@
+// Tests SWIG's handling of pass-by-value for complex datatypes
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Some functions that manipulate Vectors by value */
+extern double dot_product(Vector a, Vector b);
+extern Vector vector_add(Vector a, Vector b);
+
+/* Include this because the vector_add() function will leak memory */
+void free(void *);
+
+/* Some helper functions for our interface */
+%inline %{
+
+Vector *new_Vector(double x, double y, double z) {
+ Vector *v = (Vector *) malloc(sizeof(Vector));
+ v->x = x;
+ v->y = y;
+ v->z = z;
+ return v;
+}
+
+void vector_print(Vector *v) {
+ printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+}
+%}
+
diff --git a/trunk/Examples/xml/example_p5.expected-xml b/trunk/Examples/xml/example_p5.expected-xml
new file mode 100644
index 000000000..15dc20546
--- /dev/null
+++ b/trunk/Examples/xml/example_p5.expected-xml
@@ -0,0 +1,24 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_p5.i" >
+ <swigxml:child >
+ <swig:module name="example" />
+ <swig:insert >
+ <swigxml:code >
+
+#include "example.h"
+ </swigxml:code>
+ </swig:insert>
+ <swig:file name="example.h" >
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_p5.i b/trunk/Examples/xml/example_p5.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/trunk/Examples/xml/example_p5.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/trunk/Examples/xml/example_ro.expected-xml b/trunk/Examples/xml/example_ro.expected-xml
new file mode 100644
index 000000000..d4a0661c0
--- /dev/null
+++ b/trunk/Examples/xml/example_ro.expected-xml
@@ -0,0 +1,23 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_ro.i" >
+ <swigxml:child >
+ <swig:pragma name="readonly" />
+ <c:variable name="status" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="path" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="a(256).char" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_ro.i b/trunk/Examples/xml/example_ro.i
new file mode 100644
index 000000000..23bd1a8e4
--- /dev/null
+++ b/trunk/Examples/xml/example_ro.i
@@ -0,0 +1,6 @@
+/* File : example.i */
+%readonly
+extern int status;
+extern char path[256];
+
+
diff --git a/trunk/Examples/xml/example_title_add.expected-xml b/trunk/Examples/xml/example_title_add.expected-xml
new file mode 100644
index 000000000..5aed72972
--- /dev/null
+++ b/trunk/Examples/xml/example_title_add.expected-xml
@@ -0,0 +1,119 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_title_add.i" >
+ <swigxml:child >
+ <swig:module name="example" />
+ <swig:insert >
+ <swigxml:code >
+
+#include "example.h"
+ </swigxml:code>
+ </swig:insert>
+ <c:class name="Vector" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:function name="Vector" >
+ <swigxml:parms >
+ <swigxml:parm name="x" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ <swigxml:parm name="z" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="int" />
+ </c:function>
+ <c:destructor name="Vector" />
+ <c:function name="print" >
+ <swigxml:type string="p.char" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:classtype string="class" />
+ <swigxml:namespace string="Vector" />
+ </c:class>
+ <swig:insert >
+ <swigxml:code >
+
+Vector addv(Vector &amp;a, Vector &amp;b) {
+ return a+b;
+}
+ </swigxml:code>
+ </swig:insert>
+ <c:function name="addv" >
+ <swigxml:parms >
+ <swigxml:parm name="a" >
+ <swigxml:type string="r.Vector" />
+ </swigxml:parm>
+ <swigxml:parm name="b" >
+ <swigxml:type string="r.Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ return a+b;
+} </swigxml:code>
+ <swigxml:type string="Vector" />
+ </c:function>
+ <c:class name="VectorArray" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:function name="VectorArray" >
+ <swigxml:parms >
+ <swigxml:parm name="maxsize" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="int" />
+ </c:function>
+ <c:destructor name="VectorArray" />
+ <c:function name="size" >
+ <swigxml:type string="int" />
+ </c:function>
+ <swig:addmethods >
+ <swigxml:child >
+ <c:function name="get" >
+ <swigxml:parms >
+ <swigxml:parm name="index" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ return (*self)[index];
+ } </swigxml:code>
+ <swigxml:type string="r.Vector" />
+ </c:function>
+ <c:function name="set" >
+ <swigxml:parms >
+ <swigxml:parm name="index" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="a" >
+ <swigxml:type string="r.Vector" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ (*self)[index] = a;
+ } </swigxml:code>
+ <swigxml:type string="void" />
+ </c:function>
+ </swigxml:child>
+ </swig:addmethods>
+ </swigxml:child>
+ <swigxml:classtype string="class" />
+ <swigxml:namespace string="VectorArray" />
+ </c:class>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_title_add.i b/trunk/Examples/xml/example_title_add.i
new file mode 100644
index 000000000..33209191c
--- /dev/null
+++ b/trunk/Examples/xml/example_title_add.i
@@ -0,0 +1,47 @@
+/* File : example.i */
+%title "Matrix and vector package"
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *print();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %addmethods {
+ Vector &get(int index) {
+ return (*self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*self)[index] = a;
+ }
+ }
+};
+
+
+
+
diff --git a/trunk/Examples/xml/example_xml.expected-xml b/trunk/Examples/xml/example_xml.expected-xml
new file mode 100644
index 000000000..584e468f6
--- /dev/null
+++ b/trunk/Examples/xml/example_xml.expected-xml
@@ -0,0 +1,1624 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="example_xml.i" >
+ <swigxml:child >
+ <swig:module name="my_example" />
+ <c:enum name="color" >
+ <swigxml:child >
+ <c:enumvalue name="RED" >
+ <swigxml:value string="RED" />
+ </c:enumvalue>
+ <c:enumvalue name="BLUE" />
+ <c:enumvalue name="GREEN" />
+ </swigxml:child>
+ </c:enum>
+ <c:class name="Foo" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:function name="Foo" >
+ <swigxml:code >
+{ } </swigxml:code>
+ <swigxml:type string="int" />
+ </c:function>
+ <c:enum name="speed" >
+ <swigxml:child >
+ <c:enumvalue name="IMPULSE" />
+ <c:enumvalue name="WARP" />
+ <c:enumvalue name="LUDICROUS" />
+ </swigxml:child>
+ </c:enum>
+ <c:function name="enum_test" >
+ <swigxml:parms >
+ <swigxml:parm name="s" >
+ <swigxml:type string="speed" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:classtype string="class" />
+ <swigxml:namespace string="Foo" />
+ </c:class>
+ <c:function name="enum_test" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="color" />
+ </swigxml:parm>
+ <swigxml:parm name="s" >
+ <swigxml:type string="Foo::speed" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:file name="../../Lib/pointer.i" >
+ <swigxml:child >
+ <swig:module name="pointer" />
+ <swig:insert >
+ <swigxml:code >
+
+%include pointer.i
+
+The pointer.i library provides run-time support for managing and
+manipulating a variety of C/C++ pointer values. In particular,
+you can create various kinds of objects and dereference common
+pointer types. This is done through a common set of functions:
+
+ ptrvalue - Dereferences a pointer
+ ptrset - Set the value of an object referenced by
+ a pointer.
+ ptrcreate - Create a new object and return a pointer.
+ ptrfree - Free the memory allocated by ptrcreate.
+ ptradd - Increment/decrement a pointer value.
+
+When creating, dereferencing, or setting the value of pointer
+variable, only the common C datatypes of int, short, long, float,
+double, char, and char * are currently supported. Other
+datatypes may generate an error.
+
+One of the more interesting aspects of this library is that
+it operates with a wide range of datatypes. For example,
+the "ptrvalue" function can dereference "double *", "int *",
+"long *", "char *", and other datatypes. Since SWIG encodes
+pointers with type information, this can be done transparently
+and in most cases, you can dereference a pointer without
+ever knowing what type it actually is.
+
+This library is primarily designed for utility, not high
+performance (the dynamic determination of pointer types takes
+more work than most normal wrapper functions). As a result,
+you may achieve better performance by writing customized
+"helper" functions if you're making lots of calls to these
+functions in inner loops or other intensive operations.
+ </swigxml:code>
+ <swigxml:section string="doc" />
+ </swig:insert>
+ <swig:types >
+ <swigxml:parms >
+ <swigxml:parm >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.short" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.long" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.float" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.double" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.p.char" />
+ </swigxml:parm>
+ <swigxml:parm >
+ <swigxml:type string="p.void" />
+ </swigxml:parm>
+ </swigxml:parms>
+ </swig:types>
+ <swig:file name="../../Lib/xml/ptrlang.i" >
+ <swigxml:child >
+ <swig:insert >
+ <swigxml:code >
+
+#include &amp;lt;ctype.h>
+
+/* Types used by the library */
+static swig_type_info *SWIG_POINTER_int_p = 0;
+static swig_type_info *SWIG_POINTER_short_p =0;
+static swig_type_info *SWIG_POINTER_long_p = 0;
+static swig_type_info *SWIG_POINTER_float_p = 0;
+static swig_type_info *SWIG_POINTER_double_p = 0;
+static swig_type_info *SWIG_POINTER_char_p = 0;
+static swig_type_info *SWIG_POINTER_char_pp = 0;
+static swig_type_info *SWIG_POINTER_void_p = 0;
+ </swigxml:code>
+ </swig:insert>
+ <swig:insert >
+ <swigxml:code >
+
+ SWIG_POINTER_int_p = SWIG_TypeQuery("int *");
+ SWIG_POINTER_short_p = SWIG_TypeQuery("short *");
+ SWIG_POINTER_long_p = SWIG_TypeQuery("long *");
+ SWIG_POINTER_float_p = SWIG_TypeQuery("float *");
+ SWIG_POINTER_double_p = SWIG_TypeQuery("double *");
+ SWIG_POINTER_char_p = SWIG_TypeQuery("char *");
+ SWIG_POINTER_char_pp = SWIG_TypeQuery("char **");
+ SWIG_POINTER_void_p = SWIG_TypeQuery("void *");
+ </swigxml:code>
+ <swigxml:section string="init" />
+ </swig:insert>
+ <swig:insert >
+ <swigxml:code >
+
+
+/* #ifdef WIN32
+#undef isspace
+#define isspace(c) (c == ' ')
+#endif
+*/
+
+/*------------------------------------------------------------------
+ ptrvalue(ptr,type = 0)
+
+ Attempts to dereference a pointer value. If type is given, it
+ will try to use that type. Otherwise, this function will attempt
+ to "guess" the proper datatype by checking against all of the
+ builtin C datatypes.
+ ------------------------------------------------------------------ */
+
+#ifdef PERL_OBJECT
+static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, char *type) {
+#define ptrvalue(a,b,c) _ptrvalue(pPerl,a,b,c)
+#else
+static SV *_ptrvalue(SV *_PTRVALUE, int index, char *type) {
+#define ptrvalue(a,b,c) _ptrvalue(a,b,c)
+#endif
+
+ void *ptr;
+ SV *obj = 0;
+
+ if (SWIG_ConvertPtr(_PTRVALUE, &amp;ptr, 0) &amp;lt; 0) {
+ croak("Type error it ptrvalue. Argument is not a valid pointer value.");
+ } else {
+ /* If no datatype was passed, try a few common datatypes first */
+ if (!type) {
+
+ /* No datatype was passed. Type to figure out if it's a common one */
+
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_int_p) >= 0) {
+ type = "int";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_double_p) >= 0) {
+ type = "double";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_short_p) >= 0) {
+ type = "short";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_long_p) >= 0) {
+ type = "long";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_float_p) >= 0) {
+ type = "float";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_p) >= 0) {
+ type = "char";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_pp) >= 0) {
+ type = "char *";
+ } else {
+ type = "unknown";
+ }
+ }
+
+ if (!ptr) {
+ croak("Unable to dereference NULL pointer.");
+ return 0;
+ }
+
+ /* Now we have a datatype. Try to figure out what to do about it */
+ if (strcmp(type,"int") == 0) {
+ obj = sv_newmortal();
+ sv_setiv(obj,(IV) *(((int *) ptr) + index));
+ } else if (strcmp(type,"double") == 0) {
+ obj = sv_newmortal();
+ sv_setnv(obj,(double) *(((double *) ptr)+index));
+ } else if (strcmp(type,"short") == 0) {
+ obj = sv_newmortal();
+ sv_setiv(obj,(IV) *(((short *) ptr) + index));
+ } else if (strcmp(type,"long") == 0) {
+ obj = sv_newmortal();
+ sv_setiv(obj,(IV) *(((long *) ptr) + index));
+ } else if (strcmp(type,"float") == 0) {
+ obj = sv_newmortal();
+ sv_setnv(obj,(double) *(((float *) ptr)+index));
+ } else if (strcmp(type,"char") == 0) {
+ obj = sv_newmortal();
+ sv_setpv(obj,((char *) ptr)+index);
+ } else if (strcmp(type,"char *") == 0) {
+ char *c = *(((char **) ptr)+index);
+ obj = sv_newmortal();
+ if (c)
+ sv_setpv(obj,c);
+ else
+ sv_setpv(obj,"NULL");
+ } else {
+ croak("Unable to dereference unsupported datatype.");
+ obj = 0;
+ }
+ }
+ return obj;
+}
+
+/*------------------------------------------------------------------
+ ptrcreate(type,value = 0,numelements = 1)
+
+ Attempts to create a new object of given type. Type must be
+ a basic C datatype. Will not create complex objects.
+ ------------------------------------------------------------------ */
+#ifdef PERL_OBJECT
+static SV *_ptrcreate(CPerlObj *pPerl, char *type, SV *value, int numelements) {
+#define ptrcreate(a,b,c) _ptrcreate(pPerl,a,b,c)
+#else
+static SV *_ptrcreate(char *type, SV *value, int numelements) {
+#define ptrcreate(a,b,c) _ptrcreate(a,b,c)
+#endif
+
+ void *ptr;
+ SV *obj;
+ int sz;
+ swig_type_info *cast = 0;
+
+ /* Check the type string against a variety of possibilities */
+
+ if (strcmp(type,"int") == 0) {
+ sz = sizeof(int)*numelements;
+ cast = SWIG_POINTER_int_p;
+ } else if (strcmp(type,"short") == 0) {
+ sz = sizeof(short)*numelements;
+ cast = SWIG_POINTER_short_p;
+ } else if (strcmp(type,"long") == 0) {
+ sz = sizeof(long)*numelements;
+ cast = SWIG_POINTER_long_p;
+ } else if (strcmp(type,"double") == 0) {
+ sz = sizeof(double)*numelements;
+ cast = SWIG_POINTER_double_p;
+ } else if (strcmp(type,"float") == 0) {
+ sz = sizeof(float)*numelements;
+ cast = SWIG_POINTER_float_p;
+ } else if (strcmp(type,"char") == 0) {
+ sz = sizeof(char)*numelements;
+ cast = SWIG_POINTER_char_p;
+ } else if (strcmp(type,"char *") == 0) {
+ sz = sizeof(char *)*(numelements+1);
+ cast = SWIG_POINTER_char_pp;
+ } else if (strcmp(type,"void") == 0) {
+ sz = numelements;
+ cast = SWIG_POINTER_void_p;
+ } else {
+ croak("Unable to create unknown datatype.");
+ return 0;
+ }
+
+ /* Create the new object */
+
+ ptr = (void *) malloc(sz);
+ if (!ptr) {
+ croak("Out of memory in ptrcreate.");
+ return 0;
+ }
+
+ /* Now try to set its default value */
+
+ if (value) {
+ if (strcmp(type,"int") == 0) {
+ int *ip,i,ivalue;
+ ivalue = (int) SvIV(value);
+ ip = (int *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"short") == 0) {
+ short *ip,ivalue;
+ int i;
+ ivalue = (short) SvIV(value);
+ ip = (short *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"long") == 0) {
+ long *ip,ivalue;
+ int i;
+ ivalue = (long) SvIV(value);
+ ip = (long *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"double") == 0) {
+ double *ip,ivalue;
+ int i;
+ ivalue = (double) SvNV(value);
+ ip = (double *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"float") == 0) {
+ float *ip,ivalue;
+ int i;
+ ivalue = (float) SvNV(value);
+ ip = (float *) ptr;
+ for (i = 0; i &amp;lt; numelements; i++)
+ ip[i] = ivalue;
+ } else if (strcmp(type,"char") == 0) {
+ char *ip,*ivalue;
+ ivalue = (char *) SvPV(value,PL_na);
+ ip = (char *) ptr;
+ strncpy(ip,ivalue,numelements-1);
+ } else if (strcmp(type,"char *") == 0) {
+ char **ip, *ivalue;
+ int i;
+ ivalue = (char *) SvPV(value,PL_na);
+ ip = (char **) ptr;
+ for (i = 0; i &amp;lt; numelements; i++) {
+ if (ivalue) {
+ ip[i] = (char *) malloc(strlen(ivalue)+1);
+ strcpy(ip[i],ivalue);
+ } else {
+ ip[i] = 0;
+ }
+ }
+ ip[numelements] = 0;
+ }
+ }
+ /* Create the pointer value */
+
+
+ obj = sv_newmortal();
+ SWIG_MakePtr(obj,ptr,cast);
+ return obj;
+}
+
+/*------------------------------------------------------------------
+ ptrset(ptr,value,index = 0,type = 0)
+
+ Attempts to set the value of a pointer variable. If type is
+ given, we will use that type. Otherwise, we'll guess the datatype.
+ ------------------------------------------------------------------ */
+
+#ifdef PERL_OBJECT
+static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, char *type) {
+#define ptrset(a,b,c,d) _ptrset(pPerl,a,b,c,d)
+#else
+static void _ptrset(SV *_PTRVALUE, SV *value, int index, char *type) {
+#define ptrset(a,b,c,d) _ptrset(a,b,c,d)
+#endif
+ void *ptr;
+ SV *obj;
+
+
+ if (SWIG_ConvertPtr(_PTRVALUE, &amp;ptr, 0) &amp;lt; 0) {
+ croak("Type error it ptrvalue. Argument is not a valid pointer value.");
+ } else {
+ /* If no datatype was passed, try a few common datatypes first */
+ if (!type) {
+ /* No datatype was passed. Type to figure out if it's a common one */
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_int_p) >= 0) {
+ type = "int";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_double_p) >= 0) {
+ type = "double";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_short_p) >= 0) {
+ type = "short";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_long_p) >= 0) {
+ type = "long";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_float_p) >= 0) {
+ type = "float";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_p) >= 0) {
+ type = "char";
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_pp) >= 0) {
+ type = "char *";
+ } else {
+ type = "unknown";
+ }
+ }
+ }
+ if (!ptr) {
+ croak("Unable to set NULL pointer.");
+ return;
+ }
+
+ /* Now we have a datatype. Try to figure out what to do about it */
+ if (strcmp(type,"int") == 0) {
+ *(((int *) ptr)+index) = (int) SvIV(value);
+ } else if (strcmp(type,"double") == 0) {
+ *(((double *) ptr)+index) = (double) SvNV(value);
+ } else if (strcmp(type,"short") == 0) {
+ *(((short *) ptr)+index) = (short) SvIV(value);
+ } else if (strcmp(type,"long") == 0) {
+ *(((long *) ptr)+index) = (long) SvIV(value);
+ } else if (strcmp(type,"float") == 0) {
+ *(((float *) ptr)+index) = (float) SvNV(value);
+ } else if (strcmp(type,"char") == 0) {
+ char *c = SvPV(value,PL_na);
+ strcpy(((char *) ptr)+index, c);
+ } else if (strcmp(type,"char *") == 0) {
+ char *c = SvPV(value,PL_na);
+ char **ca = (char **) ptr;
+ if (ca[index]) free(ca[index]);
+ if (strcmp(c,"NULL") == 0) {
+ ca[index] = 0;
+ } else {
+ ca[index] = (char *) malloc(strlen(c)+1);
+ strcpy(ca[index],c);
+ }
+ } else {
+ croak("Unable to set unsupported datatype.");
+ return;
+ }
+}
+
+/*------------------------------------------------------------------
+ ptradd(ptr,offset)
+
+ Adds a value to an existing pointer value. Will do a type-dependent
+ add for basic datatypes. For other datatypes, will do a byte-add.
+ ------------------------------------------------------------------ */
+
+#ifdef PERL_OBJECT
+static SV *_ptradd(CPerlObj *pPerl, SV *_PTRVALUE, int offset) {
+#define ptradd(a,b) _ptradd(pPerl,a,b)
+#else
+static SV *_ptradd(SV *_PTRVALUE, int offset) {
+#define ptradd(a,b) _ptradd(a,b)
+#endif
+
+ void *ptr,*junk;
+ SV *obj;
+ swig_type_info *type;
+ char *tname;
+
+ /* Try to handle a few common datatypes first */
+
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_int_p) >= 0) {
+ ptr = (void *) (((int *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_double_p) >= 0) {
+ ptr = (void *) (((double *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_short_p) >= 0) {
+ ptr = (void *) (((short *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_long_p) >= 0) {
+ ptr = (void *) (((long *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_float_p) >= 0) {
+ ptr = (void *) (((float *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,SWIG_POINTER_char_p) >= 0) {
+ ptr = (void *) (((char *) ptr) + offset);
+ } else if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,0) >= 0) {
+ ptr = (void *) (((char *) ptr) + offset);
+ } else {
+ croak("Type error in ptradd. Argument is not a valid pointer value.");
+ return 0;
+ }
+ printf("ptradd = %x\n", ptr);
+ tname = HvNAME(SvSTASH(SvRV(_PTRVALUE)));
+ obj = sv_newmortal();
+ sv_setref_pv(obj,tname,ptr);
+ return obj;
+}
+
+/*------------------------------------------------------------------
+ ptrfree(ptr)
+
+ Destroys a pointer value
+ ------------------------------------------------------------------ */
+#ifdef PERL_OBJECT
+void _ptrfree(CPerlObj *pPerl, SV *_PTRVALUE) {
+#define ptrfree(a) _ptrfree(pPerl, a)
+#else
+void _ptrfree(SV *_PTRVALUE) {
+#define ptrfree(a) _ptrfree(a)
+#endif
+
+ void *ptr, *junk;
+
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;ptr,0) &amp;lt; 0) {
+ croak("Type error in ptrfree. Argument is not a valid pointer value.");
+ return;
+ }
+
+ /* Check to see if this pointer is a char ** */
+ if (SWIG_ConvertPtr(_PTRVALUE,&amp;junk,SWIG_POINTER_char_pp) >= 0) {
+ char **c = (char **) ptr;
+ if (c) {
+ int i = 0;
+ while (c[i]) {
+ free(c[i]);
+ i++;
+ }
+ }
+ }
+ if (ptr)
+ free((char *) ptr);
+}
+
+ </swigxml:code>
+ </swig:insert>
+ <swig:typemap name="ptr" >
+ <swigxml:code >
+{
+ $target = $source;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="value" >
+ <swigxml:code >
+{
+ $target = $source;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrcast" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrvalue" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrcreate" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptradd" >
+ <swigxml:code >
+{
+ $target = $source;
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.SV" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="ptrset" >
+ <swigxml:code >
+{
+ if ($source == -1) return NULL;
+} </swigxml:code>
+ <swigxml:method string="ret" />
+ <swigxml:type string="int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <c:function name="ptrvalue" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:value string="0" />
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="type" >
+ <swigxml:value string="0" />
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="p.SV" />
+ </c:function>
+ <c:function name="ptrset" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="value" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="index" >
+ <swigxml:value string="0" />
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ <swigxml:parm name="type" >
+ <swigxml:value string="0" />
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ptrcreate" >
+ <swigxml:parms >
+ <swigxml:parm name="type" >
+ <swigxml:type string="p.char" />
+ </swigxml:parm>
+ <swigxml:parm name="value" >
+ <swigxml:value string="0" />
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="nitems" >
+ <swigxml:value string="1" />
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="p.SV" />
+ </c:function>
+ <c:function name="ptrfree" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="ptradd" >
+ <swigxml:parms >
+ <swigxml:parm name="ptr" >
+ <swigxml:type string="p.SV" />
+ </swigxml:parm>
+ <swigxml:parm name="offset" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="p.SV" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="../../Lib/xml/typemaps.i" >
+ <swigxml:child >
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (double) SvNV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="float" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (float) SvNV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (int) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (short) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (long) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned int) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned short) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned long) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="INPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ temp = (unsigned char) SvIV($source);
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="unsigned char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="float" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:parms >
+ <swigxml:parm name="temp" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ $target = &amp;amp;amp;amp;amp;amp;amp;amp;amp;temp;
+} </swigxml:code>
+ <swigxml:method string="ignore" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setiv($target,(IV) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setnv($target,(double) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="OUTPUT" >
+ <swigxml:code >
+{
+ if (argvi >= items) {
+ EXTEND(sp,1);
+ }
+ $target = sv_newmortal();
+ sv_setnv($target,(double) *($source));
+ argvi++;
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.int" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.short" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.long" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned short" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned long" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned char" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.float" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.double" />
+ <swigxml:method string="in" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="INPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.int" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.short" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.long" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned short" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned long" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.unsigned char" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned char" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.float" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="BOTH" >
+ <swigxml:srctype string="p.double" />
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ <swigxml:srcname string="OUTPUT" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="double" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if ((!SvNOK(tempsv)) &amp;&amp; (!SvIOK(tempsv))) {
+ printf("Received %d\n", SvTYPE(tempsv));
+ croak("Expected a double reference.");
+ }
+ dvalue = SvNV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="float" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if ((!SvNOK(tempsv)) &amp;&amp; (!SvIOK(tempsv))) {
+ croak("expected a double reference");
+ }
+ dvalue = (float) SvNV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (short) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (long) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="unsigned int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (unsigned int) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="unsigned short" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (unsigned short) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:parms >
+ <swigxml:parm name="dvalue" >
+ <swigxml:type string="unsigned long" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:code >
+{
+ SV *tempsv;
+ if (!SvROK($source)) {
+ croak("expected a reference");
+ }
+ tempsv = SvRV($source);
+ if (!SvIOK(tempsv)) {
+ croak("expected a integer reference");
+ }
+ dvalue = (unsigned long) SvIV(tempsv);
+ $target = &amp;dvalue;
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setnv(tempsv, (double) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.double" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setnv(tempsv, (double) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.float" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned int" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned short" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ <swig:typemap name="REFERENCE" >
+ <swigxml:code >
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ sv_setiv(tempsv, (int) *$source);
+} </swigxml:code>
+ <swigxml:method string="argout" />
+ <swigxml:type string="p.unsigned long" />
+ <swigxml:lang string="perl5" />
+ </swig:typemap>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:typemap >
+ <swigxml:code >
+{
+ WHATEVER MAKES YOU HAPPY AS RESULT
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.int" />
+ </swig:typemap>
+ <swig:typemap >
+ <swigxml:code >
+{
+ WHATEVER MAKES YOU HAPPY AS PARAMETER
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ </swig:typemap>
+ <swig:pragma name="DEBUG" >
+ <swigxml:value string="false" />
+ <swigxml:lang string="xml" />
+ </swig:pragma>
+ <c:function name="my_gcd" >
+ <swigxml:parms >
+ <swigxml:parm name="x" >
+ <swigxml:type string="p.q(const).char" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="a().p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="op" >
+ <swigxml:type string="p.f(int,int).int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.int" />
+ </c:function>
+ <c:variable name="my_foo" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:function name="my_void" >
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="my_empty" >
+ <swigxml:type string="int" />
+ </c:function>
+ <c:variable name="my_dutch" >
+ <swigxml:value string="1.0" />
+ <swigxml:type string="q(const).double" />
+ </c:variable>
+ <c:class name="my_union" >
+ <swigxml:child >
+ <c:variable name="my_iii" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="my_ccc" >
+ <swigxml:type string="char" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="union" />
+ <swigxml:namespace string="my_union" />
+ </c:class>
+ <c:class name="my_struct" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:destructor name="my_struct" >
+ <swigxml:storage string="virtual" />
+ </c:destructor>
+ <c:function name="my_foo" >
+ <swigxml:type string="int" />
+ </c:function>
+ <c:access name="protected" />
+ <c:variable name="my_bar" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="x" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="y" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:function name="area" >
+ <swigxml:abstract string="1" />
+ <swigxml:storage string="virtual" />
+ <swigxml:type string="double" />
+ </c:function>
+ <c:variable name="nshapes" >
+ <swigxml:storage string="static" />
+ <swigxml:type string="int" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="my_struct" />
+ </c:class>
+ <c:class name="my_class" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:function name="my_class" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="int" />
+ </c:function>
+ <c:access name="private" />
+ <c:destructor name="my_class" />
+ <c:function name="my_func" >
+ <swigxml:parms >
+ <swigxml:parm >
+ <swigxml:type string="my_class" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="p.p.char" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="a().int" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="r.q(const).int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="virtual" />
+ <swigxml:type string="p.q(const).int" />
+ </c:function>
+ <c:variable name="my_foo" >
+ <swigxml:type string="a(128).double" />
+ </c:variable>
+ <c:variable name="i" >
+ <swigxml:type string="q(const).my_int" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="class" />
+ <swigxml:bases >
+ <swigxml:item name="my_struct" />
+ <swigxml:item name="my_union" />
+ </swigxml:bases>
+ <swigxml:namespace string="my_class" />
+ </c:class>
+ <c:typedef name="my_int" >
+ <swigxml:type string="int" />
+ </c:typedef>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/example_xml.h b/trunk/Examples/xml/example_xml.h
new file mode 100644
index 000000000..849071dd3
--- /dev/null
+++ b/trunk/Examples/xml/example_xml.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/trunk/Examples/xml/example_xml.i b/trunk/Examples/xml/example_xml.i
new file mode 100644
index 000000000..a598b6a42
--- /dev/null
+++ b/trunk/Examples/xml/example_xml.i
@@ -0,0 +1,69 @@
+/* File : example.i */
+%module my_example
+
+enum color { RED=10, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE, WARP, LUDICROUS };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
+
+
+%include pointer.i
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+
+%typemap(out) int * {
+ WHATEVER MAKES YOU HAPPY AS RESULT
+}
+
+%typemap(in) int * {
+ WHATEVER MAKES YOU HAPPY AS PARAMETER
+}
+
+%pragma(xml) DEBUG="false";
+
+extern int * my_gcd(const char * x, int * y[], int * r, int (*op)(int,int)) const;
+extern double my_foo;
+void my_void();
+my_empty();
+
+const double my_dutch = 1.0;
+
+union my_union
+{
+ int my_iii;
+ char my_ccc;
+};
+
+struct my_struct
+{
+public:
+ virtual ~my_struct();
+ int my_foo();
+protected:
+ int my_bar;
+ double x, y;
+ virtual double area() = 0;
+ static int nshapes;
+};
+
+class my_class : public my_struct, public my_union
+{
+public:
+ my_class( char c );
+private:
+ ~my_class();
+ virtual const int * my_func( my_class , char * * x, int y[], const int & r) const;
+ double my_foo[128];
+ const my_int i;
+};
+
+typedef int my_int;
diff --git a/trunk/Examples/xml/gnarly.expected-xml b/trunk/Examples/xml/gnarly.expected-xml
new file mode 100644
index 000000000..da87d8a31
--- /dev/null
+++ b/trunk/Examples/xml/gnarly.expected-xml
@@ -0,0 +1,206 @@
+<swigxml:swig name="namespaces" xmlns:swigxml="http://jniplusplus.sourceforge.net" xmlns:swig="http://swig.sourceforge.net" xmlns:c="http://www.ansi.org" >
+ <swig:top >
+ <swigxml:child >
+ <swig:file name="../../Lib/swig.swg" >
+ <swigxml:type string="include" />
+ </swig:file>
+ <swig:file name="gnarly.i" >
+ <swigxml:child >
+ <swig:module name="my_check" />
+ <c:enum name="color" >
+ <swigxml:child >
+ <c:enumvalue name="RED" >
+ <swigxml:value string="RED" />
+ </c:enumvalue>
+ <c:enumvalue name="BLUE" />
+ <c:enumvalue name="GREEN" />
+ </swigxml:child>
+ </c:enum>
+ <c:class name="Foo" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:function name="Foo" >
+ <swigxml:code >
+{ } </swigxml:code>
+ <swigxml:type string="int" />
+ </c:function>
+ <c:enum name="speed" >
+ <swigxml:child >
+ <c:enumvalue name="IMPULSE" />
+ <c:enumvalue name="WARP" />
+ <c:enumvalue name="LUDICROUS" />
+ </swigxml:child>
+ </c:enum>
+ <c:function name="enum_test" >
+ <swigxml:parms >
+ <swigxml:parm name="s" >
+ <swigxml:type string="speed" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ </swigxml:child>
+ <swigxml:classtype string="class" />
+ <swigxml:namespace string="Foo" />
+ </c:class>
+ <c:function name="enum_test" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="color" />
+ </swigxml:parm>
+ <swigxml:parm name="s" >
+ <swigxml:type string="Foo::speed" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="void" />
+ </c:function>
+ <swig:typemap >
+ <swigxml:code >
+{
+ WHATEVER MAKES YOU HAPPY AS RESULT
+} </swigxml:code>
+ <swigxml:method string="out" />
+ <swigxml:type string="p.int" />
+ </swig:typemap>
+ <swig:typemap >
+ <swigxml:code >
+{
+ WHATEVER MAKES YOU HAPPY AS PARAMETER
+} </swigxml:code>
+ <swigxml:method string="in" />
+ <swigxml:type string="p.int" />
+ </swig:typemap>
+ <swig:pragma name="DEBUG" >
+ <swigxml:value string="false" />
+ <swigxml:lang string="xml" />
+ </swig:pragma>
+ <c:function name="my_gcd" >
+ <swigxml:parms >
+ <swigxml:parm name="x" >
+ <swigxml:type string="p.q(const).char" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="a().p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="p.int" />
+ </swigxml:parm>
+ <swigxml:parm name="op" >
+ <swigxml:type string="p.f(int,int).int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="extern" />
+ <swigxml:type string="p.int" />
+ </c:function>
+ <c:variable name="my_foo" >
+ <swigxml:storage string="extern" />
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:function name="my_void" >
+ <swigxml:type string="void" />
+ </c:function>
+ <c:function name="my_empty" >
+ <swigxml:type string="int" />
+ </c:function>
+ <c:variable name="my_dutch" >
+ <swigxml:value string="1.0" />
+ <swigxml:type string="q(const).double" />
+ </c:variable>
+ <c:class name="my_union" >
+ <swigxml:child >
+ <c:variable name="my_iii" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="my_ccc" >
+ <swigxml:type string="char" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="union" />
+ <swigxml:namespace string="my_union" />
+ </c:class>
+ <c:class name="my_struct" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:destructor name="my_struct" >
+ <swigxml:storage string="virtual" />
+ </c:destructor>
+ <c:function name="my_foo" >
+ <swigxml:type string="int" />
+ </c:function>
+ <c:access name="protected" />
+ <c:variable name="my_bar" >
+ <swigxml:type string="int" />
+ </c:variable>
+ <c:variable name="x" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:variable name="y" >
+ <swigxml:type string="double" />
+ </c:variable>
+ <c:function name="area" >
+ <swigxml:abstract string="1" />
+ <swigxml:storage string="virtual" />
+ <swigxml:type string="double" />
+ </c:function>
+ <c:variable name="nshapes" >
+ <swigxml:storage string="static" />
+ <swigxml:type string="int" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="struct" />
+ <swigxml:namespace string="my_struct" />
+ </c:class>
+ <c:class name="my_class" >
+ <swigxml:child >
+ <c:access name="public" />
+ <c:function name="my_class" >
+ <swigxml:parms >
+ <swigxml:parm name="c" >
+ <swigxml:type string="char" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:type string="int" />
+ </c:function>
+ <c:access name="private" />
+ <c:destructor name="my_class" />
+ <c:function name="my_func" >
+ <swigxml:parms >
+ <swigxml:parm >
+ <swigxml:type string="my_class" />
+ </swigxml:parm>
+ <swigxml:parm name="x" >
+ <swigxml:type string="p.p.char" />
+ </swigxml:parm>
+ <swigxml:parm name="y" >
+ <swigxml:type string="a().int" />
+ </swigxml:parm>
+ <swigxml:parm name="r" >
+ <swigxml:type string="r.q(const).int" />
+ </swigxml:parm>
+ </swigxml:parms>
+ <swigxml:storage string="virtual" />
+ <swigxml:type string="p.q(const).int" />
+ </c:function>
+ <c:variable name="my_foo" >
+ <swigxml:type string="a(128).double" />
+ </c:variable>
+ <c:variable name="i" >
+ <swigxml:type string="q(const).my_int" />
+ </c:variable>
+ </swigxml:child>
+ <swigxml:classtype string="class" />
+ <swigxml:bases >
+ <swigxml:item name="my_struct" />
+ <swigxml:item name="my_union" />
+ </swigxml:bases>
+ <swigxml:namespace string="my_class" />
+ </c:class>
+ <c:typedef name="my_int" >
+ <swigxml:type string="int" />
+ </c:typedef>
+ </swigxml:child>
+ <swigxml:type string="include" />
+ </swig:file>
+ </swigxml:child>
+ </swig:top>
+</swigxml:swig>
diff --git a/trunk/Examples/xml/gnarly.i b/trunk/Examples/xml/gnarly.i
new file mode 100644
index 000000000..47242f8dc
--- /dev/null
+++ b/trunk/Examples/xml/gnarly.i
@@ -0,0 +1,63 @@
+/* File : check.i */
+%module my_check
+
+enum color { RED=10, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE, WARP, LUDICROUS };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
+
+
+%typemap(out) int * {
+ WHATEVER MAKES YOU HAPPY AS RESULT
+}
+
+%typemap(in) int * {
+ WHATEVER MAKES YOU HAPPY AS PARAMETER
+}
+
+%pragma(xml) DEBUG="false";
+
+extern int * my_gcd(const char * x, int * y[], int * r, int (*op)(int,int)) const;
+extern double my_foo;
+void my_void();
+my_empty();
+
+const double my_dutch = 1.0;
+
+union my_union
+{
+ int my_iii;
+ char my_ccc;
+};
+
+struct my_struct
+{
+public:
+ virtual ~my_struct();
+ int my_foo();
+protected:
+ int my_bar;
+ double x, y;
+ virtual double area() = 0;
+ static int nshapes;
+};
+
+class my_class : public my_struct, public my_union
+{
+public:
+ my_class( char c );
+private:
+ ~my_class();
+ virtual const int * my_func( my_class , char * * x, int y[], const int & r) const;
+ double my_foo[128];
+ const my_int i;
+};
+
+typedef int my_int;